efficient-storefront-blocks 0.74.0 → 0.75.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/chunks/EditorPreviewCheckout-27GNLSNR.js +4 -0
  3. package/dist/chunks/{SiteEditorProvider-Z33JB5BA.js → SiteEditorProvider-N4T55FAV.js} +1 -1
  4. package/dist/chunks/chunk-4V6BLJSG.js +1 -0
  5. package/dist/chunks/{chunk-QJDTP7K6.js → chunk-K26JUDGZ.js} +1 -1
  6. package/dist/chunks/{chunk-5OFEWRWI.js → chunk-SJODSVWU.js} +1 -1
  7. package/dist/chunks/{chunk-UGXNUQRA.js → chunk-WPHE7RI4.js} +1 -1
  8. package/dist/chunks/{fitment-data-DHKRLKNI.js → fitment-data-5ZSHENM3.js} +1 -1
  9. package/dist/editor/components/CategorySource.js +1 -1
  10. package/dist/editor/lib/efficient-backend.js +1 -1
  11. package/dist/editor/lib/storefront-editor-words.d.ts +2 -3
  12. package/dist/editor/lib/storefront-editor-words.js +1 -1
  13. package/dist/index.js +232 -33
  14. package/dist/render/built-with.json +1 -1
  15. package/dist/render/components/CartContext.d.ts +3 -0
  16. package/dist/render/components/CartContext.js +1 -1
  17. package/dist/render/components/HeaderToolBlocks.d.ts +1 -2
  18. package/dist/render/components/HeaderToolBlocks.js +1 -1
  19. package/dist/render/components/SectionGroupBody.js +1 -1
  20. package/dist/render/components/checkout/checkout-parts.js +1 -1
  21. package/dist/render/components/checkout/checkout-state.d.ts +7 -2
  22. package/dist/render/components/checkout/checkout-state.js +3 -3
  23. package/dist/render/lib/api/index.d.ts +0 -8
  24. package/dist/render/lib/api/index.js +1 -1
  25. package/dist/render/lib/api/types.d.ts +7 -3
  26. package/dist/render/lib/content/site.d.ts +1 -1
  27. package/dist/render/lib/document/blocks/commerce/CountrySwitchBlock/render.js +1 -1
  28. package/dist/words.d.ts +2 -3
  29. package/dist/words.js +1 -1
  30. package/package.json +4 -1
  31. package/dist/chunks/EditorPreviewCheckout-YQ3F5MSG.js +0 -4
  32. package/dist/chunks/chunk-BZDVZUF4.js +0 -1
  33. /package/dist/chunks/{chunk-UJW4B64R.js → chunk-3TBLX25X.js} +0 -0
  34. /package/dist/chunks/{chunk-UGXNUQRA.js.LEGAL.txt → chunk-WPHE7RI4.js.LEGAL.txt} +0 -0
@@ -1,3 +1,3 @@
1
1
  {
2
- "efficient-web-builder": "44.0.0"
2
+ "efficient-web-builder": "44.0.1"
3
3
  }
@@ -39,6 +39,7 @@ export interface AppliedCoupon {
39
39
  export interface QuoteDestination {
40
40
  country: string;
41
41
  subdivision: string;
42
+ postcode: string;
42
43
  }
43
44
  interface CartCtx {
44
45
  isOpen: boolean;
@@ -64,6 +65,8 @@ interface CartCtx {
64
65
  couponBusy: boolean;
65
66
  deliveryOptions: DeliveryOption[];
66
67
  setQuoteDestination: (dest: QuoteDestination | null) => void;
68
+ courier: CartQuote["courier"] | null;
69
+ requote: () => void;
67
70
  shippingMethodId: string | null;
68
71
  setShippingMethodId: (id: string) => void;
69
72
  totals: {
@@ -1 +1 @@
1
- "use client";import{jsx as We}from"react/jsx-runtime";import{createContext as ke,useCallback as i,useContext as Qe,useEffect as g,useMemo as pe,useRef as A,useState as d}from"react";import{products as E}from"../lib/api/index.js";import{couponDeferredToCheckout as ve}from"../lib/cart/coupon-preview.js";import{snapshotCartLines as He}from"../lib/cart/snapshot-lines.js";import{MAX_QTY_PER_LINE as he,orderLinesForSets as Ve,setPrice as je}from"../lib/commerce.js";import{UNPRICED_LABEL as Fe}from"../lib/wheels/price-display.js";import{isValidEmail as ze}from"../lib/email-shape.js";import{trackAddToCart as Je}from"../lib/google-tag.js";import{shippingStatus as Xe}from"../lib/cart/shipping-status.js";import{useCurrency as Ye}from"./CurrencyContext.js";const Ge=400,Ke=400,Ze=1500;function ye(c){return(c.components?.length??0)>0}function Ce(c,s){return{code:c,valid:s.valid,deferred:ve(s,s.askedAsShopper),message:s.message||void 0,effects:s.effects??void 0}}function ge(c,s){return je(c.components,s)}function L(c,s){const r=ge(c,s);return r===null?null:r*c.qty}function Ee(c){return c!=="tyre"}const Ne=ke(null);function lt({children:c,preview:s=!1}){const{currency:r,country:W,formatMoney:be}=Ye(),[k,D]=d(s),[a,M]=d([]),[Q,Te]=d([]),[v,Be]=d([]),[H,Me]=d(!1),[V,Ie]=d(!1),[xe,Oe]=d(!1),[Se,_e]=d(!1),[m,j]=d(null),[F,z]=d(void 0),[I,qe]=d(null),[u,y]=d(null),[J,x]=d(!1),[p,X]=d(null),O=A(void 0),N=i(()=>D(!0),[]),Y=i(()=>D(!1),[]),G=i(()=>D(e=>!e),[]);g(()=>{s||typeof window>"u"||new URLSearchParams(window.location.search).get("cart")==="open"&&N()},[N,s]);const K=i(e=>{qe(t=>t?.country===e?.country&&t?.subdivision===e?.subdivision?t:e)},[]),Z=i(e=>{_e(!0),Ee(e)&&Oe(!0)},[]),$=xe||a.some(e=>Ee(e.kind)),ee=Se||a.length>0;g(()=>{if(s||!$||H)return;let e=!0;return E.listWheels().then(t=>{e&&(Te(t),Me(!0))}),()=>{e=!1}},[s,$,H]),g(()=>{if(s||!ee||V)return;let e=!0;return E.listBundles().then(t=>{e&&(Be(t),Ie(!0))}),()=>{e=!1}},[s,ee,V]);const C=m?.deliveryOptions??[];g(()=>{m&&X(e=>e&&C.some(t=>t.id===e)?e:C[0]?.id??null)},[m]);const S=i(()=>a.filter(ye).flatMap(e=>Ve(e.components,e.qty)),[a]),te=i(async(e,t)=>{const o=e.trim().toUpperCase();if(!o)return;const n=S();if(n.length===0){y({code:o,valid:!1,message:"Add a wheel to the cart first."});return}x(!0),O.current=t;try{const l=await E.validateCoupon({code:o,items:n,currency:r,shippingMethodId:p??void 0,customerEmail:t});y(Ce(o,l))}catch{y({code:o,valid:!1,message:"Could not check that code. Please try again."})}finally{x(!1)}},[S,r,p]),ne=i(()=>{y(null),O.current=void 0},[]),oe=i(e=>{if(!u)return;const{code:t}=u;y(o=>o&&o.code===t?{code:t,valid:!1,refused:!0,message:e}:o)},[u]);g(()=>{if(!u||u.refused)return;const e=u.code,t=n=>n!==null&&n.code===e&&!n.refused,o=setTimeout(async()=>{const n=S();if(n.length===0){y(l=>t(l)?{code:e,valid:!1,message:"Add a wheel to the cart first."}:l);return}x(!0);try{const l=await E.validateCoupon({code:e,items:n,currency:r,shippingMethodId:p??void 0,customerEmail:O.current});y(B=>t(B)?Ce(e,l):B)}catch{}finally{x(!1)}},Ge);return()=>clearTimeout(o)},[a,r,p]);const P=u&&!u.refused?u.code:void 0;g(()=>{if(s)return;let e=!0;const t=setTimeout(async()=>{const o=S();if(o.length===0){j(null),z(void 0);return}try{const n=await E.quoteCart({items:o,currency:r,shippingMethodId:p??void 0,couponCode:P,customerEmail:O.current||void 0,country:I?.country||W||void 0,subdivision:I?.country&&I.subdivision||void 0});if(!e)return;j(n)}catch{if(!e)return}z(P)},Ke);return()=>{e=!1,clearTimeout(t)}},[a,r,p,P,W,I]);const _=i(e=>{M(t=>{const o=t.findIndex(n=>n.id===e.id);return o===-1?[...t,e]:t.map((n,l)=>l===o?{...n,qty:Math.min(he,n.qty+e.qty)}:n)}),Je(e,r)},[r]),se=i(e=>{M(t=>t.filter(o=>o.id!==e))},[]),re=i((e,t)=>{const o=Math.max(1,Math.min(he,t));M(n=>n.map(l=>l.id===e?{...l,qty:o}:l))},[]),ue=i(e=>{M(e)},[]),[T,Ae]=d(null),ie=A(null);ie.current=T;const h=A(null),U=A(""),ce=i((e,t)=>{const o=e.trim().toLowerCase();ze(o)&&Ae(n=>n&&n.email===o&&n.firstName===(t??"")?n:{email:o,firstName:t??""})},[]);g(()=>{if(s||!T)return;const e=He(a.filter(ye),n=>L(n,r)===null?Fe:be(L(n,r),r)),t={email:T.email,firstName:T.firstName,currency:r,items:e},o=JSON.stringify(t);if(o!==U.current)return h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,U.current=o,E.captureCart(t).catch(n=>{process.env.NODE_ENV!=="production"&&console.warn("abandoned-cart capture failed",n)})},Ze),()=>{h.current&&(clearTimeout(h.current),h.current=null)}},[a,T,r,s]);const ae=i(()=>{h.current&&(clearTimeout(h.current),h.current=null);const e=ie.current;e&&(U.current="",E.captureCart({email:e.email,firstName:e.firstName,currency:r,items:[]}).catch(t=>{process.env.NODE_ENV!=="production"&&console.warn("abandoned-cart clear failed",t)}))},[r]),le=pe(()=>{const e=a.reduce((f,b)=>{const q=L(b,r);return q===null?f:f+q},0),t=a.some(f=>ge(f,r)===null),o=a.reduce((f,b)=>f+b.qty,0),n=u?.valid?u.effects:void 0,l=n?Math.min(e,Number(n.discountAmount)):0,B=m?.bundleDiscount??0,Pe=m?.appliedBundles??[],w=!!n?.freeShipping,fe=C.find(f=>f.id===p),me=w?0:m?.shipping??fe?.amount??0,Ue=Xe({quoted:m!==null,optionCount:C.length,chosenAmount:fe?.amount,couponWaivesFreight:w}),R={};for(const f of n?.freeUnits??[])R[f.partNumber]=(R[f.partNumber]??0)+f.quantity;const we=m?.tax??null,Re=m?m.grandTotal:e-l-B+me;return{sets:o,units:a.reduce((f,b)=>f+(b.components??[]).reduce((q,Le)=>q+Le.wheels*b.qty,0),0),subtotal:e,hasUnpricedLine:t,discount:l,bundleDiscount:B,appliedBundles:Pe,shipping:me,freeShipping:w,shippingStatus:Ue,freeUnitsByPartNumber:R,tax:we,grand:Re,repricing:!!u?.refused&&m!==null&&F===u?.code,currency:r}},[a,r,u,C,p,m,F]),de=i(e=>{_(e),N()},[_,N]),De=pe(()=>({isOpen:k,preview:s,open:N,close:Y,toggle:G,items:a,catalog:Q,bundles:v,warmCatalog:Z,add:_,addAndOpen:de,remove:se,setQty:re,replaceItems:ue,identify:ce,clearCapturedCart:ae,coupon:u,applyCoupon:te,removeCoupon:ne,refuseCoupon:oe,couponBusy:J,deliveryOptions:C,setQuoteDestination:K,shippingMethodId:p,setShippingMethodId:X,totals:le}),[k,s,N,Y,G,a,Q,v,Z,_,de,se,re,ue,ce,ae,u,te,ne,oe,J,C,K,p,le]);return We(Ne.Provider,{value:De,children:c})}function dt(){const c=Qe(Ne);if(!c)throw new Error("useCart() must be called inside <CartProvider>. Mount the provider in app/layout.tsx.");return c}export{lt as CartProvider,ye as isOrderable,L as lineTotal,dt as useCart};
1
+ "use client";import{jsx as Ve}from"react/jsx-runtime";import{createContext as ve,useCallback as u,useContext as je,useEffect as g,useMemo as ye,useRef as A,useState as c}from"react";import{products as E}from"../lib/api/index.js";import{couponDeferredToCheckout as Fe}from"../lib/cart/coupon-preview.js";import{snapshotCartLines as ze}from"../lib/cart/snapshot-lines.js";import{MAX_QTY_PER_LINE as Ce,orderLinesForSets as Je,setPrice as Xe}from"../lib/commerce.js";import{UNPRICED_LABEL as Ye}from"../lib/wheels/price-display.js";import{isValidEmail as Ge}from"../lib/email-shape.js";import{trackAddToCart as Ke}from"../lib/google-tag.js";import{shippingStatus as Ze}from"../lib/cart/shipping-status.js";import{useCurrency as $e}from"./CurrencyContext.js";const et=400,tt=400,nt=1500;function ge(a){return(a.components?.length??0)>0}function Ee(a,s){return{code:a,valid:s.valid,deferred:Fe(s,s.askedAsShopper),message:s.message||void 0,effects:s.effects??void 0}}function Ne(a,s){return Xe(a.components,s)}function k(a,s){const r=Ne(a,s);return r===null?null:r*a.qty}function Te(a){return a!=="tyre"}const be=ve(null);function pt({children:a,preview:s=!1}){const{currency:r,country:L,formatMoney:qe}=$e(),[W,D]=c(s),[l,M]=c([]),[Q,Be]=c([]),[H,Me]=c([]),[V,Ie]=c(!1),[v,xe]=c(!1),[Oe,Se]=c(!1),[_e,Ae]=c(!1),[m,j]=c(null),[De,Pe]=c(0),F=u(()=>Pe(e=>e+1),[]),[z,J]=c(void 0),[N,Ue]=c(null),[i,y]=c(null),[X,I]=c(!1),[p,Y]=c(null),x=A(void 0),T=u(()=>D(!0),[]),G=u(()=>D(!1),[]),K=u(()=>D(e=>!e),[]);g(()=>{s||typeof window>"u"||new URLSearchParams(window.location.search).get("cart")==="open"&&T()},[T,s]);const Z=u(e=>{Ue(t=>t?.country===e?.country&&t?.subdivision===e?.subdivision&&t?.postcode===e?.postcode?t:e)},[]),$=u(e=>{Ae(!0),Te(e)&&Se(!0)},[]),ee=Oe||l.some(e=>Te(e.kind)),te=_e||l.length>0;g(()=>{if(s||!ee||V)return;let e=!0;return E.listWheels().then(t=>{e&&(Be(t),Ie(!0))}),()=>{e=!1}},[s,ee,V]),g(()=>{if(s||!te||v)return;let e=!0;return E.listBundles().then(t=>{e&&(Me(t),xe(!0))}),()=>{e=!1}},[s,te,v]);const C=m?.deliveryOptions??[],ne=m?.courier??null;g(()=>{m&&Y(e=>e&&C.some(t=>t.id===e)?e:C[0]?.id??null)},[m]);const O=u(()=>l.filter(ge).flatMap(e=>Je(e.components,e.qty)),[l]),oe=u(async(e,t)=>{const o=e.trim().toUpperCase();if(!o)return;const n=O();if(n.length===0){y({code:o,valid:!1,message:"Add a wheel to the cart first."});return}I(!0),x.current=t;try{const d=await E.validateCoupon({code:o,items:n,currency:r,shippingMethodId:p??void 0,customerEmail:t});y(Ee(o,d))}catch{y({code:o,valid:!1,message:"Could not check that code. Please try again."})}finally{I(!1)}},[O,r,p]),se=u(()=>{y(null),x.current=void 0},[]),re=u(e=>{if(!i)return;const{code:t}=i;y(o=>o&&o.code===t?{code:t,valid:!1,refused:!0,message:e}:o)},[i]);g(()=>{if(!i||i.refused)return;const e=i.code,t=n=>n!==null&&n.code===e&&!n.refused,o=setTimeout(async()=>{const n=O();if(n.length===0){y(d=>t(d)?{code:e,valid:!1,message:"Add a wheel to the cart first."}:d);return}I(!0);try{const d=await E.validateCoupon({code:e,items:n,currency:r,shippingMethodId:p??void 0,customerEmail:x.current});y(B=>t(B)?Ee(e,d):B)}catch{}finally{I(!1)}},et);return()=>clearTimeout(o)},[l,r,p]);const P=i&&!i.refused?i.code:void 0;g(()=>{if(s)return;let e=!0;const t=setTimeout(async()=>{const o=O();if(o.length===0){j(null),J(void 0);return}try{const n=await E.quoteCart({items:o,currency:r,shippingMethodId:p??void 0,couponCode:P,customerEmail:x.current||void 0,country:N?.country||L||void 0,subdivision:N?.country&&N.subdivision||void 0,postcode:N?.country&&N.postcode||void 0});if(!e)return;j(n)}catch{if(!e)return}J(P)},tt);return()=>{e=!1,clearTimeout(t)}},[l,r,p,P,L,N,De]);const S=u(e=>{M(t=>{const o=t.findIndex(n=>n.id===e.id);return o===-1?[...t,e]:t.map((n,d)=>d===o?{...n,qty:Math.min(Ce,n.qty+e.qty)}:n)}),Ke(e,r)},[r]),ue=u(e=>{M(t=>t.filter(o=>o.id!==e))},[]),ie=u((e,t)=>{const o=Math.max(1,Math.min(Ce,t));M(n=>n.map(d=>d.id===e?{...d,qty:o}:d))},[]),ce=u(e=>{M(e)},[]),[q,we]=c(null),ae=A(null);ae.current=q;const h=A(null),U=A(""),le=u((e,t)=>{const o=e.trim().toLowerCase();Ge(o)&&we(n=>n&&n.email===o&&n.firstName===(t??"")?n:{email:o,firstName:t??""})},[]);g(()=>{if(s||!q)return;const e=ze(l.filter(ge),n=>k(n,r)===null?Ye:qe(k(n,r),r)),t={email:q.email,firstName:q.firstName,currency:r,items:e},o=JSON.stringify(t);if(o!==U.current)return h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,U.current=o,E.captureCart(t).catch(n=>{process.env.NODE_ENV!=="production"&&console.warn("abandoned-cart capture failed",n)})},nt),()=>{h.current&&(clearTimeout(h.current),h.current=null)}},[l,q,r,s]);const de=u(()=>{h.current&&(clearTimeout(h.current),h.current=null);const e=ae.current;e&&(U.current="",E.captureCart({email:e.email,firstName:e.firstName,currency:r,items:[]}).catch(t=>{process.env.NODE_ENV!=="production"&&console.warn("abandoned-cart clear failed",t)}))},[r]),fe=ye(()=>{const e=l.reduce((f,b)=>{const _=k(b,r);return _===null?f:f+_},0),t=l.some(f=>Ne(f,r)===null),o=l.reduce((f,b)=>f+b.qty,0),n=i?.valid?i.effects:void 0,d=n?Math.min(e,Number(n.discountAmount)):0,B=m?.bundleDiscount??0,ke=m?.appliedBundles??[],w=!!n?.freeShipping,pe=C.find(f=>f.id===p),he=w?0:m?.shipping??pe?.amount??0,Le=Ze({quoted:m!==null,optionCount:C.length,chosenAmount:pe?.amount,couponWaivesFreight:w}),R={};for(const f of n?.freeUnits??[])R[f.partNumber]=(R[f.partNumber]??0)+f.quantity;const We=m?.tax??null,Qe=m?m.grandTotal:e-d-B+he;return{sets:o,units:l.reduce((f,b)=>f+(b.components??[]).reduce((_,He)=>_+He.wheels*b.qty,0),0),subtotal:e,hasUnpricedLine:t,discount:d,bundleDiscount:B,appliedBundles:ke,shipping:he,freeShipping:w,shippingStatus:Le,freeUnitsByPartNumber:R,tax:We,grand:Qe,repricing:!!i?.refused&&m!==null&&z===i?.code,currency:r}},[l,r,i,C,p,m,z]),me=u(e=>{S(e),T()},[S,T]),Re=ye(()=>({isOpen:W,preview:s,open:T,close:G,toggle:K,items:l,catalog:Q,bundles:H,warmCatalog:$,add:S,addAndOpen:me,remove:ue,setQty:ie,replaceItems:ce,identify:le,clearCapturedCart:de,coupon:i,applyCoupon:oe,removeCoupon:se,refuseCoupon:re,couponBusy:X,deliveryOptions:C,setQuoteDestination:Z,courier:ne,requote:F,shippingMethodId:p,setShippingMethodId:Y,totals:fe}),[W,s,T,G,K,l,Q,H,$,S,me,ue,ie,ce,le,de,i,oe,se,re,X,C,Z,ne,F,p,fe]);return Ve(be.Provider,{value:Re,children:a})}function ht(){const a=je(be);if(!a)throw new Error("useCart() must be called inside <CartProvider>. Mount the provider in app/layout.tsx.");return a}export{pt as CartProvider,ge as isOrderable,k as lineTotal,ht as useCart};
@@ -12,7 +12,6 @@ export declare function AccountTool({ style }: {
12
12
  style?: ToolStyle;
13
13
  }): import("react").JSX.Element | null;
