@zonos/elements 1.3.92 → 1.3.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/cjs/{CheckoutConfig-850071ae.js → CheckoutConfig-8e8a0d1c.js} +1 -1
  2. package/dist/cjs/{cart-d456e0b8.js → cart-9d0ced11.js} +13 -4
  3. package/dist/cjs/{createCustomEvent-94c259c7.js → createCustomEvent-f6317809.js} +2 -2
  4. package/dist/cjs/{handleFetch-45e76490.js → handleFetch-5a16f2bc.js} +1 -1
  5. package/dist/cjs/index.cjs.js +9 -9
  6. package/dist/cjs/loader.cjs.js +1 -1
  7. package/dist/cjs/{paypal-5c5f8d32.js → paypal-a6ddcfaf.js} +2 -2
  8. package/dist/cjs/zonos-address_7.cjs.entry.js +2 -2
  9. package/dist/cjs/zonos-badge.cjs.entry.js +1 -1
  10. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +50 -32
  11. package/dist/cjs/zonos-checkout.cjs.entry.js +42 -39
  12. package/dist/cjs/zonos-controller.cjs.entry.js +2 -2
  13. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
  14. package/dist/cjs/zonos-country-select_4.cjs.entry.js +2 -2
  15. package/dist/cjs/zonos-elements.cjs.js +1 -1
  16. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
  17. package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
  18. package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
  19. package/dist/cjs/zonos-notification_3.cjs.entry.js +3 -3
  20. package/dist/collection/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.js +6 -2
  21. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +37 -34
  22. package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +42 -27
  23. package/dist/collection/components/common/zonos-badge/zonos-badge.js +1 -1
  24. package/dist/collection/components/store/checkout/cart.js +6 -1
  25. package/dist/collection/components/store/checkout/stripe.js +6 -2
  26. package/dist/collection/components/utils/logging/log.js +1 -1
  27. package/dist/esm/{CheckoutConfig-c0ec120d.js → CheckoutConfig-c54d23b8.js} +1 -1
  28. package/dist/esm/{cart-1083aa3b.js → cart-ef2e2eec.js} +13 -4
  29. package/dist/esm/{createCustomEvent-a45228e7.js → createCustomEvent-73760da0.js} +2 -2
  30. package/dist/esm/{handleFetch-0133265e.js → handleFetch-ce924688.js} +1 -1
  31. package/dist/esm/index.js +10 -10
  32. package/dist/esm/loader.js +1 -1
  33. package/dist/esm/{paypal-a2399ed3.js → paypal-cce03d02.js} +2 -2
  34. package/dist/esm/zonos-address_7.entry.js +2 -2
  35. package/dist/esm/zonos-badge.entry.js +1 -1
  36. package/dist/esm/zonos-cart-items_12.entry.js +50 -32
  37. package/dist/esm/zonos-checkout.entry.js +42 -39
  38. package/dist/esm/zonos-controller.entry.js +2 -2
  39. package/dist/esm/zonos-country-flag.entry.js +2 -2
  40. package/dist/esm/zonos-country-select_4.entry.js +2 -2
  41. package/dist/esm/zonos-elements.js +1 -1
  42. package/dist/esm/zonos-hello-dialog.entry.js +2 -2
  43. package/dist/esm/zonos-hello.entry.js +2 -2
  44. package/dist/esm/zonos-language-select_2.entry.js +2 -2
  45. package/dist/esm/zonos-notification_3.entry.js +3 -3
  46. package/dist/esm-es5/{CheckoutConfig-c0ec120d.js → CheckoutConfig-c54d23b8.js} +1 -1
  47. package/dist/esm-es5/{cart-1083aa3b.js → cart-ef2e2eec.js} +1 -1
  48. package/dist/esm-es5/createCustomEvent-73760da0.js +1 -0
  49. package/dist/esm-es5/index.js +1 -1
  50. package/dist/esm-es5/loader.js +1 -1
  51. package/dist/esm-es5/{paypal-a2399ed3.js → paypal-cce03d02.js} +1 -1
  52. package/dist/esm-es5/zonos-address_7.entry.js +1 -1
  53. package/dist/esm-es5/zonos-badge.entry.js +1 -1
  54. package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
  55. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  56. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  57. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  58. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  59. package/dist/esm-es5/zonos-elements.js +1 -1
  60. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  61. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  62. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  63. package/dist/esm-es5/zonos-notification_3.entry.js +1 -1
  64. package/dist/scripts/index.js +1 -1
  65. package/dist/scripts/loadZonos.js +1 -1
  66. package/dist/scripts/zonos.js +1 -1
  67. package/dist/types/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.d.ts +3 -0
  68. package/dist/zonos-elements/index.esm.js +1 -1
  69. package/dist/zonos-elements/{p-95b4ea5e.js → p-021c2035.js} +1 -1
  70. package/dist/zonos-elements/p-05172564.entry.js +1 -0
  71. package/dist/zonos-elements/p-0523da29.entry.js +1 -0
  72. package/dist/zonos-elements/{p-340408f2.system.entry.js → p-205d1fd0.system.entry.js} +1 -1
  73. package/dist/zonos-elements/{p-1a92ff9a.system.entry.js → p-207b73ad.system.entry.js} +1 -1
  74. package/dist/zonos-elements/{p-dbe8a5de.entry.js → p-3242242f.entry.js} +1 -1
  75. package/dist/zonos-elements/{p-8aad6abd.system.js → p-332ccd38.system.js} +1 -1
  76. package/dist/zonos-elements/{p-f13738a1.entry.js → p-36050826.entry.js} +1 -1
  77. package/dist/zonos-elements/p-40528519.system.entry.js +1 -0
  78. package/dist/zonos-elements/{p-ba0aef88.system.entry.js → p-517444c0.system.entry.js} +1 -1
  79. package/dist/zonos-elements/p-52542b33.system.js +1 -0
  80. package/dist/zonos-elements/{p-7995965e.entry.js → p-52b7a342.entry.js} +1 -1
  81. package/dist/zonos-elements/{p-3d6a7efd.entry.js → p-55534ab4.entry.js} +1 -1
  82. package/dist/zonos-elements/{p-1560ee37.entry.js → p-6037f297.entry.js} +1 -1
  83. package/dist/zonos-elements/{p-57aa09e7.system.js → p-606e0443.system.js} +1 -1
  84. package/dist/zonos-elements/p-609209fe.entry.js +1 -0
  85. package/dist/zonos-elements/{p-e8c3387c.system.entry.js → p-61c43b0c.system.entry.js} +1 -1
  86. package/dist/zonos-elements/{p-362bd7de.js → p-7141699d.js} +1 -1
  87. package/dist/zonos-elements/{p-d8a3b001.system.entry.js → p-832535b5.system.entry.js} +1 -1
  88. package/dist/zonos-elements/{p-b8e85bf5.js → p-9a13b43f.js} +1 -1
  89. package/dist/zonos-elements/{p-b53f9c25.system.js → p-a6aea068.system.js} +1 -1
  90. package/dist/zonos-elements/{p-8e4348e9.entry.js → p-a8fb9ec4.entry.js} +1 -1
  91. package/dist/zonos-elements/{p-4e3d23ad.system.entry.js → p-a92ea268.system.entry.js} +1 -1
  92. package/dist/zonos-elements/{p-8dc1342e.js → p-ad8b87ec.js} +1 -1
  93. package/dist/zonos-elements/{p-c39c3ed6.entry.js → p-c6950e78.entry.js} +1 -1
  94. package/dist/zonos-elements/{p-52fdf52d.system.entry.js → p-c6f848d6.system.entry.js} +1 -1
  95. package/dist/zonos-elements/p-c78dd680.system.js +1 -1
  96. package/dist/zonos-elements/{p-cf28a962.entry.js → p-c990f553.entry.js} +1 -1
  97. package/dist/zonos-elements/{p-1f1aaf73.system.entry.js → p-d42d729b.system.entry.js} +1 -1
  98. package/dist/zonos-elements/{p-460cc134.system.entry.js → p-d8c3540c.system.entry.js} +1 -1
  99. package/dist/zonos-elements/{p-ded2ae47.system.entry.js → p-dbc57aea.system.entry.js} +1 -1
  100. package/dist/zonos-elements/{p-4854c65b.system.js → p-e3432dca.system.js} +1 -1
  101. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  102. package/package.json +1 -1
  103. package/dist/esm-es5/createCustomEvent-a45228e7.js +0 -1
  104. package/dist/zonos-elements/p-2d2ff962.entry.js +0 -1
  105. package/dist/zonos-elements/p-403b3460.entry.js +0 -1
  106. package/dist/zonos-elements/p-8c0ff373.system.js +0 -1
  107. package/dist/zonos-elements/p-e9ee2062.entry.js +0 -1
  108. package/dist/zonos-elements/p-ed276123.system.entry.js +0 -1
  109. /package/dist/esm-es5/{handleFetch-0133265e.js → handleFetch-ce924688.js} +0 -0
  110. /package/dist/zonos-elements/{p-197c5707.system.js → p-480556ea.system.js} +0 -0
  111. /package/dist/zonos-elements/{p-ad7ce197.js → p-539cc913.js} +0 -0
