efficient-storefront-blocks 0.130.11 → 0.130.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/dist/chunks/EditorPreviewCheckout-DZWAHBAZ.js +4 -0
- package/dist/chunks/chunk-3SIVGMSB.js +1 -0
- package/dist/index.js +23 -23
- package/dist/links.js +1 -1
- package/dist/render/components/FormBlock.js +1 -1
- package/dist/render/components/ProductHeroPanel.js +1 -1
- package/dist/render/components/checkout/checkout-parts.js +1 -1
- package/dist/render/components/checkout/checkout-state.d.ts +3 -1
- package/dist/render/components/checkout/checkout-state.js +3 -3
- package/dist/render/lib/api/types.d.ts +2 -0
- package/dist/render/lib/catalog/purchase.d.ts +7 -1
- package/dist/render/lib/catalog/purchase.js +1 -1
- package/dist/render/lib/commerce.d.ts +6 -0
- package/dist/render/lib/commerce.js +1 -1
- package/dist/routine-index.json +1 -1
- package/dist/value-index.json +1 -1
- package/package.json +1 -1
- package/dist/chunks/EditorPreviewCheckout-MXKJBKHR.js +0 -4
- package/dist/chunks/chunk-4RSMAKOH.js +0 -1
package/dist/links.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var y={bold:{open:"**",close:"**",placeholder:"bold text"},italic:{open:"_",close:"_",placeholder:"italic text"},strike:{open:"~~",close:"~~",placeholder:"struck out"},code:{open:"`",close:"`",placeholder:"code"},highlight:{open:"==",close:"==",placeholder:"highlighted text"},quiet:{open:"^^",close:"^^",placeholder:"quiet text"},underline:{open:"[",close:"]{underline}",placeholder:"underlined text"},sup:{open:"[",close:"]{sup}",placeholder:"superscript"},sub:{open:"[",close:"]{sub}",placeholder:"subscript"}};var ue=["main","text","background","muted"],pt=[...ue,"surface"];var ft={bold:y.bold.placeholder,italic:y.italic.placeholder,strike:y.strike.placeholder,code:y.code.placeholder,highlight:y.highlight.placeholder,quiet:y.quiet.placeholder,link:"link text",underline:y.underline.placeholder,sup:y.sup.placeholder,sub:y.sub.placeholder,color:"colored text",style:"styled text"};var pe=[{style:"bold",label:"B",name:"Strong",title:"Strong \xB7 **words** \xB7 \u2318B",shortcut:"b"},{style:"italic",label:"I",name:"Italic",title:"Italic \xB7 _words_ \xB7 \u2318I",shortcut:"i"},{style:"strike",label:"S",name:"Strikethrough",title:"Strikethrough \xB7 ~~words~~"},{style:"highlight",label:"\u25C6",name:"Emphasis",title:"Emphasis \xB7 ==words=="},{style:"quiet",label:"a",name:"Quiet",title:"Quiet \xB7 ^^words^^"},{style:"code",label:"\u2039\u203A",name:"Code",title:"Code"},{style:"link",label:"\u{1F517}",name:"Link",title:"Link \xB7 [words](https://\u2026) \xB7 \u2318K",shortcut:"k"},{style:"bullet",label:"\u2022",name:"Bulleted list",title:"Bulleted list"},{style:"number",label:"1.",name:"Numbered list",title:"Numbered list"},{style:"quote",label:"\u275D",name:"Quote",title:"Quote"},{style:"clear",label:"T\xD7",name:"Clear marks",title:"Clear marks \xB7 \u2318\u21E7X",shortcut:"shift+x"}];var A=[{open:"**",close:"**",kind:"bold"},{open:"==",close:"==",kind:"highlight"},{open:"~~",close:"~~",kind:"strike"},{open:"_",close:"_",kind:"italic",wordBoundary:!0},{open:"^^",close:"^^",kind:"quiet"},{open:"@@",close:"@@",kind:"highlight"},{open:"++",close:"++",kind:"bold",wordStart:!0}],fe=["highlight","quiet"],dt=pe.map(e=>e.style).filter(e=>A.some(t=>t.kind===e)).filter(e=>!fe.includes(e)),mt=[...A,{open:"*",close:"*",kind:"accent"}],ht=[...A,{open:"*",close:"*",kind:"accent"},{open:"#",close:"#",kind:"bold",notBefore:"0123456789"},{open:"[",close:"]",kind:"italic",notBefore:"(",notBeforeBlock:!0}];var yt=["http","https","mailto","tel"];function j(e){if(e===""||/[\s\u0000-\u001f\u007f]/.test(e))return!1;let t=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!t||yt.includes(t[1].toLowerCase())}var de=["width","profile","rim"];var gt=/^\s*(\d{2,3})\s*\/\s*(\d{2,3})\s*[A-Za-z]*\s*(\d{2}(?:\.\d+)?)\s*$/,bt={width:[100,500],profile:[20,100],rim:[10,30]};function W(e){let t=gt.exec(e??"");if(!t)return null;let n={width:Number(t[1]),profile:Number(t[2]),rim:Number(t[3])};return de.every(o=>{let[s,i]=bt[o];return n[o]>=s&&n[o]<=i})?n:null}function _(e){if(e.width==null)return"";if(e.profile==null)return String(e.width);let t=`${e.width}/${e.profile}`;return e.rim==null?t:`${t} R${e.rim}`}function me(e){return[_({width:e.width}),_({width:e.width,profile:e.profile}),_(e)]}var x=["alloy-wheel","tyre"],he=["alloy-wheel"],F={"alloy-wheel":"Alloy wheels",tyre:"Tyres"};var Cn=x.map(e=>({value:e,label:F[e]}));function ye(e){return e==null?[...he]:Array.isArray(e)?x.filter(t=>e.includes(t)):[...he]}var m=e=>e;function d(e){return m(e).kind==="tyre"?"tyre":"alloy-wheel"}function H(e){return m(e).brand??""}function ge(e){return m(e).prices??void 0}function be(e){return m(e).inStock!==!1}function Pe(e){let t=m(e),n=d(e)==="tyre"?t.rimDiameters:t.sizes;return Array.isArray(n)?n.filter(r=>typeof r=="number"&&Number.isFinite(r)):[]}function Y(e){return d(e)==="tyre"?[]:(m(e).finishes??[]).filter(t=>typeof t?.family=="string").map(t=>({family:t.family,color:t.color??null}))}function Se(e){return Y(e).map(t=>t.family)}function ke(e){if(d(e)==="tyre")return[];let t=m(e);return Array.isArray(t.categories)?t.categories:t.process?[t.process]:[]}function xe(e){return d(e)==="tyre"?[]:m(e).spec?.pcds??[]}function we(e){return d(e)!=="tyre"?[]:m(e).tyreTypes??[]}function Le(e){return d(e)!=="tyre"?[]:m(e).speedRatings??[]}function Te(e){if(d(e)!=="tyre")return[];let t=m(e).sizes;return Array.isArray(t)?t.map(n=>W(typeof n=="string"?n:null)).filter(n=>n!==null):[]}var G=e=>typeof e=="string"&&e?e:void 0;function V(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function Oe(e,t){return Object.hasOwn(e,t)}var Ae=null;function _e(e,t){return t?e.replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g,(n,r)=>Oe(t,r)?String(V(t,r)):n):e}function g(e,t){let n=Ae?V(Ae,e):void 0;if(typeof n=="function"){try{let r=G(n(t??{}));if(r)return r}catch{}return _e(e,t)}return _e(G(n)??e,t)}function q(e){return(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}var E=(e,t,n,r)=>({default:e,min:t,max:n,step:r}),jn=E(30,0,100,10),Wn=E(0,0,100,5),Hn=E(100,0,100,5),Yn=E(2,0,4,.5);function Fe(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.text=="string"?e.text.trim():""}var Ee="homepage";var I=[{value:"page",label:"Page"},{value:"anchor",label:"Anchor"},{value:"blog",label:"Blog post",needs:"service"},{value:"product",label:"Product",needs:"commerce"},{value:"popup",label:"Popup"},{value:"custom",label:"Custom URL"}];function R(e){return e.offersCommerce&&e.offersService?I:I.filter(t=>!t.needs||(t.needs==="commerce"?e.offersCommerce:e.offersService))}var Z="#popup:";function Ie(e){return`${Z}${e}`}function Re(e){return e.startsWith(Z)&&e.slice(Z.length).trim()||null}function b(e){return e===Ee?"/":`/${e}`}function N(e){return`/journal/${e}`}function v(e){return`/wheels/${e}`}function C(e,t){return`${b(e)}#${t}`}function M(...e){let t=new Set,n=[];for(let r of e)for(let o of r?.content??[]){let s=Fe(o?.props?.anchor);if(!s)continue;let i=q(s);!i||t.has(i)||(t.add(i),n.push({slug:i,name:s}))}return n}function Ne(e){return/^\/wheels\/[^/?#]+(?:[?#].*)?$/.test(e)}var Pt=()=>({choosePage:g("Choose a page"),chooseSection:g("Choose a section"),noSections:g("No section anchors yet"),sectionHint:g("Jumps to a section on that page."),choosePost:g("Choose a post"),chooseProduct:g("Choose a product"),choosePopup:g("Choose a popup")});function K(e,t,n){if(!e)return"page";if(Re(e))return"popup";if(e.startsWith("/journal/"))return"blog";if(Ne(e))return"product";if(e.includes("#")){let r=e.slice(0,e.indexOf("#"));if(r===""||r==="/"||t.includes(r))return"anchor"}return e==="/"||t.includes(e)||n&&n.listingPaths.includes(n.targetOf(e))?"page":"custom"}function ve(e,t){let n=Pt(),r=e.pages.map(c=>({value:b(c.slug),label:c.title})),o=t?.pageOptions?t.pageOptions(r):r,s=o.map(c=>c.value),i=e.pages.map(c=>({label:c.title,options:M(...c.docs).map(u=>({value:C(c.slug,u.slug),label:u.name}))})).filter(c=>c.options.length>0),l=c=>{switch(c){case"page":return{type:"select",options:o,placeholder:n.choosePage};case"anchor":return{type:"groups",groups:i,placeholder:i.length?n.chooseSection:n.noSections};case"blog":return{type:"select",options:e.posts.map(u=>({value:N(u.slug),label:u.title||u.slug})),placeholder:n.choosePost};case"product":return{type:"select",options:e.products.map(u=>({value:u.href,label:u.name||u.href})),placeholder:n.chooseProduct};case"popup":return{type:"select",options:(e.popups??[]).map(u=>({value:Ie(u.slug),label:u.title||u.slug})),placeholder:n.choosePopup};case"custom":return{type:"text"}}},a=R(e.offers).map(c=>({value:c.value,label:g(c.label),target:l(c.value),...c.value==="anchor"?{hint:n.sectionHint}:{},...c.value==="blog"||c.value==="product"||c.value==="popup"?{hideWhenEmpty:!0}:{}}));if(!t)return{kinds:a,rules:{kindOf:c=>K(c,s),targetOf:c=>c,readFilter:()=>null,withFilter:c=>c}};let p=c=>{let u=t.withFilter(c,null);return t.listingPaths.includes(u)?u:c};return{kinds:a,rules:{kindOf:c=>K(c,s,{listingPaths:t.listingPaths,targetOf:p}),targetOf:p,readFilter:t.readFilter,withFilter:t.withFilter},filtersFor:c=>t.listingPaths.includes(c)?t.filtersFor(c):null}}var Ce=Object.freeze([]);function X(e,t){return e.length===0?e:e.filter(n=>n.kind===void 0||n.kind===t)}function Me(e,t){let n=t==="filter"?"filterOrder":"cardOrder",r=new Map;for(let o of e){let s=o[n];if(typeof s!="number"||!Number.isFinite(s))continue;let i=r.get(o.fieldKey);(i===void 0||s<i)&&r.set(o.fieldKey,s)}return o=>o?r.get(o):void 0}function Ke(e,t,n,r){let o=new Map;for(let a of n){let p=a[r];typeof p=="number"&&o.set(a.fieldKey,p)}if(o.size===0)return e;let s=[],i=[];e.forEach((a,p)=>{let c=t(a);c&&(s.push(p),i.push({item:a,index:p,order:o.get(c)}))}),i.sort((a,p)=>a.order!==void 0&&p.order!==void 0?a.order-p.order||a.index-p.index:a.order!==void 0?-1:p.order!==void 0?1:a.index-p.index);let l=[...e];return s.forEach((a,p)=>{l[a]=i[p].item}),l.every((a,p)=>a===e[p])?e:l}function ze(e){return kt(e,"filter")}var St="collection";function Q(e,t){return{tyreSizes:{},brands:{"alloy-wheel":"brand",tyre:"brand"},finishes:{"alloy-wheel":"wheel_finish_ref"},diameters:{"alloy-wheel":"diameter",tyre:"rim_diameter"},collections:{"alloy-wheel":St},pcds:{"alloy-wheel":"pcd"},tyreTypes:{tyre:"tire_type"},speedRatings:{tyre:"speed_rating"}}[e]?.[t]}function kt(e,t){let n=new Set(e.filter(r=>r[t]===!1).map(r=>r.fieldKey));return r=>!r||!n.has(r)}function xt(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function $e(e,t){let n=e?.[t];return xt(n)?n:null}function De(e,t,n,r){if(n==null&&r==null)return!0;let o=$e(e,t);return!(o===null||n!=null&&o<n||r!=null&&o>r)}function Ue(e){let t=e.spec?.lugs;return typeof t=="number"?t:null}var wt={recommended:"Recommended","price-asc":"Price \xB7 low to high","price-desc":"Price \xB7 high to low",new:"Newest",name:"Name A\u2013Z"},Ir=Object.keys(wt);var J=["tyreSizes","brands","finishes","diameters","collections","pcds","tyreTypes","speedRatings"],ee={tyreSizes:["tyre"],brands:["alloy-wheel","tyre"],finishes:["alloy-wheel"],diameters:["alloy-wheel","tyre"],collections:["alloy-wheel"],pcds:["alloy-wheel"],tyreTypes:["tyre"],speedRatings:["tyre"]},Lt={diameters:"tyreSizes"};function Tt(e){if(e.length===0)return[];let t=J.filter(n=>e.every(r=>ee[n].includes(r)));return t.filter(n=>{let r=Lt[n];return!r||!t.includes(r)})}function Ot(e){let t=new Set;for(let n of e)t.add(d(n));return[...t]}var Be={tyreSizes:[],brands:[],finishes:[],diameters:[],collections:[],pcds:[],tyreTypes:[],speedRatings:[],priceMax:null,priceMin:null,inStockOnly:!1,kind:null,sort:"recommended",page:1};function At(e,t,n,r=null,o="fail"){let s=d(e),i=l=>o==="fail"||(l==="lugs"?s==="alloy-wheel":ee[l].includes(s));if(r!=="kind"&&t.kind&&s!==t.kind)return!1;for(let l of J){if(r===l)continue;let a=t[l];if(a.length===0||!i(l))continue;let p=a.map(String);if(!je(e,l).some(c=>p.includes(c)))return!1}if(r!=="lugs"&&t.lugs&&t.lugs.length>0&&i("lugs")){let l=Ue(e);if(l===null||!t.lugs.includes(l))return!1}return!(r!=="price"&&!De(ge(e),n,t.priceMin??null,t.priceMax)||r!=="inStock"&&t.inStockOnly&&!be(e))}var _t={tyreSizes:"Size",brands:"Brand",finishes:"Colour",diameters:"Size \xB7 diameter",collections:"Collection",pcds:"PCD \xB7 fitment",tyreTypes:"Tyre type",speedRatings:"Speed rating"};function je(e,t){switch(t){case"tyreSizes":return[...new Set(Te(e).flatMap(me))];case"brands":return H(e)?[H(e)]:[];case"finishes":return Se(e);case"diameters":return Pe(e).map(String);case"collections":return ke(e);case"pcds":return xe(e);case"tyreTypes":return we(e);case"speedRatings":return Le(e)}}function Ft(e){let t=new Map;for(let n of e)for(let r of Y(n))r.color&&!t.has(r.family)&&t.set(r.family,r.color);return t}function We(e,t,n,r=Ot(e),o=Ce,s="fail"){let i=u=>It(u,r,o),l=Ft(e),p=(s==="pass"?J.filter(u=>r.some(S=>ee[u].includes(S))):Tt(r)).filter(u=>u!=="tyreSizes").filter(i).map(u=>{let S=t[u].map(String),ce=new Set,B=new Map,O=new Map;for(let f of e){let P=je(f,u);for(let h of P)ce.add(h);for(let h of new Set(P))O.set(h,(O.get(h)??0)+1);if(At(f,t,n,u,s))for(let h of new Set(P))B.set(h,(B.get(h)??0)+1)}let ut=[...ce].map(f=>({value:f,label:u==="diameters"?`${f}\u2033`:f,count:B.get(f)??0,checked:S.includes(f),swatch:u==="finishes"?l.get(f)??null:null})).sort((f,P)=>{if(u==="diameters")return Number(f.value)-Number(P.value);let h=(O.get(P.value)??0)-(O.get(f.value)??0);return h!==0?h:f.value.localeCompare(P.value)});return{key:u,label:_t[u],options:ut}}).filter(u=>u.options.length>Et),c=[];for(let u of p){let S=Rt(u.key,r,o);S!==void 0&&c.push({fieldKey:u.key,filterOrder:S})}return[...Ke(p,u=>u.key,c,"filterOrder")]}var Et=1;function He(e){return e.showCollection===!1?["collections"]:[]}function It(e,t,n){return t.length===0||n.length===0?!0:t.some(r=>ze(X(n,r))(Q(e,r)))}function Rt(e,t,n){if(n.length===0)return;let r;for(let o of t){let s=Me(X(n,o),"filter")(Q(e,o));s!==void 0&&(r===void 0||s<r)&&(r=s)}return r}var te={tyreSizes:"tyreSize",brands:"brand",finishes:"colour",diameters:"size",collections:"collection",pcds:"pcd",tyreTypes:"tyreType",speedRatings:"speed"},ne="type";var w=e=>!!e&&typeof e=="object"&&!Array.isArray(e),L=e=>w(e)&&typeof e.type=="string"&&w(e.props);var z=e=>Array.isArray(e)&&e.length>0&&e.every(L);function Nt(e){let t="";for(let n of e)t+=typeof n=="number"?`[${n}]`:t===""?n:`.${n}`;return t}function Ye(e,t){return t==="root"?e.root:e.components[t]}function Ge(e){return e?.fields??{}}function Ve(e,t){return Ge(Ye(e,t))}function qe(e,t){let n=[];return re(e,t,[],n),n}function re(e,t,n,r){for(let o of Object.keys(t)){let s=t[o];if(!s)continue;let i=[...n,o],l=e[o];if(s.type==="slot"){let a=Array.isArray(l);r.push({slot:Nt(i),segments:i,content:a?l:[],present:a})}else if(s.type==="object"&&s.objectFields&&w(l))re(l,s.objectFields,i,r);else if(s.type==="array"&&s.arrayFields&&Array.isArray(l)){let a=s.arrayFields;l.forEach((p,c)=>{w(p)&&re(p,a,[...i,c],r)})}}}function oe(e,t,n){return Ct(e,t,n).map(({slot:r,content:o})=>({slot:r,content:o}))}function $(e){let t=new TextEncoder,n=new Map(e.map(r=>[r,t.encode(r)]));return[...e].sort((r,o)=>{let s=n.get(r),i=n.get(o);if(s.length!==i.length)return s.length-i.length;for(let l=0;l<s.length;l++)if(s[l]!==i[l])return s[l]-i[l];return 0})}function Ct(e,t,n){let r=qe(e.props,Ve(t,e.type));if(n?.order!=="stored")return r;let o=$(Object.keys(e.props)),s=i=>{let l=i.present?o.indexOf(String(i.segments[0])):-1;return l<0?Number.POSITIVE_INFINITY:l};return r.map((i,l)=>({loc:i,i:l,r:s(i)})).sort((i,l)=>i.r-l.r||i.i-l.i).map(({loc:i})=>i)}var Ze=["Text","ImageBlock","ButtonBlock","Flex"];function k(){return{type:"slot",allow:[...Ze]}}var Mt=Ze.filter(e=>e!=="ButtonBlock");function Xe(){return{type:"slot",allow:[...Mt]}}var Kt="boxes",Qe={CardList:{template:Xe()},Cards:{template:k()},FAQ:{template:k()},Flex:{rowTitle:{type:"slot",allow:["Text"]},content:{type:"slot"}},Footprint:{template:k()},Grid:{content:{type:"slot"}},Hero:{slides:{type:"slot",ownPictures:!0},strip:{type:"slot",allow:["Flex"]}},HeroGroup:{content:{type:"slot"}},HeroSingle:{boxes:{type:"slot",allow:["HeroGroup"]}},HeroSlide:{groups:{type:"slot",allow:["HeroGroup"]}},Logos:{logos:{type:"slot",allow:["LogoBlock"]},template:{type:"slot",allow:["LogoBlock"]}},OrderSummary:{template:k()},ProcessSteps:{[Kt]:{type:"slot"},template:k()}};var zt={},$t=null;function Dt(){let e=Object.fromEntries(Object.entries(Qe).map(([t,n])=>[t,{fields:n}]));return $t??={components:{...e,...zt}}}function Ut(e){let t=e.props??{},n=typeof e.type=="string"?e.type:"",r=Dt(),o=n!==""&&Object.prototype.hasOwnProperty.call(r.components,n)?oe({type:n,props:t},r).map(l=>l.slot).filter(l=>!l.includes(".")):[],s=o.filter(l=>z(t[l])),i=$(Object.keys(t).filter(l=>!o.includes(l)&&z(t[l])));return[...s,...i]}function Je(e,t){let n=null;for(let r of Ut(e)){let o=e.props[r],s=t(o,r);s!==o&&((n??={...e.props})[r]=s)}return n?{...e,props:n}:e}var et="FilterBlock";var tt="AlloyWheelsListing";function Bt(e){let t=e??{},n=[];Array.isArray(t.content)&&n.push(t.content);for(let r of Object.values(t.zones??{}))Array.isArray(r)&&n.push(r);return n}function jt(e){let t=[],n=(r,o)=>{let s=[r,...o];for(let i of r)L(i)&&(t.push({node:i,order:t.length,lists:s}),Je(i,l=>(n(l,s),l)))};for(let r of Bt(e))n(r,[]);return t}function nt(e){return jt(e).map(t=>t.node)}function rt(e){return j(e.trim())}var T="/wheels",D="Products";function ot(e,t){return t>1?`${D} \xB7 ${e}`:D}function se(...e){for(let t of[tt,et])for(let n of e){let r=nt({content:n?.content}).find(o=>o.type===t);if(r)return r.props??{}}return null}function U(...e){return se(...e)!==null}function st(e,t){let n=e.filter(r=>U(...r.docs)).map(r=>b(r.slug));return t.fallback&&!n.includes(T)?[...n,T]:n}var ie=[ne,...Object.entries(te).filter(([e])=>e!=="tyreSizes").map(([,e])=>e)];function it(e){let t=e.indexOf("#"),n=t===-1?"":e.slice(t),r=t===-1?e:e.slice(0,t),o=r.indexOf("?");return{path:o===-1?r:r.slice(0,o),query:o===-1?"":r.slice(o+1),hash:n}}function Wt(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return e}}function lt(e){let t=new URLSearchParams(it(e).query);for(let n of ie){let r=t.get(n);if(r)return{param:n,value:r}}return null}function le(e,t){let{path:n,query:r,hash:o}=it(e),s=r.split("&").filter(i=>i&&!ie.includes(Wt(i.split("=")[0])));return t?.value&&s.push(`${encodeURIComponent(t.param)}=${encodeURIComponent(t.value)}`),`${n}${s.length?`?${s.join("&")}`:""}${o}`}function at(e,t){let n=le(e,null);return t.includes(n)?n:e}function Ht(e,t,n=[]){return K(e,t,{listingPaths:n,targetOf:r=>at(r,n)})}function Yt(e){return Array.isArray(e)?e.filter(t=>typeof t?.kind=="string"&&typeof t.field_key=="string").map(t=>({kind:t.kind,fieldKey:t.field_key,...typeof t.filter=="boolean"?{filter:t.filter}:{},filterOrder:t.filter_order??null})):[]}var ct="Product type",Gt="AUD";function ae(e,t){let n=t.listing??{},r=ye(n.kinds),o=e.filter(a=>r.includes(d(a))),s=He(n),i=We(o,Be,Gt,r,t.fieldUsage).filter(a=>!s.includes(a.key)).map(a=>({param:te[a.key],label:a.label,values:a.options.filter(p=>!p.value.includes(",")).map(p=>({value:p.value,label:p.label}))})).filter(a=>a.values.length>0),l=x.filter(a=>r.includes(a)&&o.some(p=>d(p)===a));return l.length>1&&i.unshift({param:ne,label:ct,values:l.map(a=>({value:a,label:F[a]}))}),i}function Vt(e){return t=>{let n=st(t,{fallback:e.offersCommerce}),r=t.filter(o=>U(...o.docs)).length;return{listingPaths:n,pageOptions:o=>{let s=o.map(i=>{let l=t.find(a=>b(a.slug)===i.value);return l&&U(...l.docs)?{...i,label:ot(l.title,r)}:i});return r===0&&e.offersCommerce&&!s.some(i=>i.value===T)&&s.push({value:T,label:D}),s},filtersFor:o=>{if(!n.includes(o))return null;let s=t.find(i=>b(i.slug)===o);return ae(e.catalogue,{listing:s?se(...s.docs):null,fieldUsage:e.fieldUsage})},readFilter:lt,withFilter:le}}}function qt(e){let t=Vt({catalogue:e.catalogue,fieldUsage:e.fieldUsage,offersCommerce:e.offers.offersCommerce})(e.pages),n=ve({pages:e.pages,posts:e.posts,products:e.products.map(r=>({href:v(r.slug),name:r.name||r.slug})),offers:e.offers},t);return{...n,rules:{...n.rules,isSafe:rt},filtersFor:n.filtersFor??(()=>null)}}function Qo(e,t){return ae(e,t)}export{T as BUILT_IN_LISTING_PATH,I as LINK_KINDS,ie as LISTING_FILTER_PARAMS,D as LISTING_PAGE_LABEL,ct as PRODUCT_TYPE_FILTER_LABEL,C as anchorPath,Yt as fieldUsageFromAdminRows,Ht as inferLinkKind,U as isProductListingPage,rt as isSafeLink,R as linkKindsFor,qt as linkPickerSetup,Qo as listingFilterFields,se as listingNode,ot as listingPageLabel,at as listingTarget,M as pageAnchors,b as pagePath,N as postPath,st as productListingPaths,lt as readListingFilter,v as wheelPath,le as withListingFilter};
|
|
1
|
+
var y={bold:{open:"**",close:"**",placeholder:"bold text"},italic:{open:"_",close:"_",placeholder:"italic text"},strike:{open:"~~",close:"~~",placeholder:"struck out"},code:{open:"`",close:"`",placeholder:"code"},highlight:{open:"==",close:"==",placeholder:"highlighted text"},quiet:{open:"^^",close:"^^",placeholder:"quiet text"},underline:{open:"[",close:"]{underline}",placeholder:"underlined text"},sup:{open:"[",close:"]{sup}",placeholder:"superscript"},sub:{open:"[",close:"]{sub}",placeholder:"subscript"}};var ue=["main","text","background","muted"],pt=[...ue,"surface"];var ft={bold:y.bold.placeholder,italic:y.italic.placeholder,strike:y.strike.placeholder,code:y.code.placeholder,highlight:y.highlight.placeholder,quiet:y.quiet.placeholder,link:"link text",underline:y.underline.placeholder,sup:y.sup.placeholder,sub:y.sub.placeholder,color:"colored text",style:"styled text"};var pe=[{style:"bold",label:"B",name:"Strong",title:"Strong \xB7 **words** \xB7 \u2318B",shortcut:"b"},{style:"italic",label:"I",name:"Italic",title:"Italic \xB7 _words_ \xB7 \u2318I",shortcut:"i"},{style:"strike",label:"S",name:"Strikethrough",title:"Strikethrough \xB7 ~~words~~"},{style:"highlight",label:"\u25C6",name:"Emphasis",title:"Emphasis \xB7 ==words=="},{style:"quiet",label:"a",name:"Quiet",title:"Quiet \xB7 ^^words^^"},{style:"code",label:"\u2039\u203A",name:"Code",title:"Code"},{style:"link",label:"\u{1F517}",name:"Link",title:"Link \xB7 [words](https://\u2026) \xB7 \u2318K",shortcut:"k"},{style:"bullet",label:"\u2022",name:"Bulleted list",title:"Bulleted list"},{style:"number",label:"1.",name:"Numbered list",title:"Numbered list"},{style:"quote",label:"\u275D",name:"Quote",title:"Quote"},{style:"clear",label:"T\xD7",name:"Clear marks",title:"Clear marks \xB7 \u2318\u21E7X",shortcut:"shift+x"}];var A=[{open:"**",close:"**",kind:"bold"},{open:"==",close:"==",kind:"highlight"},{open:"~~",close:"~~",kind:"strike"},{open:"_",close:"_",kind:"italic",wordBoundary:!0},{open:"^^",close:"^^",kind:"quiet"},{open:"@@",close:"@@",kind:"highlight"},{open:"++",close:"++",kind:"bold",wordStart:!0}],fe=["highlight","quiet"],dt=pe.map(e=>e.style).filter(e=>A.some(t=>t.kind===e)).filter(e=>!fe.includes(e)),mt=[...A,{open:"*",close:"*",kind:"accent"}],ht=[...A,{open:"*",close:"*",kind:"accent"},{open:"#",close:"#",kind:"bold",notBefore:"0123456789"},{open:"[",close:"]",kind:"italic",notBefore:"(",notBeforeBlock:!0}];var yt=["http","https","mailto","tel"];function j(e){if(e===""||/[\s\u0000-\u001f\u007f]/.test(e))return!1;let t=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!t||yt.includes(t[1].toLowerCase())}var de=["width","profile","rim"];var gt=/^\s*(\d{2,3})\s*\/\s*(\d{2,3})\s*[A-Za-z]*\s*(\d{2}(?:\.\d+)?)\s*$/,bt={width:[100,500],profile:[20,100],rim:[10,30]};function W(e){let t=gt.exec(e??"");if(!t)return null;let n={width:Number(t[1]),profile:Number(t[2]),rim:Number(t[3])};return de.every(o=>{let[s,i]=bt[o];return n[o]>=s&&n[o]<=i})?n:null}function _(e){if(e.width==null)return"";if(e.profile==null)return String(e.width);let t=`${e.width}/${e.profile}`;return e.rim==null?t:`${t} R${e.rim}`}function me(e){return[_({width:e.width}),_({width:e.width,profile:e.profile}),_(e)]}var x=["alloy-wheel","tyre"],he=["alloy-wheel"],F={"alloy-wheel":"Alloy wheels",tyre:"Tyres"};var Cn=x.map(e=>({value:e,label:F[e]}));function ye(e){return e==null?[...he]:Array.isArray(e)?x.filter(t=>e.includes(t)):[...he]}var m=e=>e;function d(e){return m(e).kind==="tyre"?"tyre":"alloy-wheel"}function H(e){return m(e).brand??""}function ge(e){return m(e).prices??void 0}function be(e){return m(e).inStock!==!1}function Se(e){let t=m(e),n=d(e)==="tyre"?t.rimDiameters:t.sizes;return Array.isArray(n)?n.filter(r=>typeof r=="number"&&Number.isFinite(r)):[]}function Y(e){return d(e)==="tyre"?[]:(m(e).finishes??[]).filter(t=>typeof t?.family=="string").map(t=>({family:t.family,color:t.color??null}))}function Pe(e){return Y(e).map(t=>t.family)}function ke(e){if(d(e)==="tyre")return[];let t=m(e);return Array.isArray(t.categories)?t.categories:t.process?[t.process]:[]}function xe(e){return d(e)==="tyre"?[]:m(e).spec?.pcds??[]}function we(e){return d(e)!=="tyre"?[]:m(e).tyreTypes??[]}function Le(e){return d(e)!=="tyre"?[]:m(e).speedRatings??[]}function Te(e){if(d(e)!=="tyre")return[];let t=m(e).sizes;return Array.isArray(t)?t.map(n=>W(typeof n=="string"?n:null)).filter(n=>n!==null):[]}var G=e=>typeof e=="string"&&e?e:void 0;function V(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function Oe(e,t){return Object.hasOwn(e,t)}var Ae=null;function _e(e,t){return t?e.replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g,(n,r)=>Oe(t,r)?String(V(t,r)):n):e}function g(e,t){let n=Ae?V(Ae,e):void 0;if(typeof n=="function"){try{let r=G(n(t??{}));if(r)return r}catch{}return _e(e,t)}return _e(G(n)??e,t)}function q(e){return(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}var E=(e,t,n,r)=>({default:e,min:t,max:n,step:r}),jn=E(30,0,100,10),Wn=E(0,0,100,5),Hn=E(100,0,100,5),Yn=E(2,0,4,.5);function Fe(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.text=="string"?e.text.trim():""}var Ee="homepage";var R=[{value:"page",label:"Page"},{value:"anchor",label:"Anchor"},{value:"blog",label:"Blog post",needs:"service"},{value:"product",label:"Product",needs:"commerce"},{value:"popup",label:"Popup"},{value:"custom",label:"Custom URL"}];function I(e){return e.offersCommerce&&e.offersService?R:R.filter(t=>!t.needs||(t.needs==="commerce"?e.offersCommerce:e.offersService))}var Z="#popup:";function Re(e){return`${Z}${e}`}function Ie(e){return e.startsWith(Z)&&e.slice(Z.length).trim()||null}function b(e){return e===Ee?"/":`/${e}`}function N(e){return`/journal/${e}`}function v(e){return`/wheels/${e}`}function C(e,t){return`${b(e)}#${t}`}function M(...e){let t=new Set,n=[];for(let r of e)for(let o of r?.content??[]){let s=Fe(o?.props?.anchor);if(!s)continue;let i=q(s);!i||t.has(i)||(t.add(i),n.push({slug:i,name:s}))}return n}function Ne(e){return/^\/wheels\/[^/?#]+(?:[?#].*)?$/.test(e)}var St=()=>({choosePage:g("Choose a page"),chooseSection:g("Choose a section"),noSections:g("No section anchors yet"),sectionHint:g("Jumps to a section on that page."),choosePost:g("Choose a post"),chooseProduct:g("Choose a product"),choosePopup:g("Choose a popup")});function K(e,t,n){if(!e)return"page";if(Ie(e))return"popup";if(e.startsWith("/journal/"))return"blog";if(Ne(e))return"product";if(e.includes("#")){let r=e.slice(0,e.indexOf("#"));if(r===""||r==="/"||t.includes(r))return"anchor"}return e==="/"||t.includes(e)||n&&n.listingPaths.includes(n.targetOf(e))?"page":"custom"}function ve(e,t){let n=St(),r=e.pages.map(c=>({value:b(c.slug),label:c.title})),o=t?.pageOptions?t.pageOptions(r):r,s=o.map(c=>c.value),i=e.pages.map(c=>({label:c.title,options:M(...c.docs).map(u=>({value:C(c.slug,u.slug),label:u.name}))})).filter(c=>c.options.length>0),l=c=>{switch(c){case"page":return{type:"select",options:o,placeholder:n.choosePage};case"anchor":return{type:"groups",groups:i,placeholder:i.length?n.chooseSection:n.noSections};case"blog":return{type:"select",options:e.posts.map(u=>({value:N(u.slug),label:u.title||u.slug})),placeholder:n.choosePost};case"product":return{type:"select",options:e.products.map(u=>({value:u.href,label:u.name||u.href})),placeholder:n.chooseProduct};case"popup":return{type:"select",options:(e.popups??[]).map(u=>({value:Re(u.slug),label:u.title||u.slug})),placeholder:n.choosePopup};case"custom":return{type:"text"}}},a=I(e.offers).map(c=>({value:c.value,label:g(c.label),target:l(c.value),...c.value==="anchor"?{hint:n.sectionHint}:{},...c.value==="blog"||c.value==="product"||c.value==="popup"?{hideWhenEmpty:!0}:{}}));if(!t)return{kinds:a,rules:{kindOf:c=>K(c,s),targetOf:c=>c,readFilter:()=>null,withFilter:c=>c}};let p=c=>{let u=t.withFilter(c,null);return t.listingPaths.includes(u)?u:c};return{kinds:a,rules:{kindOf:c=>K(c,s,{listingPaths:t.listingPaths,targetOf:p}),targetOf:p,readFilter:t.readFilter,withFilter:t.withFilter},filtersFor:c=>t.listingPaths.includes(c)?t.filtersFor(c):null}}var Ce=Object.freeze([]);function X(e,t){return e.length===0?e:e.filter(n=>n.kind===void 0||n.kind===t)}function Me(e,t){let n=t==="filter"?"filterOrder":"cardOrder",r=new Map;for(let o of e){let s=o[n];if(typeof s!="number"||!Number.isFinite(s))continue;let i=r.get(o.fieldKey);(i===void 0||s<i)&&r.set(o.fieldKey,s)}return o=>o?r.get(o):void 0}function Ke(e,t,n,r){let o=new Map;for(let a of n){let p=a[r];typeof p=="number"&&o.set(a.fieldKey,p)}if(o.size===0)return e;let s=[],i=[];e.forEach((a,p)=>{let c=t(a);c&&(s.push(p),i.push({item:a,index:p,order:o.get(c)}))}),i.sort((a,p)=>a.order!==void 0&&p.order!==void 0?a.order-p.order||a.index-p.index:a.order!==void 0?-1:p.order!==void 0?1:a.index-p.index);let l=[...e];return s.forEach((a,p)=>{l[a]=i[p].item}),l.every((a,p)=>a===e[p])?e:l}function ze(e){return kt(e,"filter")}var Pt="collection";function Q(e,t){return{tyreSizes:{},brands:{"alloy-wheel":"brand",tyre:"brand"},finishes:{"alloy-wheel":"wheel_finish_ref"},diameters:{"alloy-wheel":"diameter",tyre:"rim_diameter"},collections:{"alloy-wheel":Pt},pcds:{"alloy-wheel":"pcd"},tyreTypes:{tyre:"tire_type"},speedRatings:{tyre:"speed_rating"}}[e]?.[t]}function kt(e,t){let n=new Set(e.filter(r=>r[t]===!1).map(r=>r.fieldKey));return r=>!r||!n.has(r)}function xt(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function $e(e,t){let n=e?.[t];return xt(n)?n:null}function De(e,t,n,r){if(n==null&&r==null)return!0;let o=$e(e,t);return!(o===null||n!=null&&o<n||r!=null&&o>r)}function Ue(e){let t=e.spec?.lugs;return typeof t=="number"?t:null}var wt={recommended:"Recommended","price-asc":"Price \xB7 low to high","price-desc":"Price \xB7 high to low",new:"Newest",name:"Name A\u2013Z"},Rr=Object.keys(wt);var J=["tyreSizes","brands","finishes","diameters","collections","pcds","tyreTypes","speedRatings"],ee={tyreSizes:["tyre"],brands:["alloy-wheel","tyre"],finishes:["alloy-wheel"],diameters:["alloy-wheel","tyre"],collections:["alloy-wheel"],pcds:["alloy-wheel"],tyreTypes:["tyre"],speedRatings:["tyre"]},Lt={diameters:"tyreSizes"};function Tt(e){if(e.length===0)return[];let t=J.filter(n=>e.every(r=>ee[n].includes(r)));return t.filter(n=>{let r=Lt[n];return!r||!t.includes(r)})}function Ot(e){let t=new Set;for(let n of e)t.add(d(n));return[...t]}var Be={tyreSizes:[],brands:[],finishes:[],diameters:[],collections:[],pcds:[],tyreTypes:[],speedRatings:[],priceMax:null,priceMin:null,inStockOnly:!1,kind:null,sort:"recommended",page:1};function At(e,t,n,r=null,o="fail"){let s=d(e),i=l=>o==="fail"||(l==="lugs"?s==="alloy-wheel":ee[l].includes(s));if(r!=="kind"&&t.kind&&s!==t.kind)return!1;for(let l of J){if(r===l)continue;let a=t[l];if(a.length===0||!i(l))continue;let p=a.map(String);if(!je(e,l).some(c=>p.includes(c)))return!1}if(r!=="lugs"&&t.lugs&&t.lugs.length>0&&i("lugs")){let l=Ue(e);if(l===null||!t.lugs.includes(l))return!1}return!(r!=="price"&&!De(ge(e),n,t.priceMin??null,t.priceMax)||r!=="inStock"&&t.inStockOnly&&!be(e))}var _t={tyreSizes:"Size",brands:"Brand",finishes:"Colour",diameters:"Size \xB7 diameter",collections:"Collection",pcds:"PCD \xB7 fitment",tyreTypes:"Tyre type",speedRatings:"Speed rating"};function je(e,t){switch(t){case"tyreSizes":return[...new Set(Te(e).flatMap(me))];case"brands":return H(e)?[H(e)]:[];case"finishes":return Pe(e);case"diameters":return Se(e).map(String);case"collections":return ke(e);case"pcds":return xe(e);case"tyreTypes":return we(e);case"speedRatings":return Le(e)}}function Ft(e){let t=new Map;for(let n of e)for(let r of Y(n))r.color&&!t.has(r.family)&&t.set(r.family,r.color);return t}function We(e,t,n,r=Ot(e),o=Ce,s="fail"){let i=u=>Rt(u,r,o),l=Ft(e),p=(s==="pass"?J.filter(u=>r.some(P=>ee[u].includes(P))):Tt(r)).filter(u=>u!=="tyreSizes").filter(i).map(u=>{let P=t[u].map(String),ce=new Set,B=new Map,O=new Map;for(let f of e){let S=je(f,u);for(let h of S)ce.add(h);for(let h of new Set(S))O.set(h,(O.get(h)??0)+1);if(At(f,t,n,u,s))for(let h of new Set(S))B.set(h,(B.get(h)??0)+1)}let ut=[...ce].map(f=>({value:f,label:u==="diameters"?`${f}\u2033`:f,count:B.get(f)??0,checked:P.includes(f),swatch:u==="finishes"?l.get(f)??null:null})).sort((f,S)=>{if(u==="diameters")return Number(f.value)-Number(S.value);let h=(O.get(S.value)??0)-(O.get(f.value)??0);return h!==0?h:f.value.localeCompare(S.value)});return{key:u,label:_t[u],options:ut}}).filter(u=>u.options.length>Et),c=[];for(let u of p){let P=It(u.key,r,o);P!==void 0&&c.push({fieldKey:u.key,filterOrder:P})}return[...Ke(p,u=>u.key,c,"filterOrder")]}var Et=1;function He(e){return e.showCollection===!1?["collections"]:[]}function Rt(e,t,n){return t.length===0||n.length===0?!0:t.some(r=>ze(X(n,r))(Q(e,r)))}function It(e,t,n){if(n.length===0)return;let r;for(let o of t){let s=Me(X(n,o),"filter")(Q(e,o));s!==void 0&&(r===void 0||s<r)&&(r=s)}return r}var te={tyreSizes:"tyreSize",brands:"brand",finishes:"colour",diameters:"size",collections:"collection",pcds:"pcd",tyreTypes:"tyreType",speedRatings:"speed"},ne="type";var w=e=>!!e&&typeof e=="object"&&!Array.isArray(e),L=e=>w(e)&&typeof e.type=="string"&&w(e.props);var z=e=>Array.isArray(e)&&e.length>0&&e.every(L);function Nt(e){let t="";for(let n of e)t+=typeof n=="number"?`[${n}]`:t===""?n:`.${n}`;return t}function Ye(e,t){return t==="root"?e.root:e.components[t]}function Ge(e){return e?.fields??{}}function Ve(e,t){return Ge(Ye(e,t))}function qe(e,t){let n=[];return re(e,t,[],n),n}function re(e,t,n,r){for(let o of Object.keys(t)){let s=t[o];if(!s)continue;let i=[...n,o],l=e[o];if(s.type==="slot"){let a=Array.isArray(l);r.push({slot:Nt(i),segments:i,content:a?l:[],present:a})}else if(s.type==="object"&&s.objectFields&&w(l))re(l,s.objectFields,i,r);else if(s.type==="array"&&s.arrayFields&&Array.isArray(l)){let a=s.arrayFields;l.forEach((p,c)=>{w(p)&&re(p,a,[...i,c],r)})}}}function oe(e,t,n){return Ct(e,t,n).map(({slot:r,content:o})=>({slot:r,content:o}))}function $(e){let t=new TextEncoder,n=new Map(e.map(r=>[r,t.encode(r)]));return[...e].sort((r,o)=>{let s=n.get(r),i=n.get(o);if(s.length!==i.length)return s.length-i.length;for(let l=0;l<s.length;l++)if(s[l]!==i[l])return s[l]-i[l];return 0})}function Ct(e,t,n){let r=qe(e.props,Ve(t,e.type));if(n?.order!=="stored")return r;let o=$(Object.keys(e.props)),s=i=>{let l=i.present?o.indexOf(String(i.segments[0])):-1;return l<0?Number.POSITIVE_INFINITY:l};return r.map((i,l)=>({loc:i,i:l,r:s(i)})).sort((i,l)=>i.r-l.r||i.i-l.i).map(({loc:i})=>i)}var Ze=["Text","ImageBlock","ButtonBlock","Flex"];function k(){return{type:"slot",allow:[...Ze]}}var Mt=Ze.filter(e=>e!=="ButtonBlock");function Xe(){return{type:"slot",allow:[...Mt]}}var Kt="boxes",Qe={CardList:{template:Xe()},Cards:{template:k()},FAQ:{template:k()},Flex:{rowTitle:{type:"slot",allow:["Text"]},content:{type:"slot"}},Footprint:{template:k()},Grid:{content:{type:"slot"}},Hero:{slides:{type:"slot",ownPictures:!0},strip:{type:"slot",allow:["Flex"]}},HeroGroup:{content:{type:"slot"}},HeroSingle:{boxes:{type:"slot",allow:["HeroGroup"]}},HeroSlide:{groups:{type:"slot",allow:["HeroGroup"]}},Logos:{logos:{type:"slot",allow:["LogoBlock"]},template:{type:"slot",allow:["LogoBlock"]}},OrderSummary:{template:k()},ProcessSteps:{[Kt]:{type:"slot"},template:k()}};var zt={},$t=null;function Dt(){let e=Object.fromEntries(Object.entries(Qe).map(([t,n])=>[t,{fields:n}]));return $t??={components:{...e,...zt}}}function Ut(e){let t=e.props??{},n=typeof e.type=="string"?e.type:"",r=Dt(),o=n!==""&&Object.prototype.hasOwnProperty.call(r.components,n)?oe({type:n,props:t},r).map(l=>l.slot).filter(l=>!l.includes(".")):[],s=o.filter(l=>z(t[l])),i=$(Object.keys(t).filter(l=>!o.includes(l)&&z(t[l])));return[...s,...i]}function Je(e,t){let n=null;for(let r of Ut(e)){let o=e.props[r],s=t(o,r);s!==o&&((n??={...e.props})[r]=s)}return n?{...e,props:n}:e}var et="FilterBlock";var tt="AlloyWheelsListing";function Bt(e){let t=e??{},n=[];Array.isArray(t.content)&&n.push(t.content);for(let r of Object.values(t.zones??{}))Array.isArray(r)&&n.push(r);return n}function jt(e){let t=[],n=(r,o)=>{let s=[r,...o];for(let i of r)L(i)&&(t.push({node:i,order:t.length,lists:s}),Je(i,l=>(n(l,s),l)))};for(let r of Bt(e))n(r,[]);return t}function nt(e){return jt(e).map(t=>t.node)}function rt(e){return j(e.trim())}var T="/wheels",D="Products";function ot(e,t){return t>1?`${D} \xB7 ${e}`:D}function se(...e){for(let t of[tt,et])for(let n of e){let r=nt({content:n?.content}).find(o=>o.type===t);if(r)return r.props??{}}return null}function U(...e){return se(...e)!==null}function st(e,t){let n=e.filter(r=>U(...r.docs)).map(r=>b(r.slug));return t.fallback&&!n.includes(T)?[...n,T]:n}var ie=[ne,...Object.entries(te).filter(([e])=>e!=="tyreSizes").map(([,e])=>e)];function it(e){let t=e.indexOf("#"),n=t===-1?"":e.slice(t),r=t===-1?e:e.slice(0,t),o=r.indexOf("?");return{path:o===-1?r:r.slice(0,o),query:o===-1?"":r.slice(o+1),hash:n}}function Wt(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return e}}function lt(e){let t=new URLSearchParams(it(e).query);for(let n of ie){let r=t.get(n);if(r)return{param:n,value:r}}return null}function le(e,t){let{path:n,query:r,hash:o}=it(e),s=r.split("&").filter(i=>i&&!ie.includes(Wt(i.split("=")[0])));return t?.value&&s.push(`${encodeURIComponent(t.param)}=${encodeURIComponent(t.value)}`),`${n}${s.length?`?${s.join("&")}`:""}${o}`}function at(e,t){let n=le(e,null);return t.includes(n)?n:e}function Ht(e,t,n=[]){return K(e,t,{listingPaths:n,targetOf:r=>at(r,n)})}function Yt(e){return Array.isArray(e)?e.filter(t=>typeof t?.kind=="string"&&typeof t.field_key=="string").map(t=>({kind:t.kind,fieldKey:t.field_key,...typeof t.filter=="boolean"?{filter:t.filter}:{},filterOrder:t.filter_order??null})):[]}var ct="Product type",Gt="AUD";function ae(e,t){let n=t.listing??{},r=ye(n.kinds),o=e.filter(a=>r.includes(d(a))),s=He(n),i=We(o,Be,Gt,r,t.fieldUsage).filter(a=>!s.includes(a.key)).map(a=>({param:te[a.key],label:a.label,values:a.options.filter(p=>!p.value.includes(",")).map(p=>({value:p.value,label:p.label}))})).filter(a=>a.values.length>0),l=x.filter(a=>r.includes(a)&&o.some(p=>d(p)===a));return l.length>1&&i.unshift({param:ne,label:ct,values:l.map(a=>({value:a,label:F[a]}))}),i}function Vt(e){return t=>{let n=st(t,{fallback:e.offersCommerce}),r=t.filter(o=>U(...o.docs)).length;return{listingPaths:n,pageOptions:o=>{let s=o.map(i=>{let l=t.find(a=>b(a.slug)===i.value);return l&&U(...l.docs)?{...i,label:ot(l.title,r)}:i});return r===0&&e.offersCommerce&&!s.some(i=>i.value===T)&&s.push({value:T,label:D}),s},filtersFor:o=>{if(!n.includes(o))return null;let s=t.find(i=>b(i.slug)===o);return ae(e.catalogue,{listing:s?se(...s.docs):null,fieldUsage:e.fieldUsage})},readFilter:lt,withFilter:le}}}function qt(e){let t=Vt({catalogue:e.catalogue,fieldUsage:e.fieldUsage,offersCommerce:e.offers.offersCommerce})(e.pages),n=ve({pages:e.pages,posts:e.posts,products:e.products.map(r=>({href:v(r.slug),name:r.name||r.slug})),offers:e.offers},t);return{...n,rules:{...n.rules,isSafe:rt},filtersFor:n.filtersFor??(()=>null)}}function Qo(e,t){return ae(e,t)}export{T as BUILT_IN_LISTING_PATH,R as LINK_KINDS,ie as LISTING_FILTER_PARAMS,D as LISTING_PAGE_LABEL,ct as PRODUCT_TYPE_FILTER_LABEL,C as anchorPath,Yt as fieldUsageFromAdminRows,Ht as inferLinkKind,U as isProductListingPage,rt as isSafeLink,I as linkKindsFor,qt as linkPickerSetup,Qo as listingFilterFields,se as listingNode,ot as listingPageLabel,at as listingTarget,M as pageAnchors,b as pagePath,N as postPath,st as productListingPaths,lt as readListingFilter,v as wheelPath,le as withListingFilter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as
|
|
1
|
+
"use client";import{jsx as t,jsxs as c}from"react/jsx-runtime";import O from"next/link";import{useEffect as L}from"react";import{FormFieldInput as S,FormHoneypot as j,successMessageFor as I,useBoundForm as P,useFormSubmission as B}from"./formSubmission.js";import k from"./SectionNotice.js";import{ThanksCard as M}from"./ThanksCard.js";import{showsSentOnCanvas as _}from"../lib/content/thanks-slot.js";import{say as w}from"efficient-web-builder/format/lib/editor-words";import q from"./WebFormField.js";import{usePopupScope as W}from"./PopupHost.js";import{FIELD_INPUT_CLASS as F}from"../lib/field-input.js";import{cornerSidesShorthand as A,normalizeCornerSides as E}from"efficient-web-builder/format/lib/content/section-corners";import{cssLengthOf as H}from"efficient-web-builder/format/lib/content/css-length";import{withSideOnce as D}from"efficient-web-builder/format/lib/content/page-width";import{useSideSpaceOnce as R}from"efficient-web-builder/render/components/SideSpaceOnce";import{withRootPad as U}from"efficient-web-builder/render/lib/content/section-own-pads";import{useSectionPad as $}from"./SectionPadScope.js";function G({field:e,value:r,onChange:s,cornersClass:o=""}){const n={field:e,value:r,onChange:s};return e.type==="checkbox"?c("label",{className:"flex items-start gap-3",children:[t(S,{...n,className:"mt-1 size-4 accent-accent"}),c("span",{className:"font-mono text-[12px] font-semibold uppercase tracking-[0.16em] text-fg",children:[e.label,e.required?t("span",{className:"text-accent",children:" *"}):null]})]}):t(q,{label:e.label,required:e.required,children:t(S,{...n,className:(e.type==="textarea"?F+" resize-y":F)+o})})}function J(e,r,s){if(typeof e!="number"||!Number.isFinite(e))return null;const o=H(Math.max(0,e),s),n=E(r);return{style:{"--form-control-radius":n===null?o:A(o,n)},className:" [border-radius:var(--form-control-radius)]"}}function K({formSlug:e,heading:r,intro:s,submitText:o,finePrint:n,form:u,editing:i=!1,nodeId:d="",thanks:x,showSent:f,buttonCorners:h,buttonCornerSides:g,buttonCornersUnit:b}={}){const y=R(),p=$(),a=P(e,u),N=W();if(a===void 0)return t(k,{size:"short",children:w("Loading form…")});if(a===null)return t(k,{size:"short",children:i?w("Choose a form in the inspector, under Form."):"This form is unavailable."});const l=(r??"").trim()||a.title;return t("section",{className:"relative z-[2] border-t border-line bg-surface",children:c("div",{...U(D("mx-auto max-w-[var(--sf-site-width,1600px)] px-[var(--sf-site-gutter,40px)] py-[84px] max-[960px]:px-[min(24px,var(--sf-site-gutter,40px))]",y),p),children:[l&&t("h2",{className:"mb-4 font-heading2 text-[length:min(var(--size-headingMedium,44px),var(--sf-heading-max,9999px))] font-medium uppercase leading-none tracking-[-0.02em] text-fg max-view-wide:text-[length:min(var(--size-headingMedium,32px),var(--sf-heading-max,9999px))]",children:l}),(s??"").trim()&&t("p",{className:"mb-12 max-w-[640px] font-display text-[16px] leading-[1.6] text-fg-dim",children:s}),t(V,{form:a,formSlug:e,submitText:o,finePrint:n,editing:i,onSent:N?.markSent,nodeId:d,thanks:x,showSent:f,corners:J(h,g,b)})]})})}function Q({account:e}){const r="font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim";switch(e?.status){case"approved":return c("p",{className:r,children:["Check your email to set your password, then"," ",t(O,{href:"/login",className:"underline",children:"Sign in"})]});case"pending":return t("p",{className:r,children:"We're reviewing your application and will email you once it's approved."});case"rejected":return t("p",{className:r,children:"We couldn't open an account from this application. Please contact the shop."});default:return null}}function V({form:e,formSlug:r,submitText:s,finePrint:o,editing:n=!1,onSent:u,corners:i=null,nodeId:d="",thanks:x,showSent:f}){const{valueOf:h,set:g,honeypot:b,setHoneypot:y,submitting:p,done:a,account:N,error:l,handleSubmit:C}=B({form:e,formSlug:r,editing:n});L(()=>{a&&u?.()},[a]);const T=(s??"").trim()||e.submitButtonText?.trim()||"Submit",v=m=>c("div",{role:"status",className:"flex max-w-[560px] flex-col gap-3",children:[t("p",{className:"font-serif text-[19px] italic leading-[1.6] text-fg-dim",children:I(e)}),m,t(Q,{account:N})]});return a||_(f,n)?t(M,{ownerId:d,ownerType:"Form",Template:x,message:v(null),children:v}):c("form",{className:"flex max-w-[720px] flex-col gap-5",style:i?.style,onSubmit:C,children:[e.fields.map(m=>t(G,{field:m,value:h(m.key),onChange:z=>g(m.key,z),cornersClass:i?.className},m.key)),t(j,{value:b,onChange:y}),l&&t("p",{role:"alert",className:"font-mono text-[12px] uppercase tracking-[0.18em] text-alert",children:l}),t("button",{type:n?"button":"submit",disabled:p,className:`cursor-pointer self-start bg-btn px-8 py-4 font-mono text-[14px] uppercase tracking-[0.32em] text-btn-ink transition-colors hover:bg-fg hover:text-bg disabled:cursor-wait disabled:opacity-60${i?.className??""}`,children:p?"Sending…":T}),e.consentText?.trim()&&t("span",{className:"font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim/70",children:e.consentText}),(o??"").trim()&&t("span",{className:"font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim/70",children:o})]})}export{Q as AccountOutcome,V as FormBody,K as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as m,Fragment as T}from"react/jsx-runtime";import{partSkus as Be}from"../lib/catalog/part-skus.js";import ie from"next/link";import{useEffect as oe,useRef as me,useState as Ye}from"react";import{useCart as Ge}from"./CartContext.js";import{useSiteTakesOrders as Qe}from"./SiteRecordContext.js";import We from"./EmailCaptureForm.js";import{useEnglish as ce}from"./EnglishVariant.js";import{MarkedLabel as pe,heroView as Xe}from"./product-hero/hero-view.js";import{HeroOptionLooksProvider as qe,OptionDropdown as Je,OptionLabel as de,optionWords as Ze,useHeroOptionLooks as et}from"./product-hero/OptionLooks.js";import{DEFAULT_HERO_OPTION_LOOKS as tt}from"../lib/sections/hero-option-looks.js";import{useRootIsDark as lt}from"efficient-shell/theme";import{useStockAlertSignup as at}from"./useStockAlertSignup.js";import{SPARE_WORDS as nt,productCartLine as st}from"../lib/catalog/purchase.js";import{OPTION_ROW_ATTR as D}from"../lib/catalog/store-product.js";import{resolvingRowsAnswered as rt}from"../lib/catalog/product-options.js";import{trackViewItem as it}from"../lib/google-tag.js";import{DEFAULT_HERO_LAYOUT as ot,DEFAULT_HERO_RATIO as mt,DEFAULT_HERO_TEXT_ALIGN as ct,parseHeroLayout as pt,parseHeroRatio as dt,parseHeroTextAlign as ut}from"../lib/sections/hero-arrangement.js";import{MAX_SPARES as ft,UNITS_PER_SET as ue,formatPrice as fe}from"../lib/commerce.js";import{formatSelectionPrice as he}from"../lib/wheels/price-display.js";import{productIsDually as ht,productIsTwoObjects as bt,setSuppressesRow as gt}from"../lib/wheels/set-mode.js";import{CONTENT_CAP_GUTTER as be}from"../lib/sections/content-cap-gutter.js";import{STICKY_COLUMNS_CLASS as vt,STICKY_SECTION_ATTR as xt}from"../lib/sections/hero-sticky.js";import{STAGE_EDGE_ATTR as kt,stageEdgeClass as Tt,stageEdgeCols as yt}from"../lib/sections/hero-stage-edge.js";import{useStickyColumns as St}from"./useStickyColumns.js";import{BLOCK_ALIGN_TEXT as Ot}from"efficient-web-builder/format/lib/content/block-align";import{CardTemplateRows as M}from"efficient-web-builder/render/components/CardRowContext";import{InsideSiteColumn as U}from"efficient-web-builder/render/components/SiteGutterFrame";import{cardRow as _t}from"efficient-web-builder/format/lib/content/card-template";import{optionCardRows as Nt}from"../lib/sections/filter-option-rows.js";import{HERO_OPTION_SLOT as Et,HERO_TILE_SLOT as Rt}from"../lib/content/hero-option-seed.js";import{HERO_BUY_SLOT as Lt,HERO_QUANTITY_PART as wt,HERO_SAVE_PART as Ct}from"../lib/content/hero-buy-seed.js";import{HERO_PART as b}from"../lib/content/hero-seed.js";import At from"./card-pieces/CardQuantity.js";import It from"./card-pieces/CardSave.js";import $t from"./card-pieces/CardStatedFacts.js";import{HeroStateProvider as Pt}from"./card-pieces/ProductCardState.js";import{PRODUCT_HERO_TYPE as z}from"../lib/document/document-nodes.js";import{withSideOnce as ge}from"efficient-web-builder/format/lib/content/page-width";import{useSideSpaceOnce as Ht}from"efficient-web-builder/render/components/SideSpaceOnce";import{withRootPad as ve}from"efficient-web-builder/render/lib/content/section-own-pads";import{useSplitPads as Dt}from"./SectionPadScope.js";const Mt=4e3;function Ut(e){return e?[e.year,e.make,e.model,e.modification].join("-"):""}const xe=[{}],zt=(e,s)=>s===wt?t(At,{}):s===Ct?t(It,{}):null,jt="[&>[data-sf-repeat]]:contents [&>[data-sf-repeat]>div]:contents";function Ft({product:e,selection:s,onLightbox:i,editing:r=!1,showVehicleFitment:c=!0,heroLayout:n=ot,imageRatio:o=mt,textAlign:l=ct,showSpecTable:O=!0,stickyColumns:Te=!1,stageToEdge:ye=!1,showBreadcrumb:j=!0,nodeId:_,template:Se,optionTemplate:Oe,optionPressTitles:_e,tileTemplate:Ne,buyTemplate:Ee,optionLooks:Re=tt}){const F=Ht(),Le=ce(),u=pt(n),K=ut(l),k=dt(o),N=Te===!0&&u!=="stacked",y=ye===!0&&u!=="stacked",V=me(null);St(V,N);const we=y?yt(k,u==="imageRight"):u==="imageRight"?`${100-k}fr ${k}fr`:`${k}fr ${100-k}fr`,E=y?{gap:"",y:"",yTablet:""}:{gap:"gap-10 ",y:"py-14 ",yTablet:"max-view-tablet:py-8 "},{picked:Ce,pick:B,qty:Y,setQty:Ae,choice:G,setChoice:Ie,angleIdx:Qt,setAngleIdx:Wt,showValidation:$e,setShowValidation:R,manualMode:Q,vehicle:L,rows:W,facts:Pe,part:f,outOfStock:X,offer:w,preOrder:C,canAddToCart:q,currency:g,price:d,set:J,msrpLabel:He}=s,p=Xe(e,s,r),Z=ht(e),De=bt(e),A=c?p.vehicle:null,Me=c?p.vehicleMemory:null,ee=!lt({whenUnset:!0}),{warmCatalog:te}=Ge(),S=Qe();oe(()=>{!r&&S&&te(e.kind,e.slug)},[r,S,e.kind,e.slug,te]);const le=W.filter(a=>!C||a.values.length>0),ae=le.filter(a=>a.role==="resolves"),I=le.filter(a=>a.role==="describes"&&!gt(De,a.key)),ne=I.findIndex(a=>a.chosen===null),se=(!A||!p.vehicleAnswersSpecs||s.fitmentSet)&&rt(W,C)?ne===-1?I:I.slice(0,ne+1):[],Ue=[...ae,...se];function ze(){return q?(R(!1),r?null:st(e,f,Ce,{choice:G,qty:Y},{fitmentLabel:Q?p.specCaption:L.appliedName?`For ${L.appliedName}`:"",fitmentKey:Q?`manual|${p.specCaption}`:`vehicle|${Ut(L.applied?.vehicle)}`})):(R(!0),window.setTimeout(()=>R(!1),Mt),null)}const je={kind:"hero",msrpLabel:He||null,amount:he(d,g),unitLabel:d.priced?p.unitLabel:null,packBadge:d.setTotal!=null?`${w.quantityLabel}: ${fe(J,g)}`:null,buy:{isSet:Z,priced:d.priced,outOfStock:X,canAdd:q,totalLabel:d.setTotal!=null?fe(J,g):null,lineToAdd:ze},qty:Y,setQty:Ae,takesQty:S&&!(Z&&!d.priced),save:{slug:e.slug,name:e.name},facts:O?Pe:null,title:{eyebrow:e.eyebrow,name:p.heading,badge:e.badge||null},product:e,selection:s,openLightbox:i,sku:Be(f),designCode:e.kind==="alloy-wheel"&&e.source.designCode||null,setLine:Bt(d,Vt(w.quantityLabel,e.kind),g)},$={nodeId:_??"",template:Oe,tileTemplate:Ne,pressTitles:_e,editing:r},h=!!(C&&p.preOrder),Fe={[b.fitmentLine]:Me,[b.options]:m(qe,{looks:Re,children:[ae.map(a=>t(ke,{row:a,onPick:B,options:$},a.key)),!h&&A,!h&&se.map(a=>t(ke,{row:a,onPick:B,options:$},a.key))]}),[b.facts]:h?null:t($t,{}),[b.howMany]:h?null:t(Yt,{offer:w,takesOrders:S,choice:G,setChoice:Ie,options:$}),[b.buy]:h?p.preOrder:t(U,{children:t(M,{ownerId:_??"",ownerType:z,slot:Lt,Template:Ee,rows:xe,fallback:null,hostParts:zt,children:a=>a})}),[b.notify]:!h&&X&&f?t(Gt,{partNumbers:f.components.map(a=>a.partNumber),productSlug:e.slug},f.id):null,[b.reminder]:!h&&$e?Ve():null},Ke=(a,v)=>Fe[v]??null;function Ve(){const a=Ue.filter(H=>H.chosen===null).map(H=>Le(H.prompt).replace(/^Select\s+/i,""));if(A&&p.vehicleAnswersSpecs&&!s.fitmentSet&&a.push("vehicle fitment"),a.length===0)return null;const v=a.length===1?a[0]:a.length===2?`${a[0]} and ${a[1]}`:`${a.slice(0,-1).join(", ")}, and ${a.at(-1)}`;return m("p",{role:"alert",className:"-mt-1 font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.18em]",style:{color:"var(--alert)"},children:["Please select ",v," first."]})}const re=me(null);oe(()=>{r||re.current===e.slug||(re.current=e.slug,it({itemId:f?`${e.slug}|${f.id}`:e.slug,itemName:e.name,variant:p.metaValue,pricePerSet:d.setTotal??d.fromSetTotal??0,currency:g}))},[r,e.slug,e.name,p.metaValue,f,d,g]);const P=Dt();return m(T,{children:[j&&t("nav",{...ve(ge(`border-b border-line ${be} pt-4 pb-4 font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.2em] text-fg-dim max-view-tablet:px-[min(20px,var(--sf-site-gutter,40px))]`,F),P?.first?.atTop,ee?void 0:{background:"var(--section-bg)"}),children:e.crumbs.map((a,v)=>m("span",{children:[v>0&&m(T,{children:[t("span",{className:"mx-3 text-accent",children:"/"}),t("wbr",{})]}),a.href?t(ie,{href:a.href,className:"hover:text-fg",children:t(pe,{text:a.label})}):t("span",{className:"text-fg",children:t(pe,{text:a.label})})]},`${a.label}-${v}`))}),t("section",{ref:V,"data-hero-layout":u,"data-hero-align":K,...N?{[xt]:""}:{},...y?{[kt]:""}:{},...ve([ge(`grid ${E.gap}${be} ${E.y}max-view-tablet:px-[min(20px,var(--sf-site-gutter,40px))] ${E.yTablet}${jt}`,F),K==="center"?Ot.center:"",u==="stacked"?"grid-cols-1":"[grid-template-columns:var(--hero-cols)] max-view-desktop:[grid-template-columns:minmax(0,1fr)]",N?vt:"",y?Tt(u==="imageRight"):""].filter(Boolean).join(" "),j?P?.second?.atTop:P?.secondOnly?.atTop,{...ee?{}:{background:"var(--section-bg)"},...u==="stacked"?{}:{"--hero-cols":we}}),children:t(Pt,{value:je,children:t(U,{children:t(M,{ownerId:_??"",ownerType:z,Template:Se,rows:xe,fallback:null,hostParts:Ke,children:a=>a})})})})]})}const Kt="wheels";function Vt(e,s){return s==="alloy-wheel"&&/\d$/.test(e)?`${e} ${Kt}`:e}function Bt(e,s,i){if(!e.priced)return null;const r=e.setTotal??e.fromSetTotal;return r==null?null:{label:s,total:he({...e,unit:r,isFrom:e.setTotal==null},i)}}function Yt({offer:e,takesOrders:s,choice:i,setChoice:r,options:c}){return e.packs.length>0||s&&(e.extra||e.spareCounts.length>0)?m("div",{className:"border-b border-line pb-[26px]",children:[e.packs.length>0&&m(T,{children:[t("div",{className:"mb-3.5 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.22em] text-fg",children:"How many"}),t("div",{className:"flex flex-wrap gap-1.5",children:t(x,{hero:c,values:e.packs,item:n=>({label:n.label}),picked:n=>i.unit===n.value,press:n=>()=>r(o=>({...o,unit:n.value}))})})]}),s&&e.extra&&m("label",{className:`${e.packs.length>0?"mt-3.5 ":""}flex cursor-pointer items-center gap-3 font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.16em] text-fg`,children:[t("input",{type:"checkbox",checked:i.spares>0,onChange:n=>r(o=>({...o,spares:n.target.checked?ft:0})),className:"h-4 w-4 cursor-pointer accent-[var(--accent)]"}),e.extra.label]}),s&&e.spareCounts.length>0&&m(T,{children:[t("div",{className:"mb-3.5 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.22em] text-fg",children:nt.howMany}),t("div",{className:"flex flex-col gap-1.5 sm:flex-row sm:flex-wrap",children:t(x,{hero:c,values:e.spareCounts,item:n=>({label:`${n.value} · ${n.label}`}),picked:n=>i.spares===n.value-ue,press:n=>()=>r(o=>({...o,spares:n.value-ue}))})})]}),s&&e.spareSide&&m(T,{children:[t("div",{className:"mb-3.5 mt-[26px] font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.22em] text-fg",children:e.spareSide.label}),t("div",{className:"flex flex-wrap gap-1.5",children:t(x,{hero:c,values:e.spareSide.options,item:n=>({label:n.label}),picked:n=>i.spareSide===n.value,press:n=>()=>r(o=>({...o,spareSide:n.value}))})})]})]}):null}function ke({row:e,onPick:s,options:i}){const r=ce(),c=et();if(e.values.length===0&&!e.empty)return null;const n=e.values.find(l=>l.value===e.chosen),o=n&&[n.label,n.note].filter(Boolean).join(" · ");return e.values.length>0&&e.display==="swatch"&&c.finish==="tiles"?m("div",{[D]:e.key,children:[t(de,{label:r(e.label),chosen:n?.label}),t("div",{className:"flex flex-wrap gap-2","data-option-tiles":"",children:t(x,{hero:i,tiles:!0,values:e.values,item:l=>({swatch:l.swatch??"",name:l.label}),label:l=>l.label,picked:l=>l.value===e.chosen,press:l=>()=>s(e.key,l.value)})})]}):e.values.length>0&&e.display==="pill"&&e.role==="resolves"&&c.size==="dropdown"?m("div",{[D]:e.key,children:[t(de,{label:r(e.label)}),t(Je,{rowKey:e.key,label:r(e.label),shown:o||r(e.prompt),items:e.values.map(l=>({value:l.value,label:Ze(l)})),value:e.chosen??"",onPick:l=>s(e.key,l),editing:i.editing})]}):m("div",{className:"border-b border-line pb-[26px]",[D]:e.key,children:[m("div",{className:"mb-3.5 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.22em] text-fg",children:[r(e.label)," · ",t("span",{className:"text-accent",children:o??r(e.prompt)})]}),e.values.length===0?m("p",{className:"font-mono text-[length:var(--size-body,12px)] leading-relaxed tracking-[0.1em] text-fg-dim",children:[e.empty.text," ",t(ie,{href:e.empty.href,className:"text-accent hover:underline",children:e.empty.linkText})]}):e.display==="swatch"?t("div",{className:"flex flex-wrap gap-2 [&>*]:max-w-full",children:t(x,{hero:i,values:e.values,item:l=>({swatch:l.swatch??"",name:l.label}),picked:l=>l.value===e.chosen,press:l=>()=>s(e.key,l.value)})}):t("div",{className:"flex flex-wrap gap-1.5",children:t(x,{hero:i,values:e.values,item:l=>({label:l.label,note:l.note??""}),picked:l=>l.value===e.chosen,press:l=>()=>s(e.key,l.value)})})]})}function x({hero:e,values:s,item:i,label:r,picked:c,press:n,tiles:o=!1}){const l=Nt(s,{item:i,selected:c,press:n,label:r});return t(U,{children:t(M,{ownerId:e.nodeId,ownerType:z,slot:o?Rt:Et,Template:o?e.tileTemplate:e.template,rows:l.items.map(_t),items:l.items,states:l.states,actions:e.editing?void 0:l.actions,pressTitles:o?void 0:e.pressTitles,fallback:null,children:O=>O})})}function Gt({partNumbers:e,productSlug:s}){const[i,r]=Ye(""),{status:c,submit:n,reset:o}=at();function l(){n({partNumbers:e,email:i,productSlug:s})}return c==="sent"?t("p",{className:"-mt-1 font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.18em] text-accent",children:"We'll email you when it's back."}):t(We,{className:"-mt-1",email:i,onEmailChange:r,status:c,onResetVerdict:o,onSubmit:l,inputAriaLabel:"Email for the back-in-stock alert",submitLabel:"Notify me when back",buttonClassName:"cursor-pointer whitespace-nowrap border-2 border-btn px-4 font-mono text-[length:var(--size-label,11px)] font-bold uppercase tracking-[0.22em] text-btn transition-colors hover:bg-btn hover:text-btn-ink disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-btn",errorMessage:"Couldn't save that — please try again."})}export{Ft as default};
|
|
1
|
+
"use client";import{jsx as t,jsxs as m,Fragment as T}from"react/jsx-runtime";import{partSkus as Be}from"../lib/catalog/part-skus.js";import ie from"next/link";import{useEffect as oe,useRef as me,useState as Ye}from"react";import{useCart as Ge}from"./CartContext.js";import{useSiteTakesOrders as Qe}from"./SiteRecordContext.js";import We from"./EmailCaptureForm.js";import{useEnglish as ce}from"./EnglishVariant.js";import{MarkedLabel as pe,heroView as Xe}from"./product-hero/hero-view.js";import{HeroOptionLooksProvider as qe,OptionDropdown as Je,OptionLabel as de,optionWords as Ze,useHeroOptionLooks as et}from"./product-hero/OptionLooks.js";import{DEFAULT_HERO_OPTION_LOOKS as tt}from"../lib/sections/hero-option-looks.js";import{useRootIsDark as lt}from"efficient-shell/theme";import{useStockAlertSignup as at}from"./useStockAlertSignup.js";import{SPARE_WORDS as nt,productCartLine as st}from"../lib/catalog/purchase.js";import{OPTION_ROW_ATTR as D}from"../lib/catalog/store-product.js";import{resolvingRowsAnswered as rt}from"../lib/catalog/product-options.js";import{trackViewItem as it}from"../lib/google-tag.js";import{DEFAULT_HERO_LAYOUT as ot,DEFAULT_HERO_RATIO as mt,DEFAULT_HERO_TEXT_ALIGN as ct,parseHeroLayout as pt,parseHeroRatio as dt,parseHeroTextAlign as ut}from"../lib/sections/hero-arrangement.js";import{MAX_SPARES as ft,UNITS_PER_SET as ue,formatPrice as fe,spareAxleOf as ht}from"../lib/commerce.js";import{formatSelectionPrice as he}from"../lib/wheels/price-display.js";import{productIsDually as bt,productIsTwoObjects as gt,setSuppressesRow as xt}from"../lib/wheels/set-mode.js";import{CONTENT_CAP_GUTTER as be}from"../lib/sections/content-cap-gutter.js";import{STICKY_COLUMNS_CLASS as vt,STICKY_SECTION_ATTR as kt}from"../lib/sections/hero-sticky.js";import{STAGE_EDGE_ATTR as Tt,stageEdgeClass as yt,stageEdgeCols as St}from"../lib/sections/hero-stage-edge.js";import{useStickyColumns as Ot}from"./useStickyColumns.js";import{BLOCK_ALIGN_TEXT as _t}from"efficient-web-builder/format/lib/content/block-align";import{CardTemplateRows as M}from"efficient-web-builder/render/components/CardRowContext";import{InsideSiteColumn as U}from"efficient-web-builder/render/components/SiteGutterFrame";import{cardRow as Nt}from"efficient-web-builder/format/lib/content/card-template";import{optionCardRows as Et}from"../lib/sections/filter-option-rows.js";import{HERO_OPTION_SLOT as Rt,HERO_TILE_SLOT as Lt}from"../lib/content/hero-option-seed.js";import{HERO_BUY_SLOT as wt,HERO_QUANTITY_PART as At,HERO_SAVE_PART as Ct}from"../lib/content/hero-buy-seed.js";import{HERO_PART as b}from"../lib/content/hero-seed.js";import It from"./card-pieces/CardQuantity.js";import $t from"./card-pieces/CardSave.js";import Pt from"./card-pieces/CardStatedFacts.js";import{HeroStateProvider as Ht}from"./card-pieces/ProductCardState.js";import{PRODUCT_HERO_TYPE as z}from"../lib/document/document-nodes.js";import{withSideOnce as ge}from"efficient-web-builder/format/lib/content/page-width";import{useSideSpaceOnce as Dt}from"efficient-web-builder/render/components/SideSpaceOnce";import{withRootPad as xe}from"efficient-web-builder/render/lib/content/section-own-pads";import{useSplitPads as Mt}from"./SectionPadScope.js";const Ut=4e3;function zt(e){return e?[e.year,e.make,e.model,e.modification].join("-"):""}const ve=[{}],jt=(e,s)=>s===At?t(It,{}):s===Ct?t($t,{}):null,Ft="[&>[data-sf-repeat]]:contents [&>[data-sf-repeat]>div]:contents";function Kt({product:e,selection:s,onLightbox:i,editing:r=!1,showVehicleFitment:c=!0,heroLayout:n=ot,imageRatio:o=mt,textAlign:l=ct,showSpecTable:O=!0,stickyColumns:Te=!1,stageToEdge:ye=!1,showBreadcrumb:j=!0,nodeId:_,template:Se,optionTemplate:Oe,optionPressTitles:_e,tileTemplate:Ne,buyTemplate:Ee,optionLooks:Re=tt}){const F=Dt(),Le=ce(),u=pt(n),K=ut(l),k=dt(o),N=Te===!0&&u!=="stacked",y=ye===!0&&u!=="stacked",V=me(null);Ot(V,N);const we=y?St(k,u==="imageRight"):u==="imageRight"?`${100-k}fr ${k}fr`:`${k}fr ${100-k}fr`,E=y?{gap:"",y:"",yTablet:""}:{gap:"gap-10 ",y:"py-14 ",yTablet:"max-view-tablet:py-8 "},{picked:Ae,pick:B,qty:Y,setQty:Ce,choice:G,setChoice:Ie,angleIdx:Wt,setAngleIdx:Xt,showValidation:$e,setShowValidation:R,manualMode:Q,vehicle:L,rows:W,facts:Pe,part:f,outOfStock:X,offer:w,preOrder:A,canAddToCart:q,currency:g,price:d,set:J,msrpLabel:He}=s,p=Xe(e,s,r),Z=bt(e),De=gt(e),C=c?p.vehicle:null,Me=c?p.vehicleMemory:null,ee=!lt({whenUnset:!0}),{warmCatalog:te}=Ge(),S=Qe();oe(()=>{!r&&S&&te(e.kind,e.slug)},[r,S,e.kind,e.slug,te]);const le=W.filter(a=>!A||a.values.length>0),ae=le.filter(a=>a.role==="resolves"),I=le.filter(a=>a.role==="describes"&&!xt(De,a.key)),ne=I.findIndex(a=>a.chosen===null),se=(!C||!p.vehicleAnswersSpecs||s.fitmentSet)&&rt(W,A)?ne===-1?I:I.slice(0,ne+1):[],Ue=[...ae,...se];function ze(){return q?(R(!1),r?null:st(e,f,Ae,{choice:G,qty:Y},{fitmentLabel:Q?p.specCaption:L.appliedName?`For ${L.appliedName}`:"",fitmentKey:Q?`manual|${p.specCaption}`:`vehicle|${zt(L.applied?.vehicle)}`})):(R(!0),window.setTimeout(()=>R(!1),Ut),null)}const je={kind:"hero",msrpLabel:He||null,amount:he(d,g),unitLabel:d.priced?p.unitLabel:null,packBadge:d.setTotal!=null?`${w.quantityLabel}: ${fe(J,g)}`:null,buy:{isSet:Z,priced:d.priced,outOfStock:X,canAdd:q,totalLabel:d.setTotal!=null?fe(J,g):null,lineToAdd:ze},qty:Y,setQty:Ce,takesQty:S&&!(Z&&!d.priced),save:{slug:e.slug,name:e.name},facts:O?Pe:null,title:{eyebrow:e.eyebrow,name:p.heading,badge:e.badge||null},product:e,selection:s,openLightbox:i,sku:Be(f),designCode:e.kind==="alloy-wheel"&&e.source.designCode||null,setLine:Yt(d,Bt(w.quantityLabel,e.kind),g)},$={nodeId:_??"",template:Oe,tileTemplate:Ne,pressTitles:_e,editing:r},h=!!(A&&p.preOrder),Fe={[b.fitmentLine]:Me,[b.options]:m(qe,{looks:Re,children:[ae.map(a=>t(ke,{row:a,onPick:B,options:$},a.key)),!h&&C,!h&&se.map(a=>t(ke,{row:a,onPick:B,options:$},a.key))]}),[b.facts]:h?null:t(Pt,{}),[b.howMany]:h?null:t(Gt,{offer:w,takesOrders:S,choice:G,setChoice:Ie,options:$}),[b.buy]:h?p.preOrder:t(U,{children:t(M,{ownerId:_??"",ownerType:z,slot:wt,Template:Ee,rows:ve,fallback:null,hostParts:jt,children:a=>a})}),[b.notify]:!h&&X&&f?t(Qt,{partNumbers:f.components.map(a=>a.partNumber),productSlug:e.slug},f.id):null,[b.reminder]:!h&&$e?Ve():null},Ke=(a,x)=>Fe[x]??null;function Ve(){const a=Ue.filter(H=>H.chosen===null).map(H=>Le(H.prompt).replace(/^Select\s+/i,""));if(C&&p.vehicleAnswersSpecs&&!s.fitmentSet&&a.push("vehicle fitment"),a.length===0)return null;const x=a.length===1?a[0]:a.length===2?`${a[0]} and ${a[1]}`:`${a.slice(0,-1).join(", ")}, and ${a.at(-1)}`;return m("p",{role:"alert",className:"-mt-1 font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.18em]",style:{color:"var(--alert)"},children:["Please select ",x," first."]})}const re=me(null);oe(()=>{r||re.current===e.slug||(re.current=e.slug,it({itemId:f?`${e.slug}|${f.id}`:e.slug,itemName:e.name,variant:p.metaValue,pricePerSet:d.setTotal??d.fromSetTotal??0,currency:g}))},[r,e.slug,e.name,p.metaValue,f,d,g]);const P=Mt();return m(T,{children:[j&&t("nav",{...xe(ge(`border-b border-line ${be} pt-4 pb-4 font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.2em] text-fg-dim max-view-tablet:px-[min(20px,var(--sf-site-gutter,40px))]`,F),P?.first?.atTop,ee?void 0:{background:"var(--section-bg)"}),children:e.crumbs.map((a,x)=>m("span",{children:[x>0&&m(T,{children:[t("span",{className:"mx-3 text-accent",children:"/"}),t("wbr",{})]}),a.href?t(ie,{href:a.href,className:"hover:text-fg",children:t(pe,{text:a.label})}):t("span",{className:"text-fg",children:t(pe,{text:a.label})})]},`${a.label}-${x}`))}),t("section",{ref:V,"data-hero-layout":u,"data-hero-align":K,...N?{[kt]:""}:{},...y?{[Tt]:""}:{},...xe([ge(`grid ${E.gap}${be} ${E.y}max-view-tablet:px-[min(20px,var(--sf-site-gutter,40px))] ${E.yTablet}${Ft}`,F),K==="center"?_t.center:"",u==="stacked"?"grid-cols-1":"[grid-template-columns:var(--hero-cols)] max-view-desktop:[grid-template-columns:minmax(0,1fr)]",N?vt:"",y?yt(u==="imageRight"):""].filter(Boolean).join(" "),j?P?.second?.atTop:P?.secondOnly?.atTop,{...ee?{}:{background:"var(--section-bg)"},...u==="stacked"?{}:{"--hero-cols":we}}),children:t(Ht,{value:je,children:t(U,{children:t(M,{ownerId:_??"",ownerType:z,Template:Se,rows:ve,fallback:null,hostParts:Ke,children:a=>a})})})})]})}const Vt="wheels";function Bt(e,s){return s==="alloy-wheel"&&/\d$/.test(e)?`${e} ${Vt}`:e}function Yt(e,s,i){if(!e.priced)return null;const r=e.setTotal??e.fromSetTotal;return r==null?null:{label:s,total:he({...e,unit:r,isFrom:e.setTotal==null},i)}}function Gt({offer:e,takesOrders:s,choice:i,setChoice:r,options:c}){return e.packs.length>0||s&&(e.extra||e.spareCounts.length>0)?m("div",{className:"border-b border-line pb-[26px]",children:[e.packs.length>0&&m(T,{children:[t("div",{className:"mb-3.5 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.22em] text-fg",children:"How many"}),t("div",{className:"flex flex-wrap gap-1.5",children:t(v,{hero:c,values:e.packs,item:n=>({label:n.label}),picked:n=>i.unit===n.value,press:n=>()=>r(o=>({...o,unit:n.value}))})})]}),s&&e.extra&&m("label",{className:`${e.packs.length>0?"mt-3.5 ":""}flex cursor-pointer items-center gap-3 font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.16em] text-fg`,children:[t("input",{type:"checkbox",checked:i.spares>0,onChange:n=>r(o=>({...o,spares:n.target.checked?ft:0})),className:"h-4 w-4 cursor-pointer accent-[var(--accent)]"}),e.extra.label]}),s&&e.spareCounts.length>0&&m(T,{children:[t("div",{className:"mb-3.5 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.22em] text-fg",children:nt.howMany}),t("div",{className:"flex flex-col gap-1.5 sm:flex-row sm:flex-wrap",children:t(v,{hero:c,values:e.spareCounts,item:n=>({label:`${n.value} · ${n.label}`}),picked:n=>i.spares===n.value-ue,press:n=>()=>r(o=>({...o,spares:n.value-ue}))})})]}),s&&e.spareSide&&m(T,{children:[t("div",{className:"mb-3.5 mt-[26px] font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.22em] text-fg",children:e.spareSide.label}),t("div",{className:"flex flex-wrap gap-1.5",children:t(v,{hero:c,values:e.spareSide.options,item:n=>({label:n.label}),picked:n=>i.spareSide===n.value&&(n.axle===void 0||ht(i)===n.axle),press:n=>()=>r(o=>({...o,spareSide:n.value,...n.axle?{spareAxle:n.axle}:{}}))})})]})]}):null}function ke({row:e,onPick:s,options:i}){const r=ce(),c=et();if(e.values.length===0&&!e.empty)return null;const n=e.values.find(l=>l.value===e.chosen),o=n&&[n.label,n.note].filter(Boolean).join(" · ");return e.values.length>0&&e.display==="swatch"&&c.finish==="tiles"?m("div",{[D]:e.key,children:[t(de,{label:r(e.label),chosen:n?.label}),t("div",{className:"flex flex-wrap gap-2","data-option-tiles":"",children:t(v,{hero:i,tiles:!0,values:e.values,item:l=>({swatch:l.swatch??"",name:l.label}),label:l=>l.label,picked:l=>l.value===e.chosen,press:l=>()=>s(e.key,l.value)})})]}):e.values.length>0&&e.display==="pill"&&e.role==="resolves"&&c.size==="dropdown"?m("div",{[D]:e.key,children:[t(de,{label:r(e.label)}),t(Je,{rowKey:e.key,label:r(e.label),shown:o||r(e.prompt),items:e.values.map(l=>({value:l.value,label:Ze(l)})),value:e.chosen??"",onPick:l=>s(e.key,l),editing:i.editing})]}):m("div",{className:"border-b border-line pb-[26px]",[D]:e.key,children:[m("div",{className:"mb-3.5 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.22em] text-fg",children:[r(e.label)," · ",t("span",{className:"text-accent",children:o??r(e.prompt)})]}),e.values.length===0?m("p",{className:"font-mono text-[length:var(--size-body,12px)] leading-relaxed tracking-[0.1em] text-fg-dim",children:[e.empty.text," ",t(ie,{href:e.empty.href,className:"text-accent hover:underline",children:e.empty.linkText})]}):e.display==="swatch"?t("div",{className:"flex flex-wrap gap-2 [&>*]:max-w-full",children:t(v,{hero:i,values:e.values,item:l=>({swatch:l.swatch??"",name:l.label}),picked:l=>l.value===e.chosen,press:l=>()=>s(e.key,l.value)})}):t("div",{className:"flex flex-wrap gap-1.5",children:t(v,{hero:i,values:e.values,item:l=>({label:l.label,note:l.note??""}),picked:l=>l.value===e.chosen,press:l=>()=>s(e.key,l.value)})})]})}function v({hero:e,values:s,item:i,label:r,picked:c,press:n,tiles:o=!1}){const l=Et(s,{item:i,selected:c,press:n,label:r});return t(U,{children:t(M,{ownerId:e.nodeId,ownerType:z,slot:o?Lt:Rt,Template:o?e.tileTemplate:e.template,rows:l.items.map(Nt),items:l.items,states:l.states,actions:e.editing?void 0:l.actions,pressTitles:o?void 0:e.pressTitles,fallback:null,children:O=>O})})}function Qt({partNumbers:e,productSlug:s}){const[i,r]=Ye(""),{status:c,submit:n,reset:o}=at();function l(){n({partNumbers:e,email:i,productSlug:s})}return c==="sent"?t("p",{className:"-mt-1 font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.18em] text-accent",children:"We'll email you when it's back."}):t(We,{className:"-mt-1",email:i,onEmailChange:r,status:c,onResetVerdict:o,onSubmit:l,inputAriaLabel:"Email for the back-in-stock alert",submitLabel:"Notify me when back",buttonClassName:"cursor-pointer whitespace-nowrap border-2 border-btn px-4 font-mono text-[length:var(--size-label,11px)] font-bold uppercase tracking-[0.22em] text-btn transition-colors hover:bg-btn hover:text-btn-ink disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-btn",errorMessage:"Couldn't save that — please try again."})}export{Kt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as N,jsxs as a}from"react/jsx-runtime";import{useId as O}from"react";import X from"next/image";import Z from"next/link";import{lineTotal as J,useCart as ee}from"../CartContext.js";import{useCurrency as te}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{FREE_PRICE as A}from"../../lib/wheels/price-display.js";import ne from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as ae}from"../../lib/cart/coupon-preview.js";import{orderReference as re}from"../../lib/checkout/pay-first.js";import{PRICES_REQUOTED as ie,PRICES_UNCHECKED as le}from"../../lib/checkout/checkout-memory.js";import{shippingWords as oe,TAX_PENDING as ce}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as se}from"../../lib/wheels/finish-defaults.js";import U from"../ThemedSelect.js";import g from"../WebFormField.js";import de from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as pe,placedOrderLockNote as me,SHIPPING_RETRY_NOTE as ue,useCheckout as w}from"./checkout-state.js";import{FIELD_INPUT_CLASS as u}from"../../lib/field-input.js";import{FIGURE_UPDATING as T}from"../../lib/wheels/price-display.js";function Me(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:s,setLastName:d,company:f,setCompany:v,me:b,checkoutSignOut:h,orderLocked:x,unpaidOrder:o}=w(),c=O();return a(L,{num:"N° 01",title:"Contact",children:[x&&o&&e(fe,{orderNumber:o.orderNumber}),e(g,{label:"Email",htmlFor:c,hint:b?a(N,{children:["Signed in ·"," ",e("button",{type:"button",onClick:h,className:"underline transition-colors enabled:hover:text-accent",children:"Not you? Sign out"})]}):void 0,children:e("input",{id:c,type:"email",value:t,onChange:p=>i(p.target.value),placeholder:"you@example.com",readOnly:b!==null,className:u})}),a(H,{children:[e(g,{label:"First name",children:e("input",{type:"text",value:n,onChange:p=>l(p.target.value),className:u})}),e(g,{label:"Last name",children:e("input",{type:"text",value:s,onChange:p=>d(p.target.value),className:u})})]}),e(g,{label:"Company (optional)",children:e("input",{type:"text",value:f,onChange:p=>v(p.target.value),autoComplete:"organization",className:u})})]})}function Ue(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:s,setAddress2:d,city:f,setCity:v,postcode:b,setPostcode:h,phone:x,setPhone:o,country:c,setCountry:p,subdivision:k,setSubdivision:m,subdivisions:E,destination:F,postcodeLabel:S,subdivisionLabel:y,me:B,savedAddresses:R,selectedAddressId:P,setSelectedAddressId:D,saveAddress:$,setSaveAddress:G,saveLabel:W,setSaveLabel:K,fillFromAddress:Q,orderLocked:V}=w(),M=O(),j=O();return a(L,{num:"N° 02",title:t?"Collection":"Shipping address",children:[t?a("div",{className:"grid gap-2 text-[14px] leading-[1.6]",children:[e("span",{className:"font-medium",children:t.name}),[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).length>0&&e("span",{className:"opacity-80",children:[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).join(", ")}),t.openingHours&&e("span",{className:"opacity-80",children:t.openingHours}),t.readyIn&&e("span",{className:"opacity-80",children:t.readyIn}),t.instructions&&e("span",{className:"opacity-80",children:t.instructions}),e("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):a(N,{children:[B!==null&&R.length>0&&a("div",{className:"grid gap-3",children:[R.map(r=>e(I,{active:P===r.id,onClick:()=>{D(r.id),Q(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(I,{active:P==="new",onClick:()=>D("new"),title:"New address",body:null,price:null})]}),e(g,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>l(r.target.value),className:u})}),e(g,{label:"Address line 2",children:e("input",{type:"text",value:s,onChange:r=>d(r.target.value),placeholder:"Apartment, unit, garage bay…",className:u})}),a(H,{cols:"three",children:[e(g,{label:"City",children:e("input",{type:"text",value:f,onChange:r=>v(r.target.value),className:u})}),e(g,{label:S,children:e("input",{type:"text",value:b,onChange:r=>h(r.target.value),className:u})}),e(g,{label:"Country",separate:!0,htmlFor:M,children:e(U,{id:M,value:c,onChange:r=>p(r.target.value),className:u+" pr-10",style:q,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(g,{label:y,separate:!0,htmlFor:j,children:E.length>0?a(U,{id:j,value:k,onChange:r=>m(r.target.value),className:u+" pr-10",style:q,children:[e("option",{value:"",children:"Select…"}),E.map(r=>e("option",{value:r.code||r.name,children:r.name},r.code||r.name))]}):e("input",{id:j,type:"text",value:k,onChange:r=>m(r.target.value),className:u})})]}),e(g,{label:"Phone",children:e("input",{type:"tel",value:x,onChange:r=>o(r.target.value),className:u})}),!t&&B!==null&&P==="new"&&!V&&a(N,{children:[e(xe,{checked:$,onChange:G,label:"Save this address to my account"}),$&&e(g,{label:"Address label",children:e("input",{type:"text",value:W,onChange:r=>K(r.target.value),placeholder:"Home",className:u})})]})]})}function Ye(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:s,pickupLocation:d,formatMoney:f,city:v,destination:b,courierUnavailable:h,retryCourier:x}=w();return e(L,{num:"N° 03",title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(o=>{const c=o.pickupLocation,p=c?[c.address,c.city,c.state,c.zipCode].filter(Boolean).join(", "):null;return e(I,{active:l===o.id,onClick:()=>s(o.id),title:c?`${o.name} — ${c.name}`:o.name,body:c?[p,c.openingHours,c.readyIn,c.instructions,o.description].filter(Boolean).join(" · "):o.description||null,price:t.freeShipping||o.amount===0?A:f(o.amount,t.currency),tag:o.tag||void 0},o.id)}),h?a("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[ue," ",e("button",{type:"button",onClick:x,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}):n.length===0&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})})}function qe(){const{payChoice:t,setPayChoice:i,payment:n,payOptions:l,noPaymentMethod:s}=w();return a(L,{num:"N° 04",title:"Payment",children:[s&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:pe}),e("div",{className:"grid gap-3",children:l.map(d=>e(I,{active:t===d.key,onClick:()=>i(d.key),title:d.title,body:d.body,price:d.price,tag:d.tag},d.key))}),t==="card"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="paypal"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll approve the payment with PayPal on the payment step after placing the order."}):t==="afterpay"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Afterpay to approve four interest-free payments, then brought straight back."}):t==="square"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="gocardless"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll set up a bank direct debit with GoCardless, then be brought straight back. Direct debits clear in a few days."}):t==="zip"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Zip to approve four instalments, then brought straight back."}):t==="klarna"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Klarna to choose how to pay, then brought straight back."}):t==="bank"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Our team emails you the invoice and bank details after review."}):null]})}function He(){const{site:t,items:i,totals:n,coupon:l,formatMoney:s,payChoice:d,placing:f,email:v,orderError:b,payment:h,noPaymentMethod:x,unpaidOrder:o,formLocked:c,restoredPrices:p,quoteFailed:k,retryQuote:m,placeOrder:E}=w(),F=p==="waiting",S=p==="changed";return a("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-view-desktop:static",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--site-surface) 70%, var(--bg)) 0%, var(--bg) 100%)"},children:[a("header",{className:"flex items-center justify-between border-b border-accent bg-accent px-6 py-4 font-mono text-[13px] font-bold uppercase tracking-[0.28em] text-bg",children:[e("span",{children:"Your order"}),e(Y,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit ↗"})]}),e("div",{className:"flex flex-col px-6 py-2",children:i.length===0?a("div",{className:"py-8 text-center font-serif text-[16px] italic leading-[1.5] text-fg-dim",children:["Your cart is empty. ",e(Y,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog →"})]}):i.map(y=>e(be,{slug:y.slug,name:y.name,qty:y.qty,config:y.config,configSummary:ye(y.config),price:S||F?null:J(y,n.currency)??0,currency:n.currency},y.id))}),e(ge,{locked:c,className:"border-t border-line px-6 pt-5",children:e(ne,{customerEmail:v,disabled:c})}),a("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[e(C,{label:"Subtotal",value:F?T:s(S?n.serverSubtotal??0:n.subtotal,n.currency)}),n.discount>0&&l?.valid&&e(C,{label:`Coupon · ${l.code}`,value:a("span",{className:"font-semibold text-green",children:["− ",s(n.discount,n.currency)]})}),l?.deferred&&e(C,{label:`Coupon · ${l.code}`,value:ae}),l?.valid&&l.effects?.gift&&e(C,{label:`Free gift · ${l.effects.gift.partNumber}${l.effects.gift.quantity>1?` ×${l.effects.gift.quantity}`:""}`,value:e("span",{className:"font-semibold text-green",children:A})}),e(C,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:A}):oe(n.shippingStatus)??s(n.shipping,n.currency)}),n.tax&&(n.tax.charged?e(C,{label:n.tax.inclusive?`${n.tax.name} included · ${n.tax.rate}%`:n.tax.name,value:s(n.tax.amount,n.currency)}):n.tax.name?e(C,{label:n.tax.name,value:ce}):null)]}),a("div",{className:"mt-4 flex items-end justify-between border-y-2 border-accent px-6 py-4",style:{background:"color-mix(in oklab, var(--accent) 10%, var(--bg))"},children:[e("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),e("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:n.repricing?T:s(n.grand,n.currency)})]}),a("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[S&&e(_,{tone:"quiet",children:ie}),k&&a(_,{role:"alert",children:[le," ",e("button",{type:"button",onClick:m,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}),b&&e(_,{role:"alert",children:b}),n.hasUnpricedLine&&a(_,{role:"status",children:["One or more items have no price in ",n.currency,". Remove them, or switch region, to continue."]}),e("button",{type:"button",onClick:E,disabled:f||!o&&(x||i.length===0||n.hasUnpricedLine||n.repricing),className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all max-[640px]:whitespace-nowrap max-[640px]:tracking-[0.04em]",f||!o&&(i.length===0||x||n.hasUnpricedLine||n.repricing)?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:f?a(N,{children:["Building order… ",e("span",{children:"·"})]}):x?a(N,{children:["No online payment ",e("span",{children:"·"})]}):o?a(N,{children:[a("span",{children:["Try payment again",a(z,{children:[" · ",re(o)]})]}),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]}):k?a(N,{children:["Total not confirmed ",e("span",{children:"·"})]}):n.repricing?a(N,{children:[T," ",e("span",{children:"·"})]}):a(N,{children:[a("span",{children:[d==="bank"?"Place order":"Continue to payment",a(z,{children:[" · ",s(n.grand,n.currency)]})]}),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})})]})]})}const he=" [&:disabled_:disabled]:cursor-not-allowed! [&:disabled_:disabled]:opacity-70! [&_input[readonly]]:cursor-not-allowed [&_input[readonly]]:opacity-70";function ge({locked:t,className:i="",children:n}){return e("fieldset",{disabled:t,className:"m-0 min-w-0 border-0 p-0 "+i+he,children:n})}function Y({href:t,className:i="",children:n,...l}){const{placing:s}=w();return s?e("span",{"aria-disabled":"true","aria-label":l["aria-label"],className:i+" pointer-events-none",children:n}):e(Z,{href:t,"aria-label":l["aria-label"],className:i,children:n})}function fe({orderNumber:t}){return e(_,{tone:"quiet",role:"status",children:a("span",{className:"flex items-start gap-2",children:[a("svg",{"aria-hidden":!0,viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"mt-[3px] shrink-0",children:[e("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),e("path",{d:"M5 7V5a3 3 0 0 1 6 0v2"})]}),e("span",{children:me(t)})]})})}const q={backgroundImage:"linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%)",backgroundPosition:"calc(100% - 18px) 50%, calc(100% - 12px) 50%",backgroundSize:"6px 6px",backgroundRepeat:"no-repeat"};function L({num:t,title:i,children:n}){return a("section",{className:"mb-6 border border-line bg-bg",children:[a("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t}),e("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:i})]}),e("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function H({cols:t="two",children:i}){return e("div",{className:["grid gap-3 max-[640px]:grid-cols-1",t==="two"?"grid-cols-2":"grid-cols-[1.2fr_1fr_1fr]"].join(" "),children:i})}function I({active:t,onClick:i,title:n,body:l,price:s,tag:d}){return a("button",{type:"button",onClick:i,"aria-pressed":t,className:["relative grid grid-cols-[auto_1fr_auto] items-center gap-5 border bg-bg px-6 py-5 text-left transition-colors",t?"border-accent outline outline-1 outline-accent -outline-offset-1":"border-line enabled:hover:border-[color-mix(in_oklab,var(--accent)_50%,var(--site-line))]"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 14%, var(--bg))"}:void 0,children:[t&&e("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),e("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",t?"border-accent":"border-fg-dim"].join(" "),children:t&&e("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),a("span",{className:"flex min-w-0 flex-col gap-1",children:[a("span",{className:"flex flex-wrap items-baseline gap-3 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,d&&e("span",{className:"border px-2 py-0.5 font-mono text-[11px] font-normal uppercase tracking-[0.24em] text-accent",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 45%, var(--site-line))"},children:d})]}),l&&e("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:l})]}),e("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:s})]})}function xe({checked:t,onChange:i,label:n,sub:l}){return a("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[e("button",{type:"button",onClick:()=>i(!t),"aria-pressed":t,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",t?"border-accent":"border-line"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:t&&e("span",{className:"text-[13px] text-accent",children:"✓"})}),a("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,l&&e("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:l})]})]})}function be({slug:t,name:i,qty:n,config:l,configSummary:s,price:d,currency:f}){const{catalog:v}=ee(),{formatMoney:b}=te(),h=v.find(m=>m.slug===t),x=h?.spokes??5,o=h?.mesh??!1,c=l.find(m=>m.gold)?.label,p=h?.finishes.find(m=>m.name===c&&m.src)??h?.finishes.find(m=>m.src),k=h?.finishes[0]?.color??se;return a("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-4 border-b border-line py-4 last:border-b-0",children:[a("div",{className:"relative aspect-square",children:[e("div",{className:"flex h-full w-full items-center justify-center overflow-hidden border border-line bg-surface",children:p?.src?e(X,{src:p.src,alt:`${i.lead}${i.accent} — ${p.name}`,width:120,height:120,sizes:"60px",className:"block h-full w-full object-contain p-2"}):e("div",{className:"block w-[78%]",style:{color:k},children:e(de,{spokes:x,mesh:o,className:"block w-full"})})}),e("span",{className:"absolute -right-1.5 -top-1.5 z-[2] flex h-[18px] w-[18px] items-center justify-center rounded-full bg-accent font-mono text-[11px] font-bold text-bg",children:n})]}),a("div",{className:"flex min-w-0 flex-col gap-0.5",children:[a("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[i.lead,e("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:i.accent})]}),e("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:s})]}),e("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:d===null?null:b(d,f)})]})}function z({children:t}){return e("span",{className:"max-[640px]:sr-only",children:t})}function C({label:t,value:i}){return a("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[e("span",{children:t}),e("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:i})]})}function ye(t){return t.map(i=>i.label).join(" · ")}export{Me as CheckoutContact,He as CheckoutOrderSummary,qe as CheckoutPayment,Ue as CheckoutShippingAddress,Ye as CheckoutShippingMethod,ge as FormLock,Y as LeaveLink};
|
|
1
|
+
"use client";import{jsx as e,Fragment as N,jsxs as a}from"react/jsx-runtime";import{useId as O}from"react";import X from"next/image";import Z from"next/link";import{lineTotal as J,useCart as ee}from"../CartContext.js";import{useCurrency as te}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{FREE_PRICE as A}from"../../lib/wheels/price-display.js";import ne from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as ae}from"../../lib/cart/coupon-preview.js";import{orderReference as re}from"../../lib/checkout/pay-first.js";import{PRICES_REQUOTED as ie,PRICES_UNCHECKED as le}from"../../lib/checkout/checkout-memory.js";import{shippingWords as oe,TAX_PENDING as ce}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as se}from"../../lib/wheels/finish-defaults.js";import U from"../ThemedSelect.js";import f from"../WebFormField.js";import de from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as pe,placedOrderLockNote as me,SHIPPING_RETRY_NOTE as ue,useCheckout as w}from"./checkout-state.js";import{FIELD_INPUT_CLASS as g}from"../../lib/field-input.js";import{FIGURE_UPDATING as T}from"../../lib/wheels/price-display.js";function He(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:s,setLastName:d,company:x,setCompany:k,me:y,signInHref:m,checkoutSignOut:b,orderLocked:o,unpaidOrder:c}=w(),u=O();return a(L,{num:"N° 01",title:"Contact",children:[o&&c&&e(fe,{orderNumber:c.orderNumber}),e(f,{label:"Email",htmlFor:u,hint:y?a(N,{children:["Signed in ·"," ",e("button",{type:"button",onClick:b,className:"underline transition-colors enabled:hover:text-accent",children:"Not you? Sign out"})]}):m?a(N,{children:["Have an account?"," ",e(B,{href:m,className:"underline transition-colors hover:text-accent",children:"Sign in"})]}):void 0,children:e("input",{id:u,type:"email",value:t,onChange:p=>i(p.target.value),placeholder:"you@example.com",readOnly:y!==null,className:g})}),a(q,{children:[e(f,{label:"First name",children:e("input",{type:"text",value:n,onChange:p=>l(p.target.value),className:g})}),e(f,{label:"Last name",children:e("input",{type:"text",value:s,onChange:p=>d(p.target.value),className:g})})]}),e(f,{label:"Company (optional)",children:e("input",{type:"text",value:x,onChange:p=>k(p.target.value),autoComplete:"organization",className:g})})]})}function Me(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:s,setAddress2:d,city:x,setCity:k,postcode:y,setPostcode:m,phone:b,setPhone:o,country:c,setCountry:u,subdivision:p,setSubdivision:h,subdivisions:E,destination:F,postcodeLabel:S,subdivisionLabel:v,me:R,savedAddresses:D,selectedAddressId:P,setSelectedAddressId:$,saveAddress:H,setSaveAddress:G,saveLabel:W,setSaveLabel:K,fillFromAddress:Q,orderLocked:V}=w(),M=O(),j=O();return a(L,{num:"N° 02",title:t?"Collection":"Shipping address",children:[t?a("div",{className:"grid gap-2 text-[14px] leading-[1.6]",children:[e("span",{className:"font-medium",children:t.name}),[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).length>0&&e("span",{className:"opacity-80",children:[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).join(", ")}),t.openingHours&&e("span",{className:"opacity-80",children:t.openingHours}),t.readyIn&&e("span",{className:"opacity-80",children:t.readyIn}),t.instructions&&e("span",{className:"opacity-80",children:t.instructions}),e("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):a(N,{children:[R!==null&&D.length>0&&a("div",{className:"grid gap-3",children:[D.map(r=>e(I,{active:P===r.id,onClick:()=>{$(r.id),Q(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(I,{active:P==="new",onClick:()=>$("new"),title:"New address",body:null,price:null})]}),e(f,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>l(r.target.value),className:g})}),e(f,{label:"Address line 2",children:e("input",{type:"text",value:s,onChange:r=>d(r.target.value),placeholder:"Apartment, unit, garage bay…",className:g})}),a(q,{cols:"three",children:[e(f,{label:"City",children:e("input",{type:"text",value:x,onChange:r=>k(r.target.value),className:g})}),e(f,{label:S,children:e("input",{type:"text",value:y,onChange:r=>m(r.target.value),className:g})}),e(f,{label:"Country",separate:!0,htmlFor:M,children:e(U,{id:M,value:c,onChange:r=>u(r.target.value),className:g+" pr-10",style:Y,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(f,{label:v,separate:!0,htmlFor:j,children:E.length>0?a(U,{id:j,value:p,onChange:r=>h(r.target.value),className:g+" pr-10",style:Y,children:[e("option",{value:"",children:"Select…"}),E.map(r=>e("option",{value:r.code||r.name,children:r.name},r.code||r.name))]}):e("input",{id:j,type:"text",value:p,onChange:r=>h(r.target.value),className:g})})]}),e(f,{label:"Phone",children:e("input",{type:"tel",value:b,onChange:r=>o(r.target.value),className:g})}),!t&&R!==null&&P==="new"&&!V&&a(N,{children:[e(xe,{checked:H,onChange:G,label:"Save this address to my account"}),H&&e(f,{label:"Address label",children:e("input",{type:"text",value:W,onChange:r=>K(r.target.value),placeholder:"Home",className:g})})]})]})}function Ue(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:s,pickupLocation:d,formatMoney:x,city:k,destination:y,courierUnavailable:m,retryCourier:b}=w();return e(L,{num:"N° 03",title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(o=>{const c=o.pickupLocation,u=c?[c.address,c.city,c.state,c.zipCode].filter(Boolean).join(", "):null;return e(I,{active:l===o.id,onClick:()=>s(o.id),title:c?`${o.name} — ${c.name}`:o.name,body:c?[u,c.openingHours,c.readyIn,c.instructions,o.description].filter(Boolean).join(" · "):o.description||null,price:t.freeShipping||o.amount===0?A:x(o.amount,t.currency),tag:o.tag||void 0},o.id)}),m?a("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[ue," ",e("button",{type:"button",onClick:b,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}):n.length===0&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})})}function Ye(){const{payChoice:t,setPayChoice:i,payment:n,payOptions:l,noPaymentMethod:s}=w();return a(L,{num:"N° 04",title:"Payment",children:[s&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:pe}),e("div",{className:"grid gap-3",children:l.map(d=>e(I,{active:t===d.key,onClick:()=>i(d.key),title:d.title,body:d.body,price:d.price,tag:d.tag},d.key))}),t==="card"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="paypal"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll approve the payment with PayPal on the payment step after placing the order."}):t==="afterpay"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Afterpay to approve four interest-free payments, then brought straight back."}):t==="square"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="gocardless"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll set up a bank direct debit with GoCardless, then be brought straight back. Direct debits clear in a few days."}):t==="zip"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Zip to approve four instalments, then brought straight back."}):t==="klarna"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Klarna to choose how to pay, then brought straight back."}):t==="bank"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Our team emails you the invoice and bank details after review."}):null]})}function qe(){const{site:t,items:i,totals:n,coupon:l,formatMoney:s,payChoice:d,placing:x,email:k,orderError:y,payment:m,noPaymentMethod:b,unpaidOrder:o,formLocked:c,restoredPrices:u,quoteFailed:p,retryQuote:h,placeOrder:E}=w(),F=u==="waiting",S=u==="changed";return a("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-view-desktop:static",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--site-surface) 70%, var(--bg)) 0%, var(--bg) 100%)"},children:[a("header",{className:"flex items-center justify-between border-b border-accent bg-accent px-6 py-4 font-mono text-[13px] font-bold uppercase tracking-[0.28em] text-bg",children:[e("span",{children:"Your order"}),e(B,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit ↗"})]}),e("div",{className:"flex flex-col px-6 py-2",children:i.length===0?a("div",{className:"py-8 text-center font-serif text-[16px] italic leading-[1.5] text-fg-dim",children:["Your cart is empty. ",e(B,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog →"})]}):i.map(v=>e(be,{slug:v.slug,name:v.name,qty:v.qty,config:v.config,configSummary:ye(v.config),price:S||F?null:J(v,n.currency)??0,currency:n.currency},v.id))}),e(ge,{locked:c,className:"border-t border-line px-6 pt-5",children:e(ne,{customerEmail:k,disabled:c})}),a("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[e(C,{label:"Subtotal",value:F?T:s(S?n.serverSubtotal??0:n.subtotal,n.currency)}),n.discount>0&&l?.valid&&e(C,{label:`Coupon · ${l.code}`,value:a("span",{className:"font-semibold text-green",children:["− ",s(n.discount,n.currency)]})}),l?.deferred&&e(C,{label:`Coupon · ${l.code}`,value:ae}),l?.valid&&l.effects?.gift&&e(C,{label:`Free gift · ${l.effects.gift.partNumber}${l.effects.gift.quantity>1?` ×${l.effects.gift.quantity}`:""}`,value:e("span",{className:"font-semibold text-green",children:A})}),e(C,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:A}):oe(n.shippingStatus)??s(n.shipping,n.currency)}),n.tax&&(n.tax.charged?e(C,{label:n.tax.inclusive?`${n.tax.name} included · ${n.tax.rate}%`:n.tax.name,value:s(n.tax.amount,n.currency)}):n.tax.name?e(C,{label:n.tax.name,value:ce}):null)]}),a("div",{className:"mt-4 flex items-end justify-between border-y-2 border-accent px-6 py-4",style:{background:"color-mix(in oklab, var(--accent) 10%, var(--bg))"},children:[e("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),e("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:n.repricing?T:s(n.grand,n.currency)})]}),a("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[S&&e(_,{tone:"quiet",children:ie}),p&&a(_,{role:"alert",children:[le," ",e("button",{type:"button",onClick:h,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}),y&&e(_,{role:"alert",children:y}),n.hasUnpricedLine&&a(_,{role:"status",children:["One or more items have no price in ",n.currency,". Remove them, or switch region, to continue."]}),e("button",{type:"button",onClick:E,disabled:x||!o&&(b||i.length===0||n.hasUnpricedLine||n.repricing),className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all max-[640px]:whitespace-nowrap max-[640px]:tracking-[0.04em]",x||!o&&(i.length===0||b||n.hasUnpricedLine||n.repricing)?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:x?a(N,{children:["Building order… ",e("span",{children:"·"})]}):b?a(N,{children:["No online payment ",e("span",{children:"·"})]}):o?a(N,{children:[a("span",{children:["Try payment again",a(z,{children:[" · ",re(o)]})]}),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]}):p?a(N,{children:["Total not confirmed ",e("span",{children:"·"})]}):n.repricing?a(N,{children:[T," ",e("span",{children:"·"})]}):a(N,{children:[a("span",{children:[d==="bank"?"Place order":"Continue to payment",a(z,{children:[" · ",s(n.grand,n.currency)]})]}),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})})]})]})}const he=" [&:disabled_:disabled]:cursor-not-allowed! [&:disabled_:disabled]:opacity-70! [&_input[readonly]]:cursor-not-allowed [&_input[readonly]]:opacity-70";function ge({locked:t,className:i="",children:n}){return e("fieldset",{disabled:t,className:"m-0 min-w-0 border-0 p-0 "+i+he,children:n})}function B({href:t,className:i="",children:n,...l}){const{placing:s}=w();return s?e("span",{"aria-disabled":"true","aria-label":l["aria-label"],className:i+" pointer-events-none",children:n}):e(Z,{href:t,"aria-label":l["aria-label"],className:i,children:n})}function fe({orderNumber:t}){return e(_,{tone:"quiet",role:"status",children:a("span",{className:"flex items-start gap-2",children:[a("svg",{"aria-hidden":!0,viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"mt-[3px] shrink-0",children:[e("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),e("path",{d:"M5 7V5a3 3 0 0 1 6 0v2"})]}),e("span",{children:me(t)})]})})}const Y={backgroundImage:"linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%)",backgroundPosition:"calc(100% - 18px) 50%, calc(100% - 12px) 50%",backgroundSize:"6px 6px",backgroundRepeat:"no-repeat"};function L({num:t,title:i,children:n}){return a("section",{className:"mb-6 border border-line bg-bg",children:[a("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t}),e("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:i})]}),e("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function q({cols:t="two",children:i}){return e("div",{className:["grid gap-3 max-[640px]:grid-cols-1",t==="two"?"grid-cols-2":"grid-cols-[1.2fr_1fr_1fr]"].join(" "),children:i})}function I({active:t,onClick:i,title:n,body:l,price:s,tag:d}){return a("button",{type:"button",onClick:i,"aria-pressed":t,className:["relative grid grid-cols-[auto_1fr_auto] items-center gap-5 border bg-bg px-6 py-5 text-left transition-colors",t?"border-accent outline outline-1 outline-accent -outline-offset-1":"border-line enabled:hover:border-[color-mix(in_oklab,var(--accent)_50%,var(--site-line))]"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 14%, var(--bg))"}:void 0,children:[t&&e("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),e("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",t?"border-accent":"border-fg-dim"].join(" "),children:t&&e("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),a("span",{className:"flex min-w-0 flex-col gap-1",children:[a("span",{className:"flex flex-wrap items-baseline gap-3 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,d&&e("span",{className:"border px-2 py-0.5 font-mono text-[11px] font-normal uppercase tracking-[0.24em] text-accent",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 45%, var(--site-line))"},children:d})]}),l&&e("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:l})]}),e("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:s})]})}function xe({checked:t,onChange:i,label:n,sub:l}){return a("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[e("button",{type:"button",onClick:()=>i(!t),"aria-pressed":t,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",t?"border-accent":"border-line"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:t&&e("span",{className:"text-[13px] text-accent",children:"✓"})}),a("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,l&&e("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:l})]})]})}function be({slug:t,name:i,qty:n,config:l,configSummary:s,price:d,currency:x}){const{catalog:k}=ee(),{formatMoney:y}=te(),m=k.find(h=>h.slug===t),b=m?.spokes??5,o=m?.mesh??!1,c=l.find(h=>h.gold)?.label,u=m?.finishes.find(h=>h.name===c&&h.src)??m?.finishes.find(h=>h.src),p=m?.finishes[0]?.color??se;return a("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-4 border-b border-line py-4 last:border-b-0",children:[a("div",{className:"relative aspect-square",children:[e("div",{className:"flex h-full w-full items-center justify-center overflow-hidden border border-line bg-surface",children:u?.src?e(X,{src:u.src,alt:`${i.lead}${i.accent} — ${u.name}`,width:120,height:120,sizes:"60px",className:"block h-full w-full object-contain p-2"}):e("div",{className:"block w-[78%]",style:{color:p},children:e(de,{spokes:b,mesh:o,className:"block w-full"})})}),e("span",{className:"absolute -right-1.5 -top-1.5 z-[2] flex h-[18px] w-[18px] items-center justify-center rounded-full bg-accent font-mono text-[11px] font-bold text-bg",children:n})]}),a("div",{className:"flex min-w-0 flex-col gap-0.5",children:[a("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[i.lead,e("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:i.accent})]}),e("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:s})]}),e("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:d===null?null:y(d,x)})]})}function z({children:t}){return e("span",{className:"max-[640px]:sr-only",children:t})}function C({label:t,value:i}){return a("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[e("span",{children:t}),e("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:i})]})}function ye(t){return t.map(i=>i.label).join(" · ")}export{He as CheckoutContact,qe as CheckoutOrderSummary,Ye as CheckoutPayment,Me as CheckoutShippingAddress,Ue as CheckoutShippingMethod,ge as FormLock,B as LeaveLink};
|
|
@@ -35,8 +35,9 @@ export interface CheckoutProps {
|
|
|
35
35
|
sizeUnit?: LengthUnit | null;
|
|
36
36
|
} | null;
|
|
37
37
|
preview?: boolean;
|
|
38
|
+
signInHref?: string | null;
|
|
38
39
|
}
|
|
39
|
-
declare function useCheckoutState({ site, logo, preview }: CheckoutProps): {
|
|
40
|
+
declare function useCheckoutState({ site, logo, signInHref, preview }: CheckoutProps): {
|
|
40
41
|
site: SiteIdentity;
|
|
41
42
|
logo: {
|
|
42
43
|
url: string | null;
|
|
@@ -47,6 +48,7 @@ declare function useCheckoutState({ site, logo, preview }: CheckoutProps): {
|
|
|
47
48
|
sizePx: number | null;
|
|
48
49
|
sizeUnit?: LengthUnit | null;
|
|
49
50
|
} | null | undefined;
|
|
51
|
+
signInHref: string | null;
|
|
50
52
|
items: CartLine[];
|
|
51
53
|
totals: {
|
|
52
54
|
sets: number;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
2
|
-
`);return
|
|
3
|
-
${Ne.trim()}`:ee,nr=Wr({email:I,firstName:L,lastName:H,company:be.trim(),phone:G,address:Me,city:F,subdivision:O,postcode:T,country:m,lines:a.map(e=>[e.id,e.qty]),shippingMethodId:Q,couponCode:mn(K),currency:P.currency,shopperId:ie?.id??null}),b=JSON.stringify([nr,C]),Ve=y(null),Le=y(!1),x=y(!1),X=y(null),Te=y(!1),A=y(b);A.current=b;const Ft=y(M);Ft.current=M;const _e=y(null);h(()=>{const e=()=>{const t=_e.current;t&&(_e.current=null,S(t),He(!1))};return window.addEventListener("pageshow",e),()=>window.removeEventListener("pageshow",e)},[]);function xe(e,t,r,c){const n={idempotencyKey:t,confirmation:r};Xt()&&(n.lostChange=!0),ct.setItem(e,JSON.stringify(n)),window.location.assign(c),_e.current=r}async function qt(e){He(!0);try{await e()}finally{_e.current||He(!1)}}const $t=y(!1),Bt=!!(Ze||ue&&ue.kind!=="processing");h(()=>{Bt&&($t.current=!0,de())},[Bt]);const Ie=y(null),le=y(!1),et=y(null);function de(){et.current=null,_r()}const Fe=y(null),[Z,rr]=s(!1);function tt(e){if($t.current||f||le.current)return;const t={key:e,authed:Qe.current,parkedAt:et.current??=Date.now(),press:wn(Vr,i.current),lines:a.length>0?a:$.current,form:Fr({email:I,firstName:L,lastName:H,company:be,address1:ee,address2:Ne,city:F,postcode:T,phone:G,country:m,subdivision:O,selectedAddressId:We,shippingMethodId:Q,couponCode:K?.valid?K.code:null})};xr(t.press)?Ir(t):de()}const Ut=y(C);Ut.current=C;function nt(e){return{...Ur(e),...Cn(),...e.payFirst?{checkoutFlow:lt}:{}}}function or(e,t){let r=e.request.payFirst?"":null,c=e.plainPressed?null:"";const n=()=>Ut.current??"";return{key:e.key,send:()=>t(nt(e.request)),request:nt(e.request),lines:e.lines,shape:JSON.stringify([e.goods,null]),get method(){return r??n()},set method(u){r=u},get plainMethod(){return c??n()},set plainMethod(u){c=u},plainLines:e.plainLines,plainShape:JSON.stringify([e.plainGoods,null])}}const[sr,cr]=s(!1),Yt=sr?!P.quoted||P.serverSubtotal===null?"waiting":Math.abs(P.serverSubtotal-P.subtotal)<jr?"same":"changed":null,rt=!k&&Yt==="waiting",ar=rt?{...P,repricing:!0}:P,ot=rt&&P.quoteFailed;h(()=>{if(!ot)return;const e=setInterval(he,Zr);return()=>clearInterval(e)},[ot,he]);const ir=he;function Ht(e,t=!0){Ce(e.email),we(e.firstName),Pe(e.lastName),Ge(e.company),te(e.address1),ne(e.address2),re(e.city),oe(e.postcode),se(e.phone),e.country&&ce(e.country),D({country:e.country||null,state:e.subdivision}),ve(e.selectedAddressId),e.shippingMethodId&&pt(e.shippingMethodId),t&&(Ie.current=e.couponCode)}h(()=>{let e=f?null:$r();const t=!!(e&&a.length>0);if(e&&t&&!Br(e.lines,a)&&(de(),e=null),e){const r=e.authed?w.createOrderAuthed:w.createOrder;Oe(e.key),et.current=e.parkedAt,Qe.current=e.authed;const c={lastPress:n=>n&&or(n,r),keptCardKey:n=>n,placedShape:n=>n===null?null:JSON.stringify([n,null]),placedRequest:n=>{if(!n)return null;const u=nt(n);return{body:u,send:()=>r(u)}},unpaidOrder:n=>n};i.current=wn(c,e.press),e.press.unpaidOrder&&S(e.press.unpaidOrder),e.lines.length>0&&!t&&(Ye(e.lines),$.current=e.lines,cr(!0)),e.form&&(Fe.current=e.form,Ht(e.form))}rr(!0)},[]),h(()=>{!Z||a.length>0||i.current.unpaidOrder||M||(le.current=!0,de())},[Z,a.length]),h(()=>{const e=Ie.current;!Z||!e||a.length===0||(Ie.current=null,Sn(e,I||void 0))},[Z,a.length]),h(()=>{!Z||M||tt(q)},[Z,M,q,k]);const B=y(null);h(()=>{Ft.current||(b!==B.current&&(B.current=null),!(!x.current||!k||k.orderNumber)&&(b===i.current.placedShape||b===B.current||qt(()=>Gt(k))))},[b,k]);async function Gt(e){if(Te.current)return null;Te.current=!0;try{const t=X.current?await Dr(X.current):"none";if(t==="succeeded"||t==="processing")return x.current=!1,S(null),E("card"),t==="succeeded"?await U(void 0,e):en(e),null;if(t===void 0||!Hr.has(t))return B.current=A.current,S(e),N(t==="requires_action"?Yr:it),null;const r=await pn(q);if(r==="committed")return x.current=!1,S(null),E("card"),await U(void 0,e),null;if(r!=="released")return B.current=A.current,S(e),N(it),null;x.current=!1,X.current=null,B.current=null,N(null),S(null);const c=$e();return Oe(c),c}finally{Te.current=!1}}async function ur(){f||M||Te.current||await qt(lr)}async function lr(){if(k){if((x.current?b!==i.current.placedShape:pe())&&!k.orderNumber){const c=await Gt(k);c&&A.current===b&&await Dt(c);return}N(null),Le.current=!1,await st();const t=v(A.current)[1],r=k.orderNumber?t:"card";if(r&&kn.has(r)&&pe()&&v(A.current)[0]!==Ve.current){zt(k);return}E(r),r!==C&&ke(r),await tn(k,r,!k.orderNumber);return}await Dt(q)}async function Dt(e){if(a.length===0||P.repricing||rt||!C||!J.some(d=>d.key===C))return;const t=a.filter(un).flatMap(d=>Nr(d.components,d.qty));if(t.length===0){N("Pick a size on each wheel's product page before checking out.");return}N(null);let r,c=e,n=C,u=!1;try{const d=ie?w.createOrderAuthed:w.createOrder,l={customer:{email:I,name:`${L} ${H}`.trim(),phone:G.trim()||void 0,companyName:be.trim()||void 0,address:Me,city:F,state:O||void 0,zipCode:T,country:m},items:t,currency:P.currency,idempotencyKey:e,shippingMethodId:Q??void 0,couponCode:mn(K),...Cn(),...Gr(C)?{checkoutFlow:lt}:{}};i.current.placedRequest={body:l,send:()=>d(l)},Qe.current=!!ie,le.current=!1,Xe(null),Ve.current=null,Le.current=!1,X.current=null,x.current=!1,B.current=null,i.current.placedShape=b,$.current=a;const p=i.current.lastPress,j=p?.key===l.idempotencyKey&&(p.shape!==b&&(!!l.checkoutFlow||!!p.method||!!p.plainMethod)||!!l.checkoutFlow&&!!p.plainMethod);j&&(i.current.keptCardKey=l.idempotencyKey);const on=jt(l,d),sn=j||!l.checkoutFlow&&i.current.keptCardKey===l.idempotencyKey,cn=!on&&!sn&&!l.checkoutFlow&&!!p&&!p.method;cn&&(p.plainMethod=C,p.plainLines=a,p.plainShape=b,tt(l.idempotencyKey));const Y=await(sn?Jt(l,d):d(l).then(fe=>({answer:fe,request:l})).catch(fe=>(on?Wt(fe,l.idempotencyKey):cn&&fn(fe)&&(p.plainMethod=""),dr(fe,l,d))));if(!Y)return;r=Y.answer,c=Y.request.idempotencyKey,n=Y.method??n,E(n),u=pe()||n!==v(A.current)[1],Y.method&&Y.method!==C&&ke(Y.method),r.orderNumber&&(Qt(r),ge()),await st()}catch(d){const l=Xr(d);l?(bn(l),N(`${l} Your order has not been placed. Place it again to continue without the code.`)):d instanceof Ue?N(it):N(d instanceof qe?d.message:"Could not place the order. Please try again.");return}if(n&&kn.has(n)&&(u||pe())){zt(r);return}await tn(r,n,!1,c)}function zt(e){Ve.current=v(A.current)[0],N(`${gn(e,null)} ${ut}`),S(e)}function Wt(e,t){fn(e)&&!dn(e)&&i.current.lastPress?.key===t&&(i.current.lastPress=null)}async function dr(e,t,r){if(at(e))return Zt(t,r);if(!dn(e))throw e;return i.current.keptCardKey=t.idempotencyKey,Jt(t,r,!0)}async function Jt(e,t,r=!1){const c=await pn(e.idempotencyKey);if(c==="released")return Zt(e,t);if(c!=="committed")throw new Ue;const n=i.current.lastPress?.key===e.idempotencyKey?i.current.lastPress:null;if($.current=n?.lines??a,n?.method&&!r){i.current.keptCardKey=null,i.current.placedRequest={body:n.request,send:n.send};const j=await n.send().catch(()=>{throw new Ue});return i.current.placedShape=n.shape,{answer:j,request:e,method:n.method}}const u={...e,checkoutFlow:lt},d=n&&!n.method?{body:n.request,send:n.send}:{body:u,send:()=>t(u)};i.current.placedRequest=d;const l=d.send,p=await l().catch(()=>null);if(!p&&n?.plainMethod)throw new Ue;return p?.orderNumber&&p.status!==zr?(i.current.keptCardKey=null,n?.plainMethod&&($.current=n.plainLines),n&&(i.current.placedShape=n.plainMethod?n.plainShape:n.shape),{answer:p,request:e,method:n?.plainMethod||void 0}):(n&&(i.current.placedShape=n.shape),E("card"),await Vt("",p?async()=>p:()=>Promise.reject(new Error("The order request did not answer."))),await st(),null)}function pe(){const e=i.current.placedShape;return e!==null&&v(e)[0]!==v(A.current)[0]}function E(e){e!==v(A.current)[1]&&(Le.current=!0),Xe(Xt()?ut:null)}function Xt(){return Le.current||pe()}async function Zt(e,t){const r={...e,idempotencyKey:$e()};i.current.keptCardKey=null,Oe(r.idempotencyKey),i.current.placedRequest={body:r,send:()=>t(r)},jt(r,t);try{return{answer:await t(r),request:r}}catch(c){throw Wt(c,r.idempotencyKey),c}}function jt(e,t){return i.current.lastPress?.key===e.idempotencyKey?!1:(i.current.lastPress={key:e.idempotencyKey,send:()=>t(e),request:e,lines:a,shape:b,method:e.checkoutFlow?"":C??"",plainMethod:"",plainLines:a,plainShape:b},le.current=!1,tt(e.idempotencyKey),!0)}function Qt(e){Pr({confirmation:e,lines:$.current,adsSendTo:o.googleAdsId&&o.googleAdsConversionLabel?`${o.googleAdsId}/${o.googleAdsConversionLabel}`:null}),br({confirmation:e,lines:$.current})}async function U(e,t=_){if(!t)return;const r=e?async()=>e:i.current.placedRequest?.send;if(t.orderNumber||!r){Re(!0),z(t);return}await Vt(t.checkoutNumber,r)}async function Vt(e,t){ge(),await Jr({checkoutNumber:e,resend:t,page:{setConfirming:jn,land:z,markPaid:()=>Re(!0),track:Qt,unplaced:Lt}})}function en(e=_){if(e){if(e.orderNumber){z(e);return}ge(),Lt({kind:"processing",checkoutNumber:e.checkoutNumber})}}async function st(){const e=JSON.stringify([Je.trim(),L,H,G.trim(),Me,F,O,T,m]);if(!(!ie||!Nt||We!=="new"||vt.current===e))try{await me.createAddress({label:Je.trim()||"Home",contact_name:`${L} ${H}`.trim(),phone:G.trim(),address:Me,city:F,zip_code:T,state:O,country:m}),vt.current=e,At("Address saved to your account.")}catch{At("We couldn't save the address to your account — you can add it under Account → Addresses.")}}async function tn(e,t=C,r=!1,c=q){S(null);try{if(t==="card"&&o.paymentMethods.includes("card")){const n=await w.createPaymentIntent({idempotencyKey:c});X.current=n;let u=e;if(r){const d=await i.current.placedRequest?.send().catch(()=>null);if(d?.orderNumber){E("card"),await U(d,e);return}u=nn(e,d)??{...e,expiresAt:null}}E("card"),W(u),je(!1),Ee(n)}else if(t==="paypal"&&o.paymentMethods.includes("paypal"))W(e),Fn(!0);else if(t==="afterpay"&&o.paymentMethods.includes("afterpay")){const n=window.location.origin,u=await w.createAfterpayCheckout({idempotencyKey:c,confirmUrl:`${n}/checkout?afterpay=confirm`,cancelUrl:`${n}/checkout?afterpay=cancel`});xe(Ar,c,e,u.redirectCheckoutUrl);return}else if(t==="square"&&o.paymentMethods.includes("square"))W(e),qn(!0);else if(t==="gocardless"&&o.paymentMethods.includes("gocardless")){const n=window.location.origin,u=await w.createGocardlessBillingRequest({idempotencyKey:c,confirmUrl:`${n}/checkout?gocardless=confirm`,cancelUrl:`${n}/checkout?gocardless=cancel`});xe(Or,c,e,u.authorisationUrl);return}else if(t==="zip"&&o.paymentMethods.includes("zip")){const n=window.location.origin,u=await w.createZipCheckout({idempotencyKey:c,redirectUrl:`${n}/checkout?zip=return`});xe(Mr,c,e,u.redirectUrl);return}else if(t==="klarna"&&o.paymentMethods.includes("klarna")){const n=window.location.origin,u=await w.createKlarnaCheckout({idempotencyKey:c,confirmUrl:`${n}/checkout?klarna=confirm`,cancelUrl:`${n}/checkout?klarna=cancel`});xe(Rr,c,e,u.redirectUrl);return}else E(t),z(e)}catch(n){if((r||t==="card")&&n instanceof qe&&n.status===409){E(t),await U(void 0,e);return}rn(e,n)}}function nn(e,t){return t&&!t.orderNumber&&t.status==="open"&&t.checkoutNumber===e.checkoutNumber?t:null}function rn(e,t){N(gn(e,t)),!e.orderNumber&&at(t)?(x.current=!1,Oe($e())):S(e)}async function pr(e){if(!_)return;const t=_;try{const r=await w.createPaymentIntent({idempotencyKey:q}),c=await i.current.placedRequest?.send().catch(()=>null);if(c?.orderNumber){await U(c);return}const n=nn(t,c);W(n??{...t,expiresAt:null}),je(e&&n!==null),X.current=r,Ee(r)}catch(r){if(r instanceof qe&&r.status===409){await U();return}Ee(null),W(null),rn(t,r)}}function fr(){_&&(x.current=!0,S(_),Ee(null),W(null),je(!1))}return{site:o,logo:g,items:a,totals:ar,coupon:K,deliveryOptions:dt,courierUnavailable:Kn,retryCourier:Mn,shippingMethodId:Q,setShippingMethodId:pt,pickupLocation:An,servedCountries:V,formatMoney:vn,payChoice:C,setPayChoice:ke,placing:M,email:I,setEmail:Ce,firstName:L,setFirstName:we,lastName:H,setLastName:Pe,company:be,setCompany:Ge,address1:ee,setAddress1:te,address2:Ne,setAddress2:ne,city:F,setCity:re,postcode:T,setPostcode:oe,phone:G,setPhone:se,country:m,setCountry:ce,subdivision:O,setSubdivision:Se,subdivisions:ae,destination:Ct,postcodeLabel:En,subdivisionLabel:Rn,me:ie,savedAddresses:Ln,selectedAddressId:We,setSelectedAddressId:ve,saveAddress:Nt,setSaveAddress:St,saveLabel:Je,setSaveLabel:Tn,addressSaveNote:_n,lostChangeNote:xn,idemKey:q,confirmation:Ze,setConfirmation:z,orderError:In,payment:Ot,paypalStep:Et,squareStep:Rt,pendingConf:_,paid:$n,setPaid:Re,unpaidOrder:k,orderLocked:Kt,formLocked:Bn,restoredPrices:Yt,quoteFailed:ot,retryQuote:ir,payNote:Un,afterpayConfirming:Hn,gocardlessConfirming:Dn,zipConfirming:Wn,klarnaConfirming:Xn,cardConfirming:Mt,checkoutResult:ue,confirmCardPayment:U,cardStillProcessing:en,renewCardPayment:pr,holdRenewed:Qn,leaveCardPayment:fr,checkoutRootRef:xt,setCheckoutHeaderEl:Vn,fillFromAddress:It,checkoutSignOut:er,payOptions:J,noPaymentMethod:tr,placeOrder:ur}}const Pn=mr(null);function No({children:o,...g}){const f=eo(g);return R(Pn.Provider,{value:f,children:o})}function So(){const o=yr(Pn);if(!o)throw new Error("useCheckout must be used inside CheckoutStateProvider");return o}export{No as CheckoutStateProvider,wo as NO_PAYMENT_METHOD_NOTE,Po as SHIPPING_RETRY_NOTE,hn as buildPayOptions,gn as paymentNotStartedMessage,bo as placedOrderLockNote,So as useCheckout};
|
|
1
|
+
"use client";import{jsx as K}from"react/jsx-runtime";import{createContext as yr,useContext as hr,useEffect as y,useMemo as un,useRef as m,useState as s}from"react";import{isOrderable as ln,useCart as gr}from"../CartContext.js";import{useCurrency as kr}from"../CurrencyContext.js";import{getClickIds as Cr}from"../../lib/click-ids.js";import{adConsentForOrder as wr}from"../../lib/consent/choice.js";import{trackBeginCheckout as Pr,trackPurchase as br}from"../../lib/google-tag.js";import{trackMetaPurchase as Nr}from"../../lib/meta-pixel.js";import{ApiError as $e,api as ye,products as P}from"../../lib/api/index.js";import{uuid as Be}from"../../lib/uuid.js";import{orderLinesForSets as Sr}from"../../lib/commerce.js";import{canPersist as Ar,safeSessionStorage as at}from"efficient-web-builder/format/lib/safe-storage";import{AFTERPAY_CONTEXT_KEY as vr,AFTERPAY_RETURN as Or,GOCARDLESS_CONTEXT_KEY as Er,GOCARDLESS_RETURN as Rr,KLARNA_CONTEXT_KEY as Kr,KLARNA_RETURN as Mr,ZIP_CONTEXT_KEY as Lr,ZIP_RETURN as Tr,runWalletReturn as Ue}from"../../lib/checkout/wallet-return.js";import{matchSubdivision as _r}from"../../lib/checkout/match-subdivision.js";import{clearCheckoutMemory as xr,holdsPress as Ir,parkCheckoutMemory as Fr,parkForm as qr,parkOrder as $r,parkRequest as dn,readCheckoutMemory as Br,sameGoods as Ur,sendableRequest as Yr}from"../../lib/checkout/checkout-memory.js";import{checkoutGone as it,checkoutWaiting as pn,BANK_WAITING as Hr,DROPPABLE_INTENT as Gr,NOT_CHECKED as ut,LOST_CHANGE as lt,PAY_FIRST_FLOW as dt,paysFirst as Dr,readIntentStatus as zr,releaseHeldCheckout as fn,CHECKOUT_COMMITTED as Wr,goodsShapeOf as Jr,refusedForGood as mn,settlePayFirst as Xr}from"../../lib/checkout/pay-first.js";import{couponCodeForOrder as yn,couponRefusedByOrder as Zr}from"../../lib/cart/coupon-preview.js";function hn(o){const k=o.indexOf(`
|
|
2
|
+
`);return k===-1?[o,""]:[o.slice(0,k),o.slice(k+1)]}function gn(o,{canParkContext:k}={canParkContext:!0}){const g=o.paymentMethods,h=[];return g.includes("card")&&h.push({key:"card",title:"Card",body:null,price:K("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),g.includes("paypal")&&o.paypalClientId&&h.push({key:"paypal",title:"PayPal",body:null,price:K("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAYPAL · CARDS"})}),g.includes("afterpay")&&h.push({key:"afterpay",title:"Afterpay",body:null,price:K("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"4 × INTEREST-FREE"})}),g.includes("square")&&o.squareApplicationId&&o.squareLocationId&&h.push({key:"square",title:"Card (Square)",body:null,price:K("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),g.includes("gocardless")&&k&&h.push({key:"gocardless",title:"Bank Direct Debit",body:null,price:K("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY BY BANK"})}),g.includes("zip")&&h.push({key:"zip",title:"Zip",body:null,price:K("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY IN 4"})}),g.includes("klarna")&&k&&h.push({key:"klarna",title:"Klarna",body:null,price:K("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),g.includes("bank")&&h.push({key:"bank",title:"Bank transfer",body:null,price:K("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),h}const Po="This shop does not take payment online yet. Please contact the shop to order.";class Ye extends Error{}function kn(o,k){if(!o.orderNumber&&it(k))return k.message;const g=k instanceof $e?` (${k.message})`:"";return o.orderNumber?`Your order ${o.orderNumber} is saved, but the payment did not start${g}. Try the payment again — your order will not be placed twice.`:`Your items are held under ${o.checkoutNumber}, but the payment did not start${g}. Try the payment again — you will not be charged twice.`}const jr=3e3,Qr=.005,Cn=new Set(["paypal","square","afterpay","gocardless","zip","klarna"]);function wn(){const o=wr();return{...o==="denied"?{}:Cr(),...o?{adConsent:o}:{}}}const O=o=>JSON.parse(o),Vr={lastPress:null,keptCardKey:null,placedShape:null,placedRequest:null,unpaidOrder:null},eo={lastPress:o=>o&&{key:o.key,request:dn(o.request),lines:o.lines,goods:O(o.shape)[0],plainPressed:!!o.plainMethod,plainLines:o.plainLines,plainGoods:O(o.plainShape)[0]},keptCardKey:o=>o,placedShape:o=>o===null?null:O(o)[0],placedRequest:o=>o&&dn(o.body),unpaidOrder:o=>o&&$r(o)};function Pn(o,k){const g={};for(const h of Object.keys(o))g[h]=o[h](k[h]);return g}const bo="Shipping cannot be calculated right now. Please try again.";function No(o){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 ${o}.`}function to({site:o,logo:k,signInHref:g=null,preview:h=!1}){const{items:f,totals:b,coupon:M,refuseCoupon:Nn,deliveryOptions:pt,shippingMethodId:V,setShippingMethodId:ft,setQuoteDestination:he,courier:Sn,requote:ge,identify:mt,clearCapturedCart:ke,replaceItems:He,removeCoupon:yt,applyCoupon:An}=gr(),vn=pt.find(e=>e.id===V)?.pickupLocation??null,{country:ht,countries:ee,activeCountry:gt,formatMoney:On}=kr(),[w,Ce]=s(()=>gn(o)[0]?.key??null),[kt,En]=s(!0);y(()=>{En(Ar(at))},[]);const[L,Ge]=s(!1),[F,we]=s(""),[T,Pe]=s(""),[G,be]=s(""),[Ne,De]=s(""),[te,ne]=s(""),[Se,re]=s(""),[q,oe]=s(""),[_,se]=s(""),[D,ce]=s(""),[p,ae]=s(()=>ht||ee[0]?.code||""),[E,Ae]=s(""),[ie,Ct]=s([]),[ze,We]=s(null),[ve,z]=s(null),wt=un(()=>ee.find(e=>e.code===p)??gt,[ee,p,gt]),Rn=wt?.postalLabel||"Postal Code",Kn=ie[0]?.divisionType||"State / Province";y(()=>{if(!p){Ct([]),We(p);return}We(null);let e=!1;return P.listCountrySubdivisions(p).then(t=>{e||(Ct(t),We(p),Ae(""))}),()=>{e=!0}},[p]);const Pt=te.trim()!==""&&q.trim()!==""&&_.trim()!==""&&ze===p&&(ie.length===0||E!=="")?_.trim():"";y(()=>{he(p?{country:p,subdivision:E,postcode:Pt}:null)},[p,E,Pt,he]),y(()=>()=>he(null),[he]);const Mn=Sn?.status==="unavailable",Ln=ge,[ue,bt]=s(null),[Tn,Nt]=s([]),[Je,Oe]=s("new"),[St,At]=s(!1),[Xe,_n]=s("Home"),[xn,vt]=s(null),[In,Ze]=s(null),[$,Ee]=s(()=>Be()),Ot=m(null),[je,W]=s(null),[Fn,S]=s(null),[Et,Re]=s(null),[Rt,qn]=s(!1),[Kt,$n]=s(!1),[x,J]=s(null),[Bn,Ke]=s(!1),[C,A]=s(null),Mt=!!C?.orderNumber,Un=Mt||L,[Yn,Hn]=s(null),[Gn,Dn]=s(!1),[zn,Wn]=s(!1),[Jn,Xn]=s(!1),[Zn,jn]=s(!1),[Lt,Qn]=s(!1),[Vn,Qe]=s(!1),[le,Tt]=s(null),a=m({...Vr});a.current.unpaidOrder=C;const Ve=m(!1),B=m(f),_t=!!(je||le&&le.kind!=="processing"||Lt||Rt||Kt||Et&&x?.orderNumber);y(()=>{_t&&(He([]),yt())},[_t,He,yt]);const xt=m(!1);y(()=>{h||xt.current||!f.some(ln)||(xt.current=!0,Pr({lines:f,currency:b.currency,value:b.subtotal-b.discount,coupon:M?.valid?M.code:void 0}))},[f,b,M,h]),y(()=>{mt(F,T.trim()||void 0)},[F,T,mt]);const It=m(null),[Me,er]=s(null);y(()=>{const e=It.current;if(!Me||!e)return;const t=()=>e.style.setProperty("--sf-checkout-header-h",`${Me.offsetHeight}px`);t();const r=new ResizeObserver(t);return r.observe(Me),()=>r.disconnect()},[Me]),y(()=>{const e=r=>({setConfirming:r,land:W,markPaid:()=>Ke(!0),note:(c,n)=>Hn({text:c,warning:n}),fail:S,clearCart:ke,lostChange:()=>Ze(lt)}),t={search:window.location.search,storage:at,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};Ue(Or,{...t,capture:P.captureAfterpayPayment,page:e(Dn)}),Ue(Tr,{...t,capture:P.captureZipPayment,page:e(Xn)}),Ue(Rr,{...t,capture:P.completeGocardlessPayment,page:e(Wn)}),Ue(Mr,{...t,capture:P.captureKlarnaPayment,page:e(jn)})},[]);function Ft(e){const[t,r]=hn(e.address);ne(t),re(r),oe(e.city),se(e.zip_code),e.country&&ae(e.country),e.phone&&ce(e.phone),z({country:e.country||null,state:e.state??""})}y(()=>{if(ve){if((ve.country||p)!==p){z(null);return}ze===p&&(Ae(_r(p,ve.state,ie)),z(null))}},[ve,p,ze,ie]),y(()=>{let e=!1;return(async()=>{try{const[t,r,c]=await Promise.all([ye.me(),ye.myProfile().catch(()=>null),ye.myAddresses().catch(()=>[])]);if(e)return;bt(t);const n=c.filter(d=>d.is_active);Nt(n),we(t.email);const i=(r?.contact_name??"").split(/\s+/);Pe(t.first_name||i[0]||""),be(t.last_name||i.slice(1).join(" "));const l=t.phone||r?.phone;l&&ce(l);const u=n.find(d=>d.id===t.default_delivery_location)??n[0];if(u)Oe(u.id),Ft(u);else if(r){const[d,Q]=hn(r.address??"");ne(d),re(Q),oe(r.city??""),se(r.zip_code??""),r.country&&ae(r.country),z({country:r.country||null,state:r.state??""})}qe.current&&Gt(qe.current,!1)}catch{}})(),()=>{e=!0}},[]);function tr(){ye.logout(),de.current=!0,qe.current=null,Fe.current=null,pe(),bt(null),Nt([]),Oe("new"),At(!1),we(""),Pe(""),be(""),De(""),ne(""),re(""),oe(""),se(""),ce(""),ae(ht||ee[0]?.code||""),Ae(""),z(null)}const X=un(()=>gn(o,{canParkContext:kt}),[o,kt]);y(()=>{X.some(e=>e.key===w)||Ce(X[0]?.key??null)},[X,w]);const nr=X.length===0,Le=Se.trim()?`${te}
|
|
3
|
+
${Se.trim()}`:te,rr=Jr({email:F,firstName:T,lastName:G,company:Ne.trim(),phone:D,address:Le,city:q,subdivision:E,postcode:_,country:p,lines:f.map(e=>[e.id,e.qty]),shippingMethodId:V,couponCode:yn(M),currency:b.currency,shopperId:ue?.id??null}),N=JSON.stringify([rr,w]),et=m(null),Te=m(!1),I=m(!1),Z=m(null),_e=m(!1),v=m(N);v.current=N;const qt=m(L);qt.current=L;const xe=m(null);y(()=>{const e=()=>{const t=xe.current;t&&(xe.current=null,A(t),Ge(!1))};return window.addEventListener("pageshow",e),()=>window.removeEventListener("pageshow",e)},[]);function Ie(e,t,r,c){const n={idempotencyKey:t,confirmation:r};Zt()&&(n.lostChange=!0),at.setItem(e,JSON.stringify(n)),window.location.assign(c),xe.current=r}async function $t(e){Ge(!0);try{await e()}finally{xe.current||Ge(!1)}}const Bt=m(!1),Ut=!!(je||le&&le.kind!=="processing");y(()=>{Ut&&(Bt.current=!0,pe())},[Ut]);const Fe=m(null),de=m(!1),tt=m(null);function pe(){tt.current=null,xr()}const qe=m(null),[j,or]=s(!1);function nt(e){if(Bt.current||h||de.current)return;const t={key:e,authed:Ve.current,parkedAt:tt.current??=Date.now(),press:Pn(eo,a.current),lines:f.length>0?f:B.current,form:qr({email:F,firstName:T,lastName:G,company:Ne,address1:te,address2:Se,city:q,postcode:_,phone:D,country:p,subdivision:E,selectedAddressId:Je,shippingMethodId:V,couponCode:M?.valid?M.code:null})};Ir(t.press)?Fr(t):pe()}const Yt=m(w);Yt.current=w;function rt(e){return{...Yr(e),...wn(),...e.payFirst?{checkoutFlow:dt}:{}}}function sr(e,t){let r=e.request.payFirst?"":null,c=e.plainPressed?null:"";const n=()=>Yt.current??"";return{key:e.key,send:()=>t(rt(e.request)),request:rt(e.request),lines:e.lines,shape:JSON.stringify([e.goods,null]),get method(){return r??n()},set method(i){r=i},get plainMethod(){return c??n()},set plainMethod(i){c=i},plainLines:e.plainLines,plainShape:JSON.stringify([e.plainGoods,null])}}const[cr,ar]=s(!1),Ht=cr?!b.quoted||b.serverSubtotal===null?"waiting":Math.abs(b.serverSubtotal-b.subtotal)<Qr?"same":"changed":null,ot=!C&&Ht==="waiting",ir=ot?{...b,repricing:!0}:b,st=ot&&b.quoteFailed;y(()=>{if(!st)return;const e=setInterval(ge,jr);return()=>clearInterval(e)},[st,ge]);const ur=ge;function Gt(e,t=!0){we(e.email),Pe(e.firstName),be(e.lastName),De(e.company),ne(e.address1),re(e.address2),oe(e.city),se(e.postcode),ce(e.phone),e.country&&ae(e.country),z({country:e.country||null,state:e.subdivision}),Oe(e.selectedAddressId),e.shippingMethodId&&ft(e.shippingMethodId),t&&(Fe.current=e.couponCode)}y(()=>{let e=h?null:Br();const t=!!(e&&f.length>0);if(e&&t&&!Ur(e.lines,f)&&(pe(),e=null),e){const r=e.authed?P.createOrderAuthed:P.createOrder;Ee(e.key),tt.current=e.parkedAt,Ve.current=e.authed;const c={lastPress:n=>n&&sr(n,r),keptCardKey:n=>n,placedShape:n=>n===null?null:JSON.stringify([n,null]),placedRequest:n=>{if(!n)return null;const i=rt(n);return{body:i,send:()=>r(i)}},unpaidOrder:n=>n};a.current=Pn(c,e.press),e.press.unpaidOrder&&A(e.press.unpaidOrder),e.lines.length>0&&!t&&(He(e.lines),B.current=e.lines,ar(!0)),e.form&&(qe.current=e.form,Gt(e.form))}or(!0)},[]),y(()=>{!j||f.length>0||a.current.unpaidOrder||L||(de.current=!0,pe())},[j,f.length]),y(()=>{const e=Fe.current;!j||!e||f.length===0||(Fe.current=null,An(e,F||void 0))},[j,f.length]),y(()=>{!j||L||nt($)},[j,L,$,C]);const U=m(null);y(()=>{qt.current||(N!==U.current&&(U.current=null),!(!I.current||!C||C.orderNumber)&&(N===a.current.placedShape||N===U.current||$t(()=>Dt(C))))},[N,C]);async function Dt(e){if(_e.current)return null;_e.current=!0;try{const t=Z.current?await zr(Z.current):"none";if(t==="succeeded"||t==="processing")return I.current=!1,A(null),R("card"),t==="succeeded"?await Y(void 0,e):tn(e),null;if(t===void 0||!Gr.has(t))return U.current=v.current,A(e),S(t==="requires_action"?Hr:ut),null;const r=await fn($);if(r==="committed")return I.current=!1,A(null),R("card"),await Y(void 0,e),null;if(r!=="released")return U.current=v.current,A(e),S(ut),null;I.current=!1,Z.current=null,U.current=null,S(null),A(null);const c=Be();return Ee(c),c}finally{_e.current=!1}}async function lr(){h||L||_e.current||await $t(dr)}async function dr(){if(C){if((I.current?N!==a.current.placedShape:fe())&&!C.orderNumber){const c=await Dt(C);c&&v.current===N&&await zt(c);return}S(null),Te.current=!1,await ct();const t=O(v.current)[1],r=C.orderNumber?t:"card";if(r&&Cn.has(r)&&fe()&&O(v.current)[0]!==et.current){Wt(C);return}R(r),r!==w&&Ce(r),await nn(C,r,!C.orderNumber);return}await zt($)}async function zt(e){if(f.length===0||b.repricing||ot||!w||!X.some(l=>l.key===w))return;const t=f.filter(ln).flatMap(l=>Sr(l.components,l.qty));if(t.length===0){S("Pick a size on each wheel's product page before checking out.");return}S(null);let r,c=e,n=w,i=!1;try{const l=ue?P.createOrderAuthed:P.createOrder,u={customer:{email:F,name:`${T} ${G}`.trim(),phone:D.trim()||void 0,companyName:Ne.trim()||void 0,address:Le,city:q,state:E||void 0,zipCode:_,country:p},items:t,currency:b.currency,idempotencyKey:e,shippingMethodId:V??void 0,couponCode:yn(M),...wn(),...Dr(w)?{checkoutFlow:dt}:{}};a.current.placedRequest={body:u,send:()=>l(u)},Ve.current=!!ue,de.current=!1,Ze(null),et.current=null,Te.current=!1,Z.current=null,I.current=!1,U.current=null,a.current.placedShape=N,B.current=f;const d=a.current.lastPress,Q=d?.key===u.idempotencyKey&&(d.shape!==N&&(!!u.checkoutFlow||!!d.method||!!d.plainMethod)||!!u.checkoutFlow&&!!d.plainMethod);Q&&(a.current.keptCardKey=u.idempotencyKey);const sn=Qt(u,l),cn=Q||!u.checkoutFlow&&a.current.keptCardKey===u.idempotencyKey,an=!sn&&!cn&&!u.checkoutFlow&&!!d&&!d.method;an&&(d.plainMethod=w,d.plainLines=f,d.plainShape=N,nt(u.idempotencyKey));const H=await(cn?Xt(u,l):l(u).then(me=>({answer:me,request:u})).catch(me=>(sn?Jt(me,u.idempotencyKey):an&&mn(me)&&(d.plainMethod=""),pr(me,u,l))));if(!H)return;r=H.answer,c=H.request.idempotencyKey,n=H.method??n,R(n),i=fe()||n!==O(v.current)[1],H.method&&H.method!==w&&Ce(H.method),r.orderNumber&&(Vt(r),ke()),await ct()}catch(l){const u=Zr(l);u?(Nn(u),S(`${u} Your order has not been placed. Place it again to continue without the code.`)):l instanceof Ye?S(ut):S(l instanceof $e?l.message:"Could not place the order. Please try again.");return}if(n&&Cn.has(n)&&(i||fe())){Wt(r);return}await nn(r,n,!1,c)}function Wt(e){et.current=O(v.current)[0],S(`${kn(e,null)} ${lt}`),A(e)}function Jt(e,t){mn(e)&&!pn(e)&&a.current.lastPress?.key===t&&(a.current.lastPress=null)}async function pr(e,t,r){if(it(e))return jt(t,r);if(!pn(e))throw e;return a.current.keptCardKey=t.idempotencyKey,Xt(t,r,!0)}async function Xt(e,t,r=!1){const c=await fn(e.idempotencyKey);if(c==="released")return jt(e,t);if(c!=="committed")throw new Ye;const n=a.current.lastPress?.key===e.idempotencyKey?a.current.lastPress:null;if(B.current=n?.lines??f,n?.method&&!r){a.current.keptCardKey=null,a.current.placedRequest={body:n.request,send:n.send};const Q=await n.send().catch(()=>{throw new Ye});return a.current.placedShape=n.shape,{answer:Q,request:e,method:n.method}}const i={...e,checkoutFlow:dt},l=n&&!n.method?{body:n.request,send:n.send}:{body:i,send:()=>t(i)};a.current.placedRequest=l;const u=l.send,d=await u().catch(()=>null);if(!d&&n?.plainMethod)throw new Ye;return d?.orderNumber&&d.status!==Wr?(a.current.keptCardKey=null,n?.plainMethod&&(B.current=n.plainLines),n&&(a.current.placedShape=n.plainMethod?n.plainShape:n.shape),{answer:d,request:e,method:n?.plainMethod||void 0}):(n&&(a.current.placedShape=n.shape),R("card"),await en("",d?async()=>d:()=>Promise.reject(new Error("The order request did not answer."))),await ct(),null)}function fe(){const e=a.current.placedShape;return e!==null&&O(e)[0]!==O(v.current)[0]}function R(e){e!==O(v.current)[1]&&(Te.current=!0),Ze(Zt()?lt:null)}function Zt(){return Te.current||fe()}async function jt(e,t){const r={...e,idempotencyKey:Be()};a.current.keptCardKey=null,Ee(r.idempotencyKey),a.current.placedRequest={body:r,send:()=>t(r)},Qt(r,t);try{return{answer:await t(r),request:r}}catch(c){throw Jt(c,r.idempotencyKey),c}}function Qt(e,t){return a.current.lastPress?.key===e.idempotencyKey?!1:(a.current.lastPress={key:e.idempotencyKey,send:()=>t(e),request:e,lines:f,shape:N,method:e.checkoutFlow?"":w??"",plainMethod:"",plainLines:f,plainShape:N},de.current=!1,nt(e.idempotencyKey),!0)}function Vt(e){br({confirmation:e,lines:B.current,adsSendTo:o.googleAdsId&&o.googleAdsConversionLabel?`${o.googleAdsId}/${o.googleAdsConversionLabel}`:null}),Nr({confirmation:e,lines:B.current})}async function Y(e,t=x){if(!t)return;const r=e?async()=>e:a.current.placedRequest?.send;if(t.orderNumber||!r){Ke(!0),W(t);return}await en(t.checkoutNumber,r)}async function en(e,t){ke(),await Xr({checkoutNumber:e,resend:t,page:{setConfirming:Qn,land:W,markPaid:()=>Ke(!0),track:Vt,unplaced:Tt}})}function tn(e=x){if(e){if(e.orderNumber){W(e);return}ke(),Tt({kind:"processing",checkoutNumber:e.checkoutNumber})}}async function ct(){const e=JSON.stringify([Xe.trim(),T,G,D.trim(),Le,q,E,_,p]);if(!(!ue||!St||Je!=="new"||Ot.current===e))try{await ye.createAddress({label:Xe.trim()||"Home",contact_name:`${T} ${G}`.trim(),phone:D.trim(),address:Le,city:q,zip_code:_,state:E,country:p}),Ot.current=e,vt("Address saved to your account.")}catch{vt("We couldn't save the address to your account — you can add it under Account → Addresses.")}}async function nn(e,t=w,r=!1,c=$){A(null);try{if(t==="card"&&o.paymentMethods.includes("card")){const n=await P.createPaymentIntent({idempotencyKey:c});Z.current=n;let i=e;if(r){const l=await a.current.placedRequest?.send().catch(()=>null);if(l?.orderNumber){R("card"),await Y(l,e);return}i=rn(e,l)??{...e,expiresAt:null}}R("card"),J(i),Qe(!1),Re(n)}else if(t==="paypal"&&o.paymentMethods.includes("paypal"))J(e),qn(!0);else if(t==="afterpay"&&o.paymentMethods.includes("afterpay")){const n=window.location.origin,i=await P.createAfterpayCheckout({idempotencyKey:c,confirmUrl:`${n}/checkout?afterpay=confirm`,cancelUrl:`${n}/checkout?afterpay=cancel`});Ie(vr,c,e,i.redirectCheckoutUrl);return}else if(t==="square"&&o.paymentMethods.includes("square"))J(e),$n(!0);else if(t==="gocardless"&&o.paymentMethods.includes("gocardless")){const n=window.location.origin,i=await P.createGocardlessBillingRequest({idempotencyKey:c,confirmUrl:`${n}/checkout?gocardless=confirm`,cancelUrl:`${n}/checkout?gocardless=cancel`});Ie(Er,c,e,i.authorisationUrl);return}else if(t==="zip"&&o.paymentMethods.includes("zip")){const n=window.location.origin,i=await P.createZipCheckout({idempotencyKey:c,redirectUrl:`${n}/checkout?zip=return`});Ie(Lr,c,e,i.redirectUrl);return}else if(t==="klarna"&&o.paymentMethods.includes("klarna")){const n=window.location.origin,i=await P.createKlarnaCheckout({idempotencyKey:c,confirmUrl:`${n}/checkout?klarna=confirm`,cancelUrl:`${n}/checkout?klarna=cancel`});Ie(Kr,c,e,i.redirectUrl);return}else R(t),W(e)}catch(n){if((r||t==="card")&&n instanceof $e&&n.status===409){R(t),await Y(void 0,e);return}on(e,n)}}function rn(e,t){return t&&!t.orderNumber&&t.status==="open"&&t.checkoutNumber===e.checkoutNumber?t:null}function on(e,t){S(kn(e,t)),!e.orderNumber&&it(t)?(I.current=!1,Ee(Be())):A(e)}async function fr(e){if(!x)return;const t=x;try{const r=await P.createPaymentIntent({idempotencyKey:$}),c=await a.current.placedRequest?.send().catch(()=>null);if(c?.orderNumber){await Y(c);return}const n=rn(t,c);J(n??{...t,expiresAt:null}),Qe(e&&n!==null),Z.current=r,Re(r)}catch(r){if(r instanceof $e&&r.status===409){await Y();return}Re(null),J(null),on(t,r)}}function mr(){x&&(I.current=!0,A(x),Re(null),J(null),Qe(!1))}return{site:o,logo:k,signInHref:g,items:f,totals:ir,coupon:M,deliveryOptions:pt,courierUnavailable:Mn,retryCourier:Ln,shippingMethodId:V,setShippingMethodId:ft,pickupLocation:vn,servedCountries:ee,formatMoney:On,payChoice:w,setPayChoice:Ce,placing:L,email:F,setEmail:we,firstName:T,setFirstName:Pe,lastName:G,setLastName:be,company:Ne,setCompany:De,address1:te,setAddress1:ne,address2:Se,setAddress2:re,city:q,setCity:oe,postcode:_,setPostcode:se,phone:D,setPhone:ce,country:p,setCountry:ae,subdivision:E,setSubdivision:Ae,subdivisions:ie,destination:wt,postcodeLabel:Rn,subdivisionLabel:Kn,me:ue,savedAddresses:Tn,selectedAddressId:Je,setSelectedAddressId:Oe,saveAddress:St,setSaveAddress:At,saveLabel:Xe,setSaveLabel:_n,addressSaveNote:xn,lostChangeNote:In,idemKey:$,confirmation:je,setConfirmation:W,orderError:Fn,payment:Et,paypalStep:Rt,squareStep:Kt,pendingConf:x,paid:Bn,setPaid:Ke,unpaidOrder:C,orderLocked:Mt,formLocked:Un,restoredPrices:Ht,quoteFailed:st,retryQuote:ur,payNote:Yn,afterpayConfirming:Gn,gocardlessConfirming:zn,zipConfirming:Jn,klarnaConfirming:Zn,cardConfirming:Lt,checkoutResult:le,confirmCardPayment:Y,cardStillProcessing:tn,renewCardPayment:fr,holdRenewed:Vn,leaveCardPayment:mr,checkoutRootRef:It,setCheckoutHeaderEl:er,fillFromAddress:Ft,checkoutSignOut:tr,payOptions:X,noPaymentMethod:nr,placeOrder:lr}}const bn=yr(null);function So({children:o,...k}){const g=to(k);return K(bn.Provider,{value:g,children:o})}function Ao(){const o=hr(bn);if(!o)throw new Error("useCheckout must be used inside CheckoutStateProvider");return o}export{So as CheckoutStateProvider,Po as NO_PAYMENT_METHOD_NOTE,bo as SHIPPING_RETRY_NOTE,gn as buildPayOptions,kn as paymentNotStartedMessage,No as placedOrderLockNote,Ao as useCheckout};
|
|
@@ -1322,6 +1322,7 @@ export interface components {
|
|
|
1322
1322
|
wheels: number;
|
|
1323
1323
|
prices: components["schemas"]["Prices"];
|
|
1324
1324
|
hand?: "left" | "right" | null;
|
|
1325
|
+
axle?: "front" | "rear" | null;
|
|
1325
1326
|
renderKey?: string;
|
|
1326
1327
|
};
|
|
1327
1328
|
WheelVariant: {
|
|
@@ -1911,6 +1912,7 @@ export interface components {
|
|
|
1911
1912
|
unit: "set" | "single";
|
|
1912
1913
|
spares: number;
|
|
1913
1914
|
spareSide?: "left" | "right";
|
|
1915
|
+
spareAxle?: "front" | "rear" | null;
|
|
1914
1916
|
readonly spare?: boolean;
|
|
1915
1917
|
};
|
|
1916
1918
|
CartCaptureRequest: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PurchaseChoice, type PurchaseUnit, type SetComponent, type SpareSide } from "../commerce.js";
|
|
1
|
+
import { type PurchaseChoice, type PurchaseUnit, type SetComponent, type SpareAxle, type SpareSide } from "../commerce.js";
|
|
2
2
|
import type { CartLine } from "../../components/CartContext.js";
|
|
3
3
|
import type { StorePart, StoreProduct } from "./store-product.js";
|
|
4
4
|
export declare function vehicleGate(product: StoreProduct): "required" | "advisory";
|
|
@@ -19,6 +19,7 @@ export interface PurchaseOffer {
|
|
|
19
19
|
label: string;
|
|
20
20
|
options: readonly {
|
|
21
21
|
value: SpareSide;
|
|
22
|
+
axle?: SpareAxle;
|
|
22
23
|
label: string;
|
|
23
24
|
}[];
|
|
24
25
|
} | null;
|
|
@@ -37,6 +38,11 @@ export declare const SPARE_WORDS: {
|
|
|
37
38
|
readonly whichSide: "Which side is the spare?";
|
|
38
39
|
readonly left: "Left";
|
|
39
40
|
readonly right: "Right";
|
|
41
|
+
readonly whichWheel: "Which wheel is the spare?";
|
|
42
|
+
readonly frontLeft: "Front left";
|
|
43
|
+
readonly frontRight: "Front right";
|
|
44
|
+
readonly rearLeft: "Rear left";
|
|
45
|
+
readonly rearRight: "Rear right";
|
|
40
46
|
};
|
|
41
47
|
export declare function purchaseOffer(product: StoreProduct, part: StorePart | null, state: PurchaseState): PurchaseOffer;
|
|
42
48
|
export interface PurchaseContext {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DEFAULT_PURCHASE_CHOICE as
|
|
1
|
+
import{DEFAULT_PURCHASE_CHOICE as d,MAX_SPARES as L,UNITS_PER_SET as o,WHEELS_PER_SET as p,packLabel as v,setPackComposition as m,spareTargetsByCorner as E,spareTargetsByHand as k,withSpare as R}from"../commerce.js";import{tyreCartLine as w,tyrePackComposition as C}from"../tyres/tyre-purchase.js";import{setLabel as $}from"../wheels/variants.js";import{partVariant as S}from"./from-wheel.js";import{splitWheelName as x}from"../wheels/wheel-name.js";function U(n){return n.kind==="tyre"?"advisory":"required"}const F={choice:d,qty:1};function A(n,e){if(n.kind!=="alloy-wheel")return`Set of ${p}`;const i=S(n.source,e);return i?$(i):`Set of ${p}`}const b=(n,e)=>n===1?e:`${n} × ${e}`;function y(n){return n.unit==="set"?{label:`Add a spare — ${o+1} instead of ${o}`}:null}const l={howMany:"How many wheels",oneSet:"One set",oneSetPlusSpare:"One set + 1 spare",whichSide:"Which side is the spare?",left:"Left",right:"Right",whichWheel:"Which wheel is the spare?",frontLeft:"Front left",frontRight:"Front right",rearLeft:"Rear left",rearRight:"Rear right"};function P(n,e){if(e.unit!=="set")return null;const i=k(n)!==null;return!i&&E(n)===null?null:{counts:[{value:o,label:l.oneSet},{value:o+L,label:l.oneSetPlusSpare}],side:e.spares<=0?null:i?{label:l.whichSide,options:[{value:"left",label:l.left},{value:"right",label:l.right}]}:{label:l.whichWheel,options:[{value:"left",axle:"front",label:l.frontLeft},{value:"right",axle:"front",label:l.frontRight},{value:"left",axle:"rear",label:l.rearLeft},{value:"right",axle:"rear",label:l.rearRight}]}}}function _(n,e,i){if(n.kind==="tyre")return{packs:[{value:"set",label:`A set of ${o}`},{value:"single",label:"Just one"}],extra:y(i.choice),spareCounts:[],spareSide:null,components:e?C({sku:e.id,prices:e.components[0].prices},i.choice):[],quantityLabel:b(i.qty,v(i.choice))};const r=e?P(e.components,i.choice):null;return{packs:[],extra:r?null:y(i.choice),spareCounts:r?.counts??[],spareSide:r?.side??null,components:e?m(e.components,i.choice):[],quantityLabel:b(i.qty,R(A(n,e),i.choice))}}function N(n,e,i,r,c){if(!e)return null;if(n.kind==="tyre"){const f=(n.source.variants??[]).find(g=>g.sku===e.id);return f?w(n.source,f,r.choice,r.qty):null}const t=n.source,u=S(t,e);if(!u)return null;const a=e.options.finish??"",s=u.size,h=r.choice.spares>0;return{id:`${t.slug}|${a}|${s}|${c.fitmentKey}${h?"|spare":""}`,slug:t.slug,name:x(t.name),process:t.process,positionNo:"01",config:[{label:s},{label:a,gold:!0},{label:c.fitmentLabel},{label:_(n,e,r).quantityLabel}],finishName:a,size:s,components:m(e.components,r.choice),qty:r.qty,...h?{pack:r.choice}:{}}}export{F as DEFAULT_PURCHASE_STATE,l as SPARE_WORDS,N as productCartLine,_ as purchaseOffer,U as vehicleGate};
|