14
14
  export declare function ThemeSwitchTool(): import("react").JSX.Element | null;
15
- export declare function CountrySwitchTool({ editing, showAs, }: {
16
- editing?: boolean;
15
+ export declare function CountrySwitchTool({ showAs, }: {
17
16
  showAs?: CountryShowAs;
18
17
  }): import("react").JSX.Element | null;
@@ -1 +1 @@
1
- "use client";import{jsx as t}from"react/jsx-runtime";import{useCart as u}from"./CartContext.js";import c,{useCountrySelectShows as i}from"./CountrySelect.js";import{AccountButton as a,CartButton as m,SearchButton as h}from"./HeaderTools.js";import f from"./ThemeToggle.js";import{useOfferToPhoneMenu as s}from"efficient-web-builder/render/components/PhoneMenuTools";import{useSearch as p}from"./SearchContext.js";import{useSiteSells as l,useSiteThemeSwitchShown as d}from"./SiteRecordContext.js";import{say as x}from"efficient-web-builder/format/lib/editor-words";function j({style:e="icon",editing:o=!1}){const{open:n}=p(),r=l();return s(r?"search":null),r?t("span",{"data-phone-menu-tool":"search",className:"contents",children:t(h,{onClick:o?void 0:n,asText:e==="text"})}):null}function k({style:e="icon",editing:o=!1}){const{open:n,totals:r}=u();return l()?t(m,{onClick:o?()=>{}:n,count:r.sets,asText:e==="text"}):null}function v({style:e="icon"}){const o=l();return s(o?"account":null),o?t(a,{asText:e==="text"}):null}function M(){const e=d();return s(e?"theme":null),e?t("span",{"data-phone-menu-tool":"theme",className:"contents",children:t(f,{})}):null}function O({editing:e=!1,showAs:o}){const n=i();return s(n?"region":null),n?t("span",{"data-phone-menu-tool":"region",className:"contents",children:t(c,{showAs:o})}):e?t("div",{"data-country-placeholder":"",className:"rounded border border-dashed border-line px-3 py-2 text-[13px] text-fg-dim",children:x("No regions yet")}):null}export{v as AccountTool,k as CartTool,O as CountrySwitchTool,j as SearchTool,M as ThemeSwitchTool};
1
+ "use client";import{jsx as o}from"react/jsx-runtime";import{useCart as u}from"./CartContext.js";import c,{useCountrySelectShows as i}from"./CountrySelect.js";import{AccountButton as a,CartButton as m,SearchButton as h}from"./HeaderTools.js";import f from"./ThemeToggle.js";import{useOfferToPhoneMenu as r}from"efficient-web-builder/render/components/PhoneMenuTools";import{useSearch as p}from"./SearchContext.js";import{useSiteSells as l,useSiteThemeSwitchShown as x}from"./SiteRecordContext.js";function N({style:t="icon",editing:e=!1}){const{open:s}=p(),n=l();return r(n?"search":null),n?o("span",{"data-phone-menu-tool":"search",className:"contents",children:o(h,{onClick:e?void 0:s,asText:t==="text"})}):null}function j({style:t="icon",editing:e=!1}){const{open:s,totals:n}=u();return l()?o(m,{onClick:e?()=>{}:s,count:n.sets,asText:t==="text"}):null}function k({style:t="icon"}){const e=l();return r(e?"account":null),e?o(a,{asText:t==="text"}):null}function M(){const t=x();return r(t?"theme":null),t?o("span",{"data-phone-menu-tool":"theme",className:"contents",children:o(f,{})}):null}function O({showAs:t}){const e=i();return r(e?"region":null),e?o("span",{"data-phone-menu-tool":"region",className:"contents",children:o(c,{showAs:t})}):null}export{k as AccountTool,j as CartTool,O as CountrySwitchTool,N as SearchTool,M as ThemeSwitchTool};
@@ -1 +1 @@
1
- "use client";import{jsx as o,jsxs as f}from"react/jsx-runtime";import{PhoneMenuToolsProvider as m}from"efficient-web-builder/render/components/PhoneMenuTools";import{resolveMenuRow as u,resolveNavTextCase as h}from"../lib/content/header-bar.js";import{say as s}from"efficient-web-builder/format/lib/editor-words";function l({place:e,sections:a,editing:t=!1,fullWidth:n=!1,navTextCase:d,menuRow:i}){const r=f(e==="footer"?"footer":"div",{"data-section-group":e,...e==="header"?{"data-header-nav-case":h(d),"data-header-menu-row":u(i)??"top"}:null,className:t&&e==="footer"?"sf-theme-surfaces bg-bg text-fg":void 0,style:n===!0?{"--sf-site-width":"100vw"}:void 0,children:[t?o("p",{className:"px-5 pt-3 font-mono text-[11px] uppercase tracking-[0.15em] text-fg-dim",children:e==="header"?s("Site header — above every page"):s("Site footer — below every page")}):null,o(a,{minEmptyHeight:120})]});return e==="header"?o(m,{children:r}):r}export{l as default};
1
+ "use client";import{jsx as o}from"react/jsx-runtime";import{PhoneMenuToolsProvider as i}from"efficient-web-builder/render/components/PhoneMenuTools";import{resolveMenuRow as f,resolveNavTextCase as u}from"../lib/content/header-bar.js";function m({place:e,sections:r,editing:s=!1,fullWidth:n=!1,navTextCase:a,menuRow:d}){const t=o(e==="footer"?"footer":"div",{"data-section-group":e,...e==="header"?{"data-header-nav-case":u(a),"data-header-menu-row":f(d)??"top"}:null,className:s&&e==="footer"?"sf-theme-surfaces bg-bg text-fg":void 0,style:n===!0?{"--sf-site-width":"100vw"}:void 0,children:o(r,{minEmptyHeight:120})});return e==="header"?o(i,{children:t}):t}export{m as default};
@@ -1 +1 @@
1
- "use client";import{jsx as e,Fragment as y,jsxs as a}from"react/jsx-runtime";import M from"next/image";import P from"next/link";import{lineTotal as D,useCart as H}from"../CartContext.js";import{useCurrency as G}from"../CurrencyContext.js";import{FREE_PRICE as _}from"../../lib/wheels/price-display.js";import W from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as K}from"../../lib/cart/coupon-preview.js";import{shippingWords as X,TAX_PENDING as Z}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as J}from"../../lib/wheels/finish-defaults.js";import O from"../ThemedSelect.js";import f from"../WebFormField.js";import Q from"../WheelSvg.js";import{useCheckout as N}from"./checkout-state.js";function xe(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:c,setLastName:s,me:p,checkoutSignOut:x}=N();return a(C,{num:"N° 01",title:"Contact",children:[e(f,{label:"Email",hint:p?a(y,{children:["Signed in ·"," ",e("button",{type:"button",onClick:x,className:"underline transition-colors hover:text-accent",children:"Not you? Sign out"})]}):void 0,children:e("input",{type:"email",value:t,onChange:m=>i(m.target.value),placeholder:"you@example.com",readOnly:p!==null,className:g+(p?" opacity-70":"")})}),a($,{children:[e(f,{label:"First name",children:e("input",{type:"text",value:n,onChange:m=>l(m.target.value),className:g})}),e(f,{label:"Last name",children:e("input",{type:"text",value:c,onChange:m=>s(m.target.value),className:g})})]})]})}function be(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:c,setAddress2:s,city:p,setCity:x,postcode:m,setPostcode:o,phone:d,setPhone:u,country:S,setCountry:v,subdivision:k,setSubdivision:h,subdivisions:A,destination:ne,postcodeLabel:R,subdivisionLabel:T,me:L,savedAddresses:F,selectedAddressId:j,setSelectedAddressId:B,saveAddress:E,setSaveAddress:Y,saveLabel:z,setSaveLabel:U,fillFromAddress:q}=N();return a(C,{num:"N° 02",title:t?"Collection":"Shipping address",children:[t?a("div",{className:"grid gap-2 text-[14px] leading-[1.6]",children:[e("span",{className:"font-medium",children:t.name}),[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).length>0&&e("span",{className:"opacity-80",children:[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).join(", ")}),t.openingHours&&e("span",{className:"opacity-80",children:t.openingHours}),t.instructions&&e("span",{className:"opacity-80",children:t.instructions}),e("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):a(y,{children:[L!==null&&F.length>0&&a("div",{className:"grid gap-3",children:[F.map(r=>e(w,{active:j===r.id,onClick:()=>{B(r.id),q(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(w,{active:j==="new",onClick:()=>B("new"),title:"New address",body:null,price:null})]}),e(f,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>l(r.target.value),className:g})}),e(f,{label:"Address line 2",children:e("input",{type:"text",value:c,onChange:r=>s(r.target.value),placeholder:"Apartment, unit, garage bay…",className:g})}),a($,{cols:"three",children:[e(f,{label:"City",children:e("input",{type:"text",value:p,onChange:r=>x(r.target.value),className:g})}),e(f,{label:R,children:e("input",{type:"text",value:m,onChange:r=>o(r.target.value),className:g})}),e(f,{label:"Country",separate:!0,children:e(O,{value:S,onChange:r=>v(r.target.value),className:g+" pr-10",style:I,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(f,{label:T,separate:!0,children:A.length>0?a(O,{value:k,onChange:r=>h(r.target.value),className:g+" pr-10",style:I,children:[e("option",{value:"",children:"Select…"}),A.map(r=>e("option",{value:r.code||r.name,children:r.name},r.code||r.name))]}):e("input",{type:"text",value:k,onChange:r=>h(r.target.value),className:g})})]}),e(f,{label:"Phone",children:e("input",{type:"tel",value:d,onChange:r=>u(r.target.value),placeholder:"+44 7700 900000",className:g})}),!t&&L!==null&&j==="new"&&a(y,{children:[e(V,{checked:E,onChange:Y,label:"Save this address to my account"}),E&&e(f,{label:"Address label",children:e("input",{type:"text",value:z,onChange:r=>U(r.target.value),placeholder:"Home",className:g})})]})]})}function ye(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:c,pickupLocation:s,formatMoney:p,city:x,destination:m}=N();return e(C,{num:"N° 03",title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(o=>{const d=o.pickupLocation,u=d?[d.address,d.city,d.state,d.zipCode].filter(Boolean).join(", "):null;return e(w,{active:l===o.id,onClick:()=>c(o.id),title:d?`${o.name} — ${d.name}`:o.name,body:d?[u,d.openingHours,d.instructions,o.description].filter(Boolean).join(" · "):o.description||null,price:t.freeShipping||o.amount===0?_:p(o.amount,t.currency),tag:o.tag||void 0},o.id)}),n.length===0&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})})}function ve(){const{payChoice:t,setPayChoice:i,placing:n,payment:l,payOptions:c}=N();return a(C,{num:"N° 04",title:"Payment",children:[e("div",{className:"grid gap-3",children:c.map(s=>e(w,{active:t===s.key,onClick:()=>i(s.key),title:s.title,body:s.body,price:s.price,tag:s.tag},s.key))}),t==="card"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="paypal"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll approve the payment with PayPal on the payment step after placing the order."}):t==="afterpay"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Afterpay to approve four interest-free payments, then brought straight back."}):t==="square"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="gocardless"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll set up a bank direct debit with GoCardless, then be brought straight back. Direct debits clear in a few days."}):t==="zip"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Zip to approve four instalments, then brought straight back."}):t==="klarna"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Klarna to choose how to pay, then brought straight back."}):e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Our team emails you the invoice and bank details after review."})]})}function Ne(){const{site:t,items:i,totals:n,coupon:l,formatMoney:c,payChoice:s,placing:p,email:x,orderError:m,payment:o,placeOrder:d}=N();return a("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-[1100px]:static",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--site-surface) 70%, var(--bg)) 0%, var(--bg) 100%)"},children:[a("header",{className:"flex items-center justify-between border-b border-accent bg-accent px-6 py-4 font-mono text-[13px] font-bold uppercase tracking-[0.28em] text-bg",children:[e("span",{children:"Your order"}),e(P,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit ↗"})]}),e("div",{className:"flex flex-col px-6 py-2",children:i.length===0?a("div",{className:"py-8 text-center font-serif text-[16px] italic leading-[1.5] text-fg-dim",children:["Your cart is empty. ",e(P,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog →"})]}):i.map(u=>e(ee,{slug:u.slug,name:u.name,qty:u.qty,config:u.config,configSummary:te(u.config),price:D(u,n.currency)??0,currency:n.currency},u.id))}),e("div",{className:"border-t border-line px-6 pt-5",children:e(W,{customerEmail:x})}),a("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[e(b,{label:"Subtotal",value:c(n.subtotal,n.currency)}),n.discount>0&&l?.valid&&e(b,{label:`Coupon · ${l.code}`,value:a("span",{className:"font-semibold text-green",children:["− ",c(n.discount,n.currency)]})}),l?.deferred&&e(b,{label:`Coupon · ${l.code}`,value:K}),l?.valid&&l.effects?.gift&&e(b,{label:`Free gift · ${l.effects.gift.partNumber}${l.effects.gift.quantity>1?` ×${l.effects.gift.quantity}`:""}`,value:e("span",{className:"font-semibold text-green",children:_})}),e(b,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:_}):X(n.shippingStatus)??c(n.shipping,n.currency)}),n.tax&&(n.tax.charged?e(b,{label:n.tax.inclusive?`${n.tax.name} included · ${n.tax.rate}%`:n.tax.name,value:c(n.tax.amount,n.currency)}):n.tax.name?e(b,{label:n.tax.name,value:Z}):null)]}),a("div",{className:"mt-4 flex items-end justify-between border-y-2 border-accent px-6 py-4",style:{background:"color-mix(in oklab, var(--accent) 10%, var(--bg))"},children:[e("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),e("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:n.repricing?"…":c(n.grand,n.currency)})]}),a("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[m&&e("p",{className:"border border-red-300 bg-red-50 px-3 py-2 text-[13px] text-red-700",children:m}),n.hasUnpricedLine&&a("p",{className:"border border-amber-300 bg-amber-50 px-3 py-2 text-[13px] text-amber-800",children:["One or more items have no price in ",n.currency,". Remove them, or switch region, to continue."]}),e("button",{type:"button",onClick:d,disabled:p||i.length===0||n.hasUnpricedLine||n.repricing,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",i.length===0||p||n.hasUnpricedLine||n.repricing?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:p?a(y,{children:["Building order… ",e("span",{children:"·"})]}):n.repricing?a(y,{children:["Updating total… ",e("span",{children:"·"})]}):a(y,{children:[s==="bank"?"Place order":"Continue to payment"," ·"," ",c(n.grand,n.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})})]})]})}const g="w-full border-2 border-line bg-bg px-4 py-4 font-display text-[17px] tracking-[-0.005em] text-fg outline-none transition-colors placeholder:text-fg-dim hover:border-fg-dim focus:border-accent",I={backgroundImage:"linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%)",backgroundPosition:"calc(100% - 18px) 50%, calc(100% - 12px) 50%",backgroundSize:"6px 6px",backgroundRepeat:"no-repeat"};function C({num:t,title:i,children:n}){return a("section",{className:"mb-6 border border-line bg-bg",children:[a("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t}),e("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:i})]}),e("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function $({cols:t="two",children:i}){return e("div",{className:["grid gap-3 max-[640px]:grid-cols-1",t==="two"?"grid-cols-2":"grid-cols-[1.2fr_1fr_1fr]"].join(" "),children:i})}function w({active:t,onClick:i,title:n,body:l,price:c,tag:s}){return a("button",{type:"button",onClick:i,"aria-pressed":t,className:["relative grid grid-cols-[auto_1fr_auto] items-center gap-5 border bg-bg px-6 py-5 text-left transition-colors",t?"border-accent outline outline-1 outline-accent -outline-offset-1":"border-line hover:border-[color-mix(in_oklab,var(--accent)_50%,var(--site-line))]"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 14%, var(--bg))"}:void 0,children:[t&&e("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),e("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",t?"border-accent":"border-fg-dim"].join(" "),children:t&&e("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),a("span",{className:"flex min-w-0 flex-col gap-1",children:[a("span",{className:"flex flex-wrap items-baseline gap-3 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,s&&e("span",{className:"border px-2 py-0.5 font-mono text-[11px] font-normal uppercase tracking-[0.24em] text-accent",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 45%, var(--site-line))"},children:s})]}),l&&e("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:l})]}),e("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:c})]})}function V({checked:t,onChange:i,label:n,sub:l}){return a("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[e("button",{type:"button",onClick:()=>i(!t),"aria-pressed":t,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",t?"border-accent":"border-line"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:t&&e("span",{className:"text-[13px] text-accent",children:"✓"})}),a("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,l&&e("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:l})]})]})}function ee({slug:t,name:i,qty:n,config:l,configSummary:c,price:s,currency:p}){const{catalog:x}=H(),{formatMoney:m}=G(),o=x.find(h=>h.slug===t),d=o?.spokes??5,u=o?.mesh??!1,S=l.find(h=>h.gold)?.label,v=o?.finishes.find(h=>h.name===S&&h.src)??o?.finishes.find(h=>h.src),k=o?.finishes[0]?.color??J;return a("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-4 border-b border-line py-4 last:border-b-0",children:[a("div",{className:"relative flex aspect-square items-center justify-center overflow-hidden border border-line bg-surface",children:[e("span",{className:"absolute -right-1.5 -top-1.5 z-[2] flex h-[18px] w-[18px] items-center justify-center rounded-full bg-accent font-mono text-[11px] font-bold text-bg",children:n}),v?.src?e(M,{src:v.src,alt:`${i.lead}${i.accent} — ${v.name}`,width:120,height:120,sizes:"60px",className:"relative block h-full w-full object-contain p-2"}):e("div",{className:"block w-[78%]",style:{color:k},children:e(Q,{spokes:d,mesh:u,className:"block w-full"})})]}),a("div",{className:"flex min-w-0 flex-col gap-0.5",children:[a("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[i.lead,e("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:i.accent})]}),e("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:c})]}),e("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:m(s,p)})]})}function b({label:t,value:i}){return a("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[e("span",{children:t}),e("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:i})]})}function te(t){return t.map(i=>i.label).join(" · ")}export{xe as CheckoutContact,Ne as CheckoutOrderSummary,ve as CheckoutPayment,be as CheckoutShippingAddress,ye as CheckoutShippingMethod};
1
+ "use client";import{jsx as e,Fragment as N,jsxs as a}from"react/jsx-runtime";import H from"next/image";import O from"next/link";import{lineTotal as q,useCart as D}from"../CartContext.js";import{useCurrency as G}from"../CurrencyContext.js";import{FREE_PRICE as j}from"../../lib/wheels/price-display.js";import W from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as K}from"../../lib/cart/coupon-preview.js";import{shippingWords as X,TAX_PENDING as Z}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as J}from"../../lib/wheels/finish-defaults.js";import B from"../ThemedSelect.js";import h from"../WebFormField.js";import Q from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as V,SHIPPING_RETRY_NOTE as ee,useCheckout as k}from"./checkout-state.js";function ye(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:s,setLastName:p,me:c,checkoutSignOut:b}=k();return a(w,{num:"N° 01",title:"Contact",children:[e(h,{label:"Email",hint:c?a(N,{children:["Signed in ·"," ",e("button",{type:"button",onClick:b,className:"underline transition-colors hover:text-accent",children:"Not you? Sign out"})]}):void 0,children:e("input",{type:"email",value:t,onChange:m=>i(m.target.value),placeholder:"you@example.com",readOnly:c!==null,className:u+(c?" opacity-70":"")})}),a(I,{children:[e(h,{label:"First name",children:e("input",{type:"text",value:n,onChange:m=>l(m.target.value),className:u})}),e(h,{label:"Last name",children:e("input",{type:"text",value:s,onChange:m=>p(m.target.value),className:u})})]})]})}function Ne(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:s,setAddress2:p,city:c,setCity:b,postcode:m,setPostcode:f,phone:x,setPhone:d,country:o,setCountry:y,subdivision:C,setSubdivision:g,subdivisions:E,destination:re,postcodeLabel:R,subdivisionLabel:$,me:A,savedAddresses:P,selectedAddressId:_,setSelectedAddressId:L,saveAddress:F,setSaveAddress:Y,saveLabel:M,setSaveLabel:U,fillFromAddress:z}=k();return a(w,{num:"N° 02",title:t?"Collection":"Shipping address",children:[t?a("div",{className:"grid gap-2 text-[14px] leading-[1.6]",children:[e("span",{className:"font-medium",children:t.name}),[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).length>0&&e("span",{className:"opacity-80",children:[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).join(", ")}),t.openingHours&&e("span",{className:"opacity-80",children:t.openingHours}),t.instructions&&e("span",{className:"opacity-80",children:t.instructions}),e("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):a(N,{children:[A!==null&&P.length>0&&a("div",{className:"grid gap-3",children:[P.map(r=>e(S,{active:_===r.id,onClick:()=>{L(r.id),z(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(S,{active:_==="new",onClick:()=>L("new"),title:"New address",body:null,price:null})]}),e(h,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>l(r.target.value),className:u})}),e(h,{label:"Address line 2",children:e("input",{type:"text",value:s,onChange:r=>p(r.target.value),placeholder:"Apartment, unit, garage bay…",className:u})}),a(I,{cols:"three",children:[e(h,{label:"City",children:e("input",{type:"text",value:c,onChange:r=>b(r.target.value),className:u})}),e(h,{label:R,children:e("input",{type:"text",value:m,onChange:r=>f(r.target.value),className:u})}),e(h,{label:"Country",separate:!0,children:e(B,{value:o,onChange:r=>y(r.target.value),className:u+" pr-10",style:T,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(h,{label:$,separate:!0,children:E.length>0?a(B,{value:C,onChange:r=>g(r.target.value),className:u+" pr-10",style:T,children:[e("option",{value:"",children:"Select…"}),E.map(r=>e("option",{value:r.code||r.name,children:r.name},r.code||r.name))]}):e("input",{type:"text",value:C,onChange:r=>g(r.target.value),className:u})})]}),e(h,{label:"Phone",children:e("input",{type:"tel",value:x,onChange:r=>d(r.target.value),className:u})}),!t&&A!==null&&_==="new"&&a(N,{children:[e(te,{checked:F,onChange:Y,label:"Save this address to my account"}),F&&e(h,{label:"Address label",children:e("input",{type:"text",value:M,onChange:r=>U(r.target.value),placeholder:"Home",className:u})})]})]})}function ve(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:s,pickupLocation:p,formatMoney:c,city:b,destination:m,courierUnavailable:f,retryCourier:x}=k();return e(w,{num:"N° 03",title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(d=>{const o=d.pickupLocation,y=o?[o.address,o.city,o.state,o.zipCode].filter(Boolean).join(", "):null;return e(S,{active:l===d.id,onClick:()=>s(d.id),title:o?`${d.name} — ${o.name}`:d.name,body:o?[y,o.openingHours,o.instructions,d.description].filter(Boolean).join(" · "):d.description||null,price:t.freeShipping||d.amount===0?j:c(d.amount,t.currency),tag:d.tag||void 0},d.id)}),f?a("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[ee," ",e("button",{type:"button",onClick:x,className:"underline transition-colors hover:text-accent",children:"Try again"})]}):n.length===0&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})})}function ke(){const{payChoice:t,setPayChoice:i,placing:n,payment:l,payOptions:s,noPaymentMethod:p}=k();return a(w,{num:"N° 04",title:"Payment",children:[p&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:V}),e("div",{className:"grid gap-3",children:s.map(c=>e(S,{active:t===c.key,onClick:()=>i(c.key),title:c.title,body:c.body,price:c.price,tag:c.tag},c.key))}),t==="card"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="paypal"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll approve the payment with PayPal on the payment step after placing the order."}):t==="afterpay"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Afterpay to approve four interest-free payments, then brought straight back."}):t==="square"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="gocardless"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll set up a bank direct debit with GoCardless, then be brought straight back. Direct debits clear in a few days."}):t==="zip"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Zip to approve four instalments, then brought straight back."}):t==="klarna"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Klarna to choose how to pay, then brought straight back."}):t==="bank"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Our team emails you the invoice and bank details after review."}):null]})}function Ce(){const{site:t,items:i,totals:n,coupon:l,formatMoney:s,payChoice:p,placing:c,email:b,orderError:m,payment:f,noPaymentMethod:x,placeOrder:d}=k();return a("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-[1100px]:static",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--site-surface) 70%, var(--bg)) 0%, var(--bg) 100%)"},children:[a("header",{className:"flex items-center justify-between border-b border-accent bg-accent px-6 py-4 font-mono text-[13px] font-bold uppercase tracking-[0.28em] text-bg",children:[e("span",{children:"Your order"}),e(O,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit ↗"})]}),e("div",{className:"flex flex-col px-6 py-2",children:i.length===0?a("div",{className:"py-8 text-center font-serif text-[16px] italic leading-[1.5] text-fg-dim",children:["Your cart is empty. ",e(O,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog →"})]}):i.map(o=>e(ne,{slug:o.slug,name:o.name,qty:o.qty,config:o.config,configSummary:ae(o.config),price:q(o,n.currency)??0,currency:n.currency},o.id))}),e("div",{className:"border-t border-line px-6 pt-5",children:e(W,{customerEmail:b})}),a("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[e(v,{label:"Subtotal",value:s(n.subtotal,n.currency)}),n.discount>0&&l?.valid&&e(v,{label:`Coupon · ${l.code}`,value:a("span",{className:"font-semibold text-green",children:["− ",s(n.discount,n.currency)]})}),l?.deferred&&e(v,{label:`Coupon · ${l.code}`,value:K}),l?.valid&&l.effects?.gift&&e(v,{label:`Free gift · ${l.effects.gift.partNumber}${l.effects.gift.quantity>1?` ×${l.effects.gift.quantity}`:""}`,value:e("span",{className:"font-semibold text-green",children:j})}),e(v,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:j}):X(n.shippingStatus)??s(n.shipping,n.currency)}),n.tax&&(n.tax.charged?e(v,{label:n.tax.inclusive?`${n.tax.name} included · ${n.tax.rate}%`:n.tax.name,value:s(n.tax.amount,n.currency)}):n.tax.name?e(v,{label:n.tax.name,value:Z}):null)]}),a("div",{className:"mt-4 flex items-end justify-between border-y-2 border-accent px-6 py-4",style:{background:"color-mix(in oklab, var(--accent) 10%, var(--bg))"},children:[e("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),e("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:n.repricing?"…":s(n.grand,n.currency)})]}),a("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[m&&e("p",{className:"border border-red-300 bg-red-50 px-3 py-2 text-[13px] text-red-700",children:m}),n.hasUnpricedLine&&a("p",{className:"border border-amber-300 bg-amber-50 px-3 py-2 text-[13px] text-amber-800",children:["One or more items have no price in ",n.currency,". Remove them, or switch region, to continue."]}),e("button",{type:"button",onClick:d,disabled:c||x||i.length===0||n.hasUnpricedLine||n.repricing,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",i.length===0||c||x||n.hasUnpricedLine||n.repricing?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:c?a(N,{children:["Building order… ",e("span",{children:"·"})]}):x?a(N,{children:["No online payment ",e("span",{children:"·"})]}):n.repricing?a(N,{children:["Updating total… ",e("span",{children:"·"})]}):a(N,{children:[p==="bank"?"Place order":"Continue to payment"," ·"," ",s(n.grand,n.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})})]})]})}const u="w-full border-2 border-line bg-bg px-4 py-4 font-display text-[17px] tracking-[-0.005em] text-fg outline-none transition-colors placeholder:text-fg-dim hover:border-fg-dim focus:border-accent",T={backgroundImage:"linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%)",backgroundPosition:"calc(100% - 18px) 50%, calc(100% - 12px) 50%",backgroundSize:"6px 6px",backgroundRepeat:"no-repeat"};function w({num:t,title:i,children:n}){return a("section",{className:"mb-6 border border-line bg-bg",children:[a("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t}),e("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:i})]}),e("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function I({cols:t="two",children:i}){return e("div",{className:["grid gap-3 max-[640px]:grid-cols-1",t==="two"?"grid-cols-2":"grid-cols-[1.2fr_1fr_1fr]"].join(" "),children:i})}function S({active:t,onClick:i,title:n,body:l,price:s,tag:p}){return a("button",{type:"button",onClick:i,"aria-pressed":t,className:["relative grid grid-cols-[auto_1fr_auto] items-center gap-5 border bg-bg px-6 py-5 text-left transition-colors",t?"border-accent outline outline-1 outline-accent -outline-offset-1":"border-line hover:border-[color-mix(in_oklab,var(--accent)_50%,var(--site-line))]"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 14%, var(--bg))"}:void 0,children:[t&&e("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),e("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",t?"border-accent":"border-fg-dim"].join(" "),children:t&&e("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),a("span",{className:"flex min-w-0 flex-col gap-1",children:[a("span",{className:"flex flex-wrap items-baseline gap-3 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,p&&e("span",{className:"border px-2 py-0.5 font-mono text-[11px] font-normal uppercase tracking-[0.24em] text-accent",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 45%, var(--site-line))"},children:p})]}),l&&e("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:l})]}),e("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:s})]})}function te({checked:t,onChange:i,label:n,sub:l}){return a("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[e("button",{type:"button",onClick:()=>i(!t),"aria-pressed":t,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",t?"border-accent":"border-line"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:t&&e("span",{className:"text-[13px] text-accent",children:"✓"})}),a("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,l&&e("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:l})]})]})}function ne({slug:t,name:i,qty:n,config:l,configSummary:s,price:p,currency:c}){const{catalog:b}=D(),{formatMoney:m}=G(),f=b.find(g=>g.slug===t),x=f?.spokes??5,d=f?.mesh??!1,o=l.find(g=>g.gold)?.label,y=f?.finishes.find(g=>g.name===o&&g.src)??f?.finishes.find(g=>g.src),C=f?.finishes[0]?.color??J;return a("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-4 border-b border-line py-4 last:border-b-0",children:[a("div",{className:"relative flex aspect-square items-center justify-center overflow-hidden border border-line bg-surface",children:[e("span",{className:"absolute -right-1.5 -top-1.5 z-[2] flex h-[18px] w-[18px] items-center justify-center rounded-full bg-accent font-mono text-[11px] font-bold text-bg",children:n}),y?.src?e(H,{src:y.src,alt:`${i.lead}${i.accent} — ${y.name}`,width:120,height:120,sizes:"60px",className:"relative block h-full w-full object-contain p-2"}):e("div",{className:"block w-[78%]",style:{color:C},children:e(Q,{spokes:x,mesh:d,className:"block w-full"})})]}),a("div",{className:"flex min-w-0 flex-col gap-0.5",children:[a("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[i.lead,e("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:i.accent})]}),e("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:s})]}),e("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:m(p,c)})]})}function v({label:t,value:i}){return a("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[e("span",{children:t}),e("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:i})]})}function ae(t){return t.map(i=>i.label).join(" · ")}export{ye as CheckoutContact,Ce as CheckoutOrderSummary,ke as CheckoutPayment,Ne as CheckoutShippingAddress,ve as CheckoutShippingMethod};
@@ -12,6 +12,8 @@ interface PayOption {
12
12
  export declare function buildPayOptions(site: SiteIdentity, { canParkContext, }?: {
13
13
  canParkContext: boolean;
14
14
  }): PayOption[];
15
+ export declare const NO_PAYMENT_METHOD_NOTE = "This shop does not take payment online yet. Please contact the shop to order.";
16
+ export declare const SHIPPING_RETRY_NOTE = "Shipping cannot be calculated right now. Please try again.";
15
17
  export interface CheckoutProps {
16
18
  site: SiteIdentity;
17
19
  logo?: {
@@ -68,6 +70,8 @@ declare function useCheckoutState({ site, logo, preview }: CheckoutProps): {
68
70
  methodType: "delivery" | "pickup";
69
71
  pickupLocation: import("../../lib/api/types.js").components["schemas"]["PickupLocation"] | null;
70
72
  }[];
73
+ courierUnavailable: boolean;
74
+ retryCourier: () => void;
71
75
  shippingMethodId: string | null;
72
76
  setShippingMethodId: (id: string) => void;
73
77
  pickupLocation: {
@@ -83,8 +87,8 @@ declare function useCheckoutState({ site, logo, preview }: CheckoutProps): {
83
87
  } | null;
84
88
  servedCountries: import("../../lib/content/site.js").SiteCountry[];
85
89
  formatMoney: (amount: number, currency?: string) => string;
86
- payChoice: PayKey;
87
- setPayChoice: import("react").Dispatch<import("react").SetStateAction<PayKey>>;
90
+ payChoice: PayKey | null;
91
+ setPayChoice: import("react").Dispatch<import("react").SetStateAction<PayKey | null>>;
88
92
  placing: boolean;
89
93
  email: string;
90
94
  setEmail: import("react").Dispatch<import("react").SetStateAction<string>>;
@@ -159,6 +163,7 @@ declare function useCheckoutState({ site, logo, preview }: CheckoutProps): {
159
163
  fillFromAddress: (a: ShopAddress) => void;
160
164
  checkoutSignOut: () => void;
161
165
  payOptions: PayOption[];
166
+ noPaymentMethod: boolean;
162
167
  placeOrder: () => Promise<void>;
163
168
  };
164
169
  export type CheckoutState = ReturnType<typeof useCheckoutState>;
@@ -1,3 +1,3 @@
1
- "use client";import{jsx as w}from"react/jsx-runtime";import{createContext as ht,useContext as gt,useEffect as u,useMemo as Oe,useRef as Re,useState as e}from"react";import{isOrderable as _e,useCart as kt}from"../CartContext.js";import{useCurrency as wt}from"../CurrencyContext.js";import{getClickIds as Ct}from"../../lib/click-ids.js";import{adConsentForOrder as St}from"../../lib/consent/choice.js";import{trackBeginCheckout as bt,trackPurchase as At}from"../../lib/google-tag.js";import{trackMetaPurchase as Pt}from"../../lib/meta-pixel.js";import{ApiError as vt,api as N,products as p}from"../../lib/api/index.js";import{uuid as xt}from"../../lib/uuid.js";import{orderLinesForSets as Nt}from"../../lib/commerce.js";import{canPersist as Kt,safeSessionStorage as g}from"efficient-web-builder/format/lib/safe-storage";import{AFTERPAY_CONTEXT_KEY as Et,AFTERPAY_RETURN as It,GOCARDLESS_CONTEXT_KEY as oe,KLARNA_CONTEXT_KEY as re,ZIP_CONTEXT_KEY as Ot,ZIP_RETURN as Rt,runWalletReturn as Te}from"../../lib/checkout/wallet-return.js";import{matchSubdivision as _t}from"../../lib/checkout/match-subdivision.js";import{couponCodeForOrder as Tt,couponRefusedByOrder as Mt}from"../../lib/cart/coupon-preview.js";function Me(r){const f=r.indexOf(`
2
- `);return f===-1?[r,""]:[r.slice(0,f),r.slice(f+1)]}function Le(r,{canParkContext:f}={canParkContext:!0}){const l=r.paymentMethods,a=[];return l.includes("card")&&a.push({key:"card",title:"Card",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),l.includes("paypal")&&r.paypalClientId&&a.push({key:"paypal",title:"PayPal",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAYPAL · CARDS"})}),l.includes("afterpay")&&a.push({key:"afterpay",title:"Afterpay",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"4 × INTEREST-FREE"})}),l.includes("square")&&r.squareApplicationId&&r.squareLocationId&&a.push({key:"square",title:"Card (Square)",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),l.includes("gocardless")&&f&&a.push({key:"gocardless",title:"Bank Direct Debit",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY BY BANK"})}),l.includes("zip")&&a.push({key:"zip",title:"Zip",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY IN 4"})}),l.includes("klarna")&&f&&a.push({key:"klarna",title:"Klarna",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),a.push({key:"bank",title:"Bank transfer",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),a}function Lt({site:r,logo:f,preview:l=!1}){const{items:a,totals:C,coupon:b,refuseCoupon:Ue,deliveryOptions:se,shippingMethodId:U,setShippingMethodId:ze,setQuoteDestination:K,identify:ce,clearCapturedCart:E}=kt(),Ye=se.find(t=>t.id===U)?.pickupLocation??null,{country:Be,countries:I,activeCountry:ae,formatMoney:qe}=wt(),[y,ie]=e(()=>Le(r)[0].key),[le,Fe]=e(!0);u(()=>{Fe(Kt(g))},[]);const[de,ue]=e(!1),[O,pe]=e(""),[A,me]=e(""),[z,fe]=e(""),[Y,B]=e(""),[q,F]=e(""),[D,J]=e(""),[X,Z]=e(""),[H,G]=e(""),[i,W]=e(()=>Be||I[0]?.code||""),[P,j]=e(""),[R,ye]=e([]),[he,Q]=e(null),[_,T]=e(null),ge=Oe(()=>I.find(t=>t.code===i)??ae,[I,i,ae]),De=ge?.postalLabel||"Postal Code",Je=R[0]?.divisionType||"State / Province";u(()=>{if(!i){ye([]),Q(i);return}Q(null);let t=!1;return p.listCountrySubdivisions(i).then(n=>{t||(ye(n),Q(i),j(""))}),()=>{t=!0}},[i]),u(()=>{K(i?{country:i,subdivision:P}:null)},[i,P,K]),u(()=>()=>K(null),[K]);const[V,ke]=e(null),[Xe,we]=e([]),[Ce,ee]=e("new"),[Se,be]=e(!1),[Ae,Ze]=e("Home"),[He,Pe]=e(null),[m]=e(()=>xt()),[Ge,S]=e(null),[We,v]=e(null),[je,Qe]=e(null),[Ve,et]=e(!1),[tt,nt]=e(!1),[ot,te]=e(null),[rt,M]=e(!1),[st,k]=e(null),[ct,at]=e(!1),[it,ve]=e(!1),[lt,dt]=e(!1),[ut,xe]=e(!1),Ne=Re(!1);u(()=>{l||Ne.current||!a.some(_e)||(Ne.current=!0,bt({lines:a,currency:C.currency,value:C.subtotal-C.discount,coupon:b?.valid?b.code:void 0}))},[a,C,b,l]),u(()=>{ce(O,A.trim()||void 0)},[O,A,ce]);const Ke=Re(null),[L,pt]=e(null);u(()=>{const t=Ke.current;if(!L||!t)return;const n=()=>t.style.setProperty("--sf-checkout-header-h",`${L.offsetHeight}px`);n();const o=new ResizeObserver(n);return o.observe(L),()=>o.disconnect()},[L]),u(()=>{const t=o=>({setConfirming:o,land:S,markPaid:()=>M(!0),note:k,fail:v,clearCart:E}),n={search:window.location.search,storage:g,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};Te(It,{...n,capture:p.captureAfterpayPayment,page:t(at)}),Te(Rt,{...n,capture:p.captureZipPayment,page:t(dt)})},[]),u(()=>{const n=new URLSearchParams(window.location.search).get("gocardless");if(n!=="confirm"&&n!=="cancel")return;const o=g.getItem(oe);if(g.removeItem(oe),window.history.replaceState(null,"",window.location.pathname),!o)return;let c;try{c=JSON.parse(o)}catch{return}if(E(),n==="cancel"){k("The direct debit was not set up — our team will follow up on payment."),S(c.confirmation);return}ve(!0),p.completeGocardlessPayment({idempotencyKey:c.idempotencyKey}).then(s=>{s.status==="paid"?M(!0):s.status==="declined"?k("The direct debit was declined — our team will follow up on payment."):k("Your direct debit is set up — the payment is collecting and will clear in a few days.")}).catch(()=>{k("We could not confirm the direct debit — our team will follow up on payment.")}).finally(()=>{S(c.confirmation),ve(!1)})},[]),u(()=>{const t=new URLSearchParams(window.location.search),n=t.get("klarna");if(n!=="confirm"&&n!=="cancel")return;const o=g.getItem(re);g.removeItem(re);const c=t.get("authorization_token");if(window.history.replaceState(null,"",window.location.pathname),!o)return;let s;try{s=JSON.parse(o)}catch{return}if(E(),n==="cancel"||!c){k("The Klarna payment was not completed — our team will follow up on payment."),S(s.confirmation);return}xe(!0),p.captureKlarnaPayment({idempotencyKey:s.idempotencyKey,authorizationToken:c}).then(d=>{d.status==="paid"?M(!0):d.status==="declined"?k("Klarna declined the payment — our team will follow up on payment."):k("Your Klarna payment is being reviewed — we'll confirm the outcome shortly.")}).catch(()=>{k("We could not confirm the Klarna payment — our team will follow up on payment.")}).finally(()=>{S(s.confirmation),xe(!1)})},[]);function Ee(t){const[n,o]=Me(t.address);B(n),F(o),J(t.city),Z(t.zip_code),t.country&&W(t.country),t.phone&&G(t.phone),T({country:t.country||null,state:t.state??""})}u(()=>{if(_){if((_.country||i)!==i){T(null);return}he===i&&(j(_t(i,_.state,R)),T(null))}},[_,i,he,R]),u(()=>{let t=!1;return(async()=>{try{const[n,o,c]=await Promise.all([N.me(),N.myProfile().catch(()=>null),N.myAddresses().catch(()=>[])]);if(t)return;ke(n);const s=c.filter(x=>x.is_active);we(s),pe(n.email);const d=(o?.contact_name??"").split(/\s+/);me(n.first_name||d[0]||""),fe(n.last_name||d.slice(1).join(" "));const h=n.phone||o?.phone;h&&G(h);const ne=s.find(x=>x.id===n.default_delivery_location)??s[0];if(ne)ee(ne.id),Ee(ne);else if(o){const[x,yt]=Me(o.address??"");B(x),F(yt),J(o.city??""),Z(o.zip_code??""),o.country&&W(o.country),T({country:o.country||null,state:o.state??""})}}catch{}})(),()=>{t=!0}},[]);function mt(){N.logout(),ke(null),we([]),ee("new"),be(!1)}const $=Oe(()=>Le(r,{canParkContext:le}),[r,le]);u(()=>{$.some(t=>t.key===y)||ie($[0].key)},[$,y]);const Ie=q.trim()?`${Y}
3
- ${q.trim()}`:Y;async function ft(){if(l||de||a.length===0||C.repricing)return;const t=a.filter(_e).flatMap(n=>Nt(n.components,n.qty));if(t.length===0){v("Pick a size on each wheel's product page before checking out.");return}ue(!0),v(null);try{const n=V?p.createOrderAuthed:p.createOrder,o=St(),c=await n({customer:{email:O,name:`${A} ${z}`.trim(),phone:H.trim()||void 0,address:Ie,city:D,state:P||void 0,zipCode:X,country:i},items:t,currency:C.currency,idempotencyKey:m,shippingMethodId:U??void 0,couponCode:Tt(b),...o==="denied"?{}:Ct(),...o?{adConsent:o}:{}});if(At({confirmation:c,lines:a,adsSendTo:r.googleAdsId&&r.googleAdsConversionLabel?`${r.googleAdsId}/${r.googleAdsConversionLabel}`:null}),Pt({confirmation:c,lines:a}),E(),V&&Se&&Ce==="new")try{await N.createAddress({label:Ae.trim()||"Home",contact_name:`${A} ${z}`.trim(),phone:H.trim(),address:Ie,city:D,zip_code:X,state:P,country:i}),Pe("Address saved to your account.")}catch{Pe("We couldn't save the address to your account — you can add it under Account → Addresses.")}if(y==="card"&&r.paymentMethods.includes("card")){const s=await p.createPaymentIntent({idempotencyKey:m});te(c),Qe(s)}else if(y==="paypal"&&r.paymentMethods.includes("paypal"))te(c),et(!0);else if(y==="afterpay"&&r.paymentMethods.includes("afterpay")){const s=window.location.origin,d=await p.createAfterpayCheckout({idempotencyKey:m,confirmUrl:`${s}/checkout?afterpay=confirm`,cancelUrl:`${s}/checkout?afterpay=cancel`}),h={idempotencyKey:m,confirmation:c};g.setItem(Et,JSON.stringify(h)),window.location.assign(d.redirectCheckoutUrl);return}else if(y==="square"&&r.paymentMethods.includes("square"))te(c),nt(!0);else if(y==="gocardless"&&r.paymentMethods.includes("gocardless")){const s=window.location.origin,d=await p.createGocardlessBillingRequest({idempotencyKey:m,confirmUrl:`${s}/checkout?gocardless=confirm`,cancelUrl:`${s}/checkout?gocardless=cancel`}),h={idempotencyKey:m,confirmation:c};g.setItem(oe,JSON.stringify(h)),window.location.assign(d.authorisationUrl);return}else if(y==="zip"&&r.paymentMethods.includes("zip")){const s=window.location.origin,d=await p.createZipCheckout({idempotencyKey:m,redirectUrl:`${s}/checkout?zip=return`}),h={idempotencyKey:m,confirmation:c};g.setItem(Ot,JSON.stringify(h)),window.location.assign(d.redirectUrl);return}else if(y==="klarna"&&r.paymentMethods.includes("klarna")){const s=window.location.origin,d=await p.createKlarnaCheckout({idempotencyKey:m,confirmUrl:`${s}/checkout?klarna=confirm`,cancelUrl:`${s}/checkout?klarna=cancel`}),h={idempotencyKey:m,confirmation:c};g.setItem(re,JSON.stringify(h)),window.location.assign(d.redirectUrl);return}else S(c)}catch(n){const o=Mt(n);o?(Ue(o),v(`${o} Your order has not been placed. Place it again to continue without the code.`)):v(n instanceof vt?n.message:"Could not place the order. Please try again."),ue(!1)}}return{site:r,logo:f,items:a,totals:C,coupon:b,deliveryOptions:se,shippingMethodId:U,setShippingMethodId:ze,pickupLocation:Ye,servedCountries:I,formatMoney:qe,payChoice:y,setPayChoice:ie,placing:de,email:O,setEmail:pe,firstName:A,setFirstName:me,lastName:z,setLastName:fe,address1:Y,setAddress1:B,address2:q,setAddress2:F,city:D,setCity:J,postcode:X,setPostcode:Z,phone:H,setPhone:G,country:i,setCountry:W,subdivision:P,setSubdivision:j,subdivisions:R,destination:ge,postcodeLabel:De,subdivisionLabel:Je,me:V,savedAddresses:Xe,selectedAddressId:Ce,setSelectedAddressId:ee,saveAddress:Se,setSaveAddress:be,saveLabel:Ae,setSaveLabel:Ze,addressSaveNote:He,idemKey:m,confirmation:Ge,setConfirmation:S,orderError:We,payment:je,paypalStep:Ve,squareStep:tt,pendingConf:ot,paid:rt,setPaid:M,payNote:st,afterpayConfirming:ct,gocardlessConfirming:it,zipConfirming:lt,klarnaConfirming:ut,checkoutRootRef:Ke,setCheckoutHeaderEl:pt,fillFromAddress:Ee,checkoutSignOut:mt,payOptions:$,placeOrder:ft}}const $e=ht(null);function Qt({children:r,...f}){const l=Lt(f);return w($e.Provider,{value:l,children:r})}function Vt(){const r=gt($e);if(!r)throw new Error("useCheckout must be used inside CheckoutStateProvider");return r}export{Qt as CheckoutStateProvider,Le as buildPayOptions,Vt as useCheckout};
1
+ "use client";import{jsx as w}from"react/jsx-runtime";import{createContext as bt,useContext as St,useEffect as u,useMemo as Te,useRef as _e,useState as e}from"react";import{isOrderable as Re,useCart as At}from"../CartContext.js";import{useCurrency as vt}from"../CurrencyContext.js";import{getClickIds as xt}from"../../lib/click-ids.js";import{adConsentForOrder as Nt}from"../../lib/consent/choice.js";import{trackBeginCheckout as Et,trackPurchase as It}from"../../lib/google-tag.js";import{trackMetaPurchase as Kt}from"../../lib/meta-pixel.js";import{ApiError as Ot,api as K,products as m}from"../../lib/api/index.js";import{uuid as Tt}from"../../lib/uuid.js";import{orderLinesForSets as _t}from"../../lib/commerce.js";import{canPersist as Rt,safeSessionStorage as g}from"efficient-web-builder/format/lib/safe-storage";import{AFTERPAY_CONTEXT_KEY as Mt,AFTERPAY_RETURN as Lt,GOCARDLESS_CONTEXT_KEY as re,KLARNA_CONTEXT_KEY as se,ZIP_CONTEXT_KEY as $t,ZIP_RETURN as Ut,runWalletReturn as Me}from"../../lib/checkout/wallet-return.js";import{matchSubdivision as Yt}from"../../lib/checkout/match-subdivision.js";import{couponCodeForOrder as zt,couponRefusedByOrder as qt}from"../../lib/cart/coupon-preview.js";function Le(r){const y=r.indexOf(`
2
+ `);return y===-1?[r,""]:[r.slice(0,y),r.slice(y+1)]}function $e(r,{canParkContext:y}={canParkContext:!0}){const l=r.paymentMethods,i=[];return l.includes("card")&&i.push({key:"card",title:"Card",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),l.includes("paypal")&&r.paypalClientId&&i.push({key:"paypal",title:"PayPal",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAYPAL · CARDS"})}),l.includes("afterpay")&&i.push({key:"afterpay",title:"Afterpay",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"4 × INTEREST-FREE"})}),l.includes("square")&&r.squareApplicationId&&r.squareLocationId&&i.push({key:"square",title:"Card (Square)",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),l.includes("gocardless")&&y&&i.push({key:"gocardless",title:"Bank Direct Debit",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY BY BANK"})}),l.includes("zip")&&i.push({key:"zip",title:"Zip",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY IN 4"})}),l.includes("klarna")&&y&&i.push({key:"klarna",title:"Klarna",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),l.includes("bank")&&i.push({key:"bank",title:"Bank transfer",body:null,price:w("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),i}const sn="This shop does not take payment online yet. Please contact the shop to order.",cn="Shipping cannot be calculated right now. Please try again.";function Bt({site:r,logo:y,preview:l=!1}){const{items:i,totals:C,coupon:A,refuseCoupon:Ye,deliveryOptions:ce,shippingMethodId:q,setShippingMethodId:ze,setQuoteDestination:O,courier:qe,requote:Be,identify:ae,clearCapturedCart:T}=At(),Fe=ce.find(n=>n.id===q)?.pickupLocation??null,{country:De,countries:_,activeCountry:ie,formatMoney:He}=vt(),[p,le]=e(()=>$e(r)[0]?.key??null),[de,Je]=e(!0);u(()=>{Je(Rt(g))},[]);const[ue,pe]=e(!1),[R,me]=e(""),[v,fe]=e(""),[B,ye]=e(""),[M,F]=e(""),[D,H]=e(""),[L,J]=e(""),[x,X]=e(""),[Z,G]=e(""),[a,W]=e(()=>De||_[0]?.code||""),[b,j]=e(""),[N,he]=e([]),[Q,V]=e(null),[$,U]=e(null),ge=Te(()=>_.find(n=>n.code===a)??ie,[_,a,ie]),Xe=ge?.postalLabel||"Postal Code",Ze=N[0]?.divisionType||"State / Province";u(()=>{if(!a){he([]),V(a);return}V(null);let n=!1;return m.listCountrySubdivisions(a).then(t=>{n||(he(t),V(a),j(""))}),()=>{n=!0}},[a]);const ke=M.trim()!==""&&L.trim()!==""&&x.trim()!==""&&Q===a&&(N.length===0||b!=="")?x.trim():"";u(()=>{O(a?{country:a,subdivision:b,postcode:ke}:null)},[a,b,ke,O]),u(()=>()=>O(null),[O]);const Ge=qe?.status==="unavailable",We=Be,[ee,we]=e(null),[je,Ce]=e([]),[Pe,te]=e("new"),[be,Se]=e(!1),[Ae,Qe]=e("Home"),[Ve,ve]=e(null),[f]=e(()=>Tt()),[et,P]=e(null),[tt,E]=e(null),[nt,ot]=e(null),[rt,st]=e(!1),[ct,at]=e(!1),[it,ne]=e(null),[lt,Y]=e(!1),[dt,k]=e(null),[ut,pt]=e(!1),[mt,xe]=e(!1),[ft,yt]=e(!1),[ht,Ne]=e(!1),Ee=_e(!1);u(()=>{l||Ee.current||!i.some(Re)||(Ee.current=!0,Et({lines:i,currency:C.currency,value:C.subtotal-C.discount,coupon:A?.valid?A.code:void 0}))},[i,C,A,l]),u(()=>{ae(R,v.trim()||void 0)},[R,v,ae]);const Ie=_e(null),[z,gt]=e(null);u(()=>{const n=Ie.current;if(!z||!n)return;const t=()=>n.style.setProperty("--sf-checkout-header-h",`${z.offsetHeight}px`);t();const o=new ResizeObserver(t);return o.observe(z),()=>o.disconnect()},[z]),u(()=>{const n=o=>({setConfirming:o,land:P,markPaid:()=>Y(!0),note:k,fail:E,clearCart:T}),t={search:window.location.search,storage:g,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};Me(Lt,{...t,capture:m.captureAfterpayPayment,page:n(pt)}),Me(Ut,{...t,capture:m.captureZipPayment,page:n(yt)})},[]),u(()=>{const t=new URLSearchParams(window.location.search).get("gocardless");if(t!=="confirm"&&t!=="cancel")return;const o=g.getItem(re);if(g.removeItem(re),window.history.replaceState(null,"",window.location.pathname),!o)return;let c;try{c=JSON.parse(o)}catch{return}if(T(),t==="cancel"){k("The direct debit was not set up — our team will follow up on payment."),P(c.confirmation);return}xe(!0),m.completeGocardlessPayment({idempotencyKey:c.idempotencyKey}).then(s=>{s.status==="paid"?Y(!0):s.status==="declined"?k("The direct debit was declined — our team will follow up on payment."):k("Your direct debit is set up — the payment is collecting and will clear in a few days.")}).catch(()=>{k("We could not confirm the direct debit — our team will follow up on payment.")}).finally(()=>{P(c.confirmation),xe(!1)})},[]),u(()=>{const n=new URLSearchParams(window.location.search),t=n.get("klarna");if(t!=="confirm"&&t!=="cancel")return;const o=g.getItem(se);g.removeItem(se);const c=n.get("authorization_token");if(window.history.replaceState(null,"",window.location.pathname),!o)return;let s;try{s=JSON.parse(o)}catch{return}if(T(),t==="cancel"||!c){k("The Klarna payment was not completed — our team will follow up on payment."),P(s.confirmation);return}Ne(!0),m.captureKlarnaPayment({idempotencyKey:s.idempotencyKey,authorizationToken:c}).then(d=>{d.status==="paid"?Y(!0):d.status==="declined"?k("Klarna declined the payment — our team will follow up on payment."):k("Your Klarna payment is being reviewed — we'll confirm the outcome shortly.")}).catch(()=>{k("We could not confirm the Klarna payment — our team will follow up on payment.")}).finally(()=>{P(s.confirmation),Ne(!1)})},[]);function Ke(n){const[t,o]=Le(n.address);F(t),H(o),J(n.city),X(n.zip_code),n.country&&W(n.country),n.phone&&G(n.phone),U({country:n.country||null,state:n.state??""})}u(()=>{if($){if(($.country||a)!==a){U(null);return}Q===a&&(j(Yt(a,$.state,N)),U(null))}},[$,a,Q,N]),u(()=>{let n=!1;return(async()=>{try{const[t,o,c]=await Promise.all([K.me(),K.myProfile().catch(()=>null),K.myAddresses().catch(()=>[])]);if(n)return;we(t);const s=c.filter(I=>I.is_active);Ce(s),me(t.email);const d=(o?.contact_name??"").split(/\s+/);fe(t.first_name||d[0]||""),ye(t.last_name||d.slice(1).join(" "));const h=t.phone||o?.phone;h&&G(h);const oe=s.find(I=>I.id===t.default_delivery_location)??s[0];if(oe)te(oe.id),Ke(oe);else if(o){const[I,Pt]=Le(o.address??"");F(I),H(Pt),J(o.city??""),X(o.zip_code??""),o.country&&W(o.country),U({country:o.country||null,state:o.state??""})}}catch{}})(),()=>{n=!0}},[]);function kt(){K.logout(),we(null),Ce([]),te("new"),Se(!1)}const S=Te(()=>$e(r,{canParkContext:de}),[r,de]);u(()=>{S.some(n=>n.key===p)||le(S[0]?.key??null)},[S,p]);const wt=S.length===0,Oe=D.trim()?`${M}
3
+ ${D.trim()}`:M;async function Ct(){if(l||ue||i.length===0||C.repricing||!p||!S.some(t=>t.key===p))return;const n=i.filter(Re).flatMap(t=>_t(t.components,t.qty));if(n.length===0){E("Pick a size on each wheel's product page before checking out.");return}pe(!0),E(null);try{const t=ee?m.createOrderAuthed:m.createOrder,o=Nt(),c=await t({customer:{email:R,name:`${v} ${B}`.trim(),phone:Z.trim()||void 0,address:Oe,city:L,state:b||void 0,zipCode:x,country:a},items:n,currency:C.currency,idempotencyKey:f,shippingMethodId:q??void 0,couponCode:zt(A),...o==="denied"?{}:xt(),...o?{adConsent:o}:{}});if(It({confirmation:c,lines:i,adsSendTo:r.googleAdsId&&r.googleAdsConversionLabel?`${r.googleAdsId}/${r.googleAdsConversionLabel}`:null}),Kt({confirmation:c,lines:i}),T(),ee&&be&&Pe==="new")try{await K.createAddress({label:Ae.trim()||"Home",contact_name:`${v} ${B}`.trim(),phone:Z.trim(),address:Oe,city:L,zip_code:x,state:b,country:a}),ve("Address saved to your account.")}catch{ve("We couldn't save the address to your account — you can add it under Account → Addresses.")}if(p==="card"&&r.paymentMethods.includes("card")){const s=await m.createPaymentIntent({idempotencyKey:f});ne(c),ot(s)}else if(p==="paypal"&&r.paymentMethods.includes("paypal"))ne(c),st(!0);else if(p==="afterpay"&&r.paymentMethods.includes("afterpay")){const s=window.location.origin,d=await m.createAfterpayCheckout({idempotencyKey:f,confirmUrl:`${s}/checkout?afterpay=confirm`,cancelUrl:`${s}/checkout?afterpay=cancel`}),h={idempotencyKey:f,confirmation:c};g.setItem(Mt,JSON.stringify(h)),window.location.assign(d.redirectCheckoutUrl);return}else if(p==="square"&&r.paymentMethods.includes("square"))ne(c),at(!0);else if(p==="gocardless"&&r.paymentMethods.includes("gocardless")){const s=window.location.origin,d=await m.createGocardlessBillingRequest({idempotencyKey:f,confirmUrl:`${s}/checkout?gocardless=confirm`,cancelUrl:`${s}/checkout?gocardless=cancel`}),h={idempotencyKey:f,confirmation:c};g.setItem(re,JSON.stringify(h)),window.location.assign(d.authorisationUrl);return}else if(p==="zip"&&r.paymentMethods.includes("zip")){const s=window.location.origin,d=await m.createZipCheckout({idempotencyKey:f,redirectUrl:`${s}/checkout?zip=return`}),h={idempotencyKey:f,confirmation:c};g.setItem($t,JSON.stringify(h)),window.location.assign(d.redirectUrl);return}else if(p==="klarna"&&r.paymentMethods.includes("klarna")){const s=window.location.origin,d=await m.createKlarnaCheckout({idempotencyKey:f,confirmUrl:`${s}/checkout?klarna=confirm`,cancelUrl:`${s}/checkout?klarna=cancel`}),h={idempotencyKey:f,confirmation:c};g.setItem(se,JSON.stringify(h)),window.location.assign(d.redirectUrl);return}else P(c)}catch(t){const o=qt(t);o?(Ye(o),E(`${o} Your order has not been placed. Place it again to continue without the code.`)):E(t instanceof Ot?t.message:"Could not place the order. Please try again."),pe(!1)}}return{site:r,logo:y,items:i,totals:C,coupon:A,deliveryOptions:ce,courierUnavailable:Ge,retryCourier:We,shippingMethodId:q,setShippingMethodId:ze,pickupLocation:Fe,servedCountries:_,formatMoney:He,payChoice:p,setPayChoice:le,placing:ue,email:R,setEmail:me,firstName:v,setFirstName:fe,lastName:B,setLastName:ye,address1:M,setAddress1:F,address2:D,setAddress2:H,city:L,setCity:J,postcode:x,setPostcode:X,phone:Z,setPhone:G,country:a,setCountry:W,subdivision:b,setSubdivision:j,subdivisions:N,destination:ge,postcodeLabel:Xe,subdivisionLabel:Ze,me:ee,savedAddresses:je,selectedAddressId:Pe,setSelectedAddressId:te,saveAddress:be,setSaveAddress:Se,saveLabel:Ae,setSaveLabel:Qe,addressSaveNote:Ve,idemKey:f,confirmation:et,setConfirmation:P,orderError:tt,payment:nt,paypalStep:rt,squareStep:ct,pendingConf:it,paid:lt,setPaid:Y,payNote:dt,afterpayConfirming:ut,gocardlessConfirming:mt,zipConfirming:ft,klarnaConfirming:ht,checkoutRootRef:Ie,setCheckoutHeaderEl:gt,fillFromAddress:Ke,checkoutSignOut:kt,payOptions:S,noPaymentMethod:wt,placeOrder:Ct}}const Ue=bt(null);function an({children:r,...y}){const l=Bt(y);return w(Ue.Provider,{value:l,children:r})}function ln(){const r=St(Ue);if(!r)throw new Error("useCheckout must be used inside CheckoutStateProvider");return r}export{an as CheckoutStateProvider,sn as NO_PAYMENT_METHOD_NOTE,cn as SHIPPING_RETRY_NOTE,$e as buildPayOptions,ln as useCheckout};
@@ -471,15 +471,9 @@ export interface AdminStorefrontSite {
471
471
  id: string;
472
472
  name: string;
473
473
  slug: string;
474
- maps_api_key: string;
475
- maps_map_id: string;
476
474
  display_order?: number;
477
475
  created_at?: string;
478
476
  }
479
- export type AdminStorefrontSitePatch = {
480
- maps_api_key?: string;
481
- maps_map_id?: string;
482
- };
483
477
  export interface AdminSiteChange {
484
478
  kind: string;
485
479
  id: string;
@@ -738,7 +732,6 @@ export declare function createStorefrontAdmin(client?: AdminClient): {
738
732
  listSiteCurrencies: (siteId: string, token: string) => Promise<AdminStorefrontSiteCurrency[]>;
739
733
  publishSite: (siteId: string, token: string) => Promise<AdminSitePublishResult>;
740
734
  getSiteLiveState: (siteId: string, token: string) => Promise<AdminSiteLiveState>;
741
- updateSite: (siteId: string, patch: AdminStorefrontSitePatch, token: string) => Promise<AdminStorefrontSite>;
742
735
  getThemeSettings: (token: string, siteId?: string) => Promise<AdminThemeSettings>;
743
736
  updateThemeSettings: (patch: AdminThemeSettingsPatch, token: string, siteId?: string) => Promise<AdminThemeSettings>;
744
737
  getChatSettings: (token: string, siteId?: string) => Promise<AdminChatSettings>;
@@ -817,7 +810,6 @@ export declare const storefrontAdmin: {
817
810
  listSiteCurrencies: (siteId: string, token: string) => Promise<AdminStorefrontSiteCurrency[]>;
818
811
  publishSite: (siteId: string, token: string) => Promise<AdminSitePublishResult>;
819
812
  getSiteLiveState: (siteId: string, token: string) => Promise<AdminSiteLiveState>;
820
- updateSite: (siteId: string, patch: AdminStorefrontSitePatch, token: string) => Promise<AdminStorefrontSite>;
821
813
  getThemeSettings: (token: string, siteId?: string) => Promise<AdminThemeSettings>;
822
814
  updateThemeSettings: (patch: AdminThemeSettingsPatch, token: string, siteId?: string) => Promise<AdminThemeSettings>;
823
815
  getChatSettings: (token: string, siteId?: string) => Promise<AdminChatSettings>;
@@ -1 +1 @@
1
- import{PREVIEW_TOKEN_HEADER as tt,SITE_HOST_HEADER as et,SITE_SLUG_HEADER as rt}from"../site-headers.js";import{PRODUCT_API_BASE as at,PRODUCT_BACKEND_URL as k}from"./origins.js";import{backendHopHeaders as st,clientIpFromForwardedFor as nt,FORWARDED_FOR_HEADER as ot,hopCachingOf as it}from"../forwarded-for.js";import ct from"efficient-web-builder/format/lib/document/media-manifest.json";import{auth as P}from"../auth.js";import{efficientClientOpen as dt}from"efficient-easel/screen/lib/session";import{listableWheelSummaries as J}from"../wheels/listable-wheels.js";import{dropRenderlessFinishes as L}from"../wheels/renderable-finishes.js";const ut=process.env.NEXT_PUBLIC_API_URL??"http://localhost:8000";class m extends Error{status;data;constructor(e,s,o){super(s),this.status=e,this.data=o}}const U="Unable to reach the server. This could be a problem with your internet connection, or the server may be undergoing maintenance or an upgrade. Please try again shortly.",lt=new Set([502,503,504]),I=0,pt="This editor runs on its host's own backend, which does not serve this request.",yt=5e3,ht=15e3,ft=()=>typeof window>"u"?yt:ht;function D(t){const e=(t.method??"GET").toUpperCase();if(!(t.body!=null||e!=="GET"&&e!=="HEAD")&&!(t.audience!=null&&t.audience!=="shop")&&typeof AbortSignal?.timeout=="function")return AbortSignal.timeout(ft())}const x=t=>t instanceof Error&&t.name==="TimeoutError",H=(t,e)=>lt.has(t)?U:e,gt=["admin","venue"];let M="admin";function ne(t){M=gt.includes(t)?t:"admin"}function mt(){return M}const wt=/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/;let F=null;function oe(t){F=t&&wt.test(t)?t:null}function St(){return F}function Pt(t){if(typeof window>"u"||!t.startsWith("/api/v1/"))return t;const e=j();return!e||/[?&]site=/.test(t)?t:C(t,`site=${encodeURIComponent(e)}`)}async function i(t,e={}){const{token:s,baseUrl:o,headers:l,audience:p,...w}=e;if(typeof window<"u"&&!dt())throw new m(I,pt,null);if(typeof window>"u"&&o===void 0)throw new Error(`apiFetch(${JSON.stringify(t)}) ran on the server without an explicit baseUrl. The API_URL default it would inherit is browser-only (the prod image bakes NEXT_PUBLIC_API_URL="" for same-origin use, which a Node fetch cannot resolve). Pass a base explicitly: \`await backendOpts()\` (or baseUrl: PRODUCT_FETCH_BASE) for product reads, or the server-only PRODUCT_BACKEND_URL env for other backend surfaces.`);const a=typeof FormData<"u"&&w.body instanceof FormData;let r;try{r=await fetch(`${o??ut}${Pt(t)}`,{...w,headers:{...a?{}:{"Content-Type":"application/json"},...s?{Authorization:`Bearer ${s}`}:{},...p===null?{}:{"X-Portal-Audience":p??"shop"},...l},signal:w.signal??D({...w,audience:p})})}catch(y){throw y instanceof TypeError||x(y)?new m(I,U,null):y}let n;try{n=await r.text()}catch(y){throw x(y)?new m(I,U,null):y}let c=null;if(n)try{c=JSON.parse(n)}catch{throw new m(r.status,r.ok?"Expected JSON but received a non-JSON response":H(r.status,r.statusText),n)}if(!r.ok){const y=(c&&typeof c=="object"&&"detail"in c&&typeof c.detail=="string"?c.detail:null)??H(r.status,r.statusText);throw new m(r.status,y,c)}return c}let O=null;async function B(){return O||(O=bt().finally(()=>{O=null}),O)}async function bt(){const t=P.takeLegacyRefresh(),e=await Ot.refresh(t??void 0);return P.setTokens(e.access),e.access}async function q(){return P.getAccess()??B()}async function h(t,e={}){let s;try{s=await q()}catch{throw P.clear(),new m(401,"Not signed in",null)}try{return await i(t,{...e,token:s})}catch(o){if(!(o instanceof m)||o.status!==401)throw o;try{const l=await B();return await i(t,{...e,token:l})}catch{throw P.clear(),o}}}async function G(t,e={}){if(P.getAccess())try{return{data:await h(t,e),asShopper:!0}}catch(s){if(!(s instanceof m)||s.status!==401)throw s}return{data:await i(t,e),asShopper:!1}}async function W(){const t=await h("/api/auth/me/");if(t.portal!=="shop")throw P.clear(),new m(403,"This session is not valid for this shop.",null);return t}const Ot={login:(t,e)=>i("/api/auth/login/",{method:"POST",body:JSON.stringify({email:t,password:e,portal:"shop"}),credentials:"include"}),refresh:t=>i("/api/auth/refresh/",{method:"POST",body:JSON.stringify(t?{refresh:t,portal:"shop"}:{portal:"shop"}),credentials:"include"}),logout:async()=>{P.clear();try{await i("/api/auth/logout/",{method:"POST",body:JSON.stringify({portal:"shop"}),credentials:"include"})}catch{}},restoreSession:async()=>{const t=await q();return await W(),t},me:W,updateMe:t=>h("/api/auth/me/",{method:"PATCH",body:JSON.stringify(t)}),changePassword:(t,e)=>h("/api/auth/me/",{method:"PATCH",body:JSON.stringify({password:e,old_password:t})}),changeEmail:(t,e)=>h("/api/shop-portal/change-email/",{method:"POST",body:JSON.stringify({new_email:t,current_password:e})}),myProfile:()=>h("/api/shop-portal/profile/"),updateMyProfile:t=>h("/api/shop-portal/profile/",{method:"PATCH",body:JSON.stringify(t)}),myAddresses:()=>h("/api/shop-portal/delivery-locations/"),createAddress:t=>h("/api/shop-portal/delivery-locations/",{method:"POST",body:JSON.stringify(t)}),updateAddress:(t,e)=>h(`/api/shop-portal/delivery-locations/${t}/`,{method:"PATCH",body:JSON.stringify(e)}),deleteAddress:t=>h(`/api/shop-portal/delivery-locations/${t}/`,{method:"DELETE"}),passwordResetRequest:t=>i("/api/auth/password-reset/",{method:"POST",body:JSON.stringify({email:t})}),passwordResetConfirm:(t,e,s)=>i("/api/auth/password-reset/confirm/",{method:"POST",body:JSON.stringify({uid:t,token:e,new_password:s})}),brands:()=>h("/api/products/brands/"),myOrders:()=>h("/api/shop-portal/orders/").then(t=>t.results),myOrder:t=>h(`/api/shop-portal/orders/${t}/`),cancelOrder:t=>h(`/api/shop-portal/orders/${t}/cancel/`,{method:"POST"}),myReturns:t=>h(`/api/shop-portal/returns/${t?`?order=${encodeURIComponent(t)}`:""}`).then(e=>e.results),createReturn:t=>h("/api/shop-portal/returns/",{method:"POST",body:JSON.stringify(t)}),withdrawReturn:t=>h(`/api/shop-portal/returns/${t}/cancel/`,{method:"POST"}),uploadReturnPhoto:(t,e)=>{const s=new FormData;return s.append("claim_item",t),s.append("file",e),s.append("media_type",e.type.startsWith("video/")?"video":"image"),h("/api/shop-portal/return-media/",{method:"POST",body:s})}};import{media as At,absolutizeApiUrl as N}from"efficient-web-builder/render/lib/media";import{analyzeLogoSvg as Tt,isSvgUrl as Rt}from"efficient-web-builder/format/lib/logo/reverse-svg";import{getEditorSiteId as Et}from"efficient-web-builder/render/lib/editor-site";import{shopRouteBase as Ct,webRuntimeSiteSlug as j}from"efficient-web-builder/format/lib/web-runtime";function g(t){if(typeof t=="string")return t.startsWith("/media/")?At(t):t;if(Array.isArray(t))return t.map(g);if(t&&typeof t=="object"){const e={};for(const[s,o]of Object.entries(t))e[s]=s==="captions"&&o&&typeof o=="object"&&!Array.isArray(o)?Object.fromEntries(Object.entries(o).map(([l,p])=>[g(l),p])):g(o);return e}return t}import{PRODUCT_API_BASE as we}from"./origins.js";const z=typeof window>"u"&&k!=="",$t=z?k:at,_t=Ct,b=()=>({baseUrl:_t(),audience:null});function d(t,e){const s=e?`?process=${encodeURIComponent(e)}`:"";return`/api/v1${t}${s}`}const Ut=100,K=50;function V(t,e,s){const o=new URLSearchParams;for(const[l,p]of Object.entries(e))p!=null&&p!==""&&o.set(l,String(p));return o.set("pageSize",String(Ut)),s&&o.set("cursor",s),`/api/v1${t}?${o.toString()}`}function It(t,e){return V("/wheels",{process:t},e)}function Nt(t,e,s){return V("/products",{kind:t.join(","),make:e?.make,model:e?.model,year:e?.year,modification:e?.modification},s)}function vt(t){if(!t)return null;try{return new URL(t,"http://cursor.invalid").searchParams.get("cursor")}catch{return null}}async function X(t,e,s=()=>!1){const o=[];let l=null;try{for(let p=0;p<K;p++){const w=await i(await e(l),await u());if(o.push(...w.results),l=vt(w.next),!l)break}l&&console.warn(`[${t}] stopped at ${K} pages (${o.length} rows); catalog may be truncated`)}catch(p){if(s(p))throw p;console.warn(`[${t}] product API unavailable, returning []`,p)}return o}const kt=t=>t instanceof m&&t.status===400;function Jt(t){return t.flatMap(e=>e.kind==="alloy-wheel"?J([e]):[e])}async function Z(){return(await Lt()).host}async function Lt(){try{const{headers:t}=await import("next/headers"),e=await t(),s=p=>p?.split(",")[0]?.split(":")[0]?.trim().toLowerCase()||null,o=s(e.get(et)??e.get("x-forwarded-host")??e.get("host")),l=s(e.get("host"));return{host:o,matchesRequestHost:o!==null&&o===l}}catch{return{host:null,matchesRequestHost:!1}}}async function Dt(){try{const{headers:t}=await import("next/headers");return nt((await t()).get(ot))}catch{return null}}async function xt(){try{const{headers:t}=await import("next/headers");return(await t()).get(rt)||null}catch{return null}}async function Ht(){const t=await xt();if(t)return`site=${encodeURIComponent(t)}`;const e=await Z();return e?`host=${encodeURIComponent(e)}`:""}async function f(t){if(typeof window<"u"){const e=j();return e?C(t,`site=${encodeURIComponent(e)}`):t}return C(t,await Ht())}function C(t,e){return e?`${t}${t.includes("?")?"&":"?"}${e}`:t}const Mt="preview";async function Ft(){if(typeof window<"u")return null;try{const{headers:t}=await import("next/headers");return(await t()).get(tt)}catch{return null}}async function Bt(){try{const{headers:t}=await import("next/headers");return(await t()).get("user-agent")}catch{return null}}async function v(t,e){const s=await Ft();if(s===null)return[await f(t),await u(e)];const o=C(await f(t),`${Mt}=${encodeURIComponent(s)}`),{next:l,cache:p,...w}=e??{},a=await u({...w,cache:"no-store"}),r=await Bt();return r&&(a.headers={...a.headers,"user-agent":r}),[o,a]}async function qt(t){if(!z)return;const[e,s]=await Promise.all([Z(),Dt()]),o=st(e,s,t);return Object.keys(o).length>0?o:void 0}async function u(t){const e=await qt(it(t)),s={baseUrl:$t,...t};return e&&(s.headers={...e,...t?.headers}),s}const A=typeof window>"u";function T(t,e){const s=new URLSearchParams;for(const[l,p]of Object.entries(e))p!==void 0&&p!==""&&s.set(l,String(p));const o=s.toString();return`/api/v1/fitment${t}${o?`?${o}`:""}`}const le={listMakes:async t=>{if(A){const{fitmentData:s}=await import("./fitment-data.js");return s.makes(t)}return(await i(T("/makes",{region:t}),b())).results},listModels:async(t,e)=>{if(A){const{fitmentData:o}=await import("./fitment-data.js");return o.models(t,e)}return(await i(T("/models",{make:t,region:e}),b())).results},listYears:async(t,e,s)=>{if(A){const{fitmentData:l}=await import("./fitment-data.js");return l.years(t,e,s)}return(await i(T("/years",{make:t,model:e,region:s}),b())).results},listModifications:async(t,e,s,o)=>{if(A){const{fitmentData:p}=await import("./fitment-data.js");return p.modifications(t,e,s,o)}return(await i(T("/modifications",{make:t,model:e,year:s,region:o}),b())).results},getStockFitment:async(t,e,s,o,l)=>{if(A){const{fitmentData:p}=await import("./fitment-data.js");return p.stockFitment(t,e,s,o,l)}return i(T("/stock-fitment",{make:t,model:e,year:s,modification:o,region:l}),b())}},pe={listWheels:async t=>{const e=await X("products.listWheels",async s=>await f(It(t,s)));return J(g(e))},listCatalog:async(t,e)=>{if(t.length===0)throw new Error("products.listCatalog() needs at least one kind. An empty list would omit `kind`, which the contract reads as `alloy-wheel` — so the call would silently return the wheel catalog instead of nothing.");const s=await X("products.listCatalog",async o=>await f(Nt(t,e,o)),kt);return Jt(g(s))},getWheel:async t=>L(g(await i(await f(d(`/wheels/${t}`)),await u()))),getTyre:async t=>g(await i(await f(d(`/tyres/${t}`)),await u())),listBundles:async()=>{try{return await i(await f(d("/bundles")),await u())}catch{return[]}},getBundle:async t=>i(await f(d(`/bundles/${t}`)),await u()),listGalleryBuilds:async(t={})=>{const{process:e=null,wheelSlug:s=null}=t;if(typeof window>"u"){const{listGalleryBuilds:o}=await import("./gallery-builds-data.js");return g(o(e,s))}try{const o=new URLSearchParams;e&&o.set("process",e),s&&o.set("wheelSlug",s);const l=o.toString(),p=await i(`/api/v1/gallery-builds${l?`?${l}`:""}`,b());return g(p.results)}catch(o){return console.warn("[products.listGalleryBuilds] product API unavailable, returning []",o),[]}},getSite:async()=>i(await f(d("/site")),await u()),getSiteBySlug:async t=>i(`${d("/site")}?${new URLSearchParams({site:t})}`,typeof window>"u"?await u():void 0),listPages:async()=>g(await i(await f(d("/pages")),await u())),listPopups:async()=>i(await f(d("/popups")),await u()),listProductTemplates:async()=>{try{return await i(await f(d("/product-templates")),await u())}catch(t){return console.warn("[products.listProductTemplates] unavailable, returning []",t),[]}},listDynamicPages:async t=>{const e=t?`?recordType=${encodeURIComponent(t)}`:"";try{return await i(await f(`${d("/dynamic-pages")}${e}`),await u())}catch(s){if(s instanceof m&&s.status===404)return[];throw s}},getRecord:async(t,e)=>{try{return await i(await f(d(`/records/${encodeURIComponent(t)}/${encodeURIComponent(e)}`)),await u())}catch(s){if(s instanceof m&&s.status===404)return null;throw s}},listRecordKeys:async t=>{try{const e=await i(await f(d(`/records/${encodeURIComponent(t)}`)),await u({cache:"no-store"}));return Array.isArray(e?.keys)?e.keys.filter(s=>typeof s=="string"&&s!==""):[]}catch(e){if(e instanceof m&&e.status===404)return[];throw e}},listProductTypeChoices:async()=>{try{return await i(await f(d("/product-type-choices")),await u())}catch(t){return console.warn("[products.listProductTypeChoices] unavailable, returning []",t),[]}},listFieldUsage:async()=>{try{return await i(await f(d("/field-usage")),await u())}catch(t){return console.warn("[products.listFieldUsage] unavailable, returning []",t),[]}},getPage:async(t,e={})=>{const s=e.record?`?record=${encodeURIComponent(e.record)}`:"",[o,l]=await v(d(`/pages/${t}`)+s,e.revalidate!==void 0?{next:{revalidate:e.revalidate}}:void 0);return g(await i(o,l))},listBlogPosts:async(t={})=>{const e=t.category?`?category=${encodeURIComponent(t.category)}`:"";try{return(await i(d("/blog-posts")+e,await u())).map(o=>({...o,coverImage:N(o.coverImage)??""}))}catch(s){return console.warn("[products.listBlogPosts] blog API unavailable, returning []",s),[]}},getBlogPost:async t=>{const e=await i(d(`/blog-posts/${t}`),await u());return{...e,coverImage:N(e.coverImage)??""}},createOrder:async t=>i(d("/orders"),await u({method:"POST",body:JSON.stringify(t)})),createOrderAuthed:async t=>h(d("/orders"),await u({method:"POST",body:JSON.stringify(t)})),lookupOrder:async t=>i(d("/orders/lookup"),await u({method:"POST",body:JSON.stringify(t)})),createPaymentIntent:async t=>i(d("/payments/intent"),await u({method:"POST",body:JSON.stringify(t)})),createPaypalOrder:async t=>i(d("/payments/paypal/order"),await u({method:"POST",body:JSON.stringify(t)})),capturePaypalOrder:async t=>i(d("/payments/paypal/capture"),await u({method:"POST",body:JSON.stringify(t)})),createAfterpayCheckout:async t=>i(d("/payments/afterpay/checkout"),await u({method:"POST",body:JSON.stringify(t)})),captureAfterpayPayment:async t=>i(d("/payments/afterpay/capture"),await u({method:"POST",body:JSON.stringify(t)})),chargeSquare:async t=>i(d("/payments/square/charge"),await u({method:"POST",body:JSON.stringify(t)})),createGocardlessBillingRequest:async t=>i(d("/payments/gocardless/billing-request"),await u({method:"POST",body:JSON.stringify(t)})),completeGocardlessPayment:async t=>i(d("/payments/gocardless/complete"),await u({method:"POST",body:JSON.stringify(t)})),createZipCheckout:async t=>i(d("/payments/zip/checkout"),await u({method:"POST",body:JSON.stringify(t)})),captureZipPayment:async t=>i(d("/payments/zip/capture"),await u({method:"POST",body:JSON.stringify(t)})),createKlarnaCheckout:async t=>i(d("/payments/klarna/checkout"),await u({method:"POST",body:JSON.stringify(t)})),captureKlarnaPayment:async t=>i(d("/payments/klarna/capture"),await u({method:"POST",body:JSON.stringify(t)})),createStockAlert:async t=>i(d("/stock-alerts"),await u({method:"POST",body:JSON.stringify(t)})),createPreOrderIntent:async t=>i(d("/pre-order-intents"),await u({method:"POST",body:JSON.stringify(t)})),createNewsletterSubscription:async t=>i(d("/newsletter-subscriptions"),await u({method:"POST",body:JSON.stringify(t)})),unsubscribeNewsletter:async t=>i(d("/newsletter-unsubscribe"),await u({method:"POST",body:JSON.stringify(t)})),captureCart:async t=>i(d("/carts"),await u({method:"POST",body:JSON.stringify(t)})),restoreCart:async t=>i(d("/carts/restore"),await u({method:"POST",body:JSON.stringify(t)})),unsubscribeCartReminders:async t=>i(d("/carts/unsubscribe"),await u({method:"POST",body:JSON.stringify(t)})),listReviews:async(t={})=>{const e=new URLSearchParams;t.limit&&e.set("limit",String(t.limit)),t.designCode&&e.set("designCode",t.designCode);const s=d("/reviews"),o=e.toString();try{return await i(await f(o?`${s}?${o}`:s),await u())}catch(l){return console.warn("[products.listReviews] product API unavailable, returning []",l),[]}},submitReview:async t=>i(d("/reviews"),await u({method:"POST",body:JSON.stringify(t)})),getForm:async t=>i(d(`/forms/${encodeURIComponent(t)}`),await u()),submitForm:async(t,e)=>i(d(`/forms/${encodeURIComponent(t)}/submissions`),await u({method:"POST",body:JSON.stringify(e)})),listShippingMethods:async()=>{try{return await i(d("/shipping-methods"),await u())}catch(t){return console.warn("[products.listShippingMethods] product API unavailable, returning []",t),[]}},listCountrySubdivisions:async t=>{try{return await i(d(`/countries/${encodeURIComponent(t)}/subdivisions`),await u())}catch(e){return console.warn("[products.listCountrySubdivisions] unavailable, returning []",e),[]}},quoteCart:async t=>{const e=d("/cart/quote"),s=await u({method:"POST",body:JSON.stringify(t)});return t.couponCode?(await G(e,s)).data:i(e,s)},validateCoupon:async t=>{const{data:e,asShopper:s}=await G(d("/coupons/validate"),await u({method:"POST",body:JSON.stringify(t)}));return{...e,askedAsShopper:s}},getHeaderSettings:async()=>{const t=D({method:"GET"}),e=await i(...await v(d("/header-settings"),{signal:t})),s=N(e.logoUrl);let o=null,l=null;if(s&&Rt(s)){const p=await Tt(s,t);p&&(o=p.reversed,l=p.inkIsDark)}return{...e,logoUrl:s,logoReversed:o,logoInkIsDark:l}},getThemeSettings:async()=>i(...await v(d("/theme-settings"))),getChatSettings:async()=>i(await f(d("/chat-settings")),await u())},ye={listServices:async()=>{try{return await i(d("/bookings/services"),await u())}catch(t){return console.warn("[bookings.listServices] API unavailable, returning []",t),{results:[],currency:"USD"}}},getAvailability:async(t,e)=>i(d(`/bookings/availability?service=${encodeURIComponent(t)}&date=${e}`),await u()),create:async t=>i(d("/bookings"),await u({method:"POST",body:JSON.stringify(t)})),get:async t=>i(d(`/bookings/manage/${encodeURIComponent(t)}`),await u()),cancel:async t=>i(d(`/bookings/manage/${encodeURIComponent(t)}/cancel`),await u({method:"POST"})),createPaymentIntent:async t=>i(d("/bookings/payments/intent"),await u({method:"POST",body:JSON.stringify({manageToken:t})}))};class Gt extends Error{slug;count;constructor(e,s){super(`Slug "${e}" exists on ${s} websites; a site is required to pick one.`),this.slug=e,this.count=s,this.name="AmbiguousPageSlugError"}}const $=(t,e,s)=>{const o=new URLSearchParams({...e?{site:e}:{},...s?{draft:"1"}:{}}).toString();return`/api/storefront/${t}/${o?`?${o}`:""}`},R=t=>`/api/storefront/sites/${encodeURIComponent(t)}/`,Wt=t=>`${R(t)}currencies/`,jt="/api/storefront/media/ingest/";class zt extends Error{constructor(){super("This editor is not connected to a website, so an upload has nowhere to go. Open the page from the website the file should belong to, then try again."),this.name="MediaUploadDestinationError"}}function Kt(){const t=Et();if(!t)throw new zt;return`${jt}?${new URLSearchParams({site:t})}`}const Vt="X-Puck-Media-Manifest",Y=ct.contentHash,_={"X-Media-Manifest":Y,[Vt]:Y},he=Q({});function Q(t){return(e,s={})=>{const o=St(),l=t.headers||o?{...o?{"Accept-Language":o}:{},...t.headers,...s.headers}:void 0;return i(e,{...s,...t.baseUrl!==void 0?{baseUrl:t.baseUrl}:{},...l?{headers:l}:{},audience:t.audience??mt()})}}function Xt(t={}){const e=Q(t),s=t.siteDrafts===!0,o=a=>$("header-settings",a,s),l=a=>$("theme-settings",a,s),p=a=>$("chat-settings",a,s),w=a=>$("social-settings",a,s);return{findPageBySlug:async(a,r,n)=>{const c=new URLSearchParams({slug:a});n&&c.set("site",n);const y=await e(`/api/storefront/pages/?${c.toString()}`,{token:r}),S=Array.isArray(y)?y:y.results??[];if(!n&&S.length>1)throw new Gt(a,S.length);return S[0]??null},getPageById:(a,r)=>e(`/api/storefront/pages/${a}/`,{token:r}),saveLayout:(a,r,n,c,y)=>e(`/api/storefront/pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r,expected_updated_at:c,...y?{client_id:y}:{}}),token:n}),duplicatePage:(a,r,n)=>e(`/api/storefront/pages/${a}/duplicate/`,{method:"POST",body:JSON.stringify({title:r.title,slug:r.slug}),token:n}),geocode:(a,r,n)=>e(`/api/storefront/geocode/?${new URLSearchParams(n?{q:a,country:n}:{q:a})}`,{token:r}),listBlockSources:a=>e("/api/storefront/block-sources/",{token:a}),listRecordTypes:a=>e("/api/storefront/record-types/",{token:a}),createPagePreviewLink:(a,r)=>e(`/api/storefront/pages/${a}/preview-link/`,{method:"POST",token:r}),claimPageEditLock:(a,r,n,c=!1)=>e(`/api/storefront/pages/${a}/edit-lock/`,{method:"POST",body:JSON.stringify({client_id:n,takeover:c}),token:r}),releasePageEditLock:(a,r)=>e(`/api/storefront/pages/${a}/edit-lock/`,{method:"DELETE",token:r}),createTemplate:(a,r,n)=>e("/api/storefront/page-templates/",{method:"POST",body:JSON.stringify({name:a,layout:r}),headers:_,token:n}),getTemplate:(a,r)=>e(`/api/storefront/page-templates/${a}/`,{token:r}),saveTemplateLayout:(a,r,n)=>e(`/api/storefront/page-templates/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r}),headers:_,token:n}),listTemplatePages:async(a,r)=>{const n=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(a)}`,{token:r});return Array.isArray(n)?n:n.results??[]},findTemplatePageBySlug:async(a,r,n)=>{const c=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(a)}&slug=${encodeURIComponent(r)}`,{token:n});return(Array.isArray(c)?c:c.results??[])[0]??null},createTemplatePage:(a,r,n)=>e("/api/storefront/template-pages/",{method:"POST",body:JSON.stringify({template:a,...r}),headers:_,token:n}),saveTemplatePageLayout:(a,r,n)=>e(`/api/storefront/template-pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r}),headers:_,token:n}),deleteTemplatePage:(a,r,n)=>e(`/api/storefront/template-pages/${a}/`,{method:"DELETE",token:r,...n?.keepalive?{keepalive:!0}:{}}),listPages:async(a,r)=>{const n=new URLSearchParams({no_page:"true"});r&&n.set("site",r);const c=await e(`/api/storefront/pages/?${n.toString()}`,{token:a});return Array.isArray(c)?c:c.results??[]},createPage:(a,r,n,c)=>e("/api/storefront/pages/",{method:"POST",body:JSON.stringify({title:a,slug:r,layout:n}),token:c}),deletePage:(a,r)=>e(`/api/storefront/pages/${a}/`,{method:"DELETE",token:r}),getHeaderSettings:(a,r)=>e(o(r),{token:a}),listMenus:async(a,r)=>{const n=new URLSearchParams({no_page:"true"});r&&n.set("site",r);const c=await e(`/api/storefront/menus/?${n}`,{token:a});return Array.isArray(c)?c:c.results??[]},listBlogPosts:async(a,r={})=>{const n=new URLSearchParams({no_page:"true"});r.visibleOnly&&n.set("is_visible","true"),r.siteId&&n.set("site",r.siteId);const c=await e(`/api/storefront/blog-posts/?${n.toString()}`,{token:a});return Array.isArray(c)?c:c.results??[]},listFieldUsage:async(a,r)=>{const n=await e(`/api/storefront/field-usage/?site=${encodeURIComponent(r)}`,{token:a});return Array.isArray(n?.entries)?n.entries:[]},listCategories:async(a,r={})=>{const n=new URLSearchParams({no_page:"true"});r.visibleOnly&&n.set("is_visible","true"),r.siteId&&n.set("site",r.siteId);const c=await e(`/api/storefront/categories/?${n.toString()}`,{token:a});return[...Array.isArray(c)?c:c.results??[]].sort((S,E)=>S.sort_order-E.sort_order||S.name.localeCompare(E.name))},listForms:async(a,r={})=>{const n=new URLSearchParams({no_page:"true"});r.siteId&&n.set("site",r.siteId);const c=await e(`/api/storefront/forms/?${n.toString()}`,{token:a});return[...Array.isArray(c)?c:c.results??[]].sort((S,E)=>S.title.localeCompare(E.title))},listWheelSummaries:async(a,r={})=>{const n=new URLSearchParams;r.siteId&&n.set("site",r.siteId);const c=n.toString(),y=await e(`/api/storefront/wheel-curations/summaries/${c?`?${c}`:""}`,{token:a});return g(y)},listProducts:async(a,r={})=>{const n=new URLSearchParams;r.kinds?.length&&n.set("kind",r.kinds.join(",")),r.siteId&&n.set("site",r.siteId);const c=n.toString(),y=await e(`/api/storefront/products/${c?`?${c}`:""}`,{token:a});return g(y)},getWheelDetail:async(a,r,n={})=>{const c=new URLSearchParams({slug:r});return n.siteId&&c.set("site",n.siteId),L(g(await e(`/api/storefront/wheel-curations/detail/?${c.toString()}`,{token:a})))},updateHeaderSettings:(a,r,n)=>e(o(n),{method:"PATCH",body:JSON.stringify(a),token:r}),getSite:(a,r)=>e(R(a),{token:r}),listSites:async a=>{const r=await e("/api/storefront/sites/?no_page=true",{token:a});return Array.isArray(r)?r:r.results??[]},listSiteCurrencies:async(a,r)=>{const n=await e(Wt(a),{token:r});return Array.isArray(n)?n:[]},publishSite:(a,r)=>e(`${R(a)}publish/`,{method:"POST",token:r}),getSiteLiveState:(a,r)=>e(`${R(a)}live-state/`,{token:r}),updateSite:(a,r,n)=>e(R(a),{method:"PATCH",body:JSON.stringify(r),token:n}),getThemeSettings:(a,r)=>e(l(r),{token:a}),updateThemeSettings:(a,r,n)=>e(l(n),{method:"PATCH",body:JSON.stringify(a),token:r}),getChatSettings:(a,r)=>e(p(r),{token:a}),updateChatSettings:(a,r,n)=>e(p(n),{method:"PATCH",body:JSON.stringify(a),token:r}),getSocialSettings:(a,r)=>e(w(r),{token:a}),updateSocialSettings:(a,r,n)=>e(w(n),{method:"PATCH",body:JSON.stringify(a),token:r}),uploadHeaderLogo:(a,r,n)=>{const c=new FormData;return c.append("logo",a),e(o(n),{method:"PATCH",body:c,token:r})},clearHeaderLogo:(a,r)=>e(o(r),{method:"PATCH",body:JSON.stringify({logo:null}),token:a}),setHeaderLogoFromAsset:(a,r,n)=>e(o(n),{method:"PATCH",body:JSON.stringify({logo_asset_id:a}),token:r}),uploadMedia:async(a,r)=>{const n=new FormData;return n.append("file",a),e(Kt(),{method:"POST",body:n,token:r})},listMedia:async(a,r)=>{const n=new URLSearchParams({no_page:"true"});r&&n.set("kind",r);const c=await e(`/api/storefront/media-assets/?${n.toString()}`,{token:a});return Array.isArray(c)?c:c.results??[]}}}const fe=Xt({siteDrafts:!0});export{ut as API_URL,Gt as AmbiguousPageSlugError,m as ApiError,ht as BROWSER_READ_TIMEOUT_MS,pt as EFFICIENT_CLIENT_CLOSED_MESSAGE,zt as MediaUploadDestinationError,Mt as PREVIEW_PARAM,we as PRODUCT_API_BASE,yt as SERVER_READ_TIMEOUT_MS,U as SERVER_UNREACHABLE_MESSAGE,I as STATUS_NETWORK_ERROR,he as adminFetch,Ot as api,i as apiFetch,C as appendSiteQuery,ye as bookings,Xt as createStorefrontAdmin,D as defaultRequestDeadline,Kt as editorMediaUploadPath,mt as editorPortalAudience,St as editorRequestLanguage,le as fitment,pe as products,ft as readDeadlineMs,Dt as resolveClientIp,g as resolveMediaUrls,Ft as resolvePreviewToken,Z as resolveSiteHost,Lt as resolveSiteHostSource,xt as resolveSiteSlug,oe as setEditorLanguage,ne as setEditorPortalAudience,fe as storefrontAdmin};
1
+ import{PREVIEW_TOKEN_HEADER as tt,SITE_HOST_HEADER as et,SITE_SLUG_HEADER as rt}from"../site-headers.js";import{PRODUCT_API_BASE as at,PRODUCT_BACKEND_URL as k}from"./origins.js";import{backendHopHeaders as st,clientIpFromForwardedFor as nt,FORWARDED_FOR_HEADER as ot,hopCachingOf as it}from"../forwarded-for.js";import ct from"efficient-web-builder/format/lib/document/media-manifest.json";import{auth as P}from"../auth.js";import{efficientClientOpen as dt}from"efficient-easel/screen/lib/session";import{listableWheelSummaries as J}from"../wheels/listable-wheels.js";import{dropRenderlessFinishes as L}from"../wheels/renderable-finishes.js";const ut=process.env.NEXT_PUBLIC_API_URL??"http://localhost:8000";class m extends Error{status;data;constructor(e,s,o){super(s),this.status=e,this.data=o}}const U="Unable to reach the server. This could be a problem with your internet connection, or the server may be undergoing maintenance or an upgrade. Please try again shortly.",lt=new Set([502,503,504]),I=0,pt="This editor runs on its host's own backend, which does not serve this request.",yt=5e3,ht=15e3,ft=()=>typeof window>"u"?yt:ht;function D(t){const e=(t.method??"GET").toUpperCase();if(!(t.body!=null||e!=="GET"&&e!=="HEAD")&&!(t.audience!=null&&t.audience!=="shop")&&typeof AbortSignal?.timeout=="function")return AbortSignal.timeout(ft())}const x=t=>t instanceof Error&&t.name==="TimeoutError",H=(t,e)=>lt.has(t)?U:e,gt=["admin","venue"];let M="admin";function ne(t){M=gt.includes(t)?t:"admin"}function mt(){return M}const wt=/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/;let F=null;function oe(t){F=t&&wt.test(t)?t:null}function St(){return F}function Pt(t){if(typeof window>"u"||!t.startsWith("/api/v1/"))return t;const e=j();return!e||/[?&]site=/.test(t)?t:E(t,`site=${encodeURIComponent(e)}`)}async function i(t,e={}){const{token:s,baseUrl:o,headers:l,audience:p,...w}=e;if(typeof window<"u"&&!dt())throw new m(I,pt,null);if(typeof window>"u"&&o===void 0)throw new Error(`apiFetch(${JSON.stringify(t)}) ran on the server without an explicit baseUrl. The API_URL default it would inherit is browser-only (the prod image bakes NEXT_PUBLIC_API_URL="" for same-origin use, which a Node fetch cannot resolve). Pass a base explicitly: \`await backendOpts()\` (or baseUrl: PRODUCT_FETCH_BASE) for product reads, or the server-only PRODUCT_BACKEND_URL env for other backend surfaces.`);const a=typeof FormData<"u"&&w.body instanceof FormData;let r;try{r=await fetch(`${o??ut}${Pt(t)}`,{...w,headers:{...a?{}:{"Content-Type":"application/json"},...s?{Authorization:`Bearer ${s}`}:{},...p===null?{}:{"X-Portal-Audience":p??"shop"},...l},signal:w.signal??D({...w,audience:p})})}catch(y){throw y instanceof TypeError||x(y)?new m(I,U,null):y}let n;try{n=await r.text()}catch(y){throw x(y)?new m(I,U,null):y}let c=null;if(n)try{c=JSON.parse(n)}catch{throw new m(r.status,r.ok?"Expected JSON but received a non-JSON response":H(r.status,r.statusText),n)}if(!r.ok){const y=(c&&typeof c=="object"&&"detail"in c&&typeof c.detail=="string"?c.detail:null)??H(r.status,r.statusText);throw new m(r.status,y,c)}return c}let O=null;async function B(){return O||(O=bt().finally(()=>{O=null}),O)}async function bt(){const t=P.takeLegacyRefresh(),e=await Ot.refresh(t??void 0);return P.setTokens(e.access),e.access}async function q(){return P.getAccess()??B()}async function h(t,e={}){let s;try{s=await q()}catch{throw P.clear(),new m(401,"Not signed in",null)}try{return await i(t,{...e,token:s})}catch(o){if(!(o instanceof m)||o.status!==401)throw o;try{const l=await B();return await i(t,{...e,token:l})}catch{throw P.clear(),o}}}async function G(t,e={}){if(P.getAccess())try{return{data:await h(t,e),asShopper:!0}}catch(s){if(!(s instanceof m)||s.status!==401)throw s}return{data:await i(t,e),asShopper:!1}}async function W(){const t=await h("/api/auth/me/");if(t.portal!=="shop")throw P.clear(),new m(403,"This session is not valid for this shop.",null);return t}const Ot={login:(t,e)=>i("/api/auth/login/",{method:"POST",body:JSON.stringify({email:t,password:e,portal:"shop"}),credentials:"include"}),refresh:t=>i("/api/auth/refresh/",{method:"POST",body:JSON.stringify(t?{refresh:t,portal:"shop"}:{portal:"shop"}),credentials:"include"}),logout:async()=>{P.clear();try{await i("/api/auth/logout/",{method:"POST",body:JSON.stringify({portal:"shop"}),credentials:"include"})}catch{}},restoreSession:async()=>{const t=await q();return await W(),t},me:W,updateMe:t=>h("/api/auth/me/",{method:"PATCH",body:JSON.stringify(t)}),changePassword:(t,e)=>h("/api/auth/me/",{method:"PATCH",body:JSON.stringify({password:e,old_password:t})}),changeEmail:(t,e)=>h("/api/shop-portal/change-email/",{method:"POST",body:JSON.stringify({new_email:t,current_password:e})}),myProfile:()=>h("/api/shop-portal/profile/"),updateMyProfile:t=>h("/api/shop-portal/profile/",{method:"PATCH",body:JSON.stringify(t)}),myAddresses:()=>h("/api/shop-portal/delivery-locations/"),createAddress:t=>h("/api/shop-portal/delivery-locations/",{method:"POST",body:JSON.stringify(t)}),updateAddress:(t,e)=>h(`/api/shop-portal/delivery-locations/${t}/`,{method:"PATCH",body:JSON.stringify(e)}),deleteAddress:t=>h(`/api/shop-portal/delivery-locations/${t}/`,{method:"DELETE"}),passwordResetRequest:t=>i("/api/auth/password-reset/",{method:"POST",body:JSON.stringify({email:t})}),passwordResetConfirm:(t,e,s)=>i("/api/auth/password-reset/confirm/",{method:"POST",body:JSON.stringify({uid:t,token:e,new_password:s})}),brands:()=>h("/api/products/brands/"),myOrders:()=>h("/api/shop-portal/orders/").then(t=>t.results),myOrder:t=>h(`/api/shop-portal/orders/${t}/`),cancelOrder:t=>h(`/api/shop-portal/orders/${t}/cancel/`,{method:"POST"}),myReturns:t=>h(`/api/shop-portal/returns/${t?`?order=${encodeURIComponent(t)}`:""}`).then(e=>e.results),createReturn:t=>h("/api/shop-portal/returns/",{method:"POST",body:JSON.stringify(t)}),withdrawReturn:t=>h(`/api/shop-portal/returns/${t}/cancel/`,{method:"POST"}),uploadReturnPhoto:(t,e)=>{const s=new FormData;return s.append("claim_item",t),s.append("file",e),s.append("media_type",e.type.startsWith("video/")?"video":"image"),h("/api/shop-portal/return-media/",{method:"POST",body:s})}};import{media as At,absolutizeApiUrl as N}from"efficient-web-builder/render/lib/media";import{analyzeLogoSvg as Tt,isSvgUrl as Rt}from"efficient-web-builder/format/lib/logo/reverse-svg";import{getEditorSiteId as Et}from"efficient-web-builder/render/lib/editor-site";import{shopRouteBase as Ct,webRuntimeSiteSlug as j}from"efficient-web-builder/format/lib/web-runtime";function g(t){if(typeof t=="string")return t.startsWith("/media/")?At(t):t;if(Array.isArray(t))return t.map(g);if(t&&typeof t=="object"){const e={};for(const[s,o]of Object.entries(t))e[s]=s==="captions"&&o&&typeof o=="object"&&!Array.isArray(o)?Object.fromEntries(Object.entries(o).map(([l,p])=>[g(l),p])):g(o);return e}return t}import{PRODUCT_API_BASE as we}from"./origins.js";const z=typeof window>"u"&&k!=="",$t=z?k:at,_t=Ct,b=()=>({baseUrl:_t(),audience:null});function d(t,e){const s=e?`?process=${encodeURIComponent(e)}`:"";return`/api/v1${t}${s}`}const Ut=100,K=50;function V(t,e,s){const o=new URLSearchParams;for(const[l,p]of Object.entries(e))p!=null&&p!==""&&o.set(l,String(p));return o.set("pageSize",String(Ut)),s&&o.set("cursor",s),`/api/v1${t}?${o.toString()}`}function It(t,e){return V("/wheels",{process:t},e)}function Nt(t,e,s){return V("/products",{kind:t.join(","),make:e?.make,model:e?.model,year:e?.year,modification:e?.modification},s)}function vt(t){if(!t)return null;try{return new URL(t,"http://cursor.invalid").searchParams.get("cursor")}catch{return null}}async function X(t,e,s=()=>!1){const o=[];let l=null;try{for(let p=0;p<K;p++){const w=await i(await e(l),await u());if(o.push(...w.results),l=vt(w.next),!l)break}l&&console.warn(`[${t}] stopped at ${K} pages (${o.length} rows); catalog may be truncated`)}catch(p){if(s(p))throw p;console.warn(`[${t}] product API unavailable, returning []`,p)}return o}const kt=t=>t instanceof m&&t.status===400;function Jt(t){return t.flatMap(e=>e.kind==="alloy-wheel"?J([e]):[e])}async function Z(){return(await Lt()).host}async function Lt(){try{const{headers:t}=await import("next/headers"),e=await t(),s=p=>p?.split(",")[0]?.split(":")[0]?.trim().toLowerCase()||null,o=s(e.get(et)??e.get("x-forwarded-host")??e.get("host")),l=s(e.get("host"));return{host:o,matchesRequestHost:o!==null&&o===l}}catch{return{host:null,matchesRequestHost:!1}}}async function Dt(){try{const{headers:t}=await import("next/headers");return nt((await t()).get(ot))}catch{return null}}async function xt(){try{const{headers:t}=await import("next/headers");return(await t()).get(rt)||null}catch{return null}}async function Ht(){const t=await xt();if(t)return`site=${encodeURIComponent(t)}`;const e=await Z();return e?`host=${encodeURIComponent(e)}`:""}async function f(t){if(typeof window<"u"){const e=j();return e?E(t,`site=${encodeURIComponent(e)}`):t}return E(t,await Ht())}function E(t,e){return e?`${t}${t.includes("?")?"&":"?"}${e}`:t}const Mt="preview";async function Ft(){if(typeof window<"u")return null;try{const{headers:t}=await import("next/headers");return(await t()).get(tt)}catch{return null}}async function Bt(){try{const{headers:t}=await import("next/headers");return(await t()).get("user-agent")}catch{return null}}async function v(t,e){const s=await Ft();if(s===null)return[await f(t),await u(e)];const o=E(await f(t),`${Mt}=${encodeURIComponent(s)}`),{next:l,cache:p,...w}=e??{},a=await u({...w,cache:"no-store"}),r=await Bt();return r&&(a.headers={...a.headers,"user-agent":r}),[o,a]}async function qt(t){if(!z)return;const[e,s]=await Promise.all([Z(),Dt()]),o=st(e,s,t);return Object.keys(o).length>0?o:void 0}async function u(t){const e=await qt(it(t)),s={baseUrl:$t,...t};return e&&(s.headers={...e,...t?.headers}),s}const A=typeof window>"u";function T(t,e){const s=new URLSearchParams;for(const[l,p]of Object.entries(e))p!==void 0&&p!==""&&s.set(l,String(p));const o=s.toString();return`/api/v1/fitment${t}${o?`?${o}`:""}`}const le={listMakes:async t=>{if(A){const{fitmentData:s}=await import("./fitment-data.js");return s.makes(t)}return(await i(T("/makes",{region:t}),b())).results},listModels:async(t,e)=>{if(A){const{fitmentData:o}=await import("./fitment-data.js");return o.models(t,e)}return(await i(T("/models",{make:t,region:e}),b())).results},listYears:async(t,e,s)=>{if(A){const{fitmentData:l}=await import("./fitment-data.js");return l.years(t,e,s)}return(await i(T("/years",{make:t,model:e,region:s}),b())).results},listModifications:async(t,e,s,o)=>{if(A){const{fitmentData:p}=await import("./fitment-data.js");return p.modifications(t,e,s,o)}return(await i(T("/modifications",{make:t,model:e,year:s,region:o}),b())).results},getStockFitment:async(t,e,s,o,l)=>{if(A){const{fitmentData:p}=await import("./fitment-data.js");return p.stockFitment(t,e,s,o,l)}return i(T("/stock-fitment",{make:t,model:e,year:s,modification:o,region:l}),b())}},pe={listWheels:async t=>{const e=await X("products.listWheels",async s=>await f(It(t,s)));return J(g(e))},listCatalog:async(t,e)=>{if(t.length===0)throw new Error("products.listCatalog() needs at least one kind. An empty list would omit `kind`, which the contract reads as `alloy-wheel` — so the call would silently return the wheel catalog instead of nothing.");const s=await X("products.listCatalog",async o=>await f(Nt(t,e,o)),kt);return Jt(g(s))},getWheel:async t=>L(g(await i(await f(d(`/wheels/${t}`)),await u()))),getTyre:async t=>g(await i(await f(d(`/tyres/${t}`)),await u())),listBundles:async()=>{try{return await i(await f(d("/bundles")),await u())}catch{return[]}},getBundle:async t=>i(await f(d(`/bundles/${t}`)),await u()),listGalleryBuilds:async(t={})=>{const{process:e=null,wheelSlug:s=null}=t;if(typeof window>"u"){const{listGalleryBuilds:o}=await import("./gallery-builds-data.js");return g(o(e,s))}try{const o=new URLSearchParams;e&&o.set("process",e),s&&o.set("wheelSlug",s);const l=o.toString(),p=await i(`/api/v1/gallery-builds${l?`?${l}`:""}`,b());return g(p.results)}catch(o){return console.warn("[products.listGalleryBuilds] product API unavailable, returning []",o),[]}},getSite:async()=>i(await f(d("/site")),await u()),getSiteBySlug:async t=>i(`${d("/site")}?${new URLSearchParams({site:t})}`,typeof window>"u"?await u():void 0),listPages:async()=>g(await i(await f(d("/pages")),await u())),listPopups:async()=>i(await f(d("/popups")),await u()),listProductTemplates:async()=>{try{return await i(await f(d("/product-templates")),await u())}catch(t){return console.warn("[products.listProductTemplates] unavailable, returning []",t),[]}},listDynamicPages:async t=>{const e=t?`?recordType=${encodeURIComponent(t)}`:"";try{return await i(await f(`${d("/dynamic-pages")}${e}`),await u())}catch(s){if(s instanceof m&&s.status===404)return[];throw s}},getRecord:async(t,e)=>{try{return await i(await f(d(`/records/${encodeURIComponent(t)}/${encodeURIComponent(e)}`)),await u())}catch(s){if(s instanceof m&&s.status===404)return null;throw s}},listRecordKeys:async t=>{try{const e=await i(await f(d(`/records/${encodeURIComponent(t)}`)),await u({cache:"no-store"}));return Array.isArray(e?.keys)?e.keys.filter(s=>typeof s=="string"&&s!==""):[]}catch(e){if(e instanceof m&&e.status===404)return[];throw e}},listProductTypeChoices:async()=>{try{return await i(await f(d("/product-type-choices")),await u())}catch(t){return console.warn("[products.listProductTypeChoices] unavailable, returning []",t),[]}},listFieldUsage:async()=>{try{return await i(await f(d("/field-usage")),await u())}catch(t){return console.warn("[products.listFieldUsage] unavailable, returning []",t),[]}},getPage:async(t,e={})=>{const s=e.record?`?record=${encodeURIComponent(e.record)}`:"",[o,l]=await v(d(`/pages/${t}`)+s,e.revalidate!==void 0?{next:{revalidate:e.revalidate}}:void 0);return g(await i(o,l))},listBlogPosts:async(t={})=>{const e=t.category?`?category=${encodeURIComponent(t.category)}`:"";try{return(await i(d("/blog-posts")+e,await u())).map(o=>({...o,coverImage:N(o.coverImage)??""}))}catch(s){return console.warn("[products.listBlogPosts] blog API unavailable, returning []",s),[]}},getBlogPost:async t=>{const e=await i(d(`/blog-posts/${t}`),await u());return{...e,coverImage:N(e.coverImage)??""}},createOrder:async t=>i(d("/orders"),await u({method:"POST",body:JSON.stringify(t)})),createOrderAuthed:async t=>h(d("/orders"),await u({method:"POST",body:JSON.stringify(t)})),lookupOrder:async t=>i(d("/orders/lookup"),await u({method:"POST",body:JSON.stringify(t)})),createPaymentIntent:async t=>i(d("/payments/intent"),await u({method:"POST",body:JSON.stringify(t)})),createPaypalOrder:async t=>i(d("/payments/paypal/order"),await u({method:"POST",body:JSON.stringify(t)})),capturePaypalOrder:async t=>i(d("/payments/paypal/capture"),await u({method:"POST",body:JSON.stringify(t)})),createAfterpayCheckout:async t=>i(d("/payments/afterpay/checkout"),await u({method:"POST",body:JSON.stringify(t)})),captureAfterpayPayment:async t=>i(d("/payments/afterpay/capture"),await u({method:"POST",body:JSON.stringify(t)})),chargeSquare:async t=>i(d("/payments/square/charge"),await u({method:"POST",body:JSON.stringify(t)})),createGocardlessBillingRequest:async t=>i(d("/payments/gocardless/billing-request"),await u({method:"POST",body:JSON.stringify(t)})),completeGocardlessPayment:async t=>i(d("/payments/gocardless/complete"),await u({method:"POST",body:JSON.stringify(t)})),createZipCheckout:async t=>i(d("/payments/zip/checkout"),await u({method:"POST",body:JSON.stringify(t)})),captureZipPayment:async t=>i(d("/payments/zip/capture"),await u({method:"POST",body:JSON.stringify(t)})),createKlarnaCheckout:async t=>i(d("/payments/klarna/checkout"),await u({method:"POST",body:JSON.stringify(t)})),captureKlarnaPayment:async t=>i(d("/payments/klarna/capture"),await u({method:"POST",body:JSON.stringify(t)})),createStockAlert:async t=>i(d("/stock-alerts"),await u({method:"POST",body:JSON.stringify(t)})),createPreOrderIntent:async t=>i(d("/pre-order-intents"),await u({method:"POST",body:JSON.stringify(t)})),createNewsletterSubscription:async t=>i(d("/newsletter-subscriptions"),await u({method:"POST",body:JSON.stringify(t)})),unsubscribeNewsletter:async t=>i(d("/newsletter-unsubscribe"),await u({method:"POST",body:JSON.stringify(t)})),captureCart:async t=>i(d("/carts"),await u({method:"POST",body:JSON.stringify(t)})),restoreCart:async t=>i(d("/carts/restore"),await u({method:"POST",body:JSON.stringify(t)})),unsubscribeCartReminders:async t=>i(d("/carts/unsubscribe"),await u({method:"POST",body:JSON.stringify(t)})),listReviews:async(t={})=>{const e=new URLSearchParams;t.limit&&e.set("limit",String(t.limit)),t.designCode&&e.set("designCode",t.designCode);const s=d("/reviews"),o=e.toString();try{return await i(await f(o?`${s}?${o}`:s),await u())}catch(l){return console.warn("[products.listReviews] product API unavailable, returning []",l),[]}},submitReview:async t=>i(d("/reviews"),await u({method:"POST",body:JSON.stringify(t)})),getForm:async t=>i(d(`/forms/${encodeURIComponent(t)}`),await u()),submitForm:async(t,e)=>i(d(`/forms/${encodeURIComponent(t)}/submissions`),await u({method:"POST",body:JSON.stringify(e)})),listShippingMethods:async()=>{try{return await i(d("/shipping-methods"),await u())}catch(t){return console.warn("[products.listShippingMethods] product API unavailable, returning []",t),[]}},listCountrySubdivisions:async t=>{try{return await i(d(`/countries/${encodeURIComponent(t)}/subdivisions`),await u())}catch(e){return console.warn("[products.listCountrySubdivisions] unavailable, returning []",e),[]}},quoteCart:async t=>{const e=d("/cart/quote"),s=await u({method:"POST",body:JSON.stringify(t)});return t.couponCode?(await G(e,s)).data:i(e,s)},validateCoupon:async t=>{const{data:e,asShopper:s}=await G(d("/coupons/validate"),await u({method:"POST",body:JSON.stringify(t)}));return{...e,askedAsShopper:s}},getHeaderSettings:async()=>{const t=D({method:"GET"}),e=await i(...await v(d("/header-settings"),{signal:t})),s=N(e.logoUrl);let o=null,l=null;if(s&&Rt(s)){const p=await Tt(s,t);p&&(o=p.reversed,l=p.inkIsDark)}return{...e,logoUrl:s,logoReversed:o,logoInkIsDark:l}},getThemeSettings:async()=>i(...await v(d("/theme-settings"))),getChatSettings:async()=>i(await f(d("/chat-settings")),await u())},ye={listServices:async()=>{try{return await i(d("/bookings/services"),await u())}catch(t){return console.warn("[bookings.listServices] API unavailable, returning []",t),{results:[],currency:"USD"}}},getAvailability:async(t,e)=>i(d(`/bookings/availability?service=${encodeURIComponent(t)}&date=${e}`),await u()),create:async t=>i(d("/bookings"),await u({method:"POST",body:JSON.stringify(t)})),get:async t=>i(d(`/bookings/manage/${encodeURIComponent(t)}`),await u()),cancel:async t=>i(d(`/bookings/manage/${encodeURIComponent(t)}/cancel`),await u({method:"POST"})),createPaymentIntent:async t=>i(d("/bookings/payments/intent"),await u({method:"POST",body:JSON.stringify({manageToken:t})}))};class Gt extends Error{slug;count;constructor(e,s){super(`Slug "${e}" exists on ${s} websites; a site is required to pick one.`),this.slug=e,this.count=s,this.name="AmbiguousPageSlugError"}}const C=(t,e,s)=>{const o=new URLSearchParams({...e?{site:e}:{},...s?{draft:"1"}:{}}).toString();return`/api/storefront/${t}/${o?`?${o}`:""}`},$=t=>`/api/storefront/sites/${encodeURIComponent(t)}/`,Wt=t=>`${$(t)}currencies/`,jt="/api/storefront/media/ingest/";class zt extends Error{constructor(){super("This editor is not connected to a website, so an upload has nowhere to go. Open the page from the website the file should belong to, then try again."),this.name="MediaUploadDestinationError"}}function Kt(){const t=Et();if(!t)throw new zt;return`${jt}?${new URLSearchParams({site:t})}`}const Vt="X-Puck-Media-Manifest",Y=ct.contentHash,_={"X-Media-Manifest":Y,[Vt]:Y},he=Q({});function Q(t){return(e,s={})=>{const o=St(),l=t.headers||o?{...o?{"Accept-Language":o}:{},...t.headers,...s.headers}:void 0;return i(e,{...s,...t.baseUrl!==void 0?{baseUrl:t.baseUrl}:{},...l?{headers:l}:{},audience:t.audience??mt()})}}function Xt(t={}){const e=Q(t),s=t.siteDrafts===!0,o=a=>C("header-settings",a,s),l=a=>C("theme-settings",a,s),p=a=>C("chat-settings",a,s),w=a=>C("social-settings",a,s);return{findPageBySlug:async(a,r,n)=>{const c=new URLSearchParams({slug:a});n&&c.set("site",n);const y=await e(`/api/storefront/pages/?${c.toString()}`,{token:r}),S=Array.isArray(y)?y:y.results??[];if(!n&&S.length>1)throw new Gt(a,S.length);return S[0]??null},getPageById:(a,r)=>e(`/api/storefront/pages/${a}/`,{token:r}),saveLayout:(a,r,n,c,y)=>e(`/api/storefront/pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r,expected_updated_at:c,...y?{client_id:y}:{}}),token:n}),duplicatePage:(a,r,n)=>e(`/api/storefront/pages/${a}/duplicate/`,{method:"POST",body:JSON.stringify({title:r.title,slug:r.slug}),token:n}),geocode:(a,r,n)=>e(`/api/storefront/geocode/?${new URLSearchParams(n?{q:a,country:n}:{q:a})}`,{token:r}),listBlockSources:a=>e("/api/storefront/block-sources/",{token:a}),listRecordTypes:a=>e("/api/storefront/record-types/",{token:a}),createPagePreviewLink:(a,r)=>e(`/api/storefront/pages/${a}/preview-link/`,{method:"POST",token:r}),claimPageEditLock:(a,r,n,c=!1)=>e(`/api/storefront/pages/${a}/edit-lock/`,{method:"POST",body:JSON.stringify({client_id:n,takeover:c}),token:r}),releasePageEditLock:(a,r)=>e(`/api/storefront/pages/${a}/edit-lock/`,{method:"DELETE",token:r}),createTemplate:(a,r,n)=>e("/api/storefront/page-templates/",{method:"POST",body:JSON.stringify({name:a,layout:r}),headers:_,token:n}),getTemplate:(a,r)=>e(`/api/storefront/page-templates/${a}/`,{token:r}),saveTemplateLayout:(a,r,n)=>e(`/api/storefront/page-templates/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r}),headers:_,token:n}),listTemplatePages:async(a,r)=>{const n=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(a)}`,{token:r});return Array.isArray(n)?n:n.results??[]},findTemplatePageBySlug:async(a,r,n)=>{const c=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(a)}&slug=${encodeURIComponent(r)}`,{token:n});return(Array.isArray(c)?c:c.results??[])[0]??null},createTemplatePage:(a,r,n)=>e("/api/storefront/template-pages/",{method:"POST",body:JSON.stringify({template:a,...r}),headers:_,token:n}),saveTemplatePageLayout:(a,r,n)=>e(`/api/storefront/template-pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r}),headers:_,token:n}),deleteTemplatePage:(a,r,n)=>e(`/api/storefront/template-pages/${a}/`,{method:"DELETE",token:r,...n?.keepalive?{keepalive:!0}:{}}),listPages:async(a,r)=>{const n=new URLSearchParams({no_page:"true"});r&&n.set("site",r);const c=await e(`/api/storefront/pages/?${n.toString()}`,{token:a});return Array.isArray(c)?c:c.results??[]},createPage:(a,r,n,c)=>e("/api/storefront/pages/",{method:"POST",body:JSON.stringify({title:a,slug:r,layout:n}),token:c}),deletePage:(a,r)=>e(`/api/storefront/pages/${a}/`,{method:"DELETE",token:r}),getHeaderSettings:(a,r)=>e(o(r),{token:a}),listMenus:async(a,r)=>{const n=new URLSearchParams({no_page:"true"});r&&n.set("site",r);const c=await e(`/api/storefront/menus/?${n}`,{token:a});return Array.isArray(c)?c:c.results??[]},listBlogPosts:async(a,r={})=>{const n=new URLSearchParams({no_page:"true"});r.visibleOnly&&n.set("is_visible","true"),r.siteId&&n.set("site",r.siteId);const c=await e(`/api/storefront/blog-posts/?${n.toString()}`,{token:a});return Array.isArray(c)?c:c.results??[]},listFieldUsage:async(a,r)=>{const n=await e(`/api/storefront/field-usage/?site=${encodeURIComponent(r)}`,{token:a});return Array.isArray(n?.entries)?n.entries:[]},listCategories:async(a,r={})=>{const n=new URLSearchParams({no_page:"true"});r.visibleOnly&&n.set("is_visible","true"),r.siteId&&n.set("site",r.siteId);const c=await e(`/api/storefront/categories/?${n.toString()}`,{token:a});return[...Array.isArray(c)?c:c.results??[]].sort((S,R)=>S.sort_order-R.sort_order||S.name.localeCompare(R.name))},listForms:async(a,r={})=>{const n=new URLSearchParams({no_page:"true"});r.siteId&&n.set("site",r.siteId);const c=await e(`/api/storefront/forms/?${n.toString()}`,{token:a});return[...Array.isArray(c)?c:c.results??[]].sort((S,R)=>S.title.localeCompare(R.title))},listWheelSummaries:async(a,r={})=>{const n=new URLSearchParams;r.siteId&&n.set("site",r.siteId);const c=n.toString(),y=await e(`/api/storefront/wheel-curations/summaries/${c?`?${c}`:""}`,{token:a});return g(y)},listProducts:async(a,r={})=>{const n=new URLSearchParams;r.kinds?.length&&n.set("kind",r.kinds.join(",")),r.siteId&&n.set("site",r.siteId);const c=n.toString(),y=await e(`/api/storefront/products/${c?`?${c}`:""}`,{token:a});return g(y)},getWheelDetail:async(a,r,n={})=>{const c=new URLSearchParams({slug:r});return n.siteId&&c.set("site",n.siteId),L(g(await e(`/api/storefront/wheel-curations/detail/?${c.toString()}`,{token:a})))},updateHeaderSettings:(a,r,n)=>e(o(n),{method:"PATCH",body:JSON.stringify(a),token:r}),getSite:(a,r)=>e($(a),{token:r}),listSites:async a=>{const r=await e("/api/storefront/sites/?no_page=true",{token:a});return Array.isArray(r)?r:r.results??[]},listSiteCurrencies:async(a,r)=>{const n=await e(Wt(a),{token:r});return Array.isArray(n)?n:[]},publishSite:(a,r)=>e(`${$(a)}publish/`,{method:"POST",token:r}),getSiteLiveState:(a,r)=>e(`${$(a)}live-state/`,{token:r}),getThemeSettings:(a,r)=>e(l(r),{token:a}),updateThemeSettings:(a,r,n)=>e(l(n),{method:"PATCH",body:JSON.stringify(a),token:r}),getChatSettings:(a,r)=>e(p(r),{token:a}),updateChatSettings:(a,r,n)=>e(p(n),{method:"PATCH",body:JSON.stringify(a),token:r}),getSocialSettings:(a,r)=>e(w(r),{token:a}),updateSocialSettings:(a,r,n)=>e(w(n),{method:"PATCH",body:JSON.stringify(a),token:r}),uploadHeaderLogo:(a,r,n)=>{const c=new FormData;return c.append("logo",a),e(o(n),{method:"PATCH",body:c,token:r})},clearHeaderLogo:(a,r)=>e(o(r),{method:"PATCH",body:JSON.stringify({logo:null}),token:a}),setHeaderLogoFromAsset:(a,r,n)=>e(o(n),{method:"PATCH",body:JSON.stringify({logo_asset_id:a}),token:r}),uploadMedia:async(a,r)=>{const n=new FormData;return n.append("file",a),e(Kt(),{method:"POST",body:n,token:r})},listMedia:async(a,r)=>{const n=new URLSearchParams({no_page:"true"});r&&n.set("kind",r);const c=await e(`/api/storefront/media-assets/?${n.toString()}`,{token:a});return Array.isArray(c)?c:c.results??[]}}}const fe=Xt({siteDrafts:!0});export{ut as API_URL,Gt as AmbiguousPageSlugError,m as ApiError,ht as BROWSER_READ_TIMEOUT_MS,pt as EFFICIENT_CLIENT_CLOSED_MESSAGE,zt as MediaUploadDestinationError,Mt as PREVIEW_PARAM,we as PRODUCT_API_BASE,yt as SERVER_READ_TIMEOUT_MS,U as SERVER_UNREACHABLE_MESSAGE,I as STATUS_NETWORK_ERROR,he as adminFetch,Ot as api,i as apiFetch,E as appendSiteQuery,ye as bookings,Xt as createStorefrontAdmin,D as defaultRequestDeadline,Kt as editorMediaUploadPath,mt as editorPortalAudience,St as editorRequestLanguage,le as fitment,pe as products,ft as readDeadlineMs,Dt as resolveClientIp,g as resolveMediaUrls,Ft as resolvePreviewToken,Z as resolveSiteHost,Lt as resolveSiteHostSource,xt as resolveSiteSlug,oe as setEditorLanguage,ne as setEditorPortalAudience,fe as storefrontAdmin};
@@ -1391,7 +1391,7 @@ export interface components {
1391
1391
  foundedYear: number | null;
1392
1392
  commerceEnabled: boolean;
1393
1393
  cardPayments: boolean;
1394
- paymentMethods: ("card" | "paypal" | "afterpay" | "square" | "gocardless" | "zip" | "klarna")[];
1394
+ paymentMethods: ("card" | "paypal" | "afterpay" | "square" | "gocardless" | "zip" | "klarna" | "bank")[];
1395
1395
  paypalClientId: string | null;
1396
1396
  paypalEnvironment: "live" | "sandbox" | null;
1397
1397
  squareApplicationId: string | null;
@@ -1401,8 +1401,6 @@ export interface components {
1401
1401
  googleAdsId: string | null;
1402
1402
  googleAdsConversionLabel: string | null;
1403
1403
  metaPixelId: string | null;
1404
- mapsApiKey: string | null;
1405
- mapsMapId: string | null;
1406
1404
  socialLinks?: components["schemas"]["SiteSocialLinks"];
1407
1405
  consentEnabled?: boolean;
1408
1406
  consentPrivacyPage?: string | null;
@@ -1933,6 +1931,7 @@ export interface components {
1933
1931
  customerEmail?: string;
1934
1932
  country?: string;
1935
1933
  subdivision?: string;
1934
+ postcode?: string;
1936
1935
  };
1937
1936
  CartQuoteTax: {
1938
1937
  name: string;
@@ -1971,6 +1970,11 @@ export interface components {
1971
1970
  grandTotal: number;
1972
1971
  currency: components["schemas"]["Currency"];
1973
1972
  deliveryOptions: components["schemas"]["DeliveryOption"][];
1973
+ courier: components["schemas"]["CartQuoteCourier"] | null;
1974
+ };
1975
+ CartQuoteCourier: {
1976
+ status: "quoted" | "unavailable";
1977
+ reason: string;
1974
1978
  };
1975
1979
  CountrySubdivision: {
1976
1980
  code: string;
@@ -8,7 +8,7 @@ export declare function resolveCopyright({ legalName, foundedYear, siteName, }:
8
8
  foundedYear?: number | null;
9
9
  siteName: string;
10
10
  }, currentYear?: number): string;
11
- export type PaymentMethod = "card" | "paypal" | "afterpay" | "square" | "gocardless" | "zip" | "klarna";
11
+ export type PaymentMethod = "card" | "paypal" | "afterpay" | "square" | "gocardless" | "zip" | "klarna" | "bank";
12
12
  export interface SiteCurrency {
13
13
  code: string;
14
14
  symbol: string;
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import{CountrySwitchTool as i}from"../../../../../components/HeaderToolBlocks.js";import{resolveCountryShowAs as e}from"../../../../content/country-show-as.js";import{CountrySwitchBlockMeta as n}from"./meta.js";const p={...n,render:({editor:o,showAs:r})=>t(i,{editing:o?.isEditing,showAs:e(r)})};export{p as CountrySwitchBlockRender};
1
+ import{jsx as r}from"react/jsx-runtime";import{CountrySwitchTool as t}from"../../../../../components/HeaderToolBlocks.js";import{resolveCountryShowAs as e}from"../../../../content/country-show-as.js";import{CountrySwitchBlockMeta as m}from"./meta.js";const h={...m,render:({showAs:o})=>r(t,{showAs:e(o)})};export{h as CountrySwitchBlockRender};