@zonos/elements 1.3.242 → 1.3.243
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{cart-4246c004.js → cart-6d254f1a.js} +2 -0
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/{invoice-d9655e9e.js → invoice-8984eb26.js} +1 -1
- package/dist/cjs/{isCollectMobileTablet-65da8408.js → isCollectMobileTablet-7e929884.js} +1 -1
- package/dist/cjs/{paypal-a3921278.js → paypal-0f4b77fd.js} +1 -1
- package/dist/cjs/{placeTestOrder-907b981d.js → placeTestOrder-6cc9d040.js} +1 -1
- package/dist/cjs/{renderCheckoutCurrency-5fe59d60.js → renderCheckoutCurrency-df60f3a6.js} +1 -1
- package/dist/cjs/zonos-address-display_9.cjs.entry.js +1 -1
- package/dist/cjs/zonos-address_4.cjs.entry.js +1 -1
- package/dist/cjs/zonos-card_5.cjs.entry.js +2 -2
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +4 -4
- package/dist/cjs/zonos-checkout.cjs.entry.js +2 -2
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +1 -1
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +5 -5
- package/dist/cjs/zonos-collect.cjs.entry.js +3 -3
- package/dist/cjs/zonos-controller.cjs.entry.js +1 -1
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +3 -3
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +5 -5
- package/dist/cjs/zonos-invoice.cjs.entry.js +3 -3
- package/dist/collection/components/utils/api/triggerBuildLandedCost.js +3 -0
- package/dist/esm/{cart-697f78dc.js → cart-00134a17.js} +2 -0
- package/dist/esm/index.js +7 -7
- package/dist/esm/{invoice-50918381.js → invoice-4a8178f8.js} +1 -1
- package/dist/esm/{isCollectMobileTablet-2e7b4f01.js → isCollectMobileTablet-70fa91b6.js} +1 -1
- package/dist/esm/{paypal-b3299b37.js → paypal-2e28d0e7.js} +1 -1
- package/dist/esm/{placeTestOrder-245f2030.js → placeTestOrder-aa884e31.js} +1 -1
- package/dist/esm/{renderCheckoutCurrency-9404ed70.js → renderCheckoutCurrency-54994d08.js} +1 -1
- package/dist/esm/zonos-address-display_9.entry.js +1 -1
- package/dist/esm/zonos-address_4.entry.js +1 -1
- package/dist/esm/zonos-card_5.entry.js +2 -2
- package/dist/esm/zonos-cart-items_12.entry.js +4 -4
- package/dist/esm/zonos-checkout.entry.js +2 -2
- package/dist/esm/zonos-collect-cart-items_3.entry.js +1 -1
- package/dist/esm/zonos-collect-finish_6.entry.js +5 -5
- package/dist/esm/zonos-collect.entry.js +3 -3
- package/dist/esm/zonos-controller.entry.js +1 -1
- package/dist/esm/zonos-invoice-cart-items_2.entry.js +3 -3
- package/dist/esm/zonos-invoice-finish_5.entry.js +5 -5
- package/dist/esm/zonos-invoice.entry.js +3 -3
- package/dist/esm-es5/cart-00134a17.js +1 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{invoice-50918381.js → invoice-4a8178f8.js} +1 -1
- package/dist/esm-es5/{isCollectMobileTablet-2e7b4f01.js → isCollectMobileTablet-70fa91b6.js} +1 -1
- package/dist/esm-es5/{paypal-b3299b37.js → paypal-2e28d0e7.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-245f2030.js → placeTestOrder-aa884e31.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-9404ed70.js → renderCheckoutCurrency-54994d08.js} +1 -1
- package/dist/esm-es5/zonos-address-display_9.entry.js +1 -1
- package/dist/esm-es5/zonos-address_4.entry.js +1 -1
- package/dist/esm-es5/zonos-card_5.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
- package/dist/esm-es5/zonos-collect.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice.entry.js +1 -1
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/utils/api/triggerBuildLandedCost.d.ts +3 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-949c9d2a.entry.js → p-069e8b40.entry.js} +1 -1
- package/dist/zonos-elements/{p-28077dd4.entry.js → p-0a1b82df.entry.js} +1 -1
- package/dist/zonos-elements/{p-bdf49bed.entry.js → p-0e70900c.entry.js} +1 -1
- package/dist/zonos-elements/{p-ea0289e8.system.js → p-0fcd7a94.system.js} +1 -1
- package/dist/zonos-elements/{p-1864fc4e.entry.js → p-10b1f35f.entry.js} +1 -1
- package/dist/zonos-elements/{p-457a2957.system.js → p-11e79ab7.system.js} +1 -1
- package/dist/zonos-elements/{p-8432de4c.system.entry.js → p-20c5d640.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-635b8da9.entry.js → p-41147617.entry.js} +1 -1
- package/dist/zonos-elements/{p-e1ed7c4a.system.entry.js → p-47f02d2a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-258407c6.js → p-4d2ed8d5.js} +1 -1
- package/dist/zonos-elements/{p-ce48f579.system.entry.js → p-4fc549f4.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-7e51fe84.system.entry.js → p-56107bdf.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-5aff8a31.system.entry.js → p-599347f4.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-b9974182.system.entry.js → p-60443628.system.entry.js} +1 -1
- package/dist/zonos-elements/p-675dd093.system.js +1 -0
- package/dist/zonos-elements/{p-3318ba9e.system.entry.js → p-67e19c00.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-b526a41e.system.js → p-68f419f1.system.js} +1 -1
- package/dist/zonos-elements/{p-1c54c3db.system.entry.js → p-6b1091f1.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-fecf66da.entry.js → p-6beaff11.entry.js} +1 -1
- package/dist/zonos-elements/{p-8159d0f8.js → p-6d82c3a4.js} +2 -2
- package/dist/zonos-elements/{p-5216584e.system.js → p-6fad6110.system.js} +1 -1
- package/dist/zonos-elements/{p-9ab32f9b.entry.js → p-73e79407.entry.js} +1 -1
- package/dist/zonos-elements/{p-fc783723.entry.js → p-7a4a4b52.entry.js} +1 -1
- package/dist/zonos-elements/{p-5feb3750.system.entry.js → p-899c3878.system.entry.js} +1 -1
- package/dist/zonos-elements/p-914149a4.js +1 -0
- package/dist/zonos-elements/{p-bfc09897.entry.js → p-9691381e.entry.js} +1 -1
- package/dist/zonos-elements/{p-036e6a72.system.js → p-975c6928.system.js} +1 -1
- package/dist/zonos-elements/{p-b90f346f.system.entry.js → p-af7e37c1.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-67414f66.system.js → p-b3dbe0ec.system.js} +1 -1
- package/dist/zonos-elements/{p-1af042d1.js → p-c02e3fef.js} +1 -1
- package/dist/zonos-elements/{p-689ce3eb.system.entry.js → p-c11668b5.system.entry.js} +1 -1
- package/dist/zonos-elements/p-c2442878.system.js +1 -1
- package/dist/zonos-elements/{p-9a67d4f2.entry.js → p-c8e5bb8a.entry.js} +1 -1
- package/dist/zonos-elements/{p-1023a77d.js → p-c9db8939.js} +1 -1
- package/dist/zonos-elements/{p-b34553d8.entry.js → p-d042455d.entry.js} +1 -1
- package/dist/zonos-elements/{p-13b3a9bd.entry.js → p-dbea1f9b.entry.js} +1 -1
- package/dist/zonos-elements/{p-ee5d5203.system.entry.js → p-e3b4a218.system.entry.js} +1 -1
- package/dist/zonos-elements/p-f5cfce05.js +1 -0
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/cart-697f78dc.js +0 -1
- package/dist/zonos-elements/p-2aa284e6.js +0 -1
- package/dist/zonos-elements/p-bcdf1cba.js +0 -1
- package/dist/zonos-elements/p-d9b96ce6.system.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{z as e,c as t}from"./p-b2a0ab4a.js";import{s as o,l as n,e as s,t as r,f as i,b as a}from"./p-fab5f272.js";import{f as d,h as l,g as c,a as u,s as m,l as p,j as v}from"./p-41dd1cb8.js";import{l as h,b as y}from"./p-0a377722.js";import{i as w}from"./p-57fa64d7.js";import{g}from"./p-1f894984.js";const f=({firstName:e,lastName:t,name:o})=>{var n;if(!o&&!e&&!t)return{firstName:"",lastName:""};const s=(null==o?void 0:o.split(/\s+/))||[];return{firstName:(null==e?void 0:e.trim())||(null===(n=s[0])||void 0===n?void 0:n.trim())||"",lastName:(null==t?void 0:t.trim())||s.slice(1).join(" ").trim()||""}},b=({currentAddress:e,translatedAddress:t})=>{var o,n,s,r,i,a;const{city:d,country:l,line1:c,line2:u,postal_code:m,state:p}=e.value.address,v=e.value.name||[e.value.firstName,e.value.lastName].join(" ");return{city:(null===(o=t.city)||void 0===o?void 0:o[d])||d,country:l,line1:(null===(n=t.line1)||void 0===n?void 0:n[c])||c,line2:(null===(s=t.line2)||void 0===s?void 0:s[u||""])||u||"",name:(null===(r=t.name)||void 0===r?void 0:r[v])||v,phone:e.value.phone||"",postal_code:(null===(i=t.postal_code)||void 0===i?void 0:i[m])||m,state:(null===(a=t.state)||void 0===a?void 0:a[p])||p}},S=e=>{var t;const r="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),i=D.stripeLinkEventData,a=D.stripeAddressEventData,d=D.stripeShippingSameAsBilling?D.stripeAddressEventData:D.stripeBillingAddressEventData;if(!a||!d)throw new Error("Missing stripe address data");const l=b({currentAddress:a,translatedAddress:D.translatedAddress.address}),{firstName:c,lastName:u}=f({name:l.name}),m=b({currentAddress:d,translatedAddress:D.translatedAddress.address}),{firstName:p,lastName:v}=f({name:m.name}),h=s()||"US";return{billingAddress:{addressLine1:m.line1,addressLine2:m.line2||"",city:m.city,country:m.country,postalCode:m.postal_code,state:m.state},billingContact:{firstName:p,lastName:v,phone:m.phone},cartCurrencyCode:null===(t=se.items[0])||void 0===t?void 0:t.currencyCode,cartId:e,checkoutSessionCountry:h||n.selectedCountryCode||void 0,checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:D.companyName,email:null==i?void 0:i.value.email,firstName:c,lastName:u,phone:l.phone},isTest:!!r,landedCostAdjustments:se.promoCode?[{amount:0,productId:null,promoCode:se.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToTaxId:D.taxId,shippingAddress:{addressLine1:l.line1,addressLine2:l.line2,city:l.city,country:l.country,postalCode:l.postal_code,state:l.state}}},C=()=>{const e="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),t=D.stripeLinkEventData,n=D.stripeAddressEventData,s=D.stripeShippingSameAsBilling?D.stripeAddressEventData:D.stripeBillingAddressEventData;if(h({stripeAddressData:n,stripeBillingAddressData:s},"info"),!n||!s)throw new Error("Missing stripe address data");const r=b({currentAddress:n,translatedAddress:D.translatedAddress.address}),{firstName:i,lastName:a}=f({name:r.name}),d=b({currentAddress:s,translatedAddress:D.translatedAddress.address}),{firstName:l,lastName:c}=f({name:d.name}),u=se.adjustments.map((e=>({amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}))),m=se.promoCode?[{amount:0,productId:null,promoCode:se.promoCode,sku:null,type:"PROMO_CODE"},...u]:u;return{billingAddress:{addressLine1:d.line1,addressLine2:d.line2||"",city:d.city,country:d.country,postalCode:d.postal_code,state:d.state},billingContact:{firstName:l,lastName:c,phone:d.phone},checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:D.companyName,email:null==t?void 0:t.value.email,firstName:i,lastName:a,phone:r.phone},isTest:e,items:se.items,landedCostAdjustments:m,shipToTaxId:D.taxId,shippingAddress:{addressLine1:r.line1,addressLine2:r.line2,city:r.city,country:r.country,postalCode:r.postal_code,state:r.state}}};const O=async t=>{const o=window.Zonos.cartId;if(!o)return await(async t=>{var o;const n=e.checkoutSettings.buildLandedCost;if(n){const e=await(async e=>{var t,o,n,s,r;const i=C(),a=await e({billingAddress:i.billingAddress,billingContact:i.billingContact,checkoutSessionId:i.checkoutSessionId,contact:i.contact,landedCostAdjustments:i.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:i.shippingAddress,zonosApiRoute:d.vercel});if(!a||!(null===(t=a.checkoutSessionWorkflow)||void 0===t?void 0:t.length)&&(null===(o=a.errors)||void 0===o?void 0:o.length))throw new Error(`Failed to build landed cost: ${(null===(s=null===(n=null==a?void 0:a.errors)||void 0===n?void 0:n[0])||void 0===s?void 0:s.message)||"Unknown error"}`);const{errors:c,json:u}=await l("/api/zonos-elements/validate-landed-cost",{body:a,headers:{"Content-Type":"application/json"},method:"POST"});if(!u||c.length)throw new Error(`Invalid landed cost object: ${(null===(r=c.find(Boolean))||void 0===r?void 0:r.message)||"Unknown error"}`);return a})(n);return e}const{errors:s,json:r}=await l("/api/zonos-elements/calculate-landed-cost",{body:C(),method:"POST",signal:null==t?void 0:t.signal});if(s.length||!r){if("The user aborted a request."===(null===(o=s[0])||void 0===o?void 0:o.message))throw new Error("The landed cost calculation request was aborted to initiate a new one.");if(s.forEach((e=>{console.warn(`Error calculating landed cost: ${e.message}`)})),!r)throw new Error("Failed to calculate landed cost");return r}return r})(t);const n=await(async({abortController:e,cartId:t})=>{var o,n,s,r,i;const{errors:a,json:d}=await l("/api/zonos-elements/cart-calculate-landed-cost",{body:S(t),method:"POST",signal:null==e?void 0:e.signal});if(a.length||!d){const e="string"==typeof(null===(o=a[0])||void 0===o?void 0:o.message)&&("The user aborted a request."===(null===(n=a[0])||void 0===n?void 0:n.message)||(null===(s=a[0])||void 0===s?void 0:s.message.includes("signal is aborted"))||(null===(r=a[0])||void 0===r?void 0:r.message.includes("The operation was aborted"))||(null===(i=a[0])||void 0===i?void 0:i.message.includes("Fetch is aborted")));throw new Error(e?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost")}return d})({abortController:t,cartId:o}),{cartWorkflow:s}=n,r=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}(n,["cartWorkflow"]);return Object.assign(Object.assign({},r),{itemCreateWorkflow:s.items})},A=async({checkoutSessionId:t,eventName:o,metadata:s})=>{var r,i;const a=Date.now(),d=[...window.Zonos.trackEventLogs];window.Zonos.trackEventLogs.push({checkoutSessionId:t,eventCreated:a,eventName:o});const p=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!(null===(r=window.Zonos)||void 0===r?void 0:r.zonosQaUrl)||!!(null===(i=window.Zonos)||void 0===i?void 0:i.debug);if((c()||u()||p)&&!window.Zonos.zonosConversionTest)return;const v=n.selectedCountryCode,h=e.organizationId;if(!t)return void m({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No checkout session id found`],metadata:{allLogs:y,checkoutSessionId:t,eventName:o,metadata:s,organizationId:h,trackEventLogs:d}});h||m({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No organization id found`],metadata:{allLogs:y,checkoutSessionId:t,eventName:o,metadata:s,organizationId:h,trackEventLogs:d}});const w={checkoutSessionId:t,countryCode:v,eventCreated:a,eventName:o,metadata:Object.assign(Object.assign({},s),{trackEventLogs:d}),organizationId:h};await l("/api/zonos-elements/track-conversion-event",{body:w,method:"POST"})},k=({address:e,invalidAdddressList:t})=>{if(!e)return;if(!t)return;const o={};return t.city&&(o.city=e.city),t.line1&&(o.line1=e.line1),t.line2&&(o.line2=e.line2),t.postal_code&&(o.postal_code=e.postal_code),t.state&&(o.state=e.state),t.name&&(o.name=e.name),Object.keys(o).length?o:void 0},I=e=>e.sort(((e,t)=>e.amount-t.amount)),N=async()=>{var e;const{errors:t,json:n}=await(async()=>{if(!o.checkoutSessionId)return{errors:[{message:"No checkout session id found"}],json:null};const e=new URLSearchParams;e.set("checkoutSessionId",o.checkoutSessionId);const{errors:t,json:n}=await l(`/api/zonos-elements/get-checkout-session?${e.toString()}`);return{errors:t,json:n}})();return t.length||!n?(p("Failed to retrieve checkout session info before confirming payment ",t),m({endpoint:"validateCheckoutSession",errors:t.map((e=>e.message)),metadata:{allLogs:y}}),{errorMessage:r("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:!1}):(null===(e=n.checkoutSession.landedCost)||void 0===e?void 0:e.id)?{errorMessage:"",valid:!0}:(p("Landed cost is not found in the checkout session before confirming payment."),m({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:y}}),{errorMessage:r('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:!1})},j=({theme:t})=>{const o={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:e.appearance.fontSizeInputValue?`${e.appearance.fontSizeInputValue}px`:void 0,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:e.appearance.fontSizeInputLabel?`${e.appearance.fontSizeInputLabel}px`:void 0},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};return"DARK"===t?Object.assign(Object.assign({},o),{".Action":Object.assign(Object.assign({},o[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},o[".PickerItem--new"]),{color:"white"})}):o},T=({borderStyle:e,theme:t})=>"DARK"===t?{borderRadius:g({overrideBorderStyle:e}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"}:{borderRadius:g({overrideBorderStyle:e}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"},{onChange:E,reset:P,state:D}=t((()=>({checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:!1,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:!1,isFetchingLandedCost:!1,isFetchingSession:!1,partyBillingId:null,partyShippingId:null,shouldInventoryRefund:!1,shouldRenderPayInUsdButton:!1,skipPaymentIntent:"0"!==new URLSearchParams(window.location.search).get("skipPaymentIntent"),stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenAsyncAddressUpdate:null,stripeAddressUsedWhenFetchingLC:null,stripeAddressUsedWhenValidatingAddress:null,stripeBillingAddressElement:null,stripeBillingAddressEventData:null,stripeBillingAddressUsedWhenAsyncAddressUpdate:null,stripeBillingAddressUsedWhenFetchingLC:null,stripeBillingAddressUsedWhenValidatingAddress:null,stripeCustomerSessionClientSecret:null,stripeElements:null,stripeElementsForBillingAddress:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null,stripeShippingSameAsBilling:!0,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}))),L=()=>{window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")},x=e=>{window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))},R=()=>{const e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return v(e)},z=async t=>{var o,s;const r=D.clientSecret;if(!D.stripe)return void h("Skip. Stripe is not initialized");const i=(({clientSecret:t,overrideBorderRadius:o,overridePrimaryColor:s,overrideSecondaryColor:r,overrideTheme:i,paypalEnabled:a})=>{const d=s||e.appearance.colorPrimary,l=r||e.appearance.colorSecondary,c=(window.Zonos.isCollect||window.Zonos.isInvoice?"DARK"===e.appearance.theme:d&&w(d))?"night":"flat",u="DARK"===i?"night":"flat",m=a?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},j({theme:i||"LIGHT"})),theme:i?u:c,variables:Object.assign(Object.assign({},T({borderStyle:o,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:t||void 0,customerSessionClientSecret:D.stripeCustomerSessionClientSecret||void 0,externalPaymentMethodTypes:[...m],locale:n.selectedLocale}})({clientSecret:r,overrideBorderRadius:null==t?void 0:t.overrideBorderRadius,overridePrimaryColor:null==t?void 0:t.overridePrimaryColor,overrideSecondaryColor:null==t?void 0:t.overrideSecondaryColor,overrideTheme:null==t?void 0:t.overrideTheme,paypalEnabled:null==t?void 0:t.paypalEnabled}),a=JSON.stringify(i)===JSON.stringify(D.stripeElementsOptions);if(!D.stripeElements||!D.stripeElementsForBillingAddress)return D.stripeElementsForBillingAddress=null===(o=D.stripe)||void 0===o?void 0:o.elements(i),h("Stripe elements for billing address initialized"),D.stripeElements=null===(s=D.stripe)||void 0===s?void 0:s.elements(i),D.stripeElementsOptions=i,void h("Stripe elements initialized");a||(D.stripeElements.update(i),D.stripeElementsForBillingAddress.update(i),D.stripeElementsOptions=i,D.stripeElements.fetchUpdates()),h("Stripe elements updated")},U=()=>{sessionStorage.removeItem("zonos--client-secret"),P(),D.stripe=window.Zonos.stripe},_=({address:e,firstName:t,lastName:n,name:s,phone:r})=>{const{firstName:i,lastName:a}=f({firstName:t,lastName:n,name:s});return i&&a||m({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:y,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,firstName:t,lastName:n,name:s}}),r||m({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:y,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,phone:r}}),{city:e.city,country:e.country,firstName:i,lastName:a,line1:e.line1,line2:e.line2,phone:r||"",postal_code:e.postal_code,state:e.state}},B=async()=>{var e,t,n,s;if(!(null===(e=D.stripeAddressEventData)||void 0===e?void 0:e.complete)||!D.stripeShippingSameAsBilling&&!(null===(t=D.stripeBillingAddressEventData)||void 0===t?void 0:t.complete)||!D.stripeBillingAddressEventData)return{partiesCreated:!1};if(!se.landedCostData)return{partiesCreated:!1};const r=null===(n=se.landedCostData.find(Boolean))||void 0===n?void 0:n.landedCost.rootId;if(!r)return m({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:y,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId}}),{partiesCreated:!1};const i=(()=>{var e,t,o,n,s,r;const i=JSON.stringify(null===(e=D.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=D.stripeLinkEventData)||void 0===t?void 0:t.value),a=JSON.stringify(null===(o=D.stripeAddressUsedWhenAsyncAddressUpdate)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=D.stripeAddressEventData)||void 0===n?void 0:n.value),d=!D.stripeShippingSameAsBilling&&JSON.stringify(null===(s=D.stripeBillingAddressUsedWhenAsyncAddressUpdate)||void 0===s?void 0:s.value)!==JSON.stringify(null===(r=D.stripeBillingAddressEventData)||void 0===r?void 0:r.value);return i||a||d||D.taxIdUsedWhenAsyncAddressUpdate!==D.taxId||D.companyNameUsedWhenAsyncAddressUpdate!==D.companyName})();if(!i)return{partiesCreated:!1};const a=_({address:D.stripeAddressEventData.value.address,firstName:D.stripeAddressEventData.value.firstName,lastName:D.stripeAddressEventData.value.lastName,name:D.stripeAddressEventData.value.name,phone:D.stripeAddressEventData.value.phone}),d=D.stripeShippingSameAsBilling?a:_({address:D.stripeBillingAddressEventData.value.address,firstName:D.stripeBillingAddressEventData.value.firstName,lastName:D.stripeBillingAddressEventData.value.lastName,name:D.stripeBillingAddressEventData.value.name,phone:D.stripeBillingAddressEventData.value.phone}),c="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:u,json:v}=await l("/api/zonos-elements/create-parties",{body:{address:a,billingAddress:d,companyName:D.companyName,email:(null===(s=D.stripeLinkEventData)||void 0===s?void 0:s.value.email)||"",isTest:c,rootId:r,taxId:D.taxId},method:"POST"});return u.length||!v?(p("Error occurs when creating parties",JSON.stringify(u,null,2)),m({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:y,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,errors:u,json:v}}),{partiesCreated:!1}):(D.companyNameUsedWhenAsyncAddressUpdate=D.companyName,D.stripeAddressUsedWhenAsyncAddressUpdate=D.stripeAddressEventData,D.stripeBillingAddressUsedWhenAsyncAddressUpdate=D.stripeBillingAddressEventData,D.taxIdUsedWhenAsyncAddressUpdate=D.taxId,D.partyBillingId=v.billToPartyId,D.partyShippingId=v.shipToPartyId,{partiesCreated:!0})},F=e=>({countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}),J=async t=>{var n,s,r,i;const a=(null==t?void 0:t.retries)||0,d=!!(null==t?void 0:t.applyingPromocode),l=(()=>{var e;const t=se.landedCostData&&(null===(e=se.landedCostData.find(Boolean))||void 0===e?void 0:e.subtotals.items)!==se.subtotal,o=(()=>{var e,t;const o=JSON.stringify(null===(e=D.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=D.stripeLinkEventData)||void 0===t?void 0:t.value),n=D.stripeAddressEventData&&JSON.stringify(F(D.stripeAddressEventData.value))!==JSON.stringify(D.stripeAddressUsedWhenFetchingLC),s=!D.stripeShippingSameAsBilling&&D.stripeBillingAddressEventData&&JSON.stringify(F(D.stripeBillingAddressEventData.value))!==JSON.stringify(D.stripeBillingAddressUsedWhenFetchingLC);return o||n||s})();return h("isPrefetchInfoOutdated","info",{isAddressOutdated:o}),!se.landedCostData&&!D.isFetchingLandedCost||o||t})();if(!(()=>{var t,o,n,s;const r=!!(null===(t=D.stripeLinkEventData)||void 0===t?void 0:t.complete),i=!!(null===(o=D.stripeAddressEventData)||void 0===o?void 0:o.complete),a=D.stripeShippingSameAsBilling?i:!!(null===(n=D.stripeBillingAddressEventData)||void 0===n?void 0:n.complete),d=(t=>{var o,n;const s=null===(o=e.genericSettings)||void 0===o?void 0:o.countryFields,r=null===(n=e.genericSettings)||void 0===n?void 0:n.stripeCountryFieldLabels;return"stripe"===se.addressFormRenderType&&(r&&t in r?r[t]:null)||(s&&t in s?s[t]:null)})((null===(s=D.stripeAddressEventData)||void 0===s?void 0:s.value.address.country)||"US");return!!(i&&a&&r)||(d&&D.stripeAddressEventData?r&&D.stripeAddressEventData.value.firstName&&D.stripeAddressEventData.value.lastName&&D.stripeAddressEventData.value.address.line1.length>0&&(!d.stateRequired||d.stateRequired&&D.stripeAddressEventData.value.address.state.length>0)&&(!d.zipRequired||d.zipRequired&&D.stripeAddressEventData.value.address.postal_code.length>=3)&&D.stripeAddressEventData.value.phone&&D.stripeAddressEventData.value.phone.length>0:i&&a&&r)})())return{isRequestNotReady:!0};if(l&&(null===(n=D.fetchingLandedCostAbortController)||void 0===n||n.abort(),D.fetchingLandedCostAbortController=null),!l&&!d)return{isRequestNotReady:!1};a?(D.isFetchingLandedCost=!1,setTimeout((()=>{D.isFetchingLandedCost=!0}),300)):D.isFetchingLandedCost=!0,D.stripeAddressEventData&&(D.stripeAddressUsedWhenFetchingLC={countryCode:D.stripeAddressEventData.value.address.country,postalCode:D.stripeAddressEventData.value.address.postal_code,state:D.stripeAddressEventData.value.address.state}),D.stripeBillingAddressEventData&&(D.stripeBillingAddressUsedWhenFetchingLC={countryCode:D.stripeBillingAddressEventData.value.address.country,postalCode:D.stripeBillingAddressEventData.value.address.postal_code,state:D.stripeBillingAddressEventData.value.address.state}),D.stripeLinkEventData&&(D.stripeLinkUsedWhenFetchingLC=Object.assign({},D.stripeLinkEventData));try{fe(),await(async()=>{var e;const t=new AbortController;D.fetchingLandedCostAbortController=t,fe();const{checkoutSessionWorkflow:n,errors:s,itemCreateWorkflow:r,landedCostCalculateWorkflow:i,partyCreateWorkflow:a,shipmentRatingCalculateWorkflow:d}=await O(t);se.customQuotingError=(null===(e=null==s?void 0:s.find((e=>{var t;return"CUSTOM"===(null===(t=e.extensions)||void 0===t?void 0:t.ruleMessageType)})))||void 0===e?void 0:e.message)||null,se.shippingData=I((null==d?void 0:d.filter(Boolean))||[]),de(r),D.fetchingLandedCostAbortController=null,se.partiesData=(null==a?void 0:a.filter(Boolean))||[],se.landedCostData=(null==n?void 0:n.map((e=>{const t=null==i?void 0:i.find((t=>(null==t?void 0:t.id)===e.landedCostId));return t?Object.assign(Object.assign({},e),{landedCost:t}):null})).filter(Boolean))||[],(null==n?void 0:n.length)&&A({checkoutSessionId:o.checkoutSessionId,eventName:"checkout_quoteReceived"});const l=se.promoCodeApplied&&!se.landedCostData.find((e=>{var t;return null===(t=e.landedCost.appliedAdjustments)||void 0===t?void 0:t.find((e=>"PROMO_CODE"===e.type))}));se.promoCodeError=l,l||sessionStorage.setItem("zonos--promo-code",se.promoCode)})();const e=null===(s=se.shippingData)||void 0===s?void 0:s.find(Boolean),t=null===(r=se.landedCostData)||void 0===r?void 0:r.find((t=>t.landedCost.shipmentRating.id===(null==e?void 0:e.id))),n=t?t.subtotals:null;n&&ue({method:(null==t?void 0:t.landedCost.method)||"DDP",subtotals:n})}catch(e){if(se.landedCostData=[],se.shippingData=[],e instanceof Error&&e.message&&!["The landed cost calculation request was aborted to initiate a new one."].includes(e.message)){if(a<1)return await J(Object.assign(Object.assign({},t),{retries:(a||0)+1})),{isRequestNotReady:!1};const o=null===(i=D.stripeAddressEventData)||void 0===i?void 0:i.value;m({endpoint:`Failed to fetch landed cost (${a} retries)`,errors:[e.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:o}})}p(e)}return D.isFetchingLandedCost=!1,{isRequestNotReady:!1}},M=async()=>{var e,t;await J({applyingPromocode:!0}),"payment"===se.step&&Se(),await B();const o=null===(e=se.shippingData)||void 0===e?void 0:e.find(Boolean),n=null===(t=se.landedCostData)||void 0===t?void 0:t.find((e=>e.landedCost.id===(null==o?void 0:o.id)));o&&n&&await ye({applySubtotalsOnly:!1,landedCostId:n.landedCostId,selectedShippingOption:o})},W=()=>{se.promoCode="",sessionStorage.removeItem("zonos--promo-code"),se.promoCodeError=!1,se.promoCodeApplied=!1},$=async()=>{"payment"===se.step&&Se(),W(),await M()},q=e=>{let t=[],o=!0;const n=window.Zonos.isCollect,s=window.Zonos.isInvoice;switch(e){case"succeeded":t=[r("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"",r("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")],(n||s)&&(t=[r("Thank you for submitting your payment. We appreciate your prompt attention."),"",r("A confirmation email with your payment details has been sent for your records. If you have any questions or need support, our team is here to help.")]),o=!1;break;case"requires_capture":case"processing":t=[r("Payment processing. We'll update you when payment is received.")],o=!1;break;case"requires_payment_method":t=[r("Payment failed. Please try another payment method.")],n&&(t=[r("Payment failed. Please reload the page and try another payment method.")]);break;case"requires_action":o=!1,t=[r("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")];default:t=[r("Something went wrong.")]}return{isError:o,messages:t}},Y=async()=>{var t,o;const{onInventoryCheck:n}=e.checkoutSettings,s=!!(null===(o=null===(t=window.Zonos.cartData)||void 0===t?void 0:t.metadata.find((e=>"referenceId"===e.key)))||void 0===o?void 0:o.value);if(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&s){const{errors:e,json:t}=await l("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"});return e.length||!t?(p("Error occurs when handling inventory refund","warn",JSON.stringify(e)),null):t.available&&204!==t.status?t.available||200===t.status?(D.shouldInventoryRefund=!0,null):null:r("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")}if("function"!=typeof n)return null;try{return await n({items:se.items},{translate:r,zonosApiRoute:d.vercel})}catch(e){const t=e instanceof Error?e.message:"Unknown error";throw m({endpoint:"onInventoryCheck",errors:[`cartId: ${window.Zonos.cartId} - ${t}`],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:se.items}}),e}},H=async()=>{var e,t;const o=!!(null===(t=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.metadata.find((e=>"referenceId"===e.key)))||void 0===t?void 0:t.value);window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o&&await l("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})},K=async({clientSecret:e,storybookForceStatus:t})=>{if(t){const{isError:e,messages:o}=q(t);return{error:e,messages:o}}const o=e||D.clientSecret;if(!D.stripe||!o)return p("Failed to retrieve payment intent. Stripe is not initialized"),{error:!0,message:[r("Something went wrong.")]};const{paymentIntent:n}=await D.stripe.retrievePaymentIntent(o),s=null==n?void 0:n.status,{isError:i,messages:a}=q(s);return{error:i,messages:a,paymentIntentId:null==n?void 0:n.id,paymentMethod:null==n?void 0:n.payment_method,status:s}},G=async e=>{var t,n;const s=!!(null===(t=D.stripePaymentEventData)||void 0===t?void 0:t.complete),i=D.stripeElements,a=D.stripe,d=D.clientSecret;if(D.customErrorMessage=null,!(null===(n=se.selectedLandedCost)||void 0===n?void 0:n.landedCost.id)&&!(null==e?void 0:e.noLandedCostCheck))throw new Error("Attempted to confirm the payment when no landed cost is found in store");const l=await N();if(!l.valid)throw D.customErrorMessage=l.errorMessage,new Error(l.errorMessage);const c=o.checkoutSessionId;if(a&&i&&s&&d&&c){const e=new URL(window.location.href);e.searchParams.set("payment_intent_client_secret",d),e.searchParams.set("zonosCheckoutSessionId",c),A({checkoutSessionId:c,eventName:"checkout_paymentInfoCompleted"});const{error:t,paymentIntent:o}=await a.confirmPayment({confirmParams:{return_url:e.toString()},elements:i,redirect:"if_required"});if(h("Payment intent confirmed","info",{error:t,paymentIntent:o}),"requires_action"===(null==o?void 0:o.status))throw new Error(r("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."));if(t){if("card_error"===t.type||"validation_error"===t.type)throw new Error(t.message);if("invalid_request_error"===t.type&&"payment_intent_unexpected_state"===t.code)return;throw new Error("An unexpected error occurred.")}if("requires_payment_method"===o.status)throw new Error(r("Payment failed. Please try another payment method."))}},V=()=>{var e;const t=se.items.reduce(((e,t)=>e+t.amount*t.quantity),0),s=o.enabledVariantTestKeys||[];return{adjustmentsAmount:se.adjustments.reduce(((e,t)=>e+t.amount),0),cartId:window.Zonos.cartId,currency:(null===(e=se.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",customerAuthenticationToken:se.customerAuthenticationToken||void 0,isCollect:!!window.Zonos.isCollect,isInvoice:!!window.Zonos.isInvoice,itemsAmount:t,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:n.selectedCountryCode,skipPaymentIntent:D.skipPaymentIntent,varianceTestInput:s}},Z=async()=>{var e;if(!o.checkoutSessionId)return m({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:y,cartId:window.Zonos.cartId}}),void ce({messages:[r("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:r("Error creating Checkout")});const{errors:t,json:n}=await l("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:o.checkoutSessionId},method:"POST"}),s=null===(e=null==n?void 0:n.checkoutSessionPaymentIntentCreate)||void 0===e?void 0:e.clientSecret;if(t.length||!s)return p("Error occurs when getting payment intent",JSON.stringify(t,null,2)),m({endpoint:"Error creating payment intent",errors:t.map((e=>e.message)),metadata:{allLogs:y,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,clientSecret:s}}),void ce({messages:[r("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:r("Error creating Checkout")});pe(n.checkoutSessionPaymentIntentCreate)},Q=async()=>{var e,t;if(!n.targetCurrency)return p("Failed to create checkout session - missing localizationStore.targetCurrency"),!1;D.isFetchingSession=!0;const o=V();h("Checkout session body","info",o);const{errors:s,json:r}=await l("/api/zonos-elements/create-checkout-session",{body:o,method:"POST"});if(D.isFetchingSession=!1,s.length||!r){const t=null===(e=s.find((e=>e.message)))||void 0===e?void 0:e.message;if(Array.isArray(t)&&t.some((e=>"Cart is expired."===e.message)))throw new Error("Cart is expired.");return p("Error occurred when creating checkout session",JSON.stringify(s,null,2)),!1}const i=r.checkoutSessionCreate;return pe(i),ue({method:(null===(t=i.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:i.subtotals}),h("Exchange rate updated for cart items (checkout session create)","info",se.exchangeRate),h("done-init-checkout-session"),!0},X=async()=>{const t=o.checkoutSessionId;if(!t)return p("Failed to update checkout session base currency"),!1;if("LOCAL"===e.checkoutSettings.allowedSettlementCurrencies)return h('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency'),!0;const{json:n}=await l("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:t,currencyCode:D.checkoutSettlementCurrency},method:"POST"}),s=null==n?void 0:n.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;return n&&s===D.checkoutSettlementCurrency?(h(`Updated checkout session to settlement currency "${s}".`),!0):(p("Failed to update checkout session base currency"),!1)},ee=({currentAddress:e,translatedAddressResult:t})=>{const o={};if(!t)return o;const{city:n,line1:s,line2:r,name:i,postal_code:a,state:d}=t;return e.city&&n&&(o.city={[e.city]:n}),e.line1&&s&&(o.line1={[e.line1]:s}),e.line2&&r&&(o.line2={[e.line2]:r}),e.postal_code&&a&&(o.postal_code={[e.postal_code]:a}),e.state&&d&&(o.state={[e.state]:d}),e.name&&i&&(o.name={[e.name]:i}),o},te=async({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t})=>{var o,n,s,r;const i=(({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:o,stripeBillingAddressEventData:n,stripeShippingSameAsBilling:s})=>{const r=!!(null==o?void 0:o.complete);if(!r||!(s?r:null==n?void 0:n.complete))return null;if(!e&&!t)return null;const i=o.value,a=(null==n?void 0:n.value)||null,{firstName:d,lastName:l}=f({firstName:i.firstName,lastName:i.lastName,name:i.name}),c=`${d} ${l}`,{firstName:u,lastName:m}=f({firstName:null==a?void 0:a.firstName,lastName:null==a?void 0:a.lastName,name:(null==a?void 0:a.name)||""}),p=u&&m?`${u} ${m}`:"",v=i.address,h=null==a?void 0:a.address;return{address:k({address:Object.assign(Object.assign({},v),{name:c}),invalidAdddressList:e}),billingAddress:s?void 0:k({address:h?Object.assign(Object.assign({},h),{name:p}):null,invalidAdddressList:t}),destinationCountry:v.country}})({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:D.stripeAddressEventData,stripeBillingAddressEventData:D.stripeBillingAddressEventData,stripeShippingSameAsBilling:D.stripeShippingSameAsBilling});if(!i)return void(D.translatedAddress={address:{},billingAddress:{}});const a=(()=>{var e,t,o,n;const s=JSON.stringify(null===(e=D.stripeAddressUsedWhenValidatingAddress)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=D.stripeAddressEventData)||void 0===t?void 0:t.value),r=!D.stripeShippingSameAsBilling&&JSON.stringify(null===(o=D.stripeBillingAddressEventData)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=D.stripeBillingAddressUsedWhenValidatingAddress)||void 0===n?void 0:n.value);return s||r})();if(!a)return;const{errors:d,json:c}=await l("/api/zonos-elements/validate-address",{body:i,method:"POST"});if(d.length||!c)return p("Error occurs when translating address to latin",JSON.stringify(d,null,2)),void(D.translatedAddress={address:{},billingAddress:{}});D.stripeAddressUsedWhenValidatingAddress=D.stripeAddressEventData,D.stripeBillingAddressUsedWhenValidatingAddress=D.stripeBillingAddressEventData;const u=null===(o=D.stripeAddressEventData)||void 0===o?void 0:o.value.address,m=null===(n=D.stripeBillingAddressEventData)||void 0===n?void 0:n.value.address;D.translatedAddress={address:u?ee({currentAddress:Object.assign(Object.assign({},u),{name:null===(s=D.stripeAddressEventData)||void 0===s?void 0:s.value.name}),translatedAddressResult:c.address||null}):{},billingAddress:D.stripeShippingSameAsBilling?{}:ee({currentAddress:Object.assign(Object.assign({},m),{name:null===(r=D.stripeBillingAddressEventData)||void 0===r?void 0:r.value.name}),translatedAddressResult:c.billingAddress||null})}};E("clientSecret",(e=>{e&&D.stripe&&sessionStorage.setItem("zonos--client-secret",e),e||sessionStorage.removeItem("zonos--client-secret")}));const{onChange:oe,reset:ne,state:se}=t((()=>({addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:!1,checkoutTimeoutInterval:null,currency:"USD",customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:!1,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:!1,isSelectedShippingGuarantee:!1,isStagingMode:u(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:!1,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:!1,step:"customer-info",subtotal:0,tabItems:{"customer-info":{index:1,isDone:!1,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:!1,label:"Shipping",value:"shipping"},payment:{index:3,isDone:!1,label:"Payment",value:"payment"}},total:0}))),re=e=>{switch(e){case"DAYS":return r("days");case"WEEKS":return r("weeks");default:return r("business days")}},ie=e=>{var t;const o=null===(t=e.shippingProfile)||void 0===t?void 0:t.transitTime;return(null==o?void 0:o.min)&&(null==o?void 0:o.max)&&(null==o?void 0:o.type)?{maxTransit:o.max,minTransit:o.min,unit:re(o.type)}:null},ae=({item1:e,item2:t})=>!(!e||!t)&&(t.sku&&e.sku&&e.sku===t.sku||t.description&&e.description&&e.description===t.description||e.name&&t.name&&e.name===t.name),de=e=>{h("Checking item restrictions");const t=e.map((e=>{if(!e.restriction)return null;const{restriction:t}=e,o=se.items.find((t=>ae({item1:t,item2:e})));return Object.assign(Object.assign({matchedItem:o},e),{restriction:t})})).filter(Boolean);return se.restrictedItems=t,se.items=se.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!!t.find((t=>ae({item1:t,item2:e})))}))),{cartItems:se.items,restrictedItems:t}},le=()=>{o.checkoutSessionId=null,ne()},ce=({messages:e,title:t})=>{le(),U(),se.step="error",se.error={messages:e,title:t}},ue=({dutiesTaxesFeesEstimate:e,method:t,subtotals:o})=>{se.exchangeRate=o.exchangeRate,se.adjustmentTotal=o.adjustments,se.dutiesTaxesFees="DAP"===t?null:o.landedCostTotal,se.subtotal=o.items,se.total=o.total,se.currency=o.presentmentCurrencyCode,se.dutiesTaxesFeesEstimate=e||null},me=()=>!!se.items.filter((e=>e.amount>0)).find((e=>!e.isRestricted)),pe=e=>{var t,n,s,r,d;D.clientSecret=e.clientSecret,D.stripeCustomerSessionClientSecret=e.customerSessionClientSecret,D.customerProfile=e.customerProfile,se.checkoutSession=e,e.id||m({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:y,checkoutSession:e}}),e.id&&(o.checkoutSessionId=e.id);const l=i(e.varianceTestResults||[]);a(l);const c=(null===(s=null===(n=null===(t=se.checkoutSession)||void 0===t?void 0:t.metadata)||void 0===n?void 0:n.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===s?void 0:s.value)||(null===(d=null===(r=window.Zonos.cartData)||void 0===r?void 0:r.metadata.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===d?void 0:d.value)||null;c&&(h(`Found externalConfirmationPageURL: ${c}`),se.externalConfirmationPageURL=c)},ve=async({adjustmentsAmount:e,cartId:t,currency:s,dutiesTaxesFeesEstimate:i,itemsAmount:a,landedCostId:d,shouldInitSessionOnFailure:c})=>{var u;if(d&&se.selectedLandedCost&&(ue({dutiesTaxesFeesEstimate:i,method:se.landedCostMethod,subtotals:se.selectedLandedCost.subtotals}),h("Exchange rate updated for cart items (landed cost subtotal)","info",se.exchangeRate)),!o.checkoutSessionId)return h("Could not update cart total without checkout session id","info"),!1;const{errors:m,json:v}=await(async({adjustmentsAmount:e,cartId:t,currency:s,id:r,itemsAmount:i,landedCostId:a,presentmentCountryCode:d})=>{const c=o.enabledVariantTestKeys||[],{errors:u,json:m}=await l("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:e,billToPartyId:D.partyBillingId,cartId:t,currency:s,customerAuthenticationToken:se.customerAuthenticationToken||void 0,id:r,itemsAmount:i,landedCostId:a,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:d,shipToPartyId:D.partyShippingId,skipPaymentIntent:D.skipPaymentIntent,varianceTestInput:c},method:"POST"});return u.length||!m?(p("Error occurs when updating checkout session",JSON.stringify(u,null,2)),{errors:u,json:m}):{errors:[],json:m}})({adjustmentsAmount:e,billToPartyId:D.partyBillingId,cartId:t,currency:s,id:o.checkoutSessionId,itemsAmount:a,landedCostId:d,presentmentCountryCode:n.selectedCountryCode,shipToPartyId:D.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]});if(m.length>0||!v){if(p("Error occurs when updating checkout session."),c){h("Initiating checkout session on failure","info");const e=await Q();return h(`stripeStoreInitCheckoutSession: ${e}`),!!e||(ce({messages:[r("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:r("Error creating Checkout")}),!1)}return!1}return d||(ue({method:(null===(u=v.checkoutSessionUpdate.landedCost)||void 0===u?void 0:u.method)||"DDP",subtotals:v.checkoutSessionUpdate.subtotals}),h("Exchange rate updated for cart items (checkout session update)","info",se.exchangeRate)),pe(v.checkoutSessionUpdate),!0},he=t=>{var o,n,s;return"DAP"===t.method&&(null===(n=null===(o=e.genericSettings)||void 0===o?void 0:o.domesticCountries)||void 0===n?void 0:n.includes((null===(s=D.stripeAddressEventData)||void 0===s?void 0:s.value.address.country)||"US"))||"DAP"===t.method&&t.remittance.length&&"ZONOS"===t.landedCostGuaranteeCode?"DDP":t.method},ye=async({applySubtotalsOnly:t,landedCostId:n,selectedShippingOption:s})=>{var r,i,a,d,l,c,u,m,p,v,y;h("Updating selected shipping option","info",{landedCostId:n,selectedShippingOption:s}),se.selectedShippingOption=s;const w=ie(se.selectedShippingOption);if(w){const{maxTransit:e,minTransit:t,unit:o}=w;se.selectedShippingOptionTransitTime=`${t}-${e} ${o}`}else se.selectedShippingOptionTransitTime="";const g=null===(r=se.landedCostData)||void 0===r?void 0:r.find((e=>e.landedCostId===n));if(se.selectedLandedCost=g||null,!g)return!1;const f=((null===(i=g.landedCost.amountSubtotals)||void 0===i?void 0:i.landedCostTotal)||0)*g.subtotals.exchangeRate.rate;f&&h(`DAP quote, using estimate: ${f}`,"info"),se.landedCostMethod=he(g.landedCost),se.shipping=g.subtotals.shipping;const b="ZONOS"===(null===(a=null==g?void 0:g.landedCost)||void 0===a?void 0:a.landedCostGuaranteeCode),S=!!(null===(l=null===(d=null==g?void 0:g.landedCost)||void 0===d?void 0:d.deMinimis)||void 0===l?void 0:l.find((e=>["DUTY","TAX"].includes(e.type)&&"ABOVE"===e.threshold)));se.isSelectedShippingAboveDeminimis=S,se.isSelectedShippingGuarantee=b;let C=!1;t?(ue({dutiesTaxesFeesEstimate:f,method:se.landedCostMethod,subtotals:g.subtotals}),h("Exchange rate updated for cart items (landed cost subtotal)","info",se.exchangeRate),C=!0):C=await ve({adjustmentsAmount:se.adjustmentTotal,billToPartyId:D.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:f,landedCostId:null===(c=g.landedCost)||void 0===c?void 0:c.id,shipToPartyId:D.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]});const O=null===(u=se.items.find(Boolean))||void 0===u?void 0:u.currencyCode,A=(null===(m=D.stripeAddressEventData)||void 0===m?void 0:m.value.address.country)||"US";return D.shouldRenderPayInUsdButton="USD"===O&&"LOCAL_AND_USD"===e.checkoutSettings.allowedSettlementCurrencies&&"USD"!==(null===(p=se.checkoutSession)||void 0===p?void 0:p.subtotals.presentmentCurrencyCode)&&!!(null===(y=null===(v=e.genericSettings)||void 0===v?void 0:v.usdSettlementCountryEnabled)||void 0===y?void 0:y.includes(A)),C},we=({isPreview:e,sessionTimeout:t})=>{if(e)return;const o=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout"),n=o&&!isNaN(parseInt(o,10))?parseInt(o,10):t;h(`==START CHECKOUT TIMEOUT - ${n}==`),se.checkoutTimeoutInterval=setTimeout((()=>{se.checkoutSessionTimeoutShow=!0}),n)},ge=()=>{se.checkoutTimeoutInterval&&(clearTimeout(se.checkoutTimeoutInterval),se.checkoutTimeoutInterval=null)},fe=()=>{se.items=se.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1}))),se.restrictedItems=[]},be=async({adjustments:e,cartItems:t,landedCostId:n,shouldInitSessionOnFailure:s=!0})=>{var r;se.adjustments=e,se.items=t.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1})));const i=null===(r=t.find(Boolean))||void 0===r?void 0:r.currencyCode,a=t.reduce(((e,t)=>e+t.amount*t.quantity),0),d=e.reduce(((e,t)=>e+t.amount),0);i&&a&&(se.currency=i,D.isFetchingSession=!0,await ve({adjustmentsAmount:d,billToPartyId:D.partyBillingId,cartId:window.Zonos.cartId,currency:i,dutiesTaxesFeesEstimate:0,itemsAmount:a,landedCostId:n,shipToPartyId:D.partyShippingId,shouldInitSessionOnFailure:s,varianceTestInput:o.enabledVariantTestKeys||[]}),D.isFetchingSession=!1)},Se=()=>{"shipping"===se.step?(se.step="customer-info",se.tabItems=Object.assign(Object.assign({},se.tabItems),{"customer-info":Object.assign(Object.assign({},se.tabItems.shipping),{isDone:!1})})):"payment"===se.step?(se.step="shipping",se.tabItems=Object.assign(Object.assign({},se.tabItems),{shipping:Object.assign(Object.assign({},se.tabItems.shipping),{isDone:!1})})):"finish"===se.step&&(se.step="payment",se.tabItems=Object.assign(Object.assign({},se.tabItems),{payment:Object.assign(Object.assign({},se.tabItems.payment),{isDone:!1})}))},Ce=()=>{"customer-info"===se.step?(se.step="shipping",se.tabItems=Object.assign(Object.assign({},se.tabItems),{"customer-info":Object.assign(Object.assign({},se.tabItems["customer-info"]),{isDone:!0})})):"shipping"===se.step?(se.step="payment",se.tabItems=Object.assign(Object.assign({},se.tabItems),{shipping:Object.assign(Object.assign({},se.tabItems.shipping),{isDone:!0})})):"payment"===se.step&&(se.step="finish")},Oe=()=>{se.step="customer-info",se.tabItems=Object.assign(Object.assign({},se.tabItems),{"customer-info":Object.assign(Object.assign({},se.tabItems["customer-info"]),{isDone:!1}),payment:Object.assign(Object.assign({},se.tabItems.payment),{isDone:!1}),shipping:Object.assign(Object.assign({},se.tabItems.shipping),{isDone:!1})}),se.selectedShippingOption=null,se.isSelectedShippingAboveDeminimis=!1,se.isSelectedShippingGuarantee=!1,se.selectedShippingOptionTransitTime="",se.dutiesTaxesFees=0,se.dutiesTaxesFeesEstimate=0,se.shipping=0,se.total=se.subtotal};export{N as A,E as B,_ as C,ye as D,me as E,M as F,$ as G,W as H,q as I,te as J,f as K,B as L,ie as M,he as N,I as O,x as a,D as b,K as c,se as d,be as e,le as f,Oe as g,ge as h,z as i,Q as j,Z as k,we as l,V as m,ce as n,L as o,pe as p,J as q,Ce as r,R as s,A as t,X as u,Y as v,G as w,H as x,U as y,oe as z}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,n,t,r){function o(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,i){function a(e){try{d(r.next(e))}catch(e){i(e)}}function s(e){try{d(r["throw"](e))}catch(e){i(e)}}function d(e){e.done?t(e.value):o(e.value).then(a,s)}d((r=r.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(n){return d([e,n])}}function d(s){if(r)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(t=0)),t)try{if(r=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:t.label++;return{value:s[1],done:false};case 5:t.label++;o=s[1];s=[0];continue;case 7:s=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){t.label=s[1];break}if(s[0]===6&&t.label<i[1]){t.label=i[1];i=s;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(s);break}if(i[2])t.ops.pop();t.trys.pop();continue}s=n.call(e,t)}catch(e){s=[6,e];o=0}finally{r=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,t){if(t||arguments.length===2)for(var r=0,o=n.length,i;r<o;r++){if(i||!(r in n)){if(!i)i=Array.prototype.slice.call(n,0,r);i[r]=n[r]}}return e.concat(i||Array.prototype.slice.call(n))};System.register(["./p-d45285aa.system.js","./p-752dae00.system.js","./p-01174496.system.js","./p-d938f42f.system.js","./p-909e2bc3.system.js","./p-23d497e3.system.js"],(function(e){"use strict";var n,t,r,o,i,a,s,d,u,l,c,v,f,m,p,h,w,g,y;return{setters:[function(e){n=e.z;t=e.c},function(e){r=e.s;o=e.l;i=e.e;a=e.t;s=e.f;d=e.b},function(e){u=e.f;l=e.h;c=e.g;v=e.a;f=e.s;m=e.l;p=e.j},function(e){h=e.l;w=e.b},function(e){g=e.i},function(e){y=e.g}],execute:function(){var b=this;var _=e("K",(function(e){var n=e.firstName,t=e.lastName,r=e.name;var o;if(!r&&!n&&!t){return{firstName:"",lastName:""}}var i=(r===null||r===void 0?void 0:r.split(/\s+/))||[];var a=(n===null||n===void 0?void 0:n.trim())||((o=i[0])===null||o===void 0?void 0:o.trim())||"";var s=(t===null||t===void 0?void 0:t.trim())||i.slice(1).join(" ").trim()||"";return{firstName:a,lastName:s}}));var S=function(e){var n=e.currentAddress,t=e.translatedAddress;var r,o,i,a,s,d;var u=n.value.address,l=u.city,c=u.country,v=u.line1,f=u.line2,m=u.postal_code,p=u.state;var h=n.value.name||[n.value.firstName,n.value.lastName].join(" ");return{city:((r=t.city)===null||r===void 0?void 0:r[l])||l,country:c,line1:((o=t.line1)===null||o===void 0?void 0:o[v])||v,line2:((i=t.line2)===null||i===void 0?void 0:i[f||""])||f||"",name:((a=t.name)===null||a===void 0?void 0:a[h])||h,phone:n.value.phone||"",postal_code:((s=t.postal_code)===null||s===void 0?void 0:s[m])||m,state:((d=t.state)===null||d===void 0?void 0:d[p])||p}};var O=function(e){var n;var t=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var a=J.stripeLinkEventData;var s=J.stripeAddressEventData;var d=J.stripeShippingSameAsBilling?J.stripeAddressEventData:J.stripeBillingAddressEventData;if(!s||!d){throw new Error("Missing stripe address data")}var u=S({currentAddress:s,translatedAddress:J.translatedAddress.address});var l=_({name:u.name}),c=l.firstName,v=l.lastName;var f=S({currentAddress:d,translatedAddress:J.translatedAddress.address});var m=_({name:f.name}),p=m.firstName,h=m.lastName;var w=i()||"US";return{billingAddress:{addressLine1:f.line1,addressLine2:f.line2||"",city:f.city,country:f.country,postalCode:f.postal_code,state:f.state},billingContact:{firstName:p,lastName:h,phone:f.phone},cartCurrencyCode:(n=Oe.items[0])===null||n===void 0?void 0:n.currencyCode,cartId:e,checkoutSessionCountry:w||o.selectedCountryCode||undefined,checkoutSessionId:r.checkoutSessionId||"",contact:{companyName:J.companyName,email:a===null||a===void 0?void 0:a.value.email,firstName:c,lastName:v,phone:u.phone},isTest:!!t,landedCostAdjustments:Oe.promoCode?[{amount:0,productId:null,promoCode:Oe.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToTaxId:J.taxId,shippingAddress:{addressLine1:u.line1,addressLine2:u.line2,city:u.city,country:u.country,postalCode:u.postal_code,state:u.state}}};var C=function(){var e=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var n=J.stripeLinkEventData;var t=J.stripeAddressEventData;var o=J.stripeShippingSameAsBilling?J.stripeAddressEventData:J.stripeBillingAddressEventData;h({stripeAddressData:t,stripeBillingAddressData:o},"info");if(!t||!o){throw new Error("Missing stripe address data")}var i=S({currentAddress:t,translatedAddress:J.translatedAddress.address});var a=_({name:i.name}),s=a.firstName,d=a.lastName;var u=S({currentAddress:o,translatedAddress:J.translatedAddress.address});var l=_({name:u.name}),c=l.firstName,v=l.lastName;var f=Oe.adjustments.map((function(e){return{amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}}));var m=Oe.promoCode?__spreadArray([{amount:0,productId:null,promoCode:Oe.promoCode,sku:null,type:"PROMO_CODE"}],f,true):f;return{billingAddress:{addressLine1:u.line1,addressLine2:u.line2||"",city:u.city,country:u.country,postalCode:u.postal_code,state:u.state},billingContact:{firstName:c,lastName:v,phone:u.phone},checkoutSessionId:r.checkoutSessionId||"",contact:{companyName:J.companyName,email:n===null||n===void 0?void 0:n.value.email,firstName:s,lastName:d,phone:i.phone},isTest:e,items:Oe.items,landedCostAdjustments:m,shipToTaxId:J.taxId,shippingAddress:{addressLine1:i.line1,addressLine2:i.line2,city:i.city,country:i.country,postalCode:i.postal_code,state:i.state}}};var A=function(e){return __awaiter(b,void 0,void 0,(function(){var n,t,r,o,i,a,s,d,c,v;return __generator(this,(function(f){switch(f.label){case 0:a=C();return[4,e({billingAddress:a.billingAddress,billingContact:a.billingContact,checkoutSessionId:a.checkoutSessionId,contact:a.contact,landedCostAdjustments:a.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:a.shippingAddress,zonosApiRoute:u["vercel"]})];case 1:s=f.sent();if(!s||!((n=s.checkoutSessionWorkflow)===null||n===void 0?void 0:n.length)&&((t=s.errors)===null||t===void 0?void 0:t.length)){throw new Error("Failed to build landed cost: ".concat(((o=(r=s===null||s===void 0?void 0:s.errors)===null||r===void 0?void 0:r[0])===null||o===void 0?void 0:o.message)||"Unknown error"))}return[4,l("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:d=f.sent(),c=d.errors,v=d.json;if(!v||c.length){throw new Error("Invalid landed cost object: ".concat(((i=c.find(Boolean))===null||i===void 0?void 0:i.message)||"Unknown error"))}return[2,s]}}))}))};var k=function(e){return __awaiter(b,void 0,void 0,(function(){var t,r,o,i,a,s,d;return __generator(this,(function(u){switch(u.label){case 0:r=n.checkoutSettings.buildLandedCost;if(!r)return[3,2];return[4,A(r)];case 1:o=u.sent();return[2,o];case 2:return[4,l("/api/zonos-elements/calculate-landed-cost",{body:C(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:i=u.sent(),a=i.errors,s=i.json;if(a.length||!s){d=((t=a[0])===null||t===void 0?void 0:t.message)==="The user aborted a request.";if(d){throw new Error("The landed cost calculation request was aborted to initiate a new one.")}a.forEach((function(e){console.warn("Error calculating landed cost: ".concat(e.message))}));if(!s){throw new Error("Failed to calculate landed cost")}return[2,s]}return[2,s]}}))}))};var I=function(e){return __awaiter(b,[e],void 0,(function(e){var n,t,r,o,i,a,s,d,u,c;var v=e.abortController,f=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4,l("/api/zonos-elements/cart-calculate-landed-cost",{body:O(f),method:"POST",signal:v===null||v===void 0?void 0:v.signal})];case 1:a=e.sent(),s=a.errors,d=a.json;if(s.length||!d){u=typeof((n=s[0])===null||n===void 0?void 0:n.message)==="string"&&(((t=s[0])===null||t===void 0?void 0:t.message)==="The user aborted a request."||((r=s[0])===null||r===void 0?void 0:r.message.includes("signal is aborted"))||((o=s[0])===null||o===void 0?void 0:o.message.includes("The operation was aborted"))||((i=s[0])===null||i===void 0?void 0:i.message.includes("Fetch is aborted")));c=u?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(c)}return[2,d]}}))}))};var T=undefined&&undefined.__rest||function(e,n){var t={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0)t[r]=e[r];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++){if(n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o]))t[r[o]]=e[r[o]]}return t};var E=function(e){return __awaiter(b,void 0,void 0,(function(){var n,t,r,o,i;return __generator(this,(function(a){switch(a.label){case 0:n=window.Zonos.cartId;if(!!n)return[3,2];return[4,k(e)];case 1:t=a.sent();return[2,t];case 2:return[4,I({abortController:e,cartId:n})];case 3:r=a.sent(),o=r.cartWorkflow,i=T(r,["cartWorkflow"]);return[2,Object.assign(Object.assign({},i),{itemCreateWorkflow:o.items})]}}))}))};var N=e("t",(function(e){return __awaiter(b,[e],void 0,(function(e){var t,r,i,a,s,d,u,m,p;var h=e.checkoutSessionId,g=e.eventName,y=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:i=Date.now();a=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:h,eventCreated:i,eventName:g});s=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!((t=window.Zonos)===null||t===void 0?void 0:t.zonosQaUrl)||!!((r=window.Zonos)===null||r===void 0?void 0:r.debug);d=c()||v();if((d||s)&&!window.Zonos.zonosConversionTest){return[2]}u=o.selectedCountryCode;m=n.organizationId;if(!h){void f({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No checkout session id found')],metadata:{allLogs:w,checkoutSessionId:h,eventName:g,metadata:y,organizationId:m,trackEventLogs:a}});return[2]}if(!m){void f({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No organization id found')],metadata:{allLogs:w,checkoutSessionId:h,eventName:g,metadata:y,organizationId:m,trackEventLogs:a}})}p={checkoutSessionId:h,countryCode:u,eventCreated:i,eventName:g,metadata:Object.assign(Object.assign({},y),{trackEventLogs:a}),organizationId:m};return[4,l("/api/zonos-elements/track-conversion-event",{body:p,method:"POST"})];case 1:e.sent();return[2]}}))}))}));var j=function(e){var n=e.address,t=e.invalidAdddressList;if(!n){return}if(!t){return}var r={};if(t.city){r.city=n.city}if(t.line1){r.line1=n.line1}if(t.line2){r.line2=n.line2}if(t.postal_code){r.postal_code=n.postal_code}if(t.state){r.state=n.state}if(t.name){r.name=n.name}return Object.keys(r).length?r:undefined};var P=function(e){var n=e.addressInvalidCharactersList,t=e.billingAddressInvalidCharactersList,r=e.stripeAddressEventData,o=e.stripeBillingAddressEventData,i=e.stripeShippingSameAsBilling;var a=!!(r===null||r===void 0?void 0:r.complete);var s=i?a:!!(o===null||o===void 0?void 0:o.complete);if(!a||!s){return null}if(!n&&!t){return null}var d=r.value;var u=(o===null||o===void 0?void 0:o.value)||null;var l=_({firstName:d.firstName,lastName:d.lastName,name:d.name}),c=l.firstName,v=l.lastName;var f="".concat(c," ").concat(v);var m=_({firstName:u===null||u===void 0?void 0:u.firstName,lastName:u===null||u===void 0?void 0:u.lastName,name:(u===null||u===void 0?void 0:u.name)||""}),p=m.firstName,h=m.lastName;var w=p&&h?"".concat(p," ").concat(h):"";var g=d.address;var y=u===null||u===void 0?void 0:u.address;return{address:j({address:Object.assign(Object.assign({},g),{name:f}),invalidAdddressList:n}),billingAddress:!i?j({address:y?Object.assign(Object.assign({},y),{name:w}):null,invalidAdddressList:t}):undefined,destinationCountry:g.country}};var D=e("O",(function(e){var n=e.sort((function(e,n){return e.amount-n.amount}));return n}));var L=function(){return __awaiter(b,void 0,void 0,(function(){var e,n,t,o;return __generator(this,(function(i){switch(i.label){case 0:if(!r.checkoutSessionId){return[2,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",r.checkoutSessionId);return[4,l("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:n=i.sent(),t=n.errors,o=n.json;return[2,{errors:t,json:o}]}}))}))};var x=e("A",(function(){return __awaiter(b,void 0,void 0,(function(){var e,n,t,r;return __generator(this,(function(o){switch(o.label){case 0:return[4,L()];case 1:n=o.sent(),t=n.errors,r=n.json;if(t.length||!r){m("Failed to retrieve checkout session info before confirming payment ",t);void f({endpoint:"validateCheckoutSession",errors:t.map((function(e){return e.message})),metadata:{allLogs:w}});return[2,{errorMessage:a("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:false}]}if(!((e=r.checkoutSession.landedCost)===null||e===void 0?void 0:e.id)){m("Landed cost is not found in the checkout session before confirming payment.");void f({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:w}});return[2,{errorMessage:a('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:false}]}return[2,{errorMessage:"",valid:true}]}}))}))}));var R=function(e){var t=e.theme;var r={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:n.appearance.fontSizeInputValue?"".concat(n.appearance.fontSizeInputValue,"px"):undefined,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:n.appearance.fontSizeInputLabel?"".concat(n.appearance.fontSizeInputLabel,"px"):undefined},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};switch(t){case"DARK":{return Object.assign(Object.assign({},r),{".Action":Object.assign(Object.assign({},r[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},r[".PickerItem--new"]),{color:"white"})})}default:return r}};var U=function(e){var n=e.borderStyle,t=e.theme;switch(t){case"DARK":return{borderRadius:y({overrideBorderStyle:n}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:y({overrideBorderStyle:n}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var z=t((function(){return{checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:false,isFetchingLandedCost:false,isFetchingSession:false,partyBillingId:null,partyShippingId:null,shouldInventoryRefund:false,shouldRenderPayInUsdButton:false,skipPaymentIntent:new URLSearchParams(window.location.search).get("skipPaymentIntent")==="0"?false:true,stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenAsyncAddressUpdate:null,stripeAddressUsedWhenFetchingLC:null,stripeAddressUsedWhenValidatingAddress:null,stripeBillingAddressElement:null,stripeBillingAddressEventData:null,stripeBillingAddressUsedWhenAsyncAddressUpdate:null,stripeBillingAddressUsedWhenFetchingLC:null,stripeBillingAddressUsedWhenValidatingAddress:null,stripeCustomerSessionClientSecret:null,stripeElements:null,stripeElementsForBillingAddress:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null,stripeShippingSameAsBilling:true,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}})),B=z.onChange,F=z.reset,J=z.state;e({B:B,b:J});var M=function(e){var t=e.clientSecret,r=e.overrideBorderRadius,i=e.overridePrimaryColor,a=e.overrideSecondaryColor,s=e.overrideTheme,d=e.paypalEnabled;var u=i||n.appearance.colorPrimary;var l=a||n.appearance.colorSecondary;var c=window.Zonos.isCollect||window.Zonos.isInvoice?n.appearance.theme==="DARK":u&&g(u);var v=c?"night":"flat";var f=s==="DARK"?"night":"flat";var m=d?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},R({theme:s||"LIGHT"})),theme:s?f:v,variables:Object.assign(Object.assign({},U({borderStyle:r,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:t||undefined,customerSessionClientSecret:J.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],m,true),locale:o.selectedLocale}};var q=e("o",(function(){window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")}));var W=e("a",(function(e){window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))}));var Y=e("s",(function(){var e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return p(e)}));var H=e("i",(function(e){return __awaiter(b,void 0,void 0,(function(){var n,t,r,o,i;return __generator(this,(function(a){r=J.clientSecret;if(!J.stripe){h("Skip. Stripe is not initialized");return[2]}o=M({clientSecret:r,overrideBorderRadius:e===null||e===void 0?void 0:e.overrideBorderRadius,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideSecondaryColor:e===null||e===void 0?void 0:e.overrideSecondaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme,paypalEnabled:e===null||e===void 0?void 0:e.paypalEnabled});i=JSON.stringify(o)===JSON.stringify(J.stripeElementsOptions);if(!J.stripeElements||!J.stripeElementsForBillingAddress){J.stripeElementsForBillingAddress=(n=J.stripe)===null||n===void 0?void 0:n.elements(o);h("Stripe elements for billing address initialized");J.stripeElements=(t=J.stripe)===null||t===void 0?void 0:t.elements(o);J.stripeElementsOptions=o;h("Stripe elements initialized");return[2]}if(!i){J.stripeElements.update(o);J.stripeElementsForBillingAddress.update(o);J.stripeElementsOptions=o;void J.stripeElements.fetchUpdates()}h("Stripe elements updated");return[2]}))}))}));var K=e("y",(function(){sessionStorage.removeItem("zonos--client-secret");F();J.stripe=window.Zonos.stripe}));var G=function(){var e,n,t,r;var o=JSON.stringify((e=J.stripeAddressUsedWhenValidatingAddress)===null||e===void 0?void 0:e.value)!==JSON.stringify((n=J.stripeAddressEventData)===null||n===void 0?void 0:n.value);var i=!J.stripeShippingSameAsBilling&&JSON.stringify((t=J.stripeBillingAddressEventData)===null||t===void 0?void 0:t.value)!==JSON.stringify((r=J.stripeBillingAddressUsedWhenValidatingAddress)===null||r===void 0?void 0:r.value);return o||i};var V=function(){var e,n,t,r,o,i;var a=JSON.stringify((e=J.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((n=J.stripeLinkEventData)===null||n===void 0?void 0:n.value);var s=JSON.stringify((t=J.stripeAddressUsedWhenAsyncAddressUpdate)===null||t===void 0?void 0:t.value)!==JSON.stringify((r=J.stripeAddressEventData)===null||r===void 0?void 0:r.value);var d=!J.stripeShippingSameAsBilling&&JSON.stringify((o=J.stripeBillingAddressUsedWhenAsyncAddressUpdate)===null||o===void 0?void 0:o.value)!==JSON.stringify((i=J.stripeBillingAddressEventData)===null||i===void 0?void 0:i.value);var u=J.taxIdUsedWhenAsyncAddressUpdate!==J.taxId;var l=J.companyNameUsedWhenAsyncAddressUpdate!==J.companyName;return a||s||d||u||l};var Z=e("C",(function(e){var n=e.address,t=e.firstName,o=e.lastName,i=e.name,a=e.phone;var s=_({firstName:t,lastName:o,name:i}),d=s.firstName,u=s.lastName;if(!d||!u){void f({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:w,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,firstName:t,lastName:o,name:i}})}if(!a){void f({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:w,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,phone:a}})}return{city:n.city,country:n.country,firstName:d,lastName:u,line1:n.line1,line2:n.line2,phone:a||"",postal_code:n.postal_code,state:n.state}}));var Q=e("L",(function(){return __awaiter(b,void 0,void 0,(function(){var e,n,t,o,i,a,s,d,u,c,v,p;return __generator(this,(function(h){switch(h.label){case 0:if(!((e=J.stripeAddressEventData)===null||e===void 0?void 0:e.complete)||!J.stripeShippingSameAsBilling&&!((n=J.stripeBillingAddressEventData)===null||n===void 0?void 0:n.complete)||!J.stripeBillingAddressEventData){return[2,{partiesCreated:false}]}if(!Oe.landedCostData){return[2,{partiesCreated:false}]}i=(t=Oe.landedCostData.find(Boolean))===null||t===void 0?void 0:t.landedCost.rootId;if(!i){void f({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:w,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId}});return[2,{partiesCreated:false}]}a=V();if(!a){return[2,{partiesCreated:false}]}s=Z({address:J.stripeAddressEventData.value.address,firstName:J.stripeAddressEventData.value.firstName,lastName:J.stripeAddressEventData.value.lastName,name:J.stripeAddressEventData.value.name,phone:J.stripeAddressEventData.value.phone});d=J.stripeShippingSameAsBilling?s:Z({address:J.stripeBillingAddressEventData.value.address,firstName:J.stripeBillingAddressEventData.value.firstName,lastName:J.stripeBillingAddressEventData.value.lastName,name:J.stripeBillingAddressEventData.value.name,phone:J.stripeBillingAddressEventData.value.phone});u=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,l("/api/zonos-elements/create-parties",{body:{address:s,billingAddress:d,companyName:J.companyName,email:((o=J.stripeLinkEventData)===null||o===void 0?void 0:o.value.email)||"",isTest:u,rootId:i,taxId:J.taxId},method:"POST"})];case 1:c=h.sent(),v=c.errors,p=c.json;if(v.length||!p){m("Error occurs when creating parties",JSON.stringify(v,null,2));void f({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:w,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,errors:v,json:p}});return[2,{partiesCreated:false}]}J.companyNameUsedWhenAsyncAddressUpdate=J.companyName;J.stripeAddressUsedWhenAsyncAddressUpdate=J.stripeAddressEventData;J.stripeBillingAddressUsedWhenAsyncAddressUpdate=J.stripeBillingAddressEventData;J.taxIdUsedWhenAsyncAddressUpdate=J.taxId;J.partyBillingId=p.billToPartyId;J.partyShippingId=p.shipToPartyId;return[2,{partiesCreated:true}]}}))}))}));var X=function(e){return{countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}};var $=function(){var e,n;var t=JSON.stringify((e=J.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((n=J.stripeLinkEventData)===null||n===void 0?void 0:n.value);var r=J.stripeAddressEventData&&JSON.stringify(X(J.stripeAddressEventData.value))!==JSON.stringify(J.stripeAddressUsedWhenFetchingLC);var o=!J.stripeShippingSameAsBilling&&J.stripeBillingAddressEventData&&JSON.stringify(X(J.stripeBillingAddressEventData.value))!==JSON.stringify(J.stripeBillingAddressUsedWhenFetchingLC);return t||r||o};var ee=function(){var e;var n=Oe.landedCostData&&((e=Oe.landedCostData.find(Boolean))===null||e===void 0?void 0:e.subtotals.items)!==Oe.subtotal;var t=$();h("isPrefetchInfoOutdated","info",{isAddressOutdated:t});return!Oe.landedCostData&&!J.isFetchingLandedCost||t||n};var ne=function(e){var t,r;var o=(t=n.genericSettings)===null||t===void 0?void 0:t.countryFields;var i=(r=n.genericSettings)===null||r===void 0?void 0:r.stripeCountryFieldLabels;var a=i&&e in i?i[e]:null;var s=o&&e in o?o[e]:null;if(Oe.addressFormRenderType==="stripe"){return a||s}return s};var te=function(){var e,n,t,r;var o=!!((e=J.stripeLinkEventData)===null||e===void 0?void 0:e.complete);var i=!!((n=J.stripeAddressEventData)===null||n===void 0?void 0:n.complete);var a=J.stripeShippingSameAsBilling?i:!!((t=J.stripeBillingAddressEventData)===null||t===void 0?void 0:t.complete);var s=((r=J.stripeAddressEventData)===null||r===void 0?void 0:r.value.address.country)||"US";var d=ne(s);if(i&&a&&o){return true}if(!d||!J.stripeAddressEventData){return i&&a&&o}var u=J.stripeAddressEventData.value.address.line1.length>0;var l=J.stripeAddressEventData.value.firstName&&J.stripeAddressEventData.value.lastName;var c=!d.stateRequired||d.stateRequired&&J.stripeAddressEventData.value.address.state.length>0;var v=!d.zipRequired||d.zipRequired&&J.stripeAddressEventData.value.address.postal_code.length>=3;var f=J.stripeAddressEventData.value.phone&&J.stripeAddressEventData.value.phone.length>0;return o&&l&&u&&c&&v&&f};var re=function(){return __awaiter(b,void 0,void 0,(function(){var e,n,t,o,i,a,s,d,u,l,c;return __generator(this,(function(v){switch(v.label){case 0:n=new AbortController;J.fetchingLandedCostAbortController=n;Be();return[4,E(n)];case 1:t=v.sent(),o=t.checkoutSessionWorkflow,i=t.errors,a=t.itemCreateWorkflow,s=t.landedCostCalculateWorkflow,d=t.partyCreateWorkflow,u=t.shipmentRatingCalculateWorkflow;Oe.customQuotingError=((e=i===null||i===void 0?void 0:i.find((function(e){var n;return((n=e.extensions)===null||n===void 0?void 0:n.ruleMessageType)==="CUSTOM"})))===null||e===void 0?void 0:e.message)||null;Oe.shippingData=D((u===null||u===void 0?void 0:u.filter(Boolean))||[]);Ie(a);J.fetchingLandedCostAbortController=null;Oe.partiesData=(d===null||d===void 0?void 0:d.filter(Boolean))||[];Oe.landedCostData=(o===null||o===void 0?void 0:o.map((function(e){var n=s===null||s===void 0?void 0:s.find((function(n){return(n===null||n===void 0?void 0:n.id)===e.landedCostId}));if(!n){return null}return Object.assign(Object.assign({},e),{landedCost:n})})).filter(Boolean))||[];l=r.checkoutSessionId;if(o===null||o===void 0?void 0:o.length){void N({checkoutSessionId:l,eventName:"checkout_quoteReceived"})}c=Oe.promoCodeApplied&&!Oe.landedCostData.find((function(e){var n;return(n=e.landedCost.appliedAdjustments)===null||n===void 0?void 0:n.find((function(e){return e.type==="PROMO_CODE"}))}));Oe.promoCodeError=c;if(!c){sessionStorage.setItem("zonos--promo-code",Oe.promoCode)}return[2]}}))}))};var oe=e("q",(function(e){return __awaiter(b,void 0,void 0,(function(){var n,t,r,o,i,a,s,d,u,l,c,v,p,h;return __generator(this,(function(w){switch(w.label){case 0:i=(e===null||e===void 0?void 0:e.retries)||0;a=!!(e===null||e===void 0?void 0:e.applyingPromocode);s=ee();d=te();if(!d){return[2,{isRequestNotReady:true}]}if(s){(n=J.fetchingLandedCostAbortController)===null||n===void 0?void 0:n.abort();J.fetchingLandedCostAbortController=null}if(!s&&!a){return[2,{isRequestNotReady:false}]}if(i){J.isFetchingLandedCost=false;setTimeout((function(){J.isFetchingLandedCost=true}),300)}else{J.isFetchingLandedCost=true}if(J.stripeAddressEventData){J.stripeAddressUsedWhenFetchingLC={countryCode:J.stripeAddressEventData.value.address.country,postalCode:J.stripeAddressEventData.value.address.postal_code,state:J.stripeAddressEventData.value.address.state}}if(J.stripeBillingAddressEventData){J.stripeBillingAddressUsedWhenFetchingLC={countryCode:J.stripeBillingAddressEventData.value.address.country,postalCode:J.stripeBillingAddressEventData.value.address.postal_code,state:J.stripeBillingAddressEventData.value.address.state}}if(J.stripeLinkEventData){J.stripeLinkUsedWhenFetchingLC=Object.assign({},J.stripeLinkEventData)}w.label=1;case 1:w.trys.push([1,3,,7]);Be();return[4,re()];case 2:w.sent();u=(t=Oe.shippingData)===null||t===void 0?void 0:t.find(Boolean);l=(r=Oe.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCost.shipmentRating.id===(u===null||u===void 0?void 0:u.id)}));c=!!l?l.subtotals:null;if(c){Ne({method:(l===null||l===void 0?void 0:l.landedCost.method)||"DDP",subtotals:c})}return[3,7];case 3:v=w.sent();Oe.landedCostData=[];Oe.shippingData=[];p=["The landed cost calculation request was aborted to initiate a new one."];if(!(v instanceof Error&&v.message&&!p.includes(v.message)))return[3,6];if(!(i<1))return[3,5];return[4,oe(Object.assign(Object.assign({},e),{retries:(i||0)+1}))];case 4:w.sent();return[2,{isRequestNotReady:false}];case 5:h=(o=J.stripeAddressEventData)===null||o===void 0?void 0:o.value;void f({endpoint:"Failed to fetch landed cost (".concat(i," retries)"),errors:[v.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:h}});w.label=6;case 6:m(v);return[3,7];case 7:J.isFetchingLandedCost=false;return[2,{isRequestNotReady:false}]}}))}))}));var ie=e("F",(function(){return __awaiter(b,void 0,void 0,(function(){var e,n,t,r;return __generator(this,(function(o){switch(o.label){case 0:return[4,oe({applyingPromocode:true})];case 1:o.sent();if(Oe.step==="payment"){Me()}return[4,Q()];case 2:o.sent();t=(e=Oe.shippingData)===null||e===void 0?void 0:e.find(Boolean);r=(n=Oe.landedCostData)===null||n===void 0?void 0:n.find((function(e){return e.landedCost.id===(t===null||t===void 0?void 0:t.id)}));if(!t||!r){return[2]}return[4,xe({applySubtotalsOnly:false,landedCostId:r.landedCostId,selectedShippingOption:t})];case 3:o.sent();return[2]}}))}))}));var ae=e("H",(function(){Oe.promoCode="";sessionStorage.removeItem("zonos--promo-code");Oe.promoCodeError=false;Oe.promoCodeApplied=false}));var se=e("G",(function(){return __awaiter(b,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:if(Oe.step==="payment"){Me()}ae();return[4,ie()];case 1:e.sent();return[2]}}))}))}));var de=e("I",(function(e){var n=[];var t=true;var r=window.Zonos.isCollect;var o=window.Zonos.isInvoice;switch(e){case"succeeded":{n=[a("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"",a("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")];if(r||o){n=[a("Thank you for submitting your payment. We appreciate your prompt attention."),"",a("A confirmation email with your payment details has been sent for your records. If you have any questions or need support, our team is here to help.")]}t=false;break}case"requires_capture":case"processing":{n=[a("Payment processing. We'll update you when payment is received.")];t=false;break}case"requires_payment_method":{n=[a("Payment failed. Please try another payment method.")];if(r){n=[a("Payment failed. Please reload the page and try another payment method.")]}break}case"requires_action":{t=false;n=[a("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}default:{n=[a("Something went wrong.")];break}}return{isError:t,messages:n}}));var ue=e("v",(function(){return __awaiter(b,void 0,void 0,(function(){var e,t,r,o,i,s,d,c,v,c;return __generator(this,(function(p){switch(p.label){case 0:r=n.checkoutSettings.onInventoryCheck;o=!!((t=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||t===void 0?void 0:t.value);if(!(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o))return[3,2];return[4,l("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:i=p.sent(),s=i.errors,d=i.json;if(s.length||!d){m("Error occurs when handling inventory refund","warn",JSON.stringify(s));return[2,null]}if(!d.available||d.status===204){return[2,a("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")]}if(d.available||d.status===200){J.shouldInventoryRefund=true;return[2,null]}return[2,null];case 2:if(typeof r!=="function"){return[2,null]}p.label=3;case 3:p.trys.push([3,5,,6]);return[4,r({items:Oe.items},{translate:a,zonosApiRoute:u["vercel"]})];case 4:c=p.sent();return[2,c];case 5:v=p.sent();c=v instanceof Error?v.message:"Unknown error";void f({endpoint:"onInventoryCheck",errors:["cartId: ".concat(window.Zonos.cartId," - ").concat(c)],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:Oe.items}});throw v;case 6:return[2]}}))}))}));var le=e("x",(function(){return __awaiter(b,void 0,void 0,(function(){var e,n,t;return __generator(this,(function(r){switch(r.label){case 0:t=!!((n=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||n===void 0?void 0:n.value);if(!window.Zonos.isLegacyCheckout||!window.Zonos.cartData||!t){return[2]}return[4,l("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:r.sent();return[2]}}))}))}));var ce=e("c",(function(e){return __awaiter(b,[e],void 0,(function(e){var n,t,r,o,i,s,d,u,l;var c=e.clientSecret,v=e.storybookForceStatus;return __generator(this,(function(e){switch(e.label){case 0:if(v){n=de(v),t=n.isError,r=n.messages;return[2,{error:t,messages:r}]}o=c||J.clientSecret;if(!J.stripe||!o){m("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[a("Something went wrong.")]}]}return[4,J.stripe.retrievePaymentIntent(o)];case 1:i=e.sent().paymentIntent;s=i===null||i===void 0?void 0:i.status;d=de(s),u=d.isError,l=d.messages;return[2,{error:u,messages:l,paymentIntentId:i===null||i===void 0?void 0:i.id,paymentMethod:i===null||i===void 0?void 0:i.payment_method,status:s}]}}))}))}));var ve=e("w",(function(e){return __awaiter(b,void 0,void 0,(function(){var n,t,o,i,s,d,u,l,c,v,f,m;return __generator(this,(function(p){switch(p.label){case 0:o=!!((n=J.stripePaymentEventData)===null||n===void 0?void 0:n.complete);i=J.stripeElements;s=J.stripe;d=J.clientSecret;J.customErrorMessage=null;if(!((t=Oe.selectedLandedCost)===null||t===void 0?void 0:t.landedCost.id)&&!(e===null||e===void 0?void 0:e.noLandedCostCheck)){throw new Error("Attempted to confirm the payment when no landed cost is found in store")}return[4,x()];case 1:u=p.sent();if(!u.valid){J.customErrorMessage=u.errorMessage;throw new Error(u.errorMessage)}l=r.checkoutSessionId;if(!(s&&i&&o&&d&&l))return[3,3];c=new URL(window.location.href);c.searchParams.set("payment_intent_client_secret",d);c.searchParams.set("zonosCheckoutSessionId",l);void N({checkoutSessionId:l,eventName:"checkout_paymentInfoCompleted"});return[4,s.confirmPayment({confirmParams:{return_url:c.toString()},elements:i,redirect:"if_required"})];case 2:v=p.sent(),f=v.error,m=v.paymentIntent;h("Payment intent confirmed","info",{error:f,paymentIntent:m});if((m===null||m===void 0?void 0:m.status)==="requires_action"){throw new Error(a("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."))}if(f){if(f.type==="card_error"||f.type==="validation_error"){throw new Error(f.message)}if(f.type==="invalid_request_error"){if(f.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}if(m.status==="requires_payment_method"){throw new Error(a("Payment failed. Please try another payment method."))}p.label=3;case 3:return[2]}}))}))}));var fe=e("m",(function(){var e;var n=Oe.items.reduce((function(e,n){return e+n.amount*n.quantity}),0);var t=r.enabledVariantTestKeys||[];var i={adjustmentsAmount:Oe.adjustments.reduce((function(e,n){return e+n.amount}),0),cartId:window.Zonos.cartId,currency:((e=Oe.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",customerAuthenticationToken:Oe.customerAuthenticationToken||undefined,isCollect:!!window.Zonos.isCollect,isInvoice:!!window.Zonos.isInvoice,itemsAmount:n,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:o.selectedCountryCode,skipPaymentIntent:J.skipPaymentIntent,varianceTestInput:t};return i}));var me=e("k",(function(){return __awaiter(b,void 0,void 0,(function(){var e,n,t,o,i;return __generator(this,(function(s){switch(s.label){case 0:if(!r.checkoutSessionId){void f({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:w,cartId:window.Zonos.cartId}});Ee({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2]}return[4,l("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:r.checkoutSessionId},method:"POST"})];case 1:n=s.sent(),t=n.errors,o=n.json;i=(e=o===null||o===void 0?void 0:o.checkoutSessionPaymentIntentCreate)===null||e===void 0?void 0:e.clientSecret;if(t.length||!i){m("Error occurs when getting payment intent",JSON.stringify(t,null,2));void f({endpoint:"Error creating payment intent",errors:t.map((function(e){return e.message})),metadata:{allLogs:w,cartId:window.Zonos.cartId,checkoutSessionId:r.checkoutSessionId,clientSecret:i}});Ee({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2]}Pe(o.checkoutSessionPaymentIntentCreate);return[2]}}))}))}));var pe=e("j",(function(){return __awaiter(b,void 0,void 0,(function(){var e,n,t,r,i,a,s,d;return __generator(this,(function(u){switch(u.label){case 0:if(!o.targetCurrency){m("Failed to create checkout session - missing localizationStore.targetCurrency");return[2,false]}J.isFetchingSession=true;t=fe();h("Checkout session body","info",t);return[4,l("/api/zonos-elements/create-checkout-session",{body:t,method:"POST"})];case 1:r=u.sent(),i=r.errors,a=r.json;J.isFetchingSession=false;if(i.length||!a){s=(e=i.find((function(e){return e.message})))===null||e===void 0?void 0:e.message;if(Array.isArray(s)&&s.some((function(e){return e.message==="Cart is expired."}))){throw new Error("Cart is expired.")}m("Error occurred when creating checkout session",JSON.stringify(i,null,2));return[2,false]}d=a.checkoutSessionCreate;Pe(d);Ne({method:((n=d.landedCost)===null||n===void 0?void 0:n.method)||"DDP",subtotals:d.subtotals});h("Exchange rate updated for cart items (checkout session create)","info",Oe.exchangeRate);h("done-init-checkout-session");return[2,true]}}))}))}));var he=e("u",(function(){return __awaiter(b,void 0,void 0,(function(){var e,t,o;return __generator(this,(function(i){switch(i.label){case 0:e=r.checkoutSessionId;if(!e){m("Failed to update checkout session base currency");return[2,false]}if(n.checkoutSettings.allowedSettlementCurrencies==="LOCAL"){h('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency');return[2,true]}return[4,l("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:J.checkoutSettlementCurrency},method:"POST"})];case 1:t=i.sent().json;o=t===null||t===void 0?void 0:t.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;if(!t||o!==J.checkoutSettlementCurrency){m("Failed to update checkout session base currency");return[2,false]}h('Updated checkout session to settlement currency "'.concat(o,'".'));return[2,true]}}))}))}));var we=function(e){return __awaiter(b,[e],void 0,(function(e){var n,t,i,a;var s=e.adjustmentsAmount,d=e.cartId,u=e.currency,c=e.id,v=e.itemsAmount,f=e.landedCostId,p=e.presentmentCountryCode;return __generator(this,(function(e){switch(e.label){case 0:n=r.enabledVariantTestKeys||[];return[4,l("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:s,billToPartyId:J.partyBillingId,cartId:d,currency:u,customerAuthenticationToken:Oe.customerAuthenticationToken||undefined,id:c,itemsAmount:v,landedCostId:f,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:p,shipToPartyId:J.partyShippingId,skipPaymentIntent:J.skipPaymentIntent,varianceTestInput:n},method:"POST"})];case 1:t=e.sent(),i=t.errors,a=t.json;if(i.length||!a){m("Error occurs when updating checkout session",JSON.stringify(i,null,2));return[2,{errors:i,json:a}]}return[2,{errors:[],json:a}]}}))}))};var ge=function(e){var n,t,r,o,i,a;var s=e.currentAddress,d=e.translatedAddressResult;var u={};if(!d){return u}var l=d.city,c=d.line1,v=d.line2,f=d.name,m=d.postal_code,p=d.state;if(s.city&&l){u.city=(n={},n[s.city]=l,n)}if(s.line1&&c){u.line1=(t={},t[s.line1]=c,t)}if(s.line2&&v){u.line2=(r={},r[s.line2]=v,r)}if(s.postal_code&&m){u.postal_code=(o={},o[s.postal_code]=m,o)}if(s.state&&p){u.state=(i={},i[s.state]=p,i)}if(s.name&&f){u.name=(a={},a[s.name]=f,a)}return u};var ye=e("J",(function(e){return __awaiter(b,[e],void 0,(function(e){var n,t,r,o,i,a,s,d,u,c,v;var f=e.addressInvalidCharactersList,p=e.billingAddressInvalidCharactersList;return __generator(this,(function(e){switch(e.label){case 0:i=P({addressInvalidCharactersList:f,billingAddressInvalidCharactersList:p,stripeAddressEventData:J.stripeAddressEventData,stripeBillingAddressEventData:J.stripeBillingAddressEventData,stripeShippingSameAsBilling:J.stripeShippingSameAsBilling});if(!i){J.translatedAddress={address:{},billingAddress:{}};return[2]}a=G();if(!a){return[2]}return[4,l("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),d=s.errors,u=s.json;if(d.length||!u){m("Error occurs when translating address to latin",JSON.stringify(d,null,2));J.translatedAddress={address:{},billingAddress:{}};return[2]}J.stripeAddressUsedWhenValidatingAddress=J.stripeAddressEventData;J.stripeBillingAddressUsedWhenValidatingAddress=J.stripeBillingAddressEventData;c=(n=J.stripeAddressEventData)===null||n===void 0?void 0:n.value.address;v=(t=J.stripeBillingAddressEventData)===null||t===void 0?void 0:t.value.address;J.translatedAddress={address:c?ge({currentAddress:Object.assign(Object.assign({},c),{name:(r=J.stripeAddressEventData)===null||r===void 0?void 0:r.value.name}),translatedAddressResult:u.address||null}):{},billingAddress:!J.stripeShippingSameAsBilling?ge({currentAddress:Object.assign(Object.assign({},v),{name:(o=J.stripeBillingAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:u.billingAddress||null}):{}};return[2]}}))}))}));B("clientSecret",(function(e){if(e&&J.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var be=t((function(){return{addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:false,checkoutTimeoutInterval:null,currency:"USD",customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:false,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,isStagingMode:v(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:false,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:false,step:"customer-info",subtotal:0,tabItems:{"customer-info":{index:1,isDone:false,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:false,label:"Shipping",value:"shipping"},payment:{index:3,isDone:false,label:"Payment",value:"payment"}},total:0}})),_e=be.onChange,Se=be.reset,Oe=be.state;e({z:_e,d:Oe});var Ce=function(e){switch(e){case"DAYS":return a("days");case"WEEKS":return a("weeks");case"BUSINESS_DAYS":default:return a("business days")}};var Ae=e("M",(function(e){var n;var t=(n=e.shippingProfile)===null||n===void 0?void 0:n.transitTime;if(!(t===null||t===void 0?void 0:t.min)||!(t===null||t===void 0?void 0:t.max)||!(t===null||t===void 0?void 0:t.type)){return null}return{maxTransit:t.max,minTransit:t.min,unit:Ce(t.type)}}));var ke=function(e){var n=e.item1,t=e.item2;if(!n||!t){return false}return t.sku&&n.sku&&n.sku===t.sku||t.description&&n.description&&n.description===t.description||n.name&&t.name&&n.name===t.name};var Ie=function(e){h("Checking item restrictions");var n=e.map((function(e){if(!e.restriction){return null}var n=e.restriction;var t=Oe.items.find((function(n){return ke({item1:n,item2:e})}));return Object.assign(Object.assign({matchedItem:t},e),{restriction:n})})).filter(Boolean);Oe.restrictedItems=n;Oe.items=Oe.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:!!n.find((function(n){return ke({item1:n,item2:e})}))})}));return{cartItems:Oe.items,restrictedItems:n}};var Te=e("f",(function(){r.checkoutSessionId=null;Se()}));var Ee=e("n",(function(e){var n=e.messages,t=e.title;Te();K();Oe.step="error";Oe.error={messages:n,title:t}}));var Ne=function(e){var n=e.dutiesTaxesFeesEstimate,t=e.method,r=e.subtotals;Oe.exchangeRate=r.exchangeRate;Oe.adjustmentTotal=r.adjustments;Oe.dutiesTaxesFees=t==="DAP"?null:r.landedCostTotal;Oe.subtotal=r.items;Oe.total=r.total;Oe.currency=r.presentmentCurrencyCode;Oe.dutiesTaxesFeesEstimate=n||null};var je=e("E",(function(){var e=Oe.items.filter((function(e){return e.amount>0}));return!!e.find((function(e){return!e.isRestricted}))}));var Pe=e("p",(function(e){var n,t,o,i,a;J.clientSecret=e.clientSecret;J.stripeCustomerSessionClientSecret=e.customerSessionClientSecret;J.customerProfile=e.customerProfile;Oe.checkoutSession=e;if(!e.id){void f({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:w,checkoutSession:e}})}if(e.id){r.checkoutSessionId=e.id}var u=s(e.varianceTestResults||[]);d(u);var l=((o=(t=(n=Oe.checkoutSession)===null||n===void 0?void 0:n.metadata)===null||t===void 0?void 0:t.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||o===void 0?void 0:o.value)||((a=(i=window.Zonos.cartData)===null||i===void 0?void 0:i.metadata.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||a===void 0?void 0:a.value)||null;if(l){h("Found externalConfirmationPageURL: ".concat(l));Oe.externalConfirmationPageURL=l}}));var De=function(e){return __awaiter(b,[e],void 0,(function(e){var n,t,i,s,d,u;var l=e.adjustmentsAmount,c=e.cartId,v=e.currency,f=e.dutiesTaxesFeesEstimate,p=e.itemsAmount,w=e.landedCostId,g=e.shouldInitSessionOnFailure;return __generator(this,(function(e){switch(e.label){case 0:if(w&&Oe.selectedLandedCost){t=Oe.selectedLandedCost.subtotals;Ne({dutiesTaxesFeesEstimate:f,method:Oe.landedCostMethod,subtotals:t});h("Exchange rate updated for cart items (landed cost subtotal)","info",Oe.exchangeRate)}if(!r.checkoutSessionId){h("Could not update cart total without checkout session id","info");return[2,false]}return[4,we({adjustmentsAmount:l,billToPartyId:J.partyBillingId,cartId:c,currency:v,id:r.checkoutSessionId,itemsAmount:p,landedCostId:w,presentmentCountryCode:o.selectedCountryCode,shipToPartyId:J.partyShippingId,varianceTestInput:r.enabledVariantTestKeys||[]})];case 1:i=e.sent(),s=i.errors,d=i.json;if(!(s.length>0||!d))return[3,4];m("Error occurs when updating checkout session.");if(!g)return[3,3];h("Initiating checkout session on failure","info");return[4,pe()];case 2:u=e.sent();h("stripeStoreInitCheckoutSession: ".concat(u));if(!u){Ee({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2,false]}return[2,true];case 3:return[2,false];case 4:if(!w){Ne({method:((n=d.checkoutSessionUpdate.landedCost)===null||n===void 0?void 0:n.method)||"DDP",subtotals:d.checkoutSessionUpdate.subtotals});h("Exchange rate updated for cart items (checkout session update)","info",Oe.exchangeRate)}Pe(d.checkoutSessionUpdate);return[2,true]}}))}))};var Le=e("N",(function(e){var t,r,o;if(e.method==="DAP"&&((r=(t=n.genericSettings)===null||t===void 0?void 0:t.domesticCountries)===null||r===void 0?void 0:r.includes(((o=J.stripeAddressEventData)===null||o===void 0?void 0:o.value.address.country)||"US"))){return"DDP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method}));var xe=e("D",(function(e){return __awaiter(b,[e],void 0,(function(e){var t,o,i,a,s,d,u,l,c,v,f,m,p,w,g,y,b,_,S,O,C,A,k,I,T;var E=e.applySubtotalsOnly,N=e.landedCostId,j=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:h("Updating selected shipping option","info",{landedCostId:N,selectedShippingOption:j});Oe.selectedShippingOption=j;m=Ae(Oe.selectedShippingOption);if(m){p=m.maxTransit,w=m.minTransit,g=m.unit;Oe.selectedShippingOptionTransitTime="".concat(w,"-").concat(p," ").concat(g)}else{Oe.selectedShippingOptionTransitTime=""}y=(t=Oe.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCostId===N}));Oe.selectedLandedCost=y||null;if(!y){return[2,false]}b=((o=y.landedCost.amountSubtotals)===null||o===void 0?void 0:o.landedCostTotal)||0;_=y.subtotals.exchangeRate.rate;S=b*_;if(S){h("DAP quote, using estimate: ".concat(S),"info")}Oe.landedCostMethod=Le(y.landedCost);Oe.shipping=y.subtotals.shipping;O=((i=y===null||y===void 0?void 0:y.landedCost)===null||i===void 0?void 0:i.landedCostGuaranteeCode)==="ZONOS";C=!!((s=(a=y===null||y===void 0?void 0:y.landedCost)===null||a===void 0?void 0:a.deMinimis)===null||s===void 0?void 0:s.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));Oe.isSelectedShippingAboveDeminimis=C;Oe.isSelectedShippingGuarantee=O;A=false;if(!E)return[3,1];k=y.subtotals;Ne({dutiesTaxesFeesEstimate:S,method:Oe.landedCostMethod,subtotals:k});h("Exchange rate updated for cart items (landed cost subtotal)","info",Oe.exchangeRate);A=true;return[3,3];case 1:return[4,De({adjustmentsAmount:Oe.adjustmentTotal,billToPartyId:J.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:S,landedCostId:(d=y.landedCost)===null||d===void 0?void 0:d.id,shipToPartyId:J.partyShippingId,varianceTestInput:r.enabledVariantTestKeys||[]})];case 2:A=e.sent();e.label=3;case 3:I=(u=Oe.items.find(Boolean))===null||u===void 0?void 0:u.currencyCode;T=((l=J.stripeAddressEventData)===null||l===void 0?void 0:l.value.address.country)||"US";J.shouldRenderPayInUsdButton=I==="USD"&&n.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((c=Oe.checkoutSession)===null||c===void 0?void 0:c.subtotals.presentmentCurrencyCode)!=="USD"&&!!((f=(v=n.genericSettings)===null||v===void 0?void 0:v.usdSettlementCountryEnabled)===null||f===void 0?void 0:f.includes(T));return[2,A]}}))}))}));var Re=e("l",(function(e){var n=e.isPreview,t=e.sessionTimeout;if(n){return}var r=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout");var o=r&&!isNaN(parseInt(r,10))?parseInt(r,10):t;h("==START CHECKOUT TIMEOUT - ".concat(o,"=="));Oe.checkoutTimeoutInterval=setTimeout((function(){Oe.checkoutSessionTimeoutShow=true}),o)}));var Ue=e("h",(function(){if(Oe.checkoutTimeoutInterval){clearTimeout(Oe.checkoutTimeoutInterval);Oe.checkoutTimeoutInterval=null}}));var ze=function(e){return e.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}))};var Be=function(){Oe.items=Oe.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));Oe.restrictedItems=[]};var Fe=e("e",(function(e){return __awaiter(b,[e],void 0,(function(e){var n,t,o,i;var a=e.adjustments,s=e.cartItems,d=e.landedCostId,u=e.shouldInitSessionOnFailure,l=u===void 0?true:u;return __generator(this,(function(e){switch(e.label){case 0:Oe.adjustments=a;Oe.items=ze(s);t=(n=s.find(Boolean))===null||n===void 0?void 0:n.currencyCode;o=s.reduce((function(e,n){return e+n.amount*n.quantity}),0);i=a.reduce((function(e,n){return e+n.amount}),0);if(!t||!o){return[2]}Oe.currency=t;J.isFetchingSession=true;return[4,De({adjustmentsAmount:i,billToPartyId:J.partyBillingId,cartId:window.Zonos.cartId,currency:t,dutiesTaxesFeesEstimate:0,itemsAmount:o,landedCostId:d,shipToPartyId:J.partyShippingId,shouldInitSessionOnFailure:l,varianceTestInput:r.enabledVariantTestKeys||[]})];case 1:e.sent();J.isFetchingSession=false;return[2]}}))}))}));var Je=function(){Oe.selectedShippingOption=null;Oe.isSelectedShippingAboveDeminimis=false;Oe.isSelectedShippingGuarantee=false;Oe.selectedShippingOptionTransitTime="";Oe.dutiesTaxesFees=0;Oe.dutiesTaxesFeesEstimate=0;Oe.shipping=0;Oe.total=Oe.subtotal};var Me=function(){if(Oe.step==="shipping"){Oe.step="customer-info";Oe.tabItems=Object.assign(Object.assign({},Oe.tabItems),{"customer-info":Object.assign(Object.assign({},Oe.tabItems.shipping),{isDone:false})})}else if(Oe.step==="payment"){Oe.step="shipping";Oe.tabItems=Object.assign(Object.assign({},Oe.tabItems),{shipping:Object.assign(Object.assign({},Oe.tabItems.shipping),{isDone:false})})}else if(Oe.step==="finish"){Oe.step="payment";Oe.tabItems=Object.assign(Object.assign({},Oe.tabItems),{payment:Object.assign(Object.assign({},Oe.tabItems.payment),{isDone:false})})}};var qe=e("r",(function(){if(Oe.step==="customer-info"){Oe.step="shipping";Oe.tabItems=Object.assign(Object.assign({},Oe.tabItems),{"customer-info":Object.assign(Object.assign({},Oe.tabItems["customer-info"]),{isDone:true})})}else if(Oe.step==="shipping"){Oe.step="payment";Oe.tabItems=Object.assign(Object.assign({},Oe.tabItems),{shipping:Object.assign(Object.assign({},Oe.tabItems.shipping),{isDone:true})})}else if(Oe.step==="payment"){Oe.step="finish"}}));var We=e("g",(function(){Oe.step="customer-info";Oe.tabItems=Object.assign(Object.assign({},Oe.tabItems),{"customer-info":Object.assign(Object.assign({},Oe.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},Oe.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},Oe.tabItems.shipping),{isDone:false})});Je()}))}}}));
|