@shopify/hydrogen-react 2024.7.4 → 2024.7.5

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.
@@ -1,4 +1,4 @@
1
- const version = "2024.7.4";
1
+ const version = "2024.7.5";
2
2
  export {
3
3
  version
4
4
  };
@@ -1,4 +1,4 @@
1
- const version = "2024.7.4";
1
+ const version = "2024.7.5";
2
2
  export {
3
3
  version
4
4
  };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const version = "2024.7.4";
3
+ const version = "2024.7.5";
4
4
  exports.version = version;
5
5
  //# sourceMappingURL=package.json.js.map
@@ -1,4 +1,4 @@
1
- const version = "2024.7.4";
1
+ const version = "2024.7.5";
2
2
  export {
3
3
  version
4
4
  };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const version = "2024.7.4";
3
+ const version = "2024.7.5";
4
4
  exports.version = version;
5
5
  //# sourceMappingURL=package.json.js.map
@@ -1,4 +1,4 @@
1
- const version = "2024.7.4";
1
+ const version = "2024.7.5";
2
2
  export {
3
3
  version
4
4
  };
@@ -2405,7 +2405,7 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
2405
2405
  }
2406
2406
  return false;
2407
2407
  }
2408
- const version = "2024.7.4";
2408
+ const version = "2024.7.5";
2409
2409
  const SCHEMA_ID = "custom_storefront_customer_tracking/1.2";
2410
2410
  const PAGE_RENDERED_EVENT_NAME = "page_rendered";
2411
2411
  const COLLECTION_PAGE_RENDERED_EVENT_NAME = "collection_page_rendered";
@@ -269,7 +269,7 @@
269
269
  height
270
270
  }
271
271
  `,ae="2024-07",Pr="mock.shop",Re=e=>e.includes(Pr);function Rr({storeDomain:e,privateStorefrontToken:t,publicStorefrontToken:r,storefrontApiVersion:n=ae,contentType:a}){if(!e)throw new Error(De+"`storeDomain` is required when creating a new Storefront client in production.");n!==ae&&Dr(`The Storefront API version that you're using is different than the version this build of Hydrogen React is targeting.
