@zonos/elements 1.3.163 → 1.3.165

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 (144) hide show
  1. package/dist/cjs/{cart-934a8aef.js → cart-dbeee1e9.js} +70 -1
  2. package/dist/cjs/index.cjs.js +7 -7
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{paypal-dddeb76e.js → paypal-38ab2263.js} +1 -1
  5. package/dist/cjs/{zonos-address_8.cjs.entry.js → zonos-address_7.cjs.entry.js} +20 -67
  6. package/dist/cjs/zonos-cart-items_13.cjs.entry.js +2 -2
  7. package/dist/cjs/zonos-checkout.cjs.entry.js +4 -3
  8. package/dist/cjs/zonos-controller.cjs.entry.js +1 -1
  9. package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
  10. package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
  11. package/dist/cjs/zonos-elements.cjs.js +1 -1
  12. package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +2 -2
  13. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +1 -1
  14. package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
  15. package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
  16. package/dist/cjs/zonos-stripe-input.cjs.entry.js +73 -0
  17. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +2 -1
  18. package/dist/collection/components/store/checkout/stripe.js +1 -0
  19. package/dist/collection/components/store/hello/localization.js +7 -1
  20. package/dist/collection/components/store/translationStore/strings.arabic.js +3 -0
  21. package/dist/collection/components/store/translationStore/strings.base.js +3 -0
  22. package/dist/collection/components/store/translationStore/strings.chinese.js +3 -0
  23. package/dist/collection/components/store/translationStore/strings.danish.js +3 -0
  24. package/dist/collection/components/store/translationStore/strings.dutch.js +3 -0
  25. package/dist/collection/components/store/translationStore/strings.french.js +3 -0
  26. package/dist/collection/components/store/translationStore/strings.german.js +3 -0
  27. package/dist/collection/components/store/translationStore/strings.hebrew.js +3 -0
  28. package/dist/collection/components/store/translationStore/strings.indonesian.js +3 -0
  29. package/dist/collection/components/store/translationStore/strings.italian.js +3 -0
  30. package/dist/collection/components/store/translationStore/strings.japanese.js +3 -0
  31. package/dist/collection/components/store/translationStore/strings.korean.js +3 -0
  32. package/dist/collection/components/store/translationStore/strings.norwegian.js +3 -0
  33. package/dist/collection/components/store/translationStore/strings.polish.js +3 -0
  34. package/dist/collection/components/store/translationStore/strings.portuguese.js +3 -0
  35. package/dist/collection/components/store/translationStore/strings.russian.js +3 -0
  36. package/dist/collection/components/store/translationStore/strings.spanish.js +3 -0
  37. package/dist/collection/components/store/translationStore/strings.swedish.js +3 -0
  38. package/dist/collection/components/store/translationStore/strings.turkish.js +3 -0
  39. package/dist/collection/components/store/translationStore/strings.vietnamese.js +3 -0
  40. package/dist/collection/components/stripe/zonos-address/zonos-address.css +3 -0
  41. package/dist/collection/components/stripe/zonos-address/zonos-address.js +19 -1
  42. package/dist/collection/components/utils/api/prepCalculateLandedCost.js +2 -0
  43. package/dist/collection/types/generated/graphql.internal.types.js +10 -0
  44. package/dist/esm/{cart-41bdd9fb.js → cart-f2f5f13f.js} +70 -1
  45. package/dist/esm/index.js +7 -7
  46. package/dist/esm/loader.js +1 -1
  47. package/dist/esm/{paypal-c81fb5ee.js → paypal-7d253663.js} +1 -1
  48. package/dist/esm/{zonos-address_8.entry.js → zonos-address_7.entry.js} +21 -67
  49. package/dist/esm/zonos-cart-items_13.entry.js +2 -2
  50. package/dist/esm/zonos-checkout.entry.js +4 -3
  51. package/dist/esm/zonos-controller.entry.js +1 -1
  52. package/dist/esm/zonos-country-flag.entry.js +1 -1
  53. package/dist/esm/zonos-country-select_4.entry.js +1 -1
  54. package/dist/esm/zonos-elements.js +1 -1
  55. package/dist/esm/zonos-empty-state-payment_4.entry.js +2 -2
  56. package/dist/esm/zonos-hello-dialog.entry.js +1 -1
  57. package/dist/esm/zonos-hello.entry.js +1 -1
  58. package/dist/esm/zonos-language-select_2.entry.js +1 -1
  59. package/dist/esm/zonos-stripe-input.entry.js +69 -0
  60. package/dist/esm-es5/cart-f2f5f13f.js +1 -0
  61. package/dist/esm-es5/index.js +1 -1
  62. package/dist/esm-es5/loader.js +1 -1
  63. package/dist/esm-es5/{paypal-c81fb5ee.js → paypal-7d253663.js} +1 -1
  64. package/dist/esm-es5/zonos-address_7.entry.js +1 -0
  65. package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
  66. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  67. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  68. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  69. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  70. package/dist/esm-es5/zonos-elements.js +1 -1
  71. package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
  72. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  73. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  74. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  75. package/dist/esm-es5/zonos-stripe-input.entry.js +1 -0
  76. package/dist/scripts/index.d.ts +1 -0
  77. package/dist/scripts/index.js +1 -1
  78. package/dist/scripts/loadZonos.js +1 -1
  79. package/dist/scripts/zonos.js +1 -1
  80. package/dist/types/components/store/checkout/stripe.d.ts +4 -0
  81. package/dist/types/components/store/translationStore/strings.arabic.d.ts +3 -0
  82. package/dist/types/components/store/translationStore/strings.base.d.ts +3 -0
  83. package/dist/types/components/store/translationStore/strings.chinese.d.ts +3 -0
  84. package/dist/types/components/store/translationStore/strings.danish.d.ts +3 -0
  85. package/dist/types/components/store/translationStore/strings.dutch.d.ts +3 -0
  86. package/dist/types/components/store/translationStore/strings.french.d.ts +3 -0
  87. package/dist/types/components/store/translationStore/strings.german.d.ts +3 -0
  88. package/dist/types/components/store/translationStore/strings.hebrew.d.ts +3 -0
  89. package/dist/types/components/store/translationStore/strings.indonesian.d.ts +3 -0
  90. package/dist/types/components/store/translationStore/strings.italian.d.ts +3 -0
  91. package/dist/types/components/store/translationStore/strings.japanese.d.ts +3 -0
  92. package/dist/types/components/store/translationStore/strings.korean.d.ts +3 -0
  93. package/dist/types/components/store/translationStore/strings.norwegian.d.ts +3 -0
  94. package/dist/types/components/store/translationStore/strings.polish.d.ts +3 -0
  95. package/dist/types/components/store/translationStore/strings.portuguese.d.ts +3 -0
  96. package/dist/types/components/store/translationStore/strings.russian.d.ts +3 -0
  97. package/dist/types/components/store/translationStore/strings.spanish.d.ts +3 -0
  98. package/dist/types/components/store/translationStore/strings.swedish.d.ts +3 -0
  99. package/dist/types/components/store/translationStore/strings.turkish.d.ts +3 -0
  100. package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +3 -0
  101. package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +1 -0
  102. package/dist/types/types/checkout/api/CalculateLandedCost.d.ts +2 -0
  103. package/dist/types/types/generated/graphql.internal.types.d.ts +13 -0
  104. package/dist/types/types/generated/graphql.internal.types.ts +20 -0
  105. package/dist/types/types/utils/ZonosSettings.d.ts +4 -0
  106. package/dist/zonos-elements/index.esm.js +1 -1
  107. package/dist/zonos-elements/{p-22e190af.entry.js → p-163425d9.entry.js} +1 -1
  108. package/dist/zonos-elements/{p-9cbe0e06.system.entry.js → p-16413274.system.entry.js} +1 -1
  109. package/dist/zonos-elements/p-18d23528.entry.js +1 -0
  110. package/dist/zonos-elements/{p-6bbdc759.system.entry.js → p-1c850630.system.entry.js} +1 -1
  111. package/dist/zonos-elements/{p-f06559c1.entry.js → p-20802055.entry.js} +1 -1
  112. package/dist/zonos-elements/{p-7c536f5a.system.entry.js → p-25ad92dc.system.entry.js} +1 -1
  113. package/dist/zonos-elements/p-3bff5a9f.system.js +1 -0
  114. package/dist/zonos-elements/{p-0cee00ae.system.js → p-3c865c53.system.js} +1 -1
  115. package/dist/zonos-elements/{p-d9940c47.system.entry.js → p-3edccfff.system.entry.js} +1 -1
  116. package/dist/zonos-elements/{p-983c8c5f.entry.js → p-405f70b1.entry.js} +1 -1
  117. package/dist/zonos-elements/{p-a23fb562.system.entry.js → p-41688151.system.entry.js} +1 -1
  118. package/dist/zonos-elements/{p-e6bbea1e.system.entry.js → p-466de014.system.entry.js} +1 -1
  119. package/dist/zonos-elements/p-46f6e5e9.system.js +1 -1
  120. package/dist/zonos-elements/{p-a9a29cf6.system.js → p-4a0d1e3c.system.js} +1 -1
  121. package/dist/zonos-elements/p-607a6750.entry.js +1 -0
  122. package/dist/zonos-elements/{p-daa0dcb4.system.entry.js → p-669a7b5d.system.entry.js} +1 -1
  123. package/dist/zonos-elements/{p-28a062f3.entry.js → p-6e864533.entry.js} +1 -1
  124. package/dist/zonos-elements/{p-bbc11b58.entry.js → p-7011d8e2.entry.js} +1 -1
  125. package/dist/zonos-elements/p-718c9603.system.entry.js +1 -0
  126. package/dist/zonos-elements/{p-e611b266.system.entry.js → p-735d4097.system.entry.js} +1 -1
  127. package/dist/zonos-elements/{p-2f6bbd3b.entry.js → p-93499c9b.entry.js} +1 -1
  128. package/dist/zonos-elements/{p-7b76c844.system.entry.js → p-9d53988d.system.entry.js} +1 -1
  129. package/dist/zonos-elements/{p-e300d1ed.entry.js → p-ab699c84.entry.js} +1 -1
  130. package/dist/zonos-elements/p-c371558a.system.entry.js +1 -0
  131. package/dist/zonos-elements/p-c556ff98.js +1 -0
  132. package/dist/zonos-elements/p-e4a52de7.entry.js +1 -0
  133. package/dist/zonos-elements/p-e97f9606.js +17 -0
  134. package/dist/zonos-elements/{p-7cb5e4b8.entry.js → p-f9c2ff4c.entry.js} +1 -1
  135. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  136. package/package.json +1 -1
  137. package/dist/esm-es5/cart-41bdd9fb.js +0 -1
  138. package/dist/esm-es5/zonos-address_8.entry.js +0 -1
  139. package/dist/zonos-elements/p-15d4d606.system.js +0 -1
  140. package/dist/zonos-elements/p-1921fe51.entry.js +0 -1
  141. package/dist/zonos-elements/p-23021792.js +0 -17
  142. package/dist/zonos-elements/p-52bfe2bc.system.entry.js +0 -1
  143. package/dist/zonos-elements/p-a0efb02e.js +0 -1
  144. package/dist/zonos-elements/p-fb7b12af.entry.js +0 -1
