{"version":3,"sources":["../src/community-gallery/types.ts","../src/community-gallery/LegionCommunityGallery.tsx"],"names":["LegionCommunityGallery"],"mappings":";;;;;;AAsEO,IAAM,6BAAA,GAGT;AAAA,EACF,mBAAA,EAAqB,uBAAA;AAAA,EACrB,sBAAA,EAAwB,0BAAA;AAAA,EACxB,gBAAA,EAAkB,oBAAA;AAAA,EAClB,gBAAA,EAAkB,oBAAA;AAAA,EAClB,iBAAA,EAAmB,qBAAA;AAAA,EACnB,iBAAA,EAAmB,qBAAA;AAAA,EACnB,UAAA,EAAY,aAAA;AAAA,EACZ,iBAAA,EAAmB,qBAAA;AAAA,EACnB,yBAAA,EAA2B,6BAAA;AAAA,EAC3B,mBAAA,EAAqB,uBAAA;AAAA,EACrB,oBAAA,EAAsB,wBAAA;AAAA,EACtB,eAAA,EAAiB,mBAAA;AAAA,EACjB,iBAAA,EAAmB;AACrB;AC/DO,SAAS,sBACd,KAAA,EACQ;AACR,EAAA,MAAM;AAAA,IACJ,OAAA;AAAA,IACA,KAAA,GAAQ,CAAA;AAAA,IACR,KAAA,GAAQ,OAAA;AAAA,IACR,WAAA,GAAc,IAAA;AAAA,IACd,UAAA,GAAa,UAAA;AAAA,IACb;AAAA,GACF,GAAI,KAAA;AAEJ,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,2BAAA,EAA6B,OAAO,CAAA;AACxD,EAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,OAAA,EAAS,MAAA,CAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,GAAA,CAAI,KAAA,EAAO,CAAC,CAAA,EAAG,EAAE,CAAC,CAAC,CAAA;AACtE,EAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,OAAA,EAAS,KAAK,CAAA;AACnC,EAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,aAAA,EAAe,MAAA,CAAO,WAAW,CAAC,CAAA;AACvD,EAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,YA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d,QAAA,EAAU,QAAA;AAAA,IACV,KAAA,EAAO,MAAA;AAAA,IACP,MAAA,EAAQ;AAAA,GACV;AAEA,EAAA,uBACE,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAsB,KAAA,EAAO,cAAA,EAChC,QAAA,kBAAA,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,GAAA,EAAK,SAAA;AAAA,MACL,GAAA;AAAA,MACA,KAAA,EAAM,0BAAA;AAAA,MACN,KAAA,EAAM,MAAA;AAAA,MACN,OAAA,EAAQ,MAAA;AAAA,MACR,KAAA,EAAO,WAAA;AAAA,MACP,MAAA,EAAQ,UAAA;AAAA,MACR,OAAA,EAAS;AAAA;AAAA,GACX,EACF,CAAA;AAEJ,CAAC","file":"community-gallery.mjs","sourcesContent":["/**\n * Theming props for the Community Gallery Widget.\n * These map to CSS custom properties used internally.\n */\nexport interface CommunityGalleryThemingProps {\n  /** Primary accent color, e.g. \"#228be6\" */\n  galleryPrimaryColor?: string;\n  /** Container background color */\n  galleryBackgroundColor?: string;\n  /** Primary text color */\n  galleryTextColor?: string;\n  /** Overlay gradient background */\n  galleryOverlayBg?: string;\n  /** Card border radius, e.g. \"12px\" */\n  galleryCardRadius?: string;\n  /** Card box shadow */\n  galleryCardShadow?: string;\n  /** Grid gap, e.g. \"8px\" */\n  galleryGap?: string;\n  /** Hover scale factor, e.g. \"1.03\" */\n  galleryHoverScale?: string;\n  /** Transition duration, e.g. \"0.2s\" */\n  galleryTransitionDuration?: string;\n  /** Username text size, e.g. \"12px\" */\n  galleryUsernameSize?: string;\n  /** Username text color */\n  galleryUsernameColor?: string;\n  /** Media icon size, e.g. \"20px\" */\n  galleryIconSize?: string;\n  /** Font family */\n  galleryFontFamily?: string;\n}\n\n/**\n * Core configuration props for the Community Gallery Widget.\n */\nexport interface CommunityGalleryWidgetProps\n  extends CommunityGalleryThemingProps {\n  /** Base URL of the Legion application (required) */\n  baseUrl: string;\n  /** Number of gallery items to display (1-12). Default: 4 */\n  count?: number;\n  /** Theme preset. Default: \"light\" */\n  theme?: \"light\" | \"dark\";\n  /** Show \"View all in Gallery\" link. Default: true */\n  showViewAll?: boolean;\n  /** URL for the \"View all\" link. Default: \"/gallery\" */\n  viewAllUrl?: string;\n  /** URL to open when clicking on a media item */\n  communityUrl?: string;\n  /** Widget height: \"auto\" or a specific CSS value. Default: \"auto\" */\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: {\n    widget: string;\n    count: number;\n    theme: string;\n  }) => 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 community gallery widget iframe URL.\n */\nexport const GALLERY_THEMING_PROP_TO_PARAM: Record<\n  keyof CommunityGalleryThemingProps,\n  string\n> = {\n  galleryPrimaryColor: \"gallery-primary-color\",\n  galleryBackgroundColor: \"gallery-background-color\",\n  galleryTextColor: \"gallery-text-color\",\n  galleryOverlayBg: \"gallery-overlay-bg\",\n  galleryCardRadius: \"gallery-card-radius\",\n  galleryCardShadow: \"gallery-card-shadow\",\n  galleryGap: \"gallery-gap\",\n  galleryHoverScale: \"gallery-hover-scale\",\n  galleryTransitionDuration: \"gallery-transition-duration\",\n  galleryUsernameSize: \"gallery-username-size\",\n  galleryUsernameColor: \"gallery-username-color\",\n  galleryIconSize: \"gallery-icon-size\",\n  galleryFontFamily: \"gallery-font-family\",\n};\n\n","import React, {\n  useRef,\n  useCallback,\n  useMemo,\n  forwardRef,\n  useImperativeHandle,\n} from \"react\";\nimport {\n  type CommunityGalleryWidgetProps,\n  type CommunityGalleryThemingProps,\n  GALLERY_THEMING_PROP_TO_PARAM,\n} from \"./types\";\n\n/**\n * Ref handle exposed by LegionCommunityGallery for imperative control.\n */\nexport interface LegionCommunityGalleryHandle {\n  /** Reload the widget iframe */\n  refresh: () => void;\n}\n\n/**\n * Build the iframe src URL from widget props.\n */\nexport function buildGalleryWidgetUrl(\n  props: CommunityGalleryWidgetProps\n): string {\n  const {\n    baseUrl,\n    count = 4,\n    theme = \"light\",\n    showViewAll = true,\n    viewAllUrl = \"/gallery\",\n    communityUrl,\n  } = props;\n\n  const url = new URL(\"/widget/community-gallery\", baseUrl);\n  url.searchParams.set(\"count\", String(Math.min(Math.max(count, 1), 12)));\n  url.searchParams.set(\"theme\", theme);\n  url.searchParams.set(\"showViewAll\", String(showViewAll));\n  url.searchParams.set(\"viewAllUrl\", viewAllUrl);\n\n  if (communityUrl) {\n    url.searchParams.set(\"communityUrl\", communityUrl);\n  }\n\n  // Append theming params\n  const themingKeys = Object.keys(GALLERY_THEMING_PROP_TO_PARAM) as Array<\n    keyof CommunityGalleryThemingProps\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(GALLERY_THEMING_PROP_TO_PARAM[key], String(value));\n    }\n  }\n\n  return url.toString();\n}\n\n/**\n * LegionCommunityGallery – a React component that embeds the Legion\n * Community Gallery widget via an iframe.\n *\n * @example\n * ```tsx\n * import { LegionCommunityGallery } from '@legionhandtech/lht-react-widgets';\n *\n * function App() {\n *   return (\n *     <LegionCommunityGallery\n *       baseUrl=\"https://your-legion-domain.com\"\n *       count={4}\n *       theme=\"light\"\n *       communityUrl=\"/community\"\n *     />\n *   );\n * }\n * ```\n */\nexport const LegionCommunityGallery = forwardRef<\n  LegionCommunityGalleryHandle,\n  CommunityGalleryWidgetProps\n>(function LegionCommunityGallery(props, ref) {\n  const {\n    count = 4,\n    theme = \"light\",\n    showViewAll,\n    viewAllUrl,\n    communityUrl,\n    height = \"auto\",\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    () => buildGalleryWidgetUrl(props),\n    [\n      baseUrl,\n      count,\n      theme,\n      showViewAll,\n      viewAllUrl,\n      communityUrl,\n      ...Object.keys(GALLERY_THEMING_PROP_TO_PARAM).map(\n        (k) => rest[k as keyof typeof rest]\n      ),\n    ]\n  );\n\n  const handleLoad = useCallback(() => {\n    onLoad?.({\n      widget: \"community-gallery\",\n      count: Math.min(Math.max(count, 1), 12),\n      theme,\n    });\n  }, [count, theme, onLoad]);\n\n  const handleError = useCallback(() => {\n    onError?.(\"Failed to load community gallery widget\");\n  }, [onError]);\n\n  const resolvedHeight = height === \"auto\" ? \"200px\" : height;\n\n  const containerStyle: React.CSSProperties = {\n    display: \"block\",\n    width: \"100%\",\n    backgroundColor: \"transparent\",\n    minHeight: \"150px\",\n    height: resolvedHeight,\n    ...style,\n  };\n\n  const iframeStyle: React.CSSProperties = {\n    border: \"none\",\n    borderRadius: \"8px\",\n    overflow: \"hidden\",\n    width: \"100%\",\n    height: resolvedHeight,\n  };\n\n  return (\n    <div className={className} style={containerStyle}>\n      <iframe\n        ref={iframeRef}\n        src={src}\n        title=\"Community Gallery Widget\"\n        width=\"100%\"\n        loading=\"lazy\"\n        style={iframeStyle}\n        onLoad={handleLoad}\n        onError={handleError}\n      />\n    </div>\n  );\n});\n\n"]}