efficient-storefront-blocks 0.137.0 → 0.138.1

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 (40) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/chunks/{CustomHtmlCodeWindow-Z6VOLUDK.js → CustomHtmlCodeWindow-4OS3BLNS.js} +1 -1
  3. package/dist/chunks/EditorPreviewCheckout-RF2M6FBA.js +4 -0
  4. package/dist/chunks/SiteEditorProvider-445QTFDY.js +1 -0
  5. package/dist/chunks/{chunk-JBOIT52E.js → chunk-55HCCLM4.js} +1 -1
  6. package/dist/chunks/chunk-6VZXQPDK.js +337 -0
  7. package/dist/chunks/chunk-DXVVHVFA.js +11 -0
  8. package/dist/chunks/chunk-JZT76GOY.js +1 -0
  9. package/dist/chunks/{chunk-HTPROWNP.js → chunk-LAUTWUIM.js} +1 -1
  10. package/dist/chunks/{chunk-FI4EXF37.js → chunk-MCIZHB3Z.js} +1 -1
  11. package/dist/chunks/{chunk-ZVHG5QQR.js → chunk-OAHMFUHH.js} +1 -1
  12. package/dist/chunks/{chunk-2XZFXVKX.js → chunk-U54HRBBL.js} +1 -1
  13. package/dist/chunks/{fitment-data-QZLRTN6S.js → fitment-data-5CQLYPUS.js} +1 -1
  14. package/dist/chunks/{section-css-style-MHLXSGS3.js → section-css-style-GS3GFILD.js} +1 -1
  15. package/dist/editor/lib/efficient-backend.js +1 -1
  16. package/dist/index.js +25 -25
  17. package/dist/render/built-with.json +1 -1
  18. package/dist/render/components/CouponField.js +1 -1
  19. package/dist/render/components/checkout/CheckoutPageClient.js +1 -1
  20. package/dist/render/components/checkout/checkout-parts.js +1 -1
  21. package/dist/render/lib/api/index.d.ts +38 -2
  22. package/dist/render/lib/api/index.js +1 -1
  23. package/dist/render/lib/api/types.d.ts +26 -0
  24. package/dist/render/lib/cart/shipping-status.d.ts +1 -0
  25. package/dist/render/lib/cart/shipping-status.js +1 -1
  26. package/dist/routine-index.json +1 -1
  27. package/dist/value-index.json +1 -1
  28. package/dist/words.d.ts +1 -0
  29. package/dist/words.js +1 -1
  30. package/package.json +2 -2
  31. package/dist/chunks/EditorPreviewCheckout-2VQTCCYW.js +0 -4
  32. package/dist/chunks/SiteEditorProvider-DRHFIJIM.js +0 -1
  33. package/dist/chunks/chunk-4AVKWZMD.js +0 -1
  34. package/dist/chunks/chunk-JRZLQGD3.js +0 -337
  35. package/dist/chunks/chunk-MYDBTUHM.js +0 -9
  36. /package/dist/chunks/{chunk-MHHLECYD.js → chunk-4BGF2KJJ.js} +0 -0
  37. /package/dist/chunks/{chunk-JRZLQGD3.js.LEGAL.txt → chunk-6VZXQPDK.js.LEGAL.txt} +0 -0
  38. /package/dist/chunks/{chunk-PAE6QL75.js → chunk-EWEX5KJD.js} +0 -0
  39. /package/dist/chunks/{chunk-ZVHG5QQR.js.LEGAL.txt → chunk-OAHMFUHH.js.LEGAL.txt} +0 -0
  40. /package/dist/chunks/{chunk-BKBFZATI.js → chunk-T3YKEXOD.js} +0 -0
@@ -1,3 +1,3 @@
1
1
  {
2
- "efficient-web-builder": "80.0.0"
2
+ "efficient-web-builder": "80.1.0"
3
3
  }