272
- You may run into unexpected errors if these versions don't match. Received version: "${n}"; expected version "${ae}"`);const i=s=>{const o=(s==null?void 0:s.storeDomain)??e;return o.includes("://")?o:`https://${o}`};return{getShopifyDomain:i,getStorefrontApiUrl(s){const o=i(s),u=o+(o.endsWith("/")?"api":"/api");return Re(o)?u:`${u}/${(s==null?void 0:s.storefrontApiVersion)??n}/graphql.json`},getPrivateTokenHeaders(s){if(!t&&!(s!=null&&s.privateStorefrontToken)&&!Re(e))throw new Error(De+"You did not pass in a `privateStorefrontToken` while using `createStorefrontClient()` or `getPrivateTokenHeaders()`");return{"content-type":((s==null?void 0:s.contentType)??a)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-react","X-SDK-Variant-Source":"react","X-SDK-Version":n,"Shopify-Storefront-Private-Token":(s==null?void 0:s.privateStorefrontToken)??t??"",...s!=null&&s.buyerIp?{"Shopify-Storefront-Buyer-IP":s.buyerIp}:{}}},getPublicTokenHeaders(s){if(!r&&!(s!=null&&s.publicStorefrontToken)&&!Re(e))throw new Error(De+"You did not pass in a `publicStorefrontToken` while using `createStorefrontClient()` or `getPublicTokenHeaders()`");const o=(s==null?void 0:s.contentType)??a??"json";return Xe(o,n,(s==null?void 0:s.publicStorefrontToken)??r??"")}}}function Xe(e,t,r){return{"content-type":e==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-react","X-SDK-Variant-Source":"react","X-SDK-Version":t,"X-Shopify-Storefront-Access-Token":r}}const ze=new Set,De="[h2:error:createStorefrontClient] ",Dr=(e,t="warn")=>{ze.has(e)||(console[t](`[h2:${t}:createStorefrontClient] `+e),ze.add(e))},et={storeDomain:"test",storefrontToken:"abc123",storefrontApiVersion:ae,countryIsoCode:"US",languageIsoCode:"EN",getStorefrontApiUrl(){return""},getPublicTokenHeaders(){return{}},getShopifyDomain(){return""}},tt=c.createContext(et);function kr({children:e,...t}){if(!t.countryIsoCode||!t.languageIsoCode||!t.storeDomain||!t.storefrontToken||!t.storefrontApiVersion)throw new Error("Please provide the necessary props to '<ShopifyProvider/>'");t.storefrontApiVersion!==ae&&console.warn(`<ShopifyProvider/>: This version of Hydrogen React is built for Shopify's Storefront API version ${ae}, but it looks like you're using version ${t.storefrontApiVersion}. There may be issues or bugs if you use a mismatched version of Hydrogen React and the Storefront API.`);const r=c.useMemo(()=>{function n(a){const i=(a==null?void 0:a.storeDomain)??t.storeDomain;return i.includes("://")?i:`https://${i}`}return{...t,getPublicTokenHeaders(a){return Xe(a.contentType,t.storefrontApiVersion,a.storefrontToken??t.storefrontToken)},getShopifyDomain:n,getStorefrontApiUrl(a){const i=n({storeDomain:(a==null?void 0:a.storeDomain)??t.storeDomain});return`${i}${i.endsWith("/")?"":"/"}api/${(a==null?void 0:a.storefrontApiVersion)??t.storefrontApiVersion}/graphql.json`}}},[t]);return React.createElement(tt.Provider,{value:r},e)}function ce(){const e=c.useContext(tt);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}const ke="shopifyCartId",rt="Shopify-Storefront-Id",nt="Shopify-Storefront-Y",at="Shopify-Storefront-S",K="_shopify_y",X="_shopify_s";var Or=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function Ur(e){let t={},r,n,a=0,i=e.split(/;\s*/g),s,o;for(;a<i.length;a++)if(n=i[a],r=n.indexOf("="),~r){if(s=n.substring(0,r++).trim(),o=n.substring(r).trim(),o[0]==='"'&&(o=o.substring(1,o.length-1)),~o.indexOf("%"))try{o=decodeURIComponent(o)}catch{}Or.has(n=s.toLowerCase())?n==="expires"?t.expires=new Date(o):n==="max-age"?t.maxage=+o:t[n]=o:t[s]=o}else(s=n.trim().toLowerCase())&&(s==="httponly"||s==="secure")&&(t[s]=!0);return t}function Nr(e,t,r={}){let n=e+"="+encodeURIComponent(t);return r.expires&&(n+="; Expires="+new Date(r.expires).toUTCString()),r.maxage!=null&&r.maxage>=0&&(n+="; Max-Age="+(r.maxage|0)),r.domain&&(n+="; Domain="+r.domain),r.path&&(n+="; Path="+r.path),r.samesite&&(n+="; SameSite="+r.samesite),(r.secure||r.samesite==="None")&&(n+="; Secure"),r.httponly&&(n+="; HttpOnly"),n}const it="xxxx-4xxx-xxxx-xxxxxxxxxxxx";function Se(){let e="";try{const t=window.crypto,r=new Uint16Array(31);t.getRandomValues(r);let n=0;e=it.replace(/[x]/g,a=>{const i=r[n]%16,s=a==="x"?i:i&3|8;return n++,s.toString(16)}).toUpperCase()}catch{e=it.replace(/[x]/g,r=>{const n=Math.random()*16|0;return(r==="x"?n:n&3|8).toString(16)}).toUpperCase()}return`${Vr()}-${e}`}function Vr(){let e=0,t=0;e=new Date().getTime()>>>0;try{t=performance.now()>>>0}catch{t=0}return Math.abs(e+t).toString(16).toLowerCase().padStart(8,"0")}function Te(e){const t=Ur(e);return{[K]:t[K]||"",[X]:t[X]||""}}function Mr(){const{storefrontId:e,getPublicTokenHeaders:t,getStorefrontApiUrl:r}=ce();return c.useCallback(({query:n,variables:a})=>{const i=t({contentType:"json"});e&&(i[rt]=e);const s=Te(document.cookie);return i[nt]=s[K],i[at]=s[X],fetch(r(),{method:"POST",headers:i,body:JSON.stringify({query:n.toString(),variables:a})}).then(o=>o.json()).catch(o=>({data:void 0,errors:o==null?void 0:o.toString()}))},[t,e,r])}function Lr({numCartLines:e,cartFragment:t,countryCode:r="US",languageCode:n="EN"}){const a=Mr(),i=c.useCallback(h=>a({query:br(t),variables:{id:h,numCartLines:e,country:r,language:n}}),[a,t,e,r,n]),s=c.useCallback(h=>a({query:_r(t),variables:{input:h,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),o=c.useCallback((h,C)=>a({query:Er(t),variables:{cartId:h,lines:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),u=c.useCallback((h,C)=>a({query:Sr(t),variables:{cartId:h,lines:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),d=c.useCallback((h,C)=>a({query:Cr(t),variables:{cartId:h,lines:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),g=c.useCallback((h,C)=>a({query:Tr(t),variables:{cartId:h,note:C,numCartLines:e,country:r,language:n}}),[a,t,e,r,n]),f=c.useCallback((h,C)=>a({query:Ar(t),variables:{cartId:h,buyerIdentity:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),y=c.useCallback((h,C)=>a({query:wr(t),variables:{cartId:h,attributes:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),l=c.useCallback((h,C)=>a({query:Ir(t),variables:{cartId:h,discountCodes:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]);return c.useMemo(()=>({cartFetch:i,cartCreate:s,cartLineAdd:o,cartLineUpdate:u,cartLineRemove:d,noteUpdate:g,buyerIdentityUpdate:f,cartAttributesUpdate:y,discountCodesUpdate:l,cartFragment:t}),[i,s,o,u,d,g,f,y,l,t])}function Y(e,t){return{entry:[...(t==null?void 0:t.entryActions)||[],re({lastValidCart:r=>r==null?void 0:r.cart}),"onCartActionEntry","onCartActionOptimisticUI",e],on:{RESOLVE:{target:(t==null?void 0:t.resolveTarget)||"idle",actions:[re({prevCart:r=>r==null?void 0:r.lastValidCart,cart:(r,n)=>{var a;return(a=n==null?void 0:n.payload)==null?void 0:a.cart},rawCartResult:(r,n)=>{var a;return(a=n==null?void 0:n.payload)==null?void 0:a.rawCartResult},errors:r=>{}})]},ERROR:{target:(t==null?void 0:t.errorTarget)||"error",actions:[re({prevCart:r=>r==null?void 0:r.lastValidCart,cart:r=>r==null?void 0:r.lastValidCart,errors:(r,n)=>{var a;return(a=n==null?void 0:n.payload)==null?void 0:a.errors}})]},CART_COMPLETED:{target:"cartCompleted",actions:re({prevCart:r=>{},cart:r=>{},lastValidCart:r=>{},rawCartResult:r=>{},errors:r=>{}})}},exit:["onCartActionComplete",...(t==null?void 0:t.exitActions)||[]]}}const ue={CART_FETCH:{target:"cartFetching"},CART_CREATE:{target:"cartCreating"},CART_SET:{target:"idle",actions:[re({rawCartResult:(e,t)=>t.payload.cart,cart:(e,t)=>Oe(t.payload.cart)})]}},ot={CARTLINE_ADD:{target:"cartLineAdding"},CARTLINE_UPDATE:{target:"cartLineUpdating"},CARTLINE_REMOVE:{target:"cartLineRemoving"},NOTE_UPDATE:{target:"noteUpdating"},BUYER_IDENTITY_UPDATE:{target:"buyerIdentityUpdating"},CART_ATTRIBUTES_UPDATE:{target:"cartAttributesUpdating"},DISCOUNT_CODES_UPDATE:{target:"discountCodesUpdating"}};function xr(e){return We({id:"Cart",initial:e?"idle":"uninitialized",context:{cart:e&&Oe(e)},states:{uninitialized:{on:ue},cartCompleted:{on:ue},initializationError:{on:ue},idle:{on:{...ue,...ot}},error:{on:{...ue,...ot}},cartFetching:Y("cartFetchAction",{errorTarget:"initializationError"}),cartCreating:Y("cartCreateAction",{errorTarget:"initializationError"}),cartLineRemoving:Y("cartLineRemoveAction"),cartLineUpdating:Y("cartLineUpdateAction"),cartLineAdding:Y("cartLineAddAction"),noteUpdating:Y("noteUpdateAction"),buyerIdentityUpdating:Y("buyerIdentityUpdateAction"),cartAttributesUpdating:Y("cartAttributesUpdateAction"),discountCodesUpdating:Y("discountCodesUpdateAction")}})}function Fr({numCartLines:e,onCartActionEntry:t,onCartActionOptimisticUI:r,onCartActionComplete:n,data:a,cartFragment:i,countryCode:s,languageCode:o}){const{cartFetch:u,cartCreate:d,cartLineAdd:g,cartLineUpdate:f,cartLineRemove:y,noteUpdate:l,buyerIdentityUpdate:h,cartAttributesUpdate:C,discountCodesUpdate:T}=Lr({numCartLines:e,cartFragment:i,countryCode:s,languageCode:o}),w=c.useMemo(()=>xr(a),[a]),[b,I,D]=yr(w,{actions:{cartFetchAction:async(m,p)=>{var A;if(p.type!=="CART_FETCH")return;const{data:_,errors:R}=await u((A=p==null?void 0:p.payload)==null?void 0:A.cartId),P=W(p,_==null?void 0:_.cart,R);I(P)},cartCreateAction:async(m,p)=>{var A;if(p.type!=="CART_CREATE")return;const{data:_,errors:R}=await d(p==null?void 0:p.payload),P=W(p,(A=_==null?void 0:_.cartCreate)==null?void 0:A.cart,R);I(P)},cartLineAddAction:async(m,p)=>{var A,v;if(p.type!=="CARTLINE_ADD"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:R}=await g(m.cart.id,p.payload.lines),P=W(p,(v=_==null?void 0:_.cartLinesAdd)==null?void 0:v.cart,R);I(P)},cartLineUpdateAction:async(m,p)=>{var A,v;if(p.type!=="CARTLINE_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:R}=await f(m.cart.id,p.payload.lines),P=W(p,(v=_==null?void 0:_.cartLinesUpdate)==null?void 0:v.cart,R);I(P)},cartLineRemoveAction:async(m,p)=>{var A,v;if(p.type!=="CARTLINE_REMOVE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:R}=await y(m.cart.id,p.payload.lines),P=W(p,(v=_==null?void 0:_.cartLinesRemove)==null?void 0:v.cart,R);I(P)},noteUpdateAction:async(m,p)=>{var A,v;if(p.type!=="NOTE_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:R}=await l(m.cart.id,p.payload.note),P=W(p,(v=_==null?void 0:_.cartNoteUpdate)==null?void 0:v.cart,R);I(P)},buyerIdentityUpdateAction:async(m,p)=>{var A,v;if(p.type!=="BUYER_IDENTITY_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:R}=await h(m.cart.id,p.payload.buyerIdentity),P=W(p,(v=_==null?void 0:_.cartBuyerIdentityUpdate)==null?void 0:v.cart,R);I(P)},cartAttributesUpdateAction:async(m,p)=>{var A,v;if(p.type!=="CART_ATTRIBUTES_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:R}=await C(m.cart.id,p.payload.attributes),P=W(p,(v=_==null?void 0:_.cartAttributesUpdate)==null?void 0:v.cart,R);I(P)},discountCodesUpdateAction:async(m,p)=>{var A,v;if(p.type!=="DISCOUNT_CODES_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:R}=await T(m.cart.id,p.payload.discountCodes),P=W(p,(v=_==null?void 0:_.cartDiscountCodesUpdate)==null?void 0:v.cart,R);I(P)},...t&&{onCartActionEntry:(m,p)=>{$r(p)&&t(m,p)}},...r&&{onCartActionOptimisticUI:re((m,p)=>r(m,p))},...n&&{onCartActionComplete:(m,p)=>{qr(p)&&n(m,p)}}}});return c.useMemo(()=>[b,I,D],[b,I,D])}function Oe(e){return{...e,lines:J(e==null?void 0:e.lines),note:e.note??void 0}}function W(e,t,r){return r?{type:"ERROR",payload:{errors:r,cartActionEvent:e}}:t?{type:"RESOLVE",payload:{cart:Oe(t),rawCartResult:t,cartActionEvent:e}}:{type:"CART_COMPLETED",payload:{cartActionEvent:e}}}function $r(e){return e.type==="CART_CREATE"||e.type==="CARTLINE_ADD"||e.type==="CARTLINE_UPDATE"||e.type==="CARTLINE_REMOVE"||e.type==="NOTE_UPDATE"||e.type==="BUYER_IDENTITY_UPDATE"||e.type==="CART_ATTRIBUTES_UPDATE"||e.type==="DISCOUNT_CODES_UPDATE"}function qr(e){return e.type==="RESOLVE"||e.type==="ERROR"||e.type==="CART_COMPLETED"}const st=c.createContext(null);function ie(){const e=c.useContext(st);if(!e)throw new Error("Expected a Cart Context, but no Cart Context was found");return e}function Hr({children:e,numCartLines:t,onCreate:r,onLineAdd:n,onLineRemove:a,onLineUpdate:i,onNoteUpdate:s,onBuyerIdentityUpdate:o,onAttributesUpdate:u,onDiscountCodesUpdate:d,onCreateComplete:g,onLineAddComplete:f,onLineRemoveComplete:y,onLineUpdateComplete:l,onNoteUpdateComplete:h,onBuyerIdentityUpdateComplete:C,onAttributesUpdateComplete:T,onDiscountCodesUpdateComplete:w,data:b,cartFragment:I=vr,customerAccessToken:D,countryCode:m,languageCode:p}){var Mt,Lt,xt,Ft,$t,qt,Ht;const _=ce();if(!_)throw new Error("<CartProvider> needs to be a descendant of <ShopifyProvider>");m=(m??_.countryIsoCode??"US").toUpperCase(),p=(p??_.languageIsoCode??"EN").toUpperCase(),m&&(m=m.toUpperCase());const[R,P]=c.useState(m),[A,v]=c.useState(D),H=c.useRef(!1);(R!==m||A!==D)&&(P(m),v(D),H.current=!1);const[k,j]=Fr({numCartLines:t,data:b,cartFragment:I,countryCode:m,languageCode:p,onCartActionEntry(S,V){try{switch(V.type){case"CART_CREATE":return r==null?void 0:r();case"CARTLINE_ADD":return n==null?void 0:n();case"CARTLINE_REMOVE":return a==null?void 0:a();case"CARTLINE_UPDATE":return i==null?void 0:i();case"NOTE_UPDATE":return s==null?void 0:s();case"BUYER_IDENTITY_UPDATE":return o==null?void 0:o();case"CART_ATTRIBUTES_UPDATE":return u==null?void 0:u();case"DISCOUNT_CODES_UPDATE":return d==null?void 0:d()}}catch(L){console.error("Cart entry action failed",L)}},onCartActionOptimisticUI(S,V){var L,Q,M,Ee;if(!S.cart)return{...S};switch(V.type){case"CARTLINE_REMOVE":return{...S,cart:{...S.cart,lines:(Q=(L=S==null?void 0:S.cart)==null?void 0:L.lines)==null?void 0:Q.filter(x=>(x==null?void 0:x.id)&&!V.payload.lines.includes(x==null?void 0:x.id))}};case"CARTLINE_UPDATE":return{...S,cart:{...S.cart,lines:(Ee=(M=S==null?void 0:S.cart)==null?void 0:M.lines)==null?void 0:Ee.map(x=>{const Fe=V.payload.lines.find(({id:ea})=>ea===(x==null?void 0:x.id));return Fe&&Fe.quantity?{...x,quantity:Fe.quantity}:x})}}}return{...S}},onCartActionComplete(S,V){const L=V.payload.cartActionEvent;try{switch(V.type){case"RESOLVE":switch(L.type){case"CART_CREATE":return g==null?void 0:g();case"CARTLINE_ADD":return f==null?void 0:f();case"CARTLINE_REMOVE":return y==null?void 0:y();case"CARTLINE_UPDATE":return l==null?void 0:l();case"NOTE_UPDATE":return h==null?void 0:h();case"BUYER_IDENTITY_UPDATE":return Yr(S,L)&&(H.current=!0),C==null?void 0:C();case"CART_ATTRIBUTES_UPDATE":return T==null?void 0:T();case"DISCOUNT_CODES_UPDATE":return w==null?void 0:w()}}}catch(Q){console.error("onCartActionComplete failed",Q)}}}),z=c.useRef(!1),[ye,U]=c.useState(!1),se=k.matches("cartCompleted"),me=(k.value==="idle"||k.value==="error"||k.value==="cartCompleted")&&m!==((xt=(Lt=(Mt=k==null?void 0:k.context)==null?void 0:Mt.cart)==null?void 0:Lt.buyerIdentity)==null?void 0:xt.countryCode)&&!k.context.errors,pe=c.useRef(!1);c.useEffect(()=>{if(!z.current&&!pe.current){if(!b&&Ue("localStorage")){pe.current=!0;try{const S=window.localStorage.getItem(ke);S&&j({type:"CART_FETCH",payload:{cartId:S}})}catch(S){console.warn("error fetching cartId"),console.warn(S)}}z.current=!0,U(!0)}},[b,z,j]),c.useEffect(()=>{!me||H.current||j({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:{countryCode:m,customerAccessToken:D}}})},[m,D,me,H,j]);const B=c.useCallback(S=>{if(!z.current)return console.warn("Cart isn't ready yet");j(S)},[j]);c.useEffect(()=>{var S,V,L;if((V=(S=k==null?void 0:k.context)==null?void 0:S.cart)!=null&&V.id&&Ue("localStorage"))try{window.localStorage.setItem(ke,(L=k.context.cart)==null?void 0:L.id)}catch(Q){console.warn("Failed to save cartId to localStorage",Q)}},[($t=(Ft=k==null?void 0:k.context)==null?void 0:Ft.cart)==null?void 0:$t.id]),c.useEffect(()=>{if(se&&Ue("localStorage"))try{window.localStorage.removeItem(ke)}catch(S){console.warn("Failed to delete cartId from localStorage",S)}},[se]);const xe=c.useCallback(S=>{var V,L;m&&!((V=S.buyerIdentity)!=null&&V.countryCode)&&(S.buyerIdentity==null&&(S.buyerIdentity={}),S.buyerIdentity.countryCode=m),D&&!((L=S.buyerIdentity)!=null&&L.customerAccessToken)&&(S.buyerIdentity==null&&(S.buyerIdentity={}),S.buyerIdentity.customerAccessToken=D),B({type:"CART_CREATE",payload:S})},[m,D,B]),O=Br(k),zn=c.useMemo(()=>{var S,V,L,Q;return{...((S=O==null?void 0:O.context)==null?void 0:S.cart)??{lines:[],attributes:[]},status:jr(O.value),error:(V=O==null?void 0:O.context)==null?void 0:V.errors,totalQuantity:((Q=(L=O==null?void 0:O.context)==null?void 0:L.cart)==null?void 0:Q.totalQuantity)??0,cartCreate:xe,cartReady:ye,linesAdd(M){var Ee,x;(x=(Ee=O==null?void 0:O.context)==null?void 0:Ee.cart)!=null&&x.id?B({type:"CARTLINE_ADD",payload:{lines:M}}):xe({lines:M})},linesRemove(M){B({type:"CARTLINE_REMOVE",payload:{lines:M}})},linesUpdate(M){B({type:"CARTLINE_UPDATE",payload:{lines:M}})},noteUpdate(M){B({type:"NOTE_UPDATE",payload:{note:M}})},buyerIdentityUpdate(M){B({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:M}})},cartAttributesUpdate(M){B({type:"CART_ATTRIBUTES_UPDATE",payload:{attributes:M}})},discountCodesUpdate(M){B({type:"DISCOUNT_CODES_UPDATE",payload:{discountCodes:M}})},cartFragment:I}},[xe,ye,(qt=O==null?void 0:O.context)==null?void 0:qt.cart,(Ht=O==null?void 0:O.context)==null?void 0:Ht.errors,O.value,I,B]);return React.createElement(st.Provider,{value:zn},e)}function jr(e){switch(e){case"uninitialized":case"initializationError":return"uninitialized";case"idle":case"cartCompleted":case"error":return"idle";case"cartFetching":return"fetching";case"cartCreating":return"creating";case"cartLineAdding":case"cartLineRemoving":case"cartLineUpdating":case"noteUpdating":case"buyerIdentityUpdating":case"cartAttributesUpdating":case"discountCodesUpdating":return"updating"}}function Br(e){const[t,r]=c.useTransition(),[n,a]=c.useState(e),i=c.useRef(!1);t&&(i.current=!0);const s=c.useRef(!1);return!t&&i.current&&(s.current=!0),c.useEffect(()=>{r(()=>{s.current||a(e)})},[e]),s.current?e:n}function Ue(e){let t;try{t=window[e];const r="__storage_test__";return t.setItem(r,r),t.removeItem(r),!0}catch(r){return!!(r instanceof DOMException&&(r.code===22||r.code===1014||r.name==="QuotaExceededError"||r.name==="NS_ERROR_DOM_QUOTA_REACHED")&&t&&t.length!==0)}}function Yr(e,t){var r,n;return!!(t.payload.buyerIdentity.countryCode&&((n=(r=e.cart)==null?void 0:r.buyerIdentity)==null?void 0:n.countryCode)!==t.payload.buyerIdentity.countryCode)}const ct=c.createContext(null);function Wr({children:e,data:t,initialVariantId:r}){const n=c.useMemo(()=>J(t.variants??{}),[t.variants]);if(!Zr(n))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const a=c.useMemo(()=>Gr(n),[n]),[i,s]=c.useState(()=>dt(r,n)),[o,u]=c.useState(()=>ft(i));c.useEffect(()=>{const T=dt(r,n);s(T),u(ft(T))},[r,n]);const d=c.useCallback((T,w)=>{u(b=>{const I={...b,[T]:w};return s(lt(n,I)),I})},[u,n]),g=c.useCallback((T,w)=>{const b=lt(n,{...o,[T]:w});return(b==null?void 0:b.availableForSale)??!0},[o,n]),f=c.useMemo(()=>J(t.sellingPlanGroups??{}).map(T=>({...T,sellingPlans:J((T==null?void 0:T.sellingPlans)??{})})),[t.sellingPlanGroups]),[y,l]=c.useState(void 0),h=c.useMemo(()=>{var T,w;if(!(!i||!y)){if(!((T=i.sellingPlanAllocations)!=null&&T.nodes)&&!((w=i.sellingPlanAllocations)!=null&&w.edges))throw new Error("<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation");return J(i.sellingPlanAllocations).find(b=>{var I;return((I=b==null?void 0:b.sellingPlan)==null?void 0:I.id)===y.id})}},[i,y]),C=c.useMemo(()=>({product:t,variants:n,variantsConnection:t.variants,options:a,selectedVariant:i,setSelectedVariant:s,selectedOptions:o,setSelectedOption:d,setSelectedOptions:u,isOptionInStock:g,selectedSellingPlan:y,setSelectedSellingPlan:l,selectedSellingPlanAllocation:h,sellingPlanGroups:f,sellingPlanGroupsConnection:t.sellingPlanGroups}),[t,g,a,o,y,h,i,f,d,n]);return React.createElement(ct.Provider,{value:C},e)}function ut(){const e=c.useContext(ct);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function lt(e,t){var r,n;if(!(!e.length||((n=(r=e==null?void 0:e[0])==null?void 0:r.selectedOptions)==null?void 0:n.length)!==Object.keys(t).length))return e==null?void 0:e.find(a=>Object.entries(t).every(([i,s])=>{var o;return(o=a==null?void 0:a.selectedOptions)==null?void 0:o.some(u=>(u==null?void 0:u.name)===i&&(u==null?void 0:u.value)===s)}))}function Gr(e){const t=e.reduce((r,n)=>{var a;if(!n.selectedOptions)throw new Error("'getOptions' requires 'variant.selectedOptions'");return(a=n==null?void 0:n.selectedOptions)==null||a.forEach(i=>{r[(i==null?void 0:i.name)??""]=r[(i==null?void 0:i.name)??""]||new Set,r[(i==null?void 0:i.name)??""].add((i==null?void 0:i.value)??"")}),r},{});return Object.keys(t).map(r=>({name:r,values:Array.from(t[r])}))}function dt(e,t){if(e){const r=t.find(n=>(n==null?void 0:n.id)===e);return r||console.warn("<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID"),r}if(e===null)return null;if(e===void 0)return t.find(r=>r==null?void 0:r.availableForSale)||t[0]}function ft(e){return e!=null&&e.selectedOptions?e.selectedOptions.reduce((t,r)=>(t[(r==null?void 0:r.name)??""]=(r==null?void 0:r.value)??"",t),{}):{}}function Zr(e){return!(!e||!Array.isArray(e))}function Ae(e){const{as:t,onClick:r,defaultOnClick:n,children:a,buttonRef:i,...s}=e,o=c.useCallback(d=>{if(r){const g=r(d);if(typeof g=="boolean"&&g===!1||d!=null&&d.defaultPrevented)return}n==null||n(d)},[n,r]),u=t||"button";return React.createElement(u,{ref:i,onClick:o,...s},a)}function Qr(e){const[t,r]=c.useState(!1),{variantId:n,quantity:a=1,attributes:i,sellingPlanId:s,onClick:o,children:u,accessibleAddingToCartLabel:d,...g}=e,{status:f,linesAdd:y}=ie(),{selectedVariant:l}=ut(),h=n??(l==null?void 0:l.id)??"",C=n===null||h===""||l===null||t||g.disabled;c.useEffect(()=>{t&&f==="idle"&&r(!1)},[f,t]);const T=c.useCallback(()=>{r(!0),y([{quantity:a,merchandiseId:h||"",attributes:i,sellingPlanId:s}])},[y,a,h,i,s]);return N.createElement(N.Fragment,null,N.createElement(Ae,{...g,disabled:C,onClick:o,defaultOnClick:T},u),d?N.createElement("p",{style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"},role:"alert","aria-live":"assertive"},t?d:null):null)}const te={PAGE_VIEW:"PAGE_VIEW",ADD_TO_CART:"ADD_TO_CART",PAGE_VIEW_2:"PAGE_VIEW_2",COLLECTION_VIEW:"COLLECTION_VIEW",PRODUCT_VIEW:"PRODUCT_VIEW",SEARCH_VIEW:"SEARCH_VIEW"},we={article:"article",blog:"blog",captcha:"captcha",cart:"cart",collection:"collection",customersAccount:"customers/account",customersActivateAccount:"customers/activate_account",customersAddresses:"customers/addresses",customersLogin:"customers/login",customersOrder:"customers/order",customersRegister:"customers/register",customersResetPassword:"customers/reset_password",giftCard:"gift_card",home:"index",listCollections:"list-collections",forbidden:"403",notFound:"404",page:"page",password:"password",product:"product",policy:"policy",search:"search"},ht={hydrogen:"hydrogen",headless:"headless"},gt={hydrogen:"6167201",headless:"12875497473"};function q(e,t){return{schema_id:e,payload:t,metadata:{event_created_at_ms:Date.now()}}}function F(e){const t={id:"",resource:null,resourceId:null,search:"",searchParams:new URLSearchParams,hash:""};if(typeof e!="string")return t;try{const{search:r,searchParams:n,pathname:a,hash:i}=new URL(e),s=a.split("/"),o=s[s.length-1],u=s[s.length-2];return!o||!u?t:{id:`${o}${r}${i}`||"",resource:u??null,resourceId:o||null,search:r,searchParams:n,hash:i}}catch{return t}}function $(e,t){return typeof e!="object"?{}:(Object.entries(e).forEach(([r,n])=>{n&&(t[r]=n)}),t)}function Jr(e){return typeof document>"u"?(console.error(`${e} should only be used within the useEffect callback or event handlers`),!0):!1}const Kr="trekkie_storefront_page_view/1.4",Xr="myshopify.dev";function yt(e){const t=e,{id:r,resource:n}=F(t.resourceId),a=n?n.toLowerCase():void 0;return[q(Kr,$({pageType:t.pageType,customerId:parseInt(F(t.customerId).id||"0"),resourceType:a,resourceId:parseInt(r)},zr(t)))]}function zr(e){return{appClientId:e.shopifySalesChannel?gt[e.shopifySalesChannel]:gt.headless,isMerchantRequest:en(e.url),hydrogenSubchannelId:e.storefrontId||e.hydrogenSubchannelId||"0",isPersistentCookie:e.hasUserConsent,uniqToken:e.uniqueToken,visitToken:e.visitToken,microSessionId:Se(),microSessionCount:1,url:e.url,path:e.path,search:e.search,referrer:e.referrer,title:e.title,shopId:parseInt(F(e.shopId).id),currency:e.currency,contentLanguage:e.acceptedLanguage||"en"}}function en(e){if(typeof e!="string")return!1;const t=new URL(e).hostname;return t.indexOf(Xr)!==-1||t==="localhost"}const tn="2024.7.4",G="custom_storefront_customer_tracking/1.2",mt="page_rendered",pt="collection_page_rendered",Et="product_page_rendered",rn="product_added_to_cart",_t="search_submitted";function le(e){return{canonical_url:e.canonicalUrl||e.url,customer_id:parseInt(F(e.customerId).id||"0")}}function nn(e){const t=e,r=le(t),n=t.pageType,a=[];switch(a.push(q(G,$({event_name:mt,...r},Z(t)))),n){case we.collection:a.push(q(G,$({event_name:pt,...r,collection_name:t.collectionHandle,collection_id:parseInt(F(t.collectionId).id)},Z(t))));break;case we.product:a.push(q(G,$({event_name:Et,...r,products:Ne(t.products),total_value:t.totalValue},Z(t))));break;case we.search:a.push(q(G,$({event_name:_t,...r,search_string:t.searchString},Z(t))));break}return a}function an(e){const t=e,r=le(t);return[q(G,$({event_name:mt,...r},Z(t)))]}function on(e){const t=e,r=le(t);return[q(G,$({event_name:pt,...r,collection_name:t.collectionHandle,collection_id:parseInt(F(t.collectionId).id)},Z(t)))]}function sn(e){const t=e,r=le(t);return[q(G,$({event_name:Et,...r,products:Ne(t.products),total_value:t.totalValue},Z(t)))]}function cn(e){const t=e,r=le(t);return[q(G,$({event_name:_t,...r,search_string:t.searchString},Z(t)))]}function un(e){const t=e,r=F(t.cartId),n=r!=null&&r.id?`${r.id}`:null;return[q(G,$({event_name:rn,customerId:t.customerId,cart_token:n,total_value:t.totalValue,products:Ne(t.products),customer_id:parseInt(F(t.customerId).id||"0")},Z(t)))]}function Z(e){return{source:e.shopifySalesChannel||ht.headless,asset_version_id:e.assetVersionId||tn,hydrogenSubchannelId:e.storefrontId||e.hydrogenSubchannelId||"0",is_persistent_cookie:e.hasUserConsent,deprecated_visit_token:e.visitToken,unique_token:e.uniqueToken,event_time:Date.now(),event_id:Se(),event_source_url:e.url,referrer:e.referrer,user_agent:e.userAgent,navigation_type:e.navigationType,navigation_api:e.navigationApi,shop_id:parseInt(F(e.shopId).id),currency:e.currency,ccpa_enforced:e.ccpaEnforced||!1,gdpr_enforced:e.gdprEnforced||!1,gdpr_enforced_as_string:e.gdprEnforced?"true":"false",analytics_allowed:e.analyticsAllowed||!1,marketing_allowed:e.marketingAllowed||!1,sale_of_data_allowed:e.saleOfDataAllowed||!1}}function Ne(e){return e?e.map(t=>{const r=$({variant_gid:t.variantGid,category:t.category,sku:t.sku,product_id:parseInt(F(t.productGid).id),variant_id:parseInt(F(t.variantGid).id)},{product_gid:t.productGid,name:t.name,variant:t.variantName||"",brand:t.brand,price:parseFloat(t.price),quantity:Number(t.quantity||0)});return JSON.stringify(r)}):[]}function ln(e,t){const{eventName:r,payload:n}=e;if(!n.hasUserConsent)return Promise.resolve();let a=[];const i=n;return r===te.PAGE_VIEW?a=a.concat(yt(i),nn(i)):r===te.ADD_TO_CART?a=a.concat(un(n)):r===te.PAGE_VIEW_2?a=a.concat(yt(i),an(i)):r===te.COLLECTION_VIEW?a=a.concat(on(i)):r===te.PRODUCT_VIEW?a=a.concat(sn(i)):r===te.SEARCH_VIEW&&(a=a.concat(cn(i))),a.length?fn(a,t):Promise.resolve()}function dn(){return typeof window>"u"||!window.navigator?!1:/Chrome-Lighthouse/.test(window.navigator.userAgent)}const Ct="sendShopifyAnalytics request is unsuccessful";function fn(e,t){if(dn())return Promise.resolve();const r={events:e,metadata:{event_sent_at_ms:Date.now()}};try{return fetch(t?`https://${t}/.well-known/shopify/monorail/unstable/produce_batch`:"https://monorail-edge.shopifysvc.com/unstable/produce_batch",{method:"post",headers:{"content-type":"text/plain"},body:JSON.stringify(r)}).then(n=>{if(!n.ok)throw new Error("Response failed");return n.text()}).then(n=>{n&&JSON.parse(n).result.forEach(i=>{i.status!==200&&console.error(Ct,`
272
+ You may run into unexpected errors if these versions don't match. Received version: "${n}"; expected version "${ae}"`);const i=s=>{const o=(s==null?void 0:s.storeDomain)??e;return o.includes("://")?o:`https://${o}`};return{getShopifyDomain:i,getStorefrontApiUrl(s){const o=i(s),u=o+(o.endsWith("/")?"api":"/api");return Re(o)?u:`${u}/${(s==null?void 0:s.storefrontApiVersion)??n}/graphql.json`},getPrivateTokenHeaders(s){if(!t&&!(s!=null&&s.privateStorefrontToken)&&!Re(e))throw new Error(De+"You did not pass in a `privateStorefrontToken` while using `createStorefrontClient()` or `getPrivateTokenHeaders()`");return{"content-type":((s==null?void 0:s.contentType)??a)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-react","X-SDK-Variant-Source":"react","X-SDK-Version":n,"Shopify-Storefront-Private-Token":(s==null?void 0:s.privateStorefrontToken)??t??"",...s!=null&&s.buyerIp?{"Shopify-Storefront-Buyer-IP":s.buyerIp}:{}}},getPublicTokenHeaders(s){if(!r&&!(s!=null&&s.publicStorefrontToken)&&!Re(e))throw new Error(De+"You did not pass in a `publicStorefrontToken` while using `createStorefrontClient()` or `getPublicTokenHeaders()`");const o=(s==null?void 0:s.contentType)??a??"json";return Xe(o,n,(s==null?void 0:s.publicStorefrontToken)??r??"")}}}function Xe(e,t,r){return{"content-type":e==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-react","X-SDK-Variant-Source":"react","X-SDK-Version":t,"X-Shopify-Storefront-Access-Token":r}}const ze=new Set,De="[h2:error:createStorefrontClient] ",Dr=(e,t="warn")=>{ze.has(e)||(console[t](`[h2:${t}:createStorefrontClient] `+e),ze.add(e))},et={storeDomain:"test",storefrontToken:"abc123",storefrontApiVersion:ae,countryIsoCode:"US",languageIsoCode:"EN",getStorefrontApiUrl(){return""},getPublicTokenHeaders(){return{}},getShopifyDomain(){return""}},tt=c.createContext(et);function kr({children:e,...t}){if(!t.countryIsoCode||!t.languageIsoCode||!t.storeDomain||!t.storefrontToken||!t.storefrontApiVersion)throw new Error("Please provide the necessary props to '<ShopifyProvider/>'");t.storefrontApiVersion!==ae&&console.warn(`<ShopifyProvider/>: This version of Hydrogen React is built for Shopify's Storefront API version ${ae}, but it looks like you're using version ${t.storefrontApiVersion}. There may be issues or bugs if you use a mismatched version of Hydrogen React and the Storefront API.`);const r=c.useMemo(()=>{function n(a){const i=(a==null?void 0:a.storeDomain)??t.storeDomain;return i.includes("://")?i:`https://${i}`}return{...t,getPublicTokenHeaders(a){return Xe(a.contentType,t.storefrontApiVersion,a.storefrontToken??t.storefrontToken)},getShopifyDomain:n,getStorefrontApiUrl(a){const i=n({storeDomain:(a==null?void 0:a.storeDomain)??t.storeDomain});return`${i}${i.endsWith("/")?"":"/"}api/${(a==null?void 0:a.storefrontApiVersion)??t.storefrontApiVersion}/graphql.json`}}},[t]);return React.createElement(tt.Provider,{value:r},e)}function ce(){const e=c.useContext(tt);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}const ke="shopifyCartId",rt="Shopify-Storefront-Id",nt="Shopify-Storefront-Y",at="Shopify-Storefront-S",K="_shopify_y",X="_shopify_s";var Or=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function Ur(e){let t={},r,n,a=0,i=e.split(/;\s*/g),s,o;for(;a<i.length;a++)if(n=i[a],r=n.indexOf("="),~r){if(s=n.substring(0,r++).trim(),o=n.substring(r).trim(),o[0]==='"'&&(o=o.substring(1,o.length-1)),~o.indexOf("%"))try{o=decodeURIComponent(o)}catch{}Or.has(n=s.toLowerCase())?n==="expires"?t.expires=new Date(o):n==="max-age"?t.maxage=+o:t[n]=o:t[s]=o}else(s=n.trim().toLowerCase())&&(s==="httponly"||s==="secure")&&(t[s]=!0);return t}function Nr(e,t,r={}){let n=e+"="+encodeURIComponent(t);return r.expires&&(n+="; Expires="+new Date(r.expires).toUTCString()),r.maxage!=null&&r.maxage>=0&&(n+="; Max-Age="+(r.maxage|0)),r.domain&&(n+="; Domain="+r.domain),r.path&&(n+="; Path="+r.path),r.samesite&&(n+="; SameSite="+r.samesite),(r.secure||r.samesite==="None")&&(n+="; Secure"),r.httponly&&(n+="; HttpOnly"),n}const it="xxxx-4xxx-xxxx-xxxxxxxxxxxx";function Se(){let e="";try{const t=window.crypto,r=new Uint16Array(31);t.getRandomValues(r);let n=0;e=it.replace(/[x]/g,a=>{const i=r[n]%16,s=a==="x"?i:i&3|8;return n++,s.toString(16)}).toUpperCase()}catch{e=it.replace(/[x]/g,r=>{const n=Math.random()*16|0;return(r==="x"?n:n&3|8).toString(16)}).toUpperCase()}return`${Vr()}-${e}`}function Vr(){let e=0,t=0;e=new Date().getTime()>>>0;try{t=performance.now()>>>0}catch{t=0}return Math.abs(e+t).toString(16).toLowerCase().padStart(8,"0")}function Te(e){const t=Ur(e);return{[K]:t[K]||"",[X]:t[X]||""}}function Mr(){const{storefrontId:e,getPublicTokenHeaders:t,getStorefrontApiUrl:r}=ce();return c.useCallback(({query:n,variables:a})=>{const i=t({contentType:"json"});e&&(i[rt]=e);const s=Te(document.cookie);return i[nt]=s[K],i[at]=s[X],fetch(r(),{method:"POST",headers:i,body:JSON.stringify({query:n.toString(),variables:a})}).then(o=>o.json()).catch(o=>({data:void 0,errors:o==null?void 0:o.toString()}))},[t,e,r])}function Lr({numCartLines:e,cartFragment:t,countryCode:r="US",languageCode:n="EN"}){const a=Mr(),i=c.useCallback(h=>a({query:br(t),variables:{id:h,numCartLines:e,country:r,language:n}}),[a,t,e,r,n]),s=c.useCallback(h=>a({query:_r(t),variables:{input:h,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),o=c.useCallback((h,C)=>a({query:Er(t),variables:{cartId:h,lines:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),u=c.useCallback((h,C)=>a({query:Sr(t),variables:{cartId:h,lines:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),d=c.useCallback((h,C)=>a({query:Cr(t),variables:{cartId:h,lines:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),g=c.useCallback((h,C)=>a({query:Tr(t),variables:{cartId:h,note:C,numCartLines:e,country:r,language:n}}),[a,t,e,r,n]),f=c.useCallback((h,C)=>a({query:Ar(t),variables:{cartId:h,buyerIdentity:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),y=c.useCallback((h,C)=>a({query:wr(t),variables:{cartId:h,attributes:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),l=c.useCallback((h,C)=>a({query:Ir(t),variables:{cartId:h,discountCodes:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]);return c.useMemo(()=>({cartFetch:i,cartCreate:s,cartLineAdd:o,cartLineUpdate:u,cartLineRemove:d,noteUpdate:g,buyerIdentityUpdate:f,cartAttributesUpdate:y,discountCodesUpdate:l,cartFragment:t}),[i,s,o,u,d,g,f,y,l,t])}function Y(e,t){return{entry:[...(t==null?void 0:t.entryActions)||[],re({lastValidCart:r=>r==null?void 0:r.cart}),"onCartActionEntry","onCartActionOptimisticUI",e],on:{RESOLVE:{target:(t==null?void 0:t.resolveTarget)||"idle",actions:[re({prevCart:r=>r==null?void 0:r.lastValidCart,cart:(r,n)=>{var a;return(a=n==null?void 0:n.payload)==null?void 0:a.cart},rawCartResult:(r,n)=>{var a;return(a=n==null?void 0:n.payload)==null?void 0:a.rawCartResult},errors:r=>{}})]},ERROR:{target:(t==null?void 0:t.errorTarget)||"error",actions:[re({prevCart:r=>r==null?void 0:r.lastValidCart,cart:r=>r==null?void 0:r.lastValidCart,errors:(r,n)=>{var a;return(a=n==null?void 0:n.payload)==null?void 0:a.errors}})]},CART_COMPLETED:{target:"cartCompleted",actions:re({prevCart:r=>{},cart:r=>{},lastValidCart:r=>{},rawCartResult:r=>{},errors:r=>{}})}},exit:["onCartActionComplete",...(t==null?void 0:t.exitActions)||[]]}}const ue={CART_FETCH:{target:"cartFetching"},CART_CREATE:{target:"cartCreating"},CART_SET:{target:"idle",actions:[re({rawCartResult:(e,t)=>t.payload.cart,cart:(e,t)=>Oe(t.payload.cart)})]}},ot={CARTLINE_ADD:{target:"cartLineAdding"},CARTLINE_UPDATE:{target:"cartLineUpdating"},CARTLINE_REMOVE:{target:"cartLineRemoving"},NOTE_UPDATE:{target:"noteUpdating"},BUYER_IDENTITY_UPDATE:{target:"buyerIdentityUpdating"},CART_ATTRIBUTES_UPDATE:{target:"cartAttributesUpdating"},DISCOUNT_CODES_UPDATE:{target:"discountCodesUpdating"}};function xr(e){return We({id:"Cart",initial:e?"idle":"uninitialized",context:{cart:e&&Oe(e)},states:{uninitialized:{on:ue},cartCompleted:{on:ue},initializationError:{on:ue},idle:{on:{...ue,...ot}},error:{on:{...ue,...ot}},cartFetching:Y("cartFetchAction",{errorTarget:"initializationError"}),cartCreating:Y("cartCreateAction",{errorTarget:"initializationError"}),cartLineRemoving:Y("cartLineRemoveAction"),cartLineUpdating:Y("cartLineUpdateAction"),cartLineAdding:Y("cartLineAddAction"),noteUpdating:Y("noteUpdateAction"),buyerIdentityUpdating:Y("buyerIdentityUpdateAction"),cartAttributesUpdating:Y("cartAttributesUpdateAction"),discountCodesUpdating:Y("discountCodesUpdateAction")}})}function Fr({numCartLines:e,onCartActionEntry:t,onCartActionOptimisticUI:r,onCartActionComplete:n,data:a,cartFragment:i,countryCode:s,languageCode:o}){const{cartFetch:u,cartCreate:d,cartLineAdd:g,cartLineUpdate:f,cartLineRemove:y,noteUpdate:l,buyerIdentityUpdate:h,cartAttributesUpdate:C,discountCodesUpdate:T}=Lr({numCartLines:e,cartFragment:i,countryCode:s,languageCode:o}),w=c.useMemo(()=>xr(a),[a]),[b,I,D]=yr(w,{actions:{cartFetchAction:async(m,p)=>{var A;if(p.type!=="CART_FETCH")return;const{data:_,errors:R}=await u((A=p==null?void 0:p.payload)==null?void 0:A.cartId),P=W(p,_==null?void 0:_.cart,R);I(P)},cartCreateAction:async(m,p)=>{var A;if(p.type!=="CART_CREATE")return;const{data:_,errors:R}=await d(p==null?void 0:p.payload),P=W(p,(A=_==null?void 0:_.cartCreate)==null?void 0:A.cart,R);I(P)},cartLineAddAction:async(m,p)=>{var A,v;if(p.type!=="CARTLINE_ADD"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:R}=await g(m.cart.id,p.payload.lines),P=W(p,(v=_==null?void 0:_.cartLinesAdd)==null?void 0:v.cart,R);I(P)},cartLineUpdateAction:async(m,p)=>{var A,v;if(p.type!=="CARTLINE_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:R}=await f(m.cart.id,p.payload.lines),P=W(p,(v=_==null?void 0:_.cartLinesUpdate)==null?void 0:v.cart,R);I(P)},cartLineRemoveAction:async(m,p)=>{var A,v;if(p.type!=="CARTLINE_REMOVE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:R}=await y(m.cart.id,p.payload.lines),P=W(p,(v=_==null?void 0:_.cartLinesRemove)==null?void 0:v.cart,R);I(P)},noteUpdateAction:async(m,p)=>{var A,v;if(p.type!=="NOTE_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:R}=await l(m.cart.id,p.payload.note),P=W(p,(v=_==null?void 0:_.cartNoteUpdate)==null?void 0:v.cart,R);I(P)},buyerIdentityUpdateAction:async(m,p)=>{var A,v;if(p.type!=="BUYER_IDENTITY_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:R}=await h(m.cart.id,p.payload.buyerIdentity),P=W(p,(v=_==null?void 0:_.cartBuyerIdentityUpdate)==null?void 0:v.cart,R);I(P)},cartAttributesUpdateAction:async(m,p)=>{var A,v;if(p.type!=="CART_ATTRIBUTES_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:R}=await C(m.cart.id,p.payload.attributes),P=W(p,(v=_==null?void 0:_.cartAttributesUpdate)==null?void 0:v.cart,R);I(P)},discountCodesUpdateAction:async(m,p)=>{var A,v;if(p.type!=="DISCOUNT_CODES_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:R}=await T(m.cart.id,p.payload.discountCodes),P=W(p,(v=_==null?void 0:_.cartDiscountCodesUpdate)==null?void 0:v.cart,R);I(P)},...t&&{onCartActionEntry:(m,p)=>{$r(p)&&t(m,p)}},...r&&{onCartActionOptimisticUI:re((m,p)=>r(m,p))},...n&&{onCartActionComplete:(m,p)=>{qr(p)&&n(m,p)}}}});return c.useMemo(()=>[b,I,D],[b,I,D])}function Oe(e){return{...e,lines:J(e==null?void 0:e.lines),note:e.note??void 0}}function W(e,t,r){return r?{type:"ERROR",payload:{errors:r,cartActionEvent:e}}:t?{type:"RESOLVE",payload:{cart:Oe(t),rawCartResult:t,cartActionEvent:e}}:{type:"CART_COMPLETED",payload:{cartActionEvent:e}}}function $r(e){return e.type==="CART_CREATE"||e.type==="CARTLINE_ADD"||e.type==="CARTLINE_UPDATE"||e.type==="CARTLINE_REMOVE"||e.type==="NOTE_UPDATE"||e.type==="BUYER_IDENTITY_UPDATE"||e.type==="CART_ATTRIBUTES_UPDATE"||e.type==="DISCOUNT_CODES_UPDATE"}function qr(e){return e.type==="RESOLVE"||e.type==="ERROR"||e.type==="CART_COMPLETED"}const st=c.createContext(null);function ie(){const e=c.useContext(st);if(!e)throw new Error("Expected a Cart Context, but no Cart Context was found");return e}function Hr({children:e,numCartLines:t,onCreate:r,onLineAdd:n,onLineRemove:a,onLineUpdate:i,onNoteUpdate:s,onBuyerIdentityUpdate:o,onAttributesUpdate:u,onDiscountCodesUpdate:d,onCreateComplete:g,onLineAddComplete:f,onLineRemoveComplete:y,onLineUpdateComplete:l,onNoteUpdateComplete:h,onBuyerIdentityUpdateComplete:C,onAttributesUpdateComplete:T,onDiscountCodesUpdateComplete:w,data:b,cartFragment:I=vr,customerAccessToken:D,countryCode:m,languageCode:p}){var Mt,Lt,xt,Ft,$t,qt,Ht;const _=ce();if(!_)throw new Error("<CartProvider> needs to be a descendant of <ShopifyProvider>");m=(m??_.countryIsoCode??"US").toUpperCase(),p=(p??_.languageIsoCode??"EN").toUpperCase(),m&&(m=m.toUpperCase());const[R,P]=c.useState(m),[A,v]=c.useState(D),H=c.useRef(!1);(R!==m||A!==D)&&(P(m),v(D),H.current=!1);const[k,j]=Fr({numCartLines:t,data:b,cartFragment:I,countryCode:m,languageCode:p,onCartActionEntry(S,V){try{switch(V.type){case"CART_CREATE":return r==null?void 0:r();case"CARTLINE_ADD":return n==null?void 0:n();case"CARTLINE_REMOVE":return a==null?void 0:a();case"CARTLINE_UPDATE":return i==null?void 0:i();case"NOTE_UPDATE":return s==null?void 0:s();case"BUYER_IDENTITY_UPDATE":return o==null?void 0:o();case"CART_ATTRIBUTES_UPDATE":return u==null?void 0:u();case"DISCOUNT_CODES_UPDATE":return d==null?void 0:d()}}catch(L){console.error("Cart entry action failed",L)}},onCartActionOptimisticUI(S,V){var L,Q,M,Ee;if(!S.cart)return{...S};switch(V.type){case"CARTLINE_REMOVE":return{...S,cart:{...S.cart,lines:(Q=(L=S==null?void 0:S.cart)==null?void 0:L.lines)==null?void 0:Q.filter(x=>(x==null?void 0:x.id)&&!V.payload.lines.includes(x==null?void 0:x.id))}};case"CARTLINE_UPDATE":return{...S,cart:{...S.cart,lines:(Ee=(M=S==null?void 0:S.cart)==null?void 0:M.lines)==null?void 0:Ee.map(x=>{const Fe=V.payload.lines.find(({id:ea})=>ea===(x==null?void 0:x.id));return Fe&&Fe.quantity?{...x,quantity:Fe.quantity}:x})}}}return{...S}},onCartActionComplete(S,V){const L=V.payload.cartActionEvent;try{switch(V.type){case"RESOLVE":switch(L.type){case"CART_CREATE":return g==null?void 0:g();case"CARTLINE_ADD":return f==null?void 0:f();case"CARTLINE_REMOVE":return y==null?void 0:y();case"CARTLINE_UPDATE":return l==null?void 0:l();case"NOTE_UPDATE":return h==null?void 0:h();case"BUYER_IDENTITY_UPDATE":return Yr(S,L)&&(H.current=!0),C==null?void 0:C();case"CART_ATTRIBUTES_UPDATE":return T==null?void 0:T();case"DISCOUNT_CODES_UPDATE":return w==null?void 0:w()}}}catch(Q){console.error("onCartActionComplete failed",Q)}}}),z=c.useRef(!1),[ye,U]=c.useState(!1),se=k.matches("cartCompleted"),me=(k.value==="idle"||k.value==="error"||k.value==="cartCompleted")&&m!==((xt=(Lt=(Mt=k==null?void 0:k.context)==null?void 0:Mt.cart)==null?void 0:Lt.buyerIdentity)==null?void 0:xt.countryCode)&&!k.context.errors,pe=c.useRef(!1);c.useEffect(()=>{if(!z.current&&!pe.current){if(!b&&Ue("localStorage")){pe.current=!0;try{const S=window.localStorage.getItem(ke);S&&j({type:"CART_FETCH",payload:{cartId:S}})}catch(S){console.warn("error fetching cartId"),console.warn(S)}}z.current=!0,U(!0)}},[b,z,j]),c.useEffect(()=>{!me||H.current||j({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:{countryCode:m,customerAccessToken:D}}})},[m,D,me,H,j]);const B=c.useCallback(S=>{if(!z.current)return console.warn("Cart isn't ready yet");j(S)},[j]);c.useEffect(()=>{var S,V,L;if((V=(S=k==null?void 0:k.context)==null?void 0:S.cart)!=null&&V.id&&Ue("localStorage"))try{window.localStorage.setItem(ke,(L=k.context.cart)==null?void 0:L.id)}catch(Q){console.warn("Failed to save cartId to localStorage",Q)}},[($t=(Ft=k==null?void 0:k.context)==null?void 0:Ft.cart)==null?void 0:$t.id]),c.useEffect(()=>{if(se&&Ue("localStorage"))try{window.localStorage.removeItem(ke)}catch(S){console.warn("Failed to delete cartId from localStorage",S)}},[se]);const xe=c.useCallback(S=>{var V,L;m&&!((V=S.buyerIdentity)!=null&&V.countryCode)&&(S.buyerIdentity==null&&(S.buyerIdentity={}),S.buyerIdentity.countryCode=m),D&&!((L=S.buyerIdentity)!=null&&L.customerAccessToken)&&(S.buyerIdentity==null&&(S.buyerIdentity={}),S.buyerIdentity.customerAccessToken=D),B({type:"CART_CREATE",payload:S})},[m,D,B]),O=Br(k),zn=c.useMemo(()=>{var S,V,L,Q;return{...((S=O==null?void 0:O.context)==null?void 0:S.cart)??{lines:[],attributes:[]},status:jr(O.value),error:(V=O==null?void 0:O.context)==null?void 0:V.errors,totalQuantity:((Q=(L=O==null?void 0:O.context)==null?void 0:L.cart)==null?void 0:Q.totalQuantity)??0,cartCreate:xe,cartReady:ye,linesAdd(M){var Ee,x;(x=(Ee=O==null?void 0:O.context)==null?void 0:Ee.cart)!=null&&x.id?B({type:"CARTLINE_ADD",payload:{lines:M}}):xe({lines:M})},linesRemove(M){B({type:"CARTLINE_REMOVE",payload:{lines:M}})},linesUpdate(M){B({type:"CARTLINE_UPDATE",payload:{lines:M}})},noteUpdate(M){B({type:"NOTE_UPDATE",payload:{note:M}})},buyerIdentityUpdate(M){B({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:M}})},cartAttributesUpdate(M){B({type:"CART_ATTRIBUTES_UPDATE",payload:{attributes:M}})},discountCodesUpdate(M){B({type:"DISCOUNT_CODES_UPDATE",payload:{discountCodes:M}})},cartFragment:I}},[xe,ye,(qt=O==null?void 0:O.context)==null?void 0:qt.cart,(Ht=O==null?void 0:O.context)==null?void 0:Ht.errors,O.value,I,B]);return React.createElement(st.Provider,{value:zn},e)}function jr(e){switch(e){case"uninitialized":case"initializationError":return"uninitialized";case"idle":case"cartCompleted":case"error":return"idle";case"cartFetching":return"fetching";case"cartCreating":return"creating";case"cartLineAdding":case"cartLineRemoving":case"cartLineUpdating":case"noteUpdating":case"buyerIdentityUpdating":case"cartAttributesUpdating":case"discountCodesUpdating":return"updating"}}function Br(e){const[t,r]=c.useTransition(),[n,a]=c.useState(e),i=c.useRef(!1);t&&(i.current=!0);const s=c.useRef(!1);return!t&&i.current&&(s.current=!0),c.useEffect(()=>{r(()=>{s.current||a(e)})},[e]),s.current?e:n}function Ue(e){let t;try{t=window[e];const r="__storage_test__";return t.setItem(r,r),t.removeItem(r),!0}catch(r){return!!(r instanceof DOMException&&(r.code===22||r.code===1014||r.name==="QuotaExceededError"||r.name==="NS_ERROR_DOM_QUOTA_REACHED")&&t&&t.length!==0)}}function Yr(e,t){var r,n;return!!(t.payload.buyerIdentity.countryCode&&((n=(r=e.cart)==null?void 0:r.buyerIdentity)==null?void 0:n.countryCode)!==t.payload.buyerIdentity.countryCode)}const ct=c.createContext(null);function Wr({children:e,data:t,initialVariantId:r}){const n=c.useMemo(()=>J(t.variants??{}),[t.variants]);if(!Zr(n))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const a=c.useMemo(()=>Gr(n),[n]),[i,s]=c.useState(()=>dt(r,n)),[o,u]=c.useState(()=>ft(i));c.useEffect(()=>{const T=dt(r,n);s(T),u(ft(T))},[r,n]);const d=c.useCallback((T,w)=>{u(b=>{const I={...b,[T]:w};return s(lt(n,I)),I})},[u,n]),g=c.useCallback((T,w)=>{const b=lt(n,{...o,[T]:w});return(b==null?void 0:b.availableForSale)??!0},[o,n]),f=c.useMemo(()=>J(t.sellingPlanGroups??{}).map(T=>({...T,sellingPlans:J((T==null?void 0:T.sellingPlans)??{})})),[t.sellingPlanGroups]),[y,l]=c.useState(void 0),h=c.useMemo(()=>{var T,w;if(!(!i||!y)){if(!((T=i.sellingPlanAllocations)!=null&&T.nodes)&&!((w=i.sellingPlanAllocations)!=null&&w.edges))throw new Error("<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation");return J(i.sellingPlanAllocations).find(b=>{var I;return((I=b==null?void 0:b.sellingPlan)==null?void 0:I.id)===y.id})}},[i,y]),C=c.useMemo(()=>({product:t,variants:n,variantsConnection:t.variants,options:a,selectedVariant:i,setSelectedVariant:s,selectedOptions:o,setSelectedOption:d,setSelectedOptions:u,isOptionInStock:g,selectedSellingPlan:y,setSelectedSellingPlan:l,selectedSellingPlanAllocation:h,sellingPlanGroups:f,sellingPlanGroupsConnection:t.sellingPlanGroups}),[t,g,a,o,y,h,i,f,d,n]);return React.createElement(ct.Provider,{value:C},e)}function ut(){const e=c.useContext(ct);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function lt(e,t){var r,n;if(!(!e.length||((n=(r=e==null?void 0:e[0])==null?void 0:r.selectedOptions)==null?void 0:n.length)!==Object.keys(t).length))return e==null?void 0:e.find(a=>Object.entries(t).every(([i,s])=>{var o;return(o=a==null?void 0:a.selectedOptions)==null?void 0:o.some(u=>(u==null?void 0:u.name)===i&&(u==null?void 0:u.value)===s)}))}function Gr(e){const t=e.reduce((r,n)=>{var a;if(!n.selectedOptions)throw new Error("'getOptions' requires 'variant.selectedOptions'");return(a=n==null?void 0:n.selectedOptions)==null||a.forEach(i=>{r[(i==null?void 0:i.name)??""]=r[(i==null?void 0:i.name)??""]||new Set,r[(i==null?void 0:i.name)??""].add((i==null?void 0:i.value)??"")}),r},{});return Object.keys(t).map(r=>({name:r,values:Array.from(t[r])}))}function dt(e,t){if(e){const r=t.find(n=>(n==null?void 0:n.id)===e);return r||console.warn("<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID"),r}if(e===null)return null;if(e===void 0)return t.find(r=>r==null?void 0:r.availableForSale)||t[0]}function ft(e){return e!=null&&e.selectedOptions?e.selectedOptions.reduce((t,r)=>(t[(r==null?void 0:r.name)??""]=(r==null?void 0:r.value)??"",t),{}):{}}function Zr(e){return!(!e||!Array.isArray(e))}function Ae(e){const{as:t,onClick:r,defaultOnClick:n,children:a,buttonRef:i,...s}=e,o=c.useCallback(d=>{if(r){const g=r(d);if(typeof g=="boolean"&&g===!1||d!=null&&d.defaultPrevented)return}n==null||n(d)},[n,r]),u=t||"button";return React.createElement(u,{ref:i,onClick:o,...s},a)}function Qr(e){const[t,r]=c.useState(!1),{variantId:n,quantity:a=1,attributes:i,sellingPlanId:s,onClick:o,children:u,accessibleAddingToCartLabel:d,...g}=e,{status:f,linesAdd:y}=ie(),{selectedVariant:l}=ut(),h=n??(l==null?void 0:l.id)??"",C=n===null||h===""||l===null||t||g.disabled;c.useEffect(()=>{t&&f==="idle"&&r(!1)},[f,t]);const T=c.useCallback(()=>{r(!0),y([{quantity:a,merchandiseId:h||"",attributes:i,sellingPlanId:s}])},[y,a,h,i,s]);return N.createElement(N.Fragment,null,N.createElement(Ae,{...g,disabled:C,onClick:o,defaultOnClick:T},u),d?N.createElement("p",{style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"},role:"alert","aria-live":"assertive"},t?d:null):null)}const te={PAGE_VIEW:"PAGE_VIEW",ADD_TO_CART:"ADD_TO_CART",PAGE_VIEW_2:"PAGE_VIEW_2",COLLECTION_VIEW:"COLLECTION_VIEW",PRODUCT_VIEW:"PRODUCT_VIEW",SEARCH_VIEW:"SEARCH_VIEW"},we={article:"article",blog:"blog",captcha:"captcha",cart:"cart",collection:"collection",customersAccount:"customers/account",customersActivateAccount:"customers/activate_account",customersAddresses:"customers/addresses",customersLogin:"customers/login",customersOrder:"customers/order",customersRegister:"customers/register",customersResetPassword:"customers/reset_password",giftCard:"gift_card",home:"index",listCollections:"list-collections",forbidden:"403",notFound:"404",page:"page",password:"password",product:"product",policy:"policy",search:"search"},ht={hydrogen:"hydrogen",headless:"headless"},gt={hydrogen:"6167201",headless:"12875497473"};function q(e,t){return{schema_id:e,payload:t,metadata:{event_created_at_ms:Date.now()}}}function F(e){const t={id:"",resource:null,resourceId:null,search:"",searchParams:new URLSearchParams,hash:""};if(typeof e!="string")return t;try{const{search:r,searchParams:n,pathname:a,hash:i}=new URL(e),s=a.split("/"),o=s[s.length-1],u=s[s.length-2];return!o||!u?t:{id:`${o}${r}${i}`||"",resource:u??null,resourceId:o||null,search:r,searchParams:n,hash:i}}catch{return t}}function $(e,t){return typeof e!="object"?{}:(Object.entries(e).forEach(([r,n])=>{n&&(t[r]=n)}),t)}function Jr(e){return typeof document>"u"?(console.error(`${e} should only be used within the useEffect callback or event handlers`),!0):!1}const Kr="trekkie_storefront_page_view/1.4",Xr="myshopify.dev";function yt(e){const t=e,{id:r,resource:n}=F(t.resourceId),a=n?n.toLowerCase():void 0;return[q(Kr,$({pageType:t.pageType,customerId:parseInt(F(t.customerId).id||"0"),resourceType:a,resourceId:parseInt(r)},zr(t)))]}function zr(e){return{appClientId:e.shopifySalesChannel?gt[e.shopifySalesChannel]:gt.headless,isMerchantRequest:en(e.url),hydrogenSubchannelId:e.storefrontId||e.hydrogenSubchannelId||"0",isPersistentCookie:e.hasUserConsent,uniqToken:e.uniqueToken,visitToken:e.visitToken,microSessionId:Se(),microSessionCount:1,url:e.url,path:e.path,search:e.search,referrer:e.referrer,title:e.title,shopId:parseInt(F(e.shopId).id),currency:e.currency,contentLanguage:e.acceptedLanguage||"en"}}function en(e){if(typeof e!="string")return!1;const t=new URL(e).hostname;return t.indexOf(Xr)!==-1||t==="localhost"}const tn="2024.7.5",G="custom_storefront_customer_tracking/1.2",mt="page_rendered",pt="collection_page_rendered",Et="product_page_rendered",rn="product_added_to_cart",_t="search_submitted";function le(e){return{canonical_url:e.canonicalUrl||e.url,customer_id:parseInt(F(e.customerId).id||"0")}}function nn(e){const t=e,r=le(t),n=t.pageType,a=[];switch(a.push(q(G,$({event_name:mt,...r},Z(t)))),n){case we.collection:a.push(q(G,$({event_name:pt,...r,collection_name:t.collectionHandle,collection_id:parseInt(F(t.collectionId).id)},Z(t))));break;case we.product:a.push(q(G,$({event_name:Et,...r,products:Ne(t.products),total_value:t.totalValue},Z(t))));break;case we.search:a.push(q(G,$({event_name:_t,...r,search_string:t.searchString},Z(t))));break}return a}function an(e){const t=e,r=le(t);return[q(G,$({event_name:mt,...r},Z(t)))]}function on(e){const t=e,r=le(t);return[q(G,$({event_name:pt,...r,collection_name:t.collectionHandle,collection_id:parseInt(F(t.collectionId).id)},Z(t)))]}function sn(e){const t=e,r=le(t);return[q(G,$({event_name:Et,...r,products:Ne(t.products),total_value:t.totalValue},Z(t)))]}function cn(e){const t=e,r=le(t);return[q(G,$({event_name:_t,...r,search_string:t.searchString},Z(t)))]}function un(e){const t=e,r=F(t.cartId),n=r!=null&&r.id?`${r.id}`:null;return[q(G,$({event_name:rn,customerId:t.customerId,cart_token:n,total_value:t.totalValue,products:Ne(t.products),customer_id:parseInt(F(t.customerId).id||"0")},Z(t)))]}function Z(e){return{source:e.shopifySalesChannel||ht.headless,asset_version_id:e.assetVersionId||tn,hydrogenSubchannelId:e.storefrontId||e.hydrogenSubchannelId||"0",is_persistent_cookie:e.hasUserConsent,deprecated_visit_token:e.visitToken,unique_token:e.uniqueToken,event_time:Date.now(),event_id:Se(),event_source_url:e.url,referrer:e.referrer,user_agent:e.userAgent,navigation_type:e.navigationType,navigation_api:e.navigationApi,shop_id:parseInt(F(e.shopId).id),currency:e.currency,ccpa_enforced:e.ccpaEnforced||!1,gdpr_enforced:e.gdprEnforced||!1,gdpr_enforced_as_string:e.gdprEnforced?"true":"false",analytics_allowed:e.analyticsAllowed||!1,marketing_allowed:e.marketingAllowed||!1,sale_of_data_allowed:e.saleOfDataAllowed||!1}}function Ne(e){return e?e.map(t=>{const r=$({variant_gid:t.variantGid,category:t.category,sku:t.sku,product_id:parseInt(F(t.productGid).id),variant_id:parseInt(F(t.variantGid).id)},{product_gid:t.productGid,name:t.name,variant:t.variantName||"",brand:t.brand,price:parseFloat(t.price),quantity:Number(t.quantity||0)});return JSON.stringify(r)}):[]}function ln(e,t){const{eventName:r,payload:n}=e;if(!n.hasUserConsent)return Promise.resolve();let a=[];const i=n;return r===te.PAGE_VIEW?a=a.concat(yt(i),nn(i)):r===te.ADD_TO_CART?a=a.concat(un(n)):r===te.PAGE_VIEW_2?a=a.concat(yt(i),an(i)):r===te.COLLECTION_VIEW?a=a.concat(on(i)):r===te.PRODUCT_VIEW?a=a.concat(sn(i)):r===te.SEARCH_VIEW&&(a=a.concat(cn(i))),a.length?fn(a,t):Promise.resolve()}function dn(){return typeof window>"u"||!window.navigator?!1:/Chrome-Lighthouse/.test(window.navigator.userAgent)}const Ct="sendShopifyAnalytics request is unsuccessful";function fn(e,t){if(dn())return Promise.resolve();const r={events:e,metadata:{event_sent_at_ms:Date.now()}};try{return fetch(t?`https://${t}/.well-known/shopify/monorail/unstable/produce_batch`:"https://monorail-edge.shopifysvc.com/unstable/produce_batch",{method:"post",headers:{"content-type":"text/plain"},body:JSON.stringify(r)}).then(n=>{if(!n.ok)throw new Error("Response failed");return n.text()}).then(n=>{n&&JSON.parse(n).result.forEach(i=>{i.status!==200&&console.error(Ct,`
273
273
 
274
274
  `,i.message)})}).catch(n=>{console.error(Ct,n)})}catch{return Promise.resolve()}}function hn(){if(Jr("getClientBrowserParameters"))return{uniqueToken:"",visitToken:"",url:"",path:"",search:"",referrer:"",title:"",userAgent:"",navigationType:"",navigationApi:""};const[e,t]=mn(),r=Te(document.cookie);return{uniqueToken:r[K],visitToken:r[X],url:location.href,path:location.pathname,search:location.search,referrer:document.referrer,title:document.title,userAgent:navigator.userAgent,navigationType:e,navigationApi:t}}function gn(){try{const e=(performance==null?void 0:performance.getEntriesByType)&&(performance==null?void 0:performance.getEntriesByType("navigation"));if(e&&e[0]){const t=window.performance.getEntriesByType("navigation")[0].type;return t&&t.toString()}}catch{}}function yn(){var e,t;try{if(PerformanceNavigation&&((e=performance==null?void 0:performance.navigation)==null?void 0:e.type)!==null&&((t=performance==null?void 0:performance.navigation)==null?void 0:t.type)!==void 0){const r=performance.navigation.type;switch(r){case PerformanceNavigation.TYPE_NAVIGATE:return"navigate";case PerformanceNavigation.TYPE_RELOAD:return"reload";case PerformanceNavigation.TYPE_BACK_FORWARD:return"back_forward";default:return`unknown: ${r}`}}}catch{}}function mn(){try{let e="PerformanceNavigationTiming",t=gn();return t||(t=yn(),e="performance.navigation"),t?[t,e]:["unknown","unknown"]}catch{}return["error","error"]}function pn(e){const{cartCreate:t,checkoutUrl:r}=ie(),[n,a]=c.useState(!1),{quantity:i,variantId:s,sellingPlanId:o,onClick:u,attributes:d,children:g,...f}=e;c.useEffect(()=>{n&&r&&(window.location.href=r)},[n,r]);const y=c.useCallback(()=>{a(!0),t({lines:[{quantity:i??1,merchandiseId:s,attributes:d,sellingPlanId:o}]})},[t,i,s,d,o]);return React.createElement(Ae,{disabled:n??f.disabled,...f,onClick:u,defaultOnClick:y},g)}function En(e){const[t,r]=c.useState(!1),{status:n,checkoutUrl:a}=ie(),{children:i,...s}=e;return c.useEffect(()=>{t&&a&&n==="idle"&&(window.location.href=a)},[t,n,a]),React.createElement(Ae,{...s,disabled:t||s.disabled,onClick:()=>r(!0)},i)}function St(e){const{countryIsoCode:t,languageIsoCode:r}=ce(),n=r.includes("_")?r.replace("_","-"):`${r}-${t}`;if(!n)throw new Error("useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work");const a=parseFloat(e.amount),{defaultFormatter:i,nameFormatter:s,narrowSymbolFormatter:o,withoutTrailingZerosFormatter:u,withoutCurrencyFormatter:d,withoutTrailingZerosOrCurrencyFormatter:g}=c.useMemo(()=>{const l={style:"currency",currency:e.currencyCode};return{defaultFormatter:oe(n,l),nameFormatter:oe(n,{...l,currencyDisplay:"name"}),narrowSymbolFormatter:oe(n,{...l,currencyDisplay:"narrowSymbol"}),withoutTrailingZerosFormatter:oe(n,{...l,minimumFractionDigits:0,maximumFractionDigits:0}),withoutCurrencyFormatter:oe(n),withoutTrailingZerosOrCurrencyFormatter:oe(n,{minimumFractionDigits:0,maximumFractionDigits:0})}},[e.currencyCode,n]),f=l=>l.type==="currency",y=c.useMemo(()=>({original:()=>e,currencyCode:()=>e.currencyCode,localizedString:()=>i().format(a),parts:()=>i().formatToParts(a),withoutTrailingZeros:()=>a%1===0?u().format(a):i().format(a),withoutTrailingZerosAndCurrency:()=>a%1===0?g().format(a):d().format(a),currencyName:()=>{var l;return((l=s().formatToParts(a).find(f))==null?void 0:l.value)??e.currencyCode},currencySymbol:()=>{var l;return((l=i().formatToParts(a).find(f))==null?void 0:l.value)??e.currencyCode},currencyNarrowSymbol:()=>{var l;return((l=o().formatToParts(a).find(f))==null?void 0:l.value)??""},amount:()=>i().formatToParts(a).filter(l=>["decimal","fraction","group","integer","literal"].includes(l.type)).map(l=>l.value).join("")}),[e,a,s,i,o,d,u,g]);return c.useMemo(()=>new Proxy(y,{get:(l,h)=>{var C;return(C=Reflect.get(l,h))==null?void 0:C.call(null)}}),[y])}const Tt=new Map;function oe(e,t){const r=JSON.stringify([e,t]);return function(){let n=Tt.get(r);return n||(n=new Intl.NumberFormat(e,t),Tt.set(r,n)),n}}function Ie({data:e,as:t,withoutCurrency:r,withoutTrailingZeros:n,measurement:a,measurementSeparator:i="/",...s}){if(!_n(e))throw new Error("<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'");const o=St(e),u=t??"div";let d=o.localizedString;return(r||n)&&(r&&!n?d=o.amount:!r&&n?d=o.withoutTrailingZeros:d=o.withoutTrailingZerosAndCurrency),React.createElement(u,{...s},d,a&&a.referenceUnit&&React.createElement(React.Fragment,null,i,a.referenceUnit))}function _n(e){return typeof e.amount=="string"&&!!e.amount&&typeof e.currencyCode=="string"&&!!e.currencyCode}function Cn(e){const{cost:t}=ie(),{amountType:r="total",children:n,...a}=e;let i;return r=="total"?i=t==null?void 0:t.totalAmount:r=="subtotal"?i=t==null?void 0:t.subtotalAmount:r=="tax"?i=t==null?void 0:t.totalTaxAmount:r=="duty"&&(i=t==null?void 0:t.totalDutyAmount),i==null?null:React.createElement(Ie,{...a,data:i},n)}const At=c.createContext(null);function Ve(){const e=c.useContext(At);if(e==null)throw new Error("Expected a cart line context but none was found");return e}function Sn({children:e,line:t}){return React.createElement(At.Provider,{value:t},e)}function Tn(e){const t=Ve(),{as:r,...n}=e,a=r||"span";return React.createElement(a,{...n},t.quantity)}function An(e){const{status:t,linesRemove:r,linesUpdate:n}=ie(),a=Ve(),{children:i,adjust:s,onClick:o,...u}=e,d=c.useCallback(()=>{if(s==="remove"){r([(a==null?void 0:a.id)??""]);return}const f=s==="decrease"?((a==null?void 0:a.quantity)??0)-1:((a==null?void 0:a.quantity)??0)+1;if(f<=0){r([(a==null?void 0:a.id)??""]);return}const y={id:(a==null?void 0:a.id)??"",quantity:f,attributes:(a==null?void 0:a.attributes)??[]};n([y])},[s,a==null?void 0:a.attributes,a==null?void 0:a.id,a==null?void 0:a.quantity,r,n]),g=u.disabled;return React.createElement(Ae,{...u,onClick:o,defaultOnClick:d,disabled:typeof g<"u"?g:t!=="idle"},i)}const wn={DateTime:"string",Decimal:"string",HTML:"string",URL:"string",Color:"string",UnsignedInt64:"string"},In={DateTime:"string",Decimal:"string",HTML:"string",ISO8601DateTime:"string",URL:"string",UnsignedInt64:"string"},wt=c.forwardRef((e,t)=>{const{data:r,options:n,id:a=r.id,frameBorder:i="0",allow:s="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:o=!0,loading:u="lazy",...d}=e;if(!r.embedUrl)throw new Error("<ExternalVideo/> requires the 'embedUrl' property");let g=r.embedUrl;if(n){const f=new URL(r.embedUrl);for(const[y,l]of Object.entries(n))typeof l>"u"||f.searchParams.set(y,l.toString());g=f.toString()}return React.createElement("iframe",{...d,id:a??r.embedUrl,title:r.alt??r.id??"external video",frameBorder:i,allow:s,allowFullScreen:o,src:g,loading:u,ref:t})}),bn=`#graphql
275
275
  fragment Image on Image {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/hydrogen-react",
3
- "version": "2024.7.4",
3
+ "version": "2024.7.5",
4
4
  "description": "React components, hooks, and utilities for creating custom Shopify storefronts",
5
5
  "homepage": "https://github.com/Shopify/hydrogen/tree/main/packages/hydrogen-react",
6
6
  "license": "MIT",
@@ -171,8 +171,8 @@
171
171
  },
172
172
  "dependencies": {
173
173
  "@google/model-viewer": "^1.12.1",
174
- "@xstate/fsm": "^2.0.0",
175
- "@xstate/react": "^3.2.1",
174
+ "@xstate/fsm": "2.0.0",
175
+ "@xstate/react": "3.2.1",
176
176
  "graphql": "^16.6.0",
177
177
  "type-fest": "^4.5.0",
178
178
  "worktop": "^0.7.3"