efficient-storefront-blocks 0.99.0 → 0.100.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 (111) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/chunks/EditorPreviewCheckout-OLTXWUGM.js +4 -0
  3. package/dist/chunks/{SiteEditorProvider-YAIB64UV.js → SiteEditorProvider-4XV2T5MD.js} +1 -1
  4. package/dist/chunks/chunk-4SYZK3TW.js +1 -0
  5. package/dist/chunks/chunk-G6OVBAOA.js +74 -0
  6. package/dist/chunks/chunk-OWUMH5VC.js +339 -0
  7. package/dist/chunks/chunk-SCTOV5CT.js +1 -0
  8. package/dist/chunks/{chunk-EIBYUCDE.js → chunk-WN7SFD3N.js} +1 -1
  9. package/dist/chunks/{fitment-data-OUHMES66.js → fitment-data-ZWKG2FFA.js} +1 -1
  10. package/dist/contract.js +1 -1
  11. package/dist/editor/lib/document/blocks/commerce/AlloyWheelsListing/fields.js +1 -1
  12. package/dist/editor/lib/document/blocks/commerce/DetailRows/fields.js +1 -1
  13. package/dist/editor/lib/document/blocks/commerce/ProductGrid/fields.js +1 -1
  14. package/dist/editor/lib/document/blocks/service/DealerFinder/fields.d.ts +2 -0
  15. package/dist/editor/lib/document/blocks/service/DealerFinder/fields.js +1 -0
  16. package/dist/editor/lib/document/blocks/service/FooterLogo/fields.js +1 -1
  17. package/dist/editor/lib/document/blocks/service/index.d.ts +1 -1
  18. package/dist/editor/lib/document/blocks/service/index.js +1 -1
  19. package/dist/editor/lib/document/config.js +1 -1
  20. package/dist/editor/lib/storefront-editor-words.d.ts +4 -0
  21. package/dist/editor/lib/storefront-editor-words.js +1 -1
  22. package/dist/editor.css +1 -1
  23. package/dist/index.js +33 -31
  24. package/dist/render/built-with.json +1 -1
  25. package/dist/render/components/CouponField.d.ts +2 -1
  26. package/dist/render/components/CouponField.js +1 -1
  27. package/dist/render/components/DealerFinderSection.d.ts +18 -0
  28. package/dist/render/components/DealerFinderSection.js +1 -0
  29. package/dist/render/components/DetailRows.d.ts +2 -3
  30. package/dist/render/components/DetailRows.js +1 -1
  31. package/dist/render/components/Events.d.ts +2 -3
  32. package/dist/render/components/Events.js +1 -1
  33. package/dist/render/components/GalleryGrid.d.ts +2 -3
  34. package/dist/render/components/GalleryGrid.js +3 -3
  35. package/dist/render/components/GridCardTemplate.js +1 -1
  36. package/dist/render/components/ProductGridSection.d.ts +3 -2
  37. package/dist/render/components/ProductGridSection.js +1 -1
  38. package/dist/render/components/card-pieces/CardPrice.js +1 -1
  39. package/dist/render/components/card-pieces/useTaxNote.d.ts +1 -0
  40. package/dist/render/components/card-pieces/useTaxNote.js +1 -0
  41. package/dist/render/components/catalog/ShopperFilters.d.ts +3 -1
  42. package/dist/render/components/catalog/ShopperFilters.js +1 -1
  43. package/dist/render/components/checkout/checkout-parts.js +1 -1
  44. package/dist/render/components/checkout/checkout-state.d.ts +2 -0
  45. package/dist/render/components/checkout/checkout-state.js +3 -3
  46. package/dist/render/components/pdp-dynamic/DynamicDetailRows.d.ts +1 -2
  47. package/dist/render/components/pdp-dynamic/DynamicDetailRows.js +1 -1
  48. package/dist/render/components/pdp-dynamic/DynamicGalleryGrid.d.ts +1 -2
  49. package/dist/render/components/pdp-dynamic/DynamicGalleryGrid.js +1 -1
  50. package/dist/render/components/useProductSelection.d.ts +2 -1
  51. package/dist/render/components/useProductSelection.js +1 -1
  52. package/dist/render/components/wheels-plp/AlloyWheelsListing.d.ts +4 -2
  53. package/dist/render/components/wheels-plp/AlloyWheelsListing.js +1 -1
  54. package/dist/render/components/wheels-plp/PlpFacetRows.d.ts +5 -2
  55. package/dist/render/components/wheels-plp/PlpFacetRows.js +1 -1
  56. package/dist/render/components/wheels-plp/PlpSidebar.d.ts +17 -6
  57. package/dist/render/components/wheels-plp/PlpSidebar.js +1 -1
  58. package/dist/render/lib/api/index.d.ts +3 -0
  59. package/dist/render/lib/api/index.js +1 -1
  60. package/dist/render/lib/api/types.d.ts +3 -0
  61. package/dist/render/lib/catalog/default-variant.d.ts +2 -0
  62. package/dist/render/lib/catalog/default-variant.js +1 -0
  63. package/dist/render/lib/catalog/tax-note.d.ts +4 -0
  64. package/dist/render/lib/catalog/tax-note.js +1 -0
  65. package/dist/render/lib/content/facet-row-seed.d.ts +1 -0
  66. package/dist/render/lib/content/facet-row-seed.js +1 -1
  67. package/dist/render/lib/content/rail-row-seed.d.ts +16 -0
  68. package/dist/render/lib/content/rail-row-seed.js +1 -0
  69. package/dist/render/lib/document/blocks/commerce/AlloyWheelsListing/meta.d.ts +8 -0
  70. package/dist/render/lib/document/blocks/commerce/AlloyWheelsListing/meta.js +1 -1
  71. package/dist/render/lib/document/blocks/commerce/AlloyWheelsListing/render.js +1 -1
  72. package/dist/render/lib/document/blocks/commerce/DetailRows/meta.js +1 -1
  73. package/dist/render/lib/document/blocks/commerce/DetailRows/render.js +1 -1
  74. package/dist/render/lib/document/blocks/commerce/FilterBlock/meta.d.ts +8 -0
  75. package/dist/render/lib/document/blocks/commerce/FilterBlock/meta.js +1 -1
  76. package/dist/render/lib/document/blocks/commerce/FilterBlock/render.js +1 -1
  77. package/dist/render/lib/document/blocks/commerce/GalleryB/meta.js +1 -1
  78. package/dist/render/lib/document/blocks/commerce/GalleryB/render.js +1 -1
  79. package/dist/render/lib/document/blocks/commerce/ProductGrid/meta.js +1 -1
  80. package/dist/render/lib/document/blocks/commerce/ProductGrid/render.js +1 -1
  81. package/dist/render/lib/document/blocks/service/DealerFinder/meta.d.ts +2 -0
  82. package/dist/render/lib/document/blocks/service/DealerFinder/meta.js +1 -0
  83. package/dist/render/lib/document/blocks/service/DealerFinder/render.d.ts +4 -0
  84. package/dist/render/lib/document/blocks/service/DealerFinder/render.js +1 -0
  85. package/dist/render/lib/document/blocks/service/Events/meta.js +1 -1
  86. package/dist/render/lib/document/blocks/service/Events/render.js +1 -1
  87. package/dist/render/lib/document/blocks/service/metas.d.ts +1 -0
  88. package/dist/render/lib/document/blocks/service/metas.js +1 -1
  89. package/dist/render/lib/document/blocks/service/renders.d.ts +1 -0
  90. package/dist/render/lib/document/blocks/service/renders.js +1 -1
  91. package/dist/render/lib/document/blocks/text-part-shapes.json +10 -0
  92. package/dist/render/lib/document/card-templates.js +1 -1
  93. package/dist/render/lib/document/current-product.d.ts +2 -1
  94. package/dist/render/lib/document/current-product.js +1 -1
  95. package/dist/render/lib/document/lazy-draws.js +1 -1
  96. package/dist/render/lib/document/section-to-box-rows-listing.js +1 -1
  97. package/dist/render/lib/sections/band-padding.d.ts +23 -0
  98. package/dist/render/lib/sections/band-padding.js +1 -0
  99. package/dist/render/lib/sections/dealer-finder.d.ts +41 -0
  100. package/dist/render/lib/sections/dealer-finder.js +1 -0
  101. package/dist/words.d.ts +13 -0
  102. package/dist/words.js +4 -4
  103. package/package.json +2 -2
  104. package/dist/chunks/EditorPreviewCheckout-J76THKIJ.js +0 -4
  105. package/dist/chunks/chunk-B2IYTOE3.js +0 -1
  106. package/dist/chunks/chunk-GOVYQQA4.js +0 -1
  107. package/dist/chunks/chunk-KRMWJLBM.js +0 -412
  108. package/dist/chunks/chunk-QP2F42DV.js +0 -1
  109. package/dist/render/lib/sections/own-padding.d.ts +0 -3
  110. package/dist/render/lib/sections/own-padding.js +0 -1
  111. /package/dist/chunks/{chunk-KRMWJLBM.js.LEGAL.txt → chunk-OWUMH5VC.js.LEGAL.txt} +0 -0
