@zonos/elements 1.3.12-alpha.10 → 1.3.12-alpha.11
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/{submitGtag-d0718b63.js → submitGtag-79dbdad0.js} +11 -3
- package/dist/cjs/zonos-cart-items_10.cjs.entry.js +1 -1
- package/dist/cjs/zonos-checkout.cjs.entry.js +1 -1
- package/dist/collection/components/utils/api/trackConversionEvent.js +12 -3
- package/dist/collection/scripts/zonosBase.js +1 -0
- package/dist/collection/types/generated/graphql.frontend.types.js +3 -0
- package/dist/components/trackConversionEvent.js +12 -4
- package/dist/esm/{submitGtag-4c1f09dc.js → submitGtag-9ec64109.js} +12 -4
- package/dist/esm/zonos-cart-items_10.entry.js +1 -1
- package/dist/esm/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/{submitGtag-4c1f09dc.js → submitGtag-9ec64109.js} +1 -1
- package/dist/esm-es5/zonos-cart-items_10.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/scripts/zonosBase.js +1 -1
- package/dist/types/scripts/zonosBase.d.ts +5 -0
- package/dist/types/types/generated/graphql.frontend.types.d.ts +15 -0
- package/dist/types/types/generated/graphql.frontend.types.ts +28 -0
- package/dist/zonos-elements/p-2b916526.js +1 -0
- package/dist/zonos-elements/{p-3eb402c8.entry.js → p-2d5c8eb7.entry.js} +1 -1
- package/dist/zonos-elements/{p-a6c9c505.system.js → p-5fdf59db.system.js} +1 -1
- package/dist/zonos-elements/p-6e81adba.system.js +1 -1
- package/dist/zonos-elements/{p-8eb876e8.system.entry.js → p-8de91e15.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-2da8e12a.system.entry.js → p-d117ea39.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-e4919505.entry.js → p-ea06d683.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-0c5d3595.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(o,e,t,n){function s(o){return o instanceof t?o:new t((function(e){e(o)}))}return new(t||(t=Promise))((function(t,r){function c(o){try{a(n.next(o))}catch(o){r(o)}}function i(o){try{a(n["throw"](o))}catch(o){r(o)}}function a(o){o.done?t(o.value):s(o.value).then(c,i)}a((n=n.apply(o,e||[])).next())}))};var __generator=this&&this.__generator||function(o,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,s,r,c;return c={next:i(0),throw:i(1),return:i(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function i(o){return function(e){return a([o,e])}}function a(i){if(n)throw new TypeError("Generator is already executing.");while(c&&(c=0,i[0]&&(t=0)),t)try{if(n=1,s&&(r=i[0]&2?s["return"]:i[0]?s["throw"]||((r=s["return"])&&r.call(s),0):s.next)&&!(r=r.call(s,i[1])).done)return r;if(s=0,r)i=[i[0]&2,r.value];switch(i[0]){case 0:case 1:r=i;break;case 4:t.label++;return{value:i[1],done:false};case 5:t.label++;s=i[1];i=[0];continue;case 7:i=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(i[0]===6||i[0]===2)){t=0;continue}if(i[0]===3&&(!r||i[1]>r[0]&&i[1]<r[3])){t.label=i[1];break}if(i[0]===6&&t.label<r[1]){t.label=r[1];r=i;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(i);break}if(r[2])t.ops.pop();t.trys.pop();continue}i=e.call(o,t)}catch(o){i=[6,o];s=0}finally{n=r=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};import{r as registerInstance,h,F as Fragment,H as Host}from"./index-dd40cc85.js";import{l as localizationStore,a as log,s as stripeStoreGetDomesticShippingSession,b as localizationStoreUpdateSelectedCountryCode,c as stripeStoreCleanupDomesticShippingSession,d as logError,e as stripeStoreSaveDomesticShippingSession,i as initStripeElements,f as cartStore,g as cartStoreUpdateItems,h as cartStoreReset,j as stripeStore,k as stripeStoreInitCheckoutSession,m as cartStoreUpdateToErrorState,t as translate,n as stripeStorePrefetchLandedCost,o as cartStoreNextStep,p as stripeStoreConfirmPayment,q as stripeStoreReset}from"./cart-7961927b.js";import{z as zonosStore,g as getZonosStoreTheme,m as mergeConfig}from"./zonosStore-c4c45591.js";import{c as createCustomEvent,s as submitGtag,t as trackConversionEvent}from"./submitGtag-4c1f09dc.js";import{s as sendErrorLog,i as isCheckoutMobile}from"./sendErrorLog-4d9581da.js";import{c as classes}from"./classes-0d95c529.js";import{g as getBorderRadius}from"./getBorderRadius-a89e45fb.js";import{i as isDarkColor}from"./isDarkColor-6bf71e51.js";var objAttribute=function(o){var e=o.key,t=o.value;return t?{key:e,value:t}:null};var getAttributes=function(o){return[objAttribute({key:"brand",value:o.itemBrand}),objAttribute({key:"material",value:o.itemMaterial}),objAttribute({key:"category",value:o.itemCategory}),objAttribute({key:"color",value:o.itemColor}),objAttribute({key:"customization",value:o.itemCustomization}),objAttribute({key:"descriptionDetailed",value:o.itemDescriptionDetailed}),objAttribute({key:"fabricContent",value:o.itemFabricContent}),objAttribute({key:"ltlClass",value:o.itemLtlClass}),objAttribute({key:"pickingLocation",value:o.itemPickingLocation}),objAttribute({key:"shipFromLocation",value:o.itemShipFromLocation}),objAttribute({key:"size",value:o.itemSize}),objAttribute({key:"status",value:o.status})].filter(Boolean)};var getItemWeightUnit=function(o){if(!o){return"POUND"}switch(o.toUpperCase()){case"KG":return"KILOGRAM";case"OZ":return"OUNCE";case"G":return"GRAM";default:return"POUND"}};var getMeasurements=function(o){if(!o){return[]}var e=[];if(o.length){e.push({type:"LENGTH",unitOfMeasure:"INCH",value:o.length})}if(o.width){e.push({type:"WIDTH",unitOfMeasure:"INCH",value:o.width})}if(o.weight){e.push({type:"WEIGHT",unitOfMeasure:getItemWeightUnit(o.weightUnits),value:o.weight})}if(o.height){e.push({type:"HEIGHT",unitOfMeasure:"INCH",value:o.height})}return e};var buildCartItemsByTempCart=function(o){var e;var t=((e=o===null||o===void 0?void 0:o.items)===null||e===void 0?void 0:e.map((function(o){return{amount:o.unitPrice||0,attributes:getAttributes(o),countryOfOrigin:o.countryOfOrigin||undefined,currencyCode:"USD",description:o.itemDescriptionLong||"",imageUrl:o.imageURL||"",itemType:"PHYSICAL_GOOD",measurements:getMeasurements(o),name:o.description||"",productId:o.productId||"",quantity:o.quantity||0,sku:o.sku||""}})))||[];return t};var isShippableCountry=function(o){if(o===void 0){o=true}if(!localizationStore.localizationLoaded){return false}if(!localizationStore.isShippableCountry){document.dispatchEvent(createCustomEvent("legacyCheckoutError","Unable to initiate checkout process in a country where shipping is not available"));if(o){log("Checkout: not shippable country")}return false}return true};var watchBigcommerceDomesticCheckout=function(o){var e=o.domesticRedirectedBtnSelector,t=o.onShippingAddressSessionFound;if(!window.Zonos.isBigCommerce){return}var n=new MutationObserver((function(){return __awaiter(void 0,void 0,void 0,(function(){var o,s,r,c,i;return __generator(this,(function(a){o=document.querySelector(e);s=stripeStoreGetDomesticShippingSession();if(!o&&s){r=document.createElement("button");r.style.display="none";r.id="zonos--domestic-redirected-checkout-button";document.body.appendChild(r);t===null||t===void 0?void 0:t(s);n.disconnect();return[2]}c=document.querySelector('select[name="shippingAddress.countryCode"]');i=document.querySelector("#checkout-shipping-continue");if(!c||!i){return[2]}n.disconnect();i.addEventListener("click",(function(o){return __awaiter(void 0,void 0,void 0,(function(){var e,t,n,s,r,i,a;return __generator(this,(function(u){n=c.value;if(!n){return[2]}localizationStoreUpdateSelectedCountryCode(n);if(!isShippableCountry(false)){stripeStoreCleanupDomesticShippingSession();return[2]}s=document.querySelector("form");if(!s){return[2]}r=new FormData(s);i=document.querySelector("input#addressLine1Input");a={address1:(e=r.get("shippingAddress.address1"))!==null&&e!==void 0?e:i&&i.value,address2:r.get("shippingAddress.address2"),city:r.get("shippingAddress.city"),countryCode:r.get("shippingAddress.countryCode"),firstName:r.get("shippingAddress.firstName"),lastName:r.get("shippingAddress.lastName"),phone:r.get("shippingAddress.phone"),postalCode:r.get("shippingAddress.postalCode"),stateOrProvince:(t=r.get("shippingAddress.stateOrProvince"))!==null&&t!==void 0?t:r.get("shippingAddress.stateOrProvinceCode")};if(Object.values(a).some((function(o){return o===undefined||o===null}))){logError("One or more shipping address field is missing",Object.entries(a));void sendErrorLog({endpoint:"No endpoint, domestic checkout form missing fields",errors:["Bigcommerce: One or more shipping address field is missing in the domestic checkout form",JSON.stringify(Object.entries(a))],metadata:{domain:window.location.hostname,storeId:zonosStore.storeId}});return[2]}stripeStoreSaveDomesticShippingSession({address1:a.address1,address2:a.address2,city:a.city,countryCode:a.countryCode,firstName:a.firstName,lastName:a.lastName,phone:a.phone,postalCode:a.postalCode,state:a.stateOrProvince});o.preventDefault();o.stopPropagation();window.location.href="/";return[2]}))}))}));return[2]}))}))}));n.observe(document.body,{childList:true,subtree:true})};var MessageIcon='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="https://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 4.5C2.25 3.25736 3.25736 2.25 4.5 2.25H13.5C14.7426 2.25 15.75 3.25736 15.75 4.5V10.5C15.75 11.7426 14.7426 12.75 13.5 12.75H8.25C8.01393 12.75 7.79164 12.8611 7.65 13.05L6.3 14.85C5.87508 15.4166 5.2082 15.75 4.5 15.75C3.25736 15.75 2.25 14.7426 2.25 13.5V4.5ZM4.5 3.75C4.08579 3.75 3.75 4.08579 3.75 4.5V13.5C3.75 13.9142 4.08579 14.25 4.5 14.25C4.73607 14.25 4.95836 14.1389 5.1 13.95L6.45 12.15C6.87492 11.5834 7.5418 11.25 8.25 11.25H13.5C13.9142 11.25 14.25 10.9142 14.25 10.5V4.5C14.25 4.08579 13.9142 3.75 13.5 3.75H4.5ZM5.25 6C5.25 5.58579 5.58579 5.25 6 5.25H12C12.4142 5.25 12.75 5.58579 12.75 6C12.75 6.41421 12.4142 6.75 12 6.75H6C5.58579 6.75 5.25 6.41421 5.25 6ZM5.25 9C5.25 8.58579 5.58579 8.25 6 8.25H8.25C8.66421 8.25 9 8.58579 9 9C9 9.41421 8.66421 9.75 8.25 9.75H6C5.58579 9.75 5.25 9.41421 5.25 9Z" fill="#4D505A"/>\n</svg>\n';var RemoveIcon='<svg color="var(--amino-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--amino-gray-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>';var zonosCheckoutCss=".sc-zonos-checkout-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-checkout-h *.sc-zonos-checkout{font-family:var(--font-family, Inter), Inter}.sc-zonos-checkout-h img.sc-zonos-checkout{max-width:100%}.sc-zonos-checkout-h dl.sc-zonos-checkout,.sc-zonos-checkout-h dd.sc-zonos-checkout,.sc-zonos-checkout-h h1.sc-zonos-checkout,.sc-zonos-checkout-h h2.sc-zonos-checkout,.sc-zonos-checkout-h h3.sc-zonos-checkout,.sc-zonos-checkout-h h4.sc-zonos-checkout,.sc-zonos-checkout-h h5.sc-zonos-checkout,.sc-zonos-checkout-h h6.sc-zonos-checkout,.sc-zonos-checkout-h hr.sc-zonos-checkout,.sc-zonos-checkout-h figure.sc-zonos-checkout,.sc-zonos-checkout-h p.sc-zonos-checkout,.sc-zonos-checkout-h pre.sc-zonos-checkout{margin:0}.sc-zonos-checkout-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar{width:10px}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-track{background:var(--amino-gray-50)}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;border-radius:var(--border-radius, var(--amino-radius-10))}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex:1;flex:1;padding:var(--amino-space-32)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{background-color:var(--primary-color, var(--amino-gray-0));border-right:1px solid var(--amino-gray-200)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{background-color:var(--amino-gray-0)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:100%;max-height:100%;height:100%;overflow:auto;-ms-flex-direction:column;flex-direction:column;background-color:var(--amino-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:var(--amino-space-24);padding-bottom:50px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout img.sc-zonos-checkout{width:150px;min-width:150px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--logo.sc-zonos-checkout{margin-bottom:0}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout zonos-checkout-finish.sc-zonos-checkout{-ms-flex:1;flex:1}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{padding:0 var(--amino-space-8) var(--amino-space-8)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--payment-error-banner.sc-zonos-checkout{margin-top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout{position:relative}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout .zonos--close-button.sc-zonos-checkout{position:absolute;right:var(--amino-space-24);top:var(--amino-space-24);z-index:2}.sc-zonos-checkout-h .zonos--wrapper.sc-zonos-checkout{overflow:auto;max-height:100%;position:relative}.sc-zonos-checkout-h .flex--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;max-height:100%}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--checkout-default-message.sc-zonos-checkout{margin-left:var(--amino-space-76);margin-bottom:var(--amino-space-8)}.preview.sc-zonos-checkout-h{min-width:500px;margin:auto}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{border:var(--amino-border)}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{padding:var(--amino-space-32)}.mobile.sc-zonos-checkout-h{min-width:auto}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:auto;border-radius:0;max-height:100%;height:100%;border:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding:var(--amino-space-12);padding-bottom:var(--amino-space-76)}@media (max-width: 768px){.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding-bottom:var(--amino-space-0)}}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{-ms-flex-order:2;order:2;border-right:none}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex-order:1;order:1;padding-top:var(--amino-space-16)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;border:var(--amino-border);border-radius:var(--border-radius, var(--amino-radius-10));background-color:var(--amino-gray-50);padding:var(--amino-space-12);margin-top:var(--amino-space-32)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--review.sc-zonos-checkout{margin-bottom:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--cart-items.sc-zonos-checkout{margin-top:var(--amino-space-8)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout zonos-checkout-footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{max-height:100%}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:auto}.mobile.sc-zonos-checkout-h .zonos--cart-subtotal.sc-zonos-checkout{margin:0}";var ZonosCheckoutStyle0=zonosCheckoutCss;var ZonosCheckout=function(){function o(o){var e=this;registerInstance(this,o);this.applyStripeTheme=function(){return __awaiter(e,void 0,void 0,(function(){var o,e,t,n,s;return __generator(this,(function(r){switch(r.label){case 0:s=((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme)||zonosStore.appearance.theme;return[4,initStripeElements({overrideBorderRaidus:(e=this.appearanceSettingsOverride)===null||e===void 0?void 0:e.style,overridePrimaryColor:(t=this.appearanceSettingsOverride)===null||t===void 0?void 0:t.colorPrimary,overrideSecondaryColor:(n=this.appearanceSettingsOverride)===null||n===void 0?void 0:n.colorSecondary,overrideTheme:this.isMobile?s:undefined})];case 1:r.sent();return[2]}}))}))};this.getCurrentLocalePageEnum=function(){switch(cartStore.step){case"customer-info":return"checkout_customer_info";case"shipping":return"checkout_shipping_info";case"payment":return"checkout_payment_info";default:return null}};this.appearanceSettingsOverride=undefined;this.preview=false;this.mobile=false;this.defaultAddress=null;this.forceDialogOpen=false;this.open=this.forceDialogOpen;this.stripe=window.Zonos.stripe;this.submitLoading=false;this.paymentError=false;this.collapseReviewMobile=true;this.isAttachError=false;this.isMobile=false;this.zonosReviewRef=undefined;this.storybookPaymentStatusOverride=undefined;this.domesticRedirectedBtnSelector="#zonos--domestic-redirected-checkout-button";this.legacyCheckoutHiddenBtnSelector="#legacy-checkout-hidden-button";this.isLegacyCheckout=false}o.prototype.initCartInfoHandler=function(o){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){e=o.detail;void cartStoreUpdateItems(e);return[2]}))}))};o.prototype.closeDialogHandler=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){submitGtag("zonos-checkout-close");this.open=this.forceDialogOpen||false;if(!this.preview&&cartStore.step==="finish"){cartStoreReset()}cartStore.step="customer-info";return[2]}))}))};o.prototype.buildCartAndInit=function(){return __awaiter(this,void 0,void 0,(function(){var o,e,t;return __generator(this,(function(n){switch(n.label){case 0:if(!window.Zonos.tempCartData)return[3,2];o=buildCartItemsByTempCart(window.Zonos.tempCartData);return[4,cartStoreUpdateItems(o)];case 1:n.sent();return[3,5];case 2:if(!zonosStore.checkoutSettings.buildCartDetail)return[3,5];log("build cart detail");return[4,zonosStore.checkoutSettings.buildCartDetail()];case 3:e=n.sent();return[4,cartStoreUpdateItems(e)];case 4:n.sent();n.label=5;case 5:if(!!stripeStore.clientSecret)return[3,7];return[4,stripeStoreInitCheckoutSession()];case 6:t=n.sent();log("stripeStoreInitCheckoutSession: ".concat(t));if(!t){return[2,false]}n.label=7;case 7:return[4,this.applyStripeTheme()];case 8:n.sent();return[2,true]}}))}))};o.prototype.attachCheckout=function(){var o=this;var e=zonosStore.checkoutSettings.placeOrderButtonSelector;if(!e){return}var t=document.querySelectorAll("".concat(e,", ").concat(this.domesticRedirectedBtnSelector));t.forEach((function(e){var t=e.getAttribute("data-zonos-checkout-attached");if(t){return}e.addEventListener("click",(function(e){return __awaiter(o,void 0,void 0,(function(){var o,t;return __generator(this,(function(n){switch(n.label){case 0:if(!isShippableCountry()){return[2]}e.preventDefault();e.stopPropagation();log("zonos checkout button clicked");stripeStore.isFetchingSession=true;this.open=true;n.label=1;case 1:n.trys.push([1,3,,4]);return[4,this.buildCartAndInit()];case 2:o=n.sent();if(!o){throw new Error("Error building cart")}submitGtag("zonos-checkout-start");void trackConversionEvent("checkout_open");return[3,4];case 3:t=n.sent();stripeStore.isFetchingSession=false;cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[3,4];case 4:return[2]}}))}))}));e.removeAttribute("disabled");e.setAttribute("data-zonos-checkout-attached","true");if(e.matches(o.domesticRedirectedBtnSelector)){e.dispatchEvent(createCustomEvent("click"));stripeStoreCleanupDomesticShippingSession();e.remove()}if(e.matches(o.legacyCheckoutHiddenBtnSelector)){o.isLegacyCheckout=true;e.dispatchEvent(createCustomEvent("click"));e.remove()}}))};o.prototype.appearanceSettingsOverrideChanged=function(){if(!this.appearanceSettingsOverride){return}void this.applyStripeTheme()};o.prototype.useLegacyQueryParam=function(){var o=new URLSearchParams(window.location.search);var e={country:o.get("country"),customerAddress1:o.get("customerAddress1"),customerAddress2:o.get("customerAddress2"),customerCity:o.get("customerCity"),customerEmail:o.get("customerEmail"),customerName:o.get("customerName"),customerPhone:o.get("customerPhone"),customerState:o.get("customerState"),customerZip:o.get("customerZip")};if(!e.customerAddress1||!e.customerCity||!e.customerName||!e.customerPhone||!e.customerState||!e.customerZip||!e.country){return}this.defaultAddress={address:{city:e.customerCity,country:e.country,line1:e.customerAddress1,line2:e.customerAddress2||"",postal_code:e.customerZip,state:e.customerState},name:e.customerName,phone:e.customerPhone}};o.prototype.init=function(){return __awaiter(this,void 0,void 0,(function(){var o,e;var t=this;return __generator(this,(function(n){stripeStore.stripe=window.Zonos.stripe;this.stripe=window.Zonos.stripe;watchBigcommerceDomesticCheckout({domesticRedirectedBtnSelector:this.domesticRedirectedBtnSelector,onShippingAddressSessionFound:function(o){t.defaultAddress={address:{city:o.city,country:o.countryCode,line1:o.address1,line2:o.address2,postal_code:o.postalCode,state:o.state},name:"".concat(o.firstName," ").concat(o.lastName),phone:o.phone}}});if(window.Zonos.tempCartData){this.useLegacyQueryParam()}o=setInterval((function(){var e=window.Zonos.internationalHideSelector;if(!e){clearInterval(o);return}var t=isShippableCountry(false);var n=document.querySelectorAll(e);if(!t){n===null||n===void 0?void 0:n.forEach((function(o){var e=o;var t=e.getAttribute("data-zonos-checkout-original-display")||getComputedStyle(e).display;e.style.display=t||"initial"}));return}n===null||n===void 0?void 0:n.forEach((function(o){var e=o;var t=e.style.display;e.setAttribute("data-zonos-checkout-original-display",t);e.style.display="none"}))}),100);e=setInterval((function(){stripeStore.stripe=window.Zonos.stripe;t.stripe=window.Zonos.stripe;if(!t.stripe){log("waiting for stripe to be loaded");return}if(t.storybookPaymentStatusOverride){clearInterval(e);return}log("init checkout");if(t.preview||t.forceDialogOpen){void t.buildCartAndInit()}else{t.attachCheckout();var o=new MutationObserver((function(){t.attachCheckout()}));o.observe(document.body,{childList:true,subtree:true})}clearInterval(e)}),50);setTimeout((function(){clearInterval(e)}),1e4);return[2]}))}))};o.prototype.setToFinishStep=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){cartStore.step="finish";this.storybookPaymentStatusOverride=o;return[2]}))}))};o.prototype.handleCustomerInfoContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;var e=this;return __generator(this,(function(t){switch(t.label){case 0:this.submitLoading=true;return[4,stripeStorePrefetchLandedCost()];case 1:t.sent();o=setInterval((function(){if(cartStore.landedCostData||!stripeStore.isFetchingLandedCost){if(cartStore.landedCostData){cartStoreNextStep()}e.submitLoading=false;clearInterval(o)}}),500);return[2]}}))}))};o.prototype.handleShippingContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o=this;return __generator(this,(function(e){this.submitLoading=true;setTimeout((function(){cartStoreNextStep();o.submitLoading=false}),500);return[2]}))}))};o.prototype.handleCheckoutPaymentContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;return __generator(this,(function(e){switch(e.label){case 0:this.paymentError=false;this.submitLoading=true;e.label=1;case 1:e.trys.push([1,3,,4]);return[4,stripeStoreConfirmPayment()];case 2:e.sent();cartStoreNextStep();return[3,4];case 3:o=e.sent();logError(o);this.paymentError=true;return[3,4];case 4:this.submitLoading=false;return[2]}}))}))};o.prototype.handleFinishClick=function(){return __awaiter(this,void 0,void 0,(function(){var o,e,t;return __generator(this,(function(n){switch(n.label){case 0:stripeStoreReset();if(!this.preview)return[3,2];cartStore.step="customer-info";return[4,this.init()];case 1:n.sent();return[2];case 2:cartStoreReset();if(this.isLegacyCheckout&&window.Zonos.tempCartData){o=window.Zonos.tempCartData.contShoppingURL;window.location.href=o;return[2]}e=window.location.href;t=e.split("?")[0];window.history.replaceState({},document.title,t);this.open=false;window.location.reload();return[2]}}))}))};o.prototype.handleWindowResize=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};o.prototype.handleMobileChange=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};o.prototype.handleAppearanceSettingsOverrideChange=function(){var o;if((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme){this.appearanceSettingsOverride.theme=getZonosStoreTheme(this.appearanceSettingsOverride.theme)}};o.prototype.componentWillLoad=function(){void this.init();this.isMobile=isCheckoutMobile(this.mobile);this.handleAppearanceSettingsOverrideChange();log("mobile: ".concat(this.isMobile))};o.prototype.disconnectedCallback=function(){stripeStoreReset();cartStoreReset()};o.prototype.render=function(){var o=this;var e;var t=cartStore.step!=="finish"&&cartStore.step!=="error"&&!stripeStore.stripeElements||stripeStore.isFetchingSession;var n=mergeConfig(zonosStore.appearance,this.appearanceSettingsOverride),s=n.colorPrimary,r=n.colorSecondary,c=n.logoUrl,i=n.style;var a=zonosStore.appearance.zonosAttribution==="ENABLED";var u=zonosStore.appearance.theme;var l=s&&isDarkColor(s)?"DARK":"LIGHT";var d=this.isMobile?u:l;var f=!this.isMobile?r:undefined;var m=localizationStore.customMessages;var z=(e=m.find((function(o){return o.pageName==="checkout_default"})))===null||e===void 0?void 0:e.message;var p=this.getCurrentLocalePageEnum();var k=m.filter((function(o){return o.pageName===p}));var v=function(){return h("div",{class:"zonos--logo"},c&&h("img",{alt:"".concat(zonosStore.organizationName," logo"),src:c,width:100}))};var g=function(){return h("zonos-v-stack",null,v(),h("zonos-checkout-progress-tabs",{backgroundColor:o.isMobile?"--amino-gray-0":null}),k.map((function(o){return h("zonos-custom-message",{icon:MessageIcon,message:o.message})})))};var b=function(){return h("div",{class:"zonos--content",style:{"--border-radius":getBorderRadius(i)}},cartStore.step!=="finish"&&cartStore.step!=="error"&&h(Fragment,null,h("div",{class:"zonos--left","data-theme":d,style:{"--primary-color":!o.isMobile?s:""}},!o.isMobile&&g(),cartStore.step==="customer-info"&&h("zonos-customer-info",{continueLoading:o.submitLoading,defaultAddress:o.defaultAddress,onContinueClicked:function(){return o.handleCustomerInfoContinue()},submitBtnColor:f}),cartStore.step==="shipping"&&h("zonos-shipping",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleShippingContinue()},submitBtnColor:f}),cartStore.step==="payment"&&h("zonos-checkout-payment",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleCheckoutPaymentContinue()},paymentError:o.paymentError,submitBtnColor:f})),h("div",{class:"zonos--right","data-theme":u},o.isMobile&&g(),!o.isLegacyCheckout&&h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon}),noBackground:true,onClick:function(){return o.closeDialogHandler()}}),h("div",{class:"flex--wrapper"},h("div",{class:"zonos--wrapper"},h("zonos-review",{collapsed:o.collapseReviewMobile,mobile:o.isMobile,onClick:function(){if(!o.isMobile){return}o.collapseReviewMobile=!o.collapseReviewMobile}}),h("zonos-collapse",{collapsed:o.collapseReviewMobile&&o.isMobile},h("zonos-cart-items",null),o.isMobile&&h("zonos-v-stack",{spacing:16},h("zonos-cart-subtotal",null),h("zonos-custom-message",{class:"zonos--checkout-default-message",icon:MessageIcon,message:z})))),!o.isMobile&&h("zonos-v-stack",{spacing:16},h("zonos-cart-subtotal",null),h("zonos-custom-message",{class:"zonos--checkout-default-message",icon:MessageIcon,message:z}))))),(cartStore.step==="finish"||cartStore.step==="error")&&h("div",{class:"zonos--done","data-theme":u},h("div",{class:"zonos--header"},v(),h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon}),noBackground:true,onClick:function(){return o.handleFinishClick()},theme:u})),h("zonos-checkout-finish",{borderRadius:i,onCloseClick:function(){return o.handleFinishClick()},overrideNotification:cartStore.step==="error"&&!!cartStore.error?Object.assign(Object.assign({},cartStore.error),{type:"error"}):undefined,storybookForceStatus:o.storybookPaymentStatusOverride})),h("zonos-checkout-footer",{"data-theme":u,mobile:o.isMobile,slot:!o.isMobile?"dialog-footer":undefined}))};return h(Host,{class:classes(["zonos--checkout zonos--elements",a&&"has-footer",this.preview&&"preview",this.isMobile&&"mobile"])},this.preview?b():h("zonos-dialog",{borderStyle:i,height:"980px",isLoading:t,mobile:this.isMobile,noBodyPadding:true,noBorder:true,noClickOutside:true,noCloseButton:true,onCloseDialog:function(){return o.closeDialogHandler()},open:this.open,width:"1200px"},b()))};Object.defineProperty(o,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(o,"watchers",{get:function(){return{appearanceSettingsOverride:["appearanceSettingsOverrideChanged","handleAppearanceSettingsOverrideChange"],mobile:["handleMobileChange"]}},enumerable:false,configurable:true});return o}();ZonosCheckout.style=ZonosCheckoutStyle0;export{ZonosCheckout as zonos_checkout};
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(o,e,t,n){function s(o){return o instanceof t?o:new t((function(e){e(o)}))}return new(t||(t=Promise))((function(t,r){function c(o){try{a(n.next(o))}catch(o){r(o)}}function i(o){try{a(n["throw"](o))}catch(o){r(o)}}function a(o){o.done?t(o.value):s(o.value).then(c,i)}a((n=n.apply(o,e||[])).next())}))};var __generator=this&&this.__generator||function(o,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,s,r,c;return c={next:i(0),throw:i(1),return:i(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function i(o){return function(e){return a([o,e])}}function a(i){if(n)throw new TypeError("Generator is already executing.");while(c&&(c=0,i[0]&&(t=0)),t)try{if(n=1,s&&(r=i[0]&2?s["return"]:i[0]?s["throw"]||((r=s["return"])&&r.call(s),0):s.next)&&!(r=r.call(s,i[1])).done)return r;if(s=0,r)i=[i[0]&2,r.value];switch(i[0]){case 0:case 1:r=i;break;case 4:t.label++;return{value:i[1],done:false};case 5:t.label++;s=i[1];i=[0];continue;case 7:i=t.ops.pop();t.trys.pop();continue;default:if(!(r=t.trys,r=r.length>0&&r[r.length-1])&&(i[0]===6||i[0]===2)){t=0;continue}if(i[0]===3&&(!r||i[1]>r[0]&&i[1]<r[3])){t.label=i[1];break}if(i[0]===6&&t.label<r[1]){t.label=r[1];r=i;break}if(r&&t.label<r[2]){t.label=r[2];t.ops.push(i);break}if(r[2])t.ops.pop();t.trys.pop();continue}i=e.call(o,t)}catch(o){i=[6,o];s=0}finally{n=r=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};import{r as registerInstance,h,F as Fragment,H as Host}from"./index-dd40cc85.js";import{l as localizationStore,a as log,s as stripeStoreGetDomesticShippingSession,b as localizationStoreUpdateSelectedCountryCode,c as stripeStoreCleanupDomesticShippingSession,d as logError,e as stripeStoreSaveDomesticShippingSession,i as initStripeElements,f as cartStore,g as cartStoreUpdateItems,h as cartStoreReset,j as stripeStore,k as stripeStoreInitCheckoutSession,m as cartStoreUpdateToErrorState,t as translate,n as stripeStorePrefetchLandedCost,o as cartStoreNextStep,p as stripeStoreConfirmPayment,q as stripeStoreReset}from"./cart-7961927b.js";import{z as zonosStore,g as getZonosStoreTheme,m as mergeConfig}from"./zonosStore-c4c45591.js";import{c as createCustomEvent,s as submitGtag,t as trackConversionEvent}from"./submitGtag-9ec64109.js";import{s as sendErrorLog,i as isCheckoutMobile}from"./sendErrorLog-4d9581da.js";import{c as classes}from"./classes-0d95c529.js";import{g as getBorderRadius}from"./getBorderRadius-a89e45fb.js";import{i as isDarkColor}from"./isDarkColor-6bf71e51.js";var objAttribute=function(o){var e=o.key,t=o.value;return t?{key:e,value:t}:null};var getAttributes=function(o){return[objAttribute({key:"brand",value:o.itemBrand}),objAttribute({key:"material",value:o.itemMaterial}),objAttribute({key:"category",value:o.itemCategory}),objAttribute({key:"color",value:o.itemColor}),objAttribute({key:"customization",value:o.itemCustomization}),objAttribute({key:"descriptionDetailed",value:o.itemDescriptionDetailed}),objAttribute({key:"fabricContent",value:o.itemFabricContent}),objAttribute({key:"ltlClass",value:o.itemLtlClass}),objAttribute({key:"pickingLocation",value:o.itemPickingLocation}),objAttribute({key:"shipFromLocation",value:o.itemShipFromLocation}),objAttribute({key:"size",value:o.itemSize}),objAttribute({key:"status",value:o.status})].filter(Boolean)};var getItemWeightUnit=function(o){if(!o){return"POUND"}switch(o.toUpperCase()){case"KG":return"KILOGRAM";case"OZ":return"OUNCE";case"G":return"GRAM";default:return"POUND"}};var getMeasurements=function(o){if(!o){return[]}var e=[];if(o.length){e.push({type:"LENGTH",unitOfMeasure:"INCH",value:o.length})}if(o.width){e.push({type:"WIDTH",unitOfMeasure:"INCH",value:o.width})}if(o.weight){e.push({type:"WEIGHT",unitOfMeasure:getItemWeightUnit(o.weightUnits),value:o.weight})}if(o.height){e.push({type:"HEIGHT",unitOfMeasure:"INCH",value:o.height})}return e};var buildCartItemsByTempCart=function(o){var e;var t=((e=o===null||o===void 0?void 0:o.items)===null||e===void 0?void 0:e.map((function(o){return{amount:o.unitPrice||0,attributes:getAttributes(o),countryOfOrigin:o.countryOfOrigin||undefined,currencyCode:"USD",description:o.itemDescriptionLong||"",imageUrl:o.imageURL||"",itemType:"PHYSICAL_GOOD",measurements:getMeasurements(o),name:o.description||"",productId:o.productId||"",quantity:o.quantity||0,sku:o.sku||""}})))||[];return t};var isShippableCountry=function(o){if(o===void 0){o=true}if(!localizationStore.localizationLoaded){return false}if(!localizationStore.isShippableCountry){document.dispatchEvent(createCustomEvent("legacyCheckoutError","Unable to initiate checkout process in a country where shipping is not available"));if(o){log("Checkout: not shippable country")}return false}return true};var watchBigcommerceDomesticCheckout=function(o){var e=o.domesticRedirectedBtnSelector,t=o.onShippingAddressSessionFound;if(!window.Zonos.isBigCommerce){return}var n=new MutationObserver((function(){return __awaiter(void 0,void 0,void 0,(function(){var o,s,r,c,i;return __generator(this,(function(a){o=document.querySelector(e);s=stripeStoreGetDomesticShippingSession();if(!o&&s){r=document.createElement("button");r.style.display="none";r.id="zonos--domestic-redirected-checkout-button";document.body.appendChild(r);t===null||t===void 0?void 0:t(s);n.disconnect();return[2]}c=document.querySelector('select[name="shippingAddress.countryCode"]');i=document.querySelector("#checkout-shipping-continue");if(!c||!i){return[2]}n.disconnect();i.addEventListener("click",(function(o){return __awaiter(void 0,void 0,void 0,(function(){var e,t,n,s,r,i,a;return __generator(this,(function(u){n=c.value;if(!n){return[2]}localizationStoreUpdateSelectedCountryCode(n);if(!isShippableCountry(false)){stripeStoreCleanupDomesticShippingSession();return[2]}s=document.querySelector("form");if(!s){return[2]}r=new FormData(s);i=document.querySelector("input#addressLine1Input");a={address1:(e=r.get("shippingAddress.address1"))!==null&&e!==void 0?e:i&&i.value,address2:r.get("shippingAddress.address2"),city:r.get("shippingAddress.city"),countryCode:r.get("shippingAddress.countryCode"),firstName:r.get("shippingAddress.firstName"),lastName:r.get("shippingAddress.lastName"),phone:r.get("shippingAddress.phone"),postalCode:r.get("shippingAddress.postalCode"),stateOrProvince:(t=r.get("shippingAddress.stateOrProvince"))!==null&&t!==void 0?t:r.get("shippingAddress.stateOrProvinceCode")};if(Object.values(a).some((function(o){return o===undefined||o===null}))){logError("One or more shipping address field is missing",Object.entries(a));void sendErrorLog({endpoint:"No endpoint, domestic checkout form missing fields",errors:["Bigcommerce: One or more shipping address field is missing in the domestic checkout form",JSON.stringify(Object.entries(a))],metadata:{domain:window.location.hostname,storeId:zonosStore.storeId}});return[2]}stripeStoreSaveDomesticShippingSession({address1:a.address1,address2:a.address2,city:a.city,countryCode:a.countryCode,firstName:a.firstName,lastName:a.lastName,phone:a.phone,postalCode:a.postalCode,state:a.stateOrProvince});o.preventDefault();o.stopPropagation();window.location.href="/";return[2]}))}))}));return[2]}))}))}));n.observe(document.body,{childList:true,subtree:true})};var MessageIcon='<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="https://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 4.5C2.25 3.25736 3.25736 2.25 4.5 2.25H13.5C14.7426 2.25 15.75 3.25736 15.75 4.5V10.5C15.75 11.7426 14.7426 12.75 13.5 12.75H8.25C8.01393 12.75 7.79164 12.8611 7.65 13.05L6.3 14.85C5.87508 15.4166 5.2082 15.75 4.5 15.75C3.25736 15.75 2.25 14.7426 2.25 13.5V4.5ZM4.5 3.75C4.08579 3.75 3.75 4.08579 3.75 4.5V13.5C3.75 13.9142 4.08579 14.25 4.5 14.25C4.73607 14.25 4.95836 14.1389 5.1 13.95L6.45 12.15C6.87492 11.5834 7.5418 11.25 8.25 11.25H13.5C13.9142 11.25 14.25 10.9142 14.25 10.5V4.5C14.25 4.08579 13.9142 3.75 13.5 3.75H4.5ZM5.25 6C5.25 5.58579 5.58579 5.25 6 5.25H12C12.4142 5.25 12.75 5.58579 12.75 6C12.75 6.41421 12.4142 6.75 12 6.75H6C5.58579 6.75 5.25 6.41421 5.25 6ZM5.25 9C5.25 8.58579 5.58579 8.25 6 8.25H8.25C8.66421 8.25 9 8.58579 9 9C9 9.41421 8.66421 9.75 8.25 9.75H6C5.58579 9.75 5.25 9.41421 5.25 9Z" fill="#4D505A"/>\n</svg>\n';var RemoveIcon='<svg color="var(--amino-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--amino-gray-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>';var zonosCheckoutCss=".sc-zonos-checkout-h{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-checkout-h *.sc-zonos-checkout{font-family:var(--font-family, Inter), Inter}.sc-zonos-checkout-h img.sc-zonos-checkout{max-width:100%}.sc-zonos-checkout-h dl.sc-zonos-checkout,.sc-zonos-checkout-h dd.sc-zonos-checkout,.sc-zonos-checkout-h h1.sc-zonos-checkout,.sc-zonos-checkout-h h2.sc-zonos-checkout,.sc-zonos-checkout-h h3.sc-zonos-checkout,.sc-zonos-checkout-h h4.sc-zonos-checkout,.sc-zonos-checkout-h h5.sc-zonos-checkout,.sc-zonos-checkout-h h6.sc-zonos-checkout,.sc-zonos-checkout-h hr.sc-zonos-checkout,.sc-zonos-checkout-h figure.sc-zonos-checkout,.sc-zonos-checkout-h p.sc-zonos-checkout,.sc-zonos-checkout-h pre.sc-zonos-checkout{margin:0}.sc-zonos-checkout-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar{width:10px}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-track{background:var(--amino-gray-50)}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-checkout-h *.sc-zonos-checkout::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;border-radius:var(--border-radius, var(--amino-radius-10))}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex:1;flex:1;padding:var(--amino-space-32)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{background-color:var(--primary-color, var(--amino-gray-0));border-right:1px solid var(--amino-gray-200)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{background-color:var(--amino-gray-0)}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:100%;max-height:100%;height:100%;overflow:auto;-ms-flex-direction:column;flex-direction:column;background-color:var(--amino-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:var(--amino-space-24);padding-bottom:50px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--header.sc-zonos-checkout img.sc-zonos-checkout{width:150px;min-width:150px}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout .zonos--logo.sc-zonos-checkout{margin-bottom:0}.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout zonos-checkout-finish.sc-zonos-checkout{-ms-flex:1;flex:1}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{padding:0 var(--amino-space-8) var(--amino-space-8)}.sc-zonos-checkout-h .zonos--left.sc-zonos-checkout .zonos--payment-error-banner.sc-zonos-checkout{margin-top:var(--amino-space-24)}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout{position:relative}.sc-zonos-checkout-h .zonos--right.sc-zonos-checkout .zonos--close-button.sc-zonos-checkout{position:absolute;right:var(--amino-space-24);top:var(--amino-space-24);z-index:2}.sc-zonos-checkout-h .zonos--wrapper.sc-zonos-checkout{overflow:auto;max-height:100%;position:relative}.sc-zonos-checkout-h .flex--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;max-height:100%}.sc-zonos-checkout-h .zonos--logo.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-checkout-h .zonos--checkout-default-message.sc-zonos-checkout{margin-left:var(--amino-space-76);margin-bottom:var(--amino-space-8)}.preview.sc-zonos-checkout-h{min-width:500px;margin:auto}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{border:var(--amino-border)}.preview.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{padding:var(--amino-space-32)}.mobile.sc-zonos-checkout-h{min-width:auto}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:auto;border-radius:0;max-height:100%;height:100%;border:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding:var(--amino-space-12);padding-bottom:var(--amino-space-76)}@media (max-width: 768px){.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout,.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{padding-bottom:var(--amino-space-0)}}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--left.sc-zonos-checkout{-ms-flex-order:2;order:2;border-right:none}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout{-ms-flex-order:1;order:1;padding-top:var(--amino-space-16)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;border:var(--amino-border);border-radius:var(--border-radius, var(--amino-radius-10));background-color:var(--amino-gray-50);padding:var(--amino-space-12);margin-top:var(--amino-space-32)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--review.sc-zonos-checkout{margin-bottom:0}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--right.sc-zonos-checkout .zonos--cart-items.sc-zonos-checkout{margin-top:var(--amino-space-8)}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout zonos-checkout-footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--wrapper.sc-zonos-checkout{max-height:100%}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--footer.sc-zonos-checkout{-ms-flex-order:3;order:3}.mobile.sc-zonos-checkout-h .zonos--content.sc-zonos-checkout .zonos--done.sc-zonos-checkout{width:auto}.mobile.sc-zonos-checkout-h .zonos--cart-subtotal.sc-zonos-checkout{margin:0}";var ZonosCheckoutStyle0=zonosCheckoutCss;var ZonosCheckout=function(){function o(o){var e=this;registerInstance(this,o);this.applyStripeTheme=function(){return __awaiter(e,void 0,void 0,(function(){var o,e,t,n,s;return __generator(this,(function(r){switch(r.label){case 0:s=((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme)||zonosStore.appearance.theme;return[4,initStripeElements({overrideBorderRaidus:(e=this.appearanceSettingsOverride)===null||e===void 0?void 0:e.style,overridePrimaryColor:(t=this.appearanceSettingsOverride)===null||t===void 0?void 0:t.colorPrimary,overrideSecondaryColor:(n=this.appearanceSettingsOverride)===null||n===void 0?void 0:n.colorSecondary,overrideTheme:this.isMobile?s:undefined})];case 1:r.sent();return[2]}}))}))};this.getCurrentLocalePageEnum=function(){switch(cartStore.step){case"customer-info":return"checkout_customer_info";case"shipping":return"checkout_shipping_info";case"payment":return"checkout_payment_info";default:return null}};this.appearanceSettingsOverride=undefined;this.preview=false;this.mobile=false;this.defaultAddress=null;this.forceDialogOpen=false;this.open=this.forceDialogOpen;this.stripe=window.Zonos.stripe;this.submitLoading=false;this.paymentError=false;this.collapseReviewMobile=true;this.isAttachError=false;this.isMobile=false;this.zonosReviewRef=undefined;this.storybookPaymentStatusOverride=undefined;this.domesticRedirectedBtnSelector="#zonos--domestic-redirected-checkout-button";this.legacyCheckoutHiddenBtnSelector="#legacy-checkout-hidden-button";this.isLegacyCheckout=false}o.prototype.initCartInfoHandler=function(o){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){e=o.detail;void cartStoreUpdateItems(e);return[2]}))}))};o.prototype.closeDialogHandler=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){submitGtag("zonos-checkout-close");this.open=this.forceDialogOpen||false;if(!this.preview&&cartStore.step==="finish"){cartStoreReset()}cartStore.step="customer-info";return[2]}))}))};o.prototype.buildCartAndInit=function(){return __awaiter(this,void 0,void 0,(function(){var o,e,t;return __generator(this,(function(n){switch(n.label){case 0:if(!window.Zonos.tempCartData)return[3,2];o=buildCartItemsByTempCart(window.Zonos.tempCartData);return[4,cartStoreUpdateItems(o)];case 1:n.sent();return[3,5];case 2:if(!zonosStore.checkoutSettings.buildCartDetail)return[3,5];log("build cart detail");return[4,zonosStore.checkoutSettings.buildCartDetail()];case 3:e=n.sent();return[4,cartStoreUpdateItems(e)];case 4:n.sent();n.label=5;case 5:if(!!stripeStore.clientSecret)return[3,7];return[4,stripeStoreInitCheckoutSession()];case 6:t=n.sent();log("stripeStoreInitCheckoutSession: ".concat(t));if(!t){return[2,false]}n.label=7;case 7:return[4,this.applyStripeTheme()];case 8:n.sent();return[2,true]}}))}))};o.prototype.attachCheckout=function(){var o=this;var e=zonosStore.checkoutSettings.placeOrderButtonSelector;if(!e){return}var t=document.querySelectorAll("".concat(e,", ").concat(this.domesticRedirectedBtnSelector));t.forEach((function(e){var t=e.getAttribute("data-zonos-checkout-attached");if(t){return}e.addEventListener("click",(function(e){return __awaiter(o,void 0,void 0,(function(){var o,t;return __generator(this,(function(n){switch(n.label){case 0:if(!isShippableCountry()){return[2]}e.preventDefault();e.stopPropagation();log("zonos checkout button clicked");stripeStore.isFetchingSession=true;this.open=true;n.label=1;case 1:n.trys.push([1,3,,4]);return[4,this.buildCartAndInit()];case 2:o=n.sent();if(!o){throw new Error("Error building cart")}submitGtag("zonos-checkout-start");void trackConversionEvent("checkout_open");return[3,4];case 3:t=n.sent();stripeStore.isFetchingSession=false;cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[3,4];case 4:return[2]}}))}))}));e.removeAttribute("disabled");e.setAttribute("data-zonos-checkout-attached","true");if(e.matches(o.domesticRedirectedBtnSelector)){e.dispatchEvent(createCustomEvent("click"));stripeStoreCleanupDomesticShippingSession();e.remove()}if(e.matches(o.legacyCheckoutHiddenBtnSelector)){o.isLegacyCheckout=true;e.dispatchEvent(createCustomEvent("click"));e.remove()}}))};o.prototype.appearanceSettingsOverrideChanged=function(){if(!this.appearanceSettingsOverride){return}void this.applyStripeTheme()};o.prototype.useLegacyQueryParam=function(){var o=new URLSearchParams(window.location.search);var e={country:o.get("country"),customerAddress1:o.get("customerAddress1"),customerAddress2:o.get("customerAddress2"),customerCity:o.get("customerCity"),customerEmail:o.get("customerEmail"),customerName:o.get("customerName"),customerPhone:o.get("customerPhone"),customerState:o.get("customerState"),customerZip:o.get("customerZip")};if(!e.customerAddress1||!e.customerCity||!e.customerName||!e.customerPhone||!e.customerState||!e.customerZip||!e.country){return}this.defaultAddress={address:{city:e.customerCity,country:e.country,line1:e.customerAddress1,line2:e.customerAddress2||"",postal_code:e.customerZip,state:e.customerState},name:e.customerName,phone:e.customerPhone}};o.prototype.init=function(){return __awaiter(this,void 0,void 0,(function(){var o,e;var t=this;return __generator(this,(function(n){stripeStore.stripe=window.Zonos.stripe;this.stripe=window.Zonos.stripe;watchBigcommerceDomesticCheckout({domesticRedirectedBtnSelector:this.domesticRedirectedBtnSelector,onShippingAddressSessionFound:function(o){t.defaultAddress={address:{city:o.city,country:o.countryCode,line1:o.address1,line2:o.address2,postal_code:o.postalCode,state:o.state},name:"".concat(o.firstName," ").concat(o.lastName),phone:o.phone}}});if(window.Zonos.tempCartData){this.useLegacyQueryParam()}o=setInterval((function(){var e=window.Zonos.internationalHideSelector;if(!e){clearInterval(o);return}var t=isShippableCountry(false);var n=document.querySelectorAll(e);if(!t){n===null||n===void 0?void 0:n.forEach((function(o){var e=o;var t=e.getAttribute("data-zonos-checkout-original-display")||getComputedStyle(e).display;e.style.display=t||"initial"}));return}n===null||n===void 0?void 0:n.forEach((function(o){var e=o;var t=e.style.display;e.setAttribute("data-zonos-checkout-original-display",t);e.style.display="none"}))}),100);e=setInterval((function(){stripeStore.stripe=window.Zonos.stripe;t.stripe=window.Zonos.stripe;if(!t.stripe){log("waiting for stripe to be loaded");return}if(t.storybookPaymentStatusOverride){clearInterval(e);return}log("init checkout");if(t.preview||t.forceDialogOpen){void t.buildCartAndInit()}else{t.attachCheckout();var o=new MutationObserver((function(){t.attachCheckout()}));o.observe(document.body,{childList:true,subtree:true})}clearInterval(e)}),50);setTimeout((function(){clearInterval(e)}),1e4);return[2]}))}))};o.prototype.setToFinishStep=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){cartStore.step="finish";this.storybookPaymentStatusOverride=o;return[2]}))}))};o.prototype.handleCustomerInfoContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;var e=this;return __generator(this,(function(t){switch(t.label){case 0:this.submitLoading=true;return[4,stripeStorePrefetchLandedCost()];case 1:t.sent();o=setInterval((function(){if(cartStore.landedCostData||!stripeStore.isFetchingLandedCost){if(cartStore.landedCostData){cartStoreNextStep()}e.submitLoading=false;clearInterval(o)}}),500);return[2]}}))}))};o.prototype.handleShippingContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o=this;return __generator(this,(function(e){this.submitLoading=true;setTimeout((function(){cartStoreNextStep();o.submitLoading=false}),500);return[2]}))}))};o.prototype.handleCheckoutPaymentContinue=function(){return __awaiter(this,void 0,void 0,(function(){var o;return __generator(this,(function(e){switch(e.label){case 0:this.paymentError=false;this.submitLoading=true;e.label=1;case 1:e.trys.push([1,3,,4]);return[4,stripeStoreConfirmPayment()];case 2:e.sent();cartStoreNextStep();return[3,4];case 3:o=e.sent();logError(o);this.paymentError=true;return[3,4];case 4:this.submitLoading=false;return[2]}}))}))};o.prototype.handleFinishClick=function(){return __awaiter(this,void 0,void 0,(function(){var o,e,t;return __generator(this,(function(n){switch(n.label){case 0:stripeStoreReset();if(!this.preview)return[3,2];cartStore.step="customer-info";return[4,this.init()];case 1:n.sent();return[2];case 2:cartStoreReset();if(this.isLegacyCheckout&&window.Zonos.tempCartData){o=window.Zonos.tempCartData.contShoppingURL;window.location.href=o;return[2]}e=window.location.href;t=e.split("?")[0];window.history.replaceState({},document.title,t);this.open=false;window.location.reload();return[2]}}))}))};o.prototype.handleWindowResize=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};o.prototype.handleMobileChange=function(){this.isMobile=isCheckoutMobile(this.mobile);void this.applyStripeTheme();log("mobile: ".concat(this.isMobile))};o.prototype.handleAppearanceSettingsOverrideChange=function(){var o;if((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme){this.appearanceSettingsOverride.theme=getZonosStoreTheme(this.appearanceSettingsOverride.theme)}};o.prototype.componentWillLoad=function(){void this.init();this.isMobile=isCheckoutMobile(this.mobile);this.handleAppearanceSettingsOverrideChange();log("mobile: ".concat(this.isMobile))};o.prototype.disconnectedCallback=function(){stripeStoreReset();cartStoreReset()};o.prototype.render=function(){var o=this;var e;var t=cartStore.step!=="finish"&&cartStore.step!=="error"&&!stripeStore.stripeElements||stripeStore.isFetchingSession;var n=mergeConfig(zonosStore.appearance,this.appearanceSettingsOverride),s=n.colorPrimary,r=n.colorSecondary,c=n.logoUrl,i=n.style;var a=zonosStore.appearance.zonosAttribution==="ENABLED";var u=zonosStore.appearance.theme;var l=s&&isDarkColor(s)?"DARK":"LIGHT";var d=this.isMobile?u:l;var f=!this.isMobile?r:undefined;var m=localizationStore.customMessages;var z=(e=m.find((function(o){return o.pageName==="checkout_default"})))===null||e===void 0?void 0:e.message;var p=this.getCurrentLocalePageEnum();var k=m.filter((function(o){return o.pageName===p}));var v=function(){return h("div",{class:"zonos--logo"},c&&h("img",{alt:"".concat(zonosStore.organizationName," logo"),src:c,width:100}))};var g=function(){return h("zonos-v-stack",null,v(),h("zonos-checkout-progress-tabs",{backgroundColor:o.isMobile?"--amino-gray-0":null}),k.map((function(o){return h("zonos-custom-message",{icon:MessageIcon,message:o.message})})))};var b=function(){return h("div",{class:"zonos--content",style:{"--border-radius":getBorderRadius(i)}},cartStore.step!=="finish"&&cartStore.step!=="error"&&h(Fragment,null,h("div",{class:"zonos--left","data-theme":d,style:{"--primary-color":!o.isMobile?s:""}},!o.isMobile&&g(),cartStore.step==="customer-info"&&h("zonos-customer-info",{continueLoading:o.submitLoading,defaultAddress:o.defaultAddress,onContinueClicked:function(){return o.handleCustomerInfoContinue()},submitBtnColor:f}),cartStore.step==="shipping"&&h("zonos-shipping",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleShippingContinue()},submitBtnColor:f}),cartStore.step==="payment"&&h("zonos-checkout-payment",{continueLoading:o.submitLoading,onContinueClicked:function(){return o.handleCheckoutPaymentContinue()},paymentError:o.paymentError,submitBtnColor:f})),h("div",{class:"zonos--right","data-theme":u},o.isMobile&&g(),!o.isLegacyCheckout&&h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon}),noBackground:true,onClick:function(){return o.closeDialogHandler()}}),h("div",{class:"flex--wrapper"},h("div",{class:"zonos--wrapper"},h("zonos-review",{collapsed:o.collapseReviewMobile,mobile:o.isMobile,onClick:function(){if(!o.isMobile){return}o.collapseReviewMobile=!o.collapseReviewMobile}}),h("zonos-collapse",{collapsed:o.collapseReviewMobile&&o.isMobile},h("zonos-cart-items",null),o.isMobile&&h("zonos-v-stack",{spacing:16},h("zonos-cart-subtotal",null),h("zonos-custom-message",{class:"zonos--checkout-default-message",icon:MessageIcon,message:z})))),!o.isMobile&&h("zonos-v-stack",{spacing:16},h("zonos-cart-subtotal",null),h("zonos-custom-message",{class:"zonos--checkout-default-message",icon:MessageIcon,message:z}))))),(cartStore.step==="finish"||cartStore.step==="error")&&h("div",{class:"zonos--done","data-theme":u},h("div",{class:"zonos--header"},v(),h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon}),noBackground:true,onClick:function(){return o.handleFinishClick()},theme:u})),h("zonos-checkout-finish",{borderRadius:i,onCloseClick:function(){return o.handleFinishClick()},overrideNotification:cartStore.step==="error"&&!!cartStore.error?Object.assign(Object.assign({},cartStore.error),{type:"error"}):undefined,storybookForceStatus:o.storybookPaymentStatusOverride})),h("zonos-checkout-footer",{"data-theme":u,mobile:o.isMobile,slot:!o.isMobile?"dialog-footer":undefined}))};return h(Host,{class:classes(["zonos--checkout zonos--elements",a&&"has-footer",this.preview&&"preview",this.isMobile&&"mobile"])},this.preview?b():h("zonos-dialog",{borderStyle:i,height:"980px",isLoading:t,mobile:this.isMobile,noBodyPadding:true,noBorder:true,noClickOutside:true,noCloseButton:true,onCloseDialog:function(){return o.closeDialogHandler()},open:this.open,width:"1200px"},b()))};Object.defineProperty(o,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(o,"watchers",{get:function(){return{appearanceSettingsOverride:["appearanceSettingsOverrideChanged","handleAppearanceSettingsOverrideChange"],mobile:["handleMobileChange"]}},enumerable:false,configurable:true});return o}();ZonosCheckout.style=ZonosCheckoutStyle0;export{ZonosCheckout as zonos_checkout};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";"function"==typeof SuppressedError&&SuppressedError;const e=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{return await e.json()}catch(e){if(t)throw e;return o&&console.error(e),null}};const o=async(o,t)=>{const n=(function(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t})(t||{},[]),r=n.body?JSON.stringify(n.body):void 0,s=n.method||"GET",i=new URL(o);i.searchParams.set("zToken",(function(e){try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(window.location.hostname));const 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"},n.headers),c=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:a,method:s});return(async(o,t)=>{let n;try{n=await fetch(o,t)}catch(e){return e instanceof Error?{errors:[{message:e.message,type:"unknown"}],json:null,response:null}:{errors:[{message:"Fail to fetch",type:"unknown"}],json:null,response:null}}const r=n.headers.get("Zonos-Mode"),s=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&r&&s&&("production"===r&&alert("Please be aware that you are currently operating in the production environment. Any interactions with the customer store, including payments, will be processed as real transactions!"),"test"===r&&alert("For testing payments, you can utilize the test payment information provided at this link: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements#web-test-the-integration"),window.Zonos.modeAlerted=!0),n.ok)return{errors:[],json:await e({response:n}),response:n};const i=n.status.toString();try{const o=await e({response:n,shouldThrow:!0});return{errors:[{message:`${i}: ${JSON.stringify(o)}`,type:i}],json:null,response:n}}catch(e){return{errors:[{message:`${i}: Unknown error`,type:i}],json:null,response:null}}})(i.toString(),c)},t=()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t},n=(e,o,...t)=>{var n,r;if(!(!!(null===(n=window.Zonos)||void 0===n?void 0:n.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===o&&console.error(e,...t));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(o){case"warn":i.warn(e,...t);break;case"info":i.info(e,...t);break;case"error":i.error(e,...t);break;default:i.groupCollapsed(e,...t),i.trace(),i.groupEnd()}},r=(e,...o)=>{n(e,"error",...o)},s=async({endpoint:e,errors:t,metadata:n})=>{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},n)};o("https://v1.route.js.zonos.com/api/zonos-elements/log-error",{body:s,method:"POST"})};var i;const a=(()=>{const e=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href);if(!e)return null;const o=`https://${e}.preview.js.zonos.com`;return n(`[ZONOS-WARNING] using '${o}' for loading script`,"warn"),fetch(o).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${o}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:t}=window.location,n=`${t}?${e.toString()}`;return window.history.replaceState({},"",n),window.location.reload(),null})),o})();class c{}i=c,c.isBigCommerce=!1,c.requested=!1,c.internationalHideSelector="",c.zonosQaUrl=null,c.tempCartData=null,c.zonosApiKey=null,c.isLegacyCheckout=!1,c.legacyStoreLogo=null,c.legacyStoreFavicon=null,c.parallelLoadTimes=[],c.loadScriptLogHandler=async({cdnLoadTime:e,fallbackLoadTime:n,isError:r,metadata:s,scriptLoadUrl:i,storeId:a,type:c})=>{try{const l=window.performance.getEntriesByType("resource").find((e=>{const o=e;return o.name.includes(i)&&"script"===o.initiatorType}));(async e=>{const n="userAgentData"in window.navigator?window.navigator.userAgentData:null,r=t(),s=Object.assign(Object.assign({href:window.location.href},e),{metadata:Object.assign({connectionDownlink:null==r?void 0:r.downlink,connectionEffectiveType:null==r?void 0:r.effectiveType,connectionRtt:null==r?void 0:r.rtt,connectionSaveData:null==r?void 0:r.saveData,userAgent:n&&n.brands.length>0?n:window.navigator.userAgent},e.metadata)});o("https://v1.route.js.zonos.com/api/zonos-elements/log-script-load",{body:s,method:"POST"})})({cache:0===(null==l?void 0:l.transferSize)?"hit":"miss",cdnLoadTime:e,eventName:c,loadTime:l&&(null==l?void 0:l.duration)>0?parseFloat(l.duration.toFixed(2)):parseFloat(n.toFixed(2)),metadata:Object.assign({decodedBodySize:null==l?void 0:l.decodedBodySize,encodedBodySize:null==l?void 0:l.encodedBodySize,fallbackLoadTime:n,isError:!!r},s),scriptLoadUrl:i,storeId:a})}catch(e){}},c.loadScriptLogParallelHandler=async e=>{try{if(i.parallelLoadTimes.push(e),2===i.parallelLoadTimes.length){const e=i.parallelLoadTimes.find((e=>"vercel"===e.type)),o=i.parallelLoadTimes.find((e=>"jsdelivr"===e.type));if(!e||!o)return;if(e.isError&&o.isError)return void s({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}});i.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){}},c.legacyCheckoutErrorHandler=({message:e,tempCartUUID:o})=>{r(`[ZONOS - loadZonos] ${e}`),s({endpoint:"LegacyCheckoutInit",errors:[e],metadata:{tempCartUUID:o}}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:e}))},c.injectZonos=({initConfig:e,isGithubCdn:o=!1,parallelLoaded:r,url:c,version:l})=>{var d;const p=()=>{const e="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.12-alpha.10";return l?e.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${l}`):e},m=a||c,u=m.replace("https://","").replace("http://",""),g=document.createElement("script"),w=l&&l<"1.2.5"?"loadZonos.js":"zonos.js";g.src=`https://${u}/dist/scripts/${w}`,n(`[ZONOS - loadZonos] Injecting "${w}" from "${u}"`,"info");const h="4g"===(null===(d=t())||void 0===d?void 0:d.effectiveType)&&!o;if(h){const o=p();i.injectZonos({initConfig:e,isGithubCdn:!0,parallelLoaded:!0,url:o,version:l})}const y=performance.now();g.addEventListener("load",(()=>{if(h||r?i.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-y,scriptLoadUrl:g.src,storeId:i.storeId,type:o?"jsdelivr":"vercel"}):i.loadScriptLogHandler({fallbackLoadTime:performance.now()-y,scriptLoadUrl:g.src,storeId:i.storeId,type:o?"jsdelivr":"vercel"}),i.isBigCommerce||(i.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.zonosQaUrl=a,window.Zonos.internationalHideSelector=i.internationalHideSelector,window.Zonos.isBigCommerce=i.isBigCommerce,i.isLegacyCheckout){if(!i.zonosApiKey)throw i.legacyCheckoutErrorHandler({message:"zonosApiKey is required for legacy checkout",tempCartUUID:e.tempCartUUID}),new Error("zonosApiKey is required for legacy checkout");if(!i.tempCartData)throw i.legacyCheckoutErrorHandler({message:"tempCartData is required for legacy checkout",tempCartUUID:e.tempCartUUID}),new Error("zonosApiKey is required for legacy checkout");if(i.legacyStoreFavicon){const e=document.createElement("link");e.rel="shortcut icon",e.type="image/x-icon",e.href=i.legacyStoreFavicon,document.head.appendChild(e)}window.Zonos.tempCartData=i.tempCartData;const o=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:i.legacyStoreLogo||""}),checkoutSettings:Object.assign(Object.assign({},e.checkoutSettings),{successBehavior:"ZONOS_SUCCESS_PAGE",successRedirectUrl:i.tempCartData.contShoppingURL}),zonosApiKey:i.zonosApiKey});e=o}window.Zonos.version&&(n(`[ZONOS - loadZonos] Execute "Zonos.init" from "${w}" from "${u}"`,"info"),window.Zonos.init(e))})),g.addEventListener("error",(async()=>{if(!h&&!r){const o=p();i.injectZonos({initConfig:e,isGithubCdn:!0,url:o,version:l})}["localhost",".zonos.com"].some((e=>window.location.href.includes(e)))||a||(h||r?i.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-y,isError:!0,scriptLoadUrl:g.src,storeId:i.storeId,type:o?"jsdelivr":"vercel"}):s(o?{endpoint:g.src,errors:["zonos.js - Failed to fetch github CDN."],metadata:{cdnLoadTime:performance.now()-y,cdnType:"jsdelivr",loadUrl:m,version:l}}:{endpoint:g.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{vercelLoadTime:performance.now()-y}}))})),document.head.appendChild(g)},c.setupCartData=async e=>{const t=await(async e=>{const{errors:t,json:n}=await o("https://v1.route.js.zonos.com/api/bigcommerce/legacy-migration/get-temp-cart",{body:{tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"});return!n||t.length?null:n})(e);if(n("[ZONOS - loadZonos] getting temp cart data","info",t),!t)throw r("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),i.legacyCheckoutErrorHandler({message:"Error getting temp cart data",tempCartUUID:e}),new Error("Error getting temp cart data");return i.tempCartData=t.tempCart,i.legacyStoreLogo=t.storeLogoUrl,i.legacyStoreFavicon=t.storeFaviconUrl,{storeId:t.tempCart.storeId,zonosApiKey:t.zonosApiKey}},c.init=async e=>{var t;const s="https://v1.3.12-alpha.10.js.zonos.com",a=null===(t=document.querySelector("script[src*='/loadZonos.js']"))||void 0===t?void 0:t.src,c=document.querySelector('script[src*="/zonos.js"]'),l=null==a?void 0:a.includes("timestamp=");if(!a||!l)return void r("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(c||!a||i.requested)return void n("[ZONOS - loadZonos] script is already loaded or requested","info");i.requested=!0;let d=e.storeId;if(e.tempCartUUID){const o=await i.setupCartData(e.tempCartUUID);d=o.storeId,i.zonosApiKey=o.zonosApiKey,i.isLegacyCheckout=!0}if(!d)return n("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void i.injectZonos({initConfig:e,url:s,version:null});i.storeId=d;const p=new URL("https://v1.route.js.zonos.com/api/get-store-version");p.searchParams.set("storeId",e.storeId.toString());const{errors:m,json:u}=await o(p.toString());if(m.length||!u)return n("[ZONOS - loadZonos] Error getting store version, loadding the latest version.","error"),void i.injectZonos({initConfig:e,url:s,version:null});const{version:g}=u;if(!c){const{currentLoadScriptUrl:o,isForceLoadVersionDomain:t,isWhiteListed:r}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),n=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:a}),s=r&&!t?o:`${"alpha"===g?"alpha":`v${g}`}.js.zonos.com`,c=r&&!t?null:g;n("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:o,isForceLoadVersionDomain:t,isWhiteListed:r,loadUrl:s,loadVersion:c,version:g}),i.injectZonos({initConfig:e,url:s,version:c})}},void 0===window.Zonos&&(window.Zonos=c)})();
|
|
1
|
+
(function(){"use strict";"function"==typeof SuppressedError&&SuppressedError;const e=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{return await e.json()}catch(e){if(t)throw e;return o&&console.error(e),null}};const o=async(o,t)=>{const n=(function(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t})(t||{},[]),r=n.body?JSON.stringify(n.body):void 0,s=n.method||"GET",i=new URL(o);i.searchParams.set("zToken",(function(e){try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(window.location.hostname));const 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"},n.headers),c=Object.assign(Object.assign({},n),{body:"GET"===s?void 0:r,headers:a,method:s});return(async(o,t)=>{let n;try{n=await fetch(o,t)}catch(e){return e instanceof Error?{errors:[{message:e.message,type:"unknown"}],json:null,response:null}:{errors:[{message:"Fail to fetch",type:"unknown"}],json:null,response:null}}const r=n.headers.get("Zonos-Mode"),s=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&r&&s&&("production"===r&&alert("Please be aware that you are currently operating in the production environment. Any interactions with the customer store, including payments, will be processed as real transactions!"),"test"===r&&alert("For testing payments, you can utilize the test payment information provided at this link: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements#web-test-the-integration"),window.Zonos.modeAlerted=!0),n.ok)return{errors:[],json:await e({response:n}),response:n};const i=n.status.toString();try{const o=await e({response:n,shouldThrow:!0});return{errors:[{message:`${i}: ${JSON.stringify(o)}`,type:i}],json:null,response:n}}catch(e){return{errors:[{message:`${i}: Unknown error`,type:i}],json:null,response:null}}})(i.toString(),c)},t=()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t},n=(e,o,...t)=>{var n,r;if(!(!!(null===(n=window.Zonos)||void 0===n?void 0:n.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===o&&console.error(e,...t));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(o){case"warn":i.warn(e,...t);break;case"info":i.info(e,...t);break;case"error":i.error(e,...t);break;default:i.groupCollapsed(e,...t),i.trace(),i.groupEnd()}},r=(e,...o)=>{n(e,"error",...o)},s=async({endpoint:e,errors:t,metadata:n})=>{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},n)};o("https://v1.route.js.zonos.com/api/zonos-elements/log-error",{body:s,method:"POST"})};var i;const a=(()=>{const e=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href);if(!e)return null;const o=`https://${e}.preview.js.zonos.com`;return n(`[ZONOS-WARNING] using '${o}' for loading script`,"warn"),fetch(o).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${o}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:t}=window.location,n=`${t}?${e.toString()}`;return window.history.replaceState({},"",n),window.location.reload(),null})),o})();class c{}i=c,c.isBigCommerce=!1,c.requested=!1,c.internationalHideSelector="",c.zonosQaUrl=null,c.tempCartData=null,c.zonosApiKey=null,c.isLegacyCheckout=!1,c.legacyStoreLogo=null,c.legacyStoreFavicon=null,c.parallelLoadTimes=[],c.loadScriptLogHandler=async({cdnLoadTime:e,fallbackLoadTime:n,isError:r,metadata:s,scriptLoadUrl:i,storeId:a,type:c})=>{try{const l=window.performance.getEntriesByType("resource").find((e=>{const o=e;return o.name.includes(i)&&"script"===o.initiatorType}));(async e=>{const n="userAgentData"in window.navigator?window.navigator.userAgentData:null,r=t(),s=Object.assign(Object.assign({href:window.location.href},e),{metadata:Object.assign({connectionDownlink:null==r?void 0:r.downlink,connectionEffectiveType:null==r?void 0:r.effectiveType,connectionRtt:null==r?void 0:r.rtt,connectionSaveData:null==r?void 0:r.saveData,userAgent:n&&n.brands.length>0?n:window.navigator.userAgent},e.metadata)});o("https://v1.route.js.zonos.com/api/zonos-elements/log-script-load",{body:s,method:"POST"})})({cache:0===(null==l?void 0:l.transferSize)?"hit":"miss",cdnLoadTime:e,eventName:c,loadTime:l&&(null==l?void 0:l.duration)>0?parseFloat(l.duration.toFixed(2)):parseFloat(n.toFixed(2)),metadata:Object.assign({decodedBodySize:null==l?void 0:l.decodedBodySize,encodedBodySize:null==l?void 0:l.encodedBodySize,fallbackLoadTime:n,isError:!!r},s),scriptLoadUrl:i,storeId:a})}catch(e){}},c.loadScriptLogParallelHandler=async e=>{try{if(i.parallelLoadTimes.push(e),2===i.parallelLoadTimes.length){const e=i.parallelLoadTimes.find((e=>"vercel"===e.type)),o=i.parallelLoadTimes.find((e=>"jsdelivr"===e.type));if(!e||!o)return;if(e.isError&&o.isError)return void s({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}});i.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){}},c.legacyCheckoutErrorHandler=({message:e,tempCartUUID:o})=>{r(`[ZONOS - loadZonos] ${e}`),s({endpoint:"LegacyCheckoutInit",errors:[e],metadata:{tempCartUUID:o}}),document.dispatchEvent(new CustomEvent("legacyCheckoutError",{detail:e}))},c.injectZonos=({initConfig:e,isGithubCdn:o=!1,parallelLoaded:r,url:c,version:l})=>{var d;const p=()=>{const e="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.12-alpha.11";return l?e.replace(/@zonos\/elements@(.+)/,`@zonos/elements@${l}`):e},m=a||c,u=m.replace("https://","").replace("http://",""),g=document.createElement("script"),w=l&&l<"1.2.5"?"loadZonos.js":"zonos.js";g.src=`https://${u}/dist/scripts/${w}`,n(`[ZONOS - loadZonos] Injecting "${w}" from "${u}"`,"info");const h="4g"===(null===(d=t())||void 0===d?void 0:d.effectiveType),y=["dev.elements.zonos.com","zonos.com"].some((e=>window.location.href.includes(e))),f=h&&!o&&!y;if(f){const o=p();i.injectZonos({initConfig:e,isGithubCdn:!0,parallelLoaded:!0,url:o,version:l})}const v=performance.now();g.addEventListener("load",(()=>{if(f||r?i.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:g.src,storeId:i.storeId,type:o?"jsdelivr":"vercel"}):i.loadScriptLogHandler({fallbackLoadTime:performance.now()-v,scriptLoadUrl:g.src,storeId:i.storeId,type:o?"jsdelivr":"vercel"}),i.isBigCommerce||(i.isBigCommerce=!!window.stencilBootstrap||!!window.bcConfig||!!document.querySelector('script[src*="bigcommerce.com"]')),window.Zonos.zonosQaUrl=a,window.Zonos.internationalHideSelector=i.internationalHideSelector,window.Zonos.isBigCommerce=i.isBigCommerce,i.isLegacyCheckout){if(!i.zonosApiKey)throw i.legacyCheckoutErrorHandler({message:"zonosApiKey is required for legacy checkout",tempCartUUID:e.tempCartUUID}),new Error("zonosApiKey is required for legacy checkout");if(!i.tempCartData)throw i.legacyCheckoutErrorHandler({message:"tempCartData is required for legacy checkout",tempCartUUID:e.tempCartUUID}),new Error("zonosApiKey is required for legacy checkout");if(i.legacyStoreFavicon){const e=document.createElement("link");e.rel="shortcut icon",e.type="image/x-icon",e.href=i.legacyStoreFavicon,document.head.appendChild(e)}window.Zonos.tempCartData=i.tempCartData;const o=Object.assign(Object.assign({},e),{appearance:Object.assign(Object.assign({},e.appearance),{logoUrl:i.legacyStoreLogo||""}),checkoutSettings:Object.assign(Object.assign({},e.checkoutSettings),{successBehavior:"ZONOS_SUCCESS_PAGE",successRedirectUrl:i.tempCartData.contShoppingURL}),zonosApiKey:i.zonosApiKey});e=o}window.Zonos.version&&(n(`[ZONOS - loadZonos] Execute "Zonos.init" from "${w}" from "${u}"`,"info"),window.Zonos.init(e))})),g.addEventListener("error",(async()=>{if(!f&&!r){const o=p();i.injectZonos({initConfig:e,isGithubCdn:!0,url:o,version:l})}["localhost",".zonos.com"].some((e=>window.location.href.includes(e)))||a||(f||r?i.loadScriptLogParallelHandler({fallbackLoadTime:performance.now()-v,isError:!0,scriptLoadUrl:g.src,storeId:i.storeId,type:o?"jsdelivr":"vercel"}):s(o?{endpoint:g.src,errors:["zonos.js - Failed to fetch github CDN."],metadata:{cdnLoadTime:performance.now()-v,cdnType:"jsdelivr",loadUrl:m,version:l}}:{endpoint:g.src,errors:["[Info] Using alternative CDN. Failed to fetch script"],metadata:{vercelLoadTime:performance.now()-v}}))})),document.head.appendChild(g)},c.setupCartData=async e=>{const t=await(async e=>{const{errors:t,json:n}=await o("https://v1.route.js.zonos.com/api/bigcommerce/legacy-migration/get-temp-cart",{body:{tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"});return!n||t.length?null:n})(e);if(n("[ZONOS - loadZonos] getting temp cart data","info",t),!t)throw r("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),i.legacyCheckoutErrorHandler({message:"Error getting temp cart data",tempCartUUID:e}),new Error("Error getting temp cart data");return i.tempCartData=t.tempCart,i.legacyStoreLogo=t.storeLogoUrl,i.legacyStoreFavicon=t.storeFaviconUrl,{storeId:t.tempCart.storeId,zonosApiKey:t.zonosApiKey}},c.init=async e=>{var t;const s="https://v1.3.12-alpha.11.js.zonos.com",a=null===(t=document.querySelector("script[src*='/loadZonos.js']"))||void 0===t?void 0:t.src,c=document.querySelector('script[src*="/zonos.js"]'),l=null==a?void 0:a.includes("timestamp=");if(!a||!l)return void r("[ZONOS - loadZonos] A timestamp is required as a query parameter in the loadZonos.js script source. This timestamp ensures that you are loading the most recent version of the script, avoiding any cached versions.");if(c||!a||i.requested)return void n("[ZONOS - loadZonos] script is already loaded or requested","info");i.requested=!0;let d=e.storeId;if(e.tempCartUUID){const o=await i.setupCartData(e.tempCartUUID);d=o.storeId,i.zonosApiKey=o.zonosApiKey,i.isLegacyCheckout=!0}if(!d)return n("[ZONOS - loadZonos] loading latest script since storeId is not provided."),void i.injectZonos({initConfig:e,url:s,version:null});i.storeId=d;const p=new URL("https://v1.route.js.zonos.com/api/get-store-version");p.searchParams.set("storeId",e.storeId.toString());const{errors:m,json:u}=await o(p.toString());if(m.length||!u)return n("[ZONOS - loadZonos] Error getting store version, loadding the latest version.","error"),void i.injectZonos({initConfig:e,url:s,version:null});const{version:g}=u;if(!c){const{currentLoadScriptUrl:o,isForceLoadVersionDomain:t,isWhiteListed:r}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),n=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:a}),s=r&&!t?o:`${"alpha"===g?"alpha":`v${g}`}.js.zonos.com`,c=r&&!t?null:g;n("[ZONOS - loadZonos] injecting zonos script","info",{currentLoadScriptUrl:o,isForceLoadVersionDomain:t,isWhiteListed:r,loadUrl:s,loadVersion:c,version:g}),i.injectZonos({initConfig:e,url:s,version:c})}},void 0===window.Zonos&&(window.Zonos=c)})();
|
package/dist/scripts/zonos.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const e=(e,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="https://js.stripe.com/v3",n=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,r="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let s=null;const i=e=>(null!==s||(s=new Promise(((s,i)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(r),window.Stripe)s(window.Stripe);else try{let l=(()=>{const e=document.querySelectorAll(`script[src^="${o}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&n.test(o.src))return o}return null})();l&&e?console.warn(r):l||(l=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",r=document.createElement("script");r.src=`${o}${n}`;const s=document.head||document.body;return s?(s.appendChild(r),r):(t("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==l||l.addEventListener("load",(()=>{window.Stripe?s(window.Stripe):i(new Error("Stripe.js not available"))})),null==l||l.addEventListener("error",(()=>{i(new Error("Failed to load Stripe.js"))}))}catch(e){return void i(e)}else s(null)}))),s),l=Promise.resolve().then((()=>i(null)));let c=!1;l.catch((e=>{c||console.warn(e)}));var d;const a=(()=>{const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:t,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const t=new URL(e).origin,o=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>t.includes(e))),n=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:n,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?t:null})()||"https://v1.3.12-alpha.11.js.zonos.com",u="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.12-alpha.11",p="https://rsms.me",m="https://fonts.googleapis.com",h=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class y{}d=y,y.doneInit=!1,y.debug=!!window.location.search.match(/\?.*(&*)zonosDebug=1/),y.zonosConversionTest=!!window.location.search.match(/\?.*(&*)zonosConversionTest/),y.isBigCommerce=!1,y.internationalHideSelector="",y.zonosQaUrl=null,y.version="v1.3.12-alpha.11",y.modeAlerted=!1,y.tempCartData=null,y.getCurrentTimestamp=()=>(new Date).getTime(),y.zonosController=null,y.init=async({appearance:o,checkoutSettings:n,currencyConverter:r,helloSettings:s,storeId:i,zonosApiKey:l})=>{d.doneInit||(e(`====== ZONOS DEBUG MODE: on (${d.version}) ======`),l?(d.zonosApiKey=l,d.storeId=i,e("init zonos"),d.injectSentryScript(),d.injectZonosCdn(),d.injectZonosCss(),d.injectFonts(),d.injectController({config:{appearance:o,checkoutSettings:n,currencyConverter:r,helloSettings:s},zonosApiKey:l}),d.doneInit=!0):t("Missing Zonos API key"))},y.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},y.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},y.showNotification=e=>{var t;null===(t=d.zonosController)||void 0===t||t.showNotification(e)},y.updateOrganizationName=e=>{var t;null===(t=d.zonosController)||void 0===t||t.updateOrganizationName(e)},y.disablePlaceOrderButtons=({autoEnable:e=!0,disable:t,placeOrderButtonSelector:o})=>{if(o){const n=document.querySelectorAll(o),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},y.injectController=({config:o,zonosApiKey:n})=>{var r;if(document.querySelector("zonos-controller"))return;if(null===(r=o.checkoutSettings)||void 0===r?void 0:r.placeOrderButtonSelector){const e=o.checkoutSettings.placeOrderButtonSelector;d.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e});new MutationObserver((()=>{d.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=o,s.zonosApiKey=n,s.addEventListener("stripeInitEvent",(async o=>{const{detail:n}=o;e("loading Stripe");const r=await(async(...e)=>{c=!0;const t=Date.now();return l.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);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):t("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),d.zonosController=s,e("Zonos controller injected!")},y.injectSentryScript=()=>{const o="https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js";if(document.querySelector(`script[src="${o}"]`))return void e("Sentry script already exists in the document","warn");const n=document.head||document.body,r=document.createElement("script");r.crossOrigin="anonymous",r.src=o,r.integrity="sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l",r.setAttribute("data-lazy","no"),r.onerror=()=>{t(`Failed to load ${r.src}`)},r.onload=()=>{var e;null===(e=window.Sentry)||void 0===e||e.init({allowUrls:[/js\.zonos\.com\/dist\/scripts/],dsn:"https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760",ignoreErrors:["Failed to load Stripe.js"],release:`zonos-elements@${d.version}`,tracesSampler:({transactionContext:e})=>"pageload"===e.op?1:.25})},n.appendChild(r)},y.injectScript=({fallBackDomain:o,isModule:n,scriptDomain:r,theRestUrl:s})=>{const i=`${r}/${s}`;if(document.querySelector(`script[src="${i}"]`))return void e(`Zonos script "${i}" already exists in the document`,"warn");const l=document.head||document.body,c=document.createElement("script");n?c.type="module":c.noModule=!0,c.src=i,c.crossOrigin="anonymous",c.onerror=()=>{/\/\/v\d+\./g.test(r)?(o&&d.injectScript({isModule:n,scriptDomain:o,theRestUrl:s}),t(`Failed to load ${c.src}`)):e("No need to fallback since this is not a versioned domain","warn")},l.appendChild(c)},y.injectZonosCdn=()=>{d.injectScript({fallBackDomain:u,isModule:!0,scriptDomain:a,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),d.injectScript({fallBackDomain:u,isModule:!1,scriptDomain:a,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},y.injectStylesheet=({fallBackDomain:o,stylesheetDomain:n,theRestUrl:r})=>{const s=document.head||document.body,i=document.createElement("link");i.rel="preconnect",i.href=`${a}/`,s.appendChild(i);const l=document.createElement("link");l.rel="stylesheet",l.href=`${n}/${r}`,l.onerror=()=>{const s=/\/\/v\d+\./g.test(n);s?(o&&s&&d.injectStylesheet({stylesheetDomain:o,theRestUrl:r}),t(`Failed to load ${l.href}`)):e("No need to fallback since this is not a versioned domain","warn")},s.appendChild(l)},y.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(d.injectStylesheet({fallBackDomain:u,stylesheetDomain:a,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},y.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${p}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&!h.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=p,t.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${p}/inter/inter.css`,t.appendChild(n),e("Zonos font injected!")},y.setupGoogleFont=e=>{var t;null===(t=d.zonosController)||void 0===t||t.setupGoogleFont(e)},y.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^="${m}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=m,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=y)})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const e=(e,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="https://js.stripe.com/v3",n=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,r="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let s=null;const i=e=>(null!==s||(s=new Promise(((s,i)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(r),window.Stripe)s(window.Stripe);else try{let l=(()=>{const e=document.querySelectorAll(`script[src^="${o}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&n.test(o.src))return o}return null})();l&&e?console.warn(r):l||(l=(e=>{const n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",r=document.createElement("script");r.src=`${o}${n}`;const s=document.head||document.body;return s?(s.appendChild(r),r):(t("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})(e)),null==l||l.addEventListener("load",(()=>{window.Stripe?s(window.Stripe):i(new Error("Stripe.js not available"))})),null==l||l.addEventListener("error",(()=>{i(new Error("Failed to load Stripe.js"))}))}catch(e){return void i(e)}else s(null)}))),s),l=Promise.resolve().then((()=>i(null)));let c=!1;l.catch((e=>{c||console.warn(e)}));var a;const d=(()=>{const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:t,isWhiteListed:o}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const t=new URL(e).origin,o=["dev.elements.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>t.includes(e))),n=["qa.js.zonos.com"].some((e=>t.includes(e)));return{currentLoadScriptUrl:t,isForceLoadVersionDomain:n,isWhiteListed:o}})({loadScriptSrc:null==e?void 0:e.src});return o?t:null})()||"https://v1.3.12-alpha.11.js.zonos.com",u="https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.12-alpha.11",p="https://rsms.me",m="https://fonts.googleapis.com",h=/^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;class y{}a=y,y.doneInit=!1,y.debug=!!window.location.search.match(/\?.*(&*)zonosDebug=1/),y.zonosConversionTest=!!window.location.search.match(/\?.*(&*)zonosConversionTest/),y.isBigCommerce=!1,y.internationalHideSelector="",y.zonosQaUrl=null,y.version="v1.3.12-alpha.11",y.modeAlerted=!1,y.tempCartData=null,y.getCurrentTimestamp=()=>(new Date).getTime(),y.zonosController=null,y.init=async({appearance:o,checkoutSettings:n,currencyConverter:r,helloSettings:s,storeId:i,zonosApiKey:l})=>{a.doneInit||(e(`====== ZONOS DEBUG MODE: on (${a.version}) ======`),l?(a.zonosApiKey=l,a.storeId=i,e("init zonos"),a.injectSentryScript(),a.injectZonosCdn(),a.injectZonosCss(),a.injectFonts(),a.injectController({config:{appearance:o,checkoutSettings:n,currencyConverter:r,helloSettings:s},zonosApiKey:l}),a.doneInit=!0):t("Missing Zonos API key"))},y.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},y.openHelloDialog=e=>{const t=document.querySelector("zonos-hello");t&&t.openHelloDialog(null==e||e)},y.showNotification=e=>{var t;null===(t=a.zonosController)||void 0===t||t.showNotification(e)},y.updateOrganizationName=e=>{var t;null===(t=a.zonosController)||void 0===t||t.updateOrganizationName(e)},y.disablePlaceOrderButtons=({autoEnable:e=!0,disable:t,placeOrderButtonSelector:o})=>{if(o){const n=document.querySelectorAll(o),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};n.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{n.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},y.injectController=({config:o,zonosApiKey:n})=>{var r;if(document.querySelector("zonos-controller"))return;if(null===(r=o.checkoutSettings)||void 0===r?void 0:r.placeOrderButtonSelector){const e=o.checkoutSettings.placeOrderButtonSelector;a.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e});new MutationObserver((()=>{a.disablePlaceOrderButtons({disable:!0,placeOrderButtonSelector:e})})).observe(document.body,{childList:!0,subtree:!0})}const s=document.createElement("zonos-controller");s.config=o,s.zonosApiKey=n,s.addEventListener("stripeInitEvent",(async o=>{const{detail:n}=o;e("loading Stripe");const r=await(async(...e)=>{c=!0;const t=Date.now();return l.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);r?(window.Zonos.stripe=r,s.initCheckoutElement(r)):t("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(s),a.zonosController=s,e("Zonos controller injected!")},y.injectSentryScript=()=>{const o="https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js";if(document.querySelector(`script[src="${o}"]`))return void e("Sentry script already exists in the document","warn");const n=document.head||document.body,r=document.createElement("script");r.crossOrigin="anonymous",r.src=o,r.integrity="sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l",r.setAttribute("data-lazy","no"),r.onerror=()=>{t(`Failed to load ${r.src}`)},r.onload=()=>{var e;null===(e=window.Sentry)||void 0===e||e.init({allowUrls:[/js\.zonos\.com\/dist\/scripts/],dsn:"https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760",ignoreErrors:["Failed to load Stripe.js"],release:`zonos-elements@${a.version}`,tracesSampler:({transactionContext:e})=>"pageload"===e.op?1:.25})},n.appendChild(r)},y.injectScript=({fallBackDomain:o,isModule:n,scriptDomain:r,theRestUrl:s})=>{const i=`${r}/${s}`;if(document.querySelector(`script[src="${i}"]`))return void e(`Zonos script "${i}" already exists in the document`,"warn");const l=document.head||document.body,c=document.createElement("script");n?c.type="module":c.noModule=!0,c.src=i,c.crossOrigin="anonymous",c.onerror=()=>{/\/\/v\d+\./g.test(r)?(o&&a.injectScript({isModule:n,scriptDomain:o,theRestUrl:s}),t(`Failed to load ${c.src}`)):e("No need to fallback since this is not a versioned domain","warn")},l.appendChild(c)},y.injectZonosCdn=()=>{a.injectScript({fallBackDomain:u,isModule:!0,scriptDomain:d,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),a.injectScript({fallBackDomain:u,isModule:!1,scriptDomain:d,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),e("Zonos cdn script injected!")},y.injectStylesheet=({fallBackDomain:o,stylesheetDomain:n,theRestUrl:r})=>{const s=document.head||document.body,i=document.createElement("link");i.rel="preconnect",i.href=`${d}/`,s.appendChild(i);const l=document.createElement("link");l.rel="stylesheet",l.href=`${n}/${r}`,l.onerror=()=>{const s=/\/\/v\d+\./g.test(n);s?(o&&s&&a.injectStylesheet({stylesheetDomain:o,theRestUrl:r}),t(`Failed to load ${l.href}`)):e("No need to fallback since this is not a versioned domain","warn")},s.appendChild(l)},y.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?e("Zonos style links already injected","warn"):(a.injectStylesheet({fallBackDomain:u,stylesheetDomain:d,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),e("Zonos style css injected!"))},y.injectFonts=()=>{if((()=>{const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${p}"]`);for(let t=0;t<e.length;t++){const o=e[t];if(o&&!h.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=p,t.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${p}/inter/inter.css`,t.appendChild(n),e("Zonos font injected!")},y.setupGoogleFont=e=>{var t;null===(t=a.zonosController)||void 0===t||t.setupGoogleFont(e)},y.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^="${m}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=m,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!`)},exports.Zonos=y})();
|
|
@@ -36,6 +36,10 @@ export interface Zonos {
|
|
|
36
36
|
tempCartData: TempCart | null;
|
|
37
37
|
version: string;
|
|
38
38
|
zonosApiKey: string;
|
|
39
|
+
/**
|
|
40
|
+
* Flag to send tracking event to api for conversion testing, since we don't send tracking event to api when in debug/development mode
|
|
41
|
+
*/
|
|
42
|
+
zonosConversionTest?: boolean;
|
|
39
43
|
zonosQaUrl: string | null;
|
|
40
44
|
displayCurrency: () => void;
|
|
41
45
|
getCurrentTimestamp: () => number;
|
|
@@ -52,6 +56,7 @@ export declare abstract class Zonos {
|
|
|
52
56
|
static storeId: number;
|
|
53
57
|
static doneInit: boolean;
|
|
54
58
|
static debug: boolean;
|
|
59
|
+
static zonosConversionTest: boolean;
|
|
55
60
|
static isBigCommerce: boolean;
|
|
56
61
|
static internationalHideSelector: string;
|
|
57
62
|
static zonosQaUrl: string | null;
|
|
@@ -567,6 +567,18 @@ export type LocaleCountryMessagesQuery = {
|
|
|
567
567
|
pageName: Locale_PageName_Enum;
|
|
568
568
|
}>;
|
|
569
569
|
};
|
|
570
|
+
export type GetConversionEventBySessionIdAndOrgIdQuery = {
|
|
571
|
+
usage_conversionEvent: Array<{
|
|
572
|
+
countryCode: string | null;
|
|
573
|
+
createdAt: string;
|
|
574
|
+
eventName: string;
|
|
575
|
+
id: number;
|
|
576
|
+
metadata: Record<string, unknown> | Record<string, unknown>[] | null;
|
|
577
|
+
organizationId: string;
|
|
578
|
+
sessionId: string | null;
|
|
579
|
+
stepSeconds: number | null;
|
|
580
|
+
}>;
|
|
581
|
+
};
|
|
570
582
|
export type InsertConversionEventMutation = {
|
|
571
583
|
insert_usage_conversionEvent_one: {
|
|
572
584
|
id: number;
|
|
@@ -783,6 +795,9 @@ export declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionW
|
|
|
783
795
|
cleanupTestZonosElementSetting(variables?: {
|
|
784
796
|
[x: string]: never;
|
|
785
797
|
} | undefined, requestHeaders?: GraphQLClientRequestHeaders): Promise<CleanupTestZonosElementSettingMutation>;
|
|
798
|
+
getConversionEventBySessionIdAndOrgId(variables?: {
|
|
799
|
+
[x: string]: never;
|
|
800
|
+
} | undefined, requestHeaders?: GraphQLClientRequestHeaders): Promise<GetConversionEventBySessionIdAndOrgIdQuery>;
|
|
786
801
|
hasPreviousErrors(variables?: {
|
|
787
802
|
[x: string]: never;
|
|
788
803
|
} | undefined, requestHeaders?: GraphQLClientRequestHeaders): Promise<HasPreviousErrorsQuery>;
|
|
@@ -571,6 +571,19 @@ export type LocaleCountryMessagesQuery = {
|
|
|
571
571
|
}>;
|
|
572
572
|
};
|
|
573
573
|
|
|
574
|
+
export type GetConversionEventBySessionIdAndOrgIdQuery = {
|
|
575
|
+
usage_conversionEvent: Array<{
|
|
576
|
+
countryCode: string | null;
|
|
577
|
+
createdAt: string;
|
|
578
|
+
eventName: string;
|
|
579
|
+
id: number;
|
|
580
|
+
metadata: Record<string, unknown> | Record<string, unknown>[] | null;
|
|
581
|
+
organizationId: string;
|
|
582
|
+
sessionId: string | null;
|
|
583
|
+
stepSeconds: number | null;
|
|
584
|
+
}>;
|
|
585
|
+
};
|
|
586
|
+
|
|
574
587
|
export type InsertConversionEventMutation = {
|
|
575
588
|
insert_usage_conversionEvent_one: { id: number } | null;
|
|
576
589
|
};
|
|
@@ -1014,6 +1027,21 @@ export function getSdk(
|
|
|
1014
1027
|
'mutation',
|
|
1015
1028
|
);
|
|
1016
1029
|
},
|
|
1030
|
+
getConversionEventBySessionIdAndOrgId(
|
|
1031
|
+
variables?: { [x: string]: never },
|
|
1032
|
+
requestHeaders?: GraphQLClientRequestHeaders,
|
|
1033
|
+
): Promise<GetConversionEventBySessionIdAndOrgIdQuery> {
|
|
1034
|
+
return withWrapper(
|
|
1035
|
+
wrappedRequestHeaders =>
|
|
1036
|
+
client.request<GetConversionEventBySessionIdAndOrgIdQuery>(
|
|
1037
|
+
'',
|
|
1038
|
+
variables,
|
|
1039
|
+
{ ...requestHeaders, ...wrappedRequestHeaders },
|
|
1040
|
+
),
|
|
1041
|
+
'getConversionEventBySessionIdAndOrgId',
|
|
1042
|
+
'query',
|
|
1043
|
+
);
|
|
1044
|
+
},
|
|
1017
1045
|
hasPreviousErrors(
|
|
1018
1046
|
variables?: { [x: string]: never },
|
|
1019
1047
|
requestHeaders?: GraphQLClientRequestHeaders,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as o,f as n,l as t,a as e}from"./p-e4be7bd8.js";import{z as s}from"./p-1bbdfae5.js";const i=async(e,i)=>{var a,d;if((window.location.href.includes("zonos.com")||window.location.href.includes("checkout.iglobalstores.com")||(null===(a=window.Zonos)||void 0===a?void 0:a.zonosQaUrl)||(null===(d=window.Zonos)||void 0===d?void 0:d.debug))&&!window.Zonos.zonosConversionTest)return;const c=n.checkoutSessionId;if(!c)return;const r={checkoutSessionId:c,countryCode:t.selectedCountryCode,eventName:e,metadata:i,organizationId:s.organizationId};await o("https://v1.route.js.zonos.com/api/zonos-elements/track-conversion-event",{body:r,method:"POST"})},a=(o,n)=>new CustomEvent(o,{detail:n}),d=o=>{const n=s.checkoutSettings.analyticsProviders.find((o=>"GOOGLE_ANALYTICS"===o.type));n&&"DISABLED"!==(null==n?void 0:n.status)&&"function"==typeof window.gtag&&(e("Zonos submits gtag event","log",o),window.gtag("event",o,{}))};export{a as c,d as s,i as t}
|