efficient-storefront-blocks 0.53.1 → 0.55.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.
@@ -1 +0,0 @@
1
- import{g as ct,j as me,r as dt,t as ft,u as pt,w as B}from"./chunk-VHVJ74KF.js";import{Aa as pe,Ba as st,Ea as $e,Fa as lt,Ia as Be,Ja as We}from"./chunk-HQ2Q5HZE.js";import{c as at,n as ut,p as oe}from"./chunk-VHOOQYWZ.js";import{createContext as ln,useContext as un,useEffect as cn,useMemo as he,useState as ht}from"react";function mt(e,t){return e.map(n=>({partNumber:n.partNumber,quantity:n.wheels*t}))}function ie(e,t){if(e.length===0)return null;let n=0;for(let r of e){let o=r.prices?.[t];if(typeof o!="number"||!Number.isFinite(o)||o<=0)return null;n+=o*r.wheels}return n}var Ke=4,Pr=1,wr={unit:"set",spares:0,spareSide:"left"};function gt(e){return e.unit==="single"?1:Ke+e.spares}function _r(e,t){return[{partNumber:e.partNumber,wheels:gt(t),prices:e.prices}]}function Rr(e,t){let n=gt(t)-Ke;if(n<=0||e.length===0)return e;let r=an(e),o=r?r[t.spareSide]:0;return e.map((i,a)=>a===o?{...i,wheels:i.wheels+n}:i)}function an(e){let t,n;for(let r=0;r<e.length;r+=1){let o=e[r].hand;if(o!=="left"&&o!=="right")continue;if((o==="left"?t:n)!==void 0)return null;o==="left"?t=r:n=r}return t!==void 0&&n!==void 0?{left:t,right:n}:null}function sn(e,t){return t.spares>0?`${e} + spare`:e}function Nr(e){return e.unit==="single"?"Single":sn(`Set of ${Ke}`,e)}var Lr="data-add-to-basket",qe=9,Ne="en";function ge(e,t,n=0){return new Intl.NumberFormat(Ne,{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:n}).format(e)}function Ir(e,t){return new Intl.NumberFormat(Ne,{style:"currency",currency:t}).format(e)}import{jsx as mn}from"react/jsx-runtime";var dn="storefront-country",yt=dn,bt=ln(null);function fn(e){return Ct(e,"catalogue")}function pn(e){return Ct(e,"money")}function Ct(e,t){let n=new Map(e.map(o=>[o.code,o.decimalPlaces])),r=new Map;return(o,i)=>{if(!i)return"";let a=r.get(i);if(!a){let s=n.get(i)??0;a=new Intl.NumberFormat(Ne,{style:"currency",currency:i,minimumFractionDigits:t==="money"?s:0,maximumFractionDigits:s}),r.set(i,a)}return a.format(o)}}function Mr({children:e,currencies:t,countries:n,defaultCurrency:r,defaultCountry:o}){let i=he(()=>t??[],[t]),a=he(()=>n??[],[n]),s=he(()=>r||i.find(y=>y.isDefault)?.code||i[0]?.code||"",[r,i]),c=he(()=>o||a.find(y=>y.isDefault)?.code||a[0]?.code||"",[o,a]),[u,f]=ht(c),[d,S]=ht(!1);cn(()=>{let y=oe.getItem(yt);y&&a.some(w=>w.code===y)&&f(y),S(!0)},[a]);function R(y){f(y),oe.setItem(yt,y)}let C=he(()=>{let y=a.find(v=>v.code===u)??null,w=y?.currency,O=w&&i.some(v=>v.code===w)?w:s,M=fn(i),L=pn(i);return{country:u,currency:O,setCountry:R,currencies:i,countries:a,activeCountry:y,formatPrice:(v,x)=>M(v,x??O),formatMoney:(v,x)=>L(v,x??O),ready:d}},[u,i,a,s,d]);return mn(bt.Provider,{value:C,children:e})}function xt(){let e=un(bt);if(!e)throw new Error("useCurrency must be used within a CurrencyProvider");return e}import{createContext as Ln,useCallback as T,useContext as In,useEffect as j,useMemo as kt,useRef as ae,useState as k}from"react";function vt(e,t){return e.valid?!1:e.reason==="firstOrderOnly"?!0:e.reason==="notEligible"&&!t}var Et="We'll confirm this discount when you place your order.",Hr="Confirmed at checkout";function $r(e){return e&&(e.valid||e.deferred)?e.code:void 0}var St="coupon_code: ";function Br(e){return!(e instanceof me)||e.status!==400||!e.message.startsWith(St)?null:e.message.slice(St.length)}function Pt(e,t){return e.map(n=>({qty:n.qty,slug:n.slug,name:`${n.name.lead}${n.name.accent}`.trim(),finish:n.finishName,size:n.size,kind:n.kind,sku:n.sku,pack:n.pack,priceLabel:t(n)}))}var Le="Price on request",hn="Request a quote",yn="from ",Gr="From ",zr="each",wt="Free";function Ge(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function ze(e,t){let n=e?.[t];return Ge(n)?n:null}function Xr(e,t,n,r){let o=ze(e,n),i=ze(t,n);return o===null&&i===null?0:o===null?1:i===null?-1:r==="asc"?o-i:i-o}function Yr(e,t,n,r){if(n==null&&r==null)return!0;let o=ze(e,t);return!(o===null||n!=null&&o<n||r!=null&&o>r)}var bn={priced:!1,unit:null,was:null,onSale:!1,setTotal:null};function Cn(e,t,n){if(!Ge(e))return bn;let r=Ge(t)&&t>e?t:null;return{priced:!0,unit:e,was:r,onSale:r!==null,setTotal:n!=null?e*n:null}}function Vr(e,t,n=""){return!e.priced||e.unit==null?Le:`${n}${ge(e.unit,t)}`}function jr(e,t){return e.was==null?null:ge(e.was,t)}function xn(e,t,n=1){let r=ie(e,t);if(r===null)return{priced:!1,unit:null,isFrom:!1,setTotal:null};let o=e.reduce((a,s)=>a+s.wheels,0),i=Math.min(...e.map(a=>a.prices[t]));return{priced:!0,unit:i,isFrom:i*o!==r,setTotal:r*n}}var Sn={priced:!1,unit:null,isFrom:!1,was:null,onSale:!1,setTotal:null};function Qr(e,t,n,r=1){let o=Cn(e.prices[n],e.msrpPrices?.[n],4),i=o.setTotal==null?null:o.setTotal*r;if(!t)return{priced:o.priced,unit:o.unit,isFrom:!0,was:o.was,onSale:o.onSale,setTotal:null,fromSetTotal:i};let a=xn(t.components,n,r);return a.priced?{priced:!0,unit:a.unit,isFrom:a.isFrom,was:null,onSale:!1,setTotal:a.setTotal,fromSetTotal:i}:{...Sn,fromSetTotal:i}}function vn(e,t){return!e.priced||e.unit==null?Le:`${e.isFrom?yn:""}${ge(e.unit,t)}`}function Zr(e,t){return e.was==null?null:ge(e.was,t)}function Jr(e,t){return!e.priced||e.unit==null?hn:vn(e,t)}var En=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function _t(e){return En.test(e.trim())}var Rt="sf:ga-purchases",Pn=20;function Lt(){return typeof window>"u"||window.parent!==window}function ye(...e){try{if(Lt()||typeof window.gtag!="function")return;window.gtag(...e)}catch{}}function wn(e,t){let n=e.config.find(r=>r.gold)?.label;return{item_id:`${e.slug}|${e.finishName}|${e.size}`,item_name:`${e.name.lead}${e.name.accent}`.trim(),...n?{item_variant:n}:{},price:ie(e.components,t)??0,quantity:e.qty}}function Xe(e,t){return e.filter(Ie).map(n=>wn(n,t))}function io(e){ye("event","view_item",{currency:e.currency,value:e.pricePerSet,items:[{item_id:e.itemId,item_name:e.itemName,...e.variant?{item_variant:e.variant}:{},price:e.pricePerSet,quantity:1}]})}function It(e,t){let n=Xe([e],t);n.length!==0&&ye("event","add_to_cart",{currency:t,value:n[0].price*n[0].quantity,items:n})}function ao(e){let t=Xe(e.lines,e.currency);t.length!==0&&ye("event","begin_checkout",{currency:e.currency,value:e.value,...e.coupon?{coupon:e.coupon}:{},items:t})}var Nt=new Set;function _n(e){if(Nt.has(e))return!1;Nt.add(e);try{let t=JSON.parse(oe.getItem(Rt)??"[]");if(t.includes(e))return!1;oe.setItem(Rt,JSON.stringify([...t,e].slice(-Pn)))}catch{}return!0}function so(e){let t=e.confirmation;if(Lt()||!_n(t.orderNumber))return;let n=t.currency,r=Number(t.grandTotal);ye("event","purchase",{transaction_id:t.orderNumber,currency:n,value:r,shipping:Number(t.freightCharge),...t.couponCode?{coupon:t.couponCode}:{},items:Xe(e.lines,n)}),e.adsSendTo&&ye("event","conversion",{send_to:e.adsSendTo,transaction_id:t.orderNumber,currency:n,value:r})}var Rn="Arranged after review",At="Calculated at checkout",Nn=At,co=At;function Tt({quoted:e,optionCount:t,chosenAmount:n,couponWaivesFreight:r}){return e&&t===0?"arranged":r?"free":n===void 0?"pending":n===0?"free":"charged"}function fo(e){switch(e){case"arranged":return Rn;case"pending":return Nn;case"free":return wt;case"charged":return null}}import{jsx as On}from"react/jsx-runtime";var An=400,Tn=400,kn=1500;function Ie(e){return(e.components?.length??0)>0}function Ot(e,t){return{code:e,valid:t.valid,deferred:vt(t,t.askedAsShopper),message:t.message||void 0,effects:t.effects??void 0}}function Dt(e,t){return ie(e.components,t)}function Ye(e,t){let n=Dt(e,t);return n===null?null:n*e.qty}function Mt(e){return e!=="tyre"}var Ft=Ln(null);function Po({children:e,preview:t=!1}){let{currency:n,country:r,formatMoney:o}=xt(),[i,a]=k(t),[s,c]=k([]),[u,f]=k([]),[d,S]=k([]),[R,C]=k(!1),[y,w]=k(!1),[O,M]=k(!1),[L,v]=k(!1),[x,W]=k(null),[I,K]=k(void 0),b=ae(r),_=ae("");b.current=b.current||r;let[p,q]=k(null),[Q,F]=k(!1),[D,ve]=k(null),G=ae(void 0),Y=T(()=>a(!0),[]),le=T(()=>a(!1),[]),Z=T(()=>a(l=>!l),[]);j(()=>{t||typeof window>"u"||new URLSearchParams(window.location.search).get("cart")==="open"&&Y()},[Y,t]);let Ee=T(l=>{v(!0),Mt(l)&&M(!0)},[]),U=O||s.some(l=>Mt(l.kind)),Pe=L||s.length>0;j(()=>{if(t||!U||R)return;let l=!0;return B.listWheels().then(m=>{l&&(f(m),C(!0))}),()=>{l=!1}},[t,U,R]),j(()=>{if(t||!Pe||y)return;let l=!0;return B.listBundles().then(m=>{l&&(S(m),w(!0))}),()=>{l=!1}},[t,Pe,y]);let P=x?.deliveryOptions??[];j(()=>{P.length!==0&&ve(l=>l&&P.some(m=>m.id===l)?l:P[0]?.id??null)},[x]);let J=T(()=>s.filter(Ie).flatMap(l=>mt(l.components,l.qty)),[s]),ee=T(async(l,m)=>{let h=l.trim().toUpperCase();if(!h)return;let g=J();if(g.length===0){q({code:h,valid:!1,message:"Add a wheel to the cart first."});return}F(!0),G.current=m;try{let N=await B.validateCoupon({code:h,items:g,currency:n,shippingMethodId:D??void 0,customerEmail:m});q(Ot(h,N))}catch{q({code:h,valid:!1,message:"Could not check that code. Please try again."})}finally{F(!1)}},[J,n,D]),ue=T(()=>{q(null),G.current=void 0},[]),ce=T(l=>{if(!p)return;let{code:m}=p;q(h=>h&&h.code===m?{code:m,valid:!1,refused:!0,message:l}:h)},[p]);j(()=>{if(!p||p.refused)return;let l=p.code,m=g=>g!==null&&g.code===l&&!g.refused,h=setTimeout(async()=>{let g=J();if(g.length===0){q(N=>m(N)?{code:l,valid:!1,message:"Add a wheel to the cart first."}:N);return}F(!0);try{let N=await B.validateCoupon({code:l,items:g,currency:n,shippingMethodId:D??void 0,customerEmail:G.current});q(fe=>m(fe)?Ot(l,N):fe)}catch{}finally{F(!1)}},An);return()=>clearTimeout(h)},[s,n,D]);let te=p&&!p.refused?p.code:void 0;j(()=>{if(t)return;let l=!0,m=setTimeout(async()=>{let h=J();if(h.length===0){W(null),K(void 0);return}try{let g=await B.quoteCart({items:h,currency:n,shippingMethodId:D??void 0,couponCode:te,customerEmail:G.current||void 0,country:b.current||void 0,subdivision:_.current||void 0});if(!l)return;W(g)}catch{if(!l)return}K(te)},Tn);return()=>{l=!1,clearTimeout(m)}},[s,n,D,te,r]);let de=T(l=>{c(m=>{let h=m.findIndex(g=>g.id===l.id);return h===-1?[...m,l]:m.map((g,N)=>N===h?{...g,qty:Math.min(qe,g.qty+l.qty)}:g)}),It(l,n)},[n]),ne=T(l=>{c(m=>m.filter(h=>h.id!==l))},[]),we=T((l,m)=>{let h=Math.max(1,Math.min(qe,m));c(g=>g.map(N=>N.id===l?{...N,qty:h}:N))},[]),_e=T(l=>{c(l)},[]),[E,H]=k(null),V=ae(null);V.current=E;let $=ae(null),Fe=ae(""),tt=T((l,m)=>{let h=l.trim().toLowerCase();_t(h)&&H(g=>g&&g.email===h&&g.firstName===(m??"")?g:{email:h,firstName:m??""})},[]);j(()=>{if(t||!E)return;let l=Pt(s.filter(Ie),g=>Ye(g,n)===null?Le:o(Ye(g,n),n)),m={email:E.email,firstName:E.firstName,currency:n,items:l},h=JSON.stringify(m);if(h!==Fe.current)return $.current&&clearTimeout($.current),$.current=setTimeout(()=>{$.current=null,Fe.current=h,B.captureCart(m).catch(g=>{})},kn),()=>{$.current&&(clearTimeout($.current),$.current=null)}},[s,E,n,t]);let nt=T(()=>{$.current&&(clearTimeout($.current),$.current=null);let l=V.current;l&&(Fe.current="",B.captureCart({email:l.email,firstName:l.firstName,currency:n,items:[]}).catch(m=>{}))},[n]),rt=kt(()=>{let l=s.reduce((A,re)=>{let Re=Ye(re,n);return Re===null?A:A+Re},0),m=s.some(A=>Dt(A,n)===null),h=s.reduce((A,re)=>A+re.qty,0),g=p?.valid?p.effects:void 0,N=g?Math.min(l,Number(g.discountAmount)):0,fe=x?.bundleDiscount??0,en=x?.appliedBundles??[],Ue=!!g?.freeShipping,ot=P.find(A=>A.id===D),it=Ue?0:x?.shipping??ot?.amount??0,tn=Tt({quoted:x!==null,optionCount:P.length,chosenAmount:ot?.amount,couponWaivesFreight:Ue}),He={};for(let A of g?.freeUnits??[])He[A.partNumber]=(He[A.partNumber]??0)+A.quantity;let nn=x?.tax??null,rn=x?x.grandTotal:l-N-fe+it;return{sets:h,units:s.reduce((A,re)=>A+(re.components??[]).reduce((Re,on)=>Re+on.wheels*re.qty,0),0),subtotal:l,hasUnpricedLine:m,discount:N,bundleDiscount:fe,appliedBundles:en,shipping:it,freeShipping:Ue,shippingStatus:tn,freeUnitsByPartNumber:He,tax:nn,grand:rn,repricing:!!p?.refused&&x!==null&&I===p?.code,currency:n}},[s,n,p,P,D,x,I]),Jt=kt(()=>({isOpen:i,preview:t,open:Y,close:le,toggle:Z,items:s,catalog:u,bundles:d,warmCatalog:Ee,add:de,remove:ne,setQty:we,replaceItems:_e,identify:tt,clearCapturedCart:nt,coupon:p,applyCoupon:ee,removeCoupon:ue,refuseCoupon:ce,couponBusy:Q,deliveryOptions:P,shippingMethodId:D,setShippingMethodId:ve,totals:rt}),[i,t,Y,le,Z,s,u,d,Ee,de,ne,we,_e,tt,nt,p,ee,ue,ce,Q,P,D,rt]);return On(Ft.Provider,{value:Jt,children:e})}function Ut(){let e=In(Ft);if(!e)throw new Error("useCart() must be called inside <CartProvider>. Mount the provider in app/layout.tsx.");return e}import{cache as Gn}from"react";function Ht(e,t,n,r){for(;e.size>=t;){let o,i;for(let[s,c]of e){if(c.expiresAt<=r){o=s;break}i===void 0&&n(s)&&(i=s)}let a=o??i??e.keys().next().value;if(a===void 0)return;e.delete(a)}}var Mn=6e4,Dn=5e3,Fn=500,Ae=new Map;async function Un(e){let{host:t,matchesRequestHost:n}=await dt();if(!t)return"";let r=await ft();return r?`${e}|slug:${encodeURIComponent(t)}/${encodeURIComponent(r)}`:n?`${e}|host:${t}`:`${e}|xhost:${t}`}var Hn=e=>e.includes("|slug:")||e.includes("|xhost:");async function $t(e,t){if(await pt()!==null)return t();let n=await Un(e);if(!n)return t();let r=Date.now(),o=Ae.get(n);if(o&&o.expiresAt>r)return o.load;let i=await t(),a=i.outcome.state==="failed",s=a?Dn:Mn,c=Ae.get(n)?.lastGood,u=i.outcome.state==="ok"?i:a?c:void 0,f=a&&u?u:i;return Ht(Ae,Fn,Hn,r),Ae.set(n,{load:f,expiresAt:r+s,lastGood:u}),f}var $n=404;function Bn(e){if(e instanceof me&&e.status===$n)return{state:"absent"};let t=e instanceof me?e.status:-1,n=e instanceof Error?e.message:String(e);return{state:"failed",status:t,detail:n}}var Wn="[storefront:chrome-load-failed]";function Kn(e,t){console.error(`${Wn} ${e} status=${t.status} \u2014 serving fallback chrome`,t.detail)}async function Bt(e,t,n,r){try{let o=await t();return r?.(o)?{value:o,outcome:{state:"absent"}}:{value:o,outcome:{state:"ok"}}}catch(o){let i=Bn(o);return i.state==="failed"&&Kn(e,i),{value:n,outcome:i}}}function qn(e){return e==="production"?"silent":"banner"}var To=qn("production");function zn(e,t){return e?.trim()||t}function $o({legalName:e,foundedYear:t,siteName:n},r=new Date().getFullYear()){let o=zn(e,n);return`\xA9 ${t&&t<r?`${t}\u2013${r}`:`${r}`} ${o}`}var Xn={name:pe,legalName:null,foundedYear:null,faviconUrl:null,currencies:[],defaultCurrency:null,countries:[],defaultCountry:null,commerceEnabled:!0,cardPayments:!1,paymentMethods:[],paypalClientId:null,paypalEnvironment:null,squareApplicationId:null,squareLocationId:null,squareEnvironment:null,ga4MeasurementId:null,googleAdsId:null,googleAdsConversionLabel:null,metaPixelId:null,consentEnabled:!1,consentPrivacyPage:null,consentNoticeOptOut:!1,mapsApiKey:null,mapsMapId:null,socialLinks:$e},Bo=Gn(async()=>$t("site",()=>Bt("site",async()=>{let e=await B.getSite();return{name:st(e.name),legalName:e.legalName?.trim()||null,foundedYear:e.foundedYear??null,faviconUrl:e.faviconUrl??null,currencies:e.currencies??[],defaultCurrency:e.defaultCurrency??null,countries:e.countries??[],defaultCountry:e.defaultCountry??null,commerceEnabled:e.commerceEnabled??!0,cardPayments:e.cardPayments??!1,paymentMethods:e.paymentMethods??(e.cardPayments?["card"]:[]),paypalClientId:e.paypalClientId??null,paypalEnvironment:e.paypalEnvironment??null,squareApplicationId:e.squareApplicationId??null,squareLocationId:e.squareLocationId??null,squareEnvironment:e.squareEnvironment??null,ga4MeasurementId:e.ga4MeasurementId??null,googleAdsId:e.googleAdsId??null,googleAdsConversionLabel:(e.googleAdsId?e.googleAdsConversionLabel:null)??null,metaPixelId:e.metaPixelId??null,consentEnabled:e.consentEnabled??!1,consentPrivacyPage:e.consentPrivacyPage??null,consentNoticeOptOut:e.consentNoticeOptOut??!1,mapsApiKey:e.mapsApiKey??null,mapsMapId:e.mapsMapId??null,socialLinks:lt(e.socialLinks)}},Xn)));var Wo={name:pe,legalName:null,foundedYear:null,faviconUrl:null,currencies:[{code:"USD",symbol:"$",decimalPlaces:2,isDefault:!0}],defaultCurrency:"USD",countries:[{code:"US",name:"United States",currency:"USD",url:"",isDefault:!0,chargeTax:!1,taxDisplay:"none",taxName:"",taxRate:null,postalLabel:"Zip Code"}],defaultCountry:"US",commerceEnabled:!0,cardPayments:!0,paymentMethods:["card"],paypalClientId:null,paypalEnvironment:null,squareApplicationId:null,squareLocationId:null,squareEnvironment:null,ga4MeasurementId:null,googleAdsId:null,googleAdsConversionLabel:null,metaPixelId:null,consentEnabled:!1,consentPrivacyPage:null,consentNoticeOptOut:!1,mapsApiKey:null,mapsMapId:null,socialLinks:$e};import{jsx as Ce,jsxs as Ve}from"react/jsx-runtime";import{useEffect as Te,useId as jn,useRef as Kt,useState as ke}from"react";var be=new Map,Yn=64;async function Vn(e){if(!at())return null;try{let t=await fetch(`${ut()}/logo-analysis.json?url=${encodeURIComponent(e)}`);if(!t.ok)return null;let n=await t.json();if(!n||typeof n!="object")return null;let{reversed:r,inkIsDark:o}=n;return typeof r!="string"?null:{reversed:r,inkIsDark:typeof o=="boolean"?o:null}}catch{return null}}function Wt(e){let t=be.get(e);if(t)return t;let n=Vn(e);if(be.set(e,n),be.size>Yn){let r=be.keys().next();r.done||be.delete(r.value)}return n}var Qn=202/22,Zn=.88,ri=16,Jn="invert(1)";function oi({variant:e="header",scrolled:t=!0,src:n,reverse:r=!1,color:o=null,onLightSurface:i,reversedSrc:a,inkIsDark:s,size:c="medium",sizePx:u,wordmark:f,siteName:d=pe,fitToContainer:S=!1,fitWordmarkToContainer:R=!1,fitFloorPx:C}){let y=f&&f.trim()?f.trim():d,[w,O]=ke(!1),M=Kt(null),L=E=>{M.current=E};Te(()=>{let E=M.current?.ownerDocument??document,H=()=>{O(E.documentElement.getAttribute("data-theme")==="light")};H();let V=new MutationObserver(H);return V.observe(E.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>V.disconnect()},[]);let v=n&&n.trim()?n.trim():null,x=!!v&&ct(v),W=i??(w&&t),I=o&&o.trim()?o.trim():null,K=r&&!I,b=`logo-color-${jn().replace(/[^A-Za-z0-9_-]/g,"")}`,_=K&&x&&v&&a!=null?{reversed:a,inkIsDark:s??null}:null,p=_!==null,[q,Q]=ke(null);Te(()=>{if(!K||!v||!x||p){Q(null);return}let E=!1;return Q(null),Wt(v).then(H=>{E||Q(H)}),()=>{E=!0}},[K,v,x,p]);let F=_??q,D=!!F&&F.inkIsDark!==null&&(W?!F.inkIsDark:F.inkIsDark),ve=K&&!!v&&!x&&!W,G=D&&F?F.reversed:v,Y=G?[G]:[],[le,Z]=ke(0);Te(()=>{Z(0)},[v,D]);let Ee=e==="footer"?We:Be[c],U=u&&u>0?u:Ee,Pe=Math.round(U*Qn),P=le<Y.length?Y[le]:null,[J,ee]=ke(G),ue=P!==null&&P===J,ce=Kt(null);Te(()=>{let E=ce.current;if(!E||!E.complete)return;if(E.naturalWidth>0||E.naturalHeight>0){ee(P);return}let H=!1;return E.decode().then(()=>!H&&ee(P),()=>!H&&Z(V=>V+1)),()=>{H=!0}},[P]);let te=S||R,de=`calc(100cqi / ${((y.length+1)*Zn).toFixed(2)})`,ne=te&&C&&C>0?Math.min(C,U):null,we=te?ne===null?`min(${U}px, ${de})`:`clamp(${ne}px, ${de}, ${U}px)`:`${U}px`,_e=Ve("span",{className:`font-display font-bold tracking-[0.18em] ${ne===null?"whitespace-nowrap":"whitespace-normal"}`,style:{fontSize:we,lineHeight:1,...I?{color:I}:{}},"aria-label":y,children:[y,Ce("span",{className:"text-accent",style:I?{color:I}:void 0,children:"."})]});return Ve("span",{ref:L,className:"inline-flex items-center",children:[!ue&&_e,I&&P&&Ce("svg",{"aria-hidden":"true",focusable:"false",width:"0",height:"0",style:{position:"absolute"},children:Ve("filter",{id:b,colorInterpolationFilters:"sRGB",children:[Ce("feFlood",{style:{floodColor:I}}),Ce("feComposite",{in2:"SourceAlpha",operator:"in"})]})}),P&&Ce("img",{ref:ce,src:P,alt:y,width:Pe,height:U,className:"shrink-0 object-contain",style:{...ue?{height:`${U}px`,width:"auto",...S?{maxWidth:"100cqi"}:{}}:{display:"none"},...ve?{filter:Jn}:{},...I?{filter:`url(#${b})`}:{}},onLoad:()=>ee(P),onError:()=>Z(E=>E+1)},P)]})}import{jsx as xe,jsxs as tr}from"react/jsx-runtime";function er({spokes:e,mesh:t=!1,className:n}){let a=c=>Math.round(c*1e3)/1e3,s=[];for(let c=0;c<e;c++){let u=c/e*Math.PI*2-Math.PI/2;if(s.push({x1:a(100+Math.cos(u)*22),y1:a(100+Math.sin(u)*22),x2:a(100+Math.cos(u)*86),y2:a(100+Math.sin(u)*86),main:!0}),t){let f=u+Math.PI/e;s.push({x1:a(100+Math.cos(f)*22*1.4),y1:a(100+Math.sin(f)*22*1.4),x2:a(100+Math.cos(f)*78),y2:a(100+Math.sin(f)*78),main:!1})}}return tr("svg",{viewBox:"0 0 200 200",fill:"none",stroke:"currentColor",className:n??"block h-[70%] w-[70%] transition-transform duration-700 [transition-timing-function:cubic-bezier(.2,.6,.2,1)]",children:[xe("circle",{cx:100,cy:100,r:92,strokeWidth:2}),xe("circle",{cx:100,cy:100,r:84,strokeWidth:1,opacity:.4}),xe("circle",{cx:100,cy:100,r:22,strokeWidth:2}),xe("circle",{cx:100,cy:100,r:6,fill:"currentColor"}),s.map((c,u)=>xe("line",{x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,stroke:"currentColor",strokeWidth:c.main?6:3,strokeLinecap:"round",opacity:c.main?1:.5},u))]})}var li="#c9a461",qt=[{f:"black",label:"Black",hex:"#171717"},{f:"silver",label:"Silver",hex:"#cccccc"},{f:"bronze",label:"Bronze",hex:"#8a6438"},{f:"graphite",label:"Graphite",hex:"#3a3c3f"},{f:"red",label:"Candy Red",hex:"#7a0f14"}],ui={name:"",color:"var(--fg)",family:"silver",src:""};function nr(e,t){let n=r=>{let o=qt.findIndex(i=>i.f===r);return o===-1?qt.length:o};return n(e)-n(t)||e.localeCompare(t)}function ci(e){let t=new Set;for(let n of e)for(let r of n.finishes??[])r?.family&&t.add(r.family);return[...t].sort(nr)}import{useState as rr}from"react";import{jsx as se,jsxs as je}from"react/jsx-runtime";function or({customerEmail:e}){let{coupon:t,applyCoupon:n,removeCoupon:r,couponBusy:o}=Ut(),[i,a]=rr("");async function s(){o||!i.trim()||(await n(i,e),a(""))}return je("div",{className:"flex flex-col gap-2",children:[t===null?je("div",{className:"flex border border-line",children:[se("input",{type:"text",value:i,onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),s())},placeholder:"Coupon code","aria-label":"Coupon code",className:"flex-1 bg-transparent px-4 py-4 font-mono text-[11px] uppercase tracking-[0.18em] text-fg outline-none placeholder:text-fg-dim"}),se("button",{type:"button",onClick:()=>{s()},disabled:o,className:"border-l border-line px-4 font-mono text-[10px] uppercase tracking-[0.26em] text-btn transition-colors hover:bg-btn hover:text-btn-ink disabled:cursor-wait disabled:opacity-60",children:o?"\u2026":"Apply"})]}):je("div",{className:["flex items-center justify-between gap-3 border px-4 py-3",t.valid?"border-accent":"border-line"].join(" "),style:t.valid?{background:"color-mix(in oklab, var(--accent) 8%, transparent)"}:void 0,children:[se("span",{className:["font-mono text-[11px] uppercase tracking-[0.22em]",t.valid?"text-accent":t.deferred?"text-fg":"text-fg-dim line-through"].join(" "),children:t.code}),se("button",{type:"button",onClick:r,"aria-label":`Remove coupon ${t.code}`,className:"font-mono text-[12px] text-fg-dim transition-colors hover:text-fg",children:"\u2715"})]}),t?.deferred?se("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-fg-dim",children:Et}):t&&!t.valid&&t.message&&se("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-alert",children:t.message})]})}var Qe="Ads on. Shopper can opt out.",Oe="Ads and analytics off until Accept",ir={us:{region:"us",name:"United States",model:"opt-out",law:"California CCPA / CPRA, other state laws",beforeChoice:Qe,footerLink:"Do Not Sell or Share My Personal Information",panelEyebrow:"Do not sell or share",adsRowName:"Sale or sharing for ads"},ca:{region:"ca",name:"Canada",model:"opt-in",law:"PIPEDA, Quebec Law 25",beforeChoice:Oe,footerLink:"Privacy choices",panelEyebrow:"Privacy choices",adsRowName:"Advertising"},au:{region:"au",name:"Australia",model:"opt-out",law:"Privacy Act 1988 (APPs)",beforeChoice:Qe,footerLink:"Privacy choices",panelEyebrow:"Privacy choices",adsRowName:"Advertising"},nz:{region:"nz",name:"New Zealand",model:"opt-out",law:"Privacy Act 2020",beforeChoice:Qe,footerLink:"Privacy choices",panelEyebrow:"Privacy choices",adsRowName:"Advertising"},uk:{region:"uk",name:"United Kingdom",model:"opt-in",law:"PECR, UK GDPR",beforeChoice:Oe,footerLink:"Cookie settings",panelEyebrow:"Cookie settings",adsRowName:"Advertising"},eu:{region:"eu",name:"European Union",model:"opt-in",law:"ePrivacy Directive, GDPR",beforeChoice:Oe,footerLink:"Cookie settings",panelEyebrow:"Cookie settings",adsRowName:"Advertising"},other:{region:"other",name:"All other countries",model:"opt-in",law:"Safe default",beforeChoice:Oe,footerLink:"Cookie settings",panelEyebrow:"Cookie settings",adsRowName:"Advertising"}};function ar(e){let t=[...e.googleAds?["Google"]:[],...e.meta?["Facebook","Instagram"]:[]];return t.length<=1?t.join(""):`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function yi(e,t,n){let r=ar(n),o=r?`We use cookies to count visits and to show you ${t} ads on ${r}.`:"We use cookies to count visits.";return e.model==="opt-in"?{heading:r?"Cookies and ads":"Cookies",before:`${o} Nothing loads until you choose. You can change this at any time with `,link:e.footerLink,after:" at the bottom of every page."}:{heading:r?"Cookies and ads":"Cookies",before:`${o} You can say no at any time: choose Privacy choices, or use `,link:e.footerLink,after:" at the bottom of every page."}}var bi={accept:"Accept all",reject:"Reject all",choose:"Choose",save:"Save",ok:"OK",privacyChoices:"Privacy choices",privacyPolicy:"Privacy Policy",alwaysOn:"Always on"};var sr={asked:!1,region:"other",model:"opt-in",analytics:!0,ads:!0,chosen:!0,gpc:!1};var lr=sr;function vi(e=lr){if(e.asked)return e.ads?"granted":"denied"}function Pi(){let e=typeof crypto<"u"?crypto:void 0;if(typeof e?.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<t.length;r++)t[r]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}import{Children as cr,isValidElement as dr,useEffect as zt,useId as fr,useLayoutEffect as Vt,useRef as z,useState as Xt}from"react";var Me=(e,t)=>!!e[t]&&!e[t].disabled;function Ze(e,t,n){let r=e.length;for(let o=1;o<=r;o++){let i=((t+n*o)%r+r)%r;if(Me(e,i))return i}return t}function Je(e,t){return Ze(e,t===1?-1:e.length,t)}function et(e,t){return Me(e,t)?t:Math.max(Je(e,1),0)}function Gt(e,t,n){let{open:r,focus:o}=e,i=a=>({...e,...a});if(t.length===1&&/\S/.test(t)){let a=e.typed+t.toLowerCase(),s=n.findIndex((c,u)=>Me(n,u)&&c.label.toLowerCase().startsWith(a));return{state:i({open:!0,typed:a,focus:s>=0?s:o}),handled:!0}}if(!r)return t==="ArrowDown"||t==="ArrowUp"||t==="Enter"||t===" "?{state:i({open:!0,typed:""}),handled:!0}:{state:e,handled:!1};switch(t){case"ArrowDown":return{state:i({focus:Ze(n,o,1)}),handled:!0};case"ArrowUp":return{state:i({focus:Ze(n,o,-1)}),handled:!0};case"Home":return{state:i({focus:Je(n,1)}),handled:!0};case"End":return{state:i({focus:Je(n,-1)}),handled:!0};case"Enter":case" ":return Me(n,o)?{state:i({open:!1,typed:""}),commit:o,refocus:!0,handled:!0}:{state:e,handled:!0};case"Escape":return{state:i({open:!1,typed:""}),refocus:!0,handled:!0};case"Tab":return{state:i({open:!1,typed:""}),handled:!1};default:return{state:e,handled:!1}}}import{placeMenu as pr}from"efficient-shell/ui";import{Fragment as Cr,jsx as X,jsxs as jt}from"react/jsx-runtime";var Yt={body:"text-[length:var(--size-body,14px)]",label:"text-[length:var(--size-label,13px)]"};function mr({items:e,value:t,onPick:n,open:r,onOpen:o,onClose:i}){let[a,s]=Xt(!1),c=r!==void 0,u=c?r:a,[f,d]=Xt(0),S=z({text:"",timer:0}),R=z(null),C=z(null),y=z(null),w=fr(),O=z(null),M=e.findIndex(b=>b.value===t),L=b=>{b!==u&&(c||s(b),b?o?.():i?.())},v=b=>{let _=e[b];!_||_.disabled||(n(_.value),L(!1),C.current?.focus())},x=b=>{let _={open:u,focus:u?f:et(e,M),typed:S.current.text},p=Gt(_,b,e);return!p.handled&&p.state.open===u?!1:(p.state.typed!==_.typed&&(S.current.text=p.state.typed,window.clearTimeout(S.current.timer),S.current.timer=window.setTimeout(()=>{S.current.text=""},500)),d(p.state.focus),p.commit!==void 0?v(p.commit):L(p.state.open),p.refocus&&C.current?.focus(),p.handled)},W=z(x);W.current=x;let I=z(()=>L(!1));I.current=()=>L(!1);let K=b=>{u||(O.current=b.nativeEvent,W.current(b.key)&&b.preventDefault())};return zt(()=>{if(!u)return;let b=p=>{R.current?.contains(p.target)||I.current()},_=p=>{p!==O.current&&W.current(p.key)&&p.preventDefault()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",_),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",_)}},[u]),zt(()=>{u&&(S.current.text||d(et(e,M)))},[u]),Vt(()=>{if(!u||!y.current)return;y.current.children.item(f)?.scrollIntoView({block:"nearest"})},[f,u]),{open:u,toggle:()=>L(!u),close:()=>L(!1),focusIdx:f,setFocusIdx:d,pick:b=>v(e.findIndex(_=>_.value===b)),wrapRef:R,triggerRef:C,listRef:y,listId:w,onTriggerKeyDown:K,activeId:u?`${w}-${f}`:void 0}}var gr={select:{list:"absolute left-0 top-full z-50 mt-1 max-h-[280px] w-max min-w-full overflow-y-auto border-2 border-accent bg-bg shadow-xl",item:(e,t,n)=>["px-3 py-3 font-mono text-[13px] font-semibold uppercase tracking-[0.1em] transition-colors whitespace-nowrap",n?"cursor-not-allowed opacity-40":"cursor-pointer",e&&!n?"bg-accent text-bg":"bg-bg text-fg"].join(" ")},cell:{list:"absolute left-0 top-full z-50 mt-1 max-h-[320px] w-max min-w-full overflow-y-auto border-2 border-accent bg-bg shadow-xl",item:e=>[`cursor-pointer whitespace-nowrap px-6 py-3 font-mono ${Yt.label} font-semibold uppercase tracking-[0.1em] transition-colors`,e?"bg-accent text-bg":"bg-bg text-fg"].join(" "),pickerMarker:!0},hairline:{list:"absolute left-0 top-full z-50 max-h-[320px] w-full overflow-y-auto border border-line bg-bg shadow-[0_6px_20px_rgba(0,0,0,0.10)]",item:(e,t)=>[`flex cursor-pointer items-center justify-between gap-4 border-b border-line px-4 py-3 text-left ${Yt.body} transition-colors last:border-b-0`,t?"border-fg font-medium text-fg":e?"border-fg text-fg":"text-fg-dim"].join(" "),pickerMarker:!0},region:{list:"absolute right-0 top-full z-[200] mt-2 flex min-w-[240px] flex-col border border-line bg-surface text-fg",item:(e,t,n,r)=>["flex w-full cursor-pointer items-center gap-3 px-4 py-3 text-left transition-colors","font-mono text-[13px] uppercase tracking-[0.18em]",e?"bg-surface-2 text-fg":"",r?"":"border-b border-line",t?"text-accent":""].join(" "),itemStyle:e=>e?void 0:{color:"color-mix(in oklab, currentColor 80%, transparent)"}}};function hr(e,t){Vt(()=>{let n=e.current,r=n?.ownerDocument.defaultView;if(!n||!r)return;let o=()=>{let i=n.style;i.top=i.bottom=i.marginTop=i.marginBottom=i.maxHeight=i.overflowY=i.translate="";let a=n.offsetParent??n.parentElement;if(!a)return;let s=a.getBoundingClientRect(),c=n.getBoundingClientRect(),u=Math.abs(c.right-s.right)<Math.abs(c.left-s.left)?"end":"start",f=pr({trigger:{left:s.left,right:s.right,top:s.top,bottom:s.bottom},menu:{width:c.width,height:c.height},bounds:{left:0,top:0,right:r.innerWidth,bottom:r.innerHeight},align:u,side:"bottom"});if(f.side==="top"){i.top="auto",i.bottom="100%",i.marginTop="0px";let S=f.top+Math.min(c.height,f.maxHeight);i.marginBottom=`${Math.max(0,s.top-S)}px`}f.maxHeight<c.height&&(i.maxHeight=`${f.maxHeight}px`,i.overflowY="auto");let d=f.left-c.left;d&&(i.translate=`${d}px`)};return o(),r.addEventListener("resize",o),r.addEventListener("scroll",o,!0),()=>{r.removeEventListener("resize",o),r.removeEventListener("scroll",o,!0)}},[e,t])}function yr({id:e,tone:t,items:n,value:r,focusIdx:o,onFocus:i,onPick:a,listRef:s,ariaLabel:c}){let u=gr[t],f=z(null);return hr(f,n.length),X("ul",{ref:d=>{f.current=d,s&&(s.current=d)},id:e,role:"listbox","aria-label":c,...u.pickerMarker?{"data-picker-menu":""}:{},className:u.list,children:n.map((d,S)=>{let R=d.value===r;return X("li",{id:`${e}-${S}`,role:"option","aria-selected":R,"aria-disabled":d.disabled||void 0,onMouseEnter:()=>!d.disabled&&i(S),onMouseDown:C=>{C.preventDefault(),d.disabled||a(d.value)},className:u.item(S===o,R&&d.value!=="",!!d.disabled,S===n.length-1),style:u.itemStyle?.(R),children:d.meta===void 0?d.label:jt(Cr,{children:[d.lead,X("span",{className:"flex-1 whitespace-nowrap",children:d.label}),X("span",{className:"ml-auto text-[12px] opacity-50",children:d.meta})]})},`${d.value}_${S}`)})})}function br({value:e,onChange:t,disabled:n,children:r,className:o,style:i,name:a,id:s,"aria-label":c}){let u=cr.toArray(r).flatMap(C=>{if(!dr(C))return[];if(C.type!=="option")return[];let w=C.props,O=w.value!==void 0?String(w.value):"",M=w.children,L=typeof M=="string"||typeof M=="number"?String(M):O;return[{value:O,label:L,disabled:!!w.disabled}]}),f=e??"",d=mr({items:u,value:f,onPick:C=>t?.({target:{value:C}})}),R=u.find(C=>C.value===f)?.label??u[0]?.label??"";return jt("div",{ref:d.wrapRef,className:"relative",children:[a&&X("input",{type:"hidden",name:a,value:f}),X("button",{ref:C=>{d.triggerRef.current=C},type:"button",disabled:n,"aria-haspopup":"listbox","aria-expanded":d.open,"aria-controls":d.open?d.listId:void 0,"aria-activedescendant":d.activeId,"aria-label":c,id:s,onClick:()=>!n&&d.toggle(),onKeyDown:C=>!n&&d.onTriggerKeyDown(C),className:`block w-full ${o??""}`,style:i,children:X("span",{className:"block w-full truncate text-left",children:R})}),d.open&&X(yr,{id:d.listId,tone:"select",items:u,value:f,focusIdx:d.focusIdx,onFocus:d.setFocusIdx,onPick:d.pick,listRef:d.listRef})]})}import{jsx as Se,jsxs as De}from"react/jsx-runtime";var xr="font-mono text-[length:var(--size-label,12px)]",Sr="font-semibold uppercase tracking-[0.22em] text-fg";function Qt(e){return`${e??xr} ${Sr}`}function Zt(){return Se("span",{className:"text-accent",children:" *"})}function vr({children:e,required:t,labelFace:n}){return De("span",{className:Qt(n),children:[e,t?Se(Zt,{}):null]})}function Er({label:e,required:t,hint:n,separate:r,htmlFor:o,labelFace:i,className:a,children:s}){let c=a?`flex flex-col gap-2 ${a}`:"flex flex-col gap-2",u=n?Se("span",{className:"font-mono text-[11px] uppercase tracking-[0.22em] text-fg-dim",children:n}):null;return r||n?De("div",{className:c,children:[De("label",{htmlFor:o,className:Qt(i),children:[e,t?Se(Zt,{}):null]}),s,u]}):De("label",{htmlFor:o,className:c,children:[Se(vr,{required:t,labelFace:i,children:e}),s]})}export{Hr as a,$r as b,Br as c,mt as d,Ke as e,Pr as f,wr as g,_r as h,Rr as i,an as j,sn as k,Nr as l,Lr as m,qe as n,Ne as o,ge as p,Ir as q,Le as r,hn as s,yn as t,Gr as u,zr as v,wt as w,ze as x,Xr as y,Yr as z,Cn as A,Vr as B,jr as C,xn as D,Qr as E,vn as F,Zr as G,Jr as H,_t as I,io as J,ao as K,so as L,co as M,fo as N,Mr as O,xt as P,Ie as Q,Ye as R,Po as S,Ut as T,$o as U,Xn as V,Wo as W,ri as X,oi as Y,er as Z,li as _,qt as $,ui as aa,nr as ba,ci as ca,or as da,ir as ea,yi as fa,bi as ga,sr as ha,vi as ia,Pi as ja,mr as ka,yr as la,br as ma,vr as na,Er as oa};