@@ -1,3 +1,3 @@
1
- "use client";import{jsx as T}from"react/jsx-runtime";import{createContext as Hn,useContext as zn,useEffect as y,useMemo as qt,useRef as f,useState as o}from"react";import{isOrderable as Gt,useCart as Dn}from"../CartContext.js";import{useCurrency as qn}from"../CurrencyContext.js";import{getClickIds as Gn}from"../../lib/click-ids.js";import{adConsentForOrder as Jn}from"../../lib/consent/choice.js";import{trackBeginCheckout as Wn,trackPurchase as Xn}from"../../lib/google-tag.js";import{trackMetaPurchase as Zn}from"../../lib/meta-pixel.js";import{ApiError as Te,api as ie,products as C}from"../../lib/api/index.js";import{uuid as ue}from"../../lib/uuid.js";import{orderLinesForSets as jn}from"../../lib/commerce.js";import{canPersist as Qn,safeSessionStorage as v}from"efficient-web-builder/format/lib/safe-storage";import{AFTERPAY_CONTEXT_KEY as Vn,AFTERPAY_RETURN as er,GOCARDLESS_CONTEXT_KEY as Ge,KLARNA_CONTEXT_KEY as Je,ZIP_CONTEXT_KEY as tr,ZIP_RETURN as nr,runWalletReturn as Jt}from"../../lib/checkout/wallet-return.js";import{matchSubdivision as rr}from"../../lib/checkout/match-subdivision.js";import{checkoutGone as We,checkoutWaiting as Wt,BANK_WAITING as or,DROPPABLE_INTENT as cr,NOT_CHECKED as Xe,LOST_CHANGE as Xt,PAY_FIRST_FLOW as Zt,paysFirst as ar,readIntentStatus as sr,releaseHeldCheckout as jt,CHECKOUT_COMMITTED as ir,goodsShapeOf as ur,refusedForGood as Qt,settlePayFirst as lr}from"../../lib/checkout/pay-first.js";import{couponCodeForOrder as Vt,couponRefusedByOrder as dr}from"../../lib/cart/coupon-preview.js";function en(a){const m=a.indexOf(`
2
- `);return m===-1?[a,""]:[a.slice(0,m),a.slice(m+1)]}function tn(a,{canParkContext:m}={canParkContext:!0}){const p=a.paymentMethods,i=[];return p.includes("card")&&i.push({key:"card",title:"Card",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),p.includes("paypal")&&a.paypalClientId&&i.push({key:"paypal",title:"PayPal",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAYPAL · CARDS"})}),p.includes("afterpay")&&i.push({key:"afterpay",title:"Afterpay",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"4 × INTEREST-FREE"})}),p.includes("square")&&a.squareApplicationId&&a.squareLocationId&&i.push({key:"square",title:"Card (Square)",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),p.includes("gocardless")&&m&&i.push({key:"gocardless",title:"Bank Direct Debit",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY BY BANK"})}),p.includes("zip")&&i.push({key:"zip",title:"Zip",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY IN 4"})}),p.includes("klarna")&&m&&i.push({key:"klarna",title:"Klarna",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),p.includes("bank")&&i.push({key:"bank",title:"Bank transfer",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),i}const Er="This shop does not take payment online yet. Please contact the shop to order.";class Ie extends Error{}function nn(a,m){if(!a.orderNumber&&We(m))return m.message;const p=m instanceof Te?` (${m.message})`:"";return a.orderNumber?`Your order ${a.orderNumber} is saved, but the payment did not start${p}. Try the payment again — your order will not be placed twice.`:`Your items are held under ${a.checkoutNumber}, but the payment did not start${p}. Try the payment again — you will not be charged twice.`}const rn=new Set(["paypal","square","afterpay","gocardless","zip","klarna"]),z=a=>JSON.parse(a),Tr="Shipping cannot be calculated right now. Please try again.";function pr({site:a,logo:m,preview:p=!1}){const{items:i,totals:I,coupon:D,refuseCoupon:cn,deliveryOptions:Ze,shippingMethodId:le,setShippingMethodId:an,setQuoteDestination:de,courier:sn,requote:un,identify:je,clearCapturedCart:q,replaceItems:Qe,removeCoupon:Ve}=Dn(),ln=Ze.find(e=>e.id===le)?.pickupLocation??null,{country:et,countries:Q,activeCountry:tt,formatMoney:dn}=qn(),[w,pe]=o(()=>tn(a)[0]?.key??null),[nt,pn]=o(!0);y(()=>{pn(Qn(v))},[]);const[fe,S]=o(!1),[V,_e]=o(""),[L,Me]=o(""),[ee,Re]=o(""),[Le,rt]=o(""),[me,ye]=o(""),[$e,he]=o(""),[G,we]=o(""),[$,ge]=o(""),[te,ke]=o(""),[l,Ce]=o(()=>et||Q[0]?.code||""),[_,Ne]=o(""),[ne,ot]=o([]),[Fe,Ye]=o(null),[be,re]=o(null),ct=qt(()=>Q.find(e=>e.code===l)??tt,[Q,l,tt]),fn=ct?.postalLabel||"Postal Code",mn=ne[0]?.divisionType||"State / Province";y(()=>{if(!l){ot([]),Ye(l);return}Ye(null);let e=!1;return C.listCountrySubdivisions(l).then(t=>{e||(ot(t),Ye(l),Ne(""))}),()=>{e=!0}},[l]);const at=me.trim()!==""&&G.trim()!==""&&$.trim()!==""&&Fe===l&&(ne.length===0||_!=="")?$.trim():"";y(()=>{de(l?{country:l,subdivision:_,postcode:at}:null)},[l,_,at,de]),y(()=>()=>de(null),[de]);const yn=sn?.status==="unavailable",hn=un,[Pe,st]=o(null),[wn,it]=o([]),[ut,Ue]=o("new"),[lt,dt]=o(!1),[Be,gn]=o("Home"),[kn,pt]=o(null),[Cn,ft]=o(null),[oe,Se]=o(()=>ue()),mt=f(null),[yt,A]=o(null),[Nn,N]=o(null),[ht,Ae]=o(null),[wt,bn]=o(!1),[gt,Pn]=o(!1),[M,J]=o(null),[Sn,W]=o(!1),[b,K]=o(null),[An,x]=o(null),[vn,Kn]=o(!1),[xn,kt]=o(!1),[On,En]=o(!1),[Tn,Ct]=o(!1),[Nt,In]=o(!1),[_n,He]=o(!1),[ze,bt]=o(null),F=f(null),ce=f(i),Y=f(null),X=f(null),Pt=!!(yt||ze&&ze.kind!=="processing"||Nt||wt||gt||ht&&M?.orderNumber);y(()=>{Pt&&(Qe([]),Ve())},[Pt,Qe,Ve]);const St=f(!1);y(()=>{p||St.current||!i.some(Gt)||(St.current=!0,Wn({lines:i,currency:I.currency,value:I.subtotal-I.discount,coupon:D?.valid?D.code:void 0}))},[i,I,D,p]),y(()=>{je(V,L.trim()||void 0)},[V,L,je]);const At=f(null),[ve,Mn]=o(null);y(()=>{const e=At.current;if(!ve||!e)return;const t=()=>e.style.setProperty("--sf-checkout-header-h",`${ve.offsetHeight}px`);t();const n=new ResizeObserver(t);return n.observe(ve),()=>n.disconnect()},[ve]),y(()=>{const e=n=>({setConfirming:n,land:A,markPaid:()=>W(!0),note:x,fail:N,clearCart:q}),t={search:window.location.search,storage:v,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};Jt(er,{...t,capture:C.captureAfterpayPayment,page:e(Kn)}),Jt(nr,{...t,capture:C.captureZipPayment,page:e(En)})},[]),y(()=>{const t=new URLSearchParams(window.location.search).get("gocardless");if(t!=="confirm"&&t!=="cancel")return;const n=v.getItem(Ge);if(v.removeItem(Ge),window.history.replaceState(null,"",window.location.pathname),!n)return;let c;try{c=JSON.parse(n)}catch{return}if(q(),t==="cancel"){x("The direct debit was not set up — our team will follow up on payment."),A(c.confirmation);return}kt(!0),C.completeGocardlessPayment({idempotencyKey:c.idempotencyKey}).then(r=>{r.status==="paid"?W(!0):r.status==="declined"?x("The direct debit was declined — our team will follow up on payment."):x("Your direct debit is set up — the payment is collecting and will clear in a few days.")}).catch(()=>{x("We could not confirm the direct debit — our team will follow up on payment.")}).finally(()=>{A(c.confirmation),kt(!1)})},[]),y(()=>{const e=new URLSearchParams(window.location.search),t=e.get("klarna");if(t!=="confirm"&&t!=="cancel")return;const n=v.getItem(Je);v.removeItem(Je);const c=e.get("authorization_token");if(window.history.replaceState(null,"",window.location.pathname),!n)return;let r;try{r=JSON.parse(n)}catch{return}if(q(),t==="cancel"||!c){x("The Klarna payment was not completed — our team will follow up on payment."),A(r.confirmation);return}Ct(!0),C.captureKlarnaPayment({idempotencyKey:r.idempotencyKey,authorizationToken:c}).then(u=>{u.status==="paid"?W(!0):u.status==="declined"?x("Klarna declined the payment — our team will follow up on payment."):x("Your Klarna payment is being reviewed — we'll confirm the outcome shortly.")}).catch(()=>{x("We could not confirm the Klarna payment — our team will follow up on payment.")}).finally(()=>{A(r.confirmation),Ct(!1)})},[]);function vt(e){const[t,n]=en(e.address);ye(t),he(n),we(e.city),ge(e.zip_code),e.country&&Ce(e.country),e.phone&&ke(e.phone),re({country:e.country||null,state:e.state??""})}y(()=>{if(be){if((be.country||l)!==l){re(null);return}Fe===l&&(Ne(rr(l,be.state,ne)),re(null))}},[be,l,Fe,ne]),y(()=>{let e=!1;return(async()=>{try{const[t,n,c]=await Promise.all([ie.me(),ie.myProfile().catch(()=>null),ie.myAddresses().catch(()=>[])]);if(e)return;st(t);const r=c.filter(d=>d.is_active);it(r),_e(t.email);const u=(n?.contact_name??"").split(/\s+/);Me(t.first_name||u[0]||""),Re(t.last_name||u.slice(1).join(" "));const s=t.phone||n?.phone;s&&ke(s);const g=r.find(d=>d.id===t.default_delivery_location)??r[0];if(g)Ue(g.id),vt(g);else if(n){const[d,k]=en(n.address??"");ye(d),he(k),we(n.city??""),ge(n.zip_code??""),n.country&&Ce(n.country),re({country:n.country||null,state:n.state??""})}}catch{}})(),()=>{e=!0}},[]);function Rn(){ie.logout(),st(null),it([]),Ue("new"),dt(!1),_e(""),Me(""),Re(""),rt(""),ye(""),he(""),we(""),ge(""),ke(""),Ce(et||Q[0]?.code||""),Ne(""),re(null)}const Z=qt(()=>tn(a,{canParkContext:nt}),[a,nt]);y(()=>{Z.some(e=>e.key===w)||pe(Z[0]?.key??null)},[Z,w]);const Ln=Z.length===0,Ke=$e.trim()?`${me}
3
- ${$e.trim()}`:me,$n=ur({email:V,firstName:L,lastName:ee,company:Le.trim(),phone:te,address:Ke,city:G,subdivision:_,postcode:$,country:l,lines:i.map(e=>[e.id,e.qty]),shippingMethodId:le,couponCode:Vt(D),currency:I.currency,shopperId:Pe?.id??null}),h=JSON.stringify([$n,w]),R=f(null),De=f(null),xe=f(!1),O=f(!1),j=f(null),Oe=f(!1),P=f(h);P.current=h;const Kt=f(fe);Kt.current=fe;const xt=()=>O.current&&P.current!==R.current,U=f(null);y(()=>{Kt.current||(h!==U.current&&(U.current=null),!(!O.current||!b||b.orderNumber)&&(h===R.current||h===U.current||Ee(b)))},[h,b]);async function Ee(e){if(Oe.current)return null;Oe.current=!0,S(!0);try{const t=j.current?await sr(j.current):"none";if(t==="succeeded"||t==="processing")return O.current=!1,K(null),E("card"),t==="succeeded"?await B(void 0,e):$t(e),null;if(t===void 0||!cr.has(t))return U.current=P.current,K(e),N(t==="requires_action"?or:Xe),null;const n=await jt(oe);if(n==="committed")return O.current=!1,K(null),E("card"),await B(void 0,e),null;if(n!=="released")return U.current=P.current,K(e),N(Xe),null;O.current=!1,j.current=null,U.current=null,N(null),K(null);const c=ue();return Se(c),c}finally{Oe.current=!1,S(!1)}}async function Fn(){if(!(p||fe||Oe.current)){if(b){if((O.current?h!==R.current:ae())&&!b.orderNumber){const c=await Ee(b);c&&P.current===h&&await Ot(c);return}S(!0),N(null),xe.current=!1,await qe();const t=z(P.current)[1],n=b.orderNumber?t:"card";if(n&&rn.has(n)&&ae()&&z(P.current)[0]!==De.current){Et(b);return}E(n),n!==w&&pe(n),await Ft(b,n,!b.orderNumber);return}await Ot(oe)}}async function Ot(e){if(i.length===0||I.repricing||!w||!Z.some(s=>s.key===w))return;const t=i.filter(Gt).flatMap(s=>jn(s.components,s.qty));if(t.length===0){N("Pick a size on each wheel's product page before checking out.");return}S(!0),N(null);let n,c=e,r=w,u=!1;try{const s=Pe?C.createOrderAuthed:C.createOrder,g=Jn(),d={customer:{email:V,name:`${L} ${ee}`.trim(),phone:te.trim()||void 0,companyName:Le.trim()||void 0,address:Ke,city:G,state:_||void 0,zipCode:$,country:l},items:t,currency:I.currency,idempotencyKey:e,shippingMethodId:le??void 0,couponCode:Vt(D),...g==="denied"?{}:Gn(),...g?{adConsent:g}:{},...ar(w)?{checkoutFlow:Zt}:{}};F.current=()=>s(d),ft(null),De.current=null,xe.current=!1,j.current=null,O.current=!1,U.current=null,R.current=h,ce.current=i;const k=Y.current,Bt=k?.key===d.idempotencyKey&&(k.shape!==h&&(!!d.checkoutFlow||!!k.method||!!k.plainMethod)||!!d.checkoutFlow&&!!k.plainMethod);Bt&&(X.current=d.idempotencyKey);const Ht=Mt(d,s),zt=Bt||!d.checkoutFlow&&X.current===d.idempotencyKey,Dt=!Ht&&!zt&&!d.checkoutFlow&&!!k&&!k.method;Dt&&(k.plainMethod=w,k.plainLines=i,k.plainShape=h);const H=await(zt?It(d,s):s(d).then(se=>({answer:se,request:d})).catch(se=>(Ht?Tt(se,d.idempotencyKey):Dt&&Qt(se)&&(k.plainMethod=""),Yn(se,d,s))));if(!H)return;n=H.answer,c=H.request.idempotencyKey,r=H.method??r,E(r),u=ae()||r!==z(P.current)[1],H.method&&H.method!==w&&pe(H.method),n.orderNumber&&(Rt(n),q()),await qe()}catch(s){const g=dr(s);g?(cn(g),N(`${g} Your order has not been placed. Place it again to continue without the code.`)):s instanceof Ie?N(Xe):N(s instanceof Te?s.message:"Could not place the order. Please try again."),S(!1);return}if(r&&rn.has(r)&&(u||ae())){Et(n);return}await Ft(n,r,!1,c)}function Et(e){De.current=z(P.current)[0],N(`${nn(e,null)} ${Xt}`),K(e),S(!1)}function Tt(e,t){Qt(e)&&!Wt(e)&&Y.current?.key===t&&(Y.current=null)}async function Yn(e,t,n){if(We(e))return _t(t,n);if(!Wt(e))throw e;return X.current=t.idempotencyKey,It(t,n,!0)}async function It(e,t,n=!1){const c=await jt(e.idempotencyKey);if(c==="released")return P.current===h?_t(e,t):(Se(ue()),S(!1),null);if(c!=="committed")throw new Ie;const r=Y.current?.key===e.idempotencyKey?Y.current:null;if(ce.current=r?.lines??i,r?.method&&!n){X.current=null,F.current=r.send;const g=await r.send().catch(()=>{throw new Ie});return R.current=r.shape,{answer:g,request:e,method:r.method}}const u=r&&!r.method?r.send:()=>t({...e,checkoutFlow:Zt});F.current=u;const s=await u().catch(()=>null);if(!s&&r?.plainMethod)throw new Ie;return s?.orderNumber&&s.status!==ir?(X.current=null,r?.plainMethod&&(ce.current=r.plainLines),r&&(R.current=r.plainMethod?r.plainShape:r.shape),{answer:s,request:e,method:r?.plainMethod||void 0}):(S(!1),r&&(R.current=r.shape),E("card"),await Lt("",s?async()=>s:()=>Promise.reject(new Error("The order request did not answer."))),await qe(),null)}function ae(){const e=R.current;return e!==null&&z(e)[0]!==z(P.current)[0]}function E(e){e!==z(P.current)[1]&&(xe.current=!0),ft(xe.current||ae()?Xt:null)}async function _t(e,t){const n={...e,idempotencyKey:ue()};X.current=null,Se(n.idempotencyKey),F.current=()=>t(n),Mt(n,t);try{return{answer:await t(n),request:n}}catch(c){throw Tt(c,n.idempotencyKey),c}}function Mt(e,t){return Y.current?.key===e.idempotencyKey?!1:(Y.current={key:e.idempotencyKey,send:()=>t(e),lines:i,shape:h,method:e.checkoutFlow?"":w??"",plainMethod:"",plainLines:i,plainShape:h},!0)}function Rt(e){Xn({confirmation:e,lines:ce.current,adsSendTo:a.googleAdsId&&a.googleAdsConversionLabel?`${a.googleAdsId}/${a.googleAdsConversionLabel}`:null}),Zn({confirmation:e,lines:ce.current})}async function B(e,t=M){if(!t)return;const n=e?async()=>e:F.current;if(t.orderNumber||!n){W(!0),A(t);return}await Lt(t.checkoutNumber,n)}async function Lt(e,t){q(),await lr({checkoutNumber:e,resend:t,page:{setConfirming:In,land:A,markPaid:()=>W(!0),track:Rt,unplaced:bt}})}function $t(e=M){if(e){if(e.orderNumber){A(e);return}q(),bt({kind:"processing",checkoutNumber:e.checkoutNumber})}}async function qe(){const e=JSON.stringify([Be.trim(),L,ee,te.trim(),Ke,G,_,$,l]);if(!(!Pe||!lt||ut!=="new"||mt.current===e))try{await ie.createAddress({label:Be.trim()||"Home",contact_name:`${L} ${ee}`.trim(),phone:te.trim(),address:Ke,city:G,zip_code:$,state:_,country:l}),mt.current=e,pt("Address saved to your account.")}catch{pt("We couldn't save the address to your account — you can add it under Account → Addresses.")}}async function Ft(e,t=w,n=!1,c=oe){K(null);try{if(t==="card"&&a.paymentMethods.includes("card")){const r=await C.createPaymentIntent({idempotencyKey:c});if(j.current=r,n&&xt()){await Ee(e);return}let u=e;if(n){const s=await F.current?.().catch(()=>null);if(s?.orderNumber){E("card"),await B(s,e);return}if(u=Yt(e,s)??{...e,expiresAt:null},xt()){await Ee(e);return}}E("card"),J(u),He(!1),Ae(r)}else if(t==="paypal"&&a.paymentMethods.includes("paypal"))J(e),bn(!0);else if(t==="afterpay"&&a.paymentMethods.includes("afterpay")){const r=window.location.origin,u=await C.createAfterpayCheckout({idempotencyKey:c,confirmUrl:`${r}/checkout?afterpay=confirm`,cancelUrl:`${r}/checkout?afterpay=cancel`}),s={idempotencyKey:c,confirmation:e};v.setItem(Vn,JSON.stringify(s)),window.location.assign(u.redirectCheckoutUrl);return}else if(t==="square"&&a.paymentMethods.includes("square"))J(e),Pn(!0);else if(t==="gocardless"&&a.paymentMethods.includes("gocardless")){const r=window.location.origin,u=await C.createGocardlessBillingRequest({idempotencyKey:c,confirmUrl:`${r}/checkout?gocardless=confirm`,cancelUrl:`${r}/checkout?gocardless=cancel`}),s={idempotencyKey:c,confirmation:e};v.setItem(Ge,JSON.stringify(s)),window.location.assign(u.authorisationUrl);return}else if(t==="zip"&&a.paymentMethods.includes("zip")){const r=window.location.origin,u=await C.createZipCheckout({idempotencyKey:c,redirectUrl:`${r}/checkout?zip=return`}),s={idempotencyKey:c,confirmation:e};v.setItem(tr,JSON.stringify(s)),window.location.assign(u.redirectUrl);return}else if(t==="klarna"&&a.paymentMethods.includes("klarna")){const r=window.location.origin,u=await C.createKlarnaCheckout({idempotencyKey:c,confirmUrl:`${r}/checkout?klarna=confirm`,cancelUrl:`${r}/checkout?klarna=cancel`}),s={idempotencyKey:c,confirmation:e};v.setItem(Je,JSON.stringify(s)),window.location.assign(u.redirectUrl);return}else E(t),A(e)}catch(r){if((n||t==="card")&&r instanceof Te&&r.status===409){E(t),await B(void 0,e);return}Ut(e,r),S(!1)}}function Yt(e,t){return t&&!t.orderNumber&&t.status==="open"&&t.checkoutNumber===e.checkoutNumber?t:null}function Ut(e,t){N(nn(e,t)),!e.orderNumber&&We(t)?(O.current=!1,Se(ue())):K(e)}async function Un(e){if(!M)return;const t=M;try{const n=await C.createPaymentIntent({idempotencyKey:oe}),c=await F.current?.().catch(()=>null);if(c?.orderNumber){await B(c);return}const r=Yt(t,c);J(r??{...t,expiresAt:null}),He(e&&r!==null),j.current=n,Ae(n)}catch(n){if(n instanceof Te&&n.status===409){await B();return}Ae(null),J(null),Ut(t,n),S(!1)}}function Bn(){M&&(O.current=!0,K(M),Ae(null),J(null),He(!1),S(!1))}return{site:a,logo:m,items:i,totals:I,coupon:D,deliveryOptions:Ze,courierUnavailable:yn,retryCourier:hn,shippingMethodId:le,setShippingMethodId:an,pickupLocation:ln,servedCountries:Q,formatMoney:dn,payChoice:w,setPayChoice:pe,placing:fe,email:V,setEmail:_e,firstName:L,setFirstName:Me,lastName:ee,setLastName:Re,company:Le,setCompany:rt,address1:me,setAddress1:ye,address2:$e,setAddress2:he,city:G,setCity:we,postcode:$,setPostcode:ge,phone:te,setPhone:ke,country:l,setCountry:Ce,subdivision:_,setSubdivision:Ne,subdivisions:ne,destination:ct,postcodeLabel:fn,subdivisionLabel:mn,me:Pe,savedAddresses:wn,selectedAddressId:ut,setSelectedAddressId:Ue,saveAddress:lt,setSaveAddress:dt,saveLabel:Be,setSaveLabel:gn,addressSaveNote:kn,lostChangeNote:Cn,idemKey:oe,confirmation:yt,setConfirmation:A,orderError:Nn,payment:ht,paypalStep:wt,squareStep:gt,pendingConf:M,paid:Sn,setPaid:W,unpaidOrder:b,payNote:An,afterpayConfirming:vn,gocardlessConfirming:xn,zipConfirming:On,klarnaConfirming:Tn,cardConfirming:Nt,checkoutResult:ze,confirmCardPayment:B,cardStillProcessing:$t,renewCardPayment:Un,holdRenewed:_n,leaveCardPayment:Bn,checkoutRootRef:At,setCheckoutHeaderEl:Mn,fillFromAddress:vt,checkoutSignOut:Rn,payOptions:Z,noPaymentMethod:Ln,placeOrder:Fn}}const on=Hn(null);function Ir({children:a,...m}){const p=pr(m);return T(on.Provider,{value:p,children:a})}function _r(){const a=zn(on);if(!a)throw new Error("useCheckout must be used inside CheckoutStateProvider");return a}export{Ir as CheckoutStateProvider,Er as NO_PAYMENT_METHOD_NOTE,Tr as SHIPPING_RETRY_NOTE,tn as buildPayOptions,nn as paymentNotStartedMessage,_r as useCheckout};
1
+ "use client";import{jsx as T}from"react/jsx-runtime";import{createContext as zn,useContext as Dn,useEffect as y,useMemo as qt,useRef as f,useState as o}from"react";import{isOrderable as Gt,useCart as qn}from"../CartContext.js";import{useCurrency as Gn}from"../CurrencyContext.js";import{getClickIds as Jn}from"../../lib/click-ids.js";import{adConsentForOrder as Wn}from"../../lib/consent/choice.js";import{trackBeginCheckout as Xn,trackPurchase as Zn}from"../../lib/google-tag.js";import{trackMetaPurchase as jn}from"../../lib/meta-pixel.js";import{ApiError as Te,api as ie,products as N}from"../../lib/api/index.js";import{uuid as ue}from"../../lib/uuid.js";import{orderLinesForSets as Qn}from"../../lib/commerce.js";import{canPersist as Vn,safeSessionStorage as v}from"efficient-web-builder/format/lib/safe-storage";import{AFTERPAY_CONTEXT_KEY as er,AFTERPAY_RETURN as tr,GOCARDLESS_CONTEXT_KEY as Ge,KLARNA_CONTEXT_KEY as Je,ZIP_CONTEXT_KEY as nr,ZIP_RETURN as rr,runWalletReturn as Jt}from"../../lib/checkout/wallet-return.js";import{matchSubdivision as or}from"../../lib/checkout/match-subdivision.js";import{checkoutGone as We,checkoutWaiting as Wt,BANK_WAITING as cr,DROPPABLE_INTENT as ar,NOT_CHECKED as Xe,LOST_CHANGE as Xt,PAY_FIRST_FLOW as Zt,paysFirst as sr,readIntentStatus as ir,releaseHeldCheckout as jt,CHECKOUT_COMMITTED as ur,goodsShapeOf as lr,refusedForGood as Qt,settlePayFirst as dr}from"../../lib/checkout/pay-first.js";import{couponCodeForOrder as Vt,couponRefusedByOrder as pr}from"../../lib/cart/coupon-preview.js";function en(c){const m=c.indexOf(`
2
+ `);return m===-1?[c,""]:[c.slice(0,m),c.slice(m+1)]}function tn(c,{canParkContext:m}={canParkContext:!0}){const p=c.paymentMethods,i=[];return p.includes("card")&&i.push({key:"card",title:"Card",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),p.includes("paypal")&&c.paypalClientId&&i.push({key:"paypal",title:"PayPal",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAYPAL · CARDS"})}),p.includes("afterpay")&&i.push({key:"afterpay",title:"Afterpay",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"4 × INTEREST-FREE"})}),p.includes("square")&&c.squareApplicationId&&c.squareLocationId&&i.push({key:"square",title:"Card (Square)",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),p.includes("gocardless")&&m&&i.push({key:"gocardless",title:"Bank Direct Debit",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY BY BANK"})}),p.includes("zip")&&i.push({key:"zip",title:"Zip",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY IN 4"})}),p.includes("klarna")&&m&&i.push({key:"klarna",title:"Klarna",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),p.includes("bank")&&i.push({key:"bank",title:"Bank transfer",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),i}const Tr="This shop does not take payment online yet. Please contact the shop to order.";class Ie extends Error{}function nn(c,m){if(!c.orderNumber&&We(m))return m.message;const p=m instanceof Te?` (${m.message})`:"";return c.orderNumber?`Your order ${c.orderNumber} is saved, but the payment did not start${p}. Try the payment again — your order will not be placed twice.`:`Your items are held under ${c.checkoutNumber}, but the payment did not start${p}. Try the payment again — you will not be charged twice.`}const rn=new Set(["paypal","square","afterpay","gocardless","zip","klarna"]),z=c=>JSON.parse(c),Ir="Shipping cannot be calculated right now. Please try again.";function _r(c){return`Your order is saved, so its contact, address, delivery and discount can't change here. To change any of them, contact the shop and quote ${c}.`}function fr({site:c,logo:m,preview:p=!1}){const{items:i,totals:I,coupon:D,refuseCoupon:cn,deliveryOptions:Ze,shippingMethodId:le,setShippingMethodId:an,setQuoteDestination:de,courier:sn,requote:un,identify:je,clearCapturedCart:q,replaceItems:Qe,removeCoupon:Ve}=qn(),ln=Ze.find(e=>e.id===le)?.pickupLocation??null,{country:et,countries:Q,activeCountry:tt,formatMoney:dn}=Gn(),[w,pe]=o(()=>tn(c)[0]?.key??null),[nt,pn]=o(!0);y(()=>{pn(Vn(v))},[]);const[fe,S]=o(!1),[V,_e]=o(""),[L,Me]=o(""),[ee,Re]=o(""),[Le,rt]=o(""),[me,ye]=o(""),[$e,he]=o(""),[G,we]=o(""),[$,ge]=o(""),[te,ke]=o(""),[l,Ce]=o(()=>et||Q[0]?.code||""),[_,Ne]=o(""),[ne,ot]=o([]),[Fe,Ye]=o(null),[be,re]=o(null),ct=qt(()=>Q.find(e=>e.code===l)??tt,[Q,l,tt]),fn=ct?.postalLabel||"Postal Code",mn=ne[0]?.divisionType||"State / Province";y(()=>{if(!l){ot([]),Ye(l);return}Ye(null);let e=!1;return N.listCountrySubdivisions(l).then(t=>{e||(ot(t),Ye(l),Ne(""))}),()=>{e=!0}},[l]);const at=me.trim()!==""&&G.trim()!==""&&$.trim()!==""&&Fe===l&&(ne.length===0||_!=="")?$.trim():"";y(()=>{de(l?{country:l,subdivision:_,postcode:at}:null)},[l,_,at,de]),y(()=>()=>de(null),[de]);const yn=sn?.status==="unavailable",hn=un,[Pe,st]=o(null),[wn,it]=o([]),[ut,Be]=o("new"),[lt,dt]=o(!1),[Ue,gn]=o("Home"),[kn,pt]=o(null),[Cn,ft]=o(null),[oe,Se]=o(()=>ue()),mt=f(null),[yt,A]=o(null),[Nn,b]=o(null),[ht,Ae]=o(null),[wt,bn]=o(!1),[gt,Pn]=o(!1),[M,J]=o(null),[Sn,W]=o(!1),[g,x]=o(null),An=!!g?.orderNumber,[vn,K]=o(null),[xn,Kn]=o(!1),[On,kt]=o(!1),[En,Tn]=o(!1),[In,Ct]=o(!1),[Nt,_n]=o(!1),[Mn,He]=o(!1),[ze,bt]=o(null),F=f(null),ce=f(i),Y=f(null),X=f(null),Pt=!!(yt||ze&&ze.kind!=="processing"||Nt||wt||gt||ht&&M?.orderNumber);y(()=>{Pt&&(Qe([]),Ve())},[Pt,Qe,Ve]);const St=f(!1);y(()=>{p||St.current||!i.some(Gt)||(St.current=!0,Xn({lines:i,currency:I.currency,value:I.subtotal-I.discount,coupon:D?.valid?D.code:void 0}))},[i,I,D,p]),y(()=>{je(V,L.trim()||void 0)},[V,L,je]);const At=f(null),[ve,Rn]=o(null);y(()=>{const e=At.current;if(!ve||!e)return;const t=()=>e.style.setProperty("--sf-checkout-header-h",`${ve.offsetHeight}px`);t();const n=new ResizeObserver(t);return n.observe(ve),()=>n.disconnect()},[ve]),y(()=>{const e=n=>({setConfirming:n,land:A,markPaid:()=>W(!0),note:K,fail:b,clearCart:q}),t={search:window.location.search,storage:v,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};Jt(tr,{...t,capture:N.captureAfterpayPayment,page:e(Kn)}),Jt(rr,{...t,capture:N.captureZipPayment,page:e(Tn)})},[]),y(()=>{const t=new URLSearchParams(window.location.search).get("gocardless");if(t!=="confirm"&&t!=="cancel")return;const n=v.getItem(Ge);if(v.removeItem(Ge),window.history.replaceState(null,"",window.location.pathname),!n)return;let a;try{a=JSON.parse(n)}catch{return}if(q(),t==="cancel"){K("The direct debit was not set up — our team will follow up on payment."),A(a.confirmation);return}kt(!0),N.completeGocardlessPayment({idempotencyKey:a.idempotencyKey}).then(r=>{r.status==="paid"?W(!0):r.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(()=>{A(a.confirmation),kt(!1)})},[]),y(()=>{const e=new URLSearchParams(window.location.search),t=e.get("klarna");if(t!=="confirm"&&t!=="cancel")return;const n=v.getItem(Je);v.removeItem(Je);const a=e.get("authorization_token");if(window.history.replaceState(null,"",window.location.pathname),!n)return;let r;try{r=JSON.parse(n)}catch{return}if(q(),t==="cancel"||!a){K("The Klarna payment was not completed — our team will follow up on payment."),A(r.confirmation);return}Ct(!0),N.captureKlarnaPayment({idempotencyKey:r.idempotencyKey,authorizationToken:a}).then(u=>{u.status==="paid"?W(!0):u.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(()=>{A(r.confirmation),Ct(!1)})},[]);function vt(e){const[t,n]=en(e.address);ye(t),he(n),we(e.city),ge(e.zip_code),e.country&&Ce(e.country),e.phone&&ke(e.phone),re({country:e.country||null,state:e.state??""})}y(()=>{if(be){if((be.country||l)!==l){re(null);return}Fe===l&&(Ne(or(l,be.state,ne)),re(null))}},[be,l,Fe,ne]),y(()=>{let e=!1;return(async()=>{try{const[t,n,a]=await Promise.all([ie.me(),ie.myProfile().catch(()=>null),ie.myAddresses().catch(()=>[])]);if(e)return;st(t);const r=a.filter(d=>d.is_active);it(r),_e(t.email);const u=(n?.contact_name??"").split(/\s+/);Me(t.first_name||u[0]||""),Re(t.last_name||u.slice(1).join(" "));const s=t.phone||n?.phone;s&&ke(s);const k=r.find(d=>d.id===t.default_delivery_location)??r[0];if(k)Be(k.id),vt(k);else if(n){const[d,C]=en(n.address??"");ye(d),he(C),we(n.city??""),ge(n.zip_code??""),n.country&&Ce(n.country),re({country:n.country||null,state:n.state??""})}}catch{}})(),()=>{e=!0}},[]);function Ln(){ie.logout(),st(null),it([]),Be("new"),dt(!1),_e(""),Me(""),Re(""),rt(""),ye(""),he(""),we(""),ge(""),ke(""),Ce(et||Q[0]?.code||""),Ne(""),re(null)}const Z=qt(()=>tn(c,{canParkContext:nt}),[c,nt]);y(()=>{Z.some(e=>e.key===w)||pe(Z[0]?.key??null)},[Z,w]);const $n=Z.length===0,xe=$e.trim()?`${me}
3
+ ${$e.trim()}`:me,Fn=lr({email:V,firstName:L,lastName:ee,company:Le.trim(),phone:te,address:xe,city:G,subdivision:_,postcode:$,country:l,lines:i.map(e=>[e.id,e.qty]),shippingMethodId:le,couponCode:Vt(D),currency:I.currency,shopperId:Pe?.id??null}),h=JSON.stringify([Fn,w]),R=f(null),De=f(null),Ke=f(!1),O=f(!1),j=f(null),Oe=f(!1),P=f(h);P.current=h;const xt=f(fe);xt.current=fe;const Kt=()=>O.current&&P.current!==R.current,B=f(null);y(()=>{xt.current||(h!==B.current&&(B.current=null),!(!O.current||!g||g.orderNumber)&&(h===R.current||h===B.current||Ee(g)))},[h,g]);async function Ee(e){if(Oe.current)return null;Oe.current=!0,S(!0);try{const t=j.current?await ir(j.current):"none";if(t==="succeeded"||t==="processing")return O.current=!1,x(null),E("card"),t==="succeeded"?await U(void 0,e):$t(e),null;if(t===void 0||!ar.has(t))return B.current=P.current,x(e),b(t==="requires_action"?cr:Xe),null;const n=await jt(oe);if(n==="committed")return O.current=!1,x(null),E("card"),await U(void 0,e),null;if(n!=="released")return B.current=P.current,x(e),b(Xe),null;O.current=!1,j.current=null,B.current=null,b(null),x(null);const a=ue();return Se(a),a}finally{Oe.current=!1,S(!1)}}async function Yn(){if(!(p||fe||Oe.current)){if(g){if((O.current?h!==R.current:ae())&&!g.orderNumber){const a=await Ee(g);a&&P.current===h&&await Ot(a);return}S(!0),b(null),Ke.current=!1,await qe();const t=z(P.current)[1],n=g.orderNumber?t:"card";if(n&&rn.has(n)&&ae()&&z(P.current)[0]!==De.current){Et(g);return}E(n),n!==w&&pe(n),await Ft(g,n,!g.orderNumber);return}await Ot(oe)}}async function Ot(e){if(i.length===0||I.repricing||!w||!Z.some(s=>s.key===w))return;const t=i.filter(Gt).flatMap(s=>Qn(s.components,s.qty));if(t.length===0){b("Pick a size on each wheel's product page before checking out.");return}S(!0),b(null);let n,a=e,r=w,u=!1;try{const s=Pe?N.createOrderAuthed:N.createOrder,k=Wn(),d={customer:{email:V,name:`${L} ${ee}`.trim(),phone:te.trim()||void 0,companyName:Le.trim()||void 0,address:xe,city:G,state:_||void 0,zipCode:$,country:l},items:t,currency:I.currency,idempotencyKey:e,shippingMethodId:le??void 0,couponCode:Vt(D),...k==="denied"?{}:Jn(),...k?{adConsent:k}:{},...sr(w)?{checkoutFlow:Zt}:{}};F.current=()=>s(d),ft(null),De.current=null,Ke.current=!1,j.current=null,O.current=!1,B.current=null,R.current=h,ce.current=i;const C=Y.current,Ut=C?.key===d.idempotencyKey&&(C.shape!==h&&(!!d.checkoutFlow||!!C.method||!!C.plainMethod)||!!d.checkoutFlow&&!!C.plainMethod);Ut&&(X.current=d.idempotencyKey);const Ht=Mt(d,s),zt=Ut||!d.checkoutFlow&&X.current===d.idempotencyKey,Dt=!Ht&&!zt&&!d.checkoutFlow&&!!C&&!C.method;Dt&&(C.plainMethod=w,C.plainLines=i,C.plainShape=h);const H=await(zt?It(d,s):s(d).then(se=>({answer:se,request:d})).catch(se=>(Ht?Tt(se,d.idempotencyKey):Dt&&Qt(se)&&(C.plainMethod=""),Bn(se,d,s))));if(!H)return;n=H.answer,a=H.request.idempotencyKey,r=H.method??r,E(r),u=ae()||r!==z(P.current)[1],H.method&&H.method!==w&&pe(H.method),n.orderNumber&&(Rt(n),q()),await qe()}catch(s){const k=pr(s);k?(cn(k),b(`${k} Your order has not been placed. Place it again to continue without the code.`)):s instanceof Ie?b(Xe):b(s instanceof Te?s.message:"Could not place the order. Please try again."),S(!1);return}if(r&&rn.has(r)&&(u||ae())){Et(n);return}await Ft(n,r,!1,a)}function Et(e){De.current=z(P.current)[0],b(`${nn(e,null)} ${Xt}`),x(e),S(!1)}function Tt(e,t){Qt(e)&&!Wt(e)&&Y.current?.key===t&&(Y.current=null)}async function Bn(e,t,n){if(We(e))return _t(t,n);if(!Wt(e))throw e;return X.current=t.idempotencyKey,It(t,n,!0)}async function It(e,t,n=!1){const a=await jt(e.idempotencyKey);if(a==="released")return P.current===h?_t(e,t):(Se(ue()),S(!1),null);if(a!=="committed")throw new Ie;const r=Y.current?.key===e.idempotencyKey?Y.current:null;if(ce.current=r?.lines??i,r?.method&&!n){X.current=null,F.current=r.send;const k=await r.send().catch(()=>{throw new Ie});return R.current=r.shape,{answer:k,request:e,method:r.method}}const u=r&&!r.method?r.send:()=>t({...e,checkoutFlow:Zt});F.current=u;const s=await u().catch(()=>null);if(!s&&r?.plainMethod)throw new Ie;return s?.orderNumber&&s.status!==ur?(X.current=null,r?.plainMethod&&(ce.current=r.plainLines),r&&(R.current=r.plainMethod?r.plainShape:r.shape),{answer:s,request:e,method:r?.plainMethod||void 0}):(S(!1),r&&(R.current=r.shape),E("card"),await Lt("",s?async()=>s:()=>Promise.reject(new Error("The order request did not answer."))),await qe(),null)}function ae(){const e=R.current;return e!==null&&z(e)[0]!==z(P.current)[0]}function E(e){e!==z(P.current)[1]&&(Ke.current=!0),ft(Ke.current||ae()?Xt:null)}async function _t(e,t){const n={...e,idempotencyKey:ue()};X.current=null,Se(n.idempotencyKey),F.current=()=>t(n),Mt(n,t);try{return{answer:await t(n),request:n}}catch(a){throw Tt(a,n.idempotencyKey),a}}function Mt(e,t){return Y.current?.key===e.idempotencyKey?!1:(Y.current={key:e.idempotencyKey,send:()=>t(e),lines:i,shape:h,method:e.checkoutFlow?"":w??"",plainMethod:"",plainLines:i,plainShape:h},!0)}function Rt(e){Zn({confirmation:e,lines:ce.current,adsSendTo:c.googleAdsId&&c.googleAdsConversionLabel?`${c.googleAdsId}/${c.googleAdsConversionLabel}`:null}),jn({confirmation:e,lines:ce.current})}async function U(e,t=M){if(!t)return;const n=e?async()=>e:F.current;if(t.orderNumber||!n){W(!0),A(t);return}await Lt(t.checkoutNumber,n)}async function Lt(e,t){q(),await dr({checkoutNumber:e,resend:t,page:{setConfirming:_n,land:A,markPaid:()=>W(!0),track:Rt,unplaced:bt}})}function $t(e=M){if(e){if(e.orderNumber){A(e);return}q(),bt({kind:"processing",checkoutNumber:e.checkoutNumber})}}async function qe(){const e=JSON.stringify([Ue.trim(),L,ee,te.trim(),xe,G,_,$,l]);if(!(!Pe||!lt||ut!=="new"||mt.current===e))try{await ie.createAddress({label:Ue.trim()||"Home",contact_name:`${L} ${ee}`.trim(),phone:te.trim(),address:xe,city:G,zip_code:$,state:_,country:l}),mt.current=e,pt("Address saved to your account.")}catch{pt("We couldn't save the address to your account — you can add it under Account → Addresses.")}}async function Ft(e,t=w,n=!1,a=oe){x(null);try{if(t==="card"&&c.paymentMethods.includes("card")){const r=await N.createPaymentIntent({idempotencyKey:a});if(j.current=r,n&&Kt()){await Ee(e);return}let u=e;if(n){const s=await F.current?.().catch(()=>null);if(s?.orderNumber){E("card"),await U(s,e);return}if(u=Yt(e,s)??{...e,expiresAt:null},Kt()){await Ee(e);return}}E("card"),J(u),He(!1),Ae(r)}else if(t==="paypal"&&c.paymentMethods.includes("paypal"))J(e),bn(!0);else if(t==="afterpay"&&c.paymentMethods.includes("afterpay")){const r=window.location.origin,u=await N.createAfterpayCheckout({idempotencyKey:a,confirmUrl:`${r}/checkout?afterpay=confirm`,cancelUrl:`${r}/checkout?afterpay=cancel`}),s={idempotencyKey:a,confirmation:e};v.setItem(er,JSON.stringify(s)),window.location.assign(u.redirectCheckoutUrl);return}else if(t==="square"&&c.paymentMethods.includes("square"))J(e),Pn(!0);else if(t==="gocardless"&&c.paymentMethods.includes("gocardless")){const r=window.location.origin,u=await N.createGocardlessBillingRequest({idempotencyKey:a,confirmUrl:`${r}/checkout?gocardless=confirm`,cancelUrl:`${r}/checkout?gocardless=cancel`}),s={idempotencyKey:a,confirmation:e};v.setItem(Ge,JSON.stringify(s)),window.location.assign(u.authorisationUrl);return}else if(t==="zip"&&c.paymentMethods.includes("zip")){const r=window.location.origin,u=await N.createZipCheckout({idempotencyKey:a,redirectUrl:`${r}/checkout?zip=return`}),s={idempotencyKey:a,confirmation:e};v.setItem(nr,JSON.stringify(s)),window.location.assign(u.redirectUrl);return}else if(t==="klarna"&&c.paymentMethods.includes("klarna")){const r=window.location.origin,u=await N.createKlarnaCheckout({idempotencyKey:a,confirmUrl:`${r}/checkout?klarna=confirm`,cancelUrl:`${r}/checkout?klarna=cancel`}),s={idempotencyKey:a,confirmation:e};v.setItem(Je,JSON.stringify(s)),window.location.assign(u.redirectUrl);return}else E(t),A(e)}catch(r){if((n||t==="card")&&r instanceof Te&&r.status===409){E(t),await U(void 0,e);return}Bt(e,r),S(!1)}}function Yt(e,t){return t&&!t.orderNumber&&t.status==="open"&&t.checkoutNumber===e.checkoutNumber?t:null}function Bt(e,t){b(nn(e,t)),!e.orderNumber&&We(t)?(O.current=!1,Se(ue())):x(e)}async function Un(e){if(!M)return;const t=M;try{const n=await N.createPaymentIntent({idempotencyKey:oe}),a=await F.current?.().catch(()=>null);if(a?.orderNumber){await U(a);return}const r=Yt(t,a);J(r??{...t,expiresAt:null}),He(e&&r!==null),j.current=n,Ae(n)}catch(n){if(n instanceof Te&&n.status===409){await U();return}Ae(null),J(null),Bt(t,n),S(!1)}}function Hn(){M&&(O.current=!0,x(M),Ae(null),J(null),He(!1),S(!1))}return{site:c,logo:m,items:i,totals:I,coupon:D,deliveryOptions:Ze,courierUnavailable:yn,retryCourier:hn,shippingMethodId:le,setShippingMethodId:an,pickupLocation:ln,servedCountries:Q,formatMoney:dn,payChoice:w,setPayChoice:pe,placing:fe,email:V,setEmail:_e,firstName:L,setFirstName:Me,lastName:ee,setLastName:Re,company:Le,setCompany:rt,address1:me,setAddress1:ye,address2:$e,setAddress2:he,city:G,setCity:we,postcode:$,setPostcode:ge,phone:te,setPhone:ke,country:l,setCountry:Ce,subdivision:_,setSubdivision:Ne,subdivisions:ne,destination:ct,postcodeLabel:fn,subdivisionLabel:mn,me:Pe,savedAddresses:wn,selectedAddressId:ut,setSelectedAddressId:Be,saveAddress:lt,setSaveAddress:dt,saveLabel:Ue,setSaveLabel:gn,addressSaveNote:kn,lostChangeNote:Cn,idemKey:oe,confirmation:yt,setConfirmation:A,orderError:Nn,payment:ht,paypalStep:wt,squareStep:gt,pendingConf:M,paid:Sn,setPaid:W,unpaidOrder:g,orderLocked:An,payNote:vn,afterpayConfirming:xn,gocardlessConfirming:On,zipConfirming:En,klarnaConfirming:In,cardConfirming:Nt,checkoutResult:ze,confirmCardPayment:U,cardStillProcessing:$t,renewCardPayment:Un,holdRenewed:Mn,leaveCardPayment:Hn,checkoutRootRef:At,setCheckoutHeaderEl:Rn,fillFromAddress:vt,checkoutSignOut:Ln,payOptions:Z,noPaymentMethod:$n,placeOrder:Yn}}const on=zn(null);function Mr({children:c,...m}){const p=fr(m);return T(on.Provider,{value:p,children:c})}function Rr(){const c=Dn(on);if(!c)throw new Error("useCheckout must be used inside CheckoutStateProvider");return c}export{Mr as CheckoutStateProvider,Tr as NO_PAYMENT_METHOD_NOTE,Ir as SHIPPING_RETRY_NOTE,tn as buildPayOptions,nn as paymentNotStartedMessage,_r as placedOrderLockNote,Rr as useCheckout};
@@ -5,8 +5,7 @@ export declare const supportedKinds: readonly ProductKind[];
5
5
  interface Props {
6
6
  rowsFrom?: "story" | "details";
7
7
  startLeft?: boolean;
8
- padTop?: number;
9
- padBottom?: number;
8
+ pads?: Record<string, unknown>;
10
9
  editing?: boolean;
11
10
  template?: unknown;
12
11
  nodeId?: string;
@@ -1 +1 @@
1
- "use client";import{jsx as s}from"react/jsx-runtime";import D from"../SectionBand.js";import h from"../DetailRows.js";import x from"./KindGate.js";import b from"./RecordPhotoGallery.js";import{useCurrentProduct as k}from"../../lib/document/current-product.js";import{SAMPLE_RECORD as S,recordFacts as B,recordPictures as w,useCurrentRecord as P,useDrawsOtherRecord as T}from"../../lib/document/current-record.js";import{detailShotTag as v,pickDetailShots as N}from"../../lib/wheels/detail-shots.js";import{selectedStuds as C}from"../../lib/wheels/selected-studs.js";import{useSampleProduct as F}from"./useSampleProduct.js";import{say as L}from"efficient-web-builder/format/lib/editor-words";const j=["alloy-wheel"];function g(e,i){return e.finishes.find(t=>t.name===i)??e.finishes[0]}function E(e,i){return(g(e,i)?.features??[]).map(t=>({eyebrow:t.eyebrow,title:t.heading,copy:t.description,tag:t.mark,image:t.image||void 0}))}function G(e,i,t){const r=N(g(e,i),t);return r.rows.map(o=>({eyebrow:o.eyebrow?.trim()||void 0,title:o.title,copy:o.line||void 0,image:o.url,tag:v(o,r,t),imageShape:"square"}))}function I(e){return T(!!e.editing)?s(K,{...e}):s(x,{kinds:j,type:"DetailRows",editing:e.editing,children:s(O,{...e})})}function y(e){const i=B(e),t=w(e)[0];return!i.length&&!t&&!e.title.trim()?[]:[{title:e.title,specs:i,image:t?.url||void 0}]}function K({startLeft:e,padTop:i,padBottom:t,editing:r=!1,template:o,nodeId:c}){const a=P(),n=a?y(a):r?y(S):[];if(n.length===0)return null;const l=a?w(a,{firstField:!0}):[];return l.length&&(n[0]={...n[0],media:s(b,{pictures:l,name:a?.title??"",editing:r,fit:"column"})}),s(h,{rows:n,startLeft:e,padTop:i,padBottom:t,editing:r,template:o,nodeId:c})}function O({rowsFrom:e,startLeft:i,padTop:t,padBottom:r,editing:o=!1,template:c,nodeId:a}){const n=k(),l=F(o&&!n),u=n?.product??l,d=u?.kind==="alloy-wheel"?u.source:null,m=n?n.selection.shown.finish:void 0,R=n?C(n.selection):null,p=e==="details",f=d?p?G(d,m,R):E(d,m):[];return p&&f.length===0?o?s(D,{className:"border-b border-line py-14 max-view-desktop:py-10",children:s("p",{className:"font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.18em] text-fg-dim",children:L("No detail shots on this finish yet. Tick a close-up on the design's renderings and give it a title. This section is hidden on the live page until then.")})}):null:s(h,{rows:f,startLeft:i,padTop:t,padBottom:r,editing:o,template:c,nodeId:a})}export{I as default,y as recordDetailRows,j as supportedKinds};
1
+ "use client";import{jsx as s}from"react/jsx-runtime";import R from"../SectionBand.js";import p from"../DetailRows.js";import D from"./KindGate.js";import x from"./RecordPhotoGallery.js";import{useCurrentProduct as b}from"../../lib/document/current-product.js";import{SAMPLE_RECORD as k,recordFacts as S,recordPictures as h,useCurrentRecord as P,useDrawsOtherRecord as v}from"../../lib/document/current-record.js";import{detailShotTag as N,pickDetailShots as B}from"../../lib/wheels/detail-shots.js";import{selectedStuds as C}from"../../lib/wheels/selected-studs.js";import{useSampleProduct as F}from"./useSampleProduct.js";import{say as L}from"efficient-web-builder/format/lib/editor-words";const T=["alloy-wheel"];function w(e,i){return e.finishes.find(t=>t.name===i)??e.finishes[0]}function j(e,i){return(w(e,i)?.features??[]).map(t=>({eyebrow:t.eyebrow,title:t.heading,copy:t.description,tag:t.mark,image:t.image||void 0}))}function E(e,i,t){const r=B(w(e,i),t);return r.rows.map(o=>({eyebrow:o.eyebrow?.trim()||void 0,title:o.title,copy:o.line||void 0,image:o.url,tag:N(o,r,t),imageShape:"square"}))}function G(e){return v(!!e.editing)?s(I,{...e}):s(D,{kinds:T,type:"DetailRows",editing:e.editing,children:s(K,{...e})})}function g(e){const i=S(e),t=h(e)[0];return!i.length&&!t&&!e.title.trim()?[]:[{title:e.title,specs:i,image:t?.url||void 0}]}function I({startLeft:e,pads:i,editing:t=!1,template:r,nodeId:o}){const l=P(),n=l?g(l):t?g(k):[];if(n.length===0)return null;const a=l?h(l,{firstField:!0}):[];return a.length&&(n[0]={...n[0],media:s(x,{pictures:a,name:l?.title??"",editing:t,fit:"column"})}),s(p,{rows:n,startLeft:e,pads:i,editing:t,template:r,nodeId:o})}function K({rowsFrom:e,startLeft:i,pads:t,editing:r=!1,template:o,nodeId:l}){const n=b(),a=F(r&&!n),d=n?.product??a,c=d?.kind==="alloy-wheel"?d.source:null,u=n?n.selection.shown.finish:void 0,y=n?C(n.selection):null,m=e==="details",f=c?m?E(c,u,y):j(c,u):[];return m&&f.length===0?r?s(R,{className:"border-b border-line py-14 max-view-desktop:py-10",children:s("p",{className:"font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.18em] text-fg-dim",children:L("No detail shots on this finish yet. Tick a close-up on the design's renderings and give it a title. This section is hidden on the live page until then.")})}):null:s(p,{rows:f,startLeft:i,pads:t,editing:r,template:o,nodeId:l})}export{G as default,g as recordDetailRows,T as supportedKinds};
@@ -15,8 +15,7 @@ export interface DynamicGalleryGridProps {
15
15
  styleOwner?: string;
16
16
  editing?: boolean;
17
17
  omitHead?: boolean;
18
- padTop?: number;
19
- padBottom?: number;
18
+ pads?: Record<string, unknown>;
20
19
  }
21
20
  export default function DynamicGalleryGrid(props: DynamicGalleryGridProps): import("react").JSX.Element;
22
21
  export declare function SourcedGalleryGrid(props: DynamicGalleryGridProps & {
@@ -1 +1 @@
1
- "use client";import{jsx as t,jsxs as S}from"react/jsx-runtime";import C from"efficient-web-builder/render/components/Btn";import j,{GALLERY_GRID_ATTR as D,GalleryLinksContext as F}from"../GalleryItem.js";import{SharedPartKinds as K}from"efficient-web-builder/render/components/PublishedPartStylesContext";import{renderHeadline as U}from"efficient-web-builder/render/components/goldPhrases";import Z from"efficient-web-builder/render/components/SectionHeader";import $ from"./KindGate.js";import z from"./RecordPhotoGallery.js";import{headIsEmpty as V,ownPadding as W}from"../../lib/sections/own-padding.js";import{PLP_KINDS as X}from"../../lib/catalog/plp-item.js";import{useCurrentProduct as Y}from"../../lib/document/current-product.js";import{SAMPLE_PICTURE_COUNT as L,SAMPLE_RECORD as q,recordPictures as J,useCurrentRecord as Q,useDrawsOtherRecord as ee}from"../../lib/document/current-record.js";import{mediaGroupVehicle as re}from"../../lib/content/source-values.js";import{IMAGE_ZONES as M}from"../../lib/sections/product-pictures.js";import{useSampleProduct as te}from"./useSampleProduct.js";import{say as _}from"efficient-web-builder/format/lib/editor-words";import{galleryLayoutRatio as ie,resolveGalleryLayout as oe}from"efficient-web-builder/format/lib/content/gallery-layout";import{HideTaker as T}from"efficient-web-builder/render/components/ViewHideRoot";const ae=X;function ne(e,o){if(!e)return[];if(o==="all")return M.flatMap(n=>e[n]??[]);const r=M.includes(o)?o:null;return r?e[r]??[]:[]}const k="relative z-[2] bg-bg py-[120px] max-view-wide:py-[70px]",I="relative z-[2] bg-bg pt-0 pb-[120px] max-view-wide:pt-0 max-view-wide:pb-[70px]",H="mx-auto max-w-[var(--sf-site-width,1600px)] px-[var(--sf-site-gutter,40px)] max-view-wide:px-[min(20px,var(--sf-site-gutter,40px))]";function se(e){return ee(!!e.editing)?t(le,{...e}):t($,{kinds:ae,type:"GalleryB",editing:e.editing,children:t(me,{...e})})}function le(e){const{editing:o=!1}=e,r=Q(),n=r?J(r,{firstField:!0}).map(a=>({images:[a.url],eyebrow:a.alt&&a.alt!==r.title?a.alt:void 0,...a.video?{video:a.video}:{}})):o?Array.from({length:L},()=>({images:[""]})):[];return t(A,{...e,tiles:n,owner:{name:(r??q).title},photosOnly:!0,emptyHint:_("This record’s pictures appear here on its page. A record with no pictures draws nothing.")})}function Ee(e){const{rows:o,limit:r,layout:n,editing:a=!1,title:h}=e,d=oe(n),c=typeof r=="number"&&r>0?Math.floor(r):void 0,p=o.filter(s=>typeof s.cover=="string"&&s.cover).map(s=>({images:[s.cover],...s.video?{video:s.video}:{}})),g=a&&p.length===0?Array.from({length:c??L},()=>({images:[""]})):p;return t(A,{...e,tiles:c?g.slice(0,c):g,owner:{name:(h??"").replace(/==/g,"").trim()},photosOnly:!0,tilesAcross:d?.across===3?3:4,tileRatio:d?ie(d):null,emptyHint:_("The website’s pictures appear here, in the order they are put in. A website with no pictures draws nothing.")})}function me({omitHead:e=!1,num:o,title:r,linkText:n,linkHref:a,galleryHref:h="/gallery",submitHref:d="/contact",zone:c="all",photoDisplay:p="covers",previewHover:g,display:s,displayPhone:y,styleOwner:v,editing:f=!1,padTop:G,padBottom:x}){const w=Y(),N=te(f&&!w),u=w?.product??N,b=ne(u?.mediaGroups,c).map(i=>({images:(i.items??[]).filter(m=>m.kind==="image").map(m=>m.url),vehicle:re(i),finish:i.finish})).filter(i=>i.images.length>0),P=(p==="auto"?b.length>=4?"covers":"all":p)==="all"?b.flatMap(i=>i.images.map(m=>({images:[m],vehicle:i.vehicle,finish:i.finish}))):b;return t(A,{omitHead:e,num:o,title:r,linkText:n,linkHref:a,galleryHref:h,submitHref:d,previewHover:g,display:s,displayPhone:y,styleOwner:v,editing:f,padTop:G,padBottom:x,tiles:u?P.map(i=>({images:i.images,eyebrow:i.vehicle||void 0,meta:i.finish})):[],owner:{name:u?.name??"",href:u?.href,process:u?.eyebrow},emptyHint:_("This product’s photos appear here on a product page. Add media groups in the product’s Media tab.")})}function A({omitHead:e=!1,num:o,title:r,linkText:n,linkHref:a,galleryHref:h="/gallery",submitHref:d="/contact",previewHover:c,display:p,displayPhone:g,styleOwner:s,editing:y=!1,tiles:v,owner:f,emptyHint:G,photosOnly:x=!1,tilesAcross:w,tileRatio:N=null,padTop:u,padBottom:b}){const R=n?{text:n,href:a||"#"}:void 0,P=r?U(r,!1):void 0,i=e?null:t(Z,{num:o,title:P,link:R}),m=!y&&V(o,r,R?.text)?null:i,E=W(u,b);return v.length===0?y?t(T,{as:"section",className:e?I:k,style:E,children:S("div",{className:H,children:[m,t("p",{className:"mt-8 border-t border-line py-6 font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.18em] text-fg-dim",children:G})]})}):null:t(T,{as:"section",className:e?I:k,style:E,children:S("div",{className:H,children:[m,x?t(z,{pictures:v.map(l=>({url:l.images[0]??"",alt:l.eyebrow,video:l.video})),name:f.name,editing:y,...w?{fit:"tiles",across:w,ratio:N}:{}}):t(F.Provider,{value:{galleryHref:h,submitHref:d,previewHover:c,display:p,displayPhone:g,styleOwner:s,photosOnly:x},children:t(K,{children:t("div",{[D]:"",className:"grid grid-cols-4 gap-2 max-[1500px]:grid-cols-3 max-view-wide:grid-cols-1 max-view-wide:gap-1",children:v.map((l,O)=>t(j,{image:l.images[0],photos:l.images.slice(1).map(B=>({src:B})),href:f.href,process:f.process,eyebrow:l.eyebrow,name:f.name,meta:l.meta,editing:y},`${l.eyebrow}-${O}`))})})}),!x&&t("div",{className:"mt-12 flex flex-col items-center gap-3",children:t(C,{href:h,variant:"ghost",children:"See Gallery"})})]})})}export{Ee as SourcedGalleryGrid,se as default,ae as supportedKinds};
1
+ "use client";import{jsx as t,jsxs as M}from"react/jsx-runtime";import C from"efficient-web-builder/render/components/Btn";import H,{GALLERY_GRID_ATTR as O,GalleryLinksContext as F}from"../GalleryItem.js";import{SharedPartKinds as j}from"efficient-web-builder/render/components/PublishedPartStylesContext";import{renderHeadline as D}from"efficient-web-builder/render/components/goldPhrases";import K from"efficient-web-builder/render/components/SectionHeader";import U from"./KindGate.js";import Z from"./RecordPhotoGallery.js";import{FRAME_120 as $,framedBandPad as z,headIsEmpty as V,withBandClasses as W}from"../../lib/sections/band-padding.js";import{PLP_KINDS as X}from"../../lib/catalog/plp-item.js";import{useCurrentProduct as Y}from"../../lib/document/current-product.js";import{SAMPLE_PICTURE_COUNT as S,SAMPLE_RECORD as q,recordPictures as J,useCurrentRecord as Q,useDrawsOtherRecord as ee}from"../../lib/document/current-record.js";import{mediaGroupVehicle as re}from"../../lib/content/source-values.js";import{IMAGE_ZONES as L}from"../../lib/sections/product-pictures.js";import{useSampleProduct as te}from"./useSampleProduct.js";import{say as A}from"efficient-web-builder/format/lib/editor-words";import{galleryLayoutRatio as ie,resolveGalleryLayout as ae}from"efficient-web-builder/format/lib/content/gallery-layout";import{HideTaker as T}from"efficient-web-builder/render/components/ViewHideRoot";const oe=X;function se(e,a){if(!e)return[];if(a==="all")return L.flatMap(s=>e[s]??[]);const r=L.includes(a)?a:null;return r?e[r]??[]:[]}const ne="relative z-[2] bg-bg py-[120px] max-view-wide:py-[70px]",le="relative z-[2] bg-bg pt-0 pb-[120px] max-view-wide:pt-0 max-view-wide:pb-[70px]",k="mx-auto max-w-[var(--sf-site-width,1600px)] px-[var(--sf-site-gutter,40px)] max-view-wide:px-[min(20px,var(--sf-site-gutter,40px))]";function me(e){return ee(!!e.editing)?t(de,{...e}):t(U,{kinds:oe,type:"GalleryB",editing:e.editing,children:t(ce,{...e})})}function de(e){const{editing:a=!1}=e,r=Q(),s=r?J(r,{firstField:!0}).map(o=>({images:[o.url],eyebrow:o.alt&&o.alt!==r.title?o.alt:void 0,...o.video?{video:o.video}:{}})):a?Array.from({length:S},()=>({images:[""]})):[];return t(E,{...e,tiles:s,owner:{name:(r??q).title},photosOnly:!0,emptyHint:A("This record’s pictures appear here on its page. A record with no pictures draws nothing.")})}function Se(e){const{rows:a,limit:r,layout:s,editing:o=!1,title:h}=e,d=ae(s),c=typeof r=="number"&&r>0?Math.floor(r):void 0,p=a.filter(n=>typeof n.cover=="string"&&n.cover).map(n=>({images:[n.cover],...n.video?{video:n.video}:{}})),g=o&&p.length===0?Array.from({length:c??S},()=>({images:[""]})):p;return t(E,{...e,tiles:c?g.slice(0,c):g,owner:{name:(h??"").replace(/==/g,"").trim()},photosOnly:!0,tilesAcross:d?.across===3?3:4,tileRatio:d?ie(d):null,emptyHint:A("The website’s pictures appear here, in the order they are put in. A website with no pictures draws nothing.")})}function ce({omitHead:e=!1,num:a,title:r,linkText:s,linkHref:o,galleryHref:h="/gallery",submitHref:d="/contact",zone:c="all",photoDisplay:p="covers",previewHover:g,display:n,displayPhone:y,styleOwner:x,editing:f=!1,pads:G}){const v=Y(),b=te(f&&!v),u=v?.product??b,w=se(u?.mediaGroups,c).map(i=>({images:(i.items??[]).filter(m=>m.kind==="image").map(m=>m.url),vehicle:re(i),finish:i.finish})).filter(i=>i.images.length>0),R=(p==="auto"?w.length>=4?"covers":"all":p)==="all"?w.flatMap(i=>i.images.map(m=>({images:[m],vehicle:i.vehicle,finish:i.finish}))):w;return t(E,{omitHead:e,num:a,title:r,linkText:s,linkHref:o,galleryHref:h,submitHref:d,previewHover:g,display:n,displayPhone:y,styleOwner:x,editing:f,pads:G,tiles:u?R.map(i=>({images:i.images,eyebrow:i.vehicle||void 0,meta:i.finish})):[],owner:{name:u?.name??"",href:u?.href,process:u?.eyebrow},emptyHint:A("This product’s photos appear here on a product page. Add media groups in the product’s Media tab.")})}function E({omitHead:e=!1,num:a,title:r,linkText:s,linkHref:o,galleryHref:h="/gallery",submitHref:d="/contact",previewHover:c,display:p,displayPhone:g,styleOwner:n,editing:y=!1,tiles:x,owner:f,emptyHint:G,photosOnly:v=!1,tilesAcross:b,tileRatio:u=null,pads:w}){const N=s?{text:s,href:o||"#"}:void 0,R=r?D(r,!1):void 0,i=e?null:t(K,{num:a,title:R,link:N}),m=!y&&V(a,r,N?.text)?null:i,_=z(w,$,{noTop:e,nonNegative:!0}),P=W(e?le:ne,_);return x.length===0?y?t(T,{as:"section",className:P,style:_.style,children:M("div",{className:k,children:[m,t("p",{className:"mt-8 border-t border-line py-6 font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.18em] text-fg-dim",children:G})]})}):null:t(T,{as:"section",className:P,style:_.style,children:M("div",{className:k,children:[m,v?t(Z,{pictures:x.map(l=>({url:l.images[0]??"",alt:l.eyebrow,video:l.video})),name:f.name,editing:y,...b?{fit:"tiles",across:b,ratio:u}:{}}):t(F.Provider,{value:{galleryHref:h,submitHref:d,previewHover:c,display:p,displayPhone:g,styleOwner:n,photosOnly:v},children:t(j,{children:t("div",{[O]:"",className:"grid grid-cols-4 gap-2 max-[1500px]:grid-cols-3 max-view-wide:grid-cols-1 max-view-wide:gap-1",children:x.map((l,I)=>t(H,{image:l.images[0],photos:l.images.slice(1).map(B=>({src:B})),href:f.href,process:f.process,eyebrow:l.eyebrow,name:f.name,meta:l.meta,editing:y},`${l.eyebrow}-${I}`))})})}),!v&&t("div",{className:"mt-12 flex flex-col items-center gap-3",children:t(C,{href:h,variant:"ghost",children:"See Gallery"})})]})})}export{Se as SourcedGalleryGrid,me as default,oe as supportedKinds};
@@ -34,6 +34,7 @@ export interface ProductSelection {
34
34
  set: number;
35
35
  msrpLabel: string | null;
36
36
  }
37
- export declare function useProductSelection(product: StoreProduct, { editing, }?: {
37
+ export declare function useProductSelection(product: StoreProduct, { editing, defaultVariant, }?: {
38
38
  editing?: boolean;
39
+ defaultVariant?: number | null;
39
40
  }): ProductSelection;
@@ -1 +1 @@
1
- "use client";import{useEffect as _,useState as c}from"react";import{useCurrency as j}from"./CurrencyContext.js";import{useVehicleFit as D}from"./fitment/useVehicleFit.js";import{askableOptions as G,resolvePart as H,shownOptions as N,staleOptions as R,statedOptions as z}from"../lib/catalog/product-options.js";import{wheelForVehicle as B}from"../lib/catalog/from-wheel.js";import{DEFAULT_PURCHASE_STATE as y,purchaseOffer as J,vehicleGate as K}from"../lib/catalog/purchase.js";import{formatSelectionWasPrice as X,resolveSelectionPrice as Y}from"../lib/wheels/price-display.js";import{isPreOrderWheel as Z}from"../lib/wheels/pre-order.js";function ae(t,{editing:P=!1}={}){const[o,d]=c({}),[l,v]=c(y.qty),[h,A]=c(y.choice),[O,T]=c(0),[x,C]=c(!1),[a,E]=c(!1),p=D({editing:P,autoApply:!0}),s=B(t,a?null:p.fit),S=G(s,o),M=z(s,o),V=N(s,o),e=H(s,o),q=e!=null&&!e.inStock,f=R(s,o).join("|");_(()=>{if(!f)return;const r=new Set(f.split("|"));d(m=>{const i={...m};for(const W of r)delete i[W];return i})},[f]);const{currency:u}=j(),k=J(s,e,{choice:h,qty:l}),n=Y({prices:t.anchorPrices,msrpPrices:t.anchorMsrpPrices},e?{components:k.components}:null,u,l),F=n.unit??0,Q=n.setTotal??0,b=X(n,u),w=a||p.appliedName!=="",g=K(t)==="required"?w:!0,I=S.every(r=>r.chosen!==null)&&g&&e!=null&&e.inStock&&n.priced,L=Z({variants:t.parts,inStock:t.inStock,priced:n.priced});function U(r,m){d(i=>({...i,[r]:m}))}return{picked:o,shown:V,pick:U,qty:l,setQty:v,choice:h,setChoice:A,angleIdx:O,setAngleIdx:T,showValidation:x,setShowValidation:C,manualMode:a,setManualMode:E,vehicle:p,fitmentSet:w,rows:S,facts:M,part:e,outOfStock:q,offer:k,preOrder:L,canAddToCart:I,currency:u,price:n,unit:F,set:Q,msrpLabel:b}}export{ae as useProductSelection};
1
+ "use client";import{useEffect as j,useState as r}from"react";import{useCurrency as D}from"./CurrencyContext.js";import{useVehicleFit as G}from"./fitment/useVehicleFit.js";import{askableOptions as H,resolvePart as N,shownOptions as R,staleOptions as z,statedOptions as B}from"../lib/catalog/product-options.js";import{picksForVariant as J}from"../lib/catalog/default-variant.js";import{wheelForVehicle as K}from"../lib/catalog/from-wheel.js";import{DEFAULT_PURCHASE_STATE as y,purchaseOffer as X,vehicleGate as Y}from"../lib/catalog/purchase.js";import{formatSelectionWasPrice as Z,resolveSelectionPrice as $}from"../lib/wheels/price-display.js";import{isPreOrderWheel as ee}from"../lib/wheels/pre-order.js";function me(e,{editing:P=!1,defaultVariant:v=null}={}){const[o,d]=r(()=>J(e,v)),[l,A]=r(y.qty),[h,O]=r(y.choice),[T,V]=r(0),[x,C]=r(!1),[a,E]=r(!1),p=G({editing:P,autoApply:!0}),n=K(e,a?null:p.fit),S=H(n,o),F=B(n,o),M=R(n,o),t=N(n,o),q=t!=null&&!t.inStock,f=z(n,o).join("|");j(()=>{if(!f)return;const c=new Set(f.split("|"));d(u=>{const i={...u};for(const _ of c)delete i[_];return i})},[f]);const{currency:m}=D(),k=X(n,t,{choice:h,qty:l}),s=$({prices:e.anchorPrices,msrpPrices:e.anchorMsrpPrices},t?{components:k.components}:null,m,l),Q=s.unit??0,b=s.setTotal??0,g=Z(s,m),w=a||p.appliedName!=="",I=Y(e)==="required"?w:!0,L=S.every(c=>c.chosen!==null)&&I&&t!=null&&t.inStock&&s.priced,U=ee({variants:e.parts,inStock:e.inStock,priced:s.priced});function W(c,u){d(i=>({...i,[c]:u}))}return{picked:o,shown:M,pick:W,qty:l,setQty:A,choice:h,setChoice:O,angleIdx:T,setAngleIdx:V,showValidation:x,setShowValidation:C,manualMode:a,setManualMode:E,vehicle:p,fitmentSet:w,rows:S,facts:F,part:t,outOfStock:q,offer:k,preOrder:U,canAddToCart:L,currency:m,price:s,unit:Q,set:b,msrpLabel:g}}export{me as useProductSelection};
@@ -25,7 +25,9 @@ export interface AlloyWheelsListingProps {
25
25
  editing?: boolean;
26
26
  ownerId?: string;
27
27
  template?: SlotComponent;
28
- facetTemplate?: SlotComponent;
28
+ facetTemplate: SlotComponent;
29
+ railTemplate: SlotComponent;
30
+ railHeadTemplate: SlotComponent;
29
31
  omitHead?: boolean;
30
32
  hover?: CardHoverDrawn;
31
33
  }
@@ -33,4 +35,4 @@ export declare const PLP_GATE_DEFAULTS: {
33
35
  readonly heading: "Let's find wheels that fit your car.";
34
36
  readonly intro: "Tell us what you drive and we'll show you every set that bolts straight on — bolt pattern, offset and hub bore checked for you.";
35
37
  };
36
- export default function AlloyWheelsListing({ heading, intro, askForCar, gateHeading, gateIntro, perPage, columns, defaultSort, hiddenFacets, fieldUsage, showPrice, showInStock, kinds, products, wheels, requestQuery, editing, ownerId, template, facetTemplate, hover, titleLevel, omitHead, }: AlloyWheelsListingProps): import("react").JSX.Element | null;
38
+ export default function AlloyWheelsListing({ heading, intro, askForCar, gateHeading, gateIntro, perPage, columns, defaultSort, hiddenFacets, fieldUsage, showPrice, showInStock, kinds, products, wheels, requestQuery, editing, ownerId, template, facetTemplate, railTemplate, railHeadTemplate, hover, titleLevel, omitHead, }: AlloyWheelsListingProps): import("react").JSX.Element | null;
@@ -1 +1 @@
1
- "use client";import{jsx as o,jsxs as c,Fragment as qe}from"react/jsx-runtime";import{useScopeClass as Je}from"../../lib/use-scope-class.js";import{useCallback as d,useEffect as Qe,useMemo as i,useRef as Ue,useState as Xe}from"react";import{cardHoverOf as Ze}from"efficient-web-builder/format/lib/animation/hover";import{pageTitleTag as et}from"efficient-web-builder/format/lib/document/one-h1";import{SHARED_ROWS_LIST_CLASS as tt}from"efficient-web-builder/render/lib/content/box-shared-columns";import{NO_FIELD_ANSWERS as ot,answersForKind as ie}from"../../lib/content/field-usage.js";import{useCurrency as rt}from"../CurrencyContext.js";import nt from"../NoCurrencyNote.js";import{usePreviewDevice as st}from"efficient-easel/screen/components/PreviewDeviceContext";import{renderGold as it,renderHeadline as lt}from"efficient-web-builder/render/components/goldPhrases";import{useUnifiedProductCatalog as ct}from"../useProductCatalog.js";import{scrollBehavior as at}from"efficient-web-builder/render/components/useReducedMotion";import{normalizePlpColumns as pt,PLP_GRID_GAP_VAR as le,plpGridVars as dt}from"../../lib/wheels/plp-grid.js";import{plpCardImageSizes as mt}from"../../lib/sections/card-image-sizes.js";import{CARD_ROWS_GRID_CLASS as ut,cardRowsGridStyle as ht}from"../WheelCardFrame.js";import{applyPlpFilters as ft,buildPlpFacets as gt,buildPlpTypeOptions as yt,buildTyreSizeBoxes as St,EMPTY_PLP_FILTERS as ce,hasActivePlpFilters as xt,paginatePlp as bt,pickTyreSize as wt,plpTyreSizeBoxesShown as kt,plpInStockCount as vt,plpOpeningSort as Pt,plpPriceBounds as Nt,plpShownKinds as Ct,plpSortKeysFor as Tt,PLP_SORT_LABELS as _t}from"../../lib/wheels/plp-filters.js";import{itemKind as z,itemSlug as At,itemTyreSizes as zt,plpBrandVaries as Lt,plpProcessVaries as Mt,plpItemsOfKinds as Ot,plpKindNoun as ae,resolvePlpKinds as Ft}from"../../lib/catalog/plp-item.js";import{plpGateWords as Rt,plpVehicleCopy as Vt}from"../../lib/catalog/plp-vehicle-copy.js";import{oemBadgeSize as Gt,oemTyreSizes as It}from"../../lib/tyres/tyre-vehicle-fitment.js";import{wheelsFittingVehicle as jt}from"../../lib/wheels/plp-fitment-match.js";import Et from"./PlpActiveChips.js";import{GridCardProvider as Kt,GridMixedCards as Bt,gridIndexCss as Dt,LISTING_CARD_RULES as Wt}from"../GridCardTemplate.js";import{wheelCardEyebrowShows as $t}from"../ProductCardEyebrow.js";import Ht from"./PlpPagination.js";import Yt from"./PlpSidebar.js";import{PlpResultRange as qt,PlpToolbar as Jt}from"./PlpToolbar.js";import Qt from"../catalog/SortSelect.js";import Ut from"./PlpVehicleBar.js";import Xt from"./PlpVehicleGate.js";import{useVehicleCatalog as Zt}from"./useVehicleCatalog.js";import{useVehicleFit as eo}from"../fitment/useVehicleFit.js";import{usePlpFiltersInUrl as to}from"./usePlpFiltersInUrl.js";import{say as I}from"efficient-web-builder/format/lib/editor-words";const Eo={heading:"Let's find wheels that fit your car.",intro:"Tell us what you drive and we'll show you every set that bolts straight on — bolt pattern, offset and hub bore checked for you."};function oo({level:k,className:v,children:P}){const L=et(k);return o(L,{className:v,children:P})}const ro=Ze({},"AlloyWheelsListing");function no({heading:k="",intro:v="",askForCar:P=!0,gateHeading:L="",gateIntro:pe="",perPage:j=24,columns:de,defaultSort:me="recommended",hiddenFacets:ue=[],fieldUsage:f=ot,showPrice:E=!0,showInStock:he=!0,kinds:fe,products:ge,wheels:ye,requestQuery:Se,editing:m=!1,ownerId:K="",template:xe,facetTemplate:be,hover:we=ro,titleLevel:ke,omitHead:B=!1}){const{currency:a}=rt(),u=Ft(fe),D=st(),W=pt(de),ve=dt(W,m?D:null),Pe=mt(W,m?D:null),$=Je("plp"),Ne=Dt($),Ce=ct(),H=ge??ye??Ce??[],Y=i(()=>Ot(H,u),[H,u.join(",")]),r=eo({editing:m,enabled:P,autoApply:!0}),[Te,M]=Xe(!1),_e=Pt(me,u),g=r.applied?.vehicle??null,[e,x]=to({editing:m,openingSort:_e,appliedVehicle:g,vehicleRestored:r.restored,requestQuery:Se}),p=Ct(u,e.kind),n=d(t=>x(t),[x]),q=d((t,h)=>{const l=e[t],He=l.map(String).includes(h)?l.filter(Ye=>String(Ye)!==h):[...l,t==="diameters"?Number(h):h];n({...e,[t]:He,page:1})},[e,n]),J=d(t=>n({...e,priceMin:t,page:1}),[e,n]),Q=d(t=>n({...e,priceMax:t,page:1}),[e,n]),U=d(t=>n({...e,inStockOnly:t,page:1}),[e,n]),X=d(t=>n({...ce,kind:t,inStockOnly:e.inStockOnly,priceMin:e.priceMin,priceMax:e.priceMax,sort:e.sort}),[e.inStockOnly,e.priceMin,e.priceMax,e.sort,n]),Ae=d(t=>n({...e,sort:t,page:1}),[e,n]),ze=d(t=>{n({...e,page:t}),typeof window<"u"&&window.scrollTo({top:0,behavior:at()})},[e,n]),Z=d(()=>n({...ce,sort:e.sort}),[e.sort,n]),{clear:C}=r,ee=d(()=>{C(),M(!0),x(t=>({...t,page:1}))},[C]),Le=d(()=>{C(),M(!1),x(t=>({...t,page:1}))},[C]),T=g?[g.make,g.model,g.year,g.modification].join("|"):"",_=Ue(null);Qe(()=>{if(r.restored){if(_.current===null){_.current=T;return}_.current!==T&&(_.current=T,x(t=>t.page===1?t:{...t,page:1}))}},[r.restored,T,x]);const{items:A,failed:te,retry:Me}=Zt({catalog:Y,shownKinds:u,vehicle:g,editing:m}),s=i(()=>{if(!r.fit)return A;const t=A.filter(l=>z(l)==="alloy-wheel"),h=new Set(jt(t,r.fit).map(l=>l.slug));return A.filter(l=>z(l)!=="alloy-wheel"||h.has(At(l)))},[A,r.fit]),b=ue.join(","),Oe=i(()=>{const t=new Set(b?b.split(","):[]);return gt(s,e,a,p,f).filter(h=>!t.has(h.key))},[s,e,a,b,p.join(","),f]),y=i(()=>ft(s,e,a),[s,e,a]),Fe=p.length>1,oe=i(()=>ie(f,"alloy-wheel"),[f]),Re=i(()=>ie(f,"tyre"),[f]),O=i(()=>Lt(y),[y]),F=i(()=>Mt(y),[y]),R=Fe?ae(["alloy-wheel"]).one:null,Ve=i(()=>({kindLabel:R,brand:O,process:F}),[R,O,F]),Ge=$t({kind:!!R,brand:O,process:F},oe),Ie=i(()=>E?Nt(s,a):null,[s,a,E]),je=i(()=>vt(s,e,a),[s,e,a]),Ee=i(()=>yt(s,u,e,a),[s,u.join(","),e,a]),Ke=d((t,h)=>{const l=wt(s.flatMap(zt),e.tyreSizes[0]??"",t,h);n({...e,tyreSizes:l?[l]:[],page:1})},[s,e,n]),Be=i(()=>{const t=new Set(b?b.split(","):[]);return!kt(s,p)||t.has("tyreSizes")?null:St(s,e,a)},[s,e,a,b,p.join(","),f]),S=i(()=>bt(y,e.page,j),[y,e.page,j]),w=ae(p),V=Vt(p),re=Rt(L,pe,p,u),ne=p.length===1&&p[0]==="tyre",se=r.applied?.stock??null,N=i(()=>It(se),[se]),De=i(()=>s.filter(t=>p.includes(z(t))).length,[s,p.join(",")]),G=Y.length===0,We=!G&&s.length===0,$e=P&&!m&&!r.applied&&!Te;return u.length===0?null:c("section",{children:[P&&o(Ut,{cascade:r.cascade,appliedName:r.appliedName,fit:r.fit,fitSummary:ne&&N.length>0?`Takes ${N.join(" · ")}`:null,resolving:r.resolving,unresolved:ne?!!r.applied&&!r.resolving&&N.length===0:r.unresolved,matchCount:De,copy:V,onAmend:Le,onClear:ee}),$e&&o(Xt,{cascade:r.cascade,heading:re.heading,intro:re.intro,ready:r.restored,copy:V,onSkip:()=>M(!0)}),c("div",{className:B?void 0:"px-5 py-10 md:px-[max(2.5rem,calc((100%_-_var(--sf-content-cap,100%))/2_+_2.5rem))]",children:[!B&&(k||v)&&c("header",{className:"mb-6",children:[k&&o(oo,{level:ke,className:"font-display text-[clamp(28px,4vw,40px)] [font-weight:var(--sf-heading-weight,500)] [text-transform:var(--sf-heading-case,uppercase)] leading-[1.05] tracking-[-0.02em]",children:lt(k,!1)}),v&&o("p",{className:"mt-2 max-w-[60ch] text-[15px] text-fg-dim",children:it(v)})]}),c("div",{className:"flex flex-col gap-8 lg:flex-row lg:items-start",children:[o(Yt,{facets:Oe,filters:e,typeOptions:Ee,sizeBoxes:Be,sizeMatches:e.tyreSizes.length>0?y.length:null,noun:w,priceBounds:Ie,inStockCount:he?je:null,onToggle:q,onPickType:X,onPickSize:Ke,onPriceMin:J,onPriceMax:Q,onInStockOnly:U,onClearAll:Z,owner:{id:K,facetTemplate:be},editing:m}),c("div",{className:"min-w-0 flex-1",children:[o(Jt,{className:"mb-4",start:c(qe,{children:[o(qt,{total:S.total,range:{from:S.from,to:S.to},noun:w}),o(Et,{filters:e,onToggle:q,onPriceMin:J,onPriceMax:Q,onInStockOnly:U,onPickType:X})]}),end:o(Qt,{value:e.sort,keys:Tt(u),labels:_t,onChange:Ae})}),te&&!G&&c("div",{role:"status",className:"mb-4 flex flex-wrap items-center gap-x-4 gap-y-2 border border-line px-4 py-3",children:[o("p",{className:"text-[14px] text-fg-dim",children:"We couldn't check your car just now — try again."}),o("button",{type:"button",onClick:Me,className:"cursor-pointer bg-btn px-4 py-2 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-btn-ink hover:bg-fg",children:"Try again"})]}),G?o("div",{className:"border border-dashed border-line p-10",children:o("p",{className:"font-mono text-[12px] uppercase tracking-[0.16em] text-fg-dim",children:m?w.many==="wheels"?I("No wheels in this website's catalog yet — curate products to see them here."):w.many==="tyres"?I("No tyres in this website's catalog yet — curate products to see them here."):I("No products in this website's catalog yet — curate products to see them here."):"Our catalog is being updated. Please check back shortly."})}):We?te?null:c("div",{className:"border border-line p-10",children:[c("h3",{className:"font-display text-[22px] font-medium uppercase tracking-[-0.01em]",children:["No confirmed fit for your ",r.appliedName]}),o("p",{className:"mt-2 max-w-[52ch] text-[14px] text-fg-dim",children:V.nothingFits}),c("button",{type:"button",onClick:ee,className:"mt-4 cursor-pointer bg-btn px-4 py-3 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-btn-ink hover:bg-fg",children:["Show all ",w.many]})]}):S.total===0?c("div",{className:"border border-line p-10",children:[c("h3",{className:"font-display text-[22px] font-medium uppercase tracking-[-0.01em]",children:["No ",w.many," match those filters"]}),o("p",{className:"mt-2 max-w-[46ch] text-[14px] text-fg-dim",children:"Try widening the price range or clearing a filter."}),xt(e)&&o("button",{type:"button",onClick:Z,className:"mt-4 cursor-pointer bg-btn px-4 py-3 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-btn-ink hover:bg-fg",children:"Clear all filters"})]}):c(Kt,{value:{ownerId:K,ownerType:"AlloyWheelsListing",Template:xe,hover:we,imageSizes:Pe,fieldUsage:oe,tyreFieldUsage:Re,reserveEyebrow:Ge,editing:m,eyebrow:Ve,fit:r.fit,colours:e.finishes,setGridGap:`var(${le})`,rules:Wt},children:[o("style",{children:Ne}),o("div",{className:`plp-card-grid ${$} ${ut} ${tt}`,style:{...ve,...ht(`var(${le})`)},children:o(Bt,{items:S.items,tyreOf:t=>z(t)==="tyre"?t:null,tyreFit:t=>N.length>0?Gt(t.sizes,N):null})})]}),o(Ht,{page:S.page,pageCount:S.pageCount,onPage:ze}),o(nt,{editing:m})]})]})]})]})}export{Eo as PLP_GATE_DEFAULTS,no as default};
1
+ "use client";import{jsx as o,jsxs as c,Fragment as Qe}from"react/jsx-runtime";import{useScopeClass as Ue}from"../../lib/use-scope-class.js";import{useCallback as d,useEffect as Xe,useMemo as i,useRef as Ze,useState as et}from"react";import{cardHoverOf as tt}from"efficient-web-builder/format/lib/animation/hover";import{pageTitleTag as ot}from"efficient-web-builder/format/lib/document/one-h1";import{SHARED_ROWS_LIST_CLASS as rt}from"efficient-web-builder/render/lib/content/box-shared-columns";import{NO_FIELD_ANSWERS as nt,answersForKind as ie}from"../../lib/content/field-usage.js";import{useCurrency as st}from"../CurrencyContext.js";import it from"../NoCurrencyNote.js";import{usePreviewDevice as lt}from"efficient-easel/screen/components/PreviewDeviceContext";import{renderGold as ct,renderHeadline as at}from"efficient-web-builder/render/components/goldPhrases";import{useUnifiedProductCatalog as pt}from"../useProductCatalog.js";import{scrollBehavior as dt}from"efficient-web-builder/render/components/useReducedMotion";import{normalizePlpColumns as mt,PLP_GRID_GAP_VAR as le,plpGridVars as ut}from"../../lib/wheels/plp-grid.js";import{plpCardImageSizes as ht}from"../../lib/sections/card-image-sizes.js";import{CARD_ROWS_GRID_CLASS as ft,cardRowsGridStyle as gt}from"../WheelCardFrame.js";import{applyPlpFilters as yt,buildPlpFacets as St,buildPlpTypeOptions as xt,buildTyreSizeBoxes as bt,EMPTY_PLP_FILTERS as ce,hasActivePlpFilters as wt,paginatePlp as kt,pickTyreSize as vt,plpTyreSizeBoxesShown as Pt,plpInStockCount as Nt,plpOpeningSort as Ct,plpPriceBounds as Tt,plpShownKinds as _t,plpSortKeysFor as At,PLP_SORT_LABELS as zt}from"../../lib/wheels/plp-filters.js";import{itemKind as z,itemSlug as Lt,itemTyreSizes as Mt,plpBrandVaries as Ot,plpProcessVaries as Ft,plpItemsOfKinds as Rt,plpKindNoun as ae,resolvePlpKinds as Vt}from"../../lib/catalog/plp-item.js";import{plpGateWords as Gt,plpVehicleCopy as It}from"../../lib/catalog/plp-vehicle-copy.js";import{oemBadgeSize as jt,oemTyreSizes as Et}from"../../lib/tyres/tyre-vehicle-fitment.js";import{wheelsFittingVehicle as Kt}from"../../lib/wheels/plp-fitment-match.js";import Bt from"./PlpActiveChips.js";import{GridCardProvider as Dt,GridMixedCards as Wt,gridIndexCss as $t,LISTING_CARD_RULES as Ht}from"../GridCardTemplate.js";import{wheelCardEyebrowShows as Yt}from"../ProductCardEyebrow.js";import qt from"./PlpPagination.js";import Jt from"./PlpSidebar.js";import{PlpResultRange as Qt,PlpToolbar as Ut}from"./PlpToolbar.js";import Xt from"../catalog/SortSelect.js";import Zt from"./PlpVehicleBar.js";import eo from"./PlpVehicleGate.js";import{useVehicleCatalog as to}from"./useVehicleCatalog.js";import{useVehicleFit as oo}from"../fitment/useVehicleFit.js";import{usePlpFiltersInUrl as ro}from"./usePlpFiltersInUrl.js";import{say as I}from"efficient-web-builder/format/lib/editor-words";const Bo={heading:"Let's find wheels that fit your car.",intro:"Tell us what you drive and we'll show you every set that bolts straight on — bolt pattern, offset and hub bore checked for you."};function no({level:k,className:v,children:P}){const L=ot(k);return o(L,{className:v,children:P})}const so=tt({},"AlloyWheelsListing");function io({heading:k="",intro:v="",askForCar:P=!0,gateHeading:L="",gateIntro:pe="",perPage:j=24,columns:de,defaultSort:me="recommended",hiddenFacets:ue=[],fieldUsage:f=nt,showPrice:E=!0,showInStock:he=!0,kinds:fe,products:ge,wheels:ye,requestQuery:Se,editing:m=!1,ownerId:K="",template:xe,facetTemplate:be,railTemplate:we,railHeadTemplate:ke,hover:ve=so,titleLevel:Pe,omitHead:B=!1}){const{currency:a}=st(),u=Vt(fe),D=lt(),W=mt(de),Ne=ut(W,m?D:null),Ce=ht(W,m?D:null),$=Ue("plp"),Te=$t($),_e=pt(),H=ge??ye??_e??[],Y=i(()=>Rt(H,u),[H,u.join(",")]),r=oo({editing:m,enabled:P,autoApply:!0}),[Ae,M]=et(!1),ze=Ct(me,u),g=r.applied?.vehicle??null,[e,x]=ro({editing:m,openingSort:ze,appliedVehicle:g,vehicleRestored:r.restored,requestQuery:Se}),p=_t(u,e.kind),n=d(t=>x(t),[x]),q=d((t,h)=>{const l=e[t],qe=l.map(String).includes(h)?l.filter(Je=>String(Je)!==h):[...l,t==="diameters"?Number(h):h];n({...e,[t]:qe,page:1})},[e,n]),J=d(t=>n({...e,priceMin:t,page:1}),[e,n]),Q=d(t=>n({...e,priceMax:t,page:1}),[e,n]),U=d(t=>n({...e,inStockOnly:t,page:1}),[e,n]),X=d(t=>n({...ce,kind:t,inStockOnly:e.inStockOnly,priceMin:e.priceMin,priceMax:e.priceMax,sort:e.sort}),[e.inStockOnly,e.priceMin,e.priceMax,e.sort,n]),Le=d(t=>n({...e,sort:t,page:1}),[e,n]),Me=d(t=>{n({...e,page:t}),typeof window<"u"&&window.scrollTo({top:0,behavior:dt()})},[e,n]),Z=d(()=>n({...ce,sort:e.sort}),[e.sort,n]),{clear:C}=r,ee=d(()=>{C(),M(!0),x(t=>({...t,page:1}))},[C]),Oe=d(()=>{C(),M(!1),x(t=>({...t,page:1}))},[C]),T=g?[g.make,g.model,g.year,g.modification].join("|"):"",_=Ze(null);Xe(()=>{if(r.restored){if(_.current===null){_.current=T;return}_.current!==T&&(_.current=T,x(t=>t.page===1?t:{...t,page:1}))}},[r.restored,T,x]);const{items:A,failed:te,retry:Fe}=to({catalog:Y,shownKinds:u,vehicle:g,editing:m}),s=i(()=>{if(!r.fit)return A;const t=A.filter(l=>z(l)==="alloy-wheel"),h=new Set(Kt(t,r.fit).map(l=>l.slug));return A.filter(l=>z(l)!=="alloy-wheel"||h.has(Lt(l)))},[A,r.fit]),b=ue.join(","),Re=i(()=>{const t=new Set(b?b.split(","):[]);return St(s,e,a,p,f).filter(h=>!t.has(h.key))},[s,e,a,b,p.join(","),f]),y=i(()=>yt(s,e,a),[s,e,a]),Ve=p.length>1,oe=i(()=>ie(f,"alloy-wheel"),[f]),Ge=i(()=>ie(f,"tyre"),[f]),O=i(()=>Ot(y),[y]),F=i(()=>Ft(y),[y]),R=Ve?ae(["alloy-wheel"]).one:null,Ie=i(()=>({kindLabel:R,brand:O,process:F}),[R,O,F]),je=Yt({kind:!!R,brand:O,process:F},oe),Ee=i(()=>E?Tt(s,a):null,[s,a,E]),Ke=i(()=>Nt(s,e,a),[s,e,a]),Be=i(()=>xt(s,u,e,a),[s,u.join(","),e,a]),De=d((t,h)=>{const l=vt(s.flatMap(Mt),e.tyreSizes[0]??"",t,h);n({...e,tyreSizes:l?[l]:[],page:1})},[s,e,n]),We=i(()=>{const t=new Set(b?b.split(","):[]);return!Pt(s,p)||t.has("tyreSizes")?null:bt(s,e,a)},[s,e,a,b,p.join(","),f]),S=i(()=>kt(y,e.page,j),[y,e.page,j]),w=ae(p),V=It(p),re=Gt(L,pe,p,u),ne=p.length===1&&p[0]==="tyre",se=r.applied?.stock??null,N=i(()=>Et(se),[se]),$e=i(()=>s.filter(t=>p.includes(z(t))).length,[s,p.join(",")]),G=Y.length===0,He=!G&&s.length===0,Ye=P&&!m&&!r.applied&&!Ae;return u.length===0?null:c("section",{children:[P&&o(Zt,{cascade:r.cascade,appliedName:r.appliedName,fit:r.fit,fitSummary:ne&&N.length>0?`Takes ${N.join(" · ")}`:null,resolving:r.resolving,unresolved:ne?!!r.applied&&!r.resolving&&N.length===0:r.unresolved,matchCount:$e,copy:V,onAmend:Oe,onClear:ee}),Ye&&o(eo,{cascade:r.cascade,heading:re.heading,intro:re.intro,ready:r.restored,copy:V,onSkip:()=>M(!0)}),c("div",{className:B?void 0:"px-5 py-10 md:px-[max(2.5rem,calc((100%_-_var(--sf-content-cap,100%))/2_+_2.5rem))]",children:[!B&&(k||v)&&c("header",{className:"mb-6",children:[k&&o(no,{level:Pe,className:"font-display text-[clamp(28px,4vw,40px)] [font-weight:var(--sf-heading-weight,500)] [text-transform:var(--sf-heading-case,uppercase)] leading-[1.05] tracking-[-0.02em]",children:at(k,!1)}),v&&o("p",{className:"mt-2 max-w-[60ch] text-[15px] text-fg-dim",children:ct(v)})]}),c("div",{className:"flex flex-col gap-8 lg:flex-row lg:items-start",children:[o(Jt,{facets:Re,filters:e,typeOptions:Be,sizeBoxes:We,sizeMatches:e.tyreSizes.length>0?y.length:null,noun:w,priceBounds:Ee,inStockCount:he?Ke:null,onToggle:q,onPickType:X,onPickSize:De,onPriceMin:J,onPriceMax:Q,onInStockOnly:U,onClearAll:Z,owner:{id:K,facetTemplate:be,railTemplate:we,railHeadTemplate:ke},editing:m}),c("div",{className:"min-w-0 flex-1",children:[o(Ut,{className:"mb-4",start:c(Qe,{children:[o(Qt,{total:S.total,range:{from:S.from,to:S.to},noun:w}),o(Bt,{filters:e,onToggle:q,onPriceMin:J,onPriceMax:Q,onInStockOnly:U,onPickType:X})]}),end:o(Xt,{value:e.sort,keys:At(u),labels:zt,onChange:Le})}),te&&!G&&c("div",{role:"status",className:"mb-4 flex flex-wrap items-center gap-x-4 gap-y-2 border border-line px-4 py-3",children:[o("p",{className:"text-[14px] text-fg-dim",children:"We couldn't check your car just now — try again."}),o("button",{type:"button",onClick:Fe,className:"cursor-pointer bg-btn px-4 py-2 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-btn-ink hover:bg-fg",children:"Try again"})]}),G?o("div",{className:"border border-dashed border-line p-10",children:o("p",{className:"font-mono text-[12px] uppercase tracking-[0.16em] text-fg-dim",children:m?w.many==="wheels"?I("No wheels in this website's catalog yet — curate products to see them here."):w.many==="tyres"?I("No tyres in this website's catalog yet — curate products to see them here."):I("No products in this website's catalog yet — curate products to see them here."):"Our catalog is being updated. Please check back shortly."})}):He?te?null:c("div",{className:"border border-line p-10",children:[c("h3",{className:"font-display text-[22px] font-medium uppercase tracking-[-0.01em]",children:["No confirmed fit for your ",r.appliedName]}),o("p",{className:"mt-2 max-w-[52ch] text-[14px] text-fg-dim",children:V.nothingFits}),c("button",{type:"button",onClick:ee,className:"mt-4 cursor-pointer bg-btn px-4 py-3 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-btn-ink hover:bg-fg",children:["Show all ",w.many]})]}):S.total===0?c("div",{className:"border border-line p-10",children:[c("h3",{className:"font-display text-[22px] font-medium uppercase tracking-[-0.01em]",children:["No ",w.many," match those filters"]}),o("p",{className:"mt-2 max-w-[46ch] text-[14px] text-fg-dim",children:"Try widening the price range or clearing a filter."}),wt(e)&&o("button",{type:"button",onClick:Z,className:"mt-4 cursor-pointer bg-btn px-4 py-3 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-btn-ink hover:bg-fg",children:"Clear all filters"})]}):c(Dt,{value:{ownerId:K,ownerType:"AlloyWheelsListing",Template:xe,hover:ve,imageSizes:Ce,fieldUsage:oe,tyreFieldUsage:Ge,reserveEyebrow:je,editing:m,eyebrow:Ie,fit:r.fit,colours:e.finishes,setGridGap:`var(${le})`,rules:Ht},children:[o("style",{children:Te}),o("div",{className:`plp-card-grid ${$} ${ft} ${rt}`,style:{...Ne,...gt(`var(${le})`)},children:o(Wt,{items:S.items,tyreOf:t=>z(t)==="tyre"?t:null,tyreFit:t=>N.length>0?jt(t.sizes,N):null})})]}),o(qt,{page:S.page,pageCount:S.pageCount,onPage:Me}),o(it,{editing:m})]})]})]})]})}export{Bo as PLP_GATE_DEFAULTS,io as default};
@@ -3,14 +3,17 @@ import { type FacetRow } from "../../lib/content/facet-row-seed.js";
3
3
  import type { OptionCardRows } from "../../lib/sections/filter-option-rows.js";
4
4
  export type RailOwner = {
5
5
  id: string;
6
- facetTemplate?: SlotComponent;
6
+ facetTemplate: SlotComponent;
7
+ railTemplate: SlotComponent;
8
+ railHeadTemplate: SlotComponent;
7
9
  type?: string;
8
10
  };
11
+ export declare const RAIL_OWNER_TEMPLATES: readonly ["facetTemplate", "railTemplate", "railHeadTemplate"];
9
12
  export default function PlpFacetRows({ owner, rows, dead, label, className, editing, }: {
10
13
  owner: RailOwner;
11
14
  rows: OptionCardRows<FacetRow>;
12
15
  dead: readonly boolean[];
13
16
  label?: string;
14
- className: string;
17
+ className?: string;
15
18
  editing: boolean;
16
19
  }): import("react").JSX.Element;
@@ -1 +1 @@
1
- "use client";import{jsx as e}from"react/jsx-runtime";import{CardTemplateRows as m}from"efficient-web-builder/render/components/CardRowContext";import{InsideSiteColumn as c}from"efficient-web-builder/render/components/SiteGutterFrame";import{COPY_MARK as T}from"../../lib/content/copy-mark.js";import{FACET_TEMPLATE_SLOT as d,FACET_TICK as f,FACET_TICK_INK_CLASS as _,FACET_TICK_VAR as p}from"../../lib/content/facet-row-seed.js";import{ALLOY_WHEELS_LISTING_TYPE as C}from"../../lib/wheels/plp-hydrate.js";const A={[p]:`url("${f}")`},E="[--sf-card-lift:none] [--sf-card-shadow-hover:var(--sf-card-shadow,none)]";function I({owner:t,rows:a,dead:l,label:r,className:s,editing:i}){return e("ul",{className:`flex flex-col ${s} ${T} ${_} ${E}`,style:A,"aria-label":r,children:e(c,{children:e(m,{ownerId:t.id,ownerType:t.type??C,slot:d,Template:t.facetTemplate,rows:a.items,states:a.states,actions:i?void 0:a.actions,fallback:null,wrapCopy:(o,n)=>e("li",{className:l[n.index]?"-mx-3 opacity-40":"-mx-3",children:o}),children:o=>o})})})}export{I as default};
1
+ "use client";import{jsx as e}from"react/jsx-runtime";import{CARD_NO_LIFT_CLASS as p}from"efficient-web-builder/format/lib/content/box-background";import{CardTemplateRows as s}from"efficient-web-builder/render/components/CardRowContext";import{InsideSiteColumn as _}from"efficient-web-builder/render/components/SiteGutterFrame";import{COPY_MARK as c}from"../../lib/content/copy-mark.js";import{FACET_TEMPLATE_SLOT as n,FACET_TICK as f,FACET_TICK_INK_CLASS as C,FACET_TICK_VAR as d}from"../../lib/content/facet-row-seed.js";import{ALLOY_WHEELS_LISTING_TYPE as A}from"../../lib/wheels/plp-hydrate.js";const E={[d]:`url("${f}")`},N=["facetTemplate","railTemplate","railHeadTemplate"];function L({owner:t,rows:l,dead:o,label:r,className:i="",editing:m}){return e("ul",{className:`flex flex-col ${i} ${c} ${C} ${p}`,style:E,"aria-label":r,children:e(_,{children:e(s,{ownerId:t.id,ownerType:t.type??A,slot:n,Template:t.facetTemplate,rows:l.items,states:l.states,actions:m?void 0:l.actions,fallback:null,wrapCopy:(a,T)=>e("li",{className:o[T.index]?"-mx-3 opacity-40":"-mx-3",children:a}),children:a=>a})})})}export{N as RAIL_OWNER_TEMPLATES,L as default};
@@ -8,17 +8,12 @@ export default function PlpSidebar<K extends string = PlpFacetKey>({ facets, fil
8
8
  key: K;
9
9
  })[];
10
10
  filters: PlpFilterState;
11
- typeOptions?: PlpTypeOption[];
12
- sizeBoxes?: PlpTyreSizeBox[] | null;
13
- sizeMatches?: number | null;
14
11
  noun: {
15
12
  one: string;
16
13
  many: string;
17
14
  };
18
15
  inStockCount: number | null;
19
16
  onToggle: (key: K, value: string) => void;
20
- onPickType?: (kind: ProductKind | null) => void;
21
- onPickSize?: (part: TyreSizePart, value: number | null) => void;
22
17
  onInStockOnly: (value: boolean) => void;
23
18
  onClearAll: () => void;
24
19
  price?: {
@@ -28,7 +23,7 @@ export default function PlpSidebar<K extends string = PlpFacetKey>({ facets, fil
28
23
  foot?: ReactNode;
29
24
  owner: RailOwner;
30
25
  editing?: boolean;
31
- } & RailPrice): import("react").JSX.Element;
26
+ } & RailPrice & RailTypes & RailSizes): import("react").JSX.Element;
32
27
  type RailPrice = {
33
28
  priceBounds: {
34
29
  min: number;
@@ -41,4 +36,20 @@ type RailPrice = {
41
36
  onPriceMin?: undefined;
42
37
  onPriceMax?: undefined;
43
38
  };
39
+ type RailTypes = {
40
+ typeOptions: PlpTypeOption[];
41
+ onPickType: (kind: ProductKind | null) => void;
42
+ } | {
43
+ typeOptions?: undefined;
44
+ onPickType?: undefined;
45
+ };
46
+ type RailSizes = {
47
+ sizeBoxes: PlpTyreSizeBox[] | null;
48
+ sizeMatches?: number | null;
49
+ onPickSize: (part: TyreSizePart, value: number | null) => void;
50
+ } | {
51
+ sizeBoxes?: undefined;
52
+ sizeMatches?: undefined;
53
+ onPickSize?: undefined;
54
+ };
44
55
  export {};
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import T from"../catalog/ClearAllButton.js";import{useState as A}from"react";import{say as F}from"efficient-web-builder/format/lib/editor-words";import R from"../catalog/PriceRange.js";import{useEnglish as _}from"../EnglishVariant.js";import{facetRow as M}from"../../lib/content/facet-row-seed.js";import{optionCardRows as B}from"../../lib/sections/filter-option-rows.js";import{hasActivePlpFilters as I,isDeadPlpOption as u,PLP_FACET_LABELS as L}from"../../lib/wheels/plp-filters.js";import D from"./PlpFacetRows.js";import O from"./PlpInStockToggle.js";import G from"./PlpTypePicker.js";import H from"./PlpTyreSizeBoxes.js";function q({facets:s,filters:r,typeOptions:i=[],sizeBoxes:o=null,sizeMatches:N=null,noun:n,priceBounds:d,inStockCount:f,onToggle:P,onPickType:w,onPickSize:S,onPriceMin:C,onPriceMax:z,onInStockOnly:E,onClearAll:$,price:p,foot:h,owner:x,editing:b=!1}){const c=_(),[m,y]=A({});return t("aside",{className:"-mx-3 w-[calc(100%+1.5rem)] flex-none px-3 lg:sticky lg:[--sf-plp-rail-gap:16px] lg:[--sf-plp-rail-top:calc(var(--sf-header-h,88px)+var(--sf-plp-rail-gap))] lg:top-[var(--sf-plp-rail-top)] lg:max-h-[calc(100svh-var(--sf-plp-rail-top)-var(--sf-plp-rail-gap))] lg:w-[292px] lg:overflow-y-auto lg:overscroll-contain lg:pr-[22px]",children:[t("div",{className:"flex items-center justify-between pb-2",children:[e("h2",{className:"font-display text-[18px] font-medium uppercase tracking-[-0.01em]",children:F("Filter")}),I(r)&&e(T,{onClick:$,size:"text-[11px]"})]}),i.length>0&&e("div",{className:"pb-1 pt-1",children:e(G,{options:i,noun:n.many,onPick:w??(()=>{}),owner:x,editing:b})}),f!==null&&e("div",{className:"border-t border-line py-2",children:e(O,{checked:r.inStockOnly,count:f,noun:n.many,onChange:E})}),o&&e(k,{label:c(L.tyreSizes),open:!m.tyreSizes,onToggle:()=>y(l=>({...l,tyreSizes:!l.tyreSizes})),children:!m.tyreSizes&&e("div",{className:"pb-3",children:e(H,{boxes:o,composed:r.tyreSizes[0]??"",matches:N,noun:n.many,onPick:S??(()=>{})})})}),s.map(l=>{if(l.options.length===0)return null;const g=!m[l.key],j=B(l.options,{item:a=>M(a,a.checked),selected:a=>a.checked,press:a=>()=>P(l.key,a.value),label:a=>`${c(l.label)}: ${a.label} (${a.count} ${n.many})`,disabled:u});return e(k,{label:c(l.label),open:g,onToggle:()=>y(a=>({...a,[l.key]:!a[l.key]})),children:g&&e(D,{owner:x,rows:j,dead:l.options.map(u),label:c(l.label),className:"pb-3",editing:b})},l.key)}),p?t("div",{className:"border-t border-line py-3",children:[e("span",{className:v,children:p.label}),e("div",{className:"mt-3",children:p.control})]}):d&&t("div",{className:"border-t border-line py-3",children:[t("span",{className:v,children:["Price · per ",n.one]}),e("div",{className:"mt-3",children:e(R,{bounds:d,min:r.priceMin,max:r.priceMax,onMin:C,onMax:z})})]}),h&&e("div",{className:"border-t border-line py-3",children:h})]})}const v="block font-mono text-[11px] uppercase leading-4 tracking-[0.2em]";function k({label:s,open:r,onToggle:i,children:o}){return t("div",{className:"border-t border-line",children:[t("button",{type:"button",onClick:i,"aria-expanded":r,"aria-label":`${r?"Collapse":"Expand"} ${s} filters`,className:"flex w-full cursor-pointer items-center justify-between py-3 text-left",children:[e("span",{className:"font-mono text-[11px] uppercase tracking-[0.2em]",children:s}),e("span",{"aria-hidden":"true",className:`font-mono text-[10px] text-fg-dim transition-transform ${r?"rotate-180":""}`,children:"▾"})]}),o]})}export{q as default};
1
+ "use client";import{jsx as r,jsxs as p}from"react/jsx-runtime";import I from"../catalog/ClearAllButton.js";import{Fragment as k}from"react";import{AccordionRowStyleContext as C,BoxTabPaneContext as O}from"efficient-web-builder/render/components/BoxTabPaneContext";import{CardTemplateRows as T}from"efficient-web-builder/render/components/CardRowContext";import{InsideSiteColumn as v}from"efficient-web-builder/render/components/SiteGutterFrame";import M from"../catalog/PriceRange.js";import{useEnglish as D}from"../EnglishVariant.js";import{facetRow as $}from"../../lib/content/facet-row-seed.js";import{RAIL_END_PART as H,RAIL_HEAD_TEMPLATE_SLOT as j,RAIL_OPTIONS_PART as F,RAIL_TEMPLATE_SLOT as B,railRow as W}from"../../lib/content/rail-row-seed.js";import{optionCardRows as z}from"../../lib/sections/filter-option-rows.js";import{hasActivePlpFilters as G,isDeadPlpOption as y,PLP_FACET_LABELS as Y}from"../../lib/wheels/plp-filters.js";import{ALLOY_WHEELS_LISTING_TYPE as V}from"../../lib/wheels/plp-hydrate.js";import q,{RAIL_OWNER_TEMPLATES as J}from"./PlpFacetRows.js";import K from"./PlpInStockToggle.js";import Q from"./PlpTypePicker.js";import U from"./PlpTyreSizeBoxes.js";function X({facets:w,filters:i,typeOptions:c,sizeBoxes:m,sizeMatches:E=null,noun:n,priceBounds:h,inStockCount:f,onToggle:A,onPickType:b,onPickSize:g,onPriceMin:L,onPriceMax:N,onInStockOnly:R,onClearAll:S,price:d,foot:x,owner:o,editing:P=!1}){const s=D(),u=o.type??V;if(process.env.NODE_ENV!=="production"){for(const e of J)if(!o[e])throw new Error(`PlpSidebar: the rail owner "${o.id}" has no ${e}. A page seeds it on read; a host that draws the rail alone hands it.`)}const t=[];m&&g&&t.push({word:s(Y.tyreSizes),body:r(U,{boxes:m,composed:i.tyreSizes[0]??"",matches:E,noun:n.many,onPick:g})});for(const e of w){if(e.options.length===0)continue;const a=z(e.options,{item:l=>$(l,l.checked),selected:l=>l.checked,press:l=>()=>A(e.key,l.value),label:l=>`${s(e.label)}: ${l.label} (${l.count} ${n.many})`,disabled:y});t.push({word:s(e.label),body:r(q,{owner:o,rows:a,dead:e.options.map(y),label:s(e.label),editing:P})})}return p("aside",{className:"-mx-3 w-[calc(100%+1.5rem)] flex-none px-3 lg:sticky lg:[--sf-plp-rail-gap:16px] lg:[--sf-plp-rail-top:calc(var(--sf-header-h,88px)+var(--sf-plp-rail-gap))] lg:top-[var(--sf-plp-rail-top)] lg:max-h-[calc(100svh-var(--sf-plp-rail-top)-var(--sf-plp-rail-gap))] lg:w-[292px] lg:overflow-y-auto lg:overscroll-contain lg:pr-[22px]",children:[r(v,{children:r(T,{ownerId:o.id,ownerType:u,slot:j,Template:o.railHeadTemplate,rows:Z,fallback:null,hostParts:(e,a)=>a===H&&G(i)?r(I,{onClick:S,size:"text-[11px]"}):null,children:e=>e})}),c&&c.length>0&&b&&r("div",{className:"pb-1 pt-1",children:r(Q,{options:c,noun:n.many,onPick:b,owner:o,editing:P})}),f!==null&&r("div",{className:"border-t border-line py-2",children:r(K,{checked:i.inStockOnly,count:f,noun:n.many,onChange:R})}),r(v,{children:r(T,{ownerId:o.id,ownerType:u,slot:B,Template:o.railTemplate,rows:t.map(e=>W(e.word)),fallback:null,hostParts:(e,a)=>a===F?t[e.index]?.body:null,wrapCopy:(e,a)=>r(k,{children:e},t[a.index]?.word),children:e=>r(O.Provider,{value:"accordion",children:r(C.Provider,{value:"chevron",children:e})})})}),d?p("div",{className:"border-t border-line py-3",children:[r("span",{className:_,children:d.label}),r("div",{className:"mt-3",children:d.control})]}):h&&p("div",{className:"border-t border-line py-3",children:[p("span",{className:_,children:["Price · per ",n.one]}),r("div",{className:"mt-3",children:r(M,{bounds:h,min:i.priceMin,max:i.priceMax,onMin:L,onMax:N})})]}),x&&r("div",{className:"border-t border-line py-3",children:x})]})}const _="block font-mono text-[11px] uppercase leading-4 tracking-[0.2em]",Z=[{}];export{X as default};
@@ -202,6 +202,7 @@ export type Brand = {
202
202
  design_count: number;
203
203
  };
204
204
  import type { components, operations } from "./types.js";
205
+ import { type DealerList } from "../sections/dealer-finder.js";
205
206
  export declare function resolveMediaUrls<T>(value: T): T;
206
207
  export type Process = components["schemas"]["Process"];
207
208
  export type FinishFamily = components["schemas"]["FinishFamily"];
@@ -847,3 +848,5 @@ export declare const storefrontAdmin: {
847
848
  }>;
848
849
  listMedia: (token: string, kind?: "image" | "video") => Promise<MediaAsset[]>;
849
850
  };
851
+ export declare function dealersPath(near: string): string;
852
+ export declare function fetchDealers(near: string): Promise<DealerList>;
@@ -1 +1 @@
1
- import{PREVIEW_TOKEN_HEADER as ot,SITE_HOST_HEADER as it,SITE_SLUG_HEADER as ct}from"../site-headers.js";import{PRODUCT_API_BASE as dt,PRODUCT_BACKEND_URL as D}from"./origins.js";import{backendHopHeaders as ut,clientIpFromForwardedFor as lt,FORWARDED_FOR_HEADER as pt,hopCachingOf as yt}from"../forwarded-for.js";import ht from"efficient-web-builder/format/lib/document/media-manifest.json";import{auth as P}from"../auth.js";import{efficientClientOpen as ft}from"efficient-easel/screen/lib/session";import{listableWheelSummaries as E}from"../wheels/listable-wheels.js";import{dropRenderlessFinishes as x}from"../wheels/renderable-finishes.js";const gt=process.env.NEXT_PUBLIC_API_URL??"http://localhost:8000";class m extends Error{status;data;constructor(e,s,n){super(s),this.status=e,this.data=n}}const I="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.",wt=new Set([502,503,504]),N=0,mt="This editor runs on its host's own backend, which does not serve this request.",St=5e3,Pt=15e3,Ot=()=>typeof window>"u"?St:Pt;function H(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(Ot())}const F=t=>t instanceof Error&&t.name==="TimeoutError",M=(t,e)=>wt.has(t)?I:e,bt=["admin","venue"];let B="admin";function le(t){B=bt.includes(t)?t:"admin"}function At(){return B}const Tt=/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/;let q=null;function pe(t){q=t&&Tt.test(t)?t:null}function Rt(){return q}function Et(t){if(typeof window>"u"||!t.startsWith("/api/v1/"))return t;const e=V();return!e||/[?&]site=/.test(t)?t:$(t,`site=${encodeURIComponent(e)}`)}async function i(t,e={}){const{token:s,baseUrl:n,headers:l,audience:p,...h}=e;if(typeof window<"u"&&!ft())throw new m(N,mt,null);if(typeof window>"u"&&n===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 r=typeof FormData<"u"&&h.body instanceof FormData;let a;try{a=await fetch(`${n??gt}${Et(t)}`,{...h,headers:{...r?{}:{"Content-Type":"application/json"},...s?{Authorization:`Bearer ${s}`}:{},...p===null?{}:{"X-Portal-Audience":p??"shop"},...l},signal:h.signal??H({...h,audience:p})})}catch(y){throw y instanceof TypeError||F(y)?new m(N,I,null):y}let o;try{o=await a.text()}catch(y){throw F(y)?new m(N,I,null):y}let c=null;if(o)try{c=JSON.parse(o)}catch{throw new m(a.status,a.ok?"Expected JSON but received a non-JSON response":M(a.status,a.statusText),o)}if(!a.ok){const y=(c&&typeof c=="object"&&"detail"in c&&typeof c.detail=="string"?c.detail:null)??M(a.status,a.statusText);throw new m(a.status,y,c)}return c}let b=null;async function G(){return b||(b=$t().finally(()=>{b=null}),b)}async function $t(){const t=P.takeLegacyRefresh(),e=await Ut.refresh(t??void 0);return P.setTokens(e.access),e.access}async function W(){return P.getAccess()??G()}async function g(t,e={}){let s;try{s=await W()}catch{throw P.clear(),new m(401,"Not signed in",null)}try{return await i(t,{...e,token:s})}catch(n){if(!(n instanceof m)||n.status!==401)throw n;try{const l=await G();return await i(t,{...e,token:l})}catch{throw P.clear(),n}}}const Ct=100,j=20;function _t(t){if(!t)return null;try{return new URL(t,"http://page.invalid").searchParams.get("page")}catch{return null}}async function z(t,e){const[s,n=""]=t.split("?"),l=[];let p="1";for(let h=0;h<j&&p;h++){const r=new URLSearchParams(n);r.set("page_size",String(Ct)),p!=="1"&&r.set("page",p);const a=await g(`${s}?${r.toString()}`);l.push(...a.results),p=_t(a.next)}return p&&console.warn(`[${e}] stopped at ${j} pages (${l.length} rows); list may be truncated`),l}async function K(t,e={}){if(P.getAccess())try{return{data:await g(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 X(){const t=await g("/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 Ut={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 W();return await X(),t},me:X,updateMe:t=>g("/api/auth/me/",{method:"PATCH",body:JSON.stringify(t)}),changePassword:(t,e)=>g("/api/auth/me/",{method:"PATCH",body:JSON.stringify({password:e,old_password:t})}),changeEmail:(t,e)=>g("/api/shop-portal/change-email/",{method:"POST",body:JSON.stringify({new_email:t,current_password:e})}),myProfile:()=>g("/api/shop-portal/profile/"),updateMyProfile:t=>g("/api/shop-portal/profile/",{method:"PATCH",body:JSON.stringify(t)}),myAddresses:()=>g("/api/shop-portal/delivery-locations/"),createAddress:t=>g("/api/shop-portal/delivery-locations/",{method:"POST",body:JSON.stringify(t)}),updateAddress:(t,e)=>g(`/api/shop-portal/delivery-locations/${t}/`,{method:"PATCH",body:JSON.stringify(e)}),deleteAddress:t=>g(`/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:()=>g("/api/products/brands/"),myOrders:()=>z("/api/shop-portal/orders/","api.myOrders"),myOrder:t=>g(`/api/shop-portal/orders/${t}/`),cancelOrder:t=>g(`/api/shop-portal/orders/${t}/cancel/`,{method:"POST"}),myReturns:t=>z(`/api/shop-portal/returns/${t?`?order=${encodeURIComponent(t)}`:""}`,"api.myReturns"),createReturn:t=>g("/api/shop-portal/returns/",{method:"POST",body:JSON.stringify(t)}),withdrawReturn:t=>g(`/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"),g("/api/shop-portal/return-media/",{method:"POST",body:s})}};import{media as It,absolutizeApiUrl as v}from"efficient-web-builder/render/lib/media";import{analyzeLogoSvg as Nt,isSvgUrl as vt}from"efficient-web-builder/format/lib/logo/reverse-svg";import{getEditorSiteId as kt}from"efficient-web-builder/render/lib/editor-site";import{shopRouteBase as Lt,webRuntimeSiteSlug as V}from"efficient-web-builder/format/lib/web-runtime";function w(t){if(typeof t=="string")return t.startsWith("/media/")?It(t):t;if(Array.isArray(t))return t.map(w);if(t&&typeof t=="object"){const e={};for(const[s,n]of Object.entries(t))e[s]=s==="captions"&&n&&typeof n=="object"&&!Array.isArray(n)?Object.fromEntries(Object.entries(n).map(([l,p])=>[w(l),p])):w(n);return e}return t}import{PRODUCT_API_BASE as Te}from"./origins.js";const Z=typeof window>"u"&&D!=="",Jt=Z?D:dt,Dt=Lt,O=()=>({baseUrl:Dt(),audience:null});function d(t,e){const s=e?`?process=${encodeURIComponent(e)}`:"";return`/api/v1${t}${s}`}const Y=100,Q=50;function k(t,e,s){const n=new URLSearchParams;for(const[l,p]of Object.entries(e))p!=null&&p!==""&&n.set(l,String(p));return n.set("pageSize",String(Y)),s&&n.set("cursor",s),`/api/v1${t}?${n.toString()}`}function xt(t,e){return k("/wheels",{process:t},e)}const tt=Y;function Ht(t,e){return k("/wheels",{slug:t.join(",")},e)}function Ft(t,e,s){return k("/products",{kind:t.join(","),make:e?.make,model:e?.model,year:e?.year,modification:e?.modification},s)}function Mt(t){if(!t)return null;try{return new URL(t,"http://cursor.invalid").searchParams.get("cursor")}catch{return null}}async function L(t,e,s=()=>!1,n=()=>!1){const l=[];let p=null;try{for(let h=0;h<Q;h++){const r=await i(await e(p),await u());if(l.push(...r.results),p=Mt(r.next),!p)break;if(n(l))return l}p&&console.warn(`[${t}] stopped at ${Q} pages (${l.length} rows); catalog may be truncated`)}catch(h){if(s(h))throw h;console.warn(`[${t}] product API unavailable, returning []`,h)}return l}const et=t=>t instanceof m&&t.status===400;function rt(t){return t.flatMap(e=>e.kind==="alloy-wheel"?E([e]):[e])}async function at(){return(await Bt()).host}async function Bt(){try{const{headers:t}=await import("next/headers"),e=await t(),s=p=>p?.split(",")[0]?.split(":")[0]?.trim().toLowerCase()||null,n=s(e.get(it)??e.get("x-forwarded-host")??e.get("host")),l=s(e.get("host"));return{host:n,matchesRequestHost:n!==null&&n===l}}catch{return{host:null,matchesRequestHost:!1}}}async function qt(){try{const{headers:t}=await import("next/headers");return lt((await t()).get(pt))}catch{return null}}async function Gt(){try{const{headers:t}=await import("next/headers");return(await t()).get(ct)||null}catch{return null}}async function Wt(){const t=await Gt();if(t)return`site=${encodeURIComponent(t)}`;const e=await at();return e?`host=${encodeURIComponent(e)}`:""}async function f(t){if(typeof window<"u"){const e=V();return e?$(t,`site=${encodeURIComponent(e)}`):t}return $(t,await Wt())}function $(t,e){return e?`${t}${t.includes("?")?"&":"?"}${e}`:t}const jt="preview";async function zt(){if(typeof window<"u")return null;try{const{headers:t}=await import("next/headers");return(await t()).get(ot)}catch{return null}}async function Kt(){try{const{headers:t}=await import("next/headers");return(await t()).get("user-agent")}catch{return null}}async function J(t,e){const s=await zt();if(s===null)return[await f(t),await u(e)];const n=$(await f(t),`${jt}=${encodeURIComponent(s)}`),{next:l,cache:p,...h}=e??{},r=await u({...h,cache:"no-store"}),a=await Kt();return a&&(r.headers={...r.headers,"user-agent":a}),[n,r]}async function Xt(t){if(!Z)return;const[e,s]=await Promise.all([at(),qt()]),n=ut(e,s,t);return Object.keys(n).length>0?n:void 0}async function u(t){const e=await Xt(yt(t)),s={baseUrl:Jt,...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 n=s.toString();return`/api/v1/fitment${t}${n?`?${n}`:""}`}const we={listMakes:async t=>{if(A){const{fitmentData:s}=await import("./fitment-data.js");return s.makes(t)}return(await i(T("/makes",{region:t}),O())).results},listModels:async(t,e)=>{if(A){const{fitmentData:n}=await import("./fitment-data.js");return n.models(t,e)}return(await i(T("/models",{make:t,region:e}),O())).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}),O())).results},listModifications:async(t,e,s,n)=>{if(A){const{fitmentData:p}=await import("./fitment-data.js");return p.modifications(t,e,s,n)}return(await i(T("/modifications",{make:t,model:e,year:s,region:n}),O())).results},getStockFitment:async(t,e,s,n,l)=>{if(A){const{fitmentData:p}=await import("./fitment-data.js");return p.stockFitment(t,e,s,n,l)}return i(T("/stock-fitment",{make:t,model:e,year:s,modification:n,region:l}),O())}},me={listWheels:async(t,e={})=>{const s=await L("products.listWheels",async n=>await f(xt(t,n)),e.throwOnFailure?()=>!0:void 0,e.maxRows===void 0?void 0:n=>E([...n]).length>=e.maxRows);return E(w(s))},listWheelsBySlug:async(t,e={})=>{const s=[...new Set(t.map(r=>r.trim()).filter(Boolean))];if(s.length===0)return[];const n=[];for(let r=0;r<s.length;r+=tt)n.push(s.slice(r,r+tt));const l=await Promise.all(n.map(r=>L("products.listWheelsBySlug",async a=>await f(Ht(r,a)),e.throwOnFailure?()=>!0:et))),p=new Set(s),h=l.flat().filter(r=>p.has(r.slug));return E(w(h))},listCatalog:async(t,e,s={})=>{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 n=await L("products.listCatalog",async l=>await f(Ft(t,e,l)),s.throwOnFailure?()=>!0:et,s.maxRows===void 0?void 0:l=>rt([...l]).length>=s.maxRows);return rt(w(n))},getWheel:async t=>x(w(await i(await f(d(`/wheels/${t}`)),await u()))),getTyre:async t=>w(await i(await f(d(`/tyres/${t}`)),await u())),listBundles:async(t={})=>{try{return await i(await f(d("/bundles")),await u())}catch(e){if(t.throwOnFailure)throw e;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:n}=await import("./gallery-builds-data.js");return w(n(e,s))}try{const n=new URLSearchParams;e&&n.set("process",e),s&&n.set("wheelSlug",s);const l=n.toString(),p=await i(`/api/v1/gallery-builds${l?`?${l}`:""}`,O());return w(p.results)}catch(n){return console.warn("[products.listGalleryBuilds] product API unavailable, returning []",n),[]}},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()=>w(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)}`:"",[n,l]=await J(d(`/pages/${t}`)+s,e.revalidate!==void 0?{next:{revalidate:e.revalidate}}:void 0);return w(await i(n,l))},listBlogPosts:async(t={},{throwOnFailure:e=!1}={})=>{const s=t.category?`?category=${encodeURIComponent(t.category)}`:"";try{return(await i(d("/blog-posts")+s,await u())).map(l=>({...l,coverImage:v(l.coverImage)??""}))}catch(n){if(e)throw n;return console.warn("[products.listBlogPosts] blog API unavailable, returning []",n),[]}},getBlogPost:async t=>{const e=await i(d(`/blog-posts/${t}`),await u());return{...e,coverImage:v(e.coverImage)??""}},createOrder:async t=>i(d("/orders"),await u({method:"POST",body:JSON.stringify(t)})),createOrderAuthed:async t=>g(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)})),releaseCheckout:async t=>i(d("/checkouts/release"),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"),n=e.toString();try{return await i(await f(n?`${s}?${n}`: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 K(e,s)).data:i(e,s)},validateCoupon:async t=>{const{data:e,asShopper:s}=await K(d("/coupons/validate"),await u({method:"POST",body:JSON.stringify(t)}));return{...e,askedAsShopper:s}},getHeaderSettings:async()=>{const t=H({method:"GET"}),e=await i(...await J(d("/header-settings"),{signal:t})),s=v(e.logoUrl);let n=null,l=null;if(s&&vt(s)){const p=await Nt(s,t);p&&(n=p.reversed,l=p.inkIsDark)}return{...e,logoUrl:s,logoReversed:n,logoInkIsDark:l}},getThemeSettings:async()=>i(...await J(d("/theme-settings"))),getChatSettings:async()=>i(await f(d("/chat-settings")),await u())},Se={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 Vt 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 n=new URLSearchParams({...e?{site:e}:{},...s?{draft:"1"}:{}}).toString();return`/api/storefront/${t}/${n?`?${n}`:""}`},_=t=>`/api/storefront/sites/${encodeURIComponent(t)}/`,Zt=t=>`${_(t)}currencies/`,Yt="/api/storefront/media/ingest/";class Qt 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 te(){const t=kt();if(!t)throw new Qt;return`${Yt}?${new URLSearchParams({site:t})}`}const ee="X-Puck-Media-Manifest",st=ht.contentHash,U={"X-Media-Manifest":st,[ee]:st},Pe=nt({});function nt(t){return(e,s={})=>{const n=Rt(),l=t.headers||n?{...n?{"Accept-Language":n}:{},...t.headers,...s.headers}:void 0;return i(e,{...s,...t.baseUrl!==void 0?{baseUrl:t.baseUrl}:{},...l?{headers:l}:{},audience:t.audience??At()})}}function re(t={}){const e=nt(t),s=t.siteDrafts===!0,n=r=>C("header-settings",r,s),l=r=>C("theme-settings",r,s),p=r=>C("chat-settings",r,s),h=r=>C("social-settings",r,s);return{findPageBySlug:async(r,a,o)=>{const c=new URLSearchParams({slug:r});o&&c.set("site",o);const y=await e(`/api/storefront/pages/?${c.toString()}`,{token:a}),S=Array.isArray(y)?y:y.results??[];if(!o&&S.length>1)throw new Vt(r,S.length);return S[0]??null},getPageById:(r,a)=>e(`/api/storefront/pages/${r}/`,{token:a}),saveLayout:(r,a,o,c,y)=>e(`/api/storefront/pages/${r}/`,{method:"PATCH",body:JSON.stringify({layout:a,expected_updated_at:c,...y?{client_id:y}:{}}),token:o}),duplicatePage:(r,a,o)=>e(`/api/storefront/pages/${r}/duplicate/`,{method:"POST",body:JSON.stringify({title:a.title,slug:a.slug}),token:o}),geocode:(r,a,o)=>e(`/api/storefront/geocode/?${new URLSearchParams(o?{q:r,country:o}:{q:r})}`,{token:a}),listBlockSources:r=>e("/api/storefront/block-sources/",{token:r}),listRecordTypes:r=>e("/api/storefront/record-types/",{token:r}),createPagePreviewLink:(r,a)=>e(`/api/storefront/pages/${r}/preview-link/`,{method:"POST",token:a}),claimPageEditLock:(r,a,o,c=!1)=>e(`/api/storefront/pages/${r}/edit-lock/`,{method:"POST",body:JSON.stringify({client_id:o,takeover:c}),token:a}),releasePageEditLock:(r,a)=>e(`/api/storefront/pages/${r}/edit-lock/`,{method:"DELETE",token:a}),createTemplate:(r,a,o)=>e("/api/storefront/page-templates/",{method:"POST",body:JSON.stringify({name:r,layout:a}),headers:U,token:o}),getTemplate:(r,a)=>e(`/api/storefront/page-templates/${r}/`,{token:a}),saveTemplateLayout:(r,a,o)=>e(`/api/storefront/page-templates/${r}/`,{method:"PATCH",body:JSON.stringify({layout:a}),headers:U,token:o}),listTemplatePages:async(r,a)=>{const o=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(r)}`,{token:a});return Array.isArray(o)?o:o.results??[]},findTemplatePageBySlug:async(r,a,o)=>{const c=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(r)}&slug=${encodeURIComponent(a)}`,{token:o});return(Array.isArray(c)?c:c.results??[])[0]??null},createTemplatePage:(r,a,o)=>e("/api/storefront/template-pages/",{method:"POST",body:JSON.stringify({template:r,...a}),headers:U,token:o}),saveTemplatePageLayout:(r,a,o)=>e(`/api/storefront/template-pages/${r}/`,{method:"PATCH",body:JSON.stringify({layout:a}),headers:U,token:o}),deleteTemplatePage:(r,a,o)=>e(`/api/storefront/template-pages/${r}/`,{method:"DELETE",token:a,...o?.keepalive?{keepalive:!0}:{}}),listPages:async(r,a)=>{const o=new URLSearchParams({no_page:"true"});a&&o.set("site",a);const c=await e(`/api/storefront/pages/?${o.toString()}`,{token:r});return Array.isArray(c)?c:c.results??[]},createPage:(r,a,o,c)=>e("/api/storefront/pages/",{method:"POST",body:JSON.stringify({title:r,slug:a,layout:o}),token:c}),deletePage:(r,a)=>e(`/api/storefront/pages/${r}/`,{method:"DELETE",token:a}),getHeaderSettings:(r,a)=>e(n(a),{token:r}),listMenus:async(r,a)=>{const o=new URLSearchParams({no_page:"true"});a&&o.set("site",a);const c=await e(`/api/storefront/menus/?${o}`,{token:r});return Array.isArray(c)?c:c.results??[]},listBlogPosts:async(r,a={})=>{const o=new URLSearchParams({no_page:"true"});a.visibleOnly&&o.set("is_visible","true"),a.siteId&&o.set("site",a.siteId);const c=await e(`/api/storefront/blog-posts/?${o.toString()}`,{token:r});return Array.isArray(c)?c:c.results??[]},listFieldUsage:async(r,a)=>{const o=await e(`/api/storefront/field-usage/?site=${encodeURIComponent(a)}`,{token:r});return Array.isArray(o?.entries)?o.entries:[]},listCategories:async(r,a={})=>{const o=new URLSearchParams({no_page:"true"});a.visibleOnly&&o.set("is_visible","true"),a.siteId&&o.set("site",a.siteId);const c=await e(`/api/storefront/categories/?${o.toString()}`,{token:r});return[...Array.isArray(c)?c:c.results??[]].sort((S,R)=>S.sort_order-R.sort_order||S.name.localeCompare(R.name))},listForms:async(r,a={})=>{const o=new URLSearchParams({no_page:"true"});a.siteId&&o.set("site",a.siteId);const c=await e(`/api/storefront/forms/?${o.toString()}`,{token:r});return[...Array.isArray(c)?c:c.results??[]].sort((S,R)=>S.title.localeCompare(R.title))},listWheelSummaries:async(r,a={})=>{const o=new URLSearchParams;a.siteId&&o.set("site",a.siteId);const c=o.toString(),y=await e(`/api/storefront/wheel-curations/summaries/${c?`?${c}`:""}`,{token:r});return w(y)},listProducts:async(r,a={})=>{const o=new URLSearchParams;a.kinds?.length&&o.set("kind",a.kinds.join(",")),a.siteId&&o.set("site",a.siteId);const c=o.toString(),y=await e(`/api/storefront/products/${c?`?${c}`:""}`,{token:r});return w(y)},getWheelDetail:async(r,a,o={})=>{const c=new URLSearchParams({slug:a});return o.siteId&&c.set("site",o.siteId),x(w(await e(`/api/storefront/wheel-curations/detail/?${c.toString()}`,{token:r})))},updateHeaderSettings:(r,a,o)=>e(n(o),{method:"PATCH",body:JSON.stringify(r),token:a}),getSite:(r,a)=>e(_(r),{token:a}),listSites:async r=>{const a=await e("/api/storefront/sites/?no_page=true",{token:r});return Array.isArray(a)?a:a.results??[]},listSiteCurrencies:async(r,a)=>{const o=await e(Zt(r),{token:a});return Array.isArray(o)?o:[]},publishSite:(r,a)=>e(`${_(r)}publish/`,{method:"POST",token:a}),getSiteLiveState:(r,a)=>e(`${_(r)}live-state/`,{token:a}),getThemeSettings:(r,a)=>e(l(a),{token:r}),updateThemeSettings:(r,a,o)=>e(l(o),{method:"PATCH",body:JSON.stringify(r),token:a}),getMyPreferences:async r=>(await e("/api/auth/me/",{token:r})).preferences??{},updateMyPreferences:(r,a)=>e("/api/auth/me/",{method:"PATCH",body:JSON.stringify({preferences:r}),token:a}),getChatSettings:(r,a)=>e(p(a),{token:r}),updateChatSettings:(r,a,o)=>e(p(o),{method:"PATCH",body:JSON.stringify(r),token:a}),getSocialSettings:(r,a)=>e(h(a),{token:r}),updateSocialSettings:(r,a,o)=>e(h(o),{method:"PATCH",body:JSON.stringify(r),token:a}),uploadHeaderLogo:(r,a,o)=>{const c=new FormData;return c.append("logo",r),e(n(o),{method:"PATCH",body:c,token:a})},clearHeaderLogo:(r,a)=>e(n(a),{method:"PATCH",body:JSON.stringify({logo:null}),token:r}),setHeaderLogoFromAsset:(r,a,o)=>e(n(o),{method:"PATCH",body:JSON.stringify({logo_asset_id:r}),token:a}),uploadMedia:async(r,a)=>{const o=new FormData;return o.append("file",r),e(te(),{method:"POST",body:o,token:a})},listMedia:async(r,a)=>{const o=new URLSearchParams({no_page:"true"});a&&o.set("kind",a);const c=await e(`/api/storefront/media-assets/?${o.toString()}`,{token:r});return Array.isArray(c)?c:c.results??[]}}}const Oe=re({siteDrafts:!0});export{gt as API_URL,Vt as AmbiguousPageSlugError,m as ApiError,Pt as BROWSER_READ_TIMEOUT_MS,mt as EFFICIENT_CLIENT_CLOSED_MESSAGE,Qt as MediaUploadDestinationError,jt as PREVIEW_PARAM,Te as PRODUCT_API_BASE,St as SERVER_READ_TIMEOUT_MS,I as SERVER_UNREACHABLE_MESSAGE,N as STATUS_NETWORK_ERROR,Pe as adminFetch,Ut as api,i as apiFetch,$ as appendSiteQuery,Se as bookings,re as createStorefrontAdmin,H as defaultRequestDeadline,te as editorMediaUploadPath,At as editorPortalAudience,Rt as editorRequestLanguage,we as fitment,me as products,Ot as readDeadlineMs,qt as resolveClientIp,w as resolveMediaUrls,zt as resolvePreviewToken,at as resolveSiteHost,Bt as resolveSiteHostSource,Gt as resolveSiteSlug,pe as setEditorLanguage,le as setEditorPortalAudience,Oe as storefrontAdmin};
1
+ import{PREVIEW_TOKEN_HEADER as ot,SITE_HOST_HEADER as it,SITE_SLUG_HEADER as ct}from"../site-headers.js";import{PRODUCT_API_BASE as dt,PRODUCT_BACKEND_URL as D}from"./origins.js";import{backendHopHeaders as ut,clientIpFromForwardedFor as lt,FORWARDED_FOR_HEADER as pt,hopCachingOf as yt}from"../forwarded-for.js";import ht from"efficient-web-builder/format/lib/document/media-manifest.json";import{auth as P}from"../auth.js";import{efficientClientOpen as ft}from"efficient-easel/screen/lib/session";import{listableWheelSummaries as E}from"../wheels/listable-wheels.js";import{dropRenderlessFinishes as x}from"../wheels/renderable-finishes.js";const gt=process.env.NEXT_PUBLIC_API_URL??"http://localhost:8000";class w extends Error{status;data;constructor(e,s,n){super(s),this.status=e,this.data=n}}const I="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.",mt=new Set([502,503,504]),N=0,wt="This editor runs on its host's own backend, which does not serve this request.",St=5e3,Pt=15e3,Ot=()=>typeof window>"u"?St:Pt;function H(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(Ot())}const F=t=>t instanceof Error&&t.name==="TimeoutError",M=(t,e)=>mt.has(t)?I:e,bt=["admin","venue"];let B="admin";function ye(t){B=bt.includes(t)?t:"admin"}function At(){return B}const Tt=/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/;let q=null;function he(t){q=t&&Tt.test(t)?t:null}function Rt(){return q}function Et(t){if(typeof window>"u"||!t.startsWith("/api/v1/"))return t;const e=V();return!e||/[?&]site=/.test(t)?t:$(t,`site=${encodeURIComponent(e)}`)}async function i(t,e={}){const{token:s,baseUrl:n,headers:l,audience:p,...h}=e;if(typeof window<"u"&&!ft())throw new w(N,wt,null);if(typeof window>"u"&&n===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 r=typeof FormData<"u"&&h.body instanceof FormData;let a;try{a=await fetch(`${n??gt}${Et(t)}`,{...h,headers:{...r?{}:{"Content-Type":"application/json"},...s?{Authorization:`Bearer ${s}`}:{},...p===null?{}:{"X-Portal-Audience":p??"shop"},...l},signal:h.signal??H({...h,audience:p})})}catch(y){throw y instanceof TypeError||F(y)?new w(N,I,null):y}let o;try{o=await a.text()}catch(y){throw F(y)?new w(N,I,null):y}let c=null;if(o)try{c=JSON.parse(o)}catch{throw new w(a.status,a.ok?"Expected JSON but received a non-JSON response":M(a.status,a.statusText),o)}if(!a.ok){const y=(c&&typeof c=="object"&&"detail"in c&&typeof c.detail=="string"?c.detail:null)??M(a.status,a.statusText);throw new w(a.status,y,c)}return c}let b=null;async function G(){return b||(b=$t().finally(()=>{b=null}),b)}async function $t(){const t=P.takeLegacyRefresh(),e=await Ut.refresh(t??void 0);return P.setTokens(e.access),e.access}async function W(){return P.getAccess()??G()}async function g(t,e={}){let s;try{s=await W()}catch{throw P.clear(),new w(401,"Not signed in",null)}try{return await i(t,{...e,token:s})}catch(n){if(!(n instanceof w)||n.status!==401)throw n;try{const l=await G();return await i(t,{...e,token:l})}catch{throw P.clear(),n}}}const Ct=100,j=20;function _t(t){if(!t)return null;try{return new URL(t,"http://page.invalid").searchParams.get("page")}catch{return null}}async function z(t,e){const[s,n=""]=t.split("?"),l=[];let p="1";for(let h=0;h<j&&p;h++){const r=new URLSearchParams(n);r.set("page_size",String(Ct)),p!=="1"&&r.set("page",p);const a=await g(`${s}?${r.toString()}`);l.push(...a.results),p=_t(a.next)}return p&&console.warn(`[${e}] stopped at ${j} pages (${l.length} rows); list may be truncated`),l}async function K(t,e={}){if(P.getAccess())try{return{data:await g(t,e),asShopper:!0}}catch(s){if(!(s instanceof w)||s.status!==401)throw s}return{data:await i(t,e),asShopper:!1}}async function X(){const t=await g("/api/auth/me/");if(t.portal!=="shop")throw P.clear(),new w(403,"This session is not valid for this shop.",null);return t}const Ut={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 W();return await X(),t},me:X,updateMe:t=>g("/api/auth/me/",{method:"PATCH",body:JSON.stringify(t)}),changePassword:(t,e)=>g("/api/auth/me/",{method:"PATCH",body:JSON.stringify({password:e,old_password:t})}),changeEmail:(t,e)=>g("/api/shop-portal/change-email/",{method:"POST",body:JSON.stringify({new_email:t,current_password:e})}),myProfile:()=>g("/api/shop-portal/profile/"),updateMyProfile:t=>g("/api/shop-portal/profile/",{method:"PATCH",body:JSON.stringify(t)}),myAddresses:()=>g("/api/shop-portal/delivery-locations/"),createAddress:t=>g("/api/shop-portal/delivery-locations/",{method:"POST",body:JSON.stringify(t)}),updateAddress:(t,e)=>g(`/api/shop-portal/delivery-locations/${t}/`,{method:"PATCH",body:JSON.stringify(e)}),deleteAddress:t=>g(`/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:()=>g("/api/products/brands/"),myOrders:()=>z("/api/shop-portal/orders/","api.myOrders"),myOrder:t=>g(`/api/shop-portal/orders/${t}/`),cancelOrder:t=>g(`/api/shop-portal/orders/${t}/cancel/`,{method:"POST"}),myReturns:t=>z(`/api/shop-portal/returns/${t?`?order=${encodeURIComponent(t)}`:""}`,"api.myReturns"),createReturn:t=>g("/api/shop-portal/returns/",{method:"POST",body:JSON.stringify(t)}),withdrawReturn:t=>g(`/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"),g("/api/shop-portal/return-media/",{method:"POST",body:s})}};import{media as It,absolutizeApiUrl as v}from"efficient-web-builder/render/lib/media";import{analyzeLogoSvg as Nt,isSvgUrl as vt}from"efficient-web-builder/format/lib/logo/reverse-svg";import{getEditorSiteId as kt}from"efficient-web-builder/render/lib/editor-site";import{shopRouteBase as Lt,webRuntimeSiteSlug as V}from"efficient-web-builder/format/lib/web-runtime";import{readDealerList as Jt}from"../sections/dealer-finder.js";function m(t){if(typeof t=="string")return t.startsWith("/media/")?It(t):t;if(Array.isArray(t))return t.map(m);if(t&&typeof t=="object"){const e={};for(const[s,n]of Object.entries(t))e[s]=s==="captions"&&n&&typeof n=="object"&&!Array.isArray(n)?Object.fromEntries(Object.entries(n).map(([l,p])=>[m(l),p])):m(n);return e}return t}import{PRODUCT_API_BASE as Ce}from"./origins.js";const Z=typeof window>"u"&&D!=="",Dt=Z?D:dt,xt=Lt,O=()=>({baseUrl:xt(),audience:null});function d(t,e){const s=e?`?process=${encodeURIComponent(e)}`:"";return`/api/v1${t}${s}`}const Y=100,Q=50;function k(t,e,s){const n=new URLSearchParams;for(const[l,p]of Object.entries(e))p!=null&&p!==""&&n.set(l,String(p));return n.set("pageSize",String(Y)),s&&n.set("cursor",s),`/api/v1${t}?${n.toString()}`}function Ht(t,e){return k("/wheels",{process:t},e)}const tt=Y;function Ft(t,e){return k("/wheels",{slug:t.join(",")},e)}function Mt(t,e,s){return k("/products",{kind:t.join(","),make:e?.make,model:e?.model,year:e?.year,modification:e?.modification},s)}function Bt(t){if(!t)return null;try{return new URL(t,"http://cursor.invalid").searchParams.get("cursor")}catch{return null}}async function L(t,e,s=()=>!1,n=()=>!1){const l=[];let p=null;try{for(let h=0;h<Q;h++){const r=await i(await e(p),await u());if(l.push(...r.results),p=Bt(r.next),!p)break;if(n(l))return l}p&&console.warn(`[${t}] stopped at ${Q} pages (${l.length} rows); catalog may be truncated`)}catch(h){if(s(h))throw h;console.warn(`[${t}] product API unavailable, returning []`,h)}return l}const et=t=>t instanceof w&&t.status===400;function rt(t){return t.flatMap(e=>e.kind==="alloy-wheel"?E([e]):[e])}async function at(){return(await qt()).host}async function qt(){try{const{headers:t}=await import("next/headers"),e=await t(),s=p=>p?.split(",")[0]?.split(":")[0]?.trim().toLowerCase()||null,n=s(e.get(it)??e.get("x-forwarded-host")??e.get("host")),l=s(e.get("host"));return{host:n,matchesRequestHost:n!==null&&n===l}}catch{return{host:null,matchesRequestHost:!1}}}async function Gt(){try{const{headers:t}=await import("next/headers");return lt((await t()).get(pt))}catch{return null}}async function Wt(){try{const{headers:t}=await import("next/headers");return(await t()).get(ct)||null}catch{return null}}async function jt(){const t=await Wt();if(t)return`site=${encodeURIComponent(t)}`;const e=await at();return e?`host=${encodeURIComponent(e)}`:""}async function f(t){if(typeof window<"u"){const e=V();return e?$(t,`site=${encodeURIComponent(e)}`):t}return $(t,await jt())}function $(t,e){return e?`${t}${t.includes("?")?"&":"?"}${e}`:t}const zt="preview";async function Kt(){if(typeof window<"u")return null;try{const{headers:t}=await import("next/headers");return(await t()).get(ot)}catch{return null}}async function Xt(){try{const{headers:t}=await import("next/headers");return(await t()).get("user-agent")}catch{return null}}async function J(t,e){const s=await Kt();if(s===null)return[await f(t),await u(e)];const n=$(await f(t),`${zt}=${encodeURIComponent(s)}`),{next:l,cache:p,...h}=e??{},r=await u({...h,cache:"no-store"}),a=await Xt();return a&&(r.headers={...r.headers,"user-agent":a}),[n,r]}async function Vt(t){if(!Z)return;const[e,s]=await Promise.all([at(),Gt()]),n=ut(e,s,t);return Object.keys(n).length>0?n:void 0}async function u(t){const e=await Vt(yt(t)),s={baseUrl:Dt,...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 n=s.toString();return`/api/v1/fitment${t}${n?`?${n}`:""}`}const Pe={listMakes:async t=>{if(A){const{fitmentData:s}=await import("./fitment-data.js");return s.makes(t)}return(await i(T("/makes",{region:t}),O())).results},listModels:async(t,e)=>{if(A){const{fitmentData:n}=await import("./fitment-data.js");return n.models(t,e)}return(await i(T("/models",{make:t,region:e}),O())).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}),O())).results},listModifications:async(t,e,s,n)=>{if(A){const{fitmentData:p}=await import("./fitment-data.js");return p.modifications(t,e,s,n)}return(await i(T("/modifications",{make:t,model:e,year:s,region:n}),O())).results},getStockFitment:async(t,e,s,n,l)=>{if(A){const{fitmentData:p}=await import("./fitment-data.js");return p.stockFitment(t,e,s,n,l)}return i(T("/stock-fitment",{make:t,model:e,year:s,modification:n,region:l}),O())}},Oe={listWheels:async(t,e={})=>{const s=await L("products.listWheels",async n=>await f(Ht(t,n)),e.throwOnFailure?()=>!0:void 0,e.maxRows===void 0?void 0:n=>E([...n]).length>=e.maxRows);return E(m(s))},listWheelsBySlug:async(t,e={})=>{const s=[...new Set(t.map(r=>r.trim()).filter(Boolean))];if(s.length===0)return[];const n=[];for(let r=0;r<s.length;r+=tt)n.push(s.slice(r,r+tt));const l=await Promise.all(n.map(r=>L("products.listWheelsBySlug",async a=>await f(Ft(r,a)),e.throwOnFailure?()=>!0:et))),p=new Set(s),h=l.flat().filter(r=>p.has(r.slug));return E(m(h))},listCatalog:async(t,e,s={})=>{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 n=await L("products.listCatalog",async l=>await f(Mt(t,e,l)),s.throwOnFailure?()=>!0:et,s.maxRows===void 0?void 0:l=>rt([...l]).length>=s.maxRows);return rt(m(n))},getWheel:async t=>x(m(await i(await f(d(`/wheels/${t}`)),await u()))),getTyre:async t=>m(await i(await f(d(`/tyres/${t}`)),await u())),listBundles:async(t={})=>{try{return await i(await f(d("/bundles")),await u())}catch(e){if(t.throwOnFailure)throw e;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:n}=await import("./gallery-builds-data.js");return m(n(e,s))}try{const n=new URLSearchParams;e&&n.set("process",e),s&&n.set("wheelSlug",s);const l=n.toString(),p=await i(`/api/v1/gallery-builds${l?`?${l}`:""}`,O());return m(p.results)}catch(n){return console.warn("[products.listGalleryBuilds] product API unavailable, returning []",n),[]}},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()=>m(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 w&&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 w&&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 w&&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)}`:"",[n,l]=await J(d(`/pages/${t}`)+s,e.revalidate!==void 0?{next:{revalidate:e.revalidate}}:void 0);return m(await i(n,l))},listBlogPosts:async(t={},{throwOnFailure:e=!1}={})=>{const s=t.category?`?category=${encodeURIComponent(t.category)}`:"";try{return(await i(d("/blog-posts")+s,await u())).map(l=>({...l,coverImage:v(l.coverImage)??""}))}catch(n){if(e)throw n;return console.warn("[products.listBlogPosts] blog API unavailable, returning []",n),[]}},getBlogPost:async t=>{const e=await i(d(`/blog-posts/${t}`),await u());return{...e,coverImage:v(e.coverImage)??""}},createOrder:async t=>i(d("/orders"),await u({method:"POST",body:JSON.stringify(t)})),createOrderAuthed:async t=>g(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)})),releaseCheckout:async t=>i(d("/checkouts/release"),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"),n=e.toString();try{return await i(await f(n?`${s}?${n}`: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 K(e,s)).data:i(e,s)},validateCoupon:async t=>{const{data:e,asShopper:s}=await K(d("/coupons/validate"),await u({method:"POST",body:JSON.stringify(t)}));return{...e,askedAsShopper:s}},getHeaderSettings:async()=>{const t=H({method:"GET"}),e=await i(...await J(d("/header-settings"),{signal:t})),s=v(e.logoUrl);let n=null,l=null;if(s&&vt(s)){const p=await Nt(s,t);p&&(n=p.reversed,l=p.inkIsDark)}return{...e,logoUrl:s,logoReversed:n,logoInkIsDark:l}},getThemeSettings:async()=>i(...await J(d("/theme-settings"))),getChatSettings:async()=>i(await f(d("/chat-settings")),await u())},be={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 Zt 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 n=new URLSearchParams({...e?{site:e}:{},...s?{draft:"1"}:{}}).toString();return`/api/storefront/${t}/${n?`?${n}`:""}`},_=t=>`/api/storefront/sites/${encodeURIComponent(t)}/`,Yt=t=>`${_(t)}currencies/`,Qt="/api/storefront/media/ingest/";class te 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 ee(){const t=kt();if(!t)throw new te;return`${Qt}?${new URLSearchParams({site:t})}`}const re="X-Puck-Media-Manifest",st=ht.contentHash,U={"X-Media-Manifest":st,[re]:st},Ae=nt({});function nt(t){return(e,s={})=>{const n=Rt(),l=t.headers||n?{...n?{"Accept-Language":n}:{},...t.headers,...s.headers}:void 0;return i(e,{...s,...t.baseUrl!==void 0?{baseUrl:t.baseUrl}:{},...l?{headers:l}:{},audience:t.audience??At()})}}function ae(t={}){const e=nt(t),s=t.siteDrafts===!0,n=r=>C("header-settings",r,s),l=r=>C("theme-settings",r,s),p=r=>C("chat-settings",r,s),h=r=>C("social-settings",r,s);return{findPageBySlug:async(r,a,o)=>{const c=new URLSearchParams({slug:r});o&&c.set("site",o);const y=await e(`/api/storefront/pages/?${c.toString()}`,{token:a}),S=Array.isArray(y)?y:y.results??[];if(!o&&S.length>1)throw new Zt(r,S.length);return S[0]??null},getPageById:(r,a)=>e(`/api/storefront/pages/${r}/`,{token:a}),saveLayout:(r,a,o,c,y)=>e(`/api/storefront/pages/${r}/`,{method:"PATCH",body:JSON.stringify({layout:a,expected_updated_at:c,...y?{client_id:y}:{}}),token:o}),duplicatePage:(r,a,o)=>e(`/api/storefront/pages/${r}/duplicate/`,{method:"POST",body:JSON.stringify({title:a.title,slug:a.slug}),token:o}),geocode:(r,a,o)=>e(`/api/storefront/geocode/?${new URLSearchParams(o?{q:r,country:o}:{q:r})}`,{token:a}),listBlockSources:r=>e("/api/storefront/block-sources/",{token:r}),listRecordTypes:r=>e("/api/storefront/record-types/",{token:r}),createPagePreviewLink:(r,a)=>e(`/api/storefront/pages/${r}/preview-link/`,{method:"POST",token:a}),claimPageEditLock:(r,a,o,c=!1)=>e(`/api/storefront/pages/${r}/edit-lock/`,{method:"POST",body:JSON.stringify({client_id:o,takeover:c}),token:a}),releasePageEditLock:(r,a)=>e(`/api/storefront/pages/${r}/edit-lock/`,{method:"DELETE",token:a}),createTemplate:(r,a,o)=>e("/api/storefront/page-templates/",{method:"POST",body:JSON.stringify({name:r,layout:a}),headers:U,token:o}),getTemplate:(r,a)=>e(`/api/storefront/page-templates/${r}/`,{token:a}),saveTemplateLayout:(r,a,o)=>e(`/api/storefront/page-templates/${r}/`,{method:"PATCH",body:JSON.stringify({layout:a}),headers:U,token:o}),listTemplatePages:async(r,a)=>{const o=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(r)}`,{token:a});return Array.isArray(o)?o:o.results??[]},findTemplatePageBySlug:async(r,a,o)=>{const c=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(r)}&slug=${encodeURIComponent(a)}`,{token:o});return(Array.isArray(c)?c:c.results??[])[0]??null},createTemplatePage:(r,a,o)=>e("/api/storefront/template-pages/",{method:"POST",body:JSON.stringify({template:r,...a}),headers:U,token:o}),saveTemplatePageLayout:(r,a,o)=>e(`/api/storefront/template-pages/${r}/`,{method:"PATCH",body:JSON.stringify({layout:a}),headers:U,token:o}),deleteTemplatePage:(r,a,o)=>e(`/api/storefront/template-pages/${r}/`,{method:"DELETE",token:a,...o?.keepalive?{keepalive:!0}:{}}),listPages:async(r,a)=>{const o=new URLSearchParams({no_page:"true"});a&&o.set("site",a);const c=await e(`/api/storefront/pages/?${o.toString()}`,{token:r});return Array.isArray(c)?c:c.results??[]},createPage:(r,a,o,c)=>e("/api/storefront/pages/",{method:"POST",body:JSON.stringify({title:r,slug:a,layout:o}),token:c}),deletePage:(r,a)=>e(`/api/storefront/pages/${r}/`,{method:"DELETE",token:a}),getHeaderSettings:(r,a)=>e(n(a),{token:r}),listMenus:async(r,a)=>{const o=new URLSearchParams({no_page:"true"});a&&o.set("site",a);const c=await e(`/api/storefront/menus/?${o}`,{token:r});return Array.isArray(c)?c:c.results??[]},listBlogPosts:async(r,a={})=>{const o=new URLSearchParams({no_page:"true"});a.visibleOnly&&o.set("is_visible","true"),a.siteId&&o.set("site",a.siteId);const c=await e(`/api/storefront/blog-posts/?${o.toString()}`,{token:r});return Array.isArray(c)?c:c.results??[]},listFieldUsage:async(r,a)=>{const o=await e(`/api/storefront/field-usage/?site=${encodeURIComponent(a)}`,{token:r});return Array.isArray(o?.entries)?o.entries:[]},listCategories:async(r,a={})=>{const o=new URLSearchParams({no_page:"true"});a.visibleOnly&&o.set("is_visible","true"),a.siteId&&o.set("site",a.siteId);const c=await e(`/api/storefront/categories/?${o.toString()}`,{token:r});return[...Array.isArray(c)?c:c.results??[]].sort((S,R)=>S.sort_order-R.sort_order||S.name.localeCompare(R.name))},listForms:async(r,a={})=>{const o=new URLSearchParams({no_page:"true"});a.siteId&&o.set("site",a.siteId);const c=await e(`/api/storefront/forms/?${o.toString()}`,{token:r});return[...Array.isArray(c)?c:c.results??[]].sort((S,R)=>S.title.localeCompare(R.title))},listWheelSummaries:async(r,a={})=>{const o=new URLSearchParams;a.siteId&&o.set("site",a.siteId);const c=o.toString(),y=await e(`/api/storefront/wheel-curations/summaries/${c?`?${c}`:""}`,{token:r});return m(y)},listProducts:async(r,a={})=>{const o=new URLSearchParams;a.kinds?.length&&o.set("kind",a.kinds.join(",")),a.siteId&&o.set("site",a.siteId);const c=o.toString(),y=await e(`/api/storefront/products/${c?`?${c}`:""}`,{token:r});return m(y)},getWheelDetail:async(r,a,o={})=>{const c=new URLSearchParams({slug:a});return o.siteId&&c.set("site",o.siteId),x(m(await e(`/api/storefront/wheel-curations/detail/?${c.toString()}`,{token:r})))},updateHeaderSettings:(r,a,o)=>e(n(o),{method:"PATCH",body:JSON.stringify(r),token:a}),getSite:(r,a)=>e(_(r),{token:a}),listSites:async r=>{const a=await e("/api/storefront/sites/?no_page=true",{token:r});return Array.isArray(a)?a:a.results??[]},listSiteCurrencies:async(r,a)=>{const o=await e(Yt(r),{token:a});return Array.isArray(o)?o:[]},publishSite:(r,a)=>e(`${_(r)}publish/`,{method:"POST",token:a}),getSiteLiveState:(r,a)=>e(`${_(r)}live-state/`,{token:a}),getThemeSettings:(r,a)=>e(l(a),{token:r}),updateThemeSettings:(r,a,o)=>e(l(o),{method:"PATCH",body:JSON.stringify(r),token:a}),getMyPreferences:async r=>(await e("/api/auth/me/",{token:r})).preferences??{},updateMyPreferences:(r,a)=>e("/api/auth/me/",{method:"PATCH",body:JSON.stringify({preferences:r}),token:a}),getChatSettings:(r,a)=>e(p(a),{token:r}),updateChatSettings:(r,a,o)=>e(p(o),{method:"PATCH",body:JSON.stringify(r),token:a}),getSocialSettings:(r,a)=>e(h(a),{token:r}),updateSocialSettings:(r,a,o)=>e(h(o),{method:"PATCH",body:JSON.stringify(r),token:a}),uploadHeaderLogo:(r,a,o)=>{const c=new FormData;return c.append("logo",r),e(n(o),{method:"PATCH",body:c,token:a})},clearHeaderLogo:(r,a)=>e(n(a),{method:"PATCH",body:JSON.stringify({logo:null}),token:r}),setHeaderLogoFromAsset:(r,a,o)=>e(n(o),{method:"PATCH",body:JSON.stringify({logo_asset_id:r}),token:a}),uploadMedia:async(r,a)=>{const o=new FormData;return o.append("file",r),e(ee(),{method:"POST",body:o,token:a})},listMedia:async(r,a)=>{const o=new URLSearchParams({no_page:"true"});a&&o.set("kind",a);const c=await e(`/api/storefront/media-assets/?${o.toString()}`,{token:r});return Array.isArray(c)?c:c.results??[]}}}const Te=ae({siteDrafts:!0});function se(t){const e=t.trim();return e?`/api/v1/dealers?${new URLSearchParams({near:e}).toString()}`:"/api/v1/dealers"}async function Re(t){return Jt(await i(se(t)))}export{gt as API_URL,Zt as AmbiguousPageSlugError,w as ApiError,Pt as BROWSER_READ_TIMEOUT_MS,wt as EFFICIENT_CLIENT_CLOSED_MESSAGE,te as MediaUploadDestinationError,zt as PREVIEW_PARAM,Ce as PRODUCT_API_BASE,St as SERVER_READ_TIMEOUT_MS,I as SERVER_UNREACHABLE_MESSAGE,N as STATUS_NETWORK_ERROR,Ae as adminFetch,Ut as api,i as apiFetch,$ as appendSiteQuery,be as bookings,ae as createStorefrontAdmin,se as dealersPath,H as defaultRequestDeadline,ee as editorMediaUploadPath,At as editorPortalAudience,Rt as editorRequestLanguage,Re as fetchDealers,Pe as fitment,Oe as products,Ot as readDeadlineMs,Gt as resolveClientIp,m as resolveMediaUrls,Kt as resolvePreviewToken,at as resolveSiteHost,qt as resolveSiteHostSource,Wt as resolveSiteSlug,he as setEditorLanguage,ye as setEditorPortalAudience,Te as storefrontAdmin};