efficient-storefront-blocks 0.133.0 → 0.133.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/chunks/{CustomHtmlCodeWindow-VMHVWWU4.js → CustomHtmlCodeWindow-ZPYYAXIT.js} +1 -1
  3. package/dist/chunks/EditorPreviewCheckout-BYCGH5HR.js +4 -0
  4. package/dist/chunks/{SiteEditorProvider-XQBBIEX4.js → SiteEditorProvider-WZHTXNWZ.js} +1 -1
  5. package/dist/chunks/{chunk-6YESFEQM.js → chunk-I4IY2GTB.js} +5 -5
  6. package/dist/chunks/chunk-JBFEQFNX.js +1 -0
  7. package/dist/chunks/{chunk-PDLGLUEV.js → chunk-MJ4NDWP7.js} +1 -1
  8. package/dist/chunks/chunk-RG2VEZZ7.js +9 -0
  9. package/dist/chunks/{chunk-DI3WYPQW.js → chunk-UQDOJWLM.js} +1 -1
  10. package/dist/editor/components/EditorPreviewCheckout.js +1 -1
  11. package/dist/editor/lib/document/blocks/service/Form/fields.js +1 -1
  12. package/dist/editor/lib/storefront-editor-words.d.ts +4 -0
  13. package/dist/editor/lib/storefront-editor-words.js +1 -1
  14. package/dist/index.js +26 -26
  15. package/dist/render/app/globals.css +12 -2
  16. package/dist/render/components/FormBlock.d.ts +23 -2
  17. package/dist/render/components/FormBlock.js +1 -1
  18. package/dist/render/components/checkout/CheckoutPageClient.js +1 -1
  19. package/dist/render/components/checkout/checkout-parts.js +1 -1
  20. package/dist/render/components/checkout/checkout-state.d.ts +3 -1
  21. package/dist/render/components/checkout/checkout-state.js +3 -3
  22. package/dist/render/lib/document/blocks/service/Form/render.js +1 -1
  23. package/dist/render/lib/document/blocks/text-part-shapes.json +7 -0
  24. package/dist/routine-index.json +1 -1
  25. package/dist/value-index.json +1 -1
  26. package/dist/words.d.ts +4 -0
  27. package/dist/words.js +1 -1
  28. package/package.json +1 -1
  29. package/dist/chunks/EditorPreviewCheckout-ZZWN45X3.js +0 -4
  30. package/dist/chunks/chunk-GXZNWNY6.js +0 -1
  31. package/dist/chunks/chunk-Z5XT44JU.js +0 -9
  32. /package/dist/chunks/{chunk-PDLGLUEV.js.LEGAL.txt → chunk-MJ4NDWP7.js.LEGAL.txt} +0 -0
@@ -1185,12 +1185,22 @@ body .sf-site-header[data-header-ink="dark"] {
1185
1185
  }
1186
1186
 
1187
1187
  /* Form → Letters: Capitalised. The form's labels, button and consent line
1188
- are drawn as typed (components/FormBlock `data-form-case`). */
1189
- [data-form-case="capitalised"] .uppercase {
1188
+ are drawn as typed (components/FormBlock `data-form-case`). The checkout
1189
+ takes the header's Letters the same way (components/checkout
1190
+ CheckoutPageClient `data-checkout-case`): its labels, steps, buttons and
1191
+ copyright as typed, with no letter space. */
1192
+ [data-form-case="capitalised"] .uppercase,
1193
+ [data-checkout-case="capitalised"] .uppercase {
1190
1194
  text-transform: none;
1191
1195
  letter-spacing: normal;
1192
1196
  }
1193
1197
 
