@fluid-app/portal-sdk 0.1.222 → 0.1.223

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -479,77 +479,74 @@ function ProductListing({ companyLogoUrl, renderImage, onSelectProduct, cartButt
479
479
  return () => observer.disconnect();
480
480
  }, [handleIntersect]);
481
481
  const allProducts = data?.pages.flatMap((page) => page.products) ?? [];
482
- return /* @__PURE__ */ jsxs("div", {
483
- className: "h-full overflow-auto",
484
- children: [/* @__PURE__ */ jsx("div", {
485
- className: "mx-auto px-2 md:px-10",
486
- children: /* @__PURE__ */ jsxs("div", {
487
- className: "flex items-center justify-end gap-2 py-4",
488
- children: [
489
- /* @__PURE__ */ jsx("div", {
490
- className: "w-full max-w-sm",
491
- children: /* @__PURE__ */ jsx(SearchSort, {
492
- searchValue: catalog.searchTerm,
493
- onSearchChange: catalog.setSearchTerm,
494
- placeholder: "Search products..."
495
- })
496
- }),
497
- /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
498
- asChild: true,
499
- children: /* @__PURE__ */ jsx(Button, {
500
- variant: "outline",
501
- size: "icon",
502
- className: "h-9 w-9 shrink-0",
503
- children: /* @__PURE__ */ jsx(ArrowUpDown, { className: "h-3 w-3" })
504
- })
505
- }), /* @__PURE__ */ jsxs(DropdownMenuContent, {
506
- align: "end",
507
- className: "w-60",
508
- children: [
509
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Sort By" }),
510
- /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
511
- /* @__PURE__ */ jsx(DropdownMenuRadioGroup, {
512
- value: catalog.currentSort,
513
- onValueChange: catalog.setCurrentSort,
514
- children: SORT_OPTIONS.map((opt) => /* @__PURE__ */ jsx(DropdownMenuRadioItem, {
515
- value: opt.id,
516
- children: opt.label
517
- }, opt.id))
518
- })
519
- ]
520
- })] }),
521
- cartButton && /* @__PURE__ */ jsx("div", {
522
- className: "flex shrink-0 items-center gap-3",
523
- children: cartButton
524
- })
525
- ]
526
- })
527
- }), /* @__PURE__ */ jsx("div", {
528
- className: "mx-auto space-y-8 px-2 md:px-10 md:py-8",
529
- children: isLoading ? /* @__PURE__ */ jsx(SkeletonGrid, {}) : error ? /* @__PURE__ */ jsxs("p", {
530
- className: "mx-auto my-6 rounded-lg bg-red-100 px-3 py-2 text-red-500",
531
- children: ["Error: ", error.message]
532
- }) : isFetched && allProducts.length === 0 ? /* @__PURE__ */ jsx("div", {
533
- className: "flex flex-col items-center justify-center py-8 text-center",
534
- children: /* @__PURE__ */ jsx("p", {
535
- className: "text-muted-foreground text-sm",
536
- children: catalog.searchTerm ? `No products match "${catalog.searchTerm}". Try a different search term.` : "There are no products available at the moment."
537
- })
538
- }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
482
+ return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
483
+ className: "mx-auto px-2 md:px-10",
484
+ children: /* @__PURE__ */ jsxs("div", {
485
+ className: "flex items-center justify-end gap-2 py-4",
486
+ children: [
539
487
  /* @__PURE__ */ jsx("div", {
540
- className: GRID_CLASS,
541
- children: allProducts.map((product) => /* @__PURE__ */ jsx(ProductCard, {
542
- product: tagPortalProduct(product),
543
- companyLogoUrl,
544
- renderImage,
545
- onClick: () => onSelectProduct(String(product.id))
546
- }, product.id))
488
+ className: "w-full max-w-sm",
489
+ children: /* @__PURE__ */ jsx(SearchSort, {
490
+ searchValue: catalog.searchTerm,
491
+ onSearchChange: catalog.setSearchTerm,
492
+ placeholder: "Search products..."
493
+ })
547
494
  }),
548
- /* @__PURE__ */ jsx("div", { ref: observerTarget }),
549
- isFetchingNextPage && /* @__PURE__ */ jsx(SkeletonGrid, { count: 4 })
550
- ] })
551
- })]
552
- });
495
+ /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
496
+ asChild: true,
497
+ children: /* @__PURE__ */ jsx(Button, {
498
+ variant: "outline",
499
+ size: "icon",
500
+ className: "h-9 w-9 shrink-0",
501
+ children: /* @__PURE__ */ jsx(ArrowUpDown, { className: "h-3 w-3" })
502
+ })
503
+ }), /* @__PURE__ */ jsxs(DropdownMenuContent, {
504
+ align: "end",
505
+ className: "w-60",
506
+ children: [
507
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Sort By" }),
508
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
509
+ /* @__PURE__ */ jsx(DropdownMenuRadioGroup, {
510
+ value: catalog.currentSort,
511
+ onValueChange: catalog.setCurrentSort,
512
+ children: SORT_OPTIONS.map((opt) => /* @__PURE__ */ jsx(DropdownMenuRadioItem, {
513
+ value: opt.id,
514
+ children: opt.label
515
+ }, opt.id))
516
+ })
517
+ ]
518
+ })] }),
519
+ cartButton && /* @__PURE__ */ jsx("div", {
520
+ className: "flex shrink-0 items-center gap-3",
521
+ children: cartButton
522
+ })
523
+ ]
524
+ })
525
+ }), /* @__PURE__ */ jsx("div", {
526
+ className: "mx-auto space-y-8 px-2 md:px-10 md:py-8",
527
+ children: isLoading ? /* @__PURE__ */ jsx(SkeletonGrid, {}) : error ? /* @__PURE__ */ jsxs("p", {
528
+ className: "mx-auto my-6 rounded-lg bg-red-100 px-3 py-2 text-red-500",
529
+ children: ["Error: ", error.message]
530
+ }) : isFetched && allProducts.length === 0 ? /* @__PURE__ */ jsx("div", {
531
+ className: "flex flex-col items-center justify-center py-8 text-center",
532
+ children: /* @__PURE__ */ jsx("p", {
533
+ className: "text-muted-foreground text-sm",
534
+ children: catalog.searchTerm ? `No products match "${catalog.searchTerm}". Try a different search term.` : "There are no products available at the moment."
535
+ })
536
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
537
+ /* @__PURE__ */ jsx("div", {
538
+ className: GRID_CLASS,
539
+ children: allProducts.map((product) => /* @__PURE__ */ jsx(ProductCard, {
540
+ product: tagPortalProduct(product),
541
+ companyLogoUrl,
542
+ renderImage,
543
+ onClick: () => onSelectProduct(String(product.id))
544
+ }, product.id))
545
+ }),
546
+ /* @__PURE__ */ jsx("div", { ref: observerTarget }),
547
+ isFetchingNextPage && /* @__PURE__ */ jsx(SkeletonGrid, { count: 4 })
548
+ ] })
549
+ })] });
553
550
  }
