@zonos/elements 1.3.206 → 1.3.207
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/cjs/index.cjs.js +7 -7
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +93 -45
- package/dist/cjs/zonos-elements.cjs.js +1 -1
- package/dist/cjs/zonos-hello.cjs.entry.js +10 -1
- package/dist/collection/components/common/zonos-virtual-scroll/zonos-virtual-scroll.css +9 -2
- package/dist/collection/components/common/zonos-virtual-scroll/zonos-virtual-scroll.js +129 -59
- package/dist/collection/components/hello/zonos-hello/zonos-hello.js +10 -1
- package/dist/collection/types/common-ui/VirtualScroll.js +1 -0
- package/dist/collection/types/generated/graphql.internal.types.js +6 -0
- package/dist/esm/index.js +7 -7
- package/dist/esm/loader.js +1 -1
- package/dist/esm/zonos-country-select_4.entry.js +93 -45
- package/dist/esm/zonos-elements.js +1 -1
- package/dist/esm/zonos-hello.entry.js +10 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-elements.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/scripts/index.d.ts +30 -28
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/common/zonos-virtual-scroll/zonos-virtual-scroll.d.ts +49 -12
- package/dist/types/components/hello/zonos-hello/zonos-hello.d.ts +2 -0
- package/dist/types/components/utils/api/getLocaleMessages.d.ts +1 -1
- package/dist/types/components.d.ts +30 -28
- package/dist/types/types/common-ui/VirtualScroll.d.ts +1 -0
- package/dist/types/types/generated/graphql.frontend.types.d.ts +1 -1
- package/dist/types/types/generated/graphql.frontend.types.ts +1 -1
- package/dist/types/types/generated/graphql.internal.types.d.ts +7 -0
- package/dist/types/types/generated/graphql.internal.types.ts +9 -0
- package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-d5f7f7e6.system.js → p-0de2c731.system.js} +1 -1
- package/dist/zonos-elements/{p-f8bfc320.system.entry.js → p-1aa24297.system.entry.js} +1 -1
- package/dist/zonos-elements/p-3ee44728.system.js +1 -1
- package/dist/zonos-elements/p-536f69eb.entry.js +1 -0
- package/dist/zonos-elements/p-620deb03.system.entry.js +1 -0
- package/dist/zonos-elements/p-9f78b79e.entry.js +1 -0
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-051e0e48.entry.js +0 -1
- package/dist/zonos-elements/p-3505e4c4.entry.js +0 -1
- package/dist/zonos-elements/p-ea88baa9.system.entry.js +0 -1
|
@@ -4,7 +4,7 @@ export declare const getLocaleMessages: ({ countryCode, localeTo, storeId, }: {
|
|
|
4
4
|
localeTo?: string;
|
|
5
5
|
storeId: number;
|
|
6
6
|
}) => Promise<{
|
|
7
|
-
countryCodes: Array<string
|
|
7
|
+
countryCodes: Array<string> | null;
|
|
8
8
|
countryCodesPageMessageLinks: Array<{
|
|
9
9
|
id: number;
|
|
10
10
|
message: {
|
|
@@ -29,6 +29,7 @@ import { SpinnerColor } from "./components/common/zonos-spinner/zonos-spinner";
|
|
|
29
29
|
import { GenericZonosSettings } from "./types/utils/ZonosSettings";
|
|
30
30
|
import { ToggleItem } from "./types/common-ui/Toggle";
|
|
31
31
|
import { GridSpacing } from "./types/styles/GridSpacing";
|
|
32
|
+
import { VirtualScrollRenderItem } from "./types/common-ui/VirtualScroll";
|
|
32
33
|
export { ContactOption, PaymentIntent, Stripe, StripeAddressElementChangeEvent } from "@stripe/stripe-js";
|
|
33
34
|
export { EnteredInfo, TranslatedAddressObject } from "./types/checkout/TranslatedText";
|
|
34
35
|
export { EventPayloadMap, IframeSuggestionsResponsePayload } from "./components/utils/iframe/IframeHelpers";
|
|
@@ -53,6 +54,7 @@ export { SpinnerColor } from "./components/common/zonos-spinner/zonos-spinner";
|
|
|
53
54
|
export { GenericZonosSettings } from "./types/utils/ZonosSettings";
|
|
54
55
|
export { ToggleItem } from "./types/common-ui/Toggle";
|
|
55
56
|
export { GridSpacing } from "./types/styles/GridSpacing";
|
|
57
|
+
export { VirtualScrollRenderItem } from "./types/common-ui/VirtualScroll";
|
|
56
58
|
export namespace Components {
|
|
57
59
|
interface ZonosAddress {
|
|
58
60
|
/**
|
|
@@ -1262,34 +1264,33 @@ export namespace Components {
|
|
|
1262
1264
|
"spacing": GridSpacing;
|
|
1263
1265
|
}
|
|
1264
1266
|
/**
|
|
1265
|
-
*
|
|
1267
|
+
* Virtual scroll component for efficiently rendering large lists
|
|
1268
|
+
* The idea is from:
|
|
1266
1269
|
* @ref https://github.com/beenotung/stencil-virtual-scroll/blob/master/src/components/virtual-scroll-list/virtual-scroll-list.scss
|
|
1267
1270
|
* @ref https://github.dev/ionic-team/ionic-framework/blob/v6.7.5/core/src/components/virtual-scroll/virtual-scroll.tsx
|
|
1268
1271
|
*/
|
|
1269
1272
|
interface ZonosVirtualScroll {
|
|
1270
1273
|
/**
|
|
1271
|
-
*
|
|
1274
|
+
* Buffer size in pixels for pre-rendering items outside viewport
|
|
1275
|
+
* @default 100
|
|
1276
|
+
*/
|
|
1277
|
+
"buffer": number;
|
|
1278
|
+
/**
|
|
1279
|
+
* Fallback height used when specific item height is not provided
|
|
1272
1280
|
*/
|
|
1273
1281
|
"fallbackItemHeight": number;
|
|
1274
1282
|
/**
|
|
1275
|
-
*
|
|
1283
|
+
* Array of heights for each item in pixels
|
|
1276
1284
|
*/
|
|
1277
1285
|
"itemHeights": number[];
|
|
1278
1286
|
/**
|
|
1279
|
-
* Width of each item
|
|
1287
|
+
* Width of each item in pixels
|
|
1280
1288
|
*/
|
|
1281
1289
|
"itemWidth"?: number;
|
|
1282
1290
|
/**
|
|
1283
|
-
*
|
|
1291
|
+
* Function to render each item in the virtual scroll
|
|
1284
1292
|
*/
|
|
1285
|
-
"renderItem":
|
|
1286
|
-
itemIndex: number,
|
|
1287
|
-
) =>
|
|
1288
|
-
| HTMLElement
|
|
1289
|
-
| Promise<HTMLElement>
|
|
1290
|
-
| HTMLElement[]
|
|
1291
|
-
| Promise<HTMLElement[]>
|
|
1292
|
-
| Promise<HTMLElement>[];
|
|
1293
|
+
"renderItem": VirtualScrollRenderItem;
|
|
1293
1294
|
}
|
|
1294
1295
|
}
|
|
1295
1296
|
export interface ZonosAddressCustomEvent<T> extends CustomEvent<T> {
|
|
@@ -1990,7 +1991,8 @@ declare global {
|
|
|
1990
1991
|
new (): HTMLZonosVStackElement;
|
|
1991
1992
|
};
|
|
1992
1993
|
/**
|
|
1993
|
-
*
|
|
1994
|
+
* Virtual scroll component for efficiently rendering large lists
|
|
1995
|
+
* The idea is from:
|
|
1994
1996
|
* @ref https://github.com/beenotung/stencil-virtual-scroll/blob/master/src/components/virtual-scroll-list/virtual-scroll-list.scss
|
|
1995
1997
|
* @ref https://github.dev/ionic-team/ionic-framework/blob/v6.7.5/core/src/components/virtual-scroll/virtual-scroll.tsx
|
|
1996
1998
|
*/
|
|
@@ -3317,34 +3319,33 @@ declare namespace LocalJSX {
|
|
|
3317
3319
|
"spacing"?: GridSpacing;
|
|
3318
3320
|
}
|
|
3319
3321
|
/**
|
|
3320
|
-
*
|
|
3322
|
+
* Virtual scroll component for efficiently rendering large lists
|
|
3323
|
+
* The idea is from:
|
|
3321
3324
|
* @ref https://github.com/beenotung/stencil-virtual-scroll/blob/master/src/components/virtual-scroll-list/virtual-scroll-list.scss
|
|
3322
3325
|
* @ref https://github.dev/ionic-team/ionic-framework/blob/v6.7.5/core/src/components/virtual-scroll/virtual-scroll.tsx
|
|
3323
3326
|
*/
|
|
3324
3327
|
interface ZonosVirtualScroll {
|
|
3325
3328
|
/**
|
|
3326
|
-
*
|
|
3329
|
+
* Buffer size in pixels for pre-rendering items outside viewport
|
|
3330
|
+
* @default 100
|
|
3331
|
+
*/
|
|
3332
|
+
"buffer"?: number;
|
|
3333
|
+
/**
|
|
3334
|
+
* Fallback height used when specific item height is not provided
|
|
3327
3335
|
*/
|
|
3328
3336
|
"fallbackItemHeight": number;
|
|
3329
3337
|
/**
|
|
3330
|
-
*
|
|
3338
|
+
* Array of heights for each item in pixels
|
|
3331
3339
|
*/
|
|
3332
3340
|
"itemHeights": number[];
|
|
3333
3341
|
/**
|
|
3334
|
-
* Width of each item
|
|
3342
|
+
* Width of each item in pixels
|
|
3335
3343
|
*/
|
|
3336
3344
|
"itemWidth"?: number;
|
|
3337
3345
|
/**
|
|
3338
|
-
*
|
|
3346
|
+
* Function to render each item in the virtual scroll
|
|
3339
3347
|
*/
|
|
3340
|
-
"renderItem":
|
|
3341
|
-
itemIndex: number,
|
|
3342
|
-
) =>
|
|
3343
|
-
| HTMLElement
|
|
3344
|
-
| Promise<HTMLElement>
|
|
3345
|
-
| HTMLElement[]
|
|
3346
|
-
| Promise<HTMLElement[]>
|
|
3347
|
-
| Promise<HTMLElement>[];
|
|
3348
|
+
"renderItem": VirtualScrollRenderItem;
|
|
3348
3349
|
}
|
|
3349
3350
|
interface IntrinsicElements {
|
|
3350
3351
|
"zonos-address": ZonosAddress;
|
|
@@ -3470,7 +3471,8 @@ declare module "@stencil/core" {
|
|
|
3470
3471
|
"zonos-tooltip": LocalJSX.ZonosTooltip & JSXBase.HTMLAttributes<HTMLZonosTooltipElement>;
|
|
3471
3472
|
"zonos-v-stack": LocalJSX.ZonosVStack & JSXBase.HTMLAttributes<HTMLZonosVStackElement>;
|
|
3472
3473
|
/**
|
|
3473
|
-
*
|
|
3474
|
+
* Virtual scroll component for efficiently rendering large lists
|
|
3475
|
+
* The idea is from:
|
|
3474
3476
|
* @ref https://github.com/beenotung/stencil-virtual-scroll/blob/master/src/components/virtual-scroll-list/virtual-scroll-list.scss
|
|
3475
3477
|
* @ref https://github.dev/ionic-team/ionic-framework/blob/v6.7.5/core/src/components/virtual-scroll/virtual-scroll.tsx
|
|
3476
3478
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type VirtualScrollRenderItem = (itemIndex: number) => HTMLElement | Promise<HTMLElement> | HTMLElement[] | Promise<HTMLElement[]> | Promise<HTMLElement>[];
|
|
@@ -715,7 +715,7 @@ export type FailToGetQuoteErrorsQuery = {
|
|
|
715
715
|
};
|
|
716
716
|
export type LocaleCountryMessagesQuery = {
|
|
717
717
|
locale_countryCodesPage: Array<{
|
|
718
|
-
countryCodes: Array<string
|
|
718
|
+
countryCodes: Array<string> | null;
|
|
719
719
|
countryCodesPageMessageLinks: Array<{
|
|
720
720
|
id: number;
|
|
721
721
|
message: {
|
|
@@ -672,7 +672,7 @@ export type FailToGetQuoteErrorsQuery = {
|
|
|
672
672
|
|
|
673
673
|
export type LocaleCountryMessagesQuery = {
|
|
674
674
|
locale_countryCodesPage: Array<{
|
|
675
|
-
countryCodes: Array<string
|
|
675
|
+
countryCodes: Array<string> | null;
|
|
676
676
|
countryCodesPageMessageLinks: Array<{
|
|
677
677
|
id: number;
|
|
678
678
|
message: {
|
|
@@ -3134,6 +3134,13 @@ export declare const usageRecordTypeCode: {
|
|
|
3134
3134
|
readonly OrderTransactionInvoicing: "ORDER_TRANSACTION_INVOICING";
|
|
3135
3135
|
};
|
|
3136
3136
|
export type UsageRecordTypeCode = (typeof usageRecordTypeCode)[keyof typeof usageRecordTypeCode];
|
|
3137
|
+
export declare const userAccessLevel: {
|
|
3138
|
+
readonly Admin: "ADMIN";
|
|
3139
|
+
readonly Custom: "CUSTOM";
|
|
3140
|
+
readonly Member: "MEMBER";
|
|
3141
|
+
readonly None: "NONE";
|
|
3142
|
+
};
|
|
3143
|
+
export type UserAccessLevel = (typeof userAccessLevel)[keyof typeof userAccessLevel];
|
|
3137
3144
|
export declare const visibilityCode: {
|
|
3138
3145
|
readonly Hide: "HIDE";
|
|
3139
3146
|
readonly Optional: "OPTIONAL";
|
|
@@ -3859,6 +3859,15 @@ export const usageRecordTypeCode = {
|
|
|
3859
3859
|
|
|
3860
3860
|
export type UsageRecordTypeCode =
|
|
3861
3861
|
(typeof usageRecordTypeCode)[keyof typeof usageRecordTypeCode];
|
|
3862
|
+
export const userAccessLevel = {
|
|
3863
|
+
Admin: 'ADMIN',
|
|
3864
|
+
Custom: 'CUSTOM',
|
|
3865
|
+
Member: 'MEMBER',
|
|
3866
|
+
None: 'NONE',
|
|
3867
|
+
} as const;
|
|
3868
|
+
|
|
3869
|
+
export type UserAccessLevel =
|
|
3870
|
+
(typeof userAccessLevel)[keyof typeof userAccessLevel];
|
|
3862
3871
|
|
|
3863
3872
|
export const visibilityCode = {
|
|
3864
3873
|
Hide: 'HIDE',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg color="var(--zonos-elements-
|
|
1
|
+
<svg color="var(--zonos-elements-red-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--zonos-elements-red-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as n}from"./p-595f5dd2.js";import{g as o,I as t}from"./p-e7b0c156.js";import{g as r,a as i,l,h as u,b as m}from"./p-0fc02cde.js";import{_ as p,c as w,a as f}from"./p-3f1a2d31.js";export{c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector,d as domesticRedirectedBtnSelector}from"./p-3f1a2d31.js";export{a as availableTestKeys}from"./p-04a01cb1.js";export{c as countryRequireTaxId,e as euCountryCodes,s as shipToTaxIdLabels}from"./p-6b361d2b.js";const h=["jsdelivr","cdnjs","unpkg","vercel"],y="jsdelivr",v=e=>{const n=h.indexOf(e);return h[n+1]||null},g=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const n=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),o="https://v1.3.206.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-")))return o;if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";const t=`https://${n}.preview.js.zonos.com`;return l(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),t},S="https://js.stripe.com/v3",z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,j="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let O=null;const b=Promise.resolve().then((()=>{return e=null,null!==O||(O=new Promise(((n,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(j),window.Stripe)n(window.Stripe);else try{let t=(()=>{const e=document.querySelectorAll(`script[src^="${S}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&z.test(o.src))return o}return null})();t&&e?console.warn(j):t||(t=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${S}${n}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(m("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==t||t.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):o(new Error("Stripe.js not available"))})),null==t||t.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else n(null)}))),O;var e}));let k=!1;b.catch((e=>{k||console.warn(e)}));const $=async({cartId:e,retries:n})=>{const t=r(),s=o(),i=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:c,json:d,zonosMode:a}=await u(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),m=!d||c.length;return m&&n?(l("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise((e=>setTimeout(e,500))),$({cartId:e,retries:n-1})):m?null:Object.assign(Object.assign({},d),{zonosMode:a})};var I;const Z=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),L="https://v1.3.206.js.zonos.com",N=Z||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.206",U="https://fonts.googleapis.com",R=/^https:\/\/fonts\.googleapis\.com/;class T{}I=T,T.doneInit=!1,T.cartSettings=null,T.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),T.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),T._paypalMockResponse=null,T.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,T.isBigCommerce=!1,T.releaseDate="1748443962388",T.isLegacyCheckout=!1,T.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",T.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),T.overrideUseCustomAddressForm=!1,T.isNpm=!0,T.zonosQaUrl=null,T.zonosQaUrlApi=null,T.trackEventLogs=[],T.version="v1.3.206",T.modeAlerted=!1,T.cartData=null,T.paypal=null,T.zonosMode=null,T.IframeService=t,T.getCurrentTimestamp=()=>(new Date).getTime(),T.zonosController=null,T.loadTimeApiInfoList=[],T.logIntervalId=null,T.init=async e=>{const{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d,storeId:a,zonosApiKey:f}=e;if(I.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),I.doneInit)return;if(l(`====== ZONOS DEBUG MODE: on (${I.version}) ======`),I.zonosApiKey=f,I.storeId=a,I.isNpm){l("====== ZONOS LOADING FROM NPM ======");const n=g();if(n&&!window.isZonosPreview){l(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${n} ======`,"info");const o=document.createElement("script");return o.src=`${n}/dist/scripts/zonos.js`,document.head.appendChild(o),o.addEventListener("load",(()=>{window.Zonos.isNpm=I.isNpm,window.Zonos.isBigCommerce=I.isBigCommerce,window.Zonos.isLegacyCheckout=I.isLegacyCheckout,window.Zonos.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${n}`)})),void(window.isZonosPreview=!0)}if(!f&&!I.cartId)return void m("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!I.cartData&&I.cartId){l("Initialize cart data");const e=await(async e=>{const{isDgsCartId:n,isLegacyCartId:o}=p(e);if(!o&&!n)return m("[ZONOS - loadZonos] invalid cart id"),null;const t=await $({cartId:e,retries:5});return l("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(m("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(I.cartId);if(!e)return void m("Failed to get cart data");I.cartData=e.cartData,I.zonosApiKey=e.zonosApiKey,I.cartSettings=e.settings}const o=await(async()=>{const e=r(),n=i();if(!e&&!n||!window.Zonos.zonosApiKey)return null;if(l("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return l("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:o,json:t}=await u("/api/get-test-public-credential");if(o.length||!t)return m("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),null;const s=t.publicCredential;return s?(l(`[ZONOS - loadZonos] Retrieve new test public token ${s}`,"info"),s):(m("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();o&&(I.zonosApiKey=o)}const h=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(I.cartId&&I.cartData||h){l("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id=`${w}`,document.body.appendChild(e)}l("init zonos"),I.restoreNativeBrowserFunctions(),I.injectCustomScriptForHostedCheckout(),I.injectZonosCdn(),I.injectZonosCss(),I.injectFonts(),I.injectCheckoutInternationalButton(),I.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d}}),I.doneInit=!0},T.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${f}`)){const e=document.createElement("button");e.id=f,e.style.display="none",document.body.appendChild(e)}},T.injectCustomScriptForHostedCheckout=()=>{const e=I.cartData,n=(null==e?void 0:e.metadata)||[],o=n.find((e=>"customHeaderScript"===e.key)),t=n.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||t)){if(o){l("Injecting custom header script");const e=document.createElement("script");e.textContent=o.value,document.head.appendChild(e)}if(t){l("Injecting custom footer script");const e=document.createElement("script");e.textContent=t.value,document.body.appendChild(e)}}else l("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},T.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},T.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${f}`);setTimeout((()=>{e&&e.dispatchEvent(n("click"))}),10)},T.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},T.showNotification=e=>{var n;null===(n=I.zonosController)||void 0===n||n.showNotification(e)},T.updateOrganizationName=e=>{var n;null===(n=I.zonosController)||void 0===n||n.updateOrganizationName(e)},T.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:o,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const n=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&o&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},T.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const n="zonos---native-browser";let o=document.querySelector(`iframe#${n}`);o||(o=document.createElement("iframe"),o.id=n,o.style.display="none",o.style.opacity="0",o.style.position="absolute",o.style.top="-9999px",o.style.left="-9999px",o.style.width="1px",o.style.height="1px",o.style.border="none",o.style.overflow="hidden",o.style.visibility="hidden",document.body.appendChild(o));const t=(null===(e=o.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=t,document.body.removeChild(o)},T.injectController=({config:e})=>{var n,o;if(document.querySelector("zonos-controller"))return;if(null===(n=e.checkoutSettings)||void 0===n?void 0:n.placeOrderButtonSelector){const n=e.checkoutSettings.placeOrderButtonSelector;I.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{I.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const n=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;I.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{I.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}const t=document.createElement("zonos-controller");t.config=e,t.zonosApiKey=I.zonosApiKey||"",t.addEventListener("stripeInitEvent",(async e=>{const{detail:n}=e;l("loading Stripe");const o=await(async(...e)=>{k=!0;const n=Date.now();return b.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(n.publishableKey);o?(window.Zonos.stripe=o,t.initCheckoutElement(o)):m("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(t),I.zonosController=t,l("Zonos controller injected!")},T.injectScript=({cdnType:e,isModule:n,theRestUrl:o})=>{const t=`${I.getZonosUrl(e)}/${o}`;if(document.querySelector(`script[src="${t}"]`))return void l(`Zonos script "${t}" already exists in the document`,"warn");const s=document.head||document.body,r=document.createElement("script");n?r.type="module":r.noModule=!0,r.src=t,r.crossOrigin="anonymous",r.onerror=()=>{m(`Failed to load ${r.src}`);const t=v(e);t&&I.injectScript({cdnType:t,isModule:n,theRestUrl:o})},s.appendChild(r)},T.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return N;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.206";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.206";case"vercel":return L}};return I.isNpm&&g()||n()},T.injectZonosCdn=()=>{I.injectScript({cdnType:y,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),I.injectScript({cdnType:y,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),l("Zonos cdn script injected!")},T.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const o=I.getZonosUrl(e),t=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${L}/`,t.appendChild(s);const r=document.createElement("link");r.rel="stylesheet",r.href=`${o}/${n}`,r.onerror=()=>{m(`Failed to load ${r.href}`);const o=v(e);o&&I.injectStylesheet({cdnType:o,theRestUrl:n})},t.appendChild(r)},T.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?l("Zonos style links already injected","warn"):(I.injectStylesheet({cdnType:y,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),l("Zonos style css injected!"))},T.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void l("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${U}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!R.test(o.href))return o}return null})())return void l("Inter font already injected","warn");const e=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=U,e.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${U}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(o),l("Zonos font injected!")},T.setupGoogleFont=e=>{var n;null===(n=I.zonosController)||void 0===n||n.setupGoogleFont(e)},T.injectSupportGoogleFont=e=>{var n;l(`[FONT] injecting ${e}`);const o=null===(n=e.match(/family=(.*?):/))||void 0===n?void 0:n[1],t=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${U}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=U,t.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void l(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,t.appendChild(s),l(`[FONT] ${o} font injected!`)};export{T as Zonos}
|
|
1
|
+
import{c as n}from"./p-595f5dd2.js";import{g as o,I as t}from"./p-e7b0c156.js";import{g as r,a as i,l,h as u,b as m}from"./p-0fc02cde.js";import{_ as p,c as w,a as f}from"./p-3f1a2d31.js";export{c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector,d as domesticRedirectedBtnSelector}from"./p-3f1a2d31.js";export{a as availableTestKeys}from"./p-04a01cb1.js";export{c as countryRequireTaxId,e as euCountryCodes,s as shipToTaxIdLabels}from"./p-6b361d2b.js";const h=["jsdelivr","cdnjs","unpkg","vercel"],y="jsdelivr",v=e=>{const n=h.indexOf(e);return h[n+1]||null},g=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const n=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),o="https://v1.3.207.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-")))return o;if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";const t=`https://${n}.preview.js.zonos.com`;return l(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),t},S="https://js.stripe.com/v3",z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,j="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let O=null;const b=Promise.resolve().then((()=>{return e=null,null!==O||(O=new Promise(((n,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(j),window.Stripe)n(window.Stripe);else try{let t=(()=>{const e=document.querySelectorAll(`script[src^="${S}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&z.test(o.src))return o}return null})();t&&e?console.warn(j):t||(t=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${S}${n}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(m("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==t||t.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):o(new Error("Stripe.js not available"))})),null==t||t.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else n(null)}))),O;var e}));let k=!1;b.catch((e=>{k||console.warn(e)}));const $=async({cartId:e,retries:n})=>{const t=r(),s=o(),i=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:c,json:d,zonosMode:a}=await u(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),m=!d||c.length;return m&&n?(l("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise((e=>setTimeout(e,500))),$({cartId:e,retries:n-1})):m?null:Object.assign(Object.assign({},d),{zonosMode:a})};var I;const Z=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),L="https://v1.3.207.js.zonos.com",N=Z||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.207",U="https://fonts.googleapis.com",R=/^https:\/\/fonts\.googleapis\.com/;class T{}I=T,T.doneInit=!1,T.cartSettings=null,T.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),T.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),T._paypalMockResponse=null,T.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,T.isBigCommerce=!1,T.releaseDate="1748539024950",T.isLegacyCheckout=!1,T.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",T.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),T.overrideUseCustomAddressForm=!1,T.isNpm=!0,T.zonosQaUrl=null,T.zonosQaUrlApi=null,T.trackEventLogs=[],T.version="v1.3.207",T.modeAlerted=!1,T.cartData=null,T.paypal=null,T.zonosMode=null,T.IframeService=t,T.getCurrentTimestamp=()=>(new Date).getTime(),T.zonosController=null,T.loadTimeApiInfoList=[],T.logIntervalId=null,T.init=async e=>{const{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d,storeId:a,zonosApiKey:f}=e;if(I.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),I.doneInit)return;if(l(`====== ZONOS DEBUG MODE: on (${I.version}) ======`),I.zonosApiKey=f,I.storeId=a,I.isNpm){l("====== ZONOS LOADING FROM NPM ======");const n=g();if(n&&!window.isZonosPreview){l(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${n} ======`,"info");const o=document.createElement("script");return o.src=`${n}/dist/scripts/zonos.js`,document.head.appendChild(o),o.addEventListener("load",(()=>{window.Zonos.isNpm=I.isNpm,window.Zonos.isBigCommerce=I.isBigCommerce,window.Zonos.isLegacyCheckout=I.isLegacyCheckout,window.Zonos.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${n}`)})),void(window.isZonosPreview=!0)}if(!f&&!I.cartId)return void m("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!I.cartData&&I.cartId){l("Initialize cart data");const e=await(async e=>{const{isDgsCartId:n,isLegacyCartId:o}=p(e);if(!o&&!n)return m("[ZONOS - loadZonos] invalid cart id"),null;const t=await $({cartId:e,retries:5});return l("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(m("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(I.cartId);if(!e)return void m("Failed to get cart data");I.cartData=e.cartData,I.zonosApiKey=e.zonosApiKey,I.cartSettings=e.settings}const o=await(async()=>{const e=r(),n=i();if(!e&&!n||!window.Zonos.zonosApiKey)return null;if(l("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return l("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:o,json:t}=await u("/api/get-test-public-credential");if(o.length||!t)return m("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),null;const s=t.publicCredential;return s?(l(`[ZONOS - loadZonos] Retrieve new test public token ${s}`,"info"),s):(m("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();o&&(I.zonosApiKey=o)}const h=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(I.cartId&&I.cartData||h){l("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id=`${w}`,document.body.appendChild(e)}l("init zonos"),I.restoreNativeBrowserFunctions(),I.injectCustomScriptForHostedCheckout(),I.injectZonosCdn(),I.injectZonosCss(),I.injectFonts(),I.injectCheckoutInternationalButton(),I.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d}}),I.doneInit=!0},T.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${f}`)){const e=document.createElement("button");e.id=f,e.style.display="none",document.body.appendChild(e)}},T.injectCustomScriptForHostedCheckout=()=>{const e=I.cartData,n=(null==e?void 0:e.metadata)||[],o=n.find((e=>"customHeaderScript"===e.key)),t=n.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||t)){if(o){l("Injecting custom header script");const e=document.createElement("script");e.textContent=o.value,document.head.appendChild(e)}if(t){l("Injecting custom footer script");const e=document.createElement("script");e.textContent=t.value,document.body.appendChild(e)}}else l("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},T.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},T.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${f}`);setTimeout((()=>{e&&e.dispatchEvent(n("click"))}),10)},T.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},T.showNotification=e=>{var n;null===(n=I.zonosController)||void 0===n||n.showNotification(e)},T.updateOrganizationName=e=>{var n;null===(n=I.zonosController)||void 0===n||n.updateOrganizationName(e)},T.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:o,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const n=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&o&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},T.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const n="zonos---native-browser";let o=document.querySelector(`iframe#${n}`);o||(o=document.createElement("iframe"),o.id=n,o.style.display="none",o.style.opacity="0",o.style.position="absolute",o.style.top="-9999px",o.style.left="-9999px",o.style.width="1px",o.style.height="1px",o.style.border="none",o.style.overflow="hidden",o.style.visibility="hidden",document.body.appendChild(o));const t=(null===(e=o.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=t,document.body.removeChild(o)},T.injectController=({config:e})=>{var n,o;if(document.querySelector("zonos-controller"))return;if(null===(n=e.checkoutSettings)||void 0===n?void 0:n.placeOrderButtonSelector){const n=e.checkoutSettings.placeOrderButtonSelector;I.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{I.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const n=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;I.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{I.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}const t=document.createElement("zonos-controller");t.config=e,t.zonosApiKey=I.zonosApiKey||"",t.addEventListener("stripeInitEvent",(async e=>{const{detail:n}=e;l("loading Stripe");const o=await(async(...e)=>{k=!0;const n=Date.now();return b.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(n.publishableKey);o?(window.Zonos.stripe=o,t.initCheckoutElement(o)):m("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(t),I.zonosController=t,l("Zonos controller injected!")},T.injectScript=({cdnType:e,isModule:n,theRestUrl:o})=>{const t=`${I.getZonosUrl(e)}/${o}`;if(document.querySelector(`script[src="${t}"]`))return void l(`Zonos script "${t}" already exists in the document`,"warn");const s=document.head||document.body,r=document.createElement("script");n?r.type="module":r.noModule=!0,r.src=t,r.crossOrigin="anonymous",r.onerror=()=>{m(`Failed to load ${r.src}`);const t=v(e);t&&I.injectScript({cdnType:t,isModule:n,theRestUrl:o})},s.appendChild(r)},T.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return N;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.207";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.207";case"vercel":return L}};return I.isNpm&&g()||n()},T.injectZonosCdn=()=>{I.injectScript({cdnType:y,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),I.injectScript({cdnType:y,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),l("Zonos cdn script injected!")},T.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const o=I.getZonosUrl(e),t=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${L}/`,t.appendChild(s);const r=document.createElement("link");r.rel="stylesheet",r.href=`${o}/${n}`,r.onerror=()=>{m(`Failed to load ${r.href}`);const o=v(e);o&&I.injectStylesheet({cdnType:o,theRestUrl:n})},t.appendChild(r)},T.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?l("Zonos style links already injected","warn"):(I.injectStylesheet({cdnType:y,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),l("Zonos style css injected!"))},T.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void l("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${U}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!R.test(o.href))return o}return null})())return void l("Inter font already injected","warn");const e=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=U,e.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${U}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(o),l("Zonos font injected!")},T.setupGoogleFont=e=>{var n;null===(n=I.zonosController)||void 0===n||n.setupGoogleFont(e)},T.injectSupportGoogleFont=e=>{var n;l(`[FONT] injecting ${e}`);const o=null===(n=e.match(/family=(.*?):/))||void 0===n?void 0:n[1],t=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${U}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=U,t.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void l(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,t.appendChild(s),l(`[FONT] ${o} font injected!`)};export{T as Zonos}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(n,e,t,r){function o(n){return n instanceof t?n:new t((function(e){e(n)}))}return new(t||(t=Promise))((function(t,i){function u(n){try{s(r.next(n))}catch(n){i(n)}}function a(n){try{s(r["throw"](n))}catch(n){i(n)}}function s(n){n.done?t(n.value):o(n.value).then(u,a)}s((r=r.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,u;return u={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(n){return function(e){return s([n,e])}}function s(a){if(r)throw new TypeError("Generator is already executing.");while(u&&(u=0,a[0]&&(t=0)),t)try{if(r=1,o&&(i=a[0]&2?o["return"]:a[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;if(o=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:t.label++;return{value:a[1],done:false};case 5:t.label++;o=a[1];a=[0];continue;case 7:a=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){t.label=a[1];break}if(a[0]===6&&t.label<i[1]){t.label=i[1];i=a;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(a);break}if(i[2])t.ops.pop();t.trys.pop();continue}a=e.call(n,t)}catch(n){a=[6,n];o=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./p-bf37ccc7.system.js","./p-4160bbc2.system.js","./p-1b75aa35.system.js","./p-5e1b2654.system.js","./p-5a2dd041.system.js","./p-2b8345d8.system.js"],(function(n){"use strict";var e,t,r,o,i,u,a,s,c,d,l;return{setters:[function(n){e=n.c},function(n){t=n.g;r=n.I},function(n){o=n.g;i=n.a;u=n.l;a=n.h;s=n.b},function(e){c=e._;d=e.c;l=e.a;var t={};t.checkoutHiddenBtnSelector=e.c;t.checkoutHiddenInternationalBtnSelector=e.a;t.domesticRedirectedBtnSelector=e.d;n(t)},function(e){n("availableTestKeys",e.a)},function(e){var t={};t.countryRequireTaxId=e.c;t.euCountryCodes=e.e;t.shipToTaxIdLabels=e.s;n(t)}],execute:function(){var f=this;var v=function(n){var e=n.loadScriptSrc;if(!e){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var o=new URL(e).origin;var i=t.some((function(n){return o.includes(n)}));var u=r.some((function(n){return o.includes(n)}));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:u,isWhiteListed:i}};var m=["jsdelivr","cdnjs","unpkg","vercel"];var w="jsdelivr";var p=function(n){var e=m.indexOf(n);var t=m[e+1];return t||null};var h=function(){return __awaiter(f,void 0,void 0,(function(){var n,e,t,r,c,d;return __generator(this,(function(l){switch(l.label){case 0:n=o();e=i();if(!n&&!e||!window.Zonos.zonosApiKey){return[2,null]}u("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("credential_test")){u("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2,null]}return[4,a("/api/get-test-public-credential")];case 1:t=l.sent(),r=t.errors,c=t.json;if(r.length||!c){s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r);return[2,null]}d=c.publicCredential;if(!d){s("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}u("[ZONOS - loadZonos] Retrieve new test public token ".concat(d),"info");return[2,d]}}))}))};var y=function(n){if(!n){return null}var e=new URL(n).searchParams;var t=e.get("zonosQaUrl");if(!t){return null}var r=/[^a-zA-Z0-9-_]+/.test(t);if(!!r){return null}return t};var g=function(){var n=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||n){return null}var e=y(window.location.href);var t="https://v1.3.206.js.zonos.com";if(!e&&(t.includes("test.")||t.includes("test-"))){return t}if(!e&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!e){return null}if(e==="dev-elements"){return"https://dev.elements.zonos.com"}var r="preview.js.zonos.com";var o="https://".concat(e,".").concat(r);u("[ZONOS-WARNING] using '".concat(o,"' for loading elements script"),"warn");void fetch(o).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(o,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var n=new URLSearchParams(window.location.search);n.delete("zonosQaUrl");var e=window.location.pathname;var t="".concat(e,"?").concat(n.toString());window.history.replaceState(window.history.state,"",t);window.location.reload();return null}));return o};var b="https://js.stripe.com/v3";var z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var S="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var j=function(){var n=document.querySelectorAll('script[src^="'.concat(b,'"]'));for(var e=0;e<n.length;e++){var t=n[e];if(!t){continue}if(!z.test(t.src)){continue}return t}return null};var O=null;var k=function(n){var e=n&&!n.advancedFraudSignals?"?advancedFraudSignals=false":"";var t=document.createElement("script");t.src="".concat(b).concat(e);var r=document.head||document.body;if(!r){s("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}r.appendChild(t);return t};var _=function(n){if(O!==null){return O}O=new Promise((function(e,t){if(typeof window==="undefined"||typeof document==="undefined"){e(null);return}if(window.Stripe&&n){console.warn(S)}if(window.Stripe){e(window.Stripe);return}try{var r=j();if(r&&n){console.warn(S)}else if(!r){r=k(n)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){e(window.Stripe)}else{t(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){t(new Error("Failed to load Stripe.js"))}))}catch(n){t(n);return}}));return O};var Z=function(n,e){if(!n||!n._registerWrapper){return}n._registerWrapper({name:"stripe-js",startTime:e})};var N=function(n,e,t){if(n===null){return null}var r=n.apply(undefined,e);Z(r,t);return r};var I=Promise.resolve().then((function(){return _(null)}));var L=false;I.catch((function(n){if(!L){console.warn(n)}}));var U=function(){var n=[];for(var e=0;e<arguments.length;e++){n[e]=arguments[e]}return __awaiter(f,void 0,void 0,(function(){var e;return __generator(this,(function(t){L=true;e=Date.now();return[2,I.then((function(t){return N(t,n,e)}))]}))}))};var R="tempCartUUID";var T=function(){var n=new URLSearchParams(window.location.search);var e=n.get(R);return e};var A=function(n){return __awaiter(f,[n],void 0,(function(n){var e,r,i,s,c,d,l,f;var v=n.cartId,m=n.retries;return __generator(this,(function(n){switch(n.label){case 0:e=o();r=t();i=new URLSearchParams;if(r.overrideShouldEnabledCustomAddress){i.set("overrideShouldEnabledCustomAddress",r.overrideShouldEnabledCustomAddress)}return[4,a("/api/zonos-elements/get-cart?".concat(i.toString()),{body:{isTestMode:e,tempCartUUID:v},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:s=n.sent(),c=s.errors,d=s.json,l=s.zonosMode;f=!d||c.length;if(!(f&&m))return[3,3];u("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:m});return[4,new Promise((function(n){return setTimeout(n,500)}))];case 2:n.sent();return[2,A({cartId:v,retries:m-1})];case 3:if(f){return[2,null]}return[2,Object.assign(Object.assign({},d),{zonosMode:l})]}}))}))};var F=function(n){return __awaiter(f,void 0,void 0,(function(){var e,t,r,o;return __generator(this,(function(i){switch(i.label){case 0:e=c(n),t=e.isDgsCartId,r=e.isLegacyCartId;if(!r&&!t){s("[ZONOS - loadZonos] invalid cart id");return[2,null]}return[4,A({cartId:n,retries:5})];case 1:o=i.sent();u("[ZONOS - loadZonos] getting temp cart data","info",o);if(!o){s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2,null]}window.Zonos.storeId=o.cartData.storeId;window.Zonos.zonosApiKey=o.cartData.credentialToken;window.Zonos.zonosMode=o.zonosMode;return[2,{cartData:o.cartData,settings:o.settings,storeFavicon:o.storeFaviconUrl,storeId:o.cartData.storeId,storeLogo:o.storeLogoUrl,zonosApiKey:o.cartData.credentialToken}]}}))}))};var E;var P=function(){if(typeof document==="undefined"){return null}var n=document.querySelector('script[src*="/zonos.js"]');var e=v({loadScriptSrc:n===null||n===void 0?void 0:n.src}),t=e.currentLoadScriptUrl,r=e.isWhiteListed;if(r){return t}return null}();var C="https://v1.3.206.js.zonos.com";var D=P||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.206";var M="https://unpkg.com/@zonos/elements@1.3.206";var x="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.206";var G="https://fonts.googleapis.com";var B=/^https:\/\/fonts\.googleapis\.com/;var V=function(){function n(){}return n}();n("Zonos",V);E=V;V.doneInit=false;V.cartSettings=null;V.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);V.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);V._paypalMockResponse=null;V.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;V.isBigCommerce=false;V.releaseDate="1748443962388";V.isLegacyCheckout=false;V.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";V.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");V.overrideUseCustomAddressForm=false;V.isNpm=true;V.zonosQaUrl=null;V.zonosQaUrlApi=null;V.trackEventLogs=[];V.version="v".concat("1.3.206");V.modeAlerted=false;V.cartData=null;V.paypal=null;V.zonosMode=null;V.IframeService=r;V.getCurrentTimestamp=function(){return(new Date).getTime()};V.zonosController=null;V.loadTimeApiInfoList=[];V.logIntervalId=null;V.init=function(n){return __awaiter(f,void 0,void 0,(function(){var e,t,r,o,i,a,c,l,f,v,m,w,p,y,b;return __generator(this,(function(z){switch(z.label){case 0:e=n.appearance,t=n.checkoutSettings,r=n.currencyConverter,o=n.helloSettings,i=n.onCountryChange,a=n.overrideCurrencyFormat,c=n.storeId,l=n.zonosApiKey;E.cartId=T();if(E.doneInit){return[2]}u("====== ZONOS DEBUG MODE: on (".concat(E.version,") ======"));E.zonosApiKey=l;E.storeId=c;if(!E.isNpm)return[3,4];u("====== ZONOS LOADING FROM NPM ======");f=g();if(f&&!window.isZonosPreview){u('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(f," ======"),"info");v=document.createElement("script");v.src="".concat(f,"/dist/scripts/zonos.js");document.head.appendChild(v);v.addEventListener("load",(function(){window.Zonos.isNpm=E.isNpm;window.Zonos.isBigCommerce=E.isBigCommerce;window.Zonos.isLegacyCheckout=E.isLegacyCheckout;void window.Zonos.init(n)}));v.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(f))}));window.isZonosPreview=true;return[2]}if(!l&&!E.cartId){s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!E.cartData&&E.cartId))return[3,2];u("Initialize cart data");return[4,F(E.cartId)];case 1:m=z.sent();if(!m){s("Failed to get cart data");return[2]}E.cartData=m.cartData;E.zonosApiKey=m.zonosApiKey;E.cartSettings=m.settings;z.label=2;case 2:return[4,h()];case 3:w=z.sent();if(w){E.zonosApiKey=w}z.label=4;case 4:p=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");y=E.cartId&&E.cartData||!!p;if(y){u("Cart data or stripe client secret is available, inject hidden button and trigger checkout");b=document.createElement("button");b.style.display="none";b.id="".concat(d);document.body.appendChild(b)}u("init zonos");E.restoreNativeBrowserFunctions();E.injectCustomScriptForHostedCheckout();E.injectZonosCdn();E.injectZonosCss();E.injectFonts();E.injectCheckoutInternationalButton();E.injectController({config:{appearance:e,checkoutSettings:t,currencyConverter:r,helloSettings:o,onCountryChange:i,overrideCurrencyFormat:a}});E.doneInit=true;return[2]}}))}))};V.injectCheckoutInternationalButton=function(){if(!document.querySelector("#".concat(l))){var n=document.createElement("button");n.id=l;n.style.display="none";document.body.appendChild(n)}};V.injectCustomScriptForHostedCheckout=function(){var n=E.cartData;var e=(n===null||n===void 0?void 0:n.metadata)||[];var t=e.find((function(n){return n.key==="customHeaderScript"}));var r=e.find((function(n){return n.key==="customFooterScript"}));if(!window.Zonos.isLegacyCheckout||!t&&!r){u("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(t){u("Injecting custom header script");var o=document.createElement("script");o.textContent=t.value;document.head.appendChild(o)}if(r){u("Injecting custom footer script");var o=document.createElement("script");o.textContent=r.value;document.body.appendChild(o)}};V.displayCurrency=function(){var n=document.querySelector("zonos-hello");if(n){void n.displayCurrency()}};V.triggerCheckoutInternational=function(){return __awaiter(f,void 0,void 0,(function(){var n;return __generator(this,(function(t){n=document.querySelector("#".concat(l));setTimeout((function(){if(n){n.dispatchEvent(e("click"))}}),10);return[2]}))}))};V.openHelloDialog=function(n){var e=document.querySelector("zonos-hello");if(e){void e.openHelloDialog(n!==null&&n!==void 0?n:true)}};V.showNotification=function(n){var e;void((e=E.zonosController)===null||e===void 0?void 0:e.showNotification(n))};V.updateOrganizationName=function(n){var e;void((e=E.zonosController)===null||e===void 0?void 0:e.updateOrganizationName(n))};V.disablePlaceOrderButtons=function(n){var e=n.autoEnable,t=e===void 0?true:e,r=n.config,o=n.disable,i=n.placeOrderButtonSelector;var u;if((u=r.checkoutSettings)===null||u===void 0?void 0:u.disablePlaceOrderButtonActivation){return}if(i){var a=document.querySelectorAll(i);var s=function(n){var e=n.target;if(e.getAttribute("disabled")){n.preventDefault();n.stopPropagation()}};a.forEach((function(n){var e=n.getAttribute("data-zonos-checkout-attached");if(e){return}if(o){n.setAttribute("disabled","true");n.addEventListener("click",s)}else{n.removeAttribute("disabled");n.removeEventListener("click",s)}}));if(t&&o){setTimeout((function(){a.forEach((function(n){n.removeAttribute("disabled");n.removeEventListener("click",s)}))}),5e3)}}};V.restoreNativeBrowserFunctions=function(){var n;var e=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(e){return}var t="zonos---native-browser";var r=document.querySelector("iframe#".concat(t));if(!r){r=document.createElement("iframe");r.id=t;r.style.display="none";r.style.opacity="0";r.style.position="absolute";r.style.top="-9999px";r.style.left="-9999px";r.style.width="1px";r.style.height="1px";r.style.border="none";r.style.overflow="hidden";r.style.visibility="hidden";document.body.appendChild(r)}var o=((n=r.contentWindow)===null||n===void 0?void 0:n.window.Array.from)||Array.from;Array.from=o;document.body.removeChild(r)};V.injectController=function(n){var e=n.config;var t,r;if(document.querySelector("zonos-controller")){return}if((t=e.checkoutSettings)===null||t===void 0?void 0:t.placeOrderButtonSelector){var o=e.checkoutSettings.placeOrderButtonSelector;E.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:o});var i=new MutationObserver((function(){E.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:o})}));i.observe(document.body,{childList:true,subtree:true})}if((r=e.checkoutSettings)===null||r===void 0?void 0:r.alwaysTriggerInternationalCheckoutSelector){var a=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;E.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:a});var i=new MutationObserver((function(){E.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:a})}));i.observe(document.body,{childList:true,subtree:true})}var c=document.createElement("zonos-controller");c.config=e;c.zonosApiKey=E.zonosApiKey||"";c.addEventListener("stripeInitEvent",(function(n){return __awaiter(f,void 0,void 0,(function(){var e,t;return __generator(this,(function(r){switch(r.label){case 0:e=n.detail;u("loading Stripe");return[4,U(e.publishableKey)];case 1:t=r.sent();if(!t){s("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=t;void c.initCheckoutElement(t);return[2]}}))}))}));document.body.appendChild(c);E.zonosController=c;u("Zonos controller injected!")};V.injectScript=function(n){var e=n.cdnType,t=n.isModule,r=n.theRestUrl;var o=E.getZonosUrl(e);var i="".concat(o,"/").concat(r);var a=function(){var n=document.querySelector('script[src="'.concat(i,'"]'));return!!n};if(a()){u('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var c=document.head||document.body;var d=document.createElement("script");if(!!t){d.type="module"}else{d.noModule=true}d.src=i;d.crossOrigin="anonymous";d.onerror=function(){s("Failed to load ".concat(d.src));var n=p(e);if(!n){return}E.injectScript({cdnType:n,isModule:t,theRestUrl:r})};c.appendChild(d)};V.getZonosUrl=function(n){var e=function(){switch(n){case"jsdelivr":return D;case"unpkg":return M;case"cdnjs":return x;case"vercel":return C}};if(E.isNpm){var t=g();return t||e()}return e()};V.injectZonosCdn=function(){E.injectScript({cdnType:w,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});E.injectScript({cdnType:w,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});u("Zonos cdn script injected!")};V.injectStylesheet=function(n){var e=n.cdnType,t=n.theRestUrl;var r=E.getZonosUrl(e);var o=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(C,"/");o.appendChild(i);var u=document.createElement("link");u.rel="stylesheet";u.href="".concat(r,"/").concat(t);u.onerror=function(){s("Failed to load ".concat(u.href));var n=p(e);if(!n){return}E.injectStylesheet({cdnType:n,theRestUrl:t})};o.appendChild(u)};V.injectZonosCss=function(){var n=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(n()){u("Zonos style links already injected","warn");return}E.injectStylesheet({cdnType:w,theRestUrl:"dist/zonos-elements/zonos-elements.css"});u("Zonos style css injected!")};V.injectFonts=function(){var n=function(){var n=document.fonts.check("1em Inter");if(n){u("Inter font already loaded","warn");return}var e=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(G,'"]'));for(var t=0;t<e.length;t++){var r=e[t];if(!r){continue}if(B.test(r.href)){continue}return r}return null};if(n()){u("Inter font already injected","warn");return}var e=document.head||document.body;var t=document.createElement("link");t.rel="preconnect";t.href=G;e.appendChild(t);var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(G,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");e.appendChild(r);u("Zonos font injected!")};V.setupGoogleFont=function(n){var e;void((e=E.zonosController)===null||e===void 0?void 0:e.setupGoogleFont(n))};V.injectSupportGoogleFont=function(n){var e;u("[FONT] injecting ".concat(n));var t=(e=n.match(/family=(.*?):/))===null||e===void 0?void 0:e[1];var r=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(G,'"]'))){var o=document.createElement("link");o.rel="preconnect";o.href=G;r.appendChild(o)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(n,'"]'))){u("[FONT] ".concat(t," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=n;r.appendChild(i);u("[FONT] ".concat(t," font injected!"))}}}}));
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(n,e,t,r){function o(n){return n instanceof t?n:new t((function(e){e(n)}))}return new(t||(t=Promise))((function(t,i){function u(n){try{s(r.next(n))}catch(n){i(n)}}function a(n){try{s(r["throw"](n))}catch(n){i(n)}}function s(n){n.done?t(n.value):o(n.value).then(u,a)}s((r=r.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,u;return u={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(n){return function(e){return s([n,e])}}function s(a){if(r)throw new TypeError("Generator is already executing.");while(u&&(u=0,a[0]&&(t=0)),t)try{if(r=1,o&&(i=a[0]&2?o["return"]:a[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;if(o=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:t.label++;return{value:a[1],done:false};case 5:t.label++;o=a[1];a=[0];continue;case 7:a=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){t.label=a[1];break}if(a[0]===6&&t.label<i[1]){t.label=i[1];i=a;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(a);break}if(i[2])t.ops.pop();t.trys.pop();continue}a=e.call(n,t)}catch(n){a=[6,n];o=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./p-bf37ccc7.system.js","./p-4160bbc2.system.js","./p-1b75aa35.system.js","./p-5e1b2654.system.js","./p-5a2dd041.system.js","./p-2b8345d8.system.js"],(function(n){"use strict";var e,t,r,o,i,u,a,s,c,d,l;return{setters:[function(n){e=n.c},function(n){t=n.g;r=n.I},function(n){o=n.g;i=n.a;u=n.l;a=n.h;s=n.b},function(e){c=e._;d=e.c;l=e.a;var t={};t.checkoutHiddenBtnSelector=e.c;t.checkoutHiddenInternationalBtnSelector=e.a;t.domesticRedirectedBtnSelector=e.d;n(t)},function(e){n("availableTestKeys",e.a)},function(e){var t={};t.countryRequireTaxId=e.c;t.euCountryCodes=e.e;t.shipToTaxIdLabels=e.s;n(t)}],execute:function(){var f=this;var v=function(n){var e=n.loadScriptSrc;if(!e){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var o=new URL(e).origin;var i=t.some((function(n){return o.includes(n)}));var u=r.some((function(n){return o.includes(n)}));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:u,isWhiteListed:i}};var m=["jsdelivr","cdnjs","unpkg","vercel"];var w="jsdelivr";var p=function(n){var e=m.indexOf(n);var t=m[e+1];return t||null};var h=function(){return __awaiter(f,void 0,void 0,(function(){var n,e,t,r,c,d;return __generator(this,(function(l){switch(l.label){case 0:n=o();e=i();if(!n&&!e||!window.Zonos.zonosApiKey){return[2,null]}u("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("credential_test")){u("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2,null]}return[4,a("/api/get-test-public-credential")];case 1:t=l.sent(),r=t.errors,c=t.json;if(r.length||!c){s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r);return[2,null]}d=c.publicCredential;if(!d){s("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}u("[ZONOS - loadZonos] Retrieve new test public token ".concat(d),"info");return[2,d]}}))}))};var y=function(n){if(!n){return null}var e=new URL(n).searchParams;var t=e.get("zonosQaUrl");if(!t){return null}var r=/[^a-zA-Z0-9-_]+/.test(t);if(!!r){return null}return t};var g=function(){var n=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||n){return null}var e=y(window.location.href);var t="https://v1.3.207.js.zonos.com";if(!e&&(t.includes("test.")||t.includes("test-"))){return t}if(!e&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!e){return null}if(e==="dev-elements"){return"https://dev.elements.zonos.com"}var r="preview.js.zonos.com";var o="https://".concat(e,".").concat(r);u("[ZONOS-WARNING] using '".concat(o,"' for loading elements script"),"warn");void fetch(o).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(o,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var n=new URLSearchParams(window.location.search);n.delete("zonosQaUrl");var e=window.location.pathname;var t="".concat(e,"?").concat(n.toString());window.history.replaceState(window.history.state,"",t);window.location.reload();return null}));return o};var b="https://js.stripe.com/v3";var z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var S="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var j=function(){var n=document.querySelectorAll('script[src^="'.concat(b,'"]'));for(var e=0;e<n.length;e++){var t=n[e];if(!t){continue}if(!z.test(t.src)){continue}return t}return null};var O=null;var k=function(n){var e=n&&!n.advancedFraudSignals?"?advancedFraudSignals=false":"";var t=document.createElement("script");t.src="".concat(b).concat(e);var r=document.head||document.body;if(!r){s("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}r.appendChild(t);return t};var _=function(n){if(O!==null){return O}O=new Promise((function(e,t){if(typeof window==="undefined"||typeof document==="undefined"){e(null);return}if(window.Stripe&&n){console.warn(S)}if(window.Stripe){e(window.Stripe);return}try{var r=j();if(r&&n){console.warn(S)}else if(!r){r=k(n)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){e(window.Stripe)}else{t(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){t(new Error("Failed to load Stripe.js"))}))}catch(n){t(n);return}}));return O};var Z=function(n,e){if(!n||!n._registerWrapper){return}n._registerWrapper({name:"stripe-js",startTime:e})};var N=function(n,e,t){if(n===null){return null}var r=n.apply(undefined,e);Z(r,t);return r};var I=Promise.resolve().then((function(){return _(null)}));var L=false;I.catch((function(n){if(!L){console.warn(n)}}));var U=function(){var n=[];for(var e=0;e<arguments.length;e++){n[e]=arguments[e]}return __awaiter(f,void 0,void 0,(function(){var e;return __generator(this,(function(t){L=true;e=Date.now();return[2,I.then((function(t){return N(t,n,e)}))]}))}))};var R="tempCartUUID";var T=function(){var n=new URLSearchParams(window.location.search);var e=n.get(R);return e};var A=function(n){return __awaiter(f,[n],void 0,(function(n){var e,r,i,s,c,d,l,f;var v=n.cartId,m=n.retries;return __generator(this,(function(n){switch(n.label){case 0:e=o();r=t();i=new URLSearchParams;if(r.overrideShouldEnabledCustomAddress){i.set("overrideShouldEnabledCustomAddress",r.overrideShouldEnabledCustomAddress)}return[4,a("/api/zonos-elements/get-cart?".concat(i.toString()),{body:{isTestMode:e,tempCartUUID:v},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:s=n.sent(),c=s.errors,d=s.json,l=s.zonosMode;f=!d||c.length;if(!(f&&m))return[3,3];u("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:m});return[4,new Promise((function(n){return setTimeout(n,500)}))];case 2:n.sent();return[2,A({cartId:v,retries:m-1})];case 3:if(f){return[2,null]}return[2,Object.assign(Object.assign({},d),{zonosMode:l})]}}))}))};var F=function(n){return __awaiter(f,void 0,void 0,(function(){var e,t,r,o;return __generator(this,(function(i){switch(i.label){case 0:e=c(n),t=e.isDgsCartId,r=e.isLegacyCartId;if(!r&&!t){s("[ZONOS - loadZonos] invalid cart id");return[2,null]}return[4,A({cartId:n,retries:5})];case 1:o=i.sent();u("[ZONOS - loadZonos] getting temp cart data","info",o);if(!o){s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2,null]}window.Zonos.storeId=o.cartData.storeId;window.Zonos.zonosApiKey=o.cartData.credentialToken;window.Zonos.zonosMode=o.zonosMode;return[2,{cartData:o.cartData,settings:o.settings,storeFavicon:o.storeFaviconUrl,storeId:o.cartData.storeId,storeLogo:o.storeLogoUrl,zonosApiKey:o.cartData.credentialToken}]}}))}))};var E;var P=function(){if(typeof document==="undefined"){return null}var n=document.querySelector('script[src*="/zonos.js"]');var e=v({loadScriptSrc:n===null||n===void 0?void 0:n.src}),t=e.currentLoadScriptUrl,r=e.isWhiteListed;if(r){return t}return null}();var C="https://v1.3.207.js.zonos.com";var D=P||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.207";var M="https://unpkg.com/@zonos/elements@1.3.207";var x="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.207";var G="https://fonts.googleapis.com";var B=/^https:\/\/fonts\.googleapis\.com/;var V=function(){function n(){}return n}();n("Zonos",V);E=V;V.doneInit=false;V.cartSettings=null;V.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);V.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);V._paypalMockResponse=null;V.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;V.isBigCommerce=false;V.releaseDate="1748539024950";V.isLegacyCheckout=false;V.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";V.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");V.overrideUseCustomAddressForm=false;V.isNpm=true;V.zonosQaUrl=null;V.zonosQaUrlApi=null;V.trackEventLogs=[];V.version="v".concat("1.3.207");V.modeAlerted=false;V.cartData=null;V.paypal=null;V.zonosMode=null;V.IframeService=r;V.getCurrentTimestamp=function(){return(new Date).getTime()};V.zonosController=null;V.loadTimeApiInfoList=[];V.logIntervalId=null;V.init=function(n){return __awaiter(f,void 0,void 0,(function(){var e,t,r,o,i,a,c,l,f,v,m,w,p,y,b;return __generator(this,(function(z){switch(z.label){case 0:e=n.appearance,t=n.checkoutSettings,r=n.currencyConverter,o=n.helloSettings,i=n.onCountryChange,a=n.overrideCurrencyFormat,c=n.storeId,l=n.zonosApiKey;E.cartId=T();if(E.doneInit){return[2]}u("====== ZONOS DEBUG MODE: on (".concat(E.version,") ======"));E.zonosApiKey=l;E.storeId=c;if(!E.isNpm)return[3,4];u("====== ZONOS LOADING FROM NPM ======");f=g();if(f&&!window.isZonosPreview){u('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(f," ======"),"info");v=document.createElement("script");v.src="".concat(f,"/dist/scripts/zonos.js");document.head.appendChild(v);v.addEventListener("load",(function(){window.Zonos.isNpm=E.isNpm;window.Zonos.isBigCommerce=E.isBigCommerce;window.Zonos.isLegacyCheckout=E.isLegacyCheckout;void window.Zonos.init(n)}));v.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(f))}));window.isZonosPreview=true;return[2]}if(!l&&!E.cartId){s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!E.cartData&&E.cartId))return[3,2];u("Initialize cart data");return[4,F(E.cartId)];case 1:m=z.sent();if(!m){s("Failed to get cart data");return[2]}E.cartData=m.cartData;E.zonosApiKey=m.zonosApiKey;E.cartSettings=m.settings;z.label=2;case 2:return[4,h()];case 3:w=z.sent();if(w){E.zonosApiKey=w}z.label=4;case 4:p=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");y=E.cartId&&E.cartData||!!p;if(y){u("Cart data or stripe client secret is available, inject hidden button and trigger checkout");b=document.createElement("button");b.style.display="none";b.id="".concat(d);document.body.appendChild(b)}u("init zonos");E.restoreNativeBrowserFunctions();E.injectCustomScriptForHostedCheckout();E.injectZonosCdn();E.injectZonosCss();E.injectFonts();E.injectCheckoutInternationalButton();E.injectController({config:{appearance:e,checkoutSettings:t,currencyConverter:r,helloSettings:o,onCountryChange:i,overrideCurrencyFormat:a}});E.doneInit=true;return[2]}}))}))};V.injectCheckoutInternationalButton=function(){if(!document.querySelector("#".concat(l))){var n=document.createElement("button");n.id=l;n.style.display="none";document.body.appendChild(n)}};V.injectCustomScriptForHostedCheckout=function(){var n=E.cartData;var e=(n===null||n===void 0?void 0:n.metadata)||[];var t=e.find((function(n){return n.key==="customHeaderScript"}));var r=e.find((function(n){return n.key==="customFooterScript"}));if(!window.Zonos.isLegacyCheckout||!t&&!r){u("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(t){u("Injecting custom header script");var o=document.createElement("script");o.textContent=t.value;document.head.appendChild(o)}if(r){u("Injecting custom footer script");var o=document.createElement("script");o.textContent=r.value;document.body.appendChild(o)}};V.displayCurrency=function(){var n=document.querySelector("zonos-hello");if(n){void n.displayCurrency()}};V.triggerCheckoutInternational=function(){return __awaiter(f,void 0,void 0,(function(){var n;return __generator(this,(function(t){n=document.querySelector("#".concat(l));setTimeout((function(){if(n){n.dispatchEvent(e("click"))}}),10);return[2]}))}))};V.openHelloDialog=function(n){var e=document.querySelector("zonos-hello");if(e){void e.openHelloDialog(n!==null&&n!==void 0?n:true)}};V.showNotification=function(n){var e;void((e=E.zonosController)===null||e===void 0?void 0:e.showNotification(n))};V.updateOrganizationName=function(n){var e;void((e=E.zonosController)===null||e===void 0?void 0:e.updateOrganizationName(n))};V.disablePlaceOrderButtons=function(n){var e=n.autoEnable,t=e===void 0?true:e,r=n.config,o=n.disable,i=n.placeOrderButtonSelector;var u;if((u=r.checkoutSettings)===null||u===void 0?void 0:u.disablePlaceOrderButtonActivation){return}if(i){var a=document.querySelectorAll(i);var s=function(n){var e=n.target;if(e.getAttribute("disabled")){n.preventDefault();n.stopPropagation()}};a.forEach((function(n){var e=n.getAttribute("data-zonos-checkout-attached");if(e){return}if(o){n.setAttribute("disabled","true");n.addEventListener("click",s)}else{n.removeAttribute("disabled");n.removeEventListener("click",s)}}));if(t&&o){setTimeout((function(){a.forEach((function(n){n.removeAttribute("disabled");n.removeEventListener("click",s)}))}),5e3)}}};V.restoreNativeBrowserFunctions=function(){var n;var e=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(e){return}var t="zonos---native-browser";var r=document.querySelector("iframe#".concat(t));if(!r){r=document.createElement("iframe");r.id=t;r.style.display="none";r.style.opacity="0";r.style.position="absolute";r.style.top="-9999px";r.style.left="-9999px";r.style.width="1px";r.style.height="1px";r.style.border="none";r.style.overflow="hidden";r.style.visibility="hidden";document.body.appendChild(r)}var o=((n=r.contentWindow)===null||n===void 0?void 0:n.window.Array.from)||Array.from;Array.from=o;document.body.removeChild(r)};V.injectController=function(n){var e=n.config;var t,r;if(document.querySelector("zonos-controller")){return}if((t=e.checkoutSettings)===null||t===void 0?void 0:t.placeOrderButtonSelector){var o=e.checkoutSettings.placeOrderButtonSelector;E.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:o});var i=new MutationObserver((function(){E.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:o})}));i.observe(document.body,{childList:true,subtree:true})}if((r=e.checkoutSettings)===null||r===void 0?void 0:r.alwaysTriggerInternationalCheckoutSelector){var a=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;E.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:a});var i=new MutationObserver((function(){E.disablePlaceOrderButtons({config:e,disable:true,placeOrderButtonSelector:a})}));i.observe(document.body,{childList:true,subtree:true})}var c=document.createElement("zonos-controller");c.config=e;c.zonosApiKey=E.zonosApiKey||"";c.addEventListener("stripeInitEvent",(function(n){return __awaiter(f,void 0,void 0,(function(){var e,t;return __generator(this,(function(r){switch(r.label){case 0:e=n.detail;u("loading Stripe");return[4,U(e.publishableKey)];case 1:t=r.sent();if(!t){s("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=t;void c.initCheckoutElement(t);return[2]}}))}))}));document.body.appendChild(c);E.zonosController=c;u("Zonos controller injected!")};V.injectScript=function(n){var e=n.cdnType,t=n.isModule,r=n.theRestUrl;var o=E.getZonosUrl(e);var i="".concat(o,"/").concat(r);var a=function(){var n=document.querySelector('script[src="'.concat(i,'"]'));return!!n};if(a()){u('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var c=document.head||document.body;var d=document.createElement("script");if(!!t){d.type="module"}else{d.noModule=true}d.src=i;d.crossOrigin="anonymous";d.onerror=function(){s("Failed to load ".concat(d.src));var n=p(e);if(!n){return}E.injectScript({cdnType:n,isModule:t,theRestUrl:r})};c.appendChild(d)};V.getZonosUrl=function(n){var e=function(){switch(n){case"jsdelivr":return D;case"unpkg":return M;case"cdnjs":return x;case"vercel":return C}};if(E.isNpm){var t=g();return t||e()}return e()};V.injectZonosCdn=function(){E.injectScript({cdnType:w,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});E.injectScript({cdnType:w,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});u("Zonos cdn script injected!")};V.injectStylesheet=function(n){var e=n.cdnType,t=n.theRestUrl;var r=E.getZonosUrl(e);var o=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(C,"/");o.appendChild(i);var u=document.createElement("link");u.rel="stylesheet";u.href="".concat(r,"/").concat(t);u.onerror=function(){s("Failed to load ".concat(u.href));var n=p(e);if(!n){return}E.injectStylesheet({cdnType:n,theRestUrl:t})};o.appendChild(u)};V.injectZonosCss=function(){var n=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(n()){u("Zonos style links already injected","warn");return}E.injectStylesheet({cdnType:w,theRestUrl:"dist/zonos-elements/zonos-elements.css"});u("Zonos style css injected!")};V.injectFonts=function(){var n=function(){var n=document.fonts.check("1em Inter");if(n){u("Inter font already loaded","warn");return}var e=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(G,'"]'));for(var t=0;t<e.length;t++){var r=e[t];if(!r){continue}if(B.test(r.href)){continue}return r}return null};if(n()){u("Inter font already injected","warn");return}var e=document.head||document.body;var t=document.createElement("link");t.rel="preconnect";t.href=G;e.appendChild(t);var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(G,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");e.appendChild(r);u("Zonos font injected!")};V.setupGoogleFont=function(n){var e;void((e=E.zonosController)===null||e===void 0?void 0:e.setupGoogleFont(n))};V.injectSupportGoogleFont=function(n){var e;u("[FONT] injecting ".concat(n));var t=(e=n.match(/family=(.*?):/))===null||e===void 0?void 0:e[1];var r=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(G,'"]'))){var o=document.createElement("link");o.rel="preconnect";o.href=G;r.appendChild(o)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(n,'"]'))){u("[FONT] ".concat(t," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=n;r.appendChild(i);u("[FONT] ".concat(t," font injected!"))}}}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(o,e,t,n){function i(o){return o instanceof t?o:new t((function(e){e(o)}))}return new(t||(t=Promise))((function(t,r){function s(o){try{a(n.next(o))}catch(o){r(o)}}function l(o){try{a(n["throw"](o))}catch(o){r(o)}}function a(o){o.done?t(o.value):i(o.value).then(s,l)}a((n=n.apply(o,e||[])).next())}))};var __generator=this&&this.__generator||function(o,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,i,r,s;return s={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(o){return function(e){return a([o,e])}}function a(l){if(n)throw new TypeError("Generator is already executing.");while(s&&(s=0,l[0]&&(t=0)),t)try{if(n=1,i&&(r=l[0]&2?i["return"]:l[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,l[1])).done)return r;if(i=0,r)l=[l[0]&2,r.value];switch(l[0]){case 0:case 1:r=l;break;case 4:t.label++;return{value:l[1],done:false};case 5:t.label++;i=l[1];l=[0];continue;case 7:l=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){t.label=l[1];break}if(l[0]===6&&t.label<r[1]){t.label=r[1];r=l;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(l);break}if(r[2])t.ops.pop();t.trys.pop();continue}l=e.call(o,t)}catch(o){l=[6,o];i=0}finally{n=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:true}}};System.register(["./p-02da743b.system.js","./p-1327b935.system.js","./p-4e9c8f9e.system.js","./p-9e9ac7a2.system.js","./p-23e7c655.system.js","./p-1b75aa35.system.js","./p-bc7bf53e.system.js","./p-5a2dd041.system.js"],(function(o){"use strict";var e,t,n,i,r,s,l,a,h,d,u,f,c,w,g,m,v,z,p,b,x;return{setters:[function(o){e=o.r;t=o.h;n=o.H},function(o){i=o.d},function(o){r=o.l;s=o.i;l=o.t;a=o.g;h=o.h;d=o.j;u=o.k;f=o.m;c=o.d},function(o){w=o.z;g=o.g;m=o.m},function(o){v=o.c},function(o){z=o.h;p=o.b;b=o.l},function(o){x=o.g},function(){}],execute:function(){var y=this;var k=function(o){return __awaiter(y,[o],void 0,(function(o){var e,t,n,i,r;var s=o.items,l=o.shipFrom,a=o.shipTo;return __generator(this,(function(o){switch(o.label){case 0:t={items:s,shipFrom:l,shipTo:a};return[4,z("/api/zonos-elements/check-item-restrictions",{body:t,method:"POST"})];case 1:n=o.sent(),i=n.errors,r=n.json;if(i.length||!r){p("Error fetching item restrictions: ".concat((e=i.find(Boolean))===null||e===void 0?void 0:e.message));return[2,[]]}return[2,r.filter(Boolean)]}}))}))};var _=function(o){return __awaiter(y,void 0,void 0,(function(){var e,t,n,i;return __generator(this,(function(s){switch(s.label){case 0:if(!o.length){return[2,[]]}e=r.selectedCountryCode;if(!e){p("Hello could not check item restrictions - No country code selected");return[2,[]]}t=o.map((function(o){return{description:o.description,name:o.title}}));return[4,k({items:t,shipFrom:"AD",shipTo:e})];case 1:n=s.sent();i=n.map((function(o){var e;var n=((e=t.filter((function(e){return e.description===o.itemDescription})).find(Boolean))===null||e===void 0?void 0:e.name)||"";return Object.assign(Object.assign({},o),{name:n})}));return[2,i]}}))}))};var L=function(o){var e=o===null||o===void 0?void 0:o.replace("www.","").replace("https://","");return e&&new RegExp(e).test(window.location.href)};var O=function(){var o=w.helloSettings,e=o.cartUrlPattern,t=o.homepageUrlPattern,n=o.productDetailUrlPattern,i=o.productListUrlPattern;if(L(e)){return"cart"}if(L(n)){return"productDetail"}if(L(i)){return"productList"}if(L(t)){return"home"}return""};var T=function(){var o,e;var t=w.helloSettings,n=t.productAddToCartElementSelector,i=t.productDescriptionElementSelector,r=t.productTitleElementSelector,l=t.restrictionBehavior;if(!r||!i){b("Hello could not check item restrictions - must provide title and description selectors.")}var a=r&&s(r)&&document.querySelectorAll(r)||[];var h=i&&s(i)&&document.querySelectorAll(i)||[];if(a.length!==h.length){b("Hello could not check item restrictions - Title and description selectors do not match");return[]}var d=l==="RESTRICT_AND_BLOCK";var u=d&&n&&s(n)&&document.querySelectorAll(n)||[];if(d&&u.length!==h.length){b('Hello could not disable "Add to cart" buttons - Title and add to cart selectors do not match')}var f=[];for(var c=0;c<a.length;c++){var g=a[c];var m=h[c];var v=u[c];if(g&&m){var z={cartButtonNode:v||null,description:((o=m.textContent)===null||o===void 0?void 0:o.trim())||"",title:((e=g.textContent)===null||e===void 0?void 0:e.trim())||""};f.push(z)}}return f};var E=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{display:inline-block}:host .zonos--hello-wrapper{position:relative}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper-mobile-override{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}@media (max-width: 768px){:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}}:host .zonos--hello-widget{-webkit-transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);padding:6px;border-radius:30px;background:var(--zonos-elements-page-background);font-size:var(--zonos-elements-font-size-s);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;cursor:pointer;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;position:relative;z-index:1000}:host .zonos--hello-widget>.zonos--hello-message{-ms-flex-order:0;order:0;max-width:0;height:100%;white-space:nowrap;-webkit-transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);overflow:hidden;color:var(--zonos-elements-text-color);position:absolute;background:var(--zonos-elements-page-background);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-top-left-radius:30px;border-bottom-left-radius:30px;left:0;-webkit-transform:translateX(calc(-100% + 16px));transform:translateX(calc(-100% + 16px));width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border-top:var(--zonos-elements-border);border-bottom:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-has-restrictions{background:var(--zonos-elements-red-100);border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-has-restrictions>.zonos--hello-message{background:var(--zonos-elements-red-100);color:var(--zonos-elements-red-800);font-weight:500}:host .zonos--hello-widget.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-show-peek-message{max-width:100vw;width:100%}:host .zonos--hello-widget.zonos--hello-show-peek-message>.zonos--hello-message{max-width:100vw;padding:0 6px;padding-right:16px;border:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-show-peek-message:not(.zonos--hello-widget-animate-from-left)>.zonos--hello-message{border-right:none}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{border-left:0}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:16px;padding-right:6px;border-left:none}:host .zonos--hello-widget.zonos--hello-widget-animate-from-left>.zonos--hello-message{-ms-flex-order:1;order:1;-webkit-transform:translateX(calc(100% - 16px));transform:translateX(calc(100% - 16px));right:0;left:auto;border-top-right-radius:30px;border-bottom-right-radius:30px}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper .zonos--hello-country-flag{height:18px;width:18px;position:relative;overflow:hidden;border-radius:30px;-webkit-box-shadow:var(--zonos-elements-v3-shadow-medium);box-shadow:var(--zonos-elements-v3-shadow-medium);z-index:10;justify-self:center}:host .zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}";var S=E;var j=3e3;var I=o("zonos_hello",function(){function o(o){var t=this;e(this,o);this.showPeekMessage=false;this.zonosStoreHelloSettings=w.helloSettings;this.showDialog=false;this.peekMessage="";this.initialUrl="";this.allRestrictedItems=[];this.allFoundProducts=[];this.productsOnPage=[];this.isHelloWidgetRendered=false;this.isMobile=false;this.getHelloPeekMessage=function(o){var e=w.currentHelloPage==="productDetail"||w.currentHelloPage==="productList";if(e&&t.allRestrictedItems.length){var n=l("click to learn more");var i=w.currentHelloPage==="productDetail"?l("Restricted item"):l("Restricted items found");return"".concat(i," - ").concat(n)}switch(w.currentHelloPage){case"cart":return l("Prepay duties and taxes at checkout");case"productList":case"productDetail":return l("See duty and tax thresholds");default:return l("Welcome to [storeName]",{storeName:o})}};this.enableShowPeekMessage=function(){if(t.peekMessage){t.showPeekMessage=true}};this.getNewItemRestrictions=function(o){return __awaiter(t,void 0,void 0,(function(){var e,t;return __generator(this,(function(n){switch(n.label){case 0:e=w.currentHelloPage==="productDetail"||w.currentHelloPage==="productList";if(!e||w.helloSettings.restrictionBehavior==="DISABLED"){return[2,[]]}return[4,_(o)];case 1:t=n.sent();return[2,t]}}))}))};this.triggerShowPeekMessage=function(){t.peekMessage=t.getHelloPeekMessage(w.organizationName);var o=w.helloSettings,e=o.peekMessageBehavior,n=o.peekMessageDelay;var i=n*1e3;if(e==="ENABLED"){setTimeout((function(){t.enableShowPeekMessage();var o=t.allRestrictedItems.some((function(o){return t.productsOnPage.some((function(e){return e.description===o.itemDescription}))}));if(!o){setTimeout((function(){t.showPeekMessage=false}),j)}}),i)}};this.disableAddToCartButtons=function(){if(t.productsOnPage.length){t.productsOnPage.forEach((function(o){var e,n;var i=t.allRestrictedItems.some((function(e){return e.itemDescription===o.description}));if(i){(e=o.cartButtonNode)===null||e===void 0?void 0:e.setAttribute("disabled","disabled")}else{(n=o.cartButtonNode)===null||n===void 0?void 0:n.removeAttribute("disabled")}}))}};this.handleItemRestrictions=function(){return __awaiter(t,void 0,void 0,(function(){var o,e;var t,n;var i=this;return __generator(this,(function(r){switch(r.label){case 0:this.productsOnPage=T();o=this.productsOnPage.filter((function(o){return!i.allFoundProducts.some((function(e){return e.title===o.title}))}));return[4,this.getNewItemRestrictions(o)];case 1:e=r.sent();(t=this.allRestrictedItems).push.apply(t,e);(n=this.allFoundProducts).push.apply(n,o);this.disableAddToCartButtons();return[2]}}))}))};this.reloadHelloData=function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(o){switch(o.label){case 0:return[4,this.handleItemRestrictions()];case 1:o.sent();this.triggerShowPeekMessage();return[2]}}))}))};this.handleProductCountChange=i((function(){var o=w.helloSettings.productTitleElementSelector;if(o){var e=T();if(t.allFoundProducts.length!==e.length&&window.location.href===t.initialUrl){if(!t.allFoundProducts.length){return}void t.reloadHelloData()}}}),1e3);this.watchProductCountChange=function(){var o=new MutationObserver(t.handleProductCountChange);o.observe(document.body,{childList:true,subtree:true})};this.watchPriceChange=function(){var o=new MutationObserver((function(){return void t.displayCurrency()}));o.observe(document.body,{attributes:true,childList:true,subtree:true})};this.updateHelloOnPageChange=function(){t.watchProductCountChange();setInterval((function(){if(window.location.href!==t.initialUrl){var o=t.initialUrl&&new URL(t.initialUrl);var e=o&&a(o.searchParams);if(e!==r.selectedCountryCode){t.allFoundProducts=[];t.allRestrictedItems=[];t.productsOnPage=[]}t.initialUrl=window.location.href;w.currentHelloPage=O();var n=new URL(window.location.href);var i=a(n.searchParams);if(!i){h(r.selectedCountryCode);return}void t.reloadHelloData()}}),1e3)};this.changeShowDialog=function(o){t.showDialog=o};this.shouldAnimateLeftDesktop=function(){var o=t.helloRef&&getComputedStyle(t.helloRef).position;if(t.helloRef&&o==="relative"){var e=x(t.helloRef);return e}};this.shouldRenderHello=function(o){if(o===void 0){o=true}if(!r.localizationLoaded){return false}var e=w.helloSettings.showForCountries;if(o){if(!r.isShippableCountry){b("Hello: not shippable country - Show for countries: ".concat(e))}}if(e==="ONLY_SHIPPABLE"){return r.isShippableCountry}if(e==="ALL"){return true}return e===null||e===void 0?void 0:e.includes(r.selectedCountryCode||"")}}o.prototype.getCountryList=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){return[2,r.helloCountryList]}))}))};o.prototype.componentWillLoad=function(){var o=this;var e=setInterval((function(){return __awaiter(o,void 0,void 0,(function(){return __generator(this,(function(o){if(!this.helloRef){return[2]}if(w.loadedConfig){this.helloRef.setAttribute("data-zonos-hello-loaded","");this.updateHelloOnPageChange();this.watchPriceChange();this.handleAppearanceSettingsOverrideChange();clearInterval(e)}return[2]}))}))}),100)};o.prototype.displayCurrency=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){if(w.helloSettings.currencyBehavior==="DISABLED"){return[2]}if(!r.exchangeRate){b("Could not display currency. Exchange rate and format data is not available.","warn");return[2]}d();return[2]}))}))};o.prototype.convertAndFormat=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,u(o)]}))}))};o.prototype.convert=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,f(o)]}))}))};o.prototype.format=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,c({amount:o})]}))}))};o.prototype.openHelloDialog=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.changeShowDialog(o);return[2]}))}))};o.prototype.handleResize=function(){this.isMobile=window.innerWidth<=768};o.prototype.handleHelloWidgetInitializedState=function(o){var e=o.countryCode,t=o.currencyCode;var n,i;if(this.isHelloWidgetRendered){return}if(r.selectedCountryCode&&typeof w.helloSettings.onInitSuccess==="function"){this.isHelloWidgetRendered=true;void((i=(n=w.helloSettings).onInitSuccess)===null||i===void 0?void 0:i.call(n,{countryCode:e,currencyCode:t}))}};o.prototype.getHelloLocation=function(){var o=this.mobileLocationOverride||w.helloSettings.mobileLocation;var e=w.helloSettings.desktopLocation;var t=this.isMobile;switch(true){case t:{var n=this.animateFromLeftOverride||(o===null||o===void 0?void 0:o.includes("LEFT"));var i=o===null||o===void 0?void 0:o.includes("TOP");return{isMobileWindow:t,isOnLeft:n,isOnTop:i,shouldFloat:!!o}}default:case!t:{var r=!w.helloSettings.anchorElementSelector&&!!e;var n=this.animateFromLeftOverride||(e===null||e===void 0?void 0:e.includes("LEFT"))||this.shouldAnimateLeftDesktop();var i=e===null||e===void 0?void 0:e.includes("TOP");return{isMobileWindow:t,isOnLeft:n,isOnTop:i,shouldFloat:r}}}};o.prototype.handleAppearanceSettingsOverrideChange=function(){var o;if((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme){this.appearanceSettingsOverride.theme=g(this.appearanceSettingsOverride.theme)}};o.prototype.componentDidLoad=function(){this.isMobile=window.innerWidth<=768};o.prototype.render=function(){var o=this;var e,i;var s=(e=w.helloSettings.excludedUrlPatterns)===null||e===void 0?void 0:e.some((function(o){return o&&new RegExp(o).test(window.location.href)}));if(s){b("Hello is excluded on this url","warn");return null}var l=r.selectedCountryCode,a=r.targetCurrency;var h=this.getHelloLocation(),d=h.isOnLeft,u=h.isOnTop,f=h.shouldFloat;var c=m(w.appearance,this.appearanceSettingsOverride||null);var g=c.theme;var z=(i=this.allRestrictedItems)===null||i===void 0?void 0:i.filter((function(e){return o.productsOnPage.some((function(o){return o.description===e.itemDescription}))}));this.peekMessage=this.getHelloPeekMessage(w.organizationName);var p=this.shouldRenderHello()&&!!l;if(p&&!this.isHelloWidgetRendered){this.handleHelloWidgetInitializedState({countryCode:l,currencyCode:a})}return t(n,{class:"zonos--hello zonos--elements","data-theme":g},p&&t("div",{class:v(["zonos--hello-wrapper",f&&"zonos--hello-widget-float"])},t("button",{class:v(["zonos--hello-widget",this.showPeekMessage&&"zonos--hello-show-peek-message",this.mobileLocationOverride&&"zonos--hello-mobile-override",d&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",u&&"zonos--hello-widget-top",!!this.allRestrictedItems.length&&"zonos--hello-has-restrictions",f&&"zonos--hello-widget-float"]),onClick:function(){void o.changeShowDialog(!o.showDialog)},onMouseEnter:function(){return o.enableShowPeekMessage()},onMouseLeave:function(){return o.showPeekMessage=false},ref:function(e){return e&&(o.helloRef=e)}},t("zonos-text",{class:"zonos--hello-message"},this.peekMessage),l&&t("div",{class:"zonos--hello-country-flag-wrapper"},t("zonos-country-flag",{class:"zonos--hello-country-flag",countryCode:l}))),t("div",{class:v(["zonos--hello-dialog-wrapper",this.mobileLocationOverride&&"zonos--hello-dialog-wrapper-mobile-override",f&&"zonos--hello-widget-float"]),style:{height:this.showDialog?"fit-content":"0px"}},t("zonos-hello-dialog",{animateFromLeftOverride:this.animateFromLeftOverride,appearanceSettings:c,isOpen:this.showDialog,mobileLocationOverride:this.mobileLocationOverride,restrictedItems:z,setIsOpen:this.changeShowDialog}))))};Object.defineProperty(o,"watchers",{get:function(){return{appearanceSettingsOverride:["handleAppearanceSettingsOverrideChange"]}},enumerable:false,configurable:true});return o}());I.style=S}}}));
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(o,e,t,n){function i(o){return o instanceof t?o:new t((function(e){e(o)}))}return new(t||(t=Promise))((function(t,r){function s(o){try{a(n.next(o))}catch(o){r(o)}}function l(o){try{a(n["throw"](o))}catch(o){r(o)}}function a(o){o.done?t(o.value):i(o.value).then(s,l)}a((n=n.apply(o,e||[])).next())}))};var __generator=this&&this.__generator||function(o,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,i,r,s;return s={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(o){return function(e){return a([o,e])}}function a(l){if(n)throw new TypeError("Generator is already executing.");while(s&&(s=0,l[0]&&(t=0)),t)try{if(n=1,i&&(r=l[0]&2?i["return"]:l[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,l[1])).done)return r;if(i=0,r)l=[l[0]&2,r.value];switch(l[0]){case 0:case 1:r=l;break;case 4:t.label++;return{value:l[1],done:false};case 5:t.label++;i=l[1];l=[0];continue;case 7:l=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){t.label=l[1];break}if(l[0]===6&&t.label<r[1]){t.label=r[1];r=l;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(l);break}if(r[2])t.ops.pop();t.trys.pop();continue}l=e.call(o,t)}catch(o){l=[6,o];i=0}finally{n=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:true}}};System.register(["./p-02da743b.system.js","./p-1327b935.system.js","./p-4e9c8f9e.system.js","./p-9e9ac7a2.system.js","./p-23e7c655.system.js","./p-1b75aa35.system.js","./p-bc7bf53e.system.js","./p-5a2dd041.system.js"],(function(o){"use strict";var e,t,n,i,r,s,l,a,h,d,u,f,c,w,v,g,m,z,p,b,x;return{setters:[function(o){e=o.r;t=o.h;n=o.H},function(o){i=o.d},function(o){r=o.l;s=o.i;l=o.t;a=o.g;h=o.h;d=o.j;u=o.k;f=o.m;c=o.d},function(o){w=o.z;v=o.g;g=o.m},function(o){m=o.c},function(o){z=o.h;p=o.b;b=o.l},function(o){x=o.g},function(){}],execute:function(){var y=this;var k=function(o){return __awaiter(y,[o],void 0,(function(o){var e,t,n,i,r;var s=o.items,l=o.shipFrom,a=o.shipTo;return __generator(this,(function(o){switch(o.label){case 0:t={items:s,shipFrom:l,shipTo:a};return[4,z("/api/zonos-elements/check-item-restrictions",{body:t,method:"POST"})];case 1:n=o.sent(),i=n.errors,r=n.json;if(i.length||!r){p("Error fetching item restrictions: ".concat((e=i.find(Boolean))===null||e===void 0?void 0:e.message));return[2,[]]}return[2,r.filter(Boolean)]}}))}))};var _=function(o){return __awaiter(y,void 0,void 0,(function(){var e,t,n,i;return __generator(this,(function(s){switch(s.label){case 0:if(!o.length){return[2,[]]}e=r.selectedCountryCode;if(!e){p("Hello could not check item restrictions - No country code selected");return[2,[]]}t=o.map((function(o){return{description:o.description,name:o.title}}));return[4,k({items:t,shipFrom:"AD",shipTo:e})];case 1:n=s.sent();i=n.map((function(o){var e;var n=((e=t.filter((function(e){return e.description===o.itemDescription})).find(Boolean))===null||e===void 0?void 0:e.name)||"";return Object.assign(Object.assign({},o),{name:n})}));return[2,i]}}))}))};var L=function(o){var e=o===null||o===void 0?void 0:o.replace("www.","").replace("https://","");return e&&new RegExp(e).test(window.location.href)};var O=function(){var o=w.helloSettings,e=o.cartUrlPattern,t=o.homepageUrlPattern,n=o.productDetailUrlPattern,i=o.productListUrlPattern;if(L(e)){return"cart"}if(L(n)){return"productDetail"}if(L(i)){return"productList"}if(L(t)){return"home"}return""};var T=function(){var o,e;var t=w.helloSettings,n=t.productAddToCartElementSelector,i=t.productDescriptionElementSelector,r=t.productTitleElementSelector,l=t.restrictionBehavior;if(!r||!i){b("Hello could not check item restrictions - must provide title and description selectors.")}var a=r&&s(r)&&document.querySelectorAll(r)||[];var h=i&&s(i)&&document.querySelectorAll(i)||[];if(a.length!==h.length){b("Hello could not check item restrictions - Title and description selectors do not match");return[]}var d=l==="RESTRICT_AND_BLOCK";var u=d&&n&&s(n)&&document.querySelectorAll(n)||[];if(d&&u.length!==h.length){b('Hello could not disable "Add to cart" buttons - Title and add to cart selectors do not match')}var f=[];for(var c=0;c<a.length;c++){var v=a[c];var g=h[c];var m=u[c];if(v&&g){var z={cartButtonNode:m||null,description:((o=g.textContent)===null||o===void 0?void 0:o.trim())||"",title:((e=v.textContent)===null||e===void 0?void 0:e.trim())||""};f.push(z)}}return f};var E=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{display:inline-block}:host .zonos--hello-wrapper{position:relative}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper-mobile-override{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}@media (max-width: 768px){:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}}:host .zonos--hello-widget{-webkit-transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);padding:6px;border-radius:30px;background:var(--zonos-elements-page-background);font-size:var(--zonos-elements-font-size-s);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;cursor:pointer;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;position:relative;z-index:1000}:host .zonos--hello-widget>.zonos--hello-message{-ms-flex-order:0;order:0;max-width:0;height:100%;white-space:nowrap;-webkit-transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);overflow:hidden;color:var(--zonos-elements-text-color);position:absolute;background:var(--zonos-elements-page-background);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-top-left-radius:30px;border-bottom-left-radius:30px;left:0;-webkit-transform:translateX(calc(-100% + 16px));transform:translateX(calc(-100% + 16px));width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border-top:var(--zonos-elements-border);border-bottom:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-has-restrictions{background:var(--zonos-elements-red-100);border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-has-restrictions>.zonos--hello-message{background:var(--zonos-elements-red-100);color:var(--zonos-elements-red-800);font-weight:500}:host .zonos--hello-widget.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-show-peek-message{max-width:100vw;width:100%}:host .zonos--hello-widget.zonos--hello-show-peek-message>.zonos--hello-message{max-width:100vw;padding:0 6px;padding-right:16px;border:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-show-peek-message:not(.zonos--hello-widget-animate-from-left)>.zonos--hello-message{border-right:none}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{border-left:0}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:16px;padding-right:6px;border-left:none}:host .zonos--hello-widget.zonos--hello-widget-animate-from-left>.zonos--hello-message{-ms-flex-order:1;order:1;-webkit-transform:translateX(calc(100% - 16px));transform:translateX(calc(100% - 16px));right:0;left:auto;border-top-right-radius:30px;border-bottom-right-radius:30px}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper .zonos--hello-country-flag{height:18px;width:18px;position:relative;overflow:hidden;border-radius:30px;-webkit-box-shadow:var(--zonos-elements-v3-shadow-medium);box-shadow:var(--zonos-elements-v3-shadow-medium);z-index:10;justify-self:center}:host .zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}";var S=E;var j=3e3;var I=o("zonos_hello",function(){function o(o){var t=this;e(this,o);this.showPeekMessage=false;this.zonosStoreHelloSettings=w.helloSettings;this.showDialog=false;this.peekMessage="";this.initialUrl="";this.allRestrictedItems=[];this.allFoundProducts=[];this.productsOnPage=[];this.isHelloWidgetRendered=false;this.isMobile=false;this.getHelloPeekMessage=function(o){var e=w.currentHelloPage==="productDetail"||w.currentHelloPage==="productList";if(e&&t.allRestrictedItems.length){var n=l("click to learn more");var i=w.currentHelloPage==="productDetail"?l("Restricted item"):l("Restricted items found");return"".concat(i," - ").concat(n)}switch(w.currentHelloPage){case"cart":return l("Prepay duties and taxes at checkout");case"productList":case"productDetail":return l("See duty and tax thresholds");default:return l("Welcome to [storeName]",{storeName:o})}};this.enableShowPeekMessage=function(){if(t.peekMessage){t.showPeekMessage=true}};this.getNewItemRestrictions=function(o){return __awaiter(t,void 0,void 0,(function(){var e,t;return __generator(this,(function(n){switch(n.label){case 0:e=w.currentHelloPage==="productDetail"||w.currentHelloPage==="productList";if(!e||w.helloSettings.restrictionBehavior==="DISABLED"){return[2,[]]}return[4,_(o)];case 1:t=n.sent();return[2,t]}}))}))};this.triggerShowPeekMessage=function(){t.peekMessage=t.getHelloPeekMessage(w.organizationName);var o=w.helloSettings,e=o.peekMessageBehavior,n=o.peekMessageDelay;var i=n*1e3;if(e==="ENABLED"){setTimeout((function(){t.enableShowPeekMessage();var o=t.allRestrictedItems.some((function(o){return t.productsOnPage.some((function(e){return e.description===o.itemDescription}))}));if(!o){setTimeout((function(){t.showPeekMessage=false}),j)}}),i)}};this.disableAddToCartButtons=function(){if(t.productsOnPage.length){t.productsOnPage.forEach((function(o){var e,n;var i=t.allRestrictedItems.some((function(e){return e.itemDescription===o.description}));if(i){(e=o.cartButtonNode)===null||e===void 0?void 0:e.setAttribute("disabled","disabled")}else{(n=o.cartButtonNode)===null||n===void 0?void 0:n.removeAttribute("disabled")}}))}};this.handleItemRestrictions=function(){return __awaiter(t,void 0,void 0,(function(){var o,e;var t,n;var i=this;return __generator(this,(function(r){switch(r.label){case 0:this.productsOnPage=T();o=this.productsOnPage.filter((function(o){return!i.allFoundProducts.some((function(e){return e.title===o.title}))}));return[4,this.getNewItemRestrictions(o)];case 1:e=r.sent();(t=this.allRestrictedItems).push.apply(t,e);(n=this.allFoundProducts).push.apply(n,o);this.disableAddToCartButtons();return[2]}}))}))};this.reloadHelloData=function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(o){switch(o.label){case 0:return[4,this.handleItemRestrictions()];case 1:o.sent();this.triggerShowPeekMessage();return[2]}}))}))};this.handleProductCountChange=i((function(){var o=w.helloSettings.productTitleElementSelector;if(o){var e=T();if(t.allFoundProducts.length!==e.length&&window.location.href===t.initialUrl){if(!t.allFoundProducts.length){return}void t.reloadHelloData()}}}),1e3);this.watchProductCountChange=function(){var o;var e=new MutationObserver(t.handleProductCountChange);e.observe(document.body,{childList:true,subtree:true});(o=t.observerWatcher)===null||o===void 0?void 0:o.push(e)};this.watchPriceChange=function(){var o;var e=new MutationObserver((function(){return void t.displayCurrency()}));e.observe(document.body,{attributes:true,childList:true,subtree:true});(o=t.observerWatcher)===null||o===void 0?void 0:o.push(e)};this.updateHelloOnPageChange=function(){t.watchProductCountChange();setInterval((function(){if(window.location.href!==t.initialUrl){var o=t.initialUrl&&new URL(t.initialUrl);var e=o&&a(o.searchParams);if(e!==r.selectedCountryCode){t.allFoundProducts=[];t.allRestrictedItems=[];t.productsOnPage=[]}t.initialUrl=window.location.href;w.currentHelloPage=O();var n=new URL(window.location.href);var i=a(n.searchParams);if(!i){h(r.selectedCountryCode);return}void t.reloadHelloData()}}),1e3)};this.changeShowDialog=function(o){t.showDialog=o};this.shouldAnimateLeftDesktop=function(){var o=t.helloRef&&getComputedStyle(t.helloRef).position;if(t.helloRef&&o==="relative"){var e=x(t.helloRef);return e}};this.shouldRenderHello=function(o){if(o===void 0){o=true}if(!r.localizationLoaded){return false}var e=w.helloSettings.showForCountries;if(o){if(!r.isShippableCountry){b("Hello: not shippable country - Show for countries: ".concat(e))}}if(e==="ONLY_SHIPPABLE"){return r.isShippableCountry}if(e==="ALL"){return true}return e===null||e===void 0?void 0:e.includes(r.selectedCountryCode||"")}}o.prototype.getCountryList=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){return[2,r.helloCountryList]}))}))};o.prototype.componentWillLoad=function(){var o=this;var e=setInterval((function(){return __awaiter(o,void 0,void 0,(function(){return __generator(this,(function(o){if(!this.helloRef){return[2]}if(w.loadedConfig){this.helloRef.setAttribute("data-zonos-hello-loaded","");this.updateHelloOnPageChange();this.watchPriceChange();this.handleAppearanceSettingsOverrideChange();clearInterval(e)}return[2]}))}))}),100)};o.prototype.disconnectedCallback=function(){var o;(o=this.observerWatcher)===null||o===void 0?void 0:o.forEach((function(o){return o.disconnect()}))};o.prototype.displayCurrency=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){if(w.helloSettings.currencyBehavior==="DISABLED"){return[2]}if(!r.exchangeRate){b("Could not display currency. Exchange rate and format data is not available.","warn");return[2]}d();return[2]}))}))};o.prototype.convertAndFormat=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,u(o)]}))}))};o.prototype.convert=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,f(o)]}))}))};o.prototype.format=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,c({amount:o})]}))}))};o.prototype.openHelloDialog=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.changeShowDialog(o);return[2]}))}))};o.prototype.handleResize=function(){this.isMobile=window.innerWidth<=768};o.prototype.handleHelloWidgetInitializedState=function(o){var e=o.countryCode,t=o.currencyCode;var n,i;if(this.isHelloWidgetRendered){return}if(r.selectedCountryCode&&typeof w.helloSettings.onInitSuccess==="function"){this.isHelloWidgetRendered=true;void((i=(n=w.helloSettings).onInitSuccess)===null||i===void 0?void 0:i.call(n,{countryCode:e,currencyCode:t}))}};o.prototype.getHelloLocation=function(){var o=this.mobileLocationOverride||w.helloSettings.mobileLocation;var e=w.helloSettings.desktopLocation;var t=this.isMobile;switch(true){case t:{var n=this.animateFromLeftOverride||(o===null||o===void 0?void 0:o.includes("LEFT"));var i=o===null||o===void 0?void 0:o.includes("TOP");return{isMobileWindow:t,isOnLeft:n,isOnTop:i,shouldFloat:!!o}}default:case!t:{var r=!w.helloSettings.anchorElementSelector&&!!e;var n=this.animateFromLeftOverride||(e===null||e===void 0?void 0:e.includes("LEFT"))||this.shouldAnimateLeftDesktop();var i=e===null||e===void 0?void 0:e.includes("TOP");return{isMobileWindow:t,isOnLeft:n,isOnTop:i,shouldFloat:r}}}};o.prototype.handleAppearanceSettingsOverrideChange=function(){var o;if((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme){this.appearanceSettingsOverride.theme=v(this.appearanceSettingsOverride.theme)}};o.prototype.componentDidLoad=function(){this.isMobile=window.innerWidth<=768};o.prototype.render=function(){var o=this;var e,i;var s=(e=w.helloSettings.excludedUrlPatterns)===null||e===void 0?void 0:e.some((function(o){return o&&new RegExp(o).test(window.location.href)}));if(s){b("Hello is excluded on this url","warn");return null}var l=r.selectedCountryCode,a=r.targetCurrency;var h=this.getHelloLocation(),d=h.isOnLeft,u=h.isOnTop,f=h.shouldFloat;var c=g(w.appearance,this.appearanceSettingsOverride||null);var v=c.theme;var z=(i=this.allRestrictedItems)===null||i===void 0?void 0:i.filter((function(e){return o.productsOnPage.some((function(o){return o.description===e.itemDescription}))}));this.peekMessage=this.getHelloPeekMessage(w.organizationName);var p=this.shouldRenderHello()&&!!l;if(p&&!this.isHelloWidgetRendered){this.handleHelloWidgetInitializedState({countryCode:l,currencyCode:a})}return t(n,{class:"zonos--hello zonos--elements","data-theme":v},p&&t("div",{class:m(["zonos--hello-wrapper",f&&"zonos--hello-widget-float"])},t("button",{class:m(["zonos--hello-widget",this.showPeekMessage&&"zonos--hello-show-peek-message",this.mobileLocationOverride&&"zonos--hello-mobile-override",d&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",u&&"zonos--hello-widget-top",!!this.allRestrictedItems.length&&"zonos--hello-has-restrictions",f&&"zonos--hello-widget-float"]),onClick:function(){void o.changeShowDialog(!o.showDialog)},onMouseEnter:function(){return o.enableShowPeekMessage()},onMouseLeave:function(){return o.showPeekMessage=false},ref:function(e){return e&&(o.helloRef=e)},type:"button"},t("zonos-text",{class:"zonos--hello-message"},this.peekMessage),l&&t("div",{class:"zonos--hello-country-flag-wrapper"},t("zonos-country-flag",{class:"zonos--hello-country-flag",countryCode:l}))),t("div",{class:m(["zonos--hello-dialog-wrapper",this.mobileLocationOverride&&"zonos--hello-dialog-wrapper-mobile-override",f&&"zonos--hello-widget-float"]),style:{height:this.showDialog?"fit-content":"0px"}},t("zonos-hello-dialog",{animateFromLeftOverride:this.animateFromLeftOverride,appearanceSettings:c,isOpen:this.showDialog,mobileLocationOverride:this.mobileLocationOverride,restrictedItems:z,setIsOpen:this.changeShowDialog}))))};Object.defineProperty(o,"watchers",{get:function(){return{appearanceSettingsOverride:["handleAppearanceSettingsOverrideChange"]}},enumerable:false,configurable:true});return o}());I.style=S}}}));
|