@zonos/elements 1.3.139 → 1.3.141

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 (149) hide show
  1. package/dist/cjs/{cart-0070bff2.js → cart-e1b59d03.js} +180 -1
  2. package/dist/cjs/index.cjs.js +41 -13
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{paypal-7c8a99b0.js → paypal-86cc51e4.js} +13 -1
  5. package/dist/cjs/zonos-address_7.cjs.entry.js +1 -1
  6. package/dist/cjs/zonos-cart-items_13.cjs.entry.js +49 -7
  7. package/dist/cjs/zonos-checkout.cjs.entry.js +5 -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-hello-dialog.cjs.entry.js +1 -1
  13. package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
  14. package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
  15. package/dist/cjs/zonos-notification_3.cjs.entry.js +2 -2
  16. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-payment/zonos-checkout-payment.js +24 -2
  17. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +4 -2
  18. package/dist/collection/components/common/zonos-checkout-progress-tabs/zonos-checkout-progress-tabs.js +11 -4
  19. package/dist/collection/components/hello/zonos-hello/zonos-hello.js +1 -1
  20. package/dist/collection/components/store/checkout/paypal.js +14 -1
  21. package/dist/collection/components/store/checkout/stripe.js +9 -0
  22. package/dist/collection/components/store/hello/localization.js +3 -1
  23. package/dist/collection/components/store/translationStore/strings.arabic.js +6 -0
  24. package/dist/collection/components/store/translationStore/strings.base.js +6 -0
  25. package/dist/collection/components/store/translationStore/strings.chinese.js +6 -0
  26. package/dist/collection/components/store/translationStore/strings.danish.js +6 -0
  27. package/dist/collection/components/store/translationStore/strings.dutch.js +6 -0
  28. package/dist/collection/components/store/translationStore/strings.french.js +6 -0
  29. package/dist/collection/components/store/translationStore/strings.german.js +6 -0
  30. package/dist/collection/components/store/translationStore/strings.hebrew.js +6 -0
  31. package/dist/collection/components/store/translationStore/strings.indonesian.js +6 -0
  32. package/dist/collection/components/store/translationStore/strings.italian.js +6 -0
  33. package/dist/collection/components/store/translationStore/strings.japanese.js +6 -0
  34. package/dist/collection/components/store/translationStore/strings.korean.js +6 -0
  35. package/dist/collection/components/store/translationStore/strings.norwegian.js +6 -0
  36. package/dist/collection/components/store/translationStore/strings.polish.js +6 -0
  37. package/dist/collection/components/store/translationStore/strings.portuguese.js +6 -0
  38. package/dist/collection/components/store/translationStore/strings.russian.js +6 -0
  39. package/dist/collection/components/store/translationStore/strings.spanish.js +6 -0
  40. package/dist/collection/components/store/translationStore/strings.swedish.js +6 -0
  41. package/dist/collection/components/store/translationStore/strings.turkish.js +6 -0
  42. package/dist/collection/components/store/translationStore/strings.vietnamese.js +6 -0
  43. package/dist/collection/components/utils/api/getCheckoutSession.js +14 -0
  44. package/dist/collection/components/utils/resetToSelectedTab.js +17 -0
  45. package/dist/collection/components/utils/validateCheckoutSession.js +39 -0
  46. package/dist/collection/scripts/_zonosBase.js +34 -6
  47. package/dist/esm/{cart-e5fb3abe.js → cart-709f053f.js} +181 -3
  48. package/dist/esm/index.js +41 -13
  49. package/dist/esm/loader.js +1 -1
  50. package/dist/esm/{paypal-9636651e.js → paypal-77a60c44.js} +13 -1
  51. package/dist/esm/zonos-address_7.entry.js +1 -1
  52. package/dist/esm/zonos-cart-items_13.entry.js +49 -7
  53. package/dist/esm/zonos-checkout.entry.js +5 -3
  54. package/dist/esm/zonos-controller.entry.js +1 -1
  55. package/dist/esm/zonos-country-flag.entry.js +1 -1
  56. package/dist/esm/zonos-country-select_4.entry.js +1 -1
  57. package/dist/esm/zonos-elements.js +1 -1
  58. package/dist/esm/zonos-hello-dialog.entry.js +1 -1
  59. package/dist/esm/zonos-hello.entry.js +2 -2
  60. package/dist/esm/zonos-language-select_2.entry.js +1 -1
  61. package/dist/esm/zonos-notification_3.entry.js +2 -2
  62. package/dist/esm-es5/cart-709f053f.js +1 -0
  63. package/dist/esm-es5/index.js +1 -1
  64. package/dist/esm-es5/loader.js +1 -1
  65. package/dist/esm-es5/paypal-77a60c44.js +17 -0
  66. package/dist/esm-es5/zonos-address_7.entry.js +1 -1
  67. package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
  68. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  69. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  70. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  71. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  72. package/dist/esm-es5/zonos-elements.js +1 -1
  73. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  74. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  75. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  76. package/dist/esm-es5/zonos-notification_3.entry.js +1 -1
  77. package/dist/scripts/index.d.ts +1 -0
  78. package/dist/scripts/index.js +1 -1
  79. package/dist/scripts/loadZonos.js +1 -1
  80. package/dist/scripts/zonos.js +1 -1
  81. package/dist/types/components/checkout/zonos-checkout/zonos-checkout-payment/zonos-checkout-payment.d.ts +6 -0
  82. package/dist/types/components/store/checkout/stripe.d.ts +4 -0
  83. package/dist/types/components/store/translationStore/strings.arabic.d.ts +6 -0
  84. package/dist/types/components/store/translationStore/strings.base.d.ts +6 -0
  85. package/dist/types/components/store/translationStore/strings.chinese.d.ts +6 -0
  86. package/dist/types/components/store/translationStore/strings.danish.d.ts +6 -0
  87. package/dist/types/components/store/translationStore/strings.dutch.d.ts +6 -0
  88. package/dist/types/components/store/translationStore/strings.french.d.ts +6 -0
  89. package/dist/types/components/store/translationStore/strings.german.d.ts +6 -0
  90. package/dist/types/components/store/translationStore/strings.hebrew.d.ts +6 -0
  91. package/dist/types/components/store/translationStore/strings.indonesian.d.ts +6 -0
  92. package/dist/types/components/store/translationStore/strings.italian.d.ts +6 -0
  93. package/dist/types/components/store/translationStore/strings.japanese.d.ts +6 -0
  94. package/dist/types/components/store/translationStore/strings.korean.d.ts +6 -0
  95. package/dist/types/components/store/translationStore/strings.norwegian.d.ts +6 -0
  96. package/dist/types/components/store/translationStore/strings.polish.d.ts +6 -0
  97. package/dist/types/components/store/translationStore/strings.portuguese.d.ts +6 -0
  98. package/dist/types/components/store/translationStore/strings.russian.d.ts +6 -0
  99. package/dist/types/components/store/translationStore/strings.spanish.d.ts +6 -0
  100. package/dist/types/components/store/translationStore/strings.swedish.d.ts +6 -0
  101. package/dist/types/components/store/translationStore/strings.turkish.d.ts +6 -0
  102. package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +6 -0
  103. package/dist/types/components/store/translationStore.d.ts +1 -1
  104. package/dist/types/components/utils/api/getCheckoutSession.d.ts +9 -0
  105. package/dist/types/components/utils/resetToSelectedTab.d.ts +12 -0
  106. package/dist/types/components/utils/validateCheckoutSession.d.ts +9 -0
  107. package/dist/types/scripts/_zonosBase.d.ts +1 -0
  108. package/dist/types/types/checkout/api/CheckoutSession.d.ts +5 -1
  109. package/dist/types/types/generated/graphql.internal.types.d.ts +112 -0
  110. package/dist/types/types/generated/graphql.internal.types.ts +102 -1
  111. package/dist/zonos-elements/index.esm.js +1 -1
  112. package/dist/zonos-elements/{p-85545d0b.system.entry.js → p-01ad5be8.system.entry.js} +1 -1
  113. package/dist/zonos-elements/p-0c027d2e.entry.js +1 -0
  114. package/dist/zonos-elements/{p-d66cbed3.system.entry.js → p-1c4ff7b2.system.entry.js} +1 -1
  115. package/dist/zonos-elements/{p-30f75fc0.system.entry.js → p-22d69480.system.entry.js} +1 -1
  116. package/dist/zonos-elements/{p-3316bcb0.system.entry.js → p-25c7e4fa.system.entry.js} +1 -1
  117. package/dist/zonos-elements/{p-456d8ac3.system.entry.js → p-289ded20.system.entry.js} +1 -1
  118. package/dist/zonos-elements/{p-f8d7bad6.entry.js → p-35b8dcde.entry.js} +1 -1
  119. package/dist/zonos-elements/{p-daf800c5.system.entry.js → p-49e4ca08.system.entry.js} +1 -1
  120. package/dist/zonos-elements/{p-d374ef35.system.entry.js → p-64a04391.system.entry.js} +1 -1
  121. package/dist/zonos-elements/p-6b0aa1bb.system.js +17 -0
  122. package/dist/zonos-elements/{p-59f7cc80.entry.js → p-8368a79e.entry.js} +1 -1
  123. package/dist/zonos-elements/{p-e176da08.system.entry.js → p-896d62a4.system.entry.js} +1 -1
  124. package/dist/zonos-elements/p-8f9affb3.system.entry.js +1 -0
  125. package/dist/zonos-elements/p-a58731ec.system.js +1 -0
  126. package/dist/zonos-elements/{p-9138a10d.entry.js → p-ad1d6ea2.entry.js} +1 -1
  127. package/dist/zonos-elements/p-afffdfc2.js +1 -0
  128. package/dist/zonos-elements/{p-3f71bac6.entry.js → p-b832ec52.entry.js} +1 -1
  129. package/dist/zonos-elements/{p-0931f518.entry.js → p-b9efc660.entry.js} +1 -1
  130. package/dist/zonos-elements/p-be2feba6.entry.js +1 -0
  131. package/dist/zonos-elements/p-c78dd680.system.js +1 -1
  132. package/dist/zonos-elements/{p-244fe3a1.system.entry.js → p-cf72603f.system.entry.js} +1 -1
  133. package/dist/zonos-elements/p-d35376d3.js +17 -0
  134. package/dist/zonos-elements/{p-035571bf.entry.js → p-e6c31531.entry.js} +1 -1
  135. package/dist/zonos-elements/{p-99190477.entry.js → p-f2867195.entry.js} +1 -1
  136. package/dist/zonos-elements/{p-d58b6247.entry.js → p-f8ca3e71.entry.js} +1 -1
  137. package/dist/zonos-elements/p-f8e8b50e.system.js +1 -0
  138. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  139. package/package.json +2 -1
  140. package/dist/esm-es5/cart-e5fb3abe.js +0 -1
  141. package/dist/esm-es5/paypal-9636651e.js +0 -17
  142. package/dist/zonos-elements/p-1037c75b.system.js +0 -1
  143. package/dist/zonos-elements/p-4e4a45cb.js +0 -17
  144. package/dist/zonos-elements/p-75048606.system.js +0 -1
  145. package/dist/zonos-elements/p-79a8c9ef.system.js +0 -17
  146. package/dist/zonos-elements/p-b7652a21.system.entry.js +0 -1
  147. package/dist/zonos-elements/p-e3112267.entry.js +0 -1
  148. package/dist/zonos-elements/p-f64e4276.js +0 -1
  149. package/dist/zonos-elements/p-f66fbfe8.entry.js +0 -1