@@ -1 +1 @@
1
- (function(){"use strict";const e=performance.now(),t=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},o=(o,n,...r)=>{var s,i;const l=performance.now()-e,a=[`(${l>1e3?`${(l/1e3).toFixed(2)}s`:`${l.toFixed(2)}ms`})`,...r];a.map(t).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===n&&console.error(o,...a));let c=document.querySelector("iframe#zonos---debug-logging-iframe");c||(c=document.createElement("iframe"),c.id="zonos---debug-logging-iframe",c.style.display="none",c.style.opacity="0",c.style.position="absolute",c.style.top="-9999px",c.style.left="-9999px",c.style.width="1px",c.style.height="1px",c.style.border="none",c.style.overflow="hidden",c.style.visibility="hidden",document.body.appendChild(c));const d=(null===(i=c.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(o,...a);break;case"info":d.info(o,...a);break;case"error":d.error(o,...a);break;default:d.groupCollapsed(o,...a),d.trace(),d.groupEnd()}},n=(e,...t)=>{o(e,"error",...t)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const t=r.indexOf(e);return r[t+1]||null},l=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const t=(e=>{if(!e)return null;const t=new URL(e).searchParams.get("zonosQaUrl");return t?/[^a-zA-Z0-9-_]+/.test(t)?null:t:null})(window.location.href),n="https://v1.3.92.js.zonos.com";if(!t&&(n.includes("test.")||n.includes("test-")))return n;if(!t&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!t)return null;if("dev-elements"===t)return"https://dev.elements.zonos.com";const r=`https://${t}.preview.js.zonos.com`;return o(`[ZONOS-WARNING] using '${r}' for loading elements script`,"warn"),fetch(r).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${r}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:t}=window.location,o=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),r},a="https://js.stripe.com/v3",c=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,d="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let u=null;const p=e=>(null!==u||(u=new Promise(((t,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(d),window.Stripe)t(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${a}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&c.test(o.src))return o}return null})();r&&e?console.warn(d):r||(r=(e=>{const t=document.createElement("script");t.src=`${a}`;const o=document.head||document.body;return o?(o.appendChild(t),t):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?t(window.Stripe):o(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else t(null)}))),u),m=Promise.resolve().then((()=>p(null)));let h=!1;m.catch((e=>{h||console.warn(e)}));function y(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}"function"==typeof SuppressedError&&SuppressedError;const w=["cloudflare","vercel"],f=w[0],g={cloudflare:"https://route.elements.zonos.com",vercel:"https://v1.route.js.zonos.com"},v=g[f],b=(e=f)=>{const t=w.indexOf(e),o=w[t+1];return o||null},S=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},z=async({response:e,shouldLog:t=!0,shouldThrow:o=!1})=>{try{return await e.json()}catch(e){if(o)throw e;return t&&console.error(e),null}},j=async({basePathType:e,options:t,path:o})=>{let n;const r=window.Zonos.zonosQaUrlApi||g[e]||f,s=new URL(r+o);s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(t){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(window.location.hostname));try{n=await fetch(s.toString(),t)}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 i=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&i&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await z({response:n}),response:n,zonosMode:i}}const a=n.status.toString();try{const e=await z({response:n,shouldThrow:!0});return{baseUrl:r,errors:[{message:JSON.stringify(e),type:a}],json:null,response:n,zonosMode:i}}catch(e){return{baseUrl:r,errors:[{message:`${a}: ${"Unknown error"}`,type:a}],json:null,response:null,zonosMode:i}}},O=async({basePathType:e,options:t,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,l=await j({basePathType:i,options:t,path:n}),{errors:a,response:c}=l,d=y(l,["errors","response"]),u=b(i),p=!!a.find((({type:e})=>"unknown"===e))||404===(null==c?void 0:c.status),m=u&&p;return p&&(async({endpoint:e,errors:t,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(o("sendErrorLog","warn",e,n,t),r){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:t,metadata:Object.assign({href:window.location.href,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${v}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const t=b();if(!t)return;fetch(`${g[t]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:g[i]+n,errors:a.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:u,requestHeaders:null==t?void 0:t.headers,requestPayload:S(null===(r=null==t?void 0:t.body)||void 0===r?void 0:r.toString())||(null===(s=null==t?void 0:t.body)||void 0===s?void 0:s.toString()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),m?(o(`=== "${n}" failed to fetch, trying next fallback ${u}`),O({basePathType:u,options:t,path:n})):Object.assign({errors:a,response:c},d)},C=async e=>{const{errors:t,json:n}=await(async(e,t)=>{const n=y(t||{},[]),r=n.body?JSON.stringify(n.body):void 0,s=n.method||"GET",i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers),l=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),a=new URLSearchParams(window.location.search).get("useFallbackApi");return o(e,"info"),O({basePathType:a||f,options:l,path:e})})("/api/zonos-elements/get-temp-cart",{body:{tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"});return!n||t.length?null:n};var k;const E=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:t,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const t=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=>t.includes(e))),n=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:n,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?t:null})(),A="https://v1.3.92.js.zonos.com",U=E||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.92",Z="https://rsms.me",T="https://fonts.googleapis.com",$=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class N{}k=N,N.doneInit=!1,N.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),N.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),N._paypalMockResponse=null,N.isBigCommerce=!1,N.releaseDate="1728934669160",N.isLegacyCheckout=!1,N.isNpm=!0,N.zonosQaUrl=null,N.zonosQaUrlApi=null,N.version="v1.3.92",N.modeAlerted=!1,N.cartData=null,N.paypal=null,N.getCurrentTimestamp=()=>(new Date).getTime(),N.zonosController=null,N.init=async({appearance:e,checkoutSettings:t,currencyConverter:r,helloSettings:s,onCountryChange:i,overrideCurrencyFormat:l,storeId:a,zonosApiKey:c})=>{if(k.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!k.doneInit){if(o(`====== ZONOS DEBUG MODE: on (${k.version}) ======`),k.zonosApiKey=c,k.storeId=a,k.isNpm){if(o("====== ZONOS LOADING FROM NPM ======"),!c&&!k.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!k.cartData&&k.cartId){o("Initialize cart data");const e=await(async e=>{const t=await C(e);return o("[ZONOS - loadZonos] getting temp cart data","info",t),t?{cartData:t.cartData,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}:(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(k.cartId);if(!e)return void n("Failed to get cart data");k.cartData=e.cartData,k.zonosApiKey=e.zonosApiKey}}if(k.cartId&&k.cartData){o("Cart data 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)}o("init zonos"),k.injectZonosCdn(),k.injectZonosCss(),k.injectFonts(),k.injectController({config:{appearance:e,checkoutSettings:t,currencyConverter:r,helloSettings:s,onCountryChange:i,overrideCurrencyFormat:l}}),k.doneInit=!0}},N.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},N.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},N.showNotification=e=>{var t;null===(t=k.zonosController)||void 0===t||t.showNotification(e)},N.updateOrganizationName=e=>{var t;null===(t=k.zonosController)||void 0===t||t.updateOrganizationName(e)},N.disablePlaceOrderButtons=({autoEnable:e=!0,config:t,disable:o,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=t.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const t=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};t.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&o&&setTimeout((()=>{t.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},N.injectController=({config:e})=>{var t;if(document.querySelector("zonos-controller"))return;if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.placeOrderButtonSelector){const t=e.checkoutSettings.placeOrderButtonSelector;k.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t});new MutationObserver((()=>{k.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=k.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:t}=e;o("loading Stripe");const s=await(async(...e)=>{h=!0;const t=Date.now();return m.then((o=>((e,t,o)=>{if(null===e)return null;const n=e.apply(void 0,t);return((e,t)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:t})})(n,o),n})(o,e,t)))})(t.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),k.zonosController=r,o("Zonos controller injected!")},N.injectScript=({cdnType:e,isModule:t,theRestUrl:r})=>{const s=`${k.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void o(`Zonos script "${s}" already exists in the document`,"warn");const l=document.head||document.body,a=document.createElement("script");t?a.type="module":a.noModule=!0,a.src=s,a.crossOrigin="anonymous",a.onerror=()=>{n(`Failed to load ${a.src}`);const o=i(e);o&&k.injectScript({cdnType:o,isModule:t,theRestUrl:r})},l.appendChild(a)},N.getZonosUrl=e=>{const t=()=>{switch(e){case"jsdelivr":return U;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.92";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.92";case"vercel":return A}};if(k.isNpm){return l()||t()}return t()},N.injectZonosCdn=()=>{k.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),k.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),o("Zonos cdn script injected!")},N.injectStylesheet=({cdnType:e,theRestUrl:t})=>{const o=k.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${A}/`,r.appendChild(s);const l=document.createElement("link");l.rel="stylesheet",l.href=`${o}/${t}`,l.onerror=()=>{n(`Failed to load ${l.href}`);const o=i(e);o&&k.injectStylesheet({cdnType:o,theRestUrl:t})},r.appendChild(l)},N.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?o("Zonos style links already injected","warn"):(k.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),o("Zonos style css injected!"))},N.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${Z}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&!$.test(o.href))return o}return null})())return void o("Inter font already injected","warn");const e=document.head||document.body,t=document.createElement("link");t.rel="preconnect",t.href=Z,e.appendChild(t);const n=document.createElement("link");n.rel="stylesheet",n.href=`${Z}/inter/inter.css`,e.appendChild(n),o("Zonos font injected!")},N.setupGoogleFont=e=>{var t;null===(t=k.zonosController)||void 0===t||t.setupGoogleFont(e)},N.injectSupportGoogleFont=e=>{var t;o(`[FONT] injecting ${e}`);const n=null===(t=e.match(/family=(.*?):/))||void 0===t?void 0:t[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${T}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=T,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void o(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),o(`[FONT] ${n} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=N)})();
1
+ (function(){"use strict";const e=performance.now(),t=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},o=(o,n,...r)=>{var s,i;const l=performance.now()-e,a=[`(${l>1e3?`${(l/1e3).toFixed(2)}s`:`${l.toFixed(2)}ms`})`,...r];a.map(t).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===n&&console.error(o,...a));let c=document.querySelector("iframe#zonos---debug-logging-iframe");c||(c=document.createElement("iframe"),c.id="zonos---debug-logging-iframe",c.style.display="none",c.style.opacity="0",c.style.position="absolute",c.style.top="-9999px",c.style.left="-9999px",c.style.width="1px",c.style.height="1px",c.style.border="none",c.style.overflow="hidden",c.style.visibility="hidden",document.body.appendChild(c));const d=(null===(i=c.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(o,...a);break;case"info":d.info(o,...a);break;case"error":d.error(o,...a);break;default:d.groupCollapsed(o,...a),d.trace(),d.groupEnd()}},n=(e,...t)=>{o(e,"error",...t)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const t=r.indexOf(e);return r[t+1]||null},l=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const t=(e=>{if(!e)return null;const t=new URL(e).searchParams.get("zonosQaUrl");return t?/[^a-zA-Z0-9-_]+/.test(t)?null:t:null})(window.location.href),n="https://v1.3.94.js.zonos.com";if(!t&&(n.includes("test.")||n.includes("test-")))return n;if(!t&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!t)return null;if("dev-elements"===t)return"https://dev.elements.zonos.com";const r=`https://${t}.preview.js.zonos.com`;return o(`[ZONOS-WARNING] using '${r}' for loading elements script`,"warn"),fetch(r).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${r}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:t}=window.location,o=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),r},a="https://js.stripe.com/v3",c=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,d="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let u=null;const p=e=>(null!==u||(u=new Promise(((t,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(d),window.Stripe)t(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${a}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&c.test(o.src))return o}return null})();r&&e?console.warn(d):r||(r=(e=>{const t=document.createElement("script");t.src=`${a}`;const o=document.head||document.body;return o?(o.appendChild(t),t):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?t(window.Stripe):o(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else t(null)}))),u),m=Promise.resolve().then((()=>p(null)));let h=!1;m.catch((e=>{h||console.warn(e)}));function y(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}"function"==typeof SuppressedError&&SuppressedError;const w=["cloudflare","vercel"],f=w[0],g={cloudflare:"https://route.elements.zonos.com",vercel:"https://v1.route.js.zonos.com"},v=g[f],b=(e=f)=>{const t=w.indexOf(e),o=w[t+1];return o||null},S=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},z=async({response:e,shouldLog:t=!0,shouldThrow:o=!1})=>{try{return await e.json()}catch(e){if(o)throw e;return t&&console.error(e),null}},j=async({basePathType:e,options:t,path:o})=>{let n;const r=window.Zonos.zonosQaUrlApi||g[e]||f,s=new URL(r+o);s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(t){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(window.location.hostname));try{n=await fetch(s.toString(),t)}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 i=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&i&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await z({response:n}),response:n,zonosMode:i}}const a=n.status.toString();try{const e=await z({response:n,shouldThrow:!0});return{baseUrl:r,errors:[{message:JSON.stringify(e),type:a}],json:null,response:n,zonosMode:i}}catch(e){return{baseUrl:r,errors:[{message:`${a}: ${"Unknown error"}`,type:a}],json:null,response:null,zonosMode:i}}},O=async({basePathType:e,options:t,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,l=await j({basePathType:i,options:t,path:n}),{errors:a,response:c}=l,d=y(l,["errors","response"]),u=b(i),p=!!a.find((({type:e})=>"unknown"===e))||404===(null==c?void 0:c.status),m=u&&p;return p&&(async({endpoint:e,errors:t,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(o("sendErrorLog","warn",e,n,t),r){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:t,metadata:Object.assign({href:window.location.href,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${v}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const t=b();if(!t)return;fetch(`${g[t]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:g[i]+n,errors:a.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:u,requestHeaders:null==t?void 0:t.headers,requestPayload:S(null===(r=null==t?void 0:t.body)||void 0===r?void 0:r.toString())||(null===(s=null==t?void 0:t.body)||void 0===s?void 0:s.toString()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),m?(o(`=== "${n}" failed to fetch, trying next fallback ${u}`),O({basePathType:u,options:t,path:n})):Object.assign({errors:a,response:c},d)},C=async e=>{const{errors:t,json:n}=await(async(e,t)=>{const n=y(t||{},[]),r=n.body?JSON.stringify(n.body):void 0,s=n.method||"GET",i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers),l=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),a=new URLSearchParams(window.location.search).get("useFallbackApi");return o(e,"info"),O({basePathType:a||f,options:l,path:e})})("/api/zonos-elements/get-temp-cart",{body:{tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"});return!n||t.length?null:n};var k;const E=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:t,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const t=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=>t.includes(e))),n=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:n,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?t:null})(),A="https://v1.3.94.js.zonos.com",U=E||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.94",Z="https://rsms.me",T="https://fonts.googleapis.com",$=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class N{}k=N,N.doneInit=!1,N.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),N.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),N._paypalMockResponse=null,N.isBigCommerce=!1,N.releaseDate="1729004765406",N.isLegacyCheckout=!1,N.isNpm=!0,N.zonosQaUrl=null,N.zonosQaUrlApi=null,N.version="v1.3.94",N.modeAlerted=!1,N.cartData=null,N.paypal=null,N.getCurrentTimestamp=()=>(new Date).getTime(),N.zonosController=null,N.init=async({appearance:e,checkoutSettings:t,currencyConverter:r,helloSettings:s,onCountryChange:i,overrideCurrencyFormat:l,storeId:a,zonosApiKey:c})=>{if(k.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!k.doneInit){if(o(`====== ZONOS DEBUG MODE: on (${k.version}) ======`),k.zonosApiKey=c,k.storeId=a,k.isNpm){if(o("====== ZONOS LOADING FROM NPM ======"),!c&&!k.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!k.cartData&&k.cartId){o("Initialize cart data");const e=await(async e=>{const t=await C(e);return o("[ZONOS - loadZonos] getting temp cart data","info",t),t?{cartData:t.cartData,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}:(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(k.cartId);if(!e)return void n("Failed to get cart data");k.cartData=e.cartData,k.zonosApiKey=e.zonosApiKey}}if(k.cartId&&k.cartData){o("Cart data 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)}o("init zonos"),k.injectZonosCdn(),k.injectZonosCss(),k.injectFonts(),k.injectController({config:{appearance:e,checkoutSettings:t,currencyConverter:r,helloSettings:s,onCountryChange:i,overrideCurrencyFormat:l}}),k.doneInit=!0}},N.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},N.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},N.showNotification=e=>{var t;null===(t=k.zonosController)||void 0===t||t.showNotification(e)},N.updateOrganizationName=e=>{var t;null===(t=k.zonosController)||void 0===t||t.updateOrganizationName(e)},N.disablePlaceOrderButtons=({autoEnable:e=!0,config:t,disable:o,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=t.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const t=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};t.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&o&&setTimeout((()=>{t.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},N.injectController=({config:e})=>{var t;if(document.querySelector("zonos-controller"))return;if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.placeOrderButtonSelector){const t=e.checkoutSettings.placeOrderButtonSelector;k.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t});new MutationObserver((()=>{k.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=k.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:t}=e;o("loading Stripe");const s=await(async(...e)=>{h=!0;const t=Date.now();return m.then((o=>((e,t,o)=>{if(null===e)return null;const n=e.apply(void 0,t);return((e,t)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:t})})(n,o),n})(o,e,t)))})(t.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),k.zonosController=r,o("Zonos controller injected!")},N.injectScript=({cdnType:e,isModule:t,theRestUrl:r})=>{const s=`${k.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void o(`Zonos script "${s}" already exists in the document`,"warn");const l=document.head||document.body,a=document.createElement("script");t?a.type="module":a.noModule=!0,a.src=s,a.crossOrigin="anonymous",a.onerror=()=>{n(`Failed to load ${a.src}`);const o=i(e);o&&k.injectScript({cdnType:o,isModule:t,theRestUrl:r})},l.appendChild(a)},N.getZonosUrl=e=>{const t=()=>{switch(e){case"jsdelivr":return U;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.94";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.94";case"vercel":return A}};if(k.isNpm){return l()||t()}return t()},N.injectZonosCdn=()=>{k.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),k.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),o("Zonos cdn script injected!")},N.injectStylesheet=({cdnType:e,theRestUrl:t})=>{const o=k.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${A}/`,r.appendChild(s);const l=document.createElement("link");l.rel="stylesheet",l.href=`${o}/${t}`,l.onerror=()=>{n(`Failed to load ${l.href}`);const o=i(e);o&&k.injectStylesheet({cdnType:o,theRestUrl:t})},r.appendChild(l)},N.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?o("Zonos style links already injected","warn"):(k.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),o("Zonos style css injected!"))},N.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${Z}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&!$.test(o.href))return o}return null})())return void o("Inter font already injected","warn");const e=document.head||document.body,t=document.createElement("link");t.rel="preconnect",t.href=Z,e.appendChild(t);const n=document.createElement("link");n.rel="stylesheet",n.href=`${Z}/inter/inter.css`,e.appendChild(n),o("Zonos font injected!")},N.setupGoogleFont=e=>{var t;null===(t=k.zonosController)||void 0===t||t.setupGoogleFont(e)},N.injectSupportGoogleFont=e=>{var t;o(`[FONT] injecting ${e}`);const n=null===(t=e.match(/family=(.*?):/))||void 0===t?void 0:t[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${T}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=T,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void o(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),o(`[FONT] ${n} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=N)})();
@@ -31,14 +31,17 @@ export declare class ZonosShipping {
31
31
  serviceLevelsDDP: ShippingRichRadioItem[];
32
32
  serviceLevelsDAP: ShippingRichRadioItem[];
33
33
  serviceLevelsOther: ShippingRichRadioItem[];
34
+ serviceLevelsAll: ShippingRichRadioItem[];
34
35
  private handleRadioSelected;
35
36
  private handleValidate;
37
+ private isOutdatedShippingData;
36
38
  /**
37
39
  * handler for continue button click
38
40
  */
39
41
  private continueClickHandler;
40
42
  private getLandedCostMethodLabelSuffix;
41
43
  private initServiceLevels;
44
+ private preselectFirstShippingMethod;
42
45
  componentWillLoad(): void;
43
46
  render(): any;
44
47
  }
