bitsnap-react 1.19.0 → 1.21.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 (137) hide show
  1. package/dist/BitsnapCart-73ESTTTH.mjs +2 -0
  2. package/dist/BitsnapCart-TWT7LVGJ.js +2 -0
  3. package/dist/BitsnapCart-TWT7LVGJ.js.map +1 -0
  4. package/dist/CartProvider-4WXJPQJB.mjs +2 -0
  5. package/dist/CartProvider-CPF2E7JA.js +2 -0
  6. package/dist/CartProvider-CPF2E7JA.js.map +1 -0
  7. package/dist/PanelModelFiles-EKQRLF46.js.map +1 -1
  8. package/dist/analytics.js +1 -1
  9. package/dist/analytics.js.map +1 -1
  10. package/dist/analytics.mjs +1 -1
  11. package/dist/catalog.js +1 -1
  12. package/dist/catalog.js.map +1 -1
  13. package/dist/catalog.mjs +1 -1
  14. package/dist/chat.d.mts +10 -9
  15. package/dist/chat.d.ts +10 -9
  16. package/dist/chat.js +1 -1
  17. package/dist/chat.js.map +1 -1
  18. package/dist/chat.mjs +1 -1
  19. package/dist/chat.mjs.map +1 -1
  20. package/dist/{chunk-5M6M7FAR.mjs → chunk-27JN2GIQ.mjs} +2 -2
  21. package/dist/{chunk-WG54EHST.mjs → chunk-2G46TAUX.mjs} +2 -2
  22. package/dist/chunk-2G46TAUX.mjs.map +1 -0
  23. package/dist/{chunk-MMLBQHBM.mjs → chunk-6ALA5M44.mjs} +2 -2
  24. package/dist/{chunk-DOJICJCQ.js → chunk-6DEKVABT.js} +2 -2
  25. package/dist/chunk-6DEKVABT.js.map +1 -0
  26. package/dist/chunk-6Q3VGPSF.js.map +1 -1
  27. package/dist/{chunk-GJOGATP6.js → chunk-E5MMKBC4.js} +2 -2
  28. package/dist/chunk-E5MMKBC4.js.map +1 -0
  29. package/dist/{chunk-LGPNJ5XE.js → chunk-EFN4OW2C.js} +2 -2
  30. package/dist/chunk-EFN4OW2C.js.map +1 -0
  31. package/dist/{chunk-D2ASWUXM.js → chunk-EK3D44XW.js} +2 -2
  32. package/dist/chunk-EK3D44XW.js.map +1 -0
  33. package/dist/{chunk-N523LFAM.mjs → chunk-EXC5Z5VM.mjs} +2 -2
  34. package/dist/{chunk-YV2C276H.js → chunk-EZGL6DPG.js} +2 -2
  35. package/dist/chunk-EZGL6DPG.js.map +1 -0
  36. package/dist/chunk-FORZ5AH4.js +2 -0
  37. package/dist/chunk-FORZ5AH4.js.map +1 -0
  38. package/dist/chunk-HKRH6FI6.mjs +2 -0
  39. package/dist/chunk-HKRH6FI6.mjs.map +1 -0
  40. package/dist/{chunk-OR566YJI.mjs → chunk-HLULQA3B.mjs} +2 -2
  41. package/dist/chunk-HLULQA3B.mjs.map +1 -0
  42. package/dist/{chunk-2FD2QP4Y.js → chunk-I2RHVELR.js} +2 -2
  43. package/dist/chunk-I2RHVELR.js.map +1 -0
  44. package/dist/{chunk-GQ5OKU74.js → chunk-IKKMSLKC.js} +2 -2
  45. package/dist/chunk-IKKMSLKC.js.map +1 -0
  46. package/dist/{chunk-SSSF64M7.mjs → chunk-J6WKSO33.mjs} +2 -2
  47. package/dist/{chunk-SSSF64M7.mjs.map → chunk-J6WKSO33.mjs.map} +1 -1
  48. package/dist/chunk-JSDGZ4NY.js.map +1 -1
  49. package/dist/chunk-KO7Z3E23.mjs +2 -0
  50. package/dist/chunk-KO7Z3E23.mjs.map +1 -0
  51. package/dist/chunk-KOYBZORL.js.map +1 -1
  52. package/dist/chunk-KYSMT6ZK.js +2 -0
  53. package/dist/chunk-KYSMT6ZK.js.map +1 -0
  54. package/dist/{chunk-5JRUPLXY.mjs → chunk-LRUBBPTV.mjs} +2 -2
  55. package/dist/chunk-MDAFPGPA.js.map +1 -1
  56. package/dist/chunk-Q337IQNA.js.map +1 -1
  57. package/dist/chunk-T5JO4SP7.mjs +5 -0
  58. package/dist/chunk-T5JO4SP7.mjs.map +1 -0
  59. package/dist/{chunk-MWWEPEU2.js → chunk-TM3E3L57.js} +2 -2
  60. package/dist/chunk-TM3E3L57.js.map +1 -0
  61. package/dist/{chunk-SCEWYZUZ.mjs → chunk-TMEII7BM.mjs} +2 -2
  62. package/dist/chunk-W3RGQYPD.js.map +1 -1
  63. package/dist/{chunk-DDIEFKNP.mjs → chunk-WOA6W5RM.mjs} +2 -2
  64. package/dist/chunk-XMRGA5AN.js +5 -0
  65. package/dist/chunk-XMRGA5AN.js.map +1 -0
  66. package/dist/chunk-Z3YOJ6NZ.js +2 -0
  67. package/dist/chunk-Z3YOJ6NZ.js.map +1 -0
  68. package/dist/consent.js.map +1 -1
  69. package/dist/course.d.mts +1 -1
  70. package/dist/course.d.ts +1 -1
  71. package/dist/course.js +1 -1
  72. package/dist/course.js.map +1 -1
  73. package/dist/course.mjs +1 -1
  74. package/dist/embed/analytics.js +1 -1
  75. package/dist/errors.js.map +1 -1
  76. package/dist/index.css +1 -1
  77. package/dist/index.css.map +1 -1
  78. package/dist/index.d.mts +37 -34
  79. package/dist/index.d.ts +37 -34
  80. package/dist/index.js +1 -1
  81. package/dist/index.js.map +1 -1
  82. package/dist/index.mjs +1 -1
  83. package/dist/index.mjs.map +1 -1
  84. package/dist/internal.js.map +1 -1
  85. package/dist/methods-43RQLLWD.mjs +2 -0
  86. package/dist/methods-SZVF3HMF.js +2 -0
  87. package/dist/methods-SZVF3HMF.js.map +1 -0
  88. package/dist/model-files-client-P4PORZJ6.js.map +1 -1
  89. package/dist/models.js.map +1 -1
  90. package/dist/returns.js +1 -1
  91. package/dist/returns.js.map +1 -1
  92. package/dist/returns.mjs +1 -1
  93. package/dist/{types-B-sjyZQs.d.mts → types-CjWyHunk.d.mts} +2 -0
  94. package/dist/{types-iRe6ix2y.d.ts → types-DfqzDP9k.d.ts} +2 -0
  95. package/dist/viewer3d.js.map +1 -1
  96. package/dist/viewer3d.mjs +2 -2
  97. package/dist/{widgets-BVOSj9fU.d.ts → widgets-BL6pCMdc.d.ts} +44 -3
  98. package/dist/{widgets-BT2LN2Nq.d.mts → widgets-DmHlIbp8.d.mts} +44 -3
  99. package/package.json +2 -2
  100. package/dist/BitsnapCart-E72W5RRZ.mjs +0 -2
  101. package/dist/BitsnapCart-Q2HER6GU.js +0 -2
  102. package/dist/BitsnapCart-Q2HER6GU.js.map +0 -1
  103. package/dist/CartProvider-677CE2FI.js +0 -2
  104. package/dist/CartProvider-677CE2FI.js.map +0 -1
  105. package/dist/CartProvider-YPDOFSYC.mjs +0 -2
  106. package/dist/chunk-2FD2QP4Y.js.map +0 -1
  107. package/dist/chunk-AAC576BC.mjs +0 -5
  108. package/dist/chunk-AAC576BC.mjs.map +0 -1
  109. package/dist/chunk-AB37DWOK.mjs +0 -2
  110. package/dist/chunk-AB37DWOK.mjs.map +0 -1
  111. package/dist/chunk-BUYTK7KM.js +0 -2
  112. package/dist/chunk-BUYTK7KM.js.map +0 -1
  113. package/dist/chunk-D2ASWUXM.js.map +0 -1
  114. package/dist/chunk-DOJICJCQ.js.map +0 -1
  115. package/dist/chunk-GJOGATP6.js.map +0 -1
  116. package/dist/chunk-GQ5OKU74.js.map +0 -1
  117. package/dist/chunk-KHQEDQYF.js +0 -5
  118. package/dist/chunk-KHQEDQYF.js.map +0 -1
  119. package/dist/chunk-LGPNJ5XE.js.map +0 -1
  120. package/dist/chunk-MWWEPEU2.js.map +0 -1
  121. package/dist/chunk-NWXZ45TV.js +0 -2
  122. package/dist/chunk-NWXZ45TV.js.map +0 -1
  123. package/dist/chunk-OR566YJI.mjs.map +0 -1
  124. package/dist/chunk-WG54EHST.mjs.map +0 -1
  125. package/dist/chunk-YV2C276H.js.map +0 -1
  126. package/dist/methods-64D5DD6K.js +0 -2
  127. package/dist/methods-64D5DD6K.js.map +0 -1
  128. package/dist/methods-NQA3DFLE.mjs +0 -2
  129. /package/dist/{BitsnapCart-E72W5RRZ.mjs.map → BitsnapCart-73ESTTTH.mjs.map} +0 -0
  130. /package/dist/{CartProvider-YPDOFSYC.mjs.map → CartProvider-4WXJPQJB.mjs.map} +0 -0
  131. /package/dist/{chunk-5M6M7FAR.mjs.map → chunk-27JN2GIQ.mjs.map} +0 -0
  132. /package/dist/{chunk-MMLBQHBM.mjs.map → chunk-6ALA5M44.mjs.map} +0 -0
  133. /package/dist/{chunk-N523LFAM.mjs.map → chunk-EXC5Z5VM.mjs.map} +0 -0
  134. /package/dist/{chunk-5JRUPLXY.mjs.map → chunk-LRUBBPTV.mjs.map} +0 -0
  135. /package/dist/{chunk-SCEWYZUZ.mjs.map → chunk-TMEII7BM.mjs.map} +0 -0
  136. /package/dist/{chunk-DDIEFKNP.mjs.map → chunk-WOA6W5RM.mjs.map} +0 -0
  137. /package/dist/{methods-NQA3DFLE.mjs.map → methods-43RQLLWD.mjs.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/appearance-core.ts"],"names":["omitUndefined","tokens","result","key","value","hasAnyElement","elements","element","resolveBoundaryStyle","variables","shadcnVariables","style","token","variable","resolveAppearanceCore","appearance","config","theme","getSlotAppearance","slot"],"mappings":"AA8DO,0rBAASA,CAAAA,CACdC,CAAAA,CACgC,CAChC,IAAMC,CAAAA,CAAkC,CAAC,CAAA,CAEzC,GAAA,CAAA,GAAW,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQH,CAAM,CAAA,CAC1CG,CAAAA,EAAS,IAAA,EAAA,CACXF,CAAAA,CAAOC,CAAG,CAAA,CAAIC,CAAAA,CAAAA,CAIlB,OAAOF,CACT,CAEO,SAASG,CAAAA,CACdC,CAAAA,CACS,CACT,OAAO,MAAA,CAAO,MAAA,CAAmCA,CAAQ,CAAA,CAAE,IAAA,CACxDC,CAAAA,EACCA,CAAAA,EAAW,IAAA,EAAA,CAASA,CAAAA,CAAQ,SAAA,EAAa,IAAA,EAAQA,CAAAA,CAAQ,KAAA,EAAS,IAAA,CACtE,CACF,CAMO,SAASC,CAAAA,CACdP,CAAAA,CACAQ,CAAAA,CACAC,CAAAA,CACe,CACf,IAAMC,CAAAA,CAAgC,CAAC,CAAA,CAEvC,GAAA,CAAA,GAAW,CAACC,CAAAA,CAAOC,CAAQ,CAAA,GAAK,MAAA,CAAO,OAAA,CAAgBJ,CAAS,CAAA,CAAG,CACjE,IAAML,CAAAA,CAAQH,CAAAA,CAAOW,CAAc,CAAA,CAC/BR,CAAAA,EAAS,IAAA,EAAA,CACXO,CAAAA,CAAME,CAAQ,CAAA,CAAIT,CAAAA,CAEtB,CAEA,GAAA,CAAA,GAAW,CAAE,KAAA,CAAAQ,CAAAA,CAAO,QAAA,CAAAC,CAAS,CAAA,GAAKH,CAAAA,CAAiB,CACjD,IAAMN,CAAAA,CAAQH,CAAAA,CAAOW,CAAK,CAAA,CACtBR,CAAAA,EAAS,IAAA,EAAA,CACXO,CAAAA,CAAME,CAAQ,CAAA,CAAIT,CAAAA,CAEtB,CAEA,OAAOO,CACT,CAOO,SAASG,CAAAA,CAKdC,CAAAA,CAOAC,CAAAA,CAC4C,CAC5C,IAAMC,CAAAA,kCAAeF,CAAAA,2BAAY,OAAA,SAASC,CAAAA,CAAO,cAAA,CAE3Cf,CAAAA,CAASD,CAAAA,CAAqB,CAClC,GAAGgB,CAAAA,CAAO,OAAA,CAAQC,CAAK,CAAA,CACvB,mBAAGF,CAAAA,6BAAY,QACjB,CAAC,CAAA,CAEKT,CAAAA,kCAAWS,CAAAA,6BAAY,UAAA,SAAY,CAAC,GAAA,CAE1C,MAAO,CACL,KAAA,CAAAE,CAAAA,CACA,YAAA,iBACEF,CAAAA,6BAAY,OAAA,EAAS,IAAA,EACrB,MAAA,CAAO,IAAA,CAAKd,CAAM,CAAA,CAAE,MAAA,CAAS,CAAA,EAC7BI,CAAAA,CAAcC,CAAQ,CAAA,CACxB,MAAA,CAAAL,CAAAA,CACA,QAAA,CAAAK,CAAAA,CACA,aAAA,CAAeE,CAAAA,CACbP,CAAAA,CACAe,CAAAA,CAAO,SAAA,CACPA,CAAAA,CAAO,eACT,CACF,CACF,CAGO,SAASE,CAAAA,CACdZ,CAAAA,CACAa,CAAAA,CAC4B,CAC5B,OAAOb,CAAAA,CAASa,CAAI,CACtB,CAAA,6BAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/emems-chat-v1/dist/chunk-KOYBZORL.js","sourcesContent":["import type { CSSProperties } from \"react\";\n\n/**\n * Generic building blocks shared by the appearance modules (checkout, and\n * later returns). Each module supplies its own token to CSS variable map, theme\n * presets and shadcn mapping, and keeps its own public types. Everything here\n * is pure so it can be tested without a DOM.\n */\n\n/** Caller overrides for a single slot. */\nexport type SlotAppearance = {\n /** Merged after the built-in classes with `cn`, so Tailwind conflicts resolve. */\n className?: string;\n /** Merged after the built-in inline styles. */\n style?: CSSProperties;\n};\n\n/** Typed partial map of slot name to its overrides. */\nexport type AppearanceElements<Slot extends string> = Partial<\n Record<Slot, SlotAppearance>\n>;\n\n/** CSS custom property used for each token. */\nexport type TokenVariables<Token extends string> = Readonly<\n Record<Token, string>\n>;\n\n/**\n * Remaps a token onto a shadcn theme variable (`--background`, `--ring`, ...)\n * so shared UI primitives follow the module's tokens. Only written when the\n * token is in effect.\n */\nexport type ShadcnVariableMapping<Token extends string> = readonly {\n token: Token;\n variable: string;\n}[];\n\nexport type AppearanceCoreConfig<Token extends string, Theme extends string> = {\n /** Theme used when the caller does not select one. */\n defaultTheme: Theme;\n /** Partial token sets applied underneath the caller tokens. */\n presets: Record<Theme, Partial<Record<Token, string>>>;\n variables: TokenVariables<Token>;\n shadcnVariables: ShadcnVariableMapping<Token>;\n};\n\nexport type ResolvedAppearanceCore<\n Token extends string,\n Theme extends string,\n Slot extends string,\n> = {\n theme: Theme;\n /** `true` as soon as the caller passed a theme, a token or a slot override. */\n isCustomized: boolean;\n /** Tokens that are in effect. Empty entries were dropped. */\n tokens: Partial<Record<Token, string>>;\n elements: AppearanceElements<Slot>;\n /** Inline custom properties for the theme boundary. */\n boundaryStyle: CSSProperties;\n};\n\n/** Drops `undefined`/`null` tokens so unset values keep the stylesheet default. */\nexport function omitUndefined<Token extends string>(\n tokens: Partial<Record<Token, string>>,\n): Partial<Record<Token, string>> {\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(tokens)) {\n if (value != null) {\n result[key] = value;\n }\n }\n\n return result as Partial<Record<Token, string>>;\n}\n\nexport function hasAnyElement<Slot extends string>(\n elements: AppearanceElements<Slot>,\n): boolean {\n return Object.values<SlotAppearance | undefined>(elements).some(\n (element) =>\n element != null && (element.className != null || element.style != null),\n );\n}\n\n/**\n * Token to CSS variable resolution, followed by the shadcn remapping. Only\n * tokens that are in effect produce a variable.\n */\nexport function resolveBoundaryStyle<Token extends string>(\n tokens: Partial<Record<Token, string>>,\n variables: TokenVariables<Token>,\n shadcnVariables: ShadcnVariableMapping<Token>,\n): CSSProperties {\n const style: Record<string, string> = {};\n\n for (const [token, variable] of Object.entries<string>(variables)) {\n const value = tokens[token as Token];\n if (value != null) {\n style[variable] = value;\n }\n }\n\n for (const { token, variable } of shadcnVariables) {\n const value = tokens[token];\n if (value != null) {\n style[variable] = value;\n }\n }\n\n return style as CSSProperties;\n}\n\n/**\n * Resolves theme, tokens, slot overrides and the boundary style. The resolver\n * never invents values: a token is only present when the caller provided it or\n * selected a theme preset that carries it.\n */\nexport function resolveAppearanceCore<\n Token extends string,\n Theme extends string,\n Slot extends string,\n>(\n appearance:\n | {\n theme?: Theme;\n tokens?: Partial<Record<Token, string>>;\n elements?: AppearanceElements<Slot>;\n }\n | undefined,\n config: AppearanceCoreConfig<Token, Theme>,\n): ResolvedAppearanceCore<Token, Theme, Slot> {\n const theme: Theme = appearance?.theme ?? config.defaultTheme;\n\n const tokens = omitUndefined<Token>({\n ...config.presets[theme],\n ...appearance?.tokens,\n });\n\n const elements = appearance?.elements ?? {};\n\n return {\n theme,\n isCustomized:\n appearance?.theme != null ||\n Object.keys(tokens).length > 0 ||\n hasAnyElement(elements),\n tokens,\n elements,\n boundaryStyle: resolveBoundaryStyle(\n tokens,\n config.variables,\n config.shadcnVariables,\n ),\n };\n}\n\n/** Caller overrides for a slot, if any were provided. */\nexport function getSlotAppearance<Slot extends string>(\n elements: AppearanceElements<Slot>,\n slot: Slot,\n): SlotAppearance | undefined {\n return elements[slot];\n}\n"]}
