efficient-storefront-blocks 0.132.2 → 0.133.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/chunks/{CustomHtmlCodeWindow-2WCOBTZI.js → CustomHtmlCodeWindow-VMHVWWU4.js} +1 -1
- package/dist/chunks/EditorPreviewCheckout-ZZWN45X3.js +4 -0
- package/dist/chunks/SiteEditorProvider-XQBBIEX4.js +1 -0
- package/dist/chunks/{chunk-3P4XQK3S.js → chunk-6YESFEQM.js} +1 -1
- package/dist/chunks/{chunk-OBAUAKZL.js → chunk-C2YDFOCO.js} +1 -1
- package/dist/chunks/{chunk-UFQDBLLF.js → chunk-DI3WYPQW.js} +1 -1
- package/dist/chunks/{chunk-TNWF32DT.js → chunk-DO5FAI7I.js} +1 -1
- package/dist/chunks/{chunk-WCEMPYVI.js → chunk-GXZNWNY6.js} +1 -1
- package/dist/chunks/{chunk-XXVOKKJV.js → chunk-NQZ3O6A3.js} +1 -1
- package/dist/chunks/chunk-PDLGLUEV.js +337 -0
- package/dist/chunks/{chunk-PB4FLVPH.js → chunk-Z5XT44JU.js} +1 -1
- package/dist/chunks/{fitment-data-MW7I7F7T.js → fitment-data-6FBUVM5L.js} +1 -1
- package/dist/chunks/{section-css-style-7OKHUI7L.js → section-css-style-YWXTU6HK.js} +1 -1
- package/dist/index.js +38 -17
- package/dist/links.js +1 -1
- package/dist/render/built-with.json +1 -1
- package/dist/render/components/checkout/CheckoutPageClient.js +1 -1
- package/dist/render/components/checkout/checkout-parts.js +1 -1
- package/dist/render/components/checkout/checkout-state.d.ts +2 -1
- package/dist/render/components/checkout/checkout-state.js +3 -3
- package/dist/render/lib/api/index.d.ts +5 -0
- package/dist/render/lib/api/index.js +1 -1
- package/dist/render/lib/api/types.d.ts +138 -1
- package/dist/render/lib/checkout/wallet-return.d.ts +3 -1
- package/dist/render/lib/checkout/wallet-return.js +1 -1
- package/dist/render/lib/content/site.d.ts +1 -1
- package/dist/routine-index.json +1 -1
- package/dist/value-index.json +1 -1
- package/package.json +3 -3
- package/dist/chunks/EditorPreviewCheckout-LWCGOB7R.js +0 -4
- package/dist/chunks/SiteEditorProvider-IOAQH4S4.js +0 -1
- package/dist/chunks/chunk-3RAPOAJE.js +0 -337
- /package/dist/chunks/{chunk-2NWFNMO3.js → chunk-454ZVMST.js} +0 -0
- /package/dist/chunks/{chunk-OBAUAKZL.js.LEGAL.txt → chunk-C2YDFOCO.js.LEGAL.txt} +0 -0
- /package/dist/chunks/{chunk-AHUOASUP.js → chunk-IHBF4FM5.js} +0 -0
- /package/dist/chunks/{chunk-YDV7IGPY.js → chunk-LN6M3FAM.js} +0 -0
- /package/dist/chunks/{chunk-3RAPOAJE.js.LEGAL.txt → chunk-PDLGLUEV.js.LEGAL.txt} +0 -0
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 T=[{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=>T.some(t=>t.kind===e)).filter(e=>!fe.includes(e)),mt=[...T,{open:"*",close:"*",kind:"accent"}],ht=[...T,{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 V(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 V(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 Ae(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 Y=e=>typeof e=="string"&&e?e:void 0;function G(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function Oe(e,t){return Object.hasOwn(e,t)}var Te=null;function _e(e,t){return t?e.replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g,(n,r)=>Oe(t,r)?String(G(t,r)):n):e}function g(e,t){let n=Te?G(Te,e):void 0;if(typeof n=="function"){try{let r=Y(n(t??{}));if(r)return r}catch{}return _e(e,t)}return _e(Y(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);var Vn=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 At(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 Tt(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(Ae(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 V(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))):At(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(Tt(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 Ve(e,t){return t==="root"?e.root:e.components[t]}function Ye(e){return e?.fields??{}}function Ge(e,t){return Ye(Ve(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,Ge(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 A="/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(A)?[...n,A]: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 Vt(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",Yt="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,Yt,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 Gt(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===A)&&s.push({value:A,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=Gt({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{A 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,Vt 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
|
+
var g={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:g.bold.placeholder,italic:g.italic.placeholder,strike:g.strike.placeholder,code:g.code.placeholder,highlight:g.highlight.placeholder,quiet:g.quiet.placeholder,link:"link text",underline:g.underline.placeholder,sup:g.sup.placeholder,sub:g.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 O=[{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=>O.some(t=>t.kind===e)).filter(e=>!fe.includes(e)),mt=[...O,{open:"*",close:"*",kind:"accent"}],ht=[...O,{open:"*",close:"*",kind:"accent"},{open:"#",close:"#",kind:"bold",notBefore:"0123456789"},{open:"[",close:"]",kind:"italic",notBefore:"(",notBeforeBlock:!0}];var gt=["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||gt.includes(t[1].toLowerCase())}var de=["width","profile","rim"];var yt=/^\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=yt.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(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[E({width:e.width}),E({width:e.width,profile:e.profile}),E(e)]}var x=["alloy-wheel","tyre"],he=["alloy-wheel"],_={"alloy-wheel":"Alloy wheels",tyre:"Tyres"};var Mn=x.map(e=>({value:e,label:_[e]}));function ge(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 ye(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 V=e=>typeof e=="string"&&e?e:void 0;function G(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function Ae(e,t){return Object.hasOwn(e,t)}var Oe=null;function Ee(e,t){return t?e.replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g,(n,r)=>Ae(t,r)?String(G(t,r)):n):e}function y(e,t){let n=Oe?G(Oe,e):void 0;if(typeof n=="function"){try{let r=V(n(t??{}));if(r)return r}catch{}return Ee(e,t)}return Ee(V(n)??e,t)}function q(e){return(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}var F=(e,t,n,r)=>({default:e,min:t,max:n,step:r}),Wn=F(30,0,100,10),Hn=F(0,0,100,5),Yn=F(100,0,100,5);var Vn=F(2,0,4,.5);var Gn=["button","summary",'[role="button"]','[role="checkbox"]','[role="switch"]',"video[controls]","audio[controls]",...["checkbox","button","submit","reset","image","color","file"].map(e=>`input[type="${e}"]`)].join(", "),qn=["menuitem","option","listbox","slider","tab","tablist","combobox","radio","radiogroup","spinbutton","menu","menubar","tree","treeitem","grid","gridcell"].map(e=>`[role="${e}"]`).concat('input[type="radio"]','input[type="range"]').join(", "),St="data-motion-pin-free",Zn=`.maplibregl-map, .mapboxgl-map, .leaflet-container, .gm-style, [${St}]`;function _e(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.text=="string"?e.text.trim():""}var Fe="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 v(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 ve(e){return e.startsWith(Z)&&e.slice(Z.length).trim()||null}function b(e){return e===Fe?"/":`/${e}`}function R(e){return`/journal/${e}`}function N(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=_e(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 Re(e){return/^\/wheels\/[^/?#]+(?:[?#].*)?$/.test(e)}var Pt=()=>({choosePage:y("Choose a page"),chooseSection:y("Choose a section"),noSections:y("No section anchors yet"),sectionHint:y("Jumps to a section on that page."),choosePost:y("Choose a post"),chooseProduct:y("Choose a product"),choosePopup:y("Choose a popup")});function K(e,t,n){if(!e)return"page";if(ve(e))return"popup";if(e.startsWith("/journal/"))return"blog";if(Re(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 Ne(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:R(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=v(e.offers).map(c=>({value:c.value,label:y(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 $e(e){return xt(e,"filter")}var kt="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":kt},pcds:{"alloy-wheel":"pcd"},tyreTypes:{tyre:"tire_type"},speedRatings:{tyre:"speed_rating"}}[e]?.[t]}function xt(e,t){let n=new Set(e.filter(r=>r[t]===!1).map(r=>r.fieldKey));return r=>!r||!n.has(r)}function wt(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function ze(e,t){let n=e?.[t];return wt(n)?n:null}function De(e,t,n,r){if(n==null&&r==null)return!0;let o=ze(e,t);return!(o===null||n!=null&&o<n||r!=null&&o>r)}function Ue(e){let t=e.spec?.lugs;return typeof t=="number"?t:null}var Lt={recommended:"Recommended","price-asc":"Price \xB7 low to high","price-desc":"Price \xB7 high to low",new:"Newest",name:"Name A\u2013Z"},Cr=Object.keys(Lt);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"]},Tt={diameters:"tyreSizes"};function At(e){if(e.length===0)return[];let t=J.filter(n=>e.every(r=>ee[n].includes(r)));return t.filter(n=>{let r=Tt[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 Et(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(ye(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=>vt(u,r,o),l=Ft(e),p=(s==="pass"?J.filter(u=>r.some(P=>ee[u].includes(P))):At(r)).filter(u=>u!=="tyreSizes").filter(i).map(u=>{let P=t[u].map(String),ce=new Set,B=new Map,A=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))A.set(h,(A.get(h)??0)+1);if(Et(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=(A.get(S.value)??0)-(A.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>It),c=[];for(let u of p){let P=Rt(u.key,r,o);P!==void 0&&c.push({fieldKey:u.key,filterOrder:P})}return[...Ke(p,u=>u.key,c,"filterOrder")]}var It=1;function He(e){return e.showCollection===!1?["collections"]:[]}function vt(e,t,n){return t.length===0||n.length===0?!0:t.some(r=>$e(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 $=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 Ve(e){return e?.fields??{}}function Ge(e,t){return Ve(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 Mt(e,t,n).map(({slot:r,content:o})=>({slot:r,content:o}))}function z(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 Mt(e,t,n){let r=qe(e.props,Ge(t,e.type));if(n?.order!=="stored")return r;let o=z(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 Kt=Ze.filter(e=>e!=="ButtonBlock");function Xe(){return{type:"slot",allow:[...Kt]}}var $t="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:{[$t]:{type:"slot"},template:k()}};var zt={},Dt=null;function Ut(){let e=Object.fromEntries(Object.entries(Qe).map(([t,n])=>[t,{fields:n}]));return Dt??={components:{...e,...zt}}}function Bt(e){let t=e.props??{},n=typeof e.type=="string"?e.type:"",r=Ut(),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=>$(t[l])),i=z(Object.keys(t).filter(l=>!o.includes(l)&&$(t[l])));return[...s,...i]}function Je(e,t){let n=null;for(let r of Bt(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 jt(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 Wt(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 jt(e))n(r,[]);return t}function nt(e){return Wt(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 Ht(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(Ht(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 Yt(e,t,n=[]){return K(e,t,{listingPaths:n,targetOf:r=>at(r,n)})}function Vt(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=ge(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:_[a]}))}),i}function qt(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 Zt(e){let t=qt({catalogue:e.catalogue,fieldUsage:e.fieldUsage,offersCommerce:e.offers.offersCommerce})(e.pages),n=Ne({pages:e.pages,posts:e.posts,products:e.products.map(r=>({href:N(r.slug),name:r.name||r.slug})),offers:e.offers},t);return{...n,rules:{...n.rules,isSafe:rt},filtersFor:n.filtersFor??(()=>null)}}function ns(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,Vt as fieldUsageFromAdminRows,Yt as inferLinkKind,U as isProductListingPage,rt as isSafeLink,v as linkKindsFor,Zt as linkPickerSetup,ns as listingFilterFields,se as listingNode,ot as listingPageLabel,at as listingTarget,M as pageAnchors,b as pagePath,R as postPath,st as productListingPaths,lt as readListingFilter,N as wheelPath,le as withListingFilter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as r,Fragment as x}from"react/jsx-runtime";import R from"next/link";import{useEffect as D,useMemo as Y,useRef as j,useState as C}from"react";import{holdTime as X}from"../../lib/checkout/hold-time.js";import{stripeAppearance as J}from"../../lib/checkout/stripe-appearance.js";import{userZone as ee,parseOption as te}from"efficient-shell/format";import{Elements as re,PaymentElement as ne,useElements as ae,useStripe as ie}from"@stripe/react-stripe-js";import{loadStripe as oe}from"@stripe/stripe-js";import{useCurrency as E}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{resolveCopyright as ce}from"../../lib/content/site.js";import{ApiError as L,products as I}from"../../lib/api/index.js";import se,{WORDMARK_FIT_FLOOR_PX as le}from"efficient-web-builder/render/components/Logo";import{NOT_CHECKED as T,orderReference as de}from"../../lib/checkout/pay-first.js";import{CheckoutStateProvider as me,useCheckout as pe}from"./checkout-state.js";import{CheckoutContact as ue,CheckoutOrderSummary as fe,CheckoutPayment as xe,CheckoutShippingAddress as ge,CheckoutShippingMethod as he,FormLock as M,LeaveLink as z}from"./checkout-parts.js";function ye(t){return e(me,{...t,children:e(Ne,{})})}function be({order:t,paid:n}){const{formatMoney:o}=E();if(!t.grandTotal||!t.currency)return null;const m=s=>o(Number(s),t.currency),y=Number(t.freightCharge??0),p=Number(t.discountAmount??0);return r("dl",{className:"grid w-full max-w-sm grid-cols-[1fr_auto] gap-x-6 gap-y-1 border-y border-line py-3 text-left text-sm",children:[(t.shippingMethod||y>0)&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Delivery",t.shippingMethod?` · ${t.shippingMethod}`:""]}),e("dd",{className:"text-right font-mono",children:m(t.freightCharge??"0")})]}),p>0&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Discount",t.couponCode?` · ${t.couponCode}`:""]}),r("dd",{className:"text-right font-mono",children:["−",m(t.discountAmount??"0")]})]}),e("dt",{className:"text-fg",children:n?"Total paid":"Order total"}),e("dd",{className:"text-right font-mono text-fg",children:m(t.grandTotal)})]})}function ke({result:t,lostChangeNote:n=null}){const o=e("span",{className:"font-mono text-fg",children:t.checkoutNumber});return r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:t.kind==="refunded"||t.kind==="expired"?"Order not placed":t.kind==="processing"?"Payment processing":"Payment received"}),e("p",{className:"text-fg-dim",children:t.kind==="refunded"?r(x,{children:["An item sold out or an offer ended while you paid for checkout ",o,". Your payment goes back to your card."]}):t.kind==="expired"?r(x,{children:["The hold on checkout ",o," ran out before your payment arrived. Your payment goes back to your card."]}):t.kind==="processing"?r(x,{children:["Your payment for checkout ",o," is being processed. When it goes through, we will email your order confirmation."]}):r(x,{children:["Thank you — your payment",t.checkoutNumber?r(x,{children:[" for checkout ",o]}):null," has gone through. We will email you the order number shortly."]})}),n&&t.kind!=="refunded"&&t.kind!=="expired"&&e("p",{className:"text-sm text-fg-dim",children:n}),e(R,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]})}function Ne(){const{site:t,logo:n,items:o,placing:m,formLocked:y,email:p,me:s,addressSaveNote:g,lostChangeNote:d,idemKey:f,confirmation:c,setConfirmation:u,payment:h,paypalStep:k,squareStep:N,pendingConf:l,paid:b,setPaid:S,payNote:i,afterpayConfirming:a,gocardlessConfirming:P,zipConfirming:v,klarnaConfirming:K,cardConfirming:$,checkoutResult:A,confirmCardPayment:U,cardStillProcessing:W,renewCardPayment:H,holdRenewed:G,leaveCardPayment:Q,checkoutRootRef:V,setCheckoutHeaderEl:Z}=pe();return c?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:b?"Payment received":"Order received"}),r("p",{className:"text-fg-dim",children:[b?r(x,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:c.orderNumber})," has gone through."," "]}):r(x,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:c.orderNumber})," is being reviewed by our team."," "]}),s?r(x,{children:["Track it under"," ",e(R,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):e(x,{children:"We’ve emailed you a link to set a password and track it."})]}),e(be,{order:c,paid:b}),d&&e("p",{className:"text-sm text-fg-dim",children:d}),i&&(i.warning?e("div",{className:"w-full max-w-sm text-left",children:e(_,{tone:"bad",role:"alert",children:i.text})}):e("p",{className:"text-sm text-fg-dim",children:i.text})),g&&e("p",{className:"text-sm text-fg-dim",children:g}),!s&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(R,{href:`/track?order=${encodeURIComponent(c.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(R,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]}):A?e(ke,{result:A,lostChangeNote:d}):$?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Placing your order — one moment."})]}):a?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay — one moment."})]}):P?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Setting up your direct debit…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Confirming with GoCardless — one moment."})]}):v?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip — one moment."})]}):K?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna — one moment."})]}):h&&l?e(we,{payment:h,checkout:l,holdRenewed:G,onPaid:U,onProcessing:W,onRenew:H,onBack:Q}):k&&l?e(Se,{confirmation:l,clientId:t.paypalClientId??"",idemKey:f,onPaid:()=>{S(!0),u(l)},onSkip:()=>u(l)}):N&&l?e(Re,{confirmation:l,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:f,onPaid:()=>{S(!0),u(l)},onSkip:()=>u(l)}):r("div",{ref:V,className:"bg-bg text-fg",children:[r("header",{ref:Z,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 max-[640px]:grid-cols-[auto_minmax(0,1fr)_auto] max-[640px]:gap-3 border-b border-line px-[var(--sf-site-gutter,40px)] py-6 backdrop-blur-md max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))] max-[640px]:py-4",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[r(z,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[14px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),e("div",{className:"flex min-w-0 justify-center max-[640px]:[container-type:inline-size]",children:e(z,{href:"/","aria-label":`${t.name} home`,className:"inline-flex max-w-full items-center justify-center max-[640px]:overflow-x-clip",children:[!0,!1].map(w=>e(se,{hideClass:w?"min-[641px]:hidden":"max-[640px]:hidden",variant:"header",scrolled:!0,src:n?.url??null,reverse:n?.reverse??!1,reversedSrc:n?.reversed??null,inkIsDark:n?.inkIsDark??null,size:n?.size??"medium",sizePx:n?.sizePx??null,sizeUnit:n?.sizeUnit??null,siteName:t.name,fitWordmarkToContainer:w,fitFloorPx:w?le:void 0},w?"phone":"wide"))})}),t.cardPayments?r("span",{className:"flex items-center justify-end gap-3 font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim",children:[e("span",{className:"text-green",children:"●"}),e("span",{className:"max-[640px]:hidden",children:"Encrypted ·"})," Stripe"]}):e("span",{})]}),r("section",{className:"mx-auto flex max-w-[var(--sf-site-width,1600px)] flex-wrap items-center justify-between gap-x-8 gap-y-3 border-b border-line bg-surface px-[var(--sf-site-gutter,40px)] py-4 font-mono text-[13px] font-medium uppercase tracking-[0.24em] text-fg max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))]",children:[e("span",{className:"inline-flex items-center bg-accent px-3 py-1 font-bold text-bg",children:"Checkout"}),e("nav",{"aria-label":"Checkout steps",className:"flex flex-wrap items-center gap-5",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(w=>r("span",{className:["relative flex items-center gap-2 transition-colors",w.state==="pending"?"text-fg-dim":"text-fg",w.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[e("span",{className:w.state==="done"?"text-accent font-bold":"",children:w.n}),e("span",{children:w.label})]},w.n))})]}),r("main",{className:"mx-auto grid max-w-[var(--sf-site-width,1600px)] grid-cols-[1fr_420px] items-start gap-16 px-[var(--sf-site-gutter,40px)] pt-10 pb-[100px] max-view-desktop:grid-cols-1 max-view-desktop:gap-10 max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))] max-view-desktop:pt-8 max-view-desktop:pb-20",children:[r("div",{children:[r(M,{locked:y,children:[e(ue,{}),e(ge,{}),e(he,{})]}),e(M,{locked:m,children:e(xe,{})})]}),e(fe,{})]}),e("footer",{className:"flex flex-wrap items-center justify-between gap-4 border-t border-line px-[var(--sf-site-gutter,40px)] py-6 font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))]",children:e("span",{children:ce({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function we({payment:t,checkout:n,holdRenewed:o,onPaid:m,onProcessing:y,onRenew:p,onBack:s}){const{formatMoney:g}=E(),d=e("span",{className:"text-fg",children:g(Number(t.amount),t.currency)}),f=Y(()=>oe(t.publishableKey),[t.publishableKey]),c=Y(()=>J(),[]),u=X(n.expiresAt??"",ee()??"");return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between 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:de(n)}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:n.orderNumber?r(x,{children:["Your order is placed. Pay ",d," by card to confirm it now."]}):o?r(x,{children:["Your hold ran out, so your items are held again",u?` until ${u}`:"",". Enter your card again, then pay ",d,"."]}):r(x,{children:["Your items are held",u?` until ${u}`:"",". Pay ",d," by card to place your order."]})}),e(re,{stripe:f,options:{clientSecret:t.clientSecret,appearance:c},children:e(ve,{payment:t,checkout:n,onPaid:m,onProcessing:y,onRenew:p,onBack:s})},t.clientSecret)]})]})})}const Pe=5;function ve({payment:t,checkout:n,onPaid:o,onProcessing:m,onRenew:y,onBack:p}){const{formatMoney:s}=E(),g=ie(),d=ae(),[f,c]=C(!1),[u,h]=C(null),k=j(!1);async function N(){try{return(await g.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function l(i){let a=i;for(let P=0;a==="processing"&&P<Pe;P+=1)await new Promise(v=>setTimeout(v,1e3)),a=await N()??a;if(a==="succeeded"){o();return}if(a==="processing"){m();return}h("Payment did not complete. Please try again."),c(!1)}async function b(){if(!g||!d||f)return;c(!0),h(null),k.current=!0;const i=await g.confirmPayment({elements:d,redirect:"if_required"}).catch(()=>null);if(!i){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}h(a===void 0?T:"Payment failed. Please try again."),c(!1);return}if(i.error){if(!n.orderNumber&&i.error.code==="payment_intent_unexpected_state"){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}if(a===void 0){h(T),c(!1);return}await y(a==="canceled"),c(!1);return}h(i.error.message??"Payment failed. Please try again."),c(!1);return}await l(i.paymentIntent?.status)}async function S(){if(f)return;if(!k.current){p();return}c(!0),h(null);const i=await N();if(i==="succeeded"||i==="processing"){await l(i);return}if(c(!1),i===void 0){h(T);return}p()}return r("div",{className:"flex flex-col gap-4",children:[e(ne,{}),u&&e(_,{role:"alert",children:u}),e("button",{type:"button",onClick:b,disabled:!g||!d||f,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!g||!d||f?"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?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",s(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),!n.orderNumber&&!f&&r("button",{type:"button",onClick:S,className:"inline-flex items-center gap-3 self-start font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{children:"Back to checkout"})]})]})}const B="paypal-sdk-js";let q=null;function Ce(t,n){const o=`${t}|${n}`;if(q?.key===o)return q.promise;const m=new Promise((y,p)=>{document.getElementById(B)?.remove();const s=document.createElement("script");s.id=B;const g=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});s.src=`https://www.paypal.com/sdk/js?${g}`,s.onload=()=>{const d=window.paypal;d?y(d):p(new Error("PayPal SDK loaded without its namespace"))},s.onerror=()=>p(new Error("PayPal SDK failed to load")),document.head.appendChild(s)});return q={key:o,promise:m},m}function Se({confirmation:t,clientId:n,idemKey:o,onPaid:m,onSkip:y}){const{formatMoney:p}=E(),s=j(null),[g,d]=C(!1),[f,c]=C(null),u=j(m);return u.current=m,D(()=>{let h=!1,k=null;return Ce(n,t.currency).then(N=>{if(!(h||!s.current))return k=N.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await I.createPaypalOrder({idempotencyKey:o})).paypalOrderId,onApprove:async l=>{try{if((await I.capturePaypalOrder({idempotencyKey:o,paypalOrderId:l.orderID})).status==="paid"){u.current();return}c("PayPal did not complete the payment. Please try again.")}catch(b){c(b instanceof L?b.message:"PayPal payment failed. Please try again.")}},onError:()=>{c("PayPal could not process the payment. Please try again.")}}),k.render(s.current).then(()=>{h||d(!0)})}).catch(()=>{h||c("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{h=!0,k?.close?.()}},[n,t.currency,o]),e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between 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.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:p(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!g&&!f&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:s}),f&&e(_,{role:"alert",children:f}),e("button",{type:"button",onClick:y,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}const F="square-web-sdk";let O=null;const je=["sandbox","production"];function Ee(t){const n=te(je,"production",t);if(O?.key===n)return O.promise;const o=new Promise((m,y)=>{document.getElementById(F)?.remove();const p=document.createElement("script");p.id=F,p.src=n==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",p.onload=()=>{const s=window.Square;s?m(s):y(new Error("Square SDK loaded without its namespace"))},p.onerror=()=>y(new Error("Square SDK failed to load")),document.head.appendChild(p)});return O={key:n,promise:o},o}function Re({confirmation:t,applicationId:n,locationId:o,environment:m,idemKey:y,onPaid:p,onSkip:s}){const{formatMoney:g}=E(),d=j(null),f=j(null),c=j(null),[u,h]=C(!1),[k,N]=C(!1),[l,b]=C(null);D(()=>{let i=!1,a=null;return Ee(m).then(async P=>{if(i||!d.current)return;const v=P.payments(n,o);c.current=v,a=await v.card(),await a.attach(d.current),f.current=a,i||h(!0)}).catch(()=>{i||b("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{i=!0,a?.destroy?.()}},[n,o,m]);async function S(){const i=f.current;if(!(!i||k)){N(!0),b(null);try{const a=await i.tokenize();if(a.status!=="OK"||!a.token){b(a.errors?.[0]?.message??"Please check the card details and try again."),N(!1);return}let P;try{P=(await c.current?.verifyBuyer?.(a.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await I.chargeSquare({idempotencyKey:y,sourceId:a.token,...P?{verificationToken:P}:{}})).status==="paid"){p();return}b("Square did not complete the payment. Please try again.")}catch(a){b(a instanceof L?a.message:"Square payment failed. Please try again.")}N(!1)}}return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between 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.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:g(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!u&&!l&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form…"}),e("div",{ref:d}),l&&e(_,{role:"alert",children:l}),e("button",{type:"button",onClick:S,disabled:!u||k,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!u||k?"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:k?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",g(Number(t.grandTotal),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:s,disabled:k,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}export{ke as PayFirstResultView,ye as default};
|
|
1
|
+
"use client";import{jsx as e,jsxs as r,Fragment as x}from"react/jsx-runtime";import R from"next/link";import{useEffect as D,useMemo as Y,useRef as j,useState as C}from"react";import{holdTime as J}from"../../lib/checkout/hold-time.js";import{stripeAppearance as ee}from"../../lib/checkout/stripe-appearance.js";import{userZone as te,parseOption as re}from"efficient-shell/format";import{Elements as ne,PaymentElement as ae,useElements as ie,useStripe as oe}from"@stripe/react-stripe-js";import{loadStripe as ce}from"@stripe/stripe-js";import{useCurrency as E}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{resolveCopyright as se}from"../../lib/content/site.js";import{ApiError as L,products as I}from"../../lib/api/index.js";import le,{WORDMARK_FIT_FLOOR_PX as de}from"efficient-web-builder/render/components/Logo";import{NOT_CHECKED as T,orderReference as me}from"../../lib/checkout/pay-first.js";import{CheckoutStateProvider as pe,useCheckout as ue}from"./checkout-state.js";import{CheckoutContact as fe,CheckoutOrderSummary as xe,CheckoutPayment as ge,CheckoutShippingAddress as he,CheckoutShippingMethod as ye,FormLock as M,LeaveLink as z}from"./checkout-parts.js";function be(t){return e(pe,{...t,children:e(we,{})})}function ke({order:t,paid:n}){const{formatMoney:o}=E();if(!t.grandTotal||!t.currency)return null;const m=s=>o(Number(s),t.currency),y=Number(t.freightCharge??0),p=Number(t.discountAmount??0);return r("dl",{className:"grid w-full max-w-sm grid-cols-[1fr_auto] gap-x-6 gap-y-1 border-y border-line py-3 text-left text-sm",children:[(t.shippingMethod||y>0)&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Delivery",t.shippingMethod?` · ${t.shippingMethod}`:""]}),e("dd",{className:"text-right font-mono",children:m(t.freightCharge??"0")})]}),p>0&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Discount",t.couponCode?` · ${t.couponCode}`:""]}),r("dd",{className:"text-right font-mono",children:["−",m(t.discountAmount??"0")]})]}),e("dt",{className:"text-fg",children:n?"Total paid":"Order total"}),e("dd",{className:"text-right font-mono text-fg",children:m(t.grandTotal)})]})}function Ne({result:t,lostChangeNote:n=null}){const o=e("span",{className:"font-mono text-fg",children:t.checkoutNumber});return r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:t.kind==="refunded"||t.kind==="expired"?"Order not placed":t.kind==="processing"?"Payment processing":"Payment received"}),e("p",{className:"text-fg-dim",children:t.kind==="refunded"?r(x,{children:["An item sold out or an offer ended while you paid for checkout ",o,". Your payment goes back to your card."]}):t.kind==="expired"?r(x,{children:["The hold on checkout ",o," ran out before your payment arrived. Your payment goes back to your card."]}):t.kind==="processing"?r(x,{children:["Your payment for checkout ",o," is being processed. When it goes through, we will email your order confirmation."]}):r(x,{children:["Thank you — your payment",t.checkoutNumber?r(x,{children:[" for checkout ",o]}):null," has gone through. We will email you the order number shortly."]})}),n&&t.kind!=="refunded"&&t.kind!=="expired"&&e("p",{className:"text-sm text-fg-dim",children:n}),e(R,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]})}function we(){const{site:t,logo:n,items:o,placing:m,formLocked:y,email:p,me:s,addressSaveNote:g,lostChangeNote:d,idemKey:f,confirmation:c,setConfirmation:u,payment:h,paypalStep:k,squareStep:N,pendingConf:l,paid:b,setPaid:S,payNote:i,afterpayConfirming:a,gocardlessConfirming:P,zipConfirming:v,klarnaConfirming:K,worldpayConfirming:$,cardConfirming:U,checkoutResult:A,confirmCardPayment:W,cardStillProcessing:H,renewCardPayment:G,holdRenewed:Q,leaveCardPayment:V,checkoutRootRef:Z,setCheckoutHeaderEl:X}=ue();return c?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:b?"Payment received":"Order received"}),r("p",{className:"text-fg-dim",children:[b?r(x,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:c.orderNumber})," has gone through."," "]}):r(x,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:c.orderNumber})," is being reviewed by our team."," "]}),s?r(x,{children:["Track it under"," ",e(R,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):e(x,{children:"We’ve emailed you a link to set a password and track it."})]}),e(ke,{order:c,paid:b}),d&&e("p",{className:"text-sm text-fg-dim",children:d}),i&&(i.warning?e("div",{className:"w-full max-w-sm text-left",children:e(_,{tone:"bad",role:"alert",children:i.text})}):e("p",{className:"text-sm text-fg-dim",children:i.text})),g&&e("p",{className:"text-sm text-fg-dim",children:g}),!s&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(R,{href:`/track?order=${encodeURIComponent(c.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(R,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]}):A?e(Ne,{result:A,lostChangeNote:d}):U?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Placing your order — one moment."})]}):a?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay — one moment."})]}):P?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Setting up your direct debit…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Confirming with GoCardless — one moment."})]}):v?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip — one moment."})]}):K?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna — one moment."})]}):$?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-xs uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Worldpay — one moment."})]}):h&&l?e(Pe,{payment:h,checkout:l,holdRenewed:Q,onPaid:W,onProcessing:H,onRenew:G,onBack:V}):k&&l?e(je,{confirmation:l,clientId:t.paypalClientId??"",idemKey:f,onPaid:()=>{S(!0),u(l)},onSkip:()=>u(l)}):N&&l?e(_e,{confirmation:l,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:f,onPaid:()=>{S(!0),u(l)},onSkip:()=>u(l)}):r("div",{ref:Z,className:"bg-bg text-fg",children:[r("header",{ref:X,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 max-[640px]:grid-cols-[auto_minmax(0,1fr)_auto] max-[640px]:gap-3 border-b border-line px-[var(--sf-site-gutter,40px)] py-6 backdrop-blur-md max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))] max-[640px]:py-4",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[r(z,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[14px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),e("div",{className:"flex min-w-0 justify-center max-[640px]:[container-type:inline-size]",children:e(z,{href:"/","aria-label":`${t.name} home`,className:"inline-flex max-w-full items-center justify-center max-[640px]:overflow-x-clip",children:[!0,!1].map(w=>e(le,{hideClass:w?"min-[641px]:hidden":"max-[640px]:hidden",variant:"header",scrolled:!0,src:n?.url??null,reverse:n?.reverse??!1,reversedSrc:n?.reversed??null,inkIsDark:n?.inkIsDark??null,size:n?.size??"medium",sizePx:n?.sizePx??null,sizeUnit:n?.sizeUnit??null,siteName:t.name,fitWordmarkToContainer:w,fitFloorPx:w?de:void 0},w?"phone":"wide"))})}),t.cardPayments?r("span",{className:"flex items-center justify-end gap-3 font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim",children:[e("span",{className:"text-green",children:"●"}),e("span",{className:"max-[640px]:hidden",children:"Encrypted ·"})," Stripe"]}):e("span",{})]}),r("section",{className:"mx-auto flex max-w-[var(--sf-site-width,1600px)] flex-wrap items-center justify-between gap-x-8 gap-y-3 border-b border-line bg-surface px-[var(--sf-site-gutter,40px)] py-4 font-mono text-[13px] font-medium uppercase tracking-[0.24em] text-fg max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))]",children:[e("span",{className:"inline-flex items-center bg-accent px-3 py-1 font-bold text-bg",children:"Checkout"}),e("nav",{"aria-label":"Checkout steps",className:"flex flex-wrap items-center gap-5",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(w=>r("span",{className:["relative flex items-center gap-2 transition-colors",w.state==="pending"?"text-fg-dim":"text-fg",w.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[e("span",{className:w.state==="done"?"text-accent font-bold":"",children:w.n}),e("span",{children:w.label})]},w.n))})]}),r("main",{className:"mx-auto grid max-w-[var(--sf-site-width,1600px)] grid-cols-[1fr_420px] items-start gap-16 px-[var(--sf-site-gutter,40px)] pt-10 pb-[100px] max-view-desktop:grid-cols-1 max-view-desktop:gap-10 max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))] max-view-desktop:pt-8 max-view-desktop:pb-20",children:[r("div",{children:[r(M,{locked:y,children:[e(fe,{}),e(he,{}),e(ye,{})]}),e(M,{locked:m,children:e(ge,{})})]}),e(xe,{})]}),e("footer",{className:"flex flex-wrap items-center justify-between gap-4 border-t border-line px-[var(--sf-site-gutter,40px)] py-6 font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))]",children:e("span",{children:se({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function Pe({payment:t,checkout:n,holdRenewed:o,onPaid:m,onProcessing:y,onRenew:p,onBack:s}){const{formatMoney:g}=E(),d=e("span",{className:"text-fg",children:g(Number(t.amount),t.currency)}),f=Y(()=>ce(t.publishableKey),[t.publishableKey]),c=Y(()=>ee(),[]),u=J(n.expiresAt??"",te()??"");return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between 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:me(n)}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:n.orderNumber?r(x,{children:["Your order is placed. Pay ",d," by card to confirm it now."]}):o?r(x,{children:["Your hold ran out, so your items are held again",u?` until ${u}`:"",". Enter your card again, then pay ",d,"."]}):r(x,{children:["Your items are held",u?` until ${u}`:"",". Pay ",d," by card to place your order."]})}),e(ne,{stripe:f,options:{clientSecret:t.clientSecret,appearance:c},children:e(Ce,{payment:t,checkout:n,onPaid:m,onProcessing:y,onRenew:p,onBack:s})},t.clientSecret)]})]})})}const ve=5;function Ce({payment:t,checkout:n,onPaid:o,onProcessing:m,onRenew:y,onBack:p}){const{formatMoney:s}=E(),g=oe(),d=ie(),[f,c]=C(!1),[u,h]=C(null),k=j(!1);async function N(){try{return(await g.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function l(i){let a=i;for(let P=0;a==="processing"&&P<ve;P+=1)await new Promise(v=>setTimeout(v,1e3)),a=await N()??a;if(a==="succeeded"){o();return}if(a==="processing"){m();return}h("Payment did not complete. Please try again."),c(!1)}async function b(){if(!g||!d||f)return;c(!0),h(null),k.current=!0;const i=await g.confirmPayment({elements:d,redirect:"if_required"}).catch(()=>null);if(!i){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}h(a===void 0?T:"Payment failed. Please try again."),c(!1);return}if(i.error){if(!n.orderNumber&&i.error.code==="payment_intent_unexpected_state"){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}if(a===void 0){h(T),c(!1);return}await y(a==="canceled"),c(!1);return}h(i.error.message??"Payment failed. Please try again."),c(!1);return}await l(i.paymentIntent?.status)}async function S(){if(f)return;if(!k.current){p();return}c(!0),h(null);const i=await N();if(i==="succeeded"||i==="processing"){await l(i);return}if(c(!1),i===void 0){h(T);return}p()}return r("div",{className:"flex flex-col gap-4",children:[e(ae,{}),u&&e(_,{role:"alert",children:u}),e("button",{type:"button",onClick:b,disabled:!g||!d||f,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!g||!d||f?"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?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",s(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),!n.orderNumber&&!f&&r("button",{type:"button",onClick:S,className:"inline-flex items-center gap-3 self-start font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{children:"Back to checkout"})]})]})}const B="paypal-sdk-js";let q=null;function Se(t,n){const o=`${t}|${n}`;if(q?.key===o)return q.promise;const m=new Promise((y,p)=>{document.getElementById(B)?.remove();const s=document.createElement("script");s.id=B;const g=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});s.src=`https://www.paypal.com/sdk/js?${g}`,s.onload=()=>{const d=window.paypal;d?y(d):p(new Error("PayPal SDK loaded without its namespace"))},s.onerror=()=>p(new Error("PayPal SDK failed to load")),document.head.appendChild(s)});return q={key:o,promise:m},m}function je({confirmation:t,clientId:n,idemKey:o,onPaid:m,onSkip:y}){const{formatMoney:p}=E(),s=j(null),[g,d]=C(!1),[f,c]=C(null),u=j(m);return u.current=m,D(()=>{let h=!1,k=null;return Se(n,t.currency).then(N=>{if(!(h||!s.current))return k=N.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await I.createPaypalOrder({idempotencyKey:o})).paypalOrderId,onApprove:async l=>{try{if((await I.capturePaypalOrder({idempotencyKey:o,paypalOrderId:l.orderID})).status==="paid"){u.current();return}c("PayPal did not complete the payment. Please try again.")}catch(b){c(b instanceof L?b.message:"PayPal payment failed. Please try again.")}},onError:()=>{c("PayPal could not process the payment. Please try again.")}}),k.render(s.current).then(()=>{h||d(!0)})}).catch(()=>{h||c("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{h=!0,k?.close?.()}},[n,t.currency,o]),e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between 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.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:p(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!g&&!f&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:s}),f&&e(_,{role:"alert",children:f}),e("button",{type:"button",onClick:y,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}const F="square-web-sdk";let O=null;const Ee=["sandbox","production"];function Re(t){const n=re(Ee,"production",t);if(O?.key===n)return O.promise;const o=new Promise((m,y)=>{document.getElementById(F)?.remove();const p=document.createElement("script");p.id=F,p.src=n==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",p.onload=()=>{const s=window.Square;s?m(s):y(new Error("Square SDK loaded without its namespace"))},p.onerror=()=>y(new Error("Square SDK failed to load")),document.head.appendChild(p)});return O={key:n,promise:o},o}function _e({confirmation:t,applicationId:n,locationId:o,environment:m,idemKey:y,onPaid:p,onSkip:s}){const{formatMoney:g}=E(),d=j(null),f=j(null),c=j(null),[u,h]=C(!1),[k,N]=C(!1),[l,b]=C(null);D(()=>{let i=!1,a=null;return Re(m).then(async P=>{if(i||!d.current)return;const v=P.payments(n,o);c.current=v,a=await v.card(),await a.attach(d.current),f.current=a,i||h(!0)}).catch(()=>{i||b("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{i=!0,a?.destroy?.()}},[n,o,m]);async function S(){const i=f.current;if(!(!i||k)){N(!0),b(null);try{const a=await i.tokenize();if(a.status!=="OK"||!a.token){b(a.errors?.[0]?.message??"Please check the card details and try again."),N(!1);return}let P;try{P=(await c.current?.verifyBuyer?.(a.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await I.chargeSquare({idempotencyKey:y,sourceId:a.token,...P?{verificationToken:P}:{}})).status==="paid"){p();return}b("Square did not complete the payment. Please try again.")}catch(a){b(a instanceof L?a.message:"Square payment failed. Please try again.")}N(!1)}}return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between 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.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:g(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!u&&!l&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form…"}),e("div",{ref:d}),l&&e(_,{role:"alert",children:l}),e("button",{type:"button",onClick:S,disabled:!u||k,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!u||k?"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:k?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",g(Number(t.grandTotal),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:s,disabled:k,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}export{Ne as PayFirstResultView,be 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{couponSaving as oe,deliveryAfterCoupon as ce,shippingWords as se,TAX_PENDING as de}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as pe}from"../../lib/wheels/finish-defaults.js";import U from"../ThemedSelect.js";import x from"../WebFormField.js";import me from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as ue,placedOrderLockNote as he,SHIPPING_RETRY_NOTE as ge,useCheckout as w}from"./checkout-state.js";import{FIELD_INPUT_CLASS as f}from"../../lib/field-input.js";import{FIGURE_UPDATING as T}from"../../lib/wheels/price-display.js";function Ue(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:s,setLastName:d,company:m,setCompany:k,me:v,signInHref:u,checkoutSignOut:b,orderLocked:o,unpaidOrder:c}=w(),h=O();return a(L,{num:"N° 01",title:"Contact",children:[o&&c&&e(be,{orderNumber:c.orderNumber}),e(x,{label:"Email",htmlFor:h,hint:v?a(N,{children:["Signed in ·"," ",e("button",{type:"button",onClick:b,className:"underline transition-colors enabled:hover:text-accent",children:"Not you? Sign out"})]}):u?a(N,{children:["Have an account?"," ",e(B,{href:u,className:"underline transition-colors hover:text-accent",children:"Sign in"})]}):void 0,children:e("input",{id:h,type:"email",value:t,onChange:p=>i(p.target.value),placeholder:"you@example.com",readOnly:v!==null,className:f})}),a(q,{children:[e(x,{label:"First name",children:e("input",{type:"text",value:n,onChange:p=>l(p.target.value),className:f})}),e(x,{label:"Last name",children:e("input",{type:"text",value:s,onChange:p=>d(p.target.value),className:f})})]}),e(x,{label:"Company (optional)",children:e("input",{type:"text",value:m,onChange:p=>k(p.target.value),autoComplete:"organization",className:f})})]})}function Ye(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:s,setAddress2:d,city:m,setCity:k,postcode:v,setPostcode:u,phone:b,setPhone:o,country:c,setCountry:h,subdivision:p,setSubdivision:g,subdivisions:E,destination:P,postcodeLabel:S,subdivisionLabel:y,me:R,savedAddresses:D,selectedAddressId:F,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:F===r.id,onClick:()=>{$(r.id),Q(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(I,{active:F==="new",onClick:()=>$("new"),title:"New address",body:null,price:null})]}),e(x,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>l(r.target.value),className:f})}),e(x,{label:"Address line 2",children:e("input",{type:"text",value:s,onChange:r=>d(r.target.value),placeholder:"Apartment, unit, garage bay…",className:f})}),a(q,{cols:"three",children:[e(x,{label:"City",children:e("input",{type:"text",value:m,onChange:r=>k(r.target.value),className:f})}),e(x,{label:S,children:e("input",{type:"text",value:v,onChange:r=>u(r.target.value),className:f})}),e(x,{label:"Country",separate:!0,htmlFor:M,children:e(U,{id:M,value:c,onChange:r=>h(r.target.value),className:f+" pr-10",style:Y,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(x,{label:y,separate:!0,htmlFor:j,children:E.length>0?a(U,{id:j,value:p,onChange:r=>g(r.target.value),className:f+" 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=>g(r.target.value),className:f})})]}),e(x,{label:"Phone",children:e("input",{type:"tel",value:b,onChange:r=>o(r.target.value),className:f})}),!t&&R!==null&&F==="new"&&!V&&a(N,{children:[e(ye,{checked:H,onChange:G,label:"Save this address to my account"}),H&&e(x,{label:"Address label",children:e("input",{type:"text",value:W,onChange:r=>K(r.target.value),placeholder:"Home",className:f})})]})]})}function qe(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:s,pickupLocation:d,formatMoney:m,city:k,destination:v,courierUnavailable:u,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,h=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?[h,c.openingHours,c.readyIn,c.instructions,o.description].filter(Boolean).join(" · "):o.description||null,price:t.freeShipping||o.amount===0?A:t.deliveryDiscountPercent>0?a(N,{children:[e("s",{className:"text-fg-dim",children:m(o.amount,t.currency)})," ",m(ce(o.amount,t.deliveryDiscountPercent),t.currency)]}):m(o.amount,t.currency),tag:o.tag||void 0},o.id)}),u?a("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[ge," ",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 ze(){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:ue}),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 Ge(){const{site:t,items:i,totals:n,coupon:l,formatMoney:s,payChoice:d,placing:m,email:k,orderError:v,payment:u,noPaymentMethod:b,unpaidOrder:o,formLocked:c,restoredPrices:h,quoteFailed:p,retryQuote:g,placeOrder:E}=w(),P=h==="waiting",S=h==="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(y=>e(Ne,{slug:y.slug,name:y.name,qty:y.qty,config:y.config,configSummary:ve(y.config),price:S||P?null:J(y,n.currency)??0,currency:n.currency},y.id))}),e(xe,{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:P?T:s(S?n.serverSubtotal??0:n.subtotal,n.currency)}),(n.discount>0||n.deliverySaving>0)&&l?.valid&&e(C,{label:`Coupon · ${l.code}`,value:e("span",{className:"font-semibold text-green",children:oe(n,y=>s(y,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}):se(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:de}):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:g,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}),v&&e(_,{role:"alert",children:v}),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:m||!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]",m||!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:m?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 fe=" [&:disabled_:disabled]:cursor-not-allowed! [&:disabled_:disabled]:opacity-70! [&_input[readonly]]:cursor-not-allowed [&_input[readonly]]:opacity-70";function xe({locked:t,className:i="",children:n}){return e("fieldset",{disabled:t,className:"m-0 min-w-0 border-0 p-0 "+i+fe,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 be({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:he(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 ye({checked:t,onChange:i,label:n,sub:l}){return a("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[e("button",{type:"button",onClick:()=>i(!t),"aria-pressed":t,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",t?"border-accent":"border-line"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:t&&e("span",{className:"text-[13px] text-accent",children:"✓"})}),a("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,l&&e("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:l})]})]})}function Ne({slug:t,name:i,qty:n,config:l,configSummary:s,price:d,currency:m}){const{catalog:k}=ee(),{formatMoney:v}=te(),u=k.find(g=>g.slug===t),b=u?.spokes??5,o=u?.mesh??!1,c=l.find(g=>g.gold)?.label,h=u?.finishes.find(g=>g.name===c&&g.src)??u?.finishes.find(g=>g.src),p=u?.finishes[0]?.color??pe;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:h?.src?e(X,{src:h.src,alt:`${i.lead}${i.accent} — ${h.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(me,{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:v(d,m)})]})}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 ve(t){return t.map(i=>i.label).join(" · ")}export{Ue as CheckoutContact,Ge as CheckoutOrderSummary,ze as CheckoutPayment,Ye as CheckoutShippingAddress,qe as CheckoutShippingMethod,xe as FormLock,B 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{couponSaving as oe,deliveryAfterCoupon as ce,shippingWords as se,TAX_PENDING as de}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as pe}from"../../lib/wheels/finish-defaults.js";import M from"../ThemedSelect.js";import x from"../WebFormField.js";import me from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as ue,placedOrderLockNote as he,SHIPPING_RETRY_NOTE as ge,useCheckout as w}from"./checkout-state.js";import{FIELD_INPUT_CLASS as f}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:m,setCompany:k,me:v,signInHref:u,checkoutSignOut:b,orderLocked:o,unpaidOrder:c}=w(),h=O();return a(L,{num:"N° 01",title:"Contact",children:[o&&c&&e(be,{orderNumber:c.orderNumber}),e(x,{label:"Email",htmlFor:h,hint:v?a(N,{children:["Signed in ·"," ",e("button",{type:"button",onClick:b,className:"underline transition-colors enabled:hover:text-accent",children:"Not you? Sign out"})]}):u?a(N,{children:["Have an account?"," ",e(B,{href:u,className:"underline transition-colors hover:text-accent",children:"Sign in"})]}):void 0,children:e("input",{id:h,type:"email",value:t,onChange:p=>i(p.target.value),placeholder:"you@example.com",readOnly:v!==null,className:f})}),a(q,{children:[e(x,{label:"First name",children:e("input",{type:"text",value:n,onChange:p=>l(p.target.value),className:f})}),e(x,{label:"Last name",children:e("input",{type:"text",value:s,onChange:p=>d(p.target.value),className:f})})]}),e(x,{label:"Company (optional)",children:e("input",{type:"text",value:m,onChange:p=>k(p.target.value),autoComplete:"organization",className:f})})]})}function Ue(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:s,setAddress2:d,city:m,setCity:k,postcode:v,setPostcode:u,phone:b,setPhone:o,country:c,setCountry:h,subdivision:p,setSubdivision:g,subdivisions:E,destination:P,postcodeLabel:S,subdivisionLabel:y,me:R,savedAddresses:D,selectedAddressId:F,setSelectedAddressId:Y,saveAddress:$,setSaveAddress:G,saveLabel:W,setSaveLabel:K,fillFromAddress:Q,orderLocked:V}=w(),H=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:F===r.id,onClick:()=>{Y(r.id),Q(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(I,{active:F==="new",onClick:()=>Y("new"),title:"New address",body:null,price:null})]}),e(x,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>l(r.target.value),className:f})}),e(x,{label:"Address line 2",children:e("input",{type:"text",value:s,onChange:r=>d(r.target.value),placeholder:"Apartment, unit, garage bay…",className:f})}),a(q,{cols:"three",children:[e(x,{label:"City",children:e("input",{type:"text",value:m,onChange:r=>k(r.target.value),className:f})}),e(x,{label:S,children:e("input",{type:"text",value:v,onChange:r=>u(r.target.value),className:f})}),e(x,{label:"Country",separate:!0,htmlFor:H,children:e(M,{id:H,value:c,onChange:r=>h(r.target.value),className:f+" pr-10",style:U,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(x,{label:y,separate:!0,htmlFor:j,children:E.length>0?a(M,{id:j,value:p,onChange:r=>g(r.target.value),className:f+" pr-10",style:U,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=>g(r.target.value),className:f})})]}),e(x,{label:"Phone",children:e("input",{type:"tel",value:b,onChange:r=>o(r.target.value),className:f})}),!t&&R!==null&&F==="new"&&!V&&a(N,{children:[e(ye,{checked:$,onChange:G,label:"Save this address to my account"}),$&&e(x,{label:"Address label",children:e("input",{type:"text",value:W,onChange:r=>K(r.target.value),placeholder:"Home",className:f})})]})]})}function qe(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:s,pickupLocation:d,formatMoney:m,city:k,destination:v,courierUnavailable:u,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,h=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?[h,c.openingHours,c.readyIn,c.instructions,o.description].filter(Boolean).join(" · "):o.description||null,price:t.freeShipping||o.amount===0?A:t.deliveryDiscountPercent>0?a(N,{children:[e("s",{className:"text-fg-dim",children:m(o.amount,t.currency)})," ",m(ce(o.amount,t.deliveryDiscountPercent),t.currency)]}):m(o.amount,t.currency),tag:o.tag||void 0},o.id)}),u?a("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[ge," ",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 ze(){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:ue}),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==="worldpay"?e("p",{className:"font-mono text-xs uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter your card on Worldpay’s secure page, then be 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 Ge(){const{site:t,items:i,totals:n,coupon:l,formatMoney:s,payChoice:d,placing:m,email:k,orderError:v,payment:u,noPaymentMethod:b,unpaidOrder:o,formLocked:c,restoredPrices:h,quoteFailed:p,retryQuote:g,placeOrder:E}=w(),P=h==="waiting",S=h==="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(y=>e(Ne,{slug:y.slug,name:y.name,qty:y.qty,config:y.config,configSummary:ve(y.config),price:S||P?null:J(y,n.currency)??0,currency:n.currency},y.id))}),e(xe,{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:P?T:s(S?n.serverSubtotal??0:n.subtotal,n.currency)}),(n.discount>0||n.deliverySaving>0)&&l?.valid&&e(C,{label:`Coupon · ${l.code}`,value:e("span",{className:"font-semibold text-green",children:oe(n,y=>s(y,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}):se(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:de}):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:g,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}),v&&e(_,{role:"alert",children:v}),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:m||!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]",m||!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:m?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 fe=" [&:disabled_:disabled]:cursor-not-allowed! [&:disabled_:disabled]:opacity-70! [&_input[readonly]]:cursor-not-allowed [&_input[readonly]]:opacity-70";function xe({locked:t,className:i="",children:n}){return e("fieldset",{disabled:t,className:"m-0 min-w-0 border-0 p-0 "+i+fe,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 be({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:he(t)})]})})}const U={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 ye({checked:t,onChange:i,label:n,sub:l}){return a("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[e("button",{type:"button",onClick:()=>i(!t),"aria-pressed":t,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",t?"border-accent":"border-line"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:t&&e("span",{className:"text-[13px] text-accent",children:"✓"})}),a("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,l&&e("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:l})]})]})}function Ne({slug:t,name:i,qty:n,config:l,configSummary:s,price:d,currency:m}){const{catalog:k}=ee(),{formatMoney:v}=te(),u=k.find(g=>g.slug===t),b=u?.spokes??5,o=u?.mesh??!1,c=l.find(g=>g.gold)?.label,h=u?.finishes.find(g=>g.name===c&&g.src)??u?.finishes.find(g=>g.src),p=u?.finishes[0]?.color??pe;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:h?.src?e(X,{src:h.src,alt:`${i.lead}${i.accent} — ${h.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(me,{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:v(d,m)})]})}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 ve(t){return t.map(i=>i.label).join(" · ")}export{Me as CheckoutContact,Ge as CheckoutOrderSummary,ze as CheckoutPayment,Ue as CheckoutShippingAddress,qe as CheckoutShippingMethod,xe as FormLock,B as LeaveLink};
|
|
@@ -4,7 +4,7 @@ import type { OrderConfirmation, ShopAddress, ShopMe } from "../../lib/api/index
|
|
|
4
4
|
import { type LandingOrder } from "../../lib/checkout/wallet-return.js";
|
|
5
5
|
import { type PayFirstResult } from "../../lib/checkout/pay-first.js";
|
|
6
6
|
import type { LengthUnit } from "efficient-easel/screen/lib/content/length-units";
|
|
7
|
-
type PayKey = "card" | "paypal" | "afterpay" | "square" | "gocardless" | "zip" | "klarna" | "bank";
|
|
7
|
+
type PayKey = "card" | "paypal" | "afterpay" | "square" | "gocardless" | "zip" | "klarna" | "worldpay" | "bank";
|
|
8
8
|
interface PayOption {
|
|
9
9
|
key: PayKey;
|
|
10
10
|
title: React.ReactNode;
|
|
@@ -200,6 +200,7 @@ declare function useCheckoutState({ site, logo, signInHref, preview }: CheckoutP
|
|
|
200
200
|
gocardlessConfirming: boolean;
|
|
201
201
|
zipConfirming: boolean;
|
|
202
202
|
klarnaConfirming: boolean;
|
|
203
|
+
worldpayConfirming: boolean;
|
|
203
204
|
cardConfirming: boolean;
|
|
204
205
|
checkoutResult: PayFirstResult | null;
|
|
205
206
|
confirmCardPayment: (answer?: OrderConfirmation, held?: OrderConfirmation | null) => Promise<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
2
|
-
`);return k===-1?[
|
|
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};
|
|
1
|
+
"use client";import{jsx as O}from"react/jsx-runtime";import{createContext as gr,useContext as kr,useEffect as h,useMemo as un,useRef as y,useState as s}from"react";import{isOrderable as ln,useCart as Cr}from"../CartContext.js";import{useCurrency as wr}from"../CurrencyContext.js";import{getClickIds as Pr}from"../../lib/click-ids.js";import{adConsentForOrder as br}from"../../lib/consent/choice.js";import{trackBeginCheckout as Nr,trackPurchase as Sr}from"../../lib/google-tag.js";import{trackMetaPurchase as Ar}from"../../lib/meta-pixel.js";import{ApiError as Ue,api as he,products as C}from"../../lib/api/index.js";import{uuid as Be}from"../../lib/uuid.js";import{orderLinesForSets as vr}from"../../lib/commerce.js";import{canPersist as Or,safeSessionStorage as at}from"efficient-web-builder/format/lib/safe-storage";import{AFTERPAY_CONTEXT_KEY as Rr,AFTERPAY_RETURN as Er,GOCARDLESS_CONTEXT_KEY as Kr,GOCARDLESS_RETURN as Mr,KLARNA_CONTEXT_KEY as Lr,KLARNA_RETURN as xr,WORLDPAY_CONTEXT_KEY as Tr,WORLDPAY_RETURN as _r,ZIP_CONTEXT_KEY as Ir,ZIP_RETURN as Fr,runWalletReturn as ge}from"../../lib/checkout/wallet-return.js";import{matchSubdivision as qr}from"../../lib/checkout/match-subdivision.js";import{clearCheckoutMemory as $r,holdsPress as Ur,parkCheckoutMemory as Br,parkForm as Yr,parkOrder as Dr,parkRequest as dn,readCheckoutMemory as Hr,sameGoods as Gr,sendableRequest as Wr}from"../../lib/checkout/checkout-memory.js";import{checkoutGone as it,checkoutWaiting as pn,BANK_WAITING as zr,DROPPABLE_INTENT as Xr,NOT_CHECKED as ut,LOST_CHANGE as lt,PAY_FIRST_FLOW as dt,paysFirst as Jr,readIntentStatus as Zr,releaseHeldCheckout as fn,CHECKOUT_COMMITTED as jr,goodsShapeOf as Vr,refusedForGood as yn,settlePayFirst as Qr}from"../../lib/checkout/pay-first.js";import{couponCodeForOrder as mn,couponRefusedByOrder as eo}from"../../lib/cart/coupon-preview.js";function hn(r){const k=r.indexOf(`
|
|
2
|
+
`);return k===-1?[r,""]:[r.slice(0,k),r.slice(k+1)]}function gn(r,{canParkContext:k}={canParkContext:!0}){const g=r.paymentMethods,m=[];return g.includes("card")&&m.push({key:"card",title:"Card",body:null,price:O("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),g.includes("paypal")&&r.paypalClientId&&m.push({key:"paypal",title:"PayPal",body:null,price:O("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAYPAL · CARDS"})}),g.includes("afterpay")&&m.push({key:"afterpay",title:"Afterpay",body:null,price:O("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"4 × INTEREST-FREE"})}),g.includes("square")&&r.squareApplicationId&&r.squareLocationId&&m.push({key:"square",title:"Card (Square)",body:null,price:O("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),g.includes("gocardless")&&k&&m.push({key:"gocardless",title:"Bank Direct Debit",body:null,price:O("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY BY BANK"})}),g.includes("zip")&&m.push({key:"zip",title:"Zip",body:null,price:O("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY IN 4"})}),g.includes("klarna")&&k&&m.push({key:"klarna",title:"Klarna",body:null,price:O("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),g.includes("worldpay")&&m.push({key:"worldpay",title:"Visa / Mastercard / American Express",body:null,price:O("span",{className:"font-mono text-xs uppercase tracking-[0.2em] text-accent",children:"VIA WORLDPAY"})}),g.includes("bank")&&m.push({key:"bank",title:"Bank transfer",body:null,price:O("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),m}const Ao="This shop does not take payment online yet. Please contact the shop to order.";class Ye extends Error{}function kn(r,k){if(!r.orderNumber&&it(k))return k.message;const g=k instanceof Ue?` (${k.message})`:"";return r.orderNumber?`Your order ${r.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 ${r.checkoutNumber}, but the payment did not start${g}. Try the payment again — you will not be charged twice.`}const to=3e3,no=.005,Cn=new Set(["paypal","square","afterpay","gocardless","zip","klarna","worldpay"]);function wn(){const r=br();return{...r==="denied"?{}:Pr(),...r?{adConsent:r}:{}}}const R=r=>JSON.parse(r),ro={lastPress:null,keptCardKey:null,placedShape:null,placedRequest:null,unpaidOrder:null},oo={lastPress:r=>r&&{key:r.key,request:dn(r.request),lines:r.lines,goods:R(r.shape)[0],plainPressed:!!r.plainMethod,plainLines:r.plainLines,plainGoods:R(r.plainShape)[0]},keptCardKey:r=>r,placedShape:r=>r===null?null:R(r)[0],placedRequest:r=>r&&dn(r.body),unpaidOrder:r=>r&&Dr(r)};function Pn(r,k){const g={};for(const m of Object.keys(r))g[m]=r[m](k[m]);return g}const vo="Shipping cannot be calculated right now. Please try again.";function Oo(r){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 ${r}.`}function so({site:r,logo:k,signInHref:g=null,preview:m=!1}){const{items:f,totals:b,coupon:M,refuseCoupon:Nn,deliveryOptions:pt,shippingMethodId:Q,setShippingMethodId:ft,setQuoteDestination:ke,courier:Sn,requote:Ce,identify:yt,clearCapturedCart:we,replaceItems:De,removeCoupon:mt,applyCoupon:An}=Cr(),vn=pt.find(e=>e.id===Q)?.pickupLocation??null,{country:ht,countries:ee,activeCountry:gt,formatMoney:On}=wr(),[P,Pe]=s(()=>gn(r)[0]?.key??null),[kt,Rn]=s(!0);h(()=>{Rn(Or(at))},[]);const[L,He]=s(!1),[F,be]=s(""),[x,Ne]=s(""),[H,Se]=s(""),[Ae,Ge]=s(""),[te,ne]=s(""),[ve,re]=s(""),[q,oe]=s(""),[T,se]=s(""),[G,ce]=s(""),[p,ae]=s(()=>ht||ee[0]?.code||""),[E,Oe]=s(""),[ie,Ct]=s([]),[We,ze]=s(null),[Re,W]=s(null),wt=un(()=>ee.find(e=>e.code===p)??gt,[ee,p,gt]),En=wt?.postalLabel||"Postal Code",Kn=ie[0]?.divisionType||"State / Province";h(()=>{if(!p){Ct([]),ze(p);return}ze(null);let e=!1;return C.listCountrySubdivisions(p).then(t=>{e||(Ct(t),ze(p),Oe(""))}),()=>{e=!0}},[p]);const Pt=te.trim()!==""&&q.trim()!==""&&T.trim()!==""&&We===p&&(ie.length===0||E!=="")?T.trim():"";h(()=>{ke(p?{country:p,subdivision:E,postcode:Pt}:null)},[p,E,Pt,ke]),h(()=>()=>ke(null),[ke]);const Mn=Sn?.status==="unavailable",Ln=Ce,[ue,bt]=s(null),[xn,Nt]=s([]),[Xe,Ee]=s("new"),[St,At]=s(!1),[Je,Tn]=s("Home"),[_n,vt]=s(null),[In,Ze]=s(null),[$,Ke]=s(()=>Be()),Ot=y(null),[je,z]=s(null),[Fn,S]=s(null),[Rt,Me]=s(null),[Et,qn]=s(!1),[Kt,$n]=s(!1),[_,X]=s(null),[Un,Le]=s(!1),[w,A]=s(null),Mt=!!w?.orderNumber,Bn=Mt||L,[Yn,Dn]=s(null),[Hn,Gn]=s(!1),[Wn,zn]=s(!1),[Xn,Jn]=s(!1),[Zn,jn]=s(!1),[Vn,Qn]=s(!1),[Lt,er]=s(!1),[tr,Ve]=s(!1),[le,xt]=s(null),a=y({...ro});a.current.unpaidOrder=w;const Qe=y(!1),U=y(f),Tt=!!(je||le&&le.kind!=="processing"||Lt||Et||Kt||Rt&&_?.orderNumber);h(()=>{Tt&&(De([]),mt())},[Tt,De,mt]);const _t=y(!1);h(()=>{m||_t.current||!f.some(ln)||(_t.current=!0,Nr({lines:f,currency:b.currency,value:b.subtotal-b.discount,coupon:M?.valid?M.code:void 0}))},[f,b,M,m]),h(()=>{yt(F,x.trim()||void 0)},[F,x,yt]);const It=y(null),[xe,nr]=s(null);h(()=>{const e=It.current;if(!xe||!e)return;const t=()=>e.style.setProperty("--sf-checkout-header-h",`${xe.offsetHeight}px`);t();const o=new ResizeObserver(t);return o.observe(xe),()=>o.disconnect()},[xe]),h(()=>{const e=o=>({setConfirming:o,land:z,markPaid:()=>Le(!0),note:(c,n)=>Dn({text:c,warning:n}),fail:S,clearCart:we,lostChange:()=>Ze(lt)}),t={search:window.location.search,storage:at,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};ge(Er,{...t,capture:C.captureAfterpayPayment,page:e(Gn)}),ge(Fr,{...t,capture:C.captureZipPayment,page:e(Jn)}),ge(Mr,{...t,capture:C.completeGocardlessPayment,page:e(zn)}),ge(xr,{...t,capture:C.captureKlarnaPayment,page:e(jn)}),ge(_r,{...t,capture:C.confirmWorldpayPayment,page:e(Qn)})},[]);function Ft(e){const[t,o]=hn(e.address);ne(t),re(o),oe(e.city),se(e.zip_code),e.country&&ae(e.country),e.phone&&ce(e.phone),W({country:e.country||null,state:e.state??""})}h(()=>{if(Re){if((Re.country||p)!==p){W(null);return}We===p&&(Oe(qr(p,Re.state,ie)),W(null))}},[Re,p,We,ie]),h(()=>{let e=!1;return(async()=>{try{const[t,o,c]=await Promise.all([he.me(),he.myProfile().catch(()=>null),he.myAddresses().catch(()=>[])]);if(e)return;bt(t);const n=c.filter(d=>d.is_active);Nt(n),be(t.email);const i=(o?.contact_name??"").split(/\s+/);Ne(t.first_name||i[0]||""),Se(t.last_name||i.slice(1).join(" "));const l=t.phone||o?.phone;l&&ce(l);const u=n.find(d=>d.id===t.default_delivery_location)??n[0];if(u)Ee(u.id),Ft(u);else if(o){const[d,V]=hn(o.address??"");ne(d),re(V),oe(o.city??""),se(o.zip_code??""),o.country&&ae(o.country),W({country:o.country||null,state:o.state??""})}$e.current&&Ht($e.current,!1)}catch{}})(),()=>{e=!0}},[]);function rr(){he.logout(),pe.current=!0,$e.current=null,qe.current=null,fe(),bt(null),Nt([]),Ee("new"),At(!1),be(""),Ne(""),Se(""),Ge(""),ne(""),re(""),oe(""),se(""),ce(""),ae(ht||ee[0]?.code||""),Oe(""),W(null)}const J=un(()=>gn(r,{canParkContext:kt}),[r,kt]);h(()=>{J.some(e=>e.key===P)||Pe(J[0]?.key??null)},[J,P]);const or=J.length===0,Te=ve.trim()?`${te}
|
|
3
|
+
${ve.trim()}`:te,sr=Vr({email:F,firstName:x,lastName:H,company:Ae.trim(),phone:G,address:Te,city:q,subdivision:E,postcode:T,country:p,lines:f.map(e=>[e.id,e.qty]),shippingMethodId:Q,couponCode:mn(M),currency:b.currency,shopperId:ue?.id??null}),N=JSON.stringify([sr,P]),et=y(null),_e=y(!1),I=y(!1),Z=y(null),Ie=y(!1),v=y(N);v.current=N;const qt=y(L);qt.current=L;const Fe=y(null);h(()=>{const e=()=>{const t=Fe.current;t&&(Fe.current=null,A(t),He(!1))};return window.addEventListener("pageshow",e),()=>window.removeEventListener("pageshow",e)},[]);function de(e,t,o,c){const n={idempotencyKey:t,confirmation:o};Zt()&&(n.lostChange=!0),at.setItem(e,JSON.stringify(n)),window.location.assign(c),Fe.current=o}async function $t(e){He(!0);try{await e()}finally{Fe.current||He(!1)}}const Ut=y(!1),Bt=!!(je||le&&le.kind!=="processing");h(()=>{Bt&&(Ut.current=!0,fe())},[Bt]);const qe=y(null),pe=y(!1),tt=y(null);function fe(){tt.current=null,$r()}const $e=y(null),[j,cr]=s(!1);function nt(e){if(Ut.current||m||pe.current)return;const t={key:e,authed:Qe.current,parkedAt:tt.current??=Date.now(),press:Pn(oo,a.current),lines:f.length>0?f:U.current,form:Yr({email:F,firstName:x,lastName:H,company:Ae,address1:te,address2:ve,city:q,postcode:T,phone:G,country:p,subdivision:E,selectedAddressId:Xe,shippingMethodId:Q,couponCode:M?.valid?M.code:null})};Ur(t.press)?Br(t):fe()}const Yt=y(P);Yt.current=P;function rt(e){return{...Wr(e),...wn(),...e.payFirst?{checkoutFlow:dt}:{}}}function ar(e,t){let o=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 o??n()},set method(i){o=i},get plainMethod(){return c??n()},set plainMethod(i){c=i},plainLines:e.plainLines,plainShape:JSON.stringify([e.plainGoods,null])}}const[ir,ur]=s(!1),Dt=ir?!b.quoted||b.serverSubtotal===null?"waiting":Math.abs(b.serverSubtotal-b.subtotal)<no?"same":"changed":null,ot=!w&&Dt==="waiting",lr=ot?{...b,repricing:!0}:b,st=ot&&b.quoteFailed;h(()=>{if(!st)return;const e=setInterval(Ce,to);return()=>clearInterval(e)},[st,Ce]);const dr=Ce;function Ht(e,t=!0){be(e.email),Ne(e.firstName),Se(e.lastName),Ge(e.company),ne(e.address1),re(e.address2),oe(e.city),se(e.postcode),ce(e.phone),e.country&&ae(e.country),W({country:e.country||null,state:e.subdivision}),Ee(e.selectedAddressId),e.shippingMethodId&&ft(e.shippingMethodId),t&&(qe.current=e.couponCode)}h(()=>{let e=m?null:Hr();const t=!!(e&&f.length>0);if(e&&t&&!Gr(e.lines,f)&&(fe(),e=null),e){const o=e.authed?C.createOrderAuthed:C.createOrder;Ke(e.key),tt.current=e.parkedAt,Qe.current=e.authed;const c={lastPress:n=>n&&ar(n,o),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:()=>o(i)}},unpaidOrder:n=>n};a.current=Pn(c,e.press),e.press.unpaidOrder&&A(e.press.unpaidOrder),e.lines.length>0&&!t&&(De(e.lines),U.current=e.lines,ur(!0)),e.form&&($e.current=e.form,Ht(e.form))}cr(!0)},[]),h(()=>{!j||f.length>0||a.current.unpaidOrder||L||(pe.current=!0,fe())},[j,f.length]),h(()=>{const e=qe.current;!j||!e||f.length===0||(qe.current=null,An(e,F||void 0))},[j,f.length]),h(()=>{!j||L||nt($)},[j,L,$,w]);const B=y(null);h(()=>{qt.current||(N!==B.current&&(B.current=null),!(!I.current||!w||w.orderNumber)&&(N===a.current.placedShape||N===B.current||$t(()=>Gt(w))))},[N,w]);async function Gt(e){if(Ie.current)return null;Ie.current=!0;try{const t=Z.current?await Zr(Z.current):"none";if(t==="succeeded"||t==="processing")return I.current=!1,A(null),K("card"),t==="succeeded"?await Y(void 0,e):tn(e),null;if(t===void 0||!Xr.has(t))return B.current=v.current,A(e),S(t==="requires_action"?zr:ut),null;const o=await fn($);if(o==="committed")return I.current=!1,A(null),K("card"),await Y(void 0,e),null;if(o!=="released")return B.current=v.current,A(e),S(ut),null;I.current=!1,Z.current=null,B.current=null,S(null),A(null);const c=Be();return Ke(c),c}finally{Ie.current=!1}}async function pr(){m||L||Ie.current||await $t(fr)}async function fr(){if(w){if((I.current?N!==a.current.placedShape:ye())&&!w.orderNumber){const c=await Gt(w);c&&v.current===N&&await Wt(c);return}S(null),_e.current=!1,await ct();const t=R(v.current)[1],o=w.orderNumber?t:"card";if(o&&Cn.has(o)&&ye()&&R(v.current)[0]!==et.current){zt(w);return}K(o),o!==P&&Pe(o),await nn(w,o,!w.orderNumber);return}await Wt($)}async function Wt(e){if(f.length===0||b.repricing||ot||!P||!J.some(l=>l.key===P))return;const t=f.filter(ln).flatMap(l=>vr(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 o,c=e,n=P,i=!1;try{const l=ue?C.createOrderAuthed:C.createOrder,u={customer:{email:F,name:`${x} ${H}`.trim(),phone:G.trim()||void 0,companyName:Ae.trim()||void 0,address:Te,city:q,state:E||void 0,zipCode:T,country:p},items:t,currency:b.currency,idempotencyKey:e,shippingMethodId:Q??void 0,couponCode:mn(M),...wn(),...Jr(P)?{checkoutFlow:dt}:{}};a.current.placedRequest={body:u,send:()=>l(u)},Qe.current=!!ue,pe.current=!1,Ze(null),et.current=null,_e.current=!1,Z.current=null,I.current=!1,B.current=null,a.current.placedShape=N,U.current=f;const d=a.current.lastPress,V=d?.key===u.idempotencyKey&&(d.shape!==N&&(!!u.checkoutFlow||!!d.method||!!d.plainMethod)||!!u.checkoutFlow&&!!d.plainMethod);V&&(a.current.keptCardKey=u.idempotencyKey);const sn=Vt(u,l),cn=V||!u.checkoutFlow&&a.current.keptCardKey===u.idempotencyKey,an=!sn&&!cn&&!u.checkoutFlow&&!!d&&!d.method;an&&(d.plainMethod=P,d.plainLines=f,d.plainShape=N,nt(u.idempotencyKey));const D=await(cn?Jt(u,l):l(u).then(me=>({answer:me,request:u})).catch(me=>(sn?Xt(me,u.idempotencyKey):an&&yn(me)&&(d.plainMethod=""),yr(me,u,l))));if(!D)return;o=D.answer,c=D.request.idempotencyKey,n=D.method??n,K(n),i=ye()||n!==R(v.current)[1],D.method&&D.method!==P&&Pe(D.method),o.orderNumber&&(Qt(o),we()),await ct()}catch(l){const u=eo(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 Ue?l.message:"Could not place the order. Please try again.");return}if(n&&Cn.has(n)&&(i||ye())){zt(o);return}await nn(o,n,!1,c)}function zt(e){et.current=R(v.current)[0],S(`${kn(e,null)} ${lt}`),A(e)}function Xt(e,t){yn(e)&&!pn(e)&&a.current.lastPress?.key===t&&(a.current.lastPress=null)}async function yr(e,t,o){if(it(e))return jt(t,o);if(!pn(e))throw e;return a.current.keptCardKey=t.idempotencyKey,Jt(t,o,!0)}async function Jt(e,t,o=!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(U.current=n?.lines??f,n?.method&&!o){a.current.keptCardKey=null,a.current.placedRequest={body:n.request,send:n.send};const V=await n.send().catch(()=>{throw new Ye});return a.current.placedShape=n.shape,{answer:V,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!==jr?(a.current.keptCardKey=null,n?.plainMethod&&(U.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),K("card"),await en("",d?async()=>d:()=>Promise.reject(new Error("The order request did not answer."))),await ct(),null)}function ye(){const e=a.current.placedShape;return e!==null&&R(e)[0]!==R(v.current)[0]}function K(e){e!==R(v.current)[1]&&(_e.current=!0),Ze(Zt()?lt:null)}function Zt(){return _e.current||ye()}async function jt(e,t){const o={...e,idempotencyKey:Be()};a.current.keptCardKey=null,Ke(o.idempotencyKey),a.current.placedRequest={body:o,send:()=>t(o)},Vt(o,t);try{return{answer:await t(o),request:o}}catch(c){throw Xt(c,o.idempotencyKey),c}}function Vt(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?"":P??"",plainMethod:"",plainLines:f,plainShape:N},pe.current=!1,nt(e.idempotencyKey),!0)}function Qt(e){Sr({confirmation:e,lines:U.current,adsSendTo:r.googleAdsId&&r.googleAdsConversionLabel?`${r.googleAdsId}/${r.googleAdsConversionLabel}`:null}),Ar({confirmation:e,lines:U.current})}async function Y(e,t=_){if(!t)return;const o=e?async()=>e:a.current.placedRequest?.send;if(t.orderNumber||!o){Le(!0),z(t);return}await en(t.checkoutNumber,o)}async function en(e,t){we(),await Qr({checkoutNumber:e,resend:t,page:{setConfirming:er,land:z,markPaid:()=>Le(!0),track:Qt,unplaced:xt}})}function tn(e=_){if(e){if(e.orderNumber){z(e);return}we(),xt({kind:"processing",checkoutNumber:e.checkoutNumber})}}async function ct(){const e=JSON.stringify([Je.trim(),x,H,G.trim(),Te,q,E,T,p]);if(!(!ue||!St||Xe!=="new"||Ot.current===e))try{await he.createAddress({label:Je.trim()||"Home",contact_name:`${x} ${H}`.trim(),phone:G.trim(),address:Te,city:q,zip_code:T,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=P,o=!1,c=$){A(null);try{if(t==="card"&&r.paymentMethods.includes("card")){const n=await C.createPaymentIntent({idempotencyKey:c});Z.current=n;let i=e;if(o){const l=await a.current.placedRequest?.send().catch(()=>null);if(l?.orderNumber){K("card"),await Y(l,e);return}i=rn(e,l)??{...e,expiresAt:null}}K("card"),X(i),Ve(!1),Me(n)}else if(t==="paypal"&&r.paymentMethods.includes("paypal"))X(e),qn(!0);else if(t==="afterpay"&&r.paymentMethods.includes("afterpay")){const n=window.location.origin,i=await C.createAfterpayCheckout({idempotencyKey:c,confirmUrl:`${n}/checkout?afterpay=confirm`,cancelUrl:`${n}/checkout?afterpay=cancel`});de(Rr,c,e,i.redirectCheckoutUrl);return}else if(t==="square"&&r.paymentMethods.includes("square"))X(e),$n(!0);else if(t==="gocardless"&&r.paymentMethods.includes("gocardless")){const n=window.location.origin,i=await C.createGocardlessBillingRequest({idempotencyKey:c,confirmUrl:`${n}/checkout?gocardless=confirm`,cancelUrl:`${n}/checkout?gocardless=cancel`});de(Kr,c,e,i.authorisationUrl);return}else if(t==="zip"&&r.paymentMethods.includes("zip")){const n=window.location.origin,i=await C.createZipCheckout({idempotencyKey:c,redirectUrl:`${n}/checkout?zip=return`});de(Ir,c,e,i.redirectUrl);return}else if(t==="klarna"&&r.paymentMethods.includes("klarna")){const n=window.location.origin,i=await C.createKlarnaCheckout({idempotencyKey:c,confirmUrl:`${n}/checkout?klarna=confirm`,cancelUrl:`${n}/checkout?klarna=cancel`});de(Lr,c,e,i.redirectUrl);return}else if(t==="worldpay"&&r.paymentMethods.includes("worldpay")){const n=window.location.origin,i=await C.createWorldpayCheckout({idempotencyKey:c,successUrl:`${n}/checkout?worldpay=return`,cancelUrl:`${n}/checkout?worldpay=cancel`});de(Tr,c,e,i.redirectUrl);return}else K(t),z(e)}catch(n){if((o||t==="card")&&n instanceof Ue&&n.status===409){K(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,Ke(Be())):A(e)}async function mr(e){if(!_)return;const t=_;try{const o=await C.createPaymentIntent({idempotencyKey:$}),c=await a.current.placedRequest?.send().catch(()=>null);if(c?.orderNumber){await Y(c);return}const n=rn(t,c);X(n??{...t,expiresAt:null}),Ve(e&&n!==null),Z.current=o,Me(o)}catch(o){if(o instanceof Ue&&o.status===409){await Y();return}Me(null),X(null),on(t,o)}}function hr(){_&&(I.current=!0,A(_),Me(null),X(null),Ve(!1))}return{site:r,logo:k,signInHref:g,items:f,totals:lr,coupon:M,deliveryOptions:pt,courierUnavailable:Mn,retryCourier:Ln,shippingMethodId:Q,setShippingMethodId:ft,pickupLocation:vn,servedCountries:ee,formatMoney:On,payChoice:P,setPayChoice:Pe,placing:L,email:F,setEmail:be,firstName:x,setFirstName:Ne,lastName:H,setLastName:Se,company:Ae,setCompany:Ge,address1:te,setAddress1:ne,address2:ve,setAddress2:re,city:q,setCity:oe,postcode:T,setPostcode:se,phone:G,setPhone:ce,country:p,setCountry:ae,subdivision:E,setSubdivision:Oe,subdivisions:ie,destination:wt,postcodeLabel:En,subdivisionLabel:Kn,me:ue,savedAddresses:xn,selectedAddressId:Xe,setSelectedAddressId:Ee,saveAddress:St,setSaveAddress:At,saveLabel:Je,setSaveLabel:Tn,addressSaveNote:_n,lostChangeNote:In,idemKey:$,confirmation:je,setConfirmation:z,orderError:Fn,payment:Rt,paypalStep:Et,squareStep:Kt,pendingConf:_,paid:Un,setPaid:Le,unpaidOrder:w,orderLocked:Mt,formLocked:Bn,restoredPrices:Dt,quoteFailed:st,retryQuote:dr,payNote:Yn,afterpayConfirming:Hn,gocardlessConfirming:Wn,zipConfirming:Xn,klarnaConfirming:Zn,worldpayConfirming:Vn,cardConfirming:Lt,checkoutResult:le,confirmCardPayment:Y,cardStillProcessing:tn,renewCardPayment:mr,holdRenewed:tr,leaveCardPayment:hr,checkoutRootRef:It,setCheckoutHeaderEl:nr,fillFromAddress:Ft,checkoutSignOut:rr,payOptions:J,noPaymentMethod:or,placeOrder:pr}}const bn=gr(null);function Ro({children:r,...k}){const g=so(k);return O(bn.Provider,{value:g,children:r})}function Eo(){const r=kr(bn);if(!r)throw new Error("useCheckout must be used inside CheckoutStateProvider");return r}export{Ro as CheckoutStateProvider,Ao as NO_PAYMENT_METHOD_NOTE,vo as SHIPPING_RETRY_NOTE,gn as buildPayOptions,kn as paymentNotStartedMessage,Oo as placedOrderLockNote,Eo as useCheckout};
|
|
@@ -287,6 +287,9 @@ export type GocardlessComplete = components["schemas"]["GocardlessComplete"];
|
|
|
287
287
|
export type ZipCheckoutRequest = components["schemas"]["ZipCheckoutRequest"];
|
|
288
288
|
export type ZipCheckout = components["schemas"]["ZipCheckout"];
|
|
289
289
|
export type ZipCaptureRequest = components["schemas"]["ZipCaptureRequest"];
|
|
290
|
+
export type WorldpayCheckoutRequest = components["schemas"]["WorldpayCheckoutRequest"];
|
|
291
|
+
export type WorldpayCheckout = components["schemas"]["WorldpayCheckout"];
|
|
292
|
+
export type WorldpayConfirmRequest = components["schemas"]["WorldpayConfirmRequest"];
|
|
290
293
|
export type KlarnaCheckoutRequest = components["schemas"]["KlarnaCheckoutRequest"];
|
|
291
294
|
export type KlarnaCheckout = components["schemas"]["KlarnaCheckout"];
|
|
292
295
|
export type KlarnaCaptureRequest = components["schemas"]["KlarnaCaptureRequest"];
|
|
@@ -381,6 +384,8 @@ export declare const products: {
|
|
|
381
384
|
completeGocardlessPayment: (body: GocardlessComplete) => Promise<PaymentOutcome>;
|
|
382
385
|
createZipCheckout: (body: ZipCheckoutRequest) => Promise<ZipCheckout>;
|
|
383
386
|
captureZipPayment: (body: ZipCaptureRequest) => Promise<PaymentOutcome>;
|
|
387
|
+
createWorldpayCheckout: (body: WorldpayCheckoutRequest) => Promise<WorldpayCheckout>;
|
|
388
|
+
confirmWorldpayPayment: (body: WorldpayConfirmRequest) => Promise<PaymentOutcome>;
|
|
384
389
|
createKlarnaCheckout: (body: KlarnaCheckoutRequest) => Promise<KlarnaCheckout>;
|
|
385
390
|
captureKlarnaPayment: (body: KlarnaCaptureRequest) => Promise<PaymentOutcome>;
|
|
386
391
|
createStockAlert: (body: StockAlertRequest) => Promise<StockAlertAck>;
|