@@ -1 +1 @@
1
- import{l as e,a as n}from"./p-ad7ce197.js";import{s as t,c as o}from"./p-b8e85bf5.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./p-b8e85bf5.js";const s=["jsdelivr","cdnjs","unpkg","vercel"],r="jsdelivr",i=e=>{const n=s.indexOf(e);return s[n+1]||null},l="https://js.stripe.com/v3",u=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,a="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let m=null;const p=Promise.resolve().then((()=>{return e=null,null!==m||(m=new Promise(((t,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(a),window.Stripe)t(window.Stripe);else try{let s=(()=>{const e=document.querySelectorAll(`script[src^="${l}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&u.test(t.src))return t}return null})();s&&e?console.warn(a):s||(s=(e=>{const t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${l}${t}`;const s=document.head||document.body;return s?(s.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==s||s.addEventListener("load",(()=>{window.Stripe?t(window.Stripe):o(new Error("Stripe.js not available"))})),null==s||s.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else t(null)}))),m;var e}));let w=!1;var f;p.catch((e=>{w||console.warn(e)}));const h=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=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=>n.includes(e))),o=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:o,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?n:null})(),v="https://v1.3.92.js.zonos.com",y=h||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.92",z="https://rsms.me",j="https://fonts.googleapis.com",S=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class g{}f=g,g.doneInit=!1,g.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),g.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),g._paypalMockResponse=null,g.isBigCommerce=!1,g.releaseDate="1728934623320",g.isLegacyCheckout=!1,g.isNpm=!0,g.zonosQaUrl=null,g.zonosQaUrlApi=null,g.version="v1.3.92",g.modeAlerted=!1,g.cartData=null,g.paypal=null,g.getCurrentTimestamp=()=>(new Date).getTime(),g.zonosController=null,g.init=async({appearance:s,checkoutSettings:r,currencyConverter:i,helloSettings:c,onCountryChange:l,overrideCurrencyFormat:d,storeId:u,zonosApiKey:a})=>{if(f.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!f.doneInit){if(e(`====== ZONOS DEBUG MODE: on (${f.version}) ======`),f.zonosApiKey=a,f.storeId=u,f.isNpm){if(e("====== ZONOS LOADING FROM NPM ======"),!a&&!f.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!f.cartData&&f.cartId){e("Initialize cart data");const o=await t(f.cartId);if(!o)return void n("Failed to get cart data");f.cartData=o.cartData,f.zonosApiKey=o.zonosApiKey}}if(f.cartId&&f.cartData){e("Cart data is available, inject hidden button and trigger checkout");const n=document.createElement("button");n.style.display="none",n.id=`${o}`,document.body.appendChild(n)}e("init zonos"),f.injectZonosCdn(),f.injectZonosCss(),f.injectFonts(),f.injectController({config:{appearance:s,checkoutSettings:r,currencyConverter:i,helloSettings:c,onCountryChange:l,overrideCurrencyFormat:d}}),f.doneInit=!0}},g.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},g.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},g.showNotification=e=>{var n;null===(n=f.zonosController)||void 0===n||n.showNotification(e)},g.updateOrganizationName=e=>{var n;null===(n=f.zonosController)||void 0===n||n.updateOrganizationName(e)},g.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:t,placeOrderButtonSelector:o})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&o){const n=document.querySelectorAll(o),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&t&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},g.injectController=({config:t})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=t.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const e=t.checkoutSettings.placeOrderButtonSelector;f.disablePlaceOrderButtons({config:t,disable:!0,placeOrderButtonSelector:e}),new MutationObserver((()=>{f.disablePlaceOrderButtons({config:t,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=t,s.zonosApiKey=f.zonosApiKey||"",s.addEventListener("stripeInitEvent",(async t=>{const{detail:o}=t;e("loading Stripe");const r=await(async(...e)=>{w=!0;const n=Date.now();return p.then((t=>((e,n,t)=>{if(null===e)return null;const o=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(o,t),o})(t,e,n)))})(o.publishableKey);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),f.zonosController=s,e("Zonos controller injected!")},g.injectScript=({cdnType:t,isModule:o,theRestUrl:s})=>{const r=`${f.getZonosUrl(t)}/${s}`;if(document.querySelector(`script[src="${r}"]`))return void e(`Zonos script "${r}" already exists in the document`,"warn");const c=document.head||document.body,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=r,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const e=i(t);e&&f.injectScript({cdnType:e,isModule:o,theRestUrl:s})},c.appendChild(l)},g.getZonosUrl=n=>{const t=()=>{switch(n){case"jsdelivr":return y;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.92";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.92";case"vercel":return v}};return f.isNpm&&(()=>{const n=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||n)return null;const t=(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.3.92.js.zonos.com";if(!t&&(o.includes("test.")||o.includes("test-")))return o;if(!t&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!t)return null;if("dev-elements"===t)return"https://dev.elements.zonos.com";const s=`https://${t}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${s}' for loading elements script`,"warn"),fetch(s).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${s}' 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,t=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),s})()||t()},g.injectZonosCdn=()=>{f.injectScript({cdnType:r,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),f.injectScript({cdnType:r,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},g.injectStylesheet=({cdnType:e,theRestUrl:t})=>{const o=f.getZonosUrl(e),s=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${v}/`,s.appendChild(r);const c=document.createElement("link");c.rel="stylesheet",c.href=`${o}/${t}`,c.onerror=()=>{n(`Failed to load ${c.href}`);const o=i(e);o&&f.injectStylesheet({cdnType:o,theRestUrl:t})},s.appendChild(c)},g.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(f.injectStylesheet({cdnType:r,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},g.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${z}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&!S.test(t.href))return t}return null})())return void e("Inter font already injected","warn");const n=document.head||document.body,t=document.createElement("link");t.rel="preconnect",t.href=z,n.appendChild(t);const o=document.createElement("link");o.rel="stylesheet",o.href=`${z}/inter/inter.css`,n.appendChild(o),e("Zonos font injected!")},g.setupGoogleFont=e=>{var n;null===(n=f.zonosController)||void 0===n||n.setupGoogleFont(e)},g.injectSupportGoogleFont=n=>{var t;e(`[FONT] injecting ${n}`);const o=null===(t=n.match(/family=(.*?):/))||void 0===t?void 0:t[1],s=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${j}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=j,s.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return void e(`[FONT] ${o} font already injected`,"warn");const r=document.createElement("link");r.rel="stylesheet",r.href=n,s.appendChild(r),e(`[FONT] ${o} font injected!`)};export{g as Zonos}
1
+ import{l as e,a as n}from"./p-539cc913.js";import{s as t,c as o}from"./p-9a13b43f.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./p-9a13b43f.js";const s=["jsdelivr","cdnjs","unpkg","vercel"],r="jsdelivr",i=e=>{const n=s.indexOf(e);return s[n+1]||null},l="https://js.stripe.com/v3",u=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,a="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let m=null;const p=Promise.resolve().then((()=>{return e=null,null!==m||(m=new Promise(((t,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(a),window.Stripe)t(window.Stripe);else try{let s=(()=>{const e=document.querySelectorAll(`script[src^="${l}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&u.test(t.src))return t}return null})();s&&e?console.warn(a):s||(s=(e=>{const t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${l}${t}`;const s=document.head||document.body;return s?(s.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==s||s.addEventListener("load",(()=>{window.Stripe?t(window.Stripe):o(new Error("Stripe.js not available"))})),null==s||s.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else t(null)}))),m;var e}));let w=!1;var f;p.catch((e=>{w||console.warn(e)}));const h=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=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=>n.includes(e))),o=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:o,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?n:null})(),v="https://v1.3.94.js.zonos.com",y=h||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.94",z="https://rsms.me",j="https://fonts.googleapis.com",S=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class g{}f=g,g.doneInit=!1,g.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),g.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),g._paypalMockResponse=null,g.isBigCommerce=!1,g.releaseDate="1729004720094",g.isLegacyCheckout=!1,g.isNpm=!0,g.zonosQaUrl=null,g.zonosQaUrlApi=null,g.version="v1.3.94",g.modeAlerted=!1,g.cartData=null,g.paypal=null,g.getCurrentTimestamp=()=>(new Date).getTime(),g.zonosController=null,g.init=async({appearance:s,checkoutSettings:r,currencyConverter:i,helloSettings:c,onCountryChange:l,overrideCurrencyFormat:d,storeId:u,zonosApiKey:a})=>{if(f.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!f.doneInit){if(e(`====== ZONOS DEBUG MODE: on (${f.version}) ======`),f.zonosApiKey=a,f.storeId=u,f.isNpm){if(e("====== ZONOS LOADING FROM NPM ======"),!a&&!f.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!f.cartData&&f.cartId){e("Initialize cart data");const o=await t(f.cartId);if(!o)return void n("Failed to get cart data");f.cartData=o.cartData,f.zonosApiKey=o.zonosApiKey}}if(f.cartId&&f.cartData){e("Cart data is available, inject hidden button and trigger checkout");const n=document.createElement("button");n.style.display="none",n.id=`${o}`,document.body.appendChild(n)}e("init zonos"),f.injectZonosCdn(),f.injectZonosCss(),f.injectFonts(),f.injectController({config:{appearance:s,checkoutSettings:r,currencyConverter:i,helloSettings:c,onCountryChange:l,overrideCurrencyFormat:d}}),f.doneInit=!0}},g.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},g.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},g.showNotification=e=>{var n;null===(n=f.zonosController)||void 0===n||n.showNotification(e)},g.updateOrganizationName=e=>{var n;null===(n=f.zonosController)||void 0===n||n.updateOrganizationName(e)},g.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:t,placeOrderButtonSelector:o})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&o){const n=document.querySelectorAll(o),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&t&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},g.injectController=({config:t})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=t.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const e=t.checkoutSettings.placeOrderButtonSelector;f.disablePlaceOrderButtons({config:t,disable:!0,placeOrderButtonSelector:e}),new MutationObserver((()=>{f.disablePlaceOrderButtons({config:t,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=t,s.zonosApiKey=f.zonosApiKey||"",s.addEventListener("stripeInitEvent",(async t=>{const{detail:o}=t;e("loading Stripe");const r=await(async(...e)=>{w=!0;const n=Date.now();return p.then((t=>((e,n,t)=>{if(null===e)return null;const o=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(o,t),o})(t,e,n)))})(o.publishableKey);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),f.zonosController=s,e("Zonos controller injected!")},g.injectScript=({cdnType:t,isModule:o,theRestUrl:s})=>{const r=`${f.getZonosUrl(t)}/${s}`;if(document.querySelector(`script[src="${r}"]`))return void e(`Zonos script "${r}" already exists in the document`,"warn");const c=document.head||document.body,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=r,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const e=i(t);e&&f.injectScript({cdnType:e,isModule:o,theRestUrl:s})},c.appendChild(l)},g.getZonosUrl=n=>{const t=()=>{switch(n){case"jsdelivr":return y;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.94";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.94";case"vercel":return v}};return f.isNpm&&(()=>{const n=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||n)return null;const t=(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.3.94.js.zonos.com";if(!t&&(o.includes("test.")||o.includes("test-")))return o;if(!t&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!t)return null;if("dev-elements"===t)return"https://dev.elements.zonos.com";const s=`https://${t}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${s}' for loading elements script`,"warn"),fetch(s).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${s}' 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,t=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),s})()||t()},g.injectZonosCdn=()=>{f.injectScript({cdnType:r,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),f.injectScript({cdnType:r,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},g.injectStylesheet=({cdnType:e,theRestUrl:t})=>{const o=f.getZonosUrl(e),s=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${v}/`,s.appendChild(r);const c=document.createElement("link");c.rel="stylesheet",c.href=`${o}/${t}`,c.onerror=()=>{n(`Failed to load ${c.href}`);const o=i(e);o&&f.injectStylesheet({cdnType:o,theRestUrl:t})},s.appendChild(c)},g.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(f.injectStylesheet({cdnType:r,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},g.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${z}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&!S.test(t.href))return t}return null})())return void e("Inter font already injected","warn");const n=document.head||document.body,t=document.createElement("link");t.rel="preconnect",t.href=z,n.appendChild(t);const o=document.createElement("link");o.rel="stylesheet",o.href=`${z}/inter/inter.css`,n.appendChild(o),e("Zonos font injected!")},g.setupGoogleFont=e=>{var n;null===(n=f.zonosController)||void 0===n||n.setupGoogleFont(e)},g.injectSupportGoogleFont=n=>{var t;e(`[FONT] injecting ${n}`);const o=null===(t=n.match(/family=(.*?):/))||void 0===t?void 0:t[1],s=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${j}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=j,s.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return void e(`[FONT] ${o} font already injected`,"warn");const r=document.createElement("link");r.rel="stylesheet",r.href=n,s.appendChild(r),e(`[FONT] ${o} font injected!`)};export{g as Zonos}