@shopify/hydrogen 2024.4.1 → 2024.4.2
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/dist/development/index.cjs +171 -73
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +170 -73
- package/dist/development/index.js.map +1 -1
- package/dist/production/index.cjs +86 -78
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.d.cts +47 -15
- package/dist/production/index.d.ts +47 -15
- package/dist/production/index.js +42 -35
- package/dist/production/index.js.map +1 -1
- package/dist/vite/plugin.js +1 -3
- package/package.json +4 -3
|
@@ -4,21 +4,23 @@ var hydrogenReact = require('@shopify/hydrogen-react');
|
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var react$1 = require('@remix-run/react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
-
var
|
|
7
|
+
var Ta = require('content-security-policy-builder');
|
|
8
|
+
var Ur = require('tiny-invariant');
|
|
8
9
|
|
|
9
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
11
|
|
|
11
|
-
var
|
|
12
|
+
var Ta__default = /*#__PURE__*/_interopDefault(Ta);
|
|
13
|
+
var Ur__default = /*#__PURE__*/_interopDefault(Ur);
|
|
12
14
|
|
|
13
|
-
var
|
|
15
|
+
var Qr=Object.defineProperty;var Br=(e,t)=>()=>(e&&(t=e(e=0)),t);var Gr=(e,t)=>{for(var r in t)Qr(e,r,{get:t[r],enumerable:!0});};var Yt={};Gr(Yt,{default:()=>Jt,logSeoTags:()=>zt});function Jt({headTags:e}){return zt(e),null}function zt(e){console.log(" "),console.log("%cSEO Meta Tags",`${mo}`),console.log(" "),e.forEach(t=>{if(t.tag==="script"){if(console.log("%c\u2022 JSON LD ",ut),t.children)try{console.table(JSON.parse(t.children),["name","content"]);}catch{console.log(t.children);}}else {if(console.log(`%c\u2022 ${t.tag} `,ut),t.children)if(typeof t.children=="string")console.log(`\u21B3 ${t.children}`);else try{Object.entries(JSON.parse(t.children)).map(([r,o])=>console.log(`\u21B3 ${o}`));}catch{console.log(t.children);}if(t.props.property==="og:image:url"){let r=t.props.content;go(r).then(o=>{let a=`font-size: 400px; padding: 10px; background: white url(${o}) no-repeat center; background-size: contain;`;console.log("%c\u2022 Share image preview",ut),console.log("%c ",a),console.log(`\u21B3 ${r}`);}).catch(o=>{console.error(o);});}Object.entries(t.props).map(([r,o])=>{console.log(`\u21B3 ${r} \u2192 ${o}`);});}console.log(" ");});}async function go(e){let o=await(await(await fetch(e)).blob()).arrayBuffer();return `data:image/png;base64,${ho(o)}`}function ho(e){let t="",r=new Uint8Array(e),o=r.byteLength;for(let a=0;a<o;a++)t+=String.fromCharCode(r[a]);return btoa(t)}var ut,mo,Xt=Br(()=>{ut="text-transform: uppercase;",mo="text-transform: uppercase; font-weight: bold; text-transform: uppercase;font-weight: bold";});function Ot(e){let t=Array.isArray(e)?e:[e],r="";for(let o of t)o!=null&&(typeof o=="object"?r+=JSON.stringify(o):r+=o.toString());return encodeURIComponent(r)}var be="public",Wr="private",Qe="no-store",Ut={maxAge:"max-age",staleWhileRevalidate:"stale-while-revalidate",sMaxAge:"s-maxage",staleIfError:"stale-if-error"};function ye(e){let t=[];return Object.keys(e).forEach(r=>{r==="mode"?t.push(e[r]):Ut[r]&&t.push(`${Ut[r]}=${e[r]}`);}),t.join(", ")}function Be(){return {mode:Qe}}function Ge(e){if(e?.mode&&e?.mode!==be&&e?.mode!==Wr)throw Error("'mode' must be either 'public' or 'private'")}function re(e){return Ge(e),{mode:be,maxAge:1,staleWhileRevalidate:9,...e}}function We(e){return Ge(e),{mode:be,maxAge:3600,staleWhileRevalidate:82800,...e}}function oe(e){return Ge(e),{mode:be,maxAge:1,staleWhileRevalidate:86399,...e}}function je(e){return e}function j(e){return String(e).includes("__proto__")?JSON.parse(e,jr):JSON.parse(e)}function jr(e,t){if(e!=="__proto__")return t}function Ee(e,t){return e&&t?{...e,...t}:e||oe()}function Ke(e){return ye(Ee(e))}async function Kr(e,t){if(!e)return;let r=await e.match(t);if(!r){return}return r}async function Jr(e,t,r,o){if(!e)return;let a=Ee(o),s=Ke(Ee(a,{maxAge:(a.maxAge||0)+(a.staleWhileRevalidate||0)})),n=Ke(Ee(a));r.headers.set("cache-control",s),r.headers.set("real-cache-control",n),r.headers.set("cache-put-date",new Date().toUTCString()),await e.put(t,r);}async function zr(e,t){e&&await e.delete(t);}function Yr(e,t){let r=e.headers.get("real-cache-control"),o=0;if(r){let s=r.match(/max-age=(\d*)/);s&&s.length>1&&(o=parseFloat(s[1]));}return [(new Date().valueOf()-new Date(t).valueOf())/1e3,o]}function Xr(e,t){let r=t.headers.get("cache-put-date");if(!r)return !1;let[o,a]=Yr(t,r),s=o>a;return s}var xe={get:Kr,set:Jr,delete:zr,generateDefaultCacheControlHeader:Ke,isStale:Xr};function fe(e){return `https://shopify.dev/?${e}`}function Zr(e){return e||oe()}async function _t(e,t){if(!e)return;let r=fe(t),o=new Request(r),a=await xe.get(e,o);if(!a)return;let s=await a.text();try{return [j(s),a]}catch{return [s,a]}}async function kt(e,t,r,o){if(!e)return;let a=fe(t),s=new Request(a),n=new Response(JSON.stringify(r));await xe.set(e,s,n,Zr(o));}function Lt(e,t){return xe.isStale(new Request(fe(e)),t)}function Nt(e,t){return [e,{status:t.status,statusText:t.statusText,headers:Array.from(t.headers.entries())}]}function Mt([e,t]){return [e,new Response(e,t)]}var Vt=(e,t)=>!e?.errors&&t.status<400,Je=new Set;async function ze(e,t,{strategy:r=re(),cacheInstance:o,shouldCacheResult:a=()=>!0,waitUntil:s,debugInfo:n}){let u=Ot([...typeof e=="string"?[e]:e]),y=f=>{({displayName:f.displayName,url:f.response?.url,responseInit:{status:f.response?.status||0,statusText:f.response?.statusText||"",headers:Array.from(f.response?.headers.entries()||[])}});},p=void 0;if(!o||!r||r.mode===Qe){let f=await t({addDebugData:y});return f}let d=f=>kt(o,u,{value:f,debugInfo:void 0},r),g=await _t(o,u);if(g&&typeof g[0]!="string"){let[{value:f,debugInfo:R},v]=g;let N=Lt(u,v)?"STALE":"HIT";if(!Je.has(u)&&N==="STALE"){Je.add(u);let F=Promise.resolve().then(async()=>{let ee=Date.now();try{let _=await t({addDebugData:y});a(_)&&(await d(_),p?.({result:_,cacheStatus:"PUT",overrideStartTime:ee}));}catch(_){_.message&&(_.message="SWR in sub-request failed: "+_.message),console.error(_);}finally{Je.delete(u);}});s?.(F);}return f}let S=await t({addDebugData:y});if(a(S)){let f=Promise.resolve().then(async()=>{await d(S);});s?.(f);}return S}async function Ft(e,t,{cacheInstance:r,cache:o,cacheKey:a=[e,t],shouldCacheResponse:s=()=>!0,waitUntil:n,returnType:i="json",debugInfo:u}={}){return !o&&(!t.method||t.method==="GET")&&(o=re()),ze(a,async()=>{let c=await fetch(e,t),l;try{l=await c[i]();}catch{try{l=await c.text();}catch{return Nt("",c)}}return Nt(l,c)},{cacheInstance:r,waitUntil:n,strategy:o??null,debugInfo:u,shouldCacheResult:c=>s(...Mt(c))}).then(Mt)}var me="2024.4.2";var Ye="Custom-Storefront-Request-Group-ID",Xe="X-Shopify-Storefront-Access-Token",Ze="X-SDK-Variant",et="X-SDK-Variant-Source",tt="X-SDK-Version",De="2024-04",ae=`Shopify Hydrogen ${me}`,$t="30243aa5-17c1-465a-8493-944bcc4e88aa",E="customerAccount",ne="buyer";function qt(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`weak-${Math.random().toString(16).substring(2)}`}function se(e){return e.replace(/\s*#.*$/gm,"").replace(/\s+/gm," ").trim()}var eo=/(^|}\s)query[\s({]/im,to=/(^|}\s)mutation[\s({]/im;function Oe(e,t){if(!eo.test(e))throw new Error(`[h2:error:${t}] Can only execute queries`)}function Ue(e,t){if(!to.test(e))throw new Error(`[h2:error:${t}] Can only execute mutations`)}var K=class extends Error{locations;path;extensions;constructor(t,r={}){let a=(r.clientOperation?`[h2:error:${r.clientOperation}] `:"")+t+(r.requestId?` - Request ID: ${r.requestId}`:"");super(a),this.name="GraphQLError",this.extensions=r.extensions,this.locations=r.locations,this.path=r.path,this.stack=r.stack||void 0;try{this.cause=JSON.stringify({...typeof r.cause=="object"?r.cause:{},requestId:r.requestId});}catch{r.cause&&(this.cause=r.cause);}}get[Symbol.toStringTag](){return this.name}toString(){let t=`${this.name}: ${this.message}`;if(this.path)try{t+=` | path: ${JSON.stringify(this.path)}`;}catch{}if(this.extensions)try{t+=` | extensions: ${JSON.stringify(this.extensions)}`;}catch{}return t+=`
|
|
14
16
|
`,this.stack&&(t+=`${this.stack.slice(this.stack.indexOf(`
|
|
15
17
|
`)+1)}
|
|
16
|
-
`),t}toJSON(){return {name:"Error",message:""}}};function
|
|
18
|
+
`),t}toJSON(){return {name:"Error",message:""}}};function ge({url:e,response:t,errors:r,type:o,query:a,queryVariables:s,ErrorConstructor:n=Error,client:i="storefront"}){let u=(typeof r=="string"?r:r?.map?.(l=>l.message).join(`
|
|
17
19
|
`))||`URL: ${e}
|
|
18
|
-
API response error: ${t.status}`,c=new
|
|
20
|
+
API response error: ${t.status}`,c=new K(u,{query:a,queryVariables:s,cause:{errors:r},clientOperation:`${i}.${o}`,requestId:t.headers.get("x-request-id")});throw new n(c.message,{cause:c.cause})}function ie(e,t={}){let r=new Error,o=(a,s="Error")=>{let n=(r.stack??"").split(`
|
|
19
21
|
`).slice(3+(t.stackOffset??0)).join(`
|
|
20
22
|
`).replace(/ at loader(\d+) \(/,(i,u)=>i.replace(u,""));return `${s}: ${a}
|
|
21
|
-
`+n};return e.then(a=>{if(a?.errors&&Array.isArray(a.errors)){let s=typeof t.logErrors=="function"?t.logErrors:()=>t.logErrors??!1;a.errors.forEach(n=>{n&&(n.stack=o(n.message,n.name),s(n)&&console.error(n));});}return a}).catch(a=>{throw a&&(a.stack=o(a.message,a.name)),a})}var
|
|
23
|
+
`+n};return e.then(a=>{if(a?.errors&&Array.isArray(a.errors)){let s=typeof t.logErrors=="function"?t.logErrors:()=>t.logErrors??!1;a.errors.forEach(n=>{n&&(n.stack=o(n.message,n.name),s(n)&&console.error(n));});}return a}).catch(a=>{throw a&&(a.stack=o(a.message,a.name)),a})}var q=void 0;var io={language:"EN",country:"US"};function Kn(e){let {storefrontHeaders:t,cache:r,waitUntil:o,i18n:a,storefrontId:s,logErrors:n=!0,...i}=e,{getPublicTokenHeaders:c,getPrivateTokenHeaders:l,getStorefrontApiUrl:y,getShopifyDomain:m}=hydrogenReact.createStorefrontClient(i),d=(i.privateStorefrontToken?l:c)({contentType:"json",buyerIp:t?.buyerIp||""});if(d[Ye]=t?.requestGroupId||qt(),s&&(d[hydrogenReact.SHOPIFY_STOREFRONT_ID_HEADER]=s),(d["user-agent"]=`Hydrogen ${me}`),t&&t.cookie){let f=hydrogenReact.getShopifyCookies(t.cookie??"");f[hydrogenReact.SHOPIFY_Y]&&(d[hydrogenReact.SHOPIFY_STOREFRONT_Y_HEADER]=f[hydrogenReact.SHOPIFY_Y]),f[hydrogenReact.SHOPIFY_S]&&(d[hydrogenReact.SHOPIFY_STOREFRONT_S_HEADER]=f[hydrogenReact.SHOPIFY_S]);}let g=JSON.stringify({"content-type":d["content-type"],"user-agent":d["user-agent"],[Ze]:d[Ze],[et]:d[et],[tt]:d[tt],[Xe]:d[Xe]});async function S({query:f,mutation:R,variables:v,cache:N,headers:F=[],storefrontApiVersion:ee,displayName:_,stackInfo:Ie}){let h=F instanceof Headers?Object.fromEntries(F.entries()):Array.isArray(F)?Object.fromEntries(F):F,C=f??R,A={...v};a&&(!v?.country&&/\$country/.test(C)&&(A.country=a.country),!v?.language&&/\$language/.test(C)&&(A.language=a.language));let T=y({storefrontApiVersion:ee}),M=JSON.stringify({query:C,variables:A}),V={method:"POST",headers:{...d,...h},body:M},D=[T,V.method,g,V.body],[O,U]=await Ft(T,V,{cacheInstance:R?void 0:r,cache:N||oe(),cacheKey:D,shouldCacheResponse:Vt,waitUntil:o,debugInfo:{requestId:V.headers[Ye],displayName:_,url:T,stackInfo:Ie,graphql:M,purpose:t?.purpose}}),b={url:T,response:U,type:R?"mutation":"query",query:C,queryVariables:A,errors:void 0};if(!U.ok){let $;try{$=j(O);}catch{$=[{message:O}];}ge({...b,errors:$});}let{data:L,errors:le}=O,te=le?.map(({message:$,...de})=>new K($,{...de,clientOperation:`storefront.${b.type}`,requestId:U.headers.get("x-request-id"),queryVariables:A,query:C}));return P(L,te)}return {storefront:{query(f,R){f=se(f),Oe(f,"storefront.query");let v=Bt?.(f);return ie(S({...R,query:f,stackInfo:q?.(v)}),{stackOffset:v,logErrors:n})},mutate(f,R){f=se(f),Ue(f,"storefront.mutate");let v=Bt?.(f);return ie(S({...R,mutation:f,stackInfo:q?.(v)}),{stackOffset:v,logErrors:n})},cache:r,CacheNone:Be,CacheLong:We,CacheShort:re,CacheCustom:je,generateCacheControlHeader:ye,getPublicTokenHeaders:c,getPrivateTokenHeaders:l,getShopifyDomain:m,getApiUrl:y,i18n:a??io}}}var Bt=void 0;function P(e,t){return {...e,...t&&{errors:t}}}function _e(e,t){let r=e.headers?.get?.(t)??e.headers?.[t];return typeof r=="string"?r:null}function J(e){return {requestId:e?_e(e,"request-id"):void 0,purpose:e?_e(e,"purpose"):void 0}}function es({cache:e,waitUntil:t,request:r}){return function(a,s,n){return ze(a,n,{strategy:s,cacheInstance:e,waitUntil:t,debugInfo:{...J(r),stackInfo:q?.()}})}}var rt=class{#e;constructor(){this.#e=new Map;}add(t){throw new Error("Method not implemented. Use `put` instead.")}addAll(t){throw new Error("Method not implemented. Use `put` instead.")}matchAll(t,r){throw new Error("Method not implemented. Use `match` instead.")}async put(t,r){if(t.method!=="GET")throw new TypeError("Cannot cache response to non-GET request.");if(r.status===206)throw new TypeError("Cannot cache response to a range request (206 Partial Content).");if(r.headers.get("vary")?.includes("*"))throw new TypeError("Cannot cache response with 'Vary: *' header.");this.#e.set(t.url,{body:new Uint8Array(await r.arrayBuffer()),status:r.status,headers:[...r.headers],timestamp:Date.now()});}async match(t){if(t.method!=="GET")return;let r=this.#e.get(t.url);if(!r)return;let{body:o,timestamp:a,...s}=r,n=new Headers(s.headers),i=n.get("cache-control")||n.get("real-cache-control")||"",u=parseInt(i.match(/max-age=(\d+)/)?.[1]||"0",10),c=parseInt(i.match(/stale-while-revalidate=(\d+)/)?.[1]||"0",10),l=(Date.now()-a)/1e3;if(l>u+c){this.#e.delete(t.url);return}let m=l>u;return n.set("cache",m?"STALE":"HIT"),n.set("date",new Date(a).toUTCString()),new Response(o,{status:s.status??200,headers:n})}async delete(t){return this.#e.has(t.url)?(this.#e.delete(t.url),!0):!1}keys(t){let r=[];for(let o of this.#e.keys())(!t||t.url===o)&&r.push(new Request(o));return Promise.resolve(r)}};function ke(e){if(!e)return;let{pathname:t,search:r}=new URL(e),o=t+r,a=new URLSearchParams(r),s=a.get("return_to")||a.get("redirect");if(s){if(Wt(e,s))return s;console.warn(`Cross-domain redirects are not supported. Tried to redirect from ${o} to ${s}`);}}function Wt(e,t){try{return new URL(e).origin===new URL(t,e).origin}catch{return !1}}function ot({requestUrl:e,defaultUrl:t,redirectUrl:r}){let o=e,a=Gt(e,t),s=r?Gt(e,r):a;return Wt(e,s.toString())?s.toString():(console.warn(`Cross-domain redirects are not supported. Tried to redirect from ${o} to ${s}. Default url ${a} is used instead.`),a.toString())}function Gt(e,t){return co(t)?new URL(t):new URL(t,new URL(e).origin)}function co(e){try{return new URL(e),!0}catch{return !1}}async function uo(e){let{storefront:t,request:r,noAdminRedirect:o,matchQueryParams:a,response:s=new Response("Not Found",{status:404})}=e,n=new URL(r.url),{pathname:i,searchParams:u}=n,c=u.has("_data");u.delete("redirect"),u.delete("return_to"),u.delete("_data");let l=(a?n.toString().replace(n.origin,""):i).toLowerCase();if(n.pathname==="/admin"&&!o)return nt(`${t.getShopifyDomain()}/admin`,c,u,a);try{let{urlRedirects:y}=await t.query(po,{variables:{query:"path:"+l}}),m=y?.edges?.[0]?.node?.target;if(m)return nt(m,c,u,a);let p=ke(r.url);if(p)return nt(p,c,u,a)}catch(y){console.error(`Failed to fetch redirects from Storefront API for route ${l}`,y);}return s}var at="https://example.com";function nt(e,t,r,o){let a=new URL(e,at);if(!o)for(let[s,n]of r)a.searchParams.append(s,n);return t?new Response(null,{status:200,headers:{"X-Remix-Redirect":a.toString().replace(at,""),"X-Remix-Status":"301"}}):new Response(null,{status:301,headers:{location:a.toString().replace(at,"")}})}var po=`#graphql
|
|
22
24
|
query redirects($query: String) {
|
|
23
25
|
urlRedirects(first: 1, query: $query) {
|
|
24
26
|
edges {
|
|
@@ -28,7 +30,7 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
|
-
`;var
|
|
33
|
+
`;var lo=async function({request:t,context:r}){let o=r.storefront,a=r.customerAccount,s=new URL(t.url);if(!o)throw new Error("GraphiQL: Hydrogen's storefront client must be injected in the loader context.");let n={};if(o){let c="X-Shopify-Storefront-Access-Token";n.storefront={name:"Storefront API",authHeader:c,accessToken:o.getPublicTokenHeaders()[c],apiUrl:o.getApiUrl(),icon:"SF"};}if(a){let c=await(await fetch(s.origin+"/graphiql/customer-account.schema.json")).json(),l=await a.getAccessToken();c&&(n["customer-account"]={name:"Customer Account API",value:c,authHeader:"Authorization",accessToken:l,apiUrl:a.getApiUrl(),icon:"CA"});}let i="https://avatars.githubusercontent.com/u/12972006?s=48&v=4",u=String.raw;return new Response(u`
|
|
32
34
|
<!DOCTYPE html>
|
|
33
35
|
<html lang="en">
|
|
34
36
|
<head>
|
|
@@ -294,7 +296,13 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
294
296
|
</script>
|
|
295
297
|
</body>
|
|
296
298
|
</html>
|
|
297
|
-
`,{status:200,headers:{"content-type":"text/html"}})};var so={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},io=/[&><\u2028\u2029]/g;function Qt(e){return e.replace(io,t=>so[t])}var F="Error in SEO input: ",N={title:{validate:e=>{if(typeof e!="string")throw new Error(F.concat("`title` should be a string"));if(typeof e=="string"&&e.length>120)throw new Error(F.concat("`title` should not be longer than 120 characters"));return e}},description:{validate:e=>{if(typeof e!="string")throw new Error(F.concat("`description` should be a string"));if(typeof e=="string"&&e.length>155)throw new Error(F.concat("`description` should not be longer than 155 characters"));return e}},url:{validate:e=>{if(typeof e!="string")throw new Error(F.concat("`url` should be a string"));if(typeof e=="string"&&!e.startsWith("http"))throw new Error(F.concat("`url` should be a valid URL"));return e}},handle:{validate:e=>{if(typeof e!="string")throw new Error(F.concat("`handle` should be a string"));if(typeof e=="string"&&!e.startsWith("@"))throw new Error(F.concat("`handle` should start with `@`"));return e}}};function Gt(e){let t=[];for(let r of Object.keys(e))switch(r){case"title":{let o=M(N.title,e.title),a=at(e?.titleTemplate,o);if(!a)break;t.push(D("title",{title:a}),D("meta",{property:"og:title",content:a}),D("meta",{name:"twitter:title",content:a}));break}case"description":{let o=M(N.description,e.description);if(!o)break;t.push(D("meta",{name:"description",content:o}),D("meta",{property:"og:description",content:o}),D("meta",{name:"twitter:description",content:o}));break}case"url":{let o=M(N.url,e.url);if(!o)break;let s=o.split("?")[0].replace(/\/$/,"");t.push(D("link",{rel:"canonical",href:s}),D("meta",{property:"og:url",content:s}));break}case"handle":{let o=M(N.handle,e.handle);if(!o)break;t.push(D("meta",{name:"twitter:site",content:o}),D("meta",{name:"twitter:creator",content:o}));break}case"media":{let o,a=$(e.media);for(let s of a)if(typeof s=="string"&&t.push(D("meta",{name:"og:image",content:s})),s&&typeof s=="object"){let n=s.type||"image",i=s?{url:s?.url,secure_url:s?.url,type:nt(s.url),width:s?.width,height:s?.height,alt:s?.altText}:{};for(let u of Object.keys(i))i[u]&&(o=i[u],t.push(D("meta",{property:`og:${n}:${u}`,content:o},i.url)));}break}case"jsonLd":{let o=$(e.jsonLd),a=0;for(let s of o){if(typeof s!="object")continue;let n=D("script",{type:"application/ld+json",children:JSON.stringify(s,(i,u)=>typeof u=="string"?Qt(u):u)},`json-ld-${s?.["@type"]||s?.name||a++}`);t.push(n);}break}case"alternates":{let o=$(e.alternates);for(let a of o){if(!a)continue;let{language:s,url:n,default:i}=a,u=s?`${s}${i?"-default":""}`:void 0;t.push(D("link",{rel:"alternate",hrefLang:u,href:n}));}break}case"robots":{if(!e.robots)break;let{maxImagePreview:o,maxSnippet:a,maxVideoPreview:s,noArchive:n,noFollow:i,noImageIndex:u,noIndex:c,noSnippet:p,noTranslate:d,unavailableAfter:g}=e.robots,l=[n&&"noarchive",u&&"noimageindex",p&&"nosnippet",d&&"notranslate",o&&`max-image-preview:${o}`,a&&`max-snippet:${a}`,s&&`max-video-preview:${s}`,g&&`unavailable_after:${g}`],y=(c?"noindex":"index")+","+(i?"nofollow":"follow");for(let S of l)S&&(y+=`,${S}`);t.push(D("meta",{name:"robots",content:y}));break}}return t.flat().sort((r,o)=>r.key.localeCompare(o.key))}function D(e,t,r){let o={tag:e,props:{},key:""};return e==="title"?(o.children=t.title,o.key=ot(o),o):e==="script"?(o.children=typeof t.children=="string"?t.children:"",o.key=ot(o,r),delete t.children,o.props=t,o):(o.props=t,Object.keys(o.props).forEach(a=>!o.props[a]&&delete o.props[a]),o.key=ot(o,r),o)}function ot(e,t){let{tag:r,props:o}=e;if(r==="title")return "0-title";if(r==="meta"){let a=o.content===t&&typeof o.property=="string"&&!o.property.endsWith("secure_url")&&"0";return [r,...[t,a],o.property||o.name].filter(n=>n).join("-")}return r==="link"?[r,o.rel,o.hrefLang||o.media].filter(s=>s).join("-").replace(/\s+/g,"-"):r==="script"?`${r}-${t}`:`${r}-${o.type}`}function at(e,t){if(t)return e?typeof e=="function"?e(t):e.replace("%s",t??""):t}function nt(e){switch(e&&e.split(".").pop()){case"svg":return "image/svg+xml";case"png":return "image/png";case"gif":return "image/gif";case"swf":return "application/x-shockwave-flash";case"mp3":return "audio/mpeg";case"jpg":case"jpeg":default:return "image/jpeg"}}function $(e){return Array.isArray(e)?e:[e]}function M(e,t){try{return e.validate(t)}catch(r){return console.warn(r.message),t}}var ho=react.lazy(()=>Promise.resolve().then(()=>(Kt(),jt)));function Co({debug:e}){let t=react$1.useMatches(),r=react$1.useLocation();console.warn("[h2:warn:Seo] The `<Seo/>` component is deprecated. Use `getSeoMeta` instead.\nSee: https://shopify.dev/docs/api/hydrogen/2024-01/utilities/getseometa");let o=react.useMemo(()=>t.flatMap(n=>{let{handle:i,...u}=n,c={...u,...r},p=i?.seo,d=u?.data?.seo;return !p&&!d?[]:p?xe(p,c):[d]}).reduce((n,i)=>{Object.keys(i).forEach(c=>!i[c]&&delete i[c]);let{jsonLd:u}=i;return u?n?.jsonLd?Array.isArray(u)?{...n,...i,jsonLd:[...n.jsonLd,...u]}:{...n,...i,jsonLd:[...n.jsonLd,u]}:{...n,...i,jsonLd:[u]}:{...n,...i}},{}),[t,r]),{html:a,loggerMarkup:s}=react.useMemo(()=>{let n=Gt(o),i=n.map(c=>c.tag==="script"?react.createElement(c.tag,{...c.props,key:c.key,dangerouslySetInnerHTML:{__html:c.children}}):react.createElement(c.tag,{...c.props,key:c.key},c.children)),u=react.createElement(react.Suspense,{fallback:null},react.createElement(ho,{headTags:n}));return {html:i,loggerMarkup:u}},[o]);return react.createElement(react.Fragment,null,a,e&&s)}function xe(e,...t){if(e instanceof Function)return xe(e(...t),...t);let r={};return Array.isArray(e)?(r=e.reduce((o,a)=>[...o,xe(a)],[]),r):e instanceof Object?(Object.entries(e).forEach(([a,s])=>{r[a]=xe(s,...t);}),r):e}function So(...e){let t=[],r=e.reduce((o,a)=>{if(!a)return o;Object.keys(a).forEach(n=>!a[n]&&delete a[n]);let{jsonLd:s}=a;return s?o?.jsonLd?{...o,...a,jsonLd:$(o.jsonLd).concat(s)}:{...o,...a,jsonLd:[s]}:{...o,...a}},{})||{};for(let o of Object.keys(r))switch(o){case"title":{let a=M(N.title,r.title),s=at(r?.titleTemplate,a);if(!s)break;t.push({title:s},{property:"og:title",content:s},{property:"twitter:title",content:s});break}case"description":{let a=M(N.description,r.description);if(!a)break;t.push({name:"description",content:a},{property:"og:description",content:a},{property:"twitter:description",content:a});break}case"url":{let a=M(N.url,r.url);if(!a)break;let n=a.split("?")[0].replace(/\/$/,"");t.push({tagName:"link",rel:"canonical",href:n},{property:"og:url",content:n});break}case"handle":{let a=M(N.handle,r.handle);if(!a)break;t.push({property:"twitter:site",content:a},{property:"twitter:creator",content:a});break}case"media":{let a,s=$(r.media);for(let n of s)if(typeof n=="string"&&t.push({property:"og:image",content:n}),n&&typeof n=="object"){let i=n.type||"image",u=n?{url:n?.url,secure_url:n?.url,type:nt(n.url),width:n?.width,height:n?.height,alt:n?.altText}:{};for(let c of Object.keys(u))u[c]&&(a=u[c],t.push({property:`og:${i}:${c}`,content:a}));}break}case"jsonLd":{let a=$(r.jsonLd);for(let n of a)typeof n!="object"||Object.keys(n).length===0||t.push({"script:ld+json":n});break}case"alternates":{let a=$(r.alternates);for(let s of a){if(!s)continue;let{language:n,url:i,default:u}=s,c=n?`${n}${u?"-default":""}`:void 0;t.push({tagName:"link",rel:"alternate",hrefLang:c,href:i});}break}case"robots":{if(!r.robots)break;let{maxImagePreview:a,maxSnippet:s,maxVideoPreview:n,noArchive:i,noFollow:u,noImageIndex:c,noIndex:p,noSnippet:d,noTranslate:g,unavailableAfter:l}=r.robots,y=[i&&"noarchive",c&&"noimageindex",d&&"nosnippet",g&&"notranslate",a&&`max-image-preview:${a}`,s&&`max-snippet:${s}`,n&&`max-video-preview:${n}`,l&&`unavailable_after:${l}`],S=(p?"noindex":"index")+","+(u?"nofollow":"follow");for(let C of y)C&&(S+=`,${C}`);t.push({name:"robots",content:S});break}}return t}function wo({connection:e,children:t=()=>(console.warn("<Pagination> requires children to work properly"),null)}){let o=react$1.useNavigation().state==="loading",{endCursor:a,hasNextPage:s,hasPreviousPage:n,nextPageUrl:i,nodes:u,previousPageUrl:c,startCursor:p}=bo(e),d=react.useMemo(()=>({pageInfo:{endCursor:a,hasPreviousPage:n,hasNextPage:s,startCursor:p},nodes:u}),[a,s,n,p,u]),g=react.useMemo(()=>react.forwardRef(function(S,C){return s?react.createElement(react$1.Link,{preventScrollReset:!0,...S,to:i,state:d,replace:!0,ref:C}):null}),[s,i,d]),l=react.useMemo(()=>react.forwardRef(function(S,C){return n?react.createElement(react$1.Link,{preventScrollReset:!0,...S,to:c,state:d,replace:!0,ref:C}):null}),[n,c,d]);return t({state:d,hasNextPage:s,hasPreviousPage:n,isLoading:o,nextPageUrl:i,nodes:u,previousPageUrl:c,NextLink:g,PreviousLink:l})}function De(e){let t=new URLSearchParams(e);return t.delete("cursor"),t.delete("direction"),t.toString()}function fe(e){throw new Error(`The Pagination component requires ${"`"+e+"`"} to be a part of your query. See the guide on how to setup your query to include ${"`"+e+"`"}: https://shopify.dev/docs/custom-storefronts/hydrogen/data-fetching/pagination#setup-the-paginated-query`)}function bo(e){e.pageInfo||fe("pageInfo"),typeof e.pageInfo.startCursor>"u"&&fe("pageInfo.startCursor"),typeof e.pageInfo.endCursor>"u"&&fe("pageInfo.endCursor"),typeof e.pageInfo.hasNextPage>"u"&&fe("pageInfo.hasNextPage"),typeof e.pageInfo.hasPreviousPage>"u"&&fe("pageInfo.hasPreviousPage");let t=react$1.useNavigate(),{state:r,search:o,pathname:a}=react$1.useLocation(),i=new URLSearchParams(o).get("direction")==="previous",u=react.useMemo(()=>!globalThis?.window?.__hydrogenHydrated||!r||!r?.nodes?hydrogenReact.flattenConnection(e):i?[...hydrogenReact.flattenConnection(e),...r.nodes]:[...r.nodes,...hydrogenReact.flattenConnection(e)],[r,e]),c=react.useMemo(()=>{let l=globalThis?.window?.__hydrogenHydrated,y=!l||r?.pageInfo?.startCursor===void 0?e.pageInfo.startCursor:r.pageInfo.startCursor,S=!l||r?.pageInfo?.endCursor===void 0?e.pageInfo.endCursor:r.pageInfo.endCursor,C=!l||r?.pageInfo?.hasPreviousPage===void 0?e.pageInfo.hasPreviousPage:r.pageInfo.hasPreviousPage,f=!l||r?.pageInfo?.hasNextPage===void 0?e.pageInfo.hasNextPage:r.pageInfo.hasNextPage;return r?.nodes&&(i?(y=e.pageInfo.startCursor,C=e.pageInfo.hasPreviousPage):(S=e.pageInfo.endCursor,f=e.pageInfo.hasNextPage)),{startCursor:y,endCursor:S,hasPreviousPage:C,hasNextPage:f}},[i,r,e.pageInfo.hasNextPage,e.pageInfo.hasPreviousPage,e.pageInfo.startCursor,e.pageInfo.endCursor]),p=react.useRef({params:De(o),pathname:a});react.useEffect(()=>{window.__hydrogenHydrated=!0;},[]),react.useEffect(()=>{(De(o)!==p.current.params||a!==p.current.pathname)&&(p.current={pathname:a,params:De(o)},t(`${a}?${De(o)}`,{replace:!0,preventScrollReset:!0,state:{nodes:void 0,pageInfo:void 0}}));},[a,o]);let d=react.useMemo(()=>{let l=new URLSearchParams(o);return l.set("direction","previous"),c.startCursor&&l.set("cursor",c.startCursor),`?${l.toString()}`},[o,c.startCursor]),g=react.useMemo(()=>{let l=new URLSearchParams(o);return l.set("direction","next"),c.endCursor&&l.set("cursor",c.endCursor),`?${l.toString()}`},[o,c.endCursor]);return {...c,previousPageUrl:d,nextPageUrl:g,nodes:u}}function Ro(e,t={pageBy:20}){if(typeof e?.url>"u")throw new Error("getPaginationVariables must be called with the Request object passed to your loader function");let{pageBy:r}=t,o=new URLSearchParams(new URL(e.url).search),a=o.get("cursor")??void 0;return (o.get("direction")==="previous"?"previous":"next")==="previous"?{last:r,startCursor:a??null}:{first:r,endCursor:a??null}}var Oe="2024-04",oe=`Shopify Hydrogen ${de}`,er="30243aa5-17c1-465a-8493-944bcc4e88aa",O="customerAccount";var k=class extends Response{constructor(t,r,o){super(`Bad request: ${t}`,{status:400,headers:o});}};function ge(e,t={}){let r=t.headers?new Headers(t.headers):new Headers({});return r.set("location",e),new Response(null,{status:t.status||302,headers:r})}async function Io({session:e,customerAccountId:t,customerAccountUrl:r,httpsOrigin:o,debugInfo:a}){let s=new URLSearchParams,i=e.get(O)?.refreshToken;if(!i)throw new k("Unauthorized","No refreshToken found in the session. Make sure your session is configured correctly and passed to `createCustomerAccountClient`.");s.append("grant_type","refresh_token"),s.append("refresh_token",i),s.append("client_id",t);let u={"content-type":"application/x-www-form-urlencoded","User-Agent":oe,Origin:o};new Date().getTime();let p=`${r}/auth/oauth/token`,d=await fetch(p,{method:"POST",headers:u,body:s});if(!d.ok){let f=await d.text();throw new Response(f,{status:d.status,headers:{"Content-Type":"text/html; charset=utf-8"}})}let{access_token:g,expires_in:l,id_token:y,refresh_token:S}=await d.json(),C=await ct(g,t,r,o);e.set(O,{accessToken:C,expiresAt:new Date(new Date().getTime()+(l-120)*1e3).getTime()+"",refreshToken:S,idToken:y});}function ae(e){e.unset(O);}async function tr({locks:e,expiresAt:t,session:r,customerAccountId:o,customerAccountUrl:a,httpsOrigin:s,debugInfo:n}){if(parseInt(t,10)-1e3<new Date().getTime())try{e.refresh||(e.refresh=Io({session:r,customerAccountId:o,customerAccountUrl:a,httpsOrigin:s,debugInfo:n})),await e.refresh,delete e.refresh;}catch(i){throw ae(r),i&&i.status!==401?i:new k("Unauthorized","Login before querying the Customer Account API.",{"Set-Cookie":await r.commit()})}}function rr(){let e=Eo();return ar(e)}async function or(e){let t=await crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(e)),r=xo(t);return ar(r)}function Eo(){let e=new Uint8Array(32);return crypto.getRandomValues(e),String.fromCharCode.apply(null,Array.from(e))}function ar(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function xo(e){let t=new Uint8Array(e),r=Array.from(t);return String.fromCharCode(...r)}function nr(){let e=Date.now().toString(),t=Math.random().toString(36).substring(2);return e+t}async function ct(e,t,r,o,a){let s=t;if(!e)throw new k("Unauthorized","oAuth access token was not provided during token exchange.");let n=new URLSearchParams;n.append("grant_type","urn:ietf:params:oauth:grant-type:token-exchange"),n.append("client_id",s),n.append("audience",er),n.append("subject_token",e),n.append("subject_token_type","urn:ietf:params:oauth:token-type:access_token"),n.append("scopes","https://api.customers.com/auth/customer.graphql");let i={"content-type":"application/x-www-form-urlencoded","User-Agent":oe,Origin:o};new Date().getTime();let c=`${r}/auth/oauth/token`,p=await fetch(c,{method:"POST",headers:i,body:n});let d=await p.json();if(d.error)throw new k(d.error_description);return d.access_token}function sr(e){return Do(e).payload.nonce}function Do(e){let[t,r,o]=e.split("."),a=JSON.parse(atob(t)),s=JSON.parse(atob(r));return {header:a,payload:s,signature:o}}function Ue(){return Uo(Oo())}function Oo(){try{return crypto.getRandomValues(new Uint8Array(16))}catch{return new Uint8Array(16).map(()=>Math.random()*255|0)}}function Uo(e){return Array.from(e,function(t){return ("0"+(t&255).toString(16)).slice(-2)}).join("")}var ir="/account/login",_o="/account/authorize",cr="/account";function ko(e){if(!e.url)return ir;let{pathname:t}=new URL(e.url),r=ir+`?${new URLSearchParams({return_to:t}).toString()}`;return ge(r)}function Lo({session:e,customerAccountId:t,customerAccountUrl:r,customerApiVersion:o=Oe,request:a,waitUntil:s,authUrl:n,customAuthStatusHandler:i,logErrors:u=!0}){if(o!==Oe&&console.warn(`[h2:warn:createCustomerAccountClient] You are using Customer Account API version ${o} when this version of Hydrogen was built for ${Oe}.`),!a?.url)throw new Error("[h2:error:createCustomerAccountClient] The request object does not contain a URL.");let c=i||(()=>ko(a)),p=new URL(a.url),d=p.protocol==="http:"?p.origin.replace("http","https"):p.origin,g=et({requestUrl:d,defaultUrl:_o,redirectUrl:n}),l=`${r}/account/customer/api/${o}/graphql`,y={};async function S({query:m,type:h,variables:A={}}){let v=await T();if(!v)throw c();new Date().getTime();let U=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":oe,Origin:d,Authorization:v},body:JSON.stringify({query:m,variables:A})});let E=await U.text(),x={url:l,response:U,type:h,query:m,queryVariables:A,errors:void 0,client:"customer"};if(!U.ok){if(U.status===401){ae(e);let _=c();throw _ instanceof Response&&_.headers.set("Set-Cookie",await e.commit()),_}let b;try{b=G(E);}catch{b=[{message:E}];}le({...x,errors:b});}try{let b=G(E),{errors:_}=b,V=_?.map(({message:Y,...Q})=>new B(Y,{...Q,clientOperation:`customerAccount.${x.type}`,requestId:U.headers.get("x-request-id"),queryVariables:A,query:m}));return {...b,..._&&{errors:V}}}catch{le({...x,errors:[{message:E}]});}}async function C(){if(!r||!t)return !1;let m=e.get(O),h=m?.accessToken,A=m?.expiresAt;if(!h||!A)return !1;let v=L?.();try{await tr({locks:y,expiresAt:A,session:e,customerAccountId:t,customerAccountUrl:r,httpsOrigin:d,debugInfo:{waitUntil:s,stackInfo:v,...W(a)}});}catch{return !1}return !0}async function f(){if(!await C())throw c()}async function T(){if(await C())return e.get(O)?.accessToken}return {login:async m=>{he(r,t);let h=new URL(`${r}/auth/oauth/authorize`),A=nr(),v=Ue();if(h.searchParams.set("client_id",t),h.searchParams.set("scope","openid email"),h.searchParams.append("response_type","code"),h.searchParams.append("redirect_uri",g),h.searchParams.set("scope","openid email https://api.customers.com/auth/customer.graphql"),h.searchParams.append("state",A),h.searchParams.append("nonce",v),m?.uiLocales){let[U,E]=m.uiLocales.split("-"),x=U.toLowerCase();E&&(x+=`-${E.toUpperCase()}`),h.searchParams.append("ui_locales",x);}let w=rr(),H=await or(w);return e.set(O,{...e.get(O),codeVerifier:w,state:A,nonce:v,redirectPath:Ee(a.url)||Ie(a,"Referer")||cr}),h.searchParams.append("code_challenge",H),h.searchParams.append("code_challenge_method","S256"),ge(h.toString(),{headers:{"Set-Cookie":await e.commit()}})},logout:async m=>{he(r,t);let h=e.get(O)?.idToken,A=et({requestUrl:d,defaultUrl:d,redirectUrl:m?.postLogoutRedirectUri}),v=h?new URL(`${r}/auth/logout?${new URLSearchParams([["id_token_hint",h],["post_logout_redirect_uri",A]]).toString()}`).toString():A;return ae(e),ge(v,{status:302,headers:{"Set-Cookie":await e.commit()}})},isLoggedIn:C,handleAuthStatus:f,getAccessToken:T,getApiUrl:()=>l,mutate(m,h){return he(r,t),m=te(m),Re(m,"customer.mutate"),re(S({query:m,type:"mutation",...h}),{logErrors:u})},query(m,h){return he(r,t),m=te(m),be(m,"customer.query"),re(S({query:m,type:"query",...h}),{logErrors:u})},authorize:async()=>{he(r,t);let m=p.searchParams.get("code"),h=p.searchParams.get("state");if(!m||!h)throw ae(e),new k("Unauthorized","No code or state parameter found in the redirect URL.",{"Set-Cookie":await e.commit()});if(e.get(O)?.state!==h)throw ae(e),new k("Unauthorized","The session state does not match the state parameter. Make sure that the session is configured correctly and passed to `createCustomerAccountClient`.",{"Set-Cookie":await e.commit()});let A=t,v=new URLSearchParams;v.append("grant_type","authorization_code"),v.append("client_id",A),v.append("redirect_uri",g),v.append("code",m);let w=e.get(O)?.codeVerifier;if(!w)throw new k("Unauthorized","No code verifier found in the session. Make sure that the session is configured correctly and passed to `createCustomerAccountClient`.");v.append("code_verifier",w);let H={"content-type":"application/x-www-form-urlencoded","User-Agent":oe,Origin:d},U=L?.();new Date().getTime();let x=`${r}/auth/oauth/token`,b=await fetch(x,{method:"POST",headers:H,body:v});if(!b.ok)throw new Response(await b.text(),{status:b.status,headers:{"Content-Type":"text/html; charset=utf-8"}});let{access_token:_,expires_in:V,id_token:Y,refresh_token:Q}=await b.json(),X=e.get(O)?.nonce,ie=await sr(Y);if(X!==ie)throw new k("Unauthorized",`Returned nonce does not match: ${X} !== ${ie}`);let Ve=await ct(_,t,r,d,{waitUntil:s,stackInfo:U,...W(a)}),Fe=e.get(O)?.redirectPath;return e.set(O,{accessToken:Ve,expiresAt:new Date(new Date().getTime()+(V-120)*1e3).getTime()+"",refreshToken:Q,idToken:Y,redirectPath:void 0}),ge(Fe||cr,{headers:{"Set-Cookie":await e.commit()}})}}}function he(e,t){try{if(!e||!t)throw Error();new URL(e);}catch{console.error(new Error("[h2:error:customerAccount] You do not have the valid credential to use Customer Account API.\nRun `h2 env pull` to link your store credentials."));let r="Internal Server Error";throw new Response(r,{status:500})}}var No="https://raw.githubusercontent.com/Shopify/hydrogen/main/docs/changelog.json";async function Mo({request:e,changelogUrl:t}){new URL(e.url).searchParams;return fetch(t||No)}var ur="cartFormInput";function _e({children:e,action:t,inputs:r,route:o,fetcherKey:a}){let s=react$1.useFetcher({key:a});return jsxRuntime.jsxs(s.Form,{action:o||"",method:"post",children:[(t||r)&&jsxRuntime.jsx("input",{type:"hidden",name:ur,value:JSON.stringify({action:t,inputs:r})}),typeof e=="function"?e(s):e]})}_e.INPUT_NAME=ur;_e.ACTIONS={AttributesUpdateInput:"AttributesUpdateInput",BuyerIdentityUpdate:"BuyerIdentityUpdate",Create:"Create",DiscountCodesUpdate:"DiscountCodesUpdate",LinesAdd:"LinesAdd",LinesRemove:"LinesRemove",LinesUpdate:"LinesUpdate",NoteUpdate:"NoteUpdate",SelectedDeliveryOptionsUpdate:"SelectedDeliveryOptionsUpdate",MetafieldsSet:"MetafieldsSet",MetafieldDelete:"MetafieldDelete"};function Fo(e){let t={};for(let n of e.entries()){let i=n[0],u=e.getAll(i);t[i]=u.length>1?u:n[1];}let{cartFormInput:r,...o}=t,{action:a,inputs:s}=r?JSON.parse(String(r)):{};return {action:a,inputs:{...s,...o}}}_e.getFormInput=Fo;var R=`#graphql
|
|
299
|
+
`,{status:200,headers:{"content-type":"text/html"}})};var yo={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},fo=/[&><\u2028\u2029]/g;function jt(e){return e.replace(fo,t=>yo[t])}var B="Error in SEO input: ",H={title:{validate:e=>{if(typeof e!="string")throw new Error(B.concat("`title` should be a string"));if(typeof e=="string"&&e.length>120)throw new Error(B.concat("`title` should not be longer than 120 characters"));return e}},description:{validate:e=>{if(typeof e!="string")throw new Error(B.concat("`description` should be a string"));if(typeof e=="string"&&e.length>155)throw new Error(B.concat("`description` should not be longer than 155 characters"));return e}},url:{validate:e=>{if(typeof e!="string")throw new Error(B.concat("`url` should be a string"));if(typeof e=="string"&&!e.startsWith("http"))throw new Error(B.concat("`url` should be a valid URL"));return e}},handle:{validate:e=>{if(typeof e!="string")throw new Error(B.concat("`handle` should be a string"));if(typeof e=="string"&&!e.startsWith("@"))throw new Error(B.concat("`handle` should start with `@`"));return e}}};function Kt(e){let t=[];for(let r of Object.keys(e))switch(r){case"title":{let o=Q(H.title,e.title),a=it(e?.titleTemplate,o);if(!a)break;t.push(x("title",{title:a}),x("meta",{property:"og:title",content:a}),x("meta",{name:"twitter:title",content:a}));break}case"description":{let o=Q(H.description,e.description);if(!o)break;t.push(x("meta",{name:"description",content:o}),x("meta",{property:"og:description",content:o}),x("meta",{name:"twitter:description",content:o}));break}case"url":{let o=Q(H.url,e.url);if(!o)break;let s=o.split("?")[0].replace(/\/$/,"");t.push(x("link",{rel:"canonical",href:s}),x("meta",{property:"og:url",content:s}));break}case"handle":{let o=Q(H.handle,e.handle);if(!o)break;t.push(x("meta",{name:"twitter:site",content:o}),x("meta",{name:"twitter:creator",content:o}));break}case"media":{let o,a=G(e.media);for(let s of a)if(typeof s=="string"&&t.push(x("meta",{name:"og:image",content:s})),s&&typeof s=="object"){let n=s.type||"image",i=s?{url:s?.url,secure_url:s?.url,type:ct(s.url),width:s?.width,height:s?.height,alt:s?.altText}:{};for(let u of Object.keys(i))i[u]&&(o=i[u],t.push(x("meta",{property:`og:${n}:${u}`,content:o},i.url)));}break}case"jsonLd":{let o=G(e.jsonLd),a=0;for(let s of o){if(typeof s!="object")continue;let n=x("script",{type:"application/ld+json",children:JSON.stringify(s,(i,u)=>typeof u=="string"?jt(u):u)},`json-ld-${s?.["@type"]||s?.name||a++}`);t.push(n);}break}case"alternates":{let o=G(e.alternates);for(let a of o){if(!a)continue;let{language:s,url:n,default:i}=a,u=s?`${s}${i?"-default":""}`:void 0;t.push(x("link",{rel:"alternate",hrefLang:u,href:n}));}break}case"robots":{if(!e.robots)break;let{maxImagePreview:o,maxSnippet:a,maxVideoPreview:s,noArchive:n,noFollow:i,noImageIndex:u,noIndex:c,noSnippet:l,noTranslate:y,unavailableAfter:m}=e.robots,p=[n&&"noarchive",u&&"noimageindex",l&&"nosnippet",y&&"notranslate",o&&`max-image-preview:${o}`,a&&`max-snippet:${a}`,s&&`max-video-preview:${s}`,m&&`unavailable_after:${m}`],d=(c?"noindex":"index")+","+(i?"nofollow":"follow");for(let g of p)g&&(d+=`,${g}`);t.push(x("meta",{name:"robots",content:d}));break}}return t.flat().sort((r,o)=>r.key.localeCompare(o.key))}function x(e,t,r){let o={tag:e,props:{},key:""};return e==="title"?(o.children=t.title,o.key=st(o),o):e==="script"?(o.children=typeof t.children=="string"?t.children:"",o.key=st(o,r),delete t.children,o.props=t,o):(o.props=t,Object.keys(o.props).forEach(a=>!o.props[a]&&delete o.props[a]),o.key=st(o,r),o)}function st(e,t){let{tag:r,props:o}=e;if(r==="title")return "0-title";if(r==="meta"){let a=o.content===t&&typeof o.property=="string"&&!o.property.endsWith("secure_url")&&"0";return [r,...[t,a],o.property||o.name].filter(n=>n).join("-")}return r==="link"?[r,o.rel,o.hrefLang||o.media].filter(s=>s).join("-").replace(/\s+/g,"-"):r==="script"?`${r}-${t}`:`${r}-${o.type}`}function it(e,t){if(t)return e?typeof e=="function"?e(t):e.replace("%s",t??""):t}function ct(e){switch(e&&e.split(".").pop()){case"svg":return "image/svg+xml";case"png":return "image/png";case"gif":return "image/gif";case"swf":return "application/x-shockwave-flash";case"mp3":return "audio/mpeg";case"jpg":case"jpeg":default:return "image/jpeg"}}function G(e){return Array.isArray(e)?e:[e]}function Q(e,t){try{return e.validate(t)}catch(r){return console.warn(r.message),t}}var vo=react.lazy(()=>Promise.resolve().then(()=>(Xt(),Yt)));function Ro({debug:e}){let t=react$1.useMatches(),r=react$1.useLocation();console.warn("[h2:warn:Seo] The `<Seo/>` component is deprecated. Use `getSeoMeta` instead.\nSee: https://shopify.dev/docs/api/hydrogen/2024-01/utilities/getseometa");let o=react.useMemo(()=>t.flatMap(n=>{let{handle:i,...u}=n,c={...u,...r},l=i?.seo,y=u?.data?.seo;return !l&&!y?[]:l?Le(l,c):[y]}).reduce((n,i)=>{Object.keys(i).forEach(c=>!i[c]&&delete i[c]);let{jsonLd:u}=i;return u?n?.jsonLd?Array.isArray(u)?{...n,...i,jsonLd:[...n.jsonLd,...u]}:{...n,...i,jsonLd:[...n.jsonLd,u]}:{...n,...i,jsonLd:[u]}:{...n,...i}},{}),[t,r]),{html:a,loggerMarkup:s}=react.useMemo(()=>{let n=Kt(o),i=n.map(c=>c.tag==="script"?react.createElement(c.tag,{...c.props,key:c.key,dangerouslySetInnerHTML:{__html:c.children}}):react.createElement(c.tag,{...c.props,key:c.key},c.children)),u=react.createElement(react.Suspense,{fallback:null},react.createElement(vo,{headTags:n}));return {html:i,loggerMarkup:u}},[o]);return react.createElement(react.Fragment,null,a,e&&s)}function Le(e,...t){if(e instanceof Function)return Le(e(...t),...t);let r={};return Array.isArray(e)?(r=e.reduce((o,a)=>[...o,Le(a)],[]),r):e instanceof Object?(Object.entries(e).forEach(([a,s])=>{r[a]=Le(s,...t);}),r):e}function wo(...e){let t=[],r=e.reduce((o,a)=>{if(!a)return o;Object.keys(a).forEach(n=>!a[n]&&delete a[n]);let{jsonLd:s}=a;return s?o?.jsonLd?{...o,...a,jsonLd:G(o.jsonLd).concat(s)}:{...o,...a,jsonLd:[s]}:{...o,...a}},{})||{};for(let o of Object.keys(r))switch(o){case"title":{let a=Q(H.title,r.title),s=it(r?.titleTemplate,a);if(!s)break;t.push({title:s},{property:"og:title",content:s},{property:"twitter:title",content:s});break}case"description":{let a=Q(H.description,r.description);if(!a)break;t.push({name:"description",content:a},{property:"og:description",content:a},{property:"twitter:description",content:a});break}case"url":{let a=Q(H.url,r.url);if(!a)break;let n=a.split("?")[0].replace(/\/$/,"");t.push({tagName:"link",rel:"canonical",href:n},{property:"og:url",content:n});break}case"handle":{let a=Q(H.handle,r.handle);if(!a)break;t.push({property:"twitter:site",content:a},{property:"twitter:creator",content:a});break}case"media":{let a,s=G(r.media);for(let n of s)if(typeof n=="string"&&t.push({property:"og:image",content:n}),n&&typeof n=="object"){let i=n.type||"image",u=n?{url:n?.url,secure_url:n?.url,type:ct(n.url),width:n?.width,height:n?.height,alt:n?.altText}:{};for(let c of Object.keys(u))u[c]&&(a=u[c],t.push({property:`og:${i}:${c}`,content:a}));}break}case"jsonLd":{let a=G(r.jsonLd);for(let n of a)typeof n!="object"||Object.keys(n).length===0||t.push({"script:ld+json":n});break}case"alternates":{let a=G(r.alternates);for(let s of a){if(!s)continue;let{language:n,url:i,default:u}=s,c=n?`${n}${u?"-default":""}`:void 0;t.push({tagName:"link",rel:"alternate",hrefLang:c,href:i});}break}case"robots":{if(!r.robots)break;let{maxImagePreview:a,maxSnippet:s,maxVideoPreview:n,noArchive:i,noFollow:u,noImageIndex:c,noIndex:l,noSnippet:y,noTranslate:m,unavailableAfter:p}=r.robots,d=[i&&"noarchive",c&&"noimageindex",y&&"nosnippet",m&&"notranslate",a&&`max-image-preview:${a}`,s&&`max-snippet:${s}`,n&&`max-video-preview:${n}`,p&&`unavailable_after:${p}`],g=(l?"noindex":"index")+","+(u?"nofollow":"follow");for(let S of d)S&&(g+=`,${S}`);t.push({name:"robots",content:g});break}}return t}function Do({connection:e,children:t=()=>(console.warn("<Pagination> requires children to work properly"),null)}){let o=react$1.useNavigation().state==="loading",{endCursor:a,hasNextPage:s,hasPreviousPage:n,nextPageUrl:i,nodes:u,previousPageUrl:c,startCursor:l}=Oo(e),y=react.useMemo(()=>({pageInfo:{endCursor:a,hasPreviousPage:n,hasNextPage:s,startCursor:l},nodes:u}),[a,s,n,l,u]),m=react.useMemo(()=>react.forwardRef(function(g,S){return s?react.createElement(react$1.Link,{preventScrollReset:!0,...g,to:i,state:y,replace:!0,ref:S}):null}),[s,i,y]),p=react.useMemo(()=>react.forwardRef(function(g,S){return n?react.createElement(react$1.Link,{preventScrollReset:!0,...g,to:c,state:y,replace:!0,ref:S}):null}),[n,c,y]);return t({state:y,hasNextPage:s,hasPreviousPage:n,isLoading:o,nextPageUrl:i,nodes:u,previousPageUrl:c,NextLink:m,PreviousLink:p})}function Ne(e){let t=new URLSearchParams(e);return t.delete("cursor"),t.delete("direction"),t.toString()}function Ce(e){throw new Error(`The Pagination component requires ${"`"+e+"`"} to be a part of your query. See the guide on how to setup your query to include ${"`"+e+"`"}: https://shopify.dev/docs/custom-storefronts/hydrogen/data-fetching/pagination#setup-the-paginated-query`)}function Oo(e){e.pageInfo||Ce("pageInfo"),typeof e.pageInfo.startCursor>"u"&&Ce("pageInfo.startCursor"),typeof e.pageInfo.endCursor>"u"&&Ce("pageInfo.endCursor"),typeof e.pageInfo.hasNextPage>"u"&&Ce("pageInfo.hasNextPage"),typeof e.pageInfo.hasPreviousPage>"u"&&Ce("pageInfo.hasPreviousPage");let t=react$1.useNavigate(),{state:r,search:o,pathname:a}=react$1.useLocation(),i=new URLSearchParams(o).get("direction")==="previous",u=react.useMemo(()=>!globalThis?.window?.__hydrogenHydrated||!r||!r?.nodes?hydrogenReact.flattenConnection(e):i?[...hydrogenReact.flattenConnection(e),...r.nodes]:[...r.nodes,...hydrogenReact.flattenConnection(e)],[r,e]),c=react.useMemo(()=>{let p=globalThis?.window?.__hydrogenHydrated,d=!p||r?.pageInfo?.startCursor===void 0?e.pageInfo.startCursor:r.pageInfo.startCursor,g=!p||r?.pageInfo?.endCursor===void 0?e.pageInfo.endCursor:r.pageInfo.endCursor,S=!p||r?.pageInfo?.hasPreviousPage===void 0?e.pageInfo.hasPreviousPage:r.pageInfo.hasPreviousPage,f=!p||r?.pageInfo?.hasNextPage===void 0?e.pageInfo.hasNextPage:r.pageInfo.hasNextPage;return r?.nodes&&(i?(d=e.pageInfo.startCursor,S=e.pageInfo.hasPreviousPage):(g=e.pageInfo.endCursor,f=e.pageInfo.hasNextPage)),{startCursor:d,endCursor:g,hasPreviousPage:S,hasNextPage:f}},[i,r,e.pageInfo.hasNextPage,e.pageInfo.hasPreviousPage,e.pageInfo.startCursor,e.pageInfo.endCursor]),l=react.useRef({params:Ne(o),pathname:a});react.useEffect(()=>{window.__hydrogenHydrated=!0;},[]),react.useEffect(()=>{(Ne(o)!==l.current.params||a!==l.current.pathname)&&(l.current={pathname:a,params:Ne(o)},t(`${a}?${Ne(o)}`,{replace:!0,preventScrollReset:!0,state:{nodes:void 0,pageInfo:void 0}}));},[a,o]);let y=react.useMemo(()=>{let p=new URLSearchParams(o);return p.set("direction","previous"),c.startCursor&&p.set("cursor",c.startCursor),`?${p.toString()}`},[o,c.startCursor]),m=react.useMemo(()=>{let p=new URLSearchParams(o);return p.set("direction","next"),c.endCursor&&p.set("cursor",c.endCursor),`?${p.toString()}`},[o,c.endCursor]);return {...c,previousPageUrl:y,nextPageUrl:m,nodes:u}}function Uo(e,t={pageBy:20}){if(typeof e?.url>"u")throw new Error("getPaginationVariables must be called with the Request object passed to your loader function");let{pageBy:r}=t,o=new URLSearchParams(new URL(e.url).search),a=o.get("cursor")??void 0;return (o.get("direction")==="previous"?"previous":"next")==="previous"?{last:r,startCursor:a??null}:{first:r,endCursor:a??null}}var k=class extends Response{constructor(t,r,o){super(`Bad request: ${t}`,{status:400,headers:o});}};function Pe(e,t={}){let r=t.headers?new Headers(t.headers):new Headers({});return r.set("location",e),new Response(null,{status:t.status||302,headers:r})}async function _o({session:e,customerAccountId:t,customerAccountUrl:r,httpsOrigin:o,debugInfo:a,exchangeForStorefrontCustomerAccessToken:s}){let n=new URLSearchParams,u=e.get(E)?.refreshToken;if(!u)throw new k("Unauthorized","No refreshToken found in the session. Make sure your session is configured correctly and passed to `createCustomerAccountClient`.");n.append("grant_type","refresh_token"),n.append("refresh_token",u),n.append("client_id",t);let c={"content-type":"application/x-www-form-urlencoded","User-Agent":ae,Origin:o};new Date().getTime();let y=`${r}/auth/oauth/token`,m=await fetch(y,{method:"POST",headers:c,body:n});if(!m.ok){let R=await m.text();throw new Response(R,{status:m.status,headers:{"Content-Type":"text/html; charset=utf-8"}})}let{access_token:p,expires_in:d,id_token:g,refresh_token:S}=await m.json(),f=await lt(p,t,r,o);e.set(E,{accessToken:f,expiresAt:new Date(new Date().getTime()+(d-120)*1e3).getTime()+"",refreshToken:S,idToken:g}),await s();}function ce(e){e.unset(E),e.unset(ne);}async function ar({locks:e,expiresAt:t,session:r,customerAccountId:o,customerAccountUrl:a,httpsOrigin:s,debugInfo:n,exchangeForStorefrontCustomerAccessToken:i}){if(parseInt(t,10)-1e3<new Date().getTime())try{e.refresh||(e.refresh=_o({session:r,customerAccountId:o,customerAccountUrl:a,httpsOrigin:s,debugInfo:n,exchangeForStorefrontCustomerAccessToken:i})),await e.refresh,delete e.refresh;}catch(u){throw ce(r),u&&u.status!==401?u:new k("Unauthorized","Login before querying the Customer Account API.",{"Set-Cookie":await r.commit()})}}function nr(){let e=ko();return ir(e)}async function sr(e){let t=await crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(e)),r=Lo(t);return ir(r)}function ko(){let e=new Uint8Array(32);return crypto.getRandomValues(e),String.fromCharCode.apply(null,Array.from(e))}function ir(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Lo(e){let t=new Uint8Array(e),r=Array.from(t);return String.fromCharCode(...r)}function cr(){let e=Date.now().toString(),t=Math.random().toString(36).substring(2);return e+t}async function lt(e,t,r,o,a){let s=t;if(!e)throw new k("Unauthorized","oAuth access token was not provided during token exchange.");let n=new URLSearchParams;n.append("grant_type","urn:ietf:params:oauth:grant-type:token-exchange"),n.append("client_id",s),n.append("audience",$t),n.append("subject_token",e),n.append("subject_token_type","urn:ietf:params:oauth:token-type:access_token"),n.append("scopes","https://api.customers.com/auth/customer.graphql");let i={"content-type":"application/x-www-form-urlencoded","User-Agent":ae,Origin:o};new Date().getTime();let c=`${r}/auth/oauth/token`,l=await fetch(c,{method:"POST",headers:i,body:n});let y=await l.json();if(y.error)throw new k(y.error_description);return y.access_token}function ur(e){return No(e).payload.nonce}function No(e){let[t,r,o]=e.split("."),a=JSON.parse(atob(t)),s=JSON.parse(atob(r));return {header:a,payload:s,signature:o}}function Me(){return Vo(Mo())}function Mo(){try{return crypto.getRandomValues(new Uint8Array(16))}catch{return new Uint8Array(16).map(()=>Math.random()*255|0)}}function Vo(e){return Array.from(e,function(t){return ("0"+(t&255).toString(16)).slice(-2)}).join("")}var pr="/account/login",Fo="/account/authorize",lr="/account";function $o(e){if(!e.url)return pr;let{pathname:t}=new URL(e.url),r=pr+`?${new URLSearchParams({return_to:t}).toString()}`;return Pe(r)}function qo({session:e,customerAccountId:t,customerAccountUrl:r,customerApiVersion:o=De,request:a,waitUntil:s,authUrl:n,customAuthStatusHandler:i,logErrors:u=!0,unstableB2b:c=!1}){if(o!==De&&console.warn(`[h2:warn:createCustomerAccountClient] You are using Customer Account API version ${o} when this version of Hydrogen was built for ${De}.`),!a?.url)throw new Error("[h2:error:createCustomerAccountClient] The request object does not contain a URL.");let l=i||(()=>$o(a)),y=new URL(a.url),m=y.protocol==="http:"?y.origin.replace("http","https"):y.origin,p=ot({requestUrl:m,defaultUrl:Fo,redirectUrl:n}),d=`${r}/account/customer/api/${o}/graphql`,g={};async function S({query:h,type:C,variables:A={}}){let T=await v();if(!T)throw l();new Date().getTime();let D=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":ae,Origin:m,Authorization:T},body:JSON.stringify({query:h,variables:A})});let O=await D.text(),U={url:d,response:D,type:C,query:h,queryVariables:A,errors:void 0,client:"customer"};if(!D.ok){if(D.status===401){ce(e);let L=l();throw L instanceof Response&&L.headers.set("Set-Cookie",await e.commit()),L}let b;try{b=j(O);}catch{b=[{message:O}];}ge({...U,errors:b});}try{let b=j(O),{errors:L}=b,le=L?.map(({message:te,...$})=>new K(te,{...$,clientOperation:`customerAccount.${U.type}`,requestId:D.headers.get("x-request-id"),queryVariables:A,query:h}));return {...b,...L&&{errors:le}}}catch{ge({...U,errors:[{message:O}]});}}async function f(){if(!r||!t)return !1;let h=e.get(E),C=h?.accessToken,A=h?.expiresAt;if(!C||!A)return !1;let T=q?.();try{await ar({locks:g,expiresAt:A,session:e,customerAccountId:t,customerAccountUrl:r,httpsOrigin:m,debugInfo:{waitUntil:s,stackInfo:T,...J(a)},exchangeForStorefrontCustomerAccessToken:Ie});}catch{return !1}return !0}async function R(){if(!await f())throw l()}async function v(){if(await f())return e.get(E)?.accessToken}async function N(h,C){return Ae(r,t),h=se(h),Ue(h,"customer.mutate"),ie(S({query:h,type:"mutation",...C}),{logErrors:u})}async function F(h,C){return Ae(r,t),h=se(h),Oe(h,"customer.query"),ie(S({query:h,type:"query",...C}),{logErrors:u})}function ee(h){e.set(ne,{...e.get(ne),...h});}async function _(){if(await f())return e.get(ne)}async function Ie(){if(!c)return;let h=`#graphql
|
|
300
|
+
mutation storefrontCustomerAccessTokenCreate {
|
|
301
|
+
storefrontCustomerAccessTokenCreate {
|
|
302
|
+
customerAccessToken
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
`,{data:C}=await N(h),A=C?.storefrontCustomerAccessTokenCreate?.customerAccessToken;A&&ee({customerAccessToken:A});}return {login:async h=>{Ae(r,t);let C=new URL(`${r}/auth/oauth/authorize`),A=cr(),T=Me();if(C.searchParams.set("client_id",t),C.searchParams.set("scope","openid email"),C.searchParams.append("response_type","code"),C.searchParams.append("redirect_uri",p),C.searchParams.set("scope","openid email https://api.customers.com/auth/customer.graphql"),C.searchParams.append("state",A),C.searchParams.append("nonce",T),h?.uiLocales){let[D,O]=h.uiLocales.split("-"),U=D.toLowerCase();O&&(U+=`-${O.toUpperCase()}`),C.searchParams.append("ui_locales",U);}let M=nr(),V=await sr(M);return e.set(E,{...e.get(E),codeVerifier:M,state:A,nonce:T,redirectPath:ke(a.url)||_e(a,"Referer")||lr}),C.searchParams.append("code_challenge",V),C.searchParams.append("code_challenge_method","S256"),Pe(C.toString(),{headers:{"Set-Cookie":await e.commit()}})},logout:async h=>{Ae(r,t);let C=e.get(E)?.idToken,A=ot({requestUrl:m,defaultUrl:m,redirectUrl:h?.postLogoutRedirectUri}),T=C?new URL(`${r}/auth/logout?${new URLSearchParams([["id_token_hint",C],["post_logout_redirect_uri",A]]).toString()}`).toString():A;return ce(e),Pe(T,{status:302,headers:{"Set-Cookie":await e.commit()}})},isLoggedIn:f,handleAuthStatus:R,getAccessToken:v,getApiUrl:()=>d,mutate:N,query:F,authorize:async()=>{Ae(r,t);let h=y.searchParams.get("code"),C=y.searchParams.get("state");if(!h||!C)throw ce(e),new k("Unauthorized","No code or state parameter found in the redirect URL.",{"Set-Cookie":await e.commit()});if(e.get(E)?.state!==C)throw ce(e),new k("Unauthorized","The session state does not match the state parameter. Make sure that the session is configured correctly and passed to `createCustomerAccountClient`.",{"Set-Cookie":await e.commit()});let A=t,T=new URLSearchParams;T.append("grant_type","authorization_code"),T.append("client_id",A),T.append("redirect_uri",p),T.append("code",h);let M=e.get(E)?.codeVerifier;if(!M)throw new k("Unauthorized","No code verifier found in the session. Make sure that the session is configured correctly and passed to `createCustomerAccountClient`.");T.append("code_verifier",M);let V={"content-type":"application/x-www-form-urlencoded","User-Agent":ae,Origin:m},D=q?.();new Date().getTime();let U=`${r}/auth/oauth/token`,b=await fetch(U,{method:"POST",headers:V,body:T});if(!b.ok)throw new Response(await b.text(),{status:b.status,headers:{"Content-Type":"text/html; charset=utf-8"}});let{access_token:L,expires_in:le,id_token:te,refresh_token:$}=await b.json(),de=e.get(E)?.nonce,Dt=await ur(te);if(de!==Dt)throw new k("Unauthorized",`Returned nonce does not match: ${de} !== ${Dt}`);let qr=await lt(L,t,r,m,{waitUntil:s,stackInfo:D,...J(a)}),Hr=e.get(E)?.redirectPath;return e.set(E,{accessToken:qr,expiresAt:new Date(new Date().getTime()+(le-120)*1e3).getTime()+"",refreshToken:$,idToken:te}),await Ie(),Pe(Hr||lr,{headers:{"Set-Cookie":await e.commit()}})},UNSTABLE_setBuyer:ee,UNSTABLE_getBuyer:_}}function Ae(e,t){try{if(!e||!t)throw Error();new URL(e);}catch{console.error(new Error("[h2:error:customerAccount] You do not have the valid credential to use Customer Account API.\nRun `h2 env pull` to link your store credentials."));let r="Internal Server Error";throw new Response(r,{status:500})}}var Ho="https://raw.githubusercontent.com/Shopify/hydrogen/main/docs/changelog.json";async function Qo({request:e,changelogUrl:t}){new URL(e.url).searchParams;return fetch(t||Ho)}var dr="cartFormInput";function Ve({children:e,action:t,inputs:r,route:o,fetcherKey:a}){let s=react$1.useFetcher({key:a});return jsxRuntime.jsxs(s.Form,{action:o||"",method:"post",children:[(t||r)&&jsxRuntime.jsx("input",{type:"hidden",name:dr,value:JSON.stringify({action:t,inputs:r})}),typeof e=="function"?e(s):e]})}Ve.INPUT_NAME=dr;Ve.ACTIONS={AttributesUpdateInput:"AttributesUpdateInput",BuyerIdentityUpdate:"BuyerIdentityUpdate",Create:"Create",DiscountCodesUpdate:"DiscountCodesUpdate",LinesAdd:"LinesAdd",LinesRemove:"LinesRemove",LinesUpdate:"LinesUpdate",NoteUpdate:"NoteUpdate",SelectedDeliveryOptionsUpdate:"SelectedDeliveryOptionsUpdate",MetafieldsSet:"MetafieldsSet",MetafieldDelete:"MetafieldDelete"};function Go(e){let t={};for(let n of e.entries()){let i=n[0],u=e.getAll(i);t[i]=u.length>1?u:n[1];}let{cartFormInput:r,...o}=t,{action:a,inputs:s}=r?JSON.parse(String(r)):{};return {action:a,inputs:{...s,...o}}}Ve.getFormInput=Go;var w=`#graphql
|
|
298
306
|
fragment CartApiError on CartUserError {
|
|
299
307
|
message
|
|
300
308
|
field
|
|
@@ -305,7 +313,7 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
305
313
|
id
|
|
306
314
|
totalQuantity
|
|
307
315
|
}
|
|
308
|
-
`;function
|
|
316
|
+
`;function dt(e){return async(t,r)=>{let o=e.customerAccount?await e.customerAccount.UNSTABLE_getBuyer():void 0,{cartId:a,...s}=r||{},{buyerIdentity:n,...i}=t,{cartCreate:u,errors:c}=await e.storefront.mutate(Ko(e.cartFragment),{variables:{input:{...i,buyerIdentity:{...o,...n}},...s}});return P(u,c)}}var Ko=(e=I)=>`#graphql
|
|
309
317
|
mutation cartCreate(
|
|
310
318
|
$input: CartInput!
|
|
311
319
|
$country: CountryCode = ZZ
|
|
@@ -322,8 +330,8 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
322
330
|
}
|
|
323
331
|
}
|
|
324
332
|
${e}
|
|
325
|
-
${
|
|
326
|
-
`;function
|
|
333
|
+
${w}
|
|
334
|
+
`;function yt({storefront:e,customerAccount:t,getCartId:r,cartFragment:o}){return async a=>{let s=r();if(!s)return null;let[n,{cart:i,errors:u}]=await Promise.all([t?t.isLoggedIn():!1,e.query(zo(o),{variables:{cartId:s,...a},cache:e.CacheNone()})]);return P(Jo(n,i),u)}}function Jo(e,t){if(e&&t&&t.checkoutUrl){let r=new URL(t.checkoutUrl);r.searchParams.set("logged_in","true"),t.checkoutUrl=r.toString();}return t}var zo=(e=Yo)=>`#graphql
|
|
327
335
|
query CartQuery(
|
|
328
336
|
$cartId: ID!
|
|
329
337
|
$numCartLines: Int = 100
|
|
@@ -336,7 +344,7 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
336
344
|
}
|
|
337
345
|
|
|
338
346
|
${e}
|
|
339
|
-
`,
|
|
347
|
+
`,Yo=`#graphql
|
|
340
348
|
fragment CartApiQuery on Cart {
|
|
341
349
|
updatedAt
|
|
342
350
|
id
|
|
@@ -444,7 +452,7 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
444
452
|
width
|
|
445
453
|
height
|
|
446
454
|
}
|
|
447
|
-
`;function
|
|
455
|
+
`;function ft(e){return async(t,r)=>{let{cartLinesAdd:o,errors:a}=await e.storefront.mutate(Xo(e.cartFragment),{variables:{cartId:e.getCartId(),lines:t,...r}});return P(o,a)}}var Xo=(e=I)=>`#graphql
|
|
448
456
|
mutation cartLinesAdd(
|
|
449
457
|
$cartId: ID!
|
|
450
458
|
$lines: [CartLineInput!]!
|
|
@@ -462,8 +470,8 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
462
470
|
}
|
|
463
471
|
|
|
464
472
|
${e}
|
|
465
|
-
${
|
|
466
|
-
`;function
|
|
473
|
+
${w}
|
|
474
|
+
`;function mt(e){return async(t,r)=>{let{cartLinesUpdate:o,errors:a}=await e.storefront.mutate(Zo(e.cartFragment),{variables:{cartId:e.getCartId(),lines:t,...r}});return P(o,a)}}var Zo=(e=I)=>`#graphql
|
|
467
475
|
mutation cartLinesUpdate(
|
|
468
476
|
$cartId: ID!
|
|
469
477
|
$lines: [CartLineUpdateInput!]!
|
|
@@ -481,8 +489,8 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
481
489
|
}
|
|
482
490
|
|
|
483
491
|
${e}
|
|
484
|
-
${
|
|
485
|
-
`;function
|
|
492
|
+
${w}
|
|
493
|
+
`;function gt(e){return async(t,r)=>{let{cartLinesRemove:o,errors:a}=await e.storefront.mutate(ea(e.cartFragment),{variables:{cartId:e.getCartId(),lineIds:t,...r}});return P(o,a)}}var ea=(e=I)=>`#graphql
|
|
486
494
|
mutation cartLinesRemove(
|
|
487
495
|
$cartId: ID!
|
|
488
496
|
$lineIds: [ID!]!
|
|
@@ -500,8 +508,8 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
500
508
|
}
|
|
501
509
|
|
|
502
510
|
${e}
|
|
503
|
-
${
|
|
504
|
-
`;function
|
|
511
|
+
${w}
|
|
512
|
+
`;function ht(e){return async(t,r)=>{let o=t.filter((n,i,u)=>u.indexOf(n)===i),{cartDiscountCodesUpdate:a,errors:s}=await e.storefront.mutate(ta(e.cartFragment),{variables:{cartId:e.getCartId(),discountCodes:o,...r}});return P(a,s)}}var ta=(e=I)=>`#graphql
|
|
505
513
|
mutation cartDiscountCodesUpdate(
|
|
506
514
|
$cartId: ID!
|
|
507
515
|
$discountCodes: [String!]
|
|
@@ -518,8 +526,8 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
518
526
|
}
|
|
519
527
|
}
|
|
520
528
|
${e}
|
|
521
|
-
${
|
|
522
|
-
`;function
|
|
529
|
+
${w}
|
|
530
|
+
`;function Ct(e){return async(t,r)=>{t.companyLocationId&&e.customerAccount&&e.customerAccount.UNSTABLE_setBuyer({companyLocationId:t.companyLocationId});let o=e.customerAccount?await e.customerAccount.UNSTABLE_getBuyer():void 0,{cartBuyerIdentityUpdate:a,errors:s}=await e.storefront.mutate(ra(e.cartFragment),{variables:{cartId:e.getCartId(),buyerIdentity:{...o,...t},...r}});return P(a,s)}}var ra=(e=I)=>`#graphql
|
|
523
531
|
mutation cartBuyerIdentityUpdate(
|
|
524
532
|
$cartId: ID!
|
|
525
533
|
$buyerIdentity: CartBuyerIdentityInput!
|
|
@@ -536,8 +544,8 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
536
544
|
}
|
|
537
545
|
}
|
|
538
546
|
${e}
|
|
539
|
-
${
|
|
540
|
-
`;function
|
|
547
|
+
${w}
|
|
548
|
+
`;function St(e){return async(t,r)=>{let{cartNoteUpdate:o,errors:a}=await e.storefront.mutate(oa(e.cartFragment),{variables:{cartId:e.getCartId(),note:t,...r}});return P(o,a)}}var oa=(e=I)=>`#graphql
|
|
541
549
|
mutation cartNoteUpdate(
|
|
542
550
|
$cartId: ID!
|
|
543
551
|
$note: String!
|
|
@@ -554,8 +562,8 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
554
562
|
}
|
|
555
563
|
}
|
|
556
564
|
${e}
|
|
557
|
-
${
|
|
558
|
-
`;function
|
|
565
|
+
${w}
|
|
566
|
+
`;function Pt(e){return async(t,r)=>{let{cartSelectedDeliveryOptionsUpdate:o,errors:a}=await e.storefront.mutate(aa(e.cartFragment),{variables:{cartId:e.getCartId(),selectedDeliveryOptions:t,...r}});return P(o,a)}}var aa=(e=I)=>`#graphql
|
|
559
567
|
mutation cartSelectedDeliveryOptionsUpdate(
|
|
560
568
|
$cartId: ID!
|
|
561
569
|
$selectedDeliveryOptions: [CartSelectedDeliveryOptionInput!]!
|
|
@@ -572,8 +580,8 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
572
580
|
}
|
|
573
581
|
}
|
|
574
582
|
${e}
|
|
575
|
-
${
|
|
576
|
-
`;function
|
|
583
|
+
${w}
|
|
584
|
+
`;function At(e){return async(t,r)=>{let{cartAttributesUpdate:o,errors:a}=await e.storefront.mutate(na(e.cartFragment),{variables:{cartId:r?.cartId||e.getCartId(),attributes:t}});return P(o,a)}}var na=(e=I)=>`#graphql
|
|
577
585
|
mutation cartAttributesUpdate(
|
|
578
586
|
$cartId: ID!
|
|
579
587
|
$attributes: [AttributeInput!]!
|
|
@@ -588,8 +596,8 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
588
596
|
}
|
|
589
597
|
}
|
|
590
598
|
${e}
|
|
591
|
-
${
|
|
592
|
-
`;function
|
|
599
|
+
${w}
|
|
600
|
+
`;function Tt(e){return async(t,r)=>{let o=r?.cartId||e.getCartId(),a=t.map(i=>({...i,ownerId:o})),{cartMetafieldsSet:s,errors:n}=await e.storefront.mutate(sa(),{variables:{metafields:a}});return P({cart:{id:o},...s},n)}}var sa=()=>`#graphql
|
|
593
601
|
mutation cartMetafieldsSet(
|
|
594
602
|
$metafields: [CartMetafieldsSetInput!]!
|
|
595
603
|
$language: LanguageCode
|
|
@@ -604,7 +612,7 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
604
612
|
}
|
|
605
613
|
}
|
|
606
614
|
}
|
|
607
|
-
`;function
|
|
615
|
+
`;function vt(e){return async(t,r)=>{let o=r?.cartId||e.getCartId(),{cartMetafieldDelete:a,errors:s}=await e.storefront.mutate(ia(),{variables:{input:{ownerId:o,key:t}}});return P({cart:{id:o},...a},s)}}var ia=()=>`#graphql
|
|
608
616
|
mutation cartMetafieldDelete(
|
|
609
617
|
$input: CartMetafieldDeleteInput!
|
|
610
618
|
) {
|
|
@@ -616,7 +624,7 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
616
624
|
}
|
|
617
625
|
}
|
|
618
626
|
}
|
|
619
|
-
`;var ra=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function pr(e){let t={},r,o,a=0,s=e.split(/;\s*/g),n,i;for(;a<s.length;a++)if(o=s[a],r=o.indexOf("="),~r){if(n=o.substring(0,r++).trim(),i=o.substring(r).trim(),i[0]==='"'&&(i=i.substring(1,i.length-1)),~i.indexOf("%"))try{i=decodeURIComponent(i);}catch{}ra.has(o=n.toLowerCase())?o==="expires"?t.expires=new Date(i):o==="max-age"?t.maxage=+i:t[o]=i:t[n]=i;}else (n=o.trim().toLowerCase())&&(n==="httponly"||n==="secure")&&(t[n]=!0);return t}function dr(e,t,r={}){let o=e+"="+encodeURIComponent(t);return r.expires&&(o+="; Expires="+new Date(r.expires).toUTCString()),r.maxage!=null&&r.maxage>=0&&(o+="; Max-Age="+(r.maxage|0)),r.domain&&(o+="; Domain="+r.domain),r.path&&(o+="; Path="+r.path),r.samesite&&(o+="; SameSite="+r.samesite),(r.secure||r.samesite==="None")&&(o+="; Secure"),r.httponly&&(o+="; HttpOnly"),o}var oa=e=>{let t=pr(e.get("Cookie")||"");return ()=>t.cart?`gid://shopify/Cart/${t.cart}`:void 0};var aa=e=>t=>{let r=new Headers;return r.append("Set-Cookie",dr("cart",t.split("/").pop()||"",{path:"/",...e})),r};function na(e){let{getCartId:t,setCartId:r,storefront:o,customerAccount:a,cartQueryFragment:s,cartMutateFragment:n}=e,i=t(),u=()=>i||t(),c={storefront:o,getCartId:u,cartFragment:n},p=ut(c),d=async function(...l){let y=await p(...l);return i=y?.cart?.id,y},g={get:pt({storefront:o,customerAccount:a,getCartId:u,cartFragment:s}),getCartId:u,setCartId:r,create:d,addLines:async(l,y)=>i||y?.cartId?await dt(c)(l,y):await d({lines:l},y),updateLines:lt(c),removeLines:yt(c),updateDiscountCodes:async(l,y)=>i||y?.cartId?await ft(c)(l,y):await d({discountCodes:l},y),updateBuyerIdentity:async(l,y)=>i||y?.cartId?await mt(c)(l,y):await d({buyerIdentity:l},y),updateNote:async(l,y)=>i||y?.cartId?await gt(c)(l,y):await d({note:l},y),updateSelectedDeliveryOption:ht(c),updateAttributes:async(l,y)=>i||y?.cartId?await Ct(c)(l,y):await d({attributes:l},y),setMetafields:async(l,y)=>i||y?.cartId?await St(c)(l,y):await d({metafields:l},y),deleteMetafield:Pt(c)};return "customMethods"in e?{...g,...e.customMethods??{}}:g}function pa({handle:e,options:t=[],variants:r=[],productPath:o="products",children:a}){let s=r instanceof Array?r:hydrogenReact.flattenConnection(r),{searchParams:n,path:i,alreadyOnProductPage:u}=la(e,o),c=t.filter(p=>p?.values?.length===1);return react.createElement(react.Fragment,null,...react.useMemo(()=>t.filter(p=>p?.values?.length>1).map(p=>{let d,g=[];for(let l of p.values){let y=new URLSearchParams(u?n:void 0);y.set(p.name,l),c.forEach(m=>{y.set(m.name,m.values[0]);});let S=s.find(m=>m?.selectedOptions?.every(h=>y.get(h?.name)===h?.value)),C=n.get(p.name),f=C?C===l:!1;f&&(d=l);let T="?"+y.toString();g.push({value:l,isAvailable:S?S.availableForSale:!0,to:i+T,search:T,isActive:f});}return a({option:{name:p.name,value:d,values:g}})}),[t,s,a]))}var da=e=>{if(typeof e?.url>"u")throw new TypeError(`Expected a Request instance, got ${typeof e}`);let t=new URL(e.url).searchParams,r=[];return t.forEach((o,a)=>{r.push({name:a,value:o});}),r};function la(e,t){let{pathname:r,search:o}=react$1.useLocation();return react.useMemo(()=>{let a=/(\/[a-zA-Z]{2}-[a-zA-Z]{2}\/)/g.exec(r),s=a&&a.length>0;t=t.startsWith("/")?t.substring(1):t;let n=s?`${a[0]}${t}/${e}`:`/${t}/${e}`;return {searchParams:new URLSearchParams(o),alreadyOnProductPage:n===r,path:n}},[r,o,e,t])}var yr=react.createContext(void 0),ha=yr.Provider,At=()=>react.useContext(yr);function Ca(e){let t=Ue(),r=Sa(t,e);return {nonce:t,header:r,NonceProvider:({children:a})=>react.createElement(ha,{value:t},a)}}function Sa(e,t){let{shop:r,...o}=t??{},a=`'nonce-${e}'`,s=["'self'","'unsafe-inline'","https://cdn.shopify.com"],n=["'self'","https://monorail-edge.shopifysvc.com"];r&&r.checkoutDomain&&n.push(`https://${r.checkoutDomain}`),r&&r.storeDomain&&n.push(`https://${r.storeDomain}`);let u={baseUri:["'self'"],defaultSrc:["'self'",a,"https://cdn.shopify.com","https://shopify.com"],frameAncestors:["'none'"],styleSrc:s,connectSrc:n},c=Object.assign({},u,o);for(let p in u){let d=o[p];p&&d&&(c[p]=Pa(d,u[p]));}return c.scriptSrc instanceof Array&&!c.scriptSrc.includes(a)?c.scriptSrc.push(a):c.defaultSrc instanceof Array&&!c.defaultSrc.includes(a)&&c.defaultSrc.push(a),ga__default.default({directives:c})}function Pa(e,t){let r=typeof t=="string"?[t]:t,o=Array.isArray(e)?e:[String(e)];return Array.isArray(r)?[...o,...r]:r}var va=react.forwardRef((e,t)=>{let r=At();return jsxRuntime.jsx("script",{suppressHydrationWarning:!0,...e,nonce:r,ref:t})});function ba(e){let t=react$1.useFetchers(),r={};for(let{formData:o}of t)if(o?.get("optimistic-identifier")===e)try{if(o.has("optimistic-data")){let a=JSON.parse(String(o.get("optimistic-data")));Object.assign(r,a);}}catch{}return r}function Ra({id:e,data:t}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("input",{type:"hidden",name:"optimistic-identifier",value:e}),jsxRuntime.jsx("input",{type:"hidden",name:"optimistic-data",value:JSON.stringify(t)})]})}function Da(e){return jsxRuntime.jsx(hydrogenReact.ShopPayButton,{channel:"hydrogen",...e})}function ne(e){let{type:t,data:r={},customData:o}=e,a=react$1.useLocation(),{publish:s,cart:n,prevCart:i,shop:u}=K(),c=a.pathname+a.search;return react.useEffect(()=>{if(!u)return;let p={...r,customData:o,url:window.location.href,cart:n,prevCart:i,shop:u};s(t,p);},[s,c,n,i,u]),null}function mr(e){return jsxRuntime.jsx(ne,{...e,type:"page_viewed"})}function gr(e){return jsxRuntime.jsx(ne,{...e,type:"product_viewed"})}function hr(e){return jsxRuntime.jsx(ne,{...e,type:"collection_viewed"})}function Cr(e){return jsxRuntime.jsx(ne,{...e,type:"cart_viewed"})}function Sr(e){return jsxRuntime.jsx(ne,{...e,type:"search_viewed"})}function Pr(e){return jsxRuntime.jsx(ne,{...e})}var J={PAGE_VIEWED:"page_viewed",PRODUCT_VIEWED:"product_viewed",COLLECTION_VIEWED:"collection_viewed",CART_VIEWED:"cart_viewed",SEARCH_VIEWED:"search_viewed",CART_UPDATED:"cart_updated",PRODUCT_ADD_TO_CART:"product_added_to_cart",PRODUCT_REMOVED_FROM_CART:"product_removed_from_cart",CUSTOM_EVENT:"custom_"};var Na="https://cdn.shopify.com/shopifycloud/consent-tracking-api/v0.1/consent-tracking-api.js",Ma="https://cdn.shopify.com/shopifycloud/privacy-banner/storefront-banner.js";function vr(e){console.error(`[h2:error:useCustomerPrivacy] Unable to setup Customer Privacy API: Missing consent.${e} consent configuration.`);}function vt(e){let{withPrivacyBanner:t=!0,onVisitorConsentCollected:r,...o}=e,a=react.useRef(!1),s=hydrogenReact.useLoadScript(t?Ma:Na,{attributes:{id:"customer-privacy-api"}});o.checkoutDomain||vr("checkoutDomain"),o.storefrontAccessToken||vr("storefrontAccessToken"),react.useEffect(()=>{let n=i=>{r&&r(i.detail);};return document.addEventListener("visitorConsentCollected",n),()=>{document.removeEventListener("visitorConsentCollected",n);}},[r]),react.useEffect(()=>{if(!(s!=="done"||a.current)&&(a.current=!0,t&&window?.privacyBanner&&window?.privacyBanner?.loadBanner({checkoutRootDomain:o.checkoutDomain,storefrontAccessToken:o.storefrontAccessToken}),window.Shopify?.customerPrivacy)){let n=window.Shopify.customerPrivacy.setTrackingConsent;window.Shopify.customerPrivacy.setTrackingConsent=(i,u)=>{n({...i,headlessStorefront:!0,checkoutRootDomain:o.checkoutDomain,storefrontAccessToken:o.storefrontAccessToken},u);};}},[s,t,o]);}function Tt(){try{return window.Shopify&&window.Shopify.customerPrivacy?window.Shopify?.customerPrivacy:null}catch{return null}}function qa(){let e=Tt();if(!e)throw new Error("Shopify Customer Privacy API not available. Must be used within a useEffect. Make sure to load the Shopify Customer Privacy API with useCustomerPrivacy() or <AnalyticsProvider>.");return e}function Tr({consent:e}){let{subscribe:t,register:r,canTrack:o}=K(),{ready:a}=r("Internal_Shopify_Analytics"),{ready:s}=r("Internal_Shopify_CustomerPrivacy"),{checkoutDomain:n,storefrontAccessToken:i}=e;return n&&i&&vt({...e,onVisitorConsentCollected:s}),hydrogenReact.useShopifyCookies({hasUserConsent:o()}),react.useEffect(()=>{t(J.PAGE_VIEWED,Qa),t(J.PRODUCT_VIEWED,Ga),t(J.COLLECTION_VIEWED,Ba),t(J.SEARCH_VIEWED,Wa),t(J.PRODUCT_ADD_TO_CART,ja),a();},[t,a]),null}function ke(e){console.error(`[h2:error:ShopifyAnalytics] Unable to send Shopify analytics: Missing shop.${e} configuration.`);}function Pe(e){let t=qa(),r=t.userCanBeTracked();if(!e?.shop?.shopId){ke("shopId");return}if(!e?.shop?.acceptedLanguage){ke("acceptedLanguage");return}if(!e?.shop?.currency){ke("currency");return}if(!e?.shop?.hydrogenSubchannelId){ke("hydrogenSubchannelId");return}return {shopifySalesChannel:"hydrogen",...e.shop,hasUserConsent:r,...hydrogenReact.getClientBrowserParameters(),ccpaEnforced:!t.saleOfDataAllowed(),gdprEnforced:!(t.marketingAllowed()&&t.analyticsProcessingAllowed())}}function Ha(e,t){if(t===null)return;let r=Pe(e);return r?{...r,cartId:t.id}:void 0}var q={};function Qa(e){let t=Pe(e);t&&(hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.PAGE_VIEW_2,payload:{...t,...q}}),q={});}function Ga(e){let t=Pe(e);if(t&&wr({eventName:Ja,productField:"products",variantField:"product.<displayed_variant>",fromSource:"product_viewed products array",products:e.products})){let r=wt(e.products);q={pageType:hydrogenReact.AnalyticsPageType.product,resourceId:r[0].productGid},t={...t,...q,products:wt(e.products)},hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.PRODUCT_VIEW,payload:t});}}function Ba(e){let t=Pe(e);t&&(q={pageType:hydrogenReact.AnalyticsPageType.collection,resourceId:e.collection.id},t={...t,...q,collectionHandle:e.collection.handle},hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.COLLECTION_VIEW,payload:t}));}function Wa(e){let t=Pe(e);t&&(q={pageType:hydrogenReact.AnalyticsPageType.search},t={...t,...q,searchString:e.searchTerm},hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.SEARCH_VIEW,payload:t}));}function ja(e){let{cart:t,currentLine:r}=e,o=Ha(e,t);!o||!r?.id||Ka({matchedLine:r,eventPayload:o});}function Ka({matchedLine:e,eventPayload:t}){let r={id:e.merchandise.product.id,variantId:e.id,title:e.merchandise.product.title,variantTitle:e.merchandise.title,vendor:e.merchandise.product.vendor,price:e.merchandise.price.amount,quantity:e.quantity,productType:e.merchandise.product.productType,sku:e.merchandise.sku};wr({eventName:za,productField:"merchandise.product",variantField:"merchandise",fromSource:"cart query",products:[r]})&&hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.ADD_TO_CART,payload:{...t,products:wt([r])}});}var Ja="Product viewed",za="Add to cart";function z(e,t,r){console.error(`[h2:error:ShopifyAnalytics] ${e}: ${t} is required from the ${r}.`);}function wr({eventName:e,productField:t,variantField:r,products:o,fromSource:a}){return !o||o.length===0?(z(e,`${t}`,a),!1):(o.forEach(s=>{if(!s.id)return z(e,`${t}.id`,a),!1;if(!s.title)return z(e,`${t}.title`,a),!1;if(!s.price)return z(e,`${r}.price.amount`,a),!1;if(!s.vendor)return z(e,`${t}.vendor`,a),!1;if(!s.variantId)return z(e,`${r}.id`,a),!1;if(!s.variantTitle)return z(e,`${r}.title`,a),!1}),!0)}function wt(e){return e.map(t=>{let r={productGid:t.id,variantGid:t.variantId,name:t.title,variantName:t.variantTitle,brand:t.vendor,price:t.price,quantity:t.quantity||1,category:t.productType};return t.sku&&(r.sku=t.sku),t.productType&&(r.category=t.productType),r})}function Rr(e){console.error(`[h2:error:CartAnalytics] Unable to set up cart analytics events: ${e} is missing.`);}function Ir({cart:e,setCarts:t}){let{publish:r,shop:o,customData:a,canTrack:s,cart:n,prevCart:i}=K(),u=react.useRef(null);return react.useEffect(()=>{if(e)return Promise.resolve(e).then(c=>{if(c&&c.lines){if(!c.id){Rr("cart.id");return}if(!c.updatedAt){Rr("cart.updatedAt");return}}t(({cart:p,prevCart:d})=>c?.updatedAt!==p?.updatedAt?{cart:c,prevCart:p}:{cart:p,prevCart:d});}),()=>{}},[t,e]),react.useEffect(()=>{if(!n||!n?.updatedAt||n?.updatedAt===i?.updatedAt)return;let c;try{c=JSON.parse(localStorage.getItem("cartLastUpdatedAt")||"");}catch{c=null;}if(n.id===c?.id&&n.updatedAt===c?.updatedAt)return;let p={eventTimestamp:Date.now(),cart:n,prevCart:i,shop:o,customData:a};n.updatedAt!==u.current&&(u.current=n.updatedAt,r("cart_updated",p),localStorage.setItem("cartLastUpdatedAt",JSON.stringify({id:n.id,updatedAt:n.updatedAt})),i?.lines?.nodes?.forEach(d=>{let g=n?.lines.nodes.filter(l=>d.id===l.id);if(g?.length===1){let l=g[0];d.quantity<l.quantity?r("product_added_to_cart",{...p,prevLine:d,currentLine:l}):d.quantity>l.quantity&&r("product_removed_from_cart",{...p,prevLine:d,currentLine:l});}else r("product_removed_from_cart",{...p,prevLine:d});}),n?.lines?.nodes?.forEach(d=>{let g=i?.lines.nodes.filter(l=>d.id===l.id);(!g||g.length===0)&&r("product_added_to_cart",{...p,currentLine:d});}));},[n,i,r,o,a,s]),null}var rn={canTrack:()=>!1,cart:null,customData:{},prevCart:null,publish:()=>{},shop:null,subscribe:()=>{},register:()=>({ready:()=>{}})},_r=react.createContext(rn),Ne=new Map,Ae={};function kr(){return Object.values(Ae).every(Boolean)}function Er(e,t){Ne.has(e)||Ne.set(e,new Map),Ne.get(e)?.set(t.toString(),t);}var Me=new Map;function xr(e,t){if(!kr()){Me.set(e,t);return}Lr(e,t);}function Lr(e,t){(Ne.get(e)??new Map).forEach((r,o)=>{try{r(t);}catch(a){typeof a=="object"&&a instanceof Error?console.error("Analytics publish error",a.message,o,a.stack):console.error("Analytics publish error",a,o);}});}function Dr(e){return Ae.hasOwnProperty(e)||(Ae[e]=!1),{ready:()=>{Ae[e]=!0,kr()&&Me.size>0&&(Me.forEach((t,r)=>{Lr(r,t);}),Me.clear());}}}function Or(){return typeof window<"u"&&typeof window?.Shopify=="object"&&typeof window?.Shopify?.customerPrivacy=="object"&&typeof window?.Shopify?.customerPrivacy?.userCanBeTracked=="function"?window.Shopify.customerPrivacy.userCanBeTracked():!1}function on({canTrack:e,cart:t,children:r,consent:o,customData:a={},shop:s=null}){let n=react.useRef(!1),{shop:i}=an(s),[u,c]=react.useState(!!e),[p,d]=react.useState({cart:null,prevCart:null}),[g,l]=react.useState(e?()=>e:()=>Or);react.useEffect(()=>{e||n.current||(n.current=!0,document.addEventListener("visitorConsentCollected",()=>{c(!0),l(()=>Or);}));},[c,l,e]);let y=react.useMemo(()=>({canTrack:g,...p,customData:a,publish:g()?xr:()=>{},shop:i,subscribe:Er,register:Dr}),[u,g(),g,JSON.stringify(g),p,p.cart?.updatedAt,p.prevCart,xr,Er,a,i,Dr,JSON.stringify(Ae)]);return jsxRuntime.jsxs(_r.Provider,{value:y,children:[r,i&&jsxRuntime.jsx(mr,{}),i&&t&&jsxRuntime.jsx(Ir,{cart:t,setCarts:d}),i&&o&&jsxRuntime.jsx(Tr,{consent:o})]})}function K(){let e=react.useContext(_r);if(!e)throw new Error("[h2:error:useAnalytics] 'useAnalytics()' must be a descendent of <AnalyticsProvider/>");return e}function an(e){let[t,r]=react.useState(null);return react.useEffect(()=>(Promise.resolve(e).then(r),()=>{}),[r,e]),{shop:t}}async function nn({storefront:e,publicStorefrontId:t="0"}){return e.query(sn,{cache:e.CacheLong()}).then(({shop:r,localization:o})=>({shopId:r.id,acceptedLanguage:o.language.isoCode,currency:o.country.currency.isoCode,hydrogenSubchannelId:t}))}var sn=`#graphql
|
|
627
|
+
`;var ca=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function yr(e){let t={},r,o,a=0,s=e.split(/;\s*/g),n,i;for(;a<s.length;a++)if(o=s[a],r=o.indexOf("="),~r){if(n=o.substring(0,r++).trim(),i=o.substring(r).trim(),i[0]==='"'&&(i=i.substring(1,i.length-1)),~i.indexOf("%"))try{i=decodeURIComponent(i);}catch{}ca.has(o=n.toLowerCase())?o==="expires"?t.expires=new Date(i):o==="max-age"?t.maxage=+i:t[o]=i:t[n]=i;}else (n=o.trim().toLowerCase())&&(n==="httponly"||n==="secure")&&(t[n]=!0);return t}function fr(e,t,r={}){let o=e+"="+encodeURIComponent(t);return r.expires&&(o+="; Expires="+new Date(r.expires).toUTCString()),r.maxage!=null&&r.maxage>=0&&(o+="; Max-Age="+(r.maxage|0)),r.domain&&(o+="; Domain="+r.domain),r.path&&(o+="; Path="+r.path),r.samesite&&(o+="; SameSite="+r.samesite),(r.secure||r.samesite==="None")&&(o+="; Secure"),r.httponly&&(o+="; HttpOnly"),o}var ua=e=>{let t=yr(e.get("Cookie")||"");return ()=>t.cart?`gid://shopify/Cart/${t.cart}`:void 0};var pa=e=>t=>{let r=new Headers;return r.append("Set-Cookie",fr("cart",t.split("/").pop()||"",{path:"/",...e})),r};function la(e){let{getCartId:t,setCartId:r,storefront:o,customerAccount:a,cartQueryFragment:s,cartMutateFragment:n}=e,i=t(),u=()=>i||t(),c={storefront:o,getCartId:u,cartFragment:n,customerAccount:a},l=dt(c),y=async function(...p){let d=await l(...p);return i=d?.cart?.id,d},m={get:yt({storefront:o,customerAccount:a,getCartId:u,cartFragment:s}),getCartId:u,setCartId:r,create:y,addLines:async(p,d)=>i||d?.cartId?await ft(c)(p,d):await y({lines:p},d),updateLines:mt(c),removeLines:gt(c),updateDiscountCodes:async(p,d)=>i||d?.cartId?await ht(c)(p,d):await y({discountCodes:p},d),updateBuyerIdentity:async(p,d)=>i||d?.cartId?await Ct(c)(p,d):await y({buyerIdentity:p},d),updateNote:async(p,d)=>i||d?.cartId?await St(c)(p,d):await y({note:p},d),updateSelectedDeliveryOption:Pt(c),updateAttributes:async(p,d)=>i||d?.cartId?await At(c)(p,d):await y({attributes:p},d),setMetafields:async(p,d)=>i||d?.cartId?await Tt(c)(p,d):await y({metafields:p},d),deleteMetafield:vt(c)};return "customMethods"in e?{...m,...e.customMethods??{}}:m}function ga({handle:e,options:t=[],variants:r=[],productPath:o="products",children:a}){let s=r instanceof Array?r:hydrogenReact.flattenConnection(r),{searchParams:n,path:i,alreadyOnProductPage:u}=Ca(e,o),c=t.filter(l=>l?.values?.length===1);return react.createElement(react.Fragment,null,...react.useMemo(()=>t.filter(l=>l?.values?.length>1).map(l=>{let y,m=[];for(let p of l.values){let d=new URLSearchParams(u?n:void 0);d.set(l.name,p),c.forEach(v=>{d.set(v.name,v.values[0]);});let g=s.find(v=>v?.selectedOptions?.every(N=>d.get(N?.name)===N?.value)),S=n.get(l.name),f=S?S===p:!1;f&&(y=p);let R="?"+d.toString();m.push({value:p,isAvailable:g?g.availableForSale:!0,to:i+R,search:R,isActive:f});}return a({option:{name:l.name,value:y,values:m}})}),[t,s,a]))}var ha=e=>{if(typeof e?.url>"u")throw new TypeError(`Expected a Request instance, got ${typeof e}`);let t=new URL(e.url).searchParams,r=[];return t.forEach((o,a)=>{r.push({name:a,value:o});}),r};function Ca(e,t){let{pathname:r,search:o}=react$1.useLocation();return react.useMemo(()=>{let a=/(\/[a-zA-Z]{2}-[a-zA-Z]{2}\/)/g.exec(r),s=a&&a.length>0;t=t.startsWith("/")?t.substring(1):t;let n=s?`${a[0]}${t}/${e}`:`/${t}/${e}`;return {searchParams:new URLSearchParams(o),alreadyOnProductPage:n===r,path:n}},[r,o,e,t])}var gr=react.createContext(void 0),va=gr.Provider,Rt=()=>react.useContext(gr);function Ra(e){let t=Me(),r=wa(t,e);return {nonce:t,header:r,NonceProvider:({children:a})=>react.createElement(va,{value:t},a)}}function wa(e,t){let{shop:r,...o}=t??{},a=`'nonce-${e}'`,s=["'self'","'unsafe-inline'","https://cdn.shopify.com"],n=["'self'","https://monorail-edge.shopifysvc.com"];r&&r.checkoutDomain&&n.push(`https://${r.checkoutDomain}`),r&&r.storeDomain&&n.push(`https://${r.storeDomain}`);let u={baseUri:["'self'"],defaultSrc:["'self'",a,"https://cdn.shopify.com","https://shopify.com"],frameAncestors:["'none'"],styleSrc:s,connectSrc:n},c=Object.assign({},u,o);for(let l in u){let y=o[l];l&&y&&(c[l]=Ia(y,u[l]));}return c.scriptSrc instanceof Array&&!c.scriptSrc.includes(a)?c.scriptSrc.push(a):c.defaultSrc instanceof Array&&!c.defaultSrc.includes(a)&&c.defaultSrc.push(a),Ta__default.default({directives:c})}function Ia(e,t){let r=typeof t=="string"?[t]:t,o=Array.isArray(e)?e:[String(e)];return Array.isArray(r)?r.every(s=>s==="'none'")?o:[...o,...r]:r}var Ea=react.forwardRef((e,t)=>{let r=Rt();return jsxRuntime.jsx("script",{suppressHydrationWarning:!0,...e,nonce:r,ref:t})});function Oa(e){let t=react$1.useFetchers(),r={};for(let{formData:o}of t)if(o?.get("optimistic-identifier")===e)try{if(o.has("optimistic-data")){let a=JSON.parse(String(o.get("optimistic-data")));Object.assign(r,a);}}catch{}return r}function Ua({id:e,data:t}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("input",{type:"hidden",name:"optimistic-identifier",value:e}),jsxRuntime.jsx("input",{type:"hidden",name:"optimistic-data",value:JSON.stringify(t)})]})}function Na(e){return jsxRuntime.jsx(hydrogenReact.ShopPayButton,{channel:"hydrogen",...e})}function ue(e){let{type:t,data:r={},customData:o}=e,a=react$1.useLocation(),{publish:s,cart:n,prevCart:i,shop:u}=Y(),c=a.pathname+a.search;return react.useEffect(()=>{if(!u)return;let l={...r,customData:o,url:window.location.href,cart:n,prevCart:i,shop:u};s(t,l);},[s,c,n,i,u]),null}function Cr(e){return jsxRuntime.jsx(ue,{...e,type:"page_viewed"})}function Sr(e){return jsxRuntime.jsx(ue,{...e,type:"product_viewed"})}function Pr(e){return jsxRuntime.jsx(ue,{...e,type:"collection_viewed"})}function Ar(e){return jsxRuntime.jsx(ue,{...e,type:"cart_viewed"})}function Tr(e){return jsxRuntime.jsx(ue,{...e,type:"search_viewed"})}function vr(e){return jsxRuntime.jsx(ue,{...e})}var X={PAGE_VIEWED:"page_viewed",PRODUCT_VIEWED:"product_viewed",COLLECTION_VIEWED:"collection_viewed",CART_VIEWED:"cart_viewed",SEARCH_VIEWED:"search_viewed",CART_UPDATED:"cart_updated",PRODUCT_ADD_TO_CART:"product_added_to_cart",PRODUCT_REMOVED_FROM_CART:"product_removed_from_cart",CUSTOM_EVENT:"custom_"};var Ha="https://cdn.shopify.com/shopifycloud/consent-tracking-api/v0.1/consent-tracking-api.js",Qa="https://cdn.shopify.com/shopifycloud/privacy-banner/storefront-banner.js";function wr(e){console.error(`[h2:error:useCustomerPrivacy] Unable to setup Customer Privacy API: Missing consent.${e} consent configuration.`);}function wt(e){let{withPrivacyBanner:t=!0,onVisitorConsentCollected:r,onReady:o,...a}=e,s=react.useRef(!1),n=hydrogenReact.useLoadScript(t?Qa:Ha,{attributes:{id:"customer-privacy-api"}});a.checkoutDomain||wr("checkoutDomain"),a.storefrontAccessToken||wr("storefrontAccessToken"),react.useEffect(()=>{let i=u=>{r&&r(u.detail);};return document.addEventListener("visitorConsentCollected",i),()=>{document.removeEventListener("visitorConsentCollected",i);}},[r]),react.useEffect(()=>{if(!(n!=="done"||s.current)){if(s.current=!0,t&&window?.privacyBanner&&window?.privacyBanner?.loadBanner({checkoutRootDomain:a.checkoutDomain,storefrontAccessToken:a.storefrontAccessToken}),window.Shopify?.customerPrivacy){let i=window.Shopify.customerPrivacy.setTrackingConsent;window.Shopify.customerPrivacy.setTrackingConsent=(u,c)=>{i({...u,headlessStorefront:!0,checkoutRootDomain:a.checkoutDomain,storefrontAccessToken:a.storefrontAccessToken},c);};}o&&!t&&o();}},[n,t,a]);}function It(){try{return window.Shopify&&window.Shopify.customerPrivacy?window.Shopify?.customerPrivacy:null}catch{return null}}function ja(){let e=It();if(!e)throw new Error("Shopify Customer Privacy API not available. Must be used within a useEffect. Make sure to load the Shopify Customer Privacy API with useCustomerPrivacy() or <AnalyticsProvider>.");return e}function Ir({consent:e,onReady:t}){let{subscribe:r,register:o,canTrack:a}=Y(),{ready:s}=o("Internal_Shopify_Analytics"),{ready:n}=o("Internal_Shopify_CustomerPrivacy"),i=()=>{n(),t();};return wt({...e,onVisitorConsentCollected:i,onReady:()=>{e.withPrivacyBanner||i();}}),hydrogenReact.useShopifyCookies({hasUserConsent:a()}),react.useEffect(()=>{r(X.PAGE_VIEWED,Ja),r(X.PRODUCT_VIEWED,za),r(X.COLLECTION_VIEWED,Ya),r(X.SEARCH_VIEWED,Xa),r(X.PRODUCT_ADD_TO_CART,Za),s();},[r,s]),null}function Fe(e){console.error(`[h2:error:ShopifyAnalytics] Unable to send Shopify analytics: Missing shop.${e} configuration.`);}function Re(e){let t=ja(),r=t.analyticsProcessingAllowed();if(!e?.shop?.shopId){Fe("shopId");return}if(!e?.shop?.acceptedLanguage){Fe("acceptedLanguage");return}if(!e?.shop?.currency){Fe("currency");return}if(!e?.shop?.hydrogenSubchannelId){Fe("hydrogenSubchannelId");return}return {shopifySalesChannel:"hydrogen",...e.shop,hasUserConsent:r,...hydrogenReact.getClientBrowserParameters(),ccpaEnforced:!t.saleOfDataAllowed(),gdprEnforced:!(t.marketingAllowed()&&t.analyticsProcessingAllowed())}}function Ka(e,t){if(t===null)return;let r=Re(e);return r?{...r,cartId:t.id}:void 0}var W={};function Ja(e){let t=Re(e);t&&(hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.PAGE_VIEW_2,payload:{...t,...W}}),W={});}function za(e){let t=Re(e);if(t&&br({eventName:tn,productField:"products",variantField:"product.<displayed_variant>",fromSource:"product_viewed products array",products:e.products})){let r=bt(e.products);W={pageType:hydrogenReact.AnalyticsPageType.product,resourceId:r[0].productGid},t={...t,...W,products:bt(e.products)},hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.PRODUCT_VIEW,payload:t});}}function Ya(e){let t=Re(e);t&&(W={pageType:hydrogenReact.AnalyticsPageType.collection,resourceId:e.collection.id},t={...t,...W,collectionHandle:e.collection.handle},hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.COLLECTION_VIEW,payload:t}));}function Xa(e){let t=Re(e);t&&(W={pageType:hydrogenReact.AnalyticsPageType.search},t={...t,...W,searchString:e.searchTerm},hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.SEARCH_VIEW,payload:t}));}function Za(e){let{cart:t,currentLine:r}=e,o=Ka(e,t);!o||!r?.id||en({matchedLine:r,eventPayload:o});}function en({matchedLine:e,eventPayload:t}){let r={id:e.merchandise.product.id,variantId:e.id,title:e.merchandise.product.title,variantTitle:e.merchandise.title,vendor:e.merchandise.product.vendor,price:e.merchandise.price.amount,quantity:e.quantity,productType:e.merchandise.product.productType,sku:e.merchandise.sku};br({eventName:rn,productField:"merchandise.product",variantField:"merchandise",fromSource:"cart query",products:[r]})&&hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.ADD_TO_CART,payload:{...t,products:bt([r])}});}var tn="Product viewed",rn="Add to cart";function Z(e,t,r){console.error(`[h2:error:ShopifyAnalytics] ${e}: ${t} is required from the ${r}.`);}function br({eventName:e,productField:t,variantField:r,products:o,fromSource:a}){return !o||o.length===0?(Z(e,`${t}`,a),!1):(o.forEach(s=>{if(!s.id)return Z(e,`${t}.id`,a),!1;if(!s.title)return Z(e,`${t}.title`,a),!1;if(!s.price)return Z(e,`${r}.price.amount`,a),!1;if(!s.vendor)return Z(e,`${t}.vendor`,a),!1;if(!s.variantId)return Z(e,`${r}.id`,a),!1;if(!s.variantTitle)return Z(e,`${r}.title`,a),!1}),!0)}function bt(e){return e.map(t=>{let r={productGid:t.id,variantGid:t.variantId,name:t.title,variantName:t.variantTitle,brand:t.vendor,price:t.price,quantity:t.quantity||1,category:t.productType};return t.sku&&(r.sku=t.sku),t.productType&&(r.category=t.productType),r})}function Dr(e){console.error(`[h2:error:CartAnalytics] Unable to set up cart analytics events: ${e} is missing.`);}function Or({cart:e,setCarts:t}){let{publish:r,shop:o,customData:a,canTrack:s,cart:n,prevCart:i}=Y(),u=react.useRef(null);return react.useEffect(()=>{if(e)return Promise.resolve(e).then(c=>{if(c&&c.lines){if(!c.id){Dr("cart.id");return}if(!c.updatedAt){Dr("cart.updatedAt");return}}t(({cart:l,prevCart:y})=>c?.updatedAt!==l?.updatedAt?{cart:c,prevCart:l}:{cart:l,prevCart:y});}),()=>{}},[t,e]),react.useEffect(()=>{if(!n||!n?.updatedAt||n?.updatedAt===i?.updatedAt)return;let c;try{c=JSON.parse(localStorage.getItem("cartLastUpdatedAt")||"");}catch{c=null;}if(n.id===c?.id&&n.updatedAt===c?.updatedAt)return;let l={eventTimestamp:Date.now(),cart:n,prevCart:i,shop:o,customData:a};if(n.updatedAt===u.current)return;u.current=n.updatedAt,r("cart_updated",l),localStorage.setItem("cartLastUpdatedAt",JSON.stringify({id:n.id,updatedAt:n.updatedAt}));let y=i?.lines?hydrogenReact.flattenConnection(i?.lines):[],m=n.lines?hydrogenReact.flattenConnection(n.lines):[];y?.forEach(p=>{let d=m.filter(g=>p.id===g.id);if(d?.length===1){let g=d[0];p.quantity<g.quantity?r("product_added_to_cart",{...l,prevLine:p,currentLine:g}):p.quantity>g.quantity&&r("product_removed_from_cart",{...l,prevLine:p,currentLine:g});}else r("product_removed_from_cart",{...l,prevLine:p});}),m?.forEach(p=>{let d=y.filter(g=>p.id===g.id);(!d||d.length===0)&&r("product_added_to_cart",{...l,currentLine:p});});},[n,i,r,o,a,s]),null}var pn={canTrack:()=>!1,cart:null,customData:{},prevCart:null,publish:()=>{},shop:null,subscribe:()=>{},register:()=>({ready:()=>{}})},Vr=react.createContext(pn),qe=new Map,we={};function Fr(){return Object.values(we).every(Boolean)}function _r(e,t){qe.has(e)||qe.set(e,new Map),qe.get(e)?.set(t.toString(),t);}var He=new Map;function kr(e,t){if(!Fr()){He.set(e,t);return}$r(e,t);}function $r(e,t){(qe.get(e)??new Map).forEach((r,o)=>{try{r(t);}catch(a){typeof a=="object"&&a instanceof Error?console.error("Analytics publish error",a.message,o,a.stack):console.error("Analytics publish error",a,o);}});}function Lr(e){return we.hasOwnProperty(e)||(we[e]=!1),{ready:()=>{we[e]=!0,Fr()&&He.size>0&&(He.forEach((t,r)=>{$r(r,t);}),He.clear());}}}function Nr(){try{return window.Shopify.customerPrivacy.analyticsProcessingAllowed()}catch{}return !1}function Mr(e){return `[h2:error:Analytics.Provider] - ${e} is required`}function ln({canTrack:e,cart:t,children:r,consent:o,customData:a={},shop:s=null,disableThrowOnError:n=!1}){if(!o.checkoutDomain){let S=Mr("consent.checkoutDomain");n?console.error(S):Ur__default.default(!1,S);}if(!o.storefrontAccessToken){let S=Mr("consent.storefrontAccessToken");n?console.error(S):Ur__default.default(!1,S);}let i=react.useRef(!1),{shop:u}=dn(s),[c,l]=react.useState(!!e),[y,m]=react.useState({cart:null,prevCart:null}),[p,d]=react.useState(e?()=>e:()=>Nr),g=react.useMemo(()=>({canTrack:p,...y,customData:a,publish:p()?kr:()=>{},shop:u,subscribe:_r,register:Lr}),[c,p(),p,JSON.stringify(p),y,y.cart?.updatedAt,y.prevCart,kr,_r,a,u,Lr,JSON.stringify(we)]);return jsxRuntime.jsxs(Vr.Provider,{value:g,children:[r,!!u&&jsxRuntime.jsx(Cr,{}),!!u&&!!t&&jsxRuntime.jsx(Or,{cart:t,setCarts:m}),!!u&&jsxRuntime.jsx(Ir,{consent:o,onReady:()=>{i.current=!0,l(!0),d(()=>Nr);}})]})}function Y(){let e=react.useContext(Vr);if(!e)throw new Error("[h2:error:useAnalytics] 'useAnalytics()' must be a descendent of <AnalyticsProvider/>");return e}function dn(e){let[t,r]=react.useState(null);return react.useEffect(()=>(Promise.resolve(e).then(r),()=>{}),[r,e]),{shop:t}}async function yn({storefront:e,publicStorefrontId:t="0"}){return e.query(fn,{cache:e.CacheLong()}).then(({shop:r,localization:o})=>({shopId:r.id,acceptedLanguage:o.language.isoCode,currency:o.country.currency.isoCode,hydrogenSubchannelId:t}))}var fn=`#graphql
|
|
620
628
|
query ShopData(
|
|
621
629
|
$country: CountryCode
|
|
622
630
|
$language: LanguageCode
|
|
@@ -635,7 +643,7 @@ API response error: ${t.status}`,c=new B(u,{query:a,queryVariables:s,cause:{erro
|
|
|
635
643
|
}
|
|
636
644
|
}
|
|
637
645
|
}
|
|
638
|
-
`,
|
|
646
|
+
`,mn={CartView:Ar,CollectionView:Pr,CustomView:vr,ProductView:Sr,Provider:ln,SearchView:Tr};//! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartCreate
|
|
639
647
|
//! @see https://shopify.dev/docs/api/storefront/latest/queries/cart
|
|
640
648
|
//! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartLinesAdd
|
|
641
649
|
//! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartLinesUpdate
|
|
@@ -731,52 +739,52 @@ Object.defineProperty(exports, 'useShopifyCookies', {
|
|
|
731
739
|
enumerable: true,
|
|
732
740
|
get: function () { return hydrogenReact.useShopifyCookies; }
|
|
733
741
|
});
|
|
734
|
-
exports.AnalyticsEvent =
|
|
735
|
-
exports.CacheCustom =
|
|
736
|
-
exports.CacheLong =
|
|
737
|
-
exports.CacheNone =
|
|
738
|
-
exports.CacheShort =
|
|
739
|
-
exports.CartForm =
|
|
740
|
-
exports.InMemoryCache =
|
|
741
|
-
exports.OptimisticInput =
|
|
742
|
-
exports.Pagination =
|
|
743
|
-
exports.Script =
|
|
744
|
-
exports.Seo =
|
|
745
|
-
exports.ShopPayButton =
|
|
746
|
-
exports.UNSTABLE_Analytics =
|
|
747
|
-
exports.VariantSelector =
|
|
748
|
-
exports.cartAttributesUpdateDefault =
|
|
749
|
-
exports.cartBuyerIdentityUpdateDefault =
|
|
750
|
-
exports.cartCreateDefault =
|
|
751
|
-
exports.cartDiscountCodesUpdateDefault =
|
|
752
|
-
exports.cartGetDefault =
|
|
753
|
-
exports.cartGetIdDefault =
|
|
754
|
-
exports.cartLinesAddDefault =
|
|
755
|
-
exports.cartLinesRemoveDefault =
|
|
756
|
-
exports.cartLinesUpdateDefault =
|
|
757
|
-
exports.cartMetafieldDeleteDefault =
|
|
758
|
-
exports.cartMetafieldsSetDefault =
|
|
759
|
-
exports.cartNoteUpdateDefault =
|
|
760
|
-
exports.cartSelectedDeliveryOptionsUpdateDefault =
|
|
761
|
-
exports.cartSetIdDefault =
|
|
762
|
-
exports.changelogHandler =
|
|
763
|
-
exports.createCartHandler =
|
|
764
|
-
exports.createContentSecurityPolicy =
|
|
765
|
-
exports.createCustomerAccountClient =
|
|
766
|
-
exports.createStorefrontClient =
|
|
767
|
-
exports.createWithCache =
|
|
742
|
+
exports.AnalyticsEvent = X;
|
|
743
|
+
exports.CacheCustom = je;
|
|
744
|
+
exports.CacheLong = We;
|
|
745
|
+
exports.CacheNone = Be;
|
|
746
|
+
exports.CacheShort = re;
|
|
747
|
+
exports.CartForm = Ve;
|
|
748
|
+
exports.InMemoryCache = rt;
|
|
749
|
+
exports.OptimisticInput = Ua;
|
|
750
|
+
exports.Pagination = Do;
|
|
751
|
+
exports.Script = Ea;
|
|
752
|
+
exports.Seo = Ro;
|
|
753
|
+
exports.ShopPayButton = Na;
|
|
754
|
+
exports.UNSTABLE_Analytics = mn;
|
|
755
|
+
exports.VariantSelector = ga;
|
|
756
|
+
exports.cartAttributesUpdateDefault = At;
|
|
757
|
+
exports.cartBuyerIdentityUpdateDefault = Ct;
|
|
758
|
+
exports.cartCreateDefault = dt;
|
|
759
|
+
exports.cartDiscountCodesUpdateDefault = ht;
|
|
760
|
+
exports.cartGetDefault = yt;
|
|
761
|
+
exports.cartGetIdDefault = ua;
|
|
762
|
+
exports.cartLinesAddDefault = ft;
|
|
763
|
+
exports.cartLinesRemoveDefault = gt;
|
|
764
|
+
exports.cartLinesUpdateDefault = mt;
|
|
765
|
+
exports.cartMetafieldDeleteDefault = vt;
|
|
766
|
+
exports.cartMetafieldsSetDefault = Tt;
|
|
767
|
+
exports.cartNoteUpdateDefault = St;
|
|
768
|
+
exports.cartSelectedDeliveryOptionsUpdateDefault = Pt;
|
|
769
|
+
exports.cartSetIdDefault = pa;
|
|
770
|
+
exports.changelogHandler = Qo;
|
|
771
|
+
exports.createCartHandler = la;
|
|
772
|
+
exports.createContentSecurityPolicy = Ra;
|
|
773
|
+
exports.createCustomerAccountClient = qo;
|
|
774
|
+
exports.createStorefrontClient = Kn;
|
|
775
|
+
exports.createWithCache = es;
|
|
768
776
|
exports.formatAPIResult = P;
|
|
769
|
-
exports.generateCacheControlHeader =
|
|
770
|
-
exports.getCustomerPrivacy =
|
|
771
|
-
exports.getPaginationVariables =
|
|
772
|
-
exports.getSelectedProductOptions =
|
|
773
|
-
exports.getSeoMeta =
|
|
774
|
-
exports.getShopAnalytics =
|
|
775
|
-
exports.graphiqlLoader =
|
|
776
|
-
exports.storefrontRedirect =
|
|
777
|
-
exports.unstable_useAnalytics =
|
|
778
|
-
exports.useCustomerPrivacy =
|
|
779
|
-
exports.useNonce =
|
|
780
|
-
exports.useOptimisticData =
|
|
777
|
+
exports.generateCacheControlHeader = ye;
|
|
778
|
+
exports.getCustomerPrivacy = It;
|
|
779
|
+
exports.getPaginationVariables = Uo;
|
|
780
|
+
exports.getSelectedProductOptions = ha;
|
|
781
|
+
exports.getSeoMeta = wo;
|
|
782
|
+
exports.getShopAnalytics = yn;
|
|
783
|
+
exports.graphiqlLoader = lo;
|
|
784
|
+
exports.storefrontRedirect = uo;
|
|
785
|
+
exports.unstable_useAnalytics = Y;
|
|
786
|
+
exports.useCustomerPrivacy = wt;
|
|
787
|
+
exports.useNonce = Rt;
|
|
788
|
+
exports.useOptimisticData = Oa;
|
|
781
789
|
//# sourceMappingURL=out.js.map
|
|
782
790
|
//# sourceMappingURL=index.cjs.map
|