@zonos/elements 1.4.0 → 1.4.1

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.
@@ -131,7 +131,7 @@ const getZonosQaUrl = () => {
131
131
  return null;
132
132
  }
133
133
  const qaUrl = extractZonosQaUrl(window.location.href);
134
- const cdnUrl = "https://v1.4.0.js.zonos.com";
134
+ const cdnUrl = "https://v1.4.1.js.zonos.com";
135
135
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
136
136
  if (!qaUrl &&
137
137
  (cdnUrl.includes('test.') ||
@@ -155,6 +155,10 @@ const getZonosQaUrl = () => {
155
155
  if (qaUrl === 'dev-elements') {
156
156
  return 'https://dev.elements.zonos.com';
157
157
  }
158
+ // The worker alias selects the API host only. Scripts stay on the normal CDN.
159
+ if (qaUrl === 'worker') {
160
+ return null;
161
+ }
158
162
  const suffixDomain = 'preview.js.zonos.com';
159
163
  const fullUrl = `https://${qaUrl}.${suffixDomain}`;
160
164
  VarianceTest.log(`[ZONOS-WARNING] using '${fullUrl}' for loading elements script`, 'warn');
@@ -416,10 +420,10 @@ const zonosLoadUrl = (() => {
416
420
  return null;
417
421
  })();
418
422
  const startLoadTime = Date.now();
419
- const ZONOS_URL = "https://v1.4.0.js.zonos.com";
420
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.0";
421
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.4.0";
422
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.0";
423
+ const ZONOS_URL = "https://v1.4.1.js.zonos.com";
424
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.1";
425
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.4.1";
426
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.1";
423
427
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
424
428
  const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
425
429
  class Zonos {
@@ -437,7 +441,7 @@ Zonos.iframeLogType = typeof window !== 'undefined'
437
441
  ? new URLSearchParams(window.location.search).get('iframeLogType')
438
442
  : null;
439
443
  Zonos.isBigCommerce = false;
440
- Zonos.releaseDate = "1792186375498";
444
+ Zonos.releaseDate = "1792428736539";
441
445
  Zonos.isLegacyCheckout = false;
442
446
  Zonos.googleAnalyticId = null;
443
447
  Zonos.googleAnalyticReady = false;
@@ -462,7 +466,7 @@ Zonos.isNpm = true;
462
466
  Zonos.zonosQaUrl = null;
463
467
  Zonos.zonosQaUrlApi = null;
464
468
  Zonos.trackEventLogs = [];
465
- Zonos.version = `v${"1.4.0"}`;
469
+ Zonos.version = `v${"1.4.1"}`;
466
470
  Zonos.modeAlerted = false;
467
471
  Zonos.cartData = null;
468
472
  Zonos.paypal = null;
@@ -38,6 +38,10 @@ export const getZonosQaUrl = () => {
38
38
  if (qaUrl === 'dev-elements') {
39
39
  return 'https://dev.elements.zonos.com';
40
40
  }
41
+ // The worker alias selects the API host only. Scripts stay on the normal CDN.
42
+ if (qaUrl === 'worker') {
43
+ return null;
44
+ }
41
45
  const suffixDomain = 'preview.js.zonos.com';
42
46
  const fullUrl = `https://${qaUrl}.${suffixDomain}`;
43
47
  log(`[ZONOS-WARNING] using '${fullUrl}' for loading elements script`, 'warn');
@@ -80,10 +84,13 @@ export const getZonosQaUrlApi = () => {
80
84
  if (!qaUrl) {
81
85
  return null;
82
86
  }
83
- // If the qaUrl, use the dev-elements domain to forward the request to the dev server to quickly debug the issue
87
+ // Local API debugging. The worker host is a separate explicit alias.
84
88
  if (qaUrl === 'dev-elements') {
85
89
  return 'https://dev.demo.elements.zonos.com';
86
90
  }
91
+ if (qaUrl === 'worker') {
92
+ return 'https://worker.iglobalstores.com';
93
+ }
87
94
  // Only do this if `zonosQaUrlApi` is set, don't use zonosQaUrl
88
95
  if (!_qaUrlApi) {
89
96
  return null;
package/dist/esm/index.js CHANGED
@@ -131,7 +131,7 @@ const getZonosQaUrl = () => {
131
131
  return null;
132
132
  }
133
133
  const qaUrl = extractZonosQaUrl(window.location.href);
134
- const cdnUrl = "https://v1.4.0.js.zonos.com";
134
+ const cdnUrl = "https://v1.4.1.js.zonos.com";
135
135
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
136
136
  if (!qaUrl &&
137
137
  (cdnUrl.includes('test.') ||
@@ -155,6 +155,10 @@ const getZonosQaUrl = () => {
155
155
  if (qaUrl === 'dev-elements') {
156
156
  return 'https://dev.elements.zonos.com';
157
157
  }
158
+ // The worker alias selects the API host only. Scripts stay on the normal CDN.
159
+ if (qaUrl === 'worker') {
160
+ return null;
161
+ }
158
162
  const suffixDomain = 'preview.js.zonos.com';
159
163
  const fullUrl = `https://${qaUrl}.${suffixDomain}`;
160
164
  log(`[ZONOS-WARNING] using '${fullUrl}' for loading elements script`, 'warn');
@@ -416,10 +420,10 @@ const zonosLoadUrl = (() => {
416
420
  return null;
417
421
  })();
418
422
  const startLoadTime = Date.now();
419
- const ZONOS_URL = "https://v1.4.0.js.zonos.com";
420
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.0";
421
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.4.0";
422
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.0";
423
+ const ZONOS_URL = "https://v1.4.1.js.zonos.com";
424
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.1";
425
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.4.1";
426
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.1";
423
427
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
424
428
  const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
425
429
  class Zonos {
@@ -437,7 +441,7 @@ Zonos.iframeLogType = typeof window !== 'undefined'
437
441
  ? new URLSearchParams(window.location.search).get('iframeLogType')
438
442
  : null;
439
443
  Zonos.isBigCommerce = false;
440
- Zonos.releaseDate = "1792186375498";
444
+ Zonos.releaseDate = "1792428736539";
441
445
  Zonos.isLegacyCheckout = false;
442
446
  Zonos.googleAnalyticId = null;
443
447
  Zonos.googleAnalyticReady = false;
@@ -462,7 +466,7 @@ Zonos.isNpm = true;
462
466
  Zonos.zonosQaUrl = null;
463
467
  Zonos.zonosQaUrlApi = null;
464
468
  Zonos.trackEventLogs = [];
465
- Zonos.version = `v${"1.4.0"}`;
469
+ Zonos.version = `v${"1.4.1"}`;
466
470
  Zonos.modeAlerted = false;
467
471
  Zonos.cartData = null;
468
472
  Zonos.paypal = null;
@@ -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.0.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.4.1.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
@@ -62,7 +62,9 @@ o.includes("test-"))){return o}
62
62
  // when local demo app is running, it needs to use the local dev script unless the qaUrl is set
63
63
  if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!n){return null}
64
64
  // If the qaUrl, use the dev-elements domain to forward the request to the dev server to quickly debug the issue
65
- if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var t="preview.js.zonos.com";var r="https://".concat(n,".").concat(t);log("[ZONOS-WARNING] using '".concat(r,"' for loading elements script"),"warn");
65
+ if(n==="dev-elements"){return"https://dev.elements.zonos.com"}
66
+ // The worker alias selects the API host only. Scripts stay on the normal CDN.
67
+ if(n==="worker"){return null}var t="preview.js.zonos.com";var r="https://".concat(n,".").concat(t);log("[ZONOS-WARNING] using '".concat(r,"' for loading elements script"),"warn");
66
68
  // request to the url and check if the request has an error
67
69
  void fetch(r).then((function(){
68
70
  // cleanup checkout session to avoid using the prod session in preview domain
@@ -90,22 +92,22 @@ if(!hasCheckoutCartCallback()){return null}return zonosStripeLoadScript(null)}))
90
92
  console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r;return __generator(this,(function(i){switch(i.label){case 0:loadCalled=true;o=Date.now();return[4/*yield*/,stripePromise];case 1:if(!((n=i.sent())!==null&&n!==void 0))return[3/*break*/,2];r=n;return[3/*break*/,4];case 2:return[4/*yield*/,zonosStripeLoadScript(null)];case 3:r=i.sent();i.label=4;case 4:t=r;return[2/*return*/,initStripe(t,e,o)]}}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";
91
93
  /**
92
94
  * Simple function to get the cart id from the query param.
93
- */var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var n=e.get(TEMP_CART_ID_QUERY_PARAM);return n};var getCartInfoById=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,o,t,r,i,a,s,u,c;var d=e.cartId,l=e.retries;return __generator(this,(function(e){switch(e.label){case 0:n=getIsTestMode();o=getGenericSettingsOverride();t=getAbandonedCartRenewTokenValue()||undefined;r=new URLSearchParams;if(o.overrideShouldEnabledCustomAddress){r.set("overrideShouldEnabledCustomAddress",o.overrideShouldEnabledCustomAddress)}return[4/*yield*/,handleFetch("/api/zonos-elements/get-cart?".concat(r.toString()),{body:{isTestMode:n,renewCartExpirationToken:t,tempCartUUID:d},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:i=e.sent(),a=i.errors,s=i.json,u=i.zonosMode;c=!s||a.length;if(!(c&&l))return[3/*break*/,3];log("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:l});
95
+ */var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var n=e.get(TEMP_CART_ID_QUERY_PARAM);return n};var getCartInfoById=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,o,t,r,i,a,s,u,c;var l=e.cartId,d=e.retries;return __generator(this,(function(e){switch(e.label){case 0:n=getIsTestMode();o=getGenericSettingsOverride();t=getAbandonedCartRenewTokenValue()||undefined;r=new URLSearchParams;if(o.overrideShouldEnabledCustomAddress){r.set("overrideShouldEnabledCustomAddress",o.overrideShouldEnabledCustomAddress)}return[4/*yield*/,handleFetch("/api/zonos-elements/get-cart?".concat(r.toString()),{body:{isTestMode:n,renewCartExpirationToken:t,tempCartUUID:l},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:i=e.sent(),a=i.errors,s=i.json,u=i.zonosMode;c=!s||a.length;if(!(c&&d))return[3/*break*/,3];log("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:d});
94
96
  // wait 1 second before retrying
95
97
  return[4/*yield*/,new Promise((function(e){return setTimeout(e,500)}))];case 2:
96
98
  // wait 1 second before retrying
97
- e.sent();return[2/*return*/,getCartInfoById({cartId:d,retries:l-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;
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;
98
100
  /**
99
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
100
- */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.0.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.0";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.4.0";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.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;
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;
101
103
  // if query 'zonosDebug=1' param from url, debug mode is on
102
- 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="1792186375498";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="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
103
105
  window.location!=window.parent.location&&document.referrer||
104
106
  // current domain
105
107
  document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.overrideUseCustomAddressForm=false;Zonos.isCollect=false;Zonos.isInvoice=false;
106
108
  /**
107
109
  * By default, the package will load from npm
108
- */Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.4.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,d,l,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.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();
109
111
  // Expose the checkout cart callbacks on the global so Stripe loading can be
110
112
  // gated on whether at least one of them is configured.
111
113
  _a.createCartId=o===null||o===void 0?void 0:o.createCartId;
@@ -116,13 +118,13 @@ return[2/*return*/]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ===
116
118
  // When not in iframe, providers are ready (gtag/fbq work directly). When in iframe, relay sets these after parent configures.
117
119
  if(typeof window!=="undefined"&&window.parent===window){_a.googleAnalyticReady=true;_a.facebookPixelReady=true}if(!_a.isNpm)return[3/*break*/,4];log("====== ZONOS LOADING FROM NPM ======");c=getZonosQaUrl();
118
120
  // if zonosQaUrl is available, inject the script from the zonosQaUrl and then call init again
119
- if(c&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(c," ======"),"info");d=document.createElement("script");d.src="".concat(c,"/dist/scripts/zonos.js");document.head.appendChild(d);d.addEventListener("load",(function(){window.Zonos.isNpm=_a.isNpm;window.Zonos.isBigCommerce=_a.isBigCommerce;window.Zonos.isLegacyCheckout=_a.isLegacyCheckout;window.Zonos.zonosMode=_a.zonosMode;
121
+ if(c&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(c," ======"),"info");l=document.createElement("script");l.src="".concat(c,"/dist/scripts/zonos.js");document.head.appendChild(l);l.addEventListener("load",(function(){window.Zonos.isNpm=_a.isNpm;window.Zonos.isBigCommerce=_a.isBigCommerce;window.Zonos.isLegacyCheckout=_a.isLegacyCheckout;window.Zonos.zonosMode=_a.zonosMode;
120
122
  // call init again after the script is loaded
121
- void window.Zonos.init(e)}));d.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(c))}));
123
+ void window.Zonos.init(e)}));l.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(c))}));
122
124
  // Set so won't inject the preview script again
123
125
  window.isZonosPreview=true;return[2/*return*/]}
124
126
  // zonosApiKey is required if tempCartUUID in query params are not provided
125
- if(!u&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2/*return*/]}if(!(!_a.cartData&&_a.cartId))return[3/*break*/,2];log("Initialize cart data");return[4/*yield*/,setupCartDataWithSettings(_a.cartId)];case 1:l=p.sent();if(!l){logError("Failed to get cart data");return[2/*return*/]}_a.cartData=l.cartData;_a.zonosApiKey=l.zonosApiKey;_a.cartSettings=l.settings;p.label=2;case 2:return[4/*yield*/,getWithTestPublicCredential()];case 3:f=p.sent();if(f){_a.zonosApiKey=f}p.label=4;case 4:v=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");m=_a.cartId&&_a.cartData||!!v;
127
+ if(!u&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2/*return*/]}if(!(!_a.cartData&&_a.cartId))return[3/*break*/,2];log("Initialize cart data");return[4/*yield*/,setupCartDataWithSettings(_a.cartId)];case 1:d=p.sent();if(!d){logError("Failed to get cart data");return[2/*return*/]}_a.cartData=d.cartData;_a.zonosApiKey=d.zonosApiKey;_a.cartSettings=d.settings;p.label=2;case 2:return[4/*yield*/,getWithTestPublicCredential()];case 3:f=p.sent();if(f){_a.zonosApiKey=f}p.label=4;case 4:v=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");m=_a.cartId&&_a.cartData||!!v;
126
128
  // inject hidden button to body to trigger checkout right away if we have cartData or stripe client secret
127
129
  if(m){log("Cart data or stripe client secret is available, inject hidden button and trigger checkout");_=document.createElement("button");_.style.display="none";_.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(_)}log("init zonos");_a.restoreNativeBrowserFunctions();
128
130
  // inject custom script for hosted checkout if can find it in metadata
@@ -1 +1 @@
1
- (function(){"use strict";const e=({id:e,payload:o,target:t,type:n})=>{var r;t instanceof HTMLIFrameElement?null===(r=t.contentWindow)||void 0===r||r.postMessage({id:e,payload:o,type:n},"*"):t.postMessage({id:e,payload:o,type:n},"*")};class o{constructor(o,t){this.targetElement=o,this.targetId=t,this.sendMessage=(o,t)=>{e({id:this.targetId,payload:t,target:this.targetElement,type:o})}}}o.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},o.sendMessage=e,o.injectPrivateIframe=({id:e,onload:o,src:t})=>{const n=document.createElement("iframe");return n.src=t,n.id=e,n.style.display="none",n.role="presentation",n.ariaHidden="true",n.tabIndex=-1,n.style.border="none !important",n.style.margin="0px !important",n.style.padding="0px !important",n.style.width="1px !important",n.style.minWidth="100% !important",n.style.overflow="hidden !important",n.style.display="block !important",n.style.visibility="hidden !important",n.style.position="fixed !important",n.style.pointerEvents="none !important",n.style.userSelect="none !important",n.style.height="1px !important",n.onload=()=>o(n),document.body.appendChild(n),n};const t=performance.now(),n=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},r=(e,o,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const e=performance.now()-t,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),l=[`(${a})`,...r];l.map(n).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const c=(null===(i=d.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(o){case"warn":c.warn(e,...l);break;case"info":c.info(e,...l);break;case"error":c.error(e,...l);break;default:c.groupCollapsed(e,...l),c.trace(),c.groupEnd()}},s=(e,...o)=>{r(e,"error",...o)},i=["jsdelivr","cdnjs","unpkg","vercel"],a="jsdelivr",l=e=>{const o=i.indexOf(e);return i[o+1]||null},d=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function u(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const p=["cloudflare","vercel"],m=p[0],w={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},y=w[m],h=(e=m)=>{const o=p.indexOf(e),t=p[o+1];return t||null},g=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},f=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},v=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],b=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=g(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},S=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||w[e]||m,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await b({response:n}),response:n,zonosMode:a}}const d=n.status.toString();try{const e=await b({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map(e=>"string"==typeof e?{message:e,type:d}:e),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:d}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${d}: ${"Unknown error"}`,type:d}],json:null,response:null,zonosMode:a}}},C=async({basePathType:e,options:o,path:t})=>{var n,s;const i=t.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await S({basePathType:i,options:o,path:t}),{errors:d,response:c}=l,p=u(l,["errors","response"]),m=performance.now()-a;r(`${t} (${m.toFixed(2)}ms)`,"info");const b=null==c?void 0:c.headers.get("Zonos-Duration");200===(null==c?void 0:c.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(v.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=f(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(d=a,d||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map(e=>e.brand).filter(e=>!/Not.*A.*Brand.*/.test(e)).join(",")};var d;window.Zonos.loadTimeApiInfoList.push(l)})({apiPath:t,apiType:i,loadTimeInternal:b?Number(b):0,loadTimeTotal:m});const z=h(i),k=d.find(({type:e})=>"unknown"===e),Z=d.find(({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted"))),I=!!k||404===(null==c?void 0:c.status)||500===(null==c?void 0:c.status),j=z&&I;return I&&!Z&&(async({endpoint:e,errors:o,metadata:t,shouldPostReleaseErrorReporting:n})=>{r("sendErrorLog","warn",e,t,o);{const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},t)};try{fetch(`${y}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=h();if(!o)return;fetch(`${w[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:w[i]+t,errors:d.map(({message:e})=>`API: ${e}`),metadata:{currentBasePath:i,nextFallbackApiType:z,requestHeaders:null==o?void 0:o.headers,requestPayload:g(null===(n=null==o?void 0:o.body)||void 0===n?void 0:n.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),shouldCallFallback:j,status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),j?(r(`=== "${t}" failed to fetch, trying next fallback ${z}`),C({basePathType:z,options:o,path:t})):Object.assign({errors:d,response:c},p)},z=async(e,o)=>{const t=u(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",s=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":d()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(s).forEach(e=>void 0===s[e]&&delete s[e]);const i=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:n,headers:s,method:r}),a=new URLSearchParams(window.location.search).get("useFallbackApi");return C({basePathType:a||m,options:i,path:e})},k=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),t="https://v1.4.0.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const n=`https://${o}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${n}' for loading elements script`,"warn"),fetch(n).then(()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")}).catch(()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null}),n},Z="https://js.stripe.com/v3",I=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let j=null;const O=e=>(null!==j||(j=new Promise((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)o(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${Z}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&I.test(t.src))return t}return null})();n&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):n||(n=(()=>{const e=document.createElement("script");e.src=`${Z}`;const o=document.head||document.body;return o?(o.appendChild(e),e):(s("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))}),null==n||n.addEventListener("error",()=>{t(new Error("Failed to load Stripe.js"))})}catch(e){return void t(e)}else o(null)})),j),A=Promise.resolve().then(()=>(()=>{var e,o;return"undefined"!=typeof window&&("function"==typeof(null===(e=window.Zonos)||void 0===e?void 0:e.createCartId)||"function"==typeof(null===(o=window.Zonos)||void 0===o?void 0:o.buildCartDetail))})()?O(null):null);let E=!1;A.catch(e=>{E||console.warn(e)});const T=async(...e)=>{var o;E=!0;const t=Date.now();return((e,o,t)=>{if(null===e)return null;const[n,r]=o,s=Object.assign({},r),i=(e=>{if(!("version"in e))return;const{version:o}=e;return"number"==typeof o||"string"==typeof o?o:void 0})(e);"string"==typeof i&&i!==3..toString()?delete s.apiVersion:s.apiVersion="2025-02-24.acacia";const a=e(n,s);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(a,t),a})(null!==(o=await A)&&void 0!==o?o:await O(null),e,t)},L=async({cartId:e,retries:o})=>{const t=c(),n=(()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}})(),s=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,i=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const{errors:a,json:l,zonosMode:d}=await z(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||a.length;return u&&o?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise(e=>setTimeout(e,500)),L({cartId:e,retries:o-1})):u?null:Object.assign(Object.assign({},l),{zonosMode:d})},P=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,$=new RegExp(`^${P.source}$`),D=new RegExp(`^cart_${P.source}$`),U=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,R=async e=>{const{isDgsCartId:o,isLegacyCartId:t}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:D.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!t&&!o)return s("[ZONOS - loadZonos] invalid cart id"),null;const n=await L({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",n),n?(window.Zonos.storeId=n.cartData.storeId,window.Zonos.zonosApiKey=n.cartData.credentialToken,window.Zonos.zonosMode=n.zonosMode,{cartData:n.cartData,settings:n.settings,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}):(s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)},F="zonos--checkout-hidden-international-button";var x;const M=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some(e=>o.includes(e)),n=["qa.js.zonos.com"].some(e=>o.includes(e));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),B=Date.now(),q="https://v1.4.0.js.zonos.com",W=M||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.0",K="https://fonts.googleapis.com",G=/^https:\/\/fonts\.googleapis\.com/;class H{}x=H,H.doneInit=!1,H.cartSettings=null,H.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),H.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),H._paypalMockResponse=null,H.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,H.isBigCommerce=!1,H.releaseDate="1792186409013",H.isLegacyCheckout=!1,H.googleAnalyticId=null,H.googleAnalyticReady=!1,H.facebookPixelId=null,H.facebookPixelReady=!1,H.startLoadTime=B,H.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",H.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),H.overrideUseCustomAddressForm=!1,H.isCollect=!1,H.isInvoice=!1,H.isNpm=!0,H.zonosQaUrl=null,H.zonosQaUrlApi=null,H.trackEventLogs=[],H.version="v1.4.0",H.modeAlerted=!1,H.cartData=null,H.paypal=null,H.zonosMode=null,H.IframeService=o,H.getCurrentTimestamp=()=>(new Date).getTime(),H.zonosController=null,H.loadTimeApiInfoList=[],H.logIntervalId=null,H.init=async e=>{const{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:u,zonosApiKey:p}=e;if(x.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),x.createCartId=null==t?void 0:t.createCartId,x.buildCartDetail=null==t?void 0:t.buildCartDetail,x.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${x.version}) ======`),x.zonosApiKey=p,x.storeId=u,"undefined"!=typeof window&&window.parent===window&&(x.googleAnalyticReady=!0,x.facebookPixelReady=!0),x.isNpm){r("====== ZONOS LOADING FROM NPM ======");const o=k();if(o&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const t=document.createElement("script");return t.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(t),t.addEventListener("load",()=>{window.Zonos.isNpm=x.isNpm,window.Zonos.isBigCommerce=x.isBigCommerce,window.Zonos.isLegacyCheckout=x.isLegacyCheckout,window.Zonos.zonosMode=x.zonosMode,window.Zonos.init(e)}),t.addEventListener("error",()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)}),void(window.isZonosPreview=!0)}if(!p&&!x.cartId)return void s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!x.cartData&&x.cartId){r("Initialize cart data");const e=await R(x.cartId);if(!e)return void s("Failed to get cart data");x.cartData=e.cartData,x.zonosApiKey=e.zonosApiKey,x.cartSettings=e.settings}const t=await(async()=>{const e=c(),o=d();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:t,json:n}=await z("/api/get-test-public-credential");if(t.length||!n)return s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t),null;const i=n.publicCredential;return i?(r(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(s("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();t&&(x.zonosApiKey=t)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(x.cartId&&x.cartData||!!m){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}r("init zonos"),x.restoreNativeBrowserFunctions(),x.injectCustomScriptForHostedCheckout(),x.injectZonosCdn(),x.injectZonosCss(),x.injectFonts(),x.injectCheckoutInternationalButton(),x.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),x.doneInit=!0},H.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${F}`)){const e=document.createElement("button");e.id=F,e.style.display="none",document.body.appendChild(e)}},H.injectCustomScriptForHostedCheckout=()=>{const e=x.cartData,o=(null==e?void 0:e.metadata)||[],t=o.find(e=>"customHeaderScript"===e.key),n=o.find(e=>"customFooterScript"===e.key);if(window.Zonos.isLegacyCheckout&&(t||n)){if(t){r("Injecting custom header script");const e=document.createElement("script");e.textContent=t.value,document.head.appendChild(e)}if(n){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=n.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:n,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout})},H.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},H.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${F}`);setTimeout(()=>{var o;e&&e.dispatchEvent(new CustomEvent("click",{detail:o}))},10)},H.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},H.showNotification=e=>{var o;null===(o=x.zonosController)||void 0===o||o.showNotification(e)},H.updateOrganizationName=e=>{var o;null===(o=x.zonosController)||void 0===o||o.updateOrganizationName(e)},H.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach(e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))}),e&&t&&setTimeout(()=>{o.forEach(e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)})},5e3)}},H.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},H.injectController=({config:e})=>{var o,t;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver(()=>{x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})}).observe(document.body,{childList:!0,subtree:!0})}if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver(()=>{x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})}).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=x.zonosApiKey||"",n.addEventListener("stripeInitEvent",async e=>{const{detail:o}=e;r("loading Stripe");const t=await T(o.publishableKey);t?(window.Zonos.stripe=t,window.Zonos.isCollect?n.initCollectElement(t):window.Zonos.isInvoice?n.initInvoiceElement(t):n.initCheckoutElement(t)):s("API seems to be invalid or missing. Failed to load Stripe")}),document.body.appendChild(n),x.zonosController=n,r("Zonos controller injected!")},H.injectScript=({cdnType:e,isModule:o,theRestUrl:t})=>{const n=`${x.getZonosUrl(e)}/${t}`;if(document.querySelector(`script[src="${n}"]`))return void r(`Zonos script "${n}" already exists in the document`,"warn");const i=document.head||document.body,a=document.createElement("script");o?a.type="module":a.noModule=!0,a.src=n,a.crossOrigin="anonymous",a.onerror=()=>{s(`Failed to load ${a.src}`);const n=l(e);n&&x.injectScript({cdnType:n,isModule:o,theRestUrl:t})},i.appendChild(a)},H.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return W;case"unpkg":return"https://unpkg.com/@zonos/elements@1.4.0";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.0";case"vercel":return q}};if(x.isNpm){return k()||o()}return o()},H.injectZonosCdn=()=>{x.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),x.injectScript({cdnType:a,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},H.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=x.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${q}/`,n.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{s(`Failed to load ${i.href}`);const t=l(e);t&&x.injectStylesheet({cdnType:t,theRestUrl:o})},n.appendChild(i)},H.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(x.injectStylesheet({cdnType:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},H.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${K}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!G.test(t.href))return t}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=K,e.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${K}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(t),r("Zonos font injected!")},H.setupGoogleFont=e=>{var o;null===(o=x.zonosController)||void 0===o||o.setupGoogleFont(e)},H.injectSupportGoogleFont=e=>{var o;r(`[FONT] injecting ${e}`);const t=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${K}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=K,n.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${t} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,n.appendChild(s),r(`[FONT] ${t} font injected!`)},exports.Zonos=H})();
1
+ (function(){"use strict";const e=({id:e,payload:o,target:t,type:n})=>{var r;t instanceof HTMLIFrameElement?null===(r=t.contentWindow)||void 0===r||r.postMessage({id:e,payload:o,type:n},"*"):t.postMessage({id:e,payload:o,type:n},"*")};class o{constructor(o,t){this.targetElement=o,this.targetId=t,this.sendMessage=(o,t)=>{e({id:this.targetId,payload:t,target:this.targetElement,type:o})}}}o.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},o.sendMessage=e,o.injectPrivateIframe=({id:e,onload:o,src:t})=>{const n=document.createElement("iframe");return n.src=t,n.id=e,n.style.display="none",n.role="presentation",n.ariaHidden="true",n.tabIndex=-1,n.style.border="none !important",n.style.margin="0px !important",n.style.padding="0px !important",n.style.width="1px !important",n.style.minWidth="100% !important",n.style.overflow="hidden !important",n.style.display="block !important",n.style.visibility="hidden !important",n.style.position="fixed !important",n.style.pointerEvents="none !important",n.style.userSelect="none !important",n.style.height="1px !important",n.onload=()=>o(n),document.body.appendChild(n),n};const t=performance.now(),n=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},r=(e,o,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const e=performance.now()-t,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),l=[`(${a})`,...r];l.map(n).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const c=(null===(i=d.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(o){case"warn":c.warn(e,...l);break;case"info":c.info(e,...l);break;case"error":c.error(e,...l);break;default:c.groupCollapsed(e,...l),c.trace(),c.groupEnd()}},s=(e,...o)=>{r(e,"error",...o)},i=["jsdelivr","cdnjs","unpkg","vercel"],a="jsdelivr",l=e=>{const o=i.indexOf(e);return i[o+1]||null},d=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function u(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const p=["cloudflare","vercel"],m=p[0],w={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},y=w[m],h=(e=m)=>{const o=p.indexOf(e),t=p[o+1];return t||null},g=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},f=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},v=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],b=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=g(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},S=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||w[e]||m,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await b({response:n}),response:n,zonosMode:a}}const d=n.status.toString();try{const e=await b({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map(e=>"string"==typeof e?{message:e,type:d}:e),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:d}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${d}: ${"Unknown error"}`,type:d}],json:null,response:null,zonosMode:a}}},C=async({basePathType:e,options:o,path:t})=>{var n,s;const i=t.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await S({basePathType:i,options:o,path:t}),{errors:d,response:c}=l,p=u(l,["errors","response"]),m=performance.now()-a;r(`${t} (${m.toFixed(2)}ms)`,"info");const b=null==c?void 0:c.headers.get("Zonos-Duration");200===(null==c?void 0:c.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(v.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=f(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(d=a,d||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map(e=>e.brand).filter(e=>!/Not.*A.*Brand.*/.test(e)).join(",")};var d;window.Zonos.loadTimeApiInfoList.push(l)})({apiPath:t,apiType:i,loadTimeInternal:b?Number(b):0,loadTimeTotal:m});const z=h(i),k=d.find(({type:e})=>"unknown"===e),Z=d.find(({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted"))),I=!!k||404===(null==c?void 0:c.status)||500===(null==c?void 0:c.status),j=z&&I;return I&&!Z&&(async({endpoint:e,errors:o,metadata:t,shouldPostReleaseErrorReporting:n})=>{r("sendErrorLog","warn",e,t,o);{const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},t)};try{fetch(`${y}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=h();if(!o)return;fetch(`${w[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:w[i]+t,errors:d.map(({message:e})=>`API: ${e}`),metadata:{currentBasePath:i,nextFallbackApiType:z,requestHeaders:null==o?void 0:o.headers,requestPayload:g(null===(n=null==o?void 0:o.body)||void 0===n?void 0:n.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),shouldCallFallback:j,status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),j?(r(`=== "${t}" failed to fetch, trying next fallback ${z}`),C({basePathType:z,options:o,path:t})):Object.assign({errors:d,response:c},p)},z=async(e,o)=>{const t=u(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",s=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":d()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(s).forEach(e=>void 0===s[e]&&delete s[e]);const i=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:n,headers:s,method:r}),a=new URLSearchParams(window.location.search).get("useFallbackApi");return C({basePathType:a||m,options:i,path:e})},k=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),t="https://v1.4.1.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";if("worker"===o)return null;const n=`https://${o}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${n}' for loading elements script`,"warn"),fetch(n).then(()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")}).catch(()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null}),n},Z="https://js.stripe.com/v3",I=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let j=null;const O=e=>(null!==j||(j=new Promise((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)o(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${Z}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&I.test(t.src))return t}return null})();n&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):n||(n=(()=>{const e=document.createElement("script");e.src=`${Z}`;const o=document.head||document.body;return o?(o.appendChild(e),e):(s("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))}),null==n||n.addEventListener("error",()=>{t(new Error("Failed to load Stripe.js"))})}catch(e){return void t(e)}else o(null)})),j),A=Promise.resolve().then(()=>(()=>{var e,o;return"undefined"!=typeof window&&("function"==typeof(null===(e=window.Zonos)||void 0===e?void 0:e.createCartId)||"function"==typeof(null===(o=window.Zonos)||void 0===o?void 0:o.buildCartDetail))})()?O(null):null);let E=!1;A.catch(e=>{E||console.warn(e)});const T=async(...e)=>{var o;E=!0;const t=Date.now();return((e,o,t)=>{if(null===e)return null;const[n,r]=o,s=Object.assign({},r),i=(e=>{if(!("version"in e))return;const{version:o}=e;return"number"==typeof o||"string"==typeof o?o:void 0})(e);"string"==typeof i&&i!==3..toString()?delete s.apiVersion:s.apiVersion="2025-02-24.acacia";const a=e(n,s);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(a,t),a})(null!==(o=await A)&&void 0!==o?o:await O(null),e,t)},L=async({cartId:e,retries:o})=>{const t=c(),n=(()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}})(),s=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,i=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const{errors:a,json:l,zonosMode:d}=await z(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||a.length;return u&&o?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise(e=>setTimeout(e,500)),L({cartId:e,retries:o-1})):u?null:Object.assign(Object.assign({},l),{zonosMode:d})},P=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,$=new RegExp(`^${P.source}$`),D=new RegExp(`^cart_${P.source}$`),U=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,R=async e=>{const{isDgsCartId:o,isLegacyCartId:t}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:D.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!t&&!o)return s("[ZONOS - loadZonos] invalid cart id"),null;const n=await L({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",n),n?(window.Zonos.storeId=n.cartData.storeId,window.Zonos.zonosApiKey=n.cartData.credentialToken,window.Zonos.zonosMode=n.zonosMode,{cartData:n.cartData,settings:n.settings,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}):(s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)},F="zonos--checkout-hidden-international-button";var x;const M=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some(e=>o.includes(e)),n=["qa.js.zonos.com"].some(e=>o.includes(e));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),B=Date.now(),q="https://v1.4.1.js.zonos.com",W=M||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.1",K="https://fonts.googleapis.com",G=/^https:\/\/fonts\.googleapis\.com/;class H{}x=H,H.doneInit=!1,H.cartSettings=null,H.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),H.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),H._paypalMockResponse=null,H.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,H.isBigCommerce=!1,H.releaseDate="1792428786407",H.isLegacyCheckout=!1,H.googleAnalyticId=null,H.googleAnalyticReady=!1,H.facebookPixelId=null,H.facebookPixelReady=!1,H.startLoadTime=B,H.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",H.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),H.overrideUseCustomAddressForm=!1,H.isCollect=!1,H.isInvoice=!1,H.isNpm=!0,H.zonosQaUrl=null,H.zonosQaUrlApi=null,H.trackEventLogs=[],H.version="v1.4.1",H.modeAlerted=!1,H.cartData=null,H.paypal=null,H.zonosMode=null,H.IframeService=o,H.getCurrentTimestamp=()=>(new Date).getTime(),H.zonosController=null,H.loadTimeApiInfoList=[],H.logIntervalId=null,H.init=async e=>{const{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:u,zonosApiKey:p}=e;if(x.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),x.createCartId=null==t?void 0:t.createCartId,x.buildCartDetail=null==t?void 0:t.buildCartDetail,x.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${x.version}) ======`),x.zonosApiKey=p,x.storeId=u,"undefined"!=typeof window&&window.parent===window&&(x.googleAnalyticReady=!0,x.facebookPixelReady=!0),x.isNpm){r("====== ZONOS LOADING FROM NPM ======");const o=k();if(o&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const t=document.createElement("script");return t.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(t),t.addEventListener("load",()=>{window.Zonos.isNpm=x.isNpm,window.Zonos.isBigCommerce=x.isBigCommerce,window.Zonos.isLegacyCheckout=x.isLegacyCheckout,window.Zonos.zonosMode=x.zonosMode,window.Zonos.init(e)}),t.addEventListener("error",()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)}),void(window.isZonosPreview=!0)}if(!p&&!x.cartId)return void s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!x.cartData&&x.cartId){r("Initialize cart data");const e=await R(x.cartId);if(!e)return void s("Failed to get cart data");x.cartData=e.cartData,x.zonosApiKey=e.zonosApiKey,x.cartSettings=e.settings}const t=await(async()=>{const e=c(),o=d();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:t,json:n}=await z("/api/get-test-public-credential");if(t.length||!n)return s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t),null;const i=n.publicCredential;return i?(r(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(s("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();t&&(x.zonosApiKey=t)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(x.cartId&&x.cartData||!!m){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}r("init zonos"),x.restoreNativeBrowserFunctions(),x.injectCustomScriptForHostedCheckout(),x.injectZonosCdn(),x.injectZonosCss(),x.injectFonts(),x.injectCheckoutInternationalButton(),x.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),x.doneInit=!0},H.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${F}`)){const e=document.createElement("button");e.id=F,e.style.display="none",document.body.appendChild(e)}},H.injectCustomScriptForHostedCheckout=()=>{const e=x.cartData,o=(null==e?void 0:e.metadata)||[],t=o.find(e=>"customHeaderScript"===e.key),n=o.find(e=>"customFooterScript"===e.key);if(window.Zonos.isLegacyCheckout&&(t||n)){if(t){r("Injecting custom header script");const e=document.createElement("script");e.textContent=t.value,document.head.appendChild(e)}if(n){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=n.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:n,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout})},H.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},H.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${F}`);setTimeout(()=>{var o;e&&e.dispatchEvent(new CustomEvent("click",{detail:o}))},10)},H.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},H.showNotification=e=>{var o;null===(o=x.zonosController)||void 0===o||o.showNotification(e)},H.updateOrganizationName=e=>{var o;null===(o=x.zonosController)||void 0===o||o.updateOrganizationName(e)},H.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach(e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))}),e&&t&&setTimeout(()=>{o.forEach(e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)})},5e3)}},H.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},H.injectController=({config:e})=>{var o,t;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver(()=>{x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})}).observe(document.body,{childList:!0,subtree:!0})}if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver(()=>{x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})}).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=x.zonosApiKey||"",n.addEventListener("stripeInitEvent",async e=>{const{detail:o}=e;r("loading Stripe");const t=await T(o.publishableKey);t?(window.Zonos.stripe=t,window.Zonos.isCollect?n.initCollectElement(t):window.Zonos.isInvoice?n.initInvoiceElement(t):n.initCheckoutElement(t)):s("API seems to be invalid or missing. Failed to load Stripe")}),document.body.appendChild(n),x.zonosController=n,r("Zonos controller injected!")},H.injectScript=({cdnType:e,isModule:o,theRestUrl:t})=>{const n=`${x.getZonosUrl(e)}/${t}`;if(document.querySelector(`script[src="${n}"]`))return void r(`Zonos script "${n}" already exists in the document`,"warn");const i=document.head||document.body,a=document.createElement("script");o?a.type="module":a.noModule=!0,a.src=n,a.crossOrigin="anonymous",a.onerror=()=>{s(`Failed to load ${a.src}`);const n=l(e);n&&x.injectScript({cdnType:n,isModule:o,theRestUrl:t})},i.appendChild(a)},H.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return W;case"unpkg":return"https://unpkg.com/@zonos/elements@1.4.1";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.1";case"vercel":return q}};if(x.isNpm){return k()||o()}return o()},H.injectZonosCdn=()=>{x.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),x.injectScript({cdnType:a,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},H.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=x.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${q}/`,n.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{s(`Failed to load ${i.href}`);const t=l(e);t&&x.injectStylesheet({cdnType:t,theRestUrl:o})},n.appendChild(i)},H.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(x.injectStylesheet({cdnType:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},H.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${K}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!G.test(t.href))return t}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=K,e.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${K}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(t),r("Zonos font injected!")},H.setupGoogleFont=e=>{var o;null===(o=x.zonosController)||void 0===o||o.setupGoogleFont(e)},H.injectSupportGoogleFont=e=>{var o;r(`[FONT] injecting ${e}`);const t=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${K}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=K,n.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${t} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,n.appendChild(s),r(`[FONT] ${t} font injected!`)},exports.Zonos=H})();
@@ -1 +1 @@
1
- (function(){"use strict";const e=()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}},o=e=>/^[A-Z]{2}$/.test(e),n=e=>{try{const n=e.getItem("zonos--country");return n&&o(n)?n:null}catch(e){return null}},t=()=>(e=>{const n=new URLSearchParams(e||window.location.search),t=e=>{const t=n.get(e);return t&&o(t)?t:null},r=t("zCountry"),s=t("country"),i=t("customerCountry");return r||s||i})(new URL(window.location.href).searchParams)||(()=>{var e;return null!==(e=n(window.localStorage))&&void 0!==e?e:n(window.sessionStorage)})();function r(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(e);r<t.length;r++)o.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(e,t[r])&&(n[t[r]]=e[t[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;const s=()=>window.location.search.includes("zonosStagingMode=1"),i=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")},a=["cloudflare","vercel"],d=a[0],l={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},c=l[d],u=(e=d)=>{const o=a.indexOf(e),n=a[o+1];return n||null},p=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},w=performance.now(),g=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},m=(e,o,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const e=performance.now()-w,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),i=[`(${s})`,...n];i.map(g).join(" ");if(!(!!(null===(t=window.Zonos)||void 0===t?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let a=document.querySelector("iframe#zonos---debug-logging-iframe");a||(a=document.createElement("iframe"),a.id="zonos---debug-logging-iframe",a.style.display="none",a.style.opacity="0",a.style.position="absolute",a.style.top="-9999px",a.style.left="-9999px",a.style.width="1px",a.style.height="1px",a.style.border="none",a.style.overflow="hidden",a.style.visibility="hidden",document.body.appendChild(a));const d=(null===(r=a.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(o){case"warn":d.warn(e,...i);break;case"info":d.info(e,...i);break;case"error":d.error(e,...i);break;default:d.groupCollapsed(e,...i),d.trace(),d.groupEnd()}},y=()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||n},f=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],h=({apiPath:e,apiType:o,loadTimeInternal:n,loadTimeTotal:t})=>{if(f.includes(e))return;const r=t-n;if(r<0)return;const s=e.split("?")[0]||e,i=(()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=y();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}})(),a="object"==typeof i.userAgent&&i.userAgent.mobile,d={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(l=a,l||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:n,loadTimeTotal:t,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map(e=>e.brand).filter(e=>!/Not.*A.*Brand.*/.test(e)).join(",")};var l;window.Zonos.loadTimeApiInfoList.push(d)},v=async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:t})=>{if(m("sendErrorLog","warn",e,n,o),t){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const r="userAgentData"in window.navigator?window.navigator.userAgentData:null,s={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:r&&r.brands.length>0?r:window.navigator.userAgent},n)};try{fetch(`${c}/api/zonos-elements/log-error`,{body:JSON.stringify(s),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=u();if(!o)return;fetch(`${l[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(s),method:"POST"})}},S=async({response:e,shouldLog:o=!0,shouldThrow:n=!1})=>{try{const o=await e.text(),n=p(o);if(!n)throw new Error(`Failed to parse content: ${o}`);return n}catch(e){if(n)throw e;return o&&console.error(e),null}},z=async({basePathType:e,options:o,path:n})=>{let t;const r=window.Zonos.zonosQaUrlApi||l[e]||d,s=new URL(r+n),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{t=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=t.headers.get("Zonos-Mode"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&c&&(window.Zonos.modeAlerted=!0),t.ok){return{baseUrl:r,errors:[],json:await S({response:t}),response:t,zonosMode:a}}const u=t.status.toString();try{const e=await S({response:t,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map(e=>"string"==typeof e?{message:e,type:u}:e),json:null,response:t,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:u}],json:null,response:t,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:a}}},Z=async({basePathType:e,options:o,path:n})=>{var t,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),d=await z({basePathType:i,options:o,path:n}),{errors:c,response:w}=d,g=r(d,["errors","response"]),y=performance.now()-a;m(`${n} (${y.toFixed(2)}ms)`,"info");const f=null==w?void 0:w.headers.get("Zonos-Duration");200===(null==w?void 0:w.status)&&h({apiPath:n,apiType:i,loadTimeInternal:f?Number(f):0,loadTimeTotal:y});const S=u(i),C=c.find(({type:e})=>"unknown"===e),b=c.find(({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted"))),I=!!C||404===(null==w?void 0:w.status)||500===(null==w?void 0:w.status),L=S&&I;return I&&!b&&v({endpoint:l[i]+n,errors:c.map(({message:e})=>`API: ${e}`),metadata:{currentBasePath:i,nextFallbackApiType:S,requestHeaders:null==o?void 0:o.headers,requestPayload:p(null===(t=null==o?void 0:o.body)||void 0===t?void 0:t.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),shouldCallFallback:L,status:null==w?void 0:w.status,statusText:null==w?void 0:w.statusText},shouldPostReleaseErrorReporting:!0}),L?(m(`=== "${n}" failed to fetch, trying next fallback ${S}`),Z({basePathType:S,options:o,path:n})):Object.assign({errors:c,response:w},g)},C=async(e,o)=>{const n=r(o||{},[]),t=n.body?JSON.stringify(n.body):void 0,a=n.method||"GET",l=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":s()?"1":void 0,"Zonos-Test-Mode":i()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(l).forEach(e=>void 0===l[e]&&delete l[e]);const c=Object.assign(Object.assign({},n),{body:"GET"===a?void 0:t,headers:l,method:a}),u=new URLSearchParams(window.location.search).get("useFallbackApi");return Z({basePathType:u||d,options:c,path:e})},b=(e,...o)=>{m(e,"error",...o)},I=["jsdelivr","cdnjs","unpkg","vercel"],L=e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");if(!o)return null;return/[^a-zA-Z0-9-_]+/.test(o)?null:o},O=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,A=new RegExp(`^${O.source}$`),T=new RegExp(`^cart_${O.source}$`),k=/^[a-zA-Z0-9]{2,}$/,U=/^cart_[a-zA-Z0-9]{2,}$/,j=e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:k.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:T.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:A.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},E=async({cartId:o,retries:n})=>{const t=i(),r=e(),s=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,a=new URLSearchParams;r.overrideShouldEnabledCustomAddress&&a.set("overrideShouldEnabledCustomAddress",r.overrideShouldEnabledCustomAddress);const{errors:d,json:l,zonosMode:c}=await C(`/api/zonos-elements/get-cart?${a.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||d.length;return u&&n?(m("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise(e=>setTimeout(e,500)),E({cartId:o,retries:n-1})):u?null:Object.assign(Object.assign({},l),{zonosMode:c})},$="z--blur",P=async()=>{const e=window.zonosBlurCurrencyOnInitIntervalId;if(!e)return;await new Promise(e=>setTimeout(e,500)),clearInterval(e);document.querySelectorAll(`.${$}`).forEach(e=>{e.classList.remove($)}),window.zonosBlurCurrencyOnInitIntervalId=void 0},N=({currencySelector:e,specificSelector:o})=>{if(e||o)if(o)o.classList.add($);else{document.querySelectorAll([e].filter(Boolean).join(",")).forEach(e=>{e.classList.add($)})}};var D;const R=(()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=L(window.location.href),n="https://v1.4.0.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const t=`https://${o}.preview.js.zonos.com`;return m(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then(()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")}).catch(()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,n=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null}),t})(),F=(()=>{const e=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrlApi");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),o=L(window.location.href),n=e||o;if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com"].includes(window.location.hostname))return"https://dev.demo.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.demo.elements.zonos.com";if(!e)return null;const t=`https://${e}.route.js.zonos.com`;return m(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})(),B=Date.now();class M{}D=M,M.isNpm=!1,M.isBigCommerce=!1,M.googleAnalyticId=null,M.googleAnalyticReady=!1,M.facebookPixelId=null,M.facebookPixelReady=!1,M.requested=!1,M.zonosMode=null,M.cartData=null,M.startLoadTime=B,M.overrideUseCustomAddressForm=!1,M.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,M.version="v1.4.0",M.isLegacyCheckout=!1,M.isCollect=!1,M.isInvoice=!1,M.legacyStoreLogo=null,M.legacyStoreFavicon=null,M.parallelLoadTimes=[],M.parallelLoadState="off",M.releaseDate="1792186409013",M.loadTimeApiInfoList=[],M.cartSettings=null,M.loadScriptLogHandler=async({cdnLoadTime:e,fallbackLoadTime:o,isError:n,metadata:t,scriptLoadUrl:r,storeId:s,type:i})=>{try{const e=window.performance.getEntriesByType("resource").find(e=>{const o=e;return o.name.includes(r)&&"script"===o.initiatorType});null==e||e.transferSize;(async()=>{})((e&&(null==e?void 0:e.duration)>0?parseFloat(e.duration.toFixed(2)):parseFloat(o.toFixed(2)),Object.assign({decodedBodySize:null==e?void 0:e.decodedBodySize,encodedBodySize:null==e?void 0:e.encodedBodySize,fallbackLoadTime:o,isError:!!n},t)))}catch(e){}},M.loadScriptLogParallelHandler=async e=>{try{if(D.parallelLoadTimes.push(e),2===D.parallelLoadTimes.length){const e=D.parallelLoadTimes.find(e=>"vercel"===e.type),o=D.parallelLoadTimes.find(e=>"jsdelivr"===e.type);if(!e||!o)return;if(e.isError&&o.isError)return void v({endpoint:`<${e.scriptLoadUrl}> <${o.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:o.fallbackLoadTime,cdnType:o.type,vercelLoadTime:e.fallbackLoadTime}});D.loadScriptLogHandler({cdnLoadTime:o.fallbackLoadTime,fallbackLoadTime:e.fallbackLoadTime,isError:e.isError,metadata:{cdnScriptFallbackTime:o.fallbackLoadTime,cdnScriptIsError:!!o.isError,cdnScriptLoadUrl:o.scriptLoadUrl,cdnScriptType:o.type},scriptLoadUrl:e.scriptLoadUrl,storeId:e.storeId,type:e.type})}}catch(e){}},M.legacyCheckoutErrorHandler=({message:e,metadata:o})=>{b(`[ZONOS - loadZonos] ${e}`),v({endpoint:"LegacyCheckoutInit",errors:[e],metadata:Object.assign(Object.assign({},o),{tempCartUUID:D.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:e}))},M.getGithubCdn=({type:e,version:o})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.0";"cdnjs"===e?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.0":"unpkg"===e&&(n="https://unpkg.com/@zonos/elements@1.4.0");return o&&"alpha"!==o?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${o}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${o}`):n},M.injectZonos=({cdnType:e="jsdelivr",initConfig:o,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;o=Object.assign(Object.assign({},o),{zonosApiKey:D.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===e?t:D.getGithubCdn({type:e,version:r}),a=R||i,d=a.replace("https://","").replace("http://",""),l=document.createElement("script"),c=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";l.src=`https://${d}/dist/scripts/${c}?timestamp=${Date.now()}`,m(`[ZONOS - loadZonos] Injecting "${c}" from "${d}"`,"info");const u="4g"===(null===(s=y())||void 0===s?void 0:s.effectiveType),p=["dev.elements.zonos.com","zonos.com"].some(e=>window.location.href.includes(e)),w=I[0]===e,g=I[1],f="on"===D.parallelLoadState&&u&&w&&g&&!p;f&&D.injectZonos({cdnType:g,initConfig:o,parallelLoaded:!0,vercelUrl:t,version:r});const h=performance.now();l.addEventListener("load",async()=>{if(f||n?D.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-h,scriptLoadUrl:l.src,storeId:D.storeId||0,type:e}):D.loadScriptLogHandler({fallbackLoadTime:performance.now()-h,scriptLoadUrl:l.src,storeId:D.storeId||0,type:e}),D.isBigCommerce||(D.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=R,window.Zonos.zonosQaUrlApi=F,window.Zonos.zonosMode=D.zonosMode,window.Zonos.isBigCommerce=D.isBigCommerce,window.Zonos.loadTimeApiInfoList=D.loadTimeApiInfoList,window.Zonos.overrideUseCustomAddressForm=D.overrideUseCustomAddressForm,window.Zonos.startLoadTime=D.startLoadTime,D.cartSettings&&(window.Zonos.cartSettings=D.cartSettings),D.cartId){const e=D.isCollect?"Collect":"hosted Checkout";if(!D.zonosApiKey)throw D.legacyCheckoutErrorHandler({message:`zonosApiKey is missing to initiate ${e}`}),new Error(`zonosApiKey is required for ${e}`);if(!D.cartData)throw D.legacyCheckoutErrorHandler({message:`cartData is missing to initiate ${e}`}),new Error(`cartData is required for ${e}`);if(D.legacyStoreFavicon&&D.isLegacyCheckout&&!D.isCollect)try{if(200!==(await fetch(D.legacyStoreFavicon)).status)throw new Error("Custom favicon is not available");const e=document.createElement("link");e.rel="shortcut icon",e.type="image/x-icon",e.href=D.legacyStoreFavicon,document.head.appendChild(e)}catch(e){}window.Zonos.cartData=D.cartData,window.Zonos.isLegacyCheckout=D.isLegacyCheckout,window.Zonos.cartSettings=D.cartSettings,window.Zonos.isCollect=D.isCollect,window.Zonos.isInvoice=D.isInvoice;const n=Object.assign(Object.assign({},o),{appearance:Object.assign(Object.assign({},o.appearance),{logoUrl:D.isLegacyCheckout&&!D.isCollect&&D.legacyStoreLogo?D.legacyStoreLogo:void 0}),zonosApiKey:D.zonosApiKey});o=n}window.Zonos.version&&(m(`[ZONOS - loadZonos] Execute "Zonos.init" from "${c}" from "${d}"`,"info"),window.Zonos.init(o))}),l.addEventListener("error",async()=>{const s=(e=>{const o=I.indexOf(e);return I[o+1]||null})(e);if(!f&&!n){if(!s)return;D.injectZonos({cdnType:s,initConfig:o,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some(e=>window.location.href.includes(e))||R)return;if(f||n)return void D.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-h,isError:!0,scriptLoadUrl:l.src,storeId:D.storeId||0,type:e});["unpkg","cdnjs","vercel"].includes(e)?v({endpoint:l.src,errors:[`zonos.js - Failed to fetch ${e} CDN.`],metadata:{cdnLoadTime:performance.now()-h,cdnType:e,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):v({endpoint:l.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:e,vercelLoadTime:performance.now()-h}})}),document.head.appendChild(l)},M.handlePerformBlurCurrency=()=>{var e,o,n;!(null===(o=null===(e=D.cartSettings)||void 0===e?void 0:e.genericSettings)||void 0===o?void 0:o.blurCurrencyOnInit)?P():(window.zonosBlurCurrencyOnInitCurrencySelector=window.zonosBlurCurrencyOnInitCurrencySelector||(null===(n=D.cartSettings)||void 0===n?void 0:n.helloSettings.currencyElementSelector),(()=>{if("undefined"==typeof window)return;if(window.zonosBlurCurrencyOnInitIntervalId)return;N({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector});const e=setInterval(()=>{N({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector})},10);window.zonosBlurCurrencyOnInitIntervalId=e,setTimeout(()=>{P()},7e3)})())},M.init=async o=>{var n,r;if(m("=== Init zonos script release date","info",D.releaseDate),R&&!window.isZonosPreview){m(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${R}`,"info");const e=document.createElement("script");return e.src=`${R}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=D.isBigCommerce,window.Zonos.isLegacyCheckout=D.isLegacyCheckout,window.Zonos.startLoadTime=D.startLoadTime,window.Zonos.init(o)}),e.addEventListener("error",()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${R}`)}),void(window.isZonosPreview=!0)}const a=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:d,isLegacyCartId:l}=j(a);if(a&&!l&&!d)return void D.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${a}`,metadata:{invalidCartId:!0}});D.cartId=a;const c=document.querySelector('script[src*="/zonos.js"]'),u=null===(n=document.querySelector("script[src*='/loadZonos.js']"))||void 0===n?void 0:n.src;m(`[ZONOS - init] first load script src: ${u}`,"info"),window.Zonos.zonosQaUrl=R,window.Zonos.zonosQaUrlApi=F,window.Zonos.zonosQaUrl&&m(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&m(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const p=null==u?void 0:u.includes("timestamp=");if(!(D.isNpm||u&&p))return void b("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(c||!u||D.requested)return void m("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!D.cartId)return D.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void b("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(D.requested=!0,D.zonosApiKey=o.zonosApiKey,D.storeId=o.storeId,D.cartId){const e=await(async e=>{const{isDgsCartId:o,isLegacyCartId:n}=j(e);if(!n&&!o)return b("[ZONOS - loadZonos] invalid cart id"),null;const t=await E({cartId:e,retries:5});return m("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(b("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(D.cartId);if(!e)throw D.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");D.cartData=e.cartData,D.cartSettings=e.settings,D.legacyStoreLogo=e.storeLogo,D.legacyStoreFavicon=e.storeFavicon,D.storeId=e.storeId,D.zonosApiKey=e.zonosApiKey,D.isCollect=e.cartData.type.includes("COLLECT"),D.isInvoice="INVOICE"===e.cartData.type}if(!D.zonosApiKey)return void b('"zonosApiKey" is required to initialize Zonos');const w=await(async()=>{const e=i(),o=s();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(m("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return m("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:n,json:t}=await C("/api/get-test-public-credential");if(n.length||!t)return b("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",n),null;const r=t.publicCredential;return r?(m(`[ZONOS - loadZonos] Retrieve new test public token ${r}`,"info"),r):(b("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(w&&(m(`[ZONOS - loadZonos] Using test API key: ${w} for test mode`,"info"),D.zonosApiKey=w),!D.cartId){const{json:o,zonosMode:n}=await(async()=>{if(window.Zonos.cartSettings)return m("Reusing cached zonos settings"),{errors:[],json:window.Zonos.cartSettings,zonosMode:window.Zonos.zonosMode};const o=e(),n=new URLSearchParams;o.overrideShouldEnabledCustomAddress&&n.set("overrideShouldEnabledCustomAddress",o.overrideShouldEnabledCustomAddress);const r=t();r&&n.set("zCountry",r);const{errors:s,json:i,zonosMode:a}=await C(`/api/zonos-elements/zonos-settings?${n.toString()}`);return s.length?(b("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings"),{errors:s,json:null,zonosMode:a}):{errors:[],json:i,zonosMode:a}})();(null==o?void 0:o.appearanceSettings)&&(null==o?void 0:o.checkoutSettings)&&(null==o?void 0:o.helloSettings)&&(null==o?void 0:o.organization)&&(m("[ZONOS - loadZonos] Prefetching zonos settings","info"),D.cartSettings={appearanceSettings:o.appearanceSettings,checkoutSettings:o.checkoutSettings,credentialTokenId:D.zonosApiKey,genericSettings:o.genericSettings,helloSettings:o.helloSettings,inclusivePriceConfigurations:o.inclusivePriceConfigurations,landedCostSettings:o.landedCostSettings,onlineStoreSettings:o.onlineStoreSettings,organization:o.organization,organizationId:(null===(r=o.organization)||void 0===r?void 0:r.id)||"",shippingZones:o.shippingZones},D.zonosMode=n)}D.handlePerformBlurCurrency();const g=D.storeId||o.storeId||0;m(`[ZONOS - loadZonos] Store ID: ${g}`,"info");const y=new URLSearchParams;y.set("storeId",g.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&y.set("_enableStoreVersionPinned","1");const{errors:f,json:h}=await C(`/api/get-store-version?${y.toString()}`);if(f.length||!h)return m("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void D.injectZonos({initConfig:o,vercelUrl:"https://v1.4.0.js.zonos.com",version:null});const{isDifferent:v,source:S,version:z}=h;if(m(`[ZONOS - loadZonos] Store version: ${z}, source: ${S}`,"info"),v){m(`[ZONOS - loadZonos] Updating saved store version to ${z}`,"info");const e={storeId:g,version:z};C(`/api/set-store-version?${y.toString()}`,{body:e,method:"POST"}).catch(e=>b("Unable to save store's vesrion",e))}if(!c){const{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some(e=>o.includes(e)),t=["qa.js.zonos.com"].some(e=>o.includes(e));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:t,isWhiteListed:n}})({loadScriptSrc:u}),r=t&&!n?e:`${"alpha"===z?"alpha":`v${z}`}.js.zonos.com`,s=t&&!n?null:z;m("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:z}),D.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview&&!window.Zonos.doneInit)&&(window.Zonos=M)})();
1
+ (function(){"use strict";const e=()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}},o=e=>/^[A-Z]{2}$/.test(e),n=e=>{try{const n=e.getItem("zonos--country");return n&&o(n)?n:null}catch(e){return null}},t=()=>(e=>{const n=new URLSearchParams(e||window.location.search),t=e=>{const t=n.get(e);return t&&o(t)?t:null},r=t("zCountry"),s=t("country"),i=t("customerCountry");return r||s||i})(new URL(window.location.href).searchParams)||(()=>{var e;return null!==(e=n(window.localStorage))&&void 0!==e?e:n(window.sessionStorage)})();function r(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(e);r<t.length;r++)o.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(e,t[r])&&(n[t[r]]=e[t[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;const s=()=>window.location.search.includes("zonosStagingMode=1"),i=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")},a=["cloudflare","vercel"],d=a[0],l={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},c=l[d],u=(e=d)=>{const o=a.indexOf(e),n=a[o+1];return n||null},p=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},w=performance.now(),g=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},m=(e,o,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const e=performance.now()-w,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),i=[`(${s})`,...n];i.map(g).join(" ");if(!(!!(null===(t=window.Zonos)||void 0===t?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let a=document.querySelector("iframe#zonos---debug-logging-iframe");a||(a=document.createElement("iframe"),a.id="zonos---debug-logging-iframe",a.style.display="none",a.style.opacity="0",a.style.position="absolute",a.style.top="-9999px",a.style.left="-9999px",a.style.width="1px",a.style.height="1px",a.style.border="none",a.style.overflow="hidden",a.style.visibility="hidden",document.body.appendChild(a));const d=(null===(r=a.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(o){case"warn":d.warn(e,...i);break;case"info":d.info(e,...i);break;case"error":d.error(e,...i);break;default:d.groupCollapsed(e,...i),d.trace(),d.groupEnd()}},y=()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||n},f=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],h=({apiPath:e,apiType:o,loadTimeInternal:n,loadTimeTotal:t})=>{if(f.includes(e))return;const r=t-n;if(r<0)return;const s=e.split("?")[0]||e,i=(()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=y();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}})(),a="object"==typeof i.userAgent&&i.userAgent.mobile,d={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(l=a,l||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:n,loadTimeTotal:t,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map(e=>e.brand).filter(e=>!/Not.*A.*Brand.*/.test(e)).join(",")};var l;window.Zonos.loadTimeApiInfoList.push(d)},v=async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:t})=>{if(m("sendErrorLog","warn",e,n,o),t){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const r="userAgentData"in window.navigator?window.navigator.userAgentData:null,s={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:r&&r.brands.length>0?r:window.navigator.userAgent},n)};try{fetch(`${c}/api/zonos-elements/log-error`,{body:JSON.stringify(s),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=u();if(!o)return;fetch(`${l[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(s),method:"POST"})}},S=async({response:e,shouldLog:o=!0,shouldThrow:n=!1})=>{try{const o=await e.text(),n=p(o);if(!n)throw new Error(`Failed to parse content: ${o}`);return n}catch(e){if(n)throw e;return o&&console.error(e),null}},z=async({basePathType:e,options:o,path:n})=>{let t;const r=window.Zonos.zonosQaUrlApi||l[e]||d,s=new URL(r+n),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{t=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=t.headers.get("Zonos-Mode"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&c&&(window.Zonos.modeAlerted=!0),t.ok){return{baseUrl:r,errors:[],json:await S({response:t}),response:t,zonosMode:a}}const u=t.status.toString();try{const e=await S({response:t,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map(e=>"string"==typeof e?{message:e,type:u}:e),json:null,response:t,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:u}],json:null,response:t,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:a}}},Z=async({basePathType:e,options:o,path:n})=>{var t,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),d=await z({basePathType:i,options:o,path:n}),{errors:c,response:w}=d,g=r(d,["errors","response"]),y=performance.now()-a;m(`${n} (${y.toFixed(2)}ms)`,"info");const f=null==w?void 0:w.headers.get("Zonos-Duration");200===(null==w?void 0:w.status)&&h({apiPath:n,apiType:i,loadTimeInternal:f?Number(f):0,loadTimeTotal:y});const S=u(i),C=c.find(({type:e})=>"unknown"===e),b=c.find(({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted"))),I=!!C||404===(null==w?void 0:w.status)||500===(null==w?void 0:w.status),L=S&&I;return I&&!b&&v({endpoint:l[i]+n,errors:c.map(({message:e})=>`API: ${e}`),metadata:{currentBasePath:i,nextFallbackApiType:S,requestHeaders:null==o?void 0:o.headers,requestPayload:p(null===(t=null==o?void 0:o.body)||void 0===t?void 0:t.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),shouldCallFallback:L,status:null==w?void 0:w.status,statusText:null==w?void 0:w.statusText},shouldPostReleaseErrorReporting:!0}),L?(m(`=== "${n}" failed to fetch, trying next fallback ${S}`),Z({basePathType:S,options:o,path:n})):Object.assign({errors:c,response:w},g)},C=async(e,o)=>{const n=r(o||{},[]),t=n.body?JSON.stringify(n.body):void 0,a=n.method||"GET",l=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":s()?"1":void 0,"Zonos-Test-Mode":i()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(l).forEach(e=>void 0===l[e]&&delete l[e]);const c=Object.assign(Object.assign({},n),{body:"GET"===a?void 0:t,headers:l,method:a}),u=new URLSearchParams(window.location.search).get("useFallbackApi");return Z({basePathType:u||d,options:c,path:e})},b=(e,...o)=>{m(e,"error",...o)},I=["jsdelivr","cdnjs","unpkg","vercel"],L=e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");if(!o)return null;return/[^a-zA-Z0-9-_]+/.test(o)?null:o},O=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,A=new RegExp(`^${O.source}$`),T=new RegExp(`^cart_${O.source}$`),k=/^[a-zA-Z0-9]{2,}$/,U=/^cart_[a-zA-Z0-9]{2,}$/,j=e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:k.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:T.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:A.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},E=async({cartId:o,retries:n})=>{const t=i(),r=e(),s=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,a=new URLSearchParams;r.overrideShouldEnabledCustomAddress&&a.set("overrideShouldEnabledCustomAddress",r.overrideShouldEnabledCustomAddress);const{errors:d,json:l,zonosMode:c}=await C(`/api/zonos-elements/get-cart?${a.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||d.length;return u&&n?(m("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise(e=>setTimeout(e,500)),E({cartId:o,retries:n-1})):u?null:Object.assign(Object.assign({},l),{zonosMode:c})},$="z--blur",P=async()=>{const e=window.zonosBlurCurrencyOnInitIntervalId;if(!e)return;await new Promise(e=>setTimeout(e,500)),clearInterval(e);document.querySelectorAll(`.${$}`).forEach(e=>{e.classList.remove($)}),window.zonosBlurCurrencyOnInitIntervalId=void 0},N=({currencySelector:e,specificSelector:o})=>{if(e||o)if(o)o.classList.add($);else{document.querySelectorAll([e].filter(Boolean).join(",")).forEach(e=>{e.classList.add($)})}};var D;const R=(()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=L(window.location.href),n="https://v1.4.1.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";if("worker"===o)return null;const t=`https://${o}.preview.js.zonos.com`;return m(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then(()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")}).catch(()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,n=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null}),t})(),F=(()=>{const e=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrlApi");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),o=L(window.location.href),n=e||o;if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com"].includes(window.location.hostname))return"https://dev.demo.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.demo.elements.zonos.com";if("worker"===n)return"https://worker.iglobalstores.com";if(!e)return null;const t=`https://${e}.route.js.zonos.com`;return m(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})(),B=Date.now();class M{}D=M,M.isNpm=!1,M.isBigCommerce=!1,M.googleAnalyticId=null,M.googleAnalyticReady=!1,M.facebookPixelId=null,M.facebookPixelReady=!1,M.requested=!1,M.zonosMode=null,M.cartData=null,M.startLoadTime=B,M.overrideUseCustomAddressForm=!1,M.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,M.version="v1.4.1",M.isLegacyCheckout=!1,M.isCollect=!1,M.isInvoice=!1,M.legacyStoreLogo=null,M.legacyStoreFavicon=null,M.parallelLoadTimes=[],M.parallelLoadState="off",M.releaseDate="1792428786407",M.loadTimeApiInfoList=[],M.cartSettings=null,M.loadScriptLogHandler=async({cdnLoadTime:e,fallbackLoadTime:o,isError:n,metadata:t,scriptLoadUrl:r,storeId:s,type:i})=>{try{const e=window.performance.getEntriesByType("resource").find(e=>{const o=e;return o.name.includes(r)&&"script"===o.initiatorType});null==e||e.transferSize;(async()=>{})((e&&(null==e?void 0:e.duration)>0?parseFloat(e.duration.toFixed(2)):parseFloat(o.toFixed(2)),Object.assign({decodedBodySize:null==e?void 0:e.decodedBodySize,encodedBodySize:null==e?void 0:e.encodedBodySize,fallbackLoadTime:o,isError:!!n},t)))}catch(e){}},M.loadScriptLogParallelHandler=async e=>{try{if(D.parallelLoadTimes.push(e),2===D.parallelLoadTimes.length){const e=D.parallelLoadTimes.find(e=>"vercel"===e.type),o=D.parallelLoadTimes.find(e=>"jsdelivr"===e.type);if(!e||!o)return;if(e.isError&&o.isError)return void v({endpoint:`<${e.scriptLoadUrl}> <${o.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:o.fallbackLoadTime,cdnType:o.type,vercelLoadTime:e.fallbackLoadTime}});D.loadScriptLogHandler({cdnLoadTime:o.fallbackLoadTime,fallbackLoadTime:e.fallbackLoadTime,isError:e.isError,metadata:{cdnScriptFallbackTime:o.fallbackLoadTime,cdnScriptIsError:!!o.isError,cdnScriptLoadUrl:o.scriptLoadUrl,cdnScriptType:o.type},scriptLoadUrl:e.scriptLoadUrl,storeId:e.storeId,type:e.type})}}catch(e){}},M.legacyCheckoutErrorHandler=({message:e,metadata:o})=>{b(`[ZONOS - loadZonos] ${e}`),v({endpoint:"LegacyCheckoutInit",errors:[e],metadata:Object.assign(Object.assign({},o),{tempCartUUID:D.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:e}))},M.getGithubCdn=({type:e,version:o})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.1";"cdnjs"===e?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.1":"unpkg"===e&&(n="https://unpkg.com/@zonos/elements@1.4.1");return o&&"alpha"!==o?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${o}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${o}`):n},M.injectZonos=({cdnType:e="jsdelivr",initConfig:o,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;o=Object.assign(Object.assign({},o),{zonosApiKey:D.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===e?t:D.getGithubCdn({type:e,version:r}),a=R||i,d=a.replace("https://","").replace("http://",""),l=document.createElement("script"),c=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";l.src=`https://${d}/dist/scripts/${c}?timestamp=${Date.now()}`,m(`[ZONOS - loadZonos] Injecting "${c}" from "${d}"`,"info");const u="4g"===(null===(s=y())||void 0===s?void 0:s.effectiveType),p=["dev.elements.zonos.com","zonos.com"].some(e=>window.location.href.includes(e)),w=I[0]===e,g=I[1],f="on"===D.parallelLoadState&&u&&w&&g&&!p;f&&D.injectZonos({cdnType:g,initConfig:o,parallelLoaded:!0,vercelUrl:t,version:r});const h=performance.now();l.addEventListener("load",async()=>{if(f||n?D.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-h,scriptLoadUrl:l.src,storeId:D.storeId||0,type:e}):D.loadScriptLogHandler({fallbackLoadTime:performance.now()-h,scriptLoadUrl:l.src,storeId:D.storeId||0,type:e}),D.isBigCommerce||(D.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=R,window.Zonos.zonosQaUrlApi=F,window.Zonos.zonosMode=D.zonosMode,window.Zonos.isBigCommerce=D.isBigCommerce,window.Zonos.loadTimeApiInfoList=D.loadTimeApiInfoList,window.Zonos.overrideUseCustomAddressForm=D.overrideUseCustomAddressForm,window.Zonos.startLoadTime=D.startLoadTime,D.cartSettings&&(window.Zonos.cartSettings=D.cartSettings),D.cartId){const e=D.isCollect?"Collect":"hosted Checkout";if(!D.zonosApiKey)throw D.legacyCheckoutErrorHandler({message:`zonosApiKey is missing to initiate ${e}`}),new Error(`zonosApiKey is required for ${e}`);if(!D.cartData)throw D.legacyCheckoutErrorHandler({message:`cartData is missing to initiate ${e}`}),new Error(`cartData is required for ${e}`);if(D.legacyStoreFavicon&&D.isLegacyCheckout&&!D.isCollect)try{if(200!==(await fetch(D.legacyStoreFavicon)).status)throw new Error("Custom favicon is not available");const e=document.createElement("link");e.rel="shortcut icon",e.type="image/x-icon",e.href=D.legacyStoreFavicon,document.head.appendChild(e)}catch(e){}window.Zonos.cartData=D.cartData,window.Zonos.isLegacyCheckout=D.isLegacyCheckout,window.Zonos.cartSettings=D.cartSettings,window.Zonos.isCollect=D.isCollect,window.Zonos.isInvoice=D.isInvoice;const n=Object.assign(Object.assign({},o),{appearance:Object.assign(Object.assign({},o.appearance),{logoUrl:D.isLegacyCheckout&&!D.isCollect&&D.legacyStoreLogo?D.legacyStoreLogo:void 0}),zonosApiKey:D.zonosApiKey});o=n}window.Zonos.version&&(m(`[ZONOS - loadZonos] Execute "Zonos.init" from "${c}" from "${d}"`,"info"),window.Zonos.init(o))}),l.addEventListener("error",async()=>{const s=(e=>{const o=I.indexOf(e);return I[o+1]||null})(e);if(!f&&!n){if(!s)return;D.injectZonos({cdnType:s,initConfig:o,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some(e=>window.location.href.includes(e))||R)return;if(f||n)return void D.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-h,isError:!0,scriptLoadUrl:l.src,storeId:D.storeId||0,type:e});["unpkg","cdnjs","vercel"].includes(e)?v({endpoint:l.src,errors:[`zonos.js - Failed to fetch ${e} CDN.`],metadata:{cdnLoadTime:performance.now()-h,cdnType:e,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):v({endpoint:l.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:e,vercelLoadTime:performance.now()-h}})}),document.head.appendChild(l)},M.handlePerformBlurCurrency=()=>{var e,o,n;!(null===(o=null===(e=D.cartSettings)||void 0===e?void 0:e.genericSettings)||void 0===o?void 0:o.blurCurrencyOnInit)?P():(window.zonosBlurCurrencyOnInitCurrencySelector=window.zonosBlurCurrencyOnInitCurrencySelector||(null===(n=D.cartSettings)||void 0===n?void 0:n.helloSettings.currencyElementSelector),(()=>{if("undefined"==typeof window)return;if(window.zonosBlurCurrencyOnInitIntervalId)return;N({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector});const e=setInterval(()=>{N({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector})},10);window.zonosBlurCurrencyOnInitIntervalId=e,setTimeout(()=>{P()},7e3)})())},M.init=async o=>{var n,r;if(m("=== Init zonos script release date","info",D.releaseDate),R&&!window.isZonosPreview){m(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${R}`,"info");const e=document.createElement("script");return e.src=`${R}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=D.isBigCommerce,window.Zonos.isLegacyCheckout=D.isLegacyCheckout,window.Zonos.startLoadTime=D.startLoadTime,window.Zonos.init(o)}),e.addEventListener("error",()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${R}`)}),void(window.isZonosPreview=!0)}const a=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:d,isLegacyCartId:l}=j(a);if(a&&!l&&!d)return void D.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${a}`,metadata:{invalidCartId:!0}});D.cartId=a;const c=document.querySelector('script[src*="/zonos.js"]'),u=null===(n=document.querySelector("script[src*='/loadZonos.js']"))||void 0===n?void 0:n.src;m(`[ZONOS - init] first load script src: ${u}`,"info"),window.Zonos.zonosQaUrl=R,window.Zonos.zonosQaUrlApi=F,window.Zonos.zonosQaUrl&&m(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&m(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const p=null==u?void 0:u.includes("timestamp=");if(!(D.isNpm||u&&p))return void b("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(c||!u||D.requested)return void m("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!D.cartId)return D.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void b("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(D.requested=!0,D.zonosApiKey=o.zonosApiKey,D.storeId=o.storeId,D.cartId){const e=await(async e=>{const{isDgsCartId:o,isLegacyCartId:n}=j(e);if(!n&&!o)return b("[ZONOS - loadZonos] invalid cart id"),null;const t=await E({cartId:e,retries:5});return m("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(b("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(D.cartId);if(!e)throw D.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");D.cartData=e.cartData,D.cartSettings=e.settings,D.legacyStoreLogo=e.storeLogo,D.legacyStoreFavicon=e.storeFavicon,D.storeId=e.storeId,D.zonosApiKey=e.zonosApiKey,D.isCollect=e.cartData.type.includes("COLLECT"),D.isInvoice="INVOICE"===e.cartData.type}if(!D.zonosApiKey)return void b('"zonosApiKey" is required to initialize Zonos');const w=await(async()=>{const e=i(),o=s();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(m("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return m("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:n,json:t}=await C("/api/get-test-public-credential");if(n.length||!t)return b("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",n),null;const r=t.publicCredential;return r?(m(`[ZONOS - loadZonos] Retrieve new test public token ${r}`,"info"),r):(b("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(w&&(m(`[ZONOS - loadZonos] Using test API key: ${w} for test mode`,"info"),D.zonosApiKey=w),!D.cartId){const{json:o,zonosMode:n}=await(async()=>{if(window.Zonos.cartSettings)return m("Reusing cached zonos settings"),{errors:[],json:window.Zonos.cartSettings,zonosMode:window.Zonos.zonosMode};const o=e(),n=new URLSearchParams;o.overrideShouldEnabledCustomAddress&&n.set("overrideShouldEnabledCustomAddress",o.overrideShouldEnabledCustomAddress);const r=t();r&&n.set("zCountry",r);const{errors:s,json:i,zonosMode:a}=await C(`/api/zonos-elements/zonos-settings?${n.toString()}`);return s.length?(b("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings"),{errors:s,json:null,zonosMode:a}):{errors:[],json:i,zonosMode:a}})();(null==o?void 0:o.appearanceSettings)&&(null==o?void 0:o.checkoutSettings)&&(null==o?void 0:o.helloSettings)&&(null==o?void 0:o.organization)&&(m("[ZONOS - loadZonos] Prefetching zonos settings","info"),D.cartSettings={appearanceSettings:o.appearanceSettings,checkoutSettings:o.checkoutSettings,credentialTokenId:D.zonosApiKey,genericSettings:o.genericSettings,helloSettings:o.helloSettings,inclusivePriceConfigurations:o.inclusivePriceConfigurations,landedCostSettings:o.landedCostSettings,onlineStoreSettings:o.onlineStoreSettings,organization:o.organization,organizationId:(null===(r=o.organization)||void 0===r?void 0:r.id)||"",shippingZones:o.shippingZones},D.zonosMode=n)}D.handlePerformBlurCurrency();const g=D.storeId||o.storeId||0;m(`[ZONOS - loadZonos] Store ID: ${g}`,"info");const y=new URLSearchParams;y.set("storeId",g.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&y.set("_enableStoreVersionPinned","1");const{errors:f,json:h}=await C(`/api/get-store-version?${y.toString()}`);if(f.length||!h)return m("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void D.injectZonos({initConfig:o,vercelUrl:"https://v1.4.1.js.zonos.com",version:null});const{isDifferent:v,source:S,version:z}=h;if(m(`[ZONOS - loadZonos] Store version: ${z}, source: ${S}`,"info"),v){m(`[ZONOS - loadZonos] Updating saved store version to ${z}`,"info");const e={storeId:g,version:z};C(`/api/set-store-version?${y.toString()}`,{body:e,method:"POST"}).catch(e=>b("Unable to save store's vesrion",e))}if(!c){const{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some(e=>o.includes(e)),t=["qa.js.zonos.com"].some(e=>o.includes(e));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:t,isWhiteListed:n}})({loadScriptSrc:u}),r=t&&!n?e:`${"alpha"===z?"alpha":`v${z}`}.js.zonos.com`,s=t&&!n?null:z;m("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:z}),D.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview&&!window.Zonos.doneInit)&&(window.Zonos=M)})();
@@ -1 +1 @@
1
- (function(){"use strict";const e=({id:e,payload:o,target:t,type:n})=>{var r;t instanceof HTMLIFrameElement?null===(r=t.contentWindow)||void 0===r||r.postMessage({id:e,payload:o,type:n},"*"):t.postMessage({id:e,payload:o,type:n},"*")};class o{constructor(o,t){this.targetElement=o,this.targetId=t,this.sendMessage=(o,t)=>{e({id:this.targetId,payload:t,target:this.targetElement,type:o})}}}o.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},o.sendMessage=e,o.injectPrivateIframe=({id:e,onload:o,src:t})=>{const n=document.createElement("iframe");return n.src=t,n.id=e,n.style.display="none",n.role="presentation",n.ariaHidden="true",n.tabIndex=-1,n.style.border="none !important",n.style.margin="0px !important",n.style.padding="0px !important",n.style.width="1px !important",n.style.minWidth="100% !important",n.style.overflow="hidden !important",n.style.display="block !important",n.style.visibility="hidden !important",n.style.position="fixed !important",n.style.pointerEvents="none !important",n.style.userSelect="none !important",n.style.height="1px !important",n.onload=()=>o(n),document.body.appendChild(n),n};const t=performance.now(),n=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},r=(e,o,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const e=performance.now()-t,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),l=[`(${a})`,...r];l.map(n).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const c=(null===(i=d.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(o){case"warn":c.warn(e,...l);break;case"info":c.info(e,...l);break;case"error":c.error(e,...l);break;default:c.groupCollapsed(e,...l),c.trace(),c.groupEnd()}},s=(e,...o)=>{r(e,"error",...o)},i=["jsdelivr","cdnjs","unpkg","vercel"],a="jsdelivr",l=e=>{const o=i.indexOf(e);return i[o+1]||null},d=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function u(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const p=["cloudflare","vercel"],m=p[0],w={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},y=w[m],h=(e=m)=>{const o=p.indexOf(e),t=p[o+1];return t||null},g=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},f=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},v=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],b=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=g(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},S=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||w[e]||m,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await b({response:n}),response:n,zonosMode:a}}const d=n.status.toString();try{const e=await b({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map(e=>"string"==typeof e?{message:e,type:d}:e),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:d}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${d}: ${"Unknown error"}`,type:d}],json:null,response:null,zonosMode:a}}},C=async({basePathType:e,options:o,path:t})=>{var n,s;const i=t.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await S({basePathType:i,options:o,path:t}),{errors:d,response:c}=l,p=u(l,["errors","response"]),m=performance.now()-a;r(`${t} (${m.toFixed(2)}ms)`,"info");const b=null==c?void 0:c.headers.get("Zonos-Duration");200===(null==c?void 0:c.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(v.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=f(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(d=a,d||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map(e=>e.brand).filter(e=>!/Not.*A.*Brand.*/.test(e)).join(",")};var d;window.Zonos.loadTimeApiInfoList.push(l)})({apiPath:t,apiType:i,loadTimeInternal:b?Number(b):0,loadTimeTotal:m});const z=h(i),k=d.find(({type:e})=>"unknown"===e),Z=d.find(({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted"))),I=!!k||404===(null==c?void 0:c.status)||500===(null==c?void 0:c.status),j=z&&I;return I&&!Z&&(async({endpoint:e,errors:o,metadata:t,shouldPostReleaseErrorReporting:n})=>{r("sendErrorLog","warn",e,t,o);{const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},t)};try{fetch(`${y}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=h();if(!o)return;fetch(`${w[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:w[i]+t,errors:d.map(({message:e})=>`API: ${e}`),metadata:{currentBasePath:i,nextFallbackApiType:z,requestHeaders:null==o?void 0:o.headers,requestPayload:g(null===(n=null==o?void 0:o.body)||void 0===n?void 0:n.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),shouldCallFallback:j,status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),j?(r(`=== "${t}" failed to fetch, trying next fallback ${z}`),C({basePathType:z,options:o,path:t})):Object.assign({errors:d,response:c},p)},z=async(e,o)=>{const t=u(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",s=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":d()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(s).forEach(e=>void 0===s[e]&&delete s[e]);const i=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:n,headers:s,method:r}),a=new URLSearchParams(window.location.search).get("useFallbackApi");return C({basePathType:a||m,options:i,path:e})},k=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),t="https://v1.4.0.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const n=`https://${o}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${n}' for loading elements script`,"warn"),fetch(n).then(()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")}).catch(()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null}),n},Z="https://js.stripe.com/v3",I=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let j=null;const O=e=>(null!==j||(j=new Promise((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)o(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${Z}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&I.test(t.src))return t}return null})();n&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):n||(n=(()=>{const e=document.createElement("script");e.src=`${Z}`;const o=document.head||document.body;return o?(o.appendChild(e),e):(s("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))}),null==n||n.addEventListener("error",()=>{t(new Error("Failed to load Stripe.js"))})}catch(e){return void t(e)}else o(null)})),j),A=Promise.resolve().then(()=>(()=>{var e,o;return"undefined"!=typeof window&&("function"==typeof(null===(e=window.Zonos)||void 0===e?void 0:e.createCartId)||"function"==typeof(null===(o=window.Zonos)||void 0===o?void 0:o.buildCartDetail))})()?O(null):null);let E=!1;A.catch(e=>{E||console.warn(e)});const T=async(...e)=>{var o;E=!0;const t=Date.now();return((e,o,t)=>{if(null===e)return null;const[n,r]=o,s=Object.assign({},r),i=(e=>{if(!("version"in e))return;const{version:o}=e;return"number"==typeof o||"string"==typeof o?o:void 0})(e);"string"==typeof i&&i!==3..toString()?delete s.apiVersion:s.apiVersion="2025-02-24.acacia";const a=e(n,s);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(a,t),a})(null!==(o=await A)&&void 0!==o?o:await O(null),e,t)},L=async({cartId:e,retries:o})=>{const t=c(),n=(()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}})(),s=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,i=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const{errors:a,json:l,zonosMode:d}=await z(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||a.length;return u&&o?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise(e=>setTimeout(e,500)),L({cartId:e,retries:o-1})):u?null:Object.assign(Object.assign({},l),{zonosMode:d})},P=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,$=new RegExp(`^${P.source}$`),D=new RegExp(`^cart_${P.source}$`),U=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,R=async e=>{const{isDgsCartId:o,isLegacyCartId:t}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:D.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!t&&!o)return s("[ZONOS - loadZonos] invalid cart id"),null;const n=await L({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",n),n?(window.Zonos.storeId=n.cartData.storeId,window.Zonos.zonosApiKey=n.cartData.credentialToken,window.Zonos.zonosMode=n.zonosMode,{cartData:n.cartData,settings:n.settings,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}):(s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)},F="zonos--checkout-hidden-international-button";var x;const M=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some(e=>o.includes(e)),n=["qa.js.zonos.com"].some(e=>o.includes(e));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),B=Date.now(),q="https://v1.4.0.js.zonos.com",W=M||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.0",K="https://fonts.googleapis.com",G=/^https:\/\/fonts\.googleapis\.com/;class H{}x=H,H.doneInit=!1,H.cartSettings=null,H.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),H.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),H._paypalMockResponse=null,H.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,H.isBigCommerce=!1,H.releaseDate="1792186409013",H.isLegacyCheckout=!1,H.googleAnalyticId=null,H.googleAnalyticReady=!1,H.facebookPixelId=null,H.facebookPixelReady=!1,H.startLoadTime=B,H.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",H.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),H.overrideUseCustomAddressForm=!1,H.isCollect=!1,H.isInvoice=!1,H.isNpm=!0,H.zonosQaUrl=null,H.zonosQaUrlApi=null,H.trackEventLogs=[],H.version="v1.4.0",H.modeAlerted=!1,H.cartData=null,H.paypal=null,H.zonosMode=null,H.IframeService=o,H.getCurrentTimestamp=()=>(new Date).getTime(),H.zonosController=null,H.loadTimeApiInfoList=[],H.logIntervalId=null,H.init=async e=>{const{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:u,zonosApiKey:p}=e;if(x.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),x.createCartId=null==t?void 0:t.createCartId,x.buildCartDetail=null==t?void 0:t.buildCartDetail,x.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${x.version}) ======`),x.zonosApiKey=p,x.storeId=u,"undefined"!=typeof window&&window.parent===window&&(x.googleAnalyticReady=!0,x.facebookPixelReady=!0),x.isNpm){r("====== ZONOS LOADING FROM NPM ======");const o=k();if(o&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const t=document.createElement("script");return t.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(t),t.addEventListener("load",()=>{window.Zonos.isNpm=x.isNpm,window.Zonos.isBigCommerce=x.isBigCommerce,window.Zonos.isLegacyCheckout=x.isLegacyCheckout,window.Zonos.zonosMode=x.zonosMode,window.Zonos.init(e)}),t.addEventListener("error",()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)}),void(window.isZonosPreview=!0)}if(!p&&!x.cartId)return void s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!x.cartData&&x.cartId){r("Initialize cart data");const e=await R(x.cartId);if(!e)return void s("Failed to get cart data");x.cartData=e.cartData,x.zonosApiKey=e.zonosApiKey,x.cartSettings=e.settings}const t=await(async()=>{const e=c(),o=d();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:t,json:n}=await z("/api/get-test-public-credential");if(t.length||!n)return s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t),null;const i=n.publicCredential;return i?(r(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(s("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();t&&(x.zonosApiKey=t)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(x.cartId&&x.cartData||!!m){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}r("init zonos"),x.restoreNativeBrowserFunctions(),x.injectCustomScriptForHostedCheckout(),x.injectZonosCdn(),x.injectZonosCss(),x.injectFonts(),x.injectCheckoutInternationalButton(),x.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),x.doneInit=!0},H.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${F}`)){const e=document.createElement("button");e.id=F,e.style.display="none",document.body.appendChild(e)}},H.injectCustomScriptForHostedCheckout=()=>{const e=x.cartData,o=(null==e?void 0:e.metadata)||[],t=o.find(e=>"customHeaderScript"===e.key),n=o.find(e=>"customFooterScript"===e.key);if(window.Zonos.isLegacyCheckout&&(t||n)){if(t){r("Injecting custom header script");const e=document.createElement("script");e.textContent=t.value,document.head.appendChild(e)}if(n){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=n.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:n,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout})},H.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},H.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${F}`);setTimeout(()=>{var o;e&&e.dispatchEvent(new CustomEvent("click",{detail:o}))},10)},H.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},H.showNotification=e=>{var o;null===(o=x.zonosController)||void 0===o||o.showNotification(e)},H.updateOrganizationName=e=>{var o;null===(o=x.zonosController)||void 0===o||o.updateOrganizationName(e)},H.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach(e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))}),e&&t&&setTimeout(()=>{o.forEach(e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)})},5e3)}},H.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},H.injectController=({config:e})=>{var o,t;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver(()=>{x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})}).observe(document.body,{childList:!0,subtree:!0})}if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver(()=>{x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})}).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=x.zonosApiKey||"",n.addEventListener("stripeInitEvent",async e=>{const{detail:o}=e;r("loading Stripe");const t=await T(o.publishableKey);t?(window.Zonos.stripe=t,window.Zonos.isCollect?n.initCollectElement(t):window.Zonos.isInvoice?n.initInvoiceElement(t):n.initCheckoutElement(t)):s("API seems to be invalid or missing. Failed to load Stripe")}),document.body.appendChild(n),x.zonosController=n,r("Zonos controller injected!")},H.injectScript=({cdnType:e,isModule:o,theRestUrl:t})=>{const n=`${x.getZonosUrl(e)}/${t}`;if(document.querySelector(`script[src="${n}"]`))return void r(`Zonos script "${n}" already exists in the document`,"warn");const i=document.head||document.body,a=document.createElement("script");o?a.type="module":a.noModule=!0,a.src=n,a.crossOrigin="anonymous",a.onerror=()=>{s(`Failed to load ${a.src}`);const n=l(e);n&&x.injectScript({cdnType:n,isModule:o,theRestUrl:t})},i.appendChild(a)},H.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return W;case"unpkg":return"https://unpkg.com/@zonos/elements@1.4.0";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.0";case"vercel":return q}};if(x.isNpm){return k()||o()}return o()},H.injectZonosCdn=()=>{x.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),x.injectScript({cdnType:a,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},H.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=x.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${q}/`,n.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{s(`Failed to load ${i.href}`);const t=l(e);t&&x.injectStylesheet({cdnType:t,theRestUrl:o})},n.appendChild(i)},H.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(x.injectStylesheet({cdnType:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},H.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${K}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!G.test(t.href))return t}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=K,e.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${K}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(t),r("Zonos font injected!")},H.setupGoogleFont=e=>{var o;null===(o=x.zonosController)||void 0===o||o.setupGoogleFont(e)},H.injectSupportGoogleFont=e=>{var o;r(`[FONT] injecting ${e}`);const t=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${K}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=K,n.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${t} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,n.appendChild(s),r(`[FONT] ${t} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=H)})();
1
+ (function(){"use strict";const e=({id:e,payload:o,target:t,type:n})=>{var r;t instanceof HTMLIFrameElement?null===(r=t.contentWindow)||void 0===r||r.postMessage({id:e,payload:o,type:n},"*"):t.postMessage({id:e,payload:o,type:n},"*")};class o{constructor(o,t){this.targetElement=o,this.targetId=t,this.sendMessage=(o,t)=>{e({id:this.targetId,payload:t,target:this.targetElement,type:o})}}}o.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},o.sendMessage=e,o.injectPrivateIframe=({id:e,onload:o,src:t})=>{const n=document.createElement("iframe");return n.src=t,n.id=e,n.style.display="none",n.role="presentation",n.ariaHidden="true",n.tabIndex=-1,n.style.border="none !important",n.style.margin="0px !important",n.style.padding="0px !important",n.style.width="1px !important",n.style.minWidth="100% !important",n.style.overflow="hidden !important",n.style.display="block !important",n.style.visibility="hidden !important",n.style.position="fixed !important",n.style.pointerEvents="none !important",n.style.userSelect="none !important",n.style.height="1px !important",n.onload=()=>o(n),document.body.appendChild(n),n};const t=performance.now(),n=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},r=(e,o,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const e=performance.now()-t,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),l=[`(${a})`,...r];l.map(n).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const c=(null===(i=d.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(o){case"warn":c.warn(e,...l);break;case"info":c.info(e,...l);break;case"error":c.error(e,...l);break;default:c.groupCollapsed(e,...l),c.trace(),c.groupEnd()}},s=(e,...o)=>{r(e,"error",...o)},i=["jsdelivr","cdnjs","unpkg","vercel"],a="jsdelivr",l=e=>{const o=i.indexOf(e);return i[o+1]||null},d=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function u(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const p=["cloudflare","vercel"],m=p[0],w={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},y=w[m],h=(e=m)=>{const o=p.indexOf(e),t=p[o+1];return t||null},g=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},f=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},v=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],b=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=g(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},S=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||w[e]||m,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await b({response:n}),response:n,zonosMode:a}}const d=n.status.toString();try{const e=await b({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map(e=>"string"==typeof e?{message:e,type:d}:e),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:d}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${d}: ${"Unknown error"}`,type:d}],json:null,response:null,zonosMode:a}}},C=async({basePathType:e,options:o,path:t})=>{var n,s;const i=t.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await S({basePathType:i,options:o,path:t}),{errors:d,response:c}=l,p=u(l,["errors","response"]),m=performance.now()-a;r(`${t} (${m.toFixed(2)}ms)`,"info");const b=null==c?void 0:c.headers.get("Zonos-Duration");200===(null==c?void 0:c.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(v.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=f(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(d=a,d||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map(e=>e.brand).filter(e=>!/Not.*A.*Brand.*/.test(e)).join(",")};var d;window.Zonos.loadTimeApiInfoList.push(l)})({apiPath:t,apiType:i,loadTimeInternal:b?Number(b):0,loadTimeTotal:m});const z=h(i),k=d.find(({type:e})=>"unknown"===e),Z=d.find(({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted"))),I=!!k||404===(null==c?void 0:c.status)||500===(null==c?void 0:c.status),j=z&&I;return I&&!Z&&(async({endpoint:e,errors:o,metadata:t,shouldPostReleaseErrorReporting:n})=>{r("sendErrorLog","warn",e,t,o);{const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},t)};try{fetch(`${y}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=h();if(!o)return;fetch(`${w[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:w[i]+t,errors:d.map(({message:e})=>`API: ${e}`),metadata:{currentBasePath:i,nextFallbackApiType:z,requestHeaders:null==o?void 0:o.headers,requestPayload:g(null===(n=null==o?void 0:o.body)||void 0===n?void 0:n.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),shouldCallFallback:j,status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),j?(r(`=== "${t}" failed to fetch, trying next fallback ${z}`),C({basePathType:z,options:o,path:t})):Object.assign({errors:d,response:c},p)},z=async(e,o)=>{const t=u(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",s=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":d()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(s).forEach(e=>void 0===s[e]&&delete s[e]);const i=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:n,headers:s,method:r}),a=new URLSearchParams(window.location.search).get("useFallbackApi");return C({basePathType:a||m,options:i,path:e})},k=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),t="https://v1.4.1.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";if("worker"===o)return null;const n=`https://${o}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${n}' for loading elements script`,"warn"),fetch(n).then(()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")}).catch(()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null}),n},Z="https://js.stripe.com/v3",I=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let j=null;const O=e=>(null!==j||(j=new Promise((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)o(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${Z}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&I.test(t.src))return t}return null})();n&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):n||(n=(()=>{const e=document.createElement("script");e.src=`${Z}`;const o=document.head||document.body;return o?(o.appendChild(e),e):(s("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))}),null==n||n.addEventListener("error",()=>{t(new Error("Failed to load Stripe.js"))})}catch(e){return void t(e)}else o(null)})),j),A=Promise.resolve().then(()=>(()=>{var e,o;return"undefined"!=typeof window&&("function"==typeof(null===(e=window.Zonos)||void 0===e?void 0:e.createCartId)||"function"==typeof(null===(o=window.Zonos)||void 0===o?void 0:o.buildCartDetail))})()?O(null):null);let E=!1;A.catch(e=>{E||console.warn(e)});const T=async(...e)=>{var o;E=!0;const t=Date.now();return((e,o,t)=>{if(null===e)return null;const[n,r]=o,s=Object.assign({},r),i=(e=>{if(!("version"in e))return;const{version:o}=e;return"number"==typeof o||"string"==typeof o?o:void 0})(e);"string"==typeof i&&i!==3..toString()?delete s.apiVersion:s.apiVersion="2025-02-24.acacia";const a=e(n,s);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(a,t),a})(null!==(o=await A)&&void 0!==o?o:await O(null),e,t)},L=async({cartId:e,retries:o})=>{const t=c(),n=(()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}})(),s=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,i=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const{errors:a,json:l,zonosMode:d}=await z(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||a.length;return u&&o?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise(e=>setTimeout(e,500)),L({cartId:e,retries:o-1})):u?null:Object.assign(Object.assign({},l),{zonosMode:d})},P=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,$=new RegExp(`^${P.source}$`),D=new RegExp(`^cart_${P.source}$`),U=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,R=async e=>{const{isDgsCartId:o,isLegacyCartId:t}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:D.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!t&&!o)return s("[ZONOS - loadZonos] invalid cart id"),null;const n=await L({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",n),n?(window.Zonos.storeId=n.cartData.storeId,window.Zonos.zonosApiKey=n.cartData.credentialToken,window.Zonos.zonosMode=n.zonosMode,{cartData:n.cartData,settings:n.settings,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}):(s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)},F="zonos--checkout-hidden-international-button";var x;const M=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some(e=>o.includes(e)),n=["qa.js.zonos.com"].some(e=>o.includes(e));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),B=Date.now(),q="https://v1.4.1.js.zonos.com",W=M||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.1",K="https://fonts.googleapis.com",G=/^https:\/\/fonts\.googleapis\.com/;class H{}x=H,H.doneInit=!1,H.cartSettings=null,H.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),H.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),H._paypalMockResponse=null,H.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,H.isBigCommerce=!1,H.releaseDate="1792428786407",H.isLegacyCheckout=!1,H.googleAnalyticId=null,H.googleAnalyticReady=!1,H.facebookPixelId=null,H.facebookPixelReady=!1,H.startLoadTime=B,H.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",H.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),H.overrideUseCustomAddressForm=!1,H.isCollect=!1,H.isInvoice=!1,H.isNpm=!0,H.zonosQaUrl=null,H.zonosQaUrlApi=null,H.trackEventLogs=[],H.version="v1.4.1",H.modeAlerted=!1,H.cartData=null,H.paypal=null,H.zonosMode=null,H.IframeService=o,H.getCurrentTimestamp=()=>(new Date).getTime(),H.zonosController=null,H.loadTimeApiInfoList=[],H.logIntervalId=null,H.init=async e=>{const{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:u,zonosApiKey:p}=e;if(x.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),x.createCartId=null==t?void 0:t.createCartId,x.buildCartDetail=null==t?void 0:t.buildCartDetail,x.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${x.version}) ======`),x.zonosApiKey=p,x.storeId=u,"undefined"!=typeof window&&window.parent===window&&(x.googleAnalyticReady=!0,x.facebookPixelReady=!0),x.isNpm){r("====== ZONOS LOADING FROM NPM ======");const o=k();if(o&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const t=document.createElement("script");return t.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(t),t.addEventListener("load",()=>{window.Zonos.isNpm=x.isNpm,window.Zonos.isBigCommerce=x.isBigCommerce,window.Zonos.isLegacyCheckout=x.isLegacyCheckout,window.Zonos.zonosMode=x.zonosMode,window.Zonos.init(e)}),t.addEventListener("error",()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)}),void(window.isZonosPreview=!0)}if(!p&&!x.cartId)return void s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!x.cartData&&x.cartId){r("Initialize cart data");const e=await R(x.cartId);if(!e)return void s("Failed to get cart data");x.cartData=e.cartData,x.zonosApiKey=e.zonosApiKey,x.cartSettings=e.settings}const t=await(async()=>{const e=c(),o=d();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:t,json:n}=await z("/api/get-test-public-credential");if(t.length||!n)return s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t),null;const i=n.publicCredential;return i?(r(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(s("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();t&&(x.zonosApiKey=t)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(x.cartId&&x.cartData||!!m){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}r("init zonos"),x.restoreNativeBrowserFunctions(),x.injectCustomScriptForHostedCheckout(),x.injectZonosCdn(),x.injectZonosCss(),x.injectFonts(),x.injectCheckoutInternationalButton(),x.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),x.doneInit=!0},H.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${F}`)){const e=document.createElement("button");e.id=F,e.style.display="none",document.body.appendChild(e)}},H.injectCustomScriptForHostedCheckout=()=>{const e=x.cartData,o=(null==e?void 0:e.metadata)||[],t=o.find(e=>"customHeaderScript"===e.key),n=o.find(e=>"customFooterScript"===e.key);if(window.Zonos.isLegacyCheckout&&(t||n)){if(t){r("Injecting custom header script");const e=document.createElement("script");e.textContent=t.value,document.head.appendChild(e)}if(n){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=n.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:n,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout})},H.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},H.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${F}`);setTimeout(()=>{var o;e&&e.dispatchEvent(new CustomEvent("click",{detail:o}))},10)},H.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},H.showNotification=e=>{var o;null===(o=x.zonosController)||void 0===o||o.showNotification(e)},H.updateOrganizationName=e=>{var o;null===(o=x.zonosController)||void 0===o||o.updateOrganizationName(e)},H.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach(e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))}),e&&t&&setTimeout(()=>{o.forEach(e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)})},5e3)}},H.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},H.injectController=({config:e})=>{var o,t;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver(()=>{x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})}).observe(document.body,{childList:!0,subtree:!0})}if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver(()=>{x.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})}).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=x.zonosApiKey||"",n.addEventListener("stripeInitEvent",async e=>{const{detail:o}=e;r("loading Stripe");const t=await T(o.publishableKey);t?(window.Zonos.stripe=t,window.Zonos.isCollect?n.initCollectElement(t):window.Zonos.isInvoice?n.initInvoiceElement(t):n.initCheckoutElement(t)):s("API seems to be invalid or missing. Failed to load Stripe")}),document.body.appendChild(n),x.zonosController=n,r("Zonos controller injected!")},H.injectScript=({cdnType:e,isModule:o,theRestUrl:t})=>{const n=`${x.getZonosUrl(e)}/${t}`;if(document.querySelector(`script[src="${n}"]`))return void r(`Zonos script "${n}" already exists in the document`,"warn");const i=document.head||document.body,a=document.createElement("script");o?a.type="module":a.noModule=!0,a.src=n,a.crossOrigin="anonymous",a.onerror=()=>{s(`Failed to load ${a.src}`);const n=l(e);n&&x.injectScript({cdnType:n,isModule:o,theRestUrl:t})},i.appendChild(a)},H.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return W;case"unpkg":return"https://unpkg.com/@zonos/elements@1.4.1";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.1";case"vercel":return q}};if(x.isNpm){return k()||o()}return o()},H.injectZonosCdn=()=>{x.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),x.injectScript({cdnType:a,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},H.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=x.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${q}/`,n.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{s(`Failed to load ${i.href}`);const t=l(e);t&&x.injectStylesheet({cdnType:t,theRestUrl:o})},n.appendChild(i)},H.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(x.injectStylesheet({cdnType:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},H.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${K}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!G.test(t.href))return t}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=K,e.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${K}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(t),r("Zonos font injected!")},H.setupGoogleFont=e=>{var o;null===(o=x.zonosController)||void 0===o||o.setupGoogleFont(e)},H.injectSupportGoogleFont=e=>{var o;r(`[FONT] injecting ${e}`);const t=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${K}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=K,n.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${t} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,n.appendChild(s),r(`[FONT] ${t} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=H)})();
@@ -1 +1 @@
1
- import{c as n}from"./p-XQfWgQLB.js";import{g as o,I as t}from"./p-HeAZDwVW.js";import{l as r}from"./p-BJmZPrZl.js";export{a as availableTestKeys}from"./p-BJmZPrZl.js";import{g as i,a as l,h as u,l as m}from"./p-DE4a-QD5.js";import{g as p,_ as w,c as f,a as y}from"./p-D5SpFsQJ.js";export{d as domesticRedirectedBtnSelector}from"./p-D5SpFsQJ.js";export{c as countryRequireShortAddressCode}from"./p-nJ6oI8-n.js";export{c as countryRequireTaxId,e as euCountryCodes,s as shipToTaxIdLabels}from"./p-Cye-evFK.js";const v=["jsdelivr","cdnjs","unpkg","vercel"],h="jsdelivr",O=e=>{const n=v.indexOf(e);return v[n+1]||null},g=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const n=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),o="https://v1.4.0.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-")))return o;if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";const t=`https://${n}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),t},S="https://js.stripe.com/v3",j=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let z=null;const b=e=>(null!==z||(z=new Promise(((n,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)n(window.Stripe);else try{let t=(()=>{const e=document.querySelectorAll(`script[src^="${S}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&j.test(o.src))return o}return null})();t&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):t||(t=(()=>{const e=document.createElement("script");e.src=`${S}`;const n=document.head||document.body;return n?(n.appendChild(e),e):(m("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==t||t.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):o(new Error("Stripe.js not available"))})),null==t||t.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else n(null)}))),z),N=Promise.resolve().then((()=>(()=>{var e,n;return"undefined"!=typeof window&&("function"==typeof(null===(e=window.Zonos)||void 0===e?void 0:e.createCartId)||"function"==typeof(null===(n=window.Zonos)||void 0===n?void 0:n.buildCartDetail))})()?b(null):null));let I=!1;N.catch((e=>{I||console.warn(e)}));const Z=async({cartId:e,retries:n})=>{const t=i(),s=o(),c=p()||void 0,d=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&d.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:l,json:a,zonosMode:m}=await u(`/api/zonos-elements/get-cart?${d.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:c,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),w=!a||l.length;return w&&n?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise((e=>setTimeout(e,500))),Z({cartId:e,retries:n-1})):w?null:Object.assign(Object.assign({},a),{zonosMode:m})};var k;const R=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),T=Date.now(),$="https://v1.4.0.js.zonos.com",A=R||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.0",L="https://fonts.googleapis.com",C=/^https:\/\/fonts\.googleapis\.com/;class U{}k=U,U.doneInit=!1,U.cartSettings=null,U.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),U.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),U._paypalMockResponse=null,U.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,U.isBigCommerce=!1,U.releaseDate="1792186375498",U.isLegacyCheckout=!1,U.googleAnalyticId=null,U.googleAnalyticReady=!1,U.facebookPixelId=null,U.facebookPixelReady=!1,U.startLoadTime=T,U.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",U.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),U.overrideUseCustomAddressForm=!1,U.isCollect=!1,U.isInvoice=!1,U.isNpm=!0,U.zonosQaUrl=null,U.zonosQaUrlApi=null,U.trackEventLogs=[],U.version="v1.4.0",U.modeAlerted=!1,U.cartData=null,U.paypal=null,U.zonosMode=null,U.IframeService=t,U.getCurrentTimestamp=()=>(new Date).getTime(),U.zonosController=null,U.loadTimeApiInfoList=[],U.logIntervalId=null,U.init=async e=>{const{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d,storeId:a,zonosApiKey:p}=e;if(k.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),k.createCartId=null==o?void 0:o.createCartId,k.buildCartDetail=null==o?void 0:o.buildCartDetail,k.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${k.version}) ======`),k.zonosApiKey=p,k.storeId=a,"undefined"!=typeof window&&window.parent===window&&(k.googleAnalyticReady=!0,k.facebookPixelReady=!0),k.isNpm){r("====== ZONOS LOADING FROM NPM ======");const n=g();if(n&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${n} ======`,"info");const o=document.createElement("script");return o.src=`${n}/dist/scripts/zonos.js`,document.head.appendChild(o),o.addEventListener("load",(()=>{window.Zonos.isNpm=k.isNpm,window.Zonos.isBigCommerce=k.isBigCommerce,window.Zonos.isLegacyCheckout=k.isLegacyCheckout,window.Zonos.zonosMode=k.zonosMode,window.Zonos.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${n}`)})),void(window.isZonosPreview=!0)}if(!p&&!k.cartId)return void m("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!k.cartData&&k.cartId){r("Initialize cart data");const e=await(async e=>{const{isDgsCartId:n,isLegacyCartId:o}=w(e);if(!o&&!n)return m("[ZONOS - loadZonos] invalid cart id"),null;const t=await Z({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(m("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(k.cartId);if(!e)return void m("Failed to get cart data");k.cartData=e.cartData,k.zonosApiKey=e.zonosApiKey,k.cartSettings=e.settings}const o=await(async()=>{const e=i(),n=l();if(!e&&!n||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:o,json:t}=await u("/api/get-test-public-credential");if(o.length||!t)return m("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),null;const s=t.publicCredential;return s?(r(`[ZONOS - loadZonos] Retrieve new test public token ${s}`,"info"),s):(m("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();o&&(k.zonosApiKey=o)}const y=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(k.cartId&&k.cartData||y){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id=`${f}`,document.body.appendChild(e)}r("init zonos"),k.restoreNativeBrowserFunctions(),k.injectCustomScriptForHostedCheckout(),k.injectZonosCdn(),k.injectZonosCss(),k.injectFonts(),k.injectCheckoutInternationalButton(),k.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d}}),k.doneInit=!0},U.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${y}`)){const e=document.createElement("button");e.id=y,e.style.display="none",document.body.appendChild(e)}},U.injectCustomScriptForHostedCheckout=()=>{const e=k.cartData,n=(null==e?void 0:e.metadata)||[],o=n.find((e=>"customHeaderScript"===e.key)),t=n.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||t)){if(o){r("Injecting custom header script");const e=document.createElement("script");e.textContent=o.value,document.head.appendChild(e)}if(t){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=t.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},U.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},U.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${y}`);setTimeout((()=>{e&&e.dispatchEvent(n("click"))}),10)},U.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},U.showNotification=e=>{var n;null===(n=k.zonosController)||void 0===n||n.showNotification(e)},U.updateOrganizationName=e=>{var n;null===(n=k.zonosController)||void 0===n||n.updateOrganizationName(e)},U.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:o,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const n=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&o&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},U.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const n="zonos---native-browser";let o=document.querySelector(`iframe#${n}`);o||(o=document.createElement("iframe"),o.id=n,o.style.display="none",o.style.opacity="0",o.style.position="absolute",o.style.top="-9999px",o.style.left="-9999px",o.style.width="1px",o.style.height="1px",o.style.border="none",o.style.overflow="hidden",o.style.visibility="hidden",document.body.appendChild(o));const t=(null===(e=o.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=t,document.body.removeChild(o)},U.injectController=({config:e})=>{var n,o;if(document.querySelector("zonos-controller"))return;if(null===(n=e.checkoutSettings)||void 0===n?void 0:n.placeOrderButtonSelector){const n=e.checkoutSettings.placeOrderButtonSelector;k.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{k.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const n=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;k.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{k.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}const t=document.createElement("zonos-controller");t.config=e,t.zonosApiKey=k.zonosApiKey||"",t.addEventListener("stripeInitEvent",(async e=>{const{detail:n}=e;r("loading Stripe");const o=await(async(...e)=>{var n;I=!0;const o=Date.now();return((e,n,o)=>{if(null===e)return null;const[t,s]=n,r=Object.assign({},s),i=(e=>{if(!("version"in e))return;const{version:n}=e;return"number"==typeof n||"string"==typeof n?n:void 0})(e);"string"==typeof i&&i!==3..toString()?delete r.apiVersion:r.apiVersion="2025-02-24.acacia";const c=e(t,r);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(c,o),c})(null!==(n=await N)&&void 0!==n?n:await b(null),e,o)})(n.publishableKey);o?(window.Zonos.stripe=o,window.Zonos.isCollect?t.initCollectElement(o):window.Zonos.isInvoice?t.initInvoiceElement(o):t.initCheckoutElement(o)):m("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(t),k.zonosController=t,r("Zonos controller injected!")},U.injectScript=({cdnType:e,isModule:n,theRestUrl:o})=>{const t=`${k.getZonosUrl(e)}/${o}`;if(document.querySelector(`script[src="${t}"]`))return void r(`Zonos script "${t}" already exists in the document`,"warn");const s=document.head||document.body,i=document.createElement("script");n?i.type="module":i.noModule=!0,i.src=t,i.crossOrigin="anonymous",i.onerror=()=>{m(`Failed to load ${i.src}`);const t=O(e);t&&k.injectScript({cdnType:t,isModule:n,theRestUrl:o})},s.appendChild(i)},U.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return A;case"unpkg":return"https://unpkg.com/@zonos/elements@1.4.0";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.0";case"vercel":return $}};return k.isNpm&&g()||n()},U.injectZonosCdn=()=>{k.injectScript({cdnType:h,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),k.injectScript({cdnType:h,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},U.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const o=k.getZonosUrl(e),t=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${$}/`,t.appendChild(s);const r=document.createElement("link");r.rel="stylesheet",r.href=`${o}/${n}`,r.onerror=()=>{m(`Failed to load ${r.href}`);const o=O(e);o&&k.injectStylesheet({cdnType:o,theRestUrl:n})},t.appendChild(r)},U.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(k.injectStylesheet({cdnType:h,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},U.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!C.test(o.href))return o}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=L,e.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${L}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(o),r("Zonos font injected!")},U.setupGoogleFont=e=>{var n;null===(n=k.zonosController)||void 0===n||n.setupGoogleFont(e)},U.injectSupportGoogleFont=e=>{var n;r(`[FONT] injecting ${e}`);const o=null===(n=e.match(/family=(.*?):/))||void 0===n?void 0:n[1],t=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${L}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=L,t.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,t.appendChild(s),r(`[FONT] ${o} font injected!`)};const E=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"],D=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"],P=[...E,...D];export{U as Zonos,f as checkoutHiddenBtnSelector,y as checkoutHiddenInternationalBtnSelector,P as checkoutSessionAttributeKeys,D as checkoutSessionImmutableAttributeKeys,E as checkoutSessionMutableAttributeKeys}
1
+ import{c as n}from"./p-XQfWgQLB.js";import{g as o,I as t}from"./p-HeAZDwVW.js";import{l as r}from"./p-BJmZPrZl.js";export{a as availableTestKeys}from"./p-BJmZPrZl.js";import{g as i,a as l,h as u,l as m}from"./p-DE4a-QD5.js";import{g as p,_ as w,c as f,a as y}from"./p-D5SpFsQJ.js";export{d as domesticRedirectedBtnSelector}from"./p-D5SpFsQJ.js";export{c as countryRequireShortAddressCode}from"./p-nJ6oI8-n.js";export{c as countryRequireTaxId,e as euCountryCodes,s as shipToTaxIdLabels}from"./p-Cye-evFK.js";const v=["jsdelivr","cdnjs","unpkg","vercel"],h="jsdelivr",O=e=>{const n=v.indexOf(e);return v[n+1]||null},g=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const n=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),o="https://v1.4.1.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-")))return o;if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";if("worker"===n)return null;const t=`https://${n}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),t},S="https://js.stripe.com/v3",j=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let z=null;const b=e=>(null!==z||(z=new Promise(((n,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)n(window.Stripe);else try{let t=(()=>{const e=document.querySelectorAll(`script[src^="${S}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&j.test(o.src))return o}return null})();t&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):t||(t=(()=>{const e=document.createElement("script");e.src=`${S}`;const n=document.head||document.body;return n?(n.appendChild(e),e):(m("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==t||t.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):o(new Error("Stripe.js not available"))})),null==t||t.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else n(null)}))),z),N=Promise.resolve().then((()=>(()=>{var e,n;return"undefined"!=typeof window&&("function"==typeof(null===(e=window.Zonos)||void 0===e?void 0:e.createCartId)||"function"==typeof(null===(n=window.Zonos)||void 0===n?void 0:n.buildCartDetail))})()?b(null):null));let I=!1;N.catch((e=>{I||console.warn(e)}));const k=async({cartId:e,retries:n})=>{const t=i(),s=o(),c=p()||void 0,d=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&d.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:l,json:a,zonosMode:m}=await u(`/api/zonos-elements/get-cart?${d.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:c,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),w=!a||l.length;return w&&n?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise((e=>setTimeout(e,500))),k({cartId:e,retries:n-1})):w?null:Object.assign(Object.assign({},a),{zonosMode:m})};var Z;const R=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),T=Date.now(),$="https://v1.4.1.js.zonos.com",A=R||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.1",L="https://fonts.googleapis.com",C=/^https:\/\/fonts\.googleapis\.com/;class U{}Z=U,U.doneInit=!1,U.cartSettings=null,U.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),U.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),U._paypalMockResponse=null,U.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,U.isBigCommerce=!1,U.releaseDate="1792428736539",U.isLegacyCheckout=!1,U.googleAnalyticId=null,U.googleAnalyticReady=!1,U.facebookPixelId=null,U.facebookPixelReady=!1,U.startLoadTime=T,U.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",U.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),U.overrideUseCustomAddressForm=!1,U.isCollect=!1,U.isInvoice=!1,U.isNpm=!0,U.zonosQaUrl=null,U.zonosQaUrlApi=null,U.trackEventLogs=[],U.version="v1.4.1",U.modeAlerted=!1,U.cartData=null,U.paypal=null,U.zonosMode=null,U.IframeService=t,U.getCurrentTimestamp=()=>(new Date).getTime(),U.zonosController=null,U.loadTimeApiInfoList=[],U.logIntervalId=null,U.init=async e=>{const{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d,storeId:a,zonosApiKey:p}=e;if(Z.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),Z.createCartId=null==o?void 0:o.createCartId,Z.buildCartDetail=null==o?void 0:o.buildCartDetail,Z.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${Z.version}) ======`),Z.zonosApiKey=p,Z.storeId=a,"undefined"!=typeof window&&window.parent===window&&(Z.googleAnalyticReady=!0,Z.facebookPixelReady=!0),Z.isNpm){r("====== ZONOS LOADING FROM NPM ======");const n=g();if(n&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${n} ======`,"info");const o=document.createElement("script");return o.src=`${n}/dist/scripts/zonos.js`,document.head.appendChild(o),o.addEventListener("load",(()=>{window.Zonos.isNpm=Z.isNpm,window.Zonos.isBigCommerce=Z.isBigCommerce,window.Zonos.isLegacyCheckout=Z.isLegacyCheckout,window.Zonos.zonosMode=Z.zonosMode,window.Zonos.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${n}`)})),void(window.isZonosPreview=!0)}if(!p&&!Z.cartId)return void m("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!Z.cartData&&Z.cartId){r("Initialize cart data");const e=await(async e=>{const{isDgsCartId:n,isLegacyCartId:o}=w(e);if(!o&&!n)return m("[ZONOS - loadZonos] invalid cart id"),null;const t=await k({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(m("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(Z.cartId);if(!e)return void m("Failed to get cart data");Z.cartData=e.cartData,Z.zonosApiKey=e.zonosApiKey,Z.cartSettings=e.settings}const o=await(async()=>{const e=i(),n=l();if(!e&&!n||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:o,json:t}=await u("/api/get-test-public-credential");if(o.length||!t)return m("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),null;const s=t.publicCredential;return s?(r(`[ZONOS - loadZonos] Retrieve new test public token ${s}`,"info"),s):(m("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();o&&(Z.zonosApiKey=o)}const y=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(Z.cartId&&Z.cartData||y){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id=`${f}`,document.body.appendChild(e)}r("init zonos"),Z.restoreNativeBrowserFunctions(),Z.injectCustomScriptForHostedCheckout(),Z.injectZonosCdn(),Z.injectZonosCss(),Z.injectFonts(),Z.injectCheckoutInternationalButton(),Z.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d}}),Z.doneInit=!0},U.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${y}`)){const e=document.createElement("button");e.id=y,e.style.display="none",document.body.appendChild(e)}},U.injectCustomScriptForHostedCheckout=()=>{const e=Z.cartData,n=(null==e?void 0:e.metadata)||[],o=n.find((e=>"customHeaderScript"===e.key)),t=n.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||t)){if(o){r("Injecting custom header script");const e=document.createElement("script");e.textContent=o.value,document.head.appendChild(e)}if(t){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=t.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},U.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},U.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${y}`);setTimeout((()=>{e&&e.dispatchEvent(n("click"))}),10)},U.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},U.showNotification=e=>{var n;null===(n=Z.zonosController)||void 0===n||n.showNotification(e)},U.updateOrganizationName=e=>{var n;null===(n=Z.zonosController)||void 0===n||n.updateOrganizationName(e)},U.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:o,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const n=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&o&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},U.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const n="zonos---native-browser";let o=document.querySelector(`iframe#${n}`);o||(o=document.createElement("iframe"),o.id=n,o.style.display="none",o.style.opacity="0",o.style.position="absolute",o.style.top="-9999px",o.style.left="-9999px",o.style.width="1px",o.style.height="1px",o.style.border="none",o.style.overflow="hidden",o.style.visibility="hidden",document.body.appendChild(o));const t=(null===(e=o.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=t,document.body.removeChild(o)},U.injectController=({config:e})=>{var n,o;if(document.querySelector("zonos-controller"))return;if(null===(n=e.checkoutSettings)||void 0===n?void 0:n.placeOrderButtonSelector){const n=e.checkoutSettings.placeOrderButtonSelector;Z.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{Z.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const n=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;Z.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{Z.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}const t=document.createElement("zonos-controller");t.config=e,t.zonosApiKey=Z.zonosApiKey||"",t.addEventListener("stripeInitEvent",(async e=>{const{detail:n}=e;r("loading Stripe");const o=await(async(...e)=>{var n;I=!0;const o=Date.now();return((e,n,o)=>{if(null===e)return null;const[t,s]=n,r=Object.assign({},s),i=(e=>{if(!("version"in e))return;const{version:n}=e;return"number"==typeof n||"string"==typeof n?n:void 0})(e);"string"==typeof i&&i!==3..toString()?delete r.apiVersion:r.apiVersion="2025-02-24.acacia";const c=e(t,r);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(c,o),c})(null!==(n=await N)&&void 0!==n?n:await b(null),e,o)})(n.publishableKey);o?(window.Zonos.stripe=o,window.Zonos.isCollect?t.initCollectElement(o):window.Zonos.isInvoice?t.initInvoiceElement(o):t.initCheckoutElement(o)):m("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(t),Z.zonosController=t,r("Zonos controller injected!")},U.injectScript=({cdnType:e,isModule:n,theRestUrl:o})=>{const t=`${Z.getZonosUrl(e)}/${o}`;if(document.querySelector(`script[src="${t}"]`))return void r(`Zonos script "${t}" already exists in the document`,"warn");const s=document.head||document.body,i=document.createElement("script");n?i.type="module":i.noModule=!0,i.src=t,i.crossOrigin="anonymous",i.onerror=()=>{m(`Failed to load ${i.src}`);const t=O(e);t&&Z.injectScript({cdnType:t,isModule:n,theRestUrl:o})},s.appendChild(i)},U.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return A;case"unpkg":return"https://unpkg.com/@zonos/elements@1.4.1";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.1";case"vercel":return $}};return Z.isNpm&&g()||n()},U.injectZonosCdn=()=>{Z.injectScript({cdnType:h,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),Z.injectScript({cdnType:h,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},U.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const o=Z.getZonosUrl(e),t=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${$}/`,t.appendChild(s);const r=document.createElement("link");r.rel="stylesheet",r.href=`${o}/${n}`,r.onerror=()=>{m(`Failed to load ${r.href}`);const o=O(e);o&&Z.injectStylesheet({cdnType:o,theRestUrl:n})},t.appendChild(r)},U.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(Z.injectStylesheet({cdnType:h,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},U.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!C.test(o.href))return o}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=L,e.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${L}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(o),r("Zonos font injected!")},U.setupGoogleFont=e=>{var n;null===(n=Z.zonosController)||void 0===n||n.setupGoogleFont(e)},U.injectSupportGoogleFont=e=>{var n;r(`[FONT] injecting ${e}`);const o=null===(n=e.match(/family=(.*?):/))||void 0===n?void 0:n[1],t=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${L}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=L,t.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,t.appendChild(s),r(`[FONT] ${o} font injected!`)};const E=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"],D=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"],P=[...E,...D];export{U as Zonos,f as checkoutHiddenBtnSelector,y as checkoutHiddenInternationalBtnSelector,P as checkoutSessionAttributeKeys,D as checkoutSessionImmutableAttributeKeys,E as checkoutSessionMutableAttributeKeys}
@@ -54,7 +54,7 @@ var n=new URL(e).searchParams;var t=n.get("zonosQaUrl");if(!t){return null}var r
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=O(window.location.href);var t="https://v1.4.0.js.zonos.com";
57
+ var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=O(window.location.href);var t="https://v1.4.1.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&&(t.includes("test.")||
60
60
  // Vercel git domain
@@ -62,7 +62,9 @@ t.includes("test-"))){return t}
62
62
  // when local demo app is running, it needs to use the local dev script unless the qaUrl is set
63
63
  if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!n){return null}
64
64
  // If the qaUrl, use the dev-elements domain to forward the request to the dev server to quickly debug the issue
65
- if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var r="preview.js.zonos.com";var i="https://".concat(n,".").concat(r);o("[ZONOS-WARNING] using '".concat(i,"' for loading elements script"),"warn");
65
+ if(n==="dev-elements"){return"https://dev.elements.zonos.com"}
66
+ // The worker alias selects the API host only. Scripts stay on the normal CDN.
67
+ if(n==="worker"){return null}var r="preview.js.zonos.com";var i="https://".concat(n,".").concat(r);o("[ZONOS-WARNING] using '".concat(i,"' for loading elements script"),"warn");
66
68
  // request to the url and check if the request has an error
67
69
  void fetch(i).then((function(){
68
70
  // cleanup checkout session to avoid using the prod session in preview domain
@@ -97,15 +99,15 @@ return[4/*yield*/,new Promise((function(e){return setTimeout(e,500)}))];case 2:
97
99
  e.sent();return[2/*return*/,F({cartId:w,retries:p-1})];case 3:if(m){return[2/*return*/,null]}return[2/*return*/,Object.assign(Object.assign({},f),{zonosMode:v})]}}))}))};var M=function(e){return __awaiter(v,void 0,void 0,(function(){var n,t,r,i;return __generator(this,(function(u){switch(u.label){case 0:n=d(e),t=n.isDgsCartId,r=n.isLegacyCartId;if(!r&&!t){s("[ZONOS - loadZonos] invalid cart id");return[2/*return*/,null]}return[4/*yield*/,F({cartId:e,retries:5})];case 1:i=u.sent();o("[ZONOS - loadZonos] getting temp cart data","info",i);if(!i){s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2/*return*/,null]}window.Zonos.storeId=i.cartData.storeId;window.Zonos.zonosApiKey=i.cartData.credentialToken;window.Zonos.zonosMode=i.zonosMode;return[2/*return*/,{cartData:i.cartData,settings:i.settings,storeFavicon:i.storeFaviconUrl,storeId:i.cartData.storeId,storeLogo:i.storeLogoUrl,zonosApiKey:i.cartData.credentialToken}]}}))}))};var x;
98
100
  /**
99
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
100
- */var B=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=m({loadScriptSrc:e===null||e===void 0?void 0:e.src}),t=n.currentLoadScriptUrl,r=n.isWhiteListed;if(r){return t}return null}();var G=Date.now();var K="https://v1.4.0.js.zonos.com";var V=B||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.0";var q="https://unpkg.com/@zonos/elements@1.4.0";var H="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.0";var W="https://fonts.googleapis.com";var Q=/^https:\/\/fonts\.googleapis\.com/;var Y=/** @class */function(){function e(){}return e}();e("Zonos",Y);x=Y;Y.doneInit=false;Y.cartSettings=null;
102
+ */var B=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=m({loadScriptSrc:e===null||e===void 0?void 0:e.src}),t=n.currentLoadScriptUrl,r=n.isWhiteListed;if(r){return t}return null}();var G=Date.now();var K="https://v1.4.1.js.zonos.com";var V=B||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.1";var q="https://unpkg.com/@zonos/elements@1.4.1";var H="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.1";var W="https://fonts.googleapis.com";var Q=/^https:\/\/fonts\.googleapis\.com/;var Y=/** @class */function(){function e(){}return e}();e("Zonos",Y);x=Y;Y.doneInit=false;Y.cartSettings=null;
101
103
  // if query 'zonosDebug=1' param from url, debug mode is on
102
- Y.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Y.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Y._paypalMockResponse=null;Y.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Y.isBigCommerce=false;Y.releaseDate="1792186375498";Y.isLegacyCheckout=false;Y.googleAnalyticId=null;Y.googleAnalyticReady=false;Y.facebookPixelId=null;Y.facebookPixelReady=false;Y.startLoadTime=G;Y.domain=typeof window!=="undefined"?// domain that embeds the iframe
104
+ Y.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Y.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Y._paypalMockResponse=null;Y.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Y.isBigCommerce=false;Y.releaseDate="1792428736539";Y.isLegacyCheckout=false;Y.googleAnalyticId=null;Y.googleAnalyticReady=false;Y.facebookPixelId=null;Y.facebookPixelReady=false;Y.startLoadTime=G;Y.domain=typeof window!=="undefined"?// domain that embeds the iframe
103
105
  window.location!=window.parent.location&&document.referrer||
104
106
  // current domain
105
107
  document.location.hostname:"";Y.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Y.overrideUseCustomAddressForm=false;Y.isCollect=false;Y.isInvoice=false;
106
108
  /**
107
109
  * By default, the package will load from npm
108
- */Y.isNpm=true;Y.zonosQaUrl=null;Y.zonosQaUrlApi=null;Y.trackEventLogs=[];Y.version="v".concat("1.4.0");Y.modeAlerted=false;Y.cartData=null;Y.paypal=null;Y.zonosMode=null;Y.IframeService=r;Y.getCurrentTimestamp=function(){return(new Date).getTime()};Y.zonosController=null;Y.loadTimeApiInfoList=[];Y.logIntervalId=null;Y.init=function(e){return __awaiter(v,void 0,void 0,(function(){var n,t,r,i,u,a,c,d,f,v,m,w,p,h,O;return __generator(this,(function(S){switch(S.label){case 0:n=e.appearance,t=e.checkoutSettings,r=e.currencyConverter,i=e.helloSettings,u=e.onCountryChange,a=e.overrideCurrencyFormat,c=e.storeId,d=e.zonosApiKey;x.cartId=D();
110
+ */Y.isNpm=true;Y.zonosQaUrl=null;Y.zonosQaUrlApi=null;Y.trackEventLogs=[];Y.version="v".concat("1.4.1");Y.modeAlerted=false;Y.cartData=null;Y.paypal=null;Y.zonosMode=null;Y.IframeService=r;Y.getCurrentTimestamp=function(){return(new Date).getTime()};Y.zonosController=null;Y.loadTimeApiInfoList=[];Y.logIntervalId=null;Y.init=function(e){return __awaiter(v,void 0,void 0,(function(){var n,t,r,i,u,a,c,d,f,v,m,w,p,h,O;return __generator(this,(function(S){switch(S.label){case 0:n=e.appearance,t=e.checkoutSettings,r=e.currencyConverter,i=e.helloSettings,u=e.onCountryChange,a=e.overrideCurrencyFormat,c=e.storeId,d=e.zonosApiKey;x.cartId=D();
109
111
  // Expose the checkout cart callbacks on the global so Stripe loading can be
110
112
  // gated on whether at least one of them is configured.
111
113
  x.createCartId=t===null||t===void 0?void 0:t.createCartId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zonos/elements",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Zonos component UI for Stripe elements",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.cjs.js",