bitsnap-react 1.18.0 → 1.19.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 (157) hide show
  1. package/AGENTS.md +106 -0
  2. package/README.md +98 -0
  3. package/dist/BitsnapCart-E72W5RRZ.mjs +2 -0
  4. package/dist/BitsnapCart-LHJ6KOTV.css +2 -0
  5. package/dist/BitsnapCart-LHJ6KOTV.css.map +1 -0
  6. package/dist/BitsnapCart-Q2HER6GU.js +2 -0
  7. package/dist/BitsnapCart-Q2HER6GU.js.map +1 -0
  8. package/dist/CartProvider-677CE2FI.js +2 -0
  9. package/dist/CartProvider-677CE2FI.js.map +1 -0
  10. package/dist/CartProvider-YPDOFSYC.mjs +2 -0
  11. package/dist/{PanelModelFiles-JZFSF7BF.mjs → PanelModelFiles-4B2HYGIE.mjs} +2 -2
  12. package/dist/{PanelModelFiles-7HPXWONN.js → PanelModelFiles-EKQRLF46.js} +2 -2
  13. package/dist/PanelModelFiles-EKQRLF46.js.map +1 -0
  14. package/dist/analytics.js +1 -1
  15. package/dist/analytics.js.map +1 -1
  16. package/dist/analytics.mjs +1 -1
  17. package/dist/catalog.js +1 -1
  18. package/dist/catalog.js.map +1 -1
  19. package/dist/catalog.mjs +1 -1
  20. package/dist/chat.css +2 -0
  21. package/dist/chat.css.map +1 -0
  22. package/dist/chat.d.mts +172 -0
  23. package/dist/chat.d.ts +172 -0
  24. package/dist/chat.js +2 -0
  25. package/dist/chat.js.map +1 -0
  26. package/dist/chat.mjs +2 -0
  27. package/dist/chat.mjs.map +1 -0
  28. package/dist/chunk-2FD2QP4Y.js +2 -0
  29. package/dist/chunk-2FD2QP4Y.js.map +1 -0
  30. package/dist/chunk-5JRUPLXY.mjs +2 -0
  31. package/dist/chunk-5JRUPLXY.mjs.map +1 -0
  32. package/dist/chunk-5M6M7FAR.mjs +2 -0
  33. package/dist/chunk-5M6M7FAR.mjs.map +1 -0
  34. package/dist/chunk-6Q3VGPSF.js.map +1 -1
  35. package/dist/chunk-AAC576BC.mjs +5 -0
  36. package/dist/chunk-AAC576BC.mjs.map +1 -0
  37. package/dist/{chunk-4OVOKGGS.mjs → chunk-AB37DWOK.mjs} +2 -2
  38. package/dist/{chunk-ZATPBYOA.js → chunk-BUYTK7KM.js} +2 -2
  39. package/dist/chunk-BUYTK7KM.js.map +1 -0
  40. package/dist/{chunk-DP2NOHCI.js → chunk-D2ASWUXM.js} +2 -2
  41. package/dist/chunk-D2ASWUXM.js.map +1 -0
  42. package/dist/chunk-DDIEFKNP.mjs +2 -0
  43. package/dist/{chunk-ZHTMK5TA.mjs.map → chunk-DDIEFKNP.mjs.map} +1 -1
  44. package/dist/{chunk-4HGZZJEL.js → chunk-DOJICJCQ.js} +2 -2
  45. package/dist/chunk-DOJICJCQ.js.map +1 -0
  46. package/dist/chunk-EMR4YXNY.mjs +2 -0
  47. package/dist/chunk-EMR4YXNY.mjs.map +1 -0
  48. package/dist/{chunk-JA62KNAQ.js → chunk-GJOGATP6.js} +2 -2
  49. package/dist/chunk-GJOGATP6.js.map +1 -0
  50. package/dist/chunk-GQ5OKU74.js +2 -0
  51. package/dist/chunk-GQ5OKU74.js.map +1 -0
  52. package/dist/chunk-JSDGZ4NY.js.map +1 -1
  53. package/dist/chunk-KHQEDQYF.js +5 -0
  54. package/dist/chunk-KHQEDQYF.js.map +1 -0
  55. package/dist/chunk-KOYBZORL.js.map +1 -1
  56. package/dist/chunk-LGPNJ5XE.js +2 -0
  57. package/dist/chunk-LGPNJ5XE.js.map +1 -0
  58. package/dist/chunk-MDAFPGPA.js +2 -0
  59. package/dist/chunk-MDAFPGPA.js.map +1 -0
  60. package/dist/{chunk-JHJ3ZZF4.mjs → chunk-MMLBQHBM.mjs} +2 -2
  61. package/dist/chunk-MWWEPEU2.js +2 -0
  62. package/dist/chunk-MWWEPEU2.js.map +1 -0
  63. package/dist/{chunk-GEBRXFT3.mjs → chunk-N523LFAM.mjs} +2 -2
  64. package/dist/chunk-NWXZ45TV.js +2 -0
  65. package/dist/chunk-NWXZ45TV.js.map +1 -0
  66. package/dist/chunk-OFPRIENJ.mjs +2 -0
  67. package/dist/chunk-OFPRIENJ.mjs.map +1 -0
  68. package/dist/chunk-OR566YJI.mjs +2 -0
  69. package/dist/chunk-OR566YJI.mjs.map +1 -0
  70. package/dist/chunk-Q337IQNA.js +2 -0
  71. package/dist/chunk-Q337IQNA.js.map +1 -0
  72. package/dist/chunk-SCEWYZUZ.mjs +2 -0
  73. package/dist/chunk-SCEWYZUZ.mjs.map +1 -0
  74. package/dist/{chunk-CF45RDMD.mjs → chunk-SSSF64M7.mjs} +2 -2
  75. package/dist/{chunk-CF45RDMD.mjs.map → chunk-SSSF64M7.mjs.map} +1 -1
  76. package/dist/chunk-W3RGQYPD.js.map +1 -1
  77. package/dist/chunk-WG54EHST.mjs +2 -0
  78. package/dist/chunk-WG54EHST.mjs.map +1 -0
  79. package/dist/chunk-XEXPQFKN.mjs +2 -0
  80. package/dist/chunk-XEXPQFKN.mjs.map +1 -0
  81. package/dist/chunk-YV2C276H.js +2 -0
  82. package/dist/chunk-YV2C276H.js.map +1 -0
  83. package/dist/consent.js.map +1 -1
  84. package/dist/course.d.mts +2 -14
  85. package/dist/course.d.ts +2 -14
  86. package/dist/course.js +1 -1
  87. package/dist/course.js.map +1 -1
  88. package/dist/course.mjs +1 -1
  89. package/dist/course.mjs.map +1 -1
  90. package/dist/embed/analytics.js +1 -1
  91. package/dist/errors.js.map +1 -1
  92. package/dist/index.css +1 -1
  93. package/dist/index.css.map +1 -1
  94. package/dist/index.d.mts +288 -4
  95. package/dist/index.d.ts +288 -4
  96. package/dist/index.js +1 -1
  97. package/dist/index.js.map +1 -1
  98. package/dist/index.mjs +1 -1
  99. package/dist/index.mjs.map +1 -1
  100. package/dist/internal.js.map +1 -1
  101. package/dist/methods-64D5DD6K.js +2 -0
  102. package/dist/methods-64D5DD6K.js.map +1 -0
  103. package/dist/methods-NQA3DFLE.mjs +2 -0
  104. package/dist/methods-NQA3DFLE.mjs.map +1 -0
  105. package/dist/model-files-client-P4PORZJ6.js.map +1 -1
  106. package/dist/models.js.map +1 -1
  107. package/dist/returns.js +1 -1
  108. package/dist/returns.js.map +1 -1
  109. package/dist/returns.mjs +1 -1
  110. package/dist/texts-9kfgClsA.d.mts +14 -0
  111. package/dist/texts-9kfgClsA.d.ts +14 -0
  112. package/dist/{types-D6LsoycW.d.mts → types-B-sjyZQs.d.mts} +7 -1
  113. package/dist/{types-ClFCVzk_.d.ts → types-iRe6ix2y.d.ts} +7 -1
  114. package/dist/viewer3d.js.map +1 -1
  115. package/dist/viewer3d.mjs +1 -1
  116. package/dist/viewer3d.mjs.map +1 -1
  117. package/dist/widgets-BT2LN2Nq.d.mts +547 -0
  118. package/dist/widgets-BVOSj9fU.d.ts +547 -0
  119. package/package.json +18 -3
  120. package/dist/CartProvider-OEI526IN.js +0 -2
  121. package/dist/CartProvider-OEI526IN.js.map +0 -1
  122. package/dist/CartProvider-RYAA3JDA.mjs +0 -2
  123. package/dist/PanelModelFiles-7HPXWONN.js.map +0 -1
  124. package/dist/chunk-4HGZZJEL.js.map +0 -1
  125. package/dist/chunk-5X7TP3TQ.mjs +0 -2
  126. package/dist/chunk-5X7TP3TQ.mjs.map +0 -1
  127. package/dist/chunk-7RXW6XFY.js +0 -2
  128. package/dist/chunk-7RXW6XFY.js.map +0 -1
  129. package/dist/chunk-DP2NOHCI.js.map +0 -1
  130. package/dist/chunk-EVIDNS22.mjs +0 -2
  131. package/dist/chunk-EVIDNS22.mjs.map +0 -1
  132. package/dist/chunk-G4V2KWTV.js +0 -2
  133. package/dist/chunk-G4V2KWTV.js.map +0 -1
  134. package/dist/chunk-GWF3MRUP.js +0 -2
  135. package/dist/chunk-GWF3MRUP.js.map +0 -1
  136. package/dist/chunk-JA62KNAQ.js.map +0 -1
  137. package/dist/chunk-UPAOIY4R.mjs +0 -2
  138. package/dist/chunk-UPAOIY4R.mjs.map +0 -1
  139. package/dist/chunk-V5ECGBFW.js +0 -5
  140. package/dist/chunk-V5ECGBFW.js.map +0 -1
  141. package/dist/chunk-VNV5BD4X.js +0 -2
  142. package/dist/chunk-VNV5BD4X.js.map +0 -1
  143. package/dist/chunk-VNYHJT6V.mjs +0 -2
  144. package/dist/chunk-VNYHJT6V.mjs.map +0 -1
  145. package/dist/chunk-WJO5GSY3.mjs +0 -5
  146. package/dist/chunk-WJO5GSY3.mjs.map +0 -1
  147. package/dist/chunk-ZATPBYOA.js.map +0 -1
  148. package/dist/chunk-ZHTMK5TA.mjs +0 -2
  149. package/dist/methods-AULQDKVS.mjs +0 -2
  150. package/dist/methods-PMH5VQ25.js +0 -2
  151. package/dist/methods-PMH5VQ25.js.map +0 -1
  152. /package/dist/{CartProvider-RYAA3JDA.mjs.map → BitsnapCart-E72W5RRZ.mjs.map} +0 -0
  153. /package/dist/{methods-AULQDKVS.mjs.map → CartProvider-YPDOFSYC.mjs.map} +0 -0
  154. /package/dist/{PanelModelFiles-JZFSF7BF.mjs.map → PanelModelFiles-4B2HYGIE.mjs.map} +0 -0
  155. /package/dist/{chunk-4OVOKGGS.mjs.map → chunk-AB37DWOK.mjs.map} +0 -0
  156. /package/dist/{chunk-JHJ3ZZF4.mjs.map → chunk-MMLBQHBM.mjs.map} +0 -0
  157. /package/dist/{chunk-GEBRXFT3.mjs.map → chunk-N523LFAM.mjs.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/emems-chat-v1/dist/chunk-BUYTK7KM.js","../src/components/returns/appearance.ts","../src/components/returns/appearance.context.tsx","../src/components/returns/legacy.ts","../src/components/returns/texts.ts","../src/components/returns/texts.context.tsx","../src/components/returns/ReturnsProvider.tsx","../src/ui/email-code-login/pending.ts"],"names":["RETURNS_SLOT_NAMES","RETURNS_TOKEN_VARIABLES","RETURNS_THEME_PRESETS","RETURNS_SHADCN_VARIABLES","resolveReturnsAppearance","appearance","resolved","resolveAppearanceCore","getReturnsSlotAppearance","slot","getSlotAppearance","ReturnsAppearanceContext","createContext","ReturnsAppearanceProvider","children","useMemo","jsx","useReturnsAppearance","useContext","useReturnsSlot","resolveReturnsEnvironment","environment","LEGACY_TEXT_KEYS","mapLegacyTexts","texts","result","legacyKey","targets","value","target","key","resolveBrandAppearance","theme","color","brandColorTokens","resolvePagedArguments","first","pageToken","RETURNS_TEXT_TABLES","resolveReturnsTexts","locale","overrides","resolveTexts","fillText","template","values","match","name","STATUS_TEXT_KEYS","REFUND_STATUS_TEXT_KEYS","statusTextKey","status","refundStatusTextKey","ReturnsTextsContext","ReturnsTextsProvider","activeLocale","getLocale","useReturnsText","useCallback","useReturnsLocale","browserStorage","pendingLoginKey","surface","projectID","host"],"mappings":"AAAA,y/BAAgD,sDAAwH,sDAAwC,sDAAyD,sDAAyD,ICiErTA,EAAAA,CAAqB,CAEhC,MAAA,CACA,QAAA,CACA,OAAA,CACA,aAAA,CACA,YAAA,CACA,eAAA,CACA,OAAA,CACA,YAAA,CACA,UAAA,CAEA,WAAA,CACA,YAAA,CACA,UAAA,CACA,WAAA,CACA,cAAA,CACA,cAAA,CAEA,WAAA,CACA,WAAA,CACA,gBAAA,CACA,WAAA,CACA,YAAA,CACA,YAAA,CAEA,UAAA,CACA,MAAA,CACA,UAAA,CACA,WAAA,CACA,qBAAA,CACA,gBAAA,CACA,eAAA,CACA,sBAAA,CACA,WAAA,CAEA,SAAA,CACA,cAAA,CACA,iBAAA,CACA,cAAA,CACA,iBAAA,CACA,oBAAA,CAEA,YAAA,CACA,YAAA,CACA,aAAA,CACA,SAAA,CACA,cACF,CAAA,CA6BaC,EAAAA,CAA0B,CACrC,UAAA,CAAY,+BAAA,CACZ,QAAA,CAAU,6BAAA,CACV,UAAA,CAAY,8BAAA,CACZ,OAAA,CAAS,2BAAA,CACT,UAAA,CAAY,8BAAA,CACZ,eAAA,CAAiB,oCAAA,CACjB,MAAA,CAAQ,0BAAA,CACR,gBAAA,CAAkB,qCAAA,CAClB,gBAAA,CAAk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ACzC,CCvEA,8CAA6B,yDAItB,mDAMA,SCUE0C,EAAAA,CAAAA,CAA0C,CACjD,GAAI,CACF,OAAO,OAAO,MAAA,CAAW,GAAA,CAAc,MAAA,CAAO,cAAA,CAAiB,KAAA,CACjE,CAAA,UAAQ,CACN,MACF,CACF,CAGO,SAASC,EAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACQ,CACR,MAAO,CAAA,sBAAA,EAAyBF,CAAO,CAAA,CAAA,EAAI,kBAAA,kBAAmBE,CAAAA,SAAQ,IAAE,CAAC,CAAA,CAAA,EAAI,kBAAA,kBAAmBD,CAAAA,SAAa,IAAE,CAAC,CAAA,CAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/emems-chat-v1/dist/chunk-BUYTK7KM.js","sourcesContent":[null,"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 * Returns appearance API.\n *\n * It mirrors `CheckoutAppearance` (theme, tokens, elements) so a shop can reuse\n * one brand object for both. The resolver is pure: it turns the caller input\n * into a theme name, the tokens in effect, the slot overrides and the inline\n * style for the theme boundary.\n */\n\nexport type ReturnsTheme = \"light\" | \"dark\";\n\nexport type ReturnsAppearanceTokens = {\n /** Font family of the returns views. The library never loads fonts. */\n fontFamily?: string;\n /** Base font size. */\n fontSize?: string;\n /** Page background. */\n background?: string;\n /** Raised surfaces: cards, skeletons, summaries. */\n surface?: string;\n /** Main text color. */\n foreground?: string;\n /** Secondary text: descriptions, dates, hints. */\n mutedForeground?: string;\n /** Borders of cards, inputs and separators. */\n border?: string;\n /** Primary button background. */\n buttonBackground?: string;\n /** Primary button text. */\n buttonForeground?: string;\n /** Primary button background on hover. */\n buttonHoverBackground?: string;\n /** Hover surface of secondary buttons and selectable cards. */\n hoverSurface?: string;\n /** Focus ring color. Also applied to shared UI primitives through `--ring`. */\n focusRing?: string;\n /** Error color. */\n error?: string;\n /** Success color: result screen, completed and refunded statuses. */\n success?: string;\n /** Warning color: statuses that need attention. */\n warning?: string;\n /** Status badge background. */\n badgeBackground?: string;\n /** Status badge text. */\n badgeForeground?: string;\n /** Background of text inputs and the note field. */\n inputBackground?: string;\n /** Corner radius, applied through `--radius`. */\n radius?: string;\n};\n\n/**\n * Stable slot names. They are exposed as `data-bitsnap-returns-slot`\n * attributes so they can also be targeted from plain CSS.\n */\nexport const RETURNS_SLOT_NAMES = [\n // Frame\n \"root\",\n \"header\",\n \"title\",\n \"description\",\n \"backButton\",\n \"stepIndicator\",\n \"error\",\n \"emptyState\",\n \"skeleton\",\n // Auth\n \"emailForm\",\n \"emailInput\",\n \"codeForm\",\n \"codeInput\",\n \"resendButton\",\n \"logoutButton\",\n // Orders\n \"orderList\",\n \"orderCard\",\n \"orderReference\",\n \"orderDate\",\n \"orderTotal\",\n \"pagination\",\n // Selection\n \"lineList\",\n \"line\",\n \"lineName\",\n \"linePrice\",\n \"lineQuantityControl\",\n \"quantityButton\",\n \"quantityInput\",\n \"lineIneligibleReason\",\n \"noteInput\",\n // Confirmation and result\n \"summary\",\n \"submitButton\",\n \"secondaryButton\",\n \"successState\",\n \"returnReference\",\n \"returnInstructions\",\n // My returns\n \"returnList\",\n \"returnCard\",\n \"statusBadge\",\n \"history\",\n \"historyEntry\",\n] as const;\n\nexport type ReturnsSlotName = (typeof RETURNS_SLOT_NAMES)[number];\n\nexport type ReturnsSlotAppearance = SlotAppearance;\n\nexport type ReturnsAppearanceElements = AppearanceElements<ReturnsSlotName>;\n\nexport type ReturnsAppearance = {\n /** `\"light\"` or `\"dark\"`. Omitted means `\"light\"`. */\n theme?: ReturnsTheme;\n /** Partial overrides applied over the theme preset. */\n tokens?: ReturnsAppearanceTokens;\n /** Per element `className`/`style` overrides. */\n elements?: ReturnsAppearanceElements;\n};\n\nexport type ResolvedReturnsAppearance = {\n theme: ReturnsTheme;\n /** Tokens that are in effect (the theme preset plus caller overrides). */\n tokens: ReturnsAppearanceTokens;\n elements: ReturnsAppearanceElements;\n /** Theme marker class for the theme boundary. */\n boundaryClassName: string;\n /** Inline custom properties applied to the returns root. */\n boundaryStyle: CSSProperties;\n};\n\n/** CSS custom property used for each token. */\nexport const RETURNS_TOKEN_VARIABLES = {\n fontFamily: \"--bitsnap-returns-font-family\",\n fontSize: \"--bitsnap-returns-font-size\",\n background: \"--bitsnap-returns-background\",\n surface: \"--bitsnap-returns-surface\",\n foreground: \"--bitsnap-returns-foreground\",\n mutedForeground: \"--bitsnap-returns-muted-foreground\",\n border: \"--bitsnap-returns-border\",\n buttonBackground: \"--bitsnap-returns-button-background\",\n buttonForeground: \"--bitsnap-returns-button-foreground\",\n buttonHoverBackground: \"--bitsnap-returns-button-hover-background\",\n hoverSurface: \"--bitsnap-returns-hover-surface\",\n focusRing: \"--bitsnap-returns-focus-ring\",\n error: \"--bitsnap-returns-error\",\n success: \"--bitsnap-returns-success\",\n warning: \"--bitsnap-returns-warning\",\n badgeBackground: \"--bitsnap-returns-badge-background\",\n badgeForeground: \"--bitsnap-returns-badge-foreground\",\n inputBackground: \"--bitsnap-returns-input-background\",\n radius: \"--bitsnap-returns-radius\",\n} as const;\n\nexport type ReturnsTokenName = keyof typeof RETURNS_TOKEN_VARIABLES;\n\n/**\n * Complete palettes. They carry colors and radius only, so typography is never\n * reset implicitly. `returns.css` falls back to the light values, which keeps\n * the views usable even when the boundary style is missing.\n */\nexport const RETURNS_THEME_PRESETS: Record<\n ReturnsTheme,\n ReturnsAppearanceTokens\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 success: \"#16a34a\",\n warning: \"#d97706\",\n badgeBackground: \"#f4f4f5\",\n badgeForeground: \"#3f3f46\",\n inputBackground: \"#ffffff\",\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 success: \"#4ade80\",\n warning: \"#fbbf24\",\n badgeBackground: \"#3f3f46\",\n badgeForeground: \"#e4e4e7\",\n inputBackground: \"#27272a\",\n radius: \"8px\",\n },\n};\n\n/**\n * Shared UI primitives (`Button`, `Input`, `Label`, ...) read the shadcn theme\n * variables, so those follow the returns tokens inside the boundary.\n */\nconst RETURNS_SHADCN_VARIABLES: ShadcnVariableMapping<ReturnsTokenName> = [\n { token: \"background\", variable: \"--background\" },\n { token: \"foreground\", variable: \"--foreground\" },\n { token: \"surface\", variable: \"--card\" },\n { token: \"foreground\", variable: \"--card-foreground\" },\n { token: \"surface\", variable: \"--popover\" },\n { token: \"foreground\", variable: \"--popover-foreground\" },\n { token: \"buttonBackground\", variable: \"--primary\" },\n { token: \"buttonForeground\", variable: \"--primary-foreground\" },\n { token: \"surface\", variable: \"--secondary\" },\n { token: \"foreground\", variable: \"--secondary-foreground\" },\n { token: \"hoverSurface\", variable: \"--accent\" },\n { token: \"foreground\", variable: \"--accent-foreground\" },\n { token: \"mutedForeground\", variable: \"--muted-foreground\" },\n { token: \"border\", variable: \"--border\" },\n { token: \"border\", variable: \"--input\" },\n { token: \"focusRing\", variable: \"--ring\" },\n { token: \"error\", variable: \"--destructive\" },\n { token: \"radius\", variable: \"--radius\" },\n];\n\nexport function resolveReturnsAppearance(\n appearance?: ReturnsAppearance,\n): ResolvedReturnsAppearance {\n const resolved = resolveAppearanceCore<\n ReturnsTokenName,\n ReturnsTheme,\n ReturnsSlotName\n >(appearance, {\n defaultTheme: \"light\",\n presets: RETURNS_THEME_PRESETS,\n variables: RETURNS_TOKEN_VARIABLES,\n shadcnVariables: RETURNS_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 getReturnsSlotAppearance(\n resolved: ResolvedReturnsAppearance,\n slot: ReturnsSlotName,\n): ReturnsSlotAppearance | undefined {\n return getSlotAppearance(resolved.elements, slot);\n}\n","import { createContext, useContext, useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n getReturnsSlotAppearance,\n resolveReturnsAppearance,\n type ResolvedReturnsAppearance,\n type ReturnsAppearance,\n type ReturnsSlotAppearance,\n type ReturnsSlotName,\n} from \"./appearance\";\n\nconst ReturnsAppearanceContext = createContext<ResolvedReturnsAppearance>(\n resolveReturnsAppearance(),\n);\n\n/**\n * Returns scoped appearance provider. It only wraps the returns views, so the\n * configuration never leaks into checkout, the panel or the host page.\n */\nexport function ReturnsAppearanceProvider({\n appearance,\n children,\n}: {\n appearance?: ReturnsAppearance;\n children: ReactNode;\n}) {\n const resolved = useMemo(\n () => resolveReturnsAppearance(appearance),\n [appearance],\n );\n\n return (\n <ReturnsAppearanceContext.Provider value={resolved}>\n {children}\n </ReturnsAppearanceContext.Provider>\n );\n}\n\nexport function useReturnsAppearance(): ResolvedReturnsAppearance {\n return useContext(ReturnsAppearanceContext);\n}\n\n/**\n * Returns the caller overrides for a slot, meant to be merged with the\n * built-in presentation:\n *\n * ```tsx\n * const slot = useReturnsSlot(\"title\");\n *\n * return <h2 className={cn(\"text-xl font-semibold\", slot.className)} style={slot.style} />;\n * ```\n */\nexport function useReturnsSlot(slot: ReturnsSlotName): ReturnsSlotAppearance {\n const resolved = useReturnsAppearance();\n\n return getReturnsSlotAppearance(resolved, slot) ?? {};\n}\n","import { Environment } from \"@/src/gen/proto/common/v1/environment_pb\";\nimport type { ReturnsAppearance } from \"./appearance\";\nimport { brandColorTokens } from \"./color\";\nimport type { ReturnsTexts } from \"./texts\";\n\n/**\n * Compatibility layer for the `bitsnap-react` 1.6.0 returns widget. Everything\n * here is pure; the components and hooks apply it at their boundary.\n */\n\n/** Environment as a string or as the proto enum used by 1.6.0. */\nexport type ReturnsEnvironmentInput = \"production\" | \"test\" | Environment;\n\n/** Text keys of the 1.6.0 widget. */\nexport type LegacyReturnsTexts = Partial<{\n title: string;\n email: string;\n sendCode: string;\n code: string;\n verify: string;\n orders: string;\n submit: string;\n note: string;\n loading: string;\n history: string;\n}>;\n\n/** Our text keys plus the 1.6.0 ones. Our keys win when both are given. */\nexport type ReturnsTextsInput = Partial<ReturnsTexts> & LegacyReturnsTexts;\n\n/** 1.6.0 `theme` prop. */\nexport type LegacyReturnsTheme = { brandColor?: string };\n\n/** Backend environment for a string or enum value. Defaults to production. */\nexport function resolveReturnsEnvironment(\n environment?: ReturnsEnvironmentInput,\n): Environment {\n return environment === \"test\" || environment === Environment.TEST\n ? Environment.TEST\n : Environment.PRODUCTION;\n}\n\nconst LEGACY_TEXT_KEYS: Record<\n Exclude<keyof LegacyReturnsTexts, \"loading\">,\n readonly (keyof ReturnsTexts)[]\n> = {\n title: [\"emailStepTitle\"],\n email: [\"emailLabel\"],\n sendCode: [\"emailSubmit\"],\n code: [\"codeLabel\"],\n verify: [\"codeSubmit\"],\n orders: [\"ordersTitle\"],\n submit: [\"confirmationSubmit\"],\n note: [\"noteLabel\"],\n history: [\"myReturnsTitle\", \"myReturnsLink\"],\n};\n\n/**\n * Maps 1.6.0 text keys onto ours. A key of the new API always wins over the\n * legacy key that maps to it. `loading` has the same name in both.\n */\nexport function mapLegacyTexts(\n texts: ReturnsTextsInput | undefined,\n): Partial<ReturnsTexts> | undefined {\n if (texts == null) {\n return undefined;\n }\n\n const result: Partial<ReturnsTexts> = {};\n for (const [legacyKey, targets] of Object.entries(LEGACY_TEXT_KEYS) as [\n keyof typeof LEGACY_TEXT_KEYS,\n readonly (keyof ReturnsTexts)[],\n ][]) {\n const value = texts[legacyKey];\n if (typeof value === \"string\") {\n for (const target of targets) {\n result[target] = value;\n }\n }\n }\n\n for (const key of Object.keys(texts) as (keyof ReturnsTextsInput)[]) {\n if (key in LEGACY_TEXT_KEYS) {\n continue;\n }\n const value = texts[key];\n if (typeof value === \"string\") {\n result[key as keyof ReturnsTexts] = value;\n }\n }\n\n return result;\n}\n\n/**\n * Appearance with the 1.6.0 `brandColor` applied as button background, focus\n * ring and readable button foreground. Explicit `appearance.tokens` win.\n */\nexport function resolveBrandAppearance(\n appearance: ReturnsAppearance | undefined,\n theme: LegacyReturnsTheme | undefined,\n): ReturnsAppearance | undefined {\n const color = theme?.brandColor?.trim();\n if (color == null || color === \"\") {\n return appearance;\n }\n return {\n ...appearance,\n tokens: { ...brandColorTokens(color), ...appearance?.tokens },\n };\n}\n\n/** Arguments of the paged hooks in either call style. */\nexport type PagedArguments = {\n pageSize: number;\n /** Explicit page token of the positional (1.6.0) form. */\n explicitPageToken: string | undefined;\n};\n\n/**\n * Normalizes `(pageSize?, pageToken?)` (1.6.0) and `({ pageSize })` (ours).\n * Both forms default to 20 items, like 1.6.0.\n */\nexport function resolvePagedArguments(\n first: number | { pageSize?: number } | undefined,\n pageToken: string | undefined,\n): PagedArguments {\n if (typeof first === \"object\" && first != null) {\n return { pageSize: first.pageSize ?? 20, explicitPageToken: undefined };\n }\n if (typeof first === \"number\" || pageToken !== undefined) {\n return { pageSize: first ?? 20, explicitPageToken: pageToken ?? \"\" };\n }\n return { pageSize: 20, explicitPageToken: undefined };\n}\n","import { lookupText, resolveTexts, type LocaleTables } from \"@/src/lib/texts\";\n\n/**\n * Every string the returns views render. Pass a partial object through the\n * `texts` prop of `BitsnapReturns`/`ReturnsProvider` to override any of them,\n * whatever the locale. Strings with `{name}` placeholders keep them in\n * overrides; unknown placeholders are left untouched.\n */\nexport type ReturnsTexts = Omit<ResolvedReturnsTexts, OptionalReturnsTextKey> &\n Partial<Pick<ResolvedReturnsTexts, OptionalReturnsTextKey>>;\n\n/**\n * Keys added after 1.6: optional in {@link ReturnsTexts} so that code which\n * builds a complete texts object keeps compiling. The defaults fill them in.\n */\ntype OptionalReturnsTextKey =\n | \"resendSent\"\n | \"codeSpamHint\"\n | \"codeValidity\"\n | \"codeIncomplete\"\n | \"errorNetwork\";\n\n/** The texts after the defaults are applied: every key is present. */\nexport type ResolvedReturnsTexts = {\n // Frame\n /** Label of the back buttons. */\n back: string;\n /** Step indicator, placeholders `{current}` and `{total}`. */\n stepIndicator: string;\n /** Skeleton accessible label. */\n loading: string;\n /** Button that opens the list of previous returns. */\n myReturnsLink: string;\n\n // Email step\n emailStepTitle: string;\n emailStepDescription: string;\n emailLabel: string;\n emailPlaceholder: string;\n emailSubmit: string;\n\n // Code step\n codeStepTitle: string;\n /** Placeholder `{email}`. */\n codeStepDescription: string;\n codeLabel: string;\n codeSubmit: string;\n resend: string;\n /** Placeholder `{seconds}`. */\n resendIn: string;\n /** Confirmation after a new code was sent. */\n resendSent: string;\n /** Hint under the code field. */\n codeSpamHint: string;\n codeValidity: string;\n /** Shown when the form is submitted with fewer than 6 digits. */\n codeIncomplete: string;\n logout: string;\n\n // Orders\n ordersTitle: string;\n ordersDescription: string;\n ordersEmpty: string;\n /** Placeholder `{reference}`. */\n orderTitle: string;\n /** Placeholder `{count}`. */\n orderReturnableLines: string;\n orderSelect: string;\n paginationPrevious: string;\n paginationNext: string;\n /** Placeholders `{page}` and `{total}` (number of orders). */\n paginationInfo: string;\n\n // Order detail\n /** Placeholder `{reference}`. */\n orderDetailTitle: string;\n orderDetailDescription: string;\n /** Placeholder `{name}`. */\n quantityLabel: string;\n /** Placeholder `{name}`. */\n quantityDecrease: string;\n /** Placeholder `{name}`. */\n quantityIncrease: string;\n /** Placeholder `{available}`. */\n quantityOfAvailable: string;\n /** Shown for an ineligible line without a reason from the backend. */\n lineIneligibleFallback: string;\n noteLabel: string;\n notePlaceholder: string;\n selectionContinue: string;\n selectionEmpty: string;\n previousReturnsTitle: string;\n\n // Confirmation\n confirmationTitle: string;\n confirmationDescription: string;\n confirmationSummary: string;\n /** Placeholder `{quantity}`. */\n confirmationQuantity: string;\n confirmationNote: string;\n confirmationSubmit: string;\n\n // Result\n successTitle: string;\n successDescription: string;\n successReference: string;\n successInstructions: string;\n successDone: string;\n\n // My returns\n myReturnsTitle: string;\n myReturnsDescription: string;\n myReturnsEmpty: string;\n myReturnOpen: string;\n myReturnDetailTitle: string;\n /** Placeholder `{reference}`. */\n myReturnTitle: string;\n myReturnCreatedAt: string;\n myReturnRefund: string;\n myReturnLines: string;\n /** Placeholders `{requested}`, `{approved}`, `{received}`. */\n myReturnLineQuantities: string;\n myReturnNote: string;\n myReturnHistory: string;\n\n // Request status labels\n statusSubmitted: string;\n statusApproved: string;\n statusRejected: string;\n statusAwaitingReceipt: string;\n statusReceived: string;\n statusCompleted: string;\n statusCancelled: string;\n statusRefunded: string;\n /** Any status the backend adds later. */\n statusFallback: string;\n\n // Refund status labels\n refundStatusNotStarted: string;\n refundStatusPending: string;\n refundStatusSucceeded: string;\n refundStatusFailed: string;\n refundStatusFallback: string;\n\n // Error messages\n errorGeneric: string;\n errorNetwork: string;\n errorInvalidEmail: string;\n errorInvalidCode: string;\n errorSessionExpired: string;\n errorOrderNotFound: string;\n errorReturnNotFound: string;\n errorQuantityUnavailable: string;\n errorItemNotReturnable: string;\n errorReturnsDisabled: string;\n errorRateLimited: string;\n errorIdempotencyConflict: string;\n errorDeliveryFailed: string;\n errorRetry: string;\n};\n\nexport type ReturnsTextKey = keyof ResolvedReturnsTexts;\n\nexport const RETURNS_TEXT_TABLES: LocaleTables<ReturnsTextKey> = {\n en: {\n back: \"Back\",\n stepIndicator: \"Step {current} of {total}\",\n loading: \"Loading\",\n myReturnsLink: \"My returns\",\n\n emailStepTitle: \"Return a product\",\n emailStepDescription:\n \"Enter the email address you used for the order. We will send you a verification code.\",\n emailLabel: \"Email address\",\n emailPlaceholder: \"name@example.com\",\n emailSubmit: \"Send code\",\n\n codeStepTitle: \"Enter the code\",\n codeStepDescription: \"We sent a verification code to {email}.\",\n codeLabel: \"Verification code\",\n codeSubmit: \"Verify\",\n resend: \"Send the code again\",\n resendIn: \"Send again in {seconds} s\",\n resendSent: \"We sent a new code.\",\n codeSpamHint: \"Can't see the email? Check your spam folder.\",\n codeValidity: \"The code is valid for 10 minutes.\",\n codeIncomplete: \"Enter all 6 digits of the code.\",\n logout: \"Sign out\",\n\n ordersTitle: \"Your orders\",\n ordersDescription: \"Choose the order that contains the product to return.\",\n ordersEmpty: \"There are no orders eligible for return.\",\n orderTitle: \"Order {reference}\",\n orderReturnableLines: \"Products available to return: {count}\",\n orderSelect: \"Choose\",\n paginationPrevious: \"Previous\",\n paginationNext: \"Next\",\n paginationInfo: \"Page {page}, {total} orders\",\n\n orderDetailTitle: \"Order {reference}\",\n orderDetailDescription: \"Select the products and quantities to return.\",\n quantityLabel: \"Quantity to return: {name}\",\n quantityDecrease: \"Decrease quantity: {name}\",\n quantityIncrease: \"Increase quantity: {name}\",\n quantityOfAvailable: \"of {available}\",\n lineIneligibleFallback: \"This product cannot be returned.\",\n noteLabel: \"Note (optional)\",\n notePlaceholder: \"Tell us why you are returning the product\",\n selectionContinue: \"Continue\",\n selectionEmpty: \"Select at least one item to return.\",\n previousReturnsTitle: \"Earlier returns for this order\",\n\n confirmationTitle: \"Confirm the return\",\n confirmationDescription: \"Check the products before you submit the request.\",\n confirmationSummary: \"Products to return\",\n confirmationQuantity: \"Quantity: {quantity}\",\n confirmationNote: \"Your note\",\n confirmationSubmit: \"Submit return request\",\n\n successTitle: \"Return request submitted\",\n successDescription: \"We received your request and will keep you posted.\",\n successReference: \"Request number\",\n successInstructions: \"What to do next\",\n successDone: \"Back to orders\",\n\n myReturnsTitle: \"My returns\",\n myReturnsDescription: \"Track the status of your return requests.\",\n myReturnsEmpty: \"You have not submitted any return requests yet.\",\n myReturnOpen: \"Details\",\n myReturnDetailTitle: \"Return details\",\n myReturnTitle: \"Return {reference}\",\n myReturnCreatedAt: \"Submitted\",\n myReturnRefund: \"Refund\",\n myReturnLines: \"Products\",\n myReturnLineQuantities:\n \"Requested: {requested}, approved: {approved}, received: {received}\",\n myReturnNote: \"Your note\",\n myReturnHistory: \"History\",\n\n statusSubmitted: \"Submitted\",\n statusApproved: \"Approved\",\n statusRejected: \"Rejected\",\n statusAwaitingReceipt: \"Awaiting the package\",\n statusReceived: \"Package received\",\n statusCompleted: \"Completed\",\n statusCancelled: \"Cancelled\",\n statusRefunded: \"Refunded\",\n statusFallback: \"In progress\",\n\n refundStatusNotStarted: \"Not started\",\n refundStatusPending: \"Refund in progress\",\n refundStatusSucceeded: \"Refunded\",\n refundStatusFailed: \"Refund failed\",\n refundStatusFallback: \"Unknown\",\n\n errorGeneric: \"Something went wrong. Please try again.\",\n errorNetwork: \"Cannot reach the server. Check your connection and try again.\",\n errorInvalidEmail: \"Enter a valid email address.\",\n errorInvalidCode: \"The code is invalid or has expired.\",\n errorSessionExpired: \"Your session has expired. Verify your email again.\",\n errorOrderNotFound: \"We could not find this order.\",\n errorReturnNotFound: \"We could not find this return request.\",\n errorQuantityUnavailable:\n \"The selected quantity is no longer available for return.\",\n errorItemNotReturnable: \"One of the selected products cannot be returned.\",\n errorReturnsDisabled: \"Returns are not available in this shop.\",\n errorRateLimited: \"Too many attempts. Please try again later.\",\n errorIdempotencyConflict:\n \"This request was already submitted with different contents. Reload and try again.\",\n errorDeliveryFailed: \"We could not send the code. Please try again.\",\n errorRetry: \"Try again\",\n },\n pl: {\n back: \"Wstecz\",\n stepIndicator: \"Krok {current} z {total}\",\n loading: \"Ładowanie\",\n myReturnsLink: \"Moje zwroty\",\n\n emailStepTitle: \"Zwróć produkt\",\n emailStepDescription:\n \"Podaj adres e-mail użyty w zamówieniu. Wyślemy na niego kod weryfikacyjny.\",\n emailLabel: \"Adres e-mail\",\n emailPlaceholder: \"jan@example.com\",\n emailSubmit: \"Wyślij kod\",\n\n codeStepTitle: \"Wpisz kod\",\n codeStepDescription: \"Wysłaliśmy kod weryfikacyjny na adres {email}.\",\n codeLabel: \"Kod weryfikacyjny\",\n codeSubmit: \"Zweryfikuj\",\n resend: \"Wyślij kod ponownie\",\n resendIn: \"Wyślij ponownie za {seconds} s\",\n resendSent: \"Wysłaliśmy nowy kod.\",\n codeSpamHint: \"Nie widzisz e-maila? Sprawdź folder spam.\",\n codeValidity: \"Kod jest ważny 10 minut.\",\n codeIncomplete: \"Wpisz wszystkie 6 cyfr kodu.\",\n logout: \"Wyloguj się\",\n\n ordersTitle: \"Twoje zamówienia\",\n ordersDescription: \"Wybierz zamówienie z produktem do zwrotu.\",\n ordersEmpty: \"Brak zamówień, które można zwrócić.\",\n orderTitle: \"Zamówienie {reference}\",\n orderReturnableLines: \"Produkty do zwrotu: {count}\",\n orderSelect: \"Wybierz\",\n paginationPrevious: \"Poprzednia\",\n paginationNext: \"Następna\",\n paginationInfo: \"Strona {page}, zamówień: {total}\",\n\n orderDetailTitle: \"Zamówienie {reference}\",\n orderDetailDescription: \"Wybierz produkty i ilości do zwrotu.\",\n quantityLabel: \"Ilość do zwrotu: {name}\",\n quantityDecrease: \"Zmniejsz ilość: {name}\",\n quantityIncrease: \"Zwiększ ilość: {name}\",\n quantityOfAvailable: \"z {available}\",\n lineIneligibleFallback: \"Ten produkt nie podlega zwrotowi.\",\n noteLabel: \"Uwagi (opcjonalnie)\",\n notePlaceholder: \"Napisz, dlaczego zwracasz produkt\",\n selectionContinue: \"Dalej\",\n selectionEmpty: \"Wybierz co najmniej jedną sztukę do zwrotu.\",\n previousReturnsTitle: \"Wcześniejsze zwroty tego zamówienia\",\n\n confirmationTitle: \"Potwierdź zwrot\",\n confirmationDescription: \"Sprawdź produkty przed wysłaniem zgłoszenia.\",\n confirmationSummary: \"Produkty do zwrotu\",\n confirmationQuantity: \"Ilość: {quantity}\",\n confirmationNote: \"Twoje uwagi\",\n confirmationSubmit: \"Wyślij zgłoszenie zwrotu\",\n\n successTitle: \"Zgłoszenie zwrotu zostało wysłane\",\n successDescription: \"Otrzymaliśmy zgłoszenie i będziemy informować o jego statusie.\",\n successReference: \"Numer zgłoszenia\",\n successInstructions: \"Co dalej\",\n successDone: \"Wróć do zamówień\",\n\n myReturnsTitle: \"Moje zwroty\",\n myReturnsDescription: \"Sprawdź status swoich zgłoszeń zwrotu.\",\n myReturnsEmpty: \"Nie masz jeszcze żadnych zgłoszeń zwrotu.\",\n myReturnOpen: \"Szczegóły\",\n myReturnDetailTitle: \"Szczegóły zwrotu\",\n myReturnTitle: \"Zwrot {reference}\",\n myReturnCreatedAt: \"Zgłoszono\",\n myReturnRefund: \"Zwrot środków\",\n myReturnLines: \"Produkty\",\n myReturnLineQuantities:\n \"Zgłoszono: {requested}, zaakceptowano: {approved}, odebrano: {received}\",\n myReturnNote: \"Twoje uwagi\",\n myReturnHistory: \"Historia\",\n\n statusSubmitted: \"Zgłoszony\",\n statusApproved: \"Zaakceptowany\",\n statusRejected: \"Odrzucony\",\n statusAwaitingReceipt: \"Oczekiwanie na paczkę\",\n statusReceived: \"Paczka odebrana\",\n statusCompleted: \"Zakończony\",\n statusCancelled: \"Anulowany\",\n statusRefunded: \"Środki zwrócone\",\n statusFallback: \"W trakcie\",\n\n refundStatusNotStarted: \"Nie rozpoczęto\",\n refundStatusPending: \"Zwrot środków w toku\",\n refundStatusSucceeded: \"Środki zwrócone\",\n refundStatusFailed: \"Zwrot środków nie powiódł się\",\n refundStatusFallback: \"Nieznany\",\n\n errorGeneric: \"Coś poszło nie tak. Spróbuj ponownie.\",\n errorNetwork: \"Brak połączenia z serwerem. Sprawdź internet i spróbuj ponownie.\",\n errorInvalidEmail: \"Podaj poprawny adres e-mail.\",\n errorInvalidCode: \"Kod jest nieprawidłowy lub wygasł.\",\n errorSessionExpired: \"Sesja wygasła. Zweryfikuj adres e-mail ponownie.\",\n errorOrderNotFound: \"Nie znaleziono tego zamówienia.\",\n errorReturnNotFound: \"Nie znaleziono tego zgłoszenia zwrotu.\",\n errorQuantityUnavailable:\n \"Wybrana ilość nie jest już dostępna do zwrotu.\",\n errorItemNotReturnable: \"Jeden z wybranych produktów nie podlega zwrotowi.\",\n errorReturnsDisabled: \"Zwroty nie są dostępne w tym sklepie.\",\n errorRateLimited: \"Zbyt wiele prób. Spróbuj ponownie później.\",\n errorIdempotencyConflict:\n \"To zgłoszenie zostało już wysłane z inną zawartością. Odśwież stronę i spróbuj ponownie.\",\n errorDeliveryFailed: \"Nie udało się wysłać kodu. Spróbuj ponownie.\",\n errorRetry: \"Spróbuj ponownie\",\n },\n};\n\n/** Default texts for a locale merged with the caller overrides. */\nexport function resolveReturnsTexts(\n locale: string,\n overrides?: Partial<ReturnsTexts>,\n): ResolvedReturnsTexts {\n return resolveTexts(RETURNS_TEXT_TABLES, locale, overrides);\n}\n\nexport function getReturnsText(\n key: ReturnsTextKey,\n locale: string,\n overrides?: Partial<ReturnsTexts>,\n): string {\n return lookupText(resolveReturnsTexts(locale, overrides), key);\n}\n\n/** Replaces `{name}` placeholders. Unknown placeholders stay as they are. */\nexport function fillText(\n template: string,\n values: Record<string, string | number>,\n): string {\n return template.replace(/\\{(\\w+)\\}/g, (match, name: string) =>\n Object.prototype.hasOwnProperty.call(values, name)\n ? String(values[name])\n : match,\n );\n}\n\nconst STATUS_TEXT_KEYS: Record<string, ReturnsTextKey> = {\n submitted: \"statusSubmitted\",\n approved: \"statusApproved\",\n rejected: \"statusRejected\",\n awaiting_receipt: \"statusAwaitingReceipt\",\n received: \"statusReceived\",\n completed: \"statusCompleted\",\n cancelled: \"statusCancelled\",\n refunded: \"statusRefunded\",\n};\n\nconst REFUND_STATUS_TEXT_KEYS: Record<string, ReturnsTextKey> = {\n not_started: \"refundStatusNotStarted\",\n pending: \"refundStatusPending\",\n succeeded: \"refundStatusSucceeded\",\n failed: \"refundStatusFailed\",\n};\n\n/** Text key for a backend request status, with a fallback for unknown ones. */\nexport function statusTextKey(status: string): ReturnsTextKey {\n return STATUS_TEXT_KEYS[status] ?? \"statusFallback\";\n}\n\n/** Text key for a backend refund status, with a fallback for unknown ones. */\nexport function refundStatusTextKey(status: string): ReturnsTextKey {\n return REFUND_STATUS_TEXT_KEYS[status] ?? \"refundStatusFallback\";\n}\n","import { createContext, useCallback, useContext, useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { getLocale } from \"@/src/components/checkout/locale\";\nimport {\n fillText,\n resolveReturnsTexts,\n type ReturnsTextKey,\n type ResolvedReturnsTexts,\n type ReturnsTexts,\n} from \"./texts\";\n\ntype ReturnsTextsContextValue = {\n /** Active locale (the `locale` prop or the library locale). */\n locale: string;\n texts: ResolvedReturnsTexts;\n};\n\nconst ReturnsTextsContext = createContext<ReturnsTextsContextValue>({\n locale: \"pl-PL\",\n texts: resolveReturnsTexts(\"pl-PL\"),\n});\n\n/**\n * Returns scoped texts provider. Carries the `texts` overrides and the\n * `locale` prop down to the returns tree.\n */\nexport function ReturnsTextsProvider({\n texts,\n locale,\n children,\n}: {\n texts?: Partial<ReturnsTexts>;\n locale?: string;\n children: ReactNode;\n}) {\n const activeLocale = locale ?? getLocale();\n const value = useMemo(\n () => ({\n locale: activeLocale,\n texts: resolveReturnsTexts(activeLocale, texts),\n }),\n [activeLocale, texts],\n );\n\n return (\n <ReturnsTextsContext.Provider value={value}>\n {children}\n </ReturnsTextsContext.Provider>\n );\n}\n\n/**\n * Returns a lookup for the returns strings: the caller override when provided,\n * otherwise the default for the locale. Optional `values` fill `{placeholders}`.\n */\nexport function useReturnsText(): (\n key: ReturnsTextKey,\n values?: Record<string, string | number>,\n) => string {\n const { texts } = useContext(ReturnsTextsContext);\n\n return useCallback(\n (key, values) =>\n values == null ? texts[key] : fillText(texts[key], values),\n [texts],\n );\n}\n\n/** Active locale of the returns views, for date and money formatting. */\nexport function useReturnsLocale(): string {\n return useContext(ReturnsTextsContext).locale;\n}\n","import { createClient } from \"@connectrpc/connect\";\nimport {\n createConnectQueryKey,\n TransportProvider,\n} from \"@connectrpc/connect-query\";\nimport {\n QueryClient,\n QueryClientContext,\n QueryClientProvider,\n useQueryClient,\n} from \"@tanstack/react-query\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { CSSProperties, ReactNode } from \"react\";\nimport { Environment } from \"@/src/gen/proto/common/v1/environment_pb\";\nimport { ReturnsService } from \"@/src/gen/proto/public/v1/returns_pb\";\nimport {\n InstrumentProvider,\n useInstrument,\n type AnalyticsOption,\n} from \"@/src/analytics/instrument\";\nimport { cn } from \"@/src/lib/utils\";\nimport {\n clearPendingLogin,\n pendingLoginKey,\n readPendingLogin,\n savePendingLogin,\n} from \"@/src/ui/email-code-login/pending\";\nimport { getRpcTransport, getTransportHost } from \"@/src/rpc-provider\";\nimport type { Transport } from \"@connectrpc/connect\";\nimport type { ReturnsAppearance } from \"./appearance\";\nimport {\n ReturnsAppearanceProvider,\n useReturnsAppearance,\n useReturnsSlot,\n} from \"./appearance.context\";\nimport {\n clearStoredSession,\n expiryToMillis,\n getBrowserSessionStorage,\n readStoredSession,\n writeStoredSession,\n type StoredReturnsSession,\n} from \"./session-storage\";\nimport {\n mapLegacyTexts,\n resolveBrandAppearance,\n resolveReturnsEnvironment,\n type LegacyReturnsTheme,\n type ReturnsEnvironmentInput,\n type ReturnsTextsInput,\n} from \"./legacy\";\nimport { ReturnsTextsProvider } from \"./texts.context\";\n\n/**\n * Backend environment the returns calls run against. The library has no other\n * environment switch for public API calls, so this defaults to `\"production\"`.\n */\nexport type ReturnsEnvironment = \"production\" | \"test\";\n\nexport type ReturnsSessionStatus =\n /** Server render and first client render: storage has not been read yet. */\n | \"hydrating\"\n /** A `panelAccessToken` is being exchanged for a returns session. */\n | \"exchanging\"\n | \"anonymous\"\n | \"authenticated\";\n\n/** A pending email verification. */\nexport type ReturnsChallenge = {\n challengeId: string;\n email: string;\n /** Unix milliseconds when the next code may be requested. */\n resendAvailableAt: number;\n};\n\nexport type ReturnsContextValue = {\n projectID: string;\n environment: Environment;\n status: ReturnsSessionStatus;\n /** Session token. Never log it. */\n token: string | undefined;\n /** Failure of the last panel token exchange, if any. */\n exchangeError: unknown;\n challenge: ReturnsChallenge | undefined;\n /**\n * Stores (or, with `undefined`, drops) the pending verification. It is kept\n * in `sessionStorage` too, so a reload returns to the code step.\n */\n setChallenge: (challenge: ReturnsChallenge | undefined) => void;\n /** Email of the last verification, kept after the challenge is dropped. */\n lastEmail: string | undefined;\n /** Stores a freshly issued session in state and `sessionStorage`. */\n authenticate: (session: StoredReturnsSession) => void;\n /** Drops the session, the pending challenge and cached customer data. */\n clearSession: () => void;\n};\n\nconst ReturnsContext = createContext<ReturnsContextValue | undefined>(\n undefined,\n);\n\n/**\n * Context of the nearest `ReturnsProvider`. Throws a clear error outside of\n * it, naming the component or hook that was misplaced.\n */\nexport function useReturnsContext(name: string): ReturnsContextValue {\n const value = useContext(ReturnsContext);\n\n if (value == null) {\n throw new Error(`${name} must be rendered inside <ReturnsProvider>`);\n }\n\n return value;\n}\n\nexport type ReturnsProviderProps = {\n /** Bitsnap project ID. */\n projectID: string;\n /**\n * API host. Defaults to the host set with `setCustomHost`/`setHost`, then to\n * `https://bitsnap.pl`. Each provider keeps its own transport.\n */\n host?: string;\n /**\n * Backend environment, `\"production\"` unless set to `\"test\"`. The proto\n * `Environment` enum is accepted too.\n */\n environment?: ReturnsEnvironmentInput;\n /** Theme, tokens and per-element overrides. */\n appearance?: ReturnsAppearance;\n /**\n * Text overrides, applied whatever the locale. The keys of `bitsnap-react`\n * 1.6.0 (`title`, `email`, `sendCode`, ...) are accepted too; our own keys\n * win when both are given.\n */\n texts?: ReturnsTextsInput;\n /** `bitsnap-react` 1.6.0 brand color. Explicit `appearance.tokens` win. */\n theme?: LegacyReturnsTheme;\n /** Locale of texts, dates and money. Defaults to the library locale. */\n locale?: string;\n /**\n * Customer panel access token. When set, it is exchanged for a returns\n * session on mount, so the customer needs no second verification code.\n * Changing or removing it drops the session.\n */\n panelAccessToken?: string;\n /** Class of the themed root element. */\n className?: string;\n /**\n * Usage statistics for your Bitsnap dashboard (return started, return\n * submitted). On by default; `false` turns it off. An object lets you\n * forward every event: `{ onEvent }`. Inside `<Panel>` the panel's setting\n * applies unless this is given. Nothing is stored on the visitor's device.\n */\n analytics?: AnalyticsOption;\n children?: ReactNode;\n};\n\n/** Key prefix that matches every returns query, for invalidation and removal. */\nexport function returnsQueryKey(): readonly unknown[] {\n return createConnectQueryKey({\n schema: ReturnsService,\n cardinality: undefined,\n });\n}\n\n/** Longest delay `setTimeout` accepts. */\nconst MAX_TIMEOUT_MS = 2 ** 31 - 1;\n\nfunction SessionProvider({\n projectID,\n environment,\n transport,\n panelAccessToken,\n className,\n children,\n}: {\n projectID: string;\n environment: Environment;\n transport: Transport;\n panelAccessToken?: string;\n className?: string;\n children?: ReactNode;\n}) {\n const queryClient = useQueryClient();\n const { boundaryClassName, boundaryStyle } = useReturnsAppearance();\n const root = useReturnsSlot(\"root\");\n\n const [session, setSession] = useState<{\n status: ReturnsSessionStatus;\n token?: string;\n expiresAt?: number;\n }>({ status: \"hydrating\" });\n const [exchangeError, setExchangeError] = useState<unknown>();\n const [challenge, setChallengeState] = useState<ReturnsChallenge>();\n const [lastEmail, setLastEmail] = useState<string>();\n const pendingKey = pendingLoginKey(\"returns\", projectID);\n const previousPanelToken = useRef<string | undefined>(undefined);\n\n const setChallenge = useCallback(\n (next: ReturnsChallenge | undefined) => {\n setChallengeState(next);\n if (next == null) {\n clearPendingLogin(pendingKey);\n return;\n }\n setLastEmail(next.email);\n savePendingLogin(pendingKey, {\n email: next.email,\n challengeId: next.challengeId,\n resendAt: next.resendAvailableAt,\n sentAt: Date.now(),\n });\n },\n [pendingKey],\n );\n\n const dropCachedData = useCallback(() => {\n // Query inputs carry the session token, so cached customer data must not\n // outlive the session. Only returns queries are touched.\n queryClient.removeQueries({ queryKey: returnsQueryKey() });\n }, [queryClient]);\n\n const clearSession = useCallback(() => {\n clearStoredSession(getBrowserSessionStorage(), projectID);\n setChallenge(undefined);\n setSession({ status: \"anonymous\" });\n dropCachedData();\n }, [projectID, dropCachedData, setChallenge]);\n\n const authenticate = useCallback(\n (next: StoredReturnsSession) => {\n writeStoredSession(getBrowserSessionStorage(), projectID, next);\n setExchangeError(undefined);\n setChallenge(undefined);\n setSession({\n status: \"authenticated\",\n token: next.token,\n expiresAt: next.expiresAt,\n });\n },\n [projectID, setChallenge],\n );\n\n // Hydrates from `sessionStorage`, or exchanges the panel token. Runs after\n // mount, so render never touches `window`.\n useEffect(() => {\n let cancelled = false;\n const storage = getBrowserSessionStorage();\n\n if (panelAccessToken == null || panelAccessToken === \"\") {\n const hadPanelToken = previousPanelToken.current != null;\n previousPanelToken.current = undefined;\n\n if (hadPanelToken) {\n clearSession();\n return;\n }\n\n const stored = readStoredSession(storage, projectID);\n // A verification that was pending before a reload or an app switch.\n const pending = stored == null ? readPendingLogin(pendingKey) : undefined;\n if (pending?.challengeId != null) {\n setChallengeState({\n challengeId: pending.challengeId,\n email: pending.email,\n resendAvailableAt: pending.resendAt,\n });\n setLastEmail(pending.email);\n }\n setSession(\n stored != null\n ? {\n status: \"authenticated\",\n token: stored.token,\n expiresAt: stored.expiresAt,\n }\n : { status: \"anonymous\" },\n );\n return;\n }\n\n previousPanelToken.current = panelAccessToken;\n clearStoredSession(storage, projectID);\n dropCachedData();\n setExchangeError(undefined);\n setSession({ status: \"exchanging\" });\n\n createClient(ReturnsService, transport)\n .exchangePanelSession({\n projectId: projectID,\n accessToken: panelAccessToken,\n environment,\n })\n .then((response) => {\n if (cancelled) {\n return;\n }\n const expiresAt = expiryToMillis(response.expiresAt);\n if (response.sessionToken === \"\" || expiresAt == null) {\n throw new Error(\"EMPTY_SESSION\");\n }\n authenticate({ token: response.sessionToken, expiresAt });\n })\n .catch((error: unknown) => {\n if (cancelled) {\n return;\n }\n setExchangeError(error);\n setSession({ status: \"anonymous\" });\n });\n\n return () => {\n cancelled = true;\n };\n // `clearSession`, `authenticate` and `dropCachedData` only change with the\n // project or the query client, which are already covered.\n }, [panelAccessToken, projectID, environment, transport]);\n\n // Expired sessions are dropped even when the page stays open.\n useEffect(() => {\n if (session.status !== \"authenticated\" || session.expiresAt == null) {\n return;\n }\n const remaining = session.expiresAt - Date.now();\n if (remaining <= 0) {\n clearSession();\n return;\n }\n const timer = setTimeout(\n clearSession,\n Math.min(remaining, MAX_TIMEOUT_MS),\n );\n return () => clearTimeout(timer);\n }, [session.status, session.expiresAt, clearSession]);\n\n const value = useMemo<ReturnsContextValue>(\n () => ({\n projectID,\n environment,\n status: session.status,\n token: session.token,\n exchangeError,\n challenge,\n setChallenge,\n lastEmail,\n authenticate,\n clearSession,\n }),\n [\n projectID,\n environment,\n session.status,\n session.token,\n exchangeError,\n challenge,\n setChallenge,\n lastEmail,\n authenticate,\n clearSession,\n ],\n );\n\n return (\n <ReturnsContext.Provider value={value}>\n <div\n data-bitsnap-returns=\"root\"\n data-bitsnap-returns-slot=\"root\"\n className={cn(\"bitsnap-react\", boundaryClassName, className, root.className)}\n style={{ ...boundaryStyle, ...root.style } as CSSProperties}\n >\n {children}\n </div>\n </ReturnsContext.Provider>\n );\n}\n\n/**\n * Holds everything the returns views share: the per-instance transport, the\n * query client (when the app has none), appearance, texts and the returns\n * session. It renders the themed root element, so step components composed\n * under it are themed without extra markup.\n *\n * ```tsx\n * <ReturnsProvider projectID=\"…\" appearance={brand}>\n * <ReturnsOrderList onSelectOrder={setOrderId} />\n * </ReturnsProvider>\n * ```\n */\nexport function ReturnsProvider({\n projectID,\n host,\n environment,\n appearance,\n texts,\n theme,\n locale,\n panelAccessToken,\n className,\n analytics,\n children,\n}: ReturnsProviderProps) {\n const instrument = useInstrument(projectID, analytics, \"returns\");\n const existingQueryClient = useContext(QueryClientContext);\n const [ownQueryClient] = useState(() =>\n existingQueryClient == null\n ? new QueryClient({ defaultOptions: { queries: { staleTime: 5000 } } })\n : undefined,\n );\n\n const resolvedHost = host ?? getTransportHost();\n const transport = useMemo(\n () => getRpcTransport(resolvedHost),\n [resolvedHost],\n );\n\n const brandColor = theme?.brandColor;\n const resolvedAppearance = useMemo(\n () => resolveBrandAppearance(appearance, { brandColor }),\n [appearance, brandColor],\n );\n const resolvedTexts = useMemo(() => mapLegacyTexts(texts), [texts]);\n\n const content = (\n <InstrumentProvider value={instrument}>\n <TransportProvider transport={transport}>\n <ReturnsAppearanceProvider appearance={resolvedAppearance}>\n <ReturnsTextsProvider texts={resolvedTexts} locale={locale}>\n <SessionProvider\n projectID={projectID}\n environment={resolveReturnsEnvironment(environment)}\n transport={transport}\n panelAccessToken={panelAccessToken}\n className={className}\n >\n {children}\n </SessionProvider>\n </ReturnsTextsProvider>\n </ReturnsAppearanceProvider>\n </TransportProvider>\n </InstrumentProvider>\n );\n\n return existingQueryClient == null && ownQueryClient != null ? (\n <QueryClientProvider client={ownQueryClient}>{content}</QueryClientProvider>\n ) : (\n content\n );\n}\n\n/** Name of {@link ReturnsProvider} in `bitsnap-react` 1.6.0. */\nexport const BitsnapReturnsProvider = ReturnsProvider;\n\nexport type BitsnapReturnsProviderProps = ReturnsProviderProps;\n","/**\n * The pending step of an e-mail-code login, kept in `sessionStorage` so a\n * reload or an app switch (the code arrives in the mail app) returns to the\n * code step. One key per surface and project; never holds the code itself.\n */\n\n/** How long a sent code stays usable, in milliseconds (the copy says 10 min). */\nexport const CODE_VALID_MS = 10 * 60 * 1000;\n\nexport type PendingLogin = {\n email: string;\n challengeId?: string;\n /** Unix milliseconds when a new code may be requested. */\n resendAt: number;\n /** Unix milliseconds when the code was sent. */\n sentAt: number;\n};\n\ntype StorageLike = Pick<Storage, \"getItem\" | \"setItem\" | \"removeItem\">;\n\nfunction browserStorage(): StorageLike | undefined {\n try {\n return typeof window !== \"undefined\" ? window.sessionStorage : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** `bitsnap-login-pending:<surface>:<host>:<project>`. */\nexport function pendingLoginKey(\n surface: string,\n projectID?: string,\n host?: string,\n): string {\n return `bitsnap-login-pending:${surface}:${encodeURIComponent(host ?? \"\")}:${encodeURIComponent(projectID ?? \"\")}`;\n}\n\nexport function savePendingLogin(key: string, pending: PendingLogin): void {\n try {\n browserStorage()?.setItem(key, JSON.stringify(pending));\n } catch {\n // Storage full or blocked: the login still works, it just is not restored.\n }\n}\n\nexport function clearPendingLogin(key: string): void {\n try {\n browserStorage()?.removeItem(key);\n } catch {\n // ignore\n }\n}\n\n/**\n * The stored step. Malformed and expired entries are removed and reported as\n * none.\n */\nexport function readPendingLogin(\n key: string,\n now: number = Date.now(),\n): PendingLogin | undefined {\n const storage = browserStorage();\n if (storage == null) return undefined;\n try {\n const raw = storage.getItem(key);\n if (raw == null) return undefined;\n const parsed = JSON.parse(raw) as Partial<PendingLogin> | null;\n if (\n parsed != null &&\n typeof parsed.email === \"string\" &&\n parsed.email !== \"\" &&\n typeof parsed.sentAt === \"number\" &&\n typeof parsed.resendAt === \"number\" &&\n (parsed.challengeId == null || typeof parsed.challengeId === \"string\") &&\n now - parsed.sentAt < CODE_VALID_MS\n ) {\n return {\n email: parsed.email,\n challengeId: parsed.challengeId,\n resendAt: parsed.resendAt,\n sentAt: parsed.sentAt,\n };\n }\n storage.removeItem(key);\n } catch {\n try {\n storage.removeItem(key);\n } catch {\n // ignore\n }\n }\n return undefined;\n}\n"]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkW3RGQYPDjs = require('./chunk-W3RGQYPD.js');var Oe=Symbol.for("bitsnap.pageViews");function ye(e){let t=e;return t[Oe]??={path:null,starters:new Set,watching:!1}}function De(e,t){let n=()=>{try{t()}catch (e2){}};for(let o of["pushState","replaceState"]){let a=e.history[o];e.history[o]=function(...i){let c=a.apply(this,i);return n(),c}}e.addEventListener("popstate",n)}function A(e,t=window){try{let n=ye(t),o=()=>e();n.watching||(n.watching=!0,De(t,()=>{let i=t.location.pathname;i===n.path||n.starters.size===0||(n.path=i,_optionalChain([n, 'access', _2 => _2.starters, 'access', _3 => _3.values, 'call', _4 => _4(), 'access', _5 => _5.next, 'call', _6 => _6(), 'access', _7 => _7.value, 'optionalCall', _8 => _8()]))})),n.starters.add(o);let a=t.location.pathname;return a!==n.path&&(n.path=a,o()),()=>void n.starters.delete(o)}catch (e3){return()=>{}}}function ge(e=window){let t=ye(e);t.path=null,t.starters.clear()}var ve="1.18.0";function I(e){let t=new Uint8Array(e),n=typeof crypto<"u"?crypto:void 0;if(n&&typeof n.getRandomValues=="function")n.getRandomValues(t);else for(let o=0;o<e;o++)t[o]=Math.floor(Math.random()*256);return t}var me="X-Bitsnap-Visitor",$e=390*24*60*60,Me=/^[A-Za-z0-9_-]{22}$/;function R(e){return e.BitsnapConsent}function je(e,t){for(let n of e.cookie.split(";")){let o=n.indexOf("=");if(o!==-1&&n.slice(0,o).trim()===t)return n.slice(o+1).trim()}return null}function He(e){let t=e.toLowerCase();return t==="bitsnap.pl"||t.endsWith(".bitsnap.pl")}function F(e,t){try{let n=R(e);if(!n)return!1;if(n.scope==="project")return n.projectKey===t;let o=He(e.location.hostname);return n.scope==="global"?!o:!1}catch (e4){return!1}}function J(e,t){try{return _optionalChain([R, 'call', _9 => _9(e), 'optionalAccess', _10 => _10.get, 'call', _11 => _11(), 'optionalAccess', _12 => _12.c, 'access', _13 => _13.analytics])===!0&&F(e,t)}catch (e5){return!1}}function he(){let e="";return I(16).forEach(t=>e+=String.fromCharCode(t)),btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ee(e,t){try{return je(e,_chunkW3RGQYPDjs.g.call(void 0, t))}catch (e6){return null}}function B(e,t){let n=Ee(e,t);return n!==null&&Me.test(n)?n:null}function ke(e,t,n){try{let o=e.document,a=`${_chunkW3RGQYPDjs.g.call(void 0, t)}=${n}; Max-Age=${$e}; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");for(let i of _chunkW3RGQYPDjs.o.call(void 0, e.location.hostname).reverse())if(o.cookie=`${a}; Domain=${i}`,B(o,t)===n)return;o.cookie=a}catch (e7){}}function be(e,t){try{let n=e.document;if(Ee(n,t)===null)return;let o=`${_chunkW3RGQYPDjs.g.call(void 0, t)}=; Max-Age=0; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");n.cookie=o;for(let a of _chunkW3RGQYPDjs.o.call(void 0, e.location.hostname))n.cookie=`${o}; Domain=${a}`}catch (e8){}}function N(e,t){try{let n=e.navigator;return _optionalChain([n, 'optionalAccess', _14 => _14.globalPrivacyControl])===!0||_optionalChain([n, 'optionalAccess', _15 => _15.webdriver])===!0?null:J(e,t)?B(e.document,t):null}catch (e9){return null}}var Ue="https://collect.bitsnap.pl",Ke=5e3,Ge=20,Te=32*1024,ze=60*1024,xe=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function _e(e){return typeof TextEncoder=="function"?new TextEncoder().encode(e).length:unescape(encodeURIComponent(e)).length}var y={track(){},page(){},clientId:()=>null,flush(){},setEnabled(){},onEvent:()=>()=>{},configure(){},destroy(){}};function Ye(e=Date.now()){let t=I(16),n=e;for(let a=5;a>=0;a--)t[a]=n%256,n=Math.floor(n/256);t[6]=t[6]&15|112,t[8]=t[8]&63|128;let o=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function Fe(){return Array.from(I(16),e=>Ce[e%Ce.length]).join("")}function Je(e,t,n=!1){let o=_e(JSON.stringify({k:e,events:[]})),a=[],i=[],c=o,s=()=>{i.length>0&&a.push({body:JSON.stringify({k:e,events:i}),bytes:c,count:i.length}),i=[],c=o};for(let u of t){let l=_e(JSON.stringify(u));o+l>Te||((i.length>=_chunkW3RGQYPDjs.a.maxBatchEvents||c+l+(i.length>0?1:0)>Te)&&s(),c+=l+(i.length>0?1:0),i.push(u))}if(s(),n){let u=0,l=a.length;for(;l>0&&u+a[l-1].bytes<=ze;)u+=a[l-1].bytes,l--;a=a.slice(l)}return a}function Xe(e){try{return typeof window>"u"||typeof document>"u"?y:qe(e,window)}catch (e10){return y}}function qe(e,t){let n=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => (""))),o=!!e.debug,a=(...r)=>{o&&console.warn("[bitsnap analytics]",...r)};if(!n)return a("invalid projectKey, tracking is off"),y;let i=n,c=r=>`${(r||Ue).replace(/\/+$/,"")}/e`,s=c(e.endpoint),u=_nullishCoalesce(e.source, () => ("sdk_react")),l=_nullishCoalesce(e.channel, () => ("embed")),b=`bitsnap-react@${ve}`,M=Fe(),T=_chunkW3RGQYPDjs.e.call(void 0, t.location.href),j=_nullishCoalesce(e.env, () => ("live"));if(!e.env)try{new URLSearchParams(t.location.search).has("test")&&(j="test")}catch (e11){}let Le=_chunkW3RGQYPDjs.f.call(void 0, document.referrer),H=e.enabled!==!1,ee=null,Re=0,p=[],h=null,C=new Set;e.onEvent&&C.add(e.onEvent);let E=[],g,m=!0;function W(){let r=R(t);!r||r===g||(g=r,m=!r.ready,_optionalChain([r, 'access', _16 => _16.ready, 'optionalAccess', _17 => _17.then, 'call', _18 => _18(()=>{g===r&&(m=!0,re())},()=>{g===r&&(m=!0)})]))}function te(){W();try{if(!g)return!1;let r=g.get();return!!g.denied&&g.denied("analytics")||!!r&&r.c.analytics===!1}catch (e12){return!1}}function ne(r){C.forEach(f=>{try{f(r)}catch (e13){}})}function U(r){try{if(W(),!g||!F(t,i))return;J(t,i)?P()&&B(t.document,i)===null&&ke(t,i,he()):r&&be(t,i)}catch (e14){}}function re(){if(U(!0),te())p=[],E=[],w();else{if(m&&E.length>0){let r=E;E=[],r.forEach(ne)}p.length>0&&x()}}function P(){if(!H)return!1;let r=t.navigator;return r&&(r.globalPrivacyControl===!0||r.webdriver===!0)?!1:!te()}function w(){h!==null&&clearTimeout(h),h=null}function Be(){h===null&&(h=setTimeout(()=>{h=null,x()},Ke),_optionalChain([h, 'access', _19 => _19.unref, 'optionalCall', _20 => _20()]))}function Ne(r){try{if(typeof fetch=="function"){fetch(s,{method:"POST",body:r,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain"}}).catch(()=>{});return}}catch (e15){}try{let f=t.navigator;f&&typeof f.sendBeacon=="function"&&f.sendBeacon(s,new Blob([r],{type:"text/plain"}))}catch (e16){}}function x(r=!1){try{if(w(),p.length===0)return;if(!P()){p=[];return}if(!m)return;U(m);let f=N(t,i),d=f?p.map(k=>({...k,client_id:f})):p;p=[],Je(i,d,r).forEach(k=>Ne(k.body))}catch (e17){}}function oe(r,f,d){if(!P())return;let k=_chunkW3RGQYPDjs.h.call(void 0, r,f);if(!k.ok){a("dropped",r,k.reason);return}let se=_chunkW3RGQYPDjs.e.call(void 0, t.location.href),K={event_id:_optionalChain([d, 'optionalAccess', _21 => _21.event_id])&&xe.test(d.event_id)?d.event_id:Ye(),event:r,ts:Date.now(),schema_version:1,env:j,source:u,channel:l,sdk:b,page_id:M,page_type:_optionalChain([d, 'optionalAccess', _22 => _22.page_type])!==void 0?d.page_type:ee,host:_nullishCoalesce(_optionalChain([se, 'optionalAccess', _23 => _23.host]), () => (null)),path:_optionalChain([d, 'optionalAccess', _24 => _24.path])?_chunkW3RGQYPDjs.d.call(void 0, d.path.split(/[?#]/)[0]):_nullishCoalesce(_optionalChain([se, 'optionalAccess', _25 => _25.path]), () => (null)),referrer_host:Le,utm_source:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _26 => _26.utm_source]), () => (null)),utm_medium:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _27 => _27.utm_medium]), () => (null)),utm_campaign:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _28 => _28.utm_campaign]), () => (null)),utm_content:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _29 => _29.utm_content]), () => (null)),utm_term:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _30 => _30.utm_term]), () => (null)),ref_code:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _31 => _31.ref_code]), () => (null)),product_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _32 => _32.product_id]), () => (null)),variant_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _33 => _33.variant_id]), () => (null)),order_ref:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _34 => _34.order_ref]), () => (null)),props:k.props};_optionalChain([d, 'optionalAccess', _35 => _35.event_id])&&!xe.test(d.event_id)&&a("ignored invalid event_id",r),u==="dashboard"&&e.visitorId&&(K.visitor_id=e.visitorId);let ce=_chunkW3RGQYPDjs.i.call(void 0, K);if(!ce.ok){a("dropped",r,ce.reason);return}let G=K;m?ne(G):E.push(G),p.push(G),p.length>=Ge?x():Be()}let ie=()=>x(!0),ae=()=>{document.visibilityState==="hidden"&&x(!0)},S=()=>re();return t.addEventListener("pagehide",ie),document.addEventListener("visibilitychange",ae),t.addEventListener("bitsnap:consent",S),t.addEventListener("bitsnap:consent:ready",S),W(),U(m),{track(r,f,d){try{oe(r,f,d)}catch (e18){}},page(r,f){try{r!==void 0&&(ee=r),oe("page_view",{landing:Re++===0},f)}catch (e19){}},clientId(r){try{return r!==void 0&&_chunkW3RGQYPDjs.c.call(void 0, r)!==i?null:P()?N(t,i):null}catch (e20){return null}},flush:()=>x(),setEnabled(r){H=!!r,H||(p=[],E=[],w())},configure(r){try{(r.env==="live"||r.env==="test")&&(j=r.env),typeof r.endpoint=="string"&&r.endpoint&&(s=c(r.endpoint))}catch (e21){}},onEvent(r){return C.add(r),()=>void C.delete(r)},destroy(){p=[],E=[],w(),C.clear(),t.removeEventListener("pagehide",ie),document.removeEventListener("visibilitychange",ae),t.removeEventListener("bitsnap:consent",S),t.removeEventListener("bitsnap:consent:ready",S)}}}var v,O=null;function D(e){if(!v){let t=Xe(e);return t===y||(v=t,O=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => ("")))),t}try{let t=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => ("")));t!==O&&e.debug&&console.warn("[bitsnap analytics]","tracker already started for another projectKey, ignoring",e.projectKey),t===O&&((e.env||e.endpoint)&&v.configure({env:e.env,endpoint:e.endpoint}),e.enabled!=null&&v.setEnabled(e.enabled))}catch (e22){}return v}function Ae(){return v}function xt(){typeof window<"u"&&ge(window),_optionalChain([v, 'optionalAccess', _36 => _36.destroy, 'call', _37 => _37()]),v=void 0,O=null}function _t(e){try{if(typeof window>"u")return{};let t=v,n=null;if(t)n=t.clientId(e);else{let o=e?_chunkW3RGQYPDjs.c.call(void 0, e):null;n=o?N(window,o):null}return n?{[me]:n}:{}}catch (e23){return{}}}var _react = require('react');var nt={track:y.track,page:y.page},Pe=_react.createContext.call(void 0, nt);function St({projectKey:e,env:t,enabled:n,endpoint:o,onEvent:a,autoPageViews:i,children:c}){let s=_react.useMemo.call(void 0, ()=>D({projectKey:e,env:t,endpoint:o,enabled:n}),[e,t,o]),u=_react.useRef.call(void 0, a);u.current=a,_chunkW3RGQYPDjs.q.call(void 0, ()=>{s.setEnabled(n!==!1)},[s,n]),_chunkW3RGQYPDjs.q.call(void 0, ()=>{if(!(i===!1||n===!1||s===y))return A(()=>s.page(null))},[s,i,n]),_chunkW3RGQYPDjs.q.call(void 0, ()=>s.onEvent(b=>_optionalChain([u, 'access', _38 => _38.current, 'optionalCall', _39 => _39(b)])),[s]);let l=_react.useMemo.call(void 0, ()=>({track:s.track.bind(s),page:s.page.bind(s)}),[s]);return _react.createElement.call(void 0, Pe.Provider,{value:l},c)}function we(){return _react.useContext.call(void 0, Pe)}var $={track(){}},X=null;function lt(e){let t=Symbol("bitsnap-instrument");function n(){if(typeof window>"u")return null;let{projectKey:i,analytics:c,provided:s}=e();return c===!1?null:s||(i?D({projectKey:i,source:"sdk_react",channel:"embed",env:typeof c=="object"?c.env:void 0}):null)}let o={track(i,c,s){try{let u=n();if(!u)return;let{analytics:l,pageType:b}=e(),M=b&&_optionalChain([s, 'optionalAccess', _40 => _40.page_type])===void 0?{...s,page_type:b}:s;X=typeof l=="object"&&l.onEvent?t:null,u.track(i,c,M)}catch (e24){}finally{X=null}}};function a(){try{if(!n())return()=>{};let i=Ae();if(!i)return()=>{};let c=e().provided?()=>{}:A(()=>i.page(_nullishCoalesce(e().pageType, () => (null)))),s=i.onEvent(u=>{if(X===t)try{let{analytics:l}=e();typeof l=="object"&&_optionalChain([l, 'access', _41 => _41.onEvent, 'optionalCall', _42 => _42(u)])}catch (e25){}});return()=>{c(),s()}}catch (e26){return()=>{}}}return{instrument:o,attach:a}}var Z=_react.createContext.call(void 0, null);function Nt({value:e,children:t}){return _react.createElement.call(void 0, Z.Provider,{value:e},t)}function Ot(){return _nullishCoalesce(_react.useContext.call(void 0, Z), () => ($))}function Dt(e,t,n){let o=_react.useContext.call(void 0, Z),a=we(),i=a.track===y.track?null:a,c=_react.useRef.call(void 0, {projectKey:e,analytics:t,pageType:n,provided:i});c.current={projectKey:e,analytics:t,pageType:n,provided:i};let s=_react.useMemo.call(void 0, ()=>lt(()=>c.current),[]),u=t===void 0&&o!==null,l=typeof t=="object"&&!!t.onEvent;return _react.useLayoutEffect.call(void 0, ()=>{if(!u)return s.attach()},[s,u,l,e]),u?o:s.instrument}var Q=$;function Se(e){Q=_nullishCoalesce(e, () => ($))}var q=0;function $t(){return q>0?$:Q}async function Mt(e){q++;try{return await e()}finally{q--}}function jt(e){_react.useEffect.call(void 0, ()=>(Se(e),()=>{Q===e&&Se(null)}),[e])}function Ht(e){let t=Number.isFinite(e)?Math.max(0,Math.min(100,e)):0;return t>=100?"100":t>=75?"75-99":t>=50?"50-74":t>=25?"25-49":"0-24"}function Wt(e,t){let n=[];for(let o of[25,50,75,100])e>=o&&!t.has(o)&&(t.add(o),n.push(o));return n}exports.a = ve; exports.b = A; exports.c = Ue; exports.d = Xe; exports.e = D; exports.f = Ae; exports.g = xt; exports.h = _t; exports.i = St; exports.j = we; exports.k = $; exports.l = Nt; exports.m = Ot; exports.n = Dt; exports.o = $t; exports.p = Mt; exports.q = jt; exports.r = Ht; exports.s = Wt;
2
- //# sourceMappingURL=chunk-DP2NOHCI.js.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkW3RGQYPDjs = require('./chunk-W3RGQYPD.js');var Oe=Symbol.for("bitsnap.pageViews");function ye(e){let t=e;return t[Oe]??={path:null,starters:new Set,watching:!1}}function De(e,t){let n=()=>{try{t()}catch (e2){}};for(let o of["pushState","replaceState"]){let a=e.history[o];e.history[o]=function(...i){let c=a.apply(this,i);return n(),c}}e.addEventListener("popstate",n)}function A(e,t=window){try{let n=ye(t),o=()=>e();n.watching||(n.watching=!0,De(t,()=>{let i=t.location.pathname;i===n.path||n.starters.size===0||(n.path=i,_optionalChain([n, 'access', _2 => _2.starters, 'access', _3 => _3.values, 'call', _4 => _4(), 'access', _5 => _5.next, 'call', _6 => _6(), 'access', _7 => _7.value, 'optionalCall', _8 => _8()]))})),n.starters.add(o);let a=t.location.pathname;return a!==n.path&&(n.path=a,o()),()=>void n.starters.delete(o)}catch (e3){return()=>{}}}function ge(e=window){let t=ye(e);t.path=null,t.starters.clear()}var ve="1.19.0";function I(e){let t=new Uint8Array(e),n=typeof crypto<"u"?crypto:void 0;if(n&&typeof n.getRandomValues=="function")n.getRandomValues(t);else for(let o=0;o<e;o++)t[o]=Math.floor(Math.random()*256);return t}var me="X-Bitsnap-Visitor",$e=390*24*60*60,Me=/^[A-Za-z0-9_-]{22}$/;function R(e){return e.BitsnapConsent}function je(e,t){for(let n of e.cookie.split(";")){let o=n.indexOf("=");if(o!==-1&&n.slice(0,o).trim()===t)return n.slice(o+1).trim()}return null}function He(e){let t=e.toLowerCase();return t==="bitsnap.pl"||t.endsWith(".bitsnap.pl")}function F(e,t){try{let n=R(e);if(!n)return!1;if(n.scope==="project")return n.projectKey===t;let o=He(e.location.hostname);return n.scope==="global"?!o:!1}catch (e4){return!1}}function J(e,t){try{return _optionalChain([R, 'call', _9 => _9(e), 'optionalAccess', _10 => _10.get, 'call', _11 => _11(), 'optionalAccess', _12 => _12.c, 'access', _13 => _13.analytics])===!0&&F(e,t)}catch (e5){return!1}}function he(){let e="";return I(16).forEach(t=>e+=String.fromCharCode(t)),btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ee(e,t){try{return je(e,_chunkW3RGQYPDjs.g.call(void 0, t))}catch (e6){return null}}function B(e,t){let n=Ee(e,t);return n!==null&&Me.test(n)?n:null}function ke(e,t,n){try{let o=e.document,a=`${_chunkW3RGQYPDjs.g.call(void 0, t)}=${n}; Max-Age=${$e}; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");for(let i of _chunkW3RGQYPDjs.o.call(void 0, e.location.hostname).reverse())if(o.cookie=`${a}; Domain=${i}`,B(o,t)===n)return;o.cookie=a}catch (e7){}}function be(e,t){try{let n=e.document;if(Ee(n,t)===null)return;let o=`${_chunkW3RGQYPDjs.g.call(void 0, t)}=; Max-Age=0; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");n.cookie=o;for(let a of _chunkW3RGQYPDjs.o.call(void 0, e.location.hostname))n.cookie=`${o}; Domain=${a}`}catch (e8){}}function N(e,t){try{let n=e.navigator;return _optionalChain([n, 'optionalAccess', _14 => _14.globalPrivacyControl])===!0||_optionalChain([n, 'optionalAccess', _15 => _15.webdriver])===!0?null:J(e,t)?B(e.document,t):null}catch (e9){return null}}var Ue="https://collect.bitsnap.pl",Ke=5e3,Ge=20,Te=32*1024,ze=60*1024,xe=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function _e(e){return typeof TextEncoder=="function"?new TextEncoder().encode(e).length:unescape(encodeURIComponent(e)).length}var y={track(){},page(){},clientId:()=>null,flush(){},setEnabled(){},onEvent:()=>()=>{},configure(){},destroy(){}};function Ye(e=Date.now()){let t=I(16),n=e;for(let a=5;a>=0;a--)t[a]=n%256,n=Math.floor(n/256);t[6]=t[6]&15|112,t[8]=t[8]&63|128;let o=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function Fe(){return Array.from(I(16),e=>Ce[e%Ce.length]).join("")}function Je(e,t,n=!1){let o=_e(JSON.stringify({k:e,events:[]})),a=[],i=[],c=o,s=()=>{i.length>0&&a.push({body:JSON.stringify({k:e,events:i}),bytes:c,count:i.length}),i=[],c=o};for(let u of t){let l=_e(JSON.stringify(u));o+l>Te||((i.length>=_chunkW3RGQYPDjs.a.maxBatchEvents||c+l+(i.length>0?1:0)>Te)&&s(),c+=l+(i.length>0?1:0),i.push(u))}if(s(),n){let u=0,l=a.length;for(;l>0&&u+a[l-1].bytes<=ze;)u+=a[l-1].bytes,l--;a=a.slice(l)}return a}function Xe(e){try{return typeof window>"u"||typeof document>"u"?y:qe(e,window)}catch (e10){return y}}function qe(e,t){let n=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => (""))),o=!!e.debug,a=(...r)=>{o&&console.warn("[bitsnap analytics]",...r)};if(!n)return a("invalid projectKey, tracking is off"),y;let i=n,c=r=>`${(r||Ue).replace(/\/+$/,"")}/e`,s=c(e.endpoint),u=_nullishCoalesce(e.source, () => ("sdk_react")),l=_nullishCoalesce(e.channel, () => ("embed")),b=`bitsnap-react@${ve}`,M=Fe(),T=_chunkW3RGQYPDjs.e.call(void 0, t.location.href),j=_nullishCoalesce(e.env, () => ("live"));if(!e.env)try{new URLSearchParams(t.location.search).has("test")&&(j="test")}catch (e11){}let Le=_chunkW3RGQYPDjs.f.call(void 0, document.referrer),H=e.enabled!==!1,ee=null,Re=0,p=[],h=null,C=new Set;e.onEvent&&C.add(e.onEvent);let E=[],g,m=!0;function W(){let r=R(t);!r||r===g||(g=r,m=!r.ready,_optionalChain([r, 'access', _16 => _16.ready, 'optionalAccess', _17 => _17.then, 'call', _18 => _18(()=>{g===r&&(m=!0,re())},()=>{g===r&&(m=!0)})]))}function te(){W();try{if(!g)return!1;let r=g.get();return!!g.denied&&g.denied("analytics")||!!r&&r.c.analytics===!1}catch (e12){return!1}}function ne(r){C.forEach(f=>{try{f(r)}catch (e13){}})}function U(r){try{if(W(),!g||!F(t,i))return;J(t,i)?P()&&B(t.document,i)===null&&ke(t,i,he()):r&&be(t,i)}catch (e14){}}function re(){if(U(!0),te())p=[],E=[],w();else{if(m&&E.length>0){let r=E;E=[],r.forEach(ne)}p.length>0&&x()}}function P(){if(!H)return!1;let r=t.navigator;return r&&(r.globalPrivacyControl===!0||r.webdriver===!0)?!1:!te()}function w(){h!==null&&clearTimeout(h),h=null}function Be(){h===null&&(h=setTimeout(()=>{h=null,x()},Ke),_optionalChain([h, 'access', _19 => _19.unref, 'optionalCall', _20 => _20()]))}function Ne(r){try{if(typeof fetch=="function"){fetch(s,{method:"POST",body:r,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain"}}).catch(()=>{});return}}catch (e15){}try{let f=t.navigator;f&&typeof f.sendBeacon=="function"&&f.sendBeacon(s,new Blob([r],{type:"text/plain"}))}catch (e16){}}function x(r=!1){try{if(w(),p.length===0)return;if(!P()){p=[];return}if(!m)return;U(m);let f=N(t,i),d=f?p.map(k=>({...k,client_id:f})):p;p=[],Je(i,d,r).forEach(k=>Ne(k.body))}catch (e17){}}function oe(r,f,d){if(!P())return;let k=_chunkW3RGQYPDjs.h.call(void 0, r,f);if(!k.ok){a("dropped",r,k.reason);return}let se=_chunkW3RGQYPDjs.e.call(void 0, t.location.href),K={event_id:_optionalChain([d, 'optionalAccess', _21 => _21.event_id])&&xe.test(d.event_id)?d.event_id:Ye(),event:r,ts:Date.now(),schema_version:1,env:j,source:u,channel:l,sdk:b,page_id:M,page_type:_optionalChain([d, 'optionalAccess', _22 => _22.page_type])!==void 0?d.page_type:ee,host:_nullishCoalesce(_optionalChain([se, 'optionalAccess', _23 => _23.host]), () => (null)),path:_optionalChain([d, 'optionalAccess', _24 => _24.path])?_chunkW3RGQYPDjs.d.call(void 0, d.path.split(/[?#]/)[0]):_nullishCoalesce(_optionalChain([se, 'optionalAccess', _25 => _25.path]), () => (null)),referrer_host:Le,utm_source:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _26 => _26.utm_source]), () => (null)),utm_medium:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _27 => _27.utm_medium]), () => (null)),utm_campaign:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _28 => _28.utm_campaign]), () => (null)),utm_content:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _29 => _29.utm_content]), () => (null)),utm_term:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _30 => _30.utm_term]), () => (null)),ref_code:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _31 => _31.ref_code]), () => (null)),product_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _32 => _32.product_id]), () => (null)),variant_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _33 => _33.variant_id]), () => (null)),order_ref:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _34 => _34.order_ref]), () => (null)),props:k.props};_optionalChain([d, 'optionalAccess', _35 => _35.event_id])&&!xe.test(d.event_id)&&a("ignored invalid event_id",r),u==="dashboard"&&e.visitorId&&(K.visitor_id=e.visitorId);let ce=_chunkW3RGQYPDjs.i.call(void 0, K);if(!ce.ok){a("dropped",r,ce.reason);return}let G=K;m?ne(G):E.push(G),p.push(G),p.length>=Ge?x():Be()}let ie=()=>x(!0),ae=()=>{document.visibilityState==="hidden"&&x(!0)},S=()=>re();return t.addEventListener("pagehide",ie),document.addEventListener("visibilitychange",ae),t.addEventListener("bitsnap:consent",S),t.addEventListener("bitsnap:consent:ready",S),W(),U(m),{track(r,f,d){try{oe(r,f,d)}catch (e18){}},page(r,f){try{r!==void 0&&(ee=r),oe("page_view",{landing:Re++===0},f)}catch (e19){}},clientId(r){try{return r!==void 0&&_chunkW3RGQYPDjs.c.call(void 0, r)!==i?null:P()?N(t,i):null}catch (e20){return null}},flush:()=>x(),setEnabled(r){H=!!r,H||(p=[],E=[],w())},configure(r){try{(r.env==="live"||r.env==="test")&&(j=r.env),typeof r.endpoint=="string"&&r.endpoint&&(s=c(r.endpoint))}catch (e21){}},onEvent(r){return C.add(r),()=>void C.delete(r)},destroy(){p=[],E=[],w(),C.clear(),t.removeEventListener("pagehide",ie),document.removeEventListener("visibilitychange",ae),t.removeEventListener("bitsnap:consent",S),t.removeEventListener("bitsnap:consent:ready",S)}}}var v,O=null;function D(e){if(!v){let t=Xe(e);return t===y||(v=t,O=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => ("")))),t}try{let t=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => ("")));t!==O&&e.debug&&console.warn("[bitsnap analytics]","tracker already started for another projectKey, ignoring",e.projectKey),t===O&&((e.env||e.endpoint)&&v.configure({env:e.env,endpoint:e.endpoint}),e.enabled!=null&&v.setEnabled(e.enabled))}catch (e22){}return v}function Ae(){return v}function xt(){typeof window<"u"&&ge(window),_optionalChain([v, 'optionalAccess', _36 => _36.destroy, 'call', _37 => _37()]),v=void 0,O=null}function _t(e){try{if(typeof window>"u")return{};let t=v,n=null;if(t)n=t.clientId(e);else{let o=e?_chunkW3RGQYPDjs.c.call(void 0, e):null;n=o?N(window,o):null}return n?{[me]:n}:{}}catch (e23){return{}}}var _react = require('react');var nt={track:y.track,page:y.page},Pe=_react.createContext.call(void 0, nt);function St({projectKey:e,env:t,enabled:n,endpoint:o,onEvent:a,autoPageViews:i,children:c}){let s=_react.useMemo.call(void 0, ()=>D({projectKey:e,env:t,endpoint:o,enabled:n}),[e,t,o]),u=_react.useRef.call(void 0, a);u.current=a,_chunkW3RGQYPDjs.q.call(void 0, ()=>{s.setEnabled(n!==!1)},[s,n]),_chunkW3RGQYPDjs.q.call(void 0, ()=>{if(!(i===!1||n===!1||s===y))return A(()=>s.page(null))},[s,i,n]),_chunkW3RGQYPDjs.q.call(void 0, ()=>s.onEvent(b=>_optionalChain([u, 'access', _38 => _38.current, 'optionalCall', _39 => _39(b)])),[s]);let l=_react.useMemo.call(void 0, ()=>({track:s.track.bind(s),page:s.page.bind(s)}),[s]);return _react.createElement.call(void 0, Pe.Provider,{value:l},c)}function we(){return _react.useContext.call(void 0, Pe)}var $={track(){}},X=null;function lt(e){let t=Symbol("bitsnap-instrument");function n(){if(typeof window>"u")return null;let{projectKey:i,analytics:c,provided:s}=e();return c===!1?null:s||(i?D({projectKey:i,source:"sdk_react",channel:"embed",env:typeof c=="object"?c.env:void 0}):null)}let o={track(i,c,s){try{let u=n();if(!u)return;let{analytics:l,pageType:b}=e(),M=b&&_optionalChain([s, 'optionalAccess', _40 => _40.page_type])===void 0?{...s,page_type:b}:s;X=typeof l=="object"&&l.onEvent?t:null,u.track(i,c,M)}catch (e24){}finally{X=null}}};function a(){try{if(!n())return()=>{};let i=Ae();if(!i)return()=>{};let c=e().provided?()=>{}:A(()=>i.page(_nullishCoalesce(e().pageType, () => (null)))),s=i.onEvent(u=>{if(X===t)try{let{analytics:l}=e();typeof l=="object"&&_optionalChain([l, 'access', _41 => _41.onEvent, 'optionalCall', _42 => _42(u)])}catch (e25){}});return()=>{c(),s()}}catch (e26){return()=>{}}}return{instrument:o,attach:a}}var Z=_react.createContext.call(void 0, null);function Nt({value:e,children:t}){return _react.createElement.call(void 0, Z.Provider,{value:e},t)}function Ot(){return _nullishCoalesce(_react.useContext.call(void 0, Z), () => ($))}function Dt(e,t,n){let o=_react.useContext.call(void 0, Z),a=we(),i=a.track===y.track?null:a,c=_react.useRef.call(void 0, {projectKey:e,analytics:t,pageType:n,provided:i});c.current={projectKey:e,analytics:t,pageType:n,provided:i};let s=_react.useMemo.call(void 0, ()=>lt(()=>c.current),[]),u=t===void 0&&o!==null,l=typeof t=="object"&&!!t.onEvent;return _react.useLayoutEffect.call(void 0, ()=>{if(!u)return s.attach()},[s,u,l,e]),u?o:s.instrument}var Q=$;function Se(e){Q=_nullishCoalesce(e, () => ($))}var q=0;function $t(){return q>0?$:Q}async function Mt(e){q++;try{return await e()}finally{q--}}function jt(e){_react.useEffect.call(void 0, ()=>(Se(e),()=>{Q===e&&Se(null)}),[e])}function Ht(e){let t=Number.isFinite(e)?Math.max(0,Math.min(100,e)):0;return t>=100?"100":t>=75?"75-99":t>=50?"50-74":t>=25?"25-49":"0-24"}function Wt(e,t){let n=[];for(let o of[25,50,75,100])e>=o&&!t.has(o)&&(t.add(o),n.push(o));return n}exports.a = ve; exports.b = A; exports.c = Ue; exports.d = Xe; exports.e = D; exports.f = Ae; exports.g = xt; exports.h = _t; exports.i = St; exports.j = we; exports.k = $; exports.l = Nt; exports.m = Ot; exports.n = Dt; exports.o = $t; exports.p = Mt; exports.q = jt; exports.r = Ht; exports.s = Wt;
2
+ //# sourceMappingURL=chunk-D2ASWUXM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/emems-chat-v1/dist/chunk-D2ASWUXM.js","../src/analytics/pageviews.ts","../src/version.ts","../src/analytics/random.ts","../src/analytics/visitor.ts"],"names":["REGISTRY","registry","win","holder","watchNavigation","onChange","check","name","original","args","result","startAutoPageViews","send","reg","starter","path","resetAutoPageViews","SDK_VERSION","randomBytes","n","bytes","c","i","VISITOR_HEADER","MAX_AGE_SECONDS","VISITOR_ID_RE","consentApi","readCookie","doc","part","index","isBitsnapHost","hostname","host","consentBelongsTo","projectKey","api","onBitsnap","analyticsGranted","newVisitorId","binary","byte","rawVisitorCookie","clientIdCookieName","readVisitorCookie","value","writeVisitorCookie","id","base"],"mappings":"AAAA,uuBAA2G,ICYrGA,EAAAA,CAAW,MAAA,CAAO,GAAA,CAAI,mBAAmB,CAAA,CAE/C,SAASC,EAAAA,CAASC,CAAAA,CAAuB,CACvC,IAAMC,CAAAA,CAASD,CAAAA,CACf,OAAQC,CAAAA,CAAOH,EAAQ,CAAA,GAAM,CAAE,IAAA,CAAM,IAAA,CAAM,QAAA,CAAU,IAAI,GAAA,CAAO,QAAA,CAAU,CAAA,CAAM,CAClF,CAGA,SAASI,EAAAA,CAAgBF,CAAAA,CAAaG,CAAAA,CAAsB,CAC1D,IAAMC,CAAAA,CAAQ,CAAA,CAAA,EAAM,CAClB,GAAI,CACFD,CAAAA,CAAS,CACX,CAAA,UAAQ,CAAC,CACX,CAAA,CACA,GAAA,CAAA,IAAWE,EAAAA,EAAQ,CAAC,WAAA,CAAa,cAAc,CAAA,CAAY,CACzD,IAAMC,CAAAA,CAAWN,CAAAA,CAAI,OAAA,CAAQK,CAAI,CAAA,CACjCL,CAAAA,CAAI,OAAA,CAAQK,CAAI,CAAA,CAAI,QAAA,CAAA,GAA4BE,CAAAA,CAAwC,CACtF,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,CAAE,OAAA,CAASuB,CAAAA,EAAUD,CAAAA,EAAU,MAAA,CAAO,YAAA,CAAaC,CAAI,CAAE,CAAA,CAChE,IAAA,CAAKD,CAAM,CAAA,CAAE,OAAA,CAAQ,KAAA,CAAO,GAAG,CAAA,CAAE,OAAA,CAAQ,KAAA,CAAO,GAAG,CAAA,CAAE,OAAA,CAAQ,KAAA,CAAO,EAAE,CAC/E,CAGA,SAASE,EAAAA,CAAiBd,CAAAA,CAAeO,CAAAA,CAAmC,CAC1E,GAAI,CACF,OAAOR,EAAAA,CAAWC,CAAAA,CAAKe,gCAAAA,CAA6B,CAAC,CACvD,CAAA,UAAQ,CACN,OAAO,IACT,CACF,CAGO,SAASC,CAAAA,CAAkBhB,CAAAA,CAAeO,CAAAA,CAAmC,CAClF,IAAMU,CAAAA,CAAQH,EAAAA,CAAiBd,CAAAA,CAAKO,CAAU,CAAA,CAC9C,OAAOU,CAAAA,GAAU,IAAA,EAAQpB,EAAAA,CAAc,IAAA,CAAKoB,CAAK,CAAA,CAAIA,CAAAA,CAAQ,IAC/D,CAOO,SAASC,EAAAA,CAAmB5C,CAAAA,CAAaiC,CAAAA,CAAoBY,CAAAA,CAAkB,CACpF,GAAI,CACF,IAAMnB,CAAAA,CAAM1B,CAAAA,CAAI,QAAA,CACV8C,CAAAA,CACJ,CAAA,EAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/emems-chat-v1/dist/chunk-D2ASWUXM.js","sourcesContent":[null,"/**\n * Page-wide state of the automatic page views. It lives on `window`, so the\n * npm package, a second copy of it and the `analytics.js` script agree on who\n * reports a path and the history is patched once.\n */\ntype Registry = {\n /** Last path some starter reported. */\n path: string | null;\n starters: Set<() => void>;\n watching: boolean;\n};\n\nconst REGISTRY = Symbol.for(\"bitsnap.pageViews\");\n\nfunction registry(win: Window): Registry {\n const holder = win as unknown as Record<symbol, Registry | undefined>;\n return (holder[REGISTRY] ??= { path: null, starters: new Set(), watching: false });\n}\n\n/** Calls `onChange` when the path changes through `history.pushState`/`replaceState` or Back/Forward. */\nfunction watchNavigation(win: Window, onChange: () => void) {\n const check = () => {\n try {\n onChange();\n } catch {}\n };\n for (const name of [\"pushState\", \"replaceState\"] as const) {\n const original = win.history[name];\n win.history[name] = function (this: History, ...args: Parameters<History[typeof name]>) {\n const result = original.apply(this, args);\n check();\n return result;\n };\n }\n win.addEventListener(\"popstate\", check);\n}\n\n/**\n * Calls `send` for the current path and again on every path change, unless\n * another starter on the page already reported that path: the page gets one\n * `page_view` per path change however many providers, components and embeds\n * start it. Returns the function that stops this starter.\n */\nexport function startAutoPageViews(send: () => void, win: Window = window): () => void {\n try {\n const reg = registry(win);\n const starter = () => send();\n if (!reg.watching) {\n reg.watching = true;\n watchNavigation(win, () => {\n const path = win.location.pathname;\n // Nobody listening: leave the path unreported so the next starter sends it.\n if (path === reg.path || reg.starters.size === 0) return;\n reg.path = path;\n reg.starters.values().next().value?.();\n });\n }\n reg.starters.add(starter);\n const path = win.location.pathname;\n if (path !== reg.path) {\n reg.path = path;\n starter();\n }\n return () => void reg.starters.delete(starter);\n } catch {\n return () => {};\n }\n}\n\n/** Forgets the reported path and the starters (tests, hot reload). The history patch stays. */\nexport function resetAutoPageViews(win: Window = window) {\n const reg = registry(win);\n reg.path = null;\n reg.starters.clear();\n}\n","// Generated by scripts/write-version.mjs from package.json. Do not edit.\nexport const SDK_VERSION = \"1.19.0\";\n","export function randomBytes(n: number): Uint8Array {\n const bytes = new Uint8Array(n);\n const c = typeof crypto !== \"undefined\" ? crypto : undefined;\n if (c && typeof c.getRandomValues === \"function\") c.getRandomValues(bytes);\n else for (let i = 0; i < n; i++) bytes[i] = Math.floor(Math.random() * 256);\n return bytes;\n}\n","import { domainCandidates } from \"../consent/core/cookie\";\nimport { clientIdCookieName } from \"./contract\";\nimport { randomBytes } from \"./random\";\n\n/** The part of `window.BitsnapConsent` (`bitsnap-react/consent`) the tracker reads. */\nexport type ConsentLike = {\n /** Absent on a consent script older than 1.9.0, which never counts as the project's banner. */\n scope?: \"global\" | \"project\";\n projectKey?: string | null;\n get(): { c: { analytics?: boolean } } | null;\n /** Also true for a refusal made on an older banner version, which `get()` no longer returns. */\n denied?(category: \"analytics\"): boolean;\n ready?: Promise<unknown>;\n};\n\n/** Sent to the Bitsnap server on the requests that create a checkout or payment link. */\nexport const VISITOR_HEADER = \"X-Bitsnap-Visitor\";\n// 390 days, under the 13 months CNIL allows. Set once, never extended.\nconst MAX_AGE_SECONDS = 390 * 24 * 60 * 60;\nconst VISITOR_ID_RE = /^[A-Za-z0-9_-]{22}$/;\n\nexport function consentApi(win: Window): ConsentLike | undefined {\n return (win as unknown as { BitsnapConsent?: ConsentLike }).BitsnapConsent;\n}\n\nfunction readCookie(doc: Document, name: string): string | null {\n for (const part of doc.cookie.split(\";\")) {\n const index = part.indexOf(\"=\");\n if (index !== -1 && part.slice(0, index).trim() === name) return part.slice(index + 1).trim();\n }\n return null;\n}\n\n/** bitsnap.pl and its subdomains: many merchants share them, and the site-wide choice is bitsnap's own. */\nfunction isBitsnapHost(hostname: string): boolean {\n const host = hostname.toLowerCase();\n return host === \"bitsnap.pl\" || host.endsWith(\".bitsnap.pl\");\n}\n\n/**\n * Whether the page's consent banner speaks for `projectKey`: a project-scope banner of that\n * key, or a site-scope banner on a merchant's own site. On bitsnap.pl a site-scope choice is\n * bitsnap's own, so only a project-scope one counts.\n */\nexport function consentBelongsTo(win: Window, projectKey: string): boolean {\n try {\n const api = consentApi(win);\n if (!api) return false;\n if (api.scope === \"project\") return api.projectKey === projectKey;\n const onBitsnap = isBitsnapHost(win.location.hostname);\n if (api.scope === \"global\") return !onBitsnap;\n // A consent script from before the scope info: it cannot be told apart from another project's banner.\n return false;\n } catch {\n return false;\n }\n}\n\n/** `true` only while a banner that speaks for `projectKey` holds a valid choice that grants `analytics`. */\nexport function analyticsGranted(win: Window, projectKey: string): boolean {\n try {\n return consentApi(win)?.get()?.c.analytics === true && consentBelongsTo(win, projectKey);\n } catch {\n return false;\n }\n}\n\n/** 16 random bytes as 22 base64url characters. */\nexport function newVisitorId(): string {\n let binary = \"\";\n randomBytes(16).forEach((byte) => (binary += String.fromCharCode(byte)));\n return btoa(binary).replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/, \"\");\n}\n\n/** Value of the `bs_vid_<projectKey>` cookie, whatever it holds; `null` when it is absent. */\nfunction rawVisitorCookie(doc: Document, projectKey: string): string | null {\n try {\n return readCookie(doc, clientIdCookieName(projectKey));\n } catch {\n return null;\n }\n}\n\n/** The project's client id from its first-party cookie (`bs_vid_<projectKey>`), or `null` if absent or malformed. */\nexport function readVisitorCookie(doc: Document, projectKey: string): string | null {\n const value = rawVisitorCookie(doc, projectKey);\n return value !== null && VISITOR_ID_RE.test(value) ? value : null;\n}\n\n/**\n * Sets the cookie on the widest registrable domain the browser accepts\n * (shortest suffix with two labels first, so `shop.example.co.uk` skips the\n * refused `co.uk`), host-only where no domain sticks (localhost, IP hosts).\n */\nexport function writeVisitorCookie(win: Window, projectKey: string, id: string): void {\n try {\n const doc = win.document;\n const base =\n `${clientIdCookieName(projectKey)}=${id}; Max-Age=${MAX_AGE_SECONDS}; Path=/; SameSite=Lax` +\n (win.location.protocol === \"https:\" ? \"; Secure\" : \"\");\n for (const domain of domainCandidates(win.location.hostname).reverse()) {\n doc.cookie = `${base}; Domain=${domain}`;\n if (readVisitorCookie(doc, projectKey) === id) return;\n }\n doc.cookie = base;\n } catch {\n // cookies blocked (sandboxed frame)\n }\n}\n\n/** Expires the cookie on the host and on every parent domain it may have been set on. */\nexport function deleteVisitorCookie(win: Window, projectKey: string): void {\n try {\n const doc = win.document;\n // Present under any value: a malformed one must go too.\n if (rawVisitorCookie(doc, projectKey) === null) return;\n const base =\n `${clientIdCookieName(projectKey)}=; Max-Age=0; Path=/; SameSite=Lax` +\n (win.location.protocol === \"https:\" ? \"; Secure\" : \"\");\n doc.cookie = base;\n for (const domain of domainCandidates(win.location.hostname)) doc.cookie = `${base}; Domain=${domain}`;\n } catch {\n // best effort\n }\n}\n\n/**\n * The project's client id to send, or `null`: analytics consent is granted,\n * Global Privacy Control is off, the browser is not automated and the cookie exists.\n */\nexport function readVisitorId(win: Window, projectKey: string): string | null {\n try {\n const nav = win.navigator as { globalPrivacyControl?: boolean; webdriver?: boolean } | undefined;\n if (nav?.globalPrivacyControl === true || nav?.webdriver === true) return null;\n return analyticsGranted(win, projectKey) ? readVisitorCookie(win.document, projectKey) : null;\n } catch {\n return null;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import{a as U}from"./chunk-EMR4YXNY.mjs";import{a as ot,b as nt}from"./chunk-KOVKUJAW.mjs";import{a as O,b as at,c as it,d as st,e as dt}from"./chunk-OR566YJI.mjs";import{a as M}from"./chunk-5R6AGO3Z.mjs";import{e as rt}from"./chunk-N523LFAM.mjs";import{f as X,l as Z,m as J,n as Y,p as Q}from"./chunk-SSSF64M7.mjs";import{b as tt,d as et}from"./chunk-OFPRIENJ.mjs";var ht=["root","grid","card","cardLink","image","imagePlaceholder","body","name","description","price","comparePrice","badge","model3dBadge","actions","addToCartButton","selectButton","message","pagination","paginationButton","pageIndicator","emptyState","error","retryButton","skeleton"],xt={fontFamily:"--bitsnap-products-font-family",gridMinWidth:"--bitsnap-products-grid-min-width",fontSize:"--bitsnap-products-font-size",background:"--bitsnap-products-background",surface:"--bitsnap-products-surface",foreground:"--bitsnap-products-foreground",mutedForeground:"--bitsnap-products-muted-foreground",border:"--bitsnap-products-border",buttonBackground:"--bitsnap-products-button-background",buttonForeground:"--bitsnap-products-button-foreground",buttonHoverBackground:"--bitsnap-products-button-hover-background",hoverSurface:"--bitsnap-products-hover-surface",focusRing:"--bitsnap-products-focus-ring",error:"--bitsnap-products-error",badgeBackground:"--bitsnap-products-badge-background",badgeForeground:"--bitsnap-products-badge-foreground",radius:"--bitsnap-products-radius"},Tt={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",radius:"8px",gridMinWidth:"9rem"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",radius:"8px",gridMinWidth:"9rem"}},Ct=[];function ct(t){let e=ot(t,{defaultTheme:"light",presets:Tt,variables:xt,shadcnVariables:Ct});return{theme:e.theme,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle}}function j(t,e){return nt(t.elements,e)}import{useCallback as ut,useEffect as St,useMemo as kt,useState as F}from"react";function q(t){let{projectID:e,locale:n,search:o,initialData:i}=t,[a]=F(()=>rt),d=t.host??a,c=O(t.pageSize),s=JSON.stringify([e,d,n??null,o?.trim()??null,c]),[g,l]=F({queryKey:s,page:1});g.queryKey!==s&&l({queryKey:s,page:1});let[P,C]=F(0),[m,p]=F(()=>({requestKey:i!=null?`${s}|1|0`:"",data:i,error:void 0})),f=m.data?.totalCount??0,b=at(f,c),h=g.queryKey===s?g.page:1,k=f>0?Math.min(h,b):h,S=`${s}|${k}|${P}`,T=m.requestKey===S;St(()=>{if(T)return;let y=new AbortController;return it({projectID:e,host:d,locale:n,search:o,limit:c,offset:(k-1)*c},y.signal).then(L=>{y.signal.aborted||p({requestKey:S,data:L,error:void 0})},L=>{y.signal.aborted||p(E=>({requestKey:S,data:E.data,error:L instanceof Error?L:new Error(String(L))}))}),()=>y.abort()},[S,T]);let I=ut(y=>{let L=Math.max(1,Math.floor(y));l({queryKey:s,page:f>0?Math.min(L,b):L})},[s,f,b]),A=ut(()=>C(y=>y+1),[]);return kt(()=>({products:m.data?.items??[],totalCount:f,page:k,pageCount:b,setPage:I,isLoading:!T,error:T?m.error:void 0,refetch:A}),[m,f,k,b,I,T,A])}import{createContext as gt,useCallback as K,useContext as mt,useEffect as B,useMemo as R,useRef as H,useState as It}from"react";var z=50,At=1e3;function lt(t,e=At){let n=new Set,o=new Map,i=[],a=[],d,c,s=!1;function g(){for(c!==void 0&&clearTimeout(c),c=void 0;i.length>0;){let p=i.slice(0,z),f=a.slice(0,z);i=i.slice(z),a=a.slice(z);try{t({productIds:p,positions:f})}catch{}}}function l(){g();try{X()?.flush()}catch{}}let P=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&l()};function C(){s||typeof window>"u"||(s=!0,window.addEventListener("pagehide",l,!0),document.addEventListener("visibilitychange",P,!0))}function m(){if(d)return d;if(!(typeof IntersectionObserver>"u"))return d=new IntersectionObserver(p=>{for(let f of p){let b=o.get(f.target);!b||!f.isIntersecting||f.intersectionRatio<.5||(o.delete(f.target),d?.unobserve(f.target),!n.has(b.id)&&(n.add(b.id),i.push(b.id),a.push(b.position)))}i.length>0&&c===void 0&&(c=setTimeout(g,e),c.unref?.())},{threshold:[.5]}),C(),d}return{observe(p,f,b){try{if(n.has(f))return()=>{};let h=m();return h?(o.set(p,{id:f,position:b}),h.observe(p),()=>{o.delete(p),h.unobserve(p)}):()=>{}}catch{return()=>{}}},flush:g,destroy(){try{g(),d?.disconnect(),s&&(window.removeEventListener("pagehide",l,!0),document.removeEventListener("visibilitychange",P,!0),s=!1)}catch{}d=void 0,o.clear()}}}var wt={en:{addToCart:"Add to cart",addingToCart:"Adding\u2026",addedToCart:"Added to cart",addToCartError:"Could not add to the cart. Try again.",chooseOptions:"Choose",viewProduct:"View",unavailable:"Unavailable",subscription:"Subscription",model3d:"3D",model3dLabel:"3D model",priceFrom:"from {price}",originalPrice:"Original price",loading:"Loading products",empty:"There are no products to show.",error:"Could not load the products.",retry:"Try again",pagination:"Pagination",previousPage:"Previous",nextPage:"Next",pageOf:"Page {page} of {pageCount}"},pl:{addToCart:"Dodaj do koszyka",addingToCart:"Dodawanie\u2026",addedToCart:"Dodano do koszyka",addToCartError:"Nie uda\u0142o si\u0119 doda\u0107 do koszyka. Spr\xF3buj ponownie.",chooseOptions:"Wybierz",viewProduct:"Zobacz",unavailable:"Niedost\u0119pny",subscription:"Subskrypcja",model3d:"3D",model3dLabel:"Model 3D",priceFrom:"od {price}",originalPrice:"Cena przed obni\u017Ck\u0105",loading:"\u0141adowanie produkt\xF3w",empty:"Brak produkt\xF3w do wy\u015Bwietlenia.",error:"Nie uda\u0142o si\u0119 za\u0142adowa\u0107 produkt\xF3w.",retry:"Spr\xF3buj ponownie",pagination:"Paginacja",previousPage:"Poprzednia",nextPage:"Nast\u0119pna",pageOf:"Strona {page} z {pageCount}"}};function pt(t,e){return tt(wt,t,e)}function V(t,e){return t.replace(/\{(\w+)\}/g,(n,o)=>o in e?String(e[o]):n)}import{Fragment as Lt,jsx as r,jsxs as x}from"react/jsx-runtime";var ft=gt(void 0),Et={observe:()=>()=>{},clicked:()=>{}},bt=gt(Et);function D(){let t=mt(ft);if(t==null)throw new Error("ProductList parts must be rendered inside ProductList");return t}function u(t,e){let{appearance:n}=D(),o=j(n,t);return{"data-bitsnap-products-slot":t,className:M(e,o?.className),style:o?.style}}var $="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",Pt=`${$} w-full`,_t=`${Pt} no-underline`;function Nt({product:t,onAdd:e}){let{texts:n}=D(),[o,i]=It("idle"),a=u("addToCartButton",Pt),d=u("message","mt-2 text-xs");B(()=>{if(o!=="added")return;let g=setTimeout(()=>i("idle"),2e3);return()=>clearTimeout(g)},[o]);let c=K(async()=>{i("adding");try{await e(),i("added")}catch(g){console.error("bitsnap-react: could not add to the cart",g),i("error")}},[e]),s=o==="adding"?n.addingToCart:o==="added"?n.addedToCart:n.addToCart;return x(Lt,{children:[r("button",{type:"button",...a,disabled:o==="adding","aria-label":`${s}: ${t.name}`,onClick:c,children:s}),o==="error"?r("p",{...d,role:"alert",children:n.addToCartError}):null]})}function Ot({product:t,position:e,href:n,onAdd:o,renderItem:i}){let{texts:a,locale:d}=D(),c=mt(bt),s=H(null);B(()=>{if(s.current!=null)return c.observe(s.current,t.id,e)},[c,t.id,e]);let g=K(()=>c.clicked(t,e),[c,t,e]),l=u("card","relative flex flex-col overflow-hidden border transition-colors"),P=u("cardLink","flex flex-1 flex-col no-underline"),C=u("image","aspect-square w-full overflow-hidden"),m=u("imagePlaceholder","aspect-square w-full"),p=u("body","flex flex-1 flex-col gap-1 p-4"),f=u("name","text-base font-medium leading-snug"),b=u("description","line-clamp-2 text-sm"),h=u("price","mt-auto pt-2 text-base font-semibold"),k=u("comparePrice","ml-2 text-sm font-normal"),S=u("badge","absolute left-3 top-3 px-2 py-0.5 text-xs font-medium"),T=u("model3dBadge","absolute right-3 top-3 inline-flex items-center gap-1 px-2 py-0.5 text-xs font-semibold"),I=u("actions","p-4 pt-0"),A=u("selectButton",_t),y=U(t.price,t.currency,d),L=t.compareAtPrice!=null&&t.compareAtPrice>t.price?U(t.compareAtPrice,t.currency,d):null;if(i!=null)return r("li",{ref:s,...l,"data-unavailable":t.available?void 0:"",children:i(t,{href:n,price:y,compareAtPrice:L,texts:a,locale:d,addToCart:o,trackClick:g})});let E=t.image?.thumbnailUrl??t.image?.url,_=t.available?t.isRecurring?a.subscription:null:a.unavailable;return x("li",{ref:s,...l,"data-unavailable":t.available?void 0:"",children:[x("a",{...P,href:n,onClick:g,children:[E!=null?r("div",{...C,children:r("img",{src:E,alt:"",loading:"lazy",decoding:"async",className:"h-full w-full object-cover"})}):r("div",{...m,"aria-hidden":"true"}),x("div",{...p,children:[r("h3",{...f,children:t.name}),t.shortDescription?r("p",{...b,children:t.shortDescription}):null,x("p",{...h,children:[t.priceFrom?V(a.priceFrom,{price:y}):y,L!=null?x(Lt,{children:[x("span",{className:"sr-only",children:[a.originalPrice,": "]}),r("del",{...k,children:L})]}):null]})]})]}),_!=null?r("span",{...S,"data-kind":t.available?"subscription":"unavailable",children:_}):null,t.has3d===!0?x("span",{...T,title:a.model3dLabel,children:[r(Bt,{}),r("span",{"aria-hidden":"true",children:a.model3d}),r("span",{className:"sr-only",children:a.model3dLabel})]}):null,r("div",{...I,children:t.available?t.addToCart?r(Nt,{product:t,onAdd:o}):r("a",{...A,href:n,onClick:g,children:t.variantCount>1?a.chooseOptions:a.viewProduct}):r("button",{type:"button",...A,disabled:!0,children:a.unavailable})})]})}function Bt(){return x("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),r("path",{d:"m3.3 7 8.7 5 8.7-5"}),r("path",{d:"M12 22V12"})]})}var yt="m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,var(--bitsnap-products-grid-min-width,9rem)),1fr))] gap-5 p-0";function Rt({count:t,label:e}){let n=u("grid",yt),o=u("skeleton","aspect-[3/4] animate-pulse");return r("div",{...n,role:"status","aria-busy":"true","aria-label":e,children:Array.from({length:t},(i,a)=>r("div",{...o,"aria-hidden":"true"},a))})}function Dt({page:t,pageCount:e,isLoading:n,onPage:o}){let{texts:i}=D(),a=u("pagination","mt-8 flex items-center justify-center gap-4"),d=u("paginationButton",$),c=u("pageIndicator","text-sm");return x("nav",{...a,"aria-label":i.pagination,children:[r("button",{type:"button",...d,"aria-disabled":n||t<=1,onClick:()=>{!n&&t>1&&o(t-1)},children:i.previousPage}),r("span",{...c,"aria-live":"polite",children:V(i.pageOf,{page:t,pageCount:e})}),r("button",{type:"button",...d,"aria-disabled":n||t>=e,onClick:()=>{!n&&t<e&&o(t+1)},children:i.nextPage})]})}function Mt({options:t,productHref:e,renderItem:n,onAddToCart:o,showCartOnAdd:i}){let{texts:a}=D(),{products:d,page:c,pageCount:s,setPage:g,isLoading:l,error:P,refetch:C}=q(t),m=J(),p=t.search?.trim()?"search":"catalog",f=O(t.pageSize),b=H(!1);B(()=>{b.current||l||P!=null||(b.current=!0,m.track("product_list_viewed",{list_id:p,item_count:d.length}))},[m,l,P,p,d.length]);let h=R(()=>lt(({productIds:v,positions:w})=>m.track("product_impression",{list_id:p,product_ids:v,positions:w})),[m,p]);B(()=>()=>h.destroy(),[h]);let k=R(()=>({observe:h.observe,clicked:(v,w)=>m.track("product_clicked",{list_id:p,position:w},{product_id:v.id})}),[h,m,p]),S=H(null),T=H(!1),I=K(v=>{T.current=!0,g(v)},[g]);B(()=>{l||!T.current||(T.current=!1,S.current?.focus({preventScroll:!0}),S.current?.scrollIntoView({block:"start"}))},[l]);let A=u("grid",yt),y=u("emptyState","py-12 text-center text-sm"),L=u("error","flex flex-col items-center gap-3 py-12 text-center text-sm"),E=u("retryButton",$),{projectID:_,host:W}=t,vt=K((v,w)=>async()=>{if(o!=null){await Q(()=>o(v)),st(m,v);return}await dt(v,{projectID:_,host:W,showCart:i,analytics:m,url:w})},[o,_,W,i,m]),N;return l&&d.length===0?N=r(Rt,{count:Math.min(O(t.pageSize),8),label:a.loading}):P!=null?N=x("div",{...L,role:"alert",children:[r("p",{children:a.error}),r("button",{type:"button",...E,onClick:C,children:a.retry})]}):d.length===0?N=r("p",{...y,children:a.empty}):N=r("ul",{...A,"aria-busy":l||void 0,className:M(A.className,l&&"opacity-60"),children:d.map((v,w)=>{let G=e(v);return r(Ot,{product:v,position:(c-1)*f+w,href:G,onAdd:vt(v,G),renderItem:n},v.id)})}),r(bt.Provider,{value:k,children:x("div",{ref:S,tabIndex:-1,className:"p-1 outline-none scroll-mt-4",children:[N,s>1&&P==null?r(Dt,{page:c,pageCount:s,isLoading:l,onPage:I}):null]})})}var Ut=t=>`/p/${encodeURIComponent(t.uniqueSlug)}`;function Ft({productHref:t=Ut,appearance:e,texts:n,renderItem:o,onAddToCart:i,showCartOnAdd:a=!0,className:d,analytics:c,...s}){let g=Y(s.projectID,c,"catalog"),l=s.locale??et,P=R(()=>ct(e),[e]),C=R(()=>pt(l,n),[l,n]),m=R(()=>({appearance:P,texts:C,locale:l}),[P,C,l]),p=j(P,"root");return r(Z,{value:g,children:r(ft.Provider,{value:m,children:r("div",{"data-bitsnap-products":"root","data-bitsnap-products-slot":"root",className:M("bitsnap-react",P.boundaryClassName,d,p?.className),style:{...P.boundaryStyle,...p?.style},children:r(Mt,{options:s,productHref:t,renderItem:o,onAddToCart:i,showCartOnAdd:a})})})})}export{ht as a,q as b,Ft as c};
2
+ //# sourceMappingURL=chunk-DDIEFKNP.mjs.map