@zonos/elements 1.2.4-alpha.10 → 1.2.4-alpha.11

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 (68) hide show
  1. package/dist/cjs/{cart-90f7c8c0.js → cart-963ffc24.js} +1 -1
  2. package/dist/cjs/index.cjs.js +2 -2
  3. package/dist/cjs/{localization-9caf3397.js → localization-994933ce.js} +1 -1
  4. package/dist/cjs/{submitGtag-b141b45d.js → submitGtag-e047f309.js} +1 -1
  5. package/dist/cjs/zonos-address_2.cjs.entry.js +2 -2
  6. package/dist/cjs/zonos-cart-items_10.cjs.entry.js +3 -3
  7. package/dist/cjs/zonos-checkout.cjs.entry.js +3 -3
  8. package/dist/cjs/zonos-controller.cjs.entry.js +2 -2
  9. package/dist/cjs/zonos-country-flag_4.cjs.entry.js +1 -1
  10. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +1 -1
  11. package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
  12. package/dist/cjs/zonos-payment.cjs.entry.js +2 -2
  13. package/dist/collection/components/utils/handleFetch.js +1 -1
  14. package/dist/components/localization.js +1 -1
  15. package/dist/esm/{cart-b439be00.js → cart-c5236eec.js} +1 -1
  16. package/dist/esm/index.js +2 -2
  17. package/dist/esm/{localization-a51ccbc2.js → localization-3cb32a71.js} +1 -1
  18. package/dist/esm/{submitGtag-521826a2.js → submitGtag-9de4957f.js} +1 -1
  19. package/dist/esm/zonos-address_2.entry.js +2 -2
  20. package/dist/esm/zonos-cart-items_10.entry.js +3 -3
  21. package/dist/esm/zonos-checkout.entry.js +3 -3
  22. package/dist/esm/zonos-controller.entry.js +2 -2
  23. package/dist/esm/zonos-country-flag_4.entry.js +1 -1
  24. package/dist/esm/zonos-hello-dialog.entry.js +1 -1
  25. package/dist/esm/zonos-hello.entry.js +1 -1
  26. package/dist/esm/zonos-payment.entry.js +2 -2
  27. package/dist/esm-es5/{cart-b439be00.js → cart-c5236eec.js} +1 -1
  28. package/dist/esm-es5/index.js +1 -1
  29. package/dist/esm-es5/{submitGtag-521826a2.js → submitGtag-9de4957f.js} +1 -1
  30. package/dist/esm-es5/zonos-address_2.entry.js +1 -1
  31. package/dist/esm-es5/zonos-cart-items_10.entry.js +1 -1
  32. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  33. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  34. package/dist/esm-es5/zonos-country-flag_4.entry.js +1 -1
  35. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  36. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  37. package/dist/esm-es5/zonos-payment.entry.js +1 -1
  38. package/dist/scripts/loadZonos.js +3 -3
  39. package/dist/scripts/zonos.js +3 -3
  40. package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
  41. package/dist/zonos-elements/index.esm.js +1 -1
  42. package/dist/zonos-elements/{p-b6148206.entry.js → p-07ebdfd9.entry.js} +1 -1
  43. package/dist/zonos-elements/{p-a0e36ed3.entry.js → p-0d536271.entry.js} +1 -1
  44. package/dist/zonos-elements/p-24fbe845.system.js +1 -1
  45. package/dist/zonos-elements/{p-494c77a7.entry.js → p-39013804.entry.js} +1 -1
  46. package/dist/zonos-elements/{p-e9b832c5.entry.js → p-3e70063e.entry.js} +1 -1
  47. package/dist/zonos-elements/{p-4846796a.js → p-425996c1.js} +1 -1
  48. package/dist/zonos-elements/{p-a504f64f.system.js → p-509eb1de.system.js} +1 -1
  49. package/dist/zonos-elements/{p-f141519c.system.entry.js → p-510d3aa3.system.entry.js} +1 -1
  50. package/dist/zonos-elements/{p-4a15c5c7.system.entry.js → p-5554ff33.system.entry.js} +1 -1
  51. package/dist/zonos-elements/{p-4bee0bff.system.entry.js → p-65749745.system.entry.js} +1 -1
  52. package/dist/zonos-elements/{p-67aec665.entry.js → p-6a72fc13.entry.js} +1 -1
  53. package/dist/zonos-elements/{p-3cea383b.system.entry.js → p-6aa44c88.system.entry.js} +1 -1
  54. package/dist/zonos-elements/{p-8c48b75e.system.js → p-6d4232a6.system.js} +1 -1
  55. package/dist/zonos-elements/{p-b4601210.system.entry.js → p-7fdc8b27.system.entry.js} +1 -1
  56. package/dist/zonos-elements/{p-639396bb.entry.js → p-83c7c3f4.entry.js} +1 -1
  57. package/dist/zonos-elements/{p-afe26069.entry.js → p-8cefaae6.entry.js} +1 -1
  58. package/dist/zonos-elements/{p-4ed71bd7.entry.js → p-bb24e583.entry.js} +1 -1
  59. package/dist/zonos-elements/{p-8c5595d9.system.entry.js → p-e06711b8.system.entry.js} +1 -1
  60. package/dist/zonos-elements/{p-06fb9d1f.system.entry.js → p-e100f180.system.entry.js} +1 -1
  61. package/dist/zonos-elements/{p-1685c8df.js → p-e2c2584c.js} +1 -1
  62. package/dist/zonos-elements/{p-d2217f09.system.js → p-f33e1ffb.system.js} +1 -1
  63. package/dist/zonos-elements/{p-2a307c55.system.entry.js → p-fbfec60c.system.entry.js} +1 -1
  64. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  65. package/package.json +3 -2
  66. /package/dist/esm-es5/{localization-a51ccbc2.js → localization-3cb32a71.js} +0 -0
  67. /package/dist/zonos-elements/{p-b51de536.system.js → p-8a8b08e9.system.js} +0 -0
  68. /package/dist/zonos-elements/{p-3c6988d7.js → p-bbb154a9.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const zonosStore = require('./zonosStore-b43ef5db.js');
4
- const localization = require('./localization-9caf3397.js');
4
+ const localization = require('./localization-994933ce.js');
5
5
  const isDarkColor = require('./isDarkColor-ff6ff183.js');
6
6
  const getBorderRadius = require('./getBorderRadius-bf4a4276.js');
7
7
 
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const cart = require('./cart-90f7c8c0.js');
5
+ const cart = require('./cart-963ffc24.js');
6
6
  require('./zonosStore-b43ef5db.js');
7
7
  require('./index-0dcccc22.js');
8
- require('./localization-9caf3397.js');
8
+ require('./localization-994933ce.js');
9
9
  require('./isDarkColor-ff6ff183.js');
10
10
  require('./getBorderRadius-bf4a4276.js');
11
11
 
@@ -3182,7 +3182,7 @@ const handleFetch = async (url, _opts) => {
3182
3182
  const opts = __rest(_opts || {}, []);
3183
3183
  const body = opts.body ? JSON.stringify(opts.body) : undefined;
3184
3184
  const method = opts.method || 'GET';
3185
- // adding credentialtoken to the url so that the request will be cached differently for each store
3185
+ // adding random encoded token to the url so that the request will be cached differently for each store
3186
3186
  const modifiedUrl = new URL(url);
3187
3187
  modifiedUrl.searchParams.set('zToken', encodeString(window.location.hostname));
3188
3188
  // headers content type
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const zonosStore = require('./zonosStore-b43ef5db.js');
4
- const localization = require('./localization-9caf3397.js');
4
+ const localization = require('./localization-994933ce.js');
5
5
 
6
6
  const checkoutBreakpoint = 890;
7
7
  const isCheckoutMobile = (isMobile) => {
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-0dcccc22.js');
6
- const cart = require('./cart-90f7c8c0.js');
7
- const localization = require('./localization-9caf3397.js');
6
+ const cart = require('./cart-963ffc24.js');
7
+ const localization = require('./localization-994933ce.js');
8
8
  require('./zonosStore-b43ef5db.js');
9
9
  require('./isDarkColor-ff6ff183.js');
10
10
  require('./getBorderRadius-bf4a4276.js');
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-0dcccc22.js');
6
- const cart = require('./cart-90f7c8c0.js');
7
- const localization = require('./localization-9caf3397.js');
6
+ const cart = require('./cart-963ffc24.js');
7
+ const localization = require('./localization-994933ce.js');
8
8
  const getBorderRadius = require('./getBorderRadius-bf4a4276.js');
9
- const submitGtag = require('./submitGtag-b141b45d.js');
9
+ const submitGtag = require('./submitGtag-e047f309.js');
10
10
  const zonosStore = require('./zonosStore-b43ef5db.js');
11
11
  const classes = require('./classes-b7918f56.js');
12
12
  require('./isDarkColor-ff6ff183.js');
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-0dcccc22.js');
6
- const cart = require('./cart-90f7c8c0.js');
7
- const localization = require('./localization-9caf3397.js');
6
+ const cart = require('./cart-963ffc24.js');
7
+ const localization = require('./localization-994933ce.js');
8
8
  const zonosStore = require('./zonosStore-b43ef5db.js');
9
- const submitGtag = require('./submitGtag-b141b45d.js');
9
+ const submitGtag = require('./submitGtag-e047f309.js');
10
10
  const classes = require('./classes-b7918f56.js');
11
11
  const getBorderRadius = require('./getBorderRadius-bf4a4276.js');
12
12
  const isDarkColor = require('./isDarkColor-ff6ff183.js');
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-0dcccc22.js');
6
- const cart = require('./cart-90f7c8c0.js');
7
- const localization = require('./localization-9caf3397.js');
6
+ const cart = require('./cart-963ffc24.js');
7
+ const localization = require('./localization-994933ce.js');
8
8
  const zonosStore = require('./zonosStore-b43ef5db.js');
9
9
  require('./isDarkColor-ff6ff183.js');
10
10
  require('./getBorderRadius-bf4a4276.js');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-0dcccc22.js');
6
- const localization = require('./localization-9caf3397.js');
6
+ const localization = require('./localization-994933ce.js');
7
7
  const zonosStore = require('./zonosStore-b43ef5db.js');
8
8
  const classes = require('./classes-b7918f56.js');
9
9
  const isDarkColor = require('./isDarkColor-ff6ff183.js');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-0dcccc22.js');
6
- const localization = require('./localization-9caf3397.js');
6
+ const localization = require('./localization-994933ce.js');
7
7
  const zonosStore = require('./zonosStore-b43ef5db.js');
8
8
  const classes = require('./classes-b7918f56.js');
9
9
  const getHasMoreSpaceOnRight = require('./getHasMoreSpaceOnRight-4c94667f.js');
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-0dcccc22.js');
6
6
  const zonosStore = require('./zonosStore-b43ef5db.js');
7
- const localization = require('./localization-9caf3397.js');
7
+ const localization = require('./localization-994933ce.js');
8
8
  const classes = require('./classes-b7918f56.js');
9
9
  const getHasMoreSpaceOnRight = require('./getHasMoreSpaceOnRight-4c94667f.js');
10
10
 
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-0dcccc22.js');
6
- const cart = require('./cart-90f7c8c0.js');
6
+ const cart = require('./cart-963ffc24.js');
7
7
  require('./zonosStore-b43ef5db.js');
8
- require('./localization-9caf3397.js');
8
+ require('./localization-994933ce.js');
9
9
  require('./isDarkColor-ff6ff183.js');
10
10
  require('./getBorderRadius-bf4a4276.js');
11
11
 
@@ -107,7 +107,7 @@ export const handleFetch = async (url, _opts) => {
107
107
  const opts = __rest(_opts || {}, []);
108
108
  const body = opts.body ? JSON.stringify(opts.body) : undefined;
109
109
  const method = opts.method || 'GET';
110
- // adding credentialtoken to the url so that the request will be cached differently for each store
110
+ // adding random encoded token to the url so that the request will be cached differently for each store
111
111
  const modifiedUrl = new URL(url);
112
112
  modifiedUrl.searchParams.set('zToken', encodeString(window.location.hostname));
113
113
  // headers content type
@@ -3180,7 +3180,7 @@ const handleFetch = async (url, _opts) => {
3180
3180
  const opts = __rest(_opts || {}, []);
3181
3181
  const body = opts.body ? JSON.stringify(opts.body) : undefined;
3182
3182
  const method = opts.method || 'GET';
3183
- // adding credentialtoken to the url so that the request will be cached differently for each store
3183
+ // adding random encoded token to the url so that the request will be cached differently for each store
3184
3184
  const modifiedUrl = new URL(url);
3185
3185
  modifiedUrl.searchParams.set('zToken', encodeString(window.location.hostname));
3186
3186
  // headers content type
@@ -1,5 +1,5 @@
1
1
  import { z as zonosStore, c as createStore } from './zonosStore-61e74f58.js';
2
- import { h as handleFetch, l as log, a as localizationStore, b as logError, t as translate } from './localization-a51ccbc2.js';
2
+ import { h as handleFetch, l as log, a as localizationStore, b as logError, t as translate } from './localization-3cb32a71.js';
3
3
  import { i as isDarkColor } from './isDarkColor-416d6047.js';
4
4
  import { g as getBorderRadius } from './getBorderRadius-178a0a05.js';
5
5
 
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export { c as cartStore, a as cartStoreApplySubtotals, b as cartStoreGetShippingTransitInfo, d as cartStoreNextStep, e as cartStorePreviousStep, f as cartStoreReCalculateTotal, g as cartStoreReset, h as cartStoreUpdateItems, i as cartStoreUpdateSelectedShippingOption, j as cartStoreUpdateToErrorState } from './cart-b439be00.js';
1
+ export { c as cartStore, a as cartStoreApplySubtotals, b as cartStoreGetShippingTransitInfo, d as cartStoreNextStep, e as cartStorePreviousStep, f as cartStoreReCalculateTotal, g as cartStoreReset, h as cartStoreUpdateItems, i as cartStoreUpdateSelectedShippingOption, j as cartStoreUpdateToErrorState } from './cart-c5236eec.js';
2
2
  import './zonosStore-61e74f58.js';
3
3
  import './index-36ff6342.js';
4
- import './localization-a51ccbc2.js';
4
+ import './localization-3cb32a71.js';
5
5
  import './isDarkColor-416d6047.js';
6
6
  import './getBorderRadius-178a0a05.js';
@@ -3180,7 +3180,7 @@ const handleFetch = async (url, _opts) => {
3180
3180
  const opts = __rest(_opts || {}, []);
3181
3181
  const body = opts.body ? JSON.stringify(opts.body) : undefined;
3182
3182
  const method = opts.method || 'GET';
3183
- // adding credentialtoken to the url so that the request will be cached differently for each store
3183
+ // adding random encoded token to the url so that the request will be cached differently for each store
3184
3184
  const modifiedUrl = new URL(url);
3185
3185
  modifiedUrl.searchParams.set('zToken', encodeString(window.location.hostname));
3186
3186
  // headers content type
@@ -1,5 +1,5 @@
1
1
  import { z as zonosStore } from './zonosStore-61e74f58.js';
2
- import { l as log } from './localization-a51ccbc2.js';
2
+ import { l as log } from './localization-3cb32a71.js';
3
3
 
4
4
  const checkoutBreakpoint = 890;
5
5
  const isCheckoutMobile = (isMobile) => {
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, h, H as Host, d as getElement } from './index-36ff6342.js';
2
- import { s as stripeStore, m as stripeStorePrefetchLandedCost } from './cart-b439be00.js';
3
- import { b as logError, a as localizationStore } from './localization-a51ccbc2.js';
2
+ import { s as stripeStore, m as stripeStorePrefetchLandedCost } from './cart-c5236eec.js';
3
+ import { b as logError, a as localizationStore } from './localization-3cb32a71.js';
4
4
  import './zonosStore-61e74f58.js';
5
5
  import './isDarkColor-416d6047.js';
6
6
  import './getBorderRadius-178a0a05.js';
@@ -1,8 +1,8 @@
1
1
  import { r as registerInstance, a as getAssetPath, h, H as Host, F as Fragment, c as createEvent, d as getElement } from './index-36ff6342.js';
2
- import { c as cartStore, s as stripeStore, p as stripeStoreRetrievePayment, o as stripeStoreReset, i as cartStoreUpdateSelectedShippingOption, b as cartStoreGetShippingTransitInfo } from './cart-b439be00.js';
3
- import { t as translate, h as handleFetch, b as logError } from './localization-a51ccbc2.js';
2
+ import { c as cartStore, s as stripeStore, p as stripeStoreRetrievePayment, o as stripeStoreReset, i as cartStoreUpdateSelectedShippingOption, b as cartStoreGetShippingTransitInfo } from './cart-c5236eec.js';
3
+ import { t as translate, h as handleFetch, b as logError } from './localization-3cb32a71.js';
4
4
  import { g as getBorderRadius } from './getBorderRadius-178a0a05.js';
5
- import { s as submitGtag, i as isCheckoutMobile } from './submitGtag-521826a2.js';
5
+ import { s as submitGtag, i as isCheckoutMobile } from './submitGtag-9de4957f.js';
6
6
  import { e as zonosStoreFontFamily, z as zonosStore } from './zonosStore-61e74f58.js';
7
7
  import { c as classes } from './classes-0d95c529.js';
8
8
  import './isDarkColor-416d6047.js';
@@ -1,8 +1,8 @@
1
1
  import { r as registerInstance, h, F as Fragment, H as Host } from './index-36ff6342.js';
2
- import { k as initStripeElements, c as cartStore, h as cartStoreUpdateItems, g as cartStoreReset, s as stripeStore, l as stripeStoreInitCheckoutSession, j as cartStoreUpdateToErrorState, m as stripeStorePrefetchLandedCost, d as cartStoreNextStep, n as stripeStoreConfirmPayment, o as stripeStoreReset, e as cartStorePreviousStep } from './cart-b439be00.js';
3
- import { a as localizationStore, l as log, t as translate } from './localization-a51ccbc2.js';
2
+ import { k as initStripeElements, c as cartStore, h as cartStoreUpdateItems, g as cartStoreReset, s as stripeStore, l as stripeStoreInitCheckoutSession, j as cartStoreUpdateToErrorState, m as stripeStorePrefetchLandedCost, d as cartStoreNextStep, n as stripeStoreConfirmPayment, o as stripeStoreReset, e as cartStorePreviousStep } from './cart-c5236eec.js';
3
+ import { a as localizationStore, l as log, t as translate } from './localization-3cb32a71.js';
4
4
  import { z as zonosStore, m as mergeConfig } from './zonosStore-61e74f58.js';
5
- import { s as submitGtag, i as isCheckoutMobile } from './submitGtag-521826a2.js';
5
+ import { s as submitGtag, i as isCheckoutMobile } from './submitGtag-9de4957f.js';
6
6
  import { c as classes } from './classes-0d95c529.js';
7
7
  import { g as getBorderRadius } from './getBorderRadius-178a0a05.js';
8
8
  import { i as isDarkColor } from './isDarkColor-416d6047.js';
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host } from './index-36ff6342.js';
2
- import { s as stripeStore } from './cart-b439be00.js';
3
- import { h as handleFetch, b as logError, i as isValidSelector, l as log, c as initLocalizationStore, d as localizationStoreUpdateSelectedCountryCode } from './localization-a51ccbc2.js';
2
+ import { s as stripeStore } from './cart-c5236eec.js';
3
+ import { h as handleFetch, b as logError, i as isValidSelector, l as log, c as initLocalizationStore, d as localizationStoreUpdateSelectedCountryCode } from './localization-3cb32a71.js';
4
4
  import { z as zonosStore, d as zonosStoreInitSetting, e as zonosStoreFontFamily } from './zonosStore-61e74f58.js';
5
5
  import './isDarkColor-416d6047.js';
6
6
  import './getBorderRadius-178a0a05.js';
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, H as Host, d as getElement } from './index-36ff6342.js';
2
- import { a as localizationStore, d as localizationStoreUpdateSelectedCountryCode, t as translate } from './localization-a51ccbc2.js';
2
+ import { a as localizationStore, d as localizationStoreUpdateSelectedCountryCode, t as translate } from './localization-3cb32a71.js';
3
3
  import { e as zonosStoreFontFamily } from './zonosStore-61e74f58.js';
4
4
  import { c as classes } from './classes-0d95c529.js';
5
5
  import { i as isDarkColor } from './isDarkColor-416d6047.js';
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host } from './index-36ff6342.js';
2
- import { k as currencyFormat, a as localizationStore, t as translate } from './localization-a51ccbc2.js';
2
+ import { k as currencyFormat, a as localizationStore, t as translate } from './localization-3cb32a71.js';
3
3
  import { z as zonosStore } from './zonosStore-61e74f58.js';
4
4
  import { c as classes } from './classes-0d95c529.js';
5
5
  import { g as getHasMoreSpaceOnRight } from './getHasMoreSpaceOnRight-70eb913a.js';
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, h, H as Host } from './index-36ff6342.js';
2
2
  import { _ as _root, i as isObjectLike_1, f as _baseGetTag, g as isObject_1, z as zonosStore, m as mergeConfig } from './zonosStore-61e74f58.js';
3
- import { h as handleFetch, b as logError, a as localizationStore, i as isValidSelector, t as translate, g as getZCountryUrlParam, s as setZCountryUrlParam, l as log, e as currencyDisplay, f as currencyConvertAndFormat, j as currencyConvert, k as currencyFormat } from './localization-a51ccbc2.js';
3
+ import { h as handleFetch, b as logError, a as localizationStore, i as isValidSelector, t as translate, g as getZCountryUrlParam, s as setZCountryUrlParam, l as log, e as currencyDisplay, f as currencyConvertAndFormat, j as currencyConvert, k as currencyFormat } from './localization-3cb32a71.js';
4
4
  import { c as classes } from './classes-0d95c529.js';
5
5
  import { g as getHasMoreSpaceOnRight } from './getHasMoreSpaceOnRight-70eb913a.js';
6
6
 
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, h, H as Host, d as getElement } from './index-36ff6342.js';
2
- import { s as stripeStore } from './cart-b439be00.js';
2
+ import { s as stripeStore } from './cart-c5236eec.js';
3
3
  import './zonosStore-61e74f58.js';
4
- import './localization-a51ccbc2.js';
4
+ import './localization-3cb32a71.js';
5
5
  import './isDarkColor-416d6047.js';
6
6
  import './getBorderRadius-178a0a05.js';
7
7
 
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,t,r,o){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function s(e){try{c(o["throw"](e))}catch(e){i(e)}}function c(e){e.done?r(e.value):n(e.value).then(a,s)}c((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,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(t){return c([e,t])}}function c(s){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(r=0)),r)try{if(o=1,n&&(i=s[0]&2?n["return"]:s[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;if(n=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:r.label++;return{value:s[1],done:false};case 5:r.label++;n=s[1];s=[0];continue;case 7:s=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){r.label=s[1];break}if(s[0]===6&&r.label<i[1]){r.label=i[1];i=s;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(s);break}if(i[2])r.ops.pop();r.trys.pop();continue}s=t.call(e,r)}catch(e){s=[6,e];n=0}finally{o=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{z as zonosStore,c as createStore}from"./zonosStore-61e74f58.js";import{h as handleFetch,l as log,a as localizationStore,b as logError,t as translate}from"./localization-a51ccbc2.js";import{i as isDarkColor}from"./isDarkColor-416d6047.js";import{g as getBorderRadius}from"./getBorderRadius-178a0a05.js";var prepCalculateLandedCost=function(){var e=stripeStore.stripeLinkEventData;var t=stripeStore.stripeAddressEventData;if(!t||!t.complete){throw new Error("Missing stripe address data")}return{checkoutSessionId:cartStore.checkoutSessionId||"",contact:{email:(e===null||e===void 0?void 0:e.value.email)||"",firstName:t.value.firstName||"",lastName:t.value.lastName||"",phone:t.value.phone||""},items:cartStore.items.map((function(e){return e})),shippingAddress:{addressLine1:t.value.address.line1,addressLine2:t.value.address.line2||"",city:t.value.address.city,country:t.value.address.country,postalCode:t.value.address.postal_code,state:t.value.address.state}}};var triggerBuildLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a;return __generator(this,(function(s){switch(s.label){case 0:r=prepCalculateLandedCost();return[4,e(r.checkoutSessionId,r.contact,r.shippingAddress)];case 1:o=s.sent();if(!o){throw new Error("Failed to build landed cost")}return[4,handleFetch("".concat("https://v1.route.js.zonos.com","/api/zonos-elements/validate-landed-cost"),{body:o,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:n=s.sent(),i=n.errors,a=n.json;if(!a||i.length){throw new Error("Invalid landed cost object: ".concat(((t=i.find(Boolean))===null||t===void 0?void 0:t.message)||"Unknown error"))}return[2,o]}}))}))};var calculateLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a;return __generator(this,(function(s){switch(s.label){case 0:t=zonosStore.checkoutSettings.buildLandedCost;if(!t)return[3,2];return[4,triggerBuildLandedCost(t)];case 1:r=s.sent();return[2,r];case 2:o="".concat("https://v1.route.js.zonos.com","/api/zonos-elements/calculate-landed-cost");return[4,handleFetch(o,{body:prepCalculateLandedCost(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:n=s.sent(),i=n.errors,a=n.json;if(i.length||!a){throw new Error("Failed to calculate landed cost")}return[2,a]}}))}))};var addressRuleStyle=function(e){var t=e.theme;switch(t){default:return{".Input":{padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"}}}};var defaultVariable=function(e){var t=e.borderStyle,r=e.theme;switch(r){case"DARK":return{borderRadius:getBorderRadius(t),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:getBorderRadius(t)}}};var _f=createStore((function(){return{clientSecret:sessionStorage.getItem("zonos--client-secret")||null,fetchingLandedCostAbordController:null,isFetchingLandedCost:false,isFetchingSession:false,stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenFetchingLC:null,stripeBillingAddressElement:null,stripeElements:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null}})),onChange$1=_f.onChange,reset$1=_f.reset,stripeStore=_f.state;var getStripeOptions=function(e){var t=e.clientSecret,r=e.overrideBorderRaidus,o=e.overridePrimaryColor,n=e.overrideTheme;var i=o||zonosStore.appearance.colorPrimary;var a=i&&isDarkColor(i)?"night":"flat";var s=n==="DARK"?"night":"flat";return{appearance:{labels:"floating",rules:Object.assign({},addressRuleStyle({theme:"LIGHT"})),theme:n?s:a,variables:Object.assign({},defaultVariable({borderStyle:r,theme:"LIGHT"}))},clientSecret:t,locale:localizationStore.selectedLocale}};var initStripeElements=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n;return __generator(this,(function(i){r=stripeStore.clientSecret;if(!stripeStore.stripe){log("Skip. Stripe is not initialized");return[2]}if(r){o=getStripeOptions({clientSecret:r,overrideBorderRaidus:e===null||e===void 0?void 0:e.overrideBorderRaidus,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme});n=JSON.stringify(o)===JSON.stringify(stripeStore.stripeElementsOptions);if(!stripeStore.stripeElements){stripeStore.stripeElements=(t=stripeStore.stripe)===null||t===void 0?void 0:t.elements(o);stripeStore.stripeElementsOptions=o;log("Stripe elements initialized");return[2]}if(!n){stripeStore.stripeElements.update(o);stripeStore.stripeElementsOptions=o}log("Stripe elements initialized")}return[2]}))}))};var stripeStoreReset=function(){sessionStorage.removeItem("zonos--client-secret");reset$1();stripeStore.stripe=window.Zonos.stripe};var isPrefetchInfoOutdated=function(){var e,t,r,o;var n=stripeStore.fetchingLandedCostAbordController;if(!n){return false}var i=JSON.stringify((e=stripeStore.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.value);var a=JSON.stringify((r=stripeStore.stripeAddressUsedWhenFetchingLC)===null||r===void 0?void 0:r.value)!==JSON.stringify((o=stripeStore.stripeAddressEventData)===null||o===void 0?void 0:o.value);return i||a};var stripeStorePrefetchLandedCost=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,c,u,l,d,p,S;return __generator(this,(function(f){switch(f.label){case 0:n=!!((e=stripeStore.stripeAddressEventData)===null||e===void 0?void 0:e.complete);i=!!((t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.complete);a=isPrefetchInfoOutdated();if(a){(r=stripeStore.fetchingLandedCostAbordController)===null||r===void 0?void 0:r.abort();stripeStore.fetchingLandedCostAbordController=null}if(!(n&&i&&(a||!stripeStore.isFetchingLandedCost)))return[3,5];stripeStore.isFetchingLandedCost=true;if(stripeStore.stripeAddressEventData){stripeStore.stripeAddressUsedWhenFetchingLC=Object.assign({},stripeStore.stripeAddressEventData)}if(stripeStore.stripeLinkEventData){stripeStore.stripeLinkUsedWhenFetchingLC=Object.assign({},stripeStore.stripeLinkEventData)}f.label=1;case 1:f.trys.push([1,3,,4]);s=new AbortController;stripeStore.fetchingLandedCostAbordController=s;return[4,calculateLandedCost(s)];case 2:c=f.sent(),u=c.checkoutSessionWorkflow,l=c.shipmentRatingCalculateWorkflow;stripeStore.fetchingLandedCostAbordController=null;cartStore.landedCostData=(u===null||u===void 0?void 0:u.filter(Boolean))||null;cartStore.shippingData=(l===null||l===void 0?void 0:l.filter(Boolean))||null;d=(o=cartStore.landedCostData)===null||o===void 0?void 0:o.find(Boolean);p=!!d?d.subtotals:null;if(p){cartStoreApplySubtotals({exchangeRate:p.exchangeRate,items:p.items,landedCostTotal:0,presentmentCurrencyCode:p.presentmentCurrencyCode,shipping:0,total:p.items})}return[3,4];case 3:S=f.sent();logError(S);return[3,4];case 4:stripeStore.isFetchingLandedCost=false;f.label=5;case 5:return[2]}}))}))};var getStripeMessageBasedOnStatus=function(e){var t=[];var r=true;switch(e){case"succeeded":{t=[translate("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"","",translate("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")];r=false;break}case"requires_capture":case"processing":{t=[translate("Payment processing. We'll update you when payment is received.")];r=false;break}case"requires_payment_method":{t=[translate("Payment failed. Please try another payment method.")];break}default:{t=[translate("Something went wrong.")];break}}return{isError:r,messages:t}};var stripeStoreRetrievePayment=function(e){var t=e.clientSecret,r=e.storybookForceStatus;return __awaiter(void 0,void 0,void 0,(function(){var e,o,n,i,a,s,c,u,l;return __generator(this,(function(d){switch(d.label){case 0:if(r){e=getStripeMessageBasedOnStatus(r),o=e.isError,n=e.messages;return[2,{error:o,messages:n}]}i=t||stripeStore.clientSecret;if(!stripeStore.stripe||!i){logError("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[translate("Something went wrong.")]}]}return[4,stripeStore.stripe.retrievePaymentIntent(i)];case 1:a=d.sent().paymentIntent;s=a===null||a===void 0?void 0:a.status;c=getStripeMessageBasedOnStatus(s),u=c.isError,l=c.messages;return[2,{error:u,messages:l}]}}))}))};var stripeStoreConfirmPayment=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s;return __generator(this,(function(c){switch(c.label){case 0:o=!!((e=stripeStore.stripePaymentEventData)===null||e===void 0?void 0:e.complete);n=stripeStore.stripeElements;i=stripeStore.stripe;a=stripeStore.clientSecret;if(!(i&&n&&o&&a))return[3,2];return[4,i.confirmPayment({confirmParams:{receipt_email:(r=(t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.value)===null||r===void 0?void 0:r.email,return_url:window.location.href},elements:n,redirect:"if_required"})];case 1:s=c.sent().error;if(s){if(s.type==="card_error"||s.type==="validation_error"){throw new Error(s.message)}if(s.type==="invalid_request_error"){if(s.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}c.label=2;case 2:return[2]}}))}))};var stripeStoreInitCheckoutSession=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i;return __generator(this,(function(a){switch(a.label){case 0:t=cartStore.items.reduce((function(e,t){return e+t.amount*t.quantity}),0);if(!t||!localizationStore.targetCurrency){logError("Fail to create checkout session - invalid total or currency");return[2,false]}stripeStore.isFetchingSession=true;return[4,handleFetch("".concat("https://v1.route.js.zonos.com","/api/zonos-elements/create-checkout-session"),{body:{currency:((e=cartStore.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",itemsAmount:t,presentmentCountryCode:localizationStore.selectedCountryCode||null},method:"POST"})];case 1:r=a.sent(),o=r.errors,n=r.json;stripeStore.isFetchingSession=false;if(o.length||!n){logError("Error occurs when creating checkout session",JSON.stringify(o,null,2));return[2,false]}i=n.checkoutSessionCreate;stripeStore.clientSecret=i.clientSecret;cartStore.checkoutSessionId=i.id;cartStoreApplySubtotals(Object.assign(Object.assign({},i.subtotals),{landedCostTotal:0,shipping:0,total:i.subtotals.items}));log("Exchange rate updated for cart items (checkout session create)","info",cartStore.exchangeRate);log("done-init-checkout-session");return[2,true]}}))}))};var stripeStoreUpdateCheckoutSession=function(e){var t=e.currency,r=e.id,o=e.itemsAmount,n=e.landedCostId,i=e.presentmentCountryCode;return __awaiter(void 0,void 0,void 0,(function(){var e,a,s;return __generator(this,(function(c){switch(c.label){case 0:return[4,handleFetch("".concat("https://v1.route.js.zonos.com","/api/zonos-elements/update-checkout-session"),{body:{currency:t,id:r,itemsAmount:o,landedCostId:n,presentmentCountryCode:i},method:"POST"})];case 1:e=c.sent(),a=e.errors,s=e.json;if(a.length||!s){logError("Error occurs when updating checkout session",JSON.stringify(a,null,2));return[2,{errors:a,json:s}]}return[2,{errors:[],json:s}]}}))}))};onChange$1("clientSecret",(function(e){if(e&&stripeStore.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var formatDate=function(e){var t=e.date,r=e.formatOptions,o=r===void 0?{day:"numeric",weekday:"long",year:"numeric"}:r;return new Intl.DateTimeFormat("en-US",o).format(t)};var getDaysDifference=function(e){var t=new Date;var r=e.getTime()-t.getTime();var o=Math.floor(r/(1e3*60*60*24));return o};var _g=createStore((function(){return{checkoutSessionId:sessionStorage.getItem("zonos--checkout-session-id")||null,currency:"USD",dutiesTaxFees:0,error:null,exchangeRate:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,items:[],landedCostData:null,selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,step:"customer-info",subtotal:0,total:0}})),onChange=_g.onChange,reset=_g.reset,cartStore=_g.state;var cartStoreGetShippingTransitInfo=function(e){var t=e.minTransitAt?getDaysDifference(new Date(e.minTransitAt)):"";var r=e.maxTransitAt?getDaysDifference(new Date(e.maxTransitAt)):"";var o=e.minTransitAt?formatDate({date:new Date(e.minTransitAt)}):"";return{expectedDate:o,maxTransit:r,minTransit:t}};var cartStoreReset=function(){sessionStorage.removeItem("zonos--checkout-session-id");reset()};var cartStoreUpdateToErrorState=function(e){var t=e.messages,r=e.title;cartStore.step="error";cartStore.error={messages:t,title:r}};var cartStoreApplySubtotals=function(e){cartStore.exchangeRate=e.exchangeRate;cartStore.dutiesTaxFees=e.landedCostTotal;cartStore.subtotal=e.items;cartStore.total=e.total;cartStore.currency=e.presentmentCurrencyCode};var cartStoreReCalculateTotal=function(e){var t=e.currency,r=e.itemsAmount,o=e.landedCostId;return __awaiter(void 0,void 0,void 0,(function(){var e,n;return __generator(this,(function(i){switch(i.label){case 0:if(o&&cartStore.selectedLandedCost){e=cartStore.selectedLandedCost.subtotals;cartStoreApplySubtotals(e);log("Exchange rate updated for cart items (landed cost subtotal)","info",cartStore.exchangeRate)}if(!cartStore.checkoutSessionId){logError("Could not update cart total without checkout session id");return[2,false]}return[4,stripeStoreUpdateCheckoutSession({currency:t,id:cartStore.checkoutSessionId,itemsAmount:r,landedCostId:o,presentmentCountryCode:localizationStore.selectedCountryCode})];case 1:n=i.sent().json;if(!n){logError("Error occurs when updating checkout session");cartStoreUpdateToErrorState({messages:[translate("There's been an error updating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error updating Checkout")});return[2,false]}if(!o){cartStoreApplySubtotals(n.checkoutSessionUpdate.subtotals);log("Exchange rate updated for cart items (checkout session update)","info",cartStore.exchangeRate)}return[2,true]}}))}))};var cartStoreUpdateSelectedShippingOption=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a,s,c,u,l,d,p,S;return __generator(this,(function(f){switch(f.label){case 0:cartStore.selectedShippingOption=e;a=cartStoreGetShippingTransitInfo(cartStore.selectedShippingOption),s=a.expectedDate,c=a.maxTransit,u=a.minTransit;cartStore.selectedShippingOptionExpectedDate=s;cartStore.selectedShippingOptionTransitTime=u&&c?"".concat(u,"-").concat(c):"".concat(u||c);l=(t=cartStore.landedCostData)===null||t===void 0?void 0:t.find((function(e){var t,r,o;return((r=(t=e.landedCost)===null||t===void 0?void 0:t.shipmentRating)===null||r===void 0?void 0:r.id)===((o=cartStore.selectedShippingOption)===null||o===void 0?void 0:o.id)}));cartStore.selectedLandedCost=l||null;if(!l){return[2,false]}cartStore.shipping=l.subtotals.shipping;d=((r=l===null||l===void 0?void 0:l.landedCost)===null||r===void 0?void 0:r.landedCostGuaranteeCode)==="ZONOS";p=!!((n=(o=l===null||l===void 0?void 0:l.landedCost)===null||o===void 0?void 0:o.deMinimis)===null||n===void 0?void 0:n.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));cartStore.isSelectedShippingAboveDeminimis=p;cartStore.isSelectedShippingGuarantee=d;return[4,cartStoreReCalculateTotal({landedCostId:(i=l.landedCost)===null||i===void 0?void 0:i.id})];case 1:S=f.sent();return[2,S]}}))}))};onChange("checkoutSessionId",(function(){if(!cartStore.checkoutSessionId){sessionStorage.removeItem("zonos--checkout-session-id");return}sessionStorage.setItem("zonos--checkout-session-id",cartStore.checkoutSessionId)}));var cartStoreUpdateItems=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o;return __generator(this,(function(n){switch(n.label){case 0:cartStore.items=e;r=(t=e.find(Boolean))===null||t===void 0?void 0:t.currencyCode;o=e.reduce((function(e,t){return e+t.amount*t.quantity}),0);if(!r||!o){return[2]}cartStore.currency=r;stripeStore.isFetchingSession=true;return[4,cartStoreReCalculateTotal({currency:r,itemsAmount:o})];case 1:n.sent();stripeStore.isFetchingSession=false;return[2]}}))}))};var cartStoreResetSelectedShippingOption=function(){cartStore.selectedShippingOption=null;cartStore.isSelectedShippingAboveDeminimis=false;cartStore.isSelectedShippingGuarantee=false;cartStore.selectedShippingOptionExpectedDate="";cartStore.selectedShippingOptionTransitTime="";cartStore.shipping=0};var cartStoreNextStep=function(){if(cartStore.step==="customer-info"){cartStore.step="shipping"}else if(cartStore.step==="shipping"){cartStore.step="payment"}else if(cartStore.step==="payment"){cartStore.step="finish"}};var cartStorePreviousStep=function(){if(cartStore.step==="payment"){cartStore.step="shipping"}else if(cartStore.step==="shipping"){cartStore.step="customer-info";cartStoreResetSelectedShippingOption()}};export{cartStoreApplySubtotals as a,cartStoreGetShippingTransitInfo as b,cartStore as c,cartStoreNextStep as d,cartStorePreviousStep as e,cartStoreReCalculateTotal as f,cartStoreReset as g,cartStoreUpdateItems as h,cartStoreUpdateSelectedShippingOption as i,cartStoreUpdateToErrorState as j,initStripeElements as k,stripeStoreInitCheckoutSession as l,stripeStorePrefetchLandedCost as m,stripeStoreConfirmPayment as n,stripeStoreReset as o,stripeStoreRetrievePayment as p,stripeStore as s};
1
+ var __awaiter=this&&this.__awaiter||function(e,t,r,o){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function s(e){try{c(o["throw"](e))}catch(e){i(e)}}function c(e){e.done?r(e.value):n(e.value).then(a,s)}c((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,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(t){return c([e,t])}}function c(s){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(r=0)),r)try{if(o=1,n&&(i=s[0]&2?n["return"]:s[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;if(n=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:r.label++;return{value:s[1],done:false};case 5:r.label++;n=s[1];s=[0];continue;case 7:s=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){r.label=s[1];break}if(s[0]===6&&r.label<i[1]){r.label=i[1];i=s;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(s);break}if(i[2])r.ops.pop();r.trys.pop();continue}s=t.call(e,r)}catch(e){s=[6,e];n=0}finally{o=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{z as zonosStore,c as createStore}from"./zonosStore-61e74f58.js";import{h as handleFetch,l as log,a as localizationStore,b as logError,t as translate}from"./localization-3cb32a71.js";import{i as isDarkColor}from"./isDarkColor-416d6047.js";import{g as getBorderRadius}from"./getBorderRadius-178a0a05.js";var prepCalculateLandedCost=function(){var e=stripeStore.stripeLinkEventData;var t=stripeStore.stripeAddressEventData;if(!t||!t.complete){throw new Error("Missing stripe address data")}return{checkoutSessionId:cartStore.checkoutSessionId||"",contact:{email:(e===null||e===void 0?void 0:e.value.email)||"",firstName:t.value.firstName||"",lastName:t.value.lastName||"",phone:t.value.phone||""},items:cartStore.items.map((function(e){return e})),shippingAddress:{addressLine1:t.value.address.line1,addressLine2:t.value.address.line2||"",city:t.value.address.city,country:t.value.address.country,postalCode:t.value.address.postal_code,state:t.value.address.state}}};var triggerBuildLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a;return __generator(this,(function(s){switch(s.label){case 0:r=prepCalculateLandedCost();return[4,e(r.checkoutSessionId,r.contact,r.shippingAddress)];case 1:o=s.sent();if(!o){throw new Error("Failed to build landed cost")}return[4,handleFetch("".concat("https://v1.route.js.zonos.com","/api/zonos-elements/validate-landed-cost"),{body:o,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:n=s.sent(),i=n.errors,a=n.json;if(!a||i.length){throw new Error("Invalid landed cost object: ".concat(((t=i.find(Boolean))===null||t===void 0?void 0:t.message)||"Unknown error"))}return[2,o]}}))}))};var calculateLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a;return __generator(this,(function(s){switch(s.label){case 0:t=zonosStore.checkoutSettings.buildLandedCost;if(!t)return[3,2];return[4,triggerBuildLandedCost(t)];case 1:r=s.sent();return[2,r];case 2:o="".concat("https://v1.route.js.zonos.com","/api/zonos-elements/calculate-landed-cost");return[4,handleFetch(o,{body:prepCalculateLandedCost(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:n=s.sent(),i=n.errors,a=n.json;if(i.length||!a){throw new Error("Failed to calculate landed cost")}return[2,a]}}))}))};var addressRuleStyle=function(e){var t=e.theme;switch(t){default:return{".Input":{padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"}}}};var defaultVariable=function(e){var t=e.borderStyle,r=e.theme;switch(r){case"DARK":return{borderRadius:getBorderRadius(t),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:getBorderRadius(t)}}};var _f=createStore((function(){return{clientSecret:sessionStorage.getItem("zonos--client-secret")||null,fetchingLandedCostAbordController:null,isFetchingLandedCost:false,isFetchingSession:false,stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenFetchingLC:null,stripeBillingAddressElement:null,stripeElements:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null}})),onChange$1=_f.onChange,reset$1=_f.reset,stripeStore=_f.state;var getStripeOptions=function(e){var t=e.clientSecret,r=e.overrideBorderRaidus,o=e.overridePrimaryColor,n=e.overrideTheme;var i=o||zonosStore.appearance.colorPrimary;var a=i&&isDarkColor(i)?"night":"flat";var s=n==="DARK"?"night":"flat";return{appearance:{labels:"floating",rules:Object.assign({},addressRuleStyle({theme:"LIGHT"})),theme:n?s:a,variables:Object.assign({},defaultVariable({borderStyle:r,theme:"LIGHT"}))},clientSecret:t,locale:localizationStore.selectedLocale}};var initStripeElements=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n;return __generator(this,(function(i){r=stripeStore.clientSecret;if(!stripeStore.stripe){log("Skip. Stripe is not initialized");return[2]}if(r){o=getStripeOptions({clientSecret:r,overrideBorderRaidus:e===null||e===void 0?void 0:e.overrideBorderRaidus,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme});n=JSON.stringify(o)===JSON.stringify(stripeStore.stripeElementsOptions);if(!stripeStore.stripeElements){stripeStore.stripeElements=(t=stripeStore.stripe)===null||t===void 0?void 0:t.elements(o);stripeStore.stripeElementsOptions=o;log("Stripe elements initialized");return[2]}if(!n){stripeStore.stripeElements.update(o);stripeStore.stripeElementsOptions=o}log("Stripe elements initialized")}return[2]}))}))};var stripeStoreReset=function(){sessionStorage.removeItem("zonos--client-secret");reset$1();stripeStore.stripe=window.Zonos.stripe};var isPrefetchInfoOutdated=function(){var e,t,r,o;var n=stripeStore.fetchingLandedCostAbordController;if(!n){return false}var i=JSON.stringify((e=stripeStore.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.value);var a=JSON.stringify((r=stripeStore.stripeAddressUsedWhenFetchingLC)===null||r===void 0?void 0:r.value)!==JSON.stringify((o=stripeStore.stripeAddressEventData)===null||o===void 0?void 0:o.value);return i||a};var stripeStorePrefetchLandedCost=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,c,u,l,d,p,S;return __generator(this,(function(f){switch(f.label){case 0:n=!!((e=stripeStore.stripeAddressEventData)===null||e===void 0?void 0:e.complete);i=!!((t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.complete);a=isPrefetchInfoOutdated();if(a){(r=stripeStore.fetchingLandedCostAbordController)===null||r===void 0?void 0:r.abort();stripeStore.fetchingLandedCostAbordController=null}if(!(n&&i&&(a||!stripeStore.isFetchingLandedCost)))return[3,5];stripeStore.isFetchingLandedCost=true;if(stripeStore.stripeAddressEventData){stripeStore.stripeAddressUsedWhenFetchingLC=Object.assign({},stripeStore.stripeAddressEventData)}if(stripeStore.stripeLinkEventData){stripeStore.stripeLinkUsedWhenFetchingLC=Object.assign({},stripeStore.stripeLinkEventData)}f.label=1;case 1:f.trys.push([1,3,,4]);s=new AbortController;stripeStore.fetchingLandedCostAbordController=s;return[4,calculateLandedCost(s)];case 2:c=f.sent(),u=c.checkoutSessionWorkflow,l=c.shipmentRatingCalculateWorkflow;stripeStore.fetchingLandedCostAbordController=null;cartStore.landedCostData=(u===null||u===void 0?void 0:u.filter(Boolean))||null;cartStore.shippingData=(l===null||l===void 0?void 0:l.filter(Boolean))||null;d=(o=cartStore.landedCostData)===null||o===void 0?void 0:o.find(Boolean);p=!!d?d.subtotals:null;if(p){cartStoreApplySubtotals({exchangeRate:p.exchangeRate,items:p.items,landedCostTotal:0,presentmentCurrencyCode:p.presentmentCurrencyCode,shipping:0,total:p.items})}return[3,4];case 3:S=f.sent();logError(S);return[3,4];case 4:stripeStore.isFetchingLandedCost=false;f.label=5;case 5:return[2]}}))}))};var getStripeMessageBasedOnStatus=function(e){var t=[];var r=true;switch(e){case"succeeded":{t=[translate("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"","",translate("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")];r=false;break}case"requires_capture":case"processing":{t=[translate("Payment processing. We'll update you when payment is received.")];r=false;break}case"requires_payment_method":{t=[translate("Payment failed. Please try another payment method.")];break}default:{t=[translate("Something went wrong.")];break}}return{isError:r,messages:t}};var stripeStoreRetrievePayment=function(e){var t=e.clientSecret,r=e.storybookForceStatus;return __awaiter(void 0,void 0,void 0,(function(){var e,o,n,i,a,s,c,u,l;return __generator(this,(function(d){switch(d.label){case 0:if(r){e=getStripeMessageBasedOnStatus(r),o=e.isError,n=e.messages;return[2,{error:o,messages:n}]}i=t||stripeStore.clientSecret;if(!stripeStore.stripe||!i){logError("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[translate("Something went wrong.")]}]}return[4,stripeStore.stripe.retrievePaymentIntent(i)];case 1:a=d.sent().paymentIntent;s=a===null||a===void 0?void 0:a.status;c=getStripeMessageBasedOnStatus(s),u=c.isError,l=c.messages;return[2,{error:u,messages:l}]}}))}))};var stripeStoreConfirmPayment=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s;return __generator(this,(function(c){switch(c.label){case 0:o=!!((e=stripeStore.stripePaymentEventData)===null||e===void 0?void 0:e.complete);n=stripeStore.stripeElements;i=stripeStore.stripe;a=stripeStore.clientSecret;if(!(i&&n&&o&&a))return[3,2];return[4,i.confirmPayment({confirmParams:{receipt_email:(r=(t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.value)===null||r===void 0?void 0:r.email,return_url:window.location.href},elements:n,redirect:"if_required"})];case 1:s=c.sent().error;if(s){if(s.type==="card_error"||s.type==="validation_error"){throw new Error(s.message)}if(s.type==="invalid_request_error"){if(s.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}c.label=2;case 2:return[2]}}))}))};var stripeStoreInitCheckoutSession=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i;return __generator(this,(function(a){switch(a.label){case 0:t=cartStore.items.reduce((function(e,t){return e+t.amount*t.quantity}),0);if(!t||!localizationStore.targetCurrency){logError("Fail to create checkout session - invalid total or currency");return[2,false]}stripeStore.isFetchingSession=true;return[4,handleFetch("".concat("https://v1.route.js.zonos.com","/api/zonos-elements/create-checkout-session"),{body:{currency:((e=cartStore.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",itemsAmount:t,presentmentCountryCode:localizationStore.selectedCountryCode||null},method:"POST"})];case 1:r=a.sent(),o=r.errors,n=r.json;stripeStore.isFetchingSession=false;if(o.length||!n){logError("Error occurs when creating checkout session",JSON.stringify(o,null,2));return[2,false]}i=n.checkoutSessionCreate;stripeStore.clientSecret=i.clientSecret;cartStore.checkoutSessionId=i.id;cartStoreApplySubtotals(Object.assign(Object.assign({},i.subtotals),{landedCostTotal:0,shipping:0,total:i.subtotals.items}));log("Exchange rate updated for cart items (checkout session create)","info",cartStore.exchangeRate);log("done-init-checkout-session");return[2,true]}}))}))};var stripeStoreUpdateCheckoutSession=function(e){var t=e.currency,r=e.id,o=e.itemsAmount,n=e.landedCostId,i=e.presentmentCountryCode;return __awaiter(void 0,void 0,void 0,(function(){var e,a,s;return __generator(this,(function(c){switch(c.label){case 0:return[4,handleFetch("".concat("https://v1.route.js.zonos.com","/api/zonos-elements/update-checkout-session"),{body:{currency:t,id:r,itemsAmount:o,landedCostId:n,presentmentCountryCode:i},method:"POST"})];case 1:e=c.sent(),a=e.errors,s=e.json;if(a.length||!s){logError("Error occurs when updating checkout session",JSON.stringify(a,null,2));return[2,{errors:a,json:s}]}return[2,{errors:[],json:s}]}}))}))};onChange$1("clientSecret",(function(e){if(e&&stripeStore.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var formatDate=function(e){var t=e.date,r=e.formatOptions,o=r===void 0?{day:"numeric",weekday:"long",year:"numeric"}:r;return new Intl.DateTimeFormat("en-US",o).format(t)};var getDaysDifference=function(e){var t=new Date;var r=e.getTime()-t.getTime();var o=Math.floor(r/(1e3*60*60*24));return o};var _g=createStore((function(){return{checkoutSessionId:sessionStorage.getItem("zonos--checkout-session-id")||null,currency:"USD",dutiesTaxFees:0,error:null,exchangeRate:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,items:[],landedCostData:null,selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,step:"customer-info",subtotal:0,total:0}})),onChange=_g.onChange,reset=_g.reset,cartStore=_g.state;var cartStoreGetShippingTransitInfo=function(e){var t=e.minTransitAt?getDaysDifference(new Date(e.minTransitAt)):"";var r=e.maxTransitAt?getDaysDifference(new Date(e.maxTransitAt)):"";var o=e.minTransitAt?formatDate({date:new Date(e.minTransitAt)}):"";return{expectedDate:o,maxTransit:r,minTransit:t}};var cartStoreReset=function(){sessionStorage.removeItem("zonos--checkout-session-id");reset()};var cartStoreUpdateToErrorState=function(e){var t=e.messages,r=e.title;cartStore.step="error";cartStore.error={messages:t,title:r}};var cartStoreApplySubtotals=function(e){cartStore.exchangeRate=e.exchangeRate;cartStore.dutiesTaxFees=e.landedCostTotal;cartStore.subtotal=e.items;cartStore.total=e.total;cartStore.currency=e.presentmentCurrencyCode};var cartStoreReCalculateTotal=function(e){var t=e.currency,r=e.itemsAmount,o=e.landedCostId;return __awaiter(void 0,void 0,void 0,(function(){var e,n;return __generator(this,(function(i){switch(i.label){case 0:if(o&&cartStore.selectedLandedCost){e=cartStore.selectedLandedCost.subtotals;cartStoreApplySubtotals(e);log("Exchange rate updated for cart items (landed cost subtotal)","info",cartStore.exchangeRate)}if(!cartStore.checkoutSessionId){logError("Could not update cart total without checkout session id");return[2,false]}return[4,stripeStoreUpdateCheckoutSession({currency:t,id:cartStore.checkoutSessionId,itemsAmount:r,landedCostId:o,presentmentCountryCode:localizationStore.selectedCountryCode})];case 1:n=i.sent().json;if(!n){logError("Error occurs when updating checkout session");cartStoreUpdateToErrorState({messages:[translate("There's been an error updating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error updating Checkout")});return[2,false]}if(!o){cartStoreApplySubtotals(n.checkoutSessionUpdate.subtotals);log("Exchange rate updated for cart items (checkout session update)","info",cartStore.exchangeRate)}return[2,true]}}))}))};var cartStoreUpdateSelectedShippingOption=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a,s,c,u,l,d,p,S;return __generator(this,(function(f){switch(f.label){case 0:cartStore.selectedShippingOption=e;a=cartStoreGetShippingTransitInfo(cartStore.selectedShippingOption),s=a.expectedDate,c=a.maxTransit,u=a.minTransit;cartStore.selectedShippingOptionExpectedDate=s;cartStore.selectedShippingOptionTransitTime=u&&c?"".concat(u,"-").concat(c):"".concat(u||c);l=(t=cartStore.landedCostData)===null||t===void 0?void 0:t.find((function(e){var t,r,o;return((r=(t=e.landedCost)===null||t===void 0?void 0:t.shipmentRating)===null||r===void 0?void 0:r.id)===((o=cartStore.selectedShippingOption)===null||o===void 0?void 0:o.id)}));cartStore.selectedLandedCost=l||null;if(!l){return[2,false]}cartStore.shipping=l.subtotals.shipping;d=((r=l===null||l===void 0?void 0:l.landedCost)===null||r===void 0?void 0:r.landedCostGuaranteeCode)==="ZONOS";p=!!((n=(o=l===null||l===void 0?void 0:l.landedCost)===null||o===void 0?void 0:o.deMinimis)===null||n===void 0?void 0:n.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));cartStore.isSelectedShippingAboveDeminimis=p;cartStore.isSelectedShippingGuarantee=d;return[4,cartStoreReCalculateTotal({landedCostId:(i=l.landedCost)===null||i===void 0?void 0:i.id})];case 1:S=f.sent();return[2,S]}}))}))};onChange("checkoutSessionId",(function(){if(!cartStore.checkoutSessionId){sessionStorage.removeItem("zonos--checkout-session-id");return}sessionStorage.setItem("zonos--checkout-session-id",cartStore.checkoutSessionId)}));var cartStoreUpdateItems=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o;return __generator(this,(function(n){switch(n.label){case 0:cartStore.items=e;r=(t=e.find(Boolean))===null||t===void 0?void 0:t.currencyCode;o=e.reduce((function(e,t){return e+t.amount*t.quantity}),0);if(!r||!o){return[2]}cartStore.currency=r;stripeStore.isFetchingSession=true;return[4,cartStoreReCalculateTotal({currency:r,itemsAmount:o})];case 1:n.sent();stripeStore.isFetchingSession=false;return[2]}}))}))};var cartStoreResetSelectedShippingOption=function(){cartStore.selectedShippingOption=null;cartStore.isSelectedShippingAboveDeminimis=false;cartStore.isSelectedShippingGuarantee=false;cartStore.selectedShippingOptionExpectedDate="";cartStore.selectedShippingOptionTransitTime="";cartStore.shipping=0};var cartStoreNextStep=function(){if(cartStore.step==="customer-info"){cartStore.step="shipping"}else if(cartStore.step==="shipping"){cartStore.step="payment"}else if(cartStore.step==="payment"){cartStore.step="finish"}};var cartStorePreviousStep=function(){if(cartStore.step==="payment"){cartStore.step="shipping"}else if(cartStore.step==="shipping"){cartStore.step="customer-info";cartStoreResetSelectedShippingOption()}};export{cartStoreApplySubtotals as a,cartStoreGetShippingTransitInfo as b,cartStore as c,cartStoreNextStep as d,cartStorePreviousStep as e,cartStoreReCalculateTotal as f,cartStoreReset as g,cartStoreUpdateItems as h,cartStoreUpdateSelectedShippingOption as i,cartStoreUpdateToErrorState as j,initStripeElements as k,stripeStoreInitCheckoutSession as l,stripeStorePrefetchLandedCost as m,stripeStoreConfirmPayment as n,stripeStoreReset as o,stripeStoreRetrievePayment as p,stripeStore as s};
@@ -1 +1 @@
1
- export{c as cartStore,a as cartStoreApplySubtotals,b as cartStoreGetShippingTransitInfo,d as cartStoreNextStep,e as cartStorePreviousStep,f as cartStoreReCalculateTotal,g as cartStoreReset,h as cartStoreUpdateItems,i as cartStoreUpdateSelectedShippingOption,j as cartStoreUpdateToErrorState}from"./cart-b439be00.js";import"./zonosStore-61e74f58.js";import"./index-36ff6342.js";import"./localization-a51ccbc2.js";import"./isDarkColor-416d6047.js";import"./getBorderRadius-178a0a05.js";
1
+ export{c as cartStore,a as cartStoreApplySubtotals,b as cartStoreGetShippingTransitInfo,d as cartStoreNextStep,e as cartStorePreviousStep,f as cartStoreReCalculateTotal,g as cartStoreReset,h as cartStoreUpdateItems,i as cartStoreUpdateSelectedShippingOption,j as cartStoreUpdateToErrorState}from"./cart-c5236eec.js";import"./zonosStore-61e74f58.js";import"./index-36ff6342.js";import"./localization-3cb32a71.js";import"./isDarkColor-416d6047.js";import"./getBorderRadius-178a0a05.js";
@@ -1 +1 @@
1
- import{z as zonosStore}from"./zonosStore-61e74f58.js";import{l as log}from"./localization-a51ccbc2.js";var checkoutBreakpoint=890;var isCheckoutMobile=function(o){return o||window.innerWidth<checkoutBreakpoint};var submitGtag=function(o){var t=zonosStore.checkoutSettings.analyticsProviders.find((function(o){return o.type==="GOOGLE_ANALYTICS"}));if(!t||(t===null||t===void 0?void 0:t.status)==="DISABLED"){return}if(typeof window.gtag==="function"){log("Zonos submits gtag event","log",o);window.gtag("event",o,{})}};export{isCheckoutMobile as i,submitGtag as s};
1
+ import{z as zonosStore}from"./zonosStore-61e74f58.js";import{l as log}from"./localization-3cb32a71.js";var checkoutBreakpoint=890;var isCheckoutMobile=function(o){return o||window.innerWidth<checkoutBreakpoint};var submitGtag=function(o){var t=zonosStore.checkoutSettings.analyticsProviders.find((function(o){return o.type==="GOOGLE_ANALYTICS"}));if(!t||(t===null||t===void 0?void 0:t.status)==="DISABLED"){return}if(typeof window.gtag==="function"){log("Zonos submits gtag event","log",o);window.gtag("event",o,{})}};export{isCheckoutMobile as i,submitGtag as s};
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(n,t,o,s){function e(n){return n instanceof o?n:new o((function(t){t(n)}))}return new(o||(o=Promise))((function(o,i){function a(n){try{c(s.next(n))}catch(n){i(n)}}function r(n){try{c(s["throw"](n))}catch(n){i(n)}}function c(n){n.done?o(n.value):e(n.value).then(a,r)}c((s=s.apply(n,t||[])).next())}))};var __generator=this&&this.__generator||function(n,t){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},s,e,i,a;return a={next:r(0),throw:r(1),return:r(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function r(n){return function(t){return c([n,t])}}function c(r){if(s)throw new TypeError("Generator is already executing.");while(a&&(a=0,r[0]&&(o=0)),o)try{if(s=1,e&&(i=r[0]&2?e["return"]:r[0]?e["throw"]||((i=e["return"])&&i.call(e),0):e.next)&&!(i=i.call(e,r[1])).done)return i;if(e=0,i)r=[r[0]&2,i.value];switch(r[0]){case 0:case 1:i=r;break;case 4:o.label++;return{value:r[1],done:false};case 5:o.label++;e=r[1];r=[0];continue;case 7:r=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(r[0]===6||r[0]===2)){o=0;continue}if(r[0]===3&&(!i||r[1]>i[0]&&r[1]<i[3])){o.label=r[1];break}if(r[0]===6&&o.label<i[1]){o.label=i[1];i=r;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(r);break}if(i[2])o.ops.pop();o.trys.pop();continue}r=t.call(n,o)}catch(n){r=[6,n];e=0}finally{s=i=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};import{r as registerInstance,h,H as Host,d as getElement}from"./index-36ff6342.js";import{s as stripeStore,m as stripeStorePrefetchLandedCost}from"./cart-b439be00.js";import{b as logError,a as localizationStore}from"./localization-a51ccbc2.js";import"./zonosStore-61e74f58.js";import"./isDarkColor-416d6047.js";import"./getBorderRadius-178a0a05.js";var zonosAddressCss=".sc-zonos-address-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-address-h *.sc-zonos-address{font-family:var(--font-family, Inter), Inter}.sc-zonos-address-h img.sc-zonos-address{max-width:100%}.sc-zonos-address-h dl.sc-zonos-address,.sc-zonos-address-h dd.sc-zonos-address,.sc-zonos-address-h h1.sc-zonos-address,.sc-zonos-address-h h2.sc-zonos-address,.sc-zonos-address-h h3.sc-zonos-address,.sc-zonos-address-h h4.sc-zonos-address,.sc-zonos-address-h h5.sc-zonos-address,.sc-zonos-address-h h6.sc-zonos-address,.sc-zonos-address-h hr.sc-zonos-address,.sc-zonos-address-h figure.sc-zonos-address,.sc-zonos-address-h p.sc-zonos-address,.sc-zonos-address-h pre.sc-zonos-address{margin:0}.sc-zonos-address-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-address-h .zonos--title.sc-zonos-address{margin-bottom:var(--amino-space-16)}";var ZonosAddress=function(){function n(n){registerInstance(this,n);this.type=undefined;this.titleText=undefined;this.defaultAddress=null;this.stripe=window.Zonos.stripe}n.prototype.watchInitStripe=function(){return __awaiter(this,void 0,void 0,(function(){var n,t,o,s,e;return __generator(this,(function(i){this.stripe=window.Zonos.stripe;if(!this.stripe||!stripeStore.stripeElements){logError("Stripe is not initialized. Couldn't load stripe element.");return[2]}o=(n=this.defaultAddress)===null||n===void 0?void 0:n.phone;if(!o){(t=this.defaultAddress)===null||t===void 0?true:delete t.phone}s=localizationStore.shippingZoneCountries;e=stripeStore.stripeAddressElement||stripeStore.stripeElements.create("address",{allowedCountries:s?Object.values(s).map((function(n){return n.code})):[],contacts:this.defaultAddress?[this.defaultAddress]:undefined,defaultValues:{address:{country:localizationStore.selectedCountryCode||"AL"}},display:{name:"split"},fields:{phone:"always"},mode:this.type,validation:{phone:{required:"always"}}});e.mount(this.el.querySelector(".zonos--address-component"));e.on("change",(function(n){var t=n.value;stripeStore.stripeAddressEventData=Object.assign(Object.assign({},n),{elementMode:"shipping",elementType:"address",empty:false,value:Object.assign(Object.assign({},t),{firstName:t.firstName||t.name.split(" ")[0],lastName:t.lastName||t.name.split(" ").pop()})});void stripeStorePrefetchLandedCost()}));stripeStore.stripeAddressElement=e;return[2]}))}))};n.prototype.componentDidLoad=function(){void this.watchInitStripe()};n.prototype.render=function(){return h(Host,{class:"zonos--address zonos--elements"},h("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),h("div",{class:"zonos--address-component"}))};Object.defineProperty(n.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(n,"watchers",{get:function(){return{stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return n}();ZonosAddress.style=zonosAddressCss;var zonosLinkAuthenticationCss=".sc-zonos-link-authentication-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-link-authentication-h *.sc-zonos-link-authentication{font-family:var(--font-family, Inter), Inter}.sc-zonos-link-authentication-h img.sc-zonos-link-authentication{max-width:100%}.sc-zonos-link-authentication-h dl.sc-zonos-link-authentication,.sc-zonos-link-authentication-h dd.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h1.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h2.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h3.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h4.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h5.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h6.sc-zonos-link-authentication,.sc-zonos-link-authentication-h hr.sc-zonos-link-authentication,.sc-zonos-link-authentication-h figure.sc-zonos-link-authentication,.sc-zonos-link-authentication-h p.sc-zonos-link-authentication,.sc-zonos-link-authentication-h pre.sc-zonos-link-authentication{margin:0}.sc-zonos-link-authentication-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-link-authentication-h .zonos--title.sc-zonos-link-authentication{margin-bottom:var(--amino-space-16)}";var ZonosLinkAuthentication=function(){function n(n){registerInstance(this,n);this.titleText=undefined;this.stripe=stripeStore.stripe}n.prototype.watchInitStripe=function(){if(!this.stripe||!stripeStore.stripeElements){return}var n=stripeStore.stripeLinkElement||stripeStore.stripeElements.create("linkAuthentication");var t=this.el.querySelector(".zonos--link-authentication-component");if(!t){console.error("Cannot find container element for linkAuthenticationElement");return}n.mount(t);n.on("change",(function(n){stripeStore.stripeLinkEventData=n;void stripeStorePrefetchLandedCost()}));stripeStore.stripeLinkElement=n};n.prototype.componentDidLoad=function(){this.watchInitStripe()};n.prototype.render=function(){return h(Host,{class:"zonos--link-authentication zonos--elements"},h("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),h("div",{class:"zonos--link-authentication-component"}))};Object.defineProperty(n.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(n,"watchers",{get:function(){return{stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return n}();ZonosLinkAuthentication.style=zonosLinkAuthenticationCss;export{ZonosAddress as zonos_address,ZonosLinkAuthentication as zonos_link_authentication};
1
+ var __awaiter=this&&this.__awaiter||function(n,t,o,s){function e(n){return n instanceof o?n:new o((function(t){t(n)}))}return new(o||(o=Promise))((function(o,i){function a(n){try{c(s.next(n))}catch(n){i(n)}}function r(n){try{c(s["throw"](n))}catch(n){i(n)}}function c(n){n.done?o(n.value):e(n.value).then(a,r)}c((s=s.apply(n,t||[])).next())}))};var __generator=this&&this.__generator||function(n,t){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},s,e,i,a;return a={next:r(0),throw:r(1),return:r(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function r(n){return function(t){return c([n,t])}}function c(r){if(s)throw new TypeError("Generator is already executing.");while(a&&(a=0,r[0]&&(o=0)),o)try{if(s=1,e&&(i=r[0]&2?e["return"]:r[0]?e["throw"]||((i=e["return"])&&i.call(e),0):e.next)&&!(i=i.call(e,r[1])).done)return i;if(e=0,i)r=[r[0]&2,i.value];switch(r[0]){case 0:case 1:i=r;break;case 4:o.label++;return{value:r[1],done:false};case 5:o.label++;e=r[1];r=[0];continue;case 7:r=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(r[0]===6||r[0]===2)){o=0;continue}if(r[0]===3&&(!i||r[1]>i[0]&&r[1]<i[3])){o.label=r[1];break}if(r[0]===6&&o.label<i[1]){o.label=i[1];i=r;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(r);break}if(i[2])o.ops.pop();o.trys.pop();continue}r=t.call(n,o)}catch(n){r=[6,n];e=0}finally{s=i=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};import{r as registerInstance,h,H as Host,d as getElement}from"./index-36ff6342.js";import{s as stripeStore,m as stripeStorePrefetchLandedCost}from"./cart-c5236eec.js";import{b as logError,a as localizationStore}from"./localization-3cb32a71.js";import"./zonosStore-61e74f58.js";import"./isDarkColor-416d6047.js";import"./getBorderRadius-178a0a05.js";var zonosAddressCss=".sc-zonos-address-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-address-h *.sc-zonos-address{font-family:var(--font-family, Inter), Inter}.sc-zonos-address-h img.sc-zonos-address{max-width:100%}.sc-zonos-address-h dl.sc-zonos-address,.sc-zonos-address-h dd.sc-zonos-address,.sc-zonos-address-h h1.sc-zonos-address,.sc-zonos-address-h h2.sc-zonos-address,.sc-zonos-address-h h3.sc-zonos-address,.sc-zonos-address-h h4.sc-zonos-address,.sc-zonos-address-h h5.sc-zonos-address,.sc-zonos-address-h h6.sc-zonos-address,.sc-zonos-address-h hr.sc-zonos-address,.sc-zonos-address-h figure.sc-zonos-address,.sc-zonos-address-h p.sc-zonos-address,.sc-zonos-address-h pre.sc-zonos-address{margin:0}.sc-zonos-address-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-address-h .zonos--title.sc-zonos-address{margin-bottom:var(--amino-space-16)}";var ZonosAddress=function(){function n(n){registerInstance(this,n);this.type=undefined;this.titleText=undefined;this.defaultAddress=null;this.stripe=window.Zonos.stripe}n.prototype.watchInitStripe=function(){return __awaiter(this,void 0,void 0,(function(){var n,t,o,s,e;return __generator(this,(function(i){this.stripe=window.Zonos.stripe;if(!this.stripe||!stripeStore.stripeElements){logError("Stripe is not initialized. Couldn't load stripe element.");return[2]}o=(n=this.defaultAddress)===null||n===void 0?void 0:n.phone;if(!o){(t=this.defaultAddress)===null||t===void 0?true:delete t.phone}s=localizationStore.shippingZoneCountries;e=stripeStore.stripeAddressElement||stripeStore.stripeElements.create("address",{allowedCountries:s?Object.values(s).map((function(n){return n.code})):[],contacts:this.defaultAddress?[this.defaultAddress]:undefined,defaultValues:{address:{country:localizationStore.selectedCountryCode||"AL"}},display:{name:"split"},fields:{phone:"always"},mode:this.type,validation:{phone:{required:"always"}}});e.mount(this.el.querySelector(".zonos--address-component"));e.on("change",(function(n){var t=n.value;stripeStore.stripeAddressEventData=Object.assign(Object.assign({},n),{elementMode:"shipping",elementType:"address",empty:false,value:Object.assign(Object.assign({},t),{firstName:t.firstName||t.name.split(" ")[0],lastName:t.lastName||t.name.split(" ").pop()})});void stripeStorePrefetchLandedCost()}));stripeStore.stripeAddressElement=e;return[2]}))}))};n.prototype.componentDidLoad=function(){void this.watchInitStripe()};n.prototype.render=function(){return h(Host,{class:"zonos--address zonos--elements"},h("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),h("div",{class:"zonos--address-component"}))};Object.defineProperty(n.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(n,"watchers",{get:function(){return{stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return n}();ZonosAddress.style=zonosAddressCss;var zonosLinkAuthenticationCss=".sc-zonos-link-authentication-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-link-authentication-h *.sc-zonos-link-authentication{font-family:var(--font-family, Inter), Inter}.sc-zonos-link-authentication-h img.sc-zonos-link-authentication{max-width:100%}.sc-zonos-link-authentication-h dl.sc-zonos-link-authentication,.sc-zonos-link-authentication-h dd.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h1.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h2.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h3.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h4.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h5.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h6.sc-zonos-link-authentication,.sc-zonos-link-authentication-h hr.sc-zonos-link-authentication,.sc-zonos-link-authentication-h figure.sc-zonos-link-authentication,.sc-zonos-link-authentication-h p.sc-zonos-link-authentication,.sc-zonos-link-authentication-h pre.sc-zonos-link-authentication{margin:0}.sc-zonos-link-authentication-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-link-authentication-h .zonos--title.sc-zonos-link-authentication{margin-bottom:var(--amino-space-16)}";var ZonosLinkAuthentication=function(){function n(n){registerInstance(this,n);this.titleText=undefined;this.stripe=stripeStore.stripe}n.prototype.watchInitStripe=function(){if(!this.stripe||!stripeStore.stripeElements){return}var n=stripeStore.stripeLinkElement||stripeStore.stripeElements.create("linkAuthentication");var t=this.el.querySelector(".zonos--link-authentication-component");if(!t){console.error("Cannot find container element for linkAuthenticationElement");return}n.mount(t);n.on("change",(function(n){stripeStore.stripeLinkEventData=n;void stripeStorePrefetchLandedCost()}));stripeStore.stripeLinkElement=n};n.prototype.componentDidLoad=function(){this.watchInitStripe()};n.prototype.render=function(){return h(Host,{class:"zonos--link-authentication zonos--elements"},h("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),h("div",{class:"zonos--link-authentication-component"}))};Object.defineProperty(n.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(n,"watchers",{get:function(){return{stripe:["watchInitStripe"]}},enumerable:false,configurable:true});return n}();ZonosLinkAuthentication.style=zonosLinkAuthenticationCss;export{ZonosAddress as zonos_address,ZonosLinkAuthentication as zonos_link_authentication};