@elevateab/sdk 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -99
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/next.cjs +1 -1
- package/dist/next.cjs.map +1 -1
- package/dist/next.js +1 -1
- package/dist/next.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,6 @@ npm install @elevateab/sdk
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
**Peer Dependencies:**
|
|
12
|
-
|
|
13
12
|
- `react` >= 18.0.0 or >= 19.0.0
|
|
14
13
|
- `@shopify/hydrogen` >= 2023.10.0 (Hydrogen only)
|
|
15
14
|
- `next` >= 13.0.0 (Next.js only)
|
|
@@ -23,23 +22,17 @@ Hydrogen uses automatic analytics tracking via Shopify's `useAnalytics()` hook.
|
|
|
23
22
|
```tsx
|
|
24
23
|
// app/root.tsx
|
|
25
24
|
import { ElevateProvider, ElevateAnalytics } from "@elevateab/sdk";
|
|
26
|
-
import { Analytics
|
|
25
|
+
import { Analytics } from "@shopify/hydrogen";
|
|
27
26
|
|
|
28
27
|
export default function Root() {
|
|
29
28
|
const data = useLoaderData<typeof loader>();
|
|
30
|
-
const nonce = useNonce(); // Only needed if your store uses strict CSP
|
|
31
29
|
|
|
32
30
|
return (
|
|
33
|
-
<Analytics.Provider
|
|
34
|
-
cart={data.cart}
|
|
35
|
-
shop={data.shop}
|
|
36
|
-
consent={data.consent}
|
|
37
|
-
>
|
|
31
|
+
<Analytics.Provider cart={data.cart} shop={data.shop} consent={data.consent}>
|
|
38
32
|
<ElevateProvider
|
|
39
33
|
storeId="mystore.myshopify.com"
|
|
40
34
|
storefrontAccessToken={env.PUBLIC_STOREFRONT_API_TOKEN}
|
|
41
35
|
preventFlickering={true}
|
|
42
|
-
nonce={nonce}
|
|
43
36
|
>
|
|
44
37
|
<ElevateAnalytics />
|
|
45
38
|
<Outlet />
|
|
@@ -49,52 +42,10 @@ export default function Root() {
|
|
|
49
42
|
}
|
|
50
43
|
```
|
|
51
44
|
|
|
52
|
-
That's it
|
|
45
|
+
That's it. Analytics events are tracked automatically when users view pages, products, add to cart, etc.
|
|
53
46
|
|
|
54
47
|
The `preventFlickering={true}` prop prevents content flash while tests load.
|
|
55
48
|
|
|
56
|
-
### Content Security Policy Configuration
|
|
57
|
-
|
|
58
|
-
This step is optional. Only add CSP directives if your store enforces a strict CSP
|
|
59
|
-
and you see console errors about blocked scripts.
|
|
60
|
-
|
|
61
|
-
**For Hydrogen stores:** Add Elevate CDN domains to your CSP in `app/entry.server.tsx`:
|
|
62
|
-
|
|
63
|
-
```tsx
|
|
64
|
-
// app/entry.server.tsx
|
|
65
|
-
export default async function handleRequest(
|
|
66
|
-
request: Request,
|
|
67
|
-
responseStatusCode: number,
|
|
68
|
-
responseHeaders: Headers,
|
|
69
|
-
reactRouterContext: EntryContext,
|
|
70
|
-
context: HydrogenRouterContextProvider,
|
|
71
|
-
) {
|
|
72
|
-
const {nonce, header, NonceProvider} = createContentSecurityPolicy({...});
|
|
73
|
-
|
|
74
|
-
// Add Elevate domains to CSP
|
|
75
|
-
let elevateCSP = header
|
|
76
|
-
.replace(
|
|
77
|
-
/script-src-elem\s+([^;]+)/,
|
|
78
|
-
`script-src-elem $1 https://d19dz5bxptjmv5.cloudfront.net`
|
|
79
|
-
)
|
|
80
|
-
.replace(
|
|
81
|
-
/connect-src\s+([^;]+)/,
|
|
82
|
-
`connect-src $1 https://d19dz5bxptjmv5.cloudfront.net https://d339co84ntxcme.cloudfront.net https://configs.elevateab.com`
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
responseHeaders.set('Content-Security-Policy', elevateCSP);
|
|
86
|
-
// ... rest of your code
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
**For other frameworks (Next.js, Gatsby, etc.):**
|
|
91
|
-
|
|
92
|
-
Add the following CSP header:
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
Content-Security-Policy: script-src 'self' https://d19dz5bxptjmv5.cloudfront.net; script-src-elem 'self' https://d19dz5bxptjmv5.cloudfront.net; connect-src 'self' https://d19dz5bxptjmv5.cloudfront.net https://d339co84ntxcme.cloudfront.net https://configs.elevateab.com
|
|
96
|
-
```
|
|
97
|
-
|
|
98
49
|
---
|
|
99
50
|
|
|
100
51
|
## Next.js Setup
|
|
@@ -125,7 +76,6 @@ export default function RootLayout({ children }) {
|
|
|
125
76
|
```
|
|
126
77
|
|
|
127
78
|
The `ElevateNextProvider` automatically:
|
|
128
|
-
|
|
129
79
|
- Tracks page views on route changes
|
|
130
80
|
- Initializes analytics globally
|
|
131
81
|
- Prevents content flicker (when `preventFlickering={true}`)
|
|
@@ -159,12 +109,12 @@ import { trackAddToCart } from "@elevateab/sdk";
|
|
|
159
109
|
async function handleAddToCart() {
|
|
160
110
|
// Shopify GIDs are automatically converted to numeric IDs
|
|
161
111
|
await trackAddToCart({
|
|
162
|
-
productId: product.id,
|
|
163
|
-
variantId: variant.id,
|
|
112
|
+
productId: product.id, // "gid://shopify/Product/123" works
|
|
113
|
+
variantId: variant.id, // "gid://shopify/ProductVariant/456" works
|
|
164
114
|
productPrice: 99.99,
|
|
165
115
|
productQuantity: 1,
|
|
166
116
|
currency: "USD",
|
|
167
|
-
cartId: cart.id,
|
|
117
|
+
cartId: cart.id, // For cart attribute tagging
|
|
168
118
|
});
|
|
169
119
|
}
|
|
170
120
|
```
|
|
@@ -200,21 +150,6 @@ await trackCartView({
|
|
|
200
150
|
|
|
201
151
|
// Search
|
|
202
152
|
await trackSearchSubmitted({ searchQuery: "blue shirt" });
|
|
203
|
-
|
|
204
|
-
// Checkout started
|
|
205
|
-
await trackCheckoutStarted({
|
|
206
|
-
cartTotalPrice: 199.99,
|
|
207
|
-
currency: "USD",
|
|
208
|
-
cartItems: [...],
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
// Checkout completed (order placed)
|
|
212
|
-
await trackCheckoutCompleted({
|
|
213
|
-
orderId: "order_123",
|
|
214
|
-
cartTotalPrice: 199.99,
|
|
215
|
-
currency: "USD",
|
|
216
|
-
cartItems: [...],
|
|
217
|
-
});
|
|
218
153
|
```
|
|
219
154
|
|
|
220
155
|
---
|
|
@@ -234,7 +169,7 @@ function PricingSection() {
|
|
|
234
169
|
if (variant?.isControl) {
|
|
235
170
|
return <Price amount={99.99} />;
|
|
236
171
|
}
|
|
237
|
-
|
|
172
|
+
|
|
238
173
|
return <Price amount={79.99} />;
|
|
239
174
|
}
|
|
240
175
|
```
|
|
@@ -244,13 +179,13 @@ function PricingSection() {
|
|
|
244
179
|
```tsx
|
|
245
180
|
const { variant } = useExperiment("test-id");
|
|
246
181
|
|
|
247
|
-
variant?.isControl
|
|
248
|
-
variant?.isA
|
|
249
|
-
variant?.isB
|
|
250
|
-
variant?.isC
|
|
251
|
-
variant?.isD
|
|
252
|
-
variant?.id
|
|
253
|
-
variant?.name
|
|
182
|
+
variant?.isControl // true if control group
|
|
183
|
+
variant?.isA // true if variant A
|
|
184
|
+
variant?.isB // true if variant B
|
|
185
|
+
variant?.isC // true if variant C
|
|
186
|
+
variant?.isD // true if variant D
|
|
187
|
+
variant?.id // variant ID
|
|
188
|
+
variant?.name // variant name
|
|
254
189
|
```
|
|
255
190
|
|
|
256
191
|
### Multiple Variants
|
|
@@ -278,7 +213,6 @@ https://yourstore.com/?eabUserPreview=true&abtid=<test-id>&eab_tests=<short-id>_
|
|
|
278
213
|
```
|
|
279
214
|
|
|
280
215
|
Example:
|
|
281
|
-
|
|
282
216
|
```
|
|
283
217
|
https://yourstore.com/products/shirt?eabUserPreview=true&abtid=abc123&eab_tests=c123_12345
|
|
284
218
|
```
|
|
@@ -299,16 +233,13 @@ if (isPreviewMode()) {
|
|
|
299
233
|
|
|
300
234
|
Orders are attributed to A/B tests via cart attributes. This happens automatically when you provide `storefrontAccessToken` and `cartId`.
|
|
301
235
|
|
|
302
|
-
For Hydrogen, pass `storefrontAccessToken`
|
|
236
|
+
For Hydrogen, pass `storefrontAccessToken` to the provider:
|
|
303
237
|
|
|
304
238
|
```tsx
|
|
305
|
-
const nonce = useNonce();
|
|
306
|
-
|
|
307
239
|
<ElevateProvider
|
|
308
240
|
storeId="mystore.myshopify.com"
|
|
309
241
|
storefrontAccessToken={env.PUBLIC_STOREFRONT_API_TOKEN}
|
|
310
|
-
|
|
311
|
-
/>;
|
|
242
|
+
/>
|
|
312
243
|
```
|
|
313
244
|
|
|
314
245
|
For Next.js, pass `cartId` to `trackAddToCart`:
|
|
@@ -334,7 +265,7 @@ The Storefront Access Token is safe to use client-side - it's a public token des
|
|
|
334
265
|
import { extractShopifyId, isShopifyGid } from "@elevateab/sdk";
|
|
335
266
|
|
|
336
267
|
extractShopifyId("gid://shopify/Product/123456"); // "123456"
|
|
337
|
-
isShopifyGid("gid://shopify/Product/123");
|
|
268
|
+
isShopifyGid("gid://shopify/Product/123"); // true
|
|
338
269
|
```
|
|
339
270
|
|
|
340
271
|
Note: Tracking functions automatically extract IDs, so you rarely need these directly.
|
|
@@ -347,25 +278,25 @@ Note: Tracking functions automatically extract IDs, so you rarely need these dir
|
|
|
347
278
|
|
|
348
279
|
```tsx
|
|
349
280
|
interface ElevateProviderProps {
|
|
350
|
-
storeId: string;
|
|
351
|
-
storefrontAccessToken?: string;
|
|
352
|
-
preventFlickering?: boolean;
|
|
353
|
-
|
|
281
|
+
storeId: string; // Required: your-store.myshopify.com
|
|
282
|
+
storefrontAccessToken?: string; // For cart attribute tagging
|
|
283
|
+
preventFlickering?: boolean; // Enable anti-flicker (default: false)
|
|
284
|
+
flickerTimeout?: number; // Max wait time in ms (default: 3000)
|
|
354
285
|
children: React.ReactNode;
|
|
355
286
|
}
|
|
356
287
|
```
|
|
357
288
|
|
|
358
289
|
### Analytics Events Summary
|
|
359
290
|
|
|
360
|
-
| Event
|
|
361
|
-
|
|
362
|
-
| Page view
|
|
363
|
-
| Product view
|
|
364
|
-
| Add to cart
|
|
365
|
-
| Remove from cart
|
|
366
|
-
| Cart view
|
|
367
|
-
| Search
|
|
368
|
-
| Checkout started
|
|
291
|
+
| Event | Hydrogen | Next.js |
|
|
292
|
+
|-------|----------|---------|
|
|
293
|
+
| Page view | Automatic | Automatic |
|
|
294
|
+
| Product view | Automatic | `ProductViewTracker` |
|
|
295
|
+
| Add to cart | Automatic | `trackAddToCart()` |
|
|
296
|
+
| Remove from cart | Automatic | `trackRemoveFromCart()` |
|
|
297
|
+
| Cart view | Automatic | `trackCartView()` |
|
|
298
|
+
| Search | Automatic | `trackSearchSubmitted()` |
|
|
299
|
+
| Checkout started | Automatic | `trackCheckoutStarted()` |
|
|
369
300
|
| Checkout completed | Automatic | `trackCheckoutCompleted()` |
|
|
370
301
|
|
|
371
302
|
---
|
package/dist/index.cjs
CHANGED
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
if(window.__eab_reveal)window.__eab_reveal();
|
|
43
43
|
};
|
|
44
44
|
document.head.appendChild(script);
|
|
45
|
-
})();`}function Hr(e){if(!e?.trim())return"";try{let r=`https://${e.trim().replace(/^https?:\/\//,"")}`,o=new URL(r.replace(/\/+$/,""));return o.hostname.startsWith("www.")&&(o.hostname=o.hostname.substring(4)),o.toString().replace(/\/+$/,"")}catch{return e.trim().replace(/\/+$/,"")}}function $t(e,t){let r=Hr(e.split("?")[0]);for(let o of t){let n=Hr(o.split("?")[0]);if(r===n)return!0;try{let c=new URL(e).pathname,a=new URL(o,e).pathname;if(c===a)return!0}catch{}}return!1}function Sn(e){return e.data?.redirectBehavior||"redirectAll"}function zr(e){return!!(N("eabRedirectedTests")||{})[e]}function qr(e){let t=N("eabRedirectedTests")||{};t[e]=!0,H("eabRedirectedTests",JSON.stringify(t))}function In(e,t){for(let r of e.tests)if(!(r.type!=="SPLIT_URL"||!r.enabled))for(let o of r.variations){let n=o.splitUrlTestLinks||[];if(n.length!==0&&$t(t,n))return{test:r,matchedVariation:o,isControlUrl:!!o.isControl}}return null}function Un(e){if(typeof window>"u")return;let t=new URL(e,window.location.origin);t.searchParams.set("abtr","true");let r=t.toString(),o=window.__remixRouter?.navigate??window.next?.router?.push??window.$nuxt?.$router?.push??window.__navigate;if(o&&typeof o=="function")try{let n=t.pathname+t.search;o(n);return}catch{}window.location.href=r}function Fe(e,t){if(typeof window>"u")return!1;let r=window.location.href;if(new URLSearchParams(window.location.search).get("abtr")==="true")return!1;let n=In(e,r);if(!n)return!1;let{test:c,matchedVariation:a,isControlUrl:f}=n,d=c.testId,g=Sn(c),i=J(d);if(!i)return!1;let l=c.variations.find(p=>p.id===i);if(!l)return!1;let s=l.splitUrlTestLinks||[];if(s.length===0||$t(r,s))return!1;switch(g){case"redirectOnlyControlUrl":if(!f||l.isControl)return!1;break;case"redirectOnce":if(zr(d))return!1;qr(d);break;case"redirectOnceControlUrlOnly":if(!f||zr(d)||l.isControl)return!1;qr(d);break;default:break}let u=s[0];return Un(u),!0}var Wt={type:"SPLIT_URL",shouldActivate(e,t){for(let r of e.variations){let o=r.splitUrlTestLinks||[];if($t(t.currentUrl,o))return!0}return!1},getVariantData(){return{handlerActivated:!0}}};var Gt=nt(jr(),1),Fr={"facebook.com":"Facebook","fb.me":"Facebook","m.facebook.com":"Facebook","l.facebook.com":"Facebook","lm.facebook.com":"Facebook","instagram.com":"Instagram","l.instagram.com":"Instagram","youtube.com":"Youtube","youtu.be":"Youtube","m.youtube.com":"Youtube","bing.com":"Bing","www.bing.com":"Bing","msnbc.msn.com":"Bing","dizionario.it.msn.com":"Bing","cc.bingj.com":"Bing","m.bing.com":"Bing","twitter.com":"Twitter","t.co":"Twitter"};function P(e){return typeof e!="string"?String(e):e.replace(/[\\"'`\x00-\x1F\x7F]/g,"")}function v(e){if(e==null)return null;let t=typeof e=="string"?parseFloat(e):Number(e);return isNaN(t)?null:+(Math.round(+(t+"e2"))+"e-2")}function te(e){if(!e)return null;let t=/gid:\/\/shopify\/Product\/(\d+)/,r=e.match(t);return r?r[1]:null}function we(e){if(!e)return null;let t=/gid:\/\/shopify\/ProductVariant\/(\d+)/,r=e.match(t);return r?r[1]:null}function Ue(e){if(!e)return null;let t=/gid:\/\/shopify\/Cart\/([^?]+(\?.+)?)/,r=e.match(t);return r?r[1]:null}function Re(e){try{return typeof e!="string"?null:decodeURIComponent(e).split("?")[0]}catch{return e||null}}function Rn(e){return/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i.test(e)}function On(e){return/(instagram)[\/ ]([-\w\.]+)/i.test(e)}function $r(e){return Rn(e)||On(e)}function Vn(e){if(!e)return"";switch(e){case"Mobile Safari":return"Safari";case"Chrome Mobile":case"Chrome Mobile iOS":return"Chrome";case"Firefox Mobile":case"Firefox Mobile iOS":return"Firefox";case"Opera Mobile":case"Opera Mini":case"Opera Mini iOS":return"Opera";case"Yandex Browser Lite":return"Yandex Browser";case"Chrome Webview":case"Mobile App":return"Mobile App";default:return e}}function Ln(e){let t={};return e.searchParams.forEach((r,o)=>{t[o]||(t[o]=r)}),t}function Bn(e){return!!e.host&&["http:","https:"].includes(e.protocol)}function Dn(e){return e.replace(/^www\./,"")}function Nn(e,t,r){if(t&&{Facebook:"Facebook",Instagram:"Instagram"}[t])return t;let n,c;try{if(e&&e.trim()!=="")n=new URL(e);else return"Direct";if(n?.hostname&&Bn(n)){if(c=n.hostname,r&&r===c)return"Direct"}else return""}catch{}if(!c)return"";let a=Dn(c);return a?Fr[a]?Fr[a]:a?.includes("google")?"Google":a:""}function Oe(e){let{referrer:t,entryPage:r,userAgent:o}=e,n={referrer_source:"",browser_info:"",os_info:"",device_type:"",page_entry_path:"",utm_medium:"",utm_source:"",utm_campaign:"",utm_content:"",utm_term:"",referrer_url:t||"",gclid:"",fbclid:"",pins_campaign_id:"",epik:""};try{let c;if(r&&r.trim()!==""&&r.startsWith("http"))try{let a=new URL(r),f=a?.pathname;c=a?.hostname,f&&(n.page_entry_path=f??"");let d=Ln(a);n.utm_medium=d.utm_medium??"",n.utm_source=d.utm_source??"",n.utm_campaign=d.utm_campaign??"",n.utm_content=d.utm_content??"",n.utm_term=d.utm_term??"",n.gclid=d.gclid??"",n.fbclid=d.fbclid??"",n.pins_campaign_id=d.pins_campaign_id??"",n.epik=d.epik??""}catch{}if(o){let a=(0,Gt.UAParser)(o),f=a?.browser?.name,d=Vn(f);n.browser_info=d??"",n.os_info=a?.os?.name??"",o&&(n.device_type=(a?.device?.type||"desktop")?.toUpperCase()??"")}return n.referrer_source=Nn(t,n?.browser_info,c)??"",n}catch{return n}}function Ve(e,t){let r=e==="/"||e==="",n=t&&/^\/[a-z]{2}(-[a-z]{2})?\/?$/i.test(e);return r||n?"index":/\/products\//.test(e)?"product":/\/collections\//.test(e)?"collection":/\/pages\//.test(e)?"page":/\/search/.test(e)?"search":/\/cart/.test(e)?"cart":/\/checkouts\//.test(e)?"checkout":"unknown"}function Wr(e){try{return e&&new URLSearchParams(e).get("eabUserId")||!1}catch{return!1}}function Le(e){if(!e)return"";try{let t=(0,Gt.UAParser)(e),r=t?.os,o=t?.device,n="";return r?.name&&(n+=r.name,r.version&&(n+=` ${r.version}`)),o?.type&&(n+=n?` (${o.type})`:o.type),o?.vendor&&(n+=n?` ${o.vendor}`:o.vendor),o?.model&&(n+=n?` ${o.model}`:o.model),n||e}catch{return e}}function q(e){return e?e.includes("gid://")&&e.split("/").pop()||e:""}function Gr(e){return!e||!e.includes("gid://")?null:e.split("/")[3]||null}function Jr(e){return!!e&&e.startsWith("gid://shopify/")}function Yr(){if(typeof window>"u")return;let e=window.Shopify;if(e?.currency?.active)return e.currency.active}fe();var Qr="elv-el-",Xr={ELEMENT_NODE:1,TEXT_NODE:3},ft=new Map,mt=new Map,gt=new Map,wt=new Map,Be=!1;function re(e,t){if(t==="*")return!0;if(t.startsWith("*")&&t.endsWith("*")){let r=t.slice(1,-1);return e.includes(r)}if(t.startsWith("*")){let r=t.slice(1);return e.endsWith(r)}return t===e}function Qt(){return typeof window>"u"?!1:window.innerWidth<768}function Mn(e){let t="";for(let r=0;r<e.length;r++){let o=e[r];o>="A"&&o<="Z"?(r!==0&&(t+="-"),t+=o.toLowerCase()):t+=o}return t}function Hn(e){return e.nodeType===Xr.TEXT_NODE}function Jt(e){return e.nodeType===Xr.ELEMENT_NODE}function Yt(e,t){ft.has(e)||ft.set(e,t.cloneNode(!0))}function Kr(e){let t=e;t=t.replace(/`/g,"`").replace(/$/g,"$");try{t=JSON.parse('"'+t+'"')}catch{}return t}function Xt(e){if(typeof window>"u"||e.length===0)return;let t=window.location.pathname,r=e.filter(n=>n.pathnames?.length?n.pathnames.some(c=>re(t,c)):!0);Be=Qt();let o=r.map(n=>({...n,style:n.style?{...n.style.lg,...Be&&n.style.sm}:void 0,content:n.content&&Be&&n.content.sm?n.content.sm:n.content?.lg}));o.filter(n=>n.content!==void 0).forEach(n=>{(n.applyAll?Array.from(document.querySelectorAll(n.selector)):[document.querySelector(n.selector)].filter(Boolean)).forEach((a,f)=>{if(!a)return;let d=n.applyAll?`${n.selector}-${f}-${a.id||Math.random().toString(36).substr(2,9)}`:n.selector;Yt(d,a),Hn(a)?a.nodeValue=n.content:Jt(a)&&(a.innerHTML=n.content)})}),o.filter(n=>n.style!==void 0).forEach(n=>{let c=document.querySelector(n.selector);!c||!Jt(c)||(Yt(n.selector,c),Object.entries(n.style).forEach(([a,f])=>{let d=Mn(a),g=f.toString().includes("!important"),i=f.toString().replace(/\s*!important\s*$/,"");c.style.setProperty(d,i,g?"important":void 0)}))}),o.filter(n=>n.attributes!==void 0).forEach(n=>{let c=document.querySelector(n.selector);!c||!Jt(c)||(Yt(n.selector,c),Object.entries(n.attributes).forEach(([a,f])=>{c.setAttribute(a,f)}))})}function Kt(e){if(typeof window>"u"||e.length===0)return;let t=window.location.pathname;e.filter(o=>o.selector?.pathnames?.length?o.selector.pathnames.some(n=>re(t,n)):!0).forEach(o=>{let n=`${Qr}${o.id}`;if(wt.has(n))return;let c=document.querySelector(o.selector.target);if(!c||c.parentElement?.querySelector(`#${n}`))return;let a=Zr(o);o.selector.placement==="after"?c.after(a):o.selector.placement==="before"&&c.before(a),wt.set(n,a)})}function Zr(e){let t=document.createElement(e.tagName);return t.id=`${Qr}${e.id}`,e.style&&Object.assign(t.style,e.style),e.attributes&&Object.entries(e.attributes).forEach(([r,o])=>{t.setAttribute(r,o)}),e.kind==="text"&&e.content&&(t.innerText=e.content),e.kind==="container"&&e.childrens&&e.childrens.forEach(r=>{let o=Zr(r);t.appendChild(o)}),t}function We(e,t){if(typeof window>"u"||e.length===0)return;let r=window.location.pathname;e.filter(n=>n.pathnames?.length?n.excludePathnames?.length&&n.excludePathnames.some(a=>re(r,a))?!1:n.pathnames.some(c=>re(r,c)):!0).forEach(n=>{n.id&&(n.css&&zn(n.id,n.css),n.js&&qn(n.id,n.js,t))})}function zn(e,t){let r=`css-${e}`;if(mt.has(r)||document.getElementById(r))return;let o=document.createElement("style");o.id=r,o.textContent=Kr(t),document.head.appendChild(o),mt.set(r,o)}function qn(e,t,r){let o=`js-${e}`;if(gt.has(o)||document.getElementById(o))return;let n=document.createElement("script");n.id=o,r&&n.setAttribute("nonce",r);let c=Kr(t);n.textContent="(function(){try{"+c+"}catch(e){console.error('[ElevateAB] Custom script error:', e)}})();",document.head.appendChild(n),gt.set(o,n)}function Zt(){ft.forEach((e,t)=>{let r=document.querySelector(t);r&&r.replaceWith(e.cloneNode(!0))})}function er(){mt.forEach(e=>e.remove()),mt.clear(),gt.forEach(e=>e.remove()),gt.clear(),wt.forEach(e=>e.remove()),wt.clear(),ft.clear()}function jn(e,t){let r=[],o=[],n=[];return e.tests.filter(a=>a.type==="CONTENT"&&a.enabled).forEach(a=>{let f=J(a.testId);if(!f)return;let d=a.variations.find(g=>g.id===f);d?.content&&(d.content.changes?.length&&r.push(...d.content.changes),d.content.elements?.length&&o.push(...d.content.elements),d.content.customCodes?.length&&n.push(...d.content.customCodes))}),{changes:r,elements:o,blocks:[],customCodes:n}}function Ge(e){return e.tests.some(t=>t.type==="CONTENT"&&t.enabled)}function Je(e,t,r){if(typeof window>"u"||!Ge(e))return;let o=jn(e,t);(o.changes.length>0||o.elements.length>0||o.customCodes.length>0)&&(Xt(o.changes),Kt(o.elements),We(o.customCodes,r))}function bt(e,t,r){if(typeof window>"u")return;let o=Qt();o!==Be&&(Zt(),Be=o),Je(e,t,r)}function ht(e,t,r){if(typeof window>"u")return()=>{};let o=()=>{Qt()!==Be&&bt(e,t,r)},n=()=>{bt(e,t,r)};return window.addEventListener("resize",o),window.addEventListener("popstate",n),()=>{window.removeEventListener("resize",o),window.removeEventListener("popstate",n),er()}}vt();tr();Y();var Pe=require("react"),Fn="https://bitter-river-9c62.support-67d.workers.dev",$n="https://d339co84ntxcme.cloudfront.net/Prod/orders",D=null;function _t(e){D=e}function be(e){let t=e?.storeId||D?.storeId;return t||(console.warn("[ElevateAB] No storeId provided. Call initAnalytics() first or pass storeId to tracking function."),"")}function Wn(e){return Object.entries(e).filter(([,t])=>typeof t=="string").map(([t,r])=>({test_id:t,variant_id:r}))}function Gn(e,t){return Object.entries(e).filter(([r])=>typeof t[r]=="string").map(([r])=>({test_id:r,variant_id:t[r]}))}function Jn(){return typeof window>"u"?!1:V("eabUserPreview")==="true"||new URLSearchParams(window.location.search).get("eabUserPreview")==="true"}function he(e,t,r){if(typeof window>"u"||Jn())return null;let o=navigator.userAgent,n=window.location.pathname,c=Ve(n,r),{referrer:a,entryPage:f}=Ie(),d=Oe({referrer:a,entryPage:f,userAgent:o}),g=N("ABTL")||{},i=N("ABAU")||{},l=Wn(g),s=Gn(i,g),u=Ue(localStorage.getItem("shopifyCartId")),p=new Date().toISOString(),_=sessionStorage.getItem("eabIsFirstVisit")==="true",x=V("localization")||"";return{pixel_event_id:`sh-${le()}`,shop_name:e,timestamp:p,event_type:t,client_id:V("_shopify_y")||void 0,visitor_id:ce(),session_id:Te(),cart_token:Re(u||V("cart")),page_url:window.location.href,page_pathname:n,page_search:window.location.search,referrer_url:a,referrer_source:d?.referrer_source,previous_page:document.referrer,page_entry:f,page_entry_path:d?.page_entry_path,page_type:c,utm_medium:d?.utm_medium,utm_source:d?.utm_source,utm_campaign:d?.utm_campaign,utm_content:d?.utm_content,utm_term:d?.utm_term,gclid:d?.gclid,fbclid:d?.fbclid,pins_campaign_id:d?.pins_campaign_id,epik:d?.epik,browser_info:d?.browser_info,os_info:d?.os_info,device_type:d?.device_type,language:navigator.language,root_route:localStorage.getItem("eabRootRoute")||"",user_agent:o,user_agent_no_browser:Le(o),is_first_visit:_,shopify_country:x,ab_test_assignments:l,ab_test_views:s,is_first_order:null}}async function ye(e,t=Fn){try{let r=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:!0});if(!r.ok)throw new Error(`Worker error: ${r.status}`)}catch(r){console.error("[ElevateAB] Error sending analytics:",r)}}async function nr(e={}){let t=be(e);if(!t)return;let r=e.hasLocalizedPaths??D?.hasLocalizedPaths,o=e.workerUrl??D?.workerUrl,n=he(t,"page_viewed",r);if(!n)return;let c={...n,cart_currency:e.currency};await ye(c,o)}async function rn(e){let t=be(e);if(!t)return;let{productId:r,productVendor:o,productPrice:n,productSku:c,currency:a}=e,f=e.hasLocalizedPaths??D?.hasLocalizedPaths,d=e.workerUrl??D?.workerUrl,g=he(t,"product_viewed",f);if(!g)return;let i={...g,cart_currency:a,product_id:q(r),product_vendor:P(o),product_price:v(n),product_sku:P(c)};await ye(i,d)}async function nn(e){let t=be(e);if(!t)return;let{productId:r,variantId:o,productVendor:n,productPrice:c,productQuantity:a,productSku:f,currency:d,cartId:g}=e,i=e.hasLocalizedPaths??D?.hasLocalizedPaths,l=e.workerUrl??D?.workerUrl,s=e.storefrontAccessToken??D?.storefrontAccessToken,u=he(t,"product_added_to_cart",i);if(!u)return;let p={...u,cart_currency:d,product_id:q(r),variant_id:q(o),product_vendor:P(n),product_price:v(c),product_quantity:a,product_sku:P(f)};if(await ye(p,l),g&&s)try{let{updateCartAttributes:_}=await Promise.resolve().then(()=>(vt(),tn));await _(g,{storefrontAccessToken:s})}catch(_){console.error("[ElevateAB] Failed to update cart attributes:",_)}}async function on(e){let t=be(e);if(!t)return;let{productId:r,variantId:o,productVendor:n,productPrice:c,productQuantity:a,productSku:f,currency:d}=e,g=e.hasLocalizedPaths??D?.hasLocalizedPaths,i=e.workerUrl??D?.workerUrl,l=he(t,"product_removed_from_cart",g);if(!l)return;let s={...l,cart_currency:d,product_id:q(r),variant_id:q(o),product_vendor:P(n),product_price:v(c),product_quantity:a,product_sku:P(f)};await ye(s,i)}async function sn(e){let t=be(e);if(!t)return;let{cartTotalPrice:r,cartTotalQuantity:o,cartItems:n,currency:c}=e,a=e.hasLocalizedPaths??D?.hasLocalizedPaths,f=e.workerUrl??D?.workerUrl,d=he(t,"cart_viewed",a);if(!d)return;let g={...d,cart_currency:c,cart_total_price:v(r),cart_total_quantity:o,cart_items:n?.map(i=>({product_id:q(i.productId),variant_id:q(i.variantId),product_vendor:P(i.productVendor)||"",product_price:v(i.productPrice),product_quantity:i.productQuantity??null,product_sku:P(i.productSku)||""}))};await ye(g,f)}async function an(e){let t=be(e);if(!t)return;let{searchQuery:r,currency:o}=e,n=e.hasLocalizedPaths??D?.hasLocalizedPaths,c=e.workerUrl??D?.workerUrl,a=he(t,"search_submitted",n);if(!a)return;let f={...a,cart_currency:o,search_query:P(r)};await ye(f,c)}async function cn(e){let t=be(e);if(!t)return;let{cartTotalPrice:r,cartSubtotalPrice:o,cartShippingPrice:n,cartTaxAmount:c,cartDiscountAmount:a,customerId:f,cartItems:d,currency:g}=e,i=e.hasLocalizedPaths??D?.hasLocalizedPaths,l=e.workerUrl??D?.workerUrl,s=he(t,"checkout_started",i);if(!s)return;let u=0,p=d?.map(x=>{let w=x.productQuantity??0;return u+=w,{product_id:q(x.productId),variant_id:q(x.variantId),product_vendor:P(x.productVendor)||"",vendor:P(x.productVendor)||"",product_price:v(x.productPrice),total_price:v(x.productPrice),product_quantity:w,quantity:w,product_sku:P(x.productSku)||"",sku:P(x.productSku)||"",total_discount:v(x.totalDiscount)}})||[],_={...s,cart_currency:g,cart_total_price:v(r),cart_subtotal_price:v(o),cart_total_quantity:u,cart_shipping_price:v(n),cart_tax_amount:v(c),cart_discount_amount:v(a),cart_items:p,customer_id:f};await ye(_,l)}async function un(e){let t=be(e);if(!t)return;let{orderId:r,cartTotalPrice:o,cartSubtotalPrice:n,cartShippingPrice:c,cartTaxAmount:a,cartDiscountAmount:f,customerId:d,isFirstOrder:g,noteAttributes:i,cartItems:l,currency:s}=e,u=e.hasLocalizedPaths??D?.hasLocalizedPaths,p=e.ordersWorkerUrl??D?.ordersWorkerUrl??$n,_=he(t,"checkout_completed",u);if(!_)return;let x=0,w=l?.map(k=>{let L=k.productQuantity??0;return x+=L,{product_id:q(k.productId),variant_id:q(k.variantId),product_vendor:P(k.productVendor)||"",vendor:P(k.productVendor)||"",product_price:v(k.productPrice),total_price:v(k.productPrice),product_quantity:L,quantity:L,product_sku:P(k.productSku)||"",sku:P(k.productSku)||"",total_discount:v(k.totalDiscount)}})||[],b={..._,cart_currency:s,cart_total_price:v(o),cart_subtotal_price:v(n),cart_total_quantity:x,cart_shipping_price:v(c),cart_tax_amount:v(a),cart_discount_amount:v(f),cart_items:w,order_id:r,customer_id:d,is_first_order:g??null,note_attributes:i};await ye(b,p)}function dn(e){let{storeId:t,hasLocalizedPaths:r,currency:o,workerUrl:n,enabled:c=!0,pathname:a}=e,f=(0,Pe.useRef)(null),[d,g]=(0,Pe.useState)(()=>a||(typeof window<"u"?window.location.pathname:""));(0,Pe.useEffect)(()=>{a&&g(a)},[a]),(0,Pe.useEffect)(()=>{typeof window>"u"||!c||f.current!==d&&(f.current=d,nr({storeId:t,hasLocalizedPaths:r,currency:o,workerUrl:n}))},[d,t,r,o,n,c])}var _e=nt(require("react"),1);var or=nt(require("react"),1),Xe=or.default.createContext(null);function Ct(){let e=or.default.useContext(Xe);if(e===null)throw new Error("useElevateConfig must be used within ElevateProvider");return e}fe();je();var kt=new Map;function ve(e){kt.set(e.type,e)}function Ke(e){return kt.get(e)}function ir(){return Array.from(kt.values())}function sr(e){return kt.has(e)}function Yn(e){try{let o=new URL(e,"https://example.com").pathname.match(/\/products\/([^\/\?]+)/);return o?o[1]:null}catch{return null}}function Qn(e,t,r,o){if(typeof window>"u"||!e.prices||!t)return;let n=e.prices[t];if(!n)return;let c=n.price?.[r],a=n.compare?.[r],f=o;if(f?.selectorsV2?.length)for(let d of f.selectorsV2){if(d.price&&c){let g=d.price.replace("{{variant}}",t);document.querySelectorAll(g).forEach(l=>{let s=new Intl.NumberFormat("en-US",{style:"currency",currency:r}).format(parseFloat(c));l.textContent=s})}if(d.compareAt&&a){let g=d.compareAt.replace("{{variant}}",t);document.querySelectorAll(g).forEach(l=>{let s=new Intl.NumberFormat("en-US",{style:"currency",currency:r}).format(parseFloat(a));l.textContent=s})}if(d.saving&&c&&a)for(let g of d.saving){let i=g.selector.replace("{{variant}}",t);document.querySelectorAll(i).forEach(s=>{let u=parseFloat(c),p=parseFloat(a),_=p-u;if(g.isPercentage){let x=Math.round(_/p*100);s.textContent=`${x}%`}else{let x=new Intl.NumberFormat("en-US",{style:"currency",currency:r}).format(_);s.textContent=x}})}}}var ar={type:"PRICE_PLUS",shouldActivate(e,t){let r=e.data;if(!r)return!1;let{productId:o,productHandle:n}=t,c=n||Yn(t.currentUrl),a=o&&r.productIds?.includes(o),f=c&&r.handles?.includes(c);return a||f},applyEffect(e,t,r){Qn(t,r.variantId,r.currencyCode||"USD",r.selectors)},getVariantData(e,t,r){let o=e.data;return{prices:t.prices,matchedProductId:r.productId,productIds:o?.productIds,handles:o?.handles,handlerActivated:!0}}};function Xn(e,t){let o=e.data?.pathnames||[];if(!o.length)return!0;try{let c=new URL(t,"https://example.com").pathname;return o.some(a=>re(c,a))}catch{return!1}}var Ze={type:"CONTENT",shouldActivate(e,t){return Xn(e,t.currentUrl)},getVariantData(e,t,r){let o=e.data;return{content:t.content,pathnames:o?.pathnames,handlerActivated:!0}}};function Kn(e,t){let o=e.data?.pathnames||[];if(!o.length)return!0;try{let c=new URL(t,"https://example.com").pathname;return o.some(a=>re(c,a))}catch{return!1}}var cr={type:"CUSTOM_CODE",shouldActivate(e,t){return Kn(e,t.currentUrl)},getVariantData(e,t,r){let o=e.data;return{customCode:t.customCode,pathnames:o?.pathnames,excludePathnames:o?.excludePathnames,handlerActivated:!0}}};ve(ar);ve(Wt);ve(Ze);ve(cr);function Zn(e){if(typeof window>"u")return{currentUrl:"",selectors:e};let t=window.location.href,r=window.location.pathname,o,n=r.match(/\/products\/([^\/\?]+)/);n&&(o=n[1]);let c,f=new URLSearchParams(window.location.search).get("variant");return f&&(c=f),{currentUrl:t,productHandle:o,variantId:c,selectors:e,currencyCode:"USD"}}function ln(e){let{config:t,previewState:r,selectors:o}=Ct(),[n,c]=_e.default.useState(null),[a,f]=_e.default.useState(!0),d=_e.default.useMemo(()=>t&&t.tests.find(s=>s.testId===e)||null,[t,e]),g=_e.default.useMemo(()=>r||pe(),[r]),i=_e.default.useRef(null),l=_e.default.useRef(null);return _e.default.useEffect(()=>{let s=!0;if(t===null)return;if(!d){i.current!==e&&(i.current=e,console.warn(`[ElevateAB] Test not found: ${e}`)),s&&f(!1);return}if(!d.enabled&&!g?.isPreview){i.current!==`${e}-disabled`&&(i.current=`${e}-disabled`,console.warn(`[ElevateAB] Test disabled: ${e}`)),s&&f(!1);return}let u=J(e);if(!u){s&&f(!1);return}let p=d.variations.find(b=>b.id===u);if(!p){s&&f(!1);return}let _=Ke(d.type),x=Zn(o),w={...p};if(_?.shouldActivate(d,x)){let b=`${e}-${p.id}`;_.applyEffect&&l.current!==b&&(l.current=b,_.applyEffect(d,p,x));let k=_.getVariantData(d,p,x);w={...w,...k}}return s&&c(w),g?.isPreview||dt(e),s&&f(!1),()=>{s=!1}},[t,d,e,g,o]),{variant:n,isLoading:a,isControl:n?.isControl??!1,isA:n?.isA??!1,isB:n?.isB??!1,isC:n?.isC??!1,isD:n?.isD??!1}}var M=nt(require("react"),1);it();je();fe();function ur(e){return e.tests.some(t=>t.type==="CUSTOM_CODE"&&t.enabled)}function dr(e,t,r){if(typeof window>"u")return;if(console.log("[ElevateAB Custom Code] All tests:",e.tests.map(c=>({id:c.testId,type:c.type,enabled:c.enabled}))),!ur(e)){console.log("[ElevateAB Custom Code] No CUSTOM_CODE tests found");return}let o=e.tests.filter(c=>c.type==="CUSTOM_CODE"&&c.enabled);console.log("[ElevateAB Custom Code] Found",o.length,"CUSTOM_CODE tests");let n=[];o.forEach(c=>{let a=J(c.testId);if(console.log("[ElevateAB Custom Code] Test",c.testId,"assigned variant:",a),!a)return;let f=c.variations.find(d=>d.id===a);if(console.log("[ElevateAB Custom Code] Variation data:",f),!f?.customCode){console.log("[ElevateAB Custom Code] No customCode on variation");return}(f.customCode.js||f.customCode.css)&&(console.log("[ElevateAB Custom Code] Adding custom code:",f.customCode),n.push(f.customCode))}),n.length>0?(console.log("[ElevateAB Custom Code] Applying",n.length,"custom code blocks"),We(n,r)):console.log("[ElevateAB Custom Code] No custom code to apply")}function eo(e,t,r){typeof window>"u"||dr(e,t,r)}function pn(e,t,r){if(typeof window>"u")return()=>{};let o=()=>{eo(e,t,r)};return window.addEventListener("popstate",o),()=>{window.removeEventListener("popstate",o)}}fe();var xt=require("react/jsx-runtime"),to="https://d19dz5bxptjmv5.cloudfront.net/headless";function ro(e){return e.replace(/^https?:\/\//,"").replace(".myshopify.com","")}function fn(e){return`${to}/${ro(e)}.js`}function mn({storeId:e,storefrontAccessToken:t,preventFlickering:r=!1,flickerTimeout:o=3e3,nonce:n,children:c}){let[a,f]=M.default.useState(null),[d,g]=M.default.useState(null),[i,l]=M.default.useState(null);M.default.useEffect(()=>{if(typeof window>"u")return;_t({storeId:e,storefrontAccessToken:t});let w=pe();g(w);let b=ge();l(b)},[e,t]);let s=(0,M.useCallback)(()=>{typeof window<"u"&&window.__eab_reveal&&window.__eab_reveal()},[]);M.default.useEffect(()=>{async function w(){try{let b=typeof window<"u"?pe():null,k=null;if(typeof window<"u"&&window.eab_data)k=window.eab_data;else{let Q=fn(e);k=await new Promise((ne,X)=>{let $=document.createElement("script");$.src=Q,$.async=!0,$.onload=()=>{let m=window.eab_data;$.remove(),m?ne(m):X(new Error("Failed to load config: window.eab_data is undefined"))},$.onerror=()=>{$.remove(),ne({allTests:{},selectors:{selectorsV2:[]}})},document.head.appendChild($)})}if(!k||!k.allTests||Object.keys(k.allTests).length===0){f({tests:[],selectors:void 0}),s();return}if(k.subscriptionPaused){console.error(`[ElevateAB] Subscription is paused or stopped for store: ${e}. `+(k.subscriptionMessage||"A/B tests will not run. Please reactivate your subscription.")),f({tests:[],selectors:void 0}),s();return}if(!(Object.keys(k.allTests||{}).length>0)){f({tests:[],selectors:void 0}),s();return}let F=Cr(k);if(ut(F,b),F.tests.some(Q=>Q.type==="SPLIT_URL")&&Fe(F,b))return;f(F),s()}catch(b){console.error("[ElevateAB] Failed to load config:",b),f({tests:[],selectors:void 0}),s()}}w()},[e,s]),M.default.useEffect(()=>!a||typeof window>"u"||!Ge(a)?void 0:(Je(a,d,n),ht(a,d,n)),[a,d,n]),M.default.useEffect(()=>!a||typeof window>"u"||!ur(a)?void 0:(dr(a,d,n),pn(a,d,n)),[a,d,n]);let u=M.default.useMemo(()=>({config:a,storeId:e,storefrontAccessToken:t,isPreviewMode:d?.isPreview??!1,previewTestId:d?.previewTestId??null,previewState:d,selectors:a?.selectors,countryCode:i}),[a,e,t,d,i]),p=(0,M.useRef)(!1);M.default.useEffect(()=>{!t&&!p.current&&(p.current=!0,console.warn("[ElevateAB] No storefrontAccessToken provided. Orders won't be attributed to test variants."))},[t]);let _=M.default.useMemo(()=>fn(e),[e]),x=M.default.useMemo(()=>lt({configUrl:_,timeout:r?o:2e3}),[_,r,o]);return(0,xt.jsxs)(Xe.Provider,{value:u,children:[(0,xt.jsx)("script",{nonce:n,dangerouslySetInnerHTML:{__html:x}}),c]})}var Ee=require("react");Y();Y();vt();var no="https://bitter-river-9c62.support-67d.workers.dev",oo="https://d339co84ntxcme.cloudfront.net/Prod/orders";function Ce(){return`sh-${le()}`}function io(e){return Object.entries(e).filter(([,t])=>typeof t=="string").map(([t,r])=>({test_id:t,variant_id:r}))}function so(e,t){return Object.entries(e).filter(([r])=>typeof t[r]=="string").map(([r])=>({test_id:r,variant_id:t[r]}))}function gn({storeId:e,storefrontAccessToken:t,hasLocalizedPaths:r,workerUrl:o=no,ordersWorkerUrl:n=oo,useAnalytics:c}){let a=(0,Ee.useContext)(Xe),f=e||a?.storeId||"",d=t||a?.storefrontAccessToken,g=(0,Ee.useRef)(!1);(0,Ee.useEffect)(()=>{!a&&!e&&!g.current&&(g.current=!0,console.error("[ElevateAB] ElevateAnalytics must be used inside ElevateProvider, or you must pass storeId as a prop."))},[a,e]);let{subscribe:i,register:l}=c(),{ready:s}=l("Elevate Analytics");return(0,Ee.useEffect)(()=>{if(typeof window>"u")return;if(ce(),Te(),typeof document<"u"){let p=document.referrer||"",_=window.location.href;st(p,_)}(()=>{let p=m=>{let h=te(m.products?.[0]?.id);h&&typeof localStorage<"u"?localStorage.setItem("eabProductPageId",h):typeof window<"u"&&!window.location.pathname.includes("/products/")&&localStorage?.removeItem("eabProductPageId");let S=Ue(typeof localStorage<"u"?localStorage.getItem("shopifyCartId"):null),{referrer:R,entryPage:O}=Ie();return{visitorId:ce(),sessionId:Te(),cartToken:S||V("cart")||"",referrer:R,entryPage:O,clientId:V("_shopify_y"),rootRoute:typeof localStorage<"u"&&localStorage.getItem("eabRootRoute")||"",productPageId:typeof localStorage<"u"&&localStorage.getItem("eabProductPageId")||""}},_=(m,h,S,R)=>{let O=typeof navigator<"u"?navigator.userAgent:"",z=S?.url?new URL(S.url).pathname:typeof window<"u"?window.location.pathname:"",W=Ve(z,r),I=Oe({referrer:R.referrer,entryPage:R.entryPage,userAgent:O}),B=N("ABTL")||{},G=N("ABAU")||{},ke=io(B),oe=so(G,B),ie=new Date().toISOString(),de=typeof sessionStorage<"u"?sessionStorage.getItem("eabIsFirstVisit")==="true":!1,xe=V("localization")||"";return{pixel_event_id:h,shop_name:f,timestamp:ie,event_type:m,client_id:R.clientId,visitor_id:R.visitorId,session_id:R.sessionId,cart_token:Re(R.cartToken),page_url:S.context?.document?.location?.href||(typeof window<"u"?window.location.href:""),page_pathname:z,page_search:S.context?.document?.location?.search||(typeof window<"u"?window.location.search:""),referrer_url:R.referrer,referrer_source:I?.referrer_source,previous_page:typeof document<"u"?document.referrer:"",page_entry:R.entryPage,page_entry_path:I?.page_entry_path,page_type:W,utm_medium:I?.utm_medium,utm_source:I?.utm_source,utm_campaign:I?.utm_campaign,utm_content:I?.utm_content,utm_term:I?.utm_term,gclid:I?.gclid,fbclid:I?.fbclid,pins_campaign_id:I?.pins_campaign_id,epik:I?.epik,browser_info:I?.browser_info,os_info:I?.os_info,device_type:I?.device_type,language:S.context?.navigator?.language||(typeof navigator<"u"?navigator.language:""),root_route:R.rootRoute,user_agent:O,user_agent_no_browser:Le(O),is_first_visit:de,shopify_country:xe,cart_currency:S.shop?.currency,ab_test_assignments:ke,ab_test_views:oe,is_first_order:null}},x=async m=>{if(!m.exclude)try{let h=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m),keepalive:!0});if(!h.ok)throw new Error(`Worker error: ${h.status}`);return h}catch(h){console.error("[ElevateAB] Error sending analytics:",h)}},w=async m=>{try{let h=p(m),S=Ce(),R=_("page_viewed",S,m,h);await x(R)}catch(h){console.error("[ElevateAB] Error handling page_viewed:",h)}},b=async m=>{try{let h=p(m),S=Ce(),O={..._("product_viewed",S,m,h),product_id:te(m?.products?.[0]?.id)||"",product_vendor:P(m?.products?.[0]?.vendor)??"",product_price:v(m?.products?.[0]?.price)??null,product_sku:P(m?.products?.[0]?.sku)??""};await x(O)}catch(h){console.error("[ElevateAB] Error handling product_viewed:",h)}},k=async m=>{try{let h=p(m),S=Ce(),O={..._("product_added_to_cart",S,m,h),product_id:te(m?.currentLine?.merchandise?.product?.id)??"",variant_id:we(m?.currentLine?.merchandise?.id)??"",product_vendor:P(m?.currentLine?.merchandise?.product?.vendor)??"",product_price:v(m?.currentLine?.cost?.totalAmount?.amount)??null,product_quantity:m?.currentLine?.quantity??null,product_sku:P(m?.currentLine?.merchandise?.sku)??""};await x(O);let z=m?.cart?.id;z&&d&&f&&Qe(z,{storefrontAccessToken:d,storefrontApiUrl:`https://${f}/api/2025-01/graphql.json`}).catch(W=>{console.error("[ElevateAB] Failed to update cart attributes:",W)})}catch(h){console.error("[ElevateAB] Error handling product_added_to_cart:",h)}},L=async m=>{try{let h=p(m),S=Ce(),O={..._("product_removed_from_cart",S,m,h),product_id:te(m?.prevLine?.merchandise?.product?.id)??"",variant_id:we(m?.prevLine?.merchandise?.id)??"",product_vendor:P(m?.prevLine?.merchandise?.product?.vendor)??"",product_price:v(m?.prevLine?.cost?.totalAmount?.amount)??null,product_quantity:m?.prevLine?.quantity??null,product_sku:P(m?.prevLine?.merchandise?.sku)??""};await x(O)}catch(h){console.error("[ElevateAB] Error handling product_removed_from_cart:",h)}},F=async m=>{try{let h=p(m),S=Ce(),R=_("cart_viewed",S,m,h),z=(m?.data?.cart?.lines?.nodes||m?.data?.cart?.lines||[]).map(I=>({product_id:te(I?.merchandise?.product?.id)??"",variant_id:we(I?.merchandise?.id)??"",vendor:P(I?.merchandise?.product?.vendor)??"",total_price:v(I?.cost?.totalAmount?.amount)??null,quantity:I?.quantity??null,sku:P(I?.merchandise?.sku)??""})),W={...R,cart_total_price:v(m?.cart?.cost?.totalAmount?.amount)??null,cart_total_quantity:m?.cart?.totalQuantity??null,cart_items:z};await x(W)}catch(h){console.error("[ElevateAB] Error handling cart_viewed:",h)}},Q=async m=>{try{let h=p(m),S=Ce(),O={..._("search_submitted",S,m,h),search_query:P(m?.data?.searchResult?.query)??""};await x(O)}catch(h){console.error("[ElevateAB] Error handling search_submitted:",h)}},ne=async m=>{try{let h=p(m),S=Ce(),R=_("checkout_started",S,m,h),O=0,W=(m?.data?.checkout?.lineItems??[]).map(B=>{let G=B?.quantity??0;O+=G;let oe=(B?.discountAllocations??[])?.reduce((ie,de)=>ie+(de?.amount?.amount||0),0);return{product_id:te(B?.variant?.product?.id)??"",variant_id:we(B?.variant?.id)??"",vendor:P(B?.variant?.product?.vendor)??"",total_price:v(B?.finalLinePrice?.amount)??null,quantity:G,sku:P(B?.variant?.sku)??"",total_discount:v(oe)??null}}),I={...R,cart_total_price:v(m?.data?.checkout?.totalPrice?.amount)??null,cart_subtotal_price:v(m?.data?.checkout?.subtotalPrice?.amount)??null,cart_total_quantity:O,cart_shipping_price:v(m?.data?.checkout?.shippingLine?.price?.amount)??null,cart_tax_amount:v(m?.data?.checkout?.totalTax?.amount)??null,cart_discount_amount:v(m?.data?.checkout?.discountsAmount?.amount)??null,cart_items:W,customer_id:m?.data?.checkout?.order?.customer?.id??""};await x(I)}catch(h){console.error("[ElevateAB] Error handling checkout_started:",h)}},X=async m=>{try{let h=p(m),S=Ce(),R=_("checkout_completed",S,m,h),O=0,W=(m?.data?.checkout?.lineItems??[]).map(B=>{let G=B?.quantity??0;O+=G;let oe=(B?.discountAllocations??[])?.reduce((ie,de)=>ie+(de?.amount?.amount||0),0);return{product_id:te(B?.variant?.product?.id)??"",variant_id:we(B?.variant?.id)??"",vendor:P(B?.variant?.product?.vendor)??"",total_price:v(B?.finalLinePrice?.amount)??null,quantity:G,sku:P(B?.variant?.sku)??"",total_discount:v(oe)??null}}),I={...R,cart_total_price:v(m?.data?.checkout?.totalPrice?.amount)??null,cart_subtotal_price:v(m?.data?.checkout?.subtotalPrice?.amount)??null,cart_total_quantity:O,cart_shipping_price:v(m?.data?.checkout?.shippingLine?.price?.amount)??null,cart_tax_amount:v(m?.data?.checkout?.totalTax?.amount)??null,cart_discount_amount:v(m?.data?.checkout?.discountsAmount?.amount)??null,cart_items:W,order_id:m?.data?.checkout?.order?.id??"",customer_id:m?.data?.checkout?.order?.customer?.id??"",is_first_order:m?.data?.checkout?.order?.customer?.isFirstOrder??null,note_attributes:m?.data?.checkout?.attributes??[]};await $(I)}catch(h){console.error("[ElevateAB] Error handling checkout_completed:",h)}},$=async m=>{if(!m.exclude)try{let h=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m),keepalive:!0});if(!h.ok)throw new Error(`Orders worker error: ${h.status}`);return h}catch(h){console.error("[ElevateAB] Error sending order analytics:",h)}};i("page_viewed",w),i("product_viewed",b),i("product_added_to_cart",k),i("product_removed_from_cart",L),i("cart_viewed",F),i("search_submitted",Q),i("checkout_started",ne),i("checkout_completed",X)})(),s()},[i,s,f,r,d,o,n]),null}var ao="1.1.2";0&&(module.exports={CART_ATTRIBUTES_UPDATE_MUTATION,COUNTRIES,ElevateAnalytics,ElevateProvider,REGIONS,VERSION,applyContentChanges,applyContentElements,applyCustomCode,assignAllTests,assignAndPersistVariant,buildEabTestsParam,canAssignToTest,checkFacebookBrowser,checkFacebookInstagramBrowser,checkInstagramBrowser,checkPinterestBrowser,checkTikTokBrowser,checkVisitorIdParams,cleanCartToken,cleanupCartAttributes,cleanupContentTests,clearPreviewMode,contentHandler,deleteCookie,detectShopifyCurrency,extractCartToken,extractProductId,extractProductVariantId,extractShopifyId,extractShopifyType,getAllHandlers,getAssignedVariant,getCartAttributesPayload,getCookie,getCountryCode,getDeviceType,getGeoLocation,getHandler,getJsonCookie,getJsonSessionItem,getPageTypeFromPathname,getPreviewState,getPreviewVariation,getReferrerData,getSessionId,getSessionItem,getSplitUrlBlockingScript,getTestList,getTrafficSource,getUserAgentNoBrowser,getVisitorId,hasContentTests,hasHandler,hasSessionView,hasUniqueView,hashString,initAnalytics,initializeSessionId,initializeVisitorId,isCountryExcluded,isCountryIncluded,isInPreviewMode,isPreviewTest,isShopifyGid,matchesGeoTargeting,matchesWildcardPattern,parseAddViewData,processContentTests,processSplitUrlTests,registerHandler,reprocessContentTests,restoreOriginalElements,roundToTwo,sanitizeString,saveTestList,setCookie,setCountryCode,setGeoLocation,setReferrerData,setSessionItem,setupContentTestListeners,shouldShowTest,trackAddToCart,trackCartView,trackCheckoutCompleted,trackCheckoutStarted,trackPageView,trackProductView,trackRemoveFromCart,trackSearchSubmitted,trackSessionView,trackUniqueView,trackViews,updateCartAttributes,updateUrlWithTestParams,useElevateConfig,useExperiment,usePageViewTracking,uuidv4});
|
|
45
|
+
})();`}function Hr(e){if(!e?.trim())return"";try{let r=`https://${e.trim().replace(/^https?:\/\//,"")}`,o=new URL(r.replace(/\/+$/,""));return o.hostname.startsWith("www.")&&(o.hostname=o.hostname.substring(4)),o.toString().replace(/\/+$/,"")}catch{return e.trim().replace(/\/+$/,"")}}function $t(e,t){let r=Hr(e.split("?")[0]);for(let o of t){let n=Hr(o.split("?")[0]);if(r===n)return!0;try{let c=new URL(e).pathname,a=new URL(o,e).pathname;if(c===a)return!0}catch{}}return!1}function Sn(e){return e.data?.redirectBehavior||"redirectAll"}function zr(e){return!!(N("eabRedirectedTests")||{})[e]}function qr(e){let t=N("eabRedirectedTests")||{};t[e]=!0,H("eabRedirectedTests",JSON.stringify(t))}function In(e,t){for(let r of e.tests)if(!(r.type!=="SPLIT_URL"||!r.enabled))for(let o of r.variations){let n=o.splitUrlTestLinks||[];if(n.length!==0&&$t(t,n))return{test:r,matchedVariation:o,isControlUrl:!!o.isControl}}return null}function Un(e){if(typeof window>"u")return;let t=new URL(e,window.location.origin);t.searchParams.set("abtr","true");let r=t.toString(),o=window.__remixRouter?.navigate??window.next?.router?.push??window.$nuxt?.$router?.push??window.__navigate;if(o&&typeof o=="function")try{let n=t.pathname+t.search;o(n);return}catch{}window.location.href=r}function Fe(e,t){if(typeof window>"u")return!1;let r=window.location.href;if(new URLSearchParams(window.location.search).get("abtr")==="true")return!1;let n=In(e,r);if(!n)return!1;let{test:c,matchedVariation:a,isControlUrl:f}=n,d=c.testId,g=Sn(c),i=J(d);if(!i)return!1;let l=c.variations.find(p=>p.id===i);if(!l)return!1;let s=l.splitUrlTestLinks||[];if(s.length===0||$t(r,s))return!1;switch(g){case"redirectOnlyControlUrl":if(!f||l.isControl)return!1;break;case"redirectOnce":if(zr(d))return!1;qr(d);break;case"redirectOnceControlUrlOnly":if(!f||zr(d)||l.isControl)return!1;qr(d);break;default:break}let u=s[0];return Un(u),!0}var Wt={type:"SPLIT_URL",shouldActivate(e,t){for(let r of e.variations){let o=r.splitUrlTestLinks||[];if($t(t.currentUrl,o))return!0}return!1},getVariantData(){return{handlerActivated:!0}}};var Gt=nt(jr(),1),Fr={"facebook.com":"Facebook","fb.me":"Facebook","m.facebook.com":"Facebook","l.facebook.com":"Facebook","lm.facebook.com":"Facebook","instagram.com":"Instagram","l.instagram.com":"Instagram","youtube.com":"Youtube","youtu.be":"Youtube","m.youtube.com":"Youtube","bing.com":"Bing","www.bing.com":"Bing","msnbc.msn.com":"Bing","dizionario.it.msn.com":"Bing","cc.bingj.com":"Bing","m.bing.com":"Bing","twitter.com":"Twitter","t.co":"Twitter"};function P(e){return typeof e!="string"?String(e):e.replace(/[\\"'`\x00-\x1F\x7F]/g,"")}function v(e){if(e==null)return null;let t=typeof e=="string"?parseFloat(e):Number(e);return isNaN(t)?null:+(Math.round(+(t+"e2"))+"e-2")}function te(e){if(!e)return null;let t=/gid:\/\/shopify\/Product\/(\d+)/,r=e.match(t);return r?r[1]:null}function we(e){if(!e)return null;let t=/gid:\/\/shopify\/ProductVariant\/(\d+)/,r=e.match(t);return r?r[1]:null}function Ue(e){if(!e)return null;let t=/gid:\/\/shopify\/Cart\/([^?]+(\?.+)?)/,r=e.match(t);return r?r[1]:null}function Re(e){try{return typeof e!="string"?null:decodeURIComponent(e).split("?")[0]}catch{return e||null}}function Rn(e){return/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i.test(e)}function On(e){return/(instagram)[\/ ]([-\w\.]+)/i.test(e)}function $r(e){return Rn(e)||On(e)}function Vn(e){if(!e)return"";switch(e){case"Mobile Safari":return"Safari";case"Chrome Mobile":case"Chrome Mobile iOS":return"Chrome";case"Firefox Mobile":case"Firefox Mobile iOS":return"Firefox";case"Opera Mobile":case"Opera Mini":case"Opera Mini iOS":return"Opera";case"Yandex Browser Lite":return"Yandex Browser";case"Chrome Webview":case"Mobile App":return"Mobile App";default:return e}}function Ln(e){let t={};return e.searchParams.forEach((r,o)=>{t[o]||(t[o]=r)}),t}function Bn(e){return!!e.host&&["http:","https:"].includes(e.protocol)}function Dn(e){return e.replace(/^www\./,"")}function Nn(e,t,r){if(t&&{Facebook:"Facebook",Instagram:"Instagram"}[t])return t;let n,c;try{if(e&&e.trim()!=="")n=new URL(e);else return"Direct";if(n?.hostname&&Bn(n)){if(c=n.hostname,r&&r===c)return"Direct"}else return""}catch{}if(!c)return"";let a=Dn(c);return a?Fr[a]?Fr[a]:a?.includes("google")?"Google":a:""}function Oe(e){let{referrer:t,entryPage:r,userAgent:o}=e,n={referrer_source:"",browser_info:"",os_info:"",device_type:"",page_entry_path:"",utm_medium:"",utm_source:"",utm_campaign:"",utm_content:"",utm_term:"",referrer_url:t||"",gclid:"",fbclid:"",pins_campaign_id:"",epik:""};try{let c;if(r&&r.trim()!==""&&r.startsWith("http"))try{let a=new URL(r),f=a?.pathname;c=a?.hostname,f&&(n.page_entry_path=f??"");let d=Ln(a);n.utm_medium=d.utm_medium??"",n.utm_source=d.utm_source??"",n.utm_campaign=d.utm_campaign??"",n.utm_content=d.utm_content??"",n.utm_term=d.utm_term??"",n.gclid=d.gclid??"",n.fbclid=d.fbclid??"",n.pins_campaign_id=d.pins_campaign_id??"",n.epik=d.epik??""}catch{}if(o){let a=(0,Gt.UAParser)(o),f=a?.browser?.name,d=Vn(f);n.browser_info=d??"",n.os_info=a?.os?.name??"",o&&(n.device_type=(a?.device?.type||"desktop")?.toUpperCase()??"")}return n.referrer_source=Nn(t,n?.browser_info,c)??"",n}catch{return n}}function Ve(e,t){let r=e==="/"||e==="",n=t&&/^\/[a-z]{2}(-[a-z]{2})?\/?$/i.test(e);return r||n?"index":/\/products\//.test(e)?"product":/\/collections\//.test(e)?"collection":/\/pages\//.test(e)?"page":/\/search/.test(e)?"search":/\/cart/.test(e)?"cart":/\/checkouts\//.test(e)?"checkout":"unknown"}function Wr(e){try{return e&&new URLSearchParams(e).get("eabUserId")||!1}catch{return!1}}function Le(e){if(!e)return"";try{let t=(0,Gt.UAParser)(e),r=t?.os,o=t?.device,n="";return r?.name&&(n+=r.name,r.version&&(n+=` ${r.version}`)),o?.type&&(n+=n?` (${o.type})`:o.type),o?.vendor&&(n+=n?` ${o.vendor}`:o.vendor),o?.model&&(n+=n?` ${o.model}`:o.model),n||e}catch{return e}}function q(e){return e?e.includes("gid://")&&e.split("/").pop()||e:""}function Gr(e){return!e||!e.includes("gid://")?null:e.split("/")[3]||null}function Jr(e){return!!e&&e.startsWith("gid://shopify/")}function Yr(){if(typeof window>"u")return;let e=window.Shopify;if(e?.currency?.active)return e.currency.active}fe();var Qr="elv-el-",Xr={ELEMENT_NODE:1,TEXT_NODE:3},ft=new Map,mt=new Map,gt=new Map,wt=new Map,Be=!1;function re(e,t){if(t==="*")return!0;if(t.startsWith("*")&&t.endsWith("*")){let r=t.slice(1,-1);return e.includes(r)}if(t.startsWith("*")){let r=t.slice(1);return e.endsWith(r)}return t===e}function Qt(){return typeof window>"u"?!1:window.innerWidth<768}function Mn(e){let t="";for(let r=0;r<e.length;r++){let o=e[r];o>="A"&&o<="Z"?(r!==0&&(t+="-"),t+=o.toLowerCase()):t+=o}return t}function Hn(e){return e.nodeType===Xr.TEXT_NODE}function Jt(e){return e.nodeType===Xr.ELEMENT_NODE}function Yt(e,t){ft.has(e)||ft.set(e,t.cloneNode(!0))}function Kr(e){let t=e;t=t.replace(/`/g,"`").replace(/$/g,"$");try{t=JSON.parse('"'+t+'"')}catch{}return t}function Xt(e){if(typeof window>"u"||e.length===0)return;let t=window.location.pathname,r=e.filter(n=>n.pathnames?.length?n.pathnames.some(c=>re(t,c)):!0);Be=Qt();let o=r.map(n=>({...n,style:n.style?{...n.style.lg,...Be&&n.style.sm}:void 0,content:n.content&&Be&&n.content.sm?n.content.sm:n.content?.lg}));o.filter(n=>n.content!==void 0).forEach(n=>{(n.applyAll?Array.from(document.querySelectorAll(n.selector)):[document.querySelector(n.selector)].filter(Boolean)).forEach((a,f)=>{if(!a)return;let d=n.applyAll?`${n.selector}-${f}-${a.id||Math.random().toString(36).substr(2,9)}`:n.selector;Yt(d,a),Hn(a)?a.nodeValue=n.content:Jt(a)&&(a.innerHTML=n.content)})}),o.filter(n=>n.style!==void 0).forEach(n=>{let c=document.querySelector(n.selector);!c||!Jt(c)||(Yt(n.selector,c),Object.entries(n.style).forEach(([a,f])=>{let d=Mn(a),g=f.toString().includes("!important"),i=f.toString().replace(/\s*!important\s*$/,"");c.style.setProperty(d,i,g?"important":void 0)}))}),o.filter(n=>n.attributes!==void 0).forEach(n=>{let c=document.querySelector(n.selector);!c||!Jt(c)||(Yt(n.selector,c),Object.entries(n.attributes).forEach(([a,f])=>{c.setAttribute(a,f)}))})}function Kt(e){if(typeof window>"u"||e.length===0)return;let t=window.location.pathname;e.filter(o=>o.selector?.pathnames?.length?o.selector.pathnames.some(n=>re(t,n)):!0).forEach(o=>{let n=`${Qr}${o.id}`;if(wt.has(n))return;let c=document.querySelector(o.selector.target);if(!c||c.parentElement?.querySelector(`#${n}`))return;let a=Zr(o);o.selector.placement==="after"?c.after(a):o.selector.placement==="before"&&c.before(a),wt.set(n,a)})}function Zr(e){let t=document.createElement(e.tagName);return t.id=`${Qr}${e.id}`,e.style&&Object.assign(t.style,e.style),e.attributes&&Object.entries(e.attributes).forEach(([r,o])=>{t.setAttribute(r,o)}),e.kind==="text"&&e.content&&(t.innerText=e.content),e.kind==="container"&&e.childrens&&e.childrens.forEach(r=>{let o=Zr(r);t.appendChild(o)}),t}function We(e,t){if(typeof window>"u"||e.length===0)return;let r=window.location.pathname;e.filter(n=>n.pathnames?.length?n.excludePathnames?.length&&n.excludePathnames.some(a=>re(r,a))?!1:n.pathnames.some(c=>re(r,c)):!0).forEach(n=>{n.id&&(n.css&&zn(n.id,n.css),n.js&&qn(n.id,n.js,t))})}function zn(e,t){let r=`css-${e}`;if(mt.has(r)||document.getElementById(r))return;let o=document.createElement("style");o.id=r,o.textContent=Kr(t),document.head.appendChild(o),mt.set(r,o)}function qn(e,t,r){let o=`js-${e}`;if(gt.has(o)||document.getElementById(o))return;let n=document.createElement("script");n.id=o,r&&n.setAttribute("nonce",r);let c=Kr(t);n.textContent="(function(){try{"+c+"}catch(e){console.error('[ElevateAB] Custom script error:', e)}})();",document.head.appendChild(n),gt.set(o,n)}function Zt(){ft.forEach((e,t)=>{let r=document.querySelector(t);r&&r.replaceWith(e.cloneNode(!0))})}function er(){mt.forEach(e=>e.remove()),mt.clear(),gt.forEach(e=>e.remove()),gt.clear(),wt.forEach(e=>e.remove()),wt.clear(),ft.clear()}function jn(e,t){let r=[],o=[],n=[];return e.tests.filter(a=>a.type==="CONTENT"&&a.enabled).forEach(a=>{let f=J(a.testId);if(!f)return;let d=a.variations.find(g=>g.id===f);d?.content&&(d.content.changes?.length&&r.push(...d.content.changes),d.content.elements?.length&&o.push(...d.content.elements),d.content.customCodes?.length&&n.push(...d.content.customCodes))}),{changes:r,elements:o,blocks:[],customCodes:n}}function Ge(e){return e.tests.some(t=>t.type==="CONTENT"&&t.enabled)}function Je(e,t,r){if(typeof window>"u"||!Ge(e))return;let o=jn(e,t);(o.changes.length>0||o.elements.length>0||o.customCodes.length>0)&&(Xt(o.changes),Kt(o.elements),We(o.customCodes,r))}function bt(e,t,r){if(typeof window>"u")return;let o=Qt();o!==Be&&(Zt(),Be=o),Je(e,t,r)}function ht(e,t,r){if(typeof window>"u")return()=>{};let o=()=>{Qt()!==Be&&bt(e,t,r)},n=()=>{bt(e,t,r)};return window.addEventListener("resize",o),window.addEventListener("popstate",n),()=>{window.removeEventListener("resize",o),window.removeEventListener("popstate",n),er()}}vt();tr();Y();var Pe=require("react"),Fn="https://bitter-river-9c62.support-67d.workers.dev",$n="https://d339co84ntxcme.cloudfront.net/Prod/orders",D=null;function _t(e){D=e}function be(e){let t=e?.storeId||D?.storeId;return t||(console.warn("[ElevateAB] No storeId provided. Call initAnalytics() first or pass storeId to tracking function."),"")}function Wn(e){return Object.entries(e).filter(([,t])=>typeof t=="string").map(([t,r])=>({test_id:t,variant_id:r}))}function Gn(e,t){return Object.entries(e).filter(([r])=>typeof t[r]=="string").map(([r])=>({test_id:r,variant_id:t[r]}))}function Jn(){return typeof window>"u"?!1:V("eabUserPreview")==="true"||new URLSearchParams(window.location.search).get("eabUserPreview")==="true"}function he(e,t,r){if(typeof window>"u"||Jn())return null;let o=navigator.userAgent,n=window.location.pathname,c=Ve(n,r),{referrer:a,entryPage:f}=Ie(),d=Oe({referrer:a,entryPage:f,userAgent:o}),g=N("ABTL")||{},i=N("ABAU")||{},l=Wn(g),s=Gn(i,g),u=Ue(localStorage.getItem("shopifyCartId")),p=new Date().toISOString(),_=sessionStorage.getItem("eabIsFirstVisit")==="true",x=V("localization")||"";return{pixel_event_id:`sh-${le()}`,shop_name:e,timestamp:p,event_type:t,client_id:V("_shopify_y")||void 0,visitor_id:ce(),session_id:Te(),cart_token:Re(u||V("cart")),page_url:window.location.href,page_pathname:n,page_search:window.location.search,referrer_url:a,referrer_source:d?.referrer_source,previous_page:document.referrer,page_entry:f,page_entry_path:d?.page_entry_path,page_type:c,utm_medium:d?.utm_medium,utm_source:d?.utm_source,utm_campaign:d?.utm_campaign,utm_content:d?.utm_content,utm_term:d?.utm_term,gclid:d?.gclid,fbclid:d?.fbclid,pins_campaign_id:d?.pins_campaign_id,epik:d?.epik,browser_info:d?.browser_info,os_info:d?.os_info,device_type:d?.device_type,language:navigator.language,root_route:localStorage.getItem("eabRootRoute")||"",user_agent:o,user_agent_no_browser:Le(o),is_first_visit:_,shopify_country:x,ab_test_assignments:l,ab_test_views:s,is_first_order:null}}async function ye(e,t=Fn){try{let r=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:!0});if(!r.ok)throw new Error(`Worker error: ${r.status}`)}catch(r){console.error("[ElevateAB] Error sending analytics:",r)}}async function nr(e={}){let t=be(e);if(!t)return;let r=e.hasLocalizedPaths??D?.hasLocalizedPaths,o=e.workerUrl??D?.workerUrl,n=he(t,"page_viewed",r);if(!n)return;let c={...n,cart_currency:e.currency};await ye(c,o)}async function rn(e){let t=be(e);if(!t)return;let{productId:r,productVendor:o,productPrice:n,productSku:c,currency:a}=e,f=e.hasLocalizedPaths??D?.hasLocalizedPaths,d=e.workerUrl??D?.workerUrl,g=he(t,"product_viewed",f);if(!g)return;let i={...g,cart_currency:a,product_id:q(r),product_vendor:P(o),product_price:v(n),product_sku:P(c)};await ye(i,d)}async function nn(e){let t=be(e);if(!t)return;let{productId:r,variantId:o,productVendor:n,productPrice:c,productQuantity:a,productSku:f,currency:d,cartId:g}=e,i=e.hasLocalizedPaths??D?.hasLocalizedPaths,l=e.workerUrl??D?.workerUrl,s=e.storefrontAccessToken??D?.storefrontAccessToken,u=he(t,"product_added_to_cart",i);if(!u)return;let p={...u,cart_currency:d,product_id:q(r),variant_id:q(o),product_vendor:P(n),product_price:v(c),product_quantity:a,product_sku:P(f)};if(await ye(p,l),g&&s)try{let{updateCartAttributes:_}=await Promise.resolve().then(()=>(vt(),tn));await _(g,{storefrontAccessToken:s})}catch(_){console.error("[ElevateAB] Failed to update cart attributes:",_)}}async function on(e){let t=be(e);if(!t)return;let{productId:r,variantId:o,productVendor:n,productPrice:c,productQuantity:a,productSku:f,currency:d}=e,g=e.hasLocalizedPaths??D?.hasLocalizedPaths,i=e.workerUrl??D?.workerUrl,l=he(t,"product_removed_from_cart",g);if(!l)return;let s={...l,cart_currency:d,product_id:q(r),variant_id:q(o),product_vendor:P(n),product_price:v(c),product_quantity:a,product_sku:P(f)};await ye(s,i)}async function sn(e){let t=be(e);if(!t)return;let{cartTotalPrice:r,cartTotalQuantity:o,cartItems:n,currency:c}=e,a=e.hasLocalizedPaths??D?.hasLocalizedPaths,f=e.workerUrl??D?.workerUrl,d=he(t,"cart_viewed",a);if(!d)return;let g={...d,cart_currency:c,cart_total_price:v(r),cart_total_quantity:o,cart_items:n?.map(i=>({product_id:q(i.productId),variant_id:q(i.variantId),product_vendor:P(i.productVendor)||"",product_price:v(i.productPrice),product_quantity:i.productQuantity??null,product_sku:P(i.productSku)||""}))};await ye(g,f)}async function an(e){let t=be(e);if(!t)return;let{searchQuery:r,currency:o}=e,n=e.hasLocalizedPaths??D?.hasLocalizedPaths,c=e.workerUrl??D?.workerUrl,a=he(t,"search_submitted",n);if(!a)return;let f={...a,cart_currency:o,search_query:P(r)};await ye(f,c)}async function cn(e){let t=be(e);if(!t)return;let{cartTotalPrice:r,cartSubtotalPrice:o,cartShippingPrice:n,cartTaxAmount:c,cartDiscountAmount:a,customerId:f,cartItems:d,currency:g}=e,i=e.hasLocalizedPaths??D?.hasLocalizedPaths,l=e.workerUrl??D?.workerUrl,s=he(t,"checkout_started",i);if(!s)return;let u=0,p=d?.map(x=>{let w=x.productQuantity??0;return u+=w,{product_id:q(x.productId),variant_id:q(x.variantId),product_vendor:P(x.productVendor)||"",vendor:P(x.productVendor)||"",product_price:v(x.productPrice),total_price:v(x.productPrice),product_quantity:w,quantity:w,product_sku:P(x.productSku)||"",sku:P(x.productSku)||"",total_discount:v(x.totalDiscount)}})||[],_={...s,cart_currency:g,cart_total_price:v(r),cart_subtotal_price:v(o),cart_total_quantity:u,cart_shipping_price:v(n),cart_tax_amount:v(c),cart_discount_amount:v(a),cart_items:p,customer_id:f};await ye(_,l)}async function un(e){let t=be(e);if(!t)return;let{orderId:r,cartTotalPrice:o,cartSubtotalPrice:n,cartShippingPrice:c,cartTaxAmount:a,cartDiscountAmount:f,customerId:d,isFirstOrder:g,noteAttributes:i,cartItems:l,currency:s}=e,u=e.hasLocalizedPaths??D?.hasLocalizedPaths,p=e.ordersWorkerUrl??D?.ordersWorkerUrl??$n,_=he(t,"checkout_completed",u);if(!_)return;let x=0,w=l?.map(k=>{let L=k.productQuantity??0;return x+=L,{product_id:q(k.productId),variant_id:q(k.variantId),product_vendor:P(k.productVendor)||"",vendor:P(k.productVendor)||"",product_price:v(k.productPrice),total_price:v(k.productPrice),product_quantity:L,quantity:L,product_sku:P(k.productSku)||"",sku:P(k.productSku)||"",total_discount:v(k.totalDiscount)}})||[],b={..._,cart_currency:s,cart_total_price:v(o),cart_subtotal_price:v(n),cart_total_quantity:x,cart_shipping_price:v(c),cart_tax_amount:v(a),cart_discount_amount:v(f),cart_items:w,order_id:r,customer_id:d,is_first_order:g??null,note_attributes:i};await ye(b,p)}function dn(e){let{storeId:t,hasLocalizedPaths:r,currency:o,workerUrl:n,enabled:c=!0,pathname:a}=e,f=(0,Pe.useRef)(null),[d,g]=(0,Pe.useState)(()=>a||(typeof window<"u"?window.location.pathname:""));(0,Pe.useEffect)(()=>{a&&g(a)},[a]),(0,Pe.useEffect)(()=>{typeof window>"u"||!c||f.current!==d&&(f.current=d,nr({storeId:t,hasLocalizedPaths:r,currency:o,workerUrl:n}))},[d,t,r,o,n,c])}var _e=nt(require("react"),1);var or=nt(require("react"),1),Xe=or.default.createContext(null);function Ct(){let e=or.default.useContext(Xe);if(e===null)throw new Error("useElevateConfig must be used within ElevateProvider");return e}fe();je();var kt=new Map;function ve(e){kt.set(e.type,e)}function Ke(e){return kt.get(e)}function ir(){return Array.from(kt.values())}function sr(e){return kt.has(e)}function Yn(e){try{let o=new URL(e,"https://example.com").pathname.match(/\/products\/([^\/\?]+)/);return o?o[1]:null}catch{return null}}function Qn(e,t,r,o){if(typeof window>"u"||!e.prices||!t)return;let n=e.prices[t];if(!n)return;let c=n.price?.[r],a=n.compare?.[r],f=o;if(f?.selectorsV2?.length)for(let d of f.selectorsV2){if(d.price&&c){let g=d.price.replace("{{variant}}",t);document.querySelectorAll(g).forEach(l=>{let s=new Intl.NumberFormat("en-US",{style:"currency",currency:r}).format(parseFloat(c));l.textContent=s})}if(d.compareAt&&a){let g=d.compareAt.replace("{{variant}}",t);document.querySelectorAll(g).forEach(l=>{let s=new Intl.NumberFormat("en-US",{style:"currency",currency:r}).format(parseFloat(a));l.textContent=s})}if(d.saving&&c&&a)for(let g of d.saving){let i=g.selector.replace("{{variant}}",t);document.querySelectorAll(i).forEach(s=>{let u=parseFloat(c),p=parseFloat(a),_=p-u;if(g.isPercentage){let x=Math.round(_/p*100);s.textContent=`${x}%`}else{let x=new Intl.NumberFormat("en-US",{style:"currency",currency:r}).format(_);s.textContent=x}})}}}var ar={type:"PRICE_PLUS",shouldActivate(e,t){let r=e.data;if(!r)return!1;let{productId:o,productHandle:n}=t,c=n||Yn(t.currentUrl),a=o&&r.productIds?.includes(o),f=c&&r.handles?.includes(c);return a||f},applyEffect(e,t,r){Qn(t,r.variantId,r.currencyCode||"USD",r.selectors)},getVariantData(e,t,r){let o=e.data;return{prices:t.prices,matchedProductId:r.productId,productIds:o?.productIds,handles:o?.handles,handlerActivated:!0}}};function Xn(e,t){let o=e.data?.pathnames||[];if(!o.length)return!0;try{let c=new URL(t,"https://example.com").pathname;return o.some(a=>re(c,a))}catch{return!1}}var Ze={type:"CONTENT",shouldActivate(e,t){return Xn(e,t.currentUrl)},getVariantData(e,t,r){let o=e.data;return{content:t.content,pathnames:o?.pathnames,handlerActivated:!0}}};function Kn(e,t){let o=e.data?.pathnames||[];if(!o.length)return!0;try{let c=new URL(t,"https://example.com").pathname;return o.some(a=>re(c,a))}catch{return!1}}var cr={type:"CUSTOM_CODE",shouldActivate(e,t){return Kn(e,t.currentUrl)},getVariantData(e,t,r){let o=e.data;return{customCode:t.customCode,pathnames:o?.pathnames,excludePathnames:o?.excludePathnames,handlerActivated:!0}}};ve(ar);ve(Wt);ve(Ze);ve(cr);function Zn(e){if(typeof window>"u")return{currentUrl:"",selectors:e};let t=window.location.href,r=window.location.pathname,o,n=r.match(/\/products\/([^\/\?]+)/);n&&(o=n[1]);let c,f=new URLSearchParams(window.location.search).get("variant");return f&&(c=f),{currentUrl:t,productHandle:o,variantId:c,selectors:e,currencyCode:"USD"}}function ln(e){let{config:t,previewState:r,selectors:o}=Ct(),[n,c]=_e.default.useState(null),[a,f]=_e.default.useState(!0),d=_e.default.useMemo(()=>t&&t.tests.find(s=>s.testId===e)||null,[t,e]),g=_e.default.useMemo(()=>r||pe(),[r]),i=_e.default.useRef(null),l=_e.default.useRef(null);return _e.default.useEffect(()=>{let s=!0;if(t===null)return;if(!d){i.current!==e&&(i.current=e,console.warn(`[ElevateAB] Test not found: ${e}`)),s&&f(!1);return}if(!d.enabled&&!g?.isPreview){i.current!==`${e}-disabled`&&(i.current=`${e}-disabled`,console.warn(`[ElevateAB] Test disabled: ${e}`)),s&&f(!1);return}let u=J(e);if(!u){s&&f(!1);return}let p=d.variations.find(b=>b.id===u);if(!p){s&&f(!1);return}let _=Ke(d.type),x=Zn(o),w={...p};if(_?.shouldActivate(d,x)){let b=`${e}-${p.id}`;_.applyEffect&&l.current!==b&&(l.current=b,_.applyEffect(d,p,x));let k=_.getVariantData(d,p,x);w={...w,...k}}return s&&c(w),g?.isPreview||dt(e),s&&f(!1),()=>{s=!1}},[t,d,e,g,o]),{variant:n,isLoading:a,isControl:n?.isControl??!1,isA:n?.isA??!1,isB:n?.isB??!1,isC:n?.isC??!1,isD:n?.isD??!1}}var M=nt(require("react"),1);it();je();fe();function ur(e){return e.tests.some(t=>t.type==="CUSTOM_CODE"&&t.enabled)}function dr(e,t,r){if(typeof window>"u")return;if(console.log("[ElevateAB Custom Code] All tests:",e.tests.map(c=>({id:c.testId,type:c.type,enabled:c.enabled}))),!ur(e)){console.log("[ElevateAB Custom Code] No CUSTOM_CODE tests found");return}let o=e.tests.filter(c=>c.type==="CUSTOM_CODE"&&c.enabled);console.log("[ElevateAB Custom Code] Found",o.length,"CUSTOM_CODE tests");let n=[];o.forEach(c=>{let a=J(c.testId);if(console.log("[ElevateAB Custom Code] Test",c.testId,"assigned variant:",a),!a)return;let f=c.variations.find(d=>d.id===a);if(console.log("[ElevateAB Custom Code] Variation data:",f),!f?.customCode){console.log("[ElevateAB Custom Code] No customCode on variation");return}(f.customCode.js||f.customCode.css)&&(console.log("[ElevateAB Custom Code] Adding custom code:",f.customCode),n.push(f.customCode))}),n.length>0?(console.log("[ElevateAB Custom Code] Applying",n.length,"custom code blocks"),We(n,r)):console.log("[ElevateAB Custom Code] No custom code to apply")}function eo(e,t,r){typeof window>"u"||dr(e,t,r)}function pn(e,t,r){if(typeof window>"u")return()=>{};let o=()=>{eo(e,t,r)};return window.addEventListener("popstate",o),()=>{window.removeEventListener("popstate",o)}}fe();var xt=require("react/jsx-runtime"),to="https://ds0wlyksfn0sb.cloudfront.net/headless";function ro(e){return e.replace(/^https?:\/\//,"").replace(".myshopify.com","")}function fn(e){return`${to}/${ro(e)}.js`}function mn({storeId:e,storefrontAccessToken:t,preventFlickering:r=!1,flickerTimeout:o=3e3,nonce:n,children:c}){let[a,f]=M.default.useState(null),[d,g]=M.default.useState(null),[i,l]=M.default.useState(null);M.default.useEffect(()=>{if(typeof window>"u")return;_t({storeId:e,storefrontAccessToken:t});let w=pe();g(w);let b=ge();l(b)},[e,t]);let s=(0,M.useCallback)(()=>{typeof window<"u"&&window.__eab_reveal&&window.__eab_reveal()},[]);M.default.useEffect(()=>{async function w(){try{let b=typeof window<"u"?pe():null,k=null;if(typeof window<"u"&&window.eab_data)k=window.eab_data;else{let Q=fn(e);k=await new Promise((ne,X)=>{let $=document.createElement("script");$.src=Q,$.async=!0,$.onload=()=>{let m=window.eab_data;$.remove(),m?ne(m):X(new Error("Failed to load config: window.eab_data is undefined"))},$.onerror=()=>{$.remove(),ne({allTests:{},selectors:{selectorsV2:[]}})},document.head.appendChild($)})}if(!k||!k.allTests||Object.keys(k.allTests).length===0){f({tests:[],selectors:void 0}),s();return}if(k.subscriptionPaused){console.error(`[ElevateAB] Subscription is paused or stopped for store: ${e}. `+(k.subscriptionMessage||"A/B tests will not run. Please reactivate your subscription.")),f({tests:[],selectors:void 0}),s();return}if(!(Object.keys(k.allTests||{}).length>0)){f({tests:[],selectors:void 0}),s();return}let F=Cr(k);if(ut(F,b),F.tests.some(Q=>Q.type==="SPLIT_URL")&&Fe(F,b))return;f(F),s()}catch(b){console.error("[ElevateAB] Failed to load config:",b),f({tests:[],selectors:void 0}),s()}}w()},[e,s]),M.default.useEffect(()=>!a||typeof window>"u"||!Ge(a)?void 0:(Je(a,d,n),ht(a,d,n)),[a,d,n]),M.default.useEffect(()=>!a||typeof window>"u"||!ur(a)?void 0:(dr(a,d,n),pn(a,d,n)),[a,d,n]);let u=M.default.useMemo(()=>({config:a,storeId:e,storefrontAccessToken:t,isPreviewMode:d?.isPreview??!1,previewTestId:d?.previewTestId??null,previewState:d,selectors:a?.selectors,countryCode:i}),[a,e,t,d,i]),p=(0,M.useRef)(!1);M.default.useEffect(()=>{!t&&!p.current&&(p.current=!0,console.warn("[ElevateAB] No storefrontAccessToken provided. Orders won't be attributed to test variants."))},[t]);let _=M.default.useMemo(()=>fn(e),[e]),x=M.default.useMemo(()=>lt({configUrl:_,timeout:r?o:2e3}),[_,r,o]);return(0,xt.jsxs)(Xe.Provider,{value:u,children:[(0,xt.jsx)("script",{nonce:n,dangerouslySetInnerHTML:{__html:x}}),c]})}var Ee=require("react");Y();Y();vt();var no="https://bitter-river-9c62.support-67d.workers.dev",oo="https://d339co84ntxcme.cloudfront.net/Prod/orders";function Ce(){return`sh-${le()}`}function io(e){return Object.entries(e).filter(([,t])=>typeof t=="string").map(([t,r])=>({test_id:t,variant_id:r}))}function so(e,t){return Object.entries(e).filter(([r])=>typeof t[r]=="string").map(([r])=>({test_id:r,variant_id:t[r]}))}function gn({storeId:e,storefrontAccessToken:t,hasLocalizedPaths:r,workerUrl:o=no,ordersWorkerUrl:n=oo,useAnalytics:c}){let a=(0,Ee.useContext)(Xe),f=e||a?.storeId||"",d=t||a?.storefrontAccessToken,g=(0,Ee.useRef)(!1);(0,Ee.useEffect)(()=>{!a&&!e&&!g.current&&(g.current=!0,console.error("[ElevateAB] ElevateAnalytics must be used inside ElevateProvider, or you must pass storeId as a prop."))},[a,e]);let{subscribe:i,register:l}=c(),{ready:s}=l("Elevate Analytics");return(0,Ee.useEffect)(()=>{if(typeof window>"u")return;if(ce(),Te(),typeof document<"u"){let p=document.referrer||"",_=window.location.href;st(p,_)}(()=>{let p=m=>{let h=te(m.products?.[0]?.id);h&&typeof localStorage<"u"?localStorage.setItem("eabProductPageId",h):typeof window<"u"&&!window.location.pathname.includes("/products/")&&localStorage?.removeItem("eabProductPageId");let S=Ue(typeof localStorage<"u"?localStorage.getItem("shopifyCartId"):null),{referrer:R,entryPage:O}=Ie();return{visitorId:ce(),sessionId:Te(),cartToken:S||V("cart")||"",referrer:R,entryPage:O,clientId:V("_shopify_y"),rootRoute:typeof localStorage<"u"&&localStorage.getItem("eabRootRoute")||"",productPageId:typeof localStorage<"u"&&localStorage.getItem("eabProductPageId")||""}},_=(m,h,S,R)=>{let O=typeof navigator<"u"?navigator.userAgent:"",z=S?.url?new URL(S.url).pathname:typeof window<"u"?window.location.pathname:"",W=Ve(z,r),I=Oe({referrer:R.referrer,entryPage:R.entryPage,userAgent:O}),B=N("ABTL")||{},G=N("ABAU")||{},ke=io(B),oe=so(G,B),ie=new Date().toISOString(),de=typeof sessionStorage<"u"?sessionStorage.getItem("eabIsFirstVisit")==="true":!1,xe=V("localization")||"";return{pixel_event_id:h,shop_name:f,timestamp:ie,event_type:m,client_id:R.clientId,visitor_id:R.visitorId,session_id:R.sessionId,cart_token:Re(R.cartToken),page_url:S.context?.document?.location?.href||(typeof window<"u"?window.location.href:""),page_pathname:z,page_search:S.context?.document?.location?.search||(typeof window<"u"?window.location.search:""),referrer_url:R.referrer,referrer_source:I?.referrer_source,previous_page:typeof document<"u"?document.referrer:"",page_entry:R.entryPage,page_entry_path:I?.page_entry_path,page_type:W,utm_medium:I?.utm_medium,utm_source:I?.utm_source,utm_campaign:I?.utm_campaign,utm_content:I?.utm_content,utm_term:I?.utm_term,gclid:I?.gclid,fbclid:I?.fbclid,pins_campaign_id:I?.pins_campaign_id,epik:I?.epik,browser_info:I?.browser_info,os_info:I?.os_info,device_type:I?.device_type,language:S.context?.navigator?.language||(typeof navigator<"u"?navigator.language:""),root_route:R.rootRoute,user_agent:O,user_agent_no_browser:Le(O),is_first_visit:de,shopify_country:xe,cart_currency:S.shop?.currency,ab_test_assignments:ke,ab_test_views:oe,is_first_order:null}},x=async m=>{if(!m.exclude)try{let h=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m),keepalive:!0});if(!h.ok)throw new Error(`Worker error: ${h.status}`);return h}catch(h){console.error("[ElevateAB] Error sending analytics:",h)}},w=async m=>{try{let h=p(m),S=Ce(),R=_("page_viewed",S,m,h);await x(R)}catch(h){console.error("[ElevateAB] Error handling page_viewed:",h)}},b=async m=>{try{let h=p(m),S=Ce(),O={..._("product_viewed",S,m,h),product_id:te(m?.products?.[0]?.id)||"",product_vendor:P(m?.products?.[0]?.vendor)??"",product_price:v(m?.products?.[0]?.price)??null,product_sku:P(m?.products?.[0]?.sku)??""};await x(O)}catch(h){console.error("[ElevateAB] Error handling product_viewed:",h)}},k=async m=>{try{let h=p(m),S=Ce(),O={..._("product_added_to_cart",S,m,h),product_id:te(m?.currentLine?.merchandise?.product?.id)??"",variant_id:we(m?.currentLine?.merchandise?.id)??"",product_vendor:P(m?.currentLine?.merchandise?.product?.vendor)??"",product_price:v(m?.currentLine?.cost?.totalAmount?.amount)??null,product_quantity:m?.currentLine?.quantity??null,product_sku:P(m?.currentLine?.merchandise?.sku)??""};await x(O);let z=m?.cart?.id;z&&d&&f&&Qe(z,{storefrontAccessToken:d,storefrontApiUrl:`https://${f}/api/2025-01/graphql.json`}).catch(W=>{console.error("[ElevateAB] Failed to update cart attributes:",W)})}catch(h){console.error("[ElevateAB] Error handling product_added_to_cart:",h)}},L=async m=>{try{let h=p(m),S=Ce(),O={..._("product_removed_from_cart",S,m,h),product_id:te(m?.prevLine?.merchandise?.product?.id)??"",variant_id:we(m?.prevLine?.merchandise?.id)??"",product_vendor:P(m?.prevLine?.merchandise?.product?.vendor)??"",product_price:v(m?.prevLine?.cost?.totalAmount?.amount)??null,product_quantity:m?.prevLine?.quantity??null,product_sku:P(m?.prevLine?.merchandise?.sku)??""};await x(O)}catch(h){console.error("[ElevateAB] Error handling product_removed_from_cart:",h)}},F=async m=>{try{let h=p(m),S=Ce(),R=_("cart_viewed",S,m,h),z=(m?.data?.cart?.lines?.nodes||m?.data?.cart?.lines||[]).map(I=>({product_id:te(I?.merchandise?.product?.id)??"",variant_id:we(I?.merchandise?.id)??"",vendor:P(I?.merchandise?.product?.vendor)??"",total_price:v(I?.cost?.totalAmount?.amount)??null,quantity:I?.quantity??null,sku:P(I?.merchandise?.sku)??""})),W={...R,cart_total_price:v(m?.cart?.cost?.totalAmount?.amount)??null,cart_total_quantity:m?.cart?.totalQuantity??null,cart_items:z};await x(W)}catch(h){console.error("[ElevateAB] Error handling cart_viewed:",h)}},Q=async m=>{try{let h=p(m),S=Ce(),O={..._("search_submitted",S,m,h),search_query:P(m?.data?.searchResult?.query)??""};await x(O)}catch(h){console.error("[ElevateAB] Error handling search_submitted:",h)}},ne=async m=>{try{let h=p(m),S=Ce(),R=_("checkout_started",S,m,h),O=0,W=(m?.data?.checkout?.lineItems??[]).map(B=>{let G=B?.quantity??0;O+=G;let oe=(B?.discountAllocations??[])?.reduce((ie,de)=>ie+(de?.amount?.amount||0),0);return{product_id:te(B?.variant?.product?.id)??"",variant_id:we(B?.variant?.id)??"",vendor:P(B?.variant?.product?.vendor)??"",total_price:v(B?.finalLinePrice?.amount)??null,quantity:G,sku:P(B?.variant?.sku)??"",total_discount:v(oe)??null}}),I={...R,cart_total_price:v(m?.data?.checkout?.totalPrice?.amount)??null,cart_subtotal_price:v(m?.data?.checkout?.subtotalPrice?.amount)??null,cart_total_quantity:O,cart_shipping_price:v(m?.data?.checkout?.shippingLine?.price?.amount)??null,cart_tax_amount:v(m?.data?.checkout?.totalTax?.amount)??null,cart_discount_amount:v(m?.data?.checkout?.discountsAmount?.amount)??null,cart_items:W,customer_id:m?.data?.checkout?.order?.customer?.id??""};await x(I)}catch(h){console.error("[ElevateAB] Error handling checkout_started:",h)}},X=async m=>{try{let h=p(m),S=Ce(),R=_("checkout_completed",S,m,h),O=0,W=(m?.data?.checkout?.lineItems??[]).map(B=>{let G=B?.quantity??0;O+=G;let oe=(B?.discountAllocations??[])?.reduce((ie,de)=>ie+(de?.amount?.amount||0),0);return{product_id:te(B?.variant?.product?.id)??"",variant_id:we(B?.variant?.id)??"",vendor:P(B?.variant?.product?.vendor)??"",total_price:v(B?.finalLinePrice?.amount)??null,quantity:G,sku:P(B?.variant?.sku)??"",total_discount:v(oe)??null}}),I={...R,cart_total_price:v(m?.data?.checkout?.totalPrice?.amount)??null,cart_subtotal_price:v(m?.data?.checkout?.subtotalPrice?.amount)??null,cart_total_quantity:O,cart_shipping_price:v(m?.data?.checkout?.shippingLine?.price?.amount)??null,cart_tax_amount:v(m?.data?.checkout?.totalTax?.amount)??null,cart_discount_amount:v(m?.data?.checkout?.discountsAmount?.amount)??null,cart_items:W,order_id:m?.data?.checkout?.order?.id??"",customer_id:m?.data?.checkout?.order?.customer?.id??"",is_first_order:m?.data?.checkout?.order?.customer?.isFirstOrder??null,note_attributes:m?.data?.checkout?.attributes??[]};await $(I)}catch(h){console.error("[ElevateAB] Error handling checkout_completed:",h)}},$=async m=>{if(!m.exclude)try{let h=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m),keepalive:!0});if(!h.ok)throw new Error(`Orders worker error: ${h.status}`);return h}catch(h){console.error("[ElevateAB] Error sending order analytics:",h)}};i("page_viewed",w),i("product_viewed",b),i("product_added_to_cart",k),i("product_removed_from_cart",L),i("cart_viewed",F),i("search_submitted",Q),i("checkout_started",ne),i("checkout_completed",X)})(),s()},[i,s,f,r,d,o,n]),null}var ao="1.1.2";0&&(module.exports={CART_ATTRIBUTES_UPDATE_MUTATION,COUNTRIES,ElevateAnalytics,ElevateProvider,REGIONS,VERSION,applyContentChanges,applyContentElements,applyCustomCode,assignAllTests,assignAndPersistVariant,buildEabTestsParam,canAssignToTest,checkFacebookBrowser,checkFacebookInstagramBrowser,checkInstagramBrowser,checkPinterestBrowser,checkTikTokBrowser,checkVisitorIdParams,cleanCartToken,cleanupCartAttributes,cleanupContentTests,clearPreviewMode,contentHandler,deleteCookie,detectShopifyCurrency,extractCartToken,extractProductId,extractProductVariantId,extractShopifyId,extractShopifyType,getAllHandlers,getAssignedVariant,getCartAttributesPayload,getCookie,getCountryCode,getDeviceType,getGeoLocation,getHandler,getJsonCookie,getJsonSessionItem,getPageTypeFromPathname,getPreviewState,getPreviewVariation,getReferrerData,getSessionId,getSessionItem,getSplitUrlBlockingScript,getTestList,getTrafficSource,getUserAgentNoBrowser,getVisitorId,hasContentTests,hasHandler,hasSessionView,hasUniqueView,hashString,initAnalytics,initializeSessionId,initializeVisitorId,isCountryExcluded,isCountryIncluded,isInPreviewMode,isPreviewTest,isShopifyGid,matchesGeoTargeting,matchesWildcardPattern,parseAddViewData,processContentTests,processSplitUrlTests,registerHandler,reprocessContentTests,restoreOriginalElements,roundToTwo,sanitizeString,saveTestList,setCookie,setCountryCode,setGeoLocation,setReferrerData,setSessionItem,setupContentTestListeners,shouldShowTest,trackAddToCart,trackCartView,trackCheckoutCompleted,trackCheckoutStarted,trackPageView,trackProductView,trackRemoveFromCart,trackSearchSubmitted,trackSessionView,trackUniqueView,trackViews,updateCartAttributes,updateUrlWithTestParams,useElevateConfig,useExperiment,usePageViewTracking,uuidv4});
|
|
46
46
|
//# sourceMappingURL=index.cjs.map
|