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,IACxD,GAAG,CAAC,MAAA,EAAQ,KAAA,EAAO,SAAA,EAAW,OAAO,CAAC,CAAA;AAEtC,IAAA,MAAM,WAAA,GAAc,YAAY,MAAM;AACpC,MAAA,OAAA,IAAA,IAAA,GAAA,MAAA,GAAA,OAAA,CAAU,+BAAA,CAAA;AAAA,IACZ,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAEZ,IAAA,uBACE,GAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,SAAA;AAAA,QACA,KAAA,EAAO,EAAE,KAAA,EAAO,MAAA,EAAQ,GAAG,KAAA,EAAM;AAAA,QACjC,aAAA,EAAY,gBAAA;AAAA,QAEZ,QAAA,kBAAA,GAAA;AAAA,UAAC,QAAA;AAAA,UAAA;AAAA,YACC,GAAA,EAAK,SAAA;AAAA,YACL,GAAA;AAAA,YACA,KAAA,EAAM,gBAAA;AAAA,YACN,KAAA,EAAM,MAAA;AAAA,YACN,MAAA,EAAO,MAAA;AAAA,YACP,WAAA,EAAY,GAAA;AAAA,YACZ,SAAA,EAAU,IAAA;AAAA,YACV,MAAA,EAAQ,UAAA;AAAA,YACR,OAAA,EAAS,WAAA;AAAA,YACT,KAAA,EAAO,EAAE,MAAA,EAAQ,MAAA;AAAO;AAAA;AAC1B;AAAA,KACF;AAAA,EAEJ;AACF","file":"profile.mjs","sourcesContent":["/**\n * Theming props for the Profile Widget.\n * These map to CSS custom properties used internally.\n */\nexport interface ProfileThemingProps {\n  /** Container background color */\n  profileBackgroundColor?: string;\n  /** Primary text color */\n  profileTextColor?: string;\n  /** Secondary text color */\n  profileSecondaryTextColor?: string;\n  /** Border color */\n  profileBorderColor?: string;\n  /** Container border radius, e.g. \"12px\" */\n  profileBorderRadius?: string;\n  /** Container padding */\n  profilePadding?: string;\n  /** Container box shadow */\n  profileShadow?: string;\n  /** Primary accent color */\n  profilePrimaryColor?: string;\n  /** Primary hover color */\n  profilePrimaryHover?: string;\n  /** Accent color */\n  profileAccentColor?: string;\n  /** Card background */\n  profileCardBg?: string;\n  /** Card border */\n  profileCardBorder?: string;\n  /** Card border radius */\n  profileCardRadius?: string;\n  /** Card box shadow */\n  profileCardShadow?: string;\n  /** Card padding */\n  profileCardPadding?: string;\n  /** Avatar size, e.g. \"80px\" */\n  profileAvatarSize?: string;\n  /** Avatar border radius */\n  profileAvatarRadius?: string;\n  /** Avatar border */\n  profileAvatarBorder?: string;\n  /** Avatar box shadow */\n  profileAvatarShadow?: string;\n  /** Header background */\n  profileHeaderBg?: string;\n  /** Header height */\n  profileHeaderHeight?: string;\n  /** Badge background */\n  profileBadgeBg?: string;\n  /** Badge text color */\n  profileBadgeColor?: string;\n  /** Badge border radius */\n  profileBadgeRadius?: string;\n  /** Stat background */\n  profileStatBg?: string;\n  /** Stat border */\n  profileStatBorder?: string;\n  /** Stat value text color */\n  profileStatValueColor?: string;\n  /** Stat label text color */\n  profileStatLabelColor?: string;\n  /** Tab active background */\n  profileTabActiveBg?: string;\n  /** Tab active text color */\n  profileTabActiveColor?: string;\n  /** Tab text color */\n  profileTabColor?: string;\n  /** Tab hover background */\n  profileTabHoverBg?: string;\n  /** Tab border radius */\n  profileTabRadius?: string;\n  /** Button background */\n  profileButtonBg?: string;\n  /** Button hover background */\n  profileButtonHoverBg?: string;\n  /** Button text color */\n  profileButtonColor?: string;\n  /** Button border radius */\n  profileButtonRadius?: string;\n  /** Font family */\n  profileFontFamily?: string;\n  /** Name font size */\n  profileNameSize?: string;\n  /** Name font weight */\n  profileNameWeight?: string;\n  /** Username font size */\n  profileUsernameSize?: string;\n  /** Bio font size */\n  profileBioSize?: string;\n  /** Stat font size */\n  profileStatSize?: string;\n  /** Label font size */\n  profileLabelSize?: string;\n  /** Divider color */\n  profileDividerColor?: string;\n  /** Transition duration, e.g. \"0.2s\" */\n  profileTransitionDuration?: string;\n  /** Hover scale factor, e.g. \"1.02\" */\n  profileHoverScale?: string;\n}\n\n/**\n * Core configuration props for the Profile Widget.\n */\nexport interface ProfileWidgetProps extends ProfileThemingProps {\n  /** Base URL of the Legion application (required) */\n  baseUrl: string;\n  /** JWT auth token for authenticated profile viewing */\n  authToken?: string;\n  /** Theme preset. Default: \"light\" */\n  theme?: \"light\" | \"dark\";\n  /** Widget width CSS value. Default: \"400px\" */\n  width?: string;\n  /** Widget height CSS value. Default: \"400px\" */\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 widget iframe URL.\n */\nexport const PROFILE_THEMING_PROP_TO_PARAM: Record<\n  keyof ProfileThemingProps,\n  string\n> = {\n  profileBackgroundColor: \"profile-background-color\",\n  profileTextColor: \"profile-text-color\",\n  profileSecondaryTextColor: \"profile-secondary-text-color\",\n  profileBorderColor: \"profile-border-color\",\n  profileBorderRadius: \"profile-border-radius\",\n  profilePadding: \"profile-padding\",\n  profileShadow: \"profile-shadow\",\n  profilePrimaryColor: \"profile-primary-color\",\n  profilePrimaryHover: \"profile-primary-hover\",\n  profileAccentColor: \"profile-accent-color\",\n  profileCardBg: \"profile-card-bg\",\n  profileCardBorder: \"profile-card-border\",\n  profileCardRadius: \"profile-card-radius\",\n  profileCardShadow: \"profile-card-shadow\",\n  profileCardPadding: \"profile-card-padding\",\n  profileAvatarSize: \"profile-avatar-size\",\n  profileAvatarRadius: \"profile-avatar-radius\",\n  profileAvatarBorder: \"profile-avatar-border\",\n  profileAvatarShadow: \"profile-avatar-shadow\",\n  profileHeaderBg: \"profile-header-bg\",\n  profileHeaderHeight: \"profile-header-height\",\n  profileBadgeBg: \"profile-badge-bg\",\n  profileBadgeColor: \"profile-badge-color\",\n  profileBadgeRadius: \"profile-badge-radius\",\n  profileStatBg: \"profile-stat-bg\",\n  profileStatBorder: \"profile-stat-border\",\n  profileStatValueColor: \"profile-stat-value-color\",\n  profileStatLabelColor: \"profile-stat-label-color\",\n  profileTabActiveBg: \"profile-tab-active-bg\",\n  profileTabActiveColor: \"profile-tab-active-color\",\n  profileTabColor: \"profile-tab-color\",\n  profileTabHoverBg: \"profile-tab-hover-bg\",\n  profileTabRadius: \"profile-tab-radius\",\n  profileButtonBg: \"profile-button-bg\",\n  profileButtonHoverBg: \"profile-button-hover-bg\",\n  profileButtonColor: \"profile-button-color\",\n  profileButtonRadius: \"profile-button-radius\",\n  profileFontFamily: \"profile-font-family\",\n  profileNameSize: \"profile-name-size\",\n  profileNameWeight: \"profile-name-weight\",\n  profileUsernameSize: \"profile-username-size\",\n  profileBioSize: \"profile-bio-size\",\n  profileStatSize: \"profile-stat-size\",\n  profileLabelSize: \"profile-label-size\",\n  profileDividerColor: \"profile-divider-color\",\n  profileTransitionDuration: \"profile-transition-duration\",\n  profileHoverScale: \"profile-hover-scale\",\n};\n\n","import {\n  useRef,\n  useCallback,\n  useMemo,\n  forwardRef,\n  useImperativeHandle,\n} from \"react\";\nimport {\n  type ProfileWidgetProps,\n  type ProfileThemingProps,\n  PROFILE_THEMING_PROP_TO_PARAM,\n} from \"./types\";\n\n/**\n * Ref handle exposed by LegionProfile for imperative control.\n */\nexport interface LegionProfileHandle {\n  /** Reload the widget iframe */\n  refresh: () => void;\n}\n\n/**\n * Build the iframe src URL from widget props.\n */\nexport function buildProfileWidgetUrl(props: ProfileWidgetProps): string {\n  const { baseUrl, theme = \"light\" } = props;\n\n  const url = new URL(\"/widget/profile\", baseUrl);\n  url.searchParams.set(\"theme\", theme);\n\n  // Append theming CSS variable params\n  const themingKeys = Object.keys(PROFILE_THEMING_PROP_TO_PARAM) as Array<\n    keyof ProfileThemingProps\n  >;\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(PROFILE_THEMING_PROP_TO_PARAM[key], String(value));\n    }\n  }\n\n  return url.toString();\n}\n\n/**\n * LegionProfile – a React component that embeds the Legion Profile widget\n * via an iframe.\n *\n * @example\n * ```tsx\n * import { LegionProfile } from '@legionhandtech/lht-react-widgets';\n *\n * function App() {\n *   return (\n *     <LegionProfile\n *       baseUrl=\"https://your-legion-domain.com\"\n *       authToken=\"your-jwt-token\"\n *       theme=\"light\"\n *     />\n *   );\n * }\n * ```\n */\nexport const LegionProfile = forwardRef<LegionProfileHandle, ProfileWidgetProps>(\n  function LegionProfile(props, ref) {\n    const {\n      theme = \"light\",\n      authToken,\n      width = \"400px\",\n      height = \"400px\",\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      () => buildProfileWidgetUrl(props),\n      [\n        baseUrl,\n        theme,\n        ...Object.keys(PROFILE_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\", theme: theme ?? \"light\" });\n    }, [onLoad, theme, authToken, baseUrl]);\n\n    const handleError = useCallback(() => {\n      onError?.(\"Failed to load profile widget\");\n    }, [onError]);\n\n    return (\n      <div\n        className={className}\n        style={{ width, height, ...style }}\n        data-testid=\"legion-profile\"\n      >\n        <iframe\n          ref={iframeRef}\n          src={src}\n          title=\"Profile 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\n"]}