bitsnap-react 1.22.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/AGENTS.md +20 -0
  2. package/dist/BitsnapCart-GK3MQGP7.js +2 -0
  3. package/dist/BitsnapCart-GK3MQGP7.js.map +1 -0
  4. package/dist/BitsnapCart-ZC6LMXLO.mjs +2 -0
  5. package/dist/CartProvider-FJDBDV4N.js +2 -0
  6. package/dist/CartProvider-FJDBDV4N.js.map +1 -0
  7. package/dist/{CartProvider-YUV2Q523.mjs → CartProvider-P7BZVK2M.mjs} +2 -2
  8. package/dist/PanelModelFiles-EKQRLF46.js.map +1 -1
  9. package/dist/analytics.js +1 -1
  10. package/dist/analytics.js.map +1 -1
  11. package/dist/analytics.mjs +1 -1
  12. package/dist/catalog.js +1 -1
  13. package/dist/catalog.js.map +1 -1
  14. package/dist/catalog.mjs +1 -1
  15. package/dist/chat.js +1 -1
  16. package/dist/chat.js.map +1 -1
  17. package/dist/chat.mjs +1 -1
  18. package/dist/{chunk-SAKZOHU7.js → chunk-2CL4B4KM.js} +2 -2
  19. package/dist/chunk-2CL4B4KM.js.map +1 -0
  20. package/dist/chunk-2D2TQK3R.js +2 -0
  21. package/dist/chunk-2D2TQK3R.js.map +1 -0
  22. package/dist/{chunk-C2AJ5B32.mjs → chunk-4AU5SEHU.mjs} +2 -2
  23. package/dist/chunk-6Q3VGPSF.js.map +1 -1
  24. package/dist/{chunk-ZFZR3CI5.js → chunk-7GSQV4NW.js} +2 -2
  25. package/dist/chunk-7GSQV4NW.js.map +1 -0
  26. package/dist/{chunk-WYRECFVW.js → chunk-CA5EJJW7.js} +2 -2
  27. package/dist/chunk-CA5EJJW7.js.map +1 -0
  28. package/dist/{chunk-U37ZH4YJ.js → chunk-DCICRN6G.js} +2 -2
  29. package/dist/chunk-DCICRN6G.js.map +1 -0
  30. package/dist/{chunk-QQSCVPOG.mjs → chunk-EVV25IKM.mjs} +2 -2
  31. package/dist/{chunk-QQSCVPOG.mjs.map → chunk-EVV25IKM.mjs.map} +1 -1
  32. package/dist/{chunk-MBSXTB6G.js → chunk-EVX5SQL2.js} +2 -2
  33. package/dist/chunk-EVX5SQL2.js.map +1 -0
  34. package/dist/chunk-FVZ4W7QG.js +5 -0
  35. package/dist/chunk-FVZ4W7QG.js.map +1 -0
  36. package/dist/chunk-GMQYQTUM.mjs +2 -0
  37. package/dist/chunk-GMQYQTUM.mjs.map +1 -0
  38. package/dist/{chunk-35ZQU353.js → chunk-I6QN3T6K.js} +2 -2
  39. package/dist/chunk-I6QN3T6K.js.map +1 -0
  40. package/dist/chunk-ILYJCT5S.js +2 -0
  41. package/dist/chunk-ILYJCT5S.js.map +1 -0
  42. package/dist/{chunk-QJOMFK4X.mjs → chunk-JRSQ2IGQ.mjs} +2 -2
  43. package/dist/chunk-JSDGZ4NY.js.map +1 -1
  44. package/dist/chunk-KOYBZORL.js.map +1 -1
  45. package/dist/{chunk-5MXBUGY3.mjs → chunk-M6QFQ3DR.mjs} +2 -2
  46. package/dist/chunk-MDAFPGPA.js.map +1 -1
  47. package/dist/{chunk-KFY6IOAA.js → chunk-MY6BPCRV.js} +2 -2
  48. package/dist/{chunk-ZFUE3AX5.mjs.map → chunk-MY6BPCRV.js.map} +1 -1
  49. package/dist/{chunk-QCIETNFZ.mjs → chunk-NMXTTD5M.mjs} +2 -2
  50. package/dist/chunk-PFKZ7KUU.js.map +1 -1
  51. package/dist/chunk-Q337IQNA.js.map +1 -1
  52. package/dist/{chunk-IVB3E4V3.mjs → chunk-RA6M3TJ3.mjs} +2 -2
  53. package/dist/{chunk-NCCP2UDM.mjs → chunk-SKQJESEB.mjs} +2 -2
  54. package/dist/chunk-STDV54FL.mjs +2 -0
  55. package/dist/chunk-STDV54FL.mjs.map +1 -0
  56. package/dist/{chunk-JS3KK56H.js → chunk-SZLSKIYU.js} +2 -2
  57. package/dist/chunk-SZLSKIYU.js.map +1 -0
  58. package/dist/chunk-W3RGQYPD.js.map +1 -1
  59. package/dist/{chunk-TVZLDLAV.mjs → chunk-W4EUYPJ3.mjs} +2 -2
  60. package/dist/chunk-Z3YOJ6NZ.js.map +1 -1
  61. package/dist/chunk-ZMEWUEZJ.mjs +5 -0
  62. package/dist/chunk-ZMEWUEZJ.mjs.map +1 -0
  63. package/dist/consent.js.map +1 -1
  64. package/dist/course.js +1 -1
  65. package/dist/course.js.map +1 -1
  66. package/dist/course.mjs +1 -1
  67. package/dist/embed/analytics.js +1 -1
  68. package/dist/errors.js.map +1 -1
  69. package/dist/index.css +1 -1
  70. package/dist/index.css.map +1 -1
  71. package/dist/index.js +1 -1
  72. package/dist/index.js.map +1 -1
  73. package/dist/index.mjs +1 -1
  74. package/dist/index.mjs.map +1 -1
  75. package/dist/internal.js.map +1 -1
  76. package/dist/methods-IEHZTZEY.mjs +2 -0
  77. package/dist/methods-S4KBRY2I.js +2 -0
  78. package/dist/methods-S4KBRY2I.js.map +1 -0
  79. package/dist/model-files-client-P4PORZJ6.js.map +1 -1
  80. package/dist/models.js.map +1 -1
  81. package/dist/returns.js +1 -1
  82. package/dist/returns.js.map +1 -1
  83. package/dist/returns.mjs +1 -1
  84. package/dist/viewer3d.js.map +1 -1
  85. package/dist/viewer3d.mjs +1 -1
  86. package/package.json +2 -2
  87. package/dist/BitsnapCart-AINUJQVF.mjs +0 -2
  88. package/dist/BitsnapCart-GP2UJSG4.js +0 -2
  89. package/dist/BitsnapCart-GP2UJSG4.js.map +0 -1
  90. package/dist/CartProvider-HTKGBPVA.js +0 -2
  91. package/dist/CartProvider-HTKGBPVA.js.map +0 -1
  92. package/dist/chunk-35ZQU353.js.map +0 -1
  93. package/dist/chunk-3TUL63IC.js +0 -2
  94. package/dist/chunk-3TUL63IC.js.map +0 -1
  95. package/dist/chunk-4JR74NXR.js +0 -2
  96. package/dist/chunk-4JR74NXR.js.map +0 -1
  97. package/dist/chunk-GLKBCVNH.mjs +0 -2
  98. package/dist/chunk-GLKBCVNH.mjs.map +0 -1
  99. package/dist/chunk-JS3KK56H.js.map +0 -1
  100. package/dist/chunk-KFY6IOAA.js.map +0 -1
  101. package/dist/chunk-MBSXTB6G.js.map +0 -1
  102. package/dist/chunk-QJBQ45R6.mjs +0 -5
  103. package/dist/chunk-QJBQ45R6.mjs.map +0 -1
  104. package/dist/chunk-SAKZOHU7.js.map +0 -1
  105. package/dist/chunk-SZNTXRFD.js +0 -5
  106. package/dist/chunk-SZNTXRFD.js.map +0 -1
  107. package/dist/chunk-U37ZH4YJ.js.map +0 -1
  108. package/dist/chunk-WYRECFVW.js.map +0 -1
  109. package/dist/chunk-ZFUE3AX5.mjs +0 -2
  110. package/dist/chunk-ZFZR3CI5.js.map +0 -1
  111. package/dist/methods-4Q37ITIM.js +0 -2
  112. package/dist/methods-4Q37ITIM.js.map +0 -1
  113. package/dist/methods-JLVRTNPE.mjs +0 -2
  114. /package/dist/{BitsnapCart-AINUJQVF.mjs.map → BitsnapCart-ZC6LMXLO.mjs.map} +0 -0
  115. /package/dist/{CartProvider-YUV2Q523.mjs.map → CartProvider-P7BZVK2M.mjs.map} +0 -0
  116. /package/dist/{chunk-C2AJ5B32.mjs.map → chunk-4AU5SEHU.mjs.map} +0 -0
  117. /package/dist/{chunk-QJOMFK4X.mjs.map → chunk-JRSQ2IGQ.mjs.map} +0 -0
  118. /package/dist/{chunk-5MXBUGY3.mjs.map → chunk-M6QFQ3DR.mjs.map} +0 -0
  119. /package/dist/{chunk-QCIETNFZ.mjs.map → chunk-NMXTTD5M.mjs.map} +0 -0
  120. /package/dist/{chunk-IVB3E4V3.mjs.map → chunk-RA6M3TJ3.mjs.map} +0 -0
  121. /package/dist/{chunk-NCCP2UDM.mjs.map → chunk-SKQJESEB.mjs.map} +0 -0
  122. /package/dist/{chunk-TVZLDLAV.mjs.map → chunk-W4EUYPJ3.mjs.map} +0 -0
  123. /package/dist/{methods-JLVRTNPE.mjs.map → methods-IEHZTZEY.mjs.map} +0 -0
