bitsnap-react 1.11.0 → 1.11.1

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 (61) hide show
  1. package/dist/CartProvider-QY2DMNCC.js +2 -0
  2. package/dist/{CartProvider-Q3CIVK5K.js.map → CartProvider-QY2DMNCC.js.map} +1 -1
  3. package/dist/CartProvider-XMHPQRWC.mjs +2 -0
  4. package/dist/analytics.js +1 -1
  5. package/dist/analytics.mjs +1 -1
  6. package/dist/catalog.js +1 -1
  7. package/dist/catalog.mjs +1 -1
  8. package/dist/{chunk-HG4YOJWE.mjs → chunk-2PK36NGB.mjs} +2 -2
  9. package/dist/{chunk-GPNALARZ.mjs → chunk-2X32DDUM.mjs} +2 -2
  10. package/dist/{chunk-VQQBBSK2.js → chunk-3IVLQILF.js} +2 -2
  11. package/dist/{chunk-VQQBBSK2.js.map → chunk-3IVLQILF.js.map} +1 -1
  12. package/dist/{chunk-C5Q7DGCD.mjs → chunk-DWRBPP32.mjs} +2 -2
  13. package/dist/{chunk-C5RMHUOG.mjs → chunk-ETGHIHWR.mjs} +2 -2
  14. package/dist/{chunk-CUQ2PNCJ.js → chunk-FBTYZHXM.js} +3 -3
  15. package/dist/{chunk-CUQ2PNCJ.js.map → chunk-FBTYZHXM.js.map} +1 -1
  16. package/dist/{chunk-EZWH6BB2.mjs → chunk-G2UOTVS5.mjs} +2 -2
  17. package/dist/{chunk-H3YP2QPV.mjs → chunk-HWQNT6XU.mjs} +2 -2
  18. package/dist/{chunk-T57337WD.mjs → chunk-IJLHU2MA.mjs} +2 -2
  19. package/dist/{chunk-T57337WD.mjs.map → chunk-IJLHU2MA.mjs.map} +1 -1
  20. package/dist/{chunk-XQ43IC4M.mjs → chunk-JUDR4EZA.mjs} +2 -2
  21. package/dist/{chunk-7RGH57QG.js → chunk-Q25D7OAO.js} +2 -2
  22. package/dist/{chunk-7RGH57QG.js.map → chunk-Q25D7OAO.js.map} +1 -1
  23. package/dist/{chunk-YFETPEI6.js → chunk-UCL4Y7L3.js} +2 -2
  24. package/dist/{chunk-YFETPEI6.js.map → chunk-UCL4Y7L3.js.map} +1 -1
  25. package/dist/{chunk-ASNUY3EU.js → chunk-UFIOJGJZ.js} +2 -2
  26. package/dist/{chunk-ASNUY3EU.js.map → chunk-UFIOJGJZ.js.map} +1 -1
  27. package/dist/{chunk-ELGNOAH4.js → chunk-VPBFEAFQ.js} +2 -2
  28. package/dist/{chunk-ELGNOAH4.js.map → chunk-VPBFEAFQ.js.map} +1 -1
  29. package/dist/{chunk-GT3OH55Y.js → chunk-WGJTXDIS.js} +2 -2
  30. package/dist/{chunk-GT3OH55Y.js.map → chunk-WGJTXDIS.js.map} +1 -1
  31. package/dist/{chunk-PUYK4YHE.js → chunk-YBGAYEJQ.js} +2 -2
  32. package/dist/{chunk-PUYK4YHE.js.map → chunk-YBGAYEJQ.js.map} +1 -1
  33. package/dist/consent.js +15 -14
  34. package/dist/consent.js.map +1 -1
  35. package/dist/consent.mjs +15 -14
  36. package/dist/consent.mjs.map +1 -1
  37. package/dist/course.js +1 -1
  38. package/dist/course.mjs +1 -1
  39. package/dist/embed/analytics.js +1 -1
  40. package/dist/embed/consent.js +11 -10
  41. package/dist/index.js +1 -1
  42. package/dist/index.mjs +1 -1
  43. package/dist/methods-ALO22YWQ.mjs +2 -0
  44. package/dist/methods-ZBX4BTDE.js +2 -0
  45. package/dist/{methods-CHNMFVFV.js.map → methods-ZBX4BTDE.js.map} +1 -1
  46. package/dist/returns.js +1 -1
  47. package/dist/returns.mjs +1 -1
  48. package/package.json +1 -1
  49. package/dist/CartProvider-ONIOELW5.mjs +0 -2
  50. package/dist/CartProvider-Q3CIVK5K.js +0 -2
  51. package/dist/methods-C5HWYPPN.mjs +0 -2
  52. package/dist/methods-CHNMFVFV.js +0 -2
  53. /package/dist/{CartProvider-ONIOELW5.mjs.map → CartProvider-XMHPQRWC.mjs.map} +0 -0
  54. /package/dist/{chunk-HG4YOJWE.mjs.map → chunk-2PK36NGB.mjs.map} +0 -0
  55. /package/dist/{chunk-GPNALARZ.mjs.map → chunk-2X32DDUM.mjs.map} +0 -0
  56. /package/dist/{chunk-C5Q7DGCD.mjs.map → chunk-DWRBPP32.mjs.map} +0 -0
  57. /package/dist/{chunk-C5RMHUOG.mjs.map → chunk-ETGHIHWR.mjs.map} +0 -0
  58. /package/dist/{chunk-EZWH6BB2.mjs.map → chunk-G2UOTVS5.mjs.map} +0 -0
  59. /package/dist/{chunk-H3YP2QPV.mjs.map → chunk-HWQNT6XU.mjs.map} +0 -0
  60. /package/dist/{chunk-XQ43IC4M.mjs.map → chunk-JUDR4EZA.mjs.map} +0 -0
  61. /package/dist/{methods-C5HWYPPN.mjs.map → methods-ALO22YWQ.mjs.map} +0 -0
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFBTYZHXMjs = require('./chunk-FBTYZHXM.js');require('./chunk-UCL4Y7L3.js');require('./chunk-KOYBZORL.js');require('./chunk-3IVLQILF.js');require('./chunk-UFIOJGJZ.js');var _chunkQ25D7OAOjs = require('./chunk-Q25D7OAO.js');require('./chunk-WGJTXDIS.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.MARKETING_AGREEMENT_ID = _chunkFBTYZHXMjs.D; exports.bitsnapProjectID = _chunkFBTYZHXMjs.E; exports.default = _chunkFBTYZHXMjs.I; exports.getCheckoutMethods = _chunkFBTYZHXMjs.J; exports.getLocale = _chunkQ25D7OAOjs.m; exports.getProjectID = _chunkFBTYZHXMjs.G; exports.setLocale = _chunkQ25D7OAOjs.l; exports.setProjectID = _chunkFBTYZHXMjs.F; exports.useCartProvider = _chunkFBTYZHXMjs.H;
2
+ //# sourceMappingURL=CartProvider-QY2DMNCC.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/CartProvider-Q3CIVK5K.js"],"names":[],"mappings":"AAAA,+HAAiF,+BAA4B,+BAA4B,+BAA4B,+BAA4B,sDAA+C,+BAA4B,+BAA4B,+BAA4B,8YAAsL","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/CartProvider-Q3CIVK5K.js"}
1
+ {"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/CartProvider-QY2DMNCC.js"],"names":[],"mappings":"AAAA,+HAAiF,+BAA4B,+BAA4B,+BAA4B,+BAA4B,sDAA+C,+BAA4B,+BAA4B,+BAA4B,8YAAsL","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/CartProvider-QY2DMNCC.js"}
@@ -0,0 +1,2 @@
1
+ import{D as c,E as d,F as e,G as f,H as g,I as h,J as i}from"./chunk-2PK36NGB.mjs";import"./chunk-HWQNT6XU.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-ETGHIHWR.mjs";import"./chunk-DWRBPP32.mjs";import{l as a,m as b}from"./chunk-G2UOTVS5.mjs";import"./chunk-IJLHU2MA.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{c as MARKETING_AGREEMENT_ID,d as bitsnapProjectID,h as default,i as getCheckoutMethods,b as getLocale,f as getProjectID,a as setLocale,e as setProjectID,g as useCartProvider};
2
+ //# sourceMappingURL=CartProvider-XMHPQRWC.mjs.map
package/dist/analytics.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGT3OH55Yjs = require('./chunk-GT3OH55Y.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.BitsnapAnalyticsProvider = _chunkGT3OH55Yjs.i; exports.DEFAULT_ENDPOINT = _chunkGT3OH55Yjs.c; exports.InstrumentProvider = _chunkGT3OH55Yjs.l; exports.createTracker = _chunkGT3OH55Yjs.d; exports.getTracker = _chunkGT3OH55Yjs.f; exports.initTracker = _chunkGT3OH55Yjs.e; exports.noopInstrument = _chunkGT3OH55Yjs.k; exports.resetTracker = _chunkGT3OH55Yjs.g; exports.scoreBucket = _chunkGT3OH55Yjs.r; exports.startAutoPageViews = _chunkGT3OH55Yjs.b; exports.useAnalytics = _chunkGT3OH55Yjs.j; exports.useInstrument = _chunkGT3OH55Yjs.n; exports.useInstrumentContext = _chunkGT3OH55Yjs.m;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkWGJTXDISjs = require('./chunk-WGJTXDIS.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.BitsnapAnalyticsProvider = _chunkWGJTXDISjs.i; exports.DEFAULT_ENDPOINT = _chunkWGJTXDISjs.c; exports.InstrumentProvider = _chunkWGJTXDISjs.l; exports.createTracker = _chunkWGJTXDISjs.d; exports.getTracker = _chunkWGJTXDISjs.f; exports.initTracker = _chunkWGJTXDISjs.e; exports.noopInstrument = _chunkWGJTXDISjs.k; exports.resetTracker = _chunkWGJTXDISjs.g; exports.scoreBucket = _chunkWGJTXDISjs.r; exports.startAutoPageViews = _chunkWGJTXDISjs.b; exports.useAnalytics = _chunkWGJTXDISjs.j; exports.useInstrument = _chunkWGJTXDISjs.n; exports.useInstrumentContext = _chunkWGJTXDISjs.m;
2
2
  //# sourceMappingURL=analytics.js.map
@@ -1,2 +1,2 @@
1
- import{b as e,c as t,d as r,e as n,f as o,g as a,i as s,j as p,k as c,l as i,m,n as u,r as v}from"./chunk-T57337WD.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{s as BitsnapAnalyticsProvider,t as DEFAULT_ENDPOINT,i as InstrumentProvider,r as createTracker,o as getTracker,n as initTracker,c as noopInstrument,a as resetTracker,v as scoreBucket,e as startAutoPageViews,p as useAnalytics,u as useInstrument,m as useInstrumentContext};
1
+ import{b as e,c as t,d as r,e as n,f as o,g as a,i as s,j as p,k as c,l as i,m,n as u,r as v}from"./chunk-IJLHU2MA.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{s as BitsnapAnalyticsProvider,t as DEFAULT_ENDPOINT,i as InstrumentProvider,r as createTracker,o as getTracker,n as initTracker,c as noopInstrument,a as resetTracker,v as scoreBucket,e as startAutoPageViews,p as useAnalytics,u as useInstrument,m as useInstrumentContext};
2
2
  //# sourceMappingURL=analytics.mjs.map
package/dist/catalog.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPUYK4YHEjs = require('./chunk-PUYK4YHE.js');require('./chunk-KOYBZORL.js');require('./chunk-7RGH57QG.js');require('./chunk-GT3OH55Y.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.PRODUCT_LIST_SLOT_NAMES = _chunkPUYK4YHEjs.a; exports.ProductList = _chunkPUYK4YHEjs.d; exports.formatProductPrice = _chunkPUYK4YHEjs.b; exports.useProducts = _chunkPUYK4YHEjs.c;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYBGAYEJQjs = require('./chunk-YBGAYEJQ.js');require('./chunk-KOYBZORL.js');require('./chunk-Q25D7OAO.js');require('./chunk-WGJTXDIS.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.PRODUCT_LIST_SLOT_NAMES = _chunkYBGAYEJQjs.a; exports.ProductList = _chunkYBGAYEJQjs.d; exports.formatProductPrice = _chunkYBGAYEJQjs.b; exports.useProducts = _chunkYBGAYEJQjs.c;
2
2
  //# sourceMappingURL=catalog.js.map
package/dist/catalog.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{a as o,b as r,c as e,d as f}from"./chunk-GPNALARZ.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-EZWH6BB2.mjs";import"./chunk-T57337WD.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{o as PRODUCT_LIST_SLOT_NAMES,f as ProductList,r as formatProductPrice,e as useProducts};
1
+ import{a as o,b as r,c as e,d as f}from"./chunk-2X32DDUM.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-G2UOTVS5.mjs";import"./chunk-IJLHU2MA.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{o as PRODUCT_LIST_SLOT_NAMES,f as ProductList,r as formatProductPrice,e as useProducts};
2
2
  //# sourceMappingURL=catalog.mjs.map
@@ -1,4 +1,4 @@
1
- import{A as Nn,a as Ne,g as pn,h as fn,i as yn,j as bn,k as Pn,s as hn,v as vn,w as wn,x as kn,y as xn,z as Cn}from"./chunk-H3YP2QPV.mjs";import{a as Dt,g as Ge,h as $e,j as ge,k as Ve,l as cn,m as dn,n as Te}from"./chunk-C5RMHUOG.mjs";import{a as Ct,b as Nt,c as St,d as It,e as Rt,f as an,j as B,k as De,l as Y,p as ln,q as I,r as lt,t as un,u as Le,v as mn}from"./chunk-C5Q7DGCD.mjs";import{a as kt,b as rn,c as xt,d as w,f as Q,g as sn,h as gn,m as ce}from"./chunk-EZWH6BB2.mjs";import{h as At,l as it,m as st,n as Ae,o as on}from"./chunk-T57337WD.mjs";import{useAutoAnimate as Hr}from"@formkit/auto-animate/react";import{useEffect as Dn,useState as ae}from"react";import{jsx as We}from"react/jsx-runtime";function de({className:e,...t}){return We("div",{"data-slot":"card",className:w("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function ye({className:e,...t}){return We("div",{"data-slot":"card-header",className:w("@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 be({className:e,...t}){return We("div",{"data-slot":"card-title",className:w("leading-none font-semibold",e),...t})}function Tt({className:e,...t}){return We("div",{"data-slot":"card-description",className:w("text-muted-foreground text-sm",e),...t})}function ue({className:e,...t}){return We("div",{"data-slot":"card-content",className:w("px-6",e),...t})}import*as Sn from"react";import{OTPInput as Ur,OTPInputContext as Or}from"input-otp";import{MinusIcon as zr}from"lucide-react";import{jsx as Ee,jsxs as Mr}from"react/jsx-runtime";function In({className:e,containerClassName:t,...r}){return Ee(Ur,{"data-slot":"input-otp",containerClassName:w("flex items-center gap-2 has-disabled:opacity-50",t),className:w("disabled:cursor-not-allowed",e),...r})}function Lt({className:e,...t}){return Ee("div",{"data-slot":"input-otp-group",className:w("flex items-center",e),...t})}function Se({index:e,className:t,...r}){let n=Sn.useContext(Or),{char:a,hasFakeCaret:o,isActive:i}=n?.slots[e]??{};return Mr("div",{"data-slot":"input-otp-slot","data-active":i,className:w("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),...r,children:[a,o&&Ee("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:Ee("div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}function Rn({...e}){return Ee("div",{"data-slot":"input-otp-separator",role:"separator",...e,children:Ee(zr,{})})}import{REGEXP_ONLY_DIGITS as Gr}from"input-otp";import{jsx as Et,jsxs as jr}from"react/jsx-runtime";function _r(){return jr("div",{className:"flex items-center gap-2",children:[Et("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),Et("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),Et("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var V=_r;var Fr="return_url",Ut="__return_url",qr="accessToken";function Ze(e){let t=new URLSearchParams(e).get(Fr);return t?An(t):null}function Je(e){typeof window>"u"||(e?window.sessionStorage.setItem(Ut,e):window.sessionStorage.removeItem(Ut))}function Ue(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(Ut);return e?An(e):null}function Br(e,t){return t.some(r=>{if(e===r)return!0;let n=new URL(r).hostname,a=new URL(e).hostname;return a.endsWith(`.${n}`)||a===n})}function An(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!Br(t.origin,$e())?null:t.toString()}catch{return null}}function Oe(e,t){let r=new URL(e);return r.searchParams.set(qr,t),r.toString()}import{jsx as v,jsxs as E}from"react/jsx-runtime";if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];$e().length===0&&Ge(Array.from(new Set(t)))}var $r=({projectID:e,host:t,reveal:r,email:n,setEmail:a,loginUser:o,isLoginLoading:i,errMsg:c})=>{let{projectID:s,host:y}=ge();if(typeof window<"u"&&Ve(e??s,t??y)!=null)return window.location.href=window.location.href.replaceAll("login",""),null;let[d,k]=ae(!1),x=l=>/^(([^<>()\[\]\\.,;:\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(l.trim())?k(!0):k(!1),u=l=>{let{value:b}=l.target;x(b),a(b)};function h(){r()}function C(l){l.preventDefault(),o()}return v("main",{className:"mx-auto flex max-w-sm flex-1 flex-col justify-center space-y-12",children:v("div",{className:w("flex min-w-sm flex-col gap-6"),children:E(de,{children:[E(ye,{children:[v(be,{className:"text-2xl",children:"Zaloguj si\u0119"}),v(Tt,{children:"Wy\u015Blemy do Ciebie kod na maila, dzi\u0119ki kt\xF3remu si\u0119 zalogujesz."})]}),v(ue,{children:E("form",{onSubmit:C,children:[E("div",{className:"flex flex-col gap-6",children:[E("div",{className:"grid gap-2",children:[v(Ne,{htmlFor:"email",children:"Email"}),v(lt,{id:"email",onChange:u,type:"email",placeholder:"m@example.com",required:!0}),v("span",{className:w(!d&&n.length>0?"font-bold text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!d&&n.length>0?"Nieprawid\u0142owy adres email":"Wpisz sw\xF3j adres email"})]}),E("div",{children:[E(I,{type:"submit",disabled:i,className:"relative w-full",onClick:o,children:[i&&v("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:v(V,{})}),"Zaloguj si\u0119"]}),c.length>0&&v("p",{className:"text-xs font-medium text-red-500",children:c})]})]}),E("div",{className:"mt-4 text-center text-sm",children:["Masz ju\u017C kod?"," ",v("button",{type:"button",onClick:h,className:"underline underline-offset-4",children:"Mam ju\u017C kod"})]})]})})]})})})},Vr=({projectID:e,host:t,email:r,reveal:n,setEmail:a,isLoginLoading:o,loginUserResponse:i,setLoginUserResponse:c,setResponseStatus:s,errMsg:y})=>{let d=st(),{mutateAsync:k,isPending:x}=Y(B.publicApi.userPanelLoginWithCode),[u,h]=ae(""),[C,l]=ae(!1),[b,R]=ae(!1),[F,q]=ae(0),A=U=>/^\d+$/.test(U.trim())?l(!0):l(!1),L=U=>{A(U),h(U)};async function j(){if(R(!0),u.length==0){l(!1);return}let U=parseInt(u),K=await k({code:U}),fe,xe,ne;if(K.result.case==="accessToken"?(l(!0),fe="ok",xe=void 0,ne=K.result.value):(l(!1),fe="error",xe=K.result.value,ne=void 0),fe==="error"&&(l(!1),console.warn("error:",`Kod b\u0142\u0119du: ${xe}`),console.warn("Nieprawid\u0142owy kod, spr\xF3buj ponownie.")),fe==="ok"){d.track("panel_login",{}),ne&&cn(e,ne,r,t);let g=typeof window<"u"?Ue():null;setTimeout(()=>{if(ne&&g){window.location.href=Oe(g,ne);return}window.location.reload()},100)}}function D(){let U=setInterval(()=>{q(K=>K>0?K-1:(clearInterval(U),0))},1e3);return()=>{clearInterval(U)}}Dn(()=>{i?.status==="ok"&&i?.retryIn>0&&(q(i.retryIn),D())},[i]);function H(){a(""),c(null),s("default"),n()}function pe(U){U.preventDefault(),j()}return v("main",{className:"mx-auto flex max-w-md flex-1 flex-col justify-center space-y-8",children:v("div",{className:w("flex min-w-sm flex-col gap-6"),children:E(de,{children:[E(ye,{children:[v(be,{className:"text-2xl",children:"Wpisz kod z maila"}),v(Tt,{children:"Sprawd\u017A czy przypadkiem nie wyl\u0105dowa\u0142 w spamie."})]}),E(ue,{children:[E("form",{onSubmit:pe,className:"flex flex-col gap-6",children:[v("div",{className:"grid gap-2",children:v("div",{className:"my-5 flex w-full items-center justify-center",children:E("div",{className:"flex flex-col gap-2",children:[E(In,{id:"verify-code",maxLength:6,pattern:Gr,onChange:U=>{L(U)},children:[E(Lt,{children:[v(Se,{index:0}),v(Se,{index:1}),v(Se,{index:2})]}),v(Rn,{}),E(Lt,{children:[v(Se,{index:3}),v(Se,{index:4}),v(Se,{index:5})]})]}),v("span",{className:w(!C&&b?"text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!C&&b?u.length==0?"Kod nie mo\u017Ce by\u0107 pusty":"Kod musi sk\u0142ada\u0107 si\u0119 z cyfr":"Wpisz kod z maila"})]})})}),E("div",{children:[E(I,{type:"submit",disabled:o||x,className:"relative w-full",children:[(o||x)&&v("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:v(V,{})}),"Zaloguj si\u0119"]}),y.length>0&&v("p",{className:"text-xs font-medium text-red-500",children:y})]})]}),E("div",{className:"mt-4 text-center text-sm",children:["Nie masz kodu?"," ",v("button",{type:"button",onClick:H,className:"underline underline-offset-4",children:"Wr\xF3\u0107"})]})]})]})})})},Wr=({analytics:e})=>{let{theme:t,allowedReturnOrigins:r,projectID:n,host:a}=ge(),o=Ae(n,e,"panel"),i={"--button-background-color":t?.colors?.brand??"#FFFFFF","--button-background-color-dark":t?.colors?.brandDark??"#000000","--button-text-color":t?.colors?.brandDark??"#000000","--button-text-color-dark":t?.colors?.brand??"#FFFFFF"},[c,s]=ae("login"),[y]=Hr({duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1}),d=()=>s(L=>L==="login"?"verifyCode":"login"),[k,x]=ae(""),[u,h]=ae("default"),[C,l]=ae(null),{mutateAsync:b,isPending:R}=Y(B.publicApi.userPanelLogin),[F,q]=ae("");Dn(()=>{if(typeof window>"u"||window.parent!==window)return;let L=Ze(window.location.search);L&&Je(L);let j=L??Ue();if(!j)return;let D=Ve(n,a);D&&(window.location.href=Oe(j,D))},[r,n,a]);async function A(){q(""),h("default");let L=await b({email:k}),j=L.result.case==="success"?"ok":"error",D=0,H;L.result.case==="success"&&(D=L.result.value.retryIn),j==="error"&&(H="Nieprawid\u0142owy adres email, spr\xF3buj ponownie."),l({status:j,retryIn:D,message:H}),j==="ok"&&c==="login"?d():j==="ok"&&c==="verifyCode"?h("success"):j==="error"&&q(H??"Nieprawid\u0142owy adres email, spr\xF3buj ponownie.")}return v(it,{value:o,children:v("div",{className:"bg-white text-black dark:bg-black dark:text-white",children:E("div",{className:"font-inter flex h-screen w-screen flex-col p-4",style:i,ref:y,children:[E("header",{children:[t?.logoDarkURL&&v("img",{src:t?.logoDarkURL,className:"hidden dark:inline",alt:"Company Logo",draggable:!1}),t?.logoURL&&v("img",{src:t?.logoURL,className:"dark:hidden",alt:"Company Logo",draggable:!1})]}),c==="login"&&v($r,{projectID:n,host:a,reveal:d,email:k,setEmail:x,loginUser:A,isLoginLoading:R,errMsg:F}),c==="verifyCode"&&v(Vr,{projectID:n,host:a,email:k,reveal:d,setEmail:x,loginUser:A,isLoginLoading:R,loginUserResponse:C,setLoginUserResponse:l,responseStatus:u,setResponseStatus:h,errMsg:F})]})})})},Zr=({analytics:e}={})=>v(Wr,{analytics:e});import{useAutoAnimate as oo}from"@formkit/auto-animate/react";import{useEffect as bt,useState as io}from"react";import{useState as Jr,useCallback as Kr,useEffect as Qr}from"react";function Tn(e){let[t,r]=Jr(()=>{if(typeof window>"u")return e;let a=new URLSearchParams(window.location.search),o={};return Object.keys(e).forEach(i=>{let c=a.get(i);if(c!==null)try{o[i]=JSON.parse(c)}catch{o[i]=c}}),{...e,...o}}),n=Kr(a=>{r(o=>{let i={...o,...a};if(typeof window<"u"){let c=new URLSearchParams;Object.keys(i).forEach(y=>{let d=i[y];d!=null&&c.set(y,JSON.stringify(d))});let s=`${window.location.pathname}?${c.toString()}`;window.history.pushState({},"",s)}return i})},[]);return Qr(()=>{let a=()=>{let o=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(c=>{let s=o.get(c);if(s!==null)try{i[c]=JSON.parse(s)}catch{i[c]=s}}),r({...e,...i})};return window.addEventListener("popstate",a),()=>window.removeEventListener("popstate",a)},[e]),[t,n]}function Ln(e,t){if(e!=null)return e;let r=t?.trim();if(!(r==null||r===""))return{tokens:un(r)}}import*as ct from"@radix-ui/react-switch";import{jsx as En}from"react/jsx-runtime";function Un({className:e,...t}){return En(ct.Root,{"data-slot":"switch",className:w("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:En(ct.Thumb,{"data-slot":"switch-thumb",className:w("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")})})}import{useState as Yr}from"react";import{Fragment as ea,jsx as Ke,jsxs as Ot}from"react/jsx-runtime";function Xr({}){let[e,t]=Yr({disableAll:!1});return Ot(ea,{children:[Ke("h3",{className:"text-2xl",children:"Powiadomienia"}),Ke("p",{className:"text-sm text-neutral-500",children:"Zarz\u0105dzaj swoimi powiadomieniami"}),Ke("div",{className:"mt-6",children:Ot("div",{className:"flex items-center space-x-2",children:[Ke(Un,{id:"disable-all-notifications",checked:e.disableAll,onCheckedChange:r=>t(n=>({...n,disableAll:r}))}),Ot(Ne,{htmlFor:"disable-all-notifications",className:"flex flex-col gap-1 text-base",children:["Wszystkie powiadomienia",Ke("span",{className:"text-xs font-normal text-neutral-500 md:text-sm",children:"Ten przycisk mo\u017Ce wy\u0142\u0105czy\u0107 wszystkie powiadomienia"})]})]})})]})}var On=Xr;import{ChevronLeftIcon as ta,ChevronRightIcon as na,MoreHorizontalIcon as ra}from"lucide-react";import{jsx as oe,jsxs as Mt}from"react/jsx-runtime";function zn({className:e,...t}){return oe("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:w("mx-auto flex w-full justify-center",e),...t})}function Mn({className:e,...t}){return oe("ul",{"data-slot":"pagination-content",className:w("flex flex-row items-center gap-1",e),...t})}function Pe({...e}){return oe("li",{"data-slot":"pagination-item",...e})}function ze({className:e,isActive:t,size:r="icon",...n}){return oe("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:w(ln({variant:t?"outline":"ghost",size:r}),e),...n})}function _n({className:e,...t}){return Mt(ze,{"aria-label":"Go to previous page",size:"default",className:w("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[oe(ta,{}),oe("span",{className:"hidden sm:block",children:"Previous"})]})}function jn({className:e,...t}){return Mt(ze,{"aria-label":"Go to next page",size:"default",className:w("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[oe("span",{className:"hidden sm:block",children:"Next"}),oe(na,{})]})}function zt({className:e,...t}){return Mt("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:w("flex size-9 items-center justify-center",e),...t,children:[oe(ra,{className:"size-4"}),oe("span",{className:"sr-only",children:"More pages"})]})}import{useState as aa}from"react";import{Fragment as da,jsx as N,jsxs as W}from"react/jsx-runtime";var oa=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),ia=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t.toUpperCase()}).format(e/100),sa={draft:"Szkic",unpaid:"Nieop\u0142acona",paid:"Op\u0142acona",overdue:"Zaleg\u0142a",cancelled:"Anulowana",completed:"Zako\u0144czone",processing:"Przetwarzane",refunded:"Zwr\xF3cone"},la={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 ca({openOrderDetails:e,projectID:t,accessToken:r}){let[n,a]=aa(0),o=20,{data:i,isFetching:c}=De(B.publicApi.getOrders,{projectId:t,accessToken:r,offset:n,limit:o}),s=i?.orders??[],y=i?.totalCount??0,d=Math.floor(n/o)+1,k=Math.ceil(y/o),x=u=>{a(u)};return W(da,{children:[N("h3",{className:"text-2xl",children:"Historia zam\xF3wie\u0144"}),N("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"Twoje zam\xF3wienia"}),c?N("div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((u,h)=>W("div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[W("div",{className:"flex items-center justify-between",children:[W("div",{className:"space-y-2",children:[N(Le,{className:"h-4 w-24"}),N(Le,{className:"h-3 w-32"})]}),W("div",{className:"space-y-2 text-right",children:[N(Le,{className:"ml-auto h-4 w-16"}),N(Le,{className:"ml-auto h-3 w-12"})]})]}),N("div",{className:"mt-3",children:N(Le,{className:"h-3 w-40"})})]},h))}):s.length===0?N("div",{className:"mt-6 text-sm text-neutral-400",children:"Brak zam\xF3wie\u0144."}):W("div",{children:[N("div",{className:"mt-6 flex w-full flex-col gap-3",children:s.map(u=>W("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:[W("div",{className:"flex items-center justify-between",children:[W("div",{children:[W("p",{className:"font-medium",children:["Zam\xF3wienie #",u.id]}),N("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:u.customerName||"Klient"})]}),W("div",{className:"text-right",children:[N("p",{className:"font-semibold",children:ia(u.totalAmount,u.currency)}),N("p",{className:`text-xs font-medium ${la[u.status]??"text-neutral-400"}`,children:sa[u.status]??u.status})]})]}),N("div",{className:"mt-2 flex items-center justify-between text-xs text-neutral-500 dark:text-neutral-400",children:W("span",{children:["Data:"," ",u.createdAt?oa(Number(u.createdAt.seconds)):"-"]})})]},u.id))}),k>1&&!c&&N("div",{className:"mt-4 flex justify-center",children:N(zn,{children:W(Mn,{children:[d>1&&N(Pe,{children:N(_n,{onClick:()=>x(n-o)})}),d>2&&N(Pe,{children:N(ze,{onClick:()=>x(0),children:"1"})}),d>3&&N(Pe,{children:N(zt,{})}),[d-1,d,d+1].filter(u=>u>0&&u<=k).map(u=>N(Pe,{children:N(ze,{onClick:()=>x((u-1)*o),isActive:d===u,children:u})},u)),d<k-2&&N(Pe,{children:N(zt,{})}),d<k&&N(Pe,{children:N(ze,{onClick:()=>x((k-1)*o),children:k})}),d<k&&N(Pe,{children:N(jn,{onClick:()=>x(n+o)})})]})})})]})]})}var Fn=ca;import{useState as qn}from"react";import{Fragment as fa,jsx as X,jsxs as he}from"react/jsx-runtime";var Bn=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),ua={active:"Aktywny",cancelled:"Anulowany",paused:"Wstrzymany"},ma={active:"text-green-600",cancelled:"text-red-500",paused:"text-yellow-500"};function pa({projectID:e}){let[t,r]=qn([]),[n,a]=qn(!0);return he(fa,{children:[X("h3",{className:"text-2xl",children:"Plany"}),X("p",{className:"text-sm text-neutral-500",children:"Twoje aktywne subskrypcje"}),n?X("div",{className:"mt-6 text-sm text-neutral-400",children:"\u0141adowanie..."}):t.length===0?X("div",{className:"mt-6 text-sm text-neutral-400",children:"Brak aktywnych plan\xF3w."}):X("div",{className:"mt-6 flex flex-col gap-4",children:t.map(o=>he("div",{className:"rounded-xl bg-white p-5 shadow-sm dark:bg-neutral-800",children:[he("div",{className:"flex items-start justify-between",children:[he("div",{children:[X("p",{className:"font-semibold",children:o.tierName}),o.configName&&X("p",{className:"text-sm text-neutral-500",children:o.configName})]}),X("span",{className:`text-sm font-medium ${ma[o.status]??"text-neutral-500"}`,children:ua[o.status]??o.status})]}),he("div",{className:"mt-3 grid grid-cols-2 gap-2 text-sm text-neutral-600 dark:text-neutral-400",children:[he("div",{children:[X("span",{className:"font-medium",children:"Dzie\u0144 rozliczenia:"})," ",o.billingDay]}),he("div",{children:[X("span",{className:"font-medium",children:"Data startu:"})," ",Bn(o.startDate)]}),o.endDate&&he("div",{children:[X("span",{className:"font-medium",children:"Data zako\u0144czenia:"})," ",Bn(o.endDate)]})]})]},o.id))})]})}var Hn=pa;import{useEffect as ga,useState as _t}from"react";import{jsx as ee,jsxs as Pa}from"react/jsx-runtime";function ya(e,t,r,n){typeof window>"u"||(t&&Te(r,n),window.location.href=e)}function ba({projectID:e,host:t,loginURL:r,screen:n,params:a,setParams:o,setActiveScreen:i}){let{status:c,exchangeError:s}=bn("PanelReturns"),y=yn(),d=c==="anonymous"&&(s==null||pn(s));ga(()=>{d&&ya(r,s!=null,e,t)},[d,r,s,e,t]);let[k,x]=_t("orders"),[u,h]=_t({items:[],note:""}),[C,l]=_t();if(c==="anonymous"&&!d)return Pa("div",{role:"alert",className:"flex flex-col items-start gap-3",children:[ee("p",{className:"text-sm",children:y(fn(s))}),ee(I,{type:"button",onClick:()=>window.location.reload(),children:y("errorRetry")})]});if(c!=="authenticated")return ee(hn,{});let b=R=>{x(R),o({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(n==="return-details"&&a.returnId)return ee(Nn,{returnId:a.returnId,onBack:()=>b("myReturns")});if(k==="myReturns")return ee(Cn,{onBack:()=>b("orders"),onSelectReturn:R=>{o({state:"return-details",returnId:R,orderId:void 0}),i("return-details")}});if(k==="result"&&C!=null)return ee(xn,{returnId:C,onContinue:()=>b("orders"),onOpenMyReturns:()=>b("myReturns")});if(a.orderId){let R=a.orderId;return k==="confirmation"?ee(kn,{orderId:R,items:u.items,note:u.note,onBack:()=>x("orders"),onSubmitted:F=>{l(F),h({items:[],note:""}),x("result"),o({orderId:void 0})}}):ee(wn,{orderId:R,initialItems:u.items.length>0?u.items:void 0,initialNote:u.note,onBack:()=>{h({items:[],note:""}),o({orderId:void 0})},onContinue:F=>{h(F),x("confirmation")}})}return ee(vn,{showLogout:!1,onSelectOrder:R=>{h({items:[],note:""}),x("orders"),o({orderId:R})},onOpenMyReturns:()=>b("myReturns")})}function jt({accessToken:e,appearance:t,texts:r,...n}){return ee(Pn,{projectID:n.projectID,host:n.host,appearance:t,texts:r,panelAccessToken:e,children:ee(ba,{...n})})}import{useState as Ea}from"react";import{jsx as ka}from"react/jsx-runtime";var ha=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,va=e=>[...e.matchAll(ha)].map(r=>({url:r[0],startIndex:r.index,endIndex:r.index+r[0].length-1})),wa=(e,t)=>{let r="",n=0;t.sort((a,o)=>a.startIndex-o.startIndex);for(let{startIndex:a,endIndex:o,replacementText:i}of t)r+=e.slice(n,a),r+=i,n=o+1;return r+=e.slice(n),r},Gn=e=>{let t=va(e);return ka("p",{dangerouslySetInnerHTML:{__html:wa(e,t.map(r=>(r.replacementText=`<a key=${r.url} href=${r.url} style="text-decoration: underline;" target="_blank">
1
+ import{A as Nn,a as Ne,g as pn,h as fn,i as yn,j as bn,k as Pn,s as hn,v as vn,w as wn,x as kn,y as xn,z as Cn}from"./chunk-HWQNT6XU.mjs";import{a as Dt,g as Ge,h as $e,j as ge,k as Ve,l as cn,m as dn,n as Te}from"./chunk-ETGHIHWR.mjs";import{a as Ct,b as Nt,c as St,d as It,e as Rt,f as an,j as B,k as De,l as Y,p as ln,q as I,r as lt,t as un,u as Le,v as mn}from"./chunk-DWRBPP32.mjs";import{a as kt,b as rn,c as xt,d as w,f as Q,g as sn,h as gn,m as ce}from"./chunk-G2UOTVS5.mjs";import{h as At,l as it,m as st,n as Ae,o as on}from"./chunk-IJLHU2MA.mjs";import{useAutoAnimate as Hr}from"@formkit/auto-animate/react";import{useEffect as Dn,useState as ae}from"react";import{jsx as We}from"react/jsx-runtime";function de({className:e,...t}){return We("div",{"data-slot":"card",className:w("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function ye({className:e,...t}){return We("div",{"data-slot":"card-header",className:w("@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 be({className:e,...t}){return We("div",{"data-slot":"card-title",className:w("leading-none font-semibold",e),...t})}function Tt({className:e,...t}){return We("div",{"data-slot":"card-description",className:w("text-muted-foreground text-sm",e),...t})}function ue({className:e,...t}){return We("div",{"data-slot":"card-content",className:w("px-6",e),...t})}import*as Sn from"react";import{OTPInput as Ur,OTPInputContext as Or}from"input-otp";import{MinusIcon as zr}from"lucide-react";import{jsx as Ee,jsxs as Mr}from"react/jsx-runtime";function In({className:e,containerClassName:t,...r}){return Ee(Ur,{"data-slot":"input-otp",containerClassName:w("flex items-center gap-2 has-disabled:opacity-50",t),className:w("disabled:cursor-not-allowed",e),...r})}function Lt({className:e,...t}){return Ee("div",{"data-slot":"input-otp-group",className:w("flex items-center",e),...t})}function Se({index:e,className:t,...r}){let n=Sn.useContext(Or),{char:a,hasFakeCaret:o,isActive:i}=n?.slots[e]??{};return Mr("div",{"data-slot":"input-otp-slot","data-active":i,className:w("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),...r,children:[a,o&&Ee("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:Ee("div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}function Rn({...e}){return Ee("div",{"data-slot":"input-otp-separator",role:"separator",...e,children:Ee(zr,{})})}import{REGEXP_ONLY_DIGITS as Gr}from"input-otp";import{jsx as Et,jsxs as jr}from"react/jsx-runtime";function _r(){return jr("div",{className:"flex items-center gap-2",children:[Et("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),Et("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),Et("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var V=_r;var Fr="return_url",Ut="__return_url",qr="accessToken";function Ze(e){let t=new URLSearchParams(e).get(Fr);return t?An(t):null}function Je(e){typeof window>"u"||(e?window.sessionStorage.setItem(Ut,e):window.sessionStorage.removeItem(Ut))}function Ue(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(Ut);return e?An(e):null}function Br(e,t){return t.some(r=>{if(e===r)return!0;let n=new URL(r).hostname,a=new URL(e).hostname;return a.endsWith(`.${n}`)||a===n})}function An(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!Br(t.origin,$e())?null:t.toString()}catch{return null}}function Oe(e,t){let r=new URL(e);return r.searchParams.set(qr,t),r.toString()}import{jsx as v,jsxs as E}from"react/jsx-runtime";if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];$e().length===0&&Ge(Array.from(new Set(t)))}var $r=({projectID:e,host:t,reveal:r,email:n,setEmail:a,loginUser:o,isLoginLoading:i,errMsg:c})=>{let{projectID:s,host:y}=ge();if(typeof window<"u"&&Ve(e??s,t??y)!=null)return window.location.href=window.location.href.replaceAll("login",""),null;let[d,k]=ae(!1),x=l=>/^(([^<>()\[\]\\.,;:\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(l.trim())?k(!0):k(!1),u=l=>{let{value:b}=l.target;x(b),a(b)};function h(){r()}function C(l){l.preventDefault(),o()}return v("main",{className:"mx-auto flex max-w-sm flex-1 flex-col justify-center space-y-12",children:v("div",{className:w("flex min-w-sm flex-col gap-6"),children:E(de,{children:[E(ye,{children:[v(be,{className:"text-2xl",children:"Zaloguj si\u0119"}),v(Tt,{children:"Wy\u015Blemy do Ciebie kod na maila, dzi\u0119ki kt\xF3remu si\u0119 zalogujesz."})]}),v(ue,{children:E("form",{onSubmit:C,children:[E("div",{className:"flex flex-col gap-6",children:[E("div",{className:"grid gap-2",children:[v(Ne,{htmlFor:"email",children:"Email"}),v(lt,{id:"email",onChange:u,type:"email",placeholder:"m@example.com",required:!0}),v("span",{className:w(!d&&n.length>0?"font-bold text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!d&&n.length>0?"Nieprawid\u0142owy adres email":"Wpisz sw\xF3j adres email"})]}),E("div",{children:[E(I,{type:"submit",disabled:i,className:"relative w-full",onClick:o,children:[i&&v("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:v(V,{})}),"Zaloguj si\u0119"]}),c.length>0&&v("p",{className:"text-xs font-medium text-red-500",children:c})]})]}),E("div",{className:"mt-4 text-center text-sm",children:["Masz ju\u017C kod?"," ",v("button",{type:"button",onClick:h,className:"underline underline-offset-4",children:"Mam ju\u017C kod"})]})]})})]})})})},Vr=({projectID:e,host:t,email:r,reveal:n,setEmail:a,isLoginLoading:o,loginUserResponse:i,setLoginUserResponse:c,setResponseStatus:s,errMsg:y})=>{let d=st(),{mutateAsync:k,isPending:x}=Y(B.publicApi.userPanelLoginWithCode),[u,h]=ae(""),[C,l]=ae(!1),[b,R]=ae(!1),[F,q]=ae(0),A=U=>/^\d+$/.test(U.trim())?l(!0):l(!1),L=U=>{A(U),h(U)};async function j(){if(R(!0),u.length==0){l(!1);return}let U=parseInt(u),K=await k({code:U}),fe,xe,ne;if(K.result.case==="accessToken"?(l(!0),fe="ok",xe=void 0,ne=K.result.value):(l(!1),fe="error",xe=K.result.value,ne=void 0),fe==="error"&&(l(!1),console.warn("error:",`Kod b\u0142\u0119du: ${xe}`),console.warn("Nieprawid\u0142owy kod, spr\xF3buj ponownie.")),fe==="ok"){d.track("panel_login",{}),ne&&cn(e,ne,r,t);let g=typeof window<"u"?Ue():null;setTimeout(()=>{if(ne&&g){window.location.href=Oe(g,ne);return}window.location.reload()},100)}}function D(){let U=setInterval(()=>{q(K=>K>0?K-1:(clearInterval(U),0))},1e3);return()=>{clearInterval(U)}}Dn(()=>{i?.status==="ok"&&i?.retryIn>0&&(q(i.retryIn),D())},[i]);function H(){a(""),c(null),s("default"),n()}function pe(U){U.preventDefault(),j()}return v("main",{className:"mx-auto flex max-w-md flex-1 flex-col justify-center space-y-8",children:v("div",{className:w("flex min-w-sm flex-col gap-6"),children:E(de,{children:[E(ye,{children:[v(be,{className:"text-2xl",children:"Wpisz kod z maila"}),v(Tt,{children:"Sprawd\u017A czy przypadkiem nie wyl\u0105dowa\u0142 w spamie."})]}),E(ue,{children:[E("form",{onSubmit:pe,className:"flex flex-col gap-6",children:[v("div",{className:"grid gap-2",children:v("div",{className:"my-5 flex w-full items-center justify-center",children:E("div",{className:"flex flex-col gap-2",children:[E(In,{id:"verify-code",maxLength:6,pattern:Gr,onChange:U=>{L(U)},children:[E(Lt,{children:[v(Se,{index:0}),v(Se,{index:1}),v(Se,{index:2})]}),v(Rn,{}),E(Lt,{children:[v(Se,{index:3}),v(Se,{index:4}),v(Se,{index:5})]})]}),v("span",{className:w(!C&&b?"text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!C&&b?u.length==0?"Kod nie mo\u017Ce by\u0107 pusty":"Kod musi sk\u0142ada\u0107 si\u0119 z cyfr":"Wpisz kod z maila"})]})})}),E("div",{children:[E(I,{type:"submit",disabled:o||x,className:"relative w-full",children:[(o||x)&&v("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:v(V,{})}),"Zaloguj si\u0119"]}),y.length>0&&v("p",{className:"text-xs font-medium text-red-500",children:y})]})]}),E("div",{className:"mt-4 text-center text-sm",children:["Nie masz kodu?"," ",v("button",{type:"button",onClick:H,className:"underline underline-offset-4",children:"Wr\xF3\u0107"})]})]})]})})})},Wr=({analytics:e})=>{let{theme:t,allowedReturnOrigins:r,projectID:n,host:a}=ge(),o=Ae(n,e,"panel"),i={"--button-background-color":t?.colors?.brand??"#FFFFFF","--button-background-color-dark":t?.colors?.brandDark??"#000000","--button-text-color":t?.colors?.brandDark??"#000000","--button-text-color-dark":t?.colors?.brand??"#FFFFFF"},[c,s]=ae("login"),[y]=Hr({duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1}),d=()=>s(L=>L==="login"?"verifyCode":"login"),[k,x]=ae(""),[u,h]=ae("default"),[C,l]=ae(null),{mutateAsync:b,isPending:R}=Y(B.publicApi.userPanelLogin),[F,q]=ae("");Dn(()=>{if(typeof window>"u"||window.parent!==window)return;let L=Ze(window.location.search);L&&Je(L);let j=L??Ue();if(!j)return;let D=Ve(n,a);D&&(window.location.href=Oe(j,D))},[r,n,a]);async function A(){q(""),h("default");let L=await b({email:k}),j=L.result.case==="success"?"ok":"error",D=0,H;L.result.case==="success"&&(D=L.result.value.retryIn),j==="error"&&(H="Nieprawid\u0142owy adres email, spr\xF3buj ponownie."),l({status:j,retryIn:D,message:H}),j==="ok"&&c==="login"?d():j==="ok"&&c==="verifyCode"?h("success"):j==="error"&&q(H??"Nieprawid\u0142owy adres email, spr\xF3buj ponownie.")}return v(it,{value:o,children:v("div",{className:"bg-white text-black dark:bg-black dark:text-white",children:E("div",{className:"font-inter flex h-screen w-screen flex-col p-4",style:i,ref:y,children:[E("header",{children:[t?.logoDarkURL&&v("img",{src:t?.logoDarkURL,className:"hidden dark:inline",alt:"Company Logo",draggable:!1}),t?.logoURL&&v("img",{src:t?.logoURL,className:"dark:hidden",alt:"Company Logo",draggable:!1})]}),c==="login"&&v($r,{projectID:n,host:a,reveal:d,email:k,setEmail:x,loginUser:A,isLoginLoading:R,errMsg:F}),c==="verifyCode"&&v(Vr,{projectID:n,host:a,email:k,reveal:d,setEmail:x,loginUser:A,isLoginLoading:R,loginUserResponse:C,setLoginUserResponse:l,responseStatus:u,setResponseStatus:h,errMsg:F})]})})})},Zr=({analytics:e}={})=>v(Wr,{analytics:e});import{useAutoAnimate as oo}from"@formkit/auto-animate/react";import{useEffect as bt,useState as io}from"react";import{useState as Jr,useCallback as Kr,useEffect as Qr}from"react";function Tn(e){let[t,r]=Jr(()=>{if(typeof window>"u")return e;let a=new URLSearchParams(window.location.search),o={};return Object.keys(e).forEach(i=>{let c=a.get(i);if(c!==null)try{o[i]=JSON.parse(c)}catch{o[i]=c}}),{...e,...o}}),n=Kr(a=>{r(o=>{let i={...o,...a};if(typeof window<"u"){let c=new URLSearchParams;Object.keys(i).forEach(y=>{let d=i[y];d!=null&&c.set(y,JSON.stringify(d))});let s=`${window.location.pathname}?${c.toString()}`;window.history.pushState({},"",s)}return i})},[]);return Qr(()=>{let a=()=>{let o=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(c=>{let s=o.get(c);if(s!==null)try{i[c]=JSON.parse(s)}catch{i[c]=s}}),r({...e,...i})};return window.addEventListener("popstate",a),()=>window.removeEventListener("popstate",a)},[e]),[t,n]}function Ln(e,t){if(e!=null)return e;let r=t?.trim();if(!(r==null||r===""))return{tokens:un(r)}}import*as ct from"@radix-ui/react-switch";import{jsx as En}from"react/jsx-runtime";function Un({className:e,...t}){return En(ct.Root,{"data-slot":"switch",className:w("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:En(ct.Thumb,{"data-slot":"switch-thumb",className:w("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")})})}import{useState as Yr}from"react";import{Fragment as ea,jsx as Ke,jsxs as Ot}from"react/jsx-runtime";function Xr({}){let[e,t]=Yr({disableAll:!1});return Ot(ea,{children:[Ke("h3",{className:"text-2xl",children:"Powiadomienia"}),Ke("p",{className:"text-sm text-neutral-500",children:"Zarz\u0105dzaj swoimi powiadomieniami"}),Ke("div",{className:"mt-6",children:Ot("div",{className:"flex items-center space-x-2",children:[Ke(Un,{id:"disable-all-notifications",checked:e.disableAll,onCheckedChange:r=>t(n=>({...n,disableAll:r}))}),Ot(Ne,{htmlFor:"disable-all-notifications",className:"flex flex-col gap-1 text-base",children:["Wszystkie powiadomienia",Ke("span",{className:"text-xs font-normal text-neutral-500 md:text-sm",children:"Ten przycisk mo\u017Ce wy\u0142\u0105czy\u0107 wszystkie powiadomienia"})]})]})})]})}var On=Xr;import{ChevronLeftIcon as ta,ChevronRightIcon as na,MoreHorizontalIcon as ra}from"lucide-react";import{jsx as oe,jsxs as Mt}from"react/jsx-runtime";function zn({className:e,...t}){return oe("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:w("mx-auto flex w-full justify-center",e),...t})}function Mn({className:e,...t}){return oe("ul",{"data-slot":"pagination-content",className:w("flex flex-row items-center gap-1",e),...t})}function Pe({...e}){return oe("li",{"data-slot":"pagination-item",...e})}function ze({className:e,isActive:t,size:r="icon",...n}){return oe("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:w(ln({variant:t?"outline":"ghost",size:r}),e),...n})}function _n({className:e,...t}){return Mt(ze,{"aria-label":"Go to previous page",size:"default",className:w("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[oe(ta,{}),oe("span",{className:"hidden sm:block",children:"Previous"})]})}function jn({className:e,...t}){return Mt(ze,{"aria-label":"Go to next page",size:"default",className:w("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[oe("span",{className:"hidden sm:block",children:"Next"}),oe(na,{})]})}function zt({className:e,...t}){return Mt("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:w("flex size-9 items-center justify-center",e),...t,children:[oe(ra,{className:"size-4"}),oe("span",{className:"sr-only",children:"More pages"})]})}import{useState as aa}from"react";import{Fragment as da,jsx as N,jsxs as W}from"react/jsx-runtime";var oa=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),ia=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t.toUpperCase()}).format(e/100),sa={draft:"Szkic",unpaid:"Nieop\u0142acona",paid:"Op\u0142acona",overdue:"Zaleg\u0142a",cancelled:"Anulowana",completed:"Zako\u0144czone",processing:"Przetwarzane",refunded:"Zwr\xF3cone"},la={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 ca({openOrderDetails:e,projectID:t,accessToken:r}){let[n,a]=aa(0),o=20,{data:i,isFetching:c}=De(B.publicApi.getOrders,{projectId:t,accessToken:r,offset:n,limit:o}),s=i?.orders??[],y=i?.totalCount??0,d=Math.floor(n/o)+1,k=Math.ceil(y/o),x=u=>{a(u)};return W(da,{children:[N("h3",{className:"text-2xl",children:"Historia zam\xF3wie\u0144"}),N("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"Twoje zam\xF3wienia"}),c?N("div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((u,h)=>W("div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[W("div",{className:"flex items-center justify-between",children:[W("div",{className:"space-y-2",children:[N(Le,{className:"h-4 w-24"}),N(Le,{className:"h-3 w-32"})]}),W("div",{className:"space-y-2 text-right",children:[N(Le,{className:"ml-auto h-4 w-16"}),N(Le,{className:"ml-auto h-3 w-12"})]})]}),N("div",{className:"mt-3",children:N(Le,{className:"h-3 w-40"})})]},h))}):s.length===0?N("div",{className:"mt-6 text-sm text-neutral-400",children:"Brak zam\xF3wie\u0144."}):W("div",{children:[N("div",{className:"mt-6 flex w-full flex-col gap-3",children:s.map(u=>W("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:[W("div",{className:"flex items-center justify-between",children:[W("div",{children:[W("p",{className:"font-medium",children:["Zam\xF3wienie #",u.id]}),N("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:u.customerName||"Klient"})]}),W("div",{className:"text-right",children:[N("p",{className:"font-semibold",children:ia(u.totalAmount,u.currency)}),N("p",{className:`text-xs font-medium ${la[u.status]??"text-neutral-400"}`,children:sa[u.status]??u.status})]})]}),N("div",{className:"mt-2 flex items-center justify-between text-xs text-neutral-500 dark:text-neutral-400",children:W("span",{children:["Data:"," ",u.createdAt?oa(Number(u.createdAt.seconds)):"-"]})})]},u.id))}),k>1&&!c&&N("div",{className:"mt-4 flex justify-center",children:N(zn,{children:W(Mn,{children:[d>1&&N(Pe,{children:N(_n,{onClick:()=>x(n-o)})}),d>2&&N(Pe,{children:N(ze,{onClick:()=>x(0),children:"1"})}),d>3&&N(Pe,{children:N(zt,{})}),[d-1,d,d+1].filter(u=>u>0&&u<=k).map(u=>N(Pe,{children:N(ze,{onClick:()=>x((u-1)*o),isActive:d===u,children:u})},u)),d<k-2&&N(Pe,{children:N(zt,{})}),d<k&&N(Pe,{children:N(ze,{onClick:()=>x((k-1)*o),children:k})}),d<k&&N(Pe,{children:N(jn,{onClick:()=>x(n+o)})})]})})})]})]})}var Fn=ca;import{useState as qn}from"react";import{Fragment as fa,jsx as X,jsxs as he}from"react/jsx-runtime";var Bn=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),ua={active:"Aktywny",cancelled:"Anulowany",paused:"Wstrzymany"},ma={active:"text-green-600",cancelled:"text-red-500",paused:"text-yellow-500"};function pa({projectID:e}){let[t,r]=qn([]),[n,a]=qn(!0);return he(fa,{children:[X("h3",{className:"text-2xl",children:"Plany"}),X("p",{className:"text-sm text-neutral-500",children:"Twoje aktywne subskrypcje"}),n?X("div",{className:"mt-6 text-sm text-neutral-400",children:"\u0141adowanie..."}):t.length===0?X("div",{className:"mt-6 text-sm text-neutral-400",children:"Brak aktywnych plan\xF3w."}):X("div",{className:"mt-6 flex flex-col gap-4",children:t.map(o=>he("div",{className:"rounded-xl bg-white p-5 shadow-sm dark:bg-neutral-800",children:[he("div",{className:"flex items-start justify-between",children:[he("div",{children:[X("p",{className:"font-semibold",children:o.tierName}),o.configName&&X("p",{className:"text-sm text-neutral-500",children:o.configName})]}),X("span",{className:`text-sm font-medium ${ma[o.status]??"text-neutral-500"}`,children:ua[o.status]??o.status})]}),he("div",{className:"mt-3 grid grid-cols-2 gap-2 text-sm text-neutral-600 dark:text-neutral-400",children:[he("div",{children:[X("span",{className:"font-medium",children:"Dzie\u0144 rozliczenia:"})," ",o.billingDay]}),he("div",{children:[X("span",{className:"font-medium",children:"Data startu:"})," ",Bn(o.startDate)]}),o.endDate&&he("div",{children:[X("span",{className:"font-medium",children:"Data zako\u0144czenia:"})," ",Bn(o.endDate)]})]})]},o.id))})]})}var Hn=pa;import{useEffect as ga,useState as _t}from"react";import{jsx as ee,jsxs as Pa}from"react/jsx-runtime";function ya(e,t,r,n){typeof window>"u"||(t&&Te(r,n),window.location.href=e)}function ba({projectID:e,host:t,loginURL:r,screen:n,params:a,setParams:o,setActiveScreen:i}){let{status:c,exchangeError:s}=bn("PanelReturns"),y=yn(),d=c==="anonymous"&&(s==null||pn(s));ga(()=>{d&&ya(r,s!=null,e,t)},[d,r,s,e,t]);let[k,x]=_t("orders"),[u,h]=_t({items:[],note:""}),[C,l]=_t();if(c==="anonymous"&&!d)return Pa("div",{role:"alert",className:"flex flex-col items-start gap-3",children:[ee("p",{className:"text-sm",children:y(fn(s))}),ee(I,{type:"button",onClick:()=>window.location.reload(),children:y("errorRetry")})]});if(c!=="authenticated")return ee(hn,{});let b=R=>{x(R),o({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(n==="return-details"&&a.returnId)return ee(Nn,{returnId:a.returnId,onBack:()=>b("myReturns")});if(k==="myReturns")return ee(Cn,{onBack:()=>b("orders"),onSelectReturn:R=>{o({state:"return-details",returnId:R,orderId:void 0}),i("return-details")}});if(k==="result"&&C!=null)return ee(xn,{returnId:C,onContinue:()=>b("orders"),onOpenMyReturns:()=>b("myReturns")});if(a.orderId){let R=a.orderId;return k==="confirmation"?ee(kn,{orderId:R,items:u.items,note:u.note,onBack:()=>x("orders"),onSubmitted:F=>{l(F),h({items:[],note:""}),x("result"),o({orderId:void 0})}}):ee(wn,{orderId:R,initialItems:u.items.length>0?u.items:void 0,initialNote:u.note,onBack:()=>{h({items:[],note:""}),o({orderId:void 0})},onContinue:F=>{h(F),x("confirmation")}})}return ee(vn,{showLogout:!1,onSelectOrder:R=>{h({items:[],note:""}),x("orders"),o({orderId:R})},onOpenMyReturns:()=>b("myReturns")})}function jt({accessToken:e,appearance:t,texts:r,...n}){return ee(Pn,{projectID:n.projectID,host:n.host,appearance:t,texts:r,panelAccessToken:e,children:ee(ba,{...n})})}import{useState as Ea}from"react";import{jsx as ka}from"react/jsx-runtime";var ha=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,va=e=>[...e.matchAll(ha)].map(r=>({url:r[0],startIndex:r.index,endIndex:r.index+r[0].length-1})),wa=(e,t)=>{let r="",n=0;t.sort((a,o)=>a.startIndex-o.startIndex);for(let{startIndex:a,endIndex:o,replacementText:i}of t)r+=e.slice(n,a),r+=i,n=o+1;return r+=e.slice(n),r},Gn=e=>{let t=va(e);return ka("p",{dangerouslySetInnerHTML:{__html:wa(e,t.map(r=>(r.replacementText=`<a key=${r.url} href=${r.url} style="text-decoration: underline;" target="_blank">
2
2
  ${r.url}
3
3
  </a>`,r)))}})};import{fromJsonString as Ua,toJsonString as Oa}from"@bufbuild/protobuf";import{useAutoAnimate as Da}from"@formkit/auto-animate/react";import{ChevronLeft as Ta,Download as er}from"lucide-react";import{useEffect as tr,useRef as nr,useState as _e}from"react";import Kn from"hls.js";import{Pause as xa,Play as Ca}from"lucide-react";import{forwardRef as Na,useEffect as dt,useImperativeHandle as Sa,useRef as Qe,useState as Me}from"react";function $n(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="playing")}function Vn(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="paused")}function Wn(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 Zn(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 Jn(){navigator.mediaSession.metadata=null}import{jsx as ie,jsxs as ut}from"react/jsx-runtime";var Ia=Na(({chapters:e,styles:t,updateCurrentTime:r,setCurrentTimeHandler:n,title:a,imageURL:o,uniqueProductID:i,onChapterChange:c},s)=>{let y;(G=>(G[G.Playing=0]="Playing",G[G.Paused=1]="Paused"))(y||={});let[d,k]=Me(1);dt(()=>{switch(d){case 0:$n();break;case 1:Vn();break}},[d]),Sa(s,()=>({selectChapter:p=>{He(p)}}));let[x,u]=Me(void 0),[h,C]=Me(void 0),l=Qe(null),b=Qe(void 0),R=Qe(void 0),F=Qe(null),q=Qe(null),[A,L]=Me(!0),[j,D]=Me(!1),[H,pe]=Me(!Ra());function U(p){p<10||localStorage.setItem(`__player__${i}_${q.current?.id}`,`${p}`)}function K(){let p=localStorage.getItem(`__player__${i}_${q.current?.id}`);if(p!=null)try{let O=parseInt(p);return isNaN(O)||O<0?void 0:O}catch{return}}function fe(){let p=localStorage.getItem(`__player__${i}_last_chapter`);if(p!=null)return p}function xe(p){localStorage.setItem(`__player__${i}_last_chapter`,p)}function ne(p){localStorage.removeItem(`__player__${i}_${p}`)}function g(){l.current!=null&&(l.current.onloadeddata=()=>{if(l.current!=null){if(l.current.readyState<2&&pe(!0),l.current.readyState>=2&&pe(!1),!j){let p=K();p!=null&&ot(p),D(!0)}if(A){L(!1);try{vt()}catch(p){console.log("play error",p)}}}},l.current.onplay=()=>{},l.current.onseeked=()=>{},l.current.onseeking=()=>{},l.current.onpause=()=>{},l.current.onended=()=>{re()},Zn({title:a??"",artwork:o,action:p=>{switch(p.action){case"play":vt();break;case"pause":wt();break;case"seekbackward":at(-15);break;case"seekforward":at(15);break;case"seekto":p.seekTime&&ot(p.seekTime);break;case"stop":wt();break;default:break}}}),Ce())}function re(){if(e==null||e.length==0)return;let p=e.findIndex(G=>G.id==q.current?.id);p==-1||(ne(e[p].id),p+1>=e.length)||He(e[p+1])}function Ce(){Ie(),R.current==null&&(R.current=setTimeout(()=>{Ie(),R.current=void 0,Ce()},500))}function Be(){R.current!=null&&clearTimeout(R.current)}function Ie(){l.current!=null&&(k(l.current.paused?1:0),C(l.current.duration),u(l.current.currentTime),U(l.current.currentTime),Wn(l.current.duration,l.current.currentTime),l.current.networkState===l.current.NETWORK_LOADING&&l.current.readyState<=l.current.HAVE_FUTURE_DATA?pe(!0):pe(!1),r&&r(l.current.currentTime))}function vt(){l.current?.play().then().catch(),Ie()}function wt(){l.current?.pause(),Ie()}function Rr(){if(d===0){wt();return}vt()}function at(p){if(l.current==null)return;let O=l.current.currentTime+p;if(O<0){l.current.currentTime=0;return}if(O>l.current.duration){l.current.currentTime=l.current.duration;return}l.current.currentTime+=p}function ot(p){if(l.current!=null){if(u(p),p<0){l.current.currentTime=0;return}if(p>l.current.duration){l.current.currentTime=l.current.duration;return}l.current.currentTime=p}}function Ar(){l.current!=null&&(l.current.onplay=null,l.current.onseeked=null,l.current.onseeking=null,l.current.onpause=null,l.current.onended=null,l.current.src="",b.current?.destroy())}function tn(p){if(p.length==0)return;let O=fe();if(O==null){He(p[0]);return}let G=p.find(Re=>Re.id==O);if(G==null){He(p[0]);return}He(G)}function He(p){D(!1),L(!0),q.current=p,Dr(p.publicUrl),c?.(p),xe(p.id)}function Dr(p){l.current!=null&&(l.current.canPlayType("application/vnd.apple.mpegurl")?l.current.src=p:Kn.isSupported()&&(b.current==null&&(b.current=new Kn,b.current?.attachMedia(l.current)),b.current?.loadSource(p)))}dt(()=>{l.current!=null&&(g(),tn(e))},[l.current]),dt(()=>{tn(e)},[e]),dt(()=>(n?.(ot),()=>{u(void 0),l.current?.pause(),Ar(),Jn()}),[]);let nn=p=>{let O=Math.floor(p/3600),G=Math.floor(p/60)%60,Re=Math.floor(p%60),Lr=O>0?O<10?`0${O}:`:`${O}:`:"",Er=Re<10?`0${Re}`:`${Re}`;return isNaN(Re)||isNaN(G)||isNaN(O)?"":`${Lr}${G}:${Er}`},Tr=p=>{let O=parseFloat(p.value)/parseFloat(p.max)*100;F.current.style.setProperty("--seek-before-width",O+"%");let G=h*O/100;ot(G)};return ut("div",{id:"audio-player-container",className:"flex flex-col",style:t,ref:F,children:[ie("video",{ref:l,className:"hidden",poster:o,title:a}),ie("input",{type:"range",min:"0",max:h!=null?Math.floor(h).toString():100,value:x??0,onChange:p=>Tr(p.target),className:"w-full"}),ut("section",{className:"flex w-full items-center justify-between text-sm font-medium",children:[ie("span",{id:"current-time",children:nn(x)}),ie("span",{id:"duration",children:nn(h)})]}),ut("div",{className:"mt-6 flex items-center justify-center gap-x-12",children:[ie(I,{variant:"outline",onClick:()=>at(-10),"aria-label":"Rewind 10 Seconds",children:"-10"}),ut(I,{variant:"outline",onClick:Rr,"aria-label":"Play Or Pause",children:[d===1&&ie(Ca,{className:"h-5 w-5"}),d===0&&ie(xa,{className:"h-5 w-5"})]}),ie(I,{variant:"outline",onClick:()=>at(10),"aria-label":"Fast Forward 10 Seconds",children:"+10"})]}),H&&ie("div",{className:"mt-2 flex w-full justify-center",children:ie(V,{})})]})});function Ra(){return navigator.userAgent.toLowerCase().indexOf("safari/")>-1}var Qn=Ia;var Aa={pl:{returnsNavLabel:"Zwroty",openCourse:"Otw\xF3rz kurs"},en:{returnsNavLabel:"Returns",openCourse:"Open the course"}};function Ye(e=ce()){return gn(Aa,e)}import*as mt from"react";import{jsx as Yn}from"react/jsx-runtime";function Xn(){let[e,t]=mt.useState(13);return mt.useEffect(()=>{let r=setTimeout(()=>t(66),500);return()=>clearTimeout(r)},[]),Yn("div",{className:"w-[60%] h-2 bg-gray-200 rounded-full overflow-hidden",children:Yn("div",{className:"h-full bg-blue-600 transition-all duration-300",style:{width:`${e}%`}})})}import{Fragment as pt,jsx as P,jsxs as M}from"react/jsx-runtime";function me(e,...t){console.warn(e,...t)}function Ft(e){console.error(e)}var La=({accessToken:e,product:t,styles:r,reveal:n,onOpenCourse:a})=>{let o=t.productType,i=st(),c=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),s=nr(null),[y]=Da(),[d,k]=_e(null),{mutateAsync:x,isPending:u}=Y(B.publicApi.userPanelGetFileDetails),h=nr(void 0),[C,l]=_e(null),[b,R]=_e(null),[F,q]=_e(!1),{mutateAsync:A,isPending:L}=Y(B.publicApi.userPanelGetAudiobookDetails),{mutateAsync:j,isPending:D}=Y(B.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[H,pe]=_e(null),[U,K]=_e(null);async function fe(){try{let g=await x({accessId:t.accessId,accessToken:e});if(g.result.case==="success"){k(g.result.value.files);return}else me("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),me("Kod b\u0142\u0119du: ",g.result.value)}catch(g){me("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Ft("B\u0142\u0105d podczas pobierania danych:"+g)}}async function xe(){try{let g=await A({accessId:t.accessId,accessToken:e});if(g.result.case==="audiobook"){l(g.result.value);return}else me("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),me("Kod b\u0142\u0119du: ",g.result.value)}catch(g){me("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Ft("B\u0142\u0105d podczas pobierania danych:"+g)}}async function ne(){try{let g=await j({accessId:t.accessId,accessToken:e,isBrowser:!0});if(g.result.case==="success"){R(g.result.value.audiobookDownloadDetails),q(g.result.value.isAvailableToDownloadInMobileApp===!0);return}else me("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),me("Kod b\u0142\u0119du: ",g.result.value)}catch(g){me("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Ft("B\u0142\u0105d podczas pobierania danych:"+g)}}return tr(()=>{o===1&&(xe().then().catch(),ne().then().catch())},[]),tr(()=>{if(C!=null&&b!=null){let g=C.chapters;if(!g)return;let re=g.map(Ce=>{let Be=b?.find(Ie=>Ie.chapterId===Ce.id);if(Be!=null)return{...Ce,publicUrl:Be.publicUrl,downloadableUrl:Be.downloadableUrl,duration:Be.duration}}).filter(Ce=>Ce!=null);re!=null&&re.length>0&&K(re)}},[C,b]),M("div",{children:[P("div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:M(I,{onClick:()=>n(),variant:"ghost",className:"w-fit",children:[P(Ta,{className:"h-6 w-6"}),P("span",{className:"font-inter text-sm font-medium",children:"Wr\xF3\u0107"})]})}),M("main",{className:"grid grid-cols-1 justify-center gap-6 sm:justify-start lg:grid-cols-2",children:[M("div",{className:"flex w-full max-w-xl flex-col gap-6",children:[o===2&&M("div",{ref:y,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:[M("div",{className:"flex items-center justify-between gap-x-4",children:[P("h4",{className:"text-xl font-semibold",children:"Twoje pliki"}),(d==null||d.length==0)&&P(I,{onClick:fe,"aria-label":"Download Product",className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:r,children:u?P(V,{}):"Wy\u015Bwietl"})]}),u&&M("div",{className:"flex flex-col items-start gap-2",children:[P(Xn,{}),P("p",{className:"font-bold transition hover:text-blue-600",children:"Trwa przygotowanie plik\xF3w..."})]}),d!=null&&d.length>0&&P("div",{className:"flex flex-col items-start justify-start gap-2",children:d.map((g,re)=>M("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:g,download:!0,onClick:c,children:[`Plik numer ${re+1}`,P(er,{width:14,height:14})]},re))})]}),o===4&&P("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:P(I,{onClick:()=>a(t.accessId),className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:r,children:Ye().openCourse})}),o===1&&P(pt,{children:M("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:[P("h4",{className:"text-xl font-semibold",children:H?.name??"Odtwarzacz"}),H?.description&&P("p",{className:"text-sm",children:H?.description}),P(pt,{children:L?M("div",{className:"flex gap-2",children:[P(V,{}),P("p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):P(pt,{children:U!=null?P(pt,{children:P(Qn,{ref:s,chapters:U,title:C?.name??t.productName??void 0,imageURL:C?.coverImage??t.productImageUrl??void 0,styles:r,setCurrentTimeHandler:g=>{h.current=g},uniqueProductID:t.productId,onChapterChange:g=>{pe(g)}})}):P("p",{className:"mt-2",children:"Wybierz rozdzia\u0142, kt\xF3ry ci\u0119 interesuje."})})}),M("div",{className:"rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",children:[P("p",{className:"mt-3 mb-3 text-xs",children:F?"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."}),M("div",{className:"flex gap-3",children:[P("a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:P("img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),P("a",{href:"https://docs.bitsnap.pl/guides/audiobook",children:P("img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),P("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:o===1&&P("div",{className:"max-h-96 w-full overflow-y-auto",children:L?M("div",{className:"jusitfy-center flex flex-col items-center gap-2",children:[P(V,{}),P("p",{children:"\u0141adowanie rozdzia\u0142\xF3w..."})]}):M("div",{children:[P("h2",{className:"mb-3 text-xl font-semibold",children:"Rozdzia\u0142y"}),U==null?P("p",{children:"Brak rozdzia\u0142\xF3w do wy\u015Bwietlenia."}):P("ul",{className:"flex w-full flex-col gap-2",children:U.map((g,re)=>M("li",{className:"flex items-center justify-between",children:[M("button",{className:w("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",H?.id==g.id?"bg-neutral-200 dark:bg-neutral-700":"bg-neutral-100 dark:bg-neutral-800 dark:text-neutral-300"),onClick:()=>{s.current.selectChapter(g)},children:[M("div",{className:"flex items-center justify-between",children:[P("p",{className:"text-sm font-medium",children:g.name}),g.duration&&M("span",{className:"text-xs text-neutral-500",children:[Math.floor(g.duration/60),":",String(Math.floor(g.duration%60)).padStart(2,"0")]})]}),g.description&&P("p",{className:"mt-3 text-xs",children:g.description})]}),C&&C.isDownloadable&&g.downloadableUrl&&P("a",{href:g.downloadableUrl,onClick:c,children:P(er,{width:14,height:14})})]},re))})]})})})]}),M("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:[P("h2",{className:"text-3xl font-semibold",children:t.productName}),P("p",{className:"text-sm font-normal text-neutral-600 dark:text-neutral-300",children:t.productDescription}),P("img",{src:t.productImageUrl,alt:"Product Photo",width:384,height:384,className:"max-h-sm max-w-sm",draggable:!1})]})]})]})},rr=La;import{Fragment as _a,jsx as $,jsxs as Xe}from"react/jsx-runtime";var za=({accessToken:e,projectID:t,loginURL:r,styles:n,activeScreen:a,params:o,setParams:i,openCourse:c})=>{let{data:s,isLoading:y}=De(B.publicApi.userPanelGetProducts,{accessToken:e});if(y)return Xe("div",{className:"flex items-center gap-2 bg-white p-2 dark:bg-black",children:[$("p",{className:"text-dark font-inter font-medium dark:text-white",children:"\u0141adowanie..."}),$(V,{})]});if(s&&s.result.case==="failure")return console.warn("error:",`Kod b\u0142\u0119du: ${s.result.value}`),Te(t),window.location.href=r,null;let d=s&&s.result.case==="success"?s.result.value.products:[];return $(Ma,{accessToken:e,products:d,styles:n,loginURL:r,activeScreen:a,params:o,setParams:i,openCourse:c})},ar=za,Ma=({accessToken:e,products:t,styles:r,loginURL:n,activeScreen:a,params:o,setParams:i,openCourse:c})=>{if(t.length===0)return window.location.href=n,null;let[s,y]=Ea(o.product?Ua(Rt,o.product):void 0),d=u=>{u==null?(y(void 0),i({product:void 0,state:"products"})):i({product:Oa(Rt,u),state:"products"})};function k(u){switch(u){case 1:return"Audio";case 2:return"Plik";case 3:return"Bilet";case 4:return"Kurs";default:return}}function x(u){if(u.productType===4){c(u.accessId);return}y(u),d(u)}return a==="products"&&s!=null?$(rr,{accessToken:e,product:s,styles:r,reveal:d,onOpenCourse:c}):Xe(_a,{children:[$("h3",{className:"text-2xl",children:"Hej \u{1F44B}"}),$("p",{className:"text-sm text-neutral-500",children:"Poni\u017Cej znajdziesz swoje produkty"}),$("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-9 sm:justify-start",children:t?.map((u,h)=>Xe("section",{onClick:()=>x(u),className:"w-full max-w-xs cursor-pointer rounded drop-shadow-xl dark:border dark:border-slate-600 dark:drop-shadow-none",children:[Xe("section",{className:"flex flex-col items-center space-y-2 rounded bg-slate-100 p-4 dark:bg-neutral-900",children:[u.productType&&$("div",{className:"w-fit self-end rounded bg-red-900 px-4 py-1",children:$("span",{className:"text-sm font-medium text-white dark:text-slate-100",children:k(u.productType)})}),$("div",{className:"jusitfy-center flex max-h-40 items-center",children:$("img",{src:u.productImageUrl,alt:`Product ${h} Photo`,draggable:!1,className:"aspect-auto max-h-40"})})]}),Xe("div",{className:"space-y-4 rounded bg-white p-4 dark:bg-black",children:[$("h2",{className:"text-xl font-semibold",children:u.productName}),$("p",{title:u.productDescription,className:"line-clamp-3 text-sm font-normal text-neutral-600 dark:text-neutral-300",children:Gn(u.productDescription)}),$(I,{onClick:C=>{C.stopPropagation(),x(u)},className:"w-full text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:r,children:"Zobacz"})]})]},h))})]})};import{useAutoAnimate as ja}from"@formkit/auto-animate/react";import{LogOut as Fa,Undo2 as ir}from"lucide-react";import{useState as qa}from"react";import{Fragment as lr,jsx as S,jsxs as se}from"react/jsx-runtime";function Ba({activeScreen:e,setActiveScreen:t,setParams:r,styles:n,theme:a,logout:o}){return se("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:[S(Ha,{activeScreen:e,setActiveScreen:t,setParams:r}),S(Ga,{activeScreen:e,setActiveScreen:t,setParams:r,theme:a,logout:o})]})}var sr=Ba;function Ha({activeScreen:e,setActiveScreen:t,setParams:r}){let{returnsNavLabel:n}=Ye();return se("nav",{className:"flex w-full items-center justify-evenly gap-4 md:hidden",children:[S(ft,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r}),S(ft,{panelScreen:"orders",label:"Faktury",imageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r}),S(ft,{panelScreen:"returns",label:n,icon:S(ir,{className:"h-5 w-5 text-white","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:r}),S(ft,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r})]})}function ft({panelScreen:e,label:t,imageURL:r,icon:n,activeScreen:a,setActiveScreen:o,setParams:i}){return se(I,{onClick:()=>{o(e),i({product:void 0,state:e})},"aria-label":t,variant:null,className:w("flex flex-col gap-0",a===e?"opacity-100":"opacity-50"),children:[n??S("img",{src:r,alt:t,className:"scale-75"}),S("span",{className:"text-xs font-normal text-white",children:t})]})}function gt({panelScreen:e,label:t,imageURL:r,darkImageURL:n,icon:a,activeScreen:o,setActiveScreen:i,setParams:c,isExpanded:s}){return se(I,{onClick:()=>{i(e),c({product:void 0,state:e})},variant:o===e?"secondary":"ghost",className:"justify-start",children:[a!=null?S("span",{className:w("inline-flex h-5 w-5 items-center justify-center",s?"mr-4":"mr-2"),children:a}):se(lr,{children:[S("img",{src:r,alt:t,className:w("aspect-auto h-5 w-5 dark:hidden",s?"mr-4":"mr-2")}),S("img",{src:n,alt:t,className:w("hidden aspect-auto h-5 w-5 dark:inline",s?"mr-4":"mr-2")})]}),s&&S("span",{className:"md:text-medium hidden md:inline",children:t})]})}function Ga({activeScreen:e,setActiveScreen:t,setParams:r,theme:n,logout:a}){let[o]=ja(),[i,c]=qa(!0),{returnsNavLabel:s}=Ye();return se("div",{ref:o,className:w("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:[S("div",{className:"flex items-center justify-between",children:S($a,{theme:n,isExpanded:i})}),S(or,{className:"my-6"}),se("div",{className:"flex flex-1 flex-col gap-2",children:[S(gt,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-dark-24x24.svg",darkImageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i}),S(gt,{panelScreen:"orders",label:"Zam\xF3wienia",imageURL:"/icons/category-dark-24x24.svg",darkImageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i}),S(gt,{panelScreen:"returns",label:s,icon:S(ir,{className:"h-5 w-5","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i}),S(gt,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-dark-24x24.svg",darkImageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i})]}),S(or,{className:"mb-6"}),se(I,{onClick:a,children:[S(Fa,{className:"mr-2",width:16,height:16}),i&&S("p",{className:"md:text-medium hidden md:inline md:text-center",children:"Wyloguj si\u0119"})]})]})}function or({className:e}){return se("div",{className:w("relative h-px w-full bg-neutral-300",e),children:[S("div",{className:"absolute -top-px left-0 h-1 w-1 rounded-full bg-neutral-500"}),S("div",{className:"absolute -top-px right-0 h-1 w-1 rounded-full bg-neutral-500"})]})}function $a({theme:e,isExpanded:t}){return se(lr,{children:[e==null&&S("p",{className:"text-xl tracking-wider md:inline dark:text-neutral-200",children:"bitsnap."}),(e?.logoDarkURL||e?.logoURL)&&S("img",{src:e.logoDarkURL??e.logoURL,alt:"Company Logo",className:"hidden h-6 w-6 dark:inline",draggable:!1}),e?.logoURL&&S("img",{src:e.logoURL,alt:"Company Logo",className:"h-6 w-6 dark:hidden",draggable:!1})]})}import{LogOut as Va}from"lucide-react";import{Fragment as Za,jsx as je,jsxs as qt}from"react/jsx-runtime";function Wa({email:e,logout:t}){return qt(Za,{children:[je("h3",{className:"text-2xl",children:"Profil"}),qt("div",{className:"mt-6 flex-1 md:flex-none",children:[je("span",{className:"text-sm text-neutral-500",children:"Email"}),je("p",{className:"mt-2 text-base",children:e||"Brak danych"})]}),je("div",{className:"flex w-full flex-col items-center space-y-2",children:qt(I,{onClick:t,className:"max-w-64 md:hidden",children:[je(Va,{className:"mr-2",width:16,height:16}),je("p",{className:"text-medium inline text-center",children:"Wyloguj si\u0119"})]})})]})}var cr=Wa;import{lazy as Ja,Suspense as Ka}from"react";import{jsx as yt}from"react/jsx-runtime";var Qa=Ja(()=>import("./course.mjs").then(e=>({default:e.PanelCourse})));function Bt(e){return yt(Ka,{fallback:yt("div",{className:"flex items-center gap-2 p-2",role:"status",children:yt(V,{})}),children:yt(Qa,{...e})})}import{AlertCircle as fr,CheckCircle2 as dr,ChevronLeft as Ya,Loader2 as Gt,Lock as ur,Package as Xa,Truck as gr}from"lucide-react";import{useEffect as eo,useState as Ht}from"react";import{Fragment as yr,jsx as m,jsxs as f}from"react/jsx-runtime";function to({status:e}){let t={created:{color:"bg-neutral-100 text-neutral-700",icon:null},paid:{color:"bg-green-100 text-green-700",icon:dr},completed:{color:"bg-blue-100 text-blue-700",icon:dr},canceled:{color:"bg-red-100 text-red-700",icon:fr},sent:{color:"bg-purple-100 text-purple-700",icon:gr},processing:{color:"bg-yellow-100 text-yellow-700",icon:Gt}},r=t[e]||t.created,n=r.icon,a={created:"Utworzone",paid:"Op\u0142acone",completed:"Zako\u0144czone",canceled:"Anulowane",sent:"Wys\u0142ane",processing:"Przetwarzane"};return f("span",{className:`inline-flex items-center gap-1 rounded-full px-3 py-1 text-sm font-medium ${r.color}`,children:[n&&m(n,{className:"h-4 w-4"}),a[e]||e]})}function no({orderID:e,email:t}){let[r,n]=Ht(""),a=Y(B.publicApi.addPublicOrderComment);return f("form",{onSubmit:async i=>{if(i.preventDefault(),!!r.trim())try{await a.mutateAsync({projectId:"",orderId:e,message:r.trim(),accessToken:t}),n("")}catch(c){console.error("Failed to add comment:",c)}},className:"mt-4 space-y-2",children:[m(Ne,{htmlFor:"comment",children:"Dodaj komentarz"}),m(mn,{id:"comment",value:r,onChange:i=>n(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:a.isPending}),m(I,{type:"submit",disabled:!r.trim()||a.isPending,children:a.isPending?f(yr,{children:[m(Gt,{className:"mr-2 h-4 w-4 animate-spin"}),"Wysy\u0142anie..."]}):"Dodaj komentarz"})]})}function mr(e){return e?new Date(Number(e.seconds)*1e3).toLocaleDateString("pl-PL",{year:"numeric",month:"long",day:"numeric"}):"N/A"}function pr(e,t){return new Intl.NumberFormat("pl-PL",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function ro({orderID:e,initialEmail:t,onBack:r,accessToken:n,analytics:a}){let{theme:o,projectID:i}=ge(),c=Ae(i,a,"order"),[s,y]=Ht(t||""),[d,k]=Ht(!1),{data:x,isLoading:u,error:h,refetch:C}=De(B.publicApi.getPublicOrderDetails,{projectId:i??"",orderId:e,email:s||void 0,accessToken:n},{enabled:!!e}),l=x?.result.case==="order"?x.result.value:null,b=l?.isVerified??!1,R=l!=null;eo(()=>{R&&c.track("panel_order_viewed",{},{order_ref:null})},[c,R]);let F=()=>{C(),k(!1)},q={"--button-background-color":o?.colors?.brand??"#000000","--button-background-color-dark":o?.colors?.brandDark??"#ffffff","--button-text-color":o?.colors?.brandDark??"#000000","--button-text-color-dark":o?.colors?.brand??"#000000"};return u?m("div",{className:"flex min-h-screen items-center justify-center",children:f("div",{className:"text-center",children:[m(Gt,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),m("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):h||!l?m("div",{className:"flex min-h-screen items-center justify-center",children:m(de,{className:"w-full max-w-md",children:m(ue,{className:"pt-6",children:f("div",{className:"text-center",children:[m(fr,{className:"mx-auto h-12 w-12 text-red-500"}),m("h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),m("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):m("div",{className:"w-full bg-white py-8 dark:bg-black",style:q,children:f("div",{className:"w-full px-4",children:[r&&f(I,{onClick:r,variant:"ghost",className:"mb-4 w-fit",children:[m(Ya,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),f("div",{className:"mb-6 flex items-center gap-4",children:[o?.logoURL&&f(yr,{children:[m("img",{src:o.logoURL,alt:"Project logo",className:`h-12 w-auto ${o.logoDarkURL?"dark:hidden":""}`}),o.logoDarkURL&&m("img",{src:o.logoDarkURL,alt:"Project logo",className:"hidden h-12 w-auto dark:block"})]}),f("div",{children:[m("h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),f("p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",l.orderId]})]})]}),f(de,{className:"mb-6",children:[m(ye,{children:f(be,{className:"flex items-center",children:[m(Xa,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),f(ue,{className:"space-y-6",children:[f("div",{children:[f("div",{className:"flex items-center gap-2",children:[m(to,{status:l.status}),l.processingStatus&&f("span",{className:"text-sm text-neutral-600",children:["\xB7 ",l.processingStatus]})]}),f("p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",mr(l.createdAt)]})]}),f("div",{className:"border-t pt-4",children:[m("h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),f("div",{className:"space-y-2",children:[f("div",{children:[m("span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",m("span",{className:b?"":"text-neutral-500",children:l.customerName})]}),f("div",{children:[m("span",{className:"font-medium",children:"Email:"})," ",m("span",{className:b?"":"text-neutral-500",children:l.customerEmail})]}),l.customerPhone&&f("div",{children:[m("span",{className:"font-medium",children:"Telefon:"})," ",m("span",{className:b?"":"text-neutral-500",children:l.customerPhone})]})]})]}),!b&&m("div",{className:"border-t pt-4",children:f(I,{onClick:()=>k(!0),variant:"outline",className:"w-full",children:[m(ur,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),f(de,{className:"mb-6",children:[m(ye,{children:m(be,{children:"Produkty"})}),f(ue,{className:"space-y-6",children:[m("div",{className:"space-y-4",children:l.items.map((A,L)=>f("div",{className:"flex items-center gap-4",children:[A.imageUrl&&m("img",{src:A.imageUrl,alt:A.name,className:"h-16 w-16 rounded object-cover"}),f("div",{className:"flex-1",children:[m("p",{className:"font-medium",children:A.name}),f("p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",A.quantity]})]}),m("div",{className:"text-right",children:m("p",{className:"font-medium",children:pr(Number(A.price),A.currency)})})]},L))}),(l.deliveryAddress||l.deliveryMethod)&&f("div",{className:"border-t pt-4",children:[f("h3",{className:"mb-3 flex items-center font-semibold",children:[m(gr,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),f("div",{className:"space-y-2",children:[l.deliveryAddress&&f("div",{children:[m("span",{className:"font-medium",children:"Adres:"})," ",m("span",{className:b?"":"text-neutral-500",children:l.deliveryAddress})]}),l.deliveryMethod&&f("div",{children:[m("span",{className:"font-medium",children:"Metoda:"})," ",l.deliveryMethod]}),l.trackingNumber&&b&&f("div",{children:[m("span",{className:"font-medium",children:"Tracking:"})," ",l.trackingNumber]})]})]}),m("div",{className:"border-t pt-4",children:f("div",{className:"flex justify-between text-lg font-bold",children:[m("span",{children:"Suma:"}),m("span",{children:pr(Number(l.totalAmount),l.currency)})]})})]})]}),f(de,{children:[m(ye,{children:f(be,{children:["Komentarze ",l.commentCount>0&&`(${l.commentCount})`]})}),f(ue,{children:[l.comments.length>0?m("div",{className:"space-y-4",children:l.comments.map(A=>f("div",{className:"border-b pb-4 last:border-b-0",children:[f("div",{className:"mb-1 flex items-center gap-2",children:[m("span",{className:"font-medium",children:A.authorName||"System"}),m("span",{className:"text-xs text-neutral-500",children:mr(A.createdAt)}),A.authorType==="admin"&&m("span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),m("p",{className:b?"":"text-neutral-500",children:A.message})]},A.id))}):m("p",{className:"text-neutral-600",children:"Brak komentarzy."}),b?m(no,{orderID:l.orderId,email:s}):m("div",{className:"mt-4",children:f(I,{onClick:()=>k(!0),variant:"outline",className:"w-full",children:[m(ur,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),d&&m("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:f(de,{className:"w-full max-w-md",children:[m(ye,{children:m(be,{children:"Zweryfikuj sw\xF3j email"})}),f(ue,{className:"space-y-4",children:[m("p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),f("div",{className:"space-y-2",children:[m(Ne,{htmlFor:"verify-email",children:"Adres email"}),m(lt,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:s,onChange:A=>y(A.target.value)})]}),f("div",{className:"flex gap-2",children:[m(I,{variant:"outline",onClick:()=>k(!1),className:"flex-1",children:"Anuluj"}),m(I,{onClick:F,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function ao(e){return m(ro,{...e})}var $t=ao;import{jsx as le,jsxs as br}from"react/jsx-runtime";var so=({returnsAppearance:e,returnsTexts:t,analytics:r}={})=>{let{projectID:n,theme:a,loginURL:o,host:i}=ge(),c=Ae(n,r,"panel"),s=Ve(n,i),y=dn(n,i),{mutateAsync:d}=Y(B.publicApi.userPanelLogout);async function k(){s&&await d({accessToken:s}),typeof window<"u"&&(Te(n,i),window.location.reload())}let[x]=oo(),u=D=>["products","notifications","profile","plans","orders","order-details","returns","return-details","course"].includes(D),[h,C]=Tn({product:void 0,state:"products",orderId:void 0,returnId:void 0,course:void 0,item:void 0}),[l,b]=io(u(h.state)?h.state:"products"),R=D=>{C({state:"order-details",orderId:D}),b("order-details")},F=()=>{C({state:"orders",orderId:void 0}),b("orders")},q=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}),b("course")},L=()=>{C({state:"products",course:void 0,item:void 0,product:void 0}),b("products")};bt(()=>{u(h.state)&&(h.state==="course"||l==="course")&&b(h.state)},[h.state]);let j={"--button-background-color":a?.colors?.brand??"#000000","--button-background-color-dark":a?.colors?.brandDark??"#ffffff","--button-text-color":a?.colors?.brandDark??"#000000","--button-text-color-dark":a?.colors?.brand??"#000000"};return bt(()=>{if(s==null||s.length===0){window.location.href=o??"/panel/login";return}},[]),bt(()=>{if(s==null||s.length===0){window.location.href=o??"/panel/login";return}},[l]),bt(()=>{if(typeof window>"u"||window.parent!==window||!s)return;let D=Ze(window.location.search);D&&Je(D);let H=D??Ue();H&&(window.location.href=Oe(H,s))},[s]),le(it,{value:c,children:br("div",{ref:x,className:"font-inter relative min-h-screen w-screen bg-beige-100 text-black dark:bg-black dark:text-white md:flex",children:[le(sr,{activeScreen:l,setActiveScreen:b,setParams:q,styles:j,theme:a,logout:k}),br("main",{className:"flex h-[calc(100vh-80px)] flex-col overflow-y-auto w-full p-5 md:h-screen",children:[l==="products"&&le(ar,{projectID:n??"",accessToken:s,loginURL:o??"/panel/login",styles:j,activeScreen:l,params:h,setParams:C,openCourse:A}),l==="course"&&h.course&&s&&le(Bt,{accessId:h.course,accessToken:s,theme:a,itemId:h.item,onItemChange:D=>C({item:D}),onBack:L}),l==="notifications"&&le(On,{}),l==="plans"&&le(Hn,{projectID:n??""}),l==="orders"&&le(Fn,{projectID:n??"",accessToken:s??"",openOrderDetails:R}),l==="order-details"&&h.orderId&&le($t,{orderID:h.orderId,onBack:F}),(l==="returns"||l==="return-details")&&s&&le(jt,{projectID:n??"",host:i,accessToken:s,loginURL:o??"/panel/login",appearance:Ln(e,a?.colors?.brand),texts:t,screen:l,params:h,setParams:C,setActiveScreen:b}),l==="profile"&&le(cr,{email:y,logout:k})]})]})})},lo=so;import{create as ke}from"@bufbuild/protobuf";import{QueryClient as ho,QueryClientProvider as vo}from"@tanstack/react-query";import{createContext as wo,useContext as ko,useEffect as xo}from"react";import{createClient as co}from"@connectrpc/connect";import{createConnectTransport as uo}from"@connectrpc/connect-web";var ve;(n=>{function e(a){return co(an,r(a))}n.get=e;let t=new Map;function r(a){let o=t.get(a);return o==null&&(o=uo({useBinaryFormat:!0,baseUrl:a+"/api/rpc",interceptors:[rn]}),t.set(a,o)),o}})(ve||={});import T from"zod";import Z from"zod";function _(e,t=2){return+(Math.round(+(e+"e+"+t))+"e-"+t)}function Pr(e,t){let r=typeof navigator>"u"?"pl-PL":navigator.language;return Intl.NumberFormat(r,{style:"currency",currency:t,currencyDisplay:"symbol"}).format(e/100)}var dc=Z.object({event:Z.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:Z.string().optional(),value:Z.number().optional(),currency:Z.string().optional(),content_name:Z.string().optional(),items:Z.array(Z.object({id:Z.string(),name:Z.string(),price:Z.number().default(0),currency:Z.string().default("PLN"),quantity:Z.number().default(1)})).optional()});function Vt(e){typeof window>"u"||(mo(e),fo(e),go(e))}function mo(e){try{typeof window.dataLayer>"u"&&(window.dataLayer=[]);let t=po(e);window.dataLayer.push(t)}catch(t){console.warn("cannot send google analytics event",t)}}function po(e){let t=e.value??e.items?.reduce((o,i)=>o+(i.price||0)*(i.quantity||1),0)??0,r=e.items?.map(o=>({item_id:o.id,item_name:o.name||o.id,price:_((o.price||0)/100,2),quantity:o.quantity||1})),n={currency:e.currency||"PLN",value:_(t/100,2)};r&&r.length>0&&(n.items=r);let a;switch(e.event){case"purchase":a="purchase",n.transaction_id=e.step||`txn_${Date.now()}`;break;case"addToCart":a="add_to_cart";break;case"viewCart":a="view_cart";break;case"removeFromCart":a="remove_from_cart";break;case"initiateCheckout":a="begin_checkout";break;case"customizeProduct":a="customize_product";break;default:a=e.event}return{event:a,ecommerce:n,...e.step&&{step:e.step},...e.content_name&&{content_name:e.content_name}}}function fo(e){if(typeof window.fbq>"u")return;let t="",r="",n={};switch(e.event){case"purchase":t="track",r="Purchase",n={category_name:e.step,...e};break;case"lead":t="track",r="Lead",n={category_name:e.step,...e};break;case"addToCart":t="track",r="Add to Cart",n={category_name:e.step,...e};break;case"customizeProduct":t="track",r="Customize Product",n={category_name:e.step,...e};break;case"viewCart":t="track",r="View Cart",n={category_name:e.step,...e};break;case"removeFromCart":t="track",r="Remove from Cart",n={category_name:e.step,...e};break;case"initiateCheckout":t="track",r="Initiate Checkout",n={category_name:e.step,...e};break;default:break}window.location.search.includes("analytics")&&console.log("Pushing FB event",t,r,n),window.fbq(t,r,n)}function go(e){try{if(typeof window.ttq>"u")return;let t=yo(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 yo(e){let t=e.value??e.items?.reduce((o,i)=>o+(i.price||0)*(i.quantity||1),0)??0,r=e.items?.map(o=>({content_id:o.id,content_type:"product",content_name:o.name||o.id,quantity:o.quantity||1,price:_((o.price||0)/100,2)}))||[];r.length===0&&e.content_name&&r.push({content_id:e.step||"unknown",content_type:"product",content_name:e.content_name,quantity:1,price:_(t/100,2)});let n={currency:e.currency||"PLN",value:_(t/100,2)};r.length>0&&(n.contents=r);let a=null;switch(e.event){case"purchase":a="Purchase";break;case"addToCart":a="AddToCart";break;case"initiateCheckout":a="InitiateCheckout";break;case"customizeProduct":a="CustomizeProduct";break;case"viewCart":return;case"removeFromCart":return;case"lead":return;default:return null}return{eventName:a,eventPayload:n}}function hr(e){let{items:t,googlePayConfig:r,checkout:n,result:a,cartRequiresShipping:o}=e;if(a.totalAmount==null)return;let i=[];return o&&(i.push("SHIPPING_ADDRESS"),i.push("SHIPPING_OPTION")),{apiVersion:2,apiVersionMinor:0,callbackIntents:i,allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["MASTERCARD","VISA"]},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:r.gateway,gatewayMerchantId:r.gatewayId}}}],emailRequired:!0,shippingAddressParameters:{phoneNumberRequired:o},shippingAddressRequired:o,shippingOptionRequired:o,shippingOptionParameters:o?{shippingOptions:a.methods.slice(0,5).map(s=>({id:s.id,label:s.name+` - ${Pr(s.amount,a.currency)}`,description:s.description??""})),defaultSelectedOptionId:a.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:r.merchantId+"",merchantName:r.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:"P\u0142atno\u015B\u0107 za koszyk",totalPrice:`${_(a.totalAmount/100,2)}`,currencyCode:a.currency,countryCode:a.country,checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",displayItems:bo(t,a.methods,a.selectedDeliveryMethod??(a.methods.length>0?a.methods[0].id:void 0),n.couponCode,a.couponValue)}}}function bo(e,t,r,n,a){let o=[],i=0;for(let s of e)s.details!=null&&(i+=s.details.price*s.quantity,o.push({label:s.details.name+" x "+s.quantity,price:`${_(s.details.price/100,2)}`,type:"LINE_ITEM",status:"FINAL"}));let c=t.find(s=>s.id===r);return c!=null&&o.push({label:c.name,price:`${_(c.amount/100,2)}`,type:"SHIPPING_OPTION",status:"FINAL"}),n!=null&&a!=null&&o.push({label:`Kupon ${n}`,price:`${_(a/100,2)}`,type:"DISCOUNT",status:"FINAL"}),i>0&&o.push({label:"Subtotal",price:`${_(i/100,2)}`,type:"SUBTOTAL",status:"FINAL"}),o}function et(e,t){return`${Q}/api/integrations/${e}/public-commerce${t}`}function we(e){return typeof e=="object"&&e!=null&&"ERR"in e}function J(e,t,r){return{ERR:!0,error:e,type:t,data:r}}function vr(e,t){return t?.find(r=>r.id===e||(r.variants?.some(n=>n.id===e)??!1))}function wr(e,t){let r=new Set(t.map(n=>n.productID));return Array.from(new Set(e.filter(n=>!r.has(n))))}import{create as Po}from"zustand";var Fe=Po(e=>({isCartVisible:!1,numberOfProductsInCart:0,showCart:()=>e(t=>({...t,isCartVisible:!0})),hideCart:()=>e(t=>({...t,isCartVisible:!1})),setNumberOfProductsInCart:t=>e(r=>({...r,numberOfProductsInCart:t}))}));import{Fragment as Eo,jsx as Wt}from"react/jsx-runtime";var Co="__m_a",Cr=wo(void 0),Jt=void 0;function Bc(e){Dt({projectID:e}),Jt=e,typeof window<"u"&&Ge([window.location.origin])}function nt(){return Jt??document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-id")??void 0}function No(){return document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-custom-host")??void 0}var So=({children:e,locale:t})=>{let r=new ho;xo(()=>{tt()},[]);let n=nt();if(n==null)return Wt(Eo,{});let a=Yt(n,t);return Wt(vo,{client:r,children:Wt(Cr.Provider,{value:a,children:e})})},qe=async(e,t)=>{let r=[];t?.items!=null&&t.items.length>0?r=t.items:r=z()?.products??[];let n=Array.from(new Set(r.map(c=>c.productID))),a=new URLSearchParams;a.set("ids",n.join(",")),a.set("locale",t?.locale??ce());let o=await fetch(xt(et(e,`/products?${a.toString()}`)),{method:"GET"});if(o.status!=200)return[];let i=await o.json();return r.flatMap(c=>{let s=vr(c.productID,i.result);return s==null?[]:[{...c,details:Lo(c.productID,s),catalogProductID:s.id}]})},Hc=()=>{let e=ko(Cr);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},Gc=So,Io=T.object({isAvailable:T.boolean(),merchantId:T.string(),merchantName:T.string(),gateway:T.string(),gatewayId:T.string()}),Ro=T.object({id:T.string(),productID:T.string(),quantity:T.number(),priceVersion:T.string().optional(),metadata:T.record(T.string(),T.string().optional()).optional()}),Ao=T.object({country:T.string().optional(),couponCode:T.string().optional(),selectedDeliveryMethod:T.string().optional(),postalCode:T.string().optional(),email:T.string().optional(),products:T.array(Ro).optional(),googlePayConfig:Io.optional()}),Kt={country:void 0,couponCode:void 0,email:void 0,selectedDeliveryMethod:void 0,postalCode:void 0,products:[],googlePayConfig:void 0},Nr="checkout";function z(){try{let e=localStorage.getItem(Nr);return e==null?Kt:Ao.parse(JSON.parse(e))}catch{return Kt}}async function kr(e,t){let r=await qe(e,{items:t.map((o,i)=>({...o,id:`price-check-${i}`}))});if(we(r))return r;let n=wr(t.map(o=>o.productID),r);if(n.length>0)return J("item-ids-not-found","notFound",n);let a=z();a.products==null&&(a.products=[]),a.products.push(...t.map(o=>({id:Math.random().toString(36).substring(7),productID:o.productID,quantity:o.quantity,priceVersion:r.find(i=>i.productID===o.productID)?.details?.pricing?.priceVersion,metadata:o.metadata}))),Do(t,r),Vt({event:"addToCart",currency:"PLN",items:t.map(o=>({id:o.productID,name:o.name??"",price:o.price??0,quantity:o.quantity,currency:o.currency??"PLN"}))}),te(a),tt()}function Do(e,t){for(let r of e)try{let n=t.find(c=>c.productID===r.productID),a=n?.details?.pricing?.effectivePrice??n?.details?.price??r.price,o=n?.details?.currency??r.currency;if(a==null||o==null)continue;let i=n?.catalogProductID??r.productID;(r.analytics??on()).track("add_to_cart",{qty:r.quantity,value_minor:Math.round(a*r.quantity),currency:o},{product_id:i,variant_id:i!==r.productID?r.productID:null})}catch{}}function xr(e){let t=z(),r={...t,products:t?.products?.filter(n=>!e.includes(n.productID)&&!e.includes(n.id))};Vt({event:"removeFromCart",items:e.map(n=>({id:n,name:"",price:0,quantity:1,currency:"PLN"}))}),te(r),tt()}function te(e){localStorage.setItem(Nr,JSON.stringify(e))}var Yt=(e,t=ce())=>{let r=No();return r!=null&&sn(r),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await ve.get(Q).isOneClickPaymentAvailable({projectId:e})).applePay}catch(n){return console.error("Error checking if Apple Pay is available",n),!1}},async getGooglePayConfiguration(n){if(typeof window>"u"||typeof document>"u")return{isAvailable:!1};try{let a=await To(e);if(a?.isAvailable!=!0)return{isAvailable:!1};let o=z();if(o==null)return console.log("checkout is null"),{isAvailable:!1};let i=await qe(e,{locale:t,items:n.items.map(d=>({id:Math.random().toString(36).substring(7),quantity:d.quantity,metadata:d.metadata,productID:d.productID}))});if(we(i))return{isAvailable:!1};let c=await ve.get(Q).getPreOrderDetails({items:i.map(d=>ke(St,{id:d.productID,quantity:d.quantity})),projectId:e,postCode:o.postalCode,couponCode:o.couponCode,countryCode:o.country,selectedDeliveryMethod:o.selectedDeliveryMethod});if(c.totalAmount==null)return{isAvailable:!1};let s=i.find(d=>d.details?.isDeliverable==!0)!=null,y=await hr({items:i,googlePayConfig:a,checkout:o,cartRequiresShipping:s,result:c});return y==null?{isAvailable:!1}:{isAvailable:!0,config:y}}catch(a){return console.error("Error resolving Google Pay configuration",a),{isAvailable:!1}}},async clearCart(){let n=structuredClone(Kt);n.country=z()?.country,te(n),tt()},async getAvailableCountries(){let n=await fetch(xt(et(e,"/countries")),{method:"GET"});if(n.status!=200)return[];try{return T.array(T.object({name:T.string(),code:T.string()})).parse(await n.json())}catch(a){return J(a.toString(),"internal")}},async getCountry(){let n=z()?.country;if(n==null){n="PL";let a=z();a.country=n,te(a)}return n},async getNumberOfElementsInCart(){return z()?.products?.reduce((n,a)=>n+a.quantity,0)??0},async getProducts(){return await qe(e,{locale:t})},async removeProductFromCart(n){return xr([n.id])},async setCountry(n){let a=z();a.country=n,te(a)},async setCouponCodeIfPossible(n){let a=z();a.couponCode=n,te(a)},async setPostalCode(n){let a=z();a.postalCode=n,te(a)},async setDeliveryMethod(n){let a=z();a.selectedDeliveryMethod=n,te(a)},async setEmail(n){let a=z();a.email=n,te(a)},async addProduct(n){return await kr(e,[n])},async updateQuantity(n){let a=z();a.products=a.products?.map(o=>(o.id===n.id&&(o.quantity=n.quantity),o)),te(a),tt()},async redirectToNextStep(){let n=z();if(n.products==null||n.products.length==0)return J("cart-is-empty","badInput");let a=n.products.reduce((c,s)=>(s.metadata!=null&&Object.keys(s.metadata).forEach(y=>{let d=s.metadata?.[y];d!=null&&(c[y]=d)}),c),{}),o={items:n.products.map(c=>({id:c.productID,quantity:c.quantity,priceVersion:c.priceVersion})),askForNote:!0,countries:n.country?[n.country]:void 0,metadata:a,locale:t},i=await Zt(o);return we(i)?(console.warn("cannot create payment URL",i.error),i):{url:i.url}},async justRedirectToPayment(n){let a={items:[{id:n.productID,quantity:1}],askForNote:!1,details:n.email||n.name?{name:n.name,email:n.email}:void 0,locale:n.locale??t};a=Qt(a),n.country==null&&(n.country="pl"),a.details==null&&(a.details={}),a.details.address==null&&(a.details.address={}),a.details.address.country=n.country,n.marketingAgreement===!0&&(a.additionalAgreements=[{id:Co,name:"",required:!0,answer:!0}]);let o=await Zt(a);return we(o)?o:{url:o.url}},async completeApplePayPayment(n){let a=z();if(a==null)return J("Checkout not found");let o=await qe(e,{locale:t});if(we(o))return o;try{let i=n.shippingContact?.givenName;n.shippingContact?.familyName!=null?i+=" "+n.shippingContact?.familyName:n.billingContact?.familyName!=null&&(i+=" "+n.billingContact?.familyName);let c={},s=Pt();s!=null&&(c.ref=s);let y=await ve.get(Q).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(n.token.paymentData),paymentMethod:JSON.stringify(n.token.paymentMethod),transactionIdentifier:n.token.transactionIdentifier,order:ke(It,{items:o.map(d=>({id:d.productID,quantity:d.quantity})),couponCode:a.couponCode,email:n.shippingContact?.emailAddress??n.billingContact?.emailAddress??a.email??void 0,phone:n.shippingContact?.phoneNumber??n.billingContact?.phoneNumber??void 0,selectedDeliveryMethod:a.selectedDeliveryMethod,postCode:a.postalCode,projectId:e}),shippingAddress:ke(Ct,{line1:n.shippingContact?.addressLines?.[0]??"",city:n.shippingContact?.locality??"",country:n.shippingContact?.countryCode??"",zipCode:n.shippingContact?.postalCode??"",name:i}),billingAddress:ke(Nt,{name:n.billingContact?.givenName??" "+(n.billingContact?.familyName??""),line1:n.billingContact?.addressLines?.[0]??"",city:n.billingContact?.locality??"",country:n.billingContact?.countryCode??"",zipCode:n.billingContact?.postalCode??""}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:y.isSuccess,redirectURL:y.redirectUrl}}catch(i){return console.error(i),J("Failed to authorize payment")}},async completeGooglePayPayment(n){let a=z();if(a==null)return J("Checkout not found");let o=await qe(e,{locale:t});if(we(o))return o;try{let i=n.paymentData.shippingAddress?.name,c={},s=Pt();s!=null&&(c.ref=s);let y=await ve.get(Q).authorizeOneClickPayment({gateway:1,paymentData:n.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:n.paymentData.paymentMethodData.type,transactionIdentifier:"",order:ke(It,{items:o.map(d=>({id:d.productID,quantity:d.quantity})),couponCode:a.couponCode,email:n.paymentData.email??void 0,phone:n.paymentData.shippingAddress?.phoneNumber??void 0,selectedDeliveryMethod:n.paymentData.shippingOptionData?.id??a.selectedDeliveryMethod,postCode:n.paymentData.shippingAddress?.postalCode,projectId:e}),shippingAddress:ke(Ct,{line1:n.paymentData.shippingAddress?.address1??"",city:n.paymentData.shippingAddress?.locality??"",country:n.paymentData.shippingAddress?.countryCode??"",zipCode:n.paymentData.shippingAddress?.postalCode??"",name:i}),billingAddress:ke(Nt,{name:n.paymentData.paymentMethodData.info?.billingAddress?.name,line1:n.paymentData.paymentMethodData.info?.billingAddress?.address1??"",city:n.paymentData.paymentMethodData.info?.billingAddress?.locality??"",country:n.paymentData.paymentMethodData.info?.billingAddress?.countryCode??"",zipCode:n.paymentData.paymentMethodData.info?.billingAddress?.postalCode??""}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:y.isSuccess,redirectURL:y.redirectUrl}}catch(i){return console.error(i),J("Failed to authorize payment")}return{isSuccess:!0}},async getApplePayPaymentRequest(n){let a=z();if(a==null)return J("Checkout not found");n&&n.expectedItems!=null&&n.expectedItems.length>0&&(a.products&&xr(a.products.map(s=>s.productID)),await kr(e,n.expectedItems));let o=await qe(e,{locale:t});if(we(o))return o;let i=await ve.get(Q).getPreOrderDetails({items:o.map(s=>ke(St,{id:s.productID,quantity:s.quantity})),projectId:e,postCode:a.postalCode,couponCode:a.couponCode,countryCode:a.country,selectedDeliveryMethod:a.selectedDeliveryMethod}),c=o.map(s=>({amount:`${_(s.quantity*(s.details?.price??0)/100,2)}`,label:s.details?.name+" - "+s.quantity,type:"final"}));if(i.selectedDeliveryMethod!=null){let s=i.methods.find(y=>y.id==i.selectedDeliveryMethod);s!=null&&c.push({amount:`${_(s.amount/100,2)}`,label:s.name,type:"final"})}return i.couponCode!=null&&i.couponValue!=null&&c.push({amount:`-${_(i.couponValue/100,2)}`,label:i.couponCode,type:"final"}),{countryCode:a.country??"PL",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],total:{amount:`${_((i.totalAmount??0)/100,2)}`,label:"P\u0142atno\u015B\u0107 za koszyk",type:"final"},shippingMethods:i.methods.map(s=>({amount:`${_(s.amount/100,2)}`,detail:s.description??"",identifier:s.id,label:s.name,dateComponentsRange:{startDateComponents:{days:s.minDays??1,hours:0,months:0,years:0},endDateComponents:{days:s.maxDays??14,hours:0,months:0,years:0}}})),lineItems:c,currencyCode:"PLN"}}}};async function To(e){let t=z();if(t.googlePayConfig?.isAvailable!=!0){let r=await ve.get(Q).isOneClickPaymentAvailable({projectId:e});r.googlePay==!0&&r.googlePayConfig!=null?t.googlePayConfig={isAvailable:!0,gateway:r.googlePayConfig.gateway,gatewayId:r.googlePayConfig.gatewayMerchantId,merchantName:r.googlePayConfig.merchantName,merchantId:r.googlePayConfig.merchantId}:t.googlePayConfig={isAvailable:!1,gateway:"",gatewayId:"",merchantName:"",merchantId:""}}return te(t),t.googlePayConfig}function Lo(e,t){if(e==t.id){let n=t.variants?.findIndex(a=>a.id===e);if(n!=null&&n!=-1){let a=t.variants[n];return{...t,availableQuantity:a.availableQuantity,isDeliverable:a.isDeliverable,images:a.images??t.images,name:t.name+" "+a.name,price:a.price,currency:a.currency,pricing:a.pricing}}return t}let r=t.variants?.find(n=>n.id===e);return r==null?t:{...t,id:r.id,name:t.name+" "+r.name,price:r.price,currency:r.currency,pricing:r.pricing,metadata:t.metadata,availableQuantity:r.availableQuantity,isDeliverable:r.isDeliverable,images:r.images??t.images}}function tt(){let e=z(),t=0;if(e==null){Fe.setState(r=>({...r,numberOfProductsInCart:t}));return}t=e.products?.reduce((r,n)=>r+n.quantity,0)??0,Fe.setState(r=>({...r,numberOfProductsInCart:t}))}var Uo=200,Oo="item-ids-not-found",rt="internal-error",Sr={"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"},zo=new Set(["internal","invalid-request"]),Mo=new Set(["product-not-available","product-not-found"]);function _o(e){return typeof e=="string"&&Object.hasOwn(Sr,e)?Sr[e]:void 0}function jo(e){return/<\/?[a-z!?][^>]*>/i.test(e)}function Fo(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 qo(e){return/Error:/.test(e)||/\n\s+at /.test(e)}function Xt(e){let t=e.trim();if(!(t.length===0||t.length>Uo||/[\r\n]/.test(t)||jo(t)||Fo(t)||qo(t)))return t}var Bo=3;function ht(e,t=0){if(typeof e=="object"&&e!=null){if(Array.isArray(e)||t>=Bo)return{};let r=e,n=ht(r.error,t+1);if(n.message==null&&r.message!=null){let a=ht(r.message,t+1);n={...a,code:n.code??a.code}}return typeof r.code=="string"&&r.code.length>0&&(n.code=r.code),n}if(typeof e!="string")return{};try{let r=JSON.parse(e);return typeof r=="object"&&r!=null?ht(r,t+1):{}}catch{}return{message:Xt(e)}}function Ho(e){let t;try{t=JSON.parse(e)}catch{return{code:rt,message:Xt(e)}}if(typeof t=="string")return{code:rt,message:Xt(t)};if(typeof t!="object"||t==null)return{code:rt};let r=t,{message:n,code:a}=ht(r.error),o={code:typeof r.code=="string"&&r.code.length>0?r.code:a??rt,message:n};return Array.isArray(r.itemIds)&&(o.itemIds=r.itemIds.filter(i=>typeof i=="string")),o}function en(e,t){let{code:r,message:n,itemIds:a}=Ho(t),o=a!=null&&a.length>0;if(o&&(r===rt||Mo.has(r)))return J(Oo,"badInput",a);let i={message:n};return o&&(i.itemIds=a),J(r,e>=500?"internal":"badInput",i)}function Jc(e,t){let r=_o(e.error);if(r!=null)return t(r);if(e.type==="internal"||typeof e.error=="string"&&zo.has(e.error))return t("checkoutFailed");let n=e.data?.message;return typeof n=="string"&&n.length>0?n:t("checkoutFailed")}var Go;(n=>{async function e(a,o=1,i,c){let s=nt();if(s==null)throw new Error("No project ID found");let d=await Yt(s).addProduct({productID:a,quantity:o,metadata:i,...c});if(d!=null)return d}n.addProductToCart=e;function t(){Fe.setState({isCartVisible:!0})}n.showCart=t;function r(){Fe.setState({isCartVisible:!1})}n.hideCart=r})(Go||={});async function Ir(e){try{return await e.text()}catch{return""}}async function Zt(e){let t=nt();if(t==null)throw new Error("No project ID found");e=Qt(e),e.locale??=ce();let r=await fetch(et(t,"/buy"),{method:"POST",headers:{...kt,...At(t),"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.status!=200){let a=en(r.status,await Ir(r));return console.warn("cannot create payment URL",r.status,a.error),a}return{url:(await r.json()).url}}async function ad(e){let t=nt();if(t==null)throw new Error("No project ID found");let r={...kt,...At(t),"Content-Type":"application/json",...e.apiKey!=null?{Authorization:`Bearer ${e.apiKey}`}:{}},n=e.testMode?`/api/payment/link/auto/${t}/test`:`/api/payment/link/auto/${t}`;delete e.apiKey,delete e.testMode,e.locale??=ce();let a=await fetch(Q+n,{method:"POST",headers:r,body:JSON.stringify(e)});return a.ok?{status:"ok",redirectURL:(await a.json()).url}:{...en(a.status,await Ir(a)),status:"error"}}function Pt(){if(typeof localStorage>"u")return;let e=localStorage.getItem("bitsnap-ref");if(e!=null)return e}function Qt(e){let t=Pt();return t==null||(e.metadata==null&&(e.metadata={}),e.metadata.ref=t),e}export{ve as a,de as b,ye as c,be as d,Tt as e,ue as f,In as g,Lt as h,Se as i,Ze as j,Je as k,Ue as l,Oe as m,Zr as n,Un as o,$t as p,lo as q,_ as r,Pr as s,Vt as t,we as u,Oo as v,Jc as w,Fe as x,Go as y,Zt as z,ad as A,Pt as B,Qt as C,Co as D,Jt as E,Bc as F,nt as G,Hc as H,Gc as I,Yt as J};
4
- //# sourceMappingURL=chunk-HG4YOJWE.mjs.map
4
+ //# sourceMappingURL=chunk-2PK36NGB.mjs.map
@@ -1,2 +1,2 @@
1
- import{a as ct,b as dt}from"./chunk-KOVKUJAW.mjs";import{c as Y,d as F,e as st,f as U,g as it,i as ut,k as D}from"./chunk-EZWH6BB2.mjs";import{f as tt,k as et,l as rt,m as ot,n as nt,p as at}from"./chunk-T57337WD.mjs";var It=["root","grid","card","cardLink","image","imagePlaceholder","body","name","description","price","comparePrice","badge","actions","addToCartButton","selectButton","message","pagination","paginationButton","pageIndicator","emptyState","error","retryButton","skeleton"],wt={fontFamily:"--bitsnap-products-font-family",fontSize:"--bitsnap-products-font-size",background:"--bitsnap-products-background",surface:"--bitsnap-products-surface",foreground:"--bitsnap-products-foreground",mutedForeground:"--bitsnap-products-muted-foreground",border:"--bitsnap-products-border",buttonBackground:"--bitsnap-products-button-background",buttonForeground:"--bitsnap-products-button-foreground",buttonHoverBackground:"--bitsnap-products-button-hover-background",hoverSurface:"--bitsnap-products-hover-surface",focusRing:"--bitsnap-products-focus-ring",error:"--bitsnap-products-error",badgeBackground:"--bitsnap-products-badge-background",badgeForeground:"--bitsnap-products-badge-foreground",radius:"--bitsnap-products-radius"},Et={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",radius:"8px"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",radius:"8px"}},_t=[];function lt(t){let e=ct(t,{defaultTheme:"light",presets:Et,variables:wt,shadcnVariables:_t});return{theme:e.theme,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle}}function q(t,e){return dt(t.elements,e)}function pt(t,e){try{return new Intl.NumberFormat(t,{style:"currency",currency:e,currencyDisplay:"symbol"})}catch{return}}function H(t,e,r=D){let o=t/100,n=pt(r,e)??pt(D,e);return n!=null?n.format(o):`${o.toFixed(2)} ${e}`}import{useCallback as gt,useEffect as Bt,useMemo as jt,useState as z}from"react";var Dt=24,Ot=48,M=class extends Error{status;constructor(e,r){super(e),this.name="ProductListError",this.status=r}};function O(t){return t==null||!Number.isFinite(t)?Dt:Math.min(Ot,Math.max(1,Math.floor(t)))}function mt(t,e){return Math.max(1,Math.ceil(t/e))}function N(t){return t.replace(/\/+$/,"")}function Nt(t){let e=new URLSearchParams;e.set("limit",String(t.limit)),e.set("offset",String(t.offset)),t.locale&&e.set("locale",t.locale);let r=t.search?.trim();return r&&e.set("search",r),`${N(t.host)}/api/integrations/${encodeURIComponent(t.projectID)}/public-commerce/product-list?${e.toString()}`}function Rt(t){return typeof t=="object"&&t!=null&&Array.isArray(t.items)&&typeof t.totalCount=="number"}async function ft(t,e){let r=await fetch(Y(Nt(t)),{method:"GET",credentials:"omit",headers:{Accept:"application/json"},signal:e});if(!r.ok)throw new M(`Could not load products (${r.status})`,r.status);let o=await r.json();if(!Rt(o))throw new M("Unexpected product list response");return o}function G(t){let{projectID:e,locale:r,search:o,initialData:n}=t,[a]=z(()=>U),i=t.host??a,d=O(t.pageSize),c=JSON.stringify([e,i,r??null,o?.trim()??null,d]),[m,u]=z({queryKey:c,page:1});m.queryKey!==c&&u({queryKey:c,page:1});let[b,v]=z(0),[f,l]=z(()=>({requestKey:n!=null?`${c}|1|0`:"",data:n,error:void 0})),g=f.data?.totalCount??0,P=mt(g,d),h=m.queryKey===c?m.page:1,k=g>0?Math.min(h,P):h,C=`${c}|${k}|${b}`,T=f.requestKey===C;Bt(()=>{if(T)return;let y=new AbortController;return ft({projectID:e,host:i,locale:r,search:o,limit:d,offset:(k-1)*d},y.signal).then(x=>{y.signal.aborted||l({requestKey:C,data:x,error:void 0})},x=>{y.signal.aborted||l(w=>({requestKey:C,data:w.data,error:x instanceof Error?x:new Error(String(x))}))}),()=>y.abort()},[C,T]);let I=gt(y=>{let x=Math.max(1,Math.floor(y));u({queryKey:c,page:g>0?Math.min(x,P):x})},[c,g,P]),A=gt(()=>v(y=>y+1),[]);return jt(()=>({products:f.data?.items??[],totalCount:g,page:k,pageCount:P,setPage:I,isLoading:!T,error:T?f.error:void 0,refetch:A}),[f,g,k,P,I,T,A])}import{createContext as ht,useCallback as V,useContext as xt,useEffect as R,useMemo as B,useRef as K,useState as Mt}from"react";function Pt(t,e){if(t.projectID!=null&&t.projectID!==e.projectID)return{ok:!1,reason:`the page cart already belongs to project "${t.projectID}"`};let r=null,o=e.host?N(e.host):"",n=N(t.host);if(o&&o!==n){if(n!==N(t.defaultHost))return{ok:!1,reason:`the page cart already uses the host "${t.host}"`};r=o}return{ok:!0,setProjectID:t.projectID==null?e.projectID:null,setHost:r}}function Q(t,e){let r=e.cartItemId!=null&&e.cartItemId!==e.id?e.cartItemId:null;t.track("add_to_cart",{qty:1,value_minor:e.price,currency:e.currency},{product_id:e.id,variant_id:r})}async function bt(t,e){let[{Bitsnap:r},{getProjectID:o,setProjectID:n}]=await Promise.all([import("./methods-C5HWYPPN.mjs"),import("./CartProvider-ONIOELW5.mjs")]),a=Pt({projectID:o(),host:U,defaultHost:st},e);if(!a.ok)return Ft(a.reason);if(a.setProjectID!=null&&n(a.setProjectID),a.setHost!=null&&it(a.setHost),await r.addProductToCart(t.cartItemId??t.id,1,void 0,{name:t.name,price:t.price,currency:t.currency,analytics:et})!=null)throw new Error("Could not add the product to the cart");e.analytics!=null&&Q(e.analytics,t),e.showCart&&r.showCart()}function Ft(t){throw console.warn(`bitsnap-react: ProductList did not add to the cart because ${t}. Pass onAddToCart to use another cart.`),new Error("The page cart belongs to another project or host")}var $=50,Ut=1e3;function yt(t,e=Ut){let r=new Set,o=new Map,n=[],a=[],i,d,c=!1;function m(){for(d!==void 0&&clearTimeout(d),d=void 0;n.length>0;){let l=n.slice(0,$),g=a.slice(0,$);n=n.slice($),a=a.slice($);try{t({productIds:l,positions:g})}catch{}}}function u(){m();try{tt()?.flush()}catch{}}let b=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&u()};function v(){c||typeof window>"u"||(c=!0,window.addEventListener("pagehide",u,!0),document.addEventListener("visibilitychange",b,!0))}function f(){if(i)return i;if(!(typeof IntersectionObserver>"u"))return i=new IntersectionObserver(l=>{for(let g of l){let P=o.get(g.target);!P||!g.isIntersecting||g.intersectionRatio<.5||(o.delete(g.target),i?.unobserve(g.target),!r.has(P.id)&&(r.add(P.id),n.push(P.id),a.push(P.position)))}n.length>0&&d===void 0&&(d=setTimeout(m,e),d.unref?.())},{threshold:[.5]}),v(),i}return{observe(l,g,P){try{if(r.has(g))return()=>{};let h=f();return h?(o.set(l,{id:g,position:P}),h.observe(l),()=>{o.delete(l),h.unobserve(l)}):()=>{}}catch{return()=>{}}},flush:m,destroy(){try{m(),i?.disconnect(),c&&(window.removeEventListener("pagehide",u,!0),document.removeEventListener("visibilitychange",b,!0),c=!1)}catch{}i=void 0,o.clear()}}}var Ht={en:{addToCart:"Add to cart",addingToCart:"Adding\u2026",addedToCart:"Added to cart",addToCartError:"Could not add to the cart. Try again.",chooseOptions:"Choose",viewProduct:"View",unavailable:"Unavailable",subscription:"Subscription",priceFrom:"from {price}",originalPrice:"Original price",loading:"Loading products",empty:"There are no products to show.",error:"Could not load the products.",retry:"Try again",pagination:"Pagination",previousPage:"Previous",nextPage:"Next",pageOf:"Page {page} of {pageCount}"},pl:{addToCart:"Dodaj do koszyka",addingToCart:"Dodawanie\u2026",addedToCart:"Dodano do koszyka",addToCartError:"Nie uda\u0142o si\u0119 doda\u0107 do koszyka. Spr\xF3buj ponownie.",chooseOptions:"Wybierz",viewProduct:"Zobacz",unavailable:"Niedost\u0119pny",subscription:"Subskrypcja",priceFrom:"od {price}",originalPrice:"Cena przed obni\u017Ck\u0105",loading:"\u0141adowanie produkt\xF3w",empty:"Brak produkt\xF3w do wy\u015Bwietlenia.",error:"Nie uda\u0142o si\u0119 za\u0142adowa\u0107 produkt\xF3w.",retry:"Spr\xF3buj ponownie",pagination:"Paginacja",previousPage:"Poprzednia",nextPage:"Nast\u0119pna",pageOf:"Strona {page} z {pageCount}"}};function Lt(t,e){return ut(Ht,t,e)}function X(t,e){return t.replace(/\{(\w+)\}/g,(r,o)=>o in e?String(e[o]):r)}import{Fragment as At,jsx as s,jsxs as S}from"react/jsx-runtime";var Tt=ht(void 0),zt={observe:()=>()=>{},clicked:()=>{}},vt=ht(zt);function j(){let t=xt(Tt);if(t==null)throw new Error("ProductList parts must be rendered inside ProductList");return t}function p(t,e){let{appearance:r}=j(),o=q(r,t);return{"data-bitsnap-products-slot":t,className:F(e,o?.className),style:o?.style}}var Z="inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50",Ct=`${Z} w-full`,$t=`${Ct} no-underline`;function Kt({product:t,onAdd:e}){let{texts:r}=j(),[o,n]=Mt("idle"),a=p("addToCartButton",Ct),i=p("message","mt-2 text-xs");R(()=>{if(o!=="added")return;let m=setTimeout(()=>n("idle"),2e3);return()=>clearTimeout(m)},[o]);let d=V(async()=>{n("adding");try{await e(),n("added")}catch(m){console.error("bitsnap-react: could not add to the cart",m),n("error")}},[e]),c=o==="adding"?r.addingToCart:o==="added"?r.addedToCart:r.addToCart;return S(At,{children:[s("button",{type:"button",...a,disabled:o==="adding","aria-label":`${c}: ${t.name}`,onClick:d,children:c}),o==="error"?s("p",{...i,role:"alert",children:r.addToCartError}):null]})}function Vt({product:t,position:e,href:r,onAdd:o,renderItem:n}){let{texts:a,locale:i}=j(),d=xt(vt),c=K(null);R(()=>{if(c.current!=null)return d.observe(c.current,t.id,e)},[d,t.id,e]);let m=V(()=>d.clicked(t,e),[d,t,e]),u=p("card","relative flex flex-col overflow-hidden border transition-colors"),b=p("cardLink","flex flex-1 flex-col no-underline"),v=p("image","aspect-square w-full overflow-hidden"),f=p("imagePlaceholder","aspect-square w-full"),l=p("body","flex flex-1 flex-col gap-1 p-4"),g=p("name","text-base font-medium leading-snug"),P=p("description","line-clamp-2 text-sm"),h=p("price","mt-auto pt-2 text-base font-semibold"),k=p("comparePrice","ml-2 text-sm font-normal"),C=p("badge","absolute left-3 top-3 px-2 py-0.5 text-xs font-medium"),T=p("actions","p-4 pt-0"),I=p("selectButton",$t),A=H(t.price,t.currency,i),y=t.compareAtPrice!=null&&t.compareAtPrice>t.price?H(t.compareAtPrice,t.currency,i):null;if(n!=null)return s("li",{ref:c,...u,"data-unavailable":t.available?void 0:"",children:n(t,{href:r,price:A,compareAtPrice:y,texts:a,locale:i,addToCart:o,trackClick:m})});let x=t.image?.thumbnailUrl??t.image?.url,w=t.available?t.isRecurring?a.subscription:null:a.unavailable;return S("li",{ref:c,...u,"data-unavailable":t.available?void 0:"",children:[S("a",{...b,href:r,onClick:m,children:[x!=null?s("div",{...v,children:s("img",{src:x,alt:"",loading:"lazy",decoding:"async",className:"h-full w-full object-cover"})}):s("div",{...f,"aria-hidden":"true"}),S("div",{...l,children:[s("h3",{...g,children:t.name}),t.shortDescription?s("p",{...P,children:t.shortDescription}):null,S("p",{...h,children:[t.priceFrom?X(a.priceFrom,{price:A}):A,y!=null?S(At,{children:[S("span",{className:"sr-only",children:[a.originalPrice,": "]}),s("del",{...k,children:y})]}):null]})]})]}),w!=null?s("span",{...C,"data-kind":t.available?"subscription":"unavailable",children:w}):null,s("div",{...T,children:t.available?t.addToCart?s(Kt,{product:t,onAdd:o}):s("a",{...I,href:r,onClick:m,children:t.variantCount>1?a.chooseOptions:a.viewProduct}):s("button",{type:"button",...I,disabled:!0,children:a.unavailable})})]})}var St="m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-5 p-0";function qt({count:t,label:e}){let r=p("grid",St),o=p("skeleton","aspect-[3/4] animate-pulse");return s("div",{...r,role:"status","aria-busy":"true","aria-label":e,children:Array.from({length:t},(n,a)=>s("div",{...o,"aria-hidden":"true"},a))})}function Gt({page:t,pageCount:e,isLoading:r,onPage:o}){let{texts:n}=j(),a=p("pagination","mt-8 flex items-center justify-center gap-4"),i=p("paginationButton",Z),d=p("pageIndicator","text-sm");return S("nav",{...a,"aria-label":n.pagination,children:[s("button",{type:"button",...i,"aria-disabled":r||t<=1,onClick:()=>{!r&&t>1&&o(t-1)},children:n.previousPage}),s("span",{...d,"aria-live":"polite",children:X(n.pageOf,{page:t,pageCount:e})}),s("button",{type:"button",...i,"aria-disabled":r||t>=e,onClick:()=>{!r&&t<e&&o(t+1)},children:n.nextPage})]})}function Qt({options:t,productHref:e,renderItem:r,onAddToCart:o,showCartOnAdd:n}){let{texts:a}=j(),{products:i,page:d,pageCount:c,setPage:m,isLoading:u,error:b,refetch:v}=G(t),f=ot(),l=t.search?.trim()?"search":"catalog",g=O(t.pageSize),P=K(!1);R(()=>{P.current||u||b!=null||(P.current=!0,f.track("product_list_viewed",{list_id:l,item_count:i.length}))},[f,u,b,l,i.length]);let h=B(()=>yt(({productIds:L,positions:_})=>f.track("product_impression",{list_id:l,product_ids:L,positions:_})),[f,l]);R(()=>()=>h.destroy(),[h]);let k=B(()=>({observe:h.observe,clicked:(L,_)=>f.track("product_clicked",{list_id:l,position:_},{product_id:L.id})}),[h,f,l]),C=K(null),T=K(!1),I=V(L=>{T.current=!0,m(L)},[m]);R(()=>{u||!T.current||(T.current=!1,C.current?.focus({preventScroll:!0}),C.current?.scrollIntoView({block:"start"}))},[u]);let A=p("grid",St),y=p("emptyState","py-12 text-center text-sm"),x=p("error","flex flex-col items-center gap-3 py-12 text-center text-sm"),w=p("retryButton",Z),{projectID:J,host:W}=t,kt=V(L=>async()=>{if(o!=null){await at(()=>o(L)),Q(f,L);return}await bt(L,{projectID:J,host:W,showCart:n,analytics:f})},[o,J,W,n,f]),E;return u&&i.length===0?E=s(qt,{count:Math.min(O(t.pageSize),8),label:a.loading}):b!=null?E=S("div",{...x,role:"alert",children:[s("p",{children:a.error}),s("button",{type:"button",...w,onClick:v,children:a.retry})]}):i.length===0?E=s("p",{...y,children:a.empty}):E=s("ul",{...A,"aria-busy":u||void 0,className:F(A.className,u&&"opacity-60"),children:i.map((L,_)=>s(Vt,{product:L,position:(d-1)*g+_,href:e(L),onAdd:kt(L),renderItem:r},L.id))}),s(vt.Provider,{value:k,children:S("div",{ref:C,tabIndex:-1,className:"p-1 outline-none scroll-mt-4",children:[E,c>1&&b==null?s(Gt,{page:d,pageCount:c,isLoading:u,onPage:I}):null]})})}var Xt=t=>`/p/${encodeURIComponent(t.uniqueSlug)}`;function Zt({productHref:t=Xt,appearance:e,texts:r,renderItem:o,onAddToCart:n,showCartOnAdd:a=!0,className:i,analytics:d,...c}){let m=nt(c.projectID,d,"catalog"),u=c.locale??D,b=B(()=>lt(e),[e]),v=B(()=>Lt(u,r),[u,r]),f=B(()=>({appearance:b,texts:v,locale:u}),[b,v,u]),l=q(b,"root");return s(rt,{value:m,children:s(Tt.Provider,{value:f,children:s("div",{"data-bitsnap-products":"root","data-bitsnap-products-slot":"root",className:F("bitsnap-react",b.boundaryClassName,i,l?.className),style:{...b.boundaryStyle,...l?.style},children:s(Qt,{options:c,productHref:t,renderItem:o,onAddToCart:n,showCartOnAdd:a})})})})}export{It as a,H as b,G as c,Zt as d};
2
- //# sourceMappingURL=chunk-GPNALARZ.mjs.map
1
+ import{a as ct,b as dt}from"./chunk-KOVKUJAW.mjs";import{c as Y,d as F,e as st,f as U,g as it,i as ut,k as D}from"./chunk-G2UOTVS5.mjs";import{f as tt,k as et,l as rt,m as ot,n as nt,p as at}from"./chunk-IJLHU2MA.mjs";var It=["root","grid","card","cardLink","image","imagePlaceholder","body","name","description","price","comparePrice","badge","actions","addToCartButton","selectButton","message","pagination","paginationButton","pageIndicator","emptyState","error","retryButton","skeleton"],wt={fontFamily:"--bitsnap-products-font-family",fontSize:"--bitsnap-products-font-size",background:"--bitsnap-products-background",surface:"--bitsnap-products-surface",foreground:"--bitsnap-products-foreground",mutedForeground:"--bitsnap-products-muted-foreground",border:"--bitsnap-products-border",buttonBackground:"--bitsnap-products-button-background",buttonForeground:"--bitsnap-products-button-foreground",buttonHoverBackground:"--bitsnap-products-button-hover-background",hoverSurface:"--bitsnap-products-hover-surface",focusRing:"--bitsnap-products-focus-ring",error:"--bitsnap-products-error",badgeBackground:"--bitsnap-products-badge-background",badgeForeground:"--bitsnap-products-badge-foreground",radius:"--bitsnap-products-radius"},Et={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",radius:"8px"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",radius:"8px"}},_t=[];function lt(t){let e=ct(t,{defaultTheme:"light",presets:Et,variables:wt,shadcnVariables:_t});return{theme:e.theme,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle}}function q(t,e){return dt(t.elements,e)}function pt(t,e){try{return new Intl.NumberFormat(t,{style:"currency",currency:e,currencyDisplay:"symbol"})}catch{return}}function H(t,e,r=D){let o=t/100,n=pt(r,e)??pt(D,e);return n!=null?n.format(o):`${o.toFixed(2)} ${e}`}import{useCallback as gt,useEffect as Bt,useMemo as jt,useState as z}from"react";var Dt=24,Ot=48,M=class extends Error{status;constructor(e,r){super(e),this.name="ProductListError",this.status=r}};function O(t){return t==null||!Number.isFinite(t)?Dt:Math.min(Ot,Math.max(1,Math.floor(t)))}function mt(t,e){return Math.max(1,Math.ceil(t/e))}function N(t){return t.replace(/\/+$/,"")}function Nt(t){let e=new URLSearchParams;e.set("limit",String(t.limit)),e.set("offset",String(t.offset)),t.locale&&e.set("locale",t.locale);let r=t.search?.trim();return r&&e.set("search",r),`${N(t.host)}/api/integrations/${encodeURIComponent(t.projectID)}/public-commerce/product-list?${e.toString()}`}function Rt(t){return typeof t=="object"&&t!=null&&Array.isArray(t.items)&&typeof t.totalCount=="number"}async function ft(t,e){let r=await fetch(Y(Nt(t)),{method:"GET",credentials:"omit",headers:{Accept:"application/json"},signal:e});if(!r.ok)throw new M(`Could not load products (${r.status})`,r.status);let o=await r.json();if(!Rt(o))throw new M("Unexpected product list response");return o}function G(t){let{projectID:e,locale:r,search:o,initialData:n}=t,[a]=z(()=>U),i=t.host??a,d=O(t.pageSize),c=JSON.stringify([e,i,r??null,o?.trim()??null,d]),[m,u]=z({queryKey:c,page:1});m.queryKey!==c&&u({queryKey:c,page:1});let[b,v]=z(0),[f,l]=z(()=>({requestKey:n!=null?`${c}|1|0`:"",data:n,error:void 0})),g=f.data?.totalCount??0,P=mt(g,d),h=m.queryKey===c?m.page:1,k=g>0?Math.min(h,P):h,C=`${c}|${k}|${b}`,T=f.requestKey===C;Bt(()=>{if(T)return;let y=new AbortController;return ft({projectID:e,host:i,locale:r,search:o,limit:d,offset:(k-1)*d},y.signal).then(x=>{y.signal.aborted||l({requestKey:C,data:x,error:void 0})},x=>{y.signal.aborted||l(w=>({requestKey:C,data:w.data,error:x instanceof Error?x:new Error(String(x))}))}),()=>y.abort()},[C,T]);let I=gt(y=>{let x=Math.max(1,Math.floor(y));u({queryKey:c,page:g>0?Math.min(x,P):x})},[c,g,P]),A=gt(()=>v(y=>y+1),[]);return jt(()=>({products:f.data?.items??[],totalCount:g,page:k,pageCount:P,setPage:I,isLoading:!T,error:T?f.error:void 0,refetch:A}),[f,g,k,P,I,T,A])}import{createContext as ht,useCallback as V,useContext as xt,useEffect as R,useMemo as B,useRef as K,useState as Mt}from"react";function Pt(t,e){if(t.projectID!=null&&t.projectID!==e.projectID)return{ok:!1,reason:`the page cart already belongs to project "${t.projectID}"`};let r=null,o=e.host?N(e.host):"",n=N(t.host);if(o&&o!==n){if(n!==N(t.defaultHost))return{ok:!1,reason:`the page cart already uses the host "${t.host}"`};r=o}return{ok:!0,setProjectID:t.projectID==null?e.projectID:null,setHost:r}}function Q(t,e){let r=e.cartItemId!=null&&e.cartItemId!==e.id?e.cartItemId:null;t.track("add_to_cart",{qty:1,value_minor:e.price,currency:e.currency},{product_id:e.id,variant_id:r})}async function bt(t,e){let[{Bitsnap:r},{getProjectID:o,setProjectID:n}]=await Promise.all([import("./methods-ALO22YWQ.mjs"),import("./CartProvider-XMHPQRWC.mjs")]),a=Pt({projectID:o(),host:U,defaultHost:st},e);if(!a.ok)return Ft(a.reason);if(a.setProjectID!=null&&n(a.setProjectID),a.setHost!=null&&it(a.setHost),await r.addProductToCart(t.cartItemId??t.id,1,void 0,{name:t.name,price:t.price,currency:t.currency,analytics:et})!=null)throw new Error("Could not add the product to the cart");e.analytics!=null&&Q(e.analytics,t),e.showCart&&r.showCart()}function Ft(t){throw console.warn(`bitsnap-react: ProductList did not add to the cart because ${t}. Pass onAddToCart to use another cart.`),new Error("The page cart belongs to another project or host")}var $=50,Ut=1e3;function yt(t,e=Ut){let r=new Set,o=new Map,n=[],a=[],i,d,c=!1;function m(){for(d!==void 0&&clearTimeout(d),d=void 0;n.length>0;){let l=n.slice(0,$),g=a.slice(0,$);n=n.slice($),a=a.slice($);try{t({productIds:l,positions:g})}catch{}}}function u(){m();try{tt()?.flush()}catch{}}let b=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&u()};function v(){c||typeof window>"u"||(c=!0,window.addEventListener("pagehide",u,!0),document.addEventListener("visibilitychange",b,!0))}function f(){if(i)return i;if(!(typeof IntersectionObserver>"u"))return i=new IntersectionObserver(l=>{for(let g of l){let P=o.get(g.target);!P||!g.isIntersecting||g.intersectionRatio<.5||(o.delete(g.target),i?.unobserve(g.target),!r.has(P.id)&&(r.add(P.id),n.push(P.id),a.push(P.position)))}n.length>0&&d===void 0&&(d=setTimeout(m,e),d.unref?.())},{threshold:[.5]}),v(),i}return{observe(l,g,P){try{if(r.has(g))return()=>{};let h=f();return h?(o.set(l,{id:g,position:P}),h.observe(l),()=>{o.delete(l),h.unobserve(l)}):()=>{}}catch{return()=>{}}},flush:m,destroy(){try{m(),i?.disconnect(),c&&(window.removeEventListener("pagehide",u,!0),document.removeEventListener("visibilitychange",b,!0),c=!1)}catch{}i=void 0,o.clear()}}}var Ht={en:{addToCart:"Add to cart",addingToCart:"Adding\u2026",addedToCart:"Added to cart",addToCartError:"Could not add to the cart. Try again.",chooseOptions:"Choose",viewProduct:"View",unavailable:"Unavailable",subscription:"Subscription",priceFrom:"from {price}",originalPrice:"Original price",loading:"Loading products",empty:"There are no products to show.",error:"Could not load the products.",retry:"Try again",pagination:"Pagination",previousPage:"Previous",nextPage:"Next",pageOf:"Page {page} of {pageCount}"},pl:{addToCart:"Dodaj do koszyka",addingToCart:"Dodawanie\u2026",addedToCart:"Dodano do koszyka",addToCartError:"Nie uda\u0142o si\u0119 doda\u0107 do koszyka. Spr\xF3buj ponownie.",chooseOptions:"Wybierz",viewProduct:"Zobacz",unavailable:"Niedost\u0119pny",subscription:"Subskrypcja",priceFrom:"od {price}",originalPrice:"Cena przed obni\u017Ck\u0105",loading:"\u0141adowanie produkt\xF3w",empty:"Brak produkt\xF3w do wy\u015Bwietlenia.",error:"Nie uda\u0142o si\u0119 za\u0142adowa\u0107 produkt\xF3w.",retry:"Spr\xF3buj ponownie",pagination:"Paginacja",previousPage:"Poprzednia",nextPage:"Nast\u0119pna",pageOf:"Strona {page} z {pageCount}"}};function Lt(t,e){return ut(Ht,t,e)}function X(t,e){return t.replace(/\{(\w+)\}/g,(r,o)=>o in e?String(e[o]):r)}import{Fragment as At,jsx as s,jsxs as S}from"react/jsx-runtime";var Tt=ht(void 0),zt={observe:()=>()=>{},clicked:()=>{}},vt=ht(zt);function j(){let t=xt(Tt);if(t==null)throw new Error("ProductList parts must be rendered inside ProductList");return t}function p(t,e){let{appearance:r}=j(),o=q(r,t);return{"data-bitsnap-products-slot":t,className:F(e,o?.className),style:o?.style}}var Z="inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50",Ct=`${Z} w-full`,$t=`${Ct} no-underline`;function Kt({product:t,onAdd:e}){let{texts:r}=j(),[o,n]=Mt("idle"),a=p("addToCartButton",Ct),i=p("message","mt-2 text-xs");R(()=>{if(o!=="added")return;let m=setTimeout(()=>n("idle"),2e3);return()=>clearTimeout(m)},[o]);let d=V(async()=>{n("adding");try{await e(),n("added")}catch(m){console.error("bitsnap-react: could not add to the cart",m),n("error")}},[e]),c=o==="adding"?r.addingToCart:o==="added"?r.addedToCart:r.addToCart;return S(At,{children:[s("button",{type:"button",...a,disabled:o==="adding","aria-label":`${c}: ${t.name}`,onClick:d,children:c}),o==="error"?s("p",{...i,role:"alert",children:r.addToCartError}):null]})}function Vt({product:t,position:e,href:r,onAdd:o,renderItem:n}){let{texts:a,locale:i}=j(),d=xt(vt),c=K(null);R(()=>{if(c.current!=null)return d.observe(c.current,t.id,e)},[d,t.id,e]);let m=V(()=>d.clicked(t,e),[d,t,e]),u=p("card","relative flex flex-col overflow-hidden border transition-colors"),b=p("cardLink","flex flex-1 flex-col no-underline"),v=p("image","aspect-square w-full overflow-hidden"),f=p("imagePlaceholder","aspect-square w-full"),l=p("body","flex flex-1 flex-col gap-1 p-4"),g=p("name","text-base font-medium leading-snug"),P=p("description","line-clamp-2 text-sm"),h=p("price","mt-auto pt-2 text-base font-semibold"),k=p("comparePrice","ml-2 text-sm font-normal"),C=p("badge","absolute left-3 top-3 px-2 py-0.5 text-xs font-medium"),T=p("actions","p-4 pt-0"),I=p("selectButton",$t),A=H(t.price,t.currency,i),y=t.compareAtPrice!=null&&t.compareAtPrice>t.price?H(t.compareAtPrice,t.currency,i):null;if(n!=null)return s("li",{ref:c,...u,"data-unavailable":t.available?void 0:"",children:n(t,{href:r,price:A,compareAtPrice:y,texts:a,locale:i,addToCart:o,trackClick:m})});let x=t.image?.thumbnailUrl??t.image?.url,w=t.available?t.isRecurring?a.subscription:null:a.unavailable;return S("li",{ref:c,...u,"data-unavailable":t.available?void 0:"",children:[S("a",{...b,href:r,onClick:m,children:[x!=null?s("div",{...v,children:s("img",{src:x,alt:"",loading:"lazy",decoding:"async",className:"h-full w-full object-cover"})}):s("div",{...f,"aria-hidden":"true"}),S("div",{...l,children:[s("h3",{...g,children:t.name}),t.shortDescription?s("p",{...P,children:t.shortDescription}):null,S("p",{...h,children:[t.priceFrom?X(a.priceFrom,{price:A}):A,y!=null?S(At,{children:[S("span",{className:"sr-only",children:[a.originalPrice,": "]}),s("del",{...k,children:y})]}):null]})]})]}),w!=null?s("span",{...C,"data-kind":t.available?"subscription":"unavailable",children:w}):null,s("div",{...T,children:t.available?t.addToCart?s(Kt,{product:t,onAdd:o}):s("a",{...I,href:r,onClick:m,children:t.variantCount>1?a.chooseOptions:a.viewProduct}):s("button",{type:"button",...I,disabled:!0,children:a.unavailable})})]})}var St="m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-5 p-0";function qt({count:t,label:e}){let r=p("grid",St),o=p("skeleton","aspect-[3/4] animate-pulse");return s("div",{...r,role:"status","aria-busy":"true","aria-label":e,children:Array.from({length:t},(n,a)=>s("div",{...o,"aria-hidden":"true"},a))})}function Gt({page:t,pageCount:e,isLoading:r,onPage:o}){let{texts:n}=j(),a=p("pagination","mt-8 flex items-center justify-center gap-4"),i=p("paginationButton",Z),d=p("pageIndicator","text-sm");return S("nav",{...a,"aria-label":n.pagination,children:[s("button",{type:"button",...i,"aria-disabled":r||t<=1,onClick:()=>{!r&&t>1&&o(t-1)},children:n.previousPage}),s("span",{...d,"aria-live":"polite",children:X(n.pageOf,{page:t,pageCount:e})}),s("button",{type:"button",...i,"aria-disabled":r||t>=e,onClick:()=>{!r&&t<e&&o(t+1)},children:n.nextPage})]})}function Qt({options:t,productHref:e,renderItem:r,onAddToCart:o,showCartOnAdd:n}){let{texts:a}=j(),{products:i,page:d,pageCount:c,setPage:m,isLoading:u,error:b,refetch:v}=G(t),f=ot(),l=t.search?.trim()?"search":"catalog",g=O(t.pageSize),P=K(!1);R(()=>{P.current||u||b!=null||(P.current=!0,f.track("product_list_viewed",{list_id:l,item_count:i.length}))},[f,u,b,l,i.length]);let h=B(()=>yt(({productIds:L,positions:_})=>f.track("product_impression",{list_id:l,product_ids:L,positions:_})),[f,l]);R(()=>()=>h.destroy(),[h]);let k=B(()=>({observe:h.observe,clicked:(L,_)=>f.track("product_clicked",{list_id:l,position:_},{product_id:L.id})}),[h,f,l]),C=K(null),T=K(!1),I=V(L=>{T.current=!0,m(L)},[m]);R(()=>{u||!T.current||(T.current=!1,C.current?.focus({preventScroll:!0}),C.current?.scrollIntoView({block:"start"}))},[u]);let A=p("grid",St),y=p("emptyState","py-12 text-center text-sm"),x=p("error","flex flex-col items-center gap-3 py-12 text-center text-sm"),w=p("retryButton",Z),{projectID:J,host:W}=t,kt=V(L=>async()=>{if(o!=null){await at(()=>o(L)),Q(f,L);return}await bt(L,{projectID:J,host:W,showCart:n,analytics:f})},[o,J,W,n,f]),E;return u&&i.length===0?E=s(qt,{count:Math.min(O(t.pageSize),8),label:a.loading}):b!=null?E=S("div",{...x,role:"alert",children:[s("p",{children:a.error}),s("button",{type:"button",...w,onClick:v,children:a.retry})]}):i.length===0?E=s("p",{...y,children:a.empty}):E=s("ul",{...A,"aria-busy":u||void 0,className:F(A.className,u&&"opacity-60"),children:i.map((L,_)=>s(Vt,{product:L,position:(d-1)*g+_,href:e(L),onAdd:kt(L),renderItem:r},L.id))}),s(vt.Provider,{value:k,children:S("div",{ref:C,tabIndex:-1,className:"p-1 outline-none scroll-mt-4",children:[E,c>1&&b==null?s(Gt,{page:d,pageCount:c,isLoading:u,onPage:I}):null]})})}var Xt=t=>`/p/${encodeURIComponent(t.uniqueSlug)}`;function Zt({productHref:t=Xt,appearance:e,texts:r,renderItem:o,onAddToCart:n,showCartOnAdd:a=!0,className:i,analytics:d,...c}){let m=nt(c.projectID,d,"catalog"),u=c.locale??D,b=B(()=>lt(e),[e]),v=B(()=>Lt(u,r),[u,r]),f=B(()=>({appearance:b,texts:v,locale:u}),[b,v,u]),l=q(b,"root");return s(rt,{value:m,children:s(Tt.Provider,{value:f,children:s("div",{"data-bitsnap-products":"root","data-bitsnap-products-slot":"root",className:F("bitsnap-react",b.boundaryClassName,i,l?.className),style:{...b.boundaryStyle,...l?.style},children:s(Qt,{options:c,productHref:t,renderItem:o,onAddToCart:n,showCartOnAdd:a})})})})}export{It as a,H as b,G as c,Zt as d};
2
+ //# sourceMappingURL=chunk-2X32DDUM.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkASNUY3EUjs = require('./chunk-ASNUY3EU.js');var _chunkGT3OH55Yjs = require('./chunk-GT3OH55Y.js');var t={projectID:void 0,loginURL:"/panel/login",theme:void 0,host:void 0,allowedReturnOrigins:[]},u=[];function w(e){t={...t,...e}}function s(){return t}function P(e){t.projectID=e}function v(e){t.theme=e}function C(e){t.loginURL=e}function R(e){t.host=e}function x(e){u=e,t={...t,allowedReturnOrigins:e}}function y(){return u}var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var f=_react.createContext.call(void 0, s()),b= exports.i =({children:e,analytics:n})=>{let o=s(),i=_chunkGT3OH55Yjs.n.call(void 0, o.projectID,n,"panel");return _jsxruntime.jsx.call(void 0, _chunkASNUY3EUjs.o,{children:_jsxruntime.jsx.call(void 0, f.Provider,{value:{...o},children:_jsxruntime.jsx.call(void 0, _chunkGT3OH55Yjs.l,{value:i,children:_jsxruntime.jsx.call(void 0, "div",{className:"bitsnap-react",children:e})})})})},L= exports.j =()=>_react.useContext.call(void 0, f);var l=(e,n)=>`bitsnap-panel-session:${encodeURIComponent(_nullishCoalesce(n, () => ("https://bitsnap.pl")))}:${encodeURIComponent(e)}`,a=(e,n)=>`bitsnap-panel-email:${encodeURIComponent(_nullishCoalesce(n, () => ("https://bitsnap.pl")))}:${encodeURIComponent(e)}`;function $(e,n){return typeof window>"u"||!e?void 0:_nullishCoalesce(window.localStorage.getItem(l(e,n)), () => (void 0))}function G(e,n,o,i){typeof window>"u"||!e||(window.localStorage.setItem(l(e,i),n),window.localStorage.setItem(a(e,i),o))}function k(e,n){return typeof window>"u"||!e?null:window.localStorage.getItem(a(e,n))}function E(e,n){typeof window>"u"||!e||(window.localStorage.removeItem(l(e,n)),window.localStorage.removeItem(a(e,n)))}exports.a = w; exports.b = s; exports.c = P; exports.d = v; exports.e = C; exports.f = R; exports.g = x; exports.h = y; exports.i = b; exports.j = L; exports.k = $; exports.l = G; exports.m = k; exports.n = E;
2
- //# sourceMappingURL=chunk-VQQBBSK2.js.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkUFIOJGJZjs = require('./chunk-UFIOJGJZ.js');var _chunkWGJTXDISjs = require('./chunk-WGJTXDIS.js');var t={projectID:void 0,loginURL:"/panel/login",theme:void 0,host:void 0,allowedReturnOrigins:[]},u=[];function w(e){t={...t,...e}}function s(){return t}function P(e){t.projectID=e}function v(e){t.theme=e}function C(e){t.loginURL=e}function R(e){t.host=e}function x(e){u=e,t={...t,allowedReturnOrigins:e}}function y(){return u}var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var f=_react.createContext.call(void 0, s()),b= exports.i =({children:e,analytics:n})=>{let o=s(),i=_chunkWGJTXDISjs.n.call(void 0, o.projectID,n,"panel");return _jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.o,{children:_jsxruntime.jsx.call(void 0, f.Provider,{value:{...o},children:_jsxruntime.jsx.call(void 0, _chunkWGJTXDISjs.l,{value:i,children:_jsxruntime.jsx.call(void 0, "div",{className:"bitsnap-react",children:e})})})})},L= exports.j =()=>_react.useContext.call(void 0, f);var l=(e,n)=>`bitsnap-panel-session:${encodeURIComponent(_nullishCoalesce(n, () => ("https://bitsnap.pl")))}:${encodeURIComponent(e)}`,a=(e,n)=>`bitsnap-panel-email:${encodeURIComponent(_nullishCoalesce(n, () => ("https://bitsnap.pl")))}:${encodeURIComponent(e)}`;function $(e,n){return typeof window>"u"||!e?void 0:_nullishCoalesce(window.localStorage.getItem(l(e,n)), () => (void 0))}function G(e,n,o,i){typeof window>"u"||!e||(window.localStorage.setItem(l(e,i),n),window.localStorage.setItem(a(e,i),o))}function k(e,n){return typeof window>"u"||!e?null:window.localStorage.getItem(a(e,n))}function E(e,n){typeof window>"u"||!e||(window.localStorage.removeItem(l(e,n)),window.localStorage.removeItem(a(e,n)))}exports.a = w; exports.b = s; exports.c = P; exports.d = v; exports.e = C; exports.f = R; exports.g = x; exports.h = y; exports.i = b; exports.j = L; exports.k = $; exports.l = G; exports.m = k; exports.n = E;
2
+ //# sourceMappingURL=chunk-3IVLQILF.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-VQQBBSK2.js","../src/panel/config.ts","../src/panel/PanelProvider.tsx","../src/panel/session-storage.ts"],"names":["config","allowedReturnOrigins","setPanelConfig","newConfig","getPanelConfig","setProjectID","projectID","setTheme","theme","setLoginURL","loginURL","setHost","host","setAllowedReturnOrigins","origins","getAllowedReturnOrigins","PanelContext","createContext","PanelProvider","children","analytics","instrument","useInstrument","jsx","RpcProvider","InstrumentProvider","usePanelConfig","useContext","panelSessionKey"],"mappings":"AAAA,mOAAuC,sDAA+C,ICElFA,CAAAA,CAAsB,CACxB,SAAA,CAAW,KAAA,CAAA,CACX,QAAA,CAAU,cAAA,CACV,KAAA,CAAO,KAAA,CAAA,CACP,IAAA,CAAM,KAAA,CAAA,CACN,oBAAA,CAAsB,CAAC,CACzB,CAAA,CAEIC,CAAAA,CAAiC,CAAC,CAAA,CAU/B,SAASC,CAAAA,CAAeC,CAAAA,CAAuC,CACpEH,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,GAAGG,CAAU,CACrC,CAEO,SAASC,CAAAA,CAAAA,CAA8B,CAC5C,OAAOJ,CACT,CAEO,SAASK,CAAAA,CAAaC,CAAAA,CAAyB,CACpDN,CAAAA,CAAO,SAAA,CAAYM,CACrB,CAEO,SAASC,CAAAA,CAASC,CAAAA,CAA6B,CACpDR,CAAAA,CAAO,KAAA,CAAQQ,CACjB,CAEO,SAASC,CAAAA,CAAYC,CAAAA,CAAwB,CAClDV,CAAAA,CAAO,QAAA,CAAWU,CACpB,CAEO,SAASC,CAAAA,CAAQC,CAAAA,CAAoB,CAC1CZ,CAAAA,CAAO,IAAA,CAAOY,CAChB,CAEO,SAASC,CAAAA,CAAwBC,CAAAA,CAAyB,CAC/Db,CAAAA,CAAuBa,CAAAA,CACvBd,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,oBAAA,CAAsBc,CAAQ,CACtD,CAEO,SAASC,CAAAA,CAAAA,CAAoC,CAClD,OAAOd,CACT,CCnDA,8BAA0C,+CA2BhC,IAlBJe,CAAAA,CAAeC,kCAAAA,CAA2Bb,CAAe,CAAC,CAAA,CAEnDc,CAAAA,aASR,CAAC,CAAE,QAAA,CAAAC,CAAAA,CAAU,SAAA,CAAAC,CAAU,CAAA,CAAA,EAAM,CAChC,IAAMpB,CAAAA,CAASI,CAAAA,CAAe,CAAA,CACxBiB,CAAAA,CAAaC,gCAAAA,CAActB,CAAO,SAAA,CAAWoB,CAAAA,CAAW,OAAO,CAAA,CACrE,OACEG,6BAAAA,kBAACC,CAAA,CACC,QAAA,CAAAD,6BAAAA,CAACP,CAAa,QAAA,CAAb,CAAsB,KAAA,CAAO,CAAE,GAAGhB,CAAO,CAAA,CACxC,QAAA,CAAAuB,6BAAAA,kBAACE,CAAA,CAAmB,KAAA,CAAOJ,CAAAA,CACzB,QAAA,CAAAE,6BAAAA,KAAC,CAAA,CAAI,SAAA,CAAU,eAAA,CAAiB,QAAA,CAAAJ,CAAAA,CAAS,CAAA,CAC3C,CAAA,CACF,CAAA,CACF,CAEJ,CAAA,CAEaO,CAAAA,aAAiB,CAAA,CAAA,EAAMC,+BAAAA,CAAuB,CAAA,CClC3D,IAAMC,CAAAA,CAAkB,CAACtB,CAAAA,CAAmBM,CAAAA,CAAAA,EAC1C,CAAA,sBAAA,EAAyB,kBAAA,kBAAmBA,CAAAA,SAAQ,sBAAoB,CAAC,CAAA,CAAA,EAAI,kBAAA,CAAmBN,CAAS,CAAC,CAAA,CAAA","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-VQQBBSK2.js","sourcesContent":[null,"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"]}
1
+ {"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-3IVLQILF.js","../src/panel/config.ts","../src/panel/PanelProvider.tsx","../src/panel/session-storage.ts"],"names":["config","allowedReturnOrigins","setPanelConfig","newConfig","getPanelConfig","setProjectID","projectID","setTheme","theme","setLoginURL","loginURL","setHost","host","setAllowedReturnOrigins","origins","getAllowedReturnOrigins","PanelContext","createContext","PanelProvider","children","analytics","instrument","useInstrument","jsx","RpcProvider","InstrumentProvider","usePanelConfig","useContext","panelSessionKey"],"mappings":"AAAA,mOAAuC,sDAA+C,ICElFA,CAAAA,CAAsB,CACxB,SAAA,CAAW,KAAA,CAAA,CACX,QAAA,CAAU,cAAA,CACV,KAAA,CAAO,KAAA,CAAA,CACP,IAAA,CAAM,KAAA,CAAA,CACN,oBAAA,CAAsB,CAAC,CACzB,CAAA,CAEIC,CAAAA,CAAiC,CAAC,CAAA,CAU/B,SAASC,CAAAA,CAAeC,CAAAA,CAAuC,CACpEH,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,GAAGG,CAAU,CACrC,CAEO,SAASC,CAAAA,CAAAA,CAA8B,CAC5C,OAAOJ,CACT,CAEO,SAASK,CAAAA,CAAaC,CAAAA,CAAyB,CACpDN,CAAAA,CAAO,SAAA,CAAYM,CACrB,CAEO,SAASC,CAAAA,CAASC,CAAAA,CAA6B,CACpDR,CAAAA,CAAO,KAAA,CAAQQ,CACjB,CAEO,SAASC,CAAAA,CAAYC,CAAAA,CAAwB,CAClDV,CAAAA,CAAO,QAAA,CAAWU,CACpB,CAEO,SAASC,CAAAA,CAAQC,CAAAA,CAAoB,CAC1CZ,CAAAA,CAAO,IAAA,CAAOY,CAChB,CAEO,SAASC,CAAAA,CAAwBC,CAAAA,CAAyB,CAC/Db,CAAAA,CAAuBa,CAAAA,CACvBd,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,oBAAA,CAAsBc,CAAQ,CACtD,CAEO,SAASC,CAAAA,CAAAA,CAAoC,CAClD,OAAOd,CACT,CCnDA,8BAA0C,+CA2BhC,IAlBJe,CAAAA,CAAeC,kCAAAA,CAA2Bb,CAAe,CAAC,CAAA,CAEnDc,CAAAA,aASR,CAAC,CAAE,QAAA,CAAAC,CAAAA,CAAU,SAAA,CAAAC,CAAU,CAAA,CAAA,EAAM,CAChC,IAAMpB,CAAAA,CAASI,CAAAA,CAAe,CAAA,CACxBiB,CAAAA,CAAaC,gCAAAA,CAActB,CAAO,SAAA,CAAWoB,CAAAA,CAAW,OAAO,CAAA,CACrE,OACEG,6BAAAA,kBAACC,CAAA,CACC,QAAA,CAAAD,6BAAAA,CAACP,CAAa,QAAA,CAAb,CAAsB,KAAA,CAAO,CAAE,GAAGhB,CAAO,CAAA,CACxC,QAAA,CAAAuB,6BAAAA,kBAACE,CAAA,CAAmB,KAAA,CAAOJ,CAAAA,CACzB,QAAA,CAAAE,6BAAAA,KAAC,CAAA,CAAI,SAAA,CAAU,eAAA,CAAiB,QAAA,CAAAJ,CAAAA,CAAS,CAAA,CAC3C,CAAA,CACF,CAAA,CACF,CAEJ,CAAA,CAEaO,CAAAA,aAAiB,CAAA,CAAA,EAAMC,+BAAAA,CAAuB,CAAA,CClC3D,IAAMC,CAAAA,CAAkB,CAACtB,CAAAA,CAAmBM,CAAAA,CAAAA,EAC1C,CAAA,sBAAA,EAAyB,kBAAA,kBAAmBA,CAAAA,SAAQ,sBAAoB,CAAC,CAAA,CAAA,EAAI,kBAAA,CAAmBN,CAAS,CAAC,CAAA,CAAA","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-3IVLQILF.js","sourcesContent":[null,"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"]}