@shopify/hydrogen-react 2023.7.4 → 2023.7.6
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/browser-dev/CartProvider.mjs +4 -1
- package/dist/browser-dev/CartProvider.mjs.map +1 -1
- package/dist/browser-dev/cart-queries.mjs +18 -9
- package/dist/browser-dev/cart-queries.mjs.map +1 -1
- package/dist/browser-dev/load-script.mjs +6 -0
- package/dist/browser-dev/load-script.mjs.map +1 -1
- package/dist/browser-dev/useCartAPIStateMachine.mjs +4 -2
- package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-dev/useCartActions.mjs +29 -19
- package/dist/browser-dev/useCartActions.mjs.map +1 -1
- package/dist/browser-prod/CartProvider.mjs +4 -1
- package/dist/browser-prod/CartProvider.mjs.map +1 -1
- package/dist/browser-prod/cart-queries.mjs +18 -9
- package/dist/browser-prod/cart-queries.mjs.map +1 -1
- package/dist/browser-prod/load-script.mjs +6 -0
- package/dist/browser-prod/load-script.mjs.map +1 -1
- package/dist/browser-prod/useCartAPIStateMachine.mjs +4 -2
- package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-prod/useCartActions.mjs +29 -19
- package/dist/browser-prod/useCartActions.mjs.map +1 -1
- package/dist/node-dev/CartProvider.js +4 -1
- package/dist/node-dev/CartProvider.js.map +1 -1
- package/dist/node-dev/CartProvider.mjs +4 -1
- package/dist/node-dev/CartProvider.mjs.map +1 -1
- package/dist/node-dev/cart-queries.js +18 -9
- package/dist/node-dev/cart-queries.js.map +1 -1
- package/dist/node-dev/cart-queries.mjs +18 -9
- package/dist/node-dev/cart-queries.mjs.map +1 -1
- package/dist/node-dev/load-script.js +6 -0
- package/dist/node-dev/load-script.js.map +1 -1
- package/dist/node-dev/load-script.mjs +6 -0
- package/dist/node-dev/load-script.mjs.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.js +4 -2
- package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.mjs +4 -2
- package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-dev/useCartActions.js +29 -19
- package/dist/node-dev/useCartActions.js.map +1 -1
- package/dist/node-dev/useCartActions.mjs +29 -19
- package/dist/node-dev/useCartActions.mjs.map +1 -1
- package/dist/node-prod/CartProvider.js +4 -1
- package/dist/node-prod/CartProvider.js.map +1 -1
- package/dist/node-prod/CartProvider.mjs +4 -1
- package/dist/node-prod/CartProvider.mjs.map +1 -1
- package/dist/node-prod/cart-queries.js +18 -9
- package/dist/node-prod/cart-queries.js.map +1 -1
- package/dist/node-prod/cart-queries.mjs +18 -9
- package/dist/node-prod/cart-queries.mjs.map +1 -1
- package/dist/node-prod/load-script.js +6 -0
- package/dist/node-prod/load-script.js.map +1 -1
- package/dist/node-prod/load-script.mjs +6 -0
- package/dist/node-prod/load-script.mjs.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.js +4 -2
- package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.mjs +4 -2
- package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-prod/useCartActions.js +29 -19
- package/dist/node-prod/useCartActions.js.map +1 -1
- package/dist/node-prod/useCartActions.mjs +29 -19
- package/dist/node-prod/useCartActions.mjs.map +1 -1
- package/dist/types/CartProvider.d.ts +4 -2
- package/dist/types/load-script.d.ts +4 -2
- package/dist/types/useCartAPIStateMachine.d.ts +4 -2
- package/dist/types/useCartActions.d.ts +5 -3
- package/dist/umd/hydrogen-react.dev.js +61 -31
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +35 -26
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +36 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(p,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],u):(p=typeof globalThis<"u"?globalThis:p||self,u(p.hydrogenreact={},p.React))})(this,function(p,u){"use strict";function kt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const N=kt(u);/*! *****************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
12
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
13
|
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */function
|
|
14
|
+
***************************************************************************** */function Ne(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n,a,i=r.call(e),s=[];try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(o){a={error:o}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(a)throw a.error}}return s}var J;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(J||(J={}));var Me={type:"xstate.init"};function Ae(e){return e===void 0?[]:[].concat(e)}function z(e){return{type:"xstate.assign",assignment:e}}function Ve(e,t){return typeof(e=typeof e=="string"&&t&&t[e]?t[e]:e)=="string"?{type:e}:typeof e=="function"?{type:e.name,exec:e}:e}function he(e){return function(t){return e===t}}function Le(e){return typeof e=="string"?{type:e}:e}function xe(e,t){return{value:e,context:t,actions:[],changed:!1,matches:he(e)}}function Fe(e,t,r){var n=t,a=!1;return[e.filter(function(i){if(i.type==="xstate.assign"){a=!0;var s=Object.assign({},n);return typeof i.assignment=="function"?s=i.assignment(n,r):Object.keys(i.assignment).forEach(function(o){s[o]=typeof i.assignment[o]=="function"?i.assignment[o](n,r):i.assignment[o]}),n=s,!1}return!0}),n,a]}function $e(e,t){t===void 0&&(t={});var r=Ne(Fe(Ae(e.states[e.initial].entry).map(function(s){return Ve(s,t.actions)}),e.context,Me),2),n=r[0],a=r[1],i={config:e,_options:t,initialState:{value:e.initial,actions:n,context:a,matches:he(e.initial)},transition:function(s,o){var c,f,l=typeof s=="string"?{value:s,context:e.context}:s,y=l.value,h=l.context,S=Le(o),d=e.states[y];if(d.on){var C=Ae(d.on[S.type]);try{for(var _=function(U){var oe=typeof Symbol=="function"&&Symbol.iterator,F=oe&&U[oe],ie=0;if(F)return F.call(U);if(U&&typeof U.length=="number")return{next:function(){return U&&ie>=U.length&&(U=void 0),{value:U&&U[ie++],done:!U}}};throw new TypeError(oe?"Object is not iterable.":"Symbol.iterator is not defined.")}(C),R=_.next();!R.done;R=_.next()){var I=R.value;if(I===void 0)return xe(y,h);var v=typeof I=="string"?{target:I}:I,D=v.target,g=v.actions,m=g===void 0?[]:g,E=v.cond,P=E===void 0?function(){return!0}:E,b=D===void 0,A=D??y,w=e.states[A];if(P(h,S)){var $=Ne(Fe((b?Ae(m):[].concat(d.exit,m,w.entry).filter(function(U){return U})).map(function(U){return Ve(U,i._options.actions)}),h,S),3),k=$[0],q=$[1],Q=$[2],K=D??y;return{value:K,context:q,actions:k,changed:D!==y||k.length>0||Q,matches:he(K)}}}}catch(U){c={error:U}}finally{try{R&&!R.done&&(f=_.return)&&f.call(_)}finally{if(c)throw c.error}}}return xe(y,h)}};return i}var qe=function(e,t){return e.actions.forEach(function(r){var n=r.exec;return n&&n(e.context,t)})};function Ut(e){var t=e.initialState,r=J.NotStarted,n=new Set,a={_machine:e,send:function(i){r===J.Running&&(t=e.transition(t,i),qe(t,Le(i)),n.forEach(function(s){return s(t)}))},subscribe:function(i){return n.add(i),i(t),{unsubscribe:function(){return n.delete(i)}}},start:function(i){if(i){var s=typeof i=="object"?i:{context:e.config.context,value:i};t={value:s.value,actions:[],context:s.context,matches:he(s.value)}}else t=e.initialState;return r=J.Running,qe(t,Me),a},stop:function(){return r=J.Stopped,n.clear(),a},get state(){return t},get status(){return r}};return a}var Ot=u.useLayoutEffect,He={exports:{}},Be={},Ye={exports:{}},je={};/**
|
|
15
15
|
* @license React
|
|
16
16
|
* use-sync-external-store-shim.production.min.js
|
|
17
17
|
*
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
* This source code is licensed under the MIT license found in the
|
|
21
21
|
* LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/var
|
|
22
|
+
*/var ee=u;function Nt(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Mt=typeof Object.is=="function"?Object.is:Nt,Vt=ee.useState,Lt=ee.useEffect,xt=ee.useLayoutEffect,Ft=ee.useDebugValue;function $t(e,t){var r=t(),n=Vt({inst:{value:r,getSnapshot:t}}),a=n[0].inst,i=n[1];return xt(function(){a.value=r,a.getSnapshot=t,ve(a)&&i({inst:a})},[e,r,t]),Lt(function(){return ve(a)&&i({inst:a}),e(function(){ve(a)&&i({inst:a})})},[e]),Ft(r),r}function ve(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!Mt(e,r)}catch{return!0}}function qt(e,t){return t()}var Ht=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?qt:$t;je.useSyncExternalStore=ee.useSyncExternalStore!==void 0?ee.useSyncExternalStore:Ht,Ye.exports=je;var Bt=Ye.exports;/**
|
|
23
23
|
* @license React
|
|
24
24
|
* use-sync-external-store-shim/with-selector.production.min.js
|
|
25
25
|
*
|
|
@@ -27,13 +27,14 @@
|
|
|
27
27
|
*
|
|
28
28
|
* This source code is licensed under the MIT license found in the
|
|
29
29
|
* LICENSE file in the root directory of this source tree.
|
|
30
|
-
*/var me=u,Bt
|
|
30
|
+
*/var me=u,Yt=Bt;function jt(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Gt=typeof Object.is=="function"?Object.is:jt,Zt=Yt.useSyncExternalStore,Wt=me.useRef,Qt=me.useEffect,Jt=me.useMemo,Xt=me.useDebugValue;Be.useSyncExternalStoreWithSelector=function(e,t,r,n,a){var i=Wt(null);if(i.current===null){var s={hasValue:!1,value:null};i.current=s}else s=i.current;i=Jt(function(){function c(S){if(!f){if(f=!0,l=S,S=n(S),a!==void 0&&s.hasValue){var d=s.value;if(a(d,S))return y=d}return y=S}if(d=y,Gt(l,S))return d;var C=n(S);return a!==void 0&&a(d,C)?d:(l=S,y=C)}var f=!1,l,y,h=r===void 0?null:r;return[function(){return c(t())},h===null?void 0:function(){return c(h())}]},[t,r,n,a]);var o=Zt(e,i[0],i[1]);return Qt(function(){s.hasValue=!0,s.value=o},[o]),Xt(o),o},He.exports=Be;var Kt=He.exports;function zt(e){var t=N.useRef();return t.current||(t.current={v:e()}),t.current.v}var er=globalThis&&globalThis.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),a,i=[],s;try{for(;(t===void 0||t-- >0)&&!(a=n.next()).done;)i.push(a.value)}catch(o){s={error:o}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i};function tr(e){return e}var rr=function(e){var t;return e.subscribe(function(r){t=r}).unsubscribe(),t};function nr(e,t){var r=u.useRef(),n=er(zt(function(){var o=[],c=Ut($e(e.config,t||e._options)),f=c.send;return c.send=function(l){if(c.status===J.NotStarted){o.push(l);return}f(l),r.current=c.state},[c,o]}),2),a=n[0],i=n[1];Ot(function(){t&&(a._machine._options=t)});var s=or(a);return u.useEffect(function(){return a.start(r.current),i.forEach(a.send),r.current=a.state,function(){a.stop()}},[]),s}var ar=function(e,t){return t.changed===!1};function or(e){var t=u.useCallback(function(){return rr(e)},[e]),r=u.useCallback(function(a){var i=e.subscribe(a).unsubscribe;return i},[e]),n=Kt.useSyncExternalStoreWithSelector(r,t,t,tr,ar);return[n,e.send,e]}function G(e){if(!e){const t=`flattenConnection(): needs a 'connection' to flatten, but received '${e??""}' instead.`;return console.error(t+" Returning an empty array"),[]}return"nodes"in e?e.nodes:"edges"in e&&Array.isArray(e.edges)?e.edges.map(t=>{if(!(t!=null&&t.node))throw new Error("flattenConnection(): Connection edges must contain nodes");return t.node}):[]}const ir=e=>`
|
|
31
31
|
mutation CartLineAdd(
|
|
32
32
|
$cartId: ID!
|
|
33
33
|
$lines: [CartLineInput!]!
|
|
34
34
|
$numCartLines: Int = 250
|
|
35
35
|
$country: CountryCode = ZZ
|
|
36
|
-
|
|
36
|
+
$language: LanguageCode
|
|
37
|
+
) @inContext(country: $country, language: $language) {
|
|
37
38
|
cartLinesAdd(cartId: $cartId, lines: $lines) {
|
|
38
39
|
cart {
|
|
39
40
|
...CartFragment
|
|
@@ -42,12 +43,13 @@
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
${e}
|
|
45
|
-
`,
|
|
46
|
+
`,sr=e=>`
|
|
46
47
|
mutation CartCreate(
|
|
47
48
|
$input: CartInput!
|
|
48
49
|
$numCartLines: Int = 250
|
|
49
50
|
$country: CountryCode = ZZ
|
|
50
|
-
|
|
51
|
+
$language: LanguageCode
|
|
52
|
+
) @inContext(country: $country, language: $language) {
|
|
51
53
|
cartCreate(input: $input) {
|
|
52
54
|
cart {
|
|
53
55
|
...CartFragment
|
|
@@ -56,13 +58,14 @@
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
${e}
|
|
59
|
-
`,
|
|
61
|
+
`,cr=e=>`
|
|
60
62
|
mutation CartLineRemove(
|
|
61
63
|
$cartId: ID!
|
|
62
64
|
$lines: [ID!]!
|
|
63
65
|
$numCartLines: Int = 250
|
|
64
66
|
$country: CountryCode = ZZ
|
|
65
|
-
|
|
67
|
+
$language: LanguageCode
|
|
68
|
+
) @inContext(country: $country, language: $language) {
|
|
66
69
|
cartLinesRemove(cartId: $cartId, lineIds: $lines) {
|
|
67
70
|
cart {
|
|
68
71
|
...CartFragment
|
|
@@ -71,13 +74,14 @@
|
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
${e}
|
|
74
|
-
`,
|
|
77
|
+
`,ur=e=>`
|
|
75
78
|
mutation CartLineUpdate(
|
|
76
79
|
$cartId: ID!
|
|
77
80
|
$lines: [CartLineUpdateInput!]!
|
|
78
81
|
$numCartLines: Int = 250
|
|
79
82
|
$country: CountryCode = ZZ
|
|
80
|
-
|
|
83
|
+
$language: LanguageCode
|
|
84
|
+
) @inContext(country: $country, language: $language) {
|
|
81
85
|
cartLinesUpdate(cartId: $cartId, lines: $lines) {
|
|
82
86
|
cart {
|
|
83
87
|
...CartFragment
|
|
@@ -86,13 +90,14 @@
|
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
${e}
|
|
89
|
-
`,
|
|
93
|
+
`,lr=e=>`
|
|
90
94
|
mutation CartNoteUpdate(
|
|
91
95
|
$cartId: ID!
|
|
92
96
|
$note: String
|
|
93
97
|
$numCartLines: Int = 250
|
|
94
98
|
$country: CountryCode = ZZ
|
|
95
|
-
|
|
99
|
+
$language: LanguageCode
|
|
100
|
+
) @inContext(country: $country, language: $language) {
|
|
96
101
|
cartNoteUpdate(cartId: $cartId, note: $note) {
|
|
97
102
|
cart {
|
|
98
103
|
...CartFragment
|
|
@@ -101,13 +106,14 @@
|
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
${e}
|
|
104
|
-
`,
|
|
109
|
+
`,dr=e=>`
|
|
105
110
|
mutation CartBuyerIdentityUpdate(
|
|
106
111
|
$cartId: ID!
|
|
107
112
|
$buyerIdentity: CartBuyerIdentityInput!
|
|
108
113
|
$numCartLines: Int = 250
|
|
109
114
|
$country: CountryCode = ZZ
|
|
110
|
-
|
|
115
|
+
$language: LanguageCode
|
|
116
|
+
) @inContext(country: $country, language: $language) {
|
|
111
117
|
cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
|
|
112
118
|
cart {
|
|
113
119
|
...CartFragment
|
|
@@ -116,13 +122,14 @@
|
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
${e}
|
|
119
|
-
`,
|
|
125
|
+
`,fr=e=>`
|
|
120
126
|
mutation CartAttributesUpdate(
|
|
121
127
|
$attributes: [AttributeInput!]!
|
|
122
128
|
$cartId: ID!
|
|
123
129
|
$numCartLines: Int = 250
|
|
124
130
|
$country: CountryCode = ZZ
|
|
125
|
-
|
|
131
|
+
$language: LanguageCode
|
|
132
|
+
) @inContext(country: $country, language: $language) {
|
|
126
133
|
cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {
|
|
127
134
|
cart {
|
|
128
135
|
...CartFragment
|
|
@@ -131,13 +138,14 @@
|
|
|
131
138
|
}
|
|
132
139
|
|
|
133
140
|
${e}
|
|
134
|
-
`,
|
|
141
|
+
`,yr=e=>`
|
|
135
142
|
mutation CartDiscountCodesUpdate(
|
|
136
143
|
$cartId: ID!
|
|
137
144
|
$discountCodes: [String!]
|
|
138
145
|
$numCartLines: Int = 250
|
|
139
146
|
$country: CountryCode = ZZ
|
|
140
|
-
|
|
147
|
+
$language: LanguageCode
|
|
148
|
+
) @inContext(country: $country, language: $language) {
|
|
141
149
|
cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
|
|
142
150
|
cart {
|
|
143
151
|
...CartFragment
|
|
@@ -146,12 +154,13 @@
|
|
|
146
154
|
}
|
|
147
155
|
|
|
148
156
|
${e}
|
|
149
|
-
`,
|
|
157
|
+
`,gr=e=>`
|
|
150
158
|
query CartQuery(
|
|
151
159
|
$id: ID!
|
|
152
160
|
$numCartLines: Int = 250
|
|
153
161
|
$country: CountryCode = ZZ
|
|
154
|
-
|
|
162
|
+
$language: LanguageCode
|
|
163
|
+
) @inContext(country: $country, language: $language) {
|
|
155
164
|
cart(id: $id) {
|
|
156
165
|
...CartFragment
|
|
157
166
|
}
|
|
@@ -259,16 +268,16 @@
|
|
|
259
268
|
width
|
|
260
269
|
height
|
|
261
270
|
}
|
|
262
|
-
`,
|
|
263
|
-
Received "${t}".`);
|
|
264
|
-
You may run into unexpected errors if these versions don't match. Received verion: "${o}"; expected version "${ee}"`);const s=c=>c.includes("mock.shop"),a=c=>{const d=(c==null?void 0:c.storeDomain)??t;return d.includes("://")?d:`https://${d}`};return{getShopifyDomain:a,getStorefrontApiUrl(c){const d=a(c),l=d+(d.endsWith("/")?"api":"/api");return s(d)?l:`${l}/${(c==null?void 0:c.storefrontApiVersion)??o}/graphql.json`},getPrivateTokenHeaders(c){if(!r&&!(c!=null&&c.privateStorefrontToken)&&!s(t))throw new Error(ve+"You did not pass in a `privateStorefrontToken` while using `createStorefrontClient()` or `getPrivateTokenHeaders()`");return{"content-type":((c==null?void 0:c.contentType)??i)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-react","X-SDK-Variant-Source":"react","X-SDK-Version":o,"Shopify-Storefront-Private-Token":(c==null?void 0:c.privateStorefrontToken)??r??"",...c!=null&&c.buyerIp?{"Shopify-Storefront-Buyer-IP":c.buyerIp}:{}}},getPublicTokenHeaders(c){if(!n&&!(c!=null&&c.publicStorefrontToken)&&!s(t))throw new Error(ve+"You did not pass in a `publicStorefrontToken` while using `createStorefrontClient()` or `getPublicTokenHeaders()`");const d=(c==null?void 0:c.contentType)??i??"json";return je(d,o,(c==null?void 0:c.publicStorefrontToken)??n??"")}}}function je(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 Ge=new Set,ve="[h2:error:createStorefrontClient] ",gr="[h2:warn:createStorefrontClient] ",pr=e=>{Ge.has(e)||(console.warn(gr+e),Ge.add(e))},Ze={storeDomain:"test",storefrontToken:"abc123",storefrontApiVersion:ee,countryIsoCode:"US",languageIsoCode:"EN",getStorefrontApiUrl(){return""},getPublicTokenHeaders(){return{}},getShopifyDomain(){return""}},We=u.createContext(Ze);function Er({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!==ee&&console.warn(`<ShopifyProvider/>: This version of Hydrogen React is built for Shopify's Storefront API version ${ee}, 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=u.useMemo(()=>{function n(o){return(o==null?void 0:o.storeDomain)??t.storeDomain}return{...t,getPublicTokenHeaders(o){return je(o.contentType,t.storefrontApiVersion,o.storefrontToken??t.storefrontToken)},getShopifyDomain:n,getStorefrontApiUrl(o){const i=n({storeDomain:(o==null?void 0:o.storeDomain)??t.storeDomain});return`${i}${i.endsWith("/")?"":"/"}api/${(o==null?void 0:o.storefrontApiVersion)??t.storefrontApiVersion}/graphql.json`}}},[t]);return React.createElement(We.Provider,{value:r},e)}function ie(){const e=u.useContext(We);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}const be="shopifyCartId",Qe="Shopify-Storefront-Id",Je="Shopify-Storefront-Y",Xe="Shopify-Storefront-S",G="_shopify_y",Z="_shopify_s";var Cr=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function Sr(e){let t={},r,n,o=0,i=e.split(/;\s*/g),s,a;for(;o<i.length;o++)if(n=i[o],r=n.indexOf("="),~r){if(s=n.substring(0,r++).trim(),a=n.substring(r).trim(),a[0]==='"'&&(a=a.substring(1,a.length-1)),~a.indexOf("%"))try{a=decodeURIComponent(a)}catch{}Cr.has(n=s.toLowerCase())?n==="expires"?t.expires=new Date(a):n==="max-age"?t.maxage=+a:t[n]=a:t[s]=a}else(s=n.trim().toLowerCase())&&(s==="httponly"||s==="secure")&&(t[s]=!0);return t}function Tr(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 Ke="xxxx-4xxx-xxxx-xxxxxxxxxxxx";function ge(){let e="";try{const t=window.crypto,r=new Uint16Array(31);t.getRandomValues(r);let n=0;e=Ke.replace(/[x]/g,o=>{const i=r[n]%16,s=o==="x"?i:i&3|8;return n++,s.toString(16)}).toUpperCase()}catch{e=Ke.replace(/[x]/g,r=>{const n=Math.random()*16|0;return(r==="x"?n:n&3|8).toString(16)}).toUpperCase()}return`${_r()}-${e}`}function _r(){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 pe(e){const t=Sr(e);return{[G]:t[G]||"",[Z]:t[Z]||""}}function Ar(){const{storefrontId:e,getPublicTokenHeaders:t,getStorefrontApiUrl:r}=ie();return u.useCallback(({query:n,variables:o})=>{const i=t({contentType:"json"});e&&(i[Qe]=e);const s=pe(document.cookie);return i[Je]=s[G],i[Xe]=s[Z],fetch(r(),{method:"POST",headers:i,body:JSON.stringify({query:n.toString(),variables:o})}).then(a=>a.json()).catch(a=>({data:void 0,errors:a==null?void 0:a.toString()}))},[t,e,r])}function vr({numCartLines:e,cartFragment:t,countryCode:r="US"}){const n=Ar(),o=u.useCallback(p=>n({query:yr(t),variables:{id:p,numCartLines:e,country:r}}),[n,t,e,r]),i=u.useCallback(p=>n({query:ir(t),variables:{input:p,numCartLines:e,country:r}}),[t,r,n,e]),s=u.useCallback((p,f)=>n({query:ar(t),variables:{cartId:p,lines:f,numCartLines:e,country:r}}),[t,r,n,e]),a=u.useCallback((p,f)=>n({query:cr(t),variables:{cartId:p,lines:f,numCartLines:e,country:r}}),[t,r,n,e]),c=u.useCallback((p,f)=>n({query:sr(t),variables:{cartId:p,lines:f,numCartLines:e,country:r}}),[t,r,n,e]),d=u.useCallback((p,f)=>n({query:ur(t),variables:{cartId:p,note:f,numCartLines:e,country:r}}),[n,t,e,r]),l=u.useCallback((p,f)=>n({query:lr(t),variables:{cartId:p,buyerIdentity:f,numCartLines:e,country:r}}),[t,r,n,e]),h=u.useCallback((p,f)=>n({query:dr(t),variables:{cartId:p,attributes:f,numCartLines:e,country:r}}),[t,r,n,e]),g=u.useCallback((p,f)=>n({query:fr(t),variables:{cartId:p,discountCodes:f,numCartLines:e,country:r}}),[t,r,n,e]);return u.useMemo(()=>({cartFetch:o,cartCreate:i,cartLineAdd:s,cartLineUpdate:a,cartLineRemove:c,noteUpdate:d,buyerIdentityUpdate:l,cartAttributesUpdate:h,discountCodesUpdate:g,cartFragment:t}),[o,i,s,a,c,d,l,h,g,t])}function q(e,t){return{entry:[...(t==null?void 0:t.entryActions)||[],K({lastValidCart:r=>r==null?void 0:r.cart}),"onCartActionEntry","onCartActionOptimisticUI",e],on:{RESOLVE:{target:(t==null?void 0:t.resolveTarget)||"idle",actions:[K({prevCart:r=>r==null?void 0:r.lastValidCart,cart:(r,n)=>{var o;return(o=n==null?void 0:n.payload)==null?void 0:o.cart},rawCartResult:(r,n)=>{var o;return(o=n==null?void 0:n.payload)==null?void 0:o.rawCartResult},errors:r=>{}})]},ERROR:{target:(t==null?void 0:t.errorTarget)||"error",actions:[K({prevCart:r=>r==null?void 0:r.lastValidCart,cart:r=>r==null?void 0:r.lastValidCart,errors:(r,n)=>{var o;return(o=n==null?void 0:n.payload)==null?void 0:o.errors}})]},CART_COMPLETED:{target:"cartCompleted",actions:K({prevCart:r=>{},cart:r=>{},lastValidCart:r=>{},rawCartResult:r=>{},errors:r=>{}})}},exit:["onCartActionComplete",...(t==null?void 0:t.exitActions)||[]]}}const se={CART_FETCH:{target:"cartFetching"},CART_CREATE:{target:"cartCreating"},CART_SET:{target:"idle",actions:[K({rawCartResult:(e,t)=>t.payload.cart,cart:(e,t)=>we(t.payload.cart)})]}},ze={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 br(e){return Fe({id:"Cart",initial:e?"idle":"uninitialized",context:{cart:e&&we(e)},states:{uninitialized:{on:se},cartCompleted:{on:se},initializationError:{on:se},idle:{on:{...se,...ze}},error:{on:{...se,...ze}},cartFetching:q("cartFetchAction",{errorTarget:"initializationError"}),cartCreating:q("cartCreateAction",{errorTarget:"initializationError"}),cartLineRemoving:q("cartLineRemoveAction"),cartLineUpdating:q("cartLineUpdateAction"),cartLineAdding:q("cartLineAddAction"),noteUpdating:q("noteUpdateAction"),buyerIdentityUpdating:q("buyerIdentityUpdateAction"),cartAttributesUpdating:q("cartAttributesUpdateAction"),discountCodesUpdating:q("discountCodesUpdateAction")}})}function wr({numCartLines:e,onCartActionEntry:t,onCartActionOptimisticUI:r,onCartActionComplete:n,data:o,cartFragment:i,countryCode:s}){const{cartFetch:a,cartCreate:c,cartLineAdd:d,cartLineUpdate:l,cartLineRemove:h,noteUpdate:g,buyerIdentityUpdate:p,cartAttributesUpdate:f,discountCodesUpdate:b}=vr({numCartLines:e,cartFragment:i,countryCode:s}),T=u.useMemo(()=>br(o),[o]),[w,A,U]=rr(T,{actions:{cartFetchAction:async(m,y)=>{var _;if(y.type!=="CART_FETCH")return;const{data:C,errors:R}=await a((_=y==null?void 0:y.payload)==null?void 0:_.cartId),I=H(y,C==null?void 0:C.cart,R);A(I)},cartCreateAction:async(m,y)=>{var _;if(y.type!=="CART_CREATE")return;const{data:C,errors:R}=await c(y==null?void 0:y.payload),I=H(y,(_=C==null?void 0:C.cartCreate)==null?void 0:_.cart,R);A(I)},cartLineAddAction:async(m,y)=>{var _,v;if(y.type!=="CARTLINE_ADD"||!((_=m==null?void 0:m.cart)!=null&&_.id))return;const{data:C,errors:R}=await d(m.cart.id,y.payload.lines),I=H(y,(v=C==null?void 0:C.cartLinesAdd)==null?void 0:v.cart,R);A(I)},cartLineUpdateAction:async(m,y)=>{var _,v;if(y.type!=="CARTLINE_UPDATE"||!((_=m==null?void 0:m.cart)!=null&&_.id))return;const{data:C,errors:R}=await l(m.cart.id,y.payload.lines),I=H(y,(v=C==null?void 0:C.cartLinesUpdate)==null?void 0:v.cart,R);A(I)},cartLineRemoveAction:async(m,y)=>{var _,v;if(y.type!=="CARTLINE_REMOVE"||!((_=m==null?void 0:m.cart)!=null&&_.id))return;const{data:C,errors:R}=await h(m.cart.id,y.payload.lines),I=H(y,(v=C==null?void 0:C.cartLinesRemove)==null?void 0:v.cart,R);A(I)},noteUpdateAction:async(m,y)=>{var _,v;if(y.type!=="NOTE_UPDATE"||!((_=m==null?void 0:m.cart)!=null&&_.id))return;const{data:C,errors:R}=await g(m.cart.id,y.payload.note),I=H(y,(v=C==null?void 0:C.cartNoteUpdate)==null?void 0:v.cart,R);A(I)},buyerIdentityUpdateAction:async(m,y)=>{var _,v;if(y.type!=="BUYER_IDENTITY_UPDATE"||!((_=m==null?void 0:m.cart)!=null&&_.id))return;const{data:C,errors:R}=await p(m.cart.id,y.payload.buyerIdentity),I=H(y,(v=C==null?void 0:C.cartBuyerIdentityUpdate)==null?void 0:v.cart,R);A(I)},cartAttributesUpdateAction:async(m,y)=>{var _,v;if(y.type!=="CART_ATTRIBUTES_UPDATE"||!((_=m==null?void 0:m.cart)!=null&&_.id))return;const{data:C,errors:R}=await f(m.cart.id,y.payload.attributes),I=H(y,(v=C==null?void 0:C.cartAttributesUpdate)==null?void 0:v.cart,R);A(I)},discountCodesUpdateAction:async(m,y)=>{var _,v;if(y.type!=="DISCOUNT_CODES_UPDATE"||!((_=m==null?void 0:m.cart)!=null&&_.id))return;const{data:C,errors:R}=await b(m.cart.id,y.payload.discountCodes),I=H(y,(v=C==null?void 0:C.cartDiscountCodesUpdate)==null?void 0:v.cart,R);A(I)},...t&&{onCartActionEntry:(m,y)=>{Ir(y)&&t(m,y)}},...r&&{onCartActionOptimisticUI:K((m,y)=>r(m,y))},...n&&{onCartActionComplete:(m,y)=>{Pr(y)&&n(m,y)}}}});return u.useMemo(()=>[w,A,U],[w,A,U])}function we(e){return{...e,lines:j(e==null?void 0:e.lines),note:e.note??void 0}}function H(e,t,r){return r?{type:"ERROR",payload:{errors:r,cartActionEvent:e}}:t?{type:"RESOLVE",payload:{cart:we(t),rawCartResult:t,cartActionEvent:e}}:{type:"CART_COMPLETED",payload:{cartActionEvent:e}}}function Ir(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 Pr(e){return e.type==="RESOLVE"||e.type==="ERROR"||e.type==="CART_COMPLETED"}const et=u.createContext(null);function te(){const e=u.useContext(et);if(!e)throw new Error("Expected a Cart Context, but no Cart Context was found");return e}function Rr({children:e,numCartLines:t,onCreate:r,onLineAdd:n,onLineRemove:o,onLineUpdate:i,onNoteUpdate:s,onBuyerIdentityUpdate:a,onAttributesUpdate:c,onDiscountCodesUpdate:d,onCreateComplete:l,onLineAddComplete:h,onLineRemoveComplete:g,onLineUpdateComplete:p,onNoteUpdateComplete:f,onBuyerIdentityUpdateComplete:b,onAttributesUpdateComplete:T,onDiscountCodesUpdateComplete:w,data:A,cartFragment:U=hr,customerAccessToken:m,countryCode:y}){var At,vt,bt,wt,It,Pt,Rt;const C=ie();if(!C)throw new Error("<CartProvider> needs to be a descendant of <ShopifyProvider>");y=(y??C.countryIsoCode??"US").toUpperCase(),y&&(y=y.toUpperCase());const[R,I]=u.useState(y),[_,v]=u.useState(m),B=u.useRef(!1);(R!==y||_!==m)&&(I(y),v(m),B.current=!1);const[P,F]=wr({numCartLines:t,data:A,cartFragment:U,countryCode:y,onCartActionEntry(S,N){try{switch(N.type){case"CART_CREATE":return r==null?void 0:r();case"CARTLINE_ADD":return n==null?void 0:n();case"CARTLINE_REMOVE":return o==null?void 0:o();case"CARTLINE_UPDATE":return i==null?void 0:i();case"NOTE_UPDATE":return s==null?void 0:s();case"BUYER_IDENTITY_UPDATE":return a==null?void 0:a();case"CART_ATTRIBUTES_UPDATE":return c==null?void 0:c();case"DISCOUNT_CODES_UPDATE":return d==null?void 0:d()}}catch(V){console.error("Cart entry action failed",V)}},onCartActionOptimisticUI(S,N){var V,Y,M,ye;if(!S.cart)return{...S};switch(N.type){case"CARTLINE_REMOVE":return{...S,cart:{...S.cart,lines:(Y=(V=S==null?void 0:S.cart)==null?void 0:V.lines)==null?void 0:Y.filter(L=>(L==null?void 0:L.id)&&!N.payload.lines.includes(L==null?void 0:L.id))}};case"CARTLINE_UPDATE":return{...S,cart:{...S.cart,lines:(ye=(M=S==null?void 0:S.cart)==null?void 0:M.lines)==null?void 0:ye.map(L=>{const Ue=N.payload.lines.find(({id:Pn})=>Pn===(L==null?void 0:L.id));return Ue&&Ue.quantity?{...L,quantity:Ue.quantity}:L})}}}return{...S}},onCartActionComplete(S,N){const V=N.payload.cartActionEvent;try{switch(N.type){case"RESOLVE":switch(V.type){case"CART_CREATE":return l==null?void 0:l();case"CARTLINE_ADD":return h==null?void 0:h();case"CARTLINE_REMOVE":return g==null?void 0:g();case"CARTLINE_UPDATE":return p==null?void 0:p();case"NOTE_UPDATE":return f==null?void 0:f();case"BUYER_IDENTITY_UPDATE":return Ur(S,V)&&(B.current=!0),b==null?void 0:b();case"CART_ATTRIBUTES_UPDATE":return T==null?void 0:T();case"DISCOUNT_CODES_UPDATE":return w==null?void 0:w()}}}catch(Y){console.error("onCartActionComplete failed",Y)}}}),W=u.useRef(!1),oe=P.matches("cartCompleted"),X=(P.value==="idle"||P.value==="error"||P.value==="cartCompleted")&&y!==((bt=(vt=(At=P==null?void 0:P.context)==null?void 0:At.cart)==null?void 0:vt.buyerIdentity)==null?void 0:bt.countryCode)&&!P.context.errors,k=u.useRef(!1);u.useEffect(()=>{if(!W.current&&!k.current){if(!A&&Ie("localStorage")){k.current=!0;try{const S=window.localStorage.getItem(be);S&&F({type:"CART_FETCH",payload:{cartId:S}})}catch(S){console.warn("error fetching cartId"),console.warn(S)}}W.current=!0}},[A,W,F]),u.useEffect(()=>{!X||B.current||F({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:{countryCode:y,customerAccessToken:m}}})},[y,m,X,B,F]);const x=u.useCallback(S=>{if(!W.current)return console.warn("Cart isn't ready yet");F(S)},[F]);u.useEffect(()=>{var S,N,V;if((N=(S=P==null?void 0:P.context)==null?void 0:S.cart)!=null&&N.id&&Ie("localStorage"))try{window.localStorage.setItem(be,(V=P.context.cart)==null?void 0:V.id)}catch(Y){console.warn("Failed to save cartId to localStorage",Y)}},[(It=(wt=P==null?void 0:P.context)==null?void 0:wt.cart)==null?void 0:It.id]),u.useEffect(()=>{if(oe&&Ie("localStorage"))try{window.localStorage.removeItem(be)}catch(S){console.warn("Failed to delete cartId from localStorage",S)}},[oe]);const ae=u.useCallback(S=>{var N,V;y&&!((N=S.buyerIdentity)!=null&&N.countryCode)&&(S.buyerIdentity==null&&(S.buyerIdentity={}),S.buyerIdentity.countryCode=y),m&&!((V=S.buyerIdentity)!=null&&V.customerAccessToken)&&(S.buyerIdentity==null&&(S.buyerIdentity={}),S.buyerIdentity.customerAccessToken=m),x({type:"CART_CREATE",payload:S})},[y,m,x]),D=kr(P),In=u.useMemo(()=>{var S,N,V,Y;return{...((S=D==null?void 0:D.context)==null?void 0:S.cart)??{lines:[],attributes:[]},status:Dr(D.value),error:(N=D==null?void 0:D.context)==null?void 0:N.errors,totalQuantity:((Y=(V=D==null?void 0:D.context)==null?void 0:V.cart)==null?void 0:Y.totalQuantity)??0,cartCreate:ae,linesAdd(M){var ye,L;(L=(ye=D==null?void 0:D.context)==null?void 0:ye.cart)!=null&&L.id?x({type:"CARTLINE_ADD",payload:{lines:M}}):ae({lines:M})},linesRemove(M){x({type:"CARTLINE_REMOVE",payload:{lines:M}})},linesUpdate(M){x({type:"CARTLINE_UPDATE",payload:{lines:M}})},noteUpdate(M){x({type:"NOTE_UPDATE",payload:{note:M}})},buyerIdentityUpdate(M){x({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:M}})},cartAttributesUpdate(M){x({type:"CART_ATTRIBUTES_UPDATE",payload:{attributes:M}})},discountCodesUpdate(M){x({type:"DISCOUNT_CODES_UPDATE",payload:{discountCodes:M}})},cartFragment:U}},[ae,(Pt=D==null?void 0:D.context)==null?void 0:Pt.cart,(Rt=D==null?void 0:D.context)==null?void 0:Rt.errors,D.value,U,x]);return React.createElement(et.Provider,{value:In},e)}function Dr(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 kr(e){const[t,r]=u.useTransition(),[n,o]=u.useState(e),i=u.useRef(!1);t&&(i.current=!0);const s=u.useRef(!1);return!t&&i.current&&(s.current=!0),u.useEffect(()=>{r(()=>{s.current||o(e)})},[e]),s.current?e:n}function Ie(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 Ur(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 tt=u.createContext(null);function Or({children:e,data:t,initialVariantId:r}){const n=u.useMemo(()=>j(t.variants??{}),[t.variants]);if(!Mr(n))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const o=u.useMemo(()=>Nr(n),[n]),[i,s]=u.useState(()=>ot(r,n)),[a,c]=u.useState(()=>at(i));u.useEffect(()=>{const T=ot(r,n);s(T),c(at(T))},[r,n]);const d=u.useCallback((T,w)=>{c(A=>{const U={...A,[T]:w};return s(nt(n,U)),U})},[c,n]),l=u.useCallback((T,w)=>{const A=nt(n,{...a,[T]:w});return(A==null?void 0:A.availableForSale)??!0},[a,n]),h=u.useMemo(()=>j(t.sellingPlanGroups??{}).map(T=>({...T,sellingPlans:j((T==null?void 0:T.sellingPlans)??{})})),[t.sellingPlanGroups]),[g,p]=u.useState(void 0),f=u.useMemo(()=>{var T,w;if(!(!i||!g)){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(A=>{var U;return((U=A==null?void 0:A.sellingPlan)==null?void 0:U.id)===g.id})}},[i,g]),b=u.useMemo(()=>({product:t,variants:n,variantsConnection:t.variants,options:o,selectedVariant:i,setSelectedVariant:s,selectedOptions:a,setSelectedOption:d,setSelectedOptions:c,isOptionInStock:l,selectedSellingPlan:g,setSelectedSellingPlan:p,selectedSellingPlanAllocation:f,sellingPlanGroups:h,sellingPlanGroupsConnection:t.sellingPlanGroups}),[t,l,o,a,g,f,i,h,d,n]);return React.createElement(tt.Provider,{value:b},e)}function rt(){const e=u.useContext(tt);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function nt(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(o=>Object.entries(t).every(([i,s])=>{var a;return(a=o==null?void 0:o.selectedOptions)==null?void 0:a.some(c=>(c==null?void 0:c.name)===i&&(c==null?void 0:c.value)===s)}))}function Nr(e){const t=e.reduce((r,n)=>{var o;if(!n.selectedOptions)throw new Error("'getOptions' requires 'variant.selectedOptions'");return(o=n==null?void 0:n.selectedOptions)==null||o.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 ot(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 at(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 Mr(e){return!(!e||!Array.isArray(e))}function Ee(e){const{as:t,onClick:r,defaultOnClick:n,children:o,buttonRef:i,...s}=e,a=u.useCallback(d=>{if(r){const l=r(d);if(typeof l=="boolean"&&l===!1||d!=null&&d.defaultPrevented)return}n==null||n(d)},[n,r]),c=t||"button";return React.createElement(c,{ref:i,onClick:a,...s},o)}function Vr(e){const[t,r]=u.useState(!1),{variantId:n,quantity:o=1,attributes:i,sellingPlanId:s,onClick:a,children:c,accessibleAddingToCartLabel:d,...l}=e,{status:h,linesAdd:g}=te(),{selectedVariant:p}=rt(),f=n??(p==null?void 0:p.id)??"",b=n===null||f===""||p===null||t||l.disabled;u.useEffect(()=>{t&&h==="idle"&&r(!1)},[h,t]);const T=u.useCallback(()=>{r(!0),g([{quantity:o,merchandiseId:f||"",attributes:i,sellingPlanId:s}])},[g,o,f,i,s]);return O.createElement(O.Fragment,null,O.createElement(Ee,{...l,disabled:b,onClick:a,defaultOnClick:T},c),d?O.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 Pe={PAGE_VIEW:"PAGE_VIEW",ADD_TO_CART:"ADD_TO_CART"},Ce={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"},it={hydrogen:"hydrogen",headless:"headless"},st={hydrogen:"6167201",headless:"12875497473"};function re(e,t){return{schema_id:e,payload:t,metadata:{event_created_at_ms:Date.now()}}}function $(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:o,hash:i}=new URL(e),s=o.split("/"),a=s[s.length-1],c=s[s.length-2];return!a||!c?t:{id:`${a}${r}${i}`||"",resource:c??null,resourceId:a||null,search:r,searchParams:n,hash:i}}catch{return t}}function J(e,t){return typeof e!="object"?{}:(Object.entries(e).forEach(([r,n])=>{n&&(t[r]=n)}),t)}function Lr(e){return typeof document>"u"?(console.error(`${e} should only be used within the useEffect callback or event handlers`),!0):!1}const xr="trekkie_storefront_page_view/1.4",Fr="myshopify.dev";function qr(e){const t=e,{id:r,resource:n}=$(t.resourceId),o=n?n.toLowerCase():void 0;return[re(xr,J({pageType:t.pageType,customerId:t.customerId,resourceType:o,resourceId:parseInt(r)},Hr(t)))]}function Hr(e){return{appClientId:e.shopifySalesChannel?st[e.shopifySalesChannel]:st.headless,isMerchantRequest:$r(e.url),hydrogenSubchannelId:e.storefrontId||"0",isPersistentCookie:e.hasUserConsent,uniqToken:e.uniqueToken,visitToken:e.visitToken,microSessionId:ge(),microSessionCount:1,url:e.url,path:e.path,search:e.search,referrer:e.referrer,title:e.title,shopId:parseInt($(e.shopId).id),currency:e.currency,contentLanguage:e.acceptedLanguage||"en"}}function $r(e){if(typeof e!="string")return!1;const t=new URL(e).hostname;return t.indexOf(Fr)!==-1||t==="localhost"}const ce="custom_storefront_customer_tracking/1.0",Br="page_rendered",Yr="collection_page_rendered",jr="product_page_rendered",Gr="product_added_to_cart",Zr="search_submitted";function Wr(e){const t=e,r={canonical_url:t.canonicalUrl||t.url,customer_id:t.customerId},n=t.pageType,o=[];switch(o.push(re(ce,J({event_name:Br,...r},ue(t)))),n){case Ce.collection:o.push(re(ce,J({event_name:Yr,...r,collection_name:t.collectionHandle},ue(t))));break;case Ce.product:o.push(re(ce,J({event_name:jr,...r,products:ct(t.products),total_value:t.totalValue},ue(t))));break;case Ce.search:o.push(re(ce,J({event_name:Zr,...r,search_string:t.searchString},ue(t))));break}return o}function Qr(e){const t=e,r=$(t.cartId),n=r!=null&&r.id?`${r.id}`:null;return[re(ce,J({event_name:Gr,customerId:t.customerId,cart_token:n,total_value:t.totalValue,products:ct(t.products)},ue(t)))]}function ue(e){return{source:e.shopifySalesChannel||it.headless,hydrogenSubchannelId:e.storefrontId||"0",is_persistent_cookie:e.hasUserConsent,ccpa_enforced:!1,gdpr_enforced:!1,unique_token:e.uniqueToken,event_time:Date.now(),event_id:ge(),event_source_url:e.url,referrer:e.referrer,user_agent:e.userAgent,navigation_type:e.navigationType,navigation_api:e.navigationApi,shop_id:parseInt($(e.shopId).id),currency:e.currency}}function ct(e){return e?e.map(t=>{const r=J({variant_gid:t.variantGid,category:t.category,sku:t.sku,product_id:parseInt($(t.productGid).id),variant_id:parseInt($(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 Jr(e,t){const{eventName:r,payload:n}=e;if(!n.hasUserConsent)return Promise.resolve();let o=[];if(r===Pe.PAGE_VIEW){const i=n;o=o.concat(qr(i),Wr(i))}else r===Pe.ADD_TO_CART&&(o=o.concat(Qr(n)));return o.length?Xr(o,t):Promise.resolve()}const ut="sendShopifyAnalytics request is unsuccessful";function Xr(e,t){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(ut,`
|
|
271
|
+
`,te="2023-07";function mr(e){const{storeDomain:t,privateStorefrontToken:r,publicStorefrontToken:n,storefrontApiVersion:a=te,contentType:i}=e;if(!t)throw new Error(be+`\`storeDomain\` is required when creating a new Storefront client.
|
|
272
|
+
Received "${t}".`);a!==te&&Er(`The Storefront API version that you're using is different than the version this build of Hydrogen React is targeting.
|
|
273
|
+
You may run into unexpected errors if these versions don't match. Received verion: "${a}"; expected version "${te}"`);const s=c=>c.includes("mock.shop"),o=c=>{const f=(c==null?void 0:c.storeDomain)??t;return f.includes("://")?f:`https://${f}`};return{getShopifyDomain:o,getStorefrontApiUrl(c){const f=o(c),l=f+(f.endsWith("/")?"api":"/api");return s(f)?l:`${l}/${(c==null?void 0:c.storefrontApiVersion)??a}/graphql.json`},getPrivateTokenHeaders(c){if(!r&&!(c!=null&&c.privateStorefrontToken)&&!s(t))throw new Error(be+"You did not pass in a `privateStorefrontToken` while using `createStorefrontClient()` or `getPrivateTokenHeaders()`");return{"content-type":((c==null?void 0:c.contentType)??i)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-react","X-SDK-Variant-Source":"react","X-SDK-Version":a,"Shopify-Storefront-Private-Token":(c==null?void 0:c.privateStorefrontToken)??r??"",...c!=null&&c.buyerIp?{"Shopify-Storefront-Buyer-IP":c.buyerIp}:{}}},getPublicTokenHeaders(c){if(!n&&!(c!=null&&c.publicStorefrontToken)&&!s(t))throw new Error(be+"You did not pass in a `publicStorefrontToken` while using `createStorefrontClient()` or `getPublicTokenHeaders()`");const f=(c==null?void 0:c.contentType)??i??"json";return Ge(f,a,(c==null?void 0:c.publicStorefrontToken)??n??"")}}}function Ge(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,be="[h2:error:createStorefrontClient] ",pr="[h2:warn:createStorefrontClient] ",Er=e=>{Ze.has(e)||(console.warn(pr+e),Ze.add(e))},We={storeDomain:"test",storefrontToken:"abc123",storefrontApiVersion:te,countryIsoCode:"US",languageIsoCode:"EN",getStorefrontApiUrl(){return""},getPublicTokenHeaders(){return{}},getShopifyDomain(){return""}},Qe=u.createContext(We);function Sr({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!==te&&console.warn(`<ShopifyProvider/>: This version of Hydrogen React is built for Shopify's Storefront API version ${te}, 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=u.useMemo(()=>{function n(a){return(a==null?void 0:a.storeDomain)??t.storeDomain}return{...t,getPublicTokenHeaders(a){return Ge(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(Qe.Provider,{value:r},e)}function se(){const e=u.useContext(Qe);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}const we="shopifyCartId",Je="Shopify-Storefront-Id",Xe="Shopify-Storefront-Y",Ke="Shopify-Storefront-S",Z="_shopify_y",W="_shopify_s";var Tr=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function Cr(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{}Tr.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 _r(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 ze="xxxx-4xxx-xxxx-xxxxxxxxxxxx";function pe(){let e="";try{const t=window.crypto,r=new Uint16Array(31);t.getRandomValues(r);let n=0;e=ze.replace(/[x]/g,a=>{const i=r[n]%16,s=a==="x"?i:i&3|8;return n++,s.toString(16)}).toUpperCase()}catch{e=ze.replace(/[x]/g,r=>{const n=Math.random()*16|0;return(r==="x"?n:n&3|8).toString(16)}).toUpperCase()}return`${Ar()}-${e}`}function Ar(){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 Ee(e){const t=Cr(e);return{[Z]:t[Z]||"",[W]:t[W]||""}}function vr(){const{storefrontId:e,getPublicTokenHeaders:t,getStorefrontApiUrl:r}=se();return u.useCallback(({query:n,variables:a})=>{const i=t({contentType:"json"});e&&(i[Je]=e);const s=Ee(document.cookie);return i[Xe]=s[Z],i[Ke]=s[W],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 br({numCartLines:e,cartFragment:t,countryCode:r="US",languageCode:n="EN"}){const a=vr(),i=u.useCallback(d=>a({query:gr(t),variables:{id:d,numCartLines:e,country:r,language:n}}),[a,t,e,r,n]),s=u.useCallback(d=>a({query:sr(t),variables:{input:d,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),o=u.useCallback((d,C)=>a({query:ir(t),variables:{cartId:d,lines:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),c=u.useCallback((d,C)=>a({query:ur(t),variables:{cartId:d,lines:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),f=u.useCallback((d,C)=>a({query:cr(t),variables:{cartId:d,lines:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),l=u.useCallback((d,C)=>a({query:lr(t),variables:{cartId:d,note:C,numCartLines:e,country:r,language:n}}),[a,t,e,r,n]),y=u.useCallback((d,C)=>a({query:dr(t),variables:{cartId:d,buyerIdentity:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),h=u.useCallback((d,C)=>a({query:fr(t),variables:{cartId:d,attributes:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),S=u.useCallback((d,C)=>a({query:yr(t),variables:{cartId:d,discountCodes:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]);return u.useMemo(()=>({cartFetch:i,cartCreate:s,cartLineAdd:o,cartLineUpdate:c,cartLineRemove:f,noteUpdate:l,buyerIdentityUpdate:y,cartAttributesUpdate:h,discountCodesUpdate:S,cartFragment:t}),[i,s,o,c,f,l,y,h,S,t])}function H(e,t){return{entry:[...(t==null?void 0:t.entryActions)||[],z({lastValidCart:r=>r==null?void 0:r.cart}),"onCartActionEntry","onCartActionOptimisticUI",e],on:{RESOLVE:{target:(t==null?void 0:t.resolveTarget)||"idle",actions:[z({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:[z({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:z({prevCart:r=>{},cart:r=>{},lastValidCart:r=>{},rawCartResult:r=>{},errors:r=>{}})}},exit:["onCartActionComplete",...(t==null?void 0:t.exitActions)||[]]}}const ce={CART_FETCH:{target:"cartFetching"},CART_CREATE:{target:"cartCreating"},CART_SET:{target:"idle",actions:[z({rawCartResult:(e,t)=>t.payload.cart,cart:(e,t)=>Ie(t.payload.cart)})]}},et={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 wr(e){return $e({id:"Cart",initial:e?"idle":"uninitialized",context:{cart:e&&Ie(e)},states:{uninitialized:{on:ce},cartCompleted:{on:ce},initializationError:{on:ce},idle:{on:{...ce,...et}},error:{on:{...ce,...et}},cartFetching:H("cartFetchAction",{errorTarget:"initializationError"}),cartCreating:H("cartCreateAction",{errorTarget:"initializationError"}),cartLineRemoving:H("cartLineRemoveAction"),cartLineUpdating:H("cartLineUpdateAction"),cartLineAdding:H("cartLineAddAction"),noteUpdating:H("noteUpdateAction"),buyerIdentityUpdating:H("buyerIdentityUpdateAction"),cartAttributesUpdating:H("cartAttributesUpdateAction"),discountCodesUpdating:H("discountCodesUpdateAction")}})}function Ir({numCartLines:e,onCartActionEntry:t,onCartActionOptimisticUI:r,onCartActionComplete:n,data:a,cartFragment:i,countryCode:s,languageCode:o}){const{cartFetch:c,cartCreate:f,cartLineAdd:l,cartLineUpdate:y,cartLineRemove:h,noteUpdate:S,buyerIdentityUpdate:d,cartAttributesUpdate:C,discountCodesUpdate:_}=br({numCartLines:e,cartFragment:i,countryCode:s,languageCode:o}),R=u.useMemo(()=>wr(a),[a]),[I,v,D]=nr(R,{actions:{cartFetchAction:async(g,m)=>{var A;if(m.type!=="CART_FETCH")return;const{data:E,errors:P}=await c((A=m==null?void 0:m.payload)==null?void 0:A.cartId),b=B(m,E==null?void 0:E.cart,P);v(b)},cartCreateAction:async(g,m)=>{var A;if(m.type!=="CART_CREATE")return;const{data:E,errors:P}=await f(m==null?void 0:m.payload),b=B(m,(A=E==null?void 0:E.cartCreate)==null?void 0:A.cart,P);v(b)},cartLineAddAction:async(g,m)=>{var A,w;if(m.type!=="CARTLINE_ADD"||!((A=g==null?void 0:g.cart)!=null&&A.id))return;const{data:E,errors:P}=await l(g.cart.id,m.payload.lines),b=B(m,(w=E==null?void 0:E.cartLinesAdd)==null?void 0:w.cart,P);v(b)},cartLineUpdateAction:async(g,m)=>{var A,w;if(m.type!=="CARTLINE_UPDATE"||!((A=g==null?void 0:g.cart)!=null&&A.id))return;const{data:E,errors:P}=await y(g.cart.id,m.payload.lines),b=B(m,(w=E==null?void 0:E.cartLinesUpdate)==null?void 0:w.cart,P);v(b)},cartLineRemoveAction:async(g,m)=>{var A,w;if(m.type!=="CARTLINE_REMOVE"||!((A=g==null?void 0:g.cart)!=null&&A.id))return;const{data:E,errors:P}=await h(g.cart.id,m.payload.lines),b=B(m,(w=E==null?void 0:E.cartLinesRemove)==null?void 0:w.cart,P);v(b)},noteUpdateAction:async(g,m)=>{var A,w;if(m.type!=="NOTE_UPDATE"||!((A=g==null?void 0:g.cart)!=null&&A.id))return;const{data:E,errors:P}=await S(g.cart.id,m.payload.note),b=B(m,(w=E==null?void 0:E.cartNoteUpdate)==null?void 0:w.cart,P);v(b)},buyerIdentityUpdateAction:async(g,m)=>{var A,w;if(m.type!=="BUYER_IDENTITY_UPDATE"||!((A=g==null?void 0:g.cart)!=null&&A.id))return;const{data:E,errors:P}=await d(g.cart.id,m.payload.buyerIdentity),b=B(m,(w=E==null?void 0:E.cartBuyerIdentityUpdate)==null?void 0:w.cart,P);v(b)},cartAttributesUpdateAction:async(g,m)=>{var A,w;if(m.type!=="CART_ATTRIBUTES_UPDATE"||!((A=g==null?void 0:g.cart)!=null&&A.id))return;const{data:E,errors:P}=await C(g.cart.id,m.payload.attributes),b=B(m,(w=E==null?void 0:E.cartAttributesUpdate)==null?void 0:w.cart,P);v(b)},discountCodesUpdateAction:async(g,m)=>{var A,w;if(m.type!=="DISCOUNT_CODES_UPDATE"||!((A=g==null?void 0:g.cart)!=null&&A.id))return;const{data:E,errors:P}=await _(g.cart.id,m.payload.discountCodes),b=B(m,(w=E==null?void 0:E.cartDiscountCodesUpdate)==null?void 0:w.cart,P);v(b)},...t&&{onCartActionEntry:(g,m)=>{Pr(m)&&t(g,m)}},...r&&{onCartActionOptimisticUI:z((g,m)=>r(g,m))},...n&&{onCartActionComplete:(g,m)=>{Rr(m)&&n(g,m)}}}});return u.useMemo(()=>[I,v,D],[I,v,D])}function Ie(e){return{...e,lines:G(e==null?void 0:e.lines),note:e.note??void 0}}function B(e,t,r){return r?{type:"ERROR",payload:{errors:r,cartActionEvent:e}}:t?{type:"RESOLVE",payload:{cart:Ie(t),rawCartResult:t,cartActionEvent:e}}:{type:"CART_COMPLETED",payload:{cartActionEvent:e}}}function Pr(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 Rr(e){return e.type==="RESOLVE"||e.type==="ERROR"||e.type==="CART_COMPLETED"}const tt=u.createContext(null);function re(){const e=u.useContext(tt);if(!e)throw new Error("Expected a Cart Context, but no Cart Context was found");return e}function Dr({children:e,numCartLines:t,onCreate:r,onLineAdd:n,onLineRemove:a,onLineUpdate:i,onNoteUpdate:s,onBuyerIdentityUpdate:o,onAttributesUpdate:c,onDiscountCodesUpdate:f,onCreateComplete:l,onLineAddComplete:y,onLineRemoveComplete:h,onLineUpdateComplete:S,onNoteUpdateComplete:d,onBuyerIdentityUpdateComplete:C,onAttributesUpdateComplete:_,onDiscountCodesUpdateComplete:R,data:I,cartFragment:v=hr,customerAccessToken:D,countryCode:g,languageCode:m}){var vt,bt,wt,It,Pt,Rt,Dt;const E=se();if(!E)throw new Error("<CartProvider> needs to be a descendant of <ShopifyProvider>");g=(g??E.countryIsoCode??"US").toUpperCase(),m=(m??E.languageIsoCode??"EN").toUpperCase(),g&&(g=g.toUpperCase());const[P,b]=u.useState(g),[A,w]=u.useState(D),$=u.useRef(!1);(P!==g||A!==D)&&(b(g),w(D),$.current=!1);const[k,q]=Ir({numCartLines:t,data:I,cartFragment:v,countryCode:g,languageCode:m,onCartActionEntry(T,M){try{switch(M.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 c==null?void 0:c();case"DISCOUNT_CODES_UPDATE":return f==null?void 0:f()}}catch(L){console.error("Cart entry action failed",L)}},onCartActionOptimisticUI(T,M){var L,j,V,ge;if(!T.cart)return{...T};switch(M.type){case"CARTLINE_REMOVE":return{...T,cart:{...T.cart,lines:(j=(L=T==null?void 0:T.cart)==null?void 0:L.lines)==null?void 0:j.filter(x=>(x==null?void 0:x.id)&&!M.payload.lines.includes(x==null?void 0:x.id))}};case"CARTLINE_UPDATE":return{...T,cart:{...T.cart,lines:(ge=(V=T==null?void 0:T.cart)==null?void 0:V.lines)==null?void 0:ge.map(x=>{const Oe=M.payload.lines.find(({id:Rn})=>Rn===(x==null?void 0:x.id));return Oe&&Oe.quantity?{...x,quantity:Oe.quantity}:x})}}}return{...T}},onCartActionComplete(T,M){const L=M.payload.cartActionEvent;try{switch(M.type){case"RESOLVE":switch(L.type){case"CART_CREATE":return l==null?void 0:l();case"CARTLINE_ADD":return y==null?void 0:y();case"CARTLINE_REMOVE":return h==null?void 0:h();case"CARTLINE_UPDATE":return S==null?void 0:S();case"NOTE_UPDATE":return d==null?void 0:d();case"BUYER_IDENTITY_UPDATE":return Or(T,L)&&($.current=!0),C==null?void 0:C();case"CART_ATTRIBUTES_UPDATE":return _==null?void 0:_();case"DISCOUNT_CODES_UPDATE":return R==null?void 0:R()}}}catch(j){console.error("onCartActionComplete failed",j)}}}),Q=u.useRef(!1),K=k.matches("cartCompleted"),U=(k.value==="idle"||k.value==="error"||k.value==="cartCompleted")&&g!==((wt=(bt=(vt=k==null?void 0:k.context)==null?void 0:vt.cart)==null?void 0:bt.buyerIdentity)==null?void 0:wt.countryCode)&&!k.context.errors,oe=u.useRef(!1);u.useEffect(()=>{if(!Q.current&&!oe.current){if(!I&&Pe("localStorage")){oe.current=!0;try{const T=window.localStorage.getItem(we);T&&q({type:"CART_FETCH",payload:{cartId:T}})}catch(T){console.warn("error fetching cartId"),console.warn(T)}}Q.current=!0}},[I,Q,q]),u.useEffect(()=>{!U||$.current||q({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:{countryCode:g,customerAccessToken:D}}})},[g,D,U,$,q]);const F=u.useCallback(T=>{if(!Q.current)return console.warn("Cart isn't ready yet");q(T)},[q]);u.useEffect(()=>{var T,M,L;if((M=(T=k==null?void 0:k.context)==null?void 0:T.cart)!=null&&M.id&&Pe("localStorage"))try{window.localStorage.setItem(we,(L=k.context.cart)==null?void 0:L.id)}catch(j){console.warn("Failed to save cartId to localStorage",j)}},[(Pt=(It=k==null?void 0:k.context)==null?void 0:It.cart)==null?void 0:Pt.id]),u.useEffect(()=>{if(K&&Pe("localStorage"))try{window.localStorage.removeItem(we)}catch(T){console.warn("Failed to delete cartId from localStorage",T)}},[K]);const ie=u.useCallback(T=>{var M,L;g&&!((M=T.buyerIdentity)!=null&&M.countryCode)&&(T.buyerIdentity==null&&(T.buyerIdentity={}),T.buyerIdentity.countryCode=g),D&&!((L=T.buyerIdentity)!=null&&L.customerAccessToken)&&(T.buyerIdentity==null&&(T.buyerIdentity={}),T.buyerIdentity.customerAccessToken=D),F({type:"CART_CREATE",payload:T})},[g,D,F]),O=Ur(k),Pn=u.useMemo(()=>{var T,M,L,j;return{...((T=O==null?void 0:O.context)==null?void 0:T.cart)??{lines:[],attributes:[]},status:kr(O.value),error:(M=O==null?void 0:O.context)==null?void 0:M.errors,totalQuantity:((j=(L=O==null?void 0:O.context)==null?void 0:L.cart)==null?void 0:j.totalQuantity)??0,cartCreate:ie,linesAdd(V){var ge,x;(x=(ge=O==null?void 0:O.context)==null?void 0:ge.cart)!=null&&x.id?F({type:"CARTLINE_ADD",payload:{lines:V}}):ie({lines:V})},linesRemove(V){F({type:"CARTLINE_REMOVE",payload:{lines:V}})},linesUpdate(V){F({type:"CARTLINE_UPDATE",payload:{lines:V}})},noteUpdate(V){F({type:"NOTE_UPDATE",payload:{note:V}})},buyerIdentityUpdate(V){F({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:V}})},cartAttributesUpdate(V){F({type:"CART_ATTRIBUTES_UPDATE",payload:{attributes:V}})},discountCodesUpdate(V){F({type:"DISCOUNT_CODES_UPDATE",payload:{discountCodes:V}})},cartFragment:v}},[ie,(Rt=O==null?void 0:O.context)==null?void 0:Rt.cart,(Dt=O==null?void 0:O.context)==null?void 0:Dt.errors,O.value,v,F]);return React.createElement(tt.Provider,{value:Pn},e)}function kr(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 Ur(e){const[t,r]=u.useTransition(),[n,a]=u.useState(e),i=u.useRef(!1);t&&(i.current=!0);const s=u.useRef(!1);return!t&&i.current&&(s.current=!0),u.useEffect(()=>{r(()=>{s.current||a(e)})},[e]),s.current?e:n}function Pe(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 Or(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 rt=u.createContext(null);function Nr({children:e,data:t,initialVariantId:r}){const n=u.useMemo(()=>G(t.variants??{}),[t.variants]);if(!Vr(n))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const a=u.useMemo(()=>Mr(n),[n]),[i,s]=u.useState(()=>ot(r,n)),[o,c]=u.useState(()=>it(i));u.useEffect(()=>{const _=ot(r,n);s(_),c(it(_))},[r,n]);const f=u.useCallback((_,R)=>{c(I=>{const v={...I,[_]:R};return s(at(n,v)),v})},[c,n]),l=u.useCallback((_,R)=>{const I=at(n,{...o,[_]:R});return(I==null?void 0:I.availableForSale)??!0},[o,n]),y=u.useMemo(()=>G(t.sellingPlanGroups??{}).map(_=>({..._,sellingPlans:G((_==null?void 0:_.sellingPlans)??{})})),[t.sellingPlanGroups]),[h,S]=u.useState(void 0),d=u.useMemo(()=>{var _,R;if(!(!i||!h)){if(!((_=i.sellingPlanAllocations)!=null&&_.nodes)&&!((R=i.sellingPlanAllocations)!=null&&R.edges))throw new Error("<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation");return G(i.sellingPlanAllocations).find(I=>{var v;return((v=I==null?void 0:I.sellingPlan)==null?void 0:v.id)===h.id})}},[i,h]),C=u.useMemo(()=>({product:t,variants:n,variantsConnection:t.variants,options:a,selectedVariant:i,setSelectedVariant:s,selectedOptions:o,setSelectedOption:f,setSelectedOptions:c,isOptionInStock:l,selectedSellingPlan:h,setSelectedSellingPlan:S,selectedSellingPlanAllocation:d,sellingPlanGroups:y,sellingPlanGroupsConnection:t.sellingPlanGroups}),[t,l,a,o,h,d,i,y,f,n]);return React.createElement(rt.Provider,{value:C},e)}function nt(){const e=u.useContext(rt);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function at(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(c=>(c==null?void 0:c.name)===i&&(c==null?void 0:c.value)===s)}))}function Mr(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 ot(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 it(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 Vr(e){return!(!e||!Array.isArray(e))}function Se(e){const{as:t,onClick:r,defaultOnClick:n,children:a,buttonRef:i,...s}=e,o=u.useCallback(f=>{if(r){const l=r(f);if(typeof l=="boolean"&&l===!1||f!=null&&f.defaultPrevented)return}n==null||n(f)},[n,r]),c=t||"button";return React.createElement(c,{ref:i,onClick:o,...s},a)}function Lr(e){const[t,r]=u.useState(!1),{variantId:n,quantity:a=1,attributes:i,sellingPlanId:s,onClick:o,children:c,accessibleAddingToCartLabel:f,...l}=e,{status:y,linesAdd:h}=re(),{selectedVariant:S}=nt(),d=n??(S==null?void 0:S.id)??"",C=n===null||d===""||S===null||t||l.disabled;u.useEffect(()=>{t&&y==="idle"&&r(!1)},[y,t]);const _=u.useCallback(()=>{r(!0),h([{quantity:a,merchandiseId:d||"",attributes:i,sellingPlanId:s}])},[h,a,d,i,s]);return N.createElement(N.Fragment,null,N.createElement(Se,{...l,disabled:C,onClick:o,defaultOnClick:_},c),f?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?f:null):null)}const Re={PAGE_VIEW:"PAGE_VIEW",ADD_TO_CART:"ADD_TO_CART"},Te={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"},st={hydrogen:"hydrogen",headless:"headless"},ct={hydrogen:"6167201",headless:"12875497473"};function ne(e,t){return{schema_id:e,payload:t,metadata:{event_created_at_ms:Date.now()}}}function Y(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],c=s[s.length-2];return!o||!c?t:{id:`${o}${r}${i}`||"",resource:c??null,resourceId:o||null,search:r,searchParams:n,hash:i}}catch{return t}}function X(e,t){return typeof e!="object"?{}:(Object.entries(e).forEach(([r,n])=>{n&&(t[r]=n)}),t)}function xr(e){return typeof document>"u"?(console.error(`${e} should only be used within the useEffect callback or event handlers`),!0):!1}const Fr="trekkie_storefront_page_view/1.4",$r="myshopify.dev";function qr(e){const t=e,{id:r,resource:n}=Y(t.resourceId),a=n?n.toLowerCase():void 0;return[ne(Fr,X({pageType:t.pageType,customerId:t.customerId,resourceType:a,resourceId:parseInt(r)},Hr(t)))]}function Hr(e){return{appClientId:e.shopifySalesChannel?ct[e.shopifySalesChannel]:ct.headless,isMerchantRequest:Br(e.url),hydrogenSubchannelId:e.storefrontId||"0",isPersistentCookie:e.hasUserConsent,uniqToken:e.uniqueToken,visitToken:e.visitToken,microSessionId:pe(),microSessionCount:1,url:e.url,path:e.path,search:e.search,referrer:e.referrer,title:e.title,shopId:parseInt(Y(e.shopId).id),currency:e.currency,contentLanguage:e.acceptedLanguage||"en"}}function Br(e){if(typeof e!="string")return!1;const t=new URL(e).hostname;return t.indexOf($r)!==-1||t==="localhost"}const ue="custom_storefront_customer_tracking/1.0",Yr="page_rendered",jr="collection_page_rendered",Gr="product_page_rendered",Zr="product_added_to_cart",Wr="search_submitted";function Qr(e){const t=e,r={canonical_url:t.canonicalUrl||t.url,customer_id:t.customerId},n=t.pageType,a=[];switch(a.push(ne(ue,X({event_name:Yr,...r},le(t)))),n){case Te.collection:a.push(ne(ue,X({event_name:jr,...r,collection_name:t.collectionHandle},le(t))));break;case Te.product:a.push(ne(ue,X({event_name:Gr,...r,products:ut(t.products),total_value:t.totalValue},le(t))));break;case Te.search:a.push(ne(ue,X({event_name:Wr,...r,search_string:t.searchString},le(t))));break}return a}function Jr(e){const t=e,r=Y(t.cartId),n=r!=null&&r.id?`${r.id}`:null;return[ne(ue,X({event_name:Zr,customerId:t.customerId,cart_token:n,total_value:t.totalValue,products:ut(t.products)},le(t)))]}function le(e){return{source:e.shopifySalesChannel||st.headless,hydrogenSubchannelId:e.storefrontId||"0",is_persistent_cookie:e.hasUserConsent,ccpa_enforced:!1,gdpr_enforced:!1,unique_token:e.uniqueToken,event_time:Date.now(),event_id:pe(),event_source_url:e.url,referrer:e.referrer,user_agent:e.userAgent,navigation_type:e.navigationType,navigation_api:e.navigationApi,shop_id:parseInt(Y(e.shopId).id),currency:e.currency}}function ut(e){return e?e.map(t=>{const r=X({variant_gid:t.variantGid,category:t.category,sku:t.sku,product_id:parseInt(Y(t.productGid).id),variant_id:parseInt(Y(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 Xr(e,t){const{eventName:r,payload:n}=e;if(!n.hasUserConsent)return Promise.resolve();let a=[];if(r===Re.PAGE_VIEW){const i=n;a=a.concat(qr(i),Qr(i))}else r===Re.ADD_TO_CART&&(a=a.concat(Jr(n)));return a.length?Kr(a,t):Promise.resolve()}const lt="sendShopifyAnalytics request is unsuccessful";function Kr(e,t){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(lt,`
|
|
265
274
|
|
|
266
|
-
`,i.message)})}).catch(n=>{console.error(
|
|
275
|
+
`,i.message)})}).catch(n=>{console.error(lt,n)})}catch{return Promise.resolve()}}function zr(){if(xr("getClientBrowserParameters"))return{uniqueToken:"",visitToken:"",url:"",path:"",search:"",referrer:"",title:"",userAgent:"",navigationType:"",navigationApi:""};const[e,t]=rn(),r=Ee(document.cookie);return{uniqueToken:r[Z],visitToken:r[W],url:location.href,path:location.pathname,search:location.search,referrer:document.referrer,title:document.title,userAgent:navigator.userAgent,navigationType:e,navigationApi:t}}function en(){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 tn(){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 rn(){try{let e="PerformanceNavigationTiming",t=en();return t||(t=tn(),e="performance.navigation"),t?[t,e]:["unknown","unknown"]}catch{}return["error","error"]}function nn(e){const{cartCreate:t,checkoutUrl:r}=re(),[n,a]=u.useState(!1),{quantity:i,variantId:s,onClick:o,attributes:c,children:f,...l}=e;u.useEffect(()=>{n&&r&&(window.location.href=r)},[n,r]);const y=u.useCallback(()=>{a(!0),t({lines:[{quantity:i??1,merchandiseId:s,attributes:c}]})},[t,i,s,c]);return React.createElement(Se,{disabled:n??l.disabled,...l,onClick:o,defaultOnClick:y},f)}function an(e){const[t,r]=u.useState(!1),{status:n,checkoutUrl:a}=re(),{children:i,...s}=e;return u.useEffect(()=>{t&&a&&n==="idle"&&(window.location.href=a)},[t,n,a]),React.createElement(Se,{...s,disabled:t||s.disabled,onClick:()=>r(!0)},i)}function dt(e){const{countryIsoCode:t,languageIsoCode:r}=se(),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),i=u.useMemo(()=>({style:"currency",currency:e.currencyCode}),[e.currencyCode]),s=ae(n,i),o=ae(n,{...i,currencyDisplay:"name"}),c=ae(n,{...i,currencyDisplay:"narrowSymbol"}),f=ae(n,{...i,minimumFractionDigits:0,maximumFractionDigits:0}),l=ae(n),y=ae(n,{minimumFractionDigits:0,maximumFractionDigits:0}),h=d=>d.type==="currency",S=u.useMemo(()=>({original:()=>e,currencyCode:()=>e.currencyCode,localizedString:()=>s().format(a),parts:()=>s().formatToParts(a),withoutTrailingZeros:()=>a%1===0?f().format(a):s().format(a),withoutTrailingZerosAndCurrency:()=>a%1===0?y().format(a):l().format(a),currencyName:()=>{var d;return((d=o().formatToParts(a).find(h))==null?void 0:d.value)??e.currencyCode},currencySymbol:()=>{var d;return((d=s().formatToParts(a).find(h))==null?void 0:d.value)??e.currencyCode},currencyNarrowSymbol:()=>{var d;return((d=c().formatToParts(a).find(h))==null?void 0:d.value)??""},amount:()=>s().formatToParts(a).filter(d=>["decimal","fraction","group","integer","literal"].includes(d.type)).map(d=>d.value).join("")}),[e,a,o,s,c,l,f,y]);return u.useMemo(()=>new Proxy(S,{get:(d,C)=>{var _;return(_=Reflect.get(d,C))==null?void 0:_.call(null)}}),[S])}function ae(e,t){return u.useMemo(()=>{let r;return()=>r??(r=new Intl.NumberFormat(e,t))},[e,t])}function Ce({data:e,as:t,withoutCurrency:r,withoutTrailingZeros:n,measurement:a,measurementSeparator:i="/",...s}){if(!on(e))throw new Error("<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'");const o=dt(e),c=t??"div";let f=o.localizedString;return(r||n)&&(r&&!n?f=o.amount:!r&&n?f=o.withoutTrailingZeros:f=o.withoutTrailingZerosAndCurrency),React.createElement(c,{...s},f,a&&a.referenceUnit&&React.createElement(React.Fragment,null,i,a.referenceUnit))}function on(e){return typeof e.amount=="string"&&!!e.amount&&typeof e.currencyCode=="string"&&!!e.currencyCode}function sn(e){const{cost:t}=re(),{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(Ce,{...a,data:i},n)}const ft=u.createContext(null);function De(){const e=u.useContext(ft);if(e==null)throw new Error("Expected a cart line context but none was found");return e}function cn({children:e,line:t}){return React.createElement(ft.Provider,{value:t},e)}function un(e){const t=De(),{as:r,...n}=e,a=r||"span";return React.createElement(a,{...n},t.quantity)}function ln(e){const{status:t,linesRemove:r,linesUpdate:n}=re(),a=De(),{children:i,adjust:s,onClick:o,...c}=e,f=u.useCallback(()=>{if(s==="remove"){r([(a==null?void 0:a.id)??""]);return}const y=s==="decrease"?((a==null?void 0:a.quantity)??0)-1:((a==null?void 0:a.quantity)??0)+1;if(y<=0){r([(a==null?void 0:a.id)??""]);return}const h={id:(a==null?void 0:a.id)??"",quantity:y,attributes:(a==null?void 0:a.attributes)??[]};n([h])},[s,a==null?void 0:a.attributes,a==null?void 0:a.id,a==null?void 0:a.quantity,r,n]),l=c.disabled;return React.createElement(Se,{...c,onClick:o,defaultOnClick:f,disabled:typeof l<"u"?l:t!=="idle"},i)}const dn={DateTime:"string",Decimal:"string",HTML:"string",URL:"string",Color:"string",UnsignedInt64:"string"};function yt(e){const{data:t,options:r,id:n=t.id,frameBorder:a="0",allow:i="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:s=!0,loading:o="lazy",...c}=e;if(!t.embedUrl)throw new Error("<ExternalVideo/> requires the 'embedUrl' property");let f=t.embedUrl;if(r){const l=new URL(t.embedUrl);for(const y of Object.keys(r))l.searchParams.set(y,r[y]);f=l.toString()}return React.createElement("iframe",{...c,id:n??t.embedUrl,title:t.alt??t.id??"external video",frameBorder:a,allow:i,allowFullScreen:s,src:f,loading:o})}const fn=`#graphql
|
|
267
276
|
fragment Image on Image {
|
|
268
277
|
altText
|
|
269
278
|
url
|
|
270
279
|
width
|
|
271
280
|
height
|
|
272
281
|
}
|
|
273
|
-
`,yt=O.forwardRef(({alt:e,aspectRatio:t,crop:r="center",data:n,decoding:o="async",height:i="auto",loader:s=le,loaderOptions:a,loading:c="lazy",sizes:d,src:l,srcSetOptions:h={intervals:15,startingWidth:200,incrementSize:200,placeholderWidth:100},width:g="100%",widths:p,...f},b)=>{const T=O.useMemo(()=>{const I=n!=null&&n.width&&(n!=null&&n.height)?n==null?void 0:n.width:void 0,_=n!=null&&n.width&&(n!=null&&n.height)?n==null?void 0:n.height:void 0;return{width:I,height:_,unitsMatch:!!ht(I,_)}},[n]),w=O.useMemo(()=>{const _=de((g||"100%").toString()),v=`${_.number}${_.unit}`,B=i==null,P=B?null:de(i.toString()),F=P?`${P.number}${P.unit}`:"",W=B?"auto":F,oe=l||(n==null?void 0:n.url),X=n!=null&&n.altText&&!e?n==null?void 0:n.altText:e||"",k=t||(T.unitsMatch?[fe(T.width),fe(T.height)].join("/"):void 0);return{width:v,height:W,src:oe,alt:X,aspectRatio:k}},[g,i,l,n,e,t,T,f==null?void 0:f.key]),{intervals:A,startingWidth:U,incrementSize:m,placeholderWidth:y}=h,C=O.useMemo(()=>hn(g,A,U,m),[g,A,U,m]);return mt(w.width)?O.createElement(fn,{aspectRatio:t,crop:r,decoding:o,height:i,imageWidths:C,loader:s,loading:c,normalizedProps:w,passthroughProps:f,ref:b,width:g}):O.createElement(yn,{aspectRatio:t,crop:r,decoding:o,imageWidths:C,loader:s,loading:c,normalizedProps:w,passthroughProps:f,placeholderWidth:y,ref:b,sizes:d})}),fn=O.forwardRef(({aspectRatio:e,crop:t,decoding:r,height:n,imageWidths:o,loader:i=le,loading:s,normalizedProps:a,passthroughProps:c,width:d},l)=>{const h=O.useMemo(()=>{const g=fe(d),p=fe(n),f=e||(ht(a.width,a.height)?[g,p].join("/"):a.aspectRatio?a.aspectRatio:void 0),b=o===void 0?void 0:pt(o,f,t),T=p||(f&&g?g*(De(f)??1):void 0),w=gt(a.src,b,i),A=i({src:a.src,width:g,height:T,crop:a.height==="auto"?void 0:t});return{width:g,aspectRatio:f,height:T,srcSet:w,src:A}},[e,t,n,o,i,a,d]);return O.createElement("img",{ref:l,alt:a.alt,decoding:r,height:h.height,loading:s,src:h.src,srcSet:h.srcSet,width:h.width,style:{aspectRatio:h.aspectRatio,...c.style},...c})}),yn=O.forwardRef(({crop:e,decoding:t,imageWidths:r,loader:n=le,loading:o,normalizedProps:i,passthroughProps:s,placeholderWidth:a,sizes:c},d)=>{const l=O.useMemo(()=>{const h=r===void 0?void 0:pt(r,i.aspectRatio,e),g=i.aspectRatio&&a?a*(De(i.aspectRatio)??1):void 0,p=gt(i.src,h,n),f=n({src:i.src,width:a,height:g,crop:e});return{placeholderHeight:g,srcSet:p,src:f}},[e,r,n,i,a]);return O.createElement("img",{ref:d,alt:i.alt,decoding:t,height:l.placeholderHeight,loading:o,sizes:c,src:l.src,srcSet:l.srcSet,width:a,...s,style:{width:i.width,aspectRatio:i.aspectRatio,...s.style}})});function le({src:e,width:t,height:r,crop:n}){if(!e)return"";const o=new URL(e);return t&&o.searchParams.append("width",Math.round(t).toString()),r&&o.searchParams.append("height",Math.round(r).toString()),n&&o.searchParams.append("crop",n),o.href}function ht(e="100%",t="auto"){return de(e.toString()).unit===de(t.toString()).unit}function de(e){const t=e.replace(/[0-9.]/g,""),r=parseFloat(e.replace(t,""));return{unit:t===""?r===void 0?"auto":"px":t,number:r}}function fe(e){if(e===void 0)return;const{unit:t,number:r}=de(e.toString());switch(t){case"em":return r*16;case"rem":return r*16;case"px":return r;case"":return r;default:return}}function mt(e){return typeof e=="number"||typeof e=="string"&&/\d(px|em|rem)$/.test(e)}function gt(e,t,r=le){return e?(t==null?void 0:t.length)===0||!t?e:t.map((n,o)=>`${r({src:e,width:n.width,height:n.height,crop:n.crop})} ${t.length===3?`${o+1}x`:`${n.width??0}w`}`).join(", "):""}function hn(e="100%",t,r,n){const o=Array.from({length:t},(s,a)=>a*n+r),i=Array.from({length:3},(s,a)=>(a+1)*(fe(e)??0));return mt(e)?i:o}function De(e){if(!e)return;const[t,r]=e.split("/");return 1/(Number(t)/Number(r))}function pt(e,t,r="center"){return e?e.map(o=>({width:o,height:t?o*(De(t)??1):void 0,crop:r})):void 0}const Et={};function mn(e,t){const r=Et[e];if(r)return r;const n=new Promise((o,i)=>{const s=document.createElement("script");t!=null&&t.module?s.type="module":s.type="text/javascript",s.src=e,s.onload=()=>{o(!0)},s.onerror=()=>{i(!1)},(t==null?void 0:t.in)==="head"?document.head.appendChild(s):document.body.appendChild(s)});return Et[e]=n,n}function ke(e,t){const[r,n]=u.useState("loading"),o=JSON.stringify(t);return u.useEffect(()=>{async function i(){try{n("loading"),await mn(e,t),n("done")}catch{n("error")}}i().catch(()=>{n("error")})},[e,o,t]),r}function Ct(e){var d;const{data:t,previewImageOptions:r,id:n=t.id,playsInline:o=!0,controls:i=!0,sourceProps:s={},...a}=e,c=le({src:((d=t.previewImage)==null?void 0:d.url)??"",...r});if(!t.sources)throw new Error("<Video/> requires a 'data.sources' array");return React.createElement("video",{...a,id:n,playsInline:o,controls:i,poster:c},t.sources.map(l=>{if(!(l!=null&&l.url&&(l!=null&&l.mimeType)))throw new Error("<Video/> needs 'source.url' and 'source.mimeType'");return React.createElement("source",{...s,key:l.url,src:l.url,type:l.mimeType})}))}function St(e){var d,l,h;const[t,r]=u.useState(void 0),n=u.useCallback(g=>{r(g)},[]),{data:o,children:i,className:s,...a}=e,c=ke("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",{module:!0});return u.useEffect(()=>{if(t)return a.onError&&t.addEventListener("error",a.onError),a.onLoad&&t.addEventListener("load",a.onLoad),a.onPreload&&t.addEventListener("preload",a.onPreload),a.onModelVisibility&&t.addEventListener("model-visibility",a.onModelVisibility),a.onProgress&&t.addEventListener("progress",a.onProgress),a.onArStatus&&t.addEventListener("ar-status",a.onArStatus),a.onArTracking&&t.addEventListener("ar-tracking",a.onArTracking),a.onQuickLookButtonTapped&&t.addEventListener("quick-look-button-tapped",a.onQuickLookButtonTapped),a.onCameraChange&&t.addEventListener("camera-change",a.onCameraChange),a.onEnvironmentChange&&t.addEventListener("environment-change",a.onEnvironmentChange),a.onPlay&&t.addEventListener("play",a.onPlay),a.onPause&&t.addEventListener("ar-status",a.onPause),a.onSceneGraphReady&&t.addEventListener("scene-graph-ready",a.onSceneGraphReady),()=>{t!=null&&(a.onError&&t.removeEventListener("error",a.onError),a.onLoad&&t.removeEventListener("load",a.onLoad),a.onPreload&&t.removeEventListener("preload",a.onPreload),a.onModelVisibility&&t.removeEventListener("model-visibility",a.onModelVisibility),a.onProgress&&t.removeEventListener("progress",a.onProgress),a.onArStatus&&t.removeEventListener("ar-status",a.onArStatus),a.onArTracking&&t.removeEventListener("ar-tracking",a.onArTracking),a.onQuickLookButtonTapped&&t.removeEventListener("quick-look-button-tapped",a.onQuickLookButtonTapped),a.onCameraChange&&t.removeEventListener("camera-change",a.onCameraChange),a.onEnvironmentChange&&t.removeEventListener("environment-change",a.onEnvironmentChange),a.onPlay&&t.removeEventListener("play",a.onPlay),a.onPause&&t.removeEventListener("ar-status",a.onPause),a.onSceneGraphReady&&t.removeEventListener("scene-graph-ready",a.onSceneGraphReady))}},[t,a.onArStatus,a.onArTracking,a.onCameraChange,a.onEnvironmentChange,a.onError,a.onLoad,a.onModelVisibility,a.onPause,a.onPlay,a.onPreload,a.onProgress,a.onQuickLookButtonTapped,a.onSceneGraphReady]),c!=="done"?null:(l=(d=o.sources)==null?void 0:d[0])!=null&&l.url?React.createElement("model-viewer",{ref:n,...a,class:s,id:a.id??o.id,src:o.sources[0].url,alt:o.alt??null,"camera-controls":a.cameraControls??!0,poster:(a.poster||((h=o.previewImage)==null?void 0:h.url))??null,autoplay:a.autoplay??!0,loading:a.loading,reveal:a.reveal,ar:a.ar,"ar-modes":a.arModes,"ar-scale":a.arScale,"ar-placement":a.arPlacement,"ios-src":a.iosSrc,"touch-action":a.touchAction,"disable-zoom":a.disableZoom,"orbit-sensitivity":a.orbitSensitivity,"auto-rotate":a.autoRotate,"auto-rotate-delay":a.autoRotateDelay,"rotation-per-second":a.rotationPerSecond,"interaction-policy":a.interactionPolicy,"interaction-prompt":a.interactionPrompt,"interaction-prompt-style":a.interactionPromptStyle,"interaction-prompt-threshold":a.interactionPromptThreshold,"camera-orbit":a.cameraOrbit,"camera-target":a.cameraTarget,"field-of-view":a.fieldOfView,"max-camera-orbit":a.maxCameraOrbit,"min-camera-orbit":a.minCameraOrbit,"max-field-of-view":a.maxFieldOfView,"min-field-of-view":a.minFieldOfView,bounds:a.bounds,"interpolation-decay":a.interpolationDecay??100,"skybox-image":a.skyboxImage,"environment-image":a.environmentImage,exposure:a.exposure,"shadow-intensity":a.shadowIntensity??0,"shadow-softness":a.shadowSoftness??0,"animation-name":a.animationName,"animation-crossfade-duration":a.animationCrossfadeDuration,"variant-name":a.variantName,orientation:a.orientation,scale:a.scale},i):(console.error("<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'"),null)}function gn({data:e,mediaOptions:t,...r}){switch(e.__typename){case"MediaImage":return e.image?React.createElement(yt,{...r,...t==null?void 0:t.image,data:e.image}):(console.warn("<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default."),null);case"Video":return React.createElement(Ct,{...r,...t==null?void 0:t.video,data:e});case"ExternalVideo":return React.createElement(ft,{...r,...t==null?void 0:t.externalVideo,data:e});case"Model3d":return React.createElement(St,{...r,...t==null?void 0:t.modelViewer,data:e});default:return console.error("<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to render the matching sub-component for this type of media. Rendering 'null' by default"),null}}function pn(e){if(!e.type)return console.error("parseMetafield(): The 'type' field is required in order to parse the Metafield. Returning 'parsedValue' of 'null'"),{...e,parsedValue:null};switch(e.type){case"boolean":return{...e,parsedValue:e.value==="true"};case"collection_reference":case"file_reference":case"page_reference":case"product_reference":case"variant_reference":return{...e,parsedValue:e.reference};case"color":case"multi_line_text_field":case"single_line_text_field":case"url":return{...e,parsedValue:e.value};case"dimension":case"money":case"json":case"rating":case"volume":case"weight":case"list.color":case"list.dimension":case"list.number_integer":case"list.number_decimal":case"list.rating":case"list.single_line_text_field":case"list.url":case"list.volume":case"list.weight":{let t=null;try{t=Tt(e.value??"")}catch{console.error("parseMetafield(): attempted to JSON.parse the 'metafield.value' property, but failed. Returning 'null' for 'parsedValue'"),t=null}return{...e,parsedValue:t}}case"date":case"date_time":return{...e,parsedValue:new Date(e.value??"")};case"list.date":case"list.date_time":{const t=Tt((e==null?void 0:e.value)??"");return{...e,parsedValue:t.map(r=>new Date(r))}}case"number_decimal":case"number_integer":return{...e,parsedValue:Number(e.value)};case"list.collection_reference":case"list.file_reference":case"list.page_reference":case"list.product_reference":case"list.variant_reference":return{...e,parsedValue:j(e.references??void 0)};default:{const t=`parseMetafield(): the 'metafield.type' you passed in is not supported. Your type: "${e.type}". If you believe this is an error, please open an issue on GitHub.`;return console.error(`${t} Returning 'parsedValue' of 'null'`),{...e,parsedValue:null}}}}function Tt(e){return String(e).includes("__proto__")?JSON.parse(e,(t,r)=>{if(t!=="__proto__")return r}):JSON.parse(e)}function En(e){var d,l,h,g,p,f;const{priceType:t="regular",variantId:r,valueType:n="min",data:o,...i}=e;if(o==null)throw new Error("<ProductPrice/> requires a product as the 'data' prop");let s,a;const c=r?j((o==null?void 0:o.variants)??{}).find(b=>(b==null?void 0:b.id)===r)??null:null;if(t==="compareAt")if(r&&c){if(((d=c.compareAtPriceV2)==null?void 0:d.amount)===((l=c.priceV2)==null?void 0:l.amount))return null;s=c.compareAtPriceV2}else n==="max"?s=(h=o==null?void 0:o.compareAtPriceRange)==null?void 0:h.maxVariantPrice:s=(g=o==null?void 0:o.compareAtPriceRange)==null?void 0:g.minVariantPrice;else r&&c?(s=c.priceV2,n==="unit"&&(s=c.unitPrice,a=c.unitPriceMeasurement)):n==="max"?s=(p=o.priceRange)==null?void 0:p.maxVariantPrice:s=(f=o.priceRange)==null?void 0:f.minVariantPrice;return s?a?React.createElement(Se,{...i,data:s,measurement:a}):React.createElement(Se,{...i,data:s}):null}const Cn="https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";function Sn({variantIds:e,className:t,variantIdsAndQuantities:r,width:n,storeDomain:o}){const i=ie(),s=o||(i==null?void 0:i.storeDomain),a=ke(Cn);let c=[];if(!s||s===Ze.storeDomain)throw new Error(Tn);if(e&&r)throw new Error(An);if(!e&&!r)throw new Error(_t);if(e)c=e.reduce((l,h)=>{const g=$(h).id;return g&&l.push(g),l},[]);else if(r)c=r.reduce((l,h)=>{const g=$(h==null?void 0:h.id).id;return g&&l.push(`${g}:${(h==null?void 0:h.quantity)??1}`),l},[]);else throw new Error(_t);if(c.length===0)throw new Error(_n);const d=n?{"--shop-pay-button-width":n}:void 0;return React.createElement("div",{className:t,style:d},a==="done"&&React.createElement("shop-pay-button",{"store-url":s,variants:c.join(",")}))}const Tn='You must pass a "storeDomain" prop to the "ShopPayButton" component, or wrap it in a "ShopifyProvider" component.',_n='You must pass in "variantIds" in the form of ["gid://shopify/ProductVariant/1"]',_t='You must pass in either "variantIds" or "variantIdsAndQuantities" to ShopPayButton',An="You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component",vn=60*60*24*360*1,bn=60*30;function wn(e){const{hasUserConsent:t=!1,domain:r=""}=e||{};u.useEffect(()=>{const n=pe(document.cookie);t?(Te(G,n[G]||ge(),vn,r),Te(Z,n[Z]||ge(),bn,r)):(Te(G,"",0,r),Te(Z,"",0,r))})}function Te(e,t,r,n){document.cookie=Tr(e,t,{maxage:r,domain:n,samesite:"Lax",path:"/"})}E.AddToCartButton=Vr,E.AnalyticsEventName=Pe,E.AnalyticsPageType=Ce,E.BuyNowButton=rn,E.CartCheckoutButton=nn,E.CartCost=an,E.CartLineProvider=sn,E.CartLineQuantity=cn,E.CartLineQuantityAdjustButton=un,E.CartProvider=Rr,E.ExternalVideo=ft,E.IMAGE_FRAGMENT=dn,E.Image=yt,E.MediaFile=gn,E.ModelViewer=St,E.Money=Se,E.ProductPrice=En,E.ProductProvider=Or,E.SHOPIFY_S=Z,E.SHOPIFY_STOREFRONT_ID_HEADER=Qe,E.SHOPIFY_STOREFRONT_S_HEADER=Xe,E.SHOPIFY_STOREFRONT_Y_HEADER=Je,E.SHOPIFY_Y=G,E.ShopPayButton=Sn,E.ShopifyProvider=Er,E.ShopifySalesChannel=it,E.Video=Ct,E.createStorefrontClient=mr,E.flattenConnection=j,E.getClientBrowserParameters=Kr,E.getShopifyCookies=pe,E.parseGid=$,E.parseMetafield=pn,E.sendShopifyAnalytics=Jr,E.storefrontApiCustomScalars=ln,E.useCart=te,E.useCartLine=Re,E.useLoadScript=ke,E.useMoney=lt,E.useProduct=rt,E.useShop=ie,E.useShopifyCookies=wn,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
|
|
282
|
+
`,gt=N.forwardRef(({alt:e,aspectRatio:t,crop:r="center",data:n,decoding:a="async",height:i="auto",loader:s=de,loaderOptions:o,loading:c="lazy",sizes:f,src:l,srcSetOptions:y={intervals:15,startingWidth:200,incrementSize:200,placeholderWidth:100},width:h="100%",widths:S,...d},C)=>{const _=N.useMemo(()=>{const P=n!=null&&n.width&&(n!=null&&n.height)?n==null?void 0:n.width:void 0,b=n!=null&&n.width&&(n!=null&&n.height)?n==null?void 0:n.height:void 0;return{width:P,height:b,unitsMatch:!!ht(P,b)}},[n]),R=N.useMemo(()=>{const b=fe((h||"100%").toString()),A=`${b.number}${b.unit}`,w=i==null,$=w?null:fe(i.toString()),k=$?`${$.number}${$.unit}`:"",q=w?"auto":k,Q=l||(n==null?void 0:n.url),K=n!=null&&n.altText&&!e?n==null?void 0:n.altText:e||"",U=t||(_.unitsMatch?[ye(_.width),ye(_.height)].join("/"):void 0);return{width:A,height:q,src:Q,alt:K,aspectRatio:U}},[h,i,l,n,e,t,_,d==null?void 0:d.key]),{intervals:I,startingWidth:v,incrementSize:D,placeholderWidth:g}=y,m=N.useMemo(()=>hn(h,I,v,D),[h,I,v,D]);return mt(R.width)?N.createElement(yn,{aspectRatio:t,crop:r,decoding:a,height:i,imageWidths:m,loader:s,loading:c,normalizedProps:R,passthroughProps:d,ref:C,width:h}):N.createElement(gn,{aspectRatio:t,crop:r,decoding:a,imageWidths:m,loader:s,loading:c,normalizedProps:R,passthroughProps:d,placeholderWidth:g,ref:C,sizes:f})}),yn=N.forwardRef(({aspectRatio:e,crop:t,decoding:r,height:n,imageWidths:a,loader:i=de,loading:s,normalizedProps:o,passthroughProps:c,width:f},l)=>{const y=N.useMemo(()=>{const h=ye(f),S=ye(n),d=e||(ht(o.width,o.height)?[h,S].join("/"):o.aspectRatio?o.aspectRatio:void 0),C=a===void 0?void 0:Et(a,d,t),_=S||(d&&h?h*(ke(d)??1):void 0),R=pt(o.src,C,i),I=i({src:o.src,width:h,height:_,crop:o.height==="auto"?void 0:t});return{width:h,aspectRatio:d,height:_,srcSet:R,src:I}},[e,t,n,a,i,o,f]);return N.createElement("img",{ref:l,alt:o.alt,decoding:r,height:y.height,loading:s,src:y.src,srcSet:y.srcSet,width:y.width,style:{aspectRatio:y.aspectRatio,...c.style},...c})}),gn=N.forwardRef(({crop:e,decoding:t,imageWidths:r,loader:n=de,loading:a,normalizedProps:i,passthroughProps:s,placeholderWidth:o,sizes:c},f)=>{const l=N.useMemo(()=>{const y=r===void 0?void 0:Et(r,i.aspectRatio,e),h=i.aspectRatio&&o?o*(ke(i.aspectRatio)??1):void 0,S=pt(i.src,y,n),d=n({src:i.src,width:o,height:h,crop:e});return{placeholderHeight:h,srcSet:S,src:d}},[e,r,n,i,o]);return N.createElement("img",{ref:f,alt:i.alt,decoding:t,height:l.placeholderHeight,loading:a,sizes:c,src:l.src,srcSet:l.srcSet,width:o,...s,style:{width:i.width,aspectRatio:i.aspectRatio,...s.style}})});function de({src:e,width:t,height:r,crop:n}){if(!e)return"";const a=new URL(e);return t&&a.searchParams.append("width",Math.round(t).toString()),r&&a.searchParams.append("height",Math.round(r).toString()),n&&a.searchParams.append("crop",n),a.href}function ht(e="100%",t="auto"){return fe(e.toString()).unit===fe(t.toString()).unit}function fe(e){const t=e.replace(/[0-9.]/g,""),r=parseFloat(e.replace(t,""));return{unit:t===""?r===void 0?"auto":"px":t,number:r}}function ye(e){if(e===void 0)return;const{unit:t,number:r}=fe(e.toString());switch(t){case"em":return r*16;case"rem":return r*16;case"px":return r;case"":return r;default:return}}function mt(e){return typeof e=="number"||typeof e=="string"&&/\d(px|em|rem)$/.test(e)}function pt(e,t,r=de){return e?(t==null?void 0:t.length)===0||!t?e:t.map((n,a)=>`${r({src:e,width:n.width,height:n.height,crop:n.crop})} ${t.length===3?`${a+1}x`:`${n.width??0}w`}`).join(", "):""}function hn(e="100%",t,r,n){const a=Array.from({length:t},(s,o)=>o*n+r),i=Array.from({length:3},(s,o)=>(o+1)*(ye(e)??0));return mt(e)?i:a}function ke(e){if(!e)return;const[t,r]=e.split("/");return 1/(Number(t)/Number(r))}function Et(e,t,r="center"){return e?e.map(a=>({width:a,height:t?a*(ke(t)??1):void 0,crop:r})):void 0}const St={};function mn(e,t){const r=St[e];if(r)return r;const n=new Promise((a,i)=>{const s=document.createElement("script");t!=null&&t.module?s.type="module":s.type="text/javascript",s.src=e,s.onload=()=>{a(!0)},s.onerror=()=>{i(!1)},(t==null?void 0:t.in)==="head"?document.head.appendChild(s):document.body.appendChild(s);const o=t==null?void 0:t.attributes;o&&Object.keys(o).forEach(c=>{s.setAttribute(c,o[c])})});return St[e]=n,n}function Ue(e,t){const[r,n]=u.useState("loading"),a=JSON.stringify(t);return u.useEffect(()=>{async function i(){try{n("loading"),await mn(e,t),n("done")}catch{n("error")}}i().catch(()=>{n("error")})},[e,a,t]),r}function Tt(e){var f;const{data:t,previewImageOptions:r,id:n=t.id,playsInline:a=!0,controls:i=!0,sourceProps:s={},...o}=e,c=de({src:((f=t.previewImage)==null?void 0:f.url)??"",...r});if(!t.sources)throw new Error("<Video/> requires a 'data.sources' array");return React.createElement("video",{...o,id:n,playsInline:a,controls:i,poster:c},t.sources.map(l=>{if(!(l!=null&&l.url&&(l!=null&&l.mimeType)))throw new Error("<Video/> needs 'source.url' and 'source.mimeType'");return React.createElement("source",{...s,key:l.url,src:l.url,type:l.mimeType})}))}function Ct(e){var f,l,y;const[t,r]=u.useState(void 0),n=u.useCallback(h=>{r(h)},[]),{data:a,children:i,className:s,...o}=e,c=Ue("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",{module:!0});return u.useEffect(()=>{if(t)return o.onError&&t.addEventListener("error",o.onError),o.onLoad&&t.addEventListener("load",o.onLoad),o.onPreload&&t.addEventListener("preload",o.onPreload),o.onModelVisibility&&t.addEventListener("model-visibility",o.onModelVisibility),o.onProgress&&t.addEventListener("progress",o.onProgress),o.onArStatus&&t.addEventListener("ar-status",o.onArStatus),o.onArTracking&&t.addEventListener("ar-tracking",o.onArTracking),o.onQuickLookButtonTapped&&t.addEventListener("quick-look-button-tapped",o.onQuickLookButtonTapped),o.onCameraChange&&t.addEventListener("camera-change",o.onCameraChange),o.onEnvironmentChange&&t.addEventListener("environment-change",o.onEnvironmentChange),o.onPlay&&t.addEventListener("play",o.onPlay),o.onPause&&t.addEventListener("ar-status",o.onPause),o.onSceneGraphReady&&t.addEventListener("scene-graph-ready",o.onSceneGraphReady),()=>{t!=null&&(o.onError&&t.removeEventListener("error",o.onError),o.onLoad&&t.removeEventListener("load",o.onLoad),o.onPreload&&t.removeEventListener("preload",o.onPreload),o.onModelVisibility&&t.removeEventListener("model-visibility",o.onModelVisibility),o.onProgress&&t.removeEventListener("progress",o.onProgress),o.onArStatus&&t.removeEventListener("ar-status",o.onArStatus),o.onArTracking&&t.removeEventListener("ar-tracking",o.onArTracking),o.onQuickLookButtonTapped&&t.removeEventListener("quick-look-button-tapped",o.onQuickLookButtonTapped),o.onCameraChange&&t.removeEventListener("camera-change",o.onCameraChange),o.onEnvironmentChange&&t.removeEventListener("environment-change",o.onEnvironmentChange),o.onPlay&&t.removeEventListener("play",o.onPlay),o.onPause&&t.removeEventListener("ar-status",o.onPause),o.onSceneGraphReady&&t.removeEventListener("scene-graph-ready",o.onSceneGraphReady))}},[t,o.onArStatus,o.onArTracking,o.onCameraChange,o.onEnvironmentChange,o.onError,o.onLoad,o.onModelVisibility,o.onPause,o.onPlay,o.onPreload,o.onProgress,o.onQuickLookButtonTapped,o.onSceneGraphReady]),c!=="done"?null:(l=(f=a.sources)==null?void 0:f[0])!=null&&l.url?React.createElement("model-viewer",{ref:n,...o,class:s,id:o.id??a.id,src:a.sources[0].url,alt:a.alt??null,"camera-controls":o.cameraControls??!0,poster:(o.poster||((y=a.previewImage)==null?void 0:y.url))??null,autoplay:o.autoplay??!0,loading:o.loading,reveal:o.reveal,ar:o.ar,"ar-modes":o.arModes,"ar-scale":o.arScale,"ar-placement":o.arPlacement,"ios-src":o.iosSrc,"touch-action":o.touchAction,"disable-zoom":o.disableZoom,"orbit-sensitivity":o.orbitSensitivity,"auto-rotate":o.autoRotate,"auto-rotate-delay":o.autoRotateDelay,"rotation-per-second":o.rotationPerSecond,"interaction-policy":o.interactionPolicy,"interaction-prompt":o.interactionPrompt,"interaction-prompt-style":o.interactionPromptStyle,"interaction-prompt-threshold":o.interactionPromptThreshold,"camera-orbit":o.cameraOrbit,"camera-target":o.cameraTarget,"field-of-view":o.fieldOfView,"max-camera-orbit":o.maxCameraOrbit,"min-camera-orbit":o.minCameraOrbit,"max-field-of-view":o.maxFieldOfView,"min-field-of-view":o.minFieldOfView,bounds:o.bounds,"interpolation-decay":o.interpolationDecay??100,"skybox-image":o.skyboxImage,"environment-image":o.environmentImage,exposure:o.exposure,"shadow-intensity":o.shadowIntensity??0,"shadow-softness":o.shadowSoftness??0,"animation-name":o.animationName,"animation-crossfade-duration":o.animationCrossfadeDuration,"variant-name":o.variantName,orientation:o.orientation,scale:o.scale},i):(console.error("<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'"),null)}function pn({data:e,mediaOptions:t,...r}){switch(e.__typename){case"MediaImage":return e.image?React.createElement(gt,{...r,...t==null?void 0:t.image,data:e.image}):(console.warn("<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default."),null);case"Video":return React.createElement(Tt,{...r,...t==null?void 0:t.video,data:e});case"ExternalVideo":return React.createElement(yt,{...r,...t==null?void 0:t.externalVideo,data:e});case"Model3d":return React.createElement(Ct,{...r,...t==null?void 0:t.modelViewer,data:e});default:return console.error("<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to render the matching sub-component for this type of media. Rendering 'null' by default"),null}}function En(e){if(!e.type)return console.error("parseMetafield(): The 'type' field is required in order to parse the Metafield. Returning 'parsedValue' of 'null'"),{...e,parsedValue:null};switch(e.type){case"boolean":return{...e,parsedValue:e.value==="true"};case"collection_reference":case"file_reference":case"page_reference":case"product_reference":case"variant_reference":return{...e,parsedValue:e.reference};case"color":case"multi_line_text_field":case"single_line_text_field":case"url":return{...e,parsedValue:e.value};case"dimension":case"money":case"json":case"rating":case"volume":case"weight":case"list.color":case"list.dimension":case"list.number_integer":case"list.number_decimal":case"list.rating":case"list.single_line_text_field":case"list.url":case"list.volume":case"list.weight":{let t=null;try{t=_t(e.value??"")}catch{console.error("parseMetafield(): attempted to JSON.parse the 'metafield.value' property, but failed. Returning 'null' for 'parsedValue'"),t=null}return{...e,parsedValue:t}}case"date":case"date_time":return{...e,parsedValue:new Date(e.value??"")};case"list.date":case"list.date_time":{const t=_t((e==null?void 0:e.value)??"");return{...e,parsedValue:t.map(r=>new Date(r))}}case"number_decimal":case"number_integer":return{...e,parsedValue:Number(e.value)};case"list.collection_reference":case"list.file_reference":case"list.page_reference":case"list.product_reference":case"list.variant_reference":return{...e,parsedValue:G(e.references??void 0)};default:{const t=`parseMetafield(): the 'metafield.type' you passed in is not supported. Your type: "${e.type}". If you believe this is an error, please open an issue on GitHub.`;return console.error(`${t} Returning 'parsedValue' of 'null'`),{...e,parsedValue:null}}}}function _t(e){return String(e).includes("__proto__")?JSON.parse(e,(t,r)=>{if(t!=="__proto__")return r}):JSON.parse(e)}function Sn(e){var f,l,y,h,S,d;const{priceType:t="regular",variantId:r,valueType:n="min",data:a,...i}=e;if(a==null)throw new Error("<ProductPrice/> requires a product as the 'data' prop");let s,o;const c=r?G((a==null?void 0:a.variants)??{}).find(C=>(C==null?void 0:C.id)===r)??null:null;if(t==="compareAt")if(r&&c){if(((f=c.compareAtPriceV2)==null?void 0:f.amount)===((l=c.priceV2)==null?void 0:l.amount))return null;s=c.compareAtPriceV2}else n==="max"?s=(y=a==null?void 0:a.compareAtPriceRange)==null?void 0:y.maxVariantPrice:s=(h=a==null?void 0:a.compareAtPriceRange)==null?void 0:h.minVariantPrice;else r&&c?(s=c.priceV2,n==="unit"&&(s=c.unitPrice,o=c.unitPriceMeasurement)):n==="max"?s=(S=a.priceRange)==null?void 0:S.maxVariantPrice:s=(d=a.priceRange)==null?void 0:d.minVariantPrice;return s?o?React.createElement(Ce,{...i,data:s,measurement:o}):React.createElement(Ce,{...i,data:s}):null}const Tn="https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";function Cn({variantIds:e,className:t,variantIdsAndQuantities:r,width:n,storeDomain:a}){const i=se(),s=a||(i==null?void 0:i.storeDomain),o=Ue(Tn);let c=[];if(!s||s===We.storeDomain)throw new Error(_n);if(e&&r)throw new Error(vn);if(!e&&!r)throw new Error(At);if(e)c=e.reduce((l,y)=>{const h=Y(y).id;return h&&l.push(h),l},[]);else if(r)c=r.reduce((l,y)=>{const h=Y(y==null?void 0:y.id).id;return h&&l.push(`${h}:${(y==null?void 0:y.quantity)??1}`),l},[]);else throw new Error(At);if(c.length===0)throw new Error(An);const f=n?{"--shop-pay-button-width":n}:void 0;return React.createElement("div",{className:t,style:f},o==="done"&&React.createElement("shop-pay-button",{"store-url":s,variants:c.join(",")}))}const _n='You must pass a "storeDomain" prop to the "ShopPayButton" component, or wrap it in a "ShopifyProvider" component.',An='You must pass in "variantIds" in the form of ["gid://shopify/ProductVariant/1"]',At='You must pass in either "variantIds" or "variantIdsAndQuantities" to ShopPayButton',vn="You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component",bn=60*60*24*360*1,wn=60*30;function In(e){const{hasUserConsent:t=!1,domain:r=""}=e||{};u.useEffect(()=>{const n=Ee(document.cookie);t?(_e(Z,n[Z]||pe(),bn,r),_e(W,n[W]||pe(),wn,r)):(_e(Z,"",0,r),_e(W,"",0,r))})}function _e(e,t,r,n){document.cookie=_r(e,t,{maxage:r,domain:n,samesite:"Lax",path:"/"})}p.AddToCartButton=Lr,p.AnalyticsEventName=Re,p.AnalyticsPageType=Te,p.BuyNowButton=nn,p.CartCheckoutButton=an,p.CartCost=sn,p.CartLineProvider=cn,p.CartLineQuantity=un,p.CartLineQuantityAdjustButton=ln,p.CartProvider=Dr,p.ExternalVideo=yt,p.IMAGE_FRAGMENT=fn,p.Image=gt,p.MediaFile=pn,p.ModelViewer=Ct,p.Money=Ce,p.ProductPrice=Sn,p.ProductProvider=Nr,p.SHOPIFY_S=W,p.SHOPIFY_STOREFRONT_ID_HEADER=Je,p.SHOPIFY_STOREFRONT_S_HEADER=Ke,p.SHOPIFY_STOREFRONT_Y_HEADER=Xe,p.SHOPIFY_Y=Z,p.ShopPayButton=Cn,p.ShopifyProvider=Sr,p.ShopifySalesChannel=st,p.Video=Tt,p.createStorefrontClient=mr,p.flattenConnection=G,p.getClientBrowserParameters=zr,p.getShopifyCookies=Ee,p.parseGid=Y,p.parseMetafield=En,p.sendShopifyAnalytics=Xr,p.storefrontApiCustomScalars=dn,p.useCart=re,p.useCartLine=De,p.useLoadScript=Ue,p.useMoney=dt,p.useProduct=nt,p.useShop=se,p.useShopifyCookies=In,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
|
274
283
|
//# sourceMappingURL=hydrogen-react.prod.js.map
|