@zonos/elements 1.3.75 → 1.3.76
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-6dd9e3cd.js → cart-307b8dc7.js} +23 -17
- package/dist/cjs/{createCustomEvent-4efb5ab7.js → createCustomEvent-8b7e430f.js} +1 -1
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/{paypal-f0d2a8cf.js → paypal-f0e6424f.js} +1 -1
- package/dist/cjs/zonos-address_8.cjs.entry.js +1 -1
- package/dist/cjs/zonos-badge_13.cjs.entry.js +3 -3
- package/dist/cjs/zonos-checkout.cjs.entry.js +9 -6
- package/dist/cjs/zonos-controller.cjs.entry.js +3 -3
- 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 +1 -1
- 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 +2 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/zonos-checkout-footer.js +2 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +8 -5
- package/dist/collection/components/checkout/zonos-checkout/zonos-review/zonos-review.js +1 -1
- package/dist/collection/components/common/zonos-button/zonos-button.js +4 -4
- package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.js +2 -2
- package/dist/collection/components/common/zonos-country-flag/zonos-country-flag.js +2 -2
- package/dist/collection/components/common/zonos-dialog/zonos-dialog.js +2 -2
- package/dist/collection/components/common/zonos-logo/zonos-logo.js +2 -2
- package/dist/collection/components/common/zonos-shipping-rich-radio/zonos-shipping-rich-radio.js +4 -4
- package/dist/collection/components/hello/zonos-hello/zonos-hello.js +2 -2
- package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +2 -2
- package/dist/collection/components/main/zonos-controller.js +4 -4
- package/dist/collection/components/store/checkout/cart.js +4 -4
- package/dist/collection/components/store/checkout/stripe.js +6 -6
- package/dist/collection/components/store/hello/localization.js +11 -5
- package/dist/collection/components/utils/api/prepCalculateLandedCost.js +1 -1
- package/dist/collection/components/utils/checkout/{buildTranslateRequestBody.js → buildTranslateRequest.js} +2 -2
- package/dist/collection/types/checkout/api/CheckoutSession.js +1 -0
- package/dist/collection/types/checkout/api/Paypal.js +1 -0
- package/dist/collection/types/checkout/api/ValidateAddress.js +1 -0
- package/dist/collection/types/generated/{graphql.customer.types.js → graphql.internal.types.js} +8 -0
- package/dist/collection/types/index.js +8 -1
- package/dist/esm/{cart-66d17f99.js → cart-0345943b.js} +23 -17
- package/dist/esm/{createCustomEvent-4ac32a26.js → createCustomEvent-11fa43d2.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/{paypal-3e2c7b41.js → paypal-7592a690.js} +1 -1
- package/dist/esm/zonos-address_8.entry.js +1 -1
- package/dist/esm/zonos-badge_13.entry.js +3 -3
- package/dist/esm/zonos-checkout.entry.js +9 -6
- package/dist/esm/zonos-controller.entry.js +3 -3
- 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 +1 -1
- 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-66d17f99.js → cart-0345943b.js} +1 -1
- package/dist/esm-es5/{createCustomEvent-4ac32a26.js → createCustomEvent-11fa43d2.js} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{paypal-3e2c7b41.js → paypal-7592a690.js} +1 -1
- package/dist/esm-es5/zonos-address_8.entry.js +1 -1
- package/dist/esm-es5/zonos-badge_13.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 +51 -50
- 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/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.d.ts +1 -1
- package/dist/types/components/checkout/zonos-checkout/zonos-checkout-footer/zonos-checkout-footer.d.ts +1 -1
- package/dist/types/components/checkout/zonos-checkout/zonos-checkout.d.ts +2 -2
- package/dist/types/components/common/zonos-button/zonos-button.d.ts +1 -1
- package/dist/types/components/common/zonos-checkbox/zonos-checkbox.d.ts +1 -1
- package/dist/types/components/common/zonos-country-flag/zonos-country-flag.d.ts +1 -1
- package/dist/types/components/common/zonos-dialog/zonos-dialog.d.ts +1 -1
- package/dist/types/components/common/zonos-logo/zonos-logo.d.ts +1 -1
- package/dist/types/components/common/zonos-shipping-rich-radio/zonos-shipping-rich-radio.d.ts +1 -1
- package/dist/types/components/hello/zonos-hello/zonos-hello.d.ts +1 -1
- package/dist/types/components/hello/zonos-hello-dialog/zonos-hello-dialog.d.ts +1 -1
- package/dist/types/components/main/zonos-controller.d.ts +1 -1
- package/dist/types/components/store/checkout/cart.d.ts +8 -8
- package/dist/types/components/store/checkout/paypal.d.ts +1 -1
- package/dist/types/components/store/checkout/stripe.d.ts +3 -15
- package/dist/types/components/store/hello/localization.d.ts +1 -1
- package/dist/types/components/store/zonosStore.d.ts +1 -1
- package/dist/types/components/utils/api/calculateLandedCost.d.ts +1 -1
- package/dist/types/components/utils/api/calculateLandedCostNormalized.d.ts +1 -1
- package/dist/types/components/utils/api/cartCalculateLandedCost.d.ts +1 -1
- package/dist/types/components/utils/api/checkItemRestrictions.d.ts +4 -13
- package/dist/types/components/utils/api/getInclusivePricing.d.ts +1 -1
- package/dist/types/components/utils/api/getShippingZones.d.ts +1 -1
- package/dist/types/components/utils/api/getZonosSettings.d.ts +1 -1
- package/dist/types/components/utils/api/paypalCaptureOrder.d.ts +3 -7
- package/dist/types/components/utils/api/paypalCreateOrder.d.ts +3 -6
- package/dist/types/components/utils/api/prepCalculateLandedCost.d.ts +1 -1
- package/dist/types/components/utils/api/trackConversionEvent.d.ts +1 -2
- package/dist/types/components/utils/api/triggerBuildLandedCost.d.ts +2 -2
- package/dist/types/components/utils/checkout/{buildTranslateRequestBody.d.ts → buildTranslateRequest.d.ts} +3 -3
- package/dist/types/components/utils/getBorderRadius.d.ts +1 -1
- package/dist/types/components/utils/hello/currencyConversion/currencyFormat.d.ts +1 -1
- package/dist/types/components/utils/hello/currencyConversion/getCurrencyCode.d.ts +1 -1
- package/dist/types/components/utils/hello/currencyConversion/numberFormat.d.ts +1 -1
- package/dist/types/components/utils/hello/detectItemRestrictions.d.ts +2 -2
- package/dist/types/components/utils/hello/initHello.d.ts +1 -1
- package/dist/types/components/utils/logging/sendLoadScriptLog.d.ts +2 -2
- package/dist/types/components.d.ts +2 -2
- package/dist/types/scripts/_zonosBase.d.ts +1 -1
- package/dist/types/scripts/cart/_setupCartData.d.ts +1 -1
- package/dist/types/styles/stripe/addressRuleStyle.d.ts +1 -1
- package/dist/types/styles/stripe/defaultVariable.d.ts +1 -1
- package/dist/types/types/ConversionEvent.d.ts +12 -0
- package/dist/types/types/ICountryJson.d.ts +1 -1
- package/dist/types/types/{LogErrorRequestBody.d.ts → LogError.d.ts} +1 -1
- package/dist/types/types/{LogLoadScriptRequestBody.d.ts → LogLoadScript.d.ts} +1 -1
- package/dist/types/types/checkout/CheckoutConfig.d.ts +1 -1
- package/dist/types/types/checkout/TranslatedText.d.ts +1 -1
- package/dist/types/types/checkout/api/{CalculateLandedCostRequest.d.ts → CalculateLandedCost.d.ts} +12 -11
- package/dist/types/types/checkout/api/CheckoutSession.d.ts +30 -0
- package/dist/types/types/checkout/api/NormalizedTempCart.d.ts +1 -1
- package/dist/types/types/checkout/api/Paypal.d.ts +8 -0
- package/dist/types/types/checkout/api/{ValidateAddressRequest.d.ts → ValidateAddress.d.ts} +2 -2
- package/dist/types/types/generated/{graphql.customer.types.d.ts → graphql.internal.types.d.ts} +10 -0
- package/dist/types/types/generated/{graphql.customer.types.ts → graphql.internal.types.ts} +14 -0
- package/dist/types/types/hello/HelloConfig.d.ts +1 -1
- package/dist/types/types/hello/RestrictedItem.d.ts +10 -1
- package/dist/types/types/index.d.ts +8 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-31c8e3f2.entry.js +1 -0
- package/dist/zonos-elements/{p-3088517c.system.js → p-320e3627.system.js} +2 -2
- package/dist/zonos-elements/{p-0d719ad2.system.js → p-3b78b5db.system.js} +1 -1
- package/dist/zonos-elements/{p-325233e3.js → p-4e21f719.js} +2 -2
- package/dist/zonos-elements/{p-432a5555.system.entry.js → p-514b94ec.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-6488e805.system.entry.js → p-54d31641.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-01a8ec15.system.entry.js → p-55020546.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-ea340dbf.entry.js → p-70acd15f.entry.js} +1 -1
- package/dist/zonos-elements/{p-dbbf8d3e.system.js → p-71382e47.system.js} +1 -1
- package/dist/zonos-elements/{p-ffaef730.js → p-76b9668f.js} +1 -1
- package/dist/zonos-elements/{p-bc803391.system.entry.js → p-78abda17.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-b6e58c30.js → p-8478f4ee.js} +1 -1
- package/dist/zonos-elements/{p-d0ae7ede.system.entry.js → p-85140605.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-0a411ee0.system.entry.js → p-8915c7ff.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-1b101d0f.entry.js → p-94d92a0b.entry.js} +1 -1
- package/dist/zonos-elements/{p-c86fa519.system.js → p-95c4785f.system.js} +1 -1
- package/dist/zonos-elements/{p-0819aa2d.system.entry.js → p-9a88fb19.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-882d2619.entry.js → p-a57f0556.entry.js} +1 -1
- package/dist/zonos-elements/{p-3ec5cfe1.entry.js → p-be6c49ec.entry.js} +1 -1
- package/dist/zonos-elements/{p-438ac9d0.entry.js → p-c6e90e75.entry.js} +1 -1
- package/dist/zonos-elements/p-c78dd680.system.js +1 -1
- package/dist/zonos-elements/{p-b362e3c9.entry.js → p-cab296cc.entry.js} +1 -1
- package/dist/zonos-elements/{p-72345655.entry.js → p-cf61027a.entry.js} +1 -1
- package/dist/zonos-elements/{p-999c1c0b.entry.js → p-dc430b34.entry.js} +1 -1
- package/dist/zonos-elements/{p-bad47d15.system.entry.js → p-e3068a5f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-ac3cd38e.system.entry.js → p-eacd1669.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a6223def.system.entry.js → p-f7965bc8.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-ea124e18.entry.js → p-f8cbd1b8.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-913efe84.entry.js +0 -1
- /package/dist/collection/types/{LogErrorRequestBody.js → ConversionEvent.js} +0 -0
- /package/dist/collection/types/{LogLoadScriptRequestBody.js → LogError.js} +0 -0
- /package/dist/collection/types/{checkout/api/CalculateLandedCostRequest.js → LogLoadScript.js} +0 -0
- /package/dist/collection/types/checkout/api/{ValidateAddressRequest.js → CalculateLandedCost.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function e(e,o){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&o.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var t=0;for(r=Object.getOwnPropertySymbols(e);t<r.length;t++)o.indexOf(r[t])<0&&Object.prototype.propertyIsEnumerable.call(e,r[t])&&(n[r[t]]=e[r[t]])}return n}"function"==typeof SuppressedError&&SuppressedError;const o=["cloudflare","vercel"],n=o[0],r={cloudflare:"https://route.elements.zonos.com",vercel:"https://v1.route.js.zonos.com"},t=r[n],s=(e=n)=>{const r=o.indexOf(e),t=o[r+1];return t||null},i=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},a=(e,o,...n)=>{var r,t;if(!(!!(null===(r=window.Zonos)||void 0===r?void 0:r.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===o&&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===(t=s.contentWindow)||void 0===t?void 0:t.window.console)||window.console;switch(o){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()}},c=async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:i})=>{if(i){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const a="userAgentData"in window.navigator?window.navigator.userAgentData:null,c={endpoint:e,errors:o,metadata:Object.assign({href:window.location.href,userAgent:a&&a.brands.length>0?a:window.navigator.userAgent},n)};try{fetch(`${t}/api/zonos-elements/log-error`,{body:JSON.stringify(c),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=s();if(!o)return;fetch(`${r[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(c),method:"POST"})}},l=async({response:e,shouldLog:o=!0,shouldThrow:n=!1})=>{try{return await e.json()}catch(e){if(n)throw e;return o&&console.error(e),null}},d=async({basePathType:e,options:o,path:t})=>{let s;const i=window.Zonos.zonosQaUrlApi||r[e]||n,a=new URL(i+t);a.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(window.location.hostname));try{s=await fetch(a.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:i,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:i,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const c=s.headers.get("Zonos-Mode"),d=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&c&&d&&(window.Zonos.modeAlerted=!0),s.ok){return{baseUrl:i,errors:[],json:await l({response:s}),response:s,zonosMode:c}}const p=s.status.toString();try{const e=await l({response:s,shouldThrow:!0});return{baseUrl:i,errors:[{message:JSON.stringify(e),type:p}],json:null,response:s,zonosMode:c}}catch(e){return{baseUrl:i,errors:[{message:`${p}: ${"Unknown error"}`,type:p}],json:null,response:null,zonosMode:c}}},p=async({basePathType:o,options:n,path:t})=>{var l,u;const m=t.startsWith("/api/bigcommerce")?"vercel":o,g=await d({basePathType:m,options:n,path:t}),{errors:w,response:h}=g,y=e(g,["errors","response"]),f=s(m),v=!!w.find((({type:e})=>"unknown"===e))||404===(null==h?void 0:h.status),z=f&&v;return v&&c({endpoint:r[m]+t,errors:w.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:m,nextFallbackApiType:f,requestHeaders:null==n?void 0:n.headers,requestPayload:i(null===(l=null==n?void 0:n.body)||void 0===l?void 0:l.toString())||(null===(u=null==n?void 0:n.body)||void 0===u?void 0:u.toString()),status:null==h?void 0:h.status,statusText:null==h?void 0:h.statusText},shouldPostReleaseErrorReporting:!0}),z?(a(`=== "${t}" failed to fetch, trying next fallback ${f}`),p({basePathType:f,options:n,path:t})):Object.assign({errors:w,response:h},y)},u=async(o,r)=>{const t=e(r||{},[]),s=t.body?JSON.stringify(t.body):void 0,i=t.method||"GET",a=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers),c=Object.assign(Object.assign({},t),{body:"GET"===i?void 0:s,headers:a,method:i}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return p({basePathType:l||n,options:c,path:o})},m=(e,...o)=>{a(e,"error",...o)},g=["jsdelivr","cdnjs","unpkg","vercel"],w=e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");if(!o)return null;return/[^a-zA-Z0-9-_]+/.test(o)?null:o},h=async e=>{const o=await(async e=>{const{errors:o,json:n}=await u("/api/zonos-elements/get-temp-cart",{body:{tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"});return!n||o.length?null:n})(e);return a("[ZONOS - loadZonos] getting temp cart data","info",o),o?{cartData:o.cartData,storeFavicon:o.storeFaviconUrl,storeId:o.cartData.storeId,storeLogo:o.storeLogoUrl,zonosApiKey:o.cartData.credentialToken}:(m("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var y;const f=(()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=w(window.location.href),n="https://v1.3.75.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 a(`[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:o}=window.location,n=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null})),r})(),v=(()=>{const e=w(window.location.href);return!e&&["dev.demo.elements.zonos.com"].includes(window.location.hostname)||e&&"dev-elements"===e?"https://dev.demo.elements.zonos.com":null})();class z{static get isNpm(){return!1}}y=z,z.isBigCommerce=!1,z.requested=!1,z.cartData=null,z.isLegacyCheckout=!1,z.legacyStoreLogo=null,z.legacyStoreFavicon=null,z.parallelLoadTimes=[],z.parallelLoadState="off",z.releaseDate="1728510343893",z.loadScriptLogHandler=async({cdnLoadTime:e,fallbackLoadTime:o,isError:n,metadata:r,scriptLoadUrl:t,storeId:s,type:i})=>{try{const e=window.performance.getEntriesByType("resource").find((e=>{const o=e;return o.name.includes(t)&&"script"===o.initiatorType}));null==e||e.transferSize;(async e=>{})((e&&(null==e?void 0:e.duration)>0?parseFloat(e.duration.toFixed(2)):parseFloat(o.toFixed(2)),Object.assign({decodedBodySize:null==e?void 0:e.decodedBodySize,encodedBodySize:null==e?void 0:e.encodedBodySize,fallbackLoadTime:o,isError:!!n},r)))}catch(e){}},z.loadScriptLogParallelHandler=async e=>{try{if(y.parallelLoadTimes.push(e),2===y.parallelLoadTimes.length){const e=y.parallelLoadTimes.find((e=>"vercel"===e.type)),o=y.parallelLoadTimes.find((e=>"jsdelivr"===e.type));if(!e||!o)return;if(e.isError&&o.isError)return void c({endpoint:`<${e.scriptLoadUrl}> <${o.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:o.fallbackLoadTime,cdnType:o.type,vercelLoadTime:e.fallbackLoadTime}});y.loadScriptLogHandler({cdnLoadTime:o.fallbackLoadTime,fallbackLoadTime:e.fallbackLoadTime,isError:e.isError,metadata:{cdnScriptFallbackTime:o.fallbackLoadTime,cdnScriptIsError:!!o.isError,cdnScriptLoadUrl:o.scriptLoadUrl,cdnScriptType:o.type},scriptLoadUrl:e.scriptLoadUrl,storeId:e.storeId,type:e.type})}}catch(e){}},z.legacyCheckoutErrorHandler=({message:e})=>{m(`[ZONOS - loadZonos] ${e}`),c({endpoint:"LegacyCheckoutInit",errors:[e],metadata:{tempCartUUID:y.cartId}}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:e}))},z.getGithubCdn=({type:e,version:o})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.75";"cdnjs"===e?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.75":"unpkg"===e&&(n="https://unpkg.com/@zonos/elements@1.3.75");return o&&"alpha"!==o?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${o}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${o}`):n},z.injectZonos=({cdnType:e="jsdelivr",initConfig:o,parallelLoaded:n,vercelUrl:r,version:t})=>{var s;const i="vercel"===e?r:y.getGithubCdn({type:e,version:t}),l=f||i,d=l.replace("https://","").replace("http://",""),p=document.createElement("script"),u=t&&t<"1.2.5"?"loadZonos.js":"zonos.js";p.src=`https://${d}/dist/scripts/${u}`,a(`[ZONOS - loadZonos] Injecting "${u}" from "${d}"`,"info");const m="4g"===(null===(s=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||n})())||void 0===s?void 0:s.effectiveType),w=["dev.elements.zonos.com","zonos.com"].some((e=>window.location.href.includes(e))),h=g[0]===e,z=g[1],S="on"===y.parallelLoadState&&m&&h&&z&&!w;S&&y.injectZonos({cdnType:z,initConfig:o,parallelLoaded:!0,vercelUrl:r,version:t});const L=performance.now();p.addEventListener("load",(()=>{if(S||n?y.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-L,scriptLoadUrl:p.src,storeId:y.storeId,type:e}):y.loadScriptLogHandler({fallbackLoadTime:performance.now()-L,scriptLoadUrl:p.src,storeId:y.storeId,type:e}),y.isBigCommerce||(y.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=f,window.Zonos.zonosQaUrlApi=v,window.Zonos.isBigCommerce=y.isBigCommerce,y.cartId){if(!y.zonosApiKey)throw y.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!y.cartData)throw y.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(y.legacyStoreFavicon&&y.isLegacyCheckout){const e=document.createElement("link");e.rel="shortcut icon",e.type="image/x-icon",e.href=y.legacyStoreFavicon,document.head.appendChild(e)}window.Zonos.cartData=y.cartData,window.Zonos.isLegacyCheckout=y.isLegacyCheckout;const e=Object.assign(Object.assign({},o),{appearance:Object.assign(Object.assign({},o.appearance),{logoUrl:y.legacyStoreLogo||""}),checkoutSettings:Object.assign(Object.assign({},o.checkoutSettings),{successBehavior:y.isLegacyCheckout?"ZONOS_SUCCESS_PAGE":void 0,successRedirectUrl:y.isLegacyCheckout?y.cartData.storeBaseUrl:void 0}),zonosApiKey:y.zonosApiKey});o=e}window.Zonos.version&&(a(`[ZONOS - loadZonos] Execute "Zonos.init" from "${u}" from "${d}"`,"info"),window.Zonos.init(o))})),p.addEventListener("error",(async()=>{const s=(e=>{const o=g.indexOf(e);return g[o+1]||null})(e);if(!S&&!n){if(!s)return;y.injectZonos({cdnType:s,initConfig:o,vercelUrl:r,version:t})}if(["localhost",".zonos.com"].some((e=>window.location.href.includes(e)))||f)return;if(S||n)return void y.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-L,isError:!0,scriptLoadUrl:p.src,storeId:y.storeId,type:e});["unpkg","cdnjs","vercel"].includes(e)?c({endpoint:p.src,errors:[`zonos.js - Failed to fetch ${e} CDN.`],metadata:{cdnLoadTime:performance.now()-L,cdnType:e,loadUrl:l,version:t},shouldPostReleaseErrorReporting:!!s}):c({endpoint:p.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:e,vercelLoadTime:performance.now()-L}})})),document.head.appendChild(p)},z.init=async e=>{var o;y.cartId=new URLSearchParams(window.location.search).get("tempCartUUID");const n="https://v1.3.75.js.zonos.com",r=document.querySelector('script[src*="/zonos.js"]'),t=null===(o=document.querySelector("script[src*='/loadZonos.js']"))||void 0===o?void 0:o.src;a(`[ZONOS - init] first load script src: ${t}`,"info"),window.Zonos.zonosQaUrl=f,window.Zonos.zonosQaUrlApi=v,window.Zonos.zonosQaUrl&&a(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&a(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const s=null==t?void 0:t.includes("timestamp=");if(!(y.isNpm||t&&s))return void m("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(r||!t||y.requested)return void a("[ZONOS - loadZonos] script is already loaded or requested","info");if(!e.zonosApiKey&&!y.cartId)return y.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void m("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(y.requested=!0,y.zonosApiKey=e.zonosApiKey,y.storeId=e.storeId,y.cartId){const e=await h(y.cartId);if(!e)throw y.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");y.cartData=e.cartData,y.zonosApiKey=e.zonosApiKey,y.legacyStoreLogo=e.storeLogo,y.legacyStoreFavicon=e.storeFavicon,y.storeId=e.storeId,y.zonosApiKey=e.zonosApiKey}if(!y.zonosApiKey)return void m('"zonosApiKey" is required to initialize Zonos');if(!y.storeId)return a("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void y.injectZonos({initConfig:e,vercelUrl:n,version:null});const i=y.storeId||e.storeId,c=new URLSearchParams;c.set("storeId",i.toString());const l=`/api/get-store-version?${c.toString()}`,{errors:d,json:p}=await u(l);if(d.length||!p)return a("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void y.injectZonos({initConfig:e,vercelUrl:n,version:null});const{version:g}=p;if(!r){const{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:r}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),r=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:r,isWhiteListed:n}})({loadScriptSrc:t}),s=r&&!n?o:`${"alpha"===g?"alpha":`v${g}`}.js.zonos.com`,i=r&&!n?null:g;a("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:r,loadUrl:s,loadVersion:i,version:g}),y.injectZonos({initConfig:e,vercelUrl:s,version:i})}},void 0===window.Zonos&&(window.Zonos=z)})();
|
|
1
|
+
(function(){"use strict";function e(e,o){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&o.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var t=0;for(r=Object.getOwnPropertySymbols(e);t<r.length;t++)o.indexOf(r[t])<0&&Object.prototype.propertyIsEnumerable.call(e,r[t])&&(n[r[t]]=e[r[t]])}return n}"function"==typeof SuppressedError&&SuppressedError;const o=["cloudflare","vercel"],n=o[0],r={cloudflare:"https://route.elements.zonos.com",vercel:"https://v1.route.js.zonos.com"},t=r[n],s=(e=n)=>{const r=o.indexOf(e),t=o[r+1];return t||null},i=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},a=(e,o,...n)=>{var r,t;if(!(!!(null===(r=window.Zonos)||void 0===r?void 0:r.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===o&&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===(t=s.contentWindow)||void 0===t?void 0:t.window.console)||window.console;switch(o){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()}},c=async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:i})=>{if(i){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const a="userAgentData"in window.navigator?window.navigator.userAgentData:null,c={endpoint:e,errors:o,metadata:Object.assign({href:window.location.href,userAgent:a&&a.brands.length>0?a:window.navigator.userAgent},n)};try{fetch(`${t}/api/zonos-elements/log-error`,{body:JSON.stringify(c),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=s();if(!o)return;fetch(`${r[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(c),method:"POST"})}},l=async({response:e,shouldLog:o=!0,shouldThrow:n=!1})=>{try{return await e.json()}catch(e){if(n)throw e;return o&&console.error(e),null}},d=async({basePathType:e,options:o,path:t})=>{let s;const i=window.Zonos.zonosQaUrlApi||r[e]||n,a=new URL(i+t);a.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(window.location.hostname));try{s=await fetch(a.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:i,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:i,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const c=s.headers.get("Zonos-Mode"),d=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&c&&d&&(window.Zonos.modeAlerted=!0),s.ok){return{baseUrl:i,errors:[],json:await l({response:s}),response:s,zonosMode:c}}const p=s.status.toString();try{const e=await l({response:s,shouldThrow:!0});return{baseUrl:i,errors:[{message:JSON.stringify(e),type:p}],json:null,response:s,zonosMode:c}}catch(e){return{baseUrl:i,errors:[{message:`${p}: ${"Unknown error"}`,type:p}],json:null,response:null,zonosMode:c}}},p=async({basePathType:o,options:n,path:t})=>{var l,u;const m=t.startsWith("/api/bigcommerce")?"vercel":o,g=await d({basePathType:m,options:n,path:t}),{errors:w,response:h}=g,y=e(g,["errors","response"]),f=s(m),v=!!w.find((({type:e})=>"unknown"===e))||404===(null==h?void 0:h.status),z=f&&v;return v&&c({endpoint:r[m]+t,errors:w.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:m,nextFallbackApiType:f,requestHeaders:null==n?void 0:n.headers,requestPayload:i(null===(l=null==n?void 0:n.body)||void 0===l?void 0:l.toString())||(null===(u=null==n?void 0:n.body)||void 0===u?void 0:u.toString()),status:null==h?void 0:h.status,statusText:null==h?void 0:h.statusText},shouldPostReleaseErrorReporting:!0}),z?(a(`=== "${t}" failed to fetch, trying next fallback ${f}`),p({basePathType:f,options:n,path:t})):Object.assign({errors:w,response:h},y)},u=async(o,r)=>{const t=e(r||{},[]),s=t.body?JSON.stringify(t.body):void 0,i=t.method||"GET",a=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers),c=Object.assign(Object.assign({},t),{body:"GET"===i?void 0:s,headers:a,method:i}),l=new URLSearchParams(window.location.search).get("useFallbackApi");return p({basePathType:l||n,options:c,path:o})},m=(e,...o)=>{a(e,"error",...o)},g=["jsdelivr","cdnjs","unpkg","vercel"],w=e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");if(!o)return null;return/[^a-zA-Z0-9-_]+/.test(o)?null:o},h=async e=>{const o=await(async e=>{const{errors:o,json:n}=await u("/api/zonos-elements/get-temp-cart",{body:{tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"});return!n||o.length?null:n})(e);return a("[ZONOS - loadZonos] getting temp cart data","info",o),o?{cartData:o.cartData,storeFavicon:o.storeFaviconUrl,storeId:o.cartData.storeId,storeLogo:o.storeLogoUrl,zonosApiKey:o.cartData.credentialToken}:(m("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var y;const f=(()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=w(window.location.href),n="https://v1.3.76.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 a(`[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:o}=window.location,n=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",n),window.location.reload(),null})),r})(),v=(()=>{const e=w(window.location.href);return!e&&["dev.demo.elements.zonos.com"].includes(window.location.hostname)||e&&"dev-elements"===e?"https://dev.demo.elements.zonos.com":null})();class z{static get isNpm(){return!1}}y=z,z.isBigCommerce=!1,z.requested=!1,z.cartData=null,z.isLegacyCheckout=!1,z.legacyStoreLogo=null,z.legacyStoreFavicon=null,z.parallelLoadTimes=[],z.parallelLoadState="off",z.releaseDate="1728577809703",z.loadScriptLogHandler=async({cdnLoadTime:e,fallbackLoadTime:o,isError:n,metadata:r,scriptLoadUrl:t,storeId:s,type:i})=>{try{const e=window.performance.getEntriesByType("resource").find((e=>{const o=e;return o.name.includes(t)&&"script"===o.initiatorType}));null==e||e.transferSize;(async e=>{})((e&&(null==e?void 0:e.duration)>0?parseFloat(e.duration.toFixed(2)):parseFloat(o.toFixed(2)),Object.assign({decodedBodySize:null==e?void 0:e.decodedBodySize,encodedBodySize:null==e?void 0:e.encodedBodySize,fallbackLoadTime:o,isError:!!n},r)))}catch(e){}},z.loadScriptLogParallelHandler=async e=>{try{if(y.parallelLoadTimes.push(e),2===y.parallelLoadTimes.length){const e=y.parallelLoadTimes.find((e=>"vercel"===e.type)),o=y.parallelLoadTimes.find((e=>"jsdelivr"===e.type));if(!e||!o)return;if(e.isError&&o.isError)return void c({endpoint:`<${e.scriptLoadUrl}> <${o.scriptLoadUrl}>`,errors:["Failed to fetch both Vercel and jsdelivr CDN. Perhaps network issue on customer site."],metadata:{cdnLoadTime:o.fallbackLoadTime,cdnType:o.type,vercelLoadTime:e.fallbackLoadTime}});y.loadScriptLogHandler({cdnLoadTime:o.fallbackLoadTime,fallbackLoadTime:e.fallbackLoadTime,isError:e.isError,metadata:{cdnScriptFallbackTime:o.fallbackLoadTime,cdnScriptIsError:!!o.isError,cdnScriptLoadUrl:o.scriptLoadUrl,cdnScriptType:o.type},scriptLoadUrl:e.scriptLoadUrl,storeId:e.storeId,type:e.type})}}catch(e){}},z.legacyCheckoutErrorHandler=({message:e})=>{m(`[ZONOS - loadZonos] ${e}`),c({endpoint:"LegacyCheckoutInit",errors:[e],metadata:{tempCartUUID:y.cartId}}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:e}))},z.getGithubCdn=({type:e,version:o})=>{let n="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.76";"cdnjs"===e?n="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.76":"unpkg"===e&&(n="https://unpkg.com/@zonos/elements@1.3.76");return o&&"alpha"!==o?n.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${o}`).replace(/\/zonos-elements\/(.+)/,`/zonos-elements/${o}`):n},z.injectZonos=({cdnType:e="jsdelivr",initConfig:o,parallelLoaded:n,vercelUrl:r,version:t})=>{var s;const i="vercel"===e?r:y.getGithubCdn({type:e,version:t}),l=f||i,d=l.replace("https://","").replace("http://",""),p=document.createElement("script"),u=t&&t<"1.2.5"?"loadZonos.js":"zonos.js";p.src=`https://${d}/dist/scripts/${u}`,a(`[ZONOS - loadZonos] Injecting "${u}" from "${d}"`,"info");const m="4g"===(null===(s=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||n})())||void 0===s?void 0:s.effectiveType),w=["dev.elements.zonos.com","zonos.com"].some((e=>window.location.href.includes(e))),h=g[0]===e,z=g[1],S="on"===y.parallelLoadState&&m&&h&&z&&!w;S&&y.injectZonos({cdnType:z,initConfig:o,parallelLoaded:!0,vercelUrl:r,version:t});const L=performance.now();p.addEventListener("load",(()=>{if(S||n?y.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-L,scriptLoadUrl:p.src,storeId:y.storeId,type:e}):y.loadScriptLogHandler({fallbackLoadTime:performance.now()-L,scriptLoadUrl:p.src,storeId:y.storeId,type:e}),y.isBigCommerce||(y.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.isNpm=!1,window.Zonos.zonosQaUrl=f,window.Zonos.zonosQaUrlApi=v,window.Zonos.isBigCommerce=y.isBigCommerce,y.cartId){if(!y.zonosApiKey)throw y.legacyCheckoutErrorHandler({message:"zonosApiKey is missing to initiate checkout"}),new Error("zonosApiKey is required for legacy checkout");if(!y.cartData)throw y.legacyCheckoutErrorHandler({message:"cartData is missing to initiate legacy checkout"}),new Error("cartData is required for legacy checkout");if(y.legacyStoreFavicon&&y.isLegacyCheckout){const e=document.createElement("link");e.rel="shortcut icon",e.type="image/x-icon",e.href=y.legacyStoreFavicon,document.head.appendChild(e)}window.Zonos.cartData=y.cartData,window.Zonos.isLegacyCheckout=y.isLegacyCheckout;const e=Object.assign(Object.assign({},o),{appearance:Object.assign(Object.assign({},o.appearance),{logoUrl:y.legacyStoreLogo||""}),checkoutSettings:Object.assign(Object.assign({},o.checkoutSettings),{successBehavior:y.isLegacyCheckout?"ZONOS_SUCCESS_PAGE":void 0,successRedirectUrl:y.isLegacyCheckout?y.cartData.storeBaseUrl:void 0}),zonosApiKey:y.zonosApiKey});o=e}window.Zonos.version&&(a(`[ZONOS - loadZonos] Execute "Zonos.init" from "${u}" from "${d}"`,"info"),window.Zonos.init(o))})),p.addEventListener("error",(async()=>{const s=(e=>{const o=g.indexOf(e);return g[o+1]||null})(e);if(!S&&!n){if(!s)return;y.injectZonos({cdnType:s,initConfig:o,vercelUrl:r,version:t})}if(["localhost",".zonos.com"].some((e=>window.location.href.includes(e)))||f)return;if(S||n)return void y.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-L,isError:!0,scriptLoadUrl:p.src,storeId:y.storeId,type:e});["unpkg","cdnjs","vercel"].includes(e)?c({endpoint:p.src,errors:[`zonos.js - Failed to fetch ${e} CDN.`],metadata:{cdnLoadTime:performance.now()-L,cdnType:e,loadUrl:l,version:t},shouldPostReleaseErrorReporting:!!s}):c({endpoint:p.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{cdnType:e,vercelLoadTime:performance.now()-L}})})),document.head.appendChild(p)},z.init=async e=>{var o;y.cartId=new URLSearchParams(window.location.search).get("tempCartUUID");const n="https://v1.3.76.js.zonos.com",r=document.querySelector('script[src*="/zonos.js"]'),t=null===(o=document.querySelector("script[src*='/loadZonos.js']"))||void 0===o?void 0:o.src;a(`[ZONOS - init] first load script src: ${t}`,"info"),window.Zonos.zonosQaUrl=f,window.Zonos.zonosQaUrlApi=v,window.Zonos.zonosQaUrl&&a(`[ZONOS - init] using zonosQaUrl: ${window.Zonos.zonosQaUrl}`,"info"),window.Zonos.zonosQaUrlApi&&a(`[ZONOS - init] using zonosQaUrlApi: ${window.Zonos.zonosQaUrlApi}`,"info");const s=null==t?void 0:t.includes("timestamp=");if(!(y.isNpm||t&&s))return void m("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(r||!t||y.requested)return void a("[ZONOS - loadZonos] script is already loaded or requested","info");if(!e.zonosApiKey&&!y.cartId)return y.legacyCheckoutErrorHandler({message:"Zonos API key is required unless `tempCartUUID` is provided in url query params."}),void m("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(y.requested=!0,y.zonosApiKey=e.zonosApiKey,y.storeId=e.storeId,y.cartId){const e=await h(y.cartId);if(!e)throw y.legacyCheckoutErrorHandler({message:"Error getting cart data"}),new Error("Error getting cart data");y.cartData=e.cartData,y.zonosApiKey=e.zonosApiKey,y.legacyStoreLogo=e.storeLogo,y.legacyStoreFavicon=e.storeFavicon,y.storeId=e.storeId,y.zonosApiKey=e.zonosApiKey}if(!y.zonosApiKey)return void m('"zonosApiKey" is required to initialize Zonos');if(!y.storeId)return a("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void y.injectZonos({initConfig:e,vercelUrl:n,version:null});const i=y.storeId||e.storeId,c=new URLSearchParams;c.set("storeId",i.toString());const l=`/api/get-store-version?${c.toString()}`,{errors:d,json:p}=await u(l);if(d.length||!p)return a("[ZONOS - loadZonos] Error getting store version, loading the latest version.","error"),void y.injectZonos({initConfig:e,vercelUrl:n,version:null});const{version:g}=p;if(!r){const{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:r}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,n=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),r=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:r,isWhiteListed:n}})({loadScriptSrc:t}),s=r&&!n?o:`${"alpha"===g?"alpha":`v${g}`}.js.zonos.com`,i=r&&!n?null:g;a("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:r,loadUrl:s,loadVersion:i,version:g}),y.injectZonos({initConfig:e,vercelUrl:s,version:i})}},void 0===window.Zonos&&(window.Zonos=z)})();
|
package/dist/scripts/zonos.js
CHANGED
|
@@ -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.75.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=window.Zonos.zonosQaUrlApi||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","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>t.includes(e))),n=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:n,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?t:null})(),k="https://v1.3.75.js.zonos.com",A=C||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.75",E="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="1728510343893",T.isLegacyCheckout=!1,T.isNpm=!0,T.zonosQaUrl=null,T.zonosQaUrlApi=null,T.version="v1.3.75",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 A;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.75";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.75";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^="${E}"]`);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=E,t.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${E}/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.76.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=window.Zonos.zonosQaUrlApi||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","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>t.includes(e))),n=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:n,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?t:null})(),k="https://v1.3.76.js.zonos.com",A=C||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.76",E="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="1728577809703",T.isLegacyCheckout=!1,T.isNpm=!0,T.zonosQaUrl=null,T.zonosQaUrlApi=null,T.version="v1.3.76",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 A;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.76";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.76";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^="${E}"]`);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=E,t.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${E}/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,7 +1,7 @@
|
|
|
1
1
|
import { type EventEmitter } from '../../../../stencil-public-runtime';
|
|
2
2
|
import type { PaymentIntent } from '@stripe/stripe-js';
|
|
3
3
|
import type { ZonosOrder } from "../../../../types/checkout/CheckoutConfig";
|
|
4
|
-
import type { ElementsUiStyle } from "../../../../types/generated/graphql.
|
|
4
|
+
import type { ElementsUiStyle } from "../../../../types/generated/graphql.internal.types";
|
|
5
5
|
export declare class ZonosCheckoutFinish {
|
|
6
6
|
/**
|
|
7
7
|
* The border radius style of the dialog
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ElementsUiTheme } from "../../../../types/generated/graphql.
|
|
1
|
+
import type { ElementsUiTheme } from "../../../../types/generated/graphql.internal.types";
|
|
2
2
|
export declare class ZonosCheckoutFooter {
|
|
3
3
|
el: HTMLZonosCheckoutFooterElement;
|
|
4
4
|
/**
|
|
@@ -2,7 +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.
|
|
5
|
+
import type { CheckoutSessionDetailsFragment } from "../../../types/generated/graphql.internal.types";
|
|
6
6
|
export declare class ZonosCheckout {
|
|
7
7
|
/**
|
|
8
8
|
* Listener for locale change in localization store
|
|
@@ -80,7 +80,7 @@ export declare class ZonosCheckout {
|
|
|
80
80
|
/**
|
|
81
81
|
* Set default address from query param if it's valid
|
|
82
82
|
*/
|
|
83
|
-
private
|
|
83
|
+
private useLegacyQueryParams;
|
|
84
84
|
/**
|
|
85
85
|
* Setup all of the event listeners for the component on first load
|
|
86
86
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ElementsUiStyle, ElementsUiTheme } from "../../../types/generated/graphql.
|
|
1
|
+
import type { ElementsUiStyle, ElementsUiTheme } from "../../../types/generated/graphql.internal.types";
|
|
2
2
|
import type { Color } from "../../../types/styles/Color";
|
|
3
3
|
export declare class ZonosButton {
|
|
4
4
|
ele: HTMLZonosButtonElement;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type EventEmitter } from '../../../stencil-public-runtime';
|
|
2
|
-
import type { ElementsUiStyle } from "../../../types/generated/graphql.
|
|
2
|
+
import type { ElementsUiStyle } from "../../../types/generated/graphql.internal.types";
|
|
3
3
|
import type { CheckboxColorPrefix } from "../../../types/styles/Color";
|
|
4
4
|
import type { Size } from "../../../types/styles/Text";
|
|
5
5
|
export declare class ZonosCheckbox {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type EventEmitter } from '../../../stencil-public-runtime';
|
|
2
|
-
import type { ElementsUiStyle } from "../../../types/generated/graphql.
|
|
2
|
+
import type { ElementsUiStyle } from "../../../types/generated/graphql.internal.types";
|
|
3
3
|
export declare class ZonosDialog {
|
|
4
4
|
/**
|
|
5
5
|
* Whether or not the dialog is open
|
package/dist/types/components/common/zonos-shipping-rich-radio/zonos-shipping-rich-radio.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type EventEmitter } from '../../../stencil-public-runtime';
|
|
2
|
-
import type { ElementsUiStyle, ElementsUiTheme } from "../../../types/generated/graphql.
|
|
2
|
+
import type { ElementsUiStyle, ElementsUiTheme } from "../../../types/generated/graphql.internal.types";
|
|
3
3
|
import type { Color } from "../../../types/styles/Color";
|
|
4
4
|
export type ShippingRichRadioItem = {
|
|
5
5
|
amount: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AppearanceConfig } from "../../store/zonosStore";
|
|
2
|
-
import type { HelloMobileLocation } from "../../../types/generated/graphql.
|
|
2
|
+
import type { HelloMobileLocation } from "../../../types/generated/graphql.internal.types";
|
|
3
3
|
import type { Product } from "../../../types/hello/Product";
|
|
4
4
|
import type { RestrictedItem } from "../../../types/hello/RestrictedItem";
|
|
5
5
|
import type { ICountryJson } from "../../../types/ICountryJson";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type EventEmitter } from '../../../stencil-public-runtime';
|
|
2
2
|
import type { AppearanceConfig } from "../../store/zonosStore";
|
|
3
|
-
import type { HelloMobileLocation } from "../../../types/generated/graphql.
|
|
3
|
+
import type { HelloMobileLocation } from "../../../types/generated/graphql.internal.types";
|
|
4
4
|
import type { RestrictedItem } from "../../../types/hello/RestrictedItem";
|
|
5
5
|
export declare class ZonosHelloDialog {
|
|
6
6
|
/**
|
|
@@ -3,7 +3,7 @@ import type { Stripe } from '@stripe/stripe-js';
|
|
|
3
3
|
import type { NotificationInit } from "../common/zonos-notification/zonos-notification";
|
|
4
4
|
import { type AppearanceConfig } from "../store/zonosStore";
|
|
5
5
|
import type { LoadZonosParamsConfig } from "../../scripts/_zonosBase";
|
|
6
|
-
import type { CountryCode } from "../../types/generated/graphql.
|
|
6
|
+
import type { CountryCode } from "../../types/generated/graphql.internal.types";
|
|
7
7
|
export declare class ZonosController {
|
|
8
8
|
/**
|
|
9
9
|
* The zonos config object
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { stripeStoreUpdateCheckoutSession } from "./stripe";
|
|
3
|
-
import type { CalculateLandedCostMutation, CartQuery, CheckoutPresentmentFragment, CheckoutSessionDetailsFragment, CurrencyCode, ItemMeasurementType, ItemType, ItemUnitOfMeasure, LandedCostFragment, ShipmentRatingFragment } from "../../../types/generated/graphql.
|
|
3
|
+
import type { CalculateLandedCostMutation, CartQuery, CheckoutPresentmentFragment, CheckoutSessionDetailsFragment, CountryCode, CurrencyCode, ItemMeasurementType, ItemType, ItemUnitOfMeasure, LandedCostFragment, ShipmentRatingFragment } from "../../../types/generated/graphql.internal.types";
|
|
4
4
|
type Step = 'customer-info' | 'shipping' | 'payment' | 'finish' | 'error';
|
|
5
5
|
export type TabItem = {
|
|
6
6
|
index: number;
|
|
@@ -11,11 +11,11 @@ export type TabItem = {
|
|
|
11
11
|
export type TabItems = Record<TabItem['value'], TabItem>;
|
|
12
12
|
export type ItemMeasurement = {
|
|
13
13
|
/** Indicates what type of `Measurement`, e.g. weight, specific dim unit. */
|
|
14
|
-
type
|
|
14
|
+
type: ItemMeasurementType;
|
|
15
15
|
/** Indicates the `Measurement` units to be used. */
|
|
16
|
-
unitOfMeasure
|
|
16
|
+
unitOfMeasure: ItemUnitOfMeasure;
|
|
17
17
|
/** The `Measurement` value. */
|
|
18
|
-
value
|
|
18
|
+
value: number;
|
|
19
19
|
};
|
|
20
20
|
type MappedCheckoutLandedCost = CheckoutPresentmentFragment & {
|
|
21
21
|
landedCost: LandedCostFragment;
|
|
@@ -31,8 +31,8 @@ export type CartItem = {
|
|
|
31
31
|
key: string;
|
|
32
32
|
value: string;
|
|
33
33
|
}[];
|
|
34
|
-
countryOfOrigin?:
|
|
35
|
-
currencyCode:
|
|
34
|
+
countryOfOrigin?: CountryCode;
|
|
35
|
+
currencyCode: CurrencyCode;
|
|
36
36
|
description?: string;
|
|
37
37
|
hsCode?: string;
|
|
38
38
|
imageUrl?: string;
|
|
@@ -120,7 +120,7 @@ declare const cartStoreCheckItemRestrictions: (itemsWorkflow: ItemWorkflowInfo[]
|
|
|
120
120
|
cartItems: CartItemToUse[];
|
|
121
121
|
restrictedItems: {
|
|
122
122
|
restriction: {
|
|
123
|
-
action: import("src/types/generated/graphql.
|
|
123
|
+
action: import("src/types/generated/graphql.internal.types").RestrictedItemAction;
|
|
124
124
|
reason: string;
|
|
125
125
|
};
|
|
126
126
|
amount: number;
|
|
@@ -164,7 +164,7 @@ type CartStoreRecalculateTotalParams = Omit<Parameters<typeof stripeStoreUpdateC
|
|
|
164
164
|
*/
|
|
165
165
|
declare const cartStoreHasOneEligibleItem: () => boolean;
|
|
166
166
|
declare const cartStoreSetCheckoutSession: (checkoutSession: CheckoutSessionDetailsFragment) => void;
|
|
167
|
-
declare const cartStoreReCalculateTotal: ({
|
|
167
|
+
declare const cartStoreReCalculateTotal: ({ adjustmentsAmount, cartId, currency, itemsAmount, landedCostId, }: CartStoreRecalculateTotalParams) => Promise<boolean>;
|
|
168
168
|
declare const cartStoreUpdateSelectedShippingOption: (selectedShippingOption: ShipmentRatingFragment, landedCostId: string) => Promise<boolean>;
|
|
169
169
|
declare const cartStoreStartCheckoutInterval: ({ isPreview, sessionTimeout, }: {
|
|
170
170
|
isPreview: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PayPalButtonsComponent } from '@paypal/paypal-js';
|
|
2
|
-
import type { CurrencyCode, ElementsUiStyle } from "../../../types/generated/graphql.
|
|
2
|
+
import type { CurrencyCode, ElementsUiStyle } from "../../../types/generated/graphql.internal.types";
|
|
3
3
|
type PaypalStore = {
|
|
4
4
|
/**
|
|
5
5
|
* Zonos order id created by paypal
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { PaymentIntent, Stripe, StripeAddressElement, StripeAddressElementChangeEvent, StripeElements, StripeElementsOptions, StripeLinkAuthenticationElement, StripeLinkAuthenticationElementChangeEvent, StripePaymentElement, StripePaymentElementChangeEvent } from '@stripe/stripe-js';
|
|
2
2
|
import type { containsNonLatinChars } from "../../utils/containsNonLatinChars";
|
|
3
|
+
import type { CheckoutSessionUpdateRequest } from "../../../types/checkout/api/CheckoutSession";
|
|
3
4
|
import type { TranslatedAddressObject } from "../../../types/checkout/TranslatedText";
|
|
4
|
-
import type { CheckoutSessionUpdateMutation,
|
|
5
|
+
import type { CheckoutSessionUpdateMutation, ElementsUiStyle, ElementsUiTheme } from "../../../types/generated/graphql.internal.types";
|
|
5
6
|
export type StripeStoreContactOption = {
|
|
6
7
|
address: {
|
|
7
8
|
city: string;
|
|
@@ -104,23 +105,10 @@ declare const stripeStoreConfirmPayment: () => Promise<void>;
|
|
|
104
105
|
* @returns {boolean} whether or not the checkout session is successfully created
|
|
105
106
|
*/
|
|
106
107
|
declare const stripeStoreInitCheckoutSession: () => Promise<boolean>;
|
|
107
|
-
type CheckoutSessionUpdateRequest = {
|
|
108
|
-
adjustmentAmount: number;
|
|
109
|
-
cartId: string | null;
|
|
110
|
-
currency?: string;
|
|
111
|
-
id: string;
|
|
112
|
-
itemsAmount?: number;
|
|
113
|
-
landedCostId?: string;
|
|
114
|
-
metadata?: {
|
|
115
|
-
key: string;
|
|
116
|
-
value: string;
|
|
117
|
-
}[];
|
|
118
|
-
presentmentCountryCode: CountryCode | null;
|
|
119
|
-
};
|
|
120
108
|
/**
|
|
121
109
|
* Update checkout session. Use for updating amount with landed cost id, or update session when cart items change
|
|
122
110
|
*/
|
|
123
|
-
declare const stripeStoreUpdateCheckoutSession: ({
|
|
111
|
+
declare const stripeStoreUpdateCheckoutSession: ({ adjustmentsAmount, cartId, currency, id, itemsAmount, landedCostId, presentmentCountryCode, }: CheckoutSessionUpdateRequest) => Promise<{
|
|
124
112
|
errors: import("../../..").JsonError[];
|
|
125
113
|
json: CheckoutSessionUpdateMutation | null;
|
|
126
114
|
}>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { type CountryLandedCost } from "../../utils/api/getCountryLandedCost";
|
|
3
3
|
import { type TargetFormat } from "../../utils/api/getExchangeRate";
|
|
4
|
-
import type { CountryCode, CurrencyCode, InclusivePriceSettingFieldsFragment } from "../../../types/generated/graphql.customer.types";
|
|
5
4
|
import type { Locale_ElementsSupportedLocationCode_Enum, Locale_PageName_Enum } from "../../../types/generated/graphql.frontend.types";
|
|
5
|
+
import type { CountryCode, CurrencyCode, InclusivePriceSettingFieldsFragment } from "../../../types/generated/graphql.internal.types";
|
|
6
6
|
import type { ICountryJson } from "../../../types/ICountryJson";
|
|
7
7
|
export type ExchangeRateForUse = {
|
|
8
8
|
rate: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CurrencyConverter, LoadZonosParamsConfig } from "../../scripts/_zonosBase";
|
|
2
2
|
import type { CheckoutConfig } from "../../types/checkout/CheckoutConfig";
|
|
3
|
-
import type { CountryCode, ElementsUiStyle, ElementsUiTheme, ZonosAttribution, ZonosSettingsQuery } from "../../types/generated/graphql.
|
|
3
|
+
import type { CountryCode, ElementsUiStyle, ElementsUiTheme, ZonosAttribution, ZonosSettingsQuery } from "../../types/generated/graphql.internal.types";
|
|
4
4
|
import type { HelloConfig } from "../../types/hello/HelloConfig";
|
|
5
5
|
export type AppearanceConfig = {
|
|
6
6
|
colorPrimary?: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CalculateLandedCostMutation } from "../../../types/generated/graphql.
|
|
1
|
+
import type { CalculateLandedCostMutation } from "../../../types/generated/graphql.internal.types";
|
|
2
2
|
export declare const calculateLandedCost: (abortController?: AbortController) => Promise<CalculateLandedCostMutation>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CalculateLandedCostMutation } from "../../../types/generated/graphql.
|
|
1
|
+
import type { CalculateLandedCostMutation } from "../../../types/generated/graphql.internal.types";
|
|
2
2
|
export declare const calculateLandedCostNormalized: (abortController: AbortController) => Promise<CalculateLandedCostMutation>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CartCalculateLandedCostMutation } from "../../../types/generated/graphql.
|
|
1
|
+
import type { CartCalculateLandedCostMutation } from "../../../types/generated/graphql.internal.types";
|
|
2
2
|
export declare const cartCalculateLandedCost: ({ abortController, cartId, }: {
|
|
3
3
|
abortController?: AbortController;
|
|
4
4
|
cartId: string;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
name: string;
|
|
5
|
-
};
|
|
6
|
-
export declare const checkItemRestrictions: ({ items, shipFrom, shipTo, }: {
|
|
7
|
-
items: Item[];
|
|
8
|
-
shipFrom: CountryCode;
|
|
9
|
-
shipTo: CountryCode;
|
|
10
|
-
}) => Promise<{
|
|
11
|
-
action: import("src/types/generated/graphql.customer.types").ItemRestrictionAction | null;
|
|
1
|
+
import type { CheckItemRestrictionRequest } from "../../../types/hello/RestrictedItem";
|
|
2
|
+
export declare const checkItemRestrictions: ({ items, shipFrom, shipTo, }: CheckItemRestrictionRequest) => Promise<{
|
|
3
|
+
action: import("src/types/generated/graphql.internal.types").ItemRestrictionAction | null;
|
|
12
4
|
id: string;
|
|
13
5
|
itemDescription: string | null;
|
|
14
6
|
itemRestrictions: ({
|
|
@@ -16,7 +8,6 @@ export declare const checkItemRestrictions: ({ items, shipFrom, shipTo, }: {
|
|
|
16
8
|
id: string;
|
|
17
9
|
note: string;
|
|
18
10
|
sources: (string | null)[] | null;
|
|
19
|
-
type: import("src/types/generated/graphql.
|
|
11
|
+
type: import("src/types/generated/graphql.internal.types").ItemRestrictionType;
|
|
20
12
|
} | null)[] | null;
|
|
21
13
|
}[]>;
|
|
22
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CountryCode } from "../../../types/index";
|
|
2
|
-
import type { InclusivePriceSettingFieldsFragment } from "../../../types/generated/graphql.
|
|
2
|
+
import type { InclusivePriceSettingFieldsFragment } from "../../../types/generated/graphql.internal.types";
|
|
3
3
|
export type ZonosInclusivePriceSetting = {
|
|
4
4
|
setting: InclusivePriceSettingFieldsFragment | null;
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getShippingZones: () => Promise<import("src/types/generated/graphql.
|
|
1
|
+
export declare const getShippingZones: () => Promise<import("src/types/generated/graphql.internal.types").CountryCode[] | null>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ZonosSettingsQuery } from "../../../types/generated/graphql.
|
|
1
|
+
import type { ZonosSettingsQuery } from "../../../types/generated/graphql.internal.types";
|
|
2
2
|
export declare const getZonosSettings: () => Promise<{
|
|
3
3
|
errors: import("../../..").JsonError[];
|
|
4
4
|
json: null;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
paypalMockResponse: PaypalMockResponse | null;
|
|
5
|
-
};
|
|
6
|
-
export declare const paypalCaptureOrder: ({ checkoutSessionId, paypalMockResponse, }: PaypalCaptureOrderPayload) => Promise<{
|
|
1
|
+
import type { PaypalCaptureOrderRequest } from "../../../types/checkout/api/Paypal";
|
|
2
|
+
import type { PaypalOrderCaptureMutation } from "../../../types/generated/graphql.internal.types";
|
|
3
|
+
export declare const paypalCaptureOrder: ({ checkoutSessionId, paypalMockResponse, }: PaypalCaptureOrderRequest) => Promise<{
|
|
7
4
|
errors: import("../../..").JsonError[];
|
|
8
5
|
json: PaypalOrderCaptureMutation | null;
|
|
9
6
|
}>;
|
|
10
|
-
export {};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
export declare const paypalCreateOrder: ({ checkoutSessionId, }: PaypalCreateOrderPayload) => Promise<{
|
|
1
|
+
import type { PaypalCreateOrderRequest } from "../../../types/checkout/api/Paypal";
|
|
2
|
+
import type { PaypalOrderCreateMutation } from "../../../types/generated/graphql.internal.types";
|
|
3
|
+
export declare const paypalCreateOrder: ({ checkoutSessionId, }: PaypalCreateOrderRequest) => Promise<{
|
|
6
4
|
errors: import("../../..").JsonError[];
|
|
7
5
|
json: PaypalOrderCreateMutation | null;
|
|
8
6
|
}>;
|
|
9
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CalculateLandedCostRequest, CartCalculateLandedCostRequest } from "../../../types/checkout/api/
|
|
1
|
+
import type { CalculateLandedCostRequest, CartCalculateLandedCostRequest } from "../../../types/checkout/api/CalculateLandedCost";
|
|
2
2
|
/**
|
|
3
3
|
* Similar to prepCalculateLandedCost except it only uses
|
|
4
4
|
*/
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
type ConversionEvent
|
|
1
|
+
import type { ConversionEvent } from "../../../types/ConversionEvent";
|
|
2
2
|
export declare const trackConversionEvent: (eventName: ConversionEvent, metadata?: Record<string, unknown>) => Promise<void>;
|
|
3
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CalculateLandedCostRequest } from "../../../types/checkout/api/
|
|
2
|
-
import type { CalculateLandedCostMutation } from "../../../types/generated/graphql.
|
|
1
|
+
import type { CalculateLandedCostRequest } from "../../../types/checkout/api/CalculateLandedCost";
|
|
2
|
+
import type { CalculateLandedCostMutation } from "../../../types/generated/graphql.internal.types";
|
|
3
3
|
export type BuildLandedCostParams = {
|
|
4
4
|
billingAddress: CalculateLandedCostRequest['billingAddress'];
|
|
5
5
|
billingContact: CalculateLandedCostRequest['billingContact'];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StripeAddressElementChangeEvent } from '@stripe/stripe-js';
|
|
2
2
|
import type { containsNonLatinChars } from "../containsNonLatinChars";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ValidateAddressRequest } from "../../../types/checkout/api/ValidateAddress";
|
|
4
4
|
type Params = {
|
|
5
5
|
addressInvalidCharactersList: ReturnType<typeof containsNonLatinChars> | null;
|
|
6
6
|
billingAddressInvalidCharactersList: ReturnType<typeof containsNonLatinChars> | null;
|
|
@@ -20,7 +20,7 @@ type Params = {
|
|
|
20
20
|
* @param {StripeAddressEventData} params.stripeBillingAddressEventData - The Stripe event data for the billing address.
|
|
21
21
|
* @param {boolean} params.stripeShippingSameAsBilling - A flag indicating whether the shipping address is the same as the billing address.
|
|
22
22
|
*
|
|
23
|
-
* @returns {
|
|
23
|
+
* @returns {ValidateAddressRequest | null} - An object that contains the address fields that have invalid characters, the destination country, and the first and last name. If the conditions are not met, the function returns null.
|
|
24
24
|
*/
|
|
25
|
-
export declare const
|
|
25
|
+
export declare const buildTranslateRequest: ({ addressInvalidCharactersList, billingAddressInvalidCharactersList, stripeAddressEventData, stripeBillingAddressEventData, stripeShippingSameAsBilling, }: Params) => ValidateAddressRequest | null;
|
|
26
26
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CurrencyCode } from "../../../../types/generated/graphql.
|
|
1
|
+
import type { CurrencyCode } from "../../../../types/generated/graphql.internal.types";
|
|
2
2
|
export declare const currencyFormat: ({ amount, currency, }: {
|
|
3
3
|
amount: number;
|
|
4
4
|
currency?: CurrencyCode;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CountryCode } from "../../../../types/index";
|
|
2
|
-
import type { CurrencyCode } from "../../../../types/generated/graphql.
|
|
2
|
+
import type { CurrencyCode } from "../../../../types/generated/graphql.internal.types";
|
|
3
3
|
export declare const getCurrencyCode: (code: CountryCode) => CurrencyCode | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TargetFormat } from "../../api/getExchangeRate";
|
|
2
|
-
import type { CurrencyCode } from "../../../../types/generated/graphql.
|
|
2
|
+
import type { CurrencyCode } from "../../../../types/generated/graphql.internal.types";
|
|
3
3
|
type NumberFormatParams = {
|
|
4
4
|
amount: number;
|
|
5
5
|
currency: CurrencyCode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Product } from "../../../types/hello/Product";
|
|
2
2
|
export declare const detectItemRestrictions: (newProducts: Product[]) => Promise<{
|
|
3
3
|
name: string;
|
|
4
|
-
action: import("../../../types/generated/graphql.
|
|
4
|
+
action: import("../../../types/generated/graphql.internal.types").ItemRestrictionAction | null;
|
|
5
5
|
id: string;
|
|
6
6
|
itemDescription: string | null;
|
|
7
7
|
itemRestrictions: ({
|
|
@@ -9,6 +9,6 @@ export declare const detectItemRestrictions: (newProducts: Product[]) => Promise
|
|
|
9
9
|
id: string;
|
|
10
10
|
note: string;
|
|
11
11
|
sources: (string | null)[] | null;
|
|
12
|
-
type: import("../../../types/generated/graphql.
|
|
12
|
+
type: import("../../../types/generated/graphql.internal.types").ItemRestrictionType;
|
|
13
13
|
} | null)[] | null;
|
|
14
14
|
}[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HelloMobileLocation, HelloSettingFragment } from "../../../types/generated/graphql.
|
|
1
|
+
import type { HelloMobileLocation, HelloSettingFragment } from "../../../types/generated/graphql.internal.types";
|
|
2
2
|
export declare const initHello: (helloSettings: Omit<Partial<HelloSettingFragment>, 'mobileLocation'> & {
|
|
3
3
|
desktopLocation?: HelloMobileLocation | null;
|
|
4
4
|
mobileLocation: HelloMobileLocation | null;
|