@zonos/elements 1.3.58 → 1.3.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/cjs/{cart-6c7bf457.js → cart-edf1ddc0.js} +12 -4
  2. package/dist/cjs/{createCustomEvent-a10ed604.js → createCustomEvent-512ed4a5.js} +1 -1
  3. package/dist/cjs/index.cjs.js +7 -7
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/{paypal-ec9ebaf5.js → paypal-570085f3.js} +1 -1
  6. package/dist/cjs/zonos-address_8.cjs.entry.js +1 -1
  7. package/dist/cjs/zonos-badge_13.cjs.entry.js +20 -8
  8. package/dist/cjs/zonos-checkout.cjs.entry.js +9 -3
  9. package/dist/cjs/zonos-controller.cjs.entry.js +1 -1
  10. package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
  11. package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
  12. package/dist/cjs/zonos-elements.cjs.js +1 -1
  13. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +1 -1
  14. package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
  15. package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
  16. package/dist/cjs/zonos-notification_3.cjs.entry.js +2 -2
  17. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +17 -5
  18. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +33 -1
  19. package/dist/collection/components/store/checkout/cart.js +10 -3
  20. package/dist/collection/components/store/checkout/stripe.js +3 -3
  21. package/dist/collection/types/generated/graphql.customer.types.js +11 -5
  22. package/dist/esm/{cart-a845a902.js → cart-70f3af44.js} +12 -5
  23. package/dist/esm/{createCustomEvent-0797e187.js → createCustomEvent-887a44ea.js} +1 -1
  24. package/dist/esm/index.js +7 -7
  25. package/dist/esm/loader.js +1 -1
  26. package/dist/esm/{paypal-6d80dfd9.js → paypal-86eba67d.js} +1 -1
  27. package/dist/esm/zonos-address_8.entry.js +1 -1
  28. package/dist/esm/zonos-badge_13.entry.js +20 -8
  29. package/dist/esm/zonos-checkout.entry.js +9 -3
  30. package/dist/esm/zonos-controller.entry.js +1 -1
  31. package/dist/esm/zonos-country-flag.entry.js +1 -1
  32. package/dist/esm/zonos-country-select_4.entry.js +1 -1
  33. package/dist/esm/zonos-elements.js +1 -1
  34. package/dist/esm/zonos-hello-dialog.entry.js +1 -1
  35. package/dist/esm/zonos-hello.entry.js +1 -1
  36. package/dist/esm/zonos-language-select_2.entry.js +1 -1
  37. package/dist/esm/zonos-notification_3.entry.js +2 -2
  38. package/dist/esm-es5/{cart-a845a902.js → cart-70f3af44.js} +1 -1
  39. package/dist/esm-es5/{createCustomEvent-0797e187.js → createCustomEvent-887a44ea.js} +1 -1
  40. package/dist/esm-es5/index.js +1 -1
  41. package/dist/esm-es5/loader.js +1 -1
  42. package/dist/esm-es5/{paypal-6d80dfd9.js → paypal-86eba67d.js} +1 -1
  43. package/dist/esm-es5/zonos-address_8.entry.js +1 -1
  44. package/dist/esm-es5/zonos-badge_13.entry.js +1 -1
  45. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  46. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  47. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  48. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  49. package/dist/esm-es5/zonos-elements.js +1 -1
  50. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  51. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  52. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  53. package/dist/esm-es5/zonos-notification_3.entry.js +1 -1
  54. package/dist/scripts/index.d.ts +53 -0
  55. package/dist/scripts/index.js +1 -1
  56. package/dist/scripts/loadZonos.js +1 -1
  57. package/dist/scripts/zonos.js +1 -1
  58. package/dist/types/components/checkout/zonos-checkout/zonos-checkout.d.ts +5 -0
  59. package/dist/types/components/store/checkout/cart.d.ts +4 -2
  60. package/dist/types/components.d.ts +6 -2
  61. package/dist/types/types/generated/graphql.customer.types.d.ts +62 -96
  62. package/dist/types/types/generated/graphql.customer.types.ts +62 -91
  63. package/dist/zonos-elements/index.esm.js +1 -1
  64. package/dist/zonos-elements/{p-d20f6cf1.js → p-02e2d953.js} +1 -1
  65. package/dist/zonos-elements/{p-298df70c.system.entry.js → p-09b19142.system.entry.js} +1 -1
  66. package/dist/zonos-elements/{p-2fc19941.system.js → p-0a8e0498.system.js} +1 -1
  67. package/dist/zonos-elements/{p-206cf031.system.js → p-0ac98033.system.js} +1 -1
  68. package/dist/zonos-elements/p-0b8e2e60.system.entry.js +1 -0
  69. package/dist/zonos-elements/p-20db26fd.entry.js +1 -0
  70. package/dist/zonos-elements/p-2fa0644e.entry.js +1 -0
  71. package/dist/zonos-elements/{p-4dd2f617.system.entry.js → p-4402dc5f.system.entry.js} +1 -1
  72. package/dist/zonos-elements/{p-921d3603.entry.js → p-5e32f30b.entry.js} +1 -1
  73. package/dist/zonos-elements/{p-8260b820.system.js → p-6ee0286a.system.js} +1 -1
  74. package/dist/zonos-elements/{p-17ea3429.system.entry.js → p-71c23712.system.entry.js} +1 -1
  75. package/dist/zonos-elements/{p-95a18511.entry.js → p-75ad3056.entry.js} +1 -1
  76. package/dist/zonos-elements/{p-4b205b2f.entry.js → p-77c2dd5c.entry.js} +1 -1
  77. package/dist/zonos-elements/{p-9fd3995f.js → p-7f0cea76.js} +1 -1
  78. package/dist/zonos-elements/{p-40f73fb4.system.entry.js → p-9c07322c.system.entry.js} +1 -1
  79. package/dist/zonos-elements/{p-324a8c0d.system.entry.js → p-a4d627b8.system.entry.js} +1 -1
  80. package/dist/zonos-elements/p-a75f5d63.js +1 -0
  81. package/dist/zonos-elements/p-b0d02c6d.entry.js +1 -0
  82. package/dist/zonos-elements/{p-556d4ddb.entry.js → p-c27e9d00.entry.js} +1 -1
  83. package/dist/zonos-elements/{p-b65b3e7b.system.entry.js → p-c328aa74.system.entry.js} +1 -1
  84. package/dist/zonos-elements/p-c78dd680.system.js +1 -1
  85. package/dist/zonos-elements/{p-d42018fc.entry.js → p-c95a8b8f.entry.js} +1 -1
  86. package/dist/zonos-elements/{p-3492c75f.system.entry.js → p-cb912299.system.entry.js} +1 -1
  87. package/dist/zonos-elements/p-cee1293a.system.entry.js +1 -0
  88. package/dist/zonos-elements/{p-d067bb64.system.js → p-d16e0d7a.system.js} +1 -1
  89. package/dist/zonos-elements/{p-35ca4dcc.entry.js → p-d740b7d1.entry.js} +1 -1
  90. package/dist/zonos-elements/{p-0954e8fe.system.entry.js → p-e7870ba2.system.entry.js} +1 -1
  91. package/dist/zonos-elements/{p-6f87b869.entry.js → p-f619cb3b.entry.js} +1 -1
  92. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  93. package/package.json +1 -1
  94. package/dist/zonos-elements/p-15599089.system.entry.js +0 -1
  95. package/dist/zonos-elements/p-173f8e5b.entry.js +0 -1
  96. package/dist/zonos-elements/p-35122d9c.system.entry.js +0 -1
  97. package/dist/zonos-elements/p-472a6c19.js +0 -1
  98. package/dist/zonos-elements/p-51d82a07.entry.js +0 -1
  99. package/dist/zonos-elements/p-c043ec95.entry.js +0 -1
