@zonos/elements 1.3.268 → 1.3.270
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.
- package/dist/cjs/{cart-af7c024e.js → cart-3ff48a0e.js} +1 -1
- package/dist/cjs/{hasInclusivePrice-0fa6e022.js → hasInclusivePrice-aec06153.js} +1 -1
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/{invoice-c2e3f232.js → invoice-ff716652.js} +2 -2
- package/dist/cjs/{isCollectMobileTablet-6014787b.js → isCollectMobileTablet-3ac53cab.js} +2 -2
- package/dist/cjs/{localization-f897bc45.js → localization-5c1c9c6a.js} +245 -4
- package/dist/cjs/{paypal-6756a0da.js → paypal-c55b6c45.js} +2 -2
- package/dist/cjs/{placeTestOrder-a4874e51.js → placeTestOrder-230f534b.js} +2 -2
- package/dist/cjs/{renderCheckoutCurrency-584d50fe.js → renderCheckoutCurrency-e9d8efa8.js} +2 -2
- package/dist/cjs/zonos-address-display_8.cjs.entry.js +2 -2
- package/dist/cjs/zonos-address_4.cjs.entry.js +2 -2
- package/dist/cjs/zonos-card_5.cjs.entry.js +3 -3
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +6 -6
- package/dist/cjs/zonos-checkout.cjs.entry.js +15 -72
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +2 -2
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +6 -6
- package/dist/cjs/zonos-collect.cjs.entry.js +4 -4
- package/dist/cjs/zonos-controller.cjs.entry.js +2 -2
- package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
- package/dist/cjs/zonos-hello.cjs.entry.js +2 -45
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +4 -4
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +6 -6
- package/dist/cjs/zonos-invoice.cjs.entry.js +4 -4
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
- package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +3 -3
- package/dist/collection/components/hello/zonos-hello/zonos-hello.js +2 -44
- package/dist/collection/components/store/hello/localization.js +12 -1
- package/dist/collection/components/utils/checkout/bigcommerceStorefrontApi.js +28 -0
- package/dist/collection/components/utils/checkout/removeBigcommerceCartShipping.js +83 -0
- package/dist/collection/components/utils/hello/currencyConversion/defaultCurrencyConverter.js +6 -2
- package/dist/collection/components/utils/hello/shouldShowHelloWidget.js +61 -0
- package/dist/collection/utils/toggleBigcommerceNativeCurrencySelector.js +2 -1
- package/dist/esm/{cart-68c16805.js → cart-44fa77ef.js} +1 -1
- package/dist/esm/{hasInclusivePrice-f1ca1610.js → hasInclusivePrice-f0440925.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/{invoice-d0eadc6a.js → invoice-89e71796.js} +2 -2
- package/dist/esm/{isCollectMobileTablet-11ade63f.js → isCollectMobileTablet-323d2ba1.js} +2 -2
- package/dist/esm/{localization-8e81b696.js → localization-066586b6.js} +242 -5
- package/dist/esm/{paypal-e32877e9.js → paypal-8725008c.js} +2 -2
- package/dist/esm/{placeTestOrder-4cf429d7.js → placeTestOrder-38be871e.js} +2 -2
- package/dist/esm/{renderCheckoutCurrency-9459b8a3.js → renderCheckoutCurrency-802f4481.js} +2 -2
- package/dist/esm/zonos-address-display_8.entry.js +2 -2
- package/dist/esm/zonos-address_4.entry.js +2 -2
- package/dist/esm/zonos-card_5.entry.js +3 -3
- package/dist/esm/zonos-cart-items_12.entry.js +6 -6
- package/dist/esm/zonos-checkout.entry.js +4 -61
- package/dist/esm/zonos-collect-cart-items_3.entry.js +2 -2
- package/dist/esm/zonos-collect-finish_6.entry.js +6 -6
- package/dist/esm/zonos-collect.entry.js +4 -4
- package/dist/esm/zonos-controller.entry.js +2 -2
- package/dist/esm/zonos-country-flag.entry.js +1 -1
- package/dist/esm/zonos-country-select_4.entry.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +2 -2
- package/dist/esm/zonos-hello.entry.js +2 -45
- package/dist/esm/zonos-invoice-cart-items_2.entry.js +4 -4
- package/dist/esm/zonos-invoice-finish_5.entry.js +6 -6
- package/dist/esm/zonos-invoice.entry.js +4 -4
- package/dist/esm/zonos-language-select_2.entry.js +1 -1
- package/dist/esm/zonos-policy-consent_2.entry.js +3 -3
- package/dist/esm-es5/{cart-68c16805.js → cart-44fa77ef.js} +1 -1
- package/dist/esm-es5/{hasInclusivePrice-f1ca1610.js → hasInclusivePrice-f0440925.js} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{invoice-d0eadc6a.js → invoice-89e71796.js} +1 -1
- package/dist/esm-es5/{isCollectMobileTablet-11ade63f.js → isCollectMobileTablet-323d2ba1.js} +1 -1
- package/dist/esm-es5/{localization-8e81b696.js → localization-066586b6.js} +1 -1
- package/dist/esm-es5/{paypal-e32877e9.js → paypal-8725008c.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-4cf429d7.js → placeTestOrder-38be871e.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-9459b8a3.js → renderCheckoutCurrency-802f4481.js} +1 -1
- package/dist/esm-es5/zonos-address-display_8.entry.js +1 -1
- package/dist/esm-es5/zonos-address_4.entry.js +1 -1
- package/dist/esm-es5/zonos-card_5.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
- package/dist/esm-es5/zonos-collect.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice.entry.js +1 -1
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/hello/zonos-hello/zonos-hello.d.ts +0 -1
- package/dist/types/components/utils/checkout/bigcommerceStorefrontApi.d.ts +9 -0
- package/dist/types/components/utils/checkout/removeBigcommerceCartShipping.d.ts +18 -0
- package/dist/types/components/utils/hello/shouldShowHelloWidget.d.ts +16 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-8ddc21f1.system.entry.js → p-08c7dc07.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-b93b66c2.entry.js → p-0d251428.entry.js} +1 -1
- package/dist/zonos-elements/{p-44b279cc.system.js → p-0d2d7fc4.system.js} +1 -1
- package/dist/zonos-elements/{p-7166df08.entry.js → p-0e9c0eff.entry.js} +1 -1
- package/dist/zonos-elements/{p-64e8f05d.system.entry.js → p-0fb8b711.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-17e3cd62.js → p-208b270a.js} +1 -1
- package/dist/zonos-elements/{p-c3459f4a.entry.js → p-225f19b6.entry.js} +1 -1
- package/dist/zonos-elements/p-238370ad.system.js +1 -0
- package/dist/zonos-elements/{p-01913da8.js → p-260a5b57.js} +1 -1
- package/dist/zonos-elements/{p-623fc89a.system.entry.js → p-2651ca93.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-5b05b461.system.js → p-27beefda.system.js} +1 -1
- package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
- package/dist/zonos-elements/{p-48805ed6.system.entry.js → p-2df84888.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-e3d6f9b4.entry.js → p-2f61dc3c.entry.js} +1 -1
- package/dist/zonos-elements/{p-50362897.entry.js → p-30e819ed.entry.js} +1 -1
- package/dist/zonos-elements/{p-2ccd20c0.system.js → p-31a3b070.system.js} +1 -1
- package/dist/zonos-elements/{p-a0ee01dd.system.entry.js → p-553ca694.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-af12a1b7.system.entry.js → p-5812b323.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-95f3bbad.system.entry.js → p-5ab4bc26.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-108b5307.system.entry.js → p-5df77315.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-97da66f2.entry.js → p-6704b83e.entry.js} +1 -1
- package/dist/zonos-elements/p-69ad7325.entry.js +1 -0
- package/dist/zonos-elements/{p-1376e67f.system.entry.js → p-6ac77d9f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-4fe3d5e0.system.js → p-703f2737.system.js} +1 -1
- package/dist/zonos-elements/p-72666536.system.entry.js +1 -0
- package/dist/zonos-elements/{p-b71ef46e.js → p-7792f4c2.js} +1 -1
- package/dist/zonos-elements/{p-95b460e9.system.entry.js → p-7e03bd33.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-53a59935.system.js → p-801dd8d8.system.js} +1 -1
- package/dist/zonos-elements/{p-673407b8.entry.js → p-91702715.entry.js} +1 -1
- package/dist/zonos-elements/{p-6f41c193.entry.js → p-9abfb6b0.entry.js} +1 -1
- package/dist/zonos-elements/{p-dcafbd4e.js → p-9e414000.js} +1 -1
- package/dist/zonos-elements/{p-bc9a30a1.system.entry.js → p-a2885536.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-620a9013.entry.js → p-a977cddd.entry.js} +1 -1
- package/dist/zonos-elements/{p-24091606.system.entry.js → p-acd7009a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-69089a6f.system.entry.js → p-ad4c8167.system.entry.js} +1 -1
- package/dist/zonos-elements/p-b1125711.system.js +1 -0
- package/dist/zonos-elements/p-b15ceaff.entry.js +1 -0
- package/dist/zonos-elements/p-b1a4f385.system.entry.js +1 -0
- package/dist/zonos-elements/{p-72c3756a.js → p-bea9d128.js} +1 -1
- package/dist/zonos-elements/{p-72960738.js → p-bfcc1432.js} +1 -1
- package/dist/zonos-elements/p-c049c527.js +1 -0
- package/dist/zonos-elements/p-c76ec587.system.js +1 -0
- package/dist/zonos-elements/{p-593764cf.system.entry.js → p-ccd0fa8f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-38311c16.entry.js → p-d29dbeb3.entry.js} +1 -1
- package/dist/zonos-elements/{p-7628569a.entry.js → p-d4c966cb.entry.js} +1 -1
- package/dist/zonos-elements/p-d659153c.entry.js +1 -0
- package/dist/zonos-elements/p-debd2e30.js +1 -0
- package/dist/zonos-elements/p-e11c3410.entry.js +1 -0
- package/dist/zonos-elements/{p-7fef8558.entry.js → p-eb96d62f.entry.js} +1 -1
- package/dist/zonos-elements/{p-c91fade3.entry.js → p-ebc966d8.entry.js} +1 -1
- package/dist/zonos-elements/{p-774de1ec.system.js → p-f5d4775a.system.js} +1 -1
- package/dist/zonos-elements/{p-5e18d92b.system.entry.js → p-fb83134b.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-c7ca3e98.system.entry.js → p-fc651784.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-fc5007e0.entry.js → p-fcf3ed5c.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-000b895a.entry.js +0 -1
- package/dist/zonos-elements/p-06e7fe2a.system.entry.js +0 -1
- package/dist/zonos-elements/p-0803ad10.js +0 -1
- package/dist/zonos-elements/p-11439d12.entry.js +0 -1
- package/dist/zonos-elements/p-17be8409.entry.js +0 -1
- package/dist/zonos-elements/p-1eef8c23.system.js +0 -1
- package/dist/zonos-elements/p-5fa2395d.system.js +0 -1
- package/dist/zonos-elements/p-7a220941.system.js +0 -1
- package/dist/zonos-elements/p-7cf8e1f0.js +0 -1
- package/dist/zonos-elements/p-8116d3ba.entry.js +0 -1
- package/dist/zonos-elements/p-b9a615bc.system.entry.js +0 -1
package/dist/scripts/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const e=({id:e,payload:o,target:t,type:n})=>{var r;t instanceof HTMLIFrameElement?null===(r=t.contentWindow)||void 0===r||r.postMessage({id:e,payload:o,type:n},"*"):t.postMessage({id:e,payload:o,type:n},"*")};class o{constructor(o,t){this.targetElement=o,this.targetId=t,this.sendMessage=(o,t)=>{e({id:this.targetId,payload:t,target:this.targetElement,type:o})}}}o.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},o.sendMessage=e,o.injectPrivateIframe=({id:e,onload:o,src:t})=>{const n=document.createElement("iframe");return n.src=t,n.id=e,n.style.display="none",n.role="presentation",n.ariaHidden="true",n.tabIndex=-1,n.style.border="none !important",n.style.margin="0px !important",n.style.padding="0px !important",n.style.width="1px !important",n.style.minWidth="100% !important",n.style.overflow="hidden !important",n.style.display="block !important",n.style.visibility="hidden !important",n.style.position="fixed !important",n.style.pointerEvents="none !important",n.style.userSelect="none !important",n.style.height="1px !important",n.onload=()=>o(n),document.body.appendChild(n),n};const t=performance.now(),n=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},r=(e,o,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const e=performance.now()-t,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),l=[`(${a})`,...r];l.map(n).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const c=(null===(i=d.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(o){case"warn":c.warn(e,...l);break;case"info":c.info(e,...l);break;case"error":c.error(e,...l);break;default:c.groupCollapsed(e,...l),c.trace(),c.groupEnd()}},s=(e,...o)=>{r(e,"error",...o)},i=["jsdelivr","cdnjs","unpkg","vercel"],a="jsdelivr",l=e=>{const o=i.indexOf(e);return i[o+1]||null},d=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function u(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const p=["cloudflare","vercel"],m=p[0],w={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},h=w[m],y=(e=m)=>{const o=p.indexOf(e),t=p[o+1];return t||null},g=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},f=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},v=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],b=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=g(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},S=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||w[e]||m,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await b({response:n}),response:n,zonosMode:a}}const d=n.status.toString();try{const e=await b({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:d}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:d}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${d}: ${"Unknown error"}`,type:d}],json:null,response:null,zonosMode:a}}},C=async({basePathType:e,options:o,path:t})=>{var n,s;const i=t.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await S({basePathType:i,options:o,path:t}),{errors:d,response:c}=l,p=u(l,["errors","response"]),m=performance.now()-a;r(`${t} (${m.toFixed(2)}ms)`,"info");const b=null==c?void 0:c.headers.get("Zonos-Duration");200===(null==c?void 0:c.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(v.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=f(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(d=a,d||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((e=>e.brand)).filter((e=>!/Not.*A.*Brand.*/.test(e))).join(",")};var d;window.Zonos.loadTimeApiInfoList.push(l)})({apiPath:t,apiType:i,loadTimeInternal:b?Number(b):0,loadTimeTotal:m});const z=y(i),k=d.find((({type:e})=>"unknown"===e)),Z=d.find((({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted")))),j=!!k||404===(null==c?void 0:c.status)||500===(null==c?void 0:c.status),O=z&&j;return j&&!Z&&(async({endpoint:e,errors:o,metadata:t,shouldPostReleaseErrorReporting:n})=>{r("sendErrorLog","warn",e,t,o);{const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},t)};try{fetch(`${h}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=y();if(!o)return;fetch(`${w[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:w[i]+t,errors:d.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:z,requestHeaders:null==o?void 0:o.headers,requestPayload:g(null===(n=null==o?void 0:o.body)||void 0===n?void 0:n.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),shouldCallFallback:O,status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),O?(r(`=== "${t}" failed to fetch, trying next fallback ${z}`),C({basePathType:z,options:o,path:t})):Object.assign({errors:d,response:c},p)},z=async(e,o)=>{const t=u(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",s=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":d()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const i=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:n,headers:s,method:r}),a=new URLSearchParams(window.location.search).get("useFallbackApi");return C({basePathType:a||m,options:i,path:e})},k=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),t="https://v1.3.268.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const n=`https://${o}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${n}' for loading elements script`,"warn"),fetch(n).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),n},Z="https://js.stripe.com/v3",j=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let O=null;const I=e=>(null!==O||(O=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)o(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${Z}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&j.test(t.src))return t}return null})();n&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):n||(n=(e=>{const o=document.createElement("script");o.src=`${Z}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(s("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==n||n.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),O),A=Promise.resolve().then((()=>I(null)));let E=!1;A.catch((e=>{E||console.warn(e)}));const T=async({cartId:e,retries:o})=>{const t=c(),n=(()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}})(),s=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,i=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const{errors:a,json:l,zonosMode:d}=await z(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||a.length;return u&&o?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),T({cartId:e,retries:o-1})):u?null:Object.assign(Object.assign({},l),{zonosMode:d})},L=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,P=new RegExp(`^${L.source}$`),$=new RegExp(`^cart_${L.source}$`),U=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,D=async e=>{const{isDgsCartId:o,isLegacyCartId:t}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:$.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:P.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!t&&!o)return s("[ZONOS - loadZonos] invalid cart id"),null;const n=await T({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",n),n?(window.Zonos.storeId=n.cartData.storeId,window.Zonos.zonosApiKey=n.cartData.credentialToken,window.Zonos.zonosMode=n.zonosMode,{cartData:n.cartData,settings:n.settings,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}):(s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)},R="zonos--checkout-hidden-international-button";var F;const x=(()=>{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})(),M=Date.now(),B="https://v1.3.268.js.zonos.com",q=x||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.268",W="https://fonts.googleapis.com",K=/^https:\/\/fonts\.googleapis\.com/;class G{}F=G,G.doneInit=!1,G.cartSettings=null,G.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),G.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),G._paypalMockResponse=null,G.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,G.isBigCommerce=!1,G.releaseDate="1780932992776",G.isLegacyCheckout=!1,G.googleAnalyticId=null,G.googleAnalyticReady=!1,G.facebookPixelId=null,G.facebookPixelReady=!1,G.startLoadTime=M,G.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",G.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),G.overrideUseCustomAddressForm=!1,G.isCollect=!1,G.isInvoice=!1,G.isNpm=!0,G.zonosQaUrl=null,G.zonosQaUrlApi=null,G.trackEventLogs=[],G.version="v1.3.268",G.modeAlerted=!1,G.cartData=null,G.paypal=null,G.zonosMode=null,G.IframeService=o,G.getCurrentTimestamp=()=>(new Date).getTime(),G.zonosController=null,G.loadTimeApiInfoList=[],G.logIntervalId=null,G.init=async e=>{const{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:u,zonosApiKey:p}=e;if(F.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),F.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${F.version}) ======`),F.zonosApiKey=p,F.storeId=u,"undefined"!=typeof window&&window.parent===window&&(F.googleAnalyticReady=!0,F.facebookPixelReady=!0),F.isNpm){r("====== ZONOS LOADING FROM NPM ======");const o=k();if(o&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const t=document.createElement("script");return t.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(t),t.addEventListener("load",(()=>{window.Zonos.isNpm=F.isNpm,window.Zonos.isBigCommerce=F.isBigCommerce,window.Zonos.isLegacyCheckout=F.isLegacyCheckout,window.Zonos.zonosMode=F.zonosMode,window.Zonos.init(e)})),t.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!F.cartId)return void s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!F.cartData&&F.cartId){r("Initialize cart data");const e=await D(F.cartId);if(!e)return void s("Failed to get cart data");F.cartData=e.cartData,F.zonosApiKey=e.zonosApiKey,F.cartSettings=e.settings}const t=await(async()=>{const e=c(),o=d();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:t,json:n}=await z("/api/get-test-public-credential");if(t.length||!n)return s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t),null;const i=n.publicCredential;return i?(r(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(s("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();t&&(F.zonosApiKey=t)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(F.cartId&&F.cartData||!!m){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}r("init zonos"),F.restoreNativeBrowserFunctions(),F.injectCustomScriptForHostedCheckout(),F.injectZonosCdn(),F.injectZonosCss(),F.injectFonts(),F.injectCheckoutInternationalButton(),F.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),F.doneInit=!0},G.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${R}`)){const e=document.createElement("button");e.id=R,e.style.display="none",document.body.appendChild(e)}},G.injectCustomScriptForHostedCheckout=()=>{const e=F.cartData,o=(null==e?void 0:e.metadata)||[],t=o.find((e=>"customHeaderScript"===e.key)),n=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(t||n)){if(t){r("Injecting custom header script");const e=document.createElement("script");e.textContent=t.value,document.head.appendChild(e)}if(n){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=n.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:n,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout})},G.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},G.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${R}`);setTimeout((()=>{var o;e&&e.dispatchEvent(new CustomEvent("click",{detail:o}))}),10)},G.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},G.showNotification=e=>{var o;null===(o=F.zonosController)||void 0===o||o.showNotification(e)},G.updateOrganizationName=e=>{var o;null===(o=F.zonosController)||void 0===o||o.updateOrganizationName(e)},G.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)}},G.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},G.injectController=({config:e})=>{var o,t;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=F.zonosApiKey||"",n.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;r("loading Stripe");const t=await(async(...e)=>{E=!0;const o=Date.now();return A.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);t?(window.Zonos.stripe=t,window.Zonos.isCollect?n.initCollectElement(t):window.Zonos.isInvoice?n.initInvoiceElement(t):n.initCheckoutElement(t)):s("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(n),F.zonosController=n,r("Zonos controller injected!")},G.injectScript=({cdnType:e,isModule:o,theRestUrl:t})=>{const n=`${F.getZonosUrl(e)}/${t}`;if(document.querySelector(`script[src="${n}"]`))return void r(`Zonos script "${n}" already exists in the document`,"warn");const i=document.head||document.body,a=document.createElement("script");o?a.type="module":a.noModule=!0,a.src=n,a.crossOrigin="anonymous",a.onerror=()=>{s(`Failed to load ${a.src}`);const n=l(e);n&&F.injectScript({cdnType:n,isModule:o,theRestUrl:t})},i.appendChild(a)},G.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return q;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.268";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.268";case"vercel":return B}};if(F.isNpm){return k()||o()}return o()},G.injectZonosCdn=()=>{F.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),F.injectScript({cdnType:a,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},G.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=F.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${B}/`,n.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{s(`Failed to load ${i.href}`);const t=l(e);t&&F.injectStylesheet({cdnType:t,theRestUrl:o})},n.appendChild(i)},G.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(F.injectStylesheet({cdnType:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},G.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${W}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!K.test(t.href))return t}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=W,e.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${W}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(t),r("Zonos font injected!")},G.setupGoogleFont=e=>{var o;null===(o=F.zonosController)||void 0===o||o.setupGoogleFont(e)},G.injectSupportGoogleFont=e=>{var o;r(`[FONT] injecting ${e}`);const t=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${W}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=W,n.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${t} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,n.appendChild(s),r(`[FONT] ${t} font injected!`)},exports.Zonos=G})();
|
|
1
|
+
(function(){"use strict";const e=({id:e,payload:o,target:t,type:n})=>{var r;t instanceof HTMLIFrameElement?null===(r=t.contentWindow)||void 0===r||r.postMessage({id:e,payload:o,type:n},"*"):t.postMessage({id:e,payload:o,type:n},"*")};class o{constructor(o,t){this.targetElement=o,this.targetId=t,this.sendMessage=(o,t)=>{e({id:this.targetId,payload:t,target:this.targetElement,type:o})}}}o.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},o.sendMessage=e,o.injectPrivateIframe=({id:e,onload:o,src:t})=>{const n=document.createElement("iframe");return n.src=t,n.id=e,n.style.display="none",n.role="presentation",n.ariaHidden="true",n.tabIndex=-1,n.style.border="none !important",n.style.margin="0px !important",n.style.padding="0px !important",n.style.width="1px !important",n.style.minWidth="100% !important",n.style.overflow="hidden !important",n.style.display="block !important",n.style.visibility="hidden !important",n.style.position="fixed !important",n.style.pointerEvents="none !important",n.style.userSelect="none !important",n.style.height="1px !important",n.onload=()=>o(n),document.body.appendChild(n),n};const t=performance.now(),n=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},r=(e,o,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const e=performance.now()-t,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),l=[`(${a})`,...r];l.map(n).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const c=(null===(i=d.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(o){case"warn":c.warn(e,...l);break;case"info":c.info(e,...l);break;case"error":c.error(e,...l);break;default:c.groupCollapsed(e,...l),c.trace(),c.groupEnd()}},s=(e,...o)=>{r(e,"error",...o)},i=["jsdelivr","cdnjs","unpkg","vercel"],a="jsdelivr",l=e=>{const o=i.indexOf(e);return i[o+1]||null},d=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function u(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const p=["cloudflare","vercel"],m=p[0],w={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},h=w[m],y=(e=m)=>{const o=p.indexOf(e),t=p[o+1];return t||null},g=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},f=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},v=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],b=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=g(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},S=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||w[e]||m,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await b({response:n}),response:n,zonosMode:a}}const d=n.status.toString();try{const e=await b({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:d}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:d}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${d}: ${"Unknown error"}`,type:d}],json:null,response:null,zonosMode:a}}},C=async({basePathType:e,options:o,path:t})=>{var n,s;const i=t.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await S({basePathType:i,options:o,path:t}),{errors:d,response:c}=l,p=u(l,["errors","response"]),m=performance.now()-a;r(`${t} (${m.toFixed(2)}ms)`,"info");const b=null==c?void 0:c.headers.get("Zonos-Duration");200===(null==c?void 0:c.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(v.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=f(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(d=a,d||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((e=>e.brand)).filter((e=>!/Not.*A.*Brand.*/.test(e))).join(",")};var d;window.Zonos.loadTimeApiInfoList.push(l)})({apiPath:t,apiType:i,loadTimeInternal:b?Number(b):0,loadTimeTotal:m});const z=y(i),k=d.find((({type:e})=>"unknown"===e)),Z=d.find((({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted")))),j=!!k||404===(null==c?void 0:c.status)||500===(null==c?void 0:c.status),O=z&&j;return j&&!Z&&(async({endpoint:e,errors:o,metadata:t,shouldPostReleaseErrorReporting:n})=>{r("sendErrorLog","warn",e,t,o);{const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},t)};try{fetch(`${h}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=y();if(!o)return;fetch(`${w[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:w[i]+t,errors:d.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:z,requestHeaders:null==o?void 0:o.headers,requestPayload:g(null===(n=null==o?void 0:o.body)||void 0===n?void 0:n.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),shouldCallFallback:O,status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),O?(r(`=== "${t}" failed to fetch, trying next fallback ${z}`),C({basePathType:z,options:o,path:t})):Object.assign({errors:d,response:c},p)},z=async(e,o)=>{const t=u(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",s=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":d()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const i=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:n,headers:s,method:r}),a=new URLSearchParams(window.location.search).get("useFallbackApi");return C({basePathType:a||m,options:i,path:e})},k=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),t="https://v1.3.270.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const n=`https://${o}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${n}' for loading elements script`,"warn"),fetch(n).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),n},Z="https://js.stripe.com/v3",j=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let O=null;const I=e=>(null!==O||(O=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)o(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${Z}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&j.test(t.src))return t}return null})();n&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):n||(n=(e=>{const o=document.createElement("script");o.src=`${Z}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(s("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==n||n.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),O),A=Promise.resolve().then((()=>I(null)));let E=!1;A.catch((e=>{E||console.warn(e)}));const T=async({cartId:e,retries:o})=>{const t=c(),n=(()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}})(),s=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,i=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const{errors:a,json:l,zonosMode:d}=await z(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||a.length;return u&&o?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),T({cartId:e,retries:o-1})):u?null:Object.assign(Object.assign({},l),{zonosMode:d})},L=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,P=new RegExp(`^${L.source}$`),$=new RegExp(`^cart_${L.source}$`),U=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,D=async e=>{const{isDgsCartId:o,isLegacyCartId:t}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:$.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:P.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!t&&!o)return s("[ZONOS - loadZonos] invalid cart id"),null;const n=await T({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",n),n?(window.Zonos.storeId=n.cartData.storeId,window.Zonos.zonosApiKey=n.cartData.credentialToken,window.Zonos.zonosMode=n.zonosMode,{cartData:n.cartData,settings:n.settings,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}):(s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)},R="zonos--checkout-hidden-international-button";var F;const x=(()=>{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})(),M=Date.now(),B="https://v1.3.270.js.zonos.com",q=x||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.270",W="https://fonts.googleapis.com",K=/^https:\/\/fonts\.googleapis\.com/;class G{}F=G,G.doneInit=!1,G.cartSettings=null,G.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),G.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),G._paypalMockResponse=null,G.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,G.isBigCommerce=!1,G.releaseDate="1781713935263",G.isLegacyCheckout=!1,G.googleAnalyticId=null,G.googleAnalyticReady=!1,G.facebookPixelId=null,G.facebookPixelReady=!1,G.startLoadTime=M,G.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",G.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),G.overrideUseCustomAddressForm=!1,G.isCollect=!1,G.isInvoice=!1,G.isNpm=!0,G.zonosQaUrl=null,G.zonosQaUrlApi=null,G.trackEventLogs=[],G.version="v1.3.270",G.modeAlerted=!1,G.cartData=null,G.paypal=null,G.zonosMode=null,G.IframeService=o,G.getCurrentTimestamp=()=>(new Date).getTime(),G.zonosController=null,G.loadTimeApiInfoList=[],G.logIntervalId=null,G.init=async e=>{const{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:u,zonosApiKey:p}=e;if(F.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),F.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${F.version}) ======`),F.zonosApiKey=p,F.storeId=u,"undefined"!=typeof window&&window.parent===window&&(F.googleAnalyticReady=!0,F.facebookPixelReady=!0),F.isNpm){r("====== ZONOS LOADING FROM NPM ======");const o=k();if(o&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const t=document.createElement("script");return t.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(t),t.addEventListener("load",(()=>{window.Zonos.isNpm=F.isNpm,window.Zonos.isBigCommerce=F.isBigCommerce,window.Zonos.isLegacyCheckout=F.isLegacyCheckout,window.Zonos.zonosMode=F.zonosMode,window.Zonos.init(e)})),t.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!F.cartId)return void s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!F.cartData&&F.cartId){r("Initialize cart data");const e=await D(F.cartId);if(!e)return void s("Failed to get cart data");F.cartData=e.cartData,F.zonosApiKey=e.zonosApiKey,F.cartSettings=e.settings}const t=await(async()=>{const e=c(),o=d();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:t,json:n}=await z("/api/get-test-public-credential");if(t.length||!n)return s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t),null;const i=n.publicCredential;return i?(r(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(s("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();t&&(F.zonosApiKey=t)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(F.cartId&&F.cartData||!!m){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}r("init zonos"),F.restoreNativeBrowserFunctions(),F.injectCustomScriptForHostedCheckout(),F.injectZonosCdn(),F.injectZonosCss(),F.injectFonts(),F.injectCheckoutInternationalButton(),F.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),F.doneInit=!0},G.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${R}`)){const e=document.createElement("button");e.id=R,e.style.display="none",document.body.appendChild(e)}},G.injectCustomScriptForHostedCheckout=()=>{const e=F.cartData,o=(null==e?void 0:e.metadata)||[],t=o.find((e=>"customHeaderScript"===e.key)),n=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(t||n)){if(t){r("Injecting custom header script");const e=document.createElement("script");e.textContent=t.value,document.head.appendChild(e)}if(n){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=n.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:n,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout})},G.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},G.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${R}`);setTimeout((()=>{var o;e&&e.dispatchEvent(new CustomEvent("click",{detail:o}))}),10)},G.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},G.showNotification=e=>{var o;null===(o=F.zonosController)||void 0===o||o.showNotification(e)},G.updateOrganizationName=e=>{var o;null===(o=F.zonosController)||void 0===o||o.updateOrganizationName(e)},G.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)}},G.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},G.injectController=({config:e})=>{var o,t;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=F.zonosApiKey||"",n.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;r("loading Stripe");const t=await(async(...e)=>{E=!0;const o=Date.now();return A.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);t?(window.Zonos.stripe=t,window.Zonos.isCollect?n.initCollectElement(t):window.Zonos.isInvoice?n.initInvoiceElement(t):n.initCheckoutElement(t)):s("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(n),F.zonosController=n,r("Zonos controller injected!")},G.injectScript=({cdnType:e,isModule:o,theRestUrl:t})=>{const n=`${F.getZonosUrl(e)}/${t}`;if(document.querySelector(`script[src="${n}"]`))return void r(`Zonos script "${n}" already exists in the document`,"warn");const i=document.head||document.body,a=document.createElement("script");o?a.type="module":a.noModule=!0,a.src=n,a.crossOrigin="anonymous",a.onerror=()=>{s(`Failed to load ${a.src}`);const n=l(e);n&&F.injectScript({cdnType:n,isModule:o,theRestUrl:t})},i.appendChild(a)},G.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return q;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.270";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.270";case"vercel":return B}};if(F.isNpm){return k()||o()}return o()},G.injectZonosCdn=()=>{F.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),F.injectScript({cdnType:a,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},G.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=F.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${B}/`,n.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{s(`Failed to load ${i.href}`);const t=l(e);t&&F.injectStylesheet({cdnType:t,theRestUrl:o})},n.appendChild(i)},G.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(F.injectStylesheet({cdnType:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},G.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${W}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!K.test(t.href))return t}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=W,e.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${W}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(t),r("Zonos font injected!")},G.setupGoogleFont=e=>{var o;null===(o=F.zonosController)||void 0===o||o.setupGoogleFont(e)},G.injectSupportGoogleFont=e=>{var o;r(`[FONT] injecting ${e}`);const t=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${W}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=W,n.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${t} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,n.appendChild(s),r(`[FONT] ${t} font injected!`)},exports.Zonos=G})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const e=()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}},o=()=>{const e=new URL(window.location.href),o=window.sessionStorage.getItem("zonos--country");return(e=>{const o=new URLSearchParams(e||window.location.search),n=e=>{return(n=o.get(e))&&/^[A-Z]{2}$/.test(n)?n:null;var n},t=n("zCountry"),r=n("country"),s=n("customerCountry");return t||r||s})(e.searchParams)||o};function n(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(e);r<t.length;r++)o.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(e,t[r])&&(n[t[r]]=e[t[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;const t=()=>window.location.search.includes("zonosStagingMode=1"),r=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")},s=["cloudflare","vercel"],i=s[0],a={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},d=a[i],l=(e=i)=>{const o=s.indexOf(e),n=s[o+1];return n||null},c=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},u=performance.now(),p=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"}},w=(e,o,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const e=performance.now()-u,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),i=[`(${s})`,...n];i.map(p).join(" ");if(!(!!(null===(t=window.Zonos)||void 0===t?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let a=document.querySelector("iframe#zonos---debug-logging-iframe");a||(a=document.createElement("iframe"),a.id="zonos---debug-logging-iframe",a.style.display="none",a.style.opacity="0",a.style.position="absolute",a.style.top="-9999px",a.style.left="-9999px",a.style.width="1px",a.style.height="1px",a.style.border="none",a.style.overflow="hidden",a.style.visibility="hidden",document.body.appendChild(a));const d=(null===(r=a.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(o){case"warn":d.warn(e,...i);break;case"info":d.info(e,...i);break;case"error":d.error(e,...i);break;default:d.groupCollapsed(e,...i),d.trace(),d.groupEnd()}},g=()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||n},m=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],y=({apiPath:e,apiType:o,loadTimeInternal:n,loadTimeTotal:t})=>{if(m.includes(e))return;const r=t-n;if(r<0)return;const s=e.split("?")[0]||e,i=(()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=g();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}})(),a="object"==typeof i.userAgent&&i.userAgent.mobile,d={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(l=a,l||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:n,loadTimeTotal:t,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((e=>e.brand)).filter((e=>!/Not.*A.*Brand.*/.test(e))).join(",")};var l;window.Zonos.loadTimeApiInfoList.push(d)},f=async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:t})=>{if(w("sendErrorLog","warn",e,n,o),t){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const r="userAgentData"in window.navigator?window.navigator.userAgentData:null,s={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:r&&r.brands.length>0?r:window.navigator.userAgent},n)};try{fetch(`${d}/api/zonos-elements/log-error`,{body:JSON.stringify(s),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=l();if(!o)return;fetch(`${a[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(s),method:"POST"})}},h=async({response:e,shouldLog:o=!0,shouldThrow:n=!1})=>{try{const o=await e.text(),n=c(o);if(!n)throw new Error(`Failed to parse content: ${o}`);return n}catch(e){if(n)throw e;return o&&console.error(e),null}},v=async({basePathType:e,options:o,path:n})=>{let t;const r=window.Zonos.zonosQaUrlApi||a[e]||i,s=new URL(r+n),d=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("")}})(d));try{t=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const l=t.headers.get("Zonos-Mode"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&l&&c&&(window.Zonos.modeAlerted=!0),t.ok){return{baseUrl:r,errors:[],json:await h({response:t}),response:t,zonosMode:l}}const u=t.status.toString();try{const e=await h({response:t,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:u}:e)),json:null,response:t,zonosMode:l}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:u}],json:null,response:t,zonosMode:l}}catch(e){return{baseUrl:r,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:l}}},S=async({basePathType:e,options:o,path:t})=>{var r,s;const i=t.startsWith("/api/bigcommerce")?"vercel":e,d=performance.now(),u=await v({basePathType:i,options:o,path:t}),{errors:p,response:g}=u,m=n(u,["errors","response"]),h=performance.now()-d;w(`${t} (${h.toFixed(2)}ms)`,"info");const z=null==g?void 0:g.headers.get("Zonos-Duration");200===(null==g?void 0:g.status)&&y({apiPath:t,apiType:i,loadTimeInternal:z?Number(z):0,loadTimeTotal:h});const Z=l(i),C=p.find((({type:e})=>"unknown"===e)),b=p.find((({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted")))),I=!!C||404===(null==g?void 0:g.status)||500===(null==g?void 0:g.status),L=Z&&I;return I&&!b&&f({endpoint:a[i]+t,errors:p.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:Z,requestHeaders:null==o?void 0:o.headers,requestPayload:c(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()),shouldCallFallback:L,status:null==g?void 0:g.status,statusText:null==g?void 0:g.statusText},shouldPostReleaseErrorReporting:!0}),L?(w(`=== "${t}" failed to fetch, trying next fallback ${Z}`),S({basePathType:Z,options:o,path:t})):Object.assign({errors:p,response:g},m)},z=async(e,o)=>{const s=n(o||{},[]),a=s.body?JSON.stringify(s.body):void 0,d=s.method||"GET",l=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":t()?"1":void 0,"Zonos-Test-Mode":r()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},s.headers);Object.keys(l).forEach((e=>void 0===l[e]&&delete l[e]));const c=Object.assign(Object.assign({},s),{body:"GET"===d?void 0:a,headers:l,method:d}),u=new URLSearchParams(window.location.search).get("useFallbackApi");return S({basePathType:u||i,options:c,path:e})},Z=(e,...o)=>{w(e,"error",...o)},C=["jsdelivr","cdnjs","unpkg","vercel"],b=e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");if(!o)return null;return/[^a-zA-Z0-9-_]+/.test(o)?null:o},I=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,L=new RegExp(`^${I.source}$`),O=new RegExp(`^cart_${I.source}$`),A=/^[a-zA-Z0-9]{2,}$/,T=/^cart_[a-zA-Z0-9]{2,}$/,k=e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:T.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:A.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:O.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:L.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},U=async({cartId:o,retries:n})=>{const t=r(),s=e(),i=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,a=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&a.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:d,json:l,zonosMode:c}=await z(`/api/zonos-elements/get-cart?${a.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:i,tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||d.length;return u&&n?(w("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise((e=>setTimeout(e,500))),U({cartId:o,retries:n-1})):u?null:Object.assign(Object.assign({},l),{zonosMode:c})},j="z--blur",E=async()=>{const e=window.zonosBlurCurrencyOnInitIntervalId;if(!e)return;await new Promise((e=>setTimeout(e,500))),clearInterval(e);document.querySelectorAll(`.${j}`).forEach((e=>{e.classList.remove(j)})),window.zonosBlurCurrencyOnInitIntervalId=void 0},$=({currencySelector:e,specificSelector:o})=>{if(e||o)if(o)o.classList.add(j);else{document.querySelectorAll([e].filter(Boolean).join(",")).forEach((e=>{e.classList.add(j)}))}};var P;const N=(()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=b(window.location.href),n="https://v1.3.268.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const t=`https://${o}.preview.js.zonos.com`;return w(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,n=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null})),t})(),D=(()=>{const e=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrlApi");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),o=b(window.location.href),n=e||o;if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com"].includes(window.location.hostname))return"https://dev.demo.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.demo.elements.zonos.com";if(!e)return null;const t=`https://${e}.route.js.zonos.com`;return w(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})(),R=Date.now();class F{}P=F,F.isNpm=!1,F.isBigCommerce=!1,F.googleAnalyticId=null,F.googleAnalyticReady=!1,F.facebookPixelId=null,F.facebookPixelReady=!1,F.requested=!1,F.zonosMode=null,F.cartData=null,F.startLoadTime=R,F.overrideUseCustomAddressForm=!1,F.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,F.version="v1.3.268",F.isLegacyCheckout=!1,F.isCollect=!1,F.isInvoice=!1,F.legacyStoreLogo=null,F.legacyStoreFavicon=null,F.parallelLoadTimes=[],F.parallelLoadState="off",F.releaseDate="1780932992776",F.loadTimeApiInfoList=[],F.cartSettings=null,F.loadScriptLogHandler=async({cdnLoadTime:e,fallbackLoadTime:o,isError:n,metadata:t,scriptLoadUrl:r,storeId:s,type:i})=>{try{const e=window.performance.getEntriesByType("resource").find((e=>{const o=e;return o.name.includes(r)&&"script"===o.initiatorType}));null==e||e.transferSize;(async e=>{})((e&&(null==e?void 0:e.duration)>0?parseFloat(e.duration.toFixed(2)):parseFloat(o.toFixed(2)),Object.assign({decodedBodySize:null==e?void 0:e.decodedBodySize,encodedBodySize:null==e?void 0:e.encodedBodySize,fallbackLoadTime:o,isError:!!n},t)))}catch(e){}},F.loadScriptLogParallelHandler=async e=>{try{if(P.parallelLoadTimes.push(e),2===P.parallelLoadTimes.length){const e=P.parallelLoadTimes.find((e=>"vercel"===e.type)),o=P.parallelLoadTimes.find((e=>"jsdelivr"===e.type));if(!e||!o)return;if(e.isError&&o.isError)return void f({endpoint:`<${e.scriptLoadUrl}> <${o.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:o.fallbackLoadTime,cdnType:o.type,vercelLoadTime:e.fallbackLoadTime}});P.loadScriptLogHandler({cdnLoadTime:o.fallbackLoadTime,fallbackLoadTime:e.fallbackLoadTime,isError:e.isError,metadata:{cdnScriptFallbackTime:o.fallbackLoadTime,cdnScriptIsError:!!o.isError,cdnScriptLoadUrl:o.scriptLoadUrl,cdnScriptType:o.type},scriptLoadUrl:e.scriptLoadUrl,storeId:e.storeId,type:e.type})}}catch(e){}},F.legacyCheckoutErrorHandler=({message:e,metadata:o})=>{Z(`[ZONOS - loadZonos] ${e}`),f({endpoint:"LegacyCheckoutInit",errors:[e],metadata:Object.assign(Object.assign({},o),{tempCartUUID:P.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:e}))},F.getGithubCdn=({type:e,version:o})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.268";"cdnjs"===e?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.268":"unpkg"===e&&(n="https://unpkg.com/@zonos/elements@1.3.268");return o&&"alpha"!==o?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${o}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${o}`):n},F.injectZonos=({cdnType:e="jsdelivr",initConfig:o,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;o=Object.assign(Object.assign({},o),{zonosApiKey:P.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===e?t:P.getGithubCdn({type:e,version:r}),a=N||i,d=a.replace("https://","").replace("http://",""),l=document.createElement("script"),c=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";l.src=`https://${d}/dist/scripts/${c}?timestamp=${Date.now()}`,w(`[ZONOS - loadZonos] Injecting "${c}" from "${d}"`,"info");const u="4g"===(null===(s=g())||void 0===s?void 0:s.effectiveType),p=["dev.elements.zonos.com","zonos.com"].some((e=>window.location.href.includes(e))),m=C[0]===e,y=C[1],h="on"===P.parallelLoadState&&u&&m&&y&&!p;h&&P.injectZonos({cdnType:y,initConfig:o,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();l.addEventListener("load",(async()=>{if(h||n?P.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:l.src,storeId:P.storeId||0,type:e}):P.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:l.src,storeId:P.storeId||0,type:e}),P.isBigCommerce||(P.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=N,window.Zonos.zonosQaUrlApi=D,window.Zonos.zonosMode=P.zonosMode,window.Zonos.isBigCommerce=P.isBigCommerce,window.Zonos.loadTimeApiInfoList=P.loadTimeApiInfoList,window.Zonos.overrideUseCustomAddressForm=P.overrideUseCustomAddressForm,window.Zonos.startLoadTime=P.startLoadTime,P.cartSettings&&(window.Zonos.cartSettings=P.cartSettings),P.cartId){const e=P.isCollect?"Collect":"hosted Checkout";if(!P.zonosApiKey)throw P.legacyCheckoutErrorHandler({message:`zonosApiKey is missing to initiate ${e}`}),new Error(`zonosApiKey is required for ${e}`);if(!P.cartData)throw P.legacyCheckoutErrorHandler({message:`cartData is missing to initiate ${e}`}),new Error(`cartData is required for ${e}`);if(P.legacyStoreFavicon&&P.isLegacyCheckout&&!P.isCollect)try{if(200!==(await fetch(P.legacyStoreFavicon)).status)throw new Error("Custom favicon is not available");const e=document.createElement("link");e.rel="shortcut icon",e.type="image/x-icon",e.href=P.legacyStoreFavicon,document.head.appendChild(e)}catch(e){}window.Zonos.cartData=P.cartData,window.Zonos.isLegacyCheckout=P.isLegacyCheckout,window.Zonos.cartSettings=P.cartSettings,window.Zonos.isCollect=P.isCollect,window.Zonos.isInvoice=P.isInvoice;const n=Object.assign(Object.assign({},o),{appearance:Object.assign(Object.assign({},o.appearance),{logoUrl:P.isLegacyCheckout&&!P.isCollect&&P.legacyStoreLogo?P.legacyStoreLogo:void 0}),zonosApiKey:P.zonosApiKey});o=n}window.Zonos.version&&(w(`[ZONOS - loadZonos] Execute "Zonos.init" from "${c}" from "${d}"`,"info"),window.Zonos.init(o))})),l.addEventListener("error",(async()=>{const s=(e=>{const o=C.indexOf(e);return C[o+1]||null})(e);if(!h&&!n){if(!s)return;P.injectZonos({cdnType:s,initConfig:o,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((e=>window.location.href.includes(e)))||N)return;if(h||n)return void P.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:l.src,storeId:P.storeId||0,type:e});["unpkg","cdnjs","vercel"].includes(e)?f({endpoint:l.src,errors:[`zonos.js - Failed to fetch ${e} CDN.`],metadata:{cdnLoadTime:performance.now()-v,cdnType:e,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):f({endpoint:l.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:e,vercelLoadTime:performance.now()-v}})})),document.head.appendChild(l)},F.handlePerformBlurCurrency=()=>{var e,o,n;!(null===(o=null===(e=P.cartSettings)||void 0===e?void 0:e.genericSettings)||void 0===o?void 0:o.blurCurrencyOnInit)?E():(window.zonosBlurCurrencyOnInitCurrencySelector=window.zonosBlurCurrencyOnInitCurrencySelector||(null===(n=P.cartSettings)||void 0===n?void 0:n.helloSettings.currencyElementSelector),(()=>{if("undefined"==typeof window)return;if(window.zonosBlurCurrencyOnInitIntervalId)return;$({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector});const e=setInterval((()=>{$({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector})}),10);window.zonosBlurCurrencyOnInitIntervalId=e,setTimeout((()=>{E()}),7e3)})())},F.init=async n=>{var s,i;if(w("=== Init zonos script release date","info",P.releaseDate),N&&!window.isZonosPreview){w(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${N}`,"info");const e=document.createElement("script");return e.src=`${N}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=P.isBigCommerce,window.Zonos.isLegacyCheckout=P.isLegacyCheckout,window.Zonos.startLoadTime=P.startLoadTime,window.Zonos.init(n)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${N}`)})),void(window.isZonosPreview=!0)}const a=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:d,isLegacyCartId:l}=k(a);if(a&&!l&&!d)return void P.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${a}`,metadata:{invalidCartId:!0}});P.cartId=a;const c=document.querySelector('script[src*="/zonos.js"]'),u=null===(s=document.querySelector("script[src*='/loadZonos.js']"))||void 0===s?void 0:s.src;w(`[ZONOS - init] first load script src: ${u}`,"info"),window.Zonos.zonosQaUrl=N,window.Zonos.zonosQaUrlApi=D,window.Zonos.zonosQaUrl&&w(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&w(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const p=null==u?void 0:u.includes("timestamp=");if(!(P.isNpm||u&&p))return void Z("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(c||!u||P.requested)return void w("[ZONOS - loadZonos] script is already loaded or requested","info");if(!n.zonosApiKey&&!P.cartId)return P.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void Z("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(P.requested=!0,P.zonosApiKey=n.zonosApiKey,P.storeId=n.storeId,P.cartId){const e=await(async e=>{const{isDgsCartId:o,isLegacyCartId:n}=k(e);if(!n&&!o)return Z("[ZONOS - loadZonos] invalid cart id"),null;const t=await U({cartId:e,retries:5});return w("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(Z("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(P.cartId);if(!e)throw P.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");P.cartData=e.cartData,P.cartSettings=e.settings,P.legacyStoreLogo=e.storeLogo,P.legacyStoreFavicon=e.storeFavicon,P.storeId=e.storeId,P.zonosApiKey=e.zonosApiKey,P.isCollect=e.cartData.type.includes("COLLECT"),P.isInvoice="INVOICE"===e.cartData.type}if(!P.zonosApiKey)return void Z('"zonosApiKey" is required to initialize Zonos');const g=await(async()=>{const e=r(),o=t();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(w("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return w("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:n,json:s}=await z("/api/get-test-public-credential");if(n.length||!s)return Z("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",n),null;const i=s.publicCredential;return i?(w(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(Z("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(g&&(w(`[ZONOS - loadZonos] Using test API key: ${g} for test mode`,"info"),P.zonosApiKey=g),!P.cartId){const{json:n,zonosMode:t}=await(async()=>{if(window.Zonos.cartSettings)return w("Reusing cached zonos settings"),{errors:[],json:window.Zonos.cartSettings,zonosMode:window.Zonos.zonosMode};const n=e(),t=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&t.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const r=o();r&&t.set("zCountry",r);const{errors:s,json:i,zonosMode:a}=await z(`/api/zonos-elements/zonos-settings?${t.toString()}`);return s.length?(Z("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings"),{errors:s,json:null,zonosMode:a}):{errors:[],json:i,zonosMode:a}})();(null==n?void 0:n.appearanceSettings)&&(null==n?void 0:n.checkoutSettings)&&(null==n?void 0:n.helloSettings)&&(null==n?void 0:n.organization)&&(w("[ZONOS - loadZonos] Prefetching zonos settings","info"),P.cartSettings={appearanceSettings:n.appearanceSettings,checkoutSettings:n.checkoutSettings,credentialTokenId:P.zonosApiKey,genericSettings:n.genericSettings,helloSettings:n.helloSettings,inclusivePriceConfigurations:n.inclusivePriceConfigurations,landedCostSettings:n.landedCostSettings,onlineStoreSettings:n.onlineStoreSettings,organization:n.organization,organizationId:(null===(i=n.organization)||void 0===i?void 0:i.id)||"",shippingZones:n.shippingZones},P.zonosMode=t)}P.handlePerformBlurCurrency();const m=P.storeId||n.storeId||0;w(`[ZONOS - loadZonos] Store ID: ${m}`,"info");const y=new URLSearchParams;y.set("storeId",m.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&y.set("_enableStoreVersionPinned","1");const{errors:f,json:h}=await z(`/api/get-store-version?${y.toString()}`);if(f.length||!h)return w("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void P.injectZonos({initConfig:n,vercelUrl:"https://v1.3.268.js.zonos.com",version:null});const{isDifferent:v,source:S,version:C}=h;if(w(`[ZONOS - loadZonos] Store version: ${C}, source: ${S}`,"info"),v){w(`[ZONOS - loadZonos] Updating saved store version to ${C}`,"info");const e={storeId:m,version:C};z(`/api/set-store-version?${y.toString()}`,{body:e,method:"POST"}).catch((e=>Z("Unable to save store's vesrion",e)))}if(!c){const{currentLoadScriptUrl:e,isForceLoadVersionDomain:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),t=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:t,isWhiteListed:n}})({loadScriptSrc:u}),r=t&&!o?e:`${"alpha"===C?"alpha":`v${C}`}.js.zonos.com`,s=t&&!o?null:C;w("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:o,isWhiteListed:t,loadUrl:r,loadVersion:s,version:C}),P.injectZonos({initConfig:n,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview&&!window.Zonos.doneInit)&&(window.Zonos=F)})();
|
|
1
|
+
(function(){"use strict";const e=()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}},o=()=>{const e=new URL(window.location.href),o=window.sessionStorage.getItem("zonos--country");return(e=>{const o=new URLSearchParams(e||window.location.search),n=e=>{return(n=o.get(e))&&/^[A-Z]{2}$/.test(n)?n:null;var n},t=n("zCountry"),r=n("country"),s=n("customerCountry");return t||r||s})(e.searchParams)||o};function n(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(e);r<t.length;r++)o.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(e,t[r])&&(n[t[r]]=e[t[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;const t=()=>window.location.search.includes("zonosStagingMode=1"),r=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")},s=["cloudflare","vercel"],i=s[0],a={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},d=a[i],l=(e=i)=>{const o=s.indexOf(e),n=s[o+1];return n||null},c=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},u=performance.now(),p=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"}},w=(e,o,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const e=performance.now()-u,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),i=[`(${s})`,...n];i.map(p).join(" ");if(!(!!(null===(t=window.Zonos)||void 0===t?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let a=document.querySelector("iframe#zonos---debug-logging-iframe");a||(a=document.createElement("iframe"),a.id="zonos---debug-logging-iframe",a.style.display="none",a.style.opacity="0",a.style.position="absolute",a.style.top="-9999px",a.style.left="-9999px",a.style.width="1px",a.style.height="1px",a.style.border="none",a.style.overflow="hidden",a.style.visibility="hidden",document.body.appendChild(a));const d=(null===(r=a.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(o){case"warn":d.warn(e,...i);break;case"info":d.info(e,...i);break;case"error":d.error(e,...i);break;default:d.groupCollapsed(e,...i),d.trace(),d.groupEnd()}},g=()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||n},m=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],y=({apiPath:e,apiType:o,loadTimeInternal:n,loadTimeTotal:t})=>{if(m.includes(e))return;const r=t-n;if(r<0)return;const s=e.split("?")[0]||e,i=(()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=g();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}})(),a="object"==typeof i.userAgent&&i.userAgent.mobile,d={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(l=a,l||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:n,loadTimeTotal:t,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((e=>e.brand)).filter((e=>!/Not.*A.*Brand.*/.test(e))).join(",")};var l;window.Zonos.loadTimeApiInfoList.push(d)},f=async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:t})=>{if(w("sendErrorLog","warn",e,n,o),t){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const r="userAgentData"in window.navigator?window.navigator.userAgentData:null,s={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:r&&r.brands.length>0?r:window.navigator.userAgent},n)};try{fetch(`${d}/api/zonos-elements/log-error`,{body:JSON.stringify(s),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=l();if(!o)return;fetch(`${a[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(s),method:"POST"})}},h=async({response:e,shouldLog:o=!0,shouldThrow:n=!1})=>{try{const o=await e.text(),n=c(o);if(!n)throw new Error(`Failed to parse content: ${o}`);return n}catch(e){if(n)throw e;return o&&console.error(e),null}},v=async({basePathType:e,options:o,path:n})=>{let t;const r=window.Zonos.zonosQaUrlApi||a[e]||i,s=new URL(r+n),d=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("")}})(d));try{t=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const l=t.headers.get("Zonos-Mode"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&l&&c&&(window.Zonos.modeAlerted=!0),t.ok){return{baseUrl:r,errors:[],json:await h({response:t}),response:t,zonosMode:l}}const u=t.status.toString();try{const e=await h({response:t,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:u}:e)),json:null,response:t,zonosMode:l}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:u}],json:null,response:t,zonosMode:l}}catch(e){return{baseUrl:r,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:l}}},S=async({basePathType:e,options:o,path:t})=>{var r,s;const i=t.startsWith("/api/bigcommerce")?"vercel":e,d=performance.now(),u=await v({basePathType:i,options:o,path:t}),{errors:p,response:g}=u,m=n(u,["errors","response"]),h=performance.now()-d;w(`${t} (${h.toFixed(2)}ms)`,"info");const z=null==g?void 0:g.headers.get("Zonos-Duration");200===(null==g?void 0:g.status)&&y({apiPath:t,apiType:i,loadTimeInternal:z?Number(z):0,loadTimeTotal:h});const Z=l(i),C=p.find((({type:e})=>"unknown"===e)),b=p.find((({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted")))),I=!!C||404===(null==g?void 0:g.status)||500===(null==g?void 0:g.status),L=Z&&I;return I&&!b&&f({endpoint:a[i]+t,errors:p.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:Z,requestHeaders:null==o?void 0:o.headers,requestPayload:c(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()),shouldCallFallback:L,status:null==g?void 0:g.status,statusText:null==g?void 0:g.statusText},shouldPostReleaseErrorReporting:!0}),L?(w(`=== "${t}" failed to fetch, trying next fallback ${Z}`),S({basePathType:Z,options:o,path:t})):Object.assign({errors:p,response:g},m)},z=async(e,o)=>{const s=n(o||{},[]),a=s.body?JSON.stringify(s.body):void 0,d=s.method||"GET",l=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":t()?"1":void 0,"Zonos-Test-Mode":r()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},s.headers);Object.keys(l).forEach((e=>void 0===l[e]&&delete l[e]));const c=Object.assign(Object.assign({},s),{body:"GET"===d?void 0:a,headers:l,method:d}),u=new URLSearchParams(window.location.search).get("useFallbackApi");return S({basePathType:u||i,options:c,path:e})},Z=(e,...o)=>{w(e,"error",...o)},C=["jsdelivr","cdnjs","unpkg","vercel"],b=e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");if(!o)return null;return/[^a-zA-Z0-9-_]+/.test(o)?null:o},I=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,L=new RegExp(`^${I.source}$`),O=new RegExp(`^cart_${I.source}$`),A=/^[a-zA-Z0-9]{2,}$/,T=/^cart_[a-zA-Z0-9]{2,}$/,k=e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:T.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:A.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:O.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:L.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1},U=async({cartId:o,retries:n})=>{const t=r(),s=e(),i=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,a=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&a.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:d,json:l,zonosMode:c}=await z(`/api/zonos-elements/get-cart?${a.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:i,tempCartUUID:o},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||d.length;return u&&n?(w("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise((e=>setTimeout(e,500))),U({cartId:o,retries:n-1})):u?null:Object.assign(Object.assign({},l),{zonosMode:c})},j="z--blur",E=async()=>{const e=window.zonosBlurCurrencyOnInitIntervalId;if(!e)return;await new Promise((e=>setTimeout(e,500))),clearInterval(e);document.querySelectorAll(`.${j}`).forEach((e=>{e.classList.remove(j)})),window.zonosBlurCurrencyOnInitIntervalId=void 0},$=({currencySelector:e,specificSelector:o})=>{if(e||o)if(o)o.classList.add(j);else{document.querySelectorAll([e].filter(Boolean).join(",")).forEach((e=>{e.classList.add(j)}))}};var P;const N=(()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=b(window.location.href),n="https://v1.3.270.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const t=`https://${o}.preview.js.zonos.com`;return w(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,n=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null})),t})(),D=(()=>{const e=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrlApi");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),o=b(window.location.href),n=e||o;if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com"].includes(window.location.hostname))return"https://dev.demo.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.demo.elements.zonos.com";if(!e)return null;const t=`https://${e}.route.js.zonos.com`;return w(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})(),R=Date.now();class F{}P=F,F.isNpm=!1,F.isBigCommerce=!1,F.googleAnalyticId=null,F.googleAnalyticReady=!1,F.facebookPixelId=null,F.facebookPixelReady=!1,F.requested=!1,F.zonosMode=null,F.cartData=null,F.startLoadTime=R,F.overrideUseCustomAddressForm=!1,F.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,F.version="v1.3.270",F.isLegacyCheckout=!1,F.isCollect=!1,F.isInvoice=!1,F.legacyStoreLogo=null,F.legacyStoreFavicon=null,F.parallelLoadTimes=[],F.parallelLoadState="off",F.releaseDate="1781713935263",F.loadTimeApiInfoList=[],F.cartSettings=null,F.loadScriptLogHandler=async({cdnLoadTime:e,fallbackLoadTime:o,isError:n,metadata:t,scriptLoadUrl:r,storeId:s,type:i})=>{try{const e=window.performance.getEntriesByType("resource").find((e=>{const o=e;return o.name.includes(r)&&"script"===o.initiatorType}));null==e||e.transferSize;(async e=>{})((e&&(null==e?void 0:e.duration)>0?parseFloat(e.duration.toFixed(2)):parseFloat(o.toFixed(2)),Object.assign({decodedBodySize:null==e?void 0:e.decodedBodySize,encodedBodySize:null==e?void 0:e.encodedBodySize,fallbackLoadTime:o,isError:!!n},t)))}catch(e){}},F.loadScriptLogParallelHandler=async e=>{try{if(P.parallelLoadTimes.push(e),2===P.parallelLoadTimes.length){const e=P.parallelLoadTimes.find((e=>"vercel"===e.type)),o=P.parallelLoadTimes.find((e=>"jsdelivr"===e.type));if(!e||!o)return;if(e.isError&&o.isError)return void f({endpoint:`<${e.scriptLoadUrl}> <${o.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:o.fallbackLoadTime,cdnType:o.type,vercelLoadTime:e.fallbackLoadTime}});P.loadScriptLogHandler({cdnLoadTime:o.fallbackLoadTime,fallbackLoadTime:e.fallbackLoadTime,isError:e.isError,metadata:{cdnScriptFallbackTime:o.fallbackLoadTime,cdnScriptIsError:!!o.isError,cdnScriptLoadUrl:o.scriptLoadUrl,cdnScriptType:o.type},scriptLoadUrl:e.scriptLoadUrl,storeId:e.storeId,type:e.type})}}catch(e){}},F.legacyCheckoutErrorHandler=({message:e,metadata:o})=>{Z(`[ZONOS - loadZonos] ${e}`),f({endpoint:"LegacyCheckoutInit",errors:[e],metadata:Object.assign(Object.assign({},o),{tempCartUUID:P.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:e}))},F.getGithubCdn=({type:e,version:o})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.270";"cdnjs"===e?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.270":"unpkg"===e&&(n="https://unpkg.com/@zonos/elements@1.3.270");return o&&"alpha"!==o?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${o}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${o}`):n},F.injectZonos=({cdnType:e="jsdelivr",initConfig:o,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;o=Object.assign(Object.assign({},o),{zonosApiKey:P.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===e?t:P.getGithubCdn({type:e,version:r}),a=N||i,d=a.replace("https://","").replace("http://",""),l=document.createElement("script"),c=r&&r<"1.2.5"?"loadZonos.js":"zonos.js";l.src=`https://${d}/dist/scripts/${c}?timestamp=${Date.now()}`,w(`[ZONOS - loadZonos] Injecting "${c}" from "${d}"`,"info");const u="4g"===(null===(s=g())||void 0===s?void 0:s.effectiveType),p=["dev.elements.zonos.com","zonos.com"].some((e=>window.location.href.includes(e))),m=C[0]===e,y=C[1],h="on"===P.parallelLoadState&&u&&m&&y&&!p;h&&P.injectZonos({cdnType:y,initConfig:o,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();l.addEventListener("load",(async()=>{if(h||n?P.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:l.src,storeId:P.storeId||0,type:e}):P.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:l.src,storeId:P.storeId||0,type:e}),P.isBigCommerce||(P.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=N,window.Zonos.zonosQaUrlApi=D,window.Zonos.zonosMode=P.zonosMode,window.Zonos.isBigCommerce=P.isBigCommerce,window.Zonos.loadTimeApiInfoList=P.loadTimeApiInfoList,window.Zonos.overrideUseCustomAddressForm=P.overrideUseCustomAddressForm,window.Zonos.startLoadTime=P.startLoadTime,P.cartSettings&&(window.Zonos.cartSettings=P.cartSettings),P.cartId){const e=P.isCollect?"Collect":"hosted Checkout";if(!P.zonosApiKey)throw P.legacyCheckoutErrorHandler({message:`zonosApiKey is missing to initiate ${e}`}),new Error(`zonosApiKey is required for ${e}`);if(!P.cartData)throw P.legacyCheckoutErrorHandler({message:`cartData is missing to initiate ${e}`}),new Error(`cartData is required for ${e}`);if(P.legacyStoreFavicon&&P.isLegacyCheckout&&!P.isCollect)try{if(200!==(await fetch(P.legacyStoreFavicon)).status)throw new Error("Custom favicon is not available");const e=document.createElement("link");e.rel="shortcut icon",e.type="image/x-icon",e.href=P.legacyStoreFavicon,document.head.appendChild(e)}catch(e){}window.Zonos.cartData=P.cartData,window.Zonos.isLegacyCheckout=P.isLegacyCheckout,window.Zonos.cartSettings=P.cartSettings,window.Zonos.isCollect=P.isCollect,window.Zonos.isInvoice=P.isInvoice;const n=Object.assign(Object.assign({},o),{appearance:Object.assign(Object.assign({},o.appearance),{logoUrl:P.isLegacyCheckout&&!P.isCollect&&P.legacyStoreLogo?P.legacyStoreLogo:void 0}),zonosApiKey:P.zonosApiKey});o=n}window.Zonos.version&&(w(`[ZONOS - loadZonos] Execute "Zonos.init" from "${c}" from "${d}"`,"info"),window.Zonos.init(o))})),l.addEventListener("error",(async()=>{const s=(e=>{const o=C.indexOf(e);return C[o+1]||null})(e);if(!h&&!n){if(!s)return;P.injectZonos({cdnType:s,initConfig:o,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((e=>window.location.href.includes(e)))||N)return;if(h||n)return void P.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:l.src,storeId:P.storeId||0,type:e});["unpkg","cdnjs","vercel"].includes(e)?f({endpoint:l.src,errors:[`zonos.js - Failed to fetch ${e} CDN.`],metadata:{cdnLoadTime:performance.now()-v,cdnType:e,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):f({endpoint:l.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:e,vercelLoadTime:performance.now()-v}})})),document.head.appendChild(l)},F.handlePerformBlurCurrency=()=>{var e,o,n;!(null===(o=null===(e=P.cartSettings)||void 0===e?void 0:e.genericSettings)||void 0===o?void 0:o.blurCurrencyOnInit)?E():(window.zonosBlurCurrencyOnInitCurrencySelector=window.zonosBlurCurrencyOnInitCurrencySelector||(null===(n=P.cartSettings)||void 0===n?void 0:n.helloSettings.currencyElementSelector),(()=>{if("undefined"==typeof window)return;if(window.zonosBlurCurrencyOnInitIntervalId)return;$({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector});const e=setInterval((()=>{$({currencySelector:window.zonosBlurCurrencyOnInitCurrencySelector})}),10);window.zonosBlurCurrencyOnInitIntervalId=e,setTimeout((()=>{E()}),7e3)})())},F.init=async n=>{var s,i;if(w("=== Init zonos script release date","info",P.releaseDate),N&&!window.isZonosPreview){w(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${N}`,"info");const e=document.createElement("script");return e.src=`${N}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(e),e.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=P.isBigCommerce,window.Zonos.isLegacyCheckout=P.isLegacyCheckout,window.Zonos.startLoadTime=P.startLoadTime,window.Zonos.init(n)})),e.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${N}`)})),void(window.isZonosPreview=!0)}const a=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:d,isLegacyCartId:l}=k(a);if(a&&!l&&!d)return void P.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${a}`,metadata:{invalidCartId:!0}});P.cartId=a;const c=document.querySelector('script[src*="/zonos.js"]'),u=null===(s=document.querySelector("script[src*='/loadZonos.js']"))||void 0===s?void 0:s.src;w(`[ZONOS - init] first load script src: ${u}`,"info"),window.Zonos.zonosQaUrl=N,window.Zonos.zonosQaUrlApi=D,window.Zonos.zonosQaUrl&&w(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&w(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const p=null==u?void 0:u.includes("timestamp=");if(!(P.isNpm||u&&p))return void Z("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(c||!u||P.requested)return void w("[ZONOS - loadZonos] script is already loaded or requested","info");if(!n.zonosApiKey&&!P.cartId)return P.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void Z("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(P.requested=!0,P.zonosApiKey=n.zonosApiKey,P.storeId=n.storeId,P.cartId){const e=await(async e=>{const{isDgsCartId:o,isLegacyCartId:n}=k(e);if(!n&&!o)return Z("[ZONOS - loadZonos] invalid cart id"),null;const t=await U({cartId:e,retries:5});return w("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(Z("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(P.cartId);if(!e)throw P.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");P.cartData=e.cartData,P.cartSettings=e.settings,P.legacyStoreLogo=e.storeLogo,P.legacyStoreFavicon=e.storeFavicon,P.storeId=e.storeId,P.zonosApiKey=e.zonosApiKey,P.isCollect=e.cartData.type.includes("COLLECT"),P.isInvoice="INVOICE"===e.cartData.type}if(!P.zonosApiKey)return void Z('"zonosApiKey" is required to initialize Zonos');const g=await(async()=>{const e=r(),o=t();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(w("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return w("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:n,json:s}=await z("/api/get-test-public-credential");if(n.length||!s)return Z("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",n),null;const i=s.publicCredential;return i?(w(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(Z("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(g&&(w(`[ZONOS - loadZonos] Using test API key: ${g} for test mode`,"info"),P.zonosApiKey=g),!P.cartId){const{json:n,zonosMode:t}=await(async()=>{if(window.Zonos.cartSettings)return w("Reusing cached zonos settings"),{errors:[],json:window.Zonos.cartSettings,zonosMode:window.Zonos.zonosMode};const n=e(),t=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&t.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const r=o();r&&t.set("zCountry",r);const{errors:s,json:i,zonosMode:a}=await z(`/api/zonos-elements/zonos-settings?${t.toString()}`);return s.length?(Z("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings"),{errors:s,json:null,zonosMode:a}):{errors:[],json:i,zonosMode:a}})();(null==n?void 0:n.appearanceSettings)&&(null==n?void 0:n.checkoutSettings)&&(null==n?void 0:n.helloSettings)&&(null==n?void 0:n.organization)&&(w("[ZONOS - loadZonos] Prefetching zonos settings","info"),P.cartSettings={appearanceSettings:n.appearanceSettings,checkoutSettings:n.checkoutSettings,credentialTokenId:P.zonosApiKey,genericSettings:n.genericSettings,helloSettings:n.helloSettings,inclusivePriceConfigurations:n.inclusivePriceConfigurations,landedCostSettings:n.landedCostSettings,onlineStoreSettings:n.onlineStoreSettings,organization:n.organization,organizationId:(null===(i=n.organization)||void 0===i?void 0:i.id)||"",shippingZones:n.shippingZones},P.zonosMode=t)}P.handlePerformBlurCurrency();const m=P.storeId||n.storeId||0;w(`[ZONOS - loadZonos] Store ID: ${m}`,"info");const y=new URLSearchParams;y.set("storeId",m.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&y.set("_enableStoreVersionPinned","1");const{errors:f,json:h}=await z(`/api/get-store-version?${y.toString()}`);if(f.length||!h)return w("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void P.injectZonos({initConfig:n,vercelUrl:"https://v1.3.270.js.zonos.com",version:null});const{isDifferent:v,source:S,version:C}=h;if(w(`[ZONOS - loadZonos] Store version: ${C}, source: ${S}`,"info"),v){w(`[ZONOS - loadZonos] Updating saved store version to ${C}`,"info");const e={storeId:m,version:C};z(`/api/set-store-version?${y.toString()}`,{body:e,method:"POST"}).catch((e=>Z("Unable to save store's vesrion",e)))}if(!c){const{currentLoadScriptUrl:e,isForceLoadVersionDomain:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),t=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:t,isWhiteListed:n}})({loadScriptSrc:u}),r=t&&!o?e:`${"alpha"===C?"alpha":`v${C}`}.js.zonos.com`,s=t&&!o?null:C;w("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:e,isForceLoadVersionDomain:o,isWhiteListed:t,loadUrl:r,loadVersion:s,version:C}),P.injectZonos({initConfig:n,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview&&!window.Zonos.doneInit)&&(window.Zonos=F)})();
|
package/dist/scripts/zonos.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const e=({id:e,payload:o,target:t,type:n})=>{var r;t instanceof HTMLIFrameElement?null===(r=t.contentWindow)||void 0===r||r.postMessage({id:e,payload:o,type:n},"*"):t.postMessage({id:e,payload:o,type:n},"*")};class o{constructor(o,t){this.targetElement=o,this.targetId=t,this.sendMessage=(o,t)=>{e({id:this.targetId,payload:t,target:this.targetElement,type:o})}}}o.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},o.sendMessage=e,o.injectPrivateIframe=({id:e,onload:o,src:t})=>{const n=document.createElement("iframe");return n.src=t,n.id=e,n.style.display="none",n.role="presentation",n.ariaHidden="true",n.tabIndex=-1,n.style.border="none !important",n.style.margin="0px !important",n.style.padding="0px !important",n.style.width="1px !important",n.style.minWidth="100% !important",n.style.overflow="hidden !important",n.style.display="block !important",n.style.visibility="hidden !important",n.style.position="fixed !important",n.style.pointerEvents="none !important",n.style.userSelect="none !important",n.style.height="1px !important",n.onload=()=>o(n),document.body.appendChild(n),n};const t=performance.now(),n=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},r=(e,o,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const e=performance.now()-t,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),l=[`(${a})`,...r];l.map(n).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const c=(null===(i=d.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(o){case"warn":c.warn(e,...l);break;case"info":c.info(e,...l);break;case"error":c.error(e,...l);break;default:c.groupCollapsed(e,...l),c.trace(),c.groupEnd()}},s=(e,...o)=>{r(e,"error",...o)},i=["jsdelivr","cdnjs","unpkg","vercel"],a="jsdelivr",l=e=>{const o=i.indexOf(e);return i[o+1]||null},d=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function u(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const p=["cloudflare","vercel"],m=p[0],w={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},h=w[m],y=(e=m)=>{const o=p.indexOf(e),t=p[o+1];return t||null},g=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},f=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},v=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],b=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=g(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},S=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||w[e]||m,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await b({response:n}),response:n,zonosMode:a}}const d=n.status.toString();try{const e=await b({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:d}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:d}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${d}: ${"Unknown error"}`,type:d}],json:null,response:null,zonosMode:a}}},C=async({basePathType:e,options:o,path:t})=>{var n,s;const i=t.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await S({basePathType:i,options:o,path:t}),{errors:d,response:c}=l,p=u(l,["errors","response"]),m=performance.now()-a;r(`${t} (${m.toFixed(2)}ms)`,"info");const b=null==c?void 0:c.headers.get("Zonos-Duration");200===(null==c?void 0:c.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(v.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=f(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(d=a,d||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((e=>e.brand)).filter((e=>!/Not.*A.*Brand.*/.test(e))).join(",")};var d;window.Zonos.loadTimeApiInfoList.push(l)})({apiPath:t,apiType:i,loadTimeInternal:b?Number(b):0,loadTimeTotal:m});const z=y(i),k=d.find((({type:e})=>"unknown"===e)),Z=d.find((({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted")))),j=!!k||404===(null==c?void 0:c.status)||500===(null==c?void 0:c.status),I=z&&j;return j&&!Z&&(async({endpoint:e,errors:o,metadata:t,shouldPostReleaseErrorReporting:n})=>{r("sendErrorLog","warn",e,t,o);{const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},t)};try{fetch(`${h}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=y();if(!o)return;fetch(`${w[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:w[i]+t,errors:d.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:z,requestHeaders:null==o?void 0:o.headers,requestPayload:g(null===(n=null==o?void 0:o.body)||void 0===n?void 0:n.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),shouldCallFallback:I,status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),I?(r(`=== "${t}" failed to fetch, trying next fallback ${z}`),C({basePathType:z,options:o,path:t})):Object.assign({errors:d,response:c},p)},z=async(e,o)=>{const t=u(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",s=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":d()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const i=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:n,headers:s,method:r}),a=new URLSearchParams(window.location.search).get("useFallbackApi");return C({basePathType:a||m,options:i,path:e})},k=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),t="https://v1.3.268.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const n=`https://${o}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${n}' for loading elements script`,"warn"),fetch(n).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),n},Z="https://js.stripe.com/v3",j=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let I=null;const O=e=>(null!==I||(I=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)o(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${Z}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&j.test(t.src))return t}return null})();n&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):n||(n=(e=>{const o=document.createElement("script");o.src=`${Z}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(s("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==n||n.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),I),A=Promise.resolve().then((()=>O(null)));let E=!1;A.catch((e=>{E||console.warn(e)}));const T=async({cartId:e,retries:o})=>{const t=c(),n=(()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}})(),s=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,i=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const{errors:a,json:l,zonosMode:d}=await z(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||a.length;return u&&o?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),T({cartId:e,retries:o-1})):u?null:Object.assign(Object.assign({},l),{zonosMode:d})},L=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,P=new RegExp(`^${L.source}$`),$=new RegExp(`^cart_${L.source}$`),U=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,D=async e=>{const{isDgsCartId:o,isLegacyCartId:t}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:$.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:P.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!t&&!o)return s("[ZONOS - loadZonos] invalid cart id"),null;const n=await T({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",n),n?(window.Zonos.storeId=n.cartData.storeId,window.Zonos.zonosApiKey=n.cartData.credentialToken,window.Zonos.zonosMode=n.zonosMode,{cartData:n.cartData,settings:n.settings,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}):(s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)},R="zonos--checkout-hidden-international-button";var F;const x=(()=>{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})(),M=Date.now(),B="https://v1.3.268.js.zonos.com",q=x||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.268",W="https://fonts.googleapis.com",K=/^https:\/\/fonts\.googleapis\.com/;class G{}F=G,G.doneInit=!1,G.cartSettings=null,G.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),G.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),G._paypalMockResponse=null,G.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,G.isBigCommerce=!1,G.releaseDate="1780932992776",G.isLegacyCheckout=!1,G.googleAnalyticId=null,G.googleAnalyticReady=!1,G.facebookPixelId=null,G.facebookPixelReady=!1,G.startLoadTime=M,G.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",G.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),G.overrideUseCustomAddressForm=!1,G.isCollect=!1,G.isInvoice=!1,G.isNpm=!0,G.zonosQaUrl=null,G.zonosQaUrlApi=null,G.trackEventLogs=[],G.version="v1.3.268",G.modeAlerted=!1,G.cartData=null,G.paypal=null,G.zonosMode=null,G.IframeService=o,G.getCurrentTimestamp=()=>(new Date).getTime(),G.zonosController=null,G.loadTimeApiInfoList=[],G.logIntervalId=null,G.init=async e=>{const{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:u,zonosApiKey:p}=e;if(F.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),F.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${F.version}) ======`),F.zonosApiKey=p,F.storeId=u,"undefined"!=typeof window&&window.parent===window&&(F.googleAnalyticReady=!0,F.facebookPixelReady=!0),F.isNpm){r("====== ZONOS LOADING FROM NPM ======");const o=k();if(o&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const t=document.createElement("script");return t.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(t),t.addEventListener("load",(()=>{window.Zonos.isNpm=F.isNpm,window.Zonos.isBigCommerce=F.isBigCommerce,window.Zonos.isLegacyCheckout=F.isLegacyCheckout,window.Zonos.zonosMode=F.zonosMode,window.Zonos.init(e)})),t.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!F.cartId)return void s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!F.cartData&&F.cartId){r("Initialize cart data");const e=await D(F.cartId);if(!e)return void s("Failed to get cart data");F.cartData=e.cartData,F.zonosApiKey=e.zonosApiKey,F.cartSettings=e.settings}const t=await(async()=>{const e=c(),o=d();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:t,json:n}=await z("/api/get-test-public-credential");if(t.length||!n)return s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t),null;const i=n.publicCredential;return i?(r(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(s("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();t&&(F.zonosApiKey=t)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(F.cartId&&F.cartData||!!m){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}r("init zonos"),F.restoreNativeBrowserFunctions(),F.injectCustomScriptForHostedCheckout(),F.injectZonosCdn(),F.injectZonosCss(),F.injectFonts(),F.injectCheckoutInternationalButton(),F.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),F.doneInit=!0},G.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${R}`)){const e=document.createElement("button");e.id=R,e.style.display="none",document.body.appendChild(e)}},G.injectCustomScriptForHostedCheckout=()=>{const e=F.cartData,o=(null==e?void 0:e.metadata)||[],t=o.find((e=>"customHeaderScript"===e.key)),n=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(t||n)){if(t){r("Injecting custom header script");const e=document.createElement("script");e.textContent=t.value,document.head.appendChild(e)}if(n){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=n.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:n,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout})},G.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},G.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${R}`);setTimeout((()=>{var o;e&&e.dispatchEvent(new CustomEvent("click",{detail:o}))}),10)},G.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},G.showNotification=e=>{var o;null===(o=F.zonosController)||void 0===o||o.showNotification(e)},G.updateOrganizationName=e=>{var o;null===(o=F.zonosController)||void 0===o||o.updateOrganizationName(e)},G.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)}},G.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},G.injectController=({config:e})=>{var o,t;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=F.zonosApiKey||"",n.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;r("loading Stripe");const t=await(async(...e)=>{E=!0;const o=Date.now();return A.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);t?(window.Zonos.stripe=t,window.Zonos.isCollect?n.initCollectElement(t):window.Zonos.isInvoice?n.initInvoiceElement(t):n.initCheckoutElement(t)):s("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(n),F.zonosController=n,r("Zonos controller injected!")},G.injectScript=({cdnType:e,isModule:o,theRestUrl:t})=>{const n=`${F.getZonosUrl(e)}/${t}`;if(document.querySelector(`script[src="${n}"]`))return void r(`Zonos script "${n}" already exists in the document`,"warn");const i=document.head||document.body,a=document.createElement("script");o?a.type="module":a.noModule=!0,a.src=n,a.crossOrigin="anonymous",a.onerror=()=>{s(`Failed to load ${a.src}`);const n=l(e);n&&F.injectScript({cdnType:n,isModule:o,theRestUrl:t})},i.appendChild(a)},G.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return q;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.268";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.268";case"vercel":return B}};if(F.isNpm){return k()||o()}return o()},G.injectZonosCdn=()=>{F.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),F.injectScript({cdnType:a,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},G.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=F.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${B}/`,n.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{s(`Failed to load ${i.href}`);const t=l(e);t&&F.injectStylesheet({cdnType:t,theRestUrl:o})},n.appendChild(i)},G.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(F.injectStylesheet({cdnType:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},G.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${W}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!K.test(t.href))return t}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=W,e.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${W}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(t),r("Zonos font injected!")},G.setupGoogleFont=e=>{var o;null===(o=F.zonosController)||void 0===o||o.setupGoogleFont(e)},G.injectSupportGoogleFont=e=>{var o;r(`[FONT] injecting ${e}`);const t=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${W}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=W,n.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${t} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,n.appendChild(s),r(`[FONT] ${t} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=G)})();
|
|
1
|
+
(function(){"use strict";const e=({id:e,payload:o,target:t,type:n})=>{var r;t instanceof HTMLIFrameElement?null===(r=t.contentWindow)||void 0===r||r.postMessage({id:e,payload:o,type:n},"*"):t.postMessage({id:e,payload:o,type:n},"*")};class o{constructor(o,t){this.targetElement=o,this.targetId=t,this.sendMessage=(o,t)=>{e({id:this.targetId,payload:t,target:this.targetElement,type:o})}}}o.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},o.sendMessage=e,o.injectPrivateIframe=({id:e,onload:o,src:t})=>{const n=document.createElement("iframe");return n.src=t,n.id=e,n.style.display="none",n.role="presentation",n.ariaHidden="true",n.tabIndex=-1,n.style.border="none !important",n.style.margin="0px !important",n.style.padding="0px !important",n.style.width="1px !important",n.style.minWidth="100% !important",n.style.overflow="hidden !important",n.style.display="block !important",n.style.visibility="hidden !important",n.style.position="fixed !important",n.style.pointerEvents="none !important",n.style.userSelect="none !important",n.style.height="1px !important",n.onload=()=>o(n),document.body.appendChild(n),n};const t=performance.now(),n=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},r=(e,o,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const e=performance.now()-t,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),l=[`(${a})`,...r];l.map(n).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;let d=document.querySelector("iframe#zonos---debug-logging-iframe");d||(d=document.createElement("iframe"),d.id="zonos---debug-logging-iframe",d.style.display="none",d.style.opacity="0",d.style.position="absolute",d.style.top="-9999px",d.style.left="-9999px",d.style.width="1px",d.style.height="1px",d.style.border="none",d.style.overflow="hidden",d.style.visibility="hidden",document.body.appendChild(d));const c=(null===(i=d.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(o){case"warn":c.warn(e,...l);break;case"info":c.info(e,...l);break;case"error":c.error(e,...l);break;default:c.groupCollapsed(e,...l),c.trace(),c.groupEnd()}},s=(e,...o)=>{r(e,"error",...o)},i=["jsdelivr","cdnjs","unpkg","vercel"],a="jsdelivr",l=e=>{const o=i.indexOf(e);return i[o+1]||null},d=()=>window.location.search.includes("zonosStagingMode=1"),c=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function u(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const p=["cloudflare","vercel"],m=p[0],w={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},h=w[m],y=(e=m)=>{const o=p.indexOf(e),t=p[o+1];return t||null},g=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},f=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},v=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],b=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=g(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},S=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||w[e]||m,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await b({response:n}),response:n,zonosMode:a}}const d=n.status.toString();try{const e=await b({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:d}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:d}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${d}: ${"Unknown error"}`,type:d}],json:null,response:null,zonosMode:a}}},C=async({basePathType:e,options:o,path:t})=>{var n,s;const i=t.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await S({basePathType:i,options:o,path:t}),{errors:d,response:c}=l,p=u(l,["errors","response"]),m=performance.now()-a;r(`${t} (${m.toFixed(2)}ms)`,"info");const b=null==c?void 0:c.headers.get("Zonos-Duration");200===(null==c?void 0:c.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(v.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=f(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(d=a,d||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((e=>e.brand)).filter((e=>!/Not.*A.*Brand.*/.test(e))).join(",")};var d;window.Zonos.loadTimeApiInfoList.push(l)})({apiPath:t,apiType:i,loadTimeInternal:b?Number(b):0,loadTimeTotal:m});const z=y(i),k=d.find((({type:e})=>"unknown"===e)),Z=d.find((({message:e})=>"string"==typeof e&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted")))),j=!!k||404===(null==c?void 0:c.status)||500===(null==c?void 0:c.status),I=z&&j;return j&&!Z&&(async({endpoint:e,errors:o,metadata:t,shouldPostReleaseErrorReporting:n})=>{r("sendErrorLog","warn",e,t,o);{const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},t)};try{fetch(`${h}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=y();if(!o)return;fetch(`${w[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:w[i]+t,errors:d.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:z,requestHeaders:null==o?void 0:o.headers,requestPayload:g(null===(n=null==o?void 0:o.body)||void 0===n?void 0:n.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),shouldCallFallback:I,status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),I?(r(`=== "${t}" failed to fetch, trying next fallback ${z}`),C({basePathType:z,options:o,path:t})):Object.assign({errors:d,response:c},p)},z=async(e,o)=>{const t=u(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",s=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":d()?"1":void 0,"Zonos-Test-Mode":c()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const i=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:n,headers:s,method:r}),a=new URLSearchParams(window.location.search).get("useFallbackApi");return C({basePathType:a||m,options:i,path:e})},k=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),t="https://v1.3.270.js.zonos.com";if(!o&&(t.includes("test.")||t.includes("test-")))return t;if(!o&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const n=`https://${o}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${n}' for loading elements script`,"warn"),fetch(n).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${n}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),n},Z="https://js.stripe.com/v3",j=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let I=null;const O=e=>(null!==I||(I=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)o(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${Z}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&j.test(t.src))return t}return null})();n&&e?console.warn("loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used"):n||(n=(e=>{const o=document.createElement("script");o.src=`${Z}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(s("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==n||n.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),I),A=Promise.resolve().then((()=>O(null)));let E=!1;A.catch((e=>{E||console.warn(e)}));const T=async({cartId:e,retries:o})=>{const t=c(),n=(()=>{const e=new URLSearchParams(window.location.search);return{overrideShouldEnabledCustomAddress:window.Zonos.overrideUseCustomAddressForm?"1":e.get("overrideShouldEnabledCustomAddress")}})(),s=(()=>{const e=new URLSearchParams(window.location.search).get("validityToken");if(!e||!/^[A-Za-z0-9+/]+={0,2}$/.test(e)||e.length%4!=0)return null;try{return atob(e),e}catch(e){return null}})()||void 0,i=new URLSearchParams;n.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",n.overrideShouldEnabledCustomAddress);const{errors:a,json:l,zonosMode:d}=await z(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||a.length;return u&&o?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),T({cartId:e,retries:o-1})):u?null:Object.assign(Object.assign({},l),{zonosMode:d})},L=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,P=new RegExp(`^${L.source}$`),$=new RegExp(`^cart_${L.source}$`),U=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,D=async e=>{const{isDgsCartId:o,isLegacyCartId:t}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:$.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:P.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!t&&!o)return s("[ZONOS - loadZonos] invalid cart id"),null;const n=await T({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",n),n?(window.Zonos.storeId=n.cartData.storeId,window.Zonos.zonosApiKey=n.cartData.credentialToken,window.Zonos.zonosMode=n.zonosMode,{cartData:n.cartData,settings:n.settings,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}):(s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)},R="zonos--checkout-hidden-international-button";var F;const x=(()=>{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})(),M=Date.now(),B="https://v1.3.270.js.zonos.com",q=x||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.270",W="https://fonts.googleapis.com",K=/^https:\/\/fonts\.googleapis\.com/;class G{}F=G,G.doneInit=!1,G.cartSettings=null,G.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),G.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),G._paypalMockResponse=null,G.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,G.isBigCommerce=!1,G.releaseDate="1781713935263",G.isLegacyCheckout=!1,G.googleAnalyticId=null,G.googleAnalyticReady=!1,G.facebookPixelId=null,G.facebookPixelReady=!1,G.startLoadTime=M,G.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",G.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),G.overrideUseCustomAddressForm=!1,G.isCollect=!1,G.isInvoice=!1,G.isNpm=!0,G.zonosQaUrl=null,G.zonosQaUrlApi=null,G.trackEventLogs=[],G.version="v1.3.270",G.modeAlerted=!1,G.cartData=null,G.paypal=null,G.zonosMode=null,G.IframeService=o,G.getCurrentTimestamp=()=>(new Date).getTime(),G.zonosController=null,G.loadTimeApiInfoList=[],G.logIntervalId=null,G.init=async e=>{const{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:u,zonosApiKey:p}=e;if(F.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),F.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${F.version}) ======`),F.zonosApiKey=p,F.storeId=u,"undefined"!=typeof window&&window.parent===window&&(F.googleAnalyticReady=!0,F.facebookPixelReady=!0),F.isNpm){r("====== ZONOS LOADING FROM NPM ======");const o=k();if(o&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const t=document.createElement("script");return t.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(t),t.addEventListener("load",(()=>{window.Zonos.isNpm=F.isNpm,window.Zonos.isBigCommerce=F.isBigCommerce,window.Zonos.isLegacyCheckout=F.isLegacyCheckout,window.Zonos.zonosMode=F.zonosMode,window.Zonos.init(e)})),t.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!F.cartId)return void s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!F.cartData&&F.cartId){r("Initialize cart data");const e=await D(F.cartId);if(!e)return void s("Failed to get cart data");F.cartData=e.cartData,F.zonosApiKey=e.zonosApiKey,F.cartSettings=e.settings}const t=await(async()=>{const e=c(),o=d();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:t,json:n}=await z("/api/get-test-public-credential");if(t.length||!n)return s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",t),null;const i=n.publicCredential;return i?(r(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(s("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();t&&(F.zonosApiKey=t)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(F.cartId&&F.cartData||!!m){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}r("init zonos"),F.restoreNativeBrowserFunctions(),F.injectCustomScriptForHostedCheckout(),F.injectZonosCdn(),F.injectZonosCss(),F.injectFonts(),F.injectCheckoutInternationalButton(),F.injectController({config:{appearance:o,checkoutSettings:t,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),F.doneInit=!0},G.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${R}`)){const e=document.createElement("button");e.id=R,e.style.display="none",document.body.appendChild(e)}},G.injectCustomScriptForHostedCheckout=()=>{const e=F.cartData,o=(null==e?void 0:e.metadata)||[],t=o.find((e=>"customHeaderScript"===e.key)),n=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(t||n)){if(t){r("Injecting custom header script");const e=document.createElement("script");e.textContent=t.value,document.head.appendChild(e)}if(n){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=n.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:n,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout})},G.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},G.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${R}`);setTimeout((()=>{var o;e&&e.dispatchEvent(new CustomEvent("click",{detail:o}))}),10)},G.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},G.showNotification=e=>{var o;null===(o=F.zonosController)||void 0===o||o.showNotification(e)},G.updateOrganizationName=e=>{var o;null===(o=F.zonosController)||void 0===o||o.updateOrganizationName(e)},G.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)}},G.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},G.injectController=({config:e})=>{var o,t;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.alwaysTriggerInternationalCheckoutSelector){const o=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{F.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=F.zonosApiKey||"",n.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;r("loading Stripe");const t=await(async(...e)=>{E=!0;const o=Date.now();return A.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);t?(window.Zonos.stripe=t,window.Zonos.isCollect?n.initCollectElement(t):window.Zonos.isInvoice?n.initInvoiceElement(t):n.initCheckoutElement(t)):s("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(n),F.zonosController=n,r("Zonos controller injected!")},G.injectScript=({cdnType:e,isModule:o,theRestUrl:t})=>{const n=`${F.getZonosUrl(e)}/${t}`;if(document.querySelector(`script[src="${n}"]`))return void r(`Zonos script "${n}" already exists in the document`,"warn");const i=document.head||document.body,a=document.createElement("script");o?a.type="module":a.noModule=!0,a.src=n,a.crossOrigin="anonymous",a.onerror=()=>{s(`Failed to load ${a.src}`);const n=l(e);n&&F.injectScript({cdnType:n,isModule:o,theRestUrl:t})},i.appendChild(a)},G.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return q;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.270";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.270";case"vercel":return B}};if(F.isNpm){return k()||o()}return o()},G.injectZonosCdn=()=>{F.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),F.injectScript({cdnType:a,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},G.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=F.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${B}/`,n.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${t}/${o}`,i.onerror=()=>{s(`Failed to load ${i.href}`);const t=l(e);t&&F.injectStylesheet({cdnType:t,theRestUrl:o})},n.appendChild(i)},G.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(F.injectStylesheet({cdnType:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},G.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${W}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!K.test(t.href))return t}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=W,e.appendChild(o);const t=document.createElement("link");t.rel="stylesheet",t.href=`${W}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(t),r("Zonos font injected!")},G.setupGoogleFont=e=>{var o;null===(o=F.zonosController)||void 0===o||o.setupGoogleFont(e)},G.injectSupportGoogleFont=e=>{var o;r(`[FONT] injecting ${e}`);const t=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${W}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=W,n.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${t} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,n.appendChild(s),r(`[FONT] ${t} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=G)})();
|
|
@@ -23,6 +23,7 @@ export type BigCommerceCustomerAddress = {
|
|
|
23
23
|
*/
|
|
24
24
|
export type BigCommerceCheckoutResponse = {
|
|
25
25
|
consignments?: {
|
|
26
|
+
id?: string;
|
|
26
27
|
shippingAddress?: BigCommerceCustomerAddress;
|
|
27
28
|
}[];
|
|
28
29
|
customer?: {
|
|
@@ -45,6 +46,14 @@ export declare const fetchCheckoutId: () => Promise<string | null>;
|
|
|
45
46
|
* This API is cookie-authenticated (same-origin), so no token is needed.
|
|
46
47
|
*/
|
|
47
48
|
export declare const fetchBigCommerceCheckout: (checkoutId: string) => Promise<BigCommerceCheckoutResponse | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Delete a consignment (a saved shipping selection, e.g. a domestic shipping
|
|
51
|
+
* quote the shopper added on the cart page) from the active BigCommerce
|
|
52
|
+
* checkout via the Storefront API. Cookie-authenticated (same-origin), so no
|
|
53
|
+
* token is needed. Returns the updated checkout on success, or null on
|
|
54
|
+
* failure.
|
|
55
|
+
*/
|
|
56
|
+
export declare const deleteBigCommerceConsignment: (checkoutId: string, consignmentId: string) => Promise<BigCommerceCheckoutResponse | null>;
|
|
48
57
|
/**
|
|
49
58
|
* Whether the BigCommerce shopper is already logged in. We key off the
|
|
50
59
|
* customer's numeric `id` since the storefront API populates it only for
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On the BigCommerce cart page, drop any native domestic shipping quote the
|
|
3
|
+
* shopper added before they switched to an international country, then reload
|
|
4
|
+
* the page.
|
|
5
|
+
*
|
|
6
|
+
* The native cart stores a shipping estimate as a consignment on the active
|
|
7
|
+
* checkout. When Hello is shown the shopper is checking out internationally
|
|
8
|
+
* through Zonos, so that domestic shipping cost should not linger in the Grand
|
|
9
|
+
* Total. We delete the consignment(s) and reload so the server re-renders the
|
|
10
|
+
* cart consistently (subtotal, shipping, and Grand Total all add up).
|
|
11
|
+
*
|
|
12
|
+
* No-ops unless all of the following hold: the host is BigCommerce, the shopper
|
|
13
|
+
* is on the cart page, they are in a shipping zone with Hello shown, and the
|
|
14
|
+
* active checkout actually has a consignment. Because the reload happens only
|
|
15
|
+
* when a consignment is found and removed, the freshly-loaded page has none —
|
|
16
|
+
* so this cannot loop.
|
|
17
|
+
*/
|
|
18
|
+
export declare const removeBigcommerceCartShipping: () => Promise<void>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the Hello widget should be shown for the current shopper. This is the
|
|
3
|
+
* single source of truth for Hello's visibility decision — the `zonos-hello`
|
|
4
|
+
* component renders by it, and other features (e.g. BigCommerce cart shipping
|
|
5
|
+
* cleanup) gate on it so their behavior stays in lockstep with what the shopper
|
|
6
|
+
* actually sees.
|
|
7
|
+
*
|
|
8
|
+
* Resolves the configured `widgetVisibility` behavior (with the deprecated
|
|
9
|
+
* `showForCountries` override) against the selected country and shipping-zone
|
|
10
|
+
* state, then applies the include/exclude country overrides.
|
|
11
|
+
*
|
|
12
|
+
* @param showLog - emit a debug log when the shopper is not in a shipping zone.
|
|
13
|
+
* Defaults to `true`; pass `false` from non-rendering callers to avoid log
|
|
14
|
+
* noise.
|
|
15
|
+
*/
|
|
16
|
+
export declare const shouldShowHelloWidget: (showLog?: boolean) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as n}from"./p-595f5dd2.js";import{g as o,I as t}from"./p-e7b0c156.js";import{l as r}from"./p-0a377722.js";export{a as availableTestKeys}from"./p-0a377722.js";import{g as i,a as l,h as u,l as m}from"./p-41dd1cb8.js";import{g as p,_ as w,c as f,a as h}from"./p-b2d81c98.js";export{c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector,d as domesticRedirectedBtnSelector}from"./p-b2d81c98.js";export{c as countryRequireShortAddressCode}from"./p-1d42cd20.js";export{c as countryRequireTaxId,e as euCountryCodes,s as shipToTaxIdLabels}from"./p-6b361d2b.js";const y=["jsdelivr","cdnjs","unpkg","vercel"],v="jsdelivr",O=e=>{const n=y.indexOf(e);return y[n+1]||null},S=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const n=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),o="https://v1.3.268.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-")))return o;if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";const t=`https://${n}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),t},g="https://js.stripe.com/v3",j=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,z="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let b=null;const N=Promise.resolve().then((()=>{return e=null,null!==b||(b=new Promise(((n,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(z),window.Stripe)n(window.Stripe);else try{let t=(()=>{const e=document.querySelectorAll(`script[src^="${g}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&j.test(o.src))return o}return null})();t&&e?console.warn(z):t||(t=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${g}${n}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(m("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==t||t.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):o(new Error("Stripe.js not available"))})),null==t||t.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else n(null)}))),b;var e}));let I=!1;N.catch((e=>{I||console.warn(e)}));const k=async({cartId:e,retries:n})=>{const t=i(),s=o(),c=p()||void 0,d=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&d.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:l,json:a,zonosMode:m}=await u(`/api/zonos-elements/get-cart?${d.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:c,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),w=!a||l.length;return w&&n?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise((e=>setTimeout(e,500))),k({cartId:e,retries:n-1})):w?null:Object.assign(Object.assign({},a),{zonosMode:m})};var R;const T=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),$=Date.now(),Z="https://v1.3.268.js.zonos.com",A=T||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.268",L="https://fonts.googleapis.com",U=/^https:\/\/fonts\.googleapis\.com/;class C{}R=C,C.doneInit=!1,C.cartSettings=null,C.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),C.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),C._paypalMockResponse=null,C.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,C.isBigCommerce=!1,C.releaseDate="1780932937557",C.isLegacyCheckout=!1,C.googleAnalyticId=null,C.googleAnalyticReady=!1,C.facebookPixelId=null,C.facebookPixelReady=!1,C.startLoadTime=$,C.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",C.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),C.overrideUseCustomAddressForm=!1,C.isCollect=!1,C.isInvoice=!1,C.isNpm=!0,C.zonosQaUrl=null,C.zonosQaUrlApi=null,C.trackEventLogs=[],C.version="v1.3.268",C.modeAlerted=!1,C.cartData=null,C.paypal=null,C.zonosMode=null,C.IframeService=t,C.getCurrentTimestamp=()=>(new Date).getTime(),C.zonosController=null,C.loadTimeApiInfoList=[],C.logIntervalId=null,C.init=async e=>{const{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d,storeId:a,zonosApiKey:p}=e;if(R.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),R.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${R.version}) ======`),R.zonosApiKey=p,R.storeId=a,"undefined"!=typeof window&&window.parent===window&&(R.googleAnalyticReady=!0,R.facebookPixelReady=!0),R.isNpm){r("====== ZONOS LOADING FROM NPM ======");const n=S();if(n&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${n} ======`,"info");const o=document.createElement("script");return o.src=`${n}/dist/scripts/zonos.js`,document.head.appendChild(o),o.addEventListener("load",(()=>{window.Zonos.isNpm=R.isNpm,window.Zonos.isBigCommerce=R.isBigCommerce,window.Zonos.isLegacyCheckout=R.isLegacyCheckout,window.Zonos.zonosMode=R.zonosMode,window.Zonos.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${n}`)})),void(window.isZonosPreview=!0)}if(!p&&!R.cartId)return void m("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!R.cartData&&R.cartId){r("Initialize cart data");const e=await(async e=>{const{isDgsCartId:n,isLegacyCartId:o}=w(e);if(!o&&!n)return m("[ZONOS - loadZonos] invalid cart id"),null;const t=await k({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(m("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(R.cartId);if(!e)return void m("Failed to get cart data");R.cartData=e.cartData,R.zonosApiKey=e.zonosApiKey,R.cartSettings=e.settings}const o=await(async()=>{const e=i(),n=l();if(!e&&!n||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:o,json:t}=await u("/api/get-test-public-credential");if(o.length||!t)return m("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),null;const s=t.publicCredential;return s?(r(`[ZONOS - loadZonos] Retrieve new test public token ${s}`,"info"),s):(m("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();o&&(R.zonosApiKey=o)}const h=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(R.cartId&&R.cartData||h){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id=`${f}`,document.body.appendChild(e)}r("init zonos"),R.restoreNativeBrowserFunctions(),R.injectCustomScriptForHostedCheckout(),R.injectZonosCdn(),R.injectZonosCss(),R.injectFonts(),R.injectCheckoutInternationalButton(),R.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d}}),R.doneInit=!0},C.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${h}`)){const e=document.createElement("button");e.id=h,e.style.display="none",document.body.appendChild(e)}},C.injectCustomScriptForHostedCheckout=()=>{const e=R.cartData,n=(null==e?void 0:e.metadata)||[],o=n.find((e=>"customHeaderScript"===e.key)),t=n.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||t)){if(o){r("Injecting custom header script");const e=document.createElement("script");e.textContent=o.value,document.head.appendChild(e)}if(t){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=t.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},C.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},C.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${h}`);setTimeout((()=>{e&&e.dispatchEvent(n("click"))}),10)},C.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},C.showNotification=e=>{var n;null===(n=R.zonosController)||void 0===n||n.showNotification(e)},C.updateOrganizationName=e=>{var n;null===(n=R.zonosController)||void 0===n||n.updateOrganizationName(e)},C.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:o,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const n=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&o&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},C.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const n="zonos---native-browser";let o=document.querySelector(`iframe#${n}`);o||(o=document.createElement("iframe"),o.id=n,o.style.display="none",o.style.opacity="0",o.style.position="absolute",o.style.top="-9999px",o.style.left="-9999px",o.style.width="1px",o.style.height="1px",o.style.border="none",o.style.overflow="hidden",o.style.visibility="hidden",document.body.appendChild(o));const t=(null===(e=o.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=t,document.body.removeChild(o)},C.injectController=({config:e})=>{var n,o;if(document.querySelector("zonos-controller"))return;if(null===(n=e.checkoutSettings)||void 0===n?void 0:n.placeOrderButtonSelector){const n=e.checkoutSettings.placeOrderButtonSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const n=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}const t=document.createElement("zonos-controller");t.config=e,t.zonosApiKey=R.zonosApiKey||"",t.addEventListener("stripeInitEvent",(async e=>{const{detail:n}=e;r("loading Stripe");const o=await(async(...e)=>{I=!0;const n=Date.now();return N.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(n.publishableKey);o?(window.Zonos.stripe=o,window.Zonos.isCollect?t.initCollectElement(o):window.Zonos.isInvoice?t.initInvoiceElement(o):t.initCheckoutElement(o)):m("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(t),R.zonosController=t,r("Zonos controller injected!")},C.injectScript=({cdnType:e,isModule:n,theRestUrl:o})=>{const t=`${R.getZonosUrl(e)}/${o}`;if(document.querySelector(`script[src="${t}"]`))return void r(`Zonos script "${t}" already exists in the document`,"warn");const s=document.head||document.body,i=document.createElement("script");n?i.type="module":i.noModule=!0,i.src=t,i.crossOrigin="anonymous",i.onerror=()=>{m(`Failed to load ${i.src}`);const t=O(e);t&&R.injectScript({cdnType:t,isModule:n,theRestUrl:o})},s.appendChild(i)},C.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return A;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.268";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.268";case"vercel":return Z}};return R.isNpm&&S()||n()},C.injectZonosCdn=()=>{R.injectScript({cdnType:v,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),R.injectScript({cdnType:v,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},C.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const o=R.getZonosUrl(e),t=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${Z}/`,t.appendChild(s);const r=document.createElement("link");r.rel="stylesheet",r.href=`${o}/${n}`,r.onerror=()=>{m(`Failed to load ${r.href}`);const o=O(e);o&&R.injectStylesheet({cdnType:o,theRestUrl:n})},t.appendChild(r)},C.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(R.injectStylesheet({cdnType:v,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},C.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!U.test(o.href))return o}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=L,e.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${L}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(o),r("Zonos font injected!")},C.setupGoogleFont=e=>{var n;null===(n=R.zonosController)||void 0===n||n.setupGoogleFont(e)},C.injectSupportGoogleFont=e=>{var n;r(`[FONT] injecting ${e}`);const o=null===(n=e.match(/family=(.*?):/))||void 0===n?void 0:n[1],t=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${L}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=L,t.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,t.appendChild(s),r(`[FONT] ${o} font injected!`)};const E=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"],P=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"],F=[...E,...P];export{C as Zonos,F as checkoutSessionAttributeKeys,P as checkoutSessionImmutableAttributeKeys,E as checkoutSessionMutableAttributeKeys}
|
|
1
|
+
import{c as n}from"./p-595f5dd2.js";import{g as o,I as t}from"./p-e7b0c156.js";import{l as r}from"./p-0a377722.js";export{a as availableTestKeys}from"./p-0a377722.js";import{g as i,a as l,h as u,l as m}from"./p-41dd1cb8.js";import{g as p,_ as w,c as f,a as h}from"./p-b2d81c98.js";export{c as checkoutHiddenBtnSelector,a as checkoutHiddenInternationalBtnSelector,d as domesticRedirectedBtnSelector}from"./p-b2d81c98.js";export{c as countryRequireShortAddressCode}from"./p-1d42cd20.js";export{c as countryRequireTaxId,e as euCountryCodes,s as shipToTaxIdLabels}from"./p-6b361d2b.js";const y=["jsdelivr","cdnjs","unpkg","vercel"],v="jsdelivr",O=e=>{const n=y.indexOf(e);return y[n+1]||null},S=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const n=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),o="https://v1.3.270.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-")))return o;if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";const t=`https://${n}.preview.js.zonos.com`;return r(`[ZONOS-WARNING] using '${t}' for loading elements script`,"warn"),fetch(t).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${t}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,o=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),t},g="https://js.stripe.com/v3",j=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,z="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let b=null;const N=Promise.resolve().then((()=>{return e=null,null!==b||(b=new Promise(((n,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(z),window.Stripe)n(window.Stripe);else try{let t=(()=>{const e=document.querySelectorAll(`script[src^="${g}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&j.test(o.src))return o}return null})();t&&e?console.warn(z):t||(t=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${g}${n}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(m("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==t||t.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):o(new Error("Stripe.js not available"))})),null==t||t.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else n(null)}))),b;var e}));let I=!1;N.catch((e=>{I||console.warn(e)}));const k=async({cartId:e,retries:n})=>{const t=i(),s=o(),c=p()||void 0,d=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&d.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:l,json:a,zonosMode:m}=await u(`/api/zonos-elements/get-cart?${d.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:c,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),w=!a||l.length;return w&&n?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:n}),await new Promise((e=>setTimeout(e,500))),k({cartId:e,retries:n-1})):w?null:Object.assign(Object.assign({},a),{zonosMode:m})};var R;const T=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),t=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:t,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?n:null})(),$=Date.now(),Z="https://v1.3.270.js.zonos.com",A=T||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.270",L="https://fonts.googleapis.com",U=/^https:\/\/fonts\.googleapis\.com/;class C{}R=C,C.doneInit=!1,C.cartSettings=null,C.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),C.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),C._paypalMockResponse=null,C.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,C.isBigCommerce=!1,C.releaseDate="1781713868966",C.isLegacyCheckout=!1,C.googleAnalyticId=null,C.googleAnalyticReady=!1,C.facebookPixelId=null,C.facebookPixelReady=!1,C.startLoadTime=$,C.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",C.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),C.overrideUseCustomAddressForm=!1,C.isCollect=!1,C.isInvoice=!1,C.isNpm=!0,C.zonosQaUrl=null,C.zonosQaUrlApi=null,C.trackEventLogs=[],C.version="v1.3.270",C.modeAlerted=!1,C.cartData=null,C.paypal=null,C.zonosMode=null,C.IframeService=t,C.getCurrentTimestamp=()=>(new Date).getTime(),C.zonosController=null,C.loadTimeApiInfoList=[],C.logIntervalId=null,C.init=async e=>{const{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d,storeId:a,zonosApiKey:p}=e;if(R.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),R.doneInit)return;if(r(`====== ZONOS DEBUG MODE: on (${R.version}) ======`),R.zonosApiKey=p,R.storeId=a,"undefined"!=typeof window&&window.parent===window&&(R.googleAnalyticReady=!0,R.facebookPixelReady=!0),R.isNpm){r("====== ZONOS LOADING FROM NPM ======");const n=S();if(n&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${n} ======`,"info");const o=document.createElement("script");return o.src=`${n}/dist/scripts/zonos.js`,document.head.appendChild(o),o.addEventListener("load",(()=>{window.Zonos.isNpm=R.isNpm,window.Zonos.isBigCommerce=R.isBigCommerce,window.Zonos.isLegacyCheckout=R.isLegacyCheckout,window.Zonos.zonosMode=R.zonosMode,window.Zonos.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${n}`)})),void(window.isZonosPreview=!0)}if(!p&&!R.cartId)return void m("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!R.cartData&&R.cartId){r("Initialize cart data");const e=await(async e=>{const{isDgsCartId:n,isLegacyCartId:o}=w(e);if(!o&&!n)return m("[ZONOS - loadZonos] invalid cart id"),null;const t=await k({cartId:e,retries:5});return r("[ZONOS - loadZonos] getting temp cart data","info",t),t?(window.Zonos.storeId=t.cartData.storeId,window.Zonos.zonosApiKey=t.cartData.credentialToken,window.Zonos.zonosMode=t.zonosMode,{cartData:t.cartData,settings:t.settings,storeFavicon:t.storeFaviconUrl,storeId:t.cartData.storeId,storeLogo:t.storeLogoUrl,zonosApiKey:t.cartData.credentialToken}):(m("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(R.cartId);if(!e)return void m("Failed to get cart data");R.cartData=e.cartData,R.zonosApiKey=e.zonosApiKey,R.cartSettings=e.settings}const o=await(async()=>{const e=i(),n=l();if(!e&&!n||!window.Zonos.zonosApiKey)return null;if(r("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return r("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:o,json:t}=await u("/api/get-test-public-credential");if(o.length||!t)return m("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),null;const s=t.publicCredential;return s?(r(`[ZONOS - loadZonos] Retrieve new test public token ${s}`,"info"),s):(m("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();o&&(R.zonosApiKey=o)}const h=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(R.cartId&&R.cartData||h){r("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id=`${f}`,document.body.appendChild(e)}r("init zonos"),R.restoreNativeBrowserFunctions(),R.injectCustomScriptForHostedCheckout(),R.injectZonosCdn(),R.injectZonosCss(),R.injectFonts(),R.injectCheckoutInternationalButton(),R.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d}}),R.doneInit=!0},C.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${h}`)){const e=document.createElement("button");e.id=h,e.style.display="none",document.body.appendChild(e)}},C.injectCustomScriptForHostedCheckout=()=>{const e=R.cartData,n=(null==e?void 0:e.metadata)||[],o=n.find((e=>"customHeaderScript"===e.key)),t=n.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||t)){if(o){r("Injecting custom header script");const e=document.createElement("script");e.textContent=o.value,document.head.appendChild(e)}if(t){r("Injecting custom footer script");const e=document.createElement("script");e.textContent=t.value,document.body.appendChild(e)}}else r("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},C.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},C.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${h}`);setTimeout((()=>{e&&e.dispatchEvent(n("click"))}),10)},C.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},C.showNotification=e=>{var n;null===(n=R.zonosController)||void 0===n||n.showNotification(e)},C.updateOrganizationName=e=>{var n;null===(n=R.zonosController)||void 0===n||n.updateOrganizationName(e)},C.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:o,placeOrderButtonSelector:t})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&t){const n=document.querySelectorAll(t),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&o&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},C.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const n="zonos---native-browser";let o=document.querySelector(`iframe#${n}`);o||(o=document.createElement("iframe"),o.id=n,o.style.display="none",o.style.opacity="0",o.style.position="absolute",o.style.top="-9999px",o.style.left="-9999px",o.style.width="1px",o.style.height="1px",o.style.border="none",o.style.overflow="hidden",o.style.visibility="hidden",document.body.appendChild(o));const t=(null===(e=o.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=t,document.body.removeChild(o)},C.injectController=({config:e})=>{var n,o;if(document.querySelector("zonos-controller"))return;if(null===(n=e.checkoutSettings)||void 0===n?void 0:n.placeOrderButtonSelector){const n=e.checkoutSettings.placeOrderButtonSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const n=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n})})).observe(document.body,{childList:!0,subtree:!0})}const t=document.createElement("zonos-controller");t.config=e,t.zonosApiKey=R.zonosApiKey||"",t.addEventListener("stripeInitEvent",(async e=>{const{detail:n}=e;r("loading Stripe");const o=await(async(...e)=>{I=!0;const n=Date.now();return N.then((o=>((e,n,o)=>{if(null===e)return null;const t=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(t,o),t})(o,e,n)))})(n.publishableKey);o?(window.Zonos.stripe=o,window.Zonos.isCollect?t.initCollectElement(o):window.Zonos.isInvoice?t.initInvoiceElement(o):t.initCheckoutElement(o)):m("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(t),R.zonosController=t,r("Zonos controller injected!")},C.injectScript=({cdnType:e,isModule:n,theRestUrl:o})=>{const t=`${R.getZonosUrl(e)}/${o}`;if(document.querySelector(`script[src="${t}"]`))return void r(`Zonos script "${t}" already exists in the document`,"warn");const s=document.head||document.body,i=document.createElement("script");n?i.type="module":i.noModule=!0,i.src=t,i.crossOrigin="anonymous",i.onerror=()=>{m(`Failed to load ${i.src}`);const t=O(e);t&&R.injectScript({cdnType:t,isModule:n,theRestUrl:o})},s.appendChild(i)},C.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return A;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.270";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.270";case"vercel":return Z}};return R.isNpm&&S()||n()},C.injectZonosCdn=()=>{R.injectScript({cdnType:v,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),R.injectScript({cdnType:v,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},C.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const o=R.getZonosUrl(e),t=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${Z}/`,t.appendChild(s);const r=document.createElement("link");r.rel="stylesheet",r.href=`${o}/${n}`,r.onerror=()=>{m(`Failed to load ${r.href}`);const o=O(e);o&&R.injectStylesheet({cdnType:o,theRestUrl:n})},t.appendChild(r)},C.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(R.injectStylesheet({cdnType:v,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},C.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${L}"]`);for(let n=0;n<e.length;n++){const o=e[n];if(o&&!U.test(o.href))return o}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=L,e.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${L}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(o),r("Zonos font injected!")},C.setupGoogleFont=e=>{var n;null===(n=R.zonosController)||void 0===n||n.setupGoogleFont(e)},C.injectSupportGoogleFont=e=>{var n;r(`[FONT] injecting ${e}`);const o=null===(n=e.match(/family=(.*?):/))||void 0===n?void 0:n[1],t=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${L}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=L,t.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void r(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,t.appendChild(s),r(`[FONT] ${o} font injected!`)};const E=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"],P=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"],F=[...E,...P];export{C as Zonos,F as checkoutSessionAttributeKeys,P as checkoutSessionImmutableAttributeKeys,E as checkoutSessionMutableAttributeKeys}
|