@zonos/elements 1.3.169 → 1.3.170

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.
@@ -6,35 +6,6 @@ const handleFetch = require('./handleFetch-7b7f9f7c.js');
6
6
  const CheckoutConfig = require('./CheckoutConfig-f5e68e14.js');
7
7
  const TaxId = require('./TaxId-4632639d.js');
8
8
 
9
- let numberOfFailures = 0;
10
- const sendBulkLoadTimeApiLog = async () => {
11
- // Don't send the log if there are no API calls to send
12
- if (window.Zonos.loadTimeApiInfoList.length === 0) {
13
- return;
14
- }
15
- handleFetch.log('Sending bulk load time api log', 'info', {
16
- loadTimeApiInfoList: window.Zonos.loadTimeApiInfoList,
17
- });
18
- // Clone the list so we can clear it after sending the log
19
- const loadTimeApiInfoListArray = [...window.Zonos.loadTimeApiInfoList];
20
- // Clear the list after sending the log successfully
21
- window.Zonos.loadTimeApiInfoList.length = 0;
22
- // Clear the list after sending the log successfully
23
- const { errors } = await handleFetch.handleFetch('/api/zonos-elements/log-bulk-load', {
24
- body: loadTimeApiInfoListArray,
25
- method: 'POST',
26
- });
27
- if (errors.length) {
28
- // If there are errors, add the logs back to the list so we can try again later
29
- window.Zonos.loadTimeApiInfoList.push(...loadTimeApiInfoListArray);
30
- numberOfFailures++;
31
- if (numberOfFailures > 5 && window.Zonos.logIntervalId) {
32
- // If there are more than 3 failures, stop the interval
33
- clearInterval(window.Zonos.logIntervalId);
34
- }
35
- }
36
- };
37
-
38
9
  /**
39
10
  * Get the load version and url based on the loadScriptSrc and version
40
11
  * @returns
@@ -158,7 +129,7 @@ const getZonosQaUrl = () => {
158
129
  return null;
159
130
  }
160
131
  const qaUrl = extractZonosQaUrl(window.location.href);
161
- const cdnUrl = "https://v1.3.169.js.zonos.com";
132
+ const cdnUrl = "https://v1.3.170.js.zonos.com";
162
133
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
163
134
  if (!qaUrl &&
164
135
  (cdnUrl.includes('test.') ||
@@ -342,10 +313,10 @@ const zonosLoadUrl = (() => {
342
313
  }
343
314
  return null;
344
315
  })();
345
- const ZONOS_URL = "https://v1.3.169.js.zonos.com";
346
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.169";
347
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.169";
348
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.169";
316
+ const ZONOS_URL = "https://v1.3.170.js.zonos.com";
317
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.170";
318
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.170";
319
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.170";
349
320
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
350
321
  const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
351
322
  class Zonos {
@@ -359,7 +330,7 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
359
330
  !!window.location.search.match(/\?.*(&*)zonosConversionTest/);
360
331
  Zonos._paypalMockResponse = null;
361
332
  Zonos.isBigCommerce = false;
362
- Zonos.releaseDate = "1741966456733";
333
+ Zonos.releaseDate = "1741970849426";
363
334
  Zonos.isLegacyCheckout = false;
364
335
  Zonos.domain = typeof window !== 'undefined'
365
336
  ? // domain that embeds the iframe
@@ -375,7 +346,7 @@ Zonos.showBaseForeign = typeof window !== 'undefined' &&
375
346
  Zonos.isNpm = true;
376
347
  Zonos.zonosQaUrl = null;
377
348
  Zonos.zonosQaUrlApi = null;
378
- Zonos.version = `v${"1.3.169"}`;
349
+ Zonos.version = `v${"1.3.170"}`;
379
350
  Zonos.modeAlerted = false;
380
351
  Zonos.cartData = null;
381
352
  Zonos.paypal = null;
@@ -475,12 +446,6 @@ Zonos.init = async (params) => {
475
446
  },
476
447
  });
477
448
  _a.doneInit = true;
478
- if (!_a.logIntervalId) {
479
- // log the load time of all API calls every 2 seconds
480
- _a.logIntervalId = setInterval(() => {
481
- void sendBulkLoadTimeApiLog();
482
- }, 2000);
483
- }
484
449
  };
485
450
  Zonos.injectCustomScriptForHostedCheckout = () => {
486
451
  const cartData = _a.cartData;
@@ -184,6 +184,35 @@ const watchBigcommerceDomesticCheckout = ({ domesticRedirectedBtnSelector, onShi
184
184
  });
185
185
  };
186
186
 
187
+ let numberOfFailures = 0;
188
+ const sendBulkLoadTimeApiLog = async () => {
189
+ // Don't send the log if there are no API calls to send
190
+ if (window.Zonos.loadTimeApiInfoList.length === 0) {
191
+ return;
192
+ }
193
+ handleFetch.log('Sending bulk load time api log', 'info', {
194
+ loadTimeApiInfoList: window.Zonos.loadTimeApiInfoList,
195
+ });
196
+ // Clone the list so we can clear it after sending the log
197
+ const loadTimeApiInfoListArray = [...window.Zonos.loadTimeApiInfoList];
198
+ // Clear the list after sending the log successfully
199
+ window.Zonos.loadTimeApiInfoList.length = 0;
200
+ // Clear the list after sending the log successfully
201
+ const { errors } = await handleFetch.handleFetch('/api/zonos-elements/log-bulk-load', {
202
+ body: loadTimeApiInfoListArray,
203
+ method: 'POST',
204
+ });
205
+ if (errors.length) {
206
+ // If there are errors, add the logs back to the list so we can try again later
207
+ window.Zonos.loadTimeApiInfoList.push(...loadTimeApiInfoListArray);
208
+ numberOfFailures++;
209
+ if (numberOfFailures > 5 && window.Zonos.logIntervalId) {
210
+ // If there are more than 3 failures, stop the interval
211
+ clearInterval(window.Zonos.logIntervalId);
212
+ }
213
+ }
214
+ };
215
+
187
216
  const sendLoadCheckoutFacadeLog = async () => {
188
217
  const { elapsedTime } = handleFetch.getElapsedTime();
189
218
  const scriptLoadLogBody = {
@@ -616,6 +645,12 @@ const ZonosCheckout = class {
616
645
  });
617
646
  button.addEventListener('click', async (e) => {
618
647
  var _a;
648
+ if (!window.Zonos.logIntervalId) {
649
+ // log the load time of all API calls every 2 seconds. This is to track the load time of all API calls for checkout user
650
+ window.Zonos.logIntervalId = setInterval(() => {
651
+ void sendBulkLoadTimeApiLog();
652
+ }, 2000);
653
+ }
619
654
  // Start tracking load time
620
655
  const startTime = performance.now();
621
656
  // Allow no country set for legacy facades. Otherwise enforce it being a shippable country and not disabled.
@@ -24,6 +24,7 @@ import { isDarkColor } from "../../utils/isDarkColor";
24
24
  import { jsonParse } from "../../utils/jsonParse";
25
25
  import { allLogs, log } from "../../utils/logging/log";
26
26
  import { logError } from "../../utils/logging/logError";
27
+ import { sendBulkLoadTimeApiLog } from "../../utils/logging/sendBulkLoadTimeApiLog";
27
28
  import { sendErrorLog } from "../../utils/logging/sendErrorLog";
28
29
  import { sendLoadCheckoutFacadeLog } from "../../utils/logging/sendLoadCheckoutFacadeLog";
29
30
  import { sendLoadNativeCheckoutLog } from "../../utils/logging/sendLoadNativeCheckoutLog";
@@ -425,6 +426,12 @@ export class ZonosCheckout {
425
426
  });
426
427
  button.addEventListener('click', async (e) => {
427
428
  var _a;
429
+ if (!window.Zonos.logIntervalId) {
430
+ // log the load time of all API calls every 2 seconds. This is to track the load time of all API calls for checkout user
431
+ window.Zonos.logIntervalId = setInterval(() => {
432
+ void sendBulkLoadTimeApiLog();
433
+ }, 2000);
434
+ }
428
435
  // Start tracking load time
429
436
  const startTime = performance.now();
430
437
  // Allow no country set for legacy facades. Otherwise enforce it being a shippable country and not disabled.
@@ -1,7 +1,6 @@
1
1
  var _a;
2
2
  import { log } from "../components/utils/logging/log";
3
3
  import { logError } from "../components/utils/logging/logError";
4
- import { sendBulkLoadTimeApiLog } from "../components/utils/logging/sendBulkLoadTimeApiLog";
5
4
  import { checkIfLoadVersionDomain } from "./_checkIfLoadVersionDomain";
6
5
  import { getNextFallbackUrl, MAIN_LOAD_CDN_TYPE, } from "./_getNextFallbackUrl";
7
6
  import { getWithTestPublicCredential } from "./_getWithTestPublicCredential";
@@ -159,12 +158,6 @@ Zonos.init = async (params) => {
159
158
  },
160
159
  });
161
160
  _a.doneInit = true;
162
- if (!_a.logIntervalId) {
163
- // log the load time of all API calls every 2 seconds
164
- _a.logIntervalId = setInterval(() => {
165
- void sendBulkLoadTimeApiLog();
166
- }, 2000);
167
- }
168
161
  };
169
162
  Zonos.injectCustomScriptForHostedCheckout = () => {
170
163
  const cartData = _a.cartData;
package/dist/esm/index.js CHANGED
@@ -1,37 +1,8 @@
1
- import { l as log, h as handleFetch, g as getIsTestMode, a as getIsStagingMode, b as logError } from './handleFetch-8d72c8cd.js';
1
+ import { g as getIsTestMode, a as getIsStagingMode, l as log, h as handleFetch, b as logError } from './handleFetch-8d72c8cd.js';
2
2
  import { s as setupCartData, c as checkoutHiddenBtnSelector } from './CheckoutConfig-2994efd9.js';
3
3
  export { c as checkoutHiddenBtnSelector, d as domesticRedirectedBtnSelector } from './CheckoutConfig-2994efd9.js';
4
4
  export { c as countryRequireTaxId, s as shipToTaxIdLabels } from './TaxId-915ef042.js';
5
5
 
6
- let numberOfFailures = 0;
7
- const sendBulkLoadTimeApiLog = async () => {
8
- // Don't send the log if there are no API calls to send
9
- if (window.Zonos.loadTimeApiInfoList.length === 0) {
10
- return;
11
- }
12
- log('Sending bulk load time api log', 'info', {
13
- loadTimeApiInfoList: window.Zonos.loadTimeApiInfoList,
14
- });
15
- // Clone the list so we can clear it after sending the log
16
- const loadTimeApiInfoListArray = [...window.Zonos.loadTimeApiInfoList];
17
- // Clear the list after sending the log successfully
18
- window.Zonos.loadTimeApiInfoList.length = 0;
19
- // Clear the list after sending the log successfully
20
- const { errors } = await handleFetch('/api/zonos-elements/log-bulk-load', {
21
- body: loadTimeApiInfoListArray,
22
- method: 'POST',
23
- });
24
- if (errors.length) {
25
- // If there are errors, add the logs back to the list so we can try again later
26
- window.Zonos.loadTimeApiInfoList.push(...loadTimeApiInfoListArray);
27
- numberOfFailures++;
28
- if (numberOfFailures > 5 && window.Zonos.logIntervalId) {
29
- // If there are more than 3 failures, stop the interval
30
- clearInterval(window.Zonos.logIntervalId);
31
- }
32
- }
33
- };
34
-
35
6
  /**
36
7
  * Get the load version and url based on the loadScriptSrc and version
37
8
  * @returns
@@ -155,7 +126,7 @@ const getZonosQaUrl = () => {
155
126
  return null;
156
127
  }
157
128
  const qaUrl = extractZonosQaUrl(window.location.href);
158
- const cdnUrl = "https://v1.3.169.js.zonos.com";
129
+ const cdnUrl = "https://v1.3.170.js.zonos.com";
159
130
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
160
131
  if (!qaUrl &&
161
132
  (cdnUrl.includes('test.') ||
@@ -339,10 +310,10 @@ const zonosLoadUrl = (() => {
339
310
  }
340
311
  return null;
341
312
  })();
342
- const ZONOS_URL = "https://v1.3.169.js.zonos.com";
343
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.169";
344
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.169";
345
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.169";
313
+ const ZONOS_URL = "https://v1.3.170.js.zonos.com";
314
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.170";
315
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.170";
316
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.170";
346
317
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
347
318
  const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
348
319
  class Zonos {
@@ -356,7 +327,7 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
356
327
  !!window.location.search.match(/\?.*(&*)zonosConversionTest/);
357
328
  Zonos._paypalMockResponse = null;
358
329
  Zonos.isBigCommerce = false;
359
- Zonos.releaseDate = "1741966456733";
330
+ Zonos.releaseDate = "1741970849426";
360
331
  Zonos.isLegacyCheckout = false;
361
332
  Zonos.domain = typeof window !== 'undefined'
362
333
  ? // domain that embeds the iframe
@@ -372,7 +343,7 @@ Zonos.showBaseForeign = typeof window !== 'undefined' &&
372
343
  Zonos.isNpm = true;
373
344
  Zonos.zonosQaUrl = null;
374
345
  Zonos.zonosQaUrlApi = null;
375
- Zonos.version = `v${"1.3.169"}`;
346
+ Zonos.version = `v${"1.3.170"}`;
376
347
  Zonos.modeAlerted = false;
377
348
  Zonos.cartData = null;
378
349
  Zonos.paypal = null;
@@ -472,12 +443,6 @@ Zonos.init = async (params) => {
472
443
  },
473
444
  });
474
445
  _a.doneInit = true;
475
- if (!_a.logIntervalId) {
476
- // log the load time of all API calls every 2 seconds
477
- _a.logIntervalId = setInterval(() => {
478
- void sendBulkLoadTimeApiLog();
479
- }, 2000);
480
- }
481
446
  };
482
447
  Zonos.injectCustomScriptForHostedCheckout = () => {
483
448
  const cartData = _a.cartData;
@@ -180,6 +180,35 @@ const watchBigcommerceDomesticCheckout = ({ domesticRedirectedBtnSelector, onShi
180
180
  });
181
181
  };
182
182
 
183
+ let numberOfFailures = 0;
184
+ const sendBulkLoadTimeApiLog = async () => {
185
+ // Don't send the log if there are no API calls to send
186
+ if (window.Zonos.loadTimeApiInfoList.length === 0) {
187
+ return;
188
+ }
189
+ log('Sending bulk load time api log', 'info', {
190
+ loadTimeApiInfoList: window.Zonos.loadTimeApiInfoList,
191
+ });
192
+ // Clone the list so we can clear it after sending the log
193
+ const loadTimeApiInfoListArray = [...window.Zonos.loadTimeApiInfoList];
194
+ // Clear the list after sending the log successfully
195
+ window.Zonos.loadTimeApiInfoList.length = 0;
196
+ // Clear the list after sending the log successfully
197
+ const { errors } = await handleFetch('/api/zonos-elements/log-bulk-load', {
198
+ body: loadTimeApiInfoListArray,
199
+ method: 'POST',
200
+ });
201
+ if (errors.length) {
202
+ // If there are errors, add the logs back to the list so we can try again later
203
+ window.Zonos.loadTimeApiInfoList.push(...loadTimeApiInfoListArray);
204
+ numberOfFailures++;
205
+ if (numberOfFailures > 5 && window.Zonos.logIntervalId) {
206
+ // If there are more than 3 failures, stop the interval
207
+ clearInterval(window.Zonos.logIntervalId);
208
+ }
209
+ }
210
+ };
211
+
183
212
  const sendLoadCheckoutFacadeLog = async () => {
184
213
  const { elapsedTime } = getElapsedTime();
185
214
  const scriptLoadLogBody = {
@@ -612,6 +641,12 @@ const ZonosCheckout = class {
612
641
  });
613
642
  button.addEventListener('click', async (e) => {
614
643
  var _a;
644
+ if (!window.Zonos.logIntervalId) {
645
+ // log the load time of all API calls every 2 seconds. This is to track the load time of all API calls for checkout user
646
+ window.Zonos.logIntervalId = setInterval(() => {
647
+ void sendBulkLoadTimeApiLog();
648
+ }, 2000);
649
+ }
615
650
  // Start tracking load time
616
651
  const startTime = performance.now();
617
652
  // Allow no country set for legacy facades. Otherwise enforce it being a shippable country and not disabled.
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,n,o,r){function t(e){return e instanceof o?e:new o((function(n){n(e)}))}return new(o||(o=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r["throw"](e))}catch(e){i(e)}}function u(e){e.done?o(e.value):t(e.value).then(a,s)}u((r=r.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,t,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(n){return u([e,n])}}function u(s){if(r)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(o=0)),o)try{if(r=1,t&&(i=s[0]&2?t["return"]:s[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,s[1])).done)return i;if(t=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:o.label++;return{value:s[1],done:false};case 5:o.label++;t=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(s[0]===6&&o.label<i[1]){o.label=i[1];i=s;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(s);break}if(i[2])o.ops.pop();o.trys.pop();continue}s=n.call(e,o)}catch(e){s=[6,e];t=0}finally{r=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,o){if(o||arguments.length===2)for(var r=0,t=n.length,i;r<t;r++){if(i||!(r in n)){if(!i)i=Array.prototype.slice.call(n,0,r);i[r]=n[r]}}return e.concat(i||Array.prototype.slice.call(n))};import{l as log,h as handleFetch,g as getIsTestMode,a as getIsStagingMode,b as logError}from"./handleFetch-8d72c8cd.js";import{s as setupCartData,c as checkoutHiddenBtnSelector}from"./CheckoutConfig-2994efd9.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./CheckoutConfig-2994efd9.js";export{c as countryRequireTaxId,s as shipToTaxIdLabels}from"./TaxId-915ef042.js";var numberOfFailures=0;var sendBulkLoadTimeApiLog=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,n;var o;return __generator(this,(function(r){switch(r.label){case 0:if(window.Zonos.loadTimeApiInfoList.length===0){return[2]}log("Sending bulk load time api log","info",{loadTimeApiInfoList:window.Zonos.loadTimeApiInfoList});e=__spreadArray([],window.Zonos.loadTimeApiInfoList,true);window.Zonos.loadTimeApiInfoList.length=0;return[4,handleFetch("/api/zonos-elements/log-bulk-load",{body:e,method:"POST"})];case 1:n=r.sent().errors;if(n.length){(o=window.Zonos.loadTimeApiInfoList).push.apply(o,e);numberOfFailures++;if(numberOfFailures>5&&window.Zonos.logIntervalId){clearInterval(window.Zonos.logIntervalId)}}return[2]}}))}))};var checkIfLoadVersionDomain=function(e){var n=e.loadScriptSrc;if(!n){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var r=["qa.js.zonos.com"];var t=new URL(n).origin;var i=o.some((function(e){return t.includes(e)}));var a=r.some((function(e){return t.includes(e)}));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:a,isWhiteListed:i}};var fallbackList=["jsdelivr","cdnjs","unpkg","vercel"];var MAIN_LOAD_CDN_TYPE="jsdelivr";var getNextFallbackUrl=function(e){var n=fallbackList.indexOf(e);var o=fallbackList[n+1];return o||null};var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,n,o,r,t,i;return __generator(this,(function(a){switch(a.label){case 0:e=getIsTestMode();n=getIsStagingMode();if(!e&&!n||!window.Zonos.zonosApiKey){return[2,null]}log("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("credential_test")){log("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2,null]}return[4,handleFetch("/api/get-test-public-credential")];case 1:o=a.sent(),r=o.errors,t=o.json;if(r.length||!t){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r);return[2,null]}i=t.publicCredential;if(!i){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}log("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");return[2,i]}}))}))};var extractZonosQaUrl=function(e){if(!e){return null}var n=new URL(e).searchParams;var o=n.get("zonosQaUrl");if(!o){return null}var r=/[^a-zA-Z0-9-_]+/.test(o);if(!!r){return null}return o};var getZonosQaUrl=function(){var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=extractZonosQaUrl(window.location.href);var o="https://v1.3.169.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-"))){return o}if(!n&&["dev.demo.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!n){return null}if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var r="preview.js.zonos.com";var t="https://".concat(n,".").concat(r);log("[ZONOS-WARNING] using '".concat(t,"' for loading elements script"),"warn");void fetch(t).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(t,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var n=window.location.pathname;var o="".concat(n,"?").concat(e.toString());window.history.replaceState(window.history.state,"",o);window.location.reload();return null}));return t};var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var zonosStripeFindScript=function(){var e=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var n=0;n<e.length;n++){var o=e[n];if(!o){continue}if(!V3_URL_REGEX.test(o.src)){continue}return o}return null};var stripePromise$1=null;var injectScript=function(e){var n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"";var o=document.createElement("script");o.src="".concat(V3_URL).concat(n);var r=document.head||document.body;if(!r){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}r.appendChild(o);return o};var zonosStripeLoadScript=function(e){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(n,o){if(typeof window==="undefined"||typeof document==="undefined"){n(null);return}if(window.Stripe&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){n(window.Stripe);return}try{var r=zonosStripeFindScript();if(r&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!r){r=injectScript(e)}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){n(window.Stripe)}else{o(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){o(new Error("Failed to load Stripe.js"))}))}catch(e){o(e);return}}));return stripePromise$1};var registerWrapper=function(e,n){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:n})};var initStripe=function(e,n,o){if(e===null){return null}var r=e.apply(undefined,n);registerWrapper(r,o);return r};var stripePromise=Promise.resolve().then((function(){return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(e){if(!loadCalled){console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(void 0,void 0,void 0,(function(){var n;return __generator(this,(function(o){loadCalled=true;n=Date.now();return[2,stripePromise.then((function(o){return initStripe(o,e,n)}))]}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var n=e.get(TEMP_CART_ID_QUERY_PARAM);return n};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=checkIfLoadVersionDomain({loadScriptSrc:e===null||e===void 0?void 0:e.src}),o=n.currentLoadScriptUrl,r=n.isWhiteListed;if(r){return o}return null}();var ZONOS_URL="https://v1.3.169.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.169";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.3.169";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.169";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.isBigCommerce=false;Zonos.releaseDate="1741966456733";Zonos.isLegacyCheckout=false;Zonos.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.version="v".concat("1.3.169");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.loadTimeApiInfoList=[];Zonos.logIntervalId=null;Zonos.init=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,r,t,i,a,s,u,c,l,d,f,v,m,p;return __generator(this,(function(_){switch(_.label){case 0:n=e.appearance,o=e.checkoutSettings,r=e.currencyConverter,t=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,u=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=u;_a.storeId=s;if(!_a.isNpm)return[3,4];log("====== ZONOS LOADING FROM NPM ======");c=getZonosQaUrl();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;void window.Zonos.init(e)}));l.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(c))}));window.isZonosPreview=true;return[2]}if(!u&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!_a.cartData&&_a.cartId))return[3,2];log("Initialize cart data");return[4,setupCartData(_a.cartId)];case 1:d=_.sent();if(!d){logError("Failed to get cart data");return[2]}_a.cartData=d.cartData;_a.zonosApiKey=d.zonosApiKey;_.label=2;case 2:return[4,getWithTestPublicCredential()];case 3:f=_.sent();if(f){_a.zonosApiKey=f}_.label=4;case 4:v=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");m=_a.cartId&&_a.cartData||!!v;if(m){log("Cart data or stripe client secret is available, inject hidden button and trigger checkout");p=document.createElement("button");p.style.display="none";p.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(p)}log("init zonos");_a.restoreNativeBrowserFunctions();_a.injectCustomScriptForHostedCheckout();_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:r,helloSettings:t,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;if(!_a.logIntervalId){_a.logIntervalId=setInterval((function(){void sendBulkLoadTimeApiLog()}),2e3)}return[2]}}))}))};Zonos.injectCustomScriptForHostedCheckout=function(){var e=_a.cartData;var n=(e===null||e===void 0?void 0:e.metadata)||[];var o=n.find((function(e){return e.key==="customHeaderScript"}));var r=n.find((function(e){return e.key==="customFooterScript"}));if(!window.Zonos.isLegacyCheckout||!o&&!r){log("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(o){log("Injecting custom header script");var t=document.createElement("script");t.textContent=o.value;document.head.appendChild(t)}if(r){log("Injecting custom footer script");var t=document.createElement("script");t.textContent=r.value;document.body.appendChild(t)}};Zonos.displayCurrency=function(){var e=document.querySelector("zonos-hello");if(e){void e.displayCurrency()}};Zonos.openHelloDialog=function(e){var n=document.querySelector("zonos-hello");if(n){void n.openHelloDialog(e!==null&&e!==void 0?e:true)}};Zonos.showNotification=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.showNotification(e))};Zonos.updateOrganizationName=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.updateOrganizationName(e))};Zonos.disablePlaceOrderButtons=function(e){var n=e.autoEnable,o=n===void 0?true:n,r=e.config,t=e.disable,i=e.placeOrderButtonSelector;var a;if((a=r.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var u=function(e){var n=e.target;if(n.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};s.forEach((function(e){var n=e.getAttribute("data-zonos-checkout-attached");if(n){return}if(t){e.setAttribute("disabled","true");e.addEventListener("click",u)}else{e.removeAttribute("disabled");e.removeEventListener("click",u)}}));if(o&&t){setTimeout((function(){s.forEach((function(e){e.removeAttribute("disabled");e.removeEventListener("click",u)}))}),5e3)}}};Zonos.restoreNativeBrowserFunctions=function(){var e;var n=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(n){return}var o="zonos---native-browser";var r=document.querySelector("iframe#".concat(o));if(!r){r=document.createElement("iframe");r.id=o;r.style.display="none";r.style.opacity="0";r.style.position="absolute";r.style.top="-9999px";r.style.left="-9999px";r.style.width="1px";r.style.height="1px";r.style.border="none";r.style.overflow="hidden";r.style.visibility="hidden";document.body.appendChild(r)}var t=((e=r.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=t;document.body.removeChild(r)};Zonos.injectController=function(e){var n=e.config;var o;if(document.querySelector("zonos-controller")){return}if((o=n.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var r=n.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r});var t=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:r})}));t.observe(document.body,{childList:true,subtree:true})}var i=document.createElement("zonos-controller");i.config=n;i.zonosApiKey=_a.zonosApiKey||"";i.addEventListener("stripeInitEvent",(function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o;return __generator(this,(function(r){switch(r.label){case 0:n=e.detail;log("loading Stripe");return[4,zonosLoadStripe(n.publishableKey)];case 1:o=r.sent();if(!o){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;void i.initCheckoutElement(o);return[2]}}))}))}));document.body.appendChild(i);_a.zonosController=i;log("Zonos controller injected!")};Zonos.injectScript=function(e){var n=e.cdnType,o=e.isModule,r=e.theRestUrl;var t=_a.getZonosUrl(n);var i="".concat(t,"/").concat(r);var a=function(){var e=document.querySelector('script[src="'.concat(i,'"]'));return!!e};if(a()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var s=document.head||document.body;var u=document.createElement("script");if(!!o){u.type="module"}else{u.noModule=true}u.src=i;u.crossOrigin="anonymous";u.onerror=function(){logError("Failed to load ".concat(u.src));var e=getNextFallbackUrl(n);if(!e){return}_a.injectScript({cdnType:e,isModule:o,theRestUrl:r})};s.appendChild(u)};Zonos.getZonosUrl=function(e){var n=function(){switch(e){case"jsdelivr":return JS_DELIVR_ZONOS_URL;case"unpkg":return UNPKG_ZONOS_URL;case"cdnjs":return CDNJS_ZONOS_URL;case"vercel":return ZONOS_URL}};if(_a.isNpm){var o=getZonosQaUrl();return o||n()}return n()};Zonos.injectZonosCdn=function(){_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(e){var n=e.cdnType,o=e.theRestUrl;var r=_a.getZonosUrl(n);var t=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");t.appendChild(i);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(r,"/").concat(o);a.onerror=function(){logError("Failed to load ".concat(a.href));var e=getNextFallbackUrl(n);if(!e){return}_a.injectStylesheet({cdnType:e,theRestUrl:o})};t.appendChild(a)};Zonos.injectZonosCss=function(){var e=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(e()){log("Zonos style links already injected","warn");return}_a.injectStylesheet({cdnType:MAIN_LOAD_CDN_TYPE,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var e=function(){var e=document.fonts.check("1em Inter");if(e){log("Inter font already loaded","warn");return}var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(GOOGLE_FONT_URL,'"]'));for(var o=0;o<n.length;o++){var r=n[o];if(!r){continue}if(GOOGLE_FONT_REGEX.test(r.href)){continue}return r}return null};if(e()){log("Inter font already injected","warn");return}var n=document.head||document.body;var o=document.createElement("link");o.rel="preconnect";o.href=GOOGLE_FONT_URL;n.appendChild(o);var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(GOOGLE_FONT_URL,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");n.appendChild(r);log("Zonos font injected!")};Zonos.setupGoogleFont=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.setupGoogleFont(e))};Zonos.injectSupportGoogleFont=function(e){var n;log("[FONT] injecting ".concat(e));var o=(n=e.match(/family=(.*?):/))===null||n===void 0?void 0:n[1];var r=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var t=document.createElement("link");t.rel="preconnect";t.href=GOOGLE_FONT_URL;r.appendChild(t)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){log("[FONT] ".concat(o," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;r.appendChild(i);log("[FONT] ".concat(o," font injected!"))};export{Zonos};
1
+ var __awaiter=this&&this.__awaiter||function(e,n,o,t){function r(e){return e instanceof o?e:new o((function(n){n(e)}))}return new(o||(o=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function s(e){try{c(t["throw"](e))}catch(e){i(e)}}function c(e){e.done?o(e.value):r(e.value).then(a,s)}c((t=t.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,r,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(n){return c([e,n])}}function c(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(o=0)),o)try{if(t=1,r&&(i=s[0]&2?r["return"]:s[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;if(r=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:o.label++;return{value:s[1],done:false};case 5:o.label++;r=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(s[0]===6&&o.label<i[1]){o.label=i[1];i=s;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(s);break}if(i[2])o.ops.pop();o.trys.pop();continue}s=n.call(e,o)}catch(e){s=[6,e];r=0}finally{t=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{g as getIsTestMode,a as getIsStagingMode,l as log,h as handleFetch,b as logError}from"./handleFetch-8d72c8cd.js";import{s as setupCartData,c as checkoutHiddenBtnSelector}from"./CheckoutConfig-2994efd9.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./CheckoutConfig-2994efd9.js";export{c as countryRequireTaxId,s as shipToTaxIdLabels}from"./TaxId-915ef042.js";var checkIfLoadVersionDomain=function(e){var n=e.loadScriptSrc;if(!n){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"];var t=["qa.js.zonos.com"];var r=new URL(n).origin;var i=o.some((function(e){return r.includes(e)}));var a=t.some((function(e){return r.includes(e)}));return{currentLoadScriptUrl:r,isForceLoadVersionDomain:a,isWhiteListed:i}};var fallbackList=["jsdelivr","cdnjs","unpkg","vercel"];var MAIN_LOAD_CDN_TYPE="jsdelivr";var getNextFallbackUrl=function(e){var n=fallbackList.indexOf(e);var o=fallbackList[n+1];return o||null};var getWithTestPublicCredential=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,n,o,t,r,i;return __generator(this,(function(a){switch(a.label){case 0:e=getIsTestMode();n=getIsStagingMode();if(!e&&!n||!window.Zonos.zonosApiKey){return[2,null]}log("[ZONOS - loadZonos] Attempt test public credential","info");if(!!window.Zonos.zonosApiKey.includes("credential_test")){log("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2,null]}return[4,handleFetch("/api/get-test-public-credential")];case 1:o=a.sent(),t=o.errors,r=o.json;if(t.length||!r){logError("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t);return[2,null]}i=r.publicCredential;if(!i){logError("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2,null]}log("[ZONOS - loadZonos] Retrieve new test public token ".concat(i),"info");return[2,i]}}))}))};var extractZonosQaUrl=function(e){if(!e){return null}var n=new URL(e).searchParams;var o=n.get("zonosQaUrl");if(!o){return null}var t=/[^a-zA-Z0-9-_]+/.test(o);if(!!t){return null}return o};var getZonosQaUrl=function(){var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=extractZonosQaUrl(window.location.href);var o="https://v1.3.170.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-"))){return o}if(!n&&["dev.demo.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!n){return null}if(n==="dev-elements"){return"https://dev.elements.zonos.com"}var t="preview.js.zonos.com";var r="https://".concat(n,".").concat(t);log("[ZONOS-WARNING] using '".concat(r,"' for loading elements script"),"warn");void fetch(r).then((function(){window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(r,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));var e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var n=window.location.pathname;var o="".concat(n,"?").concat(e.toString());window.history.replaceState(window.history.state,"",o);window.location.reload();return null}));return r};var V3_URL="https://js.stripe.com/v3";var V3_URL_REGEX=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var EXISTING_SCRIPT_MESSAGE="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var zonosStripeFindScript=function(){var e=document.querySelectorAll('script[src^="'.concat(V3_URL,'"]'));for(var n=0;n<e.length;n++){var o=e[n];if(!o){continue}if(!V3_URL_REGEX.test(o.src)){continue}return o}return null};var stripePromise$1=null;var injectScript=function(e){var n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"";var o=document.createElement("script");o.src="".concat(V3_URL).concat(n);var t=document.head||document.body;if(!t){logError("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}t.appendChild(o);return o};var zonosStripeLoadScript=function(e){if(stripePromise$1!==null){return stripePromise$1}stripePromise$1=new Promise((function(n,o){if(typeof window==="undefined"||typeof document==="undefined"){n(null);return}if(window.Stripe&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}if(window.Stripe){n(window.Stripe);return}try{var t=zonosStripeFindScript();if(t&&e){console.warn(EXISTING_SCRIPT_MESSAGE)}else if(!t){t=injectScript(e)}t===null||t===void 0?void 0:t.addEventListener("load",(function(){if(window.Stripe){n(window.Stripe)}else{o(new Error("Stripe.js not available"))}}));t===null||t===void 0?void 0:t.addEventListener("error",(function(){o(new Error("Failed to load Stripe.js"))}))}catch(e){o(e);return}}));return stripePromise$1};var registerWrapper=function(e,n){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:n})};var initStripe=function(e,n,o){if(e===null){return null}var t=e.apply(undefined,n);registerWrapper(t,o);return t};var stripePromise=Promise.resolve().then((function(){return zonosStripeLoadScript(null)}));var loadCalled=false;stripePromise.catch((function(e){if(!loadCalled){console.warn(e)}}));var zonosLoadStripe=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(void 0,void 0,void 0,(function(){var n;return __generator(this,(function(o){loadCalled=true;n=Date.now();return[2,stripePromise.then((function(o){return initStripe(o,e,n)}))]}))}))};var TEMP_CART_ID_QUERY_PARAM="tempCartUUID";var getCartIdFromQueryParam=function(){var e=new URLSearchParams(window.location.search);var n=e.get(TEMP_CART_ID_QUERY_PARAM);return n};var _a;var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=checkIfLoadVersionDomain({loadScriptSrc:e===null||e===void 0?void 0:e.src}),o=n.currentLoadScriptUrl,t=n.isWhiteListed;if(t){return o}return null}();var ZONOS_URL="https://v1.3.170.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.170";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.3.170";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.170";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.isBigCommerce=false;Zonos.releaseDate="1741970849426";Zonos.isLegacyCheckout=false;Zonos.domain=typeof window!=="undefined"?window.location!=window.parent.location&&document.referrer||document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.version="v".concat("1.3.170");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.loadTimeApiInfoList=[];Zonos.logIntervalId=null;Zonos.init=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r,i,a,s,c,u,l,d,f,v,m,p;return __generator(this,(function(_){switch(_.label){case 0:n=e.appearance,o=e.checkoutSettings,t=e.currencyConverter,r=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,c=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();if(_a.doneInit){return[2]}log("====== ZONOS DEBUG MODE: on (".concat(_a.version,") ======"));_a.zonosApiKey=c;_a.storeId=s;if(!_a.isNpm)return[3,4];log("====== ZONOS LOADING FROM NPM ======");u=getZonosQaUrl();if(u&&!window.isZonosPreview){log('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(u," ======"),"info");l=document.createElement("script");l.src="".concat(u,"/dist/scripts/zonos.js");document.head.appendChild(l);l.addEventListener("load",(function(){window.Zonos.isNpm=_a.isNpm;window.Zonos.isBigCommerce=_a.isBigCommerce;window.Zonos.isLegacyCheckout=_a.isLegacyCheckout;void window.Zonos.init(e)}));l.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(u))}));window.isZonosPreview=true;return[2]}if(!c&&!_a.cartId){logError("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2]}if(!(!_a.cartData&&_a.cartId))return[3,2];log("Initialize cart data");return[4,setupCartData(_a.cartId)];case 1:d=_.sent();if(!d){logError("Failed to get cart data");return[2]}_a.cartData=d.cartData;_a.zonosApiKey=d.zonosApiKey;_.label=2;case 2:return[4,getWithTestPublicCredential()];case 3:f=_.sent();if(f){_a.zonosApiKey=f}_.label=4;case 4:v=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");m=_a.cartId&&_a.cartData||!!v;if(m){log("Cart data or stripe client secret is available, inject hidden button and trigger checkout");p=document.createElement("button");p.style.display="none";p.id="".concat(checkoutHiddenBtnSelector);document.body.appendChild(p)}log("init zonos");_a.restoreNativeBrowserFunctions();_a.injectCustomScriptForHostedCheckout();_a.injectZonosCdn();_a.injectZonosCss();_a.injectFonts();_a.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:r,onCountryChange:i,overrideCurrencyFormat:a}});_a.doneInit=true;return[2]}}))}))};Zonos.injectCustomScriptForHostedCheckout=function(){var e=_a.cartData;var n=(e===null||e===void 0?void 0:e.metadata)||[];var o=n.find((function(e){return e.key==="customHeaderScript"}));var t=n.find((function(e){return e.key==="customFooterScript"}));if(!window.Zonos.isLegacyCheckout||!o&&!t){log("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(o){log("Injecting custom header script");var r=document.createElement("script");r.textContent=o.value;document.head.appendChild(r)}if(t){log("Injecting custom footer script");var r=document.createElement("script");r.textContent=t.value;document.body.appendChild(r)}};Zonos.displayCurrency=function(){var e=document.querySelector("zonos-hello");if(e){void e.displayCurrency()}};Zonos.openHelloDialog=function(e){var n=document.querySelector("zonos-hello");if(n){void n.openHelloDialog(e!==null&&e!==void 0?e:true)}};Zonos.showNotification=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.showNotification(e))};Zonos.updateOrganizationName=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.updateOrganizationName(e))};Zonos.disablePlaceOrderButtons=function(e){var n=e.autoEnable,o=n===void 0?true:n,t=e.config,r=e.disable,i=e.placeOrderButtonSelector;var a;if((a=t.checkoutSettings)===null||a===void 0?void 0:a.disablePlaceOrderButtonActivation){return}if(i){var s=document.querySelectorAll(i);var c=function(e){var n=e.target;if(n.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};s.forEach((function(e){var n=e.getAttribute("data-zonos-checkout-attached");if(n){return}if(r){e.setAttribute("disabled","true");e.addEventListener("click",c)}else{e.removeAttribute("disabled");e.removeEventListener("click",c)}}));if(o&&r){setTimeout((function(){s.forEach((function(e){e.removeAttribute("disabled");e.removeEventListener("click",c)}))}),5e3)}}};Zonos.restoreNativeBrowserFunctions=function(){var e;var n=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(n){return}var o="zonos---native-browser";var t=document.querySelector("iframe#".concat(o));if(!t){t=document.createElement("iframe");t.id=o;t.style.display="none";t.style.opacity="0";t.style.position="absolute";t.style.top="-9999px";t.style.left="-9999px";t.style.width="1px";t.style.height="1px";t.style.border="none";t.style.overflow="hidden";t.style.visibility="hidden";document.body.appendChild(t)}var r=((e=t.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=r;document.body.removeChild(t)};Zonos.injectController=function(e){var n=e.config;var o;if(document.querySelector("zonos-controller")){return}if((o=n.checkoutSettings)===null||o===void 0?void 0:o.placeOrderButtonSelector){var t=n.checkoutSettings.placeOrderButtonSelector;_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:t});var r=new MutationObserver((function(){_a.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:t})}));r.observe(document.body,{childList:true,subtree:true})}var i=document.createElement("zonos-controller");i.config=n;i.zonosApiKey=_a.zonosApiKey||"";i.addEventListener("stripeInitEvent",(function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o;return __generator(this,(function(t){switch(t.label){case 0:n=e.detail;log("loading Stripe");return[4,zonosLoadStripe(n.publishableKey)];case 1:o=t.sent();if(!o){logError("API seems to be invalid or missing. Failed to load Stripe");return[2]}window.Zonos.stripe=o;void i.initCheckoutElement(o);return[2]}}))}))}));document.body.appendChild(i);_a.zonosController=i;log("Zonos controller injected!")};Zonos.injectScript=function(e){var n=e.cdnType,o=e.isModule,t=e.theRestUrl;var r=_a.getZonosUrl(n);var i="".concat(r,"/").concat(t);var a=function(){var e=document.querySelector('script[src="'.concat(i,'"]'));return!!e};if(a()){log('Zonos script "'.concat(i,'" already exists in the document'),"warn");return}var s=document.head||document.body;var c=document.createElement("script");if(!!o){c.type="module"}else{c.noModule=true}c.src=i;c.crossOrigin="anonymous";c.onerror=function(){logError("Failed to load ".concat(c.src));var e=getNextFallbackUrl(n);if(!e){return}_a.injectScript({cdnType:e,isModule:o,theRestUrl:t})};s.appendChild(c)};Zonos.getZonosUrl=function(e){var n=function(){switch(e){case"jsdelivr":return JS_DELIVR_ZONOS_URL;case"unpkg":return UNPKG_ZONOS_URL;case"cdnjs":return CDNJS_ZONOS_URL;case"vercel":return ZONOS_URL}};if(_a.isNpm){var o=getZonosQaUrl();return o||n()}return n()};Zonos.injectZonosCdn=function(){_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});_a.injectScript({cdnType:MAIN_LOAD_CDN_TYPE,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});log("Zonos cdn script injected!")};Zonos.injectStylesheet=function(e){var n=e.cdnType,o=e.theRestUrl;var t=_a.getZonosUrl(n);var r=document.head||document.body;var i=document.createElement("link");i.rel="preconnect";i.href="".concat(ZONOS_URL,"/");r.appendChild(i);var a=document.createElement("link");a.rel="stylesheet";a.href="".concat(t,"/").concat(o);a.onerror=function(){logError("Failed to load ".concat(a.href));var e=getNextFallbackUrl(n);if(!e){return}_a.injectStylesheet({cdnType:e,theRestUrl:o})};r.appendChild(a)};Zonos.injectZonosCss=function(){var e=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(e()){log("Zonos style links already injected","warn");return}_a.injectStylesheet({cdnType:MAIN_LOAD_CDN_TYPE,theRestUrl:"dist/zonos-elements/zonos-elements.css"});log("Zonos style css injected!")};Zonos.injectFonts=function(){var e=function(){var e=document.fonts.check("1em Inter");if(e){log("Inter font already loaded","warn");return}var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(GOOGLE_FONT_URL,'"]'));for(var o=0;o<n.length;o++){var t=n[o];if(!t){continue}if(GOOGLE_FONT_REGEX.test(t.href)){continue}return t}return null};if(e()){log("Inter font already injected","warn");return}var n=document.head||document.body;var o=document.createElement("link");o.rel="preconnect";o.href=GOOGLE_FONT_URL;n.appendChild(o);var t=document.createElement("link");t.rel="stylesheet";t.href="".concat(GOOGLE_FONT_URL,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");n.appendChild(t);log("Zonos font injected!")};Zonos.setupGoogleFont=function(e){var n;void((n=_a.zonosController)===null||n===void 0?void 0:n.setupGoogleFont(e))};Zonos.injectSupportGoogleFont=function(e){var n;log("[FONT] injecting ".concat(e));var o=(n=e.match(/family=(.*?):/))===null||n===void 0?void 0:n[1];var t=document.head||document.body;if(!document.querySelector('link[rel="preconnect"][href^="'.concat(GOOGLE_FONT_URL,'"]'))){var r=document.createElement("link");r.rel="preconnect";r.href=GOOGLE_FONT_URL;t.appendChild(r)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){log("[FONT] ".concat(o," font already injected"),"warn");return}var i=document.createElement("link");i.rel="stylesheet";i.href=e;t.appendChild(i);log("[FONT] ".concat(o," font injected!"))};export{Zonos};