@zonos/elements 1.3.13-alpha.0 → 1.3.13-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/zonos-checkout.cjs.entry.js +8 -1
- package/dist/cjs/zonos-controller.cjs.entry.js +43 -3
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +8 -1
- package/dist/collection/components/utils/hello/initHello.js +43 -3
- package/dist/collection/scripts/zonosBase.js +14 -4
- package/dist/components/zonos-checkout.js +8 -1
- package/dist/components/zonos-controller.js +43 -3
- package/dist/esm/zonos-checkout.entry.js +8 -1
- package/dist/esm/zonos-controller.entry.js +43 -3
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/scripts/zonosBase.js +1 -1
- package/dist/types/types/global.d.ts +2 -17
- package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
- package/dist/zonos-elements/p-10dec8e6.entry.js +1 -0
- package/dist/zonos-elements/p-6e81adba.system.js +1 -1
- package/dist/zonos-elements/{p-f254612d.system.entry.js → p-b5f28531.system.entry.js} +1 -1
- package/dist/zonos-elements/p-e55d8394.system.entry.js +1 -0
- package/dist/zonos-elements/p-eb1b1d4a.entry.js +1 -0
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +2 -1
- package/dist/zonos-elements/p-11d1645b.entry.js +0 -1
- package/dist/zonos-elements/p-8f2e4f81.system.entry.js +0 -1
- package/dist/zonos-elements/p-a17fcb0a.entry.js +0 -1
|
@@ -380,6 +380,7 @@ const ZonosCheckout = class {
|
|
|
380
380
|
}
|
|
381
381
|
attachCheckout() {
|
|
382
382
|
const buttonAnchorSelector = zonosStore.zonosStore.checkoutSettings.placeOrderButtonSelector;
|
|
383
|
+
cart.log(`attach checkout ${buttonAnchorSelector}`);
|
|
383
384
|
if (!buttonAnchorSelector) {
|
|
384
385
|
// do nothing if button element is not found
|
|
385
386
|
return;
|
|
@@ -708,7 +709,13 @@ const ZonosCheckout = class {
|
|
|
708
709
|
const defaultMessage = (_a = customMessages.find(x => x.pageName === 'checkout_default')) === null || _a === void 0 ? void 0 : _a.message;
|
|
709
710
|
const localePageEnum = this.getCurrentLocalePageEnum();
|
|
710
711
|
const filteredMessages = customMessages.filter(x => x.pageName === localePageEnum);
|
|
711
|
-
const renderLogo = () =>
|
|
712
|
+
const renderLogo = () => {
|
|
713
|
+
// add timestamp to logo url if it's preview mode so browser won't cache it on the dashboard setting
|
|
714
|
+
const logo = this.preview
|
|
715
|
+
? `${logoUrl}?timestamp=${Date.now()}`
|
|
716
|
+
: logoUrl;
|
|
717
|
+
return (index.h("div", { class: "zonos--logo" }, logo && (index.h("img", { alt: `${zonosStore.zonosStore.organizationName} logo`, src: logo, width: 100 }))));
|
|
718
|
+
};
|
|
712
719
|
const renderTopHeader = () => {
|
|
713
720
|
return (index.h("zonos-v-stack", null, renderLogo(), index.h("zonos-checkout-progress-tabs", { backgroundColor:
|
|
714
721
|
// only use different contrast color when the secondary color is too off with the background in mobile
|
|
@@ -50,19 +50,59 @@ const injectHelloComponent = (anchorElementSelector) => {
|
|
|
50
50
|
}
|
|
51
51
|
return false;
|
|
52
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* Injects the hello mobile wrapper to the DOM and returns the anchor element selector
|
|
55
|
+
* @returns anchor element selector
|
|
56
|
+
*/
|
|
57
|
+
const injectHelloMobileWrapper = ({ position = 'bottom-right', }) => {
|
|
58
|
+
const mobileAnchorSelector = '.zonos--hello-mobile-wrapper';
|
|
59
|
+
const helloMobileWrapper = document.querySelector(mobileAnchorSelector);
|
|
60
|
+
if (helloMobileWrapper) {
|
|
61
|
+
return mobileAnchorSelector;
|
|
62
|
+
}
|
|
63
|
+
const newHelloMobileWrapper = document.createElement('div');
|
|
64
|
+
newHelloMobileWrapper.className = 'zonos--hello-mobile-wrapper';
|
|
65
|
+
newHelloMobileWrapper.style.position = 'fixed';
|
|
66
|
+
if (position === 'top-right') {
|
|
67
|
+
newHelloMobileWrapper.style.top = '72px';
|
|
68
|
+
newHelloMobileWrapper.style.right = '24px';
|
|
69
|
+
}
|
|
70
|
+
if (position === 'top-left') {
|
|
71
|
+
newHelloMobileWrapper.style.top = '72px';
|
|
72
|
+
newHelloMobileWrapper.style.left = '24px';
|
|
73
|
+
}
|
|
74
|
+
if (position === 'bottom-right') {
|
|
75
|
+
newHelloMobileWrapper.style.bottom = '72px';
|
|
76
|
+
newHelloMobileWrapper.style.right = '24px';
|
|
77
|
+
}
|
|
78
|
+
if (position === 'bottom-left') {
|
|
79
|
+
newHelloMobileWrapper.style.bottom = '72px';
|
|
80
|
+
newHelloMobileWrapper.style.left = '24px';
|
|
81
|
+
}
|
|
82
|
+
newHelloMobileWrapper.style.zIndex = '2147483007';
|
|
83
|
+
document.body.appendChild(newHelloMobileWrapper);
|
|
84
|
+
return mobileAnchorSelector;
|
|
85
|
+
};
|
|
53
86
|
const initHello = async (helloSettings) => {
|
|
54
87
|
const { anchorElementSelector } = helloSettings;
|
|
88
|
+
const mobileHelloAnchor = injectHelloMobileWrapper({
|
|
89
|
+
position: 'bottom-right',
|
|
90
|
+
});
|
|
91
|
+
// default to mobile anchor if anchorElementSelector is not provided, so for bigcommerce, we don't need to manually add a anchor every time we onboard a new store
|
|
92
|
+
const helloAnchor = window.Zonos.isBigCommerce
|
|
93
|
+
? anchorElementSelector || mobileHelloAnchor
|
|
94
|
+
: anchorElementSelector;
|
|
55
95
|
// check if checkout button anchor selector user pass in is valid to setup hello
|
|
56
|
-
if (!
|
|
96
|
+
if (!helloAnchor || !cart.isValidSelector(helloAnchor)) {
|
|
57
97
|
cart.logError(`Selector anchorElementSelector "${helloSettings.anchorElementSelector}" is not a valid selector.`);
|
|
58
98
|
return;
|
|
59
99
|
}
|
|
60
100
|
cart.log('Hello init complete');
|
|
61
|
-
const isHelloInjected = injectHelloComponent(
|
|
101
|
+
const isHelloInjected = injectHelloComponent(helloAnchor);
|
|
62
102
|
// keep watching for the anchor element to be added to the DOM, then inject hello component
|
|
63
103
|
if (!isHelloInjected) {
|
|
64
104
|
const observer = new MutationObserver(() => {
|
|
65
|
-
const injected = injectHelloComponent(
|
|
105
|
+
const injected = injectHelloComponent(helloAnchor);
|
|
66
106
|
if (injected) {
|
|
67
107
|
// disconnect observer if hello is successfully injected
|
|
68
108
|
observer.disconnect();
|
|
@@ -110,6 +110,7 @@ export class ZonosCheckout {
|
|
|
110
110
|
}
|
|
111
111
|
attachCheckout() {
|
|
112
112
|
const buttonAnchorSelector = zonosStore.checkoutSettings.placeOrderButtonSelector;
|
|
113
|
+
log(`attach checkout ${buttonAnchorSelector}`);
|
|
113
114
|
if (!buttonAnchorSelector) {
|
|
114
115
|
// do nothing if button element is not found
|
|
115
116
|
return;
|
|
@@ -438,7 +439,13 @@ export class ZonosCheckout {
|
|
|
438
439
|
const defaultMessage = (_a = customMessages.find(x => x.pageName === 'checkout_default')) === null || _a === void 0 ? void 0 : _a.message;
|
|
439
440
|
const localePageEnum = this.getCurrentLocalePageEnum();
|
|
440
441
|
const filteredMessages = customMessages.filter(x => x.pageName === localePageEnum);
|
|
441
|
-
const renderLogo = () =>
|
|
442
|
+
const renderLogo = () => {
|
|
443
|
+
// add timestamp to logo url if it's preview mode so browser won't cache it on the dashboard setting
|
|
444
|
+
const logo = this.preview
|
|
445
|
+
? `${logoUrl}?timestamp=${Date.now()}`
|
|
446
|
+
: logoUrl;
|
|
447
|
+
return (h("div", { class: "zonos--logo" }, logo && (h("img", { alt: `${zonosStore.organizationName} logo`, src: logo, width: 100 }))));
|
|
448
|
+
};
|
|
442
449
|
const renderTopHeader = () => {
|
|
443
450
|
return (h("zonos-v-stack", null, renderLogo(), h("zonos-checkout-progress-tabs", { backgroundColor:
|
|
444
451
|
// only use different contrast color when the secondary color is too off with the background in mobile
|
|
@@ -12,19 +12,59 @@ const injectHelloComponent = (anchorElementSelector) => {
|
|
|
12
12
|
}
|
|
13
13
|
return false;
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Injects the hello mobile wrapper to the DOM and returns the anchor element selector
|
|
17
|
+
* @returns anchor element selector
|
|
18
|
+
*/
|
|
19
|
+
const injectHelloMobileWrapper = ({ position = 'bottom-right', }) => {
|
|
20
|
+
const mobileAnchorSelector = '.zonos--hello-mobile-wrapper';
|
|
21
|
+
const helloMobileWrapper = document.querySelector(mobileAnchorSelector);
|
|
22
|
+
if (helloMobileWrapper) {
|
|
23
|
+
return mobileAnchorSelector;
|
|
24
|
+
}
|
|
25
|
+
const newHelloMobileWrapper = document.createElement('div');
|
|
26
|
+
newHelloMobileWrapper.className = 'zonos--hello-mobile-wrapper';
|
|
27
|
+
newHelloMobileWrapper.style.position = 'fixed';
|
|
28
|
+
if (position === 'top-right') {
|
|
29
|
+
newHelloMobileWrapper.style.top = '72px';
|
|
30
|
+
newHelloMobileWrapper.style.right = '24px';
|
|
31
|
+
}
|
|
32
|
+
if (position === 'top-left') {
|
|
33
|
+
newHelloMobileWrapper.style.top = '72px';
|
|
34
|
+
newHelloMobileWrapper.style.left = '24px';
|
|
35
|
+
}
|
|
36
|
+
if (position === 'bottom-right') {
|
|
37
|
+
newHelloMobileWrapper.style.bottom = '72px';
|
|
38
|
+
newHelloMobileWrapper.style.right = '24px';
|
|
39
|
+
}
|
|
40
|
+
if (position === 'bottom-left') {
|
|
41
|
+
newHelloMobileWrapper.style.bottom = '72px';
|
|
42
|
+
newHelloMobileWrapper.style.left = '24px';
|
|
43
|
+
}
|
|
44
|
+
newHelloMobileWrapper.style.zIndex = '2147483007';
|
|
45
|
+
document.body.appendChild(newHelloMobileWrapper);
|
|
46
|
+
return mobileAnchorSelector;
|
|
47
|
+
};
|
|
15
48
|
export const initHello = async (helloSettings) => {
|
|
16
49
|
const { anchorElementSelector } = helloSettings;
|
|
50
|
+
const mobileHelloAnchor = injectHelloMobileWrapper({
|
|
51
|
+
position: 'bottom-right',
|
|
52
|
+
});
|
|
53
|
+
// default to mobile anchor if anchorElementSelector is not provided, so for bigcommerce, we don't need to manually add a anchor every time we onboard a new store
|
|
54
|
+
const helloAnchor = window.Zonos.isBigCommerce
|
|
55
|
+
? anchorElementSelector || mobileHelloAnchor
|
|
56
|
+
: anchorElementSelector;
|
|
17
57
|
// check if checkout button anchor selector user pass in is valid to setup hello
|
|
18
|
-
if (!
|
|
58
|
+
if (!helloAnchor || !isValidSelector(helloAnchor)) {
|
|
19
59
|
logError(`Selector anchorElementSelector "${helloSettings.anchorElementSelector}" is not a valid selector.`);
|
|
20
60
|
return;
|
|
21
61
|
}
|
|
22
62
|
log('Hello init complete');
|
|
23
|
-
const isHelloInjected = injectHelloComponent(
|
|
63
|
+
const isHelloInjected = injectHelloComponent(helloAnchor);
|
|
24
64
|
// keep watching for the anchor element to be added to the DOM, then inject hello component
|
|
25
65
|
if (!isHelloInjected) {
|
|
26
66
|
const observer = new MutationObserver(() => {
|
|
27
|
-
const injected = injectHelloComponent(
|
|
67
|
+
const injected = injectHelloComponent(helloAnchor);
|
|
28
68
|
if (injected) {
|
|
29
69
|
// disconnect observer if hello is successfully injected
|
|
30
70
|
observer.disconnect();
|
|
@@ -200,10 +200,20 @@ Zonos.injectSentryScript = () => {
|
|
|
200
200
|
script.onload = () => {
|
|
201
201
|
var _b;
|
|
202
202
|
(_b = window.Sentry) === null || _b === void 0 ? void 0 : _b.init({
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
beforeSend(event) {
|
|
204
|
+
var _b, _c, _d, _e, _f, _g;
|
|
205
|
+
// only send error to sentry if it's from zonos production
|
|
206
|
+
const firstExceptionFilename = (_g = (_f = (_e = (_d = (_c = (_b = event.exception) === null || _b === void 0 ? void 0 : _b.values) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.stacktrace) === null || _e === void 0 ? void 0 : _e.frames) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.filename;
|
|
207
|
+
const isZonosProduction = (firstExceptionFilename === null || firstExceptionFilename === void 0 ? void 0 : firstExceptionFilename.includes('js.zonos.com')) ||
|
|
208
|
+
(firstExceptionFilename === null || firstExceptionFilename === void 0 ? void 0 : firstExceptionFilename.includes('@zonos/elements'));
|
|
209
|
+
const isDevelopmentHref = window.location.href.includes('dev.elements') ||
|
|
210
|
+
window.location.href.includes('route.js.zonos.com');
|
|
211
|
+
// don't send error to sentry if the errors are in development href
|
|
212
|
+
if (isZonosProduction && !isDevelopmentHref) {
|
|
213
|
+
return event;
|
|
214
|
+
}
|
|
215
|
+
return null;
|
|
216
|
+
},
|
|
207
217
|
dsn: 'https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760',
|
|
208
218
|
ignoreErrors: ['Failed to load Stripe.js'],
|
|
209
219
|
release: `zonos-elements@${_a.version}`,
|
|
@@ -407,6 +407,7 @@ const ZonosCheckout$1 = /*@__PURE__*/ proxyCustomElement(class ZonosCheckout ext
|
|
|
407
407
|
}
|
|
408
408
|
attachCheckout() {
|
|
409
409
|
const buttonAnchorSelector = zonosStore.checkoutSettings.placeOrderButtonSelector;
|
|
410
|
+
log(`attach checkout ${buttonAnchorSelector}`);
|
|
410
411
|
if (!buttonAnchorSelector) {
|
|
411
412
|
// do nothing if button element is not found
|
|
412
413
|
return;
|
|
@@ -735,7 +736,13 @@ const ZonosCheckout$1 = /*@__PURE__*/ proxyCustomElement(class ZonosCheckout ext
|
|
|
735
736
|
const defaultMessage = (_a = customMessages.find(x => x.pageName === 'checkout_default')) === null || _a === void 0 ? void 0 : _a.message;
|
|
736
737
|
const localePageEnum = this.getCurrentLocalePageEnum();
|
|
737
738
|
const filteredMessages = customMessages.filter(x => x.pageName === localePageEnum);
|
|
738
|
-
const renderLogo = () =>
|
|
739
|
+
const renderLogo = () => {
|
|
740
|
+
// add timestamp to logo url if it's preview mode so browser won't cache it on the dashboard setting
|
|
741
|
+
const logo = this.preview
|
|
742
|
+
? `${logoUrl}?timestamp=${Date.now()}`
|
|
743
|
+
: logoUrl;
|
|
744
|
+
return (h("div", { class: "zonos--logo" }, logo && (h("img", { alt: `${zonosStore.organizationName} logo`, src: logo, width: 100 }))));
|
|
745
|
+
};
|
|
739
746
|
const renderTopHeader = () => {
|
|
740
747
|
return (h("zonos-v-stack", null, renderLogo(), h("zonos-checkout-progress-tabs", { backgroundColor:
|
|
741
748
|
// only use different contrast color when the secondary color is too off with the background in mobile
|
|
@@ -46,19 +46,59 @@ const injectHelloComponent = (anchorElementSelector) => {
|
|
|
46
46
|
}
|
|
47
47
|
return false;
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Injects the hello mobile wrapper to the DOM and returns the anchor element selector
|
|
51
|
+
* @returns anchor element selector
|
|
52
|
+
*/
|
|
53
|
+
const injectHelloMobileWrapper = ({ position = 'bottom-right', }) => {
|
|
54
|
+
const mobileAnchorSelector = '.zonos--hello-mobile-wrapper';
|
|
55
|
+
const helloMobileWrapper = document.querySelector(mobileAnchorSelector);
|
|
56
|
+
if (helloMobileWrapper) {
|
|
57
|
+
return mobileAnchorSelector;
|
|
58
|
+
}
|
|
59
|
+
const newHelloMobileWrapper = document.createElement('div');
|
|
60
|
+
newHelloMobileWrapper.className = 'zonos--hello-mobile-wrapper';
|
|
61
|
+
newHelloMobileWrapper.style.position = 'fixed';
|
|
62
|
+
if (position === 'top-right') {
|
|
63
|
+
newHelloMobileWrapper.style.top = '72px';
|
|
64
|
+
newHelloMobileWrapper.style.right = '24px';
|
|
65
|
+
}
|
|
66
|
+
if (position === 'top-left') {
|
|
67
|
+
newHelloMobileWrapper.style.top = '72px';
|
|
68
|
+
newHelloMobileWrapper.style.left = '24px';
|
|
69
|
+
}
|
|
70
|
+
if (position === 'bottom-right') {
|
|
71
|
+
newHelloMobileWrapper.style.bottom = '72px';
|
|
72
|
+
newHelloMobileWrapper.style.right = '24px';
|
|
73
|
+
}
|
|
74
|
+
if (position === 'bottom-left') {
|
|
75
|
+
newHelloMobileWrapper.style.bottom = '72px';
|
|
76
|
+
newHelloMobileWrapper.style.left = '24px';
|
|
77
|
+
}
|
|
78
|
+
newHelloMobileWrapper.style.zIndex = '2147483007';
|
|
79
|
+
document.body.appendChild(newHelloMobileWrapper);
|
|
80
|
+
return mobileAnchorSelector;
|
|
81
|
+
};
|
|
49
82
|
const initHello = async (helloSettings) => {
|
|
50
83
|
const { anchorElementSelector } = helloSettings;
|
|
84
|
+
const mobileHelloAnchor = injectHelloMobileWrapper({
|
|
85
|
+
position: 'bottom-right',
|
|
86
|
+
});
|
|
87
|
+
// default to mobile anchor if anchorElementSelector is not provided, so for bigcommerce, we don't need to manually add a anchor every time we onboard a new store
|
|
88
|
+
const helloAnchor = window.Zonos.isBigCommerce
|
|
89
|
+
? anchorElementSelector || mobileHelloAnchor
|
|
90
|
+
: anchorElementSelector;
|
|
51
91
|
// check if checkout button anchor selector user pass in is valid to setup hello
|
|
52
|
-
if (!
|
|
92
|
+
if (!helloAnchor || !isValidSelector(helloAnchor)) {
|
|
53
93
|
logError(`Selector anchorElementSelector "${helloSettings.anchorElementSelector}" is not a valid selector.`);
|
|
54
94
|
return;
|
|
55
95
|
}
|
|
56
96
|
log('Hello init complete');
|
|
57
|
-
const isHelloInjected = injectHelloComponent(
|
|
97
|
+
const isHelloInjected = injectHelloComponent(helloAnchor);
|
|
58
98
|
// keep watching for the anchor element to be added to the DOM, then inject hello component
|
|
59
99
|
if (!isHelloInjected) {
|
|
60
100
|
const observer = new MutationObserver(() => {
|
|
61
|
-
const injected = injectHelloComponent(
|
|
101
|
+
const injected = injectHelloComponent(helloAnchor);
|
|
62
102
|
if (injected) {
|
|
63
103
|
// disconnect observer if hello is successfully injected
|
|
64
104
|
observer.disconnect();
|
|
@@ -376,6 +376,7 @@ const ZonosCheckout = class {
|
|
|
376
376
|
}
|
|
377
377
|
attachCheckout() {
|
|
378
378
|
const buttonAnchorSelector = zonosStore.checkoutSettings.placeOrderButtonSelector;
|
|
379
|
+
log(`attach checkout ${buttonAnchorSelector}`);
|
|
379
380
|
if (!buttonAnchorSelector) {
|
|
380
381
|
// do nothing if button element is not found
|
|
381
382
|
return;
|
|
@@ -704,7 +705,13 @@ const ZonosCheckout = class {
|
|
|
704
705
|
const defaultMessage = (_a = customMessages.find(x => x.pageName === 'checkout_default')) === null || _a === void 0 ? void 0 : _a.message;
|
|
705
706
|
const localePageEnum = this.getCurrentLocalePageEnum();
|
|
706
707
|
const filteredMessages = customMessages.filter(x => x.pageName === localePageEnum);
|
|
707
|
-
const renderLogo = () =>
|
|
708
|
+
const renderLogo = () => {
|
|
709
|
+
// add timestamp to logo url if it's preview mode so browser won't cache it on the dashboard setting
|
|
710
|
+
const logo = this.preview
|
|
711
|
+
? `${logoUrl}?timestamp=${Date.now()}`
|
|
712
|
+
: logoUrl;
|
|
713
|
+
return (h("div", { class: "zonos--logo" }, logo && (h("img", { alt: `${zonosStore.organizationName} logo`, src: logo, width: 100 }))));
|
|
714
|
+
};
|
|
708
715
|
const renderTopHeader = () => {
|
|
709
716
|
return (h("zonos-v-stack", null, renderLogo(), h("zonos-checkout-progress-tabs", { backgroundColor:
|
|
710
717
|
// only use different contrast color when the secondary color is too off with the background in mobile
|
|
@@ -46,19 +46,59 @@ const injectHelloComponent = (anchorElementSelector) => {
|
|
|
46
46
|
}
|
|
47
47
|
return false;
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Injects the hello mobile wrapper to the DOM and returns the anchor element selector
|
|
51
|
+
* @returns anchor element selector
|
|
52
|
+
*/
|
|
53
|
+
const injectHelloMobileWrapper = ({ position = 'bottom-right', }) => {
|
|
54
|
+
const mobileAnchorSelector = '.zonos--hello-mobile-wrapper';
|
|
55
|
+
const helloMobileWrapper = document.querySelector(mobileAnchorSelector);
|
|
56
|
+
if (helloMobileWrapper) {
|
|
57
|
+
return mobileAnchorSelector;
|
|
58
|
+
}
|
|
59
|
+
const newHelloMobileWrapper = document.createElement('div');
|
|
60
|
+
newHelloMobileWrapper.className = 'zonos--hello-mobile-wrapper';
|
|
61
|
+
newHelloMobileWrapper.style.position = 'fixed';
|
|
62
|
+
if (position === 'top-right') {
|
|
63
|
+
newHelloMobileWrapper.style.top = '72px';
|
|
64
|
+
newHelloMobileWrapper.style.right = '24px';
|
|
65
|
+
}
|
|
66
|
+
if (position === 'top-left') {
|
|
67
|
+
newHelloMobileWrapper.style.top = '72px';
|
|
68
|
+
newHelloMobileWrapper.style.left = '24px';
|
|
69
|
+
}
|
|
70
|
+
if (position === 'bottom-right') {
|
|
71
|
+
newHelloMobileWrapper.style.bottom = '72px';
|
|
72
|
+
newHelloMobileWrapper.style.right = '24px';
|
|
73
|
+
}
|
|
74
|
+
if (position === 'bottom-left') {
|
|
75
|
+
newHelloMobileWrapper.style.bottom = '72px';
|
|
76
|
+
newHelloMobileWrapper.style.left = '24px';
|
|
77
|
+
}
|
|
78
|
+
newHelloMobileWrapper.style.zIndex = '2147483007';
|
|
79
|
+
document.body.appendChild(newHelloMobileWrapper);
|
|
80
|
+
return mobileAnchorSelector;
|
|
81
|
+
};
|
|
49
82
|
const initHello = async (helloSettings) => {
|
|
50
83
|
const { anchorElementSelector } = helloSettings;
|
|
84
|
+
const mobileHelloAnchor = injectHelloMobileWrapper({
|
|
85
|
+
position: 'bottom-right',
|
|
86
|
+
});
|
|
87
|
+
// default to mobile anchor if anchorElementSelector is not provided, so for bigcommerce, we don't need to manually add a anchor every time we onboard a new store
|
|
88
|
+
const helloAnchor = window.Zonos.isBigCommerce
|
|
89
|
+
? anchorElementSelector || mobileHelloAnchor
|
|
90
|
+
: anchorElementSelector;
|
|
51
91
|
// check if checkout button anchor selector user pass in is valid to setup hello
|
|
52
|
-
if (!
|
|
92
|
+
if (!helloAnchor || !isValidSelector(helloAnchor)) {
|
|
53
93
|
logError(`Selector anchorElementSelector "${helloSettings.anchorElementSelector}" is not a valid selector.`);
|
|
54
94
|
return;
|
|
55
95
|
}
|
|
56
96
|
log('Hello init complete');
|
|
57
|
-
const isHelloInjected = injectHelloComponent(
|
|
97
|
+
const isHelloInjected = injectHelloComponent(helloAnchor);
|
|
58
98
|
// keep watching for the anchor element to be added to the DOM, then inject hello component
|
|
59
99
|
if (!isHelloInjected) {
|
|
60
100
|
const observer = new MutationObserver(() => {
|
|
61
|
-
const injected = injectHelloComponent(
|
|
101
|
+
const injected = injectHelloComponent(helloAnchor);
|
|
62
102
|
if (injected) {
|
|
63
103
|
// disconnect observer if hello is successfully injected
|
|
64
104
|
observer.disconnect();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(o,e,t,n){function s(o){return o instanceof t?o:new t((function(e){e(o)}))}return new(t||(t=Promise))((function(t,r){function c(o){try{a(n.next(o))}catch(o){r(o)}}function i(o){try{a(n["throw"](o))}catch(o){r(o)}}function a(o){o.done?t(o.value):s(o.value).then(c,i)}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,s,r,c;return c={next:i(0),throw:i(1),return:i(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function i(o){return function(e){return a([o,e])}}function a(i){if(n)throw new TypeError("Generator is already executing.");while(c&&(c=0,i[0]&&(t=0)),t)try{if(n=1,s&&(r=i[0]&2?s["return"]:i[0]?s["throw"]||((r=s["return"])&&r.call(s),0):s.next)&&!(r=r.call(s,i[1])).done)return r;if(s=0,r)i=[i[0]&2,r.value];switch(i[0]){case 0:case 1:r=i;break;case 4:t.label++;return{value:i[1],done:false};case 5:t.label++;s=i[1];i=[0];continue;case 7:i=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(i[0]===6||i[0]===2)){t=0;continue}if(i[0]===3&&(!r||i[1]>r[0]&&i[1]<r[3])){t.label=i[1];break}if(i[0]===6&&t.label<r[1]){t.label=r[1];r=i;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(i);break}if(r[2])t.ops.pop();t.trys.pop();continue}i=e.call(o,t)}catch(o){i=[6,o];s=0}finally{n=r=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};import{r as registerInstance,h,F as Fragment,H as Host}from"./index-dd40cc85.js";import{l as localizationStore,a as log,s as stripeStoreGetDomesticShippingSession,b as localizationStoreUpdateSelectedCountryCode,c as stripeStoreCleanupDomesticShippingSession,d as logError,e as stripeStoreSaveDomesticShippingSession,i as initStripeElements,f as cartStore,g as cartStoreUpdateItems,h as cartStoreReset,j as stripeStore,k as stripeStoreInitCheckoutSession,m as cartStoreUpdateToErrorState,t as translate,n as stripeStorePrefetchLandedCost,o as cartStoreNextStep,p as stripeStoreConfirmPayment,q as stripeStoreReset}from"./cart-9f9f26f9.js";import{z as zonosStore,g as getZonosStoreTheme,m as mergeConfig}from"./zonosStore-c4c45591.js";import{c as createCustomEvent,s as submitGtag,t as trackConversionEvent}from"./submitGtag-5847d1a1.js";import{s as sendErrorLog,i as isCheckoutMobile}from"./sendErrorLog-283f65ab.js";import{c as classes}from"./classes-0d95c529.js";import{g as getBorderRadius}from"./getBorderRadius-a89e45fb.js";import{i as isDarkColor}from"./isDarkColor-6bf71e51.js";var objAttribute=function(o){var e=o.key,t=o.value;return t?{key:e,value:t}:null};var getAttributes=function(o){return[objAttribute({key:"brand",value:o.itemBrand}),objAttribute({key:"material",value:o.itemMaterial}),objAttribute({key:"category",value:o.itemCategory}),objAttribute({key:"color",value:o.itemColor}),objAttribute({key:"customization",value:o.itemCustomization}),objAttribute({key:"descriptionDetailed",value:o.itemDescriptionDetailed}),objAttribute({key:"fabricContent",value:o.itemFabricContent}),objAttribute({key:"ltlClass",value:o.itemLtlClass}),objAttribute({key:"pickingLocation",value:o.itemPickingLocation}),objAttribute({key:"shipFromLocation",value:o.itemShipFromLocation}),objAttribute({key:"size",value:o.itemSize}),objAttribute({key:"status",value:o.status})].filter(Boolean)};var getItemWeightUnit=function(o){if(!o){return"POUND"}switch(o.toUpperCase()){case"KG":return"KILOGRAM";case"OZ":return"OUNCE";case"G":return"GRAM";default:return"POUND"}};var getMeasurements=function(o){if(!o){return[]}var e=[];if(o.length){e.push({type:"LENGTH",unitOfMeasure:"INCH",value:o.length})}if(o.width){e.push({type:"WIDTH",unitOfMeasure:"INCH",value:o.width})}if(o.weight){e.push({type:"WEIGHT",unitOfMeasure:getItemWeightUnit(o.weightUnits),value:o.weight})}if(o.height){e.push({type:"HEIGHT",unitOfMeasure:"INCH",value:o.height})}return e};var buildCartItemsByTempCart=function(o){var e;var t=((e=o===null||o===void 0?void 0:o.items)===null||e===void 0?void 0:e.map((function(o){return{amount:o.unitPrice||0,attributes:getAttributes(o),countryOfOrigin:o.countryOfOrigin||undefined,currencyCode:"USD",description:o.itemDescriptionLong||"",imageUrl:o.imageURL||"",itemType:"PHYSICAL_GOOD",measurements:getMeasurements(o),name:o.description||"",productId:o.productId||"",quantity:o.quantity||0,sku:o.sku||""}})))||[];return t};var isShippableCountry=function(o){if(o===void 0){o=true}if(!localizationStore.localizationLoaded){return false}if(!localizationStore.isShippableCountry){document.dispatchEvent(createCustomEvent("legacyCheckoutError","Unable to initiate checkout process in a country where shipping is not available"));if(o){log("Checkout: not shippable country")}return false}return true};var watchBigcommerceDomesticCheckout=function(o){var e=o.domesticRedirectedBtnSelector,t=o.onShippingAddressSessionFound;if(!window.Zonos.isBigCommerce){return}var n=new MutationObserver((function(){return __awaiter(void 0,void 0,void 0,(function(){var o,s,r,c,i;return __generator(this,(function(a){o=document.querySelector(e);s=stripeStoreGetDomesticShippingSession();if(!o&&s){r=document.createElement("button");r.style.display="none";r.id="zonos--domestic-redirected-checkout-button";document.body.appendChild(r);t===null||t===void 0?void 0:t(s);n.disconnect();return[2]}c=document.querySelector('select[name="shippingAddress.countryCode"]');i=document.querySelector("#checkout-shipping-continue");if(!c||!i){return[2]}n.disconnect();i.addEventListener("click",(function(o){return __awaiter(void 0,void 0,void 0,(function(){var e,t,n,s,r,i,a;return __generator(this,(function(u){n=c.value;if(!n){return[2]}localizationStoreUpdateSelectedCountryCode(n);if(!isShippableCountry(false)){stripeStoreCleanupDomesticShippingSession();return[2]}s=document.querySelector("form");if(!s){return[2]}r=new FormData(s);i=document.querySelector("input#addressLine1Input");a={address1:(e=r.get("shippingAddress.address1"))!==null&&e!==void 0?e:i&&i.value,address2:r.get("shippingAddress.address2"),city:r.get("shippingAddress.city"),countryCode:r.get("shippingAddress.countryCode"),firstName:r.get("shippingAddress.firstName"),lastName:r.get("shippingAddress.lastName"),phone:r.get("shippingAddress.phone"),postalCode:r.get("shippingAddress.postalCode"),stateOrProvince:(t=r.get("shippingAddress.stateOrProvince"))!==null&&t!==void 0?t:r.get("shippingAddress.stateOrProvinceCode")};if(Object.values(a).some((function(o){return o===undefined||o===null}))){logError("One or more shipping address field is missing",Object.entries(a));void sendErrorLog({endpoint:"No endpoint, domestic checkout form missing fields",errors:["Bigcommerce: One or more shipping address field is missing in the domestic checkout form",JSON.stringify(Object.entries(a))],metadata:{domain:window.location.hostname,storeId:zonosStore.storeId}});return[2]}stripeStoreSaveDomesticShippingSession({address1:a.address1,address2:a.address2,city:a.city,countryCode:a.countryCode,firstName:a.firstName,lastName:a.lastName,phone:a.phone,postalCode:a.postalCode,state:a.stateOrProvince});o.preventDefault();o.stopPropagation();window.location.href="/";return[2]}))}))}));return[2]}))}))}));n.observe(document.body,{childList:true,subtree:true})};var MessageIcon='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="https://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 4.5C2.25 3.25736 3.25736 2.25 4.5 2.25H13.5C14.7426 2.25 15.75 3.25736 15.75 4.5V10.5C15.75 11.7426 14.7426 12.75 13.5 12.75H8.25C8.01393 12.75 7.79164 12.8611 7.65 13.05L6.3 14.85C5.87508 15.4166 5.2082 15.75 4.5 15.75C3.25736 15.75 2.25 14.7426 2.25 13.5V4.5ZM4.5 3.75C4.08579 3.75 3.75 4.08579 3.75 4.5V13.5C3.75 13.9142 4.08579 14.25 4.5 14.25C4.73607 14.25 4.95836 14.1389 5.1 13.95L6.45 12.15C6.87492 11.5834 7.5418 11.25 8.25 11.25H13.5C13.9142 11.25 14.25 10.9142 14.25 10.5V4.5C14.25 4.08579 13.9142 3.75 13.5 3.75H4.5ZM5.25 6C5.25 5.58579 5.58579 5.25 6 5.25H12C12.4142 5.25 12.75 5.58579 12.75 6C12.75 6.41421 12.4142 6.75 12 6.75H6C5.58579 6.75 5.25 6.41421 5.25 6ZM5.25 9C5.25 8.58579 5.58579 8.25 6 8.25H8.25C8.66421 8.25 9 8.58579 9 9C9 9.41421 8.66421 9.75 8.25 9.75H6C5.58579 9.75 5.25 9.41421 5.25 9Z" fill="#4D505A"/>\n</svg>\n';var RemoveIcon='<svg color="var(--amino-gray-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(--amino-gray-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>';var zonosCheckoutCss=".sc-zonos-checkout-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-checkout-h *.sc-zonos-checkout{font-family:var(--font-family, Inter), Inter}.sc-zonos-checkout-h img.sc-zonos-checkout{max-width:100%}.sc-zonos-checkout-h dl.sc-zonos-checkout,.sc-zonos-checkout-h dd.sc-zonos-checkout,.sc-zonos-checkout-h h1.sc-zonos-checkout,.sc-zonos-checkout-h h2.sc-zonos-checkout,.sc-zonos-checkout-h h3.sc-zonos-checkout,.sc-zonos-checkout-h h4.sc-zonos-checkout,.sc-zonos-checkout-h h5.sc-zonos-checkout,.sc-zonos-checkout-h h6.sc-zonos-checkout,.sc-zonos-checkout-h hr.sc-zonos-checkout,.sc-zonos-checkout-h figure.sc-zonos-checkout,.sc-zonos-checkout-h p.sc-zonos-checkout,.sc-zonos-checkout-h pre.sc-zonos-checkout{margin:0}.sc-zonos-checkout-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar{width:10px}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-track{background:var(--amino-gray-50)}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;border-radius:var(--border-radius, var(--amino-radius-10))}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex:1;flex:1;padding:var(--amino-space-32)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{background-color:var(--primary-color, var(--amino-gray-0));border-right:1px solid var(--amino-gray-200)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{background-color:var(--amino-gray-0)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:100%;max-height:100%;height:100%;overflow:auto;-ms-flex-direction:column;flex-direction:column;background-color:var(--amino-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:var(--amino-space-24);padding-bottom:50px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout img.sc-zonos-checkout{width:150px;min-width:150px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--logo.sc-zonos-checkout{margin-bottom:0}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout zonos-checkout-finish.sc-zonos-checkout{-ms-flex:1;flex:1}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{padding:0 var(--amino-space-8) var(--amino-space-8)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--payment-error-banner.sc-zonos-checkout{margin-top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout{position:relative}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout .zonos--close-button.sc-zonos-checkout{position:absolute;right:var(--amino-space-24);top:var(--amino-space-24);z-index:2}.sc-zonos-checkout-h .zonos--wrapper.sc-zonos-checkout{overflow:auto;max-height:100%;position:relative}.sc-zonos-checkout-h .flex--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;max-height:100%}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--checkout-default-message.sc-zonos-checkout{margin-left:var(--amino-space-76);margin-bottom:var(--amino-space-8)}.preview.sc-zonos-checkout-h{min-width:500px;margin:auto}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{border:var(--amino-border)}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{padding:var(--amino-space-32)}.mobile.sc-zonos-checkout-h{min-width:auto}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:auto;border-radius:0;max-height:100%;height:100%;border:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding:var(--amino-space-12);padding-bottom:var(--amino-space-76)}@media (max-width: 768px){.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding-bottom:var(--amino-space-0)}}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{-ms-flex-order:2;order:2;border-right:none}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex-order:1;order:1;padding-top:var(--amino-space-16)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;border:var(--amino-border);border-radius:var(--border-radius, var(--amino-radius-10));background-color:var(--amino-gray-50);padding:var(--amino-space-12);margin-top:var(--amino-space-32)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--review.sc-zonos-checkout{margin-bottom:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--cart-items.sc-zonos-checkout{margin-top:var(--amino-space-8)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout zonos-checkout-footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{max-height:100%}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:auto}.mobile.sc-zonos-checkout-h .zonos--cart-subtotal.sc-zonos-checkout{margin:0}";var ZonosCheckoutStyle0=zonosCheckoutCss;var ZonosCheckout=function(){function o(o){var e=this;registerInstance(this,o);this.applyStripeTheme=function(){return __awaiter(e,void 0,void 0,(function(){var o,e,t,n,s;return __generator(this,(function(r){switch(r.label){case 0:s=((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme)||zonosStore.appearance.theme;return[4,initStripeElements({overrideBorderRaidus:(e=this.appearanceSettingsOverride)===null||e===void 0?void 0:e.style,overridePrimaryColor:(t=this.appearanceSettingsOverride)===null||t===void 0?void 0:t.colorPrimary,overrideSecondaryColor:(n=this.appearanceSettingsOverride)===null||n===void 0?void 0:n.colorSecondary,overrideTheme:this.isMobile?s:undefined})];case 1:r.sent();return[2]}}))}))};this.getCurrentLocalePageEnum=function(){switch(cartStore.step){case"customer-info":return"checkout_customer_info";case"shipping":return"checkout_shipping_info";case"payment":return"checkout_payment_info";default:return null}};this.appearanceSettingsOverride=undefined;this.preview=false;this.mobile=false;this.defaultAddress=null;this.forceDialogOpen=false;this.open=this.forceDialogOpen;this.stripe=window.Zonos.stripe;this.submitLoading=false;this.paymentError=false;this.collapseReviewMobile=true;this.isAttachError=false;this.isMobile=false;this.zonosReviewRef=undefined;this.storybookPaymentStatusOverride=undefined;this.domesticRedirectedBtnSelector="#zonos--domestic-redirected-checkout-button";this.legacyCheckoutHiddenBtnSelector="#legacy-checkout-hidden-button";this.isLegacyCheckout=false}o.prototype.initCartInfoHandler=function(o){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){e=o.detail;void cartStoreUpdateItems(e);return[2]}))}))};o.prototype.closeDialogHandler=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){submitGtag("zonos-checkout-close");this.open=this.forceDialogOpen||false;if(!this.preview&&cartStore.step==="finish"){cartStoreReset()}cartStore.step="customer-info";return[2]}))}))};o.prototype.buildCartAndInit=function(){return __awaiter(this,void 0,void 0,(function(){var o,e,t;return __generator(this,(function(n){switch(n.label){case 0:if(!window.Zonos.tempCartData)return[3,2];o=buildCartItemsByTempCart(window.Zonos.tempCartData);return[4,cartStoreUpdateItems(o)];case 1:n.sent();return[3,5];case 2:if(!zonosStore.checkoutSettings.buildCartDetail)return[3,5];log("build cart detail");return[4,zonosStore.checkoutSettings.buildCartDetail()];case 3:e=n.sent();return[4,cartStoreUpdateItems(e)];case 4:n.sent();n.label=5;case 5:if(!!stripeStore.clientSecret)return[3,7];return[4,stripeStoreInitCheckoutSession()];case 6:t=n.sent();log("stripeStoreInitCheckoutSession: ".concat(t));if(!t){return[2,false]}n.label=7;case 7:return[4,this.applyStripeTheme()];case 8:n.sent();return[2,true]}}))}))};o.prototype.attachCheckout=function(){var o=this;var e=zonosStore.checkoutSettings.placeOrderButtonSelector;if(!e){return}var t=document.querySelectorAll("".concat(e,", ").concat(this.domesticRedirectedBtnSelector));t.forEach((function(e){var t=e.getAttribute("data-zonos-checkout-attached");if(t){return}e.addEventListener("click",(function(e){return __awaiter(o,void 0,void 0,(function(){var o,t;return __generator(this,(function(n){switch(n.label){case 0:if(!isShippableCountry()){return[2]}e.preventDefault();e.stopPropagation();log("zonos checkout button clicked");stripeStore.isFetchingSession=true;this.open=true;n.label=1;case 1:n.trys.push([1,3,,4]);return[4,this.buildCartAndInit()];case 2:o=n.sent();if(!o){throw new Error("Error building cart")}submitGtag("zonos-checkout-start");void trackConversionEvent("checkout_open");return[3,4];case 3:t=n.sent();stripeStore.isFetchingSession=false;cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[3,4];case 4:return[2]}}))}))}));e.removeAttribute("disabled");e.setAttribute("data-zonos-checkout-attached","true");if(e.matches(o.domesticRedirectedBtnSelector)){e.dispatchEvent(createCustomEvent("click"));stripeStoreCleanupDomesticShippingSession();e.remove()}if(e.matches(o.legacyCheckoutHiddenBtnSelector)){o.isLegacyCheckout=true;e.dispatchEvent(createCustomEvent("click"));e.remove()}}))};o.prototype.appearanceSettingsOverrideChanged=function(){if(!this.appearanceSettingsOverride){return}void this.applyStripeTheme()};o.prototype.useLegacyQueryParam=function(){var o=new URLSearchParams(window.location.search);var e={country:o.get("country"),customerAddress1:o.get("customerAddress1"),customerAddress2:o.get("customerAddress2"),customerCity:o.get("customerCity"),customerEmail:o.get("customerEmail"),customerName:o.get("customerName"),customerPhone:o.get("customerPhone"),customerState:o.get("customerState"),customerZip:o.get("customerZip")};if(!e.customerAddress1||!e.customerCity||!e.customerName||!e.customerPhone||!e.customerState||!e.customerZip||!e.country){return}this.defaultAddress={address:{city:e.customerCity,country:e.country,line1:e.customerAddress1,line2:e.customerAddress2||"",postal_code:e.customerZip,state:e.customerState},name:e.customerName,phone:e.customerPhone}};o.prototype.init=function(){return __awaiter(this,void 0,void 0,(function(){var o,e;var t=this;return __generator(this,(function(n){stripeStore.stripe=window.Zonos.stripe;this.stripe=window.Zonos.stripe;watchBigcommerceDomesticCheckout({domesticRedirectedBtnSelector:this.domesticRedirectedBtnSelector,onShippingAddressSessionFound:function(o){t.defaultAddress={address:{city:o.city,country:o.countryCode,line1:o.address1,line2:o.address2,postal_code:o.postalCode,state:o.state},name:"".concat(o.firstName," ").concat(o.lastName),phone:o.phone}}});if(window.Zonos.tempCartData){this.useLegacyQueryParam()}o=setInterval((function(){var e=window.Zonos.internationalHideSelector;if(!e){clearInterval(o);return}var t=isShippableCountry(false);var n=document.querySelectorAll(e);if(!t){n===null||n===void 0?void 0:n.forEach((function(o){var e=o;var t=e.getAttribute("data-zonos-checkout-original-display")||getComputedStyle(e).display;e.style.display=t||"initial"}));return}n===null||n===void 0?void 0:n.forEach((function(o){var e=o;var t=e.style.display;e.setAttribute("data-zonos-checkout-original-display",t);e.style.display="none"}))}),100);e=setInterval((function(){stripeStore.stripe=window.Zonos.stripe;t.stripe=window.Zonos.stripe;if(!t.stripe){log("waiting for stripe to be loaded");return}if(t.storybookPaymentStatusOverride){clearInterval(e);return}log("init checkout");if(t.preview||t.forceDialogOpen){void t.buildCartAndInit()}else{t.attachCheckout();var o=new MutationObserver((function(){t.attachCheckout()}));o.observe(document.body,{childList:true,subtree:true})}clearInterval(e)}),50);setTimeout((function(){clearInterval(e)}),1e4);return[2]}))}))};o.prototype.setToFinishStep=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){cartStore.step="finish";this.storybookPaymentStatusOverride=o;return[2]}))}))};o.prototype.handleCustomerInfoContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;var e=this;return __generator(this,(function(t){switch(t.label){case 0:this.submitLoading=true;return[4,stripeStorePrefetchLandedCost()];case 1:t.sent();o=setInterval((function(){if(cartStore.landedCostData||!stripeStore.isFetchingLandedCost){if(cartStore.landedCostData){cartStoreNextStep()}e.submitLoading=false;clearInterval(o)}}),500);return[2]}}))}))};o.prototype.handleShippingContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o=this;return __generator(this,(function(e){this.submitLoading=true;setTimeout((function(){cartStoreNextStep();o.submitLoading=false}),500);return[2]}))}))};o.prototype.handleCheckoutPaymentContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;return __generator(this,(function(e){switch(e.label){case 0:this.paymentError=false;this.submitLoading=true;e.label=1;case 1:e.trys.push([1,3,,4]);return[4,stripeStoreConfirmPayment()];case 2:e.sent();cartStoreNextStep();return[3,4];case 3:o=e.sent();logError(o);this.paymentError=true;return[3,4];case 4:this.submitLoading=false;return[2]}}))}))};o.prototype.handleFinishClick=function(){return __awaiter(this,void 0,void 0,(function(){var o,e,t;return __generator(this,(function(n){switch(n.label){case 0:stripeStoreReset();if(!this.preview)return[3,2];cartStore.step="customer-info";return[4,this.init()];case 1:n.sent();return[2];case 2:cartStoreReset();if(this.isLegacyCheckout&&window.Zonos.tempCartData){o=window.Zonos.tempCartData.contShoppingURL;window.location.href=o;return[2]}e=window.location.href;t=e.split("?")[0];window.history.replaceState({},document.title,t);this.open=false;window.location.reload();return[2]}}))}))};o.prototype.handleWindowResize=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};o.prototype.handleMobileChange=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};o.prototype.handleAppearanceSettingsOverrideChange=function(){var o;if((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme){this.appearanceSettingsOverride.theme=getZonosStoreTheme(this.appearanceSettingsOverride.theme)}};o.prototype.componentWillLoad=function(){void this.init();this.isMobile=isCheckoutMobile(this.mobile);this.handleAppearanceSettingsOverrideChange();log("mobile: ".concat(this.isMobile))};o.prototype.disconnectedCallback=function(){stripeStoreReset();cartStoreReset()};o.prototype.render=function(){var o=this;var e;var t=cartStore.step!=="finish"&&cartStore.step!=="error"&&!stripeStore.stripeElements||stripeStore.isFetchingSession;var n=mergeConfig(zonosStore.appearance,this.appearanceSettingsOverride),s=n.colorPrimary,r=n.colorSecondary,c=n.logoUrl,i=n.style;var a=zonosStore.appearance.zonosAttribution==="ENABLED";var u=zonosStore.appearance.theme;var l=s&&isDarkColor(s)?"DARK":"LIGHT";var d=this.isMobile?u:l;var f=!this.isMobile?r:undefined;var m=localizationStore.customMessages;var z=(e=m.find((function(o){return o.pageName==="checkout_default"})))===null||e===void 0?void 0:e.message;var p=this.getCurrentLocalePageEnum();var k=m.filter((function(o){return o.pageName===p}));var v=function(){return h("div",{class:"zonos--logo"},c&&h("img",{alt:"".concat(zonosStore.organizationName," logo"),src:c,width:100}))};var g=function(){return h("zonos-v-stack",null,v(),h("zonos-checkout-progress-tabs",{backgroundColor:o.isMobile?"--amino-gray-0":null}),k.map((function(o){return h("zonos-custom-message",{icon:MessageIcon,message:o.message})})))};var b=function(){return h("div",{class:"zonos--content",style:{"--border-radius":getBorderRadius(i)}},cartStore.step!=="finish"&&cartStore.step!=="error"&&h(Fragment,null,h("div",{class:"zonos--left","data-theme":d,style:{"--primary-color":!o.isMobile?s:""}},!o.isMobile&&g(),cartStore.step==="customer-info"&&h("zonos-customer-info",{continueLoading:o.submitLoading,defaultAddress:o.defaultAddress,onContinueClicked:function(){return o.handleCustomerInfoContinue()},submitBtnColor:f}),cartStore.step==="shipping"&&h("zonos-shipping",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleShippingContinue()},submitBtnColor:f}),cartStore.step==="payment"&&h("zonos-checkout-payment",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleCheckoutPaymentContinue()},paymentError:o.paymentError,submitBtnColor:f})),h("div",{class:"zonos--right","data-theme":u},o.isMobile&&g(),!o.isLegacyCheckout&&h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon}),noBackground:true,onClick:function(){return o.closeDialogHandler()}}),h("div",{class:"flex--wrapper"},h("div",{class:"zonos--wrapper"},h("zonos-review",{collapsed:o.collapseReviewMobile,mobile:o.isMobile,onClick:function(){if(!o.isMobile){return}o.collapseReviewMobile=!o.collapseReviewMobile}}),h("zonos-collapse",{collapsed:o.collapseReviewMobile&&o.isMobile},h("zonos-cart-items",null),o.isMobile&&h("zonos-v-stack",{spacing:16},h("zonos-cart-subtotal",null),h("zonos-custom-message",{class:"zonos--checkout-default-message",icon:MessageIcon,message:z})))),!o.isMobile&&h("zonos-v-stack",{spacing:16},h("zonos-cart-subtotal",null),h("zonos-custom-message",{class:"zonos--checkout-default-message",icon:MessageIcon,message:z}))))),(cartStore.step==="finish"||cartStore.step==="error")&&h("div",{class:"zonos--done","data-theme":u},h("div",{class:"zonos--header"},v(),h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon}),noBackground:true,onClick:function(){return o.handleFinishClick()},theme:u})),h("zonos-checkout-finish",{borderRadius:i,onCloseClick:function(){return o.handleFinishClick()},overrideNotification:cartStore.step==="error"&&!!cartStore.error?Object.assign(Object.assign({},cartStore.error),{type:"error"}):undefined,storybookForceStatus:o.storybookPaymentStatusOverride})),h("zonos-checkout-footer",{"data-theme":u,mobile:o.isMobile,slot:!o.isMobile?"dialog-footer":undefined}))};return h(Host,{class:classes(["zonos--checkout zonos--elements",a&&"has-footer",this.preview&&"preview",this.isMobile&&"mobile"])},this.preview?b():h("zonos-dialog",{borderStyle:i,height:"980px",isLoading:t,mobile:this.isMobile,noBodyPadding:true,noBorder:true,noClickOutside:true,noCloseButton:true,onCloseDialog:function(){return o.closeDialogHandler()},open:this.open,width:"1200px"},b()))};Object.defineProperty(o,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(o,"watchers",{get:function(){return{appearanceSettingsOverride:["appearanceSettingsOverrideChanged","handleAppearanceSettingsOverrideChange"],mobile:["handleMobileChange"]}},enumerable:false,configurable:true});return o}();ZonosCheckout.style=ZonosCheckoutStyle0;export{ZonosCheckout as zonos_checkout};
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(o,e,t,n){function s(o){return o instanceof t?o:new t((function(e){e(o)}))}return new(t||(t=Promise))((function(t,r){function c(o){try{a(n.next(o))}catch(o){r(o)}}function i(o){try{a(n["throw"](o))}catch(o){r(o)}}function a(o){o.done?t(o.value):s(o.value).then(c,i)}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,s,r,c;return c={next:i(0),throw:i(1),return:i(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function i(o){return function(e){return a([o,e])}}function a(i){if(n)throw new TypeError("Generator is already executing.");while(c&&(c=0,i[0]&&(t=0)),t)try{if(n=1,s&&(r=i[0]&2?s["return"]:i[0]?s["throw"]||((r=s["return"])&&r.call(s),0):s.next)&&!(r=r.call(s,i[1])).done)return r;if(s=0,r)i=[i[0]&2,r.value];switch(i[0]){case 0:case 1:r=i;break;case 4:t.label++;return{value:i[1],done:false};case 5:t.label++;s=i[1];i=[0];continue;case 7:i=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(i[0]===6||i[0]===2)){t=0;continue}if(i[0]===3&&(!r||i[1]>r[0]&&i[1]<r[3])){t.label=i[1];break}if(i[0]===6&&t.label<r[1]){t.label=r[1];r=i;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(i);break}if(r[2])t.ops.pop();t.trys.pop();continue}i=e.call(o,t)}catch(o){i=[6,o];s=0}finally{n=r=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};import{r as registerInstance,h,F as Fragment,H as Host}from"./index-dd40cc85.js";import{l as localizationStore,a as log,s as stripeStoreGetDomesticShippingSession,b as localizationStoreUpdateSelectedCountryCode,c as stripeStoreCleanupDomesticShippingSession,d as logError,e as stripeStoreSaveDomesticShippingSession,i as initStripeElements,f as cartStore,g as cartStoreUpdateItems,h as cartStoreReset,j as stripeStore,k as stripeStoreInitCheckoutSession,m as cartStoreUpdateToErrorState,t as translate,n as stripeStorePrefetchLandedCost,o as cartStoreNextStep,p as stripeStoreConfirmPayment,q as stripeStoreReset}from"./cart-9f9f26f9.js";import{z as zonosStore,g as getZonosStoreTheme,m as mergeConfig}from"./zonosStore-c4c45591.js";import{c as createCustomEvent,s as submitGtag,t as trackConversionEvent}from"./submitGtag-5847d1a1.js";import{s as sendErrorLog,i as isCheckoutMobile}from"./sendErrorLog-283f65ab.js";import{c as classes}from"./classes-0d95c529.js";import{g as getBorderRadius}from"./getBorderRadius-a89e45fb.js";import{i as isDarkColor}from"./isDarkColor-6bf71e51.js";var objAttribute=function(o){var e=o.key,t=o.value;return t?{key:e,value:t}:null};var getAttributes=function(o){return[objAttribute({key:"brand",value:o.itemBrand}),objAttribute({key:"material",value:o.itemMaterial}),objAttribute({key:"category",value:o.itemCategory}),objAttribute({key:"color",value:o.itemColor}),objAttribute({key:"customization",value:o.itemCustomization}),objAttribute({key:"descriptionDetailed",value:o.itemDescriptionDetailed}),objAttribute({key:"fabricContent",value:o.itemFabricContent}),objAttribute({key:"ltlClass",value:o.itemLtlClass}),objAttribute({key:"pickingLocation",value:o.itemPickingLocation}),objAttribute({key:"shipFromLocation",value:o.itemShipFromLocation}),objAttribute({key:"size",value:o.itemSize}),objAttribute({key:"status",value:o.status})].filter(Boolean)};var getItemWeightUnit=function(o){if(!o){return"POUND"}switch(o.toUpperCase()){case"KG":return"KILOGRAM";case"OZ":return"OUNCE";case"G":return"GRAM";default:return"POUND"}};var getMeasurements=function(o){if(!o){return[]}var e=[];if(o.length){e.push({type:"LENGTH",unitOfMeasure:"INCH",value:o.length})}if(o.width){e.push({type:"WIDTH",unitOfMeasure:"INCH",value:o.width})}if(o.weight){e.push({type:"WEIGHT",unitOfMeasure:getItemWeightUnit(o.weightUnits),value:o.weight})}if(o.height){e.push({type:"HEIGHT",unitOfMeasure:"INCH",value:o.height})}return e};var buildCartItemsByTempCart=function(o){var e;var t=((e=o===null||o===void 0?void 0:o.items)===null||e===void 0?void 0:e.map((function(o){return{amount:o.unitPrice||0,attributes:getAttributes(o),countryOfOrigin:o.countryOfOrigin||undefined,currencyCode:"USD",description:o.itemDescriptionLong||"",imageUrl:o.imageURL||"",itemType:"PHYSICAL_GOOD",measurements:getMeasurements(o),name:o.description||"",productId:o.productId||"",quantity:o.quantity||0,sku:o.sku||""}})))||[];return t};var isShippableCountry=function(o){if(o===void 0){o=true}if(!localizationStore.localizationLoaded){return false}if(!localizationStore.isShippableCountry){document.dispatchEvent(createCustomEvent("legacyCheckoutError","Unable to initiate checkout process in a country where shipping is not available"));if(o){log("Checkout: not shippable country")}return false}return true};var watchBigcommerceDomesticCheckout=function(o){var e=o.domesticRedirectedBtnSelector,t=o.onShippingAddressSessionFound;if(!window.Zonos.isBigCommerce){return}var n=new MutationObserver((function(){return __awaiter(void 0,void 0,void 0,(function(){var o,s,r,c,i;return __generator(this,(function(a){o=document.querySelector(e);s=stripeStoreGetDomesticShippingSession();if(!o&&s){r=document.createElement("button");r.style.display="none";r.id="zonos--domestic-redirected-checkout-button";document.body.appendChild(r);t===null||t===void 0?void 0:t(s);n.disconnect();return[2]}c=document.querySelector('select[name="shippingAddress.countryCode"]');i=document.querySelector("#checkout-shipping-continue");if(!c||!i){return[2]}n.disconnect();i.addEventListener("click",(function(o){return __awaiter(void 0,void 0,void 0,(function(){var e,t,n,s,r,i,a;return __generator(this,(function(u){n=c.value;if(!n){return[2]}localizationStoreUpdateSelectedCountryCode(n);if(!isShippableCountry(false)){stripeStoreCleanupDomesticShippingSession();return[2]}s=document.querySelector("form");if(!s){return[2]}r=new FormData(s);i=document.querySelector("input#addressLine1Input");a={address1:(e=r.get("shippingAddress.address1"))!==null&&e!==void 0?e:i&&i.value,address2:r.get("shippingAddress.address2"),city:r.get("shippingAddress.city"),countryCode:r.get("shippingAddress.countryCode"),firstName:r.get("shippingAddress.firstName"),lastName:r.get("shippingAddress.lastName"),phone:r.get("shippingAddress.phone"),postalCode:r.get("shippingAddress.postalCode"),stateOrProvince:(t=r.get("shippingAddress.stateOrProvince"))!==null&&t!==void 0?t:r.get("shippingAddress.stateOrProvinceCode")};if(Object.values(a).some((function(o){return o===undefined||o===null}))){logError("One or more shipping address field is missing",Object.entries(a));void sendErrorLog({endpoint:"No endpoint, domestic checkout form missing fields",errors:["Bigcommerce: One or more shipping address field is missing in the domestic checkout form",JSON.stringify(Object.entries(a))],metadata:{domain:window.location.hostname,storeId:zonosStore.storeId}});return[2]}stripeStoreSaveDomesticShippingSession({address1:a.address1,address2:a.address2,city:a.city,countryCode:a.countryCode,firstName:a.firstName,lastName:a.lastName,phone:a.phone,postalCode:a.postalCode,state:a.stateOrProvince});o.preventDefault();o.stopPropagation();window.location.href="/";return[2]}))}))}));return[2]}))}))}));n.observe(document.body,{childList:true,subtree:true})};var MessageIcon='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="https://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 4.5C2.25 3.25736 3.25736 2.25 4.5 2.25H13.5C14.7426 2.25 15.75 3.25736 15.75 4.5V10.5C15.75 11.7426 14.7426 12.75 13.5 12.75H8.25C8.01393 12.75 7.79164 12.8611 7.65 13.05L6.3 14.85C5.87508 15.4166 5.2082 15.75 4.5 15.75C3.25736 15.75 2.25 14.7426 2.25 13.5V4.5ZM4.5 3.75C4.08579 3.75 3.75 4.08579 3.75 4.5V13.5C3.75 13.9142 4.08579 14.25 4.5 14.25C4.73607 14.25 4.95836 14.1389 5.1 13.95L6.45 12.15C6.87492 11.5834 7.5418 11.25 8.25 11.25H13.5C13.9142 11.25 14.25 10.9142 14.25 10.5V4.5C14.25 4.08579 13.9142 3.75 13.5 3.75H4.5ZM5.25 6C5.25 5.58579 5.58579 5.25 6 5.25H12C12.4142 5.25 12.75 5.58579 12.75 6C12.75 6.41421 12.4142 6.75 12 6.75H6C5.58579 6.75 5.25 6.41421 5.25 6ZM5.25 9C5.25 8.58579 5.58579 8.25 6 8.25H8.25C8.66421 8.25 9 8.58579 9 9C9 9.41421 8.66421 9.75 8.25 9.75H6C5.58579 9.75 5.25 9.41421 5.25 9Z" fill="#4D505A"/>\n</svg>\n';var RemoveIcon='<svg color="var(--amino-gray-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(--amino-gray-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>';var zonosCheckoutCss=".sc-zonos-checkout-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-checkout-h *.sc-zonos-checkout{font-family:var(--font-family, Inter), Inter}.sc-zonos-checkout-h img.sc-zonos-checkout{max-width:100%}.sc-zonos-checkout-h dl.sc-zonos-checkout,.sc-zonos-checkout-h dd.sc-zonos-checkout,.sc-zonos-checkout-h h1.sc-zonos-checkout,.sc-zonos-checkout-h h2.sc-zonos-checkout,.sc-zonos-checkout-h h3.sc-zonos-checkout,.sc-zonos-checkout-h h4.sc-zonos-checkout,.sc-zonos-checkout-h h5.sc-zonos-checkout,.sc-zonos-checkout-h h6.sc-zonos-checkout,.sc-zonos-checkout-h hr.sc-zonos-checkout,.sc-zonos-checkout-h figure.sc-zonos-checkout,.sc-zonos-checkout-h p.sc-zonos-checkout,.sc-zonos-checkout-h pre.sc-zonos-checkout{margin:0}.sc-zonos-checkout-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar{width:10px}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-track{background:var(--amino-gray-50)}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;border-radius:var(--border-radius, var(--amino-radius-10))}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex:1;flex:1;padding:var(--amino-space-32)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{background-color:var(--primary-color, var(--amino-gray-0));border-right:1px solid var(--amino-gray-200)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{background-color:var(--amino-gray-0)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:100%;max-height:100%;height:100%;overflow:auto;-ms-flex-direction:column;flex-direction:column;background-color:var(--amino-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:var(--amino-space-24);padding-bottom:50px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout img.sc-zonos-checkout{width:150px;min-width:150px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--logo.sc-zonos-checkout{margin-bottom:0}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout zonos-checkout-finish.sc-zonos-checkout{-ms-flex:1;flex:1}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{padding:0 var(--amino-space-8) var(--amino-space-8)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--payment-error-banner.sc-zonos-checkout{margin-top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout{position:relative}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout .zonos--close-button.sc-zonos-checkout{position:absolute;right:var(--amino-space-24);top:var(--amino-space-24);z-index:2}.sc-zonos-checkout-h .zonos--wrapper.sc-zonos-checkout{overflow:auto;max-height:100%;position:relative}.sc-zonos-checkout-h .flex--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;max-height:100%}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--checkout-default-message.sc-zonos-checkout{margin-left:var(--amino-space-76);margin-bottom:var(--amino-space-8)}.preview.sc-zonos-checkout-h{min-width:500px;margin:auto}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{border:var(--amino-border)}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{padding:var(--amino-space-32)}.mobile.sc-zonos-checkout-h{min-width:auto}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:auto;border-radius:0;max-height:100%;height:100%;border:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding:var(--amino-space-12);padding-bottom:var(--amino-space-76)}@media (max-width: 768px){.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding-bottom:var(--amino-space-0)}}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{-ms-flex-order:2;order:2;border-right:none}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex-order:1;order:1;padding-top:var(--amino-space-16)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;border:var(--amino-border);border-radius:var(--border-radius, var(--amino-radius-10));background-color:var(--amino-gray-50);padding:var(--amino-space-12);margin-top:var(--amino-space-32)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--review.sc-zonos-checkout{margin-bottom:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--cart-items.sc-zonos-checkout{margin-top:var(--amino-space-8)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout zonos-checkout-footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{max-height:100%}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:auto}.mobile.sc-zonos-checkout-h .zonos--cart-subtotal.sc-zonos-checkout{margin:0}";var ZonosCheckoutStyle0=zonosCheckoutCss;var ZonosCheckout=function(){function o(o){var e=this;registerInstance(this,o);this.applyStripeTheme=function(){return __awaiter(e,void 0,void 0,(function(){var o,e,t,n,s;return __generator(this,(function(r){switch(r.label){case 0:s=((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme)||zonosStore.appearance.theme;return[4,initStripeElements({overrideBorderRaidus:(e=this.appearanceSettingsOverride)===null||e===void 0?void 0:e.style,overridePrimaryColor:(t=this.appearanceSettingsOverride)===null||t===void 0?void 0:t.colorPrimary,overrideSecondaryColor:(n=this.appearanceSettingsOverride)===null||n===void 0?void 0:n.colorSecondary,overrideTheme:this.isMobile?s:undefined})];case 1:r.sent();return[2]}}))}))};this.getCurrentLocalePageEnum=function(){switch(cartStore.step){case"customer-info":return"checkout_customer_info";case"shipping":return"checkout_shipping_info";case"payment":return"checkout_payment_info";default:return null}};this.appearanceSettingsOverride=undefined;this.preview=false;this.mobile=false;this.defaultAddress=null;this.forceDialogOpen=false;this.open=this.forceDialogOpen;this.stripe=window.Zonos.stripe;this.submitLoading=false;this.paymentError=false;this.collapseReviewMobile=true;this.isAttachError=false;this.isMobile=false;this.zonosReviewRef=undefined;this.storybookPaymentStatusOverride=undefined;this.domesticRedirectedBtnSelector="#zonos--domestic-redirected-checkout-button";this.legacyCheckoutHiddenBtnSelector="#legacy-checkout-hidden-button";this.isLegacyCheckout=false}o.prototype.initCartInfoHandler=function(o){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){e=o.detail;void cartStoreUpdateItems(e);return[2]}))}))};o.prototype.closeDialogHandler=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){submitGtag("zonos-checkout-close");this.open=this.forceDialogOpen||false;if(!this.preview&&cartStore.step==="finish"){cartStoreReset()}cartStore.step="customer-info";return[2]}))}))};o.prototype.buildCartAndInit=function(){return __awaiter(this,void 0,void 0,(function(){var o,e,t;return __generator(this,(function(n){switch(n.label){case 0:if(!window.Zonos.tempCartData)return[3,2];o=buildCartItemsByTempCart(window.Zonos.tempCartData);return[4,cartStoreUpdateItems(o)];case 1:n.sent();return[3,5];case 2:if(!zonosStore.checkoutSettings.buildCartDetail)return[3,5];log("build cart detail");return[4,zonosStore.checkoutSettings.buildCartDetail()];case 3:e=n.sent();return[4,cartStoreUpdateItems(e)];case 4:n.sent();n.label=5;case 5:if(!!stripeStore.clientSecret)return[3,7];return[4,stripeStoreInitCheckoutSession()];case 6:t=n.sent();log("stripeStoreInitCheckoutSession: ".concat(t));if(!t){return[2,false]}n.label=7;case 7:return[4,this.applyStripeTheme()];case 8:n.sent();return[2,true]}}))}))};o.prototype.attachCheckout=function(){var o=this;var e=zonosStore.checkoutSettings.placeOrderButtonSelector;log("attach checkout ".concat(e));if(!e){return}var t=document.querySelectorAll("".concat(e,", ").concat(this.domesticRedirectedBtnSelector));t.forEach((function(e){var t=e.getAttribute("data-zonos-checkout-attached");if(t){return}e.addEventListener("click",(function(e){return __awaiter(o,void 0,void 0,(function(){var o,t;return __generator(this,(function(n){switch(n.label){case 0:if(!isShippableCountry()){return[2]}e.preventDefault();e.stopPropagation();log("zonos checkout button clicked");stripeStore.isFetchingSession=true;this.open=true;n.label=1;case 1:n.trys.push([1,3,,4]);return[4,this.buildCartAndInit()];case 2:o=n.sent();if(!o){throw new Error("Error building cart")}submitGtag("zonos-checkout-start");void trackConversionEvent("checkout_open");return[3,4];case 3:t=n.sent();stripeStore.isFetchingSession=false;cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[3,4];case 4:return[2]}}))}))}));e.removeAttribute("disabled");e.setAttribute("data-zonos-checkout-attached","true");if(e.matches(o.domesticRedirectedBtnSelector)){e.dispatchEvent(createCustomEvent("click"));stripeStoreCleanupDomesticShippingSession();e.remove()}if(e.matches(o.legacyCheckoutHiddenBtnSelector)){o.isLegacyCheckout=true;e.dispatchEvent(createCustomEvent("click"));e.remove()}}))};o.prototype.appearanceSettingsOverrideChanged=function(){if(!this.appearanceSettingsOverride){return}void this.applyStripeTheme()};o.prototype.useLegacyQueryParam=function(){var o=new URLSearchParams(window.location.search);var e={country:o.get("country"),customerAddress1:o.get("customerAddress1"),customerAddress2:o.get("customerAddress2"),customerCity:o.get("customerCity"),customerEmail:o.get("customerEmail"),customerName:o.get("customerName"),customerPhone:o.get("customerPhone"),customerState:o.get("customerState"),customerZip:o.get("customerZip")};if(!e.customerAddress1||!e.customerCity||!e.customerName||!e.customerPhone||!e.customerState||!e.customerZip||!e.country){return}this.defaultAddress={address:{city:e.customerCity,country:e.country,line1:e.customerAddress1,line2:e.customerAddress2||"",postal_code:e.customerZip,state:e.customerState},name:e.customerName,phone:e.customerPhone}};o.prototype.init=function(){return __awaiter(this,void 0,void 0,(function(){var o,e;var t=this;return __generator(this,(function(n){stripeStore.stripe=window.Zonos.stripe;this.stripe=window.Zonos.stripe;watchBigcommerceDomesticCheckout({domesticRedirectedBtnSelector:this.domesticRedirectedBtnSelector,onShippingAddressSessionFound:function(o){t.defaultAddress={address:{city:o.city,country:o.countryCode,line1:o.address1,line2:o.address2,postal_code:o.postalCode,state:o.state},name:"".concat(o.firstName," ").concat(o.lastName),phone:o.phone}}});if(window.Zonos.tempCartData){this.useLegacyQueryParam()}o=setInterval((function(){var e=window.Zonos.internationalHideSelector;if(!e){clearInterval(o);return}var t=isShippableCountry(false);var n=document.querySelectorAll(e);if(!t){n===null||n===void 0?void 0:n.forEach((function(o){var e=o;var t=e.getAttribute("data-zonos-checkout-original-display")||getComputedStyle(e).display;e.style.display=t||"initial"}));return}n===null||n===void 0?void 0:n.forEach((function(o){var e=o;var t=e.style.display;e.setAttribute("data-zonos-checkout-original-display",t);e.style.display="none"}))}),100);e=setInterval((function(){stripeStore.stripe=window.Zonos.stripe;t.stripe=window.Zonos.stripe;if(!t.stripe){log("waiting for stripe to be loaded");return}if(t.storybookPaymentStatusOverride){clearInterval(e);return}log("init checkout");if(t.preview||t.forceDialogOpen){void t.buildCartAndInit()}else{t.attachCheckout();var o=new MutationObserver((function(){t.attachCheckout()}));o.observe(document.body,{childList:true,subtree:true})}clearInterval(e)}),50);setTimeout((function(){clearInterval(e)}),1e4);return[2]}))}))};o.prototype.setToFinishStep=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){cartStore.step="finish";this.storybookPaymentStatusOverride=o;return[2]}))}))};o.prototype.handleCustomerInfoContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;var e=this;return __generator(this,(function(t){switch(t.label){case 0:this.submitLoading=true;return[4,stripeStorePrefetchLandedCost()];case 1:t.sent();o=setInterval((function(){if(cartStore.landedCostData||!stripeStore.isFetchingLandedCost){if(cartStore.landedCostData){cartStoreNextStep()}e.submitLoading=false;clearInterval(o)}}),500);return[2]}}))}))};o.prototype.handleShippingContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o=this;return __generator(this,(function(e){this.submitLoading=true;setTimeout((function(){cartStoreNextStep();o.submitLoading=false}),500);return[2]}))}))};o.prototype.handleCheckoutPaymentContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;return __generator(this,(function(e){switch(e.label){case 0:this.paymentError=false;this.submitLoading=true;e.label=1;case 1:e.trys.push([1,3,,4]);return[4,stripeStoreConfirmPayment()];case 2:e.sent();cartStoreNextStep();return[3,4];case 3:o=e.sent();logError(o);this.paymentError=true;return[3,4];case 4:this.submitLoading=false;return[2]}}))}))};o.prototype.handleFinishClick=function(){return __awaiter(this,void 0,void 0,(function(){var o,e,t;return __generator(this,(function(n){switch(n.label){case 0:stripeStoreReset();if(!this.preview)return[3,2];cartStore.step="customer-info";return[4,this.init()];case 1:n.sent();return[2];case 2:cartStoreReset();if(this.isLegacyCheckout&&window.Zonos.tempCartData){o=window.Zonos.tempCartData.contShoppingURL;window.location.href=o;return[2]}e=window.location.href;t=e.split("?")[0];window.history.replaceState({},document.title,t);this.open=false;window.location.reload();return[2]}}))}))};o.prototype.handleWindowResize=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};o.prototype.handleMobileChange=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};o.prototype.handleAppearanceSettingsOverrideChange=function(){var o;if((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme){this.appearanceSettingsOverride.theme=getZonosStoreTheme(this.appearanceSettingsOverride.theme)}};o.prototype.componentWillLoad=function(){void this.init();this.isMobile=isCheckoutMobile(this.mobile);this.handleAppearanceSettingsOverrideChange();log("mobile: ".concat(this.isMobile))};o.prototype.disconnectedCallback=function(){stripeStoreReset();cartStoreReset()};o.prototype.render=function(){var o=this;var e;var t=cartStore.step!=="finish"&&cartStore.step!=="error"&&!stripeStore.stripeElements||stripeStore.isFetchingSession;var n=mergeConfig(zonosStore.appearance,this.appearanceSettingsOverride),s=n.colorPrimary,r=n.colorSecondary,c=n.logoUrl,i=n.style;var a=zonosStore.appearance.zonosAttribution==="ENABLED";var u=zonosStore.appearance.theme;var l=s&&isDarkColor(s)?"DARK":"LIGHT";var d=this.isMobile?u:l;var f=!this.isMobile?r:undefined;var m=localizationStore.customMessages;var z=(e=m.find((function(o){return o.pageName==="checkout_default"})))===null||e===void 0?void 0:e.message;var p=this.getCurrentLocalePageEnum();var k=m.filter((function(o){return o.pageName===p}));var v=function(){var e=o.preview?"".concat(c,"?timestamp=").concat(Date.now()):c;return h("div",{class:"zonos--logo"},e&&h("img",{alt:"".concat(zonosStore.organizationName," logo"),src:e,width:100}))};var g=function(){return h("zonos-v-stack",null,v(),h("zonos-checkout-progress-tabs",{backgroundColor:o.isMobile?"--amino-gray-0":null}),k.map((function(o){return h("zonos-custom-message",{icon:MessageIcon,message:o.message})})))};var b=function(){return h("div",{class:"zonos--content",style:{"--border-radius":getBorderRadius(i)}},cartStore.step!=="finish"&&cartStore.step!=="error"&&h(Fragment,null,h("div",{class:"zonos--left","data-theme":d,style:{"--primary-color":!o.isMobile?s:""}},!o.isMobile&&g(),cartStore.step==="customer-info"&&h("zonos-customer-info",{continueLoading:o.submitLoading,defaultAddress:o.defaultAddress,onContinueClicked:function(){return o.handleCustomerInfoContinue()},submitBtnColor:f}),cartStore.step==="shipping"&&h("zonos-shipping",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleShippingContinue()},submitBtnColor:f}),cartStore.step==="payment"&&h("zonos-checkout-payment",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleCheckoutPaymentContinue()},paymentError:o.paymentError,submitBtnColor:f})),h("div",{class:"zonos--right","data-theme":u},o.isMobile&&g(),!o.isLegacyCheckout&&h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon}),noBackground:true,onClick:function(){return o.closeDialogHandler()}}),h("div",{class:"flex--wrapper"},h("div",{class:"zonos--wrapper"},h("zonos-review",{collapsed:o.collapseReviewMobile,mobile:o.isMobile,onClick:function(){if(!o.isMobile){return}o.collapseReviewMobile=!o.collapseReviewMobile}}),h("zonos-collapse",{collapsed:o.collapseReviewMobile&&o.isMobile},h("zonos-cart-items",null),o.isMobile&&h("zonos-v-stack",{spacing:16},h("zonos-cart-subtotal",null),h("zonos-custom-message",{class:"zonos--checkout-default-message",icon:MessageIcon,message:z})))),!o.isMobile&&h("zonos-v-stack",{spacing:16},h("zonos-cart-subtotal",null),h("zonos-custom-message",{class:"zonos--checkout-default-message",icon:MessageIcon,message:z}))))),(cartStore.step==="finish"||cartStore.step==="error")&&h("div",{class:"zonos--done","data-theme":u},h("div",{class:"zonos--header"},v(),h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon}),noBackground:true,onClick:function(){return o.handleFinishClick()},theme:u})),h("zonos-checkout-finish",{borderRadius:i,onCloseClick:function(){return o.handleFinishClick()},overrideNotification:cartStore.step==="error"&&!!cartStore.error?Object.assign(Object.assign({},cartStore.error),{type:"error"}):undefined,storybookForceStatus:o.storybookPaymentStatusOverride})),h("zonos-checkout-footer",{"data-theme":u,mobile:o.isMobile,slot:!o.isMobile?"dialog-footer":undefined}))};return h(Host,{class:classes(["zonos--checkout zonos--elements",a&&"has-footer",this.preview&&"preview",this.isMobile&&"mobile"])},this.preview?b():h("zonos-dialog",{borderStyle:i,height:"980px",isLoading:t,mobile:this.isMobile,noBodyPadding:true,noBorder:true,noClickOutside:true,noCloseButton:true,onCloseDialog:function(){return o.closeDialogHandler()},open:this.open,width:"1200px"},b()))};Object.defineProperty(o,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(o,"watchers",{get:function(){return{appearanceSettingsOverride:["appearanceSettingsOverrideChanged","handleAppearanceSettingsOverrideChange"],mobile:["handleMobileChange"]}},enumerable:false,configurable:true});return o}();ZonosCheckout.style=ZonosCheckoutStyle0;export{ZonosCheckout as zonos_checkout};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(t,o,n,e){function r(t){return t instanceof n?t:new n((function(o){o(t)}))}return new(n||(n=Promise))((function(n,i){function s(t){try{u(e.next(t))}catch(t){i(t)}}function a(t){try{u(e["throw"](t))}catch(t){i(t)}}function u(t){t.done?n(t.value):r(t.value).then(s,a)}u((e=e.apply(t,o||[])).next())}))};var __generator=this&&this.__generator||function(t,o){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},e,r,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(t){return function(o){return u([t,o])}}function u(a){if(e)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(n=0)),n)try{if(e=1,r&&(i=a[0]&2?r["return"]:a[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;if(r=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;r=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){n.label=a[1];break}if(a[0]===6&&n.label<i[1]){n.label=i[1];i=a;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(a);break}if(i[2])n.ops.pop();n.trys.pop();continue}a=o.call(t,n)}catch(t){a=[6,t];r=0}finally{e=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,c as createEvent,h,H as Host}from"./index-dd40cc85.js";import{r as handleFetch,d as logError,u as isValidSelector,a as log,j as stripeStore,v as initLocalizationStore,b as localizationStoreUpdateSelectedCountryCode}from"./cart-9f9f26f9.js";import{z as zonosStore,b as zonosStoreInitSetting,d as zonosStoreFontFamily}from"./zonosStore-c4c45591.js";import"./isDarkColor-6bf71e51.js";import"./getBorderRadius-a89e45fb.js";var getZonosSettings=function(){return __awaiter(void 0,void 0,void 0,(function(){var t,o,n,e;return __generator(this,(function(r){switch(r.label){case 0:t="".concat("https://v1.route.js.zonos.com","/api/zonos-elements/zonos-settings");return[4,handleFetch(t)];case 1:o=r.sent(),n=o.errors,e=o.json;if(n.length){logError("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings");return[2,{errors:n,json:null}]}return[2,{errors:[],json:e}]}}))}))};var injectCheckoutElement=function(){var t=document.querySelector("zonos-checkout");if(!t){var o=document.createElement("zonos-checkout");document.body.appendChild(o)}};var initCheckout=function(t){if(!t.placeOrderButtonSelector){return}if(!isValidSelector(t.placeOrderButtonSelector)){logError('Selector checkoutButtonAnchor "'.concat(t.placeOrderButtonSelector,'" is not a valid selector'));return}injectCheckoutElement()};var injectHelloComponent=function(t){var o=document.querySelector(t);var n=document.querySelector("zonos-hello");if(!n&&o){var e=document.createElement("zonos-hello");o.appendChild(e);return true}return false};var initHello=function(t){return __awaiter(void 0,void 0,void 0,(function(){var o,n,e;return __generator(this,(function(
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,o,n,e){function r(t){return t instanceof n?t:new n((function(o){o(t)}))}return new(n||(n=Promise))((function(n,i){function s(t){try{u(e.next(t))}catch(t){i(t)}}function a(t){try{u(e["throw"](t))}catch(t){i(t)}}function u(t){t.done?n(t.value):r(t.value).then(s,a)}u((e=e.apply(t,o||[])).next())}))};var __generator=this&&this.__generator||function(t,o){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},e,r,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(t){return function(o){return u([t,o])}}function u(a){if(e)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(n=0)),n)try{if(e=1,r&&(i=a[0]&2?r["return"]:a[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;if(r=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;r=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){n.label=a[1];break}if(a[0]===6&&n.label<i[1]){n.label=i[1];i=a;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(a);break}if(i[2])n.ops.pop();n.trys.pop();continue}a=o.call(t,n)}catch(t){a=[6,t];r=0}finally{e=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,c as createEvent,h,H as Host}from"./index-dd40cc85.js";import{r as handleFetch,d as logError,u as isValidSelector,a as log,j as stripeStore,v as initLocalizationStore,b as localizationStoreUpdateSelectedCountryCode}from"./cart-9f9f26f9.js";import{z as zonosStore,b as zonosStoreInitSetting,d as zonosStoreFontFamily}from"./zonosStore-c4c45591.js";import"./isDarkColor-6bf71e51.js";import"./getBorderRadius-a89e45fb.js";var getZonosSettings=function(){return __awaiter(void 0,void 0,void 0,(function(){var t,o,n,e;return __generator(this,(function(r){switch(r.label){case 0:t="".concat("https://v1.route.js.zonos.com","/api/zonos-elements/zonos-settings");return[4,handleFetch(t)];case 1:o=r.sent(),n=o.errors,e=o.json;if(n.length){logError("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings");return[2,{errors:n,json:null}]}return[2,{errors:[],json:e}]}}))}))};var injectCheckoutElement=function(){var t=document.querySelector("zonos-checkout");if(!t){var o=document.createElement("zonos-checkout");document.body.appendChild(o)}};var initCheckout=function(t){if(!t.placeOrderButtonSelector){return}if(!isValidSelector(t.placeOrderButtonSelector)){logError('Selector checkoutButtonAnchor "'.concat(t.placeOrderButtonSelector,'" is not a valid selector'));return}injectCheckoutElement()};var injectHelloComponent=function(t){var o=document.querySelector(t);var n=document.querySelector("zonos-hello");if(!n&&o){var e=document.createElement("zonos-hello");o.appendChild(e);return true}return false};var injectHelloMobileWrapper=function(t){var o=t.position,n=o===void 0?"bottom-right":o;var e=".zonos--hello-mobile-wrapper";var r=document.querySelector(e);if(r){return e}var i=document.createElement("div");i.className="zonos--hello-mobile-wrapper";i.style.position="fixed";if(n==="top-right"){i.style.top="72px";i.style.right="24px"}if(n==="top-left"){i.style.top="72px";i.style.left="24px"}if(n==="bottom-right"){i.style.bottom="72px";i.style.right="24px"}if(n==="bottom-left"){i.style.bottom="72px";i.style.left="24px"}i.style.zIndex="2147483007";document.body.appendChild(i);return e};var initHello=function(t){return __awaiter(void 0,void 0,void 0,(function(){var o,n,e,r,i;return __generator(this,(function(s){o=t.anchorElementSelector;n=injectHelloMobileWrapper({position:"bottom-right"});e=window.Zonos.isBigCommerce?o||n:o;if(!e||!isValidSelector(e)){logError('Selector anchorElementSelector "'.concat(t.anchorElementSelector,'" is not a valid selector.'));return[2]}log("Hello init complete");r=injectHelloComponent(e);if(!r){i=new MutationObserver((function(){var t=injectHelloComponent(e);if(t){i.disconnect()}}));i.observe(document.body,{childList:true,subtree:true});setTimeout((function(){i.disconnect()}),5e3)}return[2]}))}))};var zonosControllerCss=":host{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--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{visibility:hidden;opacity:0;height:0}";var ZonosControllerStyle0=zonosControllerCss;var ZonosController=function(){function t(t){registerInstance(this,t);this.stripeInitEvent=createEvent(this,"stripeInitEvent",7);this.config=undefined;this.zonosApiKey=undefined}t.prototype.initCheckoutElement=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){if(!t){log("Stripe is not loaded yet - cannot init checkout element","warn");return[2]}stripeStore.stripe=t;void initCheckout(zonosStore.checkoutSettings);log("init checkout element");return[2]}))}))};t.prototype.initZonosNotification=function(){var t=document.querySelector("zonos-notification");if(t){return}var o=document.createElement("zonos-notification");document.body.appendChild(o)};t.prototype.setupGoogleFont=function(t){return __awaiter(this,void 0,void 0,(function(){var o,n,e,r,i,s,a,u;return __generator(this,(function(c){switch(c.label){case 0:e=t||zonosStoreFontFamily();if(e==="Inter"){if(!t){return[2]}log("[FONT] Just applied Inter , but no need to inject since we already inject Inter on start","warn");zonosStore.appearance=Object.assign(Object.assign({},zonosStore.appearance),{fontFamily:t})}r="https://v1.route.js.zonos.com";return[4,handleFetch("".concat(r,"/api/zonos-elements/get-font-detail?family=").concat(e))];case 1:i=c.sent(),s=i.errors,a=i.json;if(s.length>0||!a){log("Failed to load font ".concat(e),"warn");return[2]}u=a.fontUrl;(n=(o=window.Zonos).injectSupportGoogleFont)===null||n===void 0?void 0:n.call(o,u);if(!t){return[2]}log("[FONT] ".concat(t," font override applied"));zonosStore.appearance=Object.assign(Object.assign({},zonosStore.appearance),{fontFamily:t});return[2]}}))}))};t.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(o){zonosStore.zonosApiKey=this.zonosApiKey;(function(){return __awaiter(t,void 0,void 0,(function(){var t,o,n,e,r,i;return __generator(this,(function(s){switch(s.label){case 0:return[4,getZonosSettings()];case 1:n=s.sent(),e=n.errors,r=n.json;if(((t=e[0])===null||t===void 0?void 0:t.type.toString())==="403"){log("Failed to load zonos settings. This domain may not have access","warn");return[2]}this.initZonosNotification();zonosStoreInitSetting({overrideSettings:this.config,zonosSettings:r});void this.setupGoogleFont();if(zonosStore.helloSettings){void initHello(zonosStore.helloSettings)}return[4,initLocalizationStore()];case 2:s.sent();i=((o=r===null||r===void 0?void 0:r.checkoutSettings)===null||o===void 0?void 0:o.externalServiceTokens.find((function(t){return t.type==="STRIPE_PUBLISHABLE_TOKEN"})))||null;if(!i||!this.stripeInitEvent){log("Checkout failed to load -- missing publishable key","warn");return[2]}if(zonosStore.checkoutSettings.subscriptionStatus==="INACTIVE"){log('=== Checkout subscription is "INACTIVE" - Cancel initializing for Checkout ===',"warn");log("zonos controller loaded");return[2]}if(zonosStore.checkoutSettings.visibilityStatus==="DISABLED"){log("=== Checkout is disabled by store owner ===","warn");log("zonos controller loaded");return[2]}this.stripeInitEvent.emit({publishableKey:i.token});log("zonos controller loaded");return[2]}}))}))})();return[2]}))}))};t.prototype.showNotification=function(t){return __awaiter(this,void 0,void 0,(function(){var o;return __generator(this,(function(n){o=document.querySelector("zonos-notification");if(!o){log("Failed to show notification - zonos-notification not found","warn");return[2]}void o.showNotification(t);return[2]}))}))};t.prototype.overrideConfig=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){zonosStoreInitSetting({overrideSettings:t,zonosSettings:null});return[2]}))}))};t.prototype.overrideCountry=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){void localizationStoreUpdateSelectedCountryCode(t);return[2]}))}))};t.prototype.getAppearanceSetting=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,zonosStore.appearance]}))}))};t.prototype.updateOrganizationName=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){zonosStore.organizationName=t;return[2]}))}))};t.prototype.render=function(){return h(Host,{key:"bd56d32009707ec9042ae5f8a87de7a7cedcca73",class:"zonos--elements"})};return t}();ZonosController.style=ZonosControllerStyle0;export{ZonosController as zonos_controller};
|