@@ -1 +1 @@
1
- (function(){"use strict";const e=performance.now(),o=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},t=(t,n,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const o=performance.now()-e,t=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:t}})(),c=[`(${a})`,...r];c.map(o).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(t,...c));let l=document.querySelector("iframe#zonos---debug-logging-iframe");l||(l=document.createElement("iframe"),l.id="zonos---debug-logging-iframe",l.style.display="none",l.style.opacity="0",l.style.position="absolute",l.style.top="-9999px",l.style.left="-9999px",l.style.width="1px",l.style.height="1px",l.style.border="none",l.style.overflow="hidden",l.style.visibility="hidden",document.body.appendChild(l));const d=(null===(i=l.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...c);break;case"info":d.info(t,...c);break;case"error":d.error(t,...c);break;default:d.groupCollapsed(t,...c),d.trace(),d.groupEnd()}},n=(e,...o)=>{t(e,"error",...o)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const o=r.indexOf(e);return r[o+1]||null},a=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function l(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const d=["cloudflare","vercel"],u=d[0],p={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},m=p[u],w=(e=u)=>{const o=d.indexOf(e),t=d[o+1];return t||null},y=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},h=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=y(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},f=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||p[e]||u,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&c&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await h({response:n}),response:n,zonosMode:a}}const l=n.status.toString();try{const e=await h({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:l}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:l}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${l}: ${"Unknown error"}`,type:l}],json:null,response:null,zonosMode:a}}},g=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=await f({basePathType:i,options:o,path:n}),{errors:c,response:d}=a,u=l(a,["errors","response"]),h=w(i),v=!!c.find((({type:e})=>"unknown"===e))||404===(null==d?void 0:d.status),b=h&&v;return v&&(async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(t("sendErrorLog","warn",e,n,o),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:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${m}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=w();if(!o)return;fetch(`${p[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:p[i]+n,errors:c.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:h,requestHeaders:null==o?void 0:o.headers,requestPayload:y(null===(r=null==o?void 0:o.body)||void 0===r?void 0:r.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==d?void 0:d.status,statusText:null==d?void 0:d.statusText},shouldPostReleaseErrorReporting:!0}),b?(t(`=== "${n}" failed to fetch, trying next fallback ${h}`),g({basePathType:h,options:o,path:n})):Object.assign({errors:c,response:d},u)},v=async(e,o)=>{const n=l(o||{},[]),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-Staging-Mode":a()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(i).forEach((e=>void 0===i[e]&&delete i[e]));const d=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),p=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),g({basePathType:p||u,options:d,path:e})},b=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),n="https://v1.3.163.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const r=`https://${o}.preview.js.zonos.com`;return t(`[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:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),r},S="https://js.stripe.com/v3",z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,C="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let j=null;const O=e=>(null!==j||(j=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(C),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${S}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&z.test(t.src))return t}return null})();r&&e?console.warn(C):r||(r=(e=>{const o=document.createElement("script");o.src=`${S}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),j),Z=Promise.resolve().then((()=>O(null)));let k=!1;Z.catch((e=>{k||console.warn(e)}));const I=async({cartId:e,retries:o})=>{const n=c(),{errors:r,json:s}=await v("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,options:{noOnlineStoreSettings:!0},tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),I({cartId:e,retries:o-1})):i?null:s},A=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${A.source}$`),L=new RegExp(`^cart_${A.source}$`),$=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,T=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:L.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:E.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!r&&!o)return n("[ZONOS - loadZonos] invalid cart id"),null;const s=await I({cartId:e,retries:5});return t("[ZONOS - loadZonos] getting temp cart data","info",s),s?(window.Zonos.storeId=s.cartData.storeId,window.Zonos.zonosApiKey=s.cartData.credentialToken,{cartData:s.cartData,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var U;const P=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),n=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),D="https://v1.3.163.js.zonos.com",F=P||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.163",R="https://fonts.googleapis.com",x=/^https:\/\/fonts\.googleapis\.com/;class M{}U=M,M.doneInit=!1,M.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),M.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),M._paypalMockResponse=null,M.isBigCommerce=!1,M.releaseDate="1740498125505",M.isLegacyCheckout=!1,M.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",M.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),M.isNpm=!0,M.zonosQaUrl=null,M.zonosQaUrlApi=null,M.version="v1.3.163",M.modeAlerted=!1,M.cartData=null,M.paypal=null,M.getCurrentTimestamp=()=>(new Date).getTime(),M.zonosController=null,M.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:d,storeId:u,zonosApiKey:p}=e;if(U.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),U.doneInit)return;if(t(`====== ZONOS DEBUG MODE: on (${U.version}) ======`),U.zonosApiKey=p,U.storeId=u,U.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=b();if(o&&!window.isZonosPreview){t(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const n=document.createElement("script");return n.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=U.isNpm,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!U.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!U.cartData&&U.cartId){t("Initialize cart data");const e=await T(U.cartId);if(!e)return void n("Failed to get cart data");U.cartData=e.cartData,U.zonosApiKey=e.zonosApiKey}const r=await(async()=>{const e=c(),o=a();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:s}=await v("/api/get-test-public-credential");if(r.length||!s)return n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const i=s.publicCredential;return i?(t(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(n("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();r&&(U.zonosApiKey=r)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(U.cartId&&U.cartData||!!m){t("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}t("init zonos"),U.restoreNativeBrowserFunctions(),U.injectCustomScriptForHostedCheckout(),U.injectZonosCdn(),U.injectZonosCss(),U.injectFonts(),U.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:d}}),U.doneInit=!0},M.injectCustomScriptForHostedCheckout=()=>{const e=U.cartData,o=(null==e?void 0:e.metadata)||[],n=o.find((e=>"customHeaderScript"===e.key)),r=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(n||r)){if(n){t("Injecting custom header script");const e=document.createElement("script");e.textContent=n.value,document.head.appendChild(e)}if(r){t("Injecting custom footer script");const e=document.createElement("script");e.textContent=r.value,document.body.appendChild(e)}}else t("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:n,isLegacyCheckout:window.Zonos.isLegacyCheckout})},M.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},M.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},M.showNotification=e=>{var o;null===(o=U.zonosController)||void 0===o||o.showNotification(e)},M.updateOrganizationName=e=>{var o;null===(o=U.zonosController)||void 0===o||o.updateOrganizationName(e)},M.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},M.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},M.injectController=({config:e})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;U.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{U.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=U.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{k=!0;const o=Date.now();return Z.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.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),U.zonosController=r,t("Zonos controller injected!")},M.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${U.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const a=document.head||document.body,c=document.createElement("script");o?c.type="module":c.noModule=!0,c.src=s,c.crossOrigin="anonymous",c.onerror=()=>{n(`Failed to load ${c.src}`);const t=i(e);t&&U.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(c)},M.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return F;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.163";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.163";case"vercel":return D}};if(U.isNpm){return b()||o()}return o()},M.injectZonosCdn=()=>{U.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),U.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},M.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=U.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${D}/`,r.appendChild(s);const a=document.createElement("link");a.rel="stylesheet",a.href=`${t}/${o}`,a.onerror=()=>{n(`Failed to load ${a.href}`);const t=i(e);t&&U.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},M.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(U.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},M.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void t("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${R}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!x.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=R,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${R}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(n),t("Zonos font injected!")},M.setupGoogleFont=e=>{var o;null===(o=U.zonosController)||void 0===o||o.setupGoogleFont(e)},M.injectSupportGoogleFont=e=>{var o;t(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${R}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=R,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),t(`[FONT] ${n} font injected!`)},exports.Zonos=M})();
1
+ (function(){"use strict";const e=performance.now(),o=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},t=(t,n,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const o=performance.now()-e,t=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:t}})(),c=[`(${a})`,...r];c.map(o).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(t,...c));let l=document.querySelector("iframe#zonos---debug-logging-iframe");l||(l=document.createElement("iframe"),l.id="zonos---debug-logging-iframe",l.style.display="none",l.style.opacity="0",l.style.position="absolute",l.style.top="-9999px",l.style.left="-9999px",l.style.width="1px",l.style.height="1px",l.style.border="none",l.style.overflow="hidden",l.style.visibility="hidden",document.body.appendChild(l));const d=(null===(i=l.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...c);break;case"info":d.info(t,...c);break;case"error":d.error(t,...c);break;default:d.groupCollapsed(t,...c),d.trace(),d.groupEnd()}},n=(e,...o)=>{t(e,"error",...o)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const o=r.indexOf(e);return r[o+1]||null},a=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function l(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const d=["cloudflare","vercel"],u=d[0],p={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},m=p[u],w=(e=u)=>{const o=d.indexOf(e),t=d[o+1];return t||null},y=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},h=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=y(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},f=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||p[e]||u,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&c&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await h({response:n}),response:n,zonosMode:a}}const l=n.status.toString();try{const e=await h({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:l}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:l}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${l}: ${"Unknown error"}`,type:l}],json:null,response:null,zonosMode:a}}},g=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=await f({basePathType:i,options:o,path:n}),{errors:c,response:d}=a,u=l(a,["errors","response"]),h=w(i),v=!!c.find((({type:e})=>"unknown"===e))||404===(null==d?void 0:d.status),b=h&&v;return v&&(async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(t("sendErrorLog","warn",e,n,o),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:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${m}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=w();if(!o)return;fetch(`${p[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:p[i]+n,errors:c.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:h,requestHeaders:null==o?void 0:o.headers,requestPayload:y(null===(r=null==o?void 0:o.body)||void 0===r?void 0:r.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==d?void 0:d.status,statusText:null==d?void 0:d.statusText},shouldPostReleaseErrorReporting:!0}),b?(t(`=== "${n}" failed to fetch, trying next fallback ${h}`),g({basePathType:h,options:o,path:n})):Object.assign({errors:c,response:d},u)},v=async(e,o)=>{const n=l(o||{},[]),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-Staging-Mode":a()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(i).forEach((e=>void 0===i[e]&&delete i[e]));const d=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),p=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),g({basePathType:p||u,options:d,path:e})},b=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),n="https://v1.3.165.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const r=`https://${o}.preview.js.zonos.com`;return t(`[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:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),r},S="https://js.stripe.com/v3",z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,C="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let j=null;const O=e=>(null!==j||(j=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(C),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${S}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&z.test(t.src))return t}return null})();r&&e?console.warn(C):r||(r=(e=>{const o=document.createElement("script");o.src=`${S}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),j),Z=Promise.resolve().then((()=>O(null)));let k=!1;Z.catch((e=>{k||console.warn(e)}));const I=async({cartId:e,retries:o})=>{const n=c(),{errors:r,json:s}=await v("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,options:{noOnlineStoreSettings:!0},tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),I({cartId:e,retries:o-1})):i?null:s},A=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${A.source}$`),L=new RegExp(`^cart_${A.source}$`),$=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,T=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:L.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:E.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!r&&!o)return n("[ZONOS - loadZonos] invalid cart id"),null;const s=await I({cartId:e,retries:5});return t("[ZONOS - loadZonos] getting temp cart data","info",s),s?(window.Zonos.storeId=s.cartData.storeId,window.Zonos.zonosApiKey=s.cartData.credentialToken,{cartData:s.cartData,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var U;const P=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),n=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),D="https://v1.3.165.js.zonos.com",F=P||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.165",R="https://fonts.googleapis.com",x=/^https:\/\/fonts\.googleapis\.com/;class M{}U=M,M.doneInit=!1,M.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),M.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),M._paypalMockResponse=null,M.isBigCommerce=!1,M.releaseDate="1740583862303",M.isLegacyCheckout=!1,M.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",M.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),M.isNpm=!0,M.zonosQaUrl=null,M.zonosQaUrlApi=null,M.version="v1.3.165",M.modeAlerted=!1,M.cartData=null,M.paypal=null,M.getCurrentTimestamp=()=>(new Date).getTime(),M.zonosController=null,M.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:d,storeId:u,zonosApiKey:p}=e;if(U.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),U.doneInit)return;if(t(`====== ZONOS DEBUG MODE: on (${U.version}) ======`),U.zonosApiKey=p,U.storeId=u,U.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=b();if(o&&!window.isZonosPreview){t(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const n=document.createElement("script");return n.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=U.isNpm,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!U.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!U.cartData&&U.cartId){t("Initialize cart data");const e=await T(U.cartId);if(!e)return void n("Failed to get cart data");U.cartData=e.cartData,U.zonosApiKey=e.zonosApiKey}const r=await(async()=>{const e=c(),o=a();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:s}=await v("/api/get-test-public-credential");if(r.length||!s)return n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const i=s.publicCredential;return i?(t(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(n("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();r&&(U.zonosApiKey=r)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(U.cartId&&U.cartData||!!m){t("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}t("init zonos"),U.restoreNativeBrowserFunctions(),U.injectCustomScriptForHostedCheckout(),U.injectZonosCdn(),U.injectZonosCss(),U.injectFonts(),U.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:d}}),U.doneInit=!0},M.injectCustomScriptForHostedCheckout=()=>{const e=U.cartData,o=(null==e?void 0:e.metadata)||[],n=o.find((e=>"customHeaderScript"===e.key)),r=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(n||r)){if(n){t("Injecting custom header script");const e=document.createElement("script");e.textContent=n.value,document.head.appendChild(e)}if(r){t("Injecting custom footer script");const e=document.createElement("script");e.textContent=r.value,document.body.appendChild(e)}}else t("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:n,isLegacyCheckout:window.Zonos.isLegacyCheckout})},M.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},M.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},M.showNotification=e=>{var o;null===(o=U.zonosController)||void 0===o||o.showNotification(e)},M.updateOrganizationName=e=>{var o;null===(o=U.zonosController)||void 0===o||o.updateOrganizationName(e)},M.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},M.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},M.injectController=({config:e})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;U.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{U.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=U.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{k=!0;const o=Date.now();return Z.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.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),U.zonosController=r,t("Zonos controller injected!")},M.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${U.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const a=document.head||document.body,c=document.createElement("script");o?c.type="module":c.noModule=!0,c.src=s,c.crossOrigin="anonymous",c.onerror=()=>{n(`Failed to load ${c.src}`);const t=i(e);t&&U.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(c)},M.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return F;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.165";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.165";case"vercel":return D}};if(U.isNpm){return b()||o()}return o()},M.injectZonosCdn=()=>{U.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),U.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},M.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=U.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${D}/`,r.appendChild(s);const a=document.createElement("link");a.rel="stylesheet",a.href=`${t}/${o}`,a.onerror=()=>{n(`Failed to load ${a.href}`);const t=i(e);t&&U.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},M.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(U.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},M.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void t("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${R}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!x.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=R,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${R}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(n),t("Zonos font injected!")},M.setupGoogleFont=e=>{var o;null===(o=U.zonosController)||void 0===o||o.setupGoogleFont(e)},M.injectSupportGoogleFont=e=>{var o;t(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${R}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=R,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),t(`[FONT] ${n} font injected!`)},exports.Zonos=M})();
@@ -1 +1 @@
1
- (function(){"use strict";function o(o,e){var n={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(n[t]=o[t]);if(null!=o&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(o);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(o,t[r])&&(n[t[r]]=o[t[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;const e=()=>window.location.search.includes("zonosStagingMode=1"),n=()=>{var o;return(null===(o=window.Zonos.zonosApiKey)||void 0===o?void 0:o.includes("test"))||window.location.search.includes("zonosTestMode=1")},t=["cloudflare","vercel"],r=t[0],s={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},i=s[r],a=(o=r)=>{const e=t.indexOf(o),n=t[e+1];return n||null},d=o=>{if("string"==typeof o)try{return JSON.parse(o)}catch(o){return null}return null},c=performance.now(),l=o=>{if("string"==typeof o)return o;try{return JSON.stringify(o)}catch(e){if(o&&"function"==typeof o.toString){return o.toString()}return"Unable to stringify info"}},p=(o,e,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const o=performance.now()-c,e=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:e}})(),i=[`(${s})`,...n];i.map(l).join(" ");if(!(!!(null===(t=window.Zonos)||void 0===t?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===e&&console.error(o,...i));let a=document.querySelector("iframe#zonos---debug-logging-iframe");a||(a=document.createElement("iframe"),a.id="zonos---debug-logging-iframe",a.style.display="none",a.style.opacity="0",a.style.position="absolute",a.style.top="-9999px",a.style.left="-9999px",a.style.width="1px",a.style.height="1px",a.style.border="none",a.style.overflow="hidden",a.style.visibility="hidden",document.body.appendChild(a));const d=(null===(r=a.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(e){case"warn":d.warn(o,...i);break;case"info":d.info(o,...i);break;case"error":d.error(o,...i);break;default:d.groupCollapsed(o,...i),d.trace(),d.groupEnd()}},u=async({endpoint:o,errors:e,metadata:n,shouldPostReleaseErrorReporting:t})=>{if(p("sendErrorLog","warn",o,n,e),t){const o=Number(window.Zonos.releaseDate);if((new Date).getTime()-o>36e5)return}const r="userAgentData"in window.navigator?window.navigator.userAgentData:null,d={endpoint:o,errors:e,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:r&&r.brands.length>0?r:window.navigator.userAgent},n)};try{fetch(`${i}/api/zonos-elements/log-error`,{body:JSON.stringify(d),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(o){const e=a();if(!e)return;fetch(`${s[e]}/api/zonos-elements/log-error`,{body:JSON.stringify(d),method:"POST"})}},m=async({response:o,shouldLog:e=!0,shouldThrow:n=!1})=>{try{const e=await o.text(),n=d(e);if(!n)throw new Error(`Failed to parse content: ${e}`);return n}catch(o){if(n)throw o;return e&&console.error(o),null}},w=async({basePathType:o,options:e,path:n})=>{let t;const i=window.Zonos.zonosQaUrlApi||s[o]||r,a=new URL(i+n),d=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;a.searchParams.set("zToken",(o=>{try{return btoa(o).replace(/=/g,"")}catch(e){return o.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(d));try{t=await fetch(a.toString(),e)}catch(o){if(o instanceof Error)return{baseUrl:i,errors:[{message:o.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:i,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const c=t.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&c&&l&&(window.Zonos.modeAlerted=!0),t.ok){return{baseUrl:i,errors:[],json:await m({response:t}),response:t,zonosMode:c}}const p=t.status.toString();try{const o=await m({response:t,shouldThrow:!0});if(o&&"errors"in o&&Array.isArray(o.errors)){const e=o.errors;return{baseUrl:i,errors:e.map((o=>"string"==typeof o?{message:o,type:p}:o)),json:null,response:t,zonosMode:c}}return{baseUrl:i,errors:[{message:JSON.stringify(o),type:p}],json:null,response:t,zonosMode:c}}catch(o){return{baseUrl:i,errors:[{message:`${p}: ${"Unknown error"}`,type:p}],json:null,response:null,zonosMode:c}}},g=async({basePathType:e,options:n,path:t})=>{var r,i;const c=t.startsWith("/api/bigcommerce")?"vercel":e,l=await w({basePathType:c,options:n,path:t}),{errors:m,response:f}=l,y=o(l,["errors","response"]),h=a(c),v=!!m.find((({type:o})=>"unknown"===o))||404===(null==f?void 0:f.status),Z=h&&v;return v&&u({endpoint:s[c]+t,errors:m.map((({message:o})=>`API: ${o}`)),metadata:{currentBasePath:c,nextFallbackApiType:h,requestHeaders:null==n?void 0:n.headers,requestPayload:d(null===(r=null==n?void 0:n.body)||void 0===r?void 0:r.toString())||(null===(i=null==n?void 0:n.body)||void 0===i?void 0:i.toString()),status:null==f?void 0:f.status,statusText:null==f?void 0:f.statusText},shouldPostReleaseErrorReporting:!0}),Z?(p(`=== "${t}" failed to fetch, trying next fallback ${h}`),g({basePathType:h,options:n,path:t})):Object.assign({errors:m,response:f},y)},f=async(t,s)=>{const i=o(s||{},[]),a=i.body?JSON.stringify(i.body):void 0,d=i.method||"GET",c=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":e()?"1":void 0,"Zonos-Test-Mode":n()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},i.headers);Object.keys(c).forEach((o=>void 0===c[o]&&delete c[o]));const l=Object.assign(Object.assign({},i),{body:"GET"===d?void 0:a,headers:c,method:d}),u=new URLSearchParams(window.location.search).get("useFallbackApi");return p(t,"info"),g({basePathType:u||r,options:l,path:t})},y=(o,...e)=>{p(o,"error",...e)},h=["jsdelivr","cdnjs","unpkg","vercel"],v=o=>{if(!o)return null;const e=new URL(o).searchParams.get("zonosQaUrl");if(!e)return null;return/[^a-zA-Z0-9-_]+/.test(e)?null:e},Z=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,S=new RegExp(`^${Z.source}$`),z=new RegExp(`^cart_${Z.source}$`),O=/^[a-zA-Z0-9]{2,}$/,L=/^cart_[a-zA-Z0-9]{2,}$/,b=o=>o?o.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:L.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:O.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:z.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:S.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},I=async({cartId:o,retries:e})=>{const t=n(),{errors:r,json:s}=await f("/api/zonos-elements/get-temp-cart",{body:{isTestMode:t,options:{noOnlineStoreSettings:!0},tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&e?(p("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:e}),await new Promise((o=>setTimeout(o,500))),I({cartId:o,retries:e-1})):i?null:s};var C;const U=(()=>{const o=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||o)return null;const e=v(window.location.href),n="https://v1.3.163.js.zonos.com";if(!e&&(n.includes("test.")||n.includes("test-")))return n;if(!e&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!e)return null;if("dev-elements"===e)return"https://dev.elements.zonos.com";const t=`https://${e}.preview.js.zonos.com`;return p(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const o=new URLSearchParams(window.location.search);o.delete("zonosQaUrl");const{pathname:e}=window.location,n=`${e}?${o.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null})),t})(),j=(()=>{const o=(o=>{if(!o)return null;const e=new URL(o).searchParams.get("zonosQaUrlApi");return e?/[^a-zA-Z0-9-_]+/.test(e)?null:e:null})(window.location.href),e=v(window.location.href),n=o||e;if(!n&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.demo.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.demo.elements.zonos.com";if(!o)return null;const t=`https://${o}.route.js.zonos.com`;return p(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})();class k{}C=k,k.isNpm=!1,k.isBigCommerce=!1,k.requested=!1,k.cartData=null,k.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,k.version="v1.3.163",k.isLegacyCheckout=!1,k.legacyStoreLogo=null,k.legacyStoreFavicon=null,k.parallelLoadTimes=[],k.parallelLoadState="off",k.releaseDate="1740498125505",k.loadScriptLogHandler=async({cdnLoadTime:o,fallbackLoadTime:e,isError:n,metadata:t,scriptLoadUrl:r,storeId:s,type:i})=>{try{const o=window.performance.getEntriesByType("resource").find((o=>{const e=o;return e.name.includes(r)&&"script"===e.initiatorType}));null==o||o.transferSize;(async o=>{})((o&&(null==o?void 0:o.duration)>0?parseFloat(o.duration.toFixed(2)):parseFloat(e.toFixed(2)),Object.assign({decodedBodySize:null==o?void 0:o.decodedBodySize,encodedBodySize:null==o?void 0:o.encodedBodySize,fallbackLoadTime:e,isError:!!n},t)))}catch(o){}},k.loadScriptLogParallelHandler=async o=>{try{if(C.parallelLoadTimes.push(o),2===C.parallelLoadTimes.length){const o=C.parallelLoadTimes.find((o=>"vercel"===o.type)),e=C.parallelLoadTimes.find((o=>"jsdelivr"===o.type));if(!o||!e)return;if(o.isError&&e.isError)return void u({endpoint:`<${o.scriptLoadUrl}> <${e.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:e.fallbackLoadTime,cdnType:e.type,vercelLoadTime:o.fallbackLoadTime}});C.loadScriptLogHandler({cdnLoadTime:e.fallbackLoadTime,fallbackLoadTime:o.fallbackLoadTime,isError:o.isError,metadata:{cdnScriptFallbackTime:e.fallbackLoadTime,cdnScriptIsError:!!e.isError,cdnScriptLoadUrl:e.scriptLoadUrl,cdnScriptType:e.type},scriptLoadUrl:o.scriptLoadUrl,storeId:o.storeId,type:o.type})}}catch(o){}},k.legacyCheckoutErrorHandler=({message:o,metadata:e})=>{y(`[ZONOS - loadZonos] ${o}`),u({endpoint:"LegacyCheckoutInit",errors:[o],metadata:Object.assign(Object.assign({},e),{tempCartUUID:C.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:o}))},k.getGithubCdn=({type:o,version:e})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.163";"cdnjs"===o?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.163":"unpkg"===o&&(n="https://unpkg.com/@zonos/elements@1.3.163");return e&&"alpha"!==e?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${e}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${e}`):n},k.injectZonos=({cdnType:o="jsdelivr",initConfig:e,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;e=Object.assign(Object.assign({},e),{zonosApiKey:C.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===o?t:C.getGithubCdn({type:o,version:r}),a=U||i,d=a.replace("https://","").replace("http://",""),c=document.createElement("script"),l=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";c.src=`https://${d}/dist/scripts/${l}?timestamp=${Date.now()}`,p(`[ZONOS - loadZonos] Injecting "${l}" from "${d}"`,"info");const m="4g"===(null===(s=(()=>{const o="connection"in window.navigator?window.navigator.connection:null,e="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return o||e||n})())||void 0===s?void 0:s.effectiveType),w=["dev.elements.zonos.com","zonos.com"].some((o=>window.location.href.includes(o))),g=h[0]===o,f=h[1],y="on"===C.parallelLoadState&&m&&g&&f&&!w;y&&C.injectZonos({cdnType:f,initConfig:e,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();c.addEventListener("load",(()=>{if(y||n?C.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:c.src,storeId:C.storeId,type:o}):C.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:c.src,storeId:C.storeId,type:o}),C.isBigCommerce||(C.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=U,window.Zonos.zonosQaUrlApi=j,window.Zonos.isBigCommerce=C.isBigCommerce,C.cartId){if(!C.zonosApiKey)throw C.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!C.cartData)throw C.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(C.legacyStoreFavicon&&C.isLegacyCheckout){const o=document.createElement("link");o.rel="shortcut icon",o.type="image/x-icon",o.href=C.legacyStoreFavicon,document.head.appendChild(o)}window.Zonos.cartData=C.cartData,window.Zonos.isLegacyCheckout=C.isLegacyCheckout;const o=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:C.legacyStoreLogo||""}),zonosApiKey:C.zonosApiKey});e=o}window.Zonos.version&&(p(`[ZONOS - loadZonos] Execute "Zonos.init" from "${l}" from "${d}"`,"info"),window.Zonos.init(e))})),c.addEventListener("error",(async()=>{const s=(o=>{const e=h.indexOf(o);return h[e+1]||null})(o);if(!y&&!n){if(!s)return;C.injectZonos({cdnType:s,initConfig:e,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((o=>window.location.href.includes(o)))||U)return;if(y||n)return void C.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:c.src,storeId:C.storeId,type:o});["unpkg","cdnjs","vercel"].includes(o)?u({endpoint:c.src,errors:[`zonos.js - Failed to fetch ${o} CDN.`],metadata:{cdnLoadTime:performance.now()-v,cdnType:o,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):u({endpoint:c.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:o,vercelLoadTime:performance.now()-v}})})),document.head.appendChild(c)},k.init=async o=>{var t;if(p("=== Init zonos script release date","info",C.releaseDate),U&&!window.isZonosPreview){p(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${U}`,"info");const e=document.createElement("script");return e.src=`${U}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=C.isBigCommerce,window.Zonos.isLegacyCheckout=C.isLegacyCheckout,window.Zonos.init(o)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${U}`)})),void(window.isZonosPreview=!0)}const r=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:s,isLegacyCartId:i}=b(r);if(r&&!i&&!s)return void C.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${r}`,metadata:{invalidCartId:!0}});C.cartId=r;const a="https://v1.3.163.js.zonos.com",d=document.querySelector('script[src*="/zonos.js"]'),c=null===(t=document.querySelector("script[src*='/loadZonos.js']"))||void 0===t?void 0:t.src;p(`[ZONOS - init] first load script src: ${c}`,"info"),window.Zonos.zonosQaUrl=U,window.Zonos.zonosQaUrlApi=j,window.Zonos.zonosQaUrl&&p(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&p(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const l=null==c?void 0:c.includes("timestamp=");if(!(C.isNpm||c&&l))return void y("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(d||!c||C.requested)return void p("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!C.cartId)return C.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void y("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(C.requested=!0,C.zonosApiKey=o.zonosApiKey,C.storeId=o.storeId,C.cartId){const o=await(async o=>{const{isDgsCartId:e,isLegacyCartId:n}=b(o);if(!n&&!e)return y("[ZONOS - loadZonos] invalid cart id"),null;const t=await I({cartId:o,retries:5});return p("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,{cartData:t.cartData,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(y("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(C.cartId);if(!o)throw C.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");C.cartData=o.cartData,C.legacyStoreLogo=o.storeLogo,C.legacyStoreFavicon=o.storeFavicon,C.storeId=o.storeId,C.zonosApiKey=o.zonosApiKey}if(!C.zonosApiKey)return void y('"zonosApiKey" is required to initialize Zonos');const u=await(async()=>{const o=n(),t=e();if(!o&&!t||!window.Zonos.zonosApiKey)return null;if(p("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return p("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:s}=await f("/api/get-test-public-credential");if(r.length||!s)return y("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const i=s.publicCredential;return i?(p(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(y("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(u&&(p(`[ZONOS - loadZonos] Using test API key: ${u} for test mode`,"info"),C.zonosApiKey=u),!C.storeId)return p("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void C.injectZonos({initConfig:o,vercelUrl:a,version:null});const m=C.storeId||o.storeId;p(`[ZONOS - loadZonos] Store ID: ${m}`,"info");const w=new URLSearchParams;w.set("storeId",m.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&w.set("_enableStoreVersionPinned","1");const{errors:g,json:h}=await f(`/api/get-store-version?${w.toString()}`);if(g.length||!h)return p("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void C.injectZonos({initConfig:o,vercelUrl:a,version:null});const{isDifferent:v,source:Z,version:S}=h;if(p(`[ZONOS - loadZonos] Store version: ${S}, source: ${Z}`,"info"),v){p(`[ZONOS - loadZonos] Updating saved store version to ${S}`,"info");const o={storeId:m,version:S};f(`/api/set-store-version?${w.toString()}`,{body:o,method:"POST"}).catch((o=>y("Unable to save store's vesrion",o)))}if(!d){const{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t}=(({loadScriptSrc:o})=>{if(!o)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const e=new URL(o).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((o=>e.includes(o))),t=["qa.js.zonos.com"].some((o=>e.includes(o)));return{currentLoadScriptUrl:e,isForceLoadVersionDomain:t,isWhiteListed:n}})({loadScriptSrc:c}),r=t&&!n?e:`${"alpha"===S?"alpha":`v${S}`}.js.zonos.com`,s=t&&!n?null:S;p("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:S}),C.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview&&!window.Zonos.doneInit)&&(window.Zonos=k)})();
1
+ (function(){"use strict";function o(o,e){var n={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(n[t]=o[t]);if(null!=o&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(o);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(o,t[r])&&(n[t[r]]=o[t[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;const e=()=>window.location.search.includes("zonosStagingMode=1"),n=()=>{var o;return(null===(o=window.Zonos.zonosApiKey)||void 0===o?void 0:o.includes("test"))||window.location.search.includes("zonosTestMode=1")},t=["cloudflare","vercel"],r=t[0],s={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},i=s[r],a=(o=r)=>{const e=t.indexOf(o),n=t[e+1];return n||null},d=o=>{if("string"==typeof o)try{return JSON.parse(o)}catch(o){return null}return null},c=performance.now(),l=o=>{if("string"==typeof o)return o;try{return JSON.stringify(o)}catch(e){if(o&&"function"==typeof o.toString){return o.toString()}return"Unable to stringify info"}},p=(o,e,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const o=performance.now()-c,e=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:e}})(),i=[`(${s})`,...n];i.map(l).join(" ");if(!(!!(null===(t=window.Zonos)||void 0===t?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===e&&console.error(o,...i));let a=document.querySelector("iframe#zonos---debug-logging-iframe");a||(a=document.createElement("iframe"),a.id="zonos---debug-logging-iframe",a.style.display="none",a.style.opacity="0",a.style.position="absolute",a.style.top="-9999px",a.style.left="-9999px",a.style.width="1px",a.style.height="1px",a.style.border="none",a.style.overflow="hidden",a.style.visibility="hidden",document.body.appendChild(a));const d=(null===(r=a.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(e){case"warn":d.warn(o,...i);break;case"info":d.info(o,...i);break;case"error":d.error(o,...i);break;default:d.groupCollapsed(o,...i),d.trace(),d.groupEnd()}},u=async({endpoint:o,errors:e,metadata:n,shouldPostReleaseErrorReporting:t})=>{if(p("sendErrorLog","warn",o,n,e),t){const o=Number(window.Zonos.releaseDate);if((new Date).getTime()-o>36e5)return}const r="userAgentData"in window.navigator?window.navigator.userAgentData:null,d={endpoint:o,errors:e,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:r&&r.brands.length>0?r:window.navigator.userAgent},n)};try{fetch(`${i}/api/zonos-elements/log-error`,{body:JSON.stringify(d),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(o){const e=a();if(!e)return;fetch(`${s[e]}/api/zonos-elements/log-error`,{body:JSON.stringify(d),method:"POST"})}},m=async({response:o,shouldLog:e=!0,shouldThrow:n=!1})=>{try{const e=await o.text(),n=d(e);if(!n)throw new Error(`Failed to parse content: ${e}`);return n}catch(o){if(n)throw o;return e&&console.error(o),null}},w=async({basePathType:o,options:e,path:n})=>{let t;const i=window.Zonos.zonosQaUrlApi||s[o]||r,a=new URL(i+n),d=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;a.searchParams.set("zToken",(o=>{try{return btoa(o).replace(/=/g,"")}catch(e){return o.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(d));try{t=await fetch(a.toString(),e)}catch(o){if(o instanceof Error)return{baseUrl:i,errors:[{message:o.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:i,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const c=t.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&c&&l&&(window.Zonos.modeAlerted=!0),t.ok){return{baseUrl:i,errors:[],json:await m({response:t}),response:t,zonosMode:c}}const p=t.status.toString();try{const o=await m({response:t,shouldThrow:!0});if(o&&"errors"in o&&Array.isArray(o.errors)){const e=o.errors;return{baseUrl:i,errors:e.map((o=>"string"==typeof o?{message:o,type:p}:o)),json:null,response:t,zonosMode:c}}return{baseUrl:i,errors:[{message:JSON.stringify(o),type:p}],json:null,response:t,zonosMode:c}}catch(o){return{baseUrl:i,errors:[{message:`${p}: ${"Unknown error"}`,type:p}],json:null,response:null,zonosMode:c}}},g=async({basePathType:e,options:n,path:t})=>{var r,i;const c=t.startsWith("/api/bigcommerce")?"vercel":e,l=await w({basePathType:c,options:n,path:t}),{errors:m,response:f}=l,y=o(l,["errors","response"]),h=a(c),v=!!m.find((({type:o})=>"unknown"===o))||404===(null==f?void 0:f.status),Z=h&&v;return v&&u({endpoint:s[c]+t,errors:m.map((({message:o})=>`API: ${o}`)),metadata:{currentBasePath:c,nextFallbackApiType:h,requestHeaders:null==n?void 0:n.headers,requestPayload:d(null===(r=null==n?void 0:n.body)||void 0===r?void 0:r.toString())||(null===(i=null==n?void 0:n.body)||void 0===i?void 0:i.toString()),status:null==f?void 0:f.status,statusText:null==f?void 0:f.statusText},shouldPostReleaseErrorReporting:!0}),Z?(p(`=== "${t}" failed to fetch, trying next fallback ${h}`),g({basePathType:h,options:n,path:t})):Object.assign({errors:m,response:f},y)},f=async(t,s)=>{const i=o(s||{},[]),a=i.body?JSON.stringify(i.body):void 0,d=i.method||"GET",c=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":e()?"1":void 0,"Zonos-Test-Mode":n()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},i.headers);Object.keys(c).forEach((o=>void 0===c[o]&&delete c[o]));const l=Object.assign(Object.assign({},i),{body:"GET"===d?void 0:a,headers:c,method:d}),u=new URLSearchParams(window.location.search).get("useFallbackApi");return p(t,"info"),g({basePathType:u||r,options:l,path:t})},y=(o,...e)=>{p(o,"error",...e)},h=["jsdelivr","cdnjs","unpkg","vercel"],v=o=>{if(!o)return null;const e=new URL(o).searchParams.get("zonosQaUrl");if(!e)return null;return/[^a-zA-Z0-9-_]+/.test(e)?null:e},Z=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,S=new RegExp(`^${Z.source}$`),z=new RegExp(`^cart_${Z.source}$`),O=/^[a-zA-Z0-9]{2,}$/,L=/^cart_[a-zA-Z0-9]{2,}$/,b=o=>o?o.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:L.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:O.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:z.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:S.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},I=async({cartId:o,retries:e})=>{const t=n(),{errors:r,json:s}=await f("/api/zonos-elements/get-temp-cart",{body:{isTestMode:t,options:{noOnlineStoreSettings:!0},tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&e?(p("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:e}),await new Promise((o=>setTimeout(o,500))),I({cartId:o,retries:e-1})):i?null:s};var C;const U=(()=>{const o=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||o)return null;const e=v(window.location.href),n="https://v1.3.165.js.zonos.com";if(!e&&(n.includes("test.")||n.includes("test-")))return n;if(!e&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!e)return null;if("dev-elements"===e)return"https://dev.elements.zonos.com";const t=`https://${e}.preview.js.zonos.com`;return p(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const o=new URLSearchParams(window.location.search);o.delete("zonosQaUrl");const{pathname:e}=window.location,n=`${e}?${o.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null})),t})(),j=(()=>{const o=(o=>{if(!o)return null;const e=new URL(o).searchParams.get("zonosQaUrlApi");return e?/[^a-zA-Z0-9-_]+/.test(e)?null:e:null})(window.location.href),e=v(window.location.href),n=o||e;if(!n&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.demo.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.demo.elements.zonos.com";if(!o)return null;const t=`https://${o}.route.js.zonos.com`;return p(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})();class k{}C=k,k.isNpm=!1,k.isBigCommerce=!1,k.requested=!1,k.cartData=null,k.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,k.version="v1.3.165",k.isLegacyCheckout=!1,k.legacyStoreLogo=null,k.legacyStoreFavicon=null,k.parallelLoadTimes=[],k.parallelLoadState="off",k.releaseDate="1740583862303",k.loadScriptLogHandler=async({cdnLoadTime:o,fallbackLoadTime:e,isError:n,metadata:t,scriptLoadUrl:r,storeId:s,type:i})=>{try{const o=window.performance.getEntriesByType("resource").find((o=>{const e=o;return e.name.includes(r)&&"script"===e.initiatorType}));null==o||o.transferSize;(async o=>{})((o&&(null==o?void 0:o.duration)>0?parseFloat(o.duration.toFixed(2)):parseFloat(e.toFixed(2)),Object.assign({decodedBodySize:null==o?void 0:o.decodedBodySize,encodedBodySize:null==o?void 0:o.encodedBodySize,fallbackLoadTime:e,isError:!!n},t)))}catch(o){}},k.loadScriptLogParallelHandler=async o=>{try{if(C.parallelLoadTimes.push(o),2===C.parallelLoadTimes.length){const o=C.parallelLoadTimes.find((o=>"vercel"===o.type)),e=C.parallelLoadTimes.find((o=>"jsdelivr"===o.type));if(!o||!e)return;if(o.isError&&e.isError)return void u({endpoint:`<${o.scriptLoadUrl}> <${e.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:e.fallbackLoadTime,cdnType:e.type,vercelLoadTime:o.fallbackLoadTime}});C.loadScriptLogHandler({cdnLoadTime:e.fallbackLoadTime,fallbackLoadTime:o.fallbackLoadTime,isError:o.isError,metadata:{cdnScriptFallbackTime:e.fallbackLoadTime,cdnScriptIsError:!!e.isError,cdnScriptLoadUrl:e.scriptLoadUrl,cdnScriptType:e.type},scriptLoadUrl:o.scriptLoadUrl,storeId:o.storeId,type:o.type})}}catch(o){}},k.legacyCheckoutErrorHandler=({message:o,metadata:e})=>{y(`[ZONOS - loadZonos] ${o}`),u({endpoint:"LegacyCheckoutInit",errors:[o],metadata:Object.assign(Object.assign({},e),{tempCartUUID:C.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:o}))},k.getGithubCdn=({type:o,version:e})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.165";"cdnjs"===o?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.165":"unpkg"===o&&(n="https://unpkg.com/@zonos/elements@1.3.165");return e&&"alpha"!==e?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${e}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${e}`):n},k.injectZonos=({cdnType:o="jsdelivr",initConfig:e,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;e=Object.assign(Object.assign({},e),{zonosApiKey:C.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===o?t:C.getGithubCdn({type:o,version:r}),a=U||i,d=a.replace("https://","").replace("http://",""),c=document.createElement("script"),l=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";c.src=`https://${d}/dist/scripts/${l}?timestamp=${Date.now()}`,p(`[ZONOS - loadZonos] Injecting "${l}" from "${d}"`,"info");const m="4g"===(null===(s=(()=>{const o="connection"in window.navigator?window.navigator.connection:null,e="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return o||e||n})())||void 0===s?void 0:s.effectiveType),w=["dev.elements.zonos.com","zonos.com"].some((o=>window.location.href.includes(o))),g=h[0]===o,f=h[1],y="on"===C.parallelLoadState&&m&&g&&f&&!w;y&&C.injectZonos({cdnType:f,initConfig:e,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();c.addEventListener("load",(()=>{if(y||n?C.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:c.src,storeId:C.storeId,type:o}):C.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:c.src,storeId:C.storeId,type:o}),C.isBigCommerce||(C.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=U,window.Zonos.zonosQaUrlApi=j,window.Zonos.isBigCommerce=C.isBigCommerce,C.cartId){if(!C.zonosApiKey)throw C.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!C.cartData)throw C.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(C.legacyStoreFavicon&&C.isLegacyCheckout){const o=document.createElement("link");o.rel="shortcut icon",o.type="image/x-icon",o.href=C.legacyStoreFavicon,document.head.appendChild(o)}window.Zonos.cartData=C.cartData,window.Zonos.isLegacyCheckout=C.isLegacyCheckout;const o=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:C.legacyStoreLogo||""}),zonosApiKey:C.zonosApiKey});e=o}window.Zonos.version&&(p(`[ZONOS - loadZonos] Execute "Zonos.init" from "${l}" from "${d}"`,"info"),window.Zonos.init(e))})),c.addEventListener("error",(async()=>{const s=(o=>{const e=h.indexOf(o);return h[e+1]||null})(o);if(!y&&!n){if(!s)return;C.injectZonos({cdnType:s,initConfig:e,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((o=>window.location.href.includes(o)))||U)return;if(y||n)return void C.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:c.src,storeId:C.storeId,type:o});["unpkg","cdnjs","vercel"].includes(o)?u({endpoint:c.src,errors:[`zonos.js - Failed to fetch ${o} CDN.`],metadata:{cdnLoadTime:performance.now()-v,cdnType:o,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):u({endpoint:c.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:o,vercelLoadTime:performance.now()-v}})})),document.head.appendChild(c)},k.init=async o=>{var t;if(p("=== Init zonos script release date","info",C.releaseDate),U&&!window.isZonosPreview){p(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${U}`,"info");const e=document.createElement("script");return e.src=`${U}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=C.isBigCommerce,window.Zonos.isLegacyCheckout=C.isLegacyCheckout,window.Zonos.init(o)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${U}`)})),void(window.isZonosPreview=!0)}const r=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:s,isLegacyCartId:i}=b(r);if(r&&!i&&!s)return void C.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${r}`,metadata:{invalidCartId:!0}});C.cartId=r;const a="https://v1.3.165.js.zonos.com",d=document.querySelector('script[src*="/zonos.js"]'),c=null===(t=document.querySelector("script[src*='/loadZonos.js']"))||void 0===t?void 0:t.src;p(`[ZONOS - init] first load script src: ${c}`,"info"),window.Zonos.zonosQaUrl=U,window.Zonos.zonosQaUrlApi=j,window.Zonos.zonosQaUrl&&p(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&p(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const l=null==c?void 0:c.includes("timestamp=");if(!(C.isNpm||c&&l))return void y("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(d||!c||C.requested)return void p("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!C.cartId)return C.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void y("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(C.requested=!0,C.zonosApiKey=o.zonosApiKey,C.storeId=o.storeId,C.cartId){const o=await(async o=>{const{isDgsCartId:e,isLegacyCartId:n}=b(o);if(!n&&!e)return y("[ZONOS - loadZonos] invalid cart id"),null;const t=await I({cartId:o,retries:5});return p("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,{cartData:t.cartData,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(y("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(C.cartId);if(!o)throw C.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");C.cartData=o.cartData,C.legacyStoreLogo=o.storeLogo,C.legacyStoreFavicon=o.storeFavicon,C.storeId=o.storeId,C.zonosApiKey=o.zonosApiKey}if(!C.zonosApiKey)return void y('"zonosApiKey" is required to initialize Zonos');const u=await(async()=>{const o=n(),t=e();if(!o&&!t||!window.Zonos.zonosApiKey)return null;if(p("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return p("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:s}=await f("/api/get-test-public-credential");if(r.length||!s)return y("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const i=s.publicCredential;return i?(p(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(y("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(u&&(p(`[ZONOS - loadZonos] Using test API key: ${u} for test mode`,"info"),C.zonosApiKey=u),!C.storeId)return p("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void C.injectZonos({initConfig:o,vercelUrl:a,version:null});const m=C.storeId||o.storeId;p(`[ZONOS - loadZonos] Store ID: ${m}`,"info");const w=new URLSearchParams;w.set("storeId",m.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&w.set("_enableStoreVersionPinned","1");const{errors:g,json:h}=await f(`/api/get-store-version?${w.toString()}`);if(g.length||!h)return p("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void C.injectZonos({initConfig:o,vercelUrl:a,version:null});const{isDifferent:v,source:Z,version:S}=h;if(p(`[ZONOS - loadZonos] Store version: ${S}, source: ${Z}`,"info"),v){p(`[ZONOS - loadZonos] Updating saved store version to ${S}`,"info");const o={storeId:m,version:S};f(`/api/set-store-version?${w.toString()}`,{body:o,method:"POST"}).catch((o=>y("Unable to save store's vesrion",o)))}if(!d){const{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t}=(({loadScriptSrc:o})=>{if(!o)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const e=new URL(o).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((o=>e.includes(o))),t=["qa.js.zonos.com"].some((o=>e.includes(o)));return{currentLoadScriptUrl:e,isForceLoadVersionDomain:t,isWhiteListed:n}})({loadScriptSrc:c}),r=t&&!n?e:`${"alpha"===S?"alpha":`v${S}`}.js.zonos.com`,s=t&&!n?null:S;p("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:S}),C.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview&&!window.Zonos.doneInit)&&(window.Zonos=k)})();
@@ -1 +1 @@
1
- (function(){"use strict";const e=performance.now(),o=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},t=(t,n,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const o=performance.now()-e,t=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:t}})(),c=[`(${a})`,...r];c.map(o).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(t,...c));let l=document.querySelector("iframe#zonos---debug-logging-iframe");l||(l=document.createElement("iframe"),l.id="zonos---debug-logging-iframe",l.style.display="none",l.style.opacity="0",l.style.position="absolute",l.style.top="-9999px",l.style.left="-9999px",l.style.width="1px",l.style.height="1px",l.style.border="none",l.style.overflow="hidden",l.style.visibility="hidden",document.body.appendChild(l));const d=(null===(i=l.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...c);break;case"info":d.info(t,...c);break;case"error":d.error(t,...c);break;default:d.groupCollapsed(t,...c),d.trace(),d.groupEnd()}},n=(e,...o)=>{t(e,"error",...o)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const o=r.indexOf(e);return r[o+1]||null},a=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function l(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const d=["cloudflare","vercel"],u=d[0],p={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},m=p[u],w=(e=u)=>{const o=d.indexOf(e),t=d[o+1];return t||null},y=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},h=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=y(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},f=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||p[e]||u,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&c&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await h({response:n}),response:n,zonosMode:a}}const l=n.status.toString();try{const e=await h({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:l}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:l}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${l}: ${"Unknown error"}`,type:l}],json:null,response:null,zonosMode:a}}},g=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=await f({basePathType:i,options:o,path:n}),{errors:c,response:d}=a,u=l(a,["errors","response"]),h=w(i),v=!!c.find((({type:e})=>"unknown"===e))||404===(null==d?void 0:d.status),b=h&&v;return v&&(async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(t("sendErrorLog","warn",e,n,o),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:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${m}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=w();if(!o)return;fetch(`${p[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:p[i]+n,errors:c.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:h,requestHeaders:null==o?void 0:o.headers,requestPayload:y(null===(r=null==o?void 0:o.body)||void 0===r?void 0:r.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==d?void 0:d.status,statusText:null==d?void 0:d.statusText},shouldPostReleaseErrorReporting:!0}),b?(t(`=== "${n}" failed to fetch, trying next fallback ${h}`),g({basePathType:h,options:o,path:n})):Object.assign({errors:c,response:d},u)},v=async(e,o)=>{const n=l(o||{},[]),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-Staging-Mode":a()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(i).forEach((e=>void 0===i[e]&&delete i[e]));const d=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),p=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),g({basePathType:p||u,options:d,path:e})},b=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),n="https://v1.3.163.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const r=`https://${o}.preview.js.zonos.com`;return t(`[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:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),r},S="https://js.stripe.com/v3",z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,C="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let Z=null;const j=e=>(null!==Z||(Z=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(C),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${S}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&z.test(t.src))return t}return null})();r&&e?console.warn(C):r||(r=(e=>{const o=document.createElement("script");o.src=`${S}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),Z),O=Promise.resolve().then((()=>j(null)));let k=!1;O.catch((e=>{k||console.warn(e)}));const I=async({cartId:e,retries:o})=>{const n=c(),{errors:r,json:s}=await v("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,options:{noOnlineStoreSettings:!0},tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),I({cartId:e,retries:o-1})):i?null:s},A=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${A.source}$`),L=new RegExp(`^cart_${A.source}$`),$=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,T=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:L.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:E.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!r&&!o)return n("[ZONOS - loadZonos] invalid cart id"),null;const s=await I({cartId:e,retries:5});return t("[ZONOS - loadZonos] getting temp cart data","info",s),s?(window.Zonos.storeId=s.cartData.storeId,window.Zonos.zonosApiKey=s.cartData.credentialToken,{cartData:s.cartData,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var U;const P=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),n=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),D="https://v1.3.163.js.zonos.com",F=P||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.163",R="https://fonts.googleapis.com",x=/^https:\/\/fonts\.googleapis\.com/;class M{}U=M,M.doneInit=!1,M.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),M.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),M._paypalMockResponse=null,M.isBigCommerce=!1,M.releaseDate="1740498125505",M.isLegacyCheckout=!1,M.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",M.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),M.isNpm=!0,M.zonosQaUrl=null,M.zonosQaUrlApi=null,M.version="v1.3.163",M.modeAlerted=!1,M.cartData=null,M.paypal=null,M.getCurrentTimestamp=()=>(new Date).getTime(),M.zonosController=null,M.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:d,storeId:u,zonosApiKey:p}=e;if(U.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),U.doneInit)return;if(t(`====== ZONOS DEBUG MODE: on (${U.version}) ======`),U.zonosApiKey=p,U.storeId=u,U.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=b();if(o&&!window.isZonosPreview){t(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const n=document.createElement("script");return n.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=U.isNpm,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!U.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!U.cartData&&U.cartId){t("Initialize cart data");const e=await T(U.cartId);if(!e)return void n("Failed to get cart data");U.cartData=e.cartData,U.zonosApiKey=e.zonosApiKey}const r=await(async()=>{const e=c(),o=a();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:s}=await v("/api/get-test-public-credential");if(r.length||!s)return n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const i=s.publicCredential;return i?(t(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(n("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();r&&(U.zonosApiKey=r)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(U.cartId&&U.cartData||!!m){t("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}t("init zonos"),U.restoreNativeBrowserFunctions(),U.injectCustomScriptForHostedCheckout(),U.injectZonosCdn(),U.injectZonosCss(),U.injectFonts(),U.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:d}}),U.doneInit=!0},M.injectCustomScriptForHostedCheckout=()=>{const e=U.cartData,o=(null==e?void 0:e.metadata)||[],n=o.find((e=>"customHeaderScript"===e.key)),r=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(n||r)){if(n){t("Injecting custom header script");const e=document.createElement("script");e.textContent=n.value,document.head.appendChild(e)}if(r){t("Injecting custom footer script");const e=document.createElement("script");e.textContent=r.value,document.body.appendChild(e)}}else t("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:n,isLegacyCheckout:window.Zonos.isLegacyCheckout})},M.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},M.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},M.showNotification=e=>{var o;null===(o=U.zonosController)||void 0===o||o.showNotification(e)},M.updateOrganizationName=e=>{var o;null===(o=U.zonosController)||void 0===o||o.updateOrganizationName(e)},M.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},M.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},M.injectController=({config:e})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;U.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{U.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=U.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{k=!0;const o=Date.now();return O.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.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),U.zonosController=r,t("Zonos controller injected!")},M.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${U.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const a=document.head||document.body,c=document.createElement("script");o?c.type="module":c.noModule=!0,c.src=s,c.crossOrigin="anonymous",c.onerror=()=>{n(`Failed to load ${c.src}`);const t=i(e);t&&U.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(c)},M.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return F;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.163";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.163";case"vercel":return D}};if(U.isNpm){return b()||o()}return o()},M.injectZonosCdn=()=>{U.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),U.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},M.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=U.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${D}/`,r.appendChild(s);const a=document.createElement("link");a.rel="stylesheet",a.href=`${t}/${o}`,a.onerror=()=>{n(`Failed to load ${a.href}`);const t=i(e);t&&U.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},M.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(U.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},M.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void t("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${R}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!x.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=R,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${R}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(n),t("Zonos font injected!")},M.setupGoogleFont=e=>{var o;null===(o=U.zonosController)||void 0===o||o.setupGoogleFont(e)},M.injectSupportGoogleFont=e=>{var o;t(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${R}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=R,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),t(`[FONT] ${n} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=M)})();
1
+ (function(){"use strict";const e=performance.now(),o=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},t=(t,n,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const o=performance.now()-e,t=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:t}})(),c=[`(${a})`,...r];c.map(o).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(t,...c));let l=document.querySelector("iframe#zonos---debug-logging-iframe");l||(l=document.createElement("iframe"),l.id="zonos---debug-logging-iframe",l.style.display="none",l.style.opacity="0",l.style.position="absolute",l.style.top="-9999px",l.style.left="-9999px",l.style.width="1px",l.style.height="1px",l.style.border="none",l.style.overflow="hidden",l.style.visibility="hidden",document.body.appendChild(l));const d=(null===(i=l.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...c);break;case"info":d.info(t,...c);break;case"error":d.error(t,...c);break;default:d.groupCollapsed(t,...c),d.trace(),d.groupEnd()}},n=(e,...o)=>{t(e,"error",...o)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const o=r.indexOf(e);return r[o+1]||null},a=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function l(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const d=["cloudflare","vercel"],u=d[0],p={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},m=p[u],w=(e=u)=>{const o=d.indexOf(e),t=d[o+1];return t||null},y=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},h=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=y(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},f=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||p[e]||u,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&c&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await h({response:n}),response:n,zonosMode:a}}const l=n.status.toString();try{const e=await h({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:l}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:l}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${l}: ${"Unknown error"}`,type:l}],json:null,response:null,zonosMode:a}}},g=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=await f({basePathType:i,options:o,path:n}),{errors:c,response:d}=a,u=l(a,["errors","response"]),h=w(i),v=!!c.find((({type:e})=>"unknown"===e))||404===(null==d?void 0:d.status),b=h&&v;return v&&(async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(t("sendErrorLog","warn",e,n,o),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:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${m}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=w();if(!o)return;fetch(`${p[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:p[i]+n,errors:c.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:h,requestHeaders:null==o?void 0:o.headers,requestPayload:y(null===(r=null==o?void 0:o.body)||void 0===r?void 0:r.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==d?void 0:d.status,statusText:null==d?void 0:d.statusText},shouldPostReleaseErrorReporting:!0}),b?(t(`=== "${n}" failed to fetch, trying next fallback ${h}`),g({basePathType:h,options:o,path:n})):Object.assign({errors:c,response:d},u)},v=async(e,o)=>{const n=l(o||{},[]),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-Staging-Mode":a()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(i).forEach((e=>void 0===i[e]&&delete i[e]));const d=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),p=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),g({basePathType:p||u,options:d,path:e})},b=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),n="https://v1.3.165.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const r=`https://${o}.preview.js.zonos.com`;return t(`[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:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),r},S="https://js.stripe.com/v3",z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,C="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let Z=null;const j=e=>(null!==Z||(Z=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(C),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${S}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&z.test(t.src))return t}return null})();r&&e?console.warn(C):r||(r=(e=>{const o=document.createElement("script");o.src=`${S}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),Z),O=Promise.resolve().then((()=>j(null)));let k=!1;O.catch((e=>{k||console.warn(e)}));const I=async({cartId:e,retries:o})=>{const n=c(),{errors:r,json:s}=await v("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,options:{noOnlineStoreSettings:!0},tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),I({cartId:e,retries:o-1})):i?null:s},A=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${A.source}$`),L=new RegExp(`^cart_${A.source}$`),$=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,T=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:L.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:E.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!r&&!o)return n("[ZONOS - loadZonos] invalid cart id"),null;const s=await I({cartId:e,retries:5});return t("[ZONOS - loadZonos] getting temp cart data","info",s),s?(window.Zonos.storeId=s.cartData.storeId,window.Zonos.zonosApiKey=s.cartData.credentialToken,{cartData:s.cartData,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var U;const P=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),n=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),D="https://v1.3.165.js.zonos.com",F=P||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.165",R="https://fonts.googleapis.com",x=/^https:\/\/fonts\.googleapis\.com/;class M{}U=M,M.doneInit=!1,M.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),M.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),M._paypalMockResponse=null,M.isBigCommerce=!1,M.releaseDate="1740583862303",M.isLegacyCheckout=!1,M.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",M.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),M.isNpm=!0,M.zonosQaUrl=null,M.zonosQaUrlApi=null,M.version="v1.3.165",M.modeAlerted=!1,M.cartData=null,M.paypal=null,M.getCurrentTimestamp=()=>(new Date).getTime(),M.zonosController=null,M.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:d,storeId:u,zonosApiKey:p}=e;if(U.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),U.doneInit)return;if(t(`====== ZONOS DEBUG MODE: on (${U.version}) ======`),U.zonosApiKey=p,U.storeId=u,U.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=b();if(o&&!window.isZonosPreview){t(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const n=document.createElement("script");return n.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=U.isNpm,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!U.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!U.cartData&&U.cartId){t("Initialize cart data");const e=await T(U.cartId);if(!e)return void n("Failed to get cart data");U.cartData=e.cartData,U.zonosApiKey=e.zonosApiKey}const r=await(async()=>{const e=c(),o=a();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:s}=await v("/api/get-test-public-credential");if(r.length||!s)return n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const i=s.publicCredential;return i?(t(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(n("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();r&&(U.zonosApiKey=r)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(U.cartId&&U.cartData||!!m){t("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}t("init zonos"),U.restoreNativeBrowserFunctions(),U.injectCustomScriptForHostedCheckout(),U.injectZonosCdn(),U.injectZonosCss(),U.injectFonts(),U.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:l,overrideCurrencyFormat:d}}),U.doneInit=!0},M.injectCustomScriptForHostedCheckout=()=>{const e=U.cartData,o=(null==e?void 0:e.metadata)||[],n=o.find((e=>"customHeaderScript"===e.key)),r=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(n||r)){if(n){t("Injecting custom header script");const e=document.createElement("script");e.textContent=n.value,document.head.appendChild(e)}if(r){t("Injecting custom footer script");const e=document.createElement("script");e.textContent=r.value,document.body.appendChild(e)}}else t("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:n,isLegacyCheckout:window.Zonos.isLegacyCheckout})},M.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},M.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},M.showNotification=e=>{var o;null===(o=U.zonosController)||void 0===o||o.showNotification(e)},M.updateOrganizationName=e=>{var o;null===(o=U.zonosController)||void 0===o||o.updateOrganizationName(e)},M.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},M.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},M.injectController=({config:e})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;U.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{U.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=U.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{k=!0;const o=Date.now();return O.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.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),U.zonosController=r,t("Zonos controller injected!")},M.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${U.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const a=document.head||document.body,c=document.createElement("script");o?c.type="module":c.noModule=!0,c.src=s,c.crossOrigin="anonymous",c.onerror=()=>{n(`Failed to load ${c.src}`);const t=i(e);t&&U.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(c)},M.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return F;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.165";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.165";case"vercel":return D}};if(U.isNpm){return b()||o()}return o()},M.injectZonosCdn=()=>{U.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),U.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},M.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=U.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${D}/`,r.appendChild(s);const a=document.createElement("link");a.rel="stylesheet",a.href=`${t}/${o}`,a.onerror=()=>{n(`Failed to load ${a.href}`);const t=i(e);t&&U.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},M.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(U.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},M.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void t("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${R}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!x.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=R,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${R}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(n),t("Zonos font injected!")},M.setupGoogleFont=e=>{var o;null===(o=U.zonosController)||void 0===o||o.setupGoogleFont(e)},M.injectSupportGoogleFont=e=>{var o;t(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${R}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=R,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),t(`[FONT] ${n} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=M)})();
@@ -23,6 +23,10 @@ type StripeStore = {
23
23
  */
24
24
  checkoutSettlementCurrency: CurrencyCode;
25
25
  clientSecret: string;
26
+ /**
27
+ * Optional company name
28
+ */
29
+ companyName: string;
26
30
  /**
27
31
  * Custom error message when payment is failed
28
32
  */
@@ -65,6 +65,9 @@ export declare const stringsArabic: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsBase: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsChinese: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsDanish: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsDutch: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsFrench: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsGerman: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsHebrew: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsIndonesian: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsItalian: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsJapanese: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsKorean: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsNorwegian: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsPolish: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsPortuguese: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsRussian: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsSpanish: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsSwedish: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsTurkish: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -65,6 +65,9 @@ export declare const stringsVietnamese: {
65
65
  Close: {
66
66
  value: string;
67
67
  };
68
+ 'Company name (optional)': {
69
+ value: string;
70
+ };
68
71
  Contact: {
69
72
  value: string;
70
73
  };
@@ -32,6 +32,7 @@ export declare class ZonosAddress {
32
32
  private updateAddressElement;
33
33
  watchInitStripe(): Promise<void>;
34
34
  defaultAddressChanged(): void;
35
+ private renderCompanyNameInput;
35
36
  disconnectedCallback(): void;
36
37
  componentDidLoad(): void;
37
38
  render(): any;
@@ -41,6 +41,7 @@ export type CalculateLandedCostRequest = {
41
41
  };
42
42
  checkoutSessionId: string;
43
43
  contact: {
44
+ companyName?: string;
44
45
  email?: string;
45
46
  firstName: string;
46
47
  lastName: string;
@@ -93,6 +94,7 @@ export type CartCalculateLandedCostRequest = {
93
94
  cartId: string;
94
95
  checkoutSessionId: string;
95
96
  contact: {
97
+ companyName?: string;
96
98
  email?: string;
97
99
  firstName: string;
98
100
  lastName: string;