@zonos/elements 1.4.1 → 1.5.0

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 (43) hide show
  1. package/dist/cjs/index.cjs.js +7 -7
  2. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +66 -3
  3. package/dist/cjs/zonos-checkout.cjs.entry.js +97 -10
  4. package/dist/collection/components/checkout/zonos-checkout/zonos-cart-items/zonos-cart-items.css +10 -0
  5. package/dist/collection/components/checkout/zonos-checkout/zonos-cart-items/zonos-cart-items.js +6 -2
  6. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +7 -10
  7. package/dist/collection/components/utils/checkout/isBigCommerceCheckoutBypassEnabled.js +74 -0
  8. package/dist/collection/components/utils/checkout/isHostedVsNativeTestAllowed.js +13 -0
  9. package/dist/collection/components/utils/checkout/itemCustomization.js +53 -0
  10. package/dist/collection/components/utils/checkout/parseItemCustomizations.js +6 -0
  11. package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +8 -0
  12. package/dist/collection/types/checkout/itemCustomization.js +1 -0
  13. package/dist/collection/types/index.js +1 -0
  14. package/dist/esm/index.js +7 -7
  15. package/dist/esm/zonos-cart-items_12.entry.js +66 -3
  16. package/dist/esm/zonos-checkout.entry.js +97 -10
  17. package/dist/esm-es5/index.js +4 -4
  18. package/dist/esm-es5/zonos-cart-items_12.entry.js +23 -10
  19. package/dist/esm-es5/zonos-checkout.entry.js +44 -19
  20. package/dist/scripts/index.d.ts +14 -0
  21. package/dist/scripts/index.js +1 -1
  22. package/dist/scripts/loadZonos.js +1 -1
  23. package/dist/scripts/zonos.js +1 -1
  24. package/dist/types/components/utils/checkout/isBigCommerceCheckoutBypassEnabled.d.ts +11 -0
  25. package/dist/types/components/utils/checkout/isHostedVsNativeTestAllowed.d.ts +11 -0
  26. package/dist/types/components/utils/checkout/itemCustomization.d.ts +23 -0
  27. package/dist/types/components/utils/checkout/parseItemCustomizations.d.ts +7 -0
  28. package/dist/types/types/checkout/CheckoutConfig.d.ts +14 -0
  29. package/dist/types/types/checkout/itemCustomization.d.ts +4 -0
  30. package/dist/types/types/index.d.ts +1 -0
  31. package/dist/zonos-elements/index.esm.js +1 -1
  32. package/dist/zonos-elements/p-30b3c9d3.entry.js +1 -0
  33. package/dist/zonos-elements/p-5873ab8e.entry.js +1 -0
  34. package/dist/zonos-elements/{p-5236c676.system.entry.js → p-7f031592.system.entry.js} +84 -59
  35. package/dist/zonos-elements/p-Bu9WCfUC.system.js +1 -1
  36. package/dist/zonos-elements/{p-DPZSD7Kg.system.js → p-CXxvn4GX.system.js} +4 -4
  37. package/dist/zonos-elements/{p-5016d71b.system.entry.js → p-d82fd8a9.system.entry.js} +68 -54
  38. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  39. package/item-customization.d.ts +25 -0
  40. package/item-customization.js +52 -0
  41. package/package.json +7 -4
  42. package/dist/zonos-elements/p-34656e6c.entry.js +0 -1
  43. package/dist/zonos-elements/p-f8b50aa0.entry.js +0 -1
@@ -28,7 +28,67 @@ import './debounce-CrmpwbEE.js';
28
28
  import './debounce-BR3PaG8X.js';
29
29
  import './ShortAddressCode-nJ6oI8-n.js';
30
30
 
31
- const zonosCartItemsCss = () => `:host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--cart-table{width:100%;border:none;border-collapse:collapse;overflow:auto;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column{padding:8px;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column:last-child{text-align:right}:host .zonos--cart-table .zonos--column:first-child{width:60px}:host .zonos--cart-table td{vertical-align:top}:host .zonos--cart-item-name{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:12px}:host .zonos--cart-item-name .zonos--cart-item-quantity>*{display:inline-block}:host .zonos--cart-item-price zonos-text{white-space:nowrap}:host img{min-width:40px;margin-top:6px}`;
31
+ /**
32
+ * Import-free so `scripts/buildItemCustomization.mjs` can emit one module.
33
+ * demo-app imports the generated `item-customization.js`, not this file.
34
+ */
35
+ const ITEM_CUSTOMIZATION_ATTRIBUTE_KEY = 'itemCustomization';
36
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
37
+ /** Drops an empty name, a non-string value, and the unselected value "0". */
38
+ const readDisplayableItemCustomization = (value) => {
39
+ if (!isRecord(value)) {
40
+ return null;
41
+ }
42
+ const { name } = value;
43
+ if (typeof name !== 'string' || name === '') {
44
+ return null;
45
+ }
46
+ const choiceValue = value.value;
47
+ if (typeof choiceValue !== 'string' || choiceValue === '0') {
48
+ return null;
49
+ }
50
+ return {
51
+ name,
52
+ value: choiceValue,
53
+ };
54
+ };
55
+ const parseJson = (value) => {
56
+ try {
57
+ // The generated package entry cannot import the shared jsonParse helper.
58
+ // eslint-disable-next-line no-restricted-syntax
59
+ return JSON.parse(value);
60
+ }
61
+ catch (_a) {
62
+ return null;
63
+ }
64
+ };
65
+ /** Selected customization entries, with the original object for extra ids. */
66
+ const readItemCustomizationEntries = (attributes) => {
67
+ var _a;
68
+ const rawValue = (_a = attributes === null || attributes === void 0 ? void 0 : attributes.find(attribute => (attribute === null || attribute === void 0 ? void 0 : attribute.key) === ITEM_CUSTOMIZATION_ATTRIBUTE_KEY)) === null || _a === void 0 ? void 0 : _a.value;
69
+ if (!rawValue) {
70
+ return [];
71
+ }
72
+ const parsed = parseJson(rawValue);
73
+ if (!Array.isArray(parsed)) {
74
+ return [];
75
+ }
76
+ return parsed.flatMap(entry => {
77
+ const choice = readDisplayableItemCustomization(entry);
78
+ if (!choice || !isRecord(entry)) {
79
+ return [];
80
+ }
81
+ return [{ choice, raw: entry }];
82
+ });
83
+ };
84
+
85
+ /**
86
+ * Reads a cart row's `itemCustomization` attribute into display pairs.
87
+ * Unreadable data is an empty list.
88
+ */
89
+ const parseItemCustomizations = (attributes) => readItemCustomizationEntries(attributes).map(entry => entry.choice);
90
+
91
+ const zonosCartItemsCss = () => `:host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--cart-table{width:100%;border:none;border-collapse:collapse;overflow:auto;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column{padding:8px;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column:last-child{text-align:right}:host .zonos--cart-table .zonos--column:first-child{width:60px}:host .zonos--cart-table td{vertical-align:top}:host .zonos--cart-item-name{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:12px}:host .zonos--cart-item-name .zonos--cart-item-choices{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:4px;min-width:0}:host .zonos--cart-item-name .zonos--cart-item-choices zonos-text{overflow-wrap:break-word;white-space:normal}:host .zonos--cart-item-name .zonos--cart-item-quantity>*{display:inline-block}:host .zonos--cart-item-price zonos-text{white-space:nowrap}:host img{min-width:40px;margin-top:6px}`;
32
92
 