@@ -1 +1 @@
1
- "use client";import{jsx as t,jsxs as i}from"react/jsx-runtime";import{useEffect as x,useRef as f,useState as b}from"react";import{ROW_INPUT_CLASS as g}from"../lib/field-input.js";import{COUPON_DEFERRED_MESSAGE as h}from"../lib/cart/coupon-preview.js";import{useCart as v}from"./CartContext.js";function y({customerEmail:l,disabled:o=!1}){const{coupon:e,applyCoupon:s,removeCoupon:m,couponBusy:n}=v(),[a,p]=b(""),c=f(!1),u=f(null);x(()=>{!c.current||e===null||(c.current=!1,u.current?.focus())},[e]);async function d(){o||n||!a.trim()||(c.current=!0,await s(a,l),p(""))}return i("div",{className:"flex flex-col gap-2",children:[e===null?i("div",{className:"flex border border-line",children:[t("input",{type:"text",value:a,onChange:r=>p(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),d())},placeholder:"Coupon code","aria-label":"Coupon code",disabled:o,className:`${g} bg-transparent px-4 py-4 font-mono text-[11px] uppercase tracking-[0.18em] text-fg outline-none placeholder:text-fg-dim`}),t("button",{type:"button",onClick:()=>{d()},disabled:n||o,className:"border-l border-line px-4 font-mono text-[10px] uppercase tracking-[0.26em] text-btn transition-colors hover:bg-btn hover:text-btn-ink disabled:cursor-wait disabled:opacity-60",children:n?"…":"Apply"})]}):i("div",{className:["flex items-center justify-between gap-3 border px-4 py-3",e.valid?"border-accent":"border-line"].join(" "),style:e.valid?{background:"color-mix(in oklab, var(--accent) 8%, transparent)"}:void 0,children:[t("span",{className:["font-mono text-[11px] uppercase tracking-[0.22em]",e.valid?"text-accent":e.deferred||e.unchecked?"text-fg":"text-fg-dim line-through"].join(" "),children:e.code}),e.unchecked&&t("button",{type:"button",onClick:()=>{s(e.code,l)},disabled:n||o,className:"ml-auto font-mono text-[10px] uppercase tracking-[0.26em] text-btn transition-colors hover:text-fg disabled:cursor-wait disabled:opacity-60",children:n?"…":"Try again"}),!o&&t("button",{ref:u,type:"button",onClick:m,"aria-label":`Remove coupon ${e.code}`,className:"font-mono text-[12px] text-fg-dim transition-colors hover:text-fg",children:"✕"})]}),e?.deferred?t("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-fg-dim",children:h}):e&&!e.valid&&e.message&&t("p",{role:"alert",className:"font-mono text-[10px] uppercase tracking-[0.18em] text-alert",children:e.message})]})}export{y as default};
1
+ "use client";import{jsx as t,jsxs as i}from"react/jsx-runtime";import{useEffect as x,useRef as f,useState as b}from"react";import{ROW_INPUT_CLASS as g}from"../lib/field-input.js";import{COUPON_DEFERRED_MESSAGE as h}from"../lib/cart/coupon-preview.js";import{useCart as v}from"./CartContext.js";function y({customerEmail:c,disabled:n=!1}){const{coupon:e,applyCoupon:s,removeCoupon:m,couponBusy:o}=v(),[a,p]=b(""),l=f(!1),u=f(null);x(()=>{!l.current||e===null||(l.current=!1,u.current?.focus())},[e]);async function d(){n||o||!a.trim()||(l.current=!0,await s(a,c),p(""))}return i("div",{className:"flex flex-col gap-2",children:[e===null?i("div",{className:"flex border border-line",children:[t("input",{type:"text",value:a,onChange:r=>p(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),d())},placeholder:"Coupon code","aria-label":"Coupon code",disabled:n,className:`${g} bg-transparent px-4 py-4 font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.18em] text-fg outline-none placeholder:text-fg-dim`}),t("button",{type:"button",onClick:()=>{d()},disabled:o||n,className:"border-l border-line px-4 font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.26em] text-btn transition-colors hover:bg-btn hover:text-btn-ink disabled:cursor-wait disabled:opacity-60",children:o?"…":"Apply"})]}):i("div",{className:["flex items-center justify-between gap-3 border px-4 py-3",e.valid?"border-accent":"border-line"].join(" "),style:e.valid?{background:"color-mix(in oklab, var(--accent) 8%, transparent)"}:void 0,children:[t("span",{className:["font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.22em]",e.valid?"text-accent":e.deferred||e.unchecked?"text-fg":"text-fg-dim line-through"].join(" "),children:e.code}),e.unchecked&&t("button",{type:"button",onClick:()=>{s(e.code,c)},disabled:o||n,className:"ml-auto font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.26em] text-btn transition-colors hover:text-fg disabled:cursor-wait disabled:opacity-60",children:o?"…":"Try again"}),!n&&t("button",{ref:u,type:"button",onClick:m,"aria-label":`Remove coupon ${e.code}`,className:"font-mono text-[12px] text-fg-dim transition-colors hover:text-fg",children:"✕"})]}),e?.deferred?t("p",{className:"font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.18em] text-fg-dim",children:h}):e&&!e.valid&&e.message&&t("p",{role:"alert",className:"font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.18em] text-alert",children:e.message})]})}export{y as default};
@@ -1 +1 @@
1
- "use client";import{jsx as e,Fragment as u,jsxs as r}from"react/jsx-runtime";import E 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 R}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 he,CheckoutShippingAddress as ge,CheckoutShippingMethod as ye,FormLock as F,LeaveLink as z}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(u,{children:t})}function Ne({order:t,paid:n}){const{formatMoney:c}=R();if(!t.grandTotal||!t.currency)return null;const m=s=>c(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(u,{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(u,{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 c=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(u,{children:["An item sold out or an offer ended while you paid for checkout ",c,". Your payment goes back to your card."]}):t.kind==="expired"?r(u,{children:["The hold on checkout ",c," ran out before your payment arrived. Your payment goes back to your card."]}):t.kind==="processing"?r(u,{children:["Your payment for checkout ",c," is being processed. When it goes through, we will email your order confirmation."]}):r(u,{children:["Thank you — your payment",t.checkoutNumber?r(u,{children:[" for checkout ",c]}):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(E,{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:c,placing:m,formLocked:y,email:p,me:s,addressSaveNote:h,lostChangeNote:d,idemKey:x,confirmation:i,setConfirmation:f,payment:g,paypalStep:k,squareStep:N,pendingConf:l,paid:b,setPaid:S,payNote:o,afterpayConfirming:a,gocardlessConfirming:P,zipConfirming:v,klarnaConfirming:A,worldpayConfirming:U,cardConfirming:W,checkoutResult:K,confirmCardPayment:H,cardStillProcessing:G,renewCardPayment:Q,holdRenewed:V,leaveCardPayment:Z,checkoutRootRef:X,setCheckoutHeaderEl:J}=M();return i?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(u,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:i.orderNumber})," has gone through."," "]}):r(u,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:i.orderNumber})," is being reviewed by our team."," "]}),s?r(u,{children:["Track it under"," ",e(E,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):i.accountLinkSent?e(u,{children:"We’ve emailed you a link to set a password and track it."}):r(u,{children:["Already have an account?"," ",e(E,{href:"/login?next=%2Faccount%2Forders",className:"text-accent underline",children:"Sign in"})," ","to see it under your orders."]})]}),e(Ne,{order:i,paid:b}),d&&e("p",{className:"text-sm text-fg-dim",children:d}),o&&(o.warning?e("div",{className:"w-full max-w-sm text-left",children:e(_,{tone:"bad",role:"alert",children:o.text})}):e("p",{className:"text-sm text-fg-dim",children:o.text})),h&&e("p",{className:"text-sm text-fg-dim",children:h}),!s&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(E,{href:`/track?order=${encodeURIComponent(i.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(E,{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"})]}):K?e(we,{result:K,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."})]}):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 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."})]}):g&&l?e(ve,{payment:g,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),f(l)},onSkip:()=>f(l)}):N&&l?e(Ie,{confirmation:l,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:x,onPaid:()=>{S(!0),f(l)},onSkip:()=>f(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(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(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(F,{locked:y,children:[e(fe,{}),e(ge,{}),e(ye,{})]}),e(F,{locked:m,children:e(he,{})})]}),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:c,onPaid:m,onProcessing:y,onRenew:p,onBack:s}){const{formatMoney:h}=R(),d=e("span",{className:"text-fg",children:h(Number(t.amount),t.currency)}),x=Y(()=>se(t.publishableKey),[t.publishableKey]),i=Y(()=>te(),[]),f=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(u,{children:["Your order is placed. Pay ",d," by card to confirm it now."]}):c?r(u,{children:["Your hold ran out, so your items are held again",f?` until ${f}`:"",". Enter your card again, then pay ",d,"."]}):r(u,{children:["Your items are held",f?` until ${f}`:"",". Pay ",d," by card to place your order."]})}),e(ae,{stripe:x,options:{clientSecret:t.clientSecret,appearance:i},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:c,onProcessing:m,onRenew:y,onBack:p}){const{formatMoney:s}=R(),h=ce(),d=oe(),[x,i]=C(!1),[f,g]=C(null),k=j(!1);async function N(){try{return(await h.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function l(o){let a=o;for(let P=0;a==="processing"&&P<Ce;P+=1)await new Promise(v=>setTimeout(v,1e3)),a=await N()??a;if(a==="succeeded"){c();return}if(a==="processing"){m();return}g("Payment did not complete. Please try again."),i(!1)}async function b(){if(!h||!d||x)return;i(!0),g(null),k.current=!0;const o=await h.confirmPayment({elements:d,redirect:"if_required"}).catch(()=>null);if(!o){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}g(a===void 0?T:"Payment failed. Please try again."),i(!1);return}if(o.error){if(!n.orderNumber&&o.error.code==="payment_intent_unexpected_state"){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}if(a===void 0){g(T),i(!1);return}await y(a==="canceled"),i(!1);return}g(o.error.message??"Payment failed. Please try again."),i(!1);return}await l(o.paymentIntent?.status)}async function S(){if(x)return;if(!k.current){p();return}i(!0),g(null);const o=await N();if(o==="succeeded"||o==="processing"){await l(o);return}if(i(!1),o===void 0){g(T);return}p()}return r("div",{className:"flex flex-col gap-4",children:[e(ie,{}),f&&e(_,{role:"alert",children:f}),e("button",{type:"button",onClick:b,disabled:!h||!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",!h||!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(u,{children:["Processing… ",e("span",{children:"·"})]}):r(u,{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 B="paypal-sdk-js";let q=null;function je(t,n){const c=`${t}|${n}`;if(q?.key===c)return q.promise;const m=new Promise((y,p)=>{document.getElementById(B)?.remove();const s=document.createElement("script");s.id=B;const h=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});s.src=`https://www.paypal.com/sdk/js?${h}`,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:c,promise:m},m}function Ee({confirmation:t,clientId:n,idemKey:c,onPaid:m,onSkip:y}){const{formatMoney:p}=R(),s=j(null),[h,d]=C(!1),[x,i]=C(null),f=j(m);return f.current=m,D(()=>{let g=!1,k=null;return je(n,t.currency).then(N=>{if(!(g||!s.current))return k=N.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await I.createPaypalOrder({idempotencyKey:c})).paypalOrderId,onApprove:async l=>{try{if((await I.capturePaypalOrder({idempotencyKey:c,paypalOrderId:l.orderID})).status==="paid"){f.current();return}i("PayPal did not complete the payment. Please try again.")}catch(b){i(b instanceof L?b.message:"PayPal payment failed. Please try again.")}},onError:()=>{i("PayPal could not process the payment. Please try again.")}}),k.render(s.current).then(()=>{g||d(!0)})}).catch(()=>{g||i("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{g=!0,k?.close?.()}},[n,t.currency,c]),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."]}),!h&&!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 c=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:c},c}function Ie({confirmation:t,applicationId:n,locationId:c,environment:m,idemKey:y,onPaid:p,onSkip:s}){const{formatMoney:h}=R(),d=j(null),x=j(null),i=j(null),[f,g]=C(!1),[k,N]=C(!1),[l,b]=C(null);D(()=>{let o=!1,a=null;return _e(m).then(async P=>{if(o||!d.current)return;const v=P.payments(n,c);i.current=v,a=await v.card(),await a.attach(d.current),x.current=a,o||g(!0)}).catch(()=>{o||b("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{o=!0,a?.destroy?.()}},[n,c,m]);async function S(){const o=x.current;if(!(!o||k)){N(!0),b(null);try{const a=await o.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 i.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:h(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!f&&!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:!f||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",!f||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(u,{children:["Processing… ",e("span",{children:"·"})]}):r(u,{children:["Pay ",h(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
+ "use client";import{jsx as e,Fragment as u,jsxs as r}from"react/jsx-runtime";import E from"next/link";import{useEffect as K,useMemo as D,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 R}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{resolveCopyright as le}from"../../lib/content/site.js";import{ApiError as Y,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 L}from"./checkout-state.js";import{CheckoutContact as fe,CheckoutOrderSummary as xe,CheckoutPayment as he,CheckoutShippingAddress as ge,CheckoutShippingMethod as ye,FormLock as M,LeaveLink as F}from"./checkout-parts.js";function be(t){return e(ue,{...t,children:e(ke,{children:e(ve,{})})})}function ke({children:t}){const{capitalised:n}=L();return n?e("div",{"data-checkout-case":"capitalised",className:"contents",children:t}):e(u,{children:t})}function Ne({order:t,paid:n}){const{formatMoney:c}=R();if(!t.grandTotal||!t.currency)return null;const m=s=>c(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(u,{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(u,{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 c=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(u,{children:["An item sold out or an offer ended while you paid for checkout ",c,". Your payment goes back to your card."]}):t.kind==="expired"?r(u,{children:["The hold on checkout ",c," ran out before your payment arrived. Your payment goes back to your card."]}):t.kind==="processing"?r(u,{children:["Your payment for checkout ",c," is being processed. When it goes through, we will email your order confirmation."]}):r(u,{children:["Thank you — your payment",t.checkoutNumber?r(u,{children:[" for checkout ",c]}):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(E,{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 ve(){const{site:t,logo:n,items:c,placing:m,formLocked:y,email:p,me:s,addressSaveNote:h,lostChangeNote:d,idemKey:x,confirmation:i,setConfirmation:f,payment:g,paypalStep:k,squareStep:N,pendingConf:l,paid:b,setPaid:S,payNote:o,afterpayConfirming:a,gocardlessConfirming:v,zipConfirming:P,klarnaConfirming:z,worldpayConfirming:U,cardConfirming:W,checkoutResult:A,confirmCardPayment:H,cardStillProcessing:G,renewCardPayment:Q,holdRenewed:V,leaveCardPayment:Z,checkoutRootRef:X,setCheckoutHeaderEl:J}=L();return i?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(u,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:i.orderNumber})," has gone through."," "]}):r(u,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:i.orderNumber})," is being reviewed by our team."," "]}),s?r(u,{children:["Track it under"," ",e(E,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):i.accountLinkSent?e(u,{children:"We’ve emailed you a link to set a password and track it."}):r(u,{children:["Already have an account?"," ",e(E,{href:"/login?next=%2Faccount%2Forders",className:"text-accent underline",children:"Sign in"})," ","to see it under your orders."]})]}),e(Ne,{order:i,paid:b}),d&&e("p",{className:"text-sm text-fg-dim",children:d}),o&&(o.warning?e("div",{className:"w-full max-w-sm text-left",children:e(_,{tone:"bad",role:"alert",children:o.text})}):e("p",{className:"text-sm text-fg-dim",children:o.text})),h&&e("p",{className:"text-sm text-fg-dim",children:h}),!s&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(E,{href:`/track?order=${encodeURIComponent(i.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(E,{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."})]}):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:"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."})]}):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:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip — one moment."})]}):z?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."})]}):g&&l?e(Pe,{payment:g,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),f(l)},onSkip:()=>f(l)}):N&&l?e(Ie,{confirmation:l,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:x,onPaid:()=>{S(!0),f(l)},onSkip:()=>f(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(F,{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(F,{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(M,{locked:y,children:[e(fe,{}),e(ge,{}),e(ye,{})]}),e(M,{locked:m,children:e(he,{})})]}),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 Pe({payment:t,checkout:n,holdRenewed:c,onPaid:m,onProcessing:y,onRenew:p,onBack:s}){const{formatMoney:h}=R(),d=e("span",{className:"text-fg",children:h(Number(t.amount),t.currency)}),x=D(()=>se(t.publishableKey),[t.publishableKey]),i=D(()=>te(),[]),f=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-[length:var(--size-label,13px)] 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(u,{children:["Your order is placed. Pay ",d," by card to confirm it now."]}):c?r(u,{children:["Your hold ran out, so your items are held again",f?` until ${f}`:"",". Enter your card again, then pay ",d,"."]}):r(u,{children:["Your items are held",f?` until ${f}`:"",". Pay ",d," by card to place your order."]})}),e(ae,{stripe:x,options:{clientSecret:t.clientSecret,appearance:i},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:c,onProcessing:m,onRenew:y,onBack:p}){const{formatMoney:s}=R(),h=ce(),d=oe(),[x,i]=C(!1),[f,g]=C(null),k=j(!1);async function N(){try{return(await h.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function l(o){let a=o;for(let v=0;a==="processing"&&v<Ce;v+=1)await new Promise(P=>setTimeout(P,1e3)),a=await N()??a;if(a==="succeeded"){c();return}if(a==="processing"){m();return}g("Payment did not complete. Please try again."),i(!1)}async function b(){if(!h||!d||x)return;i(!0),g(null),k.current=!0;const o=await h.confirmPayment({elements:d,redirect:"if_required"}).catch(()=>null);if(!o){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}g(a===void 0?T:"Payment failed. Please try again."),i(!1);return}if(o.error){if(!n.orderNumber&&o.error.code==="payment_intent_unexpected_state"){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}if(a===void 0){g(T),i(!1);return}await y(a==="canceled"),i(!1);return}g(o.error.message??"Payment failed. Please try again."),i(!1);return}await l(o.paymentIntent?.status)}async function S(){if(x)return;if(!k.current){p();return}i(!0),g(null);const o=await N();if(o==="succeeded"||o==="processing"){await l(o);return}if(i(!1),o===void 0){g(T);return}p()}return r("div",{className:"flex flex-col gap-4",children:[e(ie,{}),f&&e(_,{role:"alert",children:f}),e("button",{type:"button",onClick:b,disabled:!h||!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",!h||!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(u,{children:["Processing… ",e("span",{children:"·"})]}):r(u,{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 B="paypal-sdk-js";let q=null;function je(t,n){const c=`${t}|${n}`;if(q?.key===c)return q.promise;const m=new Promise((y,p)=>{document.getElementById(B)?.remove();const s=document.createElement("script");s.id=B;const h=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});s.src=`https://www.paypal.com/sdk/js?${h}`,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:c,promise:m},m}function Ee({confirmation:t,clientId:n,idemKey:c,onPaid:m,onSkip:y}){const{formatMoney:p}=R(),s=j(null),[h,d]=C(!1),[x,i]=C(null),f=j(m);return f.current=m,K(()=>{let g=!1,k=null;return je(n,t.currency).then(N=>{if(!(g||!s.current))return k=N.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await I.createPaypalOrder({idempotencyKey:c})).paypalOrderId,onApprove:async l=>{try{if((await I.capturePaypalOrder({idempotencyKey:c,paypalOrderId:l.orderID})).status==="paid"){f.current();return}i("PayPal did not complete the payment. Please try again.")}catch(b){i(b instanceof Y?b.message:"PayPal payment failed. Please try again.")}},onError:()=>{i("PayPal could not process the payment. Please try again.")}}),k.render(s.current).then(()=>{g||d(!0)})}).catch(()=>{g||i("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{g=!0,k?.close?.()}},[n,t.currency,c]),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-[length:var(--size-label,13px)] 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."]}),!h&&!x&&e("p",{className:"font-mono text-[length:var(--size-label,13px)] 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-[length:var(--size-label,13px)] 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 c=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:c},c}function Ie({confirmation:t,applicationId:n,locationId:c,environment:m,idemKey:y,onPaid:p,onSkip:s}){const{formatMoney:h}=R(),d=j(null),x=j(null),i=j(null),[f,g]=C(!1),[k,N]=C(!1),[l,b]=C(null);K(()=>{let o=!1,a=null;return _e(m).then(async v=>{if(o||!d.current)return;const P=v.payments(n,c);i.current=P,a=await P.card(),await a.attach(d.current),x.current=a,o||g(!0)}).catch(()=>{o||b("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{o=!0,a?.destroy?.()}},[n,c,m]);async function S(){const o=x.current;if(!(!o||k)){N(!0),b(null);try{const a=await o.tokenize();if(a.status!=="OK"||!a.token){b(a.errors?.[0]?.message??"Please check the card details and try again."),N(!1);return}let v;try{v=(await i.current?.verifyBuyer?.(a.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await I.chargeSquare({idempotencyKey:y,sourceId:a.token,...v?{verificationToken:v}:{}})).status==="paid"){p();return}b("Square did not complete the payment. Please try again.")}catch(a){b(a instanceof Y?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-[length:var(--size-label,13px)] 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:h(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!f&&!l&&e("p",{className:"font-mono text-[length:var(--size-label,13px)] 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:!f||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",!f||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(u,{children:["Processing… ",e("span",{children:"·"})]}):r(u,{children:["Pay ",h(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-[length:var(--size-label,13px)] 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 j}from"react";import Z from"next/image";import J from"next/link";import{lineTotal as ee,useCart as te}from"../CartContext.js";import{useCurrency as ne}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{FREE_PRICE as A}from"../../lib/wheels/price-display.js";import ae from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as re}from"../../lib/cart/coupon-preview.js";import{orderReference as ie}from"../../lib/checkout/pay-first.js";import{PRICES_REQUOTED as le,PRICES_UNCHECKED as oe}from"../../lib/checkout/checkout-memory.js";import{couponSaving as ce,deliveryAfterCoupon as se,shippingWords as de,TAX_PENDING as pe}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as me}from"../../lib/wheels/finish-defaults.js";import U from"../ThemedSelect.js";import b from"../WebFormField.js";import ue from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as he,placedOrderLockNote as ge,SHIPPING_RETRY_NOTE as fe,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";const xe="Loading your order",H=["py-8","text-center","font-serif","text-[16px]","italic","leading-[1.5]","text-fg-dim"].join(" ");function qe(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:c,setLastName:d,company:u,setCompany:k,me:v,signInHref:h,checkoutSignOut:y,orderLocked:o,unpaidOrder:s}=C(),g=j();return a(I,{num:1,title:"Contact",children:[o&&s&&e(Ne,{orderNumber:s.orderNumber}),e(b,{label:"Email",htmlFor:g,hint:v?a(N,{children:["Signed in ·"," ",e("button",{type:"button",onClick:y,className:"underline transition-colors enabled:hover:text-accent",children:"Not you? Sign out"})]}):h?a(N,{children:["Have an account?"," ",e(R,{href:h,className:"underline transition-colors hover:text-accent",children:"Sign in"})]}):void 0,children:e("input",{id:g,type:"email",value:t,onChange:p=>i(p.target.value),placeholder:"you@example.com",readOnly:v!==null,className:f})}),a(z,{children:[e(b,{label:"First name",children:e("input",{type:"text",value:n,onChange:p=>l(p.target.value),className:f})}),e(b,{label:"Last name",children:e("input",{type:"text",value:c,onChange:p=>d(p.target.value),className:f})})]}),e(b,{label:"Company (optional)",children:e("input",{type:"text",value:u,onChange:p=>k(p.target.value),autoComplete:"organization",className:f})})]})}function ze(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:c,setAddress2:d,city:u,setCity:k,postcode:v,setPostcode:h,phone:y,setPhone:o,country:s,setCountry:g,subdivision:p,setSubdivision:m,subdivisions:E,destination:B,postcodeLabel:L,subdivisionLabel:S,me:x,savedAddresses:D,selectedAddressId:F,setSelectedAddressId:M,saveAddress:Y,setSaveAddress:W,saveLabel:K,setSaveLabel:Q,fillFromAddress:V,orderLocked:X}=C(),$=j(),O=j();return a(I,{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:[x!==null&&D.length>0&&a("div",{className:"grid gap-3",children:[D.map(r=>e(P,{active:F===r.id,onClick:()=>{M(r.id),V(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(P,{active:F==="new",onClick:()=>M("new"),title:"New address",body:null,price:null})]}),e(b,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>l(r.target.value),className:f})}),e(b,{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(z,{cols:"three",children:[e(b,{label:"City",children:e("input",{type:"text",value:u,onChange:r=>k(r.target.value),className:f})}),e(b,{label:L,children:e("input",{type:"text",value:v,onChange:r=>h(r.target.value),className:f})}),e(b,{label:"Country",separate:!0,htmlFor:$,children:e(U,{id:$,value:s,onChange:r=>g(r.target.value),className:f+" pr-10",style:q,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(b,{label:S,separate:!0,htmlFor:O,children:E.length>0?a(U,{id:O,value:p,onChange:r=>m(r.target.value),className:f+" pr-10",style:q,children:[e("option",{value:"",children:"Select…"}),E.map(r=>e("option",{value:r.code||r.name,children:r.name},r.code||r.name))]}):e("input",{id:O,type:"text",value:p,onChange:r=>m(r.target.value),className:f})})]}),e(b,{label:"Phone",children:e("input",{type:"tel",value:y,onChange:r=>o(r.target.value),className:f})}),!t&&x!==null&&F==="new"&&!X&&a(N,{children:[e(ve,{checked:Y,onChange:W,label:"Save this address to my account"}),Y&&e(b,{label:"Address label",children:e("input",{type:"text",value:K,onChange:r=>Q(r.target.value),placeholder:"Home",className:f})})]})]})}function Ge(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:c,pickupLocation:d,formatMoney:u,city:k,destination:v,courierUnavailable:h,retryCourier:y}=C();return e(I,{num:3,title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(o=>{const s=o.pickupLocation,g=s?[s.address,s.city,s.state,s.zipCode].filter(Boolean).join(", "):null;return e(P,{active:l===o.id,onClick:()=>c(o.id),title:s?`${o.name} — ${s.name}`:o.name,body:s?[g,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:u(o.amount,t.currency)})," ",u(se(o.amount,t.deliveryDiscountPercent),t.currency)]}):u(o.amount,t.currency),tag:o.tag||void 0},o.id)}),h?a("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[fe," ",e("button",{type:"button",onClick:y,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 We(){const{payChoice:t,setPayChoice:i,payment:n,payOptions:l,noPaymentMethod:c}=C();return a(I,{num:4,title:"Payment",children:[c&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:he}),e("div",{className:"grid gap-3",children:l.map(d=>e(P,{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 Ke(){const{site:t,items:i,totals:n,coupon:l,formatMoney:c,payChoice:d,placing:u,email:k,orderError:v,payment:h,noPaymentMethod:y,unpaidOrder:o,formLocked:s,restoredPrices:g,basketRead:p,quoteFailed:m,retryQuote:E,placeOrder:B}=C(),L=g==="waiting"||!p,S=g==="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:p?i.length===0?a("div",{className:H,children:["Your cart is empty. ",e(R,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog →"})]}):i.map(x=>e(ke,{slug:x.slug,name:x.name,qty:x.qty,config:x.config,configSummary:Ce(x.config),price:S||L?null:ee(x,n.currency)??0,currency:n.currency},x.id)):e("div",{role:"status",className:H,children:xe})}),e(ye,{locked:s,className:"border-t border-line px-6 pt-5",children:e(ae,{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:L?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:ce(n,x=>c(x,n.currency))})}),l?.deferred&&e(w,{label:`Coupon · ${l.code}`,value:re}),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}):de(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:pe}):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||!p?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:le}),m&&a(_,{role:"alert",children:[oe," ",e("button",{type:"button",onClick:E,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:B,disabled:u||!o&&(y||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",u||!o&&(i.length===0||y||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:u?a(N,{children:["Building order… ",e("span",{children:"·"})]}):y?a(N,{children:["No online payment ",e("span",{children:"·"})]}):o?a(N,{children:[a("span",{children:["Try payment again",a(G,{children:[" · ",ie(o)]})]}),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]}):m?a(N,{children:["Total not confirmed ",e("span",{children:"·"})]}):n.repricing||!p?a(N,{children:[T," ",e("span",{children:"·"})]}):a(N,{children:[a("span",{children:[d==="bank"?"Place order":"Continue to payment",a(G,{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 be=" [&:disabled_:disabled]:cursor-not-allowed! [&:disabled_:disabled]:opacity-70! [&_input[readonly]]:cursor-not-allowed [&_input[readonly]]:opacity-70";function ye({locked:t,className:i="",children:n}){return e("fieldset",{disabled:t,className:"m-0 min-w-0 border-0 p-0 "+i+be,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(J,{href:t,"aria-label":l["aria-label"],className:i,children:n})}function Ne({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:ge(t)})]})})}const q={backgroundImage:"linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%)",backgroundPosition:"calc(100% - 18px) 50%, calc(100% - 12px) 50%",backgroundSize:"6px 6px",backgroundRepeat:"no-repeat"};function I({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 z({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 P({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 ve({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 ke({slug:t,name:i,qty:n,config:l,configSummary:c,price:d,currency:u}){const{catalog:k}=te(),{formatMoney:v}=ne(),h=k.find(m=>m.slug===t),y=h?.spokes??5,o=h?.mesh??!1,s=l.find(m=>m.gold)?.label,g=h?.finishes.find(m=>m.name===s&&m.src)??h?.finishes.find(m=>m.src),p=h?.finishes[0]?.color??me;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:g?.src?e(Z,{src:g.src,alt:`${i.lead}${i.accent} — ${g.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(ue,{spokes:y,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,u)})]})}function G({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 Ce(t){return t.map(i=>i.label).join(" · ")}export{qe as CheckoutContact,Ke as CheckoutOrderSummary,We as CheckoutPayment,ze as CheckoutShippingAddress,Ge as CheckoutShippingMethod,ye as FormLock,R as LeaveLink};
1
+ "use client";import{jsx as e,Fragment as v,jsxs as a}from"react/jsx-runtime";import{useId as F}from"react";import Z from"next/image";import J from"next/link";import{lineTotal as ee,useCart as te}from"../CartContext.js";import{useCurrency as ne}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{FREE_PRICE as j}from"../../lib/wheels/price-display.js";import ae from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as re}from"../../lib/cart/coupon-preview.js";import{orderReference as ie}from"../../lib/checkout/pay-first.js";import{PRICES_REQUOTED as le,PRICES_UNCHECKED as oe}from"../../lib/checkout/checkout-memory.js";import{couponSaving as se,deliveryAfterCoupon as ce,shippingWords as de,TAX_PENDING_AT_CHECKOUT as pe}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as me}from"../../lib/wheels/finish-defaults.js";import Y from"../ThemedSelect.js";import b from"../WebFormField.js";import ue from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as he,placedOrderLockNote as ge,SHIPPING_RETRY_NOTE as fe,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";const xe="Loading your order",$=["py-8","text-center","font-serif","text-[16px]","italic","leading-[1.5]","text-fg-dim"].join(" ");function He(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:s,setLastName:d,company:u,setCompany:k,me:N,signInHref:h,checkoutSignOut:y,orderLocked:o,unpaidOrder:c}=C(),g=F();return a(I,{num:1,title:"Contact",children:[o&&c&&e(ve,{orderNumber:c.orderNumber}),e(b,{label:"Email",htmlFor:g,hint:N?a(v,{children:["Signed in ·"," ",e("button",{type:"button",onClick:y,className:"underline transition-colors enabled:hover:text-accent",children:"Not you? Sign out"})]}):h?a(v,{children:["Have an account?"," ",e(z,{href:h,className:"underline transition-colors hover:text-accent",children:"Sign in"})]}):void 0,children:e("input",{id:g,type:"email",value:t,onChange:p=>i(p.target.value),placeholder:"you@example.com",readOnly:N!==null,className:f})}),a(q,{children:[e(b,{label:"First name",children:e("input",{type:"text",value:n,onChange:p=>l(p.target.value),className:f})}),e(b,{label:"Last name",children:e("input",{type:"text",value:s,onChange:p=>d(p.target.value),className:f})})]}),e(b,{label:"Company (optional)",children:e("input",{type:"text",value:u,onChange:p=>k(p.target.value),autoComplete:"organization",className:f})})]})}function qe(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:s,setAddress2:d,city:u,setCity:k,postcode:N,setPostcode:h,phone:y,setPhone:o,country:c,setCountry:g,subdivision:p,setSubdivision:m,subdivisions:E,destination:R,postcodeLabel:L,subdivisionLabel:S,me:x,savedAddresses:B,selectedAddressId:O,setSelectedAddressId:D,saveAddress:M,setSaveAddress:W,saveLabel:K,setSaveLabel:Q,fillFromAddress:V,orderLocked:X}=C(),U=F(),A=F();return a(I,{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-[length:var(--size-label,13px)] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):a(v,{children:[x!==null&&B.length>0&&a("div",{className:"grid gap-3",children:[B.map(r=>e(P,{active:O===r.id,onClick:()=>{D(r.id),V(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(P,{active:O==="new",onClick:()=>D("new"),title:"New address",body:null,price:null})]}),e(b,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>l(r.target.value),className:f})}),e(b,{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(b,{label:"City",children:e("input",{type:"text",value:u,onChange:r=>k(r.target.value),className:f})}),e(b,{label:L,children:e("input",{type:"text",value:N,onChange:r=>h(r.target.value),className:f})}),e(b,{label:"Country",separate:!0,htmlFor:U,children:e(Y,{id:U,value:c,onChange:r=>g(r.target.value),className:f+" pr-10",style:H,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(b,{label:S,separate:!0,htmlFor:A,children:E.length>0?a(Y,{id:A,value:p,onChange:r=>m(r.target.value),className:f+" pr-10",style:H,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:A,type:"text",value:p,onChange:r=>m(r.target.value),className:f})})]}),e(b,{label:"Phone",children:e("input",{type:"tel",value:y,onChange:r=>o(r.target.value),className:f})}),!t&&x!==null&&O==="new"&&!X&&a(v,{children:[e(Ne,{checked:M,onChange:W,label:"Save this address to my account"}),M&&e(b,{label:"Address label",children:e("input",{type:"text",value:K,onChange:r=>Q(r.target.value),placeholder:"Home",className:f})})]})]})}function Ge(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:s,pickupLocation:d,formatMoney:u,city:k,destination:N,courierUnavailable:h,retryCourier:y}=C();return e(I,{num:3,title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(o=>{const c=o.pickupLocation,g=c?[c.address,c.city,c.state,c.zipCode].filter(Boolean).join(", "):null;return e(P,{active:l===o.id,onClick:()=>s(o.id),title:c?`${o.name} — ${c.name}`:o.name,body:c?[g,c.openingHours,c.readyIn,c.instructions,o.description].filter(Boolean).join(" · "):o.description||null,price:t.freeShipping||o.amount===0?j:t.deliveryDiscountPercent>0?a(v,{children:[e("s",{className:"text-fg-dim",children:u(o.amount,t.currency)})," ",u(ce(o.amount,t.deliveryDiscountPercent),t.currency)]}):u(o.amount,t.currency),tag:o.tag||void 0},o.id)}),h?a("p",{className:"font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.2em] text-fg-dim",children:[fe," ",e("button",{type:"button",onClick:y,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}):n.length===0&&e("p",{className:"font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})})}function We(){const{payChoice:t,setPayChoice:i,payment:n,payOptions:l,noPaymentMethod:s}=C();return a(I,{num:4,title:"Payment",children:[s&&e("p",{className:"font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.2em] text-fg-dim",children:he}),e("div",{className:"grid gap-3",children:l.map(d=>e(P,{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-[length:var(--size-label,13px)] 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-[length:var(--size-label,13px)] 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-[length:var(--size-label,13px)] 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-[length:var(--size-label,13px)] 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-[length:var(--size-label,13px)] 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-[length:var(--size-label,13px)] 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-[length:var(--size-label,13px)] 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-[length:var(--size-label,13px)] uppercase tracking-[0.2em] text-fg-dim",children:"Our team emails you the invoice and bank details after review."}):null]})}function Ke(){const{site:t,items:i,totals:n,coupon:l,formatMoney:s,payChoice:d,placing:u,email:k,orderError:N,payment:h,noPaymentMethod:y,unpaidOrder:o,formLocked:c,restoredPrices:g,basketRead:p,quoteFailed:m,retryQuote:E,placeOrder:R}=C(),L=g==="waiting"||!p,S=g==="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(z,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit ↗"})]}),e("div",{className:"flex flex-col px-6 py-2",children:p?i.length===0?a("div",{className:$,children:["Your cart is empty. ",e(z,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog →"})]}):i.map(x=>e(ke,{slug:x.slug,name:x.name,qty:x.qty,config:x.config,configSummary:Ce(x.config),price:S||L?null:ee(x,n.currency)??0,currency:n.currency},x.id)):e("div",{role:"status",className:$,children:xe})}),e(ye,{locked:c,className:"border-t border-line px-6 pt-5",children:e(ae,{customerEmail:k,disabled:c})}),a("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[e(w,{label:"Subtotal",value:L?T:s(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:se(n,x=>s(x,n.currency))})}),l?.deferred&&e(w,{label:`Coupon · ${l.code}`,value:re}),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:j})}),e(w,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:j}):de(n.shippingStatus)??s(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:s(n.tax.amount,n.currency)}):n.tax.name?e(w,{label:n.tax.name,value:pe}):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||!p?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:le}),m&&a(_,{role:"alert",children:[oe," ",e("button",{type:"button",onClick:E,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}),N&&e(_,{role:"alert",children:N}),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:R,disabled:u||!o&&(y||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",u||!o&&(i.length===0||y||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:u?a(v,{children:["Building order… ",e("span",{children:"·"})]}):y?a(v,{children:["No online payment ",e("span",{children:"·"})]}):o?a(v,{children:[a("span",{children:["Try payment again",a(G,{children:[" · ",ie(o)]})]}),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]}):m?a(v,{children:["Total not confirmed ",e("span",{children:"·"})]}):n.repricing||!p?a(v,{children:[T," ",e("span",{children:"·"})]}):a(v,{children:[a("span",{children:[d==="bank"?"Place order":"Continue to payment",a(G,{children:[" · ",s(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:s(n.grand,n.currency)}),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})]})})]})]})}const be=" [&:disabled_:disabled]:cursor-not-allowed! [&:disabled_:disabled]:opacity-70! [&_input[readonly]]:cursor-not-allowed [&_input[readonly]]:opacity-70";function ye({locked:t,className:i="",children:n}){return e("fieldset",{disabled:t,className:"m-0 min-w-0 border-0 p-0 "+i+be,children:n})}function z({href:t,className:i="",children:n,...l}){const{placing:s}=C();return s?e("span",{"aria-disabled":"true","aria-label":l["aria-label"],className:i+" pointer-events-none",children:n}):e(J,{href:t,"aria-label":l["aria-label"],className:i,children:n})}function ve({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:ge(t)})]})})}const H={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 I({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-[length:var(--size-label,13px)] 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 P({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-[length:var(--size-label,13px)] 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 Ne({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 ke({slug:t,name:i,qty:n,config:l,configSummary:s,price:d,currency:u}){const{catalog:k}=te(),{formatMoney:N}=ne(),h=k.find(m=>m.slug===t),y=h?.spokes??5,o=h?.mesh??!1,c=l.find(m=>m.gold)?.label,g=h?.finishes.find(m=>m.name===c&&m.src)??h?.finishes.find(m=>m.src),p=h?.finishes[0]?.color??me;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:g?.src?e(Z,{src:g.src,alt:`${i.lead}${i.accent} — ${g.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(ue,{spokes:y,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-xs 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:N(d,u)})]})}function G({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 Ce(t){return t.map(i=>i.label).join(" · ")}export{He as CheckoutContact,Ke as CheckoutOrderSummary,We as CheckoutPayment,qe as CheckoutShippingAddress,Ge as CheckoutShippingMethod,ye as FormLock,z as LeaveLink};
@@ -1,8 +1,8 @@
1
1
  import type { AdminFieldUsageRow } from "../links/link-rules.js";
2
2
  import type { TyreFitVehicleQuery } from "../tyres/tyre-vehicle-fitment.js";
3
3
  import type { SocialPlatform } from "efficient-web-builder/format/lib/content/social-links";
4
- import type { SiteThemeRow, SiteThemeRowPatch } from "efficient-web-builder/format/lib/site-theme-row";
5
- import type { VideoFrames } from "efficient-web-builder/format/lib/web-backend";
4
+ import type { SiteThemeRow, SiteThemeRowFont, SiteThemeRowPatch } from "efficient-web-builder/format/lib/site-theme-row";
5
+ import type { VideoFrames, WebsiteSiteFontStatus } from "efficient-web-builder/format/lib/web-backend";
6
6
  import type { LengthUnit } from "efficient-easel/screen/lib/content/length-units";
7
7
  export declare const API_URL: string;
8
8
  export declare class ApiError extends Error {
@@ -600,6 +600,26 @@ export interface AdminHeaderSettings {
600
600
  export type AdminHeaderSettingsPatch = Partial<Omit<AdminHeaderSettings, "id" | "logo" | "logo_url" | "default_logo_url" | "effective_logo_url" | "menu_handle" | "menu_name" | "menu_items">>;
601
601
  export type AdminThemeSettings = SiteThemeRow;
602
602
  export type AdminThemeSettingsPatch = SiteThemeRowPatch;
603
+ export interface AdminSiteFont extends SiteThemeRowFont {
604
+ id: string;
605
+ site: string;
606
+ is_archived: boolean;
607
+ status: WebsiteSiteFontStatus;
608
+ failure_reason: string;
609
+ }
610
+ interface AdminGoogleFontFamily {
611
+ family: string;
612
+ google_category: string;
613
+ weights: number[];
614
+ italic_weights: number[];
615
+ }
616
+ interface AdminSiteFontAdd {
617
+ site: string;
618
+ source: "google";
619
+ family: string;
620
+ weights: number[];
621
+ italic: boolean;
622
+ }
603
623
  export interface AdminChatSettings {
604
624
  id: string;
605
625
  enabled: boolean;
@@ -731,6 +751,14 @@ export declare function createStorefrontAdmin(client?: AdminClient): {
731
751
  title: string;
732
752
  slug: string;
733
753
  }, token: string) => Promise<AdminStorefrontPage>;
754
+ listSiteFonts: (siteId: string, token: string) => Promise<AdminSiteFont[]>;
755
+ getSiteFont: (id: string, token: string) => Promise<AdminSiteFont>;
756
+ addSiteFont: (body: AdminSiteFontAdd, token: string) => Promise<AdminSiteFont>;
757
+ retrySiteFont: (id: string, token: string) => Promise<AdminSiteFont>;
758
+ archiveSiteFont: (id: string, token: string, options?: {
759
+ keepalive?: boolean;
760
+ }) => Promise<void>;
761
+ searchGoogleFontFamilies: (query: string, token: string) => Promise<AdminGoogleFontFamily[]>;
734
762
  geocode: (query: string, token: string, country?: string) => Promise<AdminGeocodeAnswer>;
735
763
  listBlockSources: (token: string) => Promise<AdminBlockSource[]>;
736
764
  listRecordTypes: (token: string) => Promise<AdminRecordType[]>;
@@ -819,6 +847,14 @@ export declare const storefrontAdmin: {
819
847
  title: string;
820
848
  slug: string;
821
849
  }, token: string) => Promise<AdminStorefrontPage>;
850
+ listSiteFonts: (siteId: string, token: string) => Promise<AdminSiteFont[]>;
851
+ getSiteFont: (id: string, token: string) => Promise<AdminSiteFont>;
852
+ addSiteFont: (body: AdminSiteFontAdd, token: string) => Promise<AdminSiteFont>;
853
+ retrySiteFont: (id: string, token: string) => Promise<AdminSiteFont>;
854
+ archiveSiteFont: (id: string, token: string, options?: {
855
+ keepalive?: boolean;
856
+ }) => Promise<void>;
857
+ searchGoogleFontFamilies: (query: string, token: string) => Promise<AdminGoogleFontFamily[]>;
822
858
  geocode: (query: string, token: string, country?: string) => Promise<AdminGeocodeAnswer>;
823
859
  listBlockSources: (token: string) => Promise<AdminBlockSource[]>;
824
860
  listRecordTypes: (token: string) => Promise<AdminRecordType[]>;
@@ -1 +1 @@
1
- import{PREVIEW_TOKEN_HEADER as dt,SITE_HOST_HEADER as lt,SITE_SLUG_HEADER as ut}from"../site-headers.js";import{PRODUCT_API_BASE as pt,PRODUCT_BACKEND_URL as H,productBackendUrlNow as yt}from"./origins.js";import{listRows as g}from"./list-rows.js";import{parseOption as ft}from"efficient-shell/format";import{backendHopHeaders as ht,clientIpFromForwardedFor as mt,FORWARDED_FOR_HEADER as gt,hopCachingOf as wt}from"../forwarded-for.js";import St from"efficient-web-builder/format/lib/document/media-manifest.json";import{auth as O}from"../auth.js";import{efficientClientOpen as Pt}from"efficient-easel/screen/lib/session";import{listableWheelSummaries as U}from"../wheels/listable-wheels.js";import{dropRenderlessFinishes as F}from"../wheels/renderable-finishes.js";const Ot=process.env.NEXT_PUBLIC_API_URL??"http://localhost:8000";class w extends Error{status;data;constructor(e,n,s){super(n),this.status=e,this.data=s}}const k="Unable to reach the server. This could be a problem with your internet connection, or the server may be undergoing maintenance or an upgrade. Please try again shortly.",bt=new Set([502,503,504]),v=0,Tt="This editor runs on its host's own backend, which does not serve this request.",Rt=5e3,At=15e3,Et=()=>typeof window>"u"?Rt:At;function M(t){const e=(t.method??"GET").toUpperCase();if(!(t.body!=null||e!=="GET"&&e!=="HEAD")&&!(t.audience!=null&&t.audience!=="shop")&&typeof AbortSignal?.timeout=="function")return AbortSignal.timeout(Et())}const B=t=>t instanceof Error&&t.name==="TimeoutError",q=(t,e)=>bt.has(t)?k:e,_t=["admin","venue"];let G="admin";function Ie(t){G=ft(_t,"admin",t)}function Ut(){return G}const Ct=/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/;let W=null;function Ne(t){W=t&&Ct.test(t)?t:null}function $t(){return W}function It(t){if(typeof window>"u"||!t.startsWith("/api/v1/"))return t;const e=Y();return!e||/[?&]site=/.test(t)?t:C(t,`site=${encodeURIComponent(e)}`)}async function i(t,e={}){const{token:n,baseUrl:s,headers:l,audience:u,...y}=e;if(typeof window<"u"&&!Pt())throw new w(v,Tt,null);if(typeof window>"u"&&s===void 0)throw new Error(`apiFetch(${JSON.stringify(t)}) ran on the server without an explicit baseUrl. The API_URL default it would inherit is browser-only (the prod image bakes NEXT_PUBLIC_API_URL="" for same-origin use, which a Node fetch cannot resolve). Pass a base explicitly: \`await backendOpts()\` (or baseUrl: PRODUCT_FETCH_BASE) for product reads, or the server-only PRODUCT_BACKEND_URL env for other backend surfaces.`);const a=typeof FormData<"u"&&y.body instanceof FormData;let r;try{r=await fetch(`${s??Ot}${It(t)}`,{...y,headers:{...a?{}:{"Content-Type":"application/json"},...n?{Authorization:`Bearer ${n}`}:{},...u===null?{}:{"X-Portal-Audience":u??"shop"},...l},signal:y.signal??M({...y,audience:u})})}catch(f){throw f instanceof TypeError||B(f)?new w(v,k,null):f}let o;try{o=await r.text()}catch(f){throw B(f)?new w(v,k,null):f}let p=null;if(o)try{p=JSON.parse(o)}catch{throw new w(r.status,r.ok?"Expected JSON but received a non-JSON response":q(r.status,r.statusText),o)}if(!r.ok){const f=(p&&typeof p=="object"&&"detail"in p&&typeof p.detail=="string"?p.detail:null)??q(r.status,r.statusText);throw new w(r.status,f,p)}return p}let R=null;async function j(){return R||(R=Nt().finally(()=>{R=null}),R)}async function Nt(){const t=O.takeLegacyRefresh(),e=await Lt.refresh(t??void 0);return O.setTokens(e.access),e.access}async function z(){return O.getAccess()??j()}async function m(t,e={}){let n;try{n=await z()}catch{throw O.clear(),new w(401,"Not signed in",null)}try{return await i(t,{...e,token:n})}catch(s){if(!(s instanceof w)||s.status!==401)throw s;try{const l=await j();return await i(t,{...e,token:l})}catch{throw O.clear(),s}}}const kt=100,K=20;function vt(t){if(!t)return null;try{return new URL(t,"http://page.invalid").searchParams.get("page")}catch{return null}}async function X(t,e){const[n,s=""]=t.split("?"),l=[];let u="1";for(let y=0;y<K&&u;y++){const a=new URLSearchParams(s);a.set("page_size",String(kt)),u!=="1"&&a.set("page",u);const r=await m(`${n}?${a.toString()}`);l.push(...g(r)),u=vt(r.next)}return u&&console.warn(`[${e}] stopped at ${K} pages (${l.length} rows); list may be truncated`),l}async function V(t,e={}){if(O.getAccess())try{return{data:await m(t,e),asShopper:!0}}catch(n){if(!(n instanceof w)||n.status!==401)throw n}return{data:await i(t,e),asShopper:!1}}async function Z(){const t=await m("/api/auth/me/");if(t.portal!=="shop")throw O.clear(),new w(403,"This session is not valid for this shop.",null);return t}const Lt={login:(t,e)=>i("/api/auth/login/",{method:"POST",body:JSON.stringify({email:t,password:e,portal:"shop"}),credentials:"include"}),refresh:t=>i("/api/auth/refresh/",{method:"POST",body:JSON.stringify(t?{refresh:t,portal:"shop"}:{portal:"shop"}),credentials:"include"}),logout:async()=>{O.clear();try{await i("/api/auth/logout/",{method:"POST",body:JSON.stringify({portal:"shop"}),credentials:"include"})}catch{}},restoreSession:async()=>{const t=await z();return await Z(),t},me:Z,updateMe:t=>m("/api/auth/me/",{method:"PATCH",body:JSON.stringify(t)}),changePassword:(t,e)=>m("/api/auth/me/",{method:"PATCH",body:JSON.stringify({password:e,old_password:t})}),changeEmail:(t,e)=>m("/api/shop-portal/change-email/",{method:"POST",body:JSON.stringify({new_email:t,current_password:e})}),myProfile:()=>m("/api/shop-portal/profile/"),updateMyProfile:t=>m("/api/shop-portal/profile/",{method:"PATCH",body:JSON.stringify(t)}),myAddresses:()=>m("/api/shop-portal/delivery-locations/"),createAddress:t=>m("/api/shop-portal/delivery-locations/",{method:"POST",body:JSON.stringify(t)}),updateAddress:(t,e)=>m(`/api/shop-portal/delivery-locations/${t}/`,{method:"PATCH",body:JSON.stringify(e)}),deleteAddress:t=>m(`/api/shop-portal/delivery-locations/${t}/`,{method:"DELETE"}),passwordResetRequest:t=>i("/api/auth/password-reset/",{method:"POST",body:JSON.stringify({email:t})}),passwordResetConfirm:(t,e,n)=>i("/api/auth/password-reset/confirm/",{method:"POST",body:JSON.stringify({uid:t,token:e,new_password:n})}),brands:()=>m("/api/products/brands/"),myOrders:()=>X("/api/shop-portal/orders/","api.myOrders"),myOrder:t=>m(`/api/shop-portal/orders/${t}/`),cancelOrder:t=>m(`/api/shop-portal/orders/${t}/cancel/`,{method:"POST"}),myReturns:t=>X(`/api/shop-portal/returns/${t?`?order=${encodeURIComponent(t)}`:""}`,"api.myReturns"),createReturn:t=>m("/api/shop-portal/returns/",{method:"POST",body:JSON.stringify(t)}),withdrawReturn:t=>m(`/api/shop-portal/returns/${t}/cancel/`,{method:"POST"}),uploadReturnPhoto:(t,e)=>{const n=new FormData;return n.append("claim_item",t),n.append("file",e),n.append("media_type",e.type.startsWith("video/")?"video":"image"),m("/api/shop-portal/return-media/",{method:"POST",body:n})}};import{media as Jt,absolutizeApiUrl as L}from"efficient-web-builder/render/lib/media";import{analyzeLogoSvg as Dt,isSvgUrl as xt}from"efficient-web-builder/format/lib/logo/reverse-svg";import{getEditorSiteId as Ht}from"efficient-web-builder/render/lib/editor-site";import{shopRouteBase as Ft,webRuntimeSiteSlug as Y}from"efficient-web-builder/format/lib/web-runtime";import{readDealerList as Mt}from"../sections/dealer-finder.js";import{SIGN_UP_PATH as Bt,SIGN_UP_VERIFY_PATH as qt,SIGN_UP_WAITING_PATH as Gt,WORKSPACE_FINDS_PATH as Wt,WORKSPACE_FIND_OPEN_PATH as jt,signInUrlOf as zt,readLinkAnswer as Q,readSignUpAvailability as Kt,readSignUpSent as Xt,signUpAvailabilityPath as Vt}from"../sections/sign-up.js";function S(t){if(typeof t=="string")return t.startsWith("/media/")?Jt(t):t;if(Array.isArray(t))return t.map(S);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=n==="captions"&&s&&typeof s=="object"&&!Array.isArray(s)?Object.fromEntries(Object.entries(s).map(([l,u])=>[S(l),u])):S(s);return e}return t}import{PRODUCT_API_BASE as Qe}from"./origins.js";const tt=typeof window>"u"&&H!=="",Zt=tt?H:pt,Yt=Ft,b=()=>({baseUrl:Yt(),audience:null});function c(t,e){const n=e?`?process=${encodeURIComponent(e)}`:"";return`/api/v1${t}${n}`}const et=100,at=50;function J(t,e,n){const s=new URLSearchParams;for(const[l,u]of Object.entries(e))u!=null&&u!==""&&s.set(l,String(u));return s.set("pageSize",String(et)),n&&s.set("cursor",n),`/api/v1${t}?${s.toString()}`}function Qt(t,e){return J("/wheels",{process:t},e)}const rt=et;function te(t,e){return J("/wheels",{slug:t.join(",")},e)}function ee(t,e,n){return J("/products",{kind:t.join(","),make:e?.make,model:e?.model,year:e?.year,modification:e?.modification},n)}function ae(t){if(!t)return null;try{return new URL(t,"http://cursor.invalid").searchParams.get("cursor")}catch{return null}}async function D(t,e,n=()=>!1,s=()=>!1){const l=[];let u=null;try{for(let y=0;y<at;y++){const a=await i(await e(u),await d());if(l.push(...g(a)),u=ae(a.next),!u)break;if(s(l))return l}u&&console.warn(`[${t}] stopped at ${at} pages (${l.length} rows); catalog may be truncated`)}catch(y){if(n(y))throw y;console.warn(`[${t}] product API unavailable, returning []`,y)}return l}const nt=t=>t instanceof w&&t.status===400;function st(t){return t.flatMap(e=>e.kind==="alloy-wheel"?U([e]):[e])}async function ot(){return(await re()).host}async function re(){try{const{headers:t}=await import("next/headers"),e=await t(),n=u=>u?.split(",")[0]?.split(":")[0]?.trim().toLowerCase()||null,s=n(e.get(lt)??e.get("x-forwarded-host")??e.get("host")),l=n(e.get("host"));return{host:s,matchesRequestHost:s!==null&&s===l}}catch{return{host:null,matchesRequestHost:!1}}}async function ne(){try{const{headers:t}=await import("next/headers");return mt((await t()).get(gt))}catch{return null}}async function se(){try{const{headers:t}=await import("next/headers");return(await t()).get(ut)||null}catch{return null}}async function oe(){const t=await se();if(t)return`site=${encodeURIComponent(t)}`;const e=await ot();return e?`host=${encodeURIComponent(e)}`:""}async function h(t){if(typeof window<"u"){const e=Y();return e?C(t,`site=${encodeURIComponent(e)}`):t}return C(t,await oe())}function C(t,e){return e?`${t}${t.includes("?")?"&":"?"}${e}`:t}const ie="preview";async function ce(){if(typeof window<"u")return null;try{const{headers:t}=await import("next/headers");return(await t()).get(dt)}catch{return null}}async function de(){try{const{headers:t}=await import("next/headers");return(await t()).get("user-agent")}catch{return null}}async function x(t,e){const n=await ce();if(n===null)return[await h(t),await d(e)];const s=C(await h(t),`${ie}=${encodeURIComponent(n)}`),{next:l,cache:u,...y}=e??{},a=await d({...y,cache:"no-store"}),r=await de();return r&&(a.headers={...a.headers,"user-agent":r}),[s,a]}async function le(t){if(!tt)return;const[e,n]=await Promise.all([ot(),ne()]),s=ht(e,n,t);return Object.keys(s).length>0?s:void 0}async function d(t){const e=await le(wt(t)),n={baseUrl:Zt,...t};return e&&(n.headers={...e,...t?.headers}),n}const A=typeof window>"u";function E(t,e){const n=new URLSearchParams;for(const[l,u]of Object.entries(e))u!==void 0&&u!==""&&n.set(l,String(u));const s=n.toString();return`/api/v1/fitment${t}${s?`?${s}`:""}`}const He={listMakes:async t=>{if(A){const{fitmentData:n}=await import("./fitment-data.js");return n.makes(t)}const e=await i(E("/makes",{region:t}),b());return g(e)},listModels:async(t,e)=>{if(A){const{fitmentData:s}=await import("./fitment-data.js");return s.models(t,e)}const n=await i(E("/models",{make:t,region:e}),b());return g(n)},listYears:async(t,e,n)=>{if(A){const{fitmentData:l}=await import("./fitment-data.js");return l.years(t,e,n)}const s=await i(E("/years",{make:t,model:e,region:n}),b());return g(s)},listModifications:async(t,e,n,s)=>{if(A){const{fitmentData:u}=await import("./fitment-data.js");return u.modifications(t,e,n,s)}const l=await i(E("/modifications",{make:t,model:e,year:n,region:s}),b());return g(l)},getStockFitment:async(t,e,n,s,l)=>{if(A){const{fitmentData:u}=await import("./fitment-data.js");return u.stockFitment(t,e,n,s,l)}return i(E("/stock-fitment",{make:t,model:e,year:n,modification:s,region:l}),b())}};function ue(t){if(!/^https?:\/\//i.test(t))return!1;const e=(y,a=y.protocol,r=y.port)=>`${a}//${y.hostname}:${r}`,n=y=>{if(!y)return null;try{return new URL(y)}catch{return null}},s=n(t);if(!s)return!1;const l=new Set,u=n(process.env.NEXT_PUBLIC_MEDIA_URL);u&&l.add(e(u,"https:",""));for(const y of[process.env.NEXT_PUBLIC_API_URL,yt()]){const a=n(y);a&&l.add(e(a))}for(const y of(process.env.ASSET_CDN_HOSTS??"").split(",").map(a=>a.trim()).filter(Boolean))l.add(`https://${y}:`);return l.has(e(s))}const Fe={listWheels:async(t,e={})=>{const n=await D("products.listWheels",async s=>await h(Qt(t,s)),e.throwOnFailure?()=>!0:void 0,e.maxRows===void 0?void 0:s=>U([...s]).length>=e.maxRows);return U(S(n))},listWheelsBySlug:async(t,e={})=>{const n=[...new Set(t.map(a=>a.trim()).filter(Boolean))];if(n.length===0)return[];const s=[];for(let a=0;a<n.length;a+=rt)s.push(n.slice(a,a+rt));const l=await Promise.all(s.map(a=>D("products.listWheelsBySlug",async r=>await h(te(a,r)),e.throwOnFailure?()=>!0:nt))),u=new Set(n),y=l.flat().filter(a=>u.has(a.slug));return U(S(y))},listCatalog:async(t,e,n={})=>{if(t.length===0)throw new Error("products.listCatalog() needs at least one kind. An empty list would omit `kind`, which the contract reads as `alloy-wheel` — so the call would silently return the wheel catalog instead of nothing.");const s=await D("products.listCatalog",async l=>await h(ee(t,e,l)),n.throwOnFailure?()=>!0:nt,n.maxRows===void 0?void 0:l=>st([...l]).length>=n.maxRows);return st(S(s))},getWheel:async t=>F(S(await i(await h(c(`/wheels/${encodeURIComponent(t)}`)),await d()))),getTyre:async t=>S(await i(await h(c(`/tyres/${encodeURIComponent(t)}`)),await d())),listBundles:async(t={})=>{try{return await i(await h(c("/bundles")),await d())}catch(e){if(t.throwOnFailure)throw e;return[]}},getBundle:async t=>i(await h(c(`/bundles/${encodeURIComponent(t)}`)),await d()),listGalleryBuilds:async(t={})=>{const{process:e=null,wheelSlug:n=null}=t;if(typeof window>"u"){const{listGalleryBuilds:s}=await import("./gallery-builds-data.js");return S(s(e,n))}try{const s=new URLSearchParams;e&&s.set("process",e),n&&s.set("wheelSlug",n);const l=s.toString(),u=await i(`/api/v1/gallery-builds${l?`?${l}`:""}`,b());return S(g(u))}catch(s){return console.warn("[products.listGalleryBuilds] product API unavailable, returning []",s),[]}},getSite:async()=>i(await h(c("/site")),await d()),getSiteBySlug:async t=>i(`${c("/site")}?${new URLSearchParams({site:t})}`,typeof window>"u"?await d():void 0),listPages:async()=>S(await i(await h(c("/pages")),await d())),listPopups:async()=>i(await h(c("/popups")),await d()),listProductTemplates:async()=>{try{return await i(await h(c("/product-templates")),await d())}catch(t){return console.warn("[products.listProductTemplates] unavailable, returning []",t),[]}},listDynamicPages:async t=>{const e=t?`?recordType=${encodeURIComponent(t)}`:"";try{return await i(await h(`${c("/dynamic-pages")}${e}`),await d())}catch(n){if(n instanceof w&&n.status===404)return[];throw n}},getRecord:async(t,e)=>{try{return await i(await h(c(`/records/${encodeURIComponent(t)}/${encodeURIComponent(e)}`)),await d())}catch(n){if(n instanceof w&&n.status===404)return null;throw n}},listRecordKeys:async t=>{try{const e=await i(await h(c(`/records/${encodeURIComponent(t)}`)),await d({cache:"no-store"}));return Array.isArray(e?.keys)?e.keys.filter(n=>typeof n=="string"&&n!==""):[]}catch(e){if(e instanceof w&&e.status===404)return[];throw e}},listProductTypeChoices:async()=>{try{return await i(await h(c("/product-type-choices")),await d())}catch(t){return console.warn("[products.listProductTypeChoices] unavailable, returning []",t),[]}},listFieldUsage:async()=>{try{return await i(await h(c("/field-usage")),await d())}catch(t){return console.warn("[products.listFieldUsage] unavailable, returning []",t),[]}},getPage:async(t,e={})=>{const n=e.record?`?record=${encodeURIComponent(e.record)}`:"",[s,l]=await x(c(`/pages/${encodeURIComponent(t)}`)+n,e.revalidate!==void 0?{next:{revalidate:e.revalidate}}:void 0);return S(await i(s,l))},listBlogPosts:async(t={},{throwOnFailure:e=!1}={})=>{const n=t.category?`?category=${encodeURIComponent(t.category)}`:"";try{return(await i(c("/blog-posts")+n,await d())).map(l=>({...l,coverImage:L(l.coverImage)??""}))}catch(s){if(e)throw s;return console.warn("[products.listBlogPosts] blog API unavailable, returning []",s),[]}},getBlogPost:async t=>{const e=await i(c(`/blog-posts/${encodeURIComponent(t)}`),await d());return{...e,coverImage:L(e.coverImage)??""}},createOrder:async t=>i(c("/orders"),await d({method:"POST",body:JSON.stringify(t)})),createOrderAuthed:async t=>m(c("/orders"),await d({method:"POST",body:JSON.stringify(t)})),lookupOrder:async t=>i(c("/orders/lookup"),await d({method:"POST",body:JSON.stringify(t)})),createPaymentIntent:async t=>i(c("/payments/intent"),await d({method:"POST",body:JSON.stringify(t)})),releaseCheckout:async t=>i(c("/checkouts/release"),await d({method:"POST",body:JSON.stringify(t)})),createPaypalOrder:async t=>i(c("/payments/paypal/order"),await d({method:"POST",body:JSON.stringify(t)})),capturePaypalOrder:async t=>i(c("/payments/paypal/capture"),await d({method:"POST",body:JSON.stringify(t)})),createAfterpayCheckout:async t=>i(c("/payments/afterpay/checkout"),await d({method:"POST",body:JSON.stringify(t)})),captureAfterpayPayment:async t=>i(c("/payments/afterpay/capture"),await d({method:"POST",body:JSON.stringify(t)})),chargeSquare:async t=>i(c("/payments/square/charge"),await d({method:"POST",body:JSON.stringify(t)})),createGocardlessBillingRequest:async t=>i(c("/payments/gocardless/billing-request"),await d({method:"POST",body:JSON.stringify(t)})),completeGocardlessPayment:async t=>i(c("/payments/gocardless/complete"),await d({method:"POST",body:JSON.stringify(t)})),createZipCheckout:async t=>i(c("/payments/zip/checkout"),await d({method:"POST",body:JSON.stringify(t)})),captureZipPayment:async t=>i(c("/payments/zip/capture"),await d({method:"POST",body:JSON.stringify(t)})),createWorldpayCheckout:async t=>i(c("/payments/worldpay/checkout"),await d({method:"POST",body:JSON.stringify(t)})),confirmWorldpayPayment:async t=>i(c("/payments/worldpay/confirm"),await d({method:"POST",body:JSON.stringify(t)})),createKlarnaCheckout:async t=>i(c("/payments/klarna/checkout"),await d({method:"POST",body:JSON.stringify(t)})),captureKlarnaPayment:async t=>i(c("/payments/klarna/capture"),await d({method:"POST",body:JSON.stringify(t)})),createStockAlert:async t=>i(c("/stock-alerts"),await d({method:"POST",body:JSON.stringify(t)})),createPreOrderIntent:async t=>i(c("/pre-order-intents"),await d({method:"POST",body:JSON.stringify(t)})),createNewsletterSubscription:async t=>i(c("/newsletter-subscriptions"),await d({method:"POST",body:JSON.stringify(t)})),unsubscribeNewsletter:async t=>i(c("/newsletter-unsubscribe"),await d({method:"POST",body:JSON.stringify(t)})),captureCart:async t=>i(c("/carts"),await d({method:"POST",body:JSON.stringify(t)})),restoreCart:async t=>i(c("/carts/restore"),await d({method:"POST",body:JSON.stringify(t)})),unsubscribeCartReminders:async t=>i(c("/carts/unsubscribe"),await d({method:"POST",body:JSON.stringify(t)})),listReviews:async(t={})=>{const e=new URLSearchParams;t.limit&&e.set("limit",String(t.limit)),t.designCode&&e.set("designCode",t.designCode);const n=c("/reviews"),s=e.toString();try{return await i(await h(s?`${n}?${s}`:n),await d())}catch(l){return console.warn("[products.listReviews] product API unavailable, returning []",l),[]}},submitReview:async t=>i(c("/reviews"),await d({method:"POST",body:JSON.stringify(t)})),getForm:async t=>i(c(`/forms/${encodeURIComponent(t)}`),await d()),submitForm:async(t,e)=>i(c(`/forms/${encodeURIComponent(t)}/submissions`),await d({method:"POST",body:JSON.stringify(e)})),listShippingMethods:async()=>{try{return await i(c("/shipping-methods"),await d())}catch(t){return console.warn("[products.listShippingMethods] product API unavailable, returning []",t),[]}},listCountrySubdivisions:async t=>{try{return await i(c(`/countries/${encodeURIComponent(t)}/subdivisions`),await d())}catch(e){return console.warn("[products.listCountrySubdivisions] unavailable, returning []",e),[]}},quoteCart:async t=>{const e=c("/cart/quote"),n=await d({method:"POST",body:JSON.stringify(t)});return t.couponCode?(await V(e,n)).data:i(e,n)},validateCoupon:async t=>{const{data:e,asShopper:n}=await V(c("/coupons/validate"),await d({method:"POST",body:JSON.stringify(t)}));return{...e,askedAsShopper:n}},getHeaderSettings:async()=>{const t=M({method:"GET"}),e=await i(...await x(c("/header-settings"),{signal:t})),n=L(e.logoUrl);let s=null,l=null;if(n&&xt(n)&&ue(n)){const u=await Dt(n,t);u&&(s=u.reversed,l=u.inkIsDark)}return{...e,logoUrl:n,logoReversed:s,logoInkIsDark:l}},getThemeSettings:async()=>i(...await x(c("/theme-settings"))),getChatSettings:async()=>i(await h(c("/chat-settings")),await d())},Me={listServices:async()=>{try{return await i(c("/bookings/services"),await d())}catch(t){return console.warn("[bookings.listServices] API unavailable, returning []",t),{results:[],currency:"USD"}}},getAvailability:async(t,e)=>i(c(`/bookings/availability?service=${encodeURIComponent(t)}&date=${e}`),await d()),create:async t=>i(c("/bookings"),await d({method:"POST",body:JSON.stringify(t)})),get:async t=>i(c(`/bookings/manage/${encodeURIComponent(t)}`),await d()),cancel:async t=>i(c(`/bookings/manage/${encodeURIComponent(t)}/cancel`),await d({method:"POST"})),reschedule:async(t,e)=>i(c(`/bookings/manage/${encodeURIComponent(t)}/reschedule`),await d({method:"POST",body:JSON.stringify({startAt:e})})),createPaymentIntent:async t=>i(c("/bookings/payments/intent"),await d({method:"POST",body:JSON.stringify({manageToken:t})}))};class pe extends Error{slug;count;constructor(e,n){super(`Slug "${e}" exists on ${n} websites; a site is required to pick one.`),this.slug=e,this.count=n,this.name="AmbiguousPageSlugError"}}const $=(t,e,n)=>{const s=new URLSearchParams({...e?{site:e}:{},...n?{draft:"1"}:{}}).toString();return`/api/storefront/${t}/${s?`?${s}`:""}`},I=t=>`/api/storefront/sites/${encodeURIComponent(t)}/`,ye=t=>`${I(t)}currencies/`,fe="/api/storefront/media/ingest/";class he extends Error{constructor(){super("This editor is not connected to a website, so an upload has nowhere to go. Open the page from the website the file should belong to, then try again."),this.name="MediaUploadDestinationError"}}function me(){const t=Ht();if(!t)throw new he;return`${fe}?${new URLSearchParams({site:t})}`}const ge="X-Puck-Media-Manifest",it=St.contentHash,N={"X-Media-Manifest":it,[ge]:it},Be=ct({});function ct(t){return(e,n={})=>{const s=$t(),l=t.headers||s?{...s?{"Accept-Language":s}:{},...t.headers,...n.headers}:void 0;return i(e,{...n,...t.baseUrl!==void 0?{baseUrl:t.baseUrl}:{},...l?{headers:l}:{},audience:t.audience??Ut()})}}function we(t={}){const e=ct(t),n=t.siteDrafts===!0,s=a=>$("header-settings",a,n),l=a=>$("theme-settings",a,n),u=a=>$("chat-settings",a,n),y=a=>$("social-settings",a,n);return{findPageBySlug:async(a,r,o)=>{const p=new URLSearchParams({slug:a});o&&p.set("site",o);const f=await e(`/api/storefront/pages/?${p.toString()}`,{token:r}),P=g(f);if(!o&&P.length>1)throw new pe(a,P.length);return P[0]??null},getPageById:(a,r)=>e(`/api/storefront/pages/${a}/`,{token:r}),saveLayout:(a,r,o,p,f)=>e(`/api/storefront/pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r,expected_updated_at:p,...f?{client_id:f}:{}}),token:o}),duplicatePage:(a,r,o)=>e(`/api/storefront/pages/${a}/duplicate/`,{method:"POST",body:JSON.stringify({title:r.title,slug:r.slug}),token:o}),geocode:(a,r,o)=>e(`/api/storefront/geocode/?${new URLSearchParams(o?{q:a,country:o}:{q:a})}`,{token:r}),listBlockSources:a=>e("/api/storefront/block-sources/",{token:a}),listRecordTypes:a=>e("/api/storefront/record-types/",{token:a}),createPagePreviewLink:(a,r)=>e(`/api/storefront/pages/${a}/preview-link/`,{method:"POST",token:r}),claimPageEditLock:(a,r,o,p=!1)=>e(`/api/storefront/pages/${a}/edit-lock/`,{method:"POST",body:JSON.stringify({client_id:o,takeover:p}),token:r}),releasePageEditLock:(a,r)=>e(`/api/storefront/pages/${a}/edit-lock/`,{method:"DELETE",token:r}),createTemplate:(a,r,o)=>e("/api/storefront/page-templates/",{method:"POST",body:JSON.stringify({name:a,layout:r}),headers:N,token:o}),getTemplate:(a,r)=>e(`/api/storefront/page-templates/${a}/`,{token:r}),saveTemplateLayout:(a,r,o)=>e(`/api/storefront/page-templates/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r}),headers:N,token:o}),listTemplatePages:async(a,r)=>{const o=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(a)}`,{token:r});return g(o)},getPageLibrary:async a=>{const r=await e("/api/storefront/page-templates/?is_page_library=true&is_active=true",{token:a});return g(r)[0]??null},getTemplateLibrary:(a,r)=>e(`/api/storefront/pages/template-library/?site=${encodeURIComponent(a)}`,{token:r}),createPageFromTemplate:(a,r)=>e(`/api/storefront/pages/from-template/${n?"?draft=1":""}`,{method:"POST",body:JSON.stringify(a),token:r}),findTemplatePageBySlug:async(a,r,o)=>{const p=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(a)}&slug=${encodeURIComponent(r)}`,{token:o});return g(p)[0]??null},createTemplatePage:(a,r,o)=>e("/api/storefront/template-pages/",{method:"POST",body:JSON.stringify({template:a,...r}),headers:N,token:o}),saveTemplatePageLayout:(a,r,o)=>e(`/api/storefront/template-pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r}),headers:N,token:o}),deleteTemplatePage:(a,r,o)=>e(`/api/storefront/template-pages/${a}/`,{method:"DELETE",token:r,...o?.keepalive?{keepalive:!0}:{}}),listPages:async(a,r)=>{const o=new URLSearchParams({no_page:"true"});r&&o.set("site",r);const p=await e(`/api/storefront/pages/?${o.toString()}`,{token:a});return g(p)},createPage:(a,r,o,p)=>e("/api/storefront/pages/",{method:"POST",body:JSON.stringify({title:a,slug:r,layout:o}),token:p}),deletePage:(a,r)=>e(`/api/storefront/pages/${a}/`,{method:"DELETE",token:r}),getHeaderSettings:(a,r)=>e(s(r),{token:a}),listMenus:async(a,r)=>{const o=new URLSearchParams({no_page:"true"});r&&o.set("site",r);const p=await e(`/api/storefront/menus/?${o}`,{token:a});return g(p)},listBlogPosts:async(a,r={})=>{const o=new URLSearchParams({no_page:"true"});r.visibleOnly&&o.set("is_visible","true"),r.siteId&&o.set("site",r.siteId);const p=await e(`/api/storefront/blog-posts/?${o.toString()}`,{token:a});return g(p)},listFieldUsage:async(a,r)=>{const o=await e(`/api/storefront/field-usage/?site=${encodeURIComponent(r)}`,{token:a});return Array.isArray(o?.entries)?o.entries:[]},listCategories:async(a,r={})=>{const o=new URLSearchParams({no_page:"true"});r.visibleOnly&&o.set("is_visible","true"),r.siteId&&o.set("site",r.siteId);const p=await e(`/api/storefront/categories/?${o.toString()}`,{token:a});return[...g(p)].sort((P,_)=>P.sort_order-_.sort_order||P.name.localeCompare(_.name))},listForms:async(a,r={})=>{const o=new URLSearchParams({no_page:"true"});r.siteId&&o.set("site",r.siteId);const p=await e(`/api/storefront/forms/?${o.toString()}`,{token:a});return[...g(p)].sort((P,_)=>P.title.localeCompare(_.title))},listWheelSummaries:async(a,r={})=>{const o=new URLSearchParams;r.siteId&&o.set("site",r.siteId);const p=o.toString(),f=await e(`/api/storefront/wheel-curations/summaries/${p?`?${p}`:""}`,{token:a});return S(f)},listProducts:async(a,r={})=>{const o=new URLSearchParams;r.kinds?.length&&o.set("kind",r.kinds.join(",")),r.siteId&&o.set("site",r.siteId);const p=o.toString(),f=await e(`/api/storefront/products/${p?`?${p}`:""}`,{token:a});return S(f)},getWheelDetail:async(a,r,o={})=>{const p=new URLSearchParams({slug:r});return o.siteId&&p.set("site",o.siteId),F(S(await e(`/api/storefront/wheel-curations/detail/?${p.toString()}`,{token:a})))},updateHeaderSettings:(a,r,o)=>e(s(o),{method:"PATCH",body:JSON.stringify(a),token:r}),getSite:(a,r)=>e(I(a),{token:r}),listSites:async a=>{const r=await e("/api/storefront/sites/?no_page=true",{token:a});return g(r)},listSiteCurrencies:async(a,r)=>{const o=await e(ye(a),{token:r});return Array.isArray(o)?o:[]},publishSite:(a,r)=>e(`${I(a)}publish/`,{method:"POST",token:r}),getSiteLiveState:(a,r)=>e(`${I(a)}live-state/`,{token:r}),getThemeSettings:(a,r)=>e(l(r),{token:a}),updateThemeSettings:(a,r,o)=>e(l(o),{method:"PATCH",body:JSON.stringify(a),token:r}),getMyPreferences:async a=>(await e("/api/auth/me/",{token:a})).preferences??{},updateMyPreferences:(a,r)=>e("/api/auth/me/",{method:"PATCH",body:JSON.stringify({preferences:a}),token:r}),getChatSettings:(a,r)=>e(u(r),{token:a}),updateChatSettings:(a,r,o)=>e(u(o),{method:"PATCH",body:JSON.stringify(a),token:r}),getSocialSettings:(a,r)=>e(y(r),{token:a}),updateSocialSettings:(a,r,o)=>e(y(o),{method:"PATCH",body:JSON.stringify(a),token:r}),uploadHeaderLogo:(a,r,o)=>{const p=new FormData;return p.append("logo",a),e(s(o),{method:"PATCH",body:p,token:r})},clearHeaderLogo:(a,r)=>e(s(r),{method:"PATCH",body:JSON.stringify({logo:null}),token:a}),setHeaderLogoFromAsset:(a,r,o)=>e(s(o),{method:"PATCH",body:JSON.stringify({logo_asset_id:a}),token:r}),uploadMedia:async(a,r)=>{const o=new FormData;return o.append("file",a),e(me(),{method:"POST",body:o,token:r})},listMedia:async(a,r)=>{const o=new URLSearchParams({no_page:"true"});r&&o.set("kind",r);const p=await e(`/api/storefront/media-assets/?${o.toString()}`,{token:a});return g(p)}}}const qe=we({siteDrafts:!0});function Se(t){const e=t.trim();return e?`/api/v1/dealers?${new URLSearchParams({near:e}).toString()}`:"/api/v1/dealers"}async function Ge(t){return Mt(await i(Se(t)))}const T={audience:null,baseUrl:""};async function We(t,e){return Kt(await i(Vt(t,e),T))}async function je(t){return Xt(await i(Bt,{...T,method:"POST",body:JSON.stringify(t)}))}async function ze(t){try{const e=await i(qt,{...T,method:"POST",body:JSON.stringify({token:t})});return Q(202,e)}catch(e){if(e instanceof w)return Q(e.status,e.data);throw e}}async function Ke(t,e){await i(Gt,{...T,method:"POST",body:JSON.stringify({email:e.trim(),...t?{product:t}:{}})})}async function Xe(t,e){await i(Wt,{...T,method:"POST",body:JSON.stringify({email:e.trim(),...t?{product:t}:{}})})}async function Ve(t){try{return zt(await i(jt,{...T,method:"POST",body:JSON.stringify({token:t})}))}catch(e){if(e instanceof w&&Pe.has(e.status))return"";throw e}}const Pe=new Set([400,404,410]);export{Ot as API_URL,pe as AmbiguousPageSlugError,w as ApiError,At as BROWSER_READ_TIMEOUT_MS,Tt as EFFICIENT_CLIENT_CLOSED_MESSAGE,he as MediaUploadDestinationError,ie as PREVIEW_PARAM,Qe as PRODUCT_API_BASE,Rt as SERVER_READ_TIMEOUT_MS,k as SERVER_UNREACHABLE_MESSAGE,v as STATUS_NETWORK_ERROR,Be as adminFetch,Lt as api,i as apiFetch,C as appendSiteQuery,Xe as askForWorkspaces,je as askToSignUp,Me as bookings,we as createStorefrontAdmin,Se as dealersPath,M as defaultRequestDeadline,me as editorMediaUploadPath,Ut as editorPortalAudience,$t as editorRequestLanguage,Ge as fetchDealers,We as fetchSignUpAvailability,He as fitment,Ke as joinSignUpWaitingList,ze as openSignUpLink,Ve as openWorkspaceFind,Fe as products,Et as readDeadlineMs,ne as resolveClientIp,S as resolveMediaUrls,ce as resolvePreviewToken,ot as resolveSiteHost,re as resolveSiteHostSource,se as resolveSiteSlug,Ne as setEditorLanguage,Ie as setEditorPortalAudience,qe as storefrontAdmin};
1
+ import{PREVIEW_TOKEN_HEADER as dt,SITE_HOST_HEADER as lt,SITE_SLUG_HEADER as ut}from"../site-headers.js";import{PRODUCT_API_BASE as pt,PRODUCT_BACKEND_URL as F,productBackendUrlNow as yt}from"./origins.js";import{listRows as h}from"./list-rows.js";import{parseOption as ft}from"efficient-shell/format";import{backendHopHeaders as ht,clientIpFromForwardedFor as mt,FORWARDED_FOR_HEADER as gt,hopCachingOf as wt}from"../forwarded-for.js";import St from"efficient-web-builder/format/lib/document/media-manifest.json";import{auth as O}from"../auth.js";import{efficientClientOpen as Pt}from"efficient-easel/screen/lib/session";import{listableWheelSummaries as U}from"../wheels/listable-wheels.js";import{dropRenderlessFinishes as H}from"../wheels/renderable-finishes.js";const Ot=process.env.NEXT_PUBLIC_API_URL??"http://localhost:8000";class w extends Error{status;data;constructor(e,n,s){super(n),this.status=e,this.data=s}}const v="Unable to reach the server. This could be a problem with your internet connection, or the server may be undergoing maintenance or an upgrade. Please try again shortly.",bt=new Set([502,503,504]),k=0,Tt="This editor runs on its host's own backend, which does not serve this request.",Rt=5e3,At=15e3,_t=()=>typeof window>"u"?Rt:At;function M(t){const e=(t.method??"GET").toUpperCase();if(!(t.body!=null||e!=="GET"&&e!=="HEAD")&&!(t.audience!=null&&t.audience!=="shop")&&typeof AbortSignal?.timeout=="function")return AbortSignal.timeout(_t())}const B=t=>t instanceof Error&&t.name==="TimeoutError",q=(t,e)=>bt.has(t)?v:e,Et=["admin","venue"];let G="admin";function Ie(t){G=ft(Et,"admin",t)}function Ut(){return G}const $t=/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/;let W=null;function Ne(t){W=t&&$t.test(t)?t:null}function Ct(){return W}function It(t){if(typeof window>"u"||!t.startsWith("/api/v1/"))return t;const e=Y();return!e||/[?&]site=/.test(t)?t:$(t,`site=${encodeURIComponent(e)}`)}async function i(t,e={}){const{token:n,baseUrl:s,headers:l,audience:u,...y}=e;if(typeof window<"u"&&!Pt())throw new w(k,Tt,null);if(typeof window>"u"&&s===void 0)throw new Error(`apiFetch(${JSON.stringify(t)}) ran on the server without an explicit baseUrl. The API_URL default it would inherit is browser-only (the prod image bakes NEXT_PUBLIC_API_URL="" for same-origin use, which a Node fetch cannot resolve). Pass a base explicitly: \`await backendOpts()\` (or baseUrl: PRODUCT_FETCH_BASE) for product reads, or the server-only PRODUCT_BACKEND_URL env for other backend surfaces.`);const a=typeof FormData<"u"&&y.body instanceof FormData;let r;try{r=await fetch(`${s??Ot}${It(t)}`,{...y,headers:{...a?{}:{"Content-Type":"application/json"},...n?{Authorization:`Bearer ${n}`}:{},...u===null?{}:{"X-Portal-Audience":u??"shop"},...l},signal:y.signal??M({...y,audience:u})})}catch(f){throw f instanceof TypeError||B(f)?new w(k,v,null):f}let o;try{o=await r.text()}catch(f){throw B(f)?new w(k,v,null):f}let p=null;if(o)try{p=JSON.parse(o)}catch{throw new w(r.status,r.ok?"Expected JSON but received a non-JSON response":q(r.status,r.statusText),o)}if(!r.ok){const f=(p&&typeof p=="object"&&"detail"in p&&typeof p.detail=="string"?p.detail:null)??q(r.status,r.statusText);throw new w(r.status,f,p)}return p}let R=null;async function j(){return R||(R=Nt().finally(()=>{R=null}),R)}async function Nt(){const t=O.takeLegacyRefresh(),e=await Lt.refresh(t??void 0);return O.setTokens(e.access),e.access}async function z(){return O.getAccess()??j()}async function g(t,e={}){let n;try{n=await z()}catch{throw O.clear(),new w(401,"Not signed in",null)}try{return await i(t,{...e,token:n})}catch(s){if(!(s instanceof w)||s.status!==401)throw s;try{const l=await j();return await i(t,{...e,token:l})}catch{throw O.clear(),s}}}const vt=100,K=20;function kt(t){if(!t)return null;try{return new URL(t,"http://page.invalid").searchParams.get("page")}catch{return null}}async function X(t,e){const[n,s=""]=t.split("?"),l=[];let u="1";for(let y=0;y<K&&u;y++){const a=new URLSearchParams(s);a.set("page_size",String(vt)),u!=="1"&&a.set("page",u);const r=await g(`${n}?${a.toString()}`);l.push(...h(r)),u=kt(r.next)}return u&&console.warn(`[${e}] stopped at ${K} pages (${l.length} rows); list may be truncated`),l}async function V(t,e={}){if(O.getAccess())try{return{data:await g(t,e),asShopper:!0}}catch(n){if(!(n instanceof w)||n.status!==401)throw n}return{data:await i(t,e),asShopper:!1}}async function Z(){const t=await g("/api/auth/me/");if(t.portal!=="shop")throw O.clear(),new w(403,"This session is not valid for this shop.",null);return t}const Lt={login:(t,e)=>i("/api/auth/login/",{method:"POST",body:JSON.stringify({email:t,password:e,portal:"shop"}),credentials:"include"}),refresh:t=>i("/api/auth/refresh/",{method:"POST",body:JSON.stringify(t?{refresh:t,portal:"shop"}:{portal:"shop"}),credentials:"include"}),logout:async()=>{O.clear();try{await i("/api/auth/logout/",{method:"POST",body:JSON.stringify({portal:"shop"}),credentials:"include"})}catch{}},restoreSession:async()=>{const t=await z();return await Z(),t},me:Z,updateMe:t=>g("/api/auth/me/",{method:"PATCH",body:JSON.stringify(t)}),changePassword:(t,e)=>g("/api/auth/me/",{method:"PATCH",body:JSON.stringify({password:e,old_password:t})}),changeEmail:(t,e)=>g("/api/shop-portal/change-email/",{method:"POST",body:JSON.stringify({new_email:t,current_password:e})}),myProfile:()=>g("/api/shop-portal/profile/"),updateMyProfile:t=>g("/api/shop-portal/profile/",{method:"PATCH",body:JSON.stringify(t)}),myAddresses:()=>g("/api/shop-portal/delivery-locations/"),createAddress:t=>g("/api/shop-portal/delivery-locations/",{method:"POST",body:JSON.stringify(t)}),updateAddress:(t,e)=>g(`/api/shop-portal/delivery-locations/${t}/`,{method:"PATCH",body:JSON.stringify(e)}),deleteAddress:t=>g(`/api/shop-portal/delivery-locations/${t}/`,{method:"DELETE"}),passwordResetRequest:t=>i("/api/auth/password-reset/",{method:"POST",body:JSON.stringify({email:t})}),passwordResetConfirm:(t,e,n)=>i("/api/auth/password-reset/confirm/",{method:"POST",body:JSON.stringify({uid:t,token:e,new_password:n})}),brands:()=>g("/api/products/brands/"),myOrders:()=>X("/api/shop-portal/orders/","api.myOrders"),myOrder:t=>g(`/api/shop-portal/orders/${t}/`),cancelOrder:t=>g(`/api/shop-portal/orders/${t}/cancel/`,{method:"POST"}),myReturns:t=>X(`/api/shop-portal/returns/${t?`?order=${encodeURIComponent(t)}`:""}`,"api.myReturns"),createReturn:t=>g("/api/shop-portal/returns/",{method:"POST",body:JSON.stringify(t)}),withdrawReturn:t=>g(`/api/shop-portal/returns/${t}/cancel/`,{method:"POST"}),uploadReturnPhoto:(t,e)=>{const n=new FormData;return n.append("claim_item",t),n.append("file",e),n.append("media_type",e.type.startsWith("video/")?"video":"image"),g("/api/shop-portal/return-media/",{method:"POST",body:n})}};import{media as Jt,absolutizeApiUrl as L}from"efficient-web-builder/render/lib/media";import{analyzeLogoSvg as Dt,isSvgUrl as xt}from"efficient-web-builder/format/lib/logo/reverse-svg";import{getEditorSiteId as Ft}from"efficient-web-builder/render/lib/editor-site";import{shopRouteBase as Ht,webRuntimeSiteSlug as Y}from"efficient-web-builder/format/lib/web-runtime";import{readDealerList as Mt}from"../sections/dealer-finder.js";import{SIGN_UP_PATH as Bt,SIGN_UP_VERIFY_PATH as qt,SIGN_UP_WAITING_PATH as Gt,WORKSPACE_FINDS_PATH as Wt,WORKSPACE_FIND_OPEN_PATH as jt,signInUrlOf as zt,readLinkAnswer as Q,readSignUpAvailability as Kt,readSignUpSent as Xt,signUpAvailabilityPath as Vt}from"../sections/sign-up.js";function S(t){if(typeof t=="string")return t.startsWith("/media/")?Jt(t):t;if(Array.isArray(t))return t.map(S);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=n==="captions"&&s&&typeof s=="object"&&!Array.isArray(s)?Object.fromEntries(Object.entries(s).map(([l,u])=>[S(l),u])):S(s);return e}return t}import{PRODUCT_API_BASE as Qe}from"./origins.js";const tt=typeof window>"u"&&F!=="",Zt=tt?F:pt,Yt=Ht,b=()=>({baseUrl:Yt(),audience:null});function c(t,e){const n=e?`?process=${encodeURIComponent(e)}`:"";return`/api/v1${t}${n}`}const et=100,at=50;function J(t,e,n){const s=new URLSearchParams;for(const[l,u]of Object.entries(e))u!=null&&u!==""&&s.set(l,String(u));return s.set("pageSize",String(et)),n&&s.set("cursor",n),`/api/v1${t}?${s.toString()}`}function Qt(t,e){return J("/wheels",{process:t},e)}const rt=et;function te(t,e){return J("/wheels",{slug:t.join(",")},e)}function ee(t,e,n){return J("/products",{kind:t.join(","),make:e?.make,model:e?.model,year:e?.year,modification:e?.modification},n)}function ae(t){if(!t)return null;try{return new URL(t,"http://cursor.invalid").searchParams.get("cursor")}catch{return null}}async function D(t,e,n=()=>!1,s=()=>!1){const l=[];let u=null;try{for(let y=0;y<at;y++){const a=await i(await e(u),await d());if(l.push(...h(a)),u=ae(a.next),!u)break;if(s(l))return l}u&&console.warn(`[${t}] stopped at ${at} pages (${l.length} rows); catalog may be truncated`)}catch(y){if(n(y))throw y;console.warn(`[${t}] product API unavailable, returning []`,y)}return l}const nt=t=>t instanceof w&&t.status===400;function st(t){return t.flatMap(e=>e.kind==="alloy-wheel"?U([e]):[e])}async function ot(){return(await re()).host}async function re(){try{const{headers:t}=await import("next/headers"),e=await t(),n=u=>u?.split(",")[0]?.split(":")[0]?.trim().toLowerCase()||null,s=n(e.get(lt)??e.get("x-forwarded-host")??e.get("host")),l=n(e.get("host"));return{host:s,matchesRequestHost:s!==null&&s===l}}catch{return{host:null,matchesRequestHost:!1}}}async function ne(){try{const{headers:t}=await import("next/headers");return mt((await t()).get(gt))}catch{return null}}async function se(){try{const{headers:t}=await import("next/headers");return(await t()).get(ut)||null}catch{return null}}async function oe(){const t=await se();if(t)return`site=${encodeURIComponent(t)}`;const e=await ot();return e?`host=${encodeURIComponent(e)}`:""}async function m(t){if(typeof window<"u"){const e=Y();return e?$(t,`site=${encodeURIComponent(e)}`):t}return $(t,await oe())}function $(t,e){return e?`${t}${t.includes("?")?"&":"?"}${e}`:t}const ie="preview";async function ce(){if(typeof window<"u")return null;try{const{headers:t}=await import("next/headers");return(await t()).get(dt)}catch{return null}}async function de(){try{const{headers:t}=await import("next/headers");return(await t()).get("user-agent")}catch{return null}}async function x(t,e){const n=await ce();if(n===null)return[await m(t),await d(e)];const s=$(await m(t),`${ie}=${encodeURIComponent(n)}`),{next:l,cache:u,...y}=e??{},a=await d({...y,cache:"no-store"}),r=await de();return r&&(a.headers={...a.headers,"user-agent":r}),[s,a]}async function le(t){if(!tt)return;const[e,n]=await Promise.all([ot(),ne()]),s=ht(e,n,t);return Object.keys(s).length>0?s:void 0}async function d(t){const e=await le(wt(t)),n={baseUrl:Zt,...t};return e&&(n.headers={...e,...t?.headers}),n}const A=typeof window>"u";function _(t,e){const n=new URLSearchParams;for(const[l,u]of Object.entries(e))u!==void 0&&u!==""&&n.set(l,String(u));const s=n.toString();return`/api/v1/fitment${t}${s?`?${s}`:""}`}const Fe={listMakes:async t=>{if(A){const{fitmentData:n}=await import("./fitment-data.js");return n.makes(t)}const e=await i(_("/makes",{region:t}),b());return h(e)},listModels:async(t,e)=>{if(A){const{fitmentData:s}=await import("./fitment-data.js");return s.models(t,e)}const n=await i(_("/models",{make:t,region:e}),b());return h(n)},listYears:async(t,e,n)=>{if(A){const{fitmentData:l}=await import("./fitment-data.js");return l.years(t,e,n)}const s=await i(_("/years",{make:t,model:e,region:n}),b());return h(s)},listModifications:async(t,e,n,s)=>{if(A){const{fitmentData:u}=await import("./fitment-data.js");return u.modifications(t,e,n,s)}const l=await i(_("/modifications",{make:t,model:e,year:n,region:s}),b());return h(l)},getStockFitment:async(t,e,n,s,l)=>{if(A){const{fitmentData:u}=await import("./fitment-data.js");return u.stockFitment(t,e,n,s,l)}return i(_("/stock-fitment",{make:t,model:e,year:n,modification:s,region:l}),b())}};function ue(t){if(!/^https?:\/\//i.test(t))return!1;const e=(y,a=y.protocol,r=y.port)=>`${a}//${y.hostname}:${r}`,n=y=>{if(!y)return null;try{return new URL(y)}catch{return null}},s=n(t);if(!s)return!1;const l=new Set,u=n(process.env.NEXT_PUBLIC_MEDIA_URL);u&&l.add(e(u,"https:",""));for(const y of[process.env.NEXT_PUBLIC_API_URL,yt()]){const a=n(y);a&&l.add(e(a))}for(const y of(process.env.ASSET_CDN_HOSTS??"").split(",").map(a=>a.trim()).filter(Boolean))l.add(`https://${y}:`);return l.has(e(s))}const He={listWheels:async(t,e={})=>{const n=await D("products.listWheels",async s=>await m(Qt(t,s)),e.throwOnFailure?()=>!0:void 0,e.maxRows===void 0?void 0:s=>U([...s]).length>=e.maxRows);return U(S(n))},listWheelsBySlug:async(t,e={})=>{const n=[...new Set(t.map(a=>a.trim()).filter(Boolean))];if(n.length===0)return[];const s=[];for(let a=0;a<n.length;a+=rt)s.push(n.slice(a,a+rt));const l=await Promise.all(s.map(a=>D("products.listWheelsBySlug",async r=>await m(te(a,r)),e.throwOnFailure?()=>!0:nt))),u=new Set(n),y=l.flat().filter(a=>u.has(a.slug));return U(S(y))},listCatalog:async(t,e,n={})=>{if(t.length===0)throw new Error("products.listCatalog() needs at least one kind. An empty list would omit `kind`, which the contract reads as `alloy-wheel` — so the call would silently return the wheel catalog instead of nothing.");const s=await D("products.listCatalog",async l=>await m(ee(t,e,l)),n.throwOnFailure?()=>!0:nt,n.maxRows===void 0?void 0:l=>st([...l]).length>=n.maxRows);return st(S(s))},getWheel:async t=>H(S(await i(await m(c(`/wheels/${encodeURIComponent(t)}`)),await d()))),getTyre:async t=>S(await i(await m(c(`/tyres/${encodeURIComponent(t)}`)),await d())),listBundles:async(t={})=>{try{return await i(await m(c("/bundles")),await d())}catch(e){if(t.throwOnFailure)throw e;return[]}},getBundle:async t=>i(await m(c(`/bundles/${encodeURIComponent(t)}`)),await d()),listGalleryBuilds:async(t={})=>{const{process:e=null,wheelSlug:n=null}=t;if(typeof window>"u"){const{listGalleryBuilds:s}=await import("./gallery-builds-data.js");return S(s(e,n))}try{const s=new URLSearchParams;e&&s.set("process",e),n&&s.set("wheelSlug",n);const l=s.toString(),u=await i(`/api/v1/gallery-builds${l?`?${l}`:""}`,b());return S(h(u))}catch(s){return console.warn("[products.listGalleryBuilds] product API unavailable, returning []",s),[]}},getSite:async()=>i(await m(c("/site")),await d()),getSiteBySlug:async t=>i(`${c("/site")}?${new URLSearchParams({site:t})}`,typeof window>"u"?await d():void 0),listPages:async()=>S(await i(await m(c("/pages")),await d())),listPopups:async()=>i(await m(c("/popups")),await d()),listProductTemplates:async()=>{try{return await i(await m(c("/product-templates")),await d())}catch(t){return console.warn("[products.listProductTemplates] unavailable, returning []",t),[]}},listDynamicPages:async t=>{const e=t?`?recordType=${encodeURIComponent(t)}`:"";try{return await i(await m(`${c("/dynamic-pages")}${e}`),await d())}catch(n){if(n instanceof w&&n.status===404)return[];throw n}},getRecord:async(t,e)=>{try{return await i(await m(c(`/records/${encodeURIComponent(t)}/${encodeURIComponent(e)}`)),await d())}catch(n){if(n instanceof w&&n.status===404)return null;throw n}},listRecordKeys:async t=>{try{const e=await i(await m(c(`/records/${encodeURIComponent(t)}`)),await d({cache:"no-store"}));return Array.isArray(e?.keys)?e.keys.filter(n=>typeof n=="string"&&n!==""):[]}catch(e){if(e instanceof w&&e.status===404)return[];throw e}},listProductTypeChoices:async()=>{try{return await i(await m(c("/product-type-choices")),await d())}catch(t){return console.warn("[products.listProductTypeChoices] unavailable, returning []",t),[]}},listFieldUsage:async()=>{try{return await i(await m(c("/field-usage")),await d())}catch(t){return console.warn("[products.listFieldUsage] unavailable, returning []",t),[]}},getPage:async(t,e={})=>{const n=e.record?`?record=${encodeURIComponent(e.record)}`:"",[s,l]=await x(c(`/pages/${encodeURIComponent(t)}`)+n,e.revalidate!==void 0?{next:{revalidate:e.revalidate}}:void 0);return S(await i(s,l))},listBlogPosts:async(t={},{throwOnFailure:e=!1}={})=>{const n=t.category?`?category=${encodeURIComponent(t.category)}`:"";try{return(await i(c("/blog-posts")+n,await d())).map(l=>({...l,coverImage:L(l.coverImage)??""}))}catch(s){if(e)throw s;return console.warn("[products.listBlogPosts] blog API unavailable, returning []",s),[]}},getBlogPost:async t=>{const e=await i(c(`/blog-posts/${encodeURIComponent(t)}`),await d());return{...e,coverImage:L(e.coverImage)??""}},createOrder:async t=>i(c("/orders"),await d({method:"POST",body:JSON.stringify(t)})),createOrderAuthed:async t=>g(c("/orders"),await d({method:"POST",body:JSON.stringify(t)})),lookupOrder:async t=>i(c("/orders/lookup"),await d({method:"POST",body:JSON.stringify(t)})),createPaymentIntent:async t=>i(c("/payments/intent"),await d({method:"POST",body:JSON.stringify(t)})),releaseCheckout:async t=>i(c("/checkouts/release"),await d({method:"POST",body:JSON.stringify(t)})),createPaypalOrder:async t=>i(c("/payments/paypal/order"),await d({method:"POST",body:JSON.stringify(t)})),capturePaypalOrder:async t=>i(c("/payments/paypal/capture"),await d({method:"POST",body:JSON.stringify(t)})),createAfterpayCheckout:async t=>i(c("/payments/afterpay/checkout"),await d({method:"POST",body:JSON.stringify(t)})),captureAfterpayPayment:async t=>i(c("/payments/afterpay/capture"),await d({method:"POST",body:JSON.stringify(t)})),chargeSquare:async t=>i(c("/payments/square/charge"),await d({method:"POST",body:JSON.stringify(t)})),createGocardlessBillingRequest:async t=>i(c("/payments/gocardless/billing-request"),await d({method:"POST",body:JSON.stringify(t)})),completeGocardlessPayment:async t=>i(c("/payments/gocardless/complete"),await d({method:"POST",body:JSON.stringify(t)})),createZipCheckout:async t=>i(c("/payments/zip/checkout"),await d({method:"POST",body:JSON.stringify(t)})),captureZipPayment:async t=>i(c("/payments/zip/capture"),await d({method:"POST",body:JSON.stringify(t)})),createWorldpayCheckout:async t=>i(c("/payments/worldpay/checkout"),await d({method:"POST",body:JSON.stringify(t)})),confirmWorldpayPayment:async t=>i(c("/payments/worldpay/confirm"),await d({method:"POST",body:JSON.stringify(t)})),createKlarnaCheckout:async t=>i(c("/payments/klarna/checkout"),await d({method:"POST",body:JSON.stringify(t)})),captureKlarnaPayment:async t=>i(c("/payments/klarna/capture"),await d({method:"POST",body:JSON.stringify(t)})),createStockAlert:async t=>i(c("/stock-alerts"),await d({method:"POST",body:JSON.stringify(t)})),createPreOrderIntent:async t=>i(c("/pre-order-intents"),await d({method:"POST",body:JSON.stringify(t)})),createNewsletterSubscription:async t=>i(c("/newsletter-subscriptions"),await d({method:"POST",body:JSON.stringify(t)})),unsubscribeNewsletter:async t=>i(c("/newsletter-unsubscribe"),await d({method:"POST",body:JSON.stringify(t)})),captureCart:async t=>i(c("/carts"),await d({method:"POST",body:JSON.stringify(t)})),restoreCart:async t=>i(c("/carts/restore"),await d({method:"POST",body:JSON.stringify(t)})),unsubscribeCartReminders:async t=>i(c("/carts/unsubscribe"),await d({method:"POST",body:JSON.stringify(t)})),listReviews:async(t={})=>{const e=new URLSearchParams;t.limit&&e.set("limit",String(t.limit)),t.designCode&&e.set("designCode",t.designCode);const n=c("/reviews"),s=e.toString();try{return await i(await m(s?`${n}?${s}`:n),await d())}catch(l){return console.warn("[products.listReviews] product API unavailable, returning []",l),[]}},submitReview:async t=>i(c("/reviews"),await d({method:"POST",body:JSON.stringify(t)})),getForm:async t=>i(c(`/forms/${encodeURIComponent(t)}`),await d()),submitForm:async(t,e)=>i(c(`/forms/${encodeURIComponent(t)}/submissions`),await d({method:"POST",body:JSON.stringify(e)})),listShippingMethods:async()=>{try{return await i(c("/shipping-methods"),await d())}catch(t){return console.warn("[products.listShippingMethods] product API unavailable, returning []",t),[]}},listCountrySubdivisions:async t=>{try{return await i(c(`/countries/${encodeURIComponent(t)}/subdivisions`),await d())}catch(e){return console.warn("[products.listCountrySubdivisions] unavailable, returning []",e),[]}},quoteCart:async t=>{const e=c("/cart/quote"),n=await d({method:"POST",body:JSON.stringify(t)});return t.couponCode?(await V(e,n)).data:i(e,n)},validateCoupon:async t=>{const{data:e,asShopper:n}=await V(c("/coupons/validate"),await d({method:"POST",body:JSON.stringify(t)}));return{...e,askedAsShopper:n}},getHeaderSettings:async()=>{const t=M({method:"GET"}),e=await i(...await x(c("/header-settings"),{signal:t})),n=L(e.logoUrl);let s=null,l=null;if(n&&xt(n)&&ue(n)){const u=await Dt(n,t);u&&(s=u.reversed,l=u.inkIsDark)}return{...e,logoUrl:n,logoReversed:s,logoInkIsDark:l}},getThemeSettings:async()=>i(...await x(c("/theme-settings"))),getChatSettings:async()=>i(await m(c("/chat-settings")),await d())},Me={listServices:async()=>{try{return await i(c("/bookings/services"),await d())}catch(t){return console.warn("[bookings.listServices] API unavailable, returning []",t),{results:[],currency:"USD"}}},getAvailability:async(t,e)=>i(c(`/bookings/availability?service=${encodeURIComponent(t)}&date=${e}`),await d()),create:async t=>i(c("/bookings"),await d({method:"POST",body:JSON.stringify(t)})),get:async t=>i(c(`/bookings/manage/${encodeURIComponent(t)}`),await d()),cancel:async t=>i(c(`/bookings/manage/${encodeURIComponent(t)}/cancel`),await d({method:"POST"})),reschedule:async(t,e)=>i(c(`/bookings/manage/${encodeURIComponent(t)}/reschedule`),await d({method:"POST",body:JSON.stringify({startAt:e})})),createPaymentIntent:async t=>i(c("/bookings/payments/intent"),await d({method:"POST",body:JSON.stringify({manageToken:t})}))};class pe extends Error{slug;count;constructor(e,n){super(`Slug "${e}" exists on ${n} websites; a site is required to pick one.`),this.slug=e,this.count=n,this.name="AmbiguousPageSlugError"}}const C=(t,e,n)=>{const s=new URLSearchParams({...e?{site:e}:{},...n?{draft:"1"}:{}}).toString();return`/api/storefront/${t}/${s?`?${s}`:""}`},I=t=>`/api/storefront/sites/${encodeURIComponent(t)}/`,ye=t=>`${I(t)}currencies/`,fe="/api/storefront/media/ingest/";class he extends Error{constructor(){super("This editor is not connected to a website, so an upload has nowhere to go. Open the page from the website the file should belong to, then try again."),this.name="MediaUploadDestinationError"}}function me(){const t=Ft();if(!t)throw new he;return`${fe}?${new URLSearchParams({site:t})}`}const ge="X-Puck-Media-Manifest",it=St.contentHash,N={"X-Media-Manifest":it,[ge]:it},Be=ct({});function ct(t){return(e,n={})=>{const s=Ct(),l=t.headers||s?{...s?{"Accept-Language":s}:{},...t.headers,...n.headers}:void 0;return i(e,{...n,...t.baseUrl!==void 0?{baseUrl:t.baseUrl}:{},...l?{headers:l}:{},audience:t.audience??Ut()})}}function we(t={}){const e=ct(t),n=t.siteDrafts===!0,s=a=>C("header-settings",a,n),l=a=>C("theme-settings",a,n),u=a=>C("chat-settings",a,n),y=a=>C("social-settings",a,n);return{findPageBySlug:async(a,r,o)=>{const p=new URLSearchParams({slug:a});o&&p.set("site",o);const f=await e(`/api/storefront/pages/?${p.toString()}`,{token:r}),P=h(f);if(!o&&P.length>1)throw new pe(a,P.length);return P[0]??null},getPageById:(a,r)=>e(`/api/storefront/pages/${a}/`,{token:r}),saveLayout:(a,r,o,p,f)=>e(`/api/storefront/pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r,expected_updated_at:p,...f?{client_id:f}:{}}),token:o}),duplicatePage:(a,r,o)=>e(`/api/storefront/pages/${a}/duplicate/`,{method:"POST",body:JSON.stringify({title:r.title,slug:r.slug}),token:o}),listSiteFonts:async(a,r)=>{const o=new URLSearchParams({site:a,no_page:"true"}),p=await e(`/api/storefront/site-fonts/?${o.toString()}`,{token:r});return h(p)},getSiteFont:(a,r)=>e(`/api/storefront/site-fonts/${a}/`,{token:r}),addSiteFont:(a,r)=>e("/api/storefront/site-fonts/",{method:"POST",body:JSON.stringify(a),token:r}),retrySiteFont:(a,r)=>e(`/api/storefront/site-fonts/${a}/retry/`,{method:"POST",token:r}),archiveSiteFont:(a,r,o)=>e(`/api/storefront/site-fonts/${a}/archive/`,{method:"POST",token:r,...o?.keepalive?{keepalive:!0}:{}}),searchGoogleFontFamilies:async(a,r)=>{const o=await e(`/api/storefront/google-font-families/?${new URLSearchParams({search:a}).toString()}`,{token:r});return h(o)},geocode:(a,r,o)=>e(`/api/storefront/geocode/?${new URLSearchParams(o?{q:a,country:o}:{q:a})}`,{token:r}),listBlockSources:a=>e("/api/storefront/block-sources/",{token:a}),listRecordTypes:a=>e("/api/storefront/record-types/",{token:a}),createPagePreviewLink:(a,r)=>e(`/api/storefront/pages/${a}/preview-link/`,{method:"POST",token:r}),claimPageEditLock:(a,r,o,p=!1)=>e(`/api/storefront/pages/${a}/edit-lock/`,{method:"POST",body:JSON.stringify({client_id:o,takeover:p}),token:r}),releasePageEditLock:(a,r)=>e(`/api/storefront/pages/${a}/edit-lock/`,{method:"DELETE",token:r}),createTemplate:(a,r,o)=>e("/api/storefront/page-templates/",{method:"POST",body:JSON.stringify({name:a,layout:r}),headers:N,token:o}),getTemplate:(a,r)=>e(`/api/storefront/page-templates/${a}/`,{token:r}),saveTemplateLayout:(a,r,o)=>e(`/api/storefront/page-templates/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r}),headers:N,token:o}),listTemplatePages:async(a,r)=>{const o=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(a)}`,{token:r});return h(o)},getPageLibrary:async a=>{const r=await e("/api/storefront/page-templates/?is_page_library=true&is_active=true",{token:a});return h(r)[0]??null},getTemplateLibrary:(a,r)=>e(`/api/storefront/pages/template-library/?site=${encodeURIComponent(a)}`,{token:r}),createPageFromTemplate:(a,r)=>e(`/api/storefront/pages/from-template/${n?"?draft=1":""}`,{method:"POST",body:JSON.stringify(a),token:r}),findTemplatePageBySlug:async(a,r,o)=>{const p=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(a)}&slug=${encodeURIComponent(r)}`,{token:o});return h(p)[0]??null},createTemplatePage:(a,r,o)=>e("/api/storefront/template-pages/",{method:"POST",body:JSON.stringify({template:a,...r}),headers:N,token:o}),saveTemplatePageLayout:(a,r,o)=>e(`/api/storefront/template-pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r}),headers:N,token:o}),deleteTemplatePage:(a,r,o)=>e(`/api/storefront/template-pages/${a}/`,{method:"DELETE",token:r,...o?.keepalive?{keepalive:!0}:{}}),listPages:async(a,r)=>{const o=new URLSearchParams({no_page:"true"});r&&o.set("site",r);const p=await e(`/api/storefront/pages/?${o.toString()}`,{token:a});return h(p)},createPage:(a,r,o,p)=>e("/api/storefront/pages/",{method:"POST",body:JSON.stringify({title:a,slug:r,layout:o}),token:p}),deletePage:(a,r)=>e(`/api/storefront/pages/${a}/`,{method:"DELETE",token:r}),getHeaderSettings:(a,r)=>e(s(r),{token:a}),listMenus:async(a,r)=>{const o=new URLSearchParams({no_page:"true"});r&&o.set("site",r);const p=await e(`/api/storefront/menus/?${o}`,{token:a});return h(p)},listBlogPosts:async(a,r={})=>{const o=new URLSearchParams({no_page:"true"});r.visibleOnly&&o.set("is_visible","true"),r.siteId&&o.set("site",r.siteId);const p=await e(`/api/storefront/blog-posts/?${o.toString()}`,{token:a});return h(p)},listFieldUsage:async(a,r)=>{const o=await e(`/api/storefront/field-usage/?site=${encodeURIComponent(r)}`,{token:a});return Array.isArray(o?.entries)?o.entries:[]},listCategories:async(a,r={})=>{const o=new URLSearchParams({no_page:"true"});r.visibleOnly&&o.set("is_visible","true"),r.siteId&&o.set("site",r.siteId);const p=await e(`/api/storefront/categories/?${o.toString()}`,{token:a});return[...h(p)].sort((P,E)=>P.sort_order-E.sort_order||P.name.localeCompare(E.name))},listForms:async(a,r={})=>{const o=new URLSearchParams({no_page:"true"});r.siteId&&o.set("site",r.siteId);const p=await e(`/api/storefront/forms/?${o.toString()}`,{token:a});return[...h(p)].sort((P,E)=>P.title.localeCompare(E.title))},listWheelSummaries:async(a,r={})=>{const o=new URLSearchParams;r.siteId&&o.set("site",r.siteId);const p=o.toString(),f=await e(`/api/storefront/wheel-curations/summaries/${p?`?${p}`:""}`,{token:a});return S(f)},listProducts:async(a,r={})=>{const o=new URLSearchParams;r.kinds?.length&&o.set("kind",r.kinds.join(",")),r.siteId&&o.set("site",r.siteId);const p=o.toString(),f=await e(`/api/storefront/products/${p?`?${p}`:""}`,{token:a});return S(f)},getWheelDetail:async(a,r,o={})=>{const p=new URLSearchParams({slug:r});return o.siteId&&p.set("site",o.siteId),H(S(await e(`/api/storefront/wheel-curations/detail/?${p.toString()}`,{token:a})))},updateHeaderSettings:(a,r,o)=>e(s(o),{method:"PATCH",body:JSON.stringify(a),token:r}),getSite:(a,r)=>e(I(a),{token:r}),listSites:async a=>{const r=await e("/api/storefront/sites/?no_page=true",{token:a});return h(r)},listSiteCurrencies:async(a,r)=>{const o=await e(ye(a),{token:r});return Array.isArray(o)?o:[]},publishSite:(a,r)=>e(`${I(a)}publish/`,{method:"POST",token:r}),getSiteLiveState:(a,r)=>e(`${I(a)}live-state/`,{token:r}),getThemeSettings:(a,r)=>e(l(r),{token:a}),updateThemeSettings:(a,r,o)=>e(l(o),{method:"PATCH",body:JSON.stringify(a),token:r}),getMyPreferences:async a=>(await e("/api/auth/me/",{token:a})).preferences??{},updateMyPreferences:(a,r)=>e("/api/auth/me/",{method:"PATCH",body:JSON.stringify({preferences:a}),token:r}),getChatSettings:(a,r)=>e(u(r),{token:a}),updateChatSettings:(a,r,o)=>e(u(o),{method:"PATCH",body:JSON.stringify(a),token:r}),getSocialSettings:(a,r)=>e(y(r),{token:a}),updateSocialSettings:(a,r,o)=>e(y(o),{method:"PATCH",body:JSON.stringify(a),token:r}),uploadHeaderLogo:(a,r,o)=>{const p=new FormData;return p.append("logo",a),e(s(o),{method:"PATCH",body:p,token:r})},clearHeaderLogo:(a,r)=>e(s(r),{method:"PATCH",body:JSON.stringify({logo:null}),token:a}),setHeaderLogoFromAsset:(a,r,o)=>e(s(o),{method:"PATCH",body:JSON.stringify({logo_asset_id:a}),token:r}),uploadMedia:async(a,r)=>{const o=new FormData;return o.append("file",a),e(me(),{method:"POST",body:o,token:r})},listMedia:async(a,r)=>{const o=new URLSearchParams({no_page:"true"});r&&o.set("kind",r);const p=await e(`/api/storefront/media-assets/?${o.toString()}`,{token:a});return h(p)}}}const qe=we({siteDrafts:!0});function Se(t){const e=t.trim();return e?`/api/v1/dealers?${new URLSearchParams({near:e}).toString()}`:"/api/v1/dealers"}async function Ge(t){return Mt(await i(Se(t)))}const T={audience:null,baseUrl:""};async function We(t,e){return Kt(await i(Vt(t,e),T))}async function je(t){return Xt(await i(Bt,{...T,method:"POST",body:JSON.stringify(t)}))}async function ze(t){try{const e=await i(qt,{...T,method:"POST",body:JSON.stringify({token:t})});return Q(202,e)}catch(e){if(e instanceof w)return Q(e.status,e.data);throw e}}async function Ke(t,e){await i(Gt,{...T,method:"POST",body:JSON.stringify({email:e.trim(),...t?{product:t}:{}})})}async function Xe(t,e){await i(Wt,{...T,method:"POST",body:JSON.stringify({email:e.trim(),...t?{product:t}:{}})})}async function Ve(t){try{return zt(await i(jt,{...T,method:"POST",body:JSON.stringify({token:t})}))}catch(e){if(e instanceof w&&Pe.has(e.status))return"";throw e}}const Pe=new Set([400,404,410]);export{Ot as API_URL,pe as AmbiguousPageSlugError,w as ApiError,At as BROWSER_READ_TIMEOUT_MS,Tt as EFFICIENT_CLIENT_CLOSED_MESSAGE,he as MediaUploadDestinationError,ie as PREVIEW_PARAM,Qe as PRODUCT_API_BASE,Rt as SERVER_READ_TIMEOUT_MS,v as SERVER_UNREACHABLE_MESSAGE,k as STATUS_NETWORK_ERROR,Be as adminFetch,Lt as api,i as apiFetch,$ as appendSiteQuery,Xe as askForWorkspaces,je as askToSignUp,Me as bookings,we as createStorefrontAdmin,Se as dealersPath,M as defaultRequestDeadline,me as editorMediaUploadPath,Ut as editorPortalAudience,Ct as editorRequestLanguage,Ge as fetchDealers,We as fetchSignUpAvailability,Fe as fitment,Ke as joinSignUpWaitingList,ze as openSignUpLink,Ve as openWorkspaceFind,He as products,_t as readDeadlineMs,ne as resolveClientIp,S as resolveMediaUrls,ce as resolvePreviewToken,ot as resolveSiteHost,re as resolveSiteHostSource,se as resolveSiteSlug,Ne as setEditorLanguage,Ie as setEditorPortalAudience,qe as storefrontAdmin};
@@ -1578,6 +1578,31 @@ export interface components {
1578
1578
  readMinutes: number;
1579
1579
  body: string;
1580
1580
  };
1581
+ SiteFont: {
1582
+ key: string;
1583
+ family: string;
1584
+ label: string;
1585
+ category: "sans" | "serif" | "mono";
1586
+ condensed: boolean;
1587
+ weights: number[];
1588
+ italic: boolean;
1589
+ fallbackMetrics: components["schemas"]["SiteFontFallbackMetrics"] | null;
1590
+ files: components["schemas"]["SiteFontFile"][];
1591
+ };
1592
+ SiteFontFallbackMetrics: {
1593
+ ascent: number;
1594
+ descent: number;
1595
+ lineGap: number;
1596
+ sizeAdjust: number;
1597
+ };
1598
+ SiteFontFile: {
1599
+ id: string;
1600
+ weight: number;
1601
+ style: "normal" | "italic";
1602
+ subset: string;
1603
+ unicodeRange: string;
1604
+ url: string;
1605
+ };
1581
1606
  ThemeSettings: {
1582
1607
  theme: {
1583
1608
  selected: number;
@@ -1631,6 +1656,7 @@ export interface components {
1631
1656
  quiet?: components["schemas"]["WordStyle"];
1632
1657
  };
1633
1658
  textStyles?: components["schemas"]["ThemeTextStyle"][] | null;
1659
+ siteFonts?: components["schemas"]["SiteFont"][];
1634
1660
  siteWidth: number;
1635
1661
  siteWidthUnit?: "px" | "%" | "vw" | null;
1636
1662
  siteGutter: number;
@@ -3,6 +3,7 @@ export declare const SHIPPING_ARRANGED = "Arranged after review";
3
3
  export declare const CALCULATED_AT_CHECKOUT = "Calculated at checkout";
4
4
  export declare const SHIPPING_PENDING = "Calculated at checkout";
5
5
  export declare const TAX_PENDING = "Calculated at checkout";
6
+ export declare const TAX_PENDING_AT_CHECKOUT = "Calculated from your address";
6
7
  export declare function shippingStatus({ quoted, optionCount, chosenAmount, couponWaivesFreight, }: {
7
8
  quoted: boolean;
8
9
  optionCount: number;
@@ -1 +1 @@
1
- import{FREE_PRICE as u}from"../wheels/price-display.js";const i="Arranged after review",t="Calculated at checkout",a=t,f=t;function p({quoted:r,optionCount:e,chosenAmount:n,couponWaivesFreight:o}){return r&&e===0?"arranged":o?"free":n===void 0?"pending":n===0?"free":"charged"}function d(r,e){return r*(100-e)/100}function l({discount:r,deliverySaving:e},n){return[r>0?`− ${n(r)}`:null,e>0?`${n(e)} off delivery`:null].filter(Boolean).join(" · ")}function s(r){switch(r){case"arranged":return i;case"pending":return a;case"free":return u;case"charged":return null}}export{t as CALCULATED_AT_CHECKOUT,i as SHIPPING_ARRANGED,a as SHIPPING_PENDING,f as TAX_PENDING,l as couponSaving,d as deliveryAfterCoupon,p as shippingStatus,s as shippingWords};
1
+ import{FREE_PRICE as u}from"../wheels/price-display.js";const a="Arranged after review",t="Calculated at checkout",c=t,f=t,p="Calculated from your address";function d({quoted:r,optionCount:e,chosenAmount:n,couponWaivesFreight:o}){return r&&e===0?"arranged":o?"free":n===void 0?"pending":n===0?"free":"charged"}function s(r,e){return r*(100-e)/100}function l({discount:r,deliverySaving:e},n){return[r>0?`− ${n(r)}`:null,e>0?`${n(e)} off delivery`:null].filter(Boolean).join(" · ")}function C(r){switch(r){case"arranged":return a;case"pending":return c;case"free":return u;case"charged":return null}}export{t as CALCULATED_AT_CHECKOUT,a as SHIPPING_ARRANGED,c as SHIPPING_PENDING,f as TAX_PENDING,p as TAX_PENDING_AT_CHECKOUT,l as couponSaving,s as deliveryAfterCoupon,d as shippingStatus,C as shippingWords};