efficient-storefront-blocks 0.118.5 → 0.119.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/chunks/{EditorPreviewCheckout-573RVCXC.js → EditorPreviewCheckout-GPCQCIKD.js} +1 -1
- package/dist/chunks/{SiteEditorProvider-IUUOJHN2.js → SiteEditorProvider-IA4YGOTE.js} +1 -1
- package/dist/chunks/{chunk-YGMNMVG2.js → chunk-DJBGDTYI.js} +1 -1
- package/dist/chunks/chunk-FVRV62ZM.js +1 -0
- package/dist/chunks/chunk-XZO5FGQV.js +1 -0
- package/dist/chunks/{fitment-data-HYODY7DX.js → fitment-data-TYSWQS7W.js} +1 -1
- package/dist/index.js +29 -29
- package/dist/render/components/GalleryItem.js +1 -1
- package/dist/render/components/HeaderTools.js +1 -1
- package/dist/render/components/ProductGridSection.js +1 -1
- package/dist/render/components/SignUpFind.d.ts +3 -1
- package/dist/render/components/SignUpFind.js +1 -1
- package/dist/render/components/catalog/FilterPill.js +1 -1
- package/dist/render/components/catalog/ShopperScope.d.ts +1 -2
- package/dist/render/components/catalog/ShopperScope.js +2 -2
- package/dist/render/lib/api/index.js +1 -1
- package/dist/render/lib/sections/sign-up.d.ts +3 -0
- package/dist/render/lib/sections/sign-up.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/chunk-CJ7IEW3F.js +0 -1
- package/dist/chunks/chunk-V7O6FKCB.js +0 -1
- /package/dist/chunks/{chunk-YGMNMVG2.js.LEGAL.txt → chunk-DJBGDTYI.js.LEGAL.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as r,jsxs as n,Fragment as f}from"react/jsx-runtime";import{createContext as Y,useCallback as Q,useContext as D,useEffect as ee,useRef as te,useState as _}from"react";import C from"next/link";import{slugify as re}from"efficient-shell/format";import{CardTemplateRows as oe}from"efficient-web-builder/render/components/CardRowContext";import{BOX_HOLDS_NO_GUTTER_CLASS as ne}from"efficient-web-builder/format/lib/content/page-width";import le,{galleryTileNumber as ae}from"./GalleryCard.js";import se,{LightboxClose as ie,LIGHTBOX_CLOSE_TINT as ce}from"./Lightbox.js";import{useSiteSells as de}from"./SiteRecordContext.js";import{renderGold as p,renderHeadline as W}from"efficient-web-builder/render/components/goldPhrases";import{sizedImage as pe}from"efficient-web-builder/format/lib/sized-image";import{
|
|
1
|
+
"use client";import{jsx as r,jsxs as n,Fragment as f}from"react/jsx-runtime";import{createContext as Y,useCallback as Q,useContext as D,useEffect as ee,useRef as te,useState as _}from"react";import C from"next/link";import{slugify as re}from"efficient-shell/format";import{CardTemplateRows as oe}from"efficient-web-builder/render/components/CardRowContext";import{BOX_HOLDS_NO_GUTTER_CLASS as ne}from"efficient-web-builder/format/lib/content/page-width";import le,{galleryTileNumber as ae}from"./GalleryCard.js";import se,{LightboxClose as ie,LIGHTBOX_CLOSE_TINT as ce}from"./Lightbox.js";import{useSiteSells as de}from"./SiteRecordContext.js";import{renderGold as p,renderHeadline as W}from"efficient-web-builder/render/components/goldPhrases";import{sizedImage as pe}from"efficient-web-builder/format/lib/sized-image";import{useBrowserLayoutEffect as me}from"efficient-shell/hooks";import{HideTaker as F}from"efficient-web-builder/render/components/ViewHideRoot";const fe="(max-width: 1100px) 100vw, min(59vw, 1050px)",he=Y({}),Re=[{id:"tag",label:"Tag"},{id:"eyebrow",label:"Eyebrow"},{id:"title",label:"Title"},{id:"meta",label:"Meta"},{id:"number",label:"Card number"}],xe=Y(null),ue="data-gallery-grid",O="data-gallery-tile";function ge(t,o){const[a,i]=_(null);return ee(()=>{const c=t.current,s=c?.closest(`[${ue}]`);if(!c||!s)return;const v=()=>{const y=Array.from(s.querySelectorAll(`[${O}]`)),N=y.indexOf(c),h=N>=0?{index:N+1,total:y.length}:null;i(x=>x?.index===h?.index&&x?.total===h?.total?x:h)};if(v(),!o)return;const w=new MutationObserver(v);return w.observe(s,{childList:!0,subtree:!0}),()=>w.disconnect()},[t,o]),a}const Ae={process:"Category",eyebrow:"Subtitle",name:"Item name",meta:"Detail"},be=()=>({image:"",href:"#",process:"",eyebrow:"",name:"",meta:""}),$e=Array.from({length:6},be);function ve(t){const o=(t.photos??[]).map(s=>s?.src).filter(s=>!!s),a=t.image||o[0]||"",i=[a,...o].filter(s=>!!s),c=re(t.name)||"gallery-item";return{car:t.eyebrow??"",wheel:t.name??"",process:t.process??"",finish:t.meta??"",imageLabel:`${c}.jpg`,detailLabel:`${c}-detail.jpg`,imageSrc:a||void 0,detailSrc:o[0]||a||void 0,photos:i,href:t.href}}function we({editing:t=!1,previewHover:o,ratio:a,captionPlace:i,tile:c,...s}){const{galleryHref:v="/gallery",submitHref:w="/contact",previewHover:y,display:N,displayPhone:h,styleOwner:x,photosOnly:X=!1,wordsAtRest:q=!1,Template:E,ownerId:Z}=D(he),e=ve(s),u=de()&&!X,P=!u&&!ye(e),d=e.photos??(e.imageSrc?[e.imageSrc]:[]),z=te(null),I=Q(l=>{z.current=l},[]),J=ge(z,t),j=D(xe),k=j?.report,m=c?.id,G=c?.tag??"",H=c?.name??"";me(()=>{if(!k||!m)return;const l={id:m,tag:G,name:H};return k(l),()=>k(l,!0)},[k,m,G,H]);const g=(m?j?.positionOf(m):null)??J,R=t&&(!!o||!!y),[K,b]=_(!1),[S,L]=_(0),A=()=>L(l=>(l-1+d.length)%d.length),$=()=>L(l=>(l+1)%d.length),T=d[S]??e.imageSrc??"",B=d.slice(1),M=E?r("div",{className:`block w-full min-w-0 ${ne}`,children:r(oe,{ownerId:Z??"GalleryB",ownerType:"GalleryB",Template:E,rows:[{key:m??e.imageSrc??"tile",image:e.imageSrc??"",tag:e.process,number:g?ae(g.index,g.total):"",eyebrow:e.car,name:e.wheel,meta:e.finish,href:e.href??""}],items:[{hoverMedia:B.length?{photos:[{finish:"",items:B.map(l=>({url:l,kind:"image"}))}]}:null}],previewHover:R,fallback:null,children:l=>l})}):r(le,{build:e,forceHover:R,alwaysShowOverlay:q,index:g?.index,total:g?.total,ratio:a,captionPlace:i,display:N,displayPhone:h,styleOwner:x,editing:t});return n(f,{children:[t?r(F,{as:"div",ref:I,[O]:"",className:"block w-full text-left",children:M}):r(F,{as:"button",ref:I,[O]:"",type:"button","aria-label":u?`Open ${e.car||"build"} on ${e.wheel||"wheel"}`:V(e),onClick:()=>{L(0),b(!0)},className:"block w-full cursor-pointer text-left focus:outline-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",children:M}),r(se,{open:K,onClose:()=>b(!1),label:u?`${e.car} on ${e.wheel}`:V(e),onPrev:d.length>1?A:void 0,onNext:d.length>1?$:void 0,className:"flex items-center justify-center p-6 max-[700px]:p-3",children:n("div",{onClick:l=>l.stopPropagation(),className:`relative grid w-[min(1800px,100%)] max-h-[calc(100vh-48px)] ${P?"grid-cols-1":"grid-cols-[1.4fr_1fr]"} overflow-hidden border border-line bg-bg max-view-desktop:grid-cols-1 max-view-desktop:overflow-auto`,style:{boxShadow:"0 60px 120px -20px color-mix(in srgb, var(--sf-shadow-color, #141416) 70%, transparent)"},children:[r(ie,{label:"Close popup",className:"absolute right-[24px] top-[24px] z-[5] flex h-[56px] w-[56px] items-center justify-center border border-line font-mono text-[length:var(--size-label,21px)] text-fg-dim transition-colors hover:border-accent hover:text-fg",style:{background:ce},children:"✕"}),n("div",{className:"relative flex min-h-[690px] items-center justify-center overflow-hidden bg-surface-2 max-view-desktop:min-h-[450px]",children:[T&&r("img",{...pe(T,{fallbackWidth:1280}),sizes:fe,alt:`${(u?e.car:e.wheel||e.car)||"Photo"} — ${S+1} of ${d.length}`,className:"block h-full max-h-[88vh] w-full object-cover"},T),d.length>1&&n(f,{children:[r("button",{type:"button","aria-label":"Previous photo",onClick:A,className:"absolute left-4 top-1/2 flex h-16 w-16 -translate-y-1/2 cursor-pointer items-center justify-center border border-fg-dim/40 bg-overlay-scrim/40 font-mono text-[length:var(--size-label,24px)] text-fg-dim transition-colors hover:border-accent hover:text-accent",children:"◁"}),r("button",{type:"button","aria-label":"Next photo",onClick:$,className:"absolute right-4 top-1/2 flex h-16 w-16 -translate-y-1/2 cursor-pointer items-center justify-center border border-fg-dim/40 bg-overlay-scrim/40 font-mono text-[length:var(--size-label,24px)] text-fg-dim transition-colors hover:border-accent hover:text-accent",children:"▷"}),n("span",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 border border-fg-dim/30 bg-overlay-scrim/50 px-4 py-1.5 font-mono text-[length:var(--size-label,15px)] uppercase tracking-[0.22em] text-fg-dim backdrop-blur-[4px]",children:[S+1," / ",d.length]})]})]}),u?n("div",{className:"flex flex-col gap-[30px] px-[60px] py-[72px] max-view-desktop:px-9 max-view-desktop:py-[54px]",children:[e.process&&r("span",{className:"font-mono text-[length:var(--size-label,15px)] uppercase tracking-[0.3em] text-accent",children:p(e.process)}),e.wheel&&r("h2",{className:"font-heading2 text-[length:min(var(--size-headingMedium,clamp(42px,4.5vw,60px)),var(--sf-heading-max,9999px))] font-medium uppercase leading-[0.95] tracking-[-0.025em]",children:W(e.wheel,!1)}),e.car&&n("div",{className:"font-heading3 text-[length:var(--size-headingSmall,27px)] leading-[1.4] text-fg",children:["on ",r("em",{className:"font-serif font-normal italic text-accent tracking-[-0.01em]",children:p(e.car,!0)})]}),n("dl",{className:"mt-3 grid grid-cols-[auto_1fr] gap-x-7 gap-y-[18px] border-y border-line py-[30px] font-mono text-[length:var(--size-label,15px)] uppercase tracking-[0.22em]",children:[e.wheel&&n(f,{children:[r("dt",{className:"text-fg-dim",children:"Wheel"}),r("dd",{className:"text-fg",children:p(e.wheel)})]}),e.process&&n(f,{children:[r("dt",{className:"text-fg-dim",children:"Process"}),r("dd",{className:"text-fg",children:p(e.process)})]}),e.finish&&n(f,{children:[r("dt",{className:"text-fg-dim",children:"Finish"}),r("dd",{className:"text-fg",children:p(e.finish)})]}),e.car&&n(f,{children:[r("dt",{className:"text-fg-dim",children:"Vehicle"}),r("dd",{className:"text-fg",children:p(e.car)})]})]}),n("div",{className:"mt-auto flex flex-col gap-3.5 pt-6",children:[n(C,{href:e.href||"/wheels",onClick:()=>b(!1),className:"group flex items-center justify-between gap-6 border border-btn bg-btn px-9 py-6 font-mono text-[length:var(--size-label,16px)] uppercase tracking-[0.3em] text-btn-ink transition-colors hover:border-fg hover:bg-fg",children:[r("span",{children:"View product"}),r("span",{className:"transition-transform group-hover:translate-x-[6px]",children:"→"})]}),n(C,{href:v,onClick:()=>b(!1),className:"flex items-center justify-between gap-6 border border-line px-9 py-6 font-mono text-[length:var(--size-label,16px)] uppercase tracking-[0.3em] text-fg transition-colors hover:border-accent hover:text-accent",children:[r("span",{children:"See more builds"}),r("span",{children:"→"})]}),n(C,{href:w,onClick:()=>b(!1),className:"flex items-center justify-between gap-6 border border-line px-9 py-6 font-mono text-[length:var(--size-label,16px)] uppercase tracking-[0.3em] text-fg transition-colors hover:border-accent hover:text-accent",children:[r("span",{children:"Submit your build"}),r("span",{children:"→"})]})]})]}):!P&&r(Ne,{build:e})]})})]})}function U(t){return[t.process,t.car,t.finish].filter((o,a,i)=>!!o&&o!==t.wheel&&i.indexOf(o)===a)}function ye(t){return!!t.wheel||U(t).length>0}function V(t){const o=t.wheel||t.car;return o?`Open photo of ${o}`:"Open photo"}function Ne({build:t}){const o=t.wheel,a=U(t);return n("div",{className:"flex flex-col gap-[24px] px-[60px] py-[72px] max-view-desktop:px-9 max-view-desktop:py-[54px]",children:[o&&r("h2",{className:"font-heading2 text-[length:min(var(--size-headingMedium,clamp(42px,4.5vw,60px)),var(--sf-heading-max,9999px))] font-medium uppercase leading-[0.95] tracking-[-0.025em]",children:W(o,!1)}),a.map(i=>r("p",{className:"text-[length:var(--size-body,18px)] leading-[1.5] text-fg",children:p(i)},i))]})}export{ue as GALLERY_GRID_ATTR,Ae as GALLERY_ITEM_HINTS,$e as GALLERY_ITEM_SEEDS,O as GALLERY_TILE_ATTR,Re as GALLERY_TILE_PARTS,he as GalleryLinksContext,xe as GalleryTilesContext,we as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as
|
|
1
|
+
"use client";import{jsx as t,jsxs as o,Fragment as y}from"react/jsx-runtime";import N from"next/link";import{useEffect as k,useRef as w}from"react";import{CartAltIcon as v}from"efficient-shell/icons/efficient-looks";import h from"efficient-easel/screen/components/UiIcon";import{prefersReducedMotion as $}from"efficient-web-builder/render/components/useReducedMotion";import{HideTaker as _,NO_HIDE as S,useTakeViewHide as C,withViewHide as j}from"efficient-web-builder/render/components/ViewHideRoot";const l={search:"Search",account:"Account",cart:"Bag",menu:"Menu",close:"Close"},d="whitespace-nowrap";function B(n){return n>99?"99+":String(n)}function W({count:n,ref:e}){return t("span",{ref:e,"data-cart-badge":"","aria-hidden":"true",className:"pointer-events-none absolute -top-[7px] -right-[9px] inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-current px-1 text-[10px] leading-none font-semibold tabular-nums",style:{letterSpacing:0},children:t("span",{style:{color:"var(--sf-header-ground, var(--bg))"},children:B(n)})})}function M({onClick:n,count:e,asText:s,className:r,takesViewHide:a=!1}){const c=w(null),i=w(e);return k(()=>{i.current!==e&&(i.current=e,!$()&&c.current?.animate([{transform:"scale(0.6)"},{transform:"scale(1)"}],{duration:180,easing:"ease-out"}))},[e]),t(_,{as:"button",takes:a,type:"button",onClick:n,"aria-label":`Open cart, ${e} item${e===1?"":"s"}`,className:`mono-eyebrow-ctl inline-flex items-center gap-2 opacity-80 transition-opacity hover:opacity-100 ${r??""}`,children:s?o("span",{className:d,children:[l.cart,e>0?` ${e}`:""]}):o("span",{className:"relative inline-flex",children:[t(v,{size:18,strokeWidth:"1.6","aria-hidden":"true"}),e>0?t(W,{count:e,ref:c}):null]})})}function T({asText:n,className:e,takesViewHide:s=!1}){const r=C(),a=s?r:S;return a.scope(t(N,{href:"/account","aria-label":"Account",className:j(`mono-eyebrow-ctl inline-flex items-center opacity-80 transition-opacity hover:opacity-100 ${e??""}`,a.className),...a.attrs,children:n?t("span",{className:d,children:l.account}):o("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t("circle",{cx:"12",cy:"8",r:"3.4"}),t("path",{d:"M5 20a7 7 0 0 1 14 0"})]})}))}function U({onClick:n,asText:e,withWord:s,phoneLook:r,className:a}){let c=!1,i;if(r){const u=e?"text":s?"icon_text":"icon",m=(b,g)=>b&&g?"":b?"max-view-tablet:hidden":g?"view-tablet:hidden":null,p=m(u!=="text",r!=="text"),f=m(u!=="icon",r!=="icon"),x=u==="icon_text"||r==="icon_text";c=!0,i=o(y,{children:[p===null?null:t("span",{className:`inline-flex ${p}`,children:t(h,{name:"search",size:x?20:18,strokeWidth:x?1.5:1.6,rounded:!0})}),f===null?null:t("span",{className:`${d} ${f}`,children:l.search})]})}else s?(c=!0,i=o(y,{children:[t(h,{name:"search",size:20,strokeWidth:1.5,rounded:!0}),t("span",{className:`${d} max-view-tablet:hidden`,children:l.search})]})):i=e?t("span",{className:d,children:l.search}):t(h,{name:"search",size:18,strokeWidth:1.6,rounded:!0});return t("button",{type:"button",onClick:n,"aria-label":"Search",title:"Search (⌘K)",className:`mono-eyebrow-ctl inline-flex items-center ${c?"gap-2 ":""}opacity-80 transition-opacity hover:opacity-100 ${a??""}`,children:i})}export{T as AccountButton,M as CartButton,U as SearchButton,l as UTIL_WORDS,d as UTIL_WORD_CLASS};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as x,Fragment as mt}from"react/jsx-runtime";import{useScopeClass as dt}from"../lib/use-scope-class.js";import{useEffect as A,useMemo as p,useState as pe}from"react";import{cardHoverOf as ct}from"efficient-web-builder/format/lib/animation/hover";import{containerGapProps as pt}from"efficient-web-builder/format/lib/content/container-gap";import ut from"next/link";import{cardRowsGrid as gt,GridCardProvider as ft,GridMixedCards as ht,gridIndexCss as xt}from"./GridCardTemplate.js";import{gridClassImageSizes as wt}from"../lib/sections/card-image-sizes.js";import{fillRowCss as ue}from"../lib/sections/fill-row.js";import{hiddenCardsRule as ge,noHoleBands as fe,noHoleCss as he,ONE_WHEEL_MARK as vt,oneWheelScope as xe,pairScope as yt,showsASetCard as we}from"../lib/sections/grid-no-hole.js";import{setIsWide as bt,summarySetBuild as Ct}from"../lib/wheels/set-mode.js";import{answersForKind as ve,NO_FIELD_ANSWERS as ye}from"../lib/content/field-usage.js";import{wheelCardEyebrowShows as St}from"./ProductCardEyebrow.js";import Mt from"./NoCurrencyNote.js";import{SITE_WIDTH_CAP as Pt,centredCap as Et}from"efficient-web-builder/format/lib/content/page-width";import{ProductCatalogProvider as Nt,SectionWheelsProvider as Tt}from"./ProductRef.js";import{useCurrency as _t}from"./CurrencyContext.js";import{FRAME_ROOM_PRODUCT_GRID as Ot,FRAME_ROOM_PRODUCT_GRID_PHONE as $t,framedBandPad as Rt,PRODUCT_GRID_ROOM as It,withBandClasses as zt}from"../lib/sections/band-padding.js";import{COLLECTION_ATTR as Lt,useCatalogFilter as At}from"./catalog/CatalogFilterContext.js";import{useIsoLayoutEffect as Bt,useShopperMember as Gt}from"./catalog/ShopperScope.js";import Ht from"./wheels-plp/PlpPagination.js";import{CATALOG_TEXT_SIZE as Ft}from"../lib/sections/catalog-text-size.js";import{applyShopperFilters as Dt,hasActivePlpFilters as Ut,plpPricedAmounts as kt}from"../lib/wheels/plp-filters.js";import Wt from"./catalog/ClearAllButton.js";import{GRID_TOP_UP_SPARE as jt,gridPagingOf as Kt,gridShownOf as Xt}from"../lib/sections/product-grid-pages.js";import Zt from"./SectionBand.js";import{useInsideBox as qt,useInsideSiteGutter as Vt}from"efficient-web-builder/render/components/SiteGutterFrame";import{productGridColumnsClass as Yt}from"../lib/sections/product-grid-columns.js";import{renderGold as te,renderHeadline as Jt}from"efficient-web-builder/render/components/goldPhrases";import{applyCatalogFilters as Qt}from"../lib/wheels/catalog-filters.js";import{normalizeCatalogRows as er}from"../lib/wheels/wheel-summary-casing.js";import{itemKind as B,plpKindNoun as be}from"../lib/catalog/plp-item.js";import{filterBarCategoryOf as tr,gridKindsOf as Ce,gridRowsOf as rr}from"../lib/wheels/grid-source.js";import{useUnifiedProductCatalog as nr}from"./useProductCatalog.js";import{STICKY_UNDERHEADER_CLASS as ir}from"efficient-web-builder/render/lib/document/header-clearance";import{finishFamiliesOf as sr}from"../lib/wheels/finish-defaults.js";import{lugCountsOf as ar}from"../lib/wheels/lug-count.js";import{diametersOf as or}from"../lib/wheels/size-range.js";import{say as lr}from"efficient-web-builder/format/lib/editor-words";import{DEFAULT_TITLE_SIZE as mr}from"../lib/sections/product-grid-title.js";const dr=ct({},"ProductGrid"),i={headingMediumUpTo800Xs:"max-view-wide:text-[length:var(--size-headingMedium,28px)]",headingMediumUpTo800Small:"max-view-wide:text-[length:var(--size-headingMedium,32px)]",headingMediumUpTo800Large:"max-view-wide:text-[length:var(--size-headingMedium,36px)]",headingMediumUpTo800Xl:"max-view-wide:text-[length:var(--size-headingMedium,40px)]",body:"text-[length:var(--size-body,13px)]",headingMedium1:"text-[length:var(--size-headingMedium,40px)]",headingMedium2:"text-[length:var(--size-headingMedium,48px)]",headingMedium3:"text-[length:var(--size-headingMedium,56px)]",headingMedium4:"text-[length:var(--size-headingMedium,64px)]",labelSmall:"text-[length:var(--size-label,12px)]",labelLarge:"text-[length:var(--size-label,13px)]"},Se=[{value:"para",label:"Paragraph size — 13px",cls:`font-mono font-normal uppercase tracking-[0.22em] ${i.labelLarge}`},{value:"sm",label:"Small — 40px",cls:`font-heading2 font-medium tracking-[-0.03em] ${i.headingMedium1} ${i.headingMediumUpTo800Xs}`},{value:"md",label:"Medium — 48px",cls:`font-heading2 font-medium tracking-[-0.03em] ${i.headingMedium2} ${i.headingMediumUpTo800Small}`},{value:"lg",label:"Large — 56px",cls:`font-heading2 font-medium tracking-[-0.03em] ${i.headingMedium3} ${i.headingMediumUpTo800Large}`},{value:"xl",label:"Extra large — 64px",cls:`font-heading2 font-medium tracking-[-0.03em] ${i.headingMedium4} ${i.headingMediumUpTo800Xl}`}];function cr(M){return(Se.find(w=>w.value===M)??Se.find(w=>w.value===mr)).cls}function pr({num:M,catalog:w,catalogTotal:Me,firstCountInChips:Pe=!1,kinds:T,title:G,titleSize:Ee,pads:Ne,noTop:re=!1,description:_,link:P,products:Te,wheels:_e,source:c,columns:Oe,columnsPhone:$e,columnsTablet:Re,limit:Ie,moreProducts:ze,perPage:Le,editing:E,contentCapped:Ae=!1,hover:Be,fieldUsage:v,ownerId:Ge="",template:He,gap:Fe,gapPhone:De}){const H=p(()=>v?ve(v,"alloy-wheel"):void 0,[v]),Ue=p(()=>v?ve(v,"tyre"):void 0,[v]),e=dt("pg"),{paged:y,per:b,limit:o,cap:u}=Kt({moreProducts:ze,perPage:Le,limit:Ie}),m=Yt(Oe,$e,Re),ne=Ae,ke=Vt(),We=qt(),je=ke||We,F=nr(E===!0&&!!c),s=p(()=>c?er(rr(c,T,F??w??[])):null,[w,F,c,T]),D=Gt("grid",s),l=s?D.scope:null,g=tr(c),C=g!==null&&!l,{filters:O,reportCount:U,reportLugs:k,reportSizes:W,reportFinishes:j,reportCategories:K,reportPrices:X,vehicle:ie}=At(),{currency:f}=_t(),Z=C&&!!O.process&&O.process!==g,q=l?.state,r=p(()=>s?q?Dt(s,q,f):C?Qt(s,O,f,ie.fit):s:null,[s,q,C,O,f,ie.fit]),[Ke,Xe]=pe(1),V=y&&r?Math.max(1,Math.ceil(r.length/b)):1,S=Math.min(V,Math.max(1,l?l.state.page:Ke)),{reportShown:Y}=D,se=l!==null;Bt(()=>{if(!se||!r)return Y(null);Y(Xt(r.length,{paged:y,per:b,cap:u},S))},[se,r,Y,y,S,b,u]);const Ze=n=>l?l.update({page:n}):Xe(n),a=p(()=>r&&(y?r.slice((S-1)*b,S*b):u?r.slice(0,Math.ceil(o)+jt):r),[y,u,o,r,S,b]);A(()=>(K(e,g===null?[]:[g]),()=>K(e,[])),[g,K,e]),A(()=>{if(C)return U(e,Z?0:r?.length??0),()=>U(e,0)},[C,Z,r,U,e]);const N=p(()=>({lugs:ar(s??[]),sizes:or(s??[]),finishes:sr(s??[]),prices:kt((s??[]).filter(n=>B(n)!=="tyre"),f)}),[s,f]);A(()=>(k(e,N.lugs),W(e,N.sizes),j(e,N.finishes),X(e,N.prices),()=>{k(e,[]),W(e,[]),j(e,[]),X(e,[])}),[N,k,W,j,X,e]);const J=pt("ProductGrid",Fe,"both",De),qe=`${e} grid${J.className} bg-[var(--catalog-grid-bg)] ${m}`,ae=gt(J),Ve=`${e} grid${ae.className} bg-[var(--catalog-grid-bg)] ${m}`,Ye=ae.style,Je=p(()=>{const n=(r??[]).filter(d=>B(d)!=="tyre");if(n.length===0)return!1;const h=n.some(d=>!!d.process);return n.some(d=>!!d.setWords)||St({kind:!1,brand:!1,process:h},H??[])},[r,H]),Qe=a?a.length>0?t("div",{className:Ve,style:Ye,children:t(ht,{items:a,tyreOf:n=>B(n)==="tyre"?n:null})}):l&&Ut(l.state)?x("div",{className:"flex min-h-[320px] flex-col items-center justify-center gap-4 bg-surface-2 p-4 text-center",children:[t("span",{className:`font-mono ${i.labelSmall} uppercase tracking-[0.2em] text-fg-dim`,children:`No ${be(Ce(c,T)).many} match those filters`}),t(Wt,{onClick:l.clear})]}):E?t("div",{className:"flex min-h-[320px] items-center justify-center rounded bg-surface-2 p-4 text-center",children:t("span",{className:`font-mono ${i.labelSmall} uppercase tracking-[0.2em] text-fg-dim`,children:lr("No products in “{name}” yet",{name:c?.name??""})})}):null:t(Te,{className:qe,style:J.style,minEmptyHeight:320}),et=l?l.countInChips:Pe,$=r&&!et?r===s&&!F?Me??r.length:r.length:null,oe=be(Ce(c,T)),tt=M||G||_||P?x("div",{className:`${ir} sticky top-[var(--sf-header-h,88px)] z-30 mb-5 flex items-center justify-between gap-4 max-view-wide:flex-wrap max-view-wide:gap-y-2 border-b border-line bg-bg/95 py-3 backdrop-blur-md ${ne||je?"":"-mx-[var(--sf-site-gutter,40px)] px-[var(--sf-site-gutter,40px)] max-view-wide:-mx-[min(20px,var(--sf-site-gutter,40px))] max-view-wide:px-[min(20px,var(--sf-site-gutter,40px))]"}`,children:[x("div",{className:"flex min-w-0 items-end gap-6 max-view-wide:flex-col max-view-wide:items-stretch max-view-wide:gap-3",children:[M&&t("span",{className:`font-mono ${i.labelLarge} leading-none uppercase tracking-[0.22em] text-fg-dim`,children:te(M)}),G&&t("h2",{className:`${cr(Ee)} leading-none text-fg max-view-wide:leading-[1] [&>span]:block`,children:Jt(G,!1)})]}),(_||P||$!==null)&&x("div",{className:"flex items-center gap-5 max-view-wide:gap-3 view-wide:grow view-wide:justify-end",children:[_&&t("span",{className:`max-w-[340px] truncate font-display ${i.body} leading-[1.4] text-fg-dim max-view-wide:hidden view-wide:w-0 view-wide:grow view-wide:text-right`,children:te(_)}),P&&x(ut,{href:P.href,className:`inline-flex items-center gap-2 whitespace-nowrap font-mono ${i.labelLarge} uppercase tracking-[0.2em] text-fg-dim transition-colors hover:text-fg`,children:[te(P.text),t("span",{"aria-hidden":!0,children:"→"})]}),$!==null&&x("span",{className:`whitespace-nowrap font-mono ${i.labelSmall} uppercase tracking-[0.2em] text-fg-dim`,children:[$," ",$===1?oe.one:oe.many]})]})]}):null,R=Rt(Ne,It,{noTop:re}),{paddingTop:rt,...nt}=R.style,I=re?0:rt,it={...I===void 0?{}:{"--pg-pt":typeof I=="number"?`${I}px`:I},...nt},z=p(()=>{if(!a)return null;const n=a.map(h=>B(h)!=="tyre"&&bt(Ct(h))?2:1);return we(n,o)?fe(m,n,o):null},[a,m,o]),[st,at]=pe("");A(()=>{if(a)return;const n=document.querySelector(`.${e}`);if(!n)return;const h=()=>{const d=[...n.children].map(ce=>ce.classList.contains("col-span-2")&&!ce.querySelector(vt)?2:1);at(we(d,o)?he(e,fe(m,d,o,!1),d.length):"")};h();const ee=new MutationObserver(h);return ee.observe(n,{childList:!0}),()=>ee.disconnect()},[a,e,m,o]);const ot=z?z[0].tracks:a?u?Math.min(a.length,o):a.length:void 0,L=z?he(yt(e),z,a.length)+(u?ge(xe(e),o+1):"")+ue(xe(e),m,{limit:o,cards:a.length}):st,le=L?"":ue(e,m,{limit:o,cards:a?.length}),me=xt(e),de=x(mt,{children:[u&&!L&&t("style",{children:ge(e,o+1)}),L&&t("style",{children:L}),le&&t("style",{children:le}),me&&t("style",{children:me}),tt,Qe,y&&V>1&&t(Ht,{textSize:Ft.labelSmall,page:S,pageCount:V,onPage:Ze}),t(Mt,{editing:E})]});if(Z)return null;const Q=t(Zt,{rootRef:D.ref,attrs:C&&g!==null?{...R.attrs,[Lt]:g}:R.attrs,className:zt(`relative z-[2] bg-bg px-[var(--sf-site-gutter,40px)] ${Ot} max-view-wide:px-[min(20px,var(--sf-site-gutter,40px))] ${$t}`,R),column:null,inAnyBox:!0,style:it,defaults:{"--pg-pt":"120px"},children:ne?t("div",{style:Et(Pt),children:de}):de}),lt=s?Q:E?t(Nt,{currency:f,children:Q}):t(Tt,{wheels:_e,currency:f,children:Q});return t(ft,{value:{ownerId:Ge,Template:He,hover:Be??dr,imageSizes:wt(m,ot),fieldUsage:H??ye,tyreFieldUsage:Ue??ye,reserveEyebrow:Je,editing:E===!0},children:lt})}export{Se as TITLE_SIZES,pr as default};
|
|
1
|
+
"use client";import{jsx as t,jsxs as x,Fragment as mt}from"react/jsx-runtime";import{useScopeClass as dt}from"../lib/use-scope-class.js";import{useEffect as A,useMemo as p,useState as pe}from"react";import{cardHoverOf as ct}from"efficient-web-builder/format/lib/animation/hover";import{containerGapProps as pt}from"efficient-web-builder/format/lib/content/container-gap";import ut from"next/link";import{cardRowsGrid as gt,GridCardProvider as ft,GridMixedCards as ht,gridIndexCss as xt}from"./GridCardTemplate.js";import{gridClassImageSizes as wt}from"../lib/sections/card-image-sizes.js";import{fillRowCss as ue}from"../lib/sections/fill-row.js";import{hiddenCardsRule as ge,noHoleBands as fe,noHoleCss as he,ONE_WHEEL_MARK as vt,oneWheelScope as xe,pairScope as yt,showsASetCard as we}from"../lib/sections/grid-no-hole.js";import{setIsWide as bt,summarySetBuild as Ct}from"../lib/wheels/set-mode.js";import{answersForKind as ve,NO_FIELD_ANSWERS as ye}from"../lib/content/field-usage.js";import{wheelCardEyebrowShows as St}from"./ProductCardEyebrow.js";import Mt from"./NoCurrencyNote.js";import{SITE_WIDTH_CAP as Pt,centredCap as Et}from"efficient-web-builder/format/lib/content/page-width";import{ProductCatalogProvider as Nt,SectionWheelsProvider as Tt}from"./ProductRef.js";import{useCurrency as _t}from"./CurrencyContext.js";import{FRAME_ROOM_PRODUCT_GRID as Ot,FRAME_ROOM_PRODUCT_GRID_PHONE as $t,framedBandPad as Rt,PRODUCT_GRID_ROOM as zt,withBandClasses as It}from"../lib/sections/band-padding.js";import{COLLECTION_ATTR as Lt,useCatalogFilter as At}from"./catalog/CatalogFilterContext.js";import{useShopperMember as Bt}from"./catalog/ShopperScope.js";import{useBrowserLayoutEffect as Gt}from"efficient-shell/hooks";import Ht from"./wheels-plp/PlpPagination.js";import{CATALOG_TEXT_SIZE as Ft}from"../lib/sections/catalog-text-size.js";import{applyShopperFilters as Dt,hasActivePlpFilters as Ut,plpPricedAmounts as kt}from"../lib/wheels/plp-filters.js";import Wt from"./catalog/ClearAllButton.js";import{GRID_TOP_UP_SPARE as jt,gridPagingOf as Kt,gridShownOf as Xt}from"../lib/sections/product-grid-pages.js";import Zt from"./SectionBand.js";import{useInsideBox as qt,useInsideSiteGutter as Vt}from"efficient-web-builder/render/components/SiteGutterFrame";import{productGridColumnsClass as Yt}from"../lib/sections/product-grid-columns.js";import{renderGold as te,renderHeadline as Jt}from"efficient-web-builder/render/components/goldPhrases";import{applyCatalogFilters as Qt}from"../lib/wheels/catalog-filters.js";import{normalizeCatalogRows as er}from"../lib/wheels/wheel-summary-casing.js";import{itemKind as B,plpKindNoun as be}from"../lib/catalog/plp-item.js";import{filterBarCategoryOf as tr,gridKindsOf as Ce,gridRowsOf as rr}from"../lib/wheels/grid-source.js";import{useUnifiedProductCatalog as nr}from"./useProductCatalog.js";import{STICKY_UNDERHEADER_CLASS as ir}from"efficient-web-builder/render/lib/document/header-clearance";import{finishFamiliesOf as sr}from"../lib/wheels/finish-defaults.js";import{lugCountsOf as or}from"../lib/wheels/lug-count.js";import{diametersOf as ar}from"../lib/wheels/size-range.js";import{say as lr}from"efficient-web-builder/format/lib/editor-words";import{DEFAULT_TITLE_SIZE as mr}from"../lib/sections/product-grid-title.js";const dr=ct({},"ProductGrid"),i={headingMediumUpTo800Xs:"max-view-wide:text-[length:var(--size-headingMedium,28px)]",headingMediumUpTo800Small:"max-view-wide:text-[length:var(--size-headingMedium,32px)]",headingMediumUpTo800Large:"max-view-wide:text-[length:var(--size-headingMedium,36px)]",headingMediumUpTo800Xl:"max-view-wide:text-[length:var(--size-headingMedium,40px)]",body:"text-[length:var(--size-body,13px)]",headingMedium1:"text-[length:var(--size-headingMedium,40px)]",headingMedium2:"text-[length:var(--size-headingMedium,48px)]",headingMedium3:"text-[length:var(--size-headingMedium,56px)]",headingMedium4:"text-[length:var(--size-headingMedium,64px)]",labelSmall:"text-[length:var(--size-label,12px)]",labelLarge:"text-[length:var(--size-label,13px)]"},Se=[{value:"para",label:"Paragraph size — 13px",cls:`font-mono font-normal uppercase tracking-[0.22em] ${i.labelLarge}`},{value:"sm",label:"Small — 40px",cls:`font-heading2 font-medium tracking-[-0.03em] ${i.headingMedium1} ${i.headingMediumUpTo800Xs}`},{value:"md",label:"Medium — 48px",cls:`font-heading2 font-medium tracking-[-0.03em] ${i.headingMedium2} ${i.headingMediumUpTo800Small}`},{value:"lg",label:"Large — 56px",cls:`font-heading2 font-medium tracking-[-0.03em] ${i.headingMedium3} ${i.headingMediumUpTo800Large}`},{value:"xl",label:"Extra large — 64px",cls:`font-heading2 font-medium tracking-[-0.03em] ${i.headingMedium4} ${i.headingMediumUpTo800Xl}`}];function cr(M){return(Se.find(w=>w.value===M)??Se.find(w=>w.value===mr)).cls}function pr({num:M,catalog:w,catalogTotal:Me,firstCountInChips:Pe=!1,kinds:T,title:G,titleSize:Ee,pads:Ne,noTop:re=!1,description:_,link:P,products:Te,wheels:_e,source:c,columns:Oe,columnsPhone:$e,columnsTablet:Re,limit:ze,moreProducts:Ie,perPage:Le,editing:E,contentCapped:Ae=!1,hover:Be,fieldUsage:v,ownerId:Ge="",template:He,gap:Fe,gapPhone:De}){const H=p(()=>v?ve(v,"alloy-wheel"):void 0,[v]),Ue=p(()=>v?ve(v,"tyre"):void 0,[v]),e=dt("pg"),{paged:y,per:b,limit:a,cap:u}=Kt({moreProducts:Ie,perPage:Le,limit:ze}),m=Yt(Oe,$e,Re),ne=Ae,ke=Vt(),We=qt(),je=ke||We,F=nr(E===!0&&!!c),s=p(()=>c?er(rr(c,T,F??w??[])):null,[w,F,c,T]),D=Bt("grid",s),l=s?D.scope:null,g=tr(c),C=g!==null&&!l,{filters:O,reportCount:U,reportLugs:k,reportSizes:W,reportFinishes:j,reportCategories:K,reportPrices:X,vehicle:ie}=At(),{currency:f}=_t(),Z=C&&!!O.process&&O.process!==g,q=l?.state,r=p(()=>s?q?Dt(s,q,f):C?Qt(s,O,f,ie.fit):s:null,[s,q,C,O,f,ie.fit]),[Ke,Xe]=pe(1),V=y&&r?Math.max(1,Math.ceil(r.length/b)):1,S=Math.min(V,Math.max(1,l?l.state.page:Ke)),{reportShown:Y}=D,se=l!==null;Gt(()=>{if(!se||!r)return Y(null);Y(Xt(r.length,{paged:y,per:b,cap:u},S))},[se,r,Y,y,S,b,u]);const Ze=n=>l?l.update({page:n}):Xe(n),o=p(()=>r&&(y?r.slice((S-1)*b,S*b):u?r.slice(0,Math.ceil(a)+jt):r),[y,u,a,r,S,b]);A(()=>(K(e,g===null?[]:[g]),()=>K(e,[])),[g,K,e]),A(()=>{if(C)return U(e,Z?0:r?.length??0),()=>U(e,0)},[C,Z,r,U,e]);const N=p(()=>({lugs:or(s??[]),sizes:ar(s??[]),finishes:sr(s??[]),prices:kt((s??[]).filter(n=>B(n)!=="tyre"),f)}),[s,f]);A(()=>(k(e,N.lugs),W(e,N.sizes),j(e,N.finishes),X(e,N.prices),()=>{k(e,[]),W(e,[]),j(e,[]),X(e,[])}),[N,k,W,j,X,e]);const J=pt("ProductGrid",Fe,"both",De),qe=`${e} grid${J.className} bg-[var(--catalog-grid-bg)] ${m}`,oe=gt(J),Ve=`${e} grid${oe.className} bg-[var(--catalog-grid-bg)] ${m}`,Ye=oe.style,Je=p(()=>{const n=(r??[]).filter(d=>B(d)!=="tyre");if(n.length===0)return!1;const h=n.some(d=>!!d.process);return n.some(d=>!!d.setWords)||St({kind:!1,brand:!1,process:h},H??[])},[r,H]),Qe=o?o.length>0?t("div",{className:Ve,style:Ye,children:t(ht,{items:o,tyreOf:n=>B(n)==="tyre"?n:null})}):l&&Ut(l.state)?x("div",{className:"flex min-h-[320px] flex-col items-center justify-center gap-4 bg-surface-2 p-4 text-center",children:[t("span",{className:`font-mono ${i.labelSmall} uppercase tracking-[0.2em] text-fg-dim`,children:`No ${be(Ce(c,T)).many} match those filters`}),t(Wt,{onClick:l.clear})]}):E?t("div",{className:"flex min-h-[320px] items-center justify-center rounded bg-surface-2 p-4 text-center",children:t("span",{className:`font-mono ${i.labelSmall} uppercase tracking-[0.2em] text-fg-dim`,children:lr("No products in “{name}” yet",{name:c?.name??""})})}):null:t(Te,{className:qe,style:J.style,minEmptyHeight:320}),et=l?l.countInChips:Pe,$=r&&!et?r===s&&!F?Me??r.length:r.length:null,ae=be(Ce(c,T)),tt=M||G||_||P?x("div",{className:`${ir} sticky top-[var(--sf-header-h,88px)] z-30 mb-5 flex items-center justify-between gap-4 max-view-wide:flex-wrap max-view-wide:gap-y-2 border-b border-line bg-bg/95 py-3 backdrop-blur-md ${ne||je?"":"-mx-[var(--sf-site-gutter,40px)] px-[var(--sf-site-gutter,40px)] max-view-wide:-mx-[min(20px,var(--sf-site-gutter,40px))] max-view-wide:px-[min(20px,var(--sf-site-gutter,40px))]"}`,children:[x("div",{className:"flex min-w-0 items-end gap-6 max-view-wide:flex-col max-view-wide:items-stretch max-view-wide:gap-3",children:[M&&t("span",{className:`font-mono ${i.labelLarge} leading-none uppercase tracking-[0.22em] text-fg-dim`,children:te(M)}),G&&t("h2",{className:`${cr(Ee)} leading-none text-fg max-view-wide:leading-[1] [&>span]:block`,children:Jt(G,!1)})]}),(_||P||$!==null)&&x("div",{className:"flex items-center gap-5 max-view-wide:gap-3 view-wide:grow view-wide:justify-end",children:[_&&t("span",{className:`max-w-[340px] truncate font-display ${i.body} leading-[1.4] text-fg-dim max-view-wide:hidden view-wide:w-0 view-wide:grow view-wide:text-right`,children:te(_)}),P&&x(ut,{href:P.href,className:`inline-flex items-center gap-2 whitespace-nowrap font-mono ${i.labelLarge} uppercase tracking-[0.2em] text-fg-dim transition-colors hover:text-fg`,children:[te(P.text),t("span",{"aria-hidden":!0,children:"→"})]}),$!==null&&x("span",{className:`whitespace-nowrap font-mono ${i.labelSmall} uppercase tracking-[0.2em] text-fg-dim`,children:[$," ",$===1?ae.one:ae.many]})]})]}):null,R=Rt(Ne,zt,{noTop:re}),{paddingTop:rt,...nt}=R.style,z=re?0:rt,it={...z===void 0?{}:{"--pg-pt":typeof z=="number"?`${z}px`:z},...nt},I=p(()=>{if(!o)return null;const n=o.map(h=>B(h)!=="tyre"&&bt(Ct(h))?2:1);return we(n,a)?fe(m,n,a):null},[o,m,a]),[st,ot]=pe("");A(()=>{if(o)return;const n=document.querySelector(`.${e}`);if(!n)return;const h=()=>{const d=[...n.children].map(ce=>ce.classList.contains("col-span-2")&&!ce.querySelector(vt)?2:1);ot(we(d,a)?he(e,fe(m,d,a,!1),d.length):"")};h();const ee=new MutationObserver(h);return ee.observe(n,{childList:!0}),()=>ee.disconnect()},[o,e,m,a]);const at=I?I[0].tracks:o?u?Math.min(o.length,a):o.length:void 0,L=I?he(yt(e),I,o.length)+(u?ge(xe(e),a+1):"")+ue(xe(e),m,{limit:a,cards:o.length}):st,le=L?"":ue(e,m,{limit:a,cards:o?.length}),me=xt(e),de=x(mt,{children:[u&&!L&&t("style",{children:ge(e,a+1)}),L&&t("style",{children:L}),le&&t("style",{children:le}),me&&t("style",{children:me}),tt,Qe,y&&V>1&&t(Ht,{textSize:Ft.labelSmall,page:S,pageCount:V,onPage:Ze}),t(Mt,{editing:E})]});if(Z)return null;const Q=t(Zt,{rootRef:D.ref,attrs:C&&g!==null?{...R.attrs,[Lt]:g}:R.attrs,className:It(`relative z-[2] bg-bg px-[var(--sf-site-gutter,40px)] ${Ot} max-view-wide:px-[min(20px,var(--sf-site-gutter,40px))] ${$t}`,R),column:null,inAnyBox:!0,style:it,defaults:{"--pg-pt":"120px"},children:ne?t("div",{style:Et(Pt),children:de}):de}),lt=s?Q:E?t(Nt,{currency:f,children:Q}):t(Tt,{wheels:_e,currency:f,children:Q});return t(ft,{value:{ownerId:Ge,Template:He,hover:Be??dr,imageSizes:wt(m,at),fieldUsage:H??ye,tyreFieldUsage:Ue??ye,reserveEyebrow:Je,editing:E===!0},children:lt})}export{Se as TITLE_SIZES,pr as default};
|
|
@@ -16,10 +16,12 @@ interface SignUpFindViewProps {
|
|
|
16
16
|
wrong?: string | null;
|
|
17
17
|
trouble?: SignUpTrouble | null;
|
|
18
18
|
linkGone?: boolean;
|
|
19
|
+
openTrouble?: SignUpTrouble | null;
|
|
19
20
|
busy?: boolean;
|
|
20
21
|
onEmail?: (value: string) => void;
|
|
21
22
|
onSubmit?: (event: FormEvent<HTMLFormElement>) => void;
|
|
22
23
|
onAnother?: () => void;
|
|
24
|
+
onRetry?: () => void;
|
|
23
25
|
}
|
|
24
|
-
export declare function SignUpFindView({ stage, productName, startHref, email, wrong, trouble, linkGone, busy, onEmail, onSubmit, onAnother, }: SignUpFindViewProps): import("react").JSX.Element;
|
|
26
|
+
export declare function SignUpFindView({ stage, productName, startHref, email, wrong, trouble, linkGone, openTrouble, busy, onEmail, onSubmit, onAnother, onRetry, }: SignUpFindViewProps): import("react").JSX.Element;
|
|
25
27
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as f,Fragment as O}from"react/jsx-runtime";import _ from"next/link";import{usePathname as C}from"next/navigation";import{useEffect as G,useId as L,useState as s}from"react";import{ApiError as j,askForWorkspaces as U,openWorkspaceFind as B}from"../lib/api/index.js";import{BANNER as v,CARD as E,PRIMARY as P,QUIET as N,TITLE as A}from"../lib/sections/sign-up-look.js";import{FIND_WORDS as t,SIGN_UP_WORDS as g,checkWaitingEmail as M,fill as V,findTokenOf as H,readFindOpenTrouble as Q,readFindRefusal as Y}from"../lib/sections/sign-up.js";function q({product:p,productName:y,startHref:h,inert:m=!1}){const n=m?"":H(C()),[b,i]=s(n?"opening":"form"),[r,x]=s(""),[k,u]=s(null),[F,d]=s(null),[o,c]=s(!1),[S,$]=s(null),[D,I]=s(0),[w,T]=s(!1);return G(()=>{if(!n)return;let l=!1;return B(n).then(a=>{l||(a?window.location.assign(a):(c(!0),i("form")))}).catch(a=>{l||($(a instanceof j?Q(a.status):"failed"),i("form"))}),()=>{l=!0}},[n,D]),e(z,{stage:b,productName:y,startHref:h,email:r,wrong:k,trouble:F,linkGone:o,openTrouble:S,busy:w,onEmail:l=>{x(l),u(null),d(null)},onSubmit:async l=>{if(l.preventDefault(),m||w)return;const a=M(r);if(u(a),d(null),!a){T(!0);try{await U(p,r),c(!1),$(null),i("sent")}catch(R){const W=R instanceof j?Y(R.status,R.data):{email:null,trouble:"failed"};u(W.email),d(W.trouble)}finally{T(!1)}}},onAnother:()=>i("form"),onRetry:()=>{$(null),i("opening"),I(l=>l+1)}})}function z({stage:p,productName:y,startHref:h,email:m,wrong:n,trouble:b,linkGone:i=!1,openTrouble:r=null,busy:x=!1,onEmail:k,onSubmit:u,onAnother:F,onRetry:d}){const o=L();if(p==="opening")return e("div",{className:E,role:"status",children:e("p",{className:N,children:t.opening})});if(p==="sent"){const[c,S]=t.sentBody.split("{email}");return f("div",{className:E,children:[e("h2",{className:A,children:t.sentTitle}),f("p",{className:"mt-[10px]",children:[c,e("span",{className:"font-medium",children:m.trim()}),S]}),e("p",{className:`${N} mt-[10px]`,children:t.sentNote}),e("button",{type:"button",onClick:F,className:"mt-[18px] flex h-11 w-full cursor-pointer items-center justify-center rounded-[10px] border border-line font-medium text-fg",children:t.another})]})}return f("form",{noValidate:!0,onSubmit:u,className:E,children:[e("h2",{className:A,children:t.title}),r?f(O,{children:[e("p",{role:"alert",className:`${v} mt-[10px]`,children:r==="unreachable"||r==="tooMany"?g.trouble[r]:t.openFailed}),e("button",{type:"button",onClick:d,className:"mt-3 flex h-11 w-full cursor-pointer items-center justify-center rounded-[10px] border border-line font-medium text-fg",children:t.retry})]}):i?e("p",{role:"alert",className:`${v} mt-[10px]`,children:t.linkGone}):e("p",{className:`${N} mt-1`,children:t.intro}),e("label",{htmlFor:`${o}-email`,className:"mb-1 mt-3 block text-[13px] font-medium",children:g.email}),e("div",{className:`flex h-11 items-center rounded-[10px] border bg-bg px-3 ${n?"border-alert":"border-line focus-within:border-accent"}`,children:e("input",{id:`${o}-email`,name:"email",type:"email",autoComplete:"email",maxLength:254,value:m,"aria-invalid":n?!0:void 0,"aria-describedby":n?`${o}-email-said`:void 0,onChange:c=>k?.(c.target.value),className:"h-full w-full bg-transparent text-[14px] text-fg outline-none focus-visible:outline-none!"})}),n&&e("p",{id:`${o}-email-said`,role:"alert",className:"mt-1 text-[13px] text-alert",children:n}),b&&e("p",{role:"alert",className:v,children:g.trouble[b]}),e("button",{type:"submit",disabled:x,className:P,children:x?g.sending:t.submit}),h&&f("p",{className:`${N} mt-3 text-center`,children:[V(t.newHere,{name:y})," ",e(_,{href:h,className:"text-accent",children:t.create})]})]})}export{z as SignUpFindView,q as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as i,jsxs as h}from"react/jsx-runtime";import{useEffect as v,useId as k,useRef as f,useState as y}from"react";import{CATALOG_TEXT_SIZE as d}from"../../lib/sections/catalog-text-size.js";import{
|
|
1
|
+
"use client";import{jsx as i,jsxs as h}from"react/jsx-runtime";import{useEffect as v,useId as k,useRef as f,useState as y}from"react";import{CATALOG_TEXT_SIZE as d}from"../../lib/sections/catalog-text-size.js";import{useBrowserLayoutEffect as _}from"efficient-shell/hooks";function C({labelSize:n=d.labelLarge,label:c,badge:o,open:e,onToggle:r,controls:m,buttonRef:p}){const a=o>0;return h("button",{ref:p,type:"button","aria-haspopup":"dialog","aria-expanded":e,"aria-controls":m,onClick:r,className:[`inline-flex items-center gap-2 whitespace-nowrap border px-4 py-3 font-mono ${n} uppercase tracking-[0.2em] transition-colors`,a?"border-accent text-accent":"border-line hover:border-fg-dim"].join(" "),style:a?void 0:{color:"color-mix(in oklab, currentColor 80%, transparent)"},children:[c,o>0&&i("span",{className:`px-2 ${d.badge} tracking-[0.1em] text-bg`,style:{background:"var(--accent)"},children:o}),i("span",{className:`${d.badge} opacity-65 transition-transform ${e?"rotate-180":""}`,children:"▾"})]})}function R({labelSize:n,label:c,badge:o,open:e,onToggle:r,children:m}){const p=k(),a=f(null),x=f(null),b=f(null),[E,g]=y(!1);return _(()=>{if(!e){g(!1);return}const t=b.current,s=a.current,l=t?.ownerDocument.defaultView;if(!t||!s||!l||l.getComputedStyle(s).position==="static")return;const u=t.ownerDocument.documentElement.clientWidth,w=t.getBoundingClientRect();w.width>0&&w.right>u-L&&g(!0)},[e]),v(()=>{if(!e)return;const t=a.current?.ownerDocument??document,s=u=>{u.key==="Escape"&&(r(),x.current?.focus())},l=u=>{a.current?.contains(u.target)||r()};return t.addEventListener("keydown",s),t.addEventListener("pointerdown",l),()=>{t.removeEventListener("keydown",s),t.removeEventListener("pointerdown",l)}},[e,r]),h("div",{ref:a,className:e?"relative @max-[720px]:static":"relative",children:[i(C,{labelSize:n,label:c,badge:o,open:e,onToggle:r,controls:e?p:void 0,buttonRef:x}),e&&i("div",{ref:b,id:p,className:`absolute ${E?"right-0":"left-0"} top-[calc(100%+6px)] z-[60] min-w-[280px] max-w-[calc(100vw-32px)] border border-line bg-surface p-5 shadow-[0_24px_60px_rgba(0,0,0,0.4)] @max-[720px]:inset-x-0 @max-[720px]:top-auto @max-[720px]:mt-2 @max-[720px]:min-w-0`,onClick:t=>t.stopPropagation(),children:m})]})}const L=16;function S({children:n}){return i("div",{className:`mb-3 font-mono ${d.labelSmall} uppercase tracking-[0.32em] text-fg-dim`,children:n})}function B({active:n,onClick:c,children:o,role:e,ariaChecked:r}){return i("button",{type:"button",role:e,"aria-checked":e==="radio"?r:void 0,onClick:c,className:[`border px-3 py-2 font-mono ${d.labelLarge} uppercase tracking-[0.18em] transition-colors`,n?"border-accent bg-accent text-bg":"border-line hover:border-fg-dim"].join(" "),style:n?void 0:{color:"color-mix(in oklab, currentColor 75%, transparent)"},children:o})}export{R as FilterPill,B as OptButton,S as PanelTitle,C as PillButton};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type ComponentType, type ReactNode } from "react";
|
|
2
2
|
import { type SelectedRanges } from "efficient-web-builder/render/lib/content/box-show-for";
|
|
3
3
|
import type { PlpItem } from "../../lib/catalog/plp-item.js";
|
|
4
4
|
import { type PlpFilterState, type PlpSortKey } from "../../lib/wheels/plp-filters.js";
|
|
5
5
|
import { type ShopperAddressMark as AddressMark } from "../../lib/wheels/selected-ranges.js";
|
|
6
6
|
import { type GallerySortKey, type GalleryTile, type GalleryToolbarState } from "../../lib/sections/gallery-toolbar.js";
|
|
7
|
-
export declare const useIsoLayoutEffect: typeof useEffect;
|
|
8
7
|
type Patch = Partial<PlpFilterState> | ((f: PlpFilterState) => PlpFilterState);
|
|
9
8
|
export interface GridShown {
|
|
10
9
|
total: number;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use client";import{jsx as M}from"react/jsx-runtime";import{createContext as U,useCallback as k,useContext as R,useEffect as
|
|
1
|
+
"use client";import{jsx as M}from"react/jsx-runtime";import{createContext as U,useCallback as k,useContext as R,useEffect as y,useId as ct,useMemo as b,useRef as V,useState as A}from"react";import{useBrowserLayoutEffect as E}from"efficient-shell/hooks";import{useBoxId as it}from"efficient-web-builder/render/components/InBoxContext";import{SelectedRangesProvider as ut}from"efficient-web-builder/render/lib/content/box-show-for";import{EMPTY_PLP_FILTERS as x,plpFiltersToParams as j}from"../../lib/wheels/plp-filters.js";import{VEHICLE_PARAM as ft}from"../../lib/wheels/plp-vehicle-params.js";import{readSelectedRanges as pt,shopperAddressMarkOf as wt}from"../../lib/wheels/selected-ranges.js";import{resolveGalleryFollows as dt,resolveShopperScopes as gt}from"../../lib/wheels/shopper-scope.js";import{clampGalleryTag as ht,EMPTY_GALLERY_TOOLBAR as Y,galleryShownIds as St,galleryTags as mt}from"../../lib/sections/gallery-toolbar.js";import{filtersFromQuery as Pt,watchLocation as _t}from"../wheels-plp/usePlpFiltersInUrl.js";const G=U(null),kt={assign:new Map,states:{},rows:{},shown:{},chipParts:{},galleryFollow:new Map,tiles:{},galleryStates:{}};function W(o,r){if(o.size!==r.size)return!1;for(const[u,s]of o)if(r.get(u)!==s)return!1;return!0}function X(o,r){return typeof r=="function"?r(o):{...o,...r}}function vt(o,r){return j(o).toString()===j(r).toString()}function $t({children:o,address:r=null,editing:u=!1}){const s=V(new Map),[l,f]=A(kt),[p,w]=A(0),d=!u&&r?JSON.stringify(r):"",c=b(()=>d?r:null,[d]),[g,P]=A(null),_=k((t,n,e)=>{if(s.current.set(t.key,t),t.role==="filter"){const a=n??x;f(i=>i.states[t.key]?i:{...i,states:{...i.states,[t.key]:a}}),e&&P(i=>i??{key:t.key,opening:a.sort})}w(a=>a+1)},[]),S=k(t=>{P(n=>n?.key===t?null:n),s.current.delete(t),f(n=>{if(!(t in n.states)&&!(t in n.rows)&&!(t in n.shown)&&!(t in n.chipParts)&&!(t in n.tiles)&&!(t in n.galleryStates))return n;const{[t]:e,...a}=n.states,{[t]:i,...m}=n.rows,{[t]:C,...ot}=n.shown,{[t]:Rt,...st}=n.chipParts,{[t]:At,...lt}=n.tiles,{[t]:Tt,...at}=n.galleryStates;return{...n,states:a,rows:m,shown:ot,chipParts:st,tiles:lt,galleryStates:at}}),w(n=>n+1)},[]);y(()=>{if(p===0)return;const t=[...s.current.values()],n=gt(t),e=dt(t);f(a=>{const i=W(a.assign,n),m=W(a.galleryFollow,e);return i&&m?a:{...a,assign:i?a.assign:n,galleryFollow:m?a.galleryFollow:e}})},[p]);const v=k((t,n)=>{f(e=>{const a=e.states[t];return a?{...e,states:{...e.states,[t]:X(a,n)}}:e})},[]),T=k((t,n)=>{f(e=>{if(n===null){if(!(t in e.rows))return e;const{[t]:a,...i}=e.rows;return{...e,rows:i}}return e.rows[t]===n?e:{...e,rows:{...e.rows,[t]:n}}})},[]),F=k((t,n)=>{f(e=>{if(n===null){if(!(t in e.shown))return e;const{[t]:m,...C}=e.shown;return{...e,shown:C}}const a=e.shown[t];return a&&a.total===n.total&&a.range?.from===n.range?.from&&a.range?.to===n.range?.to?e:{...e,shown:{...e.shown,[t]:n}}})},[]),B=k((t,n)=>{f(e=>{const a=e.chipParts[t],i=n.count||n.sort;if(!i&&!a||a&&a.count===n.count&&a.sort===n.sort)return e;const{[t]:m,...C}=e.chipParts;return{...e,chipParts:i?{...C,[t]:n}:C}})},[]),D=k((t,n)=>{f(e=>{if(n===null){if(!(t in e.tiles))return e;const{[t]:a,...i}=e.tiles;return{...e,tiles:i}}return e.tiles[t]===n?e:{...e,tiles:{...e.tiles,[t]:n}}})},[]),H=k((t,n)=>{f(e=>({...e,galleryStates:{...e.galleryStates,[t]:{...e.galleryStates[t]??Y,...n}}}))},[]),[L,nt]=A(null),h=g?.key??null,q=g?.opening??x.sort;y(()=>{if(!c||typeof window>"u")return;const t=()=>{const n=window.location.search,e=pt(n,c.known);if(nt(i=>i&&i.writer===h&&i.ranges.join(`
|
|
2
2
|
`)===e.join(`
|
|
3
|
-
`)?i:{ranges:e,writer:h}),!h)return;const a={...
|
|
3
|
+
`)?i:{ranges:e,writer:h}),!h)return;const a={...Pt(n,q),collections:[...e]};f(i=>{const m=i.states[h];return!m||vt(m,a)?i:{...i,states:{...i.states,[h]:{...m,...a}}}})};return t(),_t(t)},[c,h,q]);const I=h?l.states[h]:void 0;y(()=>{if(!c||!h||!I||L?.writer!==h||typeof window>"u")return;const t=j(I),n=new URLSearchParams(window.location.search);for(const i of Object.values(ft))for(const m of n.getAll(i))t.append(i,m);const e=t.toString(),a=e?`?${e}`:"";a!==window.location.search&&window.history.replaceState(null,"",`${window.location.pathname}${a}`)},[c,h,I,L]);const O=c?.known,J=I?.collections,Q=L?.ranges,et=b(()=>!c||!O?null:{selected:(J??Q??c.selected).filter(n=>O.includes(n)),known:O},[c,O,J,Q]),rt=b(()=>({snap:l,address:c,writer:h,register:_,unregister:S,update:v,reportRows:T,reportShown:F,reportChipParts:B,reportTiles:D,updateGallery:H}),[l,c,h,_,S,v,T,F,B,D,H]);return M(G.Provider,{value:rt,children:M(ut,{value:et,children:o})})}const N=U(null);function xt({mark:o,children:r}){return M(N.Provider,{value:o,children:r})}function zt(o){return function(u){return M(xt,{mark:wt(u),children:M(o,{...u})})}}function Z(o,r){return{...x,sort:r,collections:[...o.selected]}}function $(o,r){if(!r)return null;const u=o.snap.states[r];if(!u)return null;const s=[];let l=0,f=0,p=!1,w=!1,d=null;for(const[c,g]of o.snap.assign){if(g!==r||c===r)continue;const P=o.snap.chipParts[c];P?.count&&(p=!0),P?.sort&&(w=!0);const _=o.snap.rows[c];if(!_)continue;f+=1,s.push(..._);const S=o.snap.shown[c];l+=S?.total??0,d=S?.range??null}return f!==1&&(d=null),{key:r,live:!0,state:u,update:c=>o.update(r,c),clear:()=>o.update(r,c=>({...x,sort:c.sort})),rows:s,total:l,grids:f,countInChips:p,sortInChips:w,range:d}}const K={count:!1,sort:!1};function z(o,r,u,s,l){const f=ct(),p=it(),w=V(null),d=k(P=>{w.current=P},[]),c=o?.register,g=o?.unregister;return E(()=>{if(!(!c||!g))return c({key:f,role:r,boxId:p,node:w.current,filtersBelow:u},s,l),()=>g(f)},[c,g,f,r,p,u,l]),{key:f,ref:d}}function Bt({filtersBelow:o,openingSort:r}){const u=R(G),s=R(N),l=u?.address??null,f=!!s?.writes&&l!==null,p=f?Z(l,r):{...x,sort:r},{key:w,ref:d}=z(u,"filter",o,p,f),[c,g]=A(p),_=(u?$(u,w):null)??{key:w,live:!1,state:c,update:S=>g(v=>X(v,S)),clear:()=>g(S=>({...x,sort:S.sort})),rows:[],total:0,grids:0,countInChips:!1,sortInChips:!1,range:null};return{ref:d,scope:_}}function Dt(o,r=null,u=K){const s=R(G),{key:l,ref:f}=z(s,o,!1),p=s?.reportRows,w=s?.reportShown;E(()=>{if(!(!p||o!=="grid"))return p(l,r),()=>p(l,null)},[p,l,o,r]);const d=k(F=>w?.(l,F),[w,l]);y(()=>()=>w?.(l,null),[w,l]);const c=s?.reportChipParts,{count:g,sort:P}=u;E(()=>{if(!(!c||o!=="chips"))return c(l,{count:g,sort:P}),()=>c(l,K)},[c,l,o,g,P]);const _=s?.snap.assign.get(l),S=R(N);let v=s?$(s,_):null;!v&&_===void 0&&s?.address&&S&&(v=(s.writer?$(s,s.writer):null)??Mt(Z(s.address,S.sort)));const T=s&&o==="chips"&&!v?Ct(s,s.snap.galleryFollow.get(l)):null;return{ref:f,scope:v,reportShown:d,gallery:T}}function Ct(o,r){if(!r)return null;const u=o.snap.tiles[r]??[],s=o.snap.galleryStates[r]??Y;return{tags:mt(u),tag:ht(s.tag,u),sort:s.sort,shown:St(u,s).length,pick:l=>o.updateGallery(r,{tag:l}),setSort:l=>o.updateGallery(r,{sort:l}),clear:()=>o.updateGallery(r,{tag:null})}}function Ht(o){const r=R(G),{key:u,ref:s}=z(r,"gallery",!1),l=r?.reportTiles;E(()=>{if(l)return l(u,o),()=>l(u,null)},[l,u,o]);let f=!1;if(r)for(const[w,d]of r.snap.galleryFollow)d===u&&!r.snap.assign.get(w)&&(f=!0);const p=r&&f?r.snap.galleryStates[u]??Y:null;return{ref:s,toolbar:p}}const tt=()=>{};function Mt(o){return{key:"",live:!1,state:o,update:tt,clear:tt,rows:[],total:0,grids:0,countInChips:!1,sortInChips:!1,range:null}}export{xt as ShopperAddressMark,$t as ShopperScopeProvider,Bt as useShopperFilter,Ht as useShopperGallery,Dt as useShopperMember,zt as withShopperAddressMark};
|
|
@@ -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{backendHopHeaders as yt,clientIpFromForwardedFor as ht,FORWARDED_FOR_HEADER as ft,hopCachingOf as gt}from"../forwarded-for.js";import mt from"efficient-web-builder/format/lib/document/media-manifest.json";import{auth as O}from"../auth.js";import{efficientClientOpen as wt}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 St=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.",Pt=new Set([502,503,504]),k=0,Ot="This editor runs on its host's own backend, which does not serve this request.",bt=5e3,Tt=15e3,At=()=>typeof window>"u"?bt:Tt;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(At())}const B=t=>t instanceof Error&&t.name==="TimeoutError",q=(t,e)=>Pt.has(t)?v:e,Rt=["admin","venue"];let G="admin";function Ee(t){G=Rt.includes(t)?t:"admin"}function Et(){return G}const _t=/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/;let W=null;function _e(t){W=t&&_t.test(t)?t:null}function Ut(){return W}function $t(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"&&!wt())throw new w(k,Ot,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??St}${$t(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=Ct().finally(()=>{A=null}),A)}async function Ct(){const t=O.takeLegacyRefresh(),e=await vt.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 Nt=100,K=20;function It(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(Nt)),l!=="1"&&a.set("page",l);const r=await g(`${n}?${a.toString()}`);u.push(...m(r)),l=It(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 vt={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 kt,absolutizeApiUrl as L}from"efficient-web-builder/render/lib/media";import{analyzeLogoSvg as Lt,isSvgUrl as Jt}from"efficient-web-builder/format/lib/logo/reverse-svg";import{getEditorSiteId as xt}from"efficient-web-builder/render/lib/editor-site";import{shopRouteBase as Dt,webRuntimeSiteSlug as Y}from"efficient-web-builder/format/lib/web-runtime";import{readDealerList as Ht}from"../sections/dealer-finder.js";import{SIGN_UP_PATH as Ft,SIGN_UP_VERIFY_PATH as Mt,SIGN_UP_WAITING_PATH as Bt,WORKSPACE_FINDS_PATH as qt,WORKSPACE_FIND_OPEN_PATH as Gt,signInUrlOf as Wt,readLinkAnswer as Q,readSignUpAvailability as jt,readSignUpSent as zt,signUpAvailabilityPath as Kt}from"../sections/sign-up.js";function S(t){if(typeof t=="string")return t.startsWith("/media/")?kt(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 Ke}from"./origins.js";const tt=typeof window>"u"&&H!=="",Vt=tt?H:pt,Xt=Dt,b=()=>({baseUrl:Xt(),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 Zt(t,e){return J("/wheels",{process:t},e)}const rt=et;function Yt(t,e){return J("/wheels",{slug:t.join(",")},e)}function Qt(t,e,n){return J("/products",{kind:t.join(","),make:e?.make,model:e?.model,year:e?.year,modification:e?.modification},n)}function te(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=te(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 ee()).host}async function ee(){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 ae(){try{const{headers:t}=await import("next/headers");return ht((await t()).get(ft))}catch{return null}}async function re(){try{const{headers:t}=await import("next/headers");return(await t()).get(lt)||null}catch{return null}}async function ne(){const t=await re();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 ne())}function $(t,e){return e?`${t}${t.includes("?")?"&":"?"}${e}`:t}const se="preview";async function oe(){if(typeof window<"u")return null;try{const{headers:t}=await import("next/headers");return(await t()).get(dt)}catch{return null}}async function ie(){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 oe();if(n===null)return[await f(t),await d(e)];const s=$(await f(t),`${se}=${encodeURIComponent(n)}`),{next:u,cache:l,...y}=e??{},a=await d({...y,cache:"no-store"}),r=await ie();return r&&(a.headers={...a.headers,"user-agent":r}),[s,a]}async function ce(t){if(!tt)return;const[e,n]=await Promise.all([ot(),ae()]),s=yt(e,n,t);return Object.keys(s).length>0?s:void 0}async function d(t){const e=await ce(gt(t)),n={baseUrl:Vt,...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 ke={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())}},Le={listWheels:async(t,e={})=>{const n=await x("products.listWheels",async s=>await f(Zt(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(Yt(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(Qt(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&&Jt(n)){const l=await Lt(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())},Je={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"})),createPaymentIntent:async t=>i(c("/bookings/payments/intent"),await d({method:"POST",body:JSON.stringify({manageToken:t})}))};class de 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)}/`,ue=t=>`${N(t)}currencies/`,le="/api/storefront/media/ingest/";class pe 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 ye(){const t=xt();if(!t)throw new pe;return`${le}?${new URLSearchParams({site:t})}`}const he="X-Puck-Media-Manifest",it=mt.contentHash,I={"X-Media-Manifest":it,[he]:it},xe=ct({});function ct(t){return(e,n={})=>{const s=Ut(),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??Et()})}}function fe(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 de(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(ue(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(ye(),{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 De=fe({siteDrafts:!0});function ge(t){const e=t.trim();return e?`/api/v1/dealers?${new URLSearchParams({near:e}).toString()}`:"/api/v1/dealers"}async function He(t){return Ht(await i(ge(t)))}const T={audience:null,baseUrl:""};async function Fe(t,e){return jt(await i(Kt(t,e),T))}async function Me(t){return zt(await i(Ft,{...T,method:"POST",body:JSON.stringify(t)}))}async function Be(t){try{const e=await i(Mt,{...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 qe(t,e){await i(Bt,{...T,method:"POST",body:JSON.stringify({email:e.trim(),...t?{product:t}:{}})})}async function Ge(t,e){await i(qt,{...T,method:"POST",body:JSON.stringify({email:e.trim(),...t?{product:t}:{}})})}async function We(t){try{return Wt(await i(Gt,{...T,method:"POST",body:JSON.stringify({token:t})}))}catch(e){if(e instanceof w)return"";throw e}}export{St as API_URL,de as AmbiguousPageSlugError,w as ApiError,Tt as BROWSER_READ_TIMEOUT_MS,Ot as EFFICIENT_CLIENT_CLOSED_MESSAGE,pe as MediaUploadDestinationError,se as PREVIEW_PARAM,Ke as PRODUCT_API_BASE,bt as SERVER_READ_TIMEOUT_MS,v as SERVER_UNREACHABLE_MESSAGE,k as STATUS_NETWORK_ERROR,xe as adminFetch,vt as api,i as apiFetch,$ as appendSiteQuery,Ge as askForWorkspaces,Me as askToSignUp,Je as bookings,fe as createStorefrontAdmin,ge as dealersPath,M as defaultRequestDeadline,ye as editorMediaUploadPath,Et as editorPortalAudience,Ut as editorRequestLanguage,He as fetchDealers,Fe as fetchSignUpAvailability,ke as fitment,qe as joinSignUpWaitingList,Be as openSignUpLink,We as openWorkspaceFind,Le as products,At as readDeadlineMs,ae as resolveClientIp,S as resolveMediaUrls,oe as resolvePreviewToken,ot as resolveSiteHost,ee as resolveSiteHostSource,re as resolveSiteSlug,_e as setEditorLanguage,Ee as setEditorPortalAudience,De as storefrontAdmin};
|
|
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{backendHopHeaders as yt,clientIpFromForwardedFor as ht,FORWARDED_FOR_HEADER as ft,hopCachingOf as gt}from"../forwarded-for.js";import mt from"efficient-web-builder/format/lib/document/media-manifest.json";import{auth as O}from"../auth.js";import{efficientClientOpen as wt}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 St=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.",Pt=new Set([502,503,504]),k=0,Ot="This editor runs on its host's own backend, which does not serve this request.",bt=5e3,Tt=15e3,At=()=>typeof window>"u"?bt:Tt;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(At())}const B=t=>t instanceof Error&&t.name==="TimeoutError",q=(t,e)=>Pt.has(t)?v:e,Rt=["admin","venue"];let G="admin";function _e(t){G=Rt.includes(t)?t:"admin"}function Et(){return G}const _t=/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/;let W=null;function Ue(t){W=t&&_t.test(t)?t:null}function Ut(){return W}function $t(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"&&!wt())throw new w(k,Ot,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??St}${$t(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=Ct().finally(()=>{A=null}),A)}async function Ct(){const t=O.takeLegacyRefresh(),e=await vt.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 Nt=100,K=20;function It(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(Nt)),l!=="1"&&a.set("page",l);const r=await g(`${n}?${a.toString()}`);u.push(...m(r)),l=It(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 vt={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 kt,absolutizeApiUrl as L}from"efficient-web-builder/render/lib/media";import{analyzeLogoSvg as Lt,isSvgUrl as Jt}from"efficient-web-builder/format/lib/logo/reverse-svg";import{getEditorSiteId as xt}from"efficient-web-builder/render/lib/editor-site";import{shopRouteBase as Dt,webRuntimeSiteSlug as Y}from"efficient-web-builder/format/lib/web-runtime";import{readDealerList as Ht}from"../sections/dealer-finder.js";import{SIGN_UP_PATH as Ft,SIGN_UP_VERIFY_PATH as Mt,SIGN_UP_WAITING_PATH as Bt,WORKSPACE_FINDS_PATH as qt,WORKSPACE_FIND_OPEN_PATH as Gt,signInUrlOf as Wt,readLinkAnswer as Q,readSignUpAvailability as jt,readSignUpSent as zt,signUpAvailabilityPath as Kt}from"../sections/sign-up.js";function S(t){if(typeof t=="string")return t.startsWith("/media/")?kt(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 Ve}from"./origins.js";const tt=typeof window>"u"&&H!=="",Vt=tt?H:pt,Xt=Dt,b=()=>({baseUrl:Xt(),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 Zt(t,e){return J("/wheels",{process:t},e)}const rt=et;function Yt(t,e){return J("/wheels",{slug:t.join(",")},e)}function Qt(t,e,n){return J("/products",{kind:t.join(","),make:e?.make,model:e?.model,year:e?.year,modification:e?.modification},n)}function te(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=te(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 ee()).host}async function ee(){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 ae(){try{const{headers:t}=await import("next/headers");return ht((await t()).get(ft))}catch{return null}}async function re(){try{const{headers:t}=await import("next/headers");return(await t()).get(lt)||null}catch{return null}}async function ne(){const t=await re();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 ne())}function $(t,e){return e?`${t}${t.includes("?")?"&":"?"}${e}`:t}const se="preview";async function oe(){if(typeof window<"u")return null;try{const{headers:t}=await import("next/headers");return(await t()).get(dt)}catch{return null}}async function ie(){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 oe();if(n===null)return[await f(t),await d(e)];const s=$(await f(t),`${se}=${encodeURIComponent(n)}`),{next:u,cache:l,...y}=e??{},a=await d({...y,cache:"no-store"}),r=await ie();return r&&(a.headers={...a.headers,"user-agent":r}),[s,a]}async function ce(t){if(!tt)return;const[e,n]=await Promise.all([ot(),ae()]),s=yt(e,n,t);return Object.keys(s).length>0?s:void 0}async function d(t){const e=await ce(gt(t)),n={baseUrl:Vt,...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 Le={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())}},Je={listWheels:async(t,e={})=>{const n=await x("products.listWheels",async s=>await f(Zt(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(Yt(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(Qt(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&&Jt(n)){const l=await Lt(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())},xe={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"})),createPaymentIntent:async t=>i(c("/bookings/payments/intent"),await d({method:"POST",body:JSON.stringify({manageToken:t})}))};class de 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)}/`,ue=t=>`${N(t)}currencies/`,le="/api/storefront/media/ingest/";class pe 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 ye(){const t=xt();if(!t)throw new pe;return`${le}?${new URLSearchParams({site:t})}`}const he="X-Puck-Media-Manifest",it=mt.contentHash,I={"X-Media-Manifest":it,[he]:it},De=ct({});function ct(t){return(e,n={})=>{const s=Ut(),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??Et()})}}function fe(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 de(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(ue(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(ye(),{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 He=fe({siteDrafts:!0});function ge(t){const e=t.trim();return e?`/api/v1/dealers?${new URLSearchParams({near:e}).toString()}`:"/api/v1/dealers"}async function Fe(t){return Ht(await i(ge(t)))}const T={audience:null,baseUrl:""};async function Me(t,e){return jt(await i(Kt(t,e),T))}async function Be(t){return zt(await i(Ft,{...T,method:"POST",body:JSON.stringify(t)}))}async function qe(t){try{const e=await i(Mt,{...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 Ge(t,e){await i(Bt,{...T,method:"POST",body:JSON.stringify({email:e.trim(),...t?{product:t}:{}})})}async function We(t,e){await i(qt,{...T,method:"POST",body:JSON.stringify({email:e.trim(),...t?{product:t}:{}})})}async function je(t){try{return Wt(await i(Gt,{...T,method:"POST",body:JSON.stringify({token:t})}))}catch(e){if(e instanceof w&&me.has(e.status))return"";throw e}}const me=new Set([400,404,410]);export{St as API_URL,de as AmbiguousPageSlugError,w as ApiError,Tt as BROWSER_READ_TIMEOUT_MS,Ot as EFFICIENT_CLIENT_CLOSED_MESSAGE,pe as MediaUploadDestinationError,se as PREVIEW_PARAM,Ve as PRODUCT_API_BASE,bt as SERVER_READ_TIMEOUT_MS,v as SERVER_UNREACHABLE_MESSAGE,k as STATUS_NETWORK_ERROR,De as adminFetch,vt as api,i as apiFetch,$ as appendSiteQuery,We as askForWorkspaces,Be as askToSignUp,xe as bookings,fe as createStorefrontAdmin,ge as dealersPath,M as defaultRequestDeadline,ye as editorMediaUploadPath,Et as editorPortalAudience,Ut as editorRequestLanguage,Fe as fetchDealers,Me as fetchSignUpAvailability,Le as fitment,Ge as joinSignUpWaitingList,qe as openSignUpLink,je as openWorkspaceFind,Je as products,At as readDeadlineMs,ae as resolveClientIp,S as resolveMediaUrls,oe as resolvePreviewToken,ot as resolveSiteHost,ee as resolveSiteHostSource,re as resolveSiteSlug,Ue as setEditorLanguage,_e as setEditorPortalAudience,He as storefrontAdmin};
|
|
@@ -197,7 +197,10 @@ export declare const FIND_WORDS: {
|
|
|
197
197
|
readonly another: "Use another email";
|
|
198
198
|
readonly linkGone: "This link is not right, or it has run out. Ask for your workspaces again.";
|
|
199
199
|
readonly opening: "Opening your workspace";
|
|
200
|
+
readonly openFailed: "We couldn't open your workspace just now. Your link still works — try again.";
|
|
201
|
+
readonly retry: "Try again";
|
|
200
202
|
};
|
|
203
|
+
export declare function readFindOpenTrouble(status: number): SignUpTrouble;
|
|
201
204
|
export declare function readFindRefusal(status: number, data: unknown): {
|
|
202
205
|
email: string | null;
|
|
203
206
|
trouble: SignUpTrouble | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{COUNTRY_CODES as y,CURRENCY_CODES as b}from"./sign-up-catalogue.js";import{formatDateTime as h}from"efficient-shell/format";import{firstReadableZone as k,runtimeLocale as w}from"../zone.js";const L={firstName:"",lastName:"",email:"",company:"",slug:"",country:"",currency:""},_=["slug_malformed","slug_reserved","slug_taken"],d=e=>typeof e=="string"&&_.includes(e),W=400,t={title:"Create your {name} workspace",freeLine:"Free to start. No card needed.",firstName:"First name",lastName:"Last name",email:"Work email",company:"Company name",address:"Workspace address",country:"Country",currency:"Currency",countryHint:"Your shop sells in this currency. The country sets its tax and shipping defaults. Both can be changed later.",checking:"Checking",available:"Available",submit:"Create workspace",sending:"Sending…",agree:"By creating a workspace you agree to the {terms} and {privacy}.",terms:"Terms",privacy:"Privacy Policy",haveOne:"Already have a workspace?",find:"Find my workspace",required:"Fill this in.",companyShort:"Use at least 2 characters.",emailWrong:"Enter an email address, like name@company.com.",notOffered:"That choice is not offered. Pick another.",wrong:"Check this and try again.",slugProblem:{slug_malformed:"Use 3 to 30 lower-case letters, digits or single hyphens, starting with a letter.",slug_reserved:"That address is kept for the platform. Choose another.",slug_taken:"That address is taken. Choose another."},trouble:{closed:"Signing up is closed just now.",dailyLimit:"Too many workspaces signed up today. Try again tomorrow.",unavailable:"Signing up is not available just now. Try again later.",tooMany:"You have asked a few times in a row. Wait a minute, then try again.",unreachable:"We couldn't reach the server. Check your connection and try again.",failed:"Something went wrong and nothing was sent. Try again."},closedTitle:"Signing up is closed just now",closedBody:"New {name} workspaces cannot be made just now.",closedLeave:"Leave your email and we'll tell you when it opens.",tellMe:"Tell me when it opens",waitingDone:"Thanks. We'll email {email} when sign-up opens.",sentTitle:"Check your email",sentBody:"We sent a link to {email}. Open it to set up {company}.",sentUntil:"The link works once, until {when}. Asking again sends a new link, and the old one stops working.",sendAgain:"Send it again",sendingAgain:"Sending…",sentAgain:"A new link is on its way. The old one no longer works.",change:"Change the details"};function p(e,n){return e.replace(/\{(\w+)\}/g,(r,o)=>n[o]??r)}function m(e){return e.trim().toLowerCase().replace(/_/g,"-")}function O(e){return e.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).join("-").replace(/^[^a-z]+/,"").slice(0,30).replace(/-+$/,"")}function U(e,n){const r=(e??"").trim().toLowerCase().replace(/^\.+/,"").replace(/\.+$/,"");if(r)return`.${r}`;const o=n.toLowerCase().replace(/\.$/,"").replace(/^www\./,"");return o?`.${o}`:""}const s=e=>typeof e=="string"?e:"";function E(e,n){const r=new URLSearchParams;n&&r.set("slug",n),e&&r.set("product",e);const o=r.toString();return`/api/business-sign-ups/availability/${o?`?${o}`:""}`}const R="/api/business-sign-ups/",D="/api/business-sign-ups/waiting-list/";function F(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{};return r.code==="sign_up_open"?{open:!0,email:null,trouble:null}:r.code==="sign_up_waiting_list_unavailable"?{open:!1,email:null,trouble:"unavailable"}:e===400&&"email"in r?{open:!1,email:t.emailWrong,trouble:null}:e===0?{open:!1,email:null,trouble:"unreachable"}:e===429?{open:!1,email:null,trouble:"tooMany"}:{open:!1,email:null,trouble:"failed"}}function j(e){const n=e.trim();return n?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?null:t.emailWrong:t.required}function $(e){const n=e&&typeof e=="object"?e:{};return{open:n.open===!0,country:s(n.country),currency:s(n.currency),slugAvailable:typeof n.slug_available=="boolean"?n.slug_available:null,slugProblem:d(n.slug_problem)?n.slug_problem:null}}function B(e){return e.slugAvailable?{state:"available"}:e.slugProblem?{state:"problem",problem:e.slugProblem}:{state:"unknown"}}function K(e){const n=e&&typeof e=="object"?e:{};return{slug:s(n.slug),expiresAt:s(n.expires_at)}}function M(e,n,r){return{business_name:e.company.trim(),slug:m(e.slug),first_name:e.firstName.trim(),last_name:e.lastName.trim(),email:e.email.trim(),...n?{product:n}:{},...r&&e.country?{country:e.country}:{},...r&&e.currency?{currency:e.currency}:{}}}function Y(e,n){const r={};e.firstName.trim()||(r.firstName=t.required);const o=e.email.trim();o?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)||(r.email=t.emailWrong):r.email=t.required;const i=e.company.trim();return i?i.length<2&&(r.company=t.companyShort):r.company=t.required,m(e.slug)?n.state==="problem"&&(r.slug=t.slugProblem[n.problem]):r.slug=t.required,r}const T={business_name:"company",slug:"slug",first_name:"firstName",last_name:"lastName",email:"email",country:"country",currency:"currency"},u={self_sign_up_off:"closed",sign_up_daily_limit:"dailyLimit",sign_up_unavailable:"unavailable",sign_up_plan_missing:"unavailable"};function H(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},o=r.code;if(d(o))return{fields:{slug:t.slugProblem[o]},trouble:null};if(typeof o=="string"&&u[o])return{fields:{},trouble:u[o]};if(e===0)return{fields:{},trouble:"unreachable"};if(e===429)return{fields:{},trouble:"tooMany"};if(e===400){const i={};for(const l of Object.keys(r)){const a=T[l];a&&(i[a]=a==="slug"?t.slugProblem.slug_malformed:a==="email"?t.emailWrong:a==="country"||a==="currency"?t.notOffered:t.wrong)}if(Object.keys(i).length)return{fields:i,trouble:null}}return{fields:{},trouble:"failed"}}function g(e,n){try{const r=new Intl.DisplayNames(n?[n]:void 0,{type:e,fallback:"code"});return o=>r.of(o)??o}catch{return r=>r}}const f=(e,n)=>n&&!e.includes(n)?[...e,n]:[...e],x=(e,n)=>{const r=new Intl.Collator(n);return e.sort((o,i)=>r.compare(o.label,i.label))};function q(e,n){const r=g("region",n);return x(f(y,e).map(o=>({value:o,label:r(o)})),n)}function G(e,n){const r=g("currency",n);return f(b,e).sort().map(o=>{const i=r(o);return{value:o,label:i===o?o:`${o} · ${i}`}})}function z(e,n,r){const o=k(r??"");return!e||Number.isNaN(new Date(e).getTime())||!o?"":h(e,{locale:n||w(),timeZone:o,style:A})}const A={weekday:"long",day:"numeric",month:"long"},S=/^\/sign-up\/verify\/([^/?#]+)\/?$/;function Z(e){const n=S.exec(e??"");if(!n)return"";try{return decodeURIComponent(n[1])}catch{return n[1]}}const V="/api/business-sign-ups/verifications/",N=["pending","provisioning","ready","failed"];function J(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},o=s(r.code),i=s(r.slug);if(e===202||o==="sign_up_already_verified"){const l=s(r.provisioning_status),a=s(r.business_name);return N.includes(l)?l==="ready"?{kind:"ready",company:a,slug:i}:l==="failed"?{kind:"failed",company:a,slug:i}:{kind:"building",company:a,slug:i,status:l}:{kind:"gone"}}return d(o)?{kind:"taken",slug:i}:o==="sign_up_daily_limit"?{kind:"dailyLimit"}:o==="self_sign_up_off"?{kind:"closed"}:o&&u[o]?{kind:"trouble",trouble:u[o]}:e===400&&"token"in r?{kind:"gone"}:e===0?{kind:"trouble",trouble:"unreachable"}:e===429?{kind:"trouble",trouble:"tooMany"}:{kind:"trouble",trouble:"failed"}}function Q(e){return e.kind==="building"||e.kind==="trouble"&&e.trouble!=="failed"}function X(e){return e<5?2e3:e<20?5e3:15e3}const ee=40;function ne(e,n,r){const o=e.kind==="failed"?"stopped":"running";return[{words:c.confirmed,at:"done"},{words:p(c.reserved,{address:`${e.slug}${r}`}),at:"done"},{words:c.building,at:o},...e.kind==="failed"?[]:[{words:p(c.adding,{name:n}),at:"waiting"}]]}const re=e=>e==="pending"?50:75,c={settingUp:"Setting up {company}",confirmed:"Email confirmed",reserved:"Address reserved: {address}",building:"Building your workspace",adding:"Adding {name}",aboutTen:"This takes about 10 seconds. You can close this page: we'll email you when it's ready.",readyTitle:"Your workspace is ready",workspace:"Workspace",address:"Address",plan:"Plan",planName:"{name} Free",readyNext:"We've emailed you a link to set your password. It's the next step.",failedBody:"We couldn't finish building your workspace. We've been told, and we'll email you when it's ready. You don't need to sign up again.",goneTitle:"This link has run out",goneBody:"This link is not right, or it has run out. Sign up again and we'll send a new one.",again:"Sign up again",takenTitle:"That address has gone",takenBody:"{address} was taken before you opened your link. Choose another address and we'll send a new link.",takenBodyBare:"That address was taken before you opened your link. Choose another address and we'll send a new link.",chooseAnother:"Choose another address",limitTitle:"Not today",limitNext:"Your link still works until it runs out. Open it again tomorrow.",checking:"Checking your link"},oe="/api/business-sign-ups/workspace-finds/",ie="/api/business-sign-ups/workspace-finds/openings/",v=/^\/find\/([^/?#]+)\/?$/;function te(e){const n=v.exec(e??"");if(!n)return"";try{return decodeURIComponent(n[1])}catch{return n[1]}}const ae={title:"Find your workspace",intro:"Enter your work email. We'll send you the address of every workspace you belong to.",submit:"Email me my workspaces",newHere:"New to {name}?",create:"Create a workspace",sentTitle:"Check your email",sentBody:"If {email} belongs to a workspace, the links are on their way.",sentNote:"They work for 30 minutes. Nothing arrives if the address isn't in any workspace.",another:"Use another email",linkGone:"This link is not right, or it has run out. Ask for your workspaces again.",opening:"Opening your workspace"};function se(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{};return r.code==="workspace_find_unavailable"?{email:null,trouble:"unavailable"}:e===400&&"email"in r?{email:t.emailWrong,trouble:null}:e===0?{email:null,trouble:"unreachable"}:e===429?{email:null,trouble:"tooMany"}:{email:null,trouble:"failed"}}function le(e){const n=e&&typeof e=="object"?s(e.sign_in_url):"";return/^https?:\/\/[^\s]+$/i.test(n)?n:""}export{W as CHECK_AFTER_MS,L as EMPTY_DRAFT,ae as FIND_WORDS,ee as LINK_ASKS_AT_MOST,c as LINK_WORDS,R as SIGN_UP_PATH,V as SIGN_UP_VERIFY_PATH,D as SIGN_UP_WAITING_PATH,t as SIGN_UP_WORDS,_ as SLUG_PROBLEMS,oe as WORKSPACE_FINDS_PATH,ie as WORKSPACE_FIND_OPEN_PATH,U as addressSuffix,re as buildProgress,ne as buildSteps,Y as checkDraft,j as checkWaitingEmail,q as countryChoices,G as currencyChoices,p as fill,te as findTokenOf,d as isSlugProblem,X as linkAskAfterMs,Q as linkAsksAgain,z as linkEnds,Z as linkTokenOf,m as normaliseSlug,se as readFindRefusal,J as readLinkAnswer,$ as readSignUpAvailability,H as readSignUpRefusal,K as readSignUpSent,F as readWaitingRefusal,le as signInUrlOf,E as signUpAvailabilityPath,M as signUpBody,B as slugCheckOf,O as slugFromName};
|
|
1
|
+
import{COUNTRY_CODES as y,CURRENCY_CODES as b}from"./sign-up-catalogue.js";import{formatDateTime as h}from"efficient-shell/format";import{firstReadableZone as k,runtimeLocale as w}from"../zone.js";const I={firstName:"",lastName:"",email:"",company:"",slug:"",country:"",currency:""},_=["slug_malformed","slug_reserved","slug_taken"],d=e=>typeof e=="string"&&_.includes(e),L=400,t={title:"Create your {name} workspace",freeLine:"Free to start. No card needed.",firstName:"First name",lastName:"Last name",email:"Work email",company:"Company name",address:"Workspace address",country:"Country",currency:"Currency",countryHint:"Your shop sells in this currency. The country sets its tax and shipping defaults. Both can be changed later.",checking:"Checking",available:"Available",submit:"Create workspace",sending:"Sending…",agree:"By creating a workspace you agree to the {terms} and {privacy}.",terms:"Terms",privacy:"Privacy Policy",haveOne:"Already have a workspace?",find:"Find my workspace",required:"Fill this in.",companyShort:"Use at least 2 characters.",emailWrong:"Enter an email address, like name@company.com.",notOffered:"That choice is not offered. Pick another.",wrong:"Check this and try again.",slugProblem:{slug_malformed:"Use 3 to 30 lower-case letters, digits or single hyphens, starting with a letter.",slug_reserved:"That address is kept for the platform. Choose another.",slug_taken:"That address is taken. Choose another."},trouble:{closed:"Signing up is closed just now.",dailyLimit:"Too many workspaces signed up today. Try again tomorrow.",unavailable:"Signing up is not available just now. Try again later.",tooMany:"You have asked a few times in a row. Wait a minute, then try again.",unreachable:"We couldn't reach the server. Check your connection and try again.",failed:"Something went wrong and nothing was sent. Try again."},closedTitle:"Signing up is closed just now",closedBody:"New {name} workspaces cannot be made just now.",closedLeave:"Leave your email and we'll tell you when it opens.",tellMe:"Tell me when it opens",waitingDone:"Thanks. We'll email {email} when sign-up opens.",sentTitle:"Check your email",sentBody:"We sent a link to {email}. Open it to set up {company}.",sentUntil:"The link works once, until {when}. Asking again sends a new link, and the old one stops working.",sendAgain:"Send it again",sendingAgain:"Sending…",sentAgain:"A new link is on its way. The old one no longer works.",change:"Change the details"};function p(e,n){return e.replace(/\{(\w+)\}/g,(r,o)=>n[o]??r)}function m(e){return e.trim().toLowerCase().replace(/_/g,"-")}function O(e){return e.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).join("-").replace(/^[^a-z]+/,"").slice(0,30).replace(/-+$/,"")}function U(e,n){const r=(e??"").trim().toLowerCase().replace(/^\.+/,"").replace(/\.+$/,"");if(r)return`.${r}`;const o=n.toLowerCase().replace(/\.$/,"").replace(/^www\./,"");return o?`.${o}`:""}const s=e=>typeof e=="string"?e:"";function F(e,n){const r=new URLSearchParams;n&&r.set("slug",n),e&&r.set("product",e);const o=r.toString();return`/api/business-sign-ups/availability/${o?`?${o}`:""}`}const E="/api/business-sign-ups/",R="/api/business-sign-ups/waiting-list/";function D(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{};return r.code==="sign_up_open"?{open:!0,email:null,trouble:null}:r.code==="sign_up_waiting_list_unavailable"?{open:!1,email:null,trouble:"unavailable"}:e===400&&"email"in r?{open:!1,email:t.emailWrong,trouble:null}:e===0?{open:!1,email:null,trouble:"unreachable"}:e===429?{open:!1,email:null,trouble:"tooMany"}:{open:!1,email:null,trouble:"failed"}}function j(e){const n=e.trim();return n?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?null:t.emailWrong:t.required}function $(e){const n=e&&typeof e=="object"?e:{};return{open:n.open===!0,country:s(n.country),currency:s(n.currency),slugAvailable:typeof n.slug_available=="boolean"?n.slug_available:null,slugProblem:d(n.slug_problem)?n.slug_problem:null}}function B(e){return e.slugAvailable?{state:"available"}:e.slugProblem?{state:"problem",problem:e.slugProblem}:{state:"unknown"}}function M(e){const n=e&&typeof e=="object"?e:{};return{slug:s(n.slug),expiresAt:s(n.expires_at)}}function Y(e,n,r){return{business_name:e.company.trim(),slug:m(e.slug),first_name:e.firstName.trim(),last_name:e.lastName.trim(),email:e.email.trim(),...n?{product:n}:{},...r&&e.country?{country:e.country}:{},...r&&e.currency?{currency:e.currency}:{}}}function K(e,n){const r={};e.firstName.trim()||(r.firstName=t.required);const o=e.email.trim();o?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)||(r.email=t.emailWrong):r.email=t.required;const i=e.company.trim();return i?i.length<2&&(r.company=t.companyShort):r.company=t.required,m(e.slug)?n.state==="problem"&&(r.slug=t.slugProblem[n.problem]):r.slug=t.required,r}const T={business_name:"company",slug:"slug",first_name:"firstName",last_name:"lastName",email:"email",country:"country",currency:"currency"},u={self_sign_up_off:"closed",sign_up_daily_limit:"dailyLimit",sign_up_unavailable:"unavailable",sign_up_plan_missing:"unavailable"};function H(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},o=r.code;if(d(o))return{fields:{slug:t.slugProblem[o]},trouble:null};if(typeof o=="string"&&u[o])return{fields:{},trouble:u[o]};if(e===0)return{fields:{},trouble:"unreachable"};if(e===429)return{fields:{},trouble:"tooMany"};if(e===400){const i={};for(const l of Object.keys(r)){const a=T[l];a&&(i[a]=a==="slug"?t.slugProblem.slug_malformed:a==="email"?t.emailWrong:a==="country"||a==="currency"?t.notOffered:t.wrong)}if(Object.keys(i).length)return{fields:i,trouble:null}}return{fields:{},trouble:"failed"}}function g(e,n){try{const r=new Intl.DisplayNames(n?[n]:void 0,{type:e,fallback:"code"});return o=>r.of(o)??o}catch{return r=>r}}const f=(e,n)=>n&&!e.includes(n)?[...e,n]:[...e],x=(e,n)=>{const r=new Intl.Collator(n);return e.sort((o,i)=>r.compare(o.label,i.label))};function q(e,n){const r=g("region",n);return x(f(y,e).map(o=>({value:o,label:r(o)})),n)}function G(e,n){const r=g("currency",n);return f(b,e).sort().map(o=>{const i=r(o);return{value:o,label:i===o?o:`${o} · ${i}`}})}function z(e,n,r){const o=k(r??"");return!e||Number.isNaN(new Date(e).getTime())||!o?"":h(e,{locale:n||w(),timeZone:o,style:A})}const A={weekday:"long",day:"numeric",month:"long"},S=/^\/sign-up\/verify\/([^/?#]+)\/?$/;function Z(e){const n=S.exec(e??"");if(!n)return"";try{return decodeURIComponent(n[1])}catch{return n[1]}}const V="/api/business-sign-ups/verifications/",N=["pending","provisioning","ready","failed"];function J(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},o=s(r.code),i=s(r.slug);if(e===202||o==="sign_up_already_verified"){const l=s(r.provisioning_status),a=s(r.business_name);return N.includes(l)?l==="ready"?{kind:"ready",company:a,slug:i}:l==="failed"?{kind:"failed",company:a,slug:i}:{kind:"building",company:a,slug:i,status:l}:{kind:"gone"}}return d(o)?{kind:"taken",slug:i}:o==="sign_up_daily_limit"?{kind:"dailyLimit"}:o==="self_sign_up_off"?{kind:"closed"}:o&&u[o]?{kind:"trouble",trouble:u[o]}:e===400&&"token"in r?{kind:"gone"}:e===0?{kind:"trouble",trouble:"unreachable"}:e===429?{kind:"trouble",trouble:"tooMany"}:{kind:"trouble",trouble:"failed"}}function Q(e){return e.kind==="building"||e.kind==="trouble"&&e.trouble!=="failed"}function X(e){return e<5?2e3:e<20?5e3:15e3}const ee=40;function ne(e,n,r){const o=e.kind==="failed"?"stopped":"running";return[{words:c.confirmed,at:"done"},{words:p(c.reserved,{address:`${e.slug}${r}`}),at:"done"},{words:c.building,at:o},...e.kind==="failed"?[]:[{words:p(c.adding,{name:n}),at:"waiting"}]]}const re=e=>e==="pending"?50:75,c={settingUp:"Setting up {company}",confirmed:"Email confirmed",reserved:"Address reserved: {address}",building:"Building your workspace",adding:"Adding {name}",aboutTen:"This takes about 10 seconds. You can close this page: we'll email you when it's ready.",readyTitle:"Your workspace is ready",workspace:"Workspace",address:"Address",plan:"Plan",planName:"{name} Free",readyNext:"We've emailed you a link to set your password. It's the next step.",failedBody:"We couldn't finish building your workspace. We've been told, and we'll email you when it's ready. You don't need to sign up again.",goneTitle:"This link has run out",goneBody:"This link is not right, or it has run out. Sign up again and we'll send a new one.",again:"Sign up again",takenTitle:"That address has gone",takenBody:"{address} was taken before you opened your link. Choose another address and we'll send a new link.",takenBodyBare:"That address was taken before you opened your link. Choose another address and we'll send a new link.",chooseAnother:"Choose another address",limitTitle:"Not today",limitNext:"Your link still works until it runs out. Open it again tomorrow.",checking:"Checking your link"},oe="/api/business-sign-ups/workspace-finds/",ie="/api/business-sign-ups/workspace-finds/openings/",v=/^\/find\/([^/?#]+)\/?$/;function te(e){const n=v.exec(e??"");if(!n)return"";try{return decodeURIComponent(n[1])}catch{return n[1]}}const ae={title:"Find your workspace",intro:"Enter your work email. We'll send you the address of every workspace you belong to.",submit:"Email me my workspaces",newHere:"New to {name}?",create:"Create a workspace",sentTitle:"Check your email",sentBody:"If {email} belongs to a workspace, the links are on their way.",sentNote:"They work for 30 minutes. Nothing arrives if the address isn't in any workspace.",another:"Use another email",linkGone:"This link is not right, or it has run out. Ask for your workspaces again.",opening:"Opening your workspace",openFailed:"We couldn't open your workspace just now. Your link still works — try again.",retry:"Try again"};function se(e){return e===0?"unreachable":e===429?"tooMany":"failed"}function le(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{};return r.code==="workspace_find_unavailable"?{email:null,trouble:"unavailable"}:e===400&&"email"in r?{email:t.emailWrong,trouble:null}:e===0?{email:null,trouble:"unreachable"}:e===429?{email:null,trouble:"tooMany"}:{email:null,trouble:"failed"}}function ue(e){const n=e&&typeof e=="object"?s(e.sign_in_url):"";return/^https?:\/\/[^\s]+$/i.test(n)?n:""}export{L as CHECK_AFTER_MS,I as EMPTY_DRAFT,ae as FIND_WORDS,ee as LINK_ASKS_AT_MOST,c as LINK_WORDS,E as SIGN_UP_PATH,V as SIGN_UP_VERIFY_PATH,R as SIGN_UP_WAITING_PATH,t as SIGN_UP_WORDS,_ as SLUG_PROBLEMS,oe as WORKSPACE_FINDS_PATH,ie as WORKSPACE_FIND_OPEN_PATH,U as addressSuffix,re as buildProgress,ne as buildSteps,K as checkDraft,j as checkWaitingEmail,q as countryChoices,G as currencyChoices,p as fill,te as findTokenOf,d as isSlugProblem,X as linkAskAfterMs,Q as linkAsksAgain,z as linkEnds,Z as linkTokenOf,m as normaliseSlug,se as readFindOpenTrouble,le as readFindRefusal,J as readLinkAnswer,$ as readSignUpAvailability,H as readSignUpRefusal,M as readSignUpSent,D as readWaitingRefusal,ue as signInUrlOf,F as signUpAvailabilityPath,Y as signUpBody,B as slugCheckOf,O as slugFromName};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "efficient-storefront-blocks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.119.1",
|
|
4
4
|
"description": "The EFFICIENT storefront's website editor — the website builder assembled with the storefront's own sections — for an app that edits a storefront website inside its own page. Built from the efficient-storefront-blocks repository.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Efficient Pty Ltd",
|