33
93
  const ZonosCartItems = class {
34
94
  constructor(hostRef) {
@@ -38,15 +98,18 @@ const ZonosCartItems = class {
38
98
  render() {
39
99
  const emptyItemImg = getAssetPath('./assets/empty-item.jpeg');
40
100
  const nonRestrictedItems = cartStore.items.filter(item => !item.isRestricted);
41
- return (h(Host, { key: '2f81af1b6315853352a29bacaa230d782e76115a', class: "zonos--cart-items zonos--elements" }, h("table", { key: '7fe64f09729e0791605cdd8e66d7230ab162c7cf', class: "zonos--cart-table" }, h("tbody", { key: '49c17b5c7c68bfd41b2d8fabbbf4c3c764faba33' }, nonRestrictedItems.map(item => {
101
+ return (h(Host, { key: 'eeb10f76fbab43d256e6130fe2ab88a33c1598aa', class: "zonos--cart-items zonos--elements" }, h("table", { key: '61ae44a57c1386f5ca6afb17c388ae9fcf29d8a1', class: "zonos--cart-table" }, h("tbody", { key: '8471ae46186543cee754685e0182c4057d982967' }, nonRestrictedItems.map(item => {
42
102
  const itemImg = item.imageUrl;
43
103
  const cleanedItemNames = cleanHtmlMarkdown(item.name);
104
+ const choices = parseItemCustomizations(item.attributes);
44
105
  const amount = item.amount * item.quantity;
45
106
  return (h("tr", { class: "zonos--cart-item" }, h("td", { class: "zonos--column zonos--cart-item-image" }, itemImg && !this.errorImages.includes(itemImg) ? (h("img", { alt: item.name, onError: () => {
46
107
  this.errorImages = [...this.errorImages, itemImg];
47
108
  }, src: item.imageUrl, style: {
48
109
  'min-width': '40px',
49
- }, width: 40 })) : (h("img", { alt: item.name, src: emptyItemImg, width: 40 }))), h("td", { class: "zonos--column zonos--cart-item-name" }, h("div", null, cleanedItemNames.map(name => (h("zonos-text", { type: "label" }, name)))), h("zonos-text", { textColor: "gray-600", type: "caption" }, translate('Quantity'), ": ", item.quantity)), h("td", { class: "zonos--column zonos--cart-item-price" }, h("zonos-text", { type: "semiBoldLabel", weight: 600 }, renderCheckoutCurrency({
110
+ }, width: 40 })) : (h("img", { alt: item.name, src: emptyItemImg, width: 40 }))), h("td", { class: "zonos--column zonos--cart-item-name" }, h("div", null, cleanedItemNames.map(name => (h("zonos-text", { type: "label" }, name)))), choices.length > 0 && (h("div", { class: "zonos--cart-item-choices" }, choices.map(choice => (h("zonos-text", { textColor: "gray-600", type: "caption" }, choice.value === ''
111
+ ? choice.name
112
+ : `${choice.name}: ${choice.value}`))))), h("zonos-text", { textColor: "gray-600", type: "caption" }, translate('Quantity'), ": ", item.quantity)), h("td", { class: "zonos--column zonos--cart-item-price" }, h("zonos-text", { type: "semiBoldLabel", weight: 600 }, renderCheckoutCurrency({
50
113
  amount,
51
114
  isForeign: false,
52
115
  })))));
@@ -673,6 +673,20 @@ const isDisabledCountry = (showLog = true) => {
673
673
  return false;
674
674
  };
675
675
 
676
+ /**
677
+ * BigCommerce checkout depends on storefront callbacks (clear cart, inventory).
678
+ * The hosted variant leaves the storefront, so the test does not apply there.
679
+ */
680
+ const isHostedVsNativeTestAllowed = ({ createCartId, enabledTestKeys, isBigCommerce, }) => {
681
+ if (isBigCommerce) {
682
+ return false;
683
+ }
684
+ if (typeof createCartId !== 'function') {
685
+ return false;
686
+ }
687
+ return enabledTestKeys.includes('hosted_vs_native');
688
+ };
689
+
676
690
  const isShippableCountry = (showLog = true,
677
691
  /**
678
692
  * If provided, will check if the country is shippable based on the provided country code instead of the Hello selected country code
@@ -698,6 +712,76 @@ providedCountryCode) => {
698
712
  return true;
699
713
  };
700
714
 
715
+ const ZBYPASS_ON_VALUES = ['1', 'true', 'yes'];
716
+ /**
717
+ * Page-load result of reading the checkout `zBypass` query. Later calls on the
718
+ * same checkout URL reuse this so stripping the parameter does not change the
719
+ * answer.
720
+ */
721
+ let consumedZBypassQuery = null;
722
+ const isCheckoutPage = () => {
723
+ return window.location.pathname.includes('/checkout');
724
+ };
725
+ const isAcceptedZBypassQuery = (rawValue) => {
726
+ if (rawValue === null) {
727
+ return false;
728
+ }
729
+ return ZBYPASS_ON_VALUES.includes(rawValue.trim().toLowerCase());
730
+ };
731
+ /**
732
+ * True only when zonos-settings set
733
+ * `checkoutSettings.plugins.bigcommerce.allowBypassQuery` to `true`.
734
+ */
735
+ const isBypassQueryAllowed = () => {
736
+ var _a, _b;
737
+ return (((_b = (_a = zonosStore.checkoutSettings.plugins) === null || _a === void 0 ? void 0 : _a.bigcommerce) === null || _b === void 0 ? void 0 : _b.allowBypassQuery) === true);
738
+ };
739
+ /**
740
+ * Read an accepted `zBypass` query on the checkout page once, then remove it
741
+ * from the URL. A later call on that same URL returns the same answer.
742
+ */
743
+ const readCheckoutZBypassQuery = () => {
744
+ const { pathname, search } = window.location;
745
+ if (consumedZBypassQuery &&
746
+ consumedZBypassQuery.pathname === pathname &&
747
+ consumedZBypassQuery.search === search) {
748
+ return consumedZBypassQuery.enabled;
749
+ }
750
+ const params = new URLSearchParams(search);
751
+ const accepted = isAcceptedZBypassQuery(params.get('zBypass'));
752
+ if (!accepted) {
753
+ consumedZBypassQuery = { enabled: false, pathname, search };
754
+ return false;
755
+ }
756
+ params.delete('zBypass');
757
+ const nextSearch = params.toString();
758
+ const hash = window.location.hash || '';
759
+ const nextUrl = `${pathname}${nextSearch ? `?${nextSearch}` : ''}${hash}`;
760
+ window.history.replaceState(window.history.state, document.title, nextUrl);
761
+ const enabled = isBypassQueryAllowed();
762
+ consumedZBypassQuery = {
763
+ enabled,
764
+ pathname,
765
+ search: window.location.search,
766
+ };
767
+ return enabled;
768
+ };
769
+ /**
770
+ * True when this BigCommerce checkout page should skip address detection.
771
+ * That is only when zonos-settings allows the `zBypass` query and this
772
+ * checkout URL has an accepted value. Storefront pages are never bypassed, so
773
+ * the query stays in the URL until checkout. The query is removed once, and
774
+ * later calls on that checkout URL keep the same answer. Nothing is written
775
+ * to storage.
776
+ */
777
+ const isBigCommerceCheckoutBypassEnabled = () => {
778
+ var _a;
779
+ if (!((_a = window.Zonos) === null || _a === void 0 ? void 0 : _a.isBigCommerce) || !isCheckoutPage()) {
780
+ return false;
781
+ }
782
+ return readCheckoutZBypassQuery();
783
+ };
784
+
701
785
  const FALLBACK_SHIP_TO_COUNTRY_SELECTOR = 'select[name="shippingAddress.countryCode"]';
702
786
  /**
703
787
  * Native BigCommerce shipping-step "Continue" button. Clicking it commits the
@@ -798,6 +882,13 @@ const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedB
798
882
  if (!window.Zonos.isBigCommerce) {
799
883
  return;
800
884
  }
885
+ // Only the native checkout page skips address detection. Storefront pages
886
+ // still run the domestic-session handoff below, and they do not consume
887
+ // a `zBypass` query, so the parameter can survive until `/checkout`.
888
+ if (window.location.pathname.includes('/checkout') &&
889
+ isBigCommerceCheckoutBypassEnabled()) {
890
+ return;
891
+ }
801
892
  /**
802
893
  * Keep checking.
803
894
  * @returns `true` if the caller should stop polling — either because the user
@@ -1603,16 +1694,12 @@ const ZonosCheckout = class {
1603
1694
  };
1604
1695
  };
1605
1696
  this.shouldAllowHostedVsNativeTest = () => {
1606
- // This test is only applicable to checkout that's using createCartid callback
1607
- if (typeof zonosStore.checkoutSettings.createCartId !== 'function') {
1608
- return false;
1609
- }
1610
- const hostedVsNativeTest = zonosStore.enabledVariantTestKeys.includes('hosted_vs_native');
1611
- // Should not do anything if the test is not enabled
1612
- if (!hostedVsNativeTest) {
1613
- return false;
1614
- }
1615
- return true;
1697
+ var _a;
1698
+ return isHostedVsNativeTestAllowed({
1699
+ createCartId: zonosStore.checkoutSettings.createCartId,
1700
+ enabledTestKeys: zonosStore.enabledVariantTestKeys,
1701
+ isBigCommerce: Boolean((_a = window.Zonos) === null || _a === void 0 ? void 0 : _a.isBigCommerce),
1702
+ });
1616
1703
  };
1617
1704
  // Register test hosted vs native if needed to get the variant selection for this test
1618
1705
  this.registerTestHostedVsNative = async () => {
@@ -54,7 +54,7 @@ var n=new URL(e).searchParams;var o=n.get("zonosQaUrl");if(!o){return null}var t
54
54
  * When developing, if the script load is from `dev.elements.zonos.com`,
55
55
  * it would load script from that same domain instead of loading from cdn
56
56
  */
57
- 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.4.1.js.zonos.com";
57
+ 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.5.0.js.zonos.com";
58
58
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
59
59
  if(!n&&(o.includes("test.")||
60
60
  // Vercel git domain
@@ -99,15 +99,15 @@ return[4/*yield*/,new Promise((function(e){return setTimeout(e,500)}))];case 2:
99
99
  e.sent();return[2/*return*/,getCartInfoById({cartId:l,retries:d-1})];case 3:if(c){return[2/*return*/,null]}return[2/*return*/,Object.assign(Object.assign({},s),{zonosMode:u})]}}))}))};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/*return*/,null]}return[4/*yield*/,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/*return*/,null]}window.Zonos.storeId=r.cartData.storeId;window.Zonos.zonosApiKey=r.cartData.credentialToken;window.Zonos.zonosMode=r.zonosMode;return[2/*return*/,{cartData:r.cartData,settings:r.settings,storeFavicon:r.storeFaviconUrl,storeId:r.cartData.storeId,storeLogo:r.storeLogoUrl,zonosApiKey:r.cartData.credentialToken}]}}))}))};var _a;
