@zonos/elements 1.3.183 → 1.3.184

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.
Files changed (37) hide show
  1. package/dist/cjs/index.cjs.js +29 -8
  2. package/dist/cjs/zonos-checkout.cjs.entry.js +15 -3
  3. package/dist/cjs/zonos-controller.cjs.entry.js +8 -1
  4. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +15 -3
  5. package/dist/collection/components/utils/checkout/initCheckout.js +8 -1
  6. package/dist/collection/scripts/_zonosBase.js +22 -1
  7. package/dist/collection/types/generated/graphql.frontend.types.js +2 -0
  8. package/dist/collection/types/generated/graphql.internal.types.js +33 -0
  9. package/dist/esm/index.js +29 -8
  10. package/dist/esm/zonos-checkout.entry.js +15 -3
  11. package/dist/esm/zonos-controller.entry.js +8 -1
  12. package/dist/esm-es5/index.js +1 -1
  13. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  14. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  15. package/dist/scripts/index.d.ts +7 -0
  16. package/dist/scripts/index.js +1 -1
  17. package/dist/scripts/loadZonos.js +1 -1
  18. package/dist/scripts/zonos.js +1 -1
  19. package/dist/types/types/checkout/CheckoutConfig.d.ts +7 -0
  20. package/dist/types/types/generated/graphql.frontend.types.d.ts +2 -0
  21. package/dist/types/types/generated/graphql.frontend.types.ts +3 -0
  22. package/dist/types/types/generated/graphql.internal.types.d.ts +53 -8
  23. package/dist/types/types/generated/graphql.internal.types.ts +63 -8
  24. package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
  25. package/dist/zonos-elements/index.esm.js +1 -1
  26. package/dist/zonos-elements/p-09041efe.entry.js +1 -0
  27. package/dist/zonos-elements/p-16e4cdb1.entry.js +1 -0
  28. package/dist/zonos-elements/p-46f6e5e9.system.js +1 -1
  29. package/dist/zonos-elements/p-642bf613.system.entry.js +1 -0
  30. package/dist/zonos-elements/{p-59e31080.system.js → p-b1020237.system.js} +1 -1
  31. package/dist/zonos-elements/p-d5d39db4.system.entry.js +1 -0
  32. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  33. package/package.json +1 -1
  34. package/dist/zonos-elements/p-358043a2.system.entry.js +0 -1
  35. package/dist/zonos-elements/p-4aca92c5.system.entry.js +0 -1
  36. package/dist/zonos-elements/p-ac889f52.entry.js +0 -1
  37. package/dist/zonos-elements/p-b998494a.entry.js +0 -1
@@ -129,7 +129,7 @@ const getZonosQaUrl = () => {
129
129
  return null;
130
130
  }
131
131
  const qaUrl = extractZonosQaUrl(window.location.href);
