efficient-web-builder 0.7.0 → 0.8.0
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 +75 -0
- package/README.md +26 -0
- package/dist/chunks/EditorPreviewCheckout-RALICX2M.js +4 -0
- package/dist/chunks/PreviewFooter-TTWVSN7F.js +1 -0
- package/dist/chunks/SectionEditorShell-QHF74BM4.js +1 -0
- package/dist/chunks/SiteEditorProvider-4NZYBEVE.js +1 -0
- package/dist/chunks/StorefrontEditorChrome-VAFMI23Y.js +1 -0
- package/dist/chunks/{chunk-IVOJJ6LW.js → chunk-23HYGLAH.js} +1 -1
- package/dist/chunks/chunk-2Z43RC3L.js +143 -0
- package/dist/chunks/chunk-4MT74TMP.js +1 -0
- package/dist/chunks/{chunk-K3Y6UBLO.js → chunk-5WIA75VU.js} +1 -1
- package/dist/chunks/chunk-764WH3TY.js +11 -0
- package/dist/chunks/chunk-DN65SLZM.js +1 -0
- package/dist/chunks/chunk-FEL3RPX5.js +230 -0
- package/dist/chunks/chunk-KZIT3J33.js +1 -0
- package/dist/chunks/chunk-X2DL3VCU.js +15 -0
- package/dist/chunks/chunk-XMRSKZIR.js +2 -0
- package/dist/chunks/{fitment-data-ZLYB5QPR.js → fitment-data-6EHBA26C.js} +1 -1
- package/dist/chunks/render-client-3H6QYWG7.js +1 -0
- package/dist/editor.css +1 -1
- package/dist/index.js +318 -213
- package/dist/links.d.ts +86 -0
- package/dist/links.js +1 -0
- package/package.json +9 -2
- package/dist/chunks/EditorPreviewCheckout-UMTU2FL4.js +0 -4
- package/dist/chunks/PreviewFooter-3TQMFRPZ.js +0 -1
- package/dist/chunks/SectionEditorShell-FZIT2REV.js +0 -1
- package/dist/chunks/SiteEditorProvider-FHKVGA4K.js +0 -1
- package/dist/chunks/StorefrontEditorChrome-MYOIHQ5J.js +0 -1
- package/dist/chunks/chunk-4G3T6ZD2.js +0 -1
- package/dist/chunks/chunk-4KLEZTLW.js +0 -11
- package/dist/chunks/chunk-KR3FTVDW.js +0 -2
- package/dist/chunks/chunk-N35EG6RF.js +0 -143
- package/dist/chunks/chunk-RF5DTRJ5.js +0 -1
- package/dist/chunks/chunk-UTFM4DGR.js +0 -15
- package/dist/chunks/chunk-WMFQNAWF.js +0 -11
- package/dist/chunks/chunk-X6KEAC34.js +0 -1
- package/dist/chunks/render-client-A75K43T5.js +0 -1
- /package/dist/chunks/{chunk-N35EG6RF.js.LEGAL.txt → chunk-2Z43RC3L.js.LEGAL.txt} +0 -0
- /package/dist/chunks/{chunk-UTFM4DGR.js.LEGAL.txt → chunk-X2DL3VCU.js.LEGAL.txt} +0 -0
package/dist/links.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public types of `efficient-web-builder/links` (published as dist/links.d.ts).
|
|
3
|
+
*
|
|
4
|
+
* Written out, like `contract.public.d.ts`, and kept honest the same way:
|
|
5
|
+
* `types.check.ts` pairs each declaration with the code it describes.
|
|
6
|
+
*
|
|
7
|
+
* This entry is plain data and pure functions. It imports nothing, so a host
|
|
8
|
+
* can load it beside its own UI without the editor.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** What a link is. */
|
|
12
|
+
export type LinkKind = "page" | "anchor" | "blog" | "product" | "custom";
|
|
13
|
+
|
|
14
|
+
/** The kinds, in menu order. `needs` names the block set a kind's targets come
|
|
15
|
+
* from; a kind without it is offered everywhere. */
|
|
16
|
+
export const LINK_KINDS: readonly { value: LinkKind; label: string; needs?: "commerce" | "service" }[];
|
|
17
|
+
|
|
18
|
+
/** The kinds a host lists, given whether it offers products and services. */
|
|
19
|
+
export function linkKindsFor(offers: { offersCommerce: boolean; offersService: boolean }): typeof LINK_KINDS;
|
|
20
|
+
|
|
21
|
+
/** A page's path; the Home page (`homepage`) is "/". */
|
|
22
|
+
export function pagePath(slug: string): string;
|
|
23
|
+
/** A blog post's path: `/journal/<slug>`. */
|
|
24
|
+
export function postPath(slug: string): string;
|
|
25
|
+
/** A product's path: `/wheels/<slug>`. */
|
|
26
|
+
export function wheelPath(slug: string): string;
|
|
27
|
+
/** A section anchor on a page: the page's path and `#<hash>`. */
|
|
28
|
+
export function anchorPath(pageSlug: string, hash: string): string;
|
|
29
|
+
/** Anchor name → URL hash id, exactly as the page renders it. */
|
|
30
|
+
export function slugifyAnchor(name: string): string;
|
|
31
|
+
/** The section anchors across a page's documents (published, then draft), in
|
|
32
|
+
* order, each slug once. */
|
|
33
|
+
export function pageAnchors(...docs: unknown[]): { slug: string; name: string }[];
|
|
34
|
+
|
|
35
|
+
/** The built-in listing route every site answers on: "/wheels". */
|
|
36
|
+
export const BUILT_IN_LISTING_PATH: "/wheels";
|
|
37
|
+
/** What the Page list calls the listing page: "Products". */
|
|
38
|
+
export const LISTING_PAGE_LABEL: "Products";
|
|
39
|
+
/** The Page list's name for a listing page; "Products · <page>" when a site has several. */
|
|
40
|
+
export function listingPageLabel(pageTitle: string, listingCount: number): string;
|
|
41
|
+
/** The listing section's props on a page (published document first), or null. */
|
|
42
|
+
export function listingNode(...docs: unknown[]): Record<string, unknown> | null;
|
|
43
|
+
/** Does this page hold the listing? */
|
|
44
|
+
export function isProductListingPage(...docs: unknown[]): boolean;
|
|
45
|
+
/** Every listing page's path; with none and `fallback`, the built-in route. */
|
|
46
|
+
export function productListingPaths(
|
|
47
|
+
pages: readonly { slug: string; docs: readonly unknown[] }[],
|
|
48
|
+
opts: { fallback: boolean },
|
|
49
|
+
): string[];
|
|
50
|
+
|
|
51
|
+
/** Every param a listing link may carry: `type`, then the listing's facets
|
|
52
|
+
* except tyre size. */
|
|
53
|
+
export const LISTING_FILTER_PARAMS: readonly string[];
|
|
54
|
+
/** One filter on a listing link, or none. */
|
|
55
|
+
export type ListingFilter = { param: string; value: string } | null;
|
|
56
|
+
/** The filter a saved link opens the listing on (the type first), or null. */
|
|
57
|
+
export function readListingFilter(url: string): ListingFilter;
|
|
58
|
+
/** Write or clear the filter: every listing param cleared first, the rest kept,
|
|
59
|
+
* a space written as `%20`. */
|
|
60
|
+
export function withListingFilter(url: string, filter: ListingFilter): string;
|
|
61
|
+
/** The listing page a link points at with its filter off — only when that is a
|
|
62
|
+
* listing page; any other link comes back as it is. */
|
|
63
|
+
export function listingTarget(url: string, listingPaths: readonly string[]): string;
|
|
64
|
+
|
|
65
|
+
/** A saved URL → its kind. A listing link with its filter reads as a Page. */
|
|
66
|
+
export function inferLinkKind(url: string, pagePaths: readonly string[], listingPaths?: readonly string[]): LinkKind;
|
|
67
|
+
|
|
68
|
+
/** May this typed address be saved? `/…`, `#…`, http(s), mailto: or tel:. */
|
|
69
|
+
export function isSafeLink(url: string): boolean;
|
|
70
|
+
|
|
71
|
+
/** The Filter list's name for the product type: "Product type". */
|
|
72
|
+
export const PRODUCT_TYPE_FILTER_LABEL: "Product type";
|
|
73
|
+
export type LinkFilterValue = { value: string; label: string };
|
|
74
|
+
export type LinkFilterField = { param: string; label: string; values: LinkFilterValue[] };
|
|
75
|
+
/** One Product Types answer, as much as the filter list reads. */
|
|
76
|
+
export type LinkFieldUsage = {
|
|
77
|
+
kind?: string;
|
|
78
|
+
fieldKey: string;
|
|
79
|
+
filter?: boolean;
|
|
80
|
+
filterOrder?: number | null;
|
|
81
|
+
};
|
|
82
|
+
/** The filters a listing link may offer, with the values this catalogue has. */
|
|
83
|
+
export function listingFilterFields(
|
|
84
|
+
catalogue: readonly unknown[],
|
|
85
|
+
opts: { listing: Record<string, unknown> | null; fieldUsage: readonly LinkFieldUsage[] },
|
|
86
|
+
): LinkFilterField[];
|
package/dist/links.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var N=["width","profile","rim"];var ye=/^\s*(\d{2,3})\s*\/\s*(\d{2,3})\s*[A-Za-z]*\s*(\d{2}(?:\.\d+)?)\s*$/,ge={width:[100,500],profile:[20,100],rim:[10,30]};function x(e){let n=ye.exec(e??"");if(!n)return null;let t={width:Number(n[1]),profile:Number(n[2]),rim:Number(n[3])};return N.every(o=>{let[l,u]=ge[o];return t[o]>=l&&t[o]<=u})?t:null}function h(e){if(e.width==null)return"";if(e.profile==null)return String(e.width);let n=`${e.width}/${e.profile}`;return e.rim==null?n:`${n} R${e.rim}`}function O(e){return[h({width:e.width}),h({width:e.width,profile:e.profile}),h(e)]}var g=["alloy-wheel","tyre"],z=["alloy-wheel"],S={"alloy-wheel":"Alloy wheels",tyre:"Tyres"};var qe=g.map(e=>({value:e,label:S[e]}));function w(e){return e==null?[...z]:Array.isArray(e)?g.filter(n=>e.includes(n)):[...z]}var d=e=>e;function c(e){return d(e).kind==="tyre"?"tyre":"alloy-wheel"}function T(e){return d(e).brand??""}function D(e){return d(e).prices??void 0}function U(e){return d(e).inStock!==!1}function M(e){let n=d(e),t=c(e)==="tyre"?n.rimDiameters:n.sizes;return Array.isArray(t)?t.filter(r=>typeof r=="number"&&Number.isFinite(r)):[]}function F(e){return c(e)==="tyre"?[]:(d(e).finishes??[]).filter(n=>typeof n?.family=="string").map(n=>({family:n.family,color:n.color??null}))}function v(e){return F(e).map(n=>n.family)}function B(e){if(c(e)==="tyre")return[];let n=d(e),t=n.categories;return t&&t.length>0?t:n.process?[n.process]:[]}function $(e){return c(e)==="tyre"?[]:d(e).spec?.pcds??[]}function W(e){return c(e)!=="tyre"?[]:d(e).tyreTypes??[]}function Y(e){return c(e)!=="tyre"?[]:d(e).speedRatings??[]}function G(e){if(c(e)!=="tyre")return[];let n=d(e).sizes;return Array.isArray(n)?n.map(t=>x(typeof t=="string"?t:null)).filter(t=>t!==null):[]}var H="homepage";function q(e){return(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function L(e,n){return e.length===0?e:e.filter(t=>t.kind===void 0||t.kind===n)}function j(e,n){let t=n==="filter"?"filterOrder":"cardOrder",r=new Map;for(let o of e){let l=o[t];if(typeof l!="number"||!Number.isFinite(l))continue;let u=r.get(o.fieldKey);(u===void 0||l<u)&&r.set(o.fieldKey,l)}return o=>o?r.get(o):void 0}function V(e,n,t,r){let o=new Map;for(let s of t){let i=s[r];typeof i=="number"&&o.set(s.fieldKey,i)}if(o.size===0)return e;let l=[],u=[];e.forEach((s,i)=>{let m=n(s);m&&(l.push(i),u.push({item:s,index:i,order:o.get(m)}))}),u.sort((s,i)=>s.order!==void 0&&i.order!==void 0?s.order-i.order||s.index-i.index:s.order!==void 0?-1:i.order!==void 0?1:s.index-i.index);let p=[...e];return l.forEach((s,i)=>{p[s]=u[i].item}),p.every((s,i)=>s===e[i])?e:p}function Z(e){return he(e,"filter")}var Pe="collection";function _(e,n){return{tyreSizes:{},brands:{"alloy-wheel":"brand",tyre:"brand"},finishes:{"alloy-wheel":"wheel_finish_ref"},diameters:{"alloy-wheel":"diameter",tyre:"rim_diameter"},collections:{"alloy-wheel":Pe},pcds:{"alloy-wheel":"pcd"},tyreTypes:{tyre:"tire_type"},speedRatings:{tyre:"speed_rating"}}[e]?.[n]}function he(e,n){let t=new Set(e.filter(r=>r[n]===!1).map(r=>r.fieldKey));return r=>!r||!t.has(r)}function Se(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function X(e,n){let t=e?.[n];return Se(t)?t:null}function Q(e,n,t,r){if(t==null&&r==null)return!0;let o=X(e,n);return!(o===null||t!=null&&o<t||r!=null&&o>r)}var be={recommended:"Recommended","price-asc":"Price \xB7 low to high","price-desc":"Price \xB7 high to low",new:"Newest",name:"Name A\u2013Z"},bn=Object.keys(be);var J=["tyreSizes","brands","finishes","diameters","collections","pcds","tyreTypes","speedRatings"],xe={tyreSizes:["tyre"],brands:["alloy-wheel","tyre"],finishes:["alloy-wheel"],diameters:["alloy-wheel","tyre"],collections:["alloy-wheel"],pcds:["alloy-wheel"],tyreTypes:["tyre"],speedRatings:["tyre"]},we={diameters:"tyreSizes"};function Te(e){if(e.length===0)return[];let n=J.filter(t=>e.every(r=>xe[t].includes(r)));return n.filter(t=>{let r=we[t];return!r||!n.includes(r)})}function Fe(e){let n=new Set;for(let t of e)n.add(c(t));return[...n]}var ee={tyreSizes:[],brands:[],finishes:[],diameters:[],collections:[],pcds:[],tyreTypes:[],speedRatings:[],priceMax:null,inStockOnly:!1,kind:null,sort:"recommended",page:1};function Le(e,n,t,r=null){if(r!=="kind"&&n.kind&&c(e)!==n.kind)return!1;for(let o of J){if(r===o)continue;let l=n[o];if(l.length===0)continue;let u=l.map(String);if(!ne(e,o).some(p=>u.includes(p)))return!1}return!(r!=="price"&&!Q(D(e),t,null,n.priceMax)||r!=="inStock"&&n.inStockOnly&&!U(e))}var _e={tyreSizes:"Size",brands:"Brand",finishes:"Colour",diameters:"Size \xB7 diameter",collections:"Collection",pcds:"PCD \xB7 fitment",tyreTypes:"Tyre type",speedRatings:"Speed rating"};function ne(e,n){switch(n){case"tyreSizes":return[...new Set(G(e).flatMap(O))];case"brands":return T(e)?[T(e)]:[];case"finishes":return v(e);case"diameters":return M(e).map(String);case"collections":return B(e);case"pcds":return $(e);case"tyreTypes":return W(e);case"speedRatings":return Y(e)}}function Ae(e){let n=new Map;for(let t of e)for(let r of F(t))r.color&&!n.has(r.family)&&n.set(r.family,r.color);return n}function te(e,n,t,r=Fe(e),o=[]){let l=i=>ke(i,r,o),u=Ae(e),p=Te(r).filter(i=>i!=="tyreSizes").filter(l).map(i=>{let m=n[i].map(String),C=new Set,b=new Map,P=new Map;for(let a of e){let y=ne(a,i);for(let f of y)C.add(f);for(let f of new Set(y))P.set(f,(P.get(f)??0)+1);if(Le(a,n,t,i))for(let f of new Set(y))b.set(f,(b.get(f)??0)+1)}let me=[...C].map(a=>({value:a,label:i==="diameters"?`${a}\u2033`:a,count:b.get(a)??0,checked:m.includes(a),swatch:i==="finishes"?u.get(a)??null:null})).sort((a,y)=>{if(i==="diameters")return Number(a.value)-Number(y.value);let f=(P.get(y.value)??0)-(P.get(a.value)??0);return f!==0?f:a.value.localeCompare(y.value)});return{key:i,label:_e[i],options:me}}).filter(i=>i.options.length>Ie),s=[];for(let i of p){let m=Re(i.key,r,o);m!==void 0&&s.push({fieldKey:i.key,filterOrder:m})}return[...V(p,i=>i.key,s,"filterOrder")]}var Ie=1;function re(e){return e.showCollection===!1?["collections"]:[]}function ke(e,n,t){return n.length===0||t.length===0?!0:n.some(r=>Z(L(t,r))(_(e,r)))}function Re(e,n,t){if(t.length===0)return;let r;for(let o of n){let l=j(L(t,o),"filter")(_(e,o));l!==void 0&&(r===void 0||l<r)&&(r=l)}return r}var A={tyreSizes:"tyreSize",brands:"brand",finishes:"colour",diameters:"size",collections:"collection",pcds:"pcd",tyreTypes:"tyreType",speedRatings:"speed"},I="type";var ie="AlloyWheelsListing";var k=[{value:"page",label:"Page"},{value:"anchor",label:"Anchor"},{value:"blog",label:"Blog post",needs:"service"},{value:"product",label:"Product",needs:"commerce"},{value:"custom",label:"Custom URL"}];function Ke(e){return e.offersCommerce&&e.offersService?k:k.filter(n=>!n.needs||(n.needs==="commerce"?e.offersCommerce:e.offersService))}function K(e){return e===H?"/":`/${e}`}function Ee(e){return`/journal/${e}`}function Ce(e){return`/wheels/${e}`}function Ne(e,n){return`${K(e)}#${n}`}function oe(e){return q(e)}function Oe(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.text=="string"?e.text.trim():""}function ze(...e){let n=new Set,t=[];for(let r of e)for(let o of r?.content??[]){let l=Oe(o?.props?.anchor);if(!l)continue;let u=oe(l);!u||n.has(u)||(n.add(u),t.push({slug:u,name:l}))}return t}var se="/wheels",R="Products";function De(e,n){return n>1?`${R} \xB7 ${e}`:R}function le(...e){for(let n of e){let t=(n?.content??[]).find(r=>r?.type===ie);if(t)return t.props??{}}return null}function ue(...e){return le(...e)!==null}function Ue(e,n){let t=e.filter(r=>ue(...r.docs)).map(r=>K(r.slug));return t.length===0&&n.fallback?[se]:t}var E=[I,...Object.entries(A).filter(([e])=>e!=="tyreSizes").map(([,e])=>e)];function ae(e){let n=e.indexOf("#"),t=n===-1?"":e.slice(n),r=n===-1?e:e.slice(0,n),o=r.indexOf("?");return{path:o===-1?r:r.slice(0,o),query:o===-1?"":r.slice(o+1),hash:t}}function Me(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return e}}function ve(e){let n=new URLSearchParams(ae(e).query);for(let t of E){let r=n.get(t);if(r)return{param:t,value:r}}return null}function ce(e,n){let{path:t,query:r,hash:o}=ae(e),l=r.split("&").filter(u=>u&&!E.includes(Me(u.split("=")[0])));return n?.value&&l.push(`${encodeURIComponent(n.param)}=${encodeURIComponent(n.value)}`),`${t}${l.length?`?${l.join("&")}`:""}${o}`}function pe(e,n){let t=ce(e,null);return n.includes(t)?t:e}function Be(e,n,t=[]){if(!e)return"page";if(e.startsWith("/journal/"))return"blog";if(e.startsWith("/wheels/"))return"product";if(e.includes("#")){let r=e.slice(0,e.indexOf("#"));if(r===""||r==="/"||n.includes(r))return"anchor"}return e==="/"||n.includes(e)||t.includes(pe(e,t))?"page":"custom"}var $e=["http","https","mailto","tel"];function We(e){let n=e.trim();if(!n||/\s/.test(n))return!1;let t=/^([a-z][a-z0-9+.-]*):/i.exec(n);return!t||$e.includes(t[1].toLowerCase())}var de="Product type",Ye="AUD";function fe(e,n){let t=n.listing??{},r=w(t.kinds),o=e.filter(s=>r.includes(c(s))),l=re(t),u=te(o,ee,Ye,r,n.fieldUsage).filter(s=>!l.includes(s.key)).map(s=>({param:A[s.key],label:s.label,values:s.options.filter(i=>!i.value.includes(",")).map(i=>({value:i.value,label:i.label}))})).filter(s=>s.values.length>0),p=g.filter(s=>r.includes(s)&&o.some(i=>c(i)===s));return p.length>1&&u.unshift({param:I,label:de,values:p.map(s=>({value:s,label:S[s]}))}),u}function Nn(e,n){return fe(e,n)}export{se as BUILT_IN_LISTING_PATH,k as LINK_KINDS,E as LISTING_FILTER_PARAMS,R as LISTING_PAGE_LABEL,de as PRODUCT_TYPE_FILTER_LABEL,Ne as anchorPath,Be as inferLinkKind,ue as isProductListingPage,We as isSafeLink,Ke as linkKindsFor,Nn as listingFilterFields,le as listingNode,De as listingPageLabel,pe as listingTarget,ze as pageAnchors,K as pagePath,Ee as postPath,Ue as productListingPaths,ve as readListingFilter,oe as slugifyAnchor,Ce as wheelPath,ce as withListingFilter};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "efficient-web-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "The EFFICIENT website builder — the website editor and its sections — for an app that edits a website inside its own page. Built from the efficient-storefront repository's own source.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Efficient Pty Ltd",
|
|
@@ -27,6 +27,11 @@
|
|
|
27
27
|
"import": "./dist/contract.js",
|
|
28
28
|
"default": "./dist/contract.js"
|
|
29
29
|
},
|
|
30
|
+
"./links": {
|
|
31
|
+
"types": "./dist/links.d.ts",
|
|
32
|
+
"import": "./dist/links.js",
|
|
33
|
+
"default": "./dist/links.js"
|
|
34
|
+
},
|
|
30
35
|
"./editor.css": "./dist/editor.css"
|
|
31
36
|
},
|
|
32
37
|
"files": [
|
|
@@ -34,6 +39,8 @@
|
|
|
34
39
|
"dist/index.d.ts",
|
|
35
40
|
"dist/contract.js",
|
|
36
41
|
"dist/contract.d.ts",
|
|
42
|
+
"dist/links.js",
|
|
43
|
+
"dist/links.d.ts",
|
|
37
44
|
"dist/editor.css",
|
|
38
45
|
"dist/chunks",
|
|
39
46
|
"README.md",
|
|
@@ -41,7 +48,7 @@
|
|
|
41
48
|
"LICENSE"
|
|
42
49
|
],
|
|
43
50
|
"peerDependencies": {
|
|
44
|
-
"efficient-easel": "^0.
|
|
51
|
+
"efficient-easel": "^0.99.2",
|
|
45
52
|
"efficient-shell": "^4.131.0",
|
|
46
53
|
"react": ">=19",
|
|
47
54
|
"react-dom": ">=19"
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use client";import{a as Kt,b as Qe,c as $t}from"./chunk-X6KEAC34.js";import{Ob as Ot,Pb as se,Sb as Lt,Tb as Tt,Ub as Ce,Vb as jt,Wb as qt,Xb as Xe,Yb as _t,a as te,b as Rt,gd as Ft,id as Ze,nb as At,nd as Mt,pd as Ut,yc as Dt}from"./chunk-4KLEZTLW.js";import{E as qe,I as de,P as L,t as It,u as ke,v as Y}from"./chunk-RF5DTRJ5.js";import{a as Je,b as tr}from"./chunk-Y6SLVHK3.js";var Yt=Je((Jr,Wt)=>{"use strict";var nr="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";Wt.exports=nr});var Vt=Je((Xr,Ht)=>{"use strict";var rr=Yt();function zt(){}function Bt(){}Bt.resetWarningCache=zt;Ht.exports=function(){function t(a,o,s,l,p,d){if(d!==rr){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}t.isRequired=t;function e(){return t}var n={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:Bt,resetWarningCache:zt};return n.PropTypes=n,n}});var Jt=Je((ea,Gt)=>{"use strict";Gt.exports=Vt()();var Zr,Qr});import{useEffect as $,useMemo as Ye,useRef as ce,useState as g}from"react";var S=tr(Jt(),1);import k from"react";function Xt(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n<e;n++)a[n]=t[n];return a}function ar(t){if(Array.isArray(t))return t}function nn(t,e,n){return(e=ur(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function or(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,o,s,l,p=[],d=!0,u=!1;try{if(s=(n=n.call(t)).next,e!==0)for(;!(d=(a=s.call(n)).done)&&(p.push(a.value),p.length!==e);d=!0);}catch(b){u=!0,o=b}finally{try{if(!d&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(u)throw o}}return p}}function ir(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,a)}return n}function Qt(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Zt(Object(n),!0).forEach(function(a){nn(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Zt(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function sr(t,e){if(t==null)return{};var n,a,o=cr(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(a=0;a<s.length;a++)n=s[a],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}function cr(t,e){if(t==null)return{};var n={};for(var a in t)if({}.hasOwnProperty.call(t,a)){if(e.indexOf(a)!==-1)continue;n[a]=t[a]}return n}function rn(t,e){return ar(t)||or(t,e)||pr(t,e)||ir()}function lr(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,e);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ur(t){var e=lr(t,"string");return typeof e=="symbol"?e:e+""}function et(t){"@babel/helpers - typeof";return et=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},et(t)}function pr(t,e){if(t){if(typeof t=="string")return Xt(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Xt(t,e):void 0}}var T=function(e,n,a){var o=!!a,s=k.useRef(a);k.useEffect(function(){s.current=a},[a]),k.useEffect(function(){if(!o||!e)return function(){};var l=function(){if(s.current)return s.current.apply(s,arguments)};return e.on(n,l),function(){e.off(n,l)}},[o,n,e,s])},tt=function(e){var n=k.useRef(e);return k.useEffect(function(){n.current=e},[e]),n.current},me=function(e){return e!==null&&et(e)==="object"},dr=function(e){return me(e)&&typeof e.then=="function"},mr=function(e){return me(e)&&typeof e.elements=="function"&&typeof e.createToken=="function"&&typeof e.createPaymentMethod=="function"&&typeof e.confirmCardPayment=="function"},en="[object Object]",fr=function t(e,n){if(!me(e)||!me(n))return e===n;var a=Array.isArray(e),o=Array.isArray(n);if(a!==o)return!1;var s=Object.prototype.toString.call(e)===en,l=Object.prototype.toString.call(n)===en;if(s!==l)return!1;if(!s&&!a)return e===n;var p=Object.keys(e),d=Object.keys(n);if(p.length!==d.length)return!1;for(var u={},b=0;b<p.length;b+=1)u[p[b]]=!0;for(var m=0;m<d.length;m+=1)u[d[m]]=!0;var C=Object.keys(u);if(C.length!==p.length)return!1;var y=e,A=n,x=function(G){return t(y[G],A[G])};return C.every(x)},an=function(e,n,a){return me(e)?Object.keys(e).reduce(function(o,s){var l=!me(n)||!fr(e[s],n[s]);return a.includes(s)?(l&&console.warn("Unsupported prop change: options.".concat(s," is not a mutable property.")),o):l?Qt(Qt({},o||{}),{},nn({},s,e[s])):o},null):null},on="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",tn=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:on;if(e===null||mr(e))return e;throw new Error(n)},gr=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:on;if(dr(e))return{tag:"async",stripePromise:Promise.resolve(e).then(function(o){return tn(o,n)})};var a=tn(e,n);return a===null?{tag:"empty"}:{tag:"sync",stripe:a}},yr=function(e){!e||!e._registerWrapper||!e.registerAppInfo||(e._registerWrapper({name:"react-stripe-js",version:"6.7.0"}),e.registerAppInfo({name:"react-stripe-js",version:"6.7.0",url:"https://stripe.com/docs/stripe-js/react"}))},_e=k.createContext(null);_e.displayName="ElementsContext";var sn=function(e,n){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(n," in an <Elements> provider."));return e},rt=function(e){var n=e.stripe,a=e.options,o=e.children,s=k.useMemo(function(){return gr(n)},[n]),l=k.useState(function(){return{stripe:s.tag==="sync"?s.stripe:null,elements:s.tag==="sync"?s.stripe.elements(a):null}}),p=rn(l,2),d=p[0],u=p[1];k.useEffect(function(){var C=!0,y=function(x){u(function(h){return h.stripe?h:{stripe:x,elements:x.elements(a)}})};return s.tag==="async"&&!d.stripe?s.stripePromise.then(function(A){A&&C&&y(A)}):s.tag==="sync"&&!d.stripe&&y(s.stripe),function(){C=!1}},[s,d,a]);var b=tt(n);k.useEffect(function(){b!==null&&b!==n&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[b,n]);var m=tt(a);return k.useEffect(function(){if(d.elements){var C=an(a,m,["clientSecret","fonts"]);C&&d.elements.update(C)}},[a,m,d.elements]),k.useEffect(function(){yr(d.stripe)},[d.stripe]),k.createElement(_e.Provider,{value:d},o)};rt.propTypes={stripe:S.default.any,options:S.default.object};var cn=function(e){var n=k.useContext(_e);return sn(n,e)},ln=function(){var e=cn("calls useElements()"),n=e.elements;return n},hr=function(e){var n=e.children,a=cn("mounts <ElementsConsumer>");return n(a)};hr.propTypes={children:S.default.func.isRequired};var un=k.createContext(null);un.displayName="CheckoutContext";var nt=function(e){var n=k.useContext(un),a=k.useContext(_e);if(n){if(a)throw new Error("You cannot wrap the part of your app that ".concat(e," in both a checkout provider and <Elements> provider."));return n}else return sn(a,e)},vr=["mode"],br=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},E=function(e,n,a){var o="".concat(br(e),"Element"),s=function(u){var b=u.id,m=u.className,C=u.options,y=C===void 0?{}:C,A=u.onBlur,x=u.onFocus,h=u.onReady,G=u.onChange,D=u.onEscape,O=u.onClick,J=u.onLoadError,ne=u.onLoaderStart,re=u.onNetworksChange,Pe=u.onConfirm,ae=u.onCancel,Ne=u.onShippingAddressChange,oe=u.onShippingRateChange,Ee=u.onSavedPaymentMethodRemove,ge=u.onSavedPaymentMethodUpdate,Re=u.onAvailablePaymentMethodsChange,Q=nt("mounts <".concat(o,">")),ee="elements"in Q?Q.elements:null,W="checkoutState"in Q?Q.checkoutState:null,B=W?.type==="success"||W?.type==="loading"?W.sdk:null,ye=k.useState(null),le=rn(ye,2),N=le[0],he=le[1],j=k.useRef(null),ie=k.useRef(null);T(N,"blur",A),T(N,"focus",x),T(N,"escape",D),T(N,"click",O),T(N,"loaderror",J),T(N,"loaderstart",ne),T(N,"networkschange",re),T(N,"confirm",Pe),T(N,"cancel",ae),T(N,"shippingaddresschange",Ne),T(N,"shippingratechange",oe),T(N,"savedpaymentmethodremove",Ee),T(N,"savedpaymentmethodupdate",ge),T(N,"availablepaymentmethodschange",Re),T(N,"change",G);var F;h&&(e==="expressCheckout"?F=h:F=function(){h(N)}),T(N,"ready",F),k.useLayoutEffect(function(){if(j.current===null&&ie.current!==null&&(ee||B)){var w=null;if(B){var H=B,ve=B;switch(e){case"paymentForm":w=ve.createForm(y);break;case"payment":w=H.createPaymentElement(y);break;case"address":if("mode"in y){var be=y.mode,Be=sr(y,vr);if(be==="shipping")w=H.createShippingAddressElement(Be);else if(be==="billing")w=H.createBillingAddressElement(Be);else throw new Error("Invalid options.mode. mode must be 'billing' or 'shipping'.")}else throw new Error("You must supply options.mode. mode must be 'billing' or 'shipping'.");break;case"expressCheckout":w=H.createExpressCheckoutElement(y);break;case"currencySelector":w=B.createCurrencySelectorElement();break;case"taxId":w=H.createTaxIdElement(y);break;case"contactDetails":w=H.createContactDetailsElement();break;default:throw new Error("<".concat(o,"> is not supported inside a checkout provider. Use an <Elements> provider instead."))}}else ee&&(w=ee.create(e,y));j.current=w,he(w),w&&w.mount(ie.current)}},[ee,B,y]);var ue=tt(y);return k.useEffect(function(){if(j.current){var w=an(y,ue,["paymentRequest"]);w&&"update"in j.current&&j.current.update(w)}},[y,ue]),k.useLayoutEffect(function(){return function(){if(j.current&&typeof j.current.destroy=="function")try{j.current.destroy(),j.current=null}catch{}}},[]),k.createElement("div",{id:b,className:m,ref:ie})},l=function(u){nt("mounts <".concat(o,">"));var b=u.id,m=u.className;return k.createElement("div",{id:b,className:m})},p=n?l:s;return p.propTypes={id:S.default.string,className:S.default.string,onChange:S.default.func,onBlur:S.default.func,onFocus:S.default.func,onReady:S.default.func,onEscape:S.default.func,onClick:S.default.func,onLoadError:S.default.func,onLoaderStart:S.default.func,onNetworksChange:S.default.func,onConfirm:S.default.func,onCancel:S.default.func,onShippingAddressChange:S.default.func,onShippingRateChange:S.default.func,onSavedPaymentMethodRemove:S.default.func,onSavedPaymentMethodUpdate:S.default.func,onAvailablePaymentMethodsChange:S.default.func,options:S.default.object},p.displayName=o,p.__elementType=e,p},R=typeof window>"u",xr=k.createContext(null);xr.displayName="EmbeddedCheckoutProviderContext";var pn=function(){var e=nt("calls useStripe()"),n=e.stripe;return n},na=E("auBankAccount",R),ra=E("card",R),aa=E("cardNumber",R),oa=E("cardExpiry",R),ia=E("cardCvc",R),sa=E("currencySelector",R),ca=E("iban",R),dn=E("payment",R),la=E("expressCheckout",R),ua=E("paymentRequestButton",R),pa=E("linkAuthentication",R),da=E("contactDetails",R),ma=E("address",R),fa=E("shippingAddress",R),ga=E("paymentMethodMessaging",R),ya=E("taxId",R),ha=E("issuingCardNumberDisplay",R),va=E("issuingCardCvcDisplay",R),ba=E("issuingCardExpiryDisplay",R),xa=E("issuingCardPinDisplay",R),ka=E("issuingCardCopyButton",R);function Me(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Me=function(e){return typeof e}:Me=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Me(t)}var gn="dahlia",kr=function(e){return e===3?"v3":e},yn="https://js.stripe.com",Cr="".concat(yn,"/").concat(gn,"/stripe.js"),Sr=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,wr=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,mn="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",Pr=function(e){return Sr.test(e)||wr.test(e)},Nr=function(){for(var e=document.querySelectorAll('script[src^="'.concat(yn,'"]')),n=0;n<e.length;n++){var a=e[n];if(Pr(a.src))return a}return null},fn=function(e){var n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",a=document.createElement("script");a.src="".concat(Cr).concat(n);var o=document.head||document.body;if(!o)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return o.appendChild(a),a},Er=function(e,n){!e||!e._registerWrapper||e._registerWrapper({name:"stripe-js",version:"9.9.0",startTime:n})},Se=null,De=null,Fe=null,Rr=function(e){return function(n){e(new Error("Failed to load Stripe.js",{cause:n}))}},Ir=function(e,n){return function(){window.Stripe?e(window.Stripe):n(new Error("Stripe.js not available"))}},Ar=function(e){return Se!==null?Se:(Se=new Promise(function(n,a){if(typeof window>"u"||typeof document>"u"){n(null);return}if(window.Stripe&&e&&console.warn(mn),window.Stripe){n(window.Stripe);return}try{var o=Nr();if(o&&e)console.warn(mn);else if(!o)o=fn(e);else if(o&&Fe!==null&&De!==null){var s;o.removeEventListener("load",Fe),o.removeEventListener("error",De),(s=o.parentNode)===null||s===void 0||s.removeChild(o),o=fn(e)}Fe=Ir(n,a),De=Rr(a),o.addEventListener("load",Fe),o.addEventListener("error",De)}catch(l){a(l);return}}),Se.catch(function(n){return Se=null,Promise.reject(n)}))},Or=function(e,n,a){if(e===null)return null;var o=n[0];if(typeof o!="string")throw new Error("Expected publishable key to be of type string, got type ".concat(Me(o)," instead."));var s=o.match(/^pk_test/),l=kr(e.version),p=gn;s&&l!==p&&console.warn("Stripe.js@".concat(l," was loaded on the page, but @stripe/stripe-js@").concat("9.9.0"," expected Stripe.js@").concat(p,". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));var d=e.apply(void 0,n);return Er(d,a),d},we,hn=!1,vn=function(){return we||(we=Ar(null).catch(function(e){return we=null,Promise.reject(e)}),we)};Promise.resolve().then(function(){return vn()}).catch(function(t){hn||console.warn(t)});var bn=function(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];hn=!0;var o=Date.now();return vn().then(function(s){return Or(s,n,o)})};var Lr="sf:gclid",Tr="sf:fbclid",jr=2160*60*60*1e3;function Cn(){return typeof window<"u"}function xn(t){let e=ke.getItem(t);if(!e)return"";try{let{v:n,t:a}=JSON.parse(e);return!n||typeof a!="number"||Date.now()-a>jr?"":n}catch{return""}}function kn(t){if(!Cn())return"";let e=t.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1"),n=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return n?decodeURIComponent(n[1]):""}function Sn(){if(!Cn())return{};let t=xn(Lr),e=xn(Tr),n=kn("_fbp"),a=kn("_fbc");!a&&e&&(a=`fb.1.${Date.now()}.${e}`);let o={};return t&&(o.gclid=t),e&&(o.fbclid=e),n&&(o.fbp=n),a&&(o.fbc=a),o}var wn="sf:meta-purchases",qr=20;function Nn(){return typeof window>"u"||window.parent!==window}function _r(...t){try{if(Nn()||typeof window.fbq!="function")return;window.fbq(...t)}catch{}}var Pn=new Set;function Dr(t){if(Pn.has(t))return!1;Pn.add(t);try{let e=JSON.parse(ke.getItem(wn)??"[]");if(e.includes(t))return!1;ke.setItem(wn,JSON.stringify([...e,t].slice(-qr)))}catch{}return!0}function Fr(t){return[...new Set(t.filter(Ce).flatMap(e=>e.components.map(n=>n.partNumber)))]}function En(t){let e=t.confirmation;Nn()||!Dr(e.orderNumber)||_r("track","Purchase",{value:Number(e.grandTotal),currency:e.currency,content_type:"product",content_ids:Fr(t.lines)},{eventID:e.orderNumber})}var at="checkout-afterpay-context",Ue="checkout-gocardless-context",ot="checkout-zip-context",Ke="checkout-klarna-context";function Mr({evidence:t,parked:e}){return t?{action:"capture",evidence:t,parked:e}:e?{action:"settle",parked:e}:{action:"ignore"}}function Ur(t,e){let n=t.getItem(e);if(t.removeItem(e),!n)return null;try{return JSON.parse(n)}catch{return null}}var Rn={name:"Afterpay",legParam:"afterpay",legValues:["confirm","cancel"],storageKey:at,evidenceFrom(t,e){return e==="cancel"||(t.get("status")??"").toUpperCase()==="CANCELLED"?null:t.get("orderToken")},requestFrom:t=>({token:t})},In={name:"Zip",legParam:"zip",legValues:["return"],storageKey:ot,evidenceFrom(t){let e=(t.get("result")??"").toLowerCase();return e==="cancelled"||e==="declined"?null:t.get("checkoutId")},requestFrom:t=>({checkoutId:t})};async function it(t,e){let n=new URLSearchParams(e.search),a=n.get(t.legParam);if(!a||!t.legValues.includes(a))return;let o=Ur(e.storage,t.storageKey),s=t.evidenceFrom(n,a);e.scrubQuery();let l=Mr({evidence:s,parked:o});if(l.action!=="ignore"){if(e.page.clearCart(),l.action==="settle"){e.page.note(`The ${t.name} payment was not completed \u2014 our team will follow up on payment.`),e.page.land(l.parked.confirmation);return}e.page.setConfirming(!0);try{let p=await e.capture(t.requestFrom(l.evidence));p.status==="paid"?e.page.markPaid():e.page.note(`${t.name} declined the payment \u2014 our team will follow up on payment.`),e.page.land(l.parked?.confirmation??p)}catch{l.parked?(e.page.note(`We could not confirm the ${t.name} payment \u2014 our team will follow up on payment.`),e.page.land(l.parked.confirmation)):e.page.fail(`We could not confirm your ${t.name} payment. Please contact us before trying again \u2014 your payment may already have been taken.`)}finally{e.page.setConfirming(!1)}}}import{Fragment as _,jsx as r,jsxs as c}from"react/jsx-runtime";function An(t){let e=t.indexOf(`
|
|
3
|
-
`);return e===-1?[t,""]:[t.slice(0,e),t.slice(e+1)]}function On(t,{canParkContext:e}={canParkContext:!0}){let n=t.paymentMethods,a=[];return n.includes("card")&&a.push({key:"card",title:"Card",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA \xB7 MC \xB7 AMEX"})}),n.includes("paypal")&&t.paypalClientId&&a.push({key:"paypal",title:"PayPal",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAYPAL \xB7 CARDS"})}),n.includes("afterpay")&&a.push({key:"afterpay",title:"Afterpay",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"4 \xD7 INTEREST-FREE"})}),n.includes("square")&&t.squareApplicationId&&t.squareLocationId&&a.push({key:"square",title:"Card (Square)",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA \xB7 MC \xB7 AMEX"})}),n.includes("gocardless")&&e&&a.push({key:"gocardless",title:"Bank Direct Debit",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY BY BANK"})}),n.includes("zip")&&a.push({key:"zip",title:"Zip",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY IN 4"})}),n.includes("klarna")&&e&&a.push({key:"klarna",title:"Klarna",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),a.push({key:"bank",title:"Bank transfer",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),a}function lt({site:t,logo:e,preview:n=!1}){let{items:a,totals:o,coupon:s,deliveryOptions:l,shippingMethodId:p,setShippingMethodId:d,identify:u,clearCapturedCart:b}=Xe(),m=l.find(i=>i.id===p)?.pickupLocation??null,{country:C,countries:y,activeCountry:A,formatMoney:x}=se(),[h,G]=g(()=>On(t)[0].key),[D,O]=g(!0);$(()=>{O(It(Y))},[]);let[J,ne]=g(!0),[re,Pe]=g(!1),[ae,Ne]=g(""),[oe,Ee]=g(""),[ge,Re]=g(""),[Q,ee]=g(""),[W,B]=g(""),[ye,le]=g(""),[N,he]=g(""),[j,ie]=g(""),[F,ue]=g(()=>C||y[0]?.code||""),[w,H]=g(""),[ve,be]=g([]),Dn=Ye(()=>y.find(i=>i.code===F)??A,[y,F,A])?.postalLabel||"Postal Code",Fn=ve[0]?.divisionType||"State / Province";$(()=>{if(!F){be([]);return}let i=!1;return L.listCountrySubdivisions(F).then(f=>{i||(be(f),H(""))}),()=>{i=!0}},[F]);let[X,ut]=g(null),[pt,dt]=g([]),[Ie,Ae]=g("new"),[He,mt]=g(!1),[ft,Mn]=g("Home"),[gt,yt]=g(null),[M]=g(()=>Ut()),[Oe,U]=g(null),[ht,Le]=g(null),[vt,Un]=g(null),[Kn,$n]=g(!1),[Wn,Yn]=g(!1),[V,Ve]=g(null),[bt,pe]=g(!1),[xt,Z]=g(null),[zn,Bn]=g(!1),[Hn,kt]=g(!1),[Vn,Gn]=g(!1),[Jn,Ct]=g(!1),St=ce(!1);$(()=>{n||St.current||!a.some(Ce)||(St.current=!0,Lt({lines:a,currency:o.currency,value:o.subtotal-o.discount,coupon:s?.valid?s.code:void 0}))},[a,o,s,n]),$(()=>{u(ae,oe.trim()||void 0)},[ae,oe,u]);let wt=ce(null),[Te,Xn]=g(null);$(()=>{let i=wt.current;if(!Te||!i)return;let f=()=>i.style.setProperty("--sf-checkout-header-h",`${Te.offsetHeight}px`);f();let v=new ResizeObserver(f);return v.observe(Te),()=>v.disconnect()},[Te]),$(()=>{let i=v=>({setConfirming:v,land:U,markPaid:()=>pe(!0),note:Z,fail:Le,clearCart:b}),f={search:window.location.search,storage:Y,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};it(Rn,{...f,capture:L.captureAfterpayPayment,page:i(Bn)}),it(In,{...f,capture:L.captureZipPayment,page:i(Gn)})},[]),$(()=>{let f=new URLSearchParams(window.location.search).get("gocardless");if(f!=="confirm"&&f!=="cancel")return;let v=Y.getItem(Ue);if(Y.removeItem(Ue),window.history.replaceState(null,"",window.location.pathname),!v)return;let P;try{P=JSON.parse(v)}catch{return}if(b(),f==="cancel"){Z("The direct debit was not set up \u2014 our team will follow up on payment."),U(P.confirmation);return}kt(!0),L.completeGocardlessPayment({idempotencyKey:P.idempotencyKey}).then(I=>{I.status==="paid"?pe(!0):I.status==="declined"?Z("The direct debit was declined \u2014 our team will follow up on payment."):Z("Your direct debit is set up \u2014 the payment is collecting and will clear in a few days.")}).catch(()=>{Z("We could not confirm the direct debit \u2014 our team will follow up on payment.")}).finally(()=>{U(P.confirmation),kt(!1)})},[]),$(()=>{let i=new URLSearchParams(window.location.search),f=i.get("klarna");if(f!=="confirm"&&f!=="cancel")return;let v=Y.getItem(Ke);Y.removeItem(Ke);let P=i.get("authorization_token");if(window.history.replaceState(null,"",window.location.pathname),!v)return;let I;try{I=JSON.parse(v)}catch{return}if(b(),f==="cancel"||!P){Z("The Klarna payment was not completed \u2014 our team will follow up on payment."),U(I.confirmation);return}Ct(!0),L.captureKlarnaPayment({idempotencyKey:I.idempotencyKey,authorizationToken:P}).then(q=>{q.status==="paid"?pe(!0):q.status==="declined"?Z("Klarna declined the payment \u2014 our team will follow up on payment."):Z("Your Klarna payment is being reviewed \u2014 we'll confirm the outcome shortly.")}).catch(()=>{Z("We could not confirm the Klarna payment \u2014 our team will follow up on payment.")}).finally(()=>{U(I.confirmation),Ct(!1)})},[]);function Pt(i){let[f,v]=An(i.address);ee(f),B(v),le(i.city),he(i.zip_code),i.country&&ue(i.country),i.phone&&ie(i.phone)}$(()=>{let i=!1;return(async()=>{try{let[f,v,P]=await Promise.all([de.me(),de.myProfile().catch(()=>null),de.myAddresses().catch(()=>[])]);if(i)return;ut(f);let I=P.filter(xe=>xe.is_active);dt(I),Ne(f.email);let q=(v?.contact_name??"").split(/\s+/);Ee(f.first_name||q[0]||""),Re(f.last_name||q.slice(1).join(" "));let Et=f.phone||v?.phone;Et&&ie(Et);let Ge=I.find(xe=>xe.id===f.default_delivery_location)??I[0];if(Ge)Ae(Ge.id),Pt(Ge);else if(v){let[xe,er]=An(v.address??"");ee(xe),B(er),le(v.city??""),he(v.zip_code??""),v.country&&ue(v.country)}}catch{}})(),()=>{i=!0}},[]);function Zn(){de.logout(),ut(null),dt([]),Ae("new"),mt(!1)}let je=Ye(()=>On(t,{canParkContext:D}),[t,D]);$(()=>{je.some(i=>i.key===h)||G(je[0].key)},[je,h]);let Nt=W.trim()?`${Q}
|
|
4
|
-
${W.trim()}`:Q;async function Qn(){if(n||re||a.length===0)return;let i=a.filter(Ce).flatMap(f=>At(f.components,f.qty));if(i.length===0){Le("Pick a size on each wheel's product page before checking out.");return}Pe(!0),Le(null);try{let v=await(X?L.createOrderAuthed:L.createOrder)({customer:{email:ae,name:`${oe} ${ge}`.trim(),phone:j.trim()||void 0,address:Nt,city:ye,state:w||void 0,zipCode:N,country:F},items:i,currency:o.currency,idempotencyKey:M,shippingMethodId:p??void 0,couponCode:s?.valid?s.code:void 0,...Sn()});if(Tt({confirmation:v,lines:a,adsSendTo:t.googleAdsId&&t.googleAdsConversionLabel?`${t.googleAdsId}/${t.googleAdsConversionLabel}`:null}),En({confirmation:v,lines:a}),b(),X&&He&&Ie==="new")try{await de.createAddress({label:ft.trim()||"Home",contact_name:`${oe} ${ge}`.trim(),phone:j.trim(),address:Nt,city:ye,zip_code:N,country:F}),yt("Address saved to your account.")}catch{yt("We couldn't save the address to your account \u2014 you can add it under Account \u2192 Addresses.")}if(h==="card"&&t.paymentMethods.includes("card")){let P=await L.createPaymentIntent({idempotencyKey:M});Ve(v),Un(P)}else if(h==="paypal"&&t.paymentMethods.includes("paypal"))Ve(v),$n(!0);else if(h==="afterpay"&&t.paymentMethods.includes("afterpay")){let P=window.location.origin,I=await L.createAfterpayCheckout({idempotencyKey:M,confirmUrl:`${P}/checkout?afterpay=confirm`,cancelUrl:`${P}/checkout?afterpay=cancel`}),q={idempotencyKey:M,confirmation:v};Y.setItem(at,JSON.stringify(q)),window.location.assign(I.redirectCheckoutUrl);return}else if(h==="square"&&t.paymentMethods.includes("square"))Ve(v),Yn(!0);else if(h==="gocardless"&&t.paymentMethods.includes("gocardless")){let P=window.location.origin,I=await L.createGocardlessBillingRequest({idempotencyKey:M,confirmUrl:`${P}/checkout?gocardless=confirm`,cancelUrl:`${P}/checkout?gocardless=cancel`}),q={idempotencyKey:M,confirmation:v};Y.setItem(Ue,JSON.stringify(q)),window.location.assign(I.authorisationUrl);return}else if(h==="zip"&&t.paymentMethods.includes("zip")){let P=window.location.origin,I=await L.createZipCheckout({idempotencyKey:M,redirectUrl:`${P}/checkout?zip=return`}),q={idempotencyKey:M,confirmation:v};Y.setItem(ot,JSON.stringify(q)),window.location.assign(I.redirectUrl);return}else if(h==="klarna"&&t.paymentMethods.includes("klarna")){let P=window.location.origin,I=await L.createKlarnaCheckout({idempotencyKey:M,confirmUrl:`${P}/checkout?klarna=confirm`,cancelUrl:`${P}/checkout?klarna=cancel`}),q={idempotencyKey:M,confirmation:v};Y.setItem(Ke,JSON.stringify(q)),window.location.assign(I.redirectUrl);return}else U(v)}catch(f){Le(f instanceof qe?f.message:"Could not place the order. Please try again."),Pe(!1)}}return Oe?c("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[r("h1",{className:"font-display text-3xl",children:bt?"Payment received":"Order received"}),c("p",{className:"text-fg-dim",children:[bt?c(_,{children:["Thank you \u2014 your payment for order"," ",r("span",{className:"font-mono text-fg",children:Oe.orderNumber})," has gone through."," "]}):c(_,{children:["Thank you \u2014 your order ",r("span",{className:"font-mono text-fg",children:Oe.orderNumber})," is being reviewed by our team."," "]}),X?c(_,{children:["Track it under"," ",r(te,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):r(_,{children:"We\u2019ve emailed you a link to set a password and track it."})]}),xt&&r("p",{className:"text-sm text-fg-dim",children:xt}),gt&&r("p",{className:"text-sm text-fg-dim",children:gt}),!X&&c("p",{className:"text-sm text-fg-dim",children:["You can also"," ",r(te,{href:`/track?order=${encodeURIComponent(Oe.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email \u2014 no password needed."]}),r(te,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]}):zn?c("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[r("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay \u2014 one moment."})]}):Hn?c("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[r("h1",{className:"font-display text-3xl",children:"Setting up your direct debit\u2026"}),r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Confirming with GoCardless \u2014 one moment."})]}):Vn?c("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[r("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip \u2014 one moment."})]}):Jn?c("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[r("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna \u2014 one moment."})]}):vt?r(Kr,{payment:vt,onPaid:()=>{pe(!0),U(V)},onSkip:()=>U(V)}):Kn&&V?r(Yr,{confirmation:V,clientId:t.paypalClientId??"",idemKey:M,onPaid:()=>{pe(!0),U(V)},onSkip:()=>U(V)}):Wn&&V?r(Br,{confirmation:V,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:M,onPaid:()=>{pe(!0),U(V)},onSkip:()=>U(V)}):c("div",{ref:wt,className:"bg-bg text-fg",children:[c("header",{ref:Xn,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 border-b border-line px-[var(--sf-site-gutter,40px)] py-[22px] backdrop-blur-md max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))] max-[640px]:py-4",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[c(te,{href:"/",className:"inline-flex items-center gap-2.5 font-mono text-[13px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["\u2190",r("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),r(te,{href:"/","aria-label":`${t.name} home`,className:"inline-flex items-center justify-center",children:r(Dt,{variant:"header",scrolled:!0,src:e?.url??null,reverse:e?.reverse??!1,reversedSrc:e?.reversed??null,inkIsDark:e?.inkIsDark??null,size:e?.size??"medium",sizePx:e?.sizePx??null,siteName:t.name})}),t.cardPayments?c("span",{className:"flex items-center justify-end gap-2.5 font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim",children:[r("span",{className:"text-green",children:"\u25CF"}),r("span",{className:"max-[640px]:hidden",children:"Encrypted \xB7"})," Stripe"]}):r("span",{})]}),c("section",{className:"mx-auto flex max-w-[var(--sf-site-width,1600px)] flex-wrap items-center justify-between gap-x-8 gap-y-3 border-b border-line bg-surface px-[var(--sf-site-gutter,40px)] py-4 font-mono text-[13px] font-medium uppercase tracking-[0.24em] text-fg max-[1100px]:px-[min(24px,var(--sf-site-gutter,40px))]",children:[r("span",{className:"inline-flex items-center bg-accent px-2.5 py-1 font-bold text-bg",children:"Checkout"}),r("nav",{"aria-label":"Checkout steps",className:"flex flex-wrap items-center gap-5",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Review",state:"pending"},{n:"04",label:"Confirmed",state:"pending"}].map(i=>c("span",{className:["relative flex items-center gap-2 transition-colors",i.state==="pending"?"text-fg-dim":"text-fg",i.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[r("span",{className:i.state==="done"?"text-accent font-bold":"",children:i.n}),r("span",{children:i.label})]},i.n))})]}),c("main",{className:"mx-auto grid max-w-[var(--sf-site-width,1600px)] grid-cols-[1fr_420px] items-start gap-16 px-[var(--sf-site-gutter,40px)] pt-9 pb-[100px] max-[1100px]:grid-cols-1 max-[1100px]:gap-10 max-[1100px]:px-[min(24px,var(--sf-site-gutter,40px))] max-[1100px]:pt-8 max-[1100px]:pb-20",children:[c("div",{children:[c($e,{num:"N\xB0 01",title:"Contact",children:[r(z,{label:"Email",hint:X?c(_,{children:["Signed in \xB7"," ",r("button",{type:"button",onClick:Zn,className:"underline transition-colors hover:text-accent",children:"Not you? Sign out"})]}):void 0,children:r("input",{type:"email",value:ae,onChange:i=>Ne(i.target.value),placeholder:"you@example.com",readOnly:X!==null,className:K+(X?" opacity-70":"")})}),c(Tn,{children:[r(z,{label:"First name",children:r("input",{type:"text",value:oe,onChange:i=>Ee(i.target.value),className:K})}),r(z,{label:"Last name",children:r("input",{type:"text",value:ge,onChange:i=>Re(i.target.value),className:K})})]})]}),c($e,{num:"N\xB0 02",title:m?"Collection":"Shipping address",children:[m?c("div",{className:"grid gap-1.5 text-[14px] leading-[1.6]",children:[r("span",{className:"font-medium",children:m.name}),[m.address,m.city,m.state,m.zipCode,m.country].filter(Boolean).length>0&&r("span",{className:"opacity-80",children:[m.address,m.city,m.state,m.zipCode,m.country].filter(Boolean).join(", ")}),m.openingHours&&r("span",{className:"opacity-80",children:m.openingHours}),m.instructions&&r("span",{className:"opacity-80",children:m.instructions}),r("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):c(_,{children:[X!==null&&pt.length>0&&c("div",{className:"grid gap-2.5",children:[pt.map(i=>r(We,{active:Ie===i.id,onClick:()=>{Ae(i.id),Pt(i)},title:i.label,body:i.formatted_address,price:null},i.id)),r(We,{active:Ie==="new",onClick:()=>Ae("new"),title:"New address",body:null,price:null})]}),r(z,{label:"Address line 1",children:r("input",{type:"text",value:Q,onChange:i=>ee(i.target.value),className:K})}),r(z,{label:"Address line 2",children:r("input",{type:"text",value:W,onChange:i=>B(i.target.value),placeholder:"Apartment, unit, garage bay\u2026",className:K})}),c(Tn,{cols:"three",children:[r(z,{label:"City",children:r("input",{type:"text",value:ye,onChange:i=>le(i.target.value),className:K})}),r(z,{label:Dn,children:r("input",{type:"text",value:N,onChange:i=>he(i.target.value),className:K})}),r(z,{label:"Country",children:r(Qe,{value:F,onChange:i=>ue(i.target.value),className:K+" pr-10",style:Ln,children:y.map(i=>r("option",{value:i.code,children:i.name},i.code))})})]}),r(z,{label:Fn,children:ve.length>0?c(Qe,{value:w,onChange:i=>H(i.target.value),className:K+" pr-10",style:Ln,children:[r("option",{value:"",children:"Select\u2026"}),ve.map(i=>r("option",{value:i.code||i.name,children:i.name},i.code||i.name))]}):r("input",{type:"text",value:w,onChange:i=>H(i.target.value),className:K})})]}),r(z,{label:"Phone",children:r("input",{type:"tel",value:j,onChange:i=>ie(i.target.value),placeholder:"+44 7700 900000",className:K})}),!m&&X!==null&&Ie==="new"&&c(_,{children:[r(_n,{checked:He,onChange:mt,label:"Save this address to my account"}),He&&r(z,{label:"Address label",children:r("input",{type:"text",value:ft,onChange:i=>Mn(i.target.value),placeholder:"Home",className:K})})]}),!m&&r(_n,{checked:J,onChange:ne,label:"Billing address is the same as shipping"})]}),r($e,{num:"N\xB0 03",title:"Shipping",children:c("div",{className:"grid gap-2.5",children:[l.map(i=>{let f=i.pickupLocation,v=f?[f.address,f.city,f.state,f.zipCode].filter(Boolean).join(", "):null;return r(We,{active:p===i.id,onClick:()=>d(i.id),title:f?`${i.name} \u2014 ${f.name}`:i.name,body:f?[v,f.openingHours,f.instructions,i.description].filter(Boolean).join(" \xB7 "):i.description||null,price:o.freeShipping||i.amount===0?"Free":x(i.amount,o.currency),tag:i.tag||void 0},i.id)}),l.length===0&&r("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})}),c($e,{num:"N\xB0 04",title:"Payment",children:[r("div",{className:"grid gap-2.5",children:je.map(i=>r(We,{active:h===i.key,onClick:()=>G(i.key),title:i.title,body:i.body,price:i.price,tag:i.tag},i.key))}),h==="card"?r("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll enter card details on the secure payment step after placing the order."}):h==="paypal"?r("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll approve the payment with PayPal on the payment step after placing the order."}):h==="afterpay"?r("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll be taken to Afterpay to approve four interest-free payments, then brought straight back."}):h==="square"?r("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll enter card details on the secure payment step after placing the order."}):h==="gocardless"?r("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll set up a bank direct debit with GoCardless, then be brought straight back. Direct debits clear in a few days."}):h==="zip"?r("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll be taken to Zip to approve four instalments, then brought straight back."}):h==="klarna"?r("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll be taken to Klarna to choose how to pay, then brought straight back."}):r("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Our team emails you the invoice and bank details after review."})]})]}),c("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-[1100px]:static",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--surface) 70%, var(--bg)) 0%, var(--bg) 100%)"},children:[c("header",{className:"flex items-center justify-between border-b border-accent bg-accent px-6 py-3.5 font-mono text-[13px] font-bold uppercase tracking-[0.28em] text-bg",children:[r("span",{children:"Your order"}),r(te,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit \u2197"})]}),r("div",{className:"flex flex-col px-6 py-2",children:a.length===0?c("div",{className:"py-8 text-center font-serif text-[16px] italic leading-[1.5] text-fg-dim",children:["Your cart is empty. ",r(te,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog \u2192"})]}):a.map(i=>r(Hr,{slug:i.slug,name:i.name,qty:i.qty,config:i.config,configSummary:Vr(i.config),price:jt(i,o.currency)??0,currency:o.currency},i.id))}),r("div",{className:"border-t border-line px-6 pt-5",children:r($t,{customerEmail:ae})}),c("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[r(fe,{label:"Subtotal",value:x(o.subtotal,o.currency)}),o.discount>0&&s?.valid&&r(fe,{label:`Coupon \xB7 ${s.code}`,value:c("span",{className:"font-semibold text-green",children:["\u2212 ",x(o.discount,o.currency)]})}),s?.valid&&s.effects?.gift&&r(fe,{label:`Free gift \xB7 ${s.effects.gift.partNumber}${s.effects.gift.quantity>1?` \xD7${s.effects.gift.quantity}`:""}`,value:r("span",{className:"font-semibold text-green",children:"Free"})}),r(fe,{label:"Shipping",value:o.freeShipping||o.shipping===0?r("span",{className:"font-semibold text-green",children:"Free"}):x(o.shipping,o.currency)}),o.tax&&(o.tax.charged?r(fe,{label:o.tax.inclusive?`${o.tax.name} included \xB7 ${o.tax.rate}%`:o.tax.name,value:x(o.tax.amount,o.currency)}):o.tax.name?r(fe,{label:o.tax.name,value:"Calculated at checkout"}):null)]}),c("div",{className:"mt-4 flex items-end justify-between border-y-2 border-accent px-6 py-4",style:{background:"color-mix(in oklab, var(--accent) 10%, var(--bg))"},children:[r("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),r("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:x(o.grand,o.currency)})]}),c("div",{className:"flex flex-col gap-2.5 px-6 pt-[18px] pb-6",children:[ht&&r("p",{className:"border border-red-300 bg-red-50 px-3 py-2 text-[13px] text-red-700",children:ht}),o.hasUnpricedLine&&c("p",{className:"border border-amber-300 bg-amber-50 px-3 py-2 text-[13px] text-amber-800",children:["One or more items have no price in ",o.currency,". Remove them, or switch region, to continue."]}),r("button",{type:"button",onClick:Qn,disabled:re||a.length===0||o.hasUnpricedLine,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",a.length===0||re||o.hasUnpricedLine?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:re?c(_,{children:["Building order\u2026 ",r("span",{children:"\xB7"})]}):c(_,{children:[h==="bank"?"Place order":"Continue to payment"," \xB7"," ",x(o.grand,o.currency),r("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})})]})]})]}),r("footer",{className:"flex flex-wrap items-center justify-between gap-4 border-t border-line px-[var(--sf-site-gutter,40px)] py-6 font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))]",children:r("span",{children:Ft({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}var K="w-full border-2 border-line bg-bg px-4 py-3.5 font-display text-[17px] tracking-[-0.005em] text-fg outline-none transition-colors placeholder:text-fg-dim hover:border-fg-dim focus:border-accent",Ln={backgroundImage:"linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%)",backgroundPosition:"calc(100% - 18px) 50%, calc(100% - 12px) 50%",backgroundSize:"6px 6px",backgroundRepeat:"no-repeat"};function $e({num:t,title:e,children:n}){return c("section",{className:"mb-6 border border-line bg-bg",children:[c("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-3.5",children:[r("span",{className:"inline-flex items-center justify-center bg-accent px-2.5 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t}),r("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:e})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function Tn({cols:t="two",children:e}){return r("div",{className:["grid gap-3 max-[640px]:grid-cols-1",t==="two"?"grid-cols-2":"grid-cols-[1.2fr_1fr_1fr]"].join(" "),children:e})}function z({label:t,hint:e,children:n}){return c("div",{className:"relative flex flex-col gap-2",children:[r("label",{className:"font-mono text-[12px] font-semibold uppercase tracking-[0.22em] text-fg",children:t}),n,e&&r("span",{className:"font-mono text-[11px] uppercase tracking-[0.22em] text-fg-dim",children:e})]})}function We({active:t,onClick:e,title:n,body:a,price:o,tag:s}){return c("button",{type:"button",onClick:e,"aria-pressed":t,className:["relative grid grid-cols-[auto_1fr_auto] items-center gap-[18px] border bg-bg px-[22px] py-[18px] text-left transition-colors",t?"border-accent outline outline-1 outline-accent -outline-offset-1":"border-line hover:border-[color-mix(in_oklab,var(--accent)_50%,var(--line))]"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 14%, var(--bg))"}:void 0,children:[t&&r("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),r("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",t?"border-accent":"border-fg-dim"].join(" "),children:t&&r("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),c("span",{className:"flex min-w-0 flex-col gap-1",children:[c("span",{className:"flex flex-wrap items-baseline gap-2.5 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,s&&r("span",{className:"border px-1.5 py-0.5 font-mono text-[11px] font-normal uppercase tracking-[0.24em] text-accent",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 45%, var(--line))"},children:s})]}),a&&r("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:a})]}),r("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:o})]})}function Kr({payment:t,onPaid:e,onSkip:n}){let{formatMoney:a}=se(),o=Ye(()=>bn(t.publishableKey),[t.publishableKey]),s=Ye(()=>{if(typeof document>"u")return;let l=getComputedStyle(document.documentElement),p=(u,b)=>l.getPropertyValue(u).trim()||b,d=document.documentElement.getAttribute("data-theme")!=="light";return{theme:d?"night":"stripe",variables:{colorPrimary:p("--accent",d?"#c9a461":"#8a6a2a"),colorBackground:p("--surface",d?"#131313":"#ffffff"),colorText:p("--fg",d?"#f5f1e8":"#0a0a0a"),borderRadius:"0px"}}},[]);return r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:c("div",{className:"w-full max-w-xl border border-line bg-bg",children:[c("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-3.5",children:[r("span",{className:"inline-flex items-center justify-center bg-accent px-2.5 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),r("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),c("div",{className:"flex flex-col gap-4 px-6 py-6",children:[c("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",r("span",{className:"text-fg",children:a(Number(t.amount),t.currency)})," ","by card to confirm it now."]}),r(rt,{stripe:o,options:{clientSecret:t.clientSecret,appearance:s},children:r($r,{payment:t,onPaid:e,onSkip:n})})]})]})})}function $r({payment:t,onPaid:e,onSkip:n}){let{formatMoney:a}=se(),o=pn(),s=ln(),[l,p]=g(!1),[d,u]=g(null);async function b(){if(!o||!s||l)return;p(!0),u(null);let m=await o.confirmPayment({elements:s,redirect:"if_required"});if(m.error){u(m.error.message??"Payment failed. Please try again."),p(!1);return}let C=m.paymentIntent?.status;if(C==="succeeded"||C==="processing"){e();return}u("Payment did not complete. Please try again."),p(!1)}return c("div",{className:"flex flex-col gap-4",children:[r(dn,{}),d&&r("p",{className:"border border-red-300 bg-red-50 px-3 py-2 text-[13px] text-red-700",children:d}),r("button",{type:"button",onClick:b,disabled:!o||!s||l,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!o||!s||l?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:l?c(_,{children:["Processing\u2026 ",r("span",{children:"\xB7"})]}):c(_,{children:["Pay ",a(Number(t.amount),t.currency),r("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})}),r("button",{type:"button",onClick:n,disabled:l,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later \u2014 our team will be in touch"})]})}var jn="paypal-sdk-js",st=null;function Wr(t,e){let n=`${t}|${e}`;if(st?.key===n)return st.promise;let a=new Promise((o,s)=>{document.getElementById(jn)?.remove();let l=document.createElement("script");l.id=jn;let p=new URLSearchParams({"client-id":t,currency:e,intent:"capture"});l.src=`https://www.paypal.com/sdk/js?${p}`,l.onload=()=>{let d=window.paypal;d?o(d):s(new Error("PayPal SDK loaded without its namespace"))},l.onerror=()=>s(new Error("PayPal SDK failed to load")),document.head.appendChild(l)});return st={key:n,promise:a},a}function Yr({confirmation:t,clientId:e,idemKey:n,onPaid:a,onSkip:o}){let{formatMoney:s}=se(),l=ce(null),[p,d]=g(!1),[u,b]=g(null),m=ce(a);return m.current=a,$(()=>{let C=!1,y=null;return Wr(e,t.currency).then(A=>{if(!(C||!l.current))return y=A.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await L.createPaypalOrder({idempotencyKey:n})).paypalOrderId,onApprove:async x=>{try{if((await L.capturePaypalOrder({idempotencyKey:n,paypalOrderId:x.orderID})).status==="paid"){m.current();return}b("PayPal did not complete the payment. Please try again.")}catch(h){b(h instanceof qe?h.message:"PayPal payment failed. Please try again.")}},onError:()=>{b("PayPal could not process the payment. Please try again.")}}),y.render(l.current).then(()=>{C||d(!0)})}).catch(()=>{C||b("PayPal could not be loaded. You can pay later \u2014 your order stands either way.")}),()=>{C=!0,y?.close?.()}},[e,t.currency,n]),r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:c("div",{className:"w-full max-w-xl border border-line bg-bg",children:[c("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-3.5",children:[r("span",{className:"inline-flex items-center justify-center bg-accent px-2.5 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),r("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),c("div",{className:"flex flex-col gap-4 px-6 py-6",children:[c("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",r("span",{className:"text-fg",children:s(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!p&&!u&&r("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal\u2026"}),r("div",{ref:l}),u&&r("p",{className:"border border-red-300 bg-red-50 px-3 py-2 text-[13px] text-red-700",children:u}),r("button",{type:"button",onClick:o,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later \u2014 our team will be in touch"})]})]})})}var qn="square-web-sdk",ct=null;function zr(t){let e=t==="sandbox"?"sandbox":"production";if(ct?.key===e)return ct.promise;let n=new Promise((a,o)=>{document.getElementById(qn)?.remove();let s=document.createElement("script");s.id=qn,s.src=e==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",s.onload=()=>{let l=window.Square;l?a(l):o(new Error("Square SDK loaded without its namespace"))},s.onerror=()=>o(new Error("Square SDK failed to load")),document.head.appendChild(s)});return ct={key:e,promise:n},n}function Br({confirmation:t,applicationId:e,locationId:n,environment:a,idemKey:o,onPaid:s,onSkip:l}){let{formatMoney:p}=se(),d=ce(null),u=ce(null),b=ce(null),[m,C]=g(!1),[y,A]=g(!1),[x,h]=g(null);$(()=>{let D=!1,O=null;return zr(a).then(async J=>{if(D||!d.current)return;let ne=J.payments(e,n);b.current=ne,O=await ne.card(),await O.attach(d.current),u.current=O,D||C(!0)}).catch(()=>{D||h("Square could not be loaded. You can pay later \u2014 your order stands either way.")}),()=>{D=!0,O?.destroy?.()}},[e,n,a]);async function G(){let D=u.current;if(!(!D||y)){A(!0),h(null);try{let O=await D.tokenize();if(O.status!=="OK"||!O.token){h(O.errors?.[0]?.message??"Please check the card details and try again."),A(!1);return}let J;try{J=(await b.current?.verifyBuyer?.(O.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await L.chargeSquare({idempotencyKey:o,sourceId:O.token,...J?{verificationToken:J}:{}})).status==="paid"){s();return}h("Square did not complete the payment. Please try again.")}catch(O){h(O instanceof qe?O.message:"Square payment failed. Please try again.")}A(!1)}}return r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:c("div",{className:"w-full max-w-xl border border-line bg-bg",children:[c("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-3.5",children:[r("span",{className:"inline-flex items-center justify-center bg-accent px-2.5 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),r("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),c("div",{className:"flex flex-col gap-4 px-6 py-6",children:[c("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",r("span",{className:"text-fg",children:p(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!m&&!x&&r("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form\u2026"}),r("div",{ref:d}),x&&r("p",{className:"border border-red-300 bg-red-50 px-3 py-2 text-[13px] text-red-700",children:x}),r("button",{type:"button",onClick:G,disabled:!m||y,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!m||y?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:y?c(_,{children:["Processing\u2026 ",r("span",{children:"\xB7"})]}):c(_,{children:["Pay ",p(Number(t.grandTotal),t.currency),r("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})}),r("button",{type:"button",onClick:l,disabled:y,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later \u2014 our team will be in touch"})]})]})})}function _n({checked:t,onChange:e,label:n,sub:a}){return c("div",{className:"flex items-start gap-3 border-t border-line py-3.5 first:border-t-0 first:pt-0",children:[r("button",{type:"button",onClick:()=>e(!t),"aria-pressed":t,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",t?"border-accent":"border-line"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:t&&r("span",{className:"text-[13px] text-accent",children:"\u2713"})}),c("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,a&&r("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:a})]})]})}function Hr({slug:t,name:e,qty:n,config:a,configSummary:o,price:s,currency:l}){let{catalog:p}=Xe(),{formatMoney:d}=se(),u=p.find(x=>x.slug===t),b=u?.spokes??5,m=u?.mesh??!1,C=a.find(x=>x.gold)?.label,y=u?.finishes.find(x=>x.name===C&&x.src)??u?.finishes.find(x=>x.src),A=u?.finishes[0]?.color??_t;return c("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-3.5 border-b border-line py-4 last:border-b-0",children:[c("div",{className:"relative flex aspect-square items-center justify-center overflow-hidden border border-line bg-surface",children:[r("span",{className:"absolute -right-1.5 -top-1.5 z-[2] flex h-[18px] w-[18px] items-center justify-center rounded-full bg-accent font-mono text-[11px] font-bold text-bg",children:n}),y?.src?r(Rt,{src:y.src,alt:`${e.lead}${e.accent} \u2014 ${y.name}`,width:120,height:120,sizes:"60px",className:"relative block h-full w-full object-contain p-1.5"}):r("div",{className:"block w-[78%]",style:{color:A},children:r(Kt,{spokes:b,mesh:m,className:"block w-full"})})]}),c("div",{className:"flex min-w-0 flex-col gap-0.5",children:[c("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[e.lead,r("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:e.accent})]}),r("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:o})]}),r("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:d(s,l)})]})}function fe({label:t,value:e}){return c("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[r("span",{children:t}),r("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:e})]})}function Vr(t){return t.map(e=>e.label).join(" \xB7 ")}import{jsx as ze}from"react/jsx-runtime";function Gr(){let{settings:t,websiteName:e}=Mt(),n=e?{...Ze,name:e}:Ze,a=t?{url:t.logoUrl,reversed:t.logoReversed??null,inkIsDark:t.logoInkIsDark??null,reverse:t.reverseLogo,size:t.logoSize,sizePx:t.logoSizePx}:null;return ze("div",{style:{position:"fixed",inset:0,zIndex:2147482e3,overflowY:"auto",background:"var(--bg)",color:"var(--fg)"},children:ze(Ot,{children:ze(qt,{preview:!0,children:ze(lt,{site:n,logo:a,preview:!0})})})})}export{Gr as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use client";import{r as m}from"./chunk-N35EG6RF.js";import{l as g}from"./chunk-KR3FTVDW.js";import"./chunk-K3Y6UBLO.js";import{of as a,wb as s}from"./chunk-UTFM4DGR.js";import"./chunk-X6KEAC34.js";import{Yc as d,bd as f,nd as c,tc as u}from"./chunk-4KLEZTLW.js";import"./chunk-RF5DTRJ5.js";import"./chunk-UBYBQ3KR.js";import"./chunk-Y6SLVHK3.js";import{Render as I}from"efficient-easel/render";import{jsx as p}from"react/jsx-runtime";function i({footerBlock:r,rootProps:e,headerSettings:o,siteName:t,legalName:l,foundedYear:n,socialLinks:h}){let v=a({root:{props:{...e??{},kind:s}},content:[r],zones:{}});return p(d.Provider,{value:{logoUrl:o?.logoUrl??null,logoReversed:o?.logoReversed??null,logoInkIsDark:o?.logoInkIsDark??null,siteName:t,legalName:l??null,foundedYear:n??null,socialLinks:h??f},children:p(I,{config:m,data:v})})}import{jsx as k}from"react/jsx-runtime";function P(){let{footerBlock:r,editFooter:e}=g(),{settings:o,websiteName:t}=c();if(!r)return null;let l=o?{logoUrl:o.logoUrl,logoReversed:o.logoReversed??null,logoInkIsDark:o.logoInkIsDark??null}:null;return k("div",{className:"sf-preview-footer-pick",onClick:e?n=>{n.stopPropagation(),e()}:void 0,style:e?{cursor:"pointer"}:void 0,title:e?"Edit the site footer \u2192":void 0,children:k(i,{footerBlock:r,headerSettings:l,siteName:t?.trim()||u})})}export{P as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use client";import{A as Ae,B as Re,D as Me,E as xe,e as v,f as _,n as Ee,p as Ce,t as he,v as f,w as E,x as Ie}from"./chunk-WMFQNAWF.js";import"./chunk-4G3T6ZD2.js";import{a as ve}from"./chunk-K3Y6UBLO.js";import{Aj as be,La as ue,Oh as Te,Sj as w,if as ge,kf as ye,lf as ke,mc as fe,mk as Pe,ok as we,qf as Se,wj as P}from"./chunk-UTFM4DGR.js";import{Ea as ae,Ia as de,Ka as pe,La as me}from"./chunk-4KLEZTLW.js";import"./chunk-RF5DTRJ5.js";import"./chunk-UBYBQ3KR.js";import"./chunk-Y6SLVHK3.js";import{Fragment as Ne,useCallback as je,useEffect as x,useRef as Le,useState as Oe}from"react";import{SaveState as Ze}from"efficient-easel/chrome";import{parseZoneKey as N,zoneKey as et}from"efficient-easel/data";import{useTreeDrag as tt}from"efficient-easel/drag";import{TrashIcon as $e}from"efficient-easel/icons";import{LayersTree as ot,Subtree as Be,TreeRow as L,TreeRowAction as ze,TreeSeam as nt}from"efficient-easel/tree";import{saveIndicator as rt}from"efficient-easel/autosave";import{useEditor as st}from"efficient-easel/editor";import{Fragment as De,jsx as n,jsxs as k}from"react/jsx-runtime";var O=$=>C=>{C.target.closest(".es-tree-select, button")||$()};function it(){let{saveState:$,readOnly:C}=Se(),i=ue(),{appState:Fe,selectedItem:b,config:B}=st(e=>e),[T,c]=Oe(f),[K,W]=Oe(null),r=Fe.data.content?.[0]??null,g=r?.props.id??null,S=r?.type===pe,He=r?.type===me,U=Le(null),z=Le(null);Me(z);let Y=ge(),h=ke();x(()=>{let e=z.current;if(!h||!e)return;let t=o=>{o.key==="Escape"&&ye()};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)},[h]),x(()=>{if(g&&U.current!==g){if(U.current=g,S){c(E);return}b||i.select({index:0})}},[g,b,i,S]);let{setSelectedHeroId:q,setSelectHandler:V}=we(),D=T.kind==="ticker"?T.heroId:null,I=je(e=>{e&&(c(t=>t.kind==="ticker"&&t.heroId===e?t:{kind:"ticker",heroId:e}),v(e))},[]);x(()=>{q(D)},[D,q]),x(()=>{V(I)},[V,I]);let{selectNode:_e}=Re({mode:T,setMode:c,onOpenPart:v}),F=e=>B.components[e]?.label??e,G=e=>fe(e,"section",F(e)),Ke=()=>{if(S){c(E);return}c(f),i.select({index:0})},J=!S&&T.kind==="puck"&&b?.props.id===g,a=r?w(r.type)?.spec??null:null,d=r&&a?`${r.props.id}:${a.slot}`:null,Q=r&&a&&Array.isArray(r.props[a.slot])?r.props[a.slot]:[],H=e=>Te(e,F),X=(e,t)=>{!r||!a||!d||(c(f),a.slider?(_(String(r.props.id),e),i.select({index:e,zone:d}),v(String(r.props.id))):(i.select({index:e,zone:d}),v(t)))},j=()=>{if(!r||!a||!d)return;let e=Q.length;i.insertComponent(d,a.childType,e),c(f),a.slider?requestAnimationFrame(()=>{_(String(r.props.id),e),i.select({index:e,zone:d})}):i.select({index:e,zone:d})},We=e=>{d&&(i.removeComponent(d,e),c(f),i.select(null))},Z=e=>ae(B,e),ee=e=>{let{parentId:t,slot:o}=N(e),s=m=>{if(!m)return null;if(String(m.props.id)===t)return m;for(let p of Z(m.type)){let u=Array.isArray(m.props[p])?m.props[p]:[];for(let y of u){let M=s(y);if(M)return M}}return null},l=s(r)?.props[o];return Array.isArray(l)?l.length:0},te=(e,t,o)=>{let s=Math.min(Math.max(o,0),ee(e)),l=t<s?s-1:s;l!==t&&(i.reorderComponent(e,t,l),c(f),i.select({index:l,zone:e}))},A=tt({keyOf:e=>e.id,readOnly:!!C,canDrop:(e,t)=>et(t)===e.zone&&t.index>=0&&t.index<=ee(e.zone),onDrop:(e,t)=>te(e.zone,e.index,t.index),onStep:(e,t)=>te(e.zone,e.index,t<0?e.index-1:e.index+2)}),R=(e,t)=>n(nt,{...C?{}:A.seam({place:{...N(e),index:t}})},`seam:${e}:${t}`),Ue=e=>Z(e.type).flatMap(t=>(Array.isArray(e.props[t])?e.props[t]:[]).map((s,l)=>({child:s,zone:`${e.props.id}:${t}`,index:l}))),oe=e=>{let t=e.props;if(e.type==="FooterMenu"){let o=t.menu;return t.heading||o?.name||"Menu"}if(e.type==="FooterText"){let o=typeof t.text=="string"?t.text.trim():"";return o?o.length>28?`${o.slice(0,28)}\u2026`:o:"Text"}return e.type==="FooterEmailSignup"?t.heading||"Email signup":F(e.type)},ne=(e,t,o)=>{c(f),i.select({index:t,zone:e}),v(o)},re=(e,t,o)=>{i.insertComponent(e,t,o),c(f),i.select({index:o,zone:e}),W(null)},Ye=(e,t)=>{i.removeComponent(e,t),c(f),i.select(null)},qe=(e,t,o)=>n(ve,{choices:o,open:K===e,onToggle:()=>W(K===e?null:e),onPick:s=>re(e,s,t)}),se=(e,t)=>{let o=Ue(e),s=w(e.type),l=s?.choices??null,m=s?.source==="footer"?oe:H;return k(De,{children:[o.map(({child:p,zone:u,index:y})=>{let M=b?.props.id===p.props.id,Je=de(B,p.type,t),ie=m(p),le=String(p.props.id),ce=()=>ne(u,y,le),{rowProps:Qe,...Xe}=A.row({item:{id:le,zone:u,index:y},place:{...N(u),index:y}},{onClick:O(ce)});return k(Ne,{children:[y===0&&R(u,0),n(L,{icon:n(P,{type:p.type,size:13}),name:ie,selected:M,onSelect:ce,...Xe,actions:n(ze,{kind:"delete",label:`Delete ${ie}`,onClick:()=>Ye(u,y),children:n($e,{size:13})}),rowProps:Qe}),Je&&n(Be,{children:se(p,t+1)}),R(u,y+1)]},String(p.props.id??`${u}-${y}`))}),s&&l?qe(`${e.props.id}:${s.slot}`,o.length,l):null]})},Ve=r?.type==="HeroSingle",Ge=!!r&&(!!a||He||S||Ve);return k("div",{ref:z,className:"sf-editor es-editor",style:he(Ce),children:[n("div",{className:"sf-section-bar",children:n(Ze,{...rt($),role:"status"})}),k("div",{className:"sf-body",children:[h&&Y?n("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left",children:n(Ee,{panel:Y,pick:h})}):Ge&&r&&k("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left",children:[n("div",{className:"sf-panel-head",children:n("button",{type:"button",className:`sf-panel-title sf-panel-title--btn ${J?"is-selected":""}`,"aria-pressed":J,title:S?"Header settings":`${G(r.type)} settings`,onClick:Ke,children:G(r.type)})}),n(ot,{className:"sf-tree sf-scroll",rootProps:A.rootProps(),children:n(Be,{children:S?n(L,{icon:n(P,{type:"header",size:13}),name:"Header settings",selected:T.kind==="header",onSelect:()=>c(E),rowProps:{onClick:O(()=>c(E))}}):a?k(De,{children:[Q.map((e,t)=>{let o=b?.props.id===e.props.id,s=H(e),l=String(e.props.id),m=()=>X(t,l),{rowProps:p,...u}=A.row({item:{id:l,zone:d,index:t},place:{...N(d),index:t}},{onClick:O(m)});return k(Ne,{children:[t===0&&R(d,0),n(L,{icon:n(P,{type:e.type,size:13}),name:s,selected:o,onSelect:m,...u,actions:n(ze,{kind:"delete",label:`Delete ${s}`,onClick:()=>We(t),children:n($e,{size:13})}),rowProps:p}),R(d,t+1)]},String(e.props.id??t))}),k("button",{type:"button",className:"sf-add-card",onClick:j,children:[n("span",{className:"sf-plus sf-plus--sm",children:"+"}),a.addLabel]}),r.type==="Hero"&&g&&n(L,{icon:n(P,{type:"ticker",size:13}),name:Pe,selected:D===g,onSelect:()=>I(g),rowProps:{onClick:O(()=>I(g))}})]}):se(r,1)})})]}),n("div",{className:"sf-center",children:n("div",{className:"sf-preview-host",children:n(xe,{})})}),n(be,{value:{selectChild:(e,t,o,s)=>w(s)?.source==="section"?X(t,o):ne(e,t,o),addChild:(e,t,o,s,l)=>w(l)?.source==="section"?j():re(`${e}:${t}`,o,s),childRowName:H,blockRowName:oe},children:n(Ae,{mode:T,onOpenWebsiteSettings:()=>c(Ie),onSelectNode:_e,hideNodeActions:!0})})]})]})}export{it as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use client";import{b as d}from"./chunk-UBYBQ3KR.js";import"./chunk-Y6SLVHK3.js";import{useEffect as i,useState as c}from"react";import{createEditor as p,EditorProvider as m}from"efficient-easel/editor";import{jsx as l}from"react/jsx-runtime";function E({config:o,data:s,onChange:r,permissions:e,children:f}){let[t]=c(()=>p({config:o,data:s,permissions:e}));i(()=>{t.setConfig(o)},[t,o]),i(()=>{if(!r)return;let n=t.getState().appState.data;return t.subscribe(()=>{let a=t.getState().appState.data;a!==n&&(n=a,r(a))})},[t,r]),i(()=>{e&&t.setPermissions(e)},[t,e]);let u=d();return l(m,{editor:t,hotkeys:u.ownsDocument,children:f})}export{E as default};
|