bitsnap-react 1.15.0 → 1.16.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 (140) hide show
  1. package/AGENTS.md +3 -0
  2. package/README.md +76 -2
  3. package/dist/CartProvider-VGZMDVFJ.js +2 -0
  4. package/dist/CartProvider-VGZMDVFJ.js.map +1 -0
  5. package/dist/CartProvider-ZY5OLTAF.mjs +2 -0
  6. package/dist/PanelModelFiles-NYCOFPLY.js +2 -0
  7. package/dist/PanelModelFiles-NYCOFPLY.js.map +1 -0
  8. package/dist/PanelModelFiles-RV7OHUUZ.mjs +2 -0
  9. package/dist/PanelModelFiles-RV7OHUUZ.mjs.map +1 -0
  10. package/dist/Viewer3D-2IDEH6W3.mjs +2 -0
  11. package/dist/Viewer3D-2IDEH6W3.mjs.map +1 -0
  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.d.mts +5 -1
  16. package/dist/catalog.d.ts +5 -1
  17. package/dist/catalog.js +1 -1
  18. package/dist/catalog.js.map +1 -1
  19. package/dist/catalog.mjs +1 -1
  20. package/dist/chunk-5AYH23UJ.mjs +4 -0
  21. package/dist/chunk-5AYH23UJ.mjs.map +1 -0
  22. package/dist/chunk-5ED7FWNY.mjs +2 -0
  23. package/dist/chunk-5ED7FWNY.mjs.map +1 -0
  24. package/dist/chunk-5R6AGO3Z.mjs +2 -0
  25. package/dist/chunk-5R6AGO3Z.mjs.map +1 -0
  26. package/dist/chunk-6Q3VGPSF.js +2 -0
  27. package/dist/chunk-6Q3VGPSF.js.map +1 -0
  28. package/dist/chunk-6YIRRDCL.mjs +2 -0
  29. package/dist/chunk-6YIRRDCL.mjs.map +1 -0
  30. package/dist/chunk-7RXW6XFY.js +2 -0
  31. package/dist/chunk-7RXW6XFY.js.map +1 -0
  32. package/dist/chunk-AGYS7Z6G.mjs +2 -0
  33. package/dist/{chunk-2TLWMYXW.mjs.map → chunk-AGYS7Z6G.mjs.map} +1 -1
  34. package/dist/chunk-CUPG4B5W.mjs +2 -0
  35. package/dist/chunk-CUPG4B5W.mjs.map +1 -0
  36. package/dist/chunk-DPKWYLN7.mjs +2 -0
  37. package/dist/chunk-DPKWYLN7.mjs.map +1 -0
  38. package/dist/{chunk-MG6VV5J2.js → chunk-GQJDFLSL.js} +2 -2
  39. package/dist/chunk-GQJDFLSL.js.map +1 -0
  40. package/dist/chunk-GXUNRJ5S.js +2 -0
  41. package/dist/chunk-GXUNRJ5S.js.map +1 -0
  42. package/dist/chunk-I3QXJJ7U.mjs +2 -0
  43. package/dist/{chunk-7TLJKYZD.mjs.map → chunk-I3QXJJ7U.mjs.map} +1 -1
  44. package/dist/chunk-JSDGZ4NY.js.map +1 -1
  45. package/dist/chunk-KOYBZORL.js.map +1 -1
  46. package/dist/{chunk-XZYCQ655.js → chunk-LL7ASBGY.js} +2 -2
  47. package/dist/chunk-LL7ASBGY.js.map +1 -0
  48. package/dist/chunk-OZHXRKMX.js +2 -0
  49. package/dist/chunk-OZHXRKMX.js.map +1 -0
  50. package/dist/chunk-QERYM7RC.js +2 -0
  51. package/dist/chunk-QERYM7RC.js.map +1 -0
  52. package/dist/{chunk-PEVB3VL4.mjs → chunk-QQQ2JSPQ.mjs} +2 -2
  53. package/dist/{chunk-PEVB3VL4.mjs.map → chunk-QQQ2JSPQ.mjs.map} +1 -1
  54. package/dist/chunk-QXGK337V.mjs +2 -0
  55. package/dist/{chunk-Q3DSK66F.mjs.map → chunk-QXGK337V.mjs.map} +1 -1
  56. package/dist/{chunk-7DG4UPWE.js → chunk-SRQOFCMO.js} +2 -2
  57. package/dist/chunk-SRQOFCMO.js.map +1 -0
  58. package/dist/chunk-SULHGFYN.mjs +2 -0
  59. package/dist/chunk-SULHGFYN.mjs.map +1 -0
  60. package/dist/chunk-SXKJ26OA.mjs +2 -0
  61. package/dist/chunk-SXKJ26OA.mjs.map +1 -0
  62. package/dist/chunk-VNYHJT6V.mjs +2 -0
  63. package/dist/chunk-VNYHJT6V.mjs.map +1 -0
  64. package/dist/chunk-W3RGQYPD.js.map +1 -1
  65. package/dist/chunk-WKE6ECID.mjs +2 -0
  66. package/dist/chunk-WKE6ECID.mjs.map +1 -0
  67. package/dist/{chunk-FGB5FJCI.js → chunk-WPOXLITY.js} +2 -2
  68. package/dist/chunk-WPOXLITY.js.map +1 -0
  69. package/dist/chunk-Y5KWVTXT.js +4 -0
  70. package/dist/chunk-Y5KWVTXT.js.map +1 -0
  71. package/dist/consent.js.map +1 -1
  72. package/dist/course.js +1 -1
  73. package/dist/course.js.map +1 -1
  74. package/dist/course.mjs +1 -1
  75. package/dist/course.mjs.map +1 -1
  76. package/dist/embed/analytics.js +1 -1
  77. package/dist/errors.js.map +1 -1
  78. package/dist/index.css +1 -1
  79. package/dist/index.css.map +1 -1
  80. package/dist/index.js +1 -1
  81. package/dist/index.js.map +1 -1
  82. package/dist/index.mjs +1 -1
  83. package/dist/index.mjs.map +1 -1
  84. package/dist/internal.js.map +1 -1
  85. package/dist/methods-NJEP64AG.mjs +2 -0
  86. package/dist/methods-WRONKK3D.js +2 -0
  87. package/dist/methods-WRONKK3D.js.map +1 -0
  88. package/dist/model-files-client-HHDXJDTS.mjs +2 -0
  89. package/dist/model-files-client-HHDXJDTS.mjs.map +1 -0
  90. package/dist/model-files-client-P4PORZJ6.js +2 -0
  91. package/dist/model-files-client-P4PORZJ6.js.map +1 -0
  92. package/dist/models.d.mts +2 -0
  93. package/dist/models.d.ts +2 -0
  94. package/dist/models.js +1 -1
  95. package/dist/models.js.map +1 -1
  96. package/dist/models.mjs +1 -1
  97. package/dist/models.mjs.map +1 -1
  98. package/dist/returns.js +1 -1
  99. package/dist/returns.js.map +1 -1
  100. package/dist/returns.mjs +1 -1
  101. package/dist/viewer3d.css +2 -0
  102. package/dist/viewer3d.css.map +1 -0
  103. package/dist/viewer3d.d.mts +318 -0
  104. package/dist/viewer3d.d.ts +318 -0
  105. package/dist/viewer3d.js +2 -0
  106. package/dist/viewer3d.js.map +1 -0
  107. package/dist/viewer3d.mjs +63 -0
  108. package/dist/viewer3d.mjs.map +1 -0
  109. package/package.json +43 -16
  110. package/dist/CartProvider-64QEJ7A7.js +0 -2
  111. package/dist/CartProvider-64QEJ7A7.js.map +0 -1
  112. package/dist/CartProvider-XKK7A3C2.mjs +0 -2
  113. package/dist/chunk-2TLWMYXW.mjs +0 -2
  114. package/dist/chunk-7DG4UPWE.js.map +0 -1
  115. package/dist/chunk-7TLJKYZD.mjs +0 -2
  116. package/dist/chunk-AZQOW73L.mjs +0 -4
  117. package/dist/chunk-AZQOW73L.mjs.map +0 -1
  118. package/dist/chunk-DY2S42Q6.js +0 -2
  119. package/dist/chunk-DY2S42Q6.js.map +0 -1
  120. package/dist/chunk-FGB5FJCI.js.map +0 -1
  121. package/dist/chunk-GLAJPUMA.js +0 -2
  122. package/dist/chunk-GLAJPUMA.js.map +0 -1
  123. package/dist/chunk-H4WAQQVO.js +0 -2
  124. package/dist/chunk-H4WAQQVO.js.map +0 -1
  125. package/dist/chunk-MG6VV5J2.js.map +0 -1
  126. package/dist/chunk-Q3DSK66F.mjs +0 -2
  127. package/dist/chunk-RWEP6IUC.mjs +0 -2
  128. package/dist/chunk-RWEP6IUC.mjs.map +0 -1
  129. package/dist/chunk-S4Z4O46O.mjs +0 -2
  130. package/dist/chunk-S4Z4O46O.mjs.map +0 -1
  131. package/dist/chunk-VY6CZVVA.js +0 -4
  132. package/dist/chunk-VY6CZVVA.js.map +0 -1
  133. package/dist/chunk-XZYCQ655.js.map +0 -1
  134. package/dist/chunk-ZIWQ57GY.mjs +0 -2
  135. package/dist/chunk-ZIWQ57GY.mjs.map +0 -1
  136. package/dist/methods-NUMVR53L.js +0 -2
  137. package/dist/methods-NUMVR53L.js.map +0 -1
  138. package/dist/methods-YKZZ6OVT.mjs +0 -2
  139. /package/dist/{CartProvider-XKK7A3C2.mjs.map → CartProvider-ZY5OLTAF.mjs.map} +0 -0
  140. /package/dist/{methods-YKZZ6OVT.mjs.map → methods-NJEP64AG.mjs.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/panel/config.ts","../src/panel/PanelProvider.tsx","../src/panel/session-storage.ts"],"sourcesContent":["import type { GetThemeOutput } from \"./types\";\n\nlet config: PanelConfig = {\n projectID: undefined,\n loginURL: \"/panel/login\",\n theme: undefined,\n host: undefined,\n allowedReturnOrigins: [],\n};\n\nlet allowedReturnOrigins: string[] = [];\n\nexport interface PanelConfig {\n projectID?: string;\n loginURL?: string;\n theme?: GetThemeOutput;\n host?: string;\n allowedReturnOrigins: string[];\n}\n\nexport function setPanelConfig(newConfig: Partial<PanelConfig>): void {\n config = { ...config, ...newConfig };\n}\n\nexport function getPanelConfig(): PanelConfig {\n return config;\n}\n\nexport function setProjectID(projectID: string): void {\n config.projectID = projectID;\n}\n\nexport function setTheme(theme: GetThemeOutput): void {\n config.theme = theme;\n}\n\nexport function setLoginURL(loginURL: string): void {\n config.loginURL = loginURL;\n}\n\nexport function setHost(host: string): void {\n config.host = host;\n}\n\nexport function setAllowedReturnOrigins(origins: string[]): void {\n allowedReturnOrigins = origins;\n config = { ...config, allowedReturnOrigins: origins };\n}\n\nexport function getAllowedReturnOrigins(): string[] {\n return allowedReturnOrigins;\n}\n","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","const panelSessionKey = (projectID: string, host?: string) =>\n `bitsnap-panel-session:${encodeURIComponent(host ?? \"https://bitsnap.pl\")}:${encodeURIComponent(projectID)}`;\n\nconst panelEmailKey = (projectID: string, host?: string) =>\n `bitsnap-panel-email:${encodeURIComponent(host ?? \"https://bitsnap.pl\")}:${encodeURIComponent(projectID)}`;\n\nexport function getPanelSession(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return undefined;\n const token = window.localStorage.getItem(panelSessionKey(projectID, host));\n return token ?? undefined;\n}\n\nexport function savePanelSession(projectID: string | undefined, token: string, email: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return;\n window.localStorage.setItem(panelSessionKey(projectID, host), token);\n window.localStorage.setItem(panelEmailKey(projectID, host), email);\n}\n\nexport function getPanelEmail(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return null;\n return window.localStorage.getItem(panelEmailKey(projectID, host));\n}\n\nexport function clearPanelSession(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return;\n window.localStorage.removeItem(panelSessionKey(projectID, host));\n window.localStorage.removeItem(panelEmailKey(projectID, host));\n}\n"],"mappings":"yFAEA,IAAIA,EAAsB,CACxB,UAAW,OACX,SAAU,eACV,MAAO,OACP,KAAM,OACN,qBAAsB,CAAC,CACzB,EAEIC,EAAiC,CAAC,EAU/B,SAASC,EAAeC,EAAuC,CACpEH,EAAS,CAAE,GAAGA,EAAQ,GAAGG,CAAU,CACrC,CAEO,SAASC,GAA8B,CAC5C,OAAOJ,CACT,CAEO,SAASK,EAAaC,EAAyB,CACpDN,EAAO,UAAYM,CACrB,CAEO,SAASC,EAASC,EAA6B,CACpDR,EAAO,MAAQQ,CACjB,CAEO,SAASC,EAAYC,EAAwB,CAClDV,EAAO,SAAWU,CACpB,CAEO,SAASC,EAAQC,EAAoB,CAC1CZ,EAAO,KAAOY,CAChB,CAEO,SAASC,EAAwBC,EAAyB,CAC/Db,EAAuBa,EACvBd,EAAS,CAAE,GAAGA,EAAQ,qBAAsBc,CAAQ,CACtD,CAEO,SAASC,GAAoC,CAClD,OAAOd,CACT,CCnDA,OAAS,iBAAAe,EAAe,cAAAC,MAAkB,QA2BhC,cAAAC,MAAA,oBAlBV,IAAMC,EAAeC,EAA2BC,EAAe,CAAC,EAEnDC,EASR,CAAC,CAAE,SAAAC,EAAU,UAAAC,CAAU,IAAM,CAChC,IAAMC,EAASJ,EAAe,EACxBK,EAAaC,EAAcF,EAAO,UAAWD,EAAW,OAAO,EACrE,OACEN,EAACU,EAAA,CACC,SAAAV,EAACC,EAAa,SAAb,CAAsB,MAAO,CAAE,GAAGM,CAAO,EACxC,SAAAP,EAACW,EAAA,CAAmB,MAAOH,EACzB,SAAAR,EAAC,OAAI,UAAU,gBAAiB,SAAAK,EAAS,EAC3C,EACF,EACF,CAEJ,EAEaO,EAAiB,IAAMC,EAAWZ,CAAY,EClC3D,IAAMa,EAAkB,CAACC,EAAmBC,IAC1C,yBAAyB,mBAAmBA,GAAQ,oBAAoB,CAAC,IAAI,mBAAmBD,CAAS,CAAC,GAEtGE,EAAgB,CAACF,EAAmBC,IACxC,uBAAuB,mBAAmBA,GAAQ,oBAAoB,CAAC,IAAI,mBAAmBD,CAAS,CAAC,GAEnG,SAASG,EAAgBH,EAAoBC,EAAe,CACjE,OAAI,OAAO,OAAW,KAAe,CAACD,EAAW,OACnC,OAAO,aAAa,QAAQD,EAAgBC,EAAWC,CAAI,CAAC,GAC1D,MAClB,CAEO,SAASG,EAAiBJ,EAA+BK,EAAeC,EAAeL,EAAe,CACvG,OAAO,OAAW,KAAe,CAACD,IACtC,OAAO,aAAa,QAAQD,EAAgBC,EAAWC,CAAI,EAAGI,CAAK,EACnE,OAAO,aAAa,QAAQH,EAAcF,EAAWC,CAAI,EAAGK,CAAK,EACnE,CAEO,SAASC,EAAcP,EAAoBC,EAAe,CAC/D,OAAI,OAAO,OAAW,KAAe,CAACD,EAAkB,KACjD,OAAO,aAAa,QAAQE,EAAcF,EAAWC,CAAI,CAAC,CACnE,CAEO,SAASO,EAAkBR,EAAoBC,EAAe,CAC/D,OAAO,OAAW,KAAe,CAACD,IACtC,OAAO,aAAa,WAAWD,EAAgBC,EAAWC,CAAI,CAAC,EAC/D,OAAO,aAAa,WAAWC,EAAcF,EAAWC,CAAI,CAAC,EAC/D","names":["config","allowedReturnOrigins","setPanelConfig","newConfig","getPanelConfig","setProjectID","projectID","setTheme","theme","setLoginURL","loginURL","setHost","host","setAllowedReturnOrigins","origins","getAllowedReturnOrigins","createContext","useContext","jsx","PanelContext","createContext","getPanelConfig","PanelProvider","children","analytics","config","instrument","useInstrument","RpcProvider","InstrumentProvider","usePanelConfig","useContext","panelSessionKey","projectID","host","panelEmailKey","getPanelSession","savePanelSession","token","email","getPanelEmail","clearPanelSession"]}