100
100
  /**
101
101
  * Get the load version and url based on the loadScriptSrc, if the domain that used to load `zonos.js` is in white listed domains, use currentLoadScriptUrl as the load url instead, if zonosQaUrl exists, it would also fall under the white listed domain
102
- */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 startLoadTime=Date.now();var ZONOS_URL="https://v1.4.1.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.1";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.4.1";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.1";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=/** @class */function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.cartSettings=null;
102
+ */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 startLoadTime=Date.now();var ZONOS_URL="https://v1.5.0.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.5.0";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.5.0";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.5.0";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=/** @class */function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.cartSettings=null;
103
103
  // if query 'zonosDebug=1' param from url, debug mode is on
104
- 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.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Zonos.isBigCommerce=false;Zonos.releaseDate="1792428736539";Zonos.isLegacyCheckout=false;Zonos.googleAnalyticId=null;Zonos.googleAnalyticReady=false;Zonos.facebookPixelId=null;Zonos.facebookPixelReady=false;Zonos.startLoadTime=startLoadTime;Zonos.domain=typeof window!=="undefined"?// domain that embeds the iframe
104
+ 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.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Zonos.isBigCommerce=false;Zonos.releaseDate="1792773585238";Zonos.isLegacyCheckout=false;Zonos.googleAnalyticId=null;Zonos.googleAnalyticReady=false;Zonos.facebookPixelId=null;Zonos.facebookPixelReady=false;Zonos.startLoadTime=startLoadTime;Zonos.domain=typeof window!=="undefined"?// domain that embeds the iframe
105
105
  window.location!=window.parent.location&&document.referrer||
106
106
  // current domain
107
107
  document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.overrideUseCustomAddressForm=false;Zonos.isCollect=false;Zonos.isInvoice=false;
108
108
  /**
109
109
  * By default, the package will load from npm
110
- */Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.4.1");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.zonosMode=null;Zonos.IframeService=IframeService;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,u,c,l,d,f,v,m,_;return __generator(this,(function(p){switch(p.label){case 0:n=e.appearance,o=e.checkoutSettings,t=e.currencyConverter,r=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,u=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();
110
+ */Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.5.0");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.zonosMode=null;Zonos.IframeService=IframeService;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,u,c,l,d,f,v,m,_;return __generator(this,(function(p){switch(p.label){case 0:n=e.appearance,o=e.checkoutSettings,t=e.currencyConverter,r=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,u=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();
111
111
  // Expose the checkout cart callbacks on the global so Stripe loading can be
112
112
  // gated on whether at least one of them is configured.
113
113
  _a.createCartId=o===null||o===void 0?void 0:o.createCartId;