@@ -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=["cloudflare","vercel"],n=e[0],t={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},r=t[n],s=(o=n)=>{const t=e.indexOf(o),r=e[t+1];return r||null},i=o=>{if("string"==typeof o)try{return JSON.parse(o)}catch(o){return null}return null},a=performance.now(),c=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"}},d=(o,e,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const o=performance.now()-a,e=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:e}})(),i=[`(${s})`,...n];i.map(c).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 d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const l=(null===(r=d.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(e){case"warn":l.warn(o,...i);break;case"info":l.info(o,...i);break;case"error":l.error(o,...i);break;default:l.groupCollapsed(o,...i),l.trace(),l.groupEnd()}},l=async({endpoint:o,errors:e,metadata:n,shouldPostReleaseErrorReporting:i})=>{if(d("sendErrorLog","warn",o,n,e),i){const o=Number(window.Zonos.releaseDate);if((new Date).getTime()-o>36e5)return}const a="userAgentData"in window.navigator?window.navigator.userAgentData:null,c={endpoint:o,errors:e,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:a&&a.brands.length>0?a:window.navigator.userAgent},n)};try{fetch(`${r}/api/zonos-elements/log-error`,{body:JSON.stringify(c),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(o){const e=s();if(!e)return;fetch(`${t[e]}/api/zonos-elements/log-error`,{body:JSON.stringify(c),method:"POST"})}},p=async({response:o,shouldLog:e=!0,shouldThrow:n=!1})=>{try{const e=await o.text(),n=i(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}},u=async({basePathType:o,options:e,path:r})=>{let s;const i=window.Zonos.zonosQaUrlApi||t[o]||n,a=new URL(i+r),c=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("")}})(c));try{s=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 d=s.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&d&&l&&(window.Zonos.modeAlerted=!0),s.ok){return{baseUrl:i,errors:[],json:await p({response:s}),response:s,zonosMode:d}}const u=s.status.toString();try{const o=await p({response:s,shouldThrow:!0});return{baseUrl:i,errors:[{message:JSON.stringify(o),type:u}],json:null,response:s,zonosMode:d}}catch(o){return{baseUrl:i,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:d}}},m=async({basePathType:e,options:n,path:r})=>{var a,c;const p=r.startsWith("/api/bigcommerce")?"vercel":e,w=await u({basePathType:p,options:n,path:r}),{errors:g,response:f}=w,y=o(w,["errors","response"]),h=s(p),v=!!g.find((({type:o})=>"unknown"===o))||404===(null==f?void 0:f.status),Z=h&&v;return v&&l({endpoint:t[p]+r,errors:g.map((({message:o})=>`API: ${o}`)),metadata:{currentBasePath:p,nextFallbackApiType:h,requestHeaders:null==n?void 0:n.headers,requestPayload:i(null===(a=null==n?void 0:n.body)||void 0===a?void 0:a.toString())||(null===(c=null==n?void 0:n.body)||void 0===c?void 0:c.toString()),status:null==f?void 0:f.status,statusText:null==f?void 0:f.statusText},shouldPostReleaseErrorReporting:!0}),Z?(d(`=== "${r}" failed to fetch, trying next fallback ${h}`),m({basePathType:h,options:n,path:r})):Object.assign({errors:g,response:f},y)},w=async(e,t)=>{const r=o(t||{},[]),s=r.body?JSON.stringify(r.body):void 0,i=r.method||"GET",a=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},r.headers),c=Object.assign(Object.assign({},r),{body:"GET"===i?void 0:s,headers:a,method:i}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return d(e,"info"),m({basePathType:l||n,options:c,path:e})},g=(o,...e)=>{d(o,"error",...e)},f=["jsdelivr","cdnjs","unpkg","vercel"],y=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},h=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,v=new RegExp(`^${h.source}$`),Z=new RegExp(`^cart_${h.source}$`),S=o=>o?Z.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:v.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},O=async({cartId:o,retries:e})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:t,json:r}=await w("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),s=!r||t.length;return s&&e?(d("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:e}),await new Promise((o=>setTimeout(o,500))),O({cartId:o,retries:e-1})):s?null:r};var z;const L=(()=>{const o=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||o)return null;const e=y(window.location.href),n="https://v1.3.139.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 d(`[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})(),b=(()=>{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=y(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 d(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})();class U{}z=U,U.isNpm=!1,U.isBigCommerce=!1,U.requested=!1,U.cartData=null,U.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,U.version="v1.3.139",U.isLegacyCheckout=!1,U.legacyStoreLogo=null,U.legacyStoreFavicon=null,U.parallelLoadTimes=[],U.parallelLoadState="off",U.releaseDate="1733763372917",U.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){}},U.loadScriptLogParallelHandler=async o=>{try{if(z.parallelLoadTimes.push(o),2===z.parallelLoadTimes.length){const o=z.parallelLoadTimes.find((o=>"vercel"===o.type)),e=z.parallelLoadTimes.find((o=>"jsdelivr"===o.type));if(!o||!e)return;if(o.isError&&e.isError)return void l({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}});z.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){}},U.legacyCheckoutErrorHandler=({message:o,metadata:e})=>{g(`[ZONOS - loadZonos] ${o}`),l({endpoint:"LegacyCheckoutInit",errors:[o],metadata:Object.assign(Object.assign({},e),{tempCartUUID:z.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:o}))},U.getGithubCdn=({type:o,version:e})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.139";"cdnjs"===o?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.139":"unpkg"===o&&(n="https://unpkg.com/@zonos/elements@1.3.139");return e&&"alpha"!==e?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${e}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${e}`):n},U.injectZonos=({cdnType:o="jsdelivr",initConfig:e,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;e=Object.assign(Object.assign({},e),{zonosApiKey:z.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===o?t:z.getGithubCdn({type:o,version:r}),a=L||i,c=a.replace("https://","").replace("http://",""),p=document.createElement("script"),u=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";p.src=`https://${c}/dist/scripts/${u}`,d(`[ZONOS - loadZonos] Injecting "${u}" from "${c}"`,"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=f[0]===o,y=f[1],h="on"===z.parallelLoadState&&m&&g&&y&&!w;h&&z.injectZonos({cdnType:y,initConfig:e,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();p.addEventListener("load",(()=>{var t;if(h||n?z.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:p.src,storeId:z.storeId,type:o}):z.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:p.src,storeId:z.storeId,type:o}),z.isBigCommerce||(z.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=L,window.Zonos.zonosQaUrlApi=b,window.Zonos.isBigCommerce=z.isBigCommerce,z.cartId){if(!z.zonosApiKey)throw z.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!z.cartData)throw z.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(z.legacyStoreFavicon&&z.isLegacyCheckout){const o=document.createElement("link");o.rel="shortcut icon",o.type="image/x-icon",o.href=z.legacyStoreFavicon,document.head.appendChild(o)}window.Zonos.cartData=z.cartData,window.Zonos.isLegacyCheckout=z.isLegacyCheckout;const o=z.isLegacyCheckout&&"CLOSE_MODAL"===(null===(t=e.checkoutSettings)||void 0===t?void 0:t.successBehavior),n=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:z.legacyStoreLogo||""}),checkoutSettings:Object.assign(Object.assign({},e.checkoutSettings),{successBehavior:o?"ZONOS_SUCCESS_PAGE":void 0,successRedirectUrl:o?z.cartData.storeBaseUrl:void 0}),zonosApiKey:z.zonosApiKey});e=n}window.Zonos.version&&(d(`[ZONOS - loadZonos] Execute "Zonos.init" from "${u}" from "${c}"`,"info"),window.Zonos.init(e))})),p.addEventListener("error",(async()=>{const s=(o=>{const e=f.indexOf(o);return f[e+1]||null})(o);if(!h&&!n){if(!s)return;z.injectZonos({cdnType:s,initConfig:e,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((o=>window.location.href.includes(o)))||L)return;if(h||n)return void z.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:p.src,storeId:z.storeId,type:o});["unpkg","cdnjs","vercel"].includes(o)?l({endpoint:p.src,errors:[`zonos.js - Failed to fetch ${o} CDN.`],metadata:{cdnLoadTime:performance.now()-v,cdnType:o,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):l({endpoint:p.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:o,vercelLoadTime:performance.now()-v}})})),document.head.appendChild(p)},U.init=async o=>{var e;if(d("=== Init zonos script release date","info",z.releaseDate),L&&!window.isZonosPreview){d(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${L}`,"info");const e=document.createElement("script");return e.src=`${L}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=z.isBigCommerce,window.Zonos.isLegacyCheckout=z.isLegacyCheckout,window.Zonos.init(o)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${L}`)})),void(window.isZonosPreview=!0)}const n=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:t,isLegacyCartId:r}=S(n);if(n&&!r&&!t)return void z.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${n}`,metadata:{invalidCartId:!0}});z.cartId=n;const s="https://v1.3.139.js.zonos.com",i=document.querySelector('script[src*="/zonos.js"]'),a=null===(e=document.querySelector("script[src*='/loadZonos.js']"))||void 0===e?void 0:e.src;d(`[ZONOS - init] first load script src: ${a}`,"info"),window.Zonos.zonosQaUrl=L,window.Zonos.zonosQaUrlApi=b,window.Zonos.zonosQaUrl&&d(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&d(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const c=null==a?void 0:a.includes("timestamp=");if(!(z.isNpm||a&&c))return void g("[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(i||!a||z.requested)return void d("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!z.cartId)return z.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void g("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(z.requested=!0,z.zonosApiKey=o.zonosApiKey,z.storeId=o.storeId,z.cartId){const o=await(async o=>{const{isDgsCartId:e,isLegacyCartId:n}=S(o);if(!n&&!e)return g("[ZONOS - loadZonos] invalid cart id"),null;const t=await O({cartId:o,retries:5});return d("[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}):(g("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(z.cartId);if(!o)throw z.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");z.cartData=o.cartData,z.legacyStoreLogo=o.storeLogo,z.legacyStoreFavicon=o.storeFavicon,z.storeId=o.storeId,z.zonosApiKey=o.zonosApiKey}if(!z.zonosApiKey)return void g('"zonosApiKey" is required to initialize Zonos');const l=await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return null;if(d("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return d("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:o,json:e}=await w("/api/get-test-public-credential");if(o.length||!e)return g("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),null;const n=e.publicCredential;return n?(d(`[ZONOS - loadZonos] Retrieve new test public token ${n}`,"info"),n):(g("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(l&&(d(`[ZONOS - loadZonos] Using test API key: ${l} for test mode`,"info"),z.zonosApiKey=l),!z.storeId)return d("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void z.injectZonos({initConfig:o,vercelUrl:s,version:null});const p=z.storeId||o.storeId;d(`[ZONOS - loadZonos] Store ID: ${p}`,"info");const u=new URLSearchParams;u.set("storeId",p.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&u.set("_enableStoreVersionPinned","1");const{errors:m,json:f}=await w(`/api/get-store-version?${u.toString()}`);if(m.length||!f)return d("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void z.injectZonos({initConfig:o,vercelUrl:s,version:null});const{isDifferent:y,source:h,version:v}=f;if(d(`[ZONOS - loadZonos] Store version: ${v}, source: ${h}`,"info"),y){d(`[ZONOS - loadZonos] Updating saved store version to ${v}`,"info");const o={storeId:p,version:v};w(`/api/set-store-version?${u.toString()}`,{body:o,method:"POST"}).catch((o=>g("Unable to save store's vesrion",o)))}if(!i){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:a}),r=t&&!n?e:`${"alpha"===v?"alpha":`v${v}`}.js.zonos.com`,s=t&&!n?null:v;d("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:v}),z.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview)&&(window.Zonos=U)})();
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=["cloudflare","vercel"],n=e[0],t={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},r=t[n],s=(o=n)=>{const t=e.indexOf(o),r=e[t+1];return r||null},i=o=>{if("string"==typeof o)try{return JSON.parse(o)}catch(o){return null}return null},a=performance.now(),c=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"}},d=(o,e,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const o=performance.now()-a,e=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:e}})(),i=[`(${s})`,...n];i.map(c).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 d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const l=(null===(r=d.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(e){case"warn":l.warn(o,...i);break;case"info":l.info(o,...i);break;case"error":l.error(o,...i);break;default:l.groupCollapsed(o,...i),l.trace(),l.groupEnd()}},l=async({endpoint:o,errors:e,metadata:n,shouldPostReleaseErrorReporting:i})=>{if(d("sendErrorLog","warn",o,n,e),i){const o=Number(window.Zonos.releaseDate);if((new Date).getTime()-o>36e5)return}const a="userAgentData"in window.navigator?window.navigator.userAgentData:null,c={endpoint:o,errors:e,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:a&&a.brands.length>0?a:window.navigator.userAgent},n)};try{fetch(`${r}/api/zonos-elements/log-error`,{body:JSON.stringify(c),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(o){const e=s();if(!e)return;fetch(`${t[e]}/api/zonos-elements/log-error`,{body:JSON.stringify(c),method:"POST"})}},p=async({response:o,shouldLog:e=!0,shouldThrow:n=!1})=>{try{const e=await o.text(),n=i(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}},u=async({basePathType:o,options:e,path:r})=>{let s;const i=window.Zonos.zonosQaUrlApi||t[o]||n,a=new URL(i+r),c=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("")}})(c));try{s=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 d=s.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&d&&l&&(window.Zonos.modeAlerted=!0),s.ok){return{baseUrl:i,errors:[],json:await p({response:s}),response:s,zonosMode:d}}const u=s.status.toString();try{const o=await p({response:s,shouldThrow:!0});return{baseUrl:i,errors:[{message:JSON.stringify(o),type:u}],json:null,response:s,zonosMode:d}}catch(o){return{baseUrl:i,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:d}}},m=async({basePathType:e,options:n,path:r})=>{var a,c;const p=r.startsWith("/api/bigcommerce")?"vercel":e,w=await u({basePathType:p,options:n,path:r}),{errors:g,response:f}=w,y=o(w,["errors","response"]),h=s(p),v=!!g.find((({type:o})=>"unknown"===o))||404===(null==f?void 0:f.status),Z=h&&v;return v&&l({endpoint:t[p]+r,errors:g.map((({message:o})=>`API: ${o}`)),metadata:{currentBasePath:p,nextFallbackApiType:h,requestHeaders:null==n?void 0:n.headers,requestPayload:i(null===(a=null==n?void 0:n.body)||void 0===a?void 0:a.toString())||(null===(c=null==n?void 0:n.body)||void 0===c?void 0:c.toString()),status:null==f?void 0:f.status,statusText:null==f?void 0:f.statusText},shouldPostReleaseErrorReporting:!0}),Z?(d(`=== "${r}" failed to fetch, trying next fallback ${h}`),m({basePathType:h,options:n,path:r})):Object.assign({errors:g,response:f},y)},w=async(e,t)=>{const r=o(t||{},[]),s=r.body?JSON.stringify(r.body):void 0,i=r.method||"GET",a=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},r.headers),c=Object.assign(Object.assign({},r),{body:"GET"===i?void 0:s,headers:a,method:i}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return d(e,"info"),m({basePathType:l||n,options:c,path:e})},g=(o,...e)=>{d(o,"error",...e)},f=["jsdelivr","cdnjs","unpkg","vercel"],y=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},h=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,v=new RegExp(`^${h.source}$`),Z=new RegExp(`^cart_${h.source}$`),S=o=>o?Z.test(o)?{isDgsCartId:!0,isLegacyCartId:!1}:v.test(o)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},O=async({cartId:o,retries:e})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:t,json:r}=await w("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),s=!r||t.length;return s&&e?(d("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:e}),await new Promise((o=>setTimeout(o,500))),O({cartId:o,retries:e-1})):s?null:r};var z;const L=(()=>{const o=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||o)return null;const e=y(window.location.href),n="https://v1.3.141.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 d(`[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})(),b=(()=>{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=y(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 d(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})();class U{}z=U,U.isNpm=!1,U.isBigCommerce=!1,U.requested=!1,U.cartData=null,U.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,U.version="v1.3.141",U.isLegacyCheckout=!1,U.legacyStoreLogo=null,U.legacyStoreFavicon=null,U.parallelLoadTimes=[],U.parallelLoadState="off",U.releaseDate="1734130633682",U.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){}},U.loadScriptLogParallelHandler=async o=>{try{if(z.parallelLoadTimes.push(o),2===z.parallelLoadTimes.length){const o=z.parallelLoadTimes.find((o=>"vercel"===o.type)),e=z.parallelLoadTimes.find((o=>"jsdelivr"===o.type));if(!o||!e)return;if(o.isError&&e.isError)return void l({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}});z.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){}},U.legacyCheckoutErrorHandler=({message:o,metadata:e})=>{g(`[ZONOS - loadZonos] ${o}`),l({endpoint:"LegacyCheckoutInit",errors:[o],metadata:Object.assign(Object.assign({},e),{tempCartUUID:z.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:o}))},U.getGithubCdn=({type:o,version:e})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.141";"cdnjs"===o?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.141":"unpkg"===o&&(n="https://unpkg.com/@zonos/elements@1.3.141");return e&&"alpha"!==e?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${e}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${e}`):n},U.injectZonos=({cdnType:o="jsdelivr",initConfig:e,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;e=Object.assign(Object.assign({},e),{zonosApiKey:z.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===o?t:z.getGithubCdn({type:o,version:r}),a=L||i,c=a.replace("https://","").replace("http://",""),p=document.createElement("script"),u=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";p.src=`https://${c}/dist/scripts/${u}?timestamp=${Date.now()}`,d(`[ZONOS - loadZonos] Injecting "${u}" from "${c}"`,"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=f[0]===o,y=f[1],h="on"===z.parallelLoadState&&m&&g&&y&&!w;h&&z.injectZonos({cdnType:y,initConfig:e,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();p.addEventListener("load",(()=>{var t;if(h||n?z.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:p.src,storeId:z.storeId,type:o}):z.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:p.src,storeId:z.storeId,type:o}),z.isBigCommerce||(z.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=L,window.Zonos.zonosQaUrlApi=b,window.Zonos.isBigCommerce=z.isBigCommerce,z.cartId){if(!z.zonosApiKey)throw z.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!z.cartData)throw z.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(z.legacyStoreFavicon&&z.isLegacyCheckout){const o=document.createElement("link");o.rel="shortcut icon",o.type="image/x-icon",o.href=z.legacyStoreFavicon,document.head.appendChild(o)}window.Zonos.cartData=z.cartData,window.Zonos.isLegacyCheckout=z.isLegacyCheckout;const o=z.isLegacyCheckout&&"CLOSE_MODAL"===(null===(t=e.checkoutSettings)||void 0===t?void 0:t.successBehavior),n=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:z.legacyStoreLogo||""}),checkoutSettings:Object.assign(Object.assign({},e.checkoutSettings),{successBehavior:o?"ZONOS_SUCCESS_PAGE":void 0,successRedirectUrl:o?z.cartData.storeBaseUrl:void 0}),zonosApiKey:z.zonosApiKey});e=n}window.Zonos.version&&(d(`[ZONOS - loadZonos] Execute "Zonos.init" from "${u}" from "${c}"`,"info"),window.Zonos.init(e))})),p.addEventListener("error",(async()=>{const s=(o=>{const e=f.indexOf(o);return f[e+1]||null})(o);if(!h&&!n){if(!s)return;z.injectZonos({cdnType:s,initConfig:e,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((o=>window.location.href.includes(o)))||L)return;if(h||n)return void z.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:p.src,storeId:z.storeId,type:o});["unpkg","cdnjs","vercel"].includes(o)?l({endpoint:p.src,errors:[`zonos.js - Failed to fetch ${o} CDN.`],metadata:{cdnLoadTime:performance.now()-v,cdnType:o,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):l({endpoint:p.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:o,vercelLoadTime:performance.now()-v}})})),document.head.appendChild(p)},U.init=async o=>{var e;if(d("=== Init zonos script release date","info",z.releaseDate),L&&!window.isZonosPreview){d(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${L}`,"info");const e=document.createElement("script");return e.src=`${L}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=z.isBigCommerce,window.Zonos.isLegacyCheckout=z.isLegacyCheckout,window.Zonos.init(o)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${L}`)})),void(window.isZonosPreview=!0)}const n=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:t,isLegacyCartId:r}=S(n);if(n&&!r&&!t)return void z.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${n}`,metadata:{invalidCartId:!0}});z.cartId=n;const s="https://v1.3.141.js.zonos.com",i=document.querySelector('script[src*="/zonos.js"]'),a=null===(e=document.querySelector("script[src*='/loadZonos.js']"))||void 0===e?void 0:e.src;d(`[ZONOS - init] first load script src: ${a}`,"info"),window.Zonos.zonosQaUrl=L,window.Zonos.zonosQaUrlApi=b,window.Zonos.zonosQaUrl&&d(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&d(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const c=null==a?void 0:a.includes("timestamp=");if(!(z.isNpm||a&&c))return void g("[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(i||!a||z.requested)return void d("[ZONOS - loadZonos] script is already loaded or requested","info");if(!o.zonosApiKey&&!z.cartId)return z.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void g("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(z.requested=!0,z.zonosApiKey=o.zonosApiKey,z.storeId=o.storeId,z.cartId){const o=await(async o=>{const{isDgsCartId:e,isLegacyCartId:n}=S(o);if(!n&&!e)return g("[ZONOS - loadZonos] invalid cart id"),null;const t=await O({cartId:o,retries:5});return d("[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}):(g("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(z.cartId);if(!o)throw z.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");z.cartData=o.cartData,z.legacyStoreLogo=o.storeLogo,z.legacyStoreFavicon=o.storeFavicon,z.storeId=o.storeId,z.zonosApiKey=o.zonosApiKey}if(!z.zonosApiKey)return void g('"zonosApiKey" is required to initialize Zonos');const l=await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!window.Zonos.zonosApiKey)return null;if(d("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return d("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:o,json:e}=await w("/api/get-test-public-credential");if(o.length||!e)return g("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),null;const n=e.publicCredential;return n?(d(`[ZONOS - loadZonos] Retrieve new test public token ${n}`,"info"),n):(g("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(l&&(d(`[ZONOS - loadZonos] Using test API key: ${l} for test mode`,"info"),z.zonosApiKey=l),!z.storeId)return d("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void z.injectZonos({initConfig:o,vercelUrl:s,version:null});const p=z.storeId||o.storeId;d(`[ZONOS - loadZonos] Store ID: ${p}`,"info");const u=new URLSearchParams;u.set("storeId",p.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&u.set("_enableStoreVersionPinned","1");const{errors:m,json:f}=await w(`/api/get-store-version?${u.toString()}`);if(m.length||!f)return d("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void z.injectZonos({initConfig:o,vercelUrl:s,version:null});const{isDifferent:y,source:h,version:v}=f;if(d(`[ZONOS - loadZonos] Store version: ${v}, source: ${h}`,"info"),y){d(`[ZONOS - loadZonos] Updating saved store version to ${v}`,"info");const o={storeId:p,version:v};w(`/api/set-store-version?${u.toString()}`,{body:o,method:"POST"}).catch((o=>g("Unable to save store's vesrion",o)))}if(!i){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:a}),r=t&&!n?e:`${"alpha"===v?"alpha":`v${v}`}.js.zonos.com`,s=t&&!n?null:v;d("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:v}),z.injectZonos({initConfig:o,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview)&&(window.Zonos=U)})();
@@ -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}})(),l=[`(${a})`,...r];l.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,...l));let c=document.querySelector("iframe#zonos---debug-logging-iframe");c||(c=document.createElement("iframe"),c.id="zonos---debug-logging-iframe",c.style.display="none",c.style.opacity="0",c.style.position="absolute",c.style.top="-9999px",c.style.left="-9999px",c.style.width="1px",c.style.height="1px",c.style.border="none",c.style.overflow="hidden",c.style.visibility="hidden",document.body.appendChild(c));const d=(null===(i=c.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...l);break;case"info":d.info(t,...l);break;case"error":d.error(t,...l);break;default:d.groupCollapsed(t,...l),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};function a(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 l=["cloudflare","vercel"],c=l[0],d={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},u=d[c],p=(e=c)=>{const o=l.indexOf(e),t=l[o+1];return t||null},m=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},w=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=m(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}},h=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||d[e]||c,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await w({response:n}),response:n,zonosMode:a}}const u=n.status.toString();try{const e=await w({response:n,shouldThrow:!0});return{baseUrl:r,errors:[{message:JSON.stringify(e),type:u}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:a}}},y=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,l=await h({basePathType:i,options:o,path:n}),{errors:c,response:w}=l,g=a(l,["errors","response"]),f=p(i),v=!!c.find((({type:e})=>"unknown"===e))||404===(null==w?void 0:w.status),b=f&&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(`${u}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=p();if(!o)return;fetch(`${d[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:d[i]+n,errors:c.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:f,requestHeaders:null==o?void 0:o.headers,requestPayload:m(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==w?void 0:w.status,statusText:null==w?void 0:w.statusText},shouldPostReleaseErrorReporting:!0}),b?(t(`=== "${n}" failed to fetch, trying next fallback ${f}`),y({basePathType:f,options:o,path:n})):Object.assign({errors:c,response:w},g)},g=async(e,o)=>{const n=a(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-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers),l=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),d=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),y({basePathType:d||c,options:l,path:e})},f=()=>{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.139.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},v="https://js.stripe.com/v3",b=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,S="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 O=e=>(null!==z||(z=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(S),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${v}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&b.test(t.src))return t}return null})();r&&e?console.warn(S):r||(r=(e=>{const o=document.createElement("script");o.src=`${v}`;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),Z=Promise.resolve().then((()=>O(null)));let j=!1;Z.catch((e=>{j||console.warn(e)}));const C=async({cartId:e,retries:o})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:r,json:s}=await g("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,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))),C({cartId:e,retries:o-1})):i?null:s},k=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,E=new RegExp(`^${k.source}$`),I=new RegExp(`^cart_${k.source}$`),A=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?I.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 C({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 T;const $=(()=>{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})(),N="https://v1.3.139.js.zonos.com",U=$||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.139",L="https://rsms.me",P="https://fonts.googleapis.com",D=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class R{}T=R,R.doneInit=!1,R.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),R.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),R._paypalMockResponse=null,R.isBigCommerce=!1,R.releaseDate="1733763372917",R.isLegacyCheckout=!1,R.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",R.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),R.isNpm=!0,R.zonosQaUrl=null,R.zonosQaUrlApi=null,R.version="v1.3.139",R.modeAlerted=!1,R.cartData=null,R.paypal=null,R.getCurrentTimestamp=()=>(new Date).getTime(),R.zonosController=null,R.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:c,zonosApiKey:d}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),T.doneInit)return;if(t(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=d,T.storeId=c,T.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=f();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=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!d&&!T.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){t("Initialize cart data");const e=await A(T.cartId);if(!e)return void n("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey}const r=await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!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:e,json:o}=await g("/api/get-test-public-credential");if(e.length||!o)return n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",e),null;const r=o.publicCredential;return r?(t(`[ZONOS - loadZonos] Retrieve new test public token ${r}`,"info"),r):(n("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();r&&(T.zonosApiKey=r)}const u=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(T.cartId&&T.cartData||!!u){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"),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),T.doneInit=!0},R.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},R.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},R.showNotification=e=>{var o;null===(o=T.zonosController)||void 0===o||o.showNotification(e)},R.updateOrganizationName=e=>{var o;null===(o=T.zonosController)||void 0===o||o.updateOrganizationName(e)},R.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)}},R.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;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{T.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=T.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{j=!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),T.zonosController=r,t("Zonos controller injected!")},R.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${T.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,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=s,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const t=i(e);t&&T.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(l)},R.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return U;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.139";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.139";case"vercel":return N}};if(T.isNpm){return f()||o()}return o()},R.injectZonosCdn=()=>{T.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},R.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=T.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${N}/`,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&&T.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},R.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},R.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!D.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=L,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${L}/inter/inter.css`,e.appendChild(n),t("Zonos font injected!")},R.setupGoogleFont=e=>{var o;null===(o=T.zonosController)||void 0===o||o.setupGoogleFont(e)},R.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^="${P}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=P,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=R)})();
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};function a(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 c=["cloudflare","vercel"],l=c[0],d={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},u=d[l],p=(e=l)=>{const o=c.indexOf(e),t=c[o+1];return t||null},m=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},w=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=m(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}},h=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||d[e]||l,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 w({response:n}),response:n,zonosMode:a}}const u=n.status.toString();try{const e=await w({response:n,shouldThrow:!0});return{baseUrl:r,errors:[{message:JSON.stringify(e),type:u}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:a}}},y=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,c=await h({basePathType:i,options:o,path:n}),{errors:l,response:w}=c,f=a(c,["errors","response"]),g=p(i),v=!!l.find((({type:e})=>"unknown"===e))||404===(null==w?void 0:w.status),b=g&&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(`${u}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=p();if(!o)return;fetch(`${d[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:d[i]+n,errors:l.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:g,requestHeaders:null==o?void 0:o.headers,requestPayload:m(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==w?void 0:w.status,statusText:null==w?void 0:w.statusText},shouldPostReleaseErrorReporting:!0}),b?(t(`=== "${n}" failed to fetch, trying next fallback ${g}`),y({basePathType:g,options:o,path:n})):Object.assign({errors:l,response:w},f)},f=async(e,o)=>{const n=a(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-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers),c=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:i,method:s}),d=new URLSearchParams(window.location.search).get("useFallbackApi");return t(e,"info"),y({basePathType:d||l,options:c,path:e})},g=()=>{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.141.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},v="https://js.stripe.com/v3",b=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,S="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(S),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${v}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&b.test(t.src))return t}return null})();r&&e?console.warn(S):r||(r=(e=>{const o=document.createElement("script");o.src=`${v}`;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),C=Promise.resolve().then((()=>j(null)));let O=!1;C.catch((e=>{O||console.warn(e)}));const Z=async({cartId:e,retries:o})=>{const n="1"===new URLSearchParams(window.location.search).get("zonosTestMode"),{errors:r,json:s}=await f("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,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))),Z({cartId:e,retries:o-1})):i?null:s},k=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,I=new RegExp(`^${k.source}$`),E=new RegExp(`^cart_${k.source}$`),A=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?E.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:I.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 Z({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 L;const T=(()=>{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})(),N="https://v1.3.141.js.zonos.com",$=T||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.141",U="https://fonts.googleapis.com",P=/^https:\/\/fonts\.googleapis\.com/;class D{}L=D,D.doneInit=!1,D.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),D.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),D._paypalMockResponse=null,D.isBigCommerce=!1,D.releaseDate="1734130633682",D.isLegacyCheckout=!1,D.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",D.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),D.isNpm=!0,D.zonosQaUrl=null,D.zonosQaUrlApi=null,D.version="v1.3.141",D.modeAlerted=!1,D.cartData=null,D.paypal=null,D.getCurrentTimestamp=()=>(new Date).getTime(),D.zonosController=null,D.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:c,storeId:l,zonosApiKey:d}=e;if(L.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),L.doneInit)return;if(t(`====== ZONOS DEBUG MODE: on (${L.version}) ======`),L.zonosApiKey=d,L.storeId=l,L.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=g();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=L.isNpm,window.Zonos.isBigCommerce=L.isBigCommerce,window.Zonos.isLegacyCheckout=L.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!d&&!L.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!L.cartData&&L.cartId){t("Initialize cart data");const e=await A(L.cartId);if(!e)return void n("Failed to get cart data");L.cartData=e.cartData,L.zonosApiKey=e.zonosApiKey}const r=await(async()=>{if(!window.location.search.includes("zonosTestMode=1")||!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:e,json:o}=await f("/api/get-test-public-credential");if(e.length||!o)return n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",e),null;const r=o.publicCredential;return r?(t(`[ZONOS - loadZonos] Retrieve new test public token ${r}`,"info"),r):(n("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();r&&(L.zonosApiKey=r)}const u=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(L.cartId&&L.cartData||!!u){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"),L.injectCustomScriptForHostedCheckout(),L.injectZonosCdn(),L.injectZonosCss(),L.injectFonts(),L.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:c}}),L.doneInit=!0},D.injectCustomScriptForHostedCheckout=()=>{const e=L.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})},D.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},D.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},D.showNotification=e=>{var o;null===(o=L.zonosController)||void 0===o||o.showNotification(e)},D.updateOrganizationName=e=>{var o;null===(o=L.zonosController)||void 0===o||o.updateOrganizationName(e)},D.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)}},D.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;L.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{L.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=L.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{O=!0;const o=Date.now();return C.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),L.zonosController=r,t("Zonos controller injected!")},D.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${L.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&&L.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(c)},D.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return $;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.141";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.141";case"vercel":return N}};if(L.isNpm){return g()||o()}return o()},D.injectZonosCdn=()=>{L.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),L.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},D.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=L.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${N}/`,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&&L.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},D.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(L.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},D.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${U}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!P.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=U,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${U}/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!")},D.setupGoogleFont=e=>{var o;null===(o=L.zonosController)||void 0===o||o.setupGoogleFont(e)},D.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^="${U}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=U,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=D)})();
@@ -1,5 +1,6 @@
1
1
  import { type EventEmitter } from '../../../../stencil-public-runtime';
2
2
  export declare class ZonosCheckoutPayment {
3
+ ele: HTMLZonosCheckoutPaymentElement;
3
4
  /**
4
5
  * Whether or not the checkout is in mobile mode
5
6
  */
@@ -29,6 +30,11 @@ export declare class ZonosCheckoutPayment {
29
30
  * @default false
30
31
  */
31
32
  showErrorBanner: boolean;
33
+ /**
34
+ * Show payment error banner when the payment is failed
35
+ */
36
+ hasStripePaymentError: boolean;
37
+ stripePaymentErrorWatcher(): void;
32
38
  private handleValidate;
33
39
  /**
34
40
  * handler for continue button click
@@ -18,6 +18,10 @@ export type StripeStoreContactOption = {
18
18
  };
19
19
  type StripeStore = {
20
20
  clientSecret: string | null;
21
+ /**
22
+ * Custom error message when payment is failed
23
+ */
24
+ customErrorMessage: string | null;
21
25
  fetchingLandedCostAbortController: AbortController | null;
22
26
  hasPaymentError: boolean;
23
27
  isFetchingLandedCost: boolean;
@@ -170,6 +170,9 @@ export declare const stringsArabic: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsArabic: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsBase: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsBase: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsChinese: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsChinese: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsDanish: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsDanish: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsDutch: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsDutch: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsFrench: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsFrench: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsGerman: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsGerman: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsHebrew: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsHebrew: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsIndonesian: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsIndonesian: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsItalian: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsItalian: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsJapanese: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsJapanese: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsKorean: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsKorean: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsNorwegian: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsNorwegian: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsPolish: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsPolish: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsPortuguese: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsPortuguese: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsRussian: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsRussian: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsSpanish: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsSpanish: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsSwedish: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsSwedish: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };
@@ -170,6 +170,9 @@ export declare const stringsTurkish: {
170
170
  'No countries found': {
171
171
  value: string;
172
172
  };
173
+ 'No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.': {
174
+ value: string;
175
+ };
173
176
  'No shipping method selected': {
174
177
  value: string;
175
178
  };
@@ -365,6 +368,9 @@ export declare const stringsTurkish: {
365
368
  'Unable to check inventory. Please try again.': {
366
369
  value: string;
367
370
  };
371
+ 'Unable to retrieve the checkout session at the moment. Please try again or contact our support team.': {
372
+ value: string;
373
+ };
368
374
  'Update address': {
369
375
  value: string;
370
376
  };