bitsnap-react 1.20.0 → 1.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BitsnapCart-3RSI3PIM.mjs +2 -0
- package/dist/BitsnapCart-4DKJ7OXL.js +2 -0
- package/dist/BitsnapCart-4DKJ7OXL.js.map +1 -0
- package/dist/{CartProvider-G7FQUPXL.mjs → CartProvider-TXRCAXOT.mjs} +2 -2
- package/dist/CartProvider-ZAGTSCHJ.js +2 -0
- package/dist/CartProvider-ZAGTSCHJ.js.map +1 -0
- package/dist/PanelModelFiles-EKQRLF46.js.map +1 -1
- package/dist/analytics.js +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/analytics.mjs +1 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.js.map +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/chat.d.mts +2 -2
- package/dist/chat.d.ts +2 -2
- package/dist/chat.js +1 -1
- package/dist/chat.js.map +1 -1
- package/dist/chat.mjs +1 -1
- package/dist/chat.mjs.map +1 -1
- package/dist/{chunk-A2ZDFN3J.mjs → chunk-2HINORSP.mjs} +2 -2
- package/dist/{chunk-EFN4OW2C.js → chunk-3TUL63IC.js} +2 -2
- package/dist/chunk-3TUL63IC.js.map +1 -0
- package/dist/chunk-56X4DBMQ.mjs +5 -0
- package/dist/chunk-56X4DBMQ.mjs.map +1 -0
- package/dist/{chunk-4Y233NII.js → chunk-6DEKVABT.js} +2 -2
- package/dist/chunk-6DEKVABT.js.map +1 -0
- package/dist/chunk-6Q3VGPSF.js.map +1 -1
- package/dist/{chunk-LHQEM3CU.mjs → chunk-7WTQGXPQ.mjs} +2 -2
- package/dist/{chunk-IRZJIPUF.js → chunk-EK3D44XW.js} +2 -2
- package/dist/chunk-EK3D44XW.js.map +1 -0
- package/dist/{chunk-BTERIY6N.mjs → chunk-EXC5Z5VM.mjs} +2 -2
- package/dist/{chunk-IXQCN7MR.mjs → chunk-FG7NLLJV.mjs} +2 -2
- package/dist/{chunk-RJPQMDIQ.js → chunk-FPCMLZFM.js} +2 -2
- package/dist/chunk-FPCMLZFM.js.map +1 -0
- package/dist/{chunk-2G46TAUX.mjs → chunk-GLKBCVNH.mjs} +2 -2
- package/dist/{chunk-2G46TAUX.mjs.map → chunk-GLKBCVNH.mjs.map} +1 -1
- package/dist/{chunk-AQYHQY2Y.js → chunk-J4GUVJP4.js} +2 -2
- package/dist/chunk-J4GUVJP4.js.map +1 -0
- package/dist/{chunk-TW25G7XX.mjs → chunk-J6WKSO33.mjs} +2 -2
- package/dist/{chunk-TW25G7XX.mjs.map → chunk-J6WKSO33.mjs.map} +1 -1
- package/dist/{chunk-GHBRR665.js → chunk-J6YI6FJN.js} +2 -2
- package/dist/chunk-J6YI6FJN.js.map +1 -0
- package/dist/chunk-JSDGZ4NY.js.map +1 -1
- package/dist/{chunk-HP3I6D2R.js → chunk-K2HIALKR.js} +2 -2
- package/dist/chunk-K2HIALKR.js.map +1 -0
- package/dist/chunk-KOYBZORL.js.map +1 -1
- package/dist/chunk-MDAFPGPA.js.map +1 -1
- package/dist/{chunk-YPA6MMGJ.js → chunk-MMQTRSI5.js} +2 -2
- package/dist/chunk-MMQTRSI5.js.map +1 -0
- package/dist/chunk-NW5PFIZB.js +2 -0
- package/dist/chunk-NW5PFIZB.js.map +1 -0
- package/dist/{chunk-C736F727.js → chunk-OCJ7YWFX.js} +2 -2
- package/dist/chunk-OCJ7YWFX.js.map +1 -0
- package/dist/chunk-Q337IQNA.js.map +1 -1
- package/dist/{chunk-URQBHNJK.mjs → chunk-QWQPAN4F.mjs} +2 -2
- package/dist/{chunk-KO7ZERN5.mjs → chunk-QXCL5CE6.mjs} +2 -2
- package/dist/chunk-TWZQ4CBY.js +5 -0
- package/dist/chunk-TWZQ4CBY.js.map +1 -0
- package/dist/{chunk-IXX6SUMB.mjs → chunk-VU2MX5HY.mjs} +2 -2
- package/dist/chunk-W3RGQYPD.js.map +1 -1
- package/dist/{chunk-LHNTSQYO.mjs → chunk-YV3UGLQ3.mjs} +2 -2
- package/dist/chunk-Z3YOJ6NZ.js.map +1 -1
- package/dist/consent.js.map +1 -1
- package/dist/course.js +1 -1
- package/dist/course.js.map +1 -1
- package/dist/course.mjs +1 -1
- package/dist/embed/analytics.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/methods-27HZQY5L.js +2 -0
- package/dist/methods-27HZQY5L.js.map +1 -0
- package/dist/methods-27JU6IH7.mjs +2 -0
- package/dist/model-files-client-P4PORZJ6.js.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/returns.js +1 -1
- package/dist/returns.js.map +1 -1
- package/dist/returns.mjs +1 -1
- package/dist/viewer3d.js.map +1 -1
- package/dist/viewer3d.mjs +1 -1
- package/dist/{widgets-Bsojw94g.d.ts → widgets-BL6pCMdc.d.ts} +34 -2
- package/dist/{widgets-u7xMJbsY.d.mts → widgets-DmHlIbp8.d.mts} +34 -2
- package/package.json +1 -1
- package/dist/BitsnapCart-V4S4EXYV.js +0 -2
- package/dist/BitsnapCart-V4S4EXYV.js.map +0 -1
- package/dist/BitsnapCart-Z6JFYNH2.mjs +0 -2
- package/dist/CartProvider-5NP4WACK.js +0 -2
- package/dist/CartProvider-5NP4WACK.js.map +0 -1
- package/dist/chunk-4Y233NII.js.map +0 -1
- package/dist/chunk-5M3OUOMU.mjs +0 -5
- package/dist/chunk-5M3OUOMU.mjs.map +0 -1
- package/dist/chunk-AQYHQY2Y.js.map +0 -1
- package/dist/chunk-C736F727.js.map +0 -1
- package/dist/chunk-EFN4OW2C.js.map +0 -1
- package/dist/chunk-GHBRR665.js.map +0 -1
- package/dist/chunk-HP3I6D2R.js.map +0 -1
- package/dist/chunk-IRZJIPUF.js.map +0 -1
- package/dist/chunk-KDL35KEI.js +0 -2
- package/dist/chunk-KDL35KEI.js.map +0 -1
- package/dist/chunk-KZWCVKLU.js +0 -5
- package/dist/chunk-KZWCVKLU.js.map +0 -1
- package/dist/chunk-RJPQMDIQ.js.map +0 -1
- package/dist/chunk-YPA6MMGJ.js.map +0 -1
- package/dist/methods-33CWGKNA.mjs +0 -2
- package/dist/methods-4GB652MQ.js +0 -2
- package/dist/methods-4GB652MQ.js.map +0 -1
- /package/dist/{BitsnapCart-Z6JFYNH2.mjs.map → BitsnapCart-3RSI3PIM.mjs.map} +0 -0
- /package/dist/{CartProvider-G7FQUPXL.mjs.map → CartProvider-TXRCAXOT.mjs.map} +0 -0
- /package/dist/{chunk-A2ZDFN3J.mjs.map → chunk-2HINORSP.mjs.map} +0 -0
- /package/dist/{chunk-LHQEM3CU.mjs.map → chunk-7WTQGXPQ.mjs.map} +0 -0
- /package/dist/{chunk-BTERIY6N.mjs.map → chunk-EXC5Z5VM.mjs.map} +0 -0
- /package/dist/{chunk-IXQCN7MR.mjs.map → chunk-FG7NLLJV.mjs.map} +0 -0
- /package/dist/{chunk-URQBHNJK.mjs.map → chunk-QWQPAN4F.mjs.map} +0 -0
- /package/dist/{chunk-KO7ZERN5.mjs.map → chunk-QXCL5CE6.mjs.map} +0 -0
- /package/dist/{chunk-IXX6SUMB.mjs.map → chunk-VU2MX5HY.mjs.map} +0 -0
- /package/dist/{chunk-LHNTSQYO.mjs.map → chunk-YV3UGLQ3.mjs.map} +0 -0
- /package/dist/{methods-33CWGKNA.mjs.map → methods-27JU6IH7.mjs.map} +0 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{C as Rn,F as Dn,G as Mn,H as On,I as Un,J as _n,K as zn,a as cr,b as hn,c as Lt,d as We,e as At,f as bn,h as Pn,i as vn,j as kn,k as xn,p as Sn,q as En,r as Ln,t as Tn,u as An}from"./chunk-VU2MX5HY.mjs";import{b as ve}from"./chunk-7WTQGXPQ.mjs";import{e as F,f as Ae,g as ae,k as L,l as Tt,n as Nn,o as Je,p as In}from"./chunk-YV3UGLQ3.mjs";import{a as fn}from"./chunk-HKRH6FI6.mjs";import{a as mt,b as wn,c as Cn,d as Ye}from"./chunk-XEXPQFKN.mjs";import{a as sr,g as ut,h as pt}from"./chunk-CUPG4B5W.mjs";import{a as or,b as ar,d as Nt,e as ir,f as un,g as pn,h as mn}from"./chunk-GLKBCVNH.mjs";import{a as H}from"./chunk-5R6AGO3Z.mjs";import{a as rr,b as cn,c as nr,e as Q,f as yn}from"./chunk-EXC5Z5VM.mjs";import{h as lr,l as It,m as St,n as Ve,o as gn}from"./chunk-J6WKSO33.mjs";import{a as Et,c as Te,e as dr,f as A}from"./chunk-OFPRIENJ.mjs";import{useAutoAnimate as wa}from"@formkit/auto-animate/react";import{useEffect as $n,useMemo as gr,useRef as Bn,useState as Ca}from"react";import{jsx as ft}from"react/jsx-runtime";function Re({className:e,...t}){return ft("div",{"data-slot":"card",className:H("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function je({className:e,...t}){return ft("div",{"data-slot":"card-header",className:H("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function Fe({className:e,...t}){return ft("div",{"data-slot":"card-title",className:H("leading-none font-semibold",e),...t})}function jn({className:e,...t}){return ft("div",{"data-slot":"card-description",className:H("text-muted-foreground text-sm",e),...t})}function De({className:e,...t}){return ft("div",{"data-slot":"card-content",className:H("px-6",e),...t})}import{CircleCheck as ma}from"lucide-react";import{useId as fa}from"react";import{jsx as q,jsxs as X}from"react/jsx-runtime";var ga="text-muted-foreground text-xs leading-5",ya="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",ha=new Set(["invalidEmail","emailNotFound","deliveryUnavailable"]),ur="inline-flex min-h-11 items-center px-1 text-sm underline underline-offset-4 hover:no-underline focus-visible:ring-[3px] focus-visible:ring-ring/50 rounded-sm outline-none disabled:opacity-50 disabled:no-underline";function Fn({login:e,texts:t,allowHaveCode:n=!0,emailPlaceholder:a,emailInputId:r,codeInputId:o,className:i,buttonClassName:d,children:c}){let l=fa(),f=r??`${l}-email`,P=o??`${l}-code`,x=`${l}-notice`,I=`${l}-hint`,{notice:g}=e,u=g?.kind==="error",m=e.busy==="send",p=e.busy==="verify",b=e.busy==="resend",S=H("h-11 w-full",d),U=g?.kind==="success",N=X("div",{id:x,className:"min-h-10 text-sm leading-5",children:[q("p",{role:"alert",className:"font-medium text-red-700 dark:text-red-400",children:u?g.text:null}),X("p",{role:"status",className:H("flex items-start gap-1.5",U?"font-medium text-emerald-700 dark:text-emerald-400":"text-foreground"),children:[U&&q(ma,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0"}),q("span",{children:g!=null&&!u?g.text:null})]})]}),ce=u&&e.step==="email"&&(g.failure==null||ha.has(g.failure)),Se=q("p",{className:"sr-only",role:"status","aria-live":"polite",children:e.announcement}),oe=X("div",{className:"grid gap-2",children:[q(We,{htmlFor:f,children:t.emailLabel}),q(Tt,{id:f,ref:e.emailRef,name:"email",type:"email",autoComplete:"email",inputMode:"email",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,autoFocus:!0,required:!0,className:H("h-11 text-base disabled:opacity-100 disabled:text-foreground/70",ya),placeholder:a??t.emailPlaceholder,value:e.email,disabled:e.isBusy,"aria-invalid":ce?!0:void 0,"aria-describedby":x,onChange:Z=>e.setEmail(Z.target.value)})]});if(e.step==="email")return X("form",{noValidate:!0,className:H("flex flex-col gap-4",i),onSubmit:Z=>{Z.preventDefault(),e.sendCode()},children:[Se,oe,N,X(L,{type:"submit",disabled:e.isBusy,"aria-busy":m,className:S,children:[m&&q(At,{"aria-hidden":!0}),m?t.sending:t.sendCode]}),n&&X("p",{className:"flex flex-wrap items-center justify-center text-center text-sm",children:[t.haveCodePrompt!==""&&q("span",{children:t.haveCodePrompt}),q("button",{type:"button",className:ur,disabled:e.isBusy,onClick:e.haveCode,children:t.haveCode})]})]});let[te,fe]=t.codeSentTo.split("{email}"),E=e.dead!=null,ge=E?t.resendNew:e.secondsLeft>0?vn(t.resendIn,{seconds:e.secondsLeft}):t.resend;return X("form",{noValidate:!0,className:H("flex flex-col gap-4",i),onSubmit:Z=>{Z.preventDefault(),e.submitCode()},children:[Se,e.needsEmail?oe:X("div",{className:"flex flex-wrap items-center justify-between gap-x-2",children:[X("p",{className:"min-w-0 flex-[1_1_14rem] text-sm leading-5 break-words",children:[te,q("strong",{className:"font-semibold",children:e.email}),"\u2060",fe]}),q("button",{type:"button",className:H(ur,"-ml-1 shrink-0"),disabled:e.isBusy,onClick:e.changeEmail,children:t.changeEmail})]}),c,X("div",{className:"grid gap-2",children:[q(We,{htmlFor:P,children:t.codeLabel}),q(xn,{id:P,name:"code",inputRef:e.codeRef,value:e.code,onChange:e.setCode,onComplete:Z=>void e.submitCode(Z),disabled:e.isBusy||E,invalid:u&&!e.needsEmail,"aria-describedby":`${x} ${I}`}),X("p",{id:I,className:ga,children:[t.validity," ",t.spamHint]})]}),N,X(L,{type:"submit",disabled:e.isBusy||E,"aria-busy":p,className:S,children:[p&&q(At,{"aria-hidden":!0}),p?t.verifying:t.verify]}),e.needsEmail?q("div",{className:"flex justify-center",children:q("button",{type:"button",className:ur,disabled:e.isBusy,onClick:e.changeEmail,children:t.noCode})}):X(L,{type:"button",variant:E?"default":"outline",disabled:e.isBusy||!E&&e.secondsLeft>0,"aria-busy":b,className:E?S:"h-11 w-full",onClick:()=>void e.resend(),children:[b&&q(At,{"aria-hidden":!0}),ge]})]})}function pr(e){switch(e){case 1:return"emailNotFound";case 2:return"invalidEmail";case 3:return"wrongCode";case 14:return"expired";case 15:return"tooManyAttempts";case 13:return"rateLimited";case 16:return"captchaRequired";case 17:return"captchaInvalid";case 12:return"deliveryFailed";case 11:return"deliveryUnavailable";default:return"unknown"}}var ba={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 Hn(e=A(),t){return{...Pn(e,t),...Et(ba,e),...Pa(t,["title","description","codeTitle","codeDescription"])}}function Pa(e,t){let n={};for(let a of t){let r=e?.[a];r!=null&&(n[a]=r)}return n}var va="return_url",mr="__return_url",ka="accessToken";function gt(e){let t=new URLSearchParams(e).get(va);return t?qn(t):null}function yt(e){typeof window>"u"||(e?window.sessionStorage.setItem(mr,e):window.sessionStorage.removeItem(mr))}function Ze(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(mr);return e?qn(e):null}function xa(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 qn(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!xa(t.origin,pt())?null:t.toString()}catch{return null}}function Qe(e,t){let n=new URL(e);return n.searchParams.set(ka,t),n.toString()}import{jsx as ie,jsxs as fr}from"react/jsx-runtime";if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];pt().length===0&&ut(Array.from(new Set(t)))}var Na=({texts:e,projectID:t,host:n,locale:a,logo:r})=>{let[o,i]=Ca(!1),d=Bn(void 0),c=Bn(""),l=gr(()=>()=>new Promise(b=>{i(!0);let S=window.setTimeout(()=>{d.current=void 0,i(!1),b(!1)},5*60*1e3);d.current=U=>{window.clearTimeout(S),d.current=void 0,i(!1),c.current=U??"",b(U!==null)}}),[]),f=St(),{mutateAsync:P}=ae(F.publicApi.userPanelLogin),{mutateAsync:x}=ae(F.publicApi.userPanelLoginWithCode),I=gr(()=>({async send(b){try{let S=await P({email:b,turnstileToken:c.current});return c.current="",S.result.case==="success"?{ok:!0,retryIn:S.result.value.retryIn||void 0,challengeId:S.result.value.challengeId||void 0}:{ok:!1,kind:pr(S.result.case==="failure"?S.result.value:0)}}catch(S){return{ok:!1,kind:cr(S),cause:S}}},async verify({email:b,code:S,challengeId:U}){try{let N=await x({code:parseInt(S,10),email:b,challengeId:U});return N.result.case==="accessToken"&&N.result.value?{ok:!0,value:{accessToken:N.result.value}}:{ok:!1,kind:pr(N.result.case==="failure"?N.result.value:0)}}catch(N){return{ok:!1,kind:cr(N),cause:N}}}}),[P,x]),g=kn({adapter:I,texts:e,beforeSend:l,storageKey:bn("panel",t,n),onVerified:({accessToken:b},S)=>{f.track("panel_login",{}),wn(t,b,S,n);let U=typeof window<"u"?Ze():null;setTimeout(()=>{if(U){window.location.href=Qe(U,b);return}window.location.reload()},100)}}),u=g.step==="code",m=u&&!g.needsEmail?e.codeTitle:e.title,p=u&&!g.needsEmail?e.codeDescription:e.description;return ie("main",{className:"mx-auto flex w-full max-w-sm flex-1 flex-col justify-start pt-4 sm:pt-[12vh]",children:fr(Re,{children:[ie(Lt,{projectId:t,locale:a,className:"px-4 sm:px-6",...r}),fr(je,{className:"px-4 sm:px-6",children:[ie(Fe,{role:"heading","aria-level":1,className:"text-2xl",children:m}),ie(jn,{children:p})]}),fr(De,{className:"px-4 sm:px-6",children:[ie(Fn,{login:g,texts:e,emailInputId:"email",codeInputId:"verify-code"}),o&&ie(fn,{action:"panel_login",locale:a,onToken:b=>d.current?.(b),onFailure:()=>d.current?.(null)})]})]})})},Ia=({analytics:e,texts:t,locale:n,showLogo:a,logoUrl:r,logoDarkUrl:o})=>{let{theme:i,allowedReturnOrigins:d,projectID:c,host:l}=ve(),f=Ve(c,e,"panel"),P=gr(()=>Hn(n??A(),t),[n,t]),x={"--button-background-color":i?.colors?.brand??"#FFFFFF","--button-background-color-dark":i?.colors?.brandDark??"#000000","--button-text-color":i?.colors?.brandDark??"#000000","--button-text-color-dark":i?.colors?.brand??"#FFFFFF"},[I]=wa({duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1});return $n(()=>{typeof window>"u"||mt(c,l)!=null&&(window.location.href=window.location.href.replaceAll("login",""))},[c,l]),$n(()=>{if(typeof window>"u"||window.parent!==window)return;let g=gt(window.location.search);g&&yt(g);let u=g??Ze();if(!u)return;let m=mt(c,l);m&&(window.location.href=Qe(u,m))},[d,c,l]),ie(It,{value:f,children:ie("div",{className:"bg-white text-black dark:bg-black dark:text-white",children:ie("div",{className:"font-inter flex min-h-screen w-full flex-col p-4",style:x,ref:I,children:ie(Na,{texts:P,projectID:c,host:l,locale:n,logo:{showLogo:a,logoUrl:r??i?.logoURL,logoDarkUrl:o??i?.logoDarkURL}})})})})},Sa=(e={})=>ie(Ia,{...e});import{useAutoAnimate as ms}from"@formkit/auto-animate/react";import{useEffect as Ut,useState as To}from"react";import{useState as Ea,useCallback as La,useEffect as Ta}from"react";function Kn(e){let[t,n]=Ea(()=>{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=La(r=>{n(o=>{let i={...o,...r};if(typeof window<"u"){let d=new URLSearchParams;Object.keys(i).forEach(l=>{let f=i[l];f!=null&&d.set(l,JSON.stringify(f))});let c=`${window.location.pathname}?${d.toString()}`;window.history.pushState({},"",c)}return i})},[]);return Ta(()=>{let r=()=>{let o=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(d=>{let c=o.get(d);if(c!==null)try{i[d]=JSON.parse(c)}catch{i[d]=c}}),n({...e,...i})};return window.addEventListener("popstate",r),()=>window.removeEventListener("popstate",r)},[e]),[t,a]}function Gn(e,t){if(e!=null)return e;let n=t?.trim();if(!(n==null||n===""))return{tokens:Nn(n)}}var Aa={pl:{returnsNavLabel:"Zwroty",openCourse:"Otw\xF3rz kurs",libraryNavLabel:"Biblioteka",messagesNavLabel:"Wiadomo\u015Bci",ordersNavLabel:"Zam\xF3wienia",accountNavLabel:"Konto",navigationLabel:"Panel klienta",logout:"Wyloguj si\u0119",profileHeading:"Profil",emailLabel:"E-mail",noData:"Brak danych",languageLabel:"J\u0119zyk",polishLanguage:"Polski",englishLanguage:"English",plansHeading:"Plany",plansUnavailable:"Plany nie s\u0105 obecnie dost\u0119pne w panelu.",notificationsHeading:"Powiadomienia",notificationsUnavailable:"Ustawienia powiadomie\u0144 nie s\u0105 obecnie dost\u0119pne w panelu.",ordersHeading:"Historia zam\xF3wie\u0144",ordersDescription:"Twoje zam\xF3wienia",ordersEmpty:"Brak zam\xF3wie\u0144.",ordersError:"Nie uda\u0142o si\u0119 pobra\u0107 zam\xF3wie\u0144.",retry:"Spr\xF3buj ponownie",orderLabel:"Zam\xF3wienie",customerLabel:"Klient",dateLabel:"Data",ordersEnd:"To ju\u017C wszystkie Twoje zam\xF3wienia.",previousPage:"Poprzednia strona",nextPage:"Nast\u0119pna strona",paginationLabel:"Strony zam\xF3wie\u0144",statusDraft:"Szkic",statusUnpaid:"Nieop\u0142acone",statusPaid:"Op\u0142acone",statusOverdue:"Zaleg\u0142e",statusCancelled:"Anulowane",statusCompleted:"Zako\u0144czone",statusProcessing:"Przetwarzane",statusRefunded:"Zwr\xF3cone"},en:{returnsNavLabel:"Returns",openCourse:"Open the course",libraryNavLabel:"Library",messagesNavLabel:"Messages",ordersNavLabel:"Orders",accountNavLabel:"Account",navigationLabel:"Customer panel",logout:"Log out",profileHeading:"Profile",emailLabel:"Email",noData:"No data",languageLabel:"Language",polishLanguage:"Polski",englishLanguage:"English",plansHeading:"Plans",plansUnavailable:"Plans are currently unavailable in the panel.",notificationsHeading:"Notifications",notificationsUnavailable:"Notification settings are currently unavailable in the panel.",ordersHeading:"Order history",ordersDescription:"Your orders",ordersEmpty:"No orders yet.",ordersError:"Could not load your orders.",retry:"Try again",orderLabel:"Order",customerLabel:"Customer",dateLabel:"Date",ordersEnd:"You\u2019ve reached the end of your orders.",previousPage:"Previous page",nextPage:"Next page",paginationLabel:"Order pages",statusDraft:"Draft",statusUnpaid:"Unpaid",statusPaid:"Paid",statusOverdue:"Overdue",statusCancelled:"Cancelled",statusCompleted:"Completed",statusProcessing:"Processing",statusRefunded:"Refunded"}};function pe(e=A()){return Et(Aa,e)}import{jsx as Vn,jsxs as Ra}from"react/jsx-runtime";function yr({}){let e=pe();return Ra("section",{children:[Vn("h3",{className:"text-2xl",children:e.notificationsHeading}),Vn("p",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:e.notificationsUnavailable})]})}import{useState as Da}from"react";import{Fragment as za,jsx as O,jsxs as W}from"react/jsx-runtime";var Ma=e=>new Date(e*1e3).toLocaleDateString(A(),{year:"numeric",month:"short",day:"numeric"}),Oa=(e,t)=>new Intl.NumberFormat(A(),{style:"currency",currency:t.toUpperCase()}).format(e/100),Ua={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 _a({openOrderDetails:e,projectID:t,accessToken:n}){let a=pe(),r={draft:a.statusDraft,unpaid:a.statusUnpaid,paid:a.statusPaid,overdue:a.statusOverdue,cancelled:a.statusCancelled,completed:a.statusCompleted,processing:a.statusProcessing,refunded:a.statusRefunded},[o,i]=Da(0),d=20,{data:c,isFetching:l,isError:f,refetch:P}=Ae(F.publicApi.getOrders,{projectId:t,accessToken:n,offset:o,limit:d}),x=c?.orders??[],I=c?.totalCount??0,g=Math.floor(o/d)+1,u=Math.ceil(I/d),m=p=>{i(p)};return W(za,{children:[O("h3",{className:"text-2xl",children:a.ordersHeading}),O("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:a.ordersDescription}),l?O("div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((p,b)=>W("div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[W("div",{className:"flex items-center justify-between gap-3",children:[W("div",{className:"space-y-2",children:[O(Je,{className:"h-4 w-24"}),O(Je,{className:"h-3 w-32"})]}),W("div",{className:"space-y-2 text-right",children:[O(Je,{className:"ml-auto h-4 w-16"}),O(Je,{className:"ml-auto h-3 w-12"})]})]}),O("div",{className:"mt-3",children:O(Je,{className:"h-3 w-40"})})]},b))}):f?W("div",{role:"alert",className:"mt-6 space-y-3",children:[O("p",{children:a.ordersError}),O(L,{onClick:()=>void P(),className:"min-h-11 focus-visible:outline-2 focus-visible:outline-current",children:a.retry})]}):x.length===0?O("div",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:a.ordersEmpty}):W("div",{children:[O("div",{className:"mt-6 flex w-full flex-col gap-3",children:x.map(p=>W("button",{onClick:()=>e(p.id),className:"block min-h-11 focus-visible:outline-2 focus-visible:outline-current rounded-xl bg-white p-4 text-left shadow-sm transition-colors hover:bg-neutral-50 dark:bg-neutral-800 dark:hover:bg-neutral-700",children:[W("div",{className:"flex items-center justify-between gap-3",children:[W("div",{className:"min-w-0 break-words",children:[W("p",{className:"font-medium",children:[a.orderLabel," #",p.id]}),O("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:p.customerName||a.customerLabel})]}),W("div",{className:"shrink-0 text-right",children:[O("p",{className:"font-semibold",children:Oa(p.totalAmount,p.currency)}),O("p",{className:`text-xs font-medium ${Ua[p.status]??"text-neutral-400"}`,children:r[p.status]??p.status})]})]}),O("div",{className:"mt-2 flex items-center justify-between gap-3 text-xs text-neutral-500 dark:text-neutral-400",children:W("span",{children:[a.dateLabel,":"," ",p.createdAt?Ma(Number(p.createdAt.seconds)):"-"]})})]},p.id))}),g>=u&&O("p",{className:"mt-6 text-center text-sm text-neutral-600 dark:text-neutral-400",children:a.ordersEnd}),u>1&&W("nav",{"aria-label":a.paginationLabel,className:"mt-4 flex flex-wrap items-center justify-center gap-2",children:[g>1&&O(L,{variant:"outline",className:"min-h-11",onClick:()=>m(o-d),children:a.previousPage}),Array.from(new Set([1,g-1,g,g+1,u])).filter(p=>p>0&&p<=u).sort((p,b)=>p-b).map(p=>O(L,{variant:p===g?"secondary":"ghost",className:"min-h-11 min-w-11","aria-current":p===g?"page":void 0,onClick:()=>m((p-1)*d),children:p},p)),g<u&&O(L,{variant:"outline",className:"min-h-11",onClick:()=>m(o+d),children:a.nextPage})]})]})]})}var Wn=_a;import{jsx as Yn,jsxs as ja}from"react/jsx-runtime";function hr({projectID:e}){let t=pe();return ja("section",{children:[Yn("h3",{className:"text-2xl",children:t.plansHeading}),Yn("p",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:t.plansUnavailable})]})}import{useEffect as Fa,useState as br}from"react";import{jsx as se,jsxs as $a}from"react/jsx-runtime";function Ha(e,t,n,a){typeof window>"u"||(t&&Ye(n,a),window.location.href=e)}function qa({projectID:e,host:t,loginURL:n,screen:a,params:r,setParams:o,setActiveScreen:i}){let{status:d,exchangeError:c}=Tn("PanelReturns"),l=Ln(),f=d==="anonymous"&&(c==null||Sn(c));Fa(()=>{f&&Ha(n,c!=null,e,t)},[f,n,c,e,t]);let[P,x]=br("orders"),[I,g]=br({items:[],note:""}),[u,m]=br();if(d==="anonymous"&&!f)return $a("div",{role:"alert",className:"flex flex-col items-start gap-3",children:[se("p",{className:"text-sm",children:l(En(c))}),se(L,{type:"button",onClick:()=>window.location.reload(),children:l("errorRetry")})]});if(d!=="authenticated")return se(Rn,{});let p=b=>{x(b),o({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(a==="return-details"&&r.returnId)return se(zn,{returnId:r.returnId,onBack:()=>p("myReturns")});if(P==="myReturns")return se(_n,{onBack:()=>p("orders"),onSelectReturn:b=>{o({state:"return-details",returnId:b,orderId:void 0}),i("return-details")}});if(P==="result"&&u!=null)return se(Un,{returnId:u,onContinue:()=>p("orders"),onOpenMyReturns:()=>p("myReturns")});if(r.orderId){let b=r.orderId;return P==="confirmation"?se(On,{orderId:b,items:I.items,note:I.note,onBack:()=>x("orders"),onSubmitted:S=>{m(S),g({items:[],note:""}),x("result"),o({orderId:void 0})}}):se(Mn,{orderId:b,initialItems:I.items.length>0?I.items:void 0,initialNote:I.note,onBack:()=>{g({items:[],note:""}),o({orderId:void 0})},onContinue:S=>{g(S),x("confirmation")}})}return se(Dn,{showLogout:!1,onSelectOrder:b=>{g({items:[],note:""}),x("orders"),o({orderId:b})},onOpenMyReturns:()=>p("myReturns")})}function Pr({accessToken:e,appearance:t,texts:n,...a}){return se(An,{projectID:a.projectID,host:a.host,appearance:t,texts:n,panelAccessToken:e,children:se(qa,{...a})})}import{lazy as Li,Suspense as Ti,useEffect as Ir,useState as Ai}from"react";import{BookOpen as Ri,Files as Di,Headphones as Mi,MessageCircle as Oi,Ticket as Ui,Users as _i}from"lucide-react";var Ba={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"},Ka={hello:"Hi \u{1F44B}",intro:"Your products are below",loading:"Loading products\u2026",empty:"You have no products in this shop yet. Your purchases will show up here.",audio:"Audio",files:"Files",course:"Course",ticket:"Ticket",chat:"Chat",community:"Community",openMessages:"Open messages",listen:"Listen",openCourse:"Open course",downloadFiles:"Download files",showTicket:"Show ticket",back:"Back",yourFiles:"Your files",download:"Download",retry:"Try again",fileError:"Your files could not be loaded.",noFiles:"No files to download.",ticketInfo:"Your purchased ticket",file:"File"};function Xe(){return A().toLowerCase().startsWith("en")?Ka:Ba}import{jsx as Ya}from"react/jsx-runtime";var Ga=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,Va=e=>[...e.matchAll(Ga)].map(n=>({url:n[0],startIndex:n.index,endIndex:n.index+n[0].length-1})),Wa=(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},Jn=e=>{let t=Va(e);return Ya("p",{dangerouslySetInnerHTML:{__html:Wa(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 zi}from"@bufbuild/protobuf";import{useAutoAnimate as xi}from"@formkit/auto-animate/react";import{ChevronLeft as wi,Download as Ci}from"lucide-react";import{useEffect as uo,useRef as po,useState as qe}from"react";import di from"hls.js";import{Pause as ci,Play as ui,SkipBack as pi,SkipForward as mi}from"lucide-react";import{forwardRef as fi,useEffect as He,useImperativeHandle as gi,useRef as G,useState as we}from"react";import{jsx as vr,jsxs as Za}from"react/jsx-runtime";function Ja(){return Za("div",{className:"flex items-center gap-2",children:[vr("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),vr("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),vr("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var ke=Ja;import Qa from"hls.js";var Xa=[401,403],Zn="networkError",Qn="mediaError";function ei(e,t){if(e==null||e.fatal!==!0)return{action:"ignore"};let n=e.response?.code,a=e.type===Zn?"network":e.type===Qn?"media":"unknown",r=n==null?{kind:a}:{kind:a,status:n};return n!=null&&Xa.includes(n)?{action:"expired",error:{kind:"network",status:n}}:e.type===Zn&&!t.network?{action:"restart-load"}:e.type===Qn&&!t.media?{action:"recover-media"}:{action:"fail",error:r}}function Xn(e){let t=e.HlsCtor??Qa,n=new t,a,r=!1,o=!1;return n.attachMedia(e.media),n.on(t.Events.ERROR,(i,d)=>{let c=ei(d,{network:r,media:o});switch(c.action){case"expired":e.handlers?.onExpiredUrl?.(),e.handlers?.onError?.(c.error);break;case"restart-load":r=!0,n.startLoad();break;case"recover-media":o=!0,n.recoverMediaError();break;case"fail":e.handlers?.onError?.(c.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 eo(e){try{return e.canPlayType("application/vnd.apple.mpegurl")!==""}catch{return!1}}function to(e){switch(e?.code){case 2:return{kind:"network"};case 3:case 4:return{kind:"media"};default:return{kind:"unknown"}}}var ti={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",avif:"image/avif",svg:"image/svg+xml"},kr="512x512";function et(){return typeof navigator<"u"&&typeof navigator.mediaSession<"u"}function ri(e){if(typeof e!="string"||e.length===0)return{src:e,sizes:kr};let t=e.split(/[?#]/)[0],n=t.includes(".")?t.slice(t.lastIndexOf(".")+1).toLowerCase():"",a=ti[n],r={src:e,sizes:kr};return a!=null&&(r.type=a),r}function ni(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(ri(a));continue}a!=null&&a.src.length>0&&n.push({src:a.src,sizes:a.sizes??kr,...a.type!=null?{type:a.type}:{}})}return n.length>0?n:void 0}function xr(e){!et()||typeof MediaMetadata>"u"||(navigator.mediaSession.metadata=new MediaMetadata({title:e.title,album:e.album,artist:e.artist,artwork:ni(e.artwork)}))}function ro(){et()&&(navigator.mediaSession.playbackState="playing")}function no(){et()&&(navigator.mediaSession.playbackState="paused")}function oo(e,t,n=1){if(!et()||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 ao=["play","pause","stop","seekbackward","seekforward","seekto","previoustrack","nexttrack"];function io(e){if(et()){xr({title:e.title,album:e.album,artist:e.artist,artwork:e.artwork});for(let t of ao)try{navigator.mediaSession.setActionHandler(t,n=>{e.action(n)})}catch{}}}function so(){if(et()){navigator.mediaSession.metadata=null;for(let e of ao)try{navigator.mediaSession.setActionHandler(e,null)}catch{}}}import{useEffect as oi,useState as ai}from"react";var ii={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"},si={play:"Play",pause:"Pause",previous:"Previous chapter",next:"Next chapter",rewind:"Rewind 10 seconds",forward:"Forward 10 seconds",progress:"Playback progress",of:"of",speed:"Speed",sleep:"Sleep timer",off:"Off",end:"End of chapter",cancel:"Cancel timer",error:"The recording could not be played.",retry:"Try again",left:"left",book:"whole book",chapter:"chapter",chapters:"Chapters",loading:"Loading chapters\u2026",empty:"No chapters to display.",resume:"Continue",chapterName:"Chapter",download:"Download chapter",playing:"Now playing",played:"Played"};function Rt(e){let[t,n]=ai("pl");return oi(()=>{try{n(A())}catch{}},[]),(e??t).toLowerCase().startsWith("en")?si:ii}function xe(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;return`${t>=3600?`${Math.floor(t/3600)}:`:""}${String(Math.floor(t/60)%60).padStart(2,"0")}:${String(t%60).padStart(2,"0")}`}var Y={get(e){try{return localStorage.getItem(e)}catch{return null}},set(e,t){try{localStorage.setItem(e,t)}catch{}},remove(e){try{localStorage.removeItem(e)}catch{}}},wr="__player__speed",Dt=[.75,1,1.25,1.5,1.75,2];import{jsx as M,jsxs as $}from"react/jsx-runtime";var yi=fi(({chapters:e,locale:t,styles:n,updateCurrentTime:a,setCurrentTimeHandler:r,title:o,imageURL:i,coverShownBeside:d,author:c,uniqueProductID:l,onChapterChange:f,onError:P,onExpiredUrl:x,onFinished:I},g)=>{let u=Rt(t),[m,p]=we(1),b=G(1),[S,U]=we(),[N,ce]=we("off"),[Se,oe]=we(0),te=G({mode:"off",deadline:0});function fe(){te.current={mode:"off",deadline:0},ce("off"),oe(0)}function E(s){let h=Number(s)*60;te.current={mode:s,deadline:Number.isFinite(h)?Date.now()+h*1e3:0},ce(s),oe(Number.isFinite(h)?h:0)}function ge(s){Dt.includes(s)&&(p(s),b.current=s,Y.set(wr,String(s)),z.current&&(z.current.playbackRate=s),K())}He(()=>{let s=Number(Y.get(wr));Dt.includes(s)&&ge(s);let h=setInterval(()=>{let{mode:k,deadline:D}=te.current;if(k==="off"||k==="chapter")return;let Pe=Math.max(0,Math.ceil((D-Date.now())/1e3));oe(Pe),Pe===0&&(ze.current=!1,xt(),fe())},1e3);return()=>clearInterval(h)},[]);let Z;(k=>(k[k.Playing=0]="Playing",k[k.Paused=1]="Paused"))(Z||={});let[_e,lt]=we(1),[Bt,Ee]=we(void 0),[w,ye]=we(void 0),[Be,ue]=we(!1),[vt,Wr]=we(null),z=G(null),he=G(null),kt=G(void 0),aa=G(null),re=G(null),Kt=G(null),ze=G(!1),Ke=G(!1),dt=G(null),Gt=G(null),Vt=G(e),Yr=G(null),ne=G({onChapterChange:f,onError:P,onExpiredUrl:x,onFinished:I,updateCurrentTime:a,title:o,imageURL:i,author:c});ne.current={onChapterChange:f,onError:P,onExpiredUrl:x,onFinished:I,updateCurrentTime:a,title:o,imageURL:i,author:c};function Wt(s){!Ke.current||!Number.isFinite(s)||s<0||Y.set(`__player__${l}_${re.current?.id}`,`${Math.floor(s)}`)}function ia(){let s=Y.get(`__player__${l}_${re.current?.id}`);if(s!=null)try{let h=parseInt(s);return isNaN(h)||h<0?void 0:h}catch{return}}function sa(){let s=Y.get(`__player__${l}_last_chapter`);if(s!=null)return s}function Jr(s){Y.set(`__player__${l}_last_chapter`,s)}function Zr(s){Y.remove(`__player__${l}_${s}`)}function Yt(s){xr({title:s?.name??ne.current.title??"",album:ne.current.title,artist:ne.current.author,artwork:ne.current.imageURL})}function Qr(s){Kt.current=s,Wr(s),ue(!1),ne.current.onError?.(s)}function Xr(){Kt.current=null,Wr(null)}function en(){let s=z.current;if(s==null)return;let h=s.play();h!=null&&typeof h.catch=="function"&&h.catch(()=>{}),K()}function tn(){en()}function xt(){z.current?.pause(),K()}function la(){if(_e===0){xt();return}tn()}function Le(s){let h=z.current;if(h==null||!Number.isFinite(s))return;let k=Number.isFinite(h.duration)?h.duration:0,D=k>0?Math.min(Math.max(s,0),k):Math.max(s,0);Ee(D),h.currentTime=D,K()}function wt(s){let h=z.current;if(h==null)return;let k=Number.isFinite(h.duration)?h.duration:void 0,D=Math.max(h.currentTime+s,0);k!=null&&D>k&&(D=k),Le(D)}function Jt(s){let h=z.current;if(h!=null){if(Xr(),ue(!0),eo(h)){Zt(),h.src=s,h.load();return}if(di.isSupported()){he.current==null&&(he.current=Xn({media:h,handlers:{onError:k=>{Qr(k)},onExpiredUrl:()=>{ne.current.onExpiredUrl?.()}}})),he.current.load(s);return}Zt(),h.src=s,h.load()}}function Zt(){he.current?.destroy(),he.current=null}function Ct(s,h){let k=h?.play===!0;re.current&&z.current&&!z.current.ended&&Wt(z.current.currentTime),Ke.current=!1,dt.current=null,ze.current=k,re.current=s,U(s.id),Ee(0),ye(s.duration),Jt(s.publicUrl),Yt(s),ne.current.onChapterChange?.(s),Jr(s.id)}function Qt(s){if(s.length===0)return;let h=sa(),k=(h!=null?s.find(D=>D.id===h):void 0)??s[0];Ct(k,{play:!1})}function Xt(){let s=Vt.current,h=re.current;if(s==null||s.length===0||h==null)return;let k=s.findIndex(Pe=>Pe.id===h.id);if(k===-1)return;let D=k+1;if(D>=s.length){da(h);return}Ct(s[D],{play:!0})}function rn(){let s=Vt.current,h=re.current;if(h==null)return;let k=z.current;if(k!=null&&k.currentTime>3){Le(0);return}let D=s==null?-1:s.findIndex(Pe=>Pe.id===h.id);if(D>0){Ct(s[D-1],{play:!0});return}Le(0)}function da(s){Zr(s.id),ze.current=!1,z.current?.pause(),lt(1),ne.current.onFinished?.()}function nn(){let s=re.current;if(s!=null){if(Y.set(`__player__${l}_${s.id}_completed`,"true"),Zr(s.id),te.current.mode==="chapter"){ze.current=!1,xt(),fe();return}Xt(),K()}}function on(){let s=z.current;if(s!=null){if(ue(!1),s.playbackRate=b.current,Gt.current=null,!Ke.current){Ke.current=!0;let h=dt.current;if(dt.current=null,h!=null)Le(h);else{let k=ia();k!=null&&Le(k)}}ze.current&&(ze.current=!1,en())}}function an(){let s=z.current?.error,h=re.current?.publicUrl;(s?.code===2||s?.code===4)&&he.current==null&&h!=null&&Gt.current!==h&&(Gt.current=h,ne.current.onExpiredUrl?.()),Qr(to(s))}function sn(){let h=re.current?.publicUrl??he.current?.src;if(h==null)return;let D=z.current?.currentTime??0;Xr(),Ke.current=!1,dt.current=D>0?D:null,Ee(D),he.current!=null?he.current.retry():Jt(h)}function ca(s){switch(s.action){case"play":tn();break;case"pause":case"stop":xt();break;case"seekbackward":wt(-(s.seekOffset??10));break;case"seekforward":wt(s.seekOffset??10);break;case"seekto":s.seekTime!=null&&Le(s.seekTime);break;case"previoustrack":rn();break;case"nexttrack":Xt();break;default:break}}gi(g,()=>({selectChapter:s=>{Ct(s,{play:!0})},retry:sn,getError:()=>Kt.current}));function K(){let s=z.current;s!=null&&(lt(s.paused?1:0),ye(s.duration),Ee(s.currentTime),s.ended||Wt(s.currentTime),oo(s.duration,s.currentTime,s.playbackRate),s.networkState===s.NETWORK_LOADING&&s.readyState<=s.HAVE_FUTURE_DATA?ue(!0):ue(!1),ne.current.updateCurrentTime?.(s.currentTime))}He(()=>(io({title:o??"",album:o,artist:c,artwork:i,action:ca}),()=>{so()}),[]),He(()=>{Yt(re.current)},[o,c,i]),He(()=>{let s=z.current;if(s!=null)return s.addEventListener("loadeddata",on),s.addEventListener("ended",nn),s.addEventListener("error",an),s.addEventListener("timeupdate",K),s.addEventListener("play",K),s.addEventListener("pause",K),s.addEventListener("ratechange",K),K(),kt.current=setInterval(K,500),()=>{s.removeEventListener("loadeddata",on),s.removeEventListener("ended",nn),s.removeEventListener("error",an),s.removeEventListener("timeupdate",K),s.removeEventListener("play",K),s.removeEventListener("pause",K),s.removeEventListener("ratechange",K),kt.current!=null&&(clearInterval(kt.current),kt.current=void 0),s.ended||Wt(s.currentTime),Ee(void 0),s.pause(),Zt(),s.removeAttribute("src"),s.load()}},[]),He(()=>{r?.(Le)},[]);let er=e.map(s=>`${s.id}|${s.publicUrl??""}`).join(`
|
|
4
|
+
`);He(()=>{Vt.current=e;let s=Yr.current;if(s===er)return;if(Yr.current=er,s==null){Qt(e);return}let h=re.current;if(h==null){Qt(e);return}let k=e.find(D=>D.id===h.id);if(!(k!=null&&k.publicUrl===h.publicUrl)){if(k!=null){let D=z.current,Pe=D?.currentTime??0,pa=D!=null&&!D.paused;re.current=k,Ke.current=!1,dt.current=Pe>0?Pe:null,ze.current=pa,Jt(k.publicUrl),Yt(k),ne.current.onChapterChange?.(k),Jr(k.id);return}Qt(e)}},[er]),He(()=>{switch(_e){case 0:ro();break;case 1:no();break}},[_e]);let Ge=e.findIndex(s=>s.id===S),be=Number.isFinite(w)&&w>0?w:e[Ge]?.duration??0,ct=Math.min(Math.max(Bt??0,0),be||1/0),ln=e.length>0&&e.every(s=>Number.isFinite(s.duration)&&s.duration>0),ua=Math.max(0,be-ct+(ln?e.slice(Ge+1).reduce((s,h)=>s+h.duration,0):0))/m,tr=Math.ceil(ua/60),dn=`${Math.floor(tr/60)>0?`${Math.floor(tr/60)} h `:""}${tr%60} min`;return $("div",{id:"audio-player-container",className:"bitsnap-audio-player flex min-w-0 flex-col gap-3 text-neutral-900 dark:text-neutral-100",style:{...n,"--seek-before-width":`${be>0?ct/be*100:0}%`},ref:aa,"data-player-error":vt?.kind,children:[M("video",{ref:z,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[Ge]?.name??o}),c&&M("p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:c})]})]}),vt&&$("div",{role:"alert",className:"rounded-lg bg-red-50 p-3 text-red-800 dark:bg-red-950 dark:text-red-200",children:[M("p",{children:u.error}),M(L,{variant:"outline",onClick:sn,children:u.retry})]}),M("input",{type:"range",min:"0",max:be||100,value:ct,disabled:!be,"aria-label":u.progress,"aria-valuetext":`${xe(ct)} ${u.of} ${xe(be)}`,onChange:s=>Le(Number(s.target.value))}),$("section",{className:"flex w-full justify-between text-sm tabular-nums",children:[M("span",{id:"current-time",children:xe(ct)}),M("span",{id:"duration",children:xe(be)})]}),be>0&&$("p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:[u.left==="left"?`${dn} ${u.left}`:`${u.left} ${dn}`," ","\xB7 ",ln?u.book:u.chapter," (",m,"\xD7)"]}),$("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[M(L,{variant:"outline",onClick:rn,disabled:Ge<0,"aria-label":u.previous,children:M(pi,{className:"h-5 w-5"})}),$(L,{variant:"outline",onClick:()=>wt(-10),"aria-label":u.rewind,children:["\u2212",10]}),M(L,{variant:"outline",onClick:la,"aria-label":_e===1?u.play:u.pause,children:_e===1?M(ui,{className:"h-5 w-5"}):M(ci,{className:"h-5 w-5"})}),$(L,{variant:"outline",onClick:()=>wt(10),"aria-label":u.forward,children:["+",10]}),M(L,{variant:"outline",onClick:Xt,disabled:Ge<0||Ge>=e.length-1,"aria-label":u.next,children:M(mi,{className:"h-5 w-5"})})]}),$("div",{className:"flex flex-wrap gap-3 md:grid md:grid-cols-2",children:[$("label",{className:"flex flex-1 items-center gap-2 text-sm md:flex-col md:items-start md:whitespace-nowrap",children:[u.speed,M("select",{"aria-label":u.speed,value:m,onChange:s=>ge(Number(s.target.value)),children:Dt.map(s=>$("option",{value:s,children:[s,"\xD7"]},s))})]}),$("label",{className:"flex flex-1 items-center gap-2 text-sm md:flex-col md:items-start md:whitespace-nowrap",children:[u.sleep,$("select",{"aria-label":u.sleep,value:N,onChange:s=>E(s.target.value),children:[M("option",{value:"off",children:u.off}),[15,30,45,60].map(s=>$("option",{value:s,children:[s," min"]},s)),M("option",{value:"chapter",children:u.end})]})]})]}),N!=="off"&&$("div",{className:"flex items-center justify-between gap-2 text-sm",children:[M("span",{role:"timer",children:N==="chapter"?u.end:xe(Se)}),M(L,{variant:"outline",onClick:fe,children:u.cancel})]}),Be&&M("div",{role:"status",className:"flex justify-center",children:M(ke,{})})]})}),lo=yi;import{Check as hi,Download as bi,Play as Pi}from"lucide-react";import{useEffect as vi,useState as co}from"react";import{Fragment as ki,jsx as le,jsxs as rt}from"react/jsx-runtime";function Cr({chapters:e,currentID:t,productID:n,onSelect:a,downloadable:r,onDownload:o,loading:i,locale:d}){let c=Rt(d),[l,f]=co(null),[P,x]=co([]);vi(()=>{let u=`__player__${n}_`,m=Y.get(`${u}last_chapter`),p=Number(m&&Y.get(`${u}${m}`));f(m&&p>0&&Number.isFinite(p)?{id:m,time:p}:null),x((e??[]).filter(b=>Y.get(`${u}${b.id}_completed`)==="true"||Number(Y.get(`${u}${b.id}`))>0).map(b=>b.id))},[e,n,t]);let I=e?.findIndex(u=>u.id===l?.id)??-1,g=e?.findIndex(u=>u.id===t)??-1;return rt("div",{className:"max-h-96 w-full overflow-y-auto",children:[le("h2",{className:"mb-3 text-xl font-semibold",children:c.chapters}),i?le("p",{role:"status",children:c.loading}):e?.length?rt(ki,{children:[l&&I>=0&&rt("button",{type:"button",className:"mb-3 min-h-11 rounded-lg border border-neutral-300 px-3 py-2 text-left dark:border-neutral-600",onClick:()=>a(e[I]),children:[c.resume,": ",c.chapterName," ",I+1,","," ",xe(l.time)]}),le("ul",{className:"flex w-full flex-col gap-2",children:e.map((u,m)=>{let p=u.id===t,b=m<g||P.includes(u.id);return rt("li",{className:"flex min-w-0 items-center gap-2",children:[rt("button",{type:"button","aria-current":p?"true":void 0,className:`min-h-11 min-w-0 flex-1 rounded-lg p-3 text-left hover:bg-neutral-200 dark:hover:bg-neutral-700 ${p?"bg-neutral-200 dark:bg-neutral-700":"bg-neutral-100 dark:bg-neutral-800"}`,onClick:()=>a(u),children:[rt("span",{className:"flex items-center gap-2",children:[p?le(Pi,{className:"size-4 shrink-0","aria-label":c.playing}):b?le(hi,{className:"size-4 shrink-0","aria-label":c.played}):null,le("span",{className:"min-w-0 flex-1 break-words text-sm font-medium",children:u.name}),!!u.duration&&le("span",{className:"shrink-0 text-xs tabular-nums text-neutral-600 dark:text-neutral-300",children:xe(u.duration)})]}),u.description&&le("span",{className:"mt-2 block text-xs",children:u.description})]}),r&&u.downloadableUrl&&le("a",{href:u.downloadableUrl,onClick:o,"aria-label":`${c.download} ${m+1}`,className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",children:le(bi,{className:"size-4","aria-hidden":"true"})})]},u.id)})})]}):le("p",{children:c.empty})]})}import{Fragment as Mt,jsx as C,jsxs as J}from"react/jsx-runtime";function Ce(e,...t){console.warn(e,...t)}function Nr(e){console.error(e)}var Ni=({accessToken:e,product:t,styles:n,reveal:a})=>{let r=Xe(),o=t.productType,i=St(),d=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),c=po(null),[l]=xi(),[f,P]=qe(!1),[x,I]=qe(null),{mutateAsync:g,isPending:u}=ae(F.publicApi.userPanelGetFileDetails),m=po(void 0),[p,b]=qe(null),[S,U]=qe(null),[N,ce]=qe(!1),{mutateAsync:Se,isPending:oe}=ae(F.publicApi.userPanelGetAudiobookDetails),{mutateAsync:te,isPending:fe}=ae(F.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[E,ge]=qe(null),[Z,_e]=qe(null);async function lt(){P(!1);try{let w=await g({accessId:t.accessId,accessToken:e});if(w.result.case==="success"){I(w.result.value.files);return}else P(!0),Ce("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),Ce("Kod b\u0142\u0119du: ",w.result.value)}catch(w){P(!0),Ce("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Nr("B\u0142\u0105d podczas pobierania danych:"+w)}}async function Bt(){try{let w=await Se({accessId:t.accessId,accessToken:e});if(w.result.case==="audiobook"){b(w.result.value);return}else Ce("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),Ce("Kod b\u0142\u0119du: ",w.result.value)}catch(w){Ce("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Nr("B\u0142\u0105d podczas pobierania danych:"+w)}}async function Ee(){try{let w=await te({accessId:t.accessId,accessToken:e,isBrowser:!0});if(w.result.case==="success"){U(w.result.value.audiobookDownloadDetails),ce(w.result.value.isAvailableToDownloadInMobileApp===!0);return}else Ce("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),Ce("Kod b\u0142\u0119du: ",w.result.value)}catch(w){Ce("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Nr("B\u0142\u0105d podczas pobierania danych:"+w)}}return uo(()=>{o===2&<(),o===1&&(Bt().then().catch(),Ee().then().catch())},[]),uo(()=>{if(p!=null&&S!=null){let w=p.chapters;if(!w)return;let ye=w.map(Be=>{let ue=S?.find(vt=>vt.chapterId===Be.id);if(ue!=null)return{...Be,publicUrl:ue.publicUrl,downloadableUrl:ue.downloadableUrl,duration:ue.duration}}).filter(Be=>Be!=null);ye!=null&&ye.length>0&&_e(ye)}},[p,S]),J("div",{children:[C("div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:J(L,{onClick:()=>a(),variant:"ghost",className:"min-h-11 w-fit",children:[C(wi,{className:"h-6 w-6"}),C("span",{className:"font-inter text-sm font-medium",children:r.back})]})}),J("main",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[J("header",{className:"flex min-w-0 flex-col gap-4 rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900 lg:row-span-2 lg:self-start",children:[C("img",{src:t.productImageUrl,alt:t.productName,width:384,height:384,draggable:!1,className:"aspect-square max-h-72 w-full object-contain"}),C("h2",{className:"text-2xl font-semibold",children:t.productName})]}),J("div",{className:"flex min-w-0 flex-col gap-6",children:[o===2&&J("section",{ref:l,className:"flex flex-col gap-4 rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900",children:[C("h3",{className:"text-xl font-semibold",children:r.yourFiles}),u&&C("div",{role:"status","aria-label":r.loading,children:C(ke,{})}),f&&J("div",{role:"alert",children:[C("p",{children:r.fileError}),C(L,{className:"min-h-11",onClick:lt,children:r.retry})]}),x?.length===0&&C("p",{children:r.noFiles}),x&&C("ul",{className:"flex flex-col gap-3",children:x.map((w,ye)=>J("li",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[C("span",{className:"min-w-0 break-all text-sm",children:mo(w)||`${r.file} ${ye+1}`}),J("a",{target:"_blank",rel:"noopener noreferrer",href:w,download:!0,onClick:d,className:"inline-flex min-h-11 items-center gap-2 rounded-md bg-neutral-900 px-3 py-2 text-sm text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 dark:bg-neutral-100 dark:text-neutral-900","aria-label":`${r.download}: ${mo(w)||`${r.file} ${ye+1}`}`,children:[r.download,C(Ci,{className:"size-4","aria-hidden":"true"})]})]},w))})]}),o===3&&J("section",{className:"rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900",children:[C("h3",{className:"text-lg font-semibold",children:r.ticket}),C("p",{className:"mt-2 font-medium",children:t.productName}),C("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-300",children:r.ticketInfo})]}),o===1&&C(Mt,{children:J("div",{className:"flex flex-col space-y-6 rounded-xl bg-white p-3 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:[C("h4",{className:"text-xl font-semibold",children:E?.name??"Odtwarzacz"}),E?.description&&C("p",{className:"text-sm",children:E?.description}),C(Mt,{children:oe?J("div",{className:"flex gap-2",children:[C(ke,{}),C("p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):C(Mt,{children:Z!=null?C(Mt,{children:C(lo,{ref:c,coverShownBeside:!0,chapters:Z,author:typeof p?.author=="string"?p.author:void 0,onExpiredUrl:()=>{Ee()},title:p?.name??t.productName??void 0,imageURL:p?.coverImage??t.productImageUrl??void 0,styles:n,setCurrentTimeHandler:w=>{m.current=w},uniqueProductID:t.productId,onChapterChange:w=>{ge(w)}})}):C("p",{className:"mt-2",children:"Wybierz rozdzia\u0142, kt\xF3ry ci\u0119 interesuje."})})}),J("div",{className:"rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",children:[C("p",{className:"mt-3 mb-3 text-xs",children:N?"Mo\u017Cesz s\u0142ucha\u0107 tego audiobooka w aplikacji r\xF3wnie\u017C bez dost\u0119pu do internetu.":"Mo\u017Cesz s\u0142ucha\u0107 tego audiobooka w aplikacji."}),J("div",{className:"flex gap-3",children:[C("a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:C("img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),C("a",{href:"https://play.google.com/store/apps/details?id=com.bitsnap.Bitsnap",children:C("img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),C("div",{className:"flex items-center justify-center rounded-xl bg-white p-3 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:o===1&&C(Cr,{chapters:Z,currentID:E?.id,productID:t.productId,loading:oe,downloadable:p?.isDownloadable===!0,onDownload:d,onSelect:w=>c.current?.selectChapter(w)})})]}),C("section",{className:"rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900",children:C("p",{className:"whitespace-pre-wrap text-sm text-neutral-600 dark:text-neutral-300",children:t.productDescription})})]})]})},fo=Ni;function mo(e){try{return decodeURIComponent(new URL(e,"https://bitsnap.pl").pathname.split("/").pop()||"")}catch{return""}}import{useTransport as Ii}from"@connectrpc/connect-query";import{useEffect as Si,useState as Ei}from"react";function go(e,t){let n=Ii(),[a,r]=Ei({status:"loading"});return Si(()=>{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 Po,jsx as _,jsxs as Me}from"react/jsx-runtime";var ji=Li(()=>import("./PanelModelFiles-4B2HYGIE.mjs")),Fi=({accessToken:e,projectID:t,loginURL:n,styles:a,activeScreen:r,params:o,setParams:i,openCourse:d,openMessages:c})=>{let{host:l}=ve(),{data:f,isLoading:P,error:x,refetch:I}=Ae(F.publicApi.userPanelGetProducts,{accessToken:e}),g=go(e,t),u=Hi({products:P?{status:"loading"}:x!=null?{status:"error"}:f?.result.case==="success"?{status:"ok",count:f.result.value.products.length}:f?.result.case==="failure"?{status:"failure",unauthorized:f.result.value===9}:{status:"error"},modelFiles:g});if(Ir(()=>{u.kind==="signed-out"&&(Ye(t,l),window.location.href=n)},[u.kind,t,l,n]),u.kind==="loading"||u.kind==="signed-out")return _("div",{role:"status","aria-label":Xe().loading,"aria-busy":"true",className:"grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5",children:Array.from({length:6},(S,U)=>_("div",{"aria-hidden":"true",className:"h-72 rounded-xl bg-neutral-100 motion-safe:animate-pulse dark:bg-neutral-800"},U))});let m=f&&f.result.case==="success"?f.result.value.products:[],p=g.status==="ready"?g.models:[],b=p.length>0?_(Ti,{fallback:null,children:_(ji,{accessToken:e,models:p,buttonStyle:a})}):null;return u.kind==="error"?Me(Po,{children:[_($i,{onRetry:()=>void I()}),b]}):u.kind==="empty"?_(qi,{}):_(Bi,{accessToken:e,products:m,styles:a,activeScreen:r,params:o,setParams:i,openCourse:d,openMessages:c,filesSection:b})};function Hi({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 qi(){let e=Xe();return Me("div",{className:"flex flex-col items-start gap-1","data-testid":"panel-empty",children:[_("h3",{className:"text-2xl",children:e.hello}),_("p",{className:"text-sm text-neutral-500",children:e.empty})]})}function $i({onRetry:e}){let t=A().toLowerCase().startsWith("en");return Me("div",{className:"flex flex-col items-start gap-3",role:"alert","data-testid":"panel-error",children:[_("p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:t?"Your products could not be loaded.":"Nie uda\u0142o si\u0119 wczyta\u0107 Twoich produkt\xF3w."}),_(L,{type:"button",onClick:e,className:"text-sm",children:t?"Try again":"Spr\xF3buj ponownie"})]})}var bo=Fi;function yo(e){return e.productType===5||e.productType===6}var Bi=({accessToken:e,products:t,styles:n,filesSection:a,activeScreen:r,params:o,setParams:i,openCourse:d,openMessages:c})=>{let l=Xe(),[f,P]=Ai(()=>ho(o.product,t));Ir(()=>{P(ho(o.product,t))},[o.product,t]);let x=g=>{P(g),i({product:g?Sr(g):void 0,state:"products"})};Ir(()=>{r==="products"&&f?.productType===4?d(f.accessId):r==="products"&&f&&yo(f)&&c&&c()},[r,f,d,c]);function I(g){if(yo(g)&&c){c();return}if(g.productType===4){d(g.accessId);return}x(g)}return r==="products"&&f?.productType===4?null:r==="products"&&f!=null?_(fo,{accessToken:e,product:f,styles:n,reveal:x,onOpenCourse:d}):Me(Po,{children:[_("h3",{className:"text-2xl",children:l.hello}),t.length>0&&_("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:l.intro}),_("div",{className:"mt-6 grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5",children:t.map(g=>{let[u,m,p]=g.productType===1?[l.audio,l.listen,Mi]:g.productType===4?[l.course,l.openCourse,Ri]:g.productType===5?[l.chat,l.openMessages,Oi]:g.productType===6?[l.community,l.openMessages,_i]:g.productType===3?[l.ticket,l.showTicket,Ui]:[l.files,l.downloadFiles,Di];return Me("button",{type:"button",onClick:()=>I(g),className:"flex min-h-11 min-w-0 flex-col overflow-hidden rounded-xl border border-neutral-200 bg-white text-left text-neutral-900 transition-colors hover:border-neutral-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-50 dark:hover:border-neutral-500",children:[Me("span",{className:"flex w-full flex-col gap-3 bg-neutral-100 p-3 dark:bg-neutral-800",children:[Me("span",{className:"flex w-fit items-center gap-1.5 rounded-md bg-white px-2 py-1 text-xs font-medium dark:bg-neutral-900",children:[_(p,{className:"size-4","aria-hidden":"true"}),u]}),_("img",{src:g.productImageUrl,alt:g.productName,draggable:!1,className:"aspect-square w-full object-contain"})]}),Me("span",{className:"flex flex-1 flex-col gap-3 p-3",children:[_("span",{className:"line-clamp-2 font-semibold",children:g.productName}),_("span",{className:"line-clamp-2 text-sm text-neutral-600 dark:text-neutral-300",children:Jn(g.productDescription)}),_("span",{className:"mt-auto pt-2 text-sm font-medium underline underline-offset-4",children:m})]})]},Sr(g))})}),a]})};function Sr(e){return`${pn[e.productType]?.toLowerCase()??"product"}-${e.accessId||e.productId}`}function ho(e,t){if(!e)return;let n=t.find(r=>Sr(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=zi(un,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 Ji}from"lucide-react";import{Library as Ki,MessageCircle as Gi,Receipt as Vi,Undo2 as Wi,User as Yi}from"lucide-react";var vo=[{screen:"products",label:"libraryNavLabel",icon:Ki},{screen:"messages",label:"messagesNavLabel",icon:Gi},{screen:"orders",label:"ordersNavLabel",icon:Vi},{screen:"returns",label:"returnsNavLabel",icon:Wi},{screen:"profile",label:"accountNavLabel",icon:Yi}];function ko(e){return e==="course"?"products":e==="order-details"?"orders":e==="return-details"?"returns":e}import{jsx as $e,jsxs as ht}from"react/jsx-runtime";function Er({activeScreen:e,setActiveScreen:t,setParams:n,theme:a,logout:r,email:o,projectID:i,showMessages:d=!1}){let c=pe(),{data:l}=hn(i??"",!!i);return ht("header",{className:"flex h-14 shrink-0 items-center border-b border-neutral-200 bg-white px-4 md:h-dvh md:w-56 md:flex-col md:items-stretch md:border-r md:border-b-0 md:py-5 dark:border-neutral-800 dark:bg-neutral-900",children:[ht("div",{className:"flex min-w-0 items-center gap-3 md:mb-6 md:flex-col md:items-start",children:[$e(Lt,{projectId:i,logoUrl:a?.logoURL,logoDarkUrl:a?.logoDarkURL,name:l?.name,className:"shrink-0"}),l?.name&&$e("span",{title:l.name,className:"truncate text-sm font-medium md:line-clamp-2 md:whitespace-normal",children:l.name})]}),$e("nav",{"aria-label":c.navigationLabel,className:"fixed inset-x-0 bottom-0 z-10 flex h-[calc(56px+env(safe-area-inset-bottom))] items-start justify-around border-t border-neutral-200 bg-white pb-[env(safe-area-inset-bottom)] md:static md:h-auto md:flex-1 md:flex-col md:justify-start md:gap-2 md:border-0 md:bg-transparent md:pb-0 dark:border-neutral-800 dark:bg-neutral-900",children:vo.filter(({screen:f})=>f!=="messages"||d).map(({screen:f,label:P,icon:x})=>{let I=ko(e)===f;return ht("button",{type:"button","aria-current":I?"page":void 0,onClick:()=>{t(f),n({product:void 0,state:f})},className:H("flex h-14 min-h-11 min-w-0 flex-1 flex-col items-center justify-center gap-1 px-1 text-[11px] focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-current md:h-11 md:w-full md:flex-none md:flex-row md:justify-start md:gap-3 md:rounded-md md:px-3 md:text-sm",I?"bg-neutral-100 font-semibold text-black dark:bg-neutral-800 dark:text-white":"text-neutral-600 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:bg-neutral-800"),children:[$e(x,{className:"h-5 w-5 shrink-0","aria-hidden":"true"}),$e("span",{children:c[P]})]},f)})}),ht("div",{className:"hidden border-t border-neutral-200 pt-4 md:block dark:border-neutral-800",children:[o&&$e("p",{title:o,className:"mb-3 truncate text-sm text-neutral-600 dark:text-neutral-400",children:o}),ht("button",{type:"button",onClick:r,className:"flex min-h-11 w-full items-center gap-3 rounded-md px-3 text-sm text-red-700 hover:bg-red-50 focus-visible:outline-2 focus-visible:outline-current dark:text-red-400 dark:hover:bg-neutral-800",children:[$e(Ji,{className:"h-4 w-4","aria-hidden":"true"}),c.logout]})]})]})}import{useState as Zi}from"react";import{LogOut as Qi}from"lucide-react";import{jsx as Oe,jsxs as nt}from"react/jsx-runtime";function Lr({email:e,logout:t,onLocaleChange:n}){let[a,r]=Zi(A),o=pe(a);return nt("section",{className:"w-full max-w-xl",children:[Oe("h3",{className:"text-2xl",children:o.accountNavLabel}),Oe("h4",{className:"mt-6 mb-2 text-sm font-medium text-neutral-600 dark:text-neutral-400",children:o.profileHeading}),nt("div",{className:"divide-y divide-neutral-200 rounded-lg border border-neutral-200 bg-white dark:divide-neutral-800 dark:border-neutral-800 dark:bg-neutral-900",children:[nt("div",{className:"p-4",children:[Oe("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:o.emailLabel}),Oe("p",{className:"mt-1 break-words",children:e||o.noData})]}),nt("label",{className:"flex min-h-11 flex-wrap items-center justify-between gap-3 p-4",children:[Oe("span",{children:o.languageLabel}),nt("select",{value:a.toLowerCase().startsWith("en")?"en-US":"pl-PL",onChange:i=>{dr(i.target.value),r(i.target.value),n?.()},className:"min-h-11 rounded-md border border-neutral-300 bg-white px-3 focus-visible:outline-2 focus-visible:outline-current dark:border-neutral-700 dark:bg-neutral-900",children:[Oe("option",{value:"pl-PL",children:o.polishLanguage}),Oe("option",{value:"en-US",children:o.englishLanguage})]})]})]}),nt("button",{type:"button",onClick:t,className:"mt-6 flex min-h-11 w-full items-center gap-3 rounded-lg border border-neutral-200 bg-white px-4 py-3 text-red-700 hover:bg-red-50 focus-visible:outline-2 focus-visible:outline-current dark:border-neutral-800 dark:bg-neutral-900 dark:text-red-400 dark:hover:bg-neutral-800",children:[Oe(Qi,{className:"h-5 w-5","aria-hidden":"true"}),o.logout]})]})}import{lazy as Xi,Suspense as es}from"react";import{jsx as bt}from"react/jsx-runtime";var ts=Xi(()=>import("./course.mjs").then(e=>({default:e.PanelCourse})));function Tr(e){return bt(es,{fallback:bt("div",{className:"flex items-center gap-2 p-2",role:"status",children:bt(ke,{})}),children:bt("div",{className:"[--course-mobile-bottom:calc(56px+env(safe-area-inset-bottom))] md:[--course-mobile-bottom:0px]",children:bt(ts,{...e})})})}import{lazy as rs,Suspense as ns}from"react";import{jsx as Ot}from"react/jsx-runtime";var os=rs(()=>import("./chat.mjs").then(e=>({default:e.PanelMessages})));function Ar(e){return Ot(ns,{fallback:Ot("div",{className:"flex items-center gap-2 p-2",role:"status",children:Ot(ke,{})}),children:Ot(os,{...e})})}function as(e,t){return!!t||e.some(n=>n.productType===5||n.productType===6)}function xo(e){let{data:t}=Ae(F.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:as(a,r),products:a,chatApiUrl:r}}import{AlertCircle as So,CheckCircle2 as wo,ChevronLeft as is,Loader2 as Dr,Lock as Co,Package as ss,Truck as Eo}from"lucide-react";import{useEffect as ls,useState as Rr}from"react";import{Fragment as Lo,jsx as y,jsxs as v}from"react/jsx-runtime";function ds({status:e}){let t={created:{color:"bg-neutral-100 text-neutral-700",icon:null},paid:{color:"bg-green-100 text-green-700",icon:wo},completed:{color:"bg-blue-100 text-blue-700",icon:wo},canceled:{color:"bg-red-100 text-red-700",icon:So},sent:{color:"bg-purple-100 text-purple-700",icon:Eo},processing:{color:"bg-yellow-100 text-yellow-700",icon:Dr}},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 v("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 cs({orderID:e,email:t}){let[n,a]=Rr(""),r=ae(F.publicApi.addPublicOrderComment);return v("form",{onSubmit:async i=>{if(i.preventDefault(),!!n.trim())try{await r.mutateAsync({projectId:"",orderId:e,message:n.trim(),accessToken:t}),a("")}catch(d){console.error("Failed to add comment:",d)}},className:"mt-4 space-y-2",children:[y(We,{htmlFor:"comment",children:"Dodaj komentarz"}),y(In,{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?v(Lo,{children:[y(Dr,{className:"mr-2 h-4 w-4 animate-spin"}),"Wysy\u0142anie..."]}):"Dodaj komentarz"})]})}function No(e){return e?new Date(Number(e.seconds)*1e3).toLocaleDateString("pl-PL",{year:"numeric",month:"long",day:"numeric"}):"N/A"}function Io(e,t){return new Intl.NumberFormat("pl-PL",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function us({orderID:e,initialEmail:t,onBack:n,accessToken:a,analytics:r}){let{theme:o,projectID:i}=ve(),d=Ve(i,r,"order"),[c,l]=Rr(t||""),[f,P]=Rr(!1),{data:x,isLoading:I,error:g,refetch:u}=Ae(F.publicApi.getPublicOrderDetails,{projectId:i??"",orderId:e,email:c||void 0,accessToken:a},{enabled:!!e}),m=x?.result.case==="order"?x.result.value:null,p=m?.isVerified??!1,b=m!=null;ls(()=>{b&&d.track("panel_order_viewed",{},{order_ref:null})},[d,b]);let S=()=>{u(),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 I?y("div",{className:"flex min-h-screen items-center justify-center",children:v("div",{className:"text-center",children:[y(Dr,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),y("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):g||!m?y("div",{className:"flex min-h-screen items-center justify-center",children:y(Re,{className:"w-full max-w-md",children:y(De,{className:"pt-6",children:v("div",{className:"text-center",children:[y(So,{className:"mx-auto h-12 w-12 text-red-500"}),y("h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),y("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):y("div",{className:"w-full bg-white py-8 dark:bg-black",style:U,children:v("div",{className:"w-full px-4",children:[n&&v(L,{onClick:n,variant:"ghost",className:"mb-4 w-fit",children:[y(is,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),v("div",{className:"mb-6 flex items-center gap-4",children:[o?.logoURL&&v(Lo,{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"})]}),v("div",{children:[y("h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),v("p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",m.orderId]})]})]}),v(Re,{className:"mb-6",children:[y(je,{children:v(Fe,{className:"flex items-center",children:[y(ss,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),v(De,{className:"space-y-6",children:[v("div",{children:[v("div",{className:"flex items-center gap-2",children:[y(ds,{status:m.status}),m.processingStatus&&v("span",{className:"text-sm text-neutral-600",children:["\xB7 ",m.processingStatus]})]}),v("p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",No(m.createdAt)]})]}),v("div",{className:"border-t pt-4",children:[y("h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),v("div",{className:"space-y-2",children:[v("div",{children:[y("span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",y("span",{className:p?"":"text-neutral-500",children:m.customerName})]}),v("div",{children:[y("span",{className:"font-medium",children:"Email:"})," ",y("span",{className:p?"":"text-neutral-500",children:m.customerEmail})]}),m.customerPhone&&v("div",{children:[y("span",{className:"font-medium",children:"Telefon:"})," ",y("span",{className:p?"":"text-neutral-500",children:m.customerPhone})]})]})]}),!p&&y("div",{className:"border-t pt-4",children:v(L,{onClick:()=>P(!0),variant:"outline",className:"w-full",children:[y(Co,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),v(Re,{className:"mb-6",children:[y(je,{children:y(Fe,{children:"Produkty"})}),v(De,{className:"space-y-6",children:[y("div",{className:"space-y-4",children:m.items.map((N,ce)=>v("div",{className:"flex items-center gap-4",children:[N.imageUrl&&y("img",{src:N.imageUrl,alt:N.name,className:"h-16 w-16 rounded object-cover"}),v("div",{className:"flex-1",children:[y("p",{className:"font-medium",children:N.name}),v("p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",N.quantity]})]}),y("div",{className:"text-right",children:y("p",{className:"font-medium",children:Io(Number(N.price),N.currency)})})]},ce))}),(m.deliveryAddress||m.deliveryMethod)&&v("div",{className:"border-t pt-4",children:[v("h3",{className:"mb-3 flex items-center font-semibold",children:[y(Eo,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),v("div",{className:"space-y-2",children:[m.deliveryAddress&&v("div",{children:[y("span",{className:"font-medium",children:"Adres:"})," ",y("span",{className:p?"":"text-neutral-500",children:m.deliveryAddress})]}),m.deliveryMethod&&v("div",{children:[y("span",{className:"font-medium",children:"Metoda:"})," ",m.deliveryMethod]}),m.trackingNumber&&p&&v("div",{children:[y("span",{className:"font-medium",children:"Tracking:"})," ",m.trackingNumber]})]})]}),y("div",{className:"border-t pt-4",children:v("div",{className:"flex justify-between text-lg font-bold",children:[y("span",{children:"Suma:"}),y("span",{children:Io(Number(m.totalAmount),m.currency)})]})})]})]}),v(Re,{children:[y(je,{children:v(Fe,{children:["Komentarze ",m.commentCount>0&&`(${m.commentCount})`]})}),v(De,{children:[m.comments.length>0?y("div",{className:"space-y-4",children:m.comments.map(N=>v("div",{className:"border-b pb-4 last:border-b-0",children:[v("div",{className:"mb-1 flex items-center gap-2",children:[y("span",{className:"font-medium",children:N.authorName||"System"}),y("span",{className:"text-xs text-neutral-500",children:No(N.createdAt)}),N.authorType==="admin"&&y("span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),y("p",{className:p?"":"text-neutral-500",children:N.message})]},N.id))}):y("p",{className:"text-neutral-600",children:"Brak komentarzy."}),p?y(cs,{orderID:m.orderId,email:c}):y("div",{className:"mt-4",children:v(L,{onClick:()=>P(!0),variant:"outline",className:"w-full",children:[y(Co,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),f&&y("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:v(Re,{className:"w-full max-w-md",children:[y(je,{children:y(Fe,{children:"Zweryfikuj sw\xF3j email"})}),v(De,{className:"space-y-4",children:[y("p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),v("div",{className:"space-y-2",children:[y(We,{htmlFor:"verify-email",children:"Adres email"}),y(Tt,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:c,onChange:N=>l(N.target.value)})]}),v("div",{className:"flex gap-2",children:[y(L,{variant:"outline",onClick:()=>P(!1),className:"flex-1",children:"Anuluj"}),y(L,{onClick:S,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function ps(e){return y(us,{...e})}var Mr=ps;import{jsx as de,jsxs as Ao}from"react/jsx-runtime";var fs=({returnsAppearance:e,returnsTexts:t,analytics:n}={})=>{let{projectID:a,theme:r,loginURL:o,host:i}=ve(),[,d]=To(0),c=Ve(a,n,"panel"),l=mt(a,i),f=Cn(a,i),{mutateAsync:P}=ae(F.publicApi.userPanelLogout);async function x(){l&&await P({accessToken:l}),typeof window<"u"&&(Ye(a,i),window.location.reload())}let[I]=ms(),g=E=>["products","notifications","profile","plans","orders","order-details","returns","return-details","course","messages"].includes(E),[u,m]=Kn({product:void 0,state:"products",orderId:void 0,returnId:void 0,course:void 0,item:void 0,chatProject:void 0,thread:void 0,channel:void 0}),[p,b]=To(g(u.state)?u.state:"products"),S=E=>{m({state:"order-details",orderId:E}),b("order-details")},U=()=>{m({state:"orders",orderId:void 0}),b("orders")},N=E=>m({orderId:void 0,returnId:void 0,course:void 0,item:void 0,chatProject:void 0,thread:void 0,channel:void 0,...E}),ce=E=>{m({state:"course",course:E,item:void 0,product:void 0}),b("course")},Se=()=>{m({state:"products",course:void 0,item:void 0,product:void 0}),b("products")},oe=()=>{m({state:"messages",product:void 0,chatProject:void 0,thread:void 0,channel:void 0}),b("messages")},te=xo(l);Ut(()=>{g(u.state)&&(u.state==="course"||p==="course"||u.state==="messages"||p==="messages")&&b(u.state)},[u.state]);let fe={"--button-background-color":r?.colors?.brand??"#000000","--button-background-color-dark":r?.colors?.brandDark??"#ffffff","--button-text-color":r?.colors?.brandDark??"#000000","--button-text-color-dark":r?.colors?.brand??"#000000"};return Ut(()=>{if(l==null||l.length===0){window.location.href=o??"/panel/login";return}},[]),Ut(()=>{if(l==null||l.length===0){window.location.href=o??"/panel/login";return}},[p]),Ut(()=>{if(typeof window>"u"||window.parent!==window||!l)return;let E=gt(window.location.search);E&&yt(E);let ge=E??Ze();ge&&(window.location.href=Qe(ge,l))},[l]),de(It,{value:c,children:Ao("div",{ref:I,className:"font-inter relative flex h-dvh w-full flex-col bg-beige-100 text-black dark:bg-black dark:text-white md:flex-row",children:[de(Er,{activeScreen:p,setActiveScreen:b,setParams:N,styles:fe,theme:r,logout:x,email:f,projectID:a,showMessages:te.visible||p==="messages"}),Ao("main",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto w-full p-5 pb-[calc(76px+env(safe-area-inset-bottom))] md:pb-5",children:[p==="products"&&de(bo,{projectID:a??"",accessToken:l,loginURL:o??"/panel/login",styles:fe,activeScreen:p,params:u,setParams:m,openCourse:ce,openMessages:oe}),p==="messages"&&l&&de(Ar,{accessToken:l,products:te.products,chatApiUrl:te.chatApiUrl,projectID:a,host:i,selection:{chatProject:u.chatProject,thread:u.thread,channel:u.channel},onSelect:E=>m({chatProject:E.chatProject,thread:E.thread,channel:E.channel})}),p==="course"&&u.course&&l&&de(Tr,{accessId:u.course,accessToken:l,theme:r,itemId:u.item,onItemChange:E=>m({item:E}),onBack:Se}),p==="notifications"&&de(yr,{}),p==="plans"&&de(hr,{projectID:a??""}),p==="orders"&&de(Wn,{projectID:a??"",accessToken:l??"",openOrderDetails:S}),p==="order-details"&&u.orderId&&de(Mr,{orderID:u.orderId,onBack:U}),(p==="returns"||p==="return-details")&&l&&de(Pr,{projectID:a??"",host:i,accessToken:l,loginURL:o??"/panel/login",appearance:Gn(e,r?.colors?.brand),texts:t,screen:p,params:u,setParams:m,setActiveScreen:b}),p==="profile"&&de(Lr,{email:f,logout:x,onLocaleChange:()=>d(E=>E+1)})]})]})})},gs=fs;import{create as Ne}from"@bufbuild/protobuf";import{QueryClient as Ds,QueryClientProvider as Ms}from"@tanstack/react-query";import{createContext as Os,useContext as Us,useEffect as Ko,useState as _s}from"react";import{createClient as ys}from"@connectrpc/connect";import{createConnectTransport as hs}from"@connectrpc/connect-web";var me;(a=>{function e(r){return ys(mn,n(r))}a.get=e;let t=new Map;function n(r){let o=t.get(r);return o==null&&(o=hs({useBinaryFormat:!0,baseUrl:r+"/api/rpc",interceptors:[cn]}),t.set(r,o)),o}})(me||={});import R from"zod";import ee from"zod";function j(e,t=2){return+(Math.round(+(e+"e+"+t))+"e-"+t)}function Ro(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 gp=ee.object({event:ee.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:ee.string().optional(),value:ee.number().optional(),currency:ee.string().optional(),content_name:ee.string().optional(),items:ee.array(ee.object({id:ee.string(),name:ee.string(),price:ee.number().default(0),currency:ee.string().default("PLN"),quantity:ee.number().default(1)})).optional()});function Or(e){typeof window>"u"||(bs(e),vs(e),ks(e))}function bs(e){try{typeof window.dataLayer>"u"&&(window.dataLayer=[]);let t=Ps(e);window.dataLayer.push(t)}catch(t){console.warn("cannot send google analytics event",t)}}function Ps(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:j((o.price||0)/100,2),quantity:o.quantity||1})),a={currency:e.currency||"PLN",value:j(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 vs(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 ks(e){try{if(typeof window.ttq>"u")return;let t=xs(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 xs(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:j((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:j(t/100,2)});let a={currency:e.currency||"PLN",value:j(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 Do(e){let{items:t,googlePayConfig:n,checkout:a,result:r,cartRequiresShipping:o}=e,i=e.locale??A();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+` - ${Ro(l.amount,r.currency)}`,description:l.description??""})),defaultSelectedOptionId:r.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:n.merchantId+"",merchantName:n.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:Te("paymentForCart",i,e.texts),totalPrice:`${j(r.totalAmount/100,2)}`,currencyCode:r.currency,countryCode:r.country,checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",displayItems:ws(t,r.methods,r.selectedDeliveryMethod??(r.methods.length>0?r.methods[0].id:void 0),a.couponCode,r.couponValue,Te("coupon",i,e.texts))}}}function ws(e,t,n,a,r,o="Coupon"){let i=[],d=0;for(let l of e){if(l.details==null)continue;let f=l.details.pricing?.effectivePrice??l.details.price;d+=f*l.quantity,i.push({label:l.details.name+" x "+l.quantity,price:`${j(f/100,2)}`,type:"LINE_ITEM",status:"FINAL"})}let c=t.find(l=>l.id===n);return c!=null&&i.push({label:c.name,price:`${j(c.amount/100,2)}`,type:"SHIPPING_OPTION",status:"FINAL"}),a!=null&&r!=null&&i.push({label:`${o} ${a}`,price:`${j(r/100,2)}`,type:"DISCOUNT",status:"FINAL"}),d>0&&i.push({label:"Subtotal",price:`${j(d/100,2)}`,type:"SUBTOTAL",status:"FINAL"}),i}function ot(e,t){return`${Q}/api/integrations/${e}/public-commerce${t}`}function Ue(e){return typeof e=="object"&&e!=null&&"ERR"in e}function B(e,t,n){return{ERR:!0,error:e,type:t,data:n}}function Mo(e,t){return t?.find(n=>n.id===e||(n.variants?.some(a=>a.id===e)??!1))}function Oo(e,t){let n=new Set(t.map(a=>a.productID));return Array.from(new Set(e.filter(a=>!n.has(a))))}function Uo(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 Cs}from"zustand";var at=Cs(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 Ns,useContext as Ur,useMemo as _o}from"react";import{jsx as Is}from"react/jsx-runtime";var _t=Ns({});function Tp({texts:e,locale:t,children:n}){let a=_o(()=>({texts:e,locale:t}),[e,t]);return Is(_t.Provider,{value:a,children:n})}function zo(){return Ur(_t)}function Ap(e){let{texts:t,locale:n}=Ur(_t);return Te(e,n??A(),t)}function Rp(){let{texts:e,locale:t}=Ur(_t),n=t??A();return _o(()=>a=>Te(a,n,e),[n,e])}var zr="bitsnap-pending-order";function Ho(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 Ss=60*1e3;function qo(e,t=Date.now,n=Ss){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 Es(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 Ls(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 Ts(e,t=Date.now(),n={}){if(Ls(e.url))return;let a=Es(e.url),r=jo(e.orderId)??a?.orderId,o=jo(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 Op(e,t={}){let n=Ts(e,t.now,t);return n!=null&&As(n,t.storage)}function jo(e){return e!=null&&e.length>0?e:void 0}function zt(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function As(e,t=zt()){try{return t?.setItem(zr,JSON.stringify(e)),t!=null}catch{return!1}}function Fo(e=zt()){try{let t=e?.getItem(zr);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(c=>typeof c?.id=="string"&&typeof c.quantity=="number"):[],ts:i}}}catch{}_r(e)}function _r(e=zt()){try{e?.removeItem(zr)}catch{}}function $o(e){let t=e.details?.status??Rs(e.details?.$unknown);return t==="created"||t==="placed"||t==="paid"||t==="canceled"?t:"unknown"}function Rs(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 Bo(e){let t=e.storage??zt(),n=Fo(t);if(n==null)return"none";if((e.now??Date.now)()-n.ts>864e5)return _r(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=Fo(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 _r(t),"paid"}return"pending"}import{Fragment as Zs,jsx as Fr}from"react/jsx-runtime";var zs="__m_a",Zo=Os(void 0),qr=void 0;function sm(e){sr({projectID:e}),qr=e,typeof window<"u"&&ut([window.location.origin])}function st(){return qr??document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-id")??void 0}function js(){return document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-custom-host")??void 0}var Fs=({children:e,locale:t})=>{let[n]=_s(()=>new Ds),a=zo();Ko(()=>{Ie()},[]);let r=st();if(Ko(()=>{if(r==null)return;let i=()=>{$s(r).then(c=>{c==="paid"&&n.invalidateQueries({queryKey:["cart"]})})},d=()=>{document.visibilityState==="visible"&&i()};return i(),window.addEventListener("pageshow",i),document.addEventListener("visibilitychange",d),()=>{window.removeEventListener("pageshow",i),document.removeEventListener("visibilitychange",d)}},[r,n]),r==null)return Fr(Zs,{});let o=Kr(r,t??a.locale,a.texts);return Fr(Ms,{client:n,children:Fr(Zo.Provider,{value:o,children:e})})},jr,Hs=qo(async e=>$o(await me.get(Q).getOrder({id:e.orderId,projectId:e.projectId})));function lm(){let{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:a}=T()??qt;return{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:a}}function dm(){return(T()?.products??[]).map(e=>({id:e.id,quantity:e.quantity}))}function qs(e){let t=T();V({...t,products:Ho(t?.products??[],e)}),Ie()}function $s(e){return jr??=Bo({projectId:e,fetchStatus:Hs,removeLines:qs}).catch(t=>{console.warn("cannot check the pending order",t)}).finally(()=>{jr=void 0}),jr}var it=async(e,t)=>{let n=[];t?.items!=null&&t.items.length>0?n=t.items:n=T()?.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??A());let o;try{let i=await fetch(nr(ot(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=Mo(i.productID,o.result);return d==null?[]:[{...i,details:Js(i.productID,d),catalogProductID:d.id}]})},cm=()=>{let e=Us(Zo);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},um=Fs,Bs=R.object({isAvailable:R.boolean(),merchantId:R.string(),merchantName:R.string(),gateway:R.string(),gatewayId:R.string()}),Ks=R.object({id:R.string(),productID:R.string(),quantity:R.number(),priceVersion:R.string().optional(),amount:R.number().int().nonnegative().optional(),metadata:R.record(R.string(),R.string().optional()).optional(),url:R.string().optional()}),Gs=R.object({country:R.string().optional(),couponCode:R.string().optional(),selectedDeliveryMethod:R.string().optional(),postalCode:R.string().optional(),email:R.string().optional(),products:R.array(Ks).optional(),googlePayConfig:Bs.optional()}),qt={country:void 0,couponCode:void 0,email:void 0,selectedDeliveryMethod:void 0,postalCode:void 0,products:[],googlePayConfig:void 0},Br="checkout";function Vs(){return typeof localStorage>"u"?[]:(T().products??[]).map(e=>({...e}))}function pm(){return Vs().map(e=>`${e.productID}:${e.quantity}`).sort().join(",")}function mm(e){let t=T();if(!(t.products==null||t.products.length===0))return{items:t.products.map(n=>({id:n.productID,quantity:n.quantity,...n.priceVersion!=null?{priceVersion:n.priceVersion}:{},...n.amount!=null?{amount:n.amount}:{}})),...t.country!=null?{countries:[t.country]}:{},...t.couponCode!=null?{couponCode:t.couponCode}:{},...t.selectedDeliveryMethod!=null?{deliveryMethod:t.selectedDeliveryMethod}:{},locale:e}}function fm(e){let t=T(),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}:{}}}),V(t),Ie()}function gm(e){let t=new Map;for(let r of e)t.set(r.id,(t.get(r.id)??0)+r.quantity);let n=T(),a=(n.products??[]).flatMap(r=>{let o=t.get(r.productID);return o==null?[r]:r.quantity<=o?[]:[{...r,quantity:r.quantity-o}]});V({...n,products:a}),Ie()}function ym(e){let t=T();t.products=t.products??[];for(let n of e)t.products.push({id:Math.random().toString(36).substring(7),productID:n.id,quantity:n.quantity});V(t),Ie()}function T(){try{let e=localStorage.getItem(Br);return e==null?qt:Gs.parse(JSON.parse(e))}catch{return qt}}async function Go(e,t){let n=await it(e,{items:t.map((o,i)=>({...o,id:`price-check-${i}`}))});if(Ue(n))return n;let a=Oo(t.map(o=>o.productID),n);if(a.length>0)return B("item-ids-not-found","notFound",a);let r=T();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:Uo(o.url,typeof window<"u"?window.location.href:void 0)}))),Ws(t,n),Or({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"}))}),V(r),Ie()}function Ws(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??gn()).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 Vo(e){let t=T(),n={...t,products:t?.products?.filter(a=>!e.includes(a.productID)&&!e.includes(a.id))};Or({event:"removeFromCart",items:e.map(a=>({id:a,name:"",price:0,quantity:1,currency:"PLN"}))}),V(n),Ie()}function V(e){localStorage.setItem(Br,JSON.stringify(e)),Xo()}var Ft=new Set,Qo=0,jt=!1;function Wo(e){e.key===Br&&Xo()}function hm(e){return Ft.add(e),!jt&&typeof window<"u"&&(window.addEventListener("storage",Wo),jt=!0),()=>{Ft.delete(e),Ft.size===0&&jt&&(window.removeEventListener("storage",Wo),jt=!1)}}function bm(){return Qo}function Xo(){Qo+=1;for(let e of Ft)try{e()}catch{}}function Yo(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 Kr=(e,t=A(),n)=>{let a=js();return a!=null&&yn(a),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await me.get(Q).isOneClickPaymentAvailable({projectId:e})).applePay}catch(r){return console.error("Error checking if Apple Pay is available",r),!1}},async getGooglePayConfiguration(r){if(typeof window>"u"||typeof document>"u")return{isAvailable:!1};try{let o=await Ys(e);if(o?.isAvailable!=!0)return{isAvailable:!1};let i=T();if(i==null)return console.log("checkout is null"),{isAvailable:!1};let d=await it(e,{locale:t,items:r.items.map(P=>({id:Math.random().toString(36).substring(7),quantity:P.quantity,metadata:P.metadata,productID:P.productID}))});if(Ue(d))return{isAvailable:!1};let c=await me.get(Q).getPreOrderDetails({items:d.map(P=>Ne(Nt,{id:P.productID,quantity:P.quantity})),projectId:e,postCode:i.postalCode,couponCode:i.couponCode,countryCode:i.country,selectedDeliveryMethod:i.selectedDeliveryMethod});if(c.totalAmount==null)return{isAvailable:!1};let l=d.find(P=>P.details?.isDeliverable==!0)!=null,f=await Do({items:d,googlePayConfig:o,checkout:i,cartRequiresShipping:l,result:c,locale:t,texts:n});return f==null?{isAvailable:!1}:{isAvailable:!0,config:f}}catch(o){return console.error("Error resolving Google Pay configuration",o),{isAvailable:!1}}},async clearCart(){let r=structuredClone(qt);r.country=T()?.country,V(r),Ie()},async getAvailableCountries(){let r=await fetch(nr(ot(e,"/countries")),{method:"GET"});if(r.status!=200)return[];try{return R.array(R.object({name:R.string(),code:R.string()})).parse(await r.json())}catch(o){return B(o.toString(),"internal")}},async getCountry(){let r=T()?.country;if(r==null){r="PL";let o=T();o.country=r,V(o)}return r},async getNumberOfElementsInCart(){return T()?.products?.reduce((r,o)=>r+o.quantity,0)??0},async getProducts(){return await it(e,{locale:t})},async removeProductFromCart(r){return Vo([r.id])},async setCountry(r){let o=T();o.country=r,V(o)},async setCouponCodeIfPossible(r){let o=T();o.couponCode=r,V(o)},async setPostalCode(r){let o=T();o.postalCode=r,V(o)},async setDeliveryMethod(r){let o=T();o.selectedDeliveryMethod=r,V(o)},async setEmail(r){let o=T();o.email=r,V(o)},async addProduct(r){return await Go(e,[r])},async updateQuantity(r){let o=T();o.products=o.products?.map(i=>(i.id===r.id&&(i.quantity=r.quantity),i)),V(o),Ie()},async getPaymentMethodChoice(){let r=Yo(T(),t);return r==null?null:Jo(r)},async redirectToNextStep(r){let o=Yo(T(),t);if(o==null)return B("cart-is-empty","badInput");r?.paymentMethod!=null&&(o.paymentMethod=r.paymentMethod);let i=await Hr(o);return Ue(i)?(console.warn("cannot create payment URL",i.error),i):{url:i.url,...i.orderId!=null?{orderId:i.orderId}:{},...i.projectId!=null?{projectId:i.projectId}:{}}},async justRedirectToPayment(r){let 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=$r(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:zs,name:"",required:!0,answer:!0}]);let i=await Hr(o);return Ue(i)?i:{url:i.url}},async getApplePayPreview(r){let o=T();try{let i=await me.get(Q).getPreOrderDetails({items:r.items.map(d=>Ne(Nt,{id:d.productID,quantity:d.quantity})),projectId:e,postCode: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:`${j(i.totalAmount/100,2)}`}}catch(i){return console.warn("cannot load the Apple Pay preview",i),B("pre-order-unavailable","internal")}},async completeApplePayPayment(r){let o=T();if(o==null)return B("Checkout not found");let i=await it(e,{locale:t});if(Ue(i))return i;try{let d=r.shippingContact?.givenName;r.shippingContact?.familyName!=null?d+=" "+r.shippingContact?.familyName:r.billingContact?.familyName!=null&&(d+=" "+r.billingContact?.familyName);let c={},l=Ht();l!=null&&(c.ref=l);let f=await me.get(Q).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(r.token.paymentData),paymentMethod:JSON.stringify(r.token.paymentMethod),transactionIdentifier:r.token.transactionIdentifier,order:Ne(ir,{items:i.map(P=>({id:P.productID,quantity:P.quantity})),couponCode: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:Ne(or,{line1:r.shippingContact?.addressLines?.[0]??"",city:r.shippingContact?.locality??"",country:r.shippingContact?.countryCode??"",zipCode:r.shippingContact?.postalCode??"",name:d}),billingAddress:Ne(ar,{name:r.billingContact?.givenName??" "+(r.billingContact?.familyName??""),line1:r.billingContact?.addressLines?.[0]??"",city:r.billingContact?.locality??"",country:r.billingContact?.countryCode??"",zipCode:r.billingContact?.postalCode??""}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:f.isSuccess,redirectURL:f.redirectUrl}}catch(d){return console.error(d),B("Failed to authorize payment")}},async completeGooglePayPayment(r){let o=T();if(o==null)return B("Checkout not found");let i=await it(e,{locale:t});if(Ue(i))return i;try{let d=r.paymentData.shippingAddress?.name,c={},l=Ht();l!=null&&(c.ref=l);let f=await me.get(Q).authorizeOneClickPayment({gateway:1,paymentData:r.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:r.paymentData.paymentMethodData.type,transactionIdentifier:"",order:Ne(ir,{items:i.map(P=>({id:P.productID,quantity:P.quantity})),couponCode: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:Ne(or,{line1:r.paymentData.shippingAddress?.address1??"",city:r.paymentData.shippingAddress?.locality??"",country:r.paymentData.shippingAddress?.countryCode??"",zipCode:r.paymentData.shippingAddress?.postalCode??"",name:d}),billingAddress:Ne(ar,{name:r.paymentData.paymentMethodData.info?.billingAddress?.name,line1:r.paymentData.paymentMethodData.info?.billingAddress?.address1??"",city:r.paymentData.paymentMethodData.info?.billingAddress?.locality??"",country:r.paymentData.paymentMethodData.info?.billingAddress?.countryCode??"",zipCode:r.paymentData.paymentMethodData.info?.billingAddress?.postalCode??""}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:f.isSuccess,redirectURL:f.redirectUrl}}catch(d){return console.error(d),B("Failed to authorize payment")}return{isSuccess:!0}},async getApplePayPaymentRequest(r){let o=T();if(o==null)return B("Checkout not found");r&&r.expectedItems!=null&&r.expectedItems.length>0&&(o.products&&Vo(o.products.map(l=>l.productID)),await Go(e,r.expectedItems));let i=await it(e,{locale:t});if(Ue(i))return i;let d=await me.get(Q).getPreOrderDetails({items:i.map(l=>Ne(Nt,{id:l.productID,quantity:l.quantity})),projectId:e,postCode:o.postalCode,couponCode:o.couponCode,countryCode:o.country,selectedDeliveryMethod:o.selectedDeliveryMethod}),c=i.map(l=>({amount:`${j(l.quantity*(l.details?.pricing?.effectivePrice??l.details?.price??0)/100,2)}`,label:l.details?.name+" - "+l.quantity,type:"final"}));if(d.selectedDeliveryMethod!=null){let l=d.methods.find(f=>f.id==d.selectedDeliveryMethod);l!=null&&c.push({amount:`${j(l.amount/100,2)}`,label:l.name,type:"final"})}return d.couponCode!=null&&d.couponValue!=null&&c.push({amount:`-${j(d.couponValue/100,2)}`,label:d.couponCode,type:"final"}),{countryCode:d.country||o.country||"PL",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],total:{amount:`${j((d.totalAmount??0)/100,2)}`,label:Te("paymentForCart",t,n),type:"final"},shippingMethods:d.methods.map(l=>({amount:`${j(l.amount/100,2)}`,detail:l.description??"",identifier:l.id,label:l.name,dateComponentsRange:{startDateComponents:{days:l.minDays??1,hours:0,months:0,years:0},endDateComponents:{days:l.maxDays??14,hours:0,months:0,years:0}}})),lineItems:c,currencyCode:d.currency||i[0]?.details?.currency||"PLN"}}}};async function Ys(e){let t=T();if(t.googlePayConfig?.isAvailable!=!0){let n=await me.get(Q).isOneClickPaymentAvailable({projectId:e});n.googlePay==!0&&n.googlePayConfig!=null?t.googlePayConfig={isAvailable:!0,gateway:n.googlePayConfig.gateway,gatewayId:n.googlePayConfig.gatewayMerchantId,merchantName:n.googlePayConfig.merchantName,merchantId:n.googlePayConfig.merchantId}:t.googlePayConfig={isAvailable:!1,gateway:"",gatewayId:"",merchantName:"",merchantId:""}}return V(t),t.googlePayConfig}function Js(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=T(),t=0;if(e==null){at.setState(n=>({...n,numberOfProductsInCart:t}));return}t=e.products?.reduce((n,a)=>n+a.quantity,0)??0,at.setState(n=>({...n,numberOfProductsInCart:t}))}var Qs=200,Xs="item-ids-not-found",Pt="internal-error",ea={"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"},el=new Set(["internal","invalid-request"]),tl=new Set(["product-not-available","product-not-found"]);function rl(e){return typeof e=="string"&&Object.hasOwn(ea,e)?ea[e]:void 0}function nl(e){return/<\/?[a-z!?][^>]*>/i.test(e)}function ol(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 al(e){return/Error:/.test(e)||/\n\s+at /.test(e)}function Gr(e){let t=e.trim();if(!(t.length===0||t.length>Qs||/[\r\n]/.test(t)||nl(t)||ol(t)||al(t)))return t}var il=3;function $t(e,t=0){if(typeof e=="object"&&e!=null){if(Array.isArray(e)||t>=il)return{};let n=e,a=$t(n.error,t+1);if(a.message==null&&n.message!=null){let r=$t(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?$t(n,t+1):{}}catch{}return{message:Gr(e)}}function sl(e){let t;try{t=JSON.parse(e)}catch{return{code:Pt,message:Gr(e)}}if(typeof t=="string")return{code:Pt,message:Gr(t)};if(typeof t!="object"||t==null)return{code:Pt};let n=t,{message:a,code:r}=$t(n.error),o={code:typeof n.code=="string"&&n.code.length>0?n.code:r??Pt,message:a};return Array.isArray(n.itemIds)&&(o.itemIds=n.itemIds.filter(i=>typeof i=="string")),o}function Vr(e,t){let{code:n,message:a,itemIds:r}=sl(t),o=r!=null&&r.length>0;if(o&&(n===Pt||tl.has(n)))return B(Xs,"badInput",r);let i={message:a};return o&&(i.itemIds=r),B(n,e>=500?"internal":"badInput",i)}function wm(e,t){let n=rl(e.error);if(n!=null)return t(n);if(e.type==="internal"||typeof e.error=="string"&&el.has(e.error))return t("checkoutFailed");let a=e.data?.message;return typeof a=="string"&&a.length>0?a:t("checkoutFailed")}var ll=["online","manual","cod"],dl=["bankTransfer","blik"];function ta(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 cl(e){if(typeof e!="object"||e==null)return null;let t=e.choice;if(typeof t!="object"||t==null)return null;let n=ta(t.methods,ll);return n.length<2?null:{methods:n,manualAccountTypes:ta(t.manualAccountTypes,dl)}}function Nm(e){if(e==null)return null;let t=e.methods.filter(n=>n!=="cod");return t.length<2?null:{...e,methods:t}}function Im(e,t){return t!=null&&e.methods.includes(t)?t:e.methods[0]}function Sm(e){let t=e.includes("bankTransfer"),n=e.includes("blik");return n&&!t?"paymentMethodManualBlik":t&&!n?"paymentMethodManualTransfer":"paymentMethodManualBoth"}async function ra(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?cl(await o.json()):null}catch{return null}finally{clearTimeout(r)}}var ul;(a=>{async function e(r,o=1,i,d){let c=st();if(c==null)throw new Error("No project ID found");let f=await Kr(c).addProduct({productID:r,quantity:o,metadata:i,...d});if(f!=null)return f}a.addProductToCart=e;function t(){at.setState({isCartVisible:!0})}a.showCart=t;function n(){at.setState({isCartVisible:!1})}a.hideCart=n})(ul||={});async function na(e){try{return await e.text()}catch{return""}}function oa(e,t){return t=$r(t),t.locale??=A(),{headers:{...rr,...lr(e),"Content-Type":"application/json"},body:JSON.stringify(t)}}async function Jo(e){let t=st();return t==null?null:ra(ot(t,"/payment-methods"),oa(t,e))}async function Hr(e){let t=st();if(t==null)throw new Error("No project ID found");let n=await fetch(ot(t,"/buy"),{method:"POST",...oa(t,e)});if(n.status!=200){let r=Vr(n.status,await na(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 _m(e){let t=st();if(t==null)throw new Error("No project ID found");let n={...rr,...lr(t),"Content-Type":"application/json",...e.apiKey!=null?{Authorization:`Bearer ${e.apiKey}`}:{}},a=e.testMode?`/api/payment/link/auto/${t}/test`:`/api/payment/link/auto/${t}`;delete e.apiKey,delete e.testMode,e.locale??=A();let r=await fetch(Q+a,{method:"POST",headers:n,body:JSON.stringify(e)});return r.ok?{status:"ok",redirectURL:(await r.json()).url}:{...Vr(r.status,await na(r)),status:"error"}}function Ht(){if(typeof localStorage>"u")return;let e=localStorage.getItem("bitsnap-ref");if(e!=null)return e}function $r(e){let t=Ht();return t==null||(e.metadata==null&&(e.metadata={}),e.metadata.ref=t),e}export{me as a,Re as b,je as c,Fe as d,De as e,Fn as f,gt as g,yt as h,Ze as i,Qe as j,Sa as k,Ue as l,Xs as m,wm as n,Nm as o,Im as p,Sm as q,at as r,ul as s,Jo as t,Hr as u,_m as v,Ht as w,$r as x,Tp as y,Ap as z,Rp as A,j as B,Ro as C,Or as D,Op as E,Mr as F,gs as G,zs as H,qr as I,sm as J,st as K,lm as L,dm as M,$s as N,cm as O,um as P,Vs as Q,pm as R,mm as S,fm as T,gm as U,ym as V,hm as W,bm as X,Yo as Y,Kr as Z};
|
|
5
|
+
//# sourceMappingURL=chunk-56X4DBMQ.mjs.map
|