1
+ {"version":3,"sources":["../src/lib/appearance-core.ts"],"names":["omitUndefined","tokens","result","key","value","hasAnyElement","elements","element","resolveBoundaryStyle","variables","shadcnVariables","style","token","variable","resolveAppearanceCore","appearance","config","theme","getSlotAppearance","slot"],"mappings":"AA8DO,0rBAASA,CAAAA,CACdC,CAAAA,CACgC,CAChC,IAAMC,CAAAA,CAAkC,CAAC,CAAA,CAEzC,GAAA,CAAA,GAAW,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQH,CAAM,CAAA,CAC1CG,CAAAA,EAAS,IAAA,EAAA,CACXF,CAAAA,CAAOC,CAAG,CAAA,CAAIC,CAAAA,CAAAA,CAIlB,OAAOF,CACT,CAEO,SAASG,CAAAA,CACdC,CAAAA,CACS,CACT,OAAO,MAAA,CAAO,MAAA,CAAmCA,CAAQ,CAAA,CAAE,IAAA,CACxDC,CAAAA,EACCA,CAAAA,EAAW,IAAA,EAAA,CAASA,CAAAA,CAAQ,SAAA,EAAa,IAAA,EAAQA,CAAAA,CAAQ,KAAA,EAAS,IAAA,CACtE,CACF,CAMO,SAASC,CAAAA,CACdP,CAAAA,CACAQ,CAAAA,CACAC,CAAAA,CACe,CACf,IAAMC,CAAAA,CAAgC,CAAC,CAAA,CAEvC,GAAA,CAAA,GAAW,CAACC,CAAAA,CAAOC,CAAQ,CAAA,GAAK,MAAA,CAAO,OAAA,CAAgBJ,CAAS,CAAA,CAAG,CACjE,IAAML,CAAAA,CAAQH,CAAAA,CAAOW,CAAc,CAAA,CAC/BR,CAAAA,EAAS,IAAA,EAAA,CACXO,CAAAA,CAAME,CAAQ,CAAA,CAAIT,CAAAA,CAEtB,CAEA,GAAA,CAAA,GAAW,CAAE,KAAA,CAAAQ,CAAAA,CAAO,QAAA,CAAAC,CAAS,CAAA,GAAKH,CAAAA,CAAiB,CACjD,IAAMN,CAAAA,CAAQH,CAAAA,CAAOW,CAAK,CAAA,CACtBR,CAAAA,EAAS,IAAA,EAAA,CACXO,CAAAA,CAAME,CAAQ,CAAA,CAAIT,CAAAA,CAEtB,CAEA,OAAOO,CACT,CAOO,SAASG,CAAAA,CAKdC,CAAAA,CAOAC,CAAAA,CAC4C,CAC5C,IAAMC,CAAAA,kCAAeF,CAAAA,2BAAY,OAAA,SAASC,CAAAA,CAAO,cAAA,CAE3Cf,CAAAA,CAASD,CAAAA,CAAqB,CAClC,GAAGgB,CAAAA,CAAO,OAAA,CAAQC,CAAK,CAAA,CACvB,mBAAGF,CAAAA,6BAAY,QACjB,CAAC,CAAA,CAEKT,CAAAA,kCAAWS,CAAAA,6BAAY,UAAA,SAAY,CAAC,GAAA,CAE1C,MAAO,CACL,KAAA,CAAAE,CAAAA,CACA,YAAA,iBACEF,CAAAA,6BAAY,OAAA,EAAS,IAAA,EACrB,MAAA,CAAO,IAAA,CAAKd,CAAM,CAAA,CAAE,MAAA,CAAS,CAAA,EAC7BI,CAAAA,CAAcC,CAAQ,CAAA,CACxB,MAAA,CAAAL,CAAAA,CACA,QAAA,CAAAK,CAAAA,CACA,aAAA,CAAeE,CAAAA,CACbP,CAAAA,CACAe,CAAAA,CAAO,SAAA,CACPA,CAAAA,CAAO,eACT,CACF,CACF,CAGO,SAASE,CAAAA,CACdZ,CAAAA,CACAa,CAAAA,CAC4B,CAC5B,OAAOb,CAAAA,CAASa,CAAI,CACtB,CAAA,6BAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/chat-attachments/dist/chunk-KOYBZORL.js","sourcesContent":["import type { CSSProperties } from \"react\";\n\n/**\n * Generic building blocks shared by the appearance modules (checkout, and\n * later returns). Each module supplies its own token to CSS variable map, theme\n * presets and shadcn mapping, and keeps its own public types. Everything here\n * is pure so it can be tested without a DOM.\n */\n\n/** Caller overrides for a single slot. */\nexport type SlotAppearance = {\n /** Merged after the built-in classes with `cn`, so Tailwind conflicts resolve. */\n className?: string;\n /** Merged after the built-in inline styles. */\n style?: CSSProperties;\n};\n\n/** Typed partial map of slot name to its overrides. */\nexport type AppearanceElements<Slot extends string> = Partial<\n Record<Slot, SlotAppearance>\n>;\n\n/** CSS custom property used for each token. */\nexport type TokenVariables<Token extends string> = Readonly<\n Record<Token, string>\n>;\n\n/**\n * Remaps a token onto a shadcn theme variable (`--background`, `--ring`, ...)\n * so shared UI primitives follow the module's tokens. Only written when the\n * token is in effect.\n */\nexport type ShadcnVariableMapping<Token extends string> = readonly {\n token: Token;\n variable: string;\n}[];\n\nexport type AppearanceCoreConfig<Token extends string, Theme extends string> = {\n /** Theme used when the caller does not select one. */\n defaultTheme: Theme;\n /** Partial token sets applied underneath the caller tokens. */\n presets: Record<Theme, Partial<Record<Token, string>>>;\n variables: TokenVariables<Token>;\n shadcnVariables: ShadcnVariableMapping<Token>;\n};\n\nexport type ResolvedAppearanceCore<\n Token extends string,\n Theme extends string,\n Slot extends string,\n> = {\n theme: Theme;\n /** `true` as soon as the caller passed a theme, a token or a slot override. */\n isCustomized: boolean;\n /** Tokens that are in effect. Empty entries were dropped. */\n tokens: Partial<Record<Token, string>>;\n elements: AppearanceElements<Slot>;\n /** Inline custom properties for the theme boundary. */\n boundaryStyle: CSSProperties;\n};\n\n/** Drops `undefined`/`null` tokens so unset values keep the stylesheet default. */\nexport function omitUndefined<Token extends string>(\n tokens: Partial<Record<Token, string>>,\n): Partial<Record<Token, string>> {\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(tokens)) {\n if (value != null) {\n result[key] = value;\n }\n }\n\n return result as Partial<Record<Token, string>>;\n}\n\nexport function hasAnyElement<Slot extends string>(\n elements: AppearanceElements<Slot>,\n): boolean {\n return Object.values<SlotAppearance | undefined>(elements).some(\n (element) =>\n element != null && (element.className != null || element.style != null),\n );\n}\n\n/**\n * Token to CSS variable resolution, followed by the shadcn remapping. Only\n * tokens that are in effect produce a variable.\n */\nexport function resolveBoundaryStyle<Token extends string>(\n tokens: Partial<Record<Token, string>>,\n variables: TokenVariables<Token>,\n shadcnVariables: ShadcnVariableMapping<Token>,\n): CSSProperties {\n const style: Record<string, string> = {};\n\n for (const [token, variable] of Object.entries<string>(variables)) {\n const value = tokens[token as Token];\n if (value != null) {\n style[variable] = value;\n }\n }\n\n for (const { token, variable } of shadcnVariables) {\n const value = tokens[token];\n if (value != null) {\n style[variable] = value;\n }\n }\n\n return style as CSSProperties;\n}\n\n/**\n * Resolves theme, tokens, slot overrides and the boundary style. The resolver\n * never invents values: a token is only present when the caller provided it or\n * selected a theme preset that carries it.\n */\nexport function resolveAppearanceCore<\n Token extends string,\n Theme extends string,\n Slot extends string,\n>(\n appearance:\n | {\n theme?: Theme;\n tokens?: Partial<Record<Token, string>>;\n elements?: AppearanceElements<Slot>;\n }\n | undefined,\n config: AppearanceCoreConfig<Token, Theme>,\n): ResolvedAppearanceCore<Token, Theme, Slot> {\n const theme: Theme = appearance?.theme ?? config.defaultTheme;\n\n const tokens = omitUndefined<Token>({\n ...config.presets[theme],\n ...appearance?.tokens,\n });\n\n const elements = appearance?.elements ?? {};\n\n return {\n theme,\n isCustomized:\n appearance?.theme != null ||\n Object.keys(tokens).length > 0 ||\n hasAnyElement(elements),\n tokens,\n elements,\n boundaryStyle: resolveBoundaryStyle(\n tokens,\n config.variables,\n config.shadcnVariables,\n ),\n };\n}\n\n/** Caller overrides for a slot, if any were provided. */\nexport function getSlotAppearance<Slot extends string>(\n elements: AppearanceElements<Slot>,\n slot: Slot,\n): SlotAppearance | undefined {\n return elements[slot];\n}\n"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkI2RHVELRjs = require('./chunk-I2RHVELR.js');var _chunkMDAFPGPAjs = require('./chunk-MDAFPGPA.js');var _chunkEK3D44XWjs = require('./chunk-EK3D44XW.js');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var a=_react.createContext.call(void 0, _chunkMDAFPGPAjs.b.call(void 0, )),u= exports.a =({children:c,analytics:s})=>{let n=_chunkMDAFPGPAjs.b.call(void 0, ),l=_chunkEK3D44XWjs.n.call(void 0, n.projectID,s,"panel");return _jsxruntime.jsx.call(void 0, _chunkI2RHVELRjs.j,{children:_jsxruntime.jsx.call(void 0, a.Provider,{value:{...n},children:_jsxruntime.jsx.call(void 0, _chunkEK3D44XWjs.l,{value:l,children:_jsxruntime.jsx.call(void 0, "div",{className:"bitsnap-react",children:c})})})})},C= exports.b =()=>_react.useContext.call(void 0, a);exports.a = u; exports.b = C;
2
+ //# sourceMappingURL=chunk-KYSMT6ZK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/chat-attachments/dist/chunk-KYSMT6ZK.js","../src/panel/PanelProvider.tsx"],"names":["PanelContext","createContext","getPanelConfig","PanelProvider","children","analytics","config","instrument","useInstrument","jsx","RpcProvider","InstrumentProvider","usePanelConfig","useContext"],"mappings":"AAAA,+HAAuC,sDAAwC,sDAA+C,8BCApF,+CA2BhC,IAlBJA,CAAAA,CAAeC,kCAAAA,gCAA2BC,CAAgB,CAAA,CAEnDC,CAAAA,aASR,CAAC,CAAE,QAAA,CAAAC,CAAAA,CAAU,SAAA,CAAAC,CAAU,CAAA,CAAA,EAAM,CAChC,IAAMC,CAAAA,CAASJ,gCAAAA,CAAe,CACxBK,CAAAA,CAAaC,gCAAAA,CAAcF,CAAO,SAAA,CAAWD,CAAAA,CAAW,OAAO,CAAA,CACrE,OACEI,6BAAAA,kBAACC,CAAA,CACC,QAAA,CAAAD,6BAAAA,CAACT,CAAa,QAAA,CAAb,CAAsB,KAAA,CAAO,CAAE,GAAGM,CAAO,CAAA,CACxC,QAAA,CAAAG,6BAAAA,kBAACE,CAAA,CAAmB,KAAA,CAAOJ,CAAAA,CACzB,QAAA,CAAAE,6BAAAA,KAAC,CAAA,CAAI,SAAA,CAAU,eAAA,CAAiB,QAAA,CAAAL,CAAAA,CAAS,CAAA,CAC3C,CAAA,CACF,CAAA,CACF,CAEJ,CAAA,CAEaQ,CAAAA,aAAiB,CAAA,CAAA,EAAMC,+BAAAA,CAAuB,CAAA,CAAA,6BAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/chat-attachments/dist/chunk-KYSMT6ZK.js","sourcesContent":[null,"import { createContext, useContext } from \"react\";\nimport {\n InstrumentProvider,\n useInstrument,\n type AnalyticsOption,\n} from \"../analytics/instrument\";\nimport { RpcProvider } from \"../rpc-provider\";\nimport { getPanelConfig, type PanelConfig } from \"./config\";\n\nconst PanelContext = createContext<PanelConfig>(getPanelConfig());\n\nexport const PanelProvider: React.FC<{\n children: React.ReactNode;\n /**\n * Usage statistics for your Bitsnap dashboard (panel logins, orders viewed,\n * downloads, course progress). On by default; `false` turns it off. An\n * object lets you forward every event: `{ onEvent }`. Nothing is stored on\n * the visitor's device.\n */\n analytics?: AnalyticsOption;\n}> = ({ children, analytics }) => {\n const config = getPanelConfig();\n const instrument = useInstrument(config.projectID, analytics, \"panel\");\n return (\n <RpcProvider>\n <PanelContext.Provider value={{ ...config }}>\n <InstrumentProvider value={instrument}>\n <div className=\"bitsnap-react\">{children}</div>\n </InstrumentProvider>\n </PanelContext.Provider>\n </RpcProvider>\n );\n};\n\nexport const usePanelConfig = () => useContext(PanelContext);\n"]}
@@ -1,2 +1,2 @@
1
- import{j as i}from"./chunk-SCEWYZUZ.mjs";import{b as t}from"./chunk-CUPG4B5W.mjs";import{l as o,n as r}from"./chunk-SSSF64M7.mjs";import{createContext as p,useContext as P}from"react";import{jsx as e}from"react/jsx-runtime";var a=p(t()),u=({children:c,analytics:s})=>{let n=t(),l=r(n.projectID,s,"panel");return e(i,{children:e(a.Provider,{value:{...n},children:e(o,{value:l,children:e("div",{className:"bitsnap-react",children:c})})})})},C=()=>P(a);export{u as a,C as b};
2
- //# sourceMappingURL=chunk-5JRUPLXY.mjs.map
1
+ import{j as i}from"./chunk-TMEII7BM.mjs";import{b as t}from"./chunk-CUPG4B5W.mjs";import{l as o,n as r}from"./chunk-J6WKSO33.mjs";import{createContext as p,useContext as P}from"react";import{jsx as e}from"react/jsx-runtime";var a=p(t()),u=({children:c,analytics:s})=>{let n=t(),l=r(n.projectID,s,"panel");return e(i,{children:e(a.Provider,{value:{...n},children:e(o,{value:l,children:e("div",{className:"bitsnap-react",children:c})})})})},C=()=>P(a);export{u as a,C as b};
2
+ //# sourceMappingURL=chunk-LRUBBPTV.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/panel/config.ts","../src/panel/session-storage.ts"],"names":["config","allowedReturnOrigins","setPanelConfig","newConfig","getPanelConfig","setProjectID","projectID","setTheme","theme","setLoginURL","loginURL","setHost","host","setAllowedReturnOrigins","origins","getAllowedReturnOrigins","panelSessionKey"],"mappings":"AAEA,iLAAIA,CAAAA,CAAsB,CACxB,SAAA,CAAW,KAAA,CAAA,CACX,QAAA,CAAU,cAAA,CACV,KAAA,CAAO,KAAA,CAAA,CACP,IAAA,CAAM,KAAA,CAAA,CACN,oBAAA,CAAsB,CAAC,CACzB,CAAA,CAEIC,CAAAA,CAAiC,CAAC,CAAA,CAU/B,SAASC,CAAAA,CAAeC,CAAAA,CAAuC,CACpEH,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,GAAGG,CAAU,CACrC,CAEO,SAASC,CAAAA,CAAAA,CAA8B,CAC5C,OAAOJ,CACT,CAEO,SAASK,CAAAA,CAAaC,CAAAA,CAAyB,CACpDN,CAAAA,CAAO,SAAA,CAAYM,CACrB,CAEO,SAASC,CAAAA,CAASC,CAAAA,CAA6B,CACpDR,CAAAA,CAAO,KAAA,CAAQQ,CACjB,CAEO,SAASC,CAAAA,CAAYC,CAAAA,CAAwB,CAClDV,CAAAA,CAAO,QAAA,CAAWU,CACpB,CAEO,SAASC,CAAAA,CAAQC,CAAAA,CAAoB,CAC1CZ,CAAAA,CAAO,IAAA,CAAOY,CAChB,CAEO,SAASC,CAAAA,CAAwBC,CAAAA,CAAyB,CAC/Db,CAAAA,CAAuBa,CAAAA,CACvBd,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,oBAAA,CAAsBc,CAAQ,CACtD,CAEO,SAASC,CAAAA,CAAAA,CAAoC,CAClD,OAAOd,CACT,CCnDA,IAAMe,CAAAA,CAAkB,CAACV,CAAAA,CAAmBM,CAAAA,CAAAA,EAC1C,CAAA,sBAAA,EAAyB,kBAAA,kBAAmBA,CAAAA,SAAQ,sBAAoB,CAAC,CAAA,CAAA,EAAI,kBAAA,CAAmBN,CAAS,CAAC,CAAA,CAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/emems-chat-v1/dist/chunk-MDAFPGPA.js","sourcesContent":["import type { GetThemeOutput } from \"./types\";\n\nlet config: PanelConfig = {\n projectID: undefined,\n loginURL: \"/panel/login\",\n theme: undefined,\n host: undefined,\n allowedReturnOrigins: [],\n};\n\nlet allowedReturnOrigins: string[] = [];\n\nexport interface PanelConfig {\n projectID?: string;\n loginURL?: string;\n theme?: GetThemeOutput;\n host?: string;\n allowedReturnOrigins: string[];\n}\n\nexport function setPanelConfig(newConfig: Partial<PanelConfig>): void {\n config = { ...config, ...newConfig };\n}\n\nexport function getPanelConfig(): PanelConfig {\n return config;\n}\n\nexport function setProjectID(projectID: string): void {\n config.projectID = projectID;\n}\n\nexport function setTheme(theme: GetThemeOutput): void {\n config.theme = theme;\n}\n\nexport function setLoginURL(loginURL: string): void {\n config.loginURL = loginURL;\n}\n\nexport function setHost(host: string): void {\n config.host = host;\n}\n\nexport function setAllowedReturnOrigins(origins: string[]): void {\n allowedReturnOrigins = origins;\n config = { ...config, allowedReturnOrigins: origins };\n}\n\nexport function getAllowedReturnOrigins(): string[] {\n return allowedReturnOrigins;\n}\n","const panelSessionKey = (projectID: string, host?: string) =>\n `bitsnap-panel-session:${encodeURIComponent(host ?? \"https://bitsnap.pl\")}:${encodeURIComponent(projectID)}`;\n\nconst panelEmailKey = (projectID: string, host?: string) =>\n `bitsnap-panel-email:${encodeURIComponent(host ?? \"https://bitsnap.pl\")}:${encodeURIComponent(projectID)}`;\n\nexport function getPanelSession(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return undefined;\n const token = window.localStorage.getItem(panelSessionKey(projectID, host));\n return token ?? undefined;\n}\n\nexport function savePanelSession(projectID: string | undefined, token: string, email: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return;\n window.localStorage.setItem(panelSessionKey(projectID, host), token);\n window.localStorage.setItem(panelEmailKey(projectID, host), email);\n}\n\nexport function getPanelEmail(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return null;\n return window.localStorage.getItem(panelEmailKey(projectID, host));\n}\n\nexport function clearPanelSession(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return;\n window.localStorage.removeItem(panelSessionKey(projectID, host));\n window.localStorage.removeItem(panelEmailKey(projectID, host));\n}\n"]}
1
+ {"version":3,"sources":["../src/panel/config.ts","../src/panel/session-storage.ts"],"names":["config","allowedReturnOrigins","setPanelConfig","newConfig","getPanelConfig","setProjectID","projectID","setTheme","theme","setLoginURL","loginURL","setHost","host","setAllowedReturnOrigins","origins","getAllowedReturnOrigins","panelSessionKey"],"mappings":"AAEA,iLAAIA,CAAAA,CAAsB,CACxB,SAAA,CAAW,KAAA,CAAA,CACX,QAAA,CAAU,cAAA,CACV,KAAA,CAAO,KAAA,CAAA,CACP,IAAA,CAAM,KAAA,CAAA,CACN,oBAAA,CAAsB,CAAC,CACzB,CAAA,CAEIC,CAAAA,CAAiC,CAAC,CAAA,CAU/B,SAASC,CAAAA,CAAeC,CAAAA,CAAuC,CACpEH,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,GAAGG,CAAU,CACrC,CAEO,SAASC,CAAAA,CAAAA,CAA8B,CAC5C,OAAOJ,CACT,CAEO,SAASK,CAAAA,CAAaC,CAAAA,CAAyB,CACpDN,CAAAA,CAAO,SAAA,CAAYM,CACrB,CAEO,SAASC,CAAAA,CAASC,CAAAA,CAA6B,CACpDR,CAAAA,CAAO,KAAA,CAAQQ,CACjB,CAEO,SAASC,CAAAA,CAAYC,CAAAA,CAAwB,CAClDV,CAAAA,CAAO,QAAA,CAAWU,CACpB,CAEO,SAASC,CAAAA,CAAQC,CAAAA,CAAoB,CAC1CZ,CAAAA,CAAO,IAAA,CAAOY,CAChB,CAEO,SAASC,CAAAA,CAAwBC,CAAAA,CAAyB,CAC/Db,CAAAA,CAAuBa,CAAAA,CACvBd,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,oBAAA,CAAsBc,CAAQ,CACtD,CAEO,SAASC,CAAAA,CAAAA,CAAoC,CAClD,OAAOd,CACT,CCnDA,IAAMe,CAAAA,CAAkB,CAACV,CAAAA,CAAmBM,CAAAA,CAAAA,EAC1C,CAAA,sBAAA,EAAyB,kBAAA,kBAAmBA,CAAAA,SAAQ,sBAAoB,CAAC,CAAA,CAAA,EAAI,kBAAA,CAAmBN,CAAS,CAAC,CAAA,CAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/chat-attachments/dist/chunk-MDAFPGPA.js","sourcesContent":["import type { GetThemeOutput } from \"./types\";\n\nlet config: PanelConfig = {\n projectID: undefined,\n loginURL: \"/panel/login\",\n theme: undefined,\n host: undefined,\n allowedReturnOrigins: [],\n};\n\nlet allowedReturnOrigins: string[] = [];\n\nexport interface PanelConfig {\n projectID?: string;\n loginURL?: string;\n theme?: GetThemeOutput;\n host?: string;\n allowedReturnOrigins: string[];\n}\n\nexport function setPanelConfig(newConfig: Partial<PanelConfig>): void {\n config = { ...config, ...newConfig };\n}\n\nexport function getPanelConfig(): PanelConfig {\n return config;\n}\n\nexport function setProjectID(projectID: string): void {\n config.projectID = projectID;\n}\n\nexport function setTheme(theme: GetThemeOutput): void {\n config.theme = theme;\n}\n\nexport function setLoginURL(loginURL: string): void {\n config.loginURL = loginURL;\n}\n\nexport function setHost(host: string): void {\n config.host = host;\n}\n\nexport function setAllowedReturnOrigins(origins: string[]): void {\n allowedReturnOrigins = origins;\n config = { ...config, allowedReturnOrigins: origins };\n}\n\nexport function getAllowedReturnOrigins(): string[] {\n return allowedReturnOrigins;\n}\n","const panelSessionKey = (projectID: string, host?: string) =>\n `bitsnap-panel-session:${encodeURIComponent(host ?? \"https://bitsnap.pl\")}:${encodeURIComponent(projectID)}`;\n\nconst panelEmailKey = (projectID: string, host?: string) =>\n `bitsnap-panel-email:${encodeURIComponent(host ?? \"https://bitsnap.pl\")}:${encodeURIComponent(projectID)}`;\n\nexport function getPanelSession(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return undefined;\n const token = window.localStorage.getItem(panelSessionKey(projectID, host));\n return token ?? undefined;\n}\n\nexport function savePanelSession(projectID: string | undefined, token: string, email: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return;\n window.localStorage.setItem(panelSessionKey(projectID, host), token);\n window.localStorage.setItem(panelEmailKey(projectID, host), email);\n}\n\nexport function getPanelEmail(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return null;\n return window.localStorage.getItem(panelEmailKey(projectID, host));\n}\n\nexport function clearPanelSession(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return;\n window.localStorage.removeItem(panelSessionKey(projectID, host));\n window.localStorage.removeItem(panelEmailKey(projectID, host));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/texts.ts","../src/components/checkout/texts.ts","../src/components/checkout/locale.ts"],"names":["pickLocaleTable","tables","locale","mergeTexts","table","overrides","result","key","value","resolveTexts","lookupText","texts","CHECKOUT_TEXT_TABLES","resolveCheckoutTexts","getCheckoutText","DEFAULT_LOCALE","localeStorageKey","activeLocale","setLocale","getLocale"],"mappings":"AAoBO,0rBAASA,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACgB,CAChB,OAAOA,CAAAA,CAAO,WAAA,CAAY,CAAA,CAAE,UAAA,CAAW,IAAI,CAAA,CAAID,CAAAA,CAAO,EAAA,CAAKA,CAAAA,CAAO,EACpE,CAMO,SAASE,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACgB,CAChB,IAAMC,CAAAA,CAAiC,CAAE,GAAGF,CAAM,CAAA,CAElD,EAAA,CAAIC,CAAAA,EAAa,IAAA,CACf,GAAA,CAAA,GAAW,CAACE,CAAAA,CAAKC,CAAK,CAAA,GAAK,MAAA,CAAO,OAAA,CAA4BH,CAAS,CAAA,CACjEG,CAAAA,EAAS,IAAA,EAAA,CACXF,CAAAA,CAAOC,CAAG,CAAA,CAAIC,CAAAA,CAAAA,CAKpB,OAAOF,CACT,CAGO,SAASG,CAAAA,CACdR,CAAAA,CACAC,CAAAA,CACAG,CAAAA,CACgB,CAChB,OAAOF,CAAAA,CAAWH,CAAAA,CAAgBC,CAAAA,CAAQC,CAAM,CAAA,CAAGG,CAAS,CAC9D,CAGO,SAASK,CAAAA,CACdC,CAAAA,CACAJ,CAAAA,CACQ,CACR,wBAAQI,CAAAA,CAA6CJ,CAAG,CAAA,SAAKA,GAC/D,CC6DO,IAAMK,CAAAA,CAAsD,CACjE,EAAA,CAAI,CACF,IAAA,CAAM,MAAA,CACN,SAAA,CAAW,qBAAA,CACX,KAAA,CAAO,QAAA,CACP,QAAA,CAAU,YAAA,CACV,aAAA,CAAe,kBAAA,CACf,QAAA,CAAU,WAAA,CACV,mBAAA,CAAqB,iCAAA,CACrB,cAAA,CAAgB,+CAAA,CAChB,gBAAA,CACE,sFAAA,CACF,oBAAA,CACE,wFAAA,CACF,qBAAA,CACE,qFAAA,CACF,cAAA,CACE,mGAAA,CACF,mBAAA,CACE,wEAAA,CACF,YAAA,CAAc,2EAAA,CACd,KAAA,CAAO,YAAA,CACP,MAAA,CAAQ,QAAA,CACR,QAAA,CAAU,UAAA,CACV,gBAAA,CAAkB,mBAAA,CAClB,gBAAA,CAAkB,mBAAA,CAClB,QAAA,CAAU,WAAA,CACV,cAAA,CAAgB,eAAA,CAChB,iBAAA,CAAmB,mCAAA,CACnB,cAAA,CAAgB,oCAAA,CAChB,cAAA,CAAgB,4DAAA,CAChB,uBAAA,CAAyB,gDAAA,CACzB,aAAA,CAAe,gBAAA,CACf,gBAAA,CAAkB,oBAAA,CAClB,eAAA,CAAiB,+BAAA,CACjB,cAAA,CAAgB,cAAA,CAChB,MAAA,CAAQ,QAAA,CACR,oBAAA,CACE,+DAAA,CACF,UAAA,CAAY,2BAAA,CACZ,KAAA,CAAO,WAAA,CACP,mBAAA,CAAqB,4BAAA,CACrB,mBAAA,CAAqB,YAAA,CACrB,8BAAA,CACE,8DAAA,CACF,2BAAA,CAA6B,eAAA,CAC7B,uBAAA,CAAyB,wCAAA,CACzB,uBAAA,CAAyB,yCAAA,CACzB,8BAAA,CACE,0HAAA,CACF,2BAAA,CACE,8EAAA,CACF,gBAAA,CAAkB,kBAAA,CAClB,2BAAA,CACE,qEAAA,CACF,2BAAA,CACE,8EAAA,CACF,cAAA,CAAgB,+BAAA,CAChB,gBAAA,CAAkB,+BAAA,CAClB,aAAA,CAAe,6CAAA,CACf,gBAAA,CAAkB,4CAAA,CAClB,kBAAA,CACE,4FAAA,CACF,iBAAA,CACE,kFAAA,CACF,sBAAA,CACE,uEAAA,CACF,mBAAA,CACE,iGAAA,CACF,mBAAA,CACE,6DAAA,CACF,yBAAA,CACE,6DACJ,CAAA,CACA,EAAA,CAAI,CACF,IAAA,CAAM,QAAA,CACN,SAAA,CAAW,8BAAA,CACX,KAAA,CAAO,OAAA,CACP,QAAA,CAAU,WAAA,CACV,aAAA,CAAe,cAAA,CACf,QAAA,CAAU,oBAAA,CACV,mBAAA,CAAqB,2DAAA,CACrB,cAAA,CAAgB,oEAAA,CAChB,gBAAA,CACE,6IAAA,CACF,oBAAA,CACE,yJAAA,CACF,qBAAA,CACE,wIAAA,CACF,cAAA,CACE,iIAAA,CACF,mBAAA,CACE,gGAAA,CACF,YAAA,CAAc,iHAAA,CACd,KAAA,CAAO,gBAAA,CACP,MAAA,CAAQ,WAAA,CACR,QAAA,CAAU,iBAAA,CACV,gBAAA,CAAkB,8BAAA,CAClB,gBAAA,CAAkB,0BAAA,CAClB,QAAA,CAAU,kBAAA,CACV,cAAA,CAAgB,wBAAA,CAChB,iBAAA,CAAmB,+BAAA,CACnB,cAAA,CAAgB,wCAAA,CAChB,cAAA,CACE,wGAAA,CACF,uBAAA,CAAyB,2DAAA,CACzB,aAAA,CAAe,kBAAA,CACf,gBAAA,CAAkB,0BAAA,CAClB,eAAA,CAAiB,4CAAA,CACjB,cAAA,CAAgB,mCAAA,CAChB,MAAA,CAAQ,OAAA,CACR,oBAAA,CAAsB,kDAAA,CACtB,UAAA,CAAY,+CAAA,CACZ,KAAA,CAAO,qBAAA,CACP,mBAAA,CAAqB,gCAAA,CACrB,mBAAA,CAAqB,yBAAA,CACrB,8BAAA,CACE,2DAAA,CACF,2BAAA,CAA6B,iBAAA,CAC7B,uBAAA,CAAyB,gCAAA,CACzB,uBAAA,CAAyB,6BAAA,CACzB,8BAAA,CACE,kLAAA,CACF,2BAAA,CACE,4FAAA,CACF,gBAAA,CAAkB,uCAAA,CAClB,2BAAA,CACE,8FAAA,CACF,2BAAA,CACE,wIAAA,CACF,cAAA,CAAgB,4CAAA,CAChB,gBAAA,CAAkB,wDAAA,CAClB,aAAA,CAAe,kFAAA,CACf,gBAAA,CAAkB,iFAAA,CAClB,kBAAA,CACE,oHAAA,CACF,iBAAA,CACE,kJAAA,CACF,sBAAA,CACE,+GAAA,CACF,mBAAA,CACE,+HAAA,CACF,mBAAA,CACE,8FAAA,CACF,yBAAA,CACE,8FACJ,CACF,CAAA,CAGO,SAASC,CAAAA,CACdX,CAAAA,CACAG,CAAAA,CACe,CACf,OAAOI,CAAAA,CAAaG,CAAAA,CAAsBV,CAAAA,CAAQG,CAAS,CAC7D,CAEO,SAASS,CAAAA,CACdP,CAAAA,CACAL,CAAAA,CACAG,CAAAA,CACQ,CACR,OAAOK,CAAAA,CAAWG,CAAAA,CAAqBX,CAAAA,CAAQG,CAAS,CAAA,CAAGE,CAAG,CAChE,CC5RO,IAAMQ,CAAAA,CAAiB,OAAA,CACxBC,CAAAA,CAAmB,gBAAA,CAErBC,CAAAA,CAEG,SAASC,CAAAA,CAAUhB,CAAAA,CAAuB,CAC/C,IAAMM,CAAAA,iBAAQN,CAAAA,2BAAQ,IAAA,mBAAK,GAAA,CAC3Be,CAAAA,CAAeT,CAAAA,CACXA,CAAAA,CAAM,WAAA,CAAY,CAAA,GAAM,IAAA,CACtB,OAAA,CACAA,CAAAA,CAAM,WAAA,CAAY,CAAA,GAAM,IAAA,CACtBO,CAAAA,CACAP,CAAAA,CACJ,KAAA,CAAA,CACA,OAAO,YAAA,CAAiB,GAAA,EAAA,CACtBS,CAAAA,EAAgB,IAAA,CAClB,YAAA,CAAa,UAAA,CAAWD,CAAgB,CAAA,CAExC,YAAA,CAAa,OAAA,CAAQA,CAAAA,CAAkBC,CAAY,CAAA,CAGzD,CAEO,SAASE,CAAAA,CAAAA,CAAoB,CAClC,wBAAIF,CAAAA,SAAAA,CAGA,OAAO,YAAA,CAAiB,GAAA,kBACnB,YAAA,CAAa,OAAA,CAAQD,CAAgB,CAAA,SAAKD,GAAAA,CAE5CA,CAAAA,GACT,CAAA,yFAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/emems-chat-v1/dist/chunk-Q337IQNA.js","sourcesContent":["/**\n * Shared text machinery: typed string tables per locale, the locale fallback\n * and a merge with caller overrides. Each module (checkout, later returns)\n * supplies its own key type and default tables.\n */\n\n/** Strings of one locale, keyed by text key. */\nexport type TextTable<Key extends string> = Record<Key, string>;\n\n/** Default tables for the supported locales. */\nexport type LocaleTables<Key extends string> = {\n en: TextTable<Key>;\n pl: TextTable<Key>;\n};\n\n/**\n * Picks the table for a locale. Any locale starting with `en` (case\n * insensitive, so `en`, `en-US`, `EN-gb`) gets English; everything else,\n * including unknown locales, gets the Polish default.\n */\nexport function pickLocaleTable<Key extends string>(\n tables: LocaleTables<Key>,\n locale: string,\n): TextTable<Key> {\n return locale.toLowerCase().startsWith(\"en\") ? tables.en : tables.pl;\n}\n\n/**\n * Merges caller overrides over a table. Overrides apply regardless of the\n * locale; `undefined`/`null` entries are ignored so the default stays.\n */\nexport function mergeTexts<Key extends string>(\n table: TextTable<Key>,\n overrides?: Partial<TextTable<Key>>,\n): TextTable<Key> {\n const result: Record<string, string> = { ...table };\n\n if (overrides != null) {\n for (const [key, value] of Object.entries<string | undefined>(overrides)) {\n if (value != null) {\n result[key] = value;\n }\n }\n }\n\n return result as TextTable<Key>;\n}\n\n/** Locale table merged with the caller overrides. */\nexport function resolveTexts<Key extends string>(\n tables: LocaleTables<Key>,\n locale: string,\n overrides?: Partial<TextTable<Key>>,\n): TextTable<Key> {\n return mergeTexts(pickLocaleTable(tables, locale), overrides);\n}\n\n/** Looks up a single text. Unknown keys return the key itself. */\nexport function lookupText<Key extends string>(\n texts: TextTable<Key>,\n key: Key,\n): string {\n return (texts as Record<string, string | undefined>)[key] ?? key;\n}\n","import {\n lookupText,\n resolveTexts,\n type LocaleTables,\n} from \"@/src/lib/texts\";\n\n/**\n * Every string the checkout renders. Pass a partial object through the\n * `texts` prop of `BitsnapCheckout` to override any of them, whatever the\n * locale.\n */\nexport type CheckoutTexts = {\n /** Drawer title. */\n cart: string;\n /** Shown when the cart has no products. */\n emptyCart: string;\n /** Label next to the total price. */\n total: string;\n /** Delivery note next to the total price. */\n delivery: string;\n /** Country selector placeholder. */\n chooseCountry: string;\n /** Checkout button label. */\n nextStep: string;\n /** Error shown when some products are out of stock. */\n unavailableProducts: string;\n /** Error shown when the checkout fails and the server gave no reason. */\n checkoutFailed: string;\n /** Error shown when the shop has no payment gateway connected. */\n noPaymentGateway: string;\n /** Error shown when the payment gateway of the shop is not set up. */\n gatewayNotConfigured: string;\n /** Error shown when delivery of the shop is not set up. */\n shippingNotConfigured: string;\n /** Error shown when the cart mixes subscriptions with one-time products. */\n mixedRecurring: string;\n /** Error shown when the cart currency cannot be paid in. */\n currencyUnsupported: string;\n /** Error shown when a price changed after the product was added. */\n priceChanged: string;\n /** Accessible name of the close button of the drawer. */\n close: string;\n /** Remove button of a cart line (also read together with the product name). */\n remove: string;\n /** Accessible name of the quantity control and its input. */\n quantity: string;\n /** Accessible name of the \"+\" quantity button. */\n increaseQuantity: string;\n /** Accessible name of the \"-\" quantity button. */\n decreaseQuantity: string;\n /** Accessible name of the cart button when it only shows an icon. */\n openCart: string;\n /** Hidden label of the number of products badge; the number is appended after a colon. */\n cartItemsCount: string;\n /** Label before the lowest price of the last 30 days; the price is appended. */\n lowestPrice30Days: string;\n /** Shown instead of the lowest price when the price has no history. */\n noPriceHistory: string;\n /** Error shown when redirecting to the payment failed. */\n redirectFailed: string;\n /** Error shown when a subscription is added to the cart. */\n subscriptionUnsupported: string;\n /** Country search placeholder. */\n searchCountry: string;\n /** Shown when the country search has no match. */\n noCountriesFound: string;\n /** Hint under the checkout button when no country is chosen. */\n countryRequired: string;\n /** Title of the Apple Pay and Google Pay sheet total. */\n paymentForCart: string;\n /** Coupon label in the Google Pay sheet; the code is appended. */\n coupon: string;\n /** Note under the cart total. */\n extrasCalculatedNext: string;\n /** Error shown when the products of the cart could not be loaded. */\n loadFailed: string;\n /** Button that loads the cart again. */\n retry: string;\n /** Heading of the payment method choice (shown only when the shop offers paying by hand). */\n paymentMethodLegend: string;\n /** Option that pays through the shop's online gateway. */\n paymentMethodOnline: string;\n /** Hint under the online option. */\n paymentMethodOnlineDescription: string;\n /** Manual option when the seller takes bank transfers only. */\n paymentMethodManualTransfer: string;\n /** Manual option when the seller takes BLIK transfers to a phone number only. */\n paymentMethodManualBlik: string;\n /** Manual option when the seller takes both. */\n paymentMethodManualBoth: string;\n /** What paying by hand means: the details come after the order is placed. */\n paymentMethodManualDescription: string;\n /** Shown with a selected manual option that includes BLIK to a phone number. */\n paymentMethodManualBlikNote: string;\n /** Cash on delivery option. */\n paymentMethodCod: string;\n /** Hint under the cash on delivery option. */\n paymentMethodCodDescription: string;\n /** Error shown when the shop refused cash on delivery for the order. */\n paymentMethodCodUnavailable: string;\n /** Status while the provider confirms a payment started from an express button. */\n expressPending: string;\n /** Status after the provider confirmed the payment. */\n expressConfirmed: string;\n /** Status when the provider reports a failed payment. */\n expressFailed: string;\n /** Status when the buyer cancelled the provider's payment flow. */\n expressCancelled: string;\n /** Shown while the payment is still unconfirmed after a page return. */\n expressPendingLong: string;\n /** Error shown when the provider's button could not be loaded. */\n expressLoadFailed: string;\n /** Error shown when the cart cannot be paid with this provider right now. */\n expressCartUnavailable: string;\n /** Error shown when another tab/provider changed the same cart line. */\n expressCartConflict: string;\n /** Shown when the server total changed between mounting and paying. */\n expressPriceChanged: string;\n /** Error shown when a product could not be added before the InPost binding. */\n expressProductUnavailable: string;\n};\n\nexport type CheckoutTextKey = keyof CheckoutTexts;\n\nexport const CHECKOUT_TEXT_TABLES: LocaleTables<CheckoutTextKey> = {\n en: {\n cart: \"Cart\",\n emptyCart: \"Your cart is empty.\",\n total: \"Total:\",\n delivery: \"+ delivery\",\n chooseCountry: \"Choose a country\",\n nextStep: \"Next step\",\n unavailableProducts: \"Not all products are available.\",\n checkoutFailed: \"Something went wrong. Please try again later.\",\n noPaymentGateway:\n \"This shop doesn't accept online payments yet. Try again later or contact the seller.\",\n gatewayNotConfigured:\n \"Payments in this shop are not set up correctly. Try again later or contact the seller.\",\n shippingNotConfigured:\n \"Delivery in this shop is not configured yet. Try again later or contact the seller.\",\n mixedRecurring:\n \"Subscriptions and one-time products cannot be paid for together. Pay for them in separate orders.\",\n currencyUnsupported:\n \"The shop doesn't accept payments in this currency. Contact the seller.\",\n priceChanged: \"The product price has changed. Refresh the page to see the current price.\",\n close: \"Close cart\",\n remove: \"Remove\",\n quantity: \"Quantity\",\n increaseQuantity: \"Increase quantity\",\n decreaseQuantity: \"Decrease quantity\",\n openCart: \"Open cart\",\n cartItemsCount: \"Items in cart\",\n lowestPrice30Days: \"Lowest price in the last 30 days:\",\n noPriceHistory: \"No price data for the last 30 days\",\n redirectFailed: \"Could not redirect to the payment. Please try again later.\",\n subscriptionUnsupported: \"Subscriptions cannot be added to the cart yet.\",\n searchCountry: \"Find a country\",\n noCountriesFound: \"No countries found\",\n countryRequired: \"Choose a country to continue.\",\n paymentForCart: \"Cart payment\",\n coupon: \"Coupon\",\n extrasCalculatedNext:\n \"Discounts, shipping and taxes are calculated at the next step\",\n loadFailed: \"Could not load your cart.\",\n retry: \"Try again\",\n paymentMethodLegend: \"How would you like to pay?\",\n paymentMethodOnline: \"Pay online\",\n paymentMethodOnlineDescription:\n \"Card, BLIK code or instant bank payment. You pay right away.\",\n paymentMethodManualTransfer: \"Bank transfer\",\n paymentMethodManualBlik: \"BLIK – transfer to a phone number\",\n paymentMethodManualBoth: \"Bank transfer or BLIK to a phone number\",\n paymentMethodManualDescription:\n \"You pay in your bank's app. We show the payment details after you place the order, and the order waits for your payment.\",\n paymentMethodManualBlikNote:\n \"This is not a BLIK code payment – you do not enter a 6‑digit code.\",\n paymentMethodCod: \"Cash on delivery\",\n paymentMethodCodDescription:\n \"You pay the courier in cash or by card when you receive the parcel.\",\n paymentMethodCodUnavailable:\n \"Cash on delivery is not available for this order. Choose another way to pay.\",\n expressPending: \"Confirming your payment…\",\n expressConfirmed: \"Payment confirmed. Thank you!\",\n expressFailed: \"The payment failed. Your cart is unchanged.\",\n expressCancelled: \"Payment cancelled. Your cart is unchanged.\",\n expressPendingLong:\n \"We are still confirming your payment. We will check again when you come back to this page.\",\n expressLoadFailed:\n \"Could not load this payment button. Try again later or use the regular checkout.\",\n expressCartUnavailable:\n \"This cart cannot be paid with this method right now. Try again later.\",\n expressCartConflict:\n \"Your cart changed in another tab or in the provider's app. Review the quantities and try again.\",\n expressPriceChanged:\n \"Your cart total changed. Check the new total and try again.\",\n expressProductUnavailable:\n \"This product cannot be paid for right now. Try again later.\",\n },\n pl: {\n cart: \"Koszyk\",\n emptyCart: \"Brak produktów w koszyku.\",\n total: \"Suma:\",\n delivery: \"+ dostawa\",\n chooseCountry: \"Wybierz kraj\",\n nextStep: \"Następny krok\",\n unavailableProducts: \"Nie wszystkie produkty są dostępne w magazynie.\",\n checkoutFailed: \"Coś poszło nie tak. Spróbuj ponownie później.\",\n noPaymentGateway:\n \"Ten sklep nie przyjmuje jeszcze płatności online. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n gatewayNotConfigured:\n \"Płatności w tym sklepie nie są poprawnie skonfigurowane. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n shippingNotConfigured:\n \"Dostawa w tym sklepie nie jest jeszcze skonfigurowana. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n mixedRecurring:\n \"Subskrypcji i produktów jednorazowych nie można opłacić razem. Opłać je w osobnych zamówieniach.\",\n currencyUnsupported:\n \"Sklep nie przyjmuje płatności w tej walucie. Skontaktuj się ze sprzedawcą.\",\n priceChanged: \"Cena produktu się zmieniła. Odśwież stronę, aby zobaczyć aktualną cenę.\",\n close: \"Zamknij koszyk\",\n remove: \"Usuń\",\n quantity: \"Ilość\",\n increaseQuantity: \"Zwiększ ilość\",\n decreaseQuantity: \"Zmniejsz ilość\",\n openCart: \"Otwórz koszyk\",\n cartItemsCount: \"Produktów w koszyku\",\n lowestPrice30Days: \"Najniższa cena z 30 dni:\",\n noPriceHistory: \"Brak danych o cenie z ostatnich 30 dni\",\n redirectFailed:\n \"Nie udało się przekierować do płatności. Spróbuj ponownie później.\",\n subscriptionUnsupported: \"Subskrypcji nie można jeszcze dodać do koszyka.\",\n searchCountry: \"Znajdź kraj\",\n noCountriesFound: \"Nie znaleziono krajów\",\n countryRequired: \"Wybierz kraj, aby przejść dalej.\",\n paymentForCart: \"Płatność za koszyk\",\n coupon: \"Kupon\",\n extrasCalculatedNext: \"Rabaty, dostawa i podatki w następnym kroku\",\n loadFailed: \"Nie udało się wczytać koszyka.\",\n retry: \"Spróbuj ponownie\",\n paymentMethodLegend: \"Jak chcesz zapłacić?\",\n paymentMethodOnline: \"Zapłać online\",\n paymentMethodOnlineDescription:\n \"Karta, kod BLIK lub szybki przelew. Płacisz od razu.\",\n paymentMethodManualTransfer: \"Przelew bankowy\",\n paymentMethodManualBlik: \"BLIK – przelew na telefon\",\n paymentMethodManualBoth: \"Przelew lub BLIK na telefon\",\n paymentMethodManualDescription:\n \"Zapłacisz w aplikacji swojego banku. Dane do płatności pokażemy po złożeniu zamówienia, a zamówienie poczeka na Twoją wpłatę.\",\n paymentMethodManualBlikNote:\n \"To nie jest płatność kodem BLIK – nie wpisujesz 6‑cyfrowego kodu.\",\n paymentMethodCod: \"Płatność przy odbiorze\",\n paymentMethodCodDescription:\n \"Zapłacisz kurierowi gotówką lub kartą, gdy odbierzesz przesyłkę.\",\n paymentMethodCodUnavailable:\n \"Płatność przy odbiorze nie jest dostępna dla tego zamówienia. Wybierz inną formę płatności.\",\n expressPending: \"Potwierdzamy płatność…\",\n expressConfirmed: \"Płatność potwierdzona. Dziękujemy!\",\n expressFailed: \"Płatność się nie udała. Koszyk pozostał bez zmian.\",\n expressCancelled: \"Płatność została anulowana. Koszyk pozostał bez zmian.\",\n expressPendingLong:\n \"Nadal potwierdzamy Twoją płatność. Sprawdzimy ponownie, gdy wrócisz na tę stronę.\",\n expressLoadFailed:\n \"Nie udało się wczytać przycisku płatności. Spróbuj ponownie później lub skorzystaj ze zwykłego koszyka.\",\n expressCartUnavailable:\n \"Tego koszyka nie można teraz opłacić tą metodą. Spróbuj ponownie później.\",\n expressCartConflict:\n \"Koszyk zmienił się w innej karcie lub w aplikacji przewoźnika. Sprawdź ilości i spróbuj ponownie.\",\n expressPriceChanged:\n \"Suma koszyka się zmieniła. Sprawdź nową sumę i spróbuj ponownie.\",\n expressProductUnavailable:\n \"Nie można teraz zapłacić za ten produkt. Spróbuj ponownie później.\",\n },\n};\n\n/** Default texts for a locale merged with the caller overrides. */\nexport function resolveCheckoutTexts(\n locale: string,\n overrides?: Partial<CheckoutTexts>,\n): CheckoutTexts {\n return resolveTexts(CHECKOUT_TEXT_TABLES, locale, overrides);\n}\n\nexport function getCheckoutText(\n key: CheckoutTextKey,\n locale: string,\n overrides?: Partial<CheckoutTexts>,\n): string {\n return lookupText(resolveCheckoutTexts(locale, overrides), key);\n}\n","import { pickLocaleTable } from \"@/src/lib/texts\";\nimport { CHECKOUT_TEXT_TABLES } from \"./texts\";\n\nexport const DEFAULT_LOCALE = \"pl-PL\" as const;\nconst localeStorageKey = \"bitsnap-locale\";\n\nlet activeLocale: string | undefined;\n\nexport function setLocale(locale?: string): void {\n const value = locale?.trim();\n activeLocale = value\n ? value.toLowerCase() === \"en\"\n ? \"en-US\"\n : value.toLowerCase() === \"pl\"\n ? DEFAULT_LOCALE\n : value\n : undefined;\n if (typeof localStorage !== \"undefined\") {\n if (activeLocale == null) {\n localStorage.removeItem(localeStorageKey);\n } else {\n localStorage.setItem(localeStorageKey, activeLocale);\n }\n }\n}\n\nexport function getLocale(): string {\n if (activeLocale != null) {\n return activeLocale;\n }\n if (typeof localStorage !== \"undefined\") {\n return localStorage.getItem(localeStorageKey) ?? DEFAULT_LOCALE;\n }\n return DEFAULT_LOCALE;\n}\n\nexport function translate(key: string, locale: string = getLocale()): string {\n return (\n (pickLocaleTable(CHECKOUT_TEXT_TABLES, locale) as Record<string, string>)[\n key\n ] ?? key\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/lib/texts.ts","../src/components/checkout/texts.ts","../src/components/checkout/locale.ts"],"names":["pickLocaleTable","tables","locale","mergeTexts","table","overrides","result","key","value","resolveTexts","lookupText","texts","CHECKOUT_TEXT_TABLES","resolveCheckoutTexts","getCheckoutText","DEFAULT_LOCALE","localeStorageKey","activeLocale","setLocale","getLocale"],"mappings":"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","file":"/home/emems/.t3/worktrees/bitsnap-react/chat-attachments/dist/chunk-Q337IQNA.js","sourcesContent":["/**\n * Shared text machinery: typed string tables per locale, the locale fallback\n * and a merge with caller overrides. Each module (checkout, later returns)\n * supplies its own key type and default tables.\n */\n\n/** Strings of one locale, keyed by text key. */\nexport type TextTable<Key extends string> = Record<Key, string>;\n\n/** Default tables for the supported locales. */\nexport type LocaleTables<Key extends string> = {\n en: TextTable<Key>;\n pl: TextTable<Key>;\n};\n\n/**\n * Picks the table for a locale. Any locale starting with `en` (case\n * insensitive, so `en`, `en-US`, `EN-gb`) gets English; everything else,\n * including unknown locales, gets the Polish default.\n */\nexport function pickLocaleTable<Key extends string>(\n tables: LocaleTables<Key>,\n locale: string,\n): TextTable<Key> {\n return locale.toLowerCase().startsWith(\"en\") ? tables.en : tables.pl;\n}\n\n/**\n * Merges caller overrides over a table. Overrides apply regardless of the\n * locale; `undefined`/`null` entries are ignored so the default stays.\n */\nexport function mergeTexts<Key extends string>(\n table: TextTable<Key>,\n overrides?: Partial<TextTable<Key>>,\n): TextTable<Key> {\n const result: Record<string, string> = { ...table };\n\n if (overrides != null) {\n for (const [key, value] of Object.entries<string | undefined>(overrides)) {\n if (value != null) {\n result[key] = value;\n }\n }\n }\n\n return result as TextTable<Key>;\n}\n\n/** Locale table merged with the caller overrides. */\nexport function resolveTexts<Key extends string>(\n tables: LocaleTables<Key>,\n locale: string,\n overrides?: Partial<TextTable<Key>>,\n): TextTable<Key> {\n return mergeTexts(pickLocaleTable(tables, locale), overrides);\n}\n\n/** Looks up a single text. Unknown keys return the key itself. */\nexport function lookupText<Key extends string>(\n texts: TextTable<Key>,\n key: Key,\n): string {\n return (texts as Record<string, string | undefined>)[key] ?? key;\n}\n","import {\n lookupText,\n resolveTexts,\n type LocaleTables,\n} from \"@/src/lib/texts\";\n\n/**\n * Every string the checkout renders. Pass a partial object through the\n * `texts` prop of `BitsnapCheckout` to override any of them, whatever the\n * locale.\n */\nexport type CheckoutTexts = {\n /** Drawer title. */\n cart: string;\n /** Shown when the cart has no products. */\n emptyCart: string;\n /** Label next to the total price. */\n total: string;\n /** Delivery note next to the total price. */\n delivery: string;\n /** Country selector placeholder. */\n chooseCountry: string;\n /** Checkout button label. */\n nextStep: string;\n /** Error shown when some products are out of stock. */\n unavailableProducts: string;\n /** Error shown when the checkout fails and the server gave no reason. */\n checkoutFailed: string;\n /** Error shown when the shop has no payment gateway connected. */\n noPaymentGateway: string;\n /** Error shown when the payment gateway of the shop is not set up. */\n gatewayNotConfigured: string;\n /** Error shown when delivery of the shop is not set up. */\n shippingNotConfigured: string;\n /** Error shown when the cart mixes subscriptions with one-time products. */\n mixedRecurring: string;\n /** Error shown when the cart currency cannot be paid in. */\n currencyUnsupported: string;\n /** Error shown when a price changed after the product was added. */\n priceChanged: string;\n /** Accessible name of the close button of the drawer. */\n close: string;\n /** Remove button of a cart line (also read together with the product name). */\n remove: string;\n /** Accessible name of the quantity control and its input. */\n quantity: string;\n /** Accessible name of the \"+\" quantity button. */\n increaseQuantity: string;\n /** Accessible name of the \"-\" quantity button. */\n decreaseQuantity: string;\n /** Accessible name of the cart button when it only shows an icon. */\n openCart: string;\n /** Hidden label of the number of products badge; the number is appended after a colon. */\n cartItemsCount: string;\n /** Label before the lowest price of the last 30 days; the price is appended. */\n lowestPrice30Days: string;\n /** Shown instead of the lowest price when the price has no history. */\n noPriceHistory: string;\n /** Error shown when redirecting to the payment failed. */\n redirectFailed: string;\n /** Error shown when a subscription is added to the cart. */\n subscriptionUnsupported: string;\n /** Country search placeholder. */\n searchCountry: string;\n /** Shown when the country search has no match. */\n noCountriesFound: string;\n /** Hint under the checkout button when no country is chosen. */\n countryRequired: string;\n /** Title of the Apple Pay and Google Pay sheet total. */\n paymentForCart: string;\n /** Coupon label in the Google Pay sheet; the code is appended. */\n coupon: string;\n /** Note under the cart total. */\n extrasCalculatedNext: string;\n /** Error shown when the products of the cart could not be loaded. */\n loadFailed: string;\n /** Button that loads the cart again. */\n retry: string;\n /** Heading of the payment method choice (shown only when the shop offers paying by hand). */\n paymentMethodLegend: string;\n /** Option that pays through the shop's online gateway. */\n paymentMethodOnline: string;\n /** Hint under the online option. */\n paymentMethodOnlineDescription: string;\n /** Manual option when the seller takes bank transfers only. */\n paymentMethodManualTransfer: string;\n /** Manual option when the seller takes BLIK transfers to a phone number only. */\n paymentMethodManualBlik: string;\n /** Manual option when the seller takes both. */\n paymentMethodManualBoth: string;\n /** What paying by hand means: the details come after the order is placed. */\n paymentMethodManualDescription: string;\n /** Shown with a selected manual option that includes BLIK to a phone number. */\n paymentMethodManualBlikNote: string;\n /** Cash on delivery option. */\n paymentMethodCod: string;\n /** Hint under the cash on delivery option. */\n paymentMethodCodDescription: string;\n /** Error shown when the shop refused cash on delivery for the order. */\n paymentMethodCodUnavailable: string;\n /** Status while the provider confirms a payment started from an express button. */\n expressPending: string;\n /** Status after the provider confirmed the payment. */\n expressConfirmed: string;\n /** Status when the provider reports a failed payment. */\n expressFailed: string;\n /** Status when the buyer cancelled the provider's payment flow. */\n expressCancelled: string;\n /** Shown while the payment is still unconfirmed after a page return. */\n expressPendingLong: string;\n /** Error shown when the provider's button could not be loaded. */\n expressLoadFailed: string;\n /** Error shown when the cart cannot be paid with this provider right now. */\n expressCartUnavailable: string;\n /** Error shown when another tab/provider changed the same cart line. */\n expressCartConflict: string;\n /** Shown when the server total changed between mounting and paying. */\n expressPriceChanged: string;\n /** Error shown when a product could not be added before the InPost binding. */\n expressProductUnavailable: string;\n};\n\nexport type CheckoutTextKey = keyof CheckoutTexts;\n\nexport const CHECKOUT_TEXT_TABLES: LocaleTables<CheckoutTextKey> = {\n en: {\n cart: \"Cart\",\n emptyCart: \"Your cart is empty.\",\n total: \"Total:\",\n delivery: \"+ delivery\",\n chooseCountry: \"Choose a country\",\n nextStep: \"Next step\",\n unavailableProducts: \"Not all products are available.\",\n checkoutFailed: \"Something went wrong. Please try again later.\",\n noPaymentGateway:\n \"This shop doesn't accept online payments yet. Try again later or contact the seller.\",\n gatewayNotConfigured:\n \"Payments in this shop are not set up correctly. Try again later or contact the seller.\",\n shippingNotConfigured:\n \"Delivery in this shop is not configured yet. Try again later or contact the seller.\",\n mixedRecurring:\n \"Subscriptions and one-time products cannot be paid for together. Pay for them in separate orders.\",\n currencyUnsupported:\n \"The shop doesn't accept payments in this currency. Contact the seller.\",\n priceChanged: \"The product price has changed. Refresh the page to see the current price.\",\n close: \"Close cart\",\n remove: \"Remove\",\n quantity: \"Quantity\",\n increaseQuantity: \"Increase quantity\",\n decreaseQuantity: \"Decrease quantity\",\n openCart: \"Open cart\",\n cartItemsCount: \"Items in cart\",\n lowestPrice30Days: \"Lowest price in the last 30 days:\",\n noPriceHistory: \"No price data for the last 30 days\",\n redirectFailed: \"Could not redirect to the payment. Please try again later.\",\n subscriptionUnsupported: \"Subscriptions cannot be added to the cart yet.\",\n searchCountry: \"Find a country\",\n noCountriesFound: \"No countries found\",\n countryRequired: \"Choose a country to continue.\",\n paymentForCart: \"Cart payment\",\n coupon: \"Coupon\",\n extrasCalculatedNext:\n \"Discounts, shipping and taxes are calculated at the next step\",\n loadFailed: \"Could not load your cart.\",\n retry: \"Try again\",\n paymentMethodLegend: \"How would you like to pay?\",\n paymentMethodOnline: \"Pay online\",\n paymentMethodOnlineDescription:\n \"Card, BLIK code or instant bank payment. You pay right away.\",\n paymentMethodManualTransfer: \"Bank transfer\",\n paymentMethodManualBlik: \"BLIK – transfer to a phone number\",\n paymentMethodManualBoth: \"Bank transfer or BLIK to a phone number\",\n paymentMethodManualDescription:\n \"You pay in your bank's app. We show the payment details after you place the order, and the order waits for your payment.\",\n paymentMethodManualBlikNote:\n \"This is not a BLIK code payment – you do not enter a 6‑digit code.\",\n paymentMethodCod: \"Cash on delivery\",\n paymentMethodCodDescription:\n \"You pay the courier in cash or by card when you receive the parcel.\",\n paymentMethodCodUnavailable:\n \"Cash on delivery is not available for this order. Choose another way to pay.\",\n expressPending: \"Confirming your payment…\",\n expressConfirmed: \"Payment confirmed. Thank you!\",\n expressFailed: \"The payment failed. Your cart is unchanged.\",\n expressCancelled: \"Payment cancelled. Your cart is unchanged.\",\n expressPendingLong:\n \"We are still confirming your payment. We will check again when you come back to this page.\",\n expressLoadFailed:\n \"Could not load this payment button. Try again later or use the regular checkout.\",\n expressCartUnavailable:\n \"This cart cannot be paid with this method right now. Try again later.\",\n expressCartConflict:\n \"Your cart changed in another tab or in the provider's app. Review the quantities and try again.\",\n expressPriceChanged:\n \"Your cart total changed. Check the new total and try again.\",\n expressProductUnavailable:\n \"This product cannot be paid for right now. Try again later.\",\n },\n pl: {\n cart: \"Koszyk\",\n emptyCart: \"Brak produktów w koszyku.\",\n total: \"Suma:\",\n delivery: \"+ dostawa\",\n chooseCountry: \"Wybierz kraj\",\n nextStep: \"Następny krok\",\n unavailableProducts: \"Nie wszystkie produkty są dostępne w magazynie.\",\n checkoutFailed: \"Coś poszło nie tak. Spróbuj ponownie później.\",\n noPaymentGateway:\n \"Ten sklep nie przyjmuje jeszcze płatności online. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n gatewayNotConfigured:\n \"Płatności w tym sklepie nie są poprawnie skonfigurowane. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n shippingNotConfigured:\n \"Dostawa w tym sklepie nie jest jeszcze skonfigurowana. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n mixedRecurring:\n \"Subskrypcji i produktów jednorazowych nie można opłacić razem. Opłać je w osobnych zamówieniach.\",\n currencyUnsupported:\n \"Sklep nie przyjmuje płatności w tej walucie. Skontaktuj się ze sprzedawcą.\",\n priceChanged: \"Cena produktu się zmieniła. Odśwież stronę, aby zobaczyć aktualną cenę.\",\n close: \"Zamknij koszyk\",\n remove: \"Usuń\",\n quantity: \"Ilość\",\n increaseQuantity: \"Zwiększ ilość\",\n decreaseQuantity: \"Zmniejsz ilość\",\n openCart: \"Otwórz koszyk\",\n cartItemsCount: \"Produktów w koszyku\",\n lowestPrice30Days: \"Najniższa cena z 30 dni:\",\n noPriceHistory: \"Brak danych o cenie z ostatnich 30 dni\",\n redirectFailed:\n \"Nie udało się przekierować do płatności. Spróbuj ponownie później.\",\n subscriptionUnsupported: \"Subskrypcji nie można jeszcze dodać do koszyka.\",\n searchCountry: \"Znajdź kraj\",\n noCountriesFound: \"Nie znaleziono krajów\",\n countryRequired: \"Wybierz kraj, aby przejść dalej.\",\n paymentForCart: \"Płatność za koszyk\",\n coupon: \"Kupon\",\n extrasCalculatedNext: \"Rabaty, dostawa i podatki w następnym kroku\",\n loadFailed: \"Nie udało się wczytać koszyka.\",\n retry: \"Spróbuj ponownie\",\n paymentMethodLegend: \"Jak chcesz zapłacić?\",\n paymentMethodOnline: \"Zapłać online\",\n paymentMethodOnlineDescription:\n \"Karta, kod BLIK lub szybki przelew. Płacisz od razu.\",\n paymentMethodManualTransfer: \"Przelew bankowy\",\n paymentMethodManualBlik: \"BLIK – przelew na telefon\",\n paymentMethodManualBoth: \"Przelew lub BLIK na telefon\",\n paymentMethodManualDescription:\n \"Zapłacisz w aplikacji swojego banku. Dane do płatności pokażemy po złożeniu zamówienia, a zamówienie poczeka na Twoją wpłatę.\",\n paymentMethodManualBlikNote:\n \"To nie jest płatność kodem BLIK – nie wpisujesz 6‑cyfrowego kodu.\",\n paymentMethodCod: \"Płatność przy odbiorze\",\n paymentMethodCodDescription:\n \"Zapłacisz kurierowi gotówką lub kartą, gdy odbierzesz przesyłkę.\",\n paymentMethodCodUnavailable:\n \"Płatność przy odbiorze nie jest dostępna dla tego zamówienia. Wybierz inną formę płatności.\",\n expressPending: \"Potwierdzamy płatność…\",\n expressConfirmed: \"Płatność potwierdzona. Dziękujemy!\",\n expressFailed: \"Płatność się nie udała. Koszyk pozostał bez zmian.\",\n expressCancelled: \"Płatność została anulowana. Koszyk pozostał bez zmian.\",\n expressPendingLong:\n \"Nadal potwierdzamy Twoją płatność. Sprawdzimy ponownie, gdy wrócisz na tę stronę.\",\n expressLoadFailed:\n \"Nie udało się wczytać przycisku płatności. Spróbuj ponownie później lub skorzystaj ze zwykłego koszyka.\",\n expressCartUnavailable:\n \"Tego koszyka nie można teraz opłacić tą metodą. Spróbuj ponownie później.\",\n expressCartConflict:\n \"Koszyk zmienił się w innej karcie lub w aplikacji przewoźnika. Sprawdź ilości i spróbuj ponownie.\",\n expressPriceChanged:\n \"Suma koszyka się zmieniła. Sprawdź nową sumę i spróbuj ponownie.\",\n expressProductUnavailable:\n \"Nie można teraz zapłacić za ten produkt. Spróbuj ponownie później.\",\n },\n};\n\n/** Default texts for a locale merged with the caller overrides. */\nexport function resolveCheckoutTexts(\n locale: string,\n overrides?: Partial<CheckoutTexts>,\n): CheckoutTexts {\n return resolveTexts(CHECKOUT_TEXT_TABLES, locale, overrides);\n}\n\nexport function getCheckoutText(\n key: CheckoutTextKey,\n locale: string,\n overrides?: Partial<CheckoutTexts>,\n): string {\n return lookupText(resolveCheckoutTexts(locale, overrides), key);\n}\n","import { pickLocaleTable } from \"@/src/lib/texts\";\nimport { CHECKOUT_TEXT_TABLES } from \"./texts\";\n\nexport const DEFAULT_LOCALE = \"pl-PL\" as const;\nconst localeStorageKey = \"bitsnap-locale\";\n\nlet activeLocale: string | undefined;\n\nexport function setLocale(locale?: string): void {\n const value = locale?.trim();\n activeLocale = value\n ? value.toLowerCase() === \"en\"\n ? \"en-US\"\n : value.toLowerCase() === \"pl\"\n ? DEFAULT_LOCALE\n : value\n : undefined;\n if (typeof localStorage !== \"undefined\") {\n if (activeLocale == null) {\n localStorage.removeItem(localeStorageKey);\n } else {\n localStorage.setItem(localeStorageKey, activeLocale);\n }\n }\n}\n\nexport function getLocale(): string {\n if (activeLocale != null) {\n return activeLocale;\n }\n if (typeof localStorage !== \"undefined\") {\n return localStorage.getItem(localeStorageKey) ?? DEFAULT_LOCALE;\n }\n return DEFAULT_LOCALE;\n}\n\nexport function translate(key: string, locale: string = getLocale()): string {\n return (\n (pickLocaleTable(CHECKOUT_TEXT_TABLES, locale) as Record<string, string>)[\n key\n ] ?? key\n );\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import{C as Tn,F as An,G as Rn,H as Dn,I as Mn,J as On,K as Un,a as cr,b as gn,c as Lt,d as We,e as At,f as yn,h as hn,i as bn,j as Pn,k as vn,p as Nn,q as In,r as Sn,t as En,u as Ln}from"./chunk-KO7Z3E23.mjs";import{b as ve}from"./chunk-LRUBBPTV.mjs";import{e as F,f as Ae,g as ae,k as L,l as Tt,n as wn,o as Je,p as Cn}from"./chunk-TMEII7BM.mjs";import{a as pn}from"./chunk-HKRH6FI6.mjs";import{a as mt,b as kn,c as xn,d as Ye}from"./chunk-XEXPQFKN.mjs";import{a as sr,g as ut,h as pt}from"./chunk-CUPG4B5W.mjs";import{a as or,b as ar,d as Nt,e as ir,f as cn,g as un}from"./chunk-2G46TAUX.mjs";import{a as H}from"./chunk-5R6AGO3Z.mjs";import{a as rr,b as dn,c as nr,e as Q,f as fn}from"./chunk-EXC5Z5VM.mjs";import{h as lr,l as It,m as St,n as Ve,o as mn}from"./chunk-J6WKSO33.mjs";import{a as Et,c as Te,e as dr,f as A}from"./chunk-OFPRIENJ.mjs";import{useAutoAnimate as ka}from"@formkit/auto-animate/react";import{useEffect as Hn,useMemo as gr,useRef as qn,useState as xa}from"react";import{jsx as ft}from"react/jsx-runtime";function Re({className:e,...t}){return ft("div",{"data-slot":"card",className:H("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function je({className:e,...t}){return ft("div",{"data-slot":"card-header",className:H("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function Fe({className:e,...t}){return ft("div",{"data-slot":"card-title",className:H("leading-none font-semibold",e),...t})}function _n({className:e,...t}){return ft("div",{"data-slot":"card-description",className:H("text-muted-foreground text-sm",e),...t})}function De({className:e,...t}){return ft("div",{"data-slot":"card-content",className:H("px-6",e),...t})}import{CircleCheck as ua}from"lucide-react";import{useId as pa}from"react";import{jsx as q,jsxs as X}from"react/jsx-runtime";var ma="text-muted-foreground text-xs leading-5",fa="dark:border-foreground/30 dark:focus-visible:border-foreground/70 dark:focus-visible:ring-foreground/25 dark:aria-invalid:border-destructive-foreground dark:aria-invalid:ring-destructive-foreground/30",ga=new Set(["invalidEmail","emailNotFound","deliveryUnavailable"]),ur="inline-flex min-h-11 items-center px-1 text-sm underline underline-offset-4 hover:no-underline focus-visible:ring-[3px] focus-visible:ring-ring/50 rounded-sm outline-none disabled:opacity-50 disabled:no-underline";function zn({login:e,texts:t,allowHaveCode:n=!0,emailPlaceholder:o,emailInputId:r,codeInputId:a,className:i,buttonClassName:d,children:c}){let l=pa(),f=r??`${l}-email`,P=a??`${l}-code`,x=`${l}-notice`,I=`${l}-hint`,{notice:g}=e,u=g?.kind==="error",m=e.busy==="send",p=e.busy==="verify",b=e.busy==="resend",S=H("h-11 w-full",d),U=g?.kind==="success",N=X("div",{id:x,className:"min-h-10 text-sm leading-5",children:[q("p",{role:"alert",className:"font-medium text-red-700 dark:text-red-400",children:u?g.text:null}),X("p",{role:"status",className:H("flex items-start gap-1.5",U?"font-medium text-emerald-700 dark:text-emerald-400":"text-foreground"),children:[U&&q(ua,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0"}),q("span",{children:g!=null&&!u?g.text:null})]})]}),ce=u&&e.step==="email"&&(g.failure==null||ga.has(g.failure)),Se=q("p",{className:"sr-only",role:"status","aria-live":"polite",children:e.announcement}),oe=X("div",{className:"grid gap-2",children:[q(We,{htmlFor:f,children:t.emailLabel}),q(Tt,{id:f,ref:e.emailRef,name:"email",type:"email",autoComplete:"email",inputMode:"email",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,autoFocus:!0,required:!0,className:H("h-11 text-base disabled:opacity-100 disabled:text-foreground/70",fa),placeholder:o??t.emailPlaceholder,value:e.email,disabled:e.isBusy,"aria-invalid":ce?!0:void 0,"aria-describedby":x,onChange:Z=>e.setEmail(Z.target.value)})]});if(e.step==="email")return X("form",{noValidate:!0,className:H("flex flex-col gap-4",i),onSubmit:Z=>{Z.preventDefault(),e.sendCode()},children:[Se,oe,N,X(L,{type:"submit",disabled:e.isBusy,"aria-busy":m,className:S,children:[m&&q(At,{"aria-hidden":!0}),m?t.sending:t.sendCode]}),n&&X("p",{className:"flex flex-wrap items-center justify-center text-center text-sm",children:[t.haveCodePrompt!==""&&q("span",{children:t.haveCodePrompt}),q("button",{type:"button",className:ur,disabled:e.isBusy,onClick:e.haveCode,children:t.haveCode})]})]});let[te,fe]=t.codeSentTo.split("{email}"),E=e.dead!=null,ge=E?t.resendNew:e.secondsLeft>0?bn(t.resendIn,{seconds:e.secondsLeft}):t.resend;return X("form",{noValidate:!0,className:H("flex flex-col gap-4",i),onSubmit:Z=>{Z.preventDefault(),e.submitCode()},children:[Se,e.needsEmail?oe:X("div",{className:"flex flex-wrap items-center justify-between gap-x-2",children:[X("p",{className:"min-w-0 flex-[1_1_14rem] text-sm leading-5 break-words",children:[te,q("strong",{className:"font-semibold",children:e.email}),"\u2060",fe]}),q("button",{type:"button",className:H(ur,"-ml-1 shrink-0"),disabled:e.isBusy,onClick:e.changeEmail,children:t.changeEmail})]}),c,X("div",{className:"grid gap-2",children:[q(We,{htmlFor:P,children:t.codeLabel}),q(vn,{id:P,name:"code",inputRef:e.codeRef,value:e.code,onChange:e.setCode,onComplete:Z=>void e.submitCode(Z),disabled:e.isBusy||E,invalid:u&&!e.needsEmail,"aria-describedby":`${x} ${I}`}),X("p",{id:I,className:ma,children:[t.validity," ",t.spamHint]})]}),N,X(L,{type:"submit",disabled:e.isBusy||E,"aria-busy":p,className:S,children:[p&&q(At,{"aria-hidden":!0}),p?t.verifying:t.verify]}),e.needsEmail?q("div",{className:"flex justify-center",children:q("button",{type:"button",className:ur,disabled:e.isBusy,onClick:e.changeEmail,children:t.noCode})}):X(L,{type:"button",variant:E?"default":"outline",disabled:e.isBusy||!E&&e.secondsLeft>0,"aria-busy":b,className:E?S:"h-11 w-full",onClick:()=>void e.resend(),children:[b&&q(At,{"aria-hidden":!0}),ge]})]})}function pr(e){switch(e){case 1:return"emailNotFound";case 2:return"invalidEmail";case 3:return"wrongCode";case 14:return"expired";case 15:return"tooManyAttempts";case 13:return"rateLimited";case 16:return"captchaRequired";case 17:return"captchaInvalid";case 12:return"deliveryFailed";case 11:return"deliveryUnavailable";default:return"unknown"}}var ya={pl:{title:"Zaloguj si\u0119",description:"Wy\u015Blemy do Ciebie kod na maila, dzi\u0119ki kt\xF3remu si\u0119 zalogujesz.",codeTitle:"Wpisz kod z maila",codeDescription:"Kod ma 6 cyfr."},en:{title:"Sign in",description:"We will email you a code that signs you in.",codeTitle:"Enter the code from the email",codeDescription:"The code has 6 digits."}};function jn(e=A(),t){return{...hn(e,t),...Et(ya,e),...ha(t,["title","description","codeTitle","codeDescription"])}}function ha(e,t){let n={};for(let o of t){let r=e?.[o];r!=null&&(n[o]=r)}return n}var ba="return_url",mr="__return_url",Pa="accessToken";function gt(e){let t=new URLSearchParams(e).get(ba);return t?Fn(t):null}function yt(e){typeof window>"u"||(e?window.sessionStorage.setItem(mr,e):window.sessionStorage.removeItem(mr))}function Ze(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(mr);return e?Fn(e):null}function va(e,t){return t.some(n=>{if(e===n)return!0;let o=new URL(n).hostname,r=new URL(e).hostname;return r.endsWith(`.${o}`)||r===o})}function Fn(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!va(t.origin,pt())?null:t.toString()}catch{return null}}function Qe(e,t){let n=new URL(e);return n.searchParams.set(Pa,t),n.toString()}import{jsx as ie,jsxs as fr}from"react/jsx-runtime";if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];pt().length===0&&ut(Array.from(new Set(t)))}var wa=({texts:e,projectID:t,host:n,locale:o,logo:r})=>{let[a,i]=xa(!1),d=qn(void 0),c=qn(""),l=gr(()=>()=>new Promise(b=>{i(!0);let S=window.setTimeout(()=>{d.current=void 0,i(!1),b(!1)},5*60*1e3);d.current=U=>{window.clearTimeout(S),d.current=void 0,i(!1),c.current=U??"",b(U!==null)}}),[]),f=St(),{mutateAsync:P}=ae(F.publicApi.userPanelLogin),{mutateAsync:x}=ae(F.publicApi.userPanelLoginWithCode),I=gr(()=>({async send(b){try{let S=await P({email:b,turnstileToken:c.current});return c.current="",S.result.case==="success"?{ok:!0,retryIn:S.result.value.retryIn||void 0,challengeId:S.result.value.challengeId||void 0}:{ok:!1,kind:pr(S.result.case==="failure"?S.result.value:0)}}catch(S){return{ok:!1,kind:cr(S),cause:S}}},async verify({email:b,code:S,challengeId:U}){try{let N=await x({code:parseInt(S,10),email:b,challengeId:U});return N.result.case==="accessToken"&&N.result.value?{ok:!0,value:{accessToken:N.result.value}}:{ok:!1,kind:pr(N.result.case==="failure"?N.result.value:0)}}catch(N){return{ok:!1,kind:cr(N),cause:N}}}}),[P,x]),g=Pn({adapter:I,texts:e,beforeSend:l,storageKey:yn("panel",t,n),onVerified:({accessToken:b},S)=>{f.track("panel_login",{}),kn(t,b,S,n);let U=typeof window<"u"?Ze():null;setTimeout(()=>{if(U){window.location.href=Qe(U,b);return}window.location.reload()},100)}}),u=g.step==="code",m=u&&!g.needsEmail?e.codeTitle:e.title,p=u&&!g.needsEmail?e.codeDescription:e.description;return ie("main",{className:"mx-auto flex w-full max-w-sm flex-1 flex-col justify-start pt-4 sm:pt-[12vh]",children:fr(Re,{children:[ie(Lt,{projectId:t,locale:o,className:"px-4 sm:px-6",...r}),fr(je,{className:"px-4 sm:px-6",children:[ie(Fe,{role:"heading","aria-level":1,className:"text-2xl",children:m}),ie(_n,{children:p})]}),fr(De,{className:"px-4 sm:px-6",children:[ie(zn,{login:g,texts:e,emailInputId:"email",codeInputId:"verify-code"}),a&&ie(pn,{action:"panel_login",locale:o,onToken:b=>d.current?.(b),onFailure:()=>d.current?.(null)})]})]})})},Ca=({analytics:e,texts:t,locale:n,showLogo:o,logoUrl:r,logoDarkUrl:a})=>{let{theme:i,allowedReturnOrigins:d,projectID:c,host:l}=ve(),f=Ve(c,e,"panel"),P=gr(()=>jn(n??A(),t),[n,t]),x={"--button-background-color":i?.colors?.brand??"#FFFFFF","--button-background-color-dark":i?.colors?.brandDark??"#000000","--button-text-color":i?.colors?.brandDark??"#000000","--button-text-color-dark":i?.colors?.brand??"#FFFFFF"},[I]=ka({duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1});return Hn(()=>{typeof window>"u"||mt(c,l)!=null&&(window.location.href=window.location.href.replaceAll("login",""))},[c,l]),Hn(()=>{if(typeof window>"u"||window.parent!==window)return;let g=gt(window.location.search);g&&yt(g);let u=g??Ze();if(!u)return;let m=mt(c,l);m&&(window.location.href=Qe(u,m))},[d,c,l]),ie(It,{value:f,children:ie("div",{className:"bg-white text-black dark:bg-black dark:text-white",children:ie("div",{className:"font-inter flex min-h-screen w-full flex-col p-4",style:x,ref:I,children:ie(wa,{texts:P,projectID:c,host:l,locale:n,logo:{showLogo:o,logoUrl:r??i?.logoURL,logoDarkUrl:a??i?.logoDarkURL}})})})})},Na=(e={})=>ie(Ca,{...e});import{useAutoAnimate as us}from"@formkit/auto-animate/react";import{useEffect as Ut,useState as Eo}from"react";import{useState as Ia,useCallback as Sa,useEffect as Ea}from"react";function $n(e){let[t,n]=Ia(()=>{if(typeof window>"u")return e;let r=new URLSearchParams(window.location.search),a={};return Object.keys(e).forEach(i=>{let d=r.get(i);if(d!==null)try{a[i]=JSON.parse(d)}catch{a[i]=d}}),{...e,...a}}),o=Sa(r=>{n(a=>{let i={...a,...r};if(typeof window<"u"){let d=new URLSearchParams;Object.keys(i).forEach(l=>{let f=i[l];f!=null&&d.set(l,JSON.stringify(f))});let c=`${window.location.pathname}?${d.toString()}`;window.history.pushState({},"",c)}return i})},[]);return Ea(()=>{let r=()=>{let a=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(d=>{let c=a.get(d);if(c!==null)try{i[d]=JSON.parse(c)}catch{i[d]=c}}),n({...e,...i})};return window.addEventListener("popstate",r),()=>window.removeEventListener("popstate",r)},[e]),[t,o]}function Bn(e,t){if(e!=null)return e;let n=t?.trim();if(!(n==null||n===""))return{tokens:wn(n)}}var La={pl:{returnsNavLabel:"Zwroty",openCourse:"Otw\xF3rz kurs",libraryNavLabel:"Biblioteka",messagesNavLabel:"Wiadomo\u015Bci",ordersNavLabel:"Zam\xF3wienia",accountNavLabel:"Konto",navigationLabel:"Panel klienta",logout:"Wyloguj si\u0119",profileHeading:"Profil",emailLabel:"E-mail",noData:"Brak danych",languageLabel:"J\u0119zyk",polishLanguage:"Polski",englishLanguage:"English",plansHeading:"Plany",plansUnavailable:"Plany nie s\u0105 obecnie dost\u0119pne w panelu.",notificationsHeading:"Powiadomienia",notificationsUnavailable:"Ustawienia powiadomie\u0144 nie s\u0105 obecnie dost\u0119pne w panelu.",ordersHeading:"Historia zam\xF3wie\u0144",ordersDescription:"Twoje zam\xF3wienia",ordersEmpty:"Brak zam\xF3wie\u0144.",ordersError:"Nie uda\u0142o si\u0119 pobra\u0107 zam\xF3wie\u0144.",retry:"Spr\xF3buj ponownie",orderLabel:"Zam\xF3wienie",customerLabel:"Klient",dateLabel:"Data",ordersEnd:"To ju\u017C wszystkie Twoje zam\xF3wienia.",previousPage:"Poprzednia strona",nextPage:"Nast\u0119pna strona",paginationLabel:"Strony zam\xF3wie\u0144",statusDraft:"Szkic",statusUnpaid:"Nieop\u0142acone",statusPaid:"Op\u0142acone",statusOverdue:"Zaleg\u0142e",statusCancelled:"Anulowane",statusCompleted:"Zako\u0144czone",statusProcessing:"Przetwarzane",statusRefunded:"Zwr\xF3cone"},en:{returnsNavLabel:"Returns",openCourse:"Open the course",libraryNavLabel:"Library",messagesNavLabel:"Messages",ordersNavLabel:"Orders",accountNavLabel:"Account",navigationLabel:"Customer panel",logout:"Log out",profileHeading:"Profile",emailLabel:"Email",noData:"No data",languageLabel:"Language",polishLanguage:"Polski",englishLanguage:"English",plansHeading:"Plans",plansUnavailable:"Plans are currently unavailable in the panel.",notificationsHeading:"Notifications",notificationsUnavailable:"Notification settings are currently unavailable in the panel.",ordersHeading:"Order history",ordersDescription:"Your orders",ordersEmpty:"No orders yet.",ordersError:"Could not load your orders.",retry:"Try again",orderLabel:"Order",customerLabel:"Customer",dateLabel:"Date",ordersEnd:"You\u2019ve reached the end of your orders.",previousPage:"Previous page",nextPage:"Next page",paginationLabel:"Order pages",statusDraft:"Draft",statusUnpaid:"Unpaid",statusPaid:"Paid",statusOverdue:"Overdue",statusCancelled:"Cancelled",statusCompleted:"Completed",statusProcessing:"Processing",statusRefunded:"Refunded"}};function pe(e=A()){return Et(La,e)}import{jsx as Kn,jsxs as Ta}from"react/jsx-runtime";function yr({}){let e=pe();return Ta("section",{children:[Kn("h3",{className:"text-2xl",children:e.notificationsHeading}),Kn("p",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:e.notificationsUnavailable})]})}import{useState as Aa}from"react";import{Fragment as Ua,jsx as O,jsxs as W}from"react/jsx-runtime";var Ra=e=>new Date(e*1e3).toLocaleDateString(A(),{year:"numeric",month:"short",day:"numeric"}),Da=(e,t)=>new Intl.NumberFormat(A(),{style:"currency",currency:t.toUpperCase()}).format(e/100),Ma={draft:"text-neutral-600 dark:text-neutral-400",unpaid:"text-amber-700 dark:text-amber-300",paid:"text-green-700 dark:text-green-400",overdue:"text-red-700 dark:text-red-400",cancelled:"text-neutral-600 line-through dark:text-neutral-400",completed:"text-green-700 dark:text-green-400",processing:"text-blue-700 dark:text-blue-400",refunded:"text-purple-700 dark:text-purple-400"};function Oa({openOrderDetails:e,projectID:t,accessToken:n}){let o=pe(),r={draft:o.statusDraft,unpaid:o.statusUnpaid,paid:o.statusPaid,overdue:o.statusOverdue,cancelled:o.statusCancelled,completed:o.statusCompleted,processing:o.statusProcessing,refunded:o.statusRefunded},[a,i]=Aa(0),d=20,{data:c,isFetching:l,isError:f,refetch:P}=Ae(F.publicApi.getOrders,{projectId:t,accessToken:n,offset:a,limit:d}),x=c?.orders??[],I=c?.totalCount??0,g=Math.floor(a/d)+1,u=Math.ceil(I/d),m=p=>{i(p)};return W(Ua,{children:[O("h3",{className:"text-2xl",children:o.ordersHeading}),O("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:o.ordersDescription}),l?O("div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((p,b)=>W("div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[W("div",{className:"flex items-center justify-between gap-3",children:[W("div",{className:"space-y-2",children:[O(Je,{className:"h-4 w-24"}),O(Je,{className:"h-3 w-32"})]}),W("div",{className:"space-y-2 text-right",children:[O(Je,{className:"ml-auto h-4 w-16"}),O(Je,{className:"ml-auto h-3 w-12"})]})]}),O("div",{className:"mt-3",children:O(Je,{className:"h-3 w-40"})})]},b))}):f?W("div",{role:"alert",className:"mt-6 space-y-3",children:[O("p",{children:o.ordersError}),O(L,{onClick:()=>void P(),className:"min-h-11 focus-visible:outline-2 focus-visible:outline-current",children:o.retry})]}):x.length===0?O("div",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:o.ordersEmpty}):W("div",{children:[O("div",{className:"mt-6 flex w-full flex-col gap-3",children:x.map(p=>W("button",{onClick:()=>e(p.id),className:"block min-h-11 focus-visible:outline-2 focus-visible:outline-current rounded-xl bg-white p-4 text-left shadow-sm transition-colors hover:bg-neutral-50 dark:bg-neutral-800 dark:hover:bg-neutral-700",children:[W("div",{className:"flex items-center justify-between gap-3",children:[W("div",{className:"min-w-0 break-words",children:[W("p",{className:"font-medium",children:[o.orderLabel," #",p.id]}),O("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:p.customerName||o.customerLabel})]}),W("div",{className:"shrink-0 text-right",children:[O("p",{className:"font-semibold",children:Da(p.totalAmount,p.currency)}),O("p",{className:`text-xs font-medium ${Ma[p.status]??"text-neutral-400"}`,children:r[p.status]??p.status})]})]}),O("div",{className:"mt-2 flex items-center justify-between gap-3 text-xs text-neutral-500 dark:text-neutral-400",children:W("span",{children:[o.dateLabel,":"," ",p.createdAt?Ra(Number(p.createdAt.seconds)):"-"]})})]},p.id))}),g>=u&&O("p",{className:"mt-6 text-center text-sm text-neutral-600 dark:text-neutral-400",children:o.ordersEnd}),u>1&&W("nav",{"aria-label":o.paginationLabel,className:"mt-4 flex flex-wrap items-center justify-center gap-2",children:[g>1&&O(L,{variant:"outline",className:"min-h-11",onClick:()=>m(a-d),children:o.previousPage}),Array.from(new Set([1,g-1,g,g+1,u])).filter(p=>p>0&&p<=u).sort((p,b)=>p-b).map(p=>O(L,{variant:p===g?"secondary":"ghost",className:"min-h-11 min-w-11","aria-current":p===g?"page":void 0,onClick:()=>m((p-1)*d),children:p},p)),g<u&&O(L,{variant:"outline",className:"min-h-11",onClick:()=>m(a+d),children:o.nextPage})]})]})]})}var Gn=Oa;import{jsx as Vn,jsxs as _a}from"react/jsx-runtime";function hr({projectID:e}){let t=pe();return _a("section",{children:[Vn("h3",{className:"text-2xl",children:t.plansHeading}),Vn("p",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:t.plansUnavailable})]})}import{useEffect as za,useState as br}from"react";import{jsx as se,jsxs as Ha}from"react/jsx-runtime";function ja(e,t,n,o){typeof window>"u"||(t&&Ye(n,o),window.location.href=e)}function Fa({projectID:e,host:t,loginURL:n,screen:o,params:r,setParams:a,setActiveScreen:i}){let{status:d,exchangeError:c}=En("PanelReturns"),l=Sn(),f=d==="anonymous"&&(c==null||Nn(c));za(()=>{f&&ja(n,c!=null,e,t)},[f,n,c,e,t]);let[P,x]=br("orders"),[I,g]=br({items:[],note:""}),[u,m]=br();if(d==="anonymous"&&!f)return Ha("div",{role:"alert",className:"flex flex-col items-start gap-3",children:[se("p",{className:"text-sm",children:l(In(c))}),se(L,{type:"button",onClick:()=>window.location.reload(),children:l("errorRetry")})]});if(d!=="authenticated")return se(Tn,{});let p=b=>{x(b),a({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(o==="return-details"&&r.returnId)return se(Un,{returnId:r.returnId,onBack:()=>p("myReturns")});if(P==="myReturns")return se(On,{onBack:()=>p("orders"),onSelectReturn:b=>{a({state:"return-details",returnId:b,orderId:void 0}),i("return-details")}});if(P==="result"&&u!=null)return se(Mn,{returnId:u,onContinue:()=>p("orders"),onOpenMyReturns:()=>p("myReturns")});if(r.orderId){let b=r.orderId;return P==="confirmation"?se(Dn,{orderId:b,items:I.items,note:I.note,onBack:()=>x("orders"),onSubmitted:S=>{m(S),g({items:[],note:""}),x("result"),a({orderId:void 0})}}):se(Rn,{orderId:b,initialItems:I.items.length>0?I.items:void 0,initialNote:I.note,onBack:()=>{g({items:[],note:""}),a({orderId:void 0})},onContinue:S=>{g(S),x("confirmation")}})}return se(An,{showLogout:!1,onSelectOrder:b=>{g({items:[],note:""}),x("orders"),a({orderId:b})},onOpenMyReturns:()=>p("myReturns")})}function Pr({accessToken:e,appearance:t,texts:n,...o}){return se(Ln,{projectID:o.projectID,host:o.host,appearance:t,texts:n,panelAccessToken:e,children:se(Fa,{...o})})}import{lazy as Si,Suspense as Ei,useEffect as Ir,useState as Li}from"react";import{BookOpen as Ti,Files as Ai,Headphones as Ri,MessageCircle as Di,Ticket as Mi,Users as Oi}from"lucide-react";var qa={hello:"Hej \u{1F44B}",intro:"Poni\u017Cej znajdziesz swoje produkty",loading:"\u0141adowanie produkt\xF3w\u2026",empty:"Nie masz jeszcze produkt\xF3w w tym sklepie. Twoje zakupy pojawi\u0105 si\u0119 tutaj.",audio:"Audio",files:"Pliki",course:"Kurs",ticket:"Bilet",chat:"Czat",community:"Spo\u0142eczno\u015B\u0107",openMessages:"Otw\xF3rz wiadomo\u015Bci",listen:"S\u0142uchaj",openCourse:"Otw\xF3rz kurs",downloadFiles:"Pobierz pliki",showTicket:"Poka\u017C bilet",back:"Wr\xF3\u0107",yourFiles:"Twoje pliki",download:"Pobierz",retry:"Spr\xF3buj ponownie",fileError:"Nie uda\u0142o si\u0119 wczyta\u0107 plik\xF3w.",noFiles:"Brak plik\xF3w do pobrania.",ticketInfo:"Tw\xF3j zakupiony bilet",file:"Plik"},$a={hello:"Hi \u{1F44B}",intro:"Your products are below",loading:"Loading products\u2026",empty:"You have no products in this shop yet. Your purchases will show up here.",audio:"Audio",files:"Files",course:"Course",ticket:"Ticket",chat:"Chat",community:"Community",openMessages:"Open messages",listen:"Listen",openCourse:"Open course",downloadFiles:"Download files",showTicket:"Show ticket",back:"Back",yourFiles:"Your files",download:"Download",retry:"Try again",fileError:"Your files could not be loaded.",noFiles:"No files to download.",ticketInfo:"Your purchased ticket",file:"File"};function Xe(){return A().toLowerCase().startsWith("en")?$a:qa}import{jsx as Va}from"react/jsx-runtime";var Ba=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,Ka=e=>[...e.matchAll(Ba)].map(n=>({url:n[0],startIndex:n.index,endIndex:n.index+n[0].length-1})),Ga=(e,t)=>{let n="",o=0;t.sort((r,a)=>r.startIndex-a.startIndex);for(let{startIndex:r,endIndex:a,replacementText:i}of t)n+=e.slice(o,r),n+=i,o=a+1;return n+=e.slice(o),n},Wn=e=>{let t=Ka(e);return Va("p",{dangerouslySetInnerHTML:{__html:Ga(e,t.map(n=>(n.replacementText=`<a key=${n.url} href=${n.url} style="text-decoration: underline;" target="_blank">
2
+ ${n.url}
3
+ </a>`,n)))}})};import{fromJsonString as Ui}from"@bufbuild/protobuf";import{useAutoAnimate as vi}from"@formkit/auto-animate/react";import{ChevronLeft as ki,Download as xi}from"lucide-react";import{useEffect as lo,useRef as co,useState as qe}from"react";import si from"hls.js";import{Pause as li,Play as di,SkipBack as ci,SkipForward as ui}from"lucide-react";import{forwardRef as pi,useEffect as He,useImperativeHandle as mi,useRef as G,useState as we}from"react";import{jsx as vr,jsxs as Ya}from"react/jsx-runtime";function Wa(){return Ya("div",{className:"flex items-center gap-2",children:[vr("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),vr("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),vr("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var ke=Wa;import Ja from"hls.js";var Za=[401,403],Yn="networkError",Jn="mediaError";function Qa(e,t){if(e==null||e.fatal!==!0)return{action:"ignore"};let n=e.response?.code,o=e.type===Yn?"network":e.type===Jn?"media":"unknown",r=n==null?{kind:o}:{kind:o,status:n};return n!=null&&Za.includes(n)?{action:"expired",error:{kind:"network",status:n}}:e.type===Yn&&!t.network?{action:"restart-load"}:e.type===Jn&&!t.media?{action:"recover-media"}:{action:"fail",error:r}}function Zn(e){let t=e.HlsCtor??Ja,n=new t,o,r=!1,a=!1;return n.attachMedia(e.media),n.on(t.Events.ERROR,(i,d)=>{let c=Qa(d,{network:r,media:a});switch(c.action){case"expired":e.handlers?.onExpiredUrl?.(),e.handlers?.onError?.(c.error);break;case"restart-load":r=!0,n.startLoad();break;case"recover-media":a=!0,n.recoverMediaError();break;case"fail":e.handlers?.onError?.(c.error);break;case"ignore":break}}),{load(i){o=i,r=!1,a=!1,n.loadSource(i)},retry(){o!=null&&(r=!1,a=!1,n.loadSource(o))},destroy(){n.destroy()},get src(){return o}}}function Qn(e){try{return e.canPlayType("application/vnd.apple.mpegurl")!==""}catch{return!1}}function Xn(e){switch(e?.code){case 2:return{kind:"network"};case 3:case 4:return{kind:"media"};default:return{kind:"unknown"}}}var Xa={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",avif:"image/avif",svg:"image/svg+xml"},kr="512x512";function et(){return typeof navigator<"u"&&typeof navigator.mediaSession<"u"}function ei(e){if(typeof e!="string"||e.length===0)return{src:e,sizes:kr};let t=e.split(/[?#]/)[0],n=t.includes(".")?t.slice(t.lastIndexOf(".")+1).toLowerCase():"",o=Xa[n],r={src:e,sizes:kr};return o!=null&&(r.type=o),r}function ti(e){if(e==null)return;let t=Array.isArray(e)?e:[e],n=[];for(let o of t){if(typeof o=="string"){o.length>0&&n.push(ei(o));continue}o!=null&&o.src.length>0&&n.push({src:o.src,sizes:o.sizes??kr,...o.type!=null?{type:o.type}:{}})}return n.length>0?n:void 0}function xr(e){!et()||typeof MediaMetadata>"u"||(navigator.mediaSession.metadata=new MediaMetadata({title:e.title,album:e.album,artist:e.artist,artwork:ti(e.artwork)}))}function eo(){et()&&(navigator.mediaSession.playbackState="playing")}function to(){et()&&(navigator.mediaSession.playbackState="paused")}function ro(e,t,n=1){if(!et()||e==null||!Number.isFinite(e)||e<=0||t!=null&&isNaN(t))return;let o=Math.min(Math.max(t??0,0),e),r=Number.isFinite(n)&&n>0?n:1;try{navigator.mediaSession.setPositionState({playbackRate:r,duration:e,position:o})}catch{}}var no=["play","pause","stop","seekbackward","seekforward","seekto","previoustrack","nexttrack"];function oo(e){if(et()){xr({title:e.title,album:e.album,artist:e.artist,artwork:e.artwork});for(let t of no)try{navigator.mediaSession.setActionHandler(t,n=>{e.action(n)})}catch{}}}function ao(){if(et()){navigator.mediaSession.metadata=null;for(let e of no)try{navigator.mediaSession.setActionHandler(e,null)}catch{}}}import{useEffect as ri,useState as ni}from"react";var oi={play:"Odtw\xF3rz",pause:"Wstrzymaj",previous:"Poprzedni rozdzia\u0142",next:"Nast\u0119pny rozdzia\u0142",rewind:"Cofnij o 10 sekund",forward:"Przewi\u0144 o 10 sekund",progress:"Post\u0119p odtwarzania",of:"z",speed:"Pr\u0119dko\u015B\u0107",sleep:"Wy\u0142\u0105cznik czasowy",off:"Wy\u0142\u0105czony",end:"Koniec rozdzia\u0142u",cancel:"Anuluj wy\u0142\u0105cznik",error:"Nie uda\u0142o si\u0119 odtworzy\u0107 nagrania.",retry:"Spr\xF3buj ponownie",left:"zosta\u0142o",book:"ca\u0142a ksi\u0105\u017Cka",chapter:"rozdzia\u0142",chapters:"Rozdzia\u0142y",loading:"\u0141adowanie rozdzia\u0142\xF3w\u2026",empty:"Brak rozdzia\u0142\xF3w do wy\u015Bwietlenia.",resume:"Kontynuuj",chapterName:"Rozdzia\u0142",download:"Pobierz rozdzia\u0142",playing:"Teraz odtwarzane",played:"Ods\u0142uchane"},ai={play:"Play",pause:"Pause",previous:"Previous chapter",next:"Next chapter",rewind:"Rewind 10 seconds",forward:"Forward 10 seconds",progress:"Playback progress",of:"of",speed:"Speed",sleep:"Sleep timer",off:"Off",end:"End of chapter",cancel:"Cancel timer",error:"The recording could not be played.",retry:"Try again",left:"left",book:"whole book",chapter:"chapter",chapters:"Chapters",loading:"Loading chapters\u2026",empty:"No chapters to display.",resume:"Continue",chapterName:"Chapter",download:"Download chapter",playing:"Now playing",played:"Played"};function Rt(e){let[t,n]=ni("pl");return ri(()=>{try{n(A())}catch{}},[]),(e??t).toLowerCase().startsWith("en")?ai:oi}function xe(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;return`${t>=3600?`${Math.floor(t/3600)}:`:""}${String(Math.floor(t/60)%60).padStart(2,"0")}:${String(t%60).padStart(2,"0")}`}var Y={get(e){try{return localStorage.getItem(e)}catch{return null}},set(e,t){try{localStorage.setItem(e,t)}catch{}},remove(e){try{localStorage.removeItem(e)}catch{}}},wr="__player__speed",Dt=[.75,1,1.25,1.5,1.75,2];import{jsx as M,jsxs as $}from"react/jsx-runtime";var fi=pi(({chapters:e,locale:t,styles:n,updateCurrentTime:o,setCurrentTimeHandler:r,title:a,imageURL:i,coverShownBeside:d,author:c,uniqueProductID:l,onChapterChange:f,onError:P,onExpiredUrl:x,onFinished:I},g)=>{let u=Rt(t),[m,p]=we(1),b=G(1),[S,U]=we(),[N,ce]=we("off"),[Se,oe]=we(0),te=G({mode:"off",deadline:0});function fe(){te.current={mode:"off",deadline:0},ce("off"),oe(0)}function E(s){let h=Number(s)*60;te.current={mode:s,deadline:Number.isFinite(h)?Date.now()+h*1e3:0},ce(s),oe(Number.isFinite(h)?h:0)}function ge(s){Dt.includes(s)&&(p(s),b.current=s,Y.set(wr,String(s)),z.current&&(z.current.playbackRate=s),K())}He(()=>{let s=Number(Y.get(wr));Dt.includes(s)&&ge(s);let h=setInterval(()=>{let{mode:k,deadline:D}=te.current;if(k==="off"||k==="chapter")return;let Pe=Math.max(0,Math.ceil((D-Date.now())/1e3));oe(Pe),Pe===0&&(ze.current=!1,xt(),fe())},1e3);return()=>clearInterval(h)},[]);let Z;(k=>(k[k.Playing=0]="Playing",k[k.Paused=1]="Paused"))(Z||={});let[_e,lt]=we(1),[Bt,Ee]=we(void 0),[w,ye]=we(void 0),[Be,ue]=we(!1),[vt,Vr]=we(null),z=G(null),he=G(null),kt=G(void 0),na=G(null),re=G(null),Kt=G(null),ze=G(!1),Ke=G(!1),dt=G(null),Gt=G(null),Vt=G(e),Wr=G(null),ne=G({onChapterChange:f,onError:P,onExpiredUrl:x,onFinished:I,updateCurrentTime:o,title:a,imageURL:i,author:c});ne.current={onChapterChange:f,onError:P,onExpiredUrl:x,onFinished:I,updateCurrentTime:o,title:a,imageURL:i,author:c};function Wt(s){!Ke.current||!Number.isFinite(s)||s<0||Y.set(`__player__${l}_${re.current?.id}`,`${Math.floor(s)}`)}function oa(){let s=Y.get(`__player__${l}_${re.current?.id}`);if(s!=null)try{let h=parseInt(s);return isNaN(h)||h<0?void 0:h}catch{return}}function aa(){let s=Y.get(`__player__${l}_last_chapter`);if(s!=null)return s}function Yr(s){Y.set(`__player__${l}_last_chapter`,s)}function Jr(s){Y.remove(`__player__${l}_${s}`)}function Yt(s){xr({title:s?.name??ne.current.title??"",album:ne.current.title,artist:ne.current.author,artwork:ne.current.imageURL})}function Zr(s){Kt.current=s,Vr(s),ue(!1),ne.current.onError?.(s)}function Qr(){Kt.current=null,Vr(null)}function Xr(){let s=z.current;if(s==null)return;let h=s.play();h!=null&&typeof h.catch=="function"&&h.catch(()=>{}),K()}function en(){Xr()}function xt(){z.current?.pause(),K()}function ia(){if(_e===0){xt();return}en()}function Le(s){let h=z.current;if(h==null||!Number.isFinite(s))return;let k=Number.isFinite(h.duration)?h.duration:0,D=k>0?Math.min(Math.max(s,0),k):Math.max(s,0);Ee(D),h.currentTime=D,K()}function wt(s){let h=z.current;if(h==null)return;let k=Number.isFinite(h.duration)?h.duration:void 0,D=Math.max(h.currentTime+s,0);k!=null&&D>k&&(D=k),Le(D)}function Jt(s){let h=z.current;if(h!=null){if(Qr(),ue(!0),Qn(h)){Zt(),h.src=s,h.load();return}if(si.isSupported()){he.current==null&&(he.current=Zn({media:h,handlers:{onError:k=>{Zr(k)},onExpiredUrl:()=>{ne.current.onExpiredUrl?.()}}})),he.current.load(s);return}Zt(),h.src=s,h.load()}}function Zt(){he.current?.destroy(),he.current=null}function Ct(s,h){let k=h?.play===!0;re.current&&z.current&&!z.current.ended&&Wt(z.current.currentTime),Ke.current=!1,dt.current=null,ze.current=k,re.current=s,U(s.id),Ee(0),ye(s.duration),Jt(s.publicUrl),Yt(s),ne.current.onChapterChange?.(s),Yr(s.id)}function Qt(s){if(s.length===0)return;let h=aa(),k=(h!=null?s.find(D=>D.id===h):void 0)??s[0];Ct(k,{play:!1})}function Xt(){let s=Vt.current,h=re.current;if(s==null||s.length===0||h==null)return;let k=s.findIndex(Pe=>Pe.id===h.id);if(k===-1)return;let D=k+1;if(D>=s.length){sa(h);return}Ct(s[D],{play:!0})}function tn(){let s=Vt.current,h=re.current;if(h==null)return;let k=z.current;if(k!=null&&k.currentTime>3){Le(0);return}let D=s==null?-1:s.findIndex(Pe=>Pe.id===h.id);if(D>0){Ct(s[D-1],{play:!0});return}Le(0)}function sa(s){Jr(s.id),ze.current=!1,z.current?.pause(),lt(1),ne.current.onFinished?.()}function rn(){let s=re.current;if(s!=null){if(Y.set(`__player__${l}_${s.id}_completed`,"true"),Jr(s.id),te.current.mode==="chapter"){ze.current=!1,xt(),fe();return}Xt(),K()}}function nn(){let s=z.current;if(s!=null){if(ue(!1),s.playbackRate=b.current,Gt.current=null,!Ke.current){Ke.current=!0;let h=dt.current;if(dt.current=null,h!=null)Le(h);else{let k=oa();k!=null&&Le(k)}}ze.current&&(ze.current=!1,Xr())}}function on(){let s=z.current?.error,h=re.current?.publicUrl;(s?.code===2||s?.code===4)&&he.current==null&&h!=null&&Gt.current!==h&&(Gt.current=h,ne.current.onExpiredUrl?.()),Zr(Xn(s))}function an(){let h=re.current?.publicUrl??he.current?.src;if(h==null)return;let D=z.current?.currentTime??0;Qr(),Ke.current=!1,dt.current=D>0?D:null,Ee(D),he.current!=null?he.current.retry():Jt(h)}function la(s){switch(s.action){case"play":en();break;case"pause":case"stop":xt();break;case"seekbackward":wt(-(s.seekOffset??10));break;case"seekforward":wt(s.seekOffset??10);break;case"seekto":s.seekTime!=null&&Le(s.seekTime);break;case"previoustrack":tn();break;case"nexttrack":Xt();break;default:break}}mi(g,()=>({selectChapter:s=>{Ct(s,{play:!0})},retry:an,getError:()=>Kt.current}));function K(){let s=z.current;s!=null&&(lt(s.paused?1:0),ye(s.duration),Ee(s.currentTime),s.ended||Wt(s.currentTime),ro(s.duration,s.currentTime,s.playbackRate),s.networkState===s.NETWORK_LOADING&&s.readyState<=s.HAVE_FUTURE_DATA?ue(!0):ue(!1),ne.current.updateCurrentTime?.(s.currentTime))}He(()=>(oo({title:a??"",album:a,artist:c,artwork:i,action:la}),()=>{ao()}),[]),He(()=>{Yt(re.current)},[a,c,i]),He(()=>{let s=z.current;if(s!=null)return s.addEventListener("loadeddata",nn),s.addEventListener("ended",rn),s.addEventListener("error",on),s.addEventListener("timeupdate",K),s.addEventListener("play",K),s.addEventListener("pause",K),s.addEventListener("ratechange",K),K(),kt.current=setInterval(K,500),()=>{s.removeEventListener("loadeddata",nn),s.removeEventListener("ended",rn),s.removeEventListener("error",on),s.removeEventListener("timeupdate",K),s.removeEventListener("play",K),s.removeEventListener("pause",K),s.removeEventListener("ratechange",K),kt.current!=null&&(clearInterval(kt.current),kt.current=void 0),s.ended||Wt(s.currentTime),Ee(void 0),s.pause(),Zt(),s.removeAttribute("src"),s.load()}},[]),He(()=>{r?.(Le)},[]);let er=e.map(s=>`${s.id}|${s.publicUrl??""}`).join(`
4
+ `);He(()=>{Vt.current=e;let s=Wr.current;if(s===er)return;if(Wr.current=er,s==null){Qt(e);return}let h=re.current;if(h==null){Qt(e);return}let k=e.find(D=>D.id===h.id);if(!(k!=null&&k.publicUrl===h.publicUrl)){if(k!=null){let D=z.current,Pe=D?.currentTime??0,ca=D!=null&&!D.paused;re.current=k,Ke.current=!1,dt.current=Pe>0?Pe:null,ze.current=ca,Jt(k.publicUrl),Yt(k),ne.current.onChapterChange?.(k),Yr(k.id);return}Qt(e)}},[er]),He(()=>{switch(_e){case 0:eo();break;case 1:to();break}},[_e]);let Ge=e.findIndex(s=>s.id===S),be=Number.isFinite(w)&&w>0?w:e[Ge]?.duration??0,ct=Math.min(Math.max(Bt??0,0),be||1/0),sn=e.length>0&&e.every(s=>Number.isFinite(s.duration)&&s.duration>0),da=Math.max(0,be-ct+(sn?e.slice(Ge+1).reduce((s,h)=>s+h.duration,0):0))/m,tr=Math.ceil(da/60),ln=`${Math.floor(tr/60)>0?`${Math.floor(tr/60)} h `:""}${tr%60} min`;return $("div",{id:"audio-player-container",className:"bitsnap-audio-player flex min-w-0 flex-col gap-3 text-neutral-900 dark:text-neutral-100",style:{...n,"--seek-before-width":`${be>0?ct/be*100:0}%`},ref:na,"data-player-error":vt?.kind,children:[M("video",{ref:z,className:"hidden",poster:i,title:a}),$("div",{className:H("flex min-w-0 items-center gap-3",d&&"lg:hidden"),children:[i&&M("img",{src:i,alt:"",className:"h-16 w-16 shrink-0 rounded object-contain"}),$("div",{className:"min-w-0 break-words",children:[M("p",{className:"font-semibold",children:e[Ge]?.name??a}),c&&M("p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:c})]})]}),vt&&$("div",{role:"alert",className:"rounded-lg bg-red-50 p-3 text-red-800 dark:bg-red-950 dark:text-red-200",children:[M("p",{children:u.error}),M(L,{variant:"outline",onClick:an,children:u.retry})]}),M("input",{type:"range",min:"0",max:be||100,value:ct,disabled:!be,"aria-label":u.progress,"aria-valuetext":`${xe(ct)} ${u.of} ${xe(be)}`,onChange:s=>Le(Number(s.target.value))}),$("section",{className:"flex w-full justify-between text-sm tabular-nums",children:[M("span",{id:"current-time",children:xe(ct)}),M("span",{id:"duration",children:xe(be)})]}),be>0&&$("p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:[u.left==="left"?`${ln} ${u.left}`:`${u.left} ${ln}`," ","\xB7 ",sn?u.book:u.chapter," (",m,"\xD7)"]}),$("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[M(L,{variant:"outline",onClick:tn,disabled:Ge<0,"aria-label":u.previous,children:M(ci,{className:"h-5 w-5"})}),$(L,{variant:"outline",onClick:()=>wt(-10),"aria-label":u.rewind,children:["\u2212",10]}),M(L,{variant:"outline",onClick:ia,"aria-label":_e===1?u.play:u.pause,children:_e===1?M(di,{className:"h-5 w-5"}):M(li,{className:"h-5 w-5"})}),$(L,{variant:"outline",onClick:()=>wt(10),"aria-label":u.forward,children:["+",10]}),M(L,{variant:"outline",onClick:Xt,disabled:Ge<0||Ge>=e.length-1,"aria-label":u.next,children:M(ui,{className:"h-5 w-5"})})]}),$("div",{className:"flex flex-wrap gap-3 md:grid md:grid-cols-2",children:[$("label",{className:"flex flex-1 items-center gap-2 text-sm md:flex-col md:items-start md:whitespace-nowrap",children:[u.speed,M("select",{"aria-label":u.speed,value:m,onChange:s=>ge(Number(s.target.value)),children:Dt.map(s=>$("option",{value:s,children:[s,"\xD7"]},s))})]}),$("label",{className:"flex flex-1 items-center gap-2 text-sm md:flex-col md:items-start md:whitespace-nowrap",children:[u.sleep,$("select",{"aria-label":u.sleep,value:N,onChange:s=>E(s.target.value),children:[M("option",{value:"off",children:u.off}),[15,30,45,60].map(s=>$("option",{value:s,children:[s," min"]},s)),M("option",{value:"chapter",children:u.end})]})]})]}),N!=="off"&&$("div",{className:"flex items-center justify-between gap-2 text-sm",children:[M("span",{role:"timer",children:N==="chapter"?u.end:xe(Se)}),M(L,{variant:"outline",onClick:fe,children:u.cancel})]}),Be&&M("div",{role:"status",className:"flex justify-center",children:M(ke,{})})]})}),io=fi;import{Check as gi,Download as yi,Play as hi}from"lucide-react";import{useEffect as bi,useState as so}from"react";import{Fragment as Pi,jsx as le,jsxs as rt}from"react/jsx-runtime";function Cr({chapters:e,currentID:t,productID:n,onSelect:o,downloadable:r,onDownload:a,loading:i,locale:d}){let c=Rt(d),[l,f]=so(null),[P,x]=so([]);bi(()=>{let u=`__player__${n}_`,m=Y.get(`${u}last_chapter`),p=Number(m&&Y.get(`${u}${m}`));f(m&&p>0&&Number.isFinite(p)?{id:m,time:p}:null),x((e??[]).filter(b=>Y.get(`${u}${b.id}_completed`)==="true"||Number(Y.get(`${u}${b.id}`))>0).map(b=>b.id))},[e,n,t]);let I=e?.findIndex(u=>u.id===l?.id)??-1,g=e?.findIndex(u=>u.id===t)??-1;return rt("div",{className:"max-h-96 w-full overflow-y-auto",children:[le("h2",{className:"mb-3 text-xl font-semibold",children:c.chapters}),i?le("p",{role:"status",children:c.loading}):e?.length?rt(Pi,{children:[l&&I>=0&&rt("button",{type:"button",className:"mb-3 min-h-11 rounded-lg border border-neutral-300 px-3 py-2 text-left dark:border-neutral-600",onClick:()=>o(e[I]),children:[c.resume,": ",c.chapterName," ",I+1,","," ",xe(l.time)]}),le("ul",{className:"flex w-full flex-col gap-2",children:e.map((u,m)=>{let p=u.id===t,b=m<g||P.includes(u.id);return rt("li",{className:"flex min-w-0 items-center gap-2",children:[rt("button",{type:"button","aria-current":p?"true":void 0,className:`min-h-11 min-w-0 flex-1 rounded-lg p-3 text-left hover:bg-neutral-200 dark:hover:bg-neutral-700 ${p?"bg-neutral-200 dark:bg-neutral-700":"bg-neutral-100 dark:bg-neutral-800"}`,onClick:()=>o(u),children:[rt("span",{className:"flex items-center gap-2",children:[p?le(hi,{className:"size-4 shrink-0","aria-label":c.playing}):b?le(gi,{className:"size-4 shrink-0","aria-label":c.played}):null,le("span",{className:"min-w-0 flex-1 break-words text-sm font-medium",children:u.name}),!!u.duration&&le("span",{className:"shrink-0 text-xs tabular-nums text-neutral-600 dark:text-neutral-300",children:xe(u.duration)})]}),u.description&&le("span",{className:"mt-2 block text-xs",children:u.description})]}),r&&u.downloadableUrl&&le("a",{href:u.downloadableUrl,onClick:a,"aria-label":`${c.download} ${m+1}`,className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",children:le(yi,{className:"size-4","aria-hidden":"true"})})]},u.id)})})]}):le("p",{children:c.empty})]})}import{Fragment as Mt,jsx as C,jsxs as J}from"react/jsx-runtime";function Ce(e,...t){console.warn(e,...t)}function Nr(e){console.error(e)}var wi=({accessToken:e,product:t,styles:n,reveal:o})=>{let r=Xe(),a=t.productType,i=St(),d=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),c=co(null),[l]=vi(),[f,P]=qe(!1),[x,I]=qe(null),{mutateAsync:g,isPending:u}=ae(F.publicApi.userPanelGetFileDetails),m=co(void 0),[p,b]=qe(null),[S,U]=qe(null),[N,ce]=qe(!1),{mutateAsync:Se,isPending:oe}=ae(F.publicApi.userPanelGetAudiobookDetails),{mutateAsync:te,isPending:fe}=ae(F.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[E,ge]=qe(null),[Z,_e]=qe(null);async function lt(){P(!1);try{let w=await g({accessId:t.accessId,accessToken:e});if(w.result.case==="success"){I(w.result.value.files);return}else P(!0),Ce("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),Ce("Kod b\u0142\u0119du: ",w.result.value)}catch(w){P(!0),Ce("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Nr("B\u0142\u0105d podczas pobierania danych:"+w)}}async function Bt(){try{let w=await Se({accessId:t.accessId,accessToken:e});if(w.result.case==="audiobook"){b(w.result.value);return}else Ce("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),Ce("Kod b\u0142\u0119du: ",w.result.value)}catch(w){Ce("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Nr("B\u0142\u0105d podczas pobierania danych:"+w)}}async function Ee(){try{let w=await te({accessId:t.accessId,accessToken:e,isBrowser:!0});if(w.result.case==="success"){U(w.result.value.audiobookDownloadDetails),ce(w.result.value.isAvailableToDownloadInMobileApp===!0);return}else Ce("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),Ce("Kod b\u0142\u0119du: ",w.result.value)}catch(w){Ce("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Nr("B\u0142\u0105d podczas pobierania danych:"+w)}}return lo(()=>{a===2&&lt(),a===1&&(Bt().then().catch(),Ee().then().catch())},[]),lo(()=>{if(p!=null&&S!=null){let w=p.chapters;if(!w)return;let ye=w.map(Be=>{let ue=S?.find(vt=>vt.chapterId===Be.id);if(ue!=null)return{...Be,publicUrl:ue.publicUrl,downloadableUrl:ue.downloadableUrl,duration:ue.duration}}).filter(Be=>Be!=null);ye!=null&&ye.length>0&&_e(ye)}},[p,S]),J("div",{children:[C("div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:J(L,{onClick:()=>o(),variant:"ghost",className:"min-h-11 w-fit",children:[C(ki,{className:"h-6 w-6"}),C("span",{className:"font-inter text-sm font-medium",children:r.back})]})}),J("main",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[J("header",{className:"flex min-w-0 flex-col gap-4 rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900 lg:row-span-2 lg:self-start",children:[C("img",{src:t.productImageUrl,alt:t.productName,width:384,height:384,draggable:!1,className:"aspect-square max-h-72 w-full object-contain"}),C("h2",{className:"text-2xl font-semibold",children:t.productName})]}),J("div",{className:"flex min-w-0 flex-col gap-6",children:[a===2&&J("section",{ref:l,className:"flex flex-col gap-4 rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900",children:[C("h3",{className:"text-xl font-semibold",children:r.yourFiles}),u&&C("div",{role:"status","aria-label":r.loading,children:C(ke,{})}),f&&J("div",{role:"alert",children:[C("p",{children:r.fileError}),C(L,{className:"min-h-11",onClick:lt,children:r.retry})]}),x?.length===0&&C("p",{children:r.noFiles}),x&&C("ul",{className:"flex flex-col gap-3",children:x.map((w,ye)=>J("li",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[C("span",{className:"min-w-0 break-all text-sm",children:uo(w)||`${r.file} ${ye+1}`}),J("a",{target:"_blank",rel:"noopener noreferrer",href:w,download:!0,onClick:d,className:"inline-flex min-h-11 items-center gap-2 rounded-md bg-neutral-900 px-3 py-2 text-sm text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 dark:bg-neutral-100 dark:text-neutral-900","aria-label":`${r.download}: ${uo(w)||`${r.file} ${ye+1}`}`,children:[r.download,C(xi,{className:"size-4","aria-hidden":"true"})]})]},w))})]}),a===3&&J("section",{className:"rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900",children:[C("h3",{className:"text-lg font-semibold",children:r.ticket}),C("p",{className:"mt-2 font-medium",children:t.productName}),C("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-300",children:r.ticketInfo})]}),a===1&&C(Mt,{children:J("div",{className:"flex flex-col space-y-6 rounded-xl bg-white p-3 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:[C("h4",{className:"text-xl font-semibold",children:E?.name??"Odtwarzacz"}),E?.description&&C("p",{className:"text-sm",children:E?.description}),C(Mt,{children:oe?J("div",{className:"flex gap-2",children:[C(ke,{}),C("p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):C(Mt,{children:Z!=null?C(Mt,{children:C(io,{ref:c,coverShownBeside:!0,chapters:Z,author:typeof p?.author=="string"?p.author:void 0,onExpiredUrl:()=>{Ee()},title:p?.name??t.productName??void 0,imageURL:p?.coverImage??t.productImageUrl??void 0,styles:n,setCurrentTimeHandler:w=>{m.current=w},uniqueProductID:t.productId,onChapterChange:w=>{ge(w)}})}):C("p",{className:"mt-2",children:"Wybierz rozdzia\u0142, kt\xF3ry ci\u0119 interesuje."})})}),J("div",{className:"rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",children:[C("p",{className:"mt-3 mb-3 text-xs",children:N?"Mo\u017Cesz s\u0142ucha\u0107 tego audiobooka w aplikacji r\xF3wnie\u017C bez dost\u0119pu do internetu.":"Mo\u017Cesz s\u0142ucha\u0107 tego audiobooka w aplikacji."}),J("div",{className:"flex gap-3",children:[C("a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:C("img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),C("a",{href:"https://play.google.com/store/apps/details?id=com.bitsnap.Bitsnap",children:C("img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),C("div",{className:"flex items-center justify-center rounded-xl bg-white p-3 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:a===1&&C(Cr,{chapters:Z,currentID:E?.id,productID:t.productId,loading:oe,downloadable:p?.isDownloadable===!0,onDownload:d,onSelect:w=>c.current?.selectChapter(w)})})]}),C("section",{className:"rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900",children:C("p",{className:"whitespace-pre-wrap text-sm text-neutral-600 dark:text-neutral-300",children:t.productDescription})})]})]})},po=wi;function uo(e){try{return decodeURIComponent(new URL(e,"https://bitsnap.pl").pathname.split("/").pop()||"")}catch{return""}}import{useTransport as Ci}from"@connectrpc/connect-query";import{useEffect as Ni,useState as Ii}from"react";function mo(e,t){let n=Ci(),[o,r]=Ii({status:"loading"});return Ni(()=>{if(!e){r({status:"hidden"});return}let a=!1;return r({status:"loading"}),import("./model-files-client-HHDXJDTS.mjs").then(({listModelFiles:i})=>i(n,e,t)).catch(()=>({status:"hidden"})).then(i=>{a||r(i)}),()=>{a=!0}},[n,e,t]),o}import{Fragment as ho,jsx as _,jsxs as Me}from"react/jsx-runtime";var _i=Si(()=>import("./PanelModelFiles-4B2HYGIE.mjs")),zi=({accessToken:e,projectID:t,loginURL:n,styles:o,activeScreen:r,params:a,setParams:i,openCourse:d,openMessages:c})=>{let{host:l}=ve(),{data:f,isLoading:P,error:x,refetch:I}=Ae(F.publicApi.userPanelGetProducts,{accessToken:e}),g=mo(e,t),u=ji({products:P?{status:"loading"}:x!=null?{status:"error"}:f?.result.case==="success"?{status:"ok",count:f.result.value.products.length}:f?.result.case==="failure"?{status:"failure",unauthorized:f.result.value===9}:{status:"error"},modelFiles:g});if(Ir(()=>{u.kind==="signed-out"&&(Ye(t,l),window.location.href=n)},[u.kind,t,l,n]),u.kind==="loading"||u.kind==="signed-out")return _("div",{role:"status","aria-label":Xe().loading,"aria-busy":"true",className:"grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5",children:Array.from({length:6},(S,U)=>_("div",{"aria-hidden":"true",className:"h-72 rounded-xl bg-neutral-100 motion-safe:animate-pulse dark:bg-neutral-800"},U))});let m=f&&f.result.case==="success"?f.result.value.products:[],p=g.status==="ready"?g.models:[],b=p.length>0?_(Ei,{fallback:null,children:_(_i,{accessToken:e,models:p,buttonStyle:o})}):null;return u.kind==="error"?Me(ho,{children:[_(Hi,{onRetry:()=>void I()}),b]}):u.kind==="empty"?_(Fi,{}):_(qi,{accessToken:e,products:m,styles:o,activeScreen:r,params:a,setParams:i,openCourse:d,openMessages:c,filesSection:b})};function ji({products:e,modelFiles:t}){if(e.status==="failure"&&e.unauthorized)return{kind:"signed-out"};if(e.status==="loading")return{kind:"loading"};if(e.status==="ok"&&e.count>0)return{kind:"list"};if(t.status==="loading")return{kind:"loading"};if(e.status==="failure"||e.status==="error")return t.status==="unauthorized"?{kind:"signed-out"}:{kind:"error"};let n=t.status==="ready"?t.models.length:0;return e.count===0&&n===0?{kind:"empty"}:{kind:"list"}}function Fi(){let e=Xe();return Me("div",{className:"flex flex-col items-start gap-1","data-testid":"panel-empty",children:[_("h3",{className:"text-2xl",children:e.hello}),_("p",{className:"text-sm text-neutral-500",children:e.empty})]})}function Hi({onRetry:e}){let t=A().toLowerCase().startsWith("en");return Me("div",{className:"flex flex-col items-start gap-3",role:"alert","data-testid":"panel-error",children:[_("p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:t?"Your products could not be loaded.":"Nie uda\u0142o si\u0119 wczyta\u0107 Twoich produkt\xF3w."}),_(L,{type:"button",onClick:e,className:"text-sm",children:t?"Try again":"Spr\xF3buj ponownie"})]})}var yo=zi;function fo(e){return e.productType===5||e.productType===6}var qi=({accessToken:e,products:t,styles:n,filesSection:o,activeScreen:r,params:a,setParams:i,openCourse:d,openMessages:c})=>{let l=Xe(),[f,P]=Li(()=>go(a.product,t));Ir(()=>{P(go(a.product,t))},[a.product,t]);let x=g=>{P(g),i({product:g?g.accessId||g.productId:void 0,state:"products"})};Ir(()=>{r==="products"&&f?.productType===4?d(f.accessId):r==="products"&&f&&fo(f)&&c&&c()},[r,f,d,c]);function I(g){if(fo(g)&&c){c();return}if(g.productType===4){d(g.accessId);return}x(g)}return r==="products"&&f?.productType===4?null:r==="products"&&f!=null?_(po,{accessToken:e,product:f,styles:n,reveal:x,onOpenCourse:d}):Me(ho,{children:[_("h3",{className:"text-2xl",children:l.hello}),t.length>0&&_("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:l.intro}),_("div",{className:"mt-6 grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5",children:t.map(g=>{let[u,m,p]=g.productType===1?[l.audio,l.listen,Ri]:g.productType===4?[l.course,l.openCourse,Ti]:g.productType===5?[l.chat,l.openMessages,Di]:g.productType===6?[l.community,l.openMessages,Oi]:g.productType===3?[l.ticket,l.showTicket,Mi]:[l.files,l.downloadFiles,Ai];return Me("button",{type:"button",onClick:()=>I(g),className:"flex min-h-11 min-w-0 flex-col overflow-hidden rounded-xl border border-neutral-200 bg-white text-left text-neutral-900 transition-colors hover:border-neutral-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-50 dark:hover:border-neutral-500",children:[Me("span",{className:"flex w-full flex-col gap-3 bg-neutral-100 p-3 dark:bg-neutral-800",children:[Me("span",{className:"flex w-fit items-center gap-1.5 rounded-md bg-white px-2 py-1 text-xs font-medium dark:bg-neutral-900",children:[_(p,{className:"size-4","aria-hidden":"true"}),u]}),_("img",{src:g.productImageUrl,alt:g.productName,draggable:!1,className:"aspect-square w-full object-contain"})]}),Me("span",{className:"flex flex-1 flex-col gap-3 p-3",children:[_("span",{className:"line-clamp-2 font-semibold",children:g.productName}),_("span",{className:"line-clamp-2 text-sm text-neutral-600 dark:text-neutral-300",children:Wn(g.productDescription)}),_("span",{className:"mt-auto pt-2 text-sm font-medium underline underline-offset-4",children:m})]})]},g.accessId||g.productId)})}),o]})};function go(e,t){if(!e)return;let n=t.find(o=>(o.accessId||o.productId)===e||o.productId===e);if(n)return n;try{let o=Ui(cn,e);return t.find(r=>o.accessId?r.accessId===o.accessId:r.productId===o.productId)}catch{return}}import{LogOut as Wi}from"lucide-react";import{Library as $i,MessageCircle as Bi,Receipt as Ki,Undo2 as Gi,User as Vi}from"lucide-react";var bo=[{screen:"products",label:"libraryNavLabel",icon:$i},{screen:"messages",label:"messagesNavLabel",icon:Bi},{screen:"orders",label:"ordersNavLabel",icon:Ki},{screen:"returns",label:"returnsNavLabel",icon:Gi},{screen:"profile",label:"accountNavLabel",icon:Vi}];function Po(e){return e==="course"?"products":e==="order-details"?"orders":e==="return-details"?"returns":e}import{jsx as $e,jsxs as ht}from"react/jsx-runtime";function Sr({activeScreen:e,setActiveScreen:t,setParams:n,theme:o,logout:r,email:a,projectID:i,showMessages:d=!1}){let c=pe(),{data:l}=gn(i??"",!!i);return ht("header",{className:"flex h-14 shrink-0 items-center border-b border-neutral-200 bg-white px-4 md:h-dvh md:w-56 md:flex-col md:items-stretch md:border-r md:border-b-0 md:py-5 dark:border-neutral-800 dark:bg-neutral-900",children:[ht("div",{className:"flex min-w-0 items-center gap-3 md:mb-6 md:flex-col md:items-start",children:[$e(Lt,{projectId:i,logoUrl:o?.logoURL,logoDarkUrl:o?.logoDarkURL,name:l?.name,className:"shrink-0"}),l?.name&&$e("span",{title:l.name,className:"truncate text-sm font-medium md:line-clamp-2 md:whitespace-normal",children:l.name})]}),$e("nav",{"aria-label":c.navigationLabel,className:"fixed inset-x-0 bottom-0 z-10 flex h-[calc(56px+env(safe-area-inset-bottom))] items-start justify-around border-t border-neutral-200 bg-white pb-[env(safe-area-inset-bottom)] md:static md:h-auto md:flex-1 md:flex-col md:justify-start md:gap-2 md:border-0 md:bg-transparent md:pb-0 dark:border-neutral-800 dark:bg-neutral-900",children:bo.filter(({screen:f})=>f!=="messages"||d).map(({screen:f,label:P,icon:x})=>{let I=Po(e)===f;return ht("button",{type:"button","aria-current":I?"page":void 0,onClick:()=>{t(f),n({product:void 0,state:f})},className:H("flex h-14 min-h-11 min-w-0 flex-1 flex-col items-center justify-center gap-1 px-1 text-[11px] focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-current md:h-11 md:w-full md:flex-none md:flex-row md:justify-start md:gap-3 md:rounded-md md:px-3 md:text-sm",I?"bg-neutral-100 font-semibold text-black dark:bg-neutral-800 dark:text-white":"text-neutral-600 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:bg-neutral-800"),children:[$e(x,{className:"h-5 w-5 shrink-0","aria-hidden":"true"}),$e("span",{children:c[P]})]},f)})}),ht("div",{className:"hidden border-t border-neutral-200 pt-4 md:block dark:border-neutral-800",children:[a&&$e("p",{title:a,className:"mb-3 truncate text-sm text-neutral-600 dark:text-neutral-400",children:a}),ht("button",{type:"button",onClick:r,className:"flex min-h-11 w-full items-center gap-3 rounded-md px-3 text-sm text-red-700 hover:bg-red-50 focus-visible:outline-2 focus-visible:outline-current dark:text-red-400 dark:hover:bg-neutral-800",children:[$e(Wi,{className:"h-4 w-4","aria-hidden":"true"}),c.logout]})]})]})}import{useState as Yi}from"react";import{LogOut as Ji}from"lucide-react";import{jsx as Oe,jsxs as nt}from"react/jsx-runtime";function Er({email:e,logout:t,onLocaleChange:n}){let[o,r]=Yi(A),a=pe(o);return nt("section",{className:"w-full max-w-xl",children:[Oe("h3",{className:"text-2xl",children:a.accountNavLabel}),Oe("h4",{className:"mt-6 mb-2 text-sm font-medium text-neutral-600 dark:text-neutral-400",children:a.profileHeading}),nt("div",{className:"divide-y divide-neutral-200 rounded-lg border border-neutral-200 bg-white dark:divide-neutral-800 dark:border-neutral-800 dark:bg-neutral-900",children:[nt("div",{className:"p-4",children:[Oe("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:a.emailLabel}),Oe("p",{className:"mt-1 break-words",children:e||a.noData})]}),nt("label",{className:"flex min-h-11 flex-wrap items-center justify-between gap-3 p-4",children:[Oe("span",{children:a.languageLabel}),nt("select",{value:o.toLowerCase().startsWith("en")?"en-US":"pl-PL",onChange:i=>{dr(i.target.value),r(i.target.value),n?.()},className:"min-h-11 rounded-md border border-neutral-300 bg-white px-3 focus-visible:outline-2 focus-visible:outline-current dark:border-neutral-700 dark:bg-neutral-900",children:[Oe("option",{value:"pl-PL",children:a.polishLanguage}),Oe("option",{value:"en-US",children:a.englishLanguage})]})]})]}),nt("button",{type:"button",onClick:t,className:"mt-6 flex min-h-11 w-full items-center gap-3 rounded-lg border border-neutral-200 bg-white px-4 py-3 text-red-700 hover:bg-red-50 focus-visible:outline-2 focus-visible:outline-current dark:border-neutral-800 dark:bg-neutral-900 dark:text-red-400 dark:hover:bg-neutral-800",children:[Oe(Ji,{className:"h-5 w-5","aria-hidden":"true"}),a.logout]})]})}import{lazy as Zi,Suspense as Qi}from"react";import{jsx as bt}from"react/jsx-runtime";var Xi=Zi(()=>import("./course.mjs").then(e=>({default:e.PanelCourse})));function Lr(e){return bt(Qi,{fallback:bt("div",{className:"flex items-center gap-2 p-2",role:"status",children:bt(ke,{})}),children:bt("div",{className:"[--course-mobile-bottom:calc(56px+env(safe-area-inset-bottom))] md:[--course-mobile-bottom:0px]",children:bt(Xi,{...e})})})}import{lazy as es,Suspense as ts}from"react";import{jsx as Ot}from"react/jsx-runtime";var rs=es(()=>import("./chat.mjs").then(e=>({default:e.PanelMessages})));function Tr(e){return Ot(ts,{fallback:Ot("div",{className:"flex items-center gap-2 p-2",role:"status",children:Ot(ke,{})}),children:Ot(rs,{...e})})}function ns(e,t){return!!t||e.some(n=>n.productType===5||n.productType===6)}function vo(e){let{data:t}=Ae(F.publicApi.userPanelGetProducts,{accessToken:e??""},{enabled:!!e}),n=t?.result.case==="success"?t.result.value:void 0,o=n?.products??[],r=n?.chatApiUrl||void 0;return{visible:ns(o,r),products:o,chatApiUrl:r}}import{AlertCircle as No,CheckCircle2 as ko,ChevronLeft as os,Loader2 as Rr,Lock as xo,Package as as,Truck as Io}from"lucide-react";import{useEffect as is,useState as Ar}from"react";import{Fragment as So,jsx as y,jsxs as v}from"react/jsx-runtime";function ss({status:e}){let t={created:{color:"bg-neutral-100 text-neutral-700",icon:null},paid:{color:"bg-green-100 text-green-700",icon:ko},completed:{color:"bg-blue-100 text-blue-700",icon:ko},canceled:{color:"bg-red-100 text-red-700",icon:No},sent:{color:"bg-purple-100 text-purple-700",icon:Io},processing:{color:"bg-yellow-100 text-yellow-700",icon:Rr}},n=t[e]||t.created,o=n.icon,r={created:"Utworzone",paid:"Op\u0142acone",completed:"Zako\u0144czone",canceled:"Anulowane",sent:"Wys\u0142ane",processing:"Przetwarzane"};return v("span",{className:`inline-flex items-center gap-1 rounded-full px-3 py-1 text-sm font-medium ${n.color}`,children:[o&&y(o,{className:"h-4 w-4"}),r[e]||e]})}function ls({orderID:e,email:t}){let[n,o]=Ar(""),r=ae(F.publicApi.addPublicOrderComment);return v("form",{onSubmit:async i=>{if(i.preventDefault(),!!n.trim())try{await r.mutateAsync({projectId:"",orderId:e,message:n.trim(),accessToken:t}),o("")}catch(d){console.error("Failed to add comment:",d)}},className:"mt-4 space-y-2",children:[y(We,{htmlFor:"comment",children:"Dodaj komentarz"}),y(Cn,{id:"comment",value:n,onChange:i=>o(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:r.isPending}),y(L,{type:"submit",disabled:!n.trim()||r.isPending,children:r.isPending?v(So,{children:[y(Rr,{className:"mr-2 h-4 w-4 animate-spin"}),"Wysy\u0142anie..."]}):"Dodaj komentarz"})]})}function wo(e){return e?new Date(Number(e.seconds)*1e3).toLocaleDateString("pl-PL",{year:"numeric",month:"long",day:"numeric"}):"N/A"}function Co(e,t){return new Intl.NumberFormat("pl-PL",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function ds({orderID:e,initialEmail:t,onBack:n,accessToken:o,analytics:r}){let{theme:a,projectID:i}=ve(),d=Ve(i,r,"order"),[c,l]=Ar(t||""),[f,P]=Ar(!1),{data:x,isLoading:I,error:g,refetch:u}=Ae(F.publicApi.getPublicOrderDetails,{projectId:i??"",orderId:e,email:c||void 0,accessToken:o},{enabled:!!e}),m=x?.result.case==="order"?x.result.value:null,p=m?.isVerified??!1,b=m!=null;is(()=>{b&&d.track("panel_order_viewed",{},{order_ref:null})},[d,b]);let S=()=>{u(),P(!1)},U={"--button-background-color":a?.colors?.brand??"#000000","--button-background-color-dark":a?.colors?.brandDark??"#ffffff","--button-text-color":a?.colors?.brandDark??"#000000","--button-text-color-dark":a?.colors?.brand??"#000000"};return I?y("div",{className:"flex min-h-screen items-center justify-center",children:v("div",{className:"text-center",children:[y(Rr,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),y("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):g||!m?y("div",{className:"flex min-h-screen items-center justify-center",children:y(Re,{className:"w-full max-w-md",children:y(De,{className:"pt-6",children:v("div",{className:"text-center",children:[y(No,{className:"mx-auto h-12 w-12 text-red-500"}),y("h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),y("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):y("div",{className:"w-full bg-white py-8 dark:bg-black",style:U,children:v("div",{className:"w-full px-4",children:[n&&v(L,{onClick:n,variant:"ghost",className:"mb-4 w-fit",children:[y(os,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),v("div",{className:"mb-6 flex items-center gap-4",children:[a?.logoURL&&v(So,{children:[y("img",{src:a.logoURL,alt:"Project logo",className:`h-12 w-auto ${a.logoDarkURL?"dark:hidden":""}`}),a.logoDarkURL&&y("img",{src:a.logoDarkURL,alt:"Project logo",className:"hidden h-12 w-auto dark:block"})]}),v("div",{children:[y("h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),v("p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",m.orderId]})]})]}),v(Re,{className:"mb-6",children:[y(je,{children:v(Fe,{className:"flex items-center",children:[y(as,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),v(De,{className:"space-y-6",children:[v("div",{children:[v("div",{className:"flex items-center gap-2",children:[y(ss,{status:m.status}),m.processingStatus&&v("span",{className:"text-sm text-neutral-600",children:["\xB7 ",m.processingStatus]})]}),v("p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",wo(m.createdAt)]})]}),v("div",{className:"border-t pt-4",children:[y("h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),v("div",{className:"space-y-2",children:[v("div",{children:[y("span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",y("span",{className:p?"":"text-neutral-500",children:m.customerName})]}),v("div",{children:[y("span",{className:"font-medium",children:"Email:"})," ",y("span",{className:p?"":"text-neutral-500",children:m.customerEmail})]}),m.customerPhone&&v("div",{children:[y("span",{className:"font-medium",children:"Telefon:"})," ",y("span",{className:p?"":"text-neutral-500",children:m.customerPhone})]})]})]}),!p&&y("div",{className:"border-t pt-4",children:v(L,{onClick:()=>P(!0),variant:"outline",className:"w-full",children:[y(xo,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),v(Re,{className:"mb-6",children:[y(je,{children:y(Fe,{children:"Produkty"})}),v(De,{className:"space-y-6",children:[y("div",{className:"space-y-4",children:m.items.map((N,ce)=>v("div",{className:"flex items-center gap-4",children:[N.imageUrl&&y("img",{src:N.imageUrl,alt:N.name,className:"h-16 w-16 rounded object-cover"}),v("div",{className:"flex-1",children:[y("p",{className:"font-medium",children:N.name}),v("p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",N.quantity]})]}),y("div",{className:"text-right",children:y("p",{className:"font-medium",children:Co(Number(N.price),N.currency)})})]},ce))}),(m.deliveryAddress||m.deliveryMethod)&&v("div",{className:"border-t pt-4",children:[v("h3",{className:"mb-3 flex items-center font-semibold",children:[y(Io,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),v("div",{className:"space-y-2",children:[m.deliveryAddress&&v("div",{children:[y("span",{className:"font-medium",children:"Adres:"})," ",y("span",{className:p?"":"text-neutral-500",children:m.deliveryAddress})]}),m.deliveryMethod&&v("div",{children:[y("span",{className:"font-medium",children:"Metoda:"})," ",m.deliveryMethod]}),m.trackingNumber&&p&&v("div",{children:[y("span",{className:"font-medium",children:"Tracking:"})," ",m.trackingNumber]})]})]}),y("div",{className:"border-t pt-4",children:v("div",{className:"flex justify-between text-lg font-bold",children:[y("span",{children:"Suma:"}),y("span",{children:Co(Number(m.totalAmount),m.currency)})]})})]})]}),v(Re,{children:[y(je,{children:v(Fe,{children:["Komentarze ",m.commentCount>0&&`(${m.commentCount})`]})}),v(De,{children:[m.comments.length>0?y("div",{className:"space-y-4",children:m.comments.map(N=>v("div",{className:"border-b pb-4 last:border-b-0",children:[v("div",{className:"mb-1 flex items-center gap-2",children:[y("span",{className:"font-medium",children:N.authorName||"System"}),y("span",{className:"text-xs text-neutral-500",children:wo(N.createdAt)}),N.authorType==="admin"&&y("span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),y("p",{className:p?"":"text-neutral-500",children:N.message})]},N.id))}):y("p",{className:"text-neutral-600",children:"Brak komentarzy."}),p?y(ls,{orderID:m.orderId,email:c}):y("div",{className:"mt-4",children:v(L,{onClick:()=>P(!0),variant:"outline",className:"w-full",children:[y(xo,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),f&&y("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:v(Re,{className:"w-full max-w-md",children:[y(je,{children:y(Fe,{children:"Zweryfikuj sw\xF3j email"})}),v(De,{className:"space-y-4",children:[y("p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),v("div",{className:"space-y-2",children:[y(We,{htmlFor:"verify-email",children:"Adres email"}),y(Tt,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:c,onChange:N=>l(N.target.value)})]}),v("div",{className:"flex gap-2",children:[y(L,{variant:"outline",onClick:()=>P(!1),className:"flex-1",children:"Anuluj"}),y(L,{onClick:S,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function cs(e){return y(ds,{...e})}var Dr=cs;import{jsx as de,jsxs as Lo}from"react/jsx-runtime";var ps=({returnsAppearance:e,returnsTexts:t,analytics:n}={})=>{let{projectID:o,theme:r,loginURL:a,host:i}=ve(),[,d]=Eo(0),c=Ve(o,n,"panel"),l=mt(o,i),f=xn(o,i),{mutateAsync:P}=ae(F.publicApi.userPanelLogout);async function x(){l&&await P({accessToken:l}),typeof window<"u"&&(Ye(o,i),window.location.reload())}let[I]=us(),g=E=>["products","notifications","profile","plans","orders","order-details","returns","return-details","course","messages"].includes(E),[u,m]=$n({product:void 0,state:"products",orderId:void 0,returnId:void 0,course:void 0,item:void 0,chatProject:void 0,thread:void 0,channel:void 0}),[p,b]=Eo(g(u.state)?u.state:"products"),S=E=>{m({state:"order-details",orderId:E}),b("order-details")},U=()=>{m({state:"orders",orderId:void 0}),b("orders")},N=E=>m({orderId:void 0,returnId:void 0,course:void 0,item:void 0,chatProject:void 0,thread:void 0,channel:void 0,...E}),ce=E=>{m({state:"course",course:E,item:void 0,product:void 0}),b("course")},Se=()=>{m({state:"products",course:void 0,item:void 0,product:void 0}),b("products")},oe=()=>{m({state:"messages",product:void 0,chatProject:void 0,thread:void 0,channel:void 0}),b("messages")},te=vo(l);Ut(()=>{g(u.state)&&(u.state==="course"||p==="course"||u.state==="messages"||p==="messages")&&b(u.state)},[u.state]);let fe={"--button-background-color":r?.colors?.brand??"#000000","--button-background-color-dark":r?.colors?.brandDark??"#ffffff","--button-text-color":r?.colors?.brandDark??"#000000","--button-text-color-dark":r?.colors?.brand??"#000000"};return Ut(()=>{if(l==null||l.length===0){window.location.href=a??"/panel/login";return}},[]),Ut(()=>{if(l==null||l.length===0){window.location.href=a??"/panel/login";return}},[p]),Ut(()=>{if(typeof window>"u"||window.parent!==window||!l)return;let E=gt(window.location.search);E&&yt(E);let ge=E??Ze();ge&&(window.location.href=Qe(ge,l))},[l]),de(It,{value:c,children:Lo("div",{ref:I,className:"font-inter relative flex h-dvh w-full flex-col bg-beige-100 text-black dark:bg-black dark:text-white md:flex-row",children:[de(Sr,{activeScreen:p,setActiveScreen:b,setParams:N,styles:fe,theme:r,logout:x,email:f,projectID:o,showMessages:te.visible||p==="messages"}),Lo("main",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto w-full p-5 pb-[calc(76px+env(safe-area-inset-bottom))] md:pb-5",children:[p==="products"&&de(yo,{projectID:o??"",accessToken:l,loginURL:a??"/panel/login",styles:fe,activeScreen:p,params:u,setParams:m,openCourse:ce,openMessages:oe}),p==="messages"&&l&&de(Tr,{accessToken:l,products:te.products,chatApiUrl:te.chatApiUrl,projectID:o,host:i,selection:{chatProject:u.chatProject,thread:u.thread,channel:u.channel},onSelect:E=>m({chatProject:E.chatProject,thread:E.thread,channel:E.channel})}),p==="course"&&u.course&&l&&de(Lr,{accessId:u.course,accessToken:l,theme:r,itemId:u.item,onItemChange:E=>m({item:E}),onBack:Se}),p==="notifications"&&de(yr,{}),p==="plans"&&de(hr,{projectID:o??""}),p==="orders"&&de(Gn,{projectID:o??"",accessToken:l??"",openOrderDetails:S}),p==="order-details"&&u.orderId&&de(Dr,{orderID:u.orderId,onBack:U}),(p==="returns"||p==="return-details")&&l&&de(Pr,{projectID:o??"",host:i,accessToken:l,loginURL:a??"/panel/login",appearance:Bn(e,r?.colors?.brand),texts:t,screen:p,params:u,setParams:m,setActiveScreen:b}),p==="profile"&&de(Er,{email:f,logout:x,onLocaleChange:()=>d(E=>E+1)})]})]})})},ms=ps;import{create as Ne}from"@bufbuild/protobuf";import{QueryClient as As,QueryClientProvider as Rs}from"@tanstack/react-query";import{createContext as Ds,useContext as Ms,useEffect as $o,useState as Os}from"react";import{createClient as fs}from"@connectrpc/connect";import{createConnectTransport as gs}from"@connectrpc/connect-web";var me;(o=>{function e(r){return fs(un,n(r))}o.get=e;let t=new Map;function n(r){let a=t.get(r);return a==null&&(a=gs({useBinaryFormat:!0,baseUrl:r+"/api/rpc",interceptors:[dn]}),t.set(r,a)),a}})(me||={});import R from"zod";import ee from"zod";function j(e,t=2){return+(Math.round(+(e+"e+"+t))+"e-"+t)}function To(e,t){let n=typeof navigator>"u"?"pl-PL":navigator.language;return Intl.NumberFormat(n,{style:"currency",currency:t,currencyDisplay:"symbol"}).format(e/100)}var fp=ee.object({event:ee.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:ee.string().optional(),value:ee.number().optional(),currency:ee.string().optional(),content_name:ee.string().optional(),items:ee.array(ee.object({id:ee.string(),name:ee.string(),price:ee.number().default(0),currency:ee.string().default("PLN"),quantity:ee.number().default(1)})).optional()});function Mr(e){typeof window>"u"||(ys(e),bs(e),Ps(e))}function ys(e){try{typeof window.dataLayer>"u"&&(window.dataLayer=[]);let t=hs(e);window.dataLayer.push(t)}catch(t){console.warn("cannot send google analytics event",t)}}function hs(e){let t=e.value??e.items?.reduce((a,i)=>a+(i.price||0)*(i.quantity||1),0)??0,n=e.items?.map(a=>({item_id:a.id,item_name:a.name||a.id,price:j((a.price||0)/100,2),quantity:a.quantity||1})),o={currency:e.currency||"PLN",value:j(t/100,2)};n&&n.length>0&&(o.items=n);let r;switch(e.event){case"purchase":r="purchase",o.transaction_id=e.step||`txn_${Date.now()}`;break;case"addToCart":r="add_to_cart";break;case"viewCart":r="view_cart";break;case"removeFromCart":r="remove_from_cart";break;case"initiateCheckout":r="begin_checkout";break;case"customizeProduct":r="customize_product";break;default:r=e.event}return{event:r,ecommerce:o,...e.step&&{step:e.step},...e.content_name&&{content_name:e.content_name}}}function bs(e){if(typeof window.fbq>"u")return;let t="",n="",o={};switch(e.event){case"purchase":t="track",n="Purchase",o={category_name:e.step,...e};break;case"lead":t="track",n="Lead",o={category_name:e.step,...e};break;case"addToCart":t="track",n="Add to Cart",o={category_name:e.step,...e};break;case"customizeProduct":t="track",n="Customize Product",o={category_name:e.step,...e};break;case"viewCart":t="track",n="View Cart",o={category_name:e.step,...e};break;case"removeFromCart":t="track",n="Remove from Cart",o={category_name:e.step,...e};break;case"initiateCheckout":t="track",n="Initiate Checkout",o={category_name:e.step,...e};break;default:break}window.location.search.includes("analytics")&&console.log("Pushing FB event",t,n,o),window.fbq(t,n,o)}function Ps(e){try{if(typeof window.ttq>"u")return;let t=vs(e);if(!t)return;window.location.search.includes("analytics")&&console.log("Pushing TikTok event",t.eventName,t.eventPayload),window.ttq.track(t.eventName,t.eventPayload)}catch(t){console.warn("cannot send tiktok analytics event",t)}}function vs(e){let t=e.value??e.items?.reduce((a,i)=>a+(i.price||0)*(i.quantity||1),0)??0,n=e.items?.map(a=>({content_id:a.id,content_type:"product",content_name:a.name||a.id,quantity:a.quantity||1,price:j((a.price||0)/100,2)}))||[];n.length===0&&e.content_name&&n.push({content_id:e.step||"unknown",content_type:"product",content_name:e.content_name,quantity:1,price:j(t/100,2)});let o={currency:e.currency||"PLN",value:j(t/100,2)};n.length>0&&(o.contents=n);let r=null;switch(e.event){case"purchase":r="Purchase";break;case"addToCart":r="AddToCart";break;case"initiateCheckout":r="InitiateCheckout";break;case"customizeProduct":r="CustomizeProduct";break;case"viewCart":return;case"removeFromCart":return;case"lead":return;default:return null}return{eventName:r,eventPayload:o}}function Ao(e){let{items:t,googlePayConfig:n,checkout:o,result:r,cartRequiresShipping:a}=e,i=e.locale??A();if(r.totalAmount==null)return;let d=[];return a&&(d.push("SHIPPING_ADDRESS"),d.push("SHIPPING_OPTION")),{apiVersion:2,apiVersionMinor:0,callbackIntents:d,allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["MASTERCARD","VISA"]},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:n.gateway,gatewayMerchantId:n.gatewayId}}}],emailRequired:!0,shippingAddressParameters:{phoneNumberRequired:a},shippingAddressRequired:a,shippingOptionRequired:a,shippingOptionParameters:a?{shippingOptions:r.methods.slice(0,5).map(l=>({id:l.id,label:l.name+` - ${To(l.amount,r.currency)}`,description:l.description??""})),defaultSelectedOptionId:r.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:n.merchantId+"",merchantName:n.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:Te("paymentForCart",i,e.texts),totalPrice:`${j(r.totalAmount/100,2)}`,currencyCode:r.currency,countryCode:r.country,checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",displayItems:ks(t,r.methods,r.selectedDeliveryMethod??(r.methods.length>0?r.methods[0].id:void 0),o.couponCode,r.couponValue,Te("coupon",i,e.texts))}}}function ks(e,t,n,o,r,a="Coupon"){let i=[],d=0;for(let l of e){if(l.details==null)continue;let f=l.details.pricing?.effectivePrice??l.details.price;d+=f*l.quantity,i.push({label:l.details.name+" x "+l.quantity,price:`${j(f/100,2)}`,type:"LINE_ITEM",status:"FINAL"})}let c=t.find(l=>l.id===n);return c!=null&&i.push({label:c.name,price:`${j(c.amount/100,2)}`,type:"SHIPPING_OPTION",status:"FINAL"}),o!=null&&r!=null&&i.push({label:`${a} ${o}`,price:`${j(r/100,2)}`,type:"DISCOUNT",status:"FINAL"}),d>0&&i.push({label:"Subtotal",price:`${j(d/100,2)}`,type:"SUBTOTAL",status:"FINAL"}),i}function ot(e,t){return`${Q}/api/integrations/${e}/public-commerce${t}`}function Ue(e){return typeof e=="object"&&e!=null&&"ERR"in e}function B(e,t,n){return{ERR:!0,error:e,type:t,data:n}}function Ro(e,t){return t?.find(n=>n.id===e||(n.variants?.some(o=>o.id===e)??!1))}function Do(e,t){let n=new Set(t.map(o=>o.productID));return Array.from(new Set(e.filter(o=>!n.has(o))))}function Mo(e,t){let n=e?.trim();if(!(n==null||n.length===0))try{let o=new URL(n,t);return o.protocol!=="http:"&&o.protocol!=="https:"?void 0:o.href}catch{return}}import{create as xs}from"zustand";var at=xs(e=>({isCartVisible:!1,notice:void 0,setNotice:t=>e(n=>({...n,notice:t})),numberOfProductsInCart:0,showCart:()=>e(t=>({...t,isCartVisible:!0})),hideCart:()=>e(t=>({...t,isCartVisible:!1})),setNumberOfProductsInCart:t=>e(n=>({...n,numberOfProductsInCart:t}))}));import{createContext as ws,useContext as Or,useMemo as Oo}from"react";import{jsx as Cs}from"react/jsx-runtime";var _t=ws({});function Lp({texts:e,locale:t,children:n}){let o=Oo(()=>({texts:e,locale:t}),[e,t]);return Cs(_t.Provider,{value:o,children:n})}function Uo(){return Or(_t)}function Tp(e){let{texts:t,locale:n}=Or(_t);return Te(e,n??A(),t)}function Ap(){let{texts:e,locale:t}=Or(_t),n=t??A();return Oo(()=>o=>Te(o,n,e),[n,e])}var _r="bitsnap-pending-order";function jo(e,t){let n=new Map;for(let r of t)n.set(r.id,(n.get(r.id)??0)+r.quantity);let o=[];for(let r of e){let a=n.get(r.id);a==null?o.push(r):r.quantity>a&&o.push({...r,quantity:r.quantity-a})}return o}var Ns=60*1e3;function Fo(e,t=Date.now,n=Ns){let o;return r=>{let a=`${r.orderId}:${r.ts}`,i=t();return o?.key===a&&i-o.at<n?Promise.reject(new Error("pending order was asked about recently")):(o={key:a,at:i},e(r))}}function Is(e){if(!(e==null||e.length===0))try{let t=new URL(e,"https://bitsnap.invalid").pathname,n=/\/payment\/common\/([^/]+)\/([^/]+)\/?$/.exec(t);return n==null?void 0:{projectId:decodeURIComponent(n[1]),orderId:decodeURIComponent(n[2])}}catch{return}}function Ss(e){if(e==null||e.length===0)return!1;try{let t=new URL(e,"https://bitsnap.invalid").pathname;return/\/payment\/manualPayment\/[^/]+\/[^/]+\/?$/.test(t)}catch{return!1}}function Es(e,t=Date.now(),n={}){if(Ss(e.url))return;let o=Is(e.url),r=_o(e.orderId)??o?.orderId,a=_o(e.projectId)??o?.projectId;if(!(r==null||a==null))return{orderId:r,projectId:a,...n.cartProjectId!=null?{cartProjectId:n.cartProjectId}:{},lines:n.lines??[],ts:t}}function Mp(e,t={}){let n=Es(e,t.now,t);return n!=null&&Ls(n,t.storage)}function _o(e){return e!=null&&e.length>0?e:void 0}function zt(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function Ls(e,t=zt()){try{return t?.setItem(_r,JSON.stringify(e)),t!=null}catch{return!1}}function zo(e=zt()){try{let t=e?.getItem(_r);if(t==null)return;let n=JSON.parse(t);if(typeof n=="object"&&n!=null&&typeof n.orderId=="string"&&typeof n.projectId=="string"&&typeof n.ts=="number"&&n.orderId.length>0){let{orderId:o,projectId:r,cartProjectId:a,ts:i,lines:d}=n;return{orderId:o,projectId:r,...typeof a=="string"?{cartProjectId:a}:{},lines:Array.isArray(d)?d.filter(c=>typeof c?.id=="string"&&typeof c.quantity=="number"):[],ts:i}}}catch{}Ur(e)}function Ur(e=zt()){try{e?.removeItem(_r)}catch{}}function Ho(e){let t=e.details?.status??Ts(e.details?.$unknown);return t==="created"||t==="placed"||t==="paid"||t==="canceled"?t:"unknown"}function Ts(e){if(Array.isArray(e)){for(let t of e)if(t?.no===3&&t.wireType===2&&t.data instanceof Uint8Array){let n=0,o=0;for(let r=0;o<t.data.length&&r<35;r+=7){let a=t.data[o++];if(n|=(a&127)<<r,!(a&128))break}if(o+n!==t.data.length)return;try{return new TextDecoder().decode(t.data.subarray(o))}catch{return}}}}async function qo(e){let t=e.storage??zt(),n=zo(t);if(n==null)return"none";if((e.now??Date.now)()-n.ts>864e5)return Ur(t),"expired";if(e.projectId!=null&&n.cartProjectId!=null&&n.cartProjectId!==e.projectId)return"pending";let r;try{r=await e.fetchStatus(n)}catch{return"pending"}let a=zo(t);if(a?.orderId!==n.orderId||a.ts!==n.ts)return"pending";if(r==="paid"||r==="placed"){try{await e.removeLines(n.lines)}catch{return"pending"}return Ur(t),"paid"}return"pending"}import{Fragment as Ys,jsx as jr}from"react/jsx-runtime";var Us="__m_a",Yo=Ds(void 0),Hr=void 0;function im(e){sr({projectID:e}),Hr=e,typeof window<"u"&&ut([window.location.origin])}function st(){return Hr??document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-id")??void 0}function _s(){return document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-custom-host")??void 0}var zs=({children:e,locale:t})=>{let[n]=Os(()=>new As),o=Uo();$o(()=>{Ie()},[]);let r=st();if($o(()=>{if(r==null)return;let i=()=>{Hs(r).then(c=>{c==="paid"&&n.invalidateQueries({queryKey:["cart"]})})},d=()=>{document.visibilityState==="visible"&&i()};return i(),window.addEventListener("pageshow",i),document.addEventListener("visibilitychange",d),()=>{window.removeEventListener("pageshow",i),document.removeEventListener("visibilitychange",d)}},[r,n]),r==null)return jr(Ys,{});let a=Br(r,t??o.locale,o.texts);return jr(Rs,{client:n,children:jr(Yo.Provider,{value:a,children:e})})},zr,js=Fo(async e=>Ho(await me.get(Q).getOrder({id:e.orderId,projectId:e.projectId})));function sm(){let{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:o}=T()??qt;return{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:o}}function lm(){return(T()?.products??[]).map(e=>({id:e.id,quantity:e.quantity}))}function Fs(e){let t=T();V({...t,products:jo(t?.products??[],e)}),Ie()}function Hs(e){return zr??=qo({projectId:e,fetchStatus:js,removeLines:Fs}).catch(t=>{console.warn("cannot check the pending order",t)}).finally(()=>{zr=void 0}),zr}var it=async(e,t)=>{let n=[];t?.items!=null&&t.items.length>0?n=t.items:n=T()?.products??[];let o=Array.from(new Set(n.map(i=>i.productID)));if(o.length===0)return[];let r=new URLSearchParams;r.set("ids",o.join(",")),r.set("locale",t?.locale??A());let a;try{let i=await fetch(nr(ot(e,`/products?${r.toString()}`)),{method:"GET"});if(i.status!=200)return B("products-load-failed","internal");a=await i.json()}catch(i){return console.warn("cannot load the products of the cart",i),B("products-load-failed","internal")}return n.flatMap(i=>{let d=Ro(i.productID,a.result);return d==null?[]:[{...i,details:Ws(i.productID,d),catalogProductID:d.id}]})},dm=()=>{let e=Ms(Yo);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},cm=zs,qs=R.object({isAvailable:R.boolean(),merchantId:R.string(),merchantName:R.string(),gateway:R.string(),gatewayId:R.string()}),$s=R.object({id:R.string(),productID:R.string(),quantity:R.number(),priceVersion:R.string().optional(),amount:R.number().int().nonnegative().optional(),metadata:R.record(R.string(),R.string().optional()).optional(),url:R.string().optional()}),Bs=R.object({country:R.string().optional(),couponCode:R.string().optional(),selectedDeliveryMethod:R.string().optional(),postalCode:R.string().optional(),email:R.string().optional(),products:R.array($s).optional(),googlePayConfig:qs.optional()}),qt={country:void 0,couponCode:void 0,email:void 0,selectedDeliveryMethod:void 0,postalCode:void 0,products:[],googlePayConfig:void 0},$r="checkout";function Ks(){return typeof localStorage>"u"?[]:(T().products??[]).map(e=>({...e}))}function um(){return Ks().map(e=>`${e.productID}:${e.quantity}`).sort().join(",")}function pm(e){let t=T();if(!(t.products==null||t.products.length===0))return{items:t.products.map(n=>({id:n.productID,quantity:n.quantity,...n.priceVersion!=null?{priceVersion:n.priceVersion}:{},...n.amount!=null?{amount:n.amount}:{}})),...t.country!=null?{countries:[t.country]}:{},...t.couponCode!=null?{couponCode:t.couponCode}:{},...t.selectedDeliveryMethod!=null?{deliveryMethod:t.selectedDeliveryMethod}:{},locale:e}}function mm(e){let t=T(),n=new Map;for(let o of t.products??[]){let r=n.get(o.productID)??[];r.push(o),n.set(o.productID,r)}t.products=e.map(o=>{let r=n.get(o.productId)?.shift();return{id:Math.random().toString(36).substring(7),productID:o.productId,quantity:o.quantity,...r?.priceVersion!=null?{priceVersion:r.priceVersion}:{},...r?.metadata!=null?{metadata:r.metadata}:{},...r?.url!=null?{url:r.url}:{}}}),V(t),Ie()}function fm(e){let t=new Map;for(let r of e)t.set(r.id,(t.get(r.id)??0)+r.quantity);let n=T(),o=(n.products??[]).flatMap(r=>{let a=t.get(r.productID);return a==null?[r]:r.quantity<=a?[]:[{...r,quantity:r.quantity-a}]});V({...n,products:o}),Ie()}function gm(e){let t=T();t.products=t.products??[];for(let n of e)t.products.push({id:Math.random().toString(36).substring(7),productID:n.id,quantity:n.quantity});V(t),Ie()}function T(){try{let e=localStorage.getItem($r);return e==null?qt:Bs.parse(JSON.parse(e))}catch{return qt}}async function Bo(e,t){let n=await it(e,{items:t.map((a,i)=>({...a,id:`price-check-${i}`}))});if(Ue(n))return n;let o=Do(t.map(a=>a.productID),n);if(o.length>0)return B("item-ids-not-found","notFound",o);let r=T();r.products==null&&(r.products=[]),r.products.push(...t.map(a=>({id:Math.random().toString(36).substring(7),productID:a.productID,quantity:a.quantity,priceVersion:n.find(i=>i.productID===a.productID)?.details?.pricing?.priceVersion,amount:a.amount,metadata:a.metadata,url:Mo(a.url,typeof window<"u"?window.location.href:void 0)}))),Gs(t,n),Mr({event:"addToCart",currency:"PLN",items:t.map(a=>({id:a.productID,name:a.name??"",price:a.price??0,quantity:a.quantity,currency:a.currency??"PLN"}))}),V(r),Ie()}function Gs(e,t){for(let n of e)try{let o=t.find(d=>d.productID===n.productID),r=o?.details?.pricing?.effectivePrice??o?.details?.price??n.price,a=o?.details?.currency??n.currency;if(r==null||a==null)continue;let i=o?.catalogProductID??n.productID;(n.analytics??mn()).track("add_to_cart",{qty:n.quantity,value_minor:Math.round(r*n.quantity),currency:a},{product_id:i,variant_id:i!==n.productID?n.productID:null})}catch{}}function Ko(e){let t=T(),n={...t,products:t?.products?.filter(o=>!e.includes(o.productID)&&!e.includes(o.id))};Mr({event:"removeFromCart",items:e.map(o=>({id:o,name:"",price:0,quantity:1,currency:"PLN"}))}),V(n),Ie()}function V(e){localStorage.setItem($r,JSON.stringify(e)),Zo()}var Ft=new Set,Jo=0,jt=!1;function Go(e){e.key===$r&&Zo()}function ym(e){return Ft.add(e),!jt&&typeof window<"u"&&(window.addEventListener("storage",Go),jt=!0),()=>{Ft.delete(e),Ft.size===0&&jt&&(window.removeEventListener("storage",Go),jt=!1)}}function hm(){return Jo}function Zo(){Jo+=1;for(let e of Ft)try{e()}catch{}}function Vo(e,t){if(e.products==null||e.products.length==0)return;let n=e.products.reduce((o,r)=>(r.metadata!=null&&Object.keys(r.metadata).forEach(a=>{let i=r.metadata?.[a];i!=null&&(o[a]=i)}),o),{});return{items:e.products.map(o=>({id:o.productID,quantity:o.quantity,priceVersion:o.priceVersion,...o.amount!=null?{amount:o.amount}:{}})),askForNote:!0,countries:e.country?[e.country]:void 0,metadata:n,locale:t}}var Br=(e,t=A(),n)=>{let o=_s();return o!=null&&fn(o),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await me.get(Q).isOneClickPaymentAvailable({projectId:e})).applePay}catch(r){return console.error("Error checking if Apple Pay is available",r),!1}},async getGooglePayConfiguration(r){if(typeof window>"u"||typeof document>"u")return{isAvailable:!1};try{let a=await Vs(e);if(a?.isAvailable!=!0)return{isAvailable:!1};let i=T();if(i==null)return console.log("checkout is null"),{isAvailable:!1};let d=await it(e,{locale:t,items:r.items.map(P=>({id:Math.random().toString(36).substring(7),quantity:P.quantity,metadata:P.metadata,productID:P.productID}))});if(Ue(d))return{isAvailable:!1};let c=await me.get(Q).getPreOrderDetails({items:d.map(P=>Ne(Nt,{id:P.productID,quantity:P.quantity})),projectId:e,postCode:i.postalCode,couponCode:i.couponCode,countryCode:i.country,selectedDeliveryMethod:i.selectedDeliveryMethod});if(c.totalAmount==null)return{isAvailable:!1};let l=d.find(P=>P.details?.isDeliverable==!0)!=null,f=await Ao({items:d,googlePayConfig:a,checkout:i,cartRequiresShipping:l,result:c,locale:t,texts:n});return f==null?{isAvailable:!1}:{isAvailable:!0,config:f}}catch(a){return console.error("Error resolving Google Pay configuration",a),{isAvailable:!1}}},async clearCart(){let r=structuredClone(qt);r.country=T()?.country,V(r),Ie()},async getAvailableCountries(){let r=await fetch(nr(ot(e,"/countries")),{method:"GET"});if(r.status!=200)return[];try{return R.array(R.object({name:R.string(),code:R.string()})).parse(await r.json())}catch(a){return B(a.toString(),"internal")}},async getCountry(){let r=T()?.country;if(r==null){r="PL";let a=T();a.country=r,V(a)}return r},async getNumberOfElementsInCart(){return T()?.products?.reduce((r,a)=>r+a.quantity,0)??0},async getProducts(){return await it(e,{locale:t})},async removeProductFromCart(r){return Ko([r.id])},async setCountry(r){let a=T();a.country=r,V(a)},async setCouponCodeIfPossible(r){let a=T();a.couponCode=r,V(a)},async setPostalCode(r){let a=T();a.postalCode=r,V(a)},async setDeliveryMethod(r){let a=T();a.selectedDeliveryMethod=r,V(a)},async setEmail(r){let a=T();a.email=r,V(a)},async addProduct(r){return await Bo(e,[r])},async updateQuantity(r){let a=T();a.products=a.products?.map(i=>(i.id===r.id&&(i.quantity=r.quantity),i)),V(a),Ie()},async getPaymentMethodChoice(){let r=Vo(T(),t);return r==null?null:Wo(r)},async redirectToNextStep(r){let a=Vo(T(),t);if(a==null)return B("cart-is-empty","badInput");r?.paymentMethod!=null&&(a.paymentMethod=r.paymentMethod);let i=await Fr(a);return Ue(i)?(console.warn("cannot create payment URL",i.error),i):{url:i.url,...i.orderId!=null?{orderId:i.orderId}:{},...i.projectId!=null?{projectId:i.projectId}:{}}},async justRedirectToPayment(r){let a={items:[{id:r.productID,quantity:1}],askForNote:!1,details:r.email||r.name?{name:r.name,email:r.email}:void 0,locale:r.locale??t};a=qr(a),r.country==null&&(r.country="pl"),a.details==null&&(a.details={}),a.details.address==null&&(a.details.address={}),a.details.address.country=r.country,r.marketingAgreement===!0&&(a.additionalAgreements=[{id:Us,name:"",required:!0,answer:!0}]);let i=await Fr(a);return Ue(i)?i:{url:i.url}},async getApplePayPreview(r){let a=T();try{let i=await me.get(Q).getPreOrderDetails({items:r.items.map(d=>Ne(Nt,{id:d.productID,quantity:d.quantity})),projectId:e,postCode:a.postalCode,couponCode:a.couponCode,countryCode:a.country,selectedDeliveryMethod:a.selectedDeliveryMethod});return i.totalAmount==null||i.currency.length===0?B("pre-order-unavailable","internal"):{countryCode:i.country||a.country||"PL",currencyCode:i.currency,totalAmount:`${j(i.totalAmount/100,2)}`}}catch(i){return console.warn("cannot load the Apple Pay preview",i),B("pre-order-unavailable","internal")}},async completeApplePayPayment(r){let a=T();if(a==null)return B("Checkout not found");let i=await it(e,{locale:t});if(Ue(i))return i;try{let d=r.shippingContact?.givenName;r.shippingContact?.familyName!=null?d+=" "+r.shippingContact?.familyName:r.billingContact?.familyName!=null&&(d+=" "+r.billingContact?.familyName);let c={},l=Ht();l!=null&&(c.ref=l);let f=await me.get(Q).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(r.token.paymentData),paymentMethod:JSON.stringify(r.token.paymentMethod),transactionIdentifier:r.token.transactionIdentifier,order:Ne(ir,{items:i.map(P=>({id:P.productID,quantity:P.quantity})),couponCode:a.couponCode,email:r.shippingContact?.emailAddress??r.billingContact?.emailAddress??a.email??void 0,phone:r.shippingContact?.phoneNumber??r.billingContact?.phoneNumber??void 0,selectedDeliveryMethod:a.selectedDeliveryMethod,postCode:a.postalCode,projectId:e}),shippingAddress:Ne(or,{line1:r.shippingContact?.addressLines?.[0]??"",city:r.shippingContact?.locality??"",country:r.shippingContact?.countryCode??"",zipCode:r.shippingContact?.postalCode??"",name:d}),billingAddress:Ne(ar,{name:r.billingContact?.givenName??" "+(r.billingContact?.familyName??""),line1:r.billingContact?.addressLines?.[0]??"",city:r.billingContact?.locality??"",country:r.billingContact?.countryCode??"",zipCode:r.billingContact?.postalCode??""}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:f.isSuccess,redirectURL:f.redirectUrl}}catch(d){return console.error(d),B("Failed to authorize payment")}},async completeGooglePayPayment(r){let a=T();if(a==null)return B("Checkout not found");let i=await it(e,{locale:t});if(Ue(i))return i;try{let d=r.paymentData.shippingAddress?.name,c={},l=Ht();l!=null&&(c.ref=l);let f=await me.get(Q).authorizeOneClickPayment({gateway:1,paymentData:r.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:r.paymentData.paymentMethodData.type,transactionIdentifier:"",order:Ne(ir,{items:i.map(P=>({id:P.productID,quantity:P.quantity})),couponCode:a.couponCode,email:r.paymentData.email??void 0,phone:r.paymentData.shippingAddress?.phoneNumber??void 0,selectedDeliveryMethod:r.paymentData.shippingOptionData?.id??a.selectedDeliveryMethod,postCode:r.paymentData.shippingAddress?.postalCode,projectId:e}),shippingAddress:Ne(or,{line1:r.paymentData.shippingAddress?.address1??"",city:r.paymentData.shippingAddress?.locality??"",country:r.paymentData.shippingAddress?.countryCode??"",zipCode:r.paymentData.shippingAddress?.postalCode??"",name:d}),billingAddress:Ne(ar,{name:r.paymentData.paymentMethodData.info?.billingAddress?.name,line1:r.paymentData.paymentMethodData.info?.billingAddress?.address1??"",city:r.paymentData.paymentMethodData.info?.billingAddress?.locality??"",country:r.paymentData.paymentMethodData.info?.billingAddress?.countryCode??"",zipCode:r.paymentData.paymentMethodData.info?.billingAddress?.postalCode??""}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:f.isSuccess,redirectURL:f.redirectUrl}}catch(d){return console.error(d),B("Failed to authorize payment")}return{isSuccess:!0}},async getApplePayPaymentRequest(r){let a=T();if(a==null)return B("Checkout not found");r&&r.expectedItems!=null&&r.expectedItems.length>0&&(a.products&&Ko(a.products.map(l=>l.productID)),await Bo(e,r.expectedItems));let i=await it(e,{locale:t});if(Ue(i))return i;let d=await me.get(Q).getPreOrderDetails({items:i.map(l=>Ne(Nt,{id:l.productID,quantity:l.quantity})),projectId:e,postCode:a.postalCode,couponCode:a.couponCode,countryCode:a.country,selectedDeliveryMethod:a.selectedDeliveryMethod}),c=i.map(l=>({amount:`${j(l.quantity*(l.details?.pricing?.effectivePrice??l.details?.price??0)/100,2)}`,label:l.details?.name+" - "+l.quantity,type:"final"}));if(d.selectedDeliveryMethod!=null){let l=d.methods.find(f=>f.id==d.selectedDeliveryMethod);l!=null&&c.push({amount:`${j(l.amount/100,2)}`,label:l.name,type:"final"})}return d.couponCode!=null&&d.couponValue!=null&&c.push({amount:`-${j(d.couponValue/100,2)}`,label:d.couponCode,type:"final"}),{countryCode:d.country||a.country||"PL",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],total:{amount:`${j((d.totalAmount??0)/100,2)}`,label:Te("paymentForCart",t,n),type:"final"},shippingMethods:d.methods.map(l=>({amount:`${j(l.amount/100,2)}`,detail:l.description??"",identifier:l.id,label:l.name,dateComponentsRange:{startDateComponents:{days:l.minDays??1,hours:0,months:0,years:0},endDateComponents:{days:l.maxDays??14,hours:0,months:0,years:0}}})),lineItems:c,currencyCode:d.currency||i[0]?.details?.currency||"PLN"}}}};async function Vs(e){let t=T();if(t.googlePayConfig?.isAvailable!=!0){let n=await me.get(Q).isOneClickPaymentAvailable({projectId:e});n.googlePay==!0&&n.googlePayConfig!=null?t.googlePayConfig={isAvailable:!0,gateway:n.googlePayConfig.gateway,gatewayId:n.googlePayConfig.gatewayMerchantId,merchantName:n.googlePayConfig.merchantName,merchantId:n.googlePayConfig.merchantId}:t.googlePayConfig={isAvailable:!1,gateway:"",gatewayId:"",merchantName:"",merchantId:""}}return V(t),t.googlePayConfig}function Ws(e,t){if(e==t.id){let o=t.variants?.findIndex(r=>r.id===e);if(o!=null&&o!=-1){let r=t.variants[o];return{...t,availableQuantity:r.availableQuantity,isDeliverable:r.isDeliverable,images:r.images??t.images,name:t.name+" "+r.name,baseName:t.name,variantName:r.name,price:r.price,currency:r.currency,pricing:r.pricing}}return t}let n=t.variants?.find(o=>o.id===e);return n==null?t:{...t,id:n.id,name:t.name+" "+n.name,baseName:t.name,variantName:n.name,price:n.price,currency:n.currency,pricing:n.pricing,metadata:t.metadata,availableQuantity:n.availableQuantity,isDeliverable:n.isDeliverable,images:n.images??t.images}}function Ie(){let e=T(),t=0;if(e==null){at.setState(n=>({...n,numberOfProductsInCart:t}));return}t=e.products?.reduce((n,o)=>n+o.quantity,0)??0,at.setState(n=>({...n,numberOfProductsInCart:t}))}var Js=200,Zs="item-ids-not-found",Pt="internal-error",Qo={"no-payment-gateway":"noPaymentGateway","gateway-not-configured":"gatewayNotConfigured","shipping-not-configured":"shippingNotConfigured","mixed-recurring":"mixedRecurring","currency-unsupported":"currencyUnsupported","price-changed":"priceChanged","product-not-found":"unavailableProducts","product-not-available":"unavailableProducts"},Qs=new Set(["internal","invalid-request"]),Xs=new Set(["product-not-available","product-not-found"]);function el(e){return typeof e=="string"&&Object.hasOwn(Qo,e)?Qo[e]:void 0}function tl(e){return/<\/?[a-z!?][^>]*>/i.test(e)}function rl(e){return/^[A-Za-z][A-Za-z0-9]*(?:[-_.:][A-Za-z0-9]+)*$/.test(e)&&!/^[A-Z][a-z]+$/.test(e)||/^\[object \w+\]$|^(?:undefined|null)$/.test(e)}function nl(e){return/Error:/.test(e)||/\n\s+at /.test(e)}function Kr(e){let t=e.trim();if(!(t.length===0||t.length>Js||/[\r\n]/.test(t)||tl(t)||rl(t)||nl(t)))return t}var ol=3;function $t(e,t=0){if(typeof e=="object"&&e!=null){if(Array.isArray(e)||t>=ol)return{};let n=e,o=$t(n.error,t+1);if(o.message==null&&n.message!=null){let r=$t(n.message,t+1);o={...r,code:o.code??r.code}}return typeof n.code=="string"&&n.code.length>0&&(o.code=n.code),o}if(typeof e!="string")return{};try{let n=JSON.parse(e);return typeof n=="object"&&n!=null?$t(n,t+1):{}}catch{}return{message:Kr(e)}}function al(e){let t;try{t=JSON.parse(e)}catch{return{code:Pt,message:Kr(e)}}if(typeof t=="string")return{code:Pt,message:Kr(t)};if(typeof t!="object"||t==null)return{code:Pt};let n=t,{message:o,code:r}=$t(n.error),a={code:typeof n.code=="string"&&n.code.length>0?n.code:r??Pt,message:o};return Array.isArray(n.itemIds)&&(a.itemIds=n.itemIds.filter(i=>typeof i=="string")),a}function Gr(e,t){let{code:n,message:o,itemIds:r}=al(t),a=r!=null&&r.length>0;if(a&&(n===Pt||Xs.has(n)))return B(Zs,"badInput",r);let i={message:o};return a&&(i.itemIds=r),B(n,e>=500?"internal":"badInput",i)}function xm(e,t){let n=el(e.error);if(n!=null)return t(n);if(e.type==="internal"||typeof e.error=="string"&&Qs.has(e.error))return t("checkoutFailed");let o=e.data?.message;return typeof o=="string"&&o.length>0?o:t("checkoutFailed")}var il=["online","manual","cod"],sl=["bankTransfer","blik"];function Xo(e,t){if(!Array.isArray(e))return[];let n=[];for(let o of e)t.includes(o)&&!n.includes(o)&&n.push(o);return n}function ll(e){if(typeof e!="object"||e==null)return null;let t=e.choice;if(typeof t!="object"||t==null)return null;let n=Xo(t.methods,il);return n.length<2?null:{methods:n,manualAccountTypes:Xo(t.manualAccountTypes,sl)}}function Cm(e){if(e==null)return null;let t=e.methods.filter(n=>n!=="cod");return t.length<2?null:{...e,methods:t}}function Nm(e,t){return t!=null&&e.methods.includes(t)?t:e.methods[0]}function Im(e){let t=e.includes("bankTransfer"),n=e.includes("blik");return n&&!t?"paymentMethodManualBlik":t&&!n?"paymentMethodManualTransfer":"paymentMethodManualBoth"}async function ea(e,t,n=5e3){let o=typeof AbortController>"u"?void 0:new AbortController,r=setTimeout(()=>o?.abort(),n);try{let a=await fetch(e,{method:"POST",headers:t.headers,body:t.body,signal:o?.signal});return a.ok?ll(await a.json()):null}catch{return null}finally{clearTimeout(r)}}var dl;(o=>{async function e(r,a=1,i,d){let c=st();if(c==null)throw new Error("No project ID found");let f=await Br(c).addProduct({productID:r,quantity:a,metadata:i,...d});if(f!=null)return f}o.addProductToCart=e;function t(){at.setState({isCartVisible:!0})}o.showCart=t;function n(){at.setState({isCartVisible:!1})}o.hideCart=n})(dl||={});async function ta(e){try{return await e.text()}catch{return""}}function ra(e,t){return t=qr(t),t.locale??=A(),{headers:{...rr,...lr(e),"Content-Type":"application/json"},body:JSON.stringify(t)}}async function Wo(e){let t=st();return t==null?null:ea(ot(t,"/payment-methods"),ra(t,e))}async function Fr(e){let t=st();if(t==null)throw new Error("No project ID found");let n=await fetch(ot(t,"/buy"),{method:"POST",...ra(t,e)});if(n.status!=200){let r=Gr(n.status,await ta(n));return console.warn("cannot create payment URL",n.status,r.error),r}let o=await n.json();return{url:o.url,...o.orderId!=null?{orderId:o.orderId}:{},...o.projectId!=null?{projectId:o.projectId}:{}}}async function Um(e){let t=st();if(t==null)throw new Error("No project ID found");let n={...rr,...lr(t),"Content-Type":"application/json",...e.apiKey!=null?{Authorization:`Bearer ${e.apiKey}`}:{}},o=e.testMode?`/api/payment/link/auto/${t}/test`:`/api/payment/link/auto/${t}`;delete e.apiKey,delete e.testMode,e.locale??=A();let r=await fetch(Q+o,{method:"POST",headers:n,body:JSON.stringify(e)});return r.ok?{status:"ok",redirectURL:(await r.json()).url}:{...Gr(r.status,await ta(r)),status:"error"}}function Ht(){if(typeof localStorage>"u")return;let e=localStorage.getItem("bitsnap-ref");if(e!=null)return e}function qr(e){let t=Ht();return t==null||(e.metadata==null&&(e.metadata={}),e.metadata.ref=t),e}export{me as a,Re as b,je as c,Fe as d,De as e,zn as f,gt as g,yt as h,Ze as i,Qe as j,Na as k,Ue as l,Zs as m,xm as n,Cm as o,Nm as p,Im as q,at as r,dl as s,Wo as t,Fr as u,Um as v,Ht as w,qr as x,Lp as y,Tp as z,Ap as A,j as B,To as C,Mr as D,Mp as E,Dr as F,ms as G,Us as H,Hr as I,im as J,st as K,sm as L,lm as M,Hs as N,dm as O,cm as P,Ks as Q,um as R,pm as S,mm as T,fm as U,gm as V,ym as W,hm as X,Vo as Y,Br as Z};
5
+ //# sourceMappingURL=chunk-T5JO4SP7.mjs.map