efficient-storefront-blocks 0.113.0 → 0.114.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 +22 -0
- package/dist/chunks/{EditorPreviewCheckout-QJWDGMO7.js → EditorPreviewCheckout-KJ7WBAJJ.js} +4 -4
- package/dist/chunks/{SiteEditorProvider-6V6EJFTL.js → SiteEditorProvider-RH2SMNYG.js} +1 -1
- package/dist/chunks/chunk-H7576DO5.js +1 -0
- package/dist/chunks/chunk-P3DTJ3CI.js +1 -0
- package/dist/chunks/{chunk-7ZIXVUD7.js → chunk-WWVWTSGF.js} +2 -2
- package/dist/chunks/{fitment-data-7BV7JBDK.js → fitment-data-RALB36SU.js} +1 -1
- package/dist/contract.js +3 -3
- package/dist/editor/components/PostListStartsFromPage.d.ts +4 -0
- package/dist/editor/components/PostListStartsFromPage.js +1 -0
- package/dist/editor/lib/document/blocks/service/Events/fields.js +1 -1
- package/dist/editor/lib/document/config.js +1 -1
- package/dist/editor/lib/storefront-editor-words.d.ts +2 -0
- package/dist/editor/lib/storefront-editor-words.js +1 -1
- package/dist/index.js +30 -30
- package/dist/links.js +1 -1
- package/dist/render/components/ConsentProvider.js +1 -1
- package/dist/render/components/Events.d.ts +5 -2
- package/dist/render/components/Events.js +1 -1
- package/dist/render/components/PostListStartsProvider.d.ts +21 -0
- package/dist/render/components/PostListStartsProvider.js +1 -0
- package/dist/render/components/PublishedFooter.js +1 -1
- package/dist/render/components/PublishedHeader.js +1 -1
- package/dist/render/components/SignUpSection.js +1 -1
- package/dist/render/components/booking/BookingFormState.d.ts +4 -0
- package/dist/render/components/booking/BookingFormState.js +1 -1
- package/dist/render/components/booking/BookingRegions.js +1 -1
- package/dist/render/components/checkout/CheckoutPageClient.js +1 -1
- package/dist/render/lib/booking/appointment-time.d.ts +5 -1
- package/dist/render/lib/booking/appointment-time.js +1 -1
- package/dist/render/lib/content/post-list-continue.d.ts +19 -0
- package/dist/render/lib/content/post-list-continue.js +1 -0
- package/dist/render/lib/document/blocks/service/Events/meta.js +1 -1
- package/dist/render/lib/document/blocks/service/Events/render.js +1 -1
- package/dist/render/lib/document/render-client.js +1 -1
- package/dist/render/lib/sections/sign-up.d.ts +1 -1
- package/dist/render/lib/sections/sign-up.js +1 -1
- package/dist/render/lib/zone.js +1 -1
- package/dist/words.d.ts +2 -0
- package/dist/words.js +1 -1
- package/package.json +2 -2
- package/dist/chunks/chunk-IY3JZXIQ.js +0 -1
- package/dist/chunks/chunk-TNITUVMH.js +0 -1
- package/dist/render/lib/reader-zone.d.ts +0 -1
- package/dist/render/lib/reader-zone.js +0 -1
- /package/dist/chunks/{chunk-7UBABYIY.js → chunk-25XGYFU3.js} +0 -0
- /package/dist/chunks/{chunk-37WWMI27.js → chunk-ISCYSRBG.js} +0 -0
- /package/dist/chunks/{chunk-7ZIXVUD7.js.LEGAL.txt → chunk-WWVWTSGF.js.LEGAL.txt} +0 -0
package/dist/links.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var g={bold:{open:"**",close:"**",placeholder:"bold text"},italic:{open:"_",close:"_",placeholder:"italic text"},strike:{open:"~~",close:"~~",placeholder:"struck out"},code:{open:"`",close:"`",placeholder:"code"},highlight:{open:"==",close:"==",placeholder:"highlighted text"},quiet:{open:"^^",close:"^^",placeholder:"quiet text"},underline:{open:"[",close:"]{underline}",placeholder:"underlined text"},sup:{open:"[",close:"]{sup}",placeholder:"superscript"},sub:{open:"[",close:"]{sub}",placeholder:"subscript"}};var ie=["main","text","background","muted"],en=[...ie,"surface"];var nn={bold:g.bold.placeholder,italic:g.italic.placeholder,strike:g.strike.placeholder,code:g.code.placeholder,highlight:g.highlight.placeholder,quiet:g.quiet.placeholder,link:"link text",underline:g.underline.placeholder,sup:g.sup.placeholder,sub:g.sub.placeholder,color:"colored text",style:"styled text"};var se=[{style:"bold",label:"B",name:"Strong",title:"Strong \xB7 **words** \xB7 \u2318B",shortcut:"b"},{style:"italic",label:"I",name:"Italic",title:"Italic \xB7 _words_ \xB7 \u2318I",shortcut:"i"},{style:"strike",label:"S",name:"Strikethrough",title:"Strikethrough \xB7 ~~words~~"},{style:"highlight",label:"\u25C6",name:"Emphasis",title:"Emphasis \xB7 ==words=="},{style:"quiet",label:"a",name:"Quiet",title:"Quiet \xB7 ^^words^^"},{style:"code",label:"\u2039\u203A",name:"Code",title:"Code"},{style:"link",label:"\u{1F517}",name:"Link",title:"Link \xB7 [words](https://\u2026) \xB7 \u2318K",shortcut:"k"},{style:"bullet",label:"\u2022",name:"Bulleted list",title:"Bulleted list"},{style:"number",label:"1.",name:"Numbered list",title:"Numbered list"},{style:"quote",label:"\u275D",name:"Quote",title:"Quote"},{style:"clear",label:"T\xD7",name:"Clear marks",title:"Clear marks \xB7 \u2318\u21E7X",shortcut:"shift+x"}];var T=[{open:"**",close:"**",kind:"bold"},{open:"==",close:"==",kind:"highlight"},{open:"~~",close:"~~",kind:"strike"},{open:"_",close:"_",kind:"italic",wordBoundary:!0},{open:"^^",close:"^^",kind:"quiet"},{open:"@@",close:"@@",kind:"highlight"},{open:"++",close:"++",kind:"bold",wordStart:!0}],le=["highlight","quiet"],tn=se.map(e=>e.style).filter(e=>T.some(n=>n.kind===e)).filter(e=>!le.includes(e)),rn=[...T,{open:"*",close:"*",kind:"accent"}],on=[...T,{open:"*",close:"*",kind:"accent"},{open:"#",close:"#",kind:"bold",notBefore:"0123456789"},{open:"[",close:"]",kind:"italic",notBefore:"(",notBeforeBlock:!0}];var sn=["http","https","mailto","tel"];function D(e){if(e===""||/[\s\u0000-\u001f\u007f]/.test(e))return!1;let n=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!n||sn.includes(n[1].toLowerCase())}var ae=["width","profile","rim"];var ln=/^\s*(\d{2,3})\s*\/\s*(\d{2,3})\s*[A-Za-z]*\s*(\d{2}(?:\.\d+)?)\s*$/,an={width:[100,500],profile:[20,100],rim:[10,30]};function U(e){let n=ln.exec(e??"");if(!n)return null;let t={width:Number(n[1]),profile:Number(n[2]),rim:Number(n[3])};return ae.every(o=>{let[i,a]=an[o];return t[o]>=i&&t[o]<=a})?t:null}function _(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 ue(e){return[_({width:e.width}),_({width:e.width,profile:e.profile}),_(e)]}var k=["alloy-wheel","tyre"],ce=["alloy-wheel"],F={"alloy-wheel":"Alloy wheels",tyre:"Tyres"};var ht=k.map(e=>({value:e,label:F[e]}));function pe(e){return e==null?[...ce]:Array.isArray(e)?k.filter(n=>e.includes(n)):[...ce]}var m=e=>e;function f(e){return m(e).kind==="tyre"?"tyre":"alloy-wheel"}function $(e){return m(e).brand??""}function de(e){return m(e).prices??void 0}function fe(e){return m(e).inStock!==!1}function me(e){let n=m(e),t=f(e)==="tyre"?n.rimDiameters:n.sizes;return Array.isArray(t)?t.filter(r=>typeof r=="number"&&Number.isFinite(r)):[]}function B(e){return f(e)==="tyre"?[]:(m(e).finishes??[]).filter(n=>typeof n?.family=="string").map(n=>({family:n.family,color:n.color??null}))}function he(e){return B(e).map(n=>n.family)}function ge(e){if(f(e)==="tyre")return[];let n=m(e);return Array.isArray(n.categories)?n.categories:n.process?[n.process]:[]}function ye(e){return f(e)==="tyre"?[]:m(e).spec?.pcds??[]}function Pe(e){return f(e)!=="tyre"?[]:m(e).tyreTypes??[]}function be(e){return f(e)!=="tyre"?[]:m(e).speedRatings??[]}function Se(e){if(f(e)!=="tyre")return[];let n=m(e).sizes;return Array.isArray(n)?n.map(t=>U(typeof t=="string"?t:null)).filter(t=>t!==null):[]}var W=e=>typeof e=="string"&&e?e:void 0;function H(e,n){return Object.hasOwn(e,n)?e[n]:void 0}function ke(e,n){return Object.hasOwn(e,n)}var xe=null;function Le(e,n){return n?e.replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g,(t,r)=>ke(n,r)?String(H(n,r)):t):e}function y(e,n){let t=xe?H(xe,e):void 0;if(typeof t=="function"){try{let r=W(t(n??{}));if(r)return r}catch{}return Le(e,n)}return Le(W(t)??e,n)}function Y(e){return(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}var w=(e,n,t,r)=>({default:e,min:n,max:t,step:r}),Lt=w(30,0,100,10),Tt=w(0,0,100,5),_t=w(100,0,100,5),Ft=w(2,0,4,.5);function Te(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.text=="string"?e.text.trim():""}var _e="homepage";var A=[{value:"page",label:"Page"},{value:"anchor",label:"Anchor"},{value:"blog",label:"Blog post",needs:"service"},{value:"product",label:"Product",needs:"commerce"},{value:"popup",label:"Popup"},{value:"custom",label:"Custom URL"}];function R(e){return e.offersCommerce&&e.offersService?A:A.filter(n=>!n.needs||(n.needs==="commerce"?e.offersCommerce:e.offersService))}var G="#popup:";function Fe(e){return`${G}${e}`}function we(e){return e.startsWith(G)&&e.slice(G.length).trim()||null}function P(e){return e===_e?"/":`/${e}`}function E(e){return`/journal/${e}`}function O(e){return`/wheels/${e}`}function I(e,n){return`${P(e)}#${n}`}function N(...e){let n=new Set,t=[];for(let r of e)for(let o of r?.content??[]){let i=Te(o?.props?.anchor);if(!i)continue;let a=Y(i);!a||n.has(a)||(n.add(a),t.push({slug:a,name:i}))}return t}function Ae(e){return/^\/wheels\/[^/?#]+(?:[?#].*)?$/.test(e)}var un=()=>({choosePage:y("Choose a page"),chooseSection:y("Choose a section"),noSections:y("No section anchors yet"),sectionHint:y("Jumps to a section on that page."),choosePost:y("Choose a post"),chooseProduct:y("Choose a product"),choosePopup:y("Choose a popup")});function C(e,n,t){if(!e)return"page";if(we(e))return"popup";if(e.startsWith("/journal/"))return"blog";if(Ae(e))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&&t.listingPaths.includes(t.targetOf(e))?"page":"custom"}function Re(e,n){let t=un(),r=e.pages.map(s=>({value:P(s.slug),label:s.title})),o=n?.pageOptions?n.pageOptions(r):r,i=o.map(s=>s.value),a=e.pages.map(s=>({label:s.title,options:N(...s.docs).map(u=>({value:I(s.slug,u.slug),label:u.name}))})).filter(s=>s.options.length>0),p=s=>{switch(s){case"page":return{type:"select",options:o,placeholder:t.choosePage};case"anchor":return{type:"groups",groups:a,placeholder:a.length?t.chooseSection:t.noSections};case"blog":return{type:"select",options:e.posts.map(u=>({value:E(u.slug),label:u.title||u.slug})),placeholder:t.choosePost};case"product":return{type:"select",options:e.products.map(u=>({value:u.href,label:u.name||u.href})),placeholder:t.chooseProduct};case"popup":return{type:"select",options:(e.popups??[]).map(u=>({value:Fe(u.slug),label:u.title||u.slug})),placeholder:t.choosePopup};case"custom":return{type:"text"}}},l=R(e.offers).map(s=>({value:s.value,label:y(s.label),target:p(s.value),...s.value==="anchor"?{hint:t.sectionHint}:{},...s.value==="blog"||s.value==="product"||s.value==="popup"?{hideWhenEmpty:!0}:{}}));if(!n)return{kinds:l,rules:{kindOf:s=>C(s,i),targetOf:s=>s,readFilter:()=>null,withFilter:s=>s}};let c=s=>{let u=n.withFilter(s,null);return n.listingPaths.includes(u)?u:s};return{kinds:l,rules:{kindOf:s=>C(s,i,{listingPaths:n.listingPaths,targetOf:c}),targetOf:c,readFilter:n.readFilter,withFilter:n.withFilter},filtersFor:s=>n.listingPaths.includes(s)?n.filtersFor(s):null}}var Ee=Object.freeze([]);function V(e,n){return e.length===0?e:e.filter(t=>t.kind===void 0||t.kind===n)}function Oe(e,n){let t=n==="filter"?"filterOrder":"cardOrder",r=new Map;for(let o of e){let i=o[t];if(typeof i!="number"||!Number.isFinite(i))continue;let a=r.get(o.fieldKey);(a===void 0||i<a)&&r.set(o.fieldKey,i)}return o=>o?r.get(o):void 0}function Ie(e,n,t,r){let o=new Map;for(let l of t){let c=l[r];typeof c=="number"&&o.set(l.fieldKey,c)}if(o.size===0)return e;let i=[],a=[];e.forEach((l,c)=>{let s=n(l);s&&(i.push(c),a.push({item:l,index:c,order:o.get(s)}))}),a.sort((l,c)=>l.order!==void 0&&c.order!==void 0?l.order-c.order||l.index-c.index:l.order!==void 0?-1:c.order!==void 0?1:l.index-c.index);let p=[...e];return i.forEach((l,c)=>{p[l]=a[c].item}),p.every((l,c)=>l===e[c])?e:p}function Ne(e){return pn(e,"filter")}var cn="collection";function q(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":cn},pcds:{"alloy-wheel":"pcd"},tyreTypes:{tyre:"tire_type"},speedRatings:{tyre:"speed_rating"}}[e]?.[n]}function pn(e,n){let t=new Set(e.filter(r=>r[n]===!1).map(r=>r.fieldKey));return r=>!r||!t.has(r)}function dn(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ce(e,n){let t=e?.[n];return dn(t)?t:null}function ve(e,n,t,r){if(t==null&&r==null)return!0;let o=Ce(e,n);return!(o===null||t!=null&&o<t||r!=null&&o>r)}function Ke(e){let n=e.spec?.lugs;return typeof n=="number"?n:null}var fn={recommended:"Recommended","price-asc":"Price \xB7 low to high","price-desc":"Price \xB7 high to low",new:"Newest",name:"Name A\u2013Z"},pr=Object.keys(fn);var j=["tyreSizes","brands","finishes","diameters","collections","pcds","tyreTypes","speedRatings"],Z={tyreSizes:["tyre"],brands:["alloy-wheel","tyre"],finishes:["alloy-wheel"],diameters:["alloy-wheel","tyre"],collections:["alloy-wheel"],pcds:["alloy-wheel"],tyreTypes:["tyre"],speedRatings:["tyre"]},mn={diameters:"tyreSizes"};function hn(e){if(e.length===0)return[];let n=j.filter(t=>e.every(r=>Z[t].includes(r)));return n.filter(t=>{let r=mn[t];return!r||!n.includes(r)})}function gn(e){let n=new Set;for(let t of e)n.add(f(t));return[...n]}var Me={tyreSizes:[],brands:[],finishes:[],diameters:[],collections:[],pcds:[],tyreTypes:[],speedRatings:[],priceMax:null,priceMin:null,inStockOnly:!1,kind:null,sort:"recommended",page:1};function yn(e,n,t,r=null,o="fail"){let i=f(e),a=p=>o==="fail"||(p==="lugs"?i==="alloy-wheel":Z[p].includes(i));if(r!=="kind"&&n.kind&&i!==n.kind)return!1;for(let p of j){if(r===p)continue;let l=n[p];if(l.length===0||!a(p))continue;let c=l.map(String);if(!ze(e,p).some(s=>c.includes(s)))return!1}if(r!=="lugs"&&n.lugs&&n.lugs.length>0&&a("lugs")){let p=Ke(e);if(p===null||!n.lugs.includes(p))return!1}return!(r!=="price"&&!ve(de(e),t,n.priceMin??null,n.priceMax)||r!=="inStock"&&n.inStockOnly&&!fe(e))}var Pn={tyreSizes:"Size",brands:"Brand",finishes:"Colour",diameters:"Size \xB7 diameter",collections:"Collection",pcds:"PCD \xB7 fitment",tyreTypes:"Tyre type",speedRatings:"Speed rating"};function ze(e,n){switch(n){case"tyreSizes":return[...new Set(Se(e).flatMap(ue))];case"brands":return $(e)?[$(e)]:[];case"finishes":return he(e);case"diameters":return me(e).map(String);case"collections":return ge(e);case"pcds":return ye(e);case"tyreTypes":return Pe(e);case"speedRatings":return be(e)}}function bn(e){let n=new Map;for(let t of e)for(let r of B(t))r.color&&!n.has(r.family)&&n.set(r.family,r.color);return n}function De(e,n,t,r=gn(e),o=Ee,i="fail"){let a=u=>kn(u,r,o),p=bn(e),c=(i==="pass"?j.filter(u=>r.some(S=>Z[u].includes(S))):hn(r)).filter(u=>u!=="tyreSizes").filter(a).map(u=>{let S=n[u].map(String),oe=new Set,z=new Map,L=new Map;for(let d of e){let b=ze(d,u);for(let h of b)oe.add(h);for(let h of new Set(b))L.set(h,(L.get(h)??0)+1);if(yn(d,n,t,u,i))for(let h of new Set(b))z.set(h,(z.get(h)??0)+1)}let Je=[...oe].map(d=>({value:d,label:u==="diameters"?`${d}\u2033`:d,count:z.get(d)??0,checked:S.includes(d),swatch:u==="finishes"?p.get(d)??null:null})).sort((d,b)=>{if(u==="diameters")return Number(d.value)-Number(b.value);let h=(L.get(b.value)??0)-(L.get(d.value)??0);return h!==0?h:d.value.localeCompare(b.value)});return{key:u,label:Pn[u],options:Je}}).filter(u=>u.options.length>Sn),s=[];for(let u of c){let S=xn(u.key,r,o);S!==void 0&&s.push({fieldKey:u.key,filterOrder:S})}return[...Ie(c,u=>u.key,s,"filterOrder")]}var Sn=1;function Ue(e){return e.showCollection===!1?["collections"]:[]}function kn(e,n,t){return n.length===0||t.length===0?!0:n.some(r=>Ne(V(t,r))(q(e,r)))}function xn(e,n,t){if(t.length===0)return;let r;for(let o of n){let i=Oe(V(t,o),"filter")(q(e,o));i!==void 0&&(r===void 0||i<r)&&(r=i)}return r}var X={tyreSizes:"tyreSize",brands:"brand",finishes:"colour",diameters:"size",collections:"collection",pcds:"pcd",tyreTypes:"tyreType",speedRatings:"speed"},Q="type";var $e=e=>!!e&&typeof e=="object"&&!Array.isArray(e),v=e=>$e(e)&&typeof e.type=="string"&&$e(e.props),J=e=>Array.isArray(e)&&e.length>0&&e.every(v);function Be(e,n){let t=null;for(let[r,o]of Object.entries(e.props??{})){if(!J(o))continue;let i=n(o,r);i!==o&&((t??={...e.props})[r]=i)}return t?{...e,props:t}:e}var We="FilterBlock";var He="AlloyWheelsListing";function Ln(e){let n=e??{},t=[];Array.isArray(n.content)&&t.push(n.content);for(let r of Object.values(n.zones??{}))Array.isArray(r)&&t.push(r);return t}function Tn(e){let n=[],t=(r,o)=>{let i=[r,...o];for(let a of r)v(a)&&(n.push({node:a,order:n.length,lists:i}),Be(a,p=>(t(p,i),p)))};for(let r of Ln(e))t(r,[]);return n}function Ye(e){return Tn(e).map(n=>n.node)}function Ge(e){return D(e.trim())}var x="/wheels",K="Products";function Ve(e,n){return n>1?`${K} \xB7 ${e}`:K}function ee(...e){for(let n of[He,We])for(let t of e){let r=Ye({content:t?.content}).find(o=>o.type===n);if(r)return r.props??{}}return null}function M(...e){return ee(...e)!==null}function qe(e,n){let t=e.filter(r=>M(...r.docs)).map(r=>P(r.slug));return n.fallback&&!t.includes(x)?[...t,x]:t}var ne=[Q,...Object.entries(X).filter(([e])=>e!=="tyreSizes").map(([,e])=>e)];function je(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 _n(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return e}}function Ze(e){let n=new URLSearchParams(je(e).query);for(let t of ne){let r=n.get(t);if(r)return{param:t,value:r}}return null}function te(e,n){let{path:t,query:r,hash:o}=je(e),i=r.split("&").filter(a=>a&&!ne.includes(_n(a.split("=")[0])));return n?.value&&i.push(`${encodeURIComponent(n.param)}=${encodeURIComponent(n.value)}`),`${t}${i.length?`?${i.join("&")}`:""}${o}`}function Xe(e,n){let t=te(e,null);return n.includes(t)?t:e}function Fn(e,n,t=[]){return C(e,n,{listingPaths:t,targetOf:r=>Xe(r,t)})}function wn(e){return Array.isArray(e)?e.filter(n=>typeof n?.kind=="string"&&typeof n.field_key=="string").map(n=>({kind:n.kind,fieldKey:n.field_key,...typeof n.filter=="boolean"?{filter:n.filter}:{},filterOrder:n.filter_order??null})):[]}var Qe="Product type",An="AUD";function re(e,n){let t=n.listing??{},r=pe(t.kinds),o=e.filter(l=>r.includes(f(l))),i=Ue(t),a=De(o,Me,An,r,n.fieldUsage).filter(l=>!i.includes(l.key)).map(l=>({param:X[l.key],label:l.label,values:l.options.filter(c=>!c.value.includes(",")).map(c=>({value:c.value,label:c.label}))})).filter(l=>l.values.length>0),p=k.filter(l=>r.includes(l)&&o.some(c=>f(c)===l));return p.length>1&&a.unshift({param:Q,label:Qe,values:p.map(l=>({value:l,label:F[l]}))}),a}function Rn(e){return n=>{let t=qe(n,{fallback:e.offersCommerce}),r=n.filter(o=>M(...o.docs)).length;return{listingPaths:t,pageOptions:o=>{let i=o.map(a=>{let p=n.find(l=>P(l.slug)===a.value);return p&&M(...p.docs)?{...a,label:Ve(p.title,r)}:a});return r===0&&e.offersCommerce&&!i.some(a=>a.value===x)&&i.push({value:x,label:K}),i},filtersFor:o=>{if(!t.includes(o))return null;let i=n.find(a=>P(a.slug)===o);return re(e.catalogue,{listing:i?ee(...i.docs):null,fieldUsage:e.fieldUsage})},readFilter:Ze,withFilter:te}}}function En(e){let n=Rn({catalogue:e.catalogue,fieldUsage:e.fieldUsage,offersCommerce:e.offers.offersCommerce})(e.pages),t=Re({pages:e.pages,posts:e.posts,products:e.products.map(r=>({href:O(r.slug),name:r.name||r.slug})),offers:e.offers},n);return{...t,rules:{...t.rules,isSafe:Ge},filtersFor:t.filtersFor??(()=>null)}}function Cr(e,n){return re(e,n)}export{x as BUILT_IN_LISTING_PATH,A as LINK_KINDS,ne as LISTING_FILTER_PARAMS,K as LISTING_PAGE_LABEL,Qe as PRODUCT_TYPE_FILTER_LABEL,I as anchorPath,wn as fieldUsageFromAdminRows,Fn as inferLinkKind,M as isProductListingPage,Ge as isSafeLink,R as linkKindsFor,En as linkPickerSetup,Cr as listingFilterFields,ee as listingNode,Ve as listingPageLabel,Xe as listingTarget,N as pageAnchors,P as pagePath,E as postPath,qe as productListingPaths,Ze as readListingFilter,O as wheelPath,te as withListingFilter};
|
|
1
|
+
var g={bold:{open:"**",close:"**",placeholder:"bold text"},italic:{open:"_",close:"_",placeholder:"italic text"},strike:{open:"~~",close:"~~",placeholder:"struck out"},code:{open:"`",close:"`",placeholder:"code"},highlight:{open:"==",close:"==",placeholder:"highlighted text"},quiet:{open:"^^",close:"^^",placeholder:"quiet text"},underline:{open:"[",close:"]{underline}",placeholder:"underlined text"},sup:{open:"[",close:"]{sup}",placeholder:"superscript"},sub:{open:"[",close:"]{sub}",placeholder:"subscript"}};var ie=["main","text","background","muted"],en=[...ie,"surface"];var nn={bold:g.bold.placeholder,italic:g.italic.placeholder,strike:g.strike.placeholder,code:g.code.placeholder,highlight:g.highlight.placeholder,quiet:g.quiet.placeholder,link:"link text",underline:g.underline.placeholder,sup:g.sup.placeholder,sub:g.sub.placeholder,color:"colored text",style:"styled text"};var se=[{style:"bold",label:"B",name:"Strong",title:"Strong \xB7 **words** \xB7 \u2318B",shortcut:"b"},{style:"italic",label:"I",name:"Italic",title:"Italic \xB7 _words_ \xB7 \u2318I",shortcut:"i"},{style:"strike",label:"S",name:"Strikethrough",title:"Strikethrough \xB7 ~~words~~"},{style:"highlight",label:"\u25C6",name:"Emphasis",title:"Emphasis \xB7 ==words=="},{style:"quiet",label:"a",name:"Quiet",title:"Quiet \xB7 ^^words^^"},{style:"code",label:"\u2039\u203A",name:"Code",title:"Code"},{style:"link",label:"\u{1F517}",name:"Link",title:"Link \xB7 [words](https://\u2026) \xB7 \u2318K",shortcut:"k"},{style:"bullet",label:"\u2022",name:"Bulleted list",title:"Bulleted list"},{style:"number",label:"1.",name:"Numbered list",title:"Numbered list"},{style:"quote",label:"\u275D",name:"Quote",title:"Quote"},{style:"clear",label:"T\xD7",name:"Clear marks",title:"Clear marks \xB7 \u2318\u21E7X",shortcut:"shift+x"}];var T=[{open:"**",close:"**",kind:"bold"},{open:"==",close:"==",kind:"highlight"},{open:"~~",close:"~~",kind:"strike"},{open:"_",close:"_",kind:"italic",wordBoundary:!0},{open:"^^",close:"^^",kind:"quiet"},{open:"@@",close:"@@",kind:"highlight"},{open:"++",close:"++",kind:"bold",wordStart:!0}],le=["highlight","quiet"],tn=se.map(e=>e.style).filter(e=>T.some(n=>n.kind===e)).filter(e=>!le.includes(e)),rn=[...T,{open:"*",close:"*",kind:"accent"}],on=[...T,{open:"*",close:"*",kind:"accent"},{open:"#",close:"#",kind:"bold",notBefore:"0123456789"},{open:"[",close:"]",kind:"italic",notBefore:"(",notBeforeBlock:!0}];var sn=["http","https","mailto","tel"];function D(e){if(e===""||/[\s\u0000-\u001f\u007f]/.test(e))return!1;let n=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!n||sn.includes(n[1].toLowerCase())}var ae=["width","profile","rim"];var ln=/^\s*(\d{2,3})\s*\/\s*(\d{2,3})\s*[A-Za-z]*\s*(\d{2}(?:\.\d+)?)\s*$/,an={width:[100,500],profile:[20,100],rim:[10,30]};function U(e){let n=ln.exec(e??"");if(!n)return null;let t={width:Number(n[1]),profile:Number(n[2]),rim:Number(n[3])};return ae.every(o=>{let[i,a]=an[o];return t[o]>=i&&t[o]<=a})?t:null}function _(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 ue(e){return[_({width:e.width}),_({width:e.width,profile:e.profile}),_(e)]}var k=["alloy-wheel","tyre"],ce=["alloy-wheel"],F={"alloy-wheel":"Alloy wheels",tyre:"Tyres"};var ht=k.map(e=>({value:e,label:F[e]}));function pe(e){return e==null?[...ce]:Array.isArray(e)?k.filter(n=>e.includes(n)):[...ce]}var m=e=>e;function f(e){return m(e).kind==="tyre"?"tyre":"alloy-wheel"}function $(e){return m(e).brand??""}function de(e){return m(e).prices??void 0}function fe(e){return m(e).inStock!==!1}function me(e){let n=m(e),t=f(e)==="tyre"?n.rimDiameters:n.sizes;return Array.isArray(t)?t.filter(r=>typeof r=="number"&&Number.isFinite(r)):[]}function B(e){return f(e)==="tyre"?[]:(m(e).finishes??[]).filter(n=>typeof n?.family=="string").map(n=>({family:n.family,color:n.color??null}))}function he(e){return B(e).map(n=>n.family)}function ge(e){if(f(e)==="tyre")return[];let n=m(e);return Array.isArray(n.categories)?n.categories:n.process?[n.process]:[]}function ye(e){return f(e)==="tyre"?[]:m(e).spec?.pcds??[]}function Pe(e){return f(e)!=="tyre"?[]:m(e).tyreTypes??[]}function be(e){return f(e)!=="tyre"?[]:m(e).speedRatings??[]}function Se(e){if(f(e)!=="tyre")return[];let n=m(e).sizes;return Array.isArray(n)?n.map(t=>U(typeof t=="string"?t:null)).filter(t=>t!==null):[]}var W=e=>typeof e=="string"&&e?e:void 0;function H(e,n){return Object.hasOwn(e,n)?e[n]:void 0}function ke(e,n){return Object.hasOwn(e,n)}var xe=null;function Le(e,n){return n?e.replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g,(t,r)=>ke(n,r)?String(H(n,r)):t):e}function y(e,n){let t=xe?H(xe,e):void 0;if(typeof t=="function"){try{let r=W(t(n??{}));if(r)return r}catch{}return Le(e,n)}return Le(W(t)??e,n)}function Y(e){return(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}var w=(e,n,t,r)=>({default:e,min:n,max:t,step:r}),Lt=w(30,0,100,10),Tt=w(0,0,100,5),_t=w(100,0,100,5),Ft=w(2,0,4,.5);function Te(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.text=="string"?e.text.trim():""}var _e="homepage";var A=[{value:"page",label:"Page"},{value:"anchor",label:"Anchor"},{value:"blog",label:"Blog post",needs:"service"},{value:"product",label:"Product",needs:"commerce"},{value:"popup",label:"Popup"},{value:"custom",label:"Custom URL"}];function R(e){return e.offersCommerce&&e.offersService?A:A.filter(n=>!n.needs||(n.needs==="commerce"?e.offersCommerce:e.offersService))}var G="#popup:";function Fe(e){return`${G}${e}`}function we(e){return e.startsWith(G)&&e.slice(G.length).trim()||null}function P(e){return e===_e?"/":`/${e}`}function E(e){return`/journal/${e}`}function O(e){return`/wheels/${e}`}function I(e,n){return`${P(e)}#${n}`}function N(...e){let n=new Set,t=[];for(let r of e)for(let o of r?.content??[]){let i=Te(o?.props?.anchor);if(!i)continue;let a=Y(i);!a||n.has(a)||(n.add(a),t.push({slug:a,name:i}))}return t}function Ae(e){return/^\/wheels\/[^/?#]+(?:[?#].*)?$/.test(e)}var un=()=>({choosePage:y("Choose a page"),chooseSection:y("Choose a section"),noSections:y("No section anchors yet"),sectionHint:y("Jumps to a section on that page."),choosePost:y("Choose a post"),chooseProduct:y("Choose a product"),choosePopup:y("Choose a popup")});function C(e,n,t){if(!e)return"page";if(we(e))return"popup";if(e.startsWith("/journal/"))return"blog";if(Ae(e))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&&t.listingPaths.includes(t.targetOf(e))?"page":"custom"}function Re(e,n){let t=un(),r=e.pages.map(s=>({value:P(s.slug),label:s.title})),o=n?.pageOptions?n.pageOptions(r):r,i=o.map(s=>s.value),a=e.pages.map(s=>({label:s.title,options:N(...s.docs).map(u=>({value:I(s.slug,u.slug),label:u.name}))})).filter(s=>s.options.length>0),p=s=>{switch(s){case"page":return{type:"select",options:o,placeholder:t.choosePage};case"anchor":return{type:"groups",groups:a,placeholder:a.length?t.chooseSection:t.noSections};case"blog":return{type:"select",options:e.posts.map(u=>({value:E(u.slug),label:u.title||u.slug})),placeholder:t.choosePost};case"product":return{type:"select",options:e.products.map(u=>({value:u.href,label:u.name||u.href})),placeholder:t.chooseProduct};case"popup":return{type:"select",options:(e.popups??[]).map(u=>({value:Fe(u.slug),label:u.title||u.slug})),placeholder:t.choosePopup};case"custom":return{type:"text"}}},l=R(e.offers).map(s=>({value:s.value,label:y(s.label),target:p(s.value),...s.value==="anchor"?{hint:t.sectionHint}:{},...s.value==="blog"||s.value==="product"||s.value==="popup"?{hideWhenEmpty:!0}:{}}));if(!n)return{kinds:l,rules:{kindOf:s=>C(s,i),targetOf:s=>s,readFilter:()=>null,withFilter:s=>s}};let c=s=>{let u=n.withFilter(s,null);return n.listingPaths.includes(u)?u:s};return{kinds:l,rules:{kindOf:s=>C(s,i,{listingPaths:n.listingPaths,targetOf:c}),targetOf:c,readFilter:n.readFilter,withFilter:n.withFilter},filtersFor:s=>n.listingPaths.includes(s)?n.filtersFor(s):null}}var Ee=Object.freeze([]);function V(e,n){return e.length===0?e:e.filter(t=>t.kind===void 0||t.kind===n)}function Oe(e,n){let t=n==="filter"?"filterOrder":"cardOrder",r=new Map;for(let o of e){let i=o[t];if(typeof i!="number"||!Number.isFinite(i))continue;let a=r.get(o.fieldKey);(a===void 0||i<a)&&r.set(o.fieldKey,i)}return o=>o?r.get(o):void 0}function Ie(e,n,t,r){let o=new Map;for(let l of t){let c=l[r];typeof c=="number"&&o.set(l.fieldKey,c)}if(o.size===0)return e;let i=[],a=[];e.forEach((l,c)=>{let s=n(l);s&&(i.push(c),a.push({item:l,index:c,order:o.get(s)}))}),a.sort((l,c)=>l.order!==void 0&&c.order!==void 0?l.order-c.order||l.index-c.index:l.order!==void 0?-1:c.order!==void 0?1:l.index-c.index);let p=[...e];return i.forEach((l,c)=>{p[l]=a[c].item}),p.every((l,c)=>l===e[c])?e:p}function Ne(e){return pn(e,"filter")}var cn="collection";function q(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":cn},pcds:{"alloy-wheel":"pcd"},tyreTypes:{tyre:"tire_type"},speedRatings:{tyre:"speed_rating"}}[e]?.[n]}function pn(e,n){let t=new Set(e.filter(r=>r[n]===!1).map(r=>r.fieldKey));return r=>!r||!t.has(r)}function dn(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ce(e,n){let t=e?.[n];return dn(t)?t:null}function ve(e,n,t,r){if(t==null&&r==null)return!0;let o=Ce(e,n);return!(o===null||t!=null&&o<t||r!=null&&o>r)}function Ke(e){let n=e.spec?.lugs;return typeof n=="number"?n:null}var fn={recommended:"Recommended","price-asc":"Price \xB7 low to high","price-desc":"Price \xB7 high to low",new:"Newest",name:"Name A\u2013Z"},pr=Object.keys(fn);var j=["tyreSizes","brands","finishes","diameters","collections","pcds","tyreTypes","speedRatings"],Z={tyreSizes:["tyre"],brands:["alloy-wheel","tyre"],finishes:["alloy-wheel"],diameters:["alloy-wheel","tyre"],collections:["alloy-wheel"],pcds:["alloy-wheel"],tyreTypes:["tyre"],speedRatings:["tyre"]},mn={diameters:"tyreSizes"};function hn(e){if(e.length===0)return[];let n=j.filter(t=>e.every(r=>Z[t].includes(r)));return n.filter(t=>{let r=mn[t];return!r||!n.includes(r)})}function gn(e){let n=new Set;for(let t of e)n.add(f(t));return[...n]}var Me={tyreSizes:[],brands:[],finishes:[],diameters:[],collections:[],pcds:[],tyreTypes:[],speedRatings:[],priceMax:null,priceMin:null,inStockOnly:!1,kind:null,sort:"recommended",page:1};function yn(e,n,t,r=null,o="fail"){let i=f(e),a=p=>o==="fail"||(p==="lugs"?i==="alloy-wheel":Z[p].includes(i));if(r!=="kind"&&n.kind&&i!==n.kind)return!1;for(let p of j){if(r===p)continue;let l=n[p];if(l.length===0||!a(p))continue;let c=l.map(String);if(!ze(e,p).some(s=>c.includes(s)))return!1}if(r!=="lugs"&&n.lugs&&n.lugs.length>0&&a("lugs")){let p=Ke(e);if(p===null||!n.lugs.includes(p))return!1}return!(r!=="price"&&!ve(de(e),t,n.priceMin??null,n.priceMax)||r!=="inStock"&&n.inStockOnly&&!fe(e))}var Pn={tyreSizes:"Size",brands:"Brand",finishes:"Colour",diameters:"Size \xB7 diameter",collections:"Collection",pcds:"PCD \xB7 fitment",tyreTypes:"Tyre type",speedRatings:"Speed rating"};function ze(e,n){switch(n){case"tyreSizes":return[...new Set(Se(e).flatMap(ue))];case"brands":return $(e)?[$(e)]:[];case"finishes":return he(e);case"diameters":return me(e).map(String);case"collections":return ge(e);case"pcds":return ye(e);case"tyreTypes":return Pe(e);case"speedRatings":return be(e)}}function bn(e){let n=new Map;for(let t of e)for(let r of B(t))r.color&&!n.has(r.family)&&n.set(r.family,r.color);return n}function De(e,n,t,r=gn(e),o=Ee,i="fail"){let a=u=>kn(u,r,o),p=bn(e),c=(i==="pass"?j.filter(u=>r.some(S=>Z[u].includes(S))):hn(r)).filter(u=>u!=="tyreSizes").filter(a).map(u=>{let S=n[u].map(String),oe=new Set,z=new Map,L=new Map;for(let d of e){let b=ze(d,u);for(let h of b)oe.add(h);for(let h of new Set(b))L.set(h,(L.get(h)??0)+1);if(yn(d,n,t,u,i))for(let h of new Set(b))z.set(h,(z.get(h)??0)+1)}let Je=[...oe].map(d=>({value:d,label:u==="diameters"?`${d}\u2033`:d,count:z.get(d)??0,checked:S.includes(d),swatch:u==="finishes"?p.get(d)??null:null})).sort((d,b)=>{if(u==="diameters")return Number(d.value)-Number(b.value);let h=(L.get(b.value)??0)-(L.get(d.value)??0);return h!==0?h:d.value.localeCompare(b.value)});return{key:u,label:Pn[u],options:Je}}).filter(u=>u.options.length>Sn),s=[];for(let u of c){let S=xn(u.key,r,o);S!==void 0&&s.push({fieldKey:u.key,filterOrder:S})}return[...Ie(c,u=>u.key,s,"filterOrder")]}var Sn=1;function Ue(e){return e.showCollection===!1?["collections"]:[]}function kn(e,n,t){return n.length===0||t.length===0?!0:n.some(r=>Ne(V(t,r))(q(e,r)))}function xn(e,n,t){if(t.length===0)return;let r;for(let o of n){let i=Oe(V(t,o),"filter")(q(e,o));i!==void 0&&(r===void 0||i<r)&&(r=i)}return r}var X={tyreSizes:"tyreSize",brands:"brand",finishes:"colour",diameters:"size",collections:"collection",pcds:"pcd",tyreTypes:"tyreType",speedRatings:"speed"},Q="type";var $e=e=>!!e&&typeof e=="object"&&!Array.isArray(e),v=e=>$e(e)&&typeof e.type=="string"&&$e(e.props);var J=e=>Array.isArray(e)&&e.length>0&&e.every(v);function Be(e,n){let t=null;for(let[r,o]of Object.entries(e.props??{})){if(!J(o))continue;let i=n(o,r);i!==o&&((t??={...e.props})[r]=i)}return t?{...e,props:t}:e}var We="FilterBlock";var He="AlloyWheelsListing";function Ln(e){let n=e??{},t=[];Array.isArray(n.content)&&t.push(n.content);for(let r of Object.values(n.zones??{}))Array.isArray(r)&&t.push(r);return t}function Tn(e){let n=[],t=(r,o)=>{let i=[r,...o];for(let a of r)v(a)&&(n.push({node:a,order:n.length,lists:i}),Be(a,p=>(t(p,i),p)))};for(let r of Ln(e))t(r,[]);return n}function Ye(e){return Tn(e).map(n=>n.node)}function Ge(e){return D(e.trim())}var x="/wheels",K="Products";function Ve(e,n){return n>1?`${K} \xB7 ${e}`:K}function ee(...e){for(let n of[He,We])for(let t of e){let r=Ye({content:t?.content}).find(o=>o.type===n);if(r)return r.props??{}}return null}function M(...e){return ee(...e)!==null}function qe(e,n){let t=e.filter(r=>M(...r.docs)).map(r=>P(r.slug));return n.fallback&&!t.includes(x)?[...t,x]:t}var ne=[Q,...Object.entries(X).filter(([e])=>e!=="tyreSizes").map(([,e])=>e)];function je(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 _n(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return e}}function Ze(e){let n=new URLSearchParams(je(e).query);for(let t of ne){let r=n.get(t);if(r)return{param:t,value:r}}return null}function te(e,n){let{path:t,query:r,hash:o}=je(e),i=r.split("&").filter(a=>a&&!ne.includes(_n(a.split("=")[0])));return n?.value&&i.push(`${encodeURIComponent(n.param)}=${encodeURIComponent(n.value)}`),`${t}${i.length?`?${i.join("&")}`:""}${o}`}function Xe(e,n){let t=te(e,null);return n.includes(t)?t:e}function Fn(e,n,t=[]){return C(e,n,{listingPaths:t,targetOf:r=>Xe(r,t)})}function wn(e){return Array.isArray(e)?e.filter(n=>typeof n?.kind=="string"&&typeof n.field_key=="string").map(n=>({kind:n.kind,fieldKey:n.field_key,...typeof n.filter=="boolean"?{filter:n.filter}:{},filterOrder:n.filter_order??null})):[]}var Qe="Product type",An="AUD";function re(e,n){let t=n.listing??{},r=pe(t.kinds),o=e.filter(l=>r.includes(f(l))),i=Ue(t),a=De(o,Me,An,r,n.fieldUsage).filter(l=>!i.includes(l.key)).map(l=>({param:X[l.key],label:l.label,values:l.options.filter(c=>!c.value.includes(",")).map(c=>({value:c.value,label:c.label}))})).filter(l=>l.values.length>0),p=k.filter(l=>r.includes(l)&&o.some(c=>f(c)===l));return p.length>1&&a.unshift({param:Q,label:Qe,values:p.map(l=>({value:l,label:F[l]}))}),a}function Rn(e){return n=>{let t=qe(n,{fallback:e.offersCommerce}),r=n.filter(o=>M(...o.docs)).length;return{listingPaths:t,pageOptions:o=>{let i=o.map(a=>{let p=n.find(l=>P(l.slug)===a.value);return p&&M(...p.docs)?{...a,label:Ve(p.title,r)}:a});return r===0&&e.offersCommerce&&!i.some(a=>a.value===x)&&i.push({value:x,label:K}),i},filtersFor:o=>{if(!t.includes(o))return null;let i=n.find(a=>P(a.slug)===o);return re(e.catalogue,{listing:i?ee(...i.docs):null,fieldUsage:e.fieldUsage})},readFilter:Ze,withFilter:te}}}function En(e){let n=Rn({catalogue:e.catalogue,fieldUsage:e.fieldUsage,offersCommerce:e.offers.offersCommerce})(e.pages),t=Re({pages:e.pages,posts:e.posts,products:e.products.map(r=>({href:O(r.slug),name:r.name||r.slug})),offers:e.offers},n);return{...t,rules:{...t.rules,isSafe:Ge},filtersFor:t.filtersFor??(()=>null)}}function vr(e,n){return re(e,n)}export{x as BUILT_IN_LISTING_PATH,A as LINK_KINDS,ne as LISTING_FILTER_PARAMS,K as LISTING_PAGE_LABEL,Qe as PRODUCT_TYPE_FILTER_LABEL,I as anchorPath,wn as fieldUsageFromAdminRows,Fn as inferLinkKind,M as isProductListingPage,Ge as isSafeLink,R as linkKindsFor,En as linkPickerSetup,vr as listingFilterFields,ee as listingNode,Ve as listingPageLabel,Xe as listingTarget,N as pageAnchors,P as pagePath,E as postPath,qe as productListingPaths,Ze as readListingFilter,O as wheelPath,te as withListingFilter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as n,jsxs as g}from"react/jsx-runtime";import{useCallback as
|
|
1
|
+
"use client";import{jsx as n,jsxs as g}from"react/jsx-runtime";import{useCallback as f,useEffect as m,useMemo as h,useState as d}from"react";import{safeLocalStorage as w}from"efficient-web-builder/format/lib/safe-storage";import{bannerWords as N,CONSENT_RULES as O,visitorRegion as P}from"../lib/consent/rules.js";import{userZone as x}from"efficient-shell/format";import{browserSendsGpc as E,NOT_ASKED as H,readStoredChoice as R,resolveConsent as _,setConsent as j,writeStoredChoice as A}from"../lib/consent/choice.js";import{COUNTRY_STORAGE_KEY as T,useActiveCountry as k}from"./CurrencyContext.js";import{ConsentBannerView as G}from"./ConsentBanner.js";import{ConsentPanelView as V,NoTrackingPanelView as D}from"./ConsentPanel.js";import{ConsentControlsContext as I,ConsentStateContext as K,PENDING as L}from"./ConsentContext.js";function Q({consent:e,children:u}){const[o,p]=d(e.enabled?L:H),[r,C]=d(!e.enabled),[l,t]=d(!1),v=k(),a=f(()=>{const c=P(x()??"",w.getItem(T));return _({asked:e.enabled,region:c,stored:R(),gpc:E()})},[e.enabled]);m(()=>{p(a()),C(!0)},[a,v]),m(()=>{j(o)},[o]);const i=f(c=>{A(c),p(a()),t(!1)},[a]),s=O[o.region],y=h(()=>({state:o,rule:s,ready:r,openPanel:()=>t(!0)}),[o,s,r]),b=e.enabled&&r&&o.model==="opt-in"&&!o.chosen,S=e.enabled&&r&&o.model==="opt-out"&&!o.chosen&&!o.gpc&&e.noticeOptOut;return n(K.Provider,{value:o,children:g(I.Provider,{value:y,children:[u,(b||S)&&!l&&n(G,{model:o.model,words:N(s,e.brand,e.tags),layout:e.layout,privacyHref:e.privacyHref,onAccept:()=>i({analytics:!0,ads:!0}),onReject:()=>i({analytics:!1,ads:!1}),onChoose:()=>t(!0)}),!e.enabled&&n(D,{open:l,privacyHref:e.privacyHref,onClose:()=>t(!1)}),e.enabled&&r&&n(V,{open:l,rule:s,analytics:o.analytics,ads:o.ads,gpc:o.gpc,privacyHref:e.privacyHref,onSave:i,onClose:()=>t(!1)})]})})}export{Q as ConsentProvider};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { type EventPost } from "efficient-web-builder/render/components/PostCard";
|
|
2
|
+
import { EVENTS_LAYOUT_COUNT } from "../lib/content/post-list-continue.js";
|
|
3
|
+
import { type ViewTier } from "efficient-easel/screen/lib/content/view-tiers";
|
|
4
|
+
export { EVENTS_LAYOUT_COUNT };
|
|
2
5
|
export type { EventPost };
|
|
3
6
|
export type EventCard = EventPost & {
|
|
4
7
|
href?: string;
|
|
@@ -18,7 +21,6 @@ export declare const EVENTS_LAYOUT_FEATURED = "featured";
|
|
|
18
21
|
export declare const EVENTS_LAYOUT_TABS = "tabs";
|
|
19
22
|
export declare const EVENTS_LAYOUT_PORTRAIT = "portrait";
|
|
20
23
|
export declare const EVENTS_LAYOUT_SPREAD = "spread";
|
|
21
|
-
export declare const EVENTS_LAYOUT_COUNT = "count";
|
|
22
24
|
export declare const EVENTS_LAYOUTS: readonly [{
|
|
23
25
|
readonly label: "Even grid";
|
|
24
26
|
readonly value: "even";
|
|
@@ -48,6 +50,7 @@ export declare const EVENTS_FEATURED_WIDTH: {
|
|
|
48
50
|
readonly unit: "of 12";
|
|
49
51
|
};
|
|
50
52
|
export interface EventsProps {
|
|
53
|
+
viewHidden?: Readonly<Record<ViewTier, boolean>>;
|
|
51
54
|
num?: string;
|
|
52
55
|
title?: string;
|
|
53
56
|
link?: {
|
|
@@ -75,4 +78,4 @@ export interface EventsProps {
|
|
|
75
78
|
ownerId?: string;
|
|
76
79
|
}
|
|
77
80
|
export declare function matchesName(title: string, typed: string): boolean;
|
|
78
|
-
export default function Events(
|
|
81
|
+
export default function Events(props: EventsProps): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as s,jsxs as c}from"react/jsx-runtime";import{Children as Re,useState as re}from"react";import{servedWords as ke}from"../lib/content/served-lists.js";import{TAB_PILLS as j}from"../lib/content/tab-strip.js";import{useScopeClass as Fe}from"../lib/use-scope-class.js";import{containerGapProps as Ie}from"efficient-web-builder/format/lib/content/container-gap";import Me from"efficient-web-builder/render/components/SectionHeader";import w from"efficient-web-builder/render/components/PostCard";import De from"efficient-web-builder/render/components/PostDate";import ze from"efficient-web-builder/render/components/Placeholder";import{SiteLink as O}from"efficient-web-builder/render/lib/site-runtime";import{renderGold as N,renderHeadline as C}from"efficient-web-builder/render/components/goldPhrases";import{say as L}from"efficient-web-builder/format/lib/editor-words";import{cardImageShapeTokens as Ue}from"efficient-web-builder/format/lib/content/card-image-shape";import{SITE_COLUMN as B}from"efficient-web-builder/format/lib/content/page-width";import{fillRowCss as Pe}from"../lib/sections/fill-row.js";import{FRAME_120 as le,FRAME_ROOM_COUNT as Ye,FRAME_ROOM_OWN_BOX as Ve,FRAME_ROOM_Y as je,framedBandPad as W,headIsEmpty as Be,withBandClasses as K}from"../lib/sections/band-padding.js";import{HideTaker as G}from"efficient-web-builder/render/components/ViewHideRoot";import{CardTemplateRows as We,useCardRow as Ke}from"efficient-web-builder/render/components/CardRowContext";import{SECTION_FILL_CLASS as Ge}from"efficient-web-builder/format/lib/content/section-min-height";import{postPath as oe}from"efficient-web-builder/format/lib/links/page-link-rules";import{EVENTS_FEATURED_DARKEN as Xe,EVENTS_FEATURED_DARKEN_STYLE as He,EVENTS_FEATURED_PLACEMENT as Je}from"../lib/content/events-featured-look.js";const qe=4;function Qt(e){return ke(e,qe)}function Zt(e){if(!e||typeof e!="object"||Array.isArray(e))return;const n={};for(const[t,r]of Object.entries(e))if(t.trim()){if(typeof r=="string")r.trim()&&(n[t]=r.trim());else if(Array.isArray(r)){const l=r.filter(d=>typeof d=="string"&&!!d.trim()).map(d=>d.trim());l.length&&(n[t]=l)}}return Object.keys(n).length?n:void 0}function ie(e,n){const t=e.facets?.[n];return t===void 0?[]:typeof t=="string"?[t]:t}const Qe=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});function Ze(e){const n=[],t=new Map;for(const r of e)for(const l of Object.keys(r.facets??{})){t.has(l)||(n.push(l),t.set(l,new Set));for(const d of ie(r,l))t.get(l).add(d)}return n.map(r=>({label:r,values:[...t.get(r)].sort(Qe.compare)}))}function et(e,n){return Object.entries(n).every(([t,r])=>r===""||ie(e,t).includes(r))}const ce=3,de="featured",fe="tabs",me="portrait",v="spread",pe="count",es=[{label:"Even grid",value:"even"},{label:"Featured first",value:de},{label:"Tabs",value:fe},{label:"Photo cards",value:me},{label:"Staggered spread",value:v},{label:"Count",value:pe}],tt=[me,v],ts="even",X={min:2,max:11,step:1,fallback:7,unit:"of 12"},st=Je,nt=Xe,at=He;function rt(e){const n=typeof e=="number"?e:Number.parseFloat(String(e??"")),t=Number.isFinite(n)?Math.min(X.max,Math.max(X.min,Math.round(n))):X.fallback;return`${t}fr ${12-t}fr`}const ge={1:"grid-cols-1",2:"grid-cols-2 max-view-wide:grid-cols-1",3:"grid-cols-3 max-view-wide:grid-cols-1",4:"grid-cols-4 max-view-desktop:grid-cols-2 max-view-wide:grid-cols-1"},lt={2:"grid-cols-2",3:"grid-cols-3 max-view-wide:grid-cols-2",4:"grid-cols-4 max-view-desktop:grid-cols-3 max-view-wide:grid-cols-2"},ot={2:"grid-cols-2 max-view-wide:grid-cols-1",3:"grid-cols-3 max-view-wide:grid-cols-1",4:"grid-cols-4 max-view-desktop:grid-cols-3 max-view-wide:grid-cols-1"};function ue(e,n){return{key:e.slug,title:e.title??"",excerpt:e.excerpt??"",cover:e.cover??"",meta:e.meta??"",dateLabel:e.dateLabel??"",href:e.href||(n?"#":oe(e.slug))}}function it(e,n){return{...ue(e,n),tags:(e.tags??[]).map(t=>({label:t}))}}const he=new WeakMap,ct={className:"hidden"},dt={className:Ge};function xe(e,n){const t=e.blockIds[0],r=e;function l(d){const b=Ke(),E=n&&b?.index===0;return s(r,{...d,cell:T=>T===t===E?dt:ct})}return Object.assign(l,{blockCount:1,blockIds:e.blockIds})}function ft(e,n){const t=e;if(typeof t!="function"||(t.blockCount??0)<2||!Array.isArray(t.blockIds))return e;let r=he.get(t);return r||(r={lead:xe(t,!0),rest:xe(t,!1)},he.set(t,r)),n?r.lead:r.rest}const mt="Find by name",pt="Nobody by that name.",gt="Nobody matches.",ut="Any",ht="No posts in this category yet.",xt="All posts",Nt=oe("").replace(/\/$/,"");function vt(e){return typeof e=="string"?e.trim():""}function bt(){return c("div",{className:"flex min-h-[40vh] flex-col items-center justify-center gap-6 text-center font-mono text-[length:var(--size-label,14px)] uppercase text-fg-dim",children:[s("p",{role:"status",className:"tracking-[0.2em]",children:ht}),c(O,{href:Nt,className:"inline-flex min-h-11 items-center tracking-[0.22em] hover:text-fg",children:[xt," ",s("span",{className:"text-accent",children:"→"})]})]})}function Et(e,n){const t=l=>l.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLocaleLowerCase().trim(),r=t(n);return r===""||t(e).includes(r)}function Ne({typed:e,onType:n,wide:t=!1}){return c("label",{className:`flex max-w-[360px] flex-col gap-1.5${t?" w-full":""}`,children:[s("span",{className:"font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.18em] text-fg-dim",children:mt}),s("input",{type:"search",value:e,onChange:r=>n(r.target.value),autoComplete:"off",className:"rounded-[var(--sf-button-radius,6px)] border border-line bg-bg px-4 py-2.5 text-[length:var(--size-body,15px)] text-fg outline-none focus:border-accent"})]})}function ve({tags:e}){return s("ul",{"aria-label":"Details",className:"flex gap-1.5 overflow-hidden",children:e.map((n,t)=>s("li",{className:"shrink-0 rounded-[var(--sf-button-radius,4px)] border border-line px-2 py-0.5 text-[length:var(--size-label,12px)] text-fg-dim",children:n},`${n}-${t}`))})}function Tt({card:e,scaffold:n,lower:t=!1}){return c(O,{href:e.href||"#",className:`sf-card group relative isolate flex aspect-[3/4] overflow-hidden bg-surface${t?" min-[801px]:mt-16":""}`,"aria-disabled":n||void 0,tabIndex:n?-1:void 0,children:[s("div",{className:"absolute inset-0 transition-transform duration-700 group-hover:scale-[1.03] motion-reduce:transition-none motion-reduce:group-hover:scale-100",children:s(ze,{label:`card-${e.slug}`,src:e.cover||void 0,sizes:"(max-width: 800px) 50vw, 25vw"})}),s("div",{"aria-hidden":!0,className:"absolute inset-0 z-0",style:{background:"linear-gradient(180deg, transparent 45%, color-mix(in srgb, var(--bg) 88%, transparent) 100%)"}}),e.meta&&s("span",{className:"absolute left-3 top-3 z-[1] rounded-[var(--sf-button-radius,999px)] bg-bg/85 px-2.5 py-1 font-mono text-[length:var(--size-label,11px)] uppercase tracking-[0.16em] text-accent",children:N(e.meta)}),c("div",{className:"relative z-[1] mt-auto flex w-full flex-col gap-1 p-4 max-view-wide:p-3",children:[s("h3",{className:"font-heading3 text-[length:var(--size-headingSmall,24px)] leading-[1.1] tracking-[-0.01em] text-fg",children:C(e.title,!1)}),(e.publishedAt||e.dateLabel)&&s("p",{className:"font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.16em] text-accent",children:e.publishedAt?s(De,{at:e.publishedAt}):N(e.dateLabel??"")}),e.tags&&e.tags.length>0&&s(ve,{tags:e.tags}),e.excerpt&&s("p",{className:"line-clamp-2 text-[length:var(--size-body,14px)] leading-[1.45] text-fg-dim",children:N(e.excerpt)})]})]})}function yt({cards:e,scaffold:n}){return s("nav",{"aria-label":"Days",className:j.nav,children:s("ul",{className:j.list,children:e.map((t,r)=>{const l=!!t.meta;return s("li",{children:c(O,{href:t.href||"#","aria-current":l?"page":void 0,"aria-disabled":n||void 0,tabIndex:n?-1:void 0,className:j.tab(l),children:[s("span",{className:"font-heading3 text-[length:var(--size-body,15px)] leading-[1.2]",children:C(t.title,!1)}),t.excerpt&&s("span",{className:`font-mono text-[length:var(--size-label,11px)] uppercase tracking-[0.14em] ${l?"opacity-80":"text-fg-dim"}`,children:N(t.excerpt)})]})},`${t.slug}-${r}`)})})})}function _t({count:e,words:n,href:t}){const r=c("span",{className:"inline-flex items-baseline gap-3",children:[s("span",{className:"font-heading text-[length:var(--size-headingLarge,64px)] leading-none text-accent",children:e}),n!==void 0&&s("span",{className:"font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.2em] text-fg",children:n})]});return t?s(O,{href:t,className:"inline-flex hover:opacity-85",children:r}):r}const H="[&>[data-sf-repeat]>*]:h-full [&>[data-sf-repeat]>*>*]:h-full",At="[&>[data-sf-repeat]]:h-full [&>[data-sf-repeat]>*]:h-full [&>[data-sf-repeat]>*>*]:h-full",be=`relative z-[2] bg-bg ${je}`,Ee=`relative z-[2] bg-bg ${Ve}`,wt=`relative z-[2] bg-bg ${Ye}`,Ot={top:32,bottom:32};function Ct({num:e,title:n,link:t,posts:r,servedCategory:l,columns:d,limit:b,showAll:E=!1,editing:T=!1,cardImage:Te,gap:ye,gapPhone:_e,layout:g,featuredWidth:Ae,listCover:we=!0,featuredDarken:Oe,omitHead:u=!1,sample:$,nameFilter:Ce=!1,pads:S,template:J,ownerId:Le=""}){const[R,q]=re(""),[Q,$e]=re({}),y=Fe("ev"),Z=r??[],ee=E?Z.length:typeof b=="number"&&b>0?b:ce,k=Z.slice(0,ee),p=T&&k.length===0;if(k.length===0&&!T){if(!vt(l))return null;const a=W(S,le,{noTop:u,nonNegative:!0});return s(G,{as:"section",...a.attrs,className:K(u?Ee:be,a),style:a.style,children:s("div",{className:B,children:s(bt,{})})})}const te=E?ce:ee,f=p?$?.length?$.slice(0,E?$.length:te):Array.from({length:te},(a,i)=>({slug:`placeholder-${i}`,title:L("Blog post title"),excerpt:L("A short summary of the post appears here."),cover:"",meta:L("Journal"),dateLabel:L("Date")})):k,o=Ie("Events",ye,"both",_e),A=g===de&&f.length>1,se=rt(Ae),F=g===fe,I=g===pe,ne=tt.includes(g??""),M=Ce&&!F&&!I&&!A,D=M?Ze(f):[],x=M?f.filter(a=>Et(a.title,R)&&et(a,Q)):f,_=I?W(S,Ot,{nonNegative:!0}):W(S,le,{noTop:u,nonNegative:!0}),z=_.style,Se=!T&&Be(e,n,t?.text),U=(J?.blockCount??0)>0?ot:lt,P=g===v?U[3]:U[Math.min(4,Math.max(2,d??3))]??U[3],Y=ge[Math.min(4,Math.max(1,d??3))]??ge[3],ae=F||A||g===v?"":Pe(y,ne?P:Y,{cards:x.length}),V=(a,i,m)=>s(We,{ownerId:Le,ownerType:"Events",Template:ft(J,A),rows:a.map(h=>ue(h,p)),items:a.map(h=>it(h,p)),fallback:i,children:h=>m(Re.toArray(h))});return I?s(G,{as:"section",..._.attrs,className:K(wt,_),style:Object.keys(z).length?z:void 0,children:s("div",{className:B,children:s(_t,{count:f.length,words:u||n===void 0?void 0:C(n,!1),href:u?void 0:t?.href})})}):s(G,{as:"section",..._.attrs,className:K(u?Ee:be,_),style:{...Ue(Te),...z},children:c("div",{className:B,children:[u||Se?null:s(Me,{num:e!==void 0?N(e):void 0,title:n!==void 0?C(n,!1):void 0,link:t?{text:N(t.text),href:t.href}:void 0}),M&&c("div",{className:"mb-6 flex flex-col gap-2",children:[D.length===0?s(Ne,{typed:R,onType:q}):c("div",{className:"flex flex-wrap items-end gap-3",children:[s(Ne,{typed:R,onType:q,wide:!0}),D.map(({label:a,values:i})=>c("label",{className:"flex min-w-[140px] flex-col gap-1.5 max-view-wide:flex-1",children:[s("span",{className:"font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.18em] text-fg-dim",children:a}),c("select",{value:Q[a]??"",onChange:m=>$e(h=>({...h,[a]:m.target.value})),className:"rounded-[var(--sf-button-radius,6px)] border border-line bg-bg px-4 py-2.5 text-[length:var(--size-body,15px)] text-fg outline-none focus:border-accent",children:[s("option",{value:"",children:ut}),i.map(m=>s("option",{value:m,children:m},m))]})]},a))]}),x.length===0&&s("p",{role:"status",className:"text-[length:var(--size-body,14px)] text-fg-dim",children:D.length===0?pt:gt})]}),ae&&s("style",{children:ae}),F?s(yt,{cards:f,scaffold:p}):ne?V(x,s("div",{className:`${y} sf-card-grid grid${o.className} ${P}`,style:o.style,children:x.map((a,i)=>s(Tt,{card:a,scaffold:p,lower:g===v&&i%3===1},`${a.slug}-${i}`))}),a=>s("div",{className:`${y} sf-card-grid grid${o.className} ${P} ${H}`,style:o.style,children:g===v?a.map((i,m)=>s("div",{className:`${At}${m%3===1?" view-wide:mt-16":""}`,children:i},m)):a})):A?V(f,c("div",{className:`sf-card-grid grid grid-cols-[var(--sf-events-split)] max-view-wide:grid-cols-1${o.className}`,style:{...o.style,"--sf-events-split":se},children:[s(w,{post:f[0],href:f[0].href,scaffold:p,layout:"cover",darken:Oe??nt,darkenStyle:at,placement:st},`${f[0].slug}-0`),s("div",{className:`grid auto-rows-min${o.className}`,style:o.style,children:f.slice(1).map((a,i)=>s(w,{post:a,href:a.href,scaffold:p,showCover:we},`${a.slug}-${i+1}`))})]}),a=>c("div",{className:`sf-card-grid grid grid-cols-[var(--sf-events-split)] max-view-wide:grid-cols-1${o.className} ${H}`,style:{...o.style,"--sf-events-split":se},children:[a[0],s("div",{className:`grid auto-rows-min${o.className}`,style:o.style,children:a.slice(1)})]})):V(x,s("div",{className:`${y} sf-card-grid grid${o.className} ${Y}`,style:o.style,children:x.map((a,i)=>a.tags&&a.tags.length>0?c("div",{className:"flex flex-col gap-2",children:[s(w,{post:a,href:a.href,scaffold:p}),s(ve,{tags:a.tags})]},`${a.slug}-${i}`):s(w,{post:a,href:a.href,scaffold:p},`${a.slug}-${i}`))}),a=>s("div",{className:`${y} sf-card-grid grid${o.className} ${Y} ${H}`,style:o.style,children:a}))]})})}export{X as EVENTS_FEATURED_WIDTH,es as EVENTS_LAYOUTS,pe as EVENTS_LAYOUT_COUNT,ts as EVENTS_LAYOUT_FALLBACK,de as EVENTS_LAYOUT_FEATURED,me as EVENTS_LAYOUT_PORTRAIT,v as EVENTS_LAYOUT_SPREAD,fe as EVENTS_LAYOUT_TABS,tt as EVENTS_PHOTO_LAYOUTS,qe as MAX_CARD_TAGS,Ct as default,Ze as facetChoices,et as matchesFacets,Et as matchesName,Zt as readFacets,Qt as readTags};
|
|
1
|
+
import{jsx as s,jsxs as c,Fragment as Me}from"react/jsx-runtime";import{Children as De,useContext as Pe,useState as ce}from"react";import{servedWords as Ue}from"../lib/content/served-lists.js";import{TAB_PILLS as B}from"../lib/content/tab-strip.js";import{useScopeClass as ze}from"../lib/use-scope-class.js";import{containerGapProps as Ve}from"efficient-web-builder/format/lib/content/container-gap";import Ye from"efficient-web-builder/render/components/SectionHeader";import A from"efficient-web-builder/render/components/PostCard";import je from"efficient-web-builder/render/components/PostDate";import Be from"efficient-web-builder/render/components/Placeholder";import{SiteLink as C}from"efficient-web-builder/render/lib/site-runtime";import{renderGold as b,renderHeadline as O}from"efficient-web-builder/render/components/goldPhrases";import{say as L}from"efficient-web-builder/format/lib/editor-words";import{cardImageShapeTokens as We}from"efficient-web-builder/format/lib/content/card-image-shape";import{SITE_COLUMN as W}from"efficient-web-builder/format/lib/content/page-width";import{fillRowCss as He}from"../lib/sections/fill-row.js";import{FRAME_120 as de,FRAME_ROOM_COUNT as Ke,FRAME_ROOM_OWN_BOX as Ge,FRAME_ROOM_Y as Xe,framedBandPad as H,headIsEmpty as Je,withBandClasses as K}from"../lib/sections/band-padding.js";import{HideTaker as G,ViewHideContext as qe,viewHideClaim as Qe}from"efficient-web-builder/render/components/ViewHideRoot";import{CardTemplateRows as Ze,useCardRow as et}from"efficient-web-builder/render/components/CardRowContext";import{SECTION_FILL_CLASS as tt}from"efficient-web-builder/format/lib/content/section-min-height";import{postPath as fe}from"efficient-web-builder/format/lib/links/page-link-rules";import{EVENTS_FEATURED_DARKEN as st,EVENTS_FEATURED_DARKEN_STYLE as nt,EVENTS_FEATURED_PLACEMENT as rt}from"../lib/content/events-featured-look.js";import{PostListStarts as at}from"./PostListStartsProvider.js";import{EVENTS_DEFAULT_LIMIT as ot,EVENTS_LAYOUT_COUNT as X,postCap as it}from"../lib/content/post-list-continue.js";import{VIEW_TIERS as J}from"efficient-easel/screen/lib/content/view-tiers";import{hiddenKeyOf as lt}from"efficient-easel/screen/lib/content/view-hide";import{nodeHiddenEverywhere as ct,nodeViewHideWords as dt,viewHideClass as me}from"efficient-web-builder/format/lib/content/view-hide-class";const ft=4;function bs(e){return Ue(e,ft)}function Es(e){if(!e||typeof e!="object"||Array.isArray(e))return;const n={};for(const[t,r]of Object.entries(e))if(t.trim()){if(typeof r=="string")r.trim()&&(n[t]=r.trim());else if(Array.isArray(r)){const o=r.filter(d=>typeof d=="string"&&!!d.trim()).map(d=>d.trim());o.length&&(n[t]=o)}}return Object.keys(n).length?n:void 0}function pe(e,n){const t=e.facets?.[n];return t===void 0?[]:typeof t=="string"?[t]:t}const mt=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});function pt(e){const n=[],t=new Map;for(const r of e)for(const o of Object.keys(r.facets??{})){t.has(o)||(n.push(o),t.set(o,new Set));for(const d of pe(r,o))t.get(o).add(d)}return n.map(r=>({label:r,values:[...t.get(r)].sort(mt.compare)}))}function ut(e,n){return Object.entries(n).every(([t,r])=>r===""||pe(e,t).includes(r))}const ue="featured",ge="tabs",he="portrait",E="spread",Ts=[{label:"Even grid",value:"even"},{label:"Featured first",value:ue},{label:"Tabs",value:ge},{label:"Photo cards",value:he},{label:"Staggered spread",value:E},{label:"Count",value:X}],gt=[he,E],ys="even",q={min:2,max:11,step:1,fallback:7,unit:"of 12"},ht=rt,xt=st,vt=nt;function Nt(e){const n=typeof e=="number"?e:Number.parseFloat(String(e??"")),t=Number.isFinite(n)?Math.min(q.max,Math.max(q.min,Math.round(n))):q.fallback;return`${t}fr ${12-t}fr`}const xe={1:"grid-cols-1",2:"grid-cols-2 max-view-wide:grid-cols-1",3:"grid-cols-3 max-view-wide:grid-cols-1",4:"grid-cols-4 max-view-desktop:grid-cols-2 max-view-wide:grid-cols-1"},bt={2:"grid-cols-2",3:"grid-cols-3 max-view-wide:grid-cols-2",4:"grid-cols-4 max-view-desktop:grid-cols-3 max-view-wide:grid-cols-2"},Et={2:"grid-cols-2 max-view-wide:grid-cols-1",3:"grid-cols-3 max-view-wide:grid-cols-1",4:"grid-cols-4 max-view-desktop:grid-cols-3 max-view-wide:grid-cols-1"};function ve(e,n){return{key:e.slug,title:e.title??"",excerpt:e.excerpt??"",cover:e.cover??"",meta:e.meta??"",dateLabel:e.dateLabel??"",href:e.href||(n?"#":fe(e.slug))}}function Tt(e,n){return{...ve(e,n),tags:(e.tags??[]).map(t=>({label:t}))}}const Ne=new WeakMap,yt={className:"hidden"},_t={className:tt};function be(e,n){const t=e.blockIds[0],r=e;function o(d){const h=et(),T=n&&h?.index===0;return s(r,{...d,cell:u=>u===t===T?_t:yt})}return Object.assign(o,{blockCount:1,blockIds:e.blockIds})}function wt(e,n){const t=e;if(typeof t!="function"||(t.blockCount??0)<2||!Array.isArray(t.blockIds))return e;let r=Ne.get(t);return r||(r={lead:be(t,!0),rest:be(t,!1)},Ne.set(t,r)),n?r.lead:r.rest}const At="Find by name",Ct="Nobody by that name.",Ot="Nobody matches.",Lt="Any",St="No posts in this category yet.",$t="All posts",Rt=fe("").replace(/\/$/,"");function kt(e){return typeof e=="string"?e.trim():""}function It(){return c("div",{className:"flex min-h-[40vh] flex-col items-center justify-center gap-6 text-center font-mono text-[length:var(--size-label,14px)] uppercase text-fg-dim",children:[s("p",{role:"status",className:"tracking-[0.2em]",children:St}),c(C,{href:Rt,className:"inline-flex min-h-11 items-center tracking-[0.22em] hover:text-fg",children:[$t," ",s("span",{className:"text-accent",children:"→"})]})]})}function Ft(e,n){const t=o=>o.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLocaleLowerCase().trim(),r=t(n);return r===""||t(e).includes(r)}function Ee({typed:e,onType:n,wide:t=!1}){return c("label",{className:`flex max-w-[360px] flex-col gap-1.5${t?" w-full":""}`,children:[s("span",{className:"font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.18em] text-fg-dim",children:At}),s("input",{type:"search",value:e,onChange:r=>n(r.target.value),autoComplete:"off",className:"rounded-[var(--sf-button-radius,6px)] border border-line bg-bg px-4 py-2.5 text-[length:var(--size-body,15px)] text-fg outline-none focus:border-accent"})]})}function Te({tags:e}){return s("ul",{"aria-label":"Details",className:"flex gap-1.5 overflow-hidden",children:e.map((n,t)=>s("li",{className:"shrink-0 rounded-[var(--sf-button-radius,4px)] border border-line px-2 py-0.5 text-[length:var(--size-label,12px)] text-fg-dim",children:n},`${n}-${t}`))})}function Mt({card:e,scaffold:n,lower:t=!1}){return c(C,{href:e.href||"#",className:`sf-card group relative isolate flex aspect-[3/4] overflow-hidden bg-surface${t?" min-[801px]:mt-16":""}`,"aria-disabled":n||void 0,tabIndex:n?-1:void 0,children:[s("div",{className:"absolute inset-0 transition-transform duration-700 group-hover:scale-[1.03] motion-reduce:transition-none motion-reduce:group-hover:scale-100",children:s(Be,{label:`card-${e.slug}`,src:e.cover||void 0,sizes:"(max-width: 800px) 50vw, 25vw"})}),s("div",{"aria-hidden":!0,className:"absolute inset-0 z-0",style:{background:"linear-gradient(180deg, transparent 45%, color-mix(in srgb, var(--bg) 88%, transparent) 100%)"}}),e.meta&&s("span",{className:"absolute left-3 top-3 z-[1] rounded-[var(--sf-button-radius,999px)] bg-bg/85 px-2.5 py-1 font-mono text-[length:var(--size-label,11px)] uppercase tracking-[0.16em] text-accent",children:b(e.meta)}),c("div",{className:"relative z-[1] mt-auto flex w-full flex-col gap-1 p-4 max-view-wide:p-3",children:[s("h3",{className:"font-heading3 text-[length:var(--size-headingSmall,24px)] leading-[1.1] tracking-[-0.01em] text-fg",children:O(e.title,!1)}),(e.publishedAt||e.dateLabel)&&s("p",{className:"font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.16em] text-accent",children:e.publishedAt?s(je,{at:e.publishedAt}):b(e.dateLabel??"")}),e.tags&&e.tags.length>0&&s(Te,{tags:e.tags}),e.excerpt&&s("p",{className:"line-clamp-2 text-[length:var(--size-body,14px)] leading-[1.45] text-fg-dim",children:b(e.excerpt)})]})]})}function Dt({cards:e,scaffold:n}){return s("nav",{"aria-label":"Days",className:B.nav,children:s("ul",{className:B.list,children:e.map((t,r)=>{const o=!!t.meta;return s("li",{children:c(C,{href:t.href||"#","aria-current":o?"page":void 0,"aria-disabled":n||void 0,tabIndex:n?-1:void 0,className:B.tab(o),children:[s("span",{className:"font-heading3 text-[length:var(--size-body,15px)] leading-[1.2]",children:O(t.title,!1)}),t.excerpt&&s("span",{className:`font-mono text-[length:var(--size-label,11px)] uppercase tracking-[0.14em] ${o?"opacity-80":"text-fg-dim"}`,children:b(t.excerpt)})]})},`${t.slug}-${r}`)})})})}function Pt({count:e,words:n,href:t}){const r=c("span",{className:"inline-flex items-baseline gap-3",children:[s("span",{className:"font-heading text-[length:var(--size-headingLarge,64px)] leading-none text-accent",children:e}),n!==void 0&&s("span",{className:"font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.2em] text-fg",children:n})]});return t?s(C,{href:t,className:"inline-flex hover:opacity-85",children:r}):r}const Q="[&>[data-sf-repeat]>*]:h-full [&>[data-sf-repeat]>*>*]:h-full",Ut="[&>[data-sf-repeat]]:h-full [&>[data-sf-repeat]>*]:h-full [&>[data-sf-repeat]>*>*]:h-full",ye=`relative z-[2] bg-bg ${Xe}`,_e=`relative z-[2] bg-bg ${Ge}`,zt=`relative z-[2] bg-bg ${Ke}`,Vt={top:32,bottom:32};function Yt(e){const{starts:n,posts:t}=Pe(at),r=n[e.ownerId??""];if(!r)return s(Z,{...e,start:0});const o=t?.[e.ownerId??""]??e.posts,d=jt(r);return d.length===1?s(Z,{...e,posts:o,start:d[0].start}):s(Me,{children:d.map(({start:h,views:T})=>{const u=Bt(T,e.viewHidden);return ct(we(u))?null:s(qe.Provider,{value:Wt(u),children:s(Z,{...e,posts:o,start:h})},h)})})}function jt(e){const n=[];for(const t of J){const r=n.find(o=>o.start===e[t]);r?r.views.push(t):n.push({start:e[t],views:[t]})}return n}const Bt=(e,n)=>Object.fromEntries(J.map(t=>[t,!e.includes(t)||!!n?.[t]])),we=e=>Object.fromEntries(J.map(n=>[lt(n),e[n]])),Wt=e=>Qe(me(e),dt(we(e)),{sectionClassName:me(e,{atSectionLine:!0}),line:"section"});function Z({start:e,num:n,title:t,link:r,posts:o,servedCategory:d,columns:h,limit:T,showAll:u=!1,editing:S=!1,cardImage:Ae,gap:Ce,gapPhone:Oe,layout:g,featuredWidth:Le,listCover:Se=!0,featuredDarken:$e,omitHead:x=!1,sample:$,nameFilter:Re=!1,pads:R,template:ee,ownerId:ke=""}){const[k,te]=ce(""),[se,Ie]=ce({}),y=ze("ev"),ne=e>0?(o??[]).slice(e):o??[],re=u?ne.length:it({limit:T}),I=ne.slice(0,re),p=S&&I.length===0;if(I.length===0&&!S){if(!kt(d))return null;const a=H(R,de,{noTop:x,nonNegative:!0});return s(G,{as:"section",...a.attrs,className:K(x?_e:ye,a),style:a.style,children:s("div",{className:W,children:s(It,{})})})}const ae=u?ot:re,f=p?$?.length?$.slice(0,u?$.length:ae):Array.from({length:ae},(a,l)=>({slug:`placeholder-${l}`,title:L("Blog post title"),excerpt:L("A short summary of the post appears here."),cover:"",meta:L("Journal"),dateLabel:L("Date")})):I,i=Ve("Events",Ce,"both",Oe),w=g===ue&&f.length>1,oe=Nt(Le),F=g===ge,M=g===X,ie=gt.includes(g??""),D=Re&&!F&&!M&&!w,P=D?pt(f):[],N=D?f.filter(a=>Ft(a.title,k)&&ut(a,se)):f,_=M?H(R,Vt,{nonNegative:!0}):H(R,de,{noTop:x,nonNegative:!0}),U=_.style,Fe=!S&&Je(n,t,r?.text),z=(ee?.blockCount??0)>0?Et:bt,V=g===E?z[3]:z[Math.min(4,Math.max(2,h??3))]??z[3],Y=xe[Math.min(4,Math.max(1,h??3))]??xe[3],le=F||w||g===E?"":He(y,ie?V:Y,{cards:N.length}),j=(a,l,m)=>s(Ze,{ownerId:ke,ownerType:"Events",Template:wt(ee,w),rows:a.map(v=>ve(v,p)),items:a.map(v=>Tt(v,p)),fallback:l,children:v=>m(De.toArray(v))});return M?s(G,{as:"section",..._.attrs,className:K(zt,_),style:Object.keys(U).length?U:void 0,children:s("div",{className:W,children:s(Pt,{count:f.length,words:x||t===void 0?void 0:O(t,!1),href:x?void 0:r?.href})})}):s(G,{as:"section",..._.attrs,className:K(x?_e:ye,_),style:{...We(Ae),...U},children:c("div",{className:W,children:[x||Fe?null:s(Ye,{num:n!==void 0?b(n):void 0,title:t!==void 0?O(t,!1):void 0,link:r?{text:b(r.text),href:r.href}:void 0}),D&&c("div",{className:"mb-6 flex flex-col gap-2",children:[P.length===0?s(Ee,{typed:k,onType:te}):c("div",{className:"flex flex-wrap items-end gap-3",children:[s(Ee,{typed:k,onType:te,wide:!0}),P.map(({label:a,values:l})=>c("label",{className:"flex min-w-[140px] flex-col gap-1.5 max-view-wide:flex-1",children:[s("span",{className:"font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.18em] text-fg-dim",children:a}),c("select",{value:se[a]??"",onChange:m=>Ie(v=>({...v,[a]:m.target.value})),className:"rounded-[var(--sf-button-radius,6px)] border border-line bg-bg px-4 py-2.5 text-[length:var(--size-body,15px)] text-fg outline-none focus:border-accent",children:[s("option",{value:"",children:Lt}),l.map(m=>s("option",{value:m,children:m},m))]})]},a))]}),N.length===0&&s("p",{role:"status",className:"text-[length:var(--size-body,14px)] text-fg-dim",children:P.length===0?Ct:Ot})]}),le&&s("style",{children:le}),F?s(Dt,{cards:f,scaffold:p}):ie?j(N,s("div",{className:`${y} sf-card-grid grid${i.className} ${V}`,style:i.style,children:N.map((a,l)=>s(Mt,{card:a,scaffold:p,lower:g===E&&l%3===1},`${a.slug}-${l}`))}),a=>s("div",{className:`${y} sf-card-grid grid${i.className} ${V} ${Q}`,style:i.style,children:g===E?a.map((l,m)=>s("div",{className:`${Ut}${m%3===1?" view-wide:mt-16":""}`,children:l},m)):a})):w?j(f,c("div",{className:`sf-card-grid grid grid-cols-[var(--sf-events-split)] max-view-wide:grid-cols-1${i.className}`,style:{...i.style,"--sf-events-split":oe},children:[s(A,{post:f[0],href:f[0].href,scaffold:p,layout:"cover",darken:$e??xt,darkenStyle:vt,placement:ht},`${f[0].slug}-0`),s("div",{className:`grid auto-rows-min${i.className}`,style:i.style,children:f.slice(1).map((a,l)=>s(A,{post:a,href:a.href,scaffold:p,showCover:Se},`${a.slug}-${l+1}`))})]}),a=>c("div",{className:`sf-card-grid grid grid-cols-[var(--sf-events-split)] max-view-wide:grid-cols-1${i.className} ${Q}`,style:{...i.style,"--sf-events-split":oe},children:[a[0],s("div",{className:`grid auto-rows-min${i.className}`,style:i.style,children:a.slice(1)})]})):j(N,s("div",{className:`${y} sf-card-grid grid${i.className} ${Y}`,style:i.style,children:N.map((a,l)=>a.tags&&a.tags.length>0?c("div",{className:"flex flex-col gap-2",children:[s(A,{post:a,href:a.href,scaffold:p}),s(Te,{tags:a.tags})]},`${a.slug}-${l}`):s(A,{post:a,href:a.href,scaffold:p},`${a.slug}-${l}`))}),a=>s("div",{className:`${y} sf-card-grid grid${i.className} ${Y} ${Q}`,style:i.style,children:a}))]})})}export{q as EVENTS_FEATURED_WIDTH,Ts as EVENTS_LAYOUTS,X as EVENTS_LAYOUT_COUNT,ys as EVENTS_LAYOUT_FALLBACK,ue as EVENTS_LAYOUT_FEATURED,he as EVENTS_LAYOUT_PORTRAIT,E as EVENTS_LAYOUT_SPREAD,ge as EVENTS_LAYOUT_TABS,gt as EVENTS_PHOTO_LAYOUTS,ft as MAX_CARD_TAGS,Yt as default,pt as facetChoices,ut as matchesFacets,Ft as matchesName,Es as readFacets,bs as readTags};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { PostListStart } from "../lib/content/post-list-continue.js";
|
|
3
|
+
export type PostListStartMap = Readonly<{
|
|
4
|
+
starts: Readonly<{
|
|
5
|
+
[sectionId: string]: PostListStart;
|
|
6
|
+
}>;
|
|
7
|
+
posts?: Readonly<{
|
|
8
|
+
[sectionId: string]: readonly unknown[];
|
|
9
|
+
}>;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const PostListStarts: import("react").Context<Readonly<{
|
|
12
|
+
starts: Readonly<{
|
|
13
|
+
[sectionId: string]: PostListStart;
|
|
14
|
+
}>;
|
|
15
|
+
posts?: Readonly<{
|
|
16
|
+
[sectionId: string]: readonly unknown[];
|
|
17
|
+
}>;
|
|
18
|
+
}>>;
|
|
19
|
+
export default function PostListStartsProvider({ starts, posts, children, }: PostListStartMap & {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as o}from"react/jsx-runtime";import{createContext as s}from"react";const i=s({starts:{}});function a({starts:t,posts:r,children:e}){return o(i.Provider,{value:{starts:t,posts:r},children:e})}export{i as PostListStarts,a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as r}from"react/jsx-runtime";import{Render as
|
|
1
|
+
"use client";import{jsx as r}from"react/jsx-runtime";import{Render as p}from"efficient-easel/render";import d from"./PostListStartsProvider.js";import{postListStartsOf as f}from"../lib/content/post-list-continue.js";import{renderConfig as u}from"../lib/document/render-config.js";import{SITE_FOOTER_KIND as c}from"efficient-web-builder/format/lib/content/footer";import{PublishedFooterContext as I}from"efficient-web-builder/render/components/PublishedFooterContext";import{publishedChromeData as g}from"efficient-web-builder/render/lib/document/published-passes";import{EMPTY_SOCIAL_LINKS as k}from"efficient-web-builder/format/lib/content/social-links";function P({footerBlock:l,rootProps:e,headerSettings:o,siteName:i,legalName:n,foundedYear:m,socialLinks:a}){const t=g({root:{props:{...e??{},kind:c}},content:[l],zones:{}}),s=f(t);return r(I.Provider,{value:{logoUrl:o?.logoUrl??null,logoReversed:o?.logoReversed??null,logoInkIsDark:o?.logoInkIsDark??null,siteName:i,legalName:n??null,foundedYear:m??null,socialLinks:a??k},children:r(d,{starts:s.starts,posts:s.posts,children:r(p,{config:u(),data:t})})})}export{P as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as r}from"react/jsx-runtime";import{Render as
|
|
1
|
+
"use client";import{jsx as r}from"react/jsx-runtime";import{Render as i}from"efficient-easel/render";import a from"./PostListStartsProvider.js";import{postListStartsOf as p}from"../lib/content/post-list-continue.js";import m from"./BoxHeaderBar.js";import{headerRenderConfig as d}from"../lib/document/render-config.js";import{headerBarOf as n}from"../lib/document/published-header-bar.js";import{publishedChromeData as f}from"efficient-web-builder/render/lib/document/published-passes";function h({group:s}){const o=f({root:{props:{}},content:[s],zones:{}}),t=n(o),e=p(o);return r(m,{sticky:t.sticky,topTextColor:t.topTextColor,heightPx:t.heightPx,theme:t.theme,bandCapped:t.bandCapped,children:r(a,{starts:e.starts,posts:e.posts,children:r(i,{config:d(),data:o})})})}export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as x,Fragment as K}from"react/jsx-runtime";import le from"next/link";import{usePathname as ce}from"next/navigation";import{useEffect as P,useId as
|
|
1
|
+
"use client";import{jsx as e,jsxs as x,Fragment as K}from"react/jsx-runtime";import le from"next/link";import{usePathname as ce}from"next/navigation";import{useEffect as P,useId as J,useMemo as ee,useRef as oe,useState as m}from"react";import Q from"efficient-web-builder/render/components/BlockFrame";import{userZone as ue}from"efficient-shell/format";import{ApiError as ne,askToSignUp as de,fetchSignUpAvailability as te,joinSignUpWaitingList as me}from"../lib/api/index.js";import fe from"./SignUpFind.js";import he from"./SignUpLink.js";import{BANNER as X,CARD as Z,PRIMARY as re,QUIET as E,TITLE as q}from"../lib/sections/sign-up-look.js";import{ROW_INPUT_CLASS as pe}from"../lib/field-input.js";import{COUNTRY_CURRENCY as ge}from"../lib/sections/sign-up-catalogue.js";import{CHECK_AFTER_MS as be,EMPTY_DRAFT as Ne,SIGN_UP_WORDS as n,addressSuffix as ae,checkDraft as ye,checkWaitingEmail as xe,countryChoices as ve,currencyChoices as $e,fill as D,linkEnds as Se,linkTokenOf as ke,normaliseSlug as Ce,readSignUpRefusal as Ue,readWaitingRefusal as Re,signUpBody as Te,slugCheckOf as Ae,slugFromName as Ee}from"../lib/sections/sign-up.js";function Oe(t){return t.mode==="find"?e(Q,{contained:t.contained,className:"py-6",children:e(fe,{product:t.product,productName:t.productName,startHref:"/start",inert:!!t.sample})}):e(_e,{...t})}function _e({product:t,productName:a,freeLine:l,zone:i,askCountry:o,termsHref:u,privacyHref:c,findHref:s,contained:y,sample:p}){const[g,f]=m(p??Ne),[U,R]=m(!1),[B,O]=m({}),[T,S]=m(null),[b,h]=m("form"),[G,H]=m(null),[F,L]=m(!1),[_,j]=m(!1),[A,W]=m(()=>ae(i,"")),r=ke(ce()),k=!!r&&!p,w=we(t,g.slug,!!p||k);P(()=>{W(ae(i,window.location.hostname))},[i]),P(()=>{if(p||k)return;let d=!1;return te(t).then(N=>{d||(N.open||h("closed"),f(v=>({...v,country:v.country||N.country,currency:v.currency||N.currency})))}).catch(()=>{}),()=>{d=!0}},[t,p,k]);const C=d=>{f(N=>({...N,...d})),O(N=>{const v={...N};for(const se of Object.keys(d))delete v[se];return v}),S(null)},$=async d=>{L(!0),S(null);try{H(await de(Te(g,t,o))),j(d),h("sent")}catch(N){const v=N instanceof ne?Ue(N.status,N.data):{fields:{},trouble:"failed"};v.trouble==="closed"?h("closed"):Object.keys(v.fields).length?(O(v.fields),h("form")):S(v.trouble)}finally{L(!1)}},I=d=>{if(d.preventDefault(),p||F)return;const N=ye(g,w);O(N),!Object.keys(N).length&&$(!1)};return k?e(Q,{contained:y,className:"py-6",children:e(he,{token:r,productName:a,suffix:A,startHref:"/start",findHref:s})}):e(Q,{contained:y,className:"py-6",children:e(Be,{stage:b,product:t,onOpen:()=>h("form"),productName:a,freeLine:l,suffix:A,askCountry:o,termsHref:u,privacyHref:c,findHref:s,draft:g,wrong:B,slug:w,trouble:T,busy:F,sent:G,resent:_,onChange:C,onCompany:d=>C(U?{company:d}:{company:d,slug:Ee(d)}),onSlug:d=>{R(!0),C({slug:Ce(d)})},onCountry:d=>C({country:d,currency:ge[d]??g.currency}),onSubmit:I,onAgain:()=>{$(!0)},onEdit:()=>{R(!0),S(null),h("form")}})})}function we(t,a,l){const[i,o]=m({slug:"",found:{state:"empty"}}),u=oe("");return P(()=>{if(l||!a)return;u.current=a;const c=window.setTimeout(()=>{te(t,a).then(s=>{u.current===a&&o({slug:a,found:Ae(s)})}).catch(()=>{u.current===a&&o({slug:a,found:{state:"unknown"}})})},be);return()=>window.clearTimeout(c)},[t,a,l]),l?{state:"available"}:a?i.slug===a?i.found:{state:"checking"}:{state:"empty"}}const M="flex h-11 items-center rounded-[10px] border bg-bg px-3",z="h-full w-full bg-transparent text-[14px] text-fg outline-none focus-visible:outline-none! placeholder:text-fg-dim",ie="flex h-11 w-full cursor-pointer items-center justify-center rounded-[10px] border font-medium text-fg disabled:cursor-wait disabled:opacity-60";function Be(t){const{stage:a,productName:l,findHref:i,trouble:o}=t,u=i?x("p",{className:`${E} mt-[10px] text-center`,children:[n.haveOne," ",e(le,{href:i,className:"text-accent",children:n.find})]}):null;return a==="closed"?e(He,{...t,children:u}):a==="sent"?e(Le,{...t}):e(De,{...t,trouble:o,children:u})}function Y({id:t,label:a,error:l,hint:i,children:o}){return x("div",{className:"min-w-0",children:[e("label",{htmlFor:t,className:"mb-1 mt-3 block text-[13px] font-medium",children:a}),o,l?e("p",{id:`${t}-said`,role:"alert",className:"mt-1 text-[13px] text-alert",children:l}):i&&e("p",{id:`${t}-said`,className:"mt-1 text-[13px]",children:i})]})}const V=t=>t?"border-alert":"border-line focus-within:border-accent";function De({productName:t,freeLine:a,suffix:l,askCountry:i,termsHref:o,privacyHref:u,draft:c,wrong:s,slug:y,trouble:p,busy:g=!1,locale:f,onChange:U,onCompany:R,onSlug:B,onCountry:O,onSubmit:T,children:S}){const b=J(),[h,G]=m(f!==void 0);P(()=>G(!0),[]);const H=r=>r?[{value:r,label:r}]:[],F=ee(()=>i?h?ve(c.country,f):H(c.country):[],[i,h,c.country,f]),L=ee(()=>i?h?$e(c.currency,f):H(c.currency):[],[i,h,c.currency,f]),_=(r,k,w,C,$)=>e(Y,{id:`${b}-${r}`,label:k,error:s[r],children:e("div",{className:`${M} ${V(s[r])}`,children:e("input",{id:`${b}-${r}`,name:r,type:w,autoComplete:C,maxLength:$,value:c[r],"aria-invalid":s[r]?!0:void 0,"aria-describedby":s[r]?`${b}-${r}-said`:void 0,onChange:I=>r==="company"?R?.(I.target.value):U?.({[r]:I.target.value}),className:z})})}),j=(r,k,w,C)=>e(Y,{id:`${b}-${r}`,label:k,error:s[r],children:e("div",{className:`${M} ${V(s[r])}`,children:e("select",{id:`${b}-${r}`,name:r,value:c[r],"aria-invalid":s[r]?!0:void 0,onChange:$=>C($.target.value),className:`${z} cursor-pointer`,children:w.map($=>e("option",{value:$.value,children:$.label},$.value))})})}),A=s.slug??(y.state==="problem"?n.slugProblem[y.problem]:void 0),W=y.state==="checking"?e("span",{className:"text-fg-dim",children:n.checking}):y.state==="available"?x("span",{className:"text-green",children:[e("span",{"aria-hidden":!0,children:"✓ "}),n.available]}):void 0;return x("form",{noValidate:!0,onSubmit:T,className:Z,children:[e("h2",{className:q,children:D(n.title,{name:t})}),a&&e("p",{className:`${E} mt-1`,children:a}),x("div",{className:"grid grid-cols-2 gap-[10px]",children:[_("firstName",n.firstName,"text","given-name",150),_("lastName",n.lastName,"text","family-name",150)]}),_("email",n.email,"email","email",254),_("company",n.company,"text","organization",200),e(Y,{id:`${b}-slug`,label:n.address,error:A,hint:W,children:x("div",{className:`${M} gap-2 ${V(A)}`,children:[e("input",{id:`${b}-slug`,name:"slug",type:"text",autoComplete:"off",autoCapitalize:"none",spellCheck:!1,maxLength:30,value:c.slug,"aria-invalid":A?!0:void 0,"aria-describedby":A||W?`${b}-slug-said`:void 0,onChange:r=>B?.(r.target.value),className:`${pe} h-full bg-transparent text-[14px] text-fg outline-none focus-visible:outline-none!`}),l&&e("span",{className:`${E} shrink-0`,children:l})]})}),i&&x(K,{children:[j("country",n.country,F,r=>O?.(r)),j("currency",n.currency,L,r=>U?.({currency:r})),e("p",{className:`${E} mt-[6px]`,children:n.countryHint})]}),p&&e("p",{role:"alert",className:X,children:n.trouble[p]}),e("button",{type:"submit",disabled:g,className:re,children:g?n.sending:n.submit}),e("p",{className:`${E} mt-3 text-center`,children:e(Fe,{termsHref:o,privacyHref:u})}),S]})}function He({product:t="",productName:a,children:l,onOpen:i}){const o=J(),[u,c]=m(""),[s,y]=m(null),[p,g]=m(null),[f,U]=m(!1),[R,B]=m(!1);return x("form",{noValidate:!0,onSubmit:async T=>{if(T.preventDefault(),f)return;const S=xe(u);if(y(S),g(null),!S){U(!0);try{await me(t,u),B(!0)}catch(b){const h=b instanceof ne?Re(b.status,b.data):{open:!1,email:null,trouble:"failed"};h.open&&i?.(),y(h.email),g(h.trouble)}finally{U(!1)}}},className:Z,children:[e("h2",{className:q,children:n.closedTitle}),x("p",{className:"mt-[10px]",children:[D(n.closedBody,{name:a})," ",R?"":n.closedLeave]}),R?e("p",{role:"status",className:"mt-[10px] font-medium",children:D(n.waitingDone,{email:u.trim()})}):x(K,{children:[e(Y,{id:`${o}-email`,label:n.email,error:s??void 0,children:e("div",{className:`${M} ${V(s??void 0)}`,children:e("input",{id:`${o}-email`,name:"email",type:"email",autoComplete:"email",maxLength:254,value:u,"aria-invalid":s?!0:void 0,"aria-describedby":s?`${o}-email-said`:void 0,onChange:T=>{c(T.target.value),y(null),g(null)},className:z})})}),p&&e("p",{role:"alert",className:X,children:n.trouble[p]}),e("button",{type:"submit",disabled:f,className:re,children:f?n.sending:n.tellMe})]}),l]})}function Fe({termsHref:t,privacyHref:a}){const l=(c,s)=>c?e("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2",children:s}):s,[i,o,u]=n.agree.split(/\{terms\}|\{privacy\}/);return x(K,{children:[i,l(t,n.terms),o,l(a,n.privacy),u]})}function Le({draft:t,sent:a,trouble:l,busy:i=!1,resent:o=!1,locale:u,timeZone:c,onAgain:s,onEdit:y}){const[p,g]=D(n.sentBody,{company:t.company.trim()}).split("{email}"),f=Se(a?.expiresAt??"",u,c??ue()??"");return x("div",{className:Z,children:[e("h2",{className:q,children:n.sentTitle}),x("p",{className:"mt-[10px]",children:[p,e("span",{className:"font-medium",children:t.email.trim()}),g]}),f&&e("p",{className:`${E} mt-[10px]`,children:D(n.sentUntil,{when:f})}),l?e("p",{role:"alert",className:X,children:n.trouble[l]}):o&&!i&&e("p",{role:"status",className:`${E} mt-[10px]`,children:n.sentAgain}),e("button",{type:"button",disabled:i,onClick:s,className:`${ie} mt-[18px] border-line`,children:i?n.sendingAgain:n.sendAgain}),e("button",{type:"button",disabled:i,onClick:y,className:`${ie} mt-2 border-transparent`,children:n.change})]})}export{Be as SignUpView,Oe as default};
|
|
@@ -37,12 +37,16 @@ export interface BookingFormValue {
|
|
|
37
37
|
export declare const BookingFormContext: import("react").Context<BookingFormValue | null>;
|
|
38
38
|
export declare function useBookingForm(): BookingFormValue;
|
|
39
39
|
export declare const SAMPLE_SERVICES: BookingService[];
|
|
40
|
+
export declare function sampleAvailability(day: string, zone: string): BookingAvailability;
|
|
40
41
|
export declare const SAMPLE_CONFIRMATION: BookingConfirmation;
|
|
42
|
+
export declare function sampleConfirmation(times: BookingAvailability | undefined): BookingConfirmation;
|
|
43
|
+
export declare function isSampleConfirmation(confirmation: BookingConfirmation): boolean;
|
|
41
44
|
export declare function showsExample(editing: boolean, services: BookingService[] | undefined): boolean;
|
|
42
45
|
export declare function bookingReady(form: {
|
|
43
46
|
editing: boolean;
|
|
44
47
|
submitting: boolean;
|
|
45
48
|
hasService: boolean;
|
|
49
|
+
hasDay?: boolean;
|
|
46
50
|
selectedStart: string;
|
|
47
51
|
name: string;
|
|
48
52
|
email: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as ce}from"react/jsx-runtime";import{createContext as ue,useContext as me,useEffect as f,useId as de,useState as o,useSyncExternalStore as fe}from"react";import{ApiError as j,bookings as g}from"../../lib/api/index.js";import{findFirstBookableDay as pe}from"../../lib/booking-dates.js";import{startHasPassed as ye}from"../../lib/booking/appointment-time.js";import{instantOnDayKey as be,userToday as he,userZone as ve}from"efficient-shell/format";import{uuid as q}from"../../lib/uuid.js";import{listRows as Se}from"../../lib/api/list-rows.js";const K=ue(null);function Fe(){const e=me(K);if(!e)throw new Error("useBookingForm must be used inside <BookingFormProvider>");return e}const D=[{id:"example-1",name:"Example service",durationMinutes:45,price:"80.00",description:"What this appointment includes, in a sentence."},{id:"example-2",name:"Second example",durationMinutes:30,price:"0",description:""}],ge=[{hour:9,minute:0},{hour:10,minute:30},{hour:13,minute:0}];function O(e,i){return{timezone:"",slots:i?ge.flatMap(({hour:u,minute:s})=>be(e,{timeZone:i,hour:u,minute:s})??[]).map(u=>({start:u})):[]}}const C={bookingNumber:"EXAMPLE-0000",service:"Example service",startAt:"",timezone:"",customerTimezone:"",manageToken:"example"};function xe(e){const i=String(e?.slots[0]?.start??"");return i?{...C,startAt:i}:C}function Le(e){return e.bookingNumber===C.bookingNumber}function Ee(e,i){return e&&i?.length===0}function Pe(e,i){return!!(!e.editing&&!e.submitting&&e.hasService&&e.hasDay!==!1&&e.selectedStart&&!ye(e.selectedStart,i)&&e.name.trim()&&e.email.trim()&&!e.requiresPayment)}function ke(){return()=>{}}function Ae(){return null}function ze({editing:e=!1,previewConfirmation:i=!1,children:I}){const u=de(),s=fe(ke,he,Ae)??"",[x,M]=o(),[Z,H]=o(""),[r,T]=o(""),[l,E]=o(s),[U,B]=o(s),[p,V]=o(!1),[X,m]=o(null),[Y,d]=o(),[P,y]=o(""),[k,$]=o(""),[A,G]=o(""),[N,J]=o(""),[w,Q]=o(""),[ee,te]=o(()=>q()),[F,ne]=o(null),[oe,b]=o(!1),[L,z]=o(!1),[ie,h]=o(null),[v,se]=o("");f(()=>{se(ve()??"")},[]),f(()=>{let t=!1;return g.listServices().then(n=>{if(t)return;const _=Se(n);M(_),H(n.currency),T(le=>le||_[0]?.id||"")}).catch(()=>{t||M([])}),()=>{t=!0}},[]),f(()=>{s&&(E(t=>t||s),B(t=>t||s))},[s]),f(()=>{if(p||!r||!s)return;const t={aborted:!1};return y(""),d(void 0),h(null),m(null),b(!0),pe(r,s,{signal:t}).then(n=>{if(!t.aborted){if(n.outcome==="found"){E(n.date),B(n.date),d(n.availability);return}m(n.outcome==="noneInWindow"?`No times are available in the next ${n.days} days.`:"We couldn't load available times. Please try again.")}}).finally(()=>{t.aborted||b(!1)}),()=>{t.aborted=!0}},[p,r,s]),f(()=>{if(!p||!r||!l)return;let t=!1;return y(""),d(void 0),h(null),m(null),b(!0),g.getAvailability(r,l).then(n=>{t||(d(n),n.slots.length===0&&m("No times are available on this date."))}).catch(()=>{t||m("We couldn't load available times. Please try again.")}).finally(()=>{t||b(!1)}),()=>{t=!0}},[l,p,r]);const c=x?.find(t=>t.id===r),R=c?.depositAmountDue!=null,W=Pe({editing:e,submitting:L,hasService:!!c,hasDay:!!l,selectedStart:P,name:k,email:A,requiresPayment:R},Date.now());async function ae(t){if(t.preventDefault(),!(!W||!c)){z(!0),h(null);try{const n=await g.create({serviceId:c.id,start:P,customer:{name:k.trim(),email:A.trim(),phone:N.trim()},notes:w.trim(),idempotencyKey:ee,customerTimezone:v});ne(n),te(q())}catch(n){h(n instanceof j&&n.status===409?"That time was just booked. Choose another available time.":"Your appointment wasn't submitted. Please check your details and try again."),n instanceof j&&n.status===409&&(y(""),g.getAvailability(c.id,l).then(d).catch(()=>{}))}finally{z(!1)}}}const a=Ee(e,x),S=a?O(l,v):void 0,re=i&&!F?xe(S??O(l,v)):null;return ce(K.Provider,{value:{fieldPrefix:u,editing:e,services:a?D:x,currency:a?"AUD":Z,serviceId:a?D[0].id:r,setServiceId:T,service:a?D[0]:c,requiresPayment:a?!1:R,date:l,earliestDate:U,setDate:E,setDateTouched:V,availability:S??Y,loadingSlots:a?!1:oe,noSlotsMessage:X,selectedStart:S?S.slots[0]?.start??"":P,setSelectedStart:y,customerTimezone:v,name:k,setName:$,email:A,setEmail:G,phone:N,setPhone:J,notes:w,setNotes:Q,confirmation:F??re,submitting:L,error:ie,canSubmit:a?!1:W,handleSubmit:ae,sample:!!a},children:I})}export{K as BookingFormContext,ze as BookingFormProvider,C as SAMPLE_CONFIRMATION,D as SAMPLE_SERVICES,Pe as bookingReady,Le as isSampleConfirmation,O as sampleAvailability,xe as sampleConfirmation,Ee as showsExample,Fe as useBookingForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as i}from"react/jsx-runtime";import{
|
|
1
|
+
"use client";import{jsx as e,jsxs as i}from"react/jsx-runtime";import{isSampleConfirmation as H,useBookingForm as F}from"./BookingFormState.js";import B from"efficient-web-builder/render/components/Btn";import{HideTaker as I}from"efficient-web-builder/render/components/ViewHideRoot";import u from"../WebFormField.js";import{CardTemplateRows as A}from"efficient-web-builder/render/components/CardRowContext";import{InsideSiteColumn as E}from"efficient-web-builder/render/components/SiteGutterFrame";import{groundCell as P}from"../card-ground-cell.js";import{PART_ROW_ATTR as K,encodePartRow as W}from"efficient-web-builder/render/lib/document/text-parts";import{BOOKING_SERVICE_SLOT as R,BOOKING_TIME_SLOT as _}from"../../lib/content/booking-card-seed.js";import{firstReadableZone as v}from"../../lib/zone.js";import{formatAppointment as q,formatAppointmentTime as D,startHasPassed as G}from"../../lib/booking/appointment-time.js";import{formatMoneyInCurrency as U}from"../../lib/commerce.js";import{FREE_PRICE as V}from"../../lib/wheels/price-display.js";const f="w-full border-2 border-line bg-bg px-4 py-4 font-[family-name:var(--bk-value-font,var(--font-display))] text-[length:var(--bk-value-size,17px)] text-fg outline-none transition-colors placeholder:text-fg-dim hover:border-fg-dim focus:border-accent";function Y(r,a){const n=Number(r);if(n===0)return V;try{return U(n,a)}catch{return`${a} ${r}`}}const L={selected:!0};function M(r,a){return({index:n})=>a?{[K]:W(r,n)}:{}}const h="font-[family-name:var(--bk-name-font,var(--font-mono))] text-[length:var(--bk-name-size,12px)]";function S({number:r,children:a}){return i("div",{className:"mb-4 flex items-center gap-3",children:[e("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-full border border-line font-[family-name:var(--bk-step-font,var(--font-mono))] text-[length:var(--bk-step-size,11px)] font-semibold text-fg-dim",children:r}),e("h3",{className:"font-[family-name:var(--bk-step-font,var(--font-mono))] text-[length:var(--bk-step-size,12px)] font-semibold uppercase tracking-[0.2em] text-fg",children:a})]})}function de({eyebrow:r,heading:a,intro:n}){return i("div",{className:"mb-10 max-w-[760px]",children:[(r??"").trim()&&e("p",{className:"mb-4 font-mono text-[12px] font-semibold uppercase tracking-[0.24em] text-accent",children:r}),(a??"").trim()&&e("h2",{className:"font-heading2 text-[length:min(var(--size-headingMedium,44px),var(--sf-heading-max,9999px))] font-medium uppercase leading-[0.98] tracking-[-0.025em] text-fg max-view-wide:text-[length:min(var(--size-headingMedium,32px),var(--sf-heading-max,9999px))]",children:a}),(n??"").trim()&&e("p",{className:"mt-5 max-w-[660px] font-display text-[17px] leading-[1.65] text-fg-dim",children:n})]})}function pe({style:r,owner:a}){const{fieldPrefix:n,services:o,currency:l,serviceId:c,setServiceId:k,requiresPayment:y,date:N,earliestDate:T,setDate:C,setDateTouched:w,availability:m,loadingSlots:d,noSlotsMessage:g,selectedStart:s,setSelectedStart:O,customerTimezone:Z,editing:p}=F();if(!o)return null;const j=Date.now(),x=v(Z,m?.timezone??""),z=v(m?.timezone??""),b=z&&z!==x?z:"",$=(m?.slots??[]).map(t=>({start:t.start,time:D(t.start,x),businessTime:b?`${D(t.start,b)} business`:"",passed:!p&&G(t.start,j)}));return i(I,{className:"flex flex-col gap-10",style:r,children:[i("div",{children:[e(S,{number:"01",children:"Choose a service"}),e("div",{className:"grid gap-3 sm:grid-cols-2",children:e(A,{ownerId:a.id,ownerType:a.type,slot:R,Template:a.serviceTemplate,rows:o.map(t=>({name:t.name,meta:`${t.durationMinutes} min · ${Y(t.price,l)}`,description:t.description??""})),states:o.map(t=>t.id===c?L:void 0),actions:p?void 0:o.map(t=>({press:()=>k(t.id),label:t.name})),copyAttrs:M(R,p),fallback:null,wrapCopy:P,children:t=>e(E,{children:t})})}),y&&e("p",{className:"mt-3 font-[family-name:var(--bk-note-font,var(--font-mono))] text-[length:var(--bk-note-size,11px)] uppercase tracking-[0.14em] text-alert",role:"alert",children:"This service requires an upfront payment and cannot be booked through this form yet."})]}),i("div",{children:[e(S,{number:"02",children:"Choose a date and time"}),e(u,{separate:!0,htmlFor:`${n}-date`,label:"Date",required:!0,labelFace:h,children:e("input",{id:`${n}-date`,type:"date",min:T,value:N,onChange:t=>{w(!0),C(t.target.value)},className:f,required:!0})}),e("div",{className:"mt-4 grid grid-cols-2 gap-2 sm:grid-cols-3 min-[1200px]:grid-cols-4",role:"group","aria-label":"Available appointment times",children:d?e("p",{className:"col-span-full py-3 font-[family-name:var(--bk-note-font,var(--font-mono))] text-[length:var(--bk-note-size,11px)] uppercase tracking-[0.18em] text-fg-dim",children:"Loading times…"}):m?.slots.length?e(A,{ownerId:a.id,ownerType:a.type,slot:_,Template:a.timeTemplate,rows:$.map(t=>({time:t.time,businessTime:t.businessTime})),states:$.map(t=>t.start===s&&!t.passed?L:void 0),actions:p?void 0:$.map(t=>({press:()=>O(t.start),label:t.time,disabled:t.passed})),copyAttrs:M(_,p),fallback:null,wrapCopy:P,children:t=>e(E,{children:t})}):g?e("p",{className:"col-span-full py-3 font-[family-name:var(--bk-note-font,var(--font-mono))] text-[length:var(--bk-note-size,11px)] uppercase tracking-[0.18em] text-fg-dim",role:"status",children:g}):null}),x&&!d&&!!m?.slots.length&&i("p",{className:"mt-3 font-[family-name:var(--bk-note-font,var(--font-mono))] text-[length:var(--bk-note-size,10px)] uppercase tracking-[0.16em] text-fg-dim",children:["Times shown in ",x,b?` · business timezone ${b}`:""]})]})]})}function ue({buttonLabel:r,style:a}){const{fieldPrefix:n,editing:o,name:l,setName:c,email:k,setEmail:y,phone:N,setPhone:T,notes:C,setNotes:w,submitting:m,error:d,canSubmit:g}=F();return i(I,{className:"sf-card border border-line bg-bg p-5 min-[640px]:p-8",style:a,children:[e(S,{number:"03",children:"Your details"}),i("div",{className:"flex flex-col gap-4",children:[e(u,{separate:!0,htmlFor:`${n}-name`,label:"Name",required:!0,labelFace:h,children:e("input",{id:`${n}-name`,type:"text",autoComplete:"name",value:l,onChange:s=>c(s.target.value),className:f,required:!0})}),e(u,{separate:!0,htmlFor:`${n}-email`,label:"Email",required:!0,labelFace:h,children:e("input",{id:`${n}-email`,type:"email",inputMode:"email",autoComplete:"email",value:k,onChange:s=>y(s.target.value),className:f,required:!0})}),e(u,{separate:!0,htmlFor:`${n}-phone`,label:"Phone",labelFace:h,children:e("input",{id:`${n}-phone`,type:"tel",inputMode:"tel",autoComplete:"tel",value:N,onChange:s=>T(s.target.value),className:f})}),e(u,{separate:!0,htmlFor:`${n}-notes`,label:"What would you like to cover?",labelFace:h,children:e("textarea",{id:`${n}-notes`,rows:4,value:C,onChange:s=>w(s.target.value),className:`${f} resize-y`})})]}),d&&e("p",{className:"mt-4 font-[family-name:var(--bk-note-font,var(--font-mono))] text-[length:var(--bk-note-size,11px)] uppercase tracking-[0.16em] text-alert",role:"alert",children:d}),e(B,{type:o?"button":"submit",disabled:!g,arrow:null,className:"mt-6 w-full disabled:cursor-not-allowed disabled:opacity-50",children:m?"Submitting…":(r??"").trim()||"Book appointment"})]})}function fe({successMessage:r}){const{confirmation:a,customerTimezone:n}=F();if(!a)return null;const o=v(a.customerTimezone,n,a.timezone),l=v(a.timezone),c=l&&l!==o?l:"";return i("div",{className:"sf-card max-w-[760px] border border-line bg-bg p-6 min-[640px]:p-10",role:"status",children:[i("p",{className:"font-mono text-[12px] font-semibold uppercase tracking-[0.22em] text-accent",children:["Request received · ",a.bookingNumber]}),e("h3",{className:"mt-4 font-display text-[28px] font-medium uppercase text-fg",children:a.service}),e("p",{className:"mt-2 font-display text-[17px] text-fg-dim",children:q(a.startAt,o)}),c&&i("p",{className:"mt-1 font-mono text-[10px] uppercase tracking-[0.16em] text-fg-dim",children:["Business time: ",q(a.startAt,c)]}),(r??"").trim()&&e("p",{className:"mt-5 max-w-[620px] font-serif text-[18px] italic leading-[1.6] text-fg-dim",children:r}),e(B,{href:`/book/${encodeURIComponent(a.manageToken)}`,newTab:!H(a),variant:"ghost",className:"mt-8",children:"Manage booking"})]})}export{pe as BookingChoose,fe as BookingConfirmed,ue as BookingDetails,de as BookingHead};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as r,Fragment as x}from"react/jsx-runtime";import R from"next/link";import{useEffect as D,useMemo as Y,useRef as j,useState as v}from"react";import{holdTime as X}from"../../lib/checkout/hold-time.js";import{stripeAppearance as J}from"../../lib/checkout/stripe-appearance.js";import{readerTimeZone as ee}from"../../lib/reader-zone.js";import{Elements as te,PaymentElement as re,useElements as ne,useStripe as ae}from"@stripe/react-stripe-js";import{loadStripe as ie}from"@stripe/stripe-js";import{useCurrency as E}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{resolveCopyright as oe}from"../../lib/content/site.js";import{ApiError as L,products as T}from"../../lib/api/index.js";import ce,{WORDMARK_FIT_FLOOR_PX as se}from"efficient-web-builder/render/components/Logo";import{NOT_CHECKED as q,orderReference as le}from"../../lib/checkout/pay-first.js";import{CheckoutStateProvider as de,useCheckout as me}from"./checkout-state.js";import{CheckoutContact as pe,CheckoutOrderSummary as ue,CheckoutPayment as fe,CheckoutShippingAddress as xe,CheckoutShippingMethod as ge,FormLock as M,LeaveLink as z}from"./checkout-parts.js";function he(t){return e(de,{...t,children:e(ke,{})})}function ye({order:t,paid:n}){const{formatMoney:i}=E();if(!t.grandTotal||!t.currency)return null;const m=c=>i(Number(c),t.currency),y=Number(t.freightCharge??0),p=Number(t.discountAmount??0);return r("dl",{className:"grid w-full max-w-sm grid-cols-[1fr_auto] gap-x-6 gap-y-1 border-y border-line py-3 text-left text-sm",children:[(t.shippingMethod||y>0)&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Delivery",t.shippingMethod?` · ${t.shippingMethod}`:""]}),e("dd",{className:"text-right font-mono",children:m(t.freightCharge??"0")})]}),p>0&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Discount",t.couponCode?` · ${t.couponCode}`:""]}),r("dd",{className:"text-right font-mono",children:["−",m(t.discountAmount??"0")]})]}),e("dt",{className:"text-fg",children:n?"Total paid":"Order total"}),e("dd",{className:"text-right font-mono text-fg",children:m(t.grandTotal)})]})}function be({result:t,lostChangeNote:n=null}){const i=e("span",{className:"font-mono text-fg",children:t.checkoutNumber});return r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:t.kind==="refunded"||t.kind==="expired"?"Order not placed":t.kind==="processing"?"Payment processing":"Payment received"}),e("p",{className:"text-fg-dim",children:t.kind==="refunded"?r(x,{children:["An item sold out or an offer ended while you paid for checkout ",i,". Your payment goes back to your card."]}):t.kind==="expired"?r(x,{children:["The hold on checkout ",i," ran out before your payment arrived. Your payment goes back to your card."]}):t.kind==="processing"?r(x,{children:["Your payment for checkout ",i," is being processed. When it goes through, we will email your order confirmation."]}):r(x,{children:["Thank you — your payment",t.checkoutNumber?r(x,{children:[" for checkout ",i]}):null," has gone through. We will email you the order number shortly."]})}),n&&t.kind!=="refunded"&&t.kind!=="expired"&&e("p",{className:"text-sm text-fg-dim",children:n}),e(R,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]})}function ke(){const{site:t,logo:n,items:i,placing:m,formLocked:y,email:p,me:c,addressSaveNote:g,lostChangeNote:d,idemKey:f,confirmation:o,setConfirmation:u,payment:h,paypalStep:k,squareStep:N,pendingConf:l,paid:b,setPaid:C,payNote:s,afterpayConfirming:a,gocardlessConfirming:w,zipConfirming:P,klarnaConfirming:O,cardConfirming:$,checkoutResult:A,confirmCardPayment:U,cardStillProcessing:W,renewCardPayment:H,holdRenewed:G,leaveCardPayment:Z,checkoutRootRef:Q,setCheckoutHeaderEl:V}=me();return o?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:b?"Payment received":"Order received"}),r("p",{className:"text-fg-dim",children:[b?r(x,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:o.orderNumber})," has gone through."," "]}):r(x,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:o.orderNumber})," is being reviewed by our team."," "]}),c?r(x,{children:["Track it under"," ",e(R,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):e(x,{children:"We’ve emailed you a link to set a password and track it."})]}),e(ye,{order:o,paid:b}),d&&e("p",{className:"text-sm text-fg-dim",children:d}),s&&e("p",{className:"text-sm text-fg-dim",children:s}),g&&e("p",{className:"text-sm text-fg-dim",children:g}),!c&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(R,{href:`/track?order=${encodeURIComponent(o.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(R,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]}):A?e(be,{result:A,lostChangeNote:d}):$?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Placing your order — one moment."})]}):a?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay — one moment."})]}):w?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Setting up your direct debit…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Confirming with GoCardless — one moment."})]}):P?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip — one moment."})]}):O?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna — one moment."})]}):h&&l?e(Ne,{payment:h,checkout:l,holdRenewed:G,onPaid:U,onProcessing:W,onRenew:H,onBack:Z}):k&&l?e(Ce,{confirmation:l,clientId:t.paypalClientId??"",idemKey:f,onPaid:()=>{C(!0),u(l)},onSkip:()=>u(l)}):N&&l?e(je,{confirmation:l,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:f,onPaid:()=>{C(!0),u(l)},onSkip:()=>u(l)}):r("div",{ref:Q,className:"bg-bg text-fg",children:[r("header",{ref:V,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 max-[640px]:grid-cols-[auto_minmax(0,1fr)_auto] max-[640px]:gap-3 border-b border-line px-[var(--sf-site-gutter,40px)] py-6 backdrop-blur-md max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))] max-[640px]:py-4",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[r(z,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[14px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),e("div",{className:"flex min-w-0 justify-center max-[640px]:[container-type:inline-size]",children:e(z,{href:"/","aria-label":`${t.name} home`,className:"inline-flex max-w-full items-center justify-center overflow-x-clip",children:e(ce,{variant:"header",scrolled:!0,src:n?.url??null,reverse:n?.reverse??!1,reversedSrc:n?.reversed??null,inkIsDark:n?.inkIsDark??null,size:n?.size??"medium",sizePx:n?.sizePx??null,sizeUnit:n?.sizeUnit??null,siteName:t.name,fitWordmarkToContainer:!0,fitFloorPx:se})})}),t.cardPayments?r("span",{className:"flex items-center justify-end gap-3 font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim",children:[e("span",{className:"text-green",children:"●"}),e("span",{className:"max-[640px]:hidden",children:"Encrypted ·"})," Stripe"]}):e("span",{})]}),r("section",{className:"mx-auto flex max-w-[var(--sf-site-width,1600px)] flex-wrap items-center justify-between gap-x-8 gap-y-3 border-b border-line bg-surface px-[var(--sf-site-gutter,40px)] py-4 font-mono text-[13px] font-medium uppercase tracking-[0.24em] text-fg max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))]",children:[e("span",{className:"inline-flex items-center bg-accent px-3 py-1 font-bold text-bg",children:"Checkout"}),e("nav",{"aria-label":"Checkout steps",className:"flex flex-wrap items-center gap-5",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(S=>r("span",{className:["relative flex items-center gap-2 transition-colors",S.state==="pending"?"text-fg-dim":"text-fg",S.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[e("span",{className:S.state==="done"?"text-accent font-bold":"",children:S.n}),e("span",{children:S.label})]},S.n))})]}),r("main",{className:"mx-auto grid max-w-[var(--sf-site-width,1600px)] grid-cols-[1fr_420px] items-start gap-16 px-[var(--sf-site-gutter,40px)] pt-10 pb-[100px] max-view-desktop:grid-cols-1 max-view-desktop:gap-10 max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))] max-view-desktop:pt-8 max-view-desktop:pb-20",children:[r("div",{children:[r(M,{locked:y,children:[e(pe,{}),e(xe,{}),e(ge,{})]}),e(M,{locked:m,children:e(fe,{})})]}),e(ue,{})]}),e("footer",{className:"flex flex-wrap items-center justify-between gap-4 border-t border-line px-[var(--sf-site-gutter,40px)] py-6 font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))]",children:e("span",{children:oe({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function Ne({payment:t,checkout:n,holdRenewed:i,onPaid:m,onProcessing:y,onRenew:p,onBack:c}){const{formatMoney:g}=E(),d=e("span",{className:"text-fg",children:g(Number(t.amount),t.currency)}),f=Y(()=>ie(t.publishableKey),[t.publishableKey]),o=Y(()=>J(),[]),u=X(n.expiresAt??"",ee());return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:le(n)}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:n.orderNumber?r(x,{children:["Your order is placed. Pay ",d," by card to confirm it now."]}):i?r(x,{children:["Your hold ran out, so your items are held again",u?` until ${u}`:"",". Enter your card again, then pay ",d,"."]}):r(x,{children:["Your items are held",u?` until ${u}`:"",". Pay ",d," by card to place your order."]})}),e(te,{stripe:f,options:{clientSecret:t.clientSecret,appearance:o},children:e(Pe,{payment:t,checkout:n,onPaid:m,onProcessing:y,onRenew:p,onBack:c})},t.clientSecret)]})]})})}const we=5;function Pe({payment:t,checkout:n,onPaid:i,onProcessing:m,onRenew:y,onBack:p}){const{formatMoney:c}=E(),g=ae(),d=ne(),[f,o]=v(!1),[u,h]=v(null),k=j(!1);async function N(){try{return(await g.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function l(s){let a=s;for(let w=0;a==="processing"&&w<we;w+=1)await new Promise(P=>setTimeout(P,1e3)),a=await N()??a;if(a==="succeeded"){i();return}if(a==="processing"){m();return}h("Payment did not complete. Please try again."),o(!1)}async function b(){if(!g||!d||f)return;o(!0),h(null),k.current=!0;const s=await g.confirmPayment({elements:d,redirect:"if_required"}).catch(()=>null);if(!s){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}h(a===void 0?q:"Payment failed. Please try again."),o(!1);return}if(s.error){if(!n.orderNumber&&s.error.code==="payment_intent_unexpected_state"){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}if(a===void 0){h(q),o(!1);return}await y(a==="canceled"),o(!1);return}h(s.error.message??"Payment failed. Please try again."),o(!1);return}await l(s.paymentIntent?.status)}async function C(){if(f)return;if(!k.current){p();return}o(!0),h(null);const s=await N();if(s==="succeeded"||s==="processing"){await l(s);return}if(o(!1),s===void 0){h(q);return}p()}return r("div",{className:"flex flex-col gap-4",children:[e(re,{}),u&&e(_,{role:"alert",children:u}),e("button",{type:"button",onClick:b,disabled:!g||!d||f,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!g||!d||f?"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:f?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",c(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),!n.orderNumber&&!f&&r("button",{type:"button",onClick:C,className:"inline-flex items-center gap-3 self-start font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{children:"Back to checkout"})]})]})}const B="paypal-sdk-js";let I=null;function ve(t,n){const i=`${t}|${n}`;if(I?.key===i)return I.promise;const m=new Promise((y,p)=>{document.getElementById(B)?.remove();const c=document.createElement("script");c.id=B;const g=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});c.src=`https://www.paypal.com/sdk/js?${g}`,c.onload=()=>{const d=window.paypal;d?y(d):p(new Error("PayPal SDK loaded without its namespace"))},c.onerror=()=>p(new Error("PayPal SDK failed to load")),document.head.appendChild(c)});return I={key:i,promise:m},m}function Ce({confirmation:t,clientId:n,idemKey:i,onPaid:m,onSkip:y}){const{formatMoney:p}=E(),c=j(null),[g,d]=v(!1),[f,o]=v(null),u=j(m);return u.current=m,D(()=>{let h=!1,k=null;return ve(n,t.currency).then(N=>{if(!(h||!c.current))return k=N.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await T.createPaypalOrder({idempotencyKey:i})).paypalOrderId,onApprove:async l=>{try{if((await T.capturePaypalOrder({idempotencyKey:i,paypalOrderId:l.orderID})).status==="paid"){u.current();return}o("PayPal did not complete the payment. Please try again.")}catch(b){o(b instanceof L?b.message:"PayPal payment failed. Please try again.")}},onError:()=>{o("PayPal could not process the payment. Please try again.")}}),k.render(c.current).then(()=>{h||d(!0)})}).catch(()=>{h||o("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{h=!0,k?.close?.()}},[n,t.currency,i]),e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:p(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!g&&!f&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:c}),f&&e(_,{role:"alert",children:f}),e("button",{type:"button",onClick:y,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}const F="square-web-sdk";let K=null;function Se(t){const n=t==="sandbox"?"sandbox":"production";if(K?.key===n)return K.promise;const i=new Promise((m,y)=>{document.getElementById(F)?.remove();const p=document.createElement("script");p.id=F,p.src=n==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",p.onload=()=>{const c=window.Square;c?m(c):y(new Error("Square SDK loaded without its namespace"))},p.onerror=()=>y(new Error("Square SDK failed to load")),document.head.appendChild(p)});return K={key:n,promise:i},i}function je({confirmation:t,applicationId:n,locationId:i,environment:m,idemKey:y,onPaid:p,onSkip:c}){const{formatMoney:g}=E(),d=j(null),f=j(null),o=j(null),[u,h]=v(!1),[k,N]=v(!1),[l,b]=v(null);D(()=>{let s=!1,a=null;return Se(m).then(async w=>{if(s||!d.current)return;const P=w.payments(n,i);o.current=P,a=await P.card(),await a.attach(d.current),f.current=a,s||h(!0)}).catch(()=>{s||b("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{s=!0,a?.destroy?.()}},[n,i,m]);async function C(){const s=f.current;if(!(!s||k)){N(!0),b(null);try{const a=await s.tokenize();if(a.status!=="OK"||!a.token){b(a.errors?.[0]?.message??"Please check the card details and try again."),N(!1);return}let w;try{w=(await o.current?.verifyBuyer?.(a.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await T.chargeSquare({idempotencyKey:y,sourceId:a.token,...w?{verificationToken:w}:{}})).status==="paid"){p();return}b("Square did not complete the payment. Please try again.")}catch(a){b(a instanceof L?a.message:"Square payment failed. Please try again.")}N(!1)}}return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:g(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!u&&!l&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form…"}),e("div",{ref:d}),l&&e(_,{role:"alert",children:l}),e("button",{type:"button",onClick:C,disabled:!u||k,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!u||k?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:k?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",g(Number(t.grandTotal),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:c,disabled:k,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}export{be as PayFirstResultView,he as default};
|
|
1
|
+
"use client";import{jsx as e,jsxs as r,Fragment as x}from"react/jsx-runtime";import R from"next/link";import{useEffect as D,useMemo as Y,useRef as j,useState as v}from"react";import{holdTime as X}from"../../lib/checkout/hold-time.js";import{stripeAppearance as J}from"../../lib/checkout/stripe-appearance.js";import{userZone as ee}from"efficient-shell/format";import{Elements as te,PaymentElement as re,useElements as ne,useStripe as ae}from"@stripe/react-stripe-js";import{loadStripe as ie}from"@stripe/stripe-js";import{useCurrency as E}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{resolveCopyright as oe}from"../../lib/content/site.js";import{ApiError as L,products as q}from"../../lib/api/index.js";import ce,{WORDMARK_FIT_FLOOR_PX as se}from"efficient-web-builder/render/components/Logo";import{NOT_CHECKED as I,orderReference as le}from"../../lib/checkout/pay-first.js";import{CheckoutStateProvider as de,useCheckout as me}from"./checkout-state.js";import{CheckoutContact as pe,CheckoutOrderSummary as ue,CheckoutPayment as fe,CheckoutShippingAddress as xe,CheckoutShippingMethod as ge,FormLock as M,LeaveLink as z}from"./checkout-parts.js";function he(t){return e(de,{...t,children:e(ke,{})})}function ye({order:t,paid:n}){const{formatMoney:i}=E();if(!t.grandTotal||!t.currency)return null;const m=c=>i(Number(c),t.currency),y=Number(t.freightCharge??0),p=Number(t.discountAmount??0);return r("dl",{className:"grid w-full max-w-sm grid-cols-[1fr_auto] gap-x-6 gap-y-1 border-y border-line py-3 text-left text-sm",children:[(t.shippingMethod||y>0)&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Delivery",t.shippingMethod?` · ${t.shippingMethod}`:""]}),e("dd",{className:"text-right font-mono",children:m(t.freightCharge??"0")})]}),p>0&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Discount",t.couponCode?` · ${t.couponCode}`:""]}),r("dd",{className:"text-right font-mono",children:["−",m(t.discountAmount??"0")]})]}),e("dt",{className:"text-fg",children:n?"Total paid":"Order total"}),e("dd",{className:"text-right font-mono text-fg",children:m(t.grandTotal)})]})}function be({result:t,lostChangeNote:n=null}){const i=e("span",{className:"font-mono text-fg",children:t.checkoutNumber});return r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:t.kind==="refunded"||t.kind==="expired"?"Order not placed":t.kind==="processing"?"Payment processing":"Payment received"}),e("p",{className:"text-fg-dim",children:t.kind==="refunded"?r(x,{children:["An item sold out or an offer ended while you paid for checkout ",i,". Your payment goes back to your card."]}):t.kind==="expired"?r(x,{children:["The hold on checkout ",i," ran out before your payment arrived. Your payment goes back to your card."]}):t.kind==="processing"?r(x,{children:["Your payment for checkout ",i," is being processed. When it goes through, we will email your order confirmation."]}):r(x,{children:["Thank you — your payment",t.checkoutNumber?r(x,{children:[" for checkout ",i]}):null," has gone through. We will email you the order number shortly."]})}),n&&t.kind!=="refunded"&&t.kind!=="expired"&&e("p",{className:"text-sm text-fg-dim",children:n}),e(R,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]})}function ke(){const{site:t,logo:n,items:i,placing:m,formLocked:y,email:p,me:c,addressSaveNote:g,lostChangeNote:d,idemKey:f,confirmation:o,setConfirmation:u,payment:h,paypalStep:k,squareStep:N,pendingConf:l,paid:b,setPaid:C,payNote:s,afterpayConfirming:a,gocardlessConfirming:w,zipConfirming:P,klarnaConfirming:O,cardConfirming:$,checkoutResult:A,confirmCardPayment:U,cardStillProcessing:W,renewCardPayment:H,holdRenewed:G,leaveCardPayment:Z,checkoutRootRef:Q,setCheckoutHeaderEl:V}=me();return o?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:b?"Payment received":"Order received"}),r("p",{className:"text-fg-dim",children:[b?r(x,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:o.orderNumber})," has gone through."," "]}):r(x,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:o.orderNumber})," is being reviewed by our team."," "]}),c?r(x,{children:["Track it under"," ",e(R,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):e(x,{children:"We’ve emailed you a link to set a password and track it."})]}),e(ye,{order:o,paid:b}),d&&e("p",{className:"text-sm text-fg-dim",children:d}),s&&e("p",{className:"text-sm text-fg-dim",children:s}),g&&e("p",{className:"text-sm text-fg-dim",children:g}),!c&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(R,{href:`/track?order=${encodeURIComponent(o.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(R,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]}):A?e(be,{result:A,lostChangeNote:d}):$?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Placing your order — one moment."})]}):a?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay — one moment."})]}):w?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Setting up your direct debit…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Confirming with GoCardless — one moment."})]}):P?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip — one moment."})]}):O?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna — one moment."})]}):h&&l?e(Ne,{payment:h,checkout:l,holdRenewed:G,onPaid:U,onProcessing:W,onRenew:H,onBack:Z}):k&&l?e(Ce,{confirmation:l,clientId:t.paypalClientId??"",idemKey:f,onPaid:()=>{C(!0),u(l)},onSkip:()=>u(l)}):N&&l?e(je,{confirmation:l,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:f,onPaid:()=>{C(!0),u(l)},onSkip:()=>u(l)}):r("div",{ref:Q,className:"bg-bg text-fg",children:[r("header",{ref:V,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 max-[640px]:grid-cols-[auto_minmax(0,1fr)_auto] max-[640px]:gap-3 border-b border-line px-[var(--sf-site-gutter,40px)] py-6 backdrop-blur-md max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))] max-[640px]:py-4",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[r(z,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[14px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),e("div",{className:"flex min-w-0 justify-center max-[640px]:[container-type:inline-size]",children:e(z,{href:"/","aria-label":`${t.name} home`,className:"inline-flex max-w-full items-center justify-center overflow-x-clip",children:e(ce,{variant:"header",scrolled:!0,src:n?.url??null,reverse:n?.reverse??!1,reversedSrc:n?.reversed??null,inkIsDark:n?.inkIsDark??null,size:n?.size??"medium",sizePx:n?.sizePx??null,sizeUnit:n?.sizeUnit??null,siteName:t.name,fitWordmarkToContainer:!0,fitFloorPx:se})})}),t.cardPayments?r("span",{className:"flex items-center justify-end gap-3 font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim",children:[e("span",{className:"text-green",children:"●"}),e("span",{className:"max-[640px]:hidden",children:"Encrypted ·"})," Stripe"]}):e("span",{})]}),r("section",{className:"mx-auto flex max-w-[var(--sf-site-width,1600px)] flex-wrap items-center justify-between gap-x-8 gap-y-3 border-b border-line bg-surface px-[var(--sf-site-gutter,40px)] py-4 font-mono text-[13px] font-medium uppercase tracking-[0.24em] text-fg max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))]",children:[e("span",{className:"inline-flex items-center bg-accent px-3 py-1 font-bold text-bg",children:"Checkout"}),e("nav",{"aria-label":"Checkout steps",className:"flex flex-wrap items-center gap-5",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(S=>r("span",{className:["relative flex items-center gap-2 transition-colors",S.state==="pending"?"text-fg-dim":"text-fg",S.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[e("span",{className:S.state==="done"?"text-accent font-bold":"",children:S.n}),e("span",{children:S.label})]},S.n))})]}),r("main",{className:"mx-auto grid max-w-[var(--sf-site-width,1600px)] grid-cols-[1fr_420px] items-start gap-16 px-[var(--sf-site-gutter,40px)] pt-10 pb-[100px] max-view-desktop:grid-cols-1 max-view-desktop:gap-10 max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))] max-view-desktop:pt-8 max-view-desktop:pb-20",children:[r("div",{children:[r(M,{locked:y,children:[e(pe,{}),e(xe,{}),e(ge,{})]}),e(M,{locked:m,children:e(fe,{})})]}),e(ue,{})]}),e("footer",{className:"flex flex-wrap items-center justify-between gap-4 border-t border-line px-[var(--sf-site-gutter,40px)] py-6 font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))]",children:e("span",{children:oe({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function Ne({payment:t,checkout:n,holdRenewed:i,onPaid:m,onProcessing:y,onRenew:p,onBack:c}){const{formatMoney:g}=E(),d=e("span",{className:"text-fg",children:g(Number(t.amount),t.currency)}),f=Y(()=>ie(t.publishableKey),[t.publishableKey]),o=Y(()=>J(),[]),u=X(n.expiresAt??"",ee()??"");return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:le(n)}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:n.orderNumber?r(x,{children:["Your order is placed. Pay ",d," by card to confirm it now."]}):i?r(x,{children:["Your hold ran out, so your items are held again",u?` until ${u}`:"",". Enter your card again, then pay ",d,"."]}):r(x,{children:["Your items are held",u?` until ${u}`:"",". Pay ",d," by card to place your order."]})}),e(te,{stripe:f,options:{clientSecret:t.clientSecret,appearance:o},children:e(Pe,{payment:t,checkout:n,onPaid:m,onProcessing:y,onRenew:p,onBack:c})},t.clientSecret)]})]})})}const we=5;function Pe({payment:t,checkout:n,onPaid:i,onProcessing:m,onRenew:y,onBack:p}){const{formatMoney:c}=E(),g=ae(),d=ne(),[f,o]=v(!1),[u,h]=v(null),k=j(!1);async function N(){try{return(await g.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function l(s){let a=s;for(let w=0;a==="processing"&&w<we;w+=1)await new Promise(P=>setTimeout(P,1e3)),a=await N()??a;if(a==="succeeded"){i();return}if(a==="processing"){m();return}h("Payment did not complete. Please try again."),o(!1)}async function b(){if(!g||!d||f)return;o(!0),h(null),k.current=!0;const s=await g.confirmPayment({elements:d,redirect:"if_required"}).catch(()=>null);if(!s){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}h(a===void 0?I:"Payment failed. Please try again."),o(!1);return}if(s.error){if(!n.orderNumber&&s.error.code==="payment_intent_unexpected_state"){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}if(a===void 0){h(I),o(!1);return}await y(a==="canceled"),o(!1);return}h(s.error.message??"Payment failed. Please try again."),o(!1);return}await l(s.paymentIntent?.status)}async function C(){if(f)return;if(!k.current){p();return}o(!0),h(null);const s=await N();if(s==="succeeded"||s==="processing"){await l(s);return}if(o(!1),s===void 0){h(I);return}p()}return r("div",{className:"flex flex-col gap-4",children:[e(re,{}),u&&e(_,{role:"alert",children:u}),e("button",{type:"button",onClick:b,disabled:!g||!d||f,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!g||!d||f?"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:f?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",c(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),!n.orderNumber&&!f&&r("button",{type:"button",onClick:C,className:"inline-flex items-center gap-3 self-start font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{children:"Back to checkout"})]})]})}const B="paypal-sdk-js";let T=null;function ve(t,n){const i=`${t}|${n}`;if(T?.key===i)return T.promise;const m=new Promise((y,p)=>{document.getElementById(B)?.remove();const c=document.createElement("script");c.id=B;const g=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});c.src=`https://www.paypal.com/sdk/js?${g}`,c.onload=()=>{const d=window.paypal;d?y(d):p(new Error("PayPal SDK loaded without its namespace"))},c.onerror=()=>p(new Error("PayPal SDK failed to load")),document.head.appendChild(c)});return T={key:i,promise:m},m}function Ce({confirmation:t,clientId:n,idemKey:i,onPaid:m,onSkip:y}){const{formatMoney:p}=E(),c=j(null),[g,d]=v(!1),[f,o]=v(null),u=j(m);return u.current=m,D(()=>{let h=!1,k=null;return ve(n,t.currency).then(N=>{if(!(h||!c.current))return k=N.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await q.createPaypalOrder({idempotencyKey:i})).paypalOrderId,onApprove:async l=>{try{if((await q.capturePaypalOrder({idempotencyKey:i,paypalOrderId:l.orderID})).status==="paid"){u.current();return}o("PayPal did not complete the payment. Please try again.")}catch(b){o(b instanceof L?b.message:"PayPal payment failed. Please try again.")}},onError:()=>{o("PayPal could not process the payment. Please try again.")}}),k.render(c.current).then(()=>{h||d(!0)})}).catch(()=>{h||o("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{h=!0,k?.close?.()}},[n,t.currency,i]),e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:p(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!g&&!f&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:c}),f&&e(_,{role:"alert",children:f}),e("button",{type:"button",onClick:y,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}const F="square-web-sdk";let K=null;function Se(t){const n=t==="sandbox"?"sandbox":"production";if(K?.key===n)return K.promise;const i=new Promise((m,y)=>{document.getElementById(F)?.remove();const p=document.createElement("script");p.id=F,p.src=n==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",p.onload=()=>{const c=window.Square;c?m(c):y(new Error("Square SDK loaded without its namespace"))},p.onerror=()=>y(new Error("Square SDK failed to load")),document.head.appendChild(p)});return K={key:n,promise:i},i}function je({confirmation:t,applicationId:n,locationId:i,environment:m,idemKey:y,onPaid:p,onSkip:c}){const{formatMoney:g}=E(),d=j(null),f=j(null),o=j(null),[u,h]=v(!1),[k,N]=v(!1),[l,b]=v(null);D(()=>{let s=!1,a=null;return Se(m).then(async w=>{if(s||!d.current)return;const P=w.payments(n,i);o.current=P,a=await P.card(),await a.attach(d.current),f.current=a,s||h(!0)}).catch(()=>{s||b("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{s=!0,a?.destroy?.()}},[n,i,m]);async function C(){const s=f.current;if(!(!s||k)){N(!0),b(null);try{const a=await s.tokenize();if(a.status!=="OK"||!a.token){b(a.errors?.[0]?.message??"Please check the card details and try again."),N(!1);return}let w;try{w=(await o.current?.verifyBuyer?.(a.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await q.chargeSquare({idempotencyKey:y,sourceId:a.token,...w?{verificationToken:w}:{}})).status==="paid"){p();return}b("Square did not complete the payment. Please try again.")}catch(a){b(a instanceof L?a.message:"Square payment failed. Please try again.")}N(!1)}}return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:g(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!u&&!l&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form…"}),e("div",{ref:d}),l&&e(_,{role:"alert",children:l}),e("button",{type:"button",onClick:C,disabled:!u||k,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!u||k?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:k?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",g(Number(t.grandTotal),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:c,disabled:k,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}export{be as PayFirstResultView,he as default};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export interface AppointmentSpan {
|
|
2
|
+
start: string;
|
|
3
|
+
end?: string | null;
|
|
4
|
+
}
|
|
1
5
|
export declare function formatAppointmentTime(value: string, ...zones: string[]): string;
|
|
2
|
-
export declare function formatAppointment(value: string, ...zones: string[]): string;
|
|
6
|
+
export declare function formatAppointment(value: string | AppointmentSpan, ...zones: string[]): string;
|
|
3
7
|
export declare function startHasPassed(start: string, now: number): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{formatTime as
|
|
1
|
+
import{dayKeyInZone as c,formatDateTime as i,formatTime as u}from"efficient-shell/format";import{firstReadableZone as f,runtimeLocale as l}from"../zone.js";const Z={weekday:"long",day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"2-digit"},d={weekday:"long",day:"numeric",month:"long",year:"numeric"},y={hour:"numeric",minute:"2-digit"},p={...y,timeZoneName:"short"};function m(e){const n=new Date(e);return Number.isFinite(n.getTime())?n:null}function A(e,...n){const t=f(...n);return!t||!m(e)?"":u(e,{locale:l(),timeZone:t})}function k(e,...n){const t=typeof e=="string"?{start:e}:e,o=f(...n),s=m(t.start);if(!o||!s)return"";const r=l(),a=t.end?m(t.end):null;if(!a||a.getTime()<=s.getTime())return i(t.start,{locale:r,timeZone:o,style:Z,zoneName:"short"});const g=i(t.start,{locale:r,timeZone:o,style:d,clock:y}),D=c(t.start,o)===c(t.end,o)?u(t.end,{locale:r,timeZone:o,clock:p}):i(t.end,{locale:r,timeZone:o,style:d,clock:p});return`${g} – ${D}`}function C(e,n){const t=Date.parse(e);return Number.isFinite(t)&&t<=n}export{k as formatAppointment,A as formatAppointmentTime,C as startHasPassed};
|