@@ -1,2 +0,0 @@
1
- import{a as c}from"./chunk-PEVB3VL4.mjs";var l="X-Bitsnap-Client",i=`bitsnap-react@${c}`,d="bs_client",b={[l]:i},f=e=>t=>(t.header.set(l,i),e(t));function M(e){let t=e.indexOf("#"),n=t===-1?e:e.slice(0,t),r=t===-1?"":e.slice(t),a=n.includes("?")?/[?&]$/.test(n)?"":"&":"?";return`${n}${a}${d}=${encodeURIComponent(i)}${r}`}var g="https://bitsnap.pl",h=g;function K(e){console.log("setCustomHost",e),h=e}function m(e,t){return t.toLowerCase().startsWith("en")?e.en:e.pl}function k(e,t){let n={...e};if(t!=null)for(let[r,a]of Object.entries(t))a!=null&&(n[r]=a);return n}function u(e,t,n){return k(m(e,t),n)}function y(e,t){return e[t]??t}var C={en:{cart:"Cart",emptyCart:"Your cart is empty.",total:"Total:",delivery:"+ delivery",chooseCountry:"Choose a country",nextStep:"Next step",unavailableProducts:"Not all products are available.",checkoutFailed:"Something went wrong. Please try again later.",noPaymentGateway:"This shop doesn't accept online payments yet. Try again later or contact the seller.",gatewayNotConfigured:"Payments in this shop are not set up correctly. Try again later or contact the seller.",shippingNotConfigured:"Delivery in this shop is not configured yet. Try again later or contact the seller.",mixedRecurring:"Subscriptions and one-time products cannot be paid for together. Pay for them in separate orders.",currencyUnsupported:"The shop doesn't accept payments in this currency. Contact the seller.",priceChanged:"The product price has changed. Refresh the page to see the current price.",close:"Close cart",remove:"Remove",quantity:"Quantity",increaseQuantity:"Increase quantity",decreaseQuantity:"Decrease quantity",openCart:"Open cart",cartItemsCount:"Items in cart",lowestPrice30Days:"Lowest price in the last 30 days:",noPriceHistory:"No price data for the last 30 days",redirectFailed:"Could not redirect to the payment. Please try again later.",subscriptionUnsupported:"Subscriptions cannot be added to the cart yet.",searchCountry:"Find a country",noCountriesFound:"No countries found",countryRequired:"Choose a country to continue.",paymentForCart:"Cart payment",coupon:"Coupon",extrasCalculatedNext:"Discounts, shipping and taxes are calculated at the next step",loadFailed:"Could not load your cart.",retry:"Try again",paymentMethodLegend:"How would you like to pay?",paymentMethodOnline:"Pay online",paymentMethodOnlineDescription:"Card, BLIK code or instant bank payment. You pay right away.",paymentMethodManualTransfer:"Bank transfer",paymentMethodManualBlik:"BLIK \u2013 transfer to a phone number",paymentMethodManualBoth:"Bank transfer or BLIK to a phone number",paymentMethodManualDescription:"You pay in your bank's app. We show the payment details after you place the order, and the order waits for your payment.",paymentMethodManualBlikNote:"This is not a BLIK code payment \u2013 you do not enter a 6\u2011digit code.",paymentMethodCod:"Cash on delivery",paymentMethodCodDescription:"You pay the courier in cash or by card when you receive the parcel.",paymentMethodCodUnavailable:"Cash on delivery is not available for this order. Choose another way to pay."},pl:{cart:"Koszyk",emptyCart:"Brak produkt\xF3w w koszyku.",total:"Suma:",delivery:"+ dostawa",chooseCountry:"Wybierz kraj",nextStep:"Nast\u0119pny krok",unavailableProducts:"Nie wszystkie produkty s\u0105 dost\u0119pne w magazynie.",checkoutFailed:"Co\u015B posz\u0142o nie tak. Spr\xF3buj ponownie p\xF3\u017Aniej.",noPaymentGateway:"Ten sklep nie przyjmuje jeszcze p\u0142atno\u015Bci online. Spr\xF3buj ponownie p\xF3\u017Aniej lub skontaktuj si\u0119 ze sprzedawc\u0105.",gatewayNotConfigured:"P\u0142atno\u015Bci w tym sklepie nie s\u0105 poprawnie skonfigurowane. Spr\xF3buj ponownie p\xF3\u017Aniej lub skontaktuj si\u0119 ze sprzedawc\u0105.",shippingNotConfigured:"Dostawa w tym sklepie nie jest jeszcze skonfigurowana. Spr\xF3buj ponownie p\xF3\u017Aniej lub skontaktuj si\u0119 ze sprzedawc\u0105.",mixedRecurring:"Subskrypcji i produkt\xF3w jednorazowych nie mo\u017Cna op\u0142aci\u0107 razem. Op\u0142a\u0107 je w osobnych zam\xF3wieniach.",currencyUnsupported:"Sklep nie przyjmuje p\u0142atno\u015Bci w tej walucie. Skontaktuj si\u0119 ze sprzedawc\u0105.",priceChanged:"Cena produktu si\u0119 zmieni\u0142a. Od\u015Bwie\u017C stron\u0119, aby zobaczy\u0107 aktualn\u0105 cen\u0119.",close:"Zamknij koszyk",remove:"Usu\u0144",quantity:"Ilo\u015B\u0107",increaseQuantity:"Zwi\u0119ksz ilo\u015B\u0107",decreaseQuantity:"Zmniejsz ilo\u015B\u0107",openCart:"Otw\xF3rz koszyk",cartItemsCount:"Produkt\xF3w w koszyku",lowestPrice30Days:"Najni\u017Csza cena z 30 dni:",noPriceHistory:"Brak danych o cenie z ostatnich 30 dni",redirectFailed:"Nie uda\u0142o si\u0119 przekierowa\u0107 do p\u0142atno\u015Bci. Spr\xF3buj ponownie p\xF3\u017Aniej.",subscriptionUnsupported:"Subskrypcji nie mo\u017Cna jeszcze doda\u0107 do koszyka.",searchCountry:"Znajd\u017A kraj",noCountriesFound:"Nie znaleziono kraj\xF3w",countryRequired:"Wybierz kraj, aby przej\u015B\u0107 dalej.",paymentForCart:"P\u0142atno\u015B\u0107 za koszyk",coupon:"Kupon",extrasCalculatedNext:"Rabaty, dostawa i podatki w nast\u0119pnym kroku",loadFailed:"Nie uda\u0142o si\u0119 wczyta\u0107 koszyka.",retry:"Spr\xF3buj ponownie",paymentMethodLegend:"Jak chcesz zap\u0142aci\u0107?",paymentMethodOnline:"Zap\u0142a\u0107 online",paymentMethodOnlineDescription:"Karta, kod BLIK lub szybki przelew. P\u0142acisz od razu.",paymentMethodManualTransfer:"Przelew bankowy",paymentMethodManualBlik:"BLIK \u2013 przelew na telefon",paymentMethodManualBoth:"Przelew lub BLIK na telefon",paymentMethodManualDescription:"Zap\u0142acisz w aplikacji swojego banku. Dane do p\u0142atno\u015Bci poka\u017Cemy po z\u0142o\u017Ceniu zam\xF3wienia, a zam\xF3wienie poczeka na Twoj\u0105 wp\u0142at\u0119.",paymentMethodManualBlikNote:"To nie jest p\u0142atno\u015B\u0107 kodem BLIK \u2013 nie wpisujesz 6\u2011cyfrowego kodu.",paymentMethodCod:"P\u0142atno\u015B\u0107 przy odbiorze",paymentMethodCodDescription:"Zap\u0142acisz kurierowi got\xF3wk\u0105 lub kart\u0105, gdy odbierzesz przesy\u0142k\u0119.",paymentMethodCodUnavailable:"P\u0142atno\u015B\u0107 przy odbiorze nie jest dost\u0119pna dla tego zam\xF3wienia. Wybierz inn\u0105 form\u0119 p\u0142atno\u015Bci."}};function T(e,t){return u(C,e,t)}function v(e,t,n){return y(T(t,n),e)}var s="pl-PL",p="bitsnap-locale",o;function I(e){let t=e?.trim();o=t?t.toLowerCase()==="en"?"en-US":t.toLowerCase()==="pl"?s:t:void 0,typeof localStorage<"u"&&(o==null?localStorage.removeItem(p):localStorage.setItem(p,o))}function B(){return o??(typeof localStorage<"u"?localStorage.getItem(p)??s:s)}import{clsx as w}from"clsx";import{twMerge as x}from"tailwind-merge";function O(...e){return x(w(e))}export{b as a,f as b,M as c,O as d,g as e,h as f,K as g,m as h,u as i,v as j,s as k,I as l,B as m};
2
- //# sourceMappingURL=chunk-S4Z4O46O.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/client-header.ts","../src/components/checkout/constants.ts","../src/lib/texts.ts","../src/components/checkout/texts.ts","../src/components/checkout/locale.ts","../src/lib/utils.ts"],"sourcesContent":["import type { Interceptor } from \"@connectrpc/connect\";\nimport { SDK_VERSION } from \"../version\";\n\nexport const CLIENT_HEADER_NAME = \"X-Bitsnap-Client\";\nexport const CLIENT_HEADER_VALUE = `bitsnap-react@${SDK_VERSION}`;\n\nexport const CLIENT_QUERY_PARAM = \"bs_client\";\n\n/**\n * Spread into the `headers` of a fetch that already triggers a CORS preflight\n * (JSON POST, Connect RPC). Never use it on a simple cross-origin GET: the\n * custom header would force a preflight that older servers and merchant\n * proxies do not allow. Use `withClientParam` there.\n */\nexport const clientHeaders: Record<string, string> = {\n [CLIENT_HEADER_NAME]: CLIENT_HEADER_VALUE,\n};\n\n/** Connect interceptor adding the client header to every RPC. */\nexport const clientHeaderInterceptor: Interceptor = (next) => (req) => {\n req.header.set(CLIENT_HEADER_NAME, CLIENT_HEADER_VALUE);\n return next(req);\n};\n\n/** Adds `bs_client=<pkg>@<ver>` to a URL, for simple GETs that must stay preflight-free. */\nexport function withClientParam(url: string): string {\n const hash = url.indexOf(\"#\");\n const base = hash === -1 ? url : url.slice(0, hash);\n const fragment = hash === -1 ? \"\" : url.slice(hash);\n const separator = base.includes(\"?\") ? (/[?&]$/.test(base) ? \"\" : \"&\") : \"?\";\n return `${base}${separator}${CLIENT_QUERY_PARAM}=${encodeURIComponent(CLIENT_HEADER_VALUE)}${fragment}`;\n}\n","export const DEFAULT_HOST = \"https://bitsnap.pl\";\nexport let HOST = DEFAULT_HOST;\n\nexport function setCustomHost(host: string) {\n console.log(\"setCustomHost\", host);\n HOST = host;\n}\n","/**\n * Shared text machinery: typed string tables per locale, the locale fallback\n * and a merge with caller overrides. Each module (checkout, later returns)\n * supplies its own key type and default tables.\n */\n\n/** Strings of one locale, keyed by text key. */\nexport type TextTable<Key extends string> = Record<Key, string>;\n\n/** Default tables for the supported locales. */\nexport type LocaleTables<Key extends string> = {\n en: TextTable<Key>;\n pl: TextTable<Key>;\n};\n\n/**\n * Picks the table for a locale. Any locale starting with `en` (case\n * insensitive, so `en`, `en-US`, `EN-gb`) gets English; everything else,\n * including unknown locales, gets the Polish default.\n */\nexport function pickLocaleTable<Key extends string>(\n tables: LocaleTables<Key>,\n locale: string,\n): TextTable<Key> {\n return locale.toLowerCase().startsWith(\"en\") ? tables.en : tables.pl;\n}\n\n/**\n * Merges caller overrides over a table. Overrides apply regardless of the\n * locale; `undefined`/`null` entries are ignored so the default stays.\n */\nexport function mergeTexts<Key extends string>(\n table: TextTable<Key>,\n overrides?: Partial<TextTable<Key>>,\n): TextTable<Key> {\n const result: Record<string, string> = { ...table };\n\n if (overrides != null) {\n for (const [key, value] of Object.entries<string | undefined>(overrides)) {\n if (value != null) {\n result[key] = value;\n }\n }\n }\n\n return result as TextTable<Key>;\n}\n\n/** Locale table merged with the caller overrides. */\nexport function resolveTexts<Key extends string>(\n tables: LocaleTables<Key>,\n locale: string,\n overrides?: Partial<TextTable<Key>>,\n): TextTable<Key> {\n return mergeTexts(pickLocaleTable(tables, locale), overrides);\n}\n\n/** Looks up a single text. Unknown keys return the key itself. */\nexport function lookupText<Key extends string>(\n texts: TextTable<Key>,\n key: Key,\n): string {\n return (texts as Record<string, string | undefined>)[key] ?? key;\n}\n","import {\n lookupText,\n resolveTexts,\n type LocaleTables,\n} from \"@/src/lib/texts\";\n\n/**\n * Every string the checkout renders. Pass a partial object through the\n * `texts` prop of `BitsnapCheckout` to override any of them, whatever the\n * locale.\n */\nexport type CheckoutTexts = {\n /** Drawer title. */\n cart: string;\n /** Shown when the cart has no products. */\n emptyCart: string;\n /** Label next to the total price. */\n total: string;\n /** Delivery note next to the total price. */\n delivery: string;\n /** Country selector placeholder. */\n chooseCountry: string;\n /** Checkout button label. */\n nextStep: string;\n /** Error shown when some products are out of stock. */\n unavailableProducts: string;\n /** Error shown when the checkout fails and the server gave no reason. */\n checkoutFailed: string;\n /** Error shown when the shop has no payment gateway connected. */\n noPaymentGateway: string;\n /** Error shown when the payment gateway of the shop is not set up. */\n gatewayNotConfigured: string;\n /** Error shown when delivery of the shop is not set up. */\n shippingNotConfigured: string;\n /** Error shown when the cart mixes subscriptions with one-time products. */\n mixedRecurring: string;\n /** Error shown when the cart currency cannot be paid in. */\n currencyUnsupported: string;\n /** Error shown when a price changed after the product was added. */\n priceChanged: string;\n /** Accessible name of the close button of the drawer. */\n close: string;\n /** Remove button of a cart line (also read together with the product name). */\n remove: string;\n /** Accessible name of the quantity control and its input. */\n quantity: string;\n /** Accessible name of the \"+\" quantity button. */\n increaseQuantity: string;\n /** Accessible name of the \"-\" quantity button. */\n decreaseQuantity: string;\n /** Accessible name of the cart button when it only shows an icon. */\n openCart: string;\n /** Hidden label of the number of products badge; the number is appended after a colon. */\n cartItemsCount: string;\n /** Label before the lowest price of the last 30 days; the price is appended. */\n lowestPrice30Days: string;\n /** Shown instead of the lowest price when the price has no history. */\n noPriceHistory: string;\n /** Error shown when redirecting to the payment failed. */\n redirectFailed: string;\n /** Error shown when a subscription is added to the cart. */\n subscriptionUnsupported: string;\n /** Country search placeholder. */\n searchCountry: string;\n /** Shown when the country search has no match. */\n noCountriesFound: string;\n /** Hint under the checkout button when no country is chosen. */\n countryRequired: string;\n /** Title of the Apple Pay and Google Pay sheet total. */\n paymentForCart: string;\n /** Coupon label in the Google Pay sheet; the code is appended. */\n coupon: string;\n /** Note under the cart total. */\n extrasCalculatedNext: string;\n /** Error shown when the products of the cart could not be loaded. */\n loadFailed: string;\n /** Button that loads the cart again. */\n retry: string;\n /** Heading of the payment method choice (shown only when the shop offers paying by hand). */\n paymentMethodLegend: string;\n /** Option that pays through the shop's online gateway. */\n paymentMethodOnline: string;\n /** Hint under the online option. */\n paymentMethodOnlineDescription: string;\n /** Manual option when the seller takes bank transfers only. */\n paymentMethodManualTransfer: string;\n /** Manual option when the seller takes BLIK transfers to a phone number only. */\n paymentMethodManualBlik: string;\n /** Manual option when the seller takes both. */\n paymentMethodManualBoth: string;\n /** What paying by hand means: the details come after the order is placed. */\n paymentMethodManualDescription: string;\n /** Shown with a selected manual option that includes BLIK to a phone number. */\n paymentMethodManualBlikNote: string;\n /** Cash on delivery option. */\n paymentMethodCod: string;\n /** Hint under the cash on delivery option. */\n paymentMethodCodDescription: string;\n /** Error shown when the shop refused cash on delivery for the order. */\n paymentMethodCodUnavailable: string;\n};\n\nexport type CheckoutTextKey = keyof CheckoutTexts;\n\nexport const CHECKOUT_TEXT_TABLES: LocaleTables<CheckoutTextKey> = {\n en: {\n cart: \"Cart\",\n emptyCart: \"Your cart is empty.\",\n total: \"Total:\",\n delivery: \"+ delivery\",\n chooseCountry: \"Choose a country\",\n nextStep: \"Next step\",\n unavailableProducts: \"Not all products are available.\",\n checkoutFailed: \"Something went wrong. Please try again later.\",\n noPaymentGateway:\n \"This shop doesn't accept online payments yet. Try again later or contact the seller.\",\n gatewayNotConfigured:\n \"Payments in this shop are not set up correctly. Try again later or contact the seller.\",\n shippingNotConfigured:\n \"Delivery in this shop is not configured yet. Try again later or contact the seller.\",\n mixedRecurring:\n \"Subscriptions and one-time products cannot be paid for together. Pay for them in separate orders.\",\n currencyUnsupported:\n \"The shop doesn't accept payments in this currency. Contact the seller.\",\n priceChanged: \"The product price has changed. Refresh the page to see the current price.\",\n close: \"Close cart\",\n remove: \"Remove\",\n quantity: \"Quantity\",\n increaseQuantity: \"Increase quantity\",\n decreaseQuantity: \"Decrease quantity\",\n openCart: \"Open cart\",\n cartItemsCount: \"Items in cart\",\n lowestPrice30Days: \"Lowest price in the last 30 days:\",\n noPriceHistory: \"No price data for the last 30 days\",\n redirectFailed: \"Could not redirect to the payment. Please try again later.\",\n subscriptionUnsupported: \"Subscriptions cannot be added to the cart yet.\",\n searchCountry: \"Find a country\",\n noCountriesFound: \"No countries found\",\n countryRequired: \"Choose a country to continue.\",\n paymentForCart: \"Cart payment\",\n coupon: \"Coupon\",\n extrasCalculatedNext:\n \"Discounts, shipping and taxes are calculated at the next step\",\n loadFailed: \"Could not load your cart.\",\n retry: \"Try again\",\n paymentMethodLegend: \"How would you like to pay?\",\n paymentMethodOnline: \"Pay online\",\n paymentMethodOnlineDescription:\n \"Card, BLIK code or instant bank payment. You pay right away.\",\n paymentMethodManualTransfer: \"Bank transfer\",\n paymentMethodManualBlik: \"BLIK – transfer to a phone number\",\n paymentMethodManualBoth: \"Bank transfer or BLIK to a phone number\",\n paymentMethodManualDescription:\n \"You pay in your bank's app. We show the payment details after you place the order, and the order waits for your payment.\",\n paymentMethodManualBlikNote:\n \"This is not a BLIK code payment – you do not enter a 6‑digit code.\",\n paymentMethodCod: \"Cash on delivery\",\n paymentMethodCodDescription:\n \"You pay the courier in cash or by card when you receive the parcel.\",\n paymentMethodCodUnavailable:\n \"Cash on delivery is not available for this order. Choose another way to pay.\",\n },\n pl: {\n cart: \"Koszyk\",\n emptyCart: \"Brak produktów w koszyku.\",\n total: \"Suma:\",\n delivery: \"+ dostawa\",\n chooseCountry: \"Wybierz kraj\",\n nextStep: \"Następny krok\",\n unavailableProducts: \"Nie wszystkie produkty są dostępne w magazynie.\",\n checkoutFailed: \"Coś poszło nie tak. Spróbuj ponownie później.\",\n noPaymentGateway:\n \"Ten sklep nie przyjmuje jeszcze płatności online. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n gatewayNotConfigured:\n \"Płatności w tym sklepie nie są poprawnie skonfigurowane. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n shippingNotConfigured:\n \"Dostawa w tym sklepie nie jest jeszcze skonfigurowana. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n mixedRecurring:\n \"Subskrypcji i produktów jednorazowych nie można opłacić razem. Opłać je w osobnych zamówieniach.\",\n currencyUnsupported:\n \"Sklep nie przyjmuje płatności w tej walucie. Skontaktuj się ze sprzedawcą.\",\n priceChanged: \"Cena produktu się zmieniła. Odśwież stronę, aby zobaczyć aktualną cenę.\",\n close: \"Zamknij koszyk\",\n remove: \"Usuń\",\n quantity: \"Ilość\",\n increaseQuantity: \"Zwiększ ilość\",\n decreaseQuantity: \"Zmniejsz ilość\",\n openCart: \"Otwórz koszyk\",\n cartItemsCount: \"Produktów w koszyku\",\n lowestPrice30Days: \"Najniższa cena z 30 dni:\",\n noPriceHistory: \"Brak danych o cenie z ostatnich 30 dni\",\n redirectFailed:\n \"Nie udało się przekierować do płatności. Spróbuj ponownie później.\",\n subscriptionUnsupported: \"Subskrypcji nie można jeszcze dodać do koszyka.\",\n searchCountry: \"Znajdź kraj\",\n noCountriesFound: \"Nie znaleziono krajów\",\n countryRequired: \"Wybierz kraj, aby przejść dalej.\",\n paymentForCart: \"Płatność za koszyk\",\n coupon: \"Kupon\",\n extrasCalculatedNext: \"Rabaty, dostawa i podatki w następnym kroku\",\n loadFailed: \"Nie udało się wczytać koszyka.\",\n retry: \"Spróbuj ponownie\",\n paymentMethodLegend: \"Jak chcesz zapłacić?\",\n paymentMethodOnline: \"Zapłać online\",\n paymentMethodOnlineDescription:\n \"Karta, kod BLIK lub szybki przelew. Płacisz od razu.\",\n paymentMethodManualTransfer: \"Przelew bankowy\",\n paymentMethodManualBlik: \"BLIK – przelew na telefon\",\n paymentMethodManualBoth: \"Przelew lub BLIK na telefon\",\n paymentMethodManualDescription:\n \"Zapłacisz w aplikacji swojego banku. Dane do płatności pokażemy po złożeniu zamówienia, a zamówienie poczeka na Twoją wpłatę.\",\n paymentMethodManualBlikNote:\n \"To nie jest płatność kodem BLIK – nie wpisujesz 6‑cyfrowego kodu.\",\n paymentMethodCod: \"Płatność przy odbiorze\",\n paymentMethodCodDescription:\n \"Zapłacisz kurierowi gotówką lub kartą, gdy odbierzesz przesyłkę.\",\n paymentMethodCodUnavailable:\n \"Płatność przy odbiorze nie jest dostępna dla tego zamówienia. Wybierz inną formę płatności.\",\n },\n};\n\n/** Default texts for a locale merged with the caller overrides. */\nexport function resolveCheckoutTexts(\n locale: string,\n overrides?: Partial<CheckoutTexts>,\n): CheckoutTexts {\n return resolveTexts(CHECKOUT_TEXT_TABLES, locale, overrides);\n}\n\nexport function getCheckoutText(\n key: CheckoutTextKey,\n locale: string,\n overrides?: Partial<CheckoutTexts>,\n): string {\n return lookupText(resolveCheckoutTexts(locale, overrides), key);\n}\n","import { pickLocaleTable } from \"@/src/lib/texts\";\nimport { CHECKOUT_TEXT_TABLES } from \"./texts\";\n\nexport const DEFAULT_LOCALE = \"pl-PL\" as const;\nconst localeStorageKey = \"bitsnap-locale\";\n\nlet activeLocale: string | undefined;\n\nexport function setLocale(locale?: string): void {\n const value = locale?.trim();\n activeLocale = value\n ? value.toLowerCase() === \"en\"\n ? \"en-US\"\n : value.toLowerCase() === \"pl\"\n ? DEFAULT_LOCALE\n : value\n : undefined;\n if (typeof localStorage !== \"undefined\") {\n if (activeLocale == null) {\n localStorage.removeItem(localeStorageKey);\n } else {\n localStorage.setItem(localeStorageKey, activeLocale);\n }\n }\n}\n\nexport function getLocale(): string {\n if (activeLocale != null) {\n return activeLocale;\n }\n if (typeof localStorage !== \"undefined\") {\n return localStorage.getItem(localeStorageKey) ?? DEFAULT_LOCALE;\n }\n return DEFAULT_LOCALE;\n}\n\nexport function translate(key: string, locale: string = getLocale()): string {\n return (\n (pickLocaleTable(CHECKOUT_TEXT_TABLES, locale) as Record<string, string>)[\n key\n ] ?? key\n );\n}\n","import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport type Modify<T, R> = Omit<T, keyof R> & R;\n\nexport type Partial<T> = {\n [P in keyof T]?: T[P];\n};\n"],"mappings":"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","names":["CLIENT_HEADER_NAME","CLIENT_HEADER_VALUE","SDK_VERSION","CLIENT_QUERY_PARAM","clientHeaders","clientHeaderInterceptor","next","req","withClientParam","url","hash","base","fragment","separator","DEFAULT_HOST","HOST","setCustomHost","host","pickLocaleTable","tables","locale","mergeTexts","table","overrides","result","key","value","resolveTexts","lookupText","texts","CHECKOUT_TEXT_TABLES","resolveCheckoutTexts","locale","overrides","resolveTexts","getCheckoutText","key","lookupText","DEFAULT_LOCALE","localeStorageKey","activeLocale","setLocale","locale","value","getLocale","clsx","twMerge","cn","inputs"]}
@@ -1,4 +0,0 @@
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 _chunkH4WAQQVOjs = require('./chunk-H4WAQQVO.js');var _chunk7DG4UPWEjs = require('./chunk-7DG4UPWE.js');var _chunkFGB5FJCIjs = require('./chunk-FGB5FJCI.js');var _chunkDY2S42Q6js = require('./chunk-DY2S42Q6.js');var _chunkMG6VV5J2js = require('./chunk-MG6VV5J2.js');var _react = require('@formkit/auto-animate/react');var _react3 = require('react'); var En = _interopRequireWildcard(_react3); var ft = _interopRequireWildcard(_react3);var _jsxruntime = require('react/jsx-runtime');function ue({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card",className:_chunkDY2S42Q6js.d.call(void 0, "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function be({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-header",className:_chunkDY2S42Q6js.d.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 ve({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-title",className:_chunkDY2S42Q6js.d.call(void 0, "leading-none font-semibold",e),...t})}function Mt({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-description",className:_chunkDY2S42Q6js.d.call(void 0, "text-muted-foreground text-sm",e),...t})}function me({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-content",className:_chunkDY2S42Q6js.d.call(void 0, "px-6",e),...t})}var _inputotp = require('input-otp');var _lucidereact = require('lucide-react');function On({className:e,containerClassName:t,...n}){return _jsxruntime.jsx.call(void 0, _inputotp.OTPInput,{"data-slot":"input-otp",containerClassName:_chunkDY2S42Q6js.d.call(void 0, "flex items-center gap-2 has-disabled:opacity-50",t),className:_chunkDY2S42Q6js.d.call(void 0, "disabled:cursor-not-allowed",e),...n})}function Ut({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"input-otp-group",className:_chunkDY2S42Q6js.d.call(void 0, "flex items-center",e),...t})}function Se({index:e,className:t,...n}){let o=En.useContext(_inputotp.OTPInputContext),{char:r,hasFakeCaret:a,isActive:i}=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _2 => _2.slots, 'access', _3 => _3[e]]), () => ({}));return _jsxruntime.jsxs.call(void 0, "div",{"data-slot":"input-otp-slot","data-active":i,className:_chunkDY2S42Q6js.d.call(void 0, "data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]",t),...n,children:[r,a&&_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:_jsxruntime.jsx.call(void 0, "div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}function Mn({...e}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"input-otp-separator",role:"separator",...e,children:_jsxruntime.jsx.call(void 0, _lucidereact.MinusIcon,{})})}function ia(){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 Z=ia;var ca="return_url",_t="__return_url",da="accessToken";function Qe(e){let t=new URLSearchParams(e).get(ca);return t?Un(t):null}function Xe(e){typeof window>"u"||(e?window.sessionStorage.setItem(_t,e):window.sessionStorage.removeItem(_t))}function Me(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(_t);return e?Un(e):null}function la(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 Un(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!la(t.origin,_chunk7DG4UPWEjs.h.call(void 0, ))?null:t.toString()}catch (e2){return null}}function Ue(e,t){let n=new URL(e);return n.searchParams.set(da,t),n.toString()}if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];_chunk7DG4UPWEjs.h.call(void 0, ).length===0&&_chunk7DG4UPWEjs.g.call(void 0, Array.from(new Set(t)))}var pa=({projectID:e,host:t,reveal:n,email:o,setEmail:r,loginUser:a,isLoginLoading:i,errMsg:c})=>{let{projectID:d,host:l}=_chunk7DG4UPWEjs.j.call(void 0, );if(typeof window<"u"&&_chunk7DG4UPWEjs.k.call(void 0, _nullishCoalesce(e, () => (d)),_nullishCoalesce(t, () => (l)))!=null)return window.location.href=window.location.href.replaceAll("login",""),null;let[m,g]=_react3.useState.call(void 0, !1),k=s=>/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(s.trim())?g(!0):g(!1),u=s=>{let{value:P}=s.target;k(P),r(P)};function v(){n()}function C(s){s.preventDefault(),a()}return _jsxruntime.jsx.call(void 0, "main",{className:"mx-auto flex max-w-sm flex-1 flex-col justify-center space-y-12",children:_jsxruntime.jsx.call(void 0, "div",{className:_chunkDY2S42Q6js.d.call(void 0, "flex min-w-sm flex-col gap-6"),children:_jsxruntime.jsxs.call(void 0, ue,{children:[_jsxruntime.jsxs.call(void 0, be,{children:[_jsxruntime.jsx.call(void 0, ve,{className:"text-2xl",children:"Zaloguj si\u0119"}),_jsxruntime.jsx.call(void 0, Mt,{children:"Wy\u015Blemy do Ciebie kod na maila, dzi\u0119ki kt\xF3remu si\u0119 zalogujesz."})]}),_jsxruntime.jsx.call(void 0, me,{children:_jsxruntime.jsxs.call(void 0, "form",{onSubmit:C,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-6",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"grid gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.a,{htmlFor:"email",children:"Email"}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.r,{id:"email",onChange:u,type:"email",placeholder:"m@example.com",required:!0}),_jsxruntime.jsx.call(void 0, "span",{className:_chunkDY2S42Q6js.d.call(void 0, !m&&o.length>0?"font-bold text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!m&&o.length>0?"Nieprawid\u0142owy adres email":"Wpisz sw\xF3j adres email"})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{type:"submit",disabled:i,className:"relative w-full",onClick:a,children:[i&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:_jsxruntime.jsx.call(void 0, Z,{})}),"Zaloguj si\u0119"]}),c.length>0&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xs font-medium text-red-500",children:c})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-4 text-center text-sm",children:["Masz ju\u017C kod?"," ",_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:v,className:"underline underline-offset-4",children:"Mam ju\u017C kod"})]})]})})]})})})},fa=({projectID:e,host:t,email:n,reveal:o,setEmail:r,isLoginLoading:a,loginUserResponse:i,setLoginUserResponse:c,setResponseStatus:d,errMsg:l})=>{let m=_chunkMG6VV5J2js.m.call(void 0, ),{mutateAsync:g,isPending:k}=_chunkFGB5FJCIjs.l.call(void 0, _chunkFGB5FJCIjs.j.publicApi.userPanelLoginWithCode),[u,v]=_react3.useState.call(void 0, ""),[C,s]=_react3.useState.call(void 0, !1),[P,R]=_react3.useState.call(void 0, !1),[q,F]=_react3.useState.call(void 0, 0),A=M=>/^\d+$/.test(M.trim())?s(!0):s(!1),E=M=>{A(M),v(M)};async function z(){if(R(!0),u.length==0){s(!1);return}let M=parseInt(u),X=await g({code:M}),ye,Ce,re;if(X.result.case==="accessToken"?(s(!0),ye="ok",Ce=void 0,re=X.result.value):(s(!1),ye="error",Ce=X.result.value,re=void 0),ye==="error"&&(s(!1),console.warn("error:",`Kod b\u0142\u0119du: ${Ce}`),console.warn("Nieprawid\u0142owy kod, spr\xF3buj ponownie.")),ye==="ok"){m.track("panel_login",{}),re&&_chunk7DG4UPWEjs.l.call(void 0, e,re,n,t);let h=typeof window<"u"?Me():null;setTimeout(()=>{if(re&&h){window.location.href=Ue(h,re);return}window.location.reload()},100)}}function D(){let M=setInterval(()=>{F(X=>X>0?X-1:(clearInterval(M),0))},1e3);return()=>{clearInterval(M)}}_react3.useEffect.call(void 0, ()=>{_optionalChain([i, 'optionalAccess', _4 => _4.status])==="ok"&&_optionalChain([i, 'optionalAccess', _5 => _5.retryIn])>0&&(F(i.retryIn),D())},[i]);function $(){r(""),c(null),d("default"),o()}function ge(M){M.preventDefault(),z()}return _jsxruntime.jsx.call(void 0, "main",{className:"mx-auto flex max-w-md flex-1 flex-col justify-center space-y-8",children:_jsxruntime.jsx.call(void 0, "div",{className:_chunkDY2S42Q6js.d.call(void 0, "flex min-w-sm flex-col gap-6"),children:_jsxruntime.jsxs.call(void 0, ue,{children:[_jsxruntime.jsxs.call(void 0, be,{children:[_jsxruntime.jsx.call(void 0, ve,{className:"text-2xl",children:"Wpisz kod z maila"}),_jsxruntime.jsx.call(void 0, Mt,{children:"Sprawd\u017A czy przypadkiem nie wyl\u0105dowa\u0142 w spamie."})]}),_jsxruntime.jsxs.call(void 0, me,{children:[_jsxruntime.jsxs.call(void 0, "form",{onSubmit:ge,className:"flex flex-col gap-6",children:[_jsxruntime.jsx.call(void 0, "div",{className:"grid gap-2",children:_jsxruntime.jsx.call(void 0, "div",{className:"my-5 flex w-full items-center justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsxs.call(void 0, On,{id:"verify-code",maxLength:6,pattern:_inputotp.REGEXP_ONLY_DIGITS,onChange:M=>{E(M)},children:[_jsxruntime.jsxs.call(void 0, Ut,{children:[_jsxruntime.jsx.call(void 0, Se,{index:0}),_jsxruntime.jsx.call(void 0, Se,{index:1}),_jsxruntime.jsx.call(void 0, Se,{index:2})]}),_jsxruntime.jsx.call(void 0, Mn,{}),_jsxruntime.jsxs.call(void 0, Ut,{children:[_jsxruntime.jsx.call(void 0, Se,{index:3}),_jsxruntime.jsx.call(void 0, Se,{index:4}),_jsxruntime.jsx.call(void 0, Se,{index:5})]})]}),_jsxruntime.jsx.call(void 0, "span",{className:_chunkDY2S42Q6js.d.call(void 0, !C&&P?"text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!C&&P?u.length==0?"Kod nie mo\u017Ce by\u0107 pusty":"Kod musi sk\u0142ada\u0107 si\u0119 z cyfr":"Wpisz kod z maila"})]})})}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{type:"submit",disabled:a||k,className:"relative w-full",children:[(a||k)&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:_jsxruntime.jsx.call(void 0, Z,{})}),"Zaloguj si\u0119"]}),l.length>0&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xs font-medium text-red-500",children:l})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-4 text-center text-sm",children:["Nie masz kodu?"," ",_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:$,className:"underline underline-offset-4",children:"Wr\xF3\u0107"})]})]})]})})})},ga=({analytics:e})=>{let{theme:t,allowedReturnOrigins:n,projectID:o,host:r}=_chunk7DG4UPWEjs.j.call(void 0, ),a=_chunkMG6VV5J2js.n.call(void 0, o,e,"panel"),i={"--button-background-color":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _6 => _6.colors, 'optionalAccess', _7 => _7.brand]), () => ("#FFFFFF")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _8 => _8.colors, 'optionalAccess', _9 => _9.brandDark]), () => ("#000000")),"--button-text-color":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _10 => _10.colors, 'optionalAccess', _11 => _11.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _12 => _12.colors, 'optionalAccess', _13 => _13.brand]), () => ("#FFFFFF"))},[c,d]=_react3.useState.call(void 0, "login"),[l]=_react.useAutoAnimate.call(void 0, {duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1}),m=()=>d(E=>E==="login"?"verifyCode":"login"),[g,k]=_react3.useState.call(void 0, ""),[u,v]=_react3.useState.call(void 0, "default"),[C,s]=_react3.useState.call(void 0, null),{mutateAsync:P,isPending:R}=_chunkFGB5FJCIjs.l.call(void 0, _chunkFGB5FJCIjs.j.publicApi.userPanelLogin),[q,F]=_react3.useState.call(void 0, "");_react3.useEffect.call(void 0, ()=>{if(typeof window>"u"||window.parent!==window)return;let E=Qe(window.location.search);E&&Xe(E);let z=_nullishCoalesce(E, () => (Me()));if(!z)return;let D=_chunk7DG4UPWEjs.k.call(void 0, o,r);D&&(window.location.href=Ue(z,D))},[n,o,r]);async function A(){F(""),v("default");let E=await P({email:g}),z=E.result.case==="success"?"ok":"error",D=0,$;E.result.case==="success"&&(D=E.result.value.retryIn),z==="error"&&($="Nieprawid\u0142owy adres email, spr\xF3buj ponownie."),s({status:z,retryIn:D,message:$}),z==="ok"&&c==="login"?m():z==="ok"&&c==="verifyCode"?v("success"):z==="error"&&F(_nullishCoalesce($, () => ("Nieprawid\u0142owy adres email, spr\xF3buj ponownie.")))}return _jsxruntime.jsx.call(void 0, _chunkMG6VV5J2js.l,{value:a,children:_jsxruntime.jsx.call(void 0, "div",{className:"bg-white text-black dark:bg-black dark:text-white",children:_jsxruntime.jsxs.call(void 0, "div",{className:"font-inter flex h-screen w-screen flex-col p-4",style:i,ref:l,children:[_jsxruntime.jsxs.call(void 0, "header",{children:[_optionalChain([t, 'optionalAccess', _14 => _14.logoDarkURL])&&_jsxruntime.jsx.call(void 0, "img",{src:_optionalChain([t, 'optionalAccess', _15 => _15.logoDarkURL]),className:"hidden dark:inline",alt:"Company Logo",draggable:!1}),_optionalChain([t, 'optionalAccess', _16 => _16.logoURL])&&_jsxruntime.jsx.call(void 0, "img",{src:_optionalChain([t, 'optionalAccess', _17 => _17.logoURL]),className:"dark:hidden",alt:"Company Logo",draggable:!1})]}),c==="login"&&_jsxruntime.jsx.call(void 0, pa,{projectID:o,host:r,reveal:m,email:g,setEmail:k,loginUser:A,isLoginLoading:R,errMsg:q}),c==="verifyCode"&&_jsxruntime.jsx.call(void 0, fa,{projectID:o,host:r,email:g,reveal:m,setEmail:k,loginUser:A,isLoginLoading:R,loginUserResponse:C,setLoginUserResponse:s,responseStatus:u,setResponseStatus:v,errMsg:q})]})})})},ya= exports.n =({analytics:e}={})=>_jsxruntime.jsx.call(void 0, ga,{analytics: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 c=r.get(i);if(c!==null)try{a[i]=JSON.parse(c)}catch (e3){a[i]=c}}),{...e,...a}}),o=_react3.useCallback.call(void 0, r=>{n(a=>{let i={...a,...r};if(typeof window<"u"){let c=new URLSearchParams;Object.keys(i).forEach(l=>{let m=i[l];m!=null&&c.set(l,JSON.stringify(m))});let d=`${window.location.pathname}?${c.toString()}`;window.history.pushState({},"",d)}return i})},[]);return _react3.useEffect.call(void 0, ()=>{let r=()=>{let a=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(c=>{let d=a.get(c);if(d!==null)try{i[c]=JSON.parse(d)}catch (e4){i[c]=d}}),n({...e,...i})};return window.addEventListener("popstate",r),()=>window.removeEventListener("popstate",r)},[e]),[t,o]}function zn(e,t){if(e!=null)return e;let n=_optionalChain([t, 'optionalAccess', _18 => _18.trim, 'call', _19 => _19()]);if(!(n==null||n===""))return{tokens:_chunkFGB5FJCIjs.t.call(void 0, n)}}var _reactswitch = require('@radix-ui/react-switch'); var ut = _interopRequireWildcard(_reactswitch);function Fn({className:e,...t}){return _jsxruntime.jsx.call(void 0, ut.Root,{"data-slot":"switch",className:_chunkDY2S42Q6js.d.call(void 0, "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:_jsxruntime.jsx.call(void 0, ut.Thumb,{"data-slot":"switch-thumb",className:_chunkDY2S42Q6js.d.call(void 0, "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function wa({}){let[e,t]=_react3.useState.call(void 0, {disableAll:!1});return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Powiadomienia"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Zarz\u0105dzaj swoimi powiadomieniami"}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-6",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center space-x-2",children:[_jsxruntime.jsx.call(void 0, Fn,{id:"disable-all-notifications",checked:e.disableAll,onCheckedChange:n=>t(o=>({...o,disableAll:n}))}),_jsxruntime.jsxs.call(void 0, _chunkH4WAQQVOjs.a,{htmlFor:"disable-all-notifications",className:"flex flex-col gap-1 text-base",children:["Wszystkie powiadomienia",_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-normal text-neutral-500 md:text-sm",children:"Ten przycisk mo\u017Ce wy\u0142\u0105czy\u0107 wszystkie powiadomienia"})]})]})})]})}var Bn=wa;function Hn({className:e,...t}){return _jsxruntime.jsx.call(void 0, "nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:_chunkDY2S42Q6js.d.call(void 0, "mx-auto flex w-full justify-center",e),...t})}function $n({className:e,...t}){return _jsxruntime.jsx.call(void 0, "ul",{"data-slot":"pagination-content",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-row items-center gap-1",e),...t})}function we({...e}){return _jsxruntime.jsx.call(void 0, "li",{"data-slot":"pagination-item",...e})}function je({className:e,isActive:t,size:n="icon",...o}){return _jsxruntime.jsx.call(void 0, "a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:_chunkDY2S42Q6js.d.call(void 0, _chunkFGB5FJCIjs.p.call(void 0, {variant:t?"outline":"ghost",size:n}),e),...o})}function Gn({className:e,...t}){return _jsxruntime.jsxs.call(void 0, je,{"aria-label":"Go to previous page",size:"default",className:_chunkDY2S42Q6js.d.call(void 0, "gap-1 px-2.5 sm:pl-2.5",e),...t,children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeftIcon,{}),_jsxruntime.jsx.call(void 0, "span",{className:"hidden sm:block",children:"Previous"})]})}function Vn({className:e,...t}){return _jsxruntime.jsxs.call(void 0, je,{"aria-label":"Go to next page",size:"default",className:_chunkDY2S42Q6js.d.call(void 0, "gap-1 px-2.5 sm:pr-2.5",e),...t,children:[_jsxruntime.jsx.call(void 0, "span",{className:"hidden sm:block",children:"Next"}),_jsxruntime.jsx.call(void 0, _lucidereact.ChevronRightIcon,{})]})}function qt({className:e,...t}){return _jsxruntime.jsxs.call(void 0, "span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:_chunkDY2S42Q6js.d.call(void 0, "flex size-9 items-center justify-center",e),...t,children:[_jsxruntime.jsx.call(void 0, _lucidereact.MoreHorizontalIcon,{className:"size-4"}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"More pages"})]})}var Sa=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),Ra=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t.toUpperCase()}).format(e/100),Aa={draft:"Szkic",unpaid:"Nieop\u0142acona",paid:"Op\u0142acona",overdue:"Zaleg\u0142a",cancelled:"Anulowana",completed:"Zako\u0144czone",processing:"Przetwarzane",refunded:"Zwr\xF3cone"},Ta={draft:"text-neutral-400",unpaid:"text-yellow-500",paid:"text-green-600",overdue:"text-red-500",cancelled:"text-neutral-400 line-through",completed:"text-green-600",processing:"text-blue-500",refunded:"text-purple-500"};function Da({openOrderDetails:e,projectID:t,accessToken:n}){let[o,r]=_react3.useState.call(void 0, 0),a=20,{data:i,isFetching:c}=_chunkFGB5FJCIjs.k.call(void 0, _chunkFGB5FJCIjs.j.publicApi.getOrders,{projectId:t,accessToken:n,offset:o,limit:a}),d=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _20 => _20.orders]), () => ([])),l=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _21 => _21.totalCount]), () => (0)),m=Math.floor(o/a)+1,g=Math.ceil(l/a),k=u=>{r(u)};return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Historia zam\xF3wie\u0144"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"Twoje zam\xF3wienia"}),c?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((u,v)=>_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",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.u,{className:"h-4 w-24"}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.u,{className:"h-3 w-32"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2 text-right",children:[_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.u,{className:"ml-auto h-4 w-16"}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.u,{className:"ml-auto h-3 w-12"})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-3",children:_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.u,{className:"h-3 w-40"})})]},v))}):d.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"Brak zam\xF3wie\u0144."}):_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex w-full flex-col gap-3",children:d.map(u=>_jsxruntime.jsxs.call(void 0, "button",{onClick:()=>e(u.id),className:"block 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",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "p",{className:"font-medium",children:["Zam\xF3wienie #",u.id]}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:u.customerName||"Klient"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-semibold",children:Ra(u.totalAmount,u.currency)}),_jsxruntime.jsx.call(void 0, "p",{className:`text-xs font-medium ${_nullishCoalesce(Ta[u.status], () => ("text-neutral-400"))}`,children:_nullishCoalesce(Aa[u.status], () => (u.status))})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 flex items-center justify-between text-xs text-neutral-500 dark:text-neutral-400",children:_jsxruntime.jsxs.call(void 0, "span",{children:["Data:"," ",u.createdAt?Sa(Number(u.createdAt.seconds)):"-"]})})]},u.id))}),g>1&&!c&&_jsxruntime.jsx.call(void 0, "div",{className:"mt-4 flex justify-center",children:_jsxruntime.jsx.call(void 0, Hn,{children:_jsxruntime.jsxs.call(void 0, $n,{children:[m>1&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, Gn,{onClick:()=>k(o-a)})}),m>2&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, je,{onClick:()=>k(0),children:"1"})}),m>3&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, qt,{})}),[m-1,m,m+1].filter(u=>u>0&&u<=g).map(u=>_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, je,{onClick:()=>k((u-1)*a),isActive:m===u,children:u})},u)),m<g-2&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, qt,{})}),m<g&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, je,{onClick:()=>k((g-1)*a),children:g})}),m<g&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, Vn,{onClick:()=>k(o+a)})})]})})})]})]})}var Kn=Da;var Zn=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),Ea={active:"Aktywny",cancelled:"Anulowany",paused:"Wstrzymany"},Oa={active:"text-green-600",cancelled:"text-red-500",paused:"text-yellow-500"};function Ma({projectID:e}){let[t,n]=_react3.useState.call(void 0, []),[o,r]=_react3.useState.call(void 0, !0);return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Plany"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Twoje aktywne subskrypcje"}),o?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"\u0141adowanie..."}):t.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"Brak aktywnych plan\xF3w."}):_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex flex-col gap-4",children:t.map(a=>_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-white p-5 shadow-sm dark:bg-neutral-800",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-start justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-semibold",children:a.tierName}),a.configName&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:a.configName})]}),_jsxruntime.jsx.call(void 0, "span",{className:`text-sm font-medium ${_nullishCoalesce(Oa[a.status], () => ("text-neutral-500"))}`,children:_nullishCoalesce(Ea[a.status], () => (a.status))})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-3 grid grid-cols-2 gap-2 text-sm text-neutral-600 dark:text-neutral-400",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Dzie\u0144 rozliczenia:"})," ",a.billingDay]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Data startu:"})," ",Zn(a.startDate)]}),a.endDate&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Data zako\u0144czenia:"})," ",Zn(a.endDate)]})]})]},a.id))})]})}var Jn=Ma;function _a(e,t,n,o){typeof window>"u"||(t&&_chunk7DG4UPWEjs.n.call(void 0, n,o),window.location.href=e)}function za({projectID:e,host:t,loginURL:n,screen:o,params:r,setParams:a,setActiveScreen:i}){let{status:c,exchangeError:d}=_chunkH4WAQQVOjs.j.call(void 0, "PanelReturns"),l=_chunkH4WAQQVOjs.i.call(void 0, ),m=c==="anonymous"&&(d==null||_chunkH4WAQQVOjs.g.call(void 0, d));_react3.useEffect.call(void 0, ()=>{m&&_a(n,d!=null,e,t)},[m,n,d,e,t]);let[g,k]=_react3.useState.call(void 0, "orders"),[u,v]=_react3.useState.call(void 0, {items:[],note:""}),[C,s]=_react3.useState.call(void 0, );if(c==="anonymous"&&!m)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(_chunkH4WAQQVOjs.h.call(void 0, d))}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button",onClick:()=>window.location.reload(),children:l("errorRetry")})]});if(c!=="authenticated")return _jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.s,{});let P=R=>{k(R),a({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(o==="return-details"&&r.returnId)return _jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.A,{returnId:r.returnId,onBack:()=>P("myReturns")});if(g==="myReturns")return _jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.z,{onBack:()=>P("orders"),onSelectReturn:R=>{a({state:"return-details",returnId:R,orderId:void 0}),i("return-details")}});if(g==="result"&&C!=null)return _jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.y,{returnId:C,onContinue:()=>P("orders"),onOpenMyReturns:()=>P("myReturns")});if(r.orderId){let R=r.orderId;return g==="confirmation"?_jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.x,{orderId:R,items:u.items,note:u.note,onBack:()=>k("orders"),onSubmitted:q=>{s(q),v({items:[],note:""}),k("result"),a({orderId:void 0})}}):_jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.w,{orderId:R,initialItems:u.items.length>0?u.items:void 0,initialNote:u.note,onBack:()=>{v({items:[],note:""}),a({orderId:void 0})},onContinue:q=>{v(q),k("confirmation")}})}return _jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.v,{showLogout:!1,onSelectOrder:R=>{v({items:[],note:""}),k("orders"),a({orderId:R})},onOpenMyReturns:()=>P("myReturns")})}function Ht({accessToken:e,appearance:t,texts:n,...o}){return _jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.k,{projectID:o.projectID,host:o.host,appearance:t,texts:n,panelAccessToken:e,children:_jsxruntime.jsx.call(void 0, za,{...o})})}var Fa=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,Ba=e=>[...e.matchAll(Fa)].map(n=>({url:n[0],startIndex:n.index,endIndex:n.index+n[0].length-1})),Ha=(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},Yn=e=>{let t=Ba(e);return _jsxruntime.jsx.call(void 0, "p",{dangerouslySetInnerHTML:{__html:Ha(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 Qn(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="playing")}function Xn(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="paused")}function er(e,t){typeof navigator>"u"||typeof navigator.mediaSession>"u"||e!=null&&isNaN(e)||t!=null&&isNaN(t)||navigator.mediaSession.setPositionState({playbackRate:1,duration:e,position:t})}function tr(e){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.metadata=new MediaMetadata({title:e.title,artwork:e.artwork?[{type:"image/png",src:e.artwork}]:void 0}),navigator.mediaSession.setActionHandler("play",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("pause",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("stop",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekbackward",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekforward",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekto",t=>{e.action(t)}))}function nr(){navigator.mediaSession.metadata=null}var Za=_react3.forwardRef.call(void 0, ({chapters:e,styles:t,updateCurrentTime:n,setCurrentTimeHandler:o,title:r,imageURL:a,uniqueProductID:i,onChapterChange:c},d)=>{let l;(G=>(G[G.Playing=0]="Playing",G[G.Paused=1]="Paused"))(l||={});let[m,g]=_react3.useState.call(void 0, 1);_react3.useEffect.call(void 0, ()=>{switch(m){case 0:Qn();break;case 1:Xn();break}},[m]),_react3.useImperativeHandle.call(void 0, d,()=>({selectChapter:f=>{Ke(f)}}));let[k,u]=_react3.useState.call(void 0, void 0),[v,C]=_react3.useState.call(void 0, void 0),s=_react3.useRef.call(void 0, null),P=_react3.useRef.call(void 0, void 0),R=_react3.useRef.call(void 0, void 0),q=_react3.useRef.call(void 0, null),F=_react3.useRef.call(void 0, null),[A,E]=_react3.useState.call(void 0, !0),[z,D]=_react3.useState.call(void 0, !1),[$,ge]=_react3.useState.call(void 0, !Ja());function M(f){f<10||localStorage.setItem(`__player__${i}_${_optionalChain([F, 'access', _22 => _22.current, 'optionalAccess', _23 => _23.id])}`,`${f}`)}function X(){let f=localStorage.getItem(`__player__${i}_${_optionalChain([F, 'access', _24 => _24.current, 'optionalAccess', _25 => _25.id])}`);if(f!=null)try{let U=parseInt(f);return isNaN(U)||U<0?void 0:U}catch (e5){return}}function ye(){let f=localStorage.getItem(`__player__${i}_last_chapter`);if(f!=null)return f}function Ce(f){localStorage.setItem(`__player__${i}_last_chapter`,f)}function re(f){localStorage.removeItem(`__player__${i}_${f}`)}function h(){s.current!=null&&(s.current.onloadeddata=()=>{if(s.current!=null){if(s.current.readyState<2&&ge(!0),s.current.readyState>=2&&ge(!1),!z){let f=X();f!=null&&it(f),D(!0)}if(A){E(!1);try{Nt()}catch(f){console.log("play error",f)}}}},s.current.onplay=()=>{},s.current.onseeked=()=>{},s.current.onseeking=()=>{},s.current.onpause=()=>{},s.current.onended=()=>{ae()},tr({title:_nullishCoalesce(r, () => ("")),artwork:a,action:f=>{switch(f.action){case"play":Nt();break;case"pause":It();break;case"seekbackward":ot(-15);break;case"seekforward":ot(15);break;case"seekto":f.seekTime&&it(f.seekTime);break;case"stop":It();break;default:break}}}),Ne())}function ae(){if(e==null||e.length==0)return;let f=e.findIndex(G=>G.id==_optionalChain([F, 'access', _26 => _26.current, 'optionalAccess', _27 => _27.id]));f==-1||(re(e[f].id),f+1>=e.length)||Ke(e[f+1])}function Ne(){Re(),R.current==null&&(R.current=setTimeout(()=>{Re(),R.current=void 0,Ne()},500))}function Ve(){R.current!=null&&clearTimeout(R.current)}function Re(){s.current!=null&&(g(s.current.paused?1:0),C(s.current.duration),u(s.current.currentTime),M(s.current.currentTime),er(s.current.duration,s.current.currentTime),s.current.networkState===s.current.NETWORK_LOADING&&s.current.readyState<=s.current.HAVE_FUTURE_DATA?ge(!0):ge(!1),n&&n(s.current.currentTime))}function Nt(){_optionalChain([s, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.play, 'call', _30 => _30(), 'access', _31 => _31.then, 'call', _32 => _32(), 'access', _33 => _33.catch, 'call', _34 => _34()]),Re()}function It(){_optionalChain([s, 'access', _35 => _35.current, 'optionalAccess', _36 => _36.pause, 'call', _37 => _37()]),Re()}function Jr(){if(m===0){It();return}Nt()}function ot(f){if(s.current==null)return;let U=s.current.currentTime+f;if(U<0){s.current.currentTime=0;return}if(U>s.current.duration){s.current.currentTime=s.current.duration;return}s.current.currentTime+=f}function it(f){if(s.current!=null){if(u(f),f<0){s.current.currentTime=0;return}if(f>s.current.duration){s.current.currentTime=s.current.duration;return}s.current.currentTime=f}}function Yr(){s.current!=null&&(s.current.onplay=null,s.current.onseeked=null,s.current.onseeking=null,s.current.onpause=null,s.current.onended=null,s.current.src="",_optionalChain([P, 'access', _38 => _38.current, 'optionalAccess', _39 => _39.destroy, 'call', _40 => _40()]))}function dn(f){if(f.length==0)return;let U=ye();if(U==null){Ke(f[0]);return}let G=f.find(Ae=>Ae.id==U);if(G==null){Ke(f[0]);return}Ke(G)}function Ke(f){D(!1),E(!0),F.current=f,Qr(f.publicUrl),_optionalChain([c, 'optionalCall', _41 => _41(f)]),Ce(f.id)}function Qr(f){s.current!=null&&(s.current.canPlayType("application/vnd.apple.mpegurl")?s.current.src=f:_hlsjs2.default.isSupported()&&(P.current==null&&(P.current=new _hlsjs2.default,_optionalChain([P, 'access', _42 => _42.current, 'optionalAccess', _43 => _43.attachMedia, 'call', _44 => _44(s.current)])),_optionalChain([P, 'access', _45 => _45.current, 'optionalAccess', _46 => _46.loadSource, 'call', _47 => _47(f)])))}_react3.useEffect.call(void 0, ()=>{s.current!=null&&(h(),dn(e))},[s.current]),_react3.useEffect.call(void 0, ()=>{dn(e)},[e]),_react3.useEffect.call(void 0, ()=>(_optionalChain([o, 'optionalCall', _48 => _48(it)]),()=>{u(void 0),_optionalChain([s, 'access', _49 => _49.current, 'optionalAccess', _50 => _50.pause, 'call', _51 => _51()]),Yr(),nr()}),[]);let ln=f=>{let U=Math.floor(f/3600),G=Math.floor(f/60)%60,Ae=Math.floor(f%60),ea=U>0?U<10?`0${U}:`:`${U}:`:"",ta=Ae<10?`0${Ae}`:`${Ae}`;return isNaN(Ae)||isNaN(G)||isNaN(U)?"":`${ea}${G}:${ta}`},Xr=f=>{let U=parseFloat(f.value)/parseFloat(f.max)*100;q.current.style.setProperty("--seek-before-width",U+"%");let G=v*U/100;it(G)};return _jsxruntime.jsxs.call(void 0, "div",{id:"audio-player-container",className:"flex flex-col",style:t,ref:q,children:[_jsxruntime.jsx.call(void 0, "video",{ref:s,className:"hidden",poster:a,title:r}),_jsxruntime.jsx.call(void 0, "input",{type:"range",min:"0",max:v!=null?Math.floor(v).toString():100,value:_nullishCoalesce(k, () => (0)),onChange:f=>Xr(f.target),className:"w-full"}),_jsxruntime.jsxs.call(void 0, "section",{className:"flex w-full items-center justify-between text-sm font-medium",children:[_jsxruntime.jsx.call(void 0, "span",{id:"current-time",children:ln(k)}),_jsxruntime.jsx.call(void 0, "span",{id:"duration",children:ln(v)})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-6 flex items-center justify-center gap-x-12",children:[_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{variant:"outline",onClick:()=>ot(-10),"aria-label":"Rewind 10 Seconds",children:"-10"}),_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{variant:"outline",onClick:Jr,"aria-label":"Play Or Pause",children:[m===1&&_jsxruntime.jsx.call(void 0, _lucidereact.Play,{className:"h-5 w-5"}),m===0&&_jsxruntime.jsx.call(void 0, _lucidereact.Pause,{className:"h-5 w-5"})]}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{variant:"outline",onClick:()=>ot(10),"aria-label":"Fast Forward 10 Seconds",children:"+10"})]}),$&&_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 flex w-full justify-center",children:_jsxruntime.jsx.call(void 0, Z,{})})]})});function Ja(){return navigator.userAgent.toLowerCase().indexOf("safari/")>-1}var ar=Za;var Ya={pl:{returnsNavLabel:"Zwroty",openCourse:"Otw\xF3rz kurs"},en:{returnsNavLabel:"Returns",openCourse:"Open the course"}};function nt(e=_chunkDY2S42Q6js.m.call(void 0, )){return _chunkDY2S42Q6js.h.call(void 0, Ya,e)}function ir(){let[e,t]=ft.useState(13);return ft.useEffect(()=>{let n=setTimeout(()=>t(66),500);return()=>clearTimeout(n)},[]),_jsxruntime.jsx.call(void 0, "div",{className:"w-[60%] h-2 bg-gray-200 rounded-full overflow-hidden",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-full bg-blue-600 transition-all duration-300",style:{width:`${e}%`}})})}function pe(e,...t){console.warn(e,...t)}function $t(e){console.error(e)}var eo=({accessToken:e,product:t,styles:n,reveal:o,onOpenCourse:r})=>{let a=t.productType,i=_chunkMG6VV5J2js.m.call(void 0, ),c=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),d=_react3.useRef.call(void 0, null),[l]=_react.useAutoAnimate.call(void 0, ),[m,g]=_react3.useState.call(void 0, null),{mutateAsync:k,isPending:u}=_chunkFGB5FJCIjs.l.call(void 0, _chunkFGB5FJCIjs.j.publicApi.userPanelGetFileDetails),v=_react3.useRef.call(void 0, void 0),[C,s]=_react3.useState.call(void 0, null),[P,R]=_react3.useState.call(void 0, null),[q,F]=_react3.useState.call(void 0, !1),{mutateAsync:A,isPending:E}=_chunkFGB5FJCIjs.l.call(void 0, _chunkFGB5FJCIjs.j.publicApi.userPanelGetAudiobookDetails),{mutateAsync:z,isPending:D}=_chunkFGB5FJCIjs.l.call(void 0, _chunkFGB5FJCIjs.j.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[$,ge]=_react3.useState.call(void 0, null),[M,X]=_react3.useState.call(void 0, null);async function ye(){try{let h=await k({accessId:t.accessId,accessToken:e});if(h.result.case==="success"){g(h.result.value.files);return}else pe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),pe("Kod b\u0142\u0119du: ",h.result.value)}catch(h){pe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),$t("B\u0142\u0105d podczas pobierania danych:"+h)}}async function Ce(){try{let h=await A({accessId:t.accessId,accessToken:e});if(h.result.case==="audiobook"){s(h.result.value);return}else pe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),pe("Kod b\u0142\u0119du: ",h.result.value)}catch(h){pe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),$t("B\u0142\u0105d podczas pobierania danych:"+h)}}async function re(){try{let h=await z({accessId:t.accessId,accessToken:e,isBrowser:!0});if(h.result.case==="success"){R(h.result.value.audiobookDownloadDetails),F(h.result.value.isAvailableToDownloadInMobileApp===!0);return}else pe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),pe("Kod b\u0142\u0119du: ",h.result.value)}catch(h){pe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),$t("B\u0142\u0105d podczas pobierania danych:"+h)}}return _react3.useEffect.call(void 0, ()=>{a===1&&(Ce().then().catch(),re().then().catch())},[]),_react3.useEffect.call(void 0, ()=>{if(C!=null&&P!=null){let h=C.chapters;if(!h)return;let ae=h.map(Ne=>{let Ve=_optionalChain([P, 'optionalAccess', _52 => _52.find, 'call', _53 => _53(Re=>Re.chapterId===Ne.id)]);if(Ve!=null)return{...Ne,publicUrl:Ve.publicUrl,downloadableUrl:Ve.downloadableUrl,duration:Ve.duration}}).filter(Ne=>Ne!=null);ae!=null&&ae.length>0&&X(ae)}},[C,P]),_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, _chunkFGB5FJCIjs.q,{onClick:()=>o(),variant:"ghost",className:"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:"Wr\xF3\u0107"})]})}),_jsxruntime.jsxs.call(void 0, "main",{className:"grid grid-cols-1 justify-center gap-6 sm:justify-start lg:grid-cols-2",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full max-w-xl flex-col gap-6",children:[a===2&&_jsxruntime.jsxs.call(void 0, "div",{ref:l,className:"flex flex-col space-y-4 rounded bg-white p-6 drop-shadow-xl dark:border dark:border-neutral-700 dark:bg-neutral-800 dark:drop-shadow-none",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between gap-x-4",children:[_jsxruntime.jsx.call(void 0, "h4",{className:"text-xl font-semibold",children:"Twoje pliki"}),(m==null||m.length==0)&&_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{onClick:ye,"aria-label":"Download Product",className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:u?_jsxruntime.jsx.call(void 0, Z,{}):"Wy\u015Bwietl"})]}),u&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start gap-2",children:[_jsxruntime.jsx.call(void 0, ir,{}),_jsxruntime.jsx.call(void 0, "p",{className:"font-bold transition hover:text-blue-600",children:"Trwa przygotowanie plik\xF3w..."})]}),m!=null&&m.length>0&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-start justify-start gap-2",children:m.map((h,ae)=>_jsxruntime.jsxs.call(void 0, "a",{target:"_blank",className:"flex w-fit items-center gap-2 rounded-md bg-neutral-800 px-3 py-2 text-neutral-200 dark:bg-neutral-200 dark:text-neutral-800",href:h,download:!0,onClick:c,children:[`Plik numer ${ae+1}`,_jsxruntime.jsx.call(void 0, _lucidereact.Download,{width:14,height:14})]},ae))})]}),a===4&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-center justify-center rounded-xl bg-white p-6 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{onClick:()=>r(t.accessId),className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:nt().openCourse})}),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([$, 'optionalAccess', _54 => _54.name]), () => ("Odtwarzacz"))}),_optionalChain([$, 'optionalAccess', _55 => _55.description])&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:_optionalChain([$, 'optionalAccess', _56 => _56.description])}),_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:E?_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-2",children:[_jsxruntime.jsx.call(void 0, Z,{}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:M!=null?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsx.call(void 0, ar,{ref:d,chapters:M,title:_nullishCoalesce(_nullishCoalesce(_optionalChain([C, 'optionalAccess', _57 => _57.name]), () => (t.productName)), () => (void 0)),imageURL:_nullishCoalesce(_nullishCoalesce(_optionalChain([C, 'optionalAccess', _58 => _58.coverImage]), () => (t.productImageUrl)), () => (void 0)),styles:n,setCurrentTimeHandler:h=>{v.current=h},uniqueProductID:t.productId,onChapterChange:h=>{ge(h)}})}):_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:q?"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://docs.bitsnap.pl/guides/audiobook",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, "div",{className:"max-h-96 w-full overflow-y-auto",children:E?_jsxruntime.jsxs.call(void 0, "div",{className:"jusitfy-center flex flex-col items-center gap-2",children:[_jsxruntime.jsx.call(void 0, Z,{}),_jsxruntime.jsx.call(void 0, "p",{children:"\u0141adowanie rozdzia\u0142\xF3w..."})]}):_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h2",{className:"mb-3 text-xl font-semibold",children:"Rozdzia\u0142y"}),M==null?_jsxruntime.jsx.call(void 0, "p",{children:"Brak rozdzia\u0142\xF3w do wy\u015Bwietlenia."}):_jsxruntime.jsx.call(void 0, "ul",{className:"flex w-full flex-col gap-2",children:M.map((h,ae)=>_jsxruntime.jsxs.call(void 0, "li",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "button",{className:_chunkDY2S42Q6js.d.call(void 0, "w-full rounded-lg p-2 text-left transition hover:bg-neutral-200 active:bg-neutral-200 dark:hover:bg-neutral-700 dark:active:bg-neutral-700",_optionalChain([$, 'optionalAccess', _59 => _59.id])==h.id?"bg-neutral-200 dark:bg-neutral-700":"bg-neutral-100 dark:bg-neutral-800 dark:text-neutral-300"),onClick:()=>{d.current.selectChapter(h)},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium",children:h.name}),h.duration&&_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs text-neutral-500",children:[Math.floor(h.duration/60),":",String(Math.floor(h.duration%60)).padStart(2,"0")]})]}),h.description&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 text-xs",children:h.description})]}),C&&C.isDownloadable&&h.downloadableUrl&&_jsxruntime.jsx.call(void 0, "a",{href:h.downloadableUrl,onClick:c,children:_jsxruntime.jsx.call(void 0, _lucidereact.Download,{width:14,height:14})})]},ae))})]})})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"w-full max-w-3xl space-y-6 rounded-xl bg-white p-6 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-3xl font-semibold",children:t.productName}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-normal text-neutral-600 dark:text-neutral-300",children:t.productDescription}),_jsxruntime.jsx.call(void 0, "img",{src:t.productImageUrl,alt:"Product Photo",width:384,height:384,className:"max-h-sm max-w-sm",draggable:!1})]})]})]})},lr=eo;var ao=({accessToken:e,projectID:t,loginURL:n,styles:o,activeScreen:r,params:a,setParams:i,openCourse:c})=>{let{data:d,isLoading:l}=_chunkFGB5FJCIjs.k.call(void 0, _chunkFGB5FJCIjs.j.publicApi.userPanelGetProducts,{accessToken:e});if(l)return _jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2 bg-white p-2 dark:bg-black",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-dark font-inter font-medium dark:text-white",children:"\u0141adowanie..."}),_jsxruntime.jsx.call(void 0, Z,{})]});if(d&&d.result.case==="failure")return console.warn("error:",`Kod b\u0142\u0119du: ${d.result.value}`),_chunk7DG4UPWEjs.n.call(void 0, t),window.location.href=n,null;let m=d&&d.result.case==="success"?d.result.value.products:[];return _jsxruntime.jsx.call(void 0, oo,{accessToken:e,products:m,styles:o,loginURL:n,activeScreen:r,params:a,setParams:i,openCourse:c})},ur=ao,oo=({accessToken:e,products:t,styles:n,loginURL:o,activeScreen:r,params:a,setParams:i,openCourse:c})=>{if(t.length===0)return window.location.href=o,null;let[d,l]=_react3.useState.call(void 0, a.product?_protobuf.fromJsonString.call(void 0, _chunkFGB5FJCIjs.e,a.product):void 0),m=u=>{u==null?(l(void 0),i({product:void 0,state:"products"})):i({product:_protobuf.toJsonString.call(void 0, _chunkFGB5FJCIjs.e,u),state:"products"})};function g(u){switch(u){case 1:return"Audio";case 2:return"Plik";case 3:return"Bilet";case 4:return"Kurs";default:return}}function k(u){if(u.productType===4){c(u.accessId);return}l(u),m(u)}return r==="products"&&d!=null?_jsxruntime.jsx.call(void 0, lr,{accessToken:e,product:d,styles:n,reveal:m,onOpenCourse:c}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Hej \u{1F44B}"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Poni\u017Cej znajdziesz swoje produkty"}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex flex-wrap items-center justify-center gap-9 sm:justify-start",children:_optionalChain([t, 'optionalAccess', _60 => _60.map, 'call', _61 => _61((u,v)=>_jsxruntime.jsxs.call(void 0, "section",{onClick:()=>k(u),className:"w-full max-w-xs cursor-pointer rounded drop-shadow-xl dark:border dark:border-slate-600 dark:drop-shadow-none",children:[_jsxruntime.jsxs.call(void 0, "section",{className:"flex flex-col items-center space-y-2 rounded bg-slate-100 p-4 dark:bg-neutral-900",children:[u.productType&&_jsxruntime.jsx.call(void 0, "div",{className:"w-fit self-end rounded bg-red-900 px-4 py-1",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-medium text-white dark:text-slate-100",children:g(u.productType)})}),_jsxruntime.jsx.call(void 0, "div",{className:"jusitfy-center flex max-h-40 items-center",children:_jsxruntime.jsx.call(void 0, "img",{src:u.productImageUrl,alt:`Product ${v} Photo`,draggable:!1,className:"aspect-auto max-h-40"})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-4 rounded bg-white p-4 dark:bg-black",children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-xl font-semibold",children:u.productName}),_jsxruntime.jsx.call(void 0, "p",{title:u.productDescription,className:"line-clamp-3 text-sm font-normal text-neutral-600 dark:text-neutral-300",children:Yn(u.productDescription)}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{onClick:C=>{C.stopPropagation(),k(u)},className:"w-full text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:"Zobacz"})]})]},v))])})]})};function uo({activeScreen:e,setActiveScreen:t,setParams:n,styles:o,theme:r,logout:a}){return _jsxruntime.jsxs.call(void 0, "header",{className:"md:border-r-neutral-150 md:bg-beige-50 fixed right-0 bottom-0 left-0 z-10 flex h-12 w-full items-center bg-neutral-800 md:static md:z-0 md:min-h-screen md:w-auto md:border-r dark:md:border-r-neutral-900",children:[_jsxruntime.jsx.call(void 0, mo,{activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, po,{activeScreen:e,setActiveScreen:t,setParams:n,theme:r,logout:a})]})}var fr=uo;function mo({activeScreen:e,setActiveScreen:t,setParams:n}){let{returnsNavLabel:o}=nt();return _jsxruntime.jsxs.call(void 0, "nav",{className:"flex w-full items-center justify-evenly gap-4 md:hidden",children:[_jsxruntime.jsx.call(void 0, yt,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, yt,{panelScreen:"orders",label:"Faktury",imageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, yt,{panelScreen:"returns",label:o,icon:_jsxruntime.jsx.call(void 0, _lucidereact.Undo2,{className:"h-5 w-5 text-white","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, yt,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n})]})}function yt({panelScreen:e,label:t,imageURL:n,icon:o,activeScreen:r,setActiveScreen:a,setParams:i}){return _jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{onClick:()=>{a(e),i({product:void 0,state:e})},"aria-label":t,variant:null,className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-0",r===e?"opacity-100":"opacity-50"),children:[_nullishCoalesce(o, () => (_jsxruntime.jsx.call(void 0, "img",{src:n,alt:t,className:"scale-75"}))),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-normal text-white",children:t})]})}function ht({panelScreen:e,label:t,imageURL:n,darkImageURL:o,icon:r,activeScreen:a,setActiveScreen:i,setParams:c,isExpanded:d}){return _jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{onClick:()=>{i(e),c({product:void 0,state:e})},variant:a===e?"secondary":"ghost",className:"justify-start",children:[r!=null?_jsxruntime.jsx.call(void 0, "span",{className:_chunkDY2S42Q6js.d.call(void 0, "inline-flex h-5 w-5 items-center justify-center",d?"mr-4":"mr-2"),children:r}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "img",{src:n,alt:t,className:_chunkDY2S42Q6js.d.call(void 0, "aspect-auto h-5 w-5 dark:hidden",d?"mr-4":"mr-2")}),_jsxruntime.jsx.call(void 0, "img",{src:o,alt:t,className:_chunkDY2S42Q6js.d.call(void 0, "hidden aspect-auto h-5 w-5 dark:inline",d?"mr-4":"mr-2")})]}),d&&_jsxruntime.jsx.call(void 0, "span",{className:"md:text-medium hidden md:inline",children:t})]})}function po({activeScreen:e,setActiveScreen:t,setParams:n,theme:o,logout:r}){let[a]=_react.useAutoAnimate.call(void 0, ),[i,c]=_react3.useState.call(void 0, !0),{returnsNavLabel:d}=nt();return _jsxruntime.jsxs.call(void 0, "div",{ref:a,className:_chunkDY2S42Q6js.d.call(void 0, "hidden px-4 pt-4 pb-12 md:flex md:h-full md:flex-col dark:bg-neutral-900",i?"md:w-52":"md:w-16"),children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-between",children:_jsxruntime.jsx.call(void 0, fo,{theme:o,isExpanded:i})}),_jsxruntime.jsx.call(void 0, mr,{className:"my-6"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-1 flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, ht,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-dark-24x24.svg",darkImageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, ht,{panelScreen:"orders",label:"Zam\xF3wienia",imageURL:"/icons/category-dark-24x24.svg",darkImageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, ht,{panelScreen:"returns",label:d,icon:_jsxruntime.jsx.call(void 0, _lucidereact.Undo2,{className:"h-5 w-5","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, ht,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-dark-24x24.svg",darkImageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i})]}),_jsxruntime.jsx.call(void 0, mr,{className:"mb-6"}),_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{onClick:r,children:[_jsxruntime.jsx.call(void 0, _lucidereact.LogOut,{className:"mr-2",width:16,height:16}),i&&_jsxruntime.jsx.call(void 0, "p",{className:"md:text-medium hidden md:inline md:text-center",children:"Wyloguj si\u0119"})]})]})}function mr({className:e}){return _jsxruntime.jsxs.call(void 0, "div",{className:_chunkDY2S42Q6js.d.call(void 0, "relative h-px w-full bg-neutral-300",e),children:[_jsxruntime.jsx.call(void 0, "div",{className:"absolute -top-px left-0 h-1 w-1 rounded-full bg-neutral-500"}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute -top-px right-0 h-1 w-1 rounded-full bg-neutral-500"})]})}function fo({theme:e,isExpanded:t}){return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[e==null&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xl tracking-wider md:inline dark:text-neutral-200",children:"bitsnap."}),(_optionalChain([e, 'optionalAccess', _62 => _62.logoDarkURL])||_optionalChain([e, 'optionalAccess', _63 => _63.logoURL]))&&_jsxruntime.jsx.call(void 0, "img",{src:_nullishCoalesce(e.logoDarkURL, () => (e.logoURL)),alt:"Company Logo",className:"hidden h-6 w-6 dark:inline",draggable:!1}),_optionalChain([e, 'optionalAccess', _64 => _64.logoURL])&&_jsxruntime.jsx.call(void 0, "img",{src:e.logoURL,alt:"Company Logo",className:"h-6 w-6 dark:hidden",draggable:!1})]})}function yo({email:e,logout:t}){return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Profil"}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-6 flex-1 md:flex-none",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm text-neutral-500",children:"Email"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-base",children:e||"Brak danych"})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex w-full flex-col items-center space-y-2",children:_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{onClick:t,className:"max-w-64 md:hidden",children:[_jsxruntime.jsx.call(void 0, _lucidereact.LogOut,{className:"mr-2",width:16,height:16}),_jsxruntime.jsx.call(void 0, "p",{className:"text-medium inline text-center",children:"Wyloguj si\u0119"})]})})]})}var yr=yo;var vo=_react3.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./course.js"))).then(e=>({default:e.PanelCourse})));function Vt(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, Z,{})}),children:_jsxruntime.jsx.call(void 0, vo,{...e})})}function Co({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 No({orderID:e,email:t}){let[n,o]=_react3.useState.call(void 0, ""),r=_chunkFGB5FJCIjs.l.call(void 0, _chunkFGB5FJCIjs.j.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(c){console.error("Failed to add comment:",c)}},className:"mt-4 space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.a,{htmlFor:"comment",children:"Dodaj komentarz"}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.v,{id:"comment",value:n,onChange:i=>o(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:r.isPending}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{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 br(e){return e?new Date(Number(e.seconds)*1e3).toLocaleDateString("pl-PL",{year:"numeric",month:"long",day:"numeric"}):"N/A"}function vr(e,t){return new Intl.NumberFormat("pl-PL",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function Io({orderID:e,initialEmail:t,onBack:n,accessToken:o,analytics:r}){let{theme:a,projectID:i}=_chunk7DG4UPWEjs.j.call(void 0, ),c=_chunkMG6VV5J2js.n.call(void 0, i,r,"order"),[d,l]=_react3.useState.call(void 0, t||""),[m,g]=_react3.useState.call(void 0, !1),{data:k,isLoading:u,error:v,refetch:C}=_chunkFGB5FJCIjs.k.call(void 0, _chunkFGB5FJCIjs.j.publicApi.getPublicOrderDetails,{projectId:_nullishCoalesce(i, () => ("")),orderId:e,email:d||void 0,accessToken:o},{enabled:!!e}),s=_optionalChain([k, 'optionalAccess', _65 => _65.result, 'access', _66 => _66.case])==="order"?k.result.value:null,P=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _67 => _67.isVerified]), () => (!1)),R=s!=null;_react3.useEffect.call(void 0, ()=>{R&&c.track("panel_order_viewed",{},{order_ref:null})},[c,R]);let q=()=>{C(),g(!1)},F={"--button-background-color":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _68 => _68.colors, 'optionalAccess', _69 => _69.brand]), () => ("#000000")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _70 => _70.colors, 'optionalAccess', _71 => _71.brandDark]), () => ("#ffffff")),"--button-text-color":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _72 => _72.colors, 'optionalAccess', _73 => _73.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _74 => _74.colors, 'optionalAccess', _75 => _75.brand]), () => ("#000000"))};return u?_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..."})]})}):v||!s?_jsxruntime.jsx.call(void 0, "div",{className:"flex min-h-screen items-center justify-center",children:_jsxruntime.jsx.call(void 0, ue,{className:"w-full max-w-md",children:_jsxruntime.jsx.call(void 0, me,{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:F,children:_jsxruntime.jsxs.call(void 0, "div",{className:"w-full px-4",children:[n&&_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{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', _76 => _76.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: #",s.orderId]})]})]}),_jsxruntime.jsxs.call(void 0, ue,{className:"mb-6",children:[_jsxruntime.jsx.call(void 0, be,{children:_jsxruntime.jsxs.call(void 0, ve,{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, me,{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, Co,{status:s.status}),s.processingStatus&&_jsxruntime.jsxs.call(void 0, "span",{className:"text-sm text-neutral-600",children:["\xB7 ",s.processingStatus]})]}),_jsxruntime.jsxs.call(void 0, "p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",br(s.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:s.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:s.customerEmail})]}),s.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:s.customerPhone})]})]})]}),!P&&_jsxruntime.jsx.call(void 0, "div",{className:"border-t pt-4",children:_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{onClick:()=>g(!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, ue,{className:"mb-6",children:[_jsxruntime.jsx.call(void 0, be,{children:_jsxruntime.jsx.call(void 0, ve,{children:"Produkty"})}),_jsxruntime.jsxs.call(void 0, me,{className:"space-y-6",children:[_jsxruntime.jsx.call(void 0, "div",{className:"space-y-4",children:s.items.map((A,E)=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-4",children:[A.imageUrl&&_jsxruntime.jsx.call(void 0, "img",{src:A.imageUrl,alt:A.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:A.name}),_jsxruntime.jsxs.call(void 0, "p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",A.quantity]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"text-right",children:_jsxruntime.jsx.call(void 0, "p",{className:"font-medium",children:vr(Number(A.price),A.currency)})})]},E))}),(s.deliveryAddress||s.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:[s.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:s.deliveryAddress})]}),s.deliveryMethod&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Metoda:"})," ",s.deliveryMethod]}),s.trackingNumber&&P&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Tracking:"})," ",s.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:vr(Number(s.totalAmount),s.currency)})]})})]})]}),_jsxruntime.jsxs.call(void 0, ue,{children:[_jsxruntime.jsx.call(void 0, be,{children:_jsxruntime.jsxs.call(void 0, ve,{children:["Komentarze ",s.commentCount>0&&`(${s.commentCount})`]})}),_jsxruntime.jsxs.call(void 0, me,{children:[s.comments.length>0?_jsxruntime.jsx.call(void 0, "div",{className:"space-y-4",children:s.comments.map(A=>_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:A.authorName||"System"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs text-neutral-500",children:br(A.createdAt)}),A.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:A.message})]},A.id))}):_jsxruntime.jsx.call(void 0, "p",{className:"text-neutral-600",children:"Brak komentarzy."}),P?_jsxruntime.jsx.call(void 0, No,{orderID:s.orderId,email:d}):_jsxruntime.jsx.call(void 0, "div",{className:"mt-4",children:_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{onClick:()=>g(!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"]})})]})]}),m&&_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, ue,{className:"w-full max-w-md",children:[_jsxruntime.jsx.call(void 0, be,{children:_jsxruntime.jsx.call(void 0, ve,{children:"Zweryfikuj sw\xF3j email"})}),_jsxruntime.jsxs.call(void 0, me,{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, _chunkH4WAQQVOjs.a,{htmlFor:"verify-email",children:"Adres email"}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.r,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:d,onChange:A=>l(A.target.value)})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{variant:"outline",onClick:()=>g(!1),className:"flex-1",children:"Anuluj"}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{onClick:q,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function So(e){return _jsxruntime.jsx.call(void 0, Io,{...e})}var Zt=So;var To=({returnsAppearance:e,returnsTexts:t,analytics:n}={})=>{let{projectID:o,theme:r,loginURL:a,host:i}=_chunk7DG4UPWEjs.j.call(void 0, ),c=_chunkMG6VV5J2js.n.call(void 0, o,n,"panel"),d=_chunk7DG4UPWEjs.k.call(void 0, o,i),l=_chunk7DG4UPWEjs.m.call(void 0, o,i),{mutateAsync:m}=_chunkFGB5FJCIjs.l.call(void 0, _chunkFGB5FJCIjs.j.publicApi.userPanelLogout);async function g(){d&&await m({accessToken:d}),typeof window<"u"&&(_chunk7DG4UPWEjs.n.call(void 0, o,i),window.location.reload())}let[k]=_react.useAutoAnimate.call(void 0, ),u=D=>["products","notifications","profile","plans","orders","order-details","returns","return-details","course"].includes(D),[v,C]=_n({product:void 0,state:"products",orderId:void 0,returnId:void 0,course:void 0,item:void 0}),[s,P]=_react3.useState.call(void 0, u(v.state)?v.state:"products"),R=D=>{C({state:"order-details",orderId:D}),P("order-details")},q=()=>{C({state:"orders",orderId:void 0}),P("orders")},F=D=>C({orderId:void 0,returnId:void 0,course:void 0,item:void 0,...D}),A=D=>{C({state:"course",course:D,item:void 0,product:void 0}),P("course")},E=()=>{C({state:"products",course:void 0,item:void 0,product:void 0}),P("products")};_react3.useEffect.call(void 0, ()=>{u(v.state)&&(v.state==="course"||s==="course")&&P(v.state)},[v.state]);let z={"--button-background-color":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _77 => _77.colors, 'optionalAccess', _78 => _78.brand]), () => ("#000000")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _79 => _79.colors, 'optionalAccess', _80 => _80.brandDark]), () => ("#ffffff")),"--button-text-color":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _81 => _81.colors, 'optionalAccess', _82 => _82.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _83 => _83.colors, 'optionalAccess', _84 => _84.brand]), () => ("#000000"))};return _react3.useEffect.call(void 0, ()=>{if(d==null||d.length===0){window.location.href=_nullishCoalesce(a, () => ("/panel/login"));return}},[]),_react3.useEffect.call(void 0, ()=>{if(d==null||d.length===0){window.location.href=_nullishCoalesce(a, () => ("/panel/login"));return}},[s]),_react3.useEffect.call(void 0, ()=>{if(typeof window>"u"||window.parent!==window||!d)return;let D=Qe(window.location.search);D&&Xe(D);let $=_nullishCoalesce(D, () => (Me()));$&&(window.location.href=Ue($,d))},[d]),_jsxruntime.jsx.call(void 0, _chunkMG6VV5J2js.l,{value:c,children:_jsxruntime.jsxs.call(void 0, "div",{ref:k,className:"font-inter relative min-h-screen w-screen bg-beige-100 text-black dark:bg-black dark:text-white md:flex",children:[_jsxruntime.jsx.call(void 0, fr,{activeScreen:s,setActiveScreen:P,setParams:F,styles:z,theme:r,logout:g}),_jsxruntime.jsxs.call(void 0, "main",{className:"flex h-[calc(100vh-80px)] flex-col overflow-y-auto w-full p-5 md:h-screen",children:[s==="products"&&_jsxruntime.jsx.call(void 0, ur,{projectID:_nullishCoalesce(o, () => ("")),accessToken:d,loginURL:_nullishCoalesce(a, () => ("/panel/login")),styles:z,activeScreen:s,params:v,setParams:C,openCourse:A}),s==="course"&&v.course&&d&&_jsxruntime.jsx.call(void 0, Vt,{accessId:v.course,accessToken:d,theme:r,itemId:v.item,onItemChange:D=>C({item:D}),onBack:E}),s==="notifications"&&_jsxruntime.jsx.call(void 0, Bn,{}),s==="plans"&&_jsxruntime.jsx.call(void 0, Jn,{projectID:_nullishCoalesce(o, () => (""))}),s==="orders"&&_jsxruntime.jsx.call(void 0, Kn,{projectID:_nullishCoalesce(o, () => ("")),accessToken:_nullishCoalesce(d, () => ("")),openOrderDetails:R}),s==="order-details"&&v.orderId&&_jsxruntime.jsx.call(void 0, Zt,{orderID:v.orderId,onBack:q}),(s==="returns"||s==="return-details")&&d&&_jsxruntime.jsx.call(void 0, Ht,{projectID:_nullishCoalesce(o, () => ("")),host:i,accessToken:d,loginURL:_nullishCoalesce(a, () => ("/panel/login")),appearance:zn(e,_optionalChain([r, 'optionalAccess', _85 => _85.colors, 'optionalAccess', _86 => _86.brand])),texts:t,screen:s,params:v,setParams:C,setActiveScreen:P}),s==="profile"&&_jsxruntime.jsx.call(void 0, yr,{email:l,logout:g})]})]})})},Do= exports.q =To;var _reactquery = require('@tanstack/react-query');var _connect = require('@connectrpc/connect');var _connectweb = require('@connectrpc/connect-web');var le;(o=>{function e(r){return _connect.createClient.call(void 0, _chunkFGB5FJCIjs.f,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:[_chunkDY2S42Q6js.b]}),t.set(r,a)),a}})(le = exports.a||={});var _zod = require('zod'); var _zod2 = _interopRequireDefault(_zod);function _(e,t=2){return+(Math.round(+(e+"e+"+t))+"e-"+t)}function Nr(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 Vd=_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 Jt(e){typeof window>"u"||(Oo(e),Uo(e),jo(e))}function Oo(e){try{typeof window.dataLayer>"u"&&(window.dataLayer=[]);let t=Mo(e);window.dataLayer.push(t)}catch(t){console.warn("cannot send google analytics event",t)}}function Mo(e){let t=_nullishCoalesce(_nullishCoalesce(e.value, () => (_optionalChain([e, 'access', _87 => _87.items, 'optionalAccess', _88 => _88.reduce, 'call', _89 => _89((a,i)=>a+(i.price||0)*(i.quantity||1),0)]))), () => (0)),n=_optionalChain([e, 'access', _90 => _90.items, 'optionalAccess', _91 => _91.map, 'call', _92 => _92(a=>({item_id:a.id,item_name:a.name||a.id,price:_((a.price||0)/100,2),quantity:a.quantity||1}))]),o={currency:e.currency||"PLN",value:_(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 Uo(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 jo(e){try{if(typeof window.ttq>"u")return;let t=_o(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 _o(e){let t=_nullishCoalesce(_nullishCoalesce(e.value, () => (_optionalChain([e, 'access', _93 => _93.items, 'optionalAccess', _94 => _94.reduce, 'call', _95 => _95((a,i)=>a+(i.price||0)*(i.quantity||1),0)]))), () => (0)),n=_optionalChain([e, 'access', _96 => _96.items, 'optionalAccess', _97 => _97.map, 'call', _98 => _98(a=>({content_id:a.id,content_type:"product",content_name:a.name||a.id,quantity:a.quantity||1,price:_((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:_(t/100,2)});let o={currency:e.currency||"PLN",value:_(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 Ir(e){let{items:t,googlePayConfig:n,checkout:o,result:r,cartRequiresShipping:a}=e,i=_nullishCoalesce(e.locale, () => (_chunkDY2S42Q6js.m.call(void 0, )));if(r.totalAmount==null)return;let c=[];return a&&(c.push("SHIPPING_ADDRESS"),c.push("SHIPPING_OPTION")),{apiVersion:2,apiVersionMinor:0,callbackIntents:c,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+` - ${Nr(l.amount,r.currency)}`,description:_nullishCoalesce(l.description, () => (""))})),defaultSelectedOptionId:r.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:n.merchantId+"",merchantName:n.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:_chunkDY2S42Q6js.j.call(void 0, "paymentForCart",i,e.texts),totalPrice:`${_(r.totalAmount/100,2)}`,currencyCode:r.currency,countryCode:r.country,checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",displayItems:zo(t,r.methods,_nullishCoalesce(r.selectedDeliveryMethod, () => ((r.methods.length>0?r.methods[0].id:void 0))),o.couponCode,r.couponValue,_chunkDY2S42Q6js.j.call(void 0, "coupon",i,e.texts))}}}function zo(e,t,n,o,r,a="Coupon"){let i=[],c=0;for(let l of e){if(l.details==null)continue;let m=_nullishCoalesce(_optionalChain([l, 'access', _99 => _99.details, 'access', _100 => _100.pricing, 'optionalAccess', _101 => _101.effectivePrice]), () => (l.details.price));c+=m*l.quantity,i.push({label:l.details.name+" x "+l.quantity,price:`${_(m/100,2)}`,type:"LINE_ITEM",status:"FINAL"})}let d=t.find(l=>l.id===n);return d!=null&&i.push({label:d.name,price:`${_(d.amount/100,2)}`,type:"SHIPPING_OPTION",status:"FINAL"}),o!=null&&r!=null&&i.push({label:`${a} ${o}`,price:`${_(r/100,2)}`,type:"DISCOUNT",status:"FINAL"}),c>0&&i.push({label:"Subtotal",price:`${_(c/100,2)}`,type:"SUBTOTAL",status:"FINAL"}),i}function Fe(e,t){return`${_chunkDY2S42Q6js.f}/api/integrations/${e}/public-commerce${t}`}function ke(e){return typeof e=="object"&&e!=null&&"ERR"in e}function H(e,t,n){return{ERR:!0,error:e,type:t,data:n}}function Sr(e,t){return _optionalChain([t, 'optionalAccess', _102 => _102.find, 'call', _103 => _103(n=>n.id===e||(_nullishCoalesce(_optionalChain([n, 'access', _104 => _104.variants, 'optionalAccess', _105 => _105.some, 'call', _106 => _106(o=>o.id===e)]), () => (!1))))])}function Rr(e,t){let n=new Set(t.map(o=>o.productID));return Array.from(new Set(e.filter(o=>!n.has(o))))}function Ar(e,t){let n=_optionalChain([e, 'optionalAccess', _107 => _107.trim, 'call', _108 => _108()]);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 (e6){return}}var _zustand = require('zustand');var Be=_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 vt=_react3.createContext.call(void 0, {});function sl({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, vt.Provider,{value:o,children:n})}function Dr(){return _react3.useContext.call(void 0, vt)}function cl(e){let{texts:t,locale:n}=_react3.useContext.call(void 0, vt);return _chunkDY2S42Q6js.j.call(void 0, e,_nullishCoalesce(n, () => (_chunkDY2S42Q6js.m.call(void 0, ))),t)}function dl(){let{texts:e,locale:t}=_react3.useContext.call(void 0, vt),n=_nullishCoalesce(t, () => (_chunkDY2S42Q6js.m.call(void 0, )));return _react3.useMemo.call(void 0, ()=>o=>_chunkDY2S42Q6js.j.call(void 0, o,n,e),[n,e])}var Xt="bitsnap-pending-order";function Or(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 Ho=60*1e3;function Mr(e,t=Date.now,n=Ho){let o;return r=>{let a=`${r.orderId}:${r.ts}`,i=t();return _optionalChain([o, 'optionalAccess', _109 => _109.key])===a&&i-o.at<n?Promise.reject(new Error("pending order was asked about recently")):(o={key:a,at:i},e(r))}}function $o(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 (e7){return}}function Go(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 (e8){return!1}}function Vo(e,t=Date.now(),n={}){if(Go(e.url))return;let o=$o(e.url),r=_nullishCoalesce(Lr(e.orderId), () => (_optionalChain([o, 'optionalAccess', _110 => _110.orderId]))),a=_nullishCoalesce(Lr(e.projectId), () => (_optionalChain([o, 'optionalAccess', _111 => _111.projectId])));if(!(r==null||a==null))return{orderId:r,projectId:a,...n.cartProjectId!=null?{cartProjectId:n.cartProjectId}:{},lines:_nullishCoalesce(n.lines, () => ([])),ts:t}}function ml(e,t={}){let n=Vo(e,t.now,t);return n!=null&&Ko(n,t.storage)}function Lr(e){return e!=null&&e.length>0?e:void 0}function wt(){try{return typeof localStorage>"u"?void 0:localStorage}catch (e9){return}}function Ko(e,t=wt()){try{return _optionalChain([t, 'optionalAccess', _112 => _112.setItem, 'call', _113 => _113(Xt,JSON.stringify(e))]),t!=null}catch (e10){return!1}}function Er(e=wt()){try{let t=_optionalChain([e, 'optionalAccess', _114 => _114.getItem, 'call', _115 => _115(Xt)]);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:c}=n;return{orderId:o,projectId:r,...typeof a=="string"?{cartProjectId:a}:{},lines:Array.isArray(c)?c.filter(d=>typeof _optionalChain([d, 'optionalAccess', _116 => _116.id])=="string"&&typeof d.quantity=="number"):[],ts:i}}}catch (e11){}Qt(e)}function Qt(e=wt()){try{_optionalChain([e, 'optionalAccess', _117 => _117.removeItem, 'call', _118 => _118(Xt)])}catch (e12){}}function Ur(e){let t=_nullishCoalesce(_optionalChain([e, 'access', _119 => _119.details, 'optionalAccess', _120 => _120.status]), () => (Wo(_optionalChain([e, 'access', _121 => _121.details, 'optionalAccess', _122 => _122.$unknown]))));return t==="created"||t==="placed"||t==="paid"||t==="canceled"?t:"unknown"}function Wo(e){if(Array.isArray(e)){for(let t of e)if(_optionalChain([t, 'optionalAccess', _123 => _123.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 (e13){return}}}}async function jr(e){let t=_nullishCoalesce(e.storage, () => (wt())),n=Er(t);if(n==null)return"none";if((_nullishCoalesce(e.now, () => (Date.now)))()-n.ts>864e5)return Qt(t),"expired";if(e.projectId!=null&&n.cartProjectId!=null&&n.cartProjectId!==e.projectId)return"pending";let r;try{r=await e.fetchStatus(n)}catch (e14){return"pending"}let a=Er(t);if(_optionalChain([a, 'optionalAccess', _124 => _124.orderId])!==n.orderId||a.ts!==n.ts)return"pending";if(r==="paid"||r==="placed"){try{await e.removeLines(n.lines)}catch (e15){return"pending"}return Qt(t),"paid"}return"pending"}var ei="__m_a",Hr=_react3.createContext.call(void 0, void 0),rn= exports.M =void 0;function zl(e){_chunk7DG4UPWEjs.a.call(void 0, {projectID:e}),rn= exports.M =e,typeof window<"u"&&_chunk7DG4UPWEjs.g.call(void 0, [window.location.origin])}function Ge(){return _nullishCoalesce(_nullishCoalesce(rn, () => (_optionalChain([document, 'access', _125 => _125.querySelector, 'call', _126 => _126('script[data-id][data-name="internal-cart"]'), 'optionalAccess', _127 => _127.getAttribute, 'call', _128 => _128("data-id")]))), () => (void 0))}function ti(){return _nullishCoalesce(_optionalChain([document, 'access', _129 => _129.querySelector, 'call', _130 => _130('script[data-id][data-name="internal-cart"]'), 'optionalAccess', _131 => _131.getAttribute, 'call', _132 => _132("data-custom-host")]), () => (void 0))}var ni=({children:e,locale:t})=>{let[n]=_react3.useState.call(void 0, ()=>new _reactquery.QueryClient),o=Dr();_react3.useEffect.call(void 0, ()=>{$e()},[]);let r=Ge();if(_react3.useEffect.call(void 0, ()=>{if(r==null)return;let i=()=>{oi(r).then(d=>{d==="paid"&&n.invalidateQueries({queryKey:["cart"]})})},c=()=>{document.visibilityState==="visible"&&i()};return i(),window.addEventListener("pageshow",i),document.addEventListener("visibilitychange",c),()=>{window.removeEventListener("pageshow",i),document.removeEventListener("visibilitychange",c)}},[r,n]),r==null)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{});let a=on(r,_nullishCoalesce(t, () => (o.locale)),o.texts);return _jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:n,children:_jsxruntime.jsx.call(void 0, Hr.Provider,{value:a,children:e})})},en,ri=Mr(async e=>Ur(await le.get(_chunkDY2S42Q6js.f).getOrder({id:e.orderId,projectId:e.projectId})));function ql(){let{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:o}=_nullishCoalesce(L(), () => (kt));return{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:o}}function Fl(){return(_nullishCoalesce(_optionalChain([L, 'call', _133 => _133(), 'optionalAccess', _134 => _134.products]), () => ([]))).map(e=>({id:e.id,quantity:e.quantity}))}function ai(e){let t=L();Q({...t,products:Or(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _135 => _135.products]), () => ([])),e)}),$e()}function oi(e){return en??=jr({projectId:e,fetchStatus:ri,removeLines:ai}).catch(t=>{console.warn("cannot check the pending order",t)}).finally(()=>{en=void 0}),en}var He=async(e,t)=>{let n=[];_optionalChain([t, 'optionalAccess', _136 => _136.items])!=null&&t.items.length>0?n=t.items:n=_nullishCoalesce(_optionalChain([L, 'call', _137 => _137(), 'optionalAccess', _138 => _138.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', _139 => _139.locale]), () => (_chunkDY2S42Q6js.m.call(void 0, ))));let a;try{let i=await fetch(_chunkDY2S42Q6js.c.call(void 0, Fe(e,`/products?${r.toString()}`)),{method:"GET"});if(i.status!=200)return H("products-load-failed","internal");a=await i.json()}catch(i){return console.warn("cannot load the products of the cart",i),H("products-load-failed","internal")}return n.flatMap(i=>{let c=Sr(i.productID,a.result);return c==null?[]:[{...i,details:ui(i.productID,c),catalogProductID:c.id}]})},Bl= exports.S =()=>{let e=_react3.useContext.call(void 0, Hr);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},Hl= exports.T =ni,ii=_zod2.default.object({isAvailable:_zod2.default.boolean(),merchantId:_zod2.default.string(),merchantName:_zod2.default.string(),gateway:_zod2.default.string(),gatewayId:_zod2.default.string()}),si=_zod2.default.object({id:_zod2.default.string(),productID:_zod2.default.string(),quantity:_zod2.default.number(),priceVersion:_zod2.default.string().optional(),metadata:_zod2.default.record(_zod2.default.string(),_zod2.default.string().optional()).optional(),url:_zod2.default.string().optional()}),ci=_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(si).optional(),googlePayConfig:ii.optional()}),kt={country:void 0,couponCode:void 0,email:void 0,selectedDeliveryMethod:void 0,postalCode:void 0,products:[],googlePayConfig:void 0},$r="checkout";function L(){try{let e=localStorage.getItem($r);return e==null?kt:ci.parse(JSON.parse(e))}catch (e16){return kt}}async function zr(e,t){let n=await He(e,{items:t.map((a,i)=>({...a,id:`price-check-${i}`}))});if(ke(n))return n;let o=Rr(t.map(a=>a.productID),n);if(o.length>0)return H("item-ids-not-found","notFound",o);let r=L();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', _140 => _140.find, 'call', _141 => _141(i=>i.productID===a.productID), 'optionalAccess', _142 => _142.details, 'optionalAccess', _143 => _143.pricing, 'optionalAccess', _144 => _144.priceVersion]),metadata:a.metadata,url:Ar(a.url,typeof window<"u"?window.location.href:void 0)}))),di(t,n),Jt({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"))}))}),Q(r),$e()}function di(e,t){for(let n of e)try{let o=t.find(c=>c.productID===n.productID),r=_nullishCoalesce(_nullishCoalesce(_optionalChain([o, 'optionalAccess', _145 => _145.details, 'optionalAccess', _146 => _146.pricing, 'optionalAccess', _147 => _147.effectivePrice]), () => (_optionalChain([o, 'optionalAccess', _148 => _148.details, 'optionalAccess', _149 => _149.price]))), () => (n.price)),a=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _150 => _150.details, 'optionalAccess', _151 => _151.currency]), () => (n.currency));if(r==null||a==null)continue;let i=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _152 => _152.catalogProductID]), () => (n.productID));(_nullishCoalesce(n.analytics, () => (_chunkMG6VV5J2js.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 (e17){}}function qr(e){let t=L(),n={...t,products:_optionalChain([t, 'optionalAccess', _153 => _153.products, 'optionalAccess', _154 => _154.filter, 'call', _155 => _155(o=>!e.includes(o.productID)&&!e.includes(o.id))])};Jt({event:"removeFromCart",items:e.map(o=>({id:o,name:"",price:0,quantity:1,currency:"PLN"}))}),Q(n),$e()}function Q(e){localStorage.setItem($r,JSON.stringify(e))}function Fr(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', _156 => _156.metadata, 'optionalAccess', _157 => _157[a]]);i!=null&&(o[a]=i)}),o),{});return{items:e.products.map(o=>({id:o.productID,quantity:o.quantity,priceVersion:o.priceVersion})),askForNote:!0,countries:e.country?[e.country]:void 0,metadata:n,locale:t}}var on=(e,t=_chunkDY2S42Q6js.m.call(void 0, ),n)=>{let o=ti();return o!=null&&_chunkDY2S42Q6js.g.call(void 0, o),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await le.get(_chunkDY2S42Q6js.f).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 li(e);if(_optionalChain([a, 'optionalAccess', _158 => _158.isAvailable])!=!0)return{isAvailable:!1};let i=L();if(i==null)return console.log("checkout is null"),{isAvailable:!1};let c=await He(e,{locale:t,items:r.items.map(g=>({id:Math.random().toString(36).substring(7),quantity:g.quantity,metadata:g.metadata,productID:g.productID}))});if(ke(c))return{isAvailable:!1};let d=await le.get(_chunkDY2S42Q6js.f).getPreOrderDetails({items:c.map(g=>_protobuf.create.call(void 0, _chunkFGB5FJCIjs.c,{id:g.productID,quantity:g.quantity})),projectId:e,postCode:i.postalCode,couponCode:i.couponCode,countryCode:i.country,selectedDeliveryMethod:i.selectedDeliveryMethod});if(d.totalAmount==null)return{isAvailable:!1};let l=c.find(g=>_optionalChain([g, 'access', _159 => _159.details, 'optionalAccess', _160 => _160.isDeliverable])==!0)!=null,m=await Ir({items:c,googlePayConfig:a,checkout:i,cartRequiresShipping:l,result:d,locale:t,texts:n});return m==null?{isAvailable:!1}:{isAvailable:!0,config:m}}catch(a){return console.error("Error resolving Google Pay configuration",a),{isAvailable:!1}}},async clearCart(){let r=structuredClone(kt);r.country=_optionalChain([L, 'call', _161 => _161(), 'optionalAccess', _162 => _162.country]),Q(r),$e()},async getAvailableCountries(){let r=await fetch(_chunkDY2S42Q6js.c.call(void 0, Fe(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 H(a.toString(),"internal")}},async getCountry(){let r=_optionalChain([L, 'call', _163 => _163(), 'optionalAccess', _164 => _164.country]);if(r==null){r="PL";let a=L();a.country=r,Q(a)}return r},async getNumberOfElementsInCart(){return _nullishCoalesce(_optionalChain([L, 'call', _165 => _165(), 'optionalAccess', _166 => _166.products, 'optionalAccess', _167 => _167.reduce, 'call', _168 => _168((r,a)=>r+a.quantity,0)]), () => (0))},async getProducts(){return await He(e,{locale:t})},async removeProductFromCart(r){return qr([r.id])},async setCountry(r){let a=L();a.country=r,Q(a)},async setCouponCodeIfPossible(r){let a=L();a.couponCode=r,Q(a)},async setPostalCode(r){let a=L();a.postalCode=r,Q(a)},async setDeliveryMethod(r){let a=L();a.selectedDeliveryMethod=r,Q(a)},async setEmail(r){let a=L();a.email=r,Q(a)},async addProduct(r){return await zr(e,[r])},async updateQuantity(r){let a=L();a.products=_optionalChain([a, 'access', _169 => _169.products, 'optionalAccess', _170 => _170.map, 'call', _171 => _171(i=>(i.id===r.id&&(i.quantity=r.quantity),i))]),Q(a),$e()},async getPaymentMethodChoice(){let r=Fr(L(),t);return r==null?null:Br(r)},async redirectToNextStep(r){let a=Fr(L(),t);if(a==null)return H("cart-is-empty","badInput");_optionalChain([r, 'optionalAccess', _172 => _172.paymentMethod])!=null&&(a.paymentMethod=r.paymentMethod);let i=await nn(a);return ke(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=an(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:ei,name:"",required:!0,answer:!0}]);let i=await nn(a);return ke(i)?i:{url:i.url}},async getApplePayPreview(r){let a=L();try{let i=await le.get(_chunkDY2S42Q6js.f).getPreOrderDetails({items:r.items.map(c=>_protobuf.create.call(void 0, _chunkFGB5FJCIjs.c,{id:c.productID,quantity:c.quantity})),projectId:e,postCode:a.postalCode,couponCode:a.couponCode,countryCode:a.country,selectedDeliveryMethod:a.selectedDeliveryMethod});return i.totalAmount==null||i.currency.length===0?H("pre-order-unavailable","internal"):{countryCode:i.country||a.country||"PL",currencyCode:i.currency,totalAmount:`${_(i.totalAmount/100,2)}`}}catch(i){return console.warn("cannot load the Apple Pay preview",i),H("pre-order-unavailable","internal")}},async completeApplePayPayment(r){let a=L();if(a==null)return H("Checkout not found");let i=await He(e,{locale:t});if(ke(i))return i;try{let c=_optionalChain([r, 'access', _173 => _173.shippingContact, 'optionalAccess', _174 => _174.givenName]);_optionalChain([r, 'access', _175 => _175.shippingContact, 'optionalAccess', _176 => _176.familyName])!=null?c+=" "+_optionalChain([r, 'access', _177 => _177.shippingContact, 'optionalAccess', _178 => _178.familyName]):_optionalChain([r, 'access', _179 => _179.billingContact, 'optionalAccess', _180 => _180.familyName])!=null&&(c+=" "+_optionalChain([r, 'access', _181 => _181.billingContact, 'optionalAccess', _182 => _182.familyName]));let d={},l=xt();l!=null&&(d.ref=l);let m=await le.get(_chunkDY2S42Q6js.f).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, _chunkFGB5FJCIjs.d,{items:i.map(g=>({id:g.productID,quantity:g.quantity})),couponCode:a.couponCode,email:_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([r, 'access', _183 => _183.shippingContact, 'optionalAccess', _184 => _184.emailAddress]), () => (_optionalChain([r, 'access', _185 => _185.billingContact, 'optionalAccess', _186 => _186.emailAddress]))), () => (a.email)), () => (void 0)),phone:_nullishCoalesce(_nullishCoalesce(_optionalChain([r, 'access', _187 => _187.shippingContact, 'optionalAccess', _188 => _188.phoneNumber]), () => (_optionalChain([r, 'access', _189 => _189.billingContact, 'optionalAccess', _190 => _190.phoneNumber]))), () => (void 0)),selectedDeliveryMethod:a.selectedDeliveryMethod,postCode:a.postalCode,projectId:e}),shippingAddress:_protobuf.create.call(void 0, _chunkFGB5FJCIjs.a,{line1:_nullishCoalesce(_optionalChain([r, 'access', _191 => _191.shippingContact, 'optionalAccess', _192 => _192.addressLines, 'optionalAccess', _193 => _193[0]]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _194 => _194.shippingContact, 'optionalAccess', _195 => _195.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _196 => _196.shippingContact, 'optionalAccess', _197 => _197.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _198 => _198.shippingContact, 'optionalAccess', _199 => _199.postalCode]), () => ("")),name:c}),billingAddress:_protobuf.create.call(void 0, _chunkFGB5FJCIjs.b,{name:_nullishCoalesce(_optionalChain([r, 'access', _200 => _200.billingContact, 'optionalAccess', _201 => _201.givenName]), () => (" "+(_nullishCoalesce(_optionalChain([r, 'access', _202 => _202.billingContact, 'optionalAccess', _203 => _203.familyName]), () => (""))))),line1:_nullishCoalesce(_optionalChain([r, 'access', _204 => _204.billingContact, 'optionalAccess', _205 => _205.addressLines, 'optionalAccess', _206 => _206[0]]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _207 => _207.billingContact, 'optionalAccess', _208 => _208.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _209 => _209.billingContact, 'optionalAccess', _210 => _210.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _211 => _211.billingContact, 'optionalAccess', _212 => _212.postalCode]), () => (""))}),metadata:Object.keys(d).length>0?JSON.stringify(d):void 0});return{isSuccess:m.isSuccess,redirectURL:m.redirectUrl}}catch(c){return console.error(c),H("Failed to authorize payment")}},async completeGooglePayPayment(r){let a=L();if(a==null)return H("Checkout not found");let i=await He(e,{locale:t});if(ke(i))return i;try{let c=_optionalChain([r, 'access', _213 => _213.paymentData, 'access', _214 => _214.shippingAddress, 'optionalAccess', _215 => _215.name]),d={},l=xt();l!=null&&(d.ref=l);let m=await le.get(_chunkDY2S42Q6js.f).authorizeOneClickPayment({gateway:1,paymentData:r.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:r.paymentData.paymentMethodData.type,transactionIdentifier:"",order:_protobuf.create.call(void 0, _chunkFGB5FJCIjs.d,{items:i.map(g=>({id:g.productID,quantity:g.quantity})),couponCode:a.couponCode,email:_nullishCoalesce(r.paymentData.email, () => (void 0)),phone:_nullishCoalesce(_optionalChain([r, 'access', _216 => _216.paymentData, 'access', _217 => _217.shippingAddress, 'optionalAccess', _218 => _218.phoneNumber]), () => (void 0)),selectedDeliveryMethod:_nullishCoalesce(_optionalChain([r, 'access', _219 => _219.paymentData, 'access', _220 => _220.shippingOptionData, 'optionalAccess', _221 => _221.id]), () => (a.selectedDeliveryMethod)),postCode:_optionalChain([r, 'access', _222 => _222.paymentData, 'access', _223 => _223.shippingAddress, 'optionalAccess', _224 => _224.postalCode]),projectId:e}),shippingAddress:_protobuf.create.call(void 0, _chunkFGB5FJCIjs.a,{line1:_nullishCoalesce(_optionalChain([r, 'access', _225 => _225.paymentData, 'access', _226 => _226.shippingAddress, 'optionalAccess', _227 => _227.address1]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _228 => _228.paymentData, 'access', _229 => _229.shippingAddress, 'optionalAccess', _230 => _230.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _231 => _231.paymentData, 'access', _232 => _232.shippingAddress, 'optionalAccess', _233 => _233.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _234 => _234.paymentData, 'access', _235 => _235.shippingAddress, 'optionalAccess', _236 => _236.postalCode]), () => ("")),name:c}),billingAddress:_protobuf.create.call(void 0, _chunkFGB5FJCIjs.b,{name:_optionalChain([r, 'access', _237 => _237.paymentData, 'access', _238 => _238.paymentMethodData, 'access', _239 => _239.info, 'optionalAccess', _240 => _240.billingAddress, 'optionalAccess', _241 => _241.name]),line1:_nullishCoalesce(_optionalChain([r, 'access', _242 => _242.paymentData, 'access', _243 => _243.paymentMethodData, 'access', _244 => _244.info, 'optionalAccess', _245 => _245.billingAddress, 'optionalAccess', _246 => _246.address1]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _247 => _247.paymentData, 'access', _248 => _248.paymentMethodData, 'access', _249 => _249.info, 'optionalAccess', _250 => _250.billingAddress, 'optionalAccess', _251 => _251.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _252 => _252.paymentData, 'access', _253 => _253.paymentMethodData, 'access', _254 => _254.info, 'optionalAccess', _255 => _255.billingAddress, 'optionalAccess', _256 => _256.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _257 => _257.paymentData, 'access', _258 => _258.paymentMethodData, 'access', _259 => _259.info, 'optionalAccess', _260 => _260.billingAddress, 'optionalAccess', _261 => _261.postalCode]), () => (""))}),metadata:Object.keys(d).length>0?JSON.stringify(d):void 0});return{isSuccess:m.isSuccess,redirectURL:m.redirectUrl}}catch(c){return console.error(c),H("Failed to authorize payment")}return{isSuccess:!0}},async getApplePayPaymentRequest(r){let a=L();if(a==null)return H("Checkout not found");r&&r.expectedItems!=null&&r.expectedItems.length>0&&(a.products&&qr(a.products.map(l=>l.productID)),await zr(e,r.expectedItems));let i=await He(e,{locale:t});if(ke(i))return i;let c=await le.get(_chunkDY2S42Q6js.f).getPreOrderDetails({items:i.map(l=>_protobuf.create.call(void 0, _chunkFGB5FJCIjs.c,{id:l.productID,quantity:l.quantity})),projectId:e,postCode:a.postalCode,couponCode:a.couponCode,countryCode:a.country,selectedDeliveryMethod:a.selectedDeliveryMethod}),d=i.map(l=>({amount:`${_(l.quantity*(_nullishCoalesce(_nullishCoalesce(_optionalChain([l, 'access', _262 => _262.details, 'optionalAccess', _263 => _263.pricing, 'optionalAccess', _264 => _264.effectivePrice]), () => (_optionalChain([l, 'access', _265 => _265.details, 'optionalAccess', _266 => _266.price]))), () => (0)))/100,2)}`,label:_optionalChain([l, 'access', _267 => _267.details, 'optionalAccess', _268 => _268.name])+" - "+l.quantity,type:"final"}));if(c.selectedDeliveryMethod!=null){let l=c.methods.find(m=>m.id==c.selectedDeliveryMethod);l!=null&&d.push({amount:`${_(l.amount/100,2)}`,label:l.name,type:"final"})}return c.couponCode!=null&&c.couponValue!=null&&d.push({amount:`-${_(c.couponValue/100,2)}`,label:c.couponCode,type:"final"}),{countryCode:c.country||a.country||"PL",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],total:{amount:`${_((_nullishCoalesce(c.totalAmount, () => (0)))/100,2)}`,label:_chunkDY2S42Q6js.j.call(void 0, "paymentForCart",t,n),type:"final"},shippingMethods:c.methods.map(l=>({amount:`${_(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:d,currencyCode:c.currency||_optionalChain([i, 'access', _269 => _269[0], 'optionalAccess', _270 => _270.details, 'optionalAccess', _271 => _271.currency])||"PLN"}}}};async function li(e){let t=L();if(_optionalChain([t, 'access', _272 => _272.googlePayConfig, 'optionalAccess', _273 => _273.isAvailable])!=!0){let n=await le.get(_chunkDY2S42Q6js.f).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 Q(t),t.googlePayConfig}function ui(e,t){if(e==t.id){let o=_optionalChain([t, 'access', _274 => _274.variants, 'optionalAccess', _275 => _275.findIndex, 'call', _276 => _276(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', _277 => _277.variants, 'optionalAccess', _278 => _278.find, 'call', _279 => _279(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 $e(){let e=L(),t=0;if(e==null){Be.setState(n=>({...n,numberOfProductsInCart:t}));return}t=_nullishCoalesce(_optionalChain([e, 'access', _280 => _280.products, 'optionalAccess', _281 => _281.reduce, 'call', _282 => _282((n,o)=>n+o.quantity,0)]), () => (0)),Be.setState(n=>({...n,numberOfProductsInCart:t}))}var pi=200,fi= exports.v ="item-ids-not-found",at="internal-error",Gr={"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"},gi=new Set(["internal","invalid-request"]),yi=new Set(["product-not-available","product-not-found"]);function hi(e){return typeof e=="string"&&Object.hasOwn(Gr,e)?Gr[e]:void 0}function Pi(e){return/<\/?[a-z!?][^>]*>/i.test(e)}function bi(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 vi(e){return/Error:/.test(e)||/\n\s+at /.test(e)}function sn(e){let t=e.trim();if(!(t.length===0||t.length>pi||/[\r\n]/.test(t)||Pi(t)||bi(t)||vi(t)))return t}var wi=3;function Ct(e,t=0){if(typeof e=="object"&&e!=null){if(Array.isArray(e)||t>=wi)return{};let n=e,o=Ct(n.error,t+1);if(o.message==null&&n.message!=null){let r=Ct(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?Ct(n,t+1):{}}catch (e18){}return{message:sn(e)}}function xi(e){let t;try{t=JSON.parse(e)}catch (e19){return{code:at,message:sn(e)}}if(typeof t=="string")return{code:at,message:sn(t)};if(typeof t!="object"||t==null)return{code:at};let n=t,{message:o,code:r}=Ct(n.error),a={code:typeof n.code=="string"&&n.code.length>0?n.code:_nullishCoalesce(r, () => (at)),message:o};return Array.isArray(n.itemIds)&&(a.itemIds=n.itemIds.filter(i=>typeof i=="string")),a}function cn(e,t){let{code:n,message:o,itemIds:r}=xi(t),a=r!=null&&r.length>0;if(a&&(n===at||yi.has(n)))return H(fi,"badInput",r);let i={message:o};return a&&(i.itemIds=r),H(n,e>=500?"internal":"badInput",i)}function Wl(e,t){let n=hi(e.error);if(n!=null)return t(n);if(e.type==="internal"||typeof e.error=="string"&&gi.has(e.error))return t("checkoutFailed");let o=_optionalChain([e, 'access', _283 => _283.data, 'optionalAccess', _284 => _284.message]);return typeof o=="string"&&o.length>0?o:t("checkoutFailed")}var ki=["online","manual","cod"],Ci=["bankTransfer","blik"];function Vr(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 Ni(e){if(typeof e!="object"||e==null)return null;let t=e.choice;if(typeof t!="object"||t==null)return null;let n=Vr(t.methods,ki);return n.length<2?null:{methods:n,manualAccountTypes:Vr(t.manualAccountTypes,Ci)}}function Jl(e){if(e==null)return null;let t=e.methods.filter(n=>n!=="cod");return t.length<2?null:{...e,methods:t}}function Yl(e,t){return t!=null&&e.methods.includes(t)?t:e.methods[0]}function Ql(e){let t=e.includes("bankTransfer"),n=e.includes("blik");return n&&!t?"paymentMethodManualBlik":t&&!n?"paymentMethodManualTransfer":"paymentMethodManualBoth"}async function Kr(e,t,n=5e3){let o=typeof AbortController>"u"?void 0:new AbortController,r=setTimeout(()=>_optionalChain([o, 'optionalAccess', _285 => _285.abort, 'call', _286 => _286()]),n);try{let a=await fetch(e,{method:"POST",headers:t.headers,body:t.body,signal:_optionalChain([o, 'optionalAccess', _287 => _287.signal])});return a.ok?Ni(await a.json()):null}catch (e20){return null}finally{clearTimeout(r)}}var Ii;(o=>{async function e(r,a=1,i,c){let d=Ge();if(d==null)throw new Error("No project ID found");let m=await on(d).addProduct({productID:r,quantity:a,metadata:i,...c});if(m!=null)return m}o.addProductToCart=e;function t(){Be.setState({isCartVisible:!0})}o.showCart=t;function n(){Be.setState({isCartVisible:!1})}o.hideCart=n})(Ii = exports.B||={});async function Wr(e){try{return await e.text()}catch (e21){return""}}function Zr(e,t){return t=an(t),t.locale??=_chunkDY2S42Q6js.m.call(void 0, ),{headers:{..._chunkDY2S42Q6js.a,..._chunkMG6VV5J2js.h.call(void 0, e),"Content-Type":"application/json"},body:JSON.stringify(t)}}async function Br(e){let t=Ge();return t==null?null:Kr(Fe(t,"/payment-methods"),Zr(t,e))}async function nn(e){let t=Ge();if(t==null)throw new Error("No project ID found");let n=await fetch(Fe(t,"/buy"),{method:"POST",...Zr(t,e)});if(n.status!=200){let r=cn(n.status,await Wr(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 cu(e){let t=Ge();if(t==null)throw new Error("No project ID found");let n={..._chunkDY2S42Q6js.a,..._chunkMG6VV5J2js.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??=_chunkDY2S42Q6js.m.call(void 0, );let r=await fetch(_chunkDY2S42Q6js.f+o,{method:"POST",headers:n,body:JSON.stringify(e)});return r.ok?{status:"ok",redirectURL:(await r.json()).url}:{...cn(r.status,await Wr(r)),status:"error"}}function xt(){if(typeof localStorage>"u")return;let e=localStorage.getItem("bitsnap-ref");if(e!=null)return e}function an(e){let t=xt();return t==null||(e.metadata==null&&(e.metadata={}),e.metadata.ref=t),e}exports.a = le; exports.b = ue; exports.c = be; exports.d = ve; exports.e = Mt; exports.f = me; exports.g = On; exports.h = Ut; exports.i = Se; exports.j = Qe; exports.k = Xe; exports.l = Me; exports.m = Ue; exports.n = ya; exports.o = Fn; exports.p = Zt; exports.q = Do; exports.r = _; exports.s = Nr; exports.t = Jt; exports.u = ke; exports.v = fi; exports.w = Wl; exports.x = Jl; exports.y = Yl; exports.z = Ql; exports.A = Be; exports.B = Ii; exports.C = Br; exports.D = nn; exports.E = cu; exports.F = xt; exports.G = an; exports.H = sl; exports.I = cl; exports.J = dl; exports.K = ml; exports.L = ei; exports.M = rn; exports.N = zl; exports.O = Ge; exports.P = ql; exports.Q = Fl; exports.R = oi; exports.S = Bl; exports.T = Hl; exports.U = on;
4
- //# sourceMappingURL=chunk-VY6CZVVA.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/private/tmp/bsr-src/dist/chunk-VY6CZVVA.js","../src/panel/components/PanelLogin.tsx","../src/ui/card.tsx","../src/ui/input-otp.tsx","../src/panel/LoadingIndicator.tsx","../src/panel/return-url.ts","../src/lib/render.text.tsx","../src/panel/audio-player/AudioPlayer.tsx"],"names":["Card","className","props","jsx","cn","CardHeader","CardTitle","CardDescription","CardContent","InputOTP","containerClassName","OTPInput","InputOTPGroup","InputOTPSlot","index","inputOTPContext","OTPInputContext","char","hasFakeCaret","isActive","jsxs","InputOTPSeparator","MinusIcon","LoadingIndicator","LoadingIndicator_default","RETURN_URL_PARAM","RETURN_URL_STORAGE_KEY","ACCESS_TOKEN_PARAM","getReturnURLFromSearch","search","raw","validateReturnURL","persistReturnURL","returnURL","readPersistedReturnURL","stored","isOriginAllowed","origin","allowedOrigins","allowed","allowedHost","originHost"],"mappings":"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","file":"/private/tmp/bsr-src/dist/chunk-VY6CZVVA.js","sourcesContent":[null,"import { useAutoAnimate } from \"@formkit/auto-animate/react\";\nimport {\n useEffect,\n useState,\n type ChangeEvent,\n type CSSProperties,\n type FormEvent,\n} from \"react\";\nimport {\n InstrumentProvider,\n useInstrument,\n useInstrumentContext,\n type AnalyticsOption,\n} from \"../../analytics/instrument\";\nimport { cn } from \"../../lib/utils\";\nimport { rpcProvider, useMutation } from \"../../rpc-provider\";\nimport { Button } from \"../../ui/button\";\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"../../ui/card\";\nimport { Input } from \"../../ui/input\";\nimport {\n InputOTP,\n InputOTPGroup,\n InputOTPSeparator,\n InputOTPSlot,\n} from \"../../ui/input-otp\";\nimport { REGEXP_ONLY_DIGITS } from \"input-otp\";\nimport { Label } from \"../../ui/label\";\nimport LoadingIndicator from \"../LoadingIndicator\";\nimport {\n getAllowedReturnOrigins,\n setAllowedReturnOrigins,\n} from \"../config\";\nimport { usePanelConfig } from \"../PanelProvider\";\nimport {\n buildAccessTokenRedirect,\n getReturnURLFromSearch,\n persistReturnURL,\n readPersistedReturnURL,\n} from \"../return-url\";\nimport { getPanelSession, savePanelSession } from \"../session-storage\";\n\ntype LoginResponseStatus = \"success\" | \"error\" | \"default\";\n\nif (typeof window !== \"undefined\") {\n const currentOrigin = window.location.origin;\n const knownSiblings = [\n currentOrigin,\n \"https://bitsnap.pl\",\n \"https://kursy.bitsnap.pl\",\n ];\n if (getAllowedReturnOrigins().length === 0) {\n setAllowedReturnOrigins(Array.from(new Set(knownSiblings)));\n }\n}\n\ninterface LoginUserPanelProps {\n projectID?: string;\n host?: string;\n reveal: () => void;\n email: string;\n setEmail: (input: string) => void;\n loginUser: () => void;\n isLoginLoading: boolean;\n errMsg: string;\n}\n\ninterface VerifyCodePanelProps {\n projectID?: string;\n host?: string;\n email: string;\n reveal: () => void;\n setEmail: (input: string) => void;\n loginUser: () => void;\n isLoginLoading: boolean;\n loginUserResponse: {\n status: \"error\" | \"ok\";\n retryIn: number;\n message?: string | undefined;\n } | null;\n setLoginUserResponse: (\n response: {\n status: \"error\" | \"ok\";\n retryIn: number;\n message?: string | undefined;\n } | null,\n ) => void;\n responseStatus: LoginResponseStatus;\n setResponseStatus: (status: LoginResponseStatus) => void;\n errMsg: string;\n}\n\nconst LoginUserPanel = ({\n projectID,\n host,\n reveal,\n email,\n setEmail,\n loginUser,\n isLoginLoading,\n errMsg,\n}: LoginUserPanelProps) => {\n const { projectID: configuredProjectID, host: configuredHost } = usePanelConfig();\n if (\n typeof window !== \"undefined\" &&\n getPanelSession(projectID ?? configuredProjectID, host ?? configuredHost) != null\n ) {\n // @ts-ignore\n window.location.href = window.location.href.replaceAll(\"login\", \"\");\n return null;\n }\n\n const [isValidEmail, setIsValidEmail] = useState<boolean>(false);\n\n const emailValidation = (input: string) => {\n const emailPattern =\n /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n\n if (emailPattern.test(input.trim())) {\n return setIsValidEmail(true);\n }\n\n return setIsValidEmail(false);\n };\n\n const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n const { value } = e.target;\n emailValidation(value);\n setEmail(value);\n };\n\n function goToVerifyCode() {\n reveal();\n }\n\n function onSubmit(e: FormEvent<HTMLFormElement>) {\n e.preventDefault();\n void loginUser();\n }\n\n return (\n <main className=\"mx-auto flex max-w-sm flex-1 flex-col justify-center space-y-12\">\n <div className={cn(\"flex min-w-sm flex-col gap-6\")}>\n <Card>\n <CardHeader>\n <CardTitle className=\"text-2xl\">Zaloguj się</CardTitle>\n <CardDescription>\n Wyślemy do Ciebie kod na maila, dzięki któremu się zalogujesz.\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form onSubmit={onSubmit}>\n <div className=\"flex flex-col gap-6\">\n <div className=\"grid gap-2\">\n <Label htmlFor=\"email\">Email</Label>\n <Input\n id=\"email\"\n onChange={handleInputChange}\n type=\"email\"\n placeholder=\"m@example.com\"\n required\n />\n <span\n className={cn(\n !isValidEmail && email.length > 0\n ? \"font-bold text-red-500\"\n : \"text-neutral-700 dark:text-neutral-400\",\n \"text-xs\",\n )}\n >\n {!isValidEmail && email.length > 0\n ? \"Nieprawidłowy adres email\"\n : \"Wpisz swój adres email\"}\n </span>\n </div>\n\n <div>\n <Button\n type=\"submit\"\n disabled={isLoginLoading}\n className=\"relative w-full\"\n onClick={loginUser}\n >\n {isLoginLoading && (\n <div className=\"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2\">\n <LoadingIndicator />\n </div>\n )}\n Zaloguj się\n </Button>\n {errMsg.length > 0 && (\n <p className=\"text-xs font-medium text-red-500\">{errMsg}</p>\n )}\n </div>\n </div>\n <div className=\"mt-4 text-center text-sm\">\n Masz już kod?{\" \"}\n <button\n type=\"button\"\n onClick={goToVerifyCode}\n className=\"underline underline-offset-4\"\n >\n Mam już kod\n </button>\n </div>\n </form>\n </CardContent>\n </Card>\n </div>\n </main>\n );\n};\n\nconst VerifyCodePanel = ({\n projectID,\n host,\n email,\n reveal,\n setEmail,\n isLoginLoading,\n loginUserResponse,\n setLoginUserResponse,\n setResponseStatus,\n errMsg,\n}: VerifyCodePanelProps) => {\n const instrument = useInstrumentContext();\n const { mutateAsync: verifyCodeAsync, isPending: isVerifyLoading } =\n useMutation(rpcProvider.publicApi.userPanelLoginWithCode);\n\n const [code, setCode] = useState<string>(\"\");\n const [isValidCode, setIsValidCode] = useState<boolean>(false);\n const [isSubmitted, setIsSubmitted] = useState<boolean>(false);\n const [retryIn, setRetryIn] = useState(0);\n\n const codeValidation = (input: string) => {\n const codePattern = /^\\d+$/;\n\n if (codePattern.test(input.trim())) {\n return setIsValidCode(true);\n }\n\n return setIsValidCode(false);\n };\n\n const handleInputChange = (value: string) => {\n codeValidation(value);\n setCode(value);\n };\n\n async function login() {\n setIsSubmitted(true);\n if (code.length == 0) {\n setIsValidCode(false);\n return;\n }\n const codeValue = parseInt(code);\n\n const verifyCodeResult = await verifyCodeAsync({\n code: codeValue,\n });\n\n let status, message, accessToken;\n\n if (verifyCodeResult.result.case === \"accessToken\") {\n setIsValidCode(true);\n status = \"ok\";\n message = undefined;\n accessToken = verifyCodeResult.result.value;\n } else {\n setIsValidCode(false);\n status = \"error\";\n message = verifyCodeResult.result.value;\n accessToken = undefined;\n }\n\n if (status === \"error\") {\n setIsValidCode(false);\n console.warn(\"error:\", `Kod błędu: ${message}`);\n console.warn(\"Nieprawidłowy kod, spróbuj ponownie.\");\n }\n\n if (status === \"ok\") {\n instrument.track(\"panel_login\", {});\n if (accessToken) {\n savePanelSession(projectID, accessToken, email, host);\n }\n const returnURL = typeof window !== \"undefined\"\n ? readPersistedReturnURL()\n : null;\n setTimeout(() => {\n if (accessToken && returnURL) {\n window.location.href = buildAccessTokenRedirect(returnURL, accessToken);\n return;\n }\n window.location.reload();\n }, 100);\n }\n }\n\n function handleRetryInTime() {\n const intervalId = setInterval(() => {\n setRetryIn((prevRetryIn) => {\n if (prevRetryIn > 0) {\n return prevRetryIn - 1;\n } else {\n clearInterval(intervalId);\n return 0;\n }\n });\n }, 1000);\n\n return () => {\n clearInterval(intervalId);\n };\n }\n\n useEffect(() => {\n if (loginUserResponse?.status === \"ok\" && loginUserResponse?.retryIn > 0) {\n setRetryIn(loginUserResponse.retryIn);\n handleRetryInTime();\n }\n }, [loginUserResponse]);\n\n function backToLoginComponent() {\n setEmail(\"\");\n setLoginUserResponse(null);\n setResponseStatus(\"default\");\n reveal();\n }\n\n function onCodeSubmit(e: FormEvent<HTMLFormElement>) {\n e.preventDefault();\n void login();\n }\n\n return (\n <main className=\"mx-auto flex max-w-md flex-1 flex-col justify-center space-y-8\">\n <div className={cn(\"flex min-w-sm flex-col gap-6\")}>\n <Card>\n <CardHeader>\n <CardTitle className=\"text-2xl\">Wpisz kod z maila</CardTitle>\n <CardDescription>\n Sprawdź czy przypadkiem nie wylądował w spamie.\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form onSubmit={onCodeSubmit} className=\"flex flex-col gap-6\">\n <div className=\"grid gap-2\">\n <div className=\"my-5 flex w-full items-center justify-center\">\n <div className=\"flex flex-col gap-2\">\n <InputOTP\n id=\"verify-code\"\n maxLength={6}\n pattern={REGEXP_ONLY_DIGITS}\n onChange={(newValue) => {\n handleInputChange(newValue);\n }}\n >\n <InputOTPGroup>\n <InputOTPSlot index={0} />\n <InputOTPSlot index={1} />\n <InputOTPSlot index={2} />\n </InputOTPGroup>\n <InputOTPSeparator />\n <InputOTPGroup>\n <InputOTPSlot index={3} />\n <InputOTPSlot index={4} />\n <InputOTPSlot index={5} />\n </InputOTPGroup>\n </InputOTP>\n <span\n className={cn(\n !isValidCode && isSubmitted\n ? \"text-red-500\"\n : \"text-neutral-700 dark:text-neutral-400\",\n \"text-xs\",\n )}\n >\n {!isValidCode && isSubmitted\n ? code.length == 0\n ? \"Kod nie może być pusty\"\n : \"Kod musi składać się z cyfr\"\n : \"Wpisz kod z maila\"}\n </span>\n </div>\n </div>\n </div>\n\n <div>\n <Button\n type=\"submit\"\n disabled={isLoginLoading || isVerifyLoading}\n className=\"relative w-full\"\n >\n {(isLoginLoading || isVerifyLoading) && (\n <div className=\"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2\">\n <LoadingIndicator />\n </div>\n )}\n Zaloguj się\n </Button>\n {errMsg.length > 0 && (\n <p className=\"text-xs font-medium text-red-500\">{errMsg}</p>\n )}\n </div>\n </form>\n <div className=\"mt-4 text-center text-sm\">\n Nie masz kodu?{\" \"}\n <button\n type=\"button\"\n onClick={backToLoginComponent}\n className=\"underline underline-offset-4\"\n >\n Wróć\n </button>\n </div>\n </CardContent>\n </Card>\n </div>\n </main>\n );\n};\n\nconst PanelLoginComponentWrapper = ({\n analytics,\n}: {\n analytics?: AnalyticsOption;\n}) => {\n const { theme, allowedReturnOrigins, projectID, host } = usePanelConfig();\n const instrument = useInstrument(projectID, analytics, \"panel\");\n\n const styles = {\n \"--button-background-color\": theme?.colors?.brand ?? \"#FFFFFF\",\n \"--button-background-color-dark\": theme?.colors?.brandDark ?? \"#000000\",\n \"--button-text-color\": theme?.colors?.brandDark ?? \"#000000\",\n \"--button-text-color-dark\": theme?.colors?.brand ?? \"#FFFFFF\",\n } as CSSProperties;\n\n type Screen = \"login\" | \"verifyCode\";\n\n const [activeScreen, setActiveScreen] = useState<Screen>(\"login\");\n const [parent] = useAutoAnimate({\n duration: 300,\n easing: \"ease-in-out\",\n disrespectUserMotionPreference: false,\n });\n\n const reveal = () =>\n setActiveScreen((prevScreen) =>\n prevScreen === \"login\" ? \"verifyCode\" : \"login\",\n );\n\n const [email, setEmail] = useState<string>(\"\");\n const [responseStatus, setResponseStatus] =\n useState<LoginResponseStatus>(\"default\");\n const [loginUserResponse, setLoginUserResponse] = useState<{\n status: \"error\" | \"ok\";\n retryIn: number;\n message?: string | undefined;\n } | null>(null);\n const { mutateAsync: loginUserAsync, isPending: isLoginLoading } =\n useMutation(rpcProvider.publicApi.userPanelLogin);\n\n const [errMsg, setErrMsg] = useState(\"\");\n\n useEffect(() => {\n if (typeof window === \"undefined\") return;\n if (window.parent !== window) return;\n\n const queryReturnURL = getReturnURLFromSearch(window.location.search);\n if (queryReturnURL) {\n persistReturnURL(queryReturnURL);\n }\n\n const returnURL = queryReturnURL ?? readPersistedReturnURL();\n if (!returnURL) return;\n\n const existingToken = getPanelSession(projectID, host);\n if (!existingToken) return;\n\n window.location.href = buildAccessTokenRedirect(returnURL, existingToken);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [allowedReturnOrigins, projectID, host]);\n\n async function loginUser() {\n setErrMsg(\"\");\n setResponseStatus(\"default\");\n const loginUserResult = await loginUserAsync({\n email: email,\n });\n\n const status = loginUserResult.result.case === \"success\" ? \"ok\" : \"error\";\n let retryIn = 0;\n let message = undefined;\n\n if (loginUserResult.result.case === \"success\") {\n retryIn = loginUserResult.result.value.retryIn;\n }\n\n if (status === \"error\") {\n message = \"Nieprawidłowy adres email, spróbuj ponownie.\";\n }\n\n setLoginUserResponse({\n status: status,\n retryIn: retryIn,\n message: message,\n });\n\n if (status === \"ok\" && activeScreen === \"login\") {\n reveal();\n } else if (status === \"ok\" && activeScreen === \"verifyCode\") {\n setResponseStatus(\"success\");\n } else if (status === \"error\") {\n setErrMsg(message ?? \"Nieprawidłowy adres email, spróbuj ponownie.\");\n }\n }\n\n return (\n <InstrumentProvider value={instrument}>\n <div className=\"bg-white text-black dark:bg-black dark:text-white\">\n <div\n className=\"font-inter flex h-screen w-screen flex-col p-4\"\n style={styles}\n ref={parent}\n >\n <header>\n {theme?.logoDarkURL && (\n <img\n src={theme?.logoDarkURL}\n className=\"hidden dark:inline\"\n alt=\"Company Logo\"\n draggable={false}\n />\n )}\n {theme?.logoURL && (\n <img\n src={theme?.logoURL}\n className=\"dark:hidden\"\n alt=\"Company Logo\"\n draggable={false}\n />\n )}\n </header>\n {activeScreen === \"login\" && (\n <LoginUserPanel\n projectID={projectID}\n host={host}\n reveal={reveal}\n email={email}\n setEmail={setEmail}\n loginUser={loginUser}\n isLoginLoading={isLoginLoading}\n errMsg={errMsg}\n />\n )}\n {activeScreen === \"verifyCode\" && (\n <VerifyCodePanel\n projectID={projectID}\n host={host}\n email={email}\n reveal={reveal}\n setEmail={setEmail}\n loginUser={loginUser}\n isLoginLoading={isLoginLoading}\n loginUserResponse={loginUserResponse}\n setLoginUserResponse={setLoginUserResponse}\n responseStatus={responseStatus}\n setResponseStatus={setResponseStatus}\n errMsg={errMsg}\n />\n )}\n </div>\n </div>\n </InstrumentProvider>\n );\n};\n\nexport const PanelLogin = ({\n analytics,\n}: { analytics?: AnalyticsOption } = {}) => {\n return <PanelLoginComponentWrapper analytics={analytics} />;\n};\n","import * as React from \"react\"\n\nimport { cn } from \"@/src/lib/utils\"\n\nfunction Card({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"card\"\n className={cn(\n \"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CardHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"card-header\"\n className={cn(\n \"@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\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CardTitle({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"card-title\"\n className={cn(\"leading-none font-semibold\", className)}\n {...props}\n />\n )\n}\n\nfunction CardDescription({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"card-description\"\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...props}\n />\n )\n}\n\nfunction CardAction({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"card-action\"\n className={cn(\n \"col-start-2 row-span-2 row-start-1 self-start justify-self-end\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CardContent({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"card-content\"\n className={cn(\"px-6\", className)}\n {...props}\n />\n )\n}\n\nfunction CardFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"card-footer\"\n className={cn(\"flex items-center px-6 [.border-t]:pt-6\", className)}\n {...props}\n />\n )\n}\n\nexport {\n Card,\n CardHeader,\n CardFooter,\n CardTitle,\n CardAction,\n CardDescription,\n CardContent,\n}\n","import * as React from \"react\"\nimport { OTPInput, OTPInputContext } from \"input-otp\"\nimport { MinusIcon } from \"lucide-react\"\n\nimport { cn } from \"@/src/lib/utils\"\n\nfunction InputOTP({\n className,\n containerClassName,\n ...props\n}: React.ComponentProps<typeof OTPInput> & {\n containerClassName?: string\n}) {\n return (\n <OTPInput\n data-slot=\"input-otp\"\n containerClassName={cn(\n \"flex items-center gap-2 has-disabled:opacity-50\",\n containerClassName\n )}\n className={cn(\"disabled:cursor-not-allowed\", className)}\n {...props}\n />\n )\n}\n\nfunction InputOTPGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"input-otp-group\"\n className={cn(\"flex items-center\", className)}\n {...props}\n />\n )\n}\n\nfunction InputOTPSlot({\n index,\n className,\n ...props\n}: React.ComponentProps<\"div\"> & {\n index: number\n}) {\n const inputOTPContext = React.useContext(OTPInputContext)\n const { char, hasFakeCaret, isActive } = inputOTPContext?.slots[index] ?? {}\n\n return (\n <div\n data-slot=\"input-otp-slot\"\n data-active={isActive}\n className={cn(\n \"data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]\",\n className\n )}\n {...props}\n >\n {char}\n {hasFakeCaret && (\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-center\">\n <div className=\"animate-caret-blink bg-foreground h-4 w-px duration-1000\" />\n </div>\n )}\n </div>\n )\n}\n\nfunction InputOTPSeparator({ ...props }: React.ComponentProps<\"div\">) {\n return (\n <div data-slot=\"input-otp-separator\" role=\"separator\" {...props}>\n <MinusIcon />\n </div>\n )\n}\n\nexport { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }\n","export function LoadingIndicator() {\n return (\n <div className=\"flex items-center gap-2\">\n <div className=\"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]\" />\n <div className=\"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]\" />\n <div className=\"h-3 w-3 animate-bounce rounded-full bg-current\" />\n </div>\n );\n}\n\nexport default LoadingIndicator;\n","import { getAllowedReturnOrigins } from \"./config\";\n\nconst RETURN_URL_PARAM = \"return_url\";\nconst RETURN_URL_STORAGE_KEY = \"__return_url\";\nconst ACCESS_TOKEN_PARAM = \"accessToken\";\n\nexport function getReturnURLFromSearch(search: string): string | null {\n const raw = new URLSearchParams(search).get(RETURN_URL_PARAM);\n if (!raw) return null;\n return validateReturnURL(raw);\n}\n\nexport function persistReturnURL(returnURL: string | null): void {\n if (typeof window === \"undefined\") return;\n if (returnURL) {\n window.sessionStorage.setItem(RETURN_URL_STORAGE_KEY, returnURL);\n } else {\n window.sessionStorage.removeItem(RETURN_URL_STORAGE_KEY);\n }\n}\n\nexport function readPersistedReturnURL(): string | null {\n if (typeof window === \"undefined\") return null;\n const stored = window.sessionStorage.getItem(RETURN_URL_STORAGE_KEY);\n if (!stored) return null;\n return validateReturnURL(stored);\n}\n\nfunction isOriginAllowed(origin: string, allowedOrigins: string[]): boolean {\n return allowedOrigins.some((allowed) => {\n if (origin === allowed) return true;\n const allowedHost = new URL(allowed).hostname;\n const originHost = new URL(origin).hostname;\n return originHost.endsWith(`.${allowedHost}`) || originHost === allowedHost;\n });\n}\n\nfunction validateReturnURL(raw: string): string | null {\n try {\n const u = new URL(raw);\n if (u.protocol !== \"https:\" && u.protocol !== \"http:\") return null;\n if (!isOriginAllowed(u.origin, getAllowedReturnOrigins())) return null;\n return u.toString();\n } catch {\n return null;\n }\n}\n\nexport function buildAccessTokenRedirect(\n returnURL: string,\n accessToken: string,\n): string {\n const u = new URL(returnURL);\n u.searchParams.set(ACCESS_TOKEN_PARAM, accessToken);\n return u.toString();\n}\n","const URL_REGEX =\n /https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)/g;\n\ntype Replacements = {\n url: string;\n startIndex: number;\n endIndex: number;\n replacementText?: string;\n};\n\nconst findURLIndices = (text: string) => {\n const matches = [...text.matchAll(URL_REGEX)];\n return matches.map(\n (match) =>\n ({\n url: match[0],\n startIndex: match.index,\n endIndex: match.index + match[0].length - 1,\n }) as Replacements,\n );\n};\n\nconst replaceTextByIndices = (\n originalText: string,\n replacements: Replacements[],\n) => {\n let result = \"\";\n let lastIndex = 0;\n\n // Sort replacements by startIndex to handle them in order\n replacements.sort((a, b) => a.startIndex - b.startIndex);\n\n for (const { startIndex, endIndex, replacementText } of replacements) {\n // Append text before the current replacement\n result += originalText.slice(lastIndex, startIndex);\n // Append the replacement text\n result += replacementText;\n // Update lastIndex to after the replaced segment\n lastIndex = endIndex + 1;\n }\n\n // Append any remaining text after the last replacement\n result += originalText.slice(lastIndex);\n\n return result;\n};\n\nexport const renderText = (txt: string) => {\n const urlIndices = findURLIndices(txt);\n\n return (\n <p\n dangerouslySetInnerHTML={{\n __html: replaceTextByIndices(\n txt,\n urlIndices.map((el) => {\n el[\"replacementText\"] =\n `<a key=${el.url} href=${el.url} style=\"text-decoration: underline;\" target=\"_blank\">\n ${el.url}\n </a>`;\n return el;\n }),\n ),\n }}\n ></p>\n );\n};\n","import Hls from \"hls.js\";\nimport { Pause, Play } from \"lucide-react\";\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n type CSSProperties,\n} from \"react\";\nimport { Button } from \"../../ui/button\";\nimport LoadingIndicator from \"../LoadingIndicator\";\nimport {\n mediaSessionPause,\n mediaSessionPlay,\n mediaSessionUpdateDurationAndPosition,\n startMediaSessionCoordinator,\n stopMediaSessionCoordinator,\n} from \"./media.session.coordinator\";\n\nimport \"./audio-player.css\";\n\ntype ChapterWithPublicUrl = {\n id: string;\n multimediaId?: string;\n name: string;\n description?: string;\n publicUrl: string;\n downloadableUrl?: string;\n duration?: number;\n};\n\nexport type AudioPlayerMethods = {\n selectChapter: (chapter: ChapterWithPublicUrl) => void;\n};\n\ntype AudioPlayerProps = {\n chapters: ChapterWithPublicUrl[];\n styles: CSSProperties;\n updateCurrentTime?: (currentTime: number) => void;\n\n title?: string;\n imageURL?: string;\n\n setCurrentTimeHandler?: (seekTo: (second: number) => void) => void;\n uniqueProductID: string;\n\n onChapterChange?: (chapter: ChapterWithPublicUrl) => void;\n};\n\nconst AudioPlayer = forwardRef<AudioPlayerMethods, AudioPlayerProps>(\n (\n {\n chapters,\n styles,\n updateCurrentTime,\n setCurrentTimeHandler,\n title,\n imageURL,\n uniqueProductID,\n onChapterChange,\n },\n ref,\n ) => {\n enum PlayState {\n Playing,\n Paused,\n }\n\n const [playState, setPlayState] = useState<PlayState>(PlayState.Paused);\n\n useEffect(() => {\n switch (playState) {\n case PlayState.Playing:\n mediaSessionPlay();\n break;\n case PlayState.Paused:\n mediaSessionPause();\n break;\n }\n }, [playState]);\n\n useImperativeHandle(ref, () => {\n return {\n selectChapter: (chapter: ChapterWithPublicUrl) => {\n playChapter(chapter);\n },\n };\n });\n\n const [currentTime, setCurrentTime] = useState<number | undefined>(\n undefined,\n );\n const [duration, setDuration] = useState<number | undefined>(undefined);\n\n const videoRef = useRef<HTMLVideoElement | null>(null);\n const hlsRef = useRef<Hls | undefined>(undefined);\n const timerRef = useRef<number | undefined>(undefined);\n\n const audioPlayerContainerRef = useRef<HTMLDivElement>(null!);\n\n const currentChapterRef = useRef<ChapterWithPublicUrl | null>(null);\n\n const [playWhenReady, setPlayWhenReady] = useState(true);\n const [isStarted, setIsStarted] = useState(false);\n const [isLoading, setIsLoading] = useState(!isSafari());\n\n function saveLastPlayedTime(timeInSeconds: number) {\n if (timeInSeconds < 10) {\n return;\n }\n localStorage.setItem(\n `__player__${uniqueProductID}_${currentChapterRef.current?.id}`,\n `${timeInSeconds}`,\n );\n }\n\n function getLastPlayedTime(): number | undefined {\n const time = localStorage.getItem(\n `__player__${uniqueProductID}_${currentChapterRef.current?.id}`,\n );\n\n if (time == null) {\n return undefined;\n }\n try {\n const result = parseInt(time);\n\n if (isNaN(result) || result < 0) {\n return undefined;\n }\n\n return result;\n } catch (e) {\n return undefined;\n }\n }\n\n function getLastSelectedChapterID(): string | undefined {\n const lastSelectedChapterID = localStorage.getItem(\n `__player__${uniqueProductID}_last_chapter`,\n );\n if (lastSelectedChapterID == null) {\n return undefined;\n }\n return lastSelectedChapterID;\n }\n\n function setLastSelectedChapterID(chapterID: string) {\n localStorage.setItem(\n `__player__${uniqueProductID}_last_chapter`,\n chapterID,\n );\n }\n\n function deleteMemoryChapter(chapterID: string) {\n localStorage.removeItem(`__player__${uniqueProductID}_${chapterID}`);\n }\n\n function setupObservers() {\n if (videoRef.current == null) {\n return;\n }\n videoRef.current.onloadeddata = () => {\n if (videoRef.current == null) {\n return;\n }\n if (videoRef.current.readyState < 2) {\n setIsLoading(true);\n }\n if (videoRef.current.readyState >= 2) {\n setIsLoading(false);\n }\n\n if (!isStarted) {\n const lastPlayedTime = getLastPlayedTime();\n if (lastPlayedTime != undefined) {\n seekTo(lastPlayedTime);\n }\n setIsStarted(true);\n }\n if (playWhenReady) {\n setPlayWhenReady(false);\n try {\n play();\n } catch (e) {\n console.log(\"play error\", e);\n }\n }\n };\n videoRef.current.onplay = () => {};\n\n videoRef.current.onseeked = () => {};\n videoRef.current.onseeking = () => {};\n\n videoRef.current.onpause = () => {};\n\n videoRef.current.onended = () => {\n playNextChapter();\n };\n\n startMediaSessionCoordinator({\n title: title ?? \"\",\n artwork: imageURL,\n action: (details) => {\n switch (details.action) {\n case \"play\":\n play();\n break;\n case \"pause\":\n pause();\n break;\n case \"seekbackward\":\n seekBy(-15);\n break;\n case \"seekforward\":\n seekBy(15);\n break;\n case \"seekto\":\n if (details.seekTime) {\n seekTo(details.seekTime);\n }\n break;\n case \"stop\":\n pause();\n break;\n default:\n break;\n }\n },\n });\n\n startTimer();\n }\n\n function playNextChapter() {\n if (chapters == null || chapters.length == 0) {\n return;\n }\n const currentChapterIndex = chapters.findIndex(\n (chapter) => chapter.id == currentChapterRef.current?.id,\n );\n if (currentChapterIndex == -1) {\n return;\n }\n deleteMemoryChapter(chapters[currentChapterIndex].id);\n const nextChapterIndex = currentChapterIndex + 1;\n if (nextChapterIndex >= chapters.length) {\n return;\n }\n playChapter(chapters[currentChapterIndex + 1]);\n }\n\n function startTimer() {\n updatePlayerDetails();\n if (timerRef.current != null) return;\n\n timerRef.current = setTimeout(() => {\n updatePlayerDetails();\n timerRef.current = undefined;\n startTimer();\n }, 500) as unknown as number;\n }\n\n function stopTimer() {\n if (timerRef.current == null) return;\n clearTimeout(timerRef.current as unknown as number);\n }\n\n function updatePlayerDetails() {\n if (videoRef.current == null) {\n return;\n }\n setPlayState(\n videoRef.current.paused ? PlayState.Paused : PlayState.Playing,\n );\n setDuration(videoRef.current.duration);\n setCurrentTime(videoRef.current.currentTime);\n saveLastPlayedTime(videoRef.current.currentTime);\n mediaSessionUpdateDurationAndPosition(\n videoRef.current.duration,\n videoRef.current.currentTime,\n );\n if (\n videoRef.current.networkState === videoRef.current.NETWORK_LOADING &&\n videoRef.current.readyState <= videoRef.current.HAVE_FUTURE_DATA\n ) {\n setIsLoading(true);\n } else {\n setIsLoading(false);\n }\n if (updateCurrentTime) {\n updateCurrentTime(videoRef.current.currentTime);\n }\n }\n\n function play() {\n videoRef.current?.play().then().catch();\n updatePlayerDetails();\n }\n\n function pause() {\n videoRef.current?.pause();\n updatePlayerDetails();\n }\n\n function togglePlayState() {\n if (playState === PlayState.Playing) {\n pause();\n return;\n }\n play();\n }\n\n function seekBy(seconds: number) {\n if (videoRef.current == null) {\n return;\n }\n const newTime = videoRef.current.currentTime + seconds;\n if (newTime < 0) {\n videoRef.current.currentTime = 0;\n return;\n }\n if (newTime > videoRef.current.duration) {\n videoRef.current.currentTime = videoRef.current.duration;\n return;\n }\n videoRef.current.currentTime += seconds;\n }\n\n function seekTo(toSecond: number) {\n if (videoRef.current == null) {\n return;\n }\n setCurrentTime(toSecond);\n if (toSecond < 0) {\n videoRef.current.currentTime = 0;\n return;\n }\n if (toSecond > videoRef.current.duration) {\n videoRef.current.currentTime = videoRef.current.duration;\n return;\n }\n videoRef.current.currentTime = toSecond;\n }\n\n function destroyPlayer() {\n if (videoRef.current == null) {\n return;\n }\n videoRef.current.onplay = null;\n videoRef.current.onseeked = null;\n videoRef.current.onseeking = null;\n videoRef.current.onpause = null;\n videoRef.current.onended = null;\n videoRef.current.src = \"\";\n hlsRef.current?.destroy();\n }\n\n function loadChapters(chapters: ChapterWithPublicUrl[]) {\n if (chapters.length == 0) {\n return;\n }\n\n const chapterID = getLastSelectedChapterID();\n if (chapterID == null) {\n playChapter(chapters[0]);\n return;\n }\n\n const chapter = chapters.find((chapter) => chapter.id == chapterID);\n if (chapter == null) {\n playChapter(chapters[0]);\n return;\n }\n\n playChapter(chapter);\n }\n\n function playChapter(chapter: ChapterWithPublicUrl) {\n setIsStarted(false);\n setPlayWhenReady(true);\n currentChapterRef.current = chapter;\n playURL(chapter.publicUrl);\n onChapterChange?.(chapter);\n setLastSelectedChapterID(chapter.id);\n }\n\n function playURL(src: string) {\n if (videoRef.current == null) {\n return;\n }\n if (videoRef.current.canPlayType(\"application/vnd.apple.mpegurl\")) {\n videoRef.current.src = src;\n } else if (Hls.isSupported()) {\n if (hlsRef.current == null) {\n hlsRef.current = new Hls();\n hlsRef.current?.attachMedia(videoRef.current);\n }\n hlsRef.current?.loadSource(src);\n }\n }\n\n useEffect(() => {\n if (videoRef.current == null) {\n return;\n }\n setupObservers();\n loadChapters(chapters);\n }, [videoRef.current]);\n\n useEffect(() => {\n loadChapters(chapters);\n }, [chapters]);\n\n useEffect(() => {\n if (setCurrentTimeHandler != null) {\n setCurrentTimeHandler(seekTo);\n }\n\n return () => {\n setCurrentTime(undefined);\n videoRef.current?.pause();\n destroyPlayer();\n stopMediaSessionCoordinator();\n };\n }, []);\n\n const calculateTime = (secs: number) => {\n const hours = Math.floor(secs / 3600);\n const minutes = Math.floor(secs / 60) % 60;\n const seconds = Math.floor(secs % 60);\n const returnedHours =\n hours > 0 ? (hours < 10 ? `0${hours}:` : `${hours}:`) : \"\";\n const returnedSeconds = seconds < 10 ? `0${seconds}` : `${seconds}`;\n if (isNaN(seconds) || isNaN(minutes) || isNaN(hours)) {\n return \"\";\n }\n return `${returnedHours}${minutes}:${returnedSeconds}`;\n };\n\n const showRangeProgress = (rangeInput: HTMLInputElement) => {\n const barProgress =\n (parseFloat(rangeInput.value) / parseFloat(rangeInput.max)) * 100;\n audioPlayerContainerRef.current.style.setProperty(\n \"--seek-before-width\",\n barProgress + \"%\",\n );\n\n const selectedTime = (duration! * barProgress) / 100;\n seekTo(selectedTime);\n };\n\n return (\n <div\n id=\"audio-player-container\"\n className=\"flex flex-col\"\n style={styles}\n ref={audioPlayerContainerRef}\n >\n <video\n ref={videoRef}\n className=\"hidden\"\n poster={imageURL}\n title={title}\n ></video>\n\n <input\n type=\"range\"\n min=\"0\"\n max={duration != undefined ? Math.floor(duration).toString() : 100}\n value={currentTime ?? 0}\n onChange={(e) => showRangeProgress(e.target as HTMLInputElement)}\n className=\"w-full\"\n />\n\n <section className=\"flex w-full items-center justify-between text-sm font-medium\">\n <span id=\"current-time\">{calculateTime(currentTime!)}</span>\n <span id=\"duration\">{calculateTime(duration!)}</span>\n </section>\n <div className=\"mt-6 flex items-center justify-center gap-x-12\">\n <Button\n variant=\"outline\"\n onClick={() => seekBy(-10)}\n aria-label=\"Rewind 10 Seconds\"\n >\n -10\n </Button>\n <Button\n variant=\"outline\"\n onClick={togglePlayState}\n aria-label=\"Play Or Pause\"\n >\n {playState === PlayState.Paused && <Play className=\"h-5 w-5\" />}\n {playState === PlayState.Playing && <Pause className=\"h-5 w-5\" />}\n </Button>\n <Button\n variant=\"outline\"\n onClick={() => seekBy(10)}\n aria-label=\"Fast Forward 10 Seconds\"\n >\n +10\n </Button>\n </div>\n {isLoading && (\n <div className=\"mt-2 flex w-full justify-center\">\n <LoadingIndicator />\n </div>\n )}\n </div>\n );\n },\n);\n\nfunction isSafari() {\n return navigator.userAgent.toLowerCase().indexOf(\"safari/\") > -1;\n}\n\nexport default AudioPlayer;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/private/tmp/bsr-src/dist/chunk-XZYCQ655.js","../src/components/returns/state-machine.ts","../src/components/returns/BitsnapReturns.tsx"],"names":["STEPS_WITH_SESSION","stepRequiresSession","step","initialReturnsStep","hasSession","reduceReturnsStep","event","STEP_NUMBERS","RETURNS_STEP_COUNT","returnsStepNumber","StepIndicator","current","text","useReturnsText","slot","useReturnsSlot","jsx","cn","ReturnsRouter","panelToken","status","useReturnsContext","dispatch","useReducer","useEffect","SkeletonRows","stepNumber","jsxs","ReturnsEmailStep","ReturnsCodeStep","ReturnsOrderList","orderId","ReturnsOrderDetail","items","note","ReturnsConfirmation","returnId","ReturnsResult","ReturnsMyReturnsList","ReturnsMyReturnDetail","BitsnapReturns","props","ReturnsProvider"],"mappings":"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","file":"/private/tmp/bsr-src/dist/chunk-XZYCQ655.js","sourcesContent":[null,"/** One line chosen for return. */\nexport type SelectedReturnLine = {\n lineId: string;\n quantity: number;\n};\n\n/** Where the default flow of `BitsnapReturns` currently is. */\nexport type ReturnsStep =\n | { name: \"email\" }\n | { name: \"code\" }\n | { name: \"orders\" }\n | {\n name: \"order\";\n orderId: string;\n /** Selection to restore when coming back from the confirmation. */\n items?: SelectedReturnLine[];\n note?: string;\n }\n | {\n name: \"confirmation\";\n orderId: string;\n items: SelectedReturnLine[];\n note: string;\n }\n | { name: \"result\"; returnId: string }\n | { name: \"myReturns\" }\n | { name: \"myReturn\"; returnId: string };\n\nexport type ReturnsStepName = ReturnsStep[\"name\"];\n\nexport type ReturnsStepEvent =\n /** A verification code was requested. */\n | { type: \"CODE_SENT\" }\n /** The session became valid: code verified, stored session or panel token. */\n | { type: \"AUTHENTICATED\" }\n /** The session was dropped by the backend, expiry or logout. */\n | { type: \"SESSION_EXPIRED\" }\n | { type: \"SELECT_ORDER\"; orderId: string }\n | { type: \"REVIEW\"; items: SelectedReturnLine[]; note: string }\n | { type: \"SUBMITTED\"; returnId: string }\n | { type: \"OPEN_MY_RETURNS\" }\n | { type: \"SELECT_RETURN\"; returnId: string }\n | { type: \"BACK\" }\n /** Leave the result screen for the order list. */\n | { type: \"CONTINUE\" };\n\nconst STEPS_WITH_SESSION: readonly ReturnsStepName[] = [\n \"orders\",\n \"order\",\n \"confirmation\",\n \"result\",\n \"myReturns\",\n \"myReturn\",\n];\n\n/** Steps that cannot be shown without a returns session. */\nexport function stepRequiresSession(step: ReturnsStepName): boolean {\n return STEPS_WITH_SESSION.includes(step);\n}\n\n/** Starts at the orders when a session exists, otherwise at the email. */\nexport function initialReturnsStep(hasSession: boolean): ReturnsStep {\n return hasSession ? { name: \"orders\" } : { name: \"email\" };\n}\n\n/**\n * Pure transition function of the default flow. Events that do not apply to\n * the current step leave it unchanged.\n */\nexport function reduceReturnsStep(\n step: ReturnsStep,\n event: ReturnsStepEvent,\n): ReturnsStep {\n switch (event.type) {\n case \"SESSION_EXPIRED\":\n // Email and code do not need a session; keep a pending verification.\n return stepRequiresSession(step.name) ? { name: \"email\" } : step;\n case \"CODE_SENT\":\n return step.name === \"email\" ? { name: \"code\" } : step;\n case \"AUTHENTICATED\":\n return step.name === \"email\" || step.name === \"code\"\n ? { name: \"orders\" }\n : step;\n case \"SELECT_ORDER\":\n return step.name === \"orders\"\n ? { name: \"order\", orderId: event.orderId }\n : step;\n case \"REVIEW\":\n return step.name === \"order\"\n ? {\n name: \"confirmation\",\n orderId: step.orderId,\n items: event.items,\n note: event.note,\n }\n : step;\n case \"SUBMITTED\":\n return step.name === \"confirmation\"\n ? { name: \"result\", returnId: event.returnId }\n : step;\n case \"OPEN_MY_RETURNS\":\n return step.name === \"orders\" || step.name === \"result\"\n ? { name: \"myReturns\" }\n : step;\n case \"SELECT_RETURN\":\n return step.name === \"myReturns\"\n ? { name: \"myReturn\", returnId: event.returnId }\n : step;\n case \"CONTINUE\":\n return step.name === \"result\" ? { name: \"orders\" } : step;\n case \"BACK\":\n switch (step.name) {\n case \"code\":\n return { name: \"email\" };\n case \"order\":\n case \"myReturns\":\n return { name: \"orders\" };\n case \"confirmation\":\n return {\n name: \"order\",\n orderId: step.orderId,\n items: step.items,\n note: step.note,\n };\n case \"myReturn\":\n return { name: \"myReturns\" };\n default:\n return step;\n }\n }\n}\n\nconst STEP_NUMBERS: Partial<Record<ReturnsStepName, number>> = {\n email: 1,\n code: 2,\n orders: 3,\n order: 4,\n confirmation: 5,\n result: 6,\n};\n\nexport const RETURNS_STEP_COUNT = 6;\n\n/** Position of a step in the return flow, `undefined` for the \"my returns\" views. */\nexport function returnsStepNumber(step: ReturnsStepName): number | undefined {\n return STEP_NUMBERS[step];\n}\n","import { useEffect, useReducer } from \"react\";\nimport { cn } from \"@/src/lib/utils\";\nimport { useReturnsSlot } from \"./appearance.context\";\nimport { ReturnsCodeStep, ReturnsEmailStep } from \"./AuthSteps\";\nimport { SkeletonRows } from \"./internal\";\nimport { ReturnsMyReturnDetail, ReturnsMyReturnsList } from \"./MyReturns\";\nimport {\n ReturnsConfirmation,\n ReturnsOrderDetail,\n ReturnsOrderList,\n ReturnsResult,\n} from \"./OrderSteps\";\nimport {\n ReturnsProvider,\n useReturnsContext,\n type ReturnsProviderProps,\n} from \"./ReturnsProvider\";\nimport {\n initialReturnsStep,\n reduceReturnsStep,\n RETURNS_STEP_COUNT,\n returnsStepNumber,\n} from \"./state-machine\";\nimport { useReturnsText } from \"./texts.context\";\n\nexport type BitsnapReturnsProps = Omit<ReturnsProviderProps, \"children\">;\n\nfunction StepIndicator({ current }: { current: number }) {\n const text = useReturnsText();\n const slot = useReturnsSlot(\"stepIndicator\");\n\n return (\n <p\n data-bitsnap-returns-slot=\"stepIndicator\"\n className={cn(\"text-xs\", slot.className)}\n style={slot.style}\n >\n {text(\"stepIndicator\", { current, total: RETURNS_STEP_COUNT })}\n </p>\n );\n}\n\n/** Default step router. All transitions come from the pure state machine. */\nfunction ReturnsRouter({ panelToken }: { panelToken: boolean }) {\n const { status } = useReturnsContext(\"BitsnapReturns\");\n const [step, dispatch] = useReducer(\n reduceReturnsStep,\n initialReturnsStep(false),\n );\n\n // A valid session (verified code, stored session, exchanged panel token)\n // moves on to the orders; a dropped one returns to the start.\n useEffect(() => {\n if (status === \"authenticated\") {\n dispatch({ type: \"AUTHENTICATED\" });\n } else if (status === \"anonymous\") {\n dispatch({ type: \"SESSION_EXPIRED\" });\n }\n }, [status]);\n\n // Without a panel token the server render and the first client render show\n // the email step; a stored session switches to the orders after hydration.\n if (status === \"exchanging\" || (status === \"hydrating\" && panelToken)) {\n return <SkeletonRows />;\n }\n\n const stepNumber = returnsStepNumber(step.name);\n\n return (\n <div className=\"flex flex-col gap-4\">\n {stepNumber != null && <StepIndicator current={stepNumber} />}\n {step.name === \"email\" && (\n <ReturnsEmailStep onSubmitted={() => dispatch({ type: \"CODE_SENT\" })} />\n )}\n {step.name === \"code\" && (\n <ReturnsCodeStep\n onVerified={() => dispatch({ type: \"AUTHENTICATED\" })}\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n {step.name === \"orders\" && (\n <ReturnsOrderList\n showLogout={!panelToken}\n onSelectOrder={(orderId) =>\n dispatch({ type: \"SELECT_ORDER\", orderId })\n }\n onOpenMyReturns={() => dispatch({ type: \"OPEN_MY_RETURNS\" })}\n />\n )}\n {step.name === \"order\" && (\n <ReturnsOrderDetail\n orderId={step.orderId}\n initialItems={step.items}\n initialNote={step.note}\n onBack={() => dispatch({ type: \"BACK\" })}\n onContinue={({ items, note }) =>\n dispatch({ type: \"REVIEW\", items, note })\n }\n />\n )}\n {step.name === \"confirmation\" && (\n <ReturnsConfirmation\n orderId={step.orderId}\n items={step.items}\n note={step.note}\n onBack={() => dispatch({ type: \"BACK\" })}\n onSubmitted={(returnId) =>\n dispatch({ type: \"SUBMITTED\", returnId })\n }\n />\n )}\n {step.name === \"result\" && (\n <ReturnsResult\n returnId={step.returnId}\n onContinue={() => dispatch({ type: \"CONTINUE\" })}\n onOpenMyReturns={() => dispatch({ type: \"OPEN_MY_RETURNS\" })}\n />\n )}\n {step.name === \"myReturns\" && (\n <ReturnsMyReturnsList\n onSelectReturn={(returnId) =>\n dispatch({ type: \"SELECT_RETURN\", returnId })\n }\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n {step.name === \"myReturn\" && (\n <ReturnsMyReturnDetail\n returnId={step.returnId}\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n </div>\n );\n}\n\n/**\n * Customer return flow: email, code, orders, line selection, confirmation and\n * result, plus the list of earlier returns. It is `ReturnsProvider` with the\n * default step router; compose your own page from the step components to\n * change the layout.\n *\n * ```tsx\n * <BitsnapReturns projectID=\"…\" appearance={brand} texts={{ emailStepTitle: \"Return a product\" }} />\n * ```\n */\nexport function BitsnapReturns(props: BitsnapReturnsProps) {\n return (\n <ReturnsProvider {...props}>\n <ReturnsRouter panelToken={props.panelAccessToken != null && props.panelAccessToken !== \"\"} />\n </ReturnsProvider>\n );\n}\n"]}