bitsnap-react 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -3
- package/dist/CartProvider-F7ER3WSS.js +2 -0
- package/dist/CartProvider-F7ER3WSS.js.map +1 -0
- package/dist/CartProvider-N73XNL7S.mjs +2 -0
- 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/{chunk-ICFYSZTV.js → chunk-3A4YOO7Z.js} +2 -2
- package/dist/chunk-3A4YOO7Z.js.map +1 -0
- package/dist/{chunk-UCESDAEC.mjs → chunk-3DGHF373.mjs} +2 -2
- package/dist/chunk-5GMWRCHK.mjs +4 -0
- package/dist/chunk-5GMWRCHK.mjs.map +1 -0
- package/dist/{chunk-MLSKHOA3.js → chunk-6CUCRTIK.js} +2 -2
- package/dist/chunk-6CUCRTIK.js.map +1 -0
- package/dist/{chunk-DGUIG334.js → chunk-EWLOGFF2.js} +2 -2
- package/dist/chunk-EWLOGFF2.js.map +1 -0
- package/dist/chunk-GAVLY6RX.mjs +2 -0
- package/dist/chunk-GAVLY6RX.mjs.map +1 -0
- package/dist/{chunk-XTIY6PXH.js → chunk-IP4OOWZ6.js} +2 -2
- package/dist/chunk-IP4OOWZ6.js.map +1 -0
- package/dist/chunk-JSDGZ4NY.js.map +1 -1
- package/dist/{chunk-3QG7H2AI.mjs → chunk-K2EITRNW.mjs} +2 -2
- package/dist/{chunk-5R3WR22A.mjs → chunk-KH7DFTJY.mjs} +2 -2
- package/dist/chunk-KOYBZORL.js.map +1 -1
- package/dist/{chunk-E5DCEFI2.mjs → chunk-L6J6H73J.mjs} +2 -2
- package/dist/chunk-M4KEUK6I.js +2 -0
- package/dist/chunk-M4KEUK6I.js.map +1 -0
- package/dist/{chunk-QSIKRVZL.mjs → chunk-OC7YS3UY.mjs} +2 -2
- package/dist/chunk-TMBC2BHN.js +4 -0
- package/dist/chunk-TMBC2BHN.js.map +1 -0
- package/dist/{chunk-DF2IK2GN.js → chunk-TSJCVFOX.js} +2 -2
- package/dist/chunk-TSJCVFOX.js.map +1 -0
- package/dist/{chunk-6IACFTJR.js → chunk-UFQVOGBS.js} +2 -2
- package/dist/chunk-UFQVOGBS.js.map +1 -0
- package/dist/chunk-XIHGWNTS.js.map +1 -1
- package/dist/{chunk-FF2ICGFQ.mjs → chunk-YNGXQJPE.mjs} +2 -2
- package/dist/{chunk-FF2ICGFQ.mjs.map → chunk-YNGXQJPE.mjs.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 +59 -2
- package/dist/index.d.ts +59 -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-ADH5XI4I.js +2 -0
- package/dist/methods-ADH5XI4I.js.map +1 -0
- package/dist/methods-BCR54EWX.mjs +2 -0
- 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/package.json +26 -51
- package/dist/CartProvider-XNFSUOCB.js +0 -2
- package/dist/CartProvider-XNFSUOCB.js.map +0 -1
- package/dist/CartProvider-YMJ7RFO4.mjs +0 -2
- package/dist/chunk-4BW6J7FP.js +0 -4
- package/dist/chunk-4BW6J7FP.js.map +0 -1
- package/dist/chunk-6IACFTJR.js.map +0 -1
- package/dist/chunk-DF2IK2GN.js.map +0 -1
- package/dist/chunk-DGUIG334.js.map +0 -1
- package/dist/chunk-ERL4Z7M7.js +0 -2
- package/dist/chunk-ERL4Z7M7.js.map +0 -1
- package/dist/chunk-ICFYSZTV.js.map +0 -1
- package/dist/chunk-MLSKHOA3.js.map +0 -1
- package/dist/chunk-P4Q5KXKS.mjs +0 -2
- package/dist/chunk-P4Q5KXKS.mjs.map +0 -1
- package/dist/chunk-PNTO3L2C.mjs +0 -4
- package/dist/chunk-PNTO3L2C.mjs.map +0 -1
- package/dist/chunk-XTIY6PXH.js.map +0 -1
- package/dist/methods-DDGOXLP6.mjs +0 -2
- package/dist/methods-RQPDIUUN.js +0 -2
- package/dist/methods-RQPDIUUN.js.map +0 -1
- /package/dist/{CartProvider-YMJ7RFO4.mjs.map → CartProvider-N73XNL7S.mjs.map} +0 -0
- /package/dist/{chunk-UCESDAEC.mjs.map → chunk-3DGHF373.mjs.map} +0 -0
- /package/dist/{chunk-3QG7H2AI.mjs.map → chunk-K2EITRNW.mjs.map} +0 -0
- /package/dist/{chunk-5R3WR22A.mjs.map → chunk-KH7DFTJY.mjs.map} +0 -0
- /package/dist/{chunk-E5DCEFI2.mjs.map → chunk-L6J6H73J.mjs.map} +0 -0
- /package/dist/{chunk-QSIKRVZL.mjs.map → chunk-OC7YS3UY.mjs.map} +0 -0
- /package/dist/{methods-DDGOXLP6.mjs.map → methods-BCR54EWX.mjs.map} +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{A as Ln,a as Ie,g as vn,h as wn,i as kn,j as Cn,k as Nn,s as In,v as Sn,w as Rn,x as An,y as Tn,z as Dn}from"./chunk-KH7DFTJY.mjs";import{a as Ot,g as We,h as Ze,j as he,k as Je,l as yn,m as hn,n as Le}from"./chunk-K2EITRNW.mjs";import{a as At,b as Tt,c as st,d as Dt,e as Lt,f as mn,j as B,k as De,l as ee,p as gn,q as S,r as lt,t as Pn,u as Ee,v as bn}from"./chunk-3DGHF373.mjs";import{a as St,b as un,c as Rt,d as x,f as W,g as fn,h as xn,j as Pe,m as V}from"./chunk-GAVLY6RX.mjs";import{h as Et,l as ct,m as dt,n as Te,o as pn}from"./chunk-YNGXQJPE.mjs";import{useAutoAnimate as ua}from"@formkit/auto-animate/react";import{useEffect as jn,useState as oe}from"react";import{jsx as Ye}from"react/jsx-runtime";function ue({className:e,...t}){return Ye("div",{"data-slot":"card",className:x("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function be({className:e,...t}){return Ye("div",{"data-slot":"card-header",className:x("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function ve({className:e,...t}){return Ye("div",{"data-slot":"card-title",className:x("leading-none font-semibold",e),...t})}function Mt({className:e,...t}){return Ye("div",{"data-slot":"card-description",className:x("text-muted-foreground text-sm",e),...t})}function me({className:e,...t}){return Ye("div",{"data-slot":"card-content",className:x("px-6",e),...t})}import*as En from"react";import{OTPInput as na,OTPInputContext as ra}from"input-otp";import{MinusIcon as aa}from"lucide-react";import{jsx as Oe,jsxs as oa}from"react/jsx-runtime";function On({className:e,containerClassName:t,...n}){return Oe(na,{"data-slot":"input-otp",containerClassName:x("flex items-center gap-2 has-disabled:opacity-50",t),className:x("disabled:cursor-not-allowed",e),...n})}function Ut({className:e,...t}){return Oe("div",{"data-slot":"input-otp-group",className:x("flex items-center",e),...t})}function Se({index:e,className:t,...n}){let o=En.useContext(ra),{char:r,hasFakeCaret:a,isActive:i}=o?.slots[e]??{};return oa("div",{"data-slot":"input-otp-slot","data-active":i,className:x("data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]",t),...n,children:[r,a&&Oe("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:Oe("div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}function Mn({...e}){return Oe("div",{"data-slot":"input-otp-separator",role:"separator",...e,children:Oe(aa,{})})}import{REGEXP_ONLY_DIGITS as ma}from"input-otp";import{jsx as jt,jsxs as sa}from"react/jsx-runtime";function ia(){return sa("div",{className:"flex items-center gap-2",children:[jt("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),jt("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),jt("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var Z=ia;var ca="return_url",_t="__return_url",da="accessToken";function Qe(e){let t=new URLSearchParams(e).get(ca);return t?Un(t):null}function Xe(e){typeof window>"u"||(e?window.sessionStorage.setItem(_t,e):window.sessionStorage.removeItem(_t))}function Me(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(_t);return e?Un(e):null}function la(e,t){return t.some(n=>{if(e===n)return!0;let o=new URL(n).hostname,r=new URL(e).hostname;return r.endsWith(`.${o}`)||r===o})}function Un(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!la(t.origin,Ze())?null:t.toString()}catch{return null}}function Ue(e,t){let n=new URL(e);return n.searchParams.set(da,t),n.toString()}import{jsx as w,jsxs as O}from"react/jsx-runtime";if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];Ze().length===0&&We(Array.from(new Set(t)))}var pa=({projectID:e,host:t,reveal:n,email:o,setEmail:r,loginUser:a,isLoginLoading:i,errMsg:c})=>{let{projectID:d,host:l}=he();if(typeof window<"u"&&Je(e??d,t??l)!=null)return window.location.href=window.location.href.replaceAll("login",""),null;let[m,g]=oe(!1),k=s=>/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(s.trim())?g(!0):g(!1),u=s=>{let{value:P}=s.target;k(P),r(P)};function v(){n()}function C(s){s.preventDefault(),a()}return w("main",{className:"mx-auto flex max-w-sm flex-1 flex-col justify-center space-y-12",children:w("div",{className:x("flex min-w-sm flex-col gap-6"),children:O(ue,{children:[O(be,{children:[w(ve,{className:"text-2xl",children:"Zaloguj si\u0119"}),w(Mt,{children:"Wy\u015Blemy do Ciebie kod na maila, dzi\u0119ki kt\xF3remu si\u0119 zalogujesz."})]}),w(me,{children:O("form",{onSubmit:C,children:[O("div",{className:"flex flex-col gap-6",children:[O("div",{className:"grid gap-2",children:[w(Ie,{htmlFor:"email",children:"Email"}),w(lt,{id:"email",onChange:u,type:"email",placeholder:"m@example.com",required:!0}),w("span",{className:x(!m&&o.length>0?"font-bold text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!m&&o.length>0?"Nieprawid\u0142owy adres email":"Wpisz sw\xF3j adres email"})]}),O("div",{children:[O(S,{type:"submit",disabled:i,className:"relative w-full",onClick:a,children:[i&&w("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:w(Z,{})}),"Zaloguj si\u0119"]}),c.length>0&&w("p",{className:"text-xs font-medium text-red-500",children:c})]})]}),O("div",{className:"mt-4 text-center text-sm",children:["Masz ju\u017C kod?"," ",w("button",{type:"button",onClick:v,className:"underline underline-offset-4",children:"Mam ju\u017C kod"})]})]})})]})})})},fa=({projectID:e,host:t,email:n,reveal:o,setEmail:r,isLoginLoading:a,loginUserResponse:i,setLoginUserResponse:c,setResponseStatus:d,errMsg:l})=>{let m=dt(),{mutateAsync:g,isPending:k}=ee(B.publicApi.userPanelLoginWithCode),[u,v]=oe(""),[C,s]=oe(!1),[P,R]=oe(!1),[q,F]=oe(0),A=M=>/^\d+$/.test(M.trim())?s(!0):s(!1),E=M=>{A(M),v(M)};async function z(){if(R(!0),u.length==0){s(!1);return}let M=parseInt(u),X=await g({code:M}),ye,Ce,re;if(X.result.case==="accessToken"?(s(!0),ye="ok",Ce=void 0,re=X.result.value):(s(!1),ye="error",Ce=X.result.value,re=void 0),ye==="error"&&(s(!1),console.warn("error:",`Kod b\u0142\u0119du: ${Ce}`),console.warn("Nieprawid\u0142owy kod, spr\xF3buj ponownie.")),ye==="ok"){m.track("panel_login",{}),re&&yn(e,re,n,t);let h=typeof window<"u"?Me():null;setTimeout(()=>{if(re&&h){window.location.href=Ue(h,re);return}window.location.reload()},100)}}function D(){let M=setInterval(()=>{F(X=>X>0?X-1:(clearInterval(M),0))},1e3);return()=>{clearInterval(M)}}jn(()=>{i?.status==="ok"&&i?.retryIn>0&&(F(i.retryIn),D())},[i]);function $(){r(""),c(null),d("default"),o()}function ge(M){M.preventDefault(),z()}return w("main",{className:"mx-auto flex max-w-md flex-1 flex-col justify-center space-y-8",children:w("div",{className:x("flex min-w-sm flex-col gap-6"),children:O(ue,{children:[O(be,{children:[w(ve,{className:"text-2xl",children:"Wpisz kod z maila"}),w(Mt,{children:"Sprawd\u017A czy przypadkiem nie wyl\u0105dowa\u0142 w spamie."})]}),O(me,{children:[O("form",{onSubmit:ge,className:"flex flex-col gap-6",children:[w("div",{className:"grid gap-2",children:w("div",{className:"my-5 flex w-full items-center justify-center",children:O("div",{className:"flex flex-col gap-2",children:[O(On,{id:"verify-code",maxLength:6,pattern:ma,onChange:M=>{E(M)},children:[O(Ut,{children:[w(Se,{index:0}),w(Se,{index:1}),w(Se,{index:2})]}),w(Mn,{}),O(Ut,{children:[w(Se,{index:3}),w(Se,{index:4}),w(Se,{index:5})]})]}),w("span",{className:x(!C&&P?"text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!C&&P?u.length==0?"Kod nie mo\u017Ce by\u0107 pusty":"Kod musi sk\u0142ada\u0107 si\u0119 z cyfr":"Wpisz kod z maila"})]})})}),O("div",{children:[O(S,{type:"submit",disabled:a||k,className:"relative w-full",children:[(a||k)&&w("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:w(Z,{})}),"Zaloguj si\u0119"]}),l.length>0&&w("p",{className:"text-xs font-medium text-red-500",children:l})]})]}),O("div",{className:"mt-4 text-center text-sm",children:["Nie masz kodu?"," ",w("button",{type:"button",onClick:$,className:"underline underline-offset-4",children:"Wr\xF3\u0107"})]})]})]})})})},ga=({analytics:e})=>{let{theme:t,allowedReturnOrigins:n,projectID:o,host:r}=he(),a=Te(o,e,"panel"),i={"--button-background-color":t?.colors?.brand??"#FFFFFF","--button-background-color-dark":t?.colors?.brandDark??"#000000","--button-text-color":t?.colors?.brandDark??"#000000","--button-text-color-dark":t?.colors?.brand??"#FFFFFF"},[c,d]=oe("login"),[l]=ua({duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1}),m=()=>d(E=>E==="login"?"verifyCode":"login"),[g,k]=oe(""),[u,v]=oe("default"),[C,s]=oe(null),{mutateAsync:P,isPending:R}=ee(B.publicApi.userPanelLogin),[q,F]=oe("");jn(()=>{if(typeof window>"u"||window.parent!==window)return;let E=Qe(window.location.search);E&&Xe(E);let z=E??Me();if(!z)return;let D=Je(o,r);D&&(window.location.href=Ue(z,D))},[n,o,r]);async function A(){F(""),v("default");let E=await P({email:g}),z=E.result.case==="success"?"ok":"error",D=0,$;E.result.case==="success"&&(D=E.result.value.retryIn),z==="error"&&($="Nieprawid\u0142owy adres email, spr\xF3buj ponownie."),s({status:z,retryIn:D,message:$}),z==="ok"&&c==="login"?m():z==="ok"&&c==="verifyCode"?v("success"):z==="error"&&F($??"Nieprawid\u0142owy adres email, spr\xF3buj ponownie.")}return w(ct,{value:a,children:w("div",{className:"bg-white text-black dark:bg-black dark:text-white",children:O("div",{className:"font-inter flex h-screen w-screen flex-col p-4",style:i,ref:l,children:[O("header",{children:[t?.logoDarkURL&&w("img",{src:t?.logoDarkURL,className:"hidden dark:inline",alt:"Company Logo",draggable:!1}),t?.logoURL&&w("img",{src:t?.logoURL,className:"dark:hidden",alt:"Company Logo",draggable:!1})]}),c==="login"&&w(pa,{projectID:o,host:r,reveal:m,email:g,setEmail:k,loginUser:A,isLoginLoading:R,errMsg:q}),c==="verifyCode"&&w(fa,{projectID:o,host:r,email:g,reveal:m,setEmail:k,loginUser:A,isLoginLoading:R,loginUserResponse:C,setLoginUserResponse:s,responseStatus:u,setResponseStatus:v,errMsg:q})]})})})},ya=({analytics:e}={})=>w(ga,{analytics:e});import{useAutoAnimate as Ro}from"@formkit/auto-animate/react";import{useEffect as bt,useState as Ao}from"react";import{useState as ha,useCallback as Pa,useEffect as ba}from"react";function _n(e){let[t,n]=ha(()=>{if(typeof window>"u")return e;let r=new URLSearchParams(window.location.search),a={};return Object.keys(e).forEach(i=>{let c=r.get(i);if(c!==null)try{a[i]=JSON.parse(c)}catch{a[i]=c}}),{...e,...a}}),o=Pa(r=>{n(a=>{let i={...a,...r};if(typeof window<"u"){let c=new URLSearchParams;Object.keys(i).forEach(l=>{let m=i[l];m!=null&&c.set(l,JSON.stringify(m))});let d=`${window.location.pathname}?${c.toString()}`;window.history.pushState({},"",d)}return i})},[]);return ba(()=>{let r=()=>{let a=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(c=>{let d=a.get(c);if(d!==null)try{i[c]=JSON.parse(d)}catch{i[c]=d}}),n({...e,...i})};return window.addEventListener("popstate",r),()=>window.removeEventListener("popstate",r)},[e]),[t,o]}function zn(e,t){if(e!=null)return e;let n=t?.trim();if(!(n==null||n===""))return{tokens:Pn(n)}}import*as ut from"@radix-ui/react-switch";import{jsx as qn}from"react/jsx-runtime";function Fn({className:e,...t}){return qn(ut.Root,{"data-slot":"switch",className:x("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:qn(ut.Thumb,{"data-slot":"switch-thumb",className:x("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}import{useState as va}from"react";import{Fragment as xa,jsx as et,jsxs as zt}from"react/jsx-runtime";function wa({}){let[e,t]=va({disableAll:!1});return zt(xa,{children:[et("h3",{className:"text-2xl",children:"Powiadomienia"}),et("p",{className:"text-sm text-neutral-500",children:"Zarz\u0105dzaj swoimi powiadomieniami"}),et("div",{className:"mt-6",children:zt("div",{className:"flex items-center space-x-2",children:[et(Fn,{id:"disable-all-notifications",checked:e.disableAll,onCheckedChange:n=>t(o=>({...o,disableAll:n}))}),zt(Ie,{htmlFor:"disable-all-notifications",className:"flex flex-col gap-1 text-base",children:["Wszystkie powiadomienia",et("span",{className:"text-xs font-normal text-neutral-500 md:text-sm",children:"Ten przycisk mo\u017Ce wy\u0142\u0105czy\u0107 wszystkie powiadomienia"})]})]})})]})}var Bn=wa;import{ChevronLeftIcon as ka,ChevronRightIcon as Ca,MoreHorizontalIcon as Na}from"lucide-react";import{jsx as ie,jsxs as Ft}from"react/jsx-runtime";function Hn({className:e,...t}){return ie("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:x("mx-auto flex w-full justify-center",e),...t})}function $n({className:e,...t}){return ie("ul",{"data-slot":"pagination-content",className:x("flex flex-row items-center gap-1",e),...t})}function we({...e}){return ie("li",{"data-slot":"pagination-item",...e})}function je({className:e,isActive:t,size:n="icon",...o}){return ie("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:x(gn({variant:t?"outline":"ghost",size:n}),e),...o})}function Gn({className:e,...t}){return Ft(je,{"aria-label":"Go to previous page",size:"default",className:x("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[ie(ka,{}),ie("span",{className:"hidden sm:block",children:"Previous"})]})}function Vn({className:e,...t}){return Ft(je,{"aria-label":"Go to next page",size:"default",className:x("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[ie("span",{className:"hidden sm:block",children:"Next"}),ie(Ca,{})]})}function qt({className:e,...t}){return Ft("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:x("flex size-9 items-center justify-center",e),...t,children:[ie(Na,{className:"size-4"}),ie("span",{className:"sr-only",children:"More pages"})]})}import{useState as Ia}from"react";import{Fragment as La,jsx as N,jsxs as J}from"react/jsx-runtime";var Sa=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),Ra=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t.toUpperCase()}).format(e/100),Aa={draft:"Szkic",unpaid:"Nieop\u0142acona",paid:"Op\u0142acona",overdue:"Zaleg\u0142a",cancelled:"Anulowana",completed:"Zako\u0144czone",processing:"Przetwarzane",refunded:"Zwr\xF3cone"},Ta={draft:"text-neutral-400",unpaid:"text-yellow-500",paid:"text-green-600",overdue:"text-red-500",cancelled:"text-neutral-400 line-through",completed:"text-green-600",processing:"text-blue-500",refunded:"text-purple-500"};function Da({openOrderDetails:e,projectID:t,accessToken:n}){let[o,r]=Ia(0),a=20,{data:i,isFetching:c}=De(B.publicApi.getOrders,{projectId:t,accessToken:n,offset:o,limit:a}),d=i?.orders??[],l=i?.totalCount??0,m=Math.floor(o/a)+1,g=Math.ceil(l/a),k=u=>{r(u)};return J(La,{children:[N("h3",{className:"text-2xl",children:"Historia zam\xF3wie\u0144"}),N("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"Twoje zam\xF3wienia"}),c?N("div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((u,v)=>J("div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[J("div",{className:"flex items-center justify-between",children:[J("div",{className:"space-y-2",children:[N(Ee,{className:"h-4 w-24"}),N(Ee,{className:"h-3 w-32"})]}),J("div",{className:"space-y-2 text-right",children:[N(Ee,{className:"ml-auto h-4 w-16"}),N(Ee,{className:"ml-auto h-3 w-12"})]})]}),N("div",{className:"mt-3",children:N(Ee,{className:"h-3 w-40"})})]},v))}):d.length===0?N("div",{className:"mt-6 text-sm text-neutral-400",children:"Brak zam\xF3wie\u0144."}):J("div",{children:[N("div",{className:"mt-6 flex w-full flex-col gap-3",children:d.map(u=>J("button",{onClick:()=>e(u.id),className:"block rounded-xl bg-white p-4 text-left shadow-sm transition-colors hover:bg-neutral-50 dark:bg-neutral-800 dark:hover:bg-neutral-700",children:[J("div",{className:"flex items-center justify-between",children:[J("div",{children:[J("p",{className:"font-medium",children:["Zam\xF3wienie #",u.id]}),N("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:u.customerName||"Klient"})]}),J("div",{className:"text-right",children:[N("p",{className:"font-semibold",children:Ra(u.totalAmount,u.currency)}),N("p",{className:`text-xs font-medium ${Ta[u.status]??"text-neutral-400"}`,children:Aa[u.status]??u.status})]})]}),N("div",{className:"mt-2 flex items-center justify-between text-xs text-neutral-500 dark:text-neutral-400",children:J("span",{children:["Data:"," ",u.createdAt?Sa(Number(u.createdAt.seconds)):"-"]})})]},u.id))}),g>1&&!c&&N("div",{className:"mt-4 flex justify-center",children:N(Hn,{children:J($n,{children:[m>1&&N(we,{children:N(Gn,{onClick:()=>k(o-a)})}),m>2&&N(we,{children:N(je,{onClick:()=>k(0),children:"1"})}),m>3&&N(we,{children:N(qt,{})}),[m-1,m,m+1].filter(u=>u>0&&u<=g).map(u=>N(we,{children:N(je,{onClick:()=>k((u-1)*a),isActive:m===u,children:u})},u)),m<g-2&&N(we,{children:N(qt,{})}),m<g&&N(we,{children:N(je,{onClick:()=>k((g-1)*a),children:g})}),m<g&&N(we,{children:N(Vn,{onClick:()=>k(o+a)})})]})})})]})]})}var Kn=Da;import{useState as Wn}from"react";import{Fragment as Ua,jsx as te,jsxs as xe}from"react/jsx-runtime";var Zn=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),Ea={active:"Aktywny",cancelled:"Anulowany",paused:"Wstrzymany"},Oa={active:"text-green-600",cancelled:"text-red-500",paused:"text-yellow-500"};function Ma({projectID:e}){let[t,n]=Wn([]),[o,r]=Wn(!0);return xe(Ua,{children:[te("h3",{className:"text-2xl",children:"Plany"}),te("p",{className:"text-sm text-neutral-500",children:"Twoje aktywne subskrypcje"}),o?te("div",{className:"mt-6 text-sm text-neutral-400",children:"\u0141adowanie..."}):t.length===0?te("div",{className:"mt-6 text-sm text-neutral-400",children:"Brak aktywnych plan\xF3w."}):te("div",{className:"mt-6 flex flex-col gap-4",children:t.map(a=>xe("div",{className:"rounded-xl bg-white p-5 shadow-sm dark:bg-neutral-800",children:[xe("div",{className:"flex items-start justify-between",children:[xe("div",{children:[te("p",{className:"font-semibold",children:a.tierName}),a.configName&&te("p",{className:"text-sm text-neutral-500",children:a.configName})]}),te("span",{className:`text-sm font-medium ${Oa[a.status]??"text-neutral-500"}`,children:Ea[a.status]??a.status})]}),xe("div",{className:"mt-3 grid grid-cols-2 gap-2 text-sm text-neutral-600 dark:text-neutral-400",children:[xe("div",{children:[te("span",{className:"font-medium",children:"Dzie\u0144 rozliczenia:"})," ",a.billingDay]}),xe("div",{children:[te("span",{className:"font-medium",children:"Data startu:"})," ",Zn(a.startDate)]}),a.endDate&&xe("div",{children:[te("span",{className:"font-medium",children:"Data zako\u0144czenia:"})," ",Zn(a.endDate)]})]})]},a.id))})]})}var Jn=Ma;import{useEffect as ja,useState as Bt}from"react";import{jsx as ne,jsxs as qa}from"react/jsx-runtime";function _a(e,t,n,o){typeof window>"u"||(t&&Le(n,o),window.location.href=e)}function za({projectID:e,host:t,loginURL:n,screen:o,params:r,setParams:a,setActiveScreen:i}){let{status:c,exchangeError:d}=Cn("PanelReturns"),l=kn(),m=c==="anonymous"&&(d==null||vn(d));ja(()=>{m&&_a(n,d!=null,e,t)},[m,n,d,e,t]);let[g,k]=Bt("orders"),[u,v]=Bt({items:[],note:""}),[C,s]=Bt();if(c==="anonymous"&&!m)return qa("div",{role:"alert",className:"flex flex-col items-start gap-3",children:[ne("p",{className:"text-sm",children:l(wn(d))}),ne(S,{type:"button",onClick:()=>window.location.reload(),children:l("errorRetry")})]});if(c!=="authenticated")return ne(In,{});let P=R=>{k(R),a({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(o==="return-details"&&r.returnId)return ne(Ln,{returnId:r.returnId,onBack:()=>P("myReturns")});if(g==="myReturns")return ne(Dn,{onBack:()=>P("orders"),onSelectReturn:R=>{a({state:"return-details",returnId:R,orderId:void 0}),i("return-details")}});if(g==="result"&&C!=null)return ne(Tn,{returnId:C,onContinue:()=>P("orders"),onOpenMyReturns:()=>P("myReturns")});if(r.orderId){let R=r.orderId;return g==="confirmation"?ne(An,{orderId:R,items:u.items,note:u.note,onBack:()=>k("orders"),onSubmitted:q=>{s(q),v({items:[],note:""}),k("result"),a({orderId:void 0})}}):ne(Rn,{orderId:R,initialItems:u.items.length>0?u.items:void 0,initialNote:u.note,onBack:()=>{v({items:[],note:""}),a({orderId:void 0})},onContinue:q=>{v(q),k("confirmation")}})}return ne(Sn,{showLogout:!1,onSelectOrder:R=>{v({items:[],note:""}),k("orders"),a({orderId:R})},onOpenMyReturns:()=>P("myReturns")})}function Ht({accessToken:e,appearance:t,texts:n,...o}){return ne(Nn,{projectID:o.projectID,host:o.host,appearance:t,texts:n,panelAccessToken:e,children:ne(za,{...o})})}import{useState as to}from"react";import{jsx as $a}from"react/jsx-runtime";var Fa=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,Ba=e=>[...e.matchAll(Fa)].map(n=>({url:n[0],startIndex:n.index,endIndex:n.index+n[0].length-1})),Ha=(e,t)=>{let n="",o=0;t.sort((r,a)=>r.startIndex-a.startIndex);for(let{startIndex:r,endIndex:a,replacementText:i}of t)n+=e.slice(o,r),n+=i,o=a+1;return n+=e.slice(o),n},Yn=e=>{let t=Ba(e);return $a("p",{dangerouslySetInnerHTML:{__html:Ha(e,t.map(n=>(n.replacementText=`<a key=${n.url} href=${n.url} style="text-decoration: underline;" target="_blank">
|
|
2
|
+
${n.url}
|
|
3
|
+
</a>`,n)))}})};import{fromJsonString as no,toJsonString as ro}from"@bufbuild/protobuf";import{useAutoAnimate as Qa}from"@formkit/auto-animate/react";import{ChevronLeft as Xa,Download as sr}from"lucide-react";import{useEffect as cr,useRef as dr,useState as ze}from"react";import rr from"hls.js";import{Pause as Ga,Play as Va}from"lucide-react";import{forwardRef as Ka,useEffect as mt,useImperativeHandle as Wa,useRef as tt,useState as _e}from"react";function Qn(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="playing")}function Xn(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="paused")}function er(e,t){typeof navigator>"u"||typeof navigator.mediaSession>"u"||e!=null&&isNaN(e)||t!=null&&isNaN(t)||navigator.mediaSession.setPositionState({playbackRate:1,duration:e,position:t})}function tr(e){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.metadata=new MediaMetadata({title:e.title,artwork:e.artwork?[{type:"image/png",src:e.artwork}]:void 0}),navigator.mediaSession.setActionHandler("play",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("pause",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("stop",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekbackward",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekforward",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekto",t=>{e.action(t)}))}function nr(){navigator.mediaSession.metadata=null}import{jsx as se,jsxs as pt}from"react/jsx-runtime";var Za=Ka(({chapters:e,styles:t,updateCurrentTime:n,setCurrentTimeHandler:o,title:r,imageURL:a,uniqueProductID:i,onChapterChange:c},d)=>{let l;(G=>(G[G.Playing=0]="Playing",G[G.Paused=1]="Paused"))(l||={});let[m,g]=_e(1);mt(()=>{switch(m){case 0:Qn();break;case 1:Xn();break}},[m]),Wa(d,()=>({selectChapter:f=>{Ke(f)}}));let[k,u]=_e(void 0),[v,C]=_e(void 0),s=tt(null),P=tt(void 0),R=tt(void 0),q=tt(null),F=tt(null),[A,E]=_e(!0),[z,D]=_e(!1),[$,ge]=_e(!Ja());function M(f){f<10||localStorage.setItem(`__player__${i}_${F.current?.id}`,`${f}`)}function X(){let f=localStorage.getItem(`__player__${i}_${F.current?.id}`);if(f!=null)try{let U=parseInt(f);return isNaN(U)||U<0?void 0:U}catch{return}}function ye(){let f=localStorage.getItem(`__player__${i}_last_chapter`);if(f!=null)return f}function Ce(f){localStorage.setItem(`__player__${i}_last_chapter`,f)}function re(f){localStorage.removeItem(`__player__${i}_${f}`)}function h(){s.current!=null&&(s.current.onloadeddata=()=>{if(s.current!=null){if(s.current.readyState<2&&ge(!0),s.current.readyState>=2&&ge(!1),!z){let f=X();f!=null&&it(f),D(!0)}if(A){E(!1);try{Nt()}catch(f){console.log("play error",f)}}}},s.current.onplay=()=>{},s.current.onseeked=()=>{},s.current.onseeking=()=>{},s.current.onpause=()=>{},s.current.onended=()=>{ae()},tr({title:r??"",artwork:a,action:f=>{switch(f.action){case"play":Nt();break;case"pause":It();break;case"seekbackward":ot(-15);break;case"seekforward":ot(15);break;case"seekto":f.seekTime&&it(f.seekTime);break;case"stop":It();break;default:break}}}),Ne())}function ae(){if(e==null||e.length==0)return;let f=e.findIndex(G=>G.id==F.current?.id);f==-1||(re(e[f].id),f+1>=e.length)||Ke(e[f+1])}function Ne(){Re(),R.current==null&&(R.current=setTimeout(()=>{Re(),R.current=void 0,Ne()},500))}function Ve(){R.current!=null&&clearTimeout(R.current)}function Re(){s.current!=null&&(g(s.current.paused?1:0),C(s.current.duration),u(s.current.currentTime),M(s.current.currentTime),er(s.current.duration,s.current.currentTime),s.current.networkState===s.current.NETWORK_LOADING&&s.current.readyState<=s.current.HAVE_FUTURE_DATA?ge(!0):ge(!1),n&&n(s.current.currentTime))}function Nt(){s.current?.play().then().catch(),Re()}function It(){s.current?.pause(),Re()}function Jr(){if(m===0){It();return}Nt()}function ot(f){if(s.current==null)return;let U=s.current.currentTime+f;if(U<0){s.current.currentTime=0;return}if(U>s.current.duration){s.current.currentTime=s.current.duration;return}s.current.currentTime+=f}function it(f){if(s.current!=null){if(u(f),f<0){s.current.currentTime=0;return}if(f>s.current.duration){s.current.currentTime=s.current.duration;return}s.current.currentTime=f}}function Yr(){s.current!=null&&(s.current.onplay=null,s.current.onseeked=null,s.current.onseeking=null,s.current.onpause=null,s.current.onended=null,s.current.src="",P.current?.destroy())}function dn(f){if(f.length==0)return;let U=ye();if(U==null){Ke(f[0]);return}let G=f.find(Ae=>Ae.id==U);if(G==null){Ke(f[0]);return}Ke(G)}function Ke(f){D(!1),E(!0),F.current=f,Qr(f.publicUrl),c?.(f),Ce(f.id)}function Qr(f){s.current!=null&&(s.current.canPlayType("application/vnd.apple.mpegurl")?s.current.src=f:rr.isSupported()&&(P.current==null&&(P.current=new rr,P.current?.attachMedia(s.current)),P.current?.loadSource(f)))}mt(()=>{s.current!=null&&(h(),dn(e))},[s.current]),mt(()=>{dn(e)},[e]),mt(()=>(o?.(it),()=>{u(void 0),s.current?.pause(),Yr(),nr()}),[]);let ln=f=>{let U=Math.floor(f/3600),G=Math.floor(f/60)%60,Ae=Math.floor(f%60),ea=U>0?U<10?`0${U}:`:`${U}:`:"",ta=Ae<10?`0${Ae}`:`${Ae}`;return isNaN(Ae)||isNaN(G)||isNaN(U)?"":`${ea}${G}:${ta}`},Xr=f=>{let U=parseFloat(f.value)/parseFloat(f.max)*100;q.current.style.setProperty("--seek-before-width",U+"%");let G=v*U/100;it(G)};return pt("div",{id:"audio-player-container",className:"flex flex-col",style:t,ref:q,children:[se("video",{ref:s,className:"hidden",poster:a,title:r}),se("input",{type:"range",min:"0",max:v!=null?Math.floor(v).toString():100,value:k??0,onChange:f=>Xr(f.target),className:"w-full"}),pt("section",{className:"flex w-full items-center justify-between text-sm font-medium",children:[se("span",{id:"current-time",children:ln(k)}),se("span",{id:"duration",children:ln(v)})]}),pt("div",{className:"mt-6 flex items-center justify-center gap-x-12",children:[se(S,{variant:"outline",onClick:()=>ot(-10),"aria-label":"Rewind 10 Seconds",children:"-10"}),pt(S,{variant:"outline",onClick:Jr,"aria-label":"Play Or Pause",children:[m===1&&se(Va,{className:"h-5 w-5"}),m===0&&se(Ga,{className:"h-5 w-5"})]}),se(S,{variant:"outline",onClick:()=>ot(10),"aria-label":"Fast Forward 10 Seconds",children:"+10"})]}),$&&se("div",{className:"mt-2 flex w-full justify-center",children:se(Z,{})})]})});function Ja(){return navigator.userAgent.toLowerCase().indexOf("safari/")>-1}var ar=Za;var Ya={pl:{returnsNavLabel:"Zwroty",openCourse:"Otw\xF3rz kurs"},en:{returnsNavLabel:"Returns",openCourse:"Open the course"}};function nt(e=V()){return xn(Ya,e)}import*as ft from"react";import{jsx as or}from"react/jsx-runtime";function ir(){let[e,t]=ft.useState(13);return ft.useEffect(()=>{let n=setTimeout(()=>t(66),500);return()=>clearTimeout(n)},[]),or("div",{className:"w-[60%] h-2 bg-gray-200 rounded-full overflow-hidden",children:or("div",{className:"h-full bg-blue-600 transition-all duration-300",style:{width:`${e}%`}})})}import{Fragment as gt,jsx as b,jsxs as j}from"react/jsx-runtime";function pe(e,...t){console.warn(e,...t)}function $t(e){console.error(e)}var eo=({accessToken:e,product:t,styles:n,reveal:o,onOpenCourse:r})=>{let a=t.productType,i=dt(),c=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),d=dr(null),[l]=Qa(),[m,g]=ze(null),{mutateAsync:k,isPending:u}=ee(B.publicApi.userPanelGetFileDetails),v=dr(void 0),[C,s]=ze(null),[P,R]=ze(null),[q,F]=ze(!1),{mutateAsync:A,isPending:E}=ee(B.publicApi.userPanelGetAudiobookDetails),{mutateAsync:z,isPending:D}=ee(B.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[$,ge]=ze(null),[M,X]=ze(null);async function ye(){try{let h=await k({accessId:t.accessId,accessToken:e});if(h.result.case==="success"){g(h.result.value.files);return}else pe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),pe("Kod b\u0142\u0119du: ",h.result.value)}catch(h){pe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),$t("B\u0142\u0105d podczas pobierania danych:"+h)}}async function Ce(){try{let h=await A({accessId:t.accessId,accessToken:e});if(h.result.case==="audiobook"){s(h.result.value);return}else pe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),pe("Kod b\u0142\u0119du: ",h.result.value)}catch(h){pe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),$t("B\u0142\u0105d podczas pobierania danych:"+h)}}async function re(){try{let h=await z({accessId:t.accessId,accessToken:e,isBrowser:!0});if(h.result.case==="success"){R(h.result.value.audiobookDownloadDetails),F(h.result.value.isAvailableToDownloadInMobileApp===!0);return}else pe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),pe("Kod b\u0142\u0119du: ",h.result.value)}catch(h){pe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),$t("B\u0142\u0105d podczas pobierania danych:"+h)}}return cr(()=>{a===1&&(Ce().then().catch(),re().then().catch())},[]),cr(()=>{if(C!=null&&P!=null){let h=C.chapters;if(!h)return;let ae=h.map(Ne=>{let Ve=P?.find(Re=>Re.chapterId===Ne.id);if(Ve!=null)return{...Ne,publicUrl:Ve.publicUrl,downloadableUrl:Ve.downloadableUrl,duration:Ve.duration}}).filter(Ne=>Ne!=null);ae!=null&&ae.length>0&&X(ae)}},[C,P]),j("div",{children:[b("div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:j(S,{onClick:()=>o(),variant:"ghost",className:"w-fit",children:[b(Xa,{className:"h-6 w-6"}),b("span",{className:"font-inter text-sm font-medium",children:"Wr\xF3\u0107"})]})}),j("main",{className:"grid grid-cols-1 justify-center gap-6 sm:justify-start lg:grid-cols-2",children:[j("div",{className:"flex w-full max-w-xl flex-col gap-6",children:[a===2&&j("div",{ref:l,className:"flex flex-col space-y-4 rounded bg-white p-6 drop-shadow-xl dark:border dark:border-neutral-700 dark:bg-neutral-800 dark:drop-shadow-none",children:[j("div",{className:"flex items-center justify-between gap-x-4",children:[b("h4",{className:"text-xl font-semibold",children:"Twoje pliki"}),(m==null||m.length==0)&&b(S,{onClick:ye,"aria-label":"Download Product",className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:u?b(Z,{}):"Wy\u015Bwietl"})]}),u&&j("div",{className:"flex flex-col items-start gap-2",children:[b(ir,{}),b("p",{className:"font-bold transition hover:text-blue-600",children:"Trwa przygotowanie plik\xF3w..."})]}),m!=null&&m.length>0&&b("div",{className:"flex flex-col items-start justify-start gap-2",children:m.map((h,ae)=>j("a",{target:"_blank",className:"flex w-fit items-center gap-2 rounded-md bg-neutral-800 px-3 py-2 text-neutral-200 dark:bg-neutral-200 dark:text-neutral-800",href:h,download:!0,onClick:c,children:[`Plik numer ${ae+1}`,b(sr,{width:14,height:14})]},ae))})]}),a===4&&b("div",{className:"flex flex-col items-center justify-center rounded-xl bg-white p-6 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:b(S,{onClick:()=>r(t.accessId),className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:nt().openCourse})}),a===1&&b(gt,{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:[b("h4",{className:"text-xl font-semibold",children:$?.name??"Odtwarzacz"}),$?.description&&b("p",{className:"text-sm",children:$?.description}),b(gt,{children:E?j("div",{className:"flex gap-2",children:[b(Z,{}),b("p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):b(gt,{children:M!=null?b(gt,{children:b(ar,{ref:d,chapters:M,title:C?.name??t.productName??void 0,imageURL:C?.coverImage??t.productImageUrl??void 0,styles:n,setCurrentTimeHandler:h=>{v.current=h},uniqueProductID:t.productId,onChapterChange:h=>{ge(h)}})}):b("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:[b("p",{className:"mt-3 mb-3 text-xs",children:q?"Mo\u017Cesz s\u0142ucha\u0107 tego audiobooka w aplikacji r\xF3wnie\u017C bez dost\u0119pu do internetu.":"Mo\u017Cesz s\u0142ucha\u0107 tego audiobooka w aplikacji."}),j("div",{className:"flex gap-3",children:[b("a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:b("img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),b("a",{href:"https://docs.bitsnap.pl/guides/audiobook",children:b("img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),b("div",{className:"flex items-center justify-center rounded-xl bg-white p-3 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:a===1&&b("div",{className:"max-h-96 w-full overflow-y-auto",children:E?j("div",{className:"jusitfy-center flex flex-col items-center gap-2",children:[b(Z,{}),b("p",{children:"\u0141adowanie rozdzia\u0142\xF3w..."})]}):j("div",{children:[b("h2",{className:"mb-3 text-xl font-semibold",children:"Rozdzia\u0142y"}),M==null?b("p",{children:"Brak rozdzia\u0142\xF3w do wy\u015Bwietlenia."}):b("ul",{className:"flex w-full flex-col gap-2",children:M.map((h,ae)=>j("li",{className:"flex items-center justify-between",children:[j("button",{className:x("w-full rounded-lg p-2 text-left transition hover:bg-neutral-200 active:bg-neutral-200 dark:hover:bg-neutral-700 dark:active:bg-neutral-700",$?.id==h.id?"bg-neutral-200 dark:bg-neutral-700":"bg-neutral-100 dark:bg-neutral-800 dark:text-neutral-300"),onClick:()=>{d.current.selectChapter(h)},children:[j("div",{className:"flex items-center justify-between",children:[b("p",{className:"text-sm font-medium",children:h.name}),h.duration&&j("span",{className:"text-xs text-neutral-500",children:[Math.floor(h.duration/60),":",String(Math.floor(h.duration%60)).padStart(2,"0")]})]}),h.description&&b("p",{className:"mt-3 text-xs",children:h.description})]}),C&&C.isDownloadable&&h.downloadableUrl&&b("a",{href:h.downloadableUrl,onClick:c,children:b(sr,{width:14,height:14})})]},ae))})]})})})]}),j("div",{className:"w-full max-w-3xl space-y-6 rounded-xl bg-white p-6 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:[b("h2",{className:"text-3xl font-semibold",children:t.productName}),b("p",{className:"text-sm font-normal text-neutral-600 dark:text-neutral-300",children:t.productDescription}),b("img",{src:t.productImageUrl,alt:"Product Photo",width:384,height:384,className:"max-h-sm max-w-sm",draggable:!1})]})]})]})},lr=eo;import{Fragment as io,jsx as K,jsxs as rt}from"react/jsx-runtime";var ao=({accessToken:e,projectID:t,loginURL:n,styles:o,activeScreen:r,params:a,setParams:i,openCourse:c})=>{let{data:d,isLoading:l}=De(B.publicApi.userPanelGetProducts,{accessToken:e});if(l)return rt("div",{className:"flex items-center gap-2 bg-white p-2 dark:bg-black",children:[K("p",{className:"text-dark font-inter font-medium dark:text-white",children:"\u0141adowanie..."}),K(Z,{})]});if(d&&d.result.case==="failure")return console.warn("error:",`Kod b\u0142\u0119du: ${d.result.value}`),Le(t),window.location.href=n,null;let m=d&&d.result.case==="success"?d.result.value.products:[];return K(oo,{accessToken:e,products:m,styles:o,loginURL:n,activeScreen:r,params:a,setParams:i,openCourse:c})},ur=ao,oo=({accessToken:e,products:t,styles:n,loginURL:o,activeScreen:r,params:a,setParams:i,openCourse:c})=>{if(t.length===0)return window.location.href=o,null;let[d,l]=to(a.product?no(Lt,a.product):void 0),m=u=>{u==null?(l(void 0),i({product:void 0,state:"products"})):i({product:ro(Lt,u),state:"products"})};function g(u){switch(u){case 1:return"Audio";case 2:return"Plik";case 3:return"Bilet";case 4:return"Kurs";default:return}}function k(u){if(u.productType===4){c(u.accessId);return}l(u),m(u)}return r==="products"&&d!=null?K(lr,{accessToken:e,product:d,styles:n,reveal:m,onOpenCourse:c}):rt(io,{children:[K("h3",{className:"text-2xl",children:"Hej \u{1F44B}"}),K("p",{className:"text-sm text-neutral-500",children:"Poni\u017Cej znajdziesz swoje produkty"}),K("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-9 sm:justify-start",children:t?.map((u,v)=>rt("section",{onClick:()=>k(u),className:"w-full max-w-xs cursor-pointer rounded drop-shadow-xl dark:border dark:border-slate-600 dark:drop-shadow-none",children:[rt("section",{className:"flex flex-col items-center space-y-2 rounded bg-slate-100 p-4 dark:bg-neutral-900",children:[u.productType&&K("div",{className:"w-fit self-end rounded bg-red-900 px-4 py-1",children:K("span",{className:"text-sm font-medium text-white dark:text-slate-100",children:g(u.productType)})}),K("div",{className:"jusitfy-center flex max-h-40 items-center",children:K("img",{src:u.productImageUrl,alt:`Product ${v} Photo`,draggable:!1,className:"aspect-auto max-h-40"})})]}),rt("div",{className:"space-y-4 rounded bg-white p-4 dark:bg-black",children:[K("h2",{className:"text-xl font-semibold",children:u.productName}),K("p",{title:u.productDescription,className:"line-clamp-3 text-sm font-normal text-neutral-600 dark:text-neutral-300",children:Yn(u.productDescription)}),K(S,{onClick:C=>{C.stopPropagation(),k(u)},className:"w-full text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:"Zobacz"})]})]},v))})]})};import{useAutoAnimate as so}from"@formkit/auto-animate/react";import{LogOut as co,Undo2 as pr}from"lucide-react";import{useState as lo}from"react";import{Fragment as gr,jsx as I,jsxs as ce}from"react/jsx-runtime";function uo({activeScreen:e,setActiveScreen:t,setParams:n,styles:o,theme:r,logout:a}){return ce("header",{className:"md:border-r-neutral-150 md:bg-beige-50 fixed right-0 bottom-0 left-0 z-10 flex h-12 w-full items-center bg-neutral-800 md:static md:z-0 md:min-h-screen md:w-auto md:border-r dark:md:border-r-neutral-900",children:[I(mo,{activeScreen:e,setActiveScreen:t,setParams:n}),I(po,{activeScreen:e,setActiveScreen:t,setParams:n,theme:r,logout:a})]})}var fr=uo;function mo({activeScreen:e,setActiveScreen:t,setParams:n}){let{returnsNavLabel:o}=nt();return ce("nav",{className:"flex w-full items-center justify-evenly gap-4 md:hidden",children:[I(yt,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n}),I(yt,{panelScreen:"orders",label:"Faktury",imageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n}),I(yt,{panelScreen:"returns",label:o,icon:I(pr,{className:"h-5 w-5 text-white","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:n}),I(yt,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n})]})}function yt({panelScreen:e,label:t,imageURL:n,icon:o,activeScreen:r,setActiveScreen:a,setParams:i}){return ce(S,{onClick:()=>{a(e),i({product:void 0,state:e})},"aria-label":t,variant:null,className:x("flex flex-col gap-0",r===e?"opacity-100":"opacity-50"),children:[o??I("img",{src:n,alt:t,className:"scale-75"}),I("span",{className:"text-xs font-normal text-white",children:t})]})}function ht({panelScreen:e,label:t,imageURL:n,darkImageURL:o,icon:r,activeScreen:a,setActiveScreen:i,setParams:c,isExpanded:d}){return ce(S,{onClick:()=>{i(e),c({product:void 0,state:e})},variant:a===e?"secondary":"ghost",className:"justify-start",children:[r!=null?I("span",{className:x("inline-flex h-5 w-5 items-center justify-center",d?"mr-4":"mr-2"),children:r}):ce(gr,{children:[I("img",{src:n,alt:t,className:x("aspect-auto h-5 w-5 dark:hidden",d?"mr-4":"mr-2")}),I("img",{src:o,alt:t,className:x("hidden aspect-auto h-5 w-5 dark:inline",d?"mr-4":"mr-2")})]}),d&&I("span",{className:"md:text-medium hidden md:inline",children:t})]})}function po({activeScreen:e,setActiveScreen:t,setParams:n,theme:o,logout:r}){let[a]=so(),[i,c]=lo(!0),{returnsNavLabel:d}=nt();return ce("div",{ref:a,className:x("hidden px-4 pt-4 pb-12 md:flex md:h-full md:flex-col dark:bg-neutral-900",i?"md:w-52":"md:w-16"),children:[I("div",{className:"flex items-center justify-between",children:I(fo,{theme:o,isExpanded:i})}),I(mr,{className:"my-6"}),ce("div",{className:"flex flex-1 flex-col gap-2",children:[I(ht,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-dark-24x24.svg",darkImageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),I(ht,{panelScreen:"orders",label:"Zam\xF3wienia",imageURL:"/icons/category-dark-24x24.svg",darkImageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),I(ht,{panelScreen:"returns",label:d,icon:I(pr,{className:"h-5 w-5","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),I(ht,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-dark-24x24.svg",darkImageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i})]}),I(mr,{className:"mb-6"}),ce(S,{onClick:r,children:[I(co,{className:"mr-2",width:16,height:16}),i&&I("p",{className:"md:text-medium hidden md:inline md:text-center",children:"Wyloguj si\u0119"})]})]})}function mr({className:e}){return ce("div",{className:x("relative h-px w-full bg-neutral-300",e),children:[I("div",{className:"absolute -top-px left-0 h-1 w-1 rounded-full bg-neutral-500"}),I("div",{className:"absolute -top-px right-0 h-1 w-1 rounded-full bg-neutral-500"})]})}function fo({theme:e,isExpanded:t}){return ce(gr,{children:[e==null&&I("p",{className:"text-xl tracking-wider md:inline dark:text-neutral-200",children:"bitsnap."}),(e?.logoDarkURL||e?.logoURL)&&I("img",{src:e.logoDarkURL??e.logoURL,alt:"Company Logo",className:"hidden h-6 w-6 dark:inline",draggable:!1}),e?.logoURL&&I("img",{src:e.logoURL,alt:"Company Logo",className:"h-6 w-6 dark:hidden",draggable:!1})]})}import{LogOut as go}from"lucide-react";import{Fragment as ho,jsx as qe,jsxs as Gt}from"react/jsx-runtime";function yo({email:e,logout:t}){return Gt(ho,{children:[qe("h3",{className:"text-2xl",children:"Profil"}),Gt("div",{className:"mt-6 flex-1 md:flex-none",children:[qe("span",{className:"text-sm text-neutral-500",children:"Email"}),qe("p",{className:"mt-2 text-base",children:e||"Brak danych"})]}),qe("div",{className:"flex w-full flex-col items-center space-y-2",children:Gt(S,{onClick:t,className:"max-w-64 md:hidden",children:[qe(go,{className:"mr-2",width:16,height:16}),qe("p",{className:"text-medium inline text-center",children:"Wyloguj si\u0119"})]})})]})}var yr=yo;import{lazy as Po,Suspense as bo}from"react";import{jsx as Pt}from"react/jsx-runtime";var vo=Po(()=>import("./course.mjs").then(e=>({default:e.PanelCourse})));function Vt(e){return Pt(bo,{fallback:Pt("div",{className:"flex items-center gap-2 p-2",role:"status",children:Pt(Z,{})}),children:Pt(vo,{...e})})}import{AlertCircle as wr,CheckCircle2 as hr,ChevronLeft as wo,Loader2 as Wt,Lock as Pr,Package as xo,Truck as xr}from"lucide-react";import{useEffect as ko,useState as Kt}from"react";import{Fragment as kr,jsx as p,jsxs as y}from"react/jsx-runtime";function Co({status:e}){let t={created:{color:"bg-neutral-100 text-neutral-700",icon:null},paid:{color:"bg-green-100 text-green-700",icon:hr},completed:{color:"bg-blue-100 text-blue-700",icon:hr},canceled:{color:"bg-red-100 text-red-700",icon:wr},sent:{color:"bg-purple-100 text-purple-700",icon:xr},processing:{color:"bg-yellow-100 text-yellow-700",icon:Wt}},n=t[e]||t.created,o=n.icon,r={created:"Utworzone",paid:"Op\u0142acone",completed:"Zako\u0144czone",canceled:"Anulowane",sent:"Wys\u0142ane",processing:"Przetwarzane"};return y("span",{className:`inline-flex items-center gap-1 rounded-full px-3 py-1 text-sm font-medium ${n.color}`,children:[o&&p(o,{className:"h-4 w-4"}),r[e]||e]})}function No({orderID:e,email:t}){let[n,o]=Kt(""),r=ee(B.publicApi.addPublicOrderComment);return y("form",{onSubmit:async i=>{if(i.preventDefault(),!!n.trim())try{await r.mutateAsync({projectId:"",orderId:e,message:n.trim(),accessToken:t}),o("")}catch(c){console.error("Failed to add comment:",c)}},className:"mt-4 space-y-2",children:[p(Ie,{htmlFor:"comment",children:"Dodaj komentarz"}),p(bn,{id:"comment",value:n,onChange:i=>o(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:r.isPending}),p(S,{type:"submit",disabled:!n.trim()||r.isPending,children:r.isPending?y(kr,{children:[p(Wt,{className:"mr-2 h-4 w-4 animate-spin"}),"Wysy\u0142anie..."]}):"Dodaj komentarz"})]})}function br(e){return e?new Date(Number(e.seconds)*1e3).toLocaleDateString("pl-PL",{year:"numeric",month:"long",day:"numeric"}):"N/A"}function vr(e,t){return new Intl.NumberFormat("pl-PL",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function Io({orderID:e,initialEmail:t,onBack:n,accessToken:o,analytics:r}){let{theme:a,projectID:i}=he(),c=Te(i,r,"order"),[d,l]=Kt(t||""),[m,g]=Kt(!1),{data:k,isLoading:u,error:v,refetch:C}=De(B.publicApi.getPublicOrderDetails,{projectId:i??"",orderId:e,email:d||void 0,accessToken:o},{enabled:!!e}),s=k?.result.case==="order"?k.result.value:null,P=s?.isVerified??!1,R=s!=null;ko(()=>{R&&c.track("panel_order_viewed",{},{order_ref:null})},[c,R]);let q=()=>{C(),g(!1)},F={"--button-background-color":a?.colors?.brand??"#000000","--button-background-color-dark":a?.colors?.brandDark??"#ffffff","--button-text-color":a?.colors?.brandDark??"#000000","--button-text-color-dark":a?.colors?.brand??"#000000"};return u?p("div",{className:"flex min-h-screen items-center justify-center",children:y("div",{className:"text-center",children:[p(Wt,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),p("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):v||!s?p("div",{className:"flex min-h-screen items-center justify-center",children:p(ue,{className:"w-full max-w-md",children:p(me,{className:"pt-6",children:y("div",{className:"text-center",children:[p(wr,{className:"mx-auto h-12 w-12 text-red-500"}),p("h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),p("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):p("div",{className:"w-full bg-white py-8 dark:bg-black",style:F,children:y("div",{className:"w-full px-4",children:[n&&y(S,{onClick:n,variant:"ghost",className:"mb-4 w-fit",children:[p(wo,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),y("div",{className:"mb-6 flex items-center gap-4",children:[a?.logoURL&&y(kr,{children:[p("img",{src:a.logoURL,alt:"Project logo",className:`h-12 w-auto ${a.logoDarkURL?"dark:hidden":""}`}),a.logoDarkURL&&p("img",{src:a.logoDarkURL,alt:"Project logo",className:"hidden h-12 w-auto dark:block"})]}),y("div",{children:[p("h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),y("p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",s.orderId]})]})]}),y(ue,{className:"mb-6",children:[p(be,{children:y(ve,{className:"flex items-center",children:[p(xo,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),y(me,{className:"space-y-6",children:[y("div",{children:[y("div",{className:"flex items-center gap-2",children:[p(Co,{status:s.status}),s.processingStatus&&y("span",{className:"text-sm text-neutral-600",children:["\xB7 ",s.processingStatus]})]}),y("p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",br(s.createdAt)]})]}),y("div",{className:"border-t pt-4",children:[p("h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),y("div",{className:"space-y-2",children:[y("div",{children:[p("span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",p("span",{className:P?"":"text-neutral-500",children:s.customerName})]}),y("div",{children:[p("span",{className:"font-medium",children:"Email:"})," ",p("span",{className:P?"":"text-neutral-500",children:s.customerEmail})]}),s.customerPhone&&y("div",{children:[p("span",{className:"font-medium",children:"Telefon:"})," ",p("span",{className:P?"":"text-neutral-500",children:s.customerPhone})]})]})]}),!P&&p("div",{className:"border-t pt-4",children:y(S,{onClick:()=>g(!0),variant:"outline",className:"w-full",children:[p(Pr,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),y(ue,{className:"mb-6",children:[p(be,{children:p(ve,{children:"Produkty"})}),y(me,{className:"space-y-6",children:[p("div",{className:"space-y-4",children:s.items.map((A,E)=>y("div",{className:"flex items-center gap-4",children:[A.imageUrl&&p("img",{src:A.imageUrl,alt:A.name,className:"h-16 w-16 rounded object-cover"}),y("div",{className:"flex-1",children:[p("p",{className:"font-medium",children:A.name}),y("p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",A.quantity]})]}),p("div",{className:"text-right",children:p("p",{className:"font-medium",children:vr(Number(A.price),A.currency)})})]},E))}),(s.deliveryAddress||s.deliveryMethod)&&y("div",{className:"border-t pt-4",children:[y("h3",{className:"mb-3 flex items-center font-semibold",children:[p(xr,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),y("div",{className:"space-y-2",children:[s.deliveryAddress&&y("div",{children:[p("span",{className:"font-medium",children:"Adres:"})," ",p("span",{className:P?"":"text-neutral-500",children:s.deliveryAddress})]}),s.deliveryMethod&&y("div",{children:[p("span",{className:"font-medium",children:"Metoda:"})," ",s.deliveryMethod]}),s.trackingNumber&&P&&y("div",{children:[p("span",{className:"font-medium",children:"Tracking:"})," ",s.trackingNumber]})]})]}),p("div",{className:"border-t pt-4",children:y("div",{className:"flex justify-between text-lg font-bold",children:[p("span",{children:"Suma:"}),p("span",{children:vr(Number(s.totalAmount),s.currency)})]})})]})]}),y(ue,{children:[p(be,{children:y(ve,{children:["Komentarze ",s.commentCount>0&&`(${s.commentCount})`]})}),y(me,{children:[s.comments.length>0?p("div",{className:"space-y-4",children:s.comments.map(A=>y("div",{className:"border-b pb-4 last:border-b-0",children:[y("div",{className:"mb-1 flex items-center gap-2",children:[p("span",{className:"font-medium",children:A.authorName||"System"}),p("span",{className:"text-xs text-neutral-500",children:br(A.createdAt)}),A.authorType==="admin"&&p("span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),p("p",{className:P?"":"text-neutral-500",children:A.message})]},A.id))}):p("p",{className:"text-neutral-600",children:"Brak komentarzy."}),P?p(No,{orderID:s.orderId,email:d}):p("div",{className:"mt-4",children:y(S,{onClick:()=>g(!0),variant:"outline",className:"w-full",children:[p(Pr,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),m&&p("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:y(ue,{className:"w-full max-w-md",children:[p(be,{children:p(ve,{children:"Zweryfikuj sw\xF3j email"})}),y(me,{className:"space-y-4",children:[p("p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),y("div",{className:"space-y-2",children:[p(Ie,{htmlFor:"verify-email",children:"Adres email"}),p(lt,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:d,onChange:A=>l(A.target.value)})]}),y("div",{className:"flex gap-2",children:[p(S,{variant:"outline",onClick:()=>g(!1),className:"flex-1",children:"Anuluj"}),p(S,{onClick:q,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function So(e){return p(Io,{...e})}var Zt=So;import{jsx as de,jsxs as Cr}from"react/jsx-runtime";var To=({returnsAppearance:e,returnsTexts:t,analytics:n}={})=>{let{projectID:o,theme:r,loginURL:a,host:i}=he(),c=Te(o,n,"panel"),d=Je(o,i),l=hn(o,i),{mutateAsync:m}=ee(B.publicApi.userPanelLogout);async function g(){d&&await m({accessToken:d}),typeof window<"u"&&(Le(o,i),window.location.reload())}let[k]=Ro(),u=D=>["products","notifications","profile","plans","orders","order-details","returns","return-details","course"].includes(D),[v,C]=_n({product:void 0,state:"products",orderId:void 0,returnId:void 0,course:void 0,item:void 0}),[s,P]=Ao(u(v.state)?v.state:"products"),R=D=>{C({state:"order-details",orderId:D}),P("order-details")},q=()=>{C({state:"orders",orderId:void 0}),P("orders")},F=D=>C({orderId:void 0,returnId:void 0,course:void 0,item:void 0,...D}),A=D=>{C({state:"course",course:D,item:void 0,product:void 0}),P("course")},E=()=>{C({state:"products",course:void 0,item:void 0,product:void 0}),P("products")};bt(()=>{u(v.state)&&(v.state==="course"||s==="course")&&P(v.state)},[v.state]);let z={"--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 bt(()=>{if(d==null||d.length===0){window.location.href=a??"/panel/login";return}},[]),bt(()=>{if(d==null||d.length===0){window.location.href=a??"/panel/login";return}},[s]),bt(()=>{if(typeof window>"u"||window.parent!==window||!d)return;let D=Qe(window.location.search);D&&Xe(D);let $=D??Me();$&&(window.location.href=Ue($,d))},[d]),de(ct,{value:c,children:Cr("div",{ref:k,className:"font-inter relative min-h-screen w-screen bg-beige-100 text-black dark:bg-black dark:text-white md:flex",children:[de(fr,{activeScreen:s,setActiveScreen:P,setParams:F,styles:z,theme:r,logout:g}),Cr("main",{className:"flex h-[calc(100vh-80px)] flex-col overflow-y-auto w-full p-5 md:h-screen",children:[s==="products"&&de(ur,{projectID:o??"",accessToken:d,loginURL:a??"/panel/login",styles:z,activeScreen:s,params:v,setParams:C,openCourse:A}),s==="course"&&v.course&&d&&de(Vt,{accessId:v.course,accessToken:d,theme:r,itemId:v.item,onItemChange:D=>C({item:D}),onBack:E}),s==="notifications"&&de(Bn,{}),s==="plans"&&de(Jn,{projectID:o??""}),s==="orders"&&de(Kn,{projectID:o??"",accessToken:d??"",openOrderDetails:R}),s==="order-details"&&v.orderId&&de(Zt,{orderID:v.orderId,onBack:q}),(s==="returns"||s==="return-details")&&d&&de(Ht,{projectID:o??"",host:i,accessToken:d,loginURL:a??"/panel/login",appearance:zn(e,r?.colors?.brand),texts:t,screen:s,params:v,setParams:C,setActiveScreen:P}),s==="profile"&&de(yr,{email:l,logout:g})]})]})})},Do=To;import{create as fe}from"@bufbuild/protobuf";import{QueryClient as Zo,QueryClientProvider as Jo}from"@tanstack/react-query";import{createContext as Yo,useContext as Qo,useEffect as _r,useState as Xo}from"react";import{createClient as Lo}from"@connectrpc/connect";import{createConnectTransport as Eo}from"@connectrpc/connect-web";var le;(o=>{function e(r){return Lo(mn,n(r))}o.get=e;let t=new Map;function n(r){let a=t.get(r);return a==null&&(a=Eo({useBinaryFormat:!0,baseUrl:r+"/api/rpc",interceptors:[un]}),t.set(r,a)),a}})(le||={});import T from"zod";import Y from"zod";function _(e,t=2){return+(Math.round(+(e+"e+"+t))+"e-"+t)}function Nr(e,t){let n=typeof navigator>"u"?"pl-PL":navigator.language;return Intl.NumberFormat(n,{style:"currency",currency:t,currencyDisplay:"symbol"}).format(e/100)}var Vd=Y.object({event:Y.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:Y.string().optional(),value:Y.number().optional(),currency:Y.string().optional(),content_name:Y.string().optional(),items:Y.array(Y.object({id:Y.string(),name:Y.string(),price:Y.number().default(0),currency:Y.string().default("PLN"),quantity:Y.number().default(1)})).optional()});function Jt(e){typeof window>"u"||(Oo(e),Uo(e),jo(e))}function Oo(e){try{typeof window.dataLayer>"u"&&(window.dataLayer=[]);let t=Mo(e);window.dataLayer.push(t)}catch(t){console.warn("cannot send google analytics event",t)}}function Mo(e){let t=e.value??e.items?.reduce((a,i)=>a+(i.price||0)*(i.quantity||1),0)??0,n=e.items?.map(a=>({item_id:a.id,item_name:a.name||a.id,price:_((a.price||0)/100,2),quantity:a.quantity||1})),o={currency:e.currency||"PLN",value:_(t/100,2)};n&&n.length>0&&(o.items=n);let r;switch(e.event){case"purchase":r="purchase",o.transaction_id=e.step||`txn_${Date.now()}`;break;case"addToCart":r="add_to_cart";break;case"viewCart":r="view_cart";break;case"removeFromCart":r="remove_from_cart";break;case"initiateCheckout":r="begin_checkout";break;case"customizeProduct":r="customize_product";break;default:r=e.event}return{event:r,ecommerce:o,...e.step&&{step:e.step},...e.content_name&&{content_name:e.content_name}}}function Uo(e){if(typeof window.fbq>"u")return;let t="",n="",o={};switch(e.event){case"purchase":t="track",n="Purchase",o={category_name:e.step,...e};break;case"lead":t="track",n="Lead",o={category_name:e.step,...e};break;case"addToCart":t="track",n="Add to Cart",o={category_name:e.step,...e};break;case"customizeProduct":t="track",n="Customize Product",o={category_name:e.step,...e};break;case"viewCart":t="track",n="View Cart",o={category_name:e.step,...e};break;case"removeFromCart":t="track",n="Remove from Cart",o={category_name:e.step,...e};break;case"initiateCheckout":t="track",n="Initiate Checkout",o={category_name:e.step,...e};break;default:break}window.location.search.includes("analytics")&&console.log("Pushing FB event",t,n,o),window.fbq(t,n,o)}function jo(e){try{if(typeof window.ttq>"u")return;let t=_o(e);if(!t)return;window.location.search.includes("analytics")&&console.log("Pushing TikTok event",t.eventName,t.eventPayload),window.ttq.track(t.eventName,t.eventPayload)}catch(t){console.warn("cannot send tiktok analytics event",t)}}function _o(e){let t=e.value??e.items?.reduce((a,i)=>a+(i.price||0)*(i.quantity||1),0)??0,n=e.items?.map(a=>({content_id:a.id,content_type:"product",content_name:a.name||a.id,quantity:a.quantity||1,price:_((a.price||0)/100,2)}))||[];n.length===0&&e.content_name&&n.push({content_id:e.step||"unknown",content_type:"product",content_name:e.content_name,quantity:1,price:_(t/100,2)});let o={currency:e.currency||"PLN",value:_(t/100,2)};n.length>0&&(o.contents=n);let r=null;switch(e.event){case"purchase":r="Purchase";break;case"addToCart":r="AddToCart";break;case"initiateCheckout":r="InitiateCheckout";break;case"customizeProduct":r="CustomizeProduct";break;case"viewCart":return;case"removeFromCart":return;case"lead":return;default:return null}return{eventName:r,eventPayload:o}}function Ir(e){let{items:t,googlePayConfig:n,checkout:o,result:r,cartRequiresShipping:a}=e,i=e.locale??V();if(r.totalAmount==null)return;let c=[];return a&&(c.push("SHIPPING_ADDRESS"),c.push("SHIPPING_OPTION")),{apiVersion:2,apiVersionMinor:0,callbackIntents:c,allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["MASTERCARD","VISA"]},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:n.gateway,gatewayMerchantId:n.gatewayId}}}],emailRequired:!0,shippingAddressParameters:{phoneNumberRequired:a},shippingAddressRequired:a,shippingOptionRequired:a,shippingOptionParameters:a?{shippingOptions:r.methods.slice(0,5).map(l=>({id:l.id,label:l.name+` - ${Nr(l.amount,r.currency)}`,description:l.description??""})),defaultSelectedOptionId:r.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:n.merchantId+"",merchantName:n.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:Pe("paymentForCart",i,e.texts),totalPrice:`${_(r.totalAmount/100,2)}`,currencyCode:r.currency,countryCode:r.country,checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",displayItems:zo(t,r.methods,r.selectedDeliveryMethod??(r.methods.length>0?r.methods[0].id:void 0),o.couponCode,r.couponValue,Pe("coupon",i,e.texts))}}}function zo(e,t,n,o,r,a="Coupon"){let i=[],c=0;for(let l of e){if(l.details==null)continue;let m=l.details.pricing?.effectivePrice??l.details.price;c+=m*l.quantity,i.push({label:l.details.name+" x "+l.quantity,price:`${_(m/100,2)}`,type:"LINE_ITEM",status:"FINAL"})}let d=t.find(l=>l.id===n);return d!=null&&i.push({label:d.name,price:`${_(d.amount/100,2)}`,type:"SHIPPING_OPTION",status:"FINAL"}),o!=null&&r!=null&&i.push({label:`${a} ${o}`,price:`${_(r/100,2)}`,type:"DISCOUNT",status:"FINAL"}),c>0&&i.push({label:"Subtotal",price:`${_(c/100,2)}`,type:"SUBTOTAL",status:"FINAL"}),i}function Fe(e,t){return`${W}/api/integrations/${e}/public-commerce${t}`}function ke(e){return typeof e=="object"&&e!=null&&"ERR"in e}function H(e,t,n){return{ERR:!0,error:e,type:t,data:n}}function Sr(e,t){return t?.find(n=>n.id===e||(n.variants?.some(o=>o.id===e)??!1))}function Rr(e,t){let n=new Set(t.map(o=>o.productID));return Array.from(new Set(e.filter(o=>!n.has(o))))}function Ar(e,t){let n=e?.trim();if(!(n==null||n.length===0))try{let o=new URL(n,t);return o.protocol!=="http:"&&o.protocol!=="https:"?void 0:o.href}catch{return}}import{create as qo}from"zustand";var Be=qo(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 Fo,useContext as Yt,useMemo as Tr}from"react";import{jsx as Bo}from"react/jsx-runtime";var vt=Fo({});function sl({texts:e,locale:t,children:n}){let o=Tr(()=>({texts:e,locale:t}),[e,t]);return Bo(vt.Provider,{value:o,children:n})}function Dr(){return Yt(vt)}function cl(e){let{texts:t,locale:n}=Yt(vt);return Pe(e,n??V(),t)}function dl(){let{texts:e,locale:t}=Yt(vt),n=t??V();return Tr(()=>o=>Pe(o,n,e),[n,e])}var Xt="bitsnap-pending-order";function Or(e,t){let n=new Map;for(let r of t)n.set(r.id,(n.get(r.id)??0)+r.quantity);let o=[];for(let r of e){let a=n.get(r.id);a==null?o.push(r):r.quantity>a&&o.push({...r,quantity:r.quantity-a})}return o}var Ho=60*1e3;function Mr(e,t=Date.now,n=Ho){let o;return r=>{let a=`${r.orderId}:${r.ts}`,i=t();return o?.key===a&&i-o.at<n?Promise.reject(new Error("pending order was asked about recently")):(o={key:a,at:i},e(r))}}function $o(e){if(!(e==null||e.length===0))try{let t=new URL(e,"https://bitsnap.invalid").pathname,n=/\/payment\/common\/([^/]+)\/([^/]+)\/?$/.exec(t);return n==null?void 0:{projectId:decodeURIComponent(n[1]),orderId:decodeURIComponent(n[2])}}catch{return}}function Go(e){if(e==null||e.length===0)return!1;try{let t=new URL(e,"https://bitsnap.invalid").pathname;return/\/payment\/manualPayment\/[^/]+\/[^/]+\/?$/.test(t)}catch{return!1}}function Vo(e,t=Date.now(),n={}){if(Go(e.url))return;let o=$o(e.url),r=Lr(e.orderId)??o?.orderId,a=Lr(e.projectId)??o?.projectId;if(!(r==null||a==null))return{orderId:r,projectId:a,...n.cartProjectId!=null?{cartProjectId:n.cartProjectId}:{},lines:n.lines??[],ts:t}}function ml(e,t={}){let n=Vo(e,t.now,t);return n!=null&&Ko(n,t.storage)}function Lr(e){return e!=null&&e.length>0?e:void 0}function wt(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function Ko(e,t=wt()){try{return t?.setItem(Xt,JSON.stringify(e)),t!=null}catch{return!1}}function Er(e=wt()){try{let t=e?.getItem(Xt);if(t==null)return;let n=JSON.parse(t);if(typeof n=="object"&&n!=null&&typeof n.orderId=="string"&&typeof n.projectId=="string"&&typeof n.ts=="number"&&n.orderId.length>0){let{orderId:o,projectId:r,cartProjectId:a,ts:i,lines:c}=n;return{orderId:o,projectId:r,...typeof a=="string"?{cartProjectId:a}:{},lines:Array.isArray(c)?c.filter(d=>typeof d?.id=="string"&&typeof d.quantity=="number"):[],ts:i}}}catch{}Qt(e)}function Qt(e=wt()){try{e?.removeItem(Xt)}catch{}}function Ur(e){let t=e.details?.status??Wo(e.details?.$unknown);return t==="created"||t==="placed"||t==="paid"||t==="canceled"?t:"unknown"}function Wo(e){if(Array.isArray(e)){for(let t of e)if(t?.no===3&&t.wireType===2&&t.data instanceof Uint8Array){let n=0,o=0;for(let r=0;o<t.data.length&&r<35;r+=7){let a=t.data[o++];if(n|=(a&127)<<r,!(a&128))break}if(o+n!==t.data.length)return;try{return new TextDecoder().decode(t.data.subarray(o))}catch{return}}}}async function jr(e){let t=e.storage??wt(),n=Er(t);if(n==null)return"none";if((e.now??Date.now)()-n.ts>864e5)return Qt(t),"expired";if(e.projectId!=null&&n.cartProjectId!=null&&n.cartProjectId!==e.projectId)return"pending";let r;try{r=await e.fetchStatus(n)}catch{return"pending"}let a=Er(t);if(a?.orderId!==n.orderId||a.ts!==n.ts)return"pending";if(r==="paid"||r==="placed"){try{await e.removeLines(n.lines)}catch{return"pending"}return Qt(t),"paid"}return"pending"}import{Fragment as mi,jsx as tn}from"react/jsx-runtime";var ei="__m_a",Hr=Yo(void 0),rn=void 0;function zl(e){Ot({projectID:e}),rn=e,typeof window<"u"&&We([window.location.origin])}function Ge(){return rn??document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-id")??void 0}function ti(){return document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-custom-host")??void 0}var ni=({children:e,locale:t})=>{let[n]=Xo(()=>new Zo),o=Dr();_r(()=>{$e()},[]);let r=Ge();if(_r(()=>{if(r==null)return;let i=()=>{oi(r).then(d=>{d==="paid"&&n.invalidateQueries({queryKey:["cart"]})})},c=()=>{document.visibilityState==="visible"&&i()};return i(),window.addEventListener("pageshow",i),document.addEventListener("visibilitychange",c),()=>{window.removeEventListener("pageshow",i),document.removeEventListener("visibilitychange",c)}},[r,n]),r==null)return tn(mi,{});let a=on(r,t??o.locale,o.texts);return tn(Jo,{client:n,children:tn(Hr.Provider,{value:a,children:e})})},en,ri=Mr(async e=>Ur(await le.get(W).getOrder({id:e.orderId,projectId:e.projectId})));function ql(){let{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:o}=L()??kt;return{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:o}}function Fl(){return(L()?.products??[]).map(e=>({id:e.id,quantity:e.quantity}))}function ai(e){let t=L();Q({...t,products:Or(t?.products??[],e)}),$e()}function oi(e){return en??=jr({projectId:e,fetchStatus:ri,removeLines:ai}).catch(t=>{console.warn("cannot check the pending order",t)}).finally(()=>{en=void 0}),en}var He=async(e,t)=>{let n=[];t?.items!=null&&t.items.length>0?n=t.items:n=L()?.products??[];let o=Array.from(new Set(n.map(i=>i.productID)));if(o.length===0)return[];let r=new URLSearchParams;r.set("ids",o.join(",")),r.set("locale",t?.locale??V());let a;try{let i=await fetch(Rt(Fe(e,`/products?${r.toString()}`)),{method:"GET"});if(i.status!=200)return H("products-load-failed","internal");a=await i.json()}catch(i){return console.warn("cannot load the products of the cart",i),H("products-load-failed","internal")}return n.flatMap(i=>{let c=Sr(i.productID,a.result);return c==null?[]:[{...i,details:ui(i.productID,c),catalogProductID:c.id}]})},Bl=()=>{let e=Qo(Hr);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},Hl=ni,ii=T.object({isAvailable:T.boolean(),merchantId:T.string(),merchantName:T.string(),gateway:T.string(),gatewayId:T.string()}),si=T.object({id:T.string(),productID:T.string(),quantity:T.number(),priceVersion:T.string().optional(),metadata:T.record(T.string(),T.string().optional()).optional(),url:T.string().optional()}),ci=T.object({country:T.string().optional(),couponCode:T.string().optional(),selectedDeliveryMethod:T.string().optional(),postalCode:T.string().optional(),email:T.string().optional(),products:T.array(si).optional(),googlePayConfig:ii.optional()}),kt={country:void 0,couponCode:void 0,email:void 0,selectedDeliveryMethod:void 0,postalCode:void 0,products:[],googlePayConfig:void 0},$r="checkout";function L(){try{let e=localStorage.getItem($r);return e==null?kt:ci.parse(JSON.parse(e))}catch{return kt}}async function zr(e,t){let n=await He(e,{items:t.map((a,i)=>({...a,id:`price-check-${i}`}))});if(ke(n))return n;let o=Rr(t.map(a=>a.productID),n);if(o.length>0)return H("item-ids-not-found","notFound",o);let r=L();r.products==null&&(r.products=[]),r.products.push(...t.map(a=>({id:Math.random().toString(36).substring(7),productID:a.productID,quantity:a.quantity,priceVersion:n.find(i=>i.productID===a.productID)?.details?.pricing?.priceVersion,metadata:a.metadata,url:Ar(a.url,typeof window<"u"?window.location.href:void 0)}))),di(t,n),Jt({event:"addToCart",currency:"PLN",items:t.map(a=>({id:a.productID,name:a.name??"",price:a.price??0,quantity:a.quantity,currency:a.currency??"PLN"}))}),Q(r),$e()}function di(e,t){for(let n of e)try{let o=t.find(c=>c.productID===n.productID),r=o?.details?.pricing?.effectivePrice??o?.details?.price??n.price,a=o?.details?.currency??n.currency;if(r==null||a==null)continue;let i=o?.catalogProductID??n.productID;(n.analytics??pn()).track("add_to_cart",{qty:n.quantity,value_minor:Math.round(r*n.quantity),currency:a},{product_id:i,variant_id:i!==n.productID?n.productID:null})}catch{}}function qr(e){let t=L(),n={...t,products:t?.products?.filter(o=>!e.includes(o.productID)&&!e.includes(o.id))};Jt({event:"removeFromCart",items:e.map(o=>({id:o,name:"",price:0,quantity:1,currency:"PLN"}))}),Q(n),$e()}function Q(e){localStorage.setItem($r,JSON.stringify(e))}function Fr(e,t){if(e.products==null||e.products.length==0)return;let n=e.products.reduce((o,r)=>(r.metadata!=null&&Object.keys(r.metadata).forEach(a=>{let i=r.metadata?.[a];i!=null&&(o[a]=i)}),o),{});return{items:e.products.map(o=>({id:o.productID,quantity:o.quantity,priceVersion:o.priceVersion})),askForNote:!0,countries:e.country?[e.country]:void 0,metadata:n,locale:t}}var on=(e,t=V(),n)=>{let o=ti();return o!=null&&fn(o),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await le.get(W).isOneClickPaymentAvailable({projectId:e})).applePay}catch(r){return console.error("Error checking if Apple Pay is available",r),!1}},async getGooglePayConfiguration(r){if(typeof window>"u"||typeof document>"u")return{isAvailable:!1};try{let a=await li(e);if(a?.isAvailable!=!0)return{isAvailable:!1};let i=L();if(i==null)return console.log("checkout is null"),{isAvailable:!1};let c=await He(e,{locale:t,items:r.items.map(g=>({id:Math.random().toString(36).substring(7),quantity:g.quantity,metadata:g.metadata,productID:g.productID}))});if(ke(c))return{isAvailable:!1};let d=await le.get(W).getPreOrderDetails({items:c.map(g=>fe(st,{id:g.productID,quantity:g.quantity})),projectId:e,postCode:i.postalCode,couponCode:i.couponCode,countryCode:i.country,selectedDeliveryMethod:i.selectedDeliveryMethod});if(d.totalAmount==null)return{isAvailable:!1};let l=c.find(g=>g.details?.isDeliverable==!0)!=null,m=await Ir({items:c,googlePayConfig:a,checkout:i,cartRequiresShipping:l,result:d,locale:t,texts:n});return m==null?{isAvailable:!1}:{isAvailable:!0,config:m}}catch(a){return console.error("Error resolving Google Pay configuration",a),{isAvailable:!1}}},async clearCart(){let r=structuredClone(kt);r.country=L()?.country,Q(r),$e()},async getAvailableCountries(){let r=await fetch(Rt(Fe(e,"/countries")),{method:"GET"});if(r.status!=200)return[];try{return T.array(T.object({name:T.string(),code:T.string()})).parse(await r.json())}catch(a){return H(a.toString(),"internal")}},async getCountry(){let r=L()?.country;if(r==null){r="PL";let a=L();a.country=r,Q(a)}return r},async getNumberOfElementsInCart(){return L()?.products?.reduce((r,a)=>r+a.quantity,0)??0},async getProducts(){return await He(e,{locale:t})},async removeProductFromCart(r){return qr([r.id])},async setCountry(r){let a=L();a.country=r,Q(a)},async setCouponCodeIfPossible(r){let a=L();a.couponCode=r,Q(a)},async setPostalCode(r){let a=L();a.postalCode=r,Q(a)},async setDeliveryMethod(r){let a=L();a.selectedDeliveryMethod=r,Q(a)},async setEmail(r){let a=L();a.email=r,Q(a)},async addProduct(r){return await zr(e,[r])},async updateQuantity(r){let a=L();a.products=a.products?.map(i=>(i.id===r.id&&(i.quantity=r.quantity),i)),Q(a),$e()},async getPaymentMethodChoice(){let r=Fr(L(),t);return r==null?null:Br(r)},async redirectToNextStep(r){let a=Fr(L(),t);if(a==null)return H("cart-is-empty","badInput");r?.paymentMethod!=null&&(a.paymentMethod=r.paymentMethod);let i=await nn(a);return ke(i)?(console.warn("cannot create payment URL",i.error),i):{url:i.url,...i.orderId!=null?{orderId:i.orderId}:{},...i.projectId!=null?{projectId:i.projectId}:{}}},async justRedirectToPayment(r){let a={items:[{id:r.productID,quantity:1}],askForNote:!1,details:r.email||r.name?{name:r.name,email:r.email}:void 0,locale:r.locale??t};a=an(a),r.country==null&&(r.country="pl"),a.details==null&&(a.details={}),a.details.address==null&&(a.details.address={}),a.details.address.country=r.country,r.marketingAgreement===!0&&(a.additionalAgreements=[{id:ei,name:"",required:!0,answer:!0}]);let i=await nn(a);return ke(i)?i:{url:i.url}},async getApplePayPreview(r){let a=L();try{let i=await le.get(W).getPreOrderDetails({items:r.items.map(c=>fe(st,{id:c.productID,quantity:c.quantity})),projectId:e,postCode:a.postalCode,couponCode:a.couponCode,countryCode:a.country,selectedDeliveryMethod:a.selectedDeliveryMethod});return i.totalAmount==null||i.currency.length===0?H("pre-order-unavailable","internal"):{countryCode:i.country||a.country||"PL",currencyCode:i.currency,totalAmount:`${_(i.totalAmount/100,2)}`}}catch(i){return console.warn("cannot load the Apple Pay preview",i),H("pre-order-unavailable","internal")}},async completeApplePayPayment(r){let a=L();if(a==null)return H("Checkout not found");let i=await He(e,{locale:t});if(ke(i))return i;try{let c=r.shippingContact?.givenName;r.shippingContact?.familyName!=null?c+=" "+r.shippingContact?.familyName:r.billingContact?.familyName!=null&&(c+=" "+r.billingContact?.familyName);let d={},l=xt();l!=null&&(d.ref=l);let m=await le.get(W).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(r.token.paymentData),paymentMethod:JSON.stringify(r.token.paymentMethod),transactionIdentifier:r.token.transactionIdentifier,order:fe(Dt,{items:i.map(g=>({id:g.productID,quantity:g.quantity})),couponCode:a.couponCode,email:r.shippingContact?.emailAddress??r.billingContact?.emailAddress??a.email??void 0,phone:r.shippingContact?.phoneNumber??r.billingContact?.phoneNumber??void 0,selectedDeliveryMethod:a.selectedDeliveryMethod,postCode:a.postalCode,projectId:e}),shippingAddress:fe(At,{line1:r.shippingContact?.addressLines?.[0]??"",city:r.shippingContact?.locality??"",country:r.shippingContact?.countryCode??"",zipCode:r.shippingContact?.postalCode??"",name:c}),billingAddress:fe(Tt,{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(d).length>0?JSON.stringify(d):void 0});return{isSuccess:m.isSuccess,redirectURL:m.redirectUrl}}catch(c){return console.error(c),H("Failed to authorize payment")}},async completeGooglePayPayment(r){let a=L();if(a==null)return H("Checkout not found");let i=await He(e,{locale:t});if(ke(i))return i;try{let c=r.paymentData.shippingAddress?.name,d={},l=xt();l!=null&&(d.ref=l);let m=await le.get(W).authorizeOneClickPayment({gateway:1,paymentData:r.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:r.paymentData.paymentMethodData.type,transactionIdentifier:"",order:fe(Dt,{items:i.map(g=>({id:g.productID,quantity:g.quantity})),couponCode:a.couponCode,email:r.paymentData.email??void 0,phone:r.paymentData.shippingAddress?.phoneNumber??void 0,selectedDeliveryMethod:r.paymentData.shippingOptionData?.id??a.selectedDeliveryMethod,postCode:r.paymentData.shippingAddress?.postalCode,projectId:e}),shippingAddress:fe(At,{line1:r.paymentData.shippingAddress?.address1??"",city:r.paymentData.shippingAddress?.locality??"",country:r.paymentData.shippingAddress?.countryCode??"",zipCode:r.paymentData.shippingAddress?.postalCode??"",name:c}),billingAddress:fe(Tt,{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(d).length>0?JSON.stringify(d):void 0});return{isSuccess:m.isSuccess,redirectURL:m.redirectUrl}}catch(c){return console.error(c),H("Failed to authorize payment")}return{isSuccess:!0}},async getApplePayPaymentRequest(r){let a=L();if(a==null)return H("Checkout not found");r&&r.expectedItems!=null&&r.expectedItems.length>0&&(a.products&&qr(a.products.map(l=>l.productID)),await zr(e,r.expectedItems));let i=await He(e,{locale:t});if(ke(i))return i;let c=await le.get(W).getPreOrderDetails({items:i.map(l=>fe(st,{id:l.productID,quantity:l.quantity})),projectId:e,postCode:a.postalCode,couponCode:a.couponCode,countryCode:a.country,selectedDeliveryMethod:a.selectedDeliveryMethod}),d=i.map(l=>({amount:`${_(l.quantity*(l.details?.pricing?.effectivePrice??l.details?.price??0)/100,2)}`,label:l.details?.name+" - "+l.quantity,type:"final"}));if(c.selectedDeliveryMethod!=null){let l=c.methods.find(m=>m.id==c.selectedDeliveryMethod);l!=null&&d.push({amount:`${_(l.amount/100,2)}`,label:l.name,type:"final"})}return c.couponCode!=null&&c.couponValue!=null&&d.push({amount:`-${_(c.couponValue/100,2)}`,label:c.couponCode,type:"final"}),{countryCode:c.country||a.country||"PL",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],total:{amount:`${_((c.totalAmount??0)/100,2)}`,label:Pe("paymentForCart",t,n),type:"final"},shippingMethods:c.methods.map(l=>({amount:`${_(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:d,currencyCode:c.currency||i[0]?.details?.currency||"PLN"}}}};async function li(e){let t=L();if(t.googlePayConfig?.isAvailable!=!0){let n=await le.get(W).isOneClickPaymentAvailable({projectId:e});n.googlePay==!0&&n.googlePayConfig!=null?t.googlePayConfig={isAvailable:!0,gateway:n.googlePayConfig.gateway,gatewayId:n.googlePayConfig.gatewayMerchantId,merchantName:n.googlePayConfig.merchantName,merchantId:n.googlePayConfig.merchantId}:t.googlePayConfig={isAvailable:!1,gateway:"",gatewayId:"",merchantName:"",merchantId:""}}return Q(t),t.googlePayConfig}function ui(e,t){if(e==t.id){let o=t.variants?.findIndex(r=>r.id===e);if(o!=null&&o!=-1){let r=t.variants[o];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(o=>o.id===e);return n==null?t:{...t,id:n.id,name:t.name+" "+n.name,baseName:t.name,variantName:n.name,price:n.price,currency:n.currency,pricing:n.pricing,metadata:t.metadata,availableQuantity:n.availableQuantity,isDeliverable:n.isDeliverable,images:n.images??t.images}}function $e(){let e=L(),t=0;if(e==null){Be.setState(n=>({...n,numberOfProductsInCart:t}));return}t=e.products?.reduce((n,o)=>n+o.quantity,0)??0,Be.setState(n=>({...n,numberOfProductsInCart:t}))}var pi=200,fi="item-ids-not-found",at="internal-error",Gr={"no-payment-gateway":"noPaymentGateway","gateway-not-configured":"gatewayNotConfigured","shipping-not-configured":"shippingNotConfigured","mixed-recurring":"mixedRecurring","currency-unsupported":"currencyUnsupported","price-changed":"priceChanged","product-not-found":"unavailableProducts","product-not-available":"unavailableProducts"},gi=new Set(["internal","invalid-request"]),yi=new Set(["product-not-available","product-not-found"]);function hi(e){return typeof e=="string"&&Object.hasOwn(Gr,e)?Gr[e]:void 0}function Pi(e){return/<\/?[a-z!?][^>]*>/i.test(e)}function bi(e){return/^[A-Za-z][A-Za-z0-9]*(?:[-_.:][A-Za-z0-9]+)*$/.test(e)&&!/^[A-Z][a-z]+$/.test(e)||/^\[object \w+\]$|^(?:undefined|null)$/.test(e)}function vi(e){return/Error:/.test(e)||/\n\s+at /.test(e)}function sn(e){let t=e.trim();if(!(t.length===0||t.length>pi||/[\r\n]/.test(t)||Pi(t)||bi(t)||vi(t)))return t}var wi=3;function Ct(e,t=0){if(typeof e=="object"&&e!=null){if(Array.isArray(e)||t>=wi)return{};let n=e,o=Ct(n.error,t+1);if(o.message==null&&n.message!=null){let r=Ct(n.message,t+1);o={...r,code:o.code??r.code}}return typeof n.code=="string"&&n.code.length>0&&(o.code=n.code),o}if(typeof e!="string")return{};try{let n=JSON.parse(e);return typeof n=="object"&&n!=null?Ct(n,t+1):{}}catch{}return{message:sn(e)}}function xi(e){let t;try{t=JSON.parse(e)}catch{return{code:at,message:sn(e)}}if(typeof t=="string")return{code:at,message:sn(t)};if(typeof t!="object"||t==null)return{code:at};let n=t,{message:o,code:r}=Ct(n.error),a={code:typeof n.code=="string"&&n.code.length>0?n.code:r??at,message:o};return Array.isArray(n.itemIds)&&(a.itemIds=n.itemIds.filter(i=>typeof i=="string")),a}function cn(e,t){let{code:n,message:o,itemIds:r}=xi(t),a=r!=null&&r.length>0;if(a&&(n===at||yi.has(n)))return H(fi,"badInput",r);let i={message:o};return a&&(i.itemIds=r),H(n,e>=500?"internal":"badInput",i)}function Wl(e,t){let n=hi(e.error);if(n!=null)return t(n);if(e.type==="internal"||typeof e.error=="string"&&gi.has(e.error))return t("checkoutFailed");let o=e.data?.message;return typeof o=="string"&&o.length>0?o:t("checkoutFailed")}var ki=["online","manual","cod"],Ci=["bankTransfer","blik"];function Vr(e,t){if(!Array.isArray(e))return[];let n=[];for(let o of e)t.includes(o)&&!n.includes(o)&&n.push(o);return n}function Ni(e){if(typeof e!="object"||e==null)return null;let t=e.choice;if(typeof t!="object"||t==null)return null;let n=Vr(t.methods,ki);return n.length<2?null:{methods:n,manualAccountTypes:Vr(t.manualAccountTypes,Ci)}}function Jl(e){if(e==null)return null;let t=e.methods.filter(n=>n!=="cod");return t.length<2?null:{...e,methods:t}}function Yl(e,t){return t!=null&&e.methods.includes(t)?t:e.methods[0]}function Ql(e){let t=e.includes("bankTransfer"),n=e.includes("blik");return n&&!t?"paymentMethodManualBlik":t&&!n?"paymentMethodManualTransfer":"paymentMethodManualBoth"}async function Kr(e,t,n=5e3){let o=typeof AbortController>"u"?void 0:new AbortController,r=setTimeout(()=>o?.abort(),n);try{let a=await fetch(e,{method:"POST",headers:t.headers,body:t.body,signal:o?.signal});return a.ok?Ni(await a.json()):null}catch{return null}finally{clearTimeout(r)}}var Ii;(o=>{async function e(r,a=1,i,c){let d=Ge();if(d==null)throw new Error("No project ID found");let m=await on(d).addProduct({productID:r,quantity:a,metadata:i,...c});if(m!=null)return m}o.addProductToCart=e;function t(){Be.setState({isCartVisible:!0})}o.showCart=t;function n(){Be.setState({isCartVisible:!1})}o.hideCart=n})(Ii||={});async function Wr(e){try{return await e.text()}catch{return""}}function Zr(e,t){return t=an(t),t.locale??=V(),{headers:{...St,...Et(e),"Content-Type":"application/json"},body:JSON.stringify(t)}}async function Br(e){let t=Ge();return t==null?null:Kr(Fe(t,"/payment-methods"),Zr(t,e))}async function nn(e){let t=Ge();if(t==null)throw new Error("No project ID found");let n=await fetch(Fe(t,"/buy"),{method:"POST",...Zr(t,e)});if(n.status!=200){let r=cn(n.status,await Wr(n));return console.warn("cannot create payment URL",n.status,r.error),r}let o=await n.json();return{url:o.url,...o.orderId!=null?{orderId:o.orderId}:{},...o.projectId!=null?{projectId:o.projectId}:{}}}async function cu(e){let t=Ge();if(t==null)throw new Error("No project ID found");let n={...St,...Et(t),"Content-Type":"application/json",...e.apiKey!=null?{Authorization:`Bearer ${e.apiKey}`}:{}},o=e.testMode?`/api/payment/link/auto/${t}/test`:`/api/payment/link/auto/${t}`;delete e.apiKey,delete e.testMode,e.locale??=V();let r=await fetch(W+o,{method:"POST",headers:n,body:JSON.stringify(e)});return r.ok?{status:"ok",redirectURL:(await r.json()).url}:{...cn(r.status,await Wr(r)),status:"error"}}function xt(){if(typeof localStorage>"u")return;let e=localStorage.getItem("bitsnap-ref");if(e!=null)return e}function an(e){let t=xt();return t==null||(e.metadata==null&&(e.metadata={}),e.metadata.ref=t),e}export{le as a,ue as b,be as c,ve as d,Mt as e,me as f,On as g,Ut as h,Se as i,Qe as j,Xe as k,Me as l,Ue as m,ya as n,Fn as o,Zt as p,Do as q,_ as r,Nr as s,Jt as t,ke as u,fi as v,Wl as w,Jl as x,Yl as y,Ql as z,Be as A,Ii as B,Br as C,nn as D,cu as E,xt as F,an as G,sl as H,cl as I,dl as J,ml as K,ei as L,rn as M,zl as N,Ge as O,ql as P,Fl as Q,oi as R,Bl as S,Hl as T,on as U};
|
|
4
|
+
//# sourceMappingURL=chunk-5GMWRCHK.mjs.map
|