@zonos/elements 1.3.45 → 1.3.47
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-89b4f62d.js → cart-85870c2e.js} +187 -62
- package/dist/cjs/{sendErrorLog-a966a8c1.js → createCustomEvent-aacc2833.js} +2 -22
- package/dist/cjs/index.cjs.js +13 -8
- package/dist/cjs/{paypal-1a1882c4.js → paypal-e4428dbf.js} +3 -3
- package/dist/cjs/zonos-address_8.cjs.entry.js +1 -1
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +25 -19
- package/dist/cjs/zonos-checkout.cjs.entry.js +10 -10
- package/dist/cjs/zonos-controller.cjs.entry.js +6 -6
- package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +1 -1
- package/dist/cjs/zonos-hello.cjs.entry.js +2 -3
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
- package/dist/cjs/zonos-notification_3.cjs.entry.js +2 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +14 -8
- package/dist/collection/components/main/zonos-controller.js +4 -3
- package/dist/collection/components/store/checkout/stripe.js +4 -7
- package/dist/collection/components/store/hello/localization.js +1 -1
- package/dist/collection/components/utils/api/calculateLandedCost.js +1 -2
- package/dist/collection/components/utils/api/checkItemRestrictions.js +1 -2
- package/dist/collection/components/utils/api/getCountries.js +1 -1
- package/dist/collection/components/utils/api/getCountryLandedCost.js +1 -1
- package/dist/collection/components/utils/api/getExchangeRate.js +6 -2
- package/dist/collection/components/utils/api/getInclusivePricing.js +1 -2
- package/dist/collection/components/utils/api/getLocaleMessages.js +7 -2
- package/dist/collection/components/utils/api/getLocalization.js +3 -6
- package/dist/collection/components/utils/api/getShippingZones.js +1 -2
- package/dist/collection/components/utils/api/getZonosSettings.js +1 -2
- package/dist/collection/components/utils/api/paypalCaptureOrder.js +1 -1
- package/dist/collection/components/utils/api/paypalCreateOrder.js +1 -1
- package/dist/collection/components/utils/api/trackConversionEvent.js +1 -2
- package/dist/collection/components/utils/api/triggerBuildLandedCost.js +3 -2
- package/dist/collection/components/utils/getNextFallbackApi.js +18 -0
- package/dist/collection/components/utils/handleFetch.js +84 -20
- package/dist/collection/components/utils/logging/sendErrorLog.js +33 -6
- package/dist/collection/components/utils/logging/sendLoadScriptLog.js +1 -1
- package/dist/collection/environment.js +15 -78
- package/dist/collection/scripts/_getZonosQaUrl.js +6 -2
- package/dist/collection/scripts/_zonosBase.js +1 -0
- package/dist/collection/utils/formattedCloudflareApiUrl.js +43 -0
- package/dist/collection/utils/formattedUrl.js +80 -0
- package/dist/collection/utils/generateCloudflareDeployUrl.js +21 -0
- package/dist/esm/{cart-9f40efd7.js → cart-3aae6236.js} +188 -64
- package/dist/esm/{sendErrorLog-aea606c0.js → createCustomEvent-ccb20b48.js} +3 -22
- package/dist/esm/index.js +13 -8
- package/dist/esm/{paypal-f4bb6ce7.js → paypal-b1589e7b.js} +3 -3
- package/dist/esm/zonos-address_8.entry.js +1 -1
- package/dist/esm/zonos-cart-items_12.entry.js +17 -11
- package/dist/esm/zonos-checkout.entry.js +3 -3
- package/dist/esm/zonos-controller.entry.js +6 -6
- package/dist/esm/zonos-country-flag.entry.js +1 -1
- package/dist/esm/zonos-country-select_4.entry.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm/zonos-hello.entry.js +2 -3
- package/dist/esm/zonos-language-select_2.entry.js +1 -1
- package/dist/esm/zonos-notification_3.entry.js +2 -2
- package/dist/esm-es5/{cart-9f40efd7.js → cart-3aae6236.js} +1 -1
- package/dist/esm-es5/createCustomEvent-ccb20b48.js +1 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/paypal-b1589e7b.js +17 -0
- package/dist/esm-es5/zonos-address_8.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-notification_3.entry.js +1 -1
- package/dist/scripts/index.d.ts +11 -0
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/utils/getNextFallbackApi.d.ts +10 -0
- package/dist/types/components/utils/handleFetch.d.ts +10 -1
- package/dist/types/components/utils/logging/sendErrorLog.d.ts +7 -1
- package/dist/types/environment.d.ts +8 -9
- package/dist/types/scripts/_getNextFallbackUrl.d.ts +1 -1
- package/dist/types/scripts/_zonosBase.d.ts +5 -0
- package/dist/types/utils/formattedCloudflareApiUrl.d.ts +20 -0
- package/dist/types/utils/formattedUrl.d.ts +9 -0
- package/dist/types/utils/generateCloudflareDeployUrl.d.ts +10 -0
- package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-7b8099ed.js → p-08a43211.js} +1 -1
- package/dist/zonos-elements/p-1738fe3f.entry.js +1 -0
- package/dist/zonos-elements/p-284520ae.js +17 -0
- package/dist/zonos-elements/{p-578f42c1.entry.js → p-3225705b.entry.js} +1 -1
- package/dist/zonos-elements/{p-8630168f.system.entry.js → p-3403a81a.system.entry.js} +1 -1
- package/dist/zonos-elements/p-3fb9e320.system.js +17 -0
- package/dist/zonos-elements/{p-acf9a97e.system.entry.js → p-3fd66f5b.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8bf1af28.entry.js → p-57c67bbf.entry.js} +1 -1
- package/dist/zonos-elements/{p-4204ccf9.system.entry.js → p-6d613cee.system.entry.js} +1 -1
- package/dist/zonos-elements/p-7d0663ab.system.entry.js +1 -0
- package/dist/zonos-elements/{p-7bd28076.system.entry.js → p-8949d4a2.system.entry.js} +1 -1
- package/dist/zonos-elements/p-8b02985f.entry.js +1 -0
- package/dist/zonos-elements/p-90935326.system.entry.js +1 -0
- package/dist/zonos-elements/{p-c7952400.entry.js → p-9c9e8288.entry.js} +1 -1
- package/dist/zonos-elements/{p-43d3cafd.system.js → p-a576cbb8.system.js} +1 -1
- package/dist/zonos-elements/p-aa0127b3.system.js +1 -0
- package/dist/zonos-elements/{p-d014791e.entry.js → p-b9815df4.entry.js} +1 -1
- package/dist/zonos-elements/{p-ca0a5c22.system.entry.js → p-c035c64f.system.entry.js} +1 -1
- package/dist/zonos-elements/p-c3ca9e48.system.entry.js +1 -0
- package/dist/zonos-elements/p-c78dd680.system.js +1 -1
- package/dist/zonos-elements/{p-5845029a.system.entry.js → p-d5741e4e.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8618e185.entry.js → p-d5b21512.entry.js} +1 -1
- package/dist/zonos-elements/{p-37c9fdd2.system.entry.js → p-e4033aa7.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-567b457b.entry.js → p-ea58a4a6.entry.js} +1 -1
- package/dist/zonos-elements/{p-f9754e48.entry.js → p-ed496e98.entry.js} +1 -1
- package/dist/zonos-elements/p-eefeab02.js +1 -0
- package/dist/zonos-elements/p-f25559fd.entry.js +1 -0
- package/dist/zonos-elements/p-f9b50965.system.js +1 -0
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/paypal-f4bb6ce7.js +0 -17
- package/dist/esm-es5/sendErrorLog-aea606c0.js +0 -1
- package/dist/zonos-elements/p-0bfe455c.system.entry.js +0 -1
- package/dist/zonos-elements/p-13618b27.system.entry.js +0 -1
- package/dist/zonos-elements/p-29f4cce5.system.js +0 -17
- package/dist/zonos-elements/p-2d01b8e6.system.entry.js +0 -1
- package/dist/zonos-elements/p-3490d40f.js +0 -17
- package/dist/zonos-elements/p-5b9f2535.system.js +0 -1
- package/dist/zonos-elements/p-6f759c76.system.js +0 -1
- package/dist/zonos-elements/p-757166b8.entry.js +0 -1
- package/dist/zonos-elements/p-76291114.entry.js +0 -1
- package/dist/zonos-elements/p-9aef3a35.entry.js +0 -1
- package/dist/zonos-elements/p-d99e58f2.js +0 -1
package/dist/scripts/zonos.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const e=(e,t,...n)=>{var o,r;if(!(!!(null===(o=window.Zonos)||void 0===o?void 0:o.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===t&&console.error(e,...n));let s=document.querySelector("iframe#zonos---debug-logging-iframe");s||(s=document.createElement("iframe"),s.id="zonos---debug-logging-iframe",s.style.display="none",s.style.opacity="0",s.style.position="absolute",s.style.top="-9999px",s.style.left="-9999px",s.style.width="1px",s.style.height="1px",s.style.border="none",s.style.overflow="hidden",s.style.visibility="hidden",document.body.appendChild(s));const i=(null===(r=s.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(t){case"warn":i.warn(e,...n);break;case"info":i.info(e,...n);break;case"error":i.error(e,...n);break;default:i.groupCollapsed(e,...n),i.trace(),i.groupEnd()}},t=(t,...n)=>{e(t,"error",...n)},n=["jsdelivr","cdnjs","unpkg","vercel"],o=e=>{const t=n.indexOf(e);return n[t+1]||null},r=()=>{const t=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||t)return null;const n=(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.45.js.zonos.com";if(!n&&o.includes("test."))return o;if(!n&&"dev.demo.elements.zonos.com"===window.location.hostname)return"https://dev.elements.zonos.com";if(!n)return null;if("dev-elements"===n)return"https://dev.elements.zonos.com";const r=`https://${n}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${r}' for loading script`,"warn"),fetch(r).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${r}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:t}=window.location,n=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null})),r},s="https://js.stripe.com/v3",i=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,l="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let c=null;const d=e=>(null!==c||(c=new Promise(((n,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(l),window.Stripe)n(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${s}"]`);for(let t=0;t<e.length;t++){const n=e[t];if(n&&i.test(n.src))return n}return null})();r&&e?console.warn(l):r||(r=(e=>{const n=document.createElement("script");n.src=`${s}`;const o=document.head||document.body;return o?(o.appendChild(n),n):(t("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):o(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else n(null)}))),c),a=Promise.resolve().then((()=>d(null)));let u=!1;a.catch((e=>{u||console.warn(e)}));var p;const m=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:t,isWhiteListed:n}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const t=new URL(e).origin,n=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>t.includes(e))),o=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:o,isWhiteListed:n}})({loadScriptSrc:null==e?void 0:e.src});return n?t:null})(),h="https://v1.3.45.js.zonos.com",y=m||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.45",w="jsdelivr",f="https://rsms.me",v="https://fonts.googleapis.com",g=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class S{}p=S,S.doneInit=!1,S.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),S.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),S._paypalMockResponse=null,S.isBigCommerce=!1,S.isNpm=!0,S.zonosQaUrl=null,S.version="v1.3.45",S.modeAlerted=!1,S.tempCartData=null,S.paypal=null,S.getCurrentTimestamp=()=>(new Date).getTime(),S.zonosController=null,S.init=async({appearance:n,checkoutSettings:o,currencyConverter:r,helloSettings:s,onCountryChange:i,overrideCurrencyFormat:l,storeId:c,zonosApiKey:d})=>{p.doneInit||(e(`====== ZONOS DEBUG MODE: on (${p.version}) ======`),d?(p.zonosApiKey=d,p.storeId=c,e("init zonos"),p.injectZonosCdn(),p.injectZonosCss(),p.injectFonts(),p.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:r,helloSettings:s,onCountryChange:i,overrideCurrencyFormat:l},zonosApiKey:d}),p.doneInit=!0):t("Missing Zonos API key"))},S.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},S.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},S.showNotification=e=>{var t;null===(t=p.zonosController)||void 0===t||t.showNotification(e)},S.updateOrganizationName=e=>{var t;null===(t=p.zonosController)||void 0===t||t.updateOrganizationName(e)},S.disablePlaceOrderButtons=({autoEnable:e=!0,config:t,disable:n,placeOrderButtonSelector:o})=>{var r;if(!(null===(r=t.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&o){const t=document.querySelectorAll(o),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};t.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(n?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&n&&setTimeout((()=>{t.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},S.injectController=({config:n,zonosApiKey:o})=>{var r;if(document.querySelector("zonos-controller"))return;if(null===(r=n.checkoutSettings)||void 0===r?void 0:r.placeOrderButtonSelector){const e=n.checkoutSettings.placeOrderButtonSelector;p.disablePlaceOrderButtons({config:n,disable:!0,placeOrderButtonSelector:e});new MutationObserver((()=>{p.disablePlaceOrderButtons({config:n,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=n,s.zonosApiKey=o,s.addEventListener("stripeInitEvent",(async n=>{const{detail:o}=n;e("loading Stripe");const r=await(async(...e)=>{u=!0;const t=Date.now();return a.then((n=>((e,t,n)=>{if(null===e)return null;const o=e.apply(void 0,t);return((e,t)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:t})})(o,n),o})(n,e,t)))})(o.publishableKey);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):t("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),p.zonosController=s,e("Zonos controller injected!")},S.injectScript=({cdnType:n,isModule:r,theRestUrl:s})=>{const i=`${p.getZonosUrl(n)}/${s}`;if(document.querySelector(`script[src="${i}"]`))return void e(`Zonos script "${i}" already exists in the document`,"warn");const l=document.head||document.body,c=document.createElement("script");r?c.type="module":c.noModule=!0,c.src=i,c.crossOrigin="anonymous",c.onerror=()=>{t(`Failed to load ${c.src}`);const e=o(n);e&&p.injectScript({cdnType:e,isModule:r,theRestUrl:s})},l.appendChild(c)},S.getZonosUrl=e=>{const t=()=>{switch(e){case"jsdelivr":return y;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.45";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.45";case"vercel":return h}};if(p.isNpm){return r()||t()}return t()},S.injectZonosCdn=()=>{p.injectScript({cdnType:w,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),p.injectScript({cdnType:w,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},S.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const r=p.getZonosUrl(e),s=document.head||document.body,i=document.createElement("link");i.rel="preconnect",i.href=`${h}/`,s.appendChild(i);const l=document.createElement("link");l.rel="stylesheet",l.href=`${r}/${n}`,l.onerror=()=>{t(`Failed to load ${l.href}`);const r=o(e);r&&p.injectStylesheet({cdnType:r,theRestUrl:n})},s.appendChild(l)},S.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(p.injectStylesheet({cdnType:w,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},S.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${f}"]`);for(let t=0;t<e.length;t++){const n=e[t];if(n&&!g.test(n.href))return n}return null})())return void e("Inter font already injected","warn");const t=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=f,t.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${f}/inter/inter.css`,t.appendChild(o),e("Zonos font injected!")},S.setupGoogleFont=e=>{var t;null===(t=p.zonosController)||void 0===t||t.setupGoogleFont(e)},S.injectSupportGoogleFont=t=>{var n;e(`[FONT] injecting ${t}`);const o=null===(n=t.match(/family=(.*?):/))||void 0===n?void 0:n[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${v}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=v,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${t}"]`))return void e(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=t,r.appendChild(s),e(`[FONT] ${o} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=S)})();
|
|
1
|
+
(function(){"use strict";const e=(e,t,...n)=>{var o,r;if(!(!!(null===(o=window.Zonos)||void 0===o?void 0:o.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===t&&console.error(e,...n));let s=document.querySelector("iframe#zonos---debug-logging-iframe");s||(s=document.createElement("iframe"),s.id="zonos---debug-logging-iframe",s.style.display="none",s.style.opacity="0",s.style.position="absolute",s.style.top="-9999px",s.style.left="-9999px",s.style.width="1px",s.style.height="1px",s.style.border="none",s.style.overflow="hidden",s.style.visibility="hidden",document.body.appendChild(s));const i=(null===(r=s.contentWindow)||void 0===r?void 0:r.window.console)||window.console;switch(t){case"warn":i.warn(e,...n);break;case"info":i.info(e,...n);break;case"error":i.error(e,...n);break;default:i.groupCollapsed(e,...n),i.trace(),i.groupEnd()}},t=(t,...n)=>{e(t,"error",...n)},n=["jsdelivr","cdnjs","unpkg","vercel"],o=e=>{const t=n.indexOf(e);return n[t+1]||null},r=()=>{const t=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||t)return null;const n=(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.47.js.zonos.com";if(!n&&(o.includes("test.")||o.includes("test-")))return o;if(!n&&["dev.demo.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 r=`https://${n}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${r}' for loading script`,"warn"),fetch(r).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${r}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:t}=window.location,n=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null})),r},s="https://js.stripe.com/v3",i=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,l="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let c=null;const d=e=>(null!==c||(c=new Promise(((n,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(l),window.Stripe)n(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${s}"]`);for(let t=0;t<e.length;t++){const n=e[t];if(n&&i.test(n.src))return n}return null})();r&&e?console.warn(l):r||(r=(e=>{const n=document.createElement("script");n.src=`${s}`;const o=document.head||document.body;return o?(o.appendChild(n),n):(t("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?n(window.Stripe):o(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else n(null)}))),c),a=Promise.resolve().then((()=>d(null)));let u=!1;a.catch((e=>{u||console.warn(e)}));var p;const m=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:t,isWhiteListed:n}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const t=new URL(e).origin,n=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>t.includes(e))),o=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:o,isWhiteListed:n}})({loadScriptSrc:null==e?void 0:e.src});return n?t:null})(),h="https://v1.3.47.js.zonos.com",y=m||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.47",w="jsdelivr",f="https://rsms.me",v="https://fonts.googleapis.com",g=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class S{}p=S,S.doneInit=!1,S.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),S.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),S._paypalMockResponse=null,S.isBigCommerce=!1,S.releaseDate="1726091079993",S.isNpm=!0,S.zonosQaUrl=null,S.version="v1.3.47",S.modeAlerted=!1,S.tempCartData=null,S.paypal=null,S.getCurrentTimestamp=()=>(new Date).getTime(),S.zonosController=null,S.init=async({appearance:n,checkoutSettings:o,currencyConverter:r,helloSettings:s,onCountryChange:i,overrideCurrencyFormat:l,storeId:c,zonosApiKey:d})=>{p.doneInit||(e(`====== ZONOS DEBUG MODE: on (${p.version}) ======`),d?(p.zonosApiKey=d,p.storeId=c,e("init zonos"),p.injectZonosCdn(),p.injectZonosCss(),p.injectFonts(),p.injectController({config:{appearance:n,checkoutSettings:o,currencyConverter:r,helloSettings:s,onCountryChange:i,overrideCurrencyFormat:l},zonosApiKey:d}),p.doneInit=!0):t("Missing Zonos API key"))},S.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},S.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},S.showNotification=e=>{var t;null===(t=p.zonosController)||void 0===t||t.showNotification(e)},S.updateOrganizationName=e=>{var t;null===(t=p.zonosController)||void 0===t||t.updateOrganizationName(e)},S.disablePlaceOrderButtons=({autoEnable:e=!0,config:t,disable:n,placeOrderButtonSelector:o})=>{var r;if(!(null===(r=t.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&o){const t=document.querySelectorAll(o),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};t.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(n?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&n&&setTimeout((()=>{t.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},S.injectController=({config:n,zonosApiKey:o})=>{var r;if(document.querySelector("zonos-controller"))return;if(null===(r=n.checkoutSettings)||void 0===r?void 0:r.placeOrderButtonSelector){const e=n.checkoutSettings.placeOrderButtonSelector;p.disablePlaceOrderButtons({config:n,disable:!0,placeOrderButtonSelector:e});new MutationObserver((()=>{p.disablePlaceOrderButtons({config:n,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=n,s.zonosApiKey=o,s.addEventListener("stripeInitEvent",(async n=>{const{detail:o}=n;e("loading Stripe");const r=await(async(...e)=>{u=!0;const t=Date.now();return a.then((n=>((e,t,n)=>{if(null===e)return null;const o=e.apply(void 0,t);return((e,t)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:t})})(o,n),o})(n,e,t)))})(o.publishableKey);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):t("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),p.zonosController=s,e("Zonos controller injected!")},S.injectScript=({cdnType:n,isModule:r,theRestUrl:s})=>{const i=`${p.getZonosUrl(n)}/${s}`;if(document.querySelector(`script[src="${i}"]`))return void e(`Zonos script "${i}" already exists in the document`,"warn");const l=document.head||document.body,c=document.createElement("script");r?c.type="module":c.noModule=!0,c.src=i,c.crossOrigin="anonymous",c.onerror=()=>{t(`Failed to load ${c.src}`);const e=o(n);e&&p.injectScript({cdnType:e,isModule:r,theRestUrl:s})},l.appendChild(c)},S.getZonosUrl=e=>{const t=()=>{switch(e){case"jsdelivr":return y;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.47";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.47";case"vercel":return h}};if(p.isNpm){return r()||t()}return t()},S.injectZonosCdn=()=>{p.injectScript({cdnType:w,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),p.injectScript({cdnType:w,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},S.injectStylesheet=({cdnType:e,theRestUrl:n})=>{const r=p.getZonosUrl(e),s=document.head||document.body,i=document.createElement("link");i.rel="preconnect",i.href=`${h}/`,s.appendChild(i);const l=document.createElement("link");l.rel="stylesheet",l.href=`${r}/${n}`,l.onerror=()=>{t(`Failed to load ${l.href}`);const r=o(e);r&&p.injectStylesheet({cdnType:r,theRestUrl:n})},s.appendChild(l)},S.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(p.injectStylesheet({cdnType:w,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},S.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${f}"]`);for(let t=0;t<e.length;t++){const n=e[t];if(n&&!g.test(n.href))return n}return null})())return void e("Inter font already injected","warn");const t=document.head||document.body,n=document.createElement("link");n.rel="preconnect",n.href=f,t.appendChild(n);const o=document.createElement("link");o.rel="stylesheet",o.href=`${f}/inter/inter.css`,t.appendChild(o),e("Zonos font injected!")},S.setupGoogleFont=e=>{var t;null===(t=p.zonosController)||void 0===t||t.setupGoogleFont(e)},S.injectSupportGoogleFont=t=>{var n;e(`[FONT] injecting ${t}`);const o=null===(n=t.match(/family=(.*?):/))||void 0===n?void 0:n[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${v}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=v,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${t}"]`))return void e(`[FONT] ${o} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=t,r.appendChild(s),e(`[FONT] ${o} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=S)})();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const fallbackApiType: readonly ["vercel", "cloudflare"];
|
|
2
|
+
export declare const MAIN_BASE_API_TYPE: "vercel";
|
|
3
|
+
export type FallBackApiType = (typeof fallbackApiType)[number];
|
|
4
|
+
export declare const fallbackApiList: Record<FallBackApiType, string>;
|
|
5
|
+
export declare const MAIN_BASE_API: string;
|
|
6
|
+
/**
|
|
7
|
+
* Next available fallback api type
|
|
8
|
+
*/
|
|
9
|
+
export declare const getNextFallbackApiType: (currentApiType?: FallBackApiType) => "vercel" | "cloudflare" | null;
|
|
10
|
+
export {};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { JsonError } from "../../types/JsonError";
|
|
2
2
|
import type { NoInfer } from "../../types/NoInfer";
|
|
3
3
|
export type HandleFetchReturn<ResponseBody extends unknown> = {
|
|
4
|
+
/**
|
|
5
|
+
* The base url of the request. Example: https://v1.route.zonos.com
|
|
6
|
+
*/
|
|
7
|
+
baseUrl: string;
|
|
4
8
|
errors: JsonError[];
|
|
5
9
|
json: NoInfer<ResponseBody> | null;
|
|
6
10
|
response: Response | null;
|
|
@@ -17,4 +21,9 @@ export type RequestOptions<ResponseBody, RequestBody> = {
|
|
|
17
21
|
body?: NoInfer<RequestBody>;
|
|
18
22
|
testExpectedData?: (data: ResponseBody) => boolean;
|
|
19
23
|
} & Omit<RequestInit, 'body'>;
|
|
20
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Fetch request and will request to fallback API when the first one fails
|
|
26
|
+
* @param path Path name of the request (e.g. /api/something/com).
|
|
27
|
+
* @param _opts fetch options
|
|
28
|
+
*/
|
|
29
|
+
export declare const handleFetch: <ResponseBody extends unknown, RequestBody = unknown>(path: string, _opts?: RequestOptions<ResponseBody, RequestBody>) => Promise<HandleFetchReturn<ResponseBody>>;
|
|
@@ -2,6 +2,12 @@ type Params = {
|
|
|
2
2
|
endpoint: string;
|
|
3
3
|
errors: string[];
|
|
4
4
|
metadata: Record<string, unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* Should only report errors that happened if current time is less than 2 hours after release time.
|
|
7
|
+
* @note If this is not set, we will always report the error
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
shouldPostReleaseErrorReporting?: boolean;
|
|
5
11
|
};
|
|
6
|
-
export declare const sendErrorLog: ({ endpoint, errors, metadata }: Params) => Promise<void>;
|
|
12
|
+
export declare const sendErrorLog: ({ endpoint, errors, metadata, shouldPostReleaseErrorReporting, }: Params) => Promise<void>;
|
|
7
13
|
export {};
|
|
@@ -6,38 +6,35 @@ export declare const inStorybook: boolean;
|
|
|
6
6
|
export declare const inVercel: boolean;
|
|
7
7
|
export declare const inCI: boolean;
|
|
8
8
|
export declare const isVercelProd: boolean;
|
|
9
|
-
export declare const formattedUrl: ({ branchName, inCI: _inCI, inVercel: _inVercel, isVercelPreview: _isVercelPreview, packageVersion: _packageVersion, type, url, }: {
|
|
10
|
-
branchName?: string;
|
|
11
|
-
inCI: boolean;
|
|
12
|
-
inVercel: boolean;
|
|
13
|
-
isVercelPreview: boolean;
|
|
14
|
-
packageVersion: string;
|
|
15
|
-
type: 'major' | 'full' | 'vercel-git';
|
|
16
|
-
url?: string;
|
|
17
|
-
}) => string | undefined;
|
|
18
9
|
declare const envClientSchema: z.ZodObject<{
|
|
19
10
|
NEXT_PUBLIC_FLAG_URL: z.ZodString;
|
|
11
|
+
NEXT_PUBLIC_RELEASE_DATE: z.ZodString;
|
|
20
12
|
NEXT_PUBLIC_ZONOS_API_KEY: z.ZodString;
|
|
21
13
|
NEXT_PUBLIC_ZONOS_CDNJS_CDN_URL: z.ZodString;
|
|
22
14
|
NEXT_PUBLIC_ZONOS_CDN_URL: z.ZodString;
|
|
15
|
+
NEXT_PUBLIC_ZONOS_CLOUDFLARE_URL: z.ZodString;
|
|
23
16
|
NEXT_PUBLIC_ZONOS_JS_DELIVR_CDN_URL: z.ZodString;
|
|
24
17
|
NEXT_PUBLIC_ZONOS_PACKAGE_VERSION: z.ZodString;
|
|
25
18
|
NEXT_PUBLIC_ZONOS_ROUTE_URL: z.ZodString;
|
|
26
19
|
NEXT_PUBLIC_ZONOS_UNPKG_CDN_URL: z.ZodString;
|
|
27
20
|
}, "strip", z.ZodTypeAny, {
|
|
28
21
|
NEXT_PUBLIC_FLAG_URL: string;
|
|
22
|
+
NEXT_PUBLIC_RELEASE_DATE: string;
|
|
29
23
|
NEXT_PUBLIC_ZONOS_API_KEY: string;
|
|
30
24
|
NEXT_PUBLIC_ZONOS_CDNJS_CDN_URL: string;
|
|
31
25
|
NEXT_PUBLIC_ZONOS_CDN_URL: string;
|
|
26
|
+
NEXT_PUBLIC_ZONOS_CLOUDFLARE_URL: string;
|
|
32
27
|
NEXT_PUBLIC_ZONOS_JS_DELIVR_CDN_URL: string;
|
|
33
28
|
NEXT_PUBLIC_ZONOS_PACKAGE_VERSION: string;
|
|
34
29
|
NEXT_PUBLIC_ZONOS_ROUTE_URL: string;
|
|
35
30
|
NEXT_PUBLIC_ZONOS_UNPKG_CDN_URL: string;
|
|
36
31
|
}, {
|
|
37
32
|
NEXT_PUBLIC_FLAG_URL: string;
|
|
33
|
+
NEXT_PUBLIC_RELEASE_DATE: string;
|
|
38
34
|
NEXT_PUBLIC_ZONOS_API_KEY: string;
|
|
39
35
|
NEXT_PUBLIC_ZONOS_CDNJS_CDN_URL: string;
|
|
40
36
|
NEXT_PUBLIC_ZONOS_CDN_URL: string;
|
|
37
|
+
NEXT_PUBLIC_ZONOS_CLOUDFLARE_URL: string;
|
|
41
38
|
NEXT_PUBLIC_ZONOS_JS_DELIVR_CDN_URL: string;
|
|
42
39
|
NEXT_PUBLIC_ZONOS_PACKAGE_VERSION: string;
|
|
43
40
|
NEXT_PUBLIC_ZONOS_ROUTE_URL: string;
|
|
@@ -47,9 +44,11 @@ export interface Env extends z.infer<typeof envClientSchema> {
|
|
|
47
44
|
}
|
|
48
45
|
export declare const env: Readonly<{
|
|
49
46
|
NEXT_PUBLIC_FLAG_URL: string;
|
|
47
|
+
NEXT_PUBLIC_RELEASE_DATE: string;
|
|
50
48
|
NEXT_PUBLIC_ZONOS_API_KEY: string;
|
|
51
49
|
NEXT_PUBLIC_ZONOS_CDNJS_CDN_URL: string;
|
|
52
50
|
NEXT_PUBLIC_ZONOS_CDN_URL: string;
|
|
51
|
+
NEXT_PUBLIC_ZONOS_CLOUDFLARE_URL: string;
|
|
53
52
|
NEXT_PUBLIC_ZONOS_JS_DELIVR_CDN_URL: string;
|
|
54
53
|
NEXT_PUBLIC_ZONOS_PACKAGE_VERSION: string;
|
|
55
54
|
NEXT_PUBLIC_ZONOS_ROUTE_URL: string;
|
|
@@ -4,4 +4,4 @@ export type InjectScriptType = (typeof fallbackList)[number];
|
|
|
4
4
|
* Get the next cdn type in the fallback list
|
|
5
5
|
* @param currentCdnType The current cdn type that want to get the next fallback url
|
|
6
6
|
*/
|
|
7
|
-
export declare const getNextFallbackUrl: (currentCdnType: InjectScriptType) => "
|
|
7
|
+
export declare const getNextFallbackUrl: (currentCdnType: InjectScriptType) => "vercel" | "jsdelivr" | "cdnjs" | "unpkg";
|
|
@@ -121,6 +121,10 @@ export interface Zonos {
|
|
|
121
121
|
/** Flag if already alerted when preview domain is defined and it's connecting production environment */
|
|
122
122
|
modeAlerted: boolean;
|
|
123
123
|
paypal: PayPalNamespace | null;
|
|
124
|
+
/**
|
|
125
|
+
* Version release timestamp
|
|
126
|
+
*/
|
|
127
|
+
releaseDate: string;
|
|
124
128
|
storeId: number;
|
|
125
129
|
/** Stripe instance */
|
|
126
130
|
stripe: Stripe;
|
|
@@ -150,6 +154,7 @@ export declare abstract class Zonos {
|
|
|
150
154
|
static zonosConversionTest: boolean;
|
|
151
155
|
static _paypalMockResponse: PaypalMockResponse | null;
|
|
152
156
|
static isBigCommerce: boolean;
|
|
157
|
+
static releaseDate: string;
|
|
153
158
|
/**
|
|
154
159
|
* By default, the package will load from npm
|
|
155
160
|
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is to generate cloudflare url based on the environment. This won't
|
|
3
|
+
* - Get the cloudflare alias to build if the environment is Preview
|
|
4
|
+
* - Get the cloudflare production url (not preview alias) if it's production
|
|
5
|
+
* @note
|
|
6
|
+
* This is mainly used for get correct Cloudflare API to be used in scripts
|
|
7
|
+
* @note
|
|
8
|
+
* "url" is the API url in Cloudflare
|
|
9
|
+
* @returns
|
|
10
|
+
* - `https://<branch_name>.<project_name>.pages.dev` if is Preview
|
|
11
|
+
* - `https://route.elements.zonos.com` if is Production
|
|
12
|
+
*/
|
|
13
|
+
export declare const formattedCloudflareApiUrl: ({ branchName, inCI: _inCI, inVercel: _inVercel, isVercelPreview: _isVercelPreview, projectName, url, }: {
|
|
14
|
+
branchName?: string;
|
|
15
|
+
inCI: boolean;
|
|
16
|
+
inVercel: boolean;
|
|
17
|
+
isVercelPreview: boolean;
|
|
18
|
+
projectName: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
}) => string | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const formattedUrl: ({ branchName, inCI: _inCI, inVercel: _inVercel, isVercelPreview: _isVercelPreview, packageVersion: _packageVersion, type, url, }: {
|
|
2
|
+
branchName?: string;
|
|
3
|
+
inCI: boolean;
|
|
4
|
+
inVercel: boolean;
|
|
5
|
+
isVercelPreview: boolean;
|
|
6
|
+
packageVersion: string;
|
|
7
|
+
type: 'major' | 'full' | 'vercel-git';
|
|
8
|
+
url?: string;
|
|
9
|
+
}) => string | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a Cloudflare deploy URL based on the branch name and project name
|
|
3
|
+
* @note not including https://
|
|
4
|
+
* @return {url} string
|
|
5
|
+
* @urlExample build-cloudflare-2.zonos-elements.page.dev
|
|
6
|
+
*/
|
|
7
|
+
export declare const generateCloudflareDeployUrl: ({ branchName, projectName, }: {
|
|
8
|
+
branchName: string;
|
|
9
|
+
projectName: string;
|
|
10
|
+
}) => string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg color="var(--zonos-elements-red-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-red-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
|
+
<svg color="var(--zonos-elements-red-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-red-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>g>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as e,a as n}from"./p-eaa335e1.js";const t=["jsdelivr","cdnjs","unpkg","vercel"],o=e=>{const n=t.indexOf(e);return t[n+1]||null},s="https://js.stripe.com/v3",r=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,i="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let l=null;const c=Promise.resolve().then((()=>{return e=null,null!==l||(l=new Promise(((t,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(i),window.Stripe)t(window.Stripe);else try{let l=(()=>{const e=document.querySelectorAll(`script[src^="${s}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&r.test(t.src))return t}return null})();l&&e?console.warn(i):l||(l=(e=>{const t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${s}${t}`;const r=document.head||document.body;return r?(r.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==l||l.addEventListener("load",(()=>{window.Stripe?t(window.Stripe):o(new Error("Stripe.js not available"))})),null==l||l.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else t(null)}))),l;var e}));let d=!1;var u;c.catch((e=>{d||console.warn(e)}));const a=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,t=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),o=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:o,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?n:null})(),m="https://v1.3.
|
|
1
|
+
import{l as e,a as n}from"./p-eaa335e1.js";const t=["jsdelivr","cdnjs","unpkg","vercel"],o=e=>{const n=t.indexOf(e);return t[n+1]||null},s="https://js.stripe.com/v3",r=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,i="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let l=null;const c=Promise.resolve().then((()=>{return e=null,null!==l||(l=new Promise(((t,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(i),window.Stripe)t(window.Stripe);else try{let l=(()=>{const e=document.querySelectorAll(`script[src^="${s}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&r.test(t.src))return t}return null})();l&&e?console.warn(i):l||(l=(e=>{const t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${s}${t}`;const r=document.head||document.body;return r?(r.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==l||l.addEventListener("load",(()=>{window.Stripe?t(window.Stripe):o(new Error("Stripe.js not available"))})),null==l||l.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else t(null)}))),l;var e}));let d=!1;var u;c.catch((e=>{d||console.warn(e)}));const a=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:n,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const n=new URL(e).origin,t=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>n.includes(e))),o=["qa.js.zonos.com"].some((e=>n.includes(e)));return{currentLoadScriptUrl:n,isForceLoadVersionDomain:o,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?n:null})(),m="https://v1.3.47.js.zonos.com",p=a||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.47",w="jsdelivr",f="https://rsms.me",h="https://fonts.googleapis.com",v=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class y{}u=y,y.doneInit=!1,y.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),y.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),y._paypalMockResponse=null,y.isBigCommerce=!1,y.releaseDate="1726091038924",y.isNpm=!0,y.zonosQaUrl=null,y.version="v1.3.47",y.modeAlerted=!1,y.tempCartData=null,y.paypal=null,y.getCurrentTimestamp=()=>(new Date).getTime(),y.zonosController=null,y.init=async({appearance:t,checkoutSettings:o,currencyConverter:s,helloSettings:r,onCountryChange:i,overrideCurrencyFormat:l,storeId:c,zonosApiKey:d})=>{u.doneInit||(e(`====== ZONOS DEBUG MODE: on (${u.version}) ======`),d?(u.zonosApiKey=d,u.storeId=c,e("init zonos"),u.injectZonosCdn(),u.injectZonosCss(),u.injectFonts(),u.injectController({config:{appearance:t,checkoutSettings:o,currencyConverter:s,helloSettings:r,onCountryChange:i,overrideCurrencyFormat:l},zonosApiKey:d}),u.doneInit=!0):n("Missing Zonos API key"))},y.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},y.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},y.showNotification=e=>{var n;null===(n=u.zonosController)||void 0===n||n.showNotification(e)},y.updateOrganizationName=e=>{var n;null===(n=u.zonosController)||void 0===n||n.updateOrganizationName(e)},y.disablePlaceOrderButtons=({autoEnable:e=!0,config:n,disable:t,placeOrderButtonSelector:o})=>{var s;if(!(null===(s=n.checkoutSettings)||void 0===s?void 0:s.disablePlaceOrderButtonActivation)&&o){const n=document.querySelectorAll(o),s=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",s)):(e.removeAttribute("disabled"),e.removeEventListener("click",s)))})),e&&t&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",s)}))}),5e3)}},y.injectController=({config:t,zonosApiKey:o})=>{var s;if(document.querySelector("zonos-controller"))return;if(null===(s=t.checkoutSettings)||void 0===s?void 0:s.placeOrderButtonSelector){const e=t.checkoutSettings.placeOrderButtonSelector;u.disablePlaceOrderButtons({config:t,disable:!0,placeOrderButtonSelector:e}),new MutationObserver((()=>{u.disablePlaceOrderButtons({config:t,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=t,r.zonosApiKey=o,r.addEventListener("stripeInitEvent",(async t=>{const{detail:o}=t;e("loading Stripe");const s=await(async(...e)=>{d=!0;const n=Date.now();return c.then((t=>((e,n,t)=>{if(null===e)return null;const o=e.apply(void 0,n);return((e,n)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:n})})(o,t),o})(t,e,n)))})(o.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),u.zonosController=r,e("Zonos controller injected!")},y.injectScript=({cdnType:t,isModule:s,theRestUrl:r})=>{const i=`${u.getZonosUrl(t)}/${r}`;if(document.querySelector(`script[src="${i}"]`))return void e(`Zonos script "${i}" already exists in the document`,"warn");const l=document.head||document.body,c=document.createElement("script");s?c.type="module":c.noModule=!0,c.src=i,c.crossOrigin="anonymous",c.onerror=()=>{n(`Failed to load ${c.src}`);const e=o(t);e&&u.injectScript({cdnType:e,isModule:s,theRestUrl:r})},l.appendChild(c)},y.getZonosUrl=n=>{const t=()=>{switch(n){case"jsdelivr":return p;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.47";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.47";case"vercel":return m}};return u.isNpm&&(()=>{const n=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||n)return null;const t=(e=>{if(!e)return null;const n=new URL(e).searchParams.get("zonosQaUrl");return n?/[^a-zA-Z0-9-_]+/.test(n)?null:n:null})(window.location.href),o="https://v1.3.47.js.zonos.com";if(!t&&(o.includes("test.")||o.includes("test-")))return o;if(!t&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!t)return null;if("dev-elements"===t)return"https://dev.elements.zonos.com";const s=`https://${t}.preview.js.zonos.com`;return e(`[ZONOS-WARNING] using '${s}' for loading script`,"warn"),fetch(s).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${s}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:n}=window.location,t=`${n}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),s})()||t()},y.injectZonosCdn=()=>{u.injectScript({cdnType:w,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),u.injectScript({cdnType:w,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},y.injectStylesheet=({cdnType:e,theRestUrl:t})=>{const s=u.getZonosUrl(e),r=document.head||document.body,i=document.createElement("link");i.rel="preconnect",i.href=`${m}/`,r.appendChild(i);const l=document.createElement("link");l.rel="stylesheet",l.href=`${s}/${t}`,l.onerror=()=>{n(`Failed to load ${l.href}`);const s=o(e);s&&u.injectStylesheet({cdnType:s,theRestUrl:t})},r.appendChild(l)},y.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(u.injectStylesheet({cdnType:w,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},y.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${f}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&!v.test(t.href))return t}return null})())return void e("Inter font already injected","warn");const n=document.head||document.body,t=document.createElement("link");t.rel="preconnect",t.href=f,n.appendChild(t);const o=document.createElement("link");o.rel="stylesheet",o.href=`${f}/inter/inter.css`,n.appendChild(o),e("Zonos font injected!")},y.setupGoogleFont=e=>{var n;null===(n=u.zonosController)||void 0===n||n.setupGoogleFont(e)},y.injectSupportGoogleFont=n=>{var t;e(`[FONT] injecting ${n}`);const o=null===(t=n.match(/family=(.*?):/))||void 0===t?void 0:t[1],s=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${h}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=h,s.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return void e(`[FONT] ${o} font already injected`,"warn");const r=document.createElement("link");r.rel="stylesheet",r.href=n,s.appendChild(r),e(`[FONT] ${o} font injected!`)};export{y as Zonos}
|