1198
+ /* A Form's Label weight, Regular: its field labels at the regular weight
1199
+ (components/FormBlock `data-form-label`). Unset is today's semibold. */
1200
+ [data-form-label="regular"] .font-semibold {
1201
+ font-weight: normal;
1202
+ }
1203
+
1194
1204
  /* ─── THE BOX HEADER'S LETTERS ────────────────────────────────────────
1195
1205
  The Site Header's `Letters` (the old header's `nav_text_case`,
1196
1206
  lib/content/header-bar): ONE value for the menu's links AND the tool words,
@@ -1,6 +1,7 @@
1
1
  import { type CSSProperties } from "react";
2
2
  import type { SlotComponent } from "efficient-easel/blocks";
3
3
  import { type Form, type FormAck } from "../lib/api/index.js";
4
+ import { type SectionBackground } from "efficient-web-builder/format/lib/content/section-background";
4
5
  export interface FormBlockProps {
5
6
  formSlug?: string;
6
7
  heading?: string;
@@ -20,7 +21,25 @@ export interface FormBlockProps {
20
21
  buttonColor?: unknown;
21
22
  buttonTextColor?: unknown;
22
23
  textCase?: unknown;
24
+ background?: SectionBackground;
25
+ requiredNote?: string;
26
+ labelWeight?: unknown;
27
+ headingTag?: unknown;
23
28
  }
29
+ export declare const FORM_BG_BUILT_IN = "var(--site-surface)";
30
+ export declare const FORM_HEADING_TAGS: {
31
+ label: string;
32
+ value: "h6" | "h1" | "h2" | "h3" | "h4" | "h5";
33
+ }[];
34
+ export declare const FORM_HEADING_TAG_DEFAULT = "h2";
35
+ export declare const FORM_LABEL_WEIGHTS: readonly [{
36
+ readonly label: "Semibold";
37
+ readonly value: "semibold";
38
+ }, {
39
+ readonly label: "Regular";
40
+ readonly value: "regular";
41
+ }];
42
+ export declare const FORM_LABEL_WEIGHT_DEFAULT = "semibold";
24
43
  export declare const FORM_BUTTON_WIDTH_FIT = "content";
25
44
  export declare const FORM_BUTTON_WIDTH_FILL = "fill";
26
45
  export declare const FORM_BUTTON_WIDTHS: readonly [{
@@ -30,11 +49,13 @@ export declare const FORM_BUTTON_WIDTHS: readonly [{
30
49
  readonly label: "Fill";
31
50
  readonly value: "fill";
32
51
  }];
33
- export default function FormBlock({ formSlug, heading, intro, submitText, finePrint, form: injected, editing, nodeId, thanks, showSent, buttonCorners, buttonCornerSides, buttonCornersUnit, widthFit, headingHidden, buttonColor, buttonTextColor, textCase, }?: FormBlockProps): import("react").JSX.Element;
52
+ export default function FormBlock({ formSlug, heading, intro, submitText, finePrint, form: injected, editing, nodeId, thanks, showSent, buttonCorners, buttonCornerSides, buttonCornersUnit, widthFit, headingHidden, buttonColor, buttonTextColor, textCase, background, requiredNote, labelWeight, headingTag, }?: FormBlockProps): import("react").JSX.Element;
34
53
  export declare function AccountOutcome({ account }: {
35
54
  account: FormAck["account"];
36
55
  }): import("react").JSX.Element | null;
37
- export declare function FormBody({ form, formSlug, submitText, finePrint, editing, onSent, corners, nodeId, thanks, showSent, fullWidthButton, buttonPaint, capitalised, }: {
56
+ export declare function FormBody({ form, formSlug, submitText, finePrint, editing, onSent, corners, nodeId, thanks, showSent, fullWidthButton, buttonPaint, capitalised, requiredNote, regularLabels, }: {
57
+ requiredNote?: string;
58
+ regularLabels?: boolean;
38
59
  capitalised?: boolean;
39
60
  buttonPaint?: CSSProperties | null;
40
61
  fullWidthButton?: boolean;
@@ -1 +1 @@
1
- "use client";import{jsx as t,jsxs as c}from"react/jsx-runtime";import M from"next/link";import{useEffect as P}from"react";import{FormFieldInput as O,FormHoneypot as W,successMessageFor as j,useBoundForm as H,useFormSubmission as R}from"./formSubmission.js";import C from"./SectionNotice.js";import{ThanksCard as D}from"./ThanksCard.js";import{showsSentOnCanvas as U}from"../lib/content/thanks-slot.js";import{say as _}from"efficient-web-builder/format/lib/editor-words";import q from"./WebFormField.js";import{usePopupScope as A}from"./PopupHost.js";import{FIELD_INPUT_CLASS as I}from"../lib/field-input.js";import{cornerSidesShorthand as E,normalizeCornerSides as $}from"efficient-web-builder/format/lib/content/section-corners";import{cssLengthOf as G}from"efficient-web-builder/format/lib/content/css-length";import{withSideOnce as J}from"efficient-web-builder/format/lib/content/page-width";import{useSideSpaceOnce as K}from"efficient-web-builder/render/components/SideSpaceOnce";import{withRootPad as Q}from"efficient-web-builder/render/lib/content/section-own-pads";import{useSectionPad as V}from"./SectionPadScope.js";import{hexToRgb as X,parseHexColor as Y}from"efficient-shell/format";import{resolveNavTextCase as Z}from"../lib/content/header-bar.js";function ee({field:e,value:r,onChange:o,cornersClass:s=""}){const n={field:e,value:r,onChange:o};return e.type==="checkbox"?c("label",{className:"flex items-start gap-3",children:[t(O,{...n,className:"mt-1 size-4 accent-accent"}),c("span",{className:"font-mono text-[12px] font-semibold uppercase tracking-[0.16em] text-fg",children:[e.label,e.required?t("span",{className:"text-accent",children:" *"}):null]})]}):t(q,{label:e.label,required:e.required,children:t(O,{...n,className:(e.type==="textarea"?I+" resize-y":I)+s})})}const te="content",B="fill",we=[{label:"Fit content",value:te},{label:"Fill",value:B}];function z(e){return typeof e=="string"&&X(e.trim())!==null?Y(e.trim()):null}function ne(e,r){const o={},s=z(e),n=z(r);return s&&(o["--btn"]=s),n&&(o["--btn-ink"]=n),Object.keys(o).length?o:null}function re(e,r,o){if(typeof e!="number"||!Number.isFinite(e))return null;const s=G(Math.max(0,e),o),n=$(r);return{style:{"--form-control-radius":n===null?s:E(s,n)},className:" [border-radius:var(--form-control-radius)]"}}function oe({formSlug:e,heading:r,intro:o,submitText:s,finePrint:n,form:d,editing:i=!1,nodeId:f="",thanks:x,showSent:h,buttonCorners:g,buttonCornerSides:b,buttonCornersUnit:y,widthFit:N,headingHidden:v=!1,buttonColor:F,buttonTextColor:S,textCase:p}={}){const m=K(),T=V(),a=H(e,d),k=A();if(a===void 0)return t(C,{size:"short",children:_("Loading form…")});if(a===null)return t(C,{size:"short",children:i?_("Choose a form in the inspector, under Form."):"This form is unavailable."});const u=v?"":(r??"").trim()||a.title;return t("section",{className:"relative z-[2] border-t border-line bg-surface",children:c("div",{...Q(J("mx-auto max-w-[var(--sf-site-width,1600px)] px-[var(--sf-site-gutter,40px)] py-[84px] max-[960px]:px-[min(24px,var(--sf-site-gutter,40px))]",m),T),children:[u&&t("h2",{className:"mb-4 font-heading2 text-[length:min(var(--size-headingMedium,44px),var(--sf-heading-max,9999px))] font-medium uppercase leading-none tracking-[-0.02em] text-fg max-view-wide:text-[length:min(var(--size-headingMedium,32px),var(--sf-heading-max,9999px))]",children:u}),(o??"").trim()&&t("p",{className:"mb-12 max-w-[640px] font-display text-[16px] leading-[1.6] text-fg-dim",children:o}),t(ae,{form:a,formSlug:e,submitText:s,finePrint:n,editing:i,onSent:k?.markSent,nodeId:f,thanks:x,showSent:h,corners:re(g,b,y),fullWidthButton:N===B,buttonPaint:ne(F,S),capitalised:Z(p)==="capitalised"})]})})}function se({account:e}){const r="font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim";switch(e?.status){case"approved":return c("p",{className:r,children:["Check your email to set your password, then"," ",t(M,{href:"/login",className:"underline",children:"Sign in"})]});case"pending":return t("p",{className:r,children:"We're reviewing your application and will email you once it's approved."});case"rejected":return t("p",{className:r,children:"We couldn't open an account from this application. Please contact the shop."});default:return null}}function ae({form:e,formSlug:r,submitText:o,finePrint:s,editing:n=!1,onSent:d,corners:i=null,nodeId:f="",thanks:x,showSent:h,fullWidthButton:g=!1,buttonPaint:b=null,capitalised:y=!1}){const{valueOf:N,set:v,honeypot:F,setHoneypot:S,submitting:p,done:m,account:T,error:a,handleSubmit:k}=R({form:e,formSlug:r,editing:n});P(()=>{m&&d?.()},[m]);const u=(o??"").trim()||e.submitButtonText?.trim()||"Submit",w=l=>c("div",{role:"status",className:"flex max-w-[560px] flex-col gap-3",children:[t("p",{className:"font-serif text-[19px] italic leading-[1.6] text-fg-dim",children:j(e)}),l,t(se,{account:T})]});return m||U(h,n)?t(D,{ownerId:f,ownerType:"Form",Template:x,message:w(null),children:w}):c("form",{className:"flex max-w-[720px] flex-col gap-5",style:i?.style,onSubmit:k,"data-form-case":y?"capitalised":void 0,children:[e.fields.map(l=>t(ee,{field:l,value:N(l.key),onChange:L=>v(l.key,L),cornersClass:i?.className},l.key)),t(W,{value:F,onChange:S}),a&&t("p",{role:"alert",className:"font-mono text-[12px] uppercase tracking-[0.18em] text-alert",children:a}),t("button",{type:n?"button":"submit",disabled:p,style:b??void 0,className:`cursor-pointer ${g?"self-stretch":"self-start"} bg-btn px-8 py-4 font-mono text-[14px] uppercase tracking-[0.32em] text-btn-ink transition-colors hover:bg-fg hover:text-bg disabled:cursor-wait disabled:opacity-60${i?.className??""}`,children:p?"Sending…":u}),e.consentText?.trim()&&t("span",{className:"font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim/70",children:e.consentText}),(s??"").trim()&&t("span",{className:"font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim/70",children:s})]})}export{se as AccountOutcome,we as FORM_BUTTON_WIDTHS,B as FORM_BUTTON_WIDTH_FILL,te as FORM_BUTTON_WIDTH_FIT,ae as FormBody,oe as default};
1
+ "use client";import{jsx as t,jsxs as c}from"react/jsx-runtime";import W from"next/link";import{useEffect as D}from"react";import{FormFieldInput as C,FormHoneypot as G,successMessageFor as U,useBoundForm as P,useFormSubmission as j}from"./formSubmission.js";import I from"./SectionNotice.js";import{ThanksCard as q}from"./ThanksCard.js";import{showsSentOnCanvas as $}from"../lib/content/thanks-slot.js";import{say as L}from"efficient-web-builder/format/lib/editor-words";import X from"./WebFormField.js";import{usePopupScope as J}from"./PopupHost.js";import{FIELD_INPUT_CLASS as M}from"../lib/field-input.js";import{cornerSidesShorthand as K,normalizeCornerSides as Q}from"efficient-web-builder/format/lib/content/section-corners";import{cssLengthOf as V}from"efficient-web-builder/format/lib/content/css-length";import{withSideOnce as Y}from"efficient-web-builder/format/lib/content/page-width";import{useSideSpaceOnce as Z}from"efficient-web-builder/render/components/SideSpaceOnce";import{withRootPad as ee}from"efficient-web-builder/render/lib/content/section-own-pads";import{useSectionPad as te}from"./SectionPadScope.js";import{hexToRgb as re,parseHexColor as ne,parseOption as z}from"efficient-shell/format";import{resolveNavTextCase as oe}from"../lib/content/header-bar.js";import{TEXT_TAGS as ae}from"efficient-web-builder/format/lib/content/text-tag";import{resolveSectionBackground as se,sectionBackgroundChoice as ie}from"efficient-web-builder/format/lib/content/section-background";function le({field:e,value:r,onChange:o,cornersClass:a=""}){const n={field:e,value:r,onChange:o};return e.type==="checkbox"?c("label",{className:"flex items-start gap-3",children:[t(C,{...n,className:"mt-1 size-4 accent-accent"}),c("span",{className:"font-mono text-[12px] font-semibold uppercase tracking-[0.16em] text-fg",children:[e.label,e.required?t("span",{className:"text-accent",children:" *"}):null]})]}):t(X,{label:e.label,required:e.required,children:t(C,{...n,className:(e.type==="textarea"?M+" resize-y":M)+a})})}const A="var(--site-surface)",ce=ae.filter(e=>e!=="p").map(e=>({label:e.toUpperCase(),value:e})),me="h2",pe=[{label:"Semibold",value:"semibold"},{label:"Regular",value:"regular"}],ue="semibold";function de(e){return e===void 0||e===""?{className:"relative z-[2] border-t border-line bg-surface"}:ie(e,A)==="none"?{className:"relative z-[2]"}:{className:"relative z-[2] border-t border-line",style:{backgroundColor:se(e,A)}}}const E=e=>e.map(r=>r.value),fe="content",R="fill",Ge=[{label:"Fit content",value:fe},{label:"Fill",value:R}];function H(e){return typeof e=="string"&&re(e.trim())!==null?ne(e.trim()):null}function xe(e,r){const o={},a=H(e),n=H(r);return a&&(o["--btn"]=a),n&&(o["--btn-ink"]=n),Object.keys(o).length?o:null}function he(e,r,o){if(typeof e!="number"||!Number.isFinite(e))return null;const a=V(Math.max(0,e),o),n=Q(r);return{style:{"--form-control-radius":n===null?a:K(a,n)},className:" [border-radius:var(--form-control-radius)]"}}function ge({formSlug:e,heading:r,intro:o,submitText:a,finePrint:n,form:x,editing:i=!1,nodeId:h="",thanks:g,showSent:b,buttonCorners:N,buttonCornerSides:v,buttonCornersUnit:T,widthFit:p,headingHidden:y=!1,buttonColor:F,buttonTextColor:S,textCase:_,background:O,requiredNote:u,labelWeight:m,headingTag:k}={}){const d=Z(),w=te(),l=P(e,x),f=J();if(l===void 0)return t(I,{size:"short",children:L("Loading form…")});if(l===null)return t(I,{size:"short",children:i?L("Choose a form in the inspector, under Form."):"This form is unavailable."});const s=y?"":(r??"").trim()||l.title,B=z(E(ce),me,k);return t("section",{...de(O),children:c("div",{...ee(Y("mx-auto max-w-[var(--sf-site-width,1600px)] px-[var(--sf-site-gutter,40px)] py-[84px] max-[960px]:px-[min(24px,var(--sf-site-gutter,40px))]",d),w),children:[s&&t(B,{className:"mb-4 font-heading2 text-[length:min(var(--size-headingMedium,44px),var(--sf-heading-max,9999px))] font-medium uppercase leading-none tracking-[-0.02em] text-fg max-view-wide:text-[length:min(var(--size-headingMedium,32px),var(--sf-heading-max,9999px))]",children:s}),(o??"").trim()&&t("p",{className:"mb-12 max-w-[640px] font-display text-[16px] leading-[1.6] text-fg-dim",children:o}),t(Ne,{form:l,formSlug:e,submitText:a,finePrint:n,editing:i,onSent:f?.markSent,nodeId:h,thanks:g,showSent:b,corners:he(N,v,T),fullWidthButton:p===R,buttonPaint:xe(F,S),capitalised:oe(_)==="capitalised",requiredNote:(u??"").trim(),regularLabels:z(E(pe),ue,m)==="regular"})]})})}function be({account:e}){const r="font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim";switch(e?.status){case"approved":return c("p",{className:r,children:["Check your email to set your password, then"," ",t(W,{href:"/login",className:"underline",children:"Sign in"})]});case"pending":return t("p",{className:r,children:"We're reviewing your application and will email you once it's approved."});case"rejected":return t("p",{className:r,children:"We couldn't open an account from this application. Please contact the shop."});default:return null}}function Ne({form:e,formSlug:r,submitText:o,finePrint:a,editing:n=!1,onSent:x,corners:i=null,nodeId:h="",thanks:g,showSent:b,fullWidthButton:N=!1,buttonPaint:v=null,capitalised:T=!1,requiredNote:p="",regularLabels:y=!1}){const{valueOf:F,set:S,honeypot:_,setHoneypot:O,submitting:u,done:m,account:k,error:d,handleSubmit:w}=j({form:e,formSlug:r,editing:n});D(()=>{m&&x?.()},[m]);const l=(o??"").trim()||e.submitButtonText?.trim()||"Submit",f=s=>c("div",{role:"status",className:"flex max-w-[560px] flex-col gap-3",children:[t("p",{className:"font-serif text-[19px] italic leading-[1.6] text-fg-dim",children:U(e)}),s,t(be,{account:k})]});return m||$(b,n)?t(q,{ownerId:h,ownerType:"Form",Template:g,message:f(null),children:f}):c("form",{className:"flex max-w-[720px] flex-col gap-5",style:i?.style,onSubmit:w,"data-form-case":T?"capitalised":void 0,"data-form-label":y?"regular":void 0,children:[p&&e.fields.some(s=>s.required)?t("p",{className:"self-end font-mono text-[length:var(--size-label,12px)] text-fg-dim",children:p}):null,e.fields.map(s=>t(le,{field:s,value:F(s.key),onChange:B=>S(s.key,B),cornersClass:i?.className},s.key)),t(G,{value:_,onChange:O}),d&&t("p",{role:"alert",className:"font-mono text-[12px] uppercase tracking-[0.18em] text-alert",children:d}),t("button",{type:n?"button":"submit",disabled:u,style:v??void 0,className:`cursor-pointer ${N?"self-stretch":"self-start"} bg-btn px-8 py-4 font-mono text-[14px] uppercase tracking-[0.32em] text-btn-ink transition-colors hover:bg-fg hover:text-bg disabled:cursor-wait disabled:opacity-60${i?.className??""}`,children:u?"Sending…":l}),e.consentText?.trim()&&t("span",{className:"font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim/70",children:e.consentText}),(a??"").trim()&&t("span",{className:"font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim/70",children:a})]})}export{be as AccountOutcome,A as FORM_BG_BUILT_IN,Ge as FORM_BUTTON_WIDTHS,R as FORM_BUTTON_WIDTH_FILL,fe as FORM_BUTTON_WIDTH_FIT,ce as FORM_HEADING_TAGS,me as FORM_HEADING_TAG_DEFAULT,pe as FORM_LABEL_WEIGHTS,ue as FORM_LABEL_WEIGHT_DEFAULT,Ne as FormBody,ge as default};
@@ -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 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
+ "use client";import{jsx as e,Fragment as f,jsxs as r}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 ee}from"../../lib/checkout/hold-time.js";import{stripeAppearance as te}from"../../lib/checkout/stripe-appearance.js";import{userZone as re,parseOption as ne}from"efficient-shell/format";import{Elements as ae,PaymentElement as ie,useElements as oe,useStripe as ce}from"@stripe/react-stripe-js";import{loadStripe as se}from"@stripe/stripe-js";import{useCurrency as E}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{resolveCopyright as le}from"../../lib/content/site.js";import{ApiError as L,products as I}from"../../lib/api/index.js";import de,{WORDMARK_FIT_FLOOR_PX as me}from"efficient-web-builder/render/components/Logo";import{NOT_CHECKED as T,orderReference as pe}from"../../lib/checkout/pay-first.js";import{CheckoutStateProvider as ue,useCheckout as M}from"./checkout-state.js";import{CheckoutContact as fe,CheckoutOrderSummary as xe,CheckoutPayment as ge,CheckoutShippingAddress as he,CheckoutShippingMethod as ye,FormLock as z,LeaveLink as B}from"./checkout-parts.js";function be(t){return e(ue,{...t,children:e(ke,{children:e(Pe,{})})})}function ke({children:t}){const{capitalised:n}=M();return n?e("div",{"data-checkout-case":"capitalised",className:"contents",children:t}):e(f,{children:t})}function Ne({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(f,{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(f,{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 we({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(f,{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(f,{children:["The hold on checkout ",o," ran out before your payment arrived. Your payment goes back to your card."]}):t.kind==="processing"?r(f,{children:["Your payment for checkout ",o," is being processed. When it goes through, we will email your order confirmation."]}):r(f,{children:["Thank you — your payment",t.checkoutNumber?r(f,{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 Pe(){const{site:t,logo:n,items:o,placing:m,formLocked:y,email:p,me:s,addressSaveNote:g,lostChangeNote:d,idemKey:x,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:U,cardConfirming:W,checkoutResult:A,confirmCardPayment:H,cardStillProcessing:G,renewCardPayment:Q,holdRenewed:V,leaveCardPayment:Z,checkoutRootRef:X,setCheckoutHeaderEl:J}=M();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(f,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:c.orderNumber})," has gone through."," "]}):r(f,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:c.orderNumber})," is being reviewed by our team."," "]}),s?r(f,{children:["Track it under"," ",e(R,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):e(f,{children:"We’ve emailed you a link to set a password and track it."})]}),e(Ne,{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(we,{result:A,lostChangeNote:d}):W?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."})]}):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-xs uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Worldpay — one moment."})]}):h&&l?e(ve,{payment:h,checkout:l,holdRenewed:V,onPaid:H,onProcessing:G,onRenew:Q,onBack:Z}):k&&l?e(Ee,{confirmation:l,clientId:t.paypalClientId??"",idemKey:x,onPaid:()=>{S(!0),u(l)},onSkip:()=>u(l)}):N&&l?e(Ie,{confirmation:l,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:x,onPaid:()=>{S(!0),u(l)},onSkip:()=>u(l)}):r("div",{ref:X,className:"bg-bg text-fg",children:[r("header",{ref:J,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(B,{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(B,{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(de,{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?me: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 max-[640px]:flex-nowrap max-[640px]:gap-3 max-[640px]:whitespace-nowrap max-[640px]:text-xs max-[640px]:tracking-[0.04em]",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(z,{locked:y,children:[e(fe,{}),e(he,{}),e(ye,{})]}),e(z,{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:le({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function ve({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)}),x=Y(()=>se(t.publishableKey),[t.publishableKey]),c=Y(()=>te(),[]),u=ee(n.expiresAt??"",re()??"");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:pe(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(f,{children:["Your order is placed. Pay ",d," by card to confirm it now."]}):o?r(f,{children:["Your hold ran out, so your items are held again",u?` until ${u}`:"",". Enter your card again, then pay ",d,"."]}):r(f,{children:["Your items are held",u?` until ${u}`:"",". Pay ",d," by card to place your order."]})}),e(ae,{stripe:x,options:{clientSecret:t.clientSecret,appearance:c},children:e(Se,{payment:t,checkout:n,onPaid:m,onProcessing:y,onRenew:p,onBack:s})},t.clientSecret)]})]})})}const Ce=5;function Se({payment:t,checkout:n,onPaid:o,onProcessing:m,onRenew:y,onBack:p}){const{formatMoney:s}=E(),g=ce(),d=oe(),[x,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<Ce;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||x)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(x)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(ie,{}),u&&e(_,{role:"alert",children:u}),e("button",{type:"button",onClick:b,disabled:!g||!d||x,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||x?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:x?r(f,{children:["Processing… ",e("span",{children:"·"})]}):r(f,{children:["Pay ",s(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),!n.orderNumber&&!x&&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 F="paypal-sdk-js";let q=null;function je(t,n){const o=`${t}|${n}`;if(q?.key===o)return q.promise;const m=new Promise((y,p)=>{document.getElementById(F)?.remove();const s=document.createElement("script");s.id=F;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 Ee({confirmation:t,clientId:n,idemKey:o,onPaid:m,onSkip:y}){const{formatMoney:p}=E(),s=j(null),[g,d]=C(!1),[x,c]=C(null),u=j(m);return u.current=m,D(()=>{let h=!1,k=null;return je(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&&!x&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:s}),x&&e(_,{role:"alert",children:x}),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 $="square-web-sdk";let O=null;const Re=["sandbox","production"];function _e(t){const n=ne(Re,"production",t);if(O?.key===n)return O.promise;const o=new Promise((m,y)=>{document.getElementById($)?.remove();const p=document.createElement("script");p.id=$,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 Ie({confirmation:t,applicationId:n,locationId:o,environment:m,idemKey:y,onPaid:p,onSkip:s}){const{formatMoney:g}=E(),d=j(null),x=j(null),c=j(null),[u,h]=C(!1),[k,N]=C(!1),[l,b]=C(null);D(()=>{let i=!1,a=null;return _e(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),x.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=x.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(f,{children:["Processing… ",e("span",{children:"·"})]}):r(f,{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{we 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 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};
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 C}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:c,setLastName:d,company:m,setCompany:k,me:v,signInHref:u,checkoutSignOut:b,orderLocked:o,unpaidOrder:s}=C(),h=O();return a(L,{num:1,title:"Contact",children:[o&&s&&e(be,{orderNumber:s.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(R,{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:c,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:c,setAddress2:d,city:m,setCity:k,postcode:v,setPostcode:u,phone:b,setPhone:o,country:s,setCountry:h,subdivision:p,setSubdivision:g,subdivisions:E,destination:P,postcodeLabel:S,subdivisionLabel:y,me:B,savedAddresses:D,selectedAddressId:F,setSelectedAddressId:$,saveAddress:Y,setSaveAddress:G,saveLabel:W,setSaveLabel:K,fillFromAddress:Q,orderLocked:V}=C(),H=O(),j=O();return a(L,{num:2,title:t?"Collection":"Shipping address",children:[t?a("div",{className:"grid gap-2 text-[14px] leading-[1.6]",children:[e("span",{className:"font-medium",children:t.name}),[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).length>0&&e("span",{className:"opacity-80",children:[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).join(", ")}),t.openingHours&&e("span",{className:"opacity-80",children:t.openingHours}),t.readyIn&&e("span",{className:"opacity-80",children:t.readyIn}),t.instructions&&e("span",{className:"opacity-80",children:t.instructions}),e("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):a(N,{children:[B!==null&&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:c,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:s,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&&B!==null&&F==="new"&&!V&&a(N,{children:[e(ye,{checked:Y,onChange:G,label:"Save this address to my account"}),Y&&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:c,pickupLocation:d,formatMoney:m,city:k,destination:v,courierUnavailable:u,retryCourier:b}=C();return e(L,{num:3,title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(o=>{const s=o.pickupLocation,h=s?[s.address,s.city,s.state,s.zipCode].filter(Boolean).join(", "):null;return e(I,{active:l===o.id,onClick:()=>c(o.id),title:s?`${o.name} — ${s.name}`:o.name,body:s?[h,s.openingHours,s.readyIn,s.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:c}=C();return a(L,{num:4,title:"Payment",children:[c&&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:c,payChoice:d,placing:m,email:k,orderError:v,payment:u,noPaymentMethod:b,unpaidOrder:o,formLocked:s,restoredPrices:h,quoteFailed:p,retryQuote:g,placeOrder:E}=C(),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(R,{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(R,{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:s,className:"border-t border-line px-6 pt-5",children:e(ne,{customerEmail:k,disabled:s})}),a("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[e(w,{label:"Subtotal",value:P?T:c(S?n.serverSubtotal??0:n.subtotal,n.currency)}),(n.discount>0||n.deliverySaving>0)&&l?.valid&&e(w,{label:`Coupon · ${l.code}`,value:e("span",{className:"font-semibold text-green",children:oe(n,y=>c(y,n.currency))})}),l?.deferred&&e(w,{label:`Coupon · ${l.code}`,value:ae}),l?.valid&&l.effects?.gift&&e(w,{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(w,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:A}):se(n.shippingStatus)??c(n.shipping,n.currency)}),n.tax&&(n.tax.charged?e(w,{label:n.tax.inclusive?`${n.tax.name} included · ${n.tax.rate}%`:n.tax.name,value:c(n.tax.amount,n.currency)}):n.tax.name?e(w,{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:c(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]:gap-3 max-[640px]:whitespace-nowrap max-[640px]:px-4 max-[640px]:text-xs max-[640px]:tracking-normal",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:[" · ",c(n.grand,n.currency)]})]}),a("span",{className:"flex items-center gap-3",children:[e("span",{"aria-hidden":"true",className:"max-[359px]:hidden min-[641px]:hidden",children:c(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 R({href:t,className:i="",children:n,...l}){const{placing:c}=C();return c?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}){const{capitalised:l}=C();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:l?String(t):`N° ${String(t).padStart(2,"0")}`}),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:c,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:c})]})}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:c,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,s=l.find(g=>g.gold)?.label,h=u?.finishes.find(g=>g.name===s&&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:c})]}),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 w({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,R as LeaveLink};
@@ -36,8 +36,9 @@ export interface CheckoutProps {
36
36
  } | null;
37
37
  preview?: boolean;
38
38
  signInHref?: string | null;
39
+ textCase?: unknown;
39
40
  }
40
- declare function useCheckoutState({ site, logo, signInHref, preview }: CheckoutProps): {
41
+ declare function useCheckoutState({ site, logo, signInHref, preview, textCase }: CheckoutProps): {
41
42
  site: SiteIdentity;
42
43
  logo: {
43
44
  url: string | null;
@@ -49,6 +50,7 @@ declare function useCheckoutState({ site, logo, signInHref, preview }: CheckoutP
49
50
  sizeUnit?: LengthUnit | null;
50
51
  } | null | undefined;
51
52
  signInHref: string | null;
53
+ capitalised: boolean;
52
54
  items: CartLine[];
53
55
  totals: {
54
56
  sets: number;
@@ -1,3 +1,3 @@
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};
1
+ "use client";import{jsx as O}from"react/jsx-runtime";import{createContext as kr,useContext as Cr,useEffect as h,useMemo as un,useRef as y,useState as s}from"react";import{isOrderable as ln,useCart as wr}from"../CartContext.js";import{useCurrency as Pr}from"../CurrencyContext.js";import{resolveNavTextCase as br}from"../../lib/content/header-bar.js";import{getClickIds as Nr}from"../../lib/click-ids.js";import{adConsentForOrder as Sr}from"../../lib/consent/choice.js";import{trackBeginCheckout as Ar,trackPurchase as vr}from"../../lib/google-tag.js";import{trackMetaPurchase as Or}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 Rr}from"../../lib/commerce.js";import{canPersist as Er,safeSessionStorage as at}from"efficient-web-builder/format/lib/safe-storage";import{AFTERPAY_CONTEXT_KEY as Kr,AFTERPAY_RETURN as Mr,GOCARDLESS_CONTEXT_KEY as xr,GOCARDLESS_RETURN as Lr,KLARNA_CONTEXT_KEY as Tr,KLARNA_RETURN as _r,WORLDPAY_CONTEXT_KEY as Ir,WORLDPAY_RETURN as Fr,ZIP_CONTEXT_KEY as qr,ZIP_RETURN as $r,runWalletReturn as ge}from"../../lib/checkout/wallet-return.js";import{matchSubdivision as Ur}from"../../lib/checkout/match-subdivision.js";import{clearCheckoutMemory as Br,holdsPress as Yr,parkCheckoutMemory as Dr,parkForm as Hr,parkOrder as Gr,parkRequest as dn,readCheckoutMemory as Wr,sameGoods as zr,sendableRequest as Xr}from"../../lib/checkout/checkout-memory.js";import{checkoutGone as it,checkoutWaiting as pn,BANK_WAITING as Jr,DROPPABLE_INTENT as Zr,NOT_CHECKED as ut,LOST_CHANGE as lt,PAY_FIRST_FLOW as dt,paysFirst as jr,readIntentStatus as Vr,releaseHeldCheckout as fn,CHECKOUT_COMMITTED as Qr,goodsShapeOf as eo,refusedForGood as yn,settlePayFirst as to}from"../../lib/checkout/pay-first.js";import{couponCodeForOrder as mn,couponRefusedByOrder as no}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 Ro="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 ro=3e3,oo=.005,Cn=new Set(["paypal","square","afterpay","gocardless","zip","klarna","worldpay"]);function wn(){const r=Sr();return{...r==="denied"?{}:Nr(),...r?{adConsent:r}:{}}}const R=r=>JSON.parse(r),so={lastPress:null,keptCardKey:null,placedShape:null,placedRequest:null,unpaidOrder:null},co={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&&Gr(r)};function Pn(r,k){const g={};for(const m of Object.keys(r))g[m]=r[m](k[m]);return g}const Eo="Shipping cannot be calculated right now. Please try again.";function Ko(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 ao({site:r,logo:k,signInHref:g=null,preview:m=!1,textCase:Nn}){const{items:f,totals:b,coupon:M,refuseCoupon:Sn,deliveryOptions:pt,shippingMethodId:Q,setShippingMethodId:ft,setQuoteDestination:ke,courier:An,requote:Ce,identify:yt,clearCapturedCart:we,replaceItems:De,removeCoupon:mt,applyCoupon:vn}=wr(),On=pt.find(e=>e.id===Q)?.pickupLocation??null,{country:ht,countries:ee,activeCountry:gt,formatMoney:Rn}=Pr(),[P,Pe]=s(()=>gn(r)[0]?.key??null),[kt,En]=s(!0);h(()=>{En(Er(at))},[]);const[x,He]=s(!1),[F,be]=s(""),[L,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]),Kn=wt?.postalLabel||"Postal Code",Mn=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 xn=An?.status==="unavailable",Ln=Ce,[ue,bt]=s(null),[Tn,Nt]=s([]),[Xe,Ee]=s("new"),[St,At]=s(!1),[Je,_n]=s("Home"),[In,vt]=s(null),[Fn,Ze]=s(null),[$,Ke]=s(()=>Be()),Ot=y(null),[je,z]=s(null),[qn,S]=s(null),[Rt,Me]=s(null),[Et,$n]=s(!1),[Kt,Un]=s(!1),[_,X]=s(null),[Bn,xe]=s(!1),[w,A]=s(null),Mt=!!w?.orderNumber,Yn=Mt||x,[Dn,Hn]=s(null),[Gn,Wn]=s(!1),[zn,Xn]=s(!1),[Jn,Zn]=s(!1),[jn,Vn]=s(!1),[Qn,er]=s(!1),[xt,tr]=s(!1),[nr,Ve]=s(!1),[le,Lt]=s(null),a=y({...so});a.current.unpaidOrder=w;const Qe=y(!1),U=y(f),Tt=!!(je||le&&le.kind!=="processing"||xt||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,Ar({lines:f,currency:b.currency,value:b.subtotal-b.discount,coupon:M?.valid?M.code:void 0}))},[f,b,M,m]),h(()=>{yt(F,L.trim()||void 0)},[F,L,yt]);const It=y(null),[Le,rr]=s(null);h(()=>{const e=It.current;if(!Le||!e)return;const t=()=>e.style.setProperty("--sf-checkout-header-h",`${Le.offsetHeight}px`);t();const o=new ResizeObserver(t);return o.observe(Le),()=>o.disconnect()},[Le]),h(()=>{const e=o=>({setConfirming:o,land:z,markPaid:()=>xe(!0),note:(c,n)=>Hn({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(Mr,{...t,capture:C.captureAfterpayPayment,page:e(Wn)}),ge($r,{...t,capture:C.captureZipPayment,page:e(Zn)}),ge(Lr,{...t,capture:C.completeGocardlessPayment,page:e(Xn)}),ge(_r,{...t,capture:C.captureKlarnaPayment,page:e(Vn)}),ge(Fr,{...t,capture:C.confirmWorldpayPayment,page:e(er)})},[]);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(Ur(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 or(){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 sr=J.length===0,Te=ve.trim()?`${te}
3
+ ${ve.trim()}`:te,cr=eo({email:F,firstName:L,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([cr,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(x);qt.current=x;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,Br()}const $e=y(null),[j,ar]=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(co,a.current),lines:f.length>0?f:U.current,form:Hr({email:F,firstName:L,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})};Yr(t.press)?Dr(t):fe()}const Yt=y(P);Yt.current=P;function rt(e){return{...Xr(e),...wn(),...e.payFirst?{checkoutFlow:dt}:{}}}function ir(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[ur,lr]=s(!1),Dt=ur?!b.quoted||b.serverSubtotal===null?"waiting":Math.abs(b.serverSubtotal-b.subtotal)<oo?"same":"changed":null,ot=!w&&Dt==="waiting",dr=ot?{...b,repricing:!0}:b,st=ot&&b.quoteFailed;h(()=>{if(!st)return;const e=setInterval(Ce,ro);return()=>clearInterval(e)},[st,Ce]);const pr=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:Wr();const t=!!(e&&f.length>0);if(e&&t&&!zr(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&&ir(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,lr(!0)),e.form&&($e.current=e.form,Ht(e.form))}ar(!0)},[]),h(()=>{!j||f.length>0||a.current.unpaidOrder||x||(pe.current=!0,fe())},[j,f.length]),h(()=>{const e=qe.current;!j||!e||f.length===0||(qe.current=null,vn(e,F||void 0))},[j,f.length]),h(()=>{!j||x||nt($)},[j,x,$,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 Vr(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||!Zr.has(t))return B.current=v.current,A(e),S(t==="requires_action"?Jr: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 fr(){m||x||Ie.current||await $t(yr)}async function yr(){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=>Rr(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:`${L} ${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=""),mr(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=no(l);u?(Sn(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 mr(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!==Qr?(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){vr({confirmation:e,lines:U.current,adsSendTo:r.googleAdsId&&r.googleAdsConversionLabel?`${r.googleAdsId}/${r.googleAdsConversionLabel}`:null}),Or({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){xe(!0),z(t);return}await en(t.checkoutNumber,o)}async function en(e,t){we(),await to({checkoutNumber:e,resend:t,page:{setConfirming:tr,land:z,markPaid:()=>xe(!0),track:Qt,unplaced:Lt}})}function tn(e=_){if(e){if(e.orderNumber){z(e);return}we(),Lt({kind:"processing",checkoutNumber:e.checkoutNumber})}}async function ct(){const e=JSON.stringify([Je.trim(),L,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:`${L} ${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),$n(!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(Kr,c,e,i.redirectCheckoutUrl);return}else if(t==="square"&&r.paymentMethods.includes("square"))X(e),Un(!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(xr,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(qr,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(Tr,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(Ir,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 hr(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 gr(){_&&(I.current=!0,A(_),Me(null),X(null),Ve(!1))}return{site:r,logo:k,signInHref:g,capitalised:br(Nn)==="capitalised",items:f,totals:dr,coupon:M,deliveryOptions:pt,courierUnavailable:xn,retryCourier:Ln,shippingMethodId:Q,setShippingMethodId:ft,pickupLocation:On,servedCountries:ee,formatMoney:Rn,payChoice:P,setPayChoice:Pe,placing:x,email:F,setEmail:be,firstName:L,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:Kn,subdivisionLabel:Mn,me:ue,savedAddresses:Tn,selectedAddressId:Xe,setSelectedAddressId:Ee,saveAddress:St,setSaveAddress:At,saveLabel:Je,setSaveLabel:_n,addressSaveNote:In,lostChangeNote:Fn,idemKey:$,confirmation:je,setConfirmation:z,orderError:qn,payment:Rt,paypalStep:Et,squareStep:Kt,pendingConf:_,paid:Bn,setPaid:xe,unpaidOrder:w,orderLocked:Mt,formLocked:Yn,restoredPrices:Dt,quoteFailed:st,retryQuote:pr,payNote:Dn,afterpayConfirming:Gn,gocardlessConfirming:zn,zipConfirming:Jn,klarnaConfirming:jn,worldpayConfirming:Qn,cardConfirming:xt,checkoutResult:le,confirmCardPayment:Y,cardStillProcessing:tn,renewCardPayment:hr,holdRenewed:nr,leaveCardPayment:gr,checkoutRootRef:It,setCheckoutHeaderEl:rr,fillFromAddress:Ft,checkoutSignOut:or,payOptions:J,noPaymentMethod:sr,placeOrder:fr}}const bn=kr(null);function Mo({children:r,...k}){const g=ao(k);return O(bn.Provider,{value:g,children:r})}function xo(){const r=Cr(bn);if(!r)throw new Error("useCheckout must be used inside CheckoutStateProvider");return r}export{Mo as CheckoutStateProvider,Ro as NO_PAYMENT_METHOD_NOTE,Eo as SHIPPING_RETRY_NOTE,gn as buildPayOptions,kn as paymentNotStartedMessage,Ko as placedOrderLockNote,xo as useCheckout};
@@ -1 +1 @@
1
- import{jsx as n}from"react/jsx-runtime";import d from"../../../../../components/FormBlock.js";import{hidableText as e,readHidable as o}from"efficient-easel/screen/lib/document/hidable";import{BUTTON_STYLE_KEYS as i}from"efficient-easel/screen/lib/content/style-keys";import{BUTTON_CORNERS_UNIT_KEY as r}from"efficient-easel/screen/lib/content/length-units";import{SHOW_SENT_KEY as m,THANKS_SLOT as f}from"../../../../content/thanks-slot.js";import{FormMeta as u}from"./meta.js";import{padsItself as a}from"../../../pads-itself.js";const C=a("Form",{...u,render:t=>n(d,{formSlug:e(t.formSlug)||void 0,heading:e(t.heading)||void 0,headingHidden:o(t.heading).hidden,intro:e(t.intro)||void 0,submitText:e(t.submitText)||void 0,finePrint:e(t.finePrint)||void 0,form:t.form,editing:t.editor?.isEditing,nodeId:typeof t.id=="string"?t.id:"",thanks:t[f],showSent:t[m],buttonCorners:t[i.corners],buttonCornerSides:t[i.cornerSides],buttonCornersUnit:t[r],widthFit:t.widthFit,buttonColor:t[i.fill],buttonTextColor:t[i.text],textCase:t.textCase})});export{C as FormRender};
1
+ import{jsx as n}from"react/jsx-runtime";import d from"../../../../../components/FormBlock.js";import{hidableText as t,readHidable as r}from"efficient-easel/screen/lib/document/hidable";import{BUTTON_STYLE_KEYS as i}from"efficient-easel/screen/lib/content/style-keys";import{BUTTON_CORNERS_UNIT_KEY as o}from"efficient-easel/screen/lib/content/length-units";import{SHOW_SENT_KEY as m,THANKS_SLOT as f}from"../../../../content/thanks-slot.js";import{FormMeta as a}from"./meta.js";import{padsItself as u}from"../../../pads-itself.js";const C=u("Form",{...a,render:e=>n(d,{formSlug:t(e.formSlug)||void 0,heading:t(e.heading)||void 0,headingHidden:r(e.heading).hidden,intro:t(e.intro)||void 0,submitText:t(e.submitText)||void 0,finePrint:t(e.finePrint)||void 0,form:e.form,editing:e.editor?.isEditing,nodeId:typeof e.id=="string"?e.id:"",thanks:e[f],showSent:e[m],buttonCorners:e[i.corners],buttonCornerSides:e[i.cornerSides],buttonCornersUnit:e[o],widthFit:e.widthFit,buttonColor:e[i.fill],buttonTextColor:e[i.text],textCase:e.textCase,background:e.background,requiredNote:t(e.requiredNote)||void 0,labelWeight:e.labelWeight,headingTag:e.headingTag})});export{C as FormRender};
@@ -1331,6 +1331,13 @@
1331
1331
  "control": "plainText",
1332
1332
  "label": "Fine print"
1333
1333
  }
1334
+ },
1335
+ "requiredNote": {
1336
+ "type": "custom",
1337
+ "__text": {
1338
+ "control": "plainText",
1339
+ "label": "Required note"
1340
+ }
1334
1341
  }
1335
1342
  },
1336
1343
  "LegalLineBlock": {