@@ -1,4 +1,17 @@
1
- var __awaiter=this&&this.__awaiter||function(o,t,e,s){function n(o){return o instanceof e?o:new e((function(t){t(o)}))}return new(e||(e=Promise))((function(e,r){function i(o){try{l(s.next(o))}catch(o){r(o)}}function a(o){try{l(s["throw"](o))}catch(o){r(o)}}function l(o){o.done?e(o.value):n(o.value).then(i,a)}l((s=s.apply(o,t||[])).next())}))};var __generator=this&&this.__generator||function(o,t){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},s,n,r,i=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return i.next=a(0),i["throw"]=a(1),i["return"]=a(2),typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(o){return function(t){return l([o,t])}}function l(a){if(s)throw new TypeError("Generator is already executing.");while(i&&(i=0,a[0]&&(e=0)),e)try{if(s=1,n&&(r=a[0]&2?n["return"]:a[0]?n["throw"]||((r=n["return"])&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;if(n=0,r)a=[a[0]&2,r.value];switch(a[0]){case 0:case 1:r=a;break;case 4:e.label++;return{value:a[1],done:false};case 5:e.label++;n=a[1];a=[0];continue;case 7:a=e.ops.pop();e.trys.pop();continue;default:if(!(r=e.trys,r=r.length>0&&r[r.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!r||a[1]>r[0]&&a[1]<r[3])){e.label=a[1];break}if(a[0]===6&&e.label<r[1]){e.label=r[1];r=a;break}if(r&&e.label<r[2]){e.label=r[2];e.ops.push(a);break}if(r[2])e.ops.pop();e.trys.pop();continue}a=t.call(o,e)}catch(o){a=[6,o];n=0}finally{s=r=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(o,t,e){if(e||arguments.length===2)for(var s=0,n=t.length,r;s<n;s++){if(r||!(s in t)){if(!r)r=Array.prototype.slice.call(t,0,s);r[s]=t[s]}}return o.concat(r||Array.prototype.slice.call(t))};import{r as registerInstance,e as getAssetPath,h,a as Host,F as Fragment,d as createEvent,g as getElement}from"./index-_lt63o7c.js";import{d as cartStore,L as cartStoreHasOneEligibleItem,M as isEuDapRemittance,m as cartStoreIsOrderModificationPaymentOnlySession,N as stripeStoreApplyPromoCode,O as stripeStoreRemovePromoCode,b as stripeStore,H as stripeStoreReset,c as stripeStoreRetrievePayment,t as trackConversionEvent,P as stripeStoreResetPromoCode,Q as stripeStoreMessageBasedOnStatus,R as storeCreditStore,S as storeCreditStoreReset,B as storeCreditStoreCoversFullAmount,y as isPolicyConsentRequired,G as policyConsentStore,T as stripeStoreRecordPolicyConsent,x as cartStoreNextStep,U as extractName,V as stripeStoreTranslateAddressToLatin,I as cartStoreOnChange,W as getCountryField,X as stripeStoreAsyncAddressUpdate,Y as cartStoreUpdateSelectedShippingOption,Z as cartStoreGetShippingTransitInfo,_ as cartStoreGetMethod,$ as sortServiceLevelOptionsByAmount}from"./cart-BoQp8Ema.js";import{t as translate,l as localizationStore,s as storageStore,k as languages,w as getExchangeRate,x as numberFormat,h as localizationStoreOnChange}from"./localization-BIh-4pc_.js";import{r as renderCheckoutCurrency}from"./renderCheckoutCurrency-C2Tw73uR.js";import{c as cleanHtmlMarkdown}from"./cleanHtmlMarkdown-ByGDytaN.js";import{c as classes}from"./classes-BJHSB96f.js";import{z as zonosStore,c as createStore,d as zonosStoreOnChange,g as getZonosStoreTheme,a as zonosStoreFontFamily}from"./zonosStore-msUlqmSD.js";import{D as DUTY_KEY,T as TAXES_KEY,h as hasInclusivePrice}from"./hasInclusivePrice-CbEfIhI5.js";import{i as isSameHostCheckoutLink}from"./isSameHostCheckoutLink-BxAHnL5J.js";import{s as submitAnalytics,c as paypalStoreReset,a as paypalStore}from"./paypal-DNfvnuUU.js";import{h as handleFetch,s as sendErrorLog,j as jsonParse,g as getIsTestMode,i as isCheckoutMobile,a as getIsStagingMode,l as logError}from"./handleFetch-D5GYDF-O.js";import{c as createCustomEvent}from"./createCustomEvent-XQfWgQLB.js";import{g as getBorderRadius}from"./getBorderRadius-DYfkeXdx.js";import{l as log,b as allLogs}from"./VarianceTest-BJmZPrZl.js";import{s as shouldShowLanguageSelect}from"./shouldShowLanguageSelect-CCD7gpSY.js";import{p as placeTestOrder}from"./placeTestOrder-CQaMKFOg.js";import{i as isDarkColor}from"./isDarkColor-YdrG78th.js";import{g as getContrastColor}from"./getContrastColor-CfCPlW9U.js";import{i as isColorVariable}from"./isColorVariable-DXXUq2Lv.js";import{u as updateCheckoutSessionAttributes}from"./updateCheckoutSessionAttributes-4Jq6V4pO.js";import{g as getMissingRequiredShippingFields}from"./getMissingRequiredShippingFields-Ks6_tpjn.js";import{c as containsNonLatinChars}from"./containsNonLatinChars-C04AWRC2.js";import{s as shouldRenderShortAddressCodeInput,a as shouldRenderTaxIdInput}from"./shouldRenderTaxIdInput-CKyZ6Zni.js";import{e as euCountryCodes}from"./TaxId-Cye-evFK.js";import"./isContrastColor-CWLU13s9.js";import"./submitGtag-df9AQ2zL.js";import"./debounce-CrmpwbEE.js";import"./debounce-BR3PaG8X.js";import"./ShortAddressCode-nJ6oI8-n.js";var zonosCartItemsCss=function(){return":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--cart-table{width:100%;border:none;border-collapse:collapse;overflow:auto;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column{padding:8px;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column:last-child{text-align:right}:host .zonos--cart-table .zonos--column:first-child{width:60px}:host .zonos--cart-table td{vertical-align:top}:host .zonos--cart-item-name{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:12px}:host .zonos--cart-item-name .zonos--cart-item-quantity>*{display:inline-block}:host .zonos--cart-item-price zonos-text{white-space:nowrap}:host img{min-width:40px;margin-top:6px}"};var ZonosCartItems=/** @class */function(){function o(o){registerInstance(this,o);this.errorImages=[]}o.prototype.render=function(){var o=this;var t=getAssetPath("./assets/empty-item.jpeg");var e=cartStore.items.filter((function(o){return!o.isRestricted}));return h(Host,{key:"2f81af1b6315853352a29bacaa230d782e76115a",class:"zonos--cart-items zonos--elements"},h("table",{key:"7fe64f09729e0791605cdd8e66d7230ab162c7cf",class:"zonos--cart-table"},h("tbody",{key:"49c17b5c7c68bfd41b2d8fabbbf4c3c764faba33"},e.map((function(e){var s=e.imageUrl;var n=cleanHtmlMarkdown(e.name);var r=e.amount*e.quantity;return h("tr",{class:"zonos--cart-item"},h("td",{class:"zonos--column zonos--cart-item-image"},s&&!o.errorImages.includes(s)?h("img",{alt:e.name,onError:function(){o.errorImages=__spreadArray(__spreadArray([],o.errorImages,true),[s],false)},src:e.imageUrl,style:{"min-width":"40px"},width:40}):h("img",{alt:e.name,src:t,width:40})),h("td",{class:"zonos--column zonos--cart-item-name"},h("div",null,n.map((function(o){return h("zonos-text",{type:"label"},o)}))),h("zonos-text",{textColor:"gray-600",type:"caption"},translate("Quantity"),": ",e.quantity)),h("td",{class:"zonos--column zonos--cart-item-price"},h("zonos-text",{type:"semiBoldLabel",weight:600},renderCheckoutCurrency({amount:r,isForeign:false}))))})))))};Object.defineProperty(o,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});return o}();ZonosCartItems.style=zonosCartItemsCss();var ChevronUpIcon$2='<svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#filter0_dd_2052_3658)">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M7.46967 14.5303C7.76256 14.8232 8.23744 14.8232 8.53033 14.5303L12.5 10.5607L16.4697 14.5303C16.7626 14.8232 17.2374 14.8232 17.5303 14.5303C17.8232 14.2374 17.8232 13.7626 17.5303 13.4697L13.0303 8.96967C12.7374 8.67678 12.2626 8.67678 11.9697 8.96967L7.46967 13.4697C7.17678 13.7626 7.17678 14.2374 7.46967 14.5303Z" fill="currentColor"/>\n</g>\n<defs>\n<filter id="filter0_dd_2052_3658" x="-3.5" y="-2" width="32" height="32" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">\n<feFlood flood-opacity="0" result="BackgroundImageFix"/>\n<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>\n<feOffset dy="2"/>\n<feGaussianBlur stdDeviation="2"/>\n<feComposite in2="hardAlpha" operator="out"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.06 0"/>\n<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_2052_3658"/>\n<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1"/>\n<feComposite in2="hardAlpha" operator="out"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.04 0"/>\n<feBlend mode="normal" in2="effect1_dropShadow_2052_3658" result="effect2_dropShadow_2052_3658"/>\n<feBlend mode="normal" in="SourceGraphic" in2="effect2_dropShadow_2052_3658" result="shape"/>\n</filter>\n</defs>\n</svg>\n';var zonosCartRestrictedItemsCss=function(){return':host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{overflow:auto;position:relative}:host zonos-banner{margin-bottom:12px}:host .zonos--cart-title-collapse-trigger{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;gap:24px;-ms-flex-align:center;align-items:center;background:var(--zonos-elements-gray-0);width:100%;border:none;cursor:pointer;margin-bottom:16px;position:-webkit-sticky;position:sticky;top:0;z-index:1;-webkit-transition:0.5s all ease;transition:0.5s all ease}:host .zonos--cart-title-collapse-trigger zonos-icon{-webkit-transition:-webkit-transform 0.3s ease;transition:-webkit-transform 0.3s ease;transition:transform 0.3s ease;transition:transform 0.3s ease, -webkit-transform 0.3s ease}:host .zonos--cart-title-collapse-trigger.collapsed{margin-bottom:0}:host .zonos--cart-title-collapse-trigger.collapsed zonos-icon{-webkit-transform:rotate(180deg);transform:rotate(180deg)}:host .zonos--cart-title-collapse-trigger::before,:host .zonos--cart-title-collapse-trigger::after{content:"";display:block;width:80%;height:1px;background-color:var(--zonos-elements-border-color);-ms-flex-negative:1;flex-shrink:1}:host .zonos--cart-title-collapse-trigger .zonos--title-wrapper{-ms-flex-positive:1;flex-grow:1;-ms-flex-negative:0;flex-shrink:0;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:row;flex-direction:row;gap:8px;-ms-flex-align:center;align-items:center}:host .zonos--cart-table{opacity:0.5;width:100%;border:none;border-collapse:collapse;overflow:auto;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column{padding:8px;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column:last-child{text-align:right}:host .zonos--cart-table .zonos--column:first-child{width:60px}:host img{min-width:40px}:host(.collapsed){-ms-flex-negative:0;flex-shrink:0}'};var ZonosCartRestrictedItems=/** @class */function(){function o(o){registerInstance(this,o);
1
+ var __awaiter=this&&this.__awaiter||function(o,t,e,s){function n(o){return o instanceof e?o:new e((function(t){t(o)}))}return new(e||(e=Promise))((function(e,r){function i(o){try{l(s.next(o))}catch(o){r(o)}}function a(o){try{l(s["throw"](o))}catch(o){r(o)}}function l(o){o.done?e(o.value):n(o.value).then(i,a)}l((s=s.apply(o,t||[])).next())}))};var __generator=this&&this.__generator||function(o,t){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},s,n,r,i=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return i.next=a(0),i["throw"]=a(1),i["return"]=a(2),typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(o){return function(t){return l([o,t])}}function l(a){if(s)throw new TypeError("Generator is already executing.");while(i&&(i=0,a[0]&&(e=0)),e)try{if(s=1,n&&(r=a[0]&2?n["return"]:a[0]?n["throw"]||((r=n["return"])&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;if(n=0,r)a=[a[0]&2,r.value];switch(a[0]){case 0:case 1:r=a;break;case 4:e.label++;return{value:a[1],done:false};case 5:e.label++;n=a[1];a=[0];continue;case 7:a=e.ops.pop();e.trys.pop();continue;default:if(!(r=e.trys,r=r.length>0&&r[r.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!r||a[1]>r[0]&&a[1]<r[3])){e.label=a[1];break}if(a[0]===6&&e.label<r[1]){e.label=r[1];r=a;break}if(r&&e.label<r[2]){e.label=r[2];e.ops.push(a);break}if(r[2])e.ops.pop();e.trys.pop();continue}a=t.call(o,e)}catch(o){a=[6,o];n=0}finally{s=r=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(o,t,e){if(e||arguments.length===2)for(var s=0,n=t.length,r;s<n;s++){if(r||!(s in t)){if(!r)r=Array.prototype.slice.call(t,0,s);r[s]=t[s]}}return o.concat(r||Array.prototype.slice.call(t))};import{r as registerInstance,e as getAssetPath,h,a as Host,F as Fragment,d as createEvent,g as getElement}from"./index-_lt63o7c.js";import{d as cartStore,L as cartStoreHasOneEligibleItem,M as isEuDapRemittance,m as cartStoreIsOrderModificationPaymentOnlySession,N as stripeStoreApplyPromoCode,O as stripeStoreRemovePromoCode,b as stripeStore,H as stripeStoreReset,c as stripeStoreRetrievePayment,t as trackConversionEvent,P as stripeStoreResetPromoCode,Q as stripeStoreMessageBasedOnStatus,R as storeCreditStore,S as storeCreditStoreReset,B as storeCreditStoreCoversFullAmount,y as isPolicyConsentRequired,G as policyConsentStore,T as stripeStoreRecordPolicyConsent,x as cartStoreNextStep,U as extractName,V as stripeStoreTranslateAddressToLatin,I as cartStoreOnChange,W as getCountryField,X as stripeStoreAsyncAddressUpdate,Y as cartStoreUpdateSelectedShippingOption,Z as cartStoreGetShippingTransitInfo,_ as cartStoreGetMethod,$ as sortServiceLevelOptionsByAmount}from"./cart-BoQp8Ema.js";import{t as translate,l as localizationStore,s as storageStore,k as languages,w as getExchangeRate,x as numberFormat,h as localizationStoreOnChange}from"./localization-BIh-4pc_.js";import{r as renderCheckoutCurrency}from"./renderCheckoutCurrency-C2Tw73uR.js";import{c as cleanHtmlMarkdown}from"./cleanHtmlMarkdown-ByGDytaN.js";import{c as classes}from"./classes-BJHSB96f.js";import{z as zonosStore,c as createStore,d as zonosStoreOnChange,g as getZonosStoreTheme,a as zonosStoreFontFamily}from"./zonosStore-msUlqmSD.js";import{D as DUTY_KEY,T as TAXES_KEY,h as hasInclusivePrice}from"./hasInclusivePrice-CbEfIhI5.js";import{i as isSameHostCheckoutLink}from"./isSameHostCheckoutLink-BxAHnL5J.js";import{s as submitAnalytics,c as paypalStoreReset,a as paypalStore}from"./paypal-DNfvnuUU.js";import{h as handleFetch,s as sendErrorLog,j as jsonParse,g as getIsTestMode,i as isCheckoutMobile,a as getIsStagingMode,l as logError}from"./handleFetch-D5GYDF-O.js";import{c as createCustomEvent}from"./createCustomEvent-XQfWgQLB.js";import{g as getBorderRadius}from"./getBorderRadius-DYfkeXdx.js";import{l as log,b as allLogs}from"./VarianceTest-BJmZPrZl.js";import{s as shouldShowLanguageSelect}from"./shouldShowLanguageSelect-CCD7gpSY.js";import{p as placeTestOrder}from"./placeTestOrder-CQaMKFOg.js";import{i as isDarkColor}from"./isDarkColor-YdrG78th.js";import{g as getContrastColor}from"./getContrastColor-CfCPlW9U.js";import{i as isColorVariable}from"./isColorVariable-DXXUq2Lv.js";import{u as updateCheckoutSessionAttributes}from"./updateCheckoutSessionAttributes-4Jq6V4pO.js";import{g as getMissingRequiredShippingFields}from"./getMissingRequiredShippingFields-Ks6_tpjn.js";import{c as containsNonLatinChars}from"./containsNonLatinChars-C04AWRC2.js";import{s as shouldRenderShortAddressCodeInput,a as shouldRenderTaxIdInput}from"./shouldRenderTaxIdInput-CKyZ6Zni.js";import{e as euCountryCodes}from"./TaxId-Cye-evFK.js";import"./isContrastColor-CWLU13s9.js";import"./submitGtag-df9AQ2zL.js";import"./debounce-CrmpwbEE.js";import"./debounce-BR3PaG8X.js";import"./ShortAddressCode-nJ6oI8-n.js";
2
+ /**
3
+ * Import-free so `scripts/buildItemCustomization.mjs` can emit one module.
4
+ * demo-app imports the generated `item-customization.js`, not this file.
5
+ */var ITEM_CUSTOMIZATION_ATTRIBUTE_KEY="itemCustomization";var isRecord=function(o){return typeof o==="object"&&o!==null&&!Array.isArray(o)};
6
+ /** Drops an empty name, a non-string value, and the unselected value "0". */var readDisplayableItemCustomization=function(o){if(!isRecord(o)){return null}var t=o.name;if(typeof t!=="string"||t===""){return null}var e=o.value;if(typeof e!=="string"||e==="0"){return null}return{name:t,value:e}};var parseJson=function(o){try{
7
+ // The generated package entry cannot import the shared jsonParse helper.
8
+ // eslint-disable-next-line no-restricted-syntax
9
+ return JSON.parse(o)}catch(o){return null}};
10
+ /** Selected customization entries, with the original object for extra ids. */var readItemCustomizationEntries=function(o){var t;var e=(t=o===null||o===void 0?void 0:o.find((function(o){return(o===null||o===void 0?void 0:o.key)===ITEM_CUSTOMIZATION_ATTRIBUTE_KEY})))===null||t===void 0?void 0:t.value;if(!e){return[]}var s=parseJson(e);if(!Array.isArray(s)){return[]}return s.flatMap((function(o){var t=readDisplayableItemCustomization(o);if(!t||!isRecord(o)){return[]}return[{choice:t,raw:o}]}))};
11
+ /**
12
+ * Reads a cart row's `itemCustomization` attribute into display pairs.
13
+ * Unreadable data is an empty list.
14
+ */var parseItemCustomizations=function(o){return readItemCustomizationEntries(o).map((function(o){return o.choice}))};var zonosCartItemsCss=function(){return":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--cart-table{width:100%;border:none;border-collapse:collapse;overflow:auto;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column{padding:8px;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column:last-child{text-align:right}:host .zonos--cart-table .zonos--column:first-child{width:60px}:host .zonos--cart-table td{vertical-align:top}:host .zonos--cart-item-name{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:12px}:host .zonos--cart-item-name .zonos--cart-item-choices{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:4px;min-width:0}:host .zonos--cart-item-name .zonos--cart-item-choices zonos-text{overflow-wrap:break-word;white-space:normal}:host .zonos--cart-item-name .zonos--cart-item-quantity>*{display:inline-block}:host .zonos--cart-item-price zonos-text{white-space:nowrap}:host img{min-width:40px;margin-top:6px}"};var ZonosCartItems=/** @class */function(){function o(o){registerInstance(this,o);this.errorImages=[]}o.prototype.render=function(){var o=this;var t=getAssetPath("./assets/empty-item.jpeg");var e=cartStore.items.filter((function(o){return!o.isRestricted}));return h(Host,{key:"eeb10f76fbab43d256e6130fe2ab88a33c1598aa",class:"zonos--cart-items zonos--elements"},h("table",{key:"61ae44a57c1386f5ca6afb17c388ae9fcf29d8a1",class:"zonos--cart-table"},h("tbody",{key:"8471ae46186543cee754685e0182c4057d982967"},e.map((function(e){var s=e.imageUrl;var n=cleanHtmlMarkdown(e.name);var r=parseItemCustomizations(e.attributes);var i=e.amount*e.quantity;return h("tr",{class:"zonos--cart-item"},h("td",{class:"zonos--column zonos--cart-item-image"},s&&!o.errorImages.includes(s)?h("img",{alt:e.name,onError:function(){o.errorImages=__spreadArray(__spreadArray([],o.errorImages,true),[s],false)},src:e.imageUrl,style:{"min-width":"40px"},width:40}):h("img",{alt:e.name,src:t,width:40})),h("td",{class:"zonos--column zonos--cart-item-name"},h("div",null,n.map((function(o){return h("zonos-text",{type:"label"},o)}))),r.length>0&&h("div",{class:"zonos--cart-item-choices"},r.map((function(o){return h("zonos-text",{textColor:"gray-600",type:"caption"},o.value===""?o.name:"".concat(o.name,": ").concat(o.value))}))),h("zonos-text",{textColor:"gray-600",type:"caption"},translate("Quantity"),": ",e.quantity)),h("td",{class:"zonos--column zonos--cart-item-price"},h("zonos-text",{type:"semiBoldLabel",weight:600},renderCheckoutCurrency({amount:i,isForeign:false}))))})))))};Object.defineProperty(o,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});return o}();ZonosCartItems.style=zonosCartItemsCss();var ChevronUpIcon$2='<svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#filter0_dd_2052_3658)">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M7.46967 14.5303C7.76256 14.8232 8.23744 14.8232 8.53033 14.5303L12.5 10.5607L16.4697 14.5303C16.7626 14.8232 17.2374 14.8232 17.5303 14.5303C17.8232 14.2374 17.8232 13.7626 17.5303 13.4697L13.0303 8.96967C12.7374 8.67678 12.2626 8.67678 11.9697 8.96967L7.46967 13.4697C7.17678 13.7626 7.17678 14.2374 7.46967 14.5303Z" fill="currentColor"/>\n</g>\n<defs>\n<filter id="filter0_dd_2052_3658" x="-3.5" y="-2" width="32" height="32" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">\n<feFlood flood-opacity="0" result="BackgroundImageFix"/>\n<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>\n<feOffset dy="2"/>\n<feGaussianBlur stdDeviation="2"/>\n<feComposite in2="hardAlpha" operator="out"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.06 0"/>\n<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_2052_3658"/>\n<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1"/>\n<feComposite in2="hardAlpha" operator="out"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.04 0"/>\n<feBlend mode="normal" in2="effect1_dropShadow_2052_3658" result="effect2_dropShadow_2052_3658"/>\n<feBlend mode="normal" in="SourceGraphic" in2="effect2_dropShadow_2052_3658" result="shape"/>\n</filter>\n</defs>\n</svg>\n';var zonosCartRestrictedItemsCss=function(){return':host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{overflow:auto;position:relative}:host zonos-banner{margin-bottom:12px}:host .zonos--cart-title-collapse-trigger{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;gap:24px;-ms-flex-align:center;align-items:center;background:var(--zonos-elements-gray-0);width:100%;border:none;cursor:pointer;margin-bottom:16px;position:-webkit-sticky;position:sticky;top:0;z-index:1;-webkit-transition:0.5s all ease;transition:0.5s all ease}:host .zonos--cart-title-collapse-trigger zonos-icon{-webkit-transition:-webkit-transform 0.3s ease;transition:-webkit-transform 0.3s ease;transition:transform 0.3s ease;transition:transform 0.3s ease, -webkit-transform 0.3s ease}:host .zonos--cart-title-collapse-trigger.collapsed{margin-bottom:0}:host .zonos--cart-title-collapse-trigger.collapsed zonos-icon{-webkit-transform:rotate(180deg);transform:rotate(180deg)}:host .zonos--cart-title-collapse-trigger::before,:host .zonos--cart-title-collapse-trigger::after{content:"";display:block;width:80%;height:1px;background-color:var(--zonos-elements-border-color);-ms-flex-negative:1;flex-shrink:1}:host .zonos--cart-title-collapse-trigger .zonos--title-wrapper{-ms-flex-positive:1;flex-grow:1;-ms-flex-negative:0;flex-shrink:0;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:row;flex-direction:row;gap:8px;-ms-flex-align:center;align-items:center}:host .zonos--cart-table{opacity:0.5;width:100%;border:none;border-collapse:collapse;overflow:auto;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column{padding:8px;font-size:var(--zonos-elements-font-size-base)}:host .zonos--cart-table .zonos--column:last-child{text-align:right}:host .zonos--cart-table .zonos--column:first-child{width:60px}:host img{min-width:40px}:host(.collapsed){-ms-flex-negative:0;flex-shrink:0}'};var ZonosCartRestrictedItems=/** @class */function(){function o(o){registerInstance(this,o);
2
15
  /**
3
16
  * This is to hide the section when the parent collapse on mobile
4
17
  */this.hide=false;this.errorImages=[];this.internalCollapsed=true;
@@ -74,7 +87,7 @@ var c=i.subtotals.exchangeRate.rate;var u=function(o){return o.reduce((function(
74
87
  // subtotals (already in presentment currency) — this is what the shopper
75
88
  // actually pays. Duties are not collected (paid on delivery), so they come
76
89
  // from the landed cost estimate converted to presentment.
77
- var h=(s=cartStore.checkoutSession)===null||s===void 0?void 0:s.subtotals;return{dutiesEstimate:u(a.duties)*c,taxesAndFeesEstimate:((n=h===null||h===void 0?void 0:h.taxes)!==null&&n!==void 0?n:0)+((r=h===null||h===void 0?void 0:h.fees)!==null&&r!==void 0?r:0)}}}o.prototype.render=function(){var o=this;var t,e,s,n,r;
90
+ var d=(s=cartStore.checkoutSession)===null||s===void 0?void 0:s.subtotals;return{dutiesEstimate:u(a.duties)*c,taxesAndFeesEstimate:((n=d===null||d===void 0?void 0:d.taxes)!==null&&n!==void 0?n:0)+((r=d===null||d===void 0?void 0:d.fees)!==null&&r!==void 0?r:0)}}}o.prototype.render=function(){var o=this;var t,e,s,n,r;
78
91
  // Since now we are prefetching the landed cost, we need to not show the total that includes the landed cost and shipping
79
92
  var i=cartStore.step==="customer-info"?cartStore.subtotal+cartStore.adjustmentTotal:cartStore.total;
80
93
  // Order-modification payment-only sessions have no landedCost at all
@@ -140,9 +153,9 @@ l.sent();return[2/*return*/,{baseUrl:r,order:a}]}}))}))};
140
153
  /**
141
154
  * The value of this parameter should be the sum of all item amounts in the transaction (without shipping and tax).
142
155
  * @ref https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag#parameters_22
143
- */var h=((n=cartStore.checkoutSession)===null||n===void 0?void 0:n.subtotals.items)||((r=t.order)===null||r===void 0?void 0:r.amountSubtotals.items);var d=((i=cartStore.checkoutSession)===null||i===void 0?void 0:i.subtotals.presentmentCurrencyCode)||((a=t.order)===null||a===void 0?void 0:a.currencyCode)||(s===null||s===void 0?void 0:s.toUpperCase());
156
+ */var d=((n=cartStore.checkoutSession)===null||n===void 0?void 0:n.subtotals.items)||((r=t.order)===null||r===void 0?void 0:r.amountSubtotals.items);var h=((i=cartStore.checkoutSession)===null||i===void 0?void 0:i.subtotals.presentmentCurrencyCode)||((a=t.order)===null||a===void 0?void 0:a.currencyCode)||(s===null||s===void 0?void 0:s.toUpperCase());
144
157
  // Cart subtotal amount, can be different on the final checkout session/payment intent, therefore only use it if the order/checkout session can not be found.
145
- var p=u.reduce((function(o,t){return o+t.price*t.quantity}),0);var f=(l=cartStore.items.find(Boolean))===null||l===void 0?void 0:l.currencyCode;var m=((c=t.order)===null||c===void 0?void 0:c.id)||e||(new Date).getTime().toString();if(d&&h){return{currency:d,items:u,transaction_id:m,value:h}}
158
+ var p=u.reduce((function(o,t){return o+t.price*t.quantity}),0);var f=(l=cartStore.items.find(Boolean))===null||l===void 0?void 0:l.currencyCode;var m=((c=t.order)===null||c===void 0?void 0:c.id)||e||(new Date).getTime().toString();if(h&&d){return{currency:h,items:u,transaction_id:m,value:d}}
146
159
  // Use cart currency and subtotal if the order/checkout session can not be found
147
160
  if(f&&p){return{currency:f,items:u,transaction_id:m,value:p}}return{currency:undefined,items:u,transaction_id:m,value:undefined}};this.redirectToUrl=function(o){
148
161
  // reset store and checkout session id before redirecting
@@ -154,8 +167,8 @@ if(window.parent){window.parent.location.href=o}window.location.href=o};this.isR
154
167
  */this.shouldRenderKeepShoppingButton=function(){return!t.isRedirectBehavior()&&t.notificationType==="success"};
155
168
  /**
156
169
  * Should render close button for redirect behavior when the success behavior is redirecting to a different page or when it's an error screen
157
- */this.shouldRenderCloseButtonForRedirectBehavior=function(){return t.isRedirectBehavior()||t.notificationType==="error"};this.redirectToMerchantSuccessPage=function(){var o,e,s,n;var r=cartStore.externalConfirmationPageURL||zonosStore.checkoutSettings.successRedirectUrl;var i=r;var a=new URLSearchParams;var l=(o=t.order)===null||o===void 0?void 0:o.id;var c=((n=(s=(e=t.order)===null||e===void 0?void 0:e.references)===null||s===void 0?void 0:s.find((function(o){return(o===null||o===void 0?void 0:o.key)==="zonosOrderNumber"})))===null||n===void 0?void 0:n.value)||null;if(l){a.set("zOrderNumber",l)}if(c){a.set("orderId",c)}var u=a.toString();var h=i.includes("?");t.isWaitingToRedirect=true;t.redirectToUrl(u?// Some url already has query string, so we need to append the query string with '&' instead of '?'
158
- "".concat(i).concat(h?"&":"?").concat(u):i)};
170
+ */this.shouldRenderCloseButtonForRedirectBehavior=function(){return t.isRedirectBehavior()||t.notificationType==="error"};this.redirectToMerchantSuccessPage=function(){var o,e,s,n;var r=cartStore.externalConfirmationPageURL||zonosStore.checkoutSettings.successRedirectUrl;var i=r;var a=new URLSearchParams;var l=(o=t.order)===null||o===void 0?void 0:o.id;var c=((n=(s=(e=t.order)===null||e===void 0?void 0:e.references)===null||s===void 0?void 0:s.find((function(o){return(o===null||o===void 0?void 0:o.key)==="zonosOrderNumber"})))===null||n===void 0?void 0:n.value)||null;if(l){a.set("zOrderNumber",l)}if(c){a.set("orderId",c)}var u=a.toString();var d=i.includes("?");t.isWaitingToRedirect=true;t.redirectToUrl(u?// Some url already has query string, so we need to append the query string with '&' instead of '?'
171
+ "".concat(i).concat(d?"&":"?").concat(u):i)};
159
172
  /**
160
173
  * Immediately redirect to the merchant's successRedirectUrl with the
161
174
  * zonosCheckoutSessionId query param, without polling for the order. Used
@@ -441,7 +454,7 @@ if(!e.length){return null}return h(Host,{class:"zonos--currency-toggle zonos--el
441
454
  */var applyAddressCompletion=function(o){var t=o.data,e=o.event;var s,n,r,i;
442
455
  // Use the same name extraction as the detection step so the two stay in agreement even when
443
456
  // the surname is only available via the combined `name` field.
444
- var a=extractName({firstName:e.value.firstName,lastName:e.value.lastName,name:e.value.name}),l=a.firstName,c=a.lastName;var u=(s=t.firstName)!==null&&s!==void 0?s:l;var h=(n=t.lastName)!==null&&n!==void 0?n:c;return Object.assign(Object.assign({},e),{complete:true,value:Object.assign(Object.assign({},e.value),{address:Object.assign(Object.assign({},e.value.address),{postal_code:(r=t.postal_code)!==null&&r!==void 0?r:e.value.address.postal_code,state:(i=t.state)!==null&&i!==void 0?i:e.value.address.state}),firstName:u,lastName:h,name:"".concat(u," ").concat(h).trim()})})};var shortAddressCodeValidationResult=function(o){var t=o.shippingCountry,e=o.shortAddressCode;
457
+ var a=extractName({firstName:e.value.firstName,lastName:e.value.lastName,name:e.value.name}),l=a.firstName,c=a.lastName;var u=(s=t.firstName)!==null&&s!==void 0?s:l;var d=(n=t.lastName)!==null&&n!==void 0?n:c;return Object.assign(Object.assign({},e),{complete:true,value:Object.assign(Object.assign({},e.value),{address:Object.assign(Object.assign({},e.value.address),{postal_code:(r=t.postal_code)!==null&&r!==void 0?r:e.value.address.postal_code,state:(i=t.state)!==null&&i!==void 0?i:e.value.address.state}),firstName:u,lastName:d,name:"".concat(u," ").concat(d).trim()})})};var shortAddressCodeValidationResult=function(o){var t=o.shippingCountry,e=o.shortAddressCode;
445
458
  // Check to see if we are required to collect short address code for the shipping country or not
446
459
  var s=shouldRenderShortAddressCodeInput({countryCode:t});
447
460
  // If the short address code input is not even rendered, no need to validate anything and allow to proceed. Validate when short address code input is not even rendered would prevent the user from checking out
@@ -560,7 +573,7 @@ var u=false;if(s||n||r||i||a||l||c){u=true}
560
573
  if(t){stripeStore.customAddressErrors=Object.assign(Object.assign({},e),{showError:u})}else{stripeStore.customBillingAddressErrors=Object.assign(Object.assign({},e),{showError:u})}return{isValid:!u}};
561
574
  /**
562
575
  * Make sure all fields in the address are within the character limit
563
- */this.validateAddressLength=function(o){var t=o.address,e=o.type;if(!t){return[]}var s=t.value.address,n=s.city,r=s.line1,i=s.postal_code,a=s.state;var l=t.value,c=l.firstName,u=l.lastName,h=l.name;var d=extractName({firstName:c,lastName:u,name:h}),p=d.firstName,f=d.lastName;var m=n.length;var v=r.length;var g=i.length;var z=a.length;var b=p.length;var y=f.length;var C=e==="shipping"?"shipping":"billing";var x=[];if(m>MAX_CHARACTER_LENGTH_PER_FIELD){x.push({addressType:C,fieldLabel:"City",value:n})}if(v>MAX_CHARACTER_LENGTH_PER_FIELD){x.push({addressType:C,fieldLabel:"Address line 1",value:r})}if(g>MAX_CHARACTER_LENGTH_PER_FIELD){x.push({addressType:C,fieldLabel:"Zip",value:i})}if(z>MAX_CHARACTER_LENGTH_PER_FIELD){x.push({addressType:C,fieldLabel:"State/Province/Region/Prefecture",value:a})}if(b>MAX_CHARACTER_LENGTH_PER_FIELD){x.push({addressType:C,fieldLabel:"First name",value:p})}if(y>MAX_CHARACTER_LENGTH_PER_FIELD){x.push({addressType:C,fieldLabel:"Last name",value:f})}return x};this.handleValidate=function(){var o,e;var s=stripeStore.stripeAddressEventData;var n=stripeStore.stripeBillingAddressEventData;var r=stripeStore.stripeLinkEventData;
576
+ */this.validateAddressLength=function(o){var t=o.address,e=o.type;if(!t){return[]}var s=t.value.address,n=s.city,r=s.line1,i=s.postal_code,a=s.state;var l=t.value,c=l.firstName,u=l.lastName,d=l.name;var h=extractName({firstName:c,lastName:u,name:d}),p=h.firstName,f=h.lastName;var m=n.length;var v=r.length;var g=i.length;var z=a.length;var b=p.length;var y=f.length;var C=e==="shipping"?"shipping":"billing";var x=[];if(m>MAX_CHARACTER_LENGTH_PER_FIELD){x.push({addressType:C,fieldLabel:"City",value:n})}if(v>MAX_CHARACTER_LENGTH_PER_FIELD){x.push({addressType:C,fieldLabel:"Address line 1",value:r})}if(g>MAX_CHARACTER_LENGTH_PER_FIELD){x.push({addressType:C,fieldLabel:"Zip",value:i})}if(z>MAX_CHARACTER_LENGTH_PER_FIELD){x.push({addressType:C,fieldLabel:"State/Province/Region/Prefecture",value:a})}if(b>MAX_CHARACTER_LENGTH_PER_FIELD){x.push({addressType:C,fieldLabel:"First name",value:p})}if(y>MAX_CHARACTER_LENGTH_PER_FIELD){x.push({addressType:C,fieldLabel:"Last name",value:f})}return x};this.handleValidate=function(){var o,e;var s=stripeStore.stripeAddressEventData;var n=stripeStore.stripeBillingAddressEventData;var r=stripeStore.stripeLinkEventData;
564
577
  // if the shipping is different from billing, we need to make sure the billing address is valid and disable the button if it's not
565
578
  var i=stripeStore.stripeShippingSameAsBilling?!!(s===null||s===void 0?void 0:s.complete):!!(n===null||n===void 0?void 0:n.complete);var a=!!(s===null||s===void 0?void 0:s.complete);var l=!!(r===null||r===void 0?void 0:r.complete);
566
579
  // display errors on fields that are invalid
@@ -570,7 +583,7 @@ var c=t.addressFormRenderType==="zonos"?t.validateCustomAddressForm("billing").i
570
583
  // if the custom address form is enabled, use the custom address form validation result, otherwise use the stripe validation result
571
584
  var u=t.addressFormRenderType==="zonos"?t.validateCustomAddressForm("shipping").isValid:a;if(!l&&(r===null||r===void 0?void 0:r.empty)){t.isEmailError=true}log("==> isValidBilling","info",c,{address:stripeStore.stripeBillingAddressEventData,errors:stripeStore.customBillingAddressErrors});log("==> isValidShipping","info",u,{address:stripeStore.stripeAddressEventData,errors:stripeStore.customAddressErrors});log("==> isValidLink","info",l);
572
585
  // validate tax id input if it's required for specific countries, optional otherwise
573
- var h=taxIdValidationResult({companyName:stripeStore.companyName,shippingCountry:t.shippingCountry,taxId:stripeStore.taxId}),d=h.error,p=h.valid;var f=shortAddressCodeValidationResult({shippingCountry:t.shippingCountry,shortAddressCode:stripeStore.shortAddressCode}),m=f.error,v=f.valid;t.taxIdErrorMessage=!p?translate(d):"";t.shortAddressCodeErrorMessage=!v?translate(m):"";var g=t.validateAddressLength({address:stripeStore.stripeAddressEventData,type:"shipping"});var z=t.validateAddressLength({address:stripeStore.stripeBillingAddressEventData,type:"billing"});t.exceededCharacterLimitErrorFieldList=__spreadArray(__spreadArray([],g,true),z,true);if(!c||!u||!l||!p||!v||t.exceededCharacterLimitErrorFieldList.length>0){return false}return true};this.handleEmailValidation=function(){var o;if(!t.isEmailError){return}if(!((o=stripeStore.stripeLinkEventData)===null||o===void 0?void 0:o.empty)){t.isEmailError=false}};this.prepareAddressObject=function(o){var t;var e=o.value;return{city:e.address.city||"",country:e.address.country,email:((t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.value.email)||"",line1:e.address.line1||"",line2:e.address.line2||"",name:e.name||"",phone:e.phone||"",postal_code:e.address.postal_code||"",state:e.address.state||""}};this.renderExceededCharacterLimitError=function(o){var e=t.exceededCharacterLimitErrorFieldList.filter((function(t){var e=t.addressType;return e===o}));if(!e.length){return null}return h("zonos-banner",{class:"zonos--error-banner",intent:"error",slot:"below-title"},h("ul",null,e.map((function(o){var t=o.fieldLabel,e=o.value;var s=t==="Address line 1";if(s){return h("li",{key:t},translate("[fieldLabel] is [currentLength] characters. Please shorten to [maxLength] or less or move the rest to address line 2.",{currentLength:e.length,fieldLabel:t,maxLength:MAX_CHARACTER_LENGTH_PER_FIELD}))}return h("li",{key:t},translate("[fieldLabel] is [currentLength] characters. Please shorten to [maxLength] or less.",{currentLength:e.length,fieldLabel:t,maxLength:MAX_CHARACTER_LENGTH_PER_FIELD}))}))))};this.renderAddressComponent=function(o){if(!t.selectedCountryCode){void sendErrorLog({endpoint:"NO_COUNTRY_SELECTED_WHEN_RENDERING_ADDRESS_COMPONENT",errors:["No country selected when rendering address component"],metadata:{type:o},shouldPostReleaseErrorReporting:true})}
586
+ var d=taxIdValidationResult({companyName:stripeStore.companyName,shippingCountry:t.shippingCountry,taxId:stripeStore.taxId}),h=d.error,p=d.valid;var f=shortAddressCodeValidationResult({shippingCountry:t.shippingCountry,shortAddressCode:stripeStore.shortAddressCode}),m=f.error,v=f.valid;t.taxIdErrorMessage=!p?translate(h):"";t.shortAddressCodeErrorMessage=!v?translate(m):"";var g=t.validateAddressLength({address:stripeStore.stripeAddressEventData,type:"shipping"});var z=t.validateAddressLength({address:stripeStore.stripeBillingAddressEventData,type:"billing"});t.exceededCharacterLimitErrorFieldList=__spreadArray(__spreadArray([],g,true),z,true);if(!c||!u||!l||!p||!v||t.exceededCharacterLimitErrorFieldList.length>0){return false}return true};this.handleEmailValidation=function(){var o;if(!t.isEmailError){return}if(!((o=stripeStore.stripeLinkEventData)===null||o===void 0?void 0:o.empty)){t.isEmailError=false}};this.prepareAddressObject=function(o){var t;var e=o.value;return{city:e.address.city||"",country:e.address.country,email:((t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.value.email)||"",line1:e.address.line1||"",line2:e.address.line2||"",name:e.name||"",phone:e.phone||"",postal_code:e.address.postal_code||"",state:e.address.state||""}};this.renderExceededCharacterLimitError=function(o){var e=t.exceededCharacterLimitErrorFieldList.filter((function(t){var e=t.addressType;return e===o}));if(!e.length){return null}return h("zonos-banner",{class:"zonos--error-banner",intent:"error",slot:"below-title"},h("ul",null,e.map((function(o){var t=o.fieldLabel,e=o.value;var s=t==="Address line 1";if(s){return h("li",{key:t},translate("[fieldLabel] is [currentLength] characters. Please shorten to [maxLength] or less or move the rest to address line 2.",{currentLength:e.length,fieldLabel:t,maxLength:MAX_CHARACTER_LENGTH_PER_FIELD}))}return h("li",{key:t},translate("[fieldLabel] is [currentLength] characters. Please shorten to [maxLength] or less.",{currentLength:e.length,fieldLabel:t,maxLength:MAX_CHARACTER_LENGTH_PER_FIELD}))}))))};this.renderAddressComponent=function(o){if(!t.selectedCountryCode){void sendErrorLog({endpoint:"NO_COUNTRY_SELECTED_WHEN_RENDERING_ADDRESS_COMPONENT",errors:["No country selected when rendering address component"],metadata:{type:o},shouldPostReleaseErrorReporting:true})}
574
587
  // Only use the default address for shipping address
575
588
  var e=o==="shipping"?t.defaultAddress:[];
576
589
  // Should only record the form type used once
@@ -582,7 +595,7 @@ return h("zonos-address",{defaultAddress:e,shortAddressCodeErrorMessage:t.shortA
582
595
  // start validate on typing after error banner is shown, and hide it if the form is complete
583
596
  if(this.showErrorBanner){this.showErrorBanner=!this.handleValidate()}};o.prototype.checkInvalidCharacters=function(o){if(!o){return null}
584
597
  // Do nothing if the allowed character sets is ALL or the address is incomplete
585
- if(!o.complete||zonosStore.checkoutSettings.allowedCharacterSets==="ALL"){return null}var t=o.value,e=t.address,s=t.firstName,n=t.lastName,r=t.name;var i=e.city,a=e.country,l=e.line1,c=e.line2,u=e.postal_code,h=e.state;var d=containsNonLatinChars({city:i,country:a,line1:l,line2:c||"",name:r||"".concat(s," ").concat(n),postal_code:u,state:h});if(!Object.keys(d).length){return null}return d};o.prototype.watchShouldEnabledCustomAddress=function(){var o,t,e;var s=this.shouldUseCustomAddressFormOverride||!!((o=this.genericSettings)===null||o===void 0?void 0:o.shouldEnabledCustomAddress);var n=!!this.selectedCountryCode&&s&&!!((e=(t=this.genericSettings)===null||t===void 0?void 0:t.countryCustomAddressEnabled)===null||e===void 0?void 0:e.includes(this.selectedCountryCode));
598
+ if(!o.complete||zonosStore.checkoutSettings.allowedCharacterSets==="ALL"){return null}var t=o.value,e=t.address,s=t.firstName,n=t.lastName,r=t.name;var i=e.city,a=e.country,l=e.line1,c=e.line2,u=e.postal_code,d=e.state;var h=containsNonLatinChars({city:i,country:a,line1:l,line2:c||"",name:r||"".concat(s," ").concat(n),postal_code:u,state:d});if(!Object.keys(h).length){return null}return h};o.prototype.watchShouldEnabledCustomAddress=function(){var o,t,e;var s=this.shouldUseCustomAddressFormOverride||!!((o=this.genericSettings)===null||o===void 0?void 0:o.shouldEnabledCustomAddress);var n=!!this.selectedCountryCode&&s&&!!((e=(t=this.genericSettings)===null||t===void 0?void 0:t.countryCustomAddressEnabled)===null||e===void 0?void 0:e.includes(this.selectedCountryCode));
586
599
  // Update the address form render type in the cart store
587
600
  cartStore.addressFormRenderType=n?"zonos":"stripe"};o.prototype.disconnectedCallback=function(){
588
601
  // unsubscribe from store subscriptions