554
551
  /**
555
552
  * Build the variant options map by grouping option_values across non-master variants.
@@ -731,7 +728,7 @@ function ProductDetail({ productId, renderImage }) {
731
728
  const isBundle = product.bundle === true;
732
729
  const bundleUrl = isBundle && product.canonical_url ? product.canonical_url : null;
733
730
  return /* @__PURE__ */ jsx("div", {
734
- className: "h-full overflow-auto pb-5 md:pl-8",
731
+ className: "pb-5 md:pl-8",
735
732
  children: /* @__PURE__ */ jsx("div", {
736
733
  className: "mx-auto max-w-7xl px-4 py-8 md:pr-6 md:pl-0 lg:pr-8 lg:pl-0",
737
734
  children: /* @__PURE__ */ jsxs("div", {
@@ -1087,7 +1084,7 @@ function ShopScreen({ background, textColor, accentColor, padding, borderRadius,
1087
1084
  }, [countryCode]);
1088
1085
  return /* @__PURE__ */ jsx("div", {
1089
1086
  ...divProps,
1090
- className: `h-full ${divProps.className ?? ""}`,
1087
+ className: divProps.className ?? "",
1091
1088
  children: /* @__PURE__ */ jsx(ShopContainer, {
1092
1089
  cartScript: subdomain ? /* @__PURE__ */ jsx(CartScript, {
1093
1090
  subdomain,
@@ -1144,4 +1141,4 @@ function ProductBreadcrumb({ productId }) {
1144
1141
  //#endregion
1145
1142
  export { ShopScreen_exports as n, shopScreenPropertySchema as r, ShopScreen as t };
1146
1143
 
1147
- //# sourceMappingURL=ShopScreen-DfYtszj_.mjs.map
1144
+ //# sourceMappingURL=ShopScreen-C8V_QlfB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShopScreen-C8V_QlfB.mjs","names":["defaultRenderImage"],"sources":["../../../shop/ui/src/utils/media-helpers.ts","../../../shop/ui/src/components/product-card.tsx","../../../shop/ui/src/components/image-gallery.tsx","../../../shop/ui/src/components/quantity-selector.tsx","../../../shop/ui/src/components/purchase-options.tsx","../../../shop/ui/src/components/shop-app.tsx","../../../cart/ui/src/components/cart-script.tsx","../../../cart/ui/src/components/cart-widget.tsx","../../../cart/ui/src/components/cart-button.tsx","../../../cart/ui/src/components/shop-container.tsx","../src/screens/ShopScreen.tsx"],"sourcesContent":["const VIDEO_EXTENSIONS = [\n \".mp4\",\n \".webm\",\n \".mov\",\n \".avi\",\n \".m4v\",\n \".mkv\",\n \".ogv\",\n \".ogg\",\n \".wmv\",\n \".flv\",\n \".3gp\",\n];\n\nconst IMAGE_EXTENSIONS = [\n \".jpg\",\n \".jpeg\",\n \".png\",\n \".gif\",\n \".webp\",\n \".svg\",\n \".bmp\",\n \".ico\",\n \".tiff\",\n \".tif\",\n];\n\nexport function isVideoUrl(url: string | undefined | null): boolean {\n if (!url) return false;\n const lowerUrl = url.toLowerCase();\n return VIDEO_EXTENSIONS.some((ext) => lowerUrl.includes(ext));\n}\n\nexport function isImageUrl(url: string | undefined | null): boolean {\n if (!url) return false;\n const lowerUrl = url.toLowerCase();\n return IMAGE_EXTENSIONS.some((ext) => lowerUrl.includes(ext));\n}\n\nexport function getMediaTypeFromUrl(\n url: string | undefined | null,\n): \"video\" | \"image\" | \"unknown\" {\n if (isVideoUrl(url)) return \"video\";\n if (isImageUrl(url)) return \"image\";\n return \"unknown\";\n}\n\nexport function getVideoThumbnailUrl(videoUrl: string): string {\n if (videoUrl.includes(\"ik.imagekit.io\")) {\n return `${videoUrl}/ik-thumbnail.jpg`;\n }\n return videoUrl;\n}\n\nexport function ensureImageIsFeatured<\n T extends { image_url: string; position?: number },\n>(items: T[]): T[] {\n if (items.length === 0) return items;\n\n const firstItem = items[0];\n if (!firstItem || !isVideoUrl(firstItem.image_url)) {\n return items;\n }\n\n const firstImageIndex = items.findIndex(\n (item) => !isVideoUrl(item.image_url),\n );\n\n if (firstImageIndex === -1) {\n return items;\n }\n\n const reordered = [...items];\n const [imageToMove] = reordered.splice(firstImageIndex, 1);\n if (imageToMove) {\n reordered.unshift(imageToMove);\n }\n\n return reordered;\n}\n","import type React from \"react\";\nimport { useState, type ReactNode } from \"react\";\nimport type { products, portalProducts } from \"@fluid-app/products-core\";\nimport {\n determineProductPrice,\n getProductImageUrl,\n} from \"@fluid-app/products-core\";\nimport { Card } from \"@fluid-app/ui-primitives\";\nimport { CirclePlay } from \"lucide-react\";\nimport { getVideoThumbnailUrl, isVideoUrl } from \"../utils/media-helpers\";\n\ntype LegacyProduct = (products.Product | products.ShopProduct) & {\n kind?: string;\n video_url?: string;\n};\n\nexport interface RenderImageProps {\n src: string;\n alt: string;\n fill?: boolean;\n className?: string;\n onError?: (e: React.SyntheticEvent<HTMLImageElement>) => void;\n unoptimized?: boolean;\n}\n\ntype TaggedPortalProduct = portalProducts.Product & {\n readonly __portalProduct: true;\n};\n\nexport type ProductCardProduct = LegacyProduct | TaggedPortalProduct;\n\ninterface ProductCardProps {\n product: ProductCardProduct;\n countryIso?: string;\n companyLogoUrl?: string | null;\n showShareModal?: boolean;\n setShareModalOpen?: (open: boolean) => void;\n setSelectedProduct?: (product: LegacyProduct) => void;\n renderLink?: (props: { href: string; children: ReactNode }) => ReactNode;\n renderImage?: (props: RenderImageProps) => ReactNode;\n onClick?: () => void;\n}\n\nexport function tagPortalProduct(\n product: portalProducts.Product,\n): TaggedPortalProduct {\n return { ...product, __portalProduct: true as const };\n}\n\nfunction isPortalProduct(\n product: ProductCardProduct,\n): product is TaggedPortalProduct {\n return \"__portalProduct\" in product && product.__portalProduct === true;\n}\n\nfunction getPortalProductCoverImage(\n product: portalProducts.Product,\n): string | null {\n if (product.images && product.images.length > 0) {\n return product.images[0]?.url ?? null;\n }\n return null;\n}\n\nfunction defaultRenderImage({\n src,\n alt,\n fill,\n className,\n onError,\n}: RenderImageProps): ReactNode {\n return (\n <img\n src={src}\n alt={alt}\n className={`${fill ? \"absolute inset-0 h-full w-full\" : \"\"} ${className ?? \"\"}`}\n onError={onError}\n />\n );\n}\n\nfunction formatPortalPrice(\n price: string | undefined,\n currency: string | undefined,\n): string | null {\n if (!price) return null;\n const numericPrice = Number(price);\n if (Number.isNaN(numericPrice)) return `${currency ?? \"\"}${price}`;\n try {\n return new Intl.NumberFormat(undefined, {\n style: \"currency\",\n currency: currency || \"USD\",\n }).format(numericPrice);\n } catch {\n return `$${price}`;\n }\n}\n\nfunction ProductCardContent({\n product,\n countryIso,\n companyLogoUrl,\n renderImage = defaultRenderImage,\n}: {\n product: ProductCardProduct;\n countryIso?: string;\n companyLogoUrl?: string | null;\n renderImage?: (props: RenderImageProps) => ReactNode;\n}) {\n const [isHovered, setIsHovered] = useState(false);\n\n const isPortal = isPortalProduct(product);\n const coverImage = isPortal\n ? getPortalProductCoverImage(product)\n : getProductImageUrl(product as Parameters<typeof getProductImageUrl>[0]);\n const isVideo = isVideoUrl(coverImage);\n const productName = isPortal\n ? product.name || \"No title available\"\n : (product as LegacyProduct).title || \"No title available\";\n\n let repPrice: string | null | undefined = null;\n let price: string | null | undefined = null;\n if (isPortal) {\n // wholesale_price is non-null for reps, null for customers\n if (product.wholesale_price) {\n repPrice = formatPortalPrice(product.wholesale_price, product.currency);\n // Show retail as strikethrough if different from wholesale\n const retailFormatted = formatPortalPrice(\n product.price,\n product.currency,\n );\n if (retailFormatted !== repPrice) {\n price = retailFormatted;\n }\n } else {\n repPrice = formatPortalPrice(product.price, product.currency);\n }\n } else if (countryIso) {\n const prices = determineProductPrice(product, countryIso);\n repPrice = prices.repPrice;\n price = prices.price;\n }\n\n return (\n <>\n {/* Image/Video container */}\n <div\n className=\"bg-muted relative aspect-square overflow-hidden\"\n onMouseEnter={() => isVideo && setIsHovered(true)}\n onMouseLeave={() => isVideo && setIsHovered(false)}\n >\n {isVideo && isHovered ? (\n <video\n src={coverImage || \"\"}\n className=\"absolute inset-0 h-full w-full object-cover\"\n autoPlay\n muted\n loop\n playsInline\n />\n ) : (\n renderImage({\n src:\n isVideo && coverImage\n ? getVideoThumbnailUrl(coverImage)\n : coverImage ||\n \"https://assets.fluid.app/fluid-admin/images/we-commerce/we-commerce.png\",\n alt: productName,\n fill: true,\n className:\n \"object-cover transition-transform group-hover:scale-105\",\n onError: (e) => {\n e.currentTarget.src =\n companyLogoUrl ||\n \"https://assets.fluid.app/fluid-admin/images/we-commerce/we-commerce.png\";\n },\n unoptimized: true,\n })\n )}\n\n {/* Video play indicator */}\n {isVideo && !isHovered && (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <div className=\"flex h-16 w-16 items-center justify-center rounded-full bg-black/50 backdrop-blur-sm\">\n <CirclePlay className=\"h-12 w-12 text-white\" />\n </div>\n </div>\n )}\n </div>\n\n {/* Product info */}\n <div className=\"px-3 pt-2 pb-4\">\n <h3 className=\"text-foreground line-clamp-1 text-sm font-bold\">\n {productName}\n </h3>\n\n <div className=\"flex items-center gap-2\">\n {repPrice && (\n <span className=\"text-foreground text-sm font-bold\">\n {repPrice}\n </span>\n )}\n {price && (\n <span className=\"text-muted-foreground text-sm line-through\">\n {price}\n </span>\n )}\n </div>\n\n {!isPortal && countryIso && (\n <div className=\"text-muted-foreground text-sm\">\n CV{\" \"}\n {getVariantCountryValue(\n getSelectedVariant(product as LegacyProduct),\n countryIso,\n \"cv\",\n ) || \"-\"}{\" \"}\n | QV{\" \"}\n {getVariantCountryValue(\n getSelectedVariant(product as LegacyProduct),\n countryIso,\n \"qv\",\n ) || \"-\"}\n </div>\n )}\n </div>\n </>\n );\n}\n\nfunction getSelectedVariant(\n product: LegacyProduct,\n): products.Variant | products.ShopVariant | null {\n if (!product.variants || product.variants.length === 0) return null;\n\n const masterVariant = product.variants.find(\n (v: products.Variant | products.ShopVariant) => {\n return \"is_master\" in v && v.is_master;\n },\n );\n if (masterVariant) return masterVariant;\n\n return product.variants[0] || null;\n}\n\nfunction getVariantCountryValue(\n variant: products.Variant | products.ShopVariant | null,\n countryIso: string,\n field: \"cv\" | \"qv\",\n): number | null {\n if (!variant || !variant.variant_countries) return null;\n\n if (\n typeof variant.variant_countries === \"object\" &&\n !Array.isArray(variant.variant_countries)\n ) {\n const countryData = variant.variant_countries[countryIso] as\n | products.VariantCountry\n | undefined;\n return countryData?.[field] ?? null;\n }\n\n if (Array.isArray(variant.variant_countries)) {\n const countryData = variant.variant_countries.find(\n (vc: products.ShopVariantCountry) => vc.country_iso === countryIso,\n );\n return countryData?.[field] ?? null;\n }\n\n return null;\n}\n\nexport default function ProductCard({\n product,\n countryIso,\n companyLogoUrl,\n showShareModal = false,\n setShareModalOpen,\n setSelectedProduct,\n renderLink,\n renderImage,\n onClick,\n}: ProductCardProps): React.JSX.Element {\n const cardContent = (\n <ProductCardContent\n product={product}\n countryIso={countryIso}\n companyLogoUrl={companyLogoUrl}\n renderImage={renderImage}\n />\n );\n\n const cardClassName = \"overflow-hidden border-0 shadow-none pt-0 gap-0\";\n\n if (showShareModal && !isPortalProduct(product)) {\n const handleShareClick = () => {\n if (setSelectedProduct && setShareModalOpen) {\n setSelectedProduct(product);\n setShareModalOpen(true);\n }\n };\n return (\n <Card className={cardClassName}>\n <button\n onClick={handleShareClick}\n className=\"group block w-full cursor-pointer text-left\"\n >\n {cardContent}\n </button>\n </Card>\n );\n }\n\n if (onClick) {\n return (\n <Card className={cardClassName}>\n <button\n onClick={onClick}\n className=\"group block w-full cursor-pointer text-left\"\n >\n {cardContent}\n </button>\n </Card>\n );\n }\n\n const href = `/portal/shop/${product.id}`;\n\n if (renderLink) {\n return (\n <Card className={cardClassName}>\n {renderLink({ href, children: cardContent })}\n </Card>\n );\n }\n\n return (\n <Card className={cardClassName}>\n <a href={href} className=\"group block cursor-pointer\">\n {cardContent}\n </a>\n </Card>\n );\n}\n","import type React from \"react\";\nimport { type ReactNode, useEffect, useMemo, useState } from \"react\";\nimport { ChevronLeft, ChevronRight } from \"lucide-react\";\nimport { isVideoUrl } from \"../utils/media-helpers\";\nimport type { RenderImageProps } from \"./product-card\";\n\ninterface ImageGalleryProps {\n images: Array<{\n id: number;\n image_url: string;\n image_path: string | null;\n position: number;\n }>;\n fallbackImageUrl: string;\n productTitle: string;\n renderImage?: (props: RenderImageProps) => ReactNode;\n}\n\nfunction defaultRenderImage({\n src,\n alt,\n fill,\n className,\n onError,\n}: RenderImageProps): ReactNode {\n return (\n <img\n src={src}\n alt={alt}\n className={`${fill ? \"absolute inset-0 h-full w-full\" : \"\"} ${className ?? \"\"}`}\n onError={onError}\n />\n );\n}\n\nexport default function ImageGallery({\n images,\n fallbackImageUrl,\n productTitle,\n renderImage = defaultRenderImage,\n}: ImageGalleryProps): React.JSX.Element {\n const [currentImageIndex, setCurrentImageIndex] = useState(0);\n\n const hasMultipleImages = images && images.length > 0;\n const displayImages = useMemo(\n () =>\n hasMultipleImages\n ? [...images].sort((a, b) => a.position - b.position)\n : [{ id: 0, image_url: fallbackImageUrl, position: 0 }],\n [images, hasMultipleImages, fallbackImageUrl],\n );\n\n // Reset to first image when the images array changes (e.g. variant switch)\n useEffect(() => {\n setCurrentImageIndex(0);\n }, [displayImages]);\n\n const nextImage = () => {\n if (displayImages.length > 1) {\n setCurrentImageIndex((prev) => (prev + 1) % displayImages.length);\n }\n };\n\n const prevImage = () => {\n if (displayImages.length > 1) {\n setCurrentImageIndex(\n (prev) => (prev - 1 + displayImages.length) % displayImages.length,\n );\n }\n };\n\n return (\n <div className=\"space-y-4\">\n {/* Main Image */}\n <div className=\"group relative aspect-square overflow-hidden rounded-sm bg-gray-100\">\n {isVideoUrl(displayImages[currentImageIndex]?.image_url) ? (\n <video\n key={displayImages[currentImageIndex]?.id}\n src={displayImages[currentImageIndex]?.image_url}\n className=\"absolute inset-0 h-full w-full object-cover\"\n controls\n loop\n playsInline\n />\n ) : (\n renderImage({\n src:\n displayImages[currentImageIndex]?.image_url || fallbackImageUrl,\n alt: productTitle,\n fill: true,\n className: \"object-cover\",\n onError: (e) => {\n e.currentTarget.src =\n \"https://assets.fluid.app/fluid-admin/images/we-commerce/we-commerce.png\";\n },\n unoptimized: true,\n })\n )}\n\n {/* Navigation arrows */}\n {displayImages.length > 1 && (\n <>\n <button\n type=\"button\"\n aria-label=\"Previous image\"\n className=\"absolute top-1/2 left-3 z-10 flex h-8 w-8 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full bg-white/40 shadow-sm transition-colors group-hover:bg-white/80 hover:bg-white\"\n onClick={prevImage}\n >\n <ChevronLeft className=\"h-5 w-5 text-black/40 transition-colors group-hover:text-black\" />\n </button>\n <button\n type=\"button\"\n aria-label=\"Next image\"\n className=\"absolute top-1/2 right-3 z-10 flex h-8 w-8 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full bg-white/40 shadow-sm transition-colors group-hover:bg-white/80 hover:bg-white\"\n onClick={nextImage}\n >\n <ChevronRight className=\"h-5 w-5 text-black/40 transition-colors group-hover:text-black\" />\n </button>\n </>\n )}\n\n {/* Page Indicators - Bottom Center */}\n {displayImages.length > 1 && (\n <div className=\"absolute bottom-3 left-1/2 flex -translate-x-1/2 gap-3\">\n {displayImages.map((_, index) => (\n <button\n type=\"button\"\n key={index}\n className={`h-1.5 w-6 cursor-pointer rounded-lg transition-colors ${\n index === currentImageIndex\n ? \"bg-gray-800\"\n : \"bg-gray-400 hover:bg-gray-600\"\n }`}\n aria-label={`Go to image ${index + 1}`}\n onClick={() => setCurrentImageIndex(index)}\n />\n ))}\n </div>\n )}\n </div>\n </div>\n );\n}\n","import type React from \"react\";\nimport { Button } from \"@fluid-app/ui-primitives\";\n\ninterface QuantitySelectorProps {\n quantity: number;\n setQuantity: (quantity: number) => void;\n}\n\nexport default function QuantitySelector({\n quantity,\n setQuantity,\n}: QuantitySelectorProps): React.JSX.Element {\n return (\n <div className=\"flex items-center gap-3\">\n <div className=\"flex items-center rounded-lg\">\n <Button\n variant=\"default\"\n onClick={() => setQuantity(Math.max(1, quantity - 1))}\n className=\"border-0 px-3 py-2 shadow-none\"\n >\n −\n </Button>\n <span className=\"text-foreground min-w-8 px-4 py-2 text-center text-sm font-medium\">\n {quantity}\n </span>\n <Button\n variant=\"default\"\n onClick={() => setQuantity(quantity + 1)}\n className=\"border-0 px-3 py-2 shadow-none\"\n >\n +\n </Button>\n </div>\n </div>\n );\n}\n","import type React from \"react\";\nimport { useMemo } from \"react\";\nimport type { products } from \"@fluid-app/products-core\";\nimport {\n RadioGroup,\n RadioGroupItem,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"@fluid-app/ui-primitives\";\n\ninterface PurchaseOptionsProps {\n showBuyOnce: boolean;\n showSubscribe: boolean;\n isSubscribe: boolean;\n onSubscribeChange: (subscribe: boolean) => void;\n product_subscription_plans: products.ProductSubscriptionPlan[];\n selectedSubscriptionPlan?: products.ProductSubscriptionPlan;\n onSubscriptionPlanChange?: (plan: products.ProductSubscriptionPlan) => void;\n userSelectedSubscribe: boolean;\n wholesalePrice?: number;\n wholesaleSubscriptionPrice?: number;\n}\n\nexport default function PurchaseOptions({\n showBuyOnce,\n showSubscribe,\n isSubscribe,\n onSubscribeChange,\n product_subscription_plans,\n selectedSubscriptionPlan,\n onSubscriptionPlanChange,\n userSelectedSubscribe,\n wholesalePrice,\n wholesaleSubscriptionPrice,\n}: PurchaseOptionsProps): React.JSX.Element | null {\n // Find default subscription plan or use first one\n const defaultSubscriptionPlan = useMemo(() => {\n if (!product_subscription_plans?.length) return null;\n return (\n product_subscription_plans.find((plan) => plan.default) ||\n product_subscription_plans[0]\n );\n }, [product_subscription_plans]);\n\n // Use selected plan or default to the default/first plan\n const currentSubscriptionPlan =\n selectedSubscriptionPlan || defaultSubscriptionPlan;\n\n // Calculate savings percentage from wholesale prices\n const savingsText = useMemo(() => {\n if (\n wholesalePrice === undefined ||\n wholesaleSubscriptionPrice === undefined ||\n wholesalePrice <= 0\n ) {\n return null;\n }\n\n const savings = wholesalePrice - wholesaleSubscriptionPrice;\n if (savings <= 0) return null;\n\n const savingsPercentage = Math.round((savings / wholesalePrice) * 100);\n if (savingsPercentage <= 0) return null;\n\n return `Save ${savingsPercentage}%`;\n }, [wholesalePrice, wholesaleSubscriptionPrice]);\n\n // Format subscription plan display name\n const formatSubscriptionPlan = (plan: products.ProductSubscriptionPlan) => {\n const interval = plan.subscription_plan.billing_interval;\n const unit = plan.subscription_plan.billing_interval_unit;\n return `${interval} ${unit} (${plan.subscription_plan.name})`;\n };\n\n // Prepare subscription plan options for Select component\n const subscriptionPlanOptions = useMemo(() => {\n if (!product_subscription_plans?.length) return [];\n\n return product_subscription_plans.map((plan) => ({\n value: plan.subscription_plan.id.toString(),\n label: formatSubscriptionPlan(plan),\n }));\n }, [product_subscription_plans]);\n\n // Don't render if only buy once is shown and subscribe is false\n if (showBuyOnce && !showSubscribe) {\n return null;\n }\n const handleSubscriptionPlanChange = (planId: string) => {\n const selectedPlan = product_subscription_plans?.find(\n (plan) => plan.subscription_plan.id.toString() === planId,\n );\n if (selectedPlan && onSubscriptionPlanChange) {\n onSubscriptionPlanChange(selectedPlan);\n }\n };\n\n const purchaseType = isSubscribe ? \"subscribe\" : \"once\";\n\n return (\n <div className=\"mb-3 flex flex-col\">\n <RadioGroup\n value={purchaseType}\n onValueChange={(value) => onSubscribeChange(value === \"subscribe\")}\n className=\"gap-0 space-y-0\"\n >\n {showSubscribe && (\n <div\n className={`cursor-pointer rounded-t-lg p-4 text-left transition-all duration-200 ${showBuyOnce ? \"border border-b-0\" : \"rounded-b-lg\"} ${userSelectedSubscribe ? \"bg-muted\" : \"bg-background\"}`}\n >\n <div className=\"flex items-start space-x-3\">\n <RadioGroupItem\n value=\"subscribe\"\n className={`flex items-center justify-center [&_svg]:h-1.5 [&_svg]:w-1.5 [&_svg]:fill-white ${\n isSubscribe\n ? \"border-contrast bg-contrast text-foreground\"\n : \"border-border bg-background text-muted-foreground\"\n }`}\n />\n <div className=\"flex-1\">\n <div className=\"text-foreground mb-1 text-sm leading-tight font-medium\">\n Subscribe{savingsText ? ` & ${savingsText}` : \"\"}\n </div>\n\n {/* Subscription Plan Dropdown*/}\n {product_subscription_plans?.length > 0 && (\n <div\n className=\"bg-muted mt-3 rounded-lg p-2\"\n onClick={(e) => e.stopPropagation()}\n >\n <div className=\"text-foreground mb-1 text-xs font-medium\">\n Delivery Frequency:\n </div>\n <Select\n value={\n currentSubscriptionPlan?.subscription_plan.id.toString() ||\n \"\"\n }\n onValueChange={handleSubscriptionPlanChange}\n disabled={product_subscription_plans?.length === 1}\n >\n <SelectTrigger className=\"bg-background text-foreground! w-full text-xs\">\n <SelectValue placeholder=\"Select delivery schedule\" />\n </SelectTrigger>\n <SelectContent>\n {subscriptionPlanOptions.map((option) => (\n <SelectItem key={option.value} value={option.value}>\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n )}\n </div>\n </div>\n </div>\n )}\n {showBuyOnce && (\n <div\n className={`cursor-pointer rounded-b-lg border p-4 text-left transition-all duration-200 ${showSubscribe ? \"border-t-0\" : \"rounded-t-lg\"} ${!userSelectedSubscribe ? \"bg-muted\" : \"bg-background\"}`}\n >\n <div className=\"flex items-center space-x-3\">\n <RadioGroupItem\n value=\"once\"\n className={`flex items-center justify-center [&_svg]:h-1.5 [&_svg]:w-1.5 [&_svg]:fill-white ${\n !isSubscribe\n ? \"border-contrast bg-contrast text-foreground\"\n : \"border-border bg-background text-muted-foreground\"\n }`}\n />\n <div className=\"text-foreground mb-1 text-sm leading-tight font-medium\">\n One-Time Purchase\n </div>\n </div>\n </div>\n )}\n </RadioGroup>\n </div>\n );\n}\n","import type React from \"react\";\nimport {\n useState,\n useMemo,\n useEffect,\n useRef,\n useCallback,\n type ReactNode,\n} from \"react\";\nimport {\n usePortalProductCatalog,\n usePortalProductDetail,\n type PortalProductPageParam,\n type portalProducts,\n type products,\n} from \"@fluid-app/products-core\";\nimport { useInfiniteQuery } from \"@tanstack/react-query\";\nimport {\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuLabel,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n Skeleton,\n} from \"@fluid-app/ui-primitives\";\nimport { SearchSort } from \"@fluid-app/ui-components/components/SearchSort\";\nimport { ArrowUpDown, ShoppingCart } from \"lucide-react\";\nimport ProductCard, {\n tagPortalProduct,\n type RenderImageProps,\n} from \"./product-card\";\nimport ImageGallery from \"./image-gallery\";\nimport QuantitySelector from \"./quantity-selector\";\nimport PurchaseOptions from \"./purchase-options\";\n\ninterface ShopAppProps {\n companyLogoUrl?: string | null;\n renderImage?: (props: RenderImageProps) => ReactNode;\n /** When provided, controls which product detail to show (URL-driven routing) */\n productId?: string | null;\n /** Called when a product is selected from the listing */\n onSelectProduct?: (productId: string) => void;\n /** Called when user navigates back from product detail */\n onBack?: () => void;\n /** Optional cart button to render in the header area */\n cartButton?: ReactNode;\n}\n\nconst PAGE_SIZE = 25;\n\nfunction sanitizeHtml(html: string): string {\n const doc = new DOMParser().parseFromString(html, \"text/html\");\n for (const el of doc.querySelectorAll(\n \"script, iframe, object, embed, form, base, meta, link, style\",\n )) {\n el.remove();\n }\n for (const el of doc.querySelectorAll(\"*\")) {\n for (const attr of [...el.attributes]) {\n if (\n attr.name.toLowerCase().startsWith(\"on\") ||\n attr.value.toLowerCase().trim().startsWith(\"javascript:\")\n ) {\n el.removeAttribute(attr.name);\n }\n }\n }\n return doc.body.innerHTML;\n}\n\nconst SORT_OPTIONS = [\n { id: \"title_asc\", label: \"Title (A-Z)\" },\n { id: \"title_desc\", label: \"Title (Z-A)\" },\n { id: \"price_asc\", label: \"Price (Low to High)\" },\n { id: \"price_desc\", label: \"Price (High to Low)\" },\n { id: \"created_at_desc\", label: \"Recently Updated\" },\n { id: \"created_at_asc\", label: \"Oldest Updated\" },\n];\n\nconst GRID_CLASS =\n \"grid grid-cols-1 gap-8 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-4\";\n\nfunction SkeletonGrid({ count = 8 }: { count?: number }) {\n return (\n <div className={GRID_CLASS}>\n {Array.from({ length: count }, (_, i) => (\n <div key={i} className=\"space-y-2\">\n <Skeleton className=\"aspect-square w-full rounded-lg\" />\n <Skeleton className=\"h-4 w-3/4\" />\n <Skeleton className=\"h-4 w-1/2\" />\n <Skeleton className=\"h-3 w-1/3\" />\n </div>\n ))}\n </div>\n );\n}\n\nfunction ProductListing({\n companyLogoUrl,\n renderImage,\n onSelectProduct,\n cartButton,\n}: {\n companyLogoUrl?: string | null;\n renderImage?: (props: RenderImageProps) => ReactNode;\n onSelectProduct: (productId: string) => void;\n cartButton?: ReactNode;\n}) {\n const observerTarget = useRef<HTMLDivElement>(null);\n\n const catalog = usePortalProductCatalog({ perPage: PAGE_SIZE });\n\n const {\n data,\n isLoading,\n isFetchingNextPage,\n hasNextPage,\n fetchNextPage,\n error,\n isFetched,\n } = useInfiniteQuery({\n queryKey: catalog.queryKey,\n queryFn: ({ pageParam }) => catalog.fetchProducts(pageParam),\n getNextPageParam: catalog.getNextPageParam,\n initialPageParam: undefined as PortalProductPageParam,\n });\n\n const handleIntersect = useCallback(\n (entries: IntersectionObserverEntry[]) => {\n if (entries[0]?.isIntersecting && hasNextPage && !isFetchingNextPage) {\n fetchNextPage();\n }\n },\n [hasNextPage, isFetchingNextPage, fetchNextPage],\n );\n\n useEffect(() => {\n const target = observerTarget.current;\n if (!target) return;\n\n const observer = new IntersectionObserver(handleIntersect, {\n threshold: 0.1,\n rootMargin: \"200px\",\n });\n observer.observe(target);\n return () => observer.disconnect();\n }, [handleIntersect]);\n\n const allProducts = data?.pages.flatMap((page) => page.products) ?? [];\n\n return (\n <div>\n <div className=\"mx-auto px-2 md:px-10\">\n {/* Search + Sort */}\n <div className=\"flex items-center justify-end gap-2 py-4\">\n <div className=\"w-full max-w-sm\">\n <SearchSort\n searchValue={catalog.searchTerm}\n onSearchChange={catalog.setSearchTerm}\n placeholder=\"Search products...\"\n />\n </div>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n variant=\"outline\"\n size=\"icon\"\n className=\"h-9 w-9 shrink-0\"\n >\n <ArrowUpDown className=\"h-3 w-3\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"w-60\">\n <DropdownMenuLabel>Sort By</DropdownMenuLabel>\n <DropdownMenuSeparator />\n <DropdownMenuRadioGroup\n value={catalog.currentSort}\n onValueChange={catalog.setCurrentSort}\n >\n {SORT_OPTIONS.map((opt) => (\n <DropdownMenuRadioItem key={opt.id} value={opt.id}>\n {opt.label}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuContent>\n </DropdownMenu>\n {cartButton && (\n <div className=\"flex shrink-0 items-center gap-3\">{cartButton}</div>\n )}\n </div>\n </div>\n\n {/* Product Grid */}\n <div className=\"mx-auto space-y-8 px-2 md:px-10 md:py-8\">\n {isLoading ? (\n <SkeletonGrid />\n ) : error ? (\n <p className=\"mx-auto my-6 rounded-lg bg-red-100 px-3 py-2 text-red-500\">\n Error: {error.message}\n </p>\n ) : isFetched && allProducts.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center py-8 text-center\">\n <p className=\"text-muted-foreground text-sm\">\n {catalog.searchTerm\n ? `No products match \"${catalog.searchTerm}\". Try a different search term.`\n : \"There are no products available at the moment.\"}\n </p>\n </div>\n ) : (\n <>\n <div className={GRID_CLASS}>\n {allProducts.map((product) => (\n <ProductCard\n key={product.id}\n product={tagPortalProduct(product)}\n companyLogoUrl={companyLogoUrl}\n renderImage={renderImage}\n onClick={() => onSelectProduct(String(product.id))}\n />\n ))}\n </div>\n <div ref={observerTarget} />\n {isFetchingNextPage && <SkeletonGrid count={4} />}\n </>\n )}\n </div>\n </div>\n );\n}\n\ninterface OptionGroup {\n optionId: number;\n name: string;\n values: { id: number; name: string }[];\n}\n\n/**\n * Build the variant options map by grouping option_values across non-master variants.\n * Groups by option_id, collecting unique value entries.\n */\nfunction buildOptionGroups(variants: portalProducts.Variant[]): OptionGroup[] {\n const groupMap = new Map<\n number,\n { name: string; values: Map<number, string> }\n >();\n\n for (const variant of variants) {\n if (variant.is_master) continue;\n for (const ov of variant.option_values ?? []) {\n if (ov.option_id == null || ov.id == null) continue;\n if (!groupMap.has(ov.option_id)) {\n groupMap.set(ov.option_id, {\n name: ov.option_name ?? `Option ${ov.option_id}`,\n values: new Map(),\n });\n }\n groupMap.get(ov.option_id)!.values.set(ov.id, ov.name ?? String(ov.id));\n }\n }\n\n return [...groupMap.entries()].map(([optionId, group]) => ({\n optionId,\n name: group.name,\n values: [...group.values.entries()].map(([id, name]) => ({ id, name })),\n }));\n}\n\n/**\n * Find the variant matching a set of selected option value IDs.\n * selections is a map of optionId → selected value id.\n */\nfunction findVariantBySelections(\n variants: portalProducts.Variant[],\n selections: Record<number, number>,\n): portalProducts.Variant | undefined {\n const entries = Object.entries(selections).map(\n ([k, v]) => [Number(k), v] as const,\n );\n if (entries.length === 0) return undefined;\n return variants.find(\n (v) =>\n !v.is_master &&\n entries.every(([optionId, valueId]) =>\n v.option_values?.some(\n (ov) => ov.option_id === optionId && ov.id === valueId,\n ),\n ),\n );\n}\n\n/**\n * Map BFF flat subscription plans to the legacy ProductSubscriptionPlan shape\n * expected by the PurchaseOptions component.\n */\nfunction mapToLegacySubscriptionPlans(\n plans: portalProducts.SubscriptionPlan[],\n): products.ProductSubscriptionPlan[] {\n return plans.map((plan, idx) => ({\n id: plan.id,\n default: idx === 0,\n products_count: null,\n subscribers_count: null,\n active: true,\n subscription_plan: {\n id: plan.id ?? 0,\n name: plan.name ?? \"\",\n billing_interval: plan.billing_interval ?? 1,\n billing_interval_unit: plan.billing_interval_unit ?? \"month\",\n billing_frequency_in_words:\n plan.billing_frequency ??\n `${plan.billing_interval} ${plan.billing_interval_unit}`,\n active: true,\n price_adjustment_amount: null,\n price_adjustment_type: null,\n },\n }));\n}\n\nfunction formatPrice(price: string | undefined, currency: string | undefined) {\n if (!price) return null;\n const numericPrice = Number(price);\n if (Number.isNaN(numericPrice)) return `${currency ?? \"\"}${price}`;\n try {\n return new Intl.NumberFormat(undefined, {\n style: \"currency\",\n currency: currency || \"USD\",\n }).format(numericPrice);\n } catch {\n return `$${price}`;\n }\n}\n\nfunction ProductDetail({\n productId,\n renderImage,\n}: {\n productId: string;\n renderImage?: (props: RenderImageProps) => ReactNode;\n}) {\n const [quantity, setQuantity] = useState(1);\n // selections: optionId → selected value id\n const [selections, setSelections] = useState<Record<number, number>>({});\n const [userSelectedSubscribe, setUserSelectedSubscribe] = useState(false);\n const [selectedSubscriptionPlan, setSelectedSubscriptionPlan] = useState<\n products.ProductSubscriptionPlan | undefined\n >(undefined);\n\n const { product, isLoading, error, images } = usePortalProductDetail({\n productId,\n });\n\n const variants = useMemo(() => product?.variants ?? [], [product?.variants]);\n const subscriptionPlans = useMemo(\n () => product?.subscription_plans ?? [],\n [product?.subscription_plans],\n );\n\n // Default to the master variant, or the first available variant\n const masterVariant = useMemo(\n () => variants.find((v) => v.is_master) ?? variants[0],\n [variants],\n );\n\n // Build option groups from non-master variants\n const optionGroups = useMemo(() => buildOptionGroups(variants), [variants]);\n\n // Initialise selections from the first non-master variant (or master fallback)\n useEffect(() => {\n if (optionGroups.length === 0) return;\n const firstNonMaster = variants.find((v) => !v.is_master);\n const source = firstNonMaster ?? masterVariant;\n if (!source?.option_values?.length) return;\n const defaults: Record<number, number> = {};\n for (const ov of source.option_values) {\n if (ov.option_id != null && ov.id != null) {\n defaults[ov.option_id] = ov.id;\n }\n }\n setSelections(defaults);\n }, [optionGroups, variants, masterVariant]);\n\n // Resolve the currently selected variant\n const selectedVariant = useMemo(() => {\n if (optionGroups.length === 0) return masterVariant;\n return findVariantBySelections(variants, selections) ?? masterVariant;\n }, [variants, optionGroups, selections, masterVariant]);\n\n // Map BFF subscription plans → legacy ProductSubscriptionPlan shape for PurchaseOptions\n const legacySubscriptionPlans = useMemo(\n () => mapToLegacySubscriptionPlans(subscriptionPlans),\n [subscriptionPlans],\n );\n\n // Derive subscription state from variant\n const isSubscribe =\n selectedVariant?.subscription_only === true || userSelectedSubscribe;\n const showSubscribe = legacySubscriptionPlans.length > 0;\n const showBuyOnce = selectedVariant?.subscription_only !== true;\n\n // Auto-select subscribe when variant is subscription-only\n useEffect(() => {\n if (\n selectedVariant?.subscription_only &&\n legacySubscriptionPlans.length > 0\n ) {\n setUserSelectedSubscribe(true);\n }\n }, [selectedVariant, legacySubscriptionPlans]);\n\n // Prefer variant-specific images when available, fall back to product-level images\n const galleryImages = useMemo(() => {\n const variantImages = selectedVariant?.images;\n if (variantImages && variantImages.length > 0) {\n return variantImages.map((img, idx) => ({\n id: idx,\n image_url: img.url ?? \"\",\n image_path: null as string | null,\n position: idx,\n }));\n }\n return images.map((img, idx) => ({\n id: img.id ?? idx,\n image_url: img.url,\n image_path: null as string | null,\n position: idx,\n }));\n }, [selectedVariant?.images, images]);\n\n const coverImage = galleryImages[0]?.image_url ?? null;\n\n // Pricing: use selected variant's subscription_pricing for wholesale comparison\n const selectedPricing = selectedVariant?.subscription_pricing?.find(\n (sp) =>\n sp.plan_id ===\n (selectedSubscriptionPlan?.subscription_plan.id ??\n legacySubscriptionPlans[0]?.subscription_plan.id),\n );\n const wholesalePrice = selectedVariant?.wholesale_price\n ? Number(selectedVariant.wholesale_price)\n : undefined;\n const wholesaleSubscriptionPrice = selectedPricing?.wholesale_price\n ? Number(selectedPricing.wholesale_price)\n : undefined;\n\n // Display prices\n // price = retail price, wholesale_price = rep/logged-in price\n // subscription_pricing.wholesale_price = subscription wholesale price\n const currency = selectedVariant?.currency ?? product?.currency;\n const displayPrice = formatPrice(\n selectedVariant?.price ?? product?.price,\n currency,\n );\n const displayWholesalePrice = formatPrice(\n selectedVariant?.wholesale_price ??\n selectedVariant?.price ??\n product?.price,\n currency,\n );\n const displayWholesaleSubscriptionPrice = formatPrice(\n selectedPricing?.wholesale_price ??\n selectedPricing?.price ??\n selectedVariant?.wholesale_price ??\n undefined,\n currency,\n );\n\n // Resolve subscription plan ID for the cart SDK\n const resolvedPlanId =\n selectedSubscriptionPlan?.subscription_plan.id ??\n legacySubscriptionPlans.find((p) => p.default)?.subscription_plan.id ??\n legacySubscriptionPlans[0]?.subscription_plan.id;\n\n // Cart data attributes — SDK expects variant ID, not product ID\n const cartVariantId = String(selectedVariant?.id ?? product?.id ?? \"\");\n\n if (isLoading) {\n return (\n <div className=\"mx-auto max-w-7xl py-8 pr-4 pl-0 md:pr-6 lg:pr-8 lg:pl-0\">\n <div className=\"grid grid-cols-1 gap-5 lg:grid-cols-2\">\n <Skeleton className=\"aspect-square w-full rounded-lg\" />\n <div className=\"space-y-4 pl-2 lg:pl-20\">\n <Skeleton className=\"h-8 w-3/4\" />\n <Skeleton className=\"h-5 w-1/4\" />\n <Skeleton className=\"h-20 w-full\" />\n <Skeleton className=\"h-10 w-1/2\" />\n <Skeleton className=\"h-10 w-full\" />\n </div>\n </div>\n </div>\n );\n }\n\n if (error) {\n return (\n <div className=\"flex min-h-[400px] items-center justify-center\">\n <div className=\"text-center\">\n <h3 className=\"text-foreground mb-2 text-lg font-medium\">\n Unable to load product\n </h3>\n <p className=\"text-muted-foreground\">\n Something went wrong. Please try again later.\n </p>\n </div>\n </div>\n );\n }\n\n if (!product) {\n return (\n <div className=\"flex min-h-[400px] items-center justify-center\">\n <div className=\"text-center\">\n <h3 className=\"text-foreground mb-2 text-lg font-medium\">\n Product not found\n </h3>\n <p className=\"text-muted-foreground\">\n The product you&apos;re looking for doesn&apos;t exist.\n </p>\n </div>\n </div>\n );\n }\n\n const title = product.name || \"Product\";\n const isBundle = product.bundle === true;\n const bundleUrl =\n isBundle && product.canonical_url ? product.canonical_url : null;\n\n return (\n <div className=\"pb-5 md:pl-8\">\n <div className=\"mx-auto max-w-7xl px-4 py-8 md:pr-6 md:pl-0 lg:pr-8 lg:pl-0\">\n <div className=\"grid grid-cols-1 gap-5 lg:grid-cols-2\">\n {/* Image Gallery */}\n <ImageGallery\n images={galleryImages}\n fallbackImageUrl={\n coverImage ??\n \"https://assets.fluid.app/fluid-admin/images/we-commerce/we-commerce.png\"\n }\n productTitle={title}\n renderImage={renderImage}\n />\n\n {/* Product Info */}\n <div className=\"max-w-lg pl-2 lg:pl-20\">\n <h1 className=\"text-foreground text-3xl font-bold\">{title}</h1>\n\n {/* Price — matches admin exactly */}\n {!isBundle && (\n <div className=\"mb-2 flex items-center gap-2\">\n <span className=\"text-foreground text-sm\">\n {isSubscribe\n ? displayWholesaleSubscriptionPrice\n : displayWholesalePrice}\n </span>\n {((isSubscribe &&\n displayWholesaleSubscriptionPrice !==\n displayWholesalePrice) ||\n (!isSubscribe && displayWholesalePrice !== displayPrice)) && (\n <span className=\"text-muted-foreground text-sm line-through\">\n {isSubscribe ? displayWholesalePrice : displayPrice}\n </span>\n )}\n </div>\n )}\n\n {/* Product Description */}\n <div className=\"pt-2\">\n <h3 className=\"text-foreground mb-1 text-sm font-medium\">\n Product Description\n </h3>\n <div\n className=\"text-foreground mb-3 text-[12px]\"\n dangerouslySetInnerHTML={{\n __html: sanitizeHtml(product.description ?? \"\"),\n }}\n />\n </div>\n\n {isBundle ? (\n <div className=\"pt-4\">\n <Button\n variant=\"default\"\n className=\"w-full gap-2 py-2 text-base font-medium\"\n disabled={!bundleUrl}\n onClick={() => {\n if (bundleUrl)\n window.open(bundleUrl, \"_blank\", \"noopener,noreferrer\");\n }}\n >\n Purchase Bundle\n </Button>\n {!bundleUrl && (\n <p className=\"text-muted-foreground mt-2 text-center text-xs\">\n Bundle configuration is unavailable. Please contact support.\n </p>\n )}\n </div>\n ) : (\n <>\n {/* Purchase Options — matches admin PurchaseOptions component */}\n <PurchaseOptions\n showBuyOnce={showBuyOnce}\n showSubscribe={showSubscribe}\n isSubscribe={isSubscribe}\n userSelectedSubscribe={userSelectedSubscribe}\n onSubscribeChange={setUserSelectedSubscribe}\n wholesalePrice={wholesalePrice}\n wholesaleSubscriptionPrice={wholesaleSubscriptionPrice}\n product_subscription_plans={legacySubscriptionPlans}\n selectedSubscriptionPlan={selectedSubscriptionPlan}\n onSubscriptionPlanChange={setSelectedSubscriptionPlan}\n />\n\n {/* Variant Options — matches admin layout */}\n {optionGroups.length > 0 && (\n <div className=\"mb-4 pt-4\">\n {optionGroups.map((group) => (\n <div\n key={group.optionId}\n className=\"mb-3 flex items-center\"\n >\n <h3 className=\"text-md text-foreground w-24 font-bold\">\n {group.name.charAt(0).toUpperCase() +\n group.name.slice(1)}\n </h3>\n <Select\n value={String(selections[group.optionId] ?? \"\")}\n onValueChange={(value) =>\n setSelections((prev) => ({\n ...prev,\n [group.optionId]: Number(value),\n }))\n }\n >\n <SelectTrigger className=\"w-48 max-w-full\">\n <SelectValue placeholder={`Select ${group.name}`} />\n </SelectTrigger>\n <SelectContent position=\"popper\" className=\"max-h-60\">\n {group.values.map((v) => (\n <SelectItem key={v.id} value={String(v.id)}>\n {v.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n ))}\n </div>\n )}\n\n {/* Unavailable product message */}\n {selectedVariant?.subscription_only &&\n !selectedVariant?.allow_subscription && (\n <div className=\"text-muted-foreground text-sm\">\n This product is unavailable for purchase.\n </div>\n )}\n\n {/* Quantity and Add to Cart — matches admin */}\n <div className=\"mt-4 mb-3\" />\n <div className=\"flex items-center gap-3 pb-3\">\n <QuantitySelector\n quantity={quantity}\n setQuantity={setQuantity}\n />\n\n <Button\n variant=\"default\"\n className=\"flex-1 gap-2 py-2 text-base font-medium\"\n disabled={\n selectedVariant?.subscription_only === true &&\n !selectedVariant?.allow_subscription\n }\n data-fluid-add-to-cart={cartVariantId}\n data-fluid-quantity={quantity}\n data-fluid-subscribe={isSubscribe}\n data-fluid-subscription-plan-id={\n isSubscribe ? String(resolvedPlanId ?? \"\") : \"\"\n }\n data-fluid-open-cart-after-add=\"false\"\n >\n <ShoppingCart className=\"h-4 w-4\" />\n {isSubscribe ? \"Subscribe\" : \"Add to Cart\"}\n </Button>\n </div>\n </>\n )}\n </div>\n </div>\n </div>\n </div>\n );\n}\n\nexport default function ShopApp({\n companyLogoUrl,\n renderImage,\n productId: controlledProductId,\n onSelectProduct: onSelectProductProp,\n onBack: _onBack,\n cartButton,\n}: ShopAppProps): React.JSX.Element {\n // Internal state used only when navigation is not controlled externally\n const [internalProductId, setInternalProductId] = useState<string | null>(\n null,\n );\n\n const isControlled = controlledProductId !== undefined;\n const activeProductId = isControlled\n ? controlledProductId\n : internalProductId;\n\n const handleSelectProduct = onSelectProductProp ?? setInternalProductId;\n\n if (activeProductId) {\n return (\n <ProductDetail productId={activeProductId} renderImage={renderImage} />\n );\n }\n\n return (\n <ProductListing\n companyLogoUrl={companyLogoUrl}\n renderImage={renderImage}\n onSelectProduct={handleSelectProduct}\n cartButton={cartButton}\n />\n );\n}\n","import { useEffect, useRef } from \"react\";\n\ninterface CartScriptProps {\n subdomain: string;\n authJwt?: string;\n /** Enable BFF mode — uses portal session cookies instead of JWT for cart auth. */\n bffMode?: boolean;\n /** Override the SDK script URL (e.g. \"http://localhost:4444/index.js\" for local dev). */\n scriptSrc?: string;\n /** Override the API base URL the SDK uses (e.g. \"http://localhost:3000\" for local dev). */\n apiBaseUrl?: string;\n /** Enable SDK debug logging. */\n debug?: boolean;\n}\n\nconst SCRIPT_ID = \"fluid-cdn-script\";\nconst LEAD_CAPTURE_ID = \"fluid-lead-capture-suppress\";\nconst DEFAULT_SCRIPT_SRC =\n \"https://assets.fluid.app/scripts/fluid-sdk/latest/web-widgets/index.js\";\n\nexport default function CartScript({\n subdomain,\n authJwt,\n bffMode,\n scriptSrc,\n apiBaseUrl,\n debug,\n}: CartScriptProps): React.ReactNode {\n // Use a ref so the script is injected once with the initial values.\n // ES modules are cached by URL — re-inserting the same script won't\n // re-execute it, so changing props after the first load has no effect.\n const authJwtRef = useRef(authJwt);\n authJwtRef.current = authJwt;\n\n useEffect(() => {\n if (!subdomain) return;\n\n // Don't add a duplicate script\n if (document.getElementById(SCRIPT_ID)) return;\n\n const script = document.createElement(\"script\");\n script.id = SCRIPT_ID;\n script.src = scriptSrc ?? DEFAULT_SCRIPT_SRC;\n script.type = \"module\";\n script.crossOrigin = \"anonymous\";\n script.dataset.fluidShop = subdomain;\n if (bffMode) {\n script.dataset.bffMode = \"true\";\n } else if (authJwtRef.current) {\n script.dataset.authJwt = authJwtRef.current;\n }\n if (apiBaseUrl) {\n script.dataset.fluidApiBaseUrl = apiBaseUrl;\n }\n if (debug) {\n script.dataset.debug = \"true\";\n }\n document.head.appendChild(script);\n\n // Suppress the SDK's auto-injected lead capture widget.\n // The SDK skips injection when it finds an existing element with hide-widget.\n const leadCapture = document.createElement(\"fluid-lead-capture-widget\");\n leadCapture.id = LEAD_CAPTURE_ID;\n leadCapture.setAttribute(\"hide-widget\", \"true\");\n document.body.appendChild(leadCapture);\n\n return () => {\n const existing = document.getElementById(SCRIPT_ID);\n if (existing) existing.remove();\n const existingLeadCapture = document.getElementById(LEAD_CAPTURE_ID);\n if (existingLeadCapture) existingLeadCapture.remove();\n };\n }, [subdomain, bffMode, scriptSrc, apiBaseUrl, debug]);\n\n return null;\n}\n","import React, { useEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\n\ninterface CartWidgetProps {\n theme?: Record<string, string>;\n}\n\nexport default function CartWidget({\n theme,\n}: CartWidgetProps): React.ReactNode {\n const [mounted, setMounted] = useState(false);\n const widgetRef = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n setMounted(true);\n }, []);\n\n useEffect(() => {\n if (!mounted) return;\n const el = widgetRef.current;\n if (!el) return;\n if (theme) {\n el.setAttribute(\"theme\", JSON.stringify(theme));\n } else {\n el.removeAttribute(\"theme\");\n }\n }, [theme, mounted]);\n\n const widget = React.createElement(\"fluid-cart-widget\", {\n ref: (el: HTMLElement | null) => {\n widgetRef.current = el;\n },\n \"data-fluid-widget\": \"true\",\n \"hide-widget\": \"true\",\n \"is-primary\": \"true\",\n });\n\n // Portal to document.body so the cart drawer escapes any\n // overflow-hidden / isolation stacking contexts in the layout.\n if (mounted) {\n return createPortal(widget, document.body);\n }\n\n return null;\n}\n","\"use client\";\n\nimport { Button } from \"@fluid-app/ui-primitives\";\nimport { ShoppingCart } from \"lucide-react\";\nimport React, { useEffect, useCallback, useState } from \"react\";\n\ndeclare global {\n interface Window {\n FluidCommerceSDK?: {\n getCheckoutUrl: () => string;\n setOnCheckout: (callback: () => void) => void;\n };\n FairShareSDK?: {\n getCartItemCount: () => number;\n isBffMode: () => boolean;\n updateLocaleSettings: (options: {\n language?: string;\n country?: string;\n }) => Promise<void>;\n };\n fluidCart?: {\n open: () => void;\n };\n }\n}\n\ninterface CartButtonProps {\n onCheckout?: (checkoutUrl: string) => void;\n}\n\nconst MAX_SDK_POLL_ATTEMPTS = 50; // 5 seconds at 100ms intervals\n\nexport function CartButton({ onCheckout }: CartButtonProps): React.ReactNode {\n const [initialCount, setInitialCount] = useState(0);\n\n const navigateToCheckout = useCallback(() => {\n if (!window.FluidCommerceSDK) {\n console.error(\"FluidCommerceSDK not available\");\n return;\n }\n\n try {\n const checkoutUrl = window.FluidCommerceSDK.getCheckoutUrl();\n if (!checkoutUrl) {\n console.error(\"No checkout URL available\");\n return;\n }\n onCheckout?.(checkoutUrl);\n } catch (error) {\n console.error(\"Error getting checkout URL:\", error);\n }\n }, [onCheckout]);\n\n useEffect(() => {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n let attempts = 0;\n let cancelled = false;\n\n const setupSDK = () => {\n if (cancelled) return;\n if (window.FluidCommerceSDK) {\n if (onCheckout) {\n window.FluidCommerceSDK.setOnCheckout(navigateToCheckout);\n }\n const count = window.FairShareSDK?.getCartItemCount?.();\n if (count != null) {\n setInitialCount(count);\n }\n } else if (attempts < MAX_SDK_POLL_ATTEMPTS) {\n attempts++;\n timeoutId = setTimeout(setupSDK, 100);\n }\n };\n\n setupSDK();\n return () => {\n cancelled = true;\n if (timeoutId) clearTimeout(timeoutId);\n };\n }, [navigateToCheckout, onCheckout]);\n\n return (\n <Button\n className=\"bg-primary text-primary-foreground hover:bg-primary/70 relative flex items-center gap-4 rounded-sm px-4 py-1.5\"\n onClick={() => {\n window.fluidCart?.open();\n }}\n >\n <div className=\"relative\">\n <ShoppingCart className=\"size-5\" />\n <span\n id=\"fluid-cart-count\"\n className=\"bg-primary-foreground text-primary absolute -top-1 -right-2 flex h-4 w-4 items-center justify-center rounded-full text-[8px] font-bold\"\n >\n {initialCount}\n </span>\n </div>\n <span>Cart</span>\n </Button>\n );\n}\n","import React, { useEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\n\ninterface ShopContainerProps {\n children: React.ReactNode;\n className?: string;\n cartScript?: React.ReactNode;\n cartWidget?: React.ReactNode;\n}\n\nexport default function ShopContainer({\n children,\n className = \"\",\n cartScript,\n cartWidget,\n}: ShopContainerProps): React.ReactNode {\n const containerRef = useRef<HTMLDivElement>(null);\n const [portalContainer, setPortalContainer] = useState<HTMLDivElement | null>(\n null,\n );\n\n useEffect(() => {\n const currentContainer = containerRef.current;\n if (!currentContainer) return;\n\n const reactContentWrapper = document.createElement(\"div\");\n reactContentWrapper.id = \"react-content-wrapper\";\n reactContentWrapper.style.cssText = `\n position: relative;\n `;\n reactContentWrapper.className = \"min-h-full\";\n\n currentContainer.appendChild(reactContentWrapper);\n\n setPortalContainer(reactContentWrapper);\n\n return () => {\n if (currentContainer && reactContentWrapper) {\n try {\n currentContainer.removeChild(reactContentWrapper);\n } catch (e) {\n console.warn(\"Failed to cleanup isolated container:\", e);\n }\n }\n setPortalContainer(null);\n };\n }, []);\n\n return (\n <>\n <div\n ref={containerRef}\n className={`isolated-shop-wrapper ${className} h-full`}\n >\n {portalContainer &&\n createPortal(\n <>\n {cartScript}\n {cartWidget}\n {children}\n </>,\n portalContainer,\n )}\n </div>\n </>\n );\n}\n","import { type ComponentProps, useEffect, useMemo } from \"react\";\nimport ShopApp from \"@fluid-app/shop-ui/components/shop-app\";\nimport {\n CartButton,\n CartScript,\n CartWidget,\n ShopContainer,\n} from \"@fluid-app/cart-ui\";\nimport {\n Breadcrumb,\n BreadcrumbList,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbPage,\n BreadcrumbSeparator,\n} from \"@fluid-app/ui-primitives\";\nimport {\n useScreenHeaderBreadcrumbs,\n useScreenHeaderActions,\n} from \"@fluid-app/portal-react/shell/ScreenHeaderContext\";\nimport type {\n BackgroundValue,\n BorderRadiusOptions,\n ColorOptions,\n PaddingOptions,\n} from \"../types\";\nimport type { WidgetPropertySchema } from \"../registries/property-schema-types\";\nimport { useFluidContext } from \"../providers/FluidProvider\";\nimport { useAppNavigation } from \"../shell/AppNavigationContext\";\nimport { useStore } from \"../hooks/use-store\";\nimport { PortalProductsApiProvider } from \"../products/PortalProductsApiProvider\";\nimport { usePortalProductDetail } from \"@fluid-app/products-core\";\n\ntype ShopScreenProps = ComponentProps<\"div\"> & {\n background?: BackgroundValue;\n textColor?: ColorOptions;\n accentColor?: ColorOptions;\n padding?: PaddingOptions;\n borderRadius?: BorderRadiusOptions;\n};\n\nexport function ShopScreen({\n /* eslint-disable @typescript-eslint/no-unused-vars -- destructured to exclude from divProps spread */\n background,\n textColor,\n accentColor,\n padding,\n borderRadius,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n ...divProps\n}: ShopScreenProps): React.JSX.Element {\n const { config } = useFluidContext();\n const { data: store } = useStore();\n const { currentSlug, navigate } = useAppNavigation();\n const countryCode = config.countryIso ?? \"US\";\n const subdomain = store?.subdomain;\n\n // Parse product ID from slug: \"shop/{productId}\"\n const parts = currentSlug.split(\"/\");\n const productId = parts[1] ?? null;\n\n const headerBreadcrumbs = useMemo(\n () => (\n <Breadcrumb>\n <BreadcrumbList className=\"text-lg\">\n <BreadcrumbItem>\n {productId ? (\n <BreadcrumbLink\n onClick={() => navigate(\"shop\")}\n className=\"cursor-pointer font-semibold\"\n >\n Shop\n </BreadcrumbLink>\n ) : (\n <BreadcrumbPage className=\"font-semibold\">Shop</BreadcrumbPage>\n )}\n </BreadcrumbItem>\n </BreadcrumbList>\n </Breadcrumb>\n ),\n [productId, navigate],\n );\n useScreenHeaderBreadcrumbs(headerBreadcrumbs);\n\n const headerActions = useMemo(\n () => (\n <div className=\"flex items-center gap-4\">\n <CartButton />\n </div>\n ),\n [],\n );\n useScreenHeaderActions(headerActions);\n\n // Sync country to FairShare SDK so the cart uses the correct country.\n // The SDK loads asynchronously via a script tag and also initializes its\n // session asynchronously after the object appears on window. Poll until\n // updateLocaleSettings resolves successfully (Sentry fix: FLUID-ADMIN-1FD —\n // SDK object present does not mean session is ready).\n useEffect(() => {\n if (!countryCode) return;\n type FairShareWindow = {\n FairShareSDK?: {\n updateLocaleSettings: (opts: { country: string }) => Promise<void>;\n };\n };\n const sdk = () => (window as FairShareWindow).FairShareSDK;\n let done = false;\n\n let inFlight = false;\n const tryUpdate = async () => {\n const fairShareSdk = sdk();\n if (done || inFlight || !fairShareSdk) return;\n inFlight = true;\n try {\n await fairShareSdk.updateLocaleSettings({ country: countryCode });\n done = true;\n clearInterval(id);\n } catch {\n // Session not yet initialized — keep polling until it is\n } finally {\n inFlight = false;\n }\n };\n\n let attempts = 0;\n const id = setInterval(() => {\n if (attempts >= 50) {\n console.warn(\n \"[FairShare] updateLocaleSettings: gave up after 50 attempts — session never became ready\",\n { country: countryCode },\n );\n clearInterval(id);\n return;\n }\n attempts++;\n void tryUpdate();\n }, 100);\n\n return () => {\n done = true;\n clearInterval(id);\n };\n }, [countryCode]);\n\n // TODO(portal-theme): Cart widget theming requires AppShell to expose\n // resolvedTheme via context. Currently it's local state in AppShell.\n\n return (\n <div {...divProps} className={divProps.className ?? \"\"}>\n <ShopContainer\n cartScript={\n subdomain ? (\n <CartScript\n subdomain={subdomain}\n bffMode\n scriptSrc={\n import.meta.env.DEV\n ? String(\n import.meta.env.VITE_FAIRSHARE_SDK_URL ||\n \"http://localhost:4444/index.js\",\n )\n : undefined\n }\n apiBaseUrl={\n import.meta.env.DEV\n ? String(\n import.meta.env.VITE_FAIRSHARE_API_BASE_URL ||\n \"http://api.fluid.localhost:3000\",\n )\n : undefined\n }\n debug={import.meta.env.DEV}\n />\n ) : null\n }\n cartWidget={<CartWidget />}\n >\n <PortalProductsApiProvider>\n {productId && <ProductBreadcrumb productId={productId} />}\n <ShopApp\n companyLogoUrl={store?.logo_url ?? undefined}\n productId={productId}\n onSelectProduct={(id) => navigate(`shop/${id}`)}\n onBack={() => navigate(\"shop\")}\n />\n </PortalProductsApiProvider>\n </ShopContainer>\n </div>\n );\n}\n\nexport const shopScreenPropertySchema: WidgetPropertySchema = {\n widgetType: \"ShopScreen\",\n displayName: \"Shop Screen\",\n tabsConfig: [{ id: \"styling\", label: \"Styling\" }],\n fields: [],\n} as const satisfies WidgetPropertySchema;\n\n/**\n * Renders inside PortalProductsCoreProvider to set breadcrumbs with the\n * product name: \"Shop > {product name}\". Overrides the parent's \"Shop\"\n * breadcrumb once product data loads.\n */\nfunction ProductBreadcrumb({ productId }: { productId: string }) {\n const { navigate } = useAppNavigation();\n const { product } = usePortalProductDetail({ productId });\n const productName = product?.name ?? \"Product\";\n\n const breadcrumb = useMemo(\n () => (\n <Breadcrumb>\n <BreadcrumbList className=\"text-lg\">\n <BreadcrumbItem>\n <BreadcrumbLink\n onClick={() => navigate(\"shop\")}\n className=\"cursor-pointer font-semibold\"\n >\n Shop\n </BreadcrumbLink>\n </BreadcrumbItem>\n <BreadcrumbSeparator />\n <BreadcrumbItem>\n <BreadcrumbPage className=\"font-semibold\">\n {productName}\n </BreadcrumbPage>\n </BreadcrumbItem>\n </BreadcrumbList>\n </Breadcrumb>\n ),\n [productName, navigate],\n );\n useScreenHeaderBreadcrumbs(breadcrumb);\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAeD,SAAgB,WAAW,KAAyC;AAClE,KAAI,CAAC,IAAK,QAAO;CACjB,MAAM,WAAW,IAAI,aAAa;AAClC,QAAO,iBAAiB,MAAM,QAAQ,SAAS,SAAS,IAAI,CAAC;;AAiB/D,SAAgB,qBAAqB,UAA0B;AAC7D,KAAI,S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A,UACE,oBAAC,gBAAD;IACE,eAAe,SAAS,OAAO;IAC/B,WAAU;cACX;IAEgB,CAAA,EACF,CAAA;GACjB,oBAAC,qBAAD,EAAuB,CAAA;GACvB,oBAAC,gBAAD,EAAA,UACE,oBAAC,gBAAD;IAAgB,WAAU;cACvB;IACc,CAAA,EACF,CAAA;GACF;KACN,CAAA,EAEf,CAAC,aAAa,SAAS,CACxB,CACqC;AAEtC,QAAO"}
@@ -44,6 +44,6 @@ require("./VideoWidget-BntlfHhP.cjs");
44
44
  require("./ScreenHeaderContext-PbjwAMeB.cjs");
45
45
  require("./SearchSort-Hwga1dIi.cjs");
46
46
  require("./PortalProductsApiProvider-DzjO6yix.cjs");
47
- const require_ShopScreen = require("./ShopScreen-CsYmdHwe.cjs");
47
+ const require_ShopScreen = require("./ShopScreen-_2S-9SvE.cjs");
48
48
  exports.ShopScreen = require_ShopScreen.ShopScreen;
49
49
  exports.shopScreenPropertySchema = require_ShopScreen.shopScreenPropertySchema;
@@ -480,77 +480,74 @@ function ProductListing({ companyLogoUrl, renderImage, onSelectProduct, cartButt
480
480
  return () => observer.disconnect();
481
481
  }, [handleIntersect]);
482
482
  const allProducts = data?.pages.flatMap((page) => page.products) ?? [];
483
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
484
- className: "h-full overflow-auto",
485
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
486
- className: "mx-auto px-2 md:px-10",
487
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
488
- className: "flex items-center justify-end gap-2 py-4",
489
- children: [
490
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
491
- className: "w-full max-w-sm",
492
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SearchSort.SearchSort, {
493
- searchValue: catalog.searchTerm,
494
- onSearchChange: catalog.setSearchTerm,
495
- placeholder: "Search products..."
496
- })
497
- }),
498
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.DropdownMenu, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.DropdownMenuTrigger, {
499
- asChild: true,
500
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Button, {
501
- variant: "outline",
502
- size: "icon",
503
- className: "h-9 w-9 shrink-0",
504
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ArrowUpDown, { className: "h-3 w-3" })
505
- })
506
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.DropdownMenuContent, {
507
- align: "end",
508
- className: "w-60",
509
- children: [
510
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.DropdownMenuLabel, { children: "Sort By" }),
511
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.DropdownMenuSeparator, {}),
512
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.DropdownMenuRadioGroup, {
513
- value: catalog.currentSort,
514
- onValueChange: catalog.setCurrentSort,
515
- children: SORT_OPTIONS.map((opt) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.DropdownMenuRadioItem, {
516
- value: opt.id,
517
- children: opt.label
518
- }, opt.id))
519
- })
520
- ]
521
- })] }),
522
- cartButton && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
523
- className: "flex shrink-0 items-center gap-3",
524
- children: cartButton
525
- })
526
- ]
527
- })
528
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
529
- className: "mx-auto space-y-8 px-2 md:px-10 md:py-8",
530
- children: isLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonGrid, {}) : error ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
531
- className: "mx-auto my-6 rounded-lg bg-red-100 px-3 py-2 text-red-500",
532
- children: ["Error: ", error.message]
533
- }) : isFetched && allProducts.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
534
- className: "flex flex-col items-center justify-center py-8 text-center",
535
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
536
- className: "text-muted-foreground text-sm",
537
- children: catalog.searchTerm ? `No products match "${catalog.searchTerm}". Try a different search term.` : "There are no products available at the moment."
538
- })
539
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
483
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
484
+ className: "mx-auto px-2 md:px-10",
485
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
486
+ className: "flex items-center justify-end gap-2 py-4",
487
+ children: [
540
488
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
541
- className: GRID_CLASS,
542
- children: allProducts.map((product) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProductCard, {
543
- product: tagPortalProduct(product),
544
- companyLogoUrl,
545
- renderImage,
546
- onClick: () => onSelectProduct(String(product.id))
547
- }, product.id))
489
+ className: "w-full max-w-sm",
490
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SearchSort.SearchSort, {
491
+ searchValue: catalog.searchTerm,
492
+ onSearchChange: catalog.setSearchTerm,
493
+ placeholder: "Search products..."
494
+ })
548
495
  }),
