bitsnap-react 1.8.0 → 1.10.0

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.
Files changed (124) hide show
  1. package/README.md +162 -0
  2. package/dist/CartProvider-HXLGQ4EX.mjs +2 -0
  3. package/dist/CartProvider-OHHYOMSG.js +2 -0
  4. package/dist/CartProvider-OHHYOMSG.js.map +1 -0
  5. package/dist/analytics.d.mts +45 -0
  6. package/dist/analytics.d.ts +45 -0
  7. package/dist/analytics.js +2 -0
  8. package/dist/analytics.js.map +1 -0
  9. package/dist/analytics.mjs +2 -0
  10. package/dist/catalog.d.mts +14 -1
  11. package/dist/catalog.d.ts +14 -1
  12. package/dist/catalog.js +1 -1
  13. package/dist/catalog.js.map +1 -1
  14. package/dist/catalog.mjs +1 -1
  15. package/dist/chunk-3Z6VNXBP.js +2 -0
  16. package/dist/chunk-3Z6VNXBP.js.map +1 -0
  17. package/dist/chunk-43IIYJ6J.mjs +2 -0
  18. package/dist/chunk-43IIYJ6J.mjs.map +1 -0
  19. package/dist/chunk-6D3OORMK.mjs +2 -0
  20. package/dist/chunk-6D3OORMK.mjs.map +1 -0
  21. package/dist/chunk-ADYVTMGH.mjs +2 -0
  22. package/dist/chunk-ADYVTMGH.mjs.map +1 -0
  23. package/dist/{chunk-WRCXZMKK.js → chunk-AJNULBC3.js} +2 -2
  24. package/dist/chunk-AJNULBC3.js.map +1 -0
  25. package/dist/chunk-B32ACCW2.js +2 -0
  26. package/dist/chunk-B32ACCW2.js.map +1 -0
  27. package/dist/chunk-DDY7IBMG.mjs +2 -0
  28. package/dist/chunk-DDY7IBMG.mjs.map +1 -0
  29. package/dist/chunk-DPKT6ITB.js +4 -0
  30. package/dist/chunk-DPKT6ITB.js.map +1 -0
  31. package/dist/{chunk-T2POA6RW.js → chunk-F46RJVWC.js} +2 -2
  32. package/dist/chunk-F46RJVWC.js.map +1 -0
  33. package/dist/chunk-F6GQLKA6.js +2 -0
  34. package/dist/chunk-F6GQLKA6.js.map +1 -0
  35. package/dist/chunk-JSDGZ4NY.js.map +1 -1
  36. package/dist/chunk-JXCHRSPW.mjs +4 -0
  37. package/dist/chunk-JXCHRSPW.mjs.map +1 -0
  38. package/dist/chunk-KOYBZORL.js.map +1 -1
  39. package/dist/chunk-RLEC25JI.mjs +2 -0
  40. package/dist/chunk-RLEC25JI.mjs.map +1 -0
  41. package/dist/chunk-RVILRUW3.js +2 -0
  42. package/dist/chunk-RVILRUW3.js.map +1 -0
  43. package/dist/chunk-T2OUOO4X.mjs +2 -0
  44. package/dist/chunk-T2OUOO4X.mjs.map +1 -0
  45. package/dist/chunk-VIII45AC.js +2 -0
  46. package/dist/chunk-VIII45AC.js.map +1 -0
  47. package/dist/chunk-XIHGWNTS.js +2 -0
  48. package/dist/chunk-XIHGWNTS.js.map +1 -0
  49. package/dist/chunk-YXFJG4MF.mjs +2 -0
  50. package/dist/chunk-YXFJG4MF.mjs.map +1 -0
  51. package/dist/chunk-ZPTHK4OX.mjs +2 -0
  52. package/dist/{chunk-OJT3YO2R.mjs.map → chunk-ZPTHK4OX.mjs.map} +1 -1
  53. package/dist/consent.d.mts +165 -0
  54. package/dist/consent.d.ts +165 -0
  55. package/dist/consent.js +75 -0
  56. package/dist/consent.js.map +1 -0
  57. package/dist/consent.mjs +75 -0
  58. package/dist/consent.mjs.map +1 -0
  59. package/dist/course.d.mts +13 -3
  60. package/dist/course.d.ts +13 -3
  61. package/dist/course.js +1 -1
  62. package/dist/course.js.map +1 -1
  63. package/dist/course.mjs +1 -1
  64. package/dist/course.mjs.map +1 -1
  65. package/dist/embed/analytics.js +1 -0
  66. package/dist/embed/consent.js +74 -0
  67. package/dist/errors.js.map +1 -1
  68. package/dist/index.css +1 -1
  69. package/dist/index.css.map +1 -1
  70. package/dist/index.d.mts +54 -7
  71. package/dist/index.d.ts +54 -7
  72. package/dist/index.js +1 -1
  73. package/dist/index.js.map +1 -1
  74. package/dist/index.mjs +1 -1
  75. package/dist/index.mjs.map +1 -1
  76. package/dist/instrument-CmxK7S4T.d.mts +929 -0
  77. package/dist/instrument-CmxK7S4T.d.ts +929 -0
  78. package/dist/internal.js.map +1 -1
  79. package/dist/methods-A5KGZBAM.js +2 -0
  80. package/dist/methods-A5KGZBAM.js.map +1 -0
  81. package/dist/methods-AOHKV7IN.mjs +2 -0
  82. package/dist/methods-AOHKV7IN.mjs.map +1 -0
  83. package/dist/models.js.map +1 -1
  84. package/dist/returns.d.mts +9 -1
  85. package/dist/returns.d.ts +9 -1
  86. package/dist/returns.js +1 -1
  87. package/dist/returns.js.map +1 -1
  88. package/dist/returns.mjs +1 -1
  89. package/dist/{types-PSBBDdQm.d.mts → types-BnVWLcoB.d.mts} +13 -0
  90. package/dist/{types-BTm_ZolC.d.ts → types-i-IuN4Im.d.ts} +13 -0
  91. package/package.json +46 -45
  92. package/dist/CartProvider-5KAG5QGA.mjs +0 -2
  93. package/dist/CartProvider-7GJXW2IP.js +0 -2
  94. package/dist/CartProvider-7GJXW2IP.js.map +0 -1
  95. package/dist/chunk-45AP7UZE.mjs +0 -2
  96. package/dist/chunk-45AP7UZE.mjs.map +0 -1
  97. package/dist/chunk-7XTDFTQU.js +0 -4
  98. package/dist/chunk-7XTDFTQU.js.map +0 -1
  99. package/dist/chunk-C6Z7LOHB.mjs +0 -2
  100. package/dist/chunk-C6Z7LOHB.mjs.map +0 -1
  101. package/dist/chunk-HB6KQT26.mjs +0 -4
  102. package/dist/chunk-HB6KQT26.mjs.map +0 -1
  103. package/dist/chunk-LWK4E5G5.js +0 -2
  104. package/dist/chunk-LWK4E5G5.js.map +0 -1
  105. package/dist/chunk-OJT3YO2R.mjs +0 -2
  106. package/dist/chunk-OUYRKNZJ.mjs +0 -2
  107. package/dist/chunk-OUYRKNZJ.mjs.map +0 -1
  108. package/dist/chunk-P2YB25KZ.js +0 -2
  109. package/dist/chunk-P2YB25KZ.js.map +0 -1
  110. package/dist/chunk-T2POA6RW.js.map +0 -1
  111. package/dist/chunk-VPKE2ZOR.mjs +0 -2
  112. package/dist/chunk-VPKE2ZOR.mjs.map +0 -1
  113. package/dist/chunk-WRCXZMKK.js.map +0 -1
  114. package/dist/chunk-WSM4OM72.mjs +0 -2
  115. package/dist/chunk-WSM4OM72.mjs.map +0 -1
  116. package/dist/chunk-XRNTUSBH.js +0 -2
  117. package/dist/chunk-XRNTUSBH.js.map +0 -1
  118. package/dist/chunk-Z2BKIX6F.js +0 -2
  119. package/dist/chunk-Z2BKIX6F.js.map +0 -1
  120. package/dist/methods-ITD6WFIY.mjs +0 -2
  121. package/dist/methods-JENIGNF7.js +0 -2
  122. package/dist/methods-JENIGNF7.js.map +0 -1
  123. /package/dist/{CartProvider-5KAG5QGA.mjs.map → CartProvider-HXLGQ4EX.mjs.map} +0 -0
  124. /package/dist/{methods-ITD6WFIY.mjs.map → analytics.mjs.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/products/appearance.ts","../src/components/products/format.ts","../src/components/products/useProducts.ts","../src/components/products/fetch.ts","../src/components/products/ProductList.tsx","../src/components/products/cart-target.ts","../src/components/products/add-to-cart.ts","../src/components/products/texts.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport {\n getSlotAppearance,\n resolveAppearanceCore,\n type AppearanceElements,\n type ShadcnVariableMapping,\n type SlotAppearance,\n} from \"@/src/lib/appearance-core\";\n\n/**\n * Product list appearance API.\n *\n * It mirrors `CheckoutAppearance` and `ReturnsAppearance` (theme, tokens,\n * elements) so a shop can reuse one brand object for all of them. The resolver\n * is pure: it turns the caller input into a theme name, the tokens in effect,\n * the slot overrides and the inline style for the theme boundary.\n */\n\nexport type ProductListTheme = \"light\" | \"dark\";\n\nexport type ProductListAppearanceTokens = {\n /** Font family of the list. The library never loads fonts. */\n fontFamily?: string;\n /** Base font size. */\n fontSize?: string;\n /** List background. */\n background?: string;\n /** Raised surfaces: cards, image placeholders, skeletons. */\n surface?: string;\n /** Main text color. */\n foreground?: string;\n /** Secondary text: descriptions, the struck-through price. */\n mutedForeground?: string;\n /** Borders of cards and buttons. */\n border?: string;\n /** \"Add to cart\" button background. */\n buttonBackground?: string;\n /** \"Add to cart\" button text. */\n buttonForeground?: string;\n /** \"Add to cart\" button background on hover. */\n buttonHoverBackground?: string;\n /** Hover surface of cards and secondary buttons. */\n hoverSurface?: string;\n /** Focus ring color. */\n focusRing?: string;\n /** Error and unavailable state color. */\n error?: string;\n /** Badge background (subscription, unavailable). */\n badgeBackground?: string;\n /** Badge text. */\n badgeForeground?: string;\n /** Corner radius of cards, images and buttons. */\n radius?: string;\n};\n\n/**\n * Stable slot names. They are exposed as `data-bitsnap-products-slot`\n * attributes so they can also be targeted from plain CSS.\n */\nexport const PRODUCT_LIST_SLOT_NAMES = [\n \"root\",\n \"grid\",\n \"card\",\n \"cardLink\",\n \"image\",\n \"imagePlaceholder\",\n \"body\",\n \"name\",\n \"description\",\n \"price\",\n \"comparePrice\",\n \"badge\",\n \"actions\",\n \"addToCartButton\",\n \"selectButton\",\n \"message\",\n \"pagination\",\n \"paginationButton\",\n \"pageIndicator\",\n \"emptyState\",\n \"error\",\n \"retryButton\",\n \"skeleton\",\n] as const;\n\nexport type ProductListSlotName = (typeof PRODUCT_LIST_SLOT_NAMES)[number];\n\nexport type ProductListSlotAppearance = SlotAppearance;\n\nexport type ProductListAppearanceElements =\n AppearanceElements<ProductListSlotName>;\n\nexport type ProductListAppearance = {\n /** `\"light\"` or `\"dark\"`. Omitted means `\"light\"`. */\n theme?: ProductListTheme;\n /** Partial overrides applied over the theme preset. */\n tokens?: ProductListAppearanceTokens;\n /** Per element `className`/`style` overrides. */\n elements?: ProductListAppearanceElements;\n};\n\nexport type ResolvedProductListAppearance = {\n theme: ProductListTheme;\n /** Tokens that are in effect (the theme preset plus caller overrides). */\n tokens: ProductListAppearanceTokens;\n elements: ProductListAppearanceElements;\n /** Theme marker class for the theme boundary. */\n boundaryClassName: string;\n /** Inline custom properties applied to the list root. */\n boundaryStyle: CSSProperties;\n};\n\n/** CSS custom property used for each token. */\nexport const PRODUCT_LIST_TOKEN_VARIABLES = {\n fontFamily: \"--bitsnap-products-font-family\",\n fontSize: \"--bitsnap-products-font-size\",\n background: \"--bitsnap-products-background\",\n surface: \"--bitsnap-products-surface\",\n foreground: \"--bitsnap-products-foreground\",\n mutedForeground: \"--bitsnap-products-muted-foreground\",\n border: \"--bitsnap-products-border\",\n buttonBackground: \"--bitsnap-products-button-background\",\n buttonForeground: \"--bitsnap-products-button-foreground\",\n buttonHoverBackground: \"--bitsnap-products-button-hover-background\",\n hoverSurface: \"--bitsnap-products-hover-surface\",\n focusRing: \"--bitsnap-products-focus-ring\",\n error: \"--bitsnap-products-error\",\n badgeBackground: \"--bitsnap-products-badge-background\",\n badgeForeground: \"--bitsnap-products-badge-foreground\",\n radius: \"--bitsnap-products-radius\",\n} as const;\n\nexport type ProductListTokenName = keyof typeof PRODUCT_LIST_TOKEN_VARIABLES;\n\n/**\n * Complete palettes. They carry colors and radius only, so typography is never\n * reset implicitly. `products.css` falls back to the light values, which keeps\n * the list usable even when the boundary style is missing.\n */\nexport const PRODUCT_LIST_THEME_PRESETS: Record<\n ProductListTheme,\n ProductListAppearanceTokens\n> = {\n light: {\n background: \"#ffffff\",\n surface: \"#f9fafb\",\n foreground: \"#18181b\",\n mutedForeground: \"#71717a\",\n border: \"#e4e4e7\",\n buttonBackground: \"#18181b\",\n buttonForeground: \"#fafafa\",\n buttonHoverBackground: \"#000000\",\n hoverSurface: \"#f4f4f5\",\n focusRing: \"#71717a\",\n error: \"#dc2626\",\n badgeBackground: \"#f4f4f5\",\n badgeForeground: \"#3f3f46\",\n radius: \"8px\",\n },\n dark: {\n background: \"#18181b\",\n surface: \"#27272a\",\n foreground: \"#fafafa\",\n mutedForeground: \"#a1a1aa\",\n border: \"#3f3f46\",\n buttonBackground: \"#fafafa\",\n buttonForeground: \"#18181b\",\n buttonHoverBackground: \"#e4e4e7\",\n hoverSurface: \"#3f3f46\",\n focusRing: \"#a1a1aa\",\n error: \"#f87171\",\n badgeBackground: \"#3f3f46\",\n badgeForeground: \"#e4e4e7\",\n radius: \"8px\",\n },\n};\n\n/** The list renders its own elements, so no shared primitive needs remapping. */\nconst PRODUCT_LIST_SHADCN_VARIABLES: ShadcnVariableMapping<ProductListTokenName> =\n [];\n\nexport function resolveProductListAppearance(\n appearance?: ProductListAppearance,\n): ResolvedProductListAppearance {\n const resolved = resolveAppearanceCore<\n ProductListTokenName,\n ProductListTheme,\n ProductListSlotName\n >(appearance, {\n defaultTheme: \"light\",\n presets: PRODUCT_LIST_THEME_PRESETS,\n variables: PRODUCT_LIST_TOKEN_VARIABLES,\n shadcnVariables: PRODUCT_LIST_SHADCN_VARIABLES,\n });\n\n return {\n theme: resolved.theme,\n tokens: resolved.tokens,\n elements: resolved.elements,\n boundaryClassName: resolved.theme,\n boundaryStyle: resolved.boundaryStyle,\n };\n}\n\n/** Caller overrides for a single slot, if any were provided. */\nexport function getProductListSlotAppearance(\n resolved: ResolvedProductListAppearance,\n slot: ProductListSlotName,\n): ProductListSlotAppearance | undefined {\n return getSlotAppearance(resolved.elements, slot);\n}\n","import { DEFAULT_LOCALE } from \"../checkout/locale\";\n\nfunction createFormatter(\n locale: string,\n currency: string,\n): Intl.NumberFormat | undefined {\n try {\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n currencyDisplay: \"symbol\",\n });\n } catch {\n // RangeError: invalid locale or currency code.\n return undefined;\n }\n}\n\n/**\n * Formats a price in minor units (grosze, cents) for the locale, the same way\n * the cart does (`amount / 100`). An unknown locale falls back to Polish and an\n * invalid currency code to a plain number followed by the code.\n */\nexport function formatProductPrice(\n amount: number,\n currency: string,\n locale: string = DEFAULT_LOCALE,\n): string {\n const value = amount / 100;\n const formatter =\n createFormatter(locale, currency) ??\n createFormatter(DEFAULT_LOCALE, currency);\n\n return formatter != null\n ? formatter.format(value)\n : `${value.toFixed(2)} ${currency}`;\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { HOST } from \"../checkout/constants\";\nimport {\n clampPageSize,\n fetchProductList,\n pageCountFor,\n type ProductListData,\n type PublicListProduct,\n} from \"./fetch\";\n\nexport type UseProductsOptions = {\n /** Project (shop) ID. */\n projectID: string;\n /**\n * Origin of the Bitsnap backend. Defaults to the library host\n * (`https://bitsnap.pl`, or what `setCustomHost` had set when the component\n * first rendered; later `setCustomHost` calls do not move an existing list).\n * On a custom domain pass the domain itself, or an empty string for\n * same-origin requests.\n */\n host?: string;\n locale?: string;\n /** Products per page, 1 to 48. Defaults to 24. */\n pageSize?: number;\n search?: string;\n /**\n * First page, loaded on the server. It is always used for the first request\n * of the mounted list (the first fetch is skipped and the products are\n * available on the first render), so it has to be the page the props ask\n * for: page 1 with the same `pageSize`, `locale` and `search`. Later changes\n * of the props fetch again.\n */\n initialData?: ProductListData;\n};\n\nexport type UseProductsResult = {\n /** Products of the current page. Keeps the previous page while loading. */\n products: PublicListProduct[];\n totalCount: number;\n /** Current page, starting at 1. */\n page: number;\n pageCount: number;\n setPage: (page: number) => void;\n /** `true` until the current page is available, also during server rendering. */\n isLoading: boolean;\n error: Error | undefined;\n /** Loads the current page again. */\n refetch: () => void;\n};\n\ntype Snapshot = {\n /** Request the data belongs to; empty when it is not tied to one. */\n requestKey: string;\n data: ProductListData | undefined;\n error: Error | undefined;\n};\n\n/**\n * Loads the product catalog page by page. It uses a plain `fetch` without\n * credentials, never reads global state (`setProjectID`, `setCustomHost`) other\n * than the default host, and does nothing during server rendering - pass\n * `initialData` to render products in the server HTML.\n */\nexport function useProducts(options: UseProductsOptions): UseProductsResult {\n const { projectID, locale, search, initialData } = options;\n // The library host is a mutable global; read it once so a later\n // `setCustomHost` does not change the query of a mounted list.\n const [defaultHost] = useState(() => HOST);\n const host = options.host ?? defaultHost;\n const pageSize = clampPageSize(options.pageSize);\n\n // Everything that identifies a list; a change resets the page.\n const queryKey = JSON.stringify([\n projectID,\n host,\n locale ?? null,\n search?.trim() ?? null,\n pageSize,\n ]);\n\n const [pageState, setPageState] = useState({ queryKey, page: 1 });\n if (pageState.queryKey !== queryKey) {\n // Another list: start from page 1 (adjusting state while rendering).\n setPageState({ queryKey, page: 1 });\n }\n const [reloads, setReloads] = useState(0);\n const [snapshot, setSnapshot] = useState<Snapshot>(() => ({\n requestKey: initialData != null ? `${queryKey}|1|0` : \"\",\n data: initialData,\n error: undefined,\n }));\n\n // A page past the end (the catalog shrank) falls back to the last page once\n // the total is known.\n const totalCount = snapshot.data?.totalCount ?? 0;\n const pageCount = pageCountFor(totalCount, pageSize);\n const requestedPage = pageState.queryKey === queryKey ? pageState.page : 1;\n const page = totalCount > 0 ? Math.min(requestedPage, pageCount) : requestedPage;\n\n const requestKey = `${queryKey}|${page}|${reloads}`;\n\n const isCurrent = snapshot.requestKey === requestKey;\n\n useEffect(() => {\n if (isCurrent) {\n return;\n }\n\n const controller = new AbortController();\n fetchProductList(\n {\n projectID,\n host,\n locale,\n search,\n limit: pageSize,\n offset: (page - 1) * pageSize,\n },\n controller.signal,\n ).then(\n (data) => {\n if (controller.signal.aborted) {\n return;\n }\n setSnapshot({ requestKey, data, error: undefined });\n },\n (error: unknown) => {\n if (controller.signal.aborted) {\n return;\n }\n setSnapshot((previous) => ({\n requestKey,\n data: previous.data,\n error: error instanceof Error ? error : new Error(String(error)),\n }));\n },\n );\n\n return () => controller.abort();\n // `requestKey` carries projectID, host, locale, search, pageSize, page and\n // the reload counter.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [requestKey, isCurrent]);\n\n const setPage = useCallback(\n (next: number) => {\n const target = Math.max(1, Math.floor(next));\n setPageState({\n queryKey,\n page: totalCount > 0 ? Math.min(target, pageCount) : target,\n });\n },\n [queryKey, totalCount, pageCount],\n );\n\n const refetch = useCallback(() => setReloads((value) => value + 1), []);\n\n return useMemo(\n () => ({\n products: snapshot.data?.items ?? [],\n totalCount,\n page,\n pageCount,\n setPage,\n isLoading: !isCurrent,\n error: isCurrent ? snapshot.error : undefined,\n refetch,\n }),\n [snapshot, totalCount, page, pageCount, setPage, isCurrent, refetch],\n );\n}\n","import type { BitsnapModels } from \"@/src/models\";\n\nexport type PublicListProduct = BitsnapModels.PublicListProduct;\nexport type ProductListData = BitsnapModels.ProductListResponse;\n\nexport const DEFAULT_PAGE_SIZE = 24;\nexport const MAX_PAGE_SIZE = 48;\n\nexport type ProductListQuery = {\n projectID: string;\n /** Origin of the Bitsnap backend (or of a custom domain), without a path. */\n host: string;\n locale?: string;\n search?: string;\n limit: number;\n offset: number;\n};\n\nexport class ProductListError extends Error {\n readonly status: number | undefined;\n\n constructor(message: string, status?: number) {\n super(message);\n this.name = \"ProductListError\";\n this.status = status;\n }\n}\n\n/** Page size within what the backend accepts (1 to 48, default 24). */\nexport function clampPageSize(pageSize?: number): number {\n if (pageSize == null || !Number.isFinite(pageSize)) {\n return DEFAULT_PAGE_SIZE;\n }\n return Math.min(MAX_PAGE_SIZE, Math.max(1, Math.floor(pageSize)));\n}\n\nexport function pageCountFor(totalCount: number, pageSize: number): number {\n return Math.max(1, Math.ceil(totalCount / pageSize));\n}\n\n/** Origin without trailing slashes, so equal hosts compare equal as strings. */\nexport function normalizeHost(host: string): string {\n return host.replace(/\\/+$/, \"\");\n}\n\nexport function buildProductListURL(query: ProductListQuery): string {\n const params = new URLSearchParams();\n params.set(\"limit\", String(query.limit));\n params.set(\"offset\", String(query.offset));\n if (query.locale) {\n params.set(\"locale\", query.locale);\n }\n const search = query.search?.trim();\n if (search) {\n params.set(\"search\", search);\n }\n\n const host = normalizeHost(query.host);\n return `${host}/api/integrations/${encodeURIComponent(\n query.projectID,\n )}/public-commerce/product-list?${params.toString()}`;\n}\n\nfunction isProductListData(value: unknown): value is ProductListData {\n return (\n typeof value === \"object\" &&\n value != null &&\n Array.isArray((value as ProductListData).items) &&\n typeof (value as ProductListData).totalCount === \"number\"\n );\n}\n\n/**\n * Loads one page of the catalog with a plain, credential-less `fetch`. It does\n * not touch the global project ID or host.\n */\nexport async function fetchProductList(\n query: ProductListQuery,\n signal?: AbortSignal,\n): Promise<ProductListData> {\n const response = await fetch(buildProductListURL(query), {\n method: \"GET\",\n credentials: \"omit\",\n headers: { Accept: \"application/json\" },\n signal,\n });\n\n if (!response.ok) {\n throw new ProductListError(\n `Could not load products (${response.status})`,\n response.status,\n );\n }\n\n const payload: unknown = await response.json();\n if (!isProductListData(payload)) {\n throw new ProductListError(\"Unexpected product list response\");\n }\n\n return payload;\n}\n","import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { CSSProperties, ReactNode } from \"react\";\nimport { cn } from \"@/src/lib/utils\";\nimport { DEFAULT_LOCALE } from \"../checkout/locale\";\nimport { addProductToCart } from \"./add-to-cart\";\nimport {\n getProductListSlotAppearance,\n resolveProductListAppearance,\n type ProductListAppearance,\n type ProductListSlotName,\n type ResolvedProductListAppearance,\n} from \"./appearance\";\nimport { clampPageSize, type PublicListProduct } from \"./fetch\";\nimport { formatProductPrice } from \"./format\";\nimport {\n fillProductListText,\n resolveProductListTexts,\n type ProductListTexts,\n} from \"./texts\";\nimport { useProducts, type UseProductsOptions } from \"./useProducts\";\n\n/** What `renderItem` gets next to the product. */\nexport type ProductListItemContext = {\n /** Product page URL from `productHref`. */\n href: string;\n /** Price formatted for the locale and currency, without the \"from\" prefix. */\n price: string;\n /** Formatted regular price when the product is discounted. */\n compareAtPrice: string | null;\n texts: ProductListTexts;\n locale: string;\n /** Adds the product to the cart the way the built-in button does. */\n addToCart: () => Promise<void>;\n};\n\nexport type ProductListProps = UseProductsOptions & {\n /**\n * Product page URL. Defaults to the relative `/p/{uniqueSlug}`, which works\n * on a Bitsnap custom domain. Embedded on another site, return the full\n * URL of the product page.\n */\n productHref?: (product: PublicListProduct) => string;\n appearance?: ProductListAppearance;\n /** Text overrides, applied whatever the locale. */\n texts?: Partial<ProductListTexts>;\n /** Replaces the content of a card. The card frame stays. */\n renderItem?: (\n product: PublicListProduct,\n context: ProductListItemContext,\n ) => ReactNode;\n /**\n * Called by the \"Add to cart\" button instead of the default action\n * (`Bitsnap.addProductToCart`). A rejected promise shows the error message.\n */\n onAddToCart?: (product: PublicListProduct) => void | Promise<void>;\n /** Open the cart drawer after the default add to cart. Defaults to `true`. */\n showCartOnAdd?: boolean;\n className?: string;\n};\n\ntype ListContext = {\n appearance: ResolvedProductListAppearance;\n texts: ProductListTexts;\n locale: string;\n};\n\nconst ProductListContext = createContext<ListContext | undefined>(undefined);\n\nfunction useListContext(): ListContext {\n const value = useContext(ProductListContext);\n if (value == null) {\n throw new Error(\"ProductList parts must be rendered inside ProductList\");\n }\n return value;\n}\n\n/** Stable slot attribute, built-in classes and the caller overrides for a slot. */\nfunction useSlot(slot: ProductListSlotName, className?: string) {\n const { appearance } = useListContext();\n const override = getProductListSlotAppearance(appearance, slot);\n\n return {\n \"data-bitsnap-products-slot\": slot,\n className: cn(className, override?.className),\n style: override?.style,\n };\n}\n\nconst BUTTON_CLASS =\n \"inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50\";\nconst BLOCK_BUTTON_CLASS = `${BUTTON_CLASS} w-full`;\nconst LINK_BUTTON_CLASS = `${BLOCK_BUTTON_CLASS} no-underline`;\n\ntype AddStatus = \"idle\" | \"adding\" | \"added\" | \"error\";\n\nfunction AddToCartButton({\n product,\n onAdd,\n}: {\n product: PublicListProduct;\n onAdd: () => Promise<void>;\n}) {\n const { texts } = useListContext();\n const [status, setStatus] = useState<AddStatus>(\"idle\");\n const button = useSlot(\"addToCartButton\", BLOCK_BUTTON_CLASS);\n const message = useSlot(\"message\", \"mt-2 text-xs\");\n\n useEffect(() => {\n if (status !== \"added\") {\n return;\n }\n const timer = setTimeout(() => setStatus(\"idle\"), 2000);\n return () => clearTimeout(timer);\n }, [status]);\n\n const click = useCallback(async () => {\n setStatus(\"adding\");\n try {\n await onAdd();\n setStatus(\"added\");\n } catch (error) {\n console.error(\"bitsnap-react: could not add to the cart\", error);\n setStatus(\"error\");\n }\n }, [onAdd]);\n\n const label =\n status === \"adding\"\n ? texts.addingToCart\n : status === \"added\"\n ? texts.addedToCart\n : texts.addToCart;\n\n return (\n <>\n <button\n type=\"button\"\n {...button}\n disabled={status === \"adding\"}\n aria-label={`${label}: ${product.name}`}\n onClick={click}\n >\n {label}\n </button>\n {status === \"error\" ? (\n <p {...message} role=\"alert\">\n {texts.addToCartError}\n </p>\n ) : null}\n </>\n );\n}\n\nfunction ProductCard({\n product,\n href,\n onAdd,\n renderItem,\n}: {\n product: PublicListProduct;\n href: string;\n onAdd: () => Promise<void>;\n renderItem?: ProductListProps[\"renderItem\"];\n}) {\n const { texts, locale } = useListContext();\n const card = useSlot(\n \"card\",\n \"relative flex flex-col overflow-hidden border transition-colors\",\n );\n const cardLink = useSlot(\"cardLink\", \"flex flex-1 flex-col no-underline\");\n const imageFrame = useSlot(\"image\", \"aspect-square w-full overflow-hidden\");\n const placeholder = useSlot(\"imagePlaceholder\", \"aspect-square w-full\");\n const body = useSlot(\"body\", \"flex flex-1 flex-col gap-1 p-4\");\n const name = useSlot(\"name\", \"text-base font-medium leading-snug\");\n const description = useSlot(\"description\", \"line-clamp-2 text-sm\");\n const price = useSlot(\"price\", \"mt-auto pt-2 text-base font-semibold\");\n const comparePrice = useSlot(\"comparePrice\", \"ml-2 text-sm font-normal\");\n const badge = useSlot(\n \"badge\",\n \"absolute left-3 top-3 px-2 py-0.5 text-xs font-medium\",\n );\n const actions = useSlot(\"actions\", \"p-4 pt-0\");\n const selectButton = useSlot(\"selectButton\", LINK_BUTTON_CLASS);\n\n const formattedPrice = formatProductPrice(\n product.price,\n product.currency,\n locale,\n );\n const formattedCompare =\n product.compareAtPrice != null && product.compareAtPrice > product.price\n ? formatProductPrice(product.compareAtPrice, product.currency, locale)\n : null;\n\n if (renderItem != null) {\n return (\n <li {...card} data-unavailable={product.available ? undefined : \"\"}>\n {renderItem(product, {\n href,\n price: formattedPrice,\n compareAtPrice: formattedCompare,\n texts,\n locale,\n addToCart: onAdd,\n })}\n </li>\n );\n }\n\n const imageSource = product.image?.thumbnailUrl ?? product.image?.url;\n const badgeText = !product.available\n ? texts.unavailable\n : product.isRecurring\n ? texts.subscription\n : null;\n\n return (\n <li {...card} data-unavailable={product.available ? undefined : \"\"}>\n <a {...cardLink} href={href}>\n {imageSource != null ? (\n <div {...imageFrame}>\n <img\n src={imageSource}\n alt=\"\"\n loading=\"lazy\"\n decoding=\"async\"\n className=\"h-full w-full object-cover\"\n />\n </div>\n ) : (\n <div {...placeholder} aria-hidden=\"true\" />\n )}\n <div {...body}>\n <h3 {...name}>{product.name}</h3>\n {product.shortDescription ? (\n <p {...description}>{product.shortDescription}</p>\n ) : null}\n <p {...price}>\n {product.priceFrom\n ? fillProductListText(texts.priceFrom, { price: formattedPrice })\n : formattedPrice}\n {formattedCompare != null ? (\n <>\n <span className=\"sr-only\">{texts.originalPrice}: </span>\n <del {...comparePrice}>{formattedCompare}</del>\n </>\n ) : null}\n </p>\n </div>\n </a>\n {badgeText != null ? (\n <span\n {...badge}\n data-kind={product.available ? \"subscription\" : \"unavailable\"}\n >\n {badgeText}\n </span>\n ) : null}\n <div {...actions}>\n {!product.available ? (\n <button type=\"button\" {...selectButton} disabled>\n {texts.unavailable}\n </button>\n ) : product.addToCart ? (\n <AddToCartButton product={product} onAdd={onAdd} />\n ) : (\n <a {...selectButton} href={href}>\n {product.variantCount > 1 ? texts.chooseOptions : texts.viewProduct}\n </a>\n )}\n </div>\n </li>\n );\n}\n\nconst GRID_CLASS =\n \"m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-5 p-0\";\n\nfunction SkeletonGrid({ count, label }: { count: number; label: string }) {\n const grid = useSlot(\"grid\", GRID_CLASS);\n const skeleton = useSlot(\"skeleton\", \"aspect-[3/4] animate-pulse\");\n\n return (\n <div {...grid} role=\"status\" aria-busy=\"true\" aria-label={label}>\n {Array.from({ length: count }, (_, index) => (\n <div key={index} {...skeleton} aria-hidden=\"true\" />\n ))}\n </div>\n );\n}\n\nfunction Pagination({\n page,\n pageCount,\n isLoading,\n onPage,\n}: {\n page: number;\n pageCount: number;\n isLoading: boolean;\n onPage: (page: number) => void;\n}) {\n const { texts } = useListContext();\n const nav = useSlot(\n \"pagination\",\n \"mt-8 flex items-center justify-center gap-4\",\n );\n const button = useSlot(\"paginationButton\", BUTTON_CLASS);\n const indicator = useSlot(\"pageIndicator\", \"text-sm\");\n\n return (\n <nav {...nav} aria-label={texts.pagination}>\n <button\n type=\"button\"\n {...button}\n aria-disabled={isLoading || page <= 1}\n onClick={() => {\n if (!isLoading && page > 1) {\n onPage(page - 1);\n }\n }}\n >\n {texts.previousPage}\n </button>\n <span {...indicator} aria-live=\"polite\">\n {fillProductListText(texts.pageOf, { page, pageCount })}\n </span>\n <button\n type=\"button\"\n {...button}\n aria-disabled={isLoading || page >= pageCount}\n onClick={() => {\n if (!isLoading && page < pageCount) {\n onPage(page + 1);\n }\n }}\n >\n {texts.nextPage}\n </button>\n </nav>\n );\n}\n\nfunction ProductListContent({\n options,\n productHref,\n renderItem,\n onAddToCart,\n showCartOnAdd,\n}: {\n options: UseProductsOptions;\n productHref: (product: PublicListProduct) => string;\n renderItem?: ProductListProps[\"renderItem\"];\n onAddToCart?: ProductListProps[\"onAddToCart\"];\n showCartOnAdd: boolean;\n}) {\n const { texts } = useListContext();\n const { products, page, pageCount, setPage, isLoading, error, refetch } =\n useProducts(options);\n\n // After a page change by the user, move focus to the products (the button\n // that was pressed stays where it is, but the content above it changes) and\n // bring them into view once the page has loaded.\n const content = useRef<HTMLDivElement>(null);\n const movedPage = useRef(false);\n const changePage = useCallback(\n (next: number) => {\n movedPage.current = true;\n setPage(next);\n },\n [setPage],\n );\n useEffect(() => {\n if (isLoading || !movedPage.current) {\n return;\n }\n movedPage.current = false;\n content.current?.focus({ preventScroll: true });\n content.current?.scrollIntoView({ block: \"start\" });\n }, [isLoading]);\n\n const grid = useSlot(\"grid\", GRID_CLASS);\n const empty = useSlot(\"emptyState\", \"py-12 text-center text-sm\");\n const errorSlot = useSlot(\"error\", \"flex flex-col items-center gap-3 py-12 text-center text-sm\");\n const retry = useSlot(\"retryButton\", BUTTON_CLASS);\n\n const { projectID, host } = options;\n const addFor = useCallback(\n (product: PublicListProduct) => () =>\n onAddToCart != null\n ? Promise.resolve(onAddToCart(product))\n : addProductToCart(product, {\n projectID,\n host,\n showCart: showCartOnAdd,\n }),\n [onAddToCart, projectID, host, showCartOnAdd],\n );\n\n let body: ReactNode;\n if (isLoading && products.length === 0) {\n body = (\n <SkeletonGrid\n count={Math.min(clampPageSize(options.pageSize), 8)}\n label={texts.loading}\n />\n );\n } else if (error != null) {\n body = (\n <div {...errorSlot} role=\"alert\">\n <p>{texts.error}</p>\n <button type=\"button\" {...retry} onClick={refetch}>\n {texts.retry}\n </button>\n </div>\n );\n } else if (products.length === 0) {\n body = <p {...empty}>{texts.empty}</p>;\n } else {\n body = (\n <ul\n {...grid}\n aria-busy={isLoading || undefined}\n className={cn(grid.className, isLoading && \"opacity-60\")}\n >\n {products.map((product) => (\n <ProductCard\n key={product.id}\n product={product}\n href={productHref(product)}\n onAdd={addFor(product)}\n renderItem={renderItem}\n />\n ))}\n </ul>\n );\n }\n\n return (\n <div\n ref={content}\n tabIndex={-1}\n className=\"p-1 outline-none scroll-mt-4\"\n >\n {body}\n {pageCount > 1 && error == null ? (\n <Pagination\n page={page}\n pageCount={pageCount}\n isLoading={isLoading}\n onPage={changePage}\n />\n ) : null}\n </div>\n );\n}\n\nconst defaultProductHref = (product: PublicListProduct) =>\n `/p/${encodeURIComponent(product.uniqueSlug)}`;\n\n/**\n * Responsive grid of the shop's products with pagination, loading, empty and\n * error states. Cards link to the product page and can add to the cart.\n *\n * ```tsx\n * <ProductList projectID=\"…\" locale=\"pl-PL\" initialData={firstPage} />\n * ```\n *\n * It renders on the server: pass `initialData` (the first page, fetched on the\n * server) to have the products in the HTML; without it the server renders the\n * loading skeleton and the browser fetches the first page.\n */\nexport function ProductList({\n productHref = defaultProductHref,\n appearance,\n texts,\n renderItem,\n onAddToCart,\n showCartOnAdd = true,\n className,\n ...options\n}: ProductListProps) {\n const locale = options.locale ?? DEFAULT_LOCALE;\n const resolvedAppearance = useMemo(\n () => resolveProductListAppearance(appearance),\n [appearance],\n );\n const resolvedTexts = useMemo(\n () => resolveProductListTexts(locale, texts),\n [locale, texts],\n );\n const context = useMemo(\n () => ({ appearance: resolvedAppearance, texts: resolvedTexts, locale }),\n [resolvedAppearance, resolvedTexts, locale],\n );\n const root = getProductListSlotAppearance(resolvedAppearance, \"root\");\n\n return (\n <ProductListContext.Provider value={context}>\n <div\n data-bitsnap-products=\"root\"\n data-bitsnap-products-slot=\"root\"\n className={cn(\n \"bitsnap-react\",\n resolvedAppearance.boundaryClassName,\n className,\n root?.className,\n )}\n style={\n { ...resolvedAppearance.boundaryStyle, ...root?.style } as CSSProperties\n }\n >\n <ProductListContent\n options={options}\n productHref={productHref}\n renderItem={renderItem}\n onAddToCart={onAddToCart}\n showCartOnAdd={showCartOnAdd}\n />\n </div>\n </ProductListContext.Provider>\n );\n}\n","import { normalizeHost } from \"./fetch\";\n\nexport type CartState = {\n /** Project the page cart is set up for, `null` or `undefined` when none yet. */\n projectID: string | null | undefined;\n /** Backend origin the page cart currently talks to. */\n host: string;\n /** Backend origin used when the page did not choose another one. */\n defaultHost: string;\n};\n\nexport type CartTarget = {\n projectID: string;\n /** Omitted or empty keeps the current host. */\n host?: string;\n};\n\nexport type CartPlan =\n | { ok: true; setProjectID: string | null; setHost: string | null }\n | { ok: false; reason: string };\n\n/**\n * Decides, without changing anything, whether the page cart can serve the\n * target and what has to be filled in first. Both the project and the host are\n * checked before the caller changes either of them, so a refused click leaves\n * the page cart untouched.\n */\nexport function planCartTarget(state: CartState, target: CartTarget): CartPlan {\n if (state.projectID != null && state.projectID !== target.projectID) {\n return {\n ok: false,\n reason: `the page cart already belongs to project \"${state.projectID}\"`,\n };\n }\n\n let setHost: string | null = null;\n const targetHost = target.host ? normalizeHost(target.host) : \"\";\n const currentHost = normalizeHost(state.host);\n if (targetHost && targetHost !== currentHost) {\n if (currentHost !== normalizeHost(state.defaultHost)) {\n return {\n ok: false,\n reason: `the page cart already uses the host \"${state.host}\"`,\n };\n }\n setHost = targetHost;\n }\n\n return {\n ok: true,\n setProjectID: state.projectID == null ? target.projectID : null,\n setHost,\n };\n}\n","import { DEFAULT_HOST, HOST, setCustomHost } from \"../checkout/constants\";\nimport { planCartTarget } from \"./cart-target\";\nimport type { PublicListProduct } from \"./fetch\";\n\nexport type AddToCartTarget = {\n projectID: string;\n /** Backend origin the cart talks to. Omitted or empty keeps the current one. */\n host?: string;\n /** Open the cart drawer afterwards. */\n showCart: boolean;\n};\n\n/**\n * Default \"add to cart\" action of `ProductList`: `Bitsnap.addProductToCart`\n * with quantity 1, then the cart drawer.\n *\n * The checkout is a heavy module (RPC client, cart state, payment buttons), so\n * it is loaded on the first click and never ends up in the first paint of a\n * catalog page. The cart only knows one project and one host at a time, and\n * they are page-wide (the cart is kept in localStorage, `setProjectID` also\n * changes the panel configuration). So the list only fills them in when the\n * page has not set them yet; when the page already works for another project\n * or host, nothing is changed and the call fails (pass `onAddToCart` to the\n * list in that case).\n */\nexport async function addProductToCart(\n product: PublicListProduct,\n target: AddToCartTarget,\n): Promise<void> {\n const [{ Bitsnap }, { getProjectID, setProjectID }] = await Promise.all([\n import(\"../checkout/methods\"),\n import(\"../checkout/CartProvider\"),\n ]);\n\n const plan = planCartTarget(\n { projectID: getProjectID(), host: HOST, defaultHost: DEFAULT_HOST },\n target,\n );\n if (!plan.ok) {\n return failConflict(plan.reason);\n }\n if (plan.setProjectID != null) {\n setProjectID(plan.setProjectID);\n }\n if (plan.setHost != null) {\n setCustomHost(plan.setHost);\n }\n\n // Single-variant products are added by their variant, not the product ID.\n const error = await Bitsnap.addProductToCart(\n product.cartItemId ?? product.id,\n 1,\n undefined,\n {\n name: product.name,\n price: product.price,\n currency: product.currency,\n },\n );\n if (error != null) {\n throw new Error(\"Could not add the product to the cart\");\n }\n\n if (target.showCart) {\n Bitsnap.showCart();\n }\n}\n\nfunction failConflict(reason: string): never {\n console.warn(\n `bitsnap-react: ProductList did not add to the cart because ${reason}. ` +\n \"Pass onAddToCart to use another cart.\",\n );\n throw new Error(\"The page cart belongs to another project or host\");\n}\n","import {\n lookupText,\n resolveTexts,\n type LocaleTables,\n} from \"@/src/lib/texts\";\n\n/**\n * Every string `ProductList` renders. Pass a partial object through the\n * `texts` prop to override any of them, whatever the locale. Placeholders\n * (`{price}`, `{page}`, `{pageCount}`) are filled by the component.\n */\nexport type ProductListTexts = {\n /** \"Add to cart\" button of products that can be bought straight from the list. */\n addToCart: string;\n /** Button label while the product is being added. */\n addingToCart: string;\n /** Button label after the product was added. */\n addedToCart: string;\n /** Message shown when adding to the cart failed. */\n addToCartError: string;\n /** Link of products with variants, to pick one on the product page. */\n chooseOptions: string;\n /** Link of products that cannot be added from the list (subscriptions). */\n viewProduct: string;\n /** Label of products that are out of stock. */\n unavailable: string;\n /** Badge of subscription products. */\n subscription: string;\n /** Price of products whose variants differ in price. `{price}` is the lowest one. */\n priceFrom: string;\n /** Screen reader label of the struck-through regular price. */\n originalPrice: string;\n /** Accessible label of the loading skeleton. */\n loading: string;\n /** Shown when the shop has no products (or none matches the search). */\n empty: string;\n /** Shown when the products could not be loaded. */\n error: string;\n /** Retry button of the error state. */\n retry: string;\n /** Accessible label of the pagination. */\n pagination: string;\n previousPage: string;\n nextPage: string;\n /** Page indicator. `{page}` and `{pageCount}` are filled in. */\n pageOf: string;\n};\n\nexport type ProductListTextKey = keyof ProductListTexts;\n\nexport const PRODUCT_LIST_TEXT_TABLES: LocaleTables<ProductListTextKey> = {\n en: {\n addToCart: \"Add to cart\",\n addingToCart: \"Adding…\",\n addedToCart: \"Added to cart\",\n addToCartError: \"Could not add to the cart. Try again.\",\n chooseOptions: \"Choose\",\n viewProduct: \"View\",\n unavailable: \"Unavailable\",\n subscription: \"Subscription\",\n priceFrom: \"from {price}\",\n originalPrice: \"Original price\",\n loading: \"Loading products\",\n empty: \"There are no products to show.\",\n error: \"Could not load the products.\",\n retry: \"Try again\",\n pagination: \"Pagination\",\n previousPage: \"Previous\",\n nextPage: \"Next\",\n pageOf: \"Page {page} of {pageCount}\",\n },\n pl: {\n addToCart: \"Dodaj do koszyka\",\n addingToCart: \"Dodawanie…\",\n addedToCart: \"Dodano do koszyka\",\n addToCartError: \"Nie udało się dodać do koszyka. Spróbuj ponownie.\",\n chooseOptions: \"Wybierz\",\n viewProduct: \"Zobacz\",\n unavailable: \"Niedostępny\",\n subscription: \"Subskrypcja\",\n priceFrom: \"od {price}\",\n originalPrice: \"Cena przed obniżką\",\n loading: \"Ładowanie produktów\",\n empty: \"Brak produktów do wyświetlenia.\",\n error: \"Nie udało się załadować produktów.\",\n retry: \"Spróbuj ponownie\",\n pagination: \"Paginacja\",\n previousPage: \"Poprzednia\",\n nextPage: \"Następna\",\n pageOf: \"Strona {page} z {pageCount}\",\n },\n};\n\n/** Default texts for a locale merged with the caller overrides. */\nexport function resolveProductListTexts(\n locale: string,\n overrides?: Partial<ProductListTexts>,\n): ProductListTexts {\n return resolveTexts(PRODUCT_LIST_TEXT_TABLES, locale, overrides);\n}\n\nexport function getProductListText(\n key: ProductListTextKey,\n locale: string,\n overrides?: Partial<ProductListTexts>,\n): string {\n return lookupText(resolveProductListTexts(locale, overrides), key);\n}\n\n/** Replaces `{name}` placeholders. Unknown placeholders stay untouched. */\nexport function fillProductListText(\n text: string,\n values: Record<string, string | number>,\n): string {\n return text.replace(/\\{(\\w+)\\}/g, (match, name: string) =>\n name in values ? String(values[name]) : match,\n );\n}\n"],"mappings":"4HA2DO,IAAMA,GAA0B,CACrC,OACA,OACA,OACA,WACA,QACA,mBACA,OACA,OACA,cACA,QACA,eACA,QACA,UACA,kBACA,eACA,UACA,aACA,mBACA,gBACA,aACA,QACA,cACA,UACF,EA8BaC,GAA+B,CAC1C,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Y,GAAKjC,GAAS,KACzB9B,EAAC6D,GAAA,CACC,KAAMC,EACN,UAAWC,EACX,UAAWC,EACX,OAAQgB,EACV,EACE,MACN,CAEJ,CAEA,IAAMU,GAAsBxE,GAC1B,MAAM,mBAAmBA,EAAQ,UAAU,CAAC,GAcvC,SAASyE,GAAY,CAC1B,YAAArB,EAAcoB,GACd,WAAAhF,EACA,MAAAU,EACA,WAAAc,EACA,YAAAqC,EACA,cAAAC,EAAgB,GAChB,UAAA/D,EACA,GAAG4D,CACL,EAAqB,CACnB,IAAMlC,EAASkC,EAAQ,QAAUuB,EAC3BC,EAAqBC,EACzB,IAAMC,EAA6BrF,CAAU,EAC7C,CAACA,CAAU,CACb,EACMsF,EAAgBF,EACpB,IAAMG,GAAwB9D,EAAQf,CAAK,EAC3C,CAACe,EAAQf,CAAK,CAChB,EACM8E,EAAUJ,EACd,KAAO,CAAE,WAAYD,EAAoB,MAAOG,EAAe,OAAA7D,CAAO,GACtE,CAAC0D,EAAoBG,EAAe7D,CAAM,CAC5C,EACMgE,EAAOvF,EAA6BiF,EAAoB,MAAM,EAEpE,OACE7F,EAACE,GAAmB,SAAnB,CAA4B,MAAOgG,EAClC,SAAAlG,EAAC,OACC,wBAAsB,OACtB,6BAA2B,OAC3B,UAAWa,EACT,gBACAgF,EAAmB,kBACnBpF,EACA0F,GAAM,SACR,EACA,MACE,CAAE,GAAGN,EAAmB,cAAe,GAAGM,GAAM,KAAM,EAGxD,SAAAnG,EAACoE,GAAA,CACC,QAASC,EACT,YAAaC,EACb,WAAYpC,EACZ,YAAaqC,EACb,cAAeC,EACjB,EACF,EACF,CAEJ","names":["PRODUCT_LIST_SLOT_NAMES","PRODUCT_LIST_TOKEN_VARIABLES","PRODUCT_LIST_THEME_PRESETS","PRODUCT_LIST_SHADCN_VARIABLES","resolveProductListAppearance","appearance","resolved","resolveAppearanceCore","getProductListSlotAppearance","slot","getSlotAppearance","createFormatter","locale","currency","formatProductPrice","amount","DEFAULT_LOCALE","value","formatter","useCallback","useEffect","useMemo","useState","ProductListError","message","status","clampPageSize","pageSize","pageCountFor","totalCount","normalizeHost","host","buildProductListURL","query","params","search","isProductListData","value","fetchProductList","signal","response","payload","useProducts","options","projectID","locale","search","initialData","defaultHost","useState","HOST","host","pageSize","clampPageSize","queryKey","pageState","setPageState","reloads","setReloads","snapshot","setSnapshot","totalCount","pageCount","pageCountFor","requestedPage","page","requestKey","isCurrent","useEffect","controller","fetchProductList","data","error","previous","setPage","useCallback","next","target","refetch","value","useMemo","createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","planCartTarget","state","target","setHost","targetHost","normalizeHost","currentHost","addProductToCart","product","target","Bitsnap","getProjectID","setProjectID","plan","planCartTarget","HOST","DEFAULT_HOST","failConflict","setCustomHost","reason","PRODUCT_LIST_TEXT_TABLES","resolveProductListTexts","locale","overrides","resolveTexts","fillProductListText","text","values","match","name","Fragment","jsx","jsxs","ProductListContext","createContext","useListContext","value","useContext","useSlot","slot","className","appearance","override","getProductListSlotAppearance","cn","BUTTON_CLASS","BLOCK_BUTTON_CLASS","LINK_BUTTON_CLASS","AddToCartButton","product","onAdd","texts","status","setStatus","useState","button","message","useEffect","timer","click","useCallback","error","label","ProductCard","href","renderItem","locale","card","cardLink","imageFrame","placeholder","body","name","description","price","comparePrice","badge","actions","selectButton","formattedPrice","formatProductPrice","formattedCompare","imageSource","badgeText","fillProductListText","GRID_CLASS","SkeletonGrid","count","grid","skeleton","_","index","Pagination","page","pageCount","isLoading","onPage","nav","indicator","ProductListContent","options","productHref","onAddToCart","showCartOnAdd","products","setPage","refetch","useProducts","content","useRef","movedPage","changePage","next","empty","errorSlot","retry","projectID","host","addFor","addProductToCart","clampPageSize","defaultProductHref","ProductList","DEFAULT_LOCALE","resolvedAppearance","useMemo","resolveProductListAppearance","resolvedTexts","resolveProductListTexts","context","root"]}