bitsnap-react 1.18.1 → 1.20.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 (153) hide show
  1. package/AGENTS.md +21 -0
  2. package/README.md +45 -0
  3. package/dist/BitsnapCart-LHJ6KOTV.css +2 -0
  4. package/dist/BitsnapCart-LHJ6KOTV.css.map +1 -0
  5. package/dist/BitsnapCart-V4S4EXYV.js +2 -0
  6. package/dist/BitsnapCart-V4S4EXYV.js.map +1 -0
  7. package/dist/BitsnapCart-Z6JFYNH2.mjs +2 -0
  8. package/dist/CartProvider-5NP4WACK.js +2 -0
  9. package/dist/CartProvider-5NP4WACK.js.map +1 -0
  10. package/dist/CartProvider-G7FQUPXL.mjs +2 -0
  11. package/dist/PanelModelFiles-EKQRLF46.js.map +1 -1
  12. package/dist/analytics.js +1 -1
  13. package/dist/analytics.js.map +1 -1
  14. package/dist/analytics.mjs +1 -1
  15. package/dist/catalog.js +1 -1
  16. package/dist/catalog.js.map +1 -1
  17. package/dist/catalog.mjs +1 -1
  18. package/dist/chat.css +2 -0
  19. package/dist/chat.css.map +1 -0
  20. package/dist/chat.d.mts +173 -0
  21. package/dist/chat.d.ts +173 -0
  22. package/dist/chat.js +2 -0
  23. package/dist/chat.js.map +1 -0
  24. package/dist/chat.mjs +2 -0
  25. package/dist/chat.mjs.map +1 -0
  26. package/dist/chunk-2G46TAUX.mjs +2 -0
  27. package/dist/chunk-2G46TAUX.mjs.map +1 -0
  28. package/dist/{chunk-N3B25GTY.js → chunk-4Y233NII.js} +2 -2
  29. package/dist/chunk-4Y233NII.js.map +1 -0
  30. package/dist/chunk-5M3OUOMU.mjs +5 -0
  31. package/dist/chunk-5M3OUOMU.mjs.map +1 -0
  32. package/dist/chunk-6Q3VGPSF.js.map +1 -1
  33. package/dist/chunk-A2ZDFN3J.mjs +2 -0
  34. package/dist/{chunk-ZM5T4TQW.mjs.map → chunk-A2ZDFN3J.mjs.map} +1 -1
  35. package/dist/{chunk-DR7WYI37.js → chunk-AQYHQY2Y.js} +2 -2
  36. package/dist/chunk-AQYHQY2Y.js.map +1 -0
  37. package/dist/{chunk-62WDFH7K.mjs → chunk-BTERIY6N.mjs} +2 -2
  38. package/dist/chunk-C736F727.js +2 -0
  39. package/dist/chunk-C736F727.js.map +1 -0
  40. package/dist/chunk-EFN4OW2C.js +2 -0
  41. package/dist/chunk-EFN4OW2C.js.map +1 -0
  42. package/dist/chunk-EMR4YXNY.mjs +2 -0
  43. package/dist/chunk-EMR4YXNY.mjs.map +1 -0
  44. package/dist/chunk-GHBRR665.js +2 -0
  45. package/dist/chunk-GHBRR665.js.map +1 -0
  46. package/dist/chunk-HKRH6FI6.mjs +2 -0
  47. package/dist/chunk-HKRH6FI6.mjs.map +1 -0
  48. package/dist/chunk-HP3I6D2R.js +2 -0
  49. package/dist/chunk-HP3I6D2R.js.map +1 -0
  50. package/dist/{chunk-G4SEOVLD.js → chunk-IRZJIPUF.js} +2 -2
  51. package/dist/chunk-IRZJIPUF.js.map +1 -0
  52. package/dist/chunk-IXQCN7MR.mjs +2 -0
  53. package/dist/chunk-IXQCN7MR.mjs.map +1 -0
  54. package/dist/chunk-IXX6SUMB.mjs +2 -0
  55. package/dist/chunk-IXX6SUMB.mjs.map +1 -0
  56. package/dist/chunk-JSDGZ4NY.js.map +1 -1
  57. package/dist/chunk-KDL35KEI.js +2 -0
  58. package/dist/chunk-KDL35KEI.js.map +1 -0
  59. package/dist/chunk-KO7ZERN5.mjs +2 -0
  60. package/dist/chunk-KO7ZERN5.mjs.map +1 -0
  61. package/dist/chunk-KOYBZORL.js.map +1 -1
  62. package/dist/chunk-KZWCVKLU.js +5 -0
  63. package/dist/chunk-KZWCVKLU.js.map +1 -0
  64. package/dist/chunk-LHNTSQYO.mjs +2 -0
  65. package/dist/chunk-LHNTSQYO.mjs.map +1 -0
  66. package/dist/chunk-LHQEM3CU.mjs +2 -0
  67. package/dist/chunk-LHQEM3CU.mjs.map +1 -0
  68. package/dist/chunk-MDAFPGPA.js +2 -0
  69. package/dist/chunk-MDAFPGPA.js.map +1 -0
  70. package/dist/chunk-Q337IQNA.js.map +1 -1
  71. package/dist/chunk-RJPQMDIQ.js +2 -0
  72. package/dist/chunk-RJPQMDIQ.js.map +1 -0
  73. package/dist/{chunk-GKJURMDO.mjs → chunk-TW25G7XX.mjs} +2 -2
  74. package/dist/{chunk-GKJURMDO.mjs.map → chunk-TW25G7XX.mjs.map} +1 -1
  75. package/dist/{chunk-UTUPPMLK.mjs → chunk-URQBHNJK.mjs} +2 -2
  76. package/dist/chunk-W3RGQYPD.js.map +1 -1
  77. package/dist/chunk-XEXPQFKN.mjs +2 -0
  78. package/dist/chunk-XEXPQFKN.mjs.map +1 -0
  79. package/dist/chunk-YPA6MMGJ.js +2 -0
  80. package/dist/chunk-YPA6MMGJ.js.map +1 -0
  81. package/dist/chunk-Z3YOJ6NZ.js +2 -0
  82. package/dist/chunk-Z3YOJ6NZ.js.map +1 -0
  83. package/dist/consent.js.map +1 -1
  84. package/dist/course.d.mts +2 -14
  85. package/dist/course.d.ts +2 -14
  86. package/dist/course.js +1 -1
  87. package/dist/course.js.map +1 -1
  88. package/dist/course.mjs +1 -1
  89. package/dist/course.mjs.map +1 -1
  90. package/dist/embed/analytics.js +1 -1
  91. package/dist/errors.js.map +1 -1
  92. package/dist/index.css +1 -1
  93. package/dist/index.css.map +1 -1
  94. package/dist/index.d.mts +50 -33
  95. package/dist/index.d.ts +50 -33
  96. package/dist/index.js +1 -1
  97. package/dist/index.js.map +1 -1
  98. package/dist/index.mjs +1 -1
  99. package/dist/index.mjs.map +1 -1
  100. package/dist/internal.js.map +1 -1
  101. package/dist/methods-33CWGKNA.mjs +2 -0
  102. package/dist/methods-33CWGKNA.mjs.map +1 -0
  103. package/dist/methods-4GB652MQ.js +2 -0
  104. package/dist/methods-4GB652MQ.js.map +1 -0
  105. package/dist/model-files-client-P4PORZJ6.js.map +1 -1
  106. package/dist/models.js.map +1 -1
  107. package/dist/returns.js +1 -1
  108. package/dist/returns.js.map +1 -1
  109. package/dist/returns.mjs +1 -1
  110. package/dist/texts-9kfgClsA.d.mts +14 -0
  111. package/dist/texts-9kfgClsA.d.ts +14 -0
  112. package/dist/{types-D6LsoycW.d.mts → types-CjWyHunk.d.mts} +9 -1
  113. package/dist/{types-ClFCVzk_.d.ts → types-DfqzDP9k.d.ts} +9 -1
  114. package/dist/viewer3d.js.map +1 -1
  115. package/dist/viewer3d.mjs +2 -2
  116. package/dist/viewer3d.mjs.map +1 -1
  117. package/dist/widgets-Bsojw94g.d.ts +556 -0
  118. package/dist/widgets-u7xMJbsY.d.mts +556 -0
  119. package/package.json +16 -2
  120. package/dist/CartProvider-CC6YIZVS.js +0 -2
  121. package/dist/CartProvider-CC6YIZVS.js.map +0 -1
  122. package/dist/CartProvider-ZL65WZN6.mjs +0 -2
  123. package/dist/chunk-2XSLIZ27.js +0 -2
  124. package/dist/chunk-2XSLIZ27.js.map +0 -1
  125. package/dist/chunk-5OCGXVLC.js +0 -2
  126. package/dist/chunk-5OCGXVLC.js.map +0 -1
  127. package/dist/chunk-5YN752OV.mjs +0 -2
  128. package/dist/chunk-5YN752OV.mjs.map +0 -1
  129. package/dist/chunk-7BG22YBF.js +0 -5
  130. package/dist/chunk-7BG22YBF.js.map +0 -1
  131. package/dist/chunk-AHISXVEE.js +0 -2
  132. package/dist/chunk-AHISXVEE.js.map +0 -1
  133. package/dist/chunk-DR7WYI37.js.map +0 -1
  134. package/dist/chunk-EOFJAQPT.js +0 -2
  135. package/dist/chunk-EOFJAQPT.js.map +0 -1
  136. package/dist/chunk-G4SEOVLD.js.map +0 -1
  137. package/dist/chunk-IGQZP4YR.mjs +0 -2
  138. package/dist/chunk-IGQZP4YR.mjs.map +0 -1
  139. package/dist/chunk-N3B25GTY.js.map +0 -1
  140. package/dist/chunk-VWA3ZCNI.mjs +0 -2
  141. package/dist/chunk-VWA3ZCNI.mjs.map +0 -1
  142. package/dist/chunk-YGE2223J.mjs +0 -5
  143. package/dist/chunk-YGE2223J.mjs.map +0 -1
  144. package/dist/chunk-ZKT4N553.mjs +0 -2
  145. package/dist/chunk-ZKT4N553.mjs.map +0 -1
  146. package/dist/chunk-ZM5T4TQW.mjs +0 -2
  147. package/dist/methods-7DWKFCPK.js +0 -2
  148. package/dist/methods-7DWKFCPK.js.map +0 -1
  149. package/dist/methods-DQTADIN4.mjs +0 -2
  150. /package/dist/{CartProvider-ZL65WZN6.mjs.map → BitsnapCart-Z6JFYNH2.mjs.map} +0 -0
  151. /package/dist/{methods-DQTADIN4.mjs.map → CartProvider-G7FQUPXL.mjs.map} +0 -0
  152. /package/dist/{chunk-62WDFH7K.mjs.map → chunk-BTERIY6N.mjs.map} +0 -0
  153. /package/dist/{chunk-UTUPPMLK.mjs.map → chunk-URQBHNJK.mjs.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/user/bitsnap-react-payment-release/dist/chunk-JSDGZ4NY.js"],"names":[],"mappings":"AAAA,6EAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,6BAAqB","file":"/home/user/bitsnap-react-payment-release/dist/chunk-JSDGZ4NY.js"}
1
+ {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/chat-free-pwyw/dist/chunk-JSDGZ4NY.js"],"names":[],"mappings":"AAAA,6EAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,6BAAqB","file":"/home/emems/.t3/worktrees/bitsnap-react/chat-free-pwyw/dist/chunk-JSDGZ4NY.js"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYPA6MMGJjs = require('./chunk-YPA6MMGJ.js');var _chunkMDAFPGPAjs = require('./chunk-MDAFPGPA.js');var _chunkIRZJIPUFjs = require('./chunk-IRZJIPUF.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=_chunkIRZJIPUFjs.n.call(void 0, n.projectID,s,"panel");return _jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.j,{children:_jsxruntime.jsx.call(void 0, a.Provider,{value:{...n},children:_jsxruntime.jsx.call(void 0, _chunkIRZJIPUFjs.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-KDL35KEI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/chat-free-pwyw/dist/chunk-KDL35KEI.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-free-pwyw/dist/chunk-KDL35KEI.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"]}
@@ -0,0 +1,2 @@
1
+ import{c,d as l,e as p,f as d}from"./chunk-BTERIY6N.mjs";import{k as u}from"./chunk-TW25G7XX.mjs";var f=24,h=48,i=class extends Error{status;constructor(r,o){super(r),this.name="ProductListError",this.status=o}};function D(t){return t==null||!Number.isFinite(t)?f:Math.min(h,Math.max(1,Math.floor(t)))}function j(t,r){return Math.max(1,Math.ceil(t/r))}function s(t){return t.replace(/\/+$/,"")}function P(t){let r=new URLSearchParams;r.set("limit",String(t.limit)),r.set("offset",String(t.offset)),t.locale&&r.set("locale",t.locale);let o=t.search?.trim();return o&&r.set("search",o),`${s(t.host)}/api/integrations/${encodeURIComponent(t.projectID)}/public-commerce/product-list?${r.toString()}`}function I(t){return typeof t=="object"&&t!=null&&Array.isArray(t.items)&&typeof t.totalCount=="number"}async function x(t,r){let o=await fetch(c(P(t)),{method:"GET",credentials:"omit",headers:{Accept:"application/json"},signal:r});if(!o.ok)throw new i(`Could not load products (${o.status})`,o.status);let e=await o.json();if(!I(e))throw new i("Unexpected product list response");return e}function m(t,r){if(t.projectID!=null&&t.projectID!==r.projectID)return{ok:!1,reason:`the page cart already belongs to project "${t.projectID}"`};let o=null,e=r.host?s(r.host):"",a=s(t.host);if(e&&e!==a){if(a!==s(t.defaultHost))return{ok:!1,reason:`the page cart already uses the host "${t.host}"`};o=e}return{ok:!0,setProjectID:t.projectID==null?r.projectID:null,setHost:o}}function g(t,r){let o=r.cartItemId!=null&&r.cartItemId!==r.id?r.cartItemId:null;t.track("add_to_cart",{qty:1,value_minor:r.price,currency:r.currency},{product_id:r.id,variant_id:o})}async function E(t,r){let[{Bitsnap:o},{getProjectID:e,setProjectID:a}]=await Promise.all([import("./methods-33CWGKNA.mjs"),import("./CartProvider-G7FQUPXL.mjs")]),n=m({projectID:e(),host:p,defaultHost:l},r);if(!n.ok)return b(n.reason);if(n.setProjectID!=null&&a(n.setProjectID),n.setHost!=null&&d(n.setHost),await o.addProductToCart(t.cartItemId??t.id,1,void 0,{url:r.url,name:t.name,price:t.price,currency:t.currency,amount:t.amount,analytics:u})!=null)throw new Error("Could not add the product to the cart");r.analytics!=null&&g(r.analytics,t),r.showCart&&o.showCart()}function b(t){throw console.warn(`bitsnap-react: ProductList did not add to the cart because ${t}. Pass onAddToCart to use another cart.`),new Error("The page cart belongs to another project or host")}export{D as a,j as b,x as c,g as d,E as e};
2
+ //# sourceMappingURL=chunk-KO7ZERN5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/products/fetch.ts","../src/components/products/cart-target.ts","../src/components/products/add-to-cart.ts"],"sourcesContent":["import { withClientParam } from \"@/src/lib/client-header\";\nimport type { BitsnapModels } from \"@/src/models\";\n\nexport type PublicListProduct = BitsnapModels.PublicListProduct;\nexport type ProductListData = BitsnapModels.ProductListResponse;\n\nexport const DEFAULT_PAGE_SIZE = 24;\nexport const MAX_PAGE_SIZE = 48;\n\nexport type ProductListQuery = {\n projectID: string;\n /** Origin of the Bitsnap backend (or of a custom domain), without a path. */\n host: string;\n locale?: string;\n search?: string;\n limit: number;\n offset: number;\n};\n\nexport class ProductListError extends Error {\n readonly status: number | undefined;\n\n constructor(message: string, status?: number) {\n super(message);\n this.name = \"ProductListError\";\n this.status = status;\n }\n}\n\n/** Page size within what the backend accepts (1 to 48, default 24). */\nexport function clampPageSize(pageSize?: number): number {\n if (pageSize == null || !Number.isFinite(pageSize)) {\n return DEFAULT_PAGE_SIZE;\n }\n return Math.min(MAX_PAGE_SIZE, Math.max(1, Math.floor(pageSize)));\n}\n\nexport function pageCountFor(totalCount: number, pageSize: number): number {\n return Math.max(1, Math.ceil(totalCount / pageSize));\n}\n\n/** Origin without trailing slashes, so equal hosts compare equal as strings. */\nexport function normalizeHost(host: string): string {\n return host.replace(/\\/+$/, \"\");\n}\n\nexport function buildProductListURL(query: ProductListQuery): string {\n const params = new URLSearchParams();\n params.set(\"limit\", String(query.limit));\n params.set(\"offset\", String(query.offset));\n if (query.locale) {\n params.set(\"locale\", query.locale);\n }\n const search = query.search?.trim();\n if (search) {\n params.set(\"search\", search);\n }\n\n const host = normalizeHost(query.host);\n return `${host}/api/integrations/${encodeURIComponent(\n query.projectID,\n )}/public-commerce/product-list?${params.toString()}`;\n}\n\nfunction isProductListData(value: unknown): value is ProductListData {\n return (\n typeof value === \"object\" &&\n value != null &&\n Array.isArray((value as ProductListData).items) &&\n typeof (value as ProductListData).totalCount === \"number\"\n );\n}\n\n/**\n * Loads one page of the catalog with a plain, credential-less `fetch`. It does\n * not touch the global project ID or host.\n */\nexport async function fetchProductList(\n query: ProductListQuery,\n signal?: AbortSignal,\n): Promise<ProductListData> {\n const response = await fetch(withClientParam(buildProductListURL(query)), {\n method: \"GET\",\n credentials: \"omit\",\n headers: { Accept: \"application/json\" },\n signal,\n });\n\n if (!response.ok) {\n throw new ProductListError(\n `Could not load products (${response.status})`,\n response.status,\n );\n }\n\n const payload: unknown = await response.json();\n if (!isProductListData(payload)) {\n throw new ProductListError(\"Unexpected product list response\");\n }\n\n return payload;\n}\n","import { normalizeHost } from \"./fetch\";\n\nexport type CartState = {\n /** Project the page cart is set up for, `null` or `undefined` when none yet. */\n projectID: string | null | undefined;\n /** Backend origin the page cart currently talks to. */\n host: string;\n /** Backend origin used when the page did not choose another one. */\n defaultHost: string;\n};\n\nexport type CartTarget = {\n projectID: string;\n /** Omitted or empty keeps the current host. */\n host?: string;\n};\n\nexport type CartPlan =\n | { ok: true; setProjectID: string | null; setHost: string | null }\n | { ok: false; reason: string };\n\n/**\n * Decides, without changing anything, whether the page cart can serve the\n * target and what has to be filled in first. Both the project and the host are\n * checked before the caller changes either of them, so a refused click leaves\n * the page cart untouched.\n */\nexport function planCartTarget(state: CartState, target: CartTarget): CartPlan {\n if (state.projectID != null && state.projectID !== target.projectID) {\n return {\n ok: false,\n reason: `the page cart already belongs to project \"${state.projectID}\"`,\n };\n }\n\n let setHost: string | null = null;\n const targetHost = target.host ? normalizeHost(target.host) : \"\";\n const currentHost = normalizeHost(state.host);\n if (targetHost && targetHost !== currentHost) {\n if (currentHost !== normalizeHost(state.defaultHost)) {\n return {\n ok: false,\n reason: `the page cart already uses the host \"${state.host}\"`,\n };\n }\n setHost = targetHost;\n }\n\n return {\n ok: true,\n setProjectID: state.projectID == null ? target.projectID : null,\n setHost,\n };\n}\n","import { noopInstrument, type Instrument } from \"@/src/analytics/instrument\";\nimport { DEFAULT_HOST, HOST, setCustomHost } from \"../checkout/constants\";\nimport { planCartTarget } from \"./cart-target\";\nimport type { PublicListProduct } from \"./fetch\";\n\n/** What adding needs; a `PublicListProduct` fits, so does the 3D viewer's product. */\nexport type CartableProduct = Pick<\n PublicListProduct,\n \"id\" | \"cartItemId\" | \"name\" | \"price\" | \"currency\"\n> & { amount?: number };\n\nexport type AddToCartTarget = {\n projectID: string;\n /** Backend origin the cart talks to. Omitted or empty keeps the current one. */\n host?: string;\n /** Open the cart drawer afterwards. */\n showCart: boolean;\n /** Product page the cart item links to. */\n url?: string;\n /** Where `add_to_cart` is reported. Omitted: nothing is reported. */\n analytics?: Instrument;\n};\n\n/** `add_to_cart` for a product of the list (quantity 1, price in minor units). */\nexport function trackProductAdded(\n instrument: Instrument,\n product: CartableProduct,\n) {\n const variant =\n product.cartItemId != null && product.cartItemId !== product.id\n ? product.cartItemId\n : null;\n instrument.track(\n \"add_to_cart\",\n { qty: 1, value_minor: product.price, currency: product.currency },\n { product_id: product.id, variant_id: variant },\n );\n}\n\n/**\n * Default \"add to cart\" action of `ProductList`: `Bitsnap.addProductToCart`\n * with quantity 1, then the cart drawer.\n *\n * The checkout is a heavy module (RPC client, cart state, payment buttons), so\n * it is loaded on the first click and never ends up in the first paint of a\n * catalog page. The cart only knows one project and one host at a time, and\n * they are page-wide (the cart is kept in localStorage, `setProjectID` also\n * changes the panel configuration). So the list only fills them in when the\n * page has not set them yet; when the page already works for another project\n * or host, nothing is changed and the call fails (pass `onAddToCart` to the\n * list in that case).\n */\nexport async function addProductToCart(\n product: CartableProduct,\n target: AddToCartTarget,\n): Promise<void> {\n const [{ Bitsnap }, { getProjectID, setProjectID }] = await Promise.all([\n import(\"../checkout/methods\"),\n import(\"../checkout/CartProvider\"),\n ]);\n\n const plan = planCartTarget(\n { projectID: getProjectID(), host: HOST, defaultHost: DEFAULT_HOST },\n target,\n );\n if (!plan.ok) {\n return failConflict(plan.reason);\n }\n if (plan.setProjectID != null) {\n setProjectID(plan.setProjectID);\n }\n if (plan.setHost != null) {\n setCustomHost(plan.setHost);\n }\n\n // Single-variant products are added by their variant, not the product ID.\n const error = await Bitsnap.addProductToCart(\n product.cartItemId ?? product.id,\n 1,\n undefined,\n {\n url: target.url,\n name: product.name,\n price: product.price,\n currency: product.currency,\n amount: product.amount,\n // Reported below from the list's own data.\n analytics: noopInstrument,\n },\n );\n if (error != null) {\n throw new Error(\"Could not add the product to the cart\");\n }\n if (target.analytics != null) {\n trackProductAdded(target.analytics, product);\n }\n\n if (target.showCart) {\n Bitsnap.showCart();\n }\n}\n\nfunction failConflict(reason: string): never {\n console.warn(\n `bitsnap-react: ProductList did not add to the cart because ${reason}. ` +\n \"Pass onAddToCart to use another cart.\",\n );\n throw new Error(\"The page cart belongs to another project or host\");\n}\n"],"mappings":"kGAMO,IAAMA,EAAoB,GACpBC,EAAgB,GAYhBC,EAAN,cAA+B,KAAM,CACjC,OAET,YAAYC,EAAiBC,EAAiB,CAC5C,MAAMD,CAAO,EACb,KAAK,KAAO,mBACZ,KAAK,OAASC,CAChB,CACF,EAGO,SAASC,EAAcC,EAA2B,CACvD,OAAIA,GAAY,MAAQ,CAAC,OAAO,SAASA,CAAQ,EACxCN,EAEF,KAAK,IAAIC,EAAe,KAAK,IAAI,EAAG,KAAK,MAAMK,CAAQ,CAAC,CAAC,CAClE,CAEO,SAASC,EAAaC,EAAoBF,EAA0B,CACzE,OAAO,KAAK,IAAI,EAAG,KAAK,KAAKE,EAAaF,CAAQ,CAAC,CACrD,CAGO,SAASG,EAAcC,EAAsB,CAClD,OAAOA,EAAK,QAAQ,OAAQ,EAAE,CAChC,CAEO,SAASC,EAAoBC,EAAiC,CACnE,IAAMC,EAAS,IAAI,gBACnBA,EAAO,IAAI,QAAS,OAAOD,EAAM,KAAK,CAAC,EACvCC,EAAO,IAAI,SAAU,OAAOD,EAAM,MAAM,CAAC,EACrCA,EAAM,QACRC,EAAO,IAAI,SAAUD,EAAM,MAAM,EAEnC,IAAME,EAASF,EAAM,QAAQ,KAAK,EAClC,OAAIE,GACFD,EAAO,IAAI,SAAUC,CAAM,EAItB,GADML,EAAcG,EAAM,IAAI,CACvB,qBAAqB,mBACjCA,EAAM,SACR,CAAC,iCAAiCC,EAAO,SAAS,CAAC,EACrD,CAEA,SAASE,EAAkBC,EAA0C,CACnE,OACE,OAAOA,GAAU,UACjBA,GAAS,MACT,MAAM,QAASA,EAA0B,KAAK,GAC9C,OAAQA,EAA0B,YAAe,QAErD,CAMA,eAAsBC,EACpBL,EACAM,EAC0B,CAC1B,IAAMC,EAAW,MAAM,MAAMC,EAAgBT,EAAoBC,CAAK,CAAC,EAAG,CACxE,OAAQ,MACR,YAAa,OACb,QAAS,CAAE,OAAQ,kBAAmB,EACtC,OAAAM,CACF,CAAC,EAED,GAAI,CAACC,EAAS,GACZ,MAAM,IAAIjB,EACR,4BAA4BiB,EAAS,MAAM,IAC3CA,EAAS,MACX,EAGF,IAAME,EAAmB,MAAMF,EAAS,KAAK,EAC7C,GAAI,CAACJ,EAAkBM,CAAO,EAC5B,MAAM,IAAInB,EAAiB,kCAAkC,EAG/D,OAAOmB,CACT,CC1EO,SAASC,EAAeC,EAAkBC,EAA8B,CAC7E,GAAID,EAAM,WAAa,MAAQA,EAAM,YAAcC,EAAO,UACxD,MAAO,CACL,GAAI,GACJ,OAAQ,6CAA6CD,EAAM,SAAS,GACtE,EAGF,IAAIE,EAAyB,KACvBC,EAAaF,EAAO,KAAOG,EAAcH,EAAO,IAAI,EAAI,GACxDI,EAAcD,EAAcJ,EAAM,IAAI,EAC5C,GAAIG,GAAcA,IAAeE,EAAa,CAC5C,GAAIA,IAAgBD,EAAcJ,EAAM,WAAW,EACjD,MAAO,CACL,GAAI,GACJ,OAAQ,wCAAwCA,EAAM,IAAI,GAC5D,EAEFE,EAAUC,CACZ,CAEA,MAAO,CACL,GAAI,GACJ,aAAcH,EAAM,WAAa,KAAOC,EAAO,UAAY,KAC3D,QAAAC,CACF,CACF,CC7BO,SAASI,EACdC,EACAC,EACA,CACA,IAAMC,EACJD,EAAQ,YAAc,MAAQA,EAAQ,aAAeA,EAAQ,GACzDA,EAAQ,WACR,KACND,EAAW,MACT,cACA,CAAE,IAAK,EAAG,YAAaC,EAAQ,MAAO,SAAUA,EAAQ,QAAS,EACjE,CAAE,WAAYA,EAAQ,GAAI,WAAYC,CAAQ,CAChD,CACF,CAeA,eAAsBC,EACpBF,EACAG,EACe,CACf,GAAM,CAAC,CAAE,QAAAC,CAAQ,EAAG,CAAE,aAAAC,EAAc,aAAAC,CAAa,CAAC,EAAI,MAAM,QAAQ,IAAI,CACtE,OAAO,wBAAqB,EAC5B,OAAO,6BAA0B,CACnC,CAAC,EAEKC,EAAOC,EACX,CAAE,UAAWH,EAAa,EAAG,KAAMI,EAAM,YAAaC,CAAa,EACnEP,CACF,EACA,GAAI,CAACI,EAAK,GACR,OAAOI,EAAaJ,EAAK,MAAM,EAwBjC,GAtBIA,EAAK,cAAgB,MACvBD,EAAaC,EAAK,YAAY,EAE5BA,EAAK,SAAW,MAClBK,EAAcL,EAAK,OAAO,EAId,MAAMH,EAAQ,iBAC1BJ,EAAQ,YAAcA,EAAQ,GAC9B,EACA,OACA,CACE,IAAKG,EAAO,IACZ,KAAMH,EAAQ,KACd,MAAOA,EAAQ,MACf,SAAUA,EAAQ,SAClB,OAAQA,EAAQ,OAEhB,UAAWa,CACb,CACF,GACa,KACX,MAAM,IAAI,MAAM,uCAAuC,EAErDV,EAAO,WAAa,MACtBL,EAAkBK,EAAO,UAAWH,CAAO,EAGzCG,EAAO,UACTC,EAAQ,SAAS,CAErB,CAEA,SAASO,EAAaG,EAAuB,CAC3C,cAAQ,KACN,8DAA8DA,CAAM,yCAEtE,EACM,IAAI,MAAM,kDAAkD,CACpE","names":["DEFAULT_PAGE_SIZE","MAX_PAGE_SIZE","ProductListError","message","status","clampPageSize","pageSize","pageCountFor","totalCount","normalizeHost","host","buildProductListURL","query","params","search","isProductListData","value","fetchProductList","signal","response","withClientParam","payload","planCartTarget","state","target","setHost","targetHost","normalizeHost","currentHost","trackProductAdded","instrument","product","variant","addProductToCart","target","Bitsnap","getProjectID","setProjectID","plan","planCartTarget","HOST","DEFAULT_HOST","failConflict","setCustomHost","noopInstrument","reason"]}
@@ -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/user/bitsnap-react-payment-release/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-free-pwyw/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,5 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkHP3I6D2Rjs = require('./chunk-HP3I6D2R.js');var _chunkKDL35KEIjs = require('./chunk-KDL35KEI.js');var _chunkYPA6MMGJjs = require('./chunk-YPA6MMGJ.js');var _chunkZ3YOJ6NZjs = require('./chunk-Z3YOJ6NZ.js');var _chunkMDAFPGPAjs = require('./chunk-MDAFPGPA.js');var _chunkEFN4OW2Cjs = require('./chunk-EFN4OW2C.js');var _chunk4Y233NIIjs = require('./chunk-4Y233NII.js');var _chunkIRZJIPUFjs = require('./chunk-IRZJIPUF.js');var _chunkQ337IQNAjs = require('./chunk-Q337IQNA.js');var _react = require('@formkit/auto-animate/react');var _react3 = require('react');var _jsxruntime = require('react/jsx-runtime');function Re({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card",className:_chunk4Y233NIIjs.g.call(void 0, "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 _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-header",className:_chunk4Y233NIIjs.g.call(void 0, "@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 _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-title",className:_chunk4Y233NIIjs.g.call(void 0, "leading-none font-semibold",e),...t})}function _n({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-description",className:_chunk4Y233NIIjs.g.call(void 0, "text-muted-foreground text-sm",e),...t})}function De({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-content",className:_chunk4Y233NIIjs.g.call(void 0, "px-6",e),...t})}var _lucidereact = require('lucide-react');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=_react3.useId.call(void 0, ),f=_nullishCoalesce(r, () => (`${l}-email`)),P=_nullishCoalesce(a, () => (`${l}-code`)),x=`${l}-notice`,I=`${l}-hint`,{notice:g}=e,u=_optionalChain([g, 'optionalAccess', _2 => _2.kind])==="error",m=e.busy==="send",p=e.busy==="verify",b=e.busy==="resend",S=_chunk4Y233NIIjs.g.call(void 0, "h-11 w-full",d),U=_optionalChain([g, 'optionalAccess', _3 => _3.kind])==="success",N=_jsxruntime.jsxs.call(void 0, "div",{id:x,className:"min-h-10 text-sm leading-5",children:[_jsxruntime.jsx.call(void 0, "p",{role:"alert",className:"font-medium text-red-700 dark:text-red-400",children:u?g.text:null}),_jsxruntime.jsxs.call(void 0, "p",{role:"status",className:_chunk4Y233NIIjs.g.call(void 0, "flex items-start gap-1.5",U?"font-medium text-emerald-700 dark:text-emerald-400":"text-foreground"),children:[U&&_jsxruntime.jsx.call(void 0, _lucidereact.CircleCheck,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0"}),_jsxruntime.jsx.call(void 0, "span",{children:g!=null&&!u?g.text:null})]})]}),ce=u&&e.step==="email"&&(g.failure==null||ga.has(g.failure)),Se=_jsxruntime.jsx.call(void 0, "p",{className:"sr-only",role:"status","aria-live":"polite",children:e.announcement}),oe=_jsxruntime.jsxs.call(void 0, "div",{className:"grid gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.d,{htmlFor:f,children:t.emailLabel}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.l,{id:f,ref:e.emailRef,name:"email",type:"email",autoComplete:"email",inputMode:"email",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,autoFocus:!0,required:!0,className:_chunk4Y233NIIjs.g.call(void 0, "h-11 text-base disabled:opacity-100 disabled:text-foreground/70",fa),placeholder:_nullishCoalesce(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 _jsxruntime.jsxs.call(void 0, "form",{noValidate:!0,className:_chunk4Y233NIIjs.g.call(void 0, "flex flex-col gap-4",i),onSubmit:Z=>{Z.preventDefault(),e.sendCode()},children:[Se,oe,N,_jsxruntime.jsxs.call(void 0, _chunkYPA6MMGJjs.k,{type:"submit",disabled:e.isBusy,"aria-busy":m,className:S,children:[m&&_jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.e,{"aria-hidden":!0}),m?t.sending:t.sendCode]}),n&&_jsxruntime.jsxs.call(void 0, "p",{className:"flex flex-wrap items-center justify-center text-center text-sm",children:[t.haveCodePrompt!==""&&_jsxruntime.jsx.call(void 0, "span",{children:t.haveCodePrompt}),_jsxruntime.jsx.call(void 0, "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?_chunkHP3I6D2Rjs.i.call(void 0, t.resendIn,{seconds:e.secondsLeft}):t.resend;return _jsxruntime.jsxs.call(void 0, "form",{noValidate:!0,className:_chunk4Y233NIIjs.g.call(void 0, "flex flex-col gap-4",i),onSubmit:Z=>{Z.preventDefault(),e.submitCode()},children:[Se,e.needsEmail?oe:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-center justify-between gap-x-2",children:[_jsxruntime.jsxs.call(void 0, "p",{className:"min-w-0 flex-[1_1_14rem] text-sm leading-5 break-words",children:[te,_jsxruntime.jsx.call(void 0, "strong",{className:"font-semibold",children:e.email}),"\u2060",fe]}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunk4Y233NIIjs.g.call(void 0, ur,"-ml-1 shrink-0"),disabled:e.isBusy,onClick:e.changeEmail,children:t.changeEmail})]}),c,_jsxruntime.jsxs.call(void 0, "div",{className:"grid gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.d,{htmlFor:P,children:t.codeLabel}),_jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.k,{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}`}),_jsxruntime.jsxs.call(void 0, "p",{id:I,className:ma,children:[t.validity," ",t.spamHint]})]}),N,_jsxruntime.jsxs.call(void 0, _chunkYPA6MMGJjs.k,{type:"submit",disabled:e.isBusy||E,"aria-busy":p,className:S,children:[p&&_jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.e,{"aria-hidden":!0}),p?t.verifying:t.verify]}),e.needsEmail?_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center",children:_jsxruntime.jsx.call(void 0, "button",{type:"button",className:ur,disabled:e.isBusy,onClick:e.changeEmail,children:t.noCode})}):_jsxruntime.jsxs.call(void 0, _chunkYPA6MMGJjs.k,{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&&_jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.e,{"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=_chunkQ337IQNAjs.f.call(void 0, ),t){return{..._chunkHP3I6D2Rjs.h.call(void 0, e,t),..._chunkQ337IQNAjs.a.call(void 0, ya,e),...ha(t,["title","description","codeTitle","codeDescription"])}}function ha(e,t){let n={};for(let o of t){let r=_optionalChain([e, 'optionalAccess', _4 => _4[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,_chunkMDAFPGPAjs.h.call(void 0, ))?null:t.toString()}catch (e2){return null}}function Qe(e,t){let n=new URL(e);return n.searchParams.set(Pa,t),n.toString()}if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];_chunkMDAFPGPAjs.h.call(void 0, ).length===0&&_chunkMDAFPGPAjs.g.call(void 0, Array.from(new Set(t)))}var wa=({texts:e,projectID:t,host:n,locale:o,logo:r})=>{let[a,i]=_react3.useState.call(void 0, !1),d=_react3.useRef.call(void 0, void 0),c=_react3.useRef.call(void 0, ""),l=_react3.useMemo.call(void 0, ()=>()=>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=_nullishCoalesce(U, () => ("")),b(U!==null)}}),[]),f=_chunkIRZJIPUFjs.m.call(void 0, ),{mutateAsync:P}=_chunkYPA6MMGJjs.g.call(void 0, _chunkYPA6MMGJjs.e.publicApi.userPanelLogin),{mutateAsync:x}=_chunkYPA6MMGJjs.g.call(void 0, _chunkYPA6MMGJjs.e.publicApi.userPanelLoginWithCode),I=_react3.useMemo.call(void 0, ()=>({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:_chunkHP3I6D2Rjs.a.call(void 0, 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:_chunkHP3I6D2Rjs.a.call(void 0, N),cause:N}}}}),[P,x]),g=_chunkHP3I6D2Rjs.j.call(void 0, {adapter:I,texts:e,beforeSend:l,storageKey:_chunkHP3I6D2Rjs.f.call(void 0, "panel",t,n),onVerified:({accessToken:b},S)=>{f.track("panel_login",{}),_chunkMDAFPGPAjs.j.call(void 0, 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 _jsxruntime.jsx.call(void 0, "main",{className:"mx-auto flex w-full max-w-sm flex-1 flex-col justify-start pt-4 sm:pt-[12vh]",children:_jsxruntime.jsxs.call(void 0, Re,{children:[_jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.c,{projectId:t,locale:o,className:"px-4 sm:px-6",...r}),_jsxruntime.jsxs.call(void 0, je,{className:"px-4 sm:px-6",children:[_jsxruntime.jsx.call(void 0, Fe,{role:"heading","aria-level":1,className:"text-2xl",children:m}),_jsxruntime.jsx.call(void 0, _n,{children:p})]}),_jsxruntime.jsxs.call(void 0, De,{className:"px-4 sm:px-6",children:[_jsxruntime.jsx.call(void 0, zn,{login:g,texts:e,emailInputId:"email",codeInputId:"verify-code"}),a&&_jsxruntime.jsx.call(void 0, _chunkZ3YOJ6NZjs.a,{action:"panel_login",locale:o,onToken:b=>_optionalChain([d, 'access', _5 => _5.current, 'optionalCall', _6 => _6(b)]),onFailure:()=>_optionalChain([d, 'access', _7 => _7.current, 'optionalCall', _8 => _8(null)])})]})]})})},Ca=({analytics:e,texts:t,locale:n,showLogo:o,logoUrl:r,logoDarkUrl:a})=>{let{theme:i,allowedReturnOrigins:d,projectID:c,host:l}=_chunkKDL35KEIjs.b.call(void 0, ),f=_chunkIRZJIPUFjs.n.call(void 0, c,e,"panel"),P=_react3.useMemo.call(void 0, ()=>jn(_nullishCoalesce(n, () => (_chunkQ337IQNAjs.f.call(void 0, ))),t),[n,t]),x={"--button-background-color":_nullishCoalesce(_optionalChain([i, 'optionalAccess', _9 => _9.colors, 'optionalAccess', _10 => _10.brand]), () => ("#FFFFFF")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([i, 'optionalAccess', _11 => _11.colors, 'optionalAccess', _12 => _12.brandDark]), () => ("#000000")),"--button-text-color":_nullishCoalesce(_optionalChain([i, 'optionalAccess', _13 => _13.colors, 'optionalAccess', _14 => _14.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([i, 'optionalAccess', _15 => _15.colors, 'optionalAccess', _16 => _16.brand]), () => ("#FFFFFF"))},[I]=_react.useAutoAnimate.call(void 0, {duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1});return _react3.useEffect.call(void 0, ()=>{typeof window>"u"||_chunkMDAFPGPAjs.i.call(void 0, c,l)!=null&&(window.location.href=window.location.href.replaceAll("login",""))},[c,l]),_react3.useEffect.call(void 0, ()=>{if(typeof window>"u"||window.parent!==window)return;let g=gt(window.location.search);g&&yt(g);let u=_nullishCoalesce(g, () => (Ze()));if(!u)return;let m=_chunkMDAFPGPAjs.i.call(void 0, c,l);m&&(window.location.href=Qe(u,m))},[d,c,l]),_jsxruntime.jsx.call(void 0, _chunkIRZJIPUFjs.l,{value:f,children:_jsxruntime.jsx.call(void 0, "div",{className:"bg-white text-black dark:bg-black dark:text-white",children:_jsxruntime.jsx.call(void 0, "div",{className:"font-inter flex min-h-screen w-full flex-col p-4",style:x,ref:I,children:_jsxruntime.jsx.call(void 0, wa,{texts:P,projectID:c,host:l,locale:n,logo:{showLogo:o,logoUrl:_nullishCoalesce(r, () => (_optionalChain([i, 'optionalAccess', _17 => _17.logoURL]))),logoDarkUrl:_nullishCoalesce(a, () => (_optionalChain([i, 'optionalAccess', _18 => _18.logoDarkURL])))}})})})})},Na= exports.k =(e={})=>_jsxruntime.jsx.call(void 0, Ca,{...e});function $n(e){let[t,n]=_react3.useState.call(void 0, ()=>{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 (e3){a[i]=d}}),{...e,...a}}),o=_react3.useCallback.call(void 0, 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 _react3.useEffect.call(void 0, ()=>{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 (e4){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=_optionalChain([t, 'optionalAccess', _19 => _19.trim, 'call', _20 => _20()]);if(!(n==null||n===""))return{tokens:_chunkYPA6MMGJjs.n.call(void 0, 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=_chunkQ337IQNAjs.f.call(void 0, )){return _chunkQ337IQNAjs.a.call(void 0, La,e)}function yr({}){let e=pe();return _jsxruntime.jsxs.call(void 0, "section",{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:e.notificationsHeading}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:e.notificationsUnavailable})]})}var Ra=e=>new Date(e*1e3).toLocaleDateString(_chunkQ337IQNAjs.f.call(void 0, ),{year:"numeric",month:"short",day:"numeric"}),Da=(e,t)=>new Intl.NumberFormat(_chunkQ337IQNAjs.f.call(void 0, ),{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]=_react3.useState.call(void 0, 0),d=20,{data:c,isFetching:l,isError:f,refetch:P}=_chunkYPA6MMGJjs.f.call(void 0, _chunkYPA6MMGJjs.e.publicApi.getOrders,{projectId:t,accessToken:n,offset:a,limit:d}),x=_nullishCoalesce(_optionalChain([c, 'optionalAccess', _21 => _21.orders]), () => ([])),I=_nullishCoalesce(_optionalChain([c, 'optionalAccess', _22 => _22.totalCount]), () => (0)),g=Math.floor(a/d)+1,u=Math.ceil(I/d),m=p=>{i(p)};return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:o.ordersHeading}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:o.ordersDescription}),l?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((p,b)=>_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between gap-3",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.o,{className:"h-4 w-24"}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.o,{className:"h-3 w-32"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2 text-right",children:[_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.o,{className:"ml-auto h-4 w-16"}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.o,{className:"ml-auto h-3 w-12"})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-3",children:_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.o,{className:"h-3 w-40"})})]},b))}):f?_jsxruntime.jsxs.call(void 0, "div",{role:"alert",className:"mt-6 space-y-3",children:[_jsxruntime.jsx.call(void 0, "p",{children:o.ordersError}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{onClick:()=>void P(),className:"min-h-11 focus-visible:outline-2 focus-visible:outline-current",children:o.retry})]}):x.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:o.ordersEmpty}):_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex w-full flex-col gap-3",children:x.map(p=>_jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between gap-3",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"min-w-0 break-words",children:[_jsxruntime.jsxs.call(void 0, "p",{className:"font-medium",children:[o.orderLabel," #",p.id]}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:p.customerName||o.customerLabel})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"shrink-0 text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-semibold",children:Da(p.totalAmount,p.currency)}),_jsxruntime.jsx.call(void 0, "p",{className:`text-xs font-medium ${_nullishCoalesce(Ma[p.status], () => ("text-neutral-400"))}`,children:_nullishCoalesce(r[p.status], () => (p.status))})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 flex items-center justify-between gap-3 text-xs text-neutral-500 dark:text-neutral-400",children:_jsxruntime.jsxs.call(void 0, "span",{children:[o.dateLabel,":"," ",p.createdAt?Ra(Number(p.createdAt.seconds)):"-"]})})]},p.id))}),g>=u&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-6 text-center text-sm text-neutral-600 dark:text-neutral-400",children:o.ordersEnd}),u>1&&_jsxruntime.jsxs.call(void 0, "nav",{"aria-label":o.paginationLabel,className:"mt-4 flex flex-wrap items-center justify-center gap-2",children:[g>1&&_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{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=>_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{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&&_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{variant:"outline",className:"min-h-11",onClick:()=>m(a+d),children:o.nextPage})]})]})]})}var Gn=Oa;function hr({projectID:e}){let t=pe();return _jsxruntime.jsxs.call(void 0, "section",{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:t.plansHeading}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:t.plansUnavailable})]})}function ja(e,t,n,o){typeof window>"u"||(t&&_chunkMDAFPGPAjs.l.call(void 0, 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}=_chunkHP3I6D2Rjs.t.call(void 0, "PanelReturns"),l=_chunkHP3I6D2Rjs.r.call(void 0, ),f=d==="anonymous"&&(c==null||_chunkHP3I6D2Rjs.p.call(void 0, c));_react3.useEffect.call(void 0, ()=>{f&&ja(n,c!=null,e,t)},[f,n,c,e,t]);let[P,x]=_react3.useState.call(void 0, "orders"),[I,g]=_react3.useState.call(void 0, {items:[],note:""}),[u,m]=_react3.useState.call(void 0, );if(d==="anonymous"&&!f)return _jsxruntime.jsxs.call(void 0, "div",{role:"alert",className:"flex flex-col items-start gap-3",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:l(_chunkHP3I6D2Rjs.q.call(void 0, c))}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{type:"button",onClick:()=>window.location.reload(),children:l("errorRetry")})]});if(d!=="authenticated")return _jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.C,{});let p=b=>{x(b),a({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(o==="return-details"&&r.returnId)return _jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.K,{returnId:r.returnId,onBack:()=>p("myReturns")});if(P==="myReturns")return _jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.J,{onBack:()=>p("orders"),onSelectReturn:b=>{a({state:"return-details",returnId:b,orderId:void 0}),i("return-details")}});if(P==="result"&&u!=null)return _jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.I,{returnId:u,onContinue:()=>p("orders"),onOpenMyReturns:()=>p("myReturns")});if(r.orderId){let b=r.orderId;return P==="confirmation"?_jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.H,{orderId:b,items:I.items,note:I.note,onBack:()=>x("orders"),onSubmitted:S=>{m(S),g({items:[],note:""}),x("result"),a({orderId:void 0})}}):_jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.G,{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 _jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.F,{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 _jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.u,{projectID:o.projectID,host:o.host,appearance:t,texts:n,panelAccessToken:e,children:_jsxruntime.jsx.call(void 0, Fa,{...o})})}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 _chunkQ337IQNAjs.f.call(void 0, ).toLowerCase().startsWith("en")?$a:qa}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 _jsxruntime.jsx.call(void 0, "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)))}})};var _protobuf = require('@bufbuild/protobuf');var _hlsjs = require('hls.js'); var _hlsjs2 = _interopRequireDefault(_hlsjs);function Wa(){return _jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var ke=Wa;var Za=[401,403],Yn="networkError",Jn="mediaError";function Qa(e,t){if(e==null||e.fatal!==!0)return{action:"ignore"};let n=_optionalChain([e, 'access', _23 => _23.response, 'optionalAccess', _24 => _24.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=_nullishCoalesce(e.HlsCtor, () => (_hlsjs2.default)),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":_optionalChain([e, 'access', _25 => _25.handlers, 'optionalAccess', _26 => _26.onExpiredUrl, 'optionalCall', _27 => _27()]),_optionalChain([e, 'access', _28 => _28.handlers, 'optionalAccess', _29 => _29.onError, 'optionalCall', _30 => _30(c.error)]);break;case"restart-load":r=!0,n.startLoad();break;case"recover-media":a=!0,n.recoverMediaError();break;case"fail":_optionalChain([e, 'access', _31 => _31.handlers, 'optionalAccess', _32 => _32.onError, 'optionalCall', _33 => _33(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 (e5){return!1}}function Xn(e){switch(_optionalChain([e, 'optionalAccess', _34 => _34.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:_nullishCoalesce(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(_nullishCoalesce(t, () => (0)),0),e),r=Number.isFinite(n)&&n>0?n:1;try{navigator.mediaSession.setPositionState({playbackRate:r,duration:e,position:o})}catch (e6){}}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 (e7){}}}function ao(){if(et()){navigator.mediaSession.metadata=null;for(let e of no)try{navigator.mediaSession.setActionHandler(e,null)}catch (e8){}}}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]=_react3.useState.call(void 0, "pl");return _react3.useEffect.call(void 0, ()=>{try{n(_chunkQ337IQNAjs.f.call(void 0, ))}catch (e9){}},[]),(_nullishCoalesce(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 (e10){return null}},set(e,t){try{localStorage.setItem(e,t)}catch (e11){}},remove(e){try{localStorage.removeItem(e)}catch (e12){}}},wr="__player__speed",Dt=[.75,1,1.25,1.5,1.75,2];var fi=_react3.forwardRef.call(void 0, ({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]=_react3.useState.call(void 0, 1),b=_react3.useRef.call(void 0, 1),[S,U]=_react3.useState.call(void 0, ),[N,ce]=_react3.useState.call(void 0, "off"),[Se,oe]=_react3.useState.call(void 0, 0),te=_react3.useRef.call(void 0, {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())}_react3.useEffect.call(void 0, ()=>{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]=_react3.useState.call(void 0, 1),[Bt,Ee]=_react3.useState.call(void 0, void 0),[w,ye]=_react3.useState.call(void 0, void 0),[Be,ue]=_react3.useState.call(void 0, !1),[vt,Vr]=_react3.useState.call(void 0, null),z=_react3.useRef.call(void 0, null),he=_react3.useRef.call(void 0, null),kt=_react3.useRef.call(void 0, void 0),na=_react3.useRef.call(void 0, null),re=_react3.useRef.call(void 0, null),Kt=_react3.useRef.call(void 0, null),ze=_react3.useRef.call(void 0, !1),Ke=_react3.useRef.call(void 0, !1),dt=_react3.useRef.call(void 0, null),Gt=_react3.useRef.call(void 0, null),Vt=_react3.useRef.call(void 0, e),Wr=_react3.useRef.call(void 0, null),ne=_react3.useRef.call(void 0, {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}_${_optionalChain([re, 'access', _35 => _35.current, 'optionalAccess', _36 => _36.id])}`,`${Math.floor(s)}`)}function oa(){let s=Y.get(`__player__${l}_${_optionalChain([re, 'access', _37 => _37.current, 'optionalAccess', _38 => _38.id])}`);if(s!=null)try{let h=parseInt(s);return isNaN(h)||h<0?void 0:h}catch (e13){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:_nullishCoalesce(_nullishCoalesce(_optionalChain([s, 'optionalAccess', _39 => _39.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),_optionalChain([ne, 'access', _40 => _40.current, 'access', _41 => _41.onError, 'optionalCall', _42 => _42(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(){_optionalChain([z, 'access', _43 => _43.current, 'optionalAccess', _44 => _44.pause, 'call', _45 => _45()]),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(_hlsjs2.default.isSupported()){he.current==null&&(he.current=Zn({media:h,handlers:{onError:k=>{Zr(k)},onExpiredUrl:()=>{_optionalChain([ne, 'access', _46 => _46.current, 'access', _47 => _47.onExpiredUrl, 'optionalCall', _48 => _48()])}}})),he.current.load(s);return}Zt(),h.src=s,h.load()}}function Zt(){_optionalChain([he, 'access', _49 => _49.current, 'optionalAccess', _50 => _50.destroy, 'call', _51 => _51()]),he.current=null}function Ct(s,h){let k=_optionalChain([h, 'optionalAccess', _52 => _52.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),_optionalChain([ne, 'access', _53 => _53.current, 'access', _54 => _54.onChapterChange, 'optionalCall', _55 => _55(s)]),Yr(s.id)}function Qt(s){if(s.length===0)return;let h=aa(),k=_nullishCoalesce((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,_optionalChain([z, 'access', _56 => _56.current, 'optionalAccess', _57 => _57.pause, 'call', _58 => _58()]),lt(1),_optionalChain([ne, 'access', _59 => _59.current, 'access', _60 => _60.onFinished, 'optionalCall', _61 => _61()])}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=_optionalChain([z, 'access', _62 => _62.current, 'optionalAccess', _63 => _63.error]),h=_optionalChain([re, 'access', _64 => _64.current, 'optionalAccess', _65 => _65.publicUrl]);(_optionalChain([s, 'optionalAccess', _66 => _66.code])===2||_optionalChain([s, 'optionalAccess', _67 => _67.code])===4)&&he.current==null&&h!=null&&Gt.current!==h&&(Gt.current=h,_optionalChain([ne, 'access', _68 => _68.current, 'access', _69 => _69.onExpiredUrl, 'optionalCall', _70 => _70()])),Zr(Xn(s))}function an(){let h=_nullishCoalesce(_optionalChain([re, 'access', _71 => _71.current, 'optionalAccess', _72 => _72.publicUrl]), () => (_optionalChain([he, 'access', _73 => _73.current, 'optionalAccess', _74 => _74.src])));if(h==null)return;let D=_nullishCoalesce(_optionalChain([z, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.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(-(_nullishCoalesce(s.seekOffset, () => (10))));break;case"seekforward":wt(_nullishCoalesce(s.seekOffset, () => (10)));break;case"seekto":s.seekTime!=null&&Le(s.seekTime);break;case"previoustrack":tn();break;case"nexttrack":Xt();break;default:break}}_react3.useImperativeHandle.call(void 0, 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),_optionalChain([ne, 'access', _77 => _77.current, 'access', _78 => _78.updateCurrentTime, 'optionalCall', _79 => _79(s.currentTime)]))}_react3.useEffect.call(void 0, ()=>(oo({title:_nullishCoalesce(a, () => ("")),album:a,artist:c,artwork:i,action:la}),()=>{ao()}),[]),_react3.useEffect.call(void 0, ()=>{Yt(re.current)},[a,c,i]),_react3.useEffect.call(void 0, ()=>{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()}},[]),_react3.useEffect.call(void 0, ()=>{_optionalChain([r, 'optionalCall', _80 => _80(Le)])},[]);let er=e.map(s=>`${s.id}|${_nullishCoalesce(s.publicUrl, () => (""))}`).join(`
4
+ `);_react3.useEffect.call(void 0, ()=>{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=_nullishCoalesce(_optionalChain([D, 'optionalAccess', _81 => _81.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),_optionalChain([ne, 'access', _82 => _82.current, 'access', _83 => _83.onChapterChange, 'optionalCall', _84 => _84(k)]),Yr(k.id);return}Qt(e)}},[er]),_react3.useEffect.call(void 0, ()=>{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:_nullishCoalesce(_optionalChain([e, 'access', _85 => _85[Ge], 'optionalAccess', _86 => _86.duration]), () => (0)),ct=Math.min(Math.max(_nullishCoalesce(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 _jsxruntime.jsxs.call(void 0, "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":_optionalChain([vt, 'optionalAccess', _87 => _87.kind]),children:[_jsxruntime.jsx.call(void 0, "video",{ref:z,className:"hidden",poster:i,title:a}),_jsxruntime.jsxs.call(void 0, "div",{className:_chunk4Y233NIIjs.g.call(void 0, "flex min-w-0 items-center gap-3",d&&"lg:hidden"),children:[i&&_jsxruntime.jsx.call(void 0, "img",{src:i,alt:"",className:"h-16 w-16 shrink-0 rounded object-contain"}),_jsxruntime.jsxs.call(void 0, "div",{className:"min-w-0 break-words",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-semibold",children:_nullishCoalesce(_optionalChain([e, 'access', _88 => _88[Ge], 'optionalAccess', _89 => _89.name]), () => (a))}),c&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:c})]})]}),vt&&_jsxruntime.jsxs.call(void 0, "div",{role:"alert",className:"rounded-lg bg-red-50 p-3 text-red-800 dark:bg-red-950 dark:text-red-200",children:[_jsxruntime.jsx.call(void 0, "p",{children:u.error}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{variant:"outline",onClick:an,children:u.retry})]}),_jsxruntime.jsx.call(void 0, "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))}),_jsxruntime.jsxs.call(void 0, "section",{className:"flex w-full justify-between text-sm tabular-nums",children:[_jsxruntime.jsx.call(void 0, "span",{id:"current-time",children:xe(ct)}),_jsxruntime.jsx.call(void 0, "span",{id:"duration",children:xe(be)})]}),be>0&&_jsxruntime.jsxs.call(void 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)"]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-center justify-center gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{variant:"outline",onClick:tn,disabled:Ge<0,"aria-label":u.previous,children:_jsxruntime.jsx.call(void 0, _lucidereact.SkipBack,{className:"h-5 w-5"})}),_jsxruntime.jsxs.call(void 0, _chunkYPA6MMGJjs.k,{variant:"outline",onClick:()=>wt(-10),"aria-label":u.rewind,children:["\u2212",10]}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{variant:"outline",onClick:ia,"aria-label":_e===1?u.play:u.pause,children:_e===1?_jsxruntime.jsx.call(void 0, _lucidereact.Play,{className:"h-5 w-5"}):_jsxruntime.jsx.call(void 0, _lucidereact.Pause,{className:"h-5 w-5"})}),_jsxruntime.jsxs.call(void 0, _chunkYPA6MMGJjs.k,{variant:"outline",onClick:()=>wt(10),"aria-label":u.forward,children:["+",10]}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{variant:"outline",onClick:Xt,disabled:Ge<0||Ge>=e.length-1,"aria-label":u.next,children:_jsxruntime.jsx.call(void 0, _lucidereact.SkipForward,{className:"h-5 w-5"})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap gap-3 md:grid md:grid-cols-2",children:[_jsxruntime.jsxs.call(void 0, "label",{className:"flex flex-1 items-center gap-2 text-sm md:flex-col md:items-start md:whitespace-nowrap",children:[u.speed,_jsxruntime.jsx.call(void 0, "select",{"aria-label":u.speed,value:m,onChange:s=>ge(Number(s.target.value)),children:Dt.map(s=>_jsxruntime.jsxs.call(void 0, "option",{value:s,children:[s,"\xD7"]},s))})]}),_jsxruntime.jsxs.call(void 0, "label",{className:"flex flex-1 items-center gap-2 text-sm md:flex-col md:items-start md:whitespace-nowrap",children:[u.sleep,_jsxruntime.jsxs.call(void 0, "select",{"aria-label":u.sleep,value:N,onChange:s=>E(s.target.value),children:[_jsxruntime.jsx.call(void 0, "option",{value:"off",children:u.off}),[15,30,45,60].map(s=>_jsxruntime.jsxs.call(void 0, "option",{value:s,children:[s," min"]},s)),_jsxruntime.jsx.call(void 0, "option",{value:"chapter",children:u.end})]})]})]}),N!=="off"&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between gap-2 text-sm",children:[_jsxruntime.jsx.call(void 0, "span",{role:"timer",children:N==="chapter"?u.end:xe(Se)}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{variant:"outline",onClick:fe,children:u.cancel})]}),Be&&_jsxruntime.jsx.call(void 0, "div",{role:"status",className:"flex justify-center",children:_jsxruntime.jsx.call(void 0, ke,{})})]})}),io=fi;function Cr({chapters:e,currentID:t,productID:n,onSelect:o,downloadable:r,onDownload:a,loading:i,locale:d}){let c=Rt(d),[l,f]=_react3.useState.call(void 0, null),[P,x]=_react3.useState.call(void 0, []);_react3.useEffect.call(void 0, ()=>{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((_nullishCoalesce(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=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _90 => _90.findIndex, 'call', _91 => _91(u=>u.id===_optionalChain([l, 'optionalAccess', _92 => _92.id]))]), () => (-1)),g=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _93 => _93.findIndex, 'call', _94 => _94(u=>u.id===t)]), () => (-1));return _jsxruntime.jsxs.call(void 0, "div",{className:"max-h-96 w-full overflow-y-auto",children:[_jsxruntime.jsx.call(void 0, "h2",{className:"mb-3 text-xl font-semibold",children:c.chapters}),i?_jsxruntime.jsx.call(void 0, "p",{role:"status",children:c.loading}):_optionalChain([e, 'optionalAccess', _95 => _95.length])?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[l&&I>=0&&_jsxruntime.jsxs.call(void 0, "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)]}),_jsxruntime.jsx.call(void 0, "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 _jsxruntime.jsxs.call(void 0, "li",{className:"flex min-w-0 items-center gap-2",children:[_jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsxs.call(void 0, "span",{className:"flex items-center gap-2",children:[p?_jsxruntime.jsx.call(void 0, _lucidereact.Play,{className:"size-4 shrink-0","aria-label":c.playing}):b?_jsxruntime.jsx.call(void 0, _lucidereact.Check,{className:"size-4 shrink-0","aria-label":c.played}):null,_jsxruntime.jsx.call(void 0, "span",{className:"min-w-0 flex-1 break-words text-sm font-medium",children:u.name}),!!u.duration&&_jsxruntime.jsx.call(void 0, "span",{className:"shrink-0 text-xs tabular-nums text-neutral-600 dark:text-neutral-300",children:xe(u.duration)})]}),u.description&&_jsxruntime.jsx.call(void 0, "span",{className:"mt-2 block text-xs",children:u.description})]}),r&&u.downloadableUrl&&_jsxruntime.jsx.call(void 0, "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:_jsxruntime.jsx.call(void 0, _lucidereact.Download,{className:"size-4","aria-hidden":"true"})})]},u.id)})})]}):_jsxruntime.jsx.call(void 0, "p",{children:c.empty})]})}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=_chunkIRZJIPUFjs.m.call(void 0, ),d=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),c=_react3.useRef.call(void 0, null),[l]=_react.useAutoAnimate.call(void 0, ),[f,P]=_react3.useState.call(void 0, !1),[x,I]=_react3.useState.call(void 0, null),{mutateAsync:g,isPending:u}=_chunkYPA6MMGJjs.g.call(void 0, _chunkYPA6MMGJjs.e.publicApi.userPanelGetFileDetails),m=_react3.useRef.call(void 0, void 0),[p,b]=_react3.useState.call(void 0, null),[S,U]=_react3.useState.call(void 0, null),[N,ce]=_react3.useState.call(void 0, !1),{mutateAsync:Se,isPending:oe}=_chunkYPA6MMGJjs.g.call(void 0, _chunkYPA6MMGJjs.e.publicApi.userPanelGetAudiobookDetails),{mutateAsync:te,isPending:fe}=_chunkYPA6MMGJjs.g.call(void 0, _chunkYPA6MMGJjs.e.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[E,ge]=_react3.useState.call(void 0, null),[Z,_e]=_react3.useState.call(void 0, 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 _react3.useEffect.call(void 0, ()=>{a===2&&lt(),a===1&&(Bt().then().catch(),Ee().then().catch())},[]),_react3.useEffect.call(void 0, ()=>{if(p!=null&&S!=null){let w=p.chapters;if(!w)return;let ye=w.map(Be=>{let ue=_optionalChain([S, 'optionalAccess', _96 => _96.find, 'call', _97 => _97(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]),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:_jsxruntime.jsxs.call(void 0, _chunkYPA6MMGJjs.k,{onClick:()=>o(),variant:"ghost",className:"min-h-11 w-fit",children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeft,{className:"h-6 w-6"}),_jsxruntime.jsx.call(void 0, "span",{className:"font-inter text-sm font-medium",children:r.back})]})}),_jsxruntime.jsxs.call(void 0, "main",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[_jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsx.call(void 0, "img",{src:t.productImageUrl,alt:t.productName,width:384,height:384,draggable:!1,className:"aspect-square max-h-72 w-full object-contain"}),_jsxruntime.jsx.call(void 0, "h2",{className:"text-2xl font-semibold",children:t.productName})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex min-w-0 flex-col gap-6",children:[a===2&&_jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-xl font-semibold",children:r.yourFiles}),u&&_jsxruntime.jsx.call(void 0, "div",{role:"status","aria-label":r.loading,children:_jsxruntime.jsx.call(void 0, ke,{})}),f&&_jsxruntime.jsxs.call(void 0, "div",{role:"alert",children:[_jsxruntime.jsx.call(void 0, "p",{children:r.fileError}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{className:"min-h-11",onClick:lt,children:r.retry})]}),_optionalChain([x, 'optionalAccess', _98 => _98.length])===0&&_jsxruntime.jsx.call(void 0, "p",{children:r.noFiles}),x&&_jsxruntime.jsx.call(void 0, "ul",{className:"flex flex-col gap-3",children:x.map((w,ye)=>_jsxruntime.jsxs.call(void 0, "li",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[_jsxruntime.jsx.call(void 0, "span",{className:"min-w-0 break-all text-sm",children:uo(w)||`${r.file} ${ye+1}`}),_jsxruntime.jsxs.call(void 0, "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,_jsxruntime.jsx.call(void 0, _lucidereact.Download,{className:"size-4","aria-hidden":"true"})]})]},w))})]}),a===3&&_jsxruntime.jsxs.call(void 0, "section",{className:"rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-lg font-semibold",children:r.ticket}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 font-medium",children:t.productName}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-300",children:r.ticketInfo})]}),a===1&&_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsx.call(void 0, "h4",{className:"text-xl font-semibold",children:_nullishCoalesce(_optionalChain([E, 'optionalAccess', _99 => _99.name]), () => ("Odtwarzacz"))}),_optionalChain([E, 'optionalAccess', _100 => _100.description])&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:_optionalChain([E, 'optionalAccess', _101 => _101.description])}),_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:oe?_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-2",children:[_jsxruntime.jsx.call(void 0, ke,{}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:Z!=null?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsx.call(void 0, io,{ref:c,coverShownBeside:!0,chapters:Z,author:typeof _optionalChain([p, 'optionalAccess', _102 => _102.author])=="string"?p.author:void 0,onExpiredUrl:()=>{Ee()},title:_nullishCoalesce(_nullishCoalesce(_optionalChain([p, 'optionalAccess', _103 => _103.name]), () => (t.productName)), () => (void 0)),imageURL:_nullishCoalesce(_nullishCoalesce(_optionalChain([p, 'optionalAccess', _104 => _104.coverImage]), () => (t.productImageUrl)), () => (void 0)),styles:n,setCurrentTimeHandler:w=>{m.current=w},uniqueProductID:t.productId,onChapterChange:w=>{ge(w)}})}):_jsxruntime.jsx.call(void 0, "p",{className:"mt-2",children:"Wybierz rozdzia\u0142, kt\xF3ry ci\u0119 interesuje."})})}),_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",children:[_jsxruntime.jsx.call(void 0, "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."}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-3",children:[_jsxruntime.jsx.call(void 0, "a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:_jsxruntime.jsx.call(void 0, "img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),_jsxruntime.jsx.call(void 0, "a",{href:"https://play.google.com/store/apps/details?id=com.bitsnap.Bitsnap",children:_jsxruntime.jsx.call(void 0, "img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),_jsxruntime.jsx.call(void 0, "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&&_jsxruntime.jsx.call(void 0, Cr,{chapters:Z,currentID:_optionalChain([E, 'optionalAccess', _105 => _105.id]),productID:t.productId,loading:oe,downloadable:_optionalChain([p, 'optionalAccess', _106 => _106.isDownloadable])===!0,onDownload:d,onSelect:w=>_optionalChain([c, 'access', _107 => _107.current, 'optionalAccess', _108 => _108.selectChapter, 'call', _109 => _109(w)])})})]}),_jsxruntime.jsx.call(void 0, "section",{className:"rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900",children:_jsxruntime.jsx.call(void 0, "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 (e14){return""}}var _connectquery = require('@connectrpc/connect-query');function mo(e,t){let n=_connectquery.useTransport.call(void 0, ),[o,r]=_react3.useState.call(void 0, {status:"loading"});return _react3.useEffect.call(void 0, ()=>{if(!e){r({status:"hidden"});return}let a=!1;return r({status:"loading"}),Promise.resolve().then(() => _interopRequireWildcard(require("./model-files-client-P4PORZJ6.js"))).then(({listModelFiles:i})=>i(n,e,t)).catch(()=>({status:"hidden"})).then(i=>{a||r(i)}),()=>{a=!0}},[n,e,t]),o}var _i=_react3.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./PanelModelFiles-EKQRLF46.js")))),zi=({accessToken:e,projectID:t,loginURL:n,styles:o,activeScreen:r,params:a,setParams:i,openCourse:d,openMessages:c})=>{let{host:l}=_chunkKDL35KEIjs.b.call(void 0, ),{data:f,isLoading:P,error:x,refetch:I}=_chunkYPA6MMGJjs.f.call(void 0, _chunkYPA6MMGJjs.e.publicApi.userPanelGetProducts,{accessToken:e}),g=mo(e,t),u=ji({products:P?{status:"loading"}:x!=null?{status:"error"}:_optionalChain([f, 'optionalAccess', _110 => _110.result, 'access', _111 => _111.case])==="success"?{status:"ok",count:f.result.value.products.length}:_optionalChain([f, 'optionalAccess', _112 => _112.result, 'access', _113 => _113.case])==="failure"?{status:"failure",unauthorized:f.result.value===9}:{status:"error"},modelFiles:g});if(_react3.useEffect.call(void 0, ()=>{u.kind==="signed-out"&&(_chunkMDAFPGPAjs.l.call(void 0, t,l),window.location.href=n)},[u.kind,t,l,n]),u.kind==="loading"||u.kind==="signed-out")return _jsxruntime.jsx.call(void 0, "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)=>_jsxruntime.jsx.call(void 0, "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?_jsxruntime.jsx.call(void 0, _react3.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, _i,{accessToken:e,models:p,buttonStyle:o})}):null;return u.kind==="error"?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, Hi,{onRetry:()=>void I()}),b]}):u.kind==="empty"?_jsxruntime.jsx.call(void 0, Fi,{}):_jsxruntime.jsx.call(void 0, 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 _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start gap-1","data-testid":"panel-empty",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:e.hello}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:e.empty})]})}function Hi({onRetry:e}){let t=_chunkQ337IQNAjs.f.call(void 0, ).toLowerCase().startsWith("en");return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start gap-3",role:"alert","data-testid":"panel-error",children:[_jsxruntime.jsx.call(void 0, "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."}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{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]=_react3.useState.call(void 0, ()=>go(a.product,t));_react3.useEffect.call(void 0, ()=>{P(go(a.product,t))},[a.product,t]);let x=g=>{P(g),i({product:g?g.accessId||g.productId:void 0,state:"products"})};_react3.useEffect.call(void 0, ()=>{r==="products"&&_optionalChain([f, 'optionalAccess', _114 => _114.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"&&_optionalChain([f, 'optionalAccess', _115 => _115.productType])===4?null:r==="products"&&f!=null?_jsxruntime.jsx.call(void 0, po,{accessToken:e,product:f,styles:n,reveal:x,onOpenCourse:d}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:l.hello}),t.length>0&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:l.intro}),_jsxruntime.jsx.call(void 0, "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,_lucidereact.Headphones]:g.productType===4?[l.course,l.openCourse,_lucidereact.BookOpen]:g.productType===5?[l.chat,l.openMessages,_lucidereact.MessageCircle]:g.productType===6?[l.community,l.openMessages,_lucidereact.Users]:g.productType===3?[l.ticket,l.showTicket,_lucidereact.Ticket]:[l.files,l.downloadFiles,_lucidereact.Files];return _jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsxs.call(void 0, "span",{className:"flex w-full flex-col gap-3 bg-neutral-100 p-3 dark:bg-neutral-800",children:[_jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsx.call(void 0, p,{className:"size-4","aria-hidden":"true"}),u]}),_jsxruntime.jsx.call(void 0, "img",{src:g.productImageUrl,alt:g.productName,draggable:!1,className:"aspect-square w-full object-contain"})]}),_jsxruntime.jsxs.call(void 0, "span",{className:"flex flex-1 flex-col gap-3 p-3",children:[_jsxruntime.jsx.call(void 0, "span",{className:"line-clamp-2 font-semibold",children:g.productName}),_jsxruntime.jsx.call(void 0, "span",{className:"line-clamp-2 text-sm text-neutral-600 dark:text-neutral-300",children:Wn(g.productDescription)}),_jsxruntime.jsx.call(void 0, "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=_protobuf.fromJsonString.call(void 0, _chunkEFN4OW2Cjs.f,e);return t.find(r=>o.accessId?r.accessId===o.accessId:r.productId===o.productId)}catch (e15){return}}var bo=[{screen:"products",label:"libraryNavLabel",icon:_lucidereact.Library},{screen:"messages",label:"messagesNavLabel",icon:_lucidereact.MessageCircle},{screen:"orders",label:"ordersNavLabel",icon:_lucidereact.Receipt},{screen:"returns",label:"returnsNavLabel",icon:_lucidereact.Undo2},{screen:"profile",label:"accountNavLabel",icon:_lucidereact.User}];function Po(e){return e==="course"?"products":e==="order-details"?"orders":e==="return-details"?"returns":e}function Sr({activeScreen:e,setActiveScreen:t,setParams:n,theme:o,logout:r,email:a,projectID:i,showMessages:d=!1}){let c=pe(),{data:l}=_chunkHP3I6D2Rjs.b.call(void 0, _nullishCoalesce(i, () => ("")),!!i);return _jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex min-w-0 items-center gap-3 md:mb-6 md:flex-col md:items-start",children:[_jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.c,{projectId:i,logoUrl:_optionalChain([o, 'optionalAccess', _116 => _116.logoURL]),logoDarkUrl:_optionalChain([o, 'optionalAccess', _117 => _117.logoDarkURL]),name:_optionalChain([l, 'optionalAccess', _118 => _118.name]),className:"shrink-0"}),_optionalChain([l, 'optionalAccess', _119 => _119.name])&&_jsxruntime.jsx.call(void 0, "span",{title:l.name,className:"truncate text-sm font-medium md:line-clamp-2 md:whitespace-normal",children:l.name})]}),_jsxruntime.jsx.call(void 0, "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 _jsxruntime.jsxs.call(void 0, "button",{type:"button","aria-current":I?"page":void 0,onClick:()=>{t(f),n({product:void 0,state:f})},className:_chunk4Y233NIIjs.g.call(void 0, "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:[_jsxruntime.jsx.call(void 0, x,{className:"h-5 w-5 shrink-0","aria-hidden":"true"}),_jsxruntime.jsx.call(void 0, "span",{children:c[P]})]},f)})}),_jsxruntime.jsxs.call(void 0, "div",{className:"hidden border-t border-neutral-200 pt-4 md:block dark:border-neutral-800",children:[a&&_jsxruntime.jsx.call(void 0, "p",{title:a,className:"mb-3 truncate text-sm text-neutral-600 dark:text-neutral-400",children:a}),_jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsx.call(void 0, _lucidereact.LogOut,{className:"h-4 w-4","aria-hidden":"true"}),c.logout]})]})]})}function Er({email:e,logout:t,onLocaleChange:n}){let[o,r]=_react3.useState.call(void 0, _chunkQ337IQNAjs.f),a=pe(o);return _jsxruntime.jsxs.call(void 0, "section",{className:"w-full max-w-xl",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:a.accountNavLabel}),_jsxruntime.jsx.call(void 0, "h4",{className:"mt-6 mb-2 text-sm font-medium text-neutral-600 dark:text-neutral-400",children:a.profileHeading}),_jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsxs.call(void 0, "div",{className:"p-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:a.emailLabel}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-1 break-words",children:e||a.noData})]}),_jsxruntime.jsxs.call(void 0, "label",{className:"flex min-h-11 flex-wrap items-center justify-between gap-3 p-4",children:[_jsxruntime.jsx.call(void 0, "span",{children:a.languageLabel}),_jsxruntime.jsxs.call(void 0, "select",{value:o.toLowerCase().startsWith("en")?"en-US":"pl-PL",onChange:i=>{_chunkQ337IQNAjs.e.call(void 0, i.target.value),r(i.target.value),_optionalChain([n, 'optionalCall', _120 => _120()])},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:[_jsxruntime.jsx.call(void 0, "option",{value:"pl-PL",children:a.polishLanguage}),_jsxruntime.jsx.call(void 0, "option",{value:"en-US",children:a.englishLanguage})]})]})]}),_jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsx.call(void 0, _lucidereact.LogOut,{className:"h-5 w-5","aria-hidden":"true"}),a.logout]})]})}var Xi=_react3.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./course.js"))).then(e=>({default:e.PanelCourse})));function Lr(e){return _jsxruntime.jsx.call(void 0, _react3.Suspense,{fallback:_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center gap-2 p-2",role:"status",children:_jsxruntime.jsx.call(void 0, ke,{})}),children:_jsxruntime.jsx.call(void 0, "div",{className:"[--course-mobile-bottom:calc(56px+env(safe-area-inset-bottom))] md:[--course-mobile-bottom:0px]",children:_jsxruntime.jsx.call(void 0, Xi,{...e})})})}var rs=_react3.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./chat.js"))).then(e=>({default:e.PanelMessages})));function Tr(e){return _jsxruntime.jsx.call(void 0, _react3.Suspense,{fallback:_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center gap-2 p-2",role:"status",children:_jsxruntime.jsx.call(void 0, ke,{})}),children:_jsxruntime.jsx.call(void 0, rs,{...e})})}function ns(e,t){return!!t||e.some(n=>n.productType===5||n.productType===6)}function vo(e){let{data:t}=_chunkYPA6MMGJjs.f.call(void 0, _chunkYPA6MMGJjs.e.publicApi.userPanelGetProducts,{accessToken:_nullishCoalesce(e, () => (""))},{enabled:!!e}),n=_optionalChain([t, 'optionalAccess', _121 => _121.result, 'access', _122 => _122.case])==="success"?t.result.value:void 0,o=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _123 => _123.products]), () => ([])),r=_optionalChain([n, 'optionalAccess', _124 => _124.chatApiUrl])||void 0;return{visible:ns(o,r),products:o,chatApiUrl:r}}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:_lucidereact.CheckCircle2},completed:{color:"bg-blue-100 text-blue-700",icon:_lucidereact.CheckCircle2},canceled:{color:"bg-red-100 text-red-700",icon:_lucidereact.AlertCircle},sent:{color:"bg-purple-100 text-purple-700",icon:_lucidereact.Truck},processing:{color:"bg-yellow-100 text-yellow-700",icon:_lucidereact.Loader2}},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 _jsxruntime.jsxs.call(void 0, "span",{className:`inline-flex items-center gap-1 rounded-full px-3 py-1 text-sm font-medium ${n.color}`,children:[o&&_jsxruntime.jsx.call(void 0, o,{className:"h-4 w-4"}),r[e]||e]})}function ls({orderID:e,email:t}){let[n,o]=_react3.useState.call(void 0, ""),r=_chunkYPA6MMGJjs.g.call(void 0, _chunkYPA6MMGJjs.e.publicApi.addPublicOrderComment);return _jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.d,{htmlFor:"comment",children:"Dodaj komentarz"}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.p,{id:"comment",value:n,onChange:i=>o(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:r.isPending}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{type:"submit",disabled:!n.trim()||r.isPending,children:r.isPending?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _lucidereact.Loader2,{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}=_chunkKDL35KEIjs.b.call(void 0, ),d=_chunkIRZJIPUFjs.n.call(void 0, i,r,"order"),[c,l]=_react3.useState.call(void 0, t||""),[f,P]=_react3.useState.call(void 0, !1),{data:x,isLoading:I,error:g,refetch:u}=_chunkYPA6MMGJjs.f.call(void 0, _chunkYPA6MMGJjs.e.publicApi.getPublicOrderDetails,{projectId:_nullishCoalesce(i, () => ("")),orderId:e,email:c||void 0,accessToken:o},{enabled:!!e}),m=_optionalChain([x, 'optionalAccess', _125 => _125.result, 'access', _126 => _126.case])==="order"?x.result.value:null,p=_nullishCoalesce(_optionalChain([m, 'optionalAccess', _127 => _127.isVerified]), () => (!1)),b=m!=null;_react3.useEffect.call(void 0, ()=>{b&&d.track("panel_order_viewed",{},{order_ref:null})},[d,b]);let S=()=>{u(),P(!1)},U={"--button-background-color":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _128 => _128.colors, 'optionalAccess', _129 => _129.brand]), () => ("#000000")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _130 => _130.colors, 'optionalAccess', _131 => _131.brandDark]), () => ("#ffffff")),"--button-text-color":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _132 => _132.colors, 'optionalAccess', _133 => _133.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _134 => _134.colors, 'optionalAccess', _135 => _135.brand]), () => ("#000000"))};return I?_jsxruntime.jsx.call(void 0, "div",{className:"flex min-h-screen items-center justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"text-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Loader2,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):g||!m?_jsxruntime.jsx.call(void 0, "div",{className:"flex min-h-screen items-center justify-center",children:_jsxruntime.jsx.call(void 0, Re,{className:"w-full max-w-md",children:_jsxruntime.jsx.call(void 0, De,{className:"pt-6",children:_jsxruntime.jsxs.call(void 0, "div",{className:"text-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle,{className:"mx-auto h-12 w-12 text-red-500"}),_jsxruntime.jsx.call(void 0, "h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):_jsxruntime.jsx.call(void 0, "div",{className:"w-full bg-white py-8 dark:bg-black",style:U,children:_jsxruntime.jsxs.call(void 0, "div",{className:"w-full px-4",children:[n&&_jsxruntime.jsxs.call(void 0, _chunkYPA6MMGJjs.k,{onClick:n,variant:"ghost",className:"mb-4 w-fit",children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeft,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mb-6 flex items-center gap-4",children:[_optionalChain([a, 'optionalAccess', _136 => _136.logoURL])&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "img",{src:a.logoURL,alt:"Project logo",className:`h-12 w-auto ${a.logoDarkURL?"dark:hidden":""}`}),a.logoDarkURL&&_jsxruntime.jsx.call(void 0, "img",{src:a.logoDarkURL,alt:"Project logo",className:"hidden h-12 w-auto dark:block"})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),_jsxruntime.jsxs.call(void 0, "p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",m.orderId]})]})]}),_jsxruntime.jsxs.call(void 0, Re,{className:"mb-6",children:[_jsxruntime.jsx.call(void 0, je,{children:_jsxruntime.jsxs.call(void 0, Fe,{className:"flex items-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Package,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),_jsxruntime.jsxs.call(void 0, De,{className:"space-y-6",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, ss,{status:m.status}),m.processingStatus&&_jsxruntime.jsxs.call(void 0, "span",{className:"text-sm text-neutral-600",children:["\xB7 ",m.processingStatus]})]}),_jsxruntime.jsxs.call(void 0, "p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",wo(m.createdAt)]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"border-t pt-4",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:p?"":"text-neutral-500",children:m.customerName})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Email:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:p?"":"text-neutral-500",children:m.customerEmail})]}),m.customerPhone&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Telefon:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:p?"":"text-neutral-500",children:m.customerPhone})]})]})]}),!p&&_jsxruntime.jsx.call(void 0, "div",{className:"border-t pt-4",children:_jsxruntime.jsxs.call(void 0, _chunkYPA6MMGJjs.k,{onClick:()=>P(!0),variant:"outline",className:"w-full",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Lock,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),_jsxruntime.jsxs.call(void 0, Re,{className:"mb-6",children:[_jsxruntime.jsx.call(void 0, je,{children:_jsxruntime.jsx.call(void 0, Fe,{children:"Produkty"})}),_jsxruntime.jsxs.call(void 0, De,{className:"space-y-6",children:[_jsxruntime.jsx.call(void 0, "div",{className:"space-y-4",children:m.items.map((N,ce)=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-4",children:[N.imageUrl&&_jsxruntime.jsx.call(void 0, "img",{src:N.imageUrl,alt:N.name,className:"h-16 w-16 rounded object-cover"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex-1",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-medium",children:N.name}),_jsxruntime.jsxs.call(void 0, "p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",N.quantity]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"text-right",children:_jsxruntime.jsx.call(void 0, "p",{className:"font-medium",children:Co(Number(N.price),N.currency)})})]},ce))}),(m.deliveryAddress||m.deliveryMethod)&&_jsxruntime.jsxs.call(void 0, "div",{className:"border-t pt-4",children:[_jsxruntime.jsxs.call(void 0, "h3",{className:"mb-3 flex items-center font-semibold",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Truck,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[m.deliveryAddress&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Adres:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:p?"":"text-neutral-500",children:m.deliveryAddress})]}),m.deliveryMethod&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Metoda:"})," ",m.deliveryMethod]}),m.trackingNumber&&p&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Tracking:"})," ",m.trackingNumber]})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"border-t pt-4",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-lg font-bold",children:[_jsxruntime.jsx.call(void 0, "span",{children:"Suma:"}),_jsxruntime.jsx.call(void 0, "span",{children:Co(Number(m.totalAmount),m.currency)})]})})]})]}),_jsxruntime.jsxs.call(void 0, Re,{children:[_jsxruntime.jsx.call(void 0, je,{children:_jsxruntime.jsxs.call(void 0, Fe,{children:["Komentarze ",m.commentCount>0&&`(${m.commentCount})`]})}),_jsxruntime.jsxs.call(void 0, De,{children:[m.comments.length>0?_jsxruntime.jsx.call(void 0, "div",{className:"space-y-4",children:m.comments.map(N=>_jsxruntime.jsxs.call(void 0, "div",{className:"border-b pb-4 last:border-b-0",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"mb-1 flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:N.authorName||"System"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs text-neutral-500",children:wo(N.createdAt)}),N.authorType==="admin"&&_jsxruntime.jsx.call(void 0, "span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),_jsxruntime.jsx.call(void 0, "p",{className:p?"":"text-neutral-500",children:N.message})]},N.id))}):_jsxruntime.jsx.call(void 0, "p",{className:"text-neutral-600",children:"Brak komentarzy."}),p?_jsxruntime.jsx.call(void 0, ls,{orderID:m.orderId,email:c}):_jsxruntime.jsx.call(void 0, "div",{className:"mt-4",children:_jsxruntime.jsxs.call(void 0, _chunkYPA6MMGJjs.k,{onClick:()=>P(!0),variant:"outline",className:"w-full",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Lock,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),f&&_jsxruntime.jsx.call(void 0, "div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:_jsxruntime.jsxs.call(void 0, Re,{className:"w-full max-w-md",children:[_jsxruntime.jsx.call(void 0, je,{children:_jsxruntime.jsx.call(void 0, Fe,{children:"Zweryfikuj sw\xF3j email"})}),_jsxruntime.jsxs.call(void 0, De,{className:"space-y-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunkHP3I6D2Rjs.d,{htmlFor:"verify-email",children:"Adres email"}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.l,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:c,onChange:N=>l(N.target.value)})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{variant:"outline",onClick:()=>P(!1),className:"flex-1",children:"Anuluj"}),_jsxruntime.jsx.call(void 0, _chunkYPA6MMGJjs.k,{onClick:S,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function cs(e){return _jsxruntime.jsx.call(void 0, ds,{...e})}var Dr=cs;var ps=({returnsAppearance:e,returnsTexts:t,analytics:n}={})=>{let{projectID:o,theme:r,loginURL:a,host:i}=_chunkKDL35KEIjs.b.call(void 0, ),[,d]=_react3.useState.call(void 0, 0),c=_chunkIRZJIPUFjs.n.call(void 0, o,n,"panel"),l=_chunkMDAFPGPAjs.i.call(void 0, o,i),f=_chunkMDAFPGPAjs.k.call(void 0, o,i),{mutateAsync:P}=_chunkYPA6MMGJjs.g.call(void 0, _chunkYPA6MMGJjs.e.publicApi.userPanelLogout);async function x(){l&&await P({accessToken:l}),typeof window<"u"&&(_chunkMDAFPGPAjs.l.call(void 0, o,i),window.location.reload())}let[I]=_react.useAutoAnimate.call(void 0, ),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]=_react3.useState.call(void 0, 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);_react3.useEffect.call(void 0, ()=>{g(u.state)&&(u.state==="course"||p==="course"||u.state==="messages"||p==="messages")&&b(u.state)},[u.state]);let fe={"--button-background-color":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _137 => _137.colors, 'optionalAccess', _138 => _138.brand]), () => ("#000000")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _139 => _139.colors, 'optionalAccess', _140 => _140.brandDark]), () => ("#ffffff")),"--button-text-color":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _141 => _141.colors, 'optionalAccess', _142 => _142.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _143 => _143.colors, 'optionalAccess', _144 => _144.brand]), () => ("#000000"))};return _react3.useEffect.call(void 0, ()=>{if(l==null||l.length===0){window.location.href=_nullishCoalesce(a, () => ("/panel/login"));return}},[]),_react3.useEffect.call(void 0, ()=>{if(l==null||l.length===0){window.location.href=_nullishCoalesce(a, () => ("/panel/login"));return}},[p]),_react3.useEffect.call(void 0, ()=>{if(typeof window>"u"||window.parent!==window||!l)return;let E=gt(window.location.search);E&&yt(E);let ge=_nullishCoalesce(E, () => (Ze()));ge&&(window.location.href=Qe(ge,l))},[l]),_jsxruntime.jsx.call(void 0, _chunkIRZJIPUFjs.l,{value:c,children:_jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsx.call(void 0, Sr,{activeScreen:p,setActiveScreen:b,setParams:N,styles:fe,theme:r,logout:x,email:f,projectID:o,showMessages:te.visible||p==="messages"}),_jsxruntime.jsxs.call(void 0, "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"&&_jsxruntime.jsx.call(void 0, yo,{projectID:_nullishCoalesce(o, () => ("")),accessToken:l,loginURL:_nullishCoalesce(a, () => ("/panel/login")),styles:fe,activeScreen:p,params:u,setParams:m,openCourse:ce,openMessages:oe}),p==="messages"&&l&&_jsxruntime.jsx.call(void 0, 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&&_jsxruntime.jsx.call(void 0, Lr,{accessId:u.course,accessToken:l,theme:r,itemId:u.item,onItemChange:E=>m({item:E}),onBack:Se}),p==="notifications"&&_jsxruntime.jsx.call(void 0, yr,{}),p==="plans"&&_jsxruntime.jsx.call(void 0, hr,{projectID:_nullishCoalesce(o, () => (""))}),p==="orders"&&_jsxruntime.jsx.call(void 0, Gn,{projectID:_nullishCoalesce(o, () => ("")),accessToken:_nullishCoalesce(l, () => ("")),openOrderDetails:S}),p==="order-details"&&u.orderId&&_jsxruntime.jsx.call(void 0, Dr,{orderID:u.orderId,onBack:U}),(p==="returns"||p==="return-details")&&l&&_jsxruntime.jsx.call(void 0, Pr,{projectID:_nullishCoalesce(o, () => ("")),host:i,accessToken:l,loginURL:_nullishCoalesce(a, () => ("/panel/login")),appearance:Bn(e,_optionalChain([r, 'optionalAccess', _145 => _145.colors, 'optionalAccess', _146 => _146.brand])),texts:t,screen:p,params:u,setParams:m,setActiveScreen:b}),p==="profile"&&_jsxruntime.jsx.call(void 0, Er,{email:f,logout:x,onLocaleChange:()=>d(E=>E+1)})]})]})})},ms= exports.G =ps;var _reactquery = require('@tanstack/react-query');var _connect = require('@connectrpc/connect');var _connectweb = require('@connectrpc/connect-web');var me;(o=>{function e(r){return _connect.createClient.call(void 0, _chunkEFN4OW2Cjs.g,n(r))}o.get=e;let t=new Map;function n(r){let a=t.get(r);return a==null&&(a=_connectweb.createConnectTransport.call(void 0, {useBinaryFormat:!0,baseUrl:r+"/api/rpc",interceptors:[_chunk4Y233NIIjs.b]}),t.set(r,a)),a}})(me = exports.a||={});var _zod = require('zod'); var _zod2 = _interopRequireDefault(_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=_zod2.default.object({event:_zod2.default.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:_zod2.default.string().optional(),value:_zod2.default.number().optional(),currency:_zod2.default.string().optional(),content_name:_zod2.default.string().optional(),items:_zod2.default.array(_zod2.default.object({id:_zod2.default.string(),name:_zod2.default.string(),price:_zod2.default.number().default(0),currency:_zod2.default.string().default("PLN"),quantity:_zod2.default.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=_nullishCoalesce(_nullishCoalesce(e.value, () => (_optionalChain([e, 'access', _147 => _147.items, 'optionalAccess', _148 => _148.reduce, 'call', _149 => _149((a,i)=>a+(i.price||0)*(i.quantity||1),0)]))), () => (0)),n=_optionalChain([e, 'access', _150 => _150.items, 'optionalAccess', _151 => _151.map, 'call', _152 => _152(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=_nullishCoalesce(_nullishCoalesce(e.value, () => (_optionalChain([e, 'access', _153 => _153.items, 'optionalAccess', _154 => _154.reduce, 'call', _155 => _155((a,i)=>a+(i.price||0)*(i.quantity||1),0)]))), () => (0)),n=_optionalChain([e, 'access', _156 => _156.items, 'optionalAccess', _157 => _157.map, 'call', _158 => _158(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=_nullishCoalesce(e.locale, () => (_chunkQ337IQNAjs.f.call(void 0, )));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:_nullishCoalesce(l.description, () => (""))})),defaultSelectedOptionId:r.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:n.merchantId+"",merchantName:n.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:_chunkQ337IQNAjs.c.call(void 0, "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,_nullishCoalesce(r.selectedDeliveryMethod, () => ((r.methods.length>0?r.methods[0].id:void 0))),o.couponCode,r.couponValue,_chunkQ337IQNAjs.c.call(void 0, "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=_nullishCoalesce(_optionalChain([l, 'access', _159 => _159.details, 'access', _160 => _160.pricing, 'optionalAccess', _161 => _161.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`${_chunk4Y233NIIjs.e}/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 _optionalChain([t, 'optionalAccess', _162 => _162.find, 'call', _163 => _163(n=>n.id===e||(_nullishCoalesce(_optionalChain([n, 'access', _164 => _164.variants, 'optionalAccess', _165 => _165.some, 'call', _166 => _166(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=_optionalChain([e, 'optionalAccess', _167 => _167.trim, 'call', _168 => _168()]);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 (e16){return}}var _zustand = require('zustand');var at=_zustand.create.call(void 0, 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}))}));var _t=_react3.createContext.call(void 0, {});function Lp({texts:e,locale:t,children:n}){let o=_react3.useMemo.call(void 0, ()=>({texts:e,locale:t}),[e,t]);return _jsxruntime.jsx.call(void 0, _t.Provider,{value:o,children:n})}function Uo(){return _react3.useContext.call(void 0, _t)}function Tp(e){let{texts:t,locale:n}=_react3.useContext.call(void 0, _t);return _chunkQ337IQNAjs.c.call(void 0, e,_nullishCoalesce(n, () => (_chunkQ337IQNAjs.f.call(void 0, ))),t)}function Ap(){let{texts:e,locale:t}=_react3.useContext.call(void 0, _t),n=_nullishCoalesce(t, () => (_chunkQ337IQNAjs.f.call(void 0, )));return _react3.useMemo.call(void 0, ()=>o=>_chunkQ337IQNAjs.c.call(void 0, 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,(_nullishCoalesce(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 _optionalChain([o, 'optionalAccess', _169 => _169.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 (e17){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 (e18){return!1}}function Es(e,t=Date.now(),n={}){if(Ss(e.url))return;let o=Is(e.url),r=_nullishCoalesce(_o(e.orderId), () => (_optionalChain([o, 'optionalAccess', _170 => _170.orderId]))),a=_nullishCoalesce(_o(e.projectId), () => (_optionalChain([o, 'optionalAccess', _171 => _171.projectId])));if(!(r==null||a==null))return{orderId:r,projectId:a,...n.cartProjectId!=null?{cartProjectId:n.cartProjectId}:{},lines:_nullishCoalesce(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 (e19){return}}function Ls(e,t=zt()){try{return _optionalChain([t, 'optionalAccess', _172 => _172.setItem, 'call', _173 => _173(_r,JSON.stringify(e))]),t!=null}catch (e20){return!1}}function zo(e=zt()){try{let t=_optionalChain([e, 'optionalAccess', _174 => _174.getItem, 'call', _175 => _175(_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 _optionalChain([c, 'optionalAccess', _176 => _176.id])=="string"&&typeof c.quantity=="number"):[],ts:i}}}catch (e21){}Ur(e)}function Ur(e=zt()){try{_optionalChain([e, 'optionalAccess', _177 => _177.removeItem, 'call', _178 => _178(_r)])}catch (e22){}}function Ho(e){let t=_nullishCoalesce(_optionalChain([e, 'access', _179 => _179.details, 'optionalAccess', _180 => _180.status]), () => (Ts(_optionalChain([e, 'access', _181 => _181.details, 'optionalAccess', _182 => _182.$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(_optionalChain([t, 'optionalAccess', _183 => _183.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 (e23){return}}}}async function qo(e){let t=_nullishCoalesce(e.storage, () => (zt())),n=zo(t);if(n==null)return"none";if((_nullishCoalesce(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 (e24){return"pending"}let a=zo(t);if(_optionalChain([a, 'optionalAccess', _184 => _184.orderId])!==n.orderId||a.ts!==n.ts)return"pending";if(r==="paid"||r==="placed"){try{await e.removeLines(n.lines)}catch (e25){return"pending"}return Ur(t),"paid"}return"pending"}var Us="__m_a",Yo=_react3.createContext.call(void 0, void 0),Hr= exports.I =void 0;function im(e){_chunkMDAFPGPAjs.a.call(void 0, {projectID:e}),Hr= exports.I =e,typeof window<"u"&&_chunkMDAFPGPAjs.g.call(void 0, [window.location.origin])}function st(){return _nullishCoalesce(_nullishCoalesce(Hr, () => (_optionalChain([document, 'access', _185 => _185.querySelector, 'call', _186 => _186('script[data-id][data-name="internal-cart"]'), 'optionalAccess', _187 => _187.getAttribute, 'call', _188 => _188("data-id")]))), () => (void 0))}function _s(){return _nullishCoalesce(_optionalChain([document, 'access', _189 => _189.querySelector, 'call', _190 => _190('script[data-id][data-name="internal-cart"]'), 'optionalAccess', _191 => _191.getAttribute, 'call', _192 => _192("data-custom-host")]), () => (void 0))}var zs=({children:e,locale:t})=>{let[n]=_react3.useState.call(void 0, ()=>new _reactquery.QueryClient),o=Uo();_react3.useEffect.call(void 0, ()=>{Ie()},[]);let r=st();if(_react3.useEffect.call(void 0, ()=>{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 _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{});let a=Br(r,_nullishCoalesce(t, () => (o.locale)),o.texts);return _jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:n,children:_jsxruntime.jsx.call(void 0, Yo.Provider,{value:a,children:e})})},zr,js=Fo(async e=>Ho(await me.get(_chunk4Y233NIIjs.e).getOrder({id:e.orderId,projectId:e.projectId})));function sm(){let{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:o}=_nullishCoalesce(T(), () => (qt));return{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:o}}function lm(){return(_nullishCoalesce(_optionalChain([T, 'call', _193 => _193(), 'optionalAccess', _194 => _194.products]), () => ([]))).map(e=>({id:e.id,quantity:e.quantity}))}function Fs(e){let t=T();V({...t,products:jo(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _195 => _195.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=[];_optionalChain([t, 'optionalAccess', _196 => _196.items])!=null&&t.items.length>0?n=t.items:n=_nullishCoalesce(_optionalChain([T, 'call', _197 => _197(), 'optionalAccess', _198 => _198.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",_nullishCoalesce(_optionalChain([t, 'optionalAccess', _199 => _199.locale]), () => (_chunkQ337IQNAjs.f.call(void 0, ))));let a;try{let i=await fetch(_chunk4Y233NIIjs.c.call(void 0, 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= exports.O =()=>{let e=_react3.useContext.call(void 0, Yo);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},cm= exports.P =zs,qs=_zod2.default.object({isAvailable:_zod2.default.boolean(),merchantId:_zod2.default.string(),merchantName:_zod2.default.string(),gateway:_zod2.default.string(),gatewayId:_zod2.default.string()}),$s=_zod2.default.object({id:_zod2.default.string(),productID:_zod2.default.string(),quantity:_zod2.default.number(),priceVersion:_zod2.default.string().optional(),amount:_zod2.default.number().int().nonnegative().optional(),metadata:_zod2.default.record(_zod2.default.string(),_zod2.default.string().optional()).optional(),url:_zod2.default.string().optional()}),Bs=_zod2.default.object({country:_zod2.default.string().optional(),couponCode:_zod2.default.string().optional(),selectedDeliveryMethod:_zod2.default.string().optional(),postalCode:_zod2.default.string().optional(),email:_zod2.default.string().optional(),products:_zod2.default.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"?[]:(_nullishCoalesce(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 _nullishCoalesce(t.products, () => ([]))){let r=_nullishCoalesce(n.get(o.productID), () => ([]));r.push(o),n.set(o.productID,r)}t.products=e.map(o=>{let r=_optionalChain([n, 'access', _200 => _200.get, 'call', _201 => _201(o.productId), 'optionalAccess', _202 => _202.shift, 'call', _203 => _203()]);return{id:Math.random().toString(36).substring(7),productID:o.productId,quantity:o.quantity,..._optionalChain([r, 'optionalAccess', _204 => _204.priceVersion])!=null?{priceVersion:r.priceVersion}:{},..._optionalChain([r, 'optionalAccess', _205 => _205.metadata])!=null?{metadata:r.metadata}:{},..._optionalChain([r, 'optionalAccess', _206 => _206.url])!=null?{url:r.url}:{}}}),V(t),Ie()}function fm(e){let t=new Map;for(let r of e)t.set(r.id,(_nullishCoalesce(t.get(r.id), () => (0)))+r.quantity);let n=T(),o=(_nullishCoalesce(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=_nullishCoalesce(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 (e26){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:_optionalChain([n, 'access', _207 => _207.find, 'call', _208 => _208(i=>i.productID===a.productID), 'optionalAccess', _209 => _209.details, 'optionalAccess', _210 => _210.pricing, 'optionalAccess', _211 => _211.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:_nullishCoalesce(a.name, () => ("")),price:_nullishCoalesce(a.price, () => (0)),quantity:a.quantity,currency:_nullishCoalesce(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=_nullishCoalesce(_nullishCoalesce(_optionalChain([o, 'optionalAccess', _212 => _212.details, 'optionalAccess', _213 => _213.pricing, 'optionalAccess', _214 => _214.effectivePrice]), () => (_optionalChain([o, 'optionalAccess', _215 => _215.details, 'optionalAccess', _216 => _216.price]))), () => (n.price)),a=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _217 => _217.details, 'optionalAccess', _218 => _218.currency]), () => (n.currency));if(r==null||a==null)continue;let i=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _219 => _219.catalogProductID]), () => (n.productID));(_nullishCoalesce(n.analytics, () => (_chunkIRZJIPUFjs.o.call(void 0, )))).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 (e27){}}function Ko(e){let t=T(),n={...t,products:_optionalChain([t, 'optionalAccess', _220 => _220.products, 'optionalAccess', _221 => _221.filter, 'call', _222 => _222(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 (e28){}}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=_optionalChain([r, 'access', _223 => _223.metadata, 'optionalAccess', _224 => _224[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=_chunkQ337IQNAjs.f.call(void 0, ),n)=>{let o=_s();return o!=null&&_chunk4Y233NIIjs.f.call(void 0, o),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await me.get(_chunk4Y233NIIjs.e).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(_optionalChain([a, 'optionalAccess', _225 => _225.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(_chunk4Y233NIIjs.e).getPreOrderDetails({items:d.map(P=>_protobuf.create.call(void 0, _chunkEFN4OW2Cjs.d,{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=>_optionalChain([P, 'access', _226 => _226.details, 'optionalAccess', _227 => _227.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=_optionalChain([T, 'call', _228 => _228(), 'optionalAccess', _229 => _229.country]),V(r),Ie()},async getAvailableCountries(){let r=await fetch(_chunk4Y233NIIjs.c.call(void 0, ot(e,"/countries")),{method:"GET"});if(r.status!=200)return[];try{return _zod2.default.array(_zod2.default.object({name:_zod2.default.string(),code:_zod2.default.string()})).parse(await r.json())}catch(a){return B(a.toString(),"internal")}},async getCountry(){let r=_optionalChain([T, 'call', _230 => _230(), 'optionalAccess', _231 => _231.country]);if(r==null){r="PL";let a=T();a.country=r,V(a)}return r},async getNumberOfElementsInCart(){return _nullishCoalesce(_optionalChain([T, 'call', _232 => _232(), 'optionalAccess', _233 => _233.products, 'optionalAccess', _234 => _234.reduce, 'call', _235 => _235((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=_optionalChain([a, 'access', _236 => _236.products, 'optionalAccess', _237 => _237.map, 'call', _238 => _238(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");_optionalChain([r, 'optionalAccess', _239 => _239.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:_nullishCoalesce(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(_chunk4Y233NIIjs.e).getPreOrderDetails({items:r.items.map(d=>_protobuf.create.call(void 0, _chunkEFN4OW2Cjs.d,{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=_optionalChain([r, 'access', _240 => _240.shippingContact, 'optionalAccess', _241 => _241.givenName]);_optionalChain([r, 'access', _242 => _242.shippingContact, 'optionalAccess', _243 => _243.familyName])!=null?d+=" "+_optionalChain([r, 'access', _244 => _244.shippingContact, 'optionalAccess', _245 => _245.familyName]):_optionalChain([r, 'access', _246 => _246.billingContact, 'optionalAccess', _247 => _247.familyName])!=null&&(d+=" "+_optionalChain([r, 'access', _248 => _248.billingContact, 'optionalAccess', _249 => _249.familyName]));let c={},l=Ht();l!=null&&(c.ref=l);let f=await me.get(_chunk4Y233NIIjs.e).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(r.token.paymentData),paymentMethod:JSON.stringify(r.token.paymentMethod),transactionIdentifier:r.token.transactionIdentifier,order:_protobuf.create.call(void 0, _chunkEFN4OW2Cjs.e,{items:i.map(P=>({id:P.productID,quantity:P.quantity})),couponCode:a.couponCode,email:_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([r, 'access', _250 => _250.shippingContact, 'optionalAccess', _251 => _251.emailAddress]), () => (_optionalChain([r, 'access', _252 => _252.billingContact, 'optionalAccess', _253 => _253.emailAddress]))), () => (a.email)), () => (void 0)),phone:_nullishCoalesce(_nullishCoalesce(_optionalChain([r, 'access', _254 => _254.shippingContact, 'optionalAccess', _255 => _255.phoneNumber]), () => (_optionalChain([r, 'access', _256 => _256.billingContact, 'optionalAccess', _257 => _257.phoneNumber]))), () => (void 0)),selectedDeliveryMethod:a.selectedDeliveryMethod,postCode:a.postalCode,projectId:e}),shippingAddress:_protobuf.create.call(void 0, _chunkEFN4OW2Cjs.a,{line1:_nullishCoalesce(_optionalChain([r, 'access', _258 => _258.shippingContact, 'optionalAccess', _259 => _259.addressLines, 'optionalAccess', _260 => _260[0]]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _261 => _261.shippingContact, 'optionalAccess', _262 => _262.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _263 => _263.shippingContact, 'optionalAccess', _264 => _264.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _265 => _265.shippingContact, 'optionalAccess', _266 => _266.postalCode]), () => ("")),name:d}),billingAddress:_protobuf.create.call(void 0, _chunkEFN4OW2Cjs.b,{name:_nullishCoalesce(_optionalChain([r, 'access', _267 => _267.billingContact, 'optionalAccess', _268 => _268.givenName]), () => (" "+(_nullishCoalesce(_optionalChain([r, 'access', _269 => _269.billingContact, 'optionalAccess', _270 => _270.familyName]), () => (""))))),line1:_nullishCoalesce(_optionalChain([r, 'access', _271 => _271.billingContact, 'optionalAccess', _272 => _272.addressLines, 'optionalAccess', _273 => _273[0]]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _274 => _274.billingContact, 'optionalAccess', _275 => _275.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _276 => _276.billingContact, 'optionalAccess', _277 => _277.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _278 => _278.billingContact, 'optionalAccess', _279 => _279.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=_optionalChain([r, 'access', _280 => _280.paymentData, 'access', _281 => _281.shippingAddress, 'optionalAccess', _282 => _282.name]),c={},l=Ht();l!=null&&(c.ref=l);let f=await me.get(_chunk4Y233NIIjs.e).authorizeOneClickPayment({gateway:1,paymentData:r.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:r.paymentData.paymentMethodData.type,transactionIdentifier:"",order:_protobuf.create.call(void 0, _chunkEFN4OW2Cjs.e,{items:i.map(P=>({id:P.productID,quantity:P.quantity})),couponCode:a.couponCode,email:_nullishCoalesce(r.paymentData.email, () => (void 0)),phone:_nullishCoalesce(_optionalChain([r, 'access', _283 => _283.paymentData, 'access', _284 => _284.shippingAddress, 'optionalAccess', _285 => _285.phoneNumber]), () => (void 0)),selectedDeliveryMethod:_nullishCoalesce(_optionalChain([r, 'access', _286 => _286.paymentData, 'access', _287 => _287.shippingOptionData, 'optionalAccess', _288 => _288.id]), () => (a.selectedDeliveryMethod)),postCode:_optionalChain([r, 'access', _289 => _289.paymentData, 'access', _290 => _290.shippingAddress, 'optionalAccess', _291 => _291.postalCode]),projectId:e}),shippingAddress:_protobuf.create.call(void 0, _chunkEFN4OW2Cjs.a,{line1:_nullishCoalesce(_optionalChain([r, 'access', _292 => _292.paymentData, 'access', _293 => _293.shippingAddress, 'optionalAccess', _294 => _294.address1]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _295 => _295.paymentData, 'access', _296 => _296.shippingAddress, 'optionalAccess', _297 => _297.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _298 => _298.paymentData, 'access', _299 => _299.shippingAddress, 'optionalAccess', _300 => _300.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _301 => _301.paymentData, 'access', _302 => _302.shippingAddress, 'optionalAccess', _303 => _303.postalCode]), () => ("")),name:d}),billingAddress:_protobuf.create.call(void 0, _chunkEFN4OW2Cjs.b,{name:_optionalChain([r, 'access', _304 => _304.paymentData, 'access', _305 => _305.paymentMethodData, 'access', _306 => _306.info, 'optionalAccess', _307 => _307.billingAddress, 'optionalAccess', _308 => _308.name]),line1:_nullishCoalesce(_optionalChain([r, 'access', _309 => _309.paymentData, 'access', _310 => _310.paymentMethodData, 'access', _311 => _311.info, 'optionalAccess', _312 => _312.billingAddress, 'optionalAccess', _313 => _313.address1]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _314 => _314.paymentData, 'access', _315 => _315.paymentMethodData, 'access', _316 => _316.info, 'optionalAccess', _317 => _317.billingAddress, 'optionalAccess', _318 => _318.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _319 => _319.paymentData, 'access', _320 => _320.paymentMethodData, 'access', _321 => _321.info, 'optionalAccess', _322 => _322.billingAddress, 'optionalAccess', _323 => _323.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _324 => _324.paymentData, 'access', _325 => _325.paymentMethodData, 'access', _326 => _326.info, 'optionalAccess', _327 => _327.billingAddress, 'optionalAccess', _328 => _328.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(_chunk4Y233NIIjs.e).getPreOrderDetails({items:i.map(l=>_protobuf.create.call(void 0, _chunkEFN4OW2Cjs.d,{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*(_nullishCoalesce(_nullishCoalesce(_optionalChain([l, 'access', _329 => _329.details, 'optionalAccess', _330 => _330.pricing, 'optionalAccess', _331 => _331.effectivePrice]), () => (_optionalChain([l, 'access', _332 => _332.details, 'optionalAccess', _333 => _333.price]))), () => (0)))/100,2)}`,label:_optionalChain([l, 'access', _334 => _334.details, 'optionalAccess', _335 => _335.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((_nullishCoalesce(d.totalAmount, () => (0)))/100,2)}`,label:_chunkQ337IQNAjs.c.call(void 0, "paymentForCart",t,n),type:"final"},shippingMethods:d.methods.map(l=>({amount:`${j(l.amount/100,2)}`,detail:_nullishCoalesce(l.description, () => ("")),identifier:l.id,label:l.name,dateComponentsRange:{startDateComponents:{days:_nullishCoalesce(l.minDays, () => (1)),hours:0,months:0,years:0},endDateComponents:{days:_nullishCoalesce(l.maxDays, () => (14)),hours:0,months:0,years:0}}})),lineItems:c,currencyCode:d.currency||_optionalChain([i, 'access', _336 => _336[0], 'optionalAccess', _337 => _337.details, 'optionalAccess', _338 => _338.currency])||"PLN"}}}};async function Vs(e){let t=T();if(_optionalChain([t, 'access', _339 => _339.googlePayConfig, 'optionalAccess', _340 => _340.isAvailable])!=!0){let n=await me.get(_chunk4Y233NIIjs.e).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=_optionalChain([t, 'access', _341 => _341.variants, 'optionalAccess', _342 => _342.findIndex, 'call', _343 => _343(r=>r.id===e)]);if(o!=null&&o!=-1){let r=t.variants[o];return{...t,availableQuantity:r.availableQuantity,isDeliverable:r.isDeliverable,images:_nullishCoalesce(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=_optionalChain([t, 'access', _344 => _344.variants, 'optionalAccess', _345 => _345.find, 'call', _346 => _346(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:_nullishCoalesce(n.images, () => (t.images))}}function Ie(){let e=T(),t=0;if(e==null){at.setState(n=>({...n,numberOfProductsInCart:t}));return}t=_nullishCoalesce(_optionalChain([e, 'access', _347 => _347.products, 'optionalAccess', _348 => _348.reduce, 'call', _349 => _349((n,o)=>n+o.quantity,0)]), () => (0)),at.setState(n=>({...n,numberOfProductsInCart:t}))}var Js=200,Zs= exports.m ="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:_nullishCoalesce(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 (e29){}return{message:Kr(e)}}function al(e){let t;try{t=JSON.parse(e)}catch (e30){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:_nullishCoalesce(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=_optionalChain([e, 'access', _350 => _350.data, 'optionalAccess', _351 => _351.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(()=>_optionalChain([o, 'optionalAccess', _352 => _352.abort, 'call', _353 => _353()]),n);try{let a=await fetch(e,{method:"POST",headers:t.headers,body:t.body,signal:_optionalChain([o, 'optionalAccess', _354 => _354.signal])});return a.ok?ll(await a.json()):null}catch (e31){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 = exports.s||={});async function ta(e){try{return await e.text()}catch (e32){return""}}function ra(e,t){return t=qr(t),t.locale??=_chunkQ337IQNAjs.f.call(void 0, ),{headers:{..._chunk4Y233NIIjs.a,..._chunkIRZJIPUFjs.h.call(void 0, 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={..._chunk4Y233NIIjs.a,..._chunkIRZJIPUFjs.h.call(void 0, 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??=_chunkQ337IQNAjs.f.call(void 0, );let r=await fetch(_chunk4Y233NIIjs.e+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}exports.a = me; exports.b = Re; exports.c = je; exports.d = Fe; exports.e = De; exports.f = zn; exports.g = gt; exports.h = yt; exports.i = Ze; exports.j = Qe; exports.k = Na; exports.l = Ue; exports.m = Zs; exports.n = xm; exports.o = Cm; exports.p = Nm; exports.q = Im; exports.r = at; exports.s = dl; exports.t = Wo; exports.u = Fr; exports.v = Um; exports.w = Ht; exports.x = qr; exports.y = Lp; exports.z = Tp; exports.A = Ap; exports.B = j; exports.C = To; exports.D = Mr; exports.E = Mp; exports.F = Dr; exports.G = ms; exports.H = Us; exports.I = Hr; exports.J = im; exports.K = st; exports.L = sm; exports.M = lm; exports.N = Hs; exports.O = dm; exports.P = cm; exports.Q = Ks; exports.R = um; exports.S = pm; exports.T = mm; exports.U = fm; exports.V = gm; exports.W = ym; exports.X = hm; exports.Y = Vo; exports.Z = Br;
5
+ //# sourceMappingURL=chunk-KZWCVKLU.js.map