549
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ref: observerTarget }),
550
- isFetchingNextPage && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonGrid, { count: 4 })
551
- ] })
552
- })]
553
- });
496
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.DropdownMenu, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.DropdownMenuTrigger, {
497
+ asChild: true,
498
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Button, {
499
+ variant: "outline",
500
+ size: "icon",
501
+ className: "h-9 w-9 shrink-0",
502
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ArrowUpDown, { className: "h-3 w-3" })
503
+ })
504
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.DropdownMenuContent, {
505
+ align: "end",
506
+ className: "w-60",
507
+ children: [
508
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.DropdownMenuLabel, { children: "Sort By" }),
509
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.DropdownMenuSeparator, {}),
510
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.DropdownMenuRadioGroup, {
511
+ value: catalog.currentSort,
512
+ onValueChange: catalog.setCurrentSort,
513
+ children: SORT_OPTIONS.map((opt) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.DropdownMenuRadioItem, {
514
+ value: opt.id,
515
+ children: opt.label
516
+ }, opt.id))
517
+ })
518
+ ]
519
+ })] }),
520
+ cartButton && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
521
+ className: "flex shrink-0 items-center gap-3",
522
+ children: cartButton
523
+ })
524
+ ]
525
+ })
526
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
527
+ className: "mx-auto space-y-8 px-2 md:px-10 md:py-8",
528
+ children: isLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonGrid, {}) : error ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
529
+ className: "mx-auto my-6 rounded-lg bg-red-100 px-3 py-2 text-red-500",
530
+ children: ["Error: ", error.message]
531
+ }) : isFetched && allProducts.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
532
+ className: "flex flex-col items-center justify-center py-8 text-center",
533
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
534
+ className: "text-muted-foreground text-sm",
535
+ children: catalog.searchTerm ? `No products match "${catalog.searchTerm}". Try a different search term.` : "There are no products available at the moment."
536
+ })
537
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
538
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
539
+ className: GRID_CLASS,
540
+ children: allProducts.map((product) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProductCard, {
541
+ product: tagPortalProduct(product),
542
+ companyLogoUrl,
543
+ renderImage,
544
+ onClick: () => onSelectProduct(String(product.id))
545
+ }, product.id))
546
+ }),
547
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ref: observerTarget }),
548
+ isFetchingNextPage && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonGrid, { count: 4 })
549
+ ] })
550
+ })] });
554
551
  }
