bitsnap-react 1.17.0 → 1.18.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 +31 -0
- package/dist/CartProvider-ECQQH3PS.css +2 -0
- package/dist/CartProvider-ECQQH3PS.css.map +1 -0
- package/dist/CartProvider-OEI526IN.js +2 -0
- package/dist/{CartProvider-YVOHSMPE.js.map → CartProvider-OEI526IN.js.map} +1 -1
- package/dist/CartProvider-RYAA3JDA.mjs +2 -0
- package/dist/{PanelModelFiles-NYCOFPLY.js → PanelModelFiles-7HPXWONN.js} +2 -2
- package/dist/{PanelModelFiles-NYCOFPLY.js.map → PanelModelFiles-7HPXWONN.js.map} +1 -1
- package/dist/PanelModelFiles-JZFSF7BF.mjs +2 -0
- package/dist/PanelModelFiles-JZFSF7BF.mjs.map +1 -0
- package/dist/analytics.js +1 -1
- package/dist/analytics.mjs +1 -1
- package/dist/catalog.css +1 -1
- package/dist/catalog.css.map +1 -1
- package/dist/catalog.d.mts +2 -0
- package/dist/catalog.d.ts +2 -0
- package/dist/catalog.js +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/{chunk-ESF5ZVVF.js → chunk-4HGZZJEL.js} +2 -2
- package/dist/{chunk-ESF5ZVVF.js.map → chunk-4HGZZJEL.js.map} +1 -1
- package/dist/{chunk-HKNWW37T.mjs → chunk-4OVOKGGS.mjs} +2 -2
- package/dist/{chunk-A6VCP3A4.mjs → chunk-5X7TP3TQ.mjs} +2 -2
- package/dist/{chunk-2UDAB2C5.mjs → chunk-CF45RDMD.mjs} +2 -2
- package/dist/{chunk-2UDAB2C5.mjs.map → chunk-CF45RDMD.mjs.map} +1 -1
- package/dist/{chunk-C3BBJOVV.js → chunk-DP2NOHCI.js} +2 -2
- package/dist/{chunk-C3BBJOVV.js.map → chunk-DP2NOHCI.js.map} +1 -1
- package/dist/{chunk-L7Q7OKM5.mjs → chunk-EVIDNS22.mjs} +2 -2
- package/dist/{chunk-SYN5KU3O.js → chunk-G4V2KWTV.js} +2 -2
- package/dist/{chunk-SYN5KU3O.js.map → chunk-G4V2KWTV.js.map} +1 -1
- package/dist/{chunk-X3LVYIJR.mjs → chunk-GEBRXFT3.mjs} +2 -2
- package/dist/chunk-GWF3MRUP.js +2 -0
- package/dist/chunk-GWF3MRUP.js.map +1 -0
- package/dist/{chunk-MIMQTH2G.js → chunk-JA62KNAQ.js} +2 -2
- package/dist/{chunk-MIMQTH2G.js.map → chunk-JA62KNAQ.js.map} +1 -1
- package/dist/{chunk-BZXV77PT.mjs → chunk-JHJ3ZZF4.mjs} +2 -2
- package/dist/{chunk-M2G74N43.mjs → chunk-UPAOIY4R.mjs} +2 -2
- package/dist/chunk-V5ECGBFW.js +5 -0
- package/dist/chunk-V5ECGBFW.js.map +1 -0
- package/dist/{chunk-4BL7TLK3.js → chunk-VNV5BD4X.js} +2 -2
- package/dist/{chunk-4BL7TLK3.js.map → chunk-VNV5BD4X.js.map} +1 -1
- package/dist/chunk-WJO5GSY3.mjs +5 -0
- package/dist/chunk-WJO5GSY3.mjs.map +1 -0
- package/dist/{chunk-5FZAROP6.js → chunk-ZATPBYOA.js} +2 -2
- package/dist/{chunk-5FZAROP6.js.map → chunk-ZATPBYOA.js.map} +1 -1
- package/dist/chunk-ZHTMK5TA.mjs +2 -0
- package/dist/chunk-ZHTMK5TA.mjs.map +1 -0
- package/dist/course.d.mts +10 -0
- package/dist/course.d.ts +10 -0
- 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 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- 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/methods-AULQDKVS.mjs +2 -0
- package/dist/methods-OJEZREBK.css +2 -0
- package/dist/methods-OJEZREBK.css.map +1 -0
- package/dist/methods-PMH5VQ25.js +2 -0
- package/dist/{methods-3W34GRYL.js.map → methods-PMH5VQ25.js.map} +1 -1
- package/dist/returns.js +1 -1
- package/dist/returns.mjs +1 -1
- package/dist/viewer3d.css +1 -1
- package/dist/viewer3d.css.map +1 -1
- package/dist/viewer3d.mjs +1 -1
- package/package.json +2 -2
- package/dist/CartProvider-DGRZDTYC.mjs +0 -2
- package/dist/CartProvider-PDEV6GCV.css +0 -2
- package/dist/CartProvider-PDEV6GCV.css.map +0 -1
- package/dist/CartProvider-YVOHSMPE.js +0 -2
- package/dist/PanelModelFiles-RV7OHUUZ.mjs +0 -2
- package/dist/PanelModelFiles-RV7OHUUZ.mjs.map +0 -1
- package/dist/chunk-2NL5FCXC.mjs +0 -4
- package/dist/chunk-2NL5FCXC.mjs.map +0 -1
- package/dist/chunk-4ETIDGYZ.mjs +0 -2
- package/dist/chunk-4ETIDGYZ.mjs.map +0 -1
- package/dist/chunk-555KFWGY.js +0 -4
- package/dist/chunk-555KFWGY.js.map +0 -1
- package/dist/chunk-6GCCNBEU.js +0 -2
- package/dist/chunk-6GCCNBEU.js.map +0 -1
- package/dist/methods-3W34GRYL.js +0 -2
- package/dist/methods-LUJSKSQ4.mjs +0 -2
- package/dist/methods-QAZED7TJ.css +0 -2
- package/dist/methods-QAZED7TJ.css.map +0 -1
- /package/dist/{CartProvider-DGRZDTYC.mjs.map → CartProvider-RYAA3JDA.mjs.map} +0 -0
- /package/dist/{chunk-HKNWW37T.mjs.map → chunk-4OVOKGGS.mjs.map} +0 -0
- /package/dist/{chunk-A6VCP3A4.mjs.map → chunk-5X7TP3TQ.mjs.map} +0 -0
- /package/dist/{chunk-L7Q7OKM5.mjs.map → chunk-EVIDNS22.mjs.map} +0 -0
- /package/dist/{chunk-X3LVYIJR.mjs.map → chunk-GEBRXFT3.mjs.map} +0 -0
- /package/dist/{chunk-BZXV77PT.mjs.map → chunk-JHJ3ZZF4.mjs.map} +0 -0
- /package/dist/{chunk-M2G74N43.mjs.map → chunk-UPAOIY4R.mjs.map} +0 -0
- /package/dist/{methods-LUJSKSQ4.mjs.map → methods-AULQDKVS.mjs.map} +0 -0
package/dist/chunk-4ETIDGYZ.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as O,b as at,c as it,d as st,e as dt,f as F}from"./chunk-M2G74N43.mjs";import{a as ot,b as nt}from"./chunk-KOVKUJAW.mjs";import{a as U}from"./chunk-5R6AGO3Z.mjs";import{e as rt}from"./chunk-X3LVYIJR.mjs";import{f as X,l as Z,m as J,n as Y,p as Q}from"./chunk-2UDAB2C5.mjs";import{b as tt,d as et}from"./chunk-VNYHJT6V.mjs";var xt=["root","grid","card","cardLink","image","imagePlaceholder","body","name","description","price","comparePrice","badge","model3dBadge","actions","addToCartButton","selectButton","message","pagination","paginationButton","pageIndicator","emptyState","error","retryButton","skeleton"],ht={fontFamily:"--bitsnap-products-font-family",fontSize:"--bitsnap-products-font-size",background:"--bitsnap-products-background",surface:"--bitsnap-products-surface",foreground:"--bitsnap-products-foreground",mutedForeground:"--bitsnap-products-muted-foreground",border:"--bitsnap-products-border",buttonBackground:"--bitsnap-products-button-background",buttonForeground:"--bitsnap-products-button-foreground",buttonHoverBackground:"--bitsnap-products-button-hover-background",hoverSurface:"--bitsnap-products-hover-surface",focusRing:"--bitsnap-products-focus-ring",error:"--bitsnap-products-error",badgeBackground:"--bitsnap-products-badge-background",badgeForeground:"--bitsnap-products-badge-foreground",radius:"--bitsnap-products-radius"},Tt={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",radius:"8px"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",radius:"8px"}},Ct=[];function ct(t){let e=ot(t,{defaultTheme:"light",presets:Tt,variables:ht,shadcnVariables:Ct});return{theme:e.theme,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle}}function j(t,e){return nt(t.elements,e)}import{useCallback as ut,useEffect as St,useMemo as kt,useState as M}from"react";function q(t){let{projectID:e,locale:n,search:o,initialData:i}=t,[a]=M(()=>rt),d=t.host??a,c=O(t.pageSize),s=JSON.stringify([e,d,n??null,o?.trim()??null,c]),[g,l]=M({queryKey:s,page:1});g.queryKey!==s&&l({queryKey:s,page:1});let[P,C]=M(0),[m,p]=M(()=>({requestKey:i!=null?`${s}|1|0`:"",data:i,error:void 0})),f=m.data?.totalCount??0,b=at(f,c),x=g.queryKey===s?g.page:1,k=f>0?Math.min(x,b):x,S=`${s}|${k}|${P}`,T=m.requestKey===S;St(()=>{if(T)return;let y=new AbortController;return it({projectID:e,host:d,locale:n,search:o,limit:c,offset:(k-1)*c},y.signal).then(L=>{y.signal.aborted||p({requestKey:S,data:L,error:void 0})},L=>{y.signal.aborted||p(E=>({requestKey:S,data:E.data,error:L instanceof Error?L:new Error(String(L))}))}),()=>y.abort()},[S,T]);let I=ut(y=>{let L=Math.max(1,Math.floor(y));l({queryKey:s,page:f>0?Math.min(L,b):L})},[s,f,b]),A=ut(()=>C(y=>y+1),[]);return kt(()=>({products:m.data?.items??[],totalCount:f,page:k,pageCount:b,setPage:I,isLoading:!T,error:T?m.error:void 0,refetch:A}),[m,f,k,b,I,T,A])}import{createContext as gt,useCallback as K,useContext as mt,useEffect as B,useMemo as R,useRef as H,useState as It}from"react";var z=50,At=1e3;function lt(t,e=At){let n=new Set,o=new Map,i=[],a=[],d,c,s=!1;function g(){for(c!==void 0&&clearTimeout(c),c=void 0;i.length>0;){let p=i.slice(0,z),f=a.slice(0,z);i=i.slice(z),a=a.slice(z);try{t({productIds:p,positions:f})}catch{}}}function l(){g();try{X()?.flush()}catch{}}let P=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&l()};function C(){s||typeof window>"u"||(s=!0,window.addEventListener("pagehide",l,!0),document.addEventListener("visibilitychange",P,!0))}function m(){if(d)return d;if(!(typeof IntersectionObserver>"u"))return d=new IntersectionObserver(p=>{for(let f of p){let b=o.get(f.target);!b||!f.isIntersecting||f.intersectionRatio<.5||(o.delete(f.target),d?.unobserve(f.target),!n.has(b.id)&&(n.add(b.id),i.push(b.id),a.push(b.position)))}i.length>0&&c===void 0&&(c=setTimeout(g,e),c.unref?.())},{threshold:[.5]}),C(),d}return{observe(p,f,b){try{if(n.has(f))return()=>{};let x=m();return x?(o.set(p,{id:f,position:b}),x.observe(p),()=>{o.delete(p),x.unobserve(p)}):()=>{}}catch{return()=>{}}},flush:g,destroy(){try{g(),d?.disconnect(),s&&(window.removeEventListener("pagehide",l,!0),document.removeEventListener("visibilitychange",P,!0),s=!1)}catch{}d=void 0,o.clear()}}}var wt={en:{addToCart:"Add to cart",addingToCart:"Adding\u2026",addedToCart:"Added to cart",addToCartError:"Could not add to the cart. Try again.",chooseOptions:"Choose",viewProduct:"View",unavailable:"Unavailable",subscription:"Subscription",model3d:"3D",model3dLabel:"3D model",priceFrom:"from {price}",originalPrice:"Original price",loading:"Loading products",empty:"There are no products to show.",error:"Could not load the products.",retry:"Try again",pagination:"Pagination",previousPage:"Previous",nextPage:"Next",pageOf:"Page {page} of {pageCount}"},pl:{addToCart:"Dodaj do koszyka",addingToCart:"Dodawanie\u2026",addedToCart:"Dodano do koszyka",addToCartError:"Nie uda\u0142o si\u0119 doda\u0107 do koszyka. Spr\xF3buj ponownie.",chooseOptions:"Wybierz",viewProduct:"Zobacz",unavailable:"Niedost\u0119pny",subscription:"Subskrypcja",model3d:"3D",model3dLabel:"Model 3D",priceFrom:"od {price}",originalPrice:"Cena przed obni\u017Ck\u0105",loading:"\u0141adowanie produkt\xF3w",empty:"Brak produkt\xF3w do wy\u015Bwietlenia.",error:"Nie uda\u0142o si\u0119 za\u0142adowa\u0107 produkt\xF3w.",retry:"Spr\xF3buj ponownie",pagination:"Paginacja",previousPage:"Poprzednia",nextPage:"Nast\u0119pna",pageOf:"Strona {page} z {pageCount}"}};function pt(t,e){return tt(wt,t,e)}function V(t,e){return t.replace(/\{(\w+)\}/g,(n,o)=>o in e?String(e[o]):n)}import{Fragment as Lt,jsx as r,jsxs as h}from"react/jsx-runtime";var ft=gt(void 0),Et={observe:()=>()=>{},clicked:()=>{}},bt=gt(Et);function D(){let t=mt(ft);if(t==null)throw new Error("ProductList parts must be rendered inside ProductList");return t}function u(t,e){let{appearance:n}=D(),o=j(n,t);return{"data-bitsnap-products-slot":t,className:U(e,o?.className),style:o?.style}}var $="inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50",Pt=`${$} w-full`,_t=`${Pt} no-underline`;function Nt({product:t,onAdd:e}){let{texts:n}=D(),[o,i]=It("idle"),a=u("addToCartButton",Pt),d=u("message","mt-2 text-xs");B(()=>{if(o!=="added")return;let g=setTimeout(()=>i("idle"),2e3);return()=>clearTimeout(g)},[o]);let c=K(async()=>{i("adding");try{await e(),i("added")}catch(g){console.error("bitsnap-react: could not add to the cart",g),i("error")}},[e]),s=o==="adding"?n.addingToCart:o==="added"?n.addedToCart:n.addToCart;return h(Lt,{children:[r("button",{type:"button",...a,disabled:o==="adding","aria-label":`${s}: ${t.name}`,onClick:c,children:s}),o==="error"?r("p",{...d,role:"alert",children:n.addToCartError}):null]})}function Ot({product:t,position:e,href:n,onAdd:o,renderItem:i}){let{texts:a,locale:d}=D(),c=mt(bt),s=H(null);B(()=>{if(s.current!=null)return c.observe(s.current,t.id,e)},[c,t.id,e]);let g=K(()=>c.clicked(t,e),[c,t,e]),l=u("card","relative flex flex-col overflow-hidden border transition-colors"),P=u("cardLink","flex flex-1 flex-col no-underline"),C=u("image","aspect-square w-full overflow-hidden"),m=u("imagePlaceholder","aspect-square w-full"),p=u("body","flex flex-1 flex-col gap-1 p-4"),f=u("name","text-base font-medium leading-snug"),b=u("description","line-clamp-2 text-sm"),x=u("price","mt-auto pt-2 text-base font-semibold"),k=u("comparePrice","ml-2 text-sm font-normal"),S=u("badge","absolute left-3 top-3 px-2 py-0.5 text-xs font-medium"),T=u("model3dBadge","absolute right-3 top-3 inline-flex items-center gap-1 px-2 py-0.5 text-xs font-semibold"),I=u("actions","p-4 pt-0"),A=u("selectButton",_t),y=F(t.price,t.currency,d),L=t.compareAtPrice!=null&&t.compareAtPrice>t.price?F(t.compareAtPrice,t.currency,d):null;if(i!=null)return r("li",{ref:s,...l,"data-unavailable":t.available?void 0:"",children:i(t,{href:n,price:y,compareAtPrice:L,texts:a,locale:d,addToCart:o,trackClick:g})});let E=t.image?.thumbnailUrl??t.image?.url,_=t.available?t.isRecurring?a.subscription:null:a.unavailable;return h("li",{ref:s,...l,"data-unavailable":t.available?void 0:"",children:[h("a",{...P,href:n,onClick:g,children:[E!=null?r("div",{...C,children:r("img",{src:E,alt:"",loading:"lazy",decoding:"async",className:"h-full w-full object-cover"})}):r("div",{...m,"aria-hidden":"true"}),h("div",{...p,children:[r("h3",{...f,children:t.name}),t.shortDescription?r("p",{...b,children:t.shortDescription}):null,h("p",{...x,children:[t.priceFrom?V(a.priceFrom,{price:y}):y,L!=null?h(Lt,{children:[h("span",{className:"sr-only",children:[a.originalPrice,": "]}),r("del",{...k,children:L})]}):null]})]})]}),_!=null?r("span",{...S,"data-kind":t.available?"subscription":"unavailable",children:_}):null,t.has3d===!0?h("span",{...T,title:a.model3dLabel,children:[r(Bt,{}),r("span",{"aria-hidden":"true",children:a.model3d}),r("span",{className:"sr-only",children:a.model3dLabel})]}):null,r("div",{...I,children:t.available?t.addToCart?r(Nt,{product:t,onAdd:o}):r("a",{...A,href:n,onClick:g,children:t.variantCount>1?a.chooseOptions:a.viewProduct}):r("button",{type:"button",...A,disabled:!0,children:a.unavailable})})]})}function Bt(){return h("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),r("path",{d:"m3.3 7 8.7 5 8.7-5"}),r("path",{d:"M12 22V12"})]})}var yt="m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-5 p-0";function Rt({count:t,label:e}){let n=u("grid",yt),o=u("skeleton","aspect-[3/4] animate-pulse");return r("div",{...n,role:"status","aria-busy":"true","aria-label":e,children:Array.from({length:t},(i,a)=>r("div",{...o,"aria-hidden":"true"},a))})}function Dt({page:t,pageCount:e,isLoading:n,onPage:o}){let{texts:i}=D(),a=u("pagination","mt-8 flex items-center justify-center gap-4"),d=u("paginationButton",$),c=u("pageIndicator","text-sm");return h("nav",{...a,"aria-label":i.pagination,children:[r("button",{type:"button",...d,"aria-disabled":n||t<=1,onClick:()=>{!n&&t>1&&o(t-1)},children:i.previousPage}),r("span",{...c,"aria-live":"polite",children:V(i.pageOf,{page:t,pageCount:e})}),r("button",{type:"button",...d,"aria-disabled":n||t>=e,onClick:()=>{!n&&t<e&&o(t+1)},children:i.nextPage})]})}function Ut({options:t,productHref:e,renderItem:n,onAddToCart:o,showCartOnAdd:i}){let{texts:a}=D(),{products:d,page:c,pageCount:s,setPage:g,isLoading:l,error:P,refetch:C}=q(t),m=J(),p=t.search?.trim()?"search":"catalog",f=O(t.pageSize),b=H(!1);B(()=>{b.current||l||P!=null||(b.current=!0,m.track("product_list_viewed",{list_id:p,item_count:d.length}))},[m,l,P,p,d.length]);let x=R(()=>lt(({productIds:v,positions:w})=>m.track("product_impression",{list_id:p,product_ids:v,positions:w})),[m,p]);B(()=>()=>x.destroy(),[x]);let k=R(()=>({observe:x.observe,clicked:(v,w)=>m.track("product_clicked",{list_id:p,position:w},{product_id:v.id})}),[x,m,p]),S=H(null),T=H(!1),I=K(v=>{T.current=!0,g(v)},[g]);B(()=>{l||!T.current||(T.current=!1,S.current?.focus({preventScroll:!0}),S.current?.scrollIntoView({block:"start"}))},[l]);let A=u("grid",yt),y=u("emptyState","py-12 text-center text-sm"),L=u("error","flex flex-col items-center gap-3 py-12 text-center text-sm"),E=u("retryButton",$),{projectID:_,host:G}=t,vt=K((v,w)=>async()=>{if(o!=null){await Q(()=>o(v)),st(m,v);return}await dt(v,{projectID:_,host:G,showCart:i,analytics:m,url:w})},[o,_,G,i,m]),N;return l&&d.length===0?N=r(Rt,{count:Math.min(O(t.pageSize),8),label:a.loading}):P!=null?N=h("div",{...L,role:"alert",children:[r("p",{children:a.error}),r("button",{type:"button",...E,onClick:C,children:a.retry})]}):d.length===0?N=r("p",{...y,children:a.empty}):N=r("ul",{...A,"aria-busy":l||void 0,className:U(A.className,l&&"opacity-60"),children:d.map((v,w)=>{let W=e(v);return r(Ot,{product:v,position:(c-1)*f+w,href:W,onAdd:vt(v,W),renderItem:n},v.id)})}),r(bt.Provider,{value:k,children:h("div",{ref:S,tabIndex:-1,className:"p-1 outline-none scroll-mt-4",children:[N,s>1&&P==null?r(Dt,{page:c,pageCount:s,isLoading:l,onPage:I}):null]})})}var Ft=t=>`/p/${encodeURIComponent(t.uniqueSlug)}`;function Mt({productHref:t=Ft,appearance:e,texts:n,renderItem:o,onAddToCart:i,showCartOnAdd:a=!0,className:d,analytics:c,...s}){let g=Y(s.projectID,c,"catalog"),l=s.locale??et,P=R(()=>ct(e),[e]),C=R(()=>pt(l,n),[l,n]),m=R(()=>({appearance:P,texts:C,locale:l}),[P,C,l]),p=j(P,"root");return r(Z,{value:g,children:r(ft.Provider,{value:m,children:r("div",{"data-bitsnap-products":"root","data-bitsnap-products-slot":"root",className:U("bitsnap-react",P.boundaryClassName,d,p?.className),style:{...P.boundaryStyle,...p?.style},children:r(Ut,{options:s,productHref:t,renderItem:o,onAddToCart:i,showCartOnAdd:a})})})})}export{xt as a,q as b,Mt as c};
|
|
2
|
-
//# sourceMappingURL=chunk-4ETIDGYZ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/products/appearance.ts","../src/components/products/useProducts.ts","../src/components/products/ProductList.tsx","../src/components/products/impressions.ts","../src/components/products/texts.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport {\n getSlotAppearance,\n resolveAppearanceCore,\n type AppearanceElements,\n type ShadcnVariableMapping,\n type SlotAppearance,\n} from \"@/src/lib/appearance-core\";\n\n/**\n * Product list appearance API.\n *\n * It mirrors `CheckoutAppearance` and `ReturnsAppearance` (theme, tokens,\n * elements) so a shop can reuse one brand object for all of them. The resolver\n * is pure: it turns the caller input into a theme name, the tokens in effect,\n * the slot overrides and the inline style for the theme boundary.\n */\n\nexport type ProductListTheme = \"light\" | \"dark\";\n\nexport type ProductListAppearanceTokens = {\n /** Font family of the list. The library never loads fonts. */\n fontFamily?: string;\n /** Base font size. */\n fontSize?: string;\n /** List background. */\n background?: string;\n /** Raised surfaces: cards, image placeholders, skeletons. */\n surface?: string;\n /** Main text color. */\n foreground?: string;\n /** Secondary text: descriptions, the struck-through price. */\n mutedForeground?: string;\n /** Borders of cards and buttons. */\n border?: string;\n /** \"Add to cart\" button background. */\n buttonBackground?: string;\n /** \"Add to cart\" button text. */\n buttonForeground?: string;\n /** \"Add to cart\" button background on hover. */\n buttonHoverBackground?: string;\n /** Hover surface of cards and secondary buttons. */\n hoverSurface?: string;\n /** Focus ring color. */\n focusRing?: string;\n /** Error and unavailable state color. */\n error?: string;\n /** Badge background (subscription, unavailable). */\n badgeBackground?: string;\n /** Badge text. */\n badgeForeground?: string;\n /** Corner radius of cards, images and buttons. */\n radius?: string;\n};\n\n/**\n * Stable slot names. They are exposed as `data-bitsnap-products-slot`\n * attributes so they can also be targeted from plain CSS.\n */\nexport const PRODUCT_LIST_SLOT_NAMES = [\n \"root\",\n \"grid\",\n \"card\",\n \"cardLink\",\n \"image\",\n \"imagePlaceholder\",\n \"body\",\n \"name\",\n \"description\",\n \"price\",\n \"comparePrice\",\n \"badge\",\n \"model3dBadge\",\n \"actions\",\n \"addToCartButton\",\n \"selectButton\",\n \"message\",\n \"pagination\",\n \"paginationButton\",\n \"pageIndicator\",\n \"emptyState\",\n \"error\",\n \"retryButton\",\n \"skeleton\",\n] as const;\n\nexport type ProductListSlotName = (typeof PRODUCT_LIST_SLOT_NAMES)[number];\n\nexport type ProductListSlotAppearance = SlotAppearance;\n\nexport type ProductListAppearanceElements =\n AppearanceElements<ProductListSlotName>;\n\nexport type ProductListAppearance = {\n /** `\"light\"` or `\"dark\"`. Omitted means `\"light\"`. */\n theme?: ProductListTheme;\n /** Partial overrides applied over the theme preset. */\n tokens?: ProductListAppearanceTokens;\n /** Per element `className`/`style` overrides. */\n elements?: ProductListAppearanceElements;\n};\n\nexport type ResolvedProductListAppearance = {\n theme: ProductListTheme;\n /** Tokens that are in effect (the theme preset plus caller overrides). */\n tokens: ProductListAppearanceTokens;\n elements: ProductListAppearanceElements;\n /** Theme marker class for the theme boundary. */\n boundaryClassName: string;\n /** Inline custom properties applied to the list root. */\n boundaryStyle: CSSProperties;\n};\n\n/** CSS custom property used for each token. */\nexport const PRODUCT_LIST_TOKEN_VARIABLES = {\n fontFamily: \"--bitsnap-products-font-family\",\n fontSize: \"--bitsnap-products-font-size\",\n background: \"--bitsnap-products-background\",\n surface: \"--bitsnap-products-surface\",\n foreground: \"--bitsnap-products-foreground\",\n mutedForeground: \"--bitsnap-products-muted-foreground\",\n border: \"--bitsnap-products-border\",\n buttonBackground: \"--bitsnap-products-button-background\",\n buttonForeground: \"--bitsnap-products-button-foreground\",\n buttonHoverBackground: \"--bitsnap-products-button-hover-background\",\n hoverSurface: \"--bitsnap-products-hover-surface\",\n focusRing: \"--bitsnap-products-focus-ring\",\n error: \"--bitsnap-products-error\",\n badgeBackground: \"--bitsnap-products-badge-background\",\n badgeForeground: \"--bitsnap-products-badge-foreground\",\n radius: \"--bitsnap-products-radius\",\n} as const;\n\nexport type ProductListTokenName = keyof typeof PRODUCT_LIST_TOKEN_VARIABLES;\n\n/**\n * Complete palettes. They carry colors and radius only, so typography is never\n * reset implicitly. `products.css` falls back to the light values, which keeps\n * the list usable even when the boundary style is missing.\n */\nexport const PRODUCT_LIST_THEME_PRESETS: Record<\n ProductListTheme,\n ProductListAppearanceTokens\n> = {\n light: {\n background: \"#ffffff\",\n surface: \"#f9fafb\",\n foreground: \"#18181b\",\n mutedForeground: \"#71717a\",\n border: \"#e4e4e7\",\n buttonBackground: \"#18181b\",\n buttonForeground: \"#fafafa\",\n buttonHoverBackground: \"#000000\",\n hoverSurface: \"#f4f4f5\",\n focusRing: \"#71717a\",\n error: \"#dc2626\",\n badgeBackground: \"#f4f4f5\",\n badgeForeground: \"#3f3f46\",\n radius: \"8px\",\n },\n dark: {\n background: \"#18181b\",\n surface: \"#27272a\",\n foreground: \"#fafafa\",\n mutedForeground: \"#a1a1aa\",\n border: \"#3f3f46\",\n buttonBackground: \"#fafafa\",\n buttonForeground: \"#18181b\",\n buttonHoverBackground: \"#e4e4e7\",\n hoverSurface: \"#3f3f46\",\n focusRing: \"#a1a1aa\",\n error: \"#f87171\",\n badgeBackground: \"#3f3f46\",\n badgeForeground: \"#e4e4e7\",\n radius: \"8px\",\n },\n};\n\n/** The list renders its own elements, so no shared primitive needs remapping. */\nconst PRODUCT_LIST_SHADCN_VARIABLES: ShadcnVariableMapping<ProductListTokenName> =\n [];\n\nexport function resolveProductListAppearance(\n appearance?: ProductListAppearance,\n): ResolvedProductListAppearance {\n const resolved = resolveAppearanceCore<\n ProductListTokenName,\n ProductListTheme,\n ProductListSlotName\n >(appearance, {\n defaultTheme: \"light\",\n presets: PRODUCT_LIST_THEME_PRESETS,\n variables: PRODUCT_LIST_TOKEN_VARIABLES,\n shadcnVariables: PRODUCT_LIST_SHADCN_VARIABLES,\n });\n\n return {\n theme: resolved.theme,\n tokens: resolved.tokens,\n elements: resolved.elements,\n boundaryClassName: resolved.theme,\n boundaryStyle: resolved.boundaryStyle,\n };\n}\n\n/** Caller overrides for a single slot, if any were provided. */\nexport function getProductListSlotAppearance(\n resolved: ResolvedProductListAppearance,\n slot: ProductListSlotName,\n): ProductListSlotAppearance | undefined {\n return getSlotAppearance(resolved.elements, slot);\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { HOST } from \"../checkout/constants\";\nimport {\n clampPageSize,\n fetchProductList,\n pageCountFor,\n type ProductListData,\n type PublicListProduct,\n} from \"./fetch\";\n\nexport type UseProductsOptions = {\n /** Project (shop) ID. */\n projectID: string;\n /**\n * Origin of the Bitsnap backend. Defaults to the library host\n * (`https://bitsnap.pl`, or what `setCustomHost` had set when the component\n * first rendered; later `setCustomHost` calls do not move an existing list).\n * On a custom domain pass the domain itself, or an empty string for\n * same-origin requests.\n */\n host?: string;\n locale?: string;\n /** Products per page, 1 to 48. Defaults to 24. */\n pageSize?: number;\n search?: string;\n /**\n * First page, loaded on the server. It is always used for the first request\n * of the mounted list (the first fetch is skipped and the products are\n * available on the first render), so it has to be the page the props ask\n * for: page 1 with the same `pageSize`, `locale` and `search`. Later changes\n * of the props fetch again.\n */\n initialData?: ProductListData;\n};\n\nexport type UseProductsResult = {\n /** Products of the current page. Keeps the previous page while loading. */\n products: PublicListProduct[];\n totalCount: number;\n /** Current page, starting at 1. */\n page: number;\n pageCount: number;\n setPage: (page: number) => void;\n /** `true` until the current page is available, also during server rendering. */\n isLoading: boolean;\n error: Error | undefined;\n /** Loads the current page again. */\n refetch: () => void;\n};\n\ntype Snapshot = {\n /** Request the data belongs to; empty when it is not tied to one. */\n requestKey: string;\n data: ProductListData | undefined;\n error: Error | undefined;\n};\n\n/**\n * Loads the product catalog page by page. It uses a plain `fetch` without\n * credentials, never reads global state (`setProjectID`, `setCustomHost`) other\n * than the default host, and does nothing during server rendering - pass\n * `initialData` to render products in the server HTML.\n */\nexport function useProducts(options: UseProductsOptions): UseProductsResult {\n const { projectID, locale, search, initialData } = options;\n // The library host is a mutable global; read it once so a later\n // `setCustomHost` does not change the query of a mounted list.\n const [defaultHost] = useState(() => HOST);\n const host = options.host ?? defaultHost;\n const pageSize = clampPageSize(options.pageSize);\n\n // Everything that identifies a list; a change resets the page.\n const queryKey = JSON.stringify([\n projectID,\n host,\n locale ?? null,\n search?.trim() ?? null,\n pageSize,\n ]);\n\n const [pageState, setPageState] = useState({ queryKey, page: 1 });\n if (pageState.queryKey !== queryKey) {\n // Another list: start from page 1 (adjusting state while rendering).\n setPageState({ queryKey, page: 1 });\n }\n const [reloads, setReloads] = useState(0);\n const [snapshot, setSnapshot] = useState<Snapshot>(() => ({\n requestKey: initialData != null ? `${queryKey}|1|0` : \"\",\n data: initialData,\n error: undefined,\n }));\n\n // A page past the end (the catalog shrank) falls back to the last page once\n // the total is known.\n const totalCount = snapshot.data?.totalCount ?? 0;\n const pageCount = pageCountFor(totalCount, pageSize);\n const requestedPage = pageState.queryKey === queryKey ? pageState.page : 1;\n const page = totalCount > 0 ? Math.min(requestedPage, pageCount) : requestedPage;\n\n const requestKey = `${queryKey}|${page}|${reloads}`;\n\n const isCurrent = snapshot.requestKey === requestKey;\n\n useEffect(() => {\n if (isCurrent) {\n return;\n }\n\n const controller = new AbortController();\n fetchProductList(\n {\n projectID,\n host,\n locale,\n search,\n limit: pageSize,\n offset: (page - 1) * pageSize,\n },\n controller.signal,\n ).then(\n (data) => {\n if (controller.signal.aborted) {\n return;\n }\n setSnapshot({ requestKey, data, error: undefined });\n },\n (error: unknown) => {\n if (controller.signal.aborted) {\n return;\n }\n setSnapshot((previous) => ({\n requestKey,\n data: previous.data,\n error: error instanceof Error ? error : new Error(String(error)),\n }));\n },\n );\n\n return () => controller.abort();\n // `requestKey` carries projectID, host, locale, search, pageSize, page and\n // the reload counter.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [requestKey, isCurrent]);\n\n const setPage = useCallback(\n (next: number) => {\n const target = Math.max(1, Math.floor(next));\n setPageState({\n queryKey,\n page: totalCount > 0 ? Math.min(target, pageCount) : target,\n });\n },\n [queryKey, totalCount, pageCount],\n );\n\n const refetch = useCallback(() => setReloads((value) => value + 1), []);\n\n return useMemo(\n () => ({\n products: snapshot.data?.items ?? [],\n totalCount,\n page,\n pageCount,\n setPage,\n isLoading: !isCurrent,\n error: isCurrent ? snapshot.error : undefined,\n refetch,\n }),\n [snapshot, totalCount, page, pageCount, setPage, isCurrent, refetch],\n );\n}\n","import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { CSSProperties, ReactNode } from \"react\";\nimport { cn } from \"@/src/lib/utils\";\nimport {\n InstrumentProvider,\n useInstrument,\n useInstrumentContext,\n withCartAnalyticsMuted,\n type AnalyticsOption,\n type Instrument,\n} from \"@/src/analytics/instrument\";\nimport { DEFAULT_LOCALE } from \"../checkout/locale\";\nimport { addProductToCart, trackProductAdded } from \"./add-to-cart\";\nimport {\n getProductListSlotAppearance,\n resolveProductListAppearance,\n type ProductListAppearance,\n type ProductListSlotName,\n type ResolvedProductListAppearance,\n} from \"./appearance\";\nimport { clampPageSize, type PublicListProduct } from \"./fetch\";\nimport { formatProductPrice } from \"./format\";\nimport { createImpressionTracker } from \"./impressions\";\nimport {\n fillProductListText,\n resolveProductListTexts,\n type ProductListTexts,\n} from \"./texts\";\nimport { useProducts, type UseProductsOptions } from \"./useProducts\";\n\n/** What `renderItem` gets next to the product. */\nexport type ProductListItemContext = {\n /** Product page URL from `productHref`. */\n href: string;\n /** Price formatted for the locale and currency, without the \"from\" prefix. */\n price: string;\n /** Formatted regular price when the product is discounted. */\n compareAtPrice: string | null;\n texts: ProductListTexts;\n locale: string;\n /** Adds the product to the cart the way the built-in button does. */\n addToCart: () => Promise<void>;\n /**\n * Reports a click on the product (`product_clicked`). Call it from the link\n * a custom card renders; the built-in card does it itself.\n */\n trackClick: () => void;\n};\n\nexport type ProductListProps = UseProductsOptions & {\n /**\n * Product page URL. Defaults to the relative `/p/{uniqueSlug}`, which works\n * on a Bitsnap custom domain. Embedded on another site, return the full\n * URL of the product page.\n */\n productHref?: (product: PublicListProduct) => string;\n appearance?: ProductListAppearance;\n /** Text overrides, applied whatever the locale. */\n texts?: Partial<ProductListTexts>;\n /** Replaces the content of a card. The card frame stays. */\n renderItem?: (\n product: PublicListProduct,\n context: ProductListItemContext,\n ) => ReactNode;\n /**\n * Called by the \"Add to cart\" button instead of the default action\n * (`Bitsnap.addProductToCart`). A rejected promise shows the error message.\n */\n onAddToCart?: (product: PublicListProduct) => void | Promise<void>;\n /** Open the cart drawer after the default add to cart. Defaults to `true`. */\n showCartOnAdd?: boolean;\n className?: string;\n /**\n * Usage statistics for your Bitsnap dashboard (list views, impressions,\n * clicks, add to cart). On by default; `false` turns it off. An object\n * lets you forward every event: `{ onEvent }`. Nothing is stored on the\n * visitor's device.\n */\n analytics?: AnalyticsOption;\n};\n\ntype ListContext = {\n appearance: ResolvedProductListAppearance;\n texts: ProductListTexts;\n locale: string;\n};\n\nconst ProductListContext = createContext<ListContext | undefined>(undefined);\n\ntype CardAnalytics = {\n observe: (element: Element, id: string, position: number) => () => void;\n clicked: (product: PublicListProduct, position: number) => void;\n};\n\nconst noCardAnalytics: CardAnalytics = {\n observe: () => () => {},\n clicked: () => {},\n};\n\nconst CardAnalyticsContext = createContext<CardAnalytics>(noCardAnalytics);\n\nfunction useListContext(): ListContext {\n const value = useContext(ProductListContext);\n if (value == null) {\n throw new Error(\"ProductList parts must be rendered inside ProductList\");\n }\n return value;\n}\n\n/** Stable slot attribute, built-in classes and the caller overrides for a slot. */\nfunction useSlot(slot: ProductListSlotName, className?: string) {\n const { appearance } = useListContext();\n const override = getProductListSlotAppearance(appearance, slot);\n\n return {\n \"data-bitsnap-products-slot\": slot,\n className: cn(className, override?.className),\n style: override?.style,\n };\n}\n\nconst BUTTON_CLASS =\n \"inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50\";\nconst BLOCK_BUTTON_CLASS = `${BUTTON_CLASS} w-full`;\nconst LINK_BUTTON_CLASS = `${BLOCK_BUTTON_CLASS} no-underline`;\n\ntype AddStatus = \"idle\" | \"adding\" | \"added\" | \"error\";\n\nfunction AddToCartButton({\n product,\n onAdd,\n}: {\n product: PublicListProduct;\n onAdd: () => Promise<void>;\n}) {\n const { texts } = useListContext();\n const [status, setStatus] = useState<AddStatus>(\"idle\");\n const button = useSlot(\"addToCartButton\", BLOCK_BUTTON_CLASS);\n const message = useSlot(\"message\", \"mt-2 text-xs\");\n\n useEffect(() => {\n if (status !== \"added\") {\n return;\n }\n const timer = setTimeout(() => setStatus(\"idle\"), 2000);\n return () => clearTimeout(timer);\n }, [status]);\n\n const click = useCallback(async () => {\n setStatus(\"adding\");\n try {\n await onAdd();\n setStatus(\"added\");\n } catch (error) {\n console.error(\"bitsnap-react: could not add to the cart\", error);\n setStatus(\"error\");\n }\n }, [onAdd]);\n\n const label =\n status === \"adding\"\n ? texts.addingToCart\n : status === \"added\"\n ? texts.addedToCart\n : texts.addToCart;\n\n return (\n <>\n <button\n type=\"button\"\n {...button}\n disabled={status === \"adding\"}\n aria-label={`${label}: ${product.name}`}\n onClick={click}\n >\n {label}\n </button>\n {status === \"error\" ? (\n <p {...message} role=\"alert\">\n {texts.addToCartError}\n </p>\n ) : null}\n </>\n );\n}\n\nfunction ProductCard({\n product,\n position,\n href,\n onAdd,\n renderItem,\n}: {\n product: PublicListProduct;\n /** Index in the whole catalog (not in the current page). */\n position: number;\n href: string;\n onAdd: () => Promise<void>;\n renderItem?: ProductListProps[\"renderItem\"];\n}) {\n const { texts, locale } = useListContext();\n const analytics = useContext(CardAnalyticsContext);\n const element = useRef<HTMLLIElement>(null);\n useEffect(() => {\n if (element.current == null) {\n return;\n }\n return analytics.observe(element.current, product.id, position);\n }, [analytics, product.id, position]);\n const trackClick = useCallback(\n () => analytics.clicked(product, position),\n [analytics, product, position],\n );\n const card = useSlot(\n \"card\",\n \"relative flex flex-col overflow-hidden border transition-colors\",\n );\n const cardLink = useSlot(\"cardLink\", \"flex flex-1 flex-col no-underline\");\n const imageFrame = useSlot(\"image\", \"aspect-square w-full overflow-hidden\");\n const placeholder = useSlot(\"imagePlaceholder\", \"aspect-square w-full\");\n const body = useSlot(\"body\", \"flex flex-1 flex-col gap-1 p-4\");\n const name = useSlot(\"name\", \"text-base font-medium leading-snug\");\n const description = useSlot(\"description\", \"line-clamp-2 text-sm\");\n const price = useSlot(\"price\", \"mt-auto pt-2 text-base font-semibold\");\n const comparePrice = useSlot(\"comparePrice\", \"ml-2 text-sm font-normal\");\n const badge = useSlot(\n \"badge\",\n \"absolute left-3 top-3 px-2 py-0.5 text-xs font-medium\",\n );\n const model3dBadge = useSlot(\n \"model3dBadge\",\n \"absolute right-3 top-3 inline-flex items-center gap-1 px-2 py-0.5 text-xs font-semibold\",\n );\n const actions = useSlot(\"actions\", \"p-4 pt-0\");\n const selectButton = useSlot(\"selectButton\", LINK_BUTTON_CLASS);\n\n const formattedPrice = formatProductPrice(\n product.price,\n product.currency,\n locale,\n );\n const formattedCompare =\n product.compareAtPrice != null && product.compareAtPrice > product.price\n ? formatProductPrice(product.compareAtPrice, product.currency, locale)\n : null;\n\n if (renderItem != null) {\n return (\n <li\n ref={element}\n {...card}\n data-unavailable={product.available ? undefined : \"\"}\n >\n {renderItem(product, {\n href,\n price: formattedPrice,\n compareAtPrice: formattedCompare,\n texts,\n locale,\n addToCart: onAdd,\n trackClick,\n })}\n </li>\n );\n }\n\n const imageSource = product.image?.thumbnailUrl ?? product.image?.url;\n const badgeText = !product.available\n ? texts.unavailable\n : product.isRecurring\n ? texts.subscription\n : null;\n\n return (\n <li ref={element} {...card} data-unavailable={product.available ? undefined : \"\"}>\n <a {...cardLink} href={href} onClick={trackClick}>\n {imageSource != null ? (\n <div {...imageFrame}>\n <img\n src={imageSource}\n alt=\"\"\n loading=\"lazy\"\n decoding=\"async\"\n className=\"h-full w-full object-cover\"\n />\n </div>\n ) : (\n <div {...placeholder} aria-hidden=\"true\" />\n )}\n <div {...body}>\n <h3 {...name}>{product.name}</h3>\n {product.shortDescription ? (\n <p {...description}>{product.shortDescription}</p>\n ) : null}\n <p {...price}>\n {product.priceFrom\n ? fillProductListText(texts.priceFrom, { price: formattedPrice })\n : formattedPrice}\n {formattedCompare != null ? (\n <>\n <span className=\"sr-only\">{texts.originalPrice}: </span>\n <del {...comparePrice}>{formattedCompare}</del>\n </>\n ) : null}\n </p>\n </div>\n </a>\n {badgeText != null ? (\n <span\n {...badge}\n data-kind={product.available ? \"subscription\" : \"unavailable\"}\n >\n {badgeText}\n </span>\n ) : null}\n {product.has3d === true ? (\n <span {...model3dBadge} title={texts.model3dLabel}>\n <CubeIcon />\n <span aria-hidden=\"true\">{texts.model3d}</span>\n <span className=\"sr-only\">{texts.model3dLabel}</span>\n </span>\n ) : null}\n <div {...actions}>\n {!product.available ? (\n <button type=\"button\" {...selectButton} disabled>\n {texts.unavailable}\n </button>\n ) : product.addToCart ? (\n <AddToCartButton product={product} onAdd={onAdd} />\n ) : (\n <a {...selectButton} href={href} onClick={trackClick}>\n {product.variantCount > 1 ? texts.chooseOptions : texts.viewProduct}\n </a>\n )}\n </div>\n </li>\n );\n}\n\nfunction CubeIcon() {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n width=\"12\"\n height=\"12\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z\" />\n <path d=\"m3.3 7 8.7 5 8.7-5\" />\n <path d=\"M12 22V12\" />\n </svg>\n );\n}\n\nconst GRID_CLASS =\n \"m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-5 p-0\";\n\nfunction SkeletonGrid({ count, label }: { count: number; label: string }) {\n const grid = useSlot(\"grid\", GRID_CLASS);\n const skeleton = useSlot(\"skeleton\", \"aspect-[3/4] animate-pulse\");\n\n return (\n <div {...grid} role=\"status\" aria-busy=\"true\" aria-label={label}>\n {Array.from({ length: count }, (_, index) => (\n <div key={index} {...skeleton} aria-hidden=\"true\" />\n ))}\n </div>\n );\n}\n\nfunction Pagination({\n page,\n pageCount,\n isLoading,\n onPage,\n}: {\n page: number;\n pageCount: number;\n isLoading: boolean;\n onPage: (page: number) => void;\n}) {\n const { texts } = useListContext();\n const nav = useSlot(\n \"pagination\",\n \"mt-8 flex items-center justify-center gap-4\",\n );\n const button = useSlot(\"paginationButton\", BUTTON_CLASS);\n const indicator = useSlot(\"pageIndicator\", \"text-sm\");\n\n return (\n <nav {...nav} aria-label={texts.pagination}>\n <button\n type=\"button\"\n {...button}\n aria-disabled={isLoading || page <= 1}\n onClick={() => {\n if (!isLoading && page > 1) {\n onPage(page - 1);\n }\n }}\n >\n {texts.previousPage}\n </button>\n <span {...indicator} aria-live=\"polite\">\n {fillProductListText(texts.pageOf, { page, pageCount })}\n </span>\n <button\n type=\"button\"\n {...button}\n aria-disabled={isLoading || page >= pageCount}\n onClick={() => {\n if (!isLoading && page < pageCount) {\n onPage(page + 1);\n }\n }}\n >\n {texts.nextPage}\n </button>\n </nav>\n );\n}\n\nfunction ProductListContent({\n options,\n productHref,\n renderItem,\n onAddToCart,\n showCartOnAdd,\n}: {\n options: UseProductsOptions;\n productHref: (product: PublicListProduct) => string;\n renderItem?: ProductListProps[\"renderItem\"];\n onAddToCart?: ProductListProps[\"onAddToCart\"];\n showCartOnAdd: boolean;\n}) {\n const { texts } = useListContext();\n const { products, page, pageCount, setPage, isLoading, error, refetch } =\n useProducts(options);\n const instrument = useInstrumentContext();\n // The search text is never reported, only that the list was searched.\n const listId = options.search?.trim() ? \"search\" : \"catalog\";\n const pageSize = clampPageSize(options.pageSize);\n\n const viewed = useRef(false);\n useEffect(() => {\n if (viewed.current || isLoading || error != null) {\n return;\n }\n viewed.current = true;\n instrument.track(\"product_list_viewed\", {\n list_id: listId,\n item_count: products.length,\n });\n }, [instrument, isLoading, error, listId, products.length]);\n\n const impressions = useMemo(\n () =>\n createImpressionTracker(({ productIds, positions }) =>\n instrument.track(\"product_impression\", {\n list_id: listId,\n product_ids: productIds,\n positions,\n }),\n ),\n [instrument, listId],\n );\n useEffect(() => () => impressions.destroy(), [impressions]);\n const cardAnalytics = useMemo<CardAnalytics>(\n () => ({\n observe: impressions.observe,\n clicked: (product, position) =>\n instrument.track(\n \"product_clicked\",\n { list_id: listId, position },\n { product_id: product.id },\n ),\n }),\n [impressions, instrument, listId],\n );\n\n // After a page change by the user, move focus to the products (the button\n // that was pressed stays where it is, but the content above it changes) and\n // bring them into view once the page has loaded.\n const content = useRef<HTMLDivElement>(null);\n const movedPage = useRef(false);\n const changePage = useCallback(\n (next: number) => {\n movedPage.current = true;\n setPage(next);\n },\n [setPage],\n );\n useEffect(() => {\n if (isLoading || !movedPage.current) {\n return;\n }\n movedPage.current = false;\n content.current?.focus({ preventScroll: true });\n content.current?.scrollIntoView({ block: \"start\" });\n }, [isLoading]);\n\n const grid = useSlot(\"grid\", GRID_CLASS);\n const empty = useSlot(\"emptyState\", \"py-12 text-center text-sm\");\n const errorSlot = useSlot(\"error\", \"flex flex-col items-center gap-3 py-12 text-center text-sm\");\n const retry = useSlot(\"retryButton\", BUTTON_CLASS);\n\n const { projectID, host } = options;\n const addFor = useCallback(\n (product: PublicListProduct, href: string) => async () => {\n if (onAddToCart != null) {\n // The list reports the add itself; a cart helper called inside must not report it again.\n await withCartAnalyticsMuted(() => onAddToCart(product));\n trackProductAdded(instrument, product);\n return;\n }\n await addProductToCart(product, {\n projectID,\n host,\n showCart: showCartOnAdd,\n analytics: instrument,\n url: href,\n });\n },\n [onAddToCart, projectID, host, showCartOnAdd, instrument],\n );\n\n let body: ReactNode;\n if (isLoading && products.length === 0) {\n body = (\n <SkeletonGrid\n count={Math.min(clampPageSize(options.pageSize), 8)}\n label={texts.loading}\n />\n );\n } else if (error != null) {\n body = (\n <div {...errorSlot} role=\"alert\">\n <p>{texts.error}</p>\n <button type=\"button\" {...retry} onClick={refetch}>\n {texts.retry}\n </button>\n </div>\n );\n } else if (products.length === 0) {\n body = <p {...empty}>{texts.empty}</p>;\n } else {\n body = (\n <ul\n {...grid}\n aria-busy={isLoading || undefined}\n className={cn(grid.className, isLoading && \"opacity-60\")}\n >\n {products.map((product, index) => {\n const href = productHref(product);\n return (\n <ProductCard\n key={product.id}\n product={product}\n position={(page - 1) * pageSize + index}\n href={href}\n onAdd={addFor(product, href)}\n renderItem={renderItem}\n />\n );\n })}\n </ul>\n );\n }\n\n return (\n <CardAnalyticsContext.Provider value={cardAnalytics}>\n <div\n ref={content}\n tabIndex={-1}\n className=\"p-1 outline-none scroll-mt-4\"\n >\n {body}\n {pageCount > 1 && error == null ? (\n <Pagination\n page={page}\n pageCount={pageCount}\n isLoading={isLoading}\n onPage={changePage}\n />\n ) : null}\n </div>\n </CardAnalyticsContext.Provider>\n );\n}\n\nconst defaultProductHref = (product: PublicListProduct) =>\n `/p/${encodeURIComponent(product.uniqueSlug)}`;\n\n/**\n * Responsive grid of the shop's products with pagination, loading, empty and\n * error states. Cards link to the product page and can add to the cart.\n *\n * ```tsx\n * <ProductList projectID=\"…\" locale=\"pl-PL\" initialData={firstPage} />\n * ```\n *\n * It renders on the server: pass `initialData` (the first page, fetched on the\n * server) to have the products in the HTML; without it the server renders the\n * loading skeleton and the browser fetches the first page.\n */\nexport function ProductList({\n productHref = defaultProductHref,\n appearance,\n texts,\n renderItem,\n onAddToCart,\n showCartOnAdd = true,\n className,\n analytics,\n ...options\n}: ProductListProps) {\n const instrument: Instrument = useInstrument(\n options.projectID,\n analytics,\n \"catalog\",\n );\n const locale = options.locale ?? DEFAULT_LOCALE;\n const resolvedAppearance = useMemo(\n () => resolveProductListAppearance(appearance),\n [appearance],\n );\n const resolvedTexts = useMemo(\n () => resolveProductListTexts(locale, texts),\n [locale, texts],\n );\n const context = useMemo(\n () => ({ appearance: resolvedAppearance, texts: resolvedTexts, locale }),\n [resolvedAppearance, resolvedTexts, locale],\n );\n const root = getProductListSlotAppearance(resolvedAppearance, \"root\");\n\n return (\n <InstrumentProvider value={instrument}>\n <ProductListContext.Provider value={context}>\n <div\n data-bitsnap-products=\"root\"\n data-bitsnap-products-slot=\"root\"\n className={cn(\n \"bitsnap-react\",\n resolvedAppearance.boundaryClassName,\n className,\n root?.className,\n )}\n style={\n { ...resolvedAppearance.boundaryStyle, ...root?.style } as CSSProperties\n }\n >\n <ProductListContent\n options={options}\n productHref={productHref}\n renderItem={renderItem}\n onAddToCart={onAddToCart}\n showCartOnAdd={showCartOnAdd}\n />\n </div>\n </ProductListContext.Provider>\n </InstrumentProvider>\n );\n}\n","import { getTracker } from \"@/src/analytics/core\";\n\n/** Matches the contract's `positions` / `product_ids` array limit. */\nconst MAX_PER_EVENT = 50;\nconst FLUSH_DELAY_MS = 1000;\n\nexport type ImpressionBatch = { productIds: string[]; positions: number[] };\n\n/**\n * Collects the products that were at least half visible, each one once, and\n * hands them over in batches. Without `IntersectionObserver` nothing is\n * reported. Never throws.\n */\nexport function createImpressionTracker(\n onBatch: (batch: ImpressionBatch) => void,\n delayMs = FLUSH_DELAY_MS,\n) {\n const seen = new Set<string>();\n const targets = new Map<Element, { id: string; position: number }>();\n let pendingIds: string[] = [];\n let pendingPositions: number[] = [];\n let observer: IntersectionObserver | undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let listening = false;\n\n function flush() {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n while (pendingIds.length > 0) {\n const productIds = pendingIds.slice(0, MAX_PER_EVENT);\n const positions = pendingPositions.slice(0, MAX_PER_EVENT);\n pendingIds = pendingIds.slice(MAX_PER_EVENT);\n pendingPositions = pendingPositions.slice(MAX_PER_EVENT);\n try {\n onBatch({ productIds, positions });\n } catch {}\n }\n }\n\n // The tracker flushes its own queue on `pagehide`; ours must be in it by then.\n function flushAll() {\n flush();\n try {\n getTracker()?.flush();\n } catch {}\n }\n const onVisibility = () => {\n if (typeof document !== \"undefined\" && document.visibilityState === \"hidden\") flushAll();\n };\n\n function listen() {\n if (listening || typeof window === \"undefined\") return;\n listening = true;\n window.addEventListener(\"pagehide\", flushAll, true);\n document.addEventListener(\"visibilitychange\", onVisibility, true);\n }\n\n function getObserver(): IntersectionObserver | undefined {\n if (observer) return observer;\n if (typeof IntersectionObserver === \"undefined\") return undefined;\n observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n const target = targets.get(entry.target);\n if (!target || !entry.isIntersecting || entry.intersectionRatio < 0.5) continue;\n targets.delete(entry.target);\n observer?.unobserve(entry.target);\n if (seen.has(target.id)) continue;\n seen.add(target.id);\n pendingIds.push(target.id);\n pendingPositions.push(target.position);\n }\n if (pendingIds.length > 0 && timer === undefined) {\n timer = setTimeout(flush, delayMs);\n (timer as { unref?: () => void }).unref?.();\n }\n },\n { threshold: [0.5] },\n );\n listen();\n return observer;\n }\n\n return {\n /** Starts watching a card. Returns a function that stops. */\n observe(element: Element, id: string, position: number): () => void {\n try {\n if (seen.has(id)) return () => {};\n const watcher = getObserver();\n if (!watcher) return () => {};\n targets.set(element, { id, position });\n watcher.observe(element);\n return () => {\n targets.delete(element);\n watcher.unobserve(element);\n };\n } catch {\n return () => {};\n }\n },\n flush,\n destroy() {\n try {\n flush();\n observer?.disconnect();\n if (listening) {\n window.removeEventListener(\"pagehide\", flushAll, true);\n document.removeEventListener(\"visibilitychange\", onVisibility, true);\n listening = false;\n }\n } catch {}\n observer = undefined;\n targets.clear();\n },\n };\n}\n","import {\n lookupText,\n resolveTexts,\n type LocaleTables,\n} from \"@/src/lib/texts\";\n\n/**\n * Every string `ProductList` renders. Pass a partial object through the\n * `texts` prop to override any of them, whatever the locale. Placeholders\n * (`{price}`, `{page}`, `{pageCount}`) are filled by the component.\n */\nexport type ProductListTexts = {\n /** \"Add to cart\" button of products that can be bought straight from the list. */\n addToCart: string;\n /** Button label while the product is being added. */\n addingToCart: string;\n /** Button label after the product was added. */\n addedToCart: string;\n /** Message shown when adding to the cart failed. */\n addToCartError: string;\n /** Link of products with variants, to pick one on the product page. */\n chooseOptions: string;\n /** Link of products that cannot be added from the list (subscriptions). */\n viewProduct: string;\n /** Label of products that are out of stock. */\n unavailable: string;\n /** Badge of subscription products. */\n subscription: string;\n /** Badge of products with a 3D model. */\n model3d: string;\n /** Screen reader label of the 3D badge. */\n model3dLabel: string;\n /** Price of products whose variants differ in price. `{price}` is the lowest one. */\n priceFrom: string;\n /** Screen reader label of the struck-through regular price. */\n originalPrice: string;\n /** Accessible label of the loading skeleton. */\n loading: string;\n /** Shown when the shop has no products (or none matches the search). */\n empty: string;\n /** Shown when the products could not be loaded. */\n error: string;\n /** Retry button of the error state. */\n retry: string;\n /** Accessible label of the pagination. */\n pagination: string;\n previousPage: string;\n nextPage: string;\n /** Page indicator. `{page}` and `{pageCount}` are filled in. */\n pageOf: string;\n};\n\nexport type ProductListTextKey = keyof ProductListTexts;\n\nexport const PRODUCT_LIST_TEXT_TABLES: LocaleTables<ProductListTextKey> = {\n en: {\n addToCart: \"Add to cart\",\n addingToCart: \"Adding…\",\n addedToCart: \"Added to cart\",\n addToCartError: \"Could not add to the cart. Try again.\",\n chooseOptions: \"Choose\",\n viewProduct: \"View\",\n unavailable: \"Unavailable\",\n subscription: \"Subscription\",\n model3d: \"3D\",\n model3dLabel: \"3D model\",\n priceFrom: \"from {price}\",\n originalPrice: \"Original price\",\n loading: \"Loading products\",\n empty: \"There are no products to show.\",\n error: \"Could not load the products.\",\n retry: \"Try again\",\n pagination: \"Pagination\",\n previousPage: \"Previous\",\n nextPage: \"Next\",\n pageOf: \"Page {page} of {pageCount}\",\n },\n pl: {\n addToCart: \"Dodaj do koszyka\",\n addingToCart: \"Dodawanie…\",\n addedToCart: \"Dodano do koszyka\",\n addToCartError: \"Nie udało się dodać do koszyka. Spróbuj ponownie.\",\n chooseOptions: \"Wybierz\",\n viewProduct: \"Zobacz\",\n unavailable: \"Niedostępny\",\n subscription: \"Subskrypcja\",\n model3d: \"3D\",\n model3dLabel: \"Model 3D\",\n priceFrom: \"od {price}\",\n originalPrice: \"Cena przed obniżką\",\n loading: \"Ładowanie produktów\",\n empty: \"Brak produktów do wyświetlenia.\",\n error: \"Nie udało się załadować produktów.\",\n retry: \"Spróbuj ponownie\",\n pagination: \"Paginacja\",\n previousPage: \"Poprzednia\",\n nextPage: \"Następna\",\n pageOf: \"Strona {page} z {pageCount}\",\n },\n};\n\n/** Default texts for a locale merged with the caller overrides. */\nexport function resolveProductListTexts(\n locale: string,\n overrides?: Partial<ProductListTexts>,\n): ProductListTexts {\n return resolveTexts(PRODUCT_LIST_TEXT_TABLES, locale, overrides);\n}\n\nexport function getProductListText(\n key: ProductListTextKey,\n locale: string,\n overrides?: Partial<ProductListTexts>,\n): string {\n return lookupText(resolveProductListTexts(locale, overrides), key);\n}\n\n/** Replaces `{name}` placeholders. Unknown placeholders stay untouched. */\nexport function fillProductListText(\n text: string,\n values: Record<string, string | number>,\n): string {\n return text.replace(/\\{(\\w+)\\}/g, (match, name: string) =>\n name in values ? String(values[name]) : match,\n );\n}\n"],"mappings":"4UA2DO,IAAMA,GAA0B,CACrC,OACA,OACA,OACA,WACA,QACA,mBACA,OACA,OACA,cACA,QACA,eACA,QACA,eACA,UACA,kBACA,eACA,UACA,aACA,mBACA,gBACA,aACA,QACA,cACA,UACF,EA8BaC,GAA+B,CAC1C,WAAY,iCACZ,SAAU,+BACV,WAAY,gCACZ,QAAS,6BACT,WAAY,gCACZ,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WC,EACX,UAAWC,EACX,OAAQ2B,EACV,EACE,MACN,EACF,CAEJ,CAEA,IAAMW,GAAsB3F,GAC1B,MAAM,mBAAmBA,EAAQ,UAAU,CAAC,GAcvC,SAAS4F,GAAY,CAC1B,YAAAjC,EAAcgC,GACd,WAAAnG,EACA,MAAAU,EACA,WAAAe,EACA,YAAA2C,EACA,cAAAC,EAAgB,GAChB,UAAAtE,EACA,UAAA4B,EACA,GAAGuC,CACL,EAAqB,CACnB,IAAMQ,EAAyB2B,EAC7BnC,EAAQ,UACRvC,EACA,SACF,EACMD,EAASwC,EAAQ,QAAUoC,GAC3BC,EAAqBtB,EACzB,IAAMuB,GAA6BxG,CAAU,EAC7C,CAACA,CAAU,CACb,EACMyG,EAAgBxB,EACpB,IAAMyB,GAAwBhF,EAAQhB,CAAK,EAC3C,CAACgB,EAAQhB,CAAK,CAChB,EACMiG,EAAU1B,EACd,KAAO,CAAE,WAAYsB,EAAoB,MAAOE,EAAe,OAAA/E,CAAO,GACtE,CAAC6E,EAAoBE,EAAe/E,CAAM,CAC5C,EACMkF,EAAO1G,EAA6BqG,EAAoB,MAAM,EAEpE,OACEnH,EAACyH,EAAA,CAAmB,MAAOnC,EAC3B,SAAAtF,EAACE,GAAmB,SAAnB,CAA4B,MAAOqH,EAClC,SAAAvH,EAAC,OACC,wBAAsB,OACtB,6BAA2B,OAC3B,UAAWe,EACT,gBACAoG,EAAmB,kBACnBxG,EACA6G,GAAM,SACR,EACA,MACE,CAAE,GAAGL,EAAmB,cAAe,GAAGK,GAAM,KAAM,EAGxD,SAAAxH,EAAC6E,GAAA,CACC,QAASC,EACT,YAAaC,EACb,WAAY1C,EACZ,YAAa2C,EACb,cAAeC,EACjB,EACF,EACF,EACA,CAEJ","names":["PRODUCT_LIST_SLOT_NAMES","PRODUCT_LIST_TOKEN_VARIABLES","PRODUCT_LIST_THEME_PRESETS","PRODUCT_LIST_SHADCN_VARIABLES","resolveProductListAppearance","appearance","resolved","resolveAppearanceCore","getProductListSlotAppearance","slot","getSlotAppearance","useCallback","useEffect","useMemo","useState","useProducts","options","projectID","locale","search","initialData","defaultHost","useState","HOST","host","pageSize","clampPageSize","queryKey","pageState","setPageState","reloads","setReloads","snapshot","setSnapshot","totalCount","pageCount","pageCountFor","requestedPage","page","requestKey","isCurrent","useEffect","controller","fetchProductList","data","error","previous","setPage","useCallback","next","target","refetch","value","useMemo","createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","MAX_PER_EVENT","FLUSH_DELAY_MS","createImpressionTracker","onBatch","delayMs","seen","targets","pendingIds","pendingPositions","observer","timer","listening","flush","productIds","positions","flushAll","getTracker","onVisibility","listen","getObserver","entries","entry","target","element","id","position","watcher","PRODUCT_LIST_TEXT_TABLES","resolveProductListTexts","locale","overrides","resolveTexts","fillProductListText","text","values","match","name","Fragment","jsx","jsxs","ProductListContext","createContext","noCardAnalytics","CardAnalyticsContext","useListContext","value","useContext","useSlot","slot","className","appearance","override","getProductListSlotAppearance","cn","BUTTON_CLASS","BLOCK_BUTTON_CLASS","LINK_BUTTON_CLASS","AddToCartButton","product","onAdd","texts","status","setStatus","useState","button","message","useEffect","timer","click","useCallback","error","label","ProductCard","position","href","renderItem","locale","analytics","element","useRef","trackClick","card","cardLink","imageFrame","placeholder","body","name","description","price","comparePrice","badge","model3dBadge","actions","selectButton","formattedPrice","formatProductPrice","formattedCompare","imageSource","badgeText","fillProductListText","CubeIcon","GRID_CLASS","SkeletonGrid","count","grid","skeleton","_","index","Pagination","page","pageCount","isLoading","onPage","nav","indicator","ProductListContent","options","productHref","onAddToCart","showCartOnAdd","products","setPage","refetch","useProducts","instrument","useInstrumentContext","listId","pageSize","clampPageSize","viewed","impressions","useMemo","createImpressionTracker","productIds","positions","cardAnalytics","content","movedPage","changePage","next","empty","errorSlot","retry","projectID","host","addFor","withCartAnalyticsMuted","trackProductAdded","addProductToCart","defaultProductHref","ProductList","useInstrument","DEFAULT_LOCALE","resolvedAppearance","resolveProductListAppearance","resolvedTexts","resolveProductListTexts","context","root","InstrumentProvider"]}
|
package/dist/chunk-555KFWGY.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk5FZAROP6js = require('./chunk-5FZAROP6.js');var _chunk4BL7TLK3js = require('./chunk-4BL7TLK3.js');var _chunkSYN5KU3Ojs = require('./chunk-SYN5KU3O.js');var _chunkESF5ZVVFjs = require('./chunk-ESF5ZVVF.js');var _chunkC3BBJOVVjs = require('./chunk-C3BBJOVV.js');var _chunk7RXW6XFYjs = require('./chunk-7RXW6XFY.js');var _react = require('@formkit/auto-animate/react');var _react3 = require('react'); var mt = _interopRequireWildcard(_react3);var _jsxruntime = require('react/jsx-runtime');function ye({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card",className:_chunkESF5ZVVFjs.g.call(void 0, "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function xe({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-header",className:_chunkESF5ZVVFjs.g.call(void 0, "@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 Ce({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-title",className:_chunkESF5ZVVFjs.g.call(void 0, "leading-none font-semibold",e),...t})}function zn({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-description",className:_chunkESF5ZVVFjs.g.call(void 0, "text-muted-foreground text-sm",e),...t})}function he({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-content",className:_chunkESF5ZVVFjs.g.call(void 0, "px-6",e),...t})}var _lucidereact = require('lucide-react');var go="text-muted-foreground text-xs leading-5",yo="dark:border-foreground/30 dark:focus-visible:border-foreground/70 dark:focus-visible:ring-foreground/25 dark:aria-invalid:border-destructive-foreground dark:aria-invalid:ring-destructive-foreground/30",ho=new Set(["invalidEmail","emailNotFound","deliveryUnavailable"]),Ut="inline-flex min-h-11 items-center px-1 text-sm underline underline-offset-4 hover:no-underline focus-visible:ring-[3px] focus-visible:ring-ring/50 rounded-sm outline-none disabled:opacity-50 disabled:no-underline";function Fn({login:e,texts:t,allowHaveCode:n=!0,emailPlaceholder:a,emailInputId:r,codeInputId:o,className:i,buttonClassName:d,children:c}){let l=_react3.useId.call(void 0, ),p=_nullishCoalesce(r, () => (`${l}-email`)),y=_nullishCoalesce(o, () => (`${l}-code`)),w=`${l}-notice`,u=`${l}-hint`,{notice:f}=e,b=_optionalChain([f, 'optionalAccess', _2 => _2.kind])==="error",s=e.busy==="send",k=e.busy==="verify",T=e.busy==="resend",j=_chunkESF5ZVVFjs.g.call(void 0, "h-11 w-full",d),B=_optionalChain([f, 'optionalAccess', _3 => _3.kind])==="success",A=_jsxruntime.jsxs.call(void 0, "div",{id:w,className:"min-h-10 text-sm leading-5",children:[_jsxruntime.jsx.call(void 0, "p",{role:"alert",className:"font-medium text-red-700 dark:text-red-400",children:b?f.text:null}),_jsxruntime.jsxs.call(void 0, "p",{role:"status",className:_chunkESF5ZVVFjs.g.call(void 0, "flex items-start gap-1.5",B?"font-medium text-emerald-700 dark:text-emerald-400":"text-foreground"),children:[B&&_jsxruntime.jsx.call(void 0, _lucidereact.CircleCheck,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0"}),_jsxruntime.jsx.call(void 0, "span",{children:f!=null&&!b?f.text:null})]})]}),J=b&&e.step==="email"&&(f.failure==null||ho.has(f.failure)),ce=_jsxruntime.jsx.call(void 0, "p",{className:"sr-only",role:"status","aria-live":"polite",children:e.announcement}),E=_jsxruntime.jsxs.call(void 0, "div",{className:"grid gap-2",children:[_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.d,{htmlFor:p,children:t.emailLabel}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.s,{id:p,ref:e.emailRef,name:"email",type:"email",autoComplete:"email",inputMode:"email",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,autoFocus:!0,required:!0,className:_chunkESF5ZVVFjs.g.call(void 0, "h-11 text-base disabled:opacity-100 disabled:text-foreground/70",yo),placeholder:_nullishCoalesce(a, () => (t.emailPlaceholder)),value:e.email,disabled:e.isBusy,"aria-invalid":J?!0:void 0,"aria-describedby":w,onChange:Y=>e.setEmail(Y.target.value)})]});if(e.step==="email")return _jsxruntime.jsxs.call(void 0, "form",{noValidate:!0,className:_chunkESF5ZVVFjs.g.call(void 0, "flex flex-col gap-4",i),onSubmit:Y=>{Y.preventDefault(),e.sendCode()},children:[ce,E,A,_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{type:"submit",disabled:e.isBusy,"aria-busy":s,className:j,children:[s&&_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.e,{"aria-hidden":!0}),s?t.sending:t.sendCode]}),n&&_jsxruntime.jsxs.call(void 0, "p",{className:"flex flex-wrap items-center justify-center text-center text-sm",children:[t.haveCodePrompt!==""&&_jsxruntime.jsx.call(void 0, "span",{children:t.haveCodePrompt}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:Ut,disabled:e.isBusy,onClick:e.haveCode,children:t.haveCode})]})]});let[Z,pe]=t.codeSentTo.split("{email}"),$=e.dead!=null,Be=$?t.resendNew:e.secondsLeft>0?_chunk5FZAROP6js.i.call(void 0, t.resendIn,{seconds:e.secondsLeft}):t.resend;return _jsxruntime.jsxs.call(void 0, "form",{noValidate:!0,className:_chunkESF5ZVVFjs.g.call(void 0, "flex flex-col gap-4",i),onSubmit:Y=>{Y.preventDefault(),e.submitCode()},children:[ce,e.needsEmail?E:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-center justify-between gap-x-2",children:[_jsxruntime.jsxs.call(void 0, "p",{className:"min-w-0 flex-[1_1_14rem] text-sm leading-5 break-words",children:[Z,_jsxruntime.jsx.call(void 0, "strong",{className:"font-semibold",children:e.email}),"\u2060",pe]}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunkESF5ZVVFjs.g.call(void 0, Ut,"-ml-1 shrink-0"),disabled:e.isBusy,onClick:e.changeEmail,children:t.changeEmail})]}),c,_jsxruntime.jsxs.call(void 0, "div",{className:"grid gap-2",children:[_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.d,{htmlFor:y,children:t.codeLabel}),_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.k,{id:y,name:"code",inputRef:e.codeRef,value:e.code,onChange:e.setCode,onComplete:Y=>void e.submitCode(Y),disabled:e.isBusy||$,invalid:b&&!e.needsEmail,"aria-describedby":`${w} ${u}`}),_jsxruntime.jsxs.call(void 0, "p",{id:u,className:go,children:[t.validity," ",t.spamHint]})]}),A,_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{type:"submit",disabled:e.isBusy||$,"aria-busy":k,className:j,children:[k&&_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.e,{"aria-hidden":!0}),k?t.verifying:t.verify]}),e.needsEmail?_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center",children:_jsxruntime.jsx.call(void 0, "button",{type:"button",className:Ut,disabled:e.isBusy,onClick:e.changeEmail,children:t.noCode})}):_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{type:"button",variant:$?"default":"outline",disabled:e.isBusy||!$&&e.secondsLeft>0,"aria-busy":T,className:$?j:"h-11 w-full",onClick:()=>void e.resend(),children:[T&&_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.e,{"aria-hidden":!0}),Be]})]})}function _t(e){switch(e){case 1:return"emailNotFound";case 2:return"invalidEmail";case 3:return"wrongCode";case 14:return"expired";case 15:return"tooManyAttempts";case 13:return"rateLimited";case 12:return"deliveryFailed";case 11:return"deliveryUnavailable";default:return"unknown"}}var Po={pl:{title:"Zaloguj si\u0119",description:"Wy\u015Blemy do Ciebie kod na maila, dzi\u0119ki kt\xF3remu si\u0119 zalogujesz.",codeTitle:"Wpisz kod z maila",codeDescription:"Kod ma 6 cyfr."},en:{title:"Sign in",description:"We will email you a code that signs you in.",codeTitle:"Enter the code from the email",codeDescription:"The code has 6 digits."}};function qn(e=_chunk7RXW6XFYjs.f.call(void 0, ),t){return{..._chunk5FZAROP6js.h.call(void 0, e,t),..._chunk7RXW6XFYjs.a.call(void 0, Po,e),...bo(t,["title","description","codeTitle","codeDescription"])}}function bo(e,t){let n={};for(let a of t){let r=_optionalChain([e, 'optionalAccess', _4 => _4[a]]);r!=null&&(n[a]=r)}return n}var vo="return_url",jt="__return_url",ko="accessToken";function Je(e){let t=new URLSearchParams(e).get(vo);return t?Bn(t):null}function Ze(e){typeof window>"u"||(e?window.sessionStorage.setItem(jt,e):window.sessionStorage.removeItem(jt))}function Le(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(jt);return e?Bn(e):null}function wo(e,t){return t.some(n=>{if(e===n)return!0;let a=new URL(n).hostname,r=new URL(e).hostname;return r.endsWith(`.${a}`)||r===a})}function Bn(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!wo(t.origin,_chunk4BL7TLK3js.h.call(void 0, ))?null:t.toString()}catch (e2){return null}}function De(e,t){let n=new URL(e);return n.searchParams.set(ko,t),n.toString()}if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];_chunk4BL7TLK3js.h.call(void 0, ).length===0&&_chunk4BL7TLK3js.g.call(void 0, Array.from(new Set(t)))}var Co=({texts:e,projectID:t,host:n,locale:a,logo:r})=>{let o=_chunkC3BBJOVVjs.m.call(void 0, ),{mutateAsync:i}=_chunkSYN5KU3Ojs.m.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.userPanelLogin),{mutateAsync:d}=_chunkSYN5KU3Ojs.m.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.userPanelLoginWithCode),c=_react3.useMemo.call(void 0, ()=>({async send(u){try{let f=await i({email:u});return f.result.case==="success"?{ok:!0,retryIn:f.result.value.retryIn||void 0,challengeId:f.result.value.challengeId||void 0}:{ok:!1,kind:_t(f.result.case==="failure"?f.result.value:0)}}catch(f){return{ok:!1,kind:_chunk5FZAROP6js.a.call(void 0, f),cause:f}}},async verify({email:u,code:f,challengeId:b}){try{let s=await d({code:parseInt(f,10),email:u,challengeId:b});return s.result.case==="accessToken"&&s.result.value?{ok:!0,value:{accessToken:s.result.value}}:{ok:!1,kind:_t(s.result.case==="failure"?s.result.value:0)}}catch(s){return{ok:!1,kind:_chunk5FZAROP6js.a.call(void 0, s),cause:s}}}}),[i,d]),l=_chunk5FZAROP6js.j.call(void 0, {adapter:c,texts:e,storageKey:_chunk5FZAROP6js.f.call(void 0, "panel",t,n),onVerified:({accessToken:u},f)=>{o.track("panel_login",{}),_chunk4BL7TLK3js.l.call(void 0, t,u,f,n);let b=typeof window<"u"?Le():null;setTimeout(()=>{if(b){window.location.href=De(b,u);return}window.location.reload()},100)}}),p=l.step==="code",y=p&&!l.needsEmail?e.codeTitle:e.title,w=p&&!l.needsEmail?e.codeDescription:e.description;return _jsxruntime.jsx.call(void 0, "main",{className:"mx-auto flex w-full max-w-sm flex-1 flex-col justify-start pt-4 sm:pt-[12vh]",children:_jsxruntime.jsxs.call(void 0, ye,{children:[_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.c,{projectId:t,locale:a,className:"px-4 sm:px-6",...r}),_jsxruntime.jsxs.call(void 0, xe,{className:"px-4 sm:px-6",children:[_jsxruntime.jsx.call(void 0, Ce,{role:"heading","aria-level":1,className:"text-2xl",children:y}),_jsxruntime.jsx.call(void 0, zn,{children:w})]}),_jsxruntime.jsx.call(void 0, he,{className:"px-4 sm:px-6",children:_jsxruntime.jsx.call(void 0, Fn,{login:l,texts:e,emailInputId:"email",codeInputId:"verify-code"})})]})})},No=({analytics:e,texts:t,locale:n,showLogo:a,logoUrl:r,logoDarkUrl:o})=>{let{theme:i,allowedReturnOrigins:d,projectID:c,host:l}=_chunk4BL7TLK3js.j.call(void 0, ),p=_chunkC3BBJOVVjs.n.call(void 0, c,e,"panel"),y=_react3.useMemo.call(void 0, ()=>qn(_nullishCoalesce(n, () => (_chunk7RXW6XFYjs.f.call(void 0, ))),t),[n,t]),w={"--button-background-color":_nullishCoalesce(_optionalChain([i, 'optionalAccess', _5 => _5.colors, 'optionalAccess', _6 => _6.brand]), () => ("#FFFFFF")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([i, 'optionalAccess', _7 => _7.colors, 'optionalAccess', _8 => _8.brandDark]), () => ("#000000")),"--button-text-color":_nullishCoalesce(_optionalChain([i, 'optionalAccess', _9 => _9.colors, 'optionalAccess', _10 => _10.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([i, 'optionalAccess', _11 => _11.colors, 'optionalAccess', _12 => _12.brand]), () => ("#FFFFFF"))},[u]=_react.useAutoAnimate.call(void 0, {duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1});return _react3.useEffect.call(void 0, ()=>{typeof window>"u"||_chunk4BL7TLK3js.k.call(void 0, c,l)!=null&&(window.location.href=window.location.href.replaceAll("login",""))},[c,l]),_react3.useEffect.call(void 0, ()=>{if(typeof window>"u"||window.parent!==window)return;let f=Je(window.location.search);f&&Ze(f);let b=_nullishCoalesce(f, () => (Le()));if(!b)return;let s=_chunk4BL7TLK3js.k.call(void 0, c,l);s&&(window.location.href=De(b,s))},[d,c,l]),_jsxruntime.jsx.call(void 0, _chunkC3BBJOVVjs.l,{value:p,children:_jsxruntime.jsx.call(void 0, "div",{className:"bg-white text-black dark:bg-black dark:text-white",children:_jsxruntime.jsx.call(void 0, "div",{className:"font-inter flex min-h-screen w-full flex-col p-4",style:w,ref:u,children:_jsxruntime.jsx.call(void 0, Co,{texts:y,projectID:c,host:l,locale:n,logo:{showLogo:a,logoUrl:_nullishCoalesce(r, () => (_optionalChain([i, 'optionalAccess', _13 => _13.logoURL]))),logoDarkUrl:_nullishCoalesce(o, () => (_optionalChain([i, 'optionalAccess', _14 => _14.logoDarkURL])))}})})})})},Io= exports.k =(e={})=>_jsxruntime.jsx.call(void 0, No,{...e});function Kn(e){let[t,n]=_react3.useState.call(void 0, ()=>{if(typeof window>"u")return e;let r=new URLSearchParams(window.location.search),o={};return Object.keys(e).forEach(i=>{let d=r.get(i);if(d!==null)try{o[i]=JSON.parse(d)}catch (e3){o[i]=d}}),{...e,...o}}),a=_react3.useCallback.call(void 0, r=>{n(o=>{let i={...o,...r};if(typeof window<"u"){let d=new URLSearchParams;Object.keys(i).forEach(l=>{let p=i[l];p!=null&&d.set(l,JSON.stringify(p))});let c=`${window.location.pathname}?${d.toString()}`;window.history.pushState({},"",c)}return i})},[]);return _react3.useEffect.call(void 0, ()=>{let r=()=>{let o=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(d=>{let c=o.get(d);if(c!==null)try{i[d]=JSON.parse(c)}catch (e4){i[d]=c}}),n({...e,...i})};return window.addEventListener("popstate",r),()=>window.removeEventListener("popstate",r)},[e]),[t,a]}function Wn(e,t){if(e!=null)return e;let n=_optionalChain([t, 'optionalAccess', _15 => _15.trim, 'call', _16 => _16()]);if(!(n==null||n===""))return{tokens:_chunkSYN5KU3Ojs.u.call(void 0, n)}}var _reactswitch = require('@radix-ui/react-switch'); var ct = _interopRequireWildcard(_reactswitch);function Jn({className:e,...t}){return _jsxruntime.jsx.call(void 0, ct.Root,{"data-slot":"switch",className:_chunkESF5ZVVFjs.g.call(void 0, "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:_jsxruntime.jsx.call(void 0, ct.Thumb,{"data-slot":"switch-thumb",className:_chunkESF5ZVVFjs.g.call(void 0, "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")})})}function Lo({}){let[e,t]=_react3.useState.call(void 0, {disableAll:!1});return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Powiadomienia"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Zarz\u0105dzaj swoimi powiadomieniami"}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-6",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center space-x-2",children:[_jsxruntime.jsx.call(void 0, Jn,{id:"disable-all-notifications",checked:e.disableAll,onCheckedChange:n=>t(a=>({...a,disableAll:n}))}),_jsxruntime.jsxs.call(void 0, _chunk5FZAROP6js.d,{htmlFor:"disable-all-notifications",className:"flex flex-col gap-1 text-base",children:["Wszystkie powiadomienia",_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-normal text-neutral-500 md:text-sm",children:"Ten przycisk mo\u017Ce wy\u0142\u0105czy\u0107 wszystkie powiadomienia"})]})]})})]})}var Zn=Lo;function Yn({className:e,...t}){return _jsxruntime.jsx.call(void 0, "nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:_chunkESF5ZVVFjs.g.call(void 0, "mx-auto flex w-full justify-center",e),...t})}function Qn({className:e,...t}){return _jsxruntime.jsx.call(void 0, "ul",{"data-slot":"pagination-content",className:_chunkESF5ZVVFjs.g.call(void 0, "flex flex-row items-center gap-1",e),...t})}function Pe({...e}){return _jsxruntime.jsx.call(void 0, "li",{"data-slot":"pagination-item",...e})}function Ee({className:e,isActive:t,size:n="icon",...a}){return _jsxruntime.jsx.call(void 0, "a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:_chunkESF5ZVVFjs.g.call(void 0, _chunkSYN5KU3Ojs.q.call(void 0, {variant:t?"outline":"ghost",size:n}),e),...a})}function Xn({className:e,...t}){return _jsxruntime.jsxs.call(void 0, Ee,{"aria-label":"Go to previous page",size:"default",className:_chunkESF5ZVVFjs.g.call(void 0, "gap-1 px-2.5 sm:pl-2.5",e),...t,children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeftIcon,{}),_jsxruntime.jsx.call(void 0, "span",{className:"hidden sm:block",children:"Previous"})]})}function er({className:e,...t}){return _jsxruntime.jsxs.call(void 0, Ee,{"aria-label":"Go to next page",size:"default",className:_chunkESF5ZVVFjs.g.call(void 0, "gap-1 px-2.5 sm:pr-2.5",e),...t,children:[_jsxruntime.jsx.call(void 0, "span",{className:"hidden sm:block",children:"Next"}),_jsxruntime.jsx.call(void 0, _lucidereact.ChevronRightIcon,{})]})}function Ft({className:e,...t}){return _jsxruntime.jsxs.call(void 0, "span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:_chunkESF5ZVVFjs.g.call(void 0, "flex size-9 items-center justify-center",e),...t,children:[_jsxruntime.jsx.call(void 0, _lucidereact.MoreHorizontalIcon,{className:"size-4"}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"More pages"})]})}var _o=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),jo=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t.toUpperCase()}).format(e/100),zo={draft:"Szkic",unpaid:"Nieop\u0142acona",paid:"Op\u0142acona",overdue:"Zaleg\u0142a",cancelled:"Anulowana",completed:"Zako\u0144czone",processing:"Przetwarzane",refunded:"Zwr\xF3cone"},Fo={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 qo({openOrderDetails:e,projectID:t,accessToken:n}){let[a,r]=_react3.useState.call(void 0, 0),o=20,{data:i,isFetching:d}=_chunkSYN5KU3Ojs.l.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.getOrders,{projectId:t,accessToken:n,offset:a,limit:o}),c=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _17 => _17.orders]), () => ([])),l=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _18 => _18.totalCount]), () => (0)),p=Math.floor(a/o)+1,y=Math.ceil(l/o),w=u=>{r(u)};return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Historia zam\xF3wie\u0144"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"Twoje zam\xF3wienia"}),d?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((u,f)=>_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.v,{className:"h-4 w-24"}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.v,{className:"h-3 w-32"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2 text-right",children:[_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.v,{className:"ml-auto h-4 w-16"}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.v,{className:"ml-auto h-3 w-12"})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-3",children:_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.v,{className:"h-3 w-40"})})]},f))}):c.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"Brak zam\xF3wie\u0144."}):_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex w-full flex-col gap-3",children:c.map(u=>_jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "p",{className:"font-medium",children:["Zam\xF3wienie #",u.id]}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:u.customerName||"Klient"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-semibold",children:jo(u.totalAmount,u.currency)}),_jsxruntime.jsx.call(void 0, "p",{className:`text-xs font-medium ${_nullishCoalesce(Fo[u.status], () => ("text-neutral-400"))}`,children:_nullishCoalesce(zo[u.status], () => (u.status))})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 flex items-center justify-between text-xs text-neutral-500 dark:text-neutral-400",children:_jsxruntime.jsxs.call(void 0, "span",{children:["Data:"," ",u.createdAt?_o(Number(u.createdAt.seconds)):"-"]})})]},u.id))}),y>1&&!d&&_jsxruntime.jsx.call(void 0, "div",{className:"mt-4 flex justify-center",children:_jsxruntime.jsx.call(void 0, Yn,{children:_jsxruntime.jsxs.call(void 0, Qn,{children:[p>1&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, Xn,{onClick:()=>w(a-o)})}),p>2&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, Ee,{onClick:()=>w(0),children:"1"})}),p>3&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, Ft,{})}),[p-1,p,p+1].filter(u=>u>0&&u<=y).map(u=>_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, Ee,{onClick:()=>w((u-1)*o),isActive:p===u,children:u})},u)),p<y-2&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, Ft,{})}),p<y&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, Ee,{onClick:()=>w((y-1)*o),children:y})}),p<y&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, er,{onClick:()=>w(a+o)})})]})})})]})]})}var tr=qo;var rr=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),$o={active:"Aktywny",cancelled:"Anulowany",paused:"Wstrzymany"},Ho={active:"text-green-600",cancelled:"text-red-500",paused:"text-yellow-500"};function Go({projectID:e}){let[t,n]=_react3.useState.call(void 0, []),[a,r]=_react3.useState.call(void 0, !0);return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Plany"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Twoje aktywne subskrypcje"}),a?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"\u0141adowanie..."}):t.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"Brak aktywnych plan\xF3w."}):_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex flex-col gap-4",children:t.map(o=>_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-white p-5 shadow-sm dark:bg-neutral-800",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-start justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-semibold",children:o.tierName}),o.configName&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:o.configName})]}),_jsxruntime.jsx.call(void 0, "span",{className:`text-sm font-medium ${_nullishCoalesce(Ho[o.status], () => ("text-neutral-500"))}`,children:_nullishCoalesce($o[o.status], () => (o.status))})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-3 grid grid-cols-2 gap-2 text-sm text-neutral-600 dark:text-neutral-400",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Dzie\u0144 rozliczenia:"})," ",o.billingDay]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Data startu:"})," ",rr(o.startDate)]}),o.endDate&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Data zako\u0144czenia:"})," ",rr(o.endDate)]})]})]},o.id))})]})}var or=Go;function Vo(e,t,n,a){typeof window>"u"||(t&&_chunk4BL7TLK3js.n.call(void 0, n,a),window.location.href=e)}function Jo({projectID:e,host:t,loginURL:n,screen:a,params:r,setParams:o,setActiveScreen:i}){let{status:d,exchangeError:c}=_chunk5FZAROP6js.t.call(void 0, "PanelReturns"),l=_chunk5FZAROP6js.r.call(void 0, ),p=d==="anonymous"&&(c==null||_chunk5FZAROP6js.p.call(void 0, c));_react3.useEffect.call(void 0, ()=>{p&&Vo(n,c!=null,e,t)},[p,n,c,e,t]);let[y,w]=_react3.useState.call(void 0, "orders"),[u,f]=_react3.useState.call(void 0, {items:[],note:""}),[b,s]=_react3.useState.call(void 0, );if(d==="anonymous"&&!p)return _jsxruntime.jsxs.call(void 0, "div",{role:"alert",className:"flex flex-col items-start gap-3",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:l(_chunk5FZAROP6js.q.call(void 0, c))}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{type:"button",onClick:()=>window.location.reload(),children:l("errorRetry")})]});if(d!=="authenticated")return _jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.C,{});let k=T=>{w(T),o({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(a==="return-details"&&r.returnId)return _jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.K,{returnId:r.returnId,onBack:()=>k("myReturns")});if(y==="myReturns")return _jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.J,{onBack:()=>k("orders"),onSelectReturn:T=>{o({state:"return-details",returnId:T,orderId:void 0}),i("return-details")}});if(y==="result"&&b!=null)return _jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.I,{returnId:b,onContinue:()=>k("orders"),onOpenMyReturns:()=>k("myReturns")});if(r.orderId){let T=r.orderId;return y==="confirmation"?_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.H,{orderId:T,items:u.items,note:u.note,onBack:()=>w("orders"),onSubmitted:j=>{s(j),f({items:[],note:""}),w("result"),o({orderId:void 0})}}):_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.G,{orderId:T,initialItems:u.items.length>0?u.items:void 0,initialNote:u.note,onBack:()=>{f({items:[],note:""}),o({orderId:void 0})},onContinue:j=>{f(j),w("confirmation")}})}return _jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.F,{showLogout:!1,onSelectOrder:T=>{f({items:[],note:""}),w("orders"),o({orderId:T})},onOpenMyReturns:()=>k("myReturns")})}function $t({accessToken:e,appearance:t,texts:n,...a}){return _jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.u,{projectID:a.projectID,host:a.host,appearance:t,texts:n,panelAccessToken:e,children:_jsxruntime.jsx.call(void 0, Jo,{...a})})}function Yo(){return _jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var oe=Yo;var Xo=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,ea=e=>[...e.matchAll(Xo)].map(n=>({url:n[0],startIndex:n.index,endIndex:n.index+n[0].length-1})),ta=(e,t)=>{let n="",a=0;t.sort((r,o)=>r.startIndex-o.startIndex);for(let{startIndex:r,endIndex:o,replacementText:i}of t)n+=e.slice(a,r),n+=i,a=o+1;return n+=e.slice(a),n},ar=e=>{let t=ea(e);return _jsxruntime.jsx.call(void 0, "p",{dangerouslySetInnerHTML:{__html:ta(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)))}})};var _protobuf = require('@bufbuild/protobuf');var _hlsjs = require('hls.js'); var _hlsjs2 = _interopRequireDefault(_hlsjs);function ir(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="playing")}function sr(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="paused")}function dr(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 cr(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 lr(){navigator.mediaSession.metadata=null}var sa=_react3.forwardRef.call(void 0, ({chapters:e,styles:t,updateCurrentTime:n,setCurrentTimeHandler:a,title:r,imageURL:o,uniqueProductID:i,onChapterChange:d},c)=>{let l;(q=>(q[q.Playing=0]="Playing",q[q.Paused=1]="Paused"))(l||={});let[p,y]=_react3.useState.call(void 0, 1);_react3.useEffect.call(void 0, ()=>{switch(p){case 0:ir();break;case 1:sr();break}},[p]),_react3.useImperativeHandle.call(void 0, c,()=>({selectChapter:g=>{He(g)}}));let[w,u]=_react3.useState.call(void 0, void 0),[f,b]=_react3.useState.call(void 0, void 0),s=_react3.useRef.call(void 0, null),k=_react3.useRef.call(void 0, void 0),T=_react3.useRef.call(void 0, void 0),j=_react3.useRef.call(void 0, null),B=_react3.useRef.call(void 0, null),[A,J]=_react3.useState.call(void 0, !0),[ce,E]=_react3.useState.call(void 0, !1),[Z,pe]=_react3.useState.call(void 0, !da());function $(g){g<10||localStorage.setItem(`__player__${i}_${_optionalChain([B, 'access', _19 => _19.current, 'optionalAccess', _20 => _20.id])}`,`${g}`)}function Be(){let g=localStorage.getItem(`__player__${i}_${_optionalChain([B, 'access', _21 => _21.current, 'optionalAccess', _22 => _22.id])}`);if(g!=null)try{let M=parseInt(g);return isNaN(M)||M<0?void 0:M}catch (e5){return}}function Y(){let g=localStorage.getItem(`__player__${i}_last_chapter`);if(g!=null)return g}function xt(g){localStorage.setItem(`__player__${i}_last_chapter`,g)}function Ct(g){localStorage.removeItem(`__player__${i}_${g}`)}function v(){s.current!=null&&(s.current.onloadeddata=()=>{if(s.current!=null){if(s.current.readyState<2&&pe(!0),s.current.readyState>=2&&pe(!1),!ce){let g=Be();g!=null&&nt(g),E(!0)}if(A){J(!1);try{Nt()}catch(g){console.log("play error",g)}}}},s.current.onplay=()=>{},s.current.onseeked=()=>{},s.current.onseeking=()=>{},s.current.onpause=()=>{},s.current.onended=()=>{ne()},cr({title:_nullishCoalesce(r, () => ("")),artwork:o,action:g=>{switch(g.action){case"play":Nt();break;case"pause":It();break;case"seekbackward":tt(-15);break;case"seekforward":tt(15);break;case"seekto":g.seekTime&&nt(g.seekTime);break;case"stop":It();break;default:break}}}),we())}function ne(){if(e==null||e.length==0)return;let g=e.findIndex(q=>q.id==_optionalChain([B, 'access', _23 => _23.current, 'optionalAccess', _24 => _24.id]));g==-1||(Ct(e[g].id),g+1>=e.length)||He(e[g+1])}function we(){Ne(),T.current==null&&(T.current=setTimeout(()=>{Ne(),T.current=void 0,we()},500))}function $e(){T.current!=null&&clearTimeout(T.current)}function Ne(){s.current!=null&&(y(s.current.paused?1:0),b(s.current.duration),u(s.current.currentTime),$(s.current.currentTime),dr(s.current.duration,s.current.currentTime),s.current.networkState===s.current.NETWORK_LOADING&&s.current.readyState<=s.current.HAVE_FUTURE_DATA?pe(!0):pe(!1),n&&n(s.current.currentTime))}function Nt(){_optionalChain([s, 'access', _25 => _25.current, 'optionalAccess', _26 => _26.play, 'call', _27 => _27(), 'access', _28 => _28.then, 'call', _29 => _29(), 'access', _30 => _30.catch, 'call', _31 => _31()]),Ne()}function It(){_optionalChain([s, 'access', _32 => _32.current, 'optionalAccess', _33 => _33.pause, 'call', _34 => _34()]),Ne()}function io(){if(p===0){It();return}Nt()}function tt(g){if(s.current==null)return;let M=s.current.currentTime+g;if(M<0){s.current.currentTime=0;return}if(M>s.current.duration){s.current.currentTime=s.current.duration;return}s.current.currentTime+=g}function nt(g){if(s.current!=null){if(u(g),g<0){s.current.currentTime=0;return}if(g>s.current.duration){s.current.currentTime=s.current.duration;return}s.current.currentTime=g}}function so(){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="",_optionalChain([k, 'access', _35 => _35.current, 'optionalAccess', _36 => _36.destroy, 'call', _37 => _37()]))}function ln(g){if(g.length==0)return;let M=Y();if(M==null){He(g[0]);return}let q=g.find(Ie=>Ie.id==M);if(q==null){He(g[0]);return}He(q)}function He(g){E(!1),J(!0),B.current=g,co(g.publicUrl),_optionalChain([d, 'optionalCall', _38 => _38(g)]),xt(g.id)}function co(g){s.current!=null&&(s.current.canPlayType("application/vnd.apple.mpegurl")?s.current.src=g:_hlsjs2.default.isSupported()&&(k.current==null&&(k.current=new _hlsjs2.default,_optionalChain([k, 'access', _39 => _39.current, 'optionalAccess', _40 => _40.attachMedia, 'call', _41 => _41(s.current)])),_optionalChain([k, 'access', _42 => _42.current, 'optionalAccess', _43 => _43.loadSource, 'call', _44 => _44(g)])))}_react3.useEffect.call(void 0, ()=>{s.current!=null&&(v(),ln(e))},[s.current]),_react3.useEffect.call(void 0, ()=>{ln(e)},[e]),_react3.useEffect.call(void 0, ()=>(_optionalChain([a, 'optionalCall', _45 => _45(nt)]),()=>{u(void 0),_optionalChain([s, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.pause, 'call', _48 => _48()]),so(),lr()}),[]);let un=g=>{let M=Math.floor(g/3600),q=Math.floor(g/60)%60,Ie=Math.floor(g%60),uo=M>0?M<10?`0${M}:`:`${M}:`:"",mo=Ie<10?`0${Ie}`:`${Ie}`;return isNaN(Ie)||isNaN(q)||isNaN(M)?"":`${uo}${q}:${mo}`},lo=g=>{let M=parseFloat(g.value)/parseFloat(g.max)*100;j.current.style.setProperty("--seek-before-width",M+"%");let q=f*M/100;nt(q)};return _jsxruntime.jsxs.call(void 0, "div",{id:"audio-player-container",className:"flex flex-col",style:t,ref:j,children:[_jsxruntime.jsx.call(void 0, "video",{ref:s,className:"hidden",poster:o,title:r}),_jsxruntime.jsx.call(void 0, "input",{type:"range",min:"0",max:f!=null?Math.floor(f).toString():100,value:_nullishCoalesce(w, () => (0)),onChange:g=>lo(g.target),className:"w-full"}),_jsxruntime.jsxs.call(void 0, "section",{className:"flex w-full items-center justify-between text-sm font-medium",children:[_jsxruntime.jsx.call(void 0, "span",{id:"current-time",children:un(w)}),_jsxruntime.jsx.call(void 0, "span",{id:"duration",children:un(f)})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-6 flex items-center justify-center gap-x-12",children:[_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{variant:"outline",onClick:()=>tt(-10),"aria-label":"Rewind 10 Seconds",children:"-10"}),_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{variant:"outline",onClick:io,"aria-label":"Play Or Pause",children:[p===1&&_jsxruntime.jsx.call(void 0, _lucidereact.Play,{className:"h-5 w-5"}),p===0&&_jsxruntime.jsx.call(void 0, _lucidereact.Pause,{className:"h-5 w-5"})]}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{variant:"outline",onClick:()=>tt(10),"aria-label":"Fast Forward 10 Seconds",children:"+10"})]}),Z&&_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 flex w-full justify-center",children:_jsxruntime.jsx.call(void 0, oe,{})})]})});function da(){return navigator.userAgent.toLowerCase().indexOf("safari/")>-1}var mr=sa;var ca={pl:{returnsNavLabel:"Zwroty",openCourse:"Otw\xF3rz kurs"},en:{returnsNavLabel:"Returns",openCourse:"Open the course"}};function Xe(e=_chunk7RXW6XFYjs.f.call(void 0, )){return _chunk7RXW6XFYjs.a.call(void 0, ca,e)}function fr(){let[e,t]=mt.useState(13);return mt.useEffect(()=>{let n=setTimeout(()=>t(66),500);return()=>clearTimeout(n)},[]),_jsxruntime.jsx.call(void 0, "div",{className:"w-[60%] h-2 bg-gray-200 rounded-full overflow-hidden",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-full bg-blue-600 transition-all duration-300",style:{width:`${e}%`}})})}function ue(e,...t){console.warn(e,...t)}function Gt(e){console.error(e)}var ma=({accessToken:e,product:t,styles:n,reveal:a,onOpenCourse:r})=>{let o=t.productType,i=_chunkC3BBJOVVjs.m.call(void 0, ),d=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),c=_react3.useRef.call(void 0, null),[l]=_react.useAutoAnimate.call(void 0, ),[p,y]=_react3.useState.call(void 0, null),{mutateAsync:w,isPending:u}=_chunkSYN5KU3Ojs.m.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.userPanelGetFileDetails),f=_react3.useRef.call(void 0, void 0),[b,s]=_react3.useState.call(void 0, null),[k,T]=_react3.useState.call(void 0, null),[j,B]=_react3.useState.call(void 0, !1),{mutateAsync:A,isPending:J}=_chunkSYN5KU3Ojs.m.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.userPanelGetAudiobookDetails),{mutateAsync:ce,isPending:E}=_chunkSYN5KU3Ojs.m.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[Z,pe]=_react3.useState.call(void 0, null),[$,Be]=_react3.useState.call(void 0, null);async function Y(){try{let v=await w({accessId:t.accessId,accessToken:e});if(v.result.case==="success"){y(v.result.value.files);return}else ue("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),ue("Kod b\u0142\u0119du: ",v.result.value)}catch(v){ue("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Gt("B\u0142\u0105d podczas pobierania danych:"+v)}}async function xt(){try{let v=await A({accessId:t.accessId,accessToken:e});if(v.result.case==="audiobook"){s(v.result.value);return}else ue("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),ue("Kod b\u0142\u0119du: ",v.result.value)}catch(v){ue("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Gt("B\u0142\u0105d podczas pobierania danych:"+v)}}async function Ct(){try{let v=await ce({accessId:t.accessId,accessToken:e,isBrowser:!0});if(v.result.case==="success"){T(v.result.value.audiobookDownloadDetails),B(v.result.value.isAvailableToDownloadInMobileApp===!0);return}else ue("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),ue("Kod b\u0142\u0119du: ",v.result.value)}catch(v){ue("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Gt("B\u0142\u0105d podczas pobierania danych:"+v)}}return _react3.useEffect.call(void 0, ()=>{o===1&&(xt().then().catch(),Ct().then().catch())},[]),_react3.useEffect.call(void 0, ()=>{if(b!=null&&k!=null){let v=b.chapters;if(!v)return;let ne=v.map(we=>{let $e=_optionalChain([k, 'optionalAccess', _49 => _49.find, 'call', _50 => _50(Ne=>Ne.chapterId===we.id)]);if($e!=null)return{...we,publicUrl:$e.publicUrl,downloadableUrl:$e.downloadableUrl,duration:$e.duration}}).filter(we=>we!=null);ne!=null&&ne.length>0&&Be(ne)}},[b,k]),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:()=>a(),variant:"ghost",className:"w-fit",children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeft,{className:"h-6 w-6"}),_jsxruntime.jsx.call(void 0, "span",{className:"font-inter text-sm font-medium",children:"Wr\xF3\u0107"})]})}),_jsxruntime.jsxs.call(void 0, "main",{className:"grid grid-cols-1 justify-center gap-6 sm:justify-start lg:grid-cols-2",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full max-w-xl flex-col gap-6",children:[o===2&&_jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between gap-x-4",children:[_jsxruntime.jsx.call(void 0, "h4",{className:"text-xl font-semibold",children:"Twoje pliki"}),(p==null||p.length==0)&&_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:Y,"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?_jsxruntime.jsx.call(void 0, oe,{}):"Wy\u015Bwietl"})]}),u&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start gap-2",children:[_jsxruntime.jsx.call(void 0, fr,{}),_jsxruntime.jsx.call(void 0, "p",{className:"font-bold transition hover:text-blue-600",children:"Trwa przygotowanie plik\xF3w..."})]}),p!=null&&p.length>0&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-start justify-start gap-2",children:p.map((v,ne)=>_jsxruntime.jsxs.call(void 0, "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:v,download:!0,onClick:d,children:[`Plik numer ${ne+1}`,_jsxruntime.jsx.call(void 0, _lucidereact.Download,{width:14,height:14})]},ne))})]}),o===4&&_jsxruntime.jsx.call(void 0, "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:_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{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:Xe().openCourse})}),o===1&&_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsx.call(void 0, "h4",{className:"text-xl font-semibold",children:_nullishCoalesce(_optionalChain([Z, 'optionalAccess', _51 => _51.name]), () => ("Odtwarzacz"))}),_optionalChain([Z, 'optionalAccess', _52 => _52.description])&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:_optionalChain([Z, 'optionalAccess', _53 => _53.description])}),_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:J?_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-2",children:[_jsxruntime.jsx.call(void 0, oe,{}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:$!=null?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsx.call(void 0, mr,{ref:c,chapters:$,title:_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'optionalAccess', _54 => _54.name]), () => (t.productName)), () => (void 0)),imageURL:_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'optionalAccess', _55 => _55.coverImage]), () => (t.productImageUrl)), () => (void 0)),styles:n,setCurrentTimeHandler:v=>{f.current=v},uniqueProductID:t.productId,onChapterChange:v=>{pe(v)}})}):_jsxruntime.jsx.call(void 0, "p",{className:"mt-2",children:"Wybierz rozdzia\u0142, kt\xF3ry ci\u0119 interesuje."})})}),_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",children:[_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 mb-3 text-xs",children:j?"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."}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-3",children:[_jsxruntime.jsx.call(void 0, "a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:_jsxruntime.jsx.call(void 0, "img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),_jsxruntime.jsx.call(void 0, "a",{href:"https://docs.bitsnap.pl/guides/audiobook",children:_jsxruntime.jsx.call(void 0, "img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),_jsxruntime.jsx.call(void 0, "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&&_jsxruntime.jsx.call(void 0, "div",{className:"max-h-96 w-full overflow-y-auto",children:J?_jsxruntime.jsxs.call(void 0, "div",{className:"jusitfy-center flex flex-col items-center gap-2",children:[_jsxruntime.jsx.call(void 0, oe,{}),_jsxruntime.jsx.call(void 0, "p",{children:"\u0141adowanie rozdzia\u0142\xF3w..."})]}):_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h2",{className:"mb-3 text-xl font-semibold",children:"Rozdzia\u0142y"}),$==null?_jsxruntime.jsx.call(void 0, "p",{children:"Brak rozdzia\u0142\xF3w do wy\u015Bwietlenia."}):_jsxruntime.jsx.call(void 0, "ul",{className:"flex w-full flex-col gap-2",children:$.map((v,ne)=>_jsxruntime.jsxs.call(void 0, "li",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "button",{className:_chunkESF5ZVVFjs.g.call(void 0, "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",_optionalChain([Z, 'optionalAccess', _56 => _56.id])==v.id?"bg-neutral-200 dark:bg-neutral-700":"bg-neutral-100 dark:bg-neutral-800 dark:text-neutral-300"),onClick:()=>{c.current.selectChapter(v)},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium",children:v.name}),v.duration&&_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs text-neutral-500",children:[Math.floor(v.duration/60),":",String(Math.floor(v.duration%60)).padStart(2,"0")]})]}),v.description&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 text-xs",children:v.description})]}),b&&b.isDownloadable&&v.downloadableUrl&&_jsxruntime.jsx.call(void 0, "a",{href:v.downloadableUrl,onClick:d,children:_jsxruntime.jsx.call(void 0, _lucidereact.Download,{width:14,height:14})})]},ne))})]})})})]}),_jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-3xl font-semibold",children:t.productName}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-normal text-neutral-600 dark:text-neutral-300",children:t.productDescription}),_jsxruntime.jsx.call(void 0, "img",{src:t.productImageUrl,alt:"Product Photo",width:384,height:384,className:"max-h-sm max-w-sm",draggable:!1})]})]})]})},Pr=ma;var _connectquery = require('@connectrpc/connect-query');function br(e,t){let n=_connectquery.useTransport.call(void 0, ),[a,r]=_react3.useState.call(void 0, {status:"loading"});return _react3.useEffect.call(void 0, ()=>{if(!e){r({status:"hidden"});return}let o=!1;return r({status:"loading"}),Promise.resolve().then(() => _interopRequireWildcard(require("./model-files-client-P4PORZJ6.js"))).then(({listModelFiles:i})=>i(n,e,t)).catch(()=>({status:"hidden"})).then(i=>{o||r(i)}),()=>{o=!0}},[n,e,t]),a}var wa=_react3.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./PanelModelFiles-NYCOFPLY.js")))),xa=({accessToken:e,projectID:t,loginURL:n,styles:a,activeScreen:r,params:o,setParams:i,openCourse:d})=>{let{host:c}=_chunk4BL7TLK3js.j.call(void 0, ),{data:l,isLoading:p,error:y,refetch:w}=_chunkSYN5KU3Ojs.l.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.userPanelGetProducts,{accessToken:e}),u=br(e,t),f=Ca({products:p?{status:"loading"}:y!=null?{status:"error"}:_optionalChain([l, 'optionalAccess', _57 => _57.result, 'access', _58 => _58.case])==="success"?{status:"ok",count:l.result.value.products.length}:_optionalChain([l, 'optionalAccess', _59 => _59.result, 'access', _60 => _60.case])==="failure"?{status:"failure",unauthorized:l.result.value===9}:{status:"error"},modelFiles:u});if(_react3.useEffect.call(void 0, ()=>{f.kind==="signed-out"&&(_chunk4BL7TLK3js.n.call(void 0, t,c),window.location.href=n)},[f.kind,t,c,n]),f.kind==="loading"||f.kind==="signed-out")return _jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2 bg-white p-2 dark:bg-black",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-dark font-inter font-medium dark:text-white",children:_chunk7RXW6XFYjs.f.call(void 0, ).toLowerCase().startsWith("en")?"Loading...":"\u0141adowanie..."}),_jsxruntime.jsx.call(void 0, oe,{})]});let b=l&&l.result.case==="success"?l.result.value.products:[],s=u.status==="ready"?u.models:[],k=s.length>0?_jsxruntime.jsx.call(void 0, _react3.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, wa,{accessToken:e,models:s,buttonStyle:a})}):null;return f.kind==="error"?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, Ia,{onRetry:()=>void w()}),k]}):f.kind==="empty"?_jsxruntime.jsx.call(void 0, Na,{}):_jsxruntime.jsx.call(void 0, Sa,{accessToken:e,products:b,styles:a,activeScreen:r,params:o,setParams:i,openCourse:d,filesSection:k})};function Ca({products:e,modelFiles:t}){if(e.status==="failure"&&e.unauthorized)return{kind:"signed-out"};if(e.status==="loading")return{kind:"loading"};if(e.status==="ok"&&e.count>0)return{kind:"list"};if(t.status==="loading")return{kind:"loading"};if(e.status==="failure"||e.status==="error")return t.status==="unauthorized"?{kind:"signed-out"}:{kind:"error"};let n=t.status==="ready"?t.models.length:0;return e.count===0&&n===0?{kind:"empty"}:{kind:"list"}}function Na(){let e=_chunk7RXW6XFYjs.f.call(void 0, ).toLowerCase().startsWith("en");return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start gap-1","data-testid":"panel-empty",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:e?"Hi \u{1F44B}":"Hej \u{1F44B}"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:e?"You have no products in this shop yet. Your purchases will show up here.":"Nie masz jeszcze produkt\xF3w w tym sklepie. Twoje zakupy pojawi\u0105 si\u0119 tutaj."})]})}function Ia({onRetry:e}){let t=_chunk7RXW6XFYjs.f.call(void 0, ).toLowerCase().startsWith("en");return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start gap-3",role:"alert","data-testid":"panel-error",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:t?"Your products could not be loaded.":"Nie uda\u0142o si\u0119 wczyta\u0107 Twoich produkt\xF3w."}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{type:"button",onClick:e,className:"text-sm",children:t?"Try again":"Spr\xF3buj ponownie"})]})}var vr=xa,Sa=({accessToken:e,products:t,styles:n,filesSection:a,activeScreen:r,params:o,setParams:i,openCourse:d})=>{let[c,l]=_react3.useState.call(void 0, o.product?_protobuf.fromJsonString.call(void 0, _chunkSYN5KU3Ojs.e,o.product):void 0),p=u=>{u==null?(l(void 0),i({product:void 0,state:"products"})):i({product:_protobuf.toJsonString.call(void 0, _chunkSYN5KU3Ojs.e,u),state:"products"})};function y(u){switch(u){case 1:return"Audio";case 2:return"Plik";case 3:return"Bilet";case 4:return"Kurs";default:return}}function w(u){if(u.productType===4){d(u.accessId);return}l(u),p(u)}return r==="products"&&c!=null?_jsxruntime.jsx.call(void 0, Pr,{accessToken:e,product:c,styles:n,reveal:p,onOpenCourse:d}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Hej \u{1F44B}"}),t.length>0&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Poni\u017Cej znajdziesz swoje produkty"}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex flex-wrap items-center justify-center gap-9 sm:justify-start",children:_optionalChain([t, 'optionalAccess', _61 => _61.map, 'call', _62 => _62((u,f)=>_jsxruntime.jsxs.call(void 0, "section",{onClick:()=>w(u),className:"w-full max-w-xs cursor-pointer rounded drop-shadow-xl dark:border dark:border-slate-600 dark:drop-shadow-none",children:[_jsxruntime.jsxs.call(void 0, "section",{className:"flex flex-col items-center space-y-2 rounded bg-slate-100 p-4 dark:bg-neutral-900",children:[u.productType&&_jsxruntime.jsx.call(void 0, "div",{className:"w-fit self-end rounded bg-red-900 px-4 py-1",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-medium text-white dark:text-slate-100",children:y(u.productType)})}),_jsxruntime.jsx.call(void 0, "div",{className:"jusitfy-center flex max-h-40 items-center",children:_jsxruntime.jsx.call(void 0, "img",{src:u.productImageUrl,alt:`Product ${f} Photo`,draggable:!1,className:"aspect-auto max-h-40"})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-4 rounded bg-white p-4 dark:bg-black",children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-xl font-semibold",children:u.productName}),_jsxruntime.jsx.call(void 0, "p",{title:u.productDescription,className:"line-clamp-3 text-sm font-normal text-neutral-600 dark:text-neutral-300",children:ar(u.productDescription)}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:b=>{b.stopPropagation(),w(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"})]})]},f))])}),a]})};function La({activeScreen:e,setActiveScreen:t,setParams:n,styles:a,theme:r,logout:o}){return _jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsx.call(void 0, Da,{activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, Ea,{activeScreen:e,setActiveScreen:t,setParams:n,theme:r,logout:o})]})}var Cr=La;function Da({activeScreen:e,setActiveScreen:t,setParams:n}){let{returnsNavLabel:a}=Xe();return _jsxruntime.jsxs.call(void 0, "nav",{className:"flex w-full items-center justify-evenly gap-4 md:hidden",children:[_jsxruntime.jsx.call(void 0, ft,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, ft,{panelScreen:"orders",label:"Faktury",imageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, ft,{panelScreen:"returns",label:a,icon:_jsxruntime.jsx.call(void 0, _lucidereact.Undo2,{className:"h-5 w-5 text-white","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, ft,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n})]})}function ft({panelScreen:e,label:t,imageURL:n,icon:a,activeScreen:r,setActiveScreen:o,setParams:i}){return _jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:()=>{o(e),i({product:void 0,state:e})},"aria-label":t,variant:null,className:_chunkESF5ZVVFjs.g.call(void 0, "flex flex-col gap-0",r===e?"opacity-100":"opacity-50"),children:[_nullishCoalesce(a, () => (_jsxruntime.jsx.call(void 0, "img",{src:n,alt:t,className:"scale-75"}))),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-normal text-white",children:t})]})}function gt({panelScreen:e,label:t,imageURL:n,darkImageURL:a,icon:r,activeScreen:o,setActiveScreen:i,setParams:d,isExpanded:c}){return _jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:()=>{i(e),d({product:void 0,state:e})},variant:o===e?"secondary":"ghost",className:"justify-start",children:[r!=null?_jsxruntime.jsx.call(void 0, "span",{className:_chunkESF5ZVVFjs.g.call(void 0, "inline-flex h-5 w-5 items-center justify-center",c?"mr-4":"mr-2"),children:r}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "img",{src:n,alt:t,className:_chunkESF5ZVVFjs.g.call(void 0, "aspect-auto h-5 w-5 dark:hidden",c?"mr-4":"mr-2")}),_jsxruntime.jsx.call(void 0, "img",{src:a,alt:t,className:_chunkESF5ZVVFjs.g.call(void 0, "hidden aspect-auto h-5 w-5 dark:inline",c?"mr-4":"mr-2")})]}),c&&_jsxruntime.jsx.call(void 0, "span",{className:"md:text-medium hidden md:inline",children:t})]})}function Ea({activeScreen:e,setActiveScreen:t,setParams:n,theme:a,logout:r}){let[o]=_react.useAutoAnimate.call(void 0, ),[i,d]=_react3.useState.call(void 0, !0),{returnsNavLabel:c}=Xe();return _jsxruntime.jsxs.call(void 0, "div",{ref:o,className:_chunkESF5ZVVFjs.g.call(void 0, "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:[_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-between",children:_jsxruntime.jsx.call(void 0, Ma,{theme:a,isExpanded:i})}),_jsxruntime.jsx.call(void 0, wr,{className:"my-6"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-1 flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, gt,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-dark-24x24.svg",darkImageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, gt,{panelScreen:"orders",label:"Zam\xF3wienia",imageURL:"/icons/category-dark-24x24.svg",darkImageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, gt,{panelScreen:"returns",label:c,icon:_jsxruntime.jsx.call(void 0, _lucidereact.Undo2,{className:"h-5 w-5","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, gt,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-dark-24x24.svg",darkImageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i})]}),_jsxruntime.jsx.call(void 0, wr,{className:"mb-6"}),_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:r,children:[_jsxruntime.jsx.call(void 0, _lucidereact.LogOut,{className:"mr-2",width:16,height:16}),i&&_jsxruntime.jsx.call(void 0, "p",{className:"md:text-medium hidden md:inline md:text-center",children:"Wyloguj si\u0119"})]})]})}function wr({className:e}){return _jsxruntime.jsxs.call(void 0, "div",{className:_chunkESF5ZVVFjs.g.call(void 0, "relative h-px w-full bg-neutral-300",e),children:[_jsxruntime.jsx.call(void 0, "div",{className:"absolute -top-px left-0 h-1 w-1 rounded-full bg-neutral-500"}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute -top-px right-0 h-1 w-1 rounded-full bg-neutral-500"})]})}function Ma({theme:e,isExpanded:t}){return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[e==null&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xl tracking-wider md:inline dark:text-neutral-200",children:"bitsnap."}),(_optionalChain([e, 'optionalAccess', _63 => _63.logoDarkURL])||_optionalChain([e, 'optionalAccess', _64 => _64.logoURL]))&&_jsxruntime.jsx.call(void 0, "img",{src:_nullishCoalesce(e.logoDarkURL, () => (e.logoURL)),alt:"Company Logo",className:"hidden h-6 w-6 dark:inline",draggable:!1}),_optionalChain([e, 'optionalAccess', _65 => _65.logoURL])&&_jsxruntime.jsx.call(void 0, "img",{src:e.logoURL,alt:"Company Logo",className:"h-6 w-6 dark:hidden",draggable:!1})]})}function Ua({email:e,logout:t}){return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Profil"}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-6 flex-1 md:flex-none",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm text-neutral-500",children:"Email"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-base",children:e||"Brak danych"})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex w-full flex-col items-center space-y-2",children:_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:t,className:"max-w-64 md:hidden",children:[_jsxruntime.jsx.call(void 0, _lucidereact.LogOut,{className:"mr-2",width:16,height:16}),_jsxruntime.jsx.call(void 0, "p",{className:"text-medium inline text-center",children:"Wyloguj si\u0119"})]})})]})}var Ir=Ua;var Fa=_react3.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./course.js"))).then(e=>({default:e.PanelCourse})));function Wt(e){return _jsxruntime.jsx.call(void 0, _react3.Suspense,{fallback:_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center gap-2 p-2",role:"status",children:_jsxruntime.jsx.call(void 0, oe,{})}),children:_jsxruntime.jsx.call(void 0, Fa,{...e})})}function Ha({status:e}){let t={created:{color:"bg-neutral-100 text-neutral-700",icon:null},paid:{color:"bg-green-100 text-green-700",icon:_lucidereact.CheckCircle2},completed:{color:"bg-blue-100 text-blue-700",icon:_lucidereact.CheckCircle2},canceled:{color:"bg-red-100 text-red-700",icon:_lucidereact.AlertCircle},sent:{color:"bg-purple-100 text-purple-700",icon:_lucidereact.Truck},processing:{color:"bg-yellow-100 text-yellow-700",icon:_lucidereact.Loader2}},n=t[e]||t.created,a=n.icon,r={created:"Utworzone",paid:"Op\u0142acone",completed:"Zako\u0144czone",canceled:"Anulowane",sent:"Wys\u0142ane",processing:"Przetwarzane"};return _jsxruntime.jsxs.call(void 0, "span",{className:`inline-flex items-center gap-1 rounded-full px-3 py-1 text-sm font-medium ${n.color}`,children:[a&&_jsxruntime.jsx.call(void 0, a,{className:"h-4 w-4"}),r[e]||e]})}function Ga({orderID:e,email:t}){let[n,a]=_react3.useState.call(void 0, ""),r=_chunkSYN5KU3Ojs.m.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.addPublicOrderComment);return _jsxruntime.jsxs.call(void 0, "form",{onSubmit:async i=>{if(i.preventDefault(),!!n.trim())try{await r.mutateAsync({projectId:"",orderId:e,message:n.trim(),accessToken:t}),a("")}catch(d){console.error("Failed to add comment:",d)}},className:"mt-4 space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.d,{htmlFor:"comment",children:"Dodaj komentarz"}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.w,{id:"comment",value:n,onChange:i=>a(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:r.isPending}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{type:"submit",disabled:!n.trim()||r.isPending,children:r.isPending?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _lucidereact.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Wysy\u0142anie..."]}):"Dodaj komentarz"})]})}function Tr(e){return e?new Date(Number(e.seconds)*1e3).toLocaleDateString("pl-PL",{year:"numeric",month:"long",day:"numeric"}):"N/A"}function Ar(e,t){return new Intl.NumberFormat("pl-PL",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function Ka({orderID:e,initialEmail:t,onBack:n,accessToken:a,analytics:r}){let{theme:o,projectID:i}=_chunk4BL7TLK3js.j.call(void 0, ),d=_chunkC3BBJOVVjs.n.call(void 0, i,r,"order"),[c,l]=_react3.useState.call(void 0, t||""),[p,y]=_react3.useState.call(void 0, !1),{data:w,isLoading:u,error:f,refetch:b}=_chunkSYN5KU3Ojs.l.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.getPublicOrderDetails,{projectId:_nullishCoalesce(i, () => ("")),orderId:e,email:c||void 0,accessToken:a},{enabled:!!e}),s=_optionalChain([w, 'optionalAccess', _66 => _66.result, 'access', _67 => _67.case])==="order"?w.result.value:null,k=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _68 => _68.isVerified]), () => (!1)),T=s!=null;_react3.useEffect.call(void 0, ()=>{T&&d.track("panel_order_viewed",{},{order_ref:null})},[d,T]);let j=()=>{b(),y(!1)},B={"--button-background-color":_nullishCoalesce(_optionalChain([o, 'optionalAccess', _69 => _69.colors, 'optionalAccess', _70 => _70.brand]), () => ("#000000")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([o, 'optionalAccess', _71 => _71.colors, 'optionalAccess', _72 => _72.brandDark]), () => ("#ffffff")),"--button-text-color":_nullishCoalesce(_optionalChain([o, 'optionalAccess', _73 => _73.colors, 'optionalAccess', _74 => _74.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([o, 'optionalAccess', _75 => _75.colors, 'optionalAccess', _76 => _76.brand]), () => ("#000000"))};return u?_jsxruntime.jsx.call(void 0, "div",{className:"flex min-h-screen items-center justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"text-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Loader2,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):f||!s?_jsxruntime.jsx.call(void 0, "div",{className:"flex min-h-screen items-center justify-center",children:_jsxruntime.jsx.call(void 0, ye,{className:"w-full max-w-md",children:_jsxruntime.jsx.call(void 0, he,{className:"pt-6",children:_jsxruntime.jsxs.call(void 0, "div",{className:"text-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle,{className:"mx-auto h-12 w-12 text-red-500"}),_jsxruntime.jsx.call(void 0, "h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):_jsxruntime.jsx.call(void 0, "div",{className:"w-full bg-white py-8 dark:bg-black",style:B,children:_jsxruntime.jsxs.call(void 0, "div",{className:"w-full px-4",children:[n&&_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:n,variant:"ghost",className:"mb-4 w-fit",children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeft,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mb-6 flex items-center gap-4",children:[_optionalChain([o, 'optionalAccess', _77 => _77.logoURL])&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "img",{src:o.logoURL,alt:"Project logo",className:`h-12 w-auto ${o.logoDarkURL?"dark:hidden":""}`}),o.logoDarkURL&&_jsxruntime.jsx.call(void 0, "img",{src:o.logoDarkURL,alt:"Project logo",className:"hidden h-12 w-auto dark:block"})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),_jsxruntime.jsxs.call(void 0, "p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",s.orderId]})]})]}),_jsxruntime.jsxs.call(void 0, ye,{className:"mb-6",children:[_jsxruntime.jsx.call(void 0, xe,{children:_jsxruntime.jsxs.call(void 0, Ce,{className:"flex items-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Package,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),_jsxruntime.jsxs.call(void 0, he,{className:"space-y-6",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, Ha,{status:s.status}),s.processingStatus&&_jsxruntime.jsxs.call(void 0, "span",{className:"text-sm text-neutral-600",children:["\xB7 ",s.processingStatus]})]}),_jsxruntime.jsxs.call(void 0, "p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",Tr(s.createdAt)]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"border-t pt-4",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:k?"":"text-neutral-500",children:s.customerName})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Email:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:k?"":"text-neutral-500",children:s.customerEmail})]}),s.customerPhone&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Telefon:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:k?"":"text-neutral-500",children:s.customerPhone})]})]})]}),!k&&_jsxruntime.jsx.call(void 0, "div",{className:"border-t pt-4",children:_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:()=>y(!0),variant:"outline",className:"w-full",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Lock,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),_jsxruntime.jsxs.call(void 0, ye,{className:"mb-6",children:[_jsxruntime.jsx.call(void 0, xe,{children:_jsxruntime.jsx.call(void 0, Ce,{children:"Produkty"})}),_jsxruntime.jsxs.call(void 0, he,{className:"space-y-6",children:[_jsxruntime.jsx.call(void 0, "div",{className:"space-y-4",children:s.items.map((A,J)=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-4",children:[A.imageUrl&&_jsxruntime.jsx.call(void 0, "img",{src:A.imageUrl,alt:A.name,className:"h-16 w-16 rounded object-cover"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex-1",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-medium",children:A.name}),_jsxruntime.jsxs.call(void 0, "p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",A.quantity]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"text-right",children:_jsxruntime.jsx.call(void 0, "p",{className:"font-medium",children:Ar(Number(A.price),A.currency)})})]},J))}),(s.deliveryAddress||s.deliveryMethod)&&_jsxruntime.jsxs.call(void 0, "div",{className:"border-t pt-4",children:[_jsxruntime.jsxs.call(void 0, "h3",{className:"mb-3 flex items-center font-semibold",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Truck,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[s.deliveryAddress&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Adres:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:k?"":"text-neutral-500",children:s.deliveryAddress})]}),s.deliveryMethod&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Metoda:"})," ",s.deliveryMethod]}),s.trackingNumber&&k&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Tracking:"})," ",s.trackingNumber]})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"border-t pt-4",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-lg font-bold",children:[_jsxruntime.jsx.call(void 0, "span",{children:"Suma:"}),_jsxruntime.jsx.call(void 0, "span",{children:Ar(Number(s.totalAmount),s.currency)})]})})]})]}),_jsxruntime.jsxs.call(void 0, ye,{children:[_jsxruntime.jsx.call(void 0, xe,{children:_jsxruntime.jsxs.call(void 0, Ce,{children:["Komentarze ",s.commentCount>0&&`(${s.commentCount})`]})}),_jsxruntime.jsxs.call(void 0, he,{children:[s.comments.length>0?_jsxruntime.jsx.call(void 0, "div",{className:"space-y-4",children:s.comments.map(A=>_jsxruntime.jsxs.call(void 0, "div",{className:"border-b pb-4 last:border-b-0",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"mb-1 flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:A.authorName||"System"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs text-neutral-500",children:Tr(A.createdAt)}),A.authorType==="admin"&&_jsxruntime.jsx.call(void 0, "span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),_jsxruntime.jsx.call(void 0, "p",{className:k?"":"text-neutral-500",children:A.message})]},A.id))}):_jsxruntime.jsx.call(void 0, "p",{className:"text-neutral-600",children:"Brak komentarzy."}),k?_jsxruntime.jsx.call(void 0, Ga,{orderID:s.orderId,email:c}):_jsxruntime.jsx.call(void 0, "div",{className:"mt-4",children:_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:()=>y(!0),variant:"outline",className:"w-full",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Lock,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),p&&_jsxruntime.jsx.call(void 0, "div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:_jsxruntime.jsxs.call(void 0, ye,{className:"w-full max-w-md",children:[_jsxruntime.jsx.call(void 0, xe,{children:_jsxruntime.jsx.call(void 0, Ce,{children:"Zweryfikuj sw\xF3j email"})}),_jsxruntime.jsxs.call(void 0, he,{className:"space-y-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.d,{htmlFor:"verify-email",children:"Adres email"}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.s,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:c,onChange:A=>l(A.target.value)})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{variant:"outline",onClick:()=>y(!1),className:"flex-1",children:"Anuluj"}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:j,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function Wa(e){return _jsxruntime.jsx.call(void 0, Ka,{...e})}var Zt=Wa;var Za=({returnsAppearance:e,returnsTexts:t,analytics:n}={})=>{let{projectID:a,theme:r,loginURL:o,host:i}=_chunk4BL7TLK3js.j.call(void 0, ),d=_chunkC3BBJOVVjs.n.call(void 0, a,n,"panel"),c=_chunk4BL7TLK3js.k.call(void 0, a,i),l=_chunk4BL7TLK3js.m.call(void 0, a,i),{mutateAsync:p}=_chunkSYN5KU3Ojs.m.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.userPanelLogout);async function y(){c&&await p({accessToken:c}),typeof window<"u"&&(_chunk4BL7TLK3js.n.call(void 0, a,i),window.location.reload())}let[w]=_react.useAutoAnimate.call(void 0, ),u=E=>["products","notifications","profile","plans","orders","order-details","returns","return-details","course"].includes(E),[f,b]=Kn({product:void 0,state:"products",orderId:void 0,returnId:void 0,course:void 0,item:void 0}),[s,k]=_react3.useState.call(void 0, u(f.state)?f.state:"products"),T=E=>{b({state:"order-details",orderId:E}),k("order-details")},j=()=>{b({state:"orders",orderId:void 0}),k("orders")},B=E=>b({orderId:void 0,returnId:void 0,course:void 0,item:void 0,...E}),A=E=>{b({state:"course",course:E,item:void 0,product:void 0}),k("course")},J=()=>{b({state:"products",course:void 0,item:void 0,product:void 0}),k("products")};_react3.useEffect.call(void 0, ()=>{u(f.state)&&(f.state==="course"||s==="course")&&k(f.state)},[f.state]);let ce={"--button-background-color":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _78 => _78.colors, 'optionalAccess', _79 => _79.brand]), () => ("#000000")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _80 => _80.colors, 'optionalAccess', _81 => _81.brandDark]), () => ("#ffffff")),"--button-text-color":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _82 => _82.colors, 'optionalAccess', _83 => _83.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _84 => _84.colors, 'optionalAccess', _85 => _85.brand]), () => ("#000000"))};return _react3.useEffect.call(void 0, ()=>{if(c==null||c.length===0){window.location.href=_nullishCoalesce(o, () => ("/panel/login"));return}},[]),_react3.useEffect.call(void 0, ()=>{if(c==null||c.length===0){window.location.href=_nullishCoalesce(o, () => ("/panel/login"));return}},[s]),_react3.useEffect.call(void 0, ()=>{if(typeof window>"u"||window.parent!==window||!c)return;let E=Je(window.location.search);E&&Ze(E);let Z=_nullishCoalesce(E, () => (Le()));Z&&(window.location.href=De(Z,c))},[c]),_jsxruntime.jsx.call(void 0, _chunkC3BBJOVVjs.l,{value:d,children:_jsxruntime.jsxs.call(void 0, "div",{ref:w,className:"font-inter relative min-h-screen w-screen bg-beige-100 text-black dark:bg-black dark:text-white md:flex",children:[_jsxruntime.jsx.call(void 0, Cr,{activeScreen:s,setActiveScreen:k,setParams:B,styles:ce,theme:r,logout:y}),_jsxruntime.jsxs.call(void 0, "main",{className:"flex h-[calc(100vh-80px)] flex-col overflow-y-auto w-full p-5 md:h-screen",children:[s==="products"&&_jsxruntime.jsx.call(void 0, vr,{projectID:_nullishCoalesce(a, () => ("")),accessToken:c,loginURL:_nullishCoalesce(o, () => ("/panel/login")),styles:ce,activeScreen:s,params:f,setParams:b,openCourse:A}),s==="course"&&f.course&&c&&_jsxruntime.jsx.call(void 0, Wt,{accessId:f.course,accessToken:c,theme:r,itemId:f.item,onItemChange:E=>b({item:E}),onBack:J}),s==="notifications"&&_jsxruntime.jsx.call(void 0, Zn,{}),s==="plans"&&_jsxruntime.jsx.call(void 0, or,{projectID:_nullishCoalesce(a, () => (""))}),s==="orders"&&_jsxruntime.jsx.call(void 0, tr,{projectID:_nullishCoalesce(a, () => ("")),accessToken:_nullishCoalesce(c, () => ("")),openOrderDetails:T}),s==="order-details"&&f.orderId&&_jsxruntime.jsx.call(void 0, Zt,{orderID:f.orderId,onBack:j}),(s==="returns"||s==="return-details")&&c&&_jsxruntime.jsx.call(void 0, $t,{projectID:_nullishCoalesce(a, () => ("")),host:i,accessToken:c,loginURL:_nullishCoalesce(o, () => ("/panel/login")),appearance:Wn(e,_optionalChain([r, 'optionalAccess', _86 => _86.colors, 'optionalAccess', _87 => _87.brand])),texts:t,screen:s,params:f,setParams:b,setActiveScreen:k}),s==="profile"&&_jsxruntime.jsx.call(void 0, Ir,{email:l,logout:y})]})]})})},Ya= exports.n =Za;var _reactquery = require('@tanstack/react-query');var _connect = require('@connectrpc/connect');var _connectweb = require('@connectrpc/connect-web');var de;(a=>{function e(r){return _connect.createClient.call(void 0, _chunkSYN5KU3Ojs.f,n(r))}a.get=e;let t=new Map;function n(r){let o=t.get(r);return o==null&&(o=_connectweb.createConnectTransport.call(void 0, {useBinaryFormat:!0,baseUrl:r+"/api/rpc",interceptors:[_chunkESF5ZVVFjs.b]}),t.set(r,o)),o}})(de = exports.a||={});var _zod = require('zod'); var _zod2 = _interopRequireDefault(_zod);function U(e,t=2){return+(Math.round(+(e+"e+"+t))+"e-"+t)}function Or(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 Ll=_zod2.default.object({event:_zod2.default.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:_zod2.default.string().optional(),value:_zod2.default.number().optional(),currency:_zod2.default.string().optional(),content_name:_zod2.default.string().optional(),items:_zod2.default.array(_zod2.default.object({id:_zod2.default.string(),name:_zod2.default.string(),price:_zod2.default.number().default(0),currency:_zod2.default.string().default("PLN"),quantity:_zod2.default.number().default(1)})).optional()});function Yt(e){typeof window>"u"||(ei(e),ni(e),ri(e))}function ei(e){try{typeof window.dataLayer>"u"&&(window.dataLayer=[]);let t=ti(e);window.dataLayer.push(t)}catch(t){console.warn("cannot send google analytics event",t)}}function ti(e){let t=_nullishCoalesce(_nullishCoalesce(e.value, () => (_optionalChain([e, 'access', _88 => _88.items, 'optionalAccess', _89 => _89.reduce, 'call', _90 => _90((o,i)=>o+(i.price||0)*(i.quantity||1),0)]))), () => (0)),n=_optionalChain([e, 'access', _91 => _91.items, 'optionalAccess', _92 => _92.map, 'call', _93 => _93(o=>({item_id:o.id,item_name:o.name||o.id,price:U((o.price||0)/100,2),quantity:o.quantity||1}))]),a={currency:e.currency||"PLN",value:U(t/100,2)};n&&n.length>0&&(a.items=n);let r;switch(e.event){case"purchase":r="purchase",a.transaction_id=e.step||`txn_${Date.now()}`;break;case"addToCart":r="add_to_cart";break;case"viewCart":r="view_cart";break;case"removeFromCart":r="remove_from_cart";break;case"initiateCheckout":r="begin_checkout";break;case"customizeProduct":r="customize_product";break;default:r=e.event}return{event:r,ecommerce:a,...e.step&&{step:e.step},...e.content_name&&{content_name:e.content_name}}}function ni(e){if(typeof window.fbq>"u")return;let t="",n="",a={};switch(e.event){case"purchase":t="track",n="Purchase",a={category_name:e.step,...e};break;case"lead":t="track",n="Lead",a={category_name:e.step,...e};break;case"addToCart":t="track",n="Add to Cart",a={category_name:e.step,...e};break;case"customizeProduct":t="track",n="Customize Product",a={category_name:e.step,...e};break;case"viewCart":t="track",n="View Cart",a={category_name:e.step,...e};break;case"removeFromCart":t="track",n="Remove from Cart",a={category_name:e.step,...e};break;case"initiateCheckout":t="track",n="Initiate Checkout",a={category_name:e.step,...e};break;default:break}window.location.search.includes("analytics")&&console.log("Pushing FB event",t,n,a),window.fbq(t,n,a)}function ri(e){try{if(typeof window.ttq>"u")return;let t=oi(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 oi(e){let t=_nullishCoalesce(_nullishCoalesce(e.value, () => (_optionalChain([e, 'access', _94 => _94.items, 'optionalAccess', _95 => _95.reduce, 'call', _96 => _96((o,i)=>o+(i.price||0)*(i.quantity||1),0)]))), () => (0)),n=_optionalChain([e, 'access', _97 => _97.items, 'optionalAccess', _98 => _98.map, 'call', _99 => _99(o=>({content_id:o.id,content_type:"product",content_name:o.name||o.id,quantity:o.quantity||1,price:U((o.price||0)/100,2)}))])||[];n.length===0&&e.content_name&&n.push({content_id:e.step||"unknown",content_type:"product",content_name:e.content_name,quantity:1,price:U(t/100,2)});let a={currency:e.currency||"PLN",value:U(t/100,2)};n.length>0&&(a.contents=n);let r=null;switch(e.event){case"purchase":r="Purchase";break;case"addToCart":r="AddToCart";break;case"initiateCheckout":r="InitiateCheckout";break;case"customizeProduct":r="CustomizeProduct";break;case"viewCart":return;case"removeFromCart":return;case"lead":return;default:return null}return{eventName:r,eventPayload:a}}function Ur(e){let{items:t,googlePayConfig:n,checkout:a,result:r,cartRequiresShipping:o}=e,i=_nullishCoalesce(e.locale, () => (_chunk7RXW6XFYjs.f.call(void 0, )));if(r.totalAmount==null)return;let d=[];return o&&(d.push("SHIPPING_ADDRESS"),d.push("SHIPPING_OPTION")),{apiVersion:2,apiVersionMinor:0,callbackIntents:d,allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["MASTERCARD","VISA"]},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:n.gateway,gatewayMerchantId:n.gatewayId}}}],emailRequired:!0,shippingAddressParameters:{phoneNumberRequired:o},shippingAddressRequired:o,shippingOptionRequired:o,shippingOptionParameters:o?{shippingOptions:r.methods.slice(0,5).map(l=>({id:l.id,label:l.name+` - ${Or(l.amount,r.currency)}`,description:_nullishCoalesce(l.description, () => (""))})),defaultSelectedOptionId:r.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:n.merchantId+"",merchantName:n.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:_chunk7RXW6XFYjs.c.call(void 0, "paymentForCart",i,e.texts),totalPrice:`${U(r.totalAmount/100,2)}`,currencyCode:r.currency,countryCode:r.country,checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",displayItems:ai(t,r.methods,_nullishCoalesce(r.selectedDeliveryMethod, () => ((r.methods.length>0?r.methods[0].id:void 0))),a.couponCode,r.couponValue,_chunk7RXW6XFYjs.c.call(void 0, "coupon",i,e.texts))}}}function ai(e,t,n,a,r,o="Coupon"){let i=[],d=0;for(let l of e){if(l.details==null)continue;let p=_nullishCoalesce(_optionalChain([l, 'access', _100 => _100.details, 'access', _101 => _101.pricing, 'optionalAccess', _102 => _102.effectivePrice]), () => (l.details.price));d+=p*l.quantity,i.push({label:l.details.name+" x "+l.quantity,price:`${U(p/100,2)}`,type:"LINE_ITEM",status:"FINAL"})}let c=t.find(l=>l.id===n);return c!=null&&i.push({label:c.name,price:`${U(c.amount/100,2)}`,type:"SHIPPING_OPTION",status:"FINAL"}),a!=null&&r!=null&&i.push({label:`${o} ${a}`,price:`${U(r/100,2)}`,type:"DISCOUNT",status:"FINAL"}),d>0&&i.push({label:"Subtotal",price:`${U(d/100,2)}`,type:"SUBTOTAL",status:"FINAL"}),i}function _e(e,t){return`${_chunkESF5ZVVFjs.e}/api/integrations/${e}/public-commerce${t}`}function ke(e){return typeof e=="object"&&e!=null&&"ERR"in e}function F(e,t,n){return{ERR:!0,error:e,type:t,data:n}}function _r(e,t){return _optionalChain([t, 'optionalAccess', _103 => _103.find, 'call', _104 => _104(n=>n.id===e||(_nullishCoalesce(_optionalChain([n, 'access', _105 => _105.variants, 'optionalAccess', _106 => _106.some, 'call', _107 => _107(a=>a.id===e)]), () => (!1))))])}function jr(e,t){let n=new Set(t.map(a=>a.productID));return Array.from(new Set(e.filter(a=>!n.has(a))))}function zr(e,t){let n=_optionalChain([e, 'optionalAccess', _108 => _108.trim, 'call', _109 => _109()]);if(!(n==null||n.length===0))try{let a=new URL(n,t);return a.protocol!=="http:"&&a.protocol!=="https:"?void 0:a.href}catch (e6){return}}var _zustand = require('zustand');var je=_zustand.create.call(void 0, 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}))}));var Pt=_react3.createContext.call(void 0, {});function Kl({texts:e,locale:t,children:n}){let a=_react3.useMemo.call(void 0, ()=>({texts:e,locale:t}),[e,t]);return _jsxruntime.jsx.call(void 0, Pt.Provider,{value:a,children:n})}function qr(){return _react3.useContext.call(void 0, Pt)}function Wl(e){let{texts:t,locale:n}=_react3.useContext.call(void 0, Pt);return _chunk7RXW6XFYjs.c.call(void 0, e,_nullishCoalesce(n, () => (_chunk7RXW6XFYjs.f.call(void 0, ))),t)}function Vl(){let{texts:e,locale:t}=_react3.useContext.call(void 0, Pt),n=_nullishCoalesce(t, () => (_chunk7RXW6XFYjs.f.call(void 0, )));return _react3.useMemo.call(void 0, ()=>a=>_chunk7RXW6XFYjs.c.call(void 0, a,n,e),[n,e])}var en="bitsnap-pending-order";function Hr(e,t){let n=new Map;for(let r of t)n.set(r.id,(_nullishCoalesce(n.get(r.id), () => (0)))+r.quantity);let a=[];for(let r of e){let o=n.get(r.id);o==null?a.push(r):r.quantity>o&&a.push({...r,quantity:r.quantity-o})}return a}var ci=60*1e3;function Gr(e,t=Date.now,n=ci){let a;return r=>{let o=`${r.orderId}:${r.ts}`,i=t();return _optionalChain([a, 'optionalAccess', _110 => _110.key])===o&&i-a.at<n?Promise.reject(new Error("pending order was asked about recently")):(a={key:o,at:i},e(r))}}function li(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 (e7){return}}function ui(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 (e8){return!1}}function mi(e,t=Date.now(),n={}){if(ui(e.url))return;let a=li(e.url),r=_nullishCoalesce(Br(e.orderId), () => (_optionalChain([a, 'optionalAccess', _111 => _111.orderId]))),o=_nullishCoalesce(Br(e.projectId), () => (_optionalChain([a, 'optionalAccess', _112 => _112.projectId])));if(!(r==null||o==null))return{orderId:r,projectId:o,...n.cartProjectId!=null?{cartProjectId:n.cartProjectId}:{},lines:_nullishCoalesce(n.lines, () => ([])),ts:t}}function Yl(e,t={}){let n=mi(e,t.now,t);return n!=null&&pi(n,t.storage)}function Br(e){return e!=null&&e.length>0?e:void 0}function bt(){try{return typeof localStorage>"u"?void 0:localStorage}catch (e9){return}}function pi(e,t=bt()){try{return _optionalChain([t, 'optionalAccess', _113 => _113.setItem, 'call', _114 => _114(en,JSON.stringify(e))]),t!=null}catch (e10){return!1}}function $r(e=bt()){try{let t=_optionalChain([e, 'optionalAccess', _115 => _115.getItem, 'call', _116 => _116(en)]);if(t==null)return;let n=JSON.parse(t);if(typeof n=="object"&&n!=null&&typeof n.orderId=="string"&&typeof n.projectId=="string"&&typeof n.ts=="number"&&n.orderId.length>0){let{orderId:a,projectId:r,cartProjectId:o,ts:i,lines:d}=n;return{orderId:a,projectId:r,...typeof o=="string"?{cartProjectId:o}:{},lines:Array.isArray(d)?d.filter(c=>typeof _optionalChain([c, 'optionalAccess', _117 => _117.id])=="string"&&typeof c.quantity=="number"):[],ts:i}}}catch (e11){}Xt(e)}function Xt(e=bt()){try{_optionalChain([e, 'optionalAccess', _118 => _118.removeItem, 'call', _119 => _119(en)])}catch (e12){}}function Kr(e){let t=_nullishCoalesce(_optionalChain([e, 'access', _120 => _120.details, 'optionalAccess', _121 => _121.status]), () => (fi(_optionalChain([e, 'access', _122 => _122.details, 'optionalAccess', _123 => _123.$unknown]))));return t==="created"||t==="placed"||t==="paid"||t==="canceled"?t:"unknown"}function fi(e){if(Array.isArray(e)){for(let t of e)if(_optionalChain([t, 'optionalAccess', _124 => _124.no])===3&&t.wireType===2&&t.data instanceof Uint8Array){let n=0,a=0;for(let r=0;a<t.data.length&&r<35;r+=7){let o=t.data[a++];if(n|=(o&127)<<r,!(o&128))break}if(a+n!==t.data.length)return;try{return new TextDecoder().decode(t.data.subarray(a))}catch (e13){return}}}}async function Wr(e){let t=_nullishCoalesce(e.storage, () => (bt())),n=$r(t);if(n==null)return"none";if((_nullishCoalesce(e.now, () => (Date.now)))()-n.ts>864e5)return Xt(t),"expired";if(e.projectId!=null&&n.cartProjectId!=null&&n.cartProjectId!==e.projectId)return"pending";let r;try{r=await e.fetchStatus(n)}catch (e14){return"pending"}let o=$r(t);if(_optionalChain([o, 'optionalAccess', _125 => _125.orderId])!==n.orderId||o.ts!==n.ts)return"pending";if(r==="paid"||r==="placed"){try{await e.removeLines(n.lines)}catch (e15){return"pending"}return Xt(t),"paid"}return"pending"}var vi="__m_a",Xr=_react3.createContext.call(void 0, void 0),on= exports.J =void 0;function Cu(e){_chunk4BL7TLK3js.a.call(void 0, {projectID:e}),on= exports.J =e,typeof window<"u"&&_chunk4BL7TLK3js.g.call(void 0, [window.location.origin])}function qe(){return _nullishCoalesce(_nullishCoalesce(on, () => (_optionalChain([document, 'access', _126 => _126.querySelector, 'call', _127 => _127('script[data-id][data-name="internal-cart"]'), 'optionalAccess', _128 => _128.getAttribute, 'call', _129 => _129("data-id")]))), () => (void 0))}function ki(){return _nullishCoalesce(_optionalChain([document, 'access', _130 => _130.querySelector, 'call', _131 => _131('script[data-id][data-name="internal-cart"]'), 'optionalAccess', _132 => _132.getAttribute, 'call', _133 => _133("data-custom-host")]), () => (void 0))}var wi=({children:e,locale:t})=>{let[n]=_react3.useState.call(void 0, ()=>new _reactquery.QueryClient),a=qr();_react3.useEffect.call(void 0, ()=>{Fe()},[]);let r=qe();if(_react3.useEffect.call(void 0, ()=>{if(r==null)return;let i=()=>{Ni(r).then(c=>{c==="paid"&&n.invalidateQueries({queryKey:["cart"]})})},d=()=>{document.visibilityState==="visible"&&i()};return i(),window.addEventListener("pageshow",i),document.addEventListener("visibilitychange",d),()=>{window.removeEventListener("pageshow",i),document.removeEventListener("visibilitychange",d)}},[r,n]),r==null)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{});let o=sn(r,_nullishCoalesce(t, () => (a.locale)),a.texts);return _jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:n,children:_jsxruntime.jsx.call(void 0, Xr.Provider,{value:o,children:e})})},tn,xi=Gr(async e=>Kr(await de.get(_chunkESF5ZVVFjs.e).getOrder({id:e.orderId,projectId:e.projectId})));function Nu(){let{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:a}=_nullishCoalesce(R(), () => (kt));return{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:a}}function Iu(){return(_nullishCoalesce(_optionalChain([R, 'call', _134 => _134(), 'optionalAccess', _135 => _135.products]), () => ([]))).map(e=>({id:e.id,quantity:e.quantity}))}function Ci(e){let t=R();V({...t,products:Hr(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _136 => _136.products]), () => ([])),e)}),Fe()}function Ni(e){return tn??=Wr({projectId:e,fetchStatus:xi,removeLines:Ci}).catch(t=>{console.warn("cannot check the pending order",t)}).finally(()=>{tn=void 0}),tn}var ze=async(e,t)=>{let n=[];_optionalChain([t, 'optionalAccess', _137 => _137.items])!=null&&t.items.length>0?n=t.items:n=_nullishCoalesce(_optionalChain([R, 'call', _138 => _138(), 'optionalAccess', _139 => _139.products]), () => ([]));let a=Array.from(new Set(n.map(i=>i.productID)));if(a.length===0)return[];let r=new URLSearchParams;r.set("ids",a.join(",")),r.set("locale",_nullishCoalesce(_optionalChain([t, 'optionalAccess', _140 => _140.locale]), () => (_chunk7RXW6XFYjs.f.call(void 0, ))));let o;try{let i=await fetch(_chunkESF5ZVVFjs.c.call(void 0, _e(e,`/products?${r.toString()}`)),{method:"GET"});if(i.status!=200)return F("products-load-failed","internal");o=await i.json()}catch(i){return console.warn("cannot load the products of the cart",i),F("products-load-failed","internal")}return n.flatMap(i=>{let d=_r(i.productID,o.result);return d==null?[]:[{...i,details:Li(i.productID,d),catalogProductID:d.id}]})},Su= exports.P =()=>{let e=_react3.useContext.call(void 0, Xr);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},Ru= exports.Q =wi,Ii=_zod2.default.object({isAvailable:_zod2.default.boolean(),merchantId:_zod2.default.string(),merchantName:_zod2.default.string(),gateway:_zod2.default.string(),gatewayId:_zod2.default.string()}),Si=_zod2.default.object({id:_zod2.default.string(),productID:_zod2.default.string(),quantity:_zod2.default.number(),priceVersion:_zod2.default.string().optional(),metadata:_zod2.default.record(_zod2.default.string(),_zod2.default.string().optional()).optional(),url:_zod2.default.string().optional()}),Ri=_zod2.default.object({country:_zod2.default.string().optional(),couponCode:_zod2.default.string().optional(),selectedDeliveryMethod:_zod2.default.string().optional(),postalCode:_zod2.default.string().optional(),email:_zod2.default.string().optional(),products:_zod2.default.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},eo="checkout";function R(){try{let e=localStorage.getItem(eo);return e==null?kt:Ri.parse(JSON.parse(e))}catch (e16){return kt}}async function Jr(e,t){let n=await ze(e,{items:t.map((o,i)=>({...o,id:`price-check-${i}`}))});if(ke(n))return n;let a=jr(t.map(o=>o.productID),n);if(a.length>0)return F("item-ids-not-found","notFound",a);let r=R();r.products==null&&(r.products=[]),r.products.push(...t.map(o=>({id:Math.random().toString(36).substring(7),productID:o.productID,quantity:o.quantity,priceVersion:_optionalChain([n, 'access', _141 => _141.find, 'call', _142 => _142(i=>i.productID===o.productID), 'optionalAccess', _143 => _143.details, 'optionalAccess', _144 => _144.pricing, 'optionalAccess', _145 => _145.priceVersion]),metadata:o.metadata,url:zr(o.url,typeof window<"u"?window.location.href:void 0)}))),Ti(t,n),Yt({event:"addToCart",currency:"PLN",items:t.map(o=>({id:o.productID,name:_nullishCoalesce(o.name, () => ("")),price:_nullishCoalesce(o.price, () => (0)),quantity:o.quantity,currency:_nullishCoalesce(o.currency, () => ("PLN"))}))}),V(r),Fe()}function Ti(e,t){for(let n of e)try{let a=t.find(d=>d.productID===n.productID),r=_nullishCoalesce(_nullishCoalesce(_optionalChain([a, 'optionalAccess', _146 => _146.details, 'optionalAccess', _147 => _147.pricing, 'optionalAccess', _148 => _148.effectivePrice]), () => (_optionalChain([a, 'optionalAccess', _149 => _149.details, 'optionalAccess', _150 => _150.price]))), () => (n.price)),o=_nullishCoalesce(_optionalChain([a, 'optionalAccess', _151 => _151.details, 'optionalAccess', _152 => _152.currency]), () => (n.currency));if(r==null||o==null)continue;let i=_nullishCoalesce(_optionalChain([a, 'optionalAccess', _153 => _153.catalogProductID]), () => (n.productID));(_nullishCoalesce(n.analytics, () => (_chunkC3BBJOVVjs.o.call(void 0, )))).track("add_to_cart",{qty:n.quantity,value_minor:Math.round(r*n.quantity),currency:o},{product_id:i,variant_id:i!==n.productID?n.productID:null})}catch (e17){}}function Zr(e){let t=R(),n={...t,products:_optionalChain([t, 'optionalAccess', _154 => _154.products, 'optionalAccess', _155 => _155.filter, 'call', _156 => _156(a=>!e.includes(a.productID)&&!e.includes(a.id))])};Yt({event:"removeFromCart",items:e.map(a=>({id:a,name:"",price:0,quantity:1,currency:"PLN"}))}),V(n),Fe()}function V(e){localStorage.setItem(eo,JSON.stringify(e))}function Yr(e,t){if(e.products==null||e.products.length==0)return;let n=e.products.reduce((a,r)=>(r.metadata!=null&&Object.keys(r.metadata).forEach(o=>{let i=_optionalChain([r, 'access', _157 => _157.metadata, 'optionalAccess', _158 => _158[o]]);i!=null&&(a[o]=i)}),a),{});return{items:e.products.map(a=>({id:a.productID,quantity:a.quantity,priceVersion:a.priceVersion})),askForNote:!0,countries:e.country?[e.country]:void 0,metadata:n,locale:t}}var sn=(e,t=_chunk7RXW6XFYjs.f.call(void 0, ),n)=>{let a=ki();return a!=null&&_chunkESF5ZVVFjs.f.call(void 0, a),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await de.get(_chunkESF5ZVVFjs.e).isOneClickPaymentAvailable({projectId:e})).applePay}catch(r){return console.error("Error checking if Apple Pay is available",r),!1}},async getGooglePayConfiguration(r){if(typeof window>"u"||typeof document>"u")return{isAvailable:!1};try{let o=await Ai(e);if(_optionalChain([o, 'optionalAccess', _159 => _159.isAvailable])!=!0)return{isAvailable:!1};let i=R();if(i==null)return console.log("checkout is null"),{isAvailable:!1};let d=await ze(e,{locale:t,items:r.items.map(y=>({id:Math.random().toString(36).substring(7),quantity:y.quantity,metadata:y.metadata,productID:y.productID}))});if(ke(d))return{isAvailable:!1};let c=await de.get(_chunkESF5ZVVFjs.e).getPreOrderDetails({items:d.map(y=>_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.c,{id:y.productID,quantity:y.quantity})),projectId:e,postCode:i.postalCode,couponCode:i.couponCode,countryCode:i.country,selectedDeliveryMethod:i.selectedDeliveryMethod});if(c.totalAmount==null)return{isAvailable:!1};let l=d.find(y=>_optionalChain([y, 'access', _160 => _160.details, 'optionalAccess', _161 => _161.isDeliverable])==!0)!=null,p=await Ur({items:d,googlePayConfig:o,checkout:i,cartRequiresShipping:l,result:c,locale:t,texts:n});return p==null?{isAvailable:!1}:{isAvailable:!0,config:p}}catch(o){return console.error("Error resolving Google Pay configuration",o),{isAvailable:!1}}},async clearCart(){let r=structuredClone(kt);r.country=_optionalChain([R, 'call', _162 => _162(), 'optionalAccess', _163 => _163.country]),V(r),Fe()},async getAvailableCountries(){let r=await fetch(_chunkESF5ZVVFjs.c.call(void 0, _e(e,"/countries")),{method:"GET"});if(r.status!=200)return[];try{return _zod2.default.array(_zod2.default.object({name:_zod2.default.string(),code:_zod2.default.string()})).parse(await r.json())}catch(o){return F(o.toString(),"internal")}},async getCountry(){let r=_optionalChain([R, 'call', _164 => _164(), 'optionalAccess', _165 => _165.country]);if(r==null){r="PL";let o=R();o.country=r,V(o)}return r},async getNumberOfElementsInCart(){return _nullishCoalesce(_optionalChain([R, 'call', _166 => _166(), 'optionalAccess', _167 => _167.products, 'optionalAccess', _168 => _168.reduce, 'call', _169 => _169((r,o)=>r+o.quantity,0)]), () => (0))},async getProducts(){return await ze(e,{locale:t})},async removeProductFromCart(r){return Zr([r.id])},async setCountry(r){let o=R();o.country=r,V(o)},async setCouponCodeIfPossible(r){let o=R();o.couponCode=r,V(o)},async setPostalCode(r){let o=R();o.postalCode=r,V(o)},async setDeliveryMethod(r){let o=R();o.selectedDeliveryMethod=r,V(o)},async setEmail(r){let o=R();o.email=r,V(o)},async addProduct(r){return await Jr(e,[r])},async updateQuantity(r){let o=R();o.products=_optionalChain([o, 'access', _170 => _170.products, 'optionalAccess', _171 => _171.map, 'call', _172 => _172(i=>(i.id===r.id&&(i.quantity=r.quantity),i))]),V(o),Fe()},async getPaymentMethodChoice(){let r=Yr(R(),t);return r==null?null:Qr(r)},async redirectToNextStep(r){let o=Yr(R(),t);if(o==null)return F("cart-is-empty","badInput");_optionalChain([r, 'optionalAccess', _173 => _173.paymentMethod])!=null&&(o.paymentMethod=r.paymentMethod);let i=await rn(o);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 o={items:[{id:r.productID,quantity:1}],askForNote:!1,details:r.email||r.name?{name:r.name,email:r.email}:void 0,locale:_nullishCoalesce(r.locale, () => (t))};o=an(o),r.country==null&&(r.country="pl"),o.details==null&&(o.details={}),o.details.address==null&&(o.details.address={}),o.details.address.country=r.country,r.marketingAgreement===!0&&(o.additionalAgreements=[{id:vi,name:"",required:!0,answer:!0}]);let i=await rn(o);return ke(i)?i:{url:i.url}},async getApplePayPreview(r){let o=R();try{let i=await de.get(_chunkESF5ZVVFjs.e).getPreOrderDetails({items:r.items.map(d=>_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.c,{id:d.productID,quantity:d.quantity})),projectId:e,postCode:o.postalCode,couponCode:o.couponCode,countryCode:o.country,selectedDeliveryMethod:o.selectedDeliveryMethod});return i.totalAmount==null||i.currency.length===0?F("pre-order-unavailable","internal"):{countryCode:i.country||o.country||"PL",currencyCode:i.currency,totalAmount:`${U(i.totalAmount/100,2)}`}}catch(i){return console.warn("cannot load the Apple Pay preview",i),F("pre-order-unavailable","internal")}},async completeApplePayPayment(r){let o=R();if(o==null)return F("Checkout not found");let i=await ze(e,{locale:t});if(ke(i))return i;try{let d=_optionalChain([r, 'access', _174 => _174.shippingContact, 'optionalAccess', _175 => _175.givenName]);_optionalChain([r, 'access', _176 => _176.shippingContact, 'optionalAccess', _177 => _177.familyName])!=null?d+=" "+_optionalChain([r, 'access', _178 => _178.shippingContact, 'optionalAccess', _179 => _179.familyName]):_optionalChain([r, 'access', _180 => _180.billingContact, 'optionalAccess', _181 => _181.familyName])!=null&&(d+=" "+_optionalChain([r, 'access', _182 => _182.billingContact, 'optionalAccess', _183 => _183.familyName]));let c={},l=vt();l!=null&&(c.ref=l);let p=await de.get(_chunkESF5ZVVFjs.e).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(r.token.paymentData),paymentMethod:JSON.stringify(r.token.paymentMethod),transactionIdentifier:r.token.transactionIdentifier,order:_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.d,{items:i.map(y=>({id:y.productID,quantity:y.quantity})),couponCode:o.couponCode,email:_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([r, 'access', _184 => _184.shippingContact, 'optionalAccess', _185 => _185.emailAddress]), () => (_optionalChain([r, 'access', _186 => _186.billingContact, 'optionalAccess', _187 => _187.emailAddress]))), () => (o.email)), () => (void 0)),phone:_nullishCoalesce(_nullishCoalesce(_optionalChain([r, 'access', _188 => _188.shippingContact, 'optionalAccess', _189 => _189.phoneNumber]), () => (_optionalChain([r, 'access', _190 => _190.billingContact, 'optionalAccess', _191 => _191.phoneNumber]))), () => (void 0)),selectedDeliveryMethod:o.selectedDeliveryMethod,postCode:o.postalCode,projectId:e}),shippingAddress:_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.a,{line1:_nullishCoalesce(_optionalChain([r, 'access', _192 => _192.shippingContact, 'optionalAccess', _193 => _193.addressLines, 'optionalAccess', _194 => _194[0]]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _195 => _195.shippingContact, 'optionalAccess', _196 => _196.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _197 => _197.shippingContact, 'optionalAccess', _198 => _198.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _199 => _199.shippingContact, 'optionalAccess', _200 => _200.postalCode]), () => ("")),name:d}),billingAddress:_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.b,{name:_nullishCoalesce(_optionalChain([r, 'access', _201 => _201.billingContact, 'optionalAccess', _202 => _202.givenName]), () => (" "+(_nullishCoalesce(_optionalChain([r, 'access', _203 => _203.billingContact, 'optionalAccess', _204 => _204.familyName]), () => (""))))),line1:_nullishCoalesce(_optionalChain([r, 'access', _205 => _205.billingContact, 'optionalAccess', _206 => _206.addressLines, 'optionalAccess', _207 => _207[0]]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _208 => _208.billingContact, 'optionalAccess', _209 => _209.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _210 => _210.billingContact, 'optionalAccess', _211 => _211.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _212 => _212.billingContact, 'optionalAccess', _213 => _213.postalCode]), () => (""))}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:p.isSuccess,redirectURL:p.redirectUrl}}catch(d){return console.error(d),F("Failed to authorize payment")}},async completeGooglePayPayment(r){let o=R();if(o==null)return F("Checkout not found");let i=await ze(e,{locale:t});if(ke(i))return i;try{let d=_optionalChain([r, 'access', _214 => _214.paymentData, 'access', _215 => _215.shippingAddress, 'optionalAccess', _216 => _216.name]),c={},l=vt();l!=null&&(c.ref=l);let p=await de.get(_chunkESF5ZVVFjs.e).authorizeOneClickPayment({gateway:1,paymentData:r.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:r.paymentData.paymentMethodData.type,transactionIdentifier:"",order:_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.d,{items:i.map(y=>({id:y.productID,quantity:y.quantity})),couponCode:o.couponCode,email:_nullishCoalesce(r.paymentData.email, () => (void 0)),phone:_nullishCoalesce(_optionalChain([r, 'access', _217 => _217.paymentData, 'access', _218 => _218.shippingAddress, 'optionalAccess', _219 => _219.phoneNumber]), () => (void 0)),selectedDeliveryMethod:_nullishCoalesce(_optionalChain([r, 'access', _220 => _220.paymentData, 'access', _221 => _221.shippingOptionData, 'optionalAccess', _222 => _222.id]), () => (o.selectedDeliveryMethod)),postCode:_optionalChain([r, 'access', _223 => _223.paymentData, 'access', _224 => _224.shippingAddress, 'optionalAccess', _225 => _225.postalCode]),projectId:e}),shippingAddress:_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.a,{line1:_nullishCoalesce(_optionalChain([r, 'access', _226 => _226.paymentData, 'access', _227 => _227.shippingAddress, 'optionalAccess', _228 => _228.address1]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _229 => _229.paymentData, 'access', _230 => _230.shippingAddress, 'optionalAccess', _231 => _231.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _232 => _232.paymentData, 'access', _233 => _233.shippingAddress, 'optionalAccess', _234 => _234.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _235 => _235.paymentData, 'access', _236 => _236.shippingAddress, 'optionalAccess', _237 => _237.postalCode]), () => ("")),name:d}),billingAddress:_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.b,{name:_optionalChain([r, 'access', _238 => _238.paymentData, 'access', _239 => _239.paymentMethodData, 'access', _240 => _240.info, 'optionalAccess', _241 => _241.billingAddress, 'optionalAccess', _242 => _242.name]),line1:_nullishCoalesce(_optionalChain([r, 'access', _243 => _243.paymentData, 'access', _244 => _244.paymentMethodData, 'access', _245 => _245.info, 'optionalAccess', _246 => _246.billingAddress, 'optionalAccess', _247 => _247.address1]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _248 => _248.paymentData, 'access', _249 => _249.paymentMethodData, 'access', _250 => _250.info, 'optionalAccess', _251 => _251.billingAddress, 'optionalAccess', _252 => _252.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _253 => _253.paymentData, 'access', _254 => _254.paymentMethodData, 'access', _255 => _255.info, 'optionalAccess', _256 => _256.billingAddress, 'optionalAccess', _257 => _257.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _258 => _258.paymentData, 'access', _259 => _259.paymentMethodData, 'access', _260 => _260.info, 'optionalAccess', _261 => _261.billingAddress, 'optionalAccess', _262 => _262.postalCode]), () => (""))}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:p.isSuccess,redirectURL:p.redirectUrl}}catch(d){return console.error(d),F("Failed to authorize payment")}return{isSuccess:!0}},async getApplePayPaymentRequest(r){let o=R();if(o==null)return F("Checkout not found");r&&r.expectedItems!=null&&r.expectedItems.length>0&&(o.products&&Zr(o.products.map(l=>l.productID)),await Jr(e,r.expectedItems));let i=await ze(e,{locale:t});if(ke(i))return i;let d=await de.get(_chunkESF5ZVVFjs.e).getPreOrderDetails({items:i.map(l=>_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.c,{id:l.productID,quantity:l.quantity})),projectId:e,postCode:o.postalCode,couponCode:o.couponCode,countryCode:o.country,selectedDeliveryMethod:o.selectedDeliveryMethod}),c=i.map(l=>({amount:`${U(l.quantity*(_nullishCoalesce(_nullishCoalesce(_optionalChain([l, 'access', _263 => _263.details, 'optionalAccess', _264 => _264.pricing, 'optionalAccess', _265 => _265.effectivePrice]), () => (_optionalChain([l, 'access', _266 => _266.details, 'optionalAccess', _267 => _267.price]))), () => (0)))/100,2)}`,label:_optionalChain([l, 'access', _268 => _268.details, 'optionalAccess', _269 => _269.name])+" - "+l.quantity,type:"final"}));if(d.selectedDeliveryMethod!=null){let l=d.methods.find(p=>p.id==d.selectedDeliveryMethod);l!=null&&c.push({amount:`${U(l.amount/100,2)}`,label:l.name,type:"final"})}return d.couponCode!=null&&d.couponValue!=null&&c.push({amount:`-${U(d.couponValue/100,2)}`,label:d.couponCode,type:"final"}),{countryCode:d.country||o.country||"PL",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],total:{amount:`${U((_nullishCoalesce(d.totalAmount, () => (0)))/100,2)}`,label:_chunk7RXW6XFYjs.c.call(void 0, "paymentForCart",t,n),type:"final"},shippingMethods:d.methods.map(l=>({amount:`${U(l.amount/100,2)}`,detail:_nullishCoalesce(l.description, () => ("")),identifier:l.id,label:l.name,dateComponentsRange:{startDateComponents:{days:_nullishCoalesce(l.minDays, () => (1)),hours:0,months:0,years:0},endDateComponents:{days:_nullishCoalesce(l.maxDays, () => (14)),hours:0,months:0,years:0}}})),lineItems:c,currencyCode:d.currency||_optionalChain([i, 'access', _270 => _270[0], 'optionalAccess', _271 => _271.details, 'optionalAccess', _272 => _272.currency])||"PLN"}}}};async function Ai(e){let t=R();if(_optionalChain([t, 'access', _273 => _273.googlePayConfig, 'optionalAccess', _274 => _274.isAvailable])!=!0){let n=await de.get(_chunkESF5ZVVFjs.e).isOneClickPaymentAvailable({projectId:e});n.googlePay==!0&&n.googlePayConfig!=null?t.googlePayConfig={isAvailable:!0,gateway:n.googlePayConfig.gateway,gatewayId:n.googlePayConfig.gatewayMerchantId,merchantName:n.googlePayConfig.merchantName,merchantId:n.googlePayConfig.merchantId}:t.googlePayConfig={isAvailable:!1,gateway:"",gatewayId:"",merchantName:"",merchantId:""}}return V(t),t.googlePayConfig}function Li(e,t){if(e==t.id){let a=_optionalChain([t, 'access', _275 => _275.variants, 'optionalAccess', _276 => _276.findIndex, 'call', _277 => _277(r=>r.id===e)]);if(a!=null&&a!=-1){let r=t.variants[a];return{...t,availableQuantity:r.availableQuantity,isDeliverable:r.isDeliverable,images:_nullishCoalesce(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=_optionalChain([t, 'access', _278 => _278.variants, 'optionalAccess', _279 => _279.find, 'call', _280 => _280(a=>a.id===e)]);return n==null?t:{...t,id:n.id,name:t.name+" "+n.name,baseName:t.name,variantName:n.name,price:n.price,currency:n.currency,pricing:n.pricing,metadata:t.metadata,availableQuantity:n.availableQuantity,isDeliverable:n.isDeliverable,images:_nullishCoalesce(n.images, () => (t.images))}}function Fe(){let e=R(),t=0;if(e==null){je.setState(n=>({...n,numberOfProductsInCart:t}));return}t=_nullishCoalesce(_optionalChain([e, 'access', _281 => _281.products, 'optionalAccess', _282 => _282.reduce, 'call', _283 => _283((n,a)=>n+a.quantity,0)]), () => (0)),je.setState(n=>({...n,numberOfProductsInCart:t}))}var Ei=200,Mi= exports.s ="item-ids-not-found",et="internal-error",to={"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"},Oi=new Set(["internal","invalid-request"]),Ui=new Set(["product-not-available","product-not-found"]);function _i(e){return typeof e=="string"&&Object.hasOwn(to,e)?to[e]:void 0}function ji(e){return/<\/?[a-z!?][^>]*>/i.test(e)}function zi(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 Fi(e){return/Error:/.test(e)||/\n\s+at /.test(e)}function dn(e){let t=e.trim();if(!(t.length===0||t.length>Ei||/[\r\n]/.test(t)||ji(t)||zi(t)||Fi(t)))return t}var qi=3;function wt(e,t=0){if(typeof e=="object"&&e!=null){if(Array.isArray(e)||t>=qi)return{};let n=e,a=wt(n.error,t+1);if(a.message==null&&n.message!=null){let r=wt(n.message,t+1);a={...r,code:_nullishCoalesce(a.code, () => (r.code))}}return typeof n.code=="string"&&n.code.length>0&&(a.code=n.code),a}if(typeof e!="string")return{};try{let n=JSON.parse(e);return typeof n=="object"&&n!=null?wt(n,t+1):{}}catch (e18){}return{message:dn(e)}}function Bi(e){let t;try{t=JSON.parse(e)}catch (e19){return{code:et,message:dn(e)}}if(typeof t=="string")return{code:et,message:dn(t)};if(typeof t!="object"||t==null)return{code:et};let n=t,{message:a,code:r}=wt(n.error),o={code:typeof n.code=="string"&&n.code.length>0?n.code:_nullishCoalesce(r, () => (et)),message:a};return Array.isArray(n.itemIds)&&(o.itemIds=n.itemIds.filter(i=>typeof i=="string")),o}function cn(e,t){let{code:n,message:a,itemIds:r}=Bi(t),o=r!=null&&r.length>0;if(o&&(n===et||Ui.has(n)))return F(Mi,"badInput",r);let i={message:a};return o&&(i.itemIds=r),F(n,e>=500?"internal":"badInput",i)}function Eu(e,t){let n=_i(e.error);if(n!=null)return t(n);if(e.type==="internal"||typeof e.error=="string"&&Oi.has(e.error))return t("checkoutFailed");let a=_optionalChain([e, 'access', _284 => _284.data, 'optionalAccess', _285 => _285.message]);return typeof a=="string"&&a.length>0?a:t("checkoutFailed")}var $i=["online","manual","cod"],Hi=["bankTransfer","blik"];function no(e,t){if(!Array.isArray(e))return[];let n=[];for(let a of e)t.includes(a)&&!n.includes(a)&&n.push(a);return n}function Gi(e){if(typeof e!="object"||e==null)return null;let t=e.choice;if(typeof t!="object"||t==null)return null;let n=no(t.methods,$i);return n.length<2?null:{methods:n,manualAccountTypes:no(t.manualAccountTypes,Hi)}}function Ou(e){if(e==null)return null;let t=e.methods.filter(n=>n!=="cod");return t.length<2?null:{...e,methods:t}}function Uu(e,t){return t!=null&&e.methods.includes(t)?t:e.methods[0]}function _u(e){let t=e.includes("bankTransfer"),n=e.includes("blik");return n&&!t?"paymentMethodManualBlik":t&&!n?"paymentMethodManualTransfer":"paymentMethodManualBoth"}async function ro(e,t,n=5e3){let a=typeof AbortController>"u"?void 0:new AbortController,r=setTimeout(()=>_optionalChain([a, 'optionalAccess', _286 => _286.abort, 'call', _287 => _287()]),n);try{let o=await fetch(e,{method:"POST",headers:t.headers,body:t.body,signal:_optionalChain([a, 'optionalAccess', _288 => _288.signal])});return o.ok?Gi(await o.json()):null}catch (e20){return null}finally{clearTimeout(r)}}var Ki;(a=>{async function e(r,o=1,i,d){let c=qe();if(c==null)throw new Error("No project ID found");let p=await sn(c).addProduct({productID:r,quantity:o,metadata:i,...d});if(p!=null)return p}a.addProductToCart=e;function t(){je.setState({isCartVisible:!0})}a.showCart=t;function n(){je.setState({isCartVisible:!1})}a.hideCart=n})(Ki = exports.y||={});async function oo(e){try{return await e.text()}catch (e21){return""}}function ao(e,t){return t=an(t),t.locale??=_chunk7RXW6XFYjs.f.call(void 0, ),{headers:{..._chunkESF5ZVVFjs.a,..._chunkC3BBJOVVjs.h.call(void 0, e),"Content-Type":"application/json"},body:JSON.stringify(t)}}async function Qr(e){let t=qe();return t==null?null:ro(_e(t,"/payment-methods"),ao(t,e))}async function rn(e){let t=qe();if(t==null)throw new Error("No project ID found");let n=await fetch(_e(t,"/buy"),{method:"POST",...ao(t,e)});if(n.status!=200){let r=cn(n.status,await oo(n));return console.warn("cannot create payment URL",n.status,r.error),r}let a=await n.json();return{url:a.url,...a.orderId!=null?{orderId:a.orderId}:{},...a.projectId!=null?{projectId:a.projectId}:{}}}async function Wu(e){let t=qe();if(t==null)throw new Error("No project ID found");let n={..._chunkESF5ZVVFjs.a,..._chunkC3BBJOVVjs.h.call(void 0, t),"Content-Type":"application/json",...e.apiKey!=null?{Authorization:`Bearer ${e.apiKey}`}:{}},a=e.testMode?`/api/payment/link/auto/${t}/test`:`/api/payment/link/auto/${t}`;delete e.apiKey,delete e.testMode,e.locale??=_chunk7RXW6XFYjs.f.call(void 0, );let r=await fetch(_chunkESF5ZVVFjs.e+a,{method:"POST",headers:n,body:JSON.stringify(e)});return r.ok?{status:"ok",redirectURL:(await r.json()).url}:{...cn(r.status,await oo(r)),status:"error"}}function vt(){if(typeof localStorage>"u")return;let e=localStorage.getItem("bitsnap-ref");if(e!=null)return e}function an(e){let t=vt();return t==null||(e.metadata==null&&(e.metadata={}),e.metadata.ref=t),e}exports.a = de; exports.b = ye; exports.c = xe; exports.d = Ce; exports.e = he; exports.f = Fn; exports.g = Je; exports.h = Ze; exports.i = Le; exports.j = De; exports.k = Io; exports.l = Jn; exports.m = Zt; exports.n = Ya; exports.o = U; exports.p = Or; exports.q = Yt; exports.r = ke; exports.s = Mi; exports.t = Eu; exports.u = Ou; exports.v = Uu; exports.w = _u; exports.x = je; exports.y = Ki; exports.z = Qr; exports.A = rn; exports.B = Wu; exports.C = vt; exports.D = an; exports.E = Kl; exports.F = Wl; exports.G = Vl; exports.H = Yl; exports.I = vi; exports.J = on; exports.K = Cu; exports.L = qe; exports.M = Nu; exports.N = Iu; exports.O = Ni; exports.P = Su; exports.Q = Ru; exports.R = sn;
|
|
4
|
-
//# sourceMappingURL=chunk-555KFWGY.js.map
|