bitsnap-react 1.16.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +5 -0
- package/README.md +87 -0
- package/dist/CartProvider-ECQQH3PS.css +2 -0
- package/dist/CartProvider-ECQQH3PS.css.map +1 -0
- package/dist/CartProvider-OEI526IN.js +2 -0
- package/dist/{CartProvider-VGZMDVFJ.js.map → CartProvider-OEI526IN.js.map} +1 -1
- package/dist/CartProvider-RYAA3JDA.mjs +2 -0
- package/dist/{PanelModelFiles-NYCOFPLY.js → PanelModelFiles-7HPXWONN.js} +2 -2
- package/dist/{PanelModelFiles-NYCOFPLY.js.map → PanelModelFiles-7HPXWONN.js.map} +1 -1
- package/dist/PanelModelFiles-JZFSF7BF.mjs +2 -0
- package/dist/PanelModelFiles-JZFSF7BF.mjs.map +1 -0
- package/dist/analytics.d.mts +2 -2
- package/dist/analytics.d.ts +2 -2
- package/dist/analytics.js +1 -1
- package/dist/analytics.mjs +1 -1
- package/dist/catalog.css +1 -1
- package/dist/catalog.css.map +1 -1
- package/dist/catalog.d.mts +3 -1
- package/dist/catalog.d.ts +3 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/{chunk-GXUNRJ5S.js → chunk-4HGZZJEL.js} +2 -2
- package/dist/{chunk-GXUNRJ5S.js.map → chunk-4HGZZJEL.js.map} +1 -1
- package/dist/chunk-4OVOKGGS.mjs +2 -0
- package/dist/chunk-4OVOKGGS.mjs.map +1 -0
- package/dist/chunk-5X7TP3TQ.mjs +2 -0
- package/dist/{chunk-SULHGFYN.mjs.map → chunk-5X7TP3TQ.mjs.map} +1 -1
- package/dist/{chunk-QQQ2JSPQ.mjs → chunk-CF45RDMD.mjs} +2 -2
- package/dist/{chunk-QQQ2JSPQ.mjs.map → chunk-CF45RDMD.mjs.map} +1 -1
- package/dist/{chunk-GQJDFLSL.js → chunk-DP2NOHCI.js} +2 -2
- package/dist/{chunk-GQJDFLSL.js.map → chunk-DP2NOHCI.js.map} +1 -1
- package/dist/chunk-EVIDNS22.mjs +2 -0
- package/dist/chunk-EVIDNS22.mjs.map +1 -0
- package/dist/chunk-G4V2KWTV.js +2 -0
- package/dist/chunk-G4V2KWTV.js.map +1 -0
- package/dist/{chunk-SXKJ26OA.mjs → chunk-GEBRXFT3.mjs} +2 -2
- package/dist/chunk-GWF3MRUP.js +2 -0
- package/dist/chunk-GWF3MRUP.js.map +1 -0
- package/dist/chunk-JA62KNAQ.js +2 -0
- package/dist/chunk-JA62KNAQ.js.map +1 -0
- package/dist/chunk-JHJ3ZZF4.mjs +2 -0
- package/dist/chunk-JHJ3ZZF4.mjs.map +1 -0
- package/dist/{chunk-WKE6ECID.mjs → chunk-UPAOIY4R.mjs} +2 -2
- package/dist/chunk-V5ECGBFW.js +5 -0
- package/dist/chunk-V5ECGBFW.js.map +1 -0
- package/dist/{chunk-SRQOFCMO.js → chunk-VNV5BD4X.js} +2 -2
- package/dist/{chunk-SRQOFCMO.js.map → chunk-VNV5BD4X.js.map} +1 -1
- package/dist/chunk-WJO5GSY3.mjs +5 -0
- package/dist/chunk-WJO5GSY3.mjs.map +1 -0
- package/dist/chunk-ZATPBYOA.js +2 -0
- package/dist/chunk-ZATPBYOA.js.map +1 -0
- package/dist/chunk-ZHTMK5TA.mjs +2 -0
- package/dist/chunk-ZHTMK5TA.mjs.map +1 -0
- package/dist/course.d.mts +13 -3
- package/dist/course.d.ts +13 -3
- package/dist/course.js +1 -1
- package/dist/course.js.map +1 -1
- package/dist/course.mjs +1 -1
- package/dist/course.mjs.map +1 -1
- package/dist/embed/analytics.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +41 -12
- package/dist/index.d.ts +41 -12
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/{instrument-BE8ktMUv.d.mts → instrument-eXaC8hc2.d.mts} +1 -1
- package/dist/{instrument-BE8ktMUv.d.ts → instrument-eXaC8hc2.d.ts} +1 -1
- package/dist/methods-AULQDKVS.mjs +2 -0
- package/dist/methods-OJEZREBK.css +2 -0
- package/dist/methods-OJEZREBK.css.map +1 -0
- package/dist/methods-PMH5VQ25.js +2 -0
- package/dist/{methods-WRONKK3D.js.map → methods-PMH5VQ25.js.map} +1 -1
- package/dist/returns.d.mts +19 -10
- package/dist/returns.d.ts +19 -10
- package/dist/returns.js +1 -1
- package/dist/returns.js.map +1 -1
- package/dist/returns.mjs +1 -1
- package/dist/{texts-tQtAGJCT.d.mts → texts-LGhuQfA9.d.mts} +28 -3
- package/dist/{texts-CIEFbJTN.d.ts → texts-m6XQGZ6w.d.ts} +28 -3
- package/dist/types-ClFCVzk_.d.ts +121 -0
- package/dist/types-D6LsoycW.d.mts +121 -0
- package/dist/viewer3d.css +1 -1
- package/dist/viewer3d.css.map +1 -1
- package/dist/viewer3d.mjs +1 -1
- package/package.json +2 -2
- package/dist/CartProvider-PDEV6GCV.css +0 -2
- package/dist/CartProvider-PDEV6GCV.css.map +0 -1
- package/dist/CartProvider-VGZMDVFJ.js +0 -2
- package/dist/CartProvider-ZY5OLTAF.mjs +0 -2
- package/dist/PanelModelFiles-RV7OHUUZ.mjs +0 -2
- package/dist/PanelModelFiles-RV7OHUUZ.mjs.map +0 -1
- package/dist/chunk-5AYH23UJ.mjs +0 -4
- package/dist/chunk-5AYH23UJ.mjs.map +0 -1
- package/dist/chunk-AGYS7Z6G.mjs +0 -2
- package/dist/chunk-AGYS7Z6G.mjs.map +0 -1
- package/dist/chunk-DPKWYLN7.mjs +0 -2
- package/dist/chunk-DPKWYLN7.mjs.map +0 -1
- package/dist/chunk-I3QXJJ7U.mjs +0 -2
- package/dist/chunk-I3QXJJ7U.mjs.map +0 -1
- package/dist/chunk-LL7ASBGY.js +0 -2
- package/dist/chunk-LL7ASBGY.js.map +0 -1
- package/dist/chunk-OZHXRKMX.js +0 -2
- package/dist/chunk-OZHXRKMX.js.map +0 -1
- package/dist/chunk-QERYM7RC.js +0 -2
- package/dist/chunk-QERYM7RC.js.map +0 -1
- package/dist/chunk-QXGK337V.mjs +0 -2
- package/dist/chunk-QXGK337V.mjs.map +0 -1
- package/dist/chunk-SULHGFYN.mjs +0 -2
- package/dist/chunk-WPOXLITY.js +0 -2
- package/dist/chunk-WPOXLITY.js.map +0 -1
- package/dist/chunk-Y5KWVTXT.js +0 -4
- package/dist/chunk-Y5KWVTXT.js.map +0 -1
- package/dist/methods-NJEP64AG.mjs +0 -2
- package/dist/methods-QAZED7TJ.css +0 -2
- package/dist/methods-QAZED7TJ.css.map +0 -1
- package/dist/methods-WRONKK3D.js +0 -2
- package/dist/types-DP1vxo5E.d.mts +0 -53
- package/dist/types-u8VwmC3j.d.ts +0 -53
- /package/dist/{CartProvider-ZY5OLTAF.mjs.map → CartProvider-RYAA3JDA.mjs.map} +0 -0
- /package/dist/{chunk-SXKJ26OA.mjs.map → chunk-GEBRXFT3.mjs.map} +0 -0
- /package/dist/{chunk-WKE6ECID.mjs.map → chunk-UPAOIY4R.mjs.map} +0 -0
- /package/dist/{methods-NJEP64AG.mjs.map → methods-AULQDKVS.mjs.map} +0 -0
package/dist/chunk-DPKWYLN7.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as O,b as at,c as it,d as st,e as dt,f as F}from"./chunk-WKE6ECID.mjs";import{a as et,b as rt}from"./chunk-KOVKUJAW.mjs";import{a as U}from"./chunk-5R6AGO3Z.mjs";import{e as tt}from"./chunk-SXKJ26OA.mjs";import{f as X,l as Z,m as J,n as Y,p as Q}from"./chunk-QQQ2JSPQ.mjs";import{b as ot,d as nt}from"./chunk-VNYHJT6V.mjs";var xt=["root","grid","card","cardLink","image","imagePlaceholder","body","name","description","price","comparePrice","badge","model3dBadge","actions","addToCartButton","selectButton","message","pagination","paginationButton","pageIndicator","emptyState","error","retryButton","skeleton"],ht={fontFamily:"--bitsnap-products-font-family",fontSize:"--bitsnap-products-font-size",background:"--bitsnap-products-background",surface:"--bitsnap-products-surface",foreground:"--bitsnap-products-foreground",mutedForeground:"--bitsnap-products-muted-foreground",border:"--bitsnap-products-border",buttonBackground:"--bitsnap-products-button-background",buttonForeground:"--bitsnap-products-button-foreground",buttonHoverBackground:"--bitsnap-products-button-hover-background",hoverSurface:"--bitsnap-products-hover-surface",focusRing:"--bitsnap-products-focus-ring",error:"--bitsnap-products-error",badgeBackground:"--bitsnap-products-badge-background",badgeForeground:"--bitsnap-products-badge-foreground",radius:"--bitsnap-products-radius"},Tt={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",radius:"8px"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",radius:"8px"}},Ct=[];function ct(t){let e=et(t,{defaultTheme:"light",presets:Tt,variables:ht,shadcnVariables:Ct});return{theme:e.theme,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle}}function j(t,e){return rt(t.elements,e)}import{useCallback as ut,useEffect as St,useMemo as kt,useState as M}from"react";function q(t){let{projectID:e,locale:n,search:o,initialData:i}=t,[a]=M(()=>tt),d=t.host??a,c=O(t.pageSize),s=JSON.stringify([e,d,n??null,o?.trim()??null,c]),[g,l]=M({queryKey:s,page:1});g.queryKey!==s&&l({queryKey:s,page:1});let[P,C]=M(0),[m,p]=M(()=>({requestKey:i!=null?`${s}|1|0`:"",data:i,error:void 0})),f=m.data?.totalCount??0,b=at(f,c),x=g.queryKey===s?g.page:1,k=f>0?Math.min(x,b):x,S=`${s}|${k}|${P}`,T=m.requestKey===S;St(()=>{if(T)return;let y=new AbortController;return it({projectID:e,host:d,locale:n,search:o,limit:c,offset:(k-1)*c},y.signal).then(L=>{y.signal.aborted||p({requestKey:S,data:L,error:void 0})},L=>{y.signal.aborted||p(E=>({requestKey:S,data:E.data,error:L instanceof Error?L:new Error(String(L))}))}),()=>y.abort()},[S,T]);let I=ut(y=>{let L=Math.max(1,Math.floor(y));l({queryKey:s,page:f>0?Math.min(L,b):L})},[s,f,b]),A=ut(()=>C(y=>y+1),[]);return kt(()=>({products:m.data?.items??[],totalCount:f,page:k,pageCount:b,setPage:I,isLoading:!T,error:T?m.error:void 0,refetch:A}),[m,f,k,b,I,T,A])}import{createContext as gt,useCallback as K,useContext as mt,useEffect as B,useMemo as R,useRef as H,useState as It}from"react";var z=50,At=1e3;function lt(t,e=At){let n=new Set,o=new Map,i=[],a=[],d,c,s=!1;function g(){for(c!==void 0&&clearTimeout(c),c=void 0;i.length>0;){let p=i.slice(0,z),f=a.slice(0,z);i=i.slice(z),a=a.slice(z);try{t({productIds:p,positions:f})}catch{}}}function l(){g();try{X()?.flush()}catch{}}let P=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&l()};function C(){s||typeof window>"u"||(s=!0,window.addEventListener("pagehide",l,!0),document.addEventListener("visibilitychange",P,!0))}function m(){if(d)return d;if(!(typeof IntersectionObserver>"u"))return d=new IntersectionObserver(p=>{for(let f of p){let b=o.get(f.target);!b||!f.isIntersecting||f.intersectionRatio<.5||(o.delete(f.target),d?.unobserve(f.target),!n.has(b.id)&&(n.add(b.id),i.push(b.id),a.push(b.position)))}i.length>0&&c===void 0&&(c=setTimeout(g,e),c.unref?.())},{threshold:[.5]}),C(),d}return{observe(p,f,b){try{if(n.has(f))return()=>{};let x=m();return x?(o.set(p,{id:f,position:b}),x.observe(p),()=>{o.delete(p),x.unobserve(p)}):()=>{}}catch{return()=>{}}},flush:g,destroy(){try{g(),d?.disconnect(),s&&(window.removeEventListener("pagehide",l,!0),document.removeEventListener("visibilitychange",P,!0),s=!1)}catch{}d=void 0,o.clear()}}}var wt={en:{addToCart:"Add to cart",addingToCart:"Adding\u2026",addedToCart:"Added to cart",addToCartError:"Could not add to the cart. Try again.",chooseOptions:"Choose",viewProduct:"View",unavailable:"Unavailable",subscription:"Subscription",model3d:"3D",model3dLabel:"3D model",priceFrom:"from {price}",originalPrice:"Original price",loading:"Loading products",empty:"There are no products to show.",error:"Could not load the products.",retry:"Try again",pagination:"Pagination",previousPage:"Previous",nextPage:"Next",pageOf:"Page {page} of {pageCount}"},pl:{addToCart:"Dodaj do koszyka",addingToCart:"Dodawanie\u2026",addedToCart:"Dodano do koszyka",addToCartError:"Nie uda\u0142o si\u0119 doda\u0107 do koszyka. Spr\xF3buj ponownie.",chooseOptions:"Wybierz",viewProduct:"Zobacz",unavailable:"Niedost\u0119pny",subscription:"Subskrypcja",model3d:"3D",model3dLabel:"Model 3D",priceFrom:"od {price}",originalPrice:"Cena przed obni\u017Ck\u0105",loading:"\u0141adowanie produkt\xF3w",empty:"Brak produkt\xF3w do wy\u015Bwietlenia.",error:"Nie uda\u0142o si\u0119 za\u0142adowa\u0107 produkt\xF3w.",retry:"Spr\xF3buj ponownie",pagination:"Paginacja",previousPage:"Poprzednia",nextPage:"Nast\u0119pna",pageOf:"Strona {page} z {pageCount}"}};function pt(t,e){return ot(wt,t,e)}function V(t,e){return t.replace(/\{(\w+)\}/g,(n,o)=>o in e?String(e[o]):n)}import{Fragment as Lt,jsx as r,jsxs as h}from"react/jsx-runtime";var ft=gt(void 0),Et={observe:()=>()=>{},clicked:()=>{}},bt=gt(Et);function D(){let t=mt(ft);if(t==null)throw new Error("ProductList parts must be rendered inside ProductList");return t}function u(t,e){let{appearance:n}=D(),o=j(n,t);return{"data-bitsnap-products-slot":t,className:U(e,o?.className),style:o?.style}}var $="inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50",Pt=`${$} w-full`,_t=`${Pt} no-underline`;function Nt({product:t,onAdd:e}){let{texts:n}=D(),[o,i]=It("idle"),a=u("addToCartButton",Pt),d=u("message","mt-2 text-xs");B(()=>{if(o!=="added")return;let g=setTimeout(()=>i("idle"),2e3);return()=>clearTimeout(g)},[o]);let c=K(async()=>{i("adding");try{await e(),i("added")}catch(g){console.error("bitsnap-react: could not add to the cart",g),i("error")}},[e]),s=o==="adding"?n.addingToCart:o==="added"?n.addedToCart:n.addToCart;return h(Lt,{children:[r("button",{type:"button",...a,disabled:o==="adding","aria-label":`${s}: ${t.name}`,onClick:c,children:s}),o==="error"?r("p",{...d,role:"alert",children:n.addToCartError}):null]})}function Ot({product:t,position:e,href:n,onAdd:o,renderItem:i}){let{texts:a,locale:d}=D(),c=mt(bt),s=H(null);B(()=>{if(s.current!=null)return c.observe(s.current,t.id,e)},[c,t.id,e]);let g=K(()=>c.clicked(t,e),[c,t,e]),l=u("card","relative flex flex-col overflow-hidden border transition-colors"),P=u("cardLink","flex flex-1 flex-col no-underline"),C=u("image","aspect-square w-full overflow-hidden"),m=u("imagePlaceholder","aspect-square w-full"),p=u("body","flex flex-1 flex-col gap-1 p-4"),f=u("name","text-base font-medium leading-snug"),b=u("description","line-clamp-2 text-sm"),x=u("price","mt-auto pt-2 text-base font-semibold"),k=u("comparePrice","ml-2 text-sm font-normal"),S=u("badge","absolute left-3 top-3 px-2 py-0.5 text-xs font-medium"),T=u("model3dBadge","absolute right-3 top-3 inline-flex items-center gap-1 px-2 py-0.5 text-xs font-semibold"),I=u("actions","p-4 pt-0"),A=u("selectButton",_t),y=F(t.price,t.currency,d),L=t.compareAtPrice!=null&&t.compareAtPrice>t.price?F(t.compareAtPrice,t.currency,d):null;if(i!=null)return r("li",{ref:s,...l,"data-unavailable":t.available?void 0:"",children:i(t,{href:n,price:y,compareAtPrice:L,texts:a,locale:d,addToCart:o,trackClick:g})});let E=t.image?.thumbnailUrl??t.image?.url,_=t.available?t.isRecurring?a.subscription:null:a.unavailable;return h("li",{ref:s,...l,"data-unavailable":t.available?void 0:"",children:[h("a",{...P,href:n,onClick:g,children:[E!=null?r("div",{...C,children:r("img",{src:E,alt:"",loading:"lazy",decoding:"async",className:"h-full w-full object-cover"})}):r("div",{...m,"aria-hidden":"true"}),h("div",{...p,children:[r("h3",{...f,children:t.name}),t.shortDescription?r("p",{...b,children:t.shortDescription}):null,h("p",{...x,children:[t.priceFrom?V(a.priceFrom,{price:y}):y,L!=null?h(Lt,{children:[h("span",{className:"sr-only",children:[a.originalPrice,": "]}),r("del",{...k,children:L})]}):null]})]})]}),_!=null?r("span",{...S,"data-kind":t.available?"subscription":"unavailable",children:_}):null,t.has3d===!0?h("span",{...T,title:a.model3dLabel,children:[r(Bt,{}),r("span",{"aria-hidden":"true",children:a.model3d}),r("span",{className:"sr-only",children:a.model3dLabel})]}):null,r("div",{...I,children:t.available?t.addToCart?r(Nt,{product:t,onAdd:o}):r("a",{...A,href:n,onClick:g,children:t.variantCount>1?a.chooseOptions:a.viewProduct}):r("button",{type:"button",...A,disabled:!0,children:a.unavailable})})]})}function Bt(){return h("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),r("path",{d:"m3.3 7 8.7 5 8.7-5"}),r("path",{d:"M12 22V12"})]})}var yt="m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-5 p-0";function Rt({count:t,label:e}){let n=u("grid",yt),o=u("skeleton","aspect-[3/4] animate-pulse");return r("div",{...n,role:"status","aria-busy":"true","aria-label":e,children:Array.from({length:t},(i,a)=>r("div",{...o,"aria-hidden":"true"},a))})}function Dt({page:t,pageCount:e,isLoading:n,onPage:o}){let{texts:i}=D(),a=u("pagination","mt-8 flex items-center justify-center gap-4"),d=u("paginationButton",$),c=u("pageIndicator","text-sm");return h("nav",{...a,"aria-label":i.pagination,children:[r("button",{type:"button",...d,"aria-disabled":n||t<=1,onClick:()=>{!n&&t>1&&o(t-1)},children:i.previousPage}),r("span",{...c,"aria-live":"polite",children:V(i.pageOf,{page:t,pageCount:e})}),r("button",{type:"button",...d,"aria-disabled":n||t>=e,onClick:()=>{!n&&t<e&&o(t+1)},children:i.nextPage})]})}function Ut({options:t,productHref:e,renderItem:n,onAddToCart:o,showCartOnAdd:i}){let{texts:a}=D(),{products:d,page:c,pageCount:s,setPage:g,isLoading:l,error:P,refetch:C}=q(t),m=J(),p=t.search?.trim()?"search":"catalog",f=O(t.pageSize),b=H(!1);B(()=>{b.current||l||P!=null||(b.current=!0,m.track("product_list_viewed",{list_id:p,item_count:d.length}))},[m,l,P,p,d.length]);let x=R(()=>lt(({productIds:v,positions:w})=>m.track("product_impression",{list_id:p,product_ids:v,positions:w})),[m,p]);B(()=>()=>x.destroy(),[x]);let k=R(()=>({observe:x.observe,clicked:(v,w)=>m.track("product_clicked",{list_id:p,position:w},{product_id:v.id})}),[x,m,p]),S=H(null),T=H(!1),I=K(v=>{T.current=!0,g(v)},[g]);B(()=>{l||!T.current||(T.current=!1,S.current?.focus({preventScroll:!0}),S.current?.scrollIntoView({block:"start"}))},[l]);let A=u("grid",yt),y=u("emptyState","py-12 text-center text-sm"),L=u("error","flex flex-col items-center gap-3 py-12 text-center text-sm"),E=u("retryButton",$),{projectID:_,host:G}=t,vt=K((v,w)=>async()=>{if(o!=null){await Q(()=>o(v)),st(m,v);return}await dt(v,{projectID:_,host:G,showCart:i,analytics:m,url:w})},[o,_,G,i,m]),N;return l&&d.length===0?N=r(Rt,{count:Math.min(O(t.pageSize),8),label:a.loading}):P!=null?N=h("div",{...L,role:"alert",children:[r("p",{children:a.error}),r("button",{type:"button",...E,onClick:C,children:a.retry})]}):d.length===0?N=r("p",{...y,children:a.empty}):N=r("ul",{...A,"aria-busy":l||void 0,className:U(A.className,l&&"opacity-60"),children:d.map((v,w)=>{let W=e(v);return r(Ot,{product:v,position:(c-1)*f+w,href:W,onAdd:vt(v,W),renderItem:n},v.id)})}),r(bt.Provider,{value:k,children:h("div",{ref:S,tabIndex:-1,className:"p-1 outline-none scroll-mt-4",children:[N,s>1&&P==null?r(Dt,{page:c,pageCount:s,isLoading:l,onPage:I}):null]})})}var Ft=t=>`/p/${encodeURIComponent(t.uniqueSlug)}`;function Mt({productHref:t=Ft,appearance:e,texts:n,renderItem:o,onAddToCart:i,showCartOnAdd:a=!0,className:d,analytics:c,...s}){let g=Y(s.projectID,c,"catalog"),l=s.locale??nt,P=R(()=>ct(e),[e]),C=R(()=>pt(l,n),[l,n]),m=R(()=>({appearance:P,texts:C,locale:l}),[P,C,l]),p=j(P,"root");return r(Z,{value:g,children:r(ft.Provider,{value:m,children:r("div",{"data-bitsnap-products":"root","data-bitsnap-products-slot":"root",className:U("bitsnap-react",P.boundaryClassName,d,p?.className),style:{...P.boundaryStyle,...p?.style},children:r(Ut,{options:s,productHref:t,renderItem:o,onAddToCart:i,showCartOnAdd:a})})})})}export{xt as a,q as b,Mt as c};
|
|
2
|
-
//# sourceMappingURL=chunk-DPKWYLN7.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/products/appearance.ts","../src/components/products/useProducts.ts","../src/components/products/ProductList.tsx","../src/components/products/impressions.ts","../src/components/products/texts.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport {\n getSlotAppearance,\n resolveAppearanceCore,\n type AppearanceElements,\n type ShadcnVariableMapping,\n type SlotAppearance,\n} from \"@/src/lib/appearance-core\";\n\n/**\n * Product list appearance API.\n *\n * It mirrors `CheckoutAppearance` and `ReturnsAppearance` (theme, tokens,\n * elements) so a shop can reuse one brand object for all of them. The resolver\n * is pure: it turns the caller input into a theme name, the tokens in effect,\n * the slot overrides and the inline style for the theme boundary.\n */\n\nexport type ProductListTheme = \"light\" | \"dark\";\n\nexport type ProductListAppearanceTokens = {\n /** Font family of the list. The library never loads fonts. */\n fontFamily?: string;\n /** Base font size. */\n fontSize?: string;\n /** List background. */\n background?: string;\n /** Raised surfaces: cards, image placeholders, skeletons. */\n surface?: string;\n /** Main text color. */\n foreground?: string;\n /** Secondary text: descriptions, the struck-through price. */\n mutedForeground?: string;\n /** Borders of cards and buttons. */\n border?: string;\n /** \"Add to cart\" button background. */\n buttonBackground?: string;\n /** \"Add to cart\" button text. */\n buttonForeground?: string;\n /** \"Add to cart\" button background on hover. */\n buttonHoverBackground?: string;\n /** Hover surface of cards and secondary buttons. */\n hoverSurface?: string;\n /** Focus ring color. */\n focusRing?: string;\n /** Error and unavailable state color. */\n error?: string;\n /** Badge background (subscription, unavailable). */\n badgeBackground?: string;\n /** Badge text. */\n badgeForeground?: string;\n /** Corner radius of cards, images and buttons. */\n radius?: string;\n};\n\n/**\n * Stable slot names. They are exposed as `data-bitsnap-products-slot`\n * attributes so they can also be targeted from plain CSS.\n */\nexport const PRODUCT_LIST_SLOT_NAMES = [\n \"root\",\n \"grid\",\n \"card\",\n \"cardLink\",\n \"image\",\n \"imagePlaceholder\",\n \"body\",\n \"name\",\n \"description\",\n \"price\",\n \"comparePrice\",\n \"badge\",\n \"model3dBadge\",\n \"actions\",\n \"addToCartButton\",\n \"selectButton\",\n \"message\",\n \"pagination\",\n \"paginationButton\",\n \"pageIndicator\",\n \"emptyState\",\n \"error\",\n \"retryButton\",\n \"skeleton\",\n] as const;\n\nexport type ProductListSlotName = (typeof PRODUCT_LIST_SLOT_NAMES)[number];\n\nexport type ProductListSlotAppearance = SlotAppearance;\n\nexport type ProductListAppearanceElements =\n AppearanceElements<ProductListSlotName>;\n\nexport type ProductListAppearance = {\n /** `\"light\"` or `\"dark\"`. Omitted means `\"light\"`. */\n theme?: ProductListTheme;\n /** Partial overrides applied over the theme preset. */\n tokens?: ProductListAppearanceTokens;\n /** Per element `className`/`style` overrides. */\n elements?: ProductListAppearanceElements;\n};\n\nexport type ResolvedProductListAppearance = {\n theme: ProductListTheme;\n /** Tokens that are in effect (the theme preset plus caller overrides). */\n tokens: ProductListAppearanceTokens;\n elements: ProductListAppearanceElements;\n /** Theme marker class for the theme boundary. */\n boundaryClassName: string;\n /** Inline custom properties applied to the list root. */\n boundaryStyle: CSSProperties;\n};\n\n/** CSS custom property used for each token. */\nexport const PRODUCT_LIST_TOKEN_VARIABLES = {\n fontFamily: \"--bitsnap-products-font-family\",\n fontSize: \"--bitsnap-products-font-size\",\n background: \"--bitsnap-products-background\",\n surface: \"--bitsnap-products-surface\",\n foreground: \"--bitsnap-products-foreground\",\n mutedForeground: \"--bitsnap-products-muted-foreground\",\n border: \"--bitsnap-products-border\",\n buttonBackground: \"--bitsnap-products-button-background\",\n buttonForeground: \"--bitsnap-products-button-foreground\",\n buttonHoverBackground: \"--bitsnap-products-button-hover-background\",\n hoverSurface: \"--bitsnap-products-hover-surface\",\n focusRing: \"--bitsnap-products-focus-ring\",\n error: \"--bitsnap-products-error\",\n badgeBackground: \"--bitsnap-products-badge-background\",\n badgeForeground: \"--bitsnap-products-badge-foreground\",\n radius: \"--bitsnap-products-radius\",\n} as const;\n\nexport type ProductListTokenName = keyof typeof PRODUCT_LIST_TOKEN_VARIABLES;\n\n/**\n * Complete palettes. They carry colors and radius only, so typography is never\n * reset implicitly. `products.css` falls back to the light values, which keeps\n * the list usable even when the boundary style is missing.\n */\nexport const PRODUCT_LIST_THEME_PRESETS: Record<\n ProductListTheme,\n ProductListAppearanceTokens\n> = {\n light: {\n background: \"#ffffff\",\n surface: \"#f9fafb\",\n foreground: \"#18181b\",\n mutedForeground: \"#71717a\",\n border: \"#e4e4e7\",\n buttonBackground: \"#18181b\",\n buttonForeground: \"#fafafa\",\n buttonHoverBackground: \"#000000\",\n hoverSurface: \"#f4f4f5\",\n focusRing: \"#71717a\",\n error: \"#dc2626\",\n badgeBackground: \"#f4f4f5\",\n badgeForeground: \"#3f3f46\",\n radius: \"8px\",\n },\n dark: {\n background: \"#18181b\",\n surface: \"#27272a\",\n foreground: \"#fafafa\",\n mutedForeground: \"#a1a1aa\",\n border: \"#3f3f46\",\n buttonBackground: \"#fafafa\",\n buttonForeground: \"#18181b\",\n buttonHoverBackground: \"#e4e4e7\",\n hoverSurface: \"#3f3f46\",\n focusRing: \"#a1a1aa\",\n error: \"#f87171\",\n badgeBackground: \"#3f3f46\",\n badgeForeground: \"#e4e4e7\",\n radius: \"8px\",\n },\n};\n\n/** The list renders its own elements, so no shared primitive needs remapping. */\nconst PRODUCT_LIST_SHADCN_VARIABLES: ShadcnVariableMapping<ProductListTokenName> =\n [];\n\nexport function resolveProductListAppearance(\n appearance?: ProductListAppearance,\n): ResolvedProductListAppearance {\n const resolved = resolveAppearanceCore<\n ProductListTokenName,\n ProductListTheme,\n ProductListSlotName\n >(appearance, {\n defaultTheme: \"light\",\n presets: PRODUCT_LIST_THEME_PRESETS,\n variables: PRODUCT_LIST_TOKEN_VARIABLES,\n shadcnVariables: PRODUCT_LIST_SHADCN_VARIABLES,\n });\n\n return {\n theme: resolved.theme,\n tokens: resolved.tokens,\n elements: resolved.elements,\n boundaryClassName: resolved.theme,\n boundaryStyle: resolved.boundaryStyle,\n };\n}\n\n/** Caller overrides for a single slot, if any were provided. */\nexport function getProductListSlotAppearance(\n resolved: ResolvedProductListAppearance,\n slot: ProductListSlotName,\n): ProductListSlotAppearance | undefined {\n return getSlotAppearance(resolved.elements, slot);\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { HOST } from \"../checkout/constants\";\nimport {\n clampPageSize,\n fetchProductList,\n pageCountFor,\n type ProductListData,\n type PublicListProduct,\n} from \"./fetch\";\n\nexport type UseProductsOptions = {\n /** Project (shop) ID. */\n projectID: string;\n /**\n * Origin of the Bitsnap backend. Defaults to the library host\n * (`https://bitsnap.pl`, or what `setCustomHost` had set when the component\n * first rendered; later `setCustomHost` calls do not move an existing list).\n * On a custom domain pass the domain itself, or an empty string for\n * same-origin requests.\n */\n host?: string;\n locale?: string;\n /** Products per page, 1 to 48. Defaults to 24. */\n pageSize?: number;\n search?: string;\n /**\n * First page, loaded on the server. It is always used for the first request\n * of the mounted list (the first fetch is skipped and the products are\n * available on the first render), so it has to be the page the props ask\n * for: page 1 with the same `pageSize`, `locale` and `search`. Later changes\n * of the props fetch again.\n */\n initialData?: ProductListData;\n};\n\nexport type UseProductsResult = {\n /** Products of the current page. Keeps the previous page while loading. */\n products: PublicListProduct[];\n totalCount: number;\n /** Current page, starting at 1. */\n page: number;\n pageCount: number;\n setPage: (page: number) => void;\n /** `true` until the current page is available, also during server rendering. */\n isLoading: boolean;\n error: Error | undefined;\n /** Loads the current page again. */\n refetch: () => void;\n};\n\ntype Snapshot = {\n /** Request the data belongs to; empty when it is not tied to one. */\n requestKey: string;\n data: ProductListData | undefined;\n error: Error | undefined;\n};\n\n/**\n * Loads the product catalog page by page. It uses a plain `fetch` without\n * credentials, never reads global state (`setProjectID`, `setCustomHost`) other\n * than the default host, and does nothing during server rendering - pass\n * `initialData` to render products in the server HTML.\n */\nexport function useProducts(options: UseProductsOptions): UseProductsResult {\n const { projectID, locale, search, initialData } = options;\n // The library host is a mutable global; read it once so a later\n // `setCustomHost` does not change the query of a mounted list.\n const [defaultHost] = useState(() => HOST);\n const host = options.host ?? defaultHost;\n const pageSize = clampPageSize(options.pageSize);\n\n // Everything that identifies a list; a change resets the page.\n const queryKey = JSON.stringify([\n projectID,\n host,\n locale ?? null,\n search?.trim() ?? null,\n pageSize,\n ]);\n\n const [pageState, setPageState] = useState({ queryKey, page: 1 });\n if (pageState.queryKey !== queryKey) {\n // Another list: start from page 1 (adjusting state while rendering).\n setPageState({ queryKey, page: 1 });\n }\n const [reloads, setReloads] = useState(0);\n const [snapshot, setSnapshot] = useState<Snapshot>(() => ({\n requestKey: initialData != null ? `${queryKey}|1|0` : \"\",\n data: initialData,\n error: undefined,\n }));\n\n // A page past the end (the catalog shrank) falls back to the last page once\n // the total is known.\n const totalCount = snapshot.data?.totalCount ?? 0;\n const pageCount = pageCountFor(totalCount, pageSize);\n const requestedPage = pageState.queryKey === queryKey ? pageState.page : 1;\n const page = totalCount > 0 ? Math.min(requestedPage, pageCount) : requestedPage;\n\n const requestKey = `${queryKey}|${page}|${reloads}`;\n\n const isCurrent = snapshot.requestKey === requestKey;\n\n useEffect(() => {\n if (isCurrent) {\n return;\n }\n\n const controller = new AbortController();\n fetchProductList(\n {\n projectID,\n host,\n locale,\n search,\n limit: pageSize,\n offset: (page - 1) * pageSize,\n },\n controller.signal,\n ).then(\n (data) => {\n if (controller.signal.aborted) {\n return;\n }\n setSnapshot({ requestKey, data, error: undefined });\n },\n (error: unknown) => {\n if (controller.signal.aborted) {\n return;\n }\n setSnapshot((previous) => ({\n requestKey,\n data: previous.data,\n error: error instanceof Error ? error : new Error(String(error)),\n }));\n },\n );\n\n return () => controller.abort();\n // `requestKey` carries projectID, host, locale, search, pageSize, page and\n // the reload counter.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [requestKey, isCurrent]);\n\n const setPage = useCallback(\n (next: number) => {\n const target = Math.max(1, Math.floor(next));\n setPageState({\n queryKey,\n page: totalCount > 0 ? Math.min(target, pageCount) : target,\n });\n },\n [queryKey, totalCount, pageCount],\n );\n\n const refetch = useCallback(() => setReloads((value) => value + 1), []);\n\n return useMemo(\n () => ({\n products: snapshot.data?.items ?? [],\n totalCount,\n page,\n pageCount,\n setPage,\n isLoading: !isCurrent,\n error: isCurrent ? snapshot.error : undefined,\n refetch,\n }),\n [snapshot, totalCount, page, pageCount, setPage, isCurrent, refetch],\n );\n}\n","import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { CSSProperties, ReactNode } from \"react\";\nimport { cn } from \"@/src/lib/utils\";\nimport {\n InstrumentProvider,\n useInstrument,\n useInstrumentContext,\n withCartAnalyticsMuted,\n type AnalyticsOption,\n type Instrument,\n} from \"@/src/analytics/instrument\";\nimport { DEFAULT_LOCALE } from \"../checkout/locale\";\nimport { addProductToCart, trackProductAdded } from \"./add-to-cart\";\nimport {\n getProductListSlotAppearance,\n resolveProductListAppearance,\n type ProductListAppearance,\n type ProductListSlotName,\n type ResolvedProductListAppearance,\n} from \"./appearance\";\nimport { clampPageSize, type PublicListProduct } from \"./fetch\";\nimport { formatProductPrice } from \"./format\";\nimport { createImpressionTracker } from \"./impressions\";\nimport {\n fillProductListText,\n resolveProductListTexts,\n type ProductListTexts,\n} from \"./texts\";\nimport { useProducts, type UseProductsOptions } from \"./useProducts\";\n\n/** What `renderItem` gets next to the product. */\nexport type ProductListItemContext = {\n /** Product page URL from `productHref`. */\n href: string;\n /** Price formatted for the locale and currency, without the \"from\" prefix. */\n price: string;\n /** Formatted regular price when the product is discounted. */\n compareAtPrice: string | null;\n texts: ProductListTexts;\n locale: string;\n /** Adds the product to the cart the way the built-in button does. */\n addToCart: () => Promise<void>;\n /**\n * Reports a click on the product (`product_clicked`). Call it from the link\n * a custom card renders; the built-in card does it itself.\n */\n trackClick: () => void;\n};\n\nexport type ProductListProps = UseProductsOptions & {\n /**\n * Product page URL. Defaults to the relative `/p/{uniqueSlug}`, which works\n * on a Bitsnap custom domain. Embedded on another site, return the full\n * URL of the product page.\n */\n productHref?: (product: PublicListProduct) => string;\n appearance?: ProductListAppearance;\n /** Text overrides, applied whatever the locale. */\n texts?: Partial<ProductListTexts>;\n /** Replaces the content of a card. The card frame stays. */\n renderItem?: (\n product: PublicListProduct,\n context: ProductListItemContext,\n ) => ReactNode;\n /**\n * Called by the \"Add to cart\" button instead of the default action\n * (`Bitsnap.addProductToCart`). A rejected promise shows the error message.\n */\n onAddToCart?: (product: PublicListProduct) => void | Promise<void>;\n /** Open the cart drawer after the default add to cart. Defaults to `true`. */\n showCartOnAdd?: boolean;\n className?: string;\n /**\n * Usage statistics for your Bitsnap dashboard (list views, impressions,\n * clicks, add to cart). On by default; `false` turns it off. An object\n * lets you forward every event: `{ onEvent }`. Nothing is stored on the\n * visitor's device.\n */\n analytics?: AnalyticsOption;\n};\n\ntype ListContext = {\n appearance: ResolvedProductListAppearance;\n texts: ProductListTexts;\n locale: string;\n};\n\nconst ProductListContext = createContext<ListContext | undefined>(undefined);\n\ntype CardAnalytics = {\n observe: (element: Element, id: string, position: number) => () => void;\n clicked: (product: PublicListProduct, position: number) => void;\n};\n\nconst noCardAnalytics: CardAnalytics = {\n observe: () => () => {},\n clicked: () => {},\n};\n\nconst CardAnalyticsContext = createContext<CardAnalytics>(noCardAnalytics);\n\nfunction useListContext(): ListContext {\n const value = useContext(ProductListContext);\n if (value == null) {\n throw new Error(\"ProductList parts must be rendered inside ProductList\");\n }\n return value;\n}\n\n/** Stable slot attribute, built-in classes and the caller overrides for a slot. */\nfunction useSlot(slot: ProductListSlotName, className?: string) {\n const { appearance } = useListContext();\n const override = getProductListSlotAppearance(appearance, slot);\n\n return {\n \"data-bitsnap-products-slot\": slot,\n className: cn(className, override?.className),\n style: override?.style,\n };\n}\n\nconst BUTTON_CLASS =\n \"inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50\";\nconst BLOCK_BUTTON_CLASS = `${BUTTON_CLASS} w-full`;\nconst LINK_BUTTON_CLASS = `${BLOCK_BUTTON_CLASS} no-underline`;\n\ntype AddStatus = \"idle\" | \"adding\" | \"added\" | \"error\";\n\nfunction AddToCartButton({\n product,\n onAdd,\n}: {\n product: PublicListProduct;\n onAdd: () => Promise<void>;\n}) {\n const { texts } = useListContext();\n const [status, setStatus] = useState<AddStatus>(\"idle\");\n const button = useSlot(\"addToCartButton\", BLOCK_BUTTON_CLASS);\n const message = useSlot(\"message\", \"mt-2 text-xs\");\n\n useEffect(() => {\n if (status !== \"added\") {\n return;\n }\n const timer = setTimeout(() => setStatus(\"idle\"), 2000);\n return () => clearTimeout(timer);\n }, [status]);\n\n const click = useCallback(async () => {\n setStatus(\"adding\");\n try {\n await onAdd();\n setStatus(\"added\");\n } catch (error) {\n console.error(\"bitsnap-react: could not add to the cart\", error);\n setStatus(\"error\");\n }\n }, [onAdd]);\n\n const label =\n status === \"adding\"\n ? texts.addingToCart\n : status === \"added\"\n ? texts.addedToCart\n : texts.addToCart;\n\n return (\n <>\n <button\n type=\"button\"\n {...button}\n disabled={status === \"adding\"}\n aria-label={`${label}: ${product.name}`}\n onClick={click}\n >\n {label}\n </button>\n {status === \"error\" ? (\n <p {...message} role=\"alert\">\n {texts.addToCartError}\n </p>\n ) : null}\n </>\n );\n}\n\nfunction ProductCard({\n product,\n position,\n href,\n onAdd,\n renderItem,\n}: {\n product: PublicListProduct;\n /** Index in the whole catalog (not in the current page). */\n position: number;\n href: string;\n onAdd: () => Promise<void>;\n renderItem?: ProductListProps[\"renderItem\"];\n}) {\n const { texts, locale } = useListContext();\n const analytics = useContext(CardAnalyticsContext);\n const element = useRef<HTMLLIElement>(null);\n useEffect(() => {\n if (element.current == null) {\n return;\n }\n return analytics.observe(element.current, product.id, position);\n }, [analytics, product.id, position]);\n const trackClick = useCallback(\n () => analytics.clicked(product, position),\n [analytics, product, position],\n );\n const card = useSlot(\n \"card\",\n \"relative flex flex-col overflow-hidden border transition-colors\",\n );\n const cardLink = useSlot(\"cardLink\", \"flex flex-1 flex-col no-underline\");\n const imageFrame = useSlot(\"image\", \"aspect-square w-full overflow-hidden\");\n const placeholder = useSlot(\"imagePlaceholder\", \"aspect-square w-full\");\n const body = useSlot(\"body\", \"flex flex-1 flex-col gap-1 p-4\");\n const name = useSlot(\"name\", \"text-base font-medium leading-snug\");\n const description = useSlot(\"description\", \"line-clamp-2 text-sm\");\n const price = useSlot(\"price\", \"mt-auto pt-2 text-base font-semibold\");\n const comparePrice = useSlot(\"comparePrice\", \"ml-2 text-sm font-normal\");\n const badge = useSlot(\n \"badge\",\n \"absolute left-3 top-3 px-2 py-0.5 text-xs font-medium\",\n );\n const model3dBadge = useSlot(\n \"model3dBadge\",\n \"absolute right-3 top-3 inline-flex items-center gap-1 px-2 py-0.5 text-xs font-semibold\",\n );\n const actions = useSlot(\"actions\", \"p-4 pt-0\");\n const selectButton = useSlot(\"selectButton\", LINK_BUTTON_CLASS);\n\n const formattedPrice = formatProductPrice(\n product.price,\n product.currency,\n locale,\n );\n const formattedCompare =\n product.compareAtPrice != null && product.compareAtPrice > product.price\n ? formatProductPrice(product.compareAtPrice, product.currency, locale)\n : null;\n\n if (renderItem != null) {\n return (\n <li\n ref={element}\n {...card}\n data-unavailable={product.available ? undefined : \"\"}\n >\n {renderItem(product, {\n href,\n price: formattedPrice,\n compareAtPrice: formattedCompare,\n texts,\n locale,\n addToCart: onAdd,\n trackClick,\n })}\n </li>\n );\n }\n\n const imageSource = product.image?.thumbnailUrl ?? product.image?.url;\n const badgeText = !product.available\n ? texts.unavailable\n : product.isRecurring\n ? texts.subscription\n : null;\n\n return (\n <li ref={element} {...card} data-unavailable={product.available ? undefined : \"\"}>\n <a {...cardLink} href={href} onClick={trackClick}>\n {imageSource != null ? (\n <div {...imageFrame}>\n <img\n src={imageSource}\n alt=\"\"\n loading=\"lazy\"\n decoding=\"async\"\n className=\"h-full w-full object-cover\"\n />\n </div>\n ) : (\n <div {...placeholder} aria-hidden=\"true\" />\n )}\n <div {...body}>\n <h3 {...name}>{product.name}</h3>\n {product.shortDescription ? (\n <p {...description}>{product.shortDescription}</p>\n ) : null}\n <p {...price}>\n {product.priceFrom\n ? fillProductListText(texts.priceFrom, { price: formattedPrice })\n : formattedPrice}\n {formattedCompare != null ? (\n <>\n <span className=\"sr-only\">{texts.originalPrice}: </span>\n <del {...comparePrice}>{formattedCompare}</del>\n </>\n ) : null}\n </p>\n </div>\n </a>\n {badgeText != null ? (\n <span\n {...badge}\n data-kind={product.available ? \"subscription\" : \"unavailable\"}\n >\n {badgeText}\n </span>\n ) : null}\n {product.has3d === true ? (\n <span {...model3dBadge} title={texts.model3dLabel}>\n <CubeIcon />\n <span aria-hidden=\"true\">{texts.model3d}</span>\n <span className=\"sr-only\">{texts.model3dLabel}</span>\n </span>\n ) : null}\n <div {...actions}>\n {!product.available ? (\n <button type=\"button\" {...selectButton} disabled>\n {texts.unavailable}\n </button>\n ) : product.addToCart ? (\n <AddToCartButton product={product} onAdd={onAdd} />\n ) : (\n <a {...selectButton} href={href} onClick={trackClick}>\n {product.variantCount > 1 ? texts.chooseOptions : texts.viewProduct}\n </a>\n )}\n </div>\n </li>\n );\n}\n\nfunction CubeIcon() {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n width=\"12\"\n height=\"12\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z\" />\n <path d=\"m3.3 7 8.7 5 8.7-5\" />\n <path d=\"M12 22V12\" />\n </svg>\n );\n}\n\nconst GRID_CLASS =\n \"m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-5 p-0\";\n\nfunction SkeletonGrid({ count, label }: { count: number; label: string }) {\n const grid = useSlot(\"grid\", GRID_CLASS);\n const skeleton = useSlot(\"skeleton\", \"aspect-[3/4] animate-pulse\");\n\n return (\n <div {...grid} role=\"status\" aria-busy=\"true\" aria-label={label}>\n {Array.from({ length: count }, (_, index) => (\n <div key={index} {...skeleton} aria-hidden=\"true\" />\n ))}\n </div>\n );\n}\n\nfunction Pagination({\n page,\n pageCount,\n isLoading,\n onPage,\n}: {\n page: number;\n pageCount: number;\n isLoading: boolean;\n onPage: (page: number) => void;\n}) {\n const { texts } = useListContext();\n const nav = useSlot(\n \"pagination\",\n \"mt-8 flex items-center justify-center gap-4\",\n );\n const button = useSlot(\"paginationButton\", BUTTON_CLASS);\n const indicator = useSlot(\"pageIndicator\", \"text-sm\");\n\n return (\n <nav {...nav} aria-label={texts.pagination}>\n <button\n type=\"button\"\n {...button}\n aria-disabled={isLoading || page <= 1}\n onClick={() => {\n if (!isLoading && page > 1) {\n onPage(page - 1);\n }\n }}\n >\n {texts.previousPage}\n </button>\n <span {...indicator} aria-live=\"polite\">\n {fillProductListText(texts.pageOf, { page, pageCount })}\n </span>\n <button\n type=\"button\"\n {...button}\n aria-disabled={isLoading || page >= pageCount}\n onClick={() => {\n if (!isLoading && page < pageCount) {\n onPage(page + 1);\n }\n }}\n >\n {texts.nextPage}\n </button>\n </nav>\n );\n}\n\nfunction ProductListContent({\n options,\n productHref,\n renderItem,\n onAddToCart,\n showCartOnAdd,\n}: {\n options: UseProductsOptions;\n productHref: (product: PublicListProduct) => string;\n renderItem?: ProductListProps[\"renderItem\"];\n onAddToCart?: ProductListProps[\"onAddToCart\"];\n showCartOnAdd: boolean;\n}) {\n const { texts } = useListContext();\n const { products, page, pageCount, setPage, isLoading, error, refetch } =\n useProducts(options);\n const instrument = useInstrumentContext();\n // The search text is never reported, only that the list was searched.\n const listId = options.search?.trim() ? \"search\" : \"catalog\";\n const pageSize = clampPageSize(options.pageSize);\n\n const viewed = useRef(false);\n useEffect(() => {\n if (viewed.current || isLoading || error != null) {\n return;\n }\n viewed.current = true;\n instrument.track(\"product_list_viewed\", {\n list_id: listId,\n item_count: products.length,\n });\n }, [instrument, isLoading, error, listId, products.length]);\n\n const impressions = useMemo(\n () =>\n createImpressionTracker(({ productIds, positions }) =>\n instrument.track(\"product_impression\", {\n list_id: listId,\n product_ids: productIds,\n positions,\n }),\n ),\n [instrument, listId],\n );\n useEffect(() => () => impressions.destroy(), [impressions]);\n const cardAnalytics = useMemo<CardAnalytics>(\n () => ({\n observe: impressions.observe,\n clicked: (product, position) =>\n instrument.track(\n \"product_clicked\",\n { list_id: listId, position },\n { product_id: product.id },\n ),\n }),\n [impressions, instrument, listId],\n );\n\n // After a page change by the user, move focus to the products (the button\n // that was pressed stays where it is, but the content above it changes) and\n // bring them into view once the page has loaded.\n const content = useRef<HTMLDivElement>(null);\n const movedPage = useRef(false);\n const changePage = useCallback(\n (next: number) => {\n movedPage.current = true;\n setPage(next);\n },\n [setPage],\n );\n useEffect(() => {\n if (isLoading || !movedPage.current) {\n return;\n }\n movedPage.current = false;\n content.current?.focus({ preventScroll: true });\n content.current?.scrollIntoView({ block: \"start\" });\n }, [isLoading]);\n\n const grid = useSlot(\"grid\", GRID_CLASS);\n const empty = useSlot(\"emptyState\", \"py-12 text-center text-sm\");\n const errorSlot = useSlot(\"error\", \"flex flex-col items-center gap-3 py-12 text-center text-sm\");\n const retry = useSlot(\"retryButton\", BUTTON_CLASS);\n\n const { projectID, host } = options;\n const addFor = useCallback(\n (product: PublicListProduct, href: string) => async () => {\n if (onAddToCart != null) {\n // The list reports the add itself; a cart helper called inside must not report it again.\n await withCartAnalyticsMuted(() => onAddToCart(product));\n trackProductAdded(instrument, product);\n return;\n }\n await addProductToCart(product, {\n projectID,\n host,\n showCart: showCartOnAdd,\n analytics: instrument,\n url: href,\n });\n },\n [onAddToCart, projectID, host, showCartOnAdd, instrument],\n );\n\n let body: ReactNode;\n if (isLoading && products.length === 0) {\n body = (\n <SkeletonGrid\n count={Math.min(clampPageSize(options.pageSize), 8)}\n label={texts.loading}\n />\n );\n } else if (error != null) {\n body = (\n <div {...errorSlot} role=\"alert\">\n <p>{texts.error}</p>\n <button type=\"button\" {...retry} onClick={refetch}>\n {texts.retry}\n </button>\n </div>\n );\n } else if (products.length === 0) {\n body = <p {...empty}>{texts.empty}</p>;\n } else {\n body = (\n <ul\n {...grid}\n aria-busy={isLoading || undefined}\n className={cn(grid.className, isLoading && \"opacity-60\")}\n >\n {products.map((product, index) => {\n const href = productHref(product);\n return (\n <ProductCard\n key={product.id}\n product={product}\n position={(page - 1) * pageSize + index}\n href={href}\n onAdd={addFor(product, href)}\n renderItem={renderItem}\n />\n );\n })}\n </ul>\n );\n }\n\n return (\n <CardAnalyticsContext.Provider value={cardAnalytics}>\n <div\n ref={content}\n tabIndex={-1}\n className=\"p-1 outline-none scroll-mt-4\"\n >\n {body}\n {pageCount > 1 && error == null ? (\n <Pagination\n page={page}\n pageCount={pageCount}\n isLoading={isLoading}\n onPage={changePage}\n />\n ) : null}\n </div>\n </CardAnalyticsContext.Provider>\n );\n}\n\nconst defaultProductHref = (product: PublicListProduct) =>\n `/p/${encodeURIComponent(product.uniqueSlug)}`;\n\n/**\n * Responsive grid of the shop's products with pagination, loading, empty and\n * error states. Cards link to the product page and can add to the cart.\n *\n * ```tsx\n * <ProductList projectID=\"…\" locale=\"pl-PL\" initialData={firstPage} />\n * ```\n *\n * It renders on the server: pass `initialData` (the first page, fetched on the\n * server) to have the products in the HTML; without it the server renders the\n * loading skeleton and the browser fetches the first page.\n */\nexport function ProductList({\n productHref = defaultProductHref,\n appearance,\n texts,\n renderItem,\n onAddToCart,\n showCartOnAdd = true,\n className,\n analytics,\n ...options\n}: ProductListProps) {\n const instrument: Instrument = useInstrument(\n options.projectID,\n analytics,\n \"catalog\",\n );\n const locale = options.locale ?? DEFAULT_LOCALE;\n const resolvedAppearance = useMemo(\n () => resolveProductListAppearance(appearance),\n [appearance],\n );\n const resolvedTexts = useMemo(\n () => resolveProductListTexts(locale, texts),\n [locale, texts],\n );\n const context = useMemo(\n () => ({ appearance: resolvedAppearance, texts: resolvedTexts, locale }),\n [resolvedAppearance, resolvedTexts, locale],\n );\n const root = getProductListSlotAppearance(resolvedAppearance, \"root\");\n\n return (\n <InstrumentProvider value={instrument}>\n <ProductListContext.Provider value={context}>\n <div\n data-bitsnap-products=\"root\"\n data-bitsnap-products-slot=\"root\"\n className={cn(\n \"bitsnap-react\",\n resolvedAppearance.boundaryClassName,\n className,\n root?.className,\n )}\n style={\n { ...resolvedAppearance.boundaryStyle, ...root?.style } as CSSProperties\n }\n >\n <ProductListContent\n options={options}\n productHref={productHref}\n renderItem={renderItem}\n onAddToCart={onAddToCart}\n showCartOnAdd={showCartOnAdd}\n />\n </div>\n </ProductListContext.Provider>\n </InstrumentProvider>\n );\n}\n","import { getTracker } from \"@/src/analytics/core\";\n\n/** Matches the contract's `positions` / `product_ids` array limit. */\nconst MAX_PER_EVENT = 50;\nconst FLUSH_DELAY_MS = 1000;\n\nexport type ImpressionBatch = { productIds: string[]; positions: number[] };\n\n/**\n * Collects the products that were at least half visible, each one once, and\n * hands them over in batches. Without `IntersectionObserver` nothing is\n * reported. Never throws.\n */\nexport function createImpressionTracker(\n onBatch: (batch: ImpressionBatch) => void,\n delayMs = FLUSH_DELAY_MS,\n) {\n const seen = new Set<string>();\n const targets = new Map<Element, { id: string; position: number }>();\n let pendingIds: string[] = [];\n let pendingPositions: number[] = [];\n let observer: IntersectionObserver | undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let listening = false;\n\n function flush() {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n while (pendingIds.length > 0) {\n const productIds = pendingIds.slice(0, MAX_PER_EVENT);\n const positions = pendingPositions.slice(0, MAX_PER_EVENT);\n pendingIds = pendingIds.slice(MAX_PER_EVENT);\n pendingPositions = pendingPositions.slice(MAX_PER_EVENT);\n try {\n onBatch({ productIds, positions });\n } catch {}\n }\n }\n\n // The tracker flushes its own queue on `pagehide`; ours must be in it by then.\n function flushAll() {\n flush();\n try {\n getTracker()?.flush();\n } catch {}\n }\n const onVisibility = () => {\n if (typeof document !== \"undefined\" && document.visibilityState === \"hidden\") flushAll();\n };\n\n function listen() {\n if (listening || typeof window === \"undefined\") return;\n listening = true;\n window.addEventListener(\"pagehide\", flushAll, true);\n document.addEventListener(\"visibilitychange\", onVisibility, true);\n }\n\n function getObserver(): IntersectionObserver | undefined {\n if (observer) return observer;\n if (typeof IntersectionObserver === \"undefined\") return undefined;\n observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n const target = targets.get(entry.target);\n if (!target || !entry.isIntersecting || entry.intersectionRatio < 0.5) continue;\n targets.delete(entry.target);\n observer?.unobserve(entry.target);\n if (seen.has(target.id)) continue;\n seen.add(target.id);\n pendingIds.push(target.id);\n pendingPositions.push(target.position);\n }\n if (pendingIds.length > 0 && timer === undefined) {\n timer = setTimeout(flush, delayMs);\n (timer as { unref?: () => void }).unref?.();\n }\n },\n { threshold: [0.5] },\n );\n listen();\n return observer;\n }\n\n return {\n /** Starts watching a card. Returns a function that stops. */\n observe(element: Element, id: string, position: number): () => void {\n try {\n if (seen.has(id)) return () => {};\n const watcher = getObserver();\n if (!watcher) return () => {};\n targets.set(element, { id, position });\n watcher.observe(element);\n return () => {\n targets.delete(element);\n watcher.unobserve(element);\n };\n } catch {\n return () => {};\n }\n },\n flush,\n destroy() {\n try {\n flush();\n observer?.disconnect();\n if (listening) {\n window.removeEventListener(\"pagehide\", flushAll, true);\n document.removeEventListener(\"visibilitychange\", onVisibility, true);\n listening = false;\n }\n } catch {}\n observer = undefined;\n targets.clear();\n },\n };\n}\n","import {\n lookupText,\n resolveTexts,\n type LocaleTables,\n} from \"@/src/lib/texts\";\n\n/**\n * Every string `ProductList` renders. Pass a partial object through the\n * `texts` prop to override any of them, whatever the locale. Placeholders\n * (`{price}`, `{page}`, `{pageCount}`) are filled by the component.\n */\nexport type ProductListTexts = {\n /** \"Add to cart\" button of products that can be bought straight from the list. */\n addToCart: string;\n /** Button label while the product is being added. */\n addingToCart: string;\n /** Button label after the product was added. */\n addedToCart: string;\n /** Message shown when adding to the cart failed. */\n addToCartError: string;\n /** Link of products with variants, to pick one on the product page. */\n chooseOptions: string;\n /** Link of products that cannot be added from the list (subscriptions). */\n viewProduct: string;\n /** Label of products that are out of stock. */\n unavailable: string;\n /** Badge of subscription products. */\n subscription: string;\n /** Badge of products with a 3D model. */\n model3d: string;\n /** Screen reader label of the 3D badge. */\n model3dLabel: string;\n /** Price of products whose variants differ in price. `{price}` is the lowest one. */\n priceFrom: string;\n /** Screen reader label of the struck-through regular price. */\n originalPrice: string;\n /** Accessible label of the loading skeleton. */\n loading: string;\n /** Shown when the shop has no products (or none matches the search). */\n empty: string;\n /** Shown when the products could not be loaded. */\n error: string;\n /** Retry button of the error state. */\n retry: string;\n /** Accessible label of the pagination. */\n pagination: string;\n previousPage: string;\n nextPage: string;\n /** Page indicator. `{page}` and `{pageCount}` are filled in. */\n pageOf: string;\n};\n\nexport type ProductListTextKey = keyof ProductListTexts;\n\nexport const PRODUCT_LIST_TEXT_TABLES: LocaleTables<ProductListTextKey> = {\n en: {\n addToCart: \"Add to cart\",\n addingToCart: \"Adding…\",\n addedToCart: \"Added to cart\",\n addToCartError: \"Could not add to the cart. Try again.\",\n chooseOptions: \"Choose\",\n viewProduct: \"View\",\n unavailable: \"Unavailable\",\n subscription: \"Subscription\",\n model3d: \"3D\",\n model3dLabel: \"3D model\",\n priceFrom: \"from {price}\",\n originalPrice: \"Original price\",\n loading: \"Loading products\",\n empty: \"There are no products to show.\",\n error: \"Could not load the products.\",\n retry: \"Try again\",\n pagination: \"Pagination\",\n previousPage: \"Previous\",\n nextPage: \"Next\",\n pageOf: \"Page {page} of {pageCount}\",\n },\n pl: {\n addToCart: \"Dodaj do koszyka\",\n addingToCart: \"Dodawanie…\",\n addedToCart: \"Dodano do koszyka\",\n addToCartError: \"Nie udało się dodać do koszyka. Spróbuj ponownie.\",\n chooseOptions: \"Wybierz\",\n viewProduct: \"Zobacz\",\n unavailable: \"Niedostępny\",\n subscription: \"Subskrypcja\",\n model3d: \"3D\",\n model3dLabel: \"Model 3D\",\n priceFrom: \"od {price}\",\n originalPrice: \"Cena przed obniżką\",\n loading: \"Ładowanie produktów\",\n empty: \"Brak produktów do wyświetlenia.\",\n error: \"Nie udało się załadować produktów.\",\n retry: \"Spróbuj ponownie\",\n pagination: \"Paginacja\",\n previousPage: \"Poprzednia\",\n nextPage: \"Następna\",\n pageOf: \"Strona {page} z {pageCount}\",\n },\n};\n\n/** Default texts for a locale merged with the caller overrides. */\nexport function resolveProductListTexts(\n locale: string,\n overrides?: Partial<ProductListTexts>,\n): ProductListTexts {\n return resolveTexts(PRODUCT_LIST_TEXT_TABLES, locale, overrides);\n}\n\nexport function getProductListText(\n key: ProductListTextKey,\n locale: string,\n overrides?: Partial<ProductListTexts>,\n): string {\n return lookupText(resolveProductListTexts(locale, overrides), key);\n}\n\n/** Replaces `{name}` placeholders. Unknown placeholders stay untouched. */\nexport function fillProductListText(\n text: string,\n values: Record<string, string | number>,\n): string {\n return text.replace(/\\{(\\w+)\\}/g, (match, name: string) =>\n name in values ? String(values[name]) : match,\n );\n}\n"],"mappings":"4UA2DO,IAAMA,GAA0B,CACrC,OACA,OACA,OACA,WACA,QACA,mBACA,OACA,OACA,cACA,QACA,eACA,QACA,eACA,UACA,kBACA,eACA,UACA,aACA,mBACA,gBACA,aACA,QACA,cACA,UACF,EA8BaC,GAA+B,CAC1C,WAAY,iCACZ,SAAU,+BACV,WAAY,gCACZ,QAAS,6BACT,WAAY,gCACZ,gBAAiB,sCACjB,OAAQ,4BACR,iBAAkB,uCAClB,iBAAkB,uCAClB,sBAAuB,6CACvB,aAAc,mCACd,UAAW,gCACX,MAAO,2BACP,gBAAiB,sCACjB,gBAAiB,sCACjB,OAAQ,2BACV,EASaC,GAGT,CACF,MAAO,CACL,WAAY,UACZ,QAAS,UACT,WAAY,UACZ,gBAAiB,UACjB,OAAQ,UACR,iBAAkB,UAClB,iBAAkB,UAClB,sBAAuB,UACvB,aAAc,UACd,UAAW,UACX,MAAO,UACP,gBAAiB,UACjB,gBAAiB,UACjB,OAAQ,KACV,EACA,KAAM,CACJ,WAAY,UACZ,QAAS,UACT,WAAY,UACZ,gBAAiB,UACjB,OAAQ,UACR,iBAAkB,UAClB,iBAAkB,UAClB,sBAAuB,UACvB,aAAc,UACd,UAAW,UACX,MAAO,UACP,gBAAiB,UACjB,gBAAiB,UACjB,O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EAAU1B,EACd,KAAO,CAAE,WAAYsB,EAAoB,MAAOE,EAAe,OAAA/E,CAAO,GACtE,CAAC6E,EAAoBE,EAAe/E,CAAM,CAC5C,EACMkF,EAAO1G,EAA6BqG,EAAoB,MAAM,EAEpE,OACEnH,EAACyH,EAAA,CAAmB,MAAOnC,EAC3B,SAAAtF,EAACE,GAAmB,SAAnB,CAA4B,MAAOqH,EAClC,SAAAvH,EAAC,OACC,wBAAsB,OACtB,6BAA2B,OAC3B,UAAWe,EACT,gBACAoG,EAAmB,kBACnBxG,EACA6G,GAAM,SACR,EACA,MACE,CAAE,GAAGL,EAAmB,cAAe,GAAGK,GAAM,KAAM,EAGxD,SAAAxH,EAAC6E,GAAA,CACC,QAASC,EACT,YAAaC,EACb,WAAY1C,EACZ,YAAa2C,EACb,cAAeC,EACjB,EACF,EACF,EACA,CAEJ","names":["PRODUCT_LIST_SLOT_NAMES","PRODUCT_LIST_TOKEN_VARIABLES","PRODUCT_LIST_THEME_PRESETS","PRODUCT_LIST_SHADCN_VARIABLES","resolveProductListAppearance","appearance","resolved","resolveAppearanceCore","getProductListSlotAppearance","slot","getSlotAppearance","useCallback","useEffect","useMemo","useState","useProducts","options","projectID","locale","search","initialData","defaultHost","useState","HOST","host","pageSize","clampPageSize","queryKey","pageState","setPageState","reloads","setReloads","snapshot","setSnapshot","totalCount","pageCount","pageCountFor","requestedPage","page","requestKey","isCurrent","useEffect","controller","fetchProductList","data","error","previous","setPage","useCallback","next","target","refetch","value","useMemo","createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","MAX_PER_EVENT","FLUSH_DELAY_MS","createImpressionTracker","onBatch","delayMs","seen","targets","pendingIds","pendingPositions","observer","timer","listening","flush","productIds","positions","flushAll","getTracker","onVisibility","listen","getObserver","entries","entry","target","element","id","position","watcher","PRODUCT_LIST_TEXT_TABLES","resolveProductListTexts","locale","overrides","resolveTexts","fillProductListText","text","values","match","name","Fragment","jsx","jsxs","ProductListContext","createContext","noCardAnalytics","CardAnalyticsContext","useListContext","value","useContext","useSlot","slot","className","appearance","override","getProductListSlotAppearance","cn","BUTTON_CLASS","BLOCK_BUTTON_CLASS","LINK_BUTTON_CLASS","AddToCartButton","product","onAdd","texts","status","setStatus","useState","button","message","useEffect","timer","click","useCallback","error","label","ProductCard","position","href","renderItem","locale","analytics","element","useRef","trackClick","card","cardLink","imageFrame","placeholder","body","name","description","price","comparePrice","badge","model3dBadge","actions","selectButton","formattedPrice","formatProductPrice","formattedCompare","imageSource","badgeText","fillProductListText","CubeIcon","GRID_CLASS","SkeletonGrid","count","grid","skeleton","_","index","Pagination","page","pageCount","isLoading","onPage","nav","indicator","ProductListContent","options","productHref","onAddToCart","showCartOnAdd","products","setPage","refetch","useProducts","instrument","useInstrumentContext","listId","pageSize","clampPageSize","viewed","impressions","useMemo","createImpressionTracker","productIds","positions","cardAnalytics","content","movedPage","changePage","next","empty","errorSlot","retry","projectID","host","addFor","withCartAnalyticsMuted","trackProductAdded","addProductToCart","defaultProductHref","ProductList","useInstrument","DEFAULT_LOCALE","resolvedAppearance","resolveProductListAppearance","resolvedTexts","resolveProductListTexts","context","root","InstrumentProvider"]}
|
package/dist/chunk-I3QXJJ7U.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{A as N,f as m,i,j as d,k as R,s as c,t as E,u as p,v as S,w as l,x as y,y as I,z as T}from"./chunk-QXGK337V.mjs";import{a}from"./chunk-5R6AGO3Z.mjs";var B=["orders","order","confirmation","result","myReturns","myReturn"];function P(e){return B.includes(e)}function f(e){return e?{name:"orders"}:{name:"email"}}function C(e,n){switch(n.type){case"SESSION_EXPIRED":return P(e.name)?{name:"email"}:e;case"CODE_SENT":return e.name==="email"?{name:"code"}:e;case"AUTHENTICATED":return e.name==="email"||e.name==="code"?{name:"orders"}:e;case"SELECT_ORDER":return e.name==="orders"?{name:"order",orderId:n.orderId}:e;case"REVIEW":return e.name==="order"?{name:"confirmation",orderId:e.orderId,items:n.items,note:n.note}:e;case"SUBMITTED":return e.name==="confirmation"?{name:"result",returnId:n.returnId}:e;case"OPEN_MY_RETURNS":return e.name==="orders"||e.name==="result"?{name:"myReturns"}:e;case"SELECT_RETURN":return e.name==="myReturns"?{name:"myReturn",returnId:n.returnId}:e;case"CONTINUE":return e.name==="result"?{name:"orders"}:e;case"BACK":switch(e.name){case"code":return{name:"email"};case"order":case"myReturns":return{name:"orders"};case"confirmation":return{name:"order",orderId:e.orderId,items:e.items,note:e.note};case"myReturn":return{name:"myReturns"};default:return e}}}var x={email:1,code:2,orders:3,order:4,confirmation:5,result:6},_=6;function O(e){return x[e]}import{useEffect as D,useReducer as A}from"react";import{jsx as o,jsxs as L}from"react/jsx-runtime";function g({current:e}){let n=i(),r=m("stepIndicator");return o("p",{"data-bitsnap-returns-slot":"stepIndicator",className:a("text-xs",r.className),style:r.style,children:n("stepIndicator",{current:e,total:_})})}function b({panelToken:e}){let{status:n}=d("BitsnapReturns"),[r,t]=A(C,f(!1));if(D(()=>{n==="authenticated"?t({type:"AUTHENTICATED"}):n==="anonymous"&&t({type:"SESSION_EXPIRED"})},[n]),n==="exchanging"||n==="hydrating"&&e)return o(c,{});let s=O(r.name);return L("div",{className:"flex flex-col gap-4",children:[s!=null&&o(g,{current:s}),r.name==="email"&&o(E,{onSubmitted:()=>t({type:"CODE_SENT"})}),r.name==="code"&&o(p,{onVerified:()=>t({type:"AUTHENTICATED"}),onBack:()=>t({type:"BACK"})}),r.name==="orders"&&o(S,{showLogout:!e,onSelectOrder:u=>t({type:"SELECT_ORDER",orderId:u}),onOpenMyReturns:()=>t({type:"OPEN_MY_RETURNS"})}),r.name==="order"&&o(l,{orderId:r.orderId,initialItems:r.items,initialNote:r.note,onBack:()=>t({type:"BACK"}),onContinue:({items:u,note:U})=>t({type:"REVIEW",items:u,note:U})}),r.name==="confirmation"&&o(y,{orderId:r.orderId,items:r.items,note:r.note,onBack:()=>t({type:"BACK"}),onSubmitted:u=>t({type:"SUBMITTED",returnId:u})}),r.name==="result"&&o(I,{returnId:r.returnId,onContinue:()=>t({type:"CONTINUE"}),onOpenMyReturns:()=>t({type:"OPEN_MY_RETURNS"})}),r.name==="myReturns"&&o(T,{onSelectReturn:u=>t({type:"SELECT_RETURN",returnId:u}),onBack:()=>t({type:"BACK"})}),r.name==="myReturn"&&o(N,{returnId:r.returnId,onBack:()=>t({type:"BACK"})})]})}function q(e){return o(R,{...e,children:o(b,{panelToken:e.panelAccessToken!=null&&e.panelAccessToken!==""})})}export{q as a};
|
|
2
|
-
//# sourceMappingURL=chunk-I3QXJJ7U.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/returns/state-machine.ts","../src/components/returns/BitsnapReturns.tsx"],"sourcesContent":["/** One line chosen for return. */\nexport type SelectedReturnLine = {\n lineId: string;\n quantity: number;\n};\n\n/** Where the default flow of `BitsnapReturns` currently is. */\nexport type ReturnsStep =\n | { name: \"email\" }\n | { name: \"code\" }\n | { name: \"orders\" }\n | {\n name: \"order\";\n orderId: string;\n /** Selection to restore when coming back from the confirmation. */\n items?: SelectedReturnLine[];\n note?: string;\n }\n | {\n name: \"confirmation\";\n orderId: string;\n items: SelectedReturnLine[];\n note: string;\n }\n | { name: \"result\"; returnId: string }\n | { name: \"myReturns\" }\n | { name: \"myReturn\"; returnId: string };\n\nexport type ReturnsStepName = ReturnsStep[\"name\"];\n\nexport type ReturnsStepEvent =\n /** A verification code was requested. */\n | { type: \"CODE_SENT\" }\n /** The session became valid: code verified, stored session or panel token. */\n | { type: \"AUTHENTICATED\" }\n /** The session was dropped by the backend, expiry or logout. */\n | { type: \"SESSION_EXPIRED\" }\n | { type: \"SELECT_ORDER\"; orderId: string }\n | { type: \"REVIEW\"; items: SelectedReturnLine[]; note: string }\n | { type: \"SUBMITTED\"; returnId: string }\n | { type: \"OPEN_MY_RETURNS\" }\n | { type: \"SELECT_RETURN\"; returnId: string }\n | { type: \"BACK\" }\n /** Leave the result screen for the order list. */\n | { type: \"CONTINUE\" };\n\nconst STEPS_WITH_SESSION: readonly ReturnsStepName[] = [\n \"orders\",\n \"order\",\n \"confirmation\",\n \"result\",\n \"myReturns\",\n \"myReturn\",\n];\n\n/** Steps that cannot be shown without a returns session. */\nexport function stepRequiresSession(step: ReturnsStepName): boolean {\n return STEPS_WITH_SESSION.includes(step);\n}\n\n/** Starts at the orders when a session exists, otherwise at the email. */\nexport function initialReturnsStep(hasSession: boolean): ReturnsStep {\n return hasSession ? { name: \"orders\" } : { name: \"email\" };\n}\n\n/**\n * Pure transition function of the default flow. Events that do not apply to\n * the current step leave it unchanged.\n */\nexport function reduceReturnsStep(\n step: ReturnsStep,\n event: ReturnsStepEvent,\n): ReturnsStep {\n switch (event.type) {\n case \"SESSION_EXPIRED\":\n // Email and code do not need a session; keep a pending verification.\n return stepRequiresSession(step.name) ? { name: \"email\" } : step;\n case \"CODE_SENT\":\n return step.name === \"email\" ? { name: \"code\" } : step;\n case \"AUTHENTICATED\":\n return step.name === \"email\" || step.name === \"code\"\n ? { name: \"orders\" }\n : step;\n case \"SELECT_ORDER\":\n return step.name === \"orders\"\n ? { name: \"order\", orderId: event.orderId }\n : step;\n case \"REVIEW\":\n return step.name === \"order\"\n ? {\n name: \"confirmation\",\n orderId: step.orderId,\n items: event.items,\n note: event.note,\n }\n : step;\n case \"SUBMITTED\":\n return step.name === \"confirmation\"\n ? { name: \"result\", returnId: event.returnId }\n : step;\n case \"OPEN_MY_RETURNS\":\n return step.name === \"orders\" || step.name === \"result\"\n ? { name: \"myReturns\" }\n : step;\n case \"SELECT_RETURN\":\n return step.name === \"myReturns\"\n ? { name: \"myReturn\", returnId: event.returnId }\n : step;\n case \"CONTINUE\":\n return step.name === \"result\" ? { name: \"orders\" } : step;\n case \"BACK\":\n switch (step.name) {\n case \"code\":\n return { name: \"email\" };\n case \"order\":\n case \"myReturns\":\n return { name: \"orders\" };\n case \"confirmation\":\n return {\n name: \"order\",\n orderId: step.orderId,\n items: step.items,\n note: step.note,\n };\n case \"myReturn\":\n return { name: \"myReturns\" };\n default:\n return step;\n }\n }\n}\n\nconst STEP_NUMBERS: Partial<Record<ReturnsStepName, number>> = {\n email: 1,\n code: 2,\n orders: 3,\n order: 4,\n confirmation: 5,\n result: 6,\n};\n\nexport const RETURNS_STEP_COUNT = 6;\n\n/** Position of a step in the return flow, `undefined` for the \"my returns\" views. */\nexport function returnsStepNumber(step: ReturnsStepName): number | undefined {\n return STEP_NUMBERS[step];\n}\n","import { useEffect, useReducer } from \"react\";\nimport { cn } from \"@/src/lib/utils\";\nimport { useReturnsSlot } from \"./appearance.context\";\nimport { ReturnsCodeStep, ReturnsEmailStep } from \"./AuthSteps\";\nimport { SkeletonRows } from \"./internal\";\nimport { ReturnsMyReturnDetail, ReturnsMyReturnsList } from \"./MyReturns\";\nimport {\n ReturnsConfirmation,\n ReturnsOrderDetail,\n ReturnsOrderList,\n ReturnsResult,\n} from \"./OrderSteps\";\nimport {\n ReturnsProvider,\n useReturnsContext,\n type ReturnsProviderProps,\n} from \"./ReturnsProvider\";\nimport {\n initialReturnsStep,\n reduceReturnsStep,\n RETURNS_STEP_COUNT,\n returnsStepNumber,\n} from \"./state-machine\";\nimport { useReturnsText } from \"./texts.context\";\n\nexport type BitsnapReturnsProps = Omit<ReturnsProviderProps, \"children\">;\n\nfunction StepIndicator({ current }: { current: number }) {\n const text = useReturnsText();\n const slot = useReturnsSlot(\"stepIndicator\");\n\n return (\n <p\n data-bitsnap-returns-slot=\"stepIndicator\"\n className={cn(\"text-xs\", slot.className)}\n style={slot.style}\n >\n {text(\"stepIndicator\", { current, total: RETURNS_STEP_COUNT })}\n </p>\n );\n}\n\n/** Default step router. All transitions come from the pure state machine. */\nfunction ReturnsRouter({ panelToken }: { panelToken: boolean }) {\n const { status } = useReturnsContext(\"BitsnapReturns\");\n const [step, dispatch] = useReducer(\n reduceReturnsStep,\n initialReturnsStep(false),\n );\n\n // A valid session (verified code, stored session, exchanged panel token)\n // moves on to the orders; a dropped one returns to the start.\n useEffect(() => {\n if (status === \"authenticated\") {\n dispatch({ type: \"AUTHENTICATED\" });\n } else if (status === \"anonymous\") {\n dispatch({ type: \"SESSION_EXPIRED\" });\n }\n }, [status]);\n\n // Without a panel token the server render and the first client render show\n // the email step; a stored session switches to the orders after hydration.\n if (status === \"exchanging\" || (status === \"hydrating\" && panelToken)) {\n return <SkeletonRows />;\n }\n\n const stepNumber = returnsStepNumber(step.name);\n\n return (\n <div className=\"flex flex-col gap-4\">\n {stepNumber != null && <StepIndicator current={stepNumber} />}\n {step.name === \"email\" && (\n <ReturnsEmailStep onSubmitted={() => dispatch({ type: \"CODE_SENT\" })} />\n )}\n {step.name === \"code\" && (\n <ReturnsCodeStep\n onVerified={() => dispatch({ type: \"AUTHENTICATED\" })}\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n {step.name === \"orders\" && (\n <ReturnsOrderList\n showLogout={!panelToken}\n onSelectOrder={(orderId) =>\n dispatch({ type: \"SELECT_ORDER\", orderId })\n }\n onOpenMyReturns={() => dispatch({ type: \"OPEN_MY_RETURNS\" })}\n />\n )}\n {step.name === \"order\" && (\n <ReturnsOrderDetail\n orderId={step.orderId}\n initialItems={step.items}\n initialNote={step.note}\n onBack={() => dispatch({ type: \"BACK\" })}\n onContinue={({ items, note }) =>\n dispatch({ type: \"REVIEW\", items, note })\n }\n />\n )}\n {step.name === \"confirmation\" && (\n <ReturnsConfirmation\n orderId={step.orderId}\n items={step.items}\n note={step.note}\n onBack={() => dispatch({ type: \"BACK\" })}\n onSubmitted={(returnId) =>\n dispatch({ type: \"SUBMITTED\", returnId })\n }\n />\n )}\n {step.name === \"result\" && (\n <ReturnsResult\n returnId={step.returnId}\n onContinue={() => dispatch({ type: \"CONTINUE\" })}\n onOpenMyReturns={() => dispatch({ type: \"OPEN_MY_RETURNS\" })}\n />\n )}\n {step.name === \"myReturns\" && (\n <ReturnsMyReturnsList\n onSelectReturn={(returnId) =>\n dispatch({ type: \"SELECT_RETURN\", returnId })\n }\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n {step.name === \"myReturn\" && (\n <ReturnsMyReturnDetail\n returnId={step.returnId}\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n </div>\n );\n}\n\n/**\n * Customer return flow: email, code, orders, line selection, confirmation and\n * result, plus the list of earlier returns. It is `ReturnsProvider` with the\n * default step router; compose your own page from the step components to\n * change the layout.\n *\n * ```tsx\n * <BitsnapReturns projectID=\"…\" appearance={brand} texts={{ emailStepTitle: \"Return a product\" }} />\n * ```\n */\nexport function BitsnapReturns(props: BitsnapReturnsProps) {\n return (\n <ReturnsProvider {...props}>\n <ReturnsRouter panelToken={props.panelAccessToken != null && props.panelAccessToken !== \"\"} />\n </ReturnsProvider>\n );\n}\n"],"mappings":"4JA8CA,IAAMA,EAAiD,CACrD,SACA,QACA,eACA,SACA,YACA,UACF,EAGO,SAASC,EAAoBC,EAAgC,CAClE,OAAOF,EAAmB,SAASE,CAAI,CACzC,CAGO,SAASC,EAAmBC,EAAkC,CACnE,OAAOA,EAAa,CAAE,KAAM,QAAS,EAAI,CAAE,KAAM,OAAQ,CAC3D,CAMO,SAASC,EACdH,EACAI,EACa,CACb,OAAQA,EAAM,KAAM,CAClB,IAAK,kBAEH,OAAOL,EAAoBC,EAAK,IAAI,EAAI,CAAE,KAAM,OAAQ,EAAIA,EAC9D,IAAK,YACH,OAAOA,EAAK,OAAS,QAAU,CAAE,KAAM,MAAO,EAAIA,EACpD,IAAK,gBACH,OAAOA,EAAK,OAAS,SAAWA,EAAK,OAAS,OAC1C,CAAE,KAAM,QAAS,EACjBA,EACN,IAAK,eACH,OAAOA,EAAK,OAAS,SACjB,CAAE,KAAM,QAAS,QAASI,EAAM,OAAQ,EACxCJ,EACN,IAAK,SACH,OAAOA,EAAK,OAAS,QACjB,CACE,KAAM,eACN,QAASA,EAAK,QACd,MAAOI,EAAM,MACb,KAAMA,EAAM,IACd,EACAJ,EACN,IAAK,YACH,OAAOA,EAAK,OAAS,eACjB,CAAE,KAA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AC,EACvC,YAAcgB,GACZhB,EAAS,CAAE,KAAM,YAAa,SAAAgB,CAAS,CAAC,EAE5C,EAEDjB,EAAK,OAAS,UACbd,EAACgC,EAAA,CACC,SAAUlB,EAAK,SACf,WAAY,IAAMC,EAAS,CAAE,KAAM,UAAW,CAAC,EAC/C,gBAAiB,IAAMA,EAAS,CAAE,KAAM,iBAAkB,CAAC,EAC7D,EAEDD,EAAK,OAAS,aACbd,EAACiC,EAAA,CACC,eAAiBF,GACfhB,EAAS,CAAE,KAAM,gBAAiB,SAAAgB,CAAS,CAAC,EAE9C,OAAQ,IAAMhB,EAAS,CAAE,KAAM,MAAO,CAAC,EACzC,EAEDD,EAAK,OAAS,YACbd,EAACkC,EAAA,CACC,SAAUpB,EAAK,SACf,OAAQ,IAAMC,EAAS,CAAE,KAAM,MAAO,CAAC,EACzC,GAEJ,CAEJ,CAYO,SAASoB,EAAeC,EAA4B,CACzD,OACEpC,EAACqC,EAAA,CAAiB,GAAGD,EACnB,SAAApC,EAACU,EAAA,CAAc,WAAY0B,EAAM,kBAAoB,MAAQA,EAAM,mBAAqB,GAAI,EAC9F,CAEJ","names":["STEPS_WITH_SESSION","stepRequiresSession","step","initialReturnsStep","hasSession","reduceReturnsStep","event","STEP_NUMBERS","RETURNS_STEP_COUNT","returnsStepNumber","useEffect","useReducer","jsx","jsxs","StepIndicator","current","text","useReturnsText","slot","useReturnsSlot","cn","RETURNS_STEP_COUNT","ReturnsRouter","panelToken","status","useReturnsContext","step","dispatch","useReducer","reduceReturnsStep","initialReturnsStep","useEffect","SkeletonRows","stepNumber","returnsStepNumber","ReturnsEmailStep","ReturnsCodeStep","ReturnsOrderList","orderId","ReturnsOrderDetail","items","note","ReturnsConfirmation","returnId","ReturnsResult","ReturnsMyReturnsList","ReturnsMyReturnDetail","BitsnapReturns","props","ReturnsProvider"]}
|
package/dist/chunk-LL7ASBGY.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQERYM7RCjs = require('./chunk-QERYM7RC.js');var _chunkGXUNRJ5Sjs = require('./chunk-GXUNRJ5S.js');var B=["orders","order","confirmation","result","myReturns","myReturn"];function P(e){return B.includes(e)}function f(e){return e?{name:"orders"}:{name:"email"}}function C(e,n){switch(n.type){case"SESSION_EXPIRED":return P(e.name)?{name:"email"}:e;case"CODE_SENT":return e.name==="email"?{name:"code"}:e;case"AUTHENTICATED":return e.name==="email"||e.name==="code"?{name:"orders"}:e;case"SELECT_ORDER":return e.name==="orders"?{name:"order",orderId:n.orderId}:e;case"REVIEW":return e.name==="order"?{name:"confirmation",orderId:e.orderId,items:n.items,note:n.note}:e;case"SUBMITTED":return e.name==="confirmation"?{name:"result",returnId:n.returnId}:e;case"OPEN_MY_RETURNS":return e.name==="orders"||e.name==="result"?{name:"myReturns"}:e;case"SELECT_RETURN":return e.name==="myReturns"?{name:"myReturn",returnId:n.returnId}:e;case"CONTINUE":return e.name==="result"?{name:"orders"}:e;case"BACK":switch(e.name){case"code":return{name:"email"};case"order":case"myReturns":return{name:"orders"};case"confirmation":return{name:"order",orderId:e.orderId,items:e.items,note:e.note};case"myReturn":return{name:"myReturns"};default:return e}}}var x={email:1,code:2,orders:3,order:4,confirmation:5,result:6},_=6;function O(e){return x[e]}var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function g({current:e}){let n=_chunkQERYM7RCjs.i.call(void 0, ),r=_chunkQERYM7RCjs.f.call(void 0, "stepIndicator");return _jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"stepIndicator",className:_chunkGXUNRJ5Sjs.d.call(void 0, "text-xs",r.className),style:r.style,children:n("stepIndicator",{current:e,total:_})})}function b({panelToken:e}){let{status:n}=_chunkQERYM7RCjs.j.call(void 0, "BitsnapReturns"),[r,t]=_react.useReducer.call(void 0, C,f(!1));if(_react.useEffect.call(void 0, ()=>{n==="authenticated"?t({type:"AUTHENTICATED"}):n==="anonymous"&&t({type:"SESSION_EXPIRED"})},[n]),n==="exchanging"||n==="hydrating"&&e)return _jsxruntime.jsx.call(void 0, _chunkQERYM7RCjs.s,{});let s=O(r.name);return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-4",children:[s!=null&&_jsxruntime.jsx.call(void 0, g,{current:s}),r.name==="email"&&_jsxruntime.jsx.call(void 0, _chunkQERYM7RCjs.t,{onSubmitted:()=>t({type:"CODE_SENT"})}),r.name==="code"&&_jsxruntime.jsx.call(void 0, _chunkQERYM7RCjs.u,{onVerified:()=>t({type:"AUTHENTICATED"}),onBack:()=>t({type:"BACK"})}),r.name==="orders"&&_jsxruntime.jsx.call(void 0, _chunkQERYM7RCjs.v,{showLogout:!e,onSelectOrder:u=>t({type:"SELECT_ORDER",orderId:u}),onOpenMyReturns:()=>t({type:"OPEN_MY_RETURNS"})}),r.name==="order"&&_jsxruntime.jsx.call(void 0, _chunkQERYM7RCjs.w,{orderId:r.orderId,initialItems:r.items,initialNote:r.note,onBack:()=>t({type:"BACK"}),onContinue:({items:u,note:U})=>t({type:"REVIEW",items:u,note:U})}),r.name==="confirmation"&&_jsxruntime.jsx.call(void 0, _chunkQERYM7RCjs.x,{orderId:r.orderId,items:r.items,note:r.note,onBack:()=>t({type:"BACK"}),onSubmitted:u=>t({type:"SUBMITTED",returnId:u})}),r.name==="result"&&_jsxruntime.jsx.call(void 0, _chunkQERYM7RCjs.y,{returnId:r.returnId,onContinue:()=>t({type:"CONTINUE"}),onOpenMyReturns:()=>t({type:"OPEN_MY_RETURNS"})}),r.name==="myReturns"&&_jsxruntime.jsx.call(void 0, _chunkQERYM7RCjs.z,{onSelectReturn:u=>t({type:"SELECT_RETURN",returnId:u}),onBack:()=>t({type:"BACK"})}),r.name==="myReturn"&&_jsxruntime.jsx.call(void 0, _chunkQERYM7RCjs.A,{returnId:r.returnId,onBack:()=>t({type:"BACK"})})]})}function q(e){return _jsxruntime.jsx.call(void 0, _chunkQERYM7RCjs.k,{...e,children:_jsxruntime.jsx.call(void 0, b,{panelToken:e.panelAccessToken!=null&&e.panelAccessToken!==""})})}exports.a = q;
|
|
2
|
-
//# sourceMappingURL=chunk-LL7ASBGY.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-LL7ASBGY.js","../src/components/returns/state-machine.ts","../src/components/returns/BitsnapReturns.tsx"],"names":["STEPS_WITH_SESSION","stepRequiresSession","step","initialReturnsStep","hasSession","reduceReturnsStep","event","STEP_NUMBERS","RETURNS_STEP_COUNT","returnsStepNumber","StepIndicator","current","text","useReturnsText","slot","useReturnsSlot","jsx","cn","ReturnsRouter","panelToken","status","useReturnsContext","dispatch","useReducer","useEffect","SkeletonRows","stepNumber","jsxs","ReturnsEmailStep","ReturnsCodeStep","ReturnsOrderList","orderId","ReturnsOrderDetail","items","note","ReturnsConfirmation","returnId","ReturnsResult","ReturnsMyReturnsList","ReturnsMyReturnDetail","BitsnapReturns","props","ReturnsProvider"],"mappings":"AAAA,+HAAsH,sDAAwC,IC8CxJA,CAAAA,CAAiD,CACrD,QAAA,CACA,OAAA,CACA,cAAA,CACA,QAAA,CACA,WAAA,CACA,UACF,CAAA,CAGO,SAASC,CAAAA,CAAoBC,CAAAA,CAAgC,CAClE,OAAOF,CAAAA,CAAmB,QAAA,CAASE,CAAI,CACzC,CAGO,SAASC,CAAAA,CAAmBC,CAAAA,CAAkC,CACnE,OAAOA,CAAAA,CAAa,CAAE,IAAA,CAAM,QAAS,CAAA,CAAI,CAAE,IAAA,CAAM,OAAQ,CAC3D,CAMO,SAASC,CAAAA,CACdH,CAAAA,CACAI,CAAAA,CACa,CACb,MAAA,CAAQA,CAAAA,CAAM,IAAA,CAAM,CAClB,IAAK,iBAAA,CAEH,OAAOL,CAAAA,CAAoBC,CAAAA,CAAK,IAAI,CAAA,CAAI,CAAE,IAAA,CAAM,OAAQ,CAAA,CAAIA,CAAAA,CAC9D,IAAK,WAAA,CACH,OAAOA,CAAA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AAUnC,CAAAA,CAAK,QAAA,CACf,UAAA,CAAY,CAAA,CAAA,EAAMoB,CAAAA,CAAS,CAAE,IAAA,CAAM,UAAW,CAAC,CAAA,CAC/C,eAAA,CAAiB,CAAA,CAAA,EAAMA,CAAAA,CAAS,CAAE,IAAA,CAAM,iBAAkB,CAAC,CAAA,CAC7D,CAAA,CAEDpB,CAAAA,CAAK,IAAA,GAAS,WAAA,EACbc,6BAAAA,kBAACsB,CAAA,CACC,cAAA,CAAiBF,CAAAA,EACfd,CAAAA,CAAS,CAAE,IAAA,CAAM,eAAA,CAAiB,QAAA,CAAAc,CAAS,CAAC,CAAA,CAE9C,MAAA,CAAQ,CAAA,CAAA,EAAMd,CAAAA,CAAS,CAAE,IAAA,CAAM,MAAO,CAAC,CAAA,CACzC,CAAA,CAEDpB,CAAAA,CAAK,IAAA,GAAS,UAAA,EACbc,6BAAAA,kBAACuB,CAAA,CACC,QAAA,CAAUrC,CAAAA,CAAK,QAAA,CACf,MAAA,CAAQ,CAAA,CAAA,EAAMoB,CAAAA,CAAS,CAAE,IAAA,CAAM,MAAO,CAAC,CAAA,CACzC,CAAA,CAAA,CAEJ,CAEJ,CAYO,SAASkB,CAAAA,CAAeC,CAAAA,CAA4B,CACzD,OACEzB,6BAAAA,kBAAC0B,CAAA,CAAiB,GAAGD,CAAAA,CACnB,QAAA,CAAAzB,6BAAAA,CAACE,CAAA,CAAc,UAAA,CAAYuB,CAAAA,CAAM,gBAAA,EAAoB,IAAA,EAAQA,CAAAA,CAAM,gBAAA,GAAqB,EAAA,CAAI,CAAA,CAC9F,CAEJ,CAAA,cAAA","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-LL7ASBGY.js","sourcesContent":[null,"/** One line chosen for return. */\nexport type SelectedReturnLine = {\n lineId: string;\n quantity: number;\n};\n\n/** Where the default flow of `BitsnapReturns` currently is. */\nexport type ReturnsStep =\n | { name: \"email\" }\n | { name: \"code\" }\n | { name: \"orders\" }\n | {\n name: \"order\";\n orderId: string;\n /** Selection to restore when coming back from the confirmation. */\n items?: SelectedReturnLine[];\n note?: string;\n }\n | {\n name: \"confirmation\";\n orderId: string;\n items: SelectedReturnLine[];\n note: string;\n }\n | { name: \"result\"; returnId: string }\n | { name: \"myReturns\" }\n | { name: \"myReturn\"; returnId: string };\n\nexport type ReturnsStepName = ReturnsStep[\"name\"];\n\nexport type ReturnsStepEvent =\n /** A verification code was requested. */\n | { type: \"CODE_SENT\" }\n /** The session became valid: code verified, stored session or panel token. */\n | { type: \"AUTHENTICATED\" }\n /** The session was dropped by the backend, expiry or logout. */\n | { type: \"SESSION_EXPIRED\" }\n | { type: \"SELECT_ORDER\"; orderId: string }\n | { type: \"REVIEW\"; items: SelectedReturnLine[]; note: string }\n | { type: \"SUBMITTED\"; returnId: string }\n | { type: \"OPEN_MY_RETURNS\" }\n | { type: \"SELECT_RETURN\"; returnId: string }\n | { type: \"BACK\" }\n /** Leave the result screen for the order list. */\n | { type: \"CONTINUE\" };\n\nconst STEPS_WITH_SESSION: readonly ReturnsStepName[] = [\n \"orders\",\n \"order\",\n \"confirmation\",\n \"result\",\n \"myReturns\",\n \"myReturn\",\n];\n\n/** Steps that cannot be shown without a returns session. */\nexport function stepRequiresSession(step: ReturnsStepName): boolean {\n return STEPS_WITH_SESSION.includes(step);\n}\n\n/** Starts at the orders when a session exists, otherwise at the email. */\nexport function initialReturnsStep(hasSession: boolean): ReturnsStep {\n return hasSession ? { name: \"orders\" } : { name: \"email\" };\n}\n\n/**\n * Pure transition function of the default flow. Events that do not apply to\n * the current step leave it unchanged.\n */\nexport function reduceReturnsStep(\n step: ReturnsStep,\n event: ReturnsStepEvent,\n): ReturnsStep {\n switch (event.type) {\n case \"SESSION_EXPIRED\":\n // Email and code do not need a session; keep a pending verification.\n return stepRequiresSession(step.name) ? { name: \"email\" } : step;\n case \"CODE_SENT\":\n return step.name === \"email\" ? { name: \"code\" } : step;\n case \"AUTHENTICATED\":\n return step.name === \"email\" || step.name === \"code\"\n ? { name: \"orders\" }\n : step;\n case \"SELECT_ORDER\":\n return step.name === \"orders\"\n ? { name: \"order\", orderId: event.orderId }\n : step;\n case \"REVIEW\":\n return step.name === \"order\"\n ? {\n name: \"confirmation\",\n orderId: step.orderId,\n items: event.items,\n note: event.note,\n }\n : step;\n case \"SUBMITTED\":\n return step.name === \"confirmation\"\n ? { name: \"result\", returnId: event.returnId }\n : step;\n case \"OPEN_MY_RETURNS\":\n return step.name === \"orders\" || step.name === \"result\"\n ? { name: \"myReturns\" }\n : step;\n case \"SELECT_RETURN\":\n return step.name === \"myReturns\"\n ? { name: \"myReturn\", returnId: event.returnId }\n : step;\n case \"CONTINUE\":\n return step.name === \"result\" ? { name: \"orders\" } : step;\n case \"BACK\":\n switch (step.name) {\n case \"code\":\n return { name: \"email\" };\n case \"order\":\n case \"myReturns\":\n return { name: \"orders\" };\n case \"confirmation\":\n return {\n name: \"order\",\n orderId: step.orderId,\n items: step.items,\n note: step.note,\n };\n case \"myReturn\":\n return { name: \"myReturns\" };\n default:\n return step;\n }\n }\n}\n\nconst STEP_NUMBERS: Partial<Record<ReturnsStepName, number>> = {\n email: 1,\n code: 2,\n orders: 3,\n order: 4,\n confirmation: 5,\n result: 6,\n};\n\nexport const RETURNS_STEP_COUNT = 6;\n\n/** Position of a step in the return flow, `undefined` for the \"my returns\" views. */\nexport function returnsStepNumber(step: ReturnsStepName): number | undefined {\n return STEP_NUMBERS[step];\n}\n","import { useEffect, useReducer } from \"react\";\nimport { cn } from \"@/src/lib/utils\";\nimport { useReturnsSlot } from \"./appearance.context\";\nimport { ReturnsCodeStep, ReturnsEmailStep } from \"./AuthSteps\";\nimport { SkeletonRows } from \"./internal\";\nimport { ReturnsMyReturnDetail, ReturnsMyReturnsList } from \"./MyReturns\";\nimport {\n ReturnsConfirmation,\n ReturnsOrderDetail,\n ReturnsOrderList,\n ReturnsResult,\n} from \"./OrderSteps\";\nimport {\n ReturnsProvider,\n useReturnsContext,\n type ReturnsProviderProps,\n} from \"./ReturnsProvider\";\nimport {\n initialReturnsStep,\n reduceReturnsStep,\n RETURNS_STEP_COUNT,\n returnsStepNumber,\n} from \"./state-machine\";\nimport { useReturnsText } from \"./texts.context\";\n\nexport type BitsnapReturnsProps = Omit<ReturnsProviderProps, \"children\">;\n\nfunction StepIndicator({ current }: { current: number }) {\n const text = useReturnsText();\n const slot = useReturnsSlot(\"stepIndicator\");\n\n return (\n <p\n data-bitsnap-returns-slot=\"stepIndicator\"\n className={cn(\"text-xs\", slot.className)}\n style={slot.style}\n >\n {text(\"stepIndicator\", { current, total: RETURNS_STEP_COUNT })}\n </p>\n );\n}\n\n/** Default step router. All transitions come from the pure state machine. */\nfunction ReturnsRouter({ panelToken }: { panelToken: boolean }) {\n const { status } = useReturnsContext(\"BitsnapReturns\");\n const [step, dispatch] = useReducer(\n reduceReturnsStep,\n initialReturnsStep(false),\n );\n\n // A valid session (verified code, stored session, exchanged panel token)\n // moves on to the orders; a dropped one returns to the start.\n useEffect(() => {\n if (status === \"authenticated\") {\n dispatch({ type: \"AUTHENTICATED\" });\n } else if (status === \"anonymous\") {\n dispatch({ type: \"SESSION_EXPIRED\" });\n }\n }, [status]);\n\n // Without a panel token the server render and the first client render show\n // the email step; a stored session switches to the orders after hydration.\n if (status === \"exchanging\" || (status === \"hydrating\" && panelToken)) {\n return <SkeletonRows />;\n }\n\n const stepNumber = returnsStepNumber(step.name);\n\n return (\n <div className=\"flex flex-col gap-4\">\n {stepNumber != null && <StepIndicator current={stepNumber} />}\n {step.name === \"email\" && (\n <ReturnsEmailStep onSubmitted={() => dispatch({ type: \"CODE_SENT\" })} />\n )}\n {step.name === \"code\" && (\n <ReturnsCodeStep\n onVerified={() => dispatch({ type: \"AUTHENTICATED\" })}\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n {step.name === \"orders\" && (\n <ReturnsOrderList\n showLogout={!panelToken}\n onSelectOrder={(orderId) =>\n dispatch({ type: \"SELECT_ORDER\", orderId })\n }\n onOpenMyReturns={() => dispatch({ type: \"OPEN_MY_RETURNS\" })}\n />\n )}\n {step.name === \"order\" && (\n <ReturnsOrderDetail\n orderId={step.orderId}\n initialItems={step.items}\n initialNote={step.note}\n onBack={() => dispatch({ type: \"BACK\" })}\n onContinue={({ items, note }) =>\n dispatch({ type: \"REVIEW\", items, note })\n }\n />\n )}\n {step.name === \"confirmation\" && (\n <ReturnsConfirmation\n orderId={step.orderId}\n items={step.items}\n note={step.note}\n onBack={() => dispatch({ type: \"BACK\" })}\n onSubmitted={(returnId) =>\n dispatch({ type: \"SUBMITTED\", returnId })\n }\n />\n )}\n {step.name === \"result\" && (\n <ReturnsResult\n returnId={step.returnId}\n onContinue={() => dispatch({ type: \"CONTINUE\" })}\n onOpenMyReturns={() => dispatch({ type: \"OPEN_MY_RETURNS\" })}\n />\n )}\n {step.name === \"myReturns\" && (\n <ReturnsMyReturnsList\n onSelectReturn={(returnId) =>\n dispatch({ type: \"SELECT_RETURN\", returnId })\n }\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n {step.name === \"myReturn\" && (\n <ReturnsMyReturnDetail\n returnId={step.returnId}\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n </div>\n );\n}\n\n/**\n * Customer return flow: email, code, orders, line selection, confirmation and\n * result, plus the list of earlier returns. It is `ReturnsProvider` with the\n * default step router; compose your own page from the step components to\n * change the layout.\n *\n * ```tsx\n * <BitsnapReturns projectID=\"…\" appearance={brand} texts={{ emailStepTitle: \"Return a product\" }} />\n * ```\n */\nexport function BitsnapReturns(props: BitsnapReturnsProps) {\n return (\n <ReturnsProvider {...props}>\n <ReturnsRouter panelToken={props.panelAccessToken != null && props.panelAccessToken !== \"\"} />\n </ReturnsProvider>\n );\n}\n"]}
|
package/dist/chunk-OZHXRKMX.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkKOYBZORLjs = require('./chunk-KOYBZORL.js');var _chunkGXUNRJ5Sjs = require('./chunk-GXUNRJ5S.js');var _chunkGQJDFLSLjs = require('./chunk-GQJDFLSL.js');var _chunk7RXW6XFYjs = require('./chunk-7RXW6XFY.js');var wt=["root","grid","card","cardLink","image","imagePlaceholder","body","name","description","price","comparePrice","badge","model3dBadge","actions","addToCartButton","selectButton","message","pagination","paginationButton","pageIndicator","emptyState","error","retryButton","skeleton"],Dt={fontFamily:"--bitsnap-products-font-family",fontSize:"--bitsnap-products-font-size",background:"--bitsnap-products-background",surface:"--bitsnap-products-surface",foreground:"--bitsnap-products-foreground",mutedForeground:"--bitsnap-products-muted-foreground",border:"--bitsnap-products-border",buttonBackground:"--bitsnap-products-button-background",buttonForeground:"--bitsnap-products-button-foreground",buttonHoverBackground:"--bitsnap-products-button-hover-background",hoverSurface:"--bitsnap-products-hover-surface",focusRing:"--bitsnap-products-focus-ring",error:"--bitsnap-products-error",badgeBackground:"--bitsnap-products-badge-background",badgeForeground:"--bitsnap-products-badge-foreground",radius:"--bitsnap-products-radius"},Et={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",radius:"8px"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",radius:"8px"}},_t=[];function pt(t){let e=_chunkKOYBZORLjs.a.call(void 0, t,{defaultTheme:"light",presets:Et,variables:Dt,shadcnVariables:_t});return{theme:e.theme,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle}}function G(t,e){return _chunkKOYBZORLjs.b.call(void 0, t.elements,e)}function mt(t,e){try{return new Intl.NumberFormat(t,{style:"currency",currency:e,currencyDisplay:"symbol"})}catch (e2){return}}function H(t,e,r=_chunk7RXW6XFYjs.d){let o=t/100,s=_nullishCoalesce(mt(r,e), () => (mt(_chunk7RXW6XFYjs.d,e)));return s!=null?s.format(o):`${o.toFixed(2)} ${e}`}var _react = require('react');var Nt=24,Ot=48,z=class extends Error{constructor(e,r){super(e),this.name="ProductListError",this.status=r}};function O(t){return t==null||!Number.isFinite(t)?Nt:Math.min(Ot,Math.max(1,Math.floor(t)))}function gt(t,e){return Math.max(1,Math.ceil(t/e))}function B(t){return t.replace(/\/+$/,"")}function Bt(t){let e=new URLSearchParams;e.set("limit",String(t.limit)),e.set("offset",String(t.offset)),t.locale&&e.set("locale",t.locale);let r=_optionalChain([t, 'access', _2 => _2.search, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]);return r&&e.set("search",r),`${B(t.host)}/api/integrations/${encodeURIComponent(t.projectID)}/public-commerce/product-list?${e.toString()}`}function Rt(t){return typeof t=="object"&&t!=null&&Array.isArray(t.items)&&typeof t.totalCount=="number"}async function ft(t,e){let r=await fetch(_chunkGXUNRJ5Sjs.c.call(void 0, Bt(t)),{method:"GET",credentials:"omit",headers:{Accept:"application/json"},signal:e});if(!r.ok)throw new z(`Could not load products (${r.status})`,r.status);let o=await r.json();if(!Rt(o))throw new z("Unexpected product list response");return o}function Z(t){let{projectID:e,locale:r,search:o,initialData:s}=t,[n]=_react.useState.call(void 0, ()=>_chunkGXUNRJ5Sjs.f),i=_nullishCoalesce(t.host, () => (n)),d=O(t.pageSize),c=JSON.stringify([e,i,_nullishCoalesce(r, () => (null)),_nullishCoalesce(_optionalChain([o, 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]), () => (null)),d]),[m,l]=_react.useState.call(void 0, {queryKey:c,page:1});m.queryKey!==c&&l({queryKey:c,page:1});let[P,T]=_react.useState.call(void 0, 0),[g,p]=_react.useState.call(void 0, ()=>({requestKey:s!=null?`${c}|1|0`:"",data:s,error:void 0})),f=_nullishCoalesce(_optionalChain([g, 'access', _7 => _7.data, 'optionalAccess', _8 => _8.totalCount]), () => (0)),b=gt(f,d),x=m.queryKey===c?m.page:1,k=f>0?Math.min(x,b):x,S=`${c}|${k}|${P}`,C=g.requestKey===S;_react.useEffect.call(void 0, ()=>{if(C)return;let y=new AbortController;return ft({projectID:e,host:i,locale:r,search:o,limit:d,offset:(k-1)*d},y.signal).then(L=>{y.signal.aborted||p({requestKey:S,data:L,error:void 0})},L=>{y.signal.aborted||p(D=>({requestKey:S,data:D.data,error:L instanceof Error?L:new Error(String(L))}))}),()=>y.abort()},[S,C]);let w=_react.useCallback.call(void 0, y=>{let L=Math.max(1,Math.floor(y));l({queryKey:c,page:f>0?Math.min(L,b):L})},[c,f,b]),A=_react.useCallback.call(void 0, ()=>T(y=>y+1),[]);return _react.useMemo.call(void 0, ()=>({products:_nullishCoalesce(_optionalChain([g, 'access', _9 => _9.data, 'optionalAccess', _10 => _10.items]), () => ([])),totalCount:f,page:k,pageCount:b,setPage:w,isLoading:!C,error:C?g.error:void 0,refetch:A}),[g,f,k,b,w,C,A])}function Pt(t,e){if(t.projectID!=null&&t.projectID!==e.projectID)return{ok:!1,reason:`the page cart already belongs to project "${t.projectID}"`};let r=null,o=e.host?B(e.host):"",s=B(t.host);if(o&&o!==s){if(s!==B(t.defaultHost))return{ok:!1,reason:`the page cart already uses the host "${t.host}"`};r=o}return{ok:!0,setProjectID:t.projectID==null?e.projectID:null,setHost:r}}function Q(t,e){let r=e.cartItemId!=null&&e.cartItemId!==e.id?e.cartItemId:null;t.track("add_to_cart",{qty:1,value_minor:e.price,currency:e.currency},{product_id:e.id,variant_id:r})}async function yt(t,e){let[{Bitsnap:r},{getProjectID:o,setProjectID:s}]=await Promise.all([Promise.resolve().then(() => _interopRequireWildcard(require("./methods-WRONKK3D.js"))),Promise.resolve().then(() => _interopRequireWildcard(require("./CartProvider-VGZMDVFJ.js")))]),n=Pt({projectID:o(),host:_chunkGXUNRJ5Sjs.f,defaultHost:_chunkGXUNRJ5Sjs.e},e);if(!n.ok)return Ut(n.reason);if(n.setProjectID!=null&&s(n.setProjectID),n.setHost!=null&&_chunkGXUNRJ5Sjs.g.call(void 0, n.setHost),await r.addProductToCart(_nullishCoalesce(t.cartItemId, () => (t.id)),1,void 0,{url:e.url,name:t.name,price:t.price,currency:t.currency,analytics:_chunkGQJDFLSLjs.k})!=null)throw new Error("Could not add the product to the cart");e.analytics!=null&&Q(e.analytics,t),e.showCart&&r.showCart()}function Ut(t){throw console.warn(`bitsnap-react: ProductList did not add to the cart because ${t}. Pass onAddToCart to use another cart.`),new Error("The page cart belongs to another project or host")}var K=50,Mt=1e3;function Lt(t,e=Mt){let r=new Set,o=new Map,s=[],n=[],i,d,c=!1;function m(){for(d!==void 0&&clearTimeout(d),d=void 0;s.length>0;){let p=s.slice(0,K),f=n.slice(0,K);s=s.slice(K),n=n.slice(K);try{t({productIds:p,positions:f})}catch (e3){}}}function l(){m();try{_optionalChain([_chunkGQJDFLSLjs.f.call(void 0, ), 'optionalAccess', _11 => _11.flush, 'call', _12 => _12()])}catch (e4){}}let P=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&l()};function T(){c||typeof window>"u"||(c=!0,window.addEventListener("pagehide",l,!0),document.addEventListener("visibilitychange",P,!0))}function g(){if(i)return i;if(!(typeof IntersectionObserver>"u"))return i=new IntersectionObserver(p=>{for(let f of p){let b=o.get(f.target);!b||!f.isIntersecting||f.intersectionRatio<.5||(o.delete(f.target),_optionalChain([i, 'optionalAccess', _13 => _13.unobserve, 'call', _14 => _14(f.target)]),!r.has(b.id)&&(r.add(b.id),s.push(b.id),n.push(b.position)))}s.length>0&&d===void 0&&(d=setTimeout(m,e),_optionalChain([d, 'access', _15 => _15.unref, 'optionalCall', _16 => _16()]))},{threshold:[.5]}),T(),i}return{observe(p,f,b){try{if(r.has(f))return()=>{};let x=g();return x?(o.set(p,{id:f,position:b}),x.observe(p),()=>{o.delete(p),x.unobserve(p)}):()=>{}}catch (e5){return()=>{}}},flush:m,destroy(){try{m(),_optionalChain([i, 'optionalAccess', _17 => _17.disconnect, 'call', _18 => _18()]),c&&(window.removeEventListener("pagehide",l,!0),document.removeEventListener("visibilitychange",P,!0),c=!1)}catch (e6){}i=void 0,o.clear()}}}var Ht={en:{addToCart:"Add to cart",addingToCart:"Adding\u2026",addedToCart:"Added to cart",addToCartError:"Could not add to the cart. Try again.",chooseOptions:"Choose",viewProduct:"View",unavailable:"Unavailable",subscription:"Subscription",model3d:"3D",model3dLabel:"3D model",priceFrom:"from {price}",originalPrice:"Original price",loading:"Loading products",empty:"There are no products to show.",error:"Could not load the products.",retry:"Try again",pagination:"Pagination",previousPage:"Previous",nextPage:"Next",pageOf:"Page {page} of {pageCount}"},pl:{addToCart:"Dodaj do koszyka",addingToCart:"Dodawanie\u2026",addedToCart:"Dodano do koszyka",addToCartError:"Nie uda\u0142o si\u0119 doda\u0107 do koszyka. Spr\xF3buj ponownie.",chooseOptions:"Wybierz",viewProduct:"Zobacz",unavailable:"Niedost\u0119pny",subscription:"Subskrypcja",model3d:"3D",model3dLabel:"Model 3D",priceFrom:"od {price}",originalPrice:"Cena przed obni\u017Ck\u0105",loading:"\u0141adowanie produkt\xF3w",empty:"Brak produkt\xF3w do wy\u015Bwietlenia.",error:"Nie uda\u0142o si\u0119 za\u0142adowa\u0107 produkt\xF3w.",retry:"Spr\xF3buj ponownie",pagination:"Paginacja",previousPage:"Poprzednia",nextPage:"Nast\u0119pna",pageOf:"Strona {page} z {pageCount}"}};function ht(t,e){return _chunk7RXW6XFYjs.b.call(void 0, Ht,t,e)}function X(t,e){return t.replace(/\{(\w+)\}/g,(r,o)=>o in e?String(e[o]):r)}var _jsxruntime = require('react/jsx-runtime');var Ct=_react.createContext.call(void 0, void 0),$t={observe:()=>()=>{},clicked:()=>{}},Tt=_react.createContext.call(void 0, $t);function F(){let t=_react.useContext.call(void 0, Ct);if(t==null)throw new Error("ProductList parts must be rendered inside ProductList");return t}function u(t,e){let{appearance:r}=F(),o=G(r,t);return{"data-bitsnap-products-slot":t,className:_chunkGXUNRJ5Sjs.d.call(void 0, e,_optionalChain([o, 'optionalAccess', _19 => _19.className])),style:_optionalChain([o, 'optionalAccess', _20 => _20.style])}}var W="inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50",St=`${W} w-full`,Kt=`${St} no-underline`;function Vt({product:t,onAdd:e}){let{texts:r}=F(),[o,s]=_react.useState.call(void 0, "idle"),n=u("addToCartButton",St),i=u("message","mt-2 text-xs");_react.useEffect.call(void 0, ()=>{if(o!=="added")return;let m=setTimeout(()=>s("idle"),2e3);return()=>clearTimeout(m)},[o]);let d=_react.useCallback.call(void 0, async()=>{s("adding");try{await e(),s("added")}catch(m){console.error("bitsnap-react: could not add to the cart",m),s("error")}},[e]),c=o==="adding"?r.addingToCart:o==="added"?r.addedToCart:r.addToCart;return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",...n,disabled:o==="adding","aria-label":`${c}: ${t.name}`,onClick:d,children:c}),o==="error"?_jsxruntime.jsx.call(void 0, "p",{...i,role:"alert",children:r.addToCartError}):null]})}function qt({product:t,position:e,href:r,onAdd:o,renderItem:s}){let{texts:n,locale:i}=F(),d=_react.useContext.call(void 0, Tt),c=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>{if(c.current!=null)return d.observe(c.current,t.id,e)},[d,t.id,e]);let m=_react.useCallback.call(void 0, ()=>d.clicked(t,e),[d,t,e]),l=u("card","relative flex flex-col overflow-hidden border transition-colors"),P=u("cardLink","flex flex-1 flex-col no-underline"),T=u("image","aspect-square w-full overflow-hidden"),g=u("imagePlaceholder","aspect-square w-full"),p=u("body","flex flex-1 flex-col gap-1 p-4"),f=u("name","text-base font-medium leading-snug"),b=u("description","line-clamp-2 text-sm"),x=u("price","mt-auto pt-2 text-base font-semibold"),k=u("comparePrice","ml-2 text-sm font-normal"),S=u("badge","absolute left-3 top-3 px-2 py-0.5 text-xs font-medium"),C=u("model3dBadge","absolute right-3 top-3 inline-flex items-center gap-1 px-2 py-0.5 text-xs font-semibold"),w=u("actions","p-4 pt-0"),A=u("selectButton",Kt),y=H(t.price,t.currency,i),L=t.compareAtPrice!=null&&t.compareAtPrice>t.price?H(t.compareAtPrice,t.currency,i):null;if(s!=null)return _jsxruntime.jsx.call(void 0, "li",{ref:c,...l,"data-unavailable":t.available?void 0:"",children:s(t,{href:r,price:y,compareAtPrice:L,texts:n,locale:i,addToCart:o,trackClick:m})});let D=_nullishCoalesce(_optionalChain([t, 'access', _21 => _21.image, 'optionalAccess', _22 => _22.thumbnailUrl]), () => (_optionalChain([t, 'access', _23 => _23.image, 'optionalAccess', _24 => _24.url]))),E=t.available?t.isRecurring?n.subscription:null:n.unavailable;return _jsxruntime.jsxs.call(void 0, "li",{ref:c,...l,"data-unavailable":t.available?void 0:"",children:[_jsxruntime.jsxs.call(void 0, "a",{...P,href:r,onClick:m,children:[D!=null?_jsxruntime.jsx.call(void 0, "div",{...T,children:_jsxruntime.jsx.call(void 0, "img",{src:D,alt:"",loading:"lazy",decoding:"async",className:"h-full w-full object-cover"})}):_jsxruntime.jsx.call(void 0, "div",{...g,"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{...p,children:[_jsxruntime.jsx.call(void 0, "h3",{...f,children:t.name}),t.shortDescription?_jsxruntime.jsx.call(void 0, "p",{...b,children:t.shortDescription}):null,_jsxruntime.jsxs.call(void 0, "p",{...x,children:[t.priceFrom?X(n.priceFrom,{price:y}):y,L!=null?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "span",{className:"sr-only",children:[n.originalPrice,": "]}),_jsxruntime.jsx.call(void 0, "del",{...k,children:L})]}):null]})]})]}),E!=null?_jsxruntime.jsx.call(void 0, "span",{...S,"data-kind":t.available?"subscription":"unavailable",children:E}):null,t.has3d===!0?_jsxruntime.jsxs.call(void 0, "span",{...C,title:n.model3dLabel,children:[_jsxruntime.jsx.call(void 0, Gt,{}),_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:n.model3d}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:n.model3dLabel})]}):null,_jsxruntime.jsx.call(void 0, "div",{...w,children:t.available?t.addToCart?_jsxruntime.jsx.call(void 0, Vt,{product:t,onAdd:o}):_jsxruntime.jsx.call(void 0, "a",{...A,href:r,onClick:m,children:t.variantCount>1?n.chooseOptions:n.viewProduct}):_jsxruntime.jsx.call(void 0, "button",{type:"button",...A,disabled:!0,children:n.unavailable})})]})}function Gt(){return _jsxruntime.jsxs.call(void 0, "svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),_jsxruntime.jsx.call(void 0, "path",{d:"m3.3 7 8.7 5 8.7-5"}),_jsxruntime.jsx.call(void 0, "path",{d:"M12 22V12"})]})}var kt="m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-5 p-0";function Zt({count:t,label:e}){let r=u("grid",kt),o=u("skeleton","aspect-[3/4] animate-pulse");return _jsxruntime.jsx.call(void 0, "div",{...r,role:"status","aria-busy":"true","aria-label":e,children:Array.from({length:t},(s,n)=>_jsxruntime.jsx.call(void 0, "div",{...o,"aria-hidden":"true"},n))})}function Qt({page:t,pageCount:e,isLoading:r,onPage:o}){let{texts:s}=F(),n=u("pagination","mt-8 flex items-center justify-center gap-4"),i=u("paginationButton",W),d=u("pageIndicator","text-sm");return _jsxruntime.jsxs.call(void 0, "nav",{...n,"aria-label":s.pagination,children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",...i,"aria-disabled":r||t<=1,onClick:()=>{!r&&t>1&&o(t-1)},children:s.previousPage}),_jsxruntime.jsx.call(void 0, "span",{...d,"aria-live":"polite",children:X(s.pageOf,{page:t,pageCount:e})}),_jsxruntime.jsx.call(void 0, "button",{type:"button",...i,"aria-disabled":r||t>=e,onClick:()=>{!r&&t<e&&o(t+1)},children:s.nextPage})]})}function Xt({options:t,productHref:e,renderItem:r,onAddToCart:o,showCartOnAdd:s}){let{texts:n}=F(),{products:i,page:d,pageCount:c,setPage:m,isLoading:l,error:P,refetch:T}=Z(t),g=_chunkGQJDFLSLjs.m.call(void 0, ),p=_optionalChain([t, 'access', _25 => _25.search, 'optionalAccess', _26 => _26.trim, 'call', _27 => _27()])?"search":"catalog",f=O(t.pageSize),b=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{b.current||l||P!=null||(b.current=!0,g.track("product_list_viewed",{list_id:p,item_count:i.length}))},[g,l,P,p,i.length]);let x=_react.useMemo.call(void 0, ()=>Lt(({productIds:h,positions:I})=>g.track("product_impression",{list_id:p,product_ids:h,positions:I})),[g,p]);_react.useEffect.call(void 0, ()=>()=>x.destroy(),[x]);let k=_react.useMemo.call(void 0, ()=>({observe:x.observe,clicked:(h,I)=>g.track("product_clicked",{list_id:p,position:I},{product_id:h.id})}),[x,g,p]),S=_react.useRef.call(void 0, null),C=_react.useRef.call(void 0, !1),w=_react.useCallback.call(void 0, h=>{C.current=!0,m(h)},[m]);_react.useEffect.call(void 0, ()=>{l||!C.current||(C.current=!1,_optionalChain([S, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.focus, 'call', _30 => _30({preventScroll:!0})]),_optionalChain([S, 'access', _31 => _31.current, 'optionalAccess', _32 => _32.scrollIntoView, 'call', _33 => _33({block:"start"})]))},[l]);let A=u("grid",kt),y=u("emptyState","py-12 text-center text-sm"),L=u("error","flex flex-col items-center gap-3 py-12 text-center text-sm"),D=u("retryButton",W),{projectID:E,host:J}=t,It=_react.useCallback.call(void 0, (h,I)=>async()=>{if(o!=null){await _chunkGQJDFLSLjs.p.call(void 0, ()=>o(h)),Q(g,h);return}await yt(h,{projectID:E,host:J,showCart:s,analytics:g,url:I})},[o,E,J,s,g]),_;return l&&i.length===0?_=_jsxruntime.jsx.call(void 0, Zt,{count:Math.min(O(t.pageSize),8),label:n.loading}):P!=null?_=_jsxruntime.jsxs.call(void 0, "div",{...L,role:"alert",children:[_jsxruntime.jsx.call(void 0, "p",{children:n.error}),_jsxruntime.jsx.call(void 0, "button",{type:"button",...D,onClick:T,children:n.retry})]}):i.length===0?_=_jsxruntime.jsx.call(void 0, "p",{...y,children:n.empty}):_=_jsxruntime.jsx.call(void 0, "ul",{...A,"aria-busy":l||void 0,className:_chunkGXUNRJ5Sjs.d.call(void 0, A.className,l&&"opacity-60"),children:i.map((h,I)=>{let Y=e(h);return _jsxruntime.jsx.call(void 0, qt,{product:h,position:(d-1)*f+I,href:Y,onAdd:It(h,Y),renderItem:r},h.id)})}),_jsxruntime.jsx.call(void 0, Tt.Provider,{value:k,children:_jsxruntime.jsxs.call(void 0, "div",{ref:S,tabIndex:-1,className:"p-1 outline-none scroll-mt-4",children:[_,c>1&&P==null?_jsxruntime.jsx.call(void 0, Qt,{page:d,pageCount:c,isLoading:l,onPage:w}):null]})})}var Wt=t=>`/p/${encodeURIComponent(t.uniqueSlug)}`;function Jt({productHref:t=Wt,appearance:e,texts:r,renderItem:o,onAddToCart:s,showCartOnAdd:n=!0,className:i,analytics:d,...c}){let m=_chunkGQJDFLSLjs.n.call(void 0, c.projectID,d,"catalog"),l=_nullishCoalesce(c.locale, () => (_chunk7RXW6XFYjs.d)),P=_react.useMemo.call(void 0, ()=>pt(e),[e]),T=_react.useMemo.call(void 0, ()=>ht(l,r),[l,r]),g=_react.useMemo.call(void 0, ()=>({appearance:P,texts:T,locale:l}),[P,T,l]),p=G(P,"root");return _jsxruntime.jsx.call(void 0, _chunkGQJDFLSLjs.l,{value:m,children:_jsxruntime.jsx.call(void 0, Ct.Provider,{value:g,children:_jsxruntime.jsx.call(void 0, "div",{"data-bitsnap-products":"root","data-bitsnap-products-slot":"root",className:_chunkGXUNRJ5Sjs.d.call(void 0, "bitsnap-react",P.boundaryClassName,i,_optionalChain([p, 'optionalAccess', _34 => _34.className])),style:{...P.boundaryStyle,..._optionalChain([p, 'optionalAccess', _35 => _35.style])},children:_jsxruntime.jsx.call(void 0, Xt,{options:c,productHref:t,renderItem:o,onAddToCart:s,showCartOnAdd:n})})})})}exports.a = wt; exports.b = H; exports.c = Z; exports.d = Jt;
|
|
2
|
-
//# sourceMappingURL=chunk-OZHXRKMX.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-OZHXRKMX.js","../src/components/products/appearance.ts","../src/components/products/format.ts"],"names":["PRODUCT_LIST_SLOT_NAMES","PRODUCT_LIST_TOKEN_VARIABLES","PRODUCT_LIST_THEME_PRESETS","PRODUCT_LIST_SHADCN_VARIABLES","resolveProductListAppearance","appearance","resolved","resolveAppearanceCore","getProductListSlotAppearance","slot","getSlotAppearance","createFormatter","locale","currency","formatProductPrice","amount","DEFAULT_LOCALE","value","formatter"],"mappings":"AAAA,y/BAAgD,sDAAuE,sDAAiF,sDAAgD,IC2D3OA,EAAAA,CAA0B,CACrC,MAAA,CACA,MAAA,CACA,MAAA,CACA,UAAA,CACA,OAAA,CACA,kBAAA,CACA,MAAA,CACA,MAAA,CACA,aAAA,CACA,OAAA,CACA,cAAA,CACA,OAAA,CACA,cAAA,CACA,SAAA,CACA,iBAAA,CACA,cAAA,CACA,SAAA,CACA,YAAA,CACA,kBAAA,CACA,eAAA,CACA,YAAA,CACA,OAAA,CACA,aAAA,CACA,UACF,CAAA,CA8BaC,EAAAA,CAA+B,CAC1C,UAAA,CAAY,gCAAA,CACZ,QAAA,CAAU,8BAAA,CACV,UAAA,CAAY,+BAAA,CACZ,OAAA,CAAS,4BAAA,CACT,UAAA,CAAY,+BAAA,CACZ,eAAA,CAAiB,qCAAA,CACjB,MAAA,CAAQ,2BAAA,CACR,gBAAA,CAAkB,sCAAA,CAClB,gBAAA,CAAkB,sCAAA,CAClB,qBAAA,CAAuB,4CAAA,CACvB,YAAA,CAAc,kCAAA,CACd,SAAA,CAAW,+BAAA,CACX,KAAA,CAAO,0BAAA,CACP,eAAA,CAAiB,qCAAA,CACjB,eAAA,CAAiB,qCAAA,CACjB,MAAA,CAAQ,2BACV,CAAA,CASaC,EAAAA,CAGT,CACF,KAAA,CAAO,CACL,UAAA,CAAY,SAAA,CACZ,OAAA,CAAS,SAAA,CACT,UAAA,CAAY,SAAA,CACZ,eAAA,CAAiB,SAAA,CACjB,MAAA,CAAQ,SAAA,CACR,gBAAA,CAAkB,SAAA,CAClB,gBAAA,CAAkB,SAAA,CAClB,qBAAA,CAAuB,SAAA,CACvB,YAAA,CAAc,SAAA,CACd,SAAA,CAAW,SAAA,CACX,KAAA,CAAO,SAAA,CACP,eAAA,CAAiB,SAAA,CACjB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AAA,CACdC,CAAAA,CACAF,CAAAA,CACAD,CAAAA,CAAiBI,kBAAAA,CACT,CACR,IAAMC,CAAAA,CAAQF,CAAAA,CAAS,GAAA,CACjBG,CAAAA,kBACJP,EAAAA,CAAgBC,CAAAA,CAAQC,CAAQ,CAAA,SAChCF,EAAAA,CAAgBK,kBAAAA,CAAgBH,CAAQ,GAAA,CAE1C,OAAOK,CAAAA,EAAa,IAAA,CAChBA,CAAAA,CAAU,MAAA,CAAOD,CAAK,CAAA,CACtB,CAAA,EAAA","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-OZHXRKMX.js","sourcesContent":[null,"import type { CSSProperties } from \"react\";\nimport {\n getSlotAppearance,\n resolveAppearanceCore,\n type AppearanceElements,\n type ShadcnVariableMapping,\n type SlotAppearance,\n} from \"@/src/lib/appearance-core\";\n\n/**\n * Product list appearance API.\n *\n * It mirrors `CheckoutAppearance` and `ReturnsAppearance` (theme, tokens,\n * elements) so a shop can reuse one brand object for all of them. The resolver\n * is pure: it turns the caller input into a theme name, the tokens in effect,\n * the slot overrides and the inline style for the theme boundary.\n */\n\nexport type ProductListTheme = \"light\" | \"dark\";\n\nexport type ProductListAppearanceTokens = {\n /** Font family of the list. The library never loads fonts. */\n fontFamily?: string;\n /** Base font size. */\n fontSize?: string;\n /** List background. */\n background?: string;\n /** Raised surfaces: cards, image placeholders, skeletons. */\n surface?: string;\n /** Main text color. */\n foreground?: string;\n /** Secondary text: descriptions, the struck-through price. */\n mutedForeground?: string;\n /** Borders of cards and buttons. */\n border?: string;\n /** \"Add to cart\" button background. */\n buttonBackground?: string;\n /** \"Add to cart\" button text. */\n buttonForeground?: string;\n /** \"Add to cart\" button background on hover. */\n buttonHoverBackground?: string;\n /** Hover surface of cards and secondary buttons. */\n hoverSurface?: string;\n /** Focus ring color. */\n focusRing?: string;\n /** Error and unavailable state color. */\n error?: string;\n /** Badge background (subscription, unavailable). */\n badgeBackground?: string;\n /** Badge text. */\n badgeForeground?: string;\n /** Corner radius of cards, images and buttons. */\n radius?: string;\n};\n\n/**\n * Stable slot names. They are exposed as `data-bitsnap-products-slot`\n * attributes so they can also be targeted from plain CSS.\n */\nexport const PRODUCT_LIST_SLOT_NAMES = [\n \"root\",\n \"grid\",\n \"card\",\n \"cardLink\",\n \"image\",\n \"imagePlaceholder\",\n \"body\",\n \"name\",\n \"description\",\n \"price\",\n \"comparePrice\",\n \"badge\",\n \"model3dBadge\",\n \"actions\",\n \"addToCartButton\",\n \"selectButton\",\n \"message\",\n \"pagination\",\n \"paginationButton\",\n \"pageIndicator\",\n \"emptyState\",\n \"error\",\n \"retryButton\",\n \"skeleton\",\n] as const;\n\nexport type ProductListSlotName = (typeof PRODUCT_LIST_SLOT_NAMES)[number];\n\nexport type ProductListSlotAppearance = SlotAppearance;\n\nexport type ProductListAppearanceElements =\n AppearanceElements<ProductListSlotName>;\n\nexport type ProductListAppearance = {\n /** `\"light\"` or `\"dark\"`. Omitted means `\"light\"`. */\n theme?: ProductListTheme;\n /** Partial overrides applied over the theme preset. */\n tokens?: ProductListAppearanceTokens;\n /** Per element `className`/`style` overrides. */\n elements?: ProductListAppearanceElements;\n};\n\nexport type ResolvedProductListAppearance = {\n theme: ProductListTheme;\n /** Tokens that are in effect (the theme preset plus caller overrides). */\n tokens: ProductListAppearanceTokens;\n elements: ProductListAppearanceElements;\n /** Theme marker class for the theme boundary. */\n boundaryClassName: string;\n /** Inline custom properties applied to the list root. */\n boundaryStyle: CSSProperties;\n};\n\n/** CSS custom property used for each token. */\nexport const PRODUCT_LIST_TOKEN_VARIABLES = {\n fontFamily: \"--bitsnap-products-font-family\",\n fontSize: \"--bitsnap-products-font-size\",\n background: \"--bitsnap-products-background\",\n surface: \"--bitsnap-products-surface\",\n foreground: \"--bitsnap-products-foreground\",\n mutedForeground: \"--bitsnap-products-muted-foreground\",\n border: \"--bitsnap-products-border\",\n buttonBackground: \"--bitsnap-products-button-background\",\n buttonForeground: \"--bitsnap-products-button-foreground\",\n buttonHoverBackground: \"--bitsnap-products-button-hover-background\",\n hoverSurface: \"--bitsnap-products-hover-surface\",\n focusRing: \"--bitsnap-products-focus-ring\",\n error: \"--bitsnap-products-error\",\n badgeBackground: \"--bitsnap-products-badge-background\",\n badgeForeground: \"--bitsnap-products-badge-foreground\",\n radius: \"--bitsnap-products-radius\",\n} as const;\n\nexport type ProductListTokenName = keyof typeof PRODUCT_LIST_TOKEN_VARIABLES;\n\n/**\n * Complete palettes. They carry colors and radius only, so typography is never\n * reset implicitly. `products.css` falls back to the light values, which keeps\n * the list usable even when the boundary style is missing.\n */\nexport const PRODUCT_LIST_THEME_PRESETS: Record<\n ProductListTheme,\n ProductListAppearanceTokens\n> = {\n light: {\n background: \"#ffffff\",\n surface: \"#f9fafb\",\n foreground: \"#18181b\",\n mutedForeground: \"#71717a\",\n border: \"#e4e4e7\",\n buttonBackground: \"#18181b\",\n buttonForeground: \"#fafafa\",\n buttonHoverBackground: \"#000000\",\n hoverSurface: \"#f4f4f5\",\n focusRing: \"#71717a\",\n error: \"#dc2626\",\n badgeBackground: \"#f4f4f5\",\n badgeForeground: \"#3f3f46\",\n radius: \"8px\",\n },\n dark: {\n background: \"#18181b\",\n surface: \"#27272a\",\n foreground: \"#fafafa\",\n mutedForeground: \"#a1a1aa\",\n border: \"#3f3f46\",\n buttonBackground: \"#fafafa\",\n buttonForeground: \"#18181b\",\n buttonHoverBackground: \"#e4e4e7\",\n hoverSurface: \"#3f3f46\",\n focusRing: \"#a1a1aa\",\n error: \"#f87171\",\n badgeBackground: \"#3f3f46\",\n badgeForeground: \"#e4e4e7\",\n radius: \"8px\",\n },\n};\n\n/** The list renders its own elements, so no shared primitive needs remapping. */\nconst PRODUCT_LIST_SHADCN_VARIABLES: ShadcnVariableMapping<ProductListTokenName> =\n [];\n\nexport function resolveProductListAppearance(\n appearance?: ProductListAppearance,\n): ResolvedProductListAppearance {\n const resolved = resolveAppearanceCore<\n ProductListTokenName,\n ProductListTheme,\n ProductListSlotName\n >(appearance, {\n defaultTheme: \"light\",\n presets: PRODUCT_LIST_THEME_PRESETS,\n variables: PRODUCT_LIST_TOKEN_VARIABLES,\n shadcnVariables: PRODUCT_LIST_SHADCN_VARIABLES,\n });\n\n return {\n theme: resolved.theme,\n tokens: resolved.tokens,\n elements: resolved.elements,\n boundaryClassName: resolved.theme,\n boundaryStyle: resolved.boundaryStyle,\n };\n}\n\n/** Caller overrides for a single slot, if any were provided. */\nexport function getProductListSlotAppearance(\n resolved: ResolvedProductListAppearance,\n slot: ProductListSlotName,\n): ProductListSlotAppearance | undefined {\n return getSlotAppearance(resolved.elements, slot);\n}\n","import { DEFAULT_LOCALE } from \"../checkout/locale\";\n\nfunction createFormatter(\n locale: string,\n currency: string,\n): Intl.NumberFormat | undefined {\n try {\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n currencyDisplay: \"symbol\",\n });\n } catch {\n // RangeError: invalid locale or currency code.\n return undefined;\n }\n}\n\n/**\n * Formats a price in minor units (grosze, cents) for the locale, the same way\n * the cart does (`amount / 100`). An unknown locale falls back to Polish and an\n * invalid currency code to a plain number followed by the code.\n */\nexport function formatProductPrice(\n amount: number,\n currency: string,\n locale: string = DEFAULT_LOCALE,\n): string {\n const value = amount / 100;\n const formatter =\n createFormatter(locale, currency) ??\n createFormatter(DEFAULT_LOCALE, currency);\n\n return formatter != null\n ? formatter.format(value)\n : `${value.toFixed(2)} ${currency}`;\n}\n"]}
|
package/dist/chunk-QERYM7RC.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkKOYBZORLjs = require('./chunk-KOYBZORL.js');var _chunkWPOXLITYjs = require('./chunk-WPOXLITY.js');var _chunkGXUNRJ5Sjs = require('./chunk-GXUNRJ5S.js');var _chunkGQJDFLSLjs = require('./chunk-GQJDFLSL.js');var _chunk7RXW6XFYjs = require('./chunk-7RXW6XFY.js');var vr=["root","header","title","description","backButton","stepIndicator","error","emptyState","skeleton","emailForm","emailInput","codeForm","codeInput","resendButton","logoutButton","orderList","orderCard","orderReference","orderDate","orderTotal","pagination","lineList","line","lineName","linePrice","lineQuantityControl","quantityButton","quantityInput","lineIneligibleReason","noteInput","summary","submitButton","secondaryButton","successState","returnReference","returnInstructions","returnList","returnCard","statusBadge","history","historyEntry"],zt={fontFamily:"--bitsnap-returns-font-family",fontSize:"--bitsnap-returns-font-size",background:"--bitsnap-returns-background",surface:"--bitsnap-returns-surface",foreground:"--bitsnap-returns-foreground",mutedForeground:"--bitsnap-returns-muted-foreground",border:"--bitsnap-returns-border",buttonBackground:"--bitsnap-returns-button-background",buttonForeground:"--bitsnap-returns-button-foreground",buttonHoverBackground:"--bitsnap-returns-button-hover-background",hoverSurface:"--bitsnap-returns-hover-surface",focusRing:"--bitsnap-returns-focus-ring",error:"--bitsnap-returns-error",success:"--bitsnap-returns-success",warning:"--bitsnap-returns-warning",badgeBackground:"--bitsnap-returns-badge-background",badgeForeground:"--bitsnap-returns-badge-foreground",inputBackground:"--bitsnap-returns-input-background",radius:"--bitsnap-returns-radius"},Dt={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",success:"#16a34a",warning:"#d97706",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",inputBackground:"#ffffff",radius:"8px"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",success:"#4ade80",warning:"#fbbf24",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",inputBackground:"#27272a",radius:"8px"}},Ot=[{token:"background",variable:"--background"},{token:"foreground",variable:"--foreground"},{token:"surface",variable:"--card"},{token:"foreground",variable:"--card-foreground"},{token:"surface",variable:"--popover"},{token:"foreground",variable:"--popover-foreground"},{token:"buttonBackground",variable:"--primary"},{token:"buttonForeground",variable:"--primary-foreground"},{token:"surface",variable:"--secondary"},{token:"foreground",variable:"--secondary-foreground"},{token:"hoverSurface",variable:"--accent"},{token:"foreground",variable:"--accent-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 ve(e){let r=_chunkKOYBZORLjs.a.call(void 0, e,{defaultTheme:"light",presets:Dt,variables:zt,shadcnVariables:Ot});return{theme:r.theme,tokens:r.tokens,elements:r.elements,boundaryClassName:r.theme,boundaryStyle:r.boundaryStyle}}function tt(e,r){return _chunkKOYBZORLjs.b.call(void 0, e.elements,r)}var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var rt=_react.createContext.call(void 0, ve());function nt({appearance:e,children:r}){let t=_react.useMemo.call(void 0, ()=>ve(e),[e]);return _jsxruntime.jsx.call(void 0, rt.Provider,{value:t,children:r})}function Ne(){return _react.useContext.call(void 0, rt)}function l(e){let r=Ne();return _nullishCoalesce(tt(r,e), () => ({}))}function ot(e){return e==="test"||e===1?1:0}var st={title:["emailStepTitle"],email:["emailLabel"],sendCode:["emailSubmit"],code:["codeLabel"],verify:["codeSubmit"],orders:["ordersTitle"],submit:["confirmationSubmit"],note:["noteLabel"],history:["myReturnsTitle","myReturnsLink"]};function at(e){if(e==null)return;let r={};for(let[t,n]of Object.entries(st)){let o=e[t];if(typeof o=="string")for(let u of n)r[u]=o}for(let t of Object.keys(e)){if(t in st)continue;let n=e[t];typeof n=="string"&&(r[t]=n)}return r}function it(e,r){let t=_optionalChain([r, 'optionalAccess', _2 => _2.brandColor, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]);return t==null||t===""?e:{...e,tokens:{..._chunkWPOXLITYjs.t.call(void 0, t),..._optionalChain([e, 'optionalAccess', _5 => _5.tokens])}}}function he(e,r){return typeof e=="object"&&e!=null?{pageSize:_nullishCoalesce(e.pageSize, () => (20)),explicitPageToken:void 0}:typeof e=="number"||r!==void 0?{pageSize:_nullishCoalesce(e, () => (20)),explicitPageToken:_nullishCoalesce(r, () => (""))}:{pageSize:20,explicitPageToken:void 0}}var _t={en:{back:"Back",stepIndicator:"Step {current} of {total}",loading:"Loading",myReturnsLink:"My returns",emailStepTitle:"Return a product",emailStepDescription:"Enter the email address you used for the order. We will send you a verification code.",emailLabel:"Email address",emailPlaceholder:"name@example.com",emailSubmit:"Send code",codeStepTitle:"Enter the code",codeStepDescription:"We sent a verification code to {email}.",codeLabel:"Verification code",codeSubmit:"Verify",resend:"Send the code again",resendIn:"Send again in {seconds} s",logout:"Sign out",ordersTitle:"Your orders",ordersDescription:"Choose the order that contains the product to return.",ordersEmpty:"There are no orders eligible for return.",orderTitle:"Order {reference}",orderReturnableLines:"Products available to return: {count}",orderSelect:"Choose",paginationPrevious:"Previous",paginationNext:"Next",paginationInfo:"Page {page}, {total} orders",orderDetailTitle:"Order {reference}",orderDetailDescription:"Select the products and quantities to return.",quantityLabel:"Quantity to return: {name}",quantityDecrease:"Decrease quantity: {name}",quantityIncrease:"Increase quantity: {name}",quantityOfAvailable:"of {available}",lineIneligibleFallback:"This product cannot be returned.",noteLabel:"Note (optional)",notePlaceholder:"Tell us why you are returning the product",selectionContinue:"Continue",selectionEmpty:"Select at least one item to return.",previousReturnsTitle:"Earlier returns for this order",confirmationTitle:"Confirm the return",confirmationDescription:"Check the products before you submit the request.",confirmationSummary:"Products to return",confirmationQuantity:"Quantity: {quantity}",confirmationNote:"Your note",confirmationSubmit:"Submit return request",successTitle:"Return request submitted",successDescription:"We received your request and will keep you posted.",successReference:"Request number",successInstructions:"What to do next",successDone:"Back to orders",myReturnsTitle:"My returns",myReturnsDescription:"Track the status of your return requests.",myReturnsEmpty:"You have not submitted any return requests yet.",myReturnOpen:"Details",myReturnDetailTitle:"Return details",myReturnTitle:"Return {reference}",myReturnCreatedAt:"Submitted",myReturnRefund:"Refund",myReturnLines:"Products",myReturnLineQuantities:"Requested: {requested}, approved: {approved}, received: {received}",myReturnNote:"Your note",myReturnHistory:"History",statusSubmitted:"Submitted",statusApproved:"Approved",statusRejected:"Rejected",statusAwaitingReceipt:"Awaiting the package",statusReceived:"Package received",statusCompleted:"Completed",statusCancelled:"Cancelled",statusRefunded:"Refunded",statusFallback:"In progress",refundStatusNotStarted:"Not started",refundStatusPending:"Refund in progress",refundStatusSucceeded:"Refunded",refundStatusFailed:"Refund failed",refundStatusFallback:"Unknown",errorGeneric:"Something went wrong. Please try again.",errorInvalidEmail:"Enter a valid email address.",errorInvalidCode:"The code is invalid or has expired.",errorSessionExpired:"Your session has expired. Verify your email again.",errorOrderNotFound:"We could not find this order.",errorReturnNotFound:"We could not find this return request.",errorQuantityUnavailable:"The selected quantity is no longer available for return.",errorItemNotReturnable:"One of the selected products cannot be returned.",errorReturnsDisabled:"Returns are not available in this shop.",errorRateLimited:"Too many attempts. Please try again later.",errorIdempotencyConflict:"This request was already submitted with different contents. Reload and try again.",errorDeliveryFailed:"We could not send the code. Please try again.",errorRetry:"Try again"},pl:{back:"Wstecz",stepIndicator:"Krok {current} z {total}",loading:"\u0141adowanie",myReturnsLink:"Moje zwroty",emailStepTitle:"Zwr\xF3\u0107 produkt",emailStepDescription:"Podaj adres e-mail u\u017Cyty w zam\xF3wieniu. Wy\u015Blemy na niego kod weryfikacyjny.",emailLabel:"Adres e-mail",emailPlaceholder:"jan@example.com",emailSubmit:"Wy\u015Blij kod",codeStepTitle:"Wpisz kod",codeStepDescription:"Wys\u0142ali\u015Bmy kod weryfikacyjny na adres {email}.",codeLabel:"Kod weryfikacyjny",codeSubmit:"Zweryfikuj",resend:"Wy\u015Blij kod ponownie",resendIn:"Wy\u015Blij ponownie za {seconds} s",logout:"Wyloguj si\u0119",ordersTitle:"Twoje zam\xF3wienia",ordersDescription:"Wybierz zam\xF3wienie z produktem do zwrotu.",ordersEmpty:"Brak zam\xF3wie\u0144, kt\xF3re mo\u017Cna zwr\xF3ci\u0107.",orderTitle:"Zam\xF3wienie {reference}",orderReturnableLines:"Produkty do zwrotu: {count}",orderSelect:"Wybierz",paginationPrevious:"Poprzednia",paginationNext:"Nast\u0119pna",paginationInfo:"Strona {page}, zam\xF3wie\u0144: {total}",orderDetailTitle:"Zam\xF3wienie {reference}",orderDetailDescription:"Wybierz produkty i ilo\u015Bci do zwrotu.",quantityLabel:"Ilo\u015B\u0107 do zwrotu: {name}",quantityDecrease:"Zmniejsz ilo\u015B\u0107: {name}",quantityIncrease:"Zwi\u0119ksz ilo\u015B\u0107: {name}",quantityOfAvailable:"z {available}",lineIneligibleFallback:"Ten produkt nie podlega zwrotowi.",noteLabel:"Uwagi (opcjonalnie)",notePlaceholder:"Napisz, dlaczego zwracasz produkt",selectionContinue:"Dalej",selectionEmpty:"Wybierz co najmniej jedn\u0105 sztuk\u0119 do zwrotu.",previousReturnsTitle:"Wcze\u015Bniejsze zwroty tego zam\xF3wienia",confirmationTitle:"Potwierd\u017A zwrot",confirmationDescription:"Sprawd\u017A produkty przed wys\u0142aniem zg\u0142oszenia.",confirmationSummary:"Produkty do zwrotu",confirmationQuantity:"Ilo\u015B\u0107: {quantity}",confirmationNote:"Twoje uwagi",confirmationSubmit:"Wy\u015Blij zg\u0142oszenie zwrotu",successTitle:"Zg\u0142oszenie zwrotu zosta\u0142o wys\u0142ane",successDescription:"Otrzymali\u015Bmy zg\u0142oszenie i b\u0119dziemy informowa\u0107 o jego statusie.",successReference:"Numer zg\u0142oszenia",successInstructions:"Co dalej",successDone:"Wr\xF3\u0107 do zam\xF3wie\u0144",myReturnsTitle:"Moje zwroty",myReturnsDescription:"Sprawd\u017A status swoich zg\u0142osze\u0144 zwrotu.",myReturnsEmpty:"Nie masz jeszcze \u017Cadnych zg\u0142osze\u0144 zwrotu.",myReturnOpen:"Szczeg\xF3\u0142y",myReturnDetailTitle:"Szczeg\xF3\u0142y zwrotu",myReturnTitle:"Zwrot {reference}",myReturnCreatedAt:"Zg\u0142oszono",myReturnRefund:"Zwrot \u015Brodk\xF3w",myReturnLines:"Produkty",myReturnLineQuantities:"Zg\u0142oszono: {requested}, zaakceptowano: {approved}, odebrano: {received}",myReturnNote:"Twoje uwagi",myReturnHistory:"Historia",statusSubmitted:"Zg\u0142oszony",statusApproved:"Zaakceptowany",statusRejected:"Odrzucony",statusAwaitingReceipt:"Oczekiwanie na paczk\u0119",statusReceived:"Paczka odebrana",statusCompleted:"Zako\u0144czony",statusCancelled:"Anulowany",statusRefunded:"\u015Arodki zwr\xF3cone",statusFallback:"W trakcie",refundStatusNotStarted:"Nie rozpocz\u0119to",refundStatusPending:"Zwrot \u015Brodk\xF3w w toku",refundStatusSucceeded:"\u015Arodki zwr\xF3cone",refundStatusFailed:"Zwrot \u015Brodk\xF3w nie powi\xF3d\u0142 si\u0119",refundStatusFallback:"Nieznany",errorGeneric:"Co\u015B posz\u0142o nie tak. Spr\xF3buj ponownie.",errorInvalidEmail:"Podaj poprawny adres e-mail.",errorInvalidCode:"Kod jest nieprawid\u0142owy lub wygas\u0142.",errorSessionExpired:"Sesja wygas\u0142a. Zweryfikuj adres e-mail ponownie.",errorOrderNotFound:"Nie znaleziono tego zam\xF3wienia.",errorReturnNotFound:"Nie znaleziono tego zg\u0142oszenia zwrotu.",errorQuantityUnavailable:"Wybrana ilo\u015B\u0107 nie jest ju\u017C dost\u0119pna do zwrotu.",errorItemNotReturnable:"Jeden z wybranych produkt\xF3w nie podlega zwrotowi.",errorReturnsDisabled:"Zwroty nie s\u0105 dost\u0119pne w tym sklepie.",errorRateLimited:"Zbyt wiele pr\xF3b. Spr\xF3buj ponownie p\xF3\u017Aniej.",errorIdempotencyConflict:"To zg\u0142oszenie zosta\u0142o ju\u017C wys\u0142ane z inn\u0105 zawarto\u015Bci\u0105. Od\u015Bwie\u017C stron\u0119 i spr\xF3buj ponownie.",errorDeliveryFailed:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 kodu. Spr\xF3buj ponownie.",errorRetry:"Spr\xF3buj ponownie"}};function ke(e,r){return _chunk7RXW6XFYjs.b.call(void 0, _t,e,r)}function ut(e,r){return e.replace(/\{(\w+)\}/g,(t,n)=>Object.prototype.hasOwnProperty.call(r,n)?String(r[n]):t)}var jt={submitted:"statusSubmitted",approved:"statusApproved",rejected:"statusRejected",awaiting_receipt:"statusAwaitingReceipt",received:"statusReceived",completed:"statusCompleted",cancelled:"statusCancelled",refunded:"statusRefunded"},Ut={not_started:"refundStatusNotStarted",pending:"refundStatusPending",succeeded:"refundStatusSucceeded",failed:"refundStatusFailed"};function lt(e){return _nullishCoalesce(jt[e], () => ("statusFallback"))}function ct(e){return _nullishCoalesce(Ut[e], () => ("refundStatusFallback"))}var Te=_react.createContext.call(void 0, {locale:"pl-PL",texts:ke("pl-PL")});function pt({texts:e,locale:r,children:t}){let n=_nullishCoalesce(r, () => (_chunk7RXW6XFYjs.f.call(void 0, ))),o=_react.useMemo.call(void 0, ()=>({locale:n,texts:ke(n,e)}),[n,e]);return _jsxruntime.jsx.call(void 0, Te.Provider,{value:o,children:t})}function h(){let{texts:e}=_react.useContext.call(void 0, Te);return _react.useCallback.call(void 0, (r,t)=>t==null?e[r]:ut(e[r],t),[e])}function Y(){return _react.useContext.call(void 0, Te).locale}var _connect = require('@connectrpc/connect');var _connectquery = require('@connectrpc/connect-query');var _reactquery = require('@tanstack/react-query');var _wkt = require('@bufbuild/protobuf/wkt');var Zt="bitsnap-returns-session:";function we(e){return`${Zt}${e}`}function oe(){try{return typeof window<"u"?window.sessionStorage:void 0}catch (e2){return}}function mt(e,r,t=Date.now()){if(e==null)return;let n=we(r);try{let o=e.getItem(n);if(o==null)return;let u=JSON.parse(o);if(u!=null&&typeof u=="object"&&typeof u.token=="string"&&u.token.length>0&&typeof u.expiresAt=="number"&&u.expiresAt>t){let{token:s,expiresAt:a}=u;return{token:s,expiresAt:a}}e.removeItem(n)}catch (e3){try{e.removeItem(n)}catch (e4){}}}function yt(e,r,t){try{_optionalChain([e, 'optionalAccess', _6 => _6.setItem, 'call', _7 => _7(we(r),JSON.stringify(t))])}catch (e5){}}function Ie(e,r){try{_optionalChain([e, 'optionalAccess', _8 => _8.removeItem, 'call', _9 => _9(we(r))])}catch (e6){}}function ae(e){return e==null?void 0:_wkt.timestampMs.call(void 0, e)}var Rt=_react.createContext.call(void 0, void 0);function T(e){let r=_react.useContext.call(void 0, Rt);if(r==null)throw new Error(`${e} must be rendered inside <ReturnsProvider>`);return r}function Ce(){return _connectquery.createConnectQueryKey.call(void 0, {schema:_chunkWPOXLITYjs.i,cardinality:void 0})}var or=2**31-1;function ar({projectID:e,environment:r,transport:t,panelAccessToken:n,className:o,children:u}){let s=_reactquery.useQueryClient.call(void 0, ),{boundaryClassName:a,boundaryStyle:y}=Ne(),m=l("root"),[p,f]=_react.useState.call(void 0, {status:"hydrating"}),[c,b]=_react.useState.call(void 0, ),[g,C]=_react.useState.call(void 0, ),I=_react.useRef.call(void 0, void 0),N=_react.useCallback.call(void 0, ()=>{s.removeQueries({queryKey:Ce()})},[s]),B=_react.useCallback.call(void 0, ()=>{Ie(oe(),e),C(void 0),f({status:"anonymous"}),N()},[e,N]),w=_react.useCallback.call(void 0, k=>{yt(oe(),e,k),b(void 0),C(void 0),f({status:"authenticated",token:k.token,expiresAt:k.expiresAt})},[e]);_react.useEffect.call(void 0, ()=>{let k=!1,Q=oe();if(n==null||n===""){let O=I.current!=null;if(I.current=void 0,O){B();return}let q=mt(Q,e);f(q!=null?{status:"authenticated",token:q.token,expiresAt:q.expiresAt}:{status:"anonymous"});return}return I.current=n,Ie(Q,e),N(),b(void 0),f({status:"exchanging"}),_connect.createClient.call(void 0, _chunkWPOXLITYjs.i,t).exchangePanelSession({projectId:e,accessToken:n,environment:r}).then(O=>{if(k)return;let q=ae(O.expiresAt);if(O.sessionToken===""||q==null)throw new Error("EMPTY_SESSION");w({token:O.sessionToken,expiresAt:q})}).catch(O=>{k||(b(O),f({status:"anonymous"}))}),()=>{k=!0}},[n,e,r,t]),_react.useEffect.call(void 0, ()=>{if(p.status!=="authenticated"||p.expiresAt==null)return;let k=p.expiresAt-Date.now();if(k<=0){B();return}let Q=setTimeout(B,Math.min(k,or));return()=>clearTimeout(Q)},[p.status,p.expiresAt,B]);let P=_react.useMemo.call(void 0, ()=>({projectID:e,environment:r,status:p.status,token:p.token,exchangeError:c,challenge:g,setChallenge:C,authenticate:w,clearSession:B}),[e,r,p.status,p.token,c,g,w,B]);return _jsxruntime.jsx.call(void 0, Rt.Provider,{value:P,children:_jsxruntime.jsx.call(void 0, "div",{"data-bitsnap-returns":"root","data-bitsnap-returns-slot":"root",className:_chunkGXUNRJ5Sjs.d.call(void 0, "bitsnap-react",a,o,m.className),style:{...y,...m.style},children:u})})}function ir({projectID:e,host:r,environment:t,appearance:n,texts:o,theme:u,locale:s,panelAccessToken:a,className:y,analytics:m,children:p}){let f=_chunkGQJDFLSLjs.n.call(void 0, e,m,"returns"),c=_react.useContext.call(void 0, _reactquery.QueryClientContext),[b]=_react.useState.call(void 0, ()=>c==null?new (0, _reactquery.QueryClient)({defaultOptions:{queries:{staleTime:5e3}}}):void 0),g=_nullishCoalesce(r, () => (_chunkWPOXLITYjs.m.call(void 0, ))),C=_react.useMemo.call(void 0, ()=>_chunkWPOXLITYjs.n.call(void 0, g),[g]),I=_optionalChain([u, 'optionalAccess', _10 => _10.brandColor]),N=_react.useMemo.call(void 0, ()=>it(n,{brandColor:I}),[n,I]),B=_react.useMemo.call(void 0, ()=>at(o),[o]),w=_jsxruntime.jsx.call(void 0, _chunkGQJDFLSLjs.l,{value:f,children:_jsxruntime.jsx.call(void 0, _connectquery.TransportProvider,{transport:C,children:_jsxruntime.jsx.call(void 0, nt,{appearance:N,children:_jsxruntime.jsx.call(void 0, pt,{texts:B,locale:s,children:_jsxruntime.jsx.call(void 0, ar,{projectID:e,environment:ot(t),transport:C,panelAccessToken:a,className:y,children:p})})})})});return c==null&&b!=null?_jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:b,children:w}):w}var Xr=ir;var ur="SESSION_EXPIRED",bt={INVALID_EMAIL:"errorInvalidEmail",INVALID_OR_EXPIRED_CODE:"errorInvalidCode",SESSION_EXPIRED:"errorSessionExpired",ORDER_NOT_FOUND:"errorOrderNotFound",RETURN_NOT_FOUND:"errorReturnNotFound",QUANTITY_UNAVAILABLE:"errorQuantityUnavailable",ITEM_NOT_RETURNABLE:"errorItemNotReturnable",INVALID_RETURN_ITEMS:"errorItemNotReturnable",RETURNS_DISABLED:"errorReturnsDisabled",SUBMISSION_RATE_LIMITED:"errorRateLimited",IDEMPOTENCY_CONFLICT:"errorIdempotencyConflict",VERIFICATION_DELIVERY_FAILED:"errorDeliveryFailed"};function xt(e){if(e==null||typeof e!="object")return;let{rawMessage:r,message:t}=e;if(typeof r=="string"&&r.length>0)return r;if(typeof t=="string")return Object.keys(bt).find(n=>t.includes(n))}function Pe(e){return xt(e)===ur}function St(e){let r=xt(e);return_nullishCoalesce((r!=null?bt[r]:void 0), () => ("errorGeneric"))}function Le(){let e=typeof globalThis<"u"?globalThis.crypto:void 0;if(typeof _optionalChain([e, 'optionalAccess', _11 => _11.randomUUID])=="function")return e.randomUUID();let r=new Uint8Array(16);if(typeof _optionalChain([e, 'optionalAccess', _12 => _12.getRandomValues])=="function")e.getRandomValues(r);else for(let t=0;t<r.length;t++)r[t]=Math.floor(Math.random()*256);return Array.from(r,t=>t.toString(16).padStart(2,"0")).join("")}function $(e){return e==null?null:e instanceof Error?e:new Error(String(e))}function X(e){return e==null?void 0:St(e)}function ce(e,r){_react.useEffect.call(void 0, ()=>{Pe(e)&&r()},[e,r])}function Nt(e){let[r,t]=_react.useState.call(void 0, [""]);return _react.useEffect.call(void 0, ()=>{t([""])},[e]),{pageToken:_nullishCoalesce(r[r.length-1], () => ("")),page:r.length,push:n=>t(o=>[...o,n]),pop:()=>t(n=>n.length>1?n.slice(0,-1):n)}}function de(){let e=T("useReturnSession"),r=_connectquery.useMutation.call(void 0, _chunkWPOXLITYjs.j.returns.startReturnSession),t=_connectquery.useMutation.call(void 0, _chunkWPOXLITYjs.j.returns.verifyReturnSession),{setChallenge:n,authenticate:o,clearSession:u}=e,s=_react.useCallback.call(void 0, async c=>{t.reset();let b=c.trim(),g=await r.mutateAsync({projectId:e.projectID,email:b,environment:e.environment});return n({challengeId:g.challengeId,email:b,resendAvailableAt:Date.now()+Math.max(0,g.resendAfterSeconds)*1e3}),g},[e.projectID,e.environment,n,r,t]),a=_react.useCallback.call(void 0, async c=>{let b=await t.mutateAsync({projectId:e.projectID,challengeId:c.challengeId,code:c.code,environment:e.environment}),g=ae(b.expiresAt);if(b.sessionToken===""||g==null)throw new Error("EMPTY_SESSION");return o({token:b.sessionToken,expiresAt:g}),b},[e.projectID,e.environment,o,t]),y=_react.useCallback.call(void 0, async c=>{try{return await s(c),!0}catch (e7){return!1}},[s]),m=_react.useCallback.call(void 0, async c=>{if(e.challenge==null)return!1;try{return await a({challengeId:e.challenge.challengeId,code:c.trim()}),!0}catch (e8){return!1}},[e.challenge,a]),p=_react.useCallback.call(void 0, ()=>e.challenge!=null?y(e.challenge.email):Promise.resolve(!1),[e.challenge,y]),f=$(_nullishCoalesce(_nullishCoalesce(r.error, () => (t.error)), () => (e.exchangeError)));return{status:e.status,isAuthenticated:e.status==="authenticated",challenge:e.challenge,isStarting:r.isPending,isVerifying:t.isPending,starting:r.isPending,verifying:t.isPending,error:f,errorKey:X(f),start:y,startSession:s,verifySession:a,verify:m,resend:p,logout:u}}function pe(e){return e.status==="hydrating"||e.status==="exchanging"}function ht(e,r){let t=T("useReturnOrders"),{pageSize:n,explicitPageToken:o}=he(e,r),u=Nt(t.token),s=_connectquery.useQuery.call(void 0, _chunkWPOXLITYjs.j.returns.listReturnOrders,{projectId:t.projectID,sessionToken:_nullishCoalesce(t.token, () => ("")),pageSize:n,pageToken:_nullishCoalesce(o, () => (u.pageToken))},{enabled:t.token!=null});ce(s.error,t.clearSession);let a=_nullishCoalesce(_optionalChain([s, 'access', _13 => _13.data, 'optionalAccess', _14 => _14.nextPageToken]), () => (""));return{orders:_nullishCoalesce(_optionalChain([s, 'access', _15 => _15.data, 'optionalAccess', _16 => _16.orders]), () => ([])),total:_nullishCoalesce(_optionalChain([s, 'access', _17 => _17.data, 'optionalAccess', _18 => _18.total]), () => (0)),data:s.data,isLoading:pe(t)||s.isLoading,isFetching:s.isFetching,error:$(s.error),errorKey:X(s.error),status:s.status,isError:s.isError,isSuccess:s.isSuccess,page:u.page,hasNext:a!=="",hasPrevious:u.page>1,next:()=>{a!==""&&u.push(a)},previous:u.pop,refetch:()=>s.refetch()}}function Be(e){let r=T("useReturnableOrder"),t=_connectquery.useQuery.call(void 0, _chunkWPOXLITYjs.j.returns.getReturnableOrder,{projectId:r.projectID,sessionToken:_nullishCoalesce(r.token, () => ("")),canonicalOrderId:_nullishCoalesce(e, () => (""))},{enabled:r.token!=null&&e!=null&&e!==""});return ce(t.error,r.clearSession),{order:_optionalChain([t, 'access', _19 => _19.data, 'optionalAccess', _20 => _20.order]),returnHistory:_nullishCoalesce(_optionalChain([t, 'access', _21 => _21.data, 'optionalAccess', _22 => _22.returnHistory]), () => ([])),data:t.data,isLoading:e!=null&&e!==""&&(pe(r)||t.isLoading),error:$(t.error),errorKey:X(t.error),status:t.status,isError:t.isError,isSuccess:t.isSuccess,refetch:()=>t.refetch()}}function kt(){let e=T("useCreateReturn"),r=_reactquery.useQueryClient.call(void 0, ),t=_connectquery.useMutation.call(void 0, _chunkWPOXLITYjs.j.returns.createReturnRequest),n=_chunkGQJDFLSLjs.m.call(void 0, ),o=_react.useRef.call(void 0, void 0),{clearSession:u}=e,s=_react.useCallback.call(void 0, async(p,f)=>{try{let c=await t.mutateAsync({projectId:e.projectID,sessionToken:_nullishCoalesce(e.token, () => ("")),canonicalOrderId:p.orderId,items:p.items,note:_nullishCoalesce(p.note, () => ("")),idempotencyKey:f});return r.invalidateQueries({queryKey:Ce()}),n.track("return_submitted",{reason_code:"unspecified",item_count:p.items.length},{order_ref:null}),c}catch(c){throw Pe(c)&&u(),c}},[e.projectID,e.token,t,r,u,n]),a=_react.useCallback.call(void 0, async p=>{o.current??=Le();try{let f=await s(p,o.current);return o.current=void 0,f.request}catch (e9){return}},[s]),y=_react.useCallback.call(void 0, async p=>{if(e.token==null)throw new Error("Verify your email to continue.");return s({orderId:p.canonicalOrderID,items:p.items,note:p.note},_nullishCoalesce(p.idempotencyKey, () => (Le())))},[e.token,s]),m=_react.useCallback.call(void 0, (p,f)=>{y(p).then(c=>_optionalChain([f, 'optionalAccess', _23 => _23.onSuccess, 'optionalCall', _24 => _24(c)]),c=>_optionalChain([f, 'optionalAccess', _25 => _25.onError, 'optionalCall', _26 => _26($(c))]))},[y]);return{submit:a,isPending:t.isPending,error:$(t.error),errorKey:X(t.error),mutateAsync:y,mutate:m,data:t.data,reset:t.reset,status:t.status,isError:t.isError,isSuccess:t.isSuccess}}function Tt(e,r){let t=T("useMyReturns"),{pageSize:n,explicitPageToken:o}=he(e,r),u=Nt(t.token),s=_connectquery.useQuery.call(void 0, _chunkWPOXLITYjs.j.returns.listMyReturns,{projectId:t.projectID,sessionToken:_nullishCoalesce(t.token, () => ("")),pageSize:n,pageToken:_nullishCoalesce(o, () => (u.pageToken))},{enabled:t.token!=null});ce(s.error,t.clearSession);let a=_nullishCoalesce(_optionalChain([s, 'access', _27 => _27.data, 'optionalAccess', _28 => _28.nextPageToken]), () => (""));return{returns:_nullishCoalesce(_optionalChain([s, 'access', _29 => _29.data, 'optionalAccess', _30 => _30.returns]), () => ([])),total:_nullishCoalesce(_optionalChain([s, 'access', _31 => _31.data, 'optionalAccess', _32 => _32.total]), () => (0)),data:s.data,isLoading:pe(t)||s.isLoading,isFetching:s.isFetching,error:$(s.error),errorKey:X(s.error),status:s.status,isError:s.isError,isSuccess:s.isSuccess,page:u.page,hasNext:a!=="",hasPrevious:u.page>1,next:()=>{a!==""&&u.push(a)},previous:u.pop,refetch:()=>s.refetch()}}function me(e){let r=T("useMyReturn"),t=_connectquery.useQuery.call(void 0, _chunkWPOXLITYjs.j.returns.getMyReturn,{projectId:r.projectID,sessionToken:_nullishCoalesce(r.token, () => ("")),returnId:e},{enabled:r.token!=null});return ce(t.error,r.clearSession),{request:_optionalChain([t, 'access', _33 => _33.data, 'optionalAccess', _34 => _34.request]),isLoading:pe(r)||t.isLoading,error:t.error,errorKey:X(t.error),refetch:()=>t.refetch()}}var _reactlabel = require('@radix-ui/react-label'); var wt = _interopRequireWildcard(_reactlabel);function te({className:e,...r}){return _jsxruntime.jsx.call(void 0, wt.Root,{"data-slot":"label",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...r})}var _lucidereact = require('lucide-react');function re({className:e,...r}){return _jsxruntime.jsx.call(void 0, _lucidereact.Loader2Icon,{role:"status","aria-label":"Loading",className:_chunkGXUNRJ5Sjs.d.call(void 0, "size-4 animate-spin",e),...r})}var H="bg-[var(--bitsnap-returns-button-background,#18181b)] text-[color:var(--bitsnap-returns-button-foreground,#fafafa)] hover:bg-[var(--bitsnap-returns-button-hover-background,#000000)] focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50",L="border border-[color:var(--bitsnap-returns-border,#e4e4e7)] bg-transparent text-[color:var(--bitsnap-returns-foreground,#18181b)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)] focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50",G="bg-[var(--bitsnap-returns-input-background,#ffffff)] dark:bg-[var(--bitsnap-returns-input-background,#ffffff)] border-[color:var(--bitsnap-returns-border,#e4e4e7)] text-[color:var(--bitsnap-returns-foreground,#18181b)] placeholder:text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] focus-visible:border-[color:var(--bitsnap-returns-focus-ring,#71717a)] focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50";function M({title:e,description:r,onBack:t,className:n,children:o}){let u=h(),s=l("header"),a=l("title"),y=l("description"),m=l("backButton");return _jsxruntime.jsxs.call(void 0, "section",{className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-5",n),children:[_jsxruntime.jsxs.call(void 0, "div",{"data-bitsnap-returns-slot":"header",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-2",s.className),style:s.style,children:[t!=null&&_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.q,{type:"button",variant:"ghost",size:"sm","data-bitsnap-returns-slot":"backButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, "self-start -ml-3 text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",m.className),style:m.style,onClick:t,children:u("back")}),_jsxruntime.jsx.call(void 0, "h2",{"data-bitsnap-returns-slot":"title",className:_chunkGXUNRJ5Sjs.d.call(void 0, "text-2xl font-semibold",a.className),style:a.style,children:e}),r!=null&&_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"description",className:_chunkGXUNRJ5Sjs.d.call(void 0, "text-sm",y.className),style:y.style,children:r})]}),o]})}function A({errorKey:e,onRetry:r}){let t=h(),n=l("error"),o=l("secondaryButton");return _jsxruntime.jsxs.call(void 0, "div",{role:"alert","data-bitsnap-returns-slot":"error",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col items-start gap-2 text-sm",n.className),style:n.style,children:[_jsxruntime.jsx.call(void 0, "p",{children:t(e)}),r!=null&&_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, L,o.className),style:o.style,onClick:r,children:t("errorRetry")})]})}function fe({children:e}){let r=l("emptyState");return _jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"emptyState",className:_chunkGXUNRJ5Sjs.d.call(void 0, "py-6 text-center text-sm",r.className),style:r.style,children:e})}function U({rows:e=3}){let r=h(),t=l("skeleton");return _jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true","aria-label":r("loading"),className:"flex flex-col gap-3",children:Array.from({length:e},(n,o)=>_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.u,{"data-bitsnap-returns-slot":"skeleton",className:_chunkGXUNRJ5Sjs.d.call(void 0, "h-16 w-full bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",t.className),style:t.style},o))})}function J({status:e}){let r=h(),t=l("statusBadge");return _jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"statusBadge","data-status":e,className:_chunkGXUNRJ5Sjs.d.call(void 0, "inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",t.className),style:t.style,children:r(lt(e))})}function ze(){let e=h();return r=>e(ct(r))}function ge({page:e,total:r,hasNext:t,hasPrevious:n,isFetching:o,onNext:u,onPrevious:s}){let a=h(),y=l("pagination"),m=l("secondaryButton");return!t&&!n?null:_jsxruntime.jsxs.call(void 0, "nav",{"data-bitsnap-returns-slot":"pagination",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex items-center justify-between gap-3 text-sm",y.className),style:y.style,children:[_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, L,m.className),style:m.style,disabled:!n||o,onClick:s,children:a("paginationPrevious")}),_jsxruntime.jsx.call(void 0, "span",{"aria-live":"polite",children:a("paginationInfo",{page:e,total:r})}),_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, L,m.className),style:m.style,disabled:!t||o,onClick:u,children:a("paginationNext")})]})}function Kn({onSubmitted:e,className:r}){T("ReturnsEmailStep");let t=h(),n=de(),[o,u]=_react.useState.call(void 0, ""),s=l("emailForm"),a=l("emailInput"),y=l("submitButton");async function m(p){p.preventDefault(),!n.isStarting&&await n.start(o)&&_optionalChain([e, 'optionalCall', _35 => _35(o.trim())])}return _jsxruntime.jsx.call(void 0, M,{className:r,title:t("emailStepTitle"),description:t("emailStepDescription"),children:_jsxruntime.jsxs.call(void 0, "form",{"data-bitsnap-returns-slot":"emailForm",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-4",s.className),style:s.style,onSubmit:m,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, te,{htmlFor:"bitsnap-returns-email",children:t("emailLabel")}),_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.r,{id:"bitsnap-returns-email",type:"email",name:"email",autoComplete:"email",required:!0,value:o,placeholder:t("emailPlaceholder"),disabled:n.isStarting,"data-bitsnap-returns-slot":"emailInput",className:_chunkGXUNRJ5Sjs.d.call(void 0, G,a.className),style:a.style,onChange:p=>u(p.target.value)})]}),n.errorKey!=null&&_jsxruntime.jsx.call(void 0, A,{errorKey:n.errorKey}),_jsxruntime.jsxs.call(void 0, _chunkWPOXLITYjs.q,{type:"submit",disabled:n.isStarting,"data-bitsnap-returns-slot":"submitButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, H,y.className),style:y.style,children:[n.isStarting&&_jsxruntime.jsx.call(void 0, re,{}),t("emailSubmit")]})]})})}function gr(e){let[r,t]=_react.useState.call(void 0, );return _react.useEffect.call(void 0, ()=>{if(e==null)return;t(Date.now());let n=setInterval(()=>{let o=Date.now();t(o),o>=e&&clearInterval(n)},1e3);return()=>clearInterval(n)},[e]),e!=null&&r!=null?Math.max(0,Math.ceil((e-r)/1e3)):0}function _n({onVerified:e,onBack:r,className:t}){T("ReturnsCodeStep");let n=h(),o=de(),[u,s]=_react.useState.call(void 0, ""),a=gr(_optionalChain([o, 'access', _36 => _36.challenge, 'optionalAccess', _37 => _37.resendAvailableAt])),y=l("codeForm"),m=l("codeInput"),p=l("submitButton"),f=l("resendButton"),c=o.isVerifying||o.isStarting;async function b(g){g.preventDefault(),!c&&await o.verify(u)&&_optionalChain([e, 'optionalCall', _38 => _38()])}return _jsxruntime.jsx.call(void 0, M,{className:t,onBack:r,title:n("codeStepTitle"),description:n("codeStepDescription",{email:_nullishCoalesce(_optionalChain([o, 'access', _39 => _39.challenge, 'optionalAccess', _40 => _40.email]), () => (""))}),children:_jsxruntime.jsxs.call(void 0, "form",{"data-bitsnap-returns-slot":"codeForm",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-4",y.className),style:y.style,onSubmit:b,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, te,{htmlFor:"bitsnap-returns-code",children:n("codeLabel")}),_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.r,{id:"bitsnap-returns-code",name:"code",inputMode:"numeric",autoComplete:"one-time-code",required:!0,value:u,disabled:c,"data-bitsnap-returns-slot":"codeInput",className:_chunkGXUNRJ5Sjs.d.call(void 0, G,m.className),style:m.style,onChange:g=>s(g.target.value)})]}),o.errorKey!=null&&_jsxruntime.jsx.call(void 0, A,{errorKey:o.errorKey}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-center gap-3",children:[_jsxruntime.jsxs.call(void 0, _chunkWPOXLITYjs.q,{type:"submit",disabled:c||o.challenge==null,"data-bitsnap-returns-slot":"submitButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, H,p.className),style:p.style,children:[o.isVerifying&&_jsxruntime.jsx.call(void 0, re,{}),n("codeSubmit")]}),_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.q,{type:"button",variant:"secondary",disabled:c||a>0||o.challenge==null,"data-bitsnap-returns-slot":"resendButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, L,f.className),style:f.style,onClick:()=>void o.resend(),children:a>0?n("resendIn",{seconds:a}):n("resend")})]})]})})}function It(){let e=h(),r=de(),t=l("logoutButton");return _jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.q,{type:"button",variant:"ghost",size:"sm","data-bitsnap-returns-slot":"logoutButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, "text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",t.className),style:t.style,onClick:r.logout,children:e("logout")})}function Z(e,r){if(e==null)return"";let t=_wkt.timestampDate.call(void 0, e);try{return new Intl.DateTimeFormat(r,{dateStyle:"medium"}).format(t)}catch (e10){return t.toISOString().slice(0,10)}}function ee(e,r,t){let n=typeof e=="bigint"?e:BigInt(Math.trunc(e));try{let o=new Intl.NumberFormat(t,{style:"currency",currency:r}),u=_nullishCoalesce(o.resolvedOptions().maximumFractionDigits, () => (2));return o.format(Et(n,u))}catch (e11){return`${Et(n,2)} ${r}`}}function Et(e,r){let t=e<BigInt(0),n=t?-e:e;if(r<=0)return`${t?"-":""}${n}`;let o=BigInt(10)**BigInt(r),u=n/o,s=(n%o).toString().padStart(r,"0");return`${t?"-":""}${u}.${s}`}function Ct(e,r){return Number.isFinite(e)?Math.min(Math.max(0,Math.trunc(e)),Math.max(0,r)):0}function Oe(e){return e.eligible&&e.availableQuantity>0}function Pt(e,r){return e.map(t=>({lineId:t,quantity:_nullishCoalesce(r[t], () => (0))})).filter(t=>t.quantity>0)}function cs({onSelectOrder:e,onOpenMyReturns:r,showLogout:t=!0,pageSize:n,className:o}){T("ReturnsOrderList");let u=h(),s=Y(),a=ht({pageSize:n}),y=l("orderList"),m=l("orderCard"),p=l("orderReference"),f=l("orderDate"),c=l("orderTotal"),b=l("secondaryButton");return _jsxruntime.jsxs.call(void 0, M,{className:o,title:u("ordersTitle"),description:u("ordersDescription"),children:[(t||r!=null)&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r!=null?_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, L,b.className),style:b.style,onClick:r,children:u("myReturnsLink")}):_jsxruntime.jsx.call(void 0, "span",{}),t&&_jsxruntime.jsx.call(void 0, It,{})]}),a.isLoading?_jsxruntime.jsx.call(void 0, U,{}):a.errorKey!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:a.errorKey,onRetry:a.refetch}):a.orders.length===0?_jsxruntime.jsx.call(void 0, fe,{children:u("ordersEmpty")}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"orderList",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-3",y.className),style:y.style,children:a.orders.map(g=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"orderCard",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-wrap items-center justify-between gap-3 border p-4",m.className),style:m.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"orderReference",className:_chunkGXUNRJ5Sjs.d.call(void 0, "font-medium",p.className),style:p.style,children:u("orderTitle",{reference:g.displayReference})}),_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"orderDate",className:_chunkGXUNRJ5Sjs.d.call(void 0, "text-sm",f.className),style:f.style,children:Z(g.purchasedAt,s)}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:u("orderReturnableLines",{count:g.returnableLineCount})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-4",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"orderTotal",className:_chunkGXUNRJ5Sjs.d.call(void 0, "font-medium",c.className),style:c.style,children:ee(g.totalMinor,g.currency,s)}),_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.q,{type:"button",variant:"secondary",size:"sm","aria-label":`${u("orderSelect")}: ${u("orderTitle",{reference:g.displayReference})}`,"data-bitsnap-returns-slot":"secondaryButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, L,b.className),style:b.style,onClick:()=>_optionalChain([e, 'optionalCall', _41 => _41(g.canonicalOrderId)]),children:u("orderSelect")})]})]},g.canonicalOrderId))}),_jsxruntime.jsx.call(void 0, ge,{page:a.page,total:a.total,hasNext:a.hasNext,hasPrevious:a.hasPrevious,isFetching:a.isFetching,onNext:a.next,onPrevious:a.previous})]})]})}function ds({orderId:e,onContinue:r,onBack:t,initialItems:n,initialNote:o,className:u}){T("ReturnsOrderDetail");let s=_chunkGQJDFLSLjs.m.call(void 0, );_react.useEffect.call(void 0, ()=>{s.track("return_started",{},{order_ref:null})},[s]);let a=h(),y=Y(),{order:m,returnHistory:p,isLoading:f,errorKey:c,refetch:b}=Be(e),[g,C]=_react.useState.call(void 0, ()=>Object.fromEntries((_nullishCoalesce(n, () => ([]))).map(R=>[R.lineId,R.quantity]))),[I,N]=_react.useState.call(void 0, _nullishCoalesce(o, () => (""))),[B,w]=_react.useState.call(void 0, !1),P=l("lineList"),k=l("line"),Q=l("lineName"),O=l("linePrice"),q=l("lineQuantityControl"),ne=l("quantityButton"),Me=l("quantityInput"),qe=l("lineIneligibleReason"),Ke=l("noteInput"),_e=l("submitButton"),je=l("history"),Ue=l("historyEntry");function Re(R,V){w(!1),C(F=>({...F,[R.lineId]:Ct(V,R.availableQuantity)}))}function At(R){if(R.preventDefault(),m==null)return;let V=Pt(m.lines.filter(Oe).map(F=>F.lineId),g);if(V.length===0){w(!0);return}_optionalChain([r, 'optionalCall', _42 => _42({items:V,note:I.trim()})])}return _jsxruntime.jsx.call(void 0, M,{className:u,onBack:t,title:a("orderDetailTitle",{reference:_nullishCoalesce(_optionalChain([m, 'optionalAccess', _43 => _43.displayReference]), () => (""))}),description:a("orderDetailDescription"),children:f?_jsxruntime.jsx.call(void 0, U,{}):c!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:c,onRetry:b}):m==null?null:_jsxruntime.jsxs.call(void 0, "form",{className:"flex flex-col gap-5",onSubmit:At,children:[_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"lineList",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-3",P.className),style:P.style,children:m.lines.map(R=>{let V=Oe(R),F=_nullishCoalesce(g[R.lineId], () => (0)),be=`bitsnap-returns-quantity-${R.lineId}`;return _jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"line","data-selected":F>0?"":void 0,"data-ineligible":V?void 0:"",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-3 border p-4",k.className),style:k.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"lineName",className:_chunkGXUNRJ5Sjs.d.call(void 0, "font-medium",Q.className),style:Q.style,children:R.name}),_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"linePrice",className:_chunkGXUNRJ5Sjs.d.call(void 0, "text-sm",O.className),style:O.style,children:ee(R.paidUnitMinor,R.currency,y)})]}),V?_jsxruntime.jsxs.call(void 0, "div",{role:"group","aria-label":a("quantityLabel",{name:R.name}),"data-bitsnap-returns-slot":"lineQuantityControl",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex items-center gap-2",q.className),style:q.style,children:[_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.q,{type:"button",variant:"secondary",size:"icon-sm","aria-label":a("quantityDecrease",{name:R.name}),"aria-controls":be,disabled:F<=0,"data-bitsnap-returns-slot":"quantityButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, L,ne.className),style:ne.style,onClick:()=>Re(R,F-1),children:_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:"-"})}),_jsxruntime.jsx.call(void 0, "input",{id:be,type:"number",inputMode:"numeric",min:0,max:R.availableQuantity,step:1,value:F,"aria-label":a("quantityLabel",{name:R.name}),"data-bitsnap-returns-slot":"quantityInput",className:_chunkGXUNRJ5Sjs.d.call(void 0, "h-8 w-16 rounded-md border px-2 text-center text-sm outline-none focus-visible:ring-[3px]",G,Me.className),style:Me.style,onChange:Bt=>Re(R,Bt.target.valueAsNumber)}),_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.q,{type:"button",variant:"secondary",size:"icon-sm","aria-label":a("quantityIncrease",{name:R.name}),"aria-controls":be,disabled:F>=R.availableQuantity,"data-bitsnap-returns-slot":"quantityButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, L,ne.className),style:ne.style,onClick:()=>Re(R,F+1),children:_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:"+"})}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:a("quantityOfAvailable",{available:R.availableQuantity})})]}):_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"lineIneligibleReason",className:_chunkGXUNRJ5Sjs.d.call(void 0, "text-sm",qe.className),style:qe.style,children:R.exclusionReason!==""?R.exclusionReason:a("lineIneligibleFallback")})]},R.lineId)})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, te,{htmlFor:"bitsnap-returns-note",children:a("noteLabel")}),_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.v,{id:"bitsnap-returns-note",name:"note",rows:3,maxLength:1e3,value:I,placeholder:a("notePlaceholder"),"data-bitsnap-returns-slot":"noteInput",className:_chunkGXUNRJ5Sjs.d.call(void 0, G,"dark:border-[color:var(--bitsnap-returns-border,#e4e4e7)] dark:placeholder:text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] dark:focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]",Ke.className),style:Ke.style,onChange:R=>N(R.target.value)})]}),B&&_jsxruntime.jsx.call(void 0, A,{errorKey:"selectionEmpty"}),_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.q,{type:"submit","data-bitsnap-returns-slot":"submitButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, H,_e.className),style:_e.style,children:a("selectionContinue")}),p.length>0&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:a("previousReturnsTitle")}),_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"history",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-2",je.className),style:je.style,children:p.map(R=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"historyEntry",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-wrap items-center justify-between gap-2 text-sm",Ue.className),style:Ue.style,children:[_jsxruntime.jsx.call(void 0, "span",{children:R.reference}),_jsxruntime.jsx.call(void 0, "span",{children:Z(R.createdAt,y)}),_jsxruntime.jsx.call(void 0, J,{status:R.status})]},R.id))})]})]})})}function ps({orderId:e,items:r,note:t,onSubmitted:n,onBack:o,className:u}){T("ReturnsConfirmation");let s=h(),a=Y(),{order:y,isLoading:m,errorKey:p,refetch:f}=Be(e),c=kt(),b=l("summary"),g=l("line"),C=l("lineName"),I=l("linePrice"),N=l("submitButton");async function B(w){if(w.preventDefault(),c.isPending)return;let P=await c.submit({orderId:e,items:r.map(k=>({lineId:k.lineId,quantity:k.quantity})),note:t});P!=null&&_optionalChain([n, 'optionalCall', _44 => _44(P.id,P)])}return _jsxruntime.jsx.call(void 0, M,{className:u,onBack:o,title:s("confirmationTitle"),description:s("confirmationDescription"),children:m?_jsxruntime.jsx.call(void 0, U,{rows:2}):p!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:p,onRetry:f}):_jsxruntime.jsxs.call(void 0, "form",{className:"flex flex-col gap-5",onSubmit:B,children:[_jsxruntime.jsxs.call(void 0, "div",{"data-bitsnap-returns-slot":"summary",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-3 border p-4",b.className),style:b.style,children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:s("confirmationSummary")}),_jsxruntime.jsx.call(void 0, "ul",{className:"flex flex-col gap-3",children:r.map(w=>{let P=_optionalChain([y, 'optionalAccess', _45 => _45.lines, 'access', _46 => _46.find, 'call', _47 => _47(k=>k.lineId===w.lineId)]);return _jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"line",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-wrap items-baseline justify-between gap-2",g.className),style:g.style,children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"lineName",className:_chunkGXUNRJ5Sjs.d.call(void 0, "font-medium",C.className),style:C.style,children:_nullishCoalesce(_optionalChain([P, 'optionalAccess', _48 => _48.name]), () => (w.lineId))}),_jsxruntime.jsxs.call(void 0, "span",{"data-bitsnap-returns-slot":"linePrice",className:_chunkGXUNRJ5Sjs.d.call(void 0, "text-sm",I.className),style:I.style,children:[s("confirmationQuantity",{quantity:w.quantity}),P!=null&&` \xB7 ${ee(P.paidUnitMinor*BigInt(w.quantity),P.currency,a)}`]})]},w.lineId)})}),t!=null&&t!==""&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1 text-sm",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:s("confirmationNote")}),_jsxruntime.jsx.call(void 0, "span",{className:"whitespace-pre-wrap",children:t})]})]}),c.errorKey!=null&&_jsxruntime.jsx.call(void 0, A,{errorKey:c.errorKey}),_jsxruntime.jsxs.call(void 0, _chunkWPOXLITYjs.q,{type:"submit",disabled:c.isPending||r.length===0,"data-bitsnap-returns-slot":"submitButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, H,N.className),style:N.style,children:[c.isPending&&_jsxruntime.jsx.call(void 0, re,{}),s("confirmationSubmit")]})]})})}function ms({returnId:e,onContinue:r,onOpenMyReturns:t,className:n}){T("ReturnsResult");let o=h(),{request:u,isLoading:s,errorKey:a,refetch:y}=me(e),m=l("successState"),p=l("returnReference"),f=l("returnInstructions"),c=l("submitButton"),b=l("secondaryButton");return _jsxruntime.jsxs.call(void 0, "section",{className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-5",n),children:[_jsxruntime.jsxs.call(void 0, "div",{role:"status","data-bitsnap-returns-slot":"successState",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-4 border p-5",m.className),style:m.style,children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-2xl font-semibold",children:o("successTitle")}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:o("successDescription")}),s?_jsxruntime.jsx.call(void 0, U,{rows:2}):a!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:a,onRetry:y}):u!=null&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:o("successReference")}),_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"returnReference",className:_chunkGXUNRJ5Sjs.d.call(void 0, "text-lg font-semibold",p.className),style:p.style,children:u.reference})]}),u.returnInstructions!==""&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-medium",children:o("successInstructions")}),_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"returnInstructions",className:_chunkGXUNRJ5Sjs.d.call(void 0, "whitespace-pre-wrap border p-3 text-sm",f.className),style:f.style,children:u.returnInstructions})]})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap gap-3",children:[_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.q,{type:"button","data-bitsnap-returns-slot":"submitButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, H,c.className),style:c.style,onClick:r,children:o("successDone")}),t!=null&&_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.q,{type:"button",variant:"secondary","data-bitsnap-returns-slot":"secondaryButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, L,b.className),style:b.style,onClick:t,children:o("myReturnsLink")})]})]})}function Ts({onSelectReturn:e,onBack:r,pageSize:t,className:n}){T("ReturnsMyReturnsList");let o=h(),u=Y(),s=ze(),a=Tt({pageSize:t}),y=l("returnList"),m=l("returnCard"),p=l("returnReference"),f=l("secondaryButton");return _jsxruntime.jsx.call(void 0, M,{className:n,onBack:r,title:o("myReturnsTitle"),description:o("myReturnsDescription"),children:a.isLoading?_jsxruntime.jsx.call(void 0, U,{}):a.errorKey!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:a.errorKey,onRetry:a.refetch}):a.returns.length===0?_jsxruntime.jsx.call(void 0, fe,{children:o("myReturnsEmpty")}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"returnList",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-3",y.className),style:y.style,children:a.returns.map(c=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"returnCard",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-wrap items-center justify-between gap-3 border p-4",m.className),style:m.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"returnReference",className:_chunkGXUNRJ5Sjs.d.call(void 0, "font-medium",p.className),style:p.style,children:c.reference}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:Z(c.createdAt,u)}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-sm",children:[o("myReturnRefund"),": ",s(c.refundStatus)]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-3",children:[_jsxruntime.jsx.call(void 0, J,{status:c.status}),_jsxruntime.jsx.call(void 0, _chunkWPOXLITYjs.q,{type:"button",variant:"secondary",size:"sm","aria-label":`${o("myReturnOpen")}: ${c.reference}`,"data-bitsnap-returns-slot":"secondaryButton",className:_chunkGXUNRJ5Sjs.d.call(void 0, L,f.className),style:f.style,onClick:()=>_optionalChain([e, 'optionalCall', _49 => _49(c.id)]),children:o("myReturnOpen")})]})]},c.id))}),_jsxruntime.jsx.call(void 0, ge,{page:a.page,total:a.total,hasNext:a.hasNext,hasPrevious:a.hasPrevious,isFetching:a.isFetching,onNext:a.next,onPrevious:a.previous})]})})}function ws({returnId:e,onBack:r,className:t}){T("ReturnsMyReturnDetail");let n=h(),o=Y(),u=ze(),{request:s,isLoading:a,errorKey:y,refetch:m}=me(e),p=l("summary"),f=l("lineList"),c=l("line"),b=l("lineName"),g=l("returnInstructions"),C=l("history"),I=l("historyEntry");return _jsxruntime.jsx.call(void 0, M,{className:t,onBack:r,title:s!=null?n("myReturnTitle",{reference:s.reference}):n("myReturnDetailTitle"),children:a?_jsxruntime.jsx.call(void 0, U,{}):y!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:y,onRetry:m}):s!=null&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-5",children:[_jsxruntime.jsxs.call(void 0, "div",{"data-bitsnap-returns-slot":"summary",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-2 border p-4 text-sm",p.className),style:p.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between gap-2",children:[_jsxruntime.jsx.call(void 0, J,{status:s.status}),_jsxruntime.jsxs.call(void 0, "span",{children:[n("myReturnCreatedAt"),":"," ",Z(s.createdAt,o)]})]}),_jsxruntime.jsxs.call(void 0, "span",{children:[n("myReturnRefund"),": ",u(s.refundStatus),s.refundAmountMinor>BigInt(0)&&` \xB7 ${ee(s.refundAmountMinor,s.currency,o)}`]}),s.customerNote!==""&&_jsxruntime.jsxs.call(void 0, "span",{className:"whitespace-pre-wrap",children:[n("myReturnNote"),": ",s.customerNote]})]}),s.returnInstructions!==""&&_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"returnInstructions",className:_chunkGXUNRJ5Sjs.d.call(void 0, "whitespace-pre-wrap border p-3 text-sm",g.className),style:g.style,children:s.returnInstructions}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:n("myReturnLines")}),_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"lineList",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-3",f.className),style:f.style,children:s.lines.map(N=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"line",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-wrap items-baseline justify-between gap-2 border p-4",c.className),style:c.style,children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"lineName",className:_chunkGXUNRJ5Sjs.d.call(void 0, "font-medium",b.className),style:b.style,children:N.name}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:n("myReturnLineQuantities",{requested:N.requestedQuantity,approved:N.approvedQuantity,received:N.receivedQuantity})})]},N.lineId))})]}),s.history.length>0&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:n("myReturnHistory")}),_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"history",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-col gap-2",C.className),style:C.style,children:s.history.map(N=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"historyEntry",className:_chunkGXUNRJ5Sjs.d.call(void 0, "flex flex-wrap items-center justify-between gap-2 text-sm",I.className),style:I.style,children:[_jsxruntime.jsx.call(void 0, J,{status:N.status}),_jsxruntime.jsx.call(void 0, "span",{children:Z(N.createdAt,o)})]},N.id))})]})]})})}exports.a = te; exports.b = re; exports.c = vr; exports.d = nt; exports.e = Ne; exports.f = l; exports.g = Pe; exports.h = St; exports.i = h; exports.j = T; exports.k = ir; exports.l = Xr; exports.m = de; exports.n = ht; exports.o = Be; exports.p = kt; exports.q = Tt; exports.r = me; exports.s = U; exports.t = Kn; exports.u = _n; exports.v = cs; exports.w = ds; exports.x = ps; exports.y = ms; exports.z = Ts; exports.A = ws;
|
|
2
|
-
//# sourceMappingURL=chunk-QERYM7RC.js.map
|