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