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AA,MACA,KAAA,EAAO,EAAE,KAAA,EAAO,MAAA,EAAQ,GAAG,KAAA,EAAM;AAAA,MACjC,aAAA,EAAY,qBAAA;AAAA,MAEZ,QAAA,kBAAA,GAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,GAAA,EAAK,SAAA;AAAA,UACL,GAAA;AAAA,UACA,KAAA,EAAM,qBAAA;AAAA,UACN,KAAA,EAAM,MAAA;AAAA,UACN,MAAA,EAAO,MAAA;AAAA,UACP,WAAA,EAAY,GAAA;AAAA,UACZ,SAAA,EAAU,IAAA;AAAA,UACV,MAAA,EAAQ,UAAA;AAAA,UACR,OAAA,EAAS,WAAA;AAAA,UACT,KAAA,EAAO,EAAE,MAAA,EAAQ,MAAA;AAAO;AAAA;AAC1B;AAAA,GACF;AAEJ,CAAC","file":"profile-edit.mjs","sourcesContent":["/**\n * Theming props for the Profile Edit Widget.\n * These map to CSS custom properties used internally.\n */\nexport interface ProfileEditThemingProps {\n  /** Container background color */\n  profileEditBackgroundColor?: string;\n  /** Primary text color */\n  profileEditTextColor?: string;\n  /** Secondary text color */\n  profileEditSecondaryTextColor?: string;\n  /** Border color */\n  profileEditBorderColor?: string;\n  /** Container border radius, e.g. \"12px\" */\n  profileEditBorderRadius?: string;\n  /** Container padding */\n  profileEditPadding?: string;\n  /** Container box shadow */\n  profileEditShadow?: string;\n  /** Primary accent color */\n  profileEditPrimaryColor?: string;\n  /** Primary hover color */\n  profileEditPrimaryHover?: string;\n  /** Accent color */\n  profileEditAccentColor?: string;\n  /** Card background */\n  profileEditCardBg?: string;\n  /** Card border */\n  profileEditCardBorder?: string;\n  /** Card border radius */\n  profileEditCardRadius?: string;\n  /** Card box shadow */\n  profileEditCardShadow?: string;\n  /** Card padding */\n  profileEditCardPadding?: string;\n  /** Avatar size, e.g. \"80px\" */\n  profileEditAvatarSize?: string;\n  /** Avatar border radius */\n  profileEditAvatarRadius?: string;\n  /** Avatar border */\n  profileEditAvatarBorder?: string;\n  /** Avatar box shadow */\n  profileEditAvatarShadow?: string;\n  /** Button background */\n  profileEditButtonBg?: string;\n  /** Button hover background */\n  profileEditButtonHoverBg?: string;\n  /** Button text color */\n  profileEditButtonColor?: string;\n  /** Button border radius */\n  profileEditButtonRadius?: string;\n  /** Secondary button background */\n  profileEditButtonSecondaryBg?: string;\n  /** Secondary button text color */\n  profileEditButtonSecondaryColor?: string;\n  /** Input background */\n  profileEditInputBg?: string;\n  /** Input border */\n  profileEditInputBorder?: string;\n  /** Input focus border color */\n  profileEditInputFocusBorder?: string;\n  /** Input border radius */\n  profileEditInputRadius?: string;\n  /** Input text color */\n  profileEditInputText?: string;\n  /** Input placeholder color */\n  profileEditInputPlaceholder?: string;\n  /** Font family */\n  profileEditFontFamily?: string;\n  /** Name font size */\n  profileEditNameSize?: string;\n  /** Name font weight */\n  profileEditNameWeight?: string;\n  /** Label font size */\n  profileEditLabelSize?: string;\n  /** Divider color */\n  profileEditDividerColor?: string;\n  /** Transition duration, e.g. \"0.2s\" */\n  profileEditTransitionDuration?: string;\n}\n\n/**\n * Core configuration props for the Profile Edit Widget.\n */\nexport interface ProfileEditWidgetProps extends ProfileEditThemingProps {\n  /** Base URL of the Legion application (required) */\n  baseUrl: string;\n  /** JWT auth token for authenticated profile editing */\n  authToken?: string;\n  /** Theme preset. Default: \"light\" */\n  theme?: \"light\" | \"dark\";\n  /** Widget width CSS value. Default: \"600px\" */\n  width?: string;\n  /** Widget height CSS value. Default: \"800px\" */\n  height?: string;\n  /** Additional CSS class name for the container */\n  className?: string;\n  /** Additional inline styles for the container */\n  style?: React.CSSProperties;\n  /** Callback when the widget iframe has loaded */\n  onLoad?: (detail: { widget: string; theme: string }) => void;\n  /** Callback when the widget iframe fails to load */\n  onError?: (message: string) => void;\n}\n\n/**\n * Mapping from camelCase theming prop names to the kebab-case query\n * parameter names used by the profile-edit widget iframe URL.\n */\nexport const PROFILE_EDIT_THEMING_PROP_TO_PARAM: Record<\n  keyof ProfileEditThemingProps,\n  string\n> = {\n  profileEditBackgroundColor: \"profile-background-color\",\n  profileEditTextColor: \"profile-text-color\",\n  profileEditSecondaryTextColor: \"profile-secondary-text-color\",\n  profileEditBorderColor: \"profile-border-color\",\n  profileEditBorderRadius: \"profile-border-radius\",\n  profileEditPadding: \"profile-padding\",\n  profileEditShadow: \"profile-shadow\",\n  profileEditPrimaryColor: \"profile-primary-color\",\n  profileEditPrimaryHover: \"profile-primary-hover\",\n  profileEditAccentColor: \"profile-accent-color\",\n  profileEditCardBg: \"profile-card-bg\",\n  profileEditCardBorder: \"profile-card-border\",\n  profileEditCardRadius: \"profile-card-radius\",\n  profileEditCardShadow: \"profile-card-shadow\",\n  profileEditCardPadding: \"profile-card-padding\",\n  profileEditAvatarSize: \"profile-avatar-size\",\n  profileEditAvatarRadius: \"profile-avatar-radius\",\n  profileEditAvatarBorder: \"profile-avatar-border\",\n  profileEditAvatarShadow: \"profile-avatar-shadow\",\n  profileEditButtonBg: \"profile-button-bg\",\n  profileEditButtonHoverBg: \"profile-button-hover-bg\",\n  profileEditButtonColor: \"profile-button-color\",\n  profileEditButtonRadius: \"profile-button-radius\",\n  profileEditButtonSecondaryBg: \"profile-button-secondary-bg\",\n  profileEditButtonSecondaryColor: \"profile-button-secondary-color\",\n  profileEditInputBg: \"profile-input-bg\",\n  profileEditInputBorder: \"profile-input-border\",\n  profileEditInputFocusBorder: \"profile-input-focus-border\",\n  profileEditInputRadius: \"profile-input-radius\",\n  profileEditInputText: \"profile-input-text\",\n  profileEditInputPlaceholder: \"profile-input-placeholder\",\n  profileEditFontFamily: \"profile-font-family\",\n  profileEditNameSize: \"profile-name-size\",\n  profileEditNameWeight: \"profile-name-weight\",\n  profileEditLabelSize: \"profile-label-size\",\n  profileEditDividerColor: \"profile-divider-color\",\n  profileEditTransitionDuration: \"profile-transition-duration\",\n};\n\n","import {\n  useRef,\n  useCallback,\n  useMemo,\n  forwardRef,\n  useImperativeHandle,\n} from \"react\";\nimport {\n  type ProfileEditWidgetProps,\n  type ProfileEditThemingProps,\n  PROFILE_EDIT_THEMING_PROP_TO_PARAM,\n} from \"./types\";\n\n/**\n * Ref handle exposed by LegionProfileEdit for imperative control.\n */\nexport interface LegionProfileEditHandle {\n  /** Reload the widget iframe */\n  refresh: () => void;\n}\n\n/**\n * Build the iframe src URL from widget props.\n */\nexport function buildProfileEditWidgetUrl(\n  props: ProfileEditWidgetProps\n): string {\n  const { baseUrl, theme = \"light\" } = props;\n\n  const url = new URL(\"/widget/profile-edit\", baseUrl);\n  url.searchParams.set(\"theme\", theme);\n\n  // Append theming CSS variable params\n  const themingKeys = Object.keys(\n    PROFILE_EDIT_THEMING_PROP_TO_PARAM\n  ) as Array<keyof ProfileEditThemingProps>;\n  for (const key of themingKeys) {\n    const value = props[key];\n    if (value !== undefined && value !== null && String(value).length > 0) {\n      url.searchParams.set(\n        PROFILE_EDIT_THEMING_PROP_TO_PARAM[key],\n        String(value)\n      );\n    }\n  }\n\n  return url.toString();\n}\n\n/**\n * LegionProfileEdit – a React component that embeds the Legion Profile Edit\n * widget via an iframe.\n *\n * @example\n * ```tsx\n * import { LegionProfileEdit } from '@legionhandtech/lht-react-widgets';\n *\n * function App() {\n *   return (\n *     <LegionProfileEdit\n *       baseUrl=\"https://your-legion-domain.com\"\n *       authToken=\"your-jwt-token\"\n *       theme=\"light\"\n *     />\n *   );\n * }\n * ```\n */\nexport const LegionProfileEdit = forwardRef<\n  LegionProfileEditHandle,\n  ProfileEditWidgetProps\n>(function LegionProfileEdit(props, ref) {\n  const {\n    theme = \"light\",\n    authToken,\n    width = \"600px\",\n    height = \"800px\",\n    className,\n    style,\n    onLoad,\n    onError,\n    baseUrl,\n    ...rest\n  } = props;\n\n  const iframeRef = useRef<HTMLIFrameElement>(null);\n\n  useImperativeHandle(\n    ref,\n    () => ({\n      refresh: () => {\n        const iframe = iframeRef.current;\n        if (iframe?.contentWindow) {\n          iframe.contentWindow.location.reload();\n        }\n      },\n    }),\n    []\n  );\n\n  const src = useMemo(\n    () => buildProfileEditWidgetUrl(props),\n    [\n      baseUrl,\n      theme,\n      ...Object.keys(PROFILE_EDIT_THEMING_PROP_TO_PARAM).map(\n        (k) => rest[k as keyof typeof rest]\n      ),\n    ]\n  );\n\n  const handleLoad = useCallback(() => {\n    // Send auth token via postMessage\n    const iframe = iframeRef.current;\n    if (authToken && iframe?.contentWindow) {\n      iframe.contentWindow.postMessage(\n        { type: \"AUTH_TOKEN\", token: authToken },\n        baseUrl\n      );\n    }\n    onLoad?.({ widget: \"profile-edit\", theme: theme ?? \"light\" });\n  }, [onLoad, theme, authToken, baseUrl]);\n\n  const handleError = useCallback(() => {\n    onError?.(\"Failed to load profile edit widget\");\n  }, [onError]);\n\n  return (\n    <div\n      className={className}\n      style={{ width, height, ...style }}\n      data-testid=\"legion-profile-edit\"\n    >\n      <iframe\n        ref={iframeRef}\n        src={src}\n        title=\"Profile Edit Widget\"\n        width=\"100%\"\n        height=\"100%\"\n        frameBorder=\"0\"\n        scrolling=\"no\"\n        onLoad={handleLoad}\n        onError={handleError}\n        style={{ border: \"none\" }}\n      />\n    </div>\n  );\n});\n\n"]}