@@ -1 +1 @@
1
- (function(){"use strict";const e=(e,t,...o)=>{var n,r;if(!(!!(null===(n=window.Zonos)||void 0===n?void 0:n.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===t&&console.error(e,...o));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,...o);break;case"info":i.info(e,...o);break;case"error":i.error(e,...o);break;default:i.groupCollapsed(e,...o),i.trace(),i.groupEnd()}},t=(t,...o)=>{e(t,"error",...o)},o=["jsdelivr","cdnjs","unpkg","vercel"],n="jsdelivr",r=e=>{const t=o.indexOf(e);return o[t+1]||null},s=()=>{const t=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||t)return null;const o=(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),n="https://v1.3.58.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const r=`https://${o}.preview.js.zonos.com`;return 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,o=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),r},i="https://js.stripe.com/v3",l=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,a="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(((o,n)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(a),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${i}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&l.test(o.src))return o}return null})();r&&e?console.warn(a):r||(r=(e=>{const o=document.createElement("script");o.src=`${i}`;const n=document.head||document.body;return n?(n.appendChild(o),o):(t("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):n(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{n(new Error("Failed to load Stripe.js"))}))}catch(e){return void n(e)}else o(null)}))),c),u=Promise.resolve().then((()=>d(null)));let p=!1;u.catch((e=>{p||console.warn(e)}));function m(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 h=["cloudflare","vercel"],y=h[0],w={cloudflare:"https://route.elements.zonos.com",vercel:"https://v1.route.js.zonos.com"},g=w[y],f=(e=y)=>{const t=h.indexOf(e),o=h[t+1];return o||null},v=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},b=async({response:e,shouldLog:t=!0,shouldThrow:o=!1})=>{try{return await e.json()}catch(e){if(o)throw e;return t&&console.error(e),null}},S=async({basePathType:e,options:t,path:o})=>{let n;const r=w[e]||y,s=new URL(r+o);s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(t){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(window.location.hostname));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 i=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&i&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await b({response:n}),response:n,zonosMode:i}}const a=n.status.toString();try{const e=await b({response:n,shouldThrow:!0});return{baseUrl:r,errors:[{message:JSON.stringify(e),type:a}],json:null,response:n,zonosMode:i}}catch(e){return{baseUrl:r,errors:[{message:`${a}: ${"Unknown error"}`,type:a}],json:null,response:null,zonosMode:i}}},z=async({basePathType:t,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":t,l=await S({basePathType:i,options:o,path:n}),{errors:a,response:c}=l,d=m(l,["errors","response"]),u=f(i),p=!!a.find((({type:e})=>"unknown"===e))||404===(null==c?void 0:c.status),h=u&&p;return p&&(async({endpoint:e,errors:t,metadata:o,shouldPostReleaseErrorReporting:n})=>{if(n){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const r="userAgentData"in window.navigator?window.navigator.userAgentData:null,s={endpoint:e,errors:t,metadata:Object.assign({href:window.location.href,userAgent:r&&r.brands.length>0?r:window.navigator.userAgent},o)};try{fetch(`${g}/api/zonos-elements/log-error`,{body:JSON.stringify(s),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const t=f();if(!t)return;fetch(`${w[t]}/api/zonos-elements/log-error`,{body:JSON.stringify(s),method:"POST"})}})({endpoint:w[i]+n,errors:a.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:u,requestHeaders:null==o?void 0:o.headers,requestPayload:v(null===(r=null==o?void 0:o.body)||void 0===r?void 0:r.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),h?(e(`=== "${n}" failed to fetch, trying next fallback ${u}`),z({basePathType:u,options:o,path:n})):Object.assign({errors:a,response:c},d)},j=async e=>{const{errors:t,json:o}=await(async(e,t)=>{const o=m(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-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},o.headers),i=Object.assign(Object.assign({},o),{body:"GET"===r?void 0:n,headers:s,method:r}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return z({basePathType:l||y,options:i,path:e})})("/api/zonos-elements/get-temp-cart",{body:{tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"});return!o||t.length?null:o};var O;const C=(()=>{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",".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})(),k="https://v1.3.58.js.zonos.com",E=C||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.58",A="https://rsms.me",Z="https://fonts.googleapis.com",U=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class T{}O=T,T.doneInit=!1,T.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),T.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),T._paypalMockResponse=null,T.isBigCommerce=!1,T.releaseDate="1727735671239",T.isLegacyCheckout=!1,T.isNpm=!0,T.zonosQaUrl=null,T.version="v1.3.58",T.modeAlerted=!1,T.cartData=null,T.paypal=null,T.getCurrentTimestamp=()=>(new Date).getTime(),T.zonosController=null,T.init=async({appearance:o,checkoutSettings:n,currencyConverter:r,helloSettings:s,onCountryChange:i,overrideCurrencyFormat:l,storeId:a,zonosApiKey:c})=>{if(O.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!O.doneInit){if(e(`====== ZONOS DEBUG MODE: on (${O.version}) ======`),O.zonosApiKey=c,O.storeId=a,O.isNpm){if(e("====== ZONOS LOADING FROM NPM ======"),!c&&!O.cartId)return void t("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!O.cartData&&O.cartId){e("Initialize cart data");const o=await(async o=>{const n=await j(o);return e("[ZONOS - loadZonos] getting temp cart data","info",n),n?{cartData:n.cartData,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}:(t("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(O.cartId);if(!o)return void t("Failed to get cart data");O.cartData=o.cartData,O.zonosApiKey=o.zonosApiKey}}if(O.cartId&&O.cartData){e("Cart data is available, inject hidden button and trigger checkout");const t=document.createElement("button");t.style.display="none",t.id="zonos--checkout-hidden-button",document.body.appendChild(t)}e("init zonos"),O.injectZonosCdn(),O.injectZonosCss(),O.injectFonts(),O.injectController({config:{appearance:o,checkoutSettings:n,currencyConverter:r,helloSettings:s,onCountryChange:i,overrideCurrencyFormat:l}}),O.doneInit=!0}},T.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},T.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},T.showNotification=e=>{var t;null===(t=O.zonosController)||void 0===t||t.showNotification(e)},T.updateOrganizationName=e=>{var t;null===(t=O.zonosController)||void 0===t||t.updateOrganizationName(e)},T.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)}},T.injectController=({config:o})=>{var n;if(document.querySelector("zonos-controller"))return;if(null===(n=o.checkoutSettings)||void 0===n?void 0:n.placeOrderButtonSelector){const e=o.checkoutSettings.placeOrderButtonSelector;O.disablePlaceOrderButtons({config:o,disable:!0,placeOrderButtonSelector:e});new MutationObserver((()=>{O.disablePlaceOrderButtons({config:o,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=o,r.zonosApiKey=O.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async o=>{const{detail:n}=o;e("loading Stripe");const s=await(async(...e)=>{p=!0;const t=Date.now();return u.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)))})(n.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):t("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),O.zonosController=r,e("Zonos controller injected!")},T.injectScript=({cdnType:o,isModule:n,theRestUrl:s})=>{const i=`${O.getZonosUrl(o)}/${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,a=document.createElement("script");n?a.type="module":a.noModule=!0,a.src=i,a.crossOrigin="anonymous",a.onerror=()=>{t(`Failed to load ${a.src}`);const e=r(o);e&&O.injectScript({cdnType:e,isModule:n,theRestUrl:s})},l.appendChild(a)},T.getZonosUrl=e=>{const t=()=>{switch(e){case"jsdelivr":return E;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.58";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.58";case"vercel":return k}};if(O.isNpm){return s()||t()}return t()},T.injectZonosCdn=()=>{O.injectScript({cdnType:n,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),O.injectScript({cdnType:n,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},T.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const n=O.getZonosUrl(e),s=document.head||document.body,i=document.createElement("link");i.rel="preconnect",i.href=`${k}/`,s.appendChild(i);const l=document.createElement("link");l.rel="stylesheet",l.href=`${n}/${o}`,l.onerror=()=>{t(`Failed to load ${l.href}`);const n=r(e);n&&O.injectStylesheet({cdnType:n,theRestUrl:o})},s.appendChild(l)},T.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(O.injectStylesheet({cdnType:n,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},T.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${A}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&!U.test(o.href))return o}return null})())return void e("Inter font already injected","warn");const t=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=A,t.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${A}/inter/inter.css`,t.appendChild(n),e("Zonos font injected!")},T.setupGoogleFont=e=>{var t;null===(t=O.zonosController)||void 0===t||t.setupGoogleFont(e)},T.injectSupportGoogleFont=t=>{var o;e(`[FONT] injecting ${t}`);const n=null===(o=t.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${Z}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=Z,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${t}"]`))return void e(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=t,r.appendChild(s),e(`[FONT] ${n} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=T)})();
1
+ (function(){"use strict";const e=(e,t,...o)=>{var n,r;if(!(!!(null===(n=window.Zonos)||void 0===n?void 0:n.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===t&&console.error(e,...o));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,...o);break;case"info":i.info(e,...o);break;case"error":i.error(e,...o);break;default:i.groupCollapsed(e,...o),i.trace(),i.groupEnd()}},t=(t,...o)=>{e(t,"error",...o)},o=["jsdelivr","cdnjs","unpkg","vercel"],n="jsdelivr",r=e=>{const t=o.indexOf(e);return o[t+1]||null},s=()=>{const t=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||t)return null;const o=(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),n="https://v1.3.59.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const r=`https://${o}.preview.js.zonos.com`;return 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,o=`${t}?${e.toString()}`;return window.history.replaceState(window.history.state,"",o),window.location.reload(),null})),r},i="https://js.stripe.com/v3",l=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,a="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(((o,n)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(a),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${i}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&l.test(o.src))return o}return null})();r&&e?console.warn(a):r||(r=(e=>{const o=document.createElement("script");o.src=`${i}`;const n=document.head||document.body;return n?(n.appendChild(o),o):(t("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):n(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{n(new Error("Failed to load Stripe.js"))}))}catch(e){return void n(e)}else o(null)}))),c),u=Promise.resolve().then((()=>d(null)));let p=!1;u.catch((e=>{p||console.warn(e)}));function m(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 h=["cloudflare","vercel"],y=h[0],w={cloudflare:"https://route.elements.zonos.com",vercel:"https://v1.route.js.zonos.com"},g=w[y],f=(e=y)=>{const t=h.indexOf(e),o=h[t+1];return o||null},v=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},b=async({response:e,shouldLog:t=!0,shouldThrow:o=!1})=>{try{return await e.json()}catch(e){if(o)throw e;return t&&console.error(e),null}},S=async({basePathType:e,options:t,path:o})=>{let n;const r=w[e]||y,s=new URL(r+o);s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(t){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(window.location.hostname));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 i=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&i&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await b({response:n}),response:n,zonosMode:i}}const a=n.status.toString();try{const e=await b({response:n,shouldThrow:!0});return{baseUrl:r,errors:[{message:JSON.stringify(e),type:a}],json:null,response:n,zonosMode:i}}catch(e){return{baseUrl:r,errors:[{message:`${a}: ${"Unknown error"}`,type:a}],json:null,response:null,zonosMode:i}}},z=async({basePathType:t,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":t,l=await S({basePathType:i,options:o,path:n}),{errors:a,response:c}=l,d=m(l,["errors","response"]),u=f(i),p=!!a.find((({type:e})=>"unknown"===e))||404===(null==c?void 0:c.status),h=u&&p;return p&&(async({endpoint:e,errors:t,metadata:o,shouldPostReleaseErrorReporting:n})=>{if(n){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const r="userAgentData"in window.navigator?window.navigator.userAgentData:null,s={endpoint:e,errors:t,metadata:Object.assign({href:window.location.href,userAgent:r&&r.brands.length>0?r:window.navigator.userAgent},o)};try{fetch(`${g}/api/zonos-elements/log-error`,{body:JSON.stringify(s),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const t=f();if(!t)return;fetch(`${w[t]}/api/zonos-elements/log-error`,{body:JSON.stringify(s),method:"POST"})}})({endpoint:w[i]+n,errors:a.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:u,requestHeaders:null==o?void 0:o.headers,requestPayload:v(null===(r=null==o?void 0:o.body)||void 0===r?void 0:r.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==c?void 0:c.status,statusText:null==c?void 0:c.statusText},shouldPostReleaseErrorReporting:!0}),h?(e(`=== "${n}" failed to fetch, trying next fallback ${u}`),z({basePathType:u,options:o,path:n})):Object.assign({errors:a,response:c},d)},j=async e=>{const{errors:t,json:o}=await(async(e,t)=>{const o=m(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-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},o.headers),i=Object.assign(Object.assign({},o),{body:"GET"===r?void 0:n,headers:s,method:r}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return z({basePathType:l||y,options:i,path:e})})("/api/zonos-elements/get-temp-cart",{body:{tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"});return!o||t.length?null:o};var O;const C=(()=>{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",".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})(),k="https://v1.3.59.js.zonos.com",E=C||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.59",A="https://rsms.me",Z="https://fonts.googleapis.com",U=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class T{}O=T,T.doneInit=!1,T.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),T.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),T._paypalMockResponse=null,T.isBigCommerce=!1,T.releaseDate="1727798297919",T.isLegacyCheckout=!1,T.isNpm=!0,T.zonosQaUrl=null,T.version="v1.3.59",T.modeAlerted=!1,T.cartData=null,T.paypal=null,T.getCurrentTimestamp=()=>(new Date).getTime(),T.zonosController=null,T.init=async({appearance:o,checkoutSettings:n,currencyConverter:r,helloSettings:s,onCountryChange:i,overrideCurrencyFormat:l,storeId:a,zonosApiKey:c})=>{if(O.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!O.doneInit){if(e(`====== ZONOS DEBUG MODE: on (${O.version}) ======`),O.zonosApiKey=c,O.storeId=a,O.isNpm){if(e("====== ZONOS LOADING FROM NPM ======"),!c&&!O.cartId)return void t("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!O.cartData&&O.cartId){e("Initialize cart data");const o=await(async o=>{const n=await j(o);return e("[ZONOS - loadZonos] getting temp cart data","info",n),n?{cartData:n.cartData,storeFavicon:n.storeFaviconUrl,storeId:n.cartData.storeId,storeLogo:n.storeLogoUrl,zonosApiKey:n.cartData.credentialToken}:(t("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)})(O.cartId);if(!o)return void t("Failed to get cart data");O.cartData=o.cartData,O.zonosApiKey=o.zonosApiKey}}if(O.cartId&&O.cartData){e("Cart data is available, inject hidden button and trigger checkout");const t=document.createElement("button");t.style.display="none",t.id="zonos--checkout-hidden-button",document.body.appendChild(t)}e("init zonos"),O.injectZonosCdn(),O.injectZonosCss(),O.injectFonts(),O.injectController({config:{appearance:o,checkoutSettings:n,currencyConverter:r,helloSettings:s,onCountryChange:i,overrideCurrencyFormat:l}}),O.doneInit=!0}},T.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},T.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},T.showNotification=e=>{var t;null===(t=O.zonosController)||void 0===t||t.showNotification(e)},T.updateOrganizationName=e=>{var t;null===(t=O.zonosController)||void 0===t||t.updateOrganizationName(e)},T.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)}},T.injectController=({config:o})=>{var n;if(document.querySelector("zonos-controller"))return;if(null===(n=o.checkoutSettings)||void 0===n?void 0:n.placeOrderButtonSelector){const e=o.checkoutSettings.placeOrderButtonSelector;O.disablePlaceOrderButtons({config:o,disable:!0,placeOrderButtonSelector:e});new MutationObserver((()=>{O.disablePlaceOrderButtons({config:o,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=o,r.zonosApiKey=O.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async o=>{const{detail:n}=o;e("loading Stripe");const s=await(async(...e)=>{p=!0;const t=Date.now();return u.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)))})(n.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):t("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),O.zonosController=r,e("Zonos controller injected!")},T.injectScript=({cdnType:o,isModule:n,theRestUrl:s})=>{const i=`${O.getZonosUrl(o)}/${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,a=document.createElement("script");n?a.type="module":a.noModule=!0,a.src=i,a.crossOrigin="anonymous",a.onerror=()=>{t(`Failed to load ${a.src}`);const e=r(o);e&&O.injectScript({cdnType:e,isModule:n,theRestUrl:s})},l.appendChild(a)},T.getZonosUrl=e=>{const t=()=>{switch(e){case"jsdelivr":return E;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.59";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.59";case"vercel":return k}};if(O.isNpm){return s()||t()}return t()},T.injectZonosCdn=()=>{O.injectScript({cdnType:n,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),O.injectScript({cdnType:n,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},T.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const n=O.getZonosUrl(e),s=document.head||document.body,i=document.createElement("link");i.rel="preconnect",i.href=`${k}/`,s.appendChild(i);const l=document.createElement("link");l.rel="stylesheet",l.href=`${n}/${o}`,l.onerror=()=>{t(`Failed to load ${l.href}`);const n=r(e);n&&O.injectStylesheet({cdnType:n,theRestUrl:o})},s.appendChild(l)},T.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(O.injectStylesheet({cdnType:n,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},T.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${A}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&!U.test(o.href))return o}return null})())return void e("Inter font already injected","warn");const t=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=A,t.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${A}/inter/inter.css`,t.appendChild(n),e("Zonos font injected!")},T.setupGoogleFont=e=>{var t;null===(t=O.zonosController)||void 0===t||t.setupGoogleFont(e)},T.injectSupportGoogleFont=t=>{var o;e(`[FONT] injecting ${t}`);const n=null===(o=t.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${Z}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=Z,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${t}"]`))return void e(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=t,r.appendChild(s),e(`[FONT] ${n} font injected!`)},window.Zonos&&window.Zonos.doneInit||(window.Zonos=T)})();
@@ -2,6 +2,7 @@ import type { PaymentIntent, Stripe } from '@stripe/stripe-js';
2
2
  import { type CartItem } from "../../store/checkout/cart";
3
3
  import { type StripeStoreContactOption } from "../../store/checkout/stripe";
4
4
  import { type AppearanceConfig } from "../../store/zonosStore";
5
+ import type { CheckoutSessionDetailsFragment } from "../../../types/generated/graphql.customer.types";
5
6
  export declare class ZonosCheckout {
6
7
  /**
7
8
  * Listener for locale change in localization store
@@ -88,6 +89,10 @@ export declare class ZonosCheckout {
88
89
  * For storybook to set to finish step, this is to trigger in the story for zonos-checkout-finish
89
90
  */
90
91
  setToFinishStep(forcePaymentStatus?: PaymentIntent['status']): Promise<void>;
92
+ /**
93
+ * For usage in storybook for a mocked flow.
94
+ */
95
+ mockCheckoutSession(session: CheckoutSessionDetailsFragment): Promise<void>;
91
96
  private handleCustomerInfoContinue;
92
97
  private handleShippingContinue;
93
98
  private handleInventoryCheckDialogCancel;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { stripeStoreUpdateCheckoutSession } from "./stripe";
3
- import type { CalculateLandedCostMutation, CartQuery, CheckoutPresentmentFragment, CurrencyCode, ItemMeasurementType, ItemType, ItemUnitOfMeasure, LandedCostFragment, ShipmentRatingFragment } from "../../../types/generated/graphql.customer.types";
3
+ import type { CalculateLandedCostMutation, CartQuery, CheckoutPresentmentFragment, CheckoutSessionDetailsFragment, CurrencyCode, ItemMeasurementType, ItemType, ItemUnitOfMeasure, LandedCostFragment, ShipmentRatingFragment } from "../../../types/generated/graphql.customer.types";
4
4
  type Step = 'customer-info' | 'shipping' | 'payment' | 'finish' | 'error';
5
5
  export type TabItem = {
6
6
  index: number;
@@ -57,6 +57,7 @@ type CartStore = {
57
57
  * Adjustments from cart
58
58
  */
59
59
  adjustments: CartAdjustment[];
60
+ checkoutSession: CheckoutSessionDetailsFragment | null;
60
61
  checkoutSessionId: string | null;
61
62
  /**
62
63
  * Checkout session timeout
@@ -159,6 +160,7 @@ type CartStoreRecalculateTotalParams = Omit<Parameters<typeof stripeStoreUpdateC
159
160
  * Detect if there are any items in cart that are not restricted and have positive amount, exclude negative amount items
160
161
  */
161
162
  declare const cartStoreHasOneEligibleItem: () => boolean;
163
+ declare const cartStoreSetCheckoutSession: (checkoutSession: CheckoutSessionDetailsFragment) => void;
162
164
  declare const cartStoreReCalculateTotal: ({ adjustmentAmount, cartId, currency, itemsAmount, landedCostId, }: CartStoreRecalculateTotalParams) => Promise<boolean>;
163
165
  declare const cartStoreUpdateSelectedShippingOption: (selectedShippingOption: ShipmentRatingFragment) => Promise<boolean>;
164
166
  declare const cartStoreStartCheckoutInterval: ({ isPreview, sessionTimeout, }: {
@@ -176,4 +178,4 @@ declare const cartStoreUpdateItems: ({ adjustments, cartItems, }: {
176
178
  }) => Promise<void>;
177
179
  declare const cartStoreNextStep: () => void;
178
180
  declare const cartStoreResetTabItems: () => void;
179
- export { cartStore, cartStoreApplySubtotals, cartStoreCheckItemRestrictions, cartStoreClearCheckoutInterval, cartStoreGetShippingTransitInfo, cartStoreHasOneEligibleItem, cartStoreNextStep, cartStoreReCalculateTotal, cartStoreReset, cartStoreResetCartItems, cartStoreResetTabItems, cartStoreStartCheckoutInterval, cartStoreUpdateItems, cartStoreUpdateSelectedShippingOption, cartStoreUpdateToErrorState, };
181
+ export { cartStore, cartStoreApplySubtotals, cartStoreCheckItemRestrictions, cartStoreClearCheckoutInterval, cartStoreGetShippingTransitInfo, cartStoreHasOneEligibleItem, cartStoreNextStep, cartStoreReCalculateTotal, cartStoreReset, cartStoreResetCartItems, cartStoreResetTabItems, cartStoreSetCheckoutSession, cartStoreStartCheckoutInterval, cartStoreUpdateItems, cartStoreUpdateSelectedShippingOption, cartStoreUpdateToErrorState, };
@@ -10,7 +10,7 @@ import { EnteredInfo, TranslatedAddressObject } from "./types/checkout/Translate
10
10
  import { SubmitEventData } from "./components/checkout/zonos-checkout/zonos-address-update-dialog/zonos-address-update-dialog";
11
11
  import { CheckboxColorPrefix, Color, ColorPrefix } from "./types/styles/Color";
12
12
  import { BannerIntent } from "./components/common/zonos-banner/zonos-banner";
13
- import { CountryCode, ElementsUiStyle, ElementsUiTheme, HelloMobileLocation } from "./types/generated/graphql.customer.types";
13
+ import { CheckoutSessionDetailsFragment, CountryCode, ElementsUiStyle, ElementsUiTheme, HelloMobileLocation } from "./types/generated/graphql.customer.types";
14
14
  import { Color as Color1 } from "./types/index";
15
15
  import { FontWeight, Size, Type } from "./types/styles/Text";
16
16
  import { AppearanceConfig } from "./components/store/zonosStore";
@@ -30,7 +30,7 @@ export { EnteredInfo, TranslatedAddressObject } from "./types/checkout/Translate
30
30
  export { SubmitEventData } from "./components/checkout/zonos-checkout/zonos-address-update-dialog/zonos-address-update-dialog";
31
31
  export { CheckboxColorPrefix, Color, ColorPrefix } from "./types/styles/Color";
32
32
  export { BannerIntent } from "./components/common/zonos-banner/zonos-banner";
33
- export { CountryCode, ElementsUiStyle, ElementsUiTheme, HelloMobileLocation } from "./types/generated/graphql.customer.types";
33
+ export { CheckoutSessionDetailsFragment, CountryCode, ElementsUiStyle, ElementsUiTheme, HelloMobileLocation } from "./types/generated/graphql.customer.types";
34
34
  export { Color as Color1 } from "./types/index";
35
35
  export { FontWeight, Size, Type } from "./types/styles/Text";
36
36
  export { AppearanceConfig } from "./components/store/zonosStore";
@@ -350,6 +350,10 @@ export namespace Components {
350
350
  * Flag to determine if the checkout is on mobile
351
351
  */
352
352
  "mobile": boolean;
353
+ /**
354
+ * For usage in storybook for a mocked flow.
355
+ */
356
+ "mockCheckoutSession": (session: CheckoutSessionDetailsFragment) => Promise<void>;
353
357
  /**
354
358
  * Preview checkout without needing to click on the button. This would be useful for demo purpose
355
359
  */
@@ -432,6 +432,11 @@ export declare const classificationRequestField: {
432
432
  readonly Name: "NAME";
433
433
  };
434
434
  export type ClassificationRequestField = (typeof classificationRequestField)[keyof typeof classificationRequestField];
435
+ export declare const classifyMissingHsCodesStatus: {
436
+ readonly Disabled: "DISABLED";
437
+ readonly Enabled: "ENABLED";
438
+ };
439
+ export type ClassifyMissingHsCodesStatus = (typeof classifyMissingHsCodesStatus)[keyof typeof classifyMissingHsCodesStatus];
435
440
  export declare const clearanceType: {
436
441
  readonly Commercial: "COMMERCIAL";
437
442
  readonly Postal: "POSTAL";
@@ -1178,8 +1183,16 @@ export declare const currencySymbolLocation: {
1178
1183
  readonly Before: "BEFORE";
1179
1184
  };
1180
1185
  export type CurrencySymbolLocation = (typeof currencySymbolLocation)[keyof typeof currencySymbolLocation];
1186
+ export declare const customsDocumentCarrier: {
1187
+ readonly Dhl: "DHL";
1188
+ readonly Fedex: "FEDEX";
1189
+ readonly Ups: "UPS";
1190
+ };
1191
+ export type CustomsDocumentCarrier = (typeof customsDocumentCarrier)[keyof typeof customsDocumentCarrier];
1181
1192
  export declare const customsDocumentFileType: {
1193
+ readonly Jpg: "JPG";
1182
1194
  readonly Pdf: "PDF";
1195
+ readonly Png: "PNG";
1183
1196
  readonly Txt: "TXT";
1184
1197
  };
1185
1198
  export type CustomsDocumentFileType = (typeof customsDocumentFileType)[keyof typeof customsDocumentFileType];
@@ -1320,12 +1333,6 @@ export declare const elementsUiTheme: {
1320
1333
  readonly System: "SYSTEM";
1321
1334
  };
1322
1335
  export type ElementsUiTheme = (typeof elementsUiTheme)[keyof typeof elementsUiTheme];
1323
- export declare const emailSenderStatus: {
1324
- readonly NotVerified: "NOT_VERIFIED";
1325
- readonly Pending: "PENDING";
1326
- readonly Verified: "VERIFIED";
1327
- };
1328
- export type EmailSenderStatus = (typeof emailSenderStatus)[keyof typeof emailSenderStatus];
1329
1336
  export declare const emailTemplateProviderType: {
1330
1337
  readonly Sendgrid: "SENDGRID";
1331
1338
  };
@@ -3032,51 +3039,6 @@ export type CheckoutSessionCreateMutation = {
3032
3039
  };
3033
3040
  };
3034
3041
  };
3035
- export type CheckoutDetailsFragment = {
3036
- cartId: string | null;
3037
- clientSecret: string;
3038
- id: string;
3039
- landedCost: {
3040
- amountSubtotals: {
3041
- discounts: number | null;
3042
- duties: number;
3043
- fees: number;
3044
- items: number;
3045
- landedCostTotal: number;
3046
- shipping: number;
3047
- taxes: number;
3048
- } | null;
3049
- id: string;
3050
- landedCostGuaranteeCode: LandedCostGuaranteeCode;
3051
- method: IncotermCode;
3052
- shipmentRating: {
3053
- displayName: string;
3054
- };
3055
- } | null;
3056
- metadata: Array<{
3057
- key: string;
3058
- value: string;
3059
- } | null> | null;
3060
- organizationId: string;
3061
- subtotals: {
3062
- adjustments: number;
3063
- duties: number;
3064
- exchangeRate: {
3065
- id: string;
3066
- rate: number;
3067
- sourceCurrencyCode: CurrencyCode;
3068
- targetCurrencyCode: CurrencyCode;
3069
- type: ExchangeRateType;
3070
- };
3071
- fees: number;
3072
- items: number;
3073
- landedCostTotal: number;
3074
- presentmentCurrencyCode: CurrencyCode;
3075
- shipping: number;
3076
- taxes: number;
3077
- total: number;
3078
- };
3079
- };
3080
3042
  export type PaypalOrderCreateMutation = {
3081
3043
  paypalOrderCreate: {
3082
3044
  paypalOrderId: string | null;
@@ -3150,6 +3112,51 @@ export type CheckoutSessionUpdateMetadataMutation = {
3150
3112
  } | null> | null;
3151
3113
  };
3152
3114
  };
3115
+ export type CheckoutSessionDetailsFragment = {
3116
+ cartId: string | null;
3117
+ clientSecret: string;
3118
+ id: string;
3119
+ landedCost: {
3120
+ amountSubtotals: {
3121
+ discounts: number | null;
3122
+ duties: number;
3123
+ fees: number;
3124
+ items: number;
3125
+ landedCostTotal: number;
3126
+ shipping: number;
3127
+ taxes: number;
3128
+ } | null;
3129
+ id: string;
3130
+ landedCostGuaranteeCode: LandedCostGuaranteeCode;
3131
+ method: IncotermCode;
3132
+ shipmentRating: {
3133
+ displayName: string;
3134
+ };
3135
+ } | null;
3136
+ metadata: Array<{
3137
+ key: string;
3138
+ value: string;
3139
+ } | null> | null;
3140
+ organizationId: string;
3141
+ subtotals: {
3142
+ adjustments: number;
3143
+ duties: number;
3144
+ exchangeRate: {
3145
+ id: string;
3146
+ rate: number;
3147
+ sourceCurrencyCode: CurrencyCode;
3148
+ targetCurrencyCode: CurrencyCode;
3149
+ type: ExchangeRateType;
3150
+ };
3151
+ fees: number;
3152
+ items: number;
3153
+ landedCostTotal: number;
3154
+ presentmentCurrencyCode: CurrencyCode;
3155
+ shipping: number;
3156
+ taxes: number;
3157
+ total: number;
3158
+ };
3159
+ };
3153
3160
  export type CheckoutSessionUpdateMutation = {
3154
3161
  checkoutSessionUpdate: {
3155
3162
  cartId: string | null;
@@ -3197,51 +3204,6 @@ export type CheckoutSessionUpdateMutation = {
3197
3204
  };
3198
3205
  };
3199
3206
  };
3200
- export type CheckoutSessionUpdateDetailsFragment = {
3201
- cartId: string | null;
3202
- clientSecret: string;
3203
- id: string;
3204
- landedCost: {
3205
- amountSubtotals: {
3206
- discounts: number | null;
3207
- duties: number;
3208
- fees: number;
3209
- items: number;
3210
- landedCostTotal: number;
3211
- shipping: number;
3212
- taxes: number;
3213
- } | null;
3214
- id: string;
3215
- landedCostGuaranteeCode: LandedCostGuaranteeCode;
3216
- method: IncotermCode;
3217
- shipmentRating: {
3218
- displayName: string;
3219
- };
3220
- } | null;
3221
- metadata: Array<{
3222
- key: string;
3223
- value: string;
3224
- } | null> | null;
3225
- organizationId: string;
3226
- subtotals: {
3227
- adjustments: number;
3228
- duties: number;
3229
- exchangeRate: {
3230
- id: string;
3231
- rate: number;
3232
- sourceCurrencyCode: CurrencyCode;
3233
- targetCurrencyCode: CurrencyCode;
3234
- type: ExchangeRateType;
3235
- };
3236
- fees: number;
3237
- items: number;
3238
- landedCostTotal: number;
3239
- presentmentCurrencyCode: CurrencyCode;
3240
- shipping: number;
3241
- taxes: number;
3242
- total: number;
3243
- };
3244
- };
3245
3207
  export type ZonosSettingsQuery = {
3246
3208
  appearanceSettings: {
3247
3209
  colorPrimary: string;
@@ -3547,6 +3509,10 @@ export type GetOrderQuery = {
3547
3509
  } | null;
3548
3510
  type: PartyType | null;
3549
3511
  }> | null;
3512
+ references: Array<{
3513
+ key: string | null;
3514
+ value: string | null;
3515
+ }> | null;
3550
3516
  root: {
3551
3517
  exchangeRates: Array<{
3552
3518
  rate: number;
@@ -546,6 +546,13 @@ export const classificationRequestField = {
546
546
  export type ClassificationRequestField =
547
547
  (typeof classificationRequestField)[keyof typeof classificationRequestField];
548
548
 
549
+ export const classifyMissingHsCodesStatus = {
550
+ Disabled: 'DISABLED',
551
+ Enabled: 'ENABLED',
552
+ } as const;
553
+
554
+ export type ClassifyMissingHsCodesStatus =
555
+ (typeof classifyMissingHsCodesStatus)[keyof typeof classifyMissingHsCodesStatus];
549
556
  export const clearanceType = {
550
557
  Commercial: 'COMMERCIAL',
551
558
  Postal: 'POSTAL',
@@ -605,6 +612,7 @@ export const collectUploadStatus = {
605
612
 
606
613
  export type CollectUploadStatus =
607
614
  (typeof collectUploadStatus)[keyof typeof collectUploadStatus];
615
+
608
616
  export const commercialInvoiceImageCarrier = {
609
617
  Dhl: 'DHL',
610
618
  Fedex: 'FEDEX',
@@ -1336,8 +1344,19 @@ export const currencySymbolLocation = {
1336
1344
  export type CurrencySymbolLocation =
1337
1345
  (typeof currencySymbolLocation)[keyof typeof currencySymbolLocation];
1338
1346
 
1347
+ export const customsDocumentCarrier = {
1348
+ Dhl: 'DHL',
1349
+ Fedex: 'FEDEX',
1350
+ Ups: 'UPS',
1351
+ } as const;
1352
+
1353
+ export type CustomsDocumentCarrier =
1354
+ (typeof customsDocumentCarrier)[keyof typeof customsDocumentCarrier];
1355
+
1339
1356
  export const customsDocumentFileType = {
1357
+ Jpg: 'JPG',
1340
1358
  Pdf: 'PDF',
1359
+ Png: 'PNG',
1341
1360
  Txt: 'TXT',
1342
1361
  } as const;
1343
1362
 
@@ -1525,15 +1544,6 @@ export const elementsUiTheme = {
1525
1544
  export type ElementsUiTheme =
1526
1545
  (typeof elementsUiTheme)[keyof typeof elementsUiTheme];
1527
1546
 
1528
- export const emailSenderStatus = {
1529
- NotVerified: 'NOT_VERIFIED',
1530
- Pending: 'PENDING',
1531
- Verified: 'VERIFIED',
1532
- } as const;
1533
-
1534
- export type EmailSenderStatus =
1535
- (typeof emailSenderStatus)[keyof typeof emailSenderStatus];
1536
-
1537
1547
  export const emailTemplateProviderType = {
1538
1548
  Sendgrid: 'SENDGRID',
1539
1549
  } as const;
@@ -1984,6 +1994,7 @@ export const itemRestrictionType = {
1984
1994
 
1985
1995
  export type ItemRestrictionType =
1986
1996
  (typeof itemRestrictionType)[keyof typeof itemRestrictionType];
1997
+
1987
1998
  export const itemType = {
1988
1999
  Bundle: 'BUNDLE',
1989
2000
  DigitalGood: 'DIGITAL_GOOD',
@@ -3543,47 +3554,6 @@ export type CheckoutSessionCreateMutation = {
3543
3554
  };
3544
3555
  };
3545
3556
 
3546
- export type CheckoutDetailsFragment = {
3547
- cartId: string | null;
3548
- clientSecret: string;
3549
- id: string;
3550
- landedCost: {
3551
- amountSubtotals: {
3552
- discounts: number | null;
3553
- duties: number;
3554
- fees: number;
3555
- items: number;
3556
- landedCostTotal: number;
3557
- shipping: number;
3558
- taxes: number;
3559
- } | null;
3560
- id: string;
3561
- landedCostGuaranteeCode: LandedCostGuaranteeCode;
3562
- method: IncotermCode;
3563
- shipmentRating: { displayName: string };
3564
- } | null;
3565
- metadata: Array<{ key: string; value: string } | null> | null;
3566
- organizationId: string;
3567
- subtotals: {
3568
- adjustments: number;
3569
- duties: number;
3570
- exchangeRate: {
3571
- id: string;
3572
- rate: number;
3573
- sourceCurrencyCode: CurrencyCode;
3574
- targetCurrencyCode: CurrencyCode;
3575
- type: ExchangeRateType;
3576
- };
3577
- fees: number;
3578
- items: number;
3579
- landedCostTotal: number;
3580
- presentmentCurrencyCode: CurrencyCode;
3581
- shipping: number;
3582
- taxes: number;
3583
- total: number;
3584
- };
3585
- };
3586
-
3587
3557
  export type PaypalOrderCreateMutation = {
3588
3558
  paypalOrderCreate: { paypalOrderId: string | null };
3589
3559
  };
@@ -3643,6 +3613,47 @@ export type CheckoutSessionUpdateMetadataMutation = {
3643
3613
  };
3644
3614
  };
3645
3615
 
3616
+ export type CheckoutSessionDetailsFragment = {
3617
+ cartId: string | null;
3618
+ clientSecret: string;
3619
+ id: string;
3620
+ landedCost: {
3621
+ amountSubtotals: {
3622
+ discounts: number | null;
3623
+ duties: number;
3624
+ fees: number;
3625
+ items: number;
3626
+ landedCostTotal: number;
3627
+ shipping: number;
3628
+ taxes: number;
3629
+ } | null;
3630
+ id: string;
3631
+ landedCostGuaranteeCode: LandedCostGuaranteeCode;
3632
+ method: IncotermCode;
3633
+ shipmentRating: { displayName: string };
3634
+ } | null;
3635
+ metadata: Array<{ key: string; value: string } | null> | null;
3636
+ organizationId: string;
3637
+ subtotals: {
3638
+ adjustments: number;
3639
+ duties: number;
3640
+ exchangeRate: {
3641
+ id: string;
3642
+ rate: number;
3643
+ sourceCurrencyCode: CurrencyCode;
3644
+ targetCurrencyCode: CurrencyCode;
3645
+ type: ExchangeRateType;
3646
+ };
3647
+ fees: number;
3648
+ items: number;
3649
+ landedCostTotal: number;
3650
+ presentmentCurrencyCode: CurrencyCode;
3651
+ shipping: number;
3652
+ taxes: number;
3653
+ total: number;
3654
+ };
3655
+ };
3656
+
3646
3657
  export type CheckoutSessionUpdateMutation = {
3647
3658
  checkoutSessionUpdate: {
3648
3659
  cartId: string | null;
@@ -3686,47 +3697,6 @@ export type CheckoutSessionUpdateMutation = {
3686
3697
  };
3687
3698
  };
3688
3699
 
3689
- export type CheckoutSessionUpdateDetailsFragment = {
3690
- cartId: string | null;
3691
- clientSecret: string;
3692
- id: string;
3693
- landedCost: {
3694
- amountSubtotals: {
3695
- discounts: number | null;
3696
- duties: number;
3697
- fees: number;
3698
- items: number;
3699
- landedCostTotal: number;
3700
- shipping: number;
3701
- taxes: number;
3702
- } | null;
3703
- id: string;
3704
- landedCostGuaranteeCode: LandedCostGuaranteeCode;
3705
- method: IncotermCode;
3706
- shipmentRating: { displayName: string };
3707
- } | null;
3708
- metadata: Array<{ key: string; value: string } | null> | null;
3709
- organizationId: string;
3710
- subtotals: {
3711
- adjustments: number;
3712
- duties: number;
3713
- exchangeRate: {
3714
- id: string;
3715
- rate: number;
3716
- sourceCurrencyCode: CurrencyCode;
3717
- targetCurrencyCode: CurrencyCode;
3718
- type: ExchangeRateType;
3719
- };
3720
- fees: number;
3721
- items: number;
3722
- landedCostTotal: number;
3723
- presentmentCurrencyCode: CurrencyCode;
3724
- shipping: number;
3725
- taxes: number;
3726
- total: number;
3727
- };
3728
- };
3729
-
3730
3700
  export type ZonosSettingsQuery = {
3731
3701
  appearanceSettings: {
3732
3702
  colorPrimary: string;
@@ -4018,6 +3988,7 @@ export type GetOrderQuery = {
4018
3988
  } | null;
4019
3989
  type: PartyType | null;
4020
3990
  }> | null;
3991
+ references: Array<{ key: string | null; value: string | null }> | null;
4021
3992
  root: {
4022
3993
  exchangeRates: Array<{
4023
3994
  rate: number;
@@ -1 +1 @@
1
- import{l as e,a as n}from"./p-fb59c3c3.js";import{s as t,c as o}from"./p-f9c2288f.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./p-f9c2288f.js";const s=["jsdelivr","cdnjs","unpkg","vercel"],r="jsdelivr",i=e=>{const n=s.indexOf(e);return s[n+1]||null},l="https://js.stripe.com/v3",u=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,a="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let m=null;const p=Promise.resolve().then((()=>{return e=null,null!==m||(m=new Promise(((t,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(a),window.Stripe)t(window.Stripe);else try{let s=(()=>{const e=document.querySelectorAll(`script[src^="${l}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&u.test(t.src))return t}return null})();s&&e?console.warn(a):s||(s=(e=>{const t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${l}${t}`;const s=document.head||document.body;return s?(s.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==s||s.addEventListener("load",(()=>{window.Stripe?t(window.Stripe):o(new Error("Stripe.js not available"))})),null==s||s.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else t(null)}))),m;var e}));let f=!1;var w;p.catch((e=>{f||console.warn(e)}));const h=(()=>{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})(),v="https://v1.3.58.js.zonos.com",y=h||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.58",z="https://rsms.me",j="https://fonts.googleapis.com",S=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class g{}w=g,g.doneInit=!1,g.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),g.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),g._paypalMockResponse=null,g.isBigCommerce=!1,g.releaseDate="1727735627207",g.isLegacyCheckout=!1,g.isNpm=!0,g.zonosQaUrl=null,g.version="v1.3.58",g.modeAlerted=!1,g.cartData=null,g.paypal=null,g.getCurrentTimestamp=()=>(new Date).getTime(),g.zonosController=null,g.init=async({appearance:s,checkoutSettings:r,currencyConverter:i,helloSettings:c,onCountryChange:l,overrideCurrencyFormat:d,storeId:u,zonosApiKey:a})=>{if(w.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!w.doneInit){if(e(`====== ZONOS DEBUG MODE: on (${w.version}) ======`),w.zonosApiKey=a,w.storeId=u,w.isNpm){if(e("====== ZONOS LOADING FROM NPM ======"),!a&&!w.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!w.cartData&&w.cartId){e("Initialize cart data");const o=await t(w.cartId);if(!o)return void n("Failed to get cart data");w.cartData=o.cartData,w.zonosApiKey=o.zonosApiKey}}if(w.cartId&&w.cartData){e("Cart data is available, inject hidden button and trigger checkout");const n=document.createElement("button");n.style.display="none",n.id=`${o}`,document.body.appendChild(n)}e("init zonos"),w.injectZonosCdn(),w.injectZonosCss(),w.injectFonts(),w.injectController({config:{appearance:s,checkoutSettings:r,currencyConverter:i,helloSettings:c,onCountryChange:l,overrideCurrencyFormat:d}}),w.doneInit=!0}},g.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},g.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},g.showNotification=e=>{var n;null===(n=w.zonosController)||void 0===n||n.showNotification(e)},g.updateOrganizationName=e=>{var n;null===(n=w.zonosController)||void 0===n||n.updateOrganizationName(e)},g.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)}},g.injectController=({config:t})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=t.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const e=t.checkoutSettings.placeOrderButtonSelector;w.disablePlaceOrderButtons({config:t,disable:!0,placeOrderButtonSelector:e}),new MutationObserver((()=>{w.disablePlaceOrderButtons({config:t,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=t,s.zonosApiKey=w.zonosApiKey||"",s.addEventListener("stripeInitEvent",(async t=>{const{detail:o}=t;e("loading Stripe");const r=await(async(...e)=>{f=!0;const n=Date.now();return p.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);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),w.zonosController=s,e("Zonos controller injected!")},g.injectScript=({cdnType:t,isModule:o,theRestUrl:s})=>{const r=`${w.getZonosUrl(t)}/${s}`;if(document.querySelector(`script[src="${r}"]`))return void e(`Zonos script "${r}" already exists in the document`,"warn");const c=document.head||document.body,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=r,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const e=i(t);e&&w.injectScript({cdnType:e,isModule:o,theRestUrl:s})},c.appendChild(l)},g.getZonosUrl=n=>{const t=()=>{switch(n){case"jsdelivr":return y;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.58";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.58";case"vercel":return v}};return w.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.58.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()},g.injectZonosCdn=()=>{w.injectScript({cdnType:r,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),w.injectScript({cdnType:r,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},g.injectStylesheet=({cdnType:e,theRestUrl:t})=>{const o=w.getZonosUrl(e),s=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${v}/`,s.appendChild(r);const c=document.createElement("link");c.rel="stylesheet",c.href=`${o}/${t}`,c.onerror=()=>{n(`Failed to load ${c.href}`);const o=i(e);o&&w.injectStylesheet({cdnType:o,theRestUrl:t})},s.appendChild(c)},g.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(w.injectStylesheet({cdnType:r,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},g.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${z}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&!S.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=z,n.appendChild(t);const o=document.createElement("link");o.rel="stylesheet",o.href=`${z}/inter/inter.css`,n.appendChild(o),e("Zonos font injected!")},g.setupGoogleFont=e=>{var n;null===(n=w.zonosController)||void 0===n||n.setupGoogleFont(e)},g.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^="${j}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=j,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{g as Zonos}
1
+ import{l as e,a as n}from"./p-fb59c3c3.js";import{s as t,c as o}from"./p-f9c2288f.js";export{c as checkoutHiddenBtnSelector,d as domesticRedirectedBtnSelector}from"./p-f9c2288f.js";const s=["jsdelivr","cdnjs","unpkg","vercel"],r="jsdelivr",i=e=>{const n=s.indexOf(e);return s[n+1]||null},l="https://js.stripe.com/v3",u=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,a="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let m=null;const p=Promise.resolve().then((()=>{return e=null,null!==m||(m=new Promise(((t,o)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(a),window.Stripe)t(window.Stripe);else try{let s=(()=>{const e=document.querySelectorAll(`script[src^="${l}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&u.test(t.src))return t}return null})();s&&e?console.warn(a):s||(s=(e=>{const t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",o=document.createElement("script");o.src=`${l}${t}`;const s=document.head||document.body;return s?(s.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==s||s.addEventListener("load",(()=>{window.Stripe?t(window.Stripe):o(new Error("Stripe.js not available"))})),null==s||s.addEventListener("error",(()=>{o(new Error("Failed to load Stripe.js"))}))}catch(e){return void o(e)}else t(null)}))),m;var e}));let f=!1;var w;p.catch((e=>{f||console.warn(e)}));const h=(()=>{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})(),v="https://v1.3.59.js.zonos.com",y=h||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.59",z="https://rsms.me",j="https://fonts.googleapis.com",S=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class g{}w=g,g.doneInit=!1,g.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),g.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),g._paypalMockResponse=null,g.isBigCommerce=!1,g.releaseDate="1727798254658",g.isLegacyCheckout=!1,g.isNpm=!0,g.zonosQaUrl=null,g.version="v1.3.59",g.modeAlerted=!1,g.cartData=null,g.paypal=null,g.getCurrentTimestamp=()=>(new Date).getTime(),g.zonosController=null,g.init=async({appearance:s,checkoutSettings:r,currencyConverter:i,helloSettings:c,onCountryChange:l,overrideCurrencyFormat:d,storeId:u,zonosApiKey:a})=>{if(w.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),!w.doneInit){if(e(`====== ZONOS DEBUG MODE: on (${w.version}) ======`),w.zonosApiKey=a,w.storeId=u,w.isNpm){if(e("====== ZONOS LOADING FROM NPM ======"),!a&&!w.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!w.cartData&&w.cartId){e("Initialize cart data");const o=await t(w.cartId);if(!o)return void n("Failed to get cart data");w.cartData=o.cartData,w.zonosApiKey=o.zonosApiKey}}if(w.cartId&&w.cartData){e("Cart data is available, inject hidden button and trigger checkout");const n=document.createElement("button");n.style.display="none",n.id=`${o}`,document.body.appendChild(n)}e("init zonos"),w.injectZonosCdn(),w.injectZonosCss(),w.injectFonts(),w.injectController({config:{appearance:s,checkoutSettings:r,currencyConverter:i,helloSettings:c,onCountryChange:l,overrideCurrencyFormat:d}}),w.doneInit=!0}},g.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},g.openHelloDialog=e=>{const n=document.querySelector("zonos-hello");n&&n.openHelloDialog(null==e||e)},g.showNotification=e=>{var n;null===(n=w.zonosController)||void 0===n||n.showNotification(e)},g.updateOrganizationName=e=>{var n;null===(n=w.zonosController)||void 0===n||n.updateOrganizationName(e)},g.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)}},g.injectController=({config:t})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=t.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const e=t.checkoutSettings.placeOrderButtonSelector;w.disablePlaceOrderButtons({config:t,disable:!0,placeOrderButtonSelector:e}),new MutationObserver((()=>{w.disablePlaceOrderButtons({config:t,disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=t,s.zonosApiKey=w.zonosApiKey||"",s.addEventListener("stripeInitEvent",(async t=>{const{detail:o}=t;e("loading Stripe");const r=await(async(...e)=>{f=!0;const n=Date.now();return p.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);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),w.zonosController=s,e("Zonos controller injected!")},g.injectScript=({cdnType:t,isModule:o,theRestUrl:s})=>{const r=`${w.getZonosUrl(t)}/${s}`;if(document.querySelector(`script[src="${r}"]`))return void e(`Zonos script "${r}" already exists in the document`,"warn");const c=document.head||document.body,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=r,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const e=i(t);e&&w.injectScript({cdnType:e,isModule:o,theRestUrl:s})},c.appendChild(l)},g.getZonosUrl=n=>{const t=()=>{switch(n){case"jsdelivr":return y;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.59";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.59";case"vercel":return v}};return w.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.59.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()},g.injectZonosCdn=()=>{w.injectScript({cdnType:r,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),w.injectScript({cdnType:r,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},g.injectStylesheet=({cdnType:e,theRestUrl:t})=>{const o=w.getZonosUrl(e),s=document.head||document.body,r=document.createElement("link");r.rel="preconnect",r.href=`${v}/`,s.appendChild(r);const c=document.createElement("link");c.rel="stylesheet",c.href=`${o}/${t}`,c.onerror=()=>{n(`Failed to load ${c.href}`);const o=i(e);o&&w.injectStylesheet({cdnType:o,theRestUrl:t})},s.appendChild(c)},g.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(w.injectStylesheet({cdnType:r,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},g.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${z}"]`);for(let n=0;n<e.length;n++){const t=e[n];if(t&&!S.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=z,n.appendChild(t);const o=document.createElement("link");o.rel="stylesheet",o.href=`${z}/inter/inter.css`,n.appendChild(o),e("Zonos font injected!")},g.setupGoogleFont=e=>{var n;null===(n=w.zonosController)||void 0===n||n.setupGoogleFont(e)},g.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^="${j}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=j,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{g as Zonos}
@@ -1,4 +1,4 @@
1
- import{z as o,c as e}from"./p-9dd6b00d.js";import{d as r,q as n,t,p as a,h as i}from"./p-9fd3995f.js";import{h as s,l as c,a as l,j as u}from"./p-fb59c3c3.js";import{t as d}from"./p-23a84835.js";
1
+ import{z as o,c as e}from"./p-9dd6b00d.js";import{d as r,r as n,t,q as a,h as i}from"./p-7f0cea76.js";import{h as s,l as c,a as l,j as u}from"./p-fb59c3c3.js";import{t as d}from"./p-23a84835.js";
2
2
  /*!
3
3
  * paypal-js v8.1.0 (2024-06-07T16:55:00.122Z)
4
4
  * Copyright 2020-present, PayPal, Inc. All rights reserved.