555
552
  /**
556
553
  * Build the variant options map by grouping option_values across non-master variants.
@@ -732,7 +729,7 @@ function ProductDetail({ productId, renderImage }) {
732
729
  const isBundle = product.bundle === true;
733
730
  const bundleUrl = isBundle && product.canonical_url ? product.canonical_url : null;
734
731
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
735
- className: "h-full overflow-auto pb-5 md:pl-8",
732
+ className: "pb-5 md:pl-8",
736
733
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
737
734
  className: "mx-auto max-w-7xl px-4 py-8 md:pr-6 md:pl-0 lg:pr-8 lg:pl-0",
738
735
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -1084,7 +1081,7 @@ function ShopScreen({ background, textColor, accentColor, padding, borderRadius,
1084
1081
  }, [countryCode]);
1085
1082
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1086
1083
  ...divProps,
1087
- className: `h-full ${divProps.className ?? ""}`,
1084
+ className: divProps.className ?? "",
1088
1085
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShopContainer, {
1089
1086
  cartScript: subdomain ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CartScript, {
1090
1087
  subdomain,
@@ -1152,4 +1149,4 @@ Object.defineProperty(exports, "shopScreenPropertySchema", {
1152
1149
  }
1153
1150
  });
1154
1151
 
1155
- //# sourceMappingURL=ShopScreen-CsYmdHwe.cjs.map
1152
+ //# sourceMappingURL=ShopScreen-_2S-9SvE.cjs.map