efficient-storefront-blocks 0.130.7 → 0.130.9

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.
@@ -1402,7 +1402,9 @@ body .sf-site-header[data-header-ink="dark"] {
1402
1402
  solid and sets background and colour inline, which beat this block. Solid is
1403
1403
  solid either way, so the bar does not change appearance as the reader
1404
1404
  scrolls — it was already painted. */
1405
- body:has([data-top-space="own"]) .sf-site-header {
1405
+ body:has([data-top-space="own"]) .sf-site-header,
1406
+ body:has(.sf-header-clearance) .sf-site-header,
1407
+ body:has(main[data-site-main]):not(:has([data-top-space="shared"])) .sf-site-header {
1406
1408
  --sf-header-overlay-fg: var(--fg);
1407
1409
  --sf-header-overlay-ground: var(--bg);
1408
1410
  background: var(--bg);
@@ -1410,6 +1412,38 @@ body:has([data-top-space="own"]) .sf-site-header {
1410
1412
  backdrop-filter: blur(12px);
1411
1413
  }
1412
1414
 
1415
+ /* ─── A PAGE THAT OWNS ITS TOP ─────────────────────────────────────────
1416
+ The first paint of lib/content/header-bar `pageOwnsTop`, which both bars
1417
+ add to `solid` after hydration. A page owns its top when it leaves room for
1418
+ the bar (`sf-header-clearance`: the 404, the journal, the catalogue) or,
1419
+ inside the site's <main> (`data-site-main`), when it does not say its first
1420
+ section shares the top (`data-top-space="shared"`, which only a stored page
1421
+ says). Sign-in, account and order pages draw their own words, so they
1422
+ own their top with nothing to remember per route.
1423
+
1424
+ 1. ROOM. The site <main> of such a page leaves the bar's height, unless the
1425
+ page already leaves it itself (a body with the clearance class).
1426
+ 2. THE BAR. Solid: these two selectors join the "own" rule above (one paint),
1427
+ and the ink here is `!important`: a
1428
+ Custom "Text color at the top" is set INLINE on the bar (BoxHeaderBar)
1429
+ for the see-through state over a photo, and no stylesheet rule beats an
1430
+ inline value otherwise. After hydration the bar is solid inline and this
1431
+ no longer decides anything.
1432
+
1433
+ ⚠️ ONE `:has()` LEVEL ONLY. `:has()` inside `:has()` is invalid, and a
1434
+ browser drops the WHOLE rule, so "a <main> with no shared page" is two
1435
+ sibling `:has()` on <body>, never one nested in the other.
1436
+ scripts/test-header-solid-without-hero.tsx §6 holds both. */
1437
+ main[data-site-main]:not(:has([data-top-space="shared"], .sf-header-clearance)) {
1438
+ /* The default lives on :root, so no fallback length is typed here. */
1439
+ padding-top: var(--sf-header-h);
1440
+ }
1441
+ body:has(.sf-header-clearance) .sf-site-header,
1442
+ body:has(main[data-site-main]):not(:has([data-top-space="shared"])) .sf-site-header {
1443
+ --sf-header-overlay-fg: var(--fg) !important;
1444
+ --sf-header-overlay-ground: var(--bg);
1445
+ }
1446
+
1413
1447
  /* ─── The page's WIDTH reaching the chrome ────────────────────────────────
1414
1448
  A page set to `Full width` publishes `data-page-width="full"` on its own
1415
1449
  wrapper, and the bar above it plus the footer below it stop capping — so
@@ -1 +1 @@
1
- "use client";import{jsx as d}from"react/jsx-runtime";import{parseOption as D}from"efficient-shell/format";import{useEffect as P,useState as R}from"react";import{useRootIsDark as S}from"efficient-shell/theme";import{usePathname as O}from"next/navigation";import{useHeaderBar as B}from"./useHeaderBar.js";import{HEADER_LINK_OPACITY_ATTR as C,HEADER_LINK_OPACITY_VAR as N,headerSolidBackground as j,isProductPage as w,readHeaderLinkOpacity as K,readHeaderTopInk as L,resolveHeaderHeightPx as M}from"../lib/content/header-bar.js";import{headerThemeWrap as Y}from"../lib/content/header-theme.js";import{HEADER_SET_HEIGHT_VAR as V}from"efficient-web-builder/render/lib/document/header-clearance";import{HEADER_INK_OVERRIDE_ATTR as W,resolveHeaderInkMode as $}from"efficient-web-builder/render/lib/document/header-ink";import{centredCap as z,SITE_WIDTH_CAP as G}from"efficient-web-builder/format/lib/content/page-width";import{HideTaker as U}from"efficient-web-builder/render/components/ViewHideRoot";import{HeaderTopInkContext as q}from"efficient-web-builder/render/components/HeaderTopInkContext";import{BoxSurfaceProvider as F}from"efficient-web-builder/render/components/BoxSurfaceContext";import{useHeaderAtTopIsDark as J}from"./useHeaderAtTopIsDark.js";import{blockParts as Q}from"../lib/block-parts.js";const X=Q("SiteHeader"),Z=["none","always","on_scroll_up"],ee=t=>D(Z,"always",t);function re({sticky:t,topTextColor:i,topTextCustom:h,linkOpacity:H,heightPx:k,theme:g,bandCapped:_=!1,children:I}){const l=ee(t),c=M(k),{headerRef:e,scrolled:u,navHidden:T}=B({stickyMode:l,heightPx:c}),n=$(i),v=n==="auto"?null:{[W]:n},a=L(i,h),s=K(H),E=s===void 0?null:{[C]:""},r=Y(g),f=w(O()),[b,x]=R(null);P(()=>x(e.current?.ownerDocument??null),[e]);const A=!S({doc:b,whenUnset:!0}),o=u||f,y=J(e,n),m=d(q.Provider,{value:o?null:a,children:I}),p=j(A,f);return d(U,{as:"header",ref:e,"data-scrolled":u||void 0,"data-box-header":"",...v,...E,className:["sf-site-header",...r?[r.className]:[],"flex flex-col justify-center",l==="none"?"absolute":"fixed","inset-x-0 top-0 z-50",o?"border-b border-line backdrop-blur-md":"border-b border-transparent","transition-[background,border-color,transform] duration-300 ease-out"].join(" "),style:{...r?r.style:null,minHeight:`var(${V}, ${c}px)`,..._?z(G):null,...T?{transform:"translateY(-100%)"}:null,...o?{background:p,color:"var(--fg)","--sf-header-ground":p}:{color:"var(--sf-header-overlay-fg)","--sf-header-ground":"var(--sf-header-overlay-ground)"},...a?{"--sf-header-overlay-fg":a}:null,...s===void 0?null:{[N]:String(s/100)}},...X("header"),children:!o&&y?d(F,{children:m}):m})}export{re as default,ee as resolveStickyMode};
1
+ "use client";import{jsx as d}from"react/jsx-runtime";import{parseOption as D}from"efficient-shell/format";import{useEffect as R,useState as S}from"react";import{useRootIsDark as O}from"efficient-shell/theme";import{usePathname as w}from"next/navigation";import{useHeaderBar as B}from"./useHeaderBar.js";import{HEADER_LINK_OPACITY_ATTR as C,HEADER_LINK_OPACITY_VAR as N,headerSolidBackground as j,isProductPage as K,readHeaderLinkOpacity as L,readHeaderTopInk as M,resolveHeaderHeightPx as Y}from"../lib/content/header-bar.js";import{headerThemeWrap as V}from"../lib/content/header-theme.js";import{HEADER_SET_HEIGHT_VAR as W}from"efficient-web-builder/render/lib/document/header-clearance";import{HEADER_INK_OVERRIDE_ATTR as $,resolveHeaderInkMode as z}from"efficient-web-builder/render/lib/document/header-ink";import{centredCap as G,SITE_WIDTH_CAP as U}from"efficient-web-builder/format/lib/content/page-width";import{HideTaker as q}from"efficient-web-builder/render/components/ViewHideRoot";import{HeaderTopInkContext as F}from"efficient-web-builder/render/components/HeaderTopInkContext";import{BoxSurfaceProvider as J}from"efficient-web-builder/render/components/BoxSurfaceContext";import{useHeaderAtTopIsDark as Q}from"./useHeaderAtTopIsDark.js";import{usePageOwnsTop as X}from"./usePageOwnsTop.js";import{blockParts as Z}from"../lib/block-parts.js";const ee=Z("SiteHeader"),re=["none","always","on_scroll_up"],oe=t=>D(re,"always",t);function te({sticky:t,topTextColor:i,topTextCustom:h,linkOpacity:H,heightPx:g,theme:k,bandCapped:T=!1,children:_}){const l=oe(t),c=Y(g),{headerRef:e,scrolled:u,navHidden:I}=B({stickyMode:l,heightPx:c}),n=z(i),v=n==="auto"?null:{[$]:n},a=M(i,h),s=L(H),E=s===void 0?null:{[C]:""},r=V(k),m=K(w()),[b,x]=S(null);R(()=>x(e.current?.ownerDocument??null),[e]);const A=!O({doc:b,whenUnset:!0}),y=X(e),o=u||m||y,P=Q(e,n),f=d(F.Provider,{value:o?null:a,children:_}),p=j(A,m);return d(q,{as:"header",ref:e,"data-scrolled":u||void 0,"data-box-header":"",...v,...E,className:["sf-site-header",...r?[r.className]:[],"flex flex-col justify-center",l==="none"?"absolute":"fixed","inset-x-0 top-0 z-50",o?"border-b border-line backdrop-blur-md":"border-b border-transparent","transition-[background,border-color,transform] duration-300 ease-out"].join(" "),style:{...r?r.style:null,minHeight:`var(${W}, ${c}px)`,...T?G(U):null,...I?{transform:"translateY(-100%)"}:null,...o?{background:p,color:"var(--fg)","--sf-header-ground":p}:{color:"var(--sf-header-overlay-fg)","--sf-header-ground":"var(--sf-header-overlay-ground)"},...a?{"--sf-header-overlay-fg":a}:null,...s===void 0?null:{[N]:String(s/100)}},...ee("header"),children:!o&&P?d(J,{children:f}):f})}export{te as default,oe as resolveStickyMode};
@@ -1 +1 @@
1
- "use client";import{jsx as r,Fragment as E,jsxs as s}from"react/jsx-runtime";import oe from"next/link";import{usePathname as Qe}from"next/navigation";import{useCallback as Ze,useEffect as re,useRef as et,useState as v}from"react";import{rootIsDark as tt,watchRootTheme as nt}from"efficient-shell/format";import{useCart as ot}from"./CartContext.js";import{useSearch as rt}from"./SearchContext.js";import st,{useCountrySelectShows as lt}from"./CountrySelect.js";import{resolveCountryShowAs as at}from"../lib/content/country-show-as.js";import se from"./HeaderNavItem.js";import it from"efficient-web-builder/render/components/Logo";import{siteLengthCss as ct}from"efficient-web-builder/format/lib/content/css-length";import dt from"./MenuPlaceholderLabel.js";import{withRMark as le}from"efficient-web-builder/render/components/RMark";import{AccountButton as mt,CartButton as ut,SearchButton as ht}from"./HeaderTools.js";import ft from"./HeaderCallButton.js";import{useHeaderBar as pt}from"./useHeaderBar.js";import{useHeaderAtTopIsDark as gt}from"./useHeaderAtTopIsDark.js";import{useModalDismiss as bt}from"./useModalDismiss.js";import xt from"./ThemeToggle.js";import{products as vt}from"../lib/api/index.js";import{shouldFetchPublicHeaderSettings as yt}from"../lib/header-settings-fetch.js";import{menuDropdownAside as wt}from"../lib/menu-link.js";import{HEADER_MENU_PLACEHOLDER_COUNT as St}from"../lib/content/menu-placeholder.js";import{DEFAULT_SWITCH_SHOWN as kt}from"efficient-web-builder/format/lib/theme";import{chromeWidthStyle as Nt,resolveChromeWidth as Pt}from"efficient-web-builder/format/lib/content/page-width";import{headerThemeWrap as Tt}from"../lib/content/header-theme.js";import{headerSolidBackground as Et,isProductPage as It,resolveMenuRow as $t,resolveNavTextCase as Ct,resolveUtilStyle as Lt}from"../lib/content/header-bar.js";import{surfaceIsLight as _t}from"../lib/logo/surface-is-light.js";import{HEADER_HEIGHT_PX as Ht,HEADER_MENU_GAP_PX as Rt,HEADER_SET_HEIGHT_CSS as At}from"efficient-web-builder/render/lib/document/header-clearance";import{HEADER_INK_OVERRIDE_ATTR as Dt,resolveHeaderInkMode as Ut}from"efficient-web-builder/render/lib/document/header-ink";const ae={stacked:{grid:"hidden min-[1501px]:grid",flex:"hidden min-[1501px]:flex"},inline:{grid:"hidden view-tablet:grid",flex:"hidden view-tablet:flex"}},Mt=Array.from({length:St},()=>({href:"#",label:r(dt,{})}));function jt({previewSettings:f,initialSettings:I,editorPreview:$,showThemeToggle:ie,wordmark:ce,hideLogo:de,hideMenu:me,siteName:C,commerceEnabled:p=!0}={}){const ue=Qe(),B=It(ue),[c,y]=v(!1),{open:he,totals:fe}=ot(),{open:pe}=rt(),[L,ge]=v(!1),[be,xe]=v(null),[ve,ye]=v(null),[t,we]=v(I??null),n=f??(t?{logoUrl:t.logoUrl,reverseLogo:t.reverseLogo,logoReversed:t.logoReversed,logoInkIsDark:t.logoInkIsDark,logoPosition:t.logoPosition,logoSize:t.logoSize,logoSizePx:t.logoSizePx,logoSizeUnit:t.logoSizeUnit??null,menuItems:(t.menuItems??[]).map(e=>({label:e.label,url:e.url,dropdown_menu:null,dropdown_items:e.dropdownItems??[],dropdown_aside:e.dropdownAside??null})),menuSplit:t.menuSplit??3,menuPosition:t.menuPosition,menuRow:t.menuRow,menuGapPx:t.menuGapPx??null,menuGapUnit:t.menuGapUnit??null,searchEnabled:t.searchEnabled,searchPosition:t.searchPosition,searchRow:t.searchRow,countrySelectorEnabled:t.countrySelectorEnabled,countrySelectorShowAs:t.countrySelectorShowAs,countryUrls:t.countryUrls,accountEnabled:t.accountEnabled,cartEnabled:t.cartEnabled,utilStyle:t.utilStyle,navTextCase:t.navTextCase,lightReverseText:t.lightReverseText,topTextColor:t.topTextColor,transparentTop:t.transparentTop,surface:t.surface,theme:t.theme,width:t.width,heightPx:t.heightPx,borderThickness:t.borderThickness??null,sticky:t.sticky,callButton:t.callButton,callPhone:t.callPhone,callHref:t.callHref}:null),Se=de?null:n?.logoUrl??null,ke=n?.reverseLogo??!1,Ne=n?.logoReversed??null,Pe=n?.logoInkIsDark??null,i=n?.logoPosition??"center",Te=n?.logoSize??"medium",Ee=n?.logoSizePx??null,Ie=n?.logoSizeUnit??null,G=Math.min(Math.max(n?.menuSplit??3,1),4),$e=(n?.menuPosition??"left")==="center",Ce=(n?.menuPosition??"left")==="beside",F=$t(n?.menuRow)==="inline",_=n?.menuGapPx??null,Le=_!=null?{gap:ct(_,n?.menuGapUnit,"gap",Rt)??`${_}px`}:void 0,w=F?ae.inline:ae.stacked,_e=n?.searchEnabled??!1,W=n?.searchPosition??"right",He=n?.countrySelectorEnabled??!0,Re=at(n?.countrySelectorShowAs),H=n?.accountEnabled??!0,Ae=n?.cartEnabled??!0,R=Lt(n?.utilStyle)==="text",l=`mono-eyebrow${Ct(n?.navTextCase)==="capitalised"?" mono-eyebrow-plain":""}`,V=n?.countryUrls??{},De=Pt(n?.width),Ue=Nt(De)??void 0,Me=n?.heightPx??Ht.default,K=Math.round(n?.borderThickness??1),je=Number.isFinite(K)?Math.min(Math.max(K,0),20):1,X=n?.sticky??"always",A=Ut(n?.topTextColor),m=Tt(n?.theme),S=Object.keys(V),Y=lt(S.length?S:void 0),g=He?r(st,{countries:S.length?S:void 0,urls:f?void 0:V,showAs:Re}):null,{headerRef:b,scrolled:J,navHidden:ze}=pt({stickyMode:X,heightPx:Me}),Oe=m?JSON.stringify(m.style):null;re(()=>{const e=b.current?.ownerDocument??document,o=e.defaultView??window,T=ne=>ne?_t(o.getComputedStyle(ne).getPropertyValue("--bg")):null,O=()=>{ge(!tt({doc:e,whenUnset:!0})),xe(T(e.body)),ye(T(b.current))};O();const qe=nt(O,{doc:e}),te=new MutationObserver(O);return e.body&&te.observe(e.body,{attributes:!0,attributeFilter:["style"]}),()=>{qe(),te.disconnect()}},[b,Oe]);const x=ie??kt?r(xt,{}):null;re(()=>{if(!yt({editorPreview:!!$,hasPreviewSettings:!!f,hasInitialSettings:!!I}))return;let e=!1;return vt.getHeaderSettings().then(o=>!e&&we(o)).catch(o=>{console.warn("[header] settings fetch failed; using built-in defaults",o)}),()=>{e=!0}},[$,f,I]);const k=J||B,q=Et(L,B),Q=gt(b,A),Be=k||!Q,Ge=k?ve??L:(be??L)&&!Q,Fe=A==="auto"?null:{[Dt]:A},We=Ze(()=>y(!1),[]),D=et(null);bt({active:c,onDismiss:We,focusRef:D,trapRef:D});const d=(e,o,T="start")=>r(se,{item:e,dropdownAlign:T},o),Ve=!me&&(n?.menuItems?.length??0)>0,N=!!$||!!f,a=Ve?n.menuItems.map(e=>({href:e.url||"",label:le(e.label),plainLabel:e.label,dropdownItems:(e.dropdown_items??[]).map(o=>({href:o.url||"",label:le(o.label),plainLabel:o.label,description:o.description,image:o.image,badge:o.badge})),dropdownAside:wt(e.dropdown_aside)})):N?Mt.map(e=>({...e,plainLabel:"Menu item",dropdownItems:[]})):[],Ke=a.length>0||p&&H||!!g&&Y||!!x,Xe=i==="center"?a.slice(0,G):i==="right"?a:[],Ye=i==="center"?a.slice(G):i==="left"?a:[],P=_e&&p?r(ht,{onClick:N?void 0:pe,asText:R}):null,U=p&&H?r(mt,{asText:R}):null,M=e=>p&&Ae?r(ut,{onClick:he,count:fe.sets,asText:R,className:e}):null,Je=n?.callPhone??"",Z=n?.callHref??"",j=e=>n?.callButton&&(Z||N)?r(ft,{href:N?"":Z,label:e?"Call":Je||"Call"}):null,u=s(E,{children:[W==="left"?P:null,g,x,U,M(),W==="right"?P:null,j(!1)]}),z=(e,o=!1)=>r(oe,{href:"/","aria-label":C?`${C} home`:"Home",className:e,children:r(it,{variant:"header",scrolled:Be,src:Se,reverse:ke,onLightSurface:Ge,reversedSrc:Ne,inkIsDark:Pe,size:Te,sizePx:Ee,sizeUnit:Ie,wordmark:ce,siteName:C,fitToContainer:o})}),h=z("inline-flex shrink-0 items-center justify-center"),ee="flex min-w-0 flex-1 items-center overflow-x-clip [container-type:inline-size]";return s(E,{children:[r("header",{ref:b,"data-scrolled":J||void 0,...Fe,className:["sf-site-header",...m?[m.className]:[],X==="none"?"absolute":"fixed","inset-x-0 top-0 z-50","flex items-center","px-[var(--sf-site-gutter,40px)] max-view-tablet:px-[min(20px,var(--sf-site-gutter,40px))]",k?"border-solid border-line backdrop-blur-md":"border-solid border-transparent","transition-[background,border-color,transform] duration-300 ease-out"].join(" "),style:{...m?m.style:null,minHeight:At,borderBottomWidth:`${je}px`,...ze?{transform:"translateY(-100%)"}:null,...k?{background:q,color:"var(--fg)","--sf-header-ground":q}:{color:"var(--sf-header-overlay-fg)","--sf-header-ground":"var(--sf-header-overlay-ground)"}},children:s("div",{className:"w-full",style:Ue,children:[$e?s("div",{"data-header-band":"",className:`${w.grid} grid-cols-[1fr_auto_1fr] items-center gap-8`,children:[i==="right"?r("nav",{className:`${l} flex items-center gap-8`,children:u}):r("div",{className:"flex items-center",children:h}),r("nav",{className:`${l} flex items-center justify-center gap-8`,children:a.map((e,o)=>d(e,`${e.href}-${o}`,"center"))}),i==="right"?r("div",{className:"flex items-center justify-end",children:h}):r("nav",{className:`${l} flex items-center justify-end gap-8`,children:u})]}):i==="center"?s("div",{"data-header-band":"",className:`${w.grid} grid-cols-[1fr_auto_1fr] items-center gap-8`,children:[r("nav",{className:`${l} flex items-center gap-8`,children:Xe.map((e,o)=>d(e,`${e.href}-${o}`))}),h,s("nav",{className:`${l} flex items-center justify-end gap-8`,children:[Ye.map((e,o)=>d(e,`${e.href}-${o}`,"end")),u]})]}):Ce?s("div",{"data-header-band":"",className:`${w.flex} items-center justify-between gap-8`,children:[s("div",{className:"flex items-center gap-8",style:Le,children:[h,r("nav",{className:`${l} flex items-center gap-8`,children:a.map((e,o)=>d(e,`${e.href}-${o}`))})]}),r("nav",{className:`${l} flex items-center justify-end gap-8`,children:u})]}):r("div",{"data-header-band":"",className:`${w.flex} items-center justify-between gap-8`,children:i==="right"?s(E,{children:[s("nav",{className:`${l} flex items-center gap-8`,children:[a.map((e,o)=>d(e,`${e.href}-${o}`)),u]}),h]}):s(E,{children:[h,s("nav",{className:`${l} flex items-center gap-8`,children:[a.map((e,o)=>d(e,`${e.href}-${o}`)),u]})]})}),!F&&s("div",{"data-header-band":"",className:"hidden view-tablet:max-[1501px]:flex flex-col gap-3",children:[s("div",{className:"flex items-center justify-between",children:[z(ee,!0),s("div",{className:`${l} flex shrink-0 items-center gap-5`,children:[P,g,x,U,M(),j(!1)]})]}),r("nav",{className:`${l} flex items-center gap-6 border-t border-line/60 pt-3`,children:a.map((e,o)=>d(e,`${e.href}-${o}`))})]}),s("div",{"data-header-phone":"",className:"hidden max-view-tablet:flex items-center justify-between",children:[z(ee,!0),s("div",{className:"flex shrink-0 items-center gap-4",children:[P,U,M(l),j(!0),Ke&&s("button",{type:"button","aria-label":c?"Close menu":"Open menu","aria-expanded":c,onClick:()=>y(e=>!e),className:"flex h-11 w-11 flex-col items-center justify-center gap-2",children:[r("span",{className:`block h-px w-5 bg-current transition-transform ${c?"translate-y-[3px] rotate-45":""}`}),r("span",{className:`block h-px w-5 bg-current transition-transform ${c?"opacity-0":""}`}),r("span",{className:`block h-px w-5 bg-current transition-transform ${c?"-translate-y-[3px] -rotate-45":""}`})]})]})]})]})}),c&&s("div",{ref:D,role:"dialog","aria-modal":"true","aria-label":"Menu",tabIndex:-1,"data-header-phone-menu":"",className:"fixed inset-x-0 top-0 bottom-0 z-40 hidden flex-col gap-8 overflow-y-auto bg-bg px-6 pt-24 pb-10 max-view-tablet:flex",children:[a.map((e,o)=>r(se,{item:e,mobile:!0,onNavigate:()=>y(!1)},`${e.href}-${o}`)),s("div",{className:"mt-auto flex flex-col gap-4 border-t border-line pt-6",children:[p&&H&&s("div",{className:"flex items-center justify-between",children:[r("span",{className:"mono-eyebrow text-fg-dim",children:"Account"}),r(oe,{href:"/account",onClick:()=>y(!1),className:"mono-eyebrow underline",children:"Your account"})]}),g&&Y&&s("div",{className:"flex items-center justify-between",children:[r("span",{className:"mono-eyebrow text-fg-dim",children:"Region"}),g]}),x&&s("div",{className:"flex items-center justify-between",children:[r("span",{className:"mono-eyebrow text-fg-dim",children:"Theme"}),x]})]})]})]})}export{jt as default};
1
+ "use client";import{jsx as r,Fragment as E,jsxs as s}from"react/jsx-runtime";import oe from"next/link";import{usePathname as Ze}from"next/navigation";import{useCallback as et,useEffect as re,useRef as tt,useState as v}from"react";import{rootIsDark as nt,watchRootTheme as ot}from"efficient-shell/format";import{useCart as rt}from"./CartContext.js";import{useSearch as st}from"./SearchContext.js";import lt,{useCountrySelectShows as at}from"./CountrySelect.js";import{resolveCountryShowAs as it}from"../lib/content/country-show-as.js";import se from"./HeaderNavItem.js";import ct from"efficient-web-builder/render/components/Logo";import{siteLengthCss as dt}from"efficient-web-builder/format/lib/content/css-length";import mt from"./MenuPlaceholderLabel.js";import{withRMark as le}from"efficient-web-builder/render/components/RMark";import{AccountButton as ut,CartButton as ht,SearchButton as ft}from"./HeaderTools.js";import pt from"./HeaderCallButton.js";import{useHeaderBar as gt}from"./useHeaderBar.js";import{useHeaderAtTopIsDark as bt}from"./useHeaderAtTopIsDark.js";import{usePageOwnsTop as xt}from"./usePageOwnsTop.js";import{useModalDismiss as vt}from"./useModalDismiss.js";import yt from"./ThemeToggle.js";import{products as wt}from"../lib/api/index.js";import{shouldFetchPublicHeaderSettings as St}from"../lib/header-settings-fetch.js";import{menuDropdownAside as kt}from"../lib/menu-link.js";import{HEADER_MENU_PLACEHOLDER_COUNT as Nt}from"../lib/content/menu-placeholder.js";import{DEFAULT_SWITCH_SHOWN as Pt}from"efficient-web-builder/format/lib/theme";import{chromeWidthStyle as Tt,resolveChromeWidth as Et}from"efficient-web-builder/format/lib/content/page-width";import{headerThemeWrap as It}from"../lib/content/header-theme.js";import{headerSolidBackground as $t,isProductPage as Ct,resolveMenuRow as Lt,resolveNavTextCase as _t,resolveUtilStyle as Ht}from"../lib/content/header-bar.js";import{surfaceIsLight as Rt}from"../lib/logo/surface-is-light.js";import{HEADER_HEIGHT_PX as At,HEADER_MENU_GAP_PX as Dt,HEADER_SET_HEIGHT_CSS as Ut}from"efficient-web-builder/render/lib/document/header-clearance";import{HEADER_INK_OVERRIDE_ATTR as Mt,resolveHeaderInkMode as jt}from"efficient-web-builder/render/lib/document/header-ink";const ae={stacked:{grid:"hidden min-[1501px]:grid",flex:"hidden min-[1501px]:flex"},inline:{grid:"hidden view-tablet:grid",flex:"hidden view-tablet:flex"}},Ot=Array.from({length:Nt},()=>({href:"#",label:r(mt,{})}));function zt({previewSettings:p,initialSettings:I,editorPreview:$,showThemeToggle:ie,wordmark:ce,hideLogo:de,hideMenu:me,siteName:C,commerceEnabled:g=!0}={}){const ue=Ze(),B=Ct(ue),[c,y]=v(!1),{open:he,totals:fe}=rt(),{open:pe}=st(),[L,ge]=v(!1),[be,xe]=v(null),[ve,ye]=v(null),[t,we]=v(I??null),n=p??(t?{logoUrl:t.logoUrl,reverseLogo:t.reverseLogo,logoReversed:t.logoReversed,logoInkIsDark:t.logoInkIsDark,logoPosition:t.logoPosition,logoSize:t.logoSize,logoSizePx:t.logoSizePx,logoSizeUnit:t.logoSizeUnit??null,menuItems:(t.menuItems??[]).map(e=>({label:e.label,url:e.url,dropdown_menu:null,dropdown_items:e.dropdownItems??[],dropdown_aside:e.dropdownAside??null})),menuSplit:t.menuSplit??3,menuPosition:t.menuPosition,menuRow:t.menuRow,menuGapPx:t.menuGapPx??null,menuGapUnit:t.menuGapUnit??null,searchEnabled:t.searchEnabled,searchPosition:t.searchPosition,searchRow:t.searchRow,countrySelectorEnabled:t.countrySelectorEnabled,countrySelectorShowAs:t.countrySelectorShowAs,countryUrls:t.countryUrls,accountEnabled:t.accountEnabled,cartEnabled:t.cartEnabled,utilStyle:t.utilStyle,navTextCase:t.navTextCase,lightReverseText:t.lightReverseText,topTextColor:t.topTextColor,transparentTop:t.transparentTop,surface:t.surface,theme:t.theme,width:t.width,heightPx:t.heightPx,borderThickness:t.borderThickness??null,sticky:t.sticky,callButton:t.callButton,callPhone:t.callPhone,callHref:t.callHref}:null),Se=de?null:n?.logoUrl??null,ke=n?.reverseLogo??!1,Ne=n?.logoReversed??null,Pe=n?.logoInkIsDark??null,i=n?.logoPosition??"center",Te=n?.logoSize??"medium",Ee=n?.logoSizePx??null,Ie=n?.logoSizeUnit??null,G=Math.min(Math.max(n?.menuSplit??3,1),4),$e=(n?.menuPosition??"left")==="center",Ce=(n?.menuPosition??"left")==="beside",F=Lt(n?.menuRow)==="inline",_=n?.menuGapPx??null,Le=_!=null?{gap:dt(_,n?.menuGapUnit,"gap",Dt)??`${_}px`}:void 0,w=F?ae.inline:ae.stacked,_e=n?.searchEnabled??!1,W=n?.searchPosition??"right",He=n?.countrySelectorEnabled??!0,Re=it(n?.countrySelectorShowAs),H=n?.accountEnabled??!0,Ae=n?.cartEnabled??!0,R=Ht(n?.utilStyle)==="text",l=`mono-eyebrow${_t(n?.navTextCase)==="capitalised"?" mono-eyebrow-plain":""}`,V=n?.countryUrls??{},De=Et(n?.width),Ue=Tt(De)??void 0,Me=n?.heightPx??At.default,K=Math.round(n?.borderThickness??1),je=Number.isFinite(K)?Math.min(Math.max(K,0),20):1,X=n?.sticky??"always",A=jt(n?.topTextColor),m=It(n?.theme),S=Object.keys(V),Y=at(S.length?S:void 0),b=He?r(lt,{countries:S.length?S:void 0,urls:p?void 0:V,showAs:Re}):null,{headerRef:u,scrolled:J,navHidden:Oe}=gt({stickyMode:X,heightPx:Me}),ze=m?JSON.stringify(m.style):null;re(()=>{const e=u.current?.ownerDocument??document,o=e.defaultView??window,T=ne=>ne?Rt(o.getComputedStyle(ne).getPropertyValue("--bg")):null,z=()=>{ge(!nt({doc:e,whenUnset:!0})),xe(T(e.body)),ye(T(u.current))};z();const Qe=ot(z,{doc:e}),te=new MutationObserver(z);return e.body&&te.observe(e.body,{attributes:!0,attributeFilter:["style"]}),()=>{Qe(),te.disconnect()}},[u,ze]);const x=ie??Pt?r(yt,{}):null;re(()=>{if(!St({editorPreview:!!$,hasPreviewSettings:!!p,hasInitialSettings:!!I}))return;let e=!1;return wt.getHeaderSettings().then(o=>!e&&we(o)).catch(o=>{console.warn("[header] settings fetch failed; using built-in defaults",o)}),()=>{e=!0}},[$,p,I]);const Be=xt(u),k=J||B||Be,q=$t(L,B),Q=bt(u,A),Ge=k||!Q,Fe=k?ve??L:(be??L)&&!Q,We=A==="auto"?null:{[Mt]:A},Ve=et(()=>y(!1),[]),D=tt(null);vt({active:c,onDismiss:Ve,focusRef:D,trapRef:D});const d=(e,o,T="start")=>r(se,{item:e,dropdownAlign:T},o),Ke=!me&&(n?.menuItems?.length??0)>0,N=!!$||!!p,a=Ke?n.menuItems.map(e=>({href:e.url||"",label:le(e.label),plainLabel:e.label,dropdownItems:(e.dropdown_items??[]).map(o=>({href:o.url||"",label:le(o.label),plainLabel:o.label,description:o.description,image:o.image,badge:o.badge})),dropdownAside:kt(e.dropdown_aside)})):N?Ot.map(e=>({...e,plainLabel:"Menu item",dropdownItems:[]})):[],Xe=a.length>0||g&&H||!!b&&Y||!!x,Ye=i==="center"?a.slice(0,G):i==="right"?a:[],Je=i==="center"?a.slice(G):i==="left"?a:[],P=_e&&g?r(ft,{onClick:N?void 0:pe,asText:R}):null,U=g&&H?r(ut,{asText:R}):null,M=e=>g&&Ae?r(ht,{onClick:he,count:fe.sets,asText:R,className:e}):null,qe=n?.callPhone??"",Z=n?.callHref??"",j=e=>n?.callButton&&(Z||N)?r(pt,{href:N?"":Z,label:e?"Call":qe||"Call"}):null,h=s(E,{children:[W==="left"?P:null,b,x,U,M(),W==="right"?P:null,j(!1)]}),O=(e,o=!1)=>r(oe,{href:"/","aria-label":C?`${C} home`:"Home",className:e,children:r(ct,{variant:"header",scrolled:Ge,src:Se,reverse:ke,onLightSurface:Fe,reversedSrc:Ne,inkIsDark:Pe,size:Te,sizePx:Ee,sizeUnit:Ie,wordmark:ce,siteName:C,fitToContainer:o})}),f=O("inline-flex shrink-0 items-center justify-center"),ee="flex min-w-0 flex-1 items-center overflow-x-clip [container-type:inline-size]";return s(E,{children:[r("header",{ref:u,"data-scrolled":J||void 0,...We,className:["sf-site-header",...m?[m.className]:[],X==="none"?"absolute":"fixed","inset-x-0 top-0 z-50","flex items-center","px-[var(--sf-site-gutter,40px)] max-view-tablet:px-[min(20px,var(--sf-site-gutter,40px))]",k?"border-solid border-line backdrop-blur-md":"border-solid border-transparent","transition-[background,border-color,transform] duration-300 ease-out"].join(" "),style:{...m?m.style:null,minHeight:Ut,borderBottomWidth:`${je}px`,...Oe?{transform:"translateY(-100%)"}:null,...k?{background:q,color:"var(--fg)","--sf-header-ground":q}:{color:"var(--sf-header-overlay-fg)","--sf-header-ground":"var(--sf-header-overlay-ground)"}},children:s("div",{className:"w-full",style:Ue,children:[$e?s("div",{"data-header-band":"",className:`${w.grid} grid-cols-[1fr_auto_1fr] items-center gap-8`,children:[i==="right"?r("nav",{className:`${l} flex items-center gap-8`,children:h}):r("div",{className:"flex items-center",children:f}),r("nav",{className:`${l} flex items-center justify-center gap-8`,children:a.map((e,o)=>d(e,`${e.href}-${o}`,"center"))}),i==="right"?r("div",{className:"flex items-center justify-end",children:f}):r("nav",{className:`${l} flex items-center justify-end gap-8`,children:h})]}):i==="center"?s("div",{"data-header-band":"",className:`${w.grid} grid-cols-[1fr_auto_1fr] items-center gap-8`,children:[r("nav",{className:`${l} flex items-center gap-8`,children:Ye.map((e,o)=>d(e,`${e.href}-${o}`))}),f,s("nav",{className:`${l} flex items-center justify-end gap-8`,children:[Je.map((e,o)=>d(e,`${e.href}-${o}`,"end")),h]})]}):Ce?s("div",{"data-header-band":"",className:`${w.flex} items-center justify-between gap-8`,children:[s("div",{className:"flex items-center gap-8",style:Le,children:[f,r("nav",{className:`${l} flex items-center gap-8`,children:a.map((e,o)=>d(e,`${e.href}-${o}`))})]}),r("nav",{className:`${l} flex items-center justify-end gap-8`,children:h})]}):r("div",{"data-header-band":"",className:`${w.flex} items-center justify-between gap-8`,children:i==="right"?s(E,{children:[s("nav",{className:`${l} flex items-center gap-8`,children:[a.map((e,o)=>d(e,`${e.href}-${o}`)),h]}),f]}):s(E,{children:[f,s("nav",{className:`${l} flex items-center gap-8`,children:[a.map((e,o)=>d(e,`${e.href}-${o}`)),h]})]})}),!F&&s("div",{"data-header-band":"",className:"hidden view-tablet:max-[1501px]:flex flex-col gap-3",children:[s("div",{className:"flex items-center justify-between",children:[O(ee,!0),s("div",{className:`${l} flex shrink-0 items-center gap-5`,children:[P,b,x,U,M(),j(!1)]})]}),r("nav",{className:`${l} flex items-center gap-6 border-t border-line/60 pt-3`,children:a.map((e,o)=>d(e,`${e.href}-${o}`))})]}),s("div",{"data-header-phone":"",className:"hidden max-view-tablet:flex items-center justify-between",children:[O(ee,!0),s("div",{className:"flex shrink-0 items-center gap-4",children:[P,U,M(l),j(!0),Xe&&s("button",{type:"button","aria-label":c?"Close menu":"Open menu","aria-expanded":c,onClick:()=>y(e=>!e),className:"flex h-11 w-11 flex-col items-center justify-center gap-2",children:[r("span",{className:`block h-px w-5 bg-current transition-transform ${c?"translate-y-[3px] rotate-45":""}`}),r("span",{className:`block h-px w-5 bg-current transition-transform ${c?"opacity-0":""}`}),r("span",{className:`block h-px w-5 bg-current transition-transform ${c?"-translate-y-[3px] -rotate-45":""}`})]})]})]})]})}),c&&s("div",{ref:D,role:"dialog","aria-modal":"true","aria-label":"Menu",tabIndex:-1,"data-header-phone-menu":"",className:"fixed inset-x-0 top-0 bottom-0 z-40 hidden flex-col gap-8 overflow-y-auto bg-bg px-6 pt-24 pb-10 max-view-tablet:flex",children:[a.map((e,o)=>r(se,{item:e,mobile:!0,onNavigate:()=>y(!1)},`${e.href}-${o}`)),s("div",{className:"mt-auto flex flex-col gap-4 border-t border-line pt-6",children:[g&&H&&s("div",{className:"flex items-center justify-between",children:[r("span",{className:"mono-eyebrow text-fg-dim",children:"Account"}),r(oe,{href:"/account",onClick:()=>y(!1),className:"mono-eyebrow underline",children:"Your account"})]}),b&&Y&&s("div",{className:"flex items-center justify-between",children:[r("span",{className:"mono-eyebrow text-fg-dim",children:"Region"}),b]}),x&&s("div",{className:"flex items-center justify-between",children:[r("span",{className:"mono-eyebrow text-fg-dim",children:"Theme"}),x]})]})]})]})}export{zt as default};
@@ -0,0 +1,2 @@
1
+ import { type RefObject } from "react";
2
+ export declare function usePageOwnsTop(headerRef: RefObject<HTMLElement | null>): boolean;
@@ -0,0 +1 @@
1
+ "use client";import{useEffect as a,useState as m}from"react";import{usePathname as c}from"next/navigation";import{pageOwnsTop as u}from"../lib/content/header-bar.js";function w(e){const t=c(),[o,r]=m(!1);return a(()=>{const n=()=>r(u(e.current?.ownerDocument??document));n();const s=requestAnimationFrame(n);return()=>cancelAnimationFrame(s)},[e,t]),o}export{w as usePageOwnsTop};
@@ -1 +1 @@
1
- import{PREVIEW_TOKEN_HEADER as dt,SITE_HOST_HEADER as ut,SITE_SLUG_HEADER as lt}from"../site-headers.js";import{PRODUCT_API_BASE as pt,PRODUCT_BACKEND_URL as H}from"./origins.js";import{listRows as m}from"./list-rows.js";import{parseOption as yt}from"efficient-shell/format";import{backendHopHeaders as ht,clientIpFromForwardedFor as ft,FORWARDED_FOR_HEADER as gt,hopCachingOf as mt}from"../forwarded-for.js";import wt from"efficient-web-builder/format/lib/document/media-manifest.json";import{auth as O}from"../auth.js";import{efficientClientOpen as St}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 Pt=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.",Ot=new Set([502,503,504]),k=0,bt="This editor runs on its host's own backend, which does not serve this request.",Tt=5e3,At=15e3,Rt=()=>typeof window>"u"?Tt: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(Rt())}const B=t=>t instanceof Error&&t.name==="TimeoutError",q=(t,e)=>Ot.has(t)?v:e,Et=["admin","venue"];let G="admin";function $e(t){G=yt(Et,"admin",t)}function _t(){return G}const Ut=/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/;let W=null;function Ce(t){W=t&&Ut.test(t)?t:null}function $t(){return W}function Ct(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:u,audience:l,...y}=e;if(typeof window<"u"&&!St())throw new w(k,bt,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??Pt}${Ct(t)}`,{...y,headers:{...a?{}:{"Content-Type":"application/json"},...n?{Authorization:`Bearer ${n}`}:{},...l===null?{}:{"X-Portal-Audience":l??"shop"},...u},signal:y.signal??M({...y,audience:l})})}catch(h){throw h instanceof TypeError||B(h)?new w(k,v,null):h}let o;try{o=await r.text()}catch(h){throw B(h)?new w(k,v,null):h}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 h=(p&&typeof p=="object"&&"detail"in p&&typeof p.detail=="string"?p.detail:null)??q(r.status,r.statusText);throw new w(r.status,h,p)}return p}let A=null;async function j(){return A||(A=Nt().finally(()=>{A=null}),A)}async function Nt(){const t=O.takeLegacyRefresh(),e=await kt.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 u=await j();return await i(t,{...e,token:u})}catch{throw O.clear(),s}}}const It=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 V(t,e){const[n,s=""]=t.split("?"),u=[];let l="1";for(let y=0;y<K&&l;y++){const a=new URLSearchParams(s);a.set("page_size",String(It)),l!=="1"&&a.set("page",l);const r=await g(`${n}?${a.toString()}`);u.push(...m(r)),l=vt(r.next)}return l&&console.warn(`[${e}] stopped at ${K} pages (${u.length} rows); list may be truncated`),u}async function X(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 kt={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:()=>V("/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=>V(`/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 Lt,absolutizeApiUrl as L}from"efficient-web-builder/render/lib/media";import{analyzeLogoSvg as Jt,isSvgUrl as xt}from"efficient-web-builder/format/lib/logo/reverse-svg";import{getEditorSiteId as Dt}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 Ft}from"../sections/dealer-finder.js";import{SIGN_UP_PATH as Mt,SIGN_UP_VERIFY_PATH as Bt,SIGN_UP_WAITING_PATH as qt,WORKSPACE_FINDS_PATH as Gt,WORKSPACE_FIND_OPEN_PATH as Wt,signInUrlOf as jt,readLinkAnswer as Q,readSignUpAvailability as zt,readSignUpSent as Kt,signUpAvailabilityPath as Vt}from"../sections/sign-up.js";function S(t){if(typeof t=="string")return t.startsWith("/media/")?Lt(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(([u,l])=>[S(u),l])):S(s);return e}return t}import{PRODUCT_API_BASE as Ze}from"./origins.js";const tt=typeof window>"u"&&H!=="",Xt=tt?H:pt,Zt=Ht,b=()=>({baseUrl:Zt(),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[u,l]of Object.entries(e))l!=null&&l!==""&&s.set(u,String(l));return s.set("pageSize",String(et)),n&&s.set("cursor",n),`/api/v1${t}?${s.toString()}`}function Yt(t,e){return J("/wheels",{process:t},e)}const rt=et;function Qt(t,e){return J("/wheels",{slug:t.join(",")},e)}function te(t,e,n){return J("/products",{kind:t.join(","),make:e?.make,model:e?.model,year:e?.year,modification:e?.modification},n)}function ee(t){if(!t)return null;try{return new URL(t,"http://cursor.invalid").searchParams.get("cursor")}catch{return null}}async function x(t,e,n=()=>!1,s=()=>!1){const u=[];let l=null;try{for(let y=0;y<at;y++){const a=await i(await e(l),await d());if(u.push(...m(a)),l=ee(a.next),!l)break;if(s(u))return u}l&&console.warn(`[${t}] stopped at ${at} pages (${u.length} rows); catalog may be truncated`)}catch(y){if(n(y))throw y;console.warn(`[${t}] product API unavailable, returning []`,y)}return u}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 ae()).host}async function ae(){try{const{headers:t}=await import("next/headers"),e=await t(),n=l=>l?.split(",")[0]?.split(":")[0]?.trim().toLowerCase()||null,s=n(e.get(ut)??e.get("x-forwarded-host")??e.get("host")),u=n(e.get("host"));return{host:s,matchesRequestHost:s!==null&&s===u}}catch{return{host:null,matchesRequestHost:!1}}}async function re(){try{const{headers:t}=await import("next/headers");return ft((await t()).get(gt))}catch{return null}}async function ne(){try{const{headers:t}=await import("next/headers");return(await t()).get(lt)||null}catch{return null}}async function se(){const t=await ne();if(t)return`site=${encodeURIComponent(t)}`;const e=await ot();return e?`host=${encodeURIComponent(e)}`:""}async function f(t){if(typeof window<"u"){const e=Y();return e?$(t,`site=${encodeURIComponent(e)}`):t}return $(t,await se())}function $(t,e){return e?`${t}${t.includes("?")?"&":"?"}${e}`:t}const oe="preview";async function ie(){if(typeof window<"u")return null;try{const{headers:t}=await import("next/headers");return(await t()).get(dt)}catch{return null}}async function ce(){try{const{headers:t}=await import("next/headers");return(await t()).get("user-agent")}catch{return null}}async function D(t,e){const n=await ie();if(n===null)return[await f(t),await d(e)];const s=$(await f(t),`${oe}=${encodeURIComponent(n)}`),{next:u,cache:l,...y}=e??{},a=await d({...y,cache:"no-store"}),r=await ce();return r&&(a.headers={...a.headers,"user-agent":r}),[s,a]}async function de(t){if(!tt)return;const[e,n]=await Promise.all([ot(),re()]),s=ht(e,n,t);return Object.keys(s).length>0?s:void 0}async function d(t){const e=await de(mt(t)),n={baseUrl:Xt,...t};return e&&(n.headers={...e,...t?.headers}),n}const R=typeof window>"u";function E(t,e){const n=new URLSearchParams;for(const[u,l]of Object.entries(e))l!==void 0&&l!==""&&n.set(u,String(l));const s=n.toString();return`/api/v1/fitment${t}${s?`?${s}`:""}`}const xe={listMakes:async t=>{if(R){const{fitmentData:n}=await import("./fitment-data.js");return n.makes(t)}const e=await i(E("/makes",{region:t}),b());return m(e)},listModels:async(t,e)=>{if(R){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 m(n)},listYears:async(t,e,n)=>{if(R){const{fitmentData:u}=await import("./fitment-data.js");return u.years(t,e,n)}const s=await i(E("/years",{make:t,model:e,region:n}),b());return m(s)},listModifications:async(t,e,n,s)=>{if(R){const{fitmentData:l}=await import("./fitment-data.js");return l.modifications(t,e,n,s)}const u=await i(E("/modifications",{make:t,model:e,year:n,region:s}),b());return m(u)},getStockFitment:async(t,e,n,s,u)=>{if(R){const{fitmentData:l}=await import("./fitment-data.js");return l.stockFitment(t,e,n,s,u)}return i(E("/stock-fitment",{make:t,model:e,year:n,modification:s,region:u}),b())}},De={listWheels:async(t,e={})=>{const n=await x("products.listWheels",async s=>await f(Yt(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 u=await Promise.all(s.map(a=>x("products.listWheelsBySlug",async r=>await f(Qt(a,r)),e.throwOnFailure?()=>!0:nt))),l=new Set(n),y=u.flat().filter(a=>l.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 x("products.listCatalog",async u=>await f(te(t,e,u)),n.throwOnFailure?()=>!0:nt,n.maxRows===void 0?void 0:u=>st([...u]).length>=n.maxRows);return st(S(s))},getWheel:async t=>F(S(await i(await f(c(`/wheels/${t}`)),await d()))),getTyre:async t=>S(await i(await f(c(`/tyres/${t}`)),await d())),listBundles:async(t={})=>{try{return await i(await f(c("/bundles")),await d())}catch(e){if(t.throwOnFailure)throw e;return[]}},getBundle:async t=>i(await f(c(`/bundles/${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 u=s.toString(),l=await i(`/api/v1/gallery-builds${u?`?${u}`:""}`,b());return S(m(l))}catch(s){return console.warn("[products.listGalleryBuilds] product API unavailable, returning []",s),[]}},getSite:async()=>i(await f(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 f(c("/pages")),await d())),listPopups:async()=>i(await f(c("/popups")),await d()),listProductTemplates:async()=>{try{return await i(await f(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 f(`${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 f(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 f(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 f(c("/product-type-choices")),await d())}catch(t){return console.warn("[products.listProductTypeChoices] unavailable, returning []",t),[]}},listFieldUsage:async()=>{try{return await i(await f(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,u]=await D(c(`/pages/${t}`)+n,e.revalidate!==void 0?{next:{revalidate:e.revalidate}}:void 0);return S(await i(s,u))},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(u=>({...u,coverImage:L(u.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/${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)})),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 f(s?`${n}?${s}`:n),await d())}catch(u){return console.warn("[products.listReviews] product API unavailable, returning []",u),[]}},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 X(e,n)).data:i(e,n)},validateCoupon:async t=>{const{data:e,asShopper:n}=await X(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 D(c("/header-settings"),{signal:t})),n=L(e.logoUrl);let s=null,u=null;if(n&&xt(n)){const l=await Jt(n,t);l&&(s=l.reversed,u=l.inkIsDark)}return{...e,logoUrl:n,logoReversed:s,logoInkIsDark:u}},getThemeSettings:async()=>i(...await D(c("/theme-settings"))),getChatSettings:async()=>i(await f(c("/chat-settings")),await d())},He={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 ue 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}`:""}`},N=t=>`/api/storefront/sites/${encodeURIComponent(t)}/`,le=t=>`${N(t)}currencies/`,pe="/api/storefront/media/ingest/";class ye 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 he(){const t=Dt();if(!t)throw new ye;return`${pe}?${new URLSearchParams({site:t})}`}const fe="X-Puck-Media-Manifest",it=wt.contentHash,I={"X-Media-Manifest":it,[fe]:it},Fe=ct({});function ct(t){return(e,n={})=>{const s=$t(),u=t.headers||s?{...s?{"Accept-Language":s}:{},...t.headers,...n.headers}:void 0;return i(e,{...n,...t.baseUrl!==void 0?{baseUrl:t.baseUrl}:{},...u?{headers:u}:{},audience:t.audience??_t()})}}function ge(t={}){const e=ct(t),n=t.siteDrafts===!0,s=a=>C("header-settings",a,n),u=a=>C("theme-settings",a,n),l=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 h=await e(`/api/storefront/pages/?${p.toString()}`,{token:r}),P=m(h);if(!o&&P.length>1)throw new ue(a,P.length);return P[0]??null},getPageById:(a,r)=>e(`/api/storefront/pages/${a}/`,{token:r}),saveLayout:(a,r,o,p,h)=>e(`/api/storefront/pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r,expected_updated_at:p,...h?{client_id:h}:{}}),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:I,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:I,token:o}),listTemplatePages:async(a,r)=>{const o=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(a)}`,{token:r});return m(o)},getPageLibrary:async a=>{const r=await e("/api/storefront/page-templates/?is_page_library=true&is_active=true",{token:a});return m(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 m(p)[0]??null},createTemplatePage:(a,r,o)=>e("/api/storefront/template-pages/",{method:"POST",body:JSON.stringify({template:a,...r}),headers:I,token:o}),saveTemplatePageLayout:(a,r,o)=>e(`/api/storefront/template-pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r}),headers:I,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 m(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 m(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 m(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[...m(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[...m(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(),h=await e(`/api/storefront/wheel-curations/summaries/${p?`?${p}`:""}`,{token:a});return S(h)},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(),h=await e(`/api/storefront/products/${p?`?${p}`:""}`,{token:a});return S(h)},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(N(a),{token:r}),listSites:async a=>{const r=await e("/api/storefront/sites/?no_page=true",{token:a});return m(r)},listSiteCurrencies:async(a,r)=>{const o=await e(le(a),{token:r});return Array.isArray(o)?o:[]},publishSite:(a,r)=>e(`${N(a)}publish/`,{method:"POST",token:r}),getSiteLiveState:(a,r)=>e(`${N(a)}live-state/`,{token:r}),getThemeSettings:(a,r)=>e(u(r),{token:a}),updateThemeSettings:(a,r,o)=>e(u(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(l(r),{token:a}),updateChatSettings:(a,r,o)=>e(l(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(he(),{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 m(p)}}}const Me=ge({siteDrafts:!0});function me(t){const e=t.trim();return e?`/api/v1/dealers?${new URLSearchParams({near:e}).toString()}`:"/api/v1/dealers"}async function Be(t){return Ft(await i(me(t)))}const T={audience:null,baseUrl:""};async function qe(t,e){return zt(await i(Vt(t,e),T))}async function Ge(t){return Kt(await i(Mt,{...T,method:"POST",body:JSON.stringify(t)}))}async function We(t){try{const e=await i(Bt,{...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 je(t,e){await i(qt,{...T,method:"POST",body:JSON.stringify({email:e.trim(),...t?{product:t}:{}})})}async function ze(t,e){await i(Gt,{...T,method:"POST",body:JSON.stringify({email:e.trim(),...t?{product:t}:{}})})}async function Ke(t){try{return jt(await i(Wt,{...T,method:"POST",body:JSON.stringify({token:t})}))}catch(e){if(e instanceof w&&we.has(e.status))return"";throw e}}const we=new Set([400,404,410]);export{Pt as API_URL,ue as AmbiguousPageSlugError,w as ApiError,At as BROWSER_READ_TIMEOUT_MS,bt as EFFICIENT_CLIENT_CLOSED_MESSAGE,ye as MediaUploadDestinationError,oe as PREVIEW_PARAM,Ze as PRODUCT_API_BASE,Tt as SERVER_READ_TIMEOUT_MS,v as SERVER_UNREACHABLE_MESSAGE,k as STATUS_NETWORK_ERROR,Fe as adminFetch,kt as api,i as apiFetch,$ as appendSiteQuery,ze as askForWorkspaces,Ge as askToSignUp,He as bookings,ge as createStorefrontAdmin,me as dealersPath,M as defaultRequestDeadline,he as editorMediaUploadPath,_t as editorPortalAudience,$t as editorRequestLanguage,Be as fetchDealers,qe as fetchSignUpAvailability,xe as fitment,je as joinSignUpWaitingList,We as openSignUpLink,Ke as openWorkspaceFind,De as products,Rt as readDeadlineMs,re as resolveClientIp,S as resolveMediaUrls,ie as resolvePreviewToken,ot as resolveSiteHost,ae as resolveSiteHostSource,ne as resolveSiteSlug,Ce as setEditorLanguage,$e as setEditorPortalAudience,Me 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 H,productBackendUrlNow as yt}from"./origins.js";import{listRows as m}from"./list-rows.js";import{parseOption as ft}from"efficient-shell/format";import{backendHopHeaders as ht,clientIpFromForwardedFor as gt,FORWARDED_FOR_HEADER as mt,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 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.",At=5e3,Rt=15e3,Et=()=>typeof window>"u"?At:Rt;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)?v:e,_t=["admin","venue"];let G="admin";function Ne(t){G=ft(_t,"admin",t)}function Ut(){return G}const $t=/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/;let W=null;function Ie(t){W=t&&$t.test(t)?t:null}function Ct(){return W}function Nt(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}${Nt(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 A=null;async function j(){return A||(A=It().finally(()=>{A=null}),A)}async function It(){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(...m(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 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(([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"&&H!=="",Zt=tt?H:pt,Yt=Ft,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(...m(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 gt((await t()).get(mt))}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?$(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 h(t),await l(e)];const s=$(await h(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 R=typeof window>"u";function E(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 He={listMakes:async t=>{if(R){const{fitmentData:n}=await import("./fitment-data.js");return n.makes(t)}const e=await i(E("/makes",{region:t}),b());return m(e)},listModels:async(t,e)=>{if(R){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 m(n)},listYears:async(t,e,n)=>{if(R){const{fitmentData:c}=await import("./fitment-data.js");return c.years(t,e,n)}const s=await i(E("/years",{make:t,model:e,region:n}),b());return m(s)},listModifications:async(t,e,n,s)=>{if(R){const{fitmentData:u}=await import("./fitment-data.js");return u.modifications(t,e,n,s)}const c=await i(E("/modifications",{make:t,model:e,year:n,region:s}),b());return m(c)},getStockFitment:async(t,e,n,s,c)=>{if(R){const{fitmentData:u}=await import("./fitment-data.js");return u.stockFitment(t,e,n,s,c)}return i(E("/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 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 c=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=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 h(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=>F(S(await i(await h(d(`/wheels/${t}`)),await l()))),getTyre:async t=>S(await i(await h(d(`/tyres/${t}`)),await l())),listBundles:async(t={})=>{try{return await i(await h(d("/bundles")),await l())}catch(e){if(t.throwOnFailure)throw e;return[]}},getBundle:async t=>i(await h(d(`/bundles/${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(m(u))}catch(s){return console.warn("[products.listGalleryBuilds] product API unavailable, returning []",s),[]}},getSite:async()=>i(await h(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 h(d("/pages")),await l())),listPopups:async()=>i(await h(d("/popups")),await l()),listProductTemplates:async()=>{try{return await i(await h(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 h(`${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 h(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 h(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 h(d("/product-type-choices")),await l())}catch(t){return console.warn("[products.listProductTypeChoices] unavailable, returning []",t),[]}},listFieldUsage:async()=>{try{return await i(await h(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/${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/${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)})),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 h(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 h(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}`:""}`},N=t=>`/api/storefront/sites/${encodeURIComponent(t)}/`,ye=t=>`${N(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 ge(){const t=Ht();if(!t)throw new he;return`${fe}?${new URLSearchParams({site:t})}`}const me="X-Puck-Media-Manifest",it=St.contentHash,I={"X-Media-Manifest":it,[me]: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=m(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:I,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:I,token:o}),listTemplatePages:async(a,r)=>{const o=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(a)}`,{token:r});return m(o)},getPageLibrary:async a=>{const r=await e("/api/storefront/page-templates/?is_page_library=true&is_active=true",{token:a});return m(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 m(p)[0]??null},createTemplatePage:(a,r,o)=>e("/api/storefront/template-pages/",{method:"POST",body:JSON.stringify({template:a,...r}),headers:I,token:o}),saveTemplatePageLayout:(a,r,o)=>e(`/api/storefront/template-pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r}),headers:I,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 m(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 m(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 m(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[...m(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[...m(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(N(a),{token:r}),listSites:async a=>{const r=await e("/api/storefront/sites/?no_page=true",{token:a});return m(r)},listSiteCurrencies:async(a,r)=>{const o=await e(ye(a),{token:r});return Array.isArray(o)?o:[]},publishSite:(a,r)=>e(`${N(a)}publish/`,{method:"POST",token:r}),getSiteLiveState:(a,r)=>e(`${N(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(ge(),{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 m(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,Rt as BROWSER_READ_TIMEOUT_MS,Tt as EFFICIENT_CLIENT_CLOSED_MESSAGE,he as MediaUploadDestinationError,ie as PREVIEW_PARAM,Qe as PRODUCT_API_BASE,At 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,ge as editorMediaUploadPath,Ut as editorPortalAudience,Ct 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,Ie as setEditorLanguage,Ne as setEditorPortalAudience,qe as storefrontAdmin};
@@ -1,2 +1,3 @@
1
1
  export declare const PRODUCT_API_BASE: string;
2
+ export declare const productBackendUrlNow: () => string;
2
3
  export declare const PRODUCT_BACKEND_URL: string;
@@ -1 +1 @@
1
- const _=process.env.NEXT_PUBLIC_PRODUCT_API_URL??"",e=(process.env.PRODUCT_BACKEND_URL??"").replace(/\/+$/,"");export{_ as PRODUCT_API_BASE,e as PRODUCT_BACKEND_URL};
1
+ const o=process.env.NEXT_PUBLIC_PRODUCT_API_URL??"",e=()=>(process.env.PRODUCT_BACKEND_URL??"").replace(/\/+$/,""),_=e();export{o as PRODUCT_API_BASE,_ as PRODUCT_BACKEND_URL,e as productBackendUrlNow};
@@ -1,6 +1,9 @@
1
1
  export declare function resolveHeaderHeightPx(v: unknown): number;
2
2
  export declare const UNDER_HEADER_SHEET_CLASS = "fixed inset-x-0 bottom-0 top-[var(--sf-header-h,88px)]";
3
3
  export declare const isProductPage: (pathname: string | null | undefined) => boolean;
4
+ export declare const SITE_MAIN_ATTR = "data-site-main";
5
+ export declare const TOP_SPACE_SHARED = "shared";
6
+ export declare function pageOwnsTop(doc: Document | null | undefined): boolean;
4
7
  export declare const headerSolidBackground: (isLight: boolean, productPage: boolean) => string;
5
8
  export declare const HEADER_NAV_TEXT_CASES: readonly [{
6
9
  readonly label: "Uppercase";
@@ -1 +1 @@
1
- import{HEADER_HEIGHT_PX as r}from"efficient-web-builder/render/lib/document/header-clearance";import{parseOption as o}from"efficient-shell/format";function T(e){return typeof e=="number"&&Number.isInteger(e)&&e>=r.min&&e<=r.max?e:r.default}const L="fixed inset-x-0 bottom-0 top-[var(--sf-header-h,88px)]",d=e=>!!e&&e.startsWith("/wheels/")&&e!=="/wheels",I=(e,t)=>!e&&t?"var(--section-bg)":"var(--bg)",n=[{label:"Uppercase",value:"uppercase"},{label:"Capitalised",value:"capitalised"}],a="uppercase",C=e=>o(n,a,e),l=[{label:"Icon",value:"icon"},{label:"Text",value:"text"}],s="icon",m=e=>o(l,s,e),D=[{label:"Own row",value:"top"},{label:"Same row",value:"inline"}],S="top",b=e=>e==="inline"?"inline":e==="top"||e==="bottom"?"top":null,E="custom";function N(e,t){return e!==E||typeof t!="string"?null:t.trim()||null}const O=80,_=0,i=100,f="data-header-link-opacity",g="--sf-header-link-opacity";function h(e){if(!(typeof e!="number"||!Number.isFinite(e)))return Math.min(i,Math.max(_,Math.round(e)))}const p=[{label:"Medium",value:"medium"},{label:"Large",value:"large"}],c="medium",A={medium:{size:18,stroke:1.6},large:{size:20,stroke:1.4}},u=[{label:"Cart",value:"cart"},{label:"Bag",value:"bag"}],x="cart",v=e=>({cart:o(u,x,e.cartIcon),glyph:A[o(p,c,e.iconSize)]});export{u as HEADER_CART_ICONS,x as HEADER_CART_ICON_FALLBACK,p as HEADER_ICON_SIZES,c as HEADER_ICON_SIZE_FALLBACK,f as HEADER_LINK_OPACITY_ATTR,O as HEADER_LINK_OPACITY_DEFAULT,i as HEADER_LINK_OPACITY_MAX,_ as HEADER_LINK_OPACITY_MIN,g as HEADER_LINK_OPACITY_VAR,D as HEADER_MENU_ROWS,S as HEADER_MENU_ROW_FALLBACK,n as HEADER_NAV_TEXT_CASES,a as HEADER_NAV_TEXT_CASE_FALLBACK,E as HEADER_TOP_INK_CUSTOM,l as HEADER_UTIL_STYLES,s as HEADER_UTIL_STYLE_FALLBACK,L as UNDER_HEADER_SHEET_CLASS,I as headerSolidBackground,d as isProductPage,h as readHeaderLinkOpacity,N as readHeaderTopInk,T as resolveHeaderHeightPx,v as resolveHeaderToolLook,b as resolveMenuRow,C as resolveNavTextCase,m as resolveUtilStyle};
1
+ import{HEADER_CLEARANCE_CLASS as a,HEADER_HEIGHT_PX as r,TOP_SPACE_ATTR as n}from"efficient-web-builder/render/lib/document/header-clearance";import{parseOption as o}from"efficient-shell/format";function I(e){return typeof e=="number"&&Number.isInteger(e)&&e>=r.min&&e<=r.max?e:r.default}const d="fixed inset-x-0 bottom-0 top-[var(--sf-header-h,88px)]",m=e=>!!e&&e.startsWith("/wheels/")&&e!=="/wheels",l="data-site-main",E="shared";function D(e){if(!e)return!1;if(e.querySelector(`.${a}, [${n}="own"]`))return!0;const t=e.querySelector(`main[${l}]`);return t!=null&&t.querySelector(`[${n}="${E}"]`)==null}const N=(e,t)=>!e&&t?"var(--section-bg)":"var(--bg)",s=[{label:"Uppercase",value:"uppercase"},{label:"Capitalised",value:"capitalised"}],_="uppercase",O=e=>o(s,_,e),i=[{label:"Icon",value:"icon"},{label:"Text",value:"text"}],A="icon",b=e=>o(i,A,e),f=[{label:"Own row",value:"top"},{label:"Same row",value:"inline"}],P="top",g=e=>e==="inline"?"inline":e==="top"||e==="bottom"?"top":null,p="custom";function h(e,t){return e!==p||typeof t!="string"?null:t.trim()||null}const v=80,c=0,u=100,y="data-header-link-opacity",K="--sf-header-link-opacity";function M(e){if(!(typeof e!="number"||!Number.isFinite(e)))return Math.min(u,Math.max(c,Math.round(e)))}const x=[{label:"Medium",value:"medium"},{label:"Large",value:"large"}],T="medium",R={medium:{size:18,stroke:1.6},large:{size:20,stroke:1.4}},H=[{label:"Cart",value:"cart"},{label:"Bag",value:"bag"}],S="cart",U=e=>({cart:o(H,S,e.cartIcon),glyph:R[o(x,T,e.iconSize)]});export{H as HEADER_CART_ICONS,S as HEADER_CART_ICON_FALLBACK,x as HEADER_ICON_SIZES,T as HEADER_ICON_SIZE_FALLBACK,y as HEADER_LINK_OPACITY_ATTR,v as HEADER_LINK_OPACITY_DEFAULT,u as HEADER_LINK_OPACITY_MAX,c as HEADER_LINK_OPACITY_MIN,K as HEADER_LINK_OPACITY_VAR,f as HEADER_MENU_ROWS,P as HEADER_MENU_ROW_FALLBACK,s as HEADER_NAV_TEXT_CASES,_ as HEADER_NAV_TEXT_CASE_FALLBACK,p as HEADER_TOP_INK_CUSTOM,i as HEADER_UTIL_STYLES,A as HEADER_UTIL_STYLE_FALLBACK,l as SITE_MAIN_ATTR,E as TOP_SPACE_SHARED,d as UNDER_HEADER_SHEET_CLASS,N as headerSolidBackground,m as isProductPage,D as pageOwnsTop,M as readHeaderLinkOpacity,h as readHeaderTopInk,I as resolveHeaderHeightPx,U as resolveHeaderToolLook,g as resolveMenuRow,O as resolveNavTextCase,b as resolveUtilStyle};