bitsnap-react 1.11.1 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -7
- package/dist/CartProvider-WPJWECBS.mjs +2 -0
- package/dist/CartProvider-YPZ3HD7W.js +2 -0
- package/dist/CartProvider-YPZ3HD7W.js.map +1 -0
- package/dist/analytics.js +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/analytics.mjs +1 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.js.map +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/chunk-3ITTSNWG.js +2 -0
- package/dist/chunk-3ITTSNWG.js.map +1 -0
- package/dist/chunk-4BV5IUZH.js +2 -0
- package/dist/chunk-4BV5IUZH.js.map +1 -0
- package/dist/{chunk-UFIOJGJZ.js → chunk-4ZFIL5S7.js} +2 -2
- package/dist/chunk-4ZFIL5S7.js.map +1 -0
- package/dist/{chunk-JUDR4EZA.mjs → chunk-DRAKVCD7.mjs} +2 -2
- package/dist/{chunk-HWQNT6XU.mjs → chunk-G3VVAVG7.mjs} +2 -2
- package/dist/chunk-GJNFDUJN.mjs +4 -0
- package/dist/chunk-GJNFDUJN.mjs.map +1 -0
- package/dist/{chunk-ETGHIHWR.mjs → chunk-HBPSSGYN.mjs} +2 -2
- package/dist/{chunk-WGJTXDIS.js → chunk-HDLCLZOK.js} +2 -2
- package/dist/chunk-HDLCLZOK.js.map +1 -0
- package/dist/{chunk-3IVLQILF.js → chunk-I6BRDRPB.js} +2 -2
- package/dist/chunk-I6BRDRPB.js.map +1 -0
- package/dist/chunk-JSDGZ4NY.js.map +1 -1
- package/dist/chunk-KOYBZORL.js.map +1 -1
- package/dist/{chunk-VPBFEAFQ.js → chunk-MZSLLGFS.js} +2 -2
- package/dist/chunk-MZSLLGFS.js.map +1 -0
- package/dist/{chunk-UCL4Y7L3.js → chunk-STVEBT6M.js} +2 -2
- package/dist/chunk-STVEBT6M.js.map +1 -0
- package/dist/{chunk-IJLHU2MA.mjs → chunk-T2YSOHJM.mjs} +2 -2
- package/dist/{chunk-IJLHU2MA.mjs.map → chunk-T2YSOHJM.mjs.map} +1 -1
- package/dist/chunk-T3PAOMHI.mjs +2 -0
- package/dist/chunk-T3PAOMHI.mjs.map +1 -0
- package/dist/chunk-VDLJW4JJ.mjs +2 -0
- package/dist/chunk-VDLJW4JJ.mjs.map +1 -0
- package/dist/{chunk-DWRBPP32.mjs → chunk-VF62KDNS.mjs} +2 -2
- package/dist/chunk-VRL3IF5J.js +4 -0
- package/dist/chunk-VRL3IF5J.js.map +1 -0
- package/dist/chunk-XIHGWNTS.js.map +1 -1
- package/dist/consent.js.map +1 -1
- package/dist/course.js +1 -1
- package/dist/course.js.map +1 -1
- package/dist/course.mjs +1 -1
- package/dist/embed/analytics.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +97 -2
- package/dist/index.d.ts +97 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/methods-FVDH6Y57.mjs +2 -0
- package/dist/methods-ISVX5JQ7.js +2 -0
- package/dist/methods-ISVX5JQ7.js.map +1 -0
- package/dist/models.js.map +1 -1
- package/dist/returns.js +1 -1
- package/dist/returns.js.map +1 -1
- package/dist/returns.mjs +1 -1
- package/package.json +2 -2
- package/dist/CartProvider-QY2DMNCC.js +0 -2
- package/dist/CartProvider-QY2DMNCC.js.map +0 -1
- package/dist/CartProvider-XMHPQRWC.mjs +0 -2
- package/dist/chunk-2PK36NGB.mjs +0 -4
- package/dist/chunk-2PK36NGB.mjs.map +0 -1
- package/dist/chunk-2X32DDUM.mjs +0 -2
- package/dist/chunk-2X32DDUM.mjs.map +0 -1
- package/dist/chunk-3IVLQILF.js.map +0 -1
- package/dist/chunk-FBTYZHXM.js +0 -4
- package/dist/chunk-FBTYZHXM.js.map +0 -1
- package/dist/chunk-G2UOTVS5.mjs +0 -2
- package/dist/chunk-G2UOTVS5.mjs.map +0 -1
- package/dist/chunk-Q25D7OAO.js +0 -2
- package/dist/chunk-Q25D7OAO.js.map +0 -1
- package/dist/chunk-UCL4Y7L3.js.map +0 -1
- package/dist/chunk-UFIOJGJZ.js.map +0 -1
- package/dist/chunk-VPBFEAFQ.js.map +0 -1
- package/dist/chunk-WGJTXDIS.js.map +0 -1
- package/dist/chunk-YBGAYEJQ.js +0 -2
- package/dist/chunk-YBGAYEJQ.js.map +0 -1
- package/dist/methods-ALO22YWQ.mjs +0 -2
- package/dist/methods-ZBX4BTDE.js +0 -2
- package/dist/methods-ZBX4BTDE.js.map +0 -1
- /package/dist/{CartProvider-XMHPQRWC.mjs.map → CartProvider-WPJWECBS.mjs.map} +0 -0
- /package/dist/{chunk-JUDR4EZA.mjs.map → chunk-DRAKVCD7.mjs.map} +0 -0
- /package/dist/{chunk-HWQNT6XU.mjs.map → chunk-G3VVAVG7.mjs.map} +0 -0
- /package/dist/{chunk-ETGHIHWR.mjs.map → chunk-HBPSSGYN.mjs.map} +0 -0
- /package/dist/{chunk-DWRBPP32.mjs.map → chunk-VF62KDNS.mjs.map} +0 -0
- /package/dist/{methods-ALO22YWQ.mjs.map → methods-FVDH6Y57.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as fi,B as vi,C as wi,F as ke,G as lt,H as Dt,I as _t,J as Ce,a as Me,b as zt,c as Et,d as ft,e as Fe,f as It,g as He,h as Ve,i as xt,j as or,k as ir,l as nr,m as sr,n as cr,o as At,p as Ir,q as Ar,r as xe,s as kt,t as ct,u as F,v as Rr,w as $e,x as Ze,y as gi,z as hi}from"./chunk-2PK36NGB.mjs";import{a as Dr}from"./chunk-JUDR4EZA.mjs";import{A as Er,a as ve,b as W,c as lr,d as pr,e as dr,f as ur,i as br,k as mr,l as gr,m as hr,n as fr,o as vr,p as wr,q as yr,r as xr,t as kr,u as Cr,v as Sr,w as Pr,x as Nr,y as Tr,z as zr}from"./chunk-HWQNT6XU.mjs";import{a as yi,b as xi,c as ki,d as Ci}from"./chunk-2X32DDUM.mjs";import{a as Ke,b as Qe}from"./chunk-KOVKUJAW.mjs";import{a as Qa,b as $a,c as Za,d as Xa,e as Ya,f as Ja,g as tr,h as er,i as ar,j as rr}from"./chunk-ETGHIHWR.mjs";import{g as he,h as Ka,j as et,k as ee,l as st,o as fe,q as D,r as Mt,u as We}from"./chunk-DWRBPP32.mjs";import{d as r,f as Tt,g as Wa,j as we,l as ye,m as Rt}from"./chunk-G2UOTVS5.mjs";import{l as Pt,m as Nt,n as ht,q as qe}from"./chunk-IJLHU2MA.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";import Xe from"apple-pay-button";function Lt(){try{return lt()}catch{return}}import{useQuery as _r}from"@tanstack/react-query";import{jsx as ae}from"react/jsx-runtime";var Lr=Xe.default??Xe;function Ur({style:t,buttonType:e,colorType:a,items:o,onClick:c}){let{checkIfApplePayIsAvailable:d,getApplePayPaymentRequest:i,completeApplePayPayment:w,setCountry:h,setCouponCodeIfPossible:u,setDeliveryMethod:v,setEmail:k,setPostalCode:S,clearCart:x}=Dt(),b=Nt(),{data:g}=_r({queryKey:["is-apple-pay-available"],queryFn:d});if(g!=!0)return null;let C=o.map(p=>({productID:p.id,quantity:p.quantity,metadata:p.metadata}));async function y(){let p=!1,s=n=>{p||(p=!0,b.track("apple_pay_result",{outcome:n}))};b.track("apple_pay_clicked",{}),b.track("payment_method_selected",{gateway:"apple_pay",method:"apple_pay"}),ct({event:"initiateCheckout",items:o.map(n=>({id:n.id,name:n.name,price:n.price,quantity:n.quantity,currency:"PLN"}))});let P=o.find(n=>n.isDeliverable===!0)!=null,f=new ApplePaySession(14,{countryCode:"PL",merchantCapabilities:["supports3DS"],supportedNetworks:["visa","masterCard"],currencyCode:"PLN",total:{amount:`${xe(o.reduce((n,l)=>n+l.price*l.quantity,0)/100,2)}`,label:"P\u0142atno\u015B\u0107 za koszyk",type:"pending"},lineItems:[...o.map(n=>({amount:`${xe(n.price*n.quantity/100,2)}`,label:n.name,type:"final"})),P?{amount:"16.99",type:"pending",label:"Dostawa"}:void 0].filter(n=>n!=null),...P?{shippingMethods:[],supportsCouponCode:!0,requiredBillingContactFields:["name","email","postalAddress","phone"],requiredShippingContactFields:["name","email","postalAddress","phone"]}:{}});await c?.();let B=await i({expectedItems:C});if(F(B)){console.error("Error creating ApplePaySession:",B.error),s("fail");return}f.oncancel=n=>{console.log("ApplePaySession cancelled",n),s("cancel")},f.onvalidatemerchant=async n=>{try{let l=await Me.get(Tt).applePayValidateMerchant({validationUrl:n.validationURL,projectId:lt()});console.log("merchantSession",l.merchantSession),l.merchantSession.length>0?(console.log("completing merchant session"),f.completeMerchantValidation(JSON.parse(l.merchantSession))):f.abort()}catch{f.abort}},f.onshippingmethodselected=async n=>{console.log("shipping method selected",n),b.track("delivery_method_selected",{method:n.shippingMethod.identifier}),await v(n.shippingMethod.identifier);let l=await i({expectedItems:C});if(console.log("apRequest",l),F(l))throw f.abort(),new Error("Failed to get Apple Pay payment request");f.completeShippingMethodSelection({newTotal:l.total,newLineItems:l.lineItems,newShippingMethods:l.shippingMethods})},f.onshippingcontactselected=async n=>{try{n.shippingContact.countryCode!=null&&await h(n.shippingContact.countryCode),n.shippingContact.postalCode!=null&&await S(n.shippingContact.postalCode),n.shippingContact.phoneNumber!=null&&await k(n.shippingContact.emailAddress);let l=await i({expectedItems:C});if(F(l))throw f.abort(),new Error("Failed to get Apple Pay payment request");console.log("apRequest",l),f.completeShippingContactSelection({newLineItems:l.lineItems,newTotal:l.total,newShippingMethods:l.shippingMethods})}catch(l){console.log("shipping contact selected error",l),f.abort()}},f.oncouponcodechanged=async n=>{try{console.log("coupon code changed",n);let l=await u(n.couponCode),N=await i({expectedItems:C});if(console.log("apRequest",N),F(N))throw f.abort(),new Error("Failed to get Apple Pay payment request");f.completeCouponCodeChange({errors:F(l)?[new ApplePayError("couponCodeInvalid")]:void 0,newTotal:N.total,newLineItems:N.lineItems,newShippingMethods:N.shippingMethods})}catch(l){console.log("coupon code changed error",l),f.abort()}},f.onpaymentauthorized=async n=>{b.track("payment_submitted",{gateway:"apple_pay",method:"apple_pay"});try{let l=await w({token:n.payment.token,billingContact:n.payment.billingContact,shippingContact:n.payment.shippingContact});if(F(l)){console.log("apple pay error",l),s("fail"),f.completePayment({status:ApplePaySession.STATUS_FAILURE});return}l.redirectURL&&setTimeout(()=>{open(l.redirectURL,"_self")},2e3),s(l.isSuccess?"success":"fail"),f.completePayment({status:l.isSuccess?ApplePaySession.STATUS_SUCCESS:ApplePaySession.STATUS_FAILURE}),l.isSuccess&&x()}catch{s("fail"),f.completePayment({status:ApplePaySession.STATUS_FAILURE})}},f.begin()}return ae(Lr,{style:t,buttonStyle:a,type:e,onClick:y})}function Br(t){let e=ht(Lt(),t.analytics,"cart");return ae(Pt,{value:e,children:ae(_t,{children:ae(Ur,{...t})})})}var Se=Br;import{useEffect as Ht}from"react";import $ from"zod";import{useAutoAnimate as vo}from"@formkit/auto-animate/react";import{createPortal as wo}from"react-dom";import{createContext as Fr,useContext as Hr,useMemo as Vr}from"react";var Or=["root","overlay","panel","header","title","closeButton","productList","product","productImage","productName","productPrice","quantityControl","quantityInput","quantityButton","removeButton","summary","totalLabel","totalValue","deliveryText","countryLabel","countryTrigger","countryDropdown","countrySearch","countryOption","paymentButtons","checkoutButton","emptyState","error","skeleton"],Gr={fontFamily:"--bitsnap-checkout-font-family",fontSize:"--bitsnap-checkout-font-size",background:"--bitsnap-checkout-background",surface:"--bitsnap-checkout-surface",foreground:"--bitsnap-checkout-foreground",mutedForeground:"--bitsnap-checkout-muted-foreground",border:"--bitsnap-checkout-border",buttonBackground:"--bitsnap-checkout-button-background",buttonForeground:"--bitsnap-checkout-button-foreground",buttonHoverBackground:"--bitsnap-checkout-button-hover-background",hoverSurface:"--bitsnap-checkout-hover-surface",focusRing:"--bitsnap-checkout-focus-ring",error:"--bitsnap-checkout-error",overlay:"--bitsnap-checkout-overlay",radius:"--bitsnap-checkout-radius"},jr={dark:{},light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#e4e4e7",focusRing:"#71717a",error:"#dc2626",overlay:"rgb(0 0 0 / 0.35)"}},Mr=[{token:"background",variable:"--background"},{token:"foreground",variable:"--foreground"},{token:"surface",variable:"--card"},{token:"surface",variable:"--popover"},{token:"foreground",variable:"--popover-foreground"},{token:"mutedForeground",variable:"--muted-foreground"},{token:"border",variable:"--border"},{token:"border",variable:"--input"},{token:"focusRing",variable:"--ring"},{token:"error",variable:"--destructive"},{token:"radius",variable:"--radius"}];function qr(t){return{"--popover":t.surface??"var(--color-neutral-800)","--popover-foreground":t.foreground??"var(--color-neutral-200)"}}function Pe(t){let e=Ke(t,{defaultTheme:"dark",presets:jr,variables:Gr,shadcnVariables:Mr});return{theme:e.theme,isCustomized:e.isCustomized,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle,dropdownStyle:qr(e.tokens)}}function Ye(t,e){return Qe(t.elements,e)}import{jsx as Wr}from"react/jsx-runtime";var Je=Fr(Pe());function ta({appearance:t,children:e}){let a=Vr(()=>Pe(t),[t]);return Wr(Je.Provider,{value:a,children:e})}function qt(){return Hr(Je)}function T(t){let e=qt();return Ye(e,t)??{}}import{useAutoAnimate as go}from"@formkit/auto-animate/react";import ut from"react";import{useEffect as Yr,useState as Jr}from"react";import*as I from"@radix-ui/react-select";import{CheckIcon as Kr,ChevronDownIcon as ea,ChevronUpIcon as Qr}from"lucide-react";import{jsx as H,jsxs as Ne}from"react/jsx-runtime";function aa({...t}){return H(I.Root,{"data-slot":"select",...t})}function ra({...t}){return H(I.Value,{"data-slot":"select-value",...t})}var $r="border-input dark:bg-input/30 dark:hover:bg-input/50 bg-transparent";function oa({className:t,size:e="default",theme:a="default",children:o,...c}){return Ne(I.Trigger,{"data-slot":"select-trigger","data-size":e,className:r("data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex w-fit items-center justify-between gap-2 rounded-md border px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",a==="bare"?"":$r,t),...c,children:[o,H(I.Icon,{asChild:!0,children:H(ea,{className:"size-4 opacity-50"})})]})}function ia({className:t,children:e,position:a="popper",align:o="center",...c}){return H(I.Portal,{children:Ne(I.Content,{"data-slot":"select-content",className:r("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,align:o,...c,children:[H(Zr,{}),H(I.Viewport,{className:r("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:e}),H(Xr,{})]})})}function na({className:t,children:e,...a}){return Ne(I.Item,{"data-slot":"select-item",className:r("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...a,children:[H("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:H(I.ItemIndicator,{children:H(Kr,{className:"size-4"})})}),H(I.ItemText,{children:e})]})}function Zr({className:t,...e}){return H(I.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:r("flex cursor-default items-center justify-center py-1",t),...e,children:H(Qr,{className:"size-4"})})}function Xr({className:t,...e}){return H(I.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:r("flex cursor-default items-center justify-center py-1",t),...e,children:H(ea,{className:"size-4"})})}import{jsx as pt,jsxs as re}from"react/jsx-runtime";function to({id:t,open:e,disabled:a=!1,onToggle:o,onChange:c,selectedValue:d,countries:i}){let[w,h]=Jr(""),{isCustomized:u,boundaryClassName:v,boundaryStyle:k,dropdownStyle:S}=qt(),x=T("countryTrigger"),b=T("countryDropdown"),g=T("countrySearch"),C=T("countryOption");Yr(()=>{d==null&&i.length>0&&c(i[0].code)},[]);let y=i.filter(s=>s.name.toLowerCase().startsWith(w.toLowerCase())),p=i.find(s=>s.code===d);return re(aa,{value:d,onValueChange:s=>{c(s),h("")},open:e,onOpenChange:s=>{s!==e&&o(),s||h("")},disabled:a,children:[pt(oa,{"data-bitsnap-checkout-slot":"countryTrigger",theme:"bare",className:r(a?"bg-neutral-100 dark:bg-neutral-800 dark:border-neutral-700":"","w-full rounded-md",x.className),style:x.style,children:pt(ra,{children:p&&re("span",{className:"truncate flex items-center",children:[pt("img",{alt:d,src:`https://purecatamphetamine.github.io/country-flag-icons/3x2/${d}.svg`,className:"inline mr-2 h-4 rounded-sm"}),p.name]})})}),re(ia,{"data-bitsnap-checkout":u?"dropdown":void 0,"data-bitsnap-checkout-slot":u?"countryDropdown":void 0,className:r(u?"bitsnap-react":"",v,"w-full max-h-80 max-w-[350px] z-[999999]",b.className),style:{...u?{...k,...S}:void 0,...b.style},position:"popper",children:[pt("div",{"data-bitsnap-checkout-slot":"countrySearch",className:r("sticky top-0 z-10 p-1 border-b",g.className),style:g.style,children:pt("input",{type:"search",name:"search",autoComplete:"off",className:"block w-full outline-none sm:text-body-regular bg-transparent rounded-md px-2 py-1.5",placeholder:"Znajd\u017A kraj",value:w,onChange:s=>h(s.target.value),onClick:s=>s.stopPropagation(),onKeyDown:s=>s.stopPropagation()})}),pt("div",{className:"max-h-64 overflow-y-auto",children:y.length===0?pt("div",{className:"cursor-default select-none relative py-2 pl-3 pr-9 text-sm",children:"No countries found"}):y.map(s=>re(na,{"data-bitsnap-checkout-slot":"countryOption",value:s.code,className:r("cursor-default select-none relative py-2 pl-3 pr-9 flex items-center transition",C.className),style:C.style,children:[pt("img",{alt:s.code,src:`https://purecatamphetamine.github.io/country-flag-icons/3x2/${s.code}.svg`,className:"inline mr-2 h-4 rounded-sm"}),pt("span",{className:"font-normal truncate",children:s.name})]},`${t}-${s.code}`))})]})]})}var sa=to;import{useEffect as no,useState as pa}from"react";import{MinusIcon as so,PlusIcon as co}from"lucide-react";import{Slot as pn}from"@radix-ui/react-slot";import{cva as eo}from"class-variance-authority";import{jsx as ro}from"react/jsx-runtime";var ao=eo("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});function ca({className:t,orientation:e,...a}){return ro("div",{role:"group","data-slot":"button-group","data-orientation":e,className:r(ao({orientation:e}),t),...a})}import{Fragment as oo,jsx as oe,jsxs as io}from"react/jsx-runtime";function la({price:t,currency:e,pricing:a,quantity:o=1}){let c=a?.regularPrice??t,d=a?.effectivePrice??t,i=a?.discount?.status==="ACTIVE"&&d<c;return oe("span",{children:i?io(oo,{children:[oe("span",{className:"mr-2 text-neutral-500 line-through",children:kt(c*o,e)}),oe("span",{className:"font-semibold text-red-700",children:kt(d*o,e)}),oe("span",{className:"mt-1 block text-xs text-neutral-600",children:a?.referencePrice.historyAvailable&&a.referencePrice.amount!=null?`Najni\u017Csza cena z 30 dni: ${kt(a.referencePrice.amount,e)}`:"Brak danych o cenie z ostatnich 30 dni"})]}):kt(d*o,e)})}import{jsx as Y,jsxs as ie}from"react/jsx-runtime";var lo=({isNotAvailable:t,quantity:e,details:a,shouldUpdate:o})=>{let c=T("product"),d=T("productImage"),i=T("productName"),w=T("productPrice"),h=T("removeButton");return ie("div",{"data-bitsnap-checkout-slot":"product","data-bitsnap-checkout-unavailable":t?"":void 0,className:r("flex items-center gap-3 mx-3",t?"outline outline-1 rounded-md m-1":"",c.className),style:c.style,children:[Y("img",{"data-bitsnap-checkout-slot":"productImage",className:r("aspect-auto max-w-[30%] max-w-32 max-h-32 py-2 overflow-hidden",d.className),style:d.style,src:a.image_url??"",alt:a.name}),ie("div",{className:"flex flex-col w-full",children:[Y("p",{"data-bitsnap-checkout-slot":"productName",className:r("font-medium",i.className),style:i.style,children:a.name}),Y("p",{"data-bitsnap-checkout-slot":"productPrice",className:r("text-sm",w.className),style:w.style,suppressHydrationWarning:!0,children:Y(la,{price:a.price,currency:a.currency,pricing:a.pricing,quantity:e})}),ie("div",{className:"flex justify-between",children:[Y(po,{className:"",quantity:e,shouldUpdate:o}),Y(D,{"data-bitsnap-checkout-slot":"removeButton",variant:"ghost",size:"sm",className:h.className,style:h.style,onClick:()=>o(0),children:"Usu\u0144"})]})]})]})},da=lo,po=({quantity:t,shouldUpdate:e,className:a})=>{let[o,c]=pa(t.toString()),[d,i]=pa(t),w=T("quantityControl"),h=T("quantityInput"),u=T("quantityButton");no(()=>{e(d)},[d]);function v(x){if(c(x),x.length==0)return;let b=parseInt(x);if(isNaN(b)){i(1),c("");return}if(b==0||b<0){i(1),c("1");return}i(b),c(b.toString())}function k(){i(t+1),c((t+1).toString())}function S(){if(t>1){c((t-1).toString()),i(t-1);return}c(t.toString()),i(t)}return Y("div",{"data-bitsnap-checkout-slot":"quantityControl",className:r("flex",a,w.className),style:w.style,children:ie(ca,{"aria-label":"Ilo\u015B\u0107",children:[Y(D,{"data-bitsnap-checkout-slot":"quantityButton",className:u.className,style:u.style,onClick:S,children:Y(so,{})}),Y("input",{"data-bitsnap-checkout-slot":"quantityInput",className:r("w-8 bg-transparent text-center",h.className),style:h.style,value:o,onInput:x=>{v(x.currentTarget.value)},type:"text"}),Y(D,{"data-bitsnap-checkout-slot":"quantityButton",className:u.className,style:u.style,onClick:k,children:Y(co,{})})]})})};import{jsx as uo}from"react/jsx-runtime";function Te({className:t,...e}){return uo("div",{"data-slot":"skeleton",className:"bg-neutral-700 animate-pulse rounded-md "+t,...e})}import{useMutation as Ft,useQuery as ne}from"@tanstack/react-query";import{createContext as bo,useContext as ua,useMemo as ba}from"react";import{jsx as mo}from"react/jsx-runtime";var ze=bo({});function ma({texts:t,locale:e,children:a}){let o=ba(()=>({texts:t,locale:e}),[t,e]);return mo(ze.Provider,{value:o,children:a})}function dt(t){let{texts:e,locale:a}=ua(ze);return we(t,a??Rt(),e)}function ga(){let{texts:t,locale:e}=ua(ze),a=e??Rt();return ba(()=>o=>we(o,a,t),[a,t])}import{Fragment as fo,jsx as L,jsxs as vt}from"react/jsx-runtime";var ho=({className:t,locale:e})=>{let a=Dt(),o=Nt(),c=e??Rt(),d=T("productList"),i=T("summary"),w=T("totalLabel"),h=T("totalValue"),u=T("deliveryText"),v=T("countryLabel"),k=T("paymentButtons"),S=T("checkoutButton"),x=T("emptyState"),b=T("error"),g=T("skeleton"),C=dt("unavailableProducts"),y=ga(),p=dt("emptyCart"),s=dt("total"),P=dt("delivery"),f=dt("chooseCountry"),B=dt("nextStep"),{mutateAsync:n}=Ft({mutationFn:a.removeProductFromCart}),{mutateAsync:l}=Ft({mutationFn:a.updateQuantity}),{mutateAsync:N}=Ft({mutationFn:a.setCountry}),{mutateAsync:z}=Ft({mutationFn:a.clearCart}),[Q,j]=ut.useState(""),[O,q]=ut.useState([]),[Zt,ue]=ut.useState(!1),{mutateAsync:be,isPending:Xt}=Ft({mutationFn:a.redirectToNextStep}),{data:Ot}=ne({queryKey:["cart-available-countries"],queryFn:a.getAvailableCountries}),{data:Yt}=ne({queryKey:["cart-one-click-payment"],queryFn:a.checkIfApplePayIsAvailable}),{data:M,isLoading:G,refetch:X}=ne({queryKey:["cart",c],queryFn:a.getProducts}),{data:Jt,refetch:Oa}=ne({queryKey:["cart-country"],queryFn:a.getCountry}),[Ga]=go(),U=F(M)?void 0:M,me=F(Ot)?[]:Ot,Gt=U?.reduce((m,R)=>R.details==null?m:m+(R.details.pricing?.effectivePrice??R.details.price)*R.quantity,0)??0,jt=U?.[0]?.details?.currency??"PLN",ja=U?.some(m=>m.details?.isDeliverable===!0)??!1,Be=Jt!=null&&!F(Jt)&&Jt!=""?Jt:void 0,Oe=ut.useRef(!1);ut.useEffect(()=>{Oe.current||G||(Oe.current=!0,o.track("cart_opened",{item_count:U?.reduce((m,R)=>m+R.quantity,0)??0,value_minor:Gt,currency:jt}))},[G,o,U,Gt,jt]);let ge=ut.useRef(new Map);ut.useEffect(()=>{ge.current.clear()},[U]);function Ma(m,R){let tt=U?.find(Va=>Va.id===m);if(tt?.details==null)return;let te=R-(ge.current.get(m)??tt.quantity);if(ge.current.set(m,R),te===0)return;let Ha=tt.details.pricing?.effectivePrice??tt.details.price,je=tt.catalogProductID??tt.productID;o.track(te>0?"add_to_cart":"remove_from_cart",{qty:Math.abs(te),value_minor:Math.round(Ha*Math.abs(te)),currency:tt.details.currency},{product_id:je,variant_id:je!==tt.productID?tt.productID:null})}let Ge=ut.useRef(!1);async function qa(m,R){if(R!=null){if(Ma(m,Math.max(0,R)),R<=0){await n({id:m}),await X();return}await l({id:m,quantity:R}),await X();return}}async function Fa(){try{if(j(""),q([]),U!=null){!Ge.current&&U.length>0&&(Ge.current=!0,o.track("checkout_started",{item_count:U.reduce((R,tt)=>R+tt.quantity,0),checkout_type:"cart",value_minor:Gt,currency:jt}));try{ct({event:"initiateCheckout",items:U?.map(R=>({id:R.productID,name:R.details?.name??"",price:R.details?.price??0,quantity:R.quantity,currency:R.details?.currency??"PLN"}))})}catch{}}let m=await be();if(F(m)){m.error=="item-ids-not-found"?(j(C),"data"in m&&Array.isArray(m.data)&&q(m.data)):j($e(m,y));return}await z(),window.location.href=m.url}catch(m){console.warn("checkout failed",m),j(y("checkoutFailed"))}}return vt("div",{className:`${t} flex flex-col`,ref:Ga,children:[G&&vt("div",{className:"relative flex w-full justify-center flex-col gap-4",children:[L(Te,{"data-bitsnap-checkout-slot":"skeleton",className:r("w-full h-32",g.className),style:g.style}),L(Te,{"data-bitsnap-checkout-slot":"skeleton",className:r("w-full h-32",g.className),style:g.style})]}),!G&&(U==null||U.length==0)&&L("div",{className:"flex flex-col gap-4 p-4",children:L("p",{"data-bitsnap-checkout-slot":"emptyState",className:r(x.className),style:x.style,children:p})}),L("div",{"data-bitsnap-checkout-slot":"productList",className:r("max-h-[70vh] overflow-clip overflow-y-scroll",d.className),style:d.style,children:U!=null&&U.length>0&&L("ul",{className:"mt-5",children:U.map(m=>L(ut.Fragment,{children:m.details!=null&&vt("li",{className:"mb-3",children:[L(da,{isNotAvailable:O.includes(m.productID),quantity:m.quantity,details:m.details,shouldUpdate:R=>{qa(m.id,R).then().catch()}}),L("hr",{className:"h-1"})]})},m.id))})}),L("div",{className:"grow"}),Gt>0&&jt!=null&&vt(fo,{children:[L("div",{"data-bitsnap-checkout-slot":"summary",className:r("mx-3 flex flex-col",i.className),style:i.style,children:vt("div",{className:"flex flex-row justify-between text-lg",children:[L("p",{"data-bitsnap-checkout-slot":"totalLabel",className:r("text-xl",w.className),style:w.style,children:s}),vt("div",{className:"flex flex-col items-end",children:[L("p",{"data-bitsnap-checkout-slot":"totalValue",className:r("font-medium",h.className),style:h.style,children:kt(Gt,jt)}),ja&&L("p",{"data-bitsnap-checkout-slot":"deliveryText",className:r("opacity-70 text-right text-base",u.className),style:u.style,children:P})]})]})}),me&&me?.length>1&&vt("div",{children:[L("h4",{"data-bitsnap-checkout-slot":"countryLabel",className:r("ml-3 text-sm",v.className),style:v.style,children:f}),L(sa,{id:Math.random().toString(),open:Zt,onToggle:()=>{ue(!Zt)},onChange:m=>{N(m).then(()=>{Oa().then().catch()})},selectedValue:Be??"",countries:me})]}),vt("div",{className:"mb-3 flex flex-col",children:[Yt&&U!=null&&U.length>0&&L("div",{"data-bitsnap-checkout-slot":"paymentButtons",className:r("w-full px-2",k.className),style:k.style,children:L(Se,{colorType:"white",style:{width:"100%"},items:U?.map(m=>({name:m.details?.name??"",id:m.productID,price:m.details?.pricing?.effectivePrice??m.details?.price??0,quantity:m.quantity,isDeliverable:m.details?.isDeliverable??!1,metadata:m.metadata}))})}),U!=null&&U.length>0&&L("div",{"data-bitsnap-checkout-slot":"paymentButtons",className:r("w-full px-2",k.className),style:k.style,children:L(Ee,{buttonSizeMode:"fill",buttonColor:"white",style:{width:"100%"},items:U?.map(m=>({name:m.details?.name??"",id:m.productID,price:m.details?.pricing?.effectivePrice??m.details?.price??0,quantity:m.quantity,isDeliverable:m.details?.isDeliverable??!1,metadata:m.metadata}))})}),L("button",{"data-bitsnap-checkout-slot":"checkoutButton",onClick:Fa,disabled:G||Xt||Be==null,className:r("px-3 py-2 my-2 mx-2 rounded-md disabled:opacity-40 disabled:cursor-not-allowed transition font-bold",S.className),style:S.style,children:Xt?L(W,{}):B}),Q.length>0&&L("p",{"data-bitsnap-checkout-slot":"error",className:r("text-sm text-center",b.className),style:b.style,children:Q})]})]})]})},ha=ho;import{Fragment as ko,jsx as at,jsxs as se}from"react/jsx-runtime";function yo({isVisible:t,shouldHide:e,locale:a}){let[o]=vo(),{boundaryClassName:c,boundaryStyle:d}=qt(),i=T("root"),w=T("overlay"),h=T("panel"),u=T("header"),v=T("title"),k=T("closeButton"),S=dt("cart");return at("div",{ref:o,"data-bitsnap-checkout":"root","data-bitsnap-checkout-slot":"root",className:r("bitsnap-react",c,i.className),style:{zIndex:999999,...d,...i.style},children:t&&se(ko,{children:[at("div",{"data-bitsnap-checkout-slot":"overlay",className:r("fixed top-0 right-0 left-0 bottom-0 cursor-pointer z-10",w.className),style:w.style,onClick:e}),se("div",{"data-bitsnap-checkout-slot":"panel",className:r("fixed z-20 top-0 right-0 bottom-0 w-full md:w-[350px] xl:w-[420px] flex flex-col",h.className),style:h.style,children:[se("div",{"data-bitsnap-checkout-slot":"header",className:r("mx-3 mt-7 flex justify-between items-center",u.className),style:u.style,children:[at("h1",{"data-bitsnap-checkout-slot":"title",className:r("text-2xl font-medium",v.className),style:v.style,children:S}),at("button",{"data-bitsnap-checkout-slot":"closeButton",className:r("rounded-xl p-2 transition",k.className),style:k.style,onClick:e,children:se("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-x",children:[at("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),at("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),at(ha,{className:"grow",locale:a})]})]})})}var xo=t=>typeof window>"u"?null:wo(at(ta,{appearance:t.appearance,children:at(ma,{texts:t.texts,locale:t.locale,children:at(_t,{locale:t.locale,children:at(yo,{...t})})})}),document.body),fa=xo;import{Fragment as va,jsx as Ct,jsxs as Ie}from"react/jsx-runtime";var Co=$.object({id:$.string(),isSubscription:$.boolean().default(!1),quantity:$.number(),metadata:$.record($.string(),$.string().optional()).optional()});function So({projectID:t,locale:e,children:a,onVisibleChange:o,className:c,numberOfProductsInCartOptions:d,appearance:i,texts:w,analytics:h}){let u=ht(t,h,"cart");qe(u);let{isCartVisible:v,showCart:k,hideCart:S,numberOfProductsInCart:x}=Ze();function b(p){document.querySelectorAll("iframe").forEach(P=>{P.contentWindow?.postMessage(p,"*")})}Ht(()=>{o?.(v),v&&ct({event:"viewCart"})},[v]),Ht(()=>{ke(t)},[t]),Ht(()=>{ye(e)},[e]),Ht(()=>{if(!("cart"in window)){let p=lt();if(p==null){console.warn("There is no project ID configured.");return}window.cart={buyProduct:async s=>{try{let P=$.object({productID:$.string(),email:$.string().optional(),name:$.string().optional(),country:$.string().optional(),marketingAgreement:$.boolean().optional(),locale:$.string().optional()}).parse(s),f=Ce(p);try{let n=await f.getProducts();F(n)==!1&&ct({event:"initiateCheckout",items:n.map(l=>({id:l.productID,name:l.details?.name??"",price:l.details?.price??0,quantity:l.quantity,currency:l.details?.currency??"PLN"}))})}catch{}let B=await f.justRedirectToPayment(P);console.log("result",B),F(B)==!1?window.location.href=B.url:alert("Nie uda\u0142o si\u0119 przekierowa\u0107 do p\u0142atno\u015Bci. Spr\xF3buj ponownie p\xF3\u017Aniej.")}catch(P){console.warn(P)}}}}},[]);async function g(p,s){let P=lt();if(P==null){console.warn("There is no project ID configured.");return}try{let f=Co.parse(s);if(f.isSubscription){await C(P,f);return}await Ce(P).addProduct({productID:f.id,quantity:f.quantity,metadata:f.metadata}),b({id:p,type:"ADD_TO_CART",success:!0}),k()}catch(f){console.warn("cannot add item to cart",f)}}async function C(p,s){alert(`TODO, nie jest to jeszcze zrobione ${p} ${s.id} ${s.quantity}`)}function y(){"__cart_is_listening"in window||(window.__cart_is_listening=!0,window.addEventListener("message",p=>{if(typeof p.data.id<"u"&&typeof p.data.type<"u"){let{id:s,type:P}=p.data;switch(P){case"ADD_TO_CART".toString():g(s,p.data.payload).then().catch();break;default:break}}}))}return Ht(()=>{if(y(),typeof window<"u")try{let p=new URLSearchParams(window.location.search),s=p.get("ref")??p.get("utm-source");typeof localStorage<"u"&&s&&s.length>0&&localStorage.setItem("bitsnap-ref",s)}catch{return}},[]),Ie(va,{children:[Ie("button",{onClick:()=>v?S():k(),style:{position:"relative"},className:["bitsnap-react",c??"rounded-full hover:bg-neutral-300 transition p-1"].join(" "),children:[a?Ct(va,{children:a}):Ie("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-shopping-cart",children:[Ct("circle",{cx:"8",cy:"21",r:"1"}),Ct("circle",{cx:"19",cy:"21",r:"1"}),Ct("path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"})]}),d?.isVisible!=!1&&x>0&&Ct("div",{style:{position:"absolute",bottom:-5,right:-5,background:"black",color:"white",borderRadius:"50%",width:"22px",height:"22px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",fontWeight:600,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.25)",...d?.style},children:x})]}),Ct(Pt,{value:u,children:Ct(fa,{isVisible:v,locale:e,appearance:i,texts:w,shouldHide:()=>{S()}})})]})}var Po=So;import No from"@google-pay/button-react";import{useQuery as To,useMutation as zo}from"@tanstack/react-query";import{Fragment as Ao,jsx as Vt,jsxs as Ro}from"react/jsx-runtime";function Eo({items:t,style:e,buttonColor:a,buttonSizeMode:o,test:c}){let{getGooglePayConfiguration:d,completeGooglePayPayment:i,setCountry:w,setCouponCodeIfPossible:h,setDeliveryMethod:u,setEmail:v,setPostalCode:k,clearCart:S}=Dt(),x=Nt(),{data:b}=To({queryKey:["get-google-pay-configuration",t.map(y=>y.id).join(",")],queryFn:()=>d({items:t.map(y=>({...y,id:void 0,productID:y.id}))})}),{mutateAsync:g,isPending:C}=zo({mutationFn:i});return b==null||b.isAvailable!=!0?(console.log("google pay configuration is not available",b),null):Ro(Ao,{children:[Vt(No,{buttonSizeMode:o,buttonColor:a,style:e,existingPaymentMethodRequired:!0,onClick:()=>x.track("payment_method_selected",{gateway:"google_pay",method:"google_pay"}),environment:c===!0?"TEST":"PRODUCTION",onPaymentDataChanged:async y=>{ct({event:"initiateCheckout",items:t.map(s=>({id:s.id,name:s.name,price:s.price,quantity:s.quantity,currency:"PLN"}))}),console.log("payment data changed",y),y.shippingAddress?.postalCode!=null&&await k(y.shippingAddress?.postalCode),y.shippingAddress?.countryCode!=null&&await w(y.shippingAddress?.countryCode),y.shippingOptionData?.id!=null&&await u(y.shippingOptionData.id);let p=await d({items:[]});return console.log("PAYMENT DATA CHANGED CONFIG",p),p.isAvailable?{error:void 0,newShippingOptionParameters:p.config.shippingOptionParameters,newTransactionInfo:p.config.transactionInfo}:{error:void 0}},paymentRequest:b.config,onLoadPaymentData:async y=>{x.track("payment_submitted",{gateway:"google_pay",method:"google_pay"});try{let p=await g({paymentData:y});if(F(p)){console.log("apple pay error",p);return}p.isSuccess&&S(),p.redirectURL&&open(p.redirectURL,"_self")}catch(p){console.warn("error completing google pay payment",p)}}}),C?Vt(W,{}):null]})}function Io(t){let e=ht(Lt(),t.analytics,"cart");return Vt(Pt,{value:e,children:Vt(_t,{children:Vt(Eo,{...t})})})}var Ee=Io;import{useReducer as ni,useRef as si,useEffect as $t}from"react";import{useQuery as ci}from"@tanstack/react-query";import{Settings as li}from"lucide-react";import{Fragment as Do,jsx as Ae,jsxs as _o}from"react/jsx-runtime";var E={title:null,description:null,managingDescription:"Zarz\u0105dzaj rodzajami powiadomie\u0144 i sposobem dostarczania.",formTitle:"Podaj Email aby zapisa\u0107 si\u0119\xA0do powiadomie\u0144",formEmailLabel:"Email",formPhoneLabel:"Numer telefonu",formPhoneOptional:"(opcjonalnie)",formEmailPlaceholder:"np. mail@gmail...",formPhonePlaceholder:"np. 663...",formSubmitButton:"Zapisz si\u0119",formSuccessMessage:"Zapisa\u0142e\u015B si\u0119 do powiadomie\u0144.",agreementText:_o(Do,{children:[Ae("span",{style:{color:"red"},children:"*"}),"Wyra\u017Cam zgod\u0119 na przetwarzanie moich danych w celach marketingowych zgodnie z"," ",Ae("a",{href:"/regulations/polityka-prywatnosci",target:"_blank",className:"cursor-alias font-bold hover:font-medium",children:"regulaminem"})," ",Ae("span",{className:"text-xs font-light",children:"(zgod\u0119 mo\u017Cna w ka\u017Cdej chwili wycofa\u0107)"})]}),qrCodeTitle:"lub zainstaluj aplikacj\u0119 mobiln\u0105",qrCodeSubtitle:"Aplikacja mobilna",qrCodeScanText:"zeskanuj kod QR",groupsNoSelectionWarning:"Je\u015Bli \u017Cadna z grup nie jest zaznaczona, nie otrzymasz \u017Cadnych powiadomie\u0144.",groupsSelectAllButton:"Zaznacz wszystkie",groupsUpdateButton:"Aktualizuj",groupsUpdateSuccess:"Zaktualizowano pomy\u015Blnie.",groupsTitle:"Zarz\u0105dzaj grupami z kt\xF3rych chcesz otrzymywa\u0107 powiadomienia",manageDataTitle:"Ustawienia powiadomie\u0144",manageDataDescription:"W jaki spos\xF3b chcesz otrzymywa\u0107 powiadomienia?",manageDataUnsubscribeButton:"Odsubskrybuj",manageDataUpdatedMessage:"Zaktualizowano",manageDataUnsubscribeDescription:"Wypisz mnie z wszystkich powiadomie\u0144 i grup.",loginEmailLabel:"Email",loginEmailPlaceholder:"Wprowad\u017A sw\xF3j email",loginSendCodeButton:"Wy\u015Blij kod weryfikacyjny",loginSendingButton:"Wysy\u0142anie...",loginCodeLabel:"Wprowad\u017A kod weryfikacyjny",loginCodeSentMessage:"Wys\u0142ali\u015Bmy kod weryfikacyjny na adres",loginChangeEmailButton:"Popraw email",loginResendCodeButton:"Wy\u015Blij kod ponownie",loginInvalidEmailError:"Wprowad\u017A prawid\u0142owy adres email",loginSlugRequiredError:"Wymagany jest identyfikator projektu",loginInvalidCodeError:"Nieprawid\u0142owy kod weryfikacyjny",loginVerificationFailedError:"Weryfikacja nie powiod\u0142a si\u0119. Sprawd\u017A sw\xF3j kod.",loginSendEmailError:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 kodu weryfikacyjnego",loginVerifyCodeError:"Nie uda\u0142o si\u0119 zweryfikowa\u0107 kodu",loginResendEmailError:"Nie uda\u0142o si\u0119 ponownie wys\u0142a\u0107 kodu weryfikacyjnego",loginTitle:"Wpisz email aby zarz\u0105dza\u0107 powiadomieniami",loginDescription:"Dostaniesz kod weryfikacyjny na email.",loginIHaveCode:"Mam ju\u017C kod"};import{LogOutIcon as Lo}from"lucide-react";import{Fragment as wa,jsx as St,jsxs as ce}from"react/jsx-runtime";function ya({projectName:t,projectLogo:e,projectLogoDark:a,description:o,className:c,onLogout:d}){return ce(wa,{children:[e!=null||t!=null&&ce("h2",{className:r("flex max-w-44 items-center gap-3 text-lg font-medium text-black sm:max-w-none md:text-xl lg:text-2xl xl:text-3xl dark:text-neutral-100",c?.headerTitle),children:[e!=null&&ce(wa,{children:[St("img",{src:e,alt:"",className:r("h-12 w-auto dark:hidden",c?.headerLogo)}),St("img",{src:a??e,alt:"",className:r("hidden h-12 w-auto dark:inline",c?.headerLogo)})]}),St("span",{children:t})]}),ce("div",{className:"flex items-center gap-2",children:[o&&St("p",{className:r("mt-4 font-medium text-left",c?.headerDescription),children:o}),St("div",{className:"grow"}),d&&St(D,{variant:"ghost",size:"icon-sm",onClick:d,children:St(Lo,{className:"h-5 w-5"})})]})]})}import{useAutoAnimate as Pa}from"@formkit/auto-animate/react";import{CheckCircleIcon as Bo,TriangleAlertIcon as Oo}from"lucide-react";import*as bt from"@radix-ui/react-popover";import{jsx as le}from"react/jsx-runtime";function xa({...t}){return le(bt.Root,{"data-slot":"popover",...t})}function ka({...t}){return le(bt.Trigger,{"data-slot":"popover-trigger",...t})}function Ca({className:t,align:e="center",sideOffset:a=4,...o}){return le(bt.Portal,{children:le(bt.Content,{"data-slot":"popover-content",align:e,sideOffset:a,className:r("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...o})})}import{ClockIcon as Uo}from"lucide-react";import{jsx as mt,jsxs as wt}from"react/jsx-runtime";function Sa({regularity:t}){let e="";switch(t){case"rarely":e="rzadko";break;case"often":e="cz\u0119sto";break;case"very_often":e="codzienne";break}return wt(xa,{children:[mt(ka,{onClick:a=>{a.stopPropagation()},children:wt("button",{type:"button",className:"flex w-[30%] cursor-help flex-col items-center justify-center text-xs md:w-[25%] xl:w-[20%]",children:[mt(Uo,{size:12}),mt("span",{children:e})]})}),mt(Ca,{className:"w-80",children:wt("div",{className:"grid gap-4",children:[wt("div",{className:"space-y-2",children:[mt("h4",{className:"leading-none font-medium",children:"Co to oznacza?"}),wt("ul",{className:"list-inside list-disc text-sm",children:[wt("li",{children:[mt("span",{className:"font-semibold",children:"Rzadko"})," \u2013 powiadomienia b\u0119d\u0105 wysy\u0142ane maksymalnie kilka razy w miesi\u0105cu."]}),wt("li",{children:[mt("span",{className:"font-semibold",children:"Cz\u0119sto"})," \u2013 powiadomienia mog\u0119 by\u0107 wysy\u0142ane kilka razy w tygodniu."]}),wt("li",{children:[mt("span",{className:"font-semibold",children:"Codzienne"})," \u2013 powiadomienia b\u0119d\u0105 wysy\u0142ane nawet codziennie."]})]})]}),mt("div",{className:"grid gap-2"})]})})]})}import{Fragment as Go,jsx as K,jsxs as it}from"react/jsx-runtime";function pe({groups:t=[],isManaging:e,onToggle:a,onCheckAll:o,onUpdate:c,isUpdating:d,wasChanged:i,isUserGroupsUpdated:w,className:h,texts:u}){let[v]=Pa(),[k]=Pa(),S=t.filter(g=>g.isOn===!1).length>0,x=t.filter(g=>g.isOn===!1).length>0;if(t.length<=1&&e!=!0)return null;let b=it("div",{ref:v,className:r("my-5 flex flex-col gap-3",h?.groupsList),children:[t.map(g=>it("div",{id:g.id,role:"button",className:r(g.isOn?"bg-neutral-50 hover:bg-transparent shadow-sm border-transparent dark:bg-neutral-800":"border-neutral-200 hover:bg-neutral-50 dark:hover:border-neutral-800 shadow-sm dark:border-neutral-800","active:bg-beige-300 flex w-full cursor-pointer items-center gap-3 rounded-xl border px-3 py-2 transition active:dark:bg-neutral-900",h?.groupItem),onClick:C=>{C.target instanceof HTMLButtonElement||a(g.id)},children:[K(At,{checked:g.isOn,className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-700",onCheckedChange:()=>{a(g.id)}}),it("div",{className:"flex flex-col items-start justify-start",children:[K("p",{className:"font-medium text-sm",children:g.name}),g.description&&K("p",{className:"text-xs font-light",children:g.description})]}),K("div",{className:"grow"}),g.howOften&&K(Sa,{regularity:g.howOften})]},g.id)),it("div",{className:"flex gap-2",children:[e===!0&&it(Go,{children:[it("div",{ref:k,className:"flex flex-col items-start justify-start",children:[i&&it(D,{variant:"default",size:"sm",className:"relative",disabled:d,onClick:c,children:[u?.groupsUpdateButton??E.groupsUpdateButton,d&&K("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:K(W,{})})]}),w&&it("p",{className:"mt-3 flex items-center gap-2 text-sm text-green-500",children:[K(Bo,{color:"var(--color-green-500",size:16})," ",u?.groupsUpdateSuccess??E.groupsUpdateSuccess]})]}),K("div",{className:"grow"})]}),x&&K("div",{className:"flex justify-start",children:K(D,{className:"cursor-pointer dark:bg-neutral-700",onClick:o,size:"sm",variant:"secondary",type:"button",children:u?.groupsSelectAllButton??E.groupsSelectAllButton})})]}),S&&it("div",{className:"flex text-left gap-2 text-xs text-yellow-500",children:[K(Oo,{color:"orange",size:16}),u?.groupsNoSelectionWarning??E.groupsNoSelectionWarning]})]});return e==!0?it(zt,{className:"mt-5 text-left",children:[K(Et,{children:K(ft,{children:u?.groupsTitle??E.groupsTitle})}),K(It,{children:b})]}):b}import{jsx as yt,jsxs as Wt}from"react/jsx-runtime";function Na({showQRCode:t=!0,isManaging:e,className:a,texts:o}){let c=typeof window<"u",d=c?!!window.matchMedia?.("(prefers-color-scheme: dark)").matches:!1;function i(w){return w?window.location.href:""}return t?Wt(zt,{className:r("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",a?.qrCodeSection),children:[yt(Et,{children:Wt(ft,{className:r("mb-3 text-base font-medium lg:text-lg",a?.qrCodeTitle),children:[o?.qrCodeSubtitle??E.qrCodeSubtitle," "+(o?.qrCodeTitle??E.qrCodeTitle)]})}),Wt(It,{className:"flex flex-col items-center gap-2",children:[Wt("div",{className:"mt-1.5 mb-3 flex items-center gap-x-2",children:[yt("a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",target:"_blank",className:"max-w-28 flex-1 basis-1/2 lg:max-w-36",children:yt("img",{className:"h-auto w-full",src:Tt+"/app-store-logo.png",alt:"Download on App Store"})}),yt("a",{href:"https://play.google.com/store/apps/details?id=com.bitsnap.Bitsnap&pli=1",target:"_blank",className:"max-w-28 flex-1 basis-1/2 lg:max-w-36",children:yt("img",{className:"h-auto w-full",src:Tt+"/google-play-logo.png",alt:"Get in on Google Play"})})]}),c&&yt("div",{className:"flex items-center justify-center",children:Wt("div",{className:r("flex min-w-[40%] flex-col items-center gap-2 rounded-xl bg-white p-2 dark:bg-neutral-900",a?.qrCodeContainer),children:[yt("img",{className:"mt-3 w-[80%] p-1 pt-3",src:Tt+`/api/qr-gen?url=${i(c)}&bgColor=${d?"171717":"F6F4F0"}&textColor=${d?"ffffff":"000000"}&margin=0`}),yt("p",{className:"text-xs md:text-sm",children:o?.qrCodeScanText??E.qrCodeScanText})]})})]})]}):null}import{useState as Kt}from"react";import{isValidPhoneNumber as Ho}from"react-phone-number-input";import{useAutoAnimate as jo}from"@formkit/auto-animate/react";import{Label as Ta}from"@radix-ui/react-label";import{CheckCircleIcon as Mo,CircleAlertIcon as qo,TriangleAlertIcon as Fo}from"lucide-react";import{useState as Re}from"react";import{jsx as J,jsxs as gt}from"react/jsx-runtime";function za({submit:t,isLoading:e,errMsg:a,emailLack:o,warnMsg:c,isSubmited:d,agreementLack:i,showPhoneInput:w=!1,agreementText:h,className:u,texts:v}){let[k,S]=Re(""),[x,b]=Re(""),[g,C]=Re(!1),[y]=jo();function p(s){s.preventDefault(),t(k,x,g)}return gt("form",{ref:y,onSubmit:p,className:r("flex flex-col gap-3 text-left",u?.formContainer),children:[gt("div",{className:"flex flex-col gap-1 text-left",children:[J(Ta,{className:"text-sm",htmlFor:"bts-notifications-form-email",children:v?.formEmailLabel??E.formEmailLabel}),J(Mt,{value:k,onChange:s=>{S(s.currentTarget.value)},id:"bts-notifications-form-email",className:r(o===!0?"border-red-400":""),type:"email",placeholder:v?.formEmailPlaceholder??E.formEmailPlaceholder})]}),w&>("div",{className:"flex flex-col gap-1 text-left",children:[gt(Ta,{className:"text-sm",htmlFor:"bts-notifications-form-phone",children:[v?.formPhoneLabel??E.formPhoneLabel," ",J("span",{className:"text-neutral-500 dark:text-neutral-500",children:v?.formPhoneOptional??E.formPhoneOptional})]}),J(Mt,{value:x,onChange:s=>{b(s.currentTarget.value)},id:"bts-notifications-form-phone",className:"",type:"tel",autoComplete:"tel",autoCorrect:"off",placeholder:v?.formPhonePlaceholder??E.formPhonePlaceholder})]}),gt("div",{className:"flex items-start gap-x-1.5",children:[J("input",{className:"cursor-pointer",id:"bts-notifications-form-marketing-consent",type:"checkbox",checked:g,onChange:()=>{C(!g)}}),J("label",{htmlFor:"bts-notifications-form-marketing-consent",className:r("cursor-pointer text-xs leading-4 transition-colors md:text-sm md:leading-4",i===!0?"text-yellow-700":""),children:h})]}),a.length>0&>("p",{className:"mb-3 flex items-center gap-1 text-sm text-red-400",children:[J(Fo,{color:"#ff6467",size:16})," ",a]}),c.length>0&>("p",{className:"mb-3 flex items-center gap-1 text-sm text-amber-400",children:[J(qo,{color:"var(--color-amber-400)",size:16})," ",c]}),d==!1&&J("div",{className:"flex justify-start",children:gt(D,{variant:"default",disabled:e,className:r(e?"cursor-not-allowed text-transparent":"","relative"),children:[v?.formSubmitButton??E.formSubmitButton,e&&J("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:J(W,{})})]})}),d&>("div",{className:"flex items-center gap-3 text-sm text-green-400",children:[J(Mo,{size:16})," ",v?.formSuccessMessage??E.formSuccessMessage]})]})}import{jsx as De,jsxs as Wo}from"react/jsx-runtime";var Vo=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;function Ea({groups:t,onToggle:e,onCheckAll:a,slug:o,showPhoneInput:c=!1,agreementText:d,className:i,texts:w,isUpdating:h,wasChanged:u,onSuccess:v}){let[k,S]=Kt(""),[x,b]=Kt(""),[g,C]=Kt(!1),[y,p]=Kt(!1),[s,P]=Kt(!1),{mutateAsync:f,isPending:B}=st(et.notifications.createNotificationUser);function n(z){return z==null?!1:Ho(z,"PL")}async function l(z,Q,j){if(S(""),b(""),P(!1),C(!1),p(!1),!j){p(!0),S("Zgoda w tym przypadku jest wymagana.");return}if(Vo.test(z)===!1){S("Email jest nieprawid\u0142owy."),P(!0);return}Q.length>0&&n(Q)===!1&&b("Numer telefonu mo\u017Ce by\u0107 nieprawid\u0142owy. Zapisali\u015Bmy go ale je\u015Bli jest nieprawid\u0142owy to wpisz jeszcze raz i kliknij przycisk.");try{let O=await f({slug:o,email:z,phone:Q,groups:t.filter(q=>q.isOn==!0).map(q=>q.id),mobileNotificationEnabled:!0,emailNotificationEnabled:!0,smsNotificationEnabled:!0});if(O.result.case==="success"){C(!0),setTimeout(()=>{v?.(!1,O.userId,O.accessToken)},1e3);return}else{C(!0);let q=O.result.value;if(q!=null){if(q==32){v?.(!0,void 0,void 0);return}console.log(`Code error: ${he[q]}`),S("Wyst\u0105pi\u0142 b\u0142\u0105d: "+he[q]);return}return}}catch(O){S("Wyst\u0105pi\u0142 b\u0142\u0105d podczas zapisywania. Spr\xF3buj ponownie."),console.log(`Error: ${O}`)}}let N=w?.formTitle??E.formTitle;return Wo("div",{className:r("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",i?.formSection),children:[N.length>0&&De("h3",{className:r("mb-3 text-base font-medium lg:text-lg",i?.formTitle),children:N}),De(pe,{groups:t,isManaging:!1,onToggle:e??(()=>{}),onCheckAll:a??(()=>{}),isUpdating:h??!1,wasChanged:u??!1,isUserGroupsUpdated:!1,className:i,texts:w}),De(za,{errMsg:k,emailLack:s,warnMsg:x,submit:l,isLoading:B,isSubmited:g,agreementLack:y,showPhoneInput:c,agreementText:d??w?.agreementText??E.agreementText,className:i,texts:w})]})}import{useEffect as Xo,useState as Qt}from"react";import{Label as _e}from"@radix-ui/react-label";import{MessageCircleWarningIcon as Yo}from"lucide-react";import{useDebouncedCallback as Jo}from"use-debounce";import{TriangleAlertIcon as Ko,XIcon as Qo}from"lucide-react";import{createPortal as $o}from"react-dom";import{useEffect as Ia,useState as Zo}from"react";import{jsx as rt,jsxs as Ut}from"react/jsx-runtime";function Aa({open:t,onOpenChange:e,onConfirm:a,isDeleting:o=!1}){let[c,d]=Zo(!1);if(Ia(()=>(d(!0),()=>d(!1)),[]),Ia(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t]),!c||!t)return null;let i=h=>{h.target===h.currentTarget&&e(!1)},w=()=>{a()};return $o(rt("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/50 p-4",onClick:i,children:Ut("div",{className:r("relative w-full max-w-md rounded-2xl bg-white p-6 shadow-lg","dark:bg-neutral-800","animate-in fade-in-0 zoom-in-95 duration-200"),onClick:h=>h.stopPropagation(),children:[Ut("button",{onClick:()=>e(!1),className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-neutral-950 focus:ring-offset-2 disabled:pointer-events-none dark:ring-offset-neutral-950 dark:focus:ring-neutral-300",disabled:o,children:[rt(Qo,{className:"h-4 w-4"}),rt("span",{className:"sr-only",children:"Zamknij"})]}),Ut("div",{className:"flex flex-col gap-4",children:[Ut("div",{className:"flex items-start gap-3",children:[rt("div",{className:"flex-shrink-0",children:rt(Ko,{className:"h-6 w-6 text-amber-500","aria-hidden":"true"})}),rt("div",{className:"flex-1",children:rt("h2",{className:"text-lg font-semibold text-black dark:text-neutral-100",children:"Czy na pewno chcesz si\u0119 wypisa\u0107?"})})]}),rt("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Klikni\u0119cie tego przycisku spowoduje wypisanie z wszelkich powiadomie\u0144 i grup, kt\xF3re zapisa\u0142e\u015B."}),Ut("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[rt(D,{type:"button",variant:"ghost",onClick:()=>e(!1),disabled:o,className:"sm:min-w-[100px]",children:"Anuluj"}),Ut(D,{type:"button",variant:"destructive",onClick:w,disabled:o,className:r(o&&"cursor-not-allowed text-transparent","relative sm:min-w-[100px]"),children:["Usu\u0144",o&&rt("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:rt("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"})})]})]})]})]})}),document.body)}import{useAutoAnimate as Ra}from"@formkit/auto-animate/react";import{Fragment as ti,jsx as _,jsxs as ot}from"react/jsx-runtime";function Da({accessToken:t,slug:e,userID:a,className:o,texts:c}){let[d]=Ra(),[i]=Ra(),{mutateAsync:w,isPending:h}=st(et.notifications.deleteNotificationUser),{mutateAsync:u,isPending:v}=st(et.notifications.updateNotificationUser),{data:k,isFetching:S}=ee(et.notifications.getNotificationUserSettings,{userId:a,slug:e,accessToken:t}),[x,b]=Qt(!1),[g,C]=Qt(!1),[y,p]=Qt(!1),[s,P]=Qt(!1),[f,B]=Qt(!1),n=k?.result.case==="success"?k?.result?.value:void 0;function l(){B(!0)}async function N(){await w({accessToken:t,slug:e,userId:a}),B(!1)}async function z(){await u({accessToken:t,slug:e,notificationUserId:a,mobileNotificationEnabled:s,emailNotificationEnabled:x,smsNotificationEnabled:g}),p(!0),setTimeout(()=>{p(!1)},3e3)}let Q=Jo(O=>{z()},300);Xo(()=>{let O=k?.result.case==="success"?k?.result?.value:void 0;b(O?.emailNotificationEnabled??!1),C(O?.smsNotificationEnabled??!1),P(O?.mobileNotificationEnabled??!1)},[k]);function j(O,q){O==="email"&&b(q),O==="phone"&&C(q),O==="push"&&P(q),Q(!0)}return ot("div",{className:r("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",o?.manageDataSection),children:[_("div",{className:"flex justify-start",children:_("h3",{className:r("mb-3 text-base font-medium lg:text-lg",o?.manageDataTitle),children:c?.manageDataTitle??E.manageDataTitle})}),S?_(We,{className:"h-64 w-full"}):ot(zt,{ref:i,className:r(v&&"relative"),children:[_(Et,{children:_(ft,{children:_("p",{className:"text-sm text-left",children:c?.manageDataDescription??E.manageDataDescription})})}),ot(It,{ref:d,children:[_("div",{className:r(v&&"opacity-50 pointer-events-none","flex flex-col gap-2"),children:ot("div",{className:"flex flex-col items-start gap-5 gap-x-2",children:[n?.emailNotificationAvailable&&ot("div",{className:"flex items-center gap-3",children:[_(At,{id:"email-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:x,onCheckedChange:()=>{j("email",!x)}}),_(_e,{htmlFor:"email-enabled",className:"text-sm",children:"Email"})]}),n?.smsNotificationAvailable&&ot("div",{className:"flex items-center gap-3",children:[_(At,{id:"sms-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:g,onCheckedChange:()=>{j("phone",!g)}}),_(_e,{htmlFor:"sms-enabled",className:"text-sm",children:"SMS"})]}),n?.mobileNotificationAvailable&&ot(ti,{children:[ot("div",{className:"flex items-center gap-3",children:[_(At,{id:"push-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:s,onCheckedChange:()=>{j("push",!s)}}),_(_e,{htmlFor:"push-enabled",className:"text-sm",children:"Powiadomienia na telefon"})]}),n?.hasUserInstalledApp===!1&&ot("div",{className:"flex items-center gap-3",children:[_(Yo,{color:"var(--color-amber-500)",size:26}),_("p",{className:"text-xs text-amber-500",children:"Wygl\u0105da na to, \u017Ce nie masz zainstalowanej aplikacji mobilnej. Zainstaluj i wyra\u017A zgod\u0119 na otrzymywanie powiadomie\u0144 na telefon."})]})]})]})}),ot("div",{className:"mt-5 flex flex-col gap-2 text-left",children:[_("hr",{}),y&&_("p",{className:"text-xs text-green-500",children:c?.manageDataUpdatedMessage??E.manageDataUpdatedMessage}),_("div",{className:"flex items-center gap-x-2",children:ot(D,{size:"sm",variant:"link",className:r("pl-0 ml-0",h&&"cursor-not-allowed"),onClick:l,children:[c?.manageDataUnsubscribeButton??E.manageDataUnsubscribeButton,h&&_("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:_(W,{})})]})})]})]}),v&&_("div",{className:"bg-black/30 absolute inset-0 rounded-xl",children:_("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:_(W,{})})})]}),_(Aa,{open:f,onOpenChange:B,onConfirm:N,isDeleting:h})]})}import{useState as de}from"react";import{ArrowLeft as oi}from"lucide-react";import{useAutoAnimate as Ua}from"@formkit/auto-animate/react";import*as Z from"@radix-ui/react-dialog";import{XIcon as ei}from"lucide-react";import{jsx as Bt,jsxs as Le}from"react/jsx-runtime";function _a({...t}){return Bt(Z.Root,{"data-slot":"dialog",...t})}function ai({...t}){return Bt(Z.Portal,{"data-slot":"dialog-portal",...t})}function ri({className:t,...e}){return Bt(Z.Overlay,{"data-slot":"dialog-overlay",className:r("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...e})}function La({className:t,children:e,showCloseButton:a=!0,...o}){return Le(ai,{"data-slot":"dialog-portal",children:[Bt(ri,{}),Le(Z.Content,{"data-slot":"dialog-content",className:r("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...o,children:[e,a&&Le(Z.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[Bt(ei,{}),Bt("span",{className:"sr-only",children:"Close"})]})]})]})}import{Fragment as ii,jsx as A,jsxs as nt}from"react/jsx-runtime";function Ba({slug:t,onSuccess:e,onError:a,className:o,isOpen:c,onClose:d,texts:i}){let[w]=Ua(),[h]=Ua(),[u,v]=de(""),[k,S]=de(""),[x,b]=de(!1),[g,C]=de(null),{mutateAsync:y,isPending:p}=st(et.notifications.verifyUserEmail),s=async n=>{if(n.preventDefault(),C(null),!u||!u.includes("@")){C(i.loginInvalidEmailError??"");return}try{await y({email:u,slug:t}),b(!0)}catch(l){let N=l instanceof Error?l:new Error(i.loginSendEmailError);C(N.message),a?.(N)}},P=async n=>{if(S(n),C(null),n.length===6)try{let l=await y({email:void 0,code:n,slug:t});l.ok&&l.accessToken?e?.(l.userId,l.accessToken):(C(i.loginVerificationFailedError??""),a?.(new Error(i.loginVerificationFailedError)))}catch(l){let N=l instanceof Error?l:new Error(i.loginVerifyCodeError);if(N.message.includes("Invalid code")){C(i.loginInvalidCodeError??N.message),S("");return}C(N.message),a?.(N),S("")}},f=async()=>{if(S(""),C(null),!u||!t){C(i.loginSlugRequiredError??"");return}try{await y({email:u,slug:t})}catch(n){let l=n instanceof Error?n:new Error(i.loginResendEmailError);C(l.message),a?.(l)}},B=()=>{b(!1),S(""),C(null)};return A(_a,{open:c,onOpenChange:d,children:A(La,{className:"sm:max-w-[425px] min-h-[250px]",children:nt("div",{className:"flex flex-col min-h-[250px] h-full",children:[nt("div",{ref:h,className:"flex items-start gap-2 mb-2",children:[x&&A(D,{variant:"ghost",size:"icon-sm",onClick:()=>{b(!1)},children:A(oi,{className:"h-5 w-5"})}),A("div",{children:A(ft,{children:x?i.loginCodeLabel??"":i.loginTitle??""})})]}),A(Fe,{className:"mb-4",children:x?nt(ii,{children:[i.loginCodeSentMessage??""," ",u]}):i.loginDescription??""}),A("div",{className:"flex-1 flex flex-col",children:x?nt("form",{onSubmit:n=>n.preventDefault(),className:"flex flex-col flex-1",children:[nt("div",{className:"space-y-2",children:[A(ve,{children:i.loginCodeLabel??""}),A(He,{maxLength:6,value:k,onChange:P,disabled:p,children:nt(Ve,{children:[A(xt,{index:0}),A(xt,{index:1}),A(xt,{index:2}),A(xt,{index:3}),A(xt,{index:4}),A(xt,{index:5})]})}),p&&A(W,{})]}),g&&A("div",{className:"text-sm text-destructive mt-2 mb-1",role:"alert",children:g}),A("div",{className:"grow"}),nt("div",{className:"flex flex-col items-start gap-2 pt-2",children:[u.length>0&&A(D,{variant:"link",size:"sm",onClick:f,disabled:p,className:"flex-1 ml-0 pl-0",children:i.loginResendCodeButton??""}),A(D,{variant:"link",size:"sm",onClick:B,disabled:p,className:"flex-1 ml-0 pl-0",children:i.loginChangeEmailButton??""})]})]}):nt("form",{onSubmit:s,className:"flex flex-col flex-1",children:[nt("div",{className:"space-y-2",children:[A(ve,{htmlFor:"email",children:i.loginEmailLabel??""}),A(Mt,{id:"email",type:"email",placeholder:i.loginEmailPlaceholder??"",value:u,onChange:n=>v(n.target.value),required:!0,disabled:p,"aria-invalid":g?"true":"false"})]}),g&&A("div",{className:"text-sm text-destructive mt-2 mb-1",role:"alert",children:g}),A("div",{className:"grow"}),nt("div",{className:"flex flex-col items-start gap-0 pt-2",children:[A(D,{type:"submit",size:"sm",disabled:p,children:p?i.loginSendingButton??"":i.loginSendCodeButton??""}),A(D,{type:"button",variant:"link",className:"ml-0 pl-0",size:"sm",onClick:()=>{b(!0)},children:i.loginIHaveCode??""})]})]})})]})})})}import{useAutoAnimate as pi}from"@formkit/auto-animate/react";import{jsx as V,jsxs as Ue}from"react/jsx-runtime";function di(t,e){switch(e.type){case"SET_IS_LOGGED_IN":return{...t,isLoggedIn:e.value};case"SET_USER_ID":return{...t,userID:e.value};case"SET_LOADING":return{...t,isLoading:e.value};case"SET_PUBLIC_GROUPS":return{...t,groupsProvided:e.value,groups:e.value!=null&&e.value.length>0?t.groups.filter(a=>e.value?.find(o=>o.id===a.id)!=null):t.groups};case"SET_GROUPS":{let a=t.isLoggedIn==!1||t.groupsProvided!=null,o=e.value.map(c=>t.isLoggedIn==!0?c:{...c,isOn:t.groupsProvided?.find(d=>d.id===c.id)?.isOn??a});return{...t,groups:o}}case"TOGGLE_GROUP":{let a=t.groups.map(o=>o.id===e.groupID?{...o,isOn:!o.isOn}:o);return{...t,wasChanged:!0,groups:a}}case"CHECK_ALL_GROUPS":{let a=t.groups.map(o=>({...o,isOn:!0}));return{...t,groups:a,wasChanged:!0}}case"SET_WAS_CHANGED":return{...t,wasChanged:e.value};case"SET_IS_USER_GROUPS_UPDATED":return{...t,isUserGroupsUpdated:e.value};case"RESET_UPDATE_STATE":return{...t,wasChanged:!1,isUserGroupsUpdated:!0};case"SHOW_SETTINGS":return{...t,showSettings:!0};case"HIDE_SETTINGS":return{...t,showSettings:!1};default:return t}}function ui({slug:t,userID:e,productID:a,projectID:o,analytics:c,projectName:d,projectLogo:i,projectLogoDark:w,groups:h,isManaging:u=!1,texts:v,showQRCode:k=!1,showPhoneInput:S=!1,hiddenGroupIds:x=[],className:b}){let[g]=pi(),C=ht(o??Lt(),c),y=t??lt()??(typeof window<"u"?window.location.hostname:""),{mutateAsync:p,isPending:s}=st(et.notifications.updateUserGroups),{data:P,refetch:f}=ci({queryKey:["notifications_accessToken"],queryFn:()=>{if(typeof window<"u")return{accessToken:localStorage.getItem("notifications_accessToken")??void 0,userID:localStorage.getItem("notifications_userID")??void 0}}}),{data:B,isPending:n,refetch:l}=ee(et.notifications.getUserGroups,{slug:y,accessToken:P?.accessToken}),[N,z]=ni(di,{isLoading:n,isUserGroupsUpdated:!1,wasChanged:!1,groupsProvided:h,groups:[],showSettings:P!=null&&u==!0,isLoggedIn:P!=null,userID:void 0});$t(()=>{z({type:"SET_LOADING",value:s||n})},[s,n]),$t(()=>{z({type:"SET_IS_LOGGED_IN",value:P?.accessToken!=null}),z({type:"SET_USER_ID",value:P?.userID}),P?.accessToken!=null&&u==!0&&z({type:"SHOW_SETTINGS"})},[P,u]),$t(()=>{if(B==null)return;let M=B.groups.map(G=>{let X="rarely";switch(G.howOften){case 0:X="rarely";break;case 1:X="often";break;case 2:X="veryOften";break}return{id:G.id,name:G.name,description:G.description,howOften:X,isOn:G.isOn??void 0}});z({type:"SET_GROUPS",value:M})},[B,n,h]);let Q=si(null);$t(()=>{let M=h?.map(G=>(G.id.startsWith("group_")||(G.id=`group_${G.id}`),G));z({type:"SET_PUBLIC_GROUPS",value:M})},[h]);let j={...E,...v};async function O(){await p({accessToken:P?.accessToken,slug:y,userId:e,groupIds:N.groups.filter(M=>M.isOn===!0).map(M=>M.id)}),z({type:"RESET_UPDATE_STATE"}),Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>{z({type:"SET_IS_USER_GROUPS_UPDATED",value:!1})},2e3)}function q(M){z({type:"TOGGLE_GROUP",groupID:M})}function Zt(){z({type:"CHECK_ALL_GROUPS"})}function ue(){z({type:"SHOW_SETTINGS"})}function be(){z({type:"HIDE_SETTINGS"})}function Xt(){localStorage.removeItem("notifications_accessToken"),localStorage.removeItem("notifications_userID"),f(),z({type:"SET_USER_ID",value:void 0}),z({type:"SET_IS_LOGGED_IN",value:!1}),z({type:"HIDE_SETTINGS"})}async function Ot(M,G){typeof window<"u"&&(localStorage.setItem("notifications_accessToken",G),M!=null&&localStorage.setItem("notifications_userID",M)),z({type:"SET_USER_ID",value:M});try{await f(),l().then().catch().finally(()=>{u==!0&&z({type:"SHOW_SETTINGS"})})}catch(X){console.log(`Error: ${X}`)}}$t(()=>()=>{Q.current&&clearTimeout(Q.current)},[]);let Yt=u==!0&&N.userID!=null&&P?.accessToken!=null;return Ue("main",{className:r("bitsnap-react relative",b?.container),children:[j.title!=null&&V("h1",{className:"text-2xl font-semibold text-black md:text-3xl lg:text-4xl xl:text-5xl dark:text-neutral-100",children:j.title}),!N.showSettings&&u&&V(D,{onClick:ue,variant:"outline",size:"icon",className:"absolute bottom-6 right-6 z-50 h-12 w-12 rounded-full shadow-lg hover:shadow-xl md:bottom-8 md:right-8","aria-label":"Settings",children:V(li,{className:"h-5 w-5"})}),V("div",{className:r("md:pt8 relative z-0 mt-6 overflow-hidden rounded-2xl bg-white px-3 pt-6 pb-3 md:px-5 md:pb-5 dark:bg-neutral-800",b?.header),children:N.showSettings?V("div",{className:"space-y-6",children:N.isLoggedIn&&Ue("div",{className:r("grid grid-cols-1 gap-3 lg:gap-6",Yt?"md:grid-cols-2":""),children:[Ue("div",{className:b?.groupsContainer,children:[V(ya,{projectName:d,projectLogo:i,projectLogoDark:w,description:j.managingDescription,className:b,onLogout:Xt}),n&&V("div",{className:"flex justify-center items-center py-8",children:V(W,{})}),V(pe,{groups:N.groups,hiddenGroupIds:x,isManaging:u,onToggle:q,onCheckAll:Zt,onUpdate:O,isUpdating:s,wasChanged:N.wasChanged,isUserGroupsUpdated:N.isUserGroupsUpdated,className:b,texts:j})]}),Yt&&V(Da,{accessToken:P.accessToken??"",slug:y,userID:N.userID??"",className:b,texts:j}),k!=!1&&V(Na,{showQRCode:k,isManaging:!0,className:b,texts:j})]})}):V("div",{className:r("grid grid-cols-1 gap-3 lg:gap-6"),children:V(Ea,{slug:y,onToggle:M=>{z({type:"TOGGLE_GROUP",groupID:M})},onCheckAll:()=>{z({type:"CHECK_ALL_GROUPS"})},onSuccess:(M,G,X)=>{C.track("availability_signup",{},{product_id:a??null}),X!=null&&Ot(G,X),M&&z({type:"SHOW_SETTINGS"})},groups:N.groups,showPhoneInput:S,agreementText:j.agreementText,className:b,texts:j,wasChanged:N.wasChanged,isUpdating:s})})}),V(Ba,{isOpen:N.showSettings&&!N.isLoggedIn,slug:y,onSuccess:Ot,texts:j,onClose:be})]})}function bi({slug:t,userID:e,productID:a,projectID:o,analytics:c,projectName:d,projectLogo:i,projectLogoDark:w,groups:h,isManaging:u,texts:v,showQRCode:k,showPhoneInput:S,hiddenGroupIds:x,className:b}){return V(fe,{children:V(ui,{slug:t,userID:e,productID:a,projectID:o,analytics:c,projectName:d,projectLogo:i,projectLogoDark:w,groups:h,isManaging:u,texts:v,showQRCode:k,showPhoneInput:S,hiddenGroupIds:x,className:b})})}var mi=bi;export{Se as ApplePayButton,gi as Bitsnap,Po as BitsnapCheckout,Dr as BitsnapReturns,gr as BitsnapReturnsProvider,Or as CHECKOUT_SLOT_NAMES,Ka as Environment,Ee as GooglePayButton,Rr as ITEM_IDS_NOT_FOUND,mi as NotificationsComponent,yi as PRODUCT_LIST_SLOT_NAMES,Ar as Panel,cr as PanelLogin,ar as PanelProvider,Ci as ProductList,Ir as PublicOrderPage,lr as RETURNS_SLOT_NAMES,pr as ReturnsAppearanceProvider,Cr as ReturnsCodeStep,Nr as ReturnsConfirmation,kr as ReturnsEmailStep,Er as ReturnsMyReturnDetail,zr as ReturnsMyReturnsList,Pr as ReturnsOrderDetail,Sr as ReturnsOrderList,mr as ReturnsProvider,Tr as ReturnsResult,sr as buildAccessTokenRedirect,fi as createCheckout,hi as createPaymentURL,xi as formatProductPrice,er as getAllowedReturnOrigins,Rt as getLocale,$a as getPanelConfig,vi as getReferenceIfPossible,or as getReturnURLFromSearch,wi as injectReferenceToRequestIfNeeded,ir as persistReturnURL,nr as readPersistedReturnURL,tr as setAllowedReturnOrigins,Wa as setCustomHost,Ja as setHost,ye as setLocale,Ya as setLoginURL,Qa as setPanelConfig,Za as setPanelProjectID,ke as setProjectID,Xa as setTheme,wr as useCreateReturn,xr as useMyReturn,yr as useMyReturns,rr as usePanelConfig,ki as useProducts,fr as useReturnOrders,hr as useReturnSession,vr as useReturnableOrder,dr as useReturnsAppearance,ur as useReturnsSlot,br as useReturnsText};
|
|
1
|
+
import{A as ei,B as ai,C as ri,D as oi,E as ni,F as ii,G as Pa,H as L,I as de,J as Sa,M as Ue,N as ot,O as Na,P as Ta,R as jt,S as Ft,T as Me,a as ba,b as Ot,c as Bt,d as Ct,e as ga,f as Gt,g as ha,h as fa,i as Et,j as Br,k as Gr,l as qr,m as jr,n as Fr,o as qt,p as uo,q as bo,r as _e,s as It,t as ht,u as H,v as mo,w as ka,x as Le,y as Ca,z as zt}from"./chunk-GJNFDUJN.mjs";import{a as go}from"./chunk-DRAKVCD7.mjs";import{A as po,a as Re,b as Z,c as Hr,d as Wr,e as Vr,f as Kr,i as Qr,k as $r,l as Xr,m as Zr,n as Yr,o as Jr,p as to,q as eo,r as ao,t as ro,u as oo,v as no,w as io,x as so,y as co,z as lo}from"./chunk-G3VVAVG7.mjs";import{a as si,b as ci,c as li,d as pi}from"./chunk-VDLJW4JJ.mjs";import{a as ya,b as wa}from"./chunk-KOVKUJAW.mjs";import{a as Ir,b as zr,c as Ar,d as Rr,e as Dr,f as _r,g as Lr,h as Ur,i as Mr,j as Or}from"./chunk-HBPSSGYN.mjs";import{g as ze,h as Er,j as it,k as pe,l as gt,o as Ae,q as G,r as $t,u as va}from"./chunk-VF62KDNS.mjs";import{d as r,f as Mt,g as Tr,j as xa,l as De,m as Xt}from"./chunk-T3PAOMHI.mjs";import{l as Lt,m as Ut,n as kt,q as ma}from"./chunk-T2YSOHJM.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";import Ea from"apple-pay-button";function Ht(){try{return ot()}catch{return}}import{useQuery as Ia}from"@tanstack/react-query";import{jsx as ue}from"react/jsx-runtime";var ho=Ea.default??Ea;function fo({style:t,buttonType:e,colorType:a,items:o,onClick:i}){let{checkIfApplePayIsAvailable:s,getApplePayPaymentRequest:n,completeApplePayPayment:x,setCountry:b,setCouponCodeIfPossible:d,setDeliveryMethod:k,setEmail:g,setPostalCode:h,clearCart:m,getApplePayPreview:l}=jt(),c=Ut(),P=L("paymentForCart"),{data:C}=Ia({queryKey:["is-apple-pay-available"],queryFn:s}),N=o.map(f=>`${f.id}:${f.quantity}`).join(","),y=Na(),{data:R}=Ia({queryKey:["apple-pay-preview",N,y.country??"",y.couponCode??"",y.selectedDeliveryMethod??"",y.postalCode??""],queryFn:()=>l({items:o.map(f=>({productID:f.id,quantity:f.quantity,metadata:f.metadata}))}),enabled:C===!0});if(C!=!0)return null;let I=R!=null&&!H(R)?R:{countryCode:y.country||"PL",currencyCode:o[0]?.currency??"PLN",totalAmount:`${_e(o.reduce((f,v)=>f+v.price*v.quantity,0)/100,2)}`},T=o.map(f=>({productID:f.id,quantity:f.quantity,metadata:f.metadata}));async function S(){let f=!1,v=p=>{f||(f=!0,c.track("apple_pay_result",{outcome:p}))};c.track("apple_pay_clicked",{}),c.track("payment_method_selected",{gateway:"apple_pay",method:"apple_pay"}),ht({event:"initiateCheckout",items:o.map(p=>({id:p.id,name:p.name,price:p.price,quantity:p.quantity,currency:I.currencyCode}))});let A=o.find(p=>p.isDeliverable===!0)!=null,E=new ApplePaySession(14,{countryCode:I.countryCode,merchantCapabilities:["supports3DS"],supportedNetworks:["visa","masterCard"],currencyCode:I.currencyCode,total:{amount:I.totalAmount,label:P,type:"pending"},lineItems:o.map(p=>({amount:`${_e(p.price*p.quantity/100,2)}`,label:p.name,type:"final"})),...A?{shippingMethods:[],supportsCouponCode:!0,requiredBillingContactFields:["name","email","postalAddress","phone"],requiredShippingContactFields:["name","email","postalAddress","phone"]}:{}});await i?.();let O=await n({expectedItems:T});if(H(O)){console.error("Error creating ApplePaySession:",O.error),v("fail");return}E.oncancel=p=>{console.log("ApplePaySession cancelled",p),v("cancel")},E.onvalidatemerchant=async p=>{try{let w=await ba.get(Mt).applePayValidateMerchant({validationUrl:p.validationURL,projectId:ot()});console.log("merchantSession",w.merchantSession),w.merchantSession.length>0?(console.log("completing merchant session"),E.completeMerchantValidation(JSON.parse(w.merchantSession))):E.abort()}catch{E.abort()}},E.onshippingmethodselected=async p=>{console.log("shipping method selected",p),c.track("delivery_method_selected",{method:p.shippingMethod.identifier}),await k(p.shippingMethod.identifier);let w=await n({expectedItems:T});if(console.log("apRequest",w),H(w))throw E.abort(),new Error("Failed to get Apple Pay payment request");E.completeShippingMethodSelection({newTotal:w.total,newLineItems:w.lineItems,newShippingMethods:w.shippingMethods})},E.onshippingcontactselected=async p=>{try{p.shippingContact.countryCode!=null&&await b(p.shippingContact.countryCode),p.shippingContact.postalCode!=null&&await h(p.shippingContact.postalCode),p.shippingContact.phoneNumber!=null&&await g(p.shippingContact.emailAddress);let w=await n({expectedItems:T});if(H(w))throw E.abort(),new Error("Failed to get Apple Pay payment request");console.log("apRequest",w),E.completeShippingContactSelection({newLineItems:w.lineItems,newTotal:w.total,newShippingMethods:w.shippingMethods})}catch(w){console.log("shipping contact selected error",w),E.abort()}},E.oncouponcodechanged=async p=>{try{console.log("coupon code changed",p);let w=await d(p.couponCode),mt=await n({expectedItems:T});if(console.log("apRequest",mt),H(mt))throw E.abort(),new Error("Failed to get Apple Pay payment request");E.completeCouponCodeChange({errors:H(w)?[new ApplePayError("couponCodeInvalid")]:void 0,newTotal:mt.total,newLineItems:mt.lineItems,newShippingMethods:mt.shippingMethods})}catch(w){console.log("coupon code changed error",w),E.abort()}},E.onpaymentauthorized=async p=>{c.track("payment_submitted",{gateway:"apple_pay",method:"apple_pay"});try{let w=await x({token:p.payment.token,billingContact:p.payment.billingContact,shippingContact:p.payment.shippingContact});if(H(w)){console.log("apple pay error",w),v("fail"),E.completePayment({status:ApplePaySession.STATUS_FAILURE});return}w.redirectURL&&setTimeout(()=>{open(w.redirectURL,"_self")},2e3),v(w.isSuccess?"success":"fail"),E.completePayment({status:w.isSuccess?ApplePaySession.STATUS_SUCCESS:ApplePaySession.STATUS_FAILURE}),w.isSuccess&&m()}catch{v("fail"),E.completePayment({status:ApplePaySession.STATUS_FAILURE})}},E.begin()}return ue(ho,{style:t,buttonStyle:a,type:e,onClick:S})}function vo(t){let e=kt(Ht(),t.analytics,"cart");return ue(Lt,{value:e,children:ue(Ft,{children:ue(fo,{...t})})})}var Oe=vo;import{useEffect as te,useId as nn,useRef as sn}from"react";import Y from"zod";import{useAutoAnimate as Yo}from"@formkit/auto-animate/react";import*as dt from"@radix-ui/react-dialog";import{useCallback as Jo,useRef as tn,useState as en}from"react";import{createPortal as an}from"react-dom";import{createContext as Po,useContext as So,useMemo as No}from"react";var yo=["root","overlay","panel","header","title","closeButton","productList","product","productImage","productName","productPrice","quantityControl","quantityInput","quantityButton","removeButton","summary","totalLabel","totalValue","deliveryText","summaryNote","countryLabel","countryTrigger","countryDropdown","countrySearch","countryOption","paymentButtons","paymentMethods","paymentMethodOption","checkoutButton","emptyState","error","skeleton"],wo={fontFamily:"--bitsnap-checkout-font-family",fontSize:"--bitsnap-checkout-font-size",background:"--bitsnap-checkout-background",surface:"--bitsnap-checkout-surface",foreground:"--bitsnap-checkout-foreground",mutedForeground:"--bitsnap-checkout-muted-foreground",border:"--bitsnap-checkout-border",buttonBackground:"--bitsnap-checkout-button-background",buttonForeground:"--bitsnap-checkout-button-foreground",buttonHoverBackground:"--bitsnap-checkout-button-hover-background",hoverSurface:"--bitsnap-checkout-hover-surface",focusRing:"--bitsnap-checkout-focus-ring",error:"--bitsnap-checkout-error",overlay:"--bitsnap-checkout-overlay",radius:"--bitsnap-checkout-radius"},xo={dark:{},light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#e4e4e7",focusRing:"#71717a",error:"#dc2626",overlay:"rgb(0 0 0 / 0.35)"}},ko=[{token:"background",variable:"--background"},{token:"foreground",variable:"--foreground"},{token:"surface",variable:"--card"},{token:"surface",variable:"--popover"},{token:"foreground",variable:"--popover-foreground"},{token:"mutedForeground",variable:"--muted-foreground"},{token:"border",variable:"--border"},{token:"border",variable:"--input"},{token:"focusRing",variable:"--ring"},{token:"error",variable:"--destructive"},{token:"radius",variable:"--radius"}];function Co(t){return{"--popover":t.surface??"var(--color-neutral-800)","--popover-foreground":t.foreground??"var(--color-neutral-200)"}}function Be(t){let e=ya(t,{defaultTheme:"dark",presets:xo,variables:wo,shadcnVariables:ko});return{theme:e.theme,isCustomized:e.isCustomized,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle,dropdownStyle:Co(e.tokens)}}function za(t,e){return wa(t.elements,e)}import{jsx as To}from"react/jsx-runtime";var Aa=Po(Be());function Ra({appearance:t,children:e}){let a=No(()=>Be(t),[t]);return To(Aa.Provider,{value:a,children:e})}function Zt(){return So(Aa)}function z(t){let e=Zt();return za(e,t)??{}}import{useAutoAnimate as Qo}from"@formkit/auto-animate/react";import Q from"react";import{useEffect as Do,useState as _o}from"react";import*as U from"@radix-ui/react-select";import{CheckIcon as Eo,ChevronDownIcon as Da,ChevronUpIcon as Io}from"lucide-react";import{jsx as $,jsxs as Ge}from"react/jsx-runtime";function _a({...t}){return $(U.Root,{"data-slot":"select",...t})}function La({...t}){return $(U.Value,{"data-slot":"select-value",...t})}var zo="border-input dark:bg-input/30 dark:hover:bg-input/50 bg-transparent";function Ua({className:t,size:e="default",theme:a="default",children:o,...i}){return Ge(U.Trigger,{"data-slot":"select-trigger","data-size":e,className:r("data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex w-fit items-center justify-between gap-2 rounded-md border px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",a==="bare"?"":zo,t),...i,children:[o,$(U.Icon,{asChild:!0,children:$(Da,{className:"size-4 opacity-50"})})]})}function Ma({className:t,children:e,position:a="popper",align:o="center",...i}){return $(U.Portal,{children:Ge(U.Content,{"data-slot":"select-content",className:r("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,align:o,...i,children:[$(Ao,{}),$(U.Viewport,{className:r("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:e}),$(Ro,{})]})})}function Oa({className:t,children:e,...a}){return Ge(U.Item,{"data-slot":"select-item",className:r("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...a,children:[$("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:$(U.ItemIndicator,{children:$(Eo,{className:"size-4"})})}),$(U.ItemText,{children:e})]})}function Ao({className:t,...e}){return $(U.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:r("flex cursor-default items-center justify-center py-1",t),...e,children:$(Io,{className:"size-4"})})}function Ro({className:t,...e}){return $(U.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:r("flex cursor-default items-center justify-center py-1",t),...e,children:$(Da,{className:"size-4"})})}import{jsx as ft,jsxs as be}from"react/jsx-runtime";function Lo({id:t,open:e,disabled:a=!1,onToggle:o,onChange:i,selectedValue:s,countries:n}){let[x,b]=_o(""),{isCustomized:d,boundaryClassName:k,boundaryStyle:g,dropdownStyle:h}=Zt(),m=z("countryTrigger"),l=z("countryDropdown"),c=z("countrySearch"),P=z("countryOption"),C=L("searchCountry"),N=L("noCountriesFound");Do(()=>{s==null&&n.length>0&&i(n[0].code)},[]);let y=n.filter(I=>I.name.toLowerCase().startsWith(x.toLowerCase())),R=n.find(I=>I.code===s);return be(_a,{value:s,onValueChange:I=>{i(I),b("")},open:e,onOpenChange:I=>{I!==e&&o(),I||b("")},disabled:a,children:[ft(Ua,{"data-bitsnap-checkout-slot":"countryTrigger",theme:"bare",className:r(a?"bg-neutral-100 dark:bg-neutral-800 dark:border-neutral-700":"","w-full rounded-md",m.className),style:m.style,children:ft(La,{children:R&&be("span",{className:"truncate flex items-center",children:[ft("img",{alt:s,src:`https://purecatamphetamine.github.io/country-flag-icons/3x2/${s}.svg`,className:"inline mr-2 h-4 rounded-sm"}),R.name]})})}),be(Ma,{"data-bitsnap-checkout":d?"dropdown":void 0,"data-bitsnap-checkout-slot":d?"countryDropdown":void 0,className:r(d?"bitsnap-react":"",k,"w-full max-h-80 max-w-[350px] z-[999999]",l.className),style:{...d?{...g,...h}:void 0,...l.style},position:"popper",children:[ft("div",{"data-bitsnap-checkout-slot":"countrySearch",className:r("sticky top-0 z-10 p-1 border-b",c.className),style:c.style,children:ft("input",{type:"search",name:"search",autoComplete:"off",className:"block w-full outline-none sm:text-body-regular bg-transparent rounded-md px-2 py-1.5",placeholder:C,"aria-label":C,value:x,onChange:I=>b(I.target.value),onClick:I=>I.stopPropagation(),onKeyDown:I=>I.stopPropagation()})}),ft("div",{className:"max-h-64 overflow-y-auto",children:y.length===0?ft("div",{className:"cursor-default select-none relative py-2 pl-3 pr-9 text-sm",children:N}):y.map(I=>be(Oa,{"data-bitsnap-checkout-slot":"countryOption",value:I.code,className:r("cursor-default select-none relative py-2 pl-3 pr-9 flex items-center transition",P.className),style:P.style,children:[ft("img",{alt:I.code,src:`https://purecatamphetamine.github.io/country-flag-icons/3x2/${I.code}.svg`,className:"inline mr-2 h-4 rounded-sm"}),ft("span",{className:"font-normal truncate",children:I.name})]},`${t}-${I.code}`))})]})]})}var Ba=Lo;import{useEffect as qo,useRef as ja,useState as Ha}from"react";import{MinusIcon as jo,PlusIcon as Fo}from"lucide-react";import{Slot as Yi}from"@radix-ui/react-slot";import{cva as Uo}from"class-variance-authority";import{jsx as Oo}from"react/jsx-runtime";var Mo=Uo("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});function Ga({className:t,orientation:e,...a}){return Oo("div",{role:"group","data-slot":"button-group","data-orientation":e,className:r(Mo({orientation:e}),t),...a})}import{Fragment as Bo,jsx as me,jsxs as Go}from"react/jsx-runtime";function qa({price:t,currency:e,pricing:a,quantity:o=1}){let i=L("lowestPrice30Days"),s=L("noPriceHistory"),n=a?.regularPrice??t,x=a?.effectivePrice??t,b=a?.discount?.status==="ACTIVE"&&x<n;return me("span",{children:b?Go(Bo,{children:[me("span",{className:"mr-2 text-neutral-500 line-through",children:It(n*o,e)}),me("span",{className:"font-semibold text-red-700",children:It(x*o,e)}),me("span",{className:"mt-1 block text-xs text-neutral-600",children:a?.referencePrice.historyAvailable&&a.referencePrice.amount!=null?`${i} ${It(a.referencePrice.amount,e)}`:s})]}):It(x*o,e)})}function ge(t){return Number.isFinite(t)?Math.min(99,Math.max(1,Math.trunc(t))):1}function qe(t,e){let a=parseInt(t,10);return Number.isNaN(a)?e:ge(a)}import{Fragment as Vo,jsx as K,jsxs as he}from"react/jsx-runtime";var Ho=({isNotAvailable:t,quantity:e,details:a,url:o,shouldUpdate:i})=>{let s=z("product"),n=z("productImage"),x=z("productName"),b=z("productPrice"),d=z("removeButton"),k=L("remove"),g=a.image_url??a.images?.[0],[h,m]=Ha(),l=g!=null&&g.length>0&&g!==h,c=a.baseName??a.name;return he("div",{"data-bitsnap-checkout-slot":"product","data-bitsnap-checkout-unavailable":t?"":void 0,className:r("flex items-center gap-3 mx-3",t?"outline outline-1 rounded-md m-1":"",s.className),style:s.style,children:[l&&K(Fa,{url:o,tabIndex:-1,"aria-hidden":"true",className:"contents",children:K("img",{"data-bitsnap-checkout-slot":"productImage",className:r("aspect-auto max-w-[30%] max-w-32 max-h-32 py-2 overflow-hidden",n.className),style:n.style,src:g,alt:"",onError:()=>m(g)})}),he("div",{className:"flex flex-col w-full",children:[K("p",{"data-bitsnap-checkout-slot":"productName",className:r("font-medium",x.className),style:x.style,children:K(Fa,{url:o,className:"text-inherit no-underline hover:underline",children:c})}),a.variantName!=null&&a.variantName.length>0&&K("p",{className:"text-sm opacity-70",children:a.variantName}),K("p",{"data-bitsnap-checkout-slot":"productPrice",className:r("text-sm",b.className),style:b.style,suppressHydrationWarning:!0,children:K(qa,{price:a.price,currency:a.currency,pricing:a.pricing,quantity:e})}),he("div",{className:"flex justify-between",children:[K(Wo,{className:"",quantity:e,shouldUpdate:i}),K(G,{"data-bitsnap-checkout-slot":"removeButton",type:"button",variant:"ghost",size:"sm",className:d.className,style:d.style,"aria-label":`${k}: ${a.name}`,onClick:()=>{Promise.resolve(i(0)).catch(()=>{})},children:k})]})]})]})},Wa=Ho,Fa=({url:t,children:e,...a})=>t==null?K(Vo,{children:e}):K("a",{href:t,...a,children:e}),Wo=({quantity:t,shouldUpdate:e,className:a})=>{let[o,i]=Ha(t.toString()),s=ja(t),n=z("quantityControl"),x=z("quantityInput"),b=z("quantityButton"),d=L("quantity"),k=L("increaseQuantity"),g=L("decreaseQuantity"),h=ja(t);h.current=t,qo(()=>{s.current=t,i(t.toString())},[t]);function m(l){i(l.toString()),l!==s.current&&(s.current=l,Promise.resolve(e(l)).catch(()=>{s.current===l&&(s.current=h.current,i(h.current.toString()))}))}return K("div",{"data-bitsnap-checkout-slot":"quantityControl",className:r("flex",a,n.className),style:n.style,children:he(Ga,{"aria-label":d,children:[K(G,{"data-bitsnap-checkout-slot":"quantityButton",type:"button",className:b.className,style:b.style,"aria-label":g,onClick:()=>m(ge(s.current-1)),children:K(jo,{"aria-hidden":"true"})}),K("input",{"data-bitsnap-checkout-slot":"quantityInput",className:r("w-8 bg-transparent text-center",x.className),style:x.style,value:o,"aria-label":d,inputMode:"numeric",pattern:"[0-9]*",onChange:l=>i(l.currentTarget.value),onBlur:l=>m(qe(l.currentTarget.value,s.current)),onKeyDown:l=>{l.key==="Enter"&&m(qe(l.currentTarget.value,s.current))},type:"text"}),K(G,{"data-bitsnap-checkout-slot":"quantityButton",type:"button",className:b.className,style:b.style,"aria-label":k,onClick:()=>m(ge(s.current+1)),children:K(Fo,{"aria-hidden":"true"})})]})})};import{jsx as Ko}from"react/jsx-runtime";function je({className:t,...e}){return Ko("div",{"data-slot":"skeleton",className:"bg-neutral-700 animate-pulse rounded-md "+t,...e})}import{useMutation as Yt,useQuery as Jt,useQueryClient as $o}from"@tanstack/react-query";import Va from"react";import{jsx as fe,jsxs as ve}from"react/jsx-runtime";function Ka({choice:t,selected:e,onChange:a,disabled:o}){let i=de(),s=z("paymentMethods"),n=z("paymentMethodOption"),x=Va.useId(),b=Va.useId(),d=t.manualAccountTypes.length===0||t.manualAccountTypes.includes("blik"),k={online:{title:i("paymentMethodOnline"),description:i("paymentMethodOnlineDescription")},manual:{title:i(Ca(t.manualAccountTypes)),description:i("paymentMethodManualDescription"),note:d?i("paymentMethodManualBlikNote"):void 0}};return ve("fieldset",{"data-bitsnap-checkout-slot":"paymentMethods","aria-labelledby":b,className:r("mx-2 mt-4 mb-2 flex min-w-0 flex-col gap-2 border-0 p-0",s.className),style:s.style,disabled:o,children:[fe("legend",{id:b,className:"mb-1 px-1 text-sm font-medium",children:i("paymentMethodLegend")}),t.methods.map(g=>{let h=k[g],m=g===e,l=`${x}-${g}-description`;return ve("label",{"data-bitsnap-checkout-slot":"paymentMethodOption","data-payment-method":g,"data-selected":m?"":void 0,className:r("flex cursor-pointer items-start gap-3 rounded-md border px-3 py-2.5 transition-colors",n.className),style:n.style,children:[fe("input",{type:"radio",name:x,value:g,checked:m,onChange:()=>a(g),"aria-describedby":l,className:"mt-0.5 size-4 shrink-0 cursor-pointer"}),ve("span",{className:"flex min-w-0 flex-col gap-0.5",children:[fe("span",{className:"text-sm font-semibold leading-snug",children:h.title}),ve("span",{id:l,"data-bitsnap-checkout-payment-method-description":"",className:"text-xs leading-snug",children:[h.description,m&&h.note!=null&&fe("span",{className:"mt-1 block font-medium",children:h.note})]})]})]},g)})]})}import{Fragment as Zo,jsx as D,jsxs as st}from"react/jsx-runtime";var Xo=({className:t,locale:e})=>{let a=jt(),o=Ut(),i=e??Xt(),s=z("productList"),n=z("summary"),x=z("totalLabel"),b=z("totalValue"),d=z("deliveryText"),k=z("summaryNote"),g=z("countryLabel"),h=z("paymentButtons"),m=z("checkoutButton"),l=z("emptyState"),c=z("error"),P=z("skeleton"),C=L("unavailableProducts"),N=de(),y=L("emptyCart"),R=L("total"),I=L("delivery"),T=L("chooseCountry"),S=L("nextStep"),f=L("loadFailed"),v=L("retry"),A=L("countryRequired"),E=L("extrasCalculatedNext"),O=Q.useId(),p=Q.useId(),{mutateAsync:w}=Yt({mutationFn:a.removeProductFromCart}),{mutateAsync:mt}=Yt({mutationFn:a.updateQuantity}),{mutateAsync:ie}=Yt({mutationFn:a.setCountry}),{mutateAsync:Se}=Yt({mutationFn:a.clearCart}),[se,Nt]=Q.useState(""),pt=zt(u=>u.notice);Q.useEffect(()=>()=>zt.getState().setNotice(void 0),[]);let F=se.length>0?se:pt??"",[V,rt]=Q.useState([]),[Xe,hr]=Q.useState(!1),{mutateAsync:fr,isPending:Ne}=Yt({mutationFn:a.redirectToNextStep}),{data:Ze}=Jt({queryKey:["cart-available-countries"],queryFn:a.getAvailableCountries}),{data:vr}=Jt({queryKey:["cart-one-click-payment"],queryFn:a.checkIfApplePayIsAvailable}),{data:Te,isLoading:Dt,isError:yr,refetch:Ye}=Jt({queryKey:["cart",i],queryFn:a.getProducts}),{data:Tt,refetch:Je}=Jt({queryKey:["cart-country"],queryFn:a.getCountry}),[wr]=Qo(),B=H(Te)?void 0:Te,ta=$o(),ce=B==null||B.length===0?void 0:B.map(u=>`${u.productID}:${u.quantity}`).sort().join(","),ea={queryKey:["cart-payment-methods",ot(),i,ce],queryFn:async()=>a.getPaymentMethodChoice().catch(()=>null),staleTime:6e4,retry:!1},{data:aa}=Jt({...ea,enabled:ce!=null}),le=ce!=null?aa??null:null,[ra,xr]=Q.useState(void 0),[oa,na]=Q.useState(!1),ia=Q.useRef(null),sa=!Dt&&(yr||H(Te)),xt=H(Ze)?[]:Ze,Kt=B?.reduce((u,W)=>W.details==null?u:u+(W.details.pricing?.effectivePrice??W.details.price)*W.quantity,0)??0,Qt=B?.[0]?.details?.currency??"PLN",kr=B?.some(u=>u.details?.isDeliverable===!0)??!1,_t=Tt!=null&&!H(Tt)&&Tt!=""?Tt:void 0,ca=Tt!==void 0&&_t==null,la=Q.useRef(!1);Q.useEffect(()=>{la.current||xt==null||xt.length===0||Tt==null||_t!=null&&xt.some(u=>u.code===_t)||(la.current=!0,ie(xt[0].code).then(()=>Je()).catch(()=>{}))},[xt,Tt,_t]);let pa=Q.useRef(!1);Q.useEffect(()=>{pa.current||Dt||(pa.current=!0,o.track("cart_opened",{item_count:B?.reduce((u,W)=>u+W.quantity,0)??0,value_minor:Kt,currency:Qt}))},[Dt,o,B,Kt,Qt]);let Ee=Q.useRef(new Map);Q.useEffect(()=>{Ee.current.clear()},[B]);function Cr(u,W){let j=B?.find(Nr=>Nr.id===u);if(j?.details==null)return;let tt=W-(Ee.current.get(u)??j.quantity);if(Ee.current.set(u,W),tt===0)return;let Ie=j.details.pricing?.effectivePrice??j.details.price,ua=j.catalogProductID??j.productID;o.track(tt>0?"add_to_cart":"remove_from_cart",{qty:Math.abs(tt),value_minor:Math.round(Ie*Math.abs(tt)),currency:j.details.currency},{product_id:ua,variant_id:ua!==j.productID?j.productID:null})}let da=Q.useRef(!1);async function Pr(u,W){if(W!=null){Cr(u,Math.max(0,W));try{let j=W<=0?await w({id:u}):await mt({id:u,quantity:W});if(H(j))throw new Error(`cannot change the cart: ${j.error}`)}finally{await Ye().catch(()=>{})}}}async function Sr(){try{Nt(""),rt([]),zt.getState().setNotice(void 0);let u=le;if(ce!=null&&aa===void 0){na(!0);try{u=await ta.fetchQuery(ea).catch(()=>null)}finally{na(!1)}if(u!=null){window.setTimeout(()=>{ia.current?.querySelector("input:checked")?.focus()},0);return}}if(B!=null){!da.current&&B.length>0&&(da.current=!0,o.track("checkout_started",{item_count:B.reduce((tt,Ie)=>tt+Ie.quantity,0),checkout_type:"cart",value_minor:Kt,currency:Qt}));try{ht({event:"initiateCheckout",items:B?.map(tt=>({id:tt.productID,name:tt.details?.name??"",price:tt.details?.price??0,quantity:tt.quantity,currency:tt.details?.currency??"PLN"}))})}catch{}}let W=Ta(),j=await fr(u!=null?{paymentMethod:Le(u,ra)}:void 0);if(H(j)){ta.invalidateQueries({queryKey:["cart-payment-methods"]}),j.error=="item-ids-not-found"?(Nt(C),"data"in j&&Array.isArray(j.data)&&rt(j.data)):Nt(ka(j,N));return}Sa(j,{cartProjectId:ot(),lines:W})||await Se(),window.location.href=j.url}catch(u){console.warn("checkout failed",u),Nt(N("checkoutFailed"))}}return st("div",{className:`${t} flex flex-col`,ref:wr,children:[Dt&&st("div",{className:"relative flex w-full justify-center flex-col gap-4",children:[D(je,{"data-bitsnap-checkout-slot":"skeleton",className:r("w-full h-32",P.className),style:P.style}),D(je,{"data-bitsnap-checkout-slot":"skeleton",className:r("w-full h-32",P.className),style:P.style})]}),sa&&st("div",{className:"flex flex-col items-start gap-3 p-4",children:[D("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:r(c.className),style:c.style,children:f}),pt!=null&&pt.length>0&&D("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:r("text-sm",c.className),style:c.style,children:pt}),D("button",{type:"button","data-bitsnap-checkout-slot":"checkoutButton",onClick:()=>{Ye().then().catch()},className:r("px-3 py-2 rounded-md transition font-bold",m.className),style:m.style,children:v})]}),!Dt&&!sa&&(B==null||B.length==0)&&st("div",{className:"flex flex-col gap-4 p-4",children:[D("p",{"data-bitsnap-checkout-slot":"emptyState",className:r(l.className),style:l.style,children:y}),pt!=null&&pt.length>0&&D("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:r("text-sm",c.className),style:c.style,children:pt})]}),D("div",{"data-bitsnap-checkout-slot":"productList",className:r("max-h-[70vh] overflow-clip overflow-y-scroll",s.className),style:s.style,children:B!=null&&B.length>0&&D("ul",{className:"mt-5",children:B.map(u=>D(Q.Fragment,{children:u.details!=null&&st("li",{className:"mb-3",children:[D(Wa,{isNotAvailable:V.includes(u.productID),quantity:u.quantity,details:u.details,url:u.url,shouldUpdate:W=>Pr(u.id,W)}),D("hr",{className:"h-1"})]})},u.id))})}),D("div",{className:"grow"}),Kt>0&&Qt!=null&&st(Zo,{children:[st("div",{"data-bitsnap-checkout-slot":"summary",className:r("mx-3 flex flex-col",n.className),style:n.style,children:[st("div",{className:"flex flex-row justify-between text-lg",children:[D("p",{"data-bitsnap-checkout-slot":"totalLabel",className:r("text-xl",x.className),style:x.style,children:R}),st("div",{className:"flex flex-col items-end",children:[D("p",{"data-bitsnap-checkout-slot":"totalValue",className:r("font-medium",b.className),style:b.style,children:It(Kt,Qt)}),kr&&D("p",{"data-bitsnap-checkout-slot":"deliveryText",className:r("opacity-70 text-right text-base",d.className),style:d.style,children:I})]})]}),D("p",{"data-bitsnap-checkout-slot":"summaryNote",className:r("opacity-70 text-sm",k.className),style:k.style,children:E})]}),xt&&xt?.length>1&&st("div",{children:[D("h4",{"data-bitsnap-checkout-slot":"countryLabel",className:r("ml-3 text-sm",g.className),style:g.style,children:T}),D(Ba,{id:O,open:Xe,onToggle:()=>{hr(!Xe)},onChange:u=>{ie(u).then(()=>{Je().then().catch()})},selectedValue:_t??"",countries:xt})]}),st("div",{className:"mb-3 flex flex-col",children:[vr&&B!=null&&B.length>0&&D("div",{"data-bitsnap-checkout-slot":"paymentButtons",className:r("w-full px-2",h.className),style:h.style,children:D(Oe,{colorType:"white",style:{width:"100%"},items:B?.map(u=>({name:u.details?.name??"",id:u.productID,price:u.details?.pricing?.effectivePrice??u.details?.price??0,currency:u.details?.currency,quantity:u.quantity,isDeliverable:u.details?.isDeliverable??!1,metadata:u.metadata}))})}),B!=null&&B.length>0&&D("div",{"data-bitsnap-checkout-slot":"paymentButtons",className:r("w-full px-2",h.className),style:h.style,children:D(Fe,{buttonSizeMode:"fill",buttonColor:"white",style:{width:"100%"},items:B?.map(u=>({name:u.details?.name??"",id:u.productID,price:u.details?.pricing?.effectivePrice??u.details?.price??0,quantity:u.quantity,isDeliverable:u.details?.isDeliverable??!1,metadata:u.metadata}))})}),le!=null&&D("div",{ref:ia,className:"contents",children:D(Ka,{choice:le,selected:Le(le,ra),onChange:xr,disabled:Ne})}),D("button",{"data-bitsnap-checkout-slot":"checkoutButton",onClick:Sr,disabled:Dt||Ne||oa||_t==null,"aria-describedby":ca?p:void 0,className:r("px-3 py-2 my-2 mx-2 rounded-md disabled:opacity-40 disabled:cursor-not-allowed transition font-bold",m.className),style:m.style,children:Ne||oa?D(Z,{}):S}),ca&&D("p",{id:p,className:"text-sm text-center opacity-70",children:A}),F.length>0&&D("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:r("text-sm text-center",c.className),style:c.style,children:F})]})]})]})},Qa=Xo;import{jsx as et,jsxs as ye}from"react/jsx-runtime";function rn({isVisible:t,shouldHide:e,panelId:a,locale:o}){let[i]=Yo(),[s,n]=en(null),x=Jo(y=>{i(y),n(y)},[i]),b=tn(null),{boundaryClassName:d,boundaryStyle:k}=Zt(),g=z("root"),h=z("overlay"),m=z("panel"),l=z("header"),c=z("title"),P=z("closeButton"),C=L("cart"),N=L("close");return et("div",{ref:x,"data-bitsnap-checkout":"root","data-bitsnap-checkout-slot":"root",className:r("bitsnap-react",d,g.className),style:{zIndex:999999,...k,...g.style},children:s!=null&&et(dt.Root,{open:t,onOpenChange:y=>{y||e()},children:ye(dt.Portal,{container:s,children:[et(dt.Overlay,{"data-bitsnap-checkout-slot":"overlay","aria-hidden":"true",className:r("fixed top-0 right-0 left-0 bottom-0 cursor-pointer z-10",h.className),style:h.style,onClick:e}),ye(dt.Content,{id:a,"data-bitsnap-checkout-slot":"panel","aria-modal":"true","aria-describedby":void 0,onOpenAutoFocus:()=>{let y=document.activeElement;b.current=y instanceof HTMLElement?y:null},onCloseAutoFocus:y=>{y.preventDefault(),b.current?.focus(),b.current=null},className:r("fixed z-20 top-0 right-0 bottom-0 w-full md:w-[350px] xl:w-[420px] flex flex-col overflow-y-auto",m.className),style:m.style,onPointerDownOutside:y=>y.preventDefault(),children:[ye("div",{"data-bitsnap-checkout-slot":"header",className:r("mx-3 mt-7 flex justify-between items-center",l.className),style:l.style,children:[et(dt.Title,{asChild:!0,children:et("h1",{"data-bitsnap-checkout-slot":"title",className:r("text-2xl font-medium",c.className),style:c.style,children:C})}),et("button",{type:"button","data-bitsnap-checkout-slot":"closeButton",className:r("rounded-xl p-2 transition",P.className),style:P.style,"aria-label":N,onClick:e,children:ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-x","aria-hidden":"true",focusable:"false",children:[et("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),et("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),et(Qa,{className:"grow",locale:o})]})]})})})}var on=t=>typeof window>"u"?null:an(et(Ra,{appearance:t.appearance,children:et(Pa,{texts:t.texts,locale:t.locale,children:et(Ft,{locale:t.locale,children:et(rn,{...t})})})}),document.body),$a=on;import{Fragment as Xa,jsx as At,jsxs as we}from"react/jsx-runtime";var cn=Y.object({id:Y.string(),isSubscription:Y.boolean().default(!1),quantity:Y.number(),metadata:Y.record(Y.string(),Y.string().optional()).optional(),url:Y.string().optional()}),ln={position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0};function pn({projectID:t,locale:e,children:a,onVisibleChange:o,className:i,numberOfProductsInCartOptions:s,appearance:n,texts:x,analytics:b}){let d=kt(t,b,"cart");ma(d);let{isCartVisible:k,showCart:g,hideCart:h,numberOfProductsInCart:m}=zt(),l=`bitsnap-cart-${nn()}`,c=T=>xa(T,e??Xt(),x),P=sn(c);P.current=c;function C(T){zt.getState().setNotice(P.current(T)),g()}function N(T){document.querySelectorAll("iframe").forEach(f=>{f.contentWindow?.postMessage(T,"*")})}te(()=>{o?.(k),k&&ht({event:"viewCart"})},[k]),te(()=>{Ue(t)},[t]),te(()=>{De(e)},[e]),te(()=>{if(!("cart"in window)){let T=ot();if(T==null){console.warn("There is no project ID configured.");return}window.cart={buyProduct:async S=>{try{let f=Y.object({productID:Y.string(),email:Y.string().optional(),name:Y.string().optional(),country:Y.string().optional(),marketingAgreement:Y.boolean().optional(),locale:Y.string().optional()}).parse(S),v=Me(T);try{let E=await v.getProducts();H(E)==!1&&ht({event:"initiateCheckout",items:E.map(O=>({id:O.productID,name:O.details?.name??"",price:O.details?.price??0,quantity:O.quantity,currency:O.details?.currency??"PLN"}))})}catch{}let A=await v.justRedirectToPayment(f);H(A)==!1?window.location.href=A.url:C("redirectFailed")}catch(f){console.warn(f)}}}}},[]);async function y(T,S){let f=ot();if(f==null){console.warn("There is no project ID configured.");return}try{let v=cn.parse(S);if(v.isSubscription){await R(f,v);return}await Me(f).addProduct({productID:v.id,quantity:v.quantity,metadata:v.metadata,url:v.url}),N({id:T,type:"ADD_TO_CART",success:!0}),g()}catch(v){console.warn("cannot add item to cart",v)}}async function R(T,S){console.warn("subscriptions cannot be added to the cart yet",T,S.id),C("subscriptionUnsupported")}function I(){"__cart_is_listening"in window||(window.__cart_is_listening=!0,window.addEventListener("message",T=>{if(typeof T.data.id<"u"&&typeof T.data.type<"u"){let{id:S,type:f}=T.data;switch(f){case"ADD_TO_CART".toString():y(S,T.data.payload).then().catch();break;default:break}}}))}return te(()=>{if(I(),typeof window<"u")try{let T=new URLSearchParams(window.location.search),S=T.get("ref")??T.get("utm-source");typeof localStorage<"u"&&S&&S.length>0&&localStorage.setItem("bitsnap-ref",S)}catch{return}},[]),we(Xa,{children:[we("button",{type:"button",onClick:()=>k?h():g(),"aria-label":a?void 0:m>0?`${c("openCart")}. ${c("cartItemsCount")}: ${m}`:c("openCart"),"aria-expanded":k,"aria-haspopup":"dialog","aria-controls":k?l:void 0,style:{position:"relative"},className:["bitsnap-react",i??"rounded-full hover:bg-neutral-300 transition p-1"].join(" "),children:[a?At(Xa,{children:a}):we("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-shopping-cart","aria-hidden":"true",focusable:"false",children:[At("circle",{cx:"8",cy:"21",r:"1"}),At("circle",{cx:"19",cy:"21",r:"1"}),At("path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"})]}),m>0&&we("span",{style:ln,children:[c("cartItemsCount"),": ",m]}),s?.isVisible!=!1&&m>0&&At("div",{"aria-hidden":"true",style:{position:"absolute",bottom:-5,right:-5,background:"black",color:"white",borderRadius:"50%",width:"22px",height:"22px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",fontWeight:600,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.25)",...s?.style},children:m})]}),At(Lt,{value:d,children:At($a,{isVisible:k,locale:e,appearance:n,texts:x,panelId:l,shouldHide:()=>{h()}})})]})}var dn=pn;import un from"@google-pay/button-react";import{useQuery as bn,useMutation as mn}from"@tanstack/react-query";import{Fragment as fn,jsx as ee,jsxs as vn}from"react/jsx-runtime";function gn({items:t,style:e,buttonColor:a,buttonSizeMode:o,test:i}){let{getGooglePayConfiguration:s,completeGooglePayPayment:n,setCountry:x,setCouponCodeIfPossible:b,setDeliveryMethod:d,setEmail:k,setPostalCode:g,clearCart:h}=jt(),m=Ut(),{data:l}=bn({queryKey:["get-google-pay-configuration",t.map(C=>C.id).join(",")],queryFn:()=>s({items:t.map(C=>({...C,id:void 0,productID:C.id}))})}),{mutateAsync:c,isPending:P}=mn({mutationFn:n});return l==null||l.isAvailable!=!0?(console.log("google pay configuration is not available",l),null):vn(fn,{children:[ee(un,{buttonSizeMode:o,buttonColor:a,style:e,existingPaymentMethodRequired:!0,onClick:()=>m.track("payment_method_selected",{gateway:"google_pay",method:"google_pay"}),environment:i===!0?"TEST":"PRODUCTION",onPaymentDataChanged:async C=>{ht({event:"initiateCheckout",items:t.map(y=>({id:y.id,name:y.name,price:y.price,quantity:y.quantity,currency:"PLN"}))}),console.log("payment data changed",C),C.shippingAddress?.postalCode!=null&&await g(C.shippingAddress?.postalCode),C.shippingAddress?.countryCode!=null&&await x(C.shippingAddress?.countryCode),C.shippingOptionData?.id!=null&&await d(C.shippingOptionData.id);let N=await s({items:[]});return console.log("PAYMENT DATA CHANGED CONFIG",N),N.isAvailable?{error:void 0,newShippingOptionParameters:N.config.shippingOptionParameters,newTransactionInfo:N.config.transactionInfo}:{error:void 0}},paymentRequest:l.config,onLoadPaymentData:async C=>{m.track("payment_submitted",{gateway:"google_pay",method:"google_pay"});try{let N=await c({paymentData:C});if(H(N)){console.log("apple pay error",N);return}N.isSuccess&&h(),N.redirectURL&&open(N.redirectURL,"_self")}catch(N){console.warn("error completing google pay payment",N)}}}),P?ee(Z,{}):null]})}function hn(t){let e=kt(Ht(),t.analytics,"cart");return ee(Lt,{value:e,children:ee(Ft,{children:ee(gn,{...t})})})}var Fe=hn;import{useReducer as Vn,useRef as Kn,useEffect as ne}from"react";import{useQuery as Qn}from"@tanstack/react-query";import{Settings as $n}from"lucide-react";import{Fragment as yn,jsx as He,jsxs as wn}from"react/jsx-runtime";var _={title:null,description:null,managingDescription:"Zarz\u0105dzaj rodzajami powiadomie\u0144 i sposobem dostarczania.",formTitle:"Podaj Email aby zapisa\u0107 si\u0119\xA0do powiadomie\u0144",formEmailLabel:"Email",formPhoneLabel:"Numer telefonu",formPhoneOptional:"(opcjonalnie)",formEmailPlaceholder:"np. mail@gmail...",formPhonePlaceholder:"np. 663...",formSubmitButton:"Zapisz si\u0119",formSuccessMessage:"Zapisa\u0142e\u015B si\u0119 do powiadomie\u0144.",agreementText:wn(yn,{children:[He("span",{style:{color:"red"},children:"*"}),"Wyra\u017Cam zgod\u0119 na przetwarzanie moich danych w celach marketingowych zgodnie z"," ",He("a",{href:"/regulations/polityka-prywatnosci",target:"_blank",className:"cursor-alias font-bold hover:font-medium",children:"regulaminem"})," ",He("span",{className:"text-xs font-light",children:"(zgod\u0119 mo\u017Cna w ka\u017Cdej chwili wycofa\u0107)"})]}),qrCodeTitle:"lub zainstaluj aplikacj\u0119 mobiln\u0105",qrCodeSubtitle:"Aplikacja mobilna",qrCodeScanText:"zeskanuj kod QR",groupsNoSelectionWarning:"Je\u015Bli \u017Cadna z grup nie jest zaznaczona, nie otrzymasz \u017Cadnych powiadomie\u0144.",groupsSelectAllButton:"Zaznacz wszystkie",groupsUpdateButton:"Aktualizuj",groupsUpdateSuccess:"Zaktualizowano pomy\u015Blnie.",groupsTitle:"Zarz\u0105dzaj grupami z kt\xF3rych chcesz otrzymywa\u0107 powiadomienia",manageDataTitle:"Ustawienia powiadomie\u0144",manageDataDescription:"W jaki spos\xF3b chcesz otrzymywa\u0107 powiadomienia?",manageDataUnsubscribeButton:"Odsubskrybuj",manageDataUpdatedMessage:"Zaktualizowano",manageDataUnsubscribeDescription:"Wypisz mnie z wszystkich powiadomie\u0144 i grup.",loginEmailLabel:"Email",loginEmailPlaceholder:"Wprowad\u017A sw\xF3j email",loginSendCodeButton:"Wy\u015Blij kod weryfikacyjny",loginSendingButton:"Wysy\u0142anie...",loginCodeLabel:"Wprowad\u017A kod weryfikacyjny",loginCodeSentMessage:"Wys\u0142ali\u015Bmy kod weryfikacyjny na adres",loginChangeEmailButton:"Popraw email",loginResendCodeButton:"Wy\u015Blij kod ponownie",loginInvalidEmailError:"Wprowad\u017A prawid\u0142owy adres email",loginSlugRequiredError:"Wymagany jest identyfikator projektu",loginInvalidCodeError:"Nieprawid\u0142owy kod weryfikacyjny",loginVerificationFailedError:"Weryfikacja nie powiod\u0142a si\u0119. Sprawd\u017A sw\xF3j kod.",loginSendEmailError:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 kodu weryfikacyjnego",loginVerifyCodeError:"Nie uda\u0142o si\u0119 zweryfikowa\u0107 kodu",loginResendEmailError:"Nie uda\u0142o si\u0119 ponownie wys\u0142a\u0107 kodu weryfikacyjnego",loginTitle:"Wpisz email aby zarz\u0105dza\u0107 powiadomieniami",loginDescription:"Dostaniesz kod weryfikacyjny na email.",loginIHaveCode:"Mam ju\u017C kod"};import{LogOutIcon as xn}from"lucide-react";import{Fragment as Za,jsx as Rt,jsxs as xe}from"react/jsx-runtime";function Ya({projectName:t,projectLogo:e,projectLogoDark:a,description:o,className:i,onLogout:s}){return xe(Za,{children:[e!=null||t!=null&&xe("h2",{className:r("flex max-w-44 items-center gap-3 text-lg font-medium text-black sm:max-w-none md:text-xl lg:text-2xl xl:text-3xl dark:text-neutral-100",i?.headerTitle),children:[e!=null&&xe(Za,{children:[Rt("img",{src:e,alt:"",className:r("h-12 w-auto dark:hidden",i?.headerLogo)}),Rt("img",{src:a??e,alt:"",className:r("hidden h-12 w-auto dark:inline",i?.headerLogo)})]}),Rt("span",{children:t})]}),xe("div",{className:"flex items-center gap-2",children:[o&&Rt("p",{className:r("mt-4 font-medium text-left",i?.headerDescription),children:o}),Rt("div",{className:"grow"}),s&&Rt(G,{variant:"ghost",size:"icon-sm",onClick:s,children:Rt(xn,{className:"h-5 w-5"})})]})]})}import{useAutoAnimate as rr}from"@formkit/auto-animate/react";import{CheckCircleIcon as Cn,TriangleAlertIcon as Pn}from"lucide-react";import*as vt from"@radix-ui/react-popover";import{jsx as ke}from"react/jsx-runtime";function Ja({...t}){return ke(vt.Root,{"data-slot":"popover",...t})}function tr({...t}){return ke(vt.Trigger,{"data-slot":"popover-trigger",...t})}function er({className:t,align:e="center",sideOffset:a=4,...o}){return ke(vt.Portal,{children:ke(vt.Content,{"data-slot":"popover-content",align:e,sideOffset:a,className:r("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...o})})}import{ClockIcon as kn}from"lucide-react";import{jsx as yt,jsxs as Pt}from"react/jsx-runtime";function ar({regularity:t}){let e="";switch(t){case"rarely":e="rzadko";break;case"often":e="cz\u0119sto";break;case"very_often":e="codzienne";break}return Pt(Ja,{children:[yt(tr,{onClick:a=>{a.stopPropagation()},children:Pt("button",{type:"button",className:"flex w-[30%] cursor-help flex-col items-center justify-center text-xs md:w-[25%] xl:w-[20%]",children:[yt(kn,{size:12}),yt("span",{children:e})]})}),yt(er,{className:"w-80",children:Pt("div",{className:"grid gap-4",children:[Pt("div",{className:"space-y-2",children:[yt("h4",{className:"leading-none font-medium",children:"Co to oznacza?"}),Pt("ul",{className:"list-inside list-disc text-sm",children:[Pt("li",{children:[yt("span",{className:"font-semibold",children:"Rzadko"})," \u2013 powiadomienia b\u0119d\u0105 wysy\u0142ane maksymalnie kilka razy w miesi\u0105cu."]}),Pt("li",{children:[yt("span",{className:"font-semibold",children:"Cz\u0119sto"})," \u2013 powiadomienia mog\u0119 by\u0107 wysy\u0142ane kilka razy w tygodniu."]}),Pt("li",{children:[yt("span",{className:"font-semibold",children:"Codzienne"})," \u2013 powiadomienia b\u0119d\u0105 wysy\u0142ane nawet codziennie."]})]})]}),yt("div",{className:"grid gap-2"})]})})]})}import{Fragment as Sn,jsx as J,jsxs as ut}from"react/jsx-runtime";function Ce({groups:t=[],isManaging:e,onToggle:a,onCheckAll:o,onUpdate:i,isUpdating:s,wasChanged:n,isUserGroupsUpdated:x,className:b,texts:d}){let[k]=rr(),[g]=rr(),h=t.filter(c=>c.isOn===!1).length>0,m=t.filter(c=>c.isOn===!1).length>0;if(t.length<=1&&e!=!0)return null;let l=ut("div",{ref:k,className:r("my-5 flex flex-col gap-3",b?.groupsList),children:[t.map(c=>ut("div",{id:c.id,role:"button",className:r(c.isOn?"bg-neutral-50 hover:bg-transparent shadow-sm border-transparent dark:bg-neutral-800":"border-neutral-200 hover:bg-neutral-50 dark:hover:border-neutral-800 shadow-sm dark:border-neutral-800","active:bg-beige-300 flex w-full cursor-pointer items-center gap-3 rounded-xl border px-3 py-2 transition active:dark:bg-neutral-900",b?.groupItem),onClick:P=>{P.target instanceof HTMLButtonElement||a(c.id)},children:[J(qt,{checked:c.isOn,className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-700",onCheckedChange:()=>{a(c.id)}}),ut("div",{className:"flex flex-col items-start justify-start",children:[J("p",{className:"font-medium text-sm",children:c.name}),c.description&&J("p",{className:"text-xs font-light",children:c.description})]}),J("div",{className:"grow"}),c.howOften&&J(ar,{regularity:c.howOften})]},c.id)),ut("div",{className:"flex gap-2",children:[e===!0&&ut(Sn,{children:[ut("div",{ref:g,className:"flex flex-col items-start justify-start",children:[n&&ut(G,{variant:"default",size:"sm",className:"relative",disabled:s,onClick:i,children:[d?.groupsUpdateButton??_.groupsUpdateButton,s&&J("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:J(Z,{})})]}),x&&ut("p",{className:"mt-3 flex items-center gap-2 text-sm text-green-500",children:[J(Cn,{color:"var(--color-green-500",size:16})," ",d?.groupsUpdateSuccess??_.groupsUpdateSuccess]})]}),J("div",{className:"grow"})]}),m&&J("div",{className:"flex justify-start",children:J(G,{className:"cursor-pointer dark:bg-neutral-700",onClick:o,size:"sm",variant:"secondary",type:"button",children:d?.groupsSelectAllButton??_.groupsSelectAllButton})})]}),h&&ut("div",{className:"flex text-left gap-2 text-xs text-yellow-500",children:[J(Pn,{color:"orange",size:16}),d?.groupsNoSelectionWarning??_.groupsNoSelectionWarning]})]});return e==!0?ut(Ot,{className:"mt-5 text-left",children:[J(Bt,{children:J(Ct,{children:d?.groupsTitle??_.groupsTitle})}),J(Gt,{children:l})]}):l}import{jsx as St,jsxs as ae}from"react/jsx-runtime";function or({showQRCode:t=!0,isManaging:e,className:a,texts:o}){let i=typeof window<"u",s=i?!!window.matchMedia?.("(prefers-color-scheme: dark)").matches:!1;function n(x){return x?window.location.href:""}return t?ae(Ot,{className:r("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",a?.qrCodeSection),children:[St(Bt,{children:ae(Ct,{className:r("mb-3 text-base font-medium lg:text-lg",a?.qrCodeTitle),children:[o?.qrCodeSubtitle??_.qrCodeSubtitle," "+(o?.qrCodeTitle??_.qrCodeTitle)]})}),ae(Gt,{className:"flex flex-col items-center gap-2",children:[ae("div",{className:"mt-1.5 mb-3 flex items-center gap-x-2",children:[St("a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",target:"_blank",className:"max-w-28 flex-1 basis-1/2 lg:max-w-36",children:St("img",{className:"h-auto w-full",src:Mt+"/app-store-logo.png",alt:"Download on App Store"})}),St("a",{href:"https://play.google.com/store/apps/details?id=com.bitsnap.Bitsnap&pli=1",target:"_blank",className:"max-w-28 flex-1 basis-1/2 lg:max-w-36",children:St("img",{className:"h-auto w-full",src:Mt+"/google-play-logo.png",alt:"Get in on Google Play"})})]}),i&&St("div",{className:"flex items-center justify-center",children:ae("div",{className:r("flex min-w-[40%] flex-col items-center gap-2 rounded-xl bg-white p-2 dark:bg-neutral-900",a?.qrCodeContainer),children:[St("img",{className:"mt-3 w-[80%] p-1 pt-3",src:Mt+`/api/qr-gen?url=${n(i)}&bgColor=${s?"171717":"F6F4F0"}&textColor=${s?"ffffff":"000000"}&margin=0`}),St("p",{className:"text-xs md:text-sm",children:o?.qrCodeScanText??_.qrCodeScanText})]})})]})]}):null}import{useState as re}from"react";import{isValidPhoneNumber as zn}from"react-phone-number-input";import{useAutoAnimate as Nn}from"@formkit/auto-animate/react";import{Label as nr}from"@radix-ui/react-label";import{CheckCircleIcon as Tn,CircleAlertIcon as En,TriangleAlertIcon as In}from"lucide-react";import{useState as We}from"react";import{jsx as nt,jsxs as wt}from"react/jsx-runtime";function ir({submit:t,isLoading:e,errMsg:a,emailLack:o,warnMsg:i,isSubmited:s,agreementLack:n,showPhoneInput:x=!1,agreementText:b,className:d,texts:k}){let[g,h]=We(""),[m,l]=We(""),[c,P]=We(!1),[C]=Nn();function N(y){y.preventDefault(),t(g,m,c)}return wt("form",{ref:C,onSubmit:N,className:r("flex flex-col gap-3 text-left",d?.formContainer),children:[wt("div",{className:"flex flex-col gap-1 text-left",children:[nt(nr,{className:"text-sm",htmlFor:"bts-notifications-form-email",children:k?.formEmailLabel??_.formEmailLabel}),nt($t,{value:g,onChange:y=>{h(y.currentTarget.value)},id:"bts-notifications-form-email",className:r(o===!0?"border-red-400":""),type:"email",placeholder:k?.formEmailPlaceholder??_.formEmailPlaceholder})]}),x&&wt("div",{className:"flex flex-col gap-1 text-left",children:[wt(nr,{className:"text-sm",htmlFor:"bts-notifications-form-phone",children:[k?.formPhoneLabel??_.formPhoneLabel," ",nt("span",{className:"text-neutral-500 dark:text-neutral-500",children:k?.formPhoneOptional??_.formPhoneOptional})]}),nt($t,{value:m,onChange:y=>{l(y.currentTarget.value)},id:"bts-notifications-form-phone",className:"",type:"tel",autoComplete:"tel",autoCorrect:"off",placeholder:k?.formPhonePlaceholder??_.formPhonePlaceholder})]}),wt("div",{className:"flex items-start gap-x-1.5",children:[nt("input",{className:"cursor-pointer",id:"bts-notifications-form-marketing-consent",type:"checkbox",checked:c,onChange:()=>{P(!c)}}),nt("label",{htmlFor:"bts-notifications-form-marketing-consent",className:r("cursor-pointer text-xs leading-4 transition-colors md:text-sm md:leading-4",n===!0?"text-yellow-700":""),children:b})]}),a.length>0&&wt("p",{className:"mb-3 flex items-center gap-1 text-sm text-red-400",children:[nt(In,{color:"#ff6467",size:16})," ",a]}),i.length>0&&wt("p",{className:"mb-3 flex items-center gap-1 text-sm text-amber-400",children:[nt(En,{color:"var(--color-amber-400)",size:16})," ",i]}),s==!1&&nt("div",{className:"flex justify-start",children:wt(G,{variant:"default",disabled:e,className:r(e?"cursor-not-allowed text-transparent":"","relative"),children:[k?.formSubmitButton??_.formSubmitButton,e&&nt("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:nt(Z,{})})]})}),s&&wt("div",{className:"flex items-center gap-3 text-sm text-green-400",children:[nt(Tn,{size:16})," ",k?.formSuccessMessage??_.formSuccessMessage]})]})}import{jsx as Ve,jsxs as Rn}from"react/jsx-runtime";var An=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;function sr({groups:t,onToggle:e,onCheckAll:a,slug:o,showPhoneInput:i=!1,agreementText:s,className:n,texts:x,isUpdating:b,wasChanged:d,onSuccess:k}){let[g,h]=re(""),[m,l]=re(""),[c,P]=re(!1),[C,N]=re(!1),[y,R]=re(!1),{mutateAsync:I,isPending:T}=gt(it.notifications.createNotificationUser);function S(A){return A==null?!1:zn(A,"PL")}async function f(A,E,O){if(h(""),l(""),R(!1),P(!1),N(!1),!O){N(!0),h("Zgoda w tym przypadku jest wymagana.");return}if(An.test(A)===!1){h("Email jest nieprawid\u0142owy."),R(!0);return}E.length>0&&S(E)===!1&&l("Numer telefonu mo\u017Ce by\u0107 nieprawid\u0142owy. Zapisali\u015Bmy go ale je\u015Bli jest nieprawid\u0142owy to wpisz jeszcze raz i kliknij przycisk.");try{let p=await I({slug:o,email:A,phone:E,groups:t.filter(w=>w.isOn==!0).map(w=>w.id),mobileNotificationEnabled:!0,emailNotificationEnabled:!0,smsNotificationEnabled:!0});if(p.result.case==="success"){P(!0),setTimeout(()=>{k?.(!1,p.userId,p.accessToken)},1e3);return}else{P(!0);let w=p.result.value;if(w!=null){if(w==32){k?.(!0,void 0,void 0);return}console.log(`Code error: ${ze[w]}`),h("Wyst\u0105pi\u0142 b\u0142\u0105d: "+ze[w]);return}return}}catch(p){h("Wyst\u0105pi\u0142 b\u0142\u0105d podczas zapisywania. Spr\xF3buj ponownie."),console.log(`Error: ${p}`)}}let v=x?.formTitle??_.formTitle;return Rn("div",{className:r("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",n?.formSection),children:[v.length>0&&Ve("h3",{className:r("mb-3 text-base font-medium lg:text-lg",n?.formTitle),children:v}),Ve(Ce,{groups:t,isManaging:!1,onToggle:e??(()=>{}),onCheckAll:a??(()=>{}),isUpdating:b??!1,wasChanged:d??!1,isUserGroupsUpdated:!1,className:n,texts:x}),Ve(ir,{errMsg:g,emailLack:y,warnMsg:m,submit:f,isLoading:T,isSubmited:c,agreementLack:C,showPhoneInput:i,agreementText:s??x?.agreementText??_.agreementText,className:n,texts:x})]})}import{useEffect as Mn,useState as oe}from"react";import{Label as Ke}from"@radix-ui/react-label";import{MessageCircleWarningIcon as On}from"lucide-react";import{useDebouncedCallback as Bn}from"use-debounce";import{TriangleAlertIcon as Dn,XIcon as _n}from"lucide-react";import{createPortal as Ln}from"react-dom";import{useEffect as cr,useState as Un}from"react";import{jsx as ct,jsxs as Wt}from"react/jsx-runtime";function lr({open:t,onOpenChange:e,onConfirm:a,isDeleting:o=!1}){let[i,s]=Un(!1);if(cr(()=>(s(!0),()=>s(!1)),[]),cr(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t]),!i||!t)return null;let n=b=>{b.target===b.currentTarget&&e(!1)},x=()=>{a()};return Ln(ct("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/50 p-4",onClick:n,children:Wt("div",{className:r("relative w-full max-w-md rounded-2xl bg-white p-6 shadow-lg","dark:bg-neutral-800","animate-in fade-in-0 zoom-in-95 duration-200"),onClick:b=>b.stopPropagation(),children:[Wt("button",{onClick:()=>e(!1),className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-neutral-950 focus:ring-offset-2 disabled:pointer-events-none dark:ring-offset-neutral-950 dark:focus:ring-neutral-300",disabled:o,children:[ct(_n,{className:"h-4 w-4"}),ct("span",{className:"sr-only",children:"Zamknij"})]}),Wt("div",{className:"flex flex-col gap-4",children:[Wt("div",{className:"flex items-start gap-3",children:[ct("div",{className:"flex-shrink-0",children:ct(Dn,{className:"h-6 w-6 text-amber-500","aria-hidden":"true"})}),ct("div",{className:"flex-1",children:ct("h2",{className:"text-lg font-semibold text-black dark:text-neutral-100",children:"Czy na pewno chcesz si\u0119 wypisa\u0107?"})})]}),ct("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Klikni\u0119cie tego przycisku spowoduje wypisanie z wszelkich powiadomie\u0144 i grup, kt\xF3re zapisa\u0142e\u015B."}),Wt("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[ct(G,{type:"button",variant:"ghost",onClick:()=>e(!1),disabled:o,className:"sm:min-w-[100px]",children:"Anuluj"}),Wt(G,{type:"button",variant:"destructive",onClick:x,disabled:o,className:r(o&&"cursor-not-allowed text-transparent","relative sm:min-w-[100px]"),children:["Usu\u0144",o&&ct("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:ct("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"})})]})]})]})]})}),document.body)}import{useAutoAnimate as pr}from"@formkit/auto-animate/react";import{Fragment as Gn,jsx as q,jsxs as lt}from"react/jsx-runtime";function dr({accessToken:t,slug:e,userID:a,className:o,texts:i}){let[s]=pr(),[n]=pr(),{mutateAsync:x,isPending:b}=gt(it.notifications.deleteNotificationUser),{mutateAsync:d,isPending:k}=gt(it.notifications.updateNotificationUser),{data:g,isFetching:h}=pe(it.notifications.getNotificationUserSettings,{userId:a,slug:e,accessToken:t}),[m,l]=oe(!1),[c,P]=oe(!1),[C,N]=oe(!1),[y,R]=oe(!1),[I,T]=oe(!1),S=g?.result.case==="success"?g?.result?.value:void 0;function f(){T(!0)}async function v(){await x({accessToken:t,slug:e,userId:a}),T(!1)}async function A(){await d({accessToken:t,slug:e,notificationUserId:a,mobileNotificationEnabled:y,emailNotificationEnabled:m,smsNotificationEnabled:c}),N(!0),setTimeout(()=>{N(!1)},3e3)}let E=Bn(p=>{A()},300);Mn(()=>{let p=g?.result.case==="success"?g?.result?.value:void 0;l(p?.emailNotificationEnabled??!1),P(p?.smsNotificationEnabled??!1),R(p?.mobileNotificationEnabled??!1)},[g]);function O(p,w){p==="email"&&l(w),p==="phone"&&P(w),p==="push"&&R(w),E(!0)}return lt("div",{className:r("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",o?.manageDataSection),children:[q("div",{className:"flex justify-start",children:q("h3",{className:r("mb-3 text-base font-medium lg:text-lg",o?.manageDataTitle),children:i?.manageDataTitle??_.manageDataTitle})}),h?q(va,{className:"h-64 w-full"}):lt(Ot,{ref:n,className:r(k&&"relative"),children:[q(Bt,{children:q(Ct,{children:q("p",{className:"text-sm text-left",children:i?.manageDataDescription??_.manageDataDescription})})}),lt(Gt,{ref:s,children:[q("div",{className:r(k&&"opacity-50 pointer-events-none","flex flex-col gap-2"),children:lt("div",{className:"flex flex-col items-start gap-5 gap-x-2",children:[S?.emailNotificationAvailable&<("div",{className:"flex items-center gap-3",children:[q(qt,{id:"email-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:m,onCheckedChange:()=>{O("email",!m)}}),q(Ke,{htmlFor:"email-enabled",className:"text-sm",children:"Email"})]}),S?.smsNotificationAvailable&<("div",{className:"flex items-center gap-3",children:[q(qt,{id:"sms-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:c,onCheckedChange:()=>{O("phone",!c)}}),q(Ke,{htmlFor:"sms-enabled",className:"text-sm",children:"SMS"})]}),S?.mobileNotificationAvailable&<(Gn,{children:[lt("div",{className:"flex items-center gap-3",children:[q(qt,{id:"push-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:y,onCheckedChange:()=>{O("push",!y)}}),q(Ke,{htmlFor:"push-enabled",className:"text-sm",children:"Powiadomienia na telefon"})]}),S?.hasUserInstalledApp===!1&<("div",{className:"flex items-center gap-3",children:[q(On,{color:"var(--color-amber-500)",size:26}),q("p",{className:"text-xs text-amber-500",children:"Wygl\u0105da na to, \u017Ce nie masz zainstalowanej aplikacji mobilnej. Zainstaluj i wyra\u017A zgod\u0119 na otrzymywanie powiadomie\u0144 na telefon."})]})]})]})}),lt("div",{className:"mt-5 flex flex-col gap-2 text-left",children:[q("hr",{}),C&&q("p",{className:"text-xs text-green-500",children:i?.manageDataUpdatedMessage??_.manageDataUpdatedMessage}),q("div",{className:"flex items-center gap-x-2",children:lt(G,{size:"sm",variant:"link",className:r("pl-0 ml-0",b&&"cursor-not-allowed"),onClick:f,children:[i?.manageDataUnsubscribeButton??_.manageDataUnsubscribeButton,b&&q("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:q(Z,{})})]})})]})]}),k&&q("div",{className:"bg-black/30 absolute inset-0 rounded-xl",children:q("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:q(Z,{})})})]}),q(lr,{open:I,onOpenChange:T,onConfirm:v,isDeleting:b})]})}import{useState as Pe}from"react";import{ArrowLeft as Hn}from"lucide-react";import{useAutoAnimate as mr}from"@formkit/auto-animate/react";import*as at from"@radix-ui/react-dialog";import{XIcon as qn}from"lucide-react";import{jsx as Vt,jsxs as Qe}from"react/jsx-runtime";function ur({...t}){return Vt(at.Root,{"data-slot":"dialog",...t})}function jn({...t}){return Vt(at.Portal,{"data-slot":"dialog-portal",...t})}function Fn({className:t,...e}){return Vt(at.Overlay,{"data-slot":"dialog-overlay",className:r("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...e})}function br({className:t,children:e,showCloseButton:a=!0,...o}){return Qe(jn,{"data-slot":"dialog-portal",children:[Vt(Fn,{}),Qe(at.Content,{"data-slot":"dialog-content",className:r("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...o,children:[e,a&&Qe(at.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[Vt(qn,{}),Vt("span",{className:"sr-only",children:"Close"})]})]})]})}import{Fragment as Wn,jsx as M,jsxs as bt}from"react/jsx-runtime";function gr({slug:t,onSuccess:e,onError:a,className:o,isOpen:i,onClose:s,texts:n}){let[x]=mr(),[b]=mr(),[d,k]=Pe(""),[g,h]=Pe(""),[m,l]=Pe(!1),[c,P]=Pe(null),{mutateAsync:C,isPending:N}=gt(it.notifications.verifyUserEmail),y=async S=>{if(S.preventDefault(),P(null),!d||!d.includes("@")){P(n.loginInvalidEmailError??"");return}try{await C({email:d,slug:t}),l(!0)}catch(f){let v=f instanceof Error?f:new Error(n.loginSendEmailError);P(v.message),a?.(v)}},R=async S=>{if(h(S),P(null),S.length===6)try{let f=await C({email:void 0,code:S,slug:t});f.ok&&f.accessToken?e?.(f.userId,f.accessToken):(P(n.loginVerificationFailedError??""),a?.(new Error(n.loginVerificationFailedError)))}catch(f){let v=f instanceof Error?f:new Error(n.loginVerifyCodeError);if(v.message.includes("Invalid code")){P(n.loginInvalidCodeError??v.message),h("");return}P(v.message),a?.(v),h("")}},I=async()=>{if(h(""),P(null),!d||!t){P(n.loginSlugRequiredError??"");return}try{await C({email:d,slug:t})}catch(S){let f=S instanceof Error?S:new Error(n.loginResendEmailError);P(f.message),a?.(f)}},T=()=>{l(!1),h(""),P(null)};return M(ur,{open:i,onOpenChange:s,children:M(br,{className:"sm:max-w-[425px] min-h-[250px]",children:bt("div",{className:"flex flex-col min-h-[250px] h-full",children:[bt("div",{ref:b,className:"flex items-start gap-2 mb-2",children:[m&&M(G,{variant:"ghost",size:"icon-sm",onClick:()=>{l(!1)},children:M(Hn,{className:"h-5 w-5"})}),M("div",{children:M(Ct,{children:m?n.loginCodeLabel??"":n.loginTitle??""})})]}),M(ga,{className:"mb-4",children:m?bt(Wn,{children:[n.loginCodeSentMessage??""," ",d]}):n.loginDescription??""}),M("div",{className:"flex-1 flex flex-col",children:m?bt("form",{onSubmit:S=>S.preventDefault(),className:"flex flex-col flex-1",children:[bt("div",{className:"space-y-2",children:[M(Re,{children:n.loginCodeLabel??""}),M(ha,{maxLength:6,value:g,onChange:R,disabled:N,children:bt(fa,{children:[M(Et,{index:0}),M(Et,{index:1}),M(Et,{index:2}),M(Et,{index:3}),M(Et,{index:4}),M(Et,{index:5})]})}),N&&M(Z,{})]}),c&&M("div",{className:"text-sm text-destructive mt-2 mb-1",role:"alert",children:c}),M("div",{className:"grow"}),bt("div",{className:"flex flex-col items-start gap-2 pt-2",children:[d.length>0&&M(G,{variant:"link",size:"sm",onClick:I,disabled:N,className:"flex-1 ml-0 pl-0",children:n.loginResendCodeButton??""}),M(G,{variant:"link",size:"sm",onClick:T,disabled:N,className:"flex-1 ml-0 pl-0",children:n.loginChangeEmailButton??""})]})]}):bt("form",{onSubmit:y,className:"flex flex-col flex-1",children:[bt("div",{className:"space-y-2",children:[M(Re,{htmlFor:"email",children:n.loginEmailLabel??""}),M($t,{id:"email",type:"email",placeholder:n.loginEmailPlaceholder??"",value:d,onChange:S=>k(S.target.value),required:!0,disabled:N,"aria-invalid":c?"true":"false"})]}),c&&M("div",{className:"text-sm text-destructive mt-2 mb-1",role:"alert",children:c}),M("div",{className:"grow"}),bt("div",{className:"flex flex-col items-start gap-0 pt-2",children:[M(G,{type:"submit",size:"sm",disabled:N,children:N?n.loginSendingButton??"":n.loginSendCodeButton??""}),M(G,{type:"button",variant:"link",className:"ml-0 pl-0",size:"sm",onClick:()=>{l(!0)},children:n.loginIHaveCode??""})]})]})})]})})})}import{useAutoAnimate as Xn}from"@formkit/auto-animate/react";import{jsx as X,jsxs as $e}from"react/jsx-runtime";function Zn(t,e){switch(e.type){case"SET_IS_LOGGED_IN":return{...t,isLoggedIn:e.value};case"SET_USER_ID":return{...t,userID:e.value};case"SET_LOADING":return{...t,isLoading:e.value};case"SET_PUBLIC_GROUPS":return{...t,groupsProvided:e.value,groups:e.value!=null&&e.value.length>0?t.groups.filter(a=>e.value?.find(o=>o.id===a.id)!=null):t.groups};case"SET_GROUPS":{let a=t.isLoggedIn==!1||t.groupsProvided!=null,o=e.value.map(i=>t.isLoggedIn==!0?i:{...i,isOn:t.groupsProvided?.find(s=>s.id===i.id)?.isOn??a});return{...t,groups:o}}case"TOGGLE_GROUP":{let a=t.groups.map(o=>o.id===e.groupID?{...o,isOn:!o.isOn}:o);return{...t,wasChanged:!0,groups:a}}case"CHECK_ALL_GROUPS":{let a=t.groups.map(o=>({...o,isOn:!0}));return{...t,groups:a,wasChanged:!0}}case"SET_WAS_CHANGED":return{...t,wasChanged:e.value};case"SET_IS_USER_GROUPS_UPDATED":return{...t,isUserGroupsUpdated:e.value};case"RESET_UPDATE_STATE":return{...t,wasChanged:!1,isUserGroupsUpdated:!0};case"SHOW_SETTINGS":return{...t,showSettings:!0};case"HIDE_SETTINGS":return{...t,showSettings:!1};default:return t}}function Yn({slug:t,userID:e,productID:a,projectID:o,analytics:i,projectName:s,projectLogo:n,projectLogoDark:x,groups:b,isManaging:d=!1,texts:k,showQRCode:g=!1,showPhoneInput:h=!1,hiddenGroupIds:m=[],className:l}){let[c]=Xn(),P=kt(o??Ht(),i),C=t??ot()??(typeof window<"u"?window.location.hostname:""),{mutateAsync:N,isPending:y}=gt(it.notifications.updateUserGroups),{data:R,refetch:I}=Qn({queryKey:["notifications_accessToken"],queryFn:()=>{if(typeof window<"u")return{accessToken:localStorage.getItem("notifications_accessToken")??void 0,userID:localStorage.getItem("notifications_userID")??void 0}}}),{data:T,isPending:S,refetch:f}=pe(it.notifications.getUserGroups,{slug:C,accessToken:R?.accessToken}),[v,A]=Vn(Zn,{isLoading:S,isUserGroupsUpdated:!1,wasChanged:!1,groupsProvided:b,groups:[],showSettings:R!=null&&d==!0,isLoggedIn:R!=null,userID:void 0});ne(()=>{A({type:"SET_LOADING",value:y||S})},[y,S]),ne(()=>{A({type:"SET_IS_LOGGED_IN",value:R?.accessToken!=null}),A({type:"SET_USER_ID",value:R?.userID}),R?.accessToken!=null&&d==!0&&A({type:"SHOW_SETTINGS"})},[R,d]),ne(()=>{if(T==null)return;let F=T.groups.map(V=>{let rt="rarely";switch(V.howOften){case 0:rt="rarely";break;case 1:rt="often";break;case 2:rt="veryOften";break}return{id:V.id,name:V.name,description:V.description,howOften:rt,isOn:V.isOn??void 0}});A({type:"SET_GROUPS",value:F})},[T,S,b]);let E=Kn(null);ne(()=>{let F=b?.map(V=>(V.id.startsWith("group_")||(V.id=`group_${V.id}`),V));A({type:"SET_PUBLIC_GROUPS",value:F})},[b]);let O={..._,...k};async function p(){await N({accessToken:R?.accessToken,slug:C,userId:e,groupIds:v.groups.filter(F=>F.isOn===!0).map(F=>F.id)}),A({type:"RESET_UPDATE_STATE"}),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{A({type:"SET_IS_USER_GROUPS_UPDATED",value:!1})},2e3)}function w(F){A({type:"TOGGLE_GROUP",groupID:F})}function mt(){A({type:"CHECK_ALL_GROUPS"})}function ie(){A({type:"SHOW_SETTINGS"})}function Se(){A({type:"HIDE_SETTINGS"})}function se(){localStorage.removeItem("notifications_accessToken"),localStorage.removeItem("notifications_userID"),I(),A({type:"SET_USER_ID",value:void 0}),A({type:"SET_IS_LOGGED_IN",value:!1}),A({type:"HIDE_SETTINGS"})}async function Nt(F,V){typeof window<"u"&&(localStorage.setItem("notifications_accessToken",V),F!=null&&localStorage.setItem("notifications_userID",F)),A({type:"SET_USER_ID",value:F});try{await I(),f().then().catch().finally(()=>{d==!0&&A({type:"SHOW_SETTINGS"})})}catch(rt){console.log(`Error: ${rt}`)}}ne(()=>()=>{E.current&&clearTimeout(E.current)},[]);let pt=d==!0&&v.userID!=null&&R?.accessToken!=null;return $e("main",{className:r("bitsnap-react relative",l?.container),children:[O.title!=null&&X("h1",{className:"text-2xl font-semibold text-black md:text-3xl lg:text-4xl xl:text-5xl dark:text-neutral-100",children:O.title}),!v.showSettings&&d&&X(G,{onClick:ie,variant:"outline",size:"icon",className:"absolute bottom-6 right-6 z-50 h-12 w-12 rounded-full shadow-lg hover:shadow-xl md:bottom-8 md:right-8","aria-label":"Settings",children:X($n,{className:"h-5 w-5"})}),X("div",{className:r("md:pt8 relative z-0 mt-6 overflow-hidden rounded-2xl bg-white px-3 pt-6 pb-3 md:px-5 md:pb-5 dark:bg-neutral-800",l?.header),children:v.showSettings?X("div",{className:"space-y-6",children:v.isLoggedIn&&$e("div",{className:r("grid grid-cols-1 gap-3 lg:gap-6",pt?"md:grid-cols-2":""),children:[$e("div",{className:l?.groupsContainer,children:[X(Ya,{projectName:s,projectLogo:n,projectLogoDark:x,description:O.managingDescription,className:l,onLogout:se}),S&&X("div",{className:"flex justify-center items-center py-8",children:X(Z,{})}),X(Ce,{groups:v.groups,hiddenGroupIds:m,isManaging:d,onToggle:w,onCheckAll:mt,onUpdate:p,isUpdating:y,wasChanged:v.wasChanged,isUserGroupsUpdated:v.isUserGroupsUpdated,className:l,texts:O})]}),pt&&X(dr,{accessToken:R.accessToken??"",slug:C,userID:v.userID??"",className:l,texts:O}),g!=!1&&X(or,{showQRCode:g,isManaging:!0,className:l,texts:O})]})}):X("div",{className:r("grid grid-cols-1 gap-3 lg:gap-6"),children:X(sr,{slug:C,onToggle:F=>{A({type:"TOGGLE_GROUP",groupID:F})},onCheckAll:()=>{A({type:"CHECK_ALL_GROUPS"})},onSuccess:(F,V,rt)=>{P.track("availability_signup",{},{product_id:a??null}),rt!=null&&Nt(V,rt),F&&A({type:"SHOW_SETTINGS"})},groups:v.groups,showPhoneInput:h,agreementText:O.agreementText,className:l,texts:O,wasChanged:v.wasChanged,isUpdating:y})})}),X(gr,{isOpen:v.showSettings&&!v.isLoggedIn,slug:C,onSuccess:Nt,texts:O,onClose:Se})]})}function Jn({slug:t,userID:e,productID:a,projectID:o,analytics:i,projectName:s,projectLogo:n,projectLogoDark:x,groups:b,isManaging:d,texts:k,showQRCode:g,showPhoneInput:h,hiddenGroupIds:m,className:l}){return X(Ae,{children:X(Yn,{slug:t,userID:e,productID:a,projectID:o,analytics:i,projectName:s,projectLogo:n,projectLogoDark:x,groups:b,isManaging:d,texts:k,showQRCode:g,showPhoneInput:h,hiddenGroupIds:m,className:l})})}var ti=Jn;export{Oe as ApplePayButton,ei as Bitsnap,dn as BitsnapCheckout,go as BitsnapReturns,Xr as BitsnapReturnsProvider,yo as CHECKOUT_SLOT_NAMES,Er as Environment,Fe as GooglePayButton,mo as ITEM_IDS_NOT_FOUND,ti as NotificationsComponent,si as PRODUCT_LIST_SLOT_NAMES,bo as Panel,Fr as PanelLogin,Mr as PanelProvider,pi as ProductList,uo as PublicOrderPage,Hr as RETURNS_SLOT_NAMES,Wr as ReturnsAppearanceProvider,oo as ReturnsCodeStep,so as ReturnsConfirmation,ro as ReturnsEmailStep,po as ReturnsMyReturnDetail,lo as ReturnsMyReturnsList,io as ReturnsOrderDetail,no as ReturnsOrderList,$r as ReturnsProvider,co as ReturnsResult,jr as buildAccessTokenRedirect,oi as createCheckout,ri as createPaymentURL,ci as formatProductPrice,Ur as getAllowedReturnOrigins,Xt as getLocale,zr as getPanelConfig,ai as getPaymentMethodChoice,ni as getReferenceIfPossible,Br as getReturnURLFromSearch,ii as injectReferenceToRequestIfNeeded,Gr as persistReturnURL,qr as readPersistedReturnURL,Lr as setAllowedReturnOrigins,Tr as setCustomHost,_r as setHost,De as setLocale,Dr as setLoginURL,Ir as setPanelConfig,Ar as setPanelProjectID,Ue as setProjectID,Rr as setTheme,to as useCreateReturn,ao as useMyReturn,eo as useMyReturns,Or as usePanelConfig,li as useProducts,Yr as useReturnOrders,Zr as useReturnSession,Jr as useReturnableOrder,Vr as useReturnsAppearance,Kr as useReturnsSlot,Qr as useReturnsText};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|