efficient-storefront-blocks 0.139.4 → 0.139.5

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.
@@ -11,8 +11,10 @@ interface DealerFinderViewProps {
11
11
  query: string;
12
12
  list: DealerList | null;
13
13
  busy?: boolean;
14
+ pickupOnly?: boolean;
14
15
  onQuery?: (value: string) => void;
15
16
  onSearch?: (event: FormEvent<HTMLFormElement>) => void;
17
+ onPickupOnly?: (value: boolean) => void;
16
18
  }
17
- export declare function DealerFinderView({ title, query, list, busy, onQuery, onSearch }: DealerFinderViewProps): import("react").JSX.Element;
19
+ export declare function DealerFinderView({ title, query, list, busy, pickupOnly, onQuery, onSearch, onPickupOnly }: DealerFinderViewProps): import("react").JSX.Element;
18
20
  export {};
@@ -1 +1 @@
1
- "use client";import{jsx as a,jsxs as l}from"react/jsx-runtime";import{useState as h}from"react";import{ROW_INPUT_CLASS as b}from"../lib/field-input.js";import g from"efficient-web-builder/render/components/BlockFrame";import{renderHeadline as y}from"efficient-web-builder/render/components/goldPhrases";import{phoneHref as N}from"efficient-web-builder/format/lib/links/phone-href";import{fetchDealers as v}from"../lib/api/index.js";import{DEALER_WORDS as r,dealerFinderNotice as w,dealerPins as _,dealerTownLine as k,distanceLabel as S}from"../lib/sections/dealer-finder.js";function j({title:c,contained:d,sample:n}){const[t,m]=h(""),[p,i]=h(n??null),[s,o]=h(!1);return a(g,{contained:d,className:"py-6",children:a(D,{title:c,query:t,list:p,busy:s,onQuery:m,onSearch:async f=>{if(f.preventDefault(),!(n||!t.trim())){o(!0);try{i(await v(t))}catch{i({near:"try_again",dealers:[]})}finally{o(!1)}}}})})}function D({title:c,query:d,list:n,busy:t=!1,onQuery:m,onSearch:p}){const i=n?w(n.near):null,s=n&&n.near!=="not_found"?n.dealers:[],o=_(s);return l("div",{className:"flex flex-col gap-5",children:[c&&a("h2",{className:"font-heading3 text-[length:min(var(--size-headingSmall,28px),var(--sf-heading-max,9999px))] font-medium leading-[1.1] tracking-[-0.02em]",children:y(c,!1)}),l("form",{role:"search",className:"flex max-w-[560px] gap-2",onSubmit:p,children:[a("input",{type:"search",name:"near",value:d,onChange:e=>m?.(e.target.value),placeholder:r.placeholder,"aria-label":r.placeholder,maxLength:120,className:`${b} rounded-sm border border-line bg-transparent px-3 py-2 text-[15px]`}),a("button",{type:"submit",disabled:t,className:"rounded-sm bg-btn px-4 py-2 text-[15px] font-medium text-btn-ink disabled:opacity-60",children:t?r.searching:r.search})]}),i&&a("p",{role:"status",className:"text-[15px] opacity-80",children:i}),n&&n.near!=="not_found"&&!s.length&&a("p",{role:"status",className:"text-[15px] opacity-80",children:r.none}),s.length>0&&l("div",{className:"grid gap-5 md:grid-cols-2",children:[a("ol",{className:"flex flex-col text-[15px]",children:s.map((e,f)=>{const u=S(e.distanceKm),x=k(e);return l("li",{className:"flex gap-3 border-b border-line py-3 last:border-b-0",children:[a("span",{"aria-hidden":!0,className:"w-6 shrink-0 font-medium tabular-nums",children:f+1}),l("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[l("div",{className:"flex flex-wrap items-baseline justify-between gap-x-4",children:[a("span",{className:"font-medium",children:e.name}),u&&a("span",{className:"tabular-nums opacity-70",children:u})]}),e.address&&a("span",{children:e.address}),x&&a("span",{children:x}),e.phone&&a("a",{href:N(e.phone),className:"underline-offset-2 hover:underline",children:e.phone}),e.website&&a("a",{href:e.website,target:"_blank",rel:"noopener noreferrer",className:"underline-offset-2 hover:underline",children:r.website})]})]},e.id)})}),o.length>0&&a("div",{role:"img","aria-label":r.map,className:"relative min-h-[280px] overflow-hidden rounded-sm border border-line",style:{background:"color-mix(in oklab, var(--accent) 6%, transparent)"},children:o.map(e=>a("span",{"data-dealer-pin":e.index+1,className:"absolute flex h-6 w-6 -translate-x-1/2 -translate-y-full items-center justify-center rounded-full bg-accent text-[12px] font-medium text-accent-ink",style:{left:`${e.left}%`,top:`${e.top}%`},children:e.index+1},e.id))})]})]})}export{D as DealerFinderView,j as default};
1
+ "use client";import{jsx as n,jsxs as s}from"react/jsx-runtime";import{useState as o}from"react";import{ROW_INPUT_CLASS as w}from"../lib/field-input.js";import v from"efficient-web-builder/render/components/BlockFrame";import{renderHeadline as P}from"efficient-web-builder/render/components/goldPhrases";import{phoneHref as S}from"efficient-web-builder/format/lib/links/phone-href";import O from"./SiteSwitch.js";import{fetchDealers as _}from"../lib/api/index.js";import{DEALER_WORDS as t,dealerFinderNotice as L,dealerPins as j,dealerTownLine as D,distanceLabel as F}from"../lib/sections/dealer-finder.js";function $({title:d,contained:x,sample:a}){const[r,p]=o(""),[m,b]=o(""),[u,h]=o(!1),[i,c]=o(a??null),[y,e]=o(!1),f=async(l,N)=>{e(!0);try{c(await _(l,N))}catch{c({near:"try_again",dealers:[]})}finally{e(!1)}};return n(v,{contained:x,className:"py-6",children:n(C,{title:d,query:r,list:i,busy:y,pickupOnly:u,onQuery:p,onSearch:async l=>{l.preventDefault(),!(a||!r.trim())&&(b(r),await f(r,u))},onPickupOnly:async l=>{a||!m.trim()||(h(l),await f(m,l))}})})}function C({title:d,query:x,list:a,busy:r=!1,pickupOnly:p=!1,onQuery:m,onSearch:b,onPickupOnly:u}){const h=a?L(a.near):null,i=a&&a.near!=="not_found"?a.dealers:[],c=j(i),y=a!==null&&(p||i.some(e=>e.pickupPoint));return s("div",{className:"flex flex-col gap-5",children:[d&&n("h2",{className:"font-heading3 text-[length:min(var(--size-headingSmall,28px),var(--sf-heading-max,9999px))] font-medium leading-[1.1] tracking-[-0.02em]",children:P(d,!1)}),s("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[s("form",{role:"search",className:"flex min-w-0 max-w-[560px] flex-1 gap-2",onSubmit:b,children:[n("input",{type:"search",name:"near",value:x,onChange:e=>m?.(e.target.value),placeholder:t.placeholder,"aria-label":t.placeholder,maxLength:120,className:`${w} rounded-sm border border-line bg-transparent px-3 py-2 text-[15px]`}),n("button",{type:"submit",disabled:r,className:"rounded-sm bg-btn px-4 py-2 text-[15px] font-medium text-btn-ink disabled:opacity-60",children:r?t.searching:t.search})]}),y&&n(O,{checked:p,onChange:e=>u?.(e),ariaLabel:t.pickupOnly,disabled:r,className:"flex cursor-pointer items-center gap-2 text-sm",children:n("span",{children:t.pickupOnly})})]}),h&&n("p",{role:"status",className:"text-[15px] opacity-80",children:h}),a&&a.near!=="not_found"&&!i.length&&n("p",{role:"status",className:"text-[15px] opacity-80",children:t.none}),i.length>0&&s("div",{className:"grid gap-5 md:grid-cols-2",children:[n("ol",{className:"flex flex-col text-[15px]",children:i.map((e,f)=>{const g=F(e.distanceKm),k=D(e);return s("li",{className:"flex gap-3 border-b border-line py-3 last:border-b-0",children:[n("span",{"aria-hidden":!0,className:"w-6 shrink-0 font-medium tabular-nums",children:f+1}),s("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[s("div",{className:"flex flex-wrap items-baseline justify-between gap-x-4",children:[n("span",{className:"font-medium",children:e.name}),g&&n("span",{className:"tabular-nums opacity-70",children:g})]}),e.pickupPoint&&n("span",{"data-pickup-point":"",className:"self-start rounded-sm border border-line px-2 text-xs font-medium",children:t.pickupPoint}),e.address&&n("span",{children:e.address}),k&&n("span",{children:k}),e.phone&&n("a",{href:S(e.phone),className:"underline-offset-2 hover:underline",children:e.phone}),e.website&&n("a",{href:e.website,target:"_blank",rel:"noopener noreferrer",className:"underline-offset-2 hover:underline",children:t.website})]})]},e.id)})}),c.length>0&&n("div",{role:"img","aria-label":t.map,className:"relative min-h-[280px] overflow-hidden rounded-sm border border-line",style:{background:"color-mix(in oklab, var(--accent) 6%, transparent)"},children:c.map(e=>n("span",{"data-dealer-pin":e.index+1,"data-pickup-point":e.pickupPoint?"":void 0,title:e.pickupPoint?t.pickupPoint:void 0,className:`absolute flex h-6 w-6 -translate-x-1/2 -translate-y-full items-center justify-center ${e.pickupPoint?"rounded-sm":"rounded-full"} bg-accent text-[12px] font-medium text-accent-ink`,style:{left:`${e.left}%`,top:`${e.top}%`},children:e.index+1},e.id))})]})]})}export{C as DealerFinderView,$ as default};
@@ -935,8 +935,8 @@ export declare const storefrontAdmin: {
935
935
  }>;
936
936
  listMedia: (token: string, kind?: "image" | "video") => Promise<MediaAsset[]>;
937
937
  };
938
- export declare function dealersPath(near: string): string;
939
- export declare function fetchDealers(near: string): Promise<DealerList>;
938
+ export declare function dealersPath(near: string, pickupOnly?: boolean): string;
939
+ export declare function fetchDealers(near: string, pickupOnly?: boolean): Promise<DealerList>;
940
940
  export declare function fetchSignUpAvailability(product: string, slug?: string): Promise<SignUpAvailability>;
941
941
  export declare function askToSignUp(body: Record<string, string>): Promise<SignUpSent>;
942
942
  export declare function openSignUpLink(token: string): Promise<LinkState>;
@@ -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 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};
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:c,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"},...c},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 c=await j();return await i(t,{...e,token:c})}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("?"),c=[];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()}`);c.push(...h(r)),u=kt(r.next)}return u&&console.warn(`[${e}] stopped at ${K} pages (${c.length} rows); list may be truncated`),c}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(([c,u])=>[S(c),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 d(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[c,u]of Object.entries(e))u!=null&&u!==""&&s.set(c,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 c=[];let u=null;try{for(let y=0;y<at;y++){const a=await i(await e(u),await l());if(c.push(...h(a)),u=ae(a.next),!u)break;if(s(c))return c}u&&console.warn(`[${t}] stopped at ${at} pages (${c.length} rows); catalog may be truncated`)}catch(y){if(n(y))throw y;console.warn(`[${t}] product API unavailable, returning []`,y)}return c}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")),c=n(e.get("host"));return{host:s,matchesRequestHost:s!==null&&s===c}}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 l(e)];const s=$(await m(t),`${ie}=${encodeURIComponent(n)}`),{next:c,cache:u,...y}=e??{},a=await l({...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 l(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[c,u]of Object.entries(e))u!==void 0&&u!==""&&n.set(c,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:c}=await import("./fitment-data.js");return c.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 c=await i(_("/modifications",{make:t,model:e,year:n,region:s}),b());return h(c)},getStockFitment:async(t,e,n,s,c)=>{if(A){const{fitmentData:u}=await import("./fitment-data.js");return u.stockFitment(t,e,n,s,c)}return i(_("/stock-fitment",{make:t,model:e,year:n,modification:s,region:c}),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 c=new Set,u=n(process.env.NEXT_PUBLIC_MEDIA_URL);u&&c.add(e(u,"https:",""));for(const y of[process.env.NEXT_PUBLIC_API_URL,yt()]){const a=n(y);a&&c.add(e(a))}for(const y of(process.env.ASSET_CDN_HOSTS??"").split(",").map(a=>a.trim()).filter(Boolean))c.add(`https://${y}:`);return c.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 c=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=c.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 c=>await m(ee(t,e,c)),n.throwOnFailure?()=>!0:nt,n.maxRows===void 0?void 0:c=>st([...c]).length>=n.maxRows);return st(S(s))},getWheel:async t=>H(S(await i(await m(d(`/wheels/${encodeURIComponent(t)}`)),await l()))),getTyre:async t=>S(await i(await m(d(`/tyres/${encodeURIComponent(t)}`)),await l())),listBundles:async(t={})=>{try{return await i(await m(d("/bundles")),await l())}catch(e){if(t.throwOnFailure)throw e;return[]}},getBundle:async t=>i(await m(d(`/bundles/${encodeURIComponent(t)}`)),await l()),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 c=s.toString(),u=await i(`/api/v1/gallery-builds${c?`?${c}`:""}`,b());return S(h(u))}catch(s){return console.warn("[products.listGalleryBuilds] product API unavailable, returning []",s),[]}},getSite:async()=>i(await m(d("/site")),await l()),getSiteBySlug:async t=>i(`${d("/site")}?${new URLSearchParams({site:t})}`,typeof window>"u"?await l():void 0),listPages:async()=>S(await i(await m(d("/pages")),await l())),listPopups:async()=>i(await m(d("/popups")),await l()),listProductTemplates:async()=>{try{return await i(await m(d("/product-templates")),await l())}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(`${d("/dynamic-pages")}${e}`),await l())}catch(n){if(n instanceof w&&n.status===404)return[];throw n}},getRecord:async(t,e)=>{try{return await i(await m(d(`/records/${encodeURIComponent(t)}/${encodeURIComponent(e)}`)),await l())}catch(n){if(n instanceof w&&n.status===404)return null;throw n}},listRecordKeys:async t=>{try{const e=await i(await m(d(`/records/${encodeURIComponent(t)}`)),await l({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(d("/product-type-choices")),await l())}catch(t){return console.warn("[products.listProductTypeChoices] unavailable, returning []",t),[]}},listFieldUsage:async()=>{try{return await i(await m(d("/field-usage")),await l())}catch(t){return console.warn("[products.listFieldUsage] unavailable, returning []",t),[]}},getPage:async(t,e={})=>{const n=e.record?`?record=${encodeURIComponent(e.record)}`:"",[s,c]=await x(d(`/pages/${encodeURIComponent(t)}`)+n,e.revalidate!==void 0?{next:{revalidate:e.revalidate}}:void 0);return S(await i(s,c))},listBlogPosts:async(t={},{throwOnFailure:e=!1}={})=>{const n=t.category?`?category=${encodeURIComponent(t.category)}`:"";try{return(await i(d("/blog-posts")+n,await l())).map(c=>({...c,coverImage:L(c.coverImage)??""}))}catch(s){if(e)throw s;return console.warn("[products.listBlogPosts] blog API unavailable, returning []",s),[]}},getBlogPost:async t=>{const e=await i(d(`/blog-posts/${encodeURIComponent(t)}`),await l());return{...e,coverImage:L(e.coverImage)??""}},createOrder:async t=>i(d("/orders"),await l({method:"POST",body:JSON.stringify(t)})),createOrderAuthed:async t=>g(d("/orders"),await l({method:"POST",body:JSON.stringify(t)})),lookupOrder:async t=>i(d("/orders/lookup"),await l({method:"POST",body:JSON.stringify(t)})),createPaymentIntent:async t=>i(d("/payments/intent"),await l({method:"POST",body:JSON.stringify(t)})),releaseCheckout:async t=>i(d("/checkouts/release"),await l({method:"POST",body:JSON.stringify(t)})),createPaypalOrder:async t=>i(d("/payments/paypal/order"),await l({method:"POST",body:JSON.stringify(t)})),capturePaypalOrder:async t=>i(d("/payments/paypal/capture"),await l({method:"POST",body:JSON.stringify(t)})),createAfterpayCheckout:async t=>i(d("/payments/afterpay/checkout"),await l({method:"POST",body:JSON.stringify(t)})),captureAfterpayPayment:async t=>i(d("/payments/afterpay/capture"),await l({method:"POST",body:JSON.stringify(t)})),chargeSquare:async t=>i(d("/payments/square/charge"),await l({method:"POST",body:JSON.stringify(t)})),createGocardlessBillingRequest:async t=>i(d("/payments/gocardless/billing-request"),await l({method:"POST",body:JSON.stringify(t)})),completeGocardlessPayment:async t=>i(d("/payments/gocardless/complete"),await l({method:"POST",body:JSON.stringify(t)})),createZipCheckout:async t=>i(d("/payments/zip/checkout"),await l({method:"POST",body:JSON.stringify(t)})),captureZipPayment:async t=>i(d("/payments/zip/capture"),await l({method:"POST",body:JSON.stringify(t)})),createWorldpayCheckout:async t=>i(d("/payments/worldpay/checkout"),await l({method:"POST",body:JSON.stringify(t)})),confirmWorldpayPayment:async t=>i(d("/payments/worldpay/confirm"),await l({method:"POST",body:JSON.stringify(t)})),createKlarnaCheckout:async t=>i(d("/payments/klarna/checkout"),await l({method:"POST",body:JSON.stringify(t)})),captureKlarnaPayment:async t=>i(d("/payments/klarna/capture"),await l({method:"POST",body:JSON.stringify(t)})),createStockAlert:async t=>i(d("/stock-alerts"),await l({method:"POST",body:JSON.stringify(t)})),createPreOrderIntent:async t=>i(d("/pre-order-intents"),await l({method:"POST",body:JSON.stringify(t)})),createNewsletterSubscription:async t=>i(d("/newsletter-subscriptions"),await l({method:"POST",body:JSON.stringify(t)})),unsubscribeNewsletter:async t=>i(d("/newsletter-unsubscribe"),await l({method:"POST",body:JSON.stringify(t)})),captureCart:async t=>i(d("/carts"),await l({method:"POST",body:JSON.stringify(t)})),restoreCart:async t=>i(d("/carts/restore"),await l({method:"POST",body:JSON.stringify(t)})),unsubscribeCartReminders:async t=>i(d("/carts/unsubscribe"),await l({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=d("/reviews"),s=e.toString();try{return await i(await m(s?`${n}?${s}`:n),await l())}catch(c){return console.warn("[products.listReviews] product API unavailable, returning []",c),[]}},submitReview:async t=>i(d("/reviews"),await l({method:"POST",body:JSON.stringify(t)})),getForm:async t=>i(d(`/forms/${encodeURIComponent(t)}`),await l()),submitForm:async(t,e)=>i(d(`/forms/${encodeURIComponent(t)}/submissions`),await l({method:"POST",body:JSON.stringify(e)})),listShippingMethods:async()=>{try{return await i(d("/shipping-methods"),await l())}catch(t){return console.warn("[products.listShippingMethods] product API unavailable, returning []",t),[]}},listCountrySubdivisions:async t=>{try{return await i(d(`/countries/${encodeURIComponent(t)}/subdivisions`),await l())}catch(e){return console.warn("[products.listCountrySubdivisions] unavailable, returning []",e),[]}},quoteCart:async t=>{const e=d("/cart/quote"),n=await l({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(d("/coupons/validate"),await l({method:"POST",body:JSON.stringify(t)}));return{...e,askedAsShopper:n}},getHeaderSettings:async()=>{const t=M({method:"GET"}),e=await i(...await x(d("/header-settings"),{signal:t})),n=L(e.logoUrl);let s=null,c=null;if(n&&xt(n)&&ue(n)){const u=await Dt(n,t);u&&(s=u.reversed,c=u.inkIsDark)}return{...e,logoUrl:n,logoReversed:s,logoInkIsDark:c}},getThemeSettings:async()=>i(...await x(d("/theme-settings"))),getChatSettings:async()=>i(await m(d("/chat-settings")),await l())},Me={listServices:async()=>{try{return await i(d("/bookings/services"),await l())}catch(t){return console.warn("[bookings.listServices] API unavailable, returning []",t),{results:[],currency:"USD"}}},getAvailability:async(t,e)=>i(d(`/bookings/availability?service=${encodeURIComponent(t)}&date=${e}`),await l()),create:async t=>i(d("/bookings"),await l({method:"POST",body:JSON.stringify(t)})),get:async t=>i(d(`/bookings/manage/${encodeURIComponent(t)}`),await l()),cancel:async t=>i(d(`/bookings/manage/${encodeURIComponent(t)}/cancel`),await l({method:"POST"})),reschedule:async(t,e)=>i(d(`/bookings/manage/${encodeURIComponent(t)}/reschedule`),await l({method:"POST",body:JSON.stringify({startAt:e})})),createPaymentIntent:async t=>i(d("/bookings/payments/intent"),await l({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(),c=t.headers||s?{...s?{"Accept-Language":s}:{},...t.headers,...n.headers}:void 0;return i(e,{...n,...t.baseUrl!==void 0?{baseUrl:t.baseUrl}:{},...c?{headers:c}:{},audience:t.audience??Ut()})}}function we(t={}){const e=ct(t),n=t.siteDrafts===!0,s=a=>C("header-settings",a,n),c=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(c(r),{token:a}),updateThemeSettings:(a,r,o)=>e(c(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,e=!1){const n=new URLSearchParams,s=t.trim();s&&n.set("near",s),e&&n.set("pickupPoint","true");const c=n.toString();return c?`/api/v1/dealers?${c}`:"/api/v1/dealers"}async function Ge(t,e=!1){return Mt(await i(Se(t,e)))}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};
@@ -1 +1 @@
1
- import{jsx as r}from"react/jsx-runtime";import a from"../../../../../components/DealerFinderSection.js";import{readHidable as d}from"efficient-easel/screen/lib/document/hidable";import{DealerFinderMeta as s}from"./meta.js";const i=()=>({near:"found",dealers:[{id:"sample-1",name:"Harbour Wheels",address:"12 Quay St",city:"Sydney",state:"NSW",postcode:"2000",country:"AU",phone:"02 9000 0000",website:"https://example.com",lat:-33.86,lng:151.21,distanceKm:1.2},{id:"sample-2",name:"Western Tyres",address:"4 Great Western Hwy",city:"Parramatta",state:"NSW",postcode:"2150",country:"AU",phone:"02 9600 0000",website:"",lat:-33.81,lng:151,distanceKm:21.4}]}),o=e=>{const{text:t,hidden:n}=d(e);return n||!t?void 0:t},y={...s,render:e=>r(a,{title:o(e.title),contained:e.contained!==!1,sample:e.editor?.isEditing?i():void 0})};export{y as DealerFinderRender,i as dealerFinderSample};
1
+ import{jsx as r}from"react/jsx-runtime";import a from"../../../../../components/DealerFinderSection.js";import{readHidable as d}from"efficient-easel/screen/lib/document/hidable";import{DealerFinderMeta as i}from"./meta.js";const s=()=>({near:"found",dealers:[{id:"sample-1",name:"Harbour Wheels",address:"12 Quay St",city:"Sydney",state:"NSW",postcode:"2000",country:"AU",phone:"02 9000 0000",website:"https://example.com",pickupPoint:!0,lat:-33.86,lng:151.21,distanceKm:1.2},{id:"sample-2",name:"Western Tyres",address:"4 Great Western Hwy",city:"Parramatta",state:"NSW",postcode:"2150",country:"AU",phone:"02 9600 0000",website:"",pickupPoint:!1,lat:-33.81,lng:151,distanceKm:21.4}]}),o=e=>{const{text:t,hidden:n}=d(e);return n||!t?void 0:t},u={...i,render:e=>r(a,{title:o(e.title),contained:e.contained!==!1,sample:e.editor?.isEditing?s():void 0})};export{u as DealerFinderRender,s as dealerFinderSample};
@@ -9,6 +9,7 @@ export interface Dealer {
9
9
  country: string;
10
10
  phone: string;
11
11
  website: string;
12
+ pickupPoint: boolean;
12
13
  lat: number | null;
13
14
  lng: number | null;
14
15
  distanceKm: number | null;
@@ -27,6 +28,8 @@ export declare const DEALER_WORDS: {
27
28
  readonly tryAgain: "We couldn't look up that place just now. Please try again.";
28
29
  readonly website: "Website";
29
30
  readonly map: "Dealers on the map";
31
+ readonly pickupPoint: "Pickup point";
32
+ readonly pickupOnly: "Pickup points only";
30
33
  };
31
34
  export declare function readDealerList(value: unknown): DealerList;
32
35
  export declare function dealerFinderNotice(near: DealerNear | null): string | null;
@@ -35,6 +38,7 @@ export declare function dealerTownLine(dealer: Dealer): string;
35
38
  export interface DealerPin {
36
39
  id: string;
37
40
  index: number;
41
+ pickupPoint: boolean;
38
42
  left: number;
39
43
  top: number;
40
44
  }
@@ -1 +1 @@
1
- const d={title:"Find a dealer",placeholder:"Postcode or suburb",search:"Search",searching:"Searching…",none:"No dealers to show yet.",notFound:"We couldn't find that place. Check the postcode or suburb and search again.",tryAgain:"We couldn't look up that place just now. Please try again.",website:"Website",map:"Dealers on the map"},o=t=>typeof t=="string"?t:"",l=t=>typeof t=="number"&&Number.isFinite(t)?t:null,m=["found","not_found","try_again"];function y(t){if(!t||typeof t!="object")return null;const n=t;return typeof n.name!="string"||!n.name?null:{id:o(n.id)||n.name,name:n.name,address:o(n.address),city:o(n.city),state:o(n.state),postcode:o(n.postcode),country:o(n.country),phone:o(n.phone),website:o(n.website),lat:l(n.lat),lng:l(n.lng),distanceKm:l(n.distanceKm)}}function g(t){if(!t||typeof t!="object")return{near:null,dealers:[]};const n=t,a=typeof n.near=="string"&&m.includes(n.near)?n.near:null,s=Array.isArray(n.dealers)?n.dealers:[];return{near:a,dealers:s.map(y).filter(i=>i!==null)}}function b(t){return t==="not_found"?d.notFound:t==="try_again"?d.tryAgain:null}function x(t){return t===null?null:t<10?`${t.toFixed(1)} km`:`${Math.round(t)} km`}function w(t){return[t.city,t.state,t.postcode].filter(Boolean).join(" ")}function A(t){const n=t.map((e,r)=>({dealer:e,index:r})).filter(({dealer:e})=>e.lat!==null&&e.lng!==null);if(!n.length)return[];const a=n.map(({dealer:e})=>e.lat),s=n.map(({dealer:e})=>e.lng),[i,p]=[Math.min(...a),Math.max(...a)],[f,h]=[Math.min(...s),Math.max(...s)],c=(e,r,u)=>u===r?50:8+(e-r)/(u-r)*84;return n.map(({dealer:e,index:r})=>({id:e.id,index:r,left:c(e.lng,f,h),top:100-c(e.lat,i,p)}))}export{d as DEALER_WORDS,b as dealerFinderNotice,A as dealerPins,w as dealerTownLine,x as distanceLabel,g as readDealerList};
1
+ const p={title:"Find a dealer",placeholder:"Postcode or suburb",search:"Search",searching:"Searching…",none:"No dealers to show yet.",notFound:"We couldn't find that place. Check the postcode or suburb and search again.",tryAgain:"We couldn't look up that place just now. Please try again.",website:"Website",map:"Dealers on the map",pickupPoint:"Pickup point",pickupOnly:"Pickup points only"},o=t=>typeof t=="string"?t:"",c=t=>typeof t=="number"&&Number.isFinite(t)?t:null,h=["found","not_found","try_again"];function m(t){if(!t||typeof t!="object")return null;const n=t;return typeof n.name!="string"||!n.name?null:{id:o(n.id)||n.name,name:n.name,address:o(n.address),city:o(n.city),state:o(n.state),postcode:o(n.postcode),country:o(n.country),phone:o(n.phone),website:o(n.website),pickupPoint:n.pickupPoint===!0,lat:c(n.lat),lng:c(n.lng),distanceKm:c(n.distanceKm)}}function g(t){if(!t||typeof t!="object")return{near:null,dealers:[]};const n=t,i=typeof n.near=="string"&&h.includes(n.near)?n.near:null,a=Array.isArray(n.dealers)?n.dealers:[];return{near:i,dealers:a.map(m).filter(s=>s!==null)}}function b(t){return t==="not_found"?p.notFound:t==="try_again"?p.tryAgain:null}function x(t){return t===null?null:t<10?`${t.toFixed(1)} km`:`${Math.round(t)} km`}function P(t){return[t.city,t.state,t.postcode].filter(Boolean).join(" ")}function k(t){const n=t.map((e,r)=>({dealer:e,index:r})).filter(({dealer:e})=>e.lat!==null&&e.lng!==null);if(!n.length)return[];const i=n.map(({dealer:e})=>e.lat),a=n.map(({dealer:e})=>e.lng),[s,d]=[Math.min(...i),Math.max(...i)],[f,y]=[Math.min(...a),Math.max(...a)],u=(e,r,l)=>l===r?50:8+(e-r)/(l-r)*84;return n.map(({dealer:e,index:r})=>({id:e.id,index:r,pickupPoint:e.pickupPoint,left:u(e.lng,f,y),top:100-u(e.lat,s,d)}))}export{p as DEALER_WORDS,b as dealerFinderNotice,k as dealerPins,P as dealerTownLine,x as distanceLabel,g as readDealerList};