132
- const cdnUrl = "https://v1.3.183.js.zonos.com";
132
+ const cdnUrl = "https://v1.3.184.js.zonos.com";
133
133
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
134
134
  if (!qaUrl &&
135
135
  (cdnUrl.includes('test.') ||
@@ -365,10 +365,10 @@ const zonosLoadUrl = (() => {
365
365
  }
366
366
  return null;
367
367
  })();
368
- const ZONOS_URL = "https://v1.3.183.js.zonos.com";
369
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.183";
370
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.183";
371
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.183";
368
+ const ZONOS_URL = "https://v1.3.184.js.zonos.com";
369
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.184";
370
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.184";
371
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.184";
372
372
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
373
373
  const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
374
374
  class Zonos {
@@ -383,7 +383,7 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
383
383
  !!window.location.search.match(/\?.*(&*)zonosConversionTest/);
384
384
  Zonos._paypalMockResponse = null;
385
385
  Zonos.isBigCommerce = false;
386
- Zonos.releaseDate = "1744403359888";
386
+ Zonos.releaseDate = "1745332596232";
387
387
  Zonos.isLegacyCheckout = false;
388
388
  Zonos.domain = typeof window !== 'undefined'
389
389
  ? // domain that embeds the iframe
@@ -400,7 +400,7 @@ Zonos.isNpm = true;
400
400
  Zonos.zonosQaUrl = null;
401
401
  Zonos.zonosQaUrlApi = null;
402
402
  Zonos.trackEventLogs = [];
403
- Zonos.version = `v${"1.3.183"}`;
403
+ Zonos.version = `v${"1.3.184"}`;
404
404
  Zonos.modeAlerted = false;
405
405
  Zonos.cartData = null;
406
406
  Zonos.paypal = null;
@@ -638,7 +638,7 @@ Zonos.restoreNativeBrowserFunctions = () => {
638
638
  document.body.removeChild(overrideIframe);
639
639
  };
640
640
  Zonos.injectController = ({ config, }) => {
641
- var _b;
641
+ var _b, _c;
642
642
  if (document.querySelector('zonos-controller')) {
643
643
  return;
644
644
  }
@@ -663,6 +663,27 @@ Zonos.injectController = ({ config, }) => {
663
663
  subtree: true,
664
664
  });
665
665
  }
666
+ // if alwaysTriggerInternationalCheckoutSelector is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
667
+ if ((_c = config.checkoutSettings) === null || _c === void 0 ? void 0 : _c.alwaysTriggerInternationalCheckoutSelector) {
668
+ const alwaysTriggerInternationalCheckoutSelector = config.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;
669
+ _a.disablePlaceOrderButtons({
670
+ config,
671
+ disable: true,
672
+ placeOrderButtonSelector: alwaysTriggerInternationalCheckoutSelector,
673
+ });
674
+ // create a mutation observer to see if any new elements that match our selector is added to the DOM
675
+ const observer = new MutationObserver(() => {
676
+ _a.disablePlaceOrderButtons({
677
+ config,
678
+ disable: true,
679
+ placeOrderButtonSelector: alwaysTriggerInternationalCheckoutSelector,
680
+ });
681
+ });
682
+ observer.observe(document.body, {
683
+ childList: true,
684
+ subtree: true,
685
+ });
686
+ }
666
687
  const zonosController = document.createElement('zonos-controller');
667
688
  zonosController.config = config;
668
689
  zonosController.zonosApiKey = _a.zonosApiKey || '';
@@ -354,6 +354,7 @@ const ZonosCheckout = class {
354
354
  const currentTime = new Date().getTime();
355
355
  const timeDiff = currentTime - cartCreatedAt;
356
356
  const timeDiffInSeconds = Math.floor(timeDiff / 1000);
357
+ handleFetch.log(`currentTime: ${currentTime} | cartCreatedAt: ${cartCreatedAt}`);
357
358
  handleFetch.log(`Cart has been created for ${timeDiffInSeconds / 60} minutes`);
358
359
  if (zonosStore.zonosStore.checkoutSettings.defaultCartExpiration) {
359
360
  if (timeDiffInSeconds > zonosStore.zonosStore.checkoutSettings.defaultCartExpiration) {
@@ -693,14 +694,19 @@ const ZonosCheckout = class {
693
694
  }
694
695
  attachCheckout() {
695
696
  const buttonAnchorSelector = zonosStore.zonosStore.checkoutSettings.placeOrderButtonSelector;
697
+ const alwaysTriggerInternationalCheckoutSelector = zonosStore.zonosStore.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;
696
698
  handleFetch.log(`attach checkout ${buttonAnchorSelector}`);
699
+ handleFetch.log(`attach checkout to always trigger international checkout selector: ${alwaysTriggerInternationalCheckoutSelector}`);
697
700
  // allow to load checkout if cartData is ready (Checkout can be loaded right away if tempCartUUID is in the URL)
698
- if (!buttonAnchorSelector && !window.Zonos.cartData) {
701
+ if (!buttonAnchorSelector &&
702
+ !alwaysTriggerInternationalCheckoutSelector &&
703
+ !window.Zonos.cartData) {
699
704
  // do nothing if button element is not found
700
705
  return;
701
706
  }
702
707
  const selectors = [
703
708
  buttonAnchorSelector,
709
+ alwaysTriggerInternationalCheckoutSelector,
704
710
  // hidden button for domestic redirected
705
711
  `#${CheckoutConfig.domesticRedirectedBtnSelector}`,
706
712
  // hidden button for legacy checkout facade and when client secret is provided in the query param or session storage when user is redirected from stripe
@@ -722,9 +728,15 @@ const ZonosCheckout = class {
722
728
  var _a;
723
729
  // Start tracking load time
724
730
  const startTime = performance.now();
731
+ const isAlwaysTriggerInternationalCheckout = alwaysTriggerInternationalCheckoutSelector &&
732
+ button.matches(alwaysTriggerInternationalCheckoutSelector);
733
+ const isAnyImmediateTrigger = button.matches(`#${CheckoutConfig.domesticRedirectedBtnSelector}`) ||
734
+ button.matches(`#${CheckoutConfig.checkoutHiddenBtnSelector}`);
725
735
  // Allow no country set for legacy facades. Otherwise enforce it being a shippable country and not disabled.
726
736
  if (!window.Zonos.isLegacyCheckout &&
727
- (!isShippableCountry() || isDisabledCountry())) {
737
+ (!isShippableCountry() || isDisabledCountry()) &&
738
+ !isAlwaysTriggerInternationalCheckout &&
739
+ !isAnyImmediateTrigger) {
728
740
  return;
729
741
  }
730
742
  e.preventDefault();
@@ -827,7 +839,7 @@ const ZonosCheckout = class {
827
839
  }
828
840
  button.setAttribute('data-zonos-checkout-attached', 'true');
829
841
  // if this button is the hidden button, trigger the click event
830
- if (button.matches(CheckoutConfig.domesticRedirectedBtnSelector)) {
842
+ if (button.matches(`#${CheckoutConfig.domesticRedirectedBtnSelector}`)) {
831
843
  button.dispatchEvent(createCustomEvent.createCustomEvent('click'));
832
844
  // cleanup shipping session after button is clicked
833
845
  cart.stripeStoreCleanupDomesticShippingSession();
@@ -35,7 +35,9 @@ const injectCheckoutElement = () => {
35
35
  };
36
36
  const initCheckout = (config) => {
37
37
  // allow to load checkout if cartData is ready (Checkout can be loaded right awaiy if tempCartUUID is in the URL)
38
- if (!config.placeOrderButtonSelector && !window.Zonos.cartData) {
38
+ if (!config.placeOrderButtonSelector &&
39
+ !config.alwaysTriggerInternationalCheckoutSelector &&
40
+ !window.Zonos.cartData) {
39
41
  // do nothing if checkout button anchor is not set
40
42
  return;
41
43
  }
@@ -45,6 +47,11 @@ const initCheckout = (config) => {
45
47
  handleFetch.logError(`Selector checkoutButtonAnchor "${config.placeOrderButtonSelector}" is not a valid selector`);
46
48
  return;
47
49
  }
50
+ if (config.alwaysTriggerInternationalCheckoutSelector &&
51
+ !cart.isValidSelector(config.alwaysTriggerInternationalCheckoutSelector)) {
52
+ handleFetch.logError(`Selector alwaysTriggerInternationalCheckoutSelector "${config.alwaysTriggerInternationalCheckoutSelector}" is not a valid selector`);
53
+ return;
54
+ }
48
55
  injectCheckoutElement();
49
56
  };
50
57
 
@@ -80,6 +80,7 @@ export class ZonosCheckout {
80
80
  const currentTime = new Date().getTime();
81
81
  const timeDiff = currentTime - cartCreatedAt;
82
82
  const timeDiffInSeconds = Math.floor(timeDiff / 1000);
83
+ log(`currentTime: ${currentTime} | cartCreatedAt: ${cartCreatedAt}`);
83
84
  log(`Cart has been created for ${timeDiffInSeconds / 60} minutes`);
84
85
  if (zonosStore.checkoutSettings.defaultCartExpiration) {
85
86
  if (timeDiffInSeconds > zonosStore.checkoutSettings.defaultCartExpiration) {
@@ -419,14 +420,19 @@ export class ZonosCheckout {
419
420
  }
420
421
  attachCheckout() {
421
422
  const buttonAnchorSelector = zonosStore.checkoutSettings.placeOrderButtonSelector;
423
+ const alwaysTriggerInternationalCheckoutSelector = zonosStore.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;
422
424
  log(`attach checkout ${buttonAnchorSelector}`);
425
+ log(`attach checkout to always trigger international checkout selector: ${alwaysTriggerInternationalCheckoutSelector}`);
423
426
  // allow to load checkout if cartData is ready (Checkout can be loaded right away if tempCartUUID is in the URL)
424
- if (!buttonAnchorSelector && !window.Zonos.cartData) {
427
+ if (!buttonAnchorSelector &&
428
+ !alwaysTriggerInternationalCheckoutSelector &&
429
+ !window.Zonos.cartData) {
425
430
  // do nothing if button element is not found
426
431
  return;
427
432
  }
428
433
  const selectors = [
429
434
  buttonAnchorSelector,
435
+ alwaysTriggerInternationalCheckoutSelector,
430
436
  // hidden button for domestic redirected
431
437
  `#${domesticRedirectedBtnSelector}`,
432
438
  // hidden button for legacy checkout facade and when client secret is provided in the query param or session storage when user is redirected from stripe
@@ -448,9 +454,15 @@ export class ZonosCheckout {
448
454
  var _a;
449
455
  // Start tracking load time
450
456
  const startTime = performance.now();
457
+ const isAlwaysTriggerInternationalCheckout = alwaysTriggerInternationalCheckoutSelector &&
458
+ button.matches(alwaysTriggerInternationalCheckoutSelector);
459
+ const isAnyImmediateTrigger = button.matches(`#${domesticRedirectedBtnSelector}`) ||
460
+ button.matches(`#${checkoutHiddenBtnSelector}`);
451
461
  // Allow no country set for legacy facades. Otherwise enforce it being a shippable country and not disabled.
452
462
  if (!window.Zonos.isLegacyCheckout &&
453
- (!isShippableCountry() || isDisabledCountry())) {
463
+ (!isShippableCountry() || isDisabledCountry()) &&
464
+ !isAlwaysTriggerInternationalCheckout &&
465
+ !isAnyImmediateTrigger) {
454
466
  return;
455
467
  }
456
468
  e.preventDefault();
@@ -553,7 +565,7 @@ export class ZonosCheckout {
553
565
  }
554
566
  button.setAttribute('data-zonos-checkout-attached', 'true');
555
567
  // if this button is the hidden button, trigger the click event
556
- if (button.matches(domesticRedirectedBtnSelector)) {
568
+ if (button.matches(`#${domesticRedirectedBtnSelector}`)) {
557
569
  button.dispatchEvent(createCustomEvent('click'));
558
570
  // cleanup shipping session after button is clicked
559
571
  stripeStoreCleanupDomesticShippingSession();
@@ -10,7 +10,9 @@ const injectCheckoutElement = () => {
10
10
  };
11
11
  export const initCheckout = (config) => {
12
12
  // allow to load checkout if cartData is ready (Checkout can be loaded right awaiy if tempCartUUID is in the URL)
13
- if (!config.placeOrderButtonSelector && !window.Zonos.cartData) {
13
+ if (!config.placeOrderButtonSelector &&
14
+ !config.alwaysTriggerInternationalCheckoutSelector &&
15
+ !window.Zonos.cartData) {
14
16
  // do nothing if checkout button anchor is not set
15
17
  return;
16
18
  }
@@ -20,5 +22,10 @@ export const initCheckout = (config) => {
20
22
  logError(`Selector checkoutButtonAnchor "${config.placeOrderButtonSelector}" is not a valid selector`);
21
23
  return;
22
24
  }
25
+ if (config.alwaysTriggerInternationalCheckoutSelector &&
26
+ !isValidSelector(config.alwaysTriggerInternationalCheckoutSelector)) {
27
+ logError(`Selector alwaysTriggerInternationalCheckoutSelector "${config.alwaysTriggerInternationalCheckoutSelector}" is not a valid selector`);
28
+ return;
29
+ }
23
30
  injectCheckoutElement();
24
31
  };
@@ -298,7 +298,7 @@ Zonos.restoreNativeBrowserFunctions = () => {
298
298
  document.body.removeChild(overrideIframe);
299
299
  };
300
300
  Zonos.injectController = ({ config, }) => {
301
- var _b;
301
+ var _b, _c;
302
302
  if (document.querySelector('zonos-controller')) {
303
303
  return;
304
304
  }
@@ -323,6 +323,27 @@ Zonos.injectController = ({ config, }) => {
323
323
  subtree: true,
324
324
  });
325
325
  }
326
+ // if alwaysTriggerInternationalCheckoutSelector is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
327
+ if ((_c = config.checkoutSettings) === null || _c === void 0 ? void 0 : _c.alwaysTriggerInternationalCheckoutSelector) {
328
+ const alwaysTriggerInternationalCheckoutSelector = config.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;
329
+ _a.disablePlaceOrderButtons({
330
+ config,
331
+ disable: true,
332
+ placeOrderButtonSelector: alwaysTriggerInternationalCheckoutSelector,
333
+ });
334
+ // create a mutation observer to see if any new elements that match our selector is added to the DOM
335
+ const observer = new MutationObserver(() => {
336
+ _a.disablePlaceOrderButtons({
337
+ config,
338
+ disable: true,
339
+ placeOrderButtonSelector: alwaysTriggerInternationalCheckoutSelector,
340
+ });
341
+ });
342
+ observer.observe(document.body, {
343
+ childList: true,
344
+ subtree: true,
345
+ });
346
+ }
326
347
  const zonosController = document.createElement('zonos-controller');
327
348
  zonosController.config = config;
328
349
  zonosController.zonosApiKey = _a.zonosApiKey || '';
@@ -14,6 +14,7 @@ export const featureAspectKeyEnum = {
14
14
  ClassifySingleRequest: 'classify_single_request',
15
15
  ComConsolidation: 'com_consolidation',
16
16
  DashboardCheckout_2Settings: 'dashboard_checkout_2_settings',
17
+ DashboardChurnedNotification: 'dashboard_churned_notification',
17
18
  DashboardHello_2Settings: 'dashboard_hello_2_settings',
18
19
  DashboardNewLabelUi: 'dashboard_new_label_ui',
19
20
  DashboardOrderApprove: 'dashboard_order_approve',
@@ -40,6 +41,7 @@ export const featureAudienceNameEnum = {
40
41
  ClassifyBulkMerchant: 'classify_bulk_merchant',
41
42
  ClassifyBulkMerchantExportConfidenceScore: 'classify_bulk_merchant_export_confidence_score',
42
43
  CustomerSuccess: 'customer_success',
44
+ DashboardChurnedNotificationMerchant: 'dashboard_churned_notification_merchant',
43
45
  DashboardLabelBetaMerchant: 'dashboard_label_beta_merchant',
44
46
  Designer: 'designer',
45
47
  DocsContributor: 'docs_contributor',
@@ -1615,6 +1615,20 @@ export const itemRestrictionType = {
1615
1615
  Prohibition: 'PROHIBITION',
1616
1616
  Restriction: 'RESTRICTION',
1617
1617
  };
1618
+ export const itemReverseAmountStatus = {
1619
+ Applied: 'APPLIED',
1620
+ NotAppliedNegativeValue: 'NOT_APPLIED_NEGATIVE_VALUE',
1621
+ NotAppliedUnderDeMinimis: 'NOT_APPLIED_UNDER_DE_MINIMIS',
1622
+ };
1623
+ export const itemReverseAmountType = {
1624
+ Duty: 'DUTY',
1625
+ DutyFee: 'DUTY_FEE',
1626
+ DutyTax: 'DUTY_TAX',
1627
+ DutyTaxFee: 'DUTY_TAX_FEE',
1628
+ None: 'NONE',
1629
+ Tax: 'TAX',
1630
+ TaxFee: 'TAX_FEE',
1631
+ };
1618
1632
  export const itemType = {
1619
1633
  Bundle: 'BUNDLE',
1620
1634
  DigitalGood: 'DIGITAL_GOOD',
@@ -2050,6 +2064,7 @@ export const orderPaymentStatus = {
2050
2064
  PartiallyRefunded: 'PARTIALLY_REFUNDED',
2051
2065
  Refunded: 'REFUNDED',
2052
2066
  Unpaid: 'UNPAID',
2067
+ Voided: 'VOIDED',
2053
2068
  };
2054
2069
  export const orderRefundSubtotalType = {
2055
2070
  Discount: 'DISCOUNT',
@@ -2275,6 +2290,20 @@ export const result = {
2275
2290
  Failure: 'FAILURE',
2276
2291
  Success: 'SUCCESS',
2277
2292
  };
2293
+ export const reverseAmountStatus = {
2294
+ Applied: 'APPLIED',
2295
+ NotAppliedNegativeValue: 'NOT_APPLIED_NEGATIVE_VALUE',
2296
+ NotAppliedUnderDeMinimis: 'NOT_APPLIED_UNDER_DE_MINIMIS',
2297
+ };
2298
+ export const reverseAmountType = {
2299
+ Duty: 'DUTY',
2300
+ DutyFee: 'DUTY_FEE',
2301
+ DutyTax: 'DUTY_TAX',
2302
+ DutyTaxFee: 'DUTY_TAX_FEE',
2303
+ None: 'NONE',
2304
+ Tax: 'TAX',
2305
+ TaxFee: 'TAX_FEE',
2306
+ };
2278
2307
  export const roundingMethod = {
2279
2308
  Custom: 'CUSTOM',
2280
2309
  Hundredth: 'HUNDREDTH',
@@ -2285,9 +2314,13 @@ export const roundingMethod = {
2285
2314
  };
2286
2315
  export const searchIndex = {
2287
2316
  Catalog: 'CATALOG',
2317
+ CatalogRecent: 'CATALOG_RECENT',
2288
2318
  Orders: 'ORDERS',
2319
+ OrdersRecent: 'ORDERS_RECENT',
2289
2320
  Quotes: 'QUOTES',
2321
+ QuotesRecent: 'QUOTES_RECENT',
2290
2322
  Shipments: 'SHIPMENTS',
2323
+ ShipmentsRecent: 'SHIPMENTS_RECENT',
2291
2324
  };
2292
2325
  export const serviceLevelAvailability = {
2293
2326
  Contracted: 'CONTRACTED',
package/dist/esm/index.js CHANGED
@@ -126,7 +126,7 @@ const getZonosQaUrl = () => {
126
126
  return null;
127
127
  }
128
128
  const qaUrl = extractZonosQaUrl(window.location.href);
129
- const cdnUrl = "https://v1.3.183.js.zonos.com";
129
+ const cdnUrl = "https://v1.3.184.js.zonos.com";
130
130
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
131
131
  if (!qaUrl &&
132
132
  (cdnUrl.includes('test.') ||
@@ -362,10 +362,10 @@ const zonosLoadUrl = (() => {
362
362
  }
363
363
  return null;
364
364
  })();
365
- const ZONOS_URL = "https://v1.3.183.js.zonos.com";
366
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.183";
367
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.183";
368
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.183";
365
+ const ZONOS_URL = "https://v1.3.184.js.zonos.com";
366
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.184";
367
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.184";
368
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.184";
369
369
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
370
370
  const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
371
371
  class Zonos {
@@ -380,7 +380,7 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
380
380
  !!window.location.search.match(/\?.*(&*)zonosConversionTest/);
381
381
  Zonos._paypalMockResponse = null;
382
382
  Zonos.isBigCommerce = false;
383
- Zonos.releaseDate = "1744403359888";
383
+ Zonos.releaseDate = "1745332596232";
384
384
  Zonos.isLegacyCheckout = false;
385
385
  Zonos.domain = typeof window !== 'undefined'
386
386
  ? // domain that embeds the iframe
@@ -397,7 +397,7 @@ Zonos.isNpm = true;
397
397
  Zonos.zonosQaUrl = null;
398
398
  Zonos.zonosQaUrlApi = null;
399
399
  Zonos.trackEventLogs = [];
400
- Zonos.version = `v${"1.3.183"}`;
400
+ Zonos.version = `v${"1.3.184"}`;
401
401
  Zonos.modeAlerted = false;
402
402
  Zonos.cartData = null;
403
403
  Zonos.paypal = null;
@@ -635,7 +635,7 @@ Zonos.restoreNativeBrowserFunctions = () => {
635
635
  document.body.removeChild(overrideIframe);
636
636
  };
637
637
  Zonos.injectController = ({ config, }) => {
638
- var _b;
638
+ var _b, _c;
639
639
  if (document.querySelector('zonos-controller')) {
640
640
  return;
641
641
  }
@@ -660,6 +660,27 @@ Zonos.injectController = ({ config, }) => {
660
660
  subtree: true,
661
661
  });
662
662
  }
663
+ // if alwaysTriggerInternationalCheckoutSelector is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
664
+ if ((_c = config.checkoutSettings) === null || _c === void 0 ? void 0 : _c.alwaysTriggerInternationalCheckoutSelector) {
665
+ const alwaysTriggerInternationalCheckoutSelector = config.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;
666
+ _a.disablePlaceOrderButtons({
667
+ config,
668
+ disable: true,
669
+ placeOrderButtonSelector: alwaysTriggerInternationalCheckoutSelector,
670
+ });
671
+ // create a mutation observer to see if any new elements that match our selector is added to the DOM
672
+ const observer = new MutationObserver(() => {
673
+ _a.disablePlaceOrderButtons({
674
+ config,
675
+ disable: true,
676
+ placeOrderButtonSelector: alwaysTriggerInternationalCheckoutSelector,
677
+ });
678
+ });
679
+ observer.observe(document.body, {
680
+ childList: true,
681
+ subtree: true,
682
+ });
683
+ }
663
684
  const zonosController = document.createElement('zonos-controller');
664
685
  zonosController.config = config;
665
686
  zonosController.zonosApiKey = _a.zonosApiKey || '';
@@ -350,6 +350,7 @@ const ZonosCheckout = class {
350
350
  const currentTime = new Date().getTime();
351
351
  const timeDiff = currentTime - cartCreatedAt;
352
352
  const timeDiffInSeconds = Math.floor(timeDiff / 1000);
353
+ log(`currentTime: ${currentTime} | cartCreatedAt: ${cartCreatedAt}`);
353
354
  log(`Cart has been created for ${timeDiffInSeconds / 60} minutes`);
354
355
  if (zonosStore.checkoutSettings.defaultCartExpiration) {
355
356
  if (timeDiffInSeconds > zonosStore.checkoutSettings.defaultCartExpiration) {
@@ -689,14 +690,19 @@ const ZonosCheckout = class {
689
690
  }
690
691
  attachCheckout() {
691
692
  const buttonAnchorSelector = zonosStore.checkoutSettings.placeOrderButtonSelector;
693
+ const alwaysTriggerInternationalCheckoutSelector = zonosStore.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;
692
694
  log(`attach checkout ${buttonAnchorSelector}`);
695
+ log(`attach checkout to always trigger international checkout selector: ${alwaysTriggerInternationalCheckoutSelector}`);
693
696
  // allow to load checkout if cartData is ready (Checkout can be loaded right away if tempCartUUID is in the URL)
694
- if (!buttonAnchorSelector && !window.Zonos.cartData) {
697
+ if (!buttonAnchorSelector &&
698
+ !alwaysTriggerInternationalCheckoutSelector &&
699
+ !window.Zonos.cartData) {
695
700
  // do nothing if button element is not found
696
701
  return;
697
702
  }
698
703
  const selectors = [
699
704
  buttonAnchorSelector,
705
+ alwaysTriggerInternationalCheckoutSelector,
700
706
  // hidden button for domestic redirected
701
707
  `#${domesticRedirectedBtnSelector}`,
702
708
  // hidden button for legacy checkout facade and when client secret is provided in the query param or session storage when user is redirected from stripe
@@ -718,9 +724,15 @@ const ZonosCheckout = class {
718
724
  var _a;
719
725
  // Start tracking load time
720
726
  const startTime = performance.now();
727
+ const isAlwaysTriggerInternationalCheckout = alwaysTriggerInternationalCheckoutSelector &&
728
+ button.matches(alwaysTriggerInternationalCheckoutSelector);
729
+ const isAnyImmediateTrigger = button.matches(`#${domesticRedirectedBtnSelector}`) ||
730
+ button.matches(`#${checkoutHiddenBtnSelector}`);
721
731
  // Allow no country set for legacy facades. Otherwise enforce it being a shippable country and not disabled.
722
732
  if (!window.Zonos.isLegacyCheckout &&
723
- (!isShippableCountry() || isDisabledCountry())) {
733
+ (!isShippableCountry() || isDisabledCountry()) &&
734
+ !isAlwaysTriggerInternationalCheckout &&
735
+ !isAnyImmediateTrigger) {
724
736
  return;
725
737
  }
726
738
  e.preventDefault();
@@ -823,7 +835,7 @@ const ZonosCheckout = class {
823
835
  }
824
836
  button.setAttribute('data-zonos-checkout-attached', 'true');
825
837
  // if this button is the hidden button, trigger the click event
826
- if (button.matches(domesticRedirectedBtnSelector)) {
838
+ if (button.matches(`#${domesticRedirectedBtnSelector}`)) {
827
839
  button.dispatchEvent(createCustomEvent('click'));
828
840
  // cleanup shipping session after button is clicked
829
841
  stripeStoreCleanupDomesticShippingSession();
@@ -31,7 +31,9 @@ const injectCheckoutElement = () => {
31
31
  };
32
32
  const initCheckout = (config) => {
33
33
  // allow to load checkout if cartData is ready (Checkout can be loaded right awaiy if tempCartUUID is in the URL)
34
- if (!config.placeOrderButtonSelector && !window.Zonos.cartData) {
34
+ if (!config.placeOrderButtonSelector &&
35
+ !config.alwaysTriggerInternationalCheckoutSelector &&
36
+ !window.Zonos.cartData) {
35
37
  // do nothing if checkout button anchor is not set
36
38
  return;
37
39
  }
@@ -41,6 +43,11 @@ const initCheckout = (config) => {
41
43
  logError(`Selector checkoutButtonAnchor "${config.placeOrderButtonSelector}" is not a valid selector`);
42
44
  return;
43
45
  }
46
+ if (config.alwaysTriggerInternationalCheckoutSelector &&
47
+ !isValidSelector(config.alwaysTriggerInternationalCheckoutSelector)) {
48
+ logError(`Selector alwaysTriggerInternationalCheckoutSelector "${config.alwaysTriggerInternationalCheckoutSelector}" is not a valid selector`);
49
+ return;
50
+ }
44
51
  injectCheckoutElement();
45
52
  };
46
53
 
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,n,o,t){function r(e){return e instanceof o?e:new o((function(n){n(e)}))}return new(o||(o=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function s(e){try{c(t["throw"](e))}catch(e){i(e)}}function c(e){e.done?o(e.value):r(e.value).then(a,s)}c((t=t.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,r,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(n){return c([e,n])}}function c(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(o=0)),o)try{if(t=1,r&&(i=s[0]&2?r["return"]:s[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;if(r=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:o.label++;return{value:s[1],done:false};case 5:o.label++;r=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(s[0]===6&&o.label<i[1]){o.label=i[1];i=s;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(s);break}if(i[2])o.ops.pop();o.trys.pop();continue}s=n.call(e,o)}catch(e){s=[6,e];r=0}finally{t=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{g as getIsTestMode,a as getIsStagingMode,l as log,h as handleFetch,b as logError}from"./handleFetch-621e45bc.js";import{_ as _getIsValidCartId,c as checkoutHiddenBtnSelector}from"./CheckoutConfig-5479d192.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./CheckoutConfig-5479d192.js";export{c as countryRequireTaxId,s as shipToTaxIdLabels}from"./TaxId-915ef042.js";var checkIfLoadVersionDomain=function(e){var n=e.loadScriptSrc;if(!n){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var t=["qa.js.zonos.com"];var r=new URL(n).origin;var i=o.some((function(e){return r.includes(e)}));var a=t.some((function(e){return r.includes(e)}));return{currentLoadScriptUrl:r,isForceLoadVersionDomain:a,isWhiteListed:i}};var fallbackList=["jsdelivr","cdnjs","unpkg","vercel"];var MAIN_LOAD_CDN_TYPE="jsdelivr";var getNextFallbackUrl=function(e){var n=fallbackList.indexOf(e);var o=fallbackList[n+1];return o||null};var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,n,o,t,r,i;return __generator(this,(function(a){switch(a.label){case 0:e=getIsTestMode();n=getIsStagingMode();if(!e&&!n||!window.Zonos.zonosApiKey){return[2,null]}log("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("credential_test")){log("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2,null]}return[4,handleFetch("/api/get-test-public-credential")];case 1:o=a.sent(),t=o.errors,r=o.json;if(t.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t);return[2,null]}i=r.publicCredential;if(!i){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}log("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");return[2,i]}}))}))};var extractZonosQaUrl=function(e){if(!e){return null}var n=new URL(e).searchParams;var o=n.get("zonosQaUrl");if(!o){return null}var t=/[^a-zA-Z0-9-_]+/.test(o);if(!!t){return null}return o};var getZonosQaUrl=function(){var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=extractZonosQaUrl(window.location.href);var o="https://v1.3.183.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-"))){return o}if(!n&&["dev.demo.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!n){return null}if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var t="preview.js.zonos.com";var r="https://".concat(n,".").concat(t);log("[ZONOS-WARNING] using '".concat(r,"' for loading elements script"),"warn");void fetch(r).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(r,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var n=window.location.pathname;var o="".concat(n,"?").concat(e.toString());window.history.replaceState(window.history.state,"",o);window.location.reload();return null}));return r};var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var zonosStripeFindScript=function(){var e=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var n=0;n<e.length;n++){var o=e[n];if(!o){continue}if(!V3_URL_REGEX.test(o.src)){continue}return o}return null};var stripePromise$1=null;var injectScript=function(e){var n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"";var o=document.createElement("script");o.src="".concat(V3_URL).concat(n);var t=document.head||document.body;if(!t){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}t.appendChild(o);return o};var zonosStripeLoadScript=function(e){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(n,o){if(typeof window==="undefined"||typeof document==="undefined"){n(null);return}if(window.Stripe&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){n(window.Stripe);return}try{var t=zonosStripeFindScript();if(t&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!t){t=injectScript(e)}t===null||t===void 0?void 0:t.addEventListener("load",(function(){if(window.Stripe){n(window.Stripe)}else{o(new Error("Stripe.js not available"))}}));t===null||t===void 0?void 0:t.addEventListener("error",(function(){o(new Error("Failed to load Stripe.js"))}))}catch(e){o(e);return}}));return stripePromise$1};var registerWrapper=function(e,n){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:n})};var initStripe=function(e,n,o){if(e===null){return null}var t=e.apply(undefined,n);registerWrapper(t,o);return t};var stripePromise=Promise.resolve().then((function(){return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(e){if(!loadCalled){console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(void 0,void 0,void 0,(function(){var n;return __generator(this,(function(o){loadCalled=true;n=Date.now();return[2,stripePromise.then((function(o){return initStripe(o,e,n)}))]}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var n=e.get(TEMP_CART_ID_QUERY_PARAM);return n};var getCartInfoById=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,o,t,r,i,a;var s=e.cartId,c=e.retries;return __generator(this,(function(e){switch(e.label){case 0:n=getIsTestMode();return[4,handleFetch("/api/zonos-elements/get-cart",{body:{isTestMode:n,tempCartUUID:s},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:o=e.sent(),t=o.errors,r=o.json,i=o.zonosMode;a=!r||t.length;if(!(a&&c))return[3,3];log("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:c});return[4,new Promise((function(e){return setTimeout(e,500)}))];case 2:e.sent();return[2,getCartInfoById({cartId:s,retries:c-1})];case 3:if(a){return[2,null]}return[2,Object.assign(Object.assign({},r),{zonosMode:i})]}}))}))};var setupCartDataWithSettings=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r;return __generator(this,(function(i){switch(i.label){case 0:n=_getIsValidCartId(e),o=n.isDgsCartId,t=n.isLegacyCartId;if(!t&&!o){logError("[ZONOS - loadZonos] invalid cart id");return[2,null]}return[4,getCartInfoById({cartId:e,retries:5})];case 1:r=i.sent();log("[ZONOS - loadZonos] getting temp cart data","info",r);if(!r){logError("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2,null]}window.Zonos.storeId=r.cartData.storeId;window.Zonos.zonosApiKey=r.cartData.credentialToken;window.Zonos.zonosMode=r.zonosMode;return[2,{cartData:r.cartData,settings:r.settings,storeFavicon:r.storeFaviconUrl,storeId:r.cartData.storeId,storeLogo:r.storeLogoUrl,zonosApiKey:r.cartData.credentialToken}]}}))}))};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=checkIfLoadVersionDomain({loadScriptSrc:e===null||e===void 0?void 0:e.src}),o=n.currentLoadScriptUrl,t=n.isWhiteListed;if(t){return o}return null}();var ZONOS_URL="https://v1.3.183.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.183";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.3.183";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.183";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.cartSettings=null;Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.isBigCommerce=false;Zonos.releaseDate="1744403359888";Zonos.isLegacyCheckout=false;Zonos.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.3.183");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.zonosMode=null;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.loadTimeApiInfoList=[];Zonos.logIntervalId=null;Zonos.init=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r,i,a,s,c,u,l,d,f,v,m,p;return __generator(this,(function(_){switch(_.label){case 0:n=e.appearance,o=e.checkoutSettings,t=e.currencyConverter,r=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,c=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=c;_a.storeId=s;if(!_a.isNpm)return[3,4];log("====== ZONOS LOADING FROM NPM ======");u=getZonosQaUrl();if(u&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(u," ======"),"info");l=document.createElement("script");l.src="".concat(u,"/dist/scripts/zonos.js");document.head.appendChild(l);l.addEventListener("load",(function(){window.Zonos.isNpm=_a.isNpm;window.Zonos.isBigCommerce=_a.isBigCommerce;window.Zonos.isLegacyCheckout=_a.isLegacyCheckout;void window.Zonos.init(e)}));l.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(u))}));window.isZonosPreview=true;return[2]}if(!c&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!_a.cartData&&_a.cartId))return[3,2];log("Initialize cart data");return[4,setupCartDataWithSettings(_a.cartId)];case 1:d=_.sent();if(!d){logError("Failed to get cart data");return[2]}_a.cartData=d.cartData;_a.zonosApiKey=d.zonosApiKey;_a.cartSettings=d.settings;_.label=2;case 2:return[4,getWithTestPublicCredential()];case 3:f=_.sent();if(f){_a.zonosApiKey=f}_.label=4;case 4:v=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");m=_a.cartId&&_a.cartData||!!v;if(m){log("Cart data or stripe client secret is available, inject hidden button and trigger checkout");p=document.createElement("button");p.style.display="none";p.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(p)}log("init zonos");_a.restoreNativeBrowserFunctions();_a.injectCustomScriptForHostedCheckout();_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:r,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2]}}))}))};Zonos.injectCustomScriptForHostedCheckout=function(){var e=_a.cartData;var n=(e===null||e===void 0?void 0:e.metadata)||[];var o=n.find((function(e){return e.key==="customHeaderScript"}));var t=n.find((function(e){return e.key==="customFooterScript"}));if(!window.Zonos.isLegacyCheckout||!o&&!t){log("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(o){log("Injecting custom header script");var r=document.createElement("script");r.textContent=o.value;document.head.appendChild(r)}if(t){log("Injecting custom footer script");var r=document.createElement("script");r.textContent=t.value;document.body.appendChild(r)}};Zonos.displayCurrency=function(){var e=document.querySelector("zonos-hello");if(e){void e.displayCurrency()}};Zonos.openHelloDialog=function(e){var n=document.querySelector("zonos-hello");if(n){void n.openHelloDialog(e!==null&&e!==void 0?e:true)}};Zonos.showNotification=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.showNotification(e))};Zonos.updateOrganizationName=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.updateOrganizationName(e))};Zonos.disablePlaceOrderButtons=function(e){var n=e.autoEnable,o=n===void 0?true:n,t=e.config,r=e.disable,i=e.placeOrderButtonSelector;var a;if((a=t.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var c=function(e){var n=e.target;if(n.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};s.forEach((function(e){var n=e.getAttribute("data-zonos-checkout-attached");if(n){return}if(r){e.setAttribute("disabled","true");e.addEventListener("click",c)}else{e.removeAttribute("disabled");e.removeEventListener("click",c)}}));if(o&&r){setTimeout((function(){s.forEach((function(e){e.removeAttribute("disabled");e.removeEventListener("click",c)}))}),5e3)}}};Zonos.restoreNativeBrowserFunctions=function(){var e;var n=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(n){return}var o="zonos---native-browser";var t=document.querySelector("iframe#".concat(o));if(!t){t=document.createElement("iframe");t.id=o;t.style.display="none";t.style.opacity="0";t.style.position="absolute";t.style.top="-9999px";t.style.left="-9999px";t.style.width="1px";t.style.height="1px";t.style.border="none";t.style.overflow="hidden";t.style.visibility="hidden";document.body.appendChild(t)}var r=((e=t.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=r;document.body.removeChild(t)};Zonos.injectController=function(e){var n=e.config;var o;if(document.querySelector("zonos-controller")){return}if((o=n.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var t=n.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:t});var r=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:t})}));r.observe(document.body,{childList:true,subtree:true})}var i=document.createElement("zonos-controller");i.config=n;i.zonosApiKey=_a.zonosApiKey||"";i.addEventListener("stripeInitEvent",(function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o;return __generator(this,(function(t){switch(t.label){case 0:n=e.detail;log("loading Stripe");return[4,zonosLoadStripe(n.publishableKey)];case 1:o=t.sent();if(!o){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;void i.initCheckoutElement(o);return[2]}}))}))}));document.body.appendChild(i);_a.zonosController=i;log("Zonos controller injected!")};Zonos.injectScript=function(e){var n=e.cdnType,o=e.isModule,t=e.theRestUrl;var r=_a.getZonosUrl(n);var i="".concat(r,"/").concat(t);var a=function(){var e=document.querySelector('script[src="'.concat(i,'"]'));return!!e};if(a()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var s=document.head||document.body;var c=document.createElement("script");if(!!o){c.type="module"}else{c.noModule=true}c.src=i;c.crossOrigin="anonymous";c.onerror=function(){logError("Failed to load ".concat(c.src));var e=getNextFallbackUrl(n);if(!e){return}_a.injectScript({cdnType:e,isModule:o,theRestUrl:t})};s.appendChild(c)};Zonos.getZonosUrl=function(e){var n=function(){switch(e){case"jsdelivr":return JS_DELIVR_ZONOS_URL;case"unpkg":return UNPKG_ZONOS_URL;case"cdnjs":return CDNJS_ZONOS_URL;case"vercel":return ZONOS_URL}};if(_a.isNpm){var o=getZonosQaUrl();return o||n()}return n()};Zonos.injectZonosCdn=function(){_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(e){var n=e.cdnType,o=e.theRestUrl;var t=_a.getZonosUrl(n);var r=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");r.appendChild(i);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(t,"/").concat(o);a.onerror=function(){logError("Failed to load ".concat(a.href));var e=getNextFallbackUrl(n);if(!e){return}_a.injectStylesheet({cdnType:e,theRestUrl:o})};r.appendChild(a)};Zonos.injectZonosCss=function(){var e=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(e()){log("Zonos style links already injected","warn");return}_a.injectStylesheet({cdnType:MAIN_LOAD_CDN_TYPE,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var e=function(){var e=document.fonts.check("1em Inter");if(e){log("Inter font already loaded","warn");return}var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(GOOGLE_FONT_URL,'"]'));for(var o=0;o<n.length;o++){var t=n[o];if(!t){continue}if(GOOGLE_FONT_REGEX.test(t.href)){continue}return t}return null};if(e()){log("Inter font already injected","warn");return}var n=document.head||document.body;var o=document.createElement("link");o.rel="preconnect";o.href=GOOGLE_FONT_URL;n.appendChild(o);var t=document.createElement("link");t.rel="stylesheet";t.href="".concat(GOOGLE_FONT_URL,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");n.appendChild(t);log("Zonos font injected!")};Zonos.setupGoogleFont=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.setupGoogleFont(e))};Zonos.injectSupportGoogleFont=function(e){var n;log("[FONT] injecting ".concat(e));var o=(n=e.match(/family=(.*?):/))===null||n===void 0?void 0:n[1];var t=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var r=document.createElement("link");r.rel="preconnect";r.href=GOOGLE_FONT_URL;t.appendChild(r)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){log("[FONT] ".concat(o," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;t.appendChild(i);log("[FONT] ".concat(o," font injected!"))};export{Zonos};
1
+ var __awaiter=this&&this.__awaiter||function(e,n,o,t){function r(e){return e instanceof o?e:new o((function(n){n(e)}))}return new(o||(o=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function s(e){try{c(t["throw"](e))}catch(e){i(e)}}function c(e){e.done?o(e.value):r(e.value).then(a,s)}c((t=t.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,r,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(n){return c([e,n])}}function c(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(o=0)),o)try{if(t=1,r&&(i=s[0]&2?r["return"]:s[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;if(r=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:o.label++;return{value:s[1],done:false};case 5:o.label++;r=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(s[0]===6&&o.label<i[1]){o.label=i[1];i=s;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(s);break}if(i[2])o.ops.pop();o.trys.pop();continue}s=n.call(e,o)}catch(e){s=[6,e];r=0}finally{t=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{g as getIsTestMode,a as getIsStagingMode,l as log,h as handleFetch,b as logError}from"./handleFetch-621e45bc.js";import{_ as _getIsValidCartId,c as checkoutHiddenBtnSelector}from"./CheckoutConfig-5479d192.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./CheckoutConfig-5479d192.js";export{c as countryRequireTaxId,s as shipToTaxIdLabels}from"./TaxId-915ef042.js";var checkIfLoadVersionDomain=function(e){var n=e.loadScriptSrc;if(!n){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var t=["qa.js.zonos.com"];var r=new URL(n).origin;var i=o.some((function(e){return r.includes(e)}));var a=t.some((function(e){return r.includes(e)}));return{currentLoadScriptUrl:r,isForceLoadVersionDomain:a,isWhiteListed:i}};var fallbackList=["jsdelivr","cdnjs","unpkg","vercel"];var MAIN_LOAD_CDN_TYPE="jsdelivr";var getNextFallbackUrl=function(e){var n=fallbackList.indexOf(e);var o=fallbackList[n+1];return o||null};var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,n,o,t,r,i;return __generator(this,(function(a){switch(a.label){case 0:e=getIsTestMode();n=getIsStagingMode();if(!e&&!n||!window.Zonos.zonosApiKey){return[2,null]}log("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("credential_test")){log("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2,null]}return[4,handleFetch("/api/get-test-public-credential")];case 1:o=a.sent(),t=o.errors,r=o.json;if(t.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t);return[2,null]}i=r.publicCredential;if(!i){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}log("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");return[2,i]}}))}))};var extractZonosQaUrl=function(e){if(!e){return null}var n=new URL(e).searchParams;var o=n.get("zonosQaUrl");if(!o){return null}var t=/[^a-zA-Z0-9-_]+/.test(o);if(!!t){return null}return o};var getZonosQaUrl=function(){var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=extractZonosQaUrl(window.location.href);var o="https://v1.3.184.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-"))){return o}if(!n&&["dev.demo.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!n){return null}if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var t="preview.js.zonos.com";var r="https://".concat(n,".").concat(t);log("[ZONOS-WARNING] using '".concat(r,"' for loading elements script"),"warn");void fetch(r).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(r,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var n=window.location.pathname;var o="".concat(n,"?").concat(e.toString());window.history.replaceState(window.history.state,"",o);window.location.reload();return null}));return r};var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var zonosStripeFindScript=function(){var e=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var n=0;n<e.length;n++){var o=e[n];if(!o){continue}if(!V3_URL_REGEX.test(o.src)){continue}return o}return null};var stripePromise$1=null;var injectScript=function(e){var n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"";var o=document.createElement("script");o.src="".concat(V3_URL).concat(n);var t=document.head||document.body;if(!t){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}t.appendChild(o);return o};var zonosStripeLoadScript=function(e){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(n,o){if(typeof window==="undefined"||typeof document==="undefined"){n(null);return}if(window.Stripe&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){n(window.Stripe);return}try{var t=zonosStripeFindScript();if(t&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!t){t=injectScript(e)}t===null||t===void 0?void 0:t.addEventListener("load",(function(){if(window.Stripe){n(window.Stripe)}else{o(new Error("Stripe.js not available"))}}));t===null||t===void 0?void 0:t.addEventListener("error",(function(){o(new Error("Failed to load Stripe.js"))}))}catch(e){o(e);return}}));return stripePromise$1};var registerWrapper=function(e,n){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:n})};var initStripe=function(e,n,o){if(e===null){return null}var t=e.apply(undefined,n);registerWrapper(t,o);return t};var stripePromise=Promise.resolve().then((function(){return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(e){if(!loadCalled){console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(void 0,void 0,void 0,(function(){var n;return __generator(this,(function(o){loadCalled=true;n=Date.now();return[2,stripePromise.then((function(o){return initStripe(o,e,n)}))]}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var n=e.get(TEMP_CART_ID_QUERY_PARAM);return n};var getCartInfoById=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,o,t,r,i,a;var s=e.cartId,c=e.retries;return __generator(this,(function(e){switch(e.label){case 0:n=getIsTestMode();return[4,handleFetch("/api/zonos-elements/get-cart",{body:{isTestMode:n,tempCartUUID:s},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:o=e.sent(),t=o.errors,r=o.json,i=o.zonosMode;a=!r||t.length;if(!(a&&c))return[3,3];log("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:c});return[4,new Promise((function(e){return setTimeout(e,500)}))];case 2:e.sent();return[2,getCartInfoById({cartId:s,retries:c-1})];case 3:if(a){return[2,null]}return[2,Object.assign(Object.assign({},r),{zonosMode:i})]}}))}))};var setupCartDataWithSettings=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r;return __generator(this,(function(i){switch(i.label){case 0:n=_getIsValidCartId(e),o=n.isDgsCartId,t=n.isLegacyCartId;if(!t&&!o){logError("[ZONOS - loadZonos] invalid cart id");return[2,null]}return[4,getCartInfoById({cartId:e,retries:5})];case 1:r=i.sent();log("[ZONOS - loadZonos] getting temp cart data","info",r);if(!r){logError("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2,null]}window.Zonos.storeId=r.cartData.storeId;window.Zonos.zonosApiKey=r.cartData.credentialToken;window.Zonos.zonosMode=r.zonosMode;return[2,{cartData:r.cartData,settings:r.settings,storeFavicon:r.storeFaviconUrl,storeId:r.cartData.storeId,storeLogo:r.storeLogoUrl,zonosApiKey:r.cartData.credentialToken}]}}))}))};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=checkIfLoadVersionDomain({loadScriptSrc:e===null||e===void 0?void 0:e.src}),o=n.currentLoadScriptUrl,t=n.isWhiteListed;if(t){return o}return null}();var ZONOS_URL="https://v1.3.184.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.184";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.3.184";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.184";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.cartSettings=null;Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.isBigCommerce=false;Zonos.releaseDate="1745332596232";Zonos.isLegacyCheckout=false;Zonos.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.3.184");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.zonosMode=null;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.loadTimeApiInfoList=[];Zonos.logIntervalId=null;Zonos.init=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r,i,a,s,c,u,l,d,f,v,m,p;return __generator(this,(function(_){switch(_.label){case 0:n=e.appearance,o=e.checkoutSettings,t=e.currencyConverter,r=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,c=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=c;_a.storeId=s;if(!_a.isNpm)return[3,4];log("====== ZONOS LOADING FROM NPM ======");u=getZonosQaUrl();if(u&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(u," ======"),"info");l=document.createElement("script");l.src="".concat(u,"/dist/scripts/zonos.js");document.head.appendChild(l);l.addEventListener("load",(function(){window.Zonos.isNpm=_a.isNpm;window.Zonos.isBigCommerce=_a.isBigCommerce;window.Zonos.isLegacyCheckout=_a.isLegacyCheckout;void window.Zonos.init(e)}));l.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(u))}));window.isZonosPreview=true;return[2]}if(!c&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!_a.cartData&&_a.cartId))return[3,2];log("Initialize cart data");return[4,setupCartDataWithSettings(_a.cartId)];case 1:d=_.sent();if(!d){logError("Failed to get cart data");return[2]}_a.cartData=d.cartData;_a.zonosApiKey=d.zonosApiKey;_a.cartSettings=d.settings;_.label=2;case 2:return[4,getWithTestPublicCredential()];case 3:f=_.sent();if(f){_a.zonosApiKey=f}_.label=4;case 4:v=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");m=_a.cartId&&_a.cartData||!!v;if(m){log("Cart data or stripe client secret is available, inject hidden button and trigger checkout");p=document.createElement("button");p.style.display="none";p.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(p)}log("init zonos");_a.restoreNativeBrowserFunctions();_a.injectCustomScriptForHostedCheckout();_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:r,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2]}}))}))};Zonos.injectCustomScriptForHostedCheckout=function(){var e=_a.cartData;var n=(e===null||e===void 0?void 0:e.metadata)||[];var o=n.find((function(e){return e.key==="customHeaderScript"}));var t=n.find((function(e){return e.key==="customFooterScript"}));if(!window.Zonos.isLegacyCheckout||!o&&!t){log("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(o){log("Injecting custom header script");var r=document.createElement("script");r.textContent=o.value;document.head.appendChild(r)}if(t){log("Injecting custom footer script");var r=document.createElement("script");r.textContent=t.value;document.body.appendChild(r)}};Zonos.displayCurrency=function(){var e=document.querySelector("zonos-hello");if(e){void e.displayCurrency()}};Zonos.openHelloDialog=function(e){var n=document.querySelector("zonos-hello");if(n){void n.openHelloDialog(e!==null&&e!==void 0?e:true)}};Zonos.showNotification=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.showNotification(e))};Zonos.updateOrganizationName=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.updateOrganizationName(e))};Zonos.disablePlaceOrderButtons=function(e){var n=e.autoEnable,o=n===void 0?true:n,t=e.config,r=e.disable,i=e.placeOrderButtonSelector;var a;if((a=t.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var c=function(e){var n=e.target;if(n.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};s.forEach((function(e){var n=e.getAttribute("data-zonos-checkout-attached");if(n){return}if(r){e.setAttribute("disabled","true");e.addEventListener("click",c)}else{e.removeAttribute("disabled");e.removeEventListener("click",c)}}));if(o&&r){setTimeout((function(){s.forEach((function(e){e.removeAttribute("disabled");e.removeEventListener("click",c)}))}),5e3)}}};Zonos.restoreNativeBrowserFunctions=function(){var e;var n=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(n){return}var o="zonos---native-browser";var t=document.querySelector("iframe#".concat(o));if(!t){t=document.createElement("iframe");t.id=o;t.style.display="none";t.style.opacity="0";t.style.position="absolute";t.style.top="-9999px";t.style.left="-9999px";t.style.width="1px";t.style.height="1px";t.style.border="none";t.style.overflow="hidden";t.style.visibility="hidden";document.body.appendChild(t)}var r=((e=t.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=r;document.body.removeChild(t)};Zonos.injectController=function(e){var n=e.config;var o,t;if(document.querySelector("zonos-controller")){return}if((o=n.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var r=n.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r})}));i.observe(document.body,{childList:true,subtree:true})}if((t=n.checkoutSettings)===null||t===void 0?void 0:t.alwaysTriggerInternationalCheckoutSelector){var a=n.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a});var i=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a})}));i.observe(document.body,{childList:true,subtree:true})}var s=document.createElement("zonos-controller");s.config=n;s.zonosApiKey=_a.zonosApiKey||"";s.addEventListener("stripeInitEvent",(function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o;return __generator(this,(function(t){switch(t.label){case 0:n=e.detail;log("loading Stripe");return[4,zonosLoadStripe(n.publishableKey)];case 1:o=t.sent();if(!o){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;void s.initCheckoutElement(o);return[2]}}))}))}));document.body.appendChild(s);_a.zonosController=s;log("Zonos controller injected!")};Zonos.injectScript=function(e){var n=e.cdnType,o=e.isModule,t=e.theRestUrl;var r=_a.getZonosUrl(n);var i="".concat(r,"/").concat(t);var a=function(){var e=document.querySelector('script[src="'.concat(i,'"]'));return!!e};if(a()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var s=document.head||document.body;var c=document.createElement("script");if(!!o){c.type="module"}else{c.noModule=true}c.src=i;c.crossOrigin="anonymous";c.onerror=function(){logError("Failed to load ".concat(c.src));var e=getNextFallbackUrl(n);if(!e){return}_a.injectScript({cdnType:e,isModule:o,theRestUrl:t})};s.appendChild(c)};Zonos.getZonosUrl=function(e){var n=function(){switch(e){case"jsdelivr":return JS_DELIVR_ZONOS_URL;case"unpkg":return UNPKG_ZONOS_URL;case"cdnjs":return CDNJS_ZONOS_URL;case"vercel":return ZONOS_URL}};if(_a.isNpm){var o=getZonosQaUrl();return o||n()}return n()};Zonos.injectZonosCdn=function(){_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(e){var n=e.cdnType,o=e.theRestUrl;var t=_a.getZonosUrl(n);var r=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");r.appendChild(i);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(t,"/").concat(o);a.onerror=function(){logError("Failed to load ".concat(a.href));var e=getNextFallbackUrl(n);if(!e){return}_a.injectStylesheet({cdnType:e,theRestUrl:o})};r.appendChild(a)};Zonos.injectZonosCss=function(){var e=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(e()){log("Zonos style links already injected","warn");return}_a.injectStylesheet({cdnType:MAIN_LOAD_CDN_TYPE,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var e=function(){var e=document.fonts.check("1em Inter");if(e){log("Inter font already loaded","warn");return}var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(GOOGLE_FONT_URL,'"]'));for(var o=0;o<n.length;o++){var t=n[o];if(!t){continue}if(GOOGLE_FONT_REGEX.test(t.href)){continue}return t}return null};if(e()){log("Inter font already injected","warn");return}var n=document.head||document.body;var o=document.createElement("link");o.rel="preconnect";o.href=GOOGLE_FONT_URL;n.appendChild(o);var t=document.createElement("link");t.rel="stylesheet";t.href="".concat(GOOGLE_FONT_URL,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");n.appendChild(t);log("Zonos font injected!")};Zonos.setupGoogleFont=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.setupGoogleFont(e))};Zonos.injectSupportGoogleFont=function(e){var n;log("[FONT] injecting ".concat(e));var o=(n=e.match(/family=(.*?):/))===null||n===void 0?void 0:n[1];var t=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var r=document.createElement("link");r.rel="preconnect";r.href=GOOGLE_FONT_URL;t.appendChild(r)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){log("[FONT] ".concat(o," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;t.appendChild(i);log("[FONT] ".concat(o," font injected!"))};export{Zonos};