@zonos/elements 1.3.209 → 1.3.210
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-2ec8cac2.js → cart-313bd2ff.js} +3 -0
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/{paypal-6449314e.js → paypal-67c96668.js} +1 -1
- package/dist/cjs/zonos-address_11.cjs.entry.js +1 -1
- package/dist/cjs/zonos-cart-items_14.cjs.entry.js +2 -2
- package/dist/cjs/zonos-checkout.cjs.entry.js +2 -2
- package/dist/cjs/zonos-controller.cjs.entry.js +1 -1
- package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +2 -2
- package/dist/collection/components/store/checkout/stripe.js +3 -0
- package/dist/esm/{cart-2f84f632.js → cart-e0703306.js} +3 -0
- package/dist/esm/index.js +7 -7
- package/dist/esm/{paypal-1cf701aa.js → paypal-dbaf76fd.js} +1 -1
- package/dist/esm/zonos-address_11.entry.js +1 -1
- package/dist/esm/zonos-cart-items_14.entry.js +2 -2
- package/dist/esm/zonos-checkout.entry.js +2 -2
- package/dist/esm/zonos-controller.entry.js +1 -1
- package/dist/esm/zonos-empty-state-payment_4.entry.js +2 -2
- package/dist/esm-es5/cart-e0703306.js +1 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{paypal-1cf701aa.js → paypal-dbaf76fd.js} +1 -1
- package/dist/esm-es5/zonos-address_11.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_14.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-empty-state-payment_4.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/zonos-elements/assets/RemoveIcon.svg +1 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-bfdb4e7a.entry.js → p-03c060d3.entry.js} +1 -1
- package/dist/zonos-elements/{p-b1bfeec9.system.entry.js → p-20b702a7.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d1c0bf92.entry.js → p-23142862.entry.js} +1 -1
- package/dist/zonos-elements/{p-30a9f802.system.entry.js → p-37058486.system.entry.js} +1 -1
- package/dist/zonos-elements/p-3ee44728.system.js +1 -1
- package/dist/zonos-elements/{p-371d91d1.js → p-5b3b58ef.js} +1 -1
- package/dist/zonos-elements/{p-44c0a584.system.js → p-68650f1e.system.js} +1 -1
- package/dist/zonos-elements/{p-08b29f73.system.entry.js → p-7211cb9f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-4f5513dc.entry.js → p-73ff25d8.entry.js} +1 -1
- package/dist/zonos-elements/{p-4ed73ff8.entry.js → p-7b02b1f6.entry.js} +1 -1
- package/dist/zonos-elements/p-7ec1fecb.system.js +1 -0
- package/dist/zonos-elements/{p-3c752420.system.js → p-8d0e116f.system.js} +1 -1
- package/dist/zonos-elements/p-992f0b96.js +1 -0
- package/dist/zonos-elements/{p-fdf5b8f4.entry.js → p-a1137930.entry.js} +1 -1
- package/dist/zonos-elements/{p-db424e02.system.entry.js → p-bf364990.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-896f2358.system.entry.js → p-cf999a15.system.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/cart-2f84f632.js +0 -1
- package/dist/zonos-elements/p-542acc2c.js +0 -1
- package/dist/zonos-elements/p-5711e187.system.js +0 -1
package/dist/scripts/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const e=({id:e,payload:t,target:o,type:n})=>{var r;o instanceof HTMLIFrameElement?null===(r=o.contentWindow)||void 0===r||r.postMessage({id:e,payload:t,type:n},"*"):o.postMessage({id:e,payload:t,type:n},"*")};class t{constructor(t,o){this.targetElement=t,this.targetId=o,this.sendMessage=(t,o)=>{e({id:this.targetId,payload:o,target:this.targetElement,type:t})}}}t.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},t.sendMessage=e,t.injectPrivateIframe=({id:e,onload:t,src:o})=>{const n=document.createElement("iframe");return n.src=o,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=()=>t(n),document.body.appendChild(n),n};const o=performance.now(),n=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},r=(e,t,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const e=performance.now()-o,t=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:t}})(),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(t){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,...t)=>{r(e,"error",...t)},i=["jsdelivr","cdnjs","unpkg","vercel"],a="jsdelivr",l=e=>{const t=i.indexOf(e);return i[t+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,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}"function"==typeof SuppressedError&&SuppressedError;const 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 t=p.indexOf(e),o=p[t+1];return o||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,t=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,t="mozConnection"in window.navigator?window.navigator.mozConnection:null,o="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||t||o})();return{connectionDownlink:null==t?void 0:t.downlink,connectionEffectiveType:null==t?void 0:t.effectiveType,connectionRtt:null==t?void 0:t.rtt,connectionSaveData:null==t?void 0:t.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:t=!0,shouldThrow:o=!1})=>{try{const t=await e.text(),o=g(t);if(!o)throw new Error(`Failed to parse content: ${t}`);return o}catch(e){if(o)throw e;return t&&console.error(e),null}},S=async({basePathType:e,options:t,path:o})=>{let n;const r=window.Zonos.zonosQaUrlApi||w[e]||m,s=new URL(r+o),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(t){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),t)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const 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 t=e.errors;return{baseUrl:r,errors:t.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:t,path:o})=>{var n,s;const i=o.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await S({basePathType:i,options:t,path:o}),{errors:d,response:c}=l,p=u(l,["errors","response"]),m=performance.now()-a;r(`${o} (${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:t,loadTimeInternal:o,loadTimeTotal:n})=>{if(v.includes(e))return;const r=n-o;if(r<0)return;const s=e.split("?")[0]||e,i=f(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:t,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(d=a,d||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:o,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:o,apiType:i,loadTimeInternal:b?Number(b):0,loadTimeTotal:m});const z=y(i),k=d.find((({type:e})=>"unknown"===e)),j=d.find((({message:e})=>e.includes("signal is aborted"))),O=!!k||404===(null==c?void 0:c.status),Z=z&&O;return(O||j)&&(async({endpoint:e,errors:t,metadata:o,shouldPostReleaseErrorReporting:n})=>{r("sendErrorLog","warn",e,o,t);{const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:t,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},o)};try{fetch(`${h}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const t=y();if(!t)return;fetch(`${w[t]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:w[i]+o,errors:d.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:z,requestHeaders:null==t?void 0:t.headers,requestPayload:g(null===(n=null==t?void 0:t.body)||void 0===n?void 0:n.toString())||(null===(s=null==t?void 0:t.body)||void 0===s?void 0:s.toString()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),Z?(r(`=== "${o}" failed to fetch, trying next fallback ${z}`),C({basePathType:z,options:t,path:o})):Object.assign({errors:d,response:c},p)},z=async(e,t)=>{const o=u(t||{},[]),n=o.body?JSON.stringify(o.body):void 0,r=o.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"},o.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const i=Object.assign(Object.assign({},o),{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 t=(e=>{if(!e)return null;const t=new URL(e).searchParams.get("zonosQaUrl");return t?/[^a-zA-Z0-9-_]+/.test(t)?null:t:null})(window.location.href),o="https://v1.3.209.js.zonos.com";if(!t&&(o.includes("test.")||o.includes("test-")))return o;if(!t&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!t)return null;if("dev-elements"===t)return"https://dev.elements.zonos.com";const n=`https://${t}.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:t}=window.location,o=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),n},j="https://js.stripe.com/v3",O=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let Z=null;const A=e=>(null!==Z||(Z=new Promise(((t,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)t(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${j}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&O.test(o.src))return o}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 t=document.createElement("script");t.src=`${j}`;const o=document.head||document.body;return o?(o.appendChild(t),t):(s("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",(()=>{window.Stripe?t(window.Stripe):o(new Error("Stripe.js not available"))})),null==n||n.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else t(null)}))),Z),I=Promise.resolve().then((()=>A(null)));let E=!1;I.catch((e=>{E||console.warn(e)}));const T=async({cartId:e,retries:t})=>{const o=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:o,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||a.length;return u&&t?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:t}),await new Promise((e=>setTimeout(e,500))),T({cartId:e,retries:t-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}/,$=new RegExp(`^${L.source}$`),P=new RegExp(`^cart_${L.source}$`),U=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,D=async e=>{const{isDgsCartId:t,isLegacyCartId:o}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:P.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!o&&!t)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)},F="zonos--checkout-hidden-international-button";var R;const x=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:t,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const t=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>t.includes(e))),n=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:n,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?t:null})(),M="https://v1.3.209.js.zonos.com",B=x||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.209",q="https://fonts.googleapis.com",W=/^https:\/\/fonts\.googleapis\.com/;class K{}R=K,K.doneInit=!1,K.cartSettings=null,K.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),K.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),K._paypalMockResponse=null,K.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,K.isBigCommerce=!1,K.releaseDate="1749049171170",K.isLegacyCheckout=!1,K.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",K.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),K.overrideUseCustomAddressForm=!1,K.isNpm=!0,K.zonosQaUrl=null,K.zonosQaUrlApi=null,K.trackEventLogs=[],K.version="v1.3.209",K.modeAlerted=!1,K.cartData=null,K.paypal=null,K.zonosMode=null,K.IframeService=t,K.getCurrentTimestamp=()=>(new Date).getTime(),K.zonosController=null,K.loadTimeApiInfoList=[],K.logIntervalId=null,K.init=async e=>{const{appearance:t,checkoutSettings:o,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:u,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=u,R.isNpm){r("====== ZONOS LOADING FROM NPM ======");const t=k();if(t&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${t} ======`,"info");const o=document.createElement("script");return o.src=`${t}/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.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${t}`)})),void(window.isZonosPreview=!0)}if(!p&&!R.cartId)return void s("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 D(R.cartId);if(!e)return void s("Failed to get cart data");R.cartData=e.cartData,R.zonosApiKey=e.zonosApiKey,R.cartSettings=e.settings}const o=await(async()=>{const e=c(),t=d();if(!e&&!t||!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:n}=await z("/api/get-test-public-credential");if(o.length||!n)return s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),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)})();o&&(R.zonosApiKey=o)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(R.cartId&&R.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"),R.restoreNativeBrowserFunctions(),R.injectCustomScriptForHostedCheckout(),R.injectZonosCdn(),R.injectZonosCss(),R.injectFonts(),R.injectCheckoutInternationalButton(),R.injectController({config:{appearance:t,checkoutSettings:o,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),R.doneInit=!0},K.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${F}`)){const e=document.createElement("button");e.id=F,e.style.display="none",document.body.appendChild(e)}},K.injectCustomScriptForHostedCheckout=()=>{const e=R.cartData,t=(null==e?void 0:e.metadata)||[],o=t.find((e=>"customHeaderScript"===e.key)),n=t.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||n)){if(o){r("Injecting custom header script");const e=document.createElement("script");e.textContent=o.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:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},K.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},K.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${F}`);setTimeout((()=>{var t;e&&e.dispatchEvent(new CustomEvent("click",{detail:t}))}),10)},K.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},K.showNotification=e=>{var t;null===(t=R.zonosController)||void 0===t||t.showNotification(e)},K.updateOrganizationName=e=>{var t;null===(t=R.zonosController)||void 0===t||t.updateOrganizationName(e)},K.disablePlaceOrderButtons=({autoEnable:e=!0,config:t,disable:o,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=t.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const t=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};t.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&o&&setTimeout((()=>{t.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},K.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const t="zonos---native-browser";let o=document.querySelector(`iframe#${t}`);o||(o=document.createElement("iframe"),o.id=t,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 n=(null===(e=o.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(o)},K.injectController=({config:e})=>{var t,o;if(document.querySelector("zonos-controller"))return;if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.placeOrderButtonSelector){const t=e.checkoutSettings.placeOrderButtonSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t});new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const t=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t});new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t})})).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=R.zonosApiKey||"",n.addEventListener("stripeInitEvent",(async e=>{const{detail:t}=e;r("loading Stripe");const o=await(async(...e)=>{E=!0;const t=Date.now();return I.then((o=>((e,t,o)=>{if(null===e)return null;const n=e.apply(void 0,t);return((e,t)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:t})})(n,o),n})(o,e,t)))})(t.publishableKey);o?(window.Zonos.stripe=o,n.initCheckoutElement(o)):s("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(n),R.zonosController=n,r("Zonos controller injected!")},K.injectScript=({cdnType:e,isModule:t,theRestUrl:o})=>{const n=`${R.getZonosUrl(e)}/${o}`;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");t?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&&R.injectScript({cdnType:n,isModule:t,theRestUrl:o})},i.appendChild(a)},K.getZonosUrl=e=>{const t=()=>{switch(e){case"jsdelivr":return B;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.209";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.209";case"vercel":return M}};if(R.isNpm){return k()||t()}return t()},K.injectZonosCdn=()=>{R.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),R.injectScript({cdnType:a,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},K.injectStylesheet=({cdnType:e,theRestUrl:t})=>{const o=R.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${M}/`,n.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${o}/${t}`,i.onerror=()=>{s(`Failed to load ${i.href}`);const o=l(e);o&&R.injectStylesheet({cdnType:o,theRestUrl:t})},n.appendChild(i)},K.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(R.injectStylesheet({cdnType:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},K.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${q}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&!W.test(o.href))return o}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,t=document.createElement("link");t.rel="preconnect",t.href=q,e.appendChild(t);const o=document.createElement("link");o.rel="stylesheet",o.href=`${q}/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!")},K.setupGoogleFont=e=>{var t;null===(t=R.zonosController)||void 0===t||t.setupGoogleFont(e)},K.injectSupportGoogleFont=e=>{var t;r(`[FONT] injecting ${e}`);const o=null===(t=e.match(/family=(.*?):/))||void 0===t?void 0:t[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${q}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=q,n.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,n.appendChild(s),r(`[FONT] ${o} font injected!`)},exports.Zonos=K})();
|
|
1
|
+
(function(){"use strict";const e=({id:e,payload:t,target:o,type:n})=>{var r;o instanceof HTMLIFrameElement?null===(r=o.contentWindow)||void 0===r||r.postMessage({id:e,payload:t,type:n},"*"):o.postMessage({id:e,payload:t,type:n},"*")};class t{constructor(t,o){this.targetElement=t,this.targetId=o,this.sendMessage=(t,o)=>{e({id:this.targetId,payload:o,target:this.targetElement,type:t})}}}t.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},t.sendMessage=e,t.injectPrivateIframe=({id:e,onload:t,src:o})=>{const n=document.createElement("iframe");return n.src=o,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=()=>t(n),document.body.appendChild(n),n};const o=performance.now(),n=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},r=(e,t,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const e=performance.now()-o,t=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:t}})(),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(t){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,...t)=>{r(e,"error",...t)},i=["jsdelivr","cdnjs","unpkg","vercel"],a="jsdelivr",l=e=>{const t=i.indexOf(e);return i[t+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,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}"function"==typeof SuppressedError&&SuppressedError;const 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 t=p.indexOf(e),o=p[t+1];return o||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,t=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,t="mozConnection"in window.navigator?window.navigator.mozConnection:null,o="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||t||o})();return{connectionDownlink:null==t?void 0:t.downlink,connectionEffectiveType:null==t?void 0:t.effectiveType,connectionRtt:null==t?void 0:t.rtt,connectionSaveData:null==t?void 0:t.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:t=!0,shouldThrow:o=!1})=>{try{const t=await e.text(),o=g(t);if(!o)throw new Error(`Failed to parse content: ${t}`);return o}catch(e){if(o)throw e;return t&&console.error(e),null}},S=async({basePathType:e,options:t,path:o})=>{let n;const r=window.Zonos.zonosQaUrlApi||w[e]||m,s=new URL(r+o),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(t){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),t)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const 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 t=e.errors;return{baseUrl:r,errors:t.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:t,path:o})=>{var n,s;const i=o.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await S({basePathType:i,options:t,path:o}),{errors:d,response:c}=l,p=u(l,["errors","response"]),m=performance.now()-a;r(`${o} (${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:t,loadTimeInternal:o,loadTimeTotal:n})=>{if(v.includes(e))return;const r=n-o;if(r<0)return;const s=e.split("?")[0]||e,i=f(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:t,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(d=a,d||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:o,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:o,apiType:i,loadTimeInternal:b?Number(b):0,loadTimeTotal:m});const z=y(i),k=d.find((({type:e})=>"unknown"===e)),j=d.find((({message:e})=>e.includes("signal is aborted"))),O=!!k||404===(null==c?void 0:c.status),Z=z&&O;return(O||j)&&(async({endpoint:e,errors:t,metadata:o,shouldPostReleaseErrorReporting:n})=>{r("sendErrorLog","warn",e,o,t);{const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:t,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},o)};try{fetch(`${h}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const t=y();if(!t)return;fetch(`${w[t]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:w[i]+o,errors:d.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:z,requestHeaders:null==t?void 0:t.headers,requestPayload:g(null===(n=null==t?void 0:t.body)||void 0===n?void 0:n.toString())||(null===(s=null==t?void 0:t.body)||void 0===s?void 0:s.toString()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),Z?(r(`=== "${o}" failed to fetch, trying next fallback ${z}`),C({basePathType:z,options:t,path:o})):Object.assign({errors:d,response:c},p)},z=async(e,t)=>{const o=u(t||{},[]),n=o.body?JSON.stringify(o.body):void 0,r=o.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"},o.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const i=Object.assign(Object.assign({},o),{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 t=(e=>{if(!e)return null;const t=new URL(e).searchParams.get("zonosQaUrl");return t?/[^a-zA-Z0-9-_]+/.test(t)?null:t:null})(window.location.href),o="https://v1.3.210.js.zonos.com";if(!t&&(o.includes("test.")||o.includes("test-")))return o;if(!t&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!t)return null;if("dev-elements"===t)return"https://dev.elements.zonos.com";const n=`https://${t}.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:t}=window.location,o=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),n},j="https://js.stripe.com/v3",O=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let Z=null;const A=e=>(null!==Z||(Z=new Promise(((t,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)t(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${j}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&O.test(o.src))return o}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 t=document.createElement("script");t.src=`${j}`;const o=document.head||document.body;return o?(o.appendChild(t),t):(s("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",(()=>{window.Stripe?t(window.Stripe):o(new Error("Stripe.js not available"))})),null==n||n.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else t(null)}))),Z),I=Promise.resolve().then((()=>A(null)));let E=!1;I.catch((e=>{E||console.warn(e)}));const T=async({cartId:e,retries:t})=>{const o=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:o,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||a.length;return u&&t?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:t}),await new Promise((e=>setTimeout(e,500))),T({cartId:e,retries:t-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}/,$=new RegExp(`^${L.source}$`),P=new RegExp(`^cart_${L.source}$`),U=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,D=async e=>{const{isDgsCartId:t,isLegacyCartId:o}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:P.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!o&&!t)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)},F="zonos--checkout-hidden-international-button";var R;const x=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:t,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const t=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>t.includes(e))),n=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:n,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?t:null})(),M="https://v1.3.210.js.zonos.com",B=x||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.210",q="https://fonts.googleapis.com",W=/^https:\/\/fonts\.googleapis\.com/;class K{}R=K,K.doneInit=!1,K.cartSettings=null,K.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),K.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),K._paypalMockResponse=null,K.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,K.isBigCommerce=!1,K.releaseDate="1749136632453",K.isLegacyCheckout=!1,K.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",K.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),K.overrideUseCustomAddressForm=!1,K.isNpm=!0,K.zonosQaUrl=null,K.zonosQaUrlApi=null,K.trackEventLogs=[],K.version="v1.3.210",K.modeAlerted=!1,K.cartData=null,K.paypal=null,K.zonosMode=null,K.IframeService=t,K.getCurrentTimestamp=()=>(new Date).getTime(),K.zonosController=null,K.loadTimeApiInfoList=[],K.logIntervalId=null,K.init=async e=>{const{appearance:t,checkoutSettings:o,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:u,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=u,R.isNpm){r("====== ZONOS LOADING FROM NPM ======");const t=k();if(t&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${t} ======`,"info");const o=document.createElement("script");return o.src=`${t}/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.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${t}`)})),void(window.isZonosPreview=!0)}if(!p&&!R.cartId)return void s("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 D(R.cartId);if(!e)return void s("Failed to get cart data");R.cartData=e.cartData,R.zonosApiKey=e.zonosApiKey,R.cartSettings=e.settings}const o=await(async()=>{const e=c(),t=d();if(!e&&!t||!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:n}=await z("/api/get-test-public-credential");if(o.length||!n)return s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),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)})();o&&(R.zonosApiKey=o)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(R.cartId&&R.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"),R.restoreNativeBrowserFunctions(),R.injectCustomScriptForHostedCheckout(),R.injectZonosCdn(),R.injectZonosCss(),R.injectFonts(),R.injectCheckoutInternationalButton(),R.injectController({config:{appearance:t,checkoutSettings:o,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),R.doneInit=!0},K.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${F}`)){const e=document.createElement("button");e.id=F,e.style.display="none",document.body.appendChild(e)}},K.injectCustomScriptForHostedCheckout=()=>{const e=R.cartData,t=(null==e?void 0:e.metadata)||[],o=t.find((e=>"customHeaderScript"===e.key)),n=t.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||n)){if(o){r("Injecting custom header script");const e=document.createElement("script");e.textContent=o.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:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},K.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},K.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${F}`);setTimeout((()=>{var t;e&&e.dispatchEvent(new CustomEvent("click",{detail:t}))}),10)},K.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},K.showNotification=e=>{var t;null===(t=R.zonosController)||void 0===t||t.showNotification(e)},K.updateOrganizationName=e=>{var t;null===(t=R.zonosController)||void 0===t||t.updateOrganizationName(e)},K.disablePlaceOrderButtons=({autoEnable:e=!0,config:t,disable:o,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=t.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const t=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};t.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&o&&setTimeout((()=>{t.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},K.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const t="zonos---native-browser";let o=document.querySelector(`iframe#${t}`);o||(o=document.createElement("iframe"),o.id=t,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 n=(null===(e=o.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(o)},K.injectController=({config:e})=>{var t,o;if(document.querySelector("zonos-controller"))return;if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.placeOrderButtonSelector){const t=e.checkoutSettings.placeOrderButtonSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t});new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const t=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t});new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t})})).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=R.zonosApiKey||"",n.addEventListener("stripeInitEvent",(async e=>{const{detail:t}=e;r("loading Stripe");const o=await(async(...e)=>{E=!0;const t=Date.now();return I.then((o=>((e,t,o)=>{if(null===e)return null;const n=e.apply(void 0,t);return((e,t)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:t})})(n,o),n})(o,e,t)))})(t.publishableKey);o?(window.Zonos.stripe=o,n.initCheckoutElement(o)):s("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(n),R.zonosController=n,r("Zonos controller injected!")},K.injectScript=({cdnType:e,isModule:t,theRestUrl:o})=>{const n=`${R.getZonosUrl(e)}/${o}`;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");t?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&&R.injectScript({cdnType:n,isModule:t,theRestUrl:o})},i.appendChild(a)},K.getZonosUrl=e=>{const t=()=>{switch(e){case"jsdelivr":return B;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.210";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.210";case"vercel":return M}};if(R.isNpm){return k()||t()}return t()},K.injectZonosCdn=()=>{R.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),R.injectScript({cdnType:a,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},K.injectStylesheet=({cdnType:e,theRestUrl:t})=>{const o=R.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${M}/`,n.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${o}/${t}`,i.onerror=()=>{s(`Failed to load ${i.href}`);const o=l(e);o&&R.injectStylesheet({cdnType:o,theRestUrl:t})},n.appendChild(i)},K.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(R.injectStylesheet({cdnType:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},K.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${q}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&!W.test(o.href))return o}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,t=document.createElement("link");t.rel="preconnect",t.href=q,e.appendChild(t);const o=document.createElement("link");o.rel="stylesheet",o.href=`${q}/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!")},K.setupGoogleFont=e=>{var t;null===(t=R.zonosController)||void 0===t||t.setupGoogleFont(e)},K.injectSupportGoogleFont=e=>{var t;r(`[FONT] injecting ${e}`);const o=null===(t=e.match(/family=(.*?):/))||void 0===t?void 0:t[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${q}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=q,n.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,n.appendChild(s),r(`[FONT] ${o} font injected!`)},exports.Zonos=K})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function e(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 o=()=>window.location.search.includes("zonosStagingMode=1"),n=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")},t=["cloudflare","vercel"],r=t[0],s={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},i=s[r],a=(e=r)=>{const o=t.indexOf(e),n=t[o+1];return n||null},d=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},l=performance.now(),c=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"}},u=(e,o,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const e=performance.now()-l,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),i=[`(${s})`,...n];i.map(c).join(" ");if(!(!!(null===(t=window.Zonos)||void 0===t?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;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()}},p=()=>{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"],w=({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=p();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)},g=async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:t})=>{if(u("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,d={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(`${i}/api/zonos-elements/log-error`,{body:JSON.stringify(d),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=a();if(!o)return;fetch(`${s[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(d),method:"POST"})}},f=async({response:e,shouldLog:o=!0,shouldThrow:n=!1})=>{try{const o=await e.text(),n=d(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}},h=async({basePathType:e,options:o,path:n})=>{let t;const i=window.Zonos.zonosQaUrlApi||s[e]||r,a=new URL(i+n),d=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;a.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(a.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:i,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:i,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const l=t.headers.get("Zonos-Mode"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&l&&c&&(window.Zonos.modeAlerted=!0),t.ok){return{baseUrl:i,errors:[],json:await f({response:t}),response:t,zonosMode:l}}const u=t.status.toString();try{const e=await f({response:t,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:i,errors:o.map((e=>"string"==typeof e?{message:e,type:u}:e)),json:null,response:t,zonosMode:l}}return{baseUrl:i,errors:[{message:JSON.stringify(e),type:u}],json:null,response:t,zonosMode:l}}catch(e){return{baseUrl:i,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:l}}},y=async({basePathType:o,options:n,path:t})=>{var r,i;const l=t.startsWith("/api/bigcommerce")?"vercel":o,c=performance.now(),p=await h({basePathType:l,options:n,path:t}),{errors:m,response:f}=p,v=e(p,["errors","response"]),Z=performance.now()-c;u(`${t} (${Z.toFixed(2)}ms)`,"info");const S=null==f?void 0:f.headers.get("Zonos-Duration");200===(null==f?void 0:f.status)&&w({apiPath:t,apiType:l,loadTimeInternal:S?Number(S):0,loadTimeTotal:Z});const z=a(l),b=m.find((({type:e})=>"unknown"===e)),L=m.find((({message:e})=>e.includes("signal is aborted"))),O=!!b||404===(null==f?void 0:f.status),I=z&&O;return(O||L)&&g({endpoint:s[l]+t,errors:m.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:l,nextFallbackApiType:z,requestHeaders:null==n?void 0:n.headers,requestPayload:d(null===(r=null==n?void 0:n.body)||void 0===r?void 0:r.toString())||(null===(i=null==n?void 0:n.body)||void 0===i?void 0:i.toString()),status:null==f?void 0:f.status,statusText:null==f?void 0:f.statusText},shouldPostReleaseErrorReporting:!0}),I?(u(`=== "${t}" failed to fetch, trying next fallback ${z}`),y({basePathType:z,options:n,path:t})):Object.assign({errors:m,response:f},v)},v=async(t,s)=>{const i=e(s||{},[]),a=i.body?JSON.stringify(i.body):void 0,d=i.method||"GET",l=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":o()?"1":void 0,"Zonos-Test-Mode":n()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},i.headers);Object.keys(l).forEach((e=>void 0===l[e]&&delete l[e]));const c=Object.assign(Object.assign({},i),{body:"GET"===d?void 0:a,headers:l,method:d}),u=new URLSearchParams(window.location.search).get("useFallbackApi");return y({basePathType:u||r,options:c,path:t})},Z=(e,...o)=>{u(e,"error",...o)},S=["jsdelivr","cdnjs","unpkg","vercel"],z=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},b=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,L=new RegExp(`^${b.source}$`),O=new RegExp(`^cart_${b.source}$`),I=/^[a-zA-Z0-9]{2,}$/,A=/^cart_[a-zA-Z0-9]{2,}$/,C=e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:A.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:I.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},T=async({cartId:e,retries:o})=>{const t=n(),r=(()=>{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;r.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",r.overrideShouldEnabledCustomAddress);const{errors:a,json:d,zonosMode:l}=await v(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),c=!d||a.length;return c&&o?(u("[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})):c?null:Object.assign(Object.assign({},d),{zonosMode:l})};var U;const k=(()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=z(window.location.href),n="https://v1.3.209.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"].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 u(`[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})(),j=(()=>{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=z(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 u(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})();class E{}U=E,E.isNpm=!1,E.isBigCommerce=!1,E.requested=!1,E.zonosMode=null,E.cartData=null,E.overrideUseCustomAddressForm=!1,E.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,E.version="v1.3.209",E.isLegacyCheckout=!1,E.legacyStoreLogo=null,E.legacyStoreFavicon=null,E.parallelLoadTimes=[],E.parallelLoadState="off",E.releaseDate="1749049171170",E.loadTimeApiInfoList=[],E.cartSettings=null,E.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){}},E.loadScriptLogParallelHandler=async e=>{try{if(U.parallelLoadTimes.push(e),2===U.parallelLoadTimes.length){const e=U.parallelLoadTimes.find((e=>"vercel"===e.type)),o=U.parallelLoadTimes.find((e=>"jsdelivr"===e.type));if(!e||!o)return;if(e.isError&&o.isError)return void g({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}});U.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){}},E.legacyCheckoutErrorHandler=({message:e,metadata:o})=>{Z(`[ZONOS - loadZonos] ${e}`),g({endpoint:"LegacyCheckoutInit",errors:[e],metadata:Object.assign(Object.assign({},o),{tempCartUUID:U.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:e}))},E.getGithubCdn=({type:e,version:o})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.209";"cdnjs"===e?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.209":"unpkg"===e&&(n="https://unpkg.com/@zonos/elements@1.3.209");return o&&"alpha"!==o?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${o}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${o}`):n},E.injectZonos=({cdnType:e="jsdelivr",initConfig:o,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;o=Object.assign(Object.assign({},o),{zonosApiKey:U.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===e?t:U.getGithubCdn({type:e,version:r}),a=k||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()}`,u(`[ZONOS - loadZonos] Injecting "${c}" from "${d}"`,"info");const m="4g"===(null===(s=p())||void 0===s?void 0:s.effectiveType),w=["dev.elements.zonos.com","zonos.com"].some((e=>window.location.href.includes(e))),f=S[0]===e,h=S[1],y="on"===U.parallelLoadState&&m&&f&&h&&!w;y&&U.injectZonos({cdnType:h,initConfig:o,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();l.addEventListener("load",(()=>{if(y||n?U.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:l.src,storeId:U.storeId,type:e}):U.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:l.src,storeId:U.storeId,type:e}),U.isBigCommerce||(U.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=k,window.Zonos.zonosQaUrlApi=j,window.Zonos.zonosMode=U.zonosMode,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.loadTimeApiInfoList=U.loadTimeApiInfoList,window.Zonos.overrideUseCustomAddressForm=U.overrideUseCustomAddressForm,U.cartId){if(!U.zonosApiKey)throw U.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!U.cartData)throw U.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(U.legacyStoreFavicon&&U.isLegacyCheckout){const e=document.createElement("link");e.rel="shortcut icon",e.type="image/x-icon",e.href=U.legacyStoreFavicon,document.head.appendChild(e)}window.Zonos.cartData=U.cartData,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.cartSettings=U.cartSettings;const e=Object.assign(Object.assign({},o),{appearance:Object.assign(Object.assign({},o.appearance),{logoUrl:U.legacyStoreLogo||""}),zonosApiKey:U.zonosApiKey});o=e}window.Zonos.version&&(u(`[ZONOS - loadZonos] Execute "Zonos.init" from "${c}" from "${d}"`,"info"),window.Zonos.init(o))})),l.addEventListener("error",(async()=>{const s=(e=>{const o=S.indexOf(e);return S[o+1]||null})(e);if(!y&&!n){if(!s)return;U.injectZonos({cdnType:s,initConfig:o,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((e=>window.location.href.includes(e)))||k)return;if(y||n)return void U.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:l.src,storeId:U.storeId,type:e});["unpkg","cdnjs","vercel"].includes(e)?g({endpoint:l.src,errors:[`zonos.js - Failed to fetch ${e} CDN.`],metadata:{cdnLoadTime:performance.now()-v,cdnType:e,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):g({endpoint:l.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:e,vercelLoadTime:performance.now()-v}})})),document.head.appendChild(l)},E.init=async e=>{var t;if(u("=== Init zonos script release date","info",U.releaseDate),k&&!window.isZonosPreview){u(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${k}`,"info");const o=document.createElement("script");return o.src=`${k}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(o),o.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${k}`)})),void(window.isZonosPreview=!0)}const r=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:s,isLegacyCartId:i}=C(r);if(r&&!i&&!s)return void U.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${r}`,metadata:{invalidCartId:!0}});U.cartId=r;const a="https://v1.3.209.js.zonos.com",d=document.querySelector('script[src*="/zonos.js"]'),l=null===(t=document.querySelector("script[src*='/loadZonos.js']"))||void 0===t?void 0:t.src;u(`[ZONOS - init] first load script src: ${l}`,"info"),window.Zonos.zonosQaUrl=k,window.Zonos.zonosQaUrlApi=j,window.Zonos.zonosQaUrl&&u(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&u(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const c=null==l?void 0:l.includes("timestamp=");if(!(U.isNpm||l&&c))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(d||!l||U.requested)return void u("[ZONOS - loadZonos] script is already loaded or requested","info");if(!e.zonosApiKey&&!U.cartId)return U.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(U.requested=!0,U.zonosApiKey=e.zonosApiKey,U.storeId=e.storeId,U.cartId){const e=await(async e=>{const{isDgsCartId:o,isLegacyCartId:n}=C(e);if(!n&&!o)return Z("[ZONOS - loadZonos] invalid cart id"),null;const t=await T({cartId:e,retries:5});return u("[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)})(U.cartId);if(!e)throw U.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");U.cartData=e.cartData,U.cartSettings=e.settings,U.legacyStoreLogo=e.storeLogo,U.legacyStoreFavicon=e.storeFavicon,U.storeId=e.storeId,U.zonosApiKey=e.zonosApiKey}if(!U.zonosApiKey)return void Z('"zonosApiKey" is required to initialize Zonos');const p=await(async()=>{const e=n(),t=o();if(!e&&!t||!window.Zonos.zonosApiKey)return null;if(u("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return u("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:s}=await v("/api/get-test-public-credential");if(r.length||!s)return Z("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const i=s.publicCredential;return i?(u(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(Z("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(p&&(u(`[ZONOS - loadZonos] Using test API key: ${p} for test mode`,"info"),U.zonosApiKey=p),!U.storeId)return u("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void U.injectZonos({initConfig:e,vercelUrl:a,version:null});const m=U.storeId||e.storeId;u(`[ZONOS - loadZonos] Store ID: ${m}`,"info");const w=new URLSearchParams;w.set("storeId",m.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&w.set("_enableStoreVersionPinned","1");const{errors:g,json:f}=await v(`/api/get-store-version?${w.toString()}`);if(g.length||!f)return u("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void U.injectZonos({initConfig:e,vercelUrl:a,version:null});const{isDifferent:h,source:y,version:S}=f;if(u(`[ZONOS - loadZonos] Store version: ${S}, source: ${y}`,"info"),h){u(`[ZONOS - loadZonos] Updating saved store version to ${S}`,"info");const e={storeId:m,version:S};v(`/api/set-store-version?${w.toString()}`,{body:e,method:"POST"}).catch((e=>Z("Unable to save store's vesrion",e)))}if(!d){const{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,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:l}),r=t&&!n?o:`${"alpha"===S?"alpha":`v${S}`}.js.zonos.com`,s=t&&!n?null:S;u("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:S}),U.injectZonos({initConfig:e,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview&&!window.Zonos.doneInit)&&(window.Zonos=E)})();
|
|
1
|
+
(function(){"use strict";function e(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 o=()=>window.location.search.includes("zonosStagingMode=1"),n=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")},t=["cloudflare","vercel"],r=t[0],s={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},i=s[r],a=(e=r)=>{const o=t.indexOf(e),n=t[o+1];return n||null},d=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},l=performance.now(),c=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"}},u=(e,o,...n)=>{var t,r;const{elapsedTimePretty:s}=(()=>{const e=performance.now()-l,o=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:o}})(),i=[`(${s})`,...n];i.map(c).join(" ");if(!(!!(null===(t=window.Zonos)||void 0===t?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return;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()}},p=()=>{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"],w=({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=p();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)},g=async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:t})=>{if(u("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,d={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(`${i}/api/zonos-elements/log-error`,{body:JSON.stringify(d),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=a();if(!o)return;fetch(`${s[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(d),method:"POST"})}},f=async({response:e,shouldLog:o=!0,shouldThrow:n=!1})=>{try{const o=await e.text(),n=d(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}},h=async({basePathType:e,options:o,path:n})=>{let t;const i=window.Zonos.zonosQaUrlApi||s[e]||r,a=new URL(i+n),d=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;a.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(a.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:i,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:i,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const l=t.headers.get("Zonos-Mode"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&l&&c&&(window.Zonos.modeAlerted=!0),t.ok){return{baseUrl:i,errors:[],json:await f({response:t}),response:t,zonosMode:l}}const u=t.status.toString();try{const e=await f({response:t,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:i,errors:o.map((e=>"string"==typeof e?{message:e,type:u}:e)),json:null,response:t,zonosMode:l}}return{baseUrl:i,errors:[{message:JSON.stringify(e),type:u}],json:null,response:t,zonosMode:l}}catch(e){return{baseUrl:i,errors:[{message:`${u}: ${"Unknown error"}`,type:u}],json:null,response:null,zonosMode:l}}},y=async({basePathType:o,options:n,path:t})=>{var r,i;const l=t.startsWith("/api/bigcommerce")?"vercel":o,c=performance.now(),p=await h({basePathType:l,options:n,path:t}),{errors:m,response:f}=p,v=e(p,["errors","response"]),Z=performance.now()-c;u(`${t} (${Z.toFixed(2)}ms)`,"info");const S=null==f?void 0:f.headers.get("Zonos-Duration");200===(null==f?void 0:f.status)&&w({apiPath:t,apiType:l,loadTimeInternal:S?Number(S):0,loadTimeTotal:Z});const z=a(l),b=m.find((({type:e})=>"unknown"===e)),L=m.find((({message:e})=>e.includes("signal is aborted"))),O=!!b||404===(null==f?void 0:f.status),I=z&&O;return(O||L)&&g({endpoint:s[l]+t,errors:m.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:l,nextFallbackApiType:z,requestHeaders:null==n?void 0:n.headers,requestPayload:d(null===(r=null==n?void 0:n.body)||void 0===r?void 0:r.toString())||(null===(i=null==n?void 0:n.body)||void 0===i?void 0:i.toString()),status:null==f?void 0:f.status,statusText:null==f?void 0:f.statusText},shouldPostReleaseErrorReporting:!0}),I?(u(`=== "${t}" failed to fetch, trying next fallback ${z}`),y({basePathType:z,options:n,path:t})):Object.assign({errors:m,response:f},v)},v=async(t,s)=>{const i=e(s||{},[]),a=i.body?JSON.stringify(i.body):void 0,d=i.method||"GET",l=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":o()?"1":void 0,"Zonos-Test-Mode":n()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},i.headers);Object.keys(l).forEach((e=>void 0===l[e]&&delete l[e]));const c=Object.assign(Object.assign({},i),{body:"GET"===d?void 0:a,headers:l,method:d}),u=new URLSearchParams(window.location.search).get("useFallbackApi");return y({basePathType:u||r,options:c,path:t})},Z=(e,...o)=>{u(e,"error",...o)},S=["jsdelivr","cdnjs","unpkg","vercel"],z=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},b=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,L=new RegExp(`^${b.source}$`),O=new RegExp(`^cart_${b.source}$`),I=/^[a-zA-Z0-9]{2,}$/,A=/^cart_[a-zA-Z0-9]{2,}$/,C=e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:A.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:I.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},T=async({cartId:e,retries:o})=>{const t=n(),r=(()=>{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;r.overrideShouldEnabledCustomAddress&&i.set("overrideShouldEnabledCustomAddress",r.overrideShouldEnabledCustomAddress);const{errors:a,json:d,zonosMode:l}=await v(`/api/zonos-elements/get-cart?${i.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),c=!d||a.length;return c&&o?(u("[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})):c?null:Object.assign(Object.assign({},d),{zonosMode:l})};var U;const k=(()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=z(window.location.href),n="https://v1.3.210.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"].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 u(`[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})(),j=(()=>{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=z(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 u(`[ZONOS-WARNING] using '${t}' for serverless API`,"warn"),t})();class E{}U=E,E.isNpm=!1,E.isBigCommerce=!1,E.requested=!1,E.zonosMode=null,E.cartData=null,E.overrideUseCustomAddressForm=!1,E.domain=window.location!=window.parent.location?document.referrer:document.location.hostname,E.version="v1.3.210",E.isLegacyCheckout=!1,E.legacyStoreLogo=null,E.legacyStoreFavicon=null,E.parallelLoadTimes=[],E.parallelLoadState="off",E.releaseDate="1749136632453",E.loadTimeApiInfoList=[],E.cartSettings=null,E.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){}},E.loadScriptLogParallelHandler=async e=>{try{if(U.parallelLoadTimes.push(e),2===U.parallelLoadTimes.length){const e=U.parallelLoadTimes.find((e=>"vercel"===e.type)),o=U.parallelLoadTimes.find((e=>"jsdelivr"===e.type));if(!e||!o)return;if(e.isError&&o.isError)return void g({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}});U.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){}},E.legacyCheckoutErrorHandler=({message:e,metadata:o})=>{Z(`[ZONOS - loadZonos] ${e}`),g({endpoint:"LegacyCheckoutInit",errors:[e],metadata:Object.assign(Object.assign({},o),{tempCartUUID:U.cartId})}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:e}))},E.getGithubCdn=({type:e,version:o})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.210";"cdnjs"===e?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.210":"unpkg"===e&&(n="https://unpkg.com/@zonos/elements@1.3.210");return o&&"alpha"!==o?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${o}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${o}`):n},E.injectZonos=({cdnType:e="jsdelivr",initConfig:o,parallelLoaded:n,vercelUrl:t,version:r})=>{var s;o=Object.assign(Object.assign({},o),{zonosApiKey:U.zonosApiKey}),r&&(window.Zonos.version=`v${r}`);const i="vercel"===e?t:U.getGithubCdn({type:e,version:r}),a=k||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()}`,u(`[ZONOS - loadZonos] Injecting "${c}" from "${d}"`,"info");const m="4g"===(null===(s=p())||void 0===s?void 0:s.effectiveType),w=["dev.elements.zonos.com","zonos.com"].some((e=>window.location.href.includes(e))),f=S[0]===e,h=S[1],y="on"===U.parallelLoadState&&m&&f&&h&&!w;y&&U.injectZonos({cdnType:h,initConfig:o,parallelLoaded:!0,vercelUrl:t,version:r});const v=performance.now();l.addEventListener("load",(()=>{if(y||n?U.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:l.src,storeId:U.storeId,type:e}):U.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:l.src,storeId:U.storeId,type:e}),U.isBigCommerce||(U.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=k,window.Zonos.zonosQaUrlApi=j,window.Zonos.zonosMode=U.zonosMode,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.loadTimeApiInfoList=U.loadTimeApiInfoList,window.Zonos.overrideUseCustomAddressForm=U.overrideUseCustomAddressForm,U.cartId){if(!U.zonosApiKey)throw U.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!U.cartData)throw U.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(U.legacyStoreFavicon&&U.isLegacyCheckout){const e=document.createElement("link");e.rel="shortcut icon",e.type="image/x-icon",e.href=U.legacyStoreFavicon,document.head.appendChild(e)}window.Zonos.cartData=U.cartData,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.cartSettings=U.cartSettings;const e=Object.assign(Object.assign({},o),{appearance:Object.assign(Object.assign({},o.appearance),{logoUrl:U.legacyStoreLogo||""}),zonosApiKey:U.zonosApiKey});o=e}window.Zonos.version&&(u(`[ZONOS - loadZonos] Execute "Zonos.init" from "${c}" from "${d}"`,"info"),window.Zonos.init(o))})),l.addEventListener("error",(async()=>{const s=(e=>{const o=S.indexOf(e);return S[o+1]||null})(e);if(!y&&!n){if(!s)return;U.injectZonos({cdnType:s,initConfig:o,vercelUrl:t,version:r})}if(["localhost",".zonos.com"].some((e=>window.location.href.includes(e)))||k)return;if(y||n)return void U.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:l.src,storeId:U.storeId,type:e});["unpkg","cdnjs","vercel"].includes(e)?g({endpoint:l.src,errors:[`zonos.js - Failed to fetch ${e} CDN.`],metadata:{cdnLoadTime:performance.now()-v,cdnType:e,loadUrl:a,version:r},shouldPostReleaseErrorReporting:!!s}):g({endpoint:l.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:e,vercelLoadTime:performance.now()-v}})})),document.head.appendChild(l)},E.init=async e=>{var t;if(u("=== Init zonos script release date","info",U.releaseDate),k&&!window.isZonosPreview){u(`[ZONOS - loadZonos] Re-inject "loadZonos.js" from zonosQaUrl: ${k}`,"info");const o=document.createElement("script");return o.src=`${k}/dist/scripts/loadZonos.js?timestamp=${Date.now()}`,document.head.appendChild(o),o.addEventListener("load",(()=>{window.Zonos.isNpm=!1,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${k}`)})),void(window.isZonosPreview=!0)}const r=new URLSearchParams(window.location.search).get("tempCartUUID"),{isDgsCartId:s,isLegacyCartId:i}=C(r);if(r&&!i&&!s)return void U.legacyCheckoutErrorHandler({message:`[ZONOS - loadZonos] invalid &tempCartUUID=${r}`,metadata:{invalidCartId:!0}});U.cartId=r;const a="https://v1.3.210.js.zonos.com",d=document.querySelector('script[src*="/zonos.js"]'),l=null===(t=document.querySelector("script[src*='/loadZonos.js']"))||void 0===t?void 0:t.src;u(`[ZONOS - init] first load script src: ${l}`,"info"),window.Zonos.zonosQaUrl=k,window.Zonos.zonosQaUrlApi=j,window.Zonos.zonosQaUrl&&u(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&u(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const c=null==l?void 0:l.includes("timestamp=");if(!(U.isNpm||l&&c))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(d||!l||U.requested)return void u("[ZONOS - loadZonos] script is already loaded or requested","info");if(!e.zonosApiKey&&!U.cartId)return U.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(U.requested=!0,U.zonosApiKey=e.zonosApiKey,U.storeId=e.storeId,U.cartId){const e=await(async e=>{const{isDgsCartId:o,isLegacyCartId:n}=C(e);if(!n&&!o)return Z("[ZONOS - loadZonos] invalid cart id"),null;const t=await T({cartId:e,retries:5});return u("[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)})(U.cartId);if(!e)throw U.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");U.cartData=e.cartData,U.cartSettings=e.settings,U.legacyStoreLogo=e.storeLogo,U.legacyStoreFavicon=e.storeFavicon,U.storeId=e.storeId,U.zonosApiKey=e.zonosApiKey}if(!U.zonosApiKey)return void Z('"zonosApiKey" is required to initialize Zonos');const p=await(async()=>{const e=n(),t=o();if(!e&&!t||!window.Zonos.zonosApiKey)return null;if(u("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return u("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:s}=await v("/api/get-test-public-credential");if(r.length||!s)return Z("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const i=s.publicCredential;return i?(u(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(Z("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();if(p&&(u(`[ZONOS - loadZonos] Using test API key: ${p} for test mode`,"info"),U.zonosApiKey=p),!U.storeId)return u("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void U.injectZonos({initConfig:e,vercelUrl:a,version:null});const m=U.storeId||e.storeId;u(`[ZONOS - loadZonos] Store ID: ${m}`,"info");const w=new URLSearchParams;w.set("storeId",m.toString()),window.location.search.includes("_enableStoreVersionPinned=1")&&w.set("_enableStoreVersionPinned","1");const{errors:g,json:f}=await v(`/api/get-store-version?${w.toString()}`);if(g.length||!f)return u("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void U.injectZonos({initConfig:e,vercelUrl:a,version:null});const{isDifferent:h,source:y,version:S}=f;if(u(`[ZONOS - loadZonos] Store version: ${S}, source: ${y}`,"info"),h){u(`[ZONOS - loadZonos] Updating saved store version to ${S}`,"info");const e={storeId:m,version:S};v(`/api/set-store-version?${w.toString()}`,{body:e,method:"POST"}).catch((e=>Z("Unable to save store's vesrion",e)))}if(!d){const{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,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:l}),r=t&&!n?o:`${"alpha"===S?"alpha":`v${S}`}.js.zonos.com`,s=t&&!n?null:S;u("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t,loadUrl:r,loadVersion:s,version:S}),U.injectZonos({initConfig:e,vercelUrl:r,version:s})}},(void 0===window.Zonos||window.isZonosPreview&&!window.Zonos.doneInit)&&(window.Zonos=E)})();
|
package/dist/scripts/zonos.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const e=({id:e,payload:t,target:o,type:n})=>{var r;o instanceof HTMLIFrameElement?null===(r=o.contentWindow)||void 0===r||r.postMessage({id:e,payload:t,type:n},"*"):o.postMessage({id:e,payload:t,type:n},"*")};class t{constructor(t,o){this.targetElement=t,this.targetId=o,this.sendMessage=(t,o)=>{e({id:this.targetId,payload:o,target:this.targetElement,type:t})}}}t.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},t.sendMessage=e,t.injectPrivateIframe=({id:e,onload:t,src:o})=>{const n=document.createElement("iframe");return n.src=o,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=()=>t(n),document.body.appendChild(n),n};const o=performance.now(),n=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},r=(e,t,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const e=performance.now()-o,t=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:t}})(),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(t){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,...t)=>{r(e,"error",...t)},i=["jsdelivr","cdnjs","unpkg","vercel"],a="jsdelivr",l=e=>{const t=i.indexOf(e);return i[t+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,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}"function"==typeof SuppressedError&&SuppressedError;const 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 t=p.indexOf(e),o=p[t+1];return o||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,t=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,t="mozConnection"in window.navigator?window.navigator.mozConnection:null,o="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||t||o})();return{connectionDownlink:null==t?void 0:t.downlink,connectionEffectiveType:null==t?void 0:t.effectiveType,connectionRtt:null==t?void 0:t.rtt,connectionSaveData:null==t?void 0:t.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:t=!0,shouldThrow:o=!1})=>{try{const t=await e.text(),o=g(t);if(!o)throw new Error(`Failed to parse content: ${t}`);return o}catch(e){if(o)throw e;return t&&console.error(e),null}},S=async({basePathType:e,options:t,path:o})=>{let n;const r=window.Zonos.zonosQaUrlApi||w[e]||m,s=new URL(r+o),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(t){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),t)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const 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 t=e.errors;return{baseUrl:r,errors:t.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:t,path:o})=>{var n,s;const i=o.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await S({basePathType:i,options:t,path:o}),{errors:d,response:c}=l,p=u(l,["errors","response"]),m=performance.now()-a;r(`${o} (${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:t,loadTimeInternal:o,loadTimeTotal:n})=>{if(v.includes(e))return;const r=n-o;if(r<0)return;const s=e.split("?")[0]||e,i=f(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:t,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(d=a,d||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:o,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:o,apiType:i,loadTimeInternal:b?Number(b):0,loadTimeTotal:m});const z=y(i),k=d.find((({type:e})=>"unknown"===e)),j=d.find((({message:e})=>e.includes("signal is aborted"))),O=!!k||404===(null==c?void 0:c.status),Z=z&&O;return(O||j)&&(async({endpoint:e,errors:t,metadata:o,shouldPostReleaseErrorReporting:n})=>{r("sendErrorLog","warn",e,o,t);{const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:t,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},o)};try{fetch(`${h}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const t=y();if(!t)return;fetch(`${w[t]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:w[i]+o,errors:d.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:z,requestHeaders:null==t?void 0:t.headers,requestPayload:g(null===(n=null==t?void 0:t.body)||void 0===n?void 0:n.toString())||(null===(s=null==t?void 0:t.body)||void 0===s?void 0:s.toString()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),Z?(r(`=== "${o}" failed to fetch, trying next fallback ${z}`),C({basePathType:z,options:t,path:o})):Object.assign({errors:d,response:c},p)},z=async(e,t)=>{const o=u(t||{},[]),n=o.body?JSON.stringify(o.body):void 0,r=o.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"},o.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const i=Object.assign(Object.assign({},o),{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 t=(e=>{if(!e)return null;const t=new URL(e).searchParams.get("zonosQaUrl");return t?/[^a-zA-Z0-9-_]+/.test(t)?null:t:null})(window.location.href),o="https://v1.3.209.js.zonos.com";if(!t&&(o.includes("test.")||o.includes("test-")))return o;if(!t&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!t)return null;if("dev-elements"===t)return"https://dev.elements.zonos.com";const n=`https://${t}.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:t}=window.location,o=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),n},j="https://js.stripe.com/v3",O=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let Z=null;const I=e=>(null!==Z||(Z=new Promise(((t,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)t(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${j}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&O.test(o.src))return o}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 t=document.createElement("script");t.src=`${j}`;const o=document.head||document.body;return o?(o.appendChild(t),t):(s("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",(()=>{window.Stripe?t(window.Stripe):o(new Error("Stripe.js not available"))})),null==n||n.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else t(null)}))),Z),A=Promise.resolve().then((()=>I(null)));let E=!1;A.catch((e=>{E||console.warn(e)}));const T=async({cartId:e,retries:t})=>{const o=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:o,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||a.length;return u&&t?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:t}),await new Promise((e=>setTimeout(e,500))),T({cartId:e,retries:t-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}/,$=new RegExp(`^${L.source}$`),P=new RegExp(`^cart_${L.source}$`),U=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,D=async e=>{const{isDgsCartId:t,isLegacyCartId:o}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:P.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!o&&!t)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)},F="zonos--checkout-hidden-international-button";var R;const M=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:t,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const t=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>t.includes(e))),n=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:n,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?t:null})(),x="https://v1.3.209.js.zonos.com",B=M||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.209",q="https://fonts.googleapis.com",W=/^https:\/\/fonts\.googleapis\.com/;class K{}R=K,K.doneInit=!1,K.cartSettings=null,K.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),K.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),K._paypalMockResponse=null,K.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,K.isBigCommerce=!1,K.releaseDate="1749049171170",K.isLegacyCheckout=!1,K.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",K.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),K.overrideUseCustomAddressForm=!1,K.isNpm=!0,K.zonosQaUrl=null,K.zonosQaUrlApi=null,K.trackEventLogs=[],K.version="v1.3.209",K.modeAlerted=!1,K.cartData=null,K.paypal=null,K.zonosMode=null,K.IframeService=t,K.getCurrentTimestamp=()=>(new Date).getTime(),K.zonosController=null,K.loadTimeApiInfoList=[],K.logIntervalId=null,K.init=async e=>{const{appearance:t,checkoutSettings:o,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:u,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=u,R.isNpm){r("====== ZONOS LOADING FROM NPM ======");const t=k();if(t&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${t} ======`,"info");const o=document.createElement("script");return o.src=`${t}/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.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${t}`)})),void(window.isZonosPreview=!0)}if(!p&&!R.cartId)return void s("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 D(R.cartId);if(!e)return void s("Failed to get cart data");R.cartData=e.cartData,R.zonosApiKey=e.zonosApiKey,R.cartSettings=e.settings}const o=await(async()=>{const e=c(),t=d();if(!e&&!t||!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:n}=await z("/api/get-test-public-credential");if(o.length||!n)return s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),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)})();o&&(R.zonosApiKey=o)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(R.cartId&&R.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"),R.restoreNativeBrowserFunctions(),R.injectCustomScriptForHostedCheckout(),R.injectZonosCdn(),R.injectZonosCss(),R.injectFonts(),R.injectCheckoutInternationalButton(),R.injectController({config:{appearance:t,checkoutSettings:o,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),R.doneInit=!0},K.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${F}`)){const e=document.createElement("button");e.id=F,e.style.display="none",document.body.appendChild(e)}},K.injectCustomScriptForHostedCheckout=()=>{const e=R.cartData,t=(null==e?void 0:e.metadata)||[],o=t.find((e=>"customHeaderScript"===e.key)),n=t.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||n)){if(o){r("Injecting custom header script");const e=document.createElement("script");e.textContent=o.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:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},K.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},K.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${F}`);setTimeout((()=>{var t;e&&e.dispatchEvent(new CustomEvent("click",{detail:t}))}),10)},K.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},K.showNotification=e=>{var t;null===(t=R.zonosController)||void 0===t||t.showNotification(e)},K.updateOrganizationName=e=>{var t;null===(t=R.zonosController)||void 0===t||t.updateOrganizationName(e)},K.disablePlaceOrderButtons=({autoEnable:e=!0,config:t,disable:o,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=t.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const t=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};t.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&o&&setTimeout((()=>{t.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},K.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const t="zonos---native-browser";let o=document.querySelector(`iframe#${t}`);o||(o=document.createElement("iframe"),o.id=t,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 n=(null===(e=o.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(o)},K.injectController=({config:e})=>{var t,o;if(document.querySelector("zonos-controller"))return;if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.placeOrderButtonSelector){const t=e.checkoutSettings.placeOrderButtonSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t});new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const t=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t});new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t})})).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=R.zonosApiKey||"",n.addEventListener("stripeInitEvent",(async e=>{const{detail:t}=e;r("loading Stripe");const o=await(async(...e)=>{E=!0;const t=Date.now();return A.then((o=>((e,t,o)=>{if(null===e)return null;const n=e.apply(void 0,t);return((e,t)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:t})})(n,o),n})(o,e,t)))})(t.publishableKey);o?(window.Zonos.stripe=o,n.initCheckoutElement(o)):s("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(n),R.zonosController=n,r("Zonos controller injected!")},K.injectScript=({cdnType:e,isModule:t,theRestUrl:o})=>{const n=`${R.getZonosUrl(e)}/${o}`;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");t?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&&R.injectScript({cdnType:n,isModule:t,theRestUrl:o})},i.appendChild(a)},K.getZonosUrl=e=>{const t=()=>{switch(e){case"jsdelivr":return B;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.209";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.209";case"vercel":return x}};if(R.isNpm){return k()||t()}return t()},K.injectZonosCdn=()=>{R.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),R.injectScript({cdnType:a,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},K.injectStylesheet=({cdnType:e,theRestUrl:t})=>{const o=R.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${x}/`,n.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${o}/${t}`,i.onerror=()=>{s(`Failed to load ${i.href}`);const o=l(e);o&&R.injectStylesheet({cdnType:o,theRestUrl:t})},n.appendChild(i)},K.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(R.injectStylesheet({cdnType:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},K.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${q}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&!W.test(o.href))return o}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,t=document.createElement("link");t.rel="preconnect",t.href=q,e.appendChild(t);const o=document.createElement("link");o.rel="stylesheet",o.href=`${q}/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!")},K.setupGoogleFont=e=>{var t;null===(t=R.zonosController)||void 0===t||t.setupGoogleFont(e)},K.injectSupportGoogleFont=e=>{var t;r(`[FONT] injecting ${e}`);const o=null===(t=e.match(/family=(.*?):/))||void 0===t?void 0:t[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${q}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=q,n.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,n.appendChild(s),r(`[FONT] ${o} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=K)})();
|
|
1
|
+
(function(){"use strict";const e=({id:e,payload:t,target:o,type:n})=>{var r;o instanceof HTMLIFrameElement?null===(r=o.contentWindow)||void 0===r||r.postMessage({id:e,payload:t,type:n},"*"):o.postMessage({id:e,payload:t,type:n},"*")};class t{constructor(t,o){this.targetElement=t,this.targetId=o,this.sendMessage=(t,o)=>{e({id:this.targetId,payload:o,target:this.targetElement,type:t})}}}t.iframeServices={GOOGLE_PLACES:"zonos--private-iframe-google-places-service-m9bmuh7g"},t.sendMessage=e,t.injectPrivateIframe=({id:e,onload:t,src:o})=>{const n=document.createElement("iframe");return n.src=o,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=()=>t(n),document.body.appendChild(n),n};const o=performance.now(),n=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},r=(e,t,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const e=performance.now()-o,t=e>1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(2)}ms`;return{elapsedTime:e,elapsedTimePretty:t}})(),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(t){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,...t)=>{r(e,"error",...t)},i=["jsdelivr","cdnjs","unpkg","vercel"],a="jsdelivr",l=e=>{const t=i.indexOf(e);return i[t+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,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}"function"==typeof SuppressedError&&SuppressedError;const 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 t=p.indexOf(e),o=p[t+1];return o||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,t=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,t="mozConnection"in window.navigator?window.navigator.mozConnection:null,o="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||t||o})();return{connectionDownlink:null==t?void 0:t.downlink,connectionEffectiveType:null==t?void 0:t.effectiveType,connectionRtt:null==t?void 0:t.rtt,connectionSaveData:null==t?void 0:t.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:t=!0,shouldThrow:o=!1})=>{try{const t=await e.text(),o=g(t);if(!o)throw new Error(`Failed to parse content: ${t}`);return o}catch(e){if(o)throw e;return t&&console.error(e),null}},S=async({basePathType:e,options:t,path:o})=>{let n;const r=window.Zonos.zonosQaUrlApi||w[e]||m,s=new URL(r+o),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(t){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),t)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const 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 t=e.errors;return{baseUrl:r,errors:t.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:t,path:o})=>{var n,s;const i=o.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await S({basePathType:i,options:t,path:o}),{errors:d,response:c}=l,p=u(l,["errors","response"]),m=performance.now()-a;r(`${o} (${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:t,loadTimeInternal:o,loadTimeTotal:n})=>{if(v.includes(e))return;const r=n-o;if(r<0)return;const s=e.split("?")[0]||e,i=f(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:t,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(d=a,d||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:o,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:o,apiType:i,loadTimeInternal:b?Number(b):0,loadTimeTotal:m});const z=y(i),k=d.find((({type:e})=>"unknown"===e)),j=d.find((({message:e})=>e.includes("signal is aborted"))),O=!!k||404===(null==c?void 0:c.status),Z=z&&O;return(O||j)&&(async({endpoint:e,errors:t,metadata:o,shouldPostReleaseErrorReporting:n})=>{r("sendErrorLog","warn",e,o,t);{const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:t,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},o)};try{fetch(`${h}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const t=y();if(!t)return;fetch(`${w[t]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:w[i]+o,errors:d.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:z,requestHeaders:null==t?void 0:t.headers,requestPayload:g(null===(n=null==t?void 0:t.body)||void 0===n?void 0:n.toString())||(null===(s=null==t?void 0:t.body)||void 0===s?void 0:s.toString()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),Z?(r(`=== "${o}" failed to fetch, trying next fallback ${z}`),C({basePathType:z,options:t,path:o})):Object.assign({errors:d,response:c},p)},z=async(e,t)=>{const o=u(t||{},[]),n=o.body?JSON.stringify(o.body):void 0,r=o.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"},o.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const i=Object.assign(Object.assign({},o),{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 t=(e=>{if(!e)return null;const t=new URL(e).searchParams.get("zonosQaUrl");return t?/[^a-zA-Z0-9-_]+/.test(t)?null:t:null})(window.location.href),o="https://v1.3.210.js.zonos.com";if(!t&&(o.includes("test.")||o.includes("test-")))return o;if(!t&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!t)return null;if("dev-elements"===t)return"https://dev.elements.zonos.com";const n=`https://${t}.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:t}=window.location,o=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),n},j="https://js.stripe.com/v3",O=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;let Z=null;const I=e=>(null!==Z||(Z=new Promise(((t,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)t(window.Stripe);else try{let n=(()=>{const e=document.querySelectorAll(`script[src^="${j}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&O.test(o.src))return o}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 t=document.createElement("script");t.src=`${j}`;const o=document.head||document.body;return o?(o.appendChild(t),t):(s("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==n||n.addEventListener("load",(()=>{window.Stripe?t(window.Stripe):o(new Error("Stripe.js not available"))})),null==n||n.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else t(null)}))),Z),A=Promise.resolve().then((()=>I(null)));let E=!1;A.catch((e=>{E||console.warn(e)}));const T=async({cartId:e,retries:t})=>{const o=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:o,renewCartExpirationToken:s,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),u=!l||a.length;return u&&t?(r("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:t}),await new Promise((e=>setTimeout(e,500))),T({cartId:e,retries:t-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}/,$=new RegExp(`^${L.source}$`),P=new RegExp(`^cart_${L.source}$`),U=/^[a-zA-Z0-9]{2,}$/,N=/^cart_[a-zA-Z0-9]{2,}$/,D=async e=>{const{isDgsCartId:t,isLegacyCartId:o}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:U.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:P.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:$.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!o&&!t)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)},F="zonos--checkout-hidden-international-button";var R;const M=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:t,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const t=new URL(e).origin,o=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>t.includes(e))),n=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:n,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?t:null})(),x="https://v1.3.210.js.zonos.com",B=M||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.210",q="https://fonts.googleapis.com",W=/^https:\/\/fonts\.googleapis\.com/;class K{}R=K,K.doneInit=!1,K.cartSettings=null,K.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),K.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),K._paypalMockResponse=null,K.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,K.isBigCommerce=!1,K.releaseDate="1749136632453",K.isLegacyCheckout=!1,K.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",K.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),K.overrideUseCustomAddressForm=!1,K.isNpm=!0,K.zonosQaUrl=null,K.zonosQaUrlApi=null,K.trackEventLogs=[],K.version="v1.3.210",K.modeAlerted=!1,K.cartData=null,K.paypal=null,K.zonosMode=null,K.IframeService=t,K.getCurrentTimestamp=()=>(new Date).getTime(),K.zonosController=null,K.loadTimeApiInfoList=[],K.logIntervalId=null,K.init=async e=>{const{appearance:t,checkoutSettings:o,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l,storeId:u,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=u,R.isNpm){r("====== ZONOS LOADING FROM NPM ======");const t=k();if(t&&!window.isZonosPreview){r(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${t} ======`,"info");const o=document.createElement("script");return o.src=`${t}/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.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${t}`)})),void(window.isZonosPreview=!0)}if(!p&&!R.cartId)return void s("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 D(R.cartId);if(!e)return void s("Failed to get cart data");R.cartData=e.cartData,R.zonosApiKey=e.zonosApiKey,R.cartSettings=e.settings}const o=await(async()=>{const e=c(),t=d();if(!e&&!t||!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:n}=await z("/api/get-test-public-credential");if(o.length||!n)return s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",o),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)})();o&&(R.zonosApiKey=o)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(R.cartId&&R.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"),R.restoreNativeBrowserFunctions(),R.injectCustomScriptForHostedCheckout(),R.injectZonosCdn(),R.injectZonosCss(),R.injectFonts(),R.injectCheckoutInternationalButton(),R.injectController({config:{appearance:t,checkoutSettings:o,currencyConverter:n,helloSettings:i,onCountryChange:a,overrideCurrencyFormat:l}}),R.doneInit=!0},K.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${F}`)){const e=document.createElement("button");e.id=F,e.style.display="none",document.body.appendChild(e)}},K.injectCustomScriptForHostedCheckout=()=>{const e=R.cartData,t=(null==e?void 0:e.metadata)||[],o=t.find((e=>"customHeaderScript"===e.key)),n=t.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(o||n)){if(o){r("Injecting custom header script");const e=document.createElement("script");e.textContent=o.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:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},K.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},K.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${F}`);setTimeout((()=>{var t;e&&e.dispatchEvent(new CustomEvent("click",{detail:t}))}),10)},K.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},K.showNotification=e=>{var t;null===(t=R.zonosController)||void 0===t||t.showNotification(e)},K.updateOrganizationName=e=>{var t;null===(t=R.zonosController)||void 0===t||t.updateOrganizationName(e)},K.disablePlaceOrderButtons=({autoEnable:e=!0,config:t,disable:o,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=t.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const t=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};t.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(o?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&o&&setTimeout((()=>{t.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},K.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const t="zonos---native-browser";let o=document.querySelector(`iframe#${t}`);o||(o=document.createElement("iframe"),o.id=t,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 n=(null===(e=o.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(o)},K.injectController=({config:e})=>{var t,o;if(document.querySelector("zonos-controller"))return;if(null===(t=e.checkoutSettings)||void 0===t?void 0:t.placeOrderButtonSelector){const t=e.checkoutSettings.placeOrderButtonSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t});new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t})})).observe(document.body,{childList:!0,subtree:!0})}if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.alwaysTriggerInternationalCheckoutSelector){const t=e.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t});new MutationObserver((()=>{R.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:t})})).observe(document.body,{childList:!0,subtree:!0})}const n=document.createElement("zonos-controller");n.config=e,n.zonosApiKey=R.zonosApiKey||"",n.addEventListener("stripeInitEvent",(async e=>{const{detail:t}=e;r("loading Stripe");const o=await(async(...e)=>{E=!0;const t=Date.now();return A.then((o=>((e,t,o)=>{if(null===e)return null;const n=e.apply(void 0,t);return((e,t)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:t})})(n,o),n})(o,e,t)))})(t.publishableKey);o?(window.Zonos.stripe=o,n.initCheckoutElement(o)):s("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(n),R.zonosController=n,r("Zonos controller injected!")},K.injectScript=({cdnType:e,isModule:t,theRestUrl:o})=>{const n=`${R.getZonosUrl(e)}/${o}`;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");t?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&&R.injectScript({cdnType:n,isModule:t,theRestUrl:o})},i.appendChild(a)},K.getZonosUrl=e=>{const t=()=>{switch(e){case"jsdelivr":return B;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.210";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.210";case"vercel":return x}};if(R.isNpm){return k()||t()}return t()},K.injectZonosCdn=()=>{R.injectScript({cdnType:a,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),R.injectScript({cdnType:a,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),r("Zonos cdn script injected!")},K.injectStylesheet=({cdnType:e,theRestUrl:t})=>{const o=R.getZonosUrl(e),n=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${x}/`,n.appendChild(r);const i=document.createElement("link");i.rel="stylesheet",i.href=`${o}/${t}`,i.onerror=()=>{s(`Failed to load ${i.href}`);const o=l(e);o&&R.injectStylesheet({cdnType:o,theRestUrl:t})},n.appendChild(i)},K.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?r("Zonos style links already injected","warn"):(R.injectStylesheet({cdnType:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),r("Zonos style css injected!"))},K.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void r("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${q}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&!W.test(o.href))return o}return null})())return void r("Inter font already injected","warn");const e=document.head||document.body,t=document.createElement("link");t.rel="preconnect",t.href=q,e.appendChild(t);const o=document.createElement("link");o.rel="stylesheet",o.href=`${q}/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!")},K.setupGoogleFont=e=>{var t;null===(t=R.zonosController)||void 0===t||t.setupGoogleFont(e)},K.injectSupportGoogleFont=e=>{var t;r(`[FONT] injecting ${e}`);const o=null===(t=e.match(/family=(.*?):/))||void 0===t?void 0:t[1],n=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${q}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=q,n.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,n.appendChild(s),r(`[FONT] ${o} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=K)})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg color="var(--zonos-elements-
|
|
1
|
+
<svg color="var(--zonos-elements-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--zonos-elements-gray-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as n}from"./p-595f5dd2.js";import{g as o,I as t}from"./p-e7b0c156.js";import{g as r,a as i,l,h as u,b as m}from"./p-20839c46.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{a as availableTestKeys}from"./p-04a01cb1.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.209.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"].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 l(`[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",z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,j="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(j),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&&z.test(o.src))return o}return null})();t&&e?console.warn(j):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=r(),s=o(),i=p()||void 0,c=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&c.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:d,json:a,zonosMode:m}=await u(`/api/zonos-elements/get-cart?${c.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:i,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),w=!a||d.length;return w&&n?(l("[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 T;const R=(()=>{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})(),$="https://v1.3.209.js.zonos.com",Z=R||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.209",L="https://fonts.googleapis.com",U=/^https:\/\/fonts\.googleapis\.com/;class A{}T=A,A.doneInit=!1,A.cartSettings=null,A.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),A.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),A._paypalMockResponse=null,A.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,A.isBigCommerce=!1,A.releaseDate="1749049121169",A.isLegacyCheckout=!1,A.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",A.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),A.overrideUseCustomAddressForm=!1,A.isNpm=!0,A.zonosQaUrl=null,A.zonosQaUrlApi=null,A.trackEventLogs=[],A.version="v1.3.209",A.modeAlerted=!1,A.cartData=null,A.paypal=null,A.zonosMode=null,A.IframeService=t,A.getCurrentTimestamp=()=>(new Date).getTime(),A.zonosController=null,A.loadTimeApiInfoList=[],A.logIntervalId=null,A.init=async e=>{const{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d,storeId:a,zonosApiKey:p}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),T.doneInit)return;if(l(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=p,T.storeId=a,T.isNpm){l("====== ZONOS LOADING FROM NPM ======");const n=S();if(n&&!window.isZonosPreview){l(`====== 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=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${n}`)})),void(window.isZonosPreview=!0)}if(!p&&!T.cartId)return void m("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){l("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 l("[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)})(T.cartId);if(!e)return void m("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey,T.cartSettings=e.settings}const o=await(async()=>{const e=r(),n=i();if(!e&&!n||!window.Zonos.zonosApiKey)return null;if(l("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return l("[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?(l(`[ZONOS - loadZonos] Retrieve new test public token ${s}`,"info"),s):(m("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();o&&(T.zonosApiKey=o)}const h=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(T.cartId&&T.cartData||h){l("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)}l("init zonos"),T.restoreNativeBrowserFunctions(),T.injectCustomScriptForHostedCheckout(),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectCheckoutInternationalButton(),T.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d}}),T.doneInit=!0},A.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${h}`)){const e=document.createElement("button");e.id=h,e.style.display="none",document.body.appendChild(e)}},A.injectCustomScriptForHostedCheckout=()=>{const e=T.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){l("Injecting custom header script");const e=document.createElement("script");e.textContent=o.value,document.head.appendChild(e)}if(t){l("Injecting custom footer script");const e=document.createElement("script");e.textContent=t.value,document.body.appendChild(e)}}else l("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},A.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},A.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${h}`);setTimeout((()=>{e&&e.dispatchEvent(n("click"))}),10)},A.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},A.showNotification=e=>{var n;null===(n=T.zonosController)||void 0===n||n.showNotification(e)},A.updateOrganizationName=e=>{var n;null===(n=T.zonosController)||void 0===n||n.updateOrganizationName(e)},A.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)}},A.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)},A.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;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{T.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;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{T.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=T.zonosApiKey||"",t.addEventListener("stripeInitEvent",(async e=>{const{detail:n}=e;l("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,t.initCheckoutElement(o)):m("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(t),T.zonosController=t,l("Zonos controller injected!")},A.injectScript=({cdnType:e,isModule:n,theRestUrl:o})=>{const t=`${T.getZonosUrl(e)}/${o}`;if(document.querySelector(`script[src="${t}"]`))return void l(`Zonos script "${t}" already exists in the document`,"warn");const s=document.head||document.body,r=document.createElement("script");n?r.type="module":r.noModule=!0,r.src=t,r.crossOrigin="anonymous",r.onerror=()=>{m(`Failed to load ${r.src}`);const t=O(e);t&&T.injectScript({cdnType:t,isModule:n,theRestUrl:o})},s.appendChild(r)},A.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return Z;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.209";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.209";case"vercel":return $}};return T.isNpm&&S()||n()},A.injectZonosCdn=()=>{T.injectScript({cdnType:v,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:v,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),l("Zonos cdn script injected!")},A.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const o=T.getZonosUrl(e),t=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${$}/`,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&&T.injectStylesheet({cdnType:o,theRestUrl:n})},t.appendChild(r)},A.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?l("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:v,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),l("Zonos style css injected!"))},A.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void l("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 l("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),l("Zonos font injected!")},A.setupGoogleFont=e=>{var n;null===(n=T.zonosController)||void 0===n||n.setupGoogleFont(e)},A.injectSupportGoogleFont=e=>{var n;l(`[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 l(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,t.appendChild(s),l(`[FONT] ${o} font injected!`)};const C=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"],E=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"],P=[...C,...E];export{A as Zonos,P as checkoutSessionAttributeKeys,E as checkoutSessionImmutableAttributeKeys,C as checkoutSessionMutableAttributeKeys}
|
|
1
|
+
import{c as n}from"./p-595f5dd2.js";import{g as o,I as t}from"./p-e7b0c156.js";import{g as r,a as i,l,h as u,b as m}from"./p-20839c46.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{a as availableTestKeys}from"./p-04a01cb1.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.210.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"].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 l(`[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",z=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,j="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(j),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&&z.test(o.src))return o}return null})();t&&e?console.warn(j):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=r(),s=o(),i=p()||void 0,c=new URLSearchParams;s.overrideShouldEnabledCustomAddress&&c.set("overrideShouldEnabledCustomAddress",s.overrideShouldEnabledCustomAddress);const{errors:d,json:a,zonosMode:m}=await u(`/api/zonos-elements/get-cart?${c.toString()}`,{body:{isTestMode:t,renewCartExpirationToken:i,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),w=!a||d.length;return w&&n?(l("[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 T;const R=(()=>{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})(),$="https://v1.3.210.js.zonos.com",Z=R||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.210",L="https://fonts.googleapis.com",U=/^https:\/\/fonts\.googleapis\.com/;class A{}T=A,A.doneInit=!1,A.cartSettings=null,A.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),A.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),A._paypalMockResponse=null,A.iframeLogType="undefined"!=typeof window?new URLSearchParams(window.location.search).get("iframeLogType"):null,A.isBigCommerce=!1,A.releaseDate="1749136579531",A.isLegacyCheckout=!1,A.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",A.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),A.overrideUseCustomAddressForm=!1,A.isNpm=!0,A.zonosQaUrl=null,A.zonosQaUrlApi=null,A.trackEventLogs=[],A.version="v1.3.210",A.modeAlerted=!1,A.cartData=null,A.paypal=null,A.zonosMode=null,A.IframeService=t,A.getCurrentTimestamp=()=>(new Date).getTime(),A.zonosController=null,A.loadTimeApiInfoList=[],A.logIntervalId=null,A.init=async e=>{const{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d,storeId:a,zonosApiKey:p}=e;if(T.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),T.doneInit)return;if(l(`====== ZONOS DEBUG MODE: on (${T.version}) ======`),T.zonosApiKey=p,T.storeId=a,T.isNpm){l("====== ZONOS LOADING FROM NPM ======");const n=S();if(n&&!window.isZonosPreview){l(`====== 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=T.isNpm,window.Zonos.isBigCommerce=T.isBigCommerce,window.Zonos.isLegacyCheckout=T.isLegacyCheckout,window.Zonos.init(e)})),o.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${n}`)})),void(window.isZonosPreview=!0)}if(!p&&!T.cartId)return void m("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!T.cartData&&T.cartId){l("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 l("[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)})(T.cartId);if(!e)return void m("Failed to get cart data");T.cartData=e.cartData,T.zonosApiKey=e.zonosApiKey,T.cartSettings=e.settings}const o=await(async()=>{const e=r(),n=i();if(!e&&!n||!window.Zonos.zonosApiKey)return null;if(l("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return l("[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?(l(`[ZONOS - loadZonos] Retrieve new test public token ${s}`,"info"),s):(m("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();o&&(T.zonosApiKey=o)}const h=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(T.cartId&&T.cartData||h){l("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)}l("init zonos"),T.restoreNativeBrowserFunctions(),T.injectCustomScriptForHostedCheckout(),T.injectZonosCdn(),T.injectZonosCss(),T.injectFonts(),T.injectCheckoutInternationalButton(),T.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:t,helloSettings:s,onCountryChange:c,overrideCurrencyFormat:d}}),T.doneInit=!0},A.injectCheckoutInternationalButton=()=>{if(!document.querySelector(`#${h}`)){const e=document.createElement("button");e.id=h,e.style.display="none",document.body.appendChild(e)}},A.injectCustomScriptForHostedCheckout=()=>{const e=T.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){l("Injecting custom header script");const e=document.createElement("script");e.textContent=o.value,document.head.appendChild(e)}if(t){l("Injecting custom footer script");const e=document.createElement("script");e.textContent=t.value,document.body.appendChild(e)}}else l("Skip injecting custom script for hosted checkout","info",{footerScript:t,headerScript:o,isLegacyCheckout:window.Zonos.isLegacyCheckout})},A.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},A.triggerCheckoutInternational=async()=>{const e=document.querySelector(`#${h}`);setTimeout((()=>{e&&e.dispatchEvent(n("click"))}),10)},A.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},A.showNotification=e=>{var n;null===(n=T.zonosController)||void 0===n||n.showNotification(e)},A.updateOrganizationName=e=>{var n;null===(n=T.zonosController)||void 0===n||n.updateOrganizationName(e)},A.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)}},A.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)},A.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;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{T.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;T.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:n}),new MutationObserver((()=>{T.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=T.zonosApiKey||"",t.addEventListener("stripeInitEvent",(async e=>{const{detail:n}=e;l("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,t.initCheckoutElement(o)):m("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(t),T.zonosController=t,l("Zonos controller injected!")},A.injectScript=({cdnType:e,isModule:n,theRestUrl:o})=>{const t=`${T.getZonosUrl(e)}/${o}`;if(document.querySelector(`script[src="${t}"]`))return void l(`Zonos script "${t}" already exists in the document`,"warn");const s=document.head||document.body,r=document.createElement("script");n?r.type="module":r.noModule=!0,r.src=t,r.crossOrigin="anonymous",r.onerror=()=>{m(`Failed to load ${r.src}`);const t=O(e);t&&T.injectScript({cdnType:t,isModule:n,theRestUrl:o})},s.appendChild(r)},A.getZonosUrl=e=>{const n=()=>{switch(e){case"jsdelivr":return Z;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.210";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.210";case"vercel":return $}};return T.isNpm&&S()||n()},A.injectZonosCdn=()=>{T.injectScript({cdnType:v,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),T.injectScript({cdnType:v,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),l("Zonos cdn script injected!")},A.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const o=T.getZonosUrl(e),t=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${$}/`,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&&T.injectStylesheet({cdnType:o,theRestUrl:n})},t.appendChild(r)},A.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?l("Zonos style links already injected","warn"):(T.injectStylesheet({cdnType:v,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),l("Zonos style css injected!"))},A.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void l("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 l("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),l("Zonos font injected!")},A.setupGoogleFont=e=>{var n;null===(n=T.zonosController)||void 0===n||n.setupGoogleFont(e)},A.injectSupportGoogleFont=e=>{var n;l(`[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 l(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,t.appendChild(s),l(`[FONT] ${o} font injected!`)};const C=["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"],E=["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"],P=[...C,...E];export{A as Zonos,P as checkoutSessionAttributeKeys,E as checkoutSessionImmutableAttributeKeys,C as checkoutSessionMutableAttributeKeys}
|