@shopify/hydrogen 2024.4.7 → 2024.7.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/customer-account-api-types.d.ts +597 -1044
- package/dist/customer-account.schema.json +1 -1
- package/dist/development/index.cjs +236 -201
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +217 -183
- package/dist/development/index.js.map +1 -1
- package/dist/production/index.cjs +101 -100
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.d.cts +152 -119
- package/dist/production/index.d.ts +152 -119
- package/dist/production/index.js +29 -29
- package/dist/production/index.js.map +1 -1
- package/dist/storefront-api-types.d.ts +758 -1076
- package/dist/storefront.schema.json +1 -1
- package/dist/vite/hydrogen-middleware.d.ts +1 -1
- package/dist/vite/hydrogen-middleware.js +1 -2
- package/dist/vite/plugin.d.ts +3 -48
- package/dist/vite/plugin.js +1 -2
- package/dist/vite/request-events.d.ts +28 -2
- package/dist/vite/request-events.js +4 -8
- package/dist/vite/types.d.ts +1 -1
- package/dist/vite/virtual-routes/components/RequestDetails.jsx +1 -2
- package/dist/vite/virtual-routes/components/RequestTable.jsx +1 -2
- package/dist/vite/virtual-routes/routes/index.jsx +1 -2
- package/dist/vite/virtual-routes/virtual-root.jsx +5 -26
- package/package.json +9 -9
|
@@ -5,21 +5,21 @@ var react = require('react');
|
|
|
5
5
|
var react$1 = require('@remix-run/react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var cookie = require('worktop/cookie');
|
|
8
|
-
var
|
|
8
|
+
var Ma = require('content-security-policy-builder');
|
|
9
9
|
|
|
10
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var Ma__default = /*#__PURE__*/_interopDefault(Ma);
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var Yr=Object.defineProperty;var Xr=(e,t)=>()=>(e&&(t=e(e=0)),t);var Zr=(e,t)=>{for(var r in t)Yr(e,r,{get:t[r],enumerable:!0});};var rr={};Zr(rr,{default:()=>er,logSeoTags:()=>tr});function er({headTags:e}){return tr(e),null}function tr(e){console.log(" "),console.log("%cSEO Meta Tags",`${Io}`),console.log(" "),e.forEach(t=>{if(t.tag==="script"){if(console.log("%c\u2022 JSON LD ",yt),t.children)try{console.table(JSON.parse(t.children),["name","content"]);}catch{console.log(t.children);}}else {if(console.log(`%c\u2022 ${t.tag} `,yt),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;bo(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",yt),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 bo(e){let o=await(await(await fetch(e)).blob()).arrayBuffer();return `data:image/png;base64,${wo(o)}`}function wo(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 yt,Io,or=Xr(()=>{yt="text-transform: uppercase;",Io="text-transform: uppercase; font-weight: bold; text-transform: uppercase;font-weight: bold";});var Ee="public",eo="private",je="no-store",_t={maxAge:"max-age",staleWhileRevalidate:"stale-while-revalidate",sMaxAge:"s-maxage",staleIfError:"stale-if-error"};function fe(e){let t=[];return Object.keys(e).forEach(r=>{r==="mode"?t.push(e[r]):_t[r]&&t.push(`${_t[r]}=${e[r]}`);}),t.join(", ")}function Ke(){return {mode:je}}function ze(e){if(e?.mode&&e?.mode!==Ee&&e?.mode!==eo)throw Error("'mode' must be either 'public' or 'private'")}function J(e){return ze(e),{mode:Ee,maxAge:1,staleWhileRevalidate:9,...e}}function Je(e){return ze(e),{mode:Ee,maxAge:3600,staleWhileRevalidate:82800,...e}}function ae(e){return ze(e),{mode:Ee,maxAge:1,staleWhileRevalidate:86399,...e}}function Ye(e){return e}function Y(e){return String(e).includes("__proto__")?JSON.parse(e,to):JSON.parse(e)}function to(e,t){if(e!=="__proto__")return t}function Oe(e,t){return e&&t?{...e,...t}:e||ae()}function Xe(e){return fe(Oe(e))}async function ro(e,t){if(!e)return;let r=await e.match(t);if(!r){return}return r}async function oo(e,t,r,o){if(!e)return;let a=Oe(o),n=Xe(Oe(a,{maxAge:(a.maxAge||0)+(a.staleWhileRevalidate||0)})),i=Xe(Oe(a));r.headers.set("cache-control",n),r.headers.set("real-cache-control",i),r.headers.set("cache-put-date",String(Date.now())),await e.put(t,r);}async function ao(e,t){e&&await e.delete(t);}function no(e,t){let r=e.headers.get("real-cache-control"),o=0;if(r){let n=r.match(/max-age=(\d*)/);n&&n.length>1&&(o=parseFloat(n[1]));}return [(Date.now()-Number(t))/1e3,o]}function io(e,t){let r=t.headers.get("cache-put-date");if(!r)return !1;let[o,a]=no(t,r),n=o>a;return n}var De={get:ro,set:oo,delete:ao,generateDefaultCacheControlHeader:Xe,isStale:io};function me(e){return `https://shopify.dev/?${e}`}function so(e){return e||ae()}async function Ut(e,t){if(!e)return;let r=me(t),o=new Request(r),a=await De.get(e,o);if(!a)return;let n=await a.text();try{return [Y(n),a]}catch{return [n,a]}}async function Nt(e,t,r,o){if(!e)return;let a=me(t),n=new Request(a),i=new Response(JSON.stringify(r));await De.set(e,n,i,so(o));}function Vt(e,t){return De.isStale(new Request(me(e)),t)}function Mt(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 Ze=new Set;async function xe(e,t,{strategy:r=J(),cacheInstance:o,shouldCacheResult:a=()=>!0,waitUntil:n,debugInfo:i}){let c=Mt([...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()||[])}});},d=void 0;if(!o||!r||r.mode===je){let f=await t({addDebugData:y});return f}let p=f=>Nt(o,c,{value:f,debugInfo:void 0},r),h=await Ut(o,c);if(h&&typeof h[0]!="string"){let[{value:f,debugInfo:v},I]=h;let _=Vt(c,I)?"STALE":"HIT";if(!Ze.has(c)&&_==="STALE"){Ze.add(c);let U=Promise.resolve().then(async()=>{let re=Date.now();try{let N=await t({addDebugData:y});a(N)&&(await p(N),d?.({result:N,cacheStatus:"PUT",overrideStartTime:re}));}catch(N){N.message&&(N.message="SWR in sub-request failed: "+N.message),console.error(N);}finally{Ze.delete(c);}});n?.(U);}return f}let g=await t({addDebugData:y});if(a(g)){let f=Promise.resolve().then(async()=>{await p(g);});n?.(f);}return g}function Ft(e,t){return [e,{status:t.status,statusText:t.statusText,headers:Array.from(t.headers.entries())}]}function $t([e,t]){return [e,new Response(e,t)]}var qt=(e,t)=>!e?.errors&&t.status<400;async function Ht(e,t,{cacheInstance:r,cache:o,cacheKey:a=[e,t],shouldCacheResponse:n=()=>!0,waitUntil:i,returnType:u="json",debugInfo:c}={}){return !o&&(!t.method||t.method==="GET")&&(o=J()),xe(a,async()=>{let s=await fetch(e,t),l;try{l=await s[u]();}catch{try{l=await s.text();}catch{return Ft("",s)}}return Ft(l,s)},{cacheInstance:r,waitUntil:i,strategy:o??null,debugInfo:c,shouldCacheResult:s=>n(...$t(s))}).then($t)}var et="Custom-Storefront-Request-Group-ID",tt="X-Shopify-Storefront-Access-Token",rt="X-SDK-Variant",ot="X-SDK-Variant-Source",at="X-SDK-Version";function Qt(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`weak-${Math.random().toString(16).substring(2)}`}var Bt=new Set,Wt=e=>{Bt.has(e)||(console.warn(e),Bt.add(e));},Gt=new Set,nt=e=>{Gt.has(e)||(console.error(new Error(e)),Gt.add(e));};var he="2024.7.2";function ne(e){return e.replace(/\s*#.*$/gm,"").replace(/\s+/gm," ").trim()}var co=/(^|}\s)query[\s({]/im,uo=/(^|}\s)mutation[\s({]/im;function ke(e,t){if(!co.test(e))throw new Error(`[h2:error:${t}] Can only execute queries`)}function Le(e,t){if(!uo.test(e))throw new Error(`[h2:error:${t}] Can only execute mutations`)}var X=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+=`
|
|
15
15
|
`,this.stack&&(t+=`${this.stack.slice(this.stack.indexOf(`
|
|
16
16
|
`)+1)}
|
|
17
|
-
`),t}toJSON(){return {name:"Error",message:""}}};function
|
|
17
|
+
`),t}toJSON(){return {name:"Error",message:""}}};function ge({url:e,response:t,errors:r,type:o,query:a,queryVariables:n,ErrorConstructor:i=Error,client:u="storefront"}){let c=(typeof r=="string"?r:r?.map?.(l=>l.message).join(`
|
|
18
18
|
`))||`URL: ${e}
|
|
19
|
-
API response error: ${t.status}`,s=new
|
|
19
|
+
API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{errors:r},clientOperation:`${u}.${o}`,requestId:t.headers.get("x-request-id")});throw new i(s.message,{cause:s.cause})}function ie(e,t={}){let r=new Error,o=(a,n="Error")=>{let i=(r.stack??"").split(`
|
|
20
20
|
`).slice(3+(t.stackOffset??0)).join(`
|
|
21
|
-
`).replace(/ at loader(\d+) \(/,(u,c)=>u.replace(c,""));return `${
|
|
22
|
-
`+
|
|
21
|
+
`).replace(/ at loader(\d+) \(/,(u,c)=>u.replace(c,""));return `${n}: ${a}
|
|
22
|
+
`+i};return e.then(a=>{if(a?.errors&&Array.isArray(a.errors)){let n=typeof t.logErrors=="function"?t.logErrors:()=>t.logErrors??!1;a.errors.forEach(i=>{i&&(i.stack=o(i.message,i.name),n(i)&&console.error(i));});}return a}).catch(a=>{throw a&&(a.stack=o(a.message,a.name)),a})}var q=void 0;var ho={language:"EN",country:"US"};function Pi(e){let {storefrontHeaders:t,cache:r,waitUntil:o,i18n:a,storefrontId:n,logErrors:i=!0,...u}=e,{getPublicTokenHeaders:s,getPrivateTokenHeaders:l,getStorefrontApiUrl:y,getShopifyDomain:m}=hydrogenReact.createStorefrontClient(u),p=(u.privateStorefrontToken?l:s)({contentType:"json",buyerIp:t?.buyerIp||""});if(p[et]=t?.requestGroupId||Qt(),n&&(p[hydrogenReact.SHOPIFY_STOREFRONT_ID_HEADER]=n),(p["user-agent"]=`Hydrogen ${he}`),t&&t.cookie){let f=hydrogenReact.getShopifyCookies(t.cookie??"");f[hydrogenReact.SHOPIFY_Y]&&(p[hydrogenReact.SHOPIFY_STOREFRONT_Y_HEADER]=f[hydrogenReact.SHOPIFY_Y]),f[hydrogenReact.SHOPIFY_S]&&(p[hydrogenReact.SHOPIFY_STOREFRONT_S_HEADER]=f[hydrogenReact.SHOPIFY_S]);}let h=JSON.stringify({"content-type":p["content-type"],"user-agent":p["user-agent"],[rt]:p[rt],[ot]:p[ot],[at]:p[at],[tt]:p[tt]});async function g({query:f,mutation:v,variables:I,cache:_,headers:U=[],storefrontApiVersion:re,displayName:N,stackInfo:Re}){let C=U instanceof Headers?Object.fromEntries(U.entries()):Array.isArray(U)?Object.fromEntries(U):U,P=f??v,A={...I};a&&(!I?.country&&/\$country/.test(P)&&(A.country=a.country),!I?.language&&/\$language/.test(P)&&(A.language=a.language));let T=y({storefrontApiVersion:re}),M=JSON.stringify({query:P,variables:A}),F={method:"POST",headers:{...p,...C},body:M},D=[T,F.method,h,F.body],[x,k]=await Ht(T,F,{cacheInstance:v?void 0:r,cache:_||ae(),cacheKey:D,shouldCacheResponse:qt,waitUntil:o,debugInfo:{requestId:F.headers[et],displayName:N,url:T,stackInfo:Re,graphql:M,purpose:t?.purpose}}),R={url:T,response:k,type:v?"mutation":"query",query:P,queryVariables:A,errors:void 0};if(!k.ok){let $;try{$=Y(x);}catch{$=[{message:x}];}ge({...R,errors:$});}let{data:W,errors:le}=x,oe=le?.map(({message:$,...ye})=>new X($,{...ye,clientOperation:`storefront.${R.type}`,requestId:k.headers.get("x-request-id"),queryVariables:A,query:P}));return S(W,oe)}return {storefront:{query(f,v){f=ne(f),ke(f,"storefront.query");let I=zt?.(f);return ie(g({...v,query:f,stackInfo:q?.(I)}),{stackOffset:I,logErrors:i})},mutate(f,v){f=ne(f),Le(f,"storefront.mutate");let I=zt?.(f);return ie(g({...v,mutation:f,stackInfo:q?.(I)}),{stackOffset:I,logErrors:i})},cache:r,CacheNone:Ke,CacheLong:Je,CacheShort:J,CacheCustom:Ye,generateCacheControlHeader:fe,getPublicTokenHeaders:s,getPrivateTokenHeaders:l,getShopifyDomain:m,getApiUrl:y,i18n:a??ho}}}var zt=void 0;function S(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 Z(e){return {requestId:e?_e(e,"request-id"):void 0,purpose:e?_e(e,"purpose"):void 0}}function go({cache:e,waitUntil:t,request:r}){return function(a,n,i){return xe(a,i,{strategy:n,cacheInstance:e,waitUntil:t,debugInfo:{...Z(r),stackInfo:q?.()}})}}var it=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,...n}=r,i=new Headers(n.headers),u=i.get("cache-control")||i.get("real-cache-control")||"",c=parseInt(u.match(/max-age=(\d+)/)?.[1]||"0",10),s=parseInt(u.match(/stale-while-revalidate=(\d+)/)?.[1]||"0",10),l=(Date.now()-a)/1e3;if(l>c+s){this.#e.delete(t.url);return}let m=l>c;return i.set("cache",m?"STALE":"HIT"),i.set("date",new Date(a).toUTCString()),new Response(o,{status:n.status??200,headers:i})}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 Ue(e){if(!e)return;let{pathname:t,search:r}=new URL(e),o=t+r,a=new URLSearchParams(r),n=a.get("return_to")||a.get("redirect");if(n){if(Yt(e,n))return n;console.warn(`Cross-domain redirects are not supported. Tried to redirect from ${o} to ${n}`);}}function Yt(e,t){try{return new URL(e).origin===new URL(t,e).origin}catch{return !1}}function st({requestUrl:e,defaultUrl:t,redirectUrl:r}){let o=e,a=Jt(e,t),n=r?Jt(e,r):a;return Yt(e,n.toString())?n.toString():(console.warn(`Cross-domain redirects are not supported. Tried to redirect from ${o} to ${n}. Default url ${a} is used instead.`),a.toString())}function Jt(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 Po(e){let{storefront:t,request:r,noAdminRedirect:o,matchQueryParams:a,response:n=new Response("Not Found",{status:404})}=e,i=new URL(r.url),{pathname:u,searchParams:c}=i,s=c.has("_data");c.delete("redirect"),c.delete("return_to"),c.delete("_data");let l=(a?i.toString().replace(i.origin,""):u).toLowerCase();if(i.pathname==="/admin"&&!o)return ut(`${t.getShopifyDomain()}/admin`,s,c,a);try{let{urlRedirects:y}=await t.query(So,{variables:{query:"path:"+l.replace(/\/+$/,"")}}),m=y?.edges?.[0]?.node?.target;if(m)return ut(m,s,c,a);let d=Ue(r.url);if(d)return ut(d,s,c,a)}catch(y){console.error(`Failed to fetch redirects from Storefront API for route ${l}`,y);}return n}var ct="https://example.com";function ut(e,t,r,o){let a=new URL(e,ct);if(!o)for(let[n,i]of r)a.searchParams.append(n,i);return t?new Response(null,{status:200,headers:{"X-Remix-Redirect":a.toString().replace(ct,""),"X-Remix-Status":"301"}}):new Response(null,{status:301,headers:{location:a.toString().replace(ct,"")}})}var So=`#graphql
|
|
23
23
|
query redirects($query: String) {
|
|
24
24
|
urlRedirects(first: 1, query: $query) {
|
|
25
25
|
edges {
|
|
@@ -29,7 +29,7 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
`;var
|
|
32
|
+
`;var Ao=async function({request:t,context:r}){let o=r.storefront,a=r.customerAccount,n=new URL(t.url);if(!o)throw new Error("GraphiQL: Hydrogen's storefront client must be injected in the loader context.");let i={};if(o){let s="X-Shopify-Storefront-Access-Token";i.storefront={name:"Storefront API",authHeader:s,accessToken:o.getPublicTokenHeaders()[s],apiUrl:o.getApiUrl(),icon:"SF"};}if(a){let s=await(await fetch(n.origin+"/graphiql/customer-account.schema.json")).json(),l=await a.getAccessToken();s&&(i["customer-account"]={name:"Customer Account API",value:s,authHeader:"Authorization",accessToken:l,apiUrl:a.getApiUrl(),icon:"CA"});}let u="https://avatars.githubusercontent.com/u/12972006?s=48&v=4",c=String.raw;return new Response(c`
|
|
33
33
|
<!DOCTYPE html>
|
|
34
34
|
<html lang="en">
|
|
35
35
|
<head>
|
|
@@ -124,7 +124,7 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
124
124
|
variables = JSON.stringify(JSON.parse(variables), null, 2);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
const schemas = ${JSON.stringify(
|
|
127
|
+
const schemas = ${JSON.stringify(i)};
|
|
128
128
|
let lastActiveTabIndex = -1;
|
|
129
129
|
let lastTabAmount = -1;
|
|
130
130
|
|
|
@@ -295,13 +295,13 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
295
295
|
</script>
|
|
296
296
|
</body>
|
|
297
297
|
</html>
|
|
298
|
-
`,{status:200,headers:{"content-type":"text/html"}})};var Po={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},Ao=/[&><\u2028\u2029]/g;function Zt(e){return e.replace(Ao,t=>Po[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 er(e){let t=[];for(let r of Object.keys(e))switch(r){case"title":{let o=Q(H.title,e.title),a=pt(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 i=o.split("?")[0].replace(/\/$/,"");t.push(x("link",{rel:"canonical",href:i}),x("meta",{property:"og:url",content:i}));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=W(e.media);for(let i of a)if(typeof i=="string"&&t.push(x("meta",{name:"og:image",content:i})),i&&typeof i=="object"){let n=i.type||"image",u=i?{url:i?.url,secure_url:i?.url,type:dt(i.url),width:i?.width,height:i?.height,alt:i?.altText}:{};for(let c of Object.keys(u))u[c]&&(o=u[c],t.push(x("meta",{property:`og:${n}:${c}`,content:o},u.url)));}break}case"jsonLd":{let o=W(e.jsonLd),a=0;for(let i of o){if(typeof i!="object")continue;let n=x("script",{type:"application/ld+json",children:JSON.stringify(i,(u,c)=>typeof c=="string"?Zt(c):c)},`json-ld-${i?.["@type"]||i?.name||a++}`);t.push(n);}break}case"alternates":{let o=W(e.alternates);for(let a of o){if(!a)continue;let{language:i,url:n,default:u}=a,c=i?`${i}${u?"-default":""}`:void 0;t.push(x("link",{rel:"alternate",hrefLang:c,href:n}));}break}case"robots":{if(!e.robots)break;let{maxImagePreview:o,maxSnippet:a,maxVideoPreview:i,noArchive:n,noFollow:u,noImageIndex:c,noIndex:s,noSnippet:l,noTranslate:y,unavailableAfter:m}=e.robots,p=[n&&"noarchive",c&&"noimageindex",l&&"nosnippet",y&&"notranslate",o&&`max-image-preview:${o}`,a&&`max-snippet:${a}`,i&&`max-video-preview:${i}`,m&&`unavailable_after:${m}`],d=(s?"noindex":"index")+","+(u?"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=ut(o),o):e==="script"?(o.children=typeof t.children=="string"?t.children:"",o.key=ut(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=ut(o,r),o)}function ut(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(i=>i).join("-").replace(/\s+/g,"-"):r==="script"?`${r}-${t}`:`${r}-${o.type}`}function pt(e,t){if(t)return e?typeof e=="function"?e(t):e.replace("%s",t??""):t}function dt(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 W(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 Do=react.lazy(()=>Promise.resolve().then(()=>(ar(),or)));function Oo({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:u,...c}=n,s={...c,...r},l=u?.seo,y=c?.data?.seo;return !l&&!y?[]:l?Ne(l,s):[y]}).reduce((n,u)=>{Object.keys(u).forEach(s=>!u[s]&&delete u[s]);let{jsonLd:c}=u;return c?n?.jsonLd?Array.isArray(c)?{...n,...u,jsonLd:[...n.jsonLd,...c]}:{...n,...u,jsonLd:[...n.jsonLd,c]}:{...n,...u,jsonLd:[c]}:{...n,...u}},{}),[t,r]),{html:a,loggerMarkup:i}=react.useMemo(()=>{let n=er(o),u=n.map(s=>s.tag==="script"?react.createElement(s.tag,{...s.props,key:s.key,dangerouslySetInnerHTML:{__html:s.children}}):react.createElement(s.tag,{...s.props,key:s.key},s.children)),c=react.createElement(react.Suspense,{fallback:null},react.createElement(Do,{headTags:n}));return {html:u,loggerMarkup:c}},[o]);return react.createElement(react.Fragment,null,a,e&&i)}function Ne(e,...t){if(e instanceof Function)return Ne(e(...t),...t);let r={};return Array.isArray(e)?(r=e.reduce((o,a)=>[...o,Ne(a)],[]),r):e instanceof Object?(Object.entries(e).forEach(([a,i])=>{r[a]=Ne(i,...t);}),r):e}function ko(...e){let t=[],r=e.reduce((o,a)=>{if(!a)return o;Object.keys(a).forEach(n=>!a[n]&&delete a[n]);let{jsonLd:i}=a;return i?o?.jsonLd?{...o,...a,jsonLd:W(o.jsonLd).concat(i)}:{...o,...a,jsonLd:[i]}:{...o,...a}},{})||{};for(let o of Object.keys(r))switch(o){case"title":{let a=Q(H.title,r.title),i=pt(r?.titleTemplate,a);if(!i)break;t.push({title:i},{property:"og:title",content:i},{property:"twitter:title",content:i});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,i=W(r.media);for(let n of i)if(typeof n=="string"&&t.push({property:"og:image",content:n}),n&&typeof n=="object"){let u=n.type||"image",c=n?{url:n?.url,secure_url:n?.url,type:dt(n.url),width:n?.width,height:n?.height,alt:n?.altText}:{};for(let s of Object.keys(c))c[s]&&(a=c[s],t.push({property:`og:${u}:${s}`,content:a}));}break}case"jsonLd":{let a=W(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=W(r.alternates);for(let i of a){if(!i)continue;let{language:n,url:u,default:c}=i,s=n?`${n}${c?"-default":""}`:void 0;t.push({tagName:"link",rel:"alternate",hrefLang:s,href:u});}break}case"robots":{if(!r.robots)break;let{maxImagePreview:a,maxSnippet:i,maxVideoPreview:n,noArchive:u,noFollow:c,noImageIndex:s,noIndex:l,noSnippet:y,noTranslate:m,unavailableAfter:p}=r.robots,d=[u&&"noarchive",s&&"noimageindex",y&&"nosnippet",m&&"notranslate",a&&`max-image-preview:${a}`,i&&`max-snippet:${i}`,n&&`max-video-preview:${n}`,p&&`unavailable_after:${p}`],g=(l?"noindex":"index")+","+(c?"nofollow":"follow");for(let h of d)h&&(g+=`,${h}`);t.push({name:"robots",content:g});break}}return t}function Mo({connection:e,children:t=()=>(console.warn("<Pagination> requires children to work properly"),null)}){let o=react$1.useNavigation().state==="loading",{endCursor:a,hasNextPage:i,hasPreviousPage:n,nextPageUrl:u,nodes:c,previousPageUrl:s,startCursor:l}=Vo(e),y=react.useMemo(()=>({pageInfo:{endCursor:a,hasPreviousPage:n,hasNextPage:i,startCursor:l},nodes:c}),[a,i,n,l,c]),m=react.useMemo(()=>react.forwardRef(function(g,h){return i?react.createElement(react$1.Link,{preventScrollReset:!0,...g,to:u,state:y,replace:!0,ref:h}):null}),[i,u,y]),p=react.useMemo(()=>react.forwardRef(function(g,h){return n?react.createElement(react$1.Link,{preventScrollReset:!0,...g,to:s,state:y,replace:!0,ref:h}):null}),[n,s,y]);return t({state:y,hasNextPage:i,hasPreviousPage:n,isLoading:o,nextPageUrl:u,nodes:c,previousPageUrl:s,NextLink:m,PreviousLink:p})}function Me(e){let t=new URLSearchParams(e);return t.delete("cursor"),t.delete("direction"),t.toString()}function Se(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 Vo(e){e.pageInfo||Se("pageInfo"),typeof e.pageInfo.startCursor>"u"&&Se("pageInfo.startCursor"),typeof e.pageInfo.endCursor>"u"&&Se("pageInfo.endCursor"),typeof e.pageInfo.hasNextPage>"u"&&Se("pageInfo.hasNextPage"),typeof e.pageInfo.hasPreviousPage>"u"&&Se("pageInfo.hasPreviousPage");let t=react$1.useNavigate(),{state:r,search:o,pathname:a}=react$1.useLocation(),u=new URLSearchParams(o).get("direction")==="previous",c=react.useMemo(()=>!globalThis?.window?.__hydrogenHydrated||!r||!r?.nodes?hydrogenReact.flattenConnection(e):u?[...hydrogenReact.flattenConnection(e),...r.nodes]:[...r.nodes,...hydrogenReact.flattenConnection(e)],[r,e]),s=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,h=!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&&(u?(d=e.pageInfo.startCursor,h=e.pageInfo.hasPreviousPage):(g=e.pageInfo.endCursor,f=e.pageInfo.hasNextPage)),{startCursor:d,endCursor:g,hasPreviousPage:h,hasNextPage:f}},[u,r,e.pageInfo.hasNextPage,e.pageInfo.hasPreviousPage,e.pageInfo.startCursor,e.pageInfo.endCursor]),l=react.useRef({params:Me(o),pathname:a});react.useEffect(()=>{window.__hydrogenHydrated=!0;},[]),react.useEffect(()=>{(Me(o)!==l.current.params||a!==l.current.pathname)&&(l.current={pathname:a,params:Me(o)},t(`${a}?${Me(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"),s.startCursor&&p.set("cursor",s.startCursor),`?${p.toString()}`},[o,s.startCursor]),m=react.useMemo(()=>{let p=new URLSearchParams(o);return p.set("direction","next"),s.endCursor&&p.set("cursor",s.endCursor),`?${p.toString()}`},[o,s.endCursor]);return {...s,previousPageUrl:y,nextPageUrl:m,nodes:c}}function Fo(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 U=class extends Response{constructor(t,r,o){super(`Bad request: ${t}`,{status:400,headers:o});}};function Ae(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:i}){let n=new URLSearchParams,u=e.get(E),c=u?.refreshToken,s=u?.idToken;if(!c)throw new U("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",c),n.append("client_id",t);let l={"content-type":"application/x-www-form-urlencoded","User-Agent":ne,Origin:o};new Date().getTime();let m=`${r}/auth/oauth/token`,p=await fetch(m,{method:"POST",headers:l,body:n});if(!p.ok){let b=await p.text();throw new Response(b,{status:p.status,headers:{"Content-Type":"text/html; charset=utf-8"}})}let{access_token:d,expires_in:g,refresh_token:h}=await p.json(),f=await ft(d,t,r,o);e.set(E,{accessToken:f,expiresAt:new Date(new Date().getTime()+(g-120)*1e3).getTime()+"",refreshToken:h,idToken:s}),await i();}function ue(e){e.unset(E),e.unset(ie);}async function pr({locks:e,expiresAt:t,session:r,customerAccountId:o,customerAccountUrl:a,httpsOrigin:i,debugInfo:n,exchangeForStorefrontCustomerAccessToken:u}){if(parseInt(t,10)-1e3<new Date().getTime())try{e.refresh||(e.refresh=$o({session:r,customerAccountId:o,customerAccountUrl:a,httpsOrigin:i,debugInfo:n,exchangeForStorefrontCustomerAccessToken:u})),await e.refresh,delete e.refresh;}catch(c){throw ue(r),c&&c.status!==401?c:new U("Unauthorized","Login before querying the Customer Account API.",{"Set-Cookie":await r.commit()})}}function dr(){let e=qo();return yr(e)}async function lr(e){let t=await crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(e)),r=Ho(t);return yr(r)}function qo(){let e=new Uint8Array(32);return crypto.getRandomValues(e),String.fromCharCode.apply(null,Array.from(e))}function yr(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Ho(e){let t=new Uint8Array(e),r=Array.from(t);return String.fromCharCode(...r)}function fr(){let e=Date.now().toString(),t=Math.random().toString(36).substring(2);return e+t}async function ft(e,t,r,o,a){let i=t;if(!e)throw new U("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",i),n.append("audience",Qt),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 u={"content-type":"application/x-www-form-urlencoded","User-Agent":ne,Origin:o};new Date().getTime();let s=`${r}/auth/oauth/token`,l=await fetch(s,{method:"POST",headers:u,body:n});let y=await l.json();if(y.error)throw new U(y.error_description);return y.access_token}function mr(e){return Qo(e).payload.nonce}function Qo(e){let[t,r,o]=e.split("."),a=JSON.parse(atob(t)),i=JSON.parse(atob(r));return {header:a,payload:i,signature:o}}function Ve(){return Bo(Go())}function Go(){try{return crypto.getRandomValues(new Uint8Array(16))}catch{return new Uint8Array(16).map(()=>Math.random()*255|0)}}function Bo(e){return Array.from(e,function(t){return ("0"+(t&255).toString(16)).slice(-2)}).join("")}var gr="/account/login",Wo="/account/authorize",hr="/account";function jo(e){if(!e.url)return gr;let{pathname:t}=new URL(e.url),r=gr+`?${new URLSearchParams({return_to:t}).toString()}`;return Ae(r)}function Ko({session:e,customerAccountId:t,customerAccountUrl:r,customerApiVersion:o=Oe,request:a,waitUntil:i,authUrl:n,customAuthStatusHandler:u,logErrors:c=!0,unstableB2b:s=!1}){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 l=u||(()=>jo(a)),y=new URL(a.url),m=y.protocol==="http:"?y.origin.replace("http","https"):y.origin,p=it({requestUrl:m,defaultUrl:Wo,redirectUrl:n}),d=`${r}/account/customer/api/${o}/graphql`,g={};async function h({query:C,type:S,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":ne,Origin:m,Authorization:T},body:JSON.stringify({query:C,variables:A})});let O=await D.text(),k={url:d,response:D,type:S,query:C,queryVariables:A,errors:void 0,client:"customer"};if(!D.ok){if(D.status===401){ue(e);let _=l();throw _ instanceof Response&&_.headers.set("Set-Cookie",await e.commit()),_}let R;try{R=K(O);}catch{R=[{message:O}];}he({...k,errors:R});}try{let R=K(O),{errors:_}=R,le=_?.map(({message:re,...$})=>new z(re,{...$,clientOperation:`customerAccount.${k.type}`,requestId:D.headers.get("x-request-id"),queryVariables:A,query:C}));return {...R,..._&&{errors:le}}}catch{he({...k,errors:[{message:O}]});}}async function f(){if(!r||!t)return !1;let C=e.get(E),S=C?.accessToken,A=C?.expiresAt;if(!S||!A)return !1;let T=q?.();try{await pr({locks:g,expiresAt:A,session:e,customerAccountId:t,customerAccountUrl:r,httpsOrigin:m,debugInfo:{waitUntil:i,stackInfo:T,...J(a)},exchangeForStorefrontCustomerAccessToken:Re});}catch{return !1}return !0}async function b(){if(!await f())throw l()}async function v(){if(await f())return e.get(E)?.accessToken}async function N(C,S){return Te(r,t),C=se(C),Le(C,"customer.mutate"),ce(h({query:C,type:"mutation",...S}),{logErrors:c})}async function F(C,S){return Te(r,t),C=se(C),ke(C,"customer.query"),ce(h({query:C,type:"query",...S}),{logErrors:c})}function te(C){e.set(ie,{...e.get(ie),...C});}async function L(){if(await f())return e.get(ie)}async function Re(){if(!s)return;let C=`#graphql
|
|
298
|
+
`,{status:200,headers:{"content-type":"text/html"}})};var To={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},vo=/[&><\u2028\u2029]/g;function Xt(e){return e.replace(vo,t=>To[t])}var j="Error in SEO input: ",H={title:{validate:e=>{if(typeof e!="string")throw new Error(j.concat("`title` should be a string"));if(typeof e=="string"&&e.length>120)throw new Error(j.concat("`title` should not be longer than 120 characters"));return e}},description:{validate:e=>{if(typeof e!="string")throw new Error(j.concat("`description` should be a string"));if(typeof e=="string"&&e.length>155)throw new Error(j.concat("`description` should not be longer than 155 characters"));return e}},url:{validate:e=>{if(typeof e!="string")throw new Error(j.concat("`url` should be a string"));if(typeof e=="string"&&!e.startsWith("http"))throw new Error(j.concat("`url` should be a valid URL"));return e}},handle:{validate:e=>{if(typeof e!="string")throw new Error(j.concat("`handle` should be a string"));if(typeof e=="string"&&!e.startsWith("@"))throw new Error(j.concat("`handle` should start with `@`"));return e}}};function Zt(e){let t=[];for(let r of Object.keys(e))switch(r){case"title":{let o=Q(H.title,e.title),a=dt(e?.titleTemplate,o);if(!a)break;t.push(E("title",{title:a}),E("meta",{property:"og:title",content:a}),E("meta",{name:"twitter:title",content:a}));break}case"description":{let o=Q(H.description,e.description);if(!o)break;t.push(E("meta",{name:"description",content:o}),E("meta",{property:"og:description",content:o}),E("meta",{name:"twitter:description",content:o}));break}case"url":{let o=Q(H.url,e.url);if(!o)break;let n=o.split("?")[0].replace(/\/$/,"");t.push(E("link",{rel:"canonical",href:n}),E("meta",{property:"og:url",content:n}));break}case"handle":{let o=Q(H.handle,e.handle);if(!o)break;t.push(E("meta",{name:"twitter:site",content:o}),E("meta",{name:"twitter:creator",content:o}));break}case"media":{let o,a=K(e.media);for(let n of a)if(typeof n=="string"&&t.push(E("meta",{name:"og:image",content:n})),n&&typeof n=="object"){let i=n.type||"image",u=n?{url:n?.url,secure_url:n?.url,type:lt(n.url),width:n?.width,height:n?.height,alt:n?.altText}:{};for(let c of Object.keys(u))u[c]&&(o=u[c],t.push(E("meta",{property:`og:${i}:${c}`,content:o},u.url)));}break}case"jsonLd":{let o=K(e.jsonLd),a=0;for(let n of o){if(typeof n!="object")continue;let i=E("script",{type:"application/ld+json",children:JSON.stringify(n,(u,c)=>typeof c=="string"?Xt(c):c)},`json-ld-${n?.["@type"]||n?.name||a++}`);t.push(i);}break}case"alternates":{let o=K(e.alternates);for(let a of o){if(!a)continue;let{language:n,url:i,default:u}=a,c=n?`${n}${u?"-default":""}`:void 0;t.push(E("link",{rel:"alternate",hrefLang:c,href:i}));}break}case"robots":{if(!e.robots)break;let{maxImagePreview:o,maxSnippet:a,maxVideoPreview:n,noArchive:i,noFollow:u,noImageIndex:c,noIndex:s,noSnippet:l,noTranslate:y,unavailableAfter:m}=e.robots,d=[i&&"noarchive",c&&"noimageindex",l&&"nosnippet",y&&"notranslate",o&&`max-image-preview:${o}`,a&&`max-snippet:${a}`,n&&`max-video-preview:${n}`,m&&`unavailable_after:${m}`],p=(s?"noindex":"index")+","+(u?"nofollow":"follow");for(let h of d)h&&(p+=`,${h}`);t.push(E("meta",{name:"robots",content:p}));break}}return t.flat().sort((r,o)=>r.key.localeCompare(o.key))}function E(e,t,r){let o={tag:e,props:{},key:""};return e==="title"?(o.children=t.title,o.key=pt(o),o):e==="script"?(o.children=typeof t.children=="string"?t.children:"",o.key=pt(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=pt(o,r),o)}function pt(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(i=>i).join("-")}return r==="link"?[r,o.rel,o.hrefLang||o.media].filter(n=>n).join("-").replace(/\s+/g,"-"):r==="script"?`${r}-${t}`:`${r}-${o.type}`}function dt(e,t){if(t)return e?typeof e=="function"?e(t):e.replace("%s",t??""):t}function lt(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 K(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 ko=react.lazy(()=>Promise.resolve().then(()=>(or(),rr)));function Lo({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(i=>{let{handle:u,...c}=i,s={...c,...r},l=u?.seo,y=c?.data?.seo;return !l&&!y?[]:l?Ne(l,s):[y]}).reduce((i,u)=>{Object.keys(u).forEach(s=>!u[s]&&delete u[s]);let{jsonLd:c}=u;return c?i?.jsonLd?Array.isArray(c)?{...i,...u,jsonLd:[...i.jsonLd,...c]}:{...i,...u,jsonLd:[...i.jsonLd,c]}:{...i,...u,jsonLd:[c]}:{...i,...u}},{}),[t,r]),{html:a,loggerMarkup:n}=react.useMemo(()=>{let i=Zt(o),u=i.map(s=>s.tag==="script"?react.createElement(s.tag,{...s.props,key:s.key,dangerouslySetInnerHTML:{__html:s.children}}):react.createElement(s.tag,{...s.props,key:s.key},s.children)),c=react.createElement(react.Suspense,{fallback:null},react.createElement(ko,{headTags:i}));return {html:u,loggerMarkup:c}},[o]);return react.createElement(react.Fragment,null,a,e&&n)}function Ne(e,...t){if(e instanceof Function)return Ne(e(...t),...t);let r={};return Array.isArray(e)?(r=e.reduce((o,a)=>[...o,Ne(a)],[]),r):e instanceof Object?(Object.entries(e).forEach(([a,n])=>{r[a]=Ne(n,...t);}),r):e}function _o(...e){let t=[],r=e.reduce((o,a)=>{if(!a)return o;Object.keys(a).forEach(i=>!a[i]&&delete a[i]);let{jsonLd:n}=a;return n?o?.jsonLd?{...o,...a,jsonLd:K(o.jsonLd).concat(n)}:{...o,...a,jsonLd:[n]}:{...o,...a}},{})||{};for(let o of Object.keys(r))switch(o){case"title":{let a=Q(H.title,r.title),n=dt(r?.titleTemplate,a);if(!n)break;t.push({title:n},{property:"og:title",content:n},{property:"twitter:title",content:n});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 i=a.split("?")[0].replace(/\/$/,"");t.push({tagName:"link",rel:"canonical",href:i},{property:"og:url",content:i});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,n=K(r.media);for(let i of n)if(typeof i=="string"&&t.push({property:"og:image",content:i}),i&&typeof i=="object"){let u=i.type||"image",c=i?{url:i?.url,secure_url:i?.url,type:lt(i.url),width:i?.width,height:i?.height,alt:i?.altText}:{};for(let s of Object.keys(c))c[s]&&(a=c[s],t.push({property:`og:${u}:${s}`,content:a}));}break}case"jsonLd":{let a=K(r.jsonLd);for(let i of a)typeof i!="object"||Object.keys(i).length===0||t.push({"script:ld+json":i});break}case"alternates":{let a=K(r.alternates);for(let n of a){if(!n)continue;let{language:i,url:u,default:c}=n,s=i?`${i}${c?"-default":""}`:void 0;t.push({tagName:"link",rel:"alternate",hrefLang:s,href:u});}break}case"robots":{if(!r.robots)break;let{maxImagePreview:a,maxSnippet:n,maxVideoPreview:i,noArchive:u,noFollow:c,noImageIndex:s,noIndex:l,noSnippet:y,noTranslate:m,unavailableAfter:d}=r.robots,p=[u&&"noarchive",s&&"noimageindex",y&&"nosnippet",m&&"notranslate",a&&`max-image-preview:${a}`,n&&`max-snippet:${n}`,i&&`max-video-preview:${i}`,d&&`unavailable_after:${d}`],h=(l?"noindex":"index")+","+(c?"nofollow":"follow");for(let g of p)g&&(h+=`,${g}`);t.push({name:"robots",content:h});break}}return t}function Fo({connection:e,children:t=()=>(console.warn("<Pagination> requires children to work properly"),null)}){let o=react$1.useNavigation().state==="loading",{endCursor:a,hasNextPage:n,hasPreviousPage:i,nextPageUrl:u,nodes:c,previousPageUrl:s,startCursor:l}=$o(e),y=react.useMemo(()=>({pageInfo:{endCursor:a,hasPreviousPage:i,hasNextPage:n,startCursor:l},nodes:c}),[a,n,i,l,c]),m=react.useMemo(()=>react.forwardRef(function(h,g){return n?react.createElement(react$1.Link,{preventScrollReset:!0,...h,to:u,state:y,replace:!0,ref:g}):null}),[n,u,y]),d=react.useMemo(()=>react.forwardRef(function(h,g){return i?react.createElement(react$1.Link,{preventScrollReset:!0,...h,to:s,state:y,replace:!0,ref:g}):null}),[i,s,y]);return t({state:y,hasNextPage:n,hasPreviousPage:i,isLoading:o,nextPageUrl:u,nodes:c,previousPageUrl:s,NextLink:m,PreviousLink:d})}function Ve(e){let t=new URLSearchParams(e);return t.delete("cursor"),t.delete("direction"),t.toString()}function Pe(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 $o(e){e.pageInfo||Pe("pageInfo"),typeof e.pageInfo.startCursor>"u"&&Pe("pageInfo.startCursor"),typeof e.pageInfo.endCursor>"u"&&Pe("pageInfo.endCursor"),typeof e.pageInfo.hasNextPage>"u"&&Pe("pageInfo.hasNextPage"),typeof e.pageInfo.hasPreviousPage>"u"&&Pe("pageInfo.hasPreviousPage");let t=react$1.useNavigate(),{state:r,search:o,pathname:a}=react$1.useLocation(),u=new URLSearchParams(o).get("direction")==="previous",c=react.useMemo(()=>!globalThis?.window?.__hydrogenHydrated||!r||!r?.nodes?hydrogenReact.flattenConnection(e):u?[...hydrogenReact.flattenConnection(e),...r.nodes]:[...r.nodes,...hydrogenReact.flattenConnection(e)],[r,e]),s=react.useMemo(()=>{let d=globalThis?.window?.__hydrogenHydrated,p=!d||r?.pageInfo?.startCursor===void 0?e.pageInfo.startCursor:r.pageInfo.startCursor,h=!d||r?.pageInfo?.endCursor===void 0?e.pageInfo.endCursor:r.pageInfo.endCursor,g=!d||r?.pageInfo?.hasPreviousPage===void 0?e.pageInfo.hasPreviousPage:r.pageInfo.hasPreviousPage,f=!d||r?.pageInfo?.hasNextPage===void 0?e.pageInfo.hasNextPage:r.pageInfo.hasNextPage;return r?.nodes&&(u?(p=e.pageInfo.startCursor,g=e.pageInfo.hasPreviousPage):(h=e.pageInfo.endCursor,f=e.pageInfo.hasNextPage)),{startCursor:p,endCursor:h,hasPreviousPage:g,hasNextPage:f}},[u,r,e.pageInfo.hasNextPage,e.pageInfo.hasPreviousPage,e.pageInfo.startCursor,e.pageInfo.endCursor]),l=react.useRef({params:Ve(o),pathname:a});react.useEffect(()=>{window.__hydrogenHydrated=!0;},[]),react.useEffect(()=>{(Ve(o)!==l.current.params||a!==l.current.pathname)&&(l.current={pathname:a,params:Ve(o)},t(`${a}?${Ve(o)}`,{replace:!0,preventScrollReset:!0,state:{nodes:void 0,pageInfo:void 0}}));},[a,o]);let y=react.useMemo(()=>{let d=new URLSearchParams(o);return d.set("direction","previous"),s.startCursor&&d.set("cursor",s.startCursor),`?${d.toString()}`},[o,s.startCursor]),m=react.useMemo(()=>{let d=new URLSearchParams(o);return d.set("direction","next"),s.endCursor&&d.set("cursor",s.endCursor),`?${d.toString()}`},[o,s.endCursor]);return {...s,previousPageUrl:y,nextPageUrl:m,nodes:c}}function qo(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 Me="2024-07",se=`Shopify Hydrogen ${he}`,ur="30243aa5-17c1-465a-8493-944bcc4e88aa",O="customerAccount",ce="buyer";var V=class extends Response{constructor(t,r,o){super(`Bad request: ${t}`,{status:400,headers:o});}};function Ae(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 Ho({session:e,customerAccountId:t,customerAccountUrl:r,httpsOrigin:o,debugInfo:a,exchangeForStorefrontCustomerAccessToken:n}){let i=new URLSearchParams,u=e.get(O),c=u?.refreshToken,s=u?.idToken;if(!c)throw new V("Unauthorized","No refreshToken found in the session. Make sure your session is configured correctly and passed to `createCustomerAccountClient`.");i.append("grant_type","refresh_token"),i.append("refresh_token",c),i.append("client_id",t);let l={"content-type":"application/x-www-form-urlencoded","User-Agent":se,Origin:o};new Date().getTime();let m=`${r}/auth/oauth/token`,d=await fetch(m,{method:"POST",headers:l,body:i});if(!d.ok){let v=await d.text();throw new Response(v,{status:d.status,headers:{"Content-Type":"text/html; charset=utf-8"}})}let{access_token:p,expires_in:h,refresh_token:g}=await d.json(),f=await mt(p,t,r,o);e.set(O,{accessToken:f,expiresAt:new Date(new Date().getTime()+(h-120)*1e3).getTime()+"",refreshToken:g,idToken:s}),await n();}function ue(e){e.unset(O),e.unset(ce);}async function pr({locks:e,expiresAt:t,session:r,customerAccountId:o,customerAccountUrl:a,httpsOrigin:n,debugInfo:i,exchangeForStorefrontCustomerAccessToken:u}){if(parseInt(t,10)-1e3<new Date().getTime())try{e.refresh||(e.refresh=Ho({session:r,customerAccountId:o,customerAccountUrl:a,httpsOrigin:n,debugInfo:i,exchangeForStorefrontCustomerAccessToken:u})),await e.refresh,delete e.refresh;}catch(c){throw ue(r),c&&c.status!==401?c:new V("Unauthorized","Login before querying the Customer Account API.")}}function dr(){let e=Qo();return yr(e)}async function lr(e){let t=await crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(e)),r=Bo(t);return yr(r)}function Qo(){let e=new Uint8Array(32);return crypto.getRandomValues(e),String.fromCharCode.apply(null,Array.from(e))}function yr(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Bo(e){let t=new Uint8Array(e),r=Array.from(t);return String.fromCharCode(...r)}function fr(){let e=Date.now().toString(),t=Math.random().toString(36).substring(2);return e+t}async function mt(e,t,r,o,a){let n=t;if(!e)throw new V("Unauthorized","oAuth access token was not provided during token exchange.");let i=new URLSearchParams;i.append("grant_type","urn:ietf:params:oauth:grant-type:token-exchange"),i.append("client_id",n),i.append("audience",ur),i.append("subject_token",e),i.append("subject_token_type","urn:ietf:params:oauth:token-type:access_token"),i.append("scopes","https://api.customers.com/auth/customer.graphql");let u={"content-type":"application/x-www-form-urlencoded","User-Agent":se,Origin:o};new Date().getTime();let s=`${r}/auth/oauth/token`,l=await fetch(s,{method:"POST",headers:u,body:i});let y=await l.json();if(y.error)throw new V(y.error_description);return y.access_token}function mr(e){return Go(e).payload.nonce}function Go(e){let[t,r,o]=e.split("."),a=JSON.parse(atob(t)),n=JSON.parse(atob(r));return {header:a,payload:n,signature:o}}function Fe(){return jo(Wo())}function Wo(){try{return crypto.getRandomValues(new Uint8Array(16))}catch{return new Uint8Array(16).map(()=>Math.random()*255|0)}}function jo(e){return Array.from(e,function(t){return ("0"+(t&255).toString(16)).slice(-2)}).join("")}var hr="/account/login",Ko="/account/authorize",gr="/account";function zo(e){if(!e.url)return hr;let{pathname:t}=new URL(e.url),r=hr+`?${new URLSearchParams({return_to:t}).toString()}`;return Ae(r)}function Jo({session:e,customerAccountId:t,customerAccountUrl:r,customerApiVersion:o=Me,request:a,waitUntil:n,authUrl:i,customAuthStatusHandler:u,logErrors:c=!0,unstableB2b:s=!1}){if(o!==Me&&console.warn(`[h2:warn:createCustomerAccountClient] You are using Customer Account API version ${o} when this version of Hydrogen was built for ${Me}.`),!a?.url)throw new Error("[h2:error:createCustomerAccountClient] The request object does not contain a URL.");let l=u||(()=>zo(a)),y=new URL(a.url),m=y.protocol==="http:"?y.origin.replace("http","https"):y.origin,d=st({requestUrl:m,defaultUrl:Ko,redirectUrl:i}),p=`${r}/account/customer/api/${o}/graphql`,h={};async function g({query:C,type:P,variables:A={}}){let T=await I();if(!T)throw l();new Date().getTime();let D=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":se,Origin:m,Authorization:T},body:JSON.stringify({query:C,variables:A})});let x=await D.text(),k={url:p,response:D,type:P,query:C,queryVariables:A,errors:void 0,client:"customer"};if(!D.ok){if(D.status===401)throw ue(e),l();let R;try{R=Y(x);}catch{R=[{message:x}];}ge({...k,errors:R});}try{let R=Y(x),{errors:W}=R,le=W?.map(({message:oe,...$})=>new X(oe,{...$,clientOperation:`customerAccount.${k.type}`,requestId:D.headers.get("x-request-id"),queryVariables:A,query:C}));return {...R,...W&&{errors:le}}}catch{ge({...k,errors:[{message:x}]});}}async function f(){if(!r||!t)return !1;let C=e.get(O),P=C?.accessToken,A=C?.expiresAt;if(!P||!A)return !1;let T=q?.();try{await pr({locks:h,expiresAt:A,session:e,customerAccountId:t,customerAccountUrl:r,httpsOrigin:m,debugInfo:{waitUntil:n,stackInfo:T,...Z(a)},exchangeForStorefrontCustomerAccessToken:Re});}catch{return !1}return !0}async function v(){if(!await f())throw l()}async function I(){if(await f())return e.get(O)?.accessToken}async function _(C,P){return Te(r,t),C=ne(C),Le(C,"customer.mutate"),ie(g({query:C,type:"mutation",...P}),{logErrors:c})}async function U(C,P){return Te(r,t),C=ne(C),ke(C,"customer.query"),ie(g({query:C,type:"query",...P}),{logErrors:c})}function re(C){e.set(ce,{...e.get(ce),...C});}async function N(){if(await f())return e.get(ce)}async function Re(){if(!s)return;let C=`#graphql
|
|
299
299
|
mutation storefrontCustomerAccessTokenCreate {
|
|
300
300
|
storefrontCustomerAccessTokenCreate {
|
|
301
301
|
customerAccessToken
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
|
-
`,{data:
|
|
304
|
+
`,{data:P}=await _(C),A=P?.storefrontCustomerAccessTokenCreate?.customerAccessToken;A&&re({customerAccessToken:A});}return {login:async C=>{Te(r,t);let P=new URL(`${r}/auth/oauth/authorize`),A=fr(),T=Fe();if(P.searchParams.set("client_id",t),P.searchParams.set("scope","openid email"),P.searchParams.append("response_type","code"),P.searchParams.append("redirect_uri",d),P.searchParams.set("scope","openid email https://api.customers.com/auth/customer.graphql"),P.searchParams.append("state",A),P.searchParams.append("nonce",T),C?.uiLocales){let[D,x]=C.uiLocales.split("-"),k=D.toLowerCase();x&&(k+=`-${x.toUpperCase()}`),P.searchParams.append("ui_locales",k);}let M=dr(),F=await lr(M);return e.set(O,{...e.get(O),codeVerifier:M,state:A,nonce:T,redirectPath:Ue(a.url)||_e(a,"Referer")||gr}),P.searchParams.append("code_challenge",F),P.searchParams.append("code_challenge_method","S256"),Ae(P.toString())},logout:async C=>{Te(r,t);let P=e.get(O)?.idToken,A=st({requestUrl:m,defaultUrl:m,redirectUrl:C?.postLogoutRedirectUri}),T=P?new URL(`${r}/auth/logout?${new URLSearchParams([["id_token_hint",P],["post_logout_redirect_uri",A]]).toString()}`).toString():A;return ue(e),Ae(T)},isLoggedIn:f,handleAuthStatus:v,getAccessToken:I,getApiUrl:()=>p,mutate:_,query:U,authorize:async()=>{Te(r,t);let C=y.searchParams.get("code"),P=y.searchParams.get("state");if(!C||!P)throw ue(e),new V("Unauthorized","No code or state parameter found in the redirect URL.");if(e.get(O)?.state!==P)throw ue(e),new V("Unauthorized","The session state does not match the state parameter. Make sure that the session is configured correctly and passed to `createCustomerAccountClient`.");let A=t,T=new URLSearchParams;T.append("grant_type","authorization_code"),T.append("client_id",A),T.append("redirect_uri",d),T.append("code",C);let M=e.get(O)?.codeVerifier;if(!M)throw new V("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 F={"content-type":"application/x-www-form-urlencoded","User-Agent":se,Origin:m},D=q?.();new Date().getTime();let k=`${r}/auth/oauth/token`,R=await fetch(k,{method:"POST",headers:F,body:T});if(!R.ok)throw new Response(await R.text(),{status:R.status,headers:{"Content-Type":"text/html; charset=utf-8"}});let{access_token:W,expires_in:le,id_token:oe,refresh_token:$}=await R.json(),ye=e.get(O)?.nonce,Lt=await mr(oe);if(ye!==Lt)throw new V("Unauthorized",`Returned nonce does not match: ${ye} !== ${Lt}`);let zr=await mt(W,t,r,m,{waitUntil:n,stackInfo:D,...Z(a)}),Jr=e.get(O)?.redirectPath;return e.set(O,{accessToken:zr,expiresAt:new Date(new Date().getTime()+(le-120)*1e3).getTime()+"",refreshToken:$,idToken:oe}),await Re(),Ae(Jr||gr)},UNSTABLE_setBuyer:re,UNSTABLE_getBuyer:N}}function Te(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 Yo="https://raw.githubusercontent.com/Shopify/hydrogen/main/docs/changelog.json";async function Xo({request:e,changelogUrl:t}){new URL(e.url).searchParams;return fetch(t||Yo)}var Cr="cartFormInput";function B({children:e,action:t,inputs:r,route:o,fetcherKey:a}){let n=react$1.useFetcher({key:a});return jsxRuntime.jsxs(n.Form,{action:o||"",method:"post",children:[(t||r)&&jsxRuntime.jsx("input",{type:"hidden",name:Cr,value:JSON.stringify({action:t,inputs:r})}),typeof e=="function"?e(n):e]})}B.INPUT_NAME=Cr;B.ACTIONS={AttributesUpdateInput:"AttributesUpdateInput",BuyerIdentityUpdate:"BuyerIdentityUpdate",Create:"Create",DiscountCodesUpdate:"DiscountCodesUpdate",LinesAdd:"LinesAdd",LinesRemove:"LinesRemove",LinesUpdate:"LinesUpdate",NoteUpdate:"NoteUpdate",SelectedDeliveryOptionsUpdate:"SelectedDeliveryOptionsUpdate",MetafieldsSet:"MetafieldsSet",MetafieldDelete:"MetafieldDelete"};function ea(e){let t={};for(let i of e.entries()){let u=i[0],c=e.getAll(u);t[u]=c.length>1?c:i[1];}let{cartFormInput:r,...o}=t,{action:a,inputs:n}=r?JSON.parse(String(r)):{};return {action:a,inputs:{...n,...o}}}B.getFormInput=ea;var b=`#graphql
|
|
305
305
|
fragment CartApiError on CartUserError {
|
|
306
306
|
message
|
|
307
307
|
field
|
|
@@ -312,7 +312,7 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
312
312
|
id
|
|
313
313
|
totalQuantity
|
|
314
314
|
}
|
|
315
|
-
`;function
|
|
315
|
+
`;function ht(e){return async(t,r)=>{let o=e.customerAccount?await e.customerAccount.UNSTABLE_getBuyer():void 0,{cartId:a,...n}=r||{},{buyerIdentity:i,...u}=t,{cartCreate:c,errors:s}=await e.storefront.mutate(oa(e.cartFragment),{variables:{input:{...u,buyerIdentity:{...o,...i}},...n}});return S(c,s)}}var oa=(e=w)=>`#graphql
|
|
316
316
|
mutation cartCreate(
|
|
317
317
|
$input: CartInput!
|
|
318
318
|
$country: CountryCode = ZZ
|
|
@@ -329,8 +329,8 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
${e}
|
|
332
|
-
${
|
|
333
|
-
`;function gt({storefront:e,customerAccount:t,getCartId:r,cartFragment:o}){return async a=>{let
|
|
332
|
+
${b}
|
|
333
|
+
`;function gt({storefront:e,customerAccount:t,getCartId:r,cartFragment:o}){return async a=>{let n=r();if(!n)return null;let[i,{cart:u,errors:c}]=await Promise.all([t?t.isLoggedIn():!1,e.query(aa(o),{variables:{cartId:n,...a},cache:e.CacheNone()})]);if(i&&u?.checkoutUrl){let s=new URL(u.checkoutUrl);s.searchParams.set("logged_in","true"),u.checkoutUrl=s.toString();}return u||c?S(u,c):null}}var aa=(e=na)=>`#graphql
|
|
334
334
|
query CartQuery(
|
|
335
335
|
$cartId: ID!
|
|
336
336
|
$numCartLines: Int = 100
|
|
@@ -343,7 +343,7 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
${e}
|
|
346
|
-
`,
|
|
346
|
+
`,na=`#graphql
|
|
347
347
|
fragment CartApiQuery on Cart {
|
|
348
348
|
updatedAt
|
|
349
349
|
id
|
|
@@ -451,7 +451,7 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
451
451
|
width
|
|
452
452
|
height
|
|
453
453
|
}
|
|
454
|
-
`;function
|
|
454
|
+
`;function Ct(e){return async(t,r)=>{let{cartLinesAdd:o,errors:a}=await e.storefront.mutate(ia(e.cartFragment),{variables:{cartId:e.getCartId(),lines:t,...r}});return S(o,a)}}var ia=(e=w)=>`#graphql
|
|
455
455
|
mutation cartLinesAdd(
|
|
456
456
|
$cartId: ID!
|
|
457
457
|
$lines: [CartLineInput!]!
|
|
@@ -469,8 +469,8 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
469
469
|
}
|
|
470
470
|
|
|
471
471
|
${e}
|
|
472
|
-
${
|
|
473
|
-
`;var
|
|
472
|
+
${b}
|
|
473
|
+
`;var Pr="__h_pending_";function Sr(e){return Pr+e}function $e(e){return e.startsWith(Pr)}function qe(e,t){if(t.some(r=>$e(typeof r=="string"?r:r.id)))throw new Error(`Tried to perform an action on an optimistic line. Make sure to disable your "${e}" CartForm action when the line is optimistic.`)}function Pt(e){return async(t,r)=>{qe("updateLines",t);let{cartLinesUpdate:o,errors:a}=await e.storefront.mutate(sa(e.cartFragment),{variables:{cartId:e.getCartId(),lines:t,...r}});return S(o,a)}}var sa=(e=w)=>`#graphql
|
|
474
474
|
mutation cartLinesUpdate(
|
|
475
475
|
$cartId: ID!
|
|
476
476
|
$lines: [CartLineUpdateInput!]!
|
|
@@ -488,8 +488,8 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
${e}
|
|
491
|
-
${
|
|
492
|
-
`;function St(e){return async(t,r)=>{
|
|
491
|
+
${b}
|
|
492
|
+
`;function St(e){return async(t,r)=>{qe("removeLines",t);let{cartLinesRemove:o,errors:a}=await e.storefront.mutate(ca(e.cartFragment),{variables:{cartId:e.getCartId(),lineIds:t,...r}});return S(o,a)}}var ca=(e=w)=>`#graphql
|
|
493
493
|
mutation cartLinesRemove(
|
|
494
494
|
$cartId: ID!
|
|
495
495
|
$lineIds: [ID!]!
|
|
@@ -507,8 +507,8 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
507
507
|
}
|
|
508
508
|
|
|
509
509
|
${e}
|
|
510
|
-
${
|
|
511
|
-
`;function
|
|
510
|
+
${b}
|
|
511
|
+
`;function At(e){return async(t,r)=>{let o=t.filter((i,u,c)=>c.indexOf(i)===u),{cartDiscountCodesUpdate:a,errors:n}=await e.storefront.mutate(ua(e.cartFragment),{variables:{cartId:e.getCartId(),discountCodes:o,...r}});return S(a,n)}}var ua=(e=w)=>`#graphql
|
|
512
512
|
mutation cartDiscountCodesUpdate(
|
|
513
513
|
$cartId: ID!
|
|
514
514
|
$discountCodes: [String!]
|
|
@@ -525,8 +525,8 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
527
|
${e}
|
|
528
|
-
${
|
|
529
|
-
`;function
|
|
528
|
+
${b}
|
|
529
|
+
`;function Tt(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:n}=await e.storefront.mutate(pa(e.cartFragment),{variables:{cartId:e.getCartId(),buyerIdentity:{...o,...t},...r}});return S(a,n)}}var pa=(e=w)=>`#graphql
|
|
530
530
|
mutation cartBuyerIdentityUpdate(
|
|
531
531
|
$cartId: ID!
|
|
532
532
|
$buyerIdentity: CartBuyerIdentityInput!
|
|
@@ -543,8 +543,8 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
543
543
|
}
|
|
544
544
|
}
|
|
545
545
|
${e}
|
|
546
|
-
${
|
|
547
|
-
`;function
|
|
546
|
+
${b}
|
|
547
|
+
`;function vt(e){return async(t,r)=>{let{cartNoteUpdate:o,errors:a}=await e.storefront.mutate(da(e.cartFragment),{variables:{cartId:e.getCartId(),note:t,...r}});return S(o,a)}}var da=(e=w)=>`#graphql
|
|
548
548
|
mutation cartNoteUpdate(
|
|
549
549
|
$cartId: ID!
|
|
550
550
|
$note: String!
|
|
@@ -561,8 +561,8 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
563
|
${e}
|
|
564
|
-
${
|
|
565
|
-
`;function
|
|
564
|
+
${b}
|
|
565
|
+
`;function It(e){return async(t,r)=>{let{cartSelectedDeliveryOptionsUpdate:o,errors:a}=await e.storefront.mutate(la(e.cartFragment),{variables:{cartId:e.getCartId(),selectedDeliveryOptions:t,...r}});return S(o,a)}}var la=(e=w)=>`#graphql
|
|
566
566
|
mutation cartSelectedDeliveryOptionsUpdate(
|
|
567
567
|
$cartId: ID!
|
|
568
568
|
$selectedDeliveryOptions: [CartSelectedDeliveryOptionInput!]!
|
|
@@ -579,8 +579,8 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
581
|
${e}
|
|
582
|
-
${
|
|
583
|
-
`;function bt(e){return async(t,r)=>{let{cartAttributesUpdate:o,errors:a}=await e.storefront.mutate(
|
|
582
|
+
${b}
|
|
583
|
+
`;function bt(e){return async(t,r)=>{let{cartAttributesUpdate:o,errors:a}=await e.storefront.mutate(ya(e.cartFragment),{variables:{cartId:r?.cartId||e.getCartId(),attributes:t}});return S(o,a)}}var ya=(e=w)=>`#graphql
|
|
584
584
|
mutation cartAttributesUpdate(
|
|
585
585
|
$cartId: ID!
|
|
586
586
|
$attributes: [AttributeInput!]!
|
|
@@ -595,8 +595,8 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
595
595
|
}
|
|
596
596
|
}
|
|
597
597
|
${e}
|
|
598
|
-
${
|
|
599
|
-
`;function
|
|
598
|
+
${b}
|
|
599
|
+
`;function wt(e){return async(t,r)=>{let o=r?.cartId||e.getCartId(),a=t.map(u=>({...u,ownerId:o})),{cartMetafieldsSet:n,errors:i}=await e.storefront.mutate(fa(),{variables:{metafields:a}});return S({cart:{id:o},...n},i)}}var fa=()=>`#graphql
|
|
600
600
|
mutation cartMetafieldsSet(
|
|
601
601
|
$metafields: [CartMetafieldsSetInput!]!
|
|
602
602
|
$language: LanguageCode
|
|
@@ -611,7 +611,7 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
|
-
`;function
|
|
614
|
+
`;function Rt(e){return async(t,r)=>{let o=r?.cartId||e.getCartId(),{cartMetafieldDelete:a,errors:n}=await e.storefront.mutate(ma(),{variables:{input:{ownerId:o,key:t}}});return S({cart:{id:o},...a},n)}}var ma=()=>`#graphql
|
|
615
615
|
mutation cartMetafieldDelete(
|
|
616
616
|
$input: CartMetafieldDeleteInput!
|
|
617
617
|
) {
|
|
@@ -623,7 +623,7 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
|
-
`;var ga=e=>{let t=cookie.parse(e.get("Cookie")||"");return ()=>t.cart?`gid://shopify/Cart/${t.cart}`:void 0};var Ca=e=>t=>{let r=new Headers;return r.append("Set-Cookie",cookie.stringify("cart",t.split("/").pop()||"",{path:"/",...e})),r};function Sa(e){let{getCartId:t,setCartId:r,storefront:o,customerAccount:a,cartQueryFragment:i,cartMutateFragment:n}=e,u=t(),c=()=>u||t(),s={storefront:o,getCartId:c,cartFragment:n,customerAccount:a},l=mt(s),y=async function(...p){let d=await l(...p);return u=d?.cart?.id,d},m={get:gt({storefront:o,customerAccount:a,getCartId:c,cartFragment:i}),getCartId:c,setCartId:r,create:y,addLines:async(p,d)=>{let g=p.map(h=>({attributes:h.attributes,quantity:h.quantity,merchandiseId:h.merchandiseId,sellingPlanId:h.sellingPlanId}));return u||d?.cartId?await ht(s)(g,d):await y({lines:g},d)},updateLines:Ct(s),removeLines:St(s),updateDiscountCodes:async(p,d)=>u||d?.cartId?await Pt(s)(p,d):await y({discountCodes:p},d),updateBuyerIdentity:async(p,d)=>u||d?.cartId?await At(s)(p,d):await y({buyerIdentity:p},d),updateNote:async(p,d)=>u||d?.cartId?await Tt(s)(p,d):await y({note:p},d),updateSelectedDeliveryOption:vt(s),updateAttributes:async(p,d)=>u||d?.cartId?await bt(s)(p,d):await y({attributes:p},d),setMetafields:async(p,d)=>u||d?.cartId?await It(s)(p,d):await y({metafields:p},d),deleteMetafield:wt(s)};return "customMethods"in e?{...m,...e.customMethods??{}}:m}function Aa(e){let t=react$1.useFetchers();if(!t||!t.length)return e;let r=e?.lines?structuredClone(e):{lines:{nodes:[]}},o=r.lines.nodes,a=!1;for(let{formData:i}of t){if(!i)continue;let n=G.getFormInput(i);if(n.action===G.ACTIONS.LinesAdd)for(let u of n.inputs.lines){if(!u.selectedVariant){console.error("[h2:error:useOptimisticCart] No selected variant was passed in the cart action. Make sure to pass the selected variant if you want to use an optimistic cart");continue}let c=o.find(s=>s.merchandise.id===u.selectedVariant?.id);a=!0,c?(c.quantity=(c.quantity||1)+(u.quantity||1),c.isOptimistic=!0):o.unshift({id:Pr(u.selectedVariant.id),merchandise:u.selectedVariant,isOptimistic:!0,quantity:u.quantity||1});}else if(n.action===G.ACTIONS.LinesRemove)for(let u of n.inputs.lineIds){let c=o.findIndex(s=>s.id===u);if(c!==-1){if(Fe(o[c].id)){console.error("[h2:error:useOptimisticCart] Tried to remove an optimistic line that has not been added to the cart yet");continue}o.splice(c,1),a=!0;}else console.warn(`[h2:warn:useOptimisticCart] Tried to remove line '${u}' but it doesn't exist in the cart`);}else if(n.action===G.ACTIONS.LinesUpdate)for(let u of n.inputs.lines){let c=o.findIndex(s=>u.id===s.id);if(c>-1){if(Fe(o[c].id)){console.error("[h2:error:useOptimisticCart] Tried to update an optimistic line that has not been added to the cart yet");continue}o[c].quantity=u.quantity,o[c].quantity===0&&o.splice(c,1),a=!0;}else console.warn(`[h2:warn:useOptimisticCart] Tried to update line '${u.id}' but it doesn't exist in the cart`);}}return a&&(r.isOptimistic=a),r}function wa({handle:e,options:t=[],variants:r=[],productPath:o="products",children:a}){let i=r instanceof Array?r:hydrogenReact.flattenConnection(r),{searchParams:n,path:u,alreadyOnProductPage:c}=Ea(e,o),s=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(c?n:void 0);d.set(l.name,p),s.forEach(v=>{d.set(v.name,v.values[0]);});let g=i.find(v=>v?.selectedOptions?.every(N=>d.get(N?.name)===N?.value)),h=n.get(l.name),f=h?h===p:!1;f&&(y=p);let b="?"+d.toString();m.push({value:p,isAvailable:g?g.availableForSale:!0,to:u+b,search:b,isActive:f,variant:g});}return a({option:{name:l.name,value:y,values:m}})}),[t,i,a]))}var Ra=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 Ea(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),i=a&&a.length>0;t=t.startsWith("/")?t.substring(1):t;let n=i?`${a[0]}${t}/${e}`:`/${t}/${e}`;return {searchParams:new URLSearchParams(o),alreadyOnProductPage:n===r,path:n}},[r,o,e,t])}var Tr=react.createContext(void 0),La=Tr.Provider,Rt=()=>react.useContext(Tr);function Ua(e){let t=Ve(),r=_a(t,e);return {nonce:t,header:r,NonceProvider:({children:a})=>react.createElement(La,{value:t},a)}}function _a(e,t){let{shop:r,...o}=t??{},a=`'nonce-${e}'`,i=["'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 c={baseUri:["'self'"],defaultSrc:["'self'",a,"https://cdn.shopify.com","https://shopify.com"],frameAncestors:["'none'"],styleSrc:i,connectSrc:n},s=Object.assign({},c,o);for(let l in c){let y=o[l];l&&y&&(s[l]=Na(y,c[l]));}return s.scriptSrc instanceof Array&&!s.scriptSrc.includes(a)?s.scriptSrc.push(a):s.defaultSrc instanceof Array&&!s.defaultSrc.includes(a)&&s.defaultSrc.push(a),ka__default.default({directives:s})}function Na(e,t){let r=typeof t=="string"?[t]:t,o=Array.isArray(e)?e:[String(e)];return Array.isArray(r)?r.every(i=>i==="'none'")?o:[...o,...r]:r}var Va=react.forwardRef((e,t)=>{let r=Rt();return jsxRuntime.jsx("script",{suppressHydrationWarning:!0,...e,nonce:r,ref:t})});function qa(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 Ha({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 Wa(e){return jsxRuntime.jsx(hydrogenReact.ShopPayButton,{channel:"hydrogen",...e})}function pe(e){let{type:t,data:r={},customData:o}=e,a=react$1.useLocation(),{publish:i,cart:n,prevCart:u,shop:c,customData:s}=X(),l=a.pathname+a.search,y={...r,customData:{...s,...o},cart:n,prevCart:u,shop:c};return react.useEffect(()=>{c?.shopId&&(y={...y,url:window.location.href},i(t,y));},[i,l,c?.shopId]),null}function br(e){return jsxRuntime.jsx(pe,{...e,type:"page_viewed"})}function Ir(e){return jsxRuntime.jsx(pe,{...e,type:"product_viewed"})}function wr(e){return jsxRuntime.jsx(pe,{...e,type:"collection_viewed"})}function Rr(e){return jsxRuntime.jsx(pe,{...e,type:"cart_viewed"})}function Er(e){return jsxRuntime.jsx(pe,{...e,type:"search_viewed"})}function xr(e){return jsxRuntime.jsx(pe,{...e})}var Z={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 Xa="https://cdn.shopify.com/shopifycloud/consent-tracking-api/v0.1/consent-tracking-api.js",Za="https://cdn.shopify.com/shopifycloud/privacy-banner/storefront-banner.js";function Or(e){console.error(`[h2:error:useCustomerPrivacy] Unable to setup Customer Privacy API: Missing consent.${e} configuration.`);}function Et(e){let{withPrivacyBanner:t=!0,onVisitorConsentCollected:r,onReady:o,...a}=e,i=react.useRef(!1),n=hydrogenReact.useLoadScript(t?Za:Xa,{attributes:{id:"customer-privacy-api"}});react.useEffect(()=>{let u=c=>{r&&r(c.detail);};return document.addEventListener("visitorConsentCollected",u),()=>{document.removeEventListener("visitorConsentCollected",u);}},[r]),react.useEffect(()=>{if(n!=="done"||i.current)return;i.current=!0;let{checkoutDomain:u,storefrontAccessToken:c}=a;u||Or("checkoutDomain"),c||Or("storefrontAccessToken"),(c.startsWith("shpat_")||c.length!==32)&&console.error("[h2:error:useCustomerPrivacy] It looks like you passed a private access token, make sure to use the public token");let s={checkoutRootDomain:u,storefrontAccessToken:c};if(u){let m=window.document.location.host,p=u.split(".").reverse(),d=m.split(".").reverse(),g=[];p.forEach((h,f)=>{h===d[f]&&g.push(h);}),m=g.reverse().join("."),m&&(s.storefrontRootDomain=m);}if(t&&window?.privacyBanner&&window.privacyBanner?.loadBanner(s),!window.Shopify?.customerPrivacy)return;let l=window.Shopify.customerPrivacy.setTrackingConsent;function y(m,p){l({...m,headlessStorefront:!0,...s},p);}window.Shopify.customerPrivacy.setTrackingConsent=y,o&&o();},[n,t,a]);}function xt(){try{return window.Shopify&&window.Shopify.customerPrivacy?window.Shopify?.customerPrivacy:null}catch{return null}}function on(){let e=xt();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 Lr({consent:e,onReady:t,domain:r}){let{subscribe:o,register:a,canTrack:i}=X(),[n,u]=react.useState(!1),[c,s]=react.useState(!1),{ready:l}=a("Internal_Shopify_Analytics"),{ready:y}=a("Internal_Shopify_CustomerPrivacy"),m=()=>{n&&c&&t();},p=()=>{s(!0),y(),m();},{checkoutDomain:d,storefrontAccessToken:g,withPrivacyBanner:h}=e;return Et({checkoutDomain:d||"mock.shop",storefrontAccessToken:g||"abcdefghijklmnopqrstuvwxyz123456",withPrivacyBanner:h,onVisitorConsentCollected:p,onReady:()=>{setTimeout(p,3e3);}}),hydrogenReact.useShopifyCookies({hasUserConsent:n&&c?i():!0,domain:r,checkoutDomain:d}),react.useEffect(()=>{o(Z.PAGE_VIEWED,nn),o(Z.PRODUCT_VIEWED,sn),o(Z.COLLECTION_VIEWED,cn),o(Z.SEARCH_VIEWED,un),o(Z.PRODUCT_ADD_TO_CART,pn),l(),u(!0),m();},[o,l]),null}function qe(e){console.error(`[h2:error:ShopifyAnalytics] Unable to send Shopify analytics: Missing shop.${e} configuration.`);}function Ie(e){let t=on(),r=t.analyticsProcessingAllowed();if(!e?.shop?.shopId){qe("shopId");return}if(!e?.shop?.acceptedLanguage){qe("acceptedLanguage");return}if(!e?.shop?.currency){qe("currency");return}if(!e?.shop?.hydrogenSubchannelId){qe("hydrogenSubchannelId");return}return {shopifySalesChannel:"hydrogen",...e.shop,hasUserConsent:r,...hydrogenReact.getClientBrowserParameters(),ccpaEnforced:!t.saleOfDataAllowed(),gdprEnforced:!(t.marketingAllowed()&&t.analyticsProcessingAllowed())}}function an(e,t){if(t===null)return;let r=Ie(e);return r?{...r,cartId:t.id}:void 0}var j={};function nn(e){let t=Ie(e);t&&(hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.PAGE_VIEW_2,payload:{...t,...j}}),j={});}function sn(e){let t=Ie(e);if(t&&Ur({type:"product",products:e.products})){let r=Dt(e.products);j={pageType:hydrogenReact.AnalyticsPageType.product,resourceId:r[0].productGid},t={...t,...j,products:Dt(e.products)},hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.PRODUCT_VIEW,payload:t});}}function cn(e){let t=Ie(e);t&&(j={pageType:hydrogenReact.AnalyticsPageType.collection,resourceId:e.collection.id},t={...t,...j,collectionHandle:e.collection.handle},hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.COLLECTION_VIEW,payload:t}));}function un(e){let t=Ie(e);t&&(j={pageType:hydrogenReact.AnalyticsPageType.search},t={...t,...j,searchString:e.searchTerm},hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.SEARCH_VIEW,payload:t}));}function pn(e){let{cart:t,currentLine:r}=e,o=an(e,t);!o||!r?.id||dn({matchedLine:r,eventPayload:o});}function dn({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};Ur({type:"cart",products:[r]})&&hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.ADD_TO_CART,payload:{...t,products:Dt([r])}});}function ee(e,t,r,o){if(e==="cart"){let a=`${r?"merchandise":"merchandise.product"}.${t}`;console.error(`[h2:error:ShopifyAnalytics] Can't set up cart analytics events because the \`cart.lines[].${a}\` value is missing from your GraphQL cart query. In your project, search for where \`fragment CartLine on CartLine\` is defined and make sure \`${a}\` is part of your cart query. Check the Hydrogen Skeleton template for reference: https://github.com/Shopify/hydrogen/blob/main/templates/skeleton/app/lib/fragments.ts#L25-L56.`);}else {let a=`${o||t}`;console.error(`[h2:error:ShopifyAnalytics] Can't set up product view analytics events because the \`${a}\` is missing from your \`<Analytics.ProductView>\`. Make sure \`${a}\` is part of your products data prop. Check the Hydrogen Skeleton template for reference: https://github.com/Shopify/hydrogen/blob/main/templates/skeleton/app/routes/products.%24handle.tsx#L159-L165.`);}}function Ur({type:e,products:t}){return !t||t.length===0?(ee(e,"",!1,"data.products"),!1):(t.forEach(r=>{if(!r.id)return ee(e,"id",!1),!1;if(!r.title)return ee(e,"title",!1),!1;if(!r.price)return ee(e,"price.amount",!0,"price"),!1;if(!r.vendor)return ee(e,"vendor",!1),!1;if(!r.variantId)return ee(e,"id",!0,"variantId"),!1;if(!r.variantTitle)return ee(e,"title",!0,"variantTitle"),!1}),!0)}function Dt(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 Mr(e){console.error(`[h2:error:CartAnalytics] Can't set up cart analytics events because the \`cart.${e}\` value is missing from your GraphQL cart query. In your project, search for where \`fragment CartApiQuery on Cart\` is defined and make sure \`${e}\` is part of your cart query. Check the Hydrogen Skeleton template for reference: https://github.com/Shopify/hydrogen/blob/main/templates/skeleton/app/lib/fragments.ts#L59.`);}function Vr({cart:e,setCarts:t}){let{publish:r,shop:o,customData:a,canTrack:i,cart:n,prevCart:u}=X(),c=react.useRef(null);return react.useEffect(()=>{if(e)return Promise.resolve(e).then(s=>{if(s&&s.lines){if(!s.id){Mr("id");return}if(!s.updatedAt){Mr("updatedAt");return}}t(({cart:l,prevCart:y})=>s?.updatedAt!==l?.updatedAt?{cart:s,prevCart:l}:{cart:l,prevCart:y});}),()=>{}},[t,e]),react.useEffect(()=>{if(!n||!n?.updatedAt||n?.updatedAt===u?.updatedAt)return;let s;try{s=JSON.parse(localStorage.getItem("cartLastUpdatedAt")||"");}catch{s=null;}if(n.id===s?.id&&n.updatedAt===s?.updatedAt)return;let l={eventTimestamp:Date.now(),cart:n,prevCart:u,shop:o,customData:a};if(n.updatedAt===c.current)return;c.current=n.updatedAt,r("cart_updated",l),localStorage.setItem("cartLastUpdatedAt",JSON.stringify({id:n.id,updatedAt:n.updatedAt}));let y=u?.lines?hydrogenReact.flattenConnection(u?.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,u,r,o,a,i]),null}var Cn={canTrack:()=>!1,cart:null,customData:{},prevCart:null,publish:()=>{},shop:null,subscribe:()=>{},register:()=>({ready:()=>{}})},Gr=react.createContext(Cn),Qe=new Map,we={};function Br(){return Object.values(we).every(Boolean)}function Fr(e,t){Qe.has(e)||Qe.set(e,new Map),Qe.get(e)?.set(t.toString(),t);}var Ge=new Map;function $r(e,t){if(!Br()){Ge.set(e,t);return}Wr(e,t);}function Wr(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 qr(e){return we.hasOwnProperty(e)||(we[e]=!1),{ready:()=>{we[e]=!0,Br()&&Ge.size>0&&(Ge.forEach((t,r)=>{Wr(r,t);}),Ge.clear());}}}function Hr(){try{return window.Shopify.customerPrivacy.analyticsProcessingAllowed()}catch{}return !1}function Qr(e,t){return `[h2:error:Analytics.Provider] - ${e} is required. Make sure ${t} is defined in your environment variables. See https://h2o.fyi/analytics/consent to learn how to setup environment variables in the Shopify admin.`}function Sn({canTrack:e,cart:t,children:r,consent:o,customData:a={},shop:i=null,disableThrowOnError:n=!1,cookieDomain:u}){let c=react.useRef(!1),{shop:s}=Pn(i),[l,y]=react.useState(!!e),[m,p]=react.useState({cart:null,prevCart:null}),[d,g]=react.useState(e?()=>e:()=>Hr);if(s)if(/\/68817551382$/.test(s.shopId))jt("[h2:error:Analytics.Provider] - Mock shop is used. Analytics will not work properly.");else {if(!o.checkoutDomain){let f=Qr("consent.checkoutDomain","PUBLIC_CHECKOUT_DOMAIN");at(f);}if(!o.storefrontAccessToken){let f=Qr("consent.storefrontAccessToken","PUBLIC_STOREFRONT_API_TOKEN");at(f);}}let h=react.useMemo(()=>({canTrack:d,...m,customData:a,publish:d()?$r:()=>{},shop:s,subscribe:Fr,register:qr}),[l,d(),d,JSON.stringify(d),m,m.cart?.updatedAt,m.prevCart,$r,Fr,a,s,qr,JSON.stringify(we)]);return jsxRuntime.jsxs(Gr.Provider,{value:h,children:[r,!!s&&jsxRuntime.jsx(br,{}),!!s&&!!t&&jsxRuntime.jsx(Vr,{cart:t,setCarts:p}),!!s&&o.checkoutDomain&&jsxRuntime.jsx(Lr,{consent:o,onReady:()=>{c.current=!0,y(!0),g(()=>Hr);},domain:u})]})}function X(){let e=react.useContext(Gr);if(!e)throw new Error("[h2:error:useAnalytics] 'useAnalytics()' must be a descendent of <AnalyticsProvider/>");return e}function Pn(e){let[t,r]=react.useState(null);return react.useEffect(()=>(Promise.resolve(e).then(r),()=>{}),[r,e]),{shop:t}}async function An({storefront:e,publicStorefrontId:t="0"}){return e.query(Tn,{cache:e.CacheLong()}).then(({shop:r,localization:o})=>({shopId:r.id,acceptedLanguage:o.language.isoCode,currency:o.country.currency.isoCode,hydrogenSubchannelId:t}))}var Tn=`#graphql
|
|
626
|
+
`;var ga=e=>{let t=cookie.parse(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",cookie.stringify("cart",t.split("/").pop()||"",{path:"/",...e})),r};function Sa(e){let{getCartId:t,setCartId:r,storefront:o,customerAccount:a,cartQueryFragment:n,cartMutateFragment:i}=e,u=t(),c=()=>u||t(),s={storefront:o,getCartId:c,cartFragment:i,customerAccount:a},l=ht(s),y=async function(...d){let p=await l(...d);return u=p?.cart?.id,p},m={get:gt({storefront:o,customerAccount:a,getCartId:c,cartFragment:n}),getCartId:c,setCartId:r,create:y,addLines:async(d,p)=>{let h=d.map(g=>({attributes:g.attributes,quantity:g.quantity,merchandiseId:g.merchandiseId,sellingPlanId:g.sellingPlanId}));return u||p?.cartId?await Ct(s)(h,p):await y({lines:h},p)},updateLines:Pt(s),removeLines:St(s),updateDiscountCodes:async(d,p)=>u||p?.cartId?await At(s)(d,p):await y({discountCodes:d},p),updateBuyerIdentity:async(d,p)=>u||p?.cartId?await Tt(s)(d,p):await y({buyerIdentity:d},p),updateNote:async(d,p)=>u||p?.cartId?await vt(s)(d,p):await y({note:d},p),updateSelectedDeliveryOption:It(s),updateAttributes:async(d,p)=>u||p?.cartId?await bt(s)(d,p):await y({attributes:d},p),setMetafields:async(d,p)=>u||p?.cartId?await wt(s)(d,p):await y({metafields:d},p),deleteMetafield:Rt(s)};return "customMethods"in e?{...m,...e.customMethods??{}}:m}function Ta(e){let t=react$1.useFetchers();if(!t||!t.length)return e;let r=e?.lines?structuredClone(e):{lines:{nodes:[]}},o=r.lines.nodes,a=!1;for(let{formData:n}of t){if(!n)continue;let i=B.getFormInput(n);if(i.action===B.ACTIONS.LinesAdd)for(let u of i.inputs.lines){if(!u.selectedVariant){console.error("[h2:error:useOptimisticCart] No selected variant was passed in the cart action. Make sure to pass the selected variant if you want to use an optimistic cart");continue}let c=o.find(s=>s.merchandise.id===u.selectedVariant?.id);a=!0,c?(c.quantity=(c.quantity||1)+(u.quantity||1),c.isOptimistic=!0):o.unshift({id:Sr(u.selectedVariant.id),merchandise:u.selectedVariant,isOptimistic:!0,quantity:u.quantity||1});}else if(i.action===B.ACTIONS.LinesRemove)for(let u of i.inputs.lineIds){let c=o.findIndex(s=>s.id===u);if(c!==-1){if($e(o[c].id)){console.error("[h2:error:useOptimisticCart] Tried to remove an optimistic line that has not been added to the cart yet");continue}o.splice(c,1),a=!0;}else console.warn(`[h2:warn:useOptimisticCart] Tried to remove line '${u}' but it doesn't exist in the cart`);}else if(i.action===B.ACTIONS.LinesUpdate)for(let u of i.inputs.lines){let c=o.findIndex(s=>u.id===s.id);if(c>-1){if($e(o[c].id)){console.error("[h2:error:useOptimisticCart] Tried to update an optimistic line that has not been added to the cart yet");continue}o[c].quantity=u.quantity,o[c].quantity===0&&o.splice(c,1),a=!0;}else console.warn(`[h2:warn:useOptimisticCart] Tried to update line '${u.id}' but it doesn't exist in the cart`);}}return a&&(r.isOptimistic=a),r}function Ea({handle:e,options:t=[],variants:r=[],productPath:o="products",waitForNavigation:a=!1,children:n}){let i=r instanceof Array?r:hydrogenReact.flattenConnection(r),{searchParams:u,path:c,alreadyOnProductPage:s}=Da(e,o,a),l=t.filter(y=>y?.values?.length===1);return react.createElement(react.Fragment,null,...react.useMemo(()=>t.map(y=>{let m,d=[];for(let p of y.values){let h=new URLSearchParams(s?u:void 0);h.set(y.name,p),l.forEach(_=>{h.set(_.name,_.values[0]);});let g=i.find(_=>_?.selectedOptions?.every(U=>h.get(U?.name)===U?.value)),f=u.get(y.name),v=f?f===p:!1;v&&(m=p);let I="?"+h.toString();d.push({value:p,isAvailable:g?g.availableForSale:!0,to:c+I,search:I,isActive:v,variant:g});}return n({option:{name:y.name,value:m,values:d}})}),[t,i,n]))}var Oa=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 Da(e,t,r){let{pathname:o,search:a}=react$1.useLocation(),n=react$1.useNavigation();return react.useMemo(()=>{let i=/(\/[a-zA-Z]{2}-[a-zA-Z]{2}\/)/g.exec(o),u=i&&i.length>0;t=t.startsWith("/")?t.substring(1):t;let c=u?`${i[0]}${t}/${e}`:`/${t}/${e}`;return {searchParams:new URLSearchParams(r||n.state!=="loading"?a:n.location.search),alreadyOnProductPage:c===o,path:c}},[o,a,r,e,t,n])}function _a(e,t){let r=react$1.useNavigation(),[o,a]=react.useState([]);if(react.useEffect(()=>{Promise.resolve(t).then(n=>{n&&a(n instanceof Array?n:n.product?.variants?.nodes||[]);}).catch(n=>{reportError(new Error("[h2:error:useOptimisticVariant] An error occurred while resolving the variants for the optimistic product hook.",{cause:n}));});},[t]),r.state==="loading"){let n=new URLSearchParams(r.location.search),i=!1,u=o.find(c=>c.selectedOptions?c.selectedOptions.every(s=>n.get(s.name)===s.value):(i||(i=!0,reportError(new Error("[h2:error:useOptimisticVariant] The optimistic product hook requires your product query to include variants with the selectedOptions field."))),!1));if(u)return {...u,isOptimistic:!0}}return e}var Tr=react.createContext(void 0),Fa=Tr.Provider,Et=()=>react.useContext(Tr);function $a(e){let t=Fe(),r=qa(t,e);return {nonce:t,header:r,NonceProvider:({children:a})=>react.createElement(Fa,{value:t},a)}}function qa(e,t){let{shop:r,...o}=t??{},a=`'nonce-${e}'`,n=["'self'","'unsafe-inline'","https://cdn.shopify.com"],i=["'self'","https://monorail-edge.shopifysvc.com"];r&&r.checkoutDomain&&i.push(`https://${r.checkoutDomain}`),r&&r.storeDomain&&i.push(`https://${r.storeDomain}`);let c={baseUri:["'self'"],defaultSrc:["'self'",a,"https://cdn.shopify.com","https://shopify.com"],frameAncestors:["'none'"],styleSrc:n,connectSrc:i},s=Object.assign({},c,o);for(let l in c){let y=o[l];l&&y&&(s[l]=Ha(y,c[l]));}return s.scriptSrc instanceof Array&&!s.scriptSrc.includes(a)?s.scriptSrc.push(a):s.defaultSrc instanceof Array&&!s.defaultSrc.includes(a)&&s.defaultSrc.push(a),Ma__default.default({directives:s})}function Ha(e,t){let r=typeof t=="string"?[t]:t,o=Array.isArray(e)?e:[String(e)];return Array.isArray(r)?r.every(n=>n==="'none'")?o:[...o,...r]:r}var Ba=react.forwardRef((e,t)=>{let r=Et();return jsxRuntime.jsx("script",{suppressHydrationWarning:!0,...e,nonce:r,ref:t})});function ja(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 Ka({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 Xa(e){return jsxRuntime.jsx(hydrogenReact.ShopPayButton,{channel:"hydrogen",...e})}function pe(e){let{type:t,data:r={},customData:o}=e,a=react$1.useLocation(),{publish:n,cart:i,prevCart:u,shop:c,customData:s}=G(),l=a.pathname+a.search,y={...r,customData:{...s,...o},cart:i,prevCart:u,shop:c};return react.useEffect(()=>{c?.shopId&&(y={...y,url:window.location.href},n(t,y));},[n,l,c?.shopId]),null}function Ir(e){return jsxRuntime.jsx(pe,{...e,type:"page_viewed"})}function br(e){return jsxRuntime.jsx(pe,{...e,type:"product_viewed"})}function wr(e){return jsxRuntime.jsx(pe,{...e,type:"collection_viewed"})}function Rr(e){return jsxRuntime.jsx(pe,{...e,type:"cart_viewed"})}function Er(e){return jsxRuntime.jsx(pe,{...e,type:"search_viewed"})}function Or(e){return jsxRuntime.jsx(pe,{...e})}var L={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 an="https://cdn.shopify.com/shopifycloud/consent-tracking-api/v0.1/consent-tracking-api.js",nn="https://cdn.shopify.com/shopifycloud/privacy-banner/storefront-banner.js";function xr(e){console.error(`[h2:error:useCustomerPrivacy] Unable to setup Customer Privacy API: Missing consent.${e} configuration.`);}function Ot(e){let{withPrivacyBanner:t=!0,onVisitorConsentCollected:r,onReady:o,...a}=e,n=react.useRef(!1),i=hydrogenReact.useLoadScript(t?nn:an,{attributes:{id:"customer-privacy-api"}});react.useEffect(()=>{let u=c=>{r&&r(c.detail);};return document.addEventListener("visitorConsentCollected",u),()=>{document.removeEventListener("visitorConsentCollected",u);}},[r]),react.useEffect(()=>{if(i!=="done"||n.current)return;n.current=!0;let{checkoutDomain:u,storefrontAccessToken:c}=a;u||xr("checkoutDomain"),c||xr("storefrontAccessToken"),(c.startsWith("shpat_")||c.length!==32)&&console.error("[h2:error:useCustomerPrivacy] It looks like you passed a private access token, make sure to use the public token");let s={checkoutRootDomain:u,storefrontAccessToken:c};if(u){let m=window.document.location.host,d=u.split(".").reverse(),p=m.split(".").reverse(),h=[];d.forEach((g,f)=>{g===p[f]&&h.push(g);}),m=h.reverse().join("."),m&&(s.storefrontRootDomain=m);}if(t&&window?.privacyBanner&&window.privacyBanner?.loadBanner(s),!window.Shopify?.customerPrivacy)return;let l=window.Shopify.customerPrivacy.setTrackingConsent;function y(m,d){l({...m,headlessStorefront:!0,...s},d);}window.Shopify.customerPrivacy.setTrackingConsent=y,o&&o();},[i,t,a]);}function Dt(){try{return window.Shopify&&window.Shopify.customerPrivacy?window.Shopify?.customerPrivacy:null}catch{return null}}function pn(){let e=Dt();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 Lr({consent:e,onReady:t,domain:r}){let{subscribe:o,register:a,canTrack:n}=G(),[i,u]=react.useState(!1),[c,s]=react.useState(!1),{ready:l}=a("Internal_Shopify_Analytics"),{ready:y}=a("Internal_Shopify_CustomerPrivacy"),m=()=>{i&&c&&t();},d=()=>{s(!0),y(),m();},{checkoutDomain:p,storefrontAccessToken:h,withPrivacyBanner:g}=e;return Ot({checkoutDomain:p||"mock.shop",storefrontAccessToken:h||"abcdefghijklmnopqrstuvwxyz123456",withPrivacyBanner:g,onVisitorConsentCollected:d,onReady:()=>{setTimeout(d,3e3);}}),hydrogenReact.useShopifyCookies({hasUserConsent:i&&c?n():!0,domain:r,checkoutDomain:p}),react.useEffect(()=>{o(L.PAGE_VIEWED,ln),o(L.PRODUCT_VIEWED,yn),o(L.COLLECTION_VIEWED,fn),o(L.SEARCH_VIEWED,mn),o(L.PRODUCT_ADD_TO_CART,hn),l(),u(!0),m();},[o,l]),null}function He(e){console.error(`[h2:error:ShopifyAnalytics] Unable to send Shopify analytics: Missing shop.${e} configuration.`);}function be(e){let t=pn(),r=t.analyticsProcessingAllowed();if(!e?.shop?.shopId){He("shopId");return}if(!e?.shop?.acceptedLanguage){He("acceptedLanguage");return}if(!e?.shop?.currency){He("currency");return}if(!e?.shop?.hydrogenSubchannelId){He("hydrogenSubchannelId");return}return {shopifySalesChannel:"hydrogen",...e.shop,hasUserConsent:r,...hydrogenReact.getClientBrowserParameters(),ccpaEnforced:!t.saleOfDataAllowed(),gdprEnforced:!(t.marketingAllowed()&&t.analyticsProcessingAllowed())}}function dn(e,t){if(t===null)return;let r=be(e);return r?{...r,cartId:t.id}:void 0}var z={};function ln(e){let t=be(e);t&&(hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.PAGE_VIEW_2,payload:{...t,...z}}),z={});}function yn(e){let t=be(e);if(t&&_r({type:"product",products:e.products})){let r=xt(e.products);z={pageType:hydrogenReact.AnalyticsPageType.product,resourceId:r[0].productGid},t={...t,...z,products:xt(e.products)},hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.PRODUCT_VIEW,payload:t});}}function fn(e){let t=be(e);t&&(z={pageType:hydrogenReact.AnalyticsPageType.collection,resourceId:e.collection.id},t={...t,...z,collectionHandle:e.collection.handle},hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.COLLECTION_VIEW,payload:t}));}function mn(e){let t=be(e);t&&(z={pageType:hydrogenReact.AnalyticsPageType.search},t={...t,...z,searchString:e.searchTerm},hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.SEARCH_VIEW,payload:t}));}function hn(e){let{cart:t,currentLine:r}=e,o=dn(e,t);!o||!r?.id||gn({matchedLine:r,eventPayload:o});}function gn({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};_r({type:"cart",products:[r]})&&hydrogenReact.sendShopifyAnalytics({eventName:hydrogenReact.AnalyticsEventName.ADD_TO_CART,payload:{...t,products:xt([r])}});}function te(e,t,r,o){if(e==="cart"){let a=`${r?"merchandise":"merchandise.product"}.${t}`;console.error(`[h2:error:ShopifyAnalytics] Can't set up cart analytics events because the \`cart.lines[].${a}\` value is missing from your GraphQL cart query. In your project, search for where \`fragment CartLine on CartLine\` is defined and make sure \`${a}\` is part of your cart query. Check the Hydrogen Skeleton template for reference: https://github.com/Shopify/hydrogen/blob/main/templates/skeleton/app/lib/fragments.ts#L25-L56.`);}else {let a=`${o||t}`;console.error(`[h2:error:ShopifyAnalytics] Can't set up product view analytics events because the \`${a}\` is missing from your \`<Analytics.ProductView>\`. Make sure \`${a}\` is part of your products data prop. Check the Hydrogen Skeleton template for reference: https://github.com/Shopify/hydrogen/blob/main/templates/skeleton/app/routes/products.%24handle.tsx#L159-L165.`);}}function _r({type:e,products:t}){return !t||t.length===0?(te(e,"",!1,"data.products"),!1):(t.forEach(r=>{if(!r.id)return te(e,"id",!1),!1;if(!r.title)return te(e,"title",!1),!1;if(!r.price)return te(e,"price.amount",!0,"price"),!1;if(!r.vendor)return te(e,"vendor",!1),!1;if(!r.variantId)return te(e,"id",!0,"variantId"),!1;if(!r.variantTitle)return te(e,"title",!0,"variantTitle"),!1}),!0)}function xt(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 Vr(e){console.error(`[h2:error:CartAnalytics] Can't set up cart analytics events because the \`cart.${e}\` value is missing from your GraphQL cart query. In your project, search for where \`fragment CartApiQuery on Cart\` is defined and make sure \`${e}\` is part of your cart query. Check the Hydrogen Skeleton template for reference: https://github.com/Shopify/hydrogen/blob/main/templates/skeleton/app/lib/fragments.ts#L59.`);}function Mr({cart:e,setCarts:t}){let{publish:r,shop:o,customData:a,canTrack:n,cart:i,prevCart:u}=G(),c=react.useRef(null);return react.useEffect(()=>{if(e)return Promise.resolve(e).then(s=>{if(s&&s.lines){if(!s.id){Vr("id");return}if(!s.updatedAt){Vr("updatedAt");return}}t(({cart:l,prevCart:y})=>s?.updatedAt!==l?.updatedAt?{cart:s,prevCart:l}:{cart:l,prevCart:y});}),()=>{}},[t,e]),react.useEffect(()=>{if(!i||!i?.updatedAt||i?.updatedAt===u?.updatedAt)return;let s;try{s=JSON.parse(localStorage.getItem("cartLastUpdatedAt")||"");}catch{s=null;}if(i.id===s?.id&&i.updatedAt===s?.updatedAt)return;let l={eventTimestamp:Date.now(),cart:i,prevCart:u,shop:o,customData:a};if(i.updatedAt===c.current)return;c.current=i.updatedAt,r("cart_updated",l),localStorage.setItem("cartLastUpdatedAt",JSON.stringify({id:i.id,updatedAt:i.updatedAt}));let y=u?.lines?hydrogenReact.flattenConnection(u?.lines):[],m=i.lines?hydrogenReact.flattenConnection(i.lines):[];y?.forEach(d=>{let p=m.filter(h=>d.id===h.id);if(p?.length===1){let h=p[0];d.quantity<h.quantity?r("product_added_to_cart",{...l,prevLine:d,currentLine:h}):d.quantity>h.quantity&&r("product_removed_from_cart",{...l,prevLine:d,currentLine:h});}else r("product_removed_from_cart",{...l,prevLine:d});}),m?.forEach(d=>{let p=y.filter(h=>d.id===h.id);(!p||p.length===0)&&r("product_added_to_cart",{...l,currentLine:d});});},[i,u,r,o,a,n]),null}var vn="https://cdn.shopify.com/shopifycloud/perf-kit/shopify-perf-kit-1bd852a.min.js";function Fr({shop:e}){let t=react.useRef(!1),{subscribe:r,register:o}=G(),{ready:a}=o("Internal_Shopify_Perf_Kit"),n=hydrogenReact.useLoadScript(vn,{attributes:{id:"perfkit","data-application":"hydrogen","data-shop-id":hydrogenReact.parseGid(e.shopId).id.toString(),"data-storefront-id":e.hydrogenSubchannelId,"data-monorail-region":"global","data-spa-mode":"true","data-resource-timing-sampling-rate":"100"}});return react.useEffect(()=>{n!=="done"||t.current||(t.current=!0,r(L.PAGE_VIEWED,()=>{window.PerfKit?.navigate();}),r(L.PRODUCT_VIEWED,()=>{window.PerfKit?.setPageType("product");}),r(L.COLLECTION_VIEWED,()=>{window.PerfKit?.setPageType("collection");}),r(L.SEARCH_VIEWED,()=>{window.PerfKit?.setPageType("search");}),r(L.CART_VIEWED,()=>{window.PerfKit?.setPageType("cart");}),a());},[r,a,n]),null}var On={canTrack:()=>!1,cart:null,customData:{},prevCart:null,publish:()=>{},shop:null,subscribe:()=>{},register:()=>({ready:()=>{}})},Gr=react.createContext(On),Ge=new Map,we={};function Wr(){return Object.values(we).every(Boolean)}function $r(e,t){Ge.has(e)||Ge.set(e,new Map),Ge.get(e)?.set(t.toString(),t);}var We=new Map;function qr(e,t){if(!Wr()){We.set(e,t);return}jr(e,t);}function jr(e,t){(Ge.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 Hr(e){return we.hasOwnProperty(e)||(we[e]=!1),{ready:()=>{we[e]=!0,Wr()&&We.size>0&&(We.forEach((t,r)=>{jr(r,t);}),We.clear());}}}function Qr(){try{return window.Shopify.customerPrivacy.analyticsProcessingAllowed()}catch{}return !1}function Br(e,t){return `[h2:error:Analytics.Provider] - ${e} is required. Make sure ${t} is defined in your environment variables. See https://h2o.fyi/analytics/consent to learn how to setup environment variables in the Shopify admin.`}function Dn({canTrack:e,cart:t,children:r,consent:o,customData:a={},shop:n=null,disableThrowOnError:i=!1,cookieDomain:u}){let c=react.useRef(!1),{shop:s}=xn(n),[l,y]=react.useState(!!e),[m,d]=react.useState({cart:null,prevCart:null}),[p,h]=react.useState(e?()=>e:()=>Qr);if(s)if(/\/68817551382$/.test(s.shopId))Wt("[h2:error:Analytics.Provider] - Mock shop is used. Analytics will not work properly.");else {if(!o.checkoutDomain){let f=Br("consent.checkoutDomain","PUBLIC_CHECKOUT_DOMAIN");nt(f);}if(!o.storefrontAccessToken){let f=Br("consent.storefrontAccessToken","PUBLIC_STOREFRONT_API_TOKEN");nt(f);}}let g=react.useMemo(()=>({canTrack:p,...m,customData:a,publish:p()?qr:()=>{},shop:s,subscribe:$r,register:Hr}),[l,p(),p,JSON.stringify(p),m,m.cart?.updatedAt,m.prevCart,qr,$r,a,s,Hr,JSON.stringify(we)]);return jsxRuntime.jsxs(Gr.Provider,{value:g,children:[r,!!s&&jsxRuntime.jsx(Ir,{}),!!s&&!!t&&jsxRuntime.jsx(Mr,{cart:t,setCarts:d}),!!s&&o.checkoutDomain&&jsxRuntime.jsx(Lr,{consent:o,onReady:()=>{c.current=!0,y(!0),h(()=>Qr);},domain:u}),!!s&&jsxRuntime.jsx(Fr,{shop:s})]})}function G(){let e=react.useContext(Gr);if(!e)throw new Error("[h2:error:useAnalytics] 'useAnalytics()' must be a descendent of <AnalyticsProvider/>");return e}function xn(e){let[t,r]=react.useState(null);return react.useEffect(()=>(Promise.resolve(e).then(r),()=>{}),[r,e]),{shop:t}}async function kn({storefront:e,publicStorefrontId:t="0"}){return e.query(Ln,{cache:e.CacheLong()}).then(({shop:r,localization:o})=>({shopId:r.id,acceptedLanguage:o.language.isoCode,currency:o.country.currency.isoCode,hydrogenSubchannelId:t}))}var Ln=`#graphql
|
|
627
627
|
query ShopData(
|
|
628
628
|
$country: CountryCode
|
|
629
629
|
$language: LanguageCode
|
|
@@ -642,7 +642,7 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
642
642
|
}
|
|
643
643
|
}
|
|
644
644
|
}
|
|
645
|
-
`,
|
|
645
|
+
`,_n={CartView:Rr,CollectionView:wr,CustomView:Or,ProductView:br,Provider:Dn,SearchView:Er};var Mn=function(e){return jsxRuntime.jsx(hydrogenReact.RichText,{...e,components:{link:({node:t})=>jsxRuntime.jsx(react$1.Link,{to:t.url,title:t.title,target:t.target,prefetch:"intent",children:t.children}),...e.components}})};//! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartCreate
|
|
646
646
|
//! @see https://shopify.dev/docs/api/storefront/latest/queries/cart
|
|
647
647
|
//! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartLinesAdd
|
|
648
648
|
//! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartLinesUpdate
|
|
@@ -652,140 +652,141 @@ API response error: ${t.status}`,s=new z(c,{query:a,queryVariables:i,cause:{erro
|
|
|
652
652
|
//! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartNoteUpdate
|
|
653
653
|
//! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartSelectedDeliveryOptionsUpdate
|
|
654
654
|
//! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartMetafieldsSet
|
|
655
|
-
//! @see https://shopify.dev/docs/api/storefront/2024-
|
|
655
|
+
//! @see https://shopify.dev/docs/api/storefront/2024-07/mutations/cartMetafieldDelete
|
|
656
656
|
|
|
657
|
-
Object.defineProperty(exports,
|
|
657
|
+
Object.defineProperty(exports, "AnalyticsEventName", {
|
|
658
658
|
enumerable: true,
|
|
659
659
|
get: function () { return hydrogenReact.AnalyticsEventName; }
|
|
660
660
|
});
|
|
661
|
-
Object.defineProperty(exports,
|
|
661
|
+
Object.defineProperty(exports, "AnalyticsPageType", {
|
|
662
662
|
enumerable: true,
|
|
663
663
|
get: function () { return hydrogenReact.AnalyticsPageType; }
|
|
664
664
|
});
|
|
665
|
-
Object.defineProperty(exports,
|
|
665
|
+
Object.defineProperty(exports, "ExternalVideo", {
|
|
666
666
|
enumerable: true,
|
|
667
667
|
get: function () { return hydrogenReact.ExternalVideo; }
|
|
668
668
|
});
|
|
669
|
-
Object.defineProperty(exports,
|
|
669
|
+
Object.defineProperty(exports, "IMAGE_FRAGMENT", {
|
|
670
670
|
enumerable: true,
|
|
671
671
|
get: function () { return hydrogenReact.IMAGE_FRAGMENT; }
|
|
672
672
|
});
|
|
673
|
-
Object.defineProperty(exports,
|
|
673
|
+
Object.defineProperty(exports, "Image", {
|
|
674
674
|
enumerable: true,
|
|
675
675
|
get: function () { return hydrogenReact.Image; }
|
|
676
676
|
});
|
|
677
|
-
Object.defineProperty(exports,
|
|
677
|
+
Object.defineProperty(exports, "MediaFile", {
|
|
678
678
|
enumerable: true,
|
|
679
679
|
get: function () { return hydrogenReact.MediaFile; }
|
|
680
680
|
});
|
|
681
|
-
Object.defineProperty(exports,
|
|
681
|
+
Object.defineProperty(exports, "ModelViewer", {
|
|
682
682
|
enumerable: true,
|
|
683
683
|
get: function () { return hydrogenReact.ModelViewer; }
|
|
684
684
|
});
|
|
685
|
-
Object.defineProperty(exports,
|
|
685
|
+
Object.defineProperty(exports, "Money", {
|
|
686
686
|
enumerable: true,
|
|
687
687
|
get: function () { return hydrogenReact.Money; }
|
|
688
688
|
});
|
|
689
|
-
Object.defineProperty(exports,
|
|
689
|
+
Object.defineProperty(exports, "ShopifySalesChannel", {
|
|
690
690
|
enumerable: true,
|
|
691
691
|
get: function () { return hydrogenReact.ShopifySalesChannel; }
|
|
692
692
|
});
|
|
693
|
-
Object.defineProperty(exports,
|
|
693
|
+
Object.defineProperty(exports, "Video", {
|
|
694
694
|
enumerable: true,
|
|
695
695
|
get: function () { return hydrogenReact.Video; }
|
|
696
696
|
});
|
|
697
|
-
Object.defineProperty(exports,
|
|
697
|
+
Object.defineProperty(exports, "customerAccountApiCustomScalars", {
|
|
698
698
|
enumerable: true,
|
|
699
699
|
get: function () { return hydrogenReact.customerAccountApiCustomScalars; }
|
|
700
700
|
});
|
|
701
|
-
Object.defineProperty(exports,
|
|
701
|
+
Object.defineProperty(exports, "flattenConnection", {
|
|
702
702
|
enumerable: true,
|
|
703
703
|
get: function () { return hydrogenReact.flattenConnection; }
|
|
704
704
|
});
|
|
705
|
-
Object.defineProperty(exports,
|
|
705
|
+
Object.defineProperty(exports, "getClientBrowserParameters", {
|
|
706
706
|
enumerable: true,
|
|
707
707
|
get: function () { return hydrogenReact.getClientBrowserParameters; }
|
|
708
708
|
});
|
|
709
|
-
Object.defineProperty(exports,
|
|
709
|
+
Object.defineProperty(exports, "getShopifyCookies", {
|
|
710
710
|
enumerable: true,
|
|
711
711
|
get: function () { return hydrogenReact.getShopifyCookies; }
|
|
712
712
|
});
|
|
713
|
-
Object.defineProperty(exports,
|
|
713
|
+
Object.defineProperty(exports, "parseGid", {
|
|
714
714
|
enumerable: true,
|
|
715
715
|
get: function () { return hydrogenReact.parseGid; }
|
|
716
716
|
});
|
|
717
|
-
Object.defineProperty(exports,
|
|
717
|
+
Object.defineProperty(exports, "parseMetafield", {
|
|
718
718
|
enumerable: true,
|
|
719
719
|
get: function () { return hydrogenReact.parseMetafield; }
|
|
720
720
|
});
|
|
721
|
-
Object.defineProperty(exports,
|
|
721
|
+
Object.defineProperty(exports, "sendShopifyAnalytics", {
|
|
722
722
|
enumerable: true,
|
|
723
723
|
get: function () { return hydrogenReact.sendShopifyAnalytics; }
|
|
724
724
|
});
|
|
725
|
-
Object.defineProperty(exports,
|
|
725
|
+
Object.defineProperty(exports, "storefrontApiCustomScalars", {
|
|
726
726
|
enumerable: true,
|
|
727
727
|
get: function () { return hydrogenReact.storefrontApiCustomScalars; }
|
|
728
728
|
});
|
|
729
|
-
Object.defineProperty(exports,
|
|
729
|
+
Object.defineProperty(exports, "useLoadScript", {
|
|
730
730
|
enumerable: true,
|
|
731
731
|
get: function () { return hydrogenReact.useLoadScript; }
|
|
732
732
|
});
|
|
733
|
-
Object.defineProperty(exports,
|
|
733
|
+
Object.defineProperty(exports, "useMoney", {
|
|
734
734
|
enumerable: true,
|
|
735
735
|
get: function () { return hydrogenReact.useMoney; }
|
|
736
736
|
});
|
|
737
|
-
Object.defineProperty(exports,
|
|
737
|
+
Object.defineProperty(exports, "useShopifyCookies", {
|
|
738
738
|
enumerable: true,
|
|
739
739
|
get: function () { return hydrogenReact.useShopifyCookies; }
|
|
740
740
|
});
|
|
741
|
-
exports.Analytics =
|
|
742
|
-
exports.AnalyticsEvent =
|
|
743
|
-
exports.CacheCustom =
|
|
744
|
-
exports.CacheLong =
|
|
745
|
-
exports.CacheNone =
|
|
746
|
-
exports.CacheShort =
|
|
747
|
-
exports.CartForm =
|
|
748
|
-
exports.InMemoryCache =
|
|
749
|
-
exports.OptimisticInput =
|
|
750
|
-
exports.Pagination =
|
|
751
|
-
exports.RichText =
|
|
752
|
-
exports.Script =
|
|
753
|
-
exports.Seo =
|
|
754
|
-
exports.ShopPayButton =
|
|
755
|
-
exports.VariantSelector =
|
|
741
|
+
exports.Analytics = _n;
|
|
742
|
+
exports.AnalyticsEvent = L;
|
|
743
|
+
exports.CacheCustom = Ye;
|
|
744
|
+
exports.CacheLong = Je;
|
|
745
|
+
exports.CacheNone = Ke;
|
|
746
|
+
exports.CacheShort = J;
|
|
747
|
+
exports.CartForm = B;
|
|
748
|
+
exports.InMemoryCache = it;
|
|
749
|
+
exports.OptimisticInput = Ka;
|
|
750
|
+
exports.Pagination = Fo;
|
|
751
|
+
exports.RichText = Mn;
|
|
752
|
+
exports.Script = Ba;
|
|
753
|
+
exports.Seo = Lo;
|
|
754
|
+
exports.ShopPayButton = Xa;
|
|
755
|
+
exports.VariantSelector = Ea;
|
|
756
756
|
exports.cartAttributesUpdateDefault = bt;
|
|
757
|
-
exports.cartBuyerIdentityUpdateDefault =
|
|
758
|
-
exports.cartCreateDefault =
|
|
759
|
-
exports.cartDiscountCodesUpdateDefault =
|
|
757
|
+
exports.cartBuyerIdentityUpdateDefault = Tt;
|
|
758
|
+
exports.cartCreateDefault = ht;
|
|
759
|
+
exports.cartDiscountCodesUpdateDefault = At;
|
|
760
760
|
exports.cartGetDefault = gt;
|
|
761
761
|
exports.cartGetIdDefault = ga;
|
|
762
|
-
exports.cartLinesAddDefault =
|
|
762
|
+
exports.cartLinesAddDefault = Ct;
|
|
763
763
|
exports.cartLinesRemoveDefault = St;
|
|
764
|
-
exports.cartLinesUpdateDefault =
|
|
765
|
-
exports.cartMetafieldDeleteDefault =
|
|
766
|
-
exports.cartMetafieldsSetDefault =
|
|
767
|
-
exports.cartNoteUpdateDefault =
|
|
768
|
-
exports.cartSelectedDeliveryOptionsUpdateDefault =
|
|
769
|
-
exports.cartSetIdDefault =
|
|
770
|
-
exports.changelogHandler =
|
|
764
|
+
exports.cartLinesUpdateDefault = Pt;
|
|
765
|
+
exports.cartMetafieldDeleteDefault = Rt;
|
|
766
|
+
exports.cartMetafieldsSetDefault = wt;
|
|
767
|
+
exports.cartNoteUpdateDefault = vt;
|
|
768
|
+
exports.cartSelectedDeliveryOptionsUpdateDefault = It;
|
|
769
|
+
exports.cartSetIdDefault = Pa;
|
|
770
|
+
exports.changelogHandler = Xo;
|
|
771
771
|
exports.createCartHandler = Sa;
|
|
772
|
-
exports.createContentSecurityPolicy =
|
|
773
|
-
exports.createCustomerAccountClient =
|
|
774
|
-
exports.createStorefrontClient =
|
|
775
|
-
exports.createWithCache =
|
|
776
|
-
exports.formatAPIResult =
|
|
772
|
+
exports.createContentSecurityPolicy = $a;
|
|
773
|
+
exports.createCustomerAccountClient = Jo;
|
|
774
|
+
exports.createStorefrontClient = Pi;
|
|
775
|
+
exports.createWithCache = go;
|
|
776
|
+
exports.formatAPIResult = S;
|
|
777
777
|
exports.generateCacheControlHeader = fe;
|
|
778
|
-
exports.getCustomerPrivacy =
|
|
779
|
-
exports.getPaginationVariables =
|
|
780
|
-
exports.getSelectedProductOptions =
|
|
781
|
-
exports.getSeoMeta =
|
|
782
|
-
exports.getShopAnalytics =
|
|
783
|
-
exports.graphiqlLoader =
|
|
784
|
-
exports.storefrontRedirect =
|
|
785
|
-
exports.useAnalytics =
|
|
786
|
-
exports.useCustomerPrivacy =
|
|
787
|
-
exports.useNonce =
|
|
788
|
-
exports.useOptimisticCart =
|
|
789
|
-
exports.useOptimisticData =
|
|
778
|
+
exports.getCustomerPrivacy = Dt;
|
|
779
|
+
exports.getPaginationVariables = qo;
|
|
780
|
+
exports.getSelectedProductOptions = Oa;
|
|
781
|
+
exports.getSeoMeta = _o;
|
|
782
|
+
exports.getShopAnalytics = kn;
|
|
783
|
+
exports.graphiqlLoader = Ao;
|
|
784
|
+
exports.storefrontRedirect = Po;
|
|
785
|
+
exports.useAnalytics = G;
|
|
786
|
+
exports.useCustomerPrivacy = Ot;
|
|
787
|
+
exports.useNonce = Et;
|
|
788
|
+
exports.useOptimisticCart = Ta;
|
|
789
|
+
exports.useOptimisticData = ja;
|
|
790
|
+
exports.useOptimisticVariant = _a;
|
|
790
791
|
//# sourceMappingURL=out.js.map
|
|
791
792
|
//# sourceMappingURL=index.cjs.map
|