@@ -0,0 +1,5 @@
1
+ import{E as Fn,H as Hn,I as qn,J as $n,K as Bn,L as Kn,M as Gn,a as gr,b as xn,c as At,d as Qe,e as Mt,f as Cn,h as Nn,i as Sn,j as In,k as Tn,p as Dn,q as Mn,r as On,s as Un,t as _n,v as zn,w as jn}from"./chunk-W4EUYPJ3.mjs";import{b as se}from"./chunk-RA6M3TJ3.mjs";import{e as _,f as Ae,g as ie,h as wn,l as L,m as Dt,o as Rn,p as et,q as An}from"./chunk-GMQYQTUM.mjs";import{a as Pn}from"./chunk-HKRH6FI6.mjs";import{a as Fe,b as En,c as Ln,d as Xe}from"./chunk-XEXPQFKN.mjs";import{a as pr,g as yt,h as ht}from"./chunk-CUPG4B5W.mjs";import{a as dr,b as ur,d as Et,e as cr,f as yn,g as hn,h as bn}from"./chunk-STDV54FL.mjs";import{a as H}from"./chunk-5R6AGO3Z.mjs";import{a as sr,b as gn,c as lr,e as Q,f as kn}from"./chunk-4AU5SEHU.mjs";import{h as mr,l as Lt,m as Rt,n as Ye,o as vn}from"./chunk-EVV25IKM.mjs";import{a as Je,c as Re,e as fr,f as E}from"./chunk-OFPRIENJ.mjs";import{useAutoAnimate as za}from"@formkit/auto-animate/react";import{useEffect as Jn,useMemo as vr,useRef as Qn,useState as ja}from"react";import{jsx as bt}from"react/jsx-runtime";function De({className:e,...t}){return bt("div",{"data-slot":"card",className:H("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function He({className:e,...t}){return bt("div",{"data-slot":"card-header",className:H("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function qe({className:e,...t}){return bt("div",{"data-slot":"card-title",className:H("leading-none font-semibold",e),...t})}function Wn({className:e,...t}){return bt("div",{"data-slot":"card-description",className:H("text-muted-foreground text-sm",e),...t})}function Me({className:e,...t}){return bt("div",{"data-slot":"card-content",className:H("px-6",e),...t})}import{CircleCheck as Ta}from"lucide-react";import{useId as Ea}from"react";import{jsx as q,jsxs as X}from"react/jsx-runtime";var La="text-muted-foreground text-xs leading-5",Ra="dark:border-foreground/30 dark:focus-visible:border-foreground/70 dark:focus-visible:ring-foreground/25 dark:aria-invalid:border-destructive-foreground dark:aria-invalid:ring-destructive-foreground/30",Aa=new Set(["invalidEmail","emailNotFound","deliveryUnavailable"]),yr="inline-flex min-h-11 items-center px-1 text-sm underline underline-offset-4 hover:no-underline focus-visible:ring-[3px] focus-visible:ring-ring/50 rounded-sm outline-none disabled:opacity-50 disabled:no-underline";function Vn({login:e,texts:t,allowHaveCode:n=!0,emailPlaceholder:a,emailInputId:r,codeInputId:o,className:i,buttonClassName:d,children:u}){let l=Ea(),m=r??`${l}-email`,P=o??`${l}-code`,b=`${l}-notice`,k=`${l}-hint`,{notice:f}=e,c=f?.kind==="error",p=e.busy==="send",g=e.busy==="verify",v=e.busy==="resend",I=H("h-11 w-full",d),U=f?.kind==="success",S=X("div",{id:b,className:"min-h-10 text-sm leading-5",children:[q("p",{role:"alert",className:"font-medium text-red-700 dark:text-red-400",children:c?f.text:null}),X("p",{role:"status",className:H("flex items-start gap-1.5",U?"font-medium text-emerald-700 dark:text-emerald-400":"text-foreground"),children:[U&&q(Ta,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0"}),q("span",{children:f!=null&&!c?f.text:null})]})]}),pe=c&&e.step==="email"&&(f.failure==null||Aa.has(f.failure)),Te=q("p",{className:"sr-only",role:"status","aria-live":"polite",children:e.announcement}),ae=X("div",{className:"grid gap-2",children:[q(Qe,{htmlFor:m,children:t.emailLabel}),q(Dt,{id:m,ref:e.emailRef,name:"email",type:"email",autoComplete:"email",inputMode:"email",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,autoFocus:!0,required:!0,className:H("h-11 text-base disabled:opacity-100 disabled:text-foreground/70",Ra),placeholder:a??t.emailPlaceholder,value:e.email,disabled:e.isBusy,"aria-invalid":pe?!0:void 0,"aria-describedby":b,onChange:J=>e.setEmail(J.target.value)})]});if(e.step==="email")return X("form",{noValidate:!0,className:H("flex flex-col gap-4",i),onSubmit:J=>{J.preventDefault(),e.sendCode()},children:[Te,ae,S,X(L,{type:"submit",disabled:e.isBusy,"aria-busy":p,className:I,children:[p&&q(Mt,{"aria-hidden":!0}),p?t.sending:t.sendCode]}),n&&X("p",{className:"flex flex-wrap items-center justify-center text-center text-sm",children:[t.haveCodePrompt!==""&&q("span",{children:t.haveCodePrompt}),q("button",{type:"button",className:yr,disabled:e.isBusy,onClick:e.haveCode,children:t.haveCode})]})]});let[re,ye]=t.codeSentTo.split("{email}"),T=e.dead!=null,he=T?t.resendNew:e.secondsLeft>0?Sn(t.resendIn,{seconds:e.secondsLeft}):t.resend;return X("form",{noValidate:!0,className:H("flex flex-col gap-4",i),onSubmit:J=>{J.preventDefault(),e.submitCode()},children:[Te,e.needsEmail?ae:X("div",{className:"flex flex-wrap items-center justify-between gap-x-2",children:[X("p",{className:"min-w-0 flex-[1_1_14rem] text-sm leading-5 break-words",children:[re,q("strong",{className:"font-semibold",children:e.email}),"\u2060",ye]}),q("button",{type:"button",className:H(yr,"-ml-1 shrink-0"),disabled:e.isBusy,onClick:e.changeEmail,children:t.changeEmail})]}),u,X("div",{className:"grid gap-2",children:[q(Qe,{htmlFor:P,children:t.codeLabel}),q(Tn,{id:P,name:"code",inputRef:e.codeRef,value:e.code,onChange:e.setCode,onComplete:J=>void e.submitCode(J),disabled:e.isBusy||T,invalid:c&&!e.needsEmail,"aria-describedby":`${b} ${k}`}),X("p",{id:k,className:La,children:[t.validity," ",t.spamHint]})]}),S,X(L,{type:"submit",disabled:e.isBusy||T,"aria-busy":g,className:I,children:[g&&q(Mt,{"aria-hidden":!0}),g?t.verifying:t.verify]}),e.needsEmail?q("div",{className:"flex justify-center",children:q("button",{type:"button",className:yr,disabled:e.isBusy,onClick:e.changeEmail,children:t.noCode})}):X(L,{type:"button",variant:T?"default":"outline",disabled:e.isBusy||!T&&e.secondsLeft>0,"aria-busy":v,className:T?I:"h-11 w-full",onClick:()=>void e.resend(),children:[v&&q(Mt,{"aria-hidden":!0}),he]})]})}function hr(e){switch(e){case 1:return"emailNotFound";case 2:return"invalidEmail";case 3:return"wrongCode";case 14:return"expired";case 15:return"tooManyAttempts";case 13:return"rateLimited";case 16:return"captchaRequired";case 17:return"captchaInvalid";case 12:return"deliveryFailed";case 11:return"deliveryUnavailable";default:return"unknown"}}var Da={pl:{title:"Zaloguj si\u0119",description:"Wy\u015Blemy do Ciebie kod na maila, dzi\u0119ki kt\xF3remu si\u0119 zalogujesz.",codeTitle:"Wpisz kod z maila",codeDescription:"Kod ma 6 cyfr."},en:{title:"Sign in",description:"We will email you a code that signs you in.",codeTitle:"Enter the code from the email",codeDescription:"The code has 6 digits."}};function Zn(e=E(),t){return{...Nn(e,t),...Je(Da,e),...Ma(t,["title","description","codeTitle","codeDescription"])}}function Ma(e,t){let n={};for(let a of t){let r=e?.[a];r!=null&&(n[a]=r)}return n}var Oa="return_url",br="__return_url",Ua="accessToken";function Pt(e){let t=new URLSearchParams(e).get(Oa);return t?Yn(t):null}function vt(e){typeof window>"u"||(e?window.sessionStorage.setItem(br,e):window.sessionStorage.removeItem(br))}function tt(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(br);return e?Yn(e):null}function _a(e,t){return t.some(n=>{if(e===n)return!0;let a=new URL(n).hostname,r=new URL(e).hostname;return r.endsWith(`.${a}`)||r===a})}function Yn(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!_a(t.origin,ht())?null:t.toString()}catch{return null}}function rt(e,t){let n=new URL(e);return n.searchParams.set(Ua,t),n.toString()}import{jsx as le,jsxs as Pr}from"react/jsx-runtime";if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];ht().length===0&&yt(Array.from(new Set(t)))}var Fa=({texts:e,projectID:t,host:n,locale:a,logo:r})=>{let[o,i]=ja(!1),d=Qn(void 0),u=Qn(""),l=vr(()=>()=>new Promise(v=>{i(!0);let I=window.setTimeout(()=>{d.current=void 0,i(!1),v(!1)},5*60*1e3);d.current=U=>{window.clearTimeout(I),d.current=void 0,i(!1),u.current=U??"",v(U!==null)}}),[]),m=Rt(),{mutateAsync:P}=ie(_.publicApi.userPanelLogin),{mutateAsync:b}=ie(_.publicApi.userPanelLoginWithCode),k=vr(()=>({async send(v){try{let I=await P({email:v,turnstileToken:u.current});return u.current="",I.result.case==="success"?{ok:!0,retryIn:I.result.value.retryIn||void 0,challengeId:I.result.value.challengeId||void 0}:{ok:!1,kind:hr(I.result.case==="failure"?I.result.value:0)}}catch(I){return{ok:!1,kind:gr(I),cause:I}}},async verify({email:v,code:I,challengeId:U}){try{let S=await b({code:parseInt(I,10),email:v,challengeId:U});return S.result.case==="accessToken"&&S.result.value?{ok:!0,value:{accessToken:S.result.value}}:{ok:!1,kind:hr(S.result.case==="failure"?S.result.value:0)}}catch(S){return{ok:!1,kind:gr(S),cause:S}}}}),[P,b]),f=In({adapter:k,texts:e,beforeSend:l,storageKey:Cn("panel",t,n),onVerified:({accessToken:v},I)=>{m.track("panel_login",{}),En(t,v,I,n);let U=typeof window<"u"?tt():null;setTimeout(()=>{if(U){window.location.href=rt(U,v);return}window.location.reload()},100)}}),c=f.step==="code",p=c&&!f.needsEmail?e.codeTitle:e.title,g=c&&!f.needsEmail?e.codeDescription:e.description;return le("main",{className:"mx-auto flex w-full max-w-sm flex-1 flex-col justify-start pt-4 sm:pt-[12vh]",children:Pr(De,{children:[le(At,{projectId:t,locale:a,className:"px-4 sm:px-6",...r}),Pr(He,{className:"px-4 sm:px-6",children:[le(qe,{role:"heading","aria-level":1,className:"text-2xl",children:p}),le(Wn,{children:g})]}),Pr(Me,{className:"px-4 sm:px-6",children:[le(Vn,{login:f,texts:e,emailInputId:"email",codeInputId:"verify-code"}),o&&le(Pn,{action:"panel_login",locale:a,onToken:v=>d.current?.(v),onFailure:()=>d.current?.(null)})]})]})})},Ha=({analytics:e,texts:t,locale:n,showLogo:a,logoUrl:r,logoDarkUrl:o})=>{let{theme:i,allowedReturnOrigins:d,projectID:u,host:l}=se(),m=Ye(u,e,"panel"),P=vr(()=>Zn(n??E(),t),[n,t]),b={"--button-background-color":i?.colors?.brand??"#FFFFFF","--button-background-color-dark":i?.colors?.brandDark??"#000000","--button-text-color":i?.colors?.brandDark??"#000000","--button-text-color-dark":i?.colors?.brand??"#FFFFFF"},[k]=za({duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1});return Jn(()=>{typeof window>"u"||Fe(u,l)!=null&&(window.location.href=window.location.href.replaceAll("login",""))},[u,l]),Jn(()=>{if(typeof window>"u"||window.parent!==window)return;let f=Pt(window.location.search);f&&vt(f);let c=f??tt();if(!c)return;let p=Fe(u,l);p&&(window.location.href=rt(c,p))},[d,u,l]),le(Lt,{value:m,children:le("div",{className:"bg-white text-black dark:bg-black dark:text-white",children:le("div",{className:"font-inter flex min-h-screen w-full flex-col p-4",style:b,ref:k,children:le(Fa,{texts:P,projectID:u,host:l,locale:n,logo:{showLogo:a,logoUrl:r??i?.logoURL,logoDarkUrl:o??i?.logoDarkURL}})})})})},qa=(e={})=>le(Ha,{...e});import{useAutoAnimate as Gs}from"@formkit/auto-animate/react";import{useEffect as Ht,useState as Ko}from"react";import{useState as $a,useCallback as Ba,useEffect as Ka}from"react";function Xn(e){let[t,n]=$a(()=>{if(typeof window>"u")return e;let r=new URLSearchParams(window.location.search),o={};return Object.keys(e).forEach(i=>{let d=r.get(i);if(d!==null)try{o[i]=JSON.parse(d)}catch{o[i]=d}}),{...e,...o}}),a=Ba(r=>{n(o=>{let i={...o,...r};if(typeof window<"u"){let d=new URLSearchParams;Object.keys(i).forEach(l=>{let m=i[l];m!=null&&d.set(l,JSON.stringify(m))});let u=`${window.location.pathname}?${d.toString()}`;window.history.pushState({},"",u)}return i})},[]);return Ka(()=>{let r=()=>{let o=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(d=>{let u=o.get(d);if(u!==null)try{i[d]=JSON.parse(u)}catch{i[d]=u}}),n({...e,...i})};return window.addEventListener("popstate",r),()=>window.removeEventListener("popstate",r)},[e]),[t,a]}function eo(e,t){if(e!=null)return e;let n=t?.trim();if(!(n==null||n===""))return{tokens:Rn(n)}}var Ga={pl:{returnsNavLabel:"Zwroty",openCourse:"Otw\xF3rz kurs",libraryNavLabel:"Biblioteka",messagesNavLabel:"Wiadomo\u015Bci",ordersNavLabel:"Zam\xF3wienia",accountNavLabel:"Konto",navigationLabel:"Panel klienta",logout:"Wyloguj si\u0119",profileHeading:"Profil",emailLabel:"E-mail",noData:"Brak danych",languageLabel:"J\u0119zyk",polishLanguage:"Polski",englishLanguage:"English",plansHeading:"Plany",plansUnavailable:"Plany nie s\u0105 obecnie dost\u0119pne w panelu.",notificationsHeading:"Powiadomienia",notificationsUnavailable:"Ustawienia powiadomie\u0144 nie s\u0105 obecnie dost\u0119pne w panelu.",ordersHeading:"Historia zam\xF3wie\u0144",ordersDescription:"Twoje zam\xF3wienia",ordersEmpty:"Brak zam\xF3wie\u0144.",ordersError:"Nie uda\u0142o si\u0119 pobra\u0107 zam\xF3wie\u0144.",retry:"Spr\xF3buj ponownie",orderLabel:"Zam\xF3wienie",customerLabel:"Klient",dateLabel:"Data",ordersEnd:"To ju\u017C wszystkie Twoje zam\xF3wienia.",previousPage:"Poprzednia strona",nextPage:"Nast\u0119pna strona",paginationLabel:"Strony zam\xF3wie\u0144",statusDraft:"Szkic",statusUnpaid:"Nieop\u0142acone",statusPaid:"Op\u0142acone",statusOverdue:"Zaleg\u0142e",statusCancelled:"Anulowane",statusCompleted:"Zako\u0144czone",statusProcessing:"Przetwarzane",statusRefunded:"Zwr\xF3cone",statusCreated:"Utworzone",statusSent:"Wys\u0142ane",statusIssue:"Wymaga uwagi",statusReturned:"Zwr\xF3cone"},en:{returnsNavLabel:"Returns",openCourse:"Open the course",libraryNavLabel:"Library",messagesNavLabel:"Messages",ordersNavLabel:"Orders",accountNavLabel:"Account",navigationLabel:"Customer panel",logout:"Log out",profileHeading:"Profile",emailLabel:"Email",noData:"No data",languageLabel:"Language",polishLanguage:"Polski",englishLanguage:"English",plansHeading:"Plans",plansUnavailable:"Plans are currently unavailable in the panel.",notificationsHeading:"Notifications",notificationsUnavailable:"Notification settings are currently unavailable in the panel.",ordersHeading:"Order history",ordersDescription:"Your orders",ordersEmpty:"No orders yet.",ordersError:"Could not load your orders.",retry:"Try again",orderLabel:"Order",customerLabel:"Customer",dateLabel:"Date",ordersEnd:"You\u2019ve reached the end of your orders.",previousPage:"Previous page",nextPage:"Next page",paginationLabel:"Order pages",statusDraft:"Draft",statusUnpaid:"Unpaid",statusPaid:"Paid",statusOverdue:"Overdue",statusCancelled:"Cancelled",statusCompleted:"Completed",statusProcessing:"Processing",statusRefunded:"Refunded",statusCreated:"Created",statusSent:"Shipped",statusIssue:"Needs attention",statusReturned:"Returned"}};function ee(e=E()){return Je(Ga,e)}var Wa={draft:"statusDraft",created:"statusCreated",unpaid:"statusUnpaid",paid:"statusPaid",overdue:"statusOverdue",cancelled:"statusCancelled",canceled:"statusCancelled",completed:"statusCompleted",processing:"statusProcessing",refunded:"statusRefunded",sent:"statusSent",issue:"statusIssue",returned:"statusReturned"};function Ot(e,t=ee()){let n=Wa[e.trim().toLowerCase()];return n==null?void 0:t[n]}import{jsx as to,jsxs as Va}from"react/jsx-runtime";function kr({}){let e=ee();return Va("section",{children:[to("h3",{className:"text-2xl",children:e.notificationsHeading}),to("p",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:e.notificationsUnavailable})]})}import{useState as Za}from"react";import{Fragment as ei,jsx as O,jsxs as V}from"react/jsx-runtime";var Ya=e=>new Date(e*1e3).toLocaleDateString(E(),{year:"numeric",month:"short",day:"numeric"}),Ja=(e,t)=>new Intl.NumberFormat(E(),{style:"currency",currency:t.toUpperCase()}).format(e/100),Qa={draft:"text-neutral-600 dark:text-neutral-400",unpaid:"text-amber-700 dark:text-amber-300",paid:"text-green-700 dark:text-green-400",overdue:"text-red-700 dark:text-red-400",cancelled:"text-neutral-600 line-through dark:text-neutral-400",completed:"text-green-700 dark:text-green-400",processing:"text-blue-700 dark:text-blue-400",refunded:"text-purple-700 dark:text-purple-400"};function Xa({openOrderDetails:e,projectID:t,accessToken:n}){let a=ee(),[r,o]=Za(0),i=20,{data:d,isFetching:u,isError:l,refetch:m}=Ae(_.publicApi.getOrders,{projectId:t,accessToken:n,offset:r,limit:i}),P=d?.orders??[],b=d?.totalCount??0,k=Math.floor(r/i)+1,f=Math.ceil(b/i),c=p=>{o(p)};return V(ei,{children:[O("h3",{className:"text-2xl",children:a.ordersHeading}),O("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:a.ordersDescription}),u?O("div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((p,g)=>V("div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[V("div",{className:"flex items-center justify-between gap-3",children:[V("div",{className:"space-y-2",children:[O(et,{className:"h-4 w-24"}),O(et,{className:"h-3 w-32"})]}),V("div",{className:"space-y-2 text-right",children:[O(et,{className:"ml-auto h-4 w-16"}),O(et,{className:"ml-auto h-3 w-12"})]})]}),O("div",{className:"mt-3",children:O(et,{className:"h-3 w-40"})})]},g))}):l?V("div",{role:"alert",className:"mt-6 space-y-3",children:[O("p",{children:a.ordersError}),O(L,{onClick:()=>void m(),className:"min-h-11 focus-visible:outline-2 focus-visible:outline-current",children:a.retry})]}):P.length===0?O("div",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:a.ordersEmpty}):V("div",{children:[O("div",{className:"mt-6 flex w-full flex-col gap-3",children:P.map(p=>V("button",{onClick:()=>e(p.id),className:"block min-h-11 focus-visible:outline-2 focus-visible:outline-current rounded-xl bg-white p-4 text-left shadow-sm transition-colors hover:bg-neutral-50 dark:bg-neutral-800 dark:hover:bg-neutral-700",children:[V("div",{className:"flex items-center justify-between gap-3",children:[V("div",{className:"min-w-0 break-words",children:[V("p",{className:"font-medium",children:[a.orderLabel," #",p.id]}),O("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:p.customerName||a.customerLabel})]}),V("div",{className:"shrink-0 text-right",children:[O("p",{className:"font-semibold",children:Ja(p.totalAmount,p.currency)}),O("p",{className:`text-xs font-medium ${Qa[p.status]??"text-neutral-400"}`,children:Ot(p.status,a)??p.status})]})]}),O("div",{className:"mt-2 flex items-center justify-between gap-3 text-xs text-neutral-500 dark:text-neutral-400",children:V("span",{children:[a.dateLabel,":"," ",p.createdAt?Ya(Number(p.createdAt.seconds)):"-"]})})]},p.id))}),k>=f&&O("p",{className:"mt-6 text-center text-sm text-neutral-600 dark:text-neutral-400",children:a.ordersEnd}),f>1&&V("nav",{"aria-label":a.paginationLabel,className:"mt-4 flex flex-wrap items-center justify-center gap-2",children:[k>1&&O(L,{variant:"outline",className:"min-h-11",onClick:()=>c(r-i),children:a.previousPage}),Array.from(new Set([1,k-1,k,k+1,f])).filter(p=>p>0&&p<=f).sort((p,g)=>p-g).map(p=>O(L,{variant:p===k?"secondary":"ghost",className:"min-h-11 min-w-11","aria-current":p===k?"page":void 0,onClick:()=>c((p-1)*i),children:p},p)),k<f&&O(L,{variant:"outline",className:"min-h-11",onClick:()=>c(r+i),children:a.nextPage})]})]})]})}var ro=Xa;import{jsx as no,jsxs as ti}from"react/jsx-runtime";function wr({projectID:e}){let t=ee();return ti("section",{children:[no("h3",{className:"text-2xl",children:t.plansHeading}),no("p",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:t.plansUnavailable})]})}import{useEffect as ri,useState as xr}from"react";import{jsx as de,jsxs as ai}from"react/jsx-runtime";function ni(e,t,n,a){typeof window>"u"||(t&&Xe(n,a),window.location.href=e)}function oi({projectID:e,host:t,loginURL:n,screen:a,params:r,setParams:o,setActiveScreen:i}){let{status:d,exchangeError:u}=zn("PanelReturns"),l=_n(),m=d==="anonymous"&&(u==null||Dn(u));ri(()=>{m&&ni(n,u!=null,e,t)},[m,n,u,e,t]);let[P,b]=xr("orders"),[k,f]=xr({items:[],note:""}),[c,p]=xr();if(d==="anonymous"&&!m)return ai("div",{role:"alert",className:"flex flex-col items-start gap-3",children:[de("p",{className:"text-sm",children:l(Mn(u))}),de(L,{type:"button",onClick:()=>window.location.reload(),children:l("errorRetry")})]});if(d!=="authenticated")return de(Fn,{});let g=v=>{b(v),o({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(a==="return-details"&&r.returnId)return de(Gn,{returnId:r.returnId,onBack:()=>g("myReturns")});if(P==="myReturns")return de(Kn,{onBack:()=>g("orders"),onSelectReturn:v=>{o({state:"return-details",returnId:v,orderId:void 0}),i("return-details")}});if(P==="result"&&c!=null)return de(Bn,{returnId:c,onContinue:()=>g("orders"),onOpenMyReturns:()=>g("myReturns")});if(r.orderId){let v=r.orderId;return P==="confirmation"?de($n,{orderId:v,items:k.items,note:k.note,onBack:()=>b("orders"),onSubmitted:I=>{p(I),f({items:[],note:""}),b("result"),o({orderId:void 0})}}):de(qn,{orderId:v,initialItems:k.items.length>0?k.items:void 0,initialNote:k.note,onBack:()=>{f({items:[],note:""}),o({orderId:void 0})},onContinue:I=>{f(I),b("confirmation")}})}return de(Hn,{showLogout:!1,onSelectOrder:v=>{f({items:[],note:""}),b("orders"),o({orderId:v})},onOpenMyReturns:()=>g("myReturns")})}function Cr({accessToken:e,appearance:t,texts:n,...a}){return de(jn,{projectID:a.projectID,host:a.host,appearance:t,texts:n,panelAccessToken:e,children:de(oi,{...a})})}import{lazy as Ki,Suspense as Gi,useEffect as Rr,useState as Wi}from"react";import{BookOpen as Vi,Files as Zi,Headphones as Yi,MessageCircle as Ji,Ticket as Qi,Users as Xi}from"lucide-react";var ii={hello:"Hej \u{1F44B}",intro:"Poni\u017Cej znajdziesz swoje produkty",loading:"\u0141adowanie produkt\xF3w\u2026",empty:"Nie masz jeszcze produkt\xF3w w tym sklepie. Twoje zakupy pojawi\u0105 si\u0119 tutaj.",audio:"Audio",files:"Pliki",course:"Kurs",ticket:"Bilet",chat:"Czat",community:"Spo\u0142eczno\u015B\u0107",openMessages:"Otw\xF3rz wiadomo\u015Bci",listen:"S\u0142uchaj",openCourse:"Otw\xF3rz kurs",downloadFiles:"Pobierz pliki",showTicket:"Poka\u017C bilet",back:"Wr\xF3\u0107",yourFiles:"Twoje pliki",download:"Pobierz",retry:"Spr\xF3buj ponownie",fileError:"Nie uda\u0142o si\u0119 wczyta\u0107 plik\xF3w.",noFiles:"Brak plik\xF3w do pobrania.",ticketInfo:"Tw\xF3j zakupiony bilet",file:"Plik"},si={hello:"Hi \u{1F44B}",intro:"Your products are below",loading:"Loading products\u2026",empty:"You have no products in this shop yet. Your purchases will show up here.",audio:"Audio",files:"Files",course:"Course",ticket:"Ticket",chat:"Chat",community:"Community",openMessages:"Open messages",listen:"Listen",openCourse:"Open course",downloadFiles:"Download files",showTicket:"Show ticket",back:"Back",yourFiles:"Your files",download:"Download",retry:"Try again",fileError:"Your files could not be loaded.",noFiles:"No files to download.",ticketInfo:"Your purchased ticket",file:"File"};function nt(){return E().toLowerCase().startsWith("en")?si:ii}import{jsx as ci}from"react/jsx-runtime";var li=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,di=e=>[...e.matchAll(li)].map(n=>({url:n[0],startIndex:n.index,endIndex:n.index+n[0].length-1})),ui=(e,t)=>{let n="",a=0;t.sort((r,o)=>r.startIndex-o.startIndex);for(let{startIndex:r,endIndex:o,replacementText:i}of t)n+=e.slice(a,r),n+=i,a=o+1;return n+=e.slice(a),n},oo=e=>{let t=di(e);return ci("p",{dangerouslySetInnerHTML:{__html:ui(e,t.map(n=>(n.replacementText=`<a key=${n.url} href=${n.url} style="text-decoration: underline;" target="_blank">
2
+ ${n.url}
3
+ </a>`,n)))}})};import{fromJsonString as es}from"@bufbuild/protobuf";import{useAutoAnimate as zi}from"@formkit/auto-animate/react";import{ChevronLeft as ji,Download as Fi}from"lucide-react";import{useEffect as Po,useRef as vo,useState as Be}from"react";import Ni from"hls.js";import{Pause as Si,Play as Ii,SkipBack as Ti,SkipForward as Ei}from"lucide-react";import{forwardRef as Li,useEffect as $e,useImperativeHandle as Ri,useRef as G,useState as Ce}from"react";import{jsx as Nr,jsxs as mi}from"react/jsx-runtime";function pi(){return mi("div",{className:"flex items-center gap-2",children:[Nr("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),Nr("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),Nr("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var we=pi;import fi from"hls.js";var gi=[401,403],ao="networkError",io="mediaError";function yi(e,t){if(e==null||e.fatal!==!0)return{action:"ignore"};let n=e.response?.code,a=e.type===ao?"network":e.type===io?"media":"unknown",r=n==null?{kind:a}:{kind:a,status:n};return n!=null&&gi.includes(n)?{action:"expired",error:{kind:"network",status:n}}:e.type===ao&&!t.network?{action:"restart-load"}:e.type===io&&!t.media?{action:"recover-media"}:{action:"fail",error:r}}function so(e){let t=e.HlsCtor??fi,n=new t,a,r=!1,o=!1;return n.attachMedia(e.media),n.on(t.Events.ERROR,(i,d)=>{let u=yi(d,{network:r,media:o});switch(u.action){case"expired":e.handlers?.onExpiredUrl?.(),e.handlers?.onError?.(u.error);break;case"restart-load":r=!0,n.startLoad();break;case"recover-media":o=!0,n.recoverMediaError();break;case"fail":e.handlers?.onError?.(u.error);break;case"ignore":break}}),{load(i){a=i,r=!1,o=!1,n.loadSource(i)},retry(){a!=null&&(r=!1,o=!1,n.loadSource(a))},destroy(){n.destroy()},get src(){return a}}}function lo(e){try{return e.canPlayType("application/vnd.apple.mpegurl")!==""}catch{return!1}}function uo(e){switch(e?.code){case 2:return{kind:"network"};case 3:case 4:return{kind:"media"};default:return{kind:"unknown"}}}var hi={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",avif:"image/avif",svg:"image/svg+xml"},Sr="512x512";function ot(){return typeof navigator<"u"&&typeof navigator.mediaSession<"u"}function bi(e){if(typeof e!="string"||e.length===0)return{src:e,sizes:Sr};let t=e.split(/[?#]/)[0],n=t.includes(".")?t.slice(t.lastIndexOf(".")+1).toLowerCase():"",a=hi[n],r={src:e,sizes:Sr};return a!=null&&(r.type=a),r}function Pi(e){if(e==null)return;let t=Array.isArray(e)?e:[e],n=[];for(let a of t){if(typeof a=="string"){a.length>0&&n.push(bi(a));continue}a!=null&&a.src.length>0&&n.push({src:a.src,sizes:a.sizes??Sr,...a.type!=null?{type:a.type}:{}})}return n.length>0?n:void 0}function Ir(e){!ot()||typeof MediaMetadata>"u"||(navigator.mediaSession.metadata=new MediaMetadata({title:e.title,album:e.album,artist:e.artist,artwork:Pi(e.artwork)}))}function co(){ot()&&(navigator.mediaSession.playbackState="playing")}function po(){ot()&&(navigator.mediaSession.playbackState="paused")}function mo(e,t,n=1){if(!ot()||e==null||!Number.isFinite(e)||e<=0||t!=null&&isNaN(t))return;let a=Math.min(Math.max(t??0,0),e),r=Number.isFinite(n)&&n>0?n:1;try{navigator.mediaSession.setPositionState({playbackRate:r,duration:e,position:a})}catch{}}var fo=["play","pause","stop","seekbackward","seekforward","seekto","previoustrack","nexttrack"];function go(e){if(ot()){Ir({title:e.title,album:e.album,artist:e.artist,artwork:e.artwork});for(let t of fo)try{navigator.mediaSession.setActionHandler(t,n=>{e.action(n)})}catch{}}}function yo(){if(ot()){navigator.mediaSession.metadata=null;for(let e of fo)try{navigator.mediaSession.setActionHandler(e,null)}catch{}}}import{useEffect as vi,useState as ki}from"react";var wi={play:"Odtw\xF3rz",pause:"Wstrzymaj",previous:"Poprzedni rozdzia\u0142",next:"Nast\u0119pny rozdzia\u0142",rewind:"Cofnij o 10 sekund",forward:"Przewi\u0144 o 10 sekund",progress:"Post\u0119p odtwarzania",of:"z",speed:"Pr\u0119dko\u015B\u0107",sleep:"Wy\u0142\u0105cznik czasowy",off:"Wy\u0142\u0105czony",end:"Koniec rozdzia\u0142u",cancel:"Anuluj wy\u0142\u0105cznik",error:"Nie uda\u0142o si\u0119 odtworzy\u0107 nagrania.",retry:"Spr\xF3buj ponownie",left:"zosta\u0142o",book:"ca\u0142a ksi\u0105\u017Cka",chapter:"rozdzia\u0142",chapters:"Rozdzia\u0142y",loading:"\u0141adowanie rozdzia\u0142\xF3w\u2026",empty:"Brak rozdzia\u0142\xF3w do wy\u015Bwietlenia.",resume:"Kontynuuj",chapterName:"Rozdzia\u0142",download:"Pobierz rozdzia\u0142",playing:"Teraz odtwarzane",played:"Ods\u0142uchane"},xi={play:"Play",pause:"Pause",previous:"Previous chapter",next:"Next chapter",rewind:"Rewind 10 seconds",forward:"Forward 10 seconds",progress:"Playback progress",of:"of",speed:"Speed",sleep:"Sleep timer",off:"Off",end:"End of chapter",cancel:"Cancel timer",error:"The recording could not be played.",retry:"Try again",left:"left",book:"whole book",chapter:"chapter",chapters:"Chapters",loading:"Loading chapters\u2026",empty:"No chapters to display.",resume:"Continue",chapterName:"Chapter",download:"Download chapter",playing:"Now playing",played:"Played"};function Ut(e){let[t,n]=ki("pl");return vi(()=>{try{n(E())}catch{}},[]),(e??t).toLowerCase().startsWith("en")?xi:wi}function xe(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;return`${t>=3600?`${Math.floor(t/3600)}:`:""}${String(Math.floor(t/60)%60).padStart(2,"0")}:${String(t%60).padStart(2,"0")}`}var Z={get(e){try{return localStorage.getItem(e)}catch{return null}},set(e,t){try{localStorage.setItem(e,t)}catch{}},remove(e){try{localStorage.removeItem(e)}catch{}}},Tr="__player__speed",_t=[.75,1,1.25,1.5,1.75,2];import{jsx as M,jsxs as $}from"react/jsx-runtime";var Ai=Li(({chapters:e,locale:t,styles:n,updateCurrentTime:a,setCurrentTimeHandler:r,title:o,imageURL:i,coverShownBeside:d,author:u,uniqueProductID:l,onChapterChange:m,onError:P,onExpiredUrl:b,onFinished:k},f)=>{let c=Ut(t),[p,g]=Ce(1),v=G(1),[I,U]=Ce(),[S,pe]=Ce("off"),[Te,ae]=Ce(0),re=G({mode:"off",deadline:0});function ye(){re.current={mode:"off",deadline:0},pe("off"),ae(0)}function T(s){let h=Number(s)*60;re.current={mode:s,deadline:Number.isFinite(h)?Date.now()+h*1e3:0},pe(s),ae(Number.isFinite(h)?h:0)}function he(s){_t.includes(s)&&(g(s),v.current=s,Z.set(Tr,String(s)),j.current&&(j.current.playbackRate=s),K())}$e(()=>{let s=Number(Z.get(Tr));_t.includes(s)&&he(s);let h=setInterval(()=>{let{mode:x,deadline:D}=re.current;if(x==="off"||x==="chapter")return;let ke=Math.max(0,Math.ceil((D-Date.now())/1e3));ae(ke),ke===0&&(je.current=!1,St(),ye())},1e3);return()=>clearInterval(h)},[]);let J;(x=>(x[x.Playing=0]="Playing",x[x.Paused=1]="Paused"))(J||={});let[ze,mt]=Ce(1),[Zt,Ee]=Ce(void 0),[C,be]=Ce(void 0),[We,me]=Ce(!1),[Ct,Xr]=Ce(null),j=G(null),Pe=G(null),Nt=G(void 0),va=G(null),ne=G(null),Yt=G(null),je=G(!1),Ve=G(!1),ft=G(null),Jt=G(null),Qt=G(e),en=G(null),oe=G({onChapterChange:m,onError:P,onExpiredUrl:b,onFinished:k,updateCurrentTime:a,title:o,imageURL:i,author:u});oe.current={onChapterChange:m,onError:P,onExpiredUrl:b,onFinished:k,updateCurrentTime:a,title:o,imageURL:i,author:u};function Xt(s){!Ve.current||!Number.isFinite(s)||s<0||Z.set(`__player__${l}_${ne.current?.id}`,`${Math.floor(s)}`)}function ka(){let s=Z.get(`__player__${l}_${ne.current?.id}`);if(s!=null)try{let h=parseInt(s);return isNaN(h)||h<0?void 0:h}catch{return}}function wa(){let s=Z.get(`__player__${l}_last_chapter`);if(s!=null)return s}function tn(s){Z.set(`__player__${l}_last_chapter`,s)}function rn(s){Z.remove(`__player__${l}_${s}`)}function er(s){Ir({title:s?.name??oe.current.title??"",album:oe.current.title,artist:oe.current.author,artwork:oe.current.imageURL})}function nn(s){Yt.current=s,Xr(s),me(!1),oe.current.onError?.(s)}function on(){Yt.current=null,Xr(null)}function an(){let s=j.current;if(s==null)return;let h=s.play();h!=null&&typeof h.catch=="function"&&h.catch(()=>{}),K()}function sn(){an()}function St(){j.current?.pause(),K()}function xa(){if(ze===0){St();return}sn()}function Le(s){let h=j.current;if(h==null||!Number.isFinite(s))return;let x=Number.isFinite(h.duration)?h.duration:0,D=x>0?Math.min(Math.max(s,0),x):Math.max(s,0);Ee(D),h.currentTime=D,K()}function It(s){let h=j.current;if(h==null)return;let x=Number.isFinite(h.duration)?h.duration:void 0,D=Math.max(h.currentTime+s,0);x!=null&&D>x&&(D=x),Le(D)}function tr(s){let h=j.current;if(h!=null){if(on(),me(!0),lo(h)){rr(),h.src=s,h.load();return}if(Ni.isSupported()){Pe.current==null&&(Pe.current=so({media:h,handlers:{onError:x=>{nn(x)},onExpiredUrl:()=>{oe.current.onExpiredUrl?.()}}})),Pe.current.load(s);return}rr(),h.src=s,h.load()}}function rr(){Pe.current?.destroy(),Pe.current=null}function Tt(s,h){let x=h?.play===!0;ne.current&&j.current&&!j.current.ended&&Xt(j.current.currentTime),Ve.current=!1,ft.current=null,je.current=x,ne.current=s,U(s.id),Ee(0),be(s.duration),tr(s.publicUrl),er(s),oe.current.onChapterChange?.(s),tn(s.id)}function nr(s){if(s.length===0)return;let h=wa(),x=(h!=null?s.find(D=>D.id===h):void 0)??s[0];Tt(x,{play:!1})}function or(){let s=Qt.current,h=ne.current;if(s==null||s.length===0||h==null)return;let x=s.findIndex(ke=>ke.id===h.id);if(x===-1)return;let D=x+1;if(D>=s.length){Ca(h);return}Tt(s[D],{play:!0})}function ln(){let s=Qt.current,h=ne.current;if(h==null)return;let x=j.current;if(x!=null&&x.currentTime>3){Le(0);return}let D=s==null?-1:s.findIndex(ke=>ke.id===h.id);if(D>0){Tt(s[D-1],{play:!0});return}Le(0)}function Ca(s){rn(s.id),je.current=!1,j.current?.pause(),mt(1),oe.current.onFinished?.()}function dn(){let s=ne.current;if(s!=null){if(Z.set(`__player__${l}_${s.id}_completed`,"true"),rn(s.id),re.current.mode==="chapter"){je.current=!1,St(),ye();return}or(),K()}}function un(){let s=j.current;if(s!=null){if(me(!1),s.playbackRate=v.current,Jt.current=null,!Ve.current){Ve.current=!0;let h=ft.current;if(ft.current=null,h!=null)Le(h);else{let x=ka();x!=null&&Le(x)}}je.current&&(je.current=!1,an())}}function cn(){let s=j.current?.error,h=ne.current?.publicUrl;(s?.code===2||s?.code===4)&&Pe.current==null&&h!=null&&Jt.current!==h&&(Jt.current=h,oe.current.onExpiredUrl?.()),nn(uo(s))}function pn(){let h=ne.current?.publicUrl??Pe.current?.src;if(h==null)return;let D=j.current?.currentTime??0;on(),Ve.current=!1,ft.current=D>0?D:null,Ee(D),Pe.current!=null?Pe.current.retry():tr(h)}function Na(s){switch(s.action){case"play":sn();break;case"pause":case"stop":St();break;case"seekbackward":It(-(s.seekOffset??10));break;case"seekforward":It(s.seekOffset??10);break;case"seekto":s.seekTime!=null&&Le(s.seekTime);break;case"previoustrack":ln();break;case"nexttrack":or();break;default:break}}Ri(f,()=>({selectChapter:s=>{Tt(s,{play:!0})},retry:pn,getError:()=>Yt.current}));function K(){let s=j.current;s!=null&&(mt(s.paused?1:0),be(s.duration),Ee(s.currentTime),s.ended||Xt(s.currentTime),mo(s.duration,s.currentTime,s.playbackRate),s.networkState===s.NETWORK_LOADING&&s.readyState<=s.HAVE_FUTURE_DATA?me(!0):me(!1),oe.current.updateCurrentTime?.(s.currentTime))}$e(()=>(go({title:o??"",album:o,artist:u,artwork:i,action:Na}),()=>{yo()}),[]),$e(()=>{er(ne.current)},[o,u,i]),$e(()=>{let s=j.current;if(s!=null)return s.addEventListener("loadeddata",un),s.addEventListener("ended",dn),s.addEventListener("error",cn),s.addEventListener("timeupdate",K),s.addEventListener("play",K),s.addEventListener("pause",K),s.addEventListener("ratechange",K),K(),Nt.current=setInterval(K,500),()=>{s.removeEventListener("loadeddata",un),s.removeEventListener("ended",dn),s.removeEventListener("error",cn),s.removeEventListener("timeupdate",K),s.removeEventListener("play",K),s.removeEventListener("pause",K),s.removeEventListener("ratechange",K),Nt.current!=null&&(clearInterval(Nt.current),Nt.current=void 0),s.ended||Xt(s.currentTime),Ee(void 0),s.pause(),rr(),s.removeAttribute("src"),s.load()}},[]),$e(()=>{r?.(Le)},[]);let ar=e.map(s=>`${s.id}|${s.publicUrl??""}`).join(`
4
+ `);$e(()=>{Qt.current=e;let s=en.current;if(s===ar)return;if(en.current=ar,s==null){nr(e);return}let h=ne.current;if(h==null){nr(e);return}let x=e.find(D=>D.id===h.id);if(!(x!=null&&x.publicUrl===h.publicUrl)){if(x!=null){let D=j.current,ke=D?.currentTime??0,Ia=D!=null&&!D.paused;ne.current=x,Ve.current=!1,ft.current=ke>0?ke:null,je.current=Ia,tr(x.publicUrl),er(x),oe.current.onChapterChange?.(x),tn(x.id);return}nr(e)}},[ar]),$e(()=>{switch(ze){case 0:co();break;case 1:po();break}},[ze]);let Ze=e.findIndex(s=>s.id===I),ve=Number.isFinite(C)&&C>0?C:e[Ze]?.duration??0,gt=Math.min(Math.max(Zt??0,0),ve||1/0),mn=e.length>0&&e.every(s=>Number.isFinite(s.duration)&&s.duration>0),Sa=Math.max(0,ve-gt+(mn?e.slice(Ze+1).reduce((s,h)=>s+h.duration,0):0))/p,ir=Math.ceil(Sa/60),fn=`${Math.floor(ir/60)>0?`${Math.floor(ir/60)} h `:""}${ir%60} min`;return $("div",{id:"audio-player-container",className:"bitsnap-audio-player flex min-w-0 flex-col gap-3 text-neutral-900 dark:text-neutral-100",style:{...n,"--seek-before-width":`${ve>0?gt/ve*100:0}%`},ref:va,"data-player-error":Ct?.kind,children:[M("video",{ref:j,className:"hidden",poster:i,title:o}),$("div",{className:H("flex min-w-0 items-center gap-3",d&&"lg:hidden"),children:[i&&M("img",{src:i,alt:"",className:"h-16 w-16 shrink-0 rounded object-contain"}),$("div",{className:"min-w-0 break-words",children:[M("p",{className:"font-semibold",children:e[Ze]?.name??o}),u&&M("p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:u})]})]}),Ct&&$("div",{role:"alert",className:"rounded-lg bg-red-50 p-3 text-red-800 dark:bg-red-950 dark:text-red-200",children:[M("p",{children:c.error}),M(L,{variant:"outline",onClick:pn,children:c.retry})]}),M("input",{type:"range",min:"0",max:ve||100,value:gt,disabled:!ve,"aria-label":c.progress,"aria-valuetext":`${xe(gt)} ${c.of} ${xe(ve)}`,onChange:s=>Le(Number(s.target.value))}),$("section",{className:"flex w-full justify-between text-sm tabular-nums",children:[M("span",{id:"current-time",children:xe(gt)}),M("span",{id:"duration",children:xe(ve)})]}),ve>0&&$("p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:[c.left==="left"?`${fn} ${c.left}`:`${c.left} ${fn}`," ","\xB7 ",mn?c.book:c.chapter," (",p,"\xD7)"]}),$("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[M(L,{variant:"outline",onClick:ln,disabled:Ze<0,"aria-label":c.previous,children:M(Ti,{className:"h-5 w-5"})}),$(L,{variant:"outline",onClick:()=>It(-10),"aria-label":c.rewind,children:["\u2212",10]}),M(L,{variant:"outline",onClick:xa,"aria-label":ze===1?c.play:c.pause,children:ze===1?M(Ii,{className:"h-5 w-5"}):M(Si,{className:"h-5 w-5"})}),$(L,{variant:"outline",onClick:()=>It(10),"aria-label":c.forward,children:["+",10]}),M(L,{variant:"outline",onClick:or,disabled:Ze<0||Ze>=e.length-1,"aria-label":c.next,children:M(Ei,{className:"h-5 w-5"})})]}),$("div",{className:"flex flex-wrap gap-3 md:grid md:grid-cols-2",children:[$("label",{className:"flex flex-1 items-center gap-2 text-sm md:flex-col md:items-start md:whitespace-nowrap",children:[c.speed,M("select",{"aria-label":c.speed,value:p,onChange:s=>he(Number(s.target.value)),children:_t.map(s=>$("option",{value:s,children:[s,"\xD7"]},s))})]}),$("label",{className:"flex flex-1 items-center gap-2 text-sm md:flex-col md:items-start md:whitespace-nowrap",children:[c.sleep,$("select",{"aria-label":c.sleep,value:S,onChange:s=>T(s.target.value),children:[M("option",{value:"off",children:c.off}),[15,30,45,60].map(s=>$("option",{value:s,children:[s," min"]},s)),M("option",{value:"chapter",children:c.end})]})]})]}),S!=="off"&&$("div",{className:"flex items-center justify-between gap-2 text-sm",children:[M("span",{role:"timer",children:S==="chapter"?c.end:xe(Te)}),M(L,{variant:"outline",onClick:ye,children:c.cancel})]}),We&&M("div",{role:"status",className:"flex justify-center",children:M(we,{})})]})}),ho=Ai;import{Check as Di,Download as Mi,Play as Oi}from"lucide-react";import{useEffect as Ui,useState as bo}from"react";import{Fragment as _i,jsx as ue,jsxs as it}from"react/jsx-runtime";function Er({chapters:e,currentID:t,productID:n,onSelect:a,downloadable:r,onDownload:o,loading:i,locale:d}){let u=Ut(d),[l,m]=bo(null),[P,b]=bo([]);Ui(()=>{let c=`__player__${n}_`,p=Z.get(`${c}last_chapter`),g=Number(p&&Z.get(`${c}${p}`));m(p&&g>0&&Number.isFinite(g)?{id:p,time:g}:null),b((e??[]).filter(v=>Z.get(`${c}${v.id}_completed`)==="true"||Number(Z.get(`${c}${v.id}`))>0).map(v=>v.id))},[e,n,t]);let k=e?.findIndex(c=>c.id===l?.id)??-1,f=e?.findIndex(c=>c.id===t)??-1;return it("div",{className:"max-h-96 w-full overflow-y-auto",children:[ue("h2",{className:"mb-3 text-xl font-semibold",children:u.chapters}),i?ue("p",{role:"status",children:u.loading}):e?.length?it(_i,{children:[l&&k>=0&&it("button",{type:"button",className:"mb-3 min-h-11 rounded-lg border border-neutral-300 px-3 py-2 text-left dark:border-neutral-600",onClick:()=>a(e[k]),children:[u.resume,": ",u.chapterName," ",k+1,","," ",xe(l.time)]}),ue("ul",{className:"flex w-full flex-col gap-2",children:e.map((c,p)=>{let g=c.id===t,v=p<f||P.includes(c.id);return it("li",{className:"flex min-w-0 items-center gap-2",children:[it("button",{type:"button","aria-current":g?"true":void 0,className:`min-h-11 min-w-0 flex-1 rounded-lg p-3 text-left hover:bg-neutral-200 dark:hover:bg-neutral-700 ${g?"bg-neutral-200 dark:bg-neutral-700":"bg-neutral-100 dark:bg-neutral-800"}`,onClick:()=>a(c),children:[it("span",{className:"flex items-center gap-2",children:[g?ue(Oi,{className:"size-4 shrink-0","aria-label":u.playing}):v?ue(Di,{className:"size-4 shrink-0","aria-label":u.played}):null,ue("span",{className:"min-w-0 flex-1 break-words text-sm font-medium",children:c.name}),!!c.duration&&ue("span",{className:"shrink-0 text-xs tabular-nums text-neutral-600 dark:text-neutral-300",children:xe(c.duration)})]}),c.description&&ue("span",{className:"mt-2 block text-xs",children:c.description})]}),r&&c.downloadableUrl&&ue("a",{href:c.downloadableUrl,onClick:o,"aria-label":`${u.download} ${p+1}`,className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",children:ue(Mi,{className:"size-4","aria-hidden":"true"})})]},c.id)})})]}):ue("p",{children:u.empty})]})}import{Fragment as zt,jsx as N,jsxs as Y}from"react/jsx-runtime";function Ne(e,...t){console.warn(e,...t)}function Lr(e){console.error(e)}var Hi=({accessToken:e,product:t,styles:n,reveal:a})=>{let r=nt(),o=t.productType,i=Rt(),d=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),u=vo(null),[l]=zi(),[m,P]=Be(!1),[b,k]=Be(null),{mutateAsync:f,isPending:c}=ie(_.publicApi.userPanelGetFileDetails),p=vo(void 0),[g,v]=Be(null),[I,U]=Be(null),[S,pe]=Be(!1),{mutateAsync:Te,isPending:ae}=ie(_.publicApi.userPanelGetAudiobookDetails),{mutateAsync:re,isPending:ye}=ie(_.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[T,he]=Be(null),[J,ze]=Be(null);async function mt(){P(!1);try{let C=await f({accessId:t.accessId,accessToken:e});if(C.result.case==="success"){k(C.result.value.files);return}else P(!0),Ne("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),Ne("Kod b\u0142\u0119du: ",C.result.value)}catch(C){P(!0),Ne("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Lr("B\u0142\u0105d podczas pobierania danych:"+C)}}async function Zt(){try{let C=await Te({accessId:t.accessId,accessToken:e});if(C.result.case==="audiobook"){v(C.result.value);return}else Ne("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),Ne("Kod b\u0142\u0119du: ",C.result.value)}catch(C){Ne("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Lr("B\u0142\u0105d podczas pobierania danych:"+C)}}async function Ee(){try{let C=await re({accessId:t.accessId,accessToken:e,isBrowser:!0});if(C.result.case==="success"){U(C.result.value.audiobookDownloadDetails),pe(C.result.value.isAvailableToDownloadInMobileApp===!0);return}else Ne("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),Ne("Kod b\u0142\u0119du: ",C.result.value)}catch(C){Ne("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Lr("B\u0142\u0105d podczas pobierania danych:"+C)}}return Po(()=>{o===2&&mt(),o===1&&(Zt().then().catch(),Ee().then().catch())},[]),Po(()=>{if(g!=null&&I!=null){let C=g.chapters;if(!C)return;let be=C.map(We=>{let me=I?.find(Ct=>Ct.chapterId===We.id);if(me!=null)return{...We,publicUrl:me.publicUrl,downloadableUrl:me.downloadableUrl,duration:me.duration}}).filter(We=>We!=null);be!=null&&be.length>0&&ze(be)}},[g,I]),Y("div",{children:[N("div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:Y(L,{onClick:()=>a(),variant:"ghost",className:"min-h-11 w-fit",children:[N(ji,{className:"h-6 w-6"}),N("span",{className:"font-inter text-sm font-medium",children:r.back})]})}),Y("main",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[Y("header",{className:"flex min-w-0 flex-col gap-4 rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900 lg:row-span-2 lg:self-start",children:[N("img",{src:t.productImageUrl,alt:t.productName,width:384,height:384,draggable:!1,className:"aspect-square max-h-72 w-full object-contain"}),N("h2",{className:"text-2xl font-semibold",children:t.productName})]}),Y("div",{className:"flex min-w-0 flex-col gap-6",children:[o===2&&Y("section",{ref:l,className:"flex flex-col gap-4 rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900",children:[N("h3",{className:"text-xl font-semibold",children:r.yourFiles}),c&&N("div",{role:"status","aria-label":r.loading,children:N(we,{})}),m&&Y("div",{role:"alert",children:[N("p",{children:r.fileError}),N(L,{className:"min-h-11",onClick:mt,children:r.retry})]}),b?.length===0&&N("p",{children:r.noFiles}),b&&N("ul",{className:"flex flex-col gap-3",children:b.map((C,be)=>Y("li",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[N("span",{className:"min-w-0 break-all text-sm",children:ko(C)||`${r.file} ${be+1}`}),Y("a",{target:"_blank",rel:"noopener noreferrer",href:C,download:!0,onClick:d,className:"inline-flex min-h-11 items-center gap-2 rounded-md bg-neutral-900 px-3 py-2 text-sm text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 dark:bg-neutral-100 dark:text-neutral-900","aria-label":`${r.download}: ${ko(C)||`${r.file} ${be+1}`}`,children:[r.download,N(Fi,{className:"size-4","aria-hidden":"true"})]})]},C))})]}),o===3&&Y("section",{className:"rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900",children:[N("h3",{className:"text-lg font-semibold",children:r.ticket}),N("p",{className:"mt-2 font-medium",children:t.productName}),N("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-300",children:r.ticketInfo})]}),o===1&&N(zt,{children:Y("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:[N("h4",{className:"text-xl font-semibold",children:T?.name??"Odtwarzacz"}),T?.description&&N("p",{className:"text-sm",children:T?.description}),N(zt,{children:ae?Y("div",{className:"flex gap-2",children:[N(we,{}),N("p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):N(zt,{children:J!=null?N(zt,{children:N(ho,{ref:u,coverShownBeside:!0,chapters:J,author:typeof g?.author=="string"?g.author:void 0,onExpiredUrl:()=>{Ee()},title:g?.name??t.productName??void 0,imageURL:g?.coverImage??t.productImageUrl??void 0,styles:n,setCurrentTimeHandler:C=>{p.current=C},uniqueProductID:t.productId,onChapterChange:C=>{he(C)}})}):N("p",{className:"mt-2",children:"Wybierz rozdzia\u0142, kt\xF3ry ci\u0119 interesuje."})})}),Y("div",{className:"rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",children:[N("p",{className:"mt-3 mb-3 text-xs",children:S?"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."}),Y("div",{className:"flex gap-3",children:[N("a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:N("img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),N("a",{href:"https://play.google.com/store/apps/details?id=com.bitsnap.Bitsnap",children:N("img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),N("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&&N(Er,{chapters:J,currentID:T?.id,productID:t.productId,loading:ae,downloadable:g?.isDownloadable===!0,onDownload:d,onSelect:C=>u.current?.selectChapter(C)})})]}),N("section",{className:"rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900",children:N("p",{className:"whitespace-pre-wrap text-sm text-neutral-600 dark:text-neutral-300",children:t.productDescription})})]})]})},wo=Hi;function ko(e){try{return decodeURIComponent(new URL(e,"https://bitsnap.pl").pathname.split("/").pop()||"")}catch{return""}}import{useTransport as qi}from"@connectrpc/connect-query";import{useEffect as $i,useState as Bi}from"react";function xo(e,t){let n=qi(),[a,r]=Bi({status:"loading"});return $i(()=>{if(!e){r({status:"hidden"});return}let o=!1;return r({status:"loading"}),import("./model-files-client-HHDXJDTS.mjs").then(({listModelFiles:i})=>i(n,e,t)).catch(()=>({status:"hidden"})).then(i=>{o||r(i)}),()=>{o=!0}},[n,e,t]),a}import{Fragment as Io,jsx as z,jsxs as Oe}from"react/jsx-runtime";var ts=Ki(()=>import("./PanelModelFiles-4B2HYGIE.mjs")),rs=({accessToken:e,projectID:t,loginURL:n,styles:a,activeScreen:r,params:o,setParams:i,openCourse:d,openMessages:u})=>{let{host:l}=se(),{data:m,isLoading:P,error:b,refetch:k}=Ae(_.publicApi.userPanelGetProducts,{accessToken:e}),f=xo(e,t),c=ns({products:P?{status:"loading"}:b!=null?{status:"error"}:m?.result.case==="success"?{status:"ok",count:m.result.value.products.length}:m?.result.case==="failure"?{status:"failure",unauthorized:m.result.value===9}:{status:"error"},modelFiles:f});if(Rr(()=>{c.kind==="signed-out"&&(Xe(t,l),window.location.href=n)},[c.kind,t,l,n]),c.kind==="loading"||c.kind==="signed-out")return z("div",{role:"status","aria-label":nt().loading,"aria-busy":"true",className:"grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5",children:Array.from({length:6},(I,U)=>z("div",{"aria-hidden":"true",className:"h-72 rounded-xl bg-neutral-100 motion-safe:animate-pulse dark:bg-neutral-800"},U))});let p=m&&m.result.case==="success"?m.result.value.products:[],g=f.status==="ready"?f.models:[],v=g.length>0?z(Gi,{fallback:null,children:z(ts,{accessToken:e,models:g,buttonStyle:a})}):null;return c.kind==="error"?Oe(Io,{children:[z(as,{onRetry:()=>void k()}),v]}):c.kind==="empty"?z(os,{}):z(is,{accessToken:e,products:p,styles:a,activeScreen:r,params:o,setParams:i,openCourse:d,openMessages:u,filesSection:v})};function ns({products:e,modelFiles:t}){if(e.status==="failure"&&e.unauthorized)return{kind:"signed-out"};if(e.status==="loading")return{kind:"loading"};if(e.status==="ok"&&e.count>0)return{kind:"list"};if(t.status==="loading")return{kind:"loading"};if(e.status==="failure"||e.status==="error")return t.status==="unauthorized"?{kind:"signed-out"}:{kind:"error"};let n=t.status==="ready"?t.models.length:0;return e.count===0&&n===0?{kind:"empty"}:{kind:"list"}}function os(){let e=nt();return Oe("div",{className:"flex flex-col items-start gap-1","data-testid":"panel-empty",children:[z("h3",{className:"text-2xl",children:e.hello}),z("p",{className:"text-sm text-neutral-500",children:e.empty})]})}function as({onRetry:e}){let t=E().toLowerCase().startsWith("en");return Oe("div",{className:"flex flex-col items-start gap-3",role:"alert","data-testid":"panel-error",children:[z("p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:t?"Your products could not be loaded.":"Nie uda\u0142o si\u0119 wczyta\u0107 Twoich produkt\xF3w."}),z(L,{type:"button",onClick:e,className:"text-sm",children:t?"Try again":"Spr\xF3buj ponownie"})]})}var So=rs;function Co(e){return e.productType===5||e.productType===6}var is=({accessToken:e,products:t,styles:n,filesSection:a,activeScreen:r,params:o,setParams:i,openCourse:d,openMessages:u})=>{let l=nt(),[m,P]=Wi(()=>No(o.product,t));Rr(()=>{P(No(o.product,t))},[o.product,t]);let b=f=>{P(f),i({product:f?Ar(f):void 0,state:"products"})};Rr(()=>{r==="products"&&m?.productType===4?d(m.accessId):r==="products"&&m&&Co(m)&&u&&u()},[r,m,d,u]);function k(f){if(Co(f)&&u){u();return}if(f.productType===4){d(f.accessId);return}b(f)}return r==="products"&&m?.productType===4?null:r==="products"&&m!=null?z(wo,{accessToken:e,product:m,styles:n,reveal:b,onOpenCourse:d}):Oe(Io,{children:[z("h3",{className:"text-2xl",children:l.hello}),t.length>0&&z("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:l.intro}),z("div",{className:"mt-6 grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5",children:t.map(f=>{let[c,p,g]=f.productType===1?[l.audio,l.listen,Yi]:f.productType===4?[l.course,l.openCourse,Vi]:f.productType===5?[l.chat,l.openMessages,Ji]:f.productType===6?[l.community,l.openMessages,Xi]:f.productType===3?[l.ticket,l.showTicket,Qi]:[l.files,l.downloadFiles,Zi];return Oe("button",{type:"button",onClick:()=>k(f),className:"flex min-h-11 min-w-0 flex-col overflow-hidden rounded-xl border border-neutral-200 bg-white text-left text-neutral-900 transition-colors hover:border-neutral-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-50 dark:hover:border-neutral-500",children:[Oe("span",{className:"flex w-full flex-col gap-3 bg-neutral-100 p-3 dark:bg-neutral-800",children:[Oe("span",{className:"flex w-fit items-center gap-1.5 rounded-md bg-white px-2 py-1 text-xs font-medium dark:bg-neutral-900",children:[z(g,{className:"size-4","aria-hidden":"true"}),c]}),z("img",{src:f.productImageUrl,alt:f.productName,draggable:!1,className:"aspect-square w-full object-contain"})]}),Oe("span",{className:"flex flex-1 flex-col gap-3 p-3",children:[z("span",{className:"line-clamp-2 font-semibold",children:f.productName}),z("span",{className:"line-clamp-2 text-sm text-neutral-600 dark:text-neutral-300",children:oo(f.productDescription)}),z("span",{className:"mt-auto pt-2 text-sm font-medium underline underline-offset-4",children:p})]})]},Ar(f))})}),a]})};function Ar(e){return`${hn[e.productType]?.toLowerCase()??"product"}-${e.accessId||e.productId}`}function No(e,t){if(!e)return;let n=t.find(r=>Ar(r)===e);if(n)return n;let a=t.find(r=>(r.accessId||r.productId)===e||r.productId===e);if(a)return a;try{let r=es(yn,e);return t.find(o=>(r.accessId?o.accessId===r.accessId:o.productId===r.productId)&&(r.productType===0||o.productType===r.productType))}catch{return}}import{LogOut as ps}from"lucide-react";import{Library as ss,MessageCircle as ls,Receipt as ds,Undo2 as us,User as cs}from"lucide-react";var To=[{screen:"products",label:"libraryNavLabel",icon:ss},{screen:"messages",label:"messagesNavLabel",icon:ls},{screen:"orders",label:"ordersNavLabel",icon:ds},{screen:"returns",label:"returnsNavLabel",icon:us},{screen:"profile",label:"accountNavLabel",icon:cs}];function Eo(e){return e==="course"?"products":e==="order-details"?"orders":e==="return-details"?"returns":e}import{jsx as Ke,jsxs as kt}from"react/jsx-runtime";function Dr({activeScreen:e,setActiveScreen:t,setParams:n,theme:a,logout:r,email:o,projectID:i,showMessages:d=!1}){let u=ee(),{data:l}=xn(i??"",!!i);return kt("header",{className:"flex h-14 shrink-0 items-center border-b border-neutral-200 bg-white px-4 md:h-dvh md:w-56 md:flex-col md:items-stretch md:border-r md:border-b-0 md:py-5 dark:border-neutral-800 dark:bg-neutral-900",children:[kt("div",{className:"flex min-w-0 items-center gap-3 md:mb-6 md:flex-col md:items-start",children:[Ke(At,{projectId:i,logoUrl:a?.logoURL,logoDarkUrl:a?.logoDarkURL,name:l?.name,className:"shrink-0"}),l?.name&&Ke("span",{title:l.name,className:"truncate text-sm font-medium md:line-clamp-2 md:whitespace-normal",children:l.name})]}),Ke("nav",{"aria-label":u.navigationLabel,className:"fixed inset-x-0 bottom-0 z-10 flex h-[calc(56px+env(safe-area-inset-bottom))] items-start justify-around border-t border-neutral-200 bg-white pb-[env(safe-area-inset-bottom)] md:static md:h-auto md:flex-1 md:flex-col md:justify-start md:gap-2 md:border-0 md:bg-transparent md:pb-0 dark:border-neutral-800 dark:bg-neutral-900",children:To.filter(({screen:m})=>m!=="messages"||d).map(({screen:m,label:P,icon:b})=>{let k=Eo(e)===m;return kt("button",{type:"button","aria-current":k?"page":void 0,onClick:()=>{t(m),n({product:void 0,state:m})},className:H("flex h-14 min-h-11 min-w-0 flex-1 flex-col items-center justify-center gap-1 px-1 text-[11px] focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-current md:h-11 md:w-full md:flex-none md:flex-row md:justify-start md:gap-3 md:rounded-md md:px-3 md:text-sm",k?"bg-neutral-100 font-semibold text-black dark:bg-neutral-800 dark:text-white":"text-neutral-600 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:bg-neutral-800"),children:[Ke(b,{className:"h-5 w-5 shrink-0","aria-hidden":"true"}),Ke("span",{children:u[P]})]},m)})}),kt("div",{className:"hidden border-t border-neutral-200 pt-4 md:block dark:border-neutral-800",children:[o&&Ke("p",{title:o,className:"mb-3 truncate text-sm text-neutral-600 dark:text-neutral-400",children:o}),kt("button",{type:"button",onClick:r,className:"flex min-h-11 w-full items-center gap-3 rounded-md px-3 text-sm text-red-700 hover:bg-red-50 focus-visible:outline-2 focus-visible:outline-current dark:text-red-400 dark:hover:bg-neutral-800",children:[Ke(ps,{className:"h-4 w-4","aria-hidden":"true"}),u.logout]})]})]})}import{useState as ms}from"react";import{LogOut as fs}from"lucide-react";import{jsx as Ue,jsxs as st}from"react/jsx-runtime";function Mr({email:e,logout:t,onLocaleChange:n}){let[a,r]=ms(E),o=ee(a);return st("section",{className:"w-full max-w-xl",children:[Ue("h3",{className:"text-2xl",children:o.accountNavLabel}),Ue("h4",{className:"mt-6 mb-2 text-sm font-medium text-neutral-600 dark:text-neutral-400",children:o.profileHeading}),st("div",{className:"divide-y divide-neutral-200 rounded-lg border border-neutral-200 bg-white dark:divide-neutral-800 dark:border-neutral-800 dark:bg-neutral-900",children:[st("div",{className:"p-4",children:[Ue("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:o.emailLabel}),Ue("p",{className:"mt-1 break-words",children:e||o.noData})]}),st("label",{className:"flex min-h-11 flex-wrap items-center justify-between gap-3 p-4",children:[Ue("span",{children:o.languageLabel}),st("select",{value:a.toLowerCase().startsWith("en")?"en-US":"pl-PL",onChange:i=>{fr(i.target.value),r(i.target.value),n?.()},className:"min-h-11 rounded-md border border-neutral-300 bg-white px-3 focus-visible:outline-2 focus-visible:outline-current dark:border-neutral-700 dark:bg-neutral-900",children:[Ue("option",{value:"pl-PL",children:o.polishLanguage}),Ue("option",{value:"en-US",children:o.englishLanguage})]})]})]}),st("button",{type:"button",onClick:t,className:"mt-6 flex min-h-11 w-full items-center gap-3 rounded-lg border border-neutral-200 bg-white px-4 py-3 text-red-700 hover:bg-red-50 focus-visible:outline-2 focus-visible:outline-current dark:border-neutral-800 dark:bg-neutral-900 dark:text-red-400 dark:hover:bg-neutral-800",children:[Ue(fs,{className:"h-5 w-5","aria-hidden":"true"}),o.logout]})]})}import{lazy as gs,Suspense as ys}from"react";import{jsx as wt}from"react/jsx-runtime";var hs=gs(()=>import("./course.mjs").then(e=>({default:e.PanelCourse})));function Or(e){return wt(ys,{fallback:wt("div",{className:"flex items-center gap-2 p-2",role:"status",children:wt(we,{})}),children:wt("div",{className:"[--course-mobile-bottom:calc(56px+env(safe-area-inset-bottom))] md:[--course-mobile-bottom:0px]",children:wt(hs,{...e})})})}import{lazy as bs,Suspense as Ps}from"react";import{jsx as jt}from"react/jsx-runtime";var vs=bs(()=>import("./chat.mjs").then(e=>({default:e.PanelMessages})));function Ur(e){return jt(Ps,{fallback:jt("div",{className:"flex items-center gap-2 p-2",role:"status",children:jt(we,{})}),children:jt(vs,{...e})})}function ks(e,t){return!!t||e.some(n=>n.productType===5||n.productType===6)}function Lo(e){let{data:t}=Ae(_.publicApi.userPanelGetProducts,{accessToken:e??""},{enabled:!!e}),n=t?.result.case==="success"?t.result.value:void 0,a=n?.products??[],r=n?.chatApiUrl||void 0;return{visible:ks(a,r),products:a,chatApiUrl:r}}import{AlertCircle as qo,CheckCircle2 as zo,ChevronLeft as js,Loader2 as zr,Lock as jo,Package as Fs,Truck as $o}from"lucide-react";import{useEffect as Hs,useState as _r}from"react";import{timestampDate as Ss}from"@bufbuild/protobuf/wkt";import{CheckCircle2 as Is,FileText as Ts,KeyRound as Es,Loader2 as Ls,Mail as Rs,RefreshCw as As,RotateCcw as Ds,Truck as Uo,Undo2 as Ms}from"lucide-react";import{useMemo as Os}from"react";var ws={pl:{heading:"Historia zam\xF3wienia",showMore:"Poka\u017C wi\u0119cej",loadingMore:"\u0141adowanie\u2026",paid:"Zam\xF3wienie op\u0142acone",paidWith:"Zam\xF3wienie op\u0142acone przez {provider}",shipped:"Zam\xF3wienie wys\u0142ane",statusChangedTo:"Status zam\xF3wienia: {status}",statusChanged:"Zmieniono status zam\xF3wienia",trackingNumber:"Numer przesy\u0142ki: {number}",trackingNumberCarrier:"Numer przesy\u0142ki: {number} ({carrier})",accessEmailSentTo:"Wys\u0142ano e-mail z dost\u0119pem na {email}",accessEmailSent:"Wys\u0142ano e-mail z dost\u0119pem",emailSentTo:"Wys\u0142ano e-mail na {email}",emailSent:"Wys\u0142ano e-mail",accessGrantedProduct:"Przyznano dost\u0119p: {product}",accessGranted:"Przyznano dost\u0119p",invoiceIssuedNumber:"Wystawiono faktur\u0119 {number}",invoiceIssued:"Wystawiono faktur\u0119",invoiceLink:"Pobierz faktur\u0119",refundedAmount:"Zwr\xF3cono {amount}",refunded:"Zwr\xF3cono pieni\u0105dze",returnRequested:"Zg\u0142oszono zwrot",returnStatusChangedTo:"Status zwrotu: {status}",returnStatusChanged:"Zmieniono status zwrotu"},en:{heading:"Order history",showMore:"Show more",loadingMore:"Loading\u2026",paid:"Order paid",paidWith:"Order paid with {provider}",shipped:"Order shipped",statusChangedTo:"Order status: {status}",statusChanged:"Order status changed",trackingNumber:"Tracking number: {number}",trackingNumberCarrier:"Tracking number: {number} ({carrier})",accessEmailSentTo:"Access e-mail sent to {email}",accessEmailSent:"Access e-mail sent",emailSentTo:"E-mail sent to {email}",emailSent:"E-mail sent",accessGrantedProduct:"Access granted: {product}",accessGranted:"Access granted",invoiceIssuedNumber:"Invoice {number} issued",invoiceIssued:"Invoice issued",invoiceLink:"Download the invoice",refundedAmount:"Refunded {amount}",refunded:"Money refunded",returnRequested:"Return requested",returnStatusChangedTo:"Return status: {status}",returnStatusChanged:"Return status changed"}};function Ft(e){return Je(ws,e)}var xs={stripe:"Stripe",payu:"PayU",przelewy24:"Przelewy24",p24:"Przelewy24",tpay:"Tpay",paynow:"Paynow",paypal:"PayPal",revolut:"Revolut",revolutpay:"Revolut Pay",inpost:"InPost Pay",inpostpay:"InPost Pay",applepay:"Apple Pay",googlepay:"Google Pay",imoje:"imoje",autopay:"Autopay",blik:"BLIK"},Ro=(e,t)=>e.replace(/\{(\w+)\}/g,(n,a)=>t[a]??n),fe=(e,t)=>(e.params[t]??"").trim();function Cs(e,t){let n=/^(-?\d+(?:[.,]\d+)?)\s*([A-Za-z]{3})$/.exec(e.trim());if(n==null)return e.trim();try{return new Intl.NumberFormat(t,{style:"currency",currency:n[2].toUpperCase()}).format(Number(n[1].replace(",",".")))}catch{return e.trim()}}function Ns(e){if(!(e==null||e.trim()===""))try{let t=new URL(e.trim());return t.protocol==="https:"?t.toString():void 0}catch{return}}function Do(e,t,n=Ft(t)){let a=(r,o,i,d,u)=>({icon:r,text:o===""?d:Ro(i,{[u]:o})});switch(e.kind){case"order.paid":{let r=xs[fe(e,"provider").toLowerCase().replace(/[^a-z0-9]/g,"")]??"";return a("paid",r,n.paidWith,n.paid,"provider")}case"order.status_changed":{let r=fe(e,"to").toLowerCase();if(r==="sent")return{icon:"shipped",text:n.shipped};let o=Ot(r,ee(t))??"";return a("status",o,n.statusChangedTo,n.statusChanged,"status")}case"order.tracking_set":{let r=fe(e,"number");if(r==="")return null;let o=fe(e,"carrier");return{icon:"tracking",text:Ro(o===""?n.trackingNumber:n.trackingNumberCarrier,{number:r,carrier:o})}}case"email.sent":{let r=fe(e,"template")==="access";return a("email",fe(e,"email"),r?n.accessEmailSentTo:n.emailSentTo,r?n.accessEmailSent:n.emailSent,"email")}case"access.granted":return a("access",fe(e,"product"),n.accessGrantedProduct,n.accessGranted,"product");case"invoice.issued":{let r=a("invoice",fe(e,"number"),n.invoiceIssuedNumber,n.invoiceIssued,"number"),o=Ns(e.linkUrl);return o==null?r:{...r,link:{url:o,label:n.invoiceLink}}}case"refund.succeeded":{let r=fe(e,"amount");return a("refund",r===""?"":Cs(r,t),n.refundedAmount,n.refunded,"amount")}case"return.requested":return{icon:"return",text:n.returnRequested};case"return.status_changed":{let r=fe(e,"to").toLowerCase(),o=Un(r),i=o==="statusFallback"?"":On(t)[o];return a("return",i,n.returnStatusChangedTo,n.returnStatusChanged,"status")}default:return null}}var Ao=[{unit:"second",seconds:1,below:45},{unit:"minute",seconds:60,below:45*60},{unit:"hour",seconds:3600,below:22*3600},{unit:"day",seconds:86400,below:26*86400},{unit:"month",seconds:30*86400,below:320*86400},{unit:"year",seconds:365*86400,below:Number.POSITIVE_INFINITY}];function Mo(e,t,n=new Date){let a=(e.getTime()-n.getTime())/1e3,r=new Intl.RelativeTimeFormat(t,{numeric:"auto"}),o=Math.abs(a);if(o<45)return r.format(0,"second");let i=Ao.find(d=>o<d.below)??Ao[5];return r.format(Math.round(a/i.seconds),i.unit)}function Oo(e,t){return e.toLocaleString(t,{dateStyle:"long",timeStyle:"short"})}import{Fragment as zs,jsx as Ge,jsxs as lt}from"react/jsx-runtime";var Us=10,_s={paid:Is,shipped:Uo,status:As,tracking:Uo,email:Rs,access:Es,invoice:Ts,refund:Ms,return:Ds};function _o({orderId:e}){let{projectID:t,host:n}=se(),a=Fe(t,n),r=E(),o=Ft(r),i=!!t&&!!a&&!!e,d=wn(_.publicApi.getOrderHistory,{projectId:t??"",accessToken:a??"",orderId:e,pageToken:"",pageSize:Us},{pageParamKey:"pageToken",getNextPageParam:b=>b.result.case==="success"&&b.result.value.nextPageToken!==""?b.result.value.nextPageToken:void 0,enabled:i,retry:!1,refetchOnWindowFocus:!1}),u=Os(()=>{let b=[],k=new Set;for(let f of d.data?.pages??[])if(f.result.case==="success")for(let c of f.result.value.entries){if(k.has(c.id))continue;k.add(c.id);let p=Do(c,r,o);p!=null&&b.push({...p,id:c.id,date:c.occurredAt?Ss(c.occurredAt):void 0})}return b},[d.data,r,o]),l=d.data?.pages[0]?.result.case==="success";if(!i||!l||u.length===0)return null;let m=d.hasNextPage&&!d.isFetchNextPageError,P=new Date;return lt("section",{"aria-labelledby":`bitsnap-order-history-${e}`,className:"border-t pt-4","data-bitsnap-order-history":"",children:[Ge("h3",{id:`bitsnap-order-history-${e}`,className:"mb-3 font-semibold",children:o.heading}),Ge("ol",{className:"space-y-3",children:u.map(b=>{let k=_s[b.icon];return lt("li",{className:"flex items-start gap-3",children:[Ge("span",{"aria-hidden":"true",className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground",children:Ge(k,{className:"h-4 w-4"})}),lt("div",{className:"min-w-0 flex-1",children:[lt("p",{className:"break-words text-sm leading-snug",children:[b.text,b.link&&lt(zs,{children:[" \xB7 ",Ge("a",{href:b.link.url,target:"_blank",rel:"noopener noreferrer",className:"font-medium underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-current",children:b.link.label})]})]}),b.date&&Ge("time",{dateTime:b.date.toISOString(),title:Oo(b.date,r),className:"text-xs text-muted-foreground",children:Mo(b.date,r,P)})]})]},b.id)})}),m&&lt("button",{type:"button",onClick:()=>void d.fetchNextPage(),disabled:d.isFetchingNextPage,className:"mt-3 inline-flex min-h-11 items-center gap-2 rounded-md px-1 text-sm font-medium underline underline-offset-2 disabled:opacity-60 focus-visible:outline-2 focus-visible:outline-current",children:[d.isFetchingNextPage&&Ge(Ls,{"aria-hidden":"true",className:"h-4 w-4 animate-spin"}),d.isFetchingNextPage?o.loadingMore:o.showMore]})]})}import{Fragment as Bo,jsx as y,jsxs as w}from"react/jsx-runtime";function qs({status:e}){let t={created:{color:"bg-neutral-100 text-neutral-700",icon:null},paid:{color:"bg-green-100 text-green-700",icon:zo},completed:{color:"bg-blue-100 text-blue-700",icon:zo},canceled:{color:"bg-red-100 text-red-700",icon:qo},sent:{color:"bg-purple-100 text-purple-700",icon:$o},processing:{color:"bg-yellow-100 text-yellow-700",icon:zr}},n=t[e]||t.created,a=n.icon,r={created:"Utworzone",paid:"Op\u0142acone",completed:"Zako\u0144czone",canceled:"Anulowane",sent:"Wys\u0142ane",processing:"Przetwarzane"};return w("span",{className:`inline-flex items-center gap-1 rounded-full px-3 py-1 text-sm font-medium ${n.color}`,children:[a&&y(a,{className:"h-4 w-4"}),r[e]||e]})}function $s({orderID:e,email:t}){let[n,a]=_r(""),r=ie(_.publicApi.addPublicOrderComment);return w("form",{onSubmit:async i=>{if(i.preventDefault(),!!n.trim())try{await r.mutateAsync({projectId:"",orderId:e,message:n.trim(),accessToken:t}),a("")}catch(d){console.error("Failed to add comment:",d)}},className:"mt-4 space-y-2",children:[y(Qe,{htmlFor:"comment",children:"Dodaj komentarz"}),y(An,{id:"comment",value:n,onChange:i=>a(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:r.isPending}),y(L,{type:"submit",disabled:!n.trim()||r.isPending,children:r.isPending?w(Bo,{children:[y(zr,{className:"mr-2 h-4 w-4 animate-spin"}),"Wysy\u0142anie..."]}):"Dodaj komentarz"})]})}function Fo(e){return e?new Date(Number(e.seconds)*1e3).toLocaleDateString("pl-PL",{year:"numeric",month:"long",day:"numeric"}):"N/A"}function Ho(e,t){return new Intl.NumberFormat("pl-PL",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function Bs({orderID:e,initialEmail:t,onBack:n,accessToken:a,analytics:r}){let{theme:o,projectID:i}=se(),d=Ye(i,r,"order"),[u,l]=_r(t||""),[m,P]=_r(!1),{data:b,isLoading:k,error:f,refetch:c}=Ae(_.publicApi.getPublicOrderDetails,{projectId:i??"",orderId:e,email:u||void 0,accessToken:a},{enabled:!!e}),p=b?.result.case==="order"?b.result.value:null,g=p?.isVerified??!1,v=p!=null;Hs(()=>{v&&d.track("panel_order_viewed",{},{order_ref:null})},[d,v]);let I=()=>{c(),P(!1)},U={"--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 k?y("div",{className:"flex min-h-screen items-center justify-center",children:w("div",{className:"text-center",children:[y(zr,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),y("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):f||!p?y("div",{className:"flex min-h-screen items-center justify-center",children:y(De,{className:"w-full max-w-md",children:y(Me,{className:"pt-6",children:w("div",{className:"text-center",children:[y(qo,{className:"mx-auto h-12 w-12 text-red-500"}),y("h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),y("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):y("div",{className:"w-full bg-white py-8 dark:bg-black",style:U,children:w("div",{className:"w-full px-4",children:[n&&w(L,{onClick:n,variant:"ghost",className:"mb-4 w-fit",children:[y(js,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),w("div",{className:"mb-6 flex items-center gap-4",children:[o?.logoURL&&w(Bo,{children:[y("img",{src:o.logoURL,alt:"Project logo",className:`h-12 w-auto ${o.logoDarkURL?"dark:hidden":""}`}),o.logoDarkURL&&y("img",{src:o.logoDarkURL,alt:"Project logo",className:"hidden h-12 w-auto dark:block"})]}),w("div",{children:[y("h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),w("p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",p.orderId]})]})]}),w(De,{className:"mb-6",children:[y(He,{children:w(qe,{className:"flex items-center",children:[y(Fs,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),w(Me,{className:"space-y-6",children:[w("div",{children:[w("div",{className:"flex items-center gap-2",children:[y(qs,{status:p.status}),p.processingStatus&&w("span",{className:"text-sm text-neutral-600",children:["\xB7 ",p.processingStatus]})]}),w("p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",Fo(p.createdAt)]})]}),y(_o,{orderId:e}),w("div",{className:"border-t pt-4",children:[y("h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),w("div",{className:"space-y-2",children:[w("div",{children:[y("span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",y("span",{className:g?"":"text-neutral-500",children:p.customerName})]}),w("div",{children:[y("span",{className:"font-medium",children:"Email:"})," ",y("span",{className:g?"":"text-neutral-500",children:p.customerEmail})]}),p.customerPhone&&w("div",{children:[y("span",{className:"font-medium",children:"Telefon:"})," ",y("span",{className:g?"":"text-neutral-500",children:p.customerPhone})]})]})]}),!g&&y("div",{className:"border-t pt-4",children:w(L,{onClick:()=>P(!0),variant:"outline",className:"w-full",children:[y(jo,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),w(De,{className:"mb-6",children:[y(He,{children:y(qe,{children:"Produkty"})}),w(Me,{className:"space-y-6",children:[y("div",{className:"space-y-4",children:p.items.map((S,pe)=>w("div",{className:"flex items-center gap-4",children:[S.imageUrl&&y("img",{src:S.imageUrl,alt:S.name,className:"h-16 w-16 rounded object-cover"}),w("div",{className:"flex-1",children:[y("p",{className:"font-medium",children:S.name}),w("p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",S.quantity]})]}),y("div",{className:"text-right",children:y("p",{className:"font-medium",children:Ho(Number(S.price),S.currency)})})]},pe))}),(p.deliveryAddress||p.deliveryMethod)&&w("div",{className:"border-t pt-4",children:[w("h3",{className:"mb-3 flex items-center font-semibold",children:[y($o,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),w("div",{className:"space-y-2",children:[p.deliveryAddress&&w("div",{children:[y("span",{className:"font-medium",children:"Adres:"})," ",y("span",{className:g?"":"text-neutral-500",children:p.deliveryAddress})]}),p.deliveryMethod&&w("div",{children:[y("span",{className:"font-medium",children:"Metoda:"})," ",p.deliveryMethod]}),p.trackingNumber&&g&&w("div",{children:[y("span",{className:"font-medium",children:"Tracking:"})," ",p.trackingNumber]})]})]}),y("div",{className:"border-t pt-4",children:w("div",{className:"flex justify-between text-lg font-bold",children:[y("span",{children:"Suma:"}),y("span",{children:Ho(Number(p.totalAmount),p.currency)})]})})]})]}),w(De,{children:[y(He,{children:w(qe,{children:["Komentarze ",p.commentCount>0&&`(${p.commentCount})`]})}),w(Me,{children:[p.comments.length>0?y("div",{className:"space-y-4",children:p.comments.map(S=>w("div",{className:"border-b pb-4 last:border-b-0",children:[w("div",{className:"mb-1 flex items-center gap-2",children:[y("span",{className:"font-medium",children:S.authorName||"System"}),y("span",{className:"text-xs text-neutral-500",children:Fo(S.createdAt)}),S.authorType==="admin"&&y("span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),y("p",{className:g?"":"text-neutral-500",children:S.message})]},S.id))}):y("p",{className:"text-neutral-600",children:"Brak komentarzy."}),g?y($s,{orderID:p.orderId,email:u}):y("div",{className:"mt-4",children:w(L,{onClick:()=>P(!0),variant:"outline",className:"w-full",children:[y(jo,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),m&&y("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:w(De,{className:"w-full max-w-md",children:[y(He,{children:y(qe,{children:"Zweryfikuj sw\xF3j email"})}),w(Me,{className:"space-y-4",children:[y("p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),w("div",{className:"space-y-2",children:[y(Qe,{htmlFor:"verify-email",children:"Adres email"}),y(Dt,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:u,onChange:S=>l(S.target.value)})]}),w("div",{className:"flex gap-2",children:[y(L,{variant:"outline",onClick:()=>P(!1),className:"flex-1",children:"Anuluj"}),y(L,{onClick:I,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function Ks(e){return y(Bs,{...e})}var jr=Ks;import{jsx as ce,jsxs as Go}from"react/jsx-runtime";var Ws=({returnsAppearance:e,returnsTexts:t,analytics:n}={})=>{let{projectID:a,theme:r,loginURL:o,host:i}=se(),[,d]=Ko(0),u=Ye(a,n,"panel"),l=Fe(a,i),m=Ln(a,i),{mutateAsync:P}=ie(_.publicApi.userPanelLogout);async function b(){l&&await P({accessToken:l}),typeof window<"u"&&(Xe(a,i),window.location.reload())}let[k]=Gs(),f=T=>["products","notifications","profile","plans","orders","order-details","returns","return-details","course","messages"].includes(T),[c,p]=Xn({product:void 0,state:"products",orderId:void 0,returnId:void 0,course:void 0,item:void 0,chatProject:void 0,thread:void 0,channel:void 0}),[g,v]=Ko(f(c.state)?c.state:"products"),I=T=>{p({state:"order-details",orderId:T}),v("order-details")},U=()=>{p({state:"orders",orderId:void 0}),v("orders")},S=T=>p({orderId:void 0,returnId:void 0,course:void 0,item:void 0,chatProject:void 0,thread:void 0,channel:void 0,...T}),pe=T=>{p({state:"course",course:T,item:void 0,product:void 0}),v("course")},Te=()=>{p({state:"products",course:void 0,item:void 0,product:void 0}),v("products")},ae=()=>{p({state:"messages",product:void 0,chatProject:void 0,thread:void 0,channel:void 0}),v("messages")},re=Lo(l);Ht(()=>{f(c.state)&&(c.state==="course"||g==="course"||c.state==="messages"||g==="messages")&&v(c.state)},[c.state]);let ye={"--button-background-color":r?.colors?.brand??"#000000","--button-background-color-dark":r?.colors?.brandDark??"#ffffff","--button-text-color":r?.colors?.brandDark??"#000000","--button-text-color-dark":r?.colors?.brand??"#000000"};return Ht(()=>{if(l==null||l.length===0){window.location.href=o??"/panel/login";return}},[]),Ht(()=>{if(l==null||l.length===0){window.location.href=o??"/panel/login";return}},[g]),Ht(()=>{if(typeof window>"u"||window.parent!==window||!l)return;let T=Pt(window.location.search);T&&vt(T);let he=T??tt();he&&(window.location.href=rt(he,l))},[l]),ce(Lt,{value:u,children:Go("div",{ref:k,className:"font-inter relative flex h-dvh w-full flex-col bg-beige-100 text-black dark:bg-black dark:text-white md:flex-row",children:[ce(Dr,{activeScreen:g,setActiveScreen:v,setParams:S,styles:ye,theme:r,logout:b,email:m,projectID:a,showMessages:re.visible||g==="messages"}),Go("main",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto w-full p-5 pb-[calc(76px+env(safe-area-inset-bottom))] md:pb-5",children:[g==="products"&&ce(So,{projectID:a??"",accessToken:l,loginURL:o??"/panel/login",styles:ye,activeScreen:g,params:c,setParams:p,openCourse:pe,openMessages:ae}),g==="messages"&&l&&ce(Ur,{accessToken:l,products:re.products,chatApiUrl:re.chatApiUrl,projectID:a,host:i,selection:{chatProject:c.chatProject,thread:c.thread,channel:c.channel},onSelect:T=>p({chatProject:T.chatProject,thread:T.thread,channel:T.channel})}),g==="course"&&c.course&&l&&ce(Or,{accessId:c.course,accessToken:l,theme:r,itemId:c.item,onItemChange:T=>p({item:T}),onBack:Te}),g==="notifications"&&ce(kr,{}),g==="plans"&&ce(wr,{projectID:a??""}),g==="orders"&&ce(ro,{projectID:a??"",accessToken:l??"",openOrderDetails:I}),g==="order-details"&&c.orderId&&ce(jr,{orderID:c.orderId,onBack:U}),(g==="returns"||g==="return-details")&&l&&ce(Cr,{projectID:a??"",host:i,accessToken:l,loginURL:o??"/panel/login",appearance:eo(e,r?.colors?.brand),texts:t,screen:g,params:c,setParams:p,setActiveScreen:v}),g==="profile"&&ce(Mr,{email:m,logout:b,onLocaleChange:()=>d(T=>T+1)})]})]})})},Vs=Ws;import{create as Se}from"@bufbuild/protobuf";import{QueryClient as pl,QueryClientProvider as ml}from"@tanstack/react-query";import{createContext as fl,useContext as gl,useEffect as ia,useState as yl}from"react";import{createClient as Zs}from"@connectrpc/connect";import{createConnectTransport as Ys}from"@connectrpc/connect-web";var ge;(a=>{function e(r){return Zs(bn,n(r))}a.get=e;let t=new Map;function n(r){let o=t.get(r);return o==null&&(o=Ys({useBinaryFormat:!0,baseUrl:r+"/api/rpc",interceptors:[gn]}),t.set(r,o)),o}})(ge||={});import A from"zod";import te from"zod";function F(e,t=2){return+(Math.round(+(e+"e+"+t))+"e-"+t)}function Wo(e,t){let n=typeof navigator>"u"?"pl-PL":navigator.language;return Intl.NumberFormat(n,{style:"currency",currency:t,currencyDisplay:"symbol"}).format(e/100)}var pm=te.object({event:te.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:te.string().optional(),value:te.number().optional(),currency:te.string().optional(),content_name:te.string().optional(),items:te.array(te.object({id:te.string(),name:te.string(),price:te.number().default(0),currency:te.string().default("PLN"),quantity:te.number().default(1)})).optional()});function Fr(e){typeof window>"u"||(Js(e),Xs(e),el(e))}function Js(e){try{typeof window.dataLayer>"u"&&(window.dataLayer=[]);let t=Qs(e);window.dataLayer.push(t)}catch(t){console.warn("cannot send google analytics event",t)}}function Qs(e){let t=e.value??e.items?.reduce((o,i)=>o+(i.price||0)*(i.quantity||1),0)??0,n=e.items?.map(o=>({item_id:o.id,item_name:o.name||o.id,price:F((o.price||0)/100,2),quantity:o.quantity||1})),a={currency:e.currency||"PLN",value:F(t/100,2)};n&&n.length>0&&(a.items=n);let r;switch(e.event){case"purchase":r="purchase",a.transaction_id=e.step||`txn_${Date.now()}`;break;case"addToCart":r="add_to_cart";break;case"viewCart":r="view_cart";break;case"removeFromCart":r="remove_from_cart";break;case"initiateCheckout":r="begin_checkout";break;case"customizeProduct":r="customize_product";break;default:r=e.event}return{event:r,ecommerce:a,...e.step&&{step:e.step},...e.content_name&&{content_name:e.content_name}}}function Xs(e){if(typeof window.fbq>"u")return;let t="",n="",a={};switch(e.event){case"purchase":t="track",n="Purchase",a={category_name:e.step,...e};break;case"lead":t="track",n="Lead",a={category_name:e.step,...e};break;case"addToCart":t="track",n="Add to Cart",a={category_name:e.step,...e};break;case"customizeProduct":t="track",n="Customize Product",a={category_name:e.step,...e};break;case"viewCart":t="track",n="View Cart",a={category_name:e.step,...e};break;case"removeFromCart":t="track",n="Remove from Cart",a={category_name:e.step,...e};break;case"initiateCheckout":t="track",n="Initiate Checkout",a={category_name:e.step,...e};break;default:break}window.location.search.includes("analytics")&&console.log("Pushing FB event",t,n,a),window.fbq(t,n,a)}function el(e){try{if(typeof window.ttq>"u")return;let t=tl(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 tl(e){let t=e.value??e.items?.reduce((o,i)=>o+(i.price||0)*(i.quantity||1),0)??0,n=e.items?.map(o=>({content_id:o.id,content_type:"product",content_name:o.name||o.id,quantity:o.quantity||1,price:F((o.price||0)/100,2)}))||[];n.length===0&&e.content_name&&n.push({content_id:e.step||"unknown",content_type:"product",content_name:e.content_name,quantity:1,price:F(t/100,2)});let a={currency:e.currency||"PLN",value:F(t/100,2)};n.length>0&&(a.contents=n);let r=null;switch(e.event){case"purchase":r="Purchase";break;case"addToCart":r="AddToCart";break;case"initiateCheckout":r="InitiateCheckout";break;case"customizeProduct":r="CustomizeProduct";break;case"viewCart":return;case"removeFromCart":return;case"lead":return;default:return null}return{eventName:r,eventPayload:a}}function Vo(e){let{items:t,googlePayConfig:n,checkout:a,result:r,cartRequiresShipping:o}=e,i=e.locale??E();if(r.totalAmount==null)return;let d=[];return o&&(d.push("SHIPPING_ADDRESS"),d.push("SHIPPING_OPTION")),{apiVersion:2,apiVersionMinor:0,callbackIntents:d,allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["MASTERCARD","VISA"]},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:n.gateway,gatewayMerchantId:n.gatewayId}}}],emailRequired:!0,shippingAddressParameters:{phoneNumberRequired:o},shippingAddressRequired:o,shippingOptionRequired:o,shippingOptionParameters:o?{shippingOptions:r.methods.slice(0,5).map(l=>({id:l.id,label:l.name+` - ${Wo(l.amount,r.currency)}`,description:l.description??""})),defaultSelectedOptionId:r.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:n.merchantId+"",merchantName:n.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:Re("paymentForCart",i,e.texts),totalPrice:`${F(r.totalAmount/100,2)}`,currencyCode:r.currency,countryCode:r.country,checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",displayItems:rl(t,r.methods,r.selectedDeliveryMethod??(r.methods.length>0?r.methods[0].id:void 0),a.couponCode,r.couponValue,Re("coupon",i,e.texts))}}}function rl(e,t,n,a,r,o="Coupon"){let i=[],d=0;for(let l of e){if(l.details==null)continue;let m=l.details.pricing?.effectivePrice??l.details.price;d+=m*l.quantity,i.push({label:l.details.name+" x "+l.quantity,price:`${F(m/100,2)}`,type:"LINE_ITEM",status:"FINAL"})}let u=t.find(l=>l.id===n);return u!=null&&i.push({label:u.name,price:`${F(u.amount/100,2)}`,type:"SHIPPING_OPTION",status:"FINAL"}),a!=null&&r!=null&&i.push({label:`${o} ${a}`,price:`${F(r/100,2)}`,type:"DISCOUNT",status:"FINAL"}),d>0&&i.push({label:"Subtotal",price:`${F(d/100,2)}`,type:"SUBTOTAL",status:"FINAL"}),i}function dt(e,t){return`${Q}/api/integrations/${e}/public-commerce${t}`}function _e(e){return typeof e=="object"&&e!=null&&"ERR"in e}function B(e,t,n){return{ERR:!0,error:e,type:t,data:n}}function Zo(e,t){return t?.find(n=>n.id===e||(n.variants?.some(a=>a.id===e)??!1))}function Yo(e,t){let n=new Set(t.map(a=>a.productID));return Array.from(new Set(e.filter(a=>!n.has(a))))}function Jo(e,t){let n=e?.trim();if(!(n==null||n.length===0))try{let a=new URL(n,t);return a.protocol!=="http:"&&a.protocol!=="https:"?void 0:a.href}catch{return}}import{create as nl}from"zustand";var ut=nl(e=>({isCartVisible:!1,notice:void 0,setNotice:t=>e(n=>({...n,notice:t})),numberOfProductsInCart:0,showCart:()=>e(t=>({...t,isCartVisible:!0})),hideCart:()=>e(t=>({...t,isCartVisible:!1})),setNumberOfProductsInCart:t=>e(n=>({...n,numberOfProductsInCart:t}))}));import{createContext as ol,useContext as Hr,useMemo as Qo}from"react";import{jsx as al}from"react/jsx-runtime";var qt=ol({});function Im({texts:e,locale:t,children:n}){let a=Qo(()=>({texts:e,locale:t}),[e,t]);return al(qt.Provider,{value:a,children:n})}function Xo(){return Hr(qt)}function Tm(e){let{texts:t,locale:n}=Hr(qt);return Re(e,n??E(),t)}function Em(){let{texts:e,locale:t}=Hr(qt),n=t??E();return Qo(()=>a=>Re(a,n,e),[n,e])}var $r="bitsnap-pending-order";function ra(e,t){let n=new Map;for(let r of t)n.set(r.id,(n.get(r.id)??0)+r.quantity);let a=[];for(let r of e){let o=n.get(r.id);o==null?a.push(r):r.quantity>o&&a.push({...r,quantity:r.quantity-o})}return a}var il=60*1e3;function na(e,t=Date.now,n=il){let a;return r=>{let o=`${r.orderId}:${r.ts}`,i=t();return a?.key===o&&i-a.at<n?Promise.reject(new Error("pending order was asked about recently")):(a={key:o,at:i},e(r))}}function sl(e){if(!(e==null||e.length===0))try{let t=new URL(e,"https://bitsnap.invalid").pathname,n=/\/payment\/common\/([^/]+)\/([^/]+)\/?$/.exec(t);return n==null?void 0:{projectId:decodeURIComponent(n[1]),orderId:decodeURIComponent(n[2])}}catch{return}}function ll(e){if(e==null||e.length===0)return!1;try{let t=new URL(e,"https://bitsnap.invalid").pathname;return/\/payment\/manualPayment\/[^/]+\/[^/]+\/?$/.test(t)}catch{return!1}}function dl(e,t=Date.now(),n={}){if(ll(e.url))return;let a=sl(e.url),r=ea(e.orderId)??a?.orderId,o=ea(e.projectId)??a?.projectId;if(!(r==null||o==null))return{orderId:r,projectId:o,...n.cartProjectId!=null?{cartProjectId:n.cartProjectId}:{},lines:n.lines??[],ts:t}}function Am(e,t={}){let n=dl(e,t.now,t);return n!=null&&ul(n,t.storage)}function ea(e){return e!=null&&e.length>0?e:void 0}function $t(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function ul(e,t=$t()){try{return t?.setItem($r,JSON.stringify(e)),t!=null}catch{return!1}}function ta(e=$t()){try{let t=e?.getItem($r);if(t==null)return;let n=JSON.parse(t);if(typeof n=="object"&&n!=null&&typeof n.orderId=="string"&&typeof n.projectId=="string"&&typeof n.ts=="number"&&n.orderId.length>0){let{orderId:a,projectId:r,cartProjectId:o,ts:i,lines:d}=n;return{orderId:a,projectId:r,...typeof o=="string"?{cartProjectId:o}:{},lines:Array.isArray(d)?d.filter(u=>typeof u?.id=="string"&&typeof u.quantity=="number"):[],ts:i}}}catch{}qr(e)}function qr(e=$t()){try{e?.removeItem($r)}catch{}}function oa(e){let t=e.details?.status??cl(e.details?.$unknown);return t==="created"||t==="placed"||t==="paid"||t==="canceled"?t:"unknown"}function cl(e){if(Array.isArray(e)){for(let t of e)if(t?.no===3&&t.wireType===2&&t.data instanceof Uint8Array){let n=0,a=0;for(let r=0;a<t.data.length&&r<35;r+=7){let o=t.data[a++];if(n|=(o&127)<<r,!(o&128))break}if(a+n!==t.data.length)return;try{return new TextDecoder().decode(t.data.subarray(a))}catch{return}}}}async function aa(e){let t=e.storage??$t(),n=ta(t);if(n==null)return"none";if((e.now??Date.now)()-n.ts>864e5)return qr(t),"expired";if(e.projectId!=null&&n.cartProjectId!=null&&n.cartProjectId!==e.projectId)return"pending";let r;try{r=await e.fetchStatus(n)}catch{return"pending"}let o=ta(t);if(o?.orderId!==n.orderId||o.ts!==n.ts)return"pending";if(r==="paid"||r==="placed"){try{await e.removeLines(n.lines)}catch{return"pending"}return qr(t),"paid"}return"pending"}import{Fragment as Ll,jsx as Kr}from"react/jsx-runtime";var hl="__m_a",pa=fl(void 0),Wr=void 0;function of(e){pr({projectID:e}),Wr=e,typeof window<"u"&&yt([window.location.origin])}function pt(){return Wr??document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-id")??void 0}function bl(){return document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-custom-host")??void 0}var Pl=({children:e,locale:t})=>{let[n]=yl(()=>new pl),a=Xo();ia(()=>{Ie()},[]);let r=pt();if(ia(()=>{if(r==null)return;let i=()=>{wl(r).then(u=>{u==="paid"&&n.invalidateQueries({queryKey:["cart"]})})},d=()=>{document.visibilityState==="visible"&&i()};return i(),window.addEventListener("pageshow",i),document.addEventListener("visibilitychange",d),()=>{window.removeEventListener("pageshow",i),document.removeEventListener("visibilitychange",d)}},[r,n]),r==null)return Kr(Ll,{});let o=Yr(r,t??a.locale,a.texts);return Kr(ml,{client:n,children:Kr(pa.Provider,{value:o,children:e})})},Br,vl=na(async e=>oa(await ge.get(Q).getOrder({id:e.orderId,projectId:e.projectId})));function af(){let{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:a}=R()??Wt;return{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:a}}function sf(){return(R()?.products??[]).map(e=>({id:e.id,quantity:e.quantity}))}function kl(e){let t=R();W({...t,products:ra(t?.products??[],e)}),Ie()}function wl(e){return Br??=aa({projectId:e,fetchStatus:vl,removeLines:kl}).catch(t=>{console.warn("cannot check the pending order",t)}).finally(()=>{Br=void 0}),Br}var ct=async(e,t)=>{let n=[];t?.items!=null&&t.items.length>0?n=t.items:n=R()?.products??[];let a=Array.from(new Set(n.map(i=>i.productID)));if(a.length===0)return[];let r=new URLSearchParams;r.set("ids",a.join(",")),r.set("locale",t?.locale??E());let o;try{let i=await fetch(lr(dt(e,`/products?${r.toString()}`)),{method:"GET"});if(i.status!=200)return B("products-load-failed","internal");o=await i.json()}catch(i){return console.warn("cannot load the products of the cart",i),B("products-load-failed","internal")}return n.flatMap(i=>{let d=Zo(i.productID,o.result);return d==null?[]:[{...i,details:El(i.productID,d),catalogProductID:d.id}]})},lf=()=>{let e=gl(pa);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},df=Pl,xl=A.object({isAvailable:A.boolean(),merchantId:A.string(),merchantName:A.string(),gateway:A.string(),gatewayId:A.string()}),Cl=A.object({id:A.string(),productID:A.string(),quantity:A.number(),priceVersion:A.string().optional(),amount:A.number().int().nonnegative().optional(),metadata:A.record(A.string(),A.string().optional()).optional(),url:A.string().optional()}),Nl=A.object({country:A.string().optional(),couponCode:A.string().optional(),selectedDeliveryMethod:A.string().optional(),postalCode:A.string().optional(),email:A.string().optional(),products:A.array(Cl).optional(),googlePayConfig:xl.optional()}),Wt={country:void 0,couponCode:void 0,email:void 0,selectedDeliveryMethod:void 0,postalCode:void 0,products:[],googlePayConfig:void 0},Zr="checkout";function Sl(){return typeof localStorage>"u"?[]:(R().products??[]).map(e=>({...e}))}function uf(){return Sl().map(e=>`${e.productID}:${e.quantity}`).sort().join(",")}function cf(e){let t=R();if(!(t.products==null||t.products.length===0))return{items:t.products.map(n=>({id:n.productID,quantity:n.quantity,...n.priceVersion!=null?{priceVersion:n.priceVersion}:{},...n.amount!=null?{amount:n.amount}:{}})),...t.country!=null?{countries:[t.country]}:{},...t.couponCode!=null?{couponCode:t.couponCode}:{},...t.selectedDeliveryMethod!=null?{deliveryMethod:t.selectedDeliveryMethod}:{},locale:e}}function pf(e){let t=R(),n=new Map;for(let a of t.products??[]){let r=n.get(a.productID)??[];r.push(a),n.set(a.productID,r)}t.products=e.map(a=>{let r=n.get(a.productId)?.shift();return{id:Math.random().toString(36).substring(7),productID:a.productId,quantity:a.quantity,...r?.priceVersion!=null?{priceVersion:r.priceVersion}:{},...r?.metadata!=null?{metadata:r.metadata}:{},...r?.url!=null?{url:r.url}:{}}}),W(t),Ie()}function mf(e){let t=new Map;for(let r of e)t.set(r.id,(t.get(r.id)??0)+r.quantity);let n=R(),a=(n.products??[]).flatMap(r=>{let o=t.get(r.productID);return o==null?[r]:r.quantity<=o?[]:[{...r,quantity:r.quantity-o}]});W({...n,products:a}),Ie()}function ff(e){let t=R();t.products=t.products??[];for(let n of e)t.products.push({id:Math.random().toString(36).substring(7),productID:n.id,quantity:n.quantity});W(t),Ie()}function R(){try{let e=localStorage.getItem(Zr);return e==null?Wt:Nl.parse(JSON.parse(e))}catch{return Wt}}async function sa(e,t){let n=await ct(e,{items:t.map((o,i)=>({...o,id:`price-check-${i}`}))});if(_e(n))return n;let a=Yo(t.map(o=>o.productID),n);if(a.length>0)return B("item-ids-not-found","notFound",a);let r=R();r.products==null&&(r.products=[]),r.products.push(...t.map(o=>({id:Math.random().toString(36).substring(7),productID:o.productID,quantity:o.quantity,priceVersion:n.find(i=>i.productID===o.productID)?.details?.pricing?.priceVersion,amount:o.amount,metadata:o.metadata,url:Jo(o.url,typeof window<"u"?window.location.href:void 0)}))),Il(t,n),Fr({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"}))}),W(r),Ie()}function Il(e,t){for(let n of e)try{let a=t.find(d=>d.productID===n.productID),r=a?.details?.pricing?.effectivePrice??a?.details?.price??n.price,o=a?.details?.currency??n.currency;if(r==null||o==null)continue;let i=a?.catalogProductID??n.productID;(n.analytics??vn()).track("add_to_cart",{qty:n.quantity,value_minor:Math.round(r*n.quantity),currency:o},{product_id:i,variant_id:i!==n.productID?n.productID:null})}catch{}}function la(e){let t=R(),n={...t,products:t?.products?.filter(a=>!e.includes(a.productID)&&!e.includes(a.id))};Fr({event:"removeFromCart",items:e.map(a=>({id:a,name:"",price:0,quantity:1,currency:"PLN"}))}),W(n),Ie()}function W(e){localStorage.setItem(Zr,JSON.stringify(e)),fa()}var Kt=new Set,ma=0,Bt=!1;function da(e){e.key===Zr&&fa()}function gf(e){return Kt.add(e),!Bt&&typeof window<"u"&&(window.addEventListener("storage",da),Bt=!0),()=>{Kt.delete(e),Kt.size===0&&Bt&&(window.removeEventListener("storage",da),Bt=!1)}}function yf(){return ma}function fa(){ma+=1;for(let e of Kt)try{e()}catch{}}function ua(e,t){if(e.products==null||e.products.length==0)return;let n=e.products.reduce((a,r)=>(r.metadata!=null&&Object.keys(r.metadata).forEach(o=>{let i=r.metadata?.[o];i!=null&&(a[o]=i)}),a),{});return{items:e.products.map(a=>({id:a.productID,quantity:a.quantity,priceVersion:a.priceVersion,...a.amount!=null?{amount:a.amount}:{}})),askForNote:!0,countries:e.country?[e.country]:void 0,metadata:n,locale:t}}var Yr=(e,t=E(),n)=>{let a=bl();return a!=null&&kn(a),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await ge.get(Q).isOneClickPaymentAvailable({projectId:e})).applePay}catch(r){return console.error("Error checking if Apple Pay is available",r),!1}},async getGooglePayConfiguration(r){if(typeof window>"u"||typeof document>"u")return{isAvailable:!1};try{let o=await Tl(e);if(o?.isAvailable!=!0)return{isAvailable:!1};let i=R();if(i==null)return console.log("checkout is null"),{isAvailable:!1};let d=await ct(e,{locale:t,items:r.items.map(P=>({id:Math.random().toString(36).substring(7),quantity:P.quantity,metadata:P.metadata,productID:P.productID}))});if(_e(d))return{isAvailable:!1};let u=await ge.get(Q).getPreOrderDetails({items:d.map(P=>Se(Et,{id:P.productID,quantity:P.quantity})),projectId:e,postCode:i.postalCode,couponCode:i.couponCode,countryCode:i.country,selectedDeliveryMethod:i.selectedDeliveryMethod});if(u.totalAmount==null)return{isAvailable:!1};let l=d.find(P=>P.details?.isDeliverable==!0)!=null,m=await Vo({items:d,googlePayConfig:o,checkout:i,cartRequiresShipping:l,result:u,locale:t,texts:n});return m==null?{isAvailable:!1}:{isAvailable:!0,config:m}}catch(o){return console.error("Error resolving Google Pay configuration",o),{isAvailable:!1}}},async clearCart(){let r=structuredClone(Wt);r.country=R()?.country,W(r),Ie()},async getAvailableCountries(){let r=await fetch(lr(dt(e,"/countries")),{method:"GET"});if(r.status!=200)return[];try{return A.array(A.object({name:A.string(),code:A.string()})).parse(await r.json())}catch(o){return B(o.toString(),"internal")}},async getCountry(){let r=R()?.country;if(r==null){r="PL";let o=R();o.country=r,W(o)}return r},async getNumberOfElementsInCart(){return R()?.products?.reduce((r,o)=>r+o.quantity,0)??0},async getProducts(){return await ct(e,{locale:t})},async removeProductFromCart(r){return la([r.id])},async setCountry(r){let o=R();o.country=r,W(o)},async setCouponCodeIfPossible(r){let o=R();o.couponCode=r,W(o)},async setPostalCode(r){let o=R();o.postalCode=r,W(o)},async setDeliveryMethod(r){let o=R();o.selectedDeliveryMethod=r,W(o)},async setEmail(r){let o=R();o.email=r,W(o)},async addProduct(r){return await sa(e,[r])},async updateQuantity(r){let o=R();o.products=o.products?.map(i=>(i.id===r.id&&(i.quantity=r.quantity),i)),W(o),Ie()},async getPaymentMethodChoice(){let r=ua(R(),t);return r==null?null:ca(r)},async redirectToNextStep(r){let o=ua(R(),t);if(o==null)return B("cart-is-empty","badInput");r?.paymentMethod!=null&&(o.paymentMethod=r.paymentMethod);let i=await Gr(o);return _e(i)?(console.warn("cannot create payment URL",i.error),i):{url:i.url,...i.orderId!=null?{orderId:i.orderId}:{},...i.projectId!=null?{projectId:i.projectId}:{}}},async justRedirectToPayment(r){let o={items:[{id:r.productID,quantity:1}],askForNote:!1,details:r.email||r.name?{name:r.name,email:r.email}:void 0,locale:r.locale??t};o=Vr(o),r.country==null&&(r.country="pl"),o.details==null&&(o.details={}),o.details.address==null&&(o.details.address={}),o.details.address.country=r.country,r.marketingAgreement===!0&&(o.additionalAgreements=[{id:hl,name:"",required:!0,answer:!0}]);let i=await Gr(o);return _e(i)?i:{url:i.url}},async getApplePayPreview(r){let o=R();try{let i=await ge.get(Q).getPreOrderDetails({items:r.items.map(d=>Se(Et,{id:d.productID,quantity:d.quantity})),projectId:e,postCode:o.postalCode,couponCode:o.couponCode,countryCode:o.country,selectedDeliveryMethod:o.selectedDeliveryMethod});return i.totalAmount==null||i.currency.length===0?B("pre-order-unavailable","internal"):{countryCode:i.country||o.country||"PL",currencyCode:i.currency,totalAmount:`${F(i.totalAmount/100,2)}`}}catch(i){return console.warn("cannot load the Apple Pay preview",i),B("pre-order-unavailable","internal")}},async completeApplePayPayment(r){let o=R();if(o==null)return B("Checkout not found");let i=await ct(e,{locale:t});if(_e(i))return i;try{let d=r.shippingContact?.givenName;r.shippingContact?.familyName!=null?d+=" "+r.shippingContact?.familyName:r.billingContact?.familyName!=null&&(d+=" "+r.billingContact?.familyName);let u={},l=Gt();l!=null&&(u.ref=l);let m=await ge.get(Q).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(r.token.paymentData),paymentMethod:JSON.stringify(r.token.paymentMethod),transactionIdentifier:r.token.transactionIdentifier,order:Se(cr,{items:i.map(P=>({id:P.productID,quantity:P.quantity})),couponCode:o.couponCode,email:r.shippingContact?.emailAddress??r.billingContact?.emailAddress??o.email??void 0,phone:r.shippingContact?.phoneNumber??r.billingContact?.phoneNumber??void 0,selectedDeliveryMethod:o.selectedDeliveryMethod,postCode:o.postalCode,projectId:e}),shippingAddress:Se(dr,{line1:r.shippingContact?.addressLines?.[0]??"",city:r.shippingContact?.locality??"",country:r.shippingContact?.countryCode??"",zipCode:r.shippingContact?.postalCode??"",name:d}),billingAddress:Se(ur,{name:r.billingContact?.givenName??" "+(r.billingContact?.familyName??""),line1:r.billingContact?.addressLines?.[0]??"",city:r.billingContact?.locality??"",country:r.billingContact?.countryCode??"",zipCode:r.billingContact?.postalCode??""}),metadata:Object.keys(u).length>0?JSON.stringify(u):void 0});return{isSuccess:m.isSuccess,redirectURL:m.redirectUrl}}catch(d){return console.error(d),B("Failed to authorize payment")}},async completeGooglePayPayment(r){let o=R();if(o==null)return B("Checkout not found");let i=await ct(e,{locale:t});if(_e(i))return i;try{let d=r.paymentData.shippingAddress?.name,u={},l=Gt();l!=null&&(u.ref=l);let m=await ge.get(Q).authorizeOneClickPayment({gateway:1,paymentData:r.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:r.paymentData.paymentMethodData.type,transactionIdentifier:"",order:Se(cr,{items:i.map(P=>({id:P.productID,quantity:P.quantity})),couponCode:o.couponCode,email:r.paymentData.email??void 0,phone:r.paymentData.shippingAddress?.phoneNumber??void 0,selectedDeliveryMethod:r.paymentData.shippingOptionData?.id??o.selectedDeliveryMethod,postCode:r.paymentData.shippingAddress?.postalCode,projectId:e}),shippingAddress:Se(dr,{line1:r.paymentData.shippingAddress?.address1??"",city:r.paymentData.shippingAddress?.locality??"",country:r.paymentData.shippingAddress?.countryCode??"",zipCode:r.paymentData.shippingAddress?.postalCode??"",name:d}),billingAddress:Se(ur,{name:r.paymentData.paymentMethodData.info?.billingAddress?.name,line1:r.paymentData.paymentMethodData.info?.billingAddress?.address1??"",city:r.paymentData.paymentMethodData.info?.billingAddress?.locality??"",country:r.paymentData.paymentMethodData.info?.billingAddress?.countryCode??"",zipCode:r.paymentData.paymentMethodData.info?.billingAddress?.postalCode??""}),metadata:Object.keys(u).length>0?JSON.stringify(u):void 0});return{isSuccess:m.isSuccess,redirectURL:m.redirectUrl}}catch(d){return console.error(d),B("Failed to authorize payment")}return{isSuccess:!0}},async getApplePayPaymentRequest(r){let o=R();if(o==null)return B("Checkout not found");r&&r.expectedItems!=null&&r.expectedItems.length>0&&(o.products&&la(o.products.map(l=>l.productID)),await sa(e,r.expectedItems));let i=await ct(e,{locale:t});if(_e(i))return i;let d=await ge.get(Q).getPreOrderDetails({items:i.map(l=>Se(Et,{id:l.productID,quantity:l.quantity})),projectId:e,postCode:o.postalCode,couponCode:o.couponCode,countryCode:o.country,selectedDeliveryMethod:o.selectedDeliveryMethod}),u=i.map(l=>({amount:`${F(l.quantity*(l.details?.pricing?.effectivePrice??l.details?.price??0)/100,2)}`,label:l.details?.name+" - "+l.quantity,type:"final"}));if(d.selectedDeliveryMethod!=null){let l=d.methods.find(m=>m.id==d.selectedDeliveryMethod);l!=null&&u.push({amount:`${F(l.amount/100,2)}`,label:l.name,type:"final"})}return d.couponCode!=null&&d.couponValue!=null&&u.push({amount:`-${F(d.couponValue/100,2)}`,label:d.couponCode,type:"final"}),{countryCode:d.country||o.country||"PL",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],total:{amount:`${F((d.totalAmount??0)/100,2)}`,label:Re("paymentForCart",t,n),type:"final"},shippingMethods:d.methods.map(l=>({amount:`${F(l.amount/100,2)}`,detail:l.description??"",identifier:l.id,label:l.name,dateComponentsRange:{startDateComponents:{days:l.minDays??1,hours:0,months:0,years:0},endDateComponents:{days:l.maxDays??14,hours:0,months:0,years:0}}})),lineItems:u,currencyCode:d.currency||i[0]?.details?.currency||"PLN"}}}};async function Tl(e){let t=R();if(t.googlePayConfig?.isAvailable!=!0){let n=await ge.get(Q).isOneClickPaymentAvailable({projectId:e});n.googlePay==!0&&n.googlePayConfig!=null?t.googlePayConfig={isAvailable:!0,gateway:n.googlePayConfig.gateway,gatewayId:n.googlePayConfig.gatewayMerchantId,merchantName:n.googlePayConfig.merchantName,merchantId:n.googlePayConfig.merchantId}:t.googlePayConfig={isAvailable:!1,gateway:"",gatewayId:"",merchantName:"",merchantId:""}}return W(t),t.googlePayConfig}function El(e,t){if(e==t.id){let a=t.variants?.findIndex(r=>r.id===e);if(a!=null&&a!=-1){let r=t.variants[a];return{...t,availableQuantity:r.availableQuantity,isDeliverable:r.isDeliverable,images:r.images??t.images,name:t.name+" "+r.name,baseName:t.name,variantName:r.name,price:r.price,currency:r.currency,pricing:r.pricing}}return t}let n=t.variants?.find(a=>a.id===e);return n==null?t:{...t,id:n.id,name:t.name+" "+n.name,baseName:t.name,variantName:n.name,price:n.price,currency:n.currency,pricing:n.pricing,metadata:t.metadata,availableQuantity:n.availableQuantity,isDeliverable:n.isDeliverable,images:n.images??t.images}}function Ie(){let e=R(),t=0;if(e==null){ut.setState(n=>({...n,numberOfProductsInCart:t}));return}t=e.products?.reduce((n,a)=>n+a.quantity,0)??0,ut.setState(n=>({...n,numberOfProductsInCart:t}))}var Rl=200,Al="item-ids-not-found",xt="internal-error",ga={"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"},Dl=new Set(["internal","invalid-request"]),Ml=new Set(["product-not-available","product-not-found"]);function Ol(e){return typeof e=="string"&&Object.hasOwn(ga,e)?ga[e]:void 0}function Ul(e){return/<\/?[a-z!?][^>]*>/i.test(e)}function _l(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 zl(e){return/Error:/.test(e)||/\n\s+at /.test(e)}function Jr(e){let t=e.trim();if(!(t.length===0||t.length>Rl||/[\r\n]/.test(t)||Ul(t)||_l(t)||zl(t)))return t}var jl=3;function Vt(e,t=0){if(typeof e=="object"&&e!=null){if(Array.isArray(e)||t>=jl)return{};let n=e,a=Vt(n.error,t+1);if(a.message==null&&n.message!=null){let r=Vt(n.message,t+1);a={...r,code:a.code??r.code}}return typeof n.code=="string"&&n.code.length>0&&(a.code=n.code),a}if(typeof e!="string")return{};try{let n=JSON.parse(e);return typeof n=="object"&&n!=null?Vt(n,t+1):{}}catch{}return{message:Jr(e)}}function Fl(e){let t;try{t=JSON.parse(e)}catch{return{code:xt,message:Jr(e)}}if(typeof t=="string")return{code:xt,message:Jr(t)};if(typeof t!="object"||t==null)return{code:xt};let n=t,{message:a,code:r}=Vt(n.error),o={code:typeof n.code=="string"&&n.code.length>0?n.code:r??xt,message:a};return Array.isArray(n.itemIds)&&(o.itemIds=n.itemIds.filter(i=>typeof i=="string")),o}function Qr(e,t){let{code:n,message:a,itemIds:r}=Fl(t),o=r!=null&&r.length>0;if(o&&(n===xt||Ml.has(n)))return B(Al,"badInput",r);let i={message:a};return o&&(i.itemIds=r),B(n,e>=500?"internal":"badInput",i)}function kf(e,t){let n=Ol(e.error);if(n!=null)return t(n);if(e.type==="internal"||typeof e.error=="string"&&Dl.has(e.error))return t("checkoutFailed");let a=e.data?.message;return typeof a=="string"&&a.length>0?a:t("checkoutFailed")}var Hl=["online","manual","cod"],ql=["bankTransfer","blik"];function ya(e,t){if(!Array.isArray(e))return[];let n=[];for(let a of e)t.includes(a)&&!n.includes(a)&&n.push(a);return n}function $l(e){if(typeof e!="object"||e==null)return null;let t=e.choice;if(typeof t!="object"||t==null)return null;let n=ya(t.methods,Hl);return n.length<2?null:{methods:n,manualAccountTypes:ya(t.manualAccountTypes,ql)}}function xf(e){if(e==null)return null;let t=e.methods.filter(n=>n!=="cod");return t.length<2?null:{...e,methods:t}}function Cf(e,t){return t!=null&&e.methods.includes(t)?t:e.methods[0]}function Nf(e){let t=e.includes("bankTransfer"),n=e.includes("blik");return n&&!t?"paymentMethodManualBlik":t&&!n?"paymentMethodManualTransfer":"paymentMethodManualBoth"}async function ha(e,t,n=5e3){let a=typeof AbortController>"u"?void 0:new AbortController,r=setTimeout(()=>a?.abort(),n);try{let o=await fetch(e,{method:"POST",headers:t.headers,body:t.body,signal:a?.signal});return o.ok?$l(await o.json()):null}catch{return null}finally{clearTimeout(r)}}var Bl;(a=>{async function e(r,o=1,i,d){let u=pt();if(u==null)throw new Error("No project ID found");let m=await Yr(u).addProduct({productID:r,quantity:o,metadata:i,...d});if(m!=null)return m}a.addProductToCart=e;function t(){ut.setState({isCartVisible:!0})}a.showCart=t;function n(){ut.setState({isCartVisible:!1})}a.hideCart=n})(Bl||={});async function ba(e){try{return await e.text()}catch{return""}}function Pa(e,t){return t=Vr(t),t.locale??=E(),{headers:{...sr,...mr(e),"Content-Type":"application/json"},body:JSON.stringify(t)}}async function ca(e){let t=pt();return t==null?null:ha(dt(t,"/payment-methods"),Pa(t,e))}async function Gr(e){let t=pt();if(t==null)throw new Error("No project ID found");let n=await fetch(dt(t,"/buy"),{method:"POST",...Pa(t,e)});if(n.status!=200){let r=Qr(n.status,await ba(n));return console.warn("cannot create payment URL",n.status,r.error),r}let a=await n.json();return{url:a.url,...a.orderId!=null?{orderId:a.orderId}:{},...a.projectId!=null?{projectId:a.projectId}:{}}}async function Of(e){let t=pt();if(t==null)throw new Error("No project ID found");let n={...sr,...mr(t),"Content-Type":"application/json",...e.apiKey!=null?{Authorization:`Bearer ${e.apiKey}`}:{}},a=e.testMode?`/api/payment/link/auto/${t}/test`:`/api/payment/link/auto/${t}`;delete e.apiKey,delete e.testMode,e.locale??=E();let r=await fetch(Q+a,{method:"POST",headers:n,body:JSON.stringify(e)});return r.ok?{status:"ok",redirectURL:(await r.json()).url}:{...Qr(r.status,await ba(r)),status:"error"}}function Gt(){if(typeof localStorage>"u")return;let e=localStorage.getItem("bitsnap-ref");if(e!=null)return e}function Vr(e){let t=Gt();return t==null||(e.metadata==null&&(e.metadata={}),e.metadata.ref=t),e}export{ge as a,De as b,He as c,qe as d,Me as e,Vn as f,Pt as g,vt as h,tt as i,rt as j,qa as k,_e as l,Al as m,kf as n,xf as o,Cf as p,Nf as q,ut as r,Bl as s,ca as t,Gr as u,Of as v,Gt as w,Vr as x,Im as y,Tm as z,Em as A,F as B,Wo as C,Fr as D,Am as E,jr as F,Vs as G,hl as H,Wr as I,of as J,pt as K,af as L,sf as M,wl as N,lf as O,df as P,Sl as Q,uf as R,cf as S,pf as T,mf as U,ff as V,gf as W,yf as X,ua as Y,Yr as Z};
5
+ //# sourceMappingURL=chunk-ZMEWUEZJ.mjs.map