@zonos/elements 1.3.211 → 1.3.212

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/cjs/{cart-7a7f3b59.js → cart-d04009b9.js} +7 -6
  2. package/dist/cjs/index.cjs.js +7 -7
  3. package/dist/cjs/{localization-33348cf3.js → localization-91bcde0e.js} +11 -10
  4. package/dist/cjs/{paypal-4124a81b.js → paypal-3a2d4501.js} +2 -2
  5. package/dist/cjs/zonos-address_11.cjs.entry.js +2 -2
  6. package/dist/cjs/zonos-cart-items_14.cjs.entry.js +3 -3
  7. package/dist/cjs/zonos-checkout.cjs.entry.js +3 -3
  8. package/dist/cjs/zonos-controller.cjs.entry.js +2 -2
  9. package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
  10. package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
  11. package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +3 -3
  12. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +1 -1
  13. package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
  14. package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
  15. package/dist/collection/components/main/zonos-controller.js +2 -2
  16. package/dist/collection/components/store/hello/localization.js +11 -10
  17. package/dist/collection/components/utils/api/cartCalculateLandedCost.js +6 -5
  18. package/dist/esm/{cart-b0ab7f79.js → cart-f36b8065.js} +7 -6
  19. package/dist/esm/index.js +7 -7
  20. package/dist/esm/{localization-f1b9c0ef.js → localization-cf31c728.js} +11 -10
  21. package/dist/esm/{paypal-5e2a45c3.js → paypal-4dd540c7.js} +2 -2
  22. package/dist/esm/zonos-address_11.entry.js +2 -2
  23. package/dist/esm/zonos-cart-items_14.entry.js +3 -3
  24. package/dist/esm/zonos-checkout.entry.js +3 -3
  25. package/dist/esm/zonos-controller.entry.js +2 -2
  26. package/dist/esm/zonos-country-flag.entry.js +1 -1
  27. package/dist/esm/zonos-country-select_4.entry.js +1 -1
  28. package/dist/esm/zonos-empty-state-payment_4.entry.js +3 -3
  29. package/dist/esm/zonos-hello-dialog.entry.js +1 -1
  30. package/dist/esm/zonos-hello.entry.js +1 -1
  31. package/dist/esm/zonos-language-select_2.entry.js +1 -1
  32. package/dist/esm-es5/cart-f36b8065.js +1 -0
  33. package/dist/esm-es5/index.js +1 -1
  34. package/dist/esm-es5/{localization-f1b9c0ef.js → localization-cf31c728.js} +1 -1
  35. package/dist/esm-es5/{paypal-5e2a45c3.js → paypal-4dd540c7.js} +1 -1
  36. package/dist/esm-es5/zonos-address_11.entry.js +1 -1
  37. package/dist/esm-es5/zonos-cart-items_14.entry.js +1 -1
  38. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  39. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  40. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  41. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  42. package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
  43. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  44. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  45. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  46. package/dist/scripts/index.d.ts +6 -2
  47. package/dist/scripts/index.js +1 -1
  48. package/dist/scripts/loadZonos.js +1 -1
  49. package/dist/scripts/zonos.js +1 -1
  50. package/dist/types/components/store/zonosStore.d.ts +1 -1
  51. package/dist/types/scripts/_zonosBase.d.ts +6 -2
  52. package/dist/zonos-elements/index.esm.js +1 -1
  53. package/dist/zonos-elements/{p-7439cba7.system.entry.js → p-002b5c5f.system.entry.js} +1 -1
  54. package/dist/zonos-elements/{p-0b48c596.entry.js → p-003f37f4.entry.js} +1 -1
  55. package/dist/zonos-elements/{p-ab7fed30.entry.js → p-0595e3f8.entry.js} +1 -1
  56. package/dist/zonos-elements/p-0707379c.entry.js +1 -0
  57. package/dist/zonos-elements/{p-88860d83.system.entry.js → p-137ee43a.system.entry.js} +1 -1
  58. package/dist/zonos-elements/{p-c6171f11.system.entry.js → p-1cc5b4f7.system.entry.js} +1 -1
  59. package/dist/zonos-elements/{p-dc0076a4.system.entry.js → p-1ed7c17d.system.entry.js} +1 -1
  60. package/dist/zonos-elements/{p-92803d13.system.js → p-20584d36.system.js} +1 -1
  61. package/dist/zonos-elements/p-23079911.js +1 -0
  62. package/dist/zonos-elements/{p-c63b2c78.system.entry.js → p-236643d0.system.entry.js} +1 -1
  63. package/dist/zonos-elements/{p-e51480a4.entry.js → p-24a5352e.entry.js} +1 -1
  64. package/dist/zonos-elements/{p-951a35e2.system.entry.js → p-3464e486.system.entry.js} +1 -1
  65. package/dist/zonos-elements/{p-e1d4ec4e.system.js → p-4444bb4e.system.js} +1 -1
  66. package/dist/zonos-elements/{p-5f125617.entry.js → p-67da7b6d.entry.js} +1 -1
  67. package/dist/zonos-elements/{p-1da85818.entry.js → p-6a157c84.entry.js} +1 -1
  68. package/dist/zonos-elements/{p-e90ff8fb.entry.js → p-752220fe.entry.js} +1 -1
  69. package/dist/zonos-elements/p-81b357f7.system.js +1 -1
  70. package/dist/zonos-elements/{p-73463715.entry.js → p-8b57a34d.entry.js} +1 -1
  71. package/dist/zonos-elements/{p-1f08477f.system.js → p-9b2aafa6.system.js} +1 -1
  72. package/dist/zonos-elements/{p-e9632a92.system.entry.js → p-a1cd5572.system.entry.js} +1 -1
  73. package/dist/zonos-elements/{p-749a0fc6.js → p-a45a15a0.js} +1 -1
  74. package/dist/zonos-elements/{p-858a55d2.entry.js → p-a4efb55c.entry.js} +1 -1
  75. package/dist/zonos-elements/{p-3041f0fd.system.entry.js → p-a9ad60a5.system.entry.js} +1 -1
  76. package/dist/zonos-elements/{p-4a1a69a9.js → p-b0643c40.js} +1 -1
  77. package/dist/zonos-elements/{p-3a0fdfb2.system.entry.js → p-b22fcbda.system.entry.js} +1 -1
  78. package/dist/zonos-elements/p-b6aabc2f.system.js +1 -0
  79. package/dist/zonos-elements/{p-55de2720.system.entry.js → p-dba65101.system.entry.js} +1 -1
  80. package/dist/zonos-elements/p-f0e8e81e.entry.js +1 -0
  81. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  82. package/package.json +1 -1
  83. package/dist/esm-es5/cart-b0ab7f79.js +0 -1
  84. package/dist/zonos-elements/p-19bb71d1.entry.js +0 -1
  85. package/dist/zonos-elements/p-20f929d8.entry.js +0 -1
  86. package/dist/zonos-elements/p-3b1ef4b2.js +0 -1
  87. package/dist/zonos-elements/p-f672d549.system.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as e,c as t,h as o,H as i}from"./p-b30c2ad9.js";import{c as n}from"./p-23079911.js";import{i as s,e as r,s as c,a}from"./p-a45a15a0.js";import{z as l,e as d,f as h}from"./p-7ce093aa.js";import{g as u,i as p,a as f}from"./p-e7b0c156.js";import{h as m,b as v,l as g}from"./p-2eec2d7c.js";import"./p-56e0ed65.js";import"./p-2b9c124d.js";import"./p-04a01cb1.js";const w=e=>{const t=document.querySelector(e);if(!document.querySelector("zonos-hello")&&t){const e=document.createElement("zonos-hello");return t.appendChild(e),!0}return!1},y=e=>{switch(e){case"BOTTOM_RIGHT":default:return"bottom-right";case"BOTTOM_LEFT":return"bottom-left";case"TOP_LEFT":return"top-left";case"TOP_RIGHT":return"top-right"}},S=({position:e="bottom-right"})=>{const t=".zonos--hello-mobile-wrapper";if(document.querySelector(t))return t;const o=document.createElement("div");return o.className="zonos--hello-mobile-wrapper",o.style.position="fixed","top-right"===e&&(o.style.top="72px",o.style.right="24px"),"top-left"===e&&(o.style.top="72px",o.style.left="24px"),"bottom-right"===e&&(o.style.bottom="72px",o.style.right="24px"),"bottom-left"===e&&(o.style.bottom="72px",o.style.left="24px"),o.style.zIndex="2147483647",document.body.appendChild(o),t},z=async e=>{if(window.Zonos.isLegacyCheckout)return void g("Hello is disabled when isLegacyCheckout","info");const{anchorElementSelector:t}=e;let o=t;if(!e.anchorElementSelector&&e.desktopLocation){const e=S({position:"bottom-right"});o=e}if(o&&s(o)){if(g("Hello init complete"),!w(o)){const t=new MutationObserver((()=>{w(o)&&t.disconnect()}));t.observe(document.body,{childList:!0,subtree:!0}),setTimeout((()=>{w(o)}),1e3),setTimeout((()=>{if(e.notFoundElementFallback){g(`Hello anchor selector ${e.anchorElementSelector} not found after 3 seconds, falling back to 'notFoundElementFallback': ${e.notFoundElementFallback}`,"info");const t=S({position:y(e.notFoundElementFallback)});w(t)}}),3e3)}}else v(`Selector anchorElementSelector "${e.anchorElementSelector}" is not a valid selector.`)};class b{constructor(e,t){this.targetId=e,this.allowedEvents=t,this.listeners=new Map,this.handleMessage=e=>{var t,o,i;const n=e.data,s=(null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||(null===(i=null===(o=this.iframe)||void 0===o?void 0:o.contentDocument)||void 0===i?void 0:i.defaultView);if(e.source!==s)return;if(!this.isValidMessage(n))return;const r=this.listeners.get(n.type);null==r||r.forEach((e=>{try{e(n.payload)}catch(e){v("Error in event listener:",e)}}))},this.initializeEventListeners(),this.iframe=document.getElementById(this.targetId)}initializeEventListeners(){window.addEventListener("message",this.handleMessage)}isValidMessage(e){if(!e||"object"!=typeof e)return!1;const t=e;return t.id===this.targetId&&"string"==typeof t.type&&this.allowedEvents.includes(t.type)&&void 0!==t.payload}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),g(`[CheckoutAddressService] listening to ${e}`,"info");const o=t,i=this.listeners.get(e);return i&&i.add(o),()=>{const t=this.listeners.get(e);t&&t.delete(o)}}destroy(){window.removeEventListener("message",this.handleMessage),this.listeners.clear()}}class I extends b{constructor(){g("=== [Google Places Service] Initializing","info"),super(p.GOOGLE_PLACES,["fetchAutocompleteSuggestions","initializeGooglePlacesService","placeSelected","onFetchAutocompleteSuggestions","onInitializeGooglePlacesService","onPlaceSelected"])}sendMessage(e,t){var o;if(!(null===(o=this.iframe)||void 0===o?void 0:o.contentWindow))return;const i={id:this.targetId,logType:window.Zonos.iframeLogType,payload:t,type:e};g(`GooglePlacesService] parent --\x3e ${e}`,"info",t),this.iframe.contentWindow.postMessage(i,"*")}initialize(){this.sendMessage("initializeGooglePlacesService",{})}fetchSuggestions({country:e,query:t,type:o}){e&&this.sendMessage("fetchAutocompleteSuggestions",{request:{includedRegionCodes:[e],input:t},type:o})}selectPlace({placeId:e,type:t}){this.sendMessage("placeSelected",{placeId:e,type:t})}}class j{constructor(){this.googlePlaceInitialized=!1,g("=== [CheckoutAddressService] Initializing","info"),this.googlePlaces=new I,this.googlePlaces.on("onInitializeGooglePlacesService",(()=>{g("=== [CheckoutAddressService] parent <-- onInitializeGooglePlacesService","info"),this.googlePlaceInitialized=!0})),this.initialize()}initialize(){this.googlePlaces.initialize()}onInitializeGooglePlacesService(e){return this.googlePlaces.on("onInitializeGooglePlacesService",(()=>{g("[CheckoutAddressService] parent <-- onInitializeGooglePlacesService"),e()}))}isGooglePlaceInitialized(){return this.googlePlaceInitialized}onAddressSuggestions(e){return this.suggestionsCallback=e,this.googlePlaces.on("onFetchAutocompleteSuggestions",((...t)=>{g(`[CheckoutAddressService] parent <-- onFetchAutocompleteSuggestions ${t[0].type}`,"info",...t),e(...t)}))}onAddressSelected(e){return this.placeSelectedCallback=e,this.googlePlaces.on("onPlaceSelected",((...t)=>{g(`[CheckoutAddressService] parent <-- onPlaceSelected ${t[0].type}`,"info",...t),e(...t)}))}getAddressSuggestions({country:e,query:t,type:o}){this.googlePlaceInitialized&&this.googlePlaces.fetchSuggestions({country:e,query:t,type:o})}selectAddress({placeId:e,type:t}){this.googlePlaces.selectPlace({placeId:e,type:t})}destroy(){this.googlePlaces.destroy(),this.suggestionsCallback&&(this.suggestionsCallback=void 0),this.placeSelectedCallback&&(this.placeSelectedCallback=void 0)}}const k=class{constructor(o){e(this,o),this.paypalInitEvent=t(this,"paypalInitEvent",7),this.stripeInitEvent=t(this,"stripeInitEvent",7)}async initCheckoutElement(e){var t;e?(n.stripe=e,((t=l.checkoutSettings).placeOrderButtonSelector||t.alwaysTriggerInternationalCheckoutSelector||window.Zonos.cartData)&&(!t.placeOrderButtonSelector||s(t.placeOrderButtonSelector)?!t.alwaysTriggerInternationalCheckoutSelector||s(t.alwaysTriggerInternationalCheckoutSelector)?(()=>{if(!document.querySelector("zonos-checkout")){const e=document.createElement("zonos-checkout");document.body.appendChild(e)}})():v(`Selector alwaysTriggerInternationalCheckoutSelector "${t.alwaysTriggerInternationalCheckoutSelector}" is not a valid selector`):v(`Selector checkoutButtonAnchor "${t.placeOrderButtonSelector}" is not a valid selector`)),g("init checkout element")):g("Stripe is not loaded yet - cannot init checkout element","warn")}initZonosNotification(){if(document.querySelector("zonos-notification"))return;const e=document.createElement("zonos-notification");document.body.appendChild(e)}async setupGoogleFont(e){var t,o;const i=e||h();if("Inter"===i){if(!e)return;g("[FONT] Just applied Inter , but no need to inject since we already inject Inter on start","warn"),l.appearance=Object.assign(Object.assign({},l.appearance),{fontFamily:e})}const n=new URLSearchParams;n.set("family",i);const{errors:s,json:r}=await m(`/api/zonos-elements/get-font-detail?${n.toString()}`);if(s.length>0)return g(`Failed to load font ${i}`,"warn"),void(l.appearance=Object.assign(Object.assign({},l.appearance),{fontFamily:"Inter"}));const c=null==r?void 0:r.fontUrl;c&&(null===(o=(t=window.Zonos).injectSupportGoogleFont)||void 0===o||o.call(t,c)),e&&(g(`[FONT] ${e} font override applied`),l.appearance=Object.assign(Object.assign({},l.appearance),{fontFamily:e}))}handleLocationChange(){z(l.helloSettings)}initHistoryListener(){const e=history.pushState;history.pushState=function(){return window.dispatchEvent(new window.Event("pushstate")),window.dispatchEvent(new window.Event("locationchange")),e.apply(this,arguments)};const t=history.replaceState;history.replaceState=function(){return window.dispatchEvent(new window.Event("replacestate")),window.dispatchEvent(new window.Event("locationchange")),t.apply(this,arguments)}}injectCustomHTML(e){if(!e)return;if(!window.Zonos.isLegacyCheckout)return void g("=== Skip injecting custom HTML for hosted checkout","info");g("=== Injecting custom HTML for hosted checkout");const t=document.createElement("template");t.innerHTML=e,t.content.querySelectorAll("script").forEach((e=>{const t=document.createElement("script");e.src?(t.src=e.src,t.async=e.async):t.textContent=e.innerHTML,document.body.appendChild(t)}))}async initGooglePlacesService(e){const t=null==e?void 0:e.genericSettings;if(!t)return;const o=t.signedTokenGooglePlaces;o&&f({id:p.GOOGLE_PLACES,onload:()=>{l.checkoutAddressService=new j},src:`https://route.elements.zonos.com/iframe/google-maps?signedToken=${o}`})}async componentWillLoad(){this.initHistoryListener(),l.zonosApiKey=this.zonosApiKey,(async()=>{var e,t,o,i,n,s;const{errors:c,json:a,zonosMode:h}=await(async()=>{if(window.Zonos.cartSettings)return{errors:[],json:window.Zonos.cartSettings,zonosMode:window.Zonos.zonosMode};const e=u(),t=new URLSearchParams;e.overrideShouldEnabledCustomAddress&&t.set("overrideShouldEnabledCustomAddress",e.overrideShouldEnabledCustomAddress);const{errors:o,json:i,zonosMode:n}=await m(`/api/zonos-elements/zonos-settings?${t.toString()}`);return o.length?(v("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings"),{errors:o,json:null,zonosMode:n}):{errors:[],json:i,zonosMode:n}})();if("403"===(null===(t=null===(e=c[0])||void 0===e?void 0:e.type)||void 0===t?void 0:t.toString()))return void g("Failed to load zonos settings. This domain may not have access","warn");const p=(null===(o=null==a?void 0:a.checkoutSettings)||void 0===o?void 0:o.customHTML)||"";this.injectCustomHTML(p),this.initZonosNotification();const f=window.Zonos.isLegacyCheckout&&!!window.Zonos.cartData&&"CLOSE_MODAL"===(null===(i=this.config.checkoutSettings)||void 0===i?void 0:i.successBehavior),w=Object.assign(Object.assign({},this.config),{appearance:Object.assign(Object.assign({},this.config.appearance),{logoUrl:(()=>{var e,t,o;return window.Zonos.isLegacyCheckout?(null===(e=null==a?void 0:a.appearanceSettings)||void 0===e?void 0:e.logoUrl)||(null===(t=this.config.appearance)||void 0===t?void 0:t.logoUrl):null===(o=this.config.appearance)||void 0===o?void 0:o.logoUrl})()}),checkoutSettings:this.config.checkoutSettings?Object.assign(Object.assign({},this.config.checkoutSettings),{allowedSettlementCurrencies:void 0,captureDelay:void 0,subscriptionStatus:void 0,successBehavior:f?"ZONOS_SUCCESS_PAGE":this.config.checkoutSettings.successBehavior,successRedirectUrl:f?(null===(n=window.Zonos.cartData)||void 0===n?void 0:n.storeBaseUrl)||(null==a?void 0:a.onlineStoreSettings.url):this.config.checkoutSettings.successRedirectUrl}):void 0});d({overrideSettings:w,zonosSettings:a}),l.zonosMode=h,this.setupGoogleFont(),"DISABLED"===l.helloSettings.visibilityStatus&&g("=== Hello is disabled by store owner ===","warn"),l.helloSettings&&"ENABLED"===l.helloSettings.visibilityStatus&&(g("Initializing hello"),z(l.helloSettings)),await r();const y=(null===(s=null==a?void 0:a.checkoutSettings)||void 0===s?void 0:s.externalServiceTokens.find((e=>"STRIPE_PUBLISHABLE_TOKEN"===e.type)))||null;if(y&&this.stripeInitEvent){if("INACTIVE"===l.checkoutSettings.subscriptionStatus)return g('=== Checkout subscription is "INACTIVE" - Cancel initializing for Checkout ===',"warn"),void g("zonos controller loaded");if("DISABLED"===l.checkoutSettings.visibilityStatus)return g("=== Checkout is disabled by store owner ===","warn"),void g("zonos controller loaded");this.stripeInitEvent.emit({publishableKey:y.token}),this.initGooglePlacesService(a)}else g("Checkout failed to load -- missing publishable key","warn")})()}async showNotification(e){const t=document.querySelector("zonos-notification");t?t.showNotification(e):g("Failed to show notification - zonos-notification not found","warn")}async reset(){c.checkoutSessionId=null,n.clientSecret=""}async overrideConfig(e){d({overrideSettings:e,zonosSettings:null})}async overrideCountry(e){g(`Override country code to ${e}`),a(e)}async getAppearanceSetting(){return l.appearance}async updateOrganizationName(e){l.organizationName=e}render(){return o(i,{key:"62c0b3079d64f05800da24daa19e0e1e3a890bca",class:"zonos--elements"})}};k.style=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{visibility:hidden;opacity:0;height:0}";export{k as zonos_controller}
@@ -1 +1 @@
1
- import{p as e,b as o}from"./p-b30c2ad9.js";export{s as setNonce}from"./p-b30c2ad9.js";import{g as t}from"./p-e1255160.js";(()=>{const o=import.meta.url,t={};return""!==o&&(t.resourcesUrl=new URL(".",o).href),e(t)})().then((async e=>(await t(),o(JSON.parse('[["p-e51480a4",[[2,"zonos-checkout",{"appearanceSettingsOverride":[16],"preview":[4],"hiddenMode":[4,"hidden-mode"],"mobile":[4],"overrideStagingMode":[4,"override-staging-mode"],"defaultAddress":[16],"forceDialogOpen":[4,"force-dialog-open"],"defaultAddressParams":[32],"defaultCustomerProfileAddress":[32],"customerProfile":[32],"open":[32],"isOverlayLoading":[32],"stripe":[32],"submitLoading":[32],"collapseReviewMobile":[32],"isAttachError":[32],"isMobile":[32],"isIframed":[32],"zonosReviewRef":[32],"storybookPaymentStatusOverride":[32],"isLegacyCheckout":[32],"confirmDialogOpen":[32],"isCartExpired":[32],"payInUsdConfirmDialogOpen":[32],"inventoryCheckErrorMessage":[32],"placedOrderInfo":[32],"clientSecret":[32],"stripeCustomerSessionClientSecret":[32],"closeDialogHandler":[64],"init":[64],"setToFinishStep":[64],"mockCheckoutSession":[64],"triggerCheckoutInternational":[64]},[[16,"zonos--init-cart-info","initCartInfoHandler"],[4,"keydown","handleKeyPress"],[9,"resize","handleWindowResize"]],{"appearanceSettingsOverride":["appearanceSettingsOverrideChanged","handleAppearanceSettingsOverrideChange"],"overrideStagingMode":["overrideStagingModeChanged"],"mobile":["handleMobileChange"],"defaultAddress":["handleAddressChange"],"customerProfile":["handleCustomerProfileChange"],"clientSecret":["handleClientSecretChange"],"stripeCustomerSessionClientSecret":["handleClientSecretChange"],"open":["handleOpenChange"]}]]],["p-e90ff8fb",[[1,"zonos-hello",{"mobileLocationOverride":[1,"mobile-location-override"],"animateFromLeftOverride":[4,"animate-from-left-override"],"appearanceSettingsOverride":[16],"showPeekMessage":[32],"zonosStoreHelloSettings":[32],"showDialog":[32],"peekMessage":[32],"initialUrl":[32],"allRestrictedItems":[32],"allFoundProducts":[32],"productsOnPage":[32],"isHelloWidgetRendered":[32],"isMobile":[32],"getCountryList":[64],"displayCurrency":[64],"convertAndFormat":[64],"convert":[64],"format":[64],"openHelloDialog":[64]},[[9,"resize","handleResize"]],{"showDialog":["showDialogHandler"],"appearanceSettingsOverride":["handleAppearanceSettingsOverrideChange"]}]]],["p-20f929d8",[[1,"zonos-controller",{"config":[16],"zonosApiKey":[1,"zonos-api-key"],"initCheckoutElement":[64],"setupGoogleFont":[64],"showNotification":[64],"reset":[64],"overrideConfig":[64],"overrideCountry":[64],"getAppearanceSetting":[64],"updateOrganizationName":[64]},[[8,"locationchange","handleLocationChange"]]]]],["p-ebaaaee9",[[1,"zonos-tooltip",{"label":[1],"subtitle":[1],"showTooltip":[32]}]]],["p-e640e8b8",[[1,"zonos-component",{"first":[1],"middle":[1],"last":[1]}]]],["p-7b5de646",[[1,"zonos-link",{"href":[1],"rel":[1],"target":[1],"linkTitle":[1,"link-title"]}]]],["p-3f31901f",[[1,"zonos-logo",{"theme":[1],"width":[1]}]]],["p-a98b1e8d",[[1,"zonos-text",{"textColor":[1,"text-color"],"size":[1],"type":[1],"weight":[2],"ready":[32]}]]],["p-858a55d2",[[1,"zonos-hello-dialog",{"isOpen":[4,"is-open"],"setIsOpen":[16],"mobileLocationOverride":[1,"mobile-location-override"],"animateFromLeftOverride":[4,"animate-from-left-override"],"appearanceSettings":[16],"restrictedItems":[16],"welcomeMessage":[32],"showCountrySelect":[32],"showLanguageSelect":[32]},[[4,"click","globalClickHandler"]],{"isOpen":["isOpenHandler"]}]]],["p-1c45cd15",[[1,"zonos-badge",{"bold":[4],"badgeColor":[1,"badge-color"],"icon":[16],"iconRight":[4,"icon-right"],"size":[1],"rounded":[4],"loading":[4],"dismissHandler":[16]}]]],["p-e7b05da2",[[1,"zonos-shipping-rich-radio",{"items":[16],"borderColor":[1,"border-color"],"borderStyle":[1,"border-style"],"theme":[1],"selectedItem":[16]}]]],["p-62813488",[[1,"zonos-toggle",{"options":[16],"value":[1]}]]],["p-edc77ea1",[[1,"zonos-collapse",{"collapsed":[4],"collapseSize":[2,"collapse-size"],"height":[32],"iframe":[32]}]]],["p-ad556be6",[[1,"zonos-card",{"actions":[16],"backgroundColor":[1,"background-color"],"borderRadius":[2,"border-radius"],"footerActions":[16],"footerContent":[16],"footerHeight":[2,"footer-height"],"label":[16],"spacing":[1]}]]],["p-605a21ac",[[2,"zonos-stripe-input",{"name":[1],"autoComplete":[1,"auto-complete"],"inputValue":[1,"input-value"],"inputLabel":[1,"input-label"],"overridePrimaryColor":[1,"override-primary-color"],"overrideSecondaryColor":[1,"override-secondary-color"],"isDisabled":[4,"is-disabled"],"isError":[4,"is-error"],"error":[1],"inputPlaceholder":[1,"input-placeholder"],"value":[1025],"required":[4],"internalValue":[32]},null,{"inputValue":["onInputValueChange"],"value":["onValueChange"]}]]],["p-c7d5d45d",[[1,"zonos-input",{"inputValue":[1,"input-value"],"inputLabel":[1,"input-label"],"inputSize":[1,"input-size"],"isDisabled":[4,"is-disabled"],"isError":[4,"is-error"],"inputPlaceholder":[1,"input-placeholder"],"value":[32]},null,{"inputValue":["onInputValueChange"]}]]],["p-b9ff6458",[[1,"zonos-banner",{"bannerTitle":[1,"banner-title"],"intent":[1],"hasContent":[32]}]]],["p-77666360",[[1,"zonos-v-stack",{"spacing":[2]}]]],["p-5f125617",[[1,"zonos-empty-state-payment",{"emptyStateText":[1,"empty-state-text"],"theme":[1]}],[2,"zonos-payment",{"titleText":[1,"title-text"],"stripe":[32],"stripeElements":[32],"isPaymentInfoFilled":[32]},null,{"isPaymentInfoFilled":["watchIsPaymentInfoFilled"],"stripeElements":["watchInitStripe"],"stripe":["watchInitStripe"]}],[2,"zonos-paypal-payment"],[1,"zonos-notification",{"notificationArray":[32],"showNotification":[64]}]]],["p-1da85818",[[1,"zonos-language-select",{"handleOnClose":[16]}],[1,"zonos-select-dialog-header",{"handleOnClose":[16],"label":[1]}]]],["p-19bb71d1",[[1,"zonos-country-flag",{"countryCode":[1,"country-code"],"size":[2]}]]],["p-d6fa2dc2",[[17,"zonos-button",{"buttonColor":[1,"button-color"],"backgroundColor":[1,"background-color"],"borderStyle":[1,"border-style"],"isDisabled":[4,"is-disabled"],"icon":[16],"iconRight":[4,"icon-right"],"size":[1],"variant":[1],"noBackground":[4,"no-background"],"withBoxShadow":[4,"with-box-shadow"],"noPaddingLeft":[4,"no-padding-left"],"noPaddingRight":[4,"no-padding-right"],"loading":[4],"justifyContent":[1,"justify-content"],"bold":[4],"theme":[1],"hasIcon":[32],"hasContent":[32]},[[2,"click","clickHandler"]],{"icon":["iconChangeHandler"]}],[1,"zonos-spinner",{"size":[2],"spinnerColor":[1,"spinner-color"]}],[1,"zonos-icon",{"autoHeight":[4,"auto-height"],"iconColor":[1,"icon-color"],"content":[1],"size":[2]}]]],["p-0b48c596",[[1,"zonos-country-select",{"handleOnClose":[16],"inputValue":[32]}],[1,"zonos-hello-dialog-footer",{"appearanceSettings":[16],"setShowCountrySelect":[16],"setShowLanguageSelect":[16]}],[1,"zonos-custom-message",{"icon":[1],"message":[1]}],[2,"zonos-virtual-scroll",{"renderItem":[16],"itemWidth":[2,"item-width"],"fallbackItemHeight":[2,"fallback-item-height"],"itemHeights":[16],"buffer":[2],"scrollTop":[32],"totalHeight":[32],"containerDimensions":[32]},null,{"itemHeights":["updateTotalHeight"],"fallbackItemHeight":["updateTotalHeight"]}]]],["p-73463715",[[1,"zonos-address-update-dialog",{"continueLoading":[4,"continue-loading"],"dialogLoading":[4,"dialog-loading"],"dialogOpen":[4,"dialog-open"],"submitBtnType":[1,"submit-btn-type"],"submitBtnColor":[1,"submit-btn-color"],"isMobile":[4,"is-mobile"],"shippingAddress":[16],"billingAddress":[16],"translatedShippingAddress":[16],"translatedBillingAddress":[16],"showErrorBanner":[32],"translatedShippingAddressState":[32],"translatedBillingAddressState":[32]},null,{"translatedShippingAddress":["watchTranslatedShippingAddress"],"translatedBillingAddress":["watchTranslatedBillingAddress"]}],[2,"zonos-custom-address",{"type":[1],"titleText":[1,"title-text"],"defaultAddress":[16],"taxIdErrorMessage":[1,"tax-id-error-message"],"stripe":[32],"isDirtyAddress":[32],"isAddressFilled":[32],"isAddressLine1Entered":[32],"addressSuggestions":[32],"countryField":[32],"startGooglePlaceSuggestions":[32],"shipToCountries":[32],"shippingZones":[32],"city":[32],"country":[32],"firstName":[32],"lastName":[32],"line1":[32],"line2":[32],"phone":[32],"postalCode":[32],"state":[32],"cityError":[32],"stateError":[32],"postalCodeError":[32],"phoneError":[32],"firstNameError":[32],"lastNameError":[32],"isFirstInitialization":[32],"addressService":[32],"checkoutSessionId":[32]},null,{"checkoutSessionId":["isAddressFilledChanged"],"isAddressFilled":["isAddressFilledChanged"],"defaultAddress":["defaultAddressChanged"],"line1":["line1Changed"],"city":["formFieldsChanged"],"country":["formFieldsChanged","countryChanged"],"firstName":["formFieldsChanged"],"lastName":["formFieldsChanged"],"line2":["formFieldsChanged"],"phone":["formFieldsChanged"],"postalCode":["formFieldsChanged"],"state":["formFieldsChanged"],"addressService":["shouldEnabledCustomAddressChanged"],"shippingZones":["shippingZonesChanged"]}],[2,"zonos-address",{"type":[1],"titleText":[1,"title-text"],"defaultAddress":[16],"taxIdErrorMessage":[1,"tax-id-error-message"],"stripe":[32],"isDirtyAddress":[32],"isAddressFilled":[32],"checkoutSessionId":[32],"prevCountry":[32],"prevPostalCode":[32]},null,{"checkoutSessionId":["isAddressFilledChanged"],"isAddressFilled":["isAddressFilledChanged"],"stripe":["watchInitStripe"],"defaultAddress":["defaultAddressChanged"]}],[2,"zonos-link-authentication",{"titleText":[1,"title-text"],"defaultEmail":[1,"default-email"],"isEmailError":[4,"is-email-error"],"stripe":[32],"isStagingMode":[32],"clientSecret":[32]},null,{"isStagingMode":["watchIsStagingMode"],"stripe":["watchInitStripe"],"clientSecret":["watchInitStripe"],"defaultEmail":["watchDefaultEmail"]}],[1,"zonos-checkbox",{"backgroundColor":[1,"background-color"],"label":[1],"isChecked":[4,"is-checked"],"isDisabled":[4,"is-disabled"],"size":[2],"fontSize":[1,"font-size"],"borderStyle":[1,"border-style"]},[[1,"click","onClick"]]],[1,"zonos-address-suggestions",{"type":[1],"suggestions":[16],"selectedSuggestionId":[32],"localSuggestions":[32],"lastHoveredSuggestionId":[32]},null,{"suggestions":["suggestionsChanged"]}],[1,"zonos-dialog",{"open":[4],"headerText":[1,"header-text"],"width":[1],"height":[1],"minHeight":[1,"min-height"],"noHeader":[4,"no-header"],"noBodyPadding":[4,"no-body-padding"],"noBorder":[4,"no-border"],"borderStyle":[1,"border-style"],"noCloseButton":[4,"no-close-button"],"noClickOutside":[4,"no-click-outside"],"mobile":[4],"isLoading":[4,"is-loading"],"isMobile":[32]},[[9,"resize","handleWindowResize"],[4,"keydown","handleKeyDown"]]],[2,"zonos-stripe-phone-input",{"autoComplete":[1,"auto-complete"],"countryOptions":[16],"disabled":[4],"error":[1],"inputLabel":[1,"input-label"],"overridePrimaryColor":[1,"override-primary-color"],"overrideSecondaryColor":[1,"override-secondary-color"],"inputValue":[1,"input-value"],"countryCode":[1,"country-code"],"minWidth":[1,"min-width"],"selectedCountry":[32],"phoneNumber":[32],"isFocused":[32],"isSelectOpen":[32]},null,{"countryOptions":["onCountryOptionsChange"],"selectedCountry":["onSelectedCountryChange"],"inputValue":["onPhoneNumberChange"]}],[1,"zonos-address-display",{"currentAddress":[16],"addressType":[1,"address-type"]}],[1,"zonos-address-form",{"currentAddress":[16],"translatedAddress":[16],"addressType":[1,"address-type"],"localAddress":[32]},null,{"translatedAddress":["watchCurrentAddress"]}],[1,"zonos-stripe-select",{"name":[1],"selectedValue":[1,"selected-value"],"selectLabel":[1,"select-label"],"overridePrimaryColor":[1,"override-primary-color"],"overrideSecondaryColor":[1,"override-secondary-color"],"isDisabled":[4,"is-disabled"],"isError":[4,"is-error"],"error":[1],"selectPlaceholder":[1,"select-placeholder"],"options":[16],"autoComplete":[1,"auto-complete"],"value":[1025],"required":[4],"isClearable":[4,"is-clearable"],"minWidth":[1,"min-width"],"internalValue":[32],"internalOptions":[32]},null,{"options":["onOptionsChange"],"selectedValue":["onSelectedValueChange"],"value":["onValueChange"]}]]],["p-ab7fed30",[[2,"zonos-customer-info",{"continueLoading":[4,"continue-loading"],"submitBtnType":[1,"submit-btn-type"],"submitBtnColor":[1,"submit-btn-color"],"isMobile":[4,"is-mobile"],"defaultAddress":[16],"shouldUseCustomAddressFormOverride":[4,"should-use-custom-address-form-override"],"showErrorBanner":[32],"shippingCountry":[32],"isCheckingForRestrictedItems":[32],"isValidatingAddress":[32],"taxIdErrorMessage":[32],"invalidShippingCharacterList":[32],"invalidBillingCharacterList":[32],"openAddressValidationDialog":[32],"isEmailError":[32],"recordedFormTypeUsed":[32],"selectedCountryCode":[32],"genericSettings":[32],"addressFormRenderType":[32]},null,{"showErrorBanner":["watchShowErrorBanner"],"shouldUseCustomAddressFormOverride":["watchShouldEnabledCustomAddress"],"genericSettings":["watchShouldEnabledCustomAddress"],"selectedCountryCode":["watchShouldEnabledCustomAddress"]}],[2,"zonos-checkout-payment",{"submitBtnType":[1,"submit-btn-type"],"continueLoading":[4,"continue-loading"],"submitBtnColor":[1,"submit-btn-color"],"isMobile":[4,"is-mobile"],"overridePrimaryColor":[1,"override-primary-color"],"showErrorBanner":[32],"hasStripePaymentError":[32],"stagingOrderCreateErrorMessage":[32],"internalContinueLoading":[32]},null,{"continueLoading":["continueLoadingWatcher"],"hasStripePaymentError":["stripePaymentErrorWatcher"]}],[1,"zonos-checkout-footer",{"mobile":[4],"dataTheme":[1,"data-theme"],"showLanguageDialog":[32],"isMobile":[32]},[[4,"click","handleGlobalClick"]],{"mobile":["handleMobileChange"]}],[2,"zonos-shipping",{"continueLoading":[4,"continue-loading"],"submitBtnColor":[1,"submit-btn-color"],"submitBtnType":[1,"submit-btn-type"],"selectedShippingMethod":[32],"collapsedDAPOptions":[32],"isSelecting":[32],"showErrorBanner":[32],"serviceLevelsDDP":[32],"serviceLevelsDAP":[32],"serviceLevelsOther":[32],"serviceLevelsAll":[32],"displayBaseCurrency":[32],"shippingData":[32]}],[1,"zonos-cart-subtotal",{"submitBtnType":[1,"submit-btn-type"],"submitBtnColor":[1,"submit-btn-color"],"loading":[32]}],[1,"zonos-cart-restricted-items",{"hide":[4],"errorImages":[32],"internalCollapsed":[32],"firstRender":[32]}],[1,"zonos-checkout-finish",{"borderRadius":[1,"border-radius"],"storybookForceStatus":[1,"storybook-force-status"],"overrideNotification":[16],"isLoading":[32],"notificationType":[32],"notificationTitle":[32],"notificationMessages":[32],"notificationActionText":[32],"order":[32],"isWaitingToRedirect":[32]}],[1,"zonos-confirm-dialog",{"dialogTitle":[1,"dialog-title"],"dialogIntent":[1,"dialog-intent"],"dialogSubtitle":[1,"dialog-subtitle"],"submitBtnColor":[1,"submit-btn-color"],"dialogConfirmBtnText":[1,"dialog-confirm-btn-text"],"dialogWidth":[2,"dialog-width"],"dialogCancelBtnText":[1,"dialog-cancel-btn-text"],"dialogType":[1,"dialog-type"],"isMobile":[4,"is-mobile"],"dialogOpen":[4,"dialog-open"],"noClickOutside":[4,"no-click-outside"]},[[4,"keydown","handleKeyDown"]]],[1,"zonos-checkout-progress-tabs",{"tabColor":[1,"tab-color"],"backgroundColor":[1,"background-color"],"setTabItems":[64],"setTabSelected":[64]}],[1,"zonos-review",{"mobile":[4],"collapsed":[4],"isMobile":[32]},[[9,"resize","handleWindowResize"]]],[1,"zonos-cart-items",{"errorImages":[32]}],[1,"zonos-currency-toggle",{"errorImages":[32]}],[1,"zonos-loading-overlay",{"open":[4],"spinnerColor":[1,"spinner-color"],"size":[2]}],[1,"zonos-rest-state",{"restStateSubtitle":[1,"rest-state-subtitle"],"restStateTitle":[1,"rest-state-title"],"restStateType":[1,"rest-state-type"],"isErrorImageLoad":[32]}]]]]'),e))));
1
+ import{p as e,b as o}from"./p-b30c2ad9.js";export{s as setNonce}from"./p-b30c2ad9.js";import{g as t}from"./p-e1255160.js";(()=>{const o=import.meta.url,t={};return""!==o&&(t.resourcesUrl=new URL(".",o).href),e(t)})().then((async e=>(await t(),o(JSON.parse('[["p-24a5352e",[[2,"zonos-checkout",{"appearanceSettingsOverride":[16],"preview":[4],"hiddenMode":[4,"hidden-mode"],"mobile":[4],"overrideStagingMode":[4,"override-staging-mode"],"defaultAddress":[16],"forceDialogOpen":[4,"force-dialog-open"],"defaultAddressParams":[32],"defaultCustomerProfileAddress":[32],"customerProfile":[32],"open":[32],"isOverlayLoading":[32],"stripe":[32],"submitLoading":[32],"collapseReviewMobile":[32],"isAttachError":[32],"isMobile":[32],"isIframed":[32],"zonosReviewRef":[32],"storybookPaymentStatusOverride":[32],"isLegacyCheckout":[32],"confirmDialogOpen":[32],"isCartExpired":[32],"payInUsdConfirmDialogOpen":[32],"inventoryCheckErrorMessage":[32],"placedOrderInfo":[32],"clientSecret":[32],"stripeCustomerSessionClientSecret":[32],"closeDialogHandler":[64],"init":[64],"setToFinishStep":[64],"mockCheckoutSession":[64],"triggerCheckoutInternational":[64]},[[16,"zonos--init-cart-info","initCartInfoHandler"],[4,"keydown","handleKeyPress"],[9,"resize","handleWindowResize"]],{"appearanceSettingsOverride":["appearanceSettingsOverrideChanged","handleAppearanceSettingsOverrideChange"],"overrideStagingMode":["overrideStagingModeChanged"],"mobile":["handleMobileChange"],"defaultAddress":["handleAddressChange"],"customerProfile":["handleCustomerProfileChange"],"clientSecret":["handleClientSecretChange"],"stripeCustomerSessionClientSecret":["handleClientSecretChange"],"open":["handleOpenChange"]}]]],["p-752220fe",[[1,"zonos-hello",{"mobileLocationOverride":[1,"mobile-location-override"],"animateFromLeftOverride":[4,"animate-from-left-override"],"appearanceSettingsOverride":[16],"showPeekMessage":[32],"zonosStoreHelloSettings":[32],"showDialog":[32],"peekMessage":[32],"initialUrl":[32],"allRestrictedItems":[32],"allFoundProducts":[32],"productsOnPage":[32],"isHelloWidgetRendered":[32],"isMobile":[32],"getCountryList":[64],"displayCurrency":[64],"convertAndFormat":[64],"convert":[64],"format":[64],"openHelloDialog":[64]},[[9,"resize","handleResize"]],{"showDialog":["showDialogHandler"],"appearanceSettingsOverride":["handleAppearanceSettingsOverrideChange"]}]]],["p-f0e8e81e",[[1,"zonos-controller",{"config":[16],"zonosApiKey":[1,"zonos-api-key"],"initCheckoutElement":[64],"setupGoogleFont":[64],"showNotification":[64],"reset":[64],"overrideConfig":[64],"overrideCountry":[64],"getAppearanceSetting":[64],"updateOrganizationName":[64]},[[8,"locationchange","handleLocationChange"]]]]],["p-ebaaaee9",[[1,"zonos-tooltip",{"label":[1],"subtitle":[1],"showTooltip":[32]}]]],["p-e640e8b8",[[1,"zonos-component",{"first":[1],"middle":[1],"last":[1]}]]],["p-7b5de646",[[1,"zonos-link",{"href":[1],"rel":[1],"target":[1],"linkTitle":[1,"link-title"]}]]],["p-3f31901f",[[1,"zonos-logo",{"theme":[1],"width":[1]}]]],["p-a98b1e8d",[[1,"zonos-text",{"textColor":[1,"text-color"],"size":[1],"type":[1],"weight":[2],"ready":[32]}]]],["p-a4efb55c",[[1,"zonos-hello-dialog",{"isOpen":[4,"is-open"],"setIsOpen":[16],"mobileLocationOverride":[1,"mobile-location-override"],"animateFromLeftOverride":[4,"animate-from-left-override"],"appearanceSettings":[16],"restrictedItems":[16],"welcomeMessage":[32],"showCountrySelect":[32],"showLanguageSelect":[32]},[[4,"click","globalClickHandler"]],{"isOpen":["isOpenHandler"]}]]],["p-1c45cd15",[[1,"zonos-badge",{"bold":[4],"badgeColor":[1,"badge-color"],"icon":[16],"iconRight":[4,"icon-right"],"size":[1],"rounded":[4],"loading":[4],"dismissHandler":[16]}]]],["p-e7b05da2",[[1,"zonos-shipping-rich-radio",{"items":[16],"borderColor":[1,"border-color"],"borderStyle":[1,"border-style"],"theme":[1],"selectedItem":[16]}]]],["p-62813488",[[1,"zonos-toggle",{"options":[16],"value":[1]}]]],["p-edc77ea1",[[1,"zonos-collapse",{"collapsed":[4],"collapseSize":[2,"collapse-size"],"height":[32],"iframe":[32]}]]],["p-ad556be6",[[1,"zonos-card",{"actions":[16],"backgroundColor":[1,"background-color"],"borderRadius":[2,"border-radius"],"footerActions":[16],"footerContent":[16],"footerHeight":[2,"footer-height"],"label":[16],"spacing":[1]}]]],["p-605a21ac",[[2,"zonos-stripe-input",{"name":[1],"autoComplete":[1,"auto-complete"],"inputValue":[1,"input-value"],"inputLabel":[1,"input-label"],"overridePrimaryColor":[1,"override-primary-color"],"overrideSecondaryColor":[1,"override-secondary-color"],"isDisabled":[4,"is-disabled"],"isError":[4,"is-error"],"error":[1],"inputPlaceholder":[1,"input-placeholder"],"value":[1025],"required":[4],"internalValue":[32]},null,{"inputValue":["onInputValueChange"],"value":["onValueChange"]}]]],["p-c7d5d45d",[[1,"zonos-input",{"inputValue":[1,"input-value"],"inputLabel":[1,"input-label"],"inputSize":[1,"input-size"],"isDisabled":[4,"is-disabled"],"isError":[4,"is-error"],"inputPlaceholder":[1,"input-placeholder"],"value":[32]},null,{"inputValue":["onInputValueChange"]}]]],["p-b9ff6458",[[1,"zonos-banner",{"bannerTitle":[1,"banner-title"],"intent":[1],"hasContent":[32]}]]],["p-77666360",[[1,"zonos-v-stack",{"spacing":[2]}]]],["p-67da7b6d",[[1,"zonos-empty-state-payment",{"emptyStateText":[1,"empty-state-text"],"theme":[1]}],[2,"zonos-payment",{"titleText":[1,"title-text"],"stripe":[32],"stripeElements":[32],"isPaymentInfoFilled":[32]},null,{"isPaymentInfoFilled":["watchIsPaymentInfoFilled"],"stripeElements":["watchInitStripe"],"stripe":["watchInitStripe"]}],[2,"zonos-paypal-payment"],[1,"zonos-notification",{"notificationArray":[32],"showNotification":[64]}]]],["p-6a157c84",[[1,"zonos-language-select",{"handleOnClose":[16]}],[1,"zonos-select-dialog-header",{"handleOnClose":[16],"label":[1]}]]],["p-0707379c",[[1,"zonos-country-flag",{"countryCode":[1,"country-code"],"size":[2]}]]],["p-d6fa2dc2",[[17,"zonos-button",{"buttonColor":[1,"button-color"],"backgroundColor":[1,"background-color"],"borderStyle":[1,"border-style"],"isDisabled":[4,"is-disabled"],"icon":[16],"iconRight":[4,"icon-right"],"size":[1],"variant":[1],"noBackground":[4,"no-background"],"withBoxShadow":[4,"with-box-shadow"],"noPaddingLeft":[4,"no-padding-left"],"noPaddingRight":[4,"no-padding-right"],"loading":[4],"justifyContent":[1,"justify-content"],"bold":[4],"theme":[1],"hasIcon":[32],"hasContent":[32]},[[2,"click","clickHandler"]],{"icon":["iconChangeHandler"]}],[1,"zonos-spinner",{"size":[2],"spinnerColor":[1,"spinner-color"]}],[1,"zonos-icon",{"autoHeight":[4,"auto-height"],"iconColor":[1,"icon-color"],"content":[1],"size":[2]}]]],["p-003f37f4",[[1,"zonos-country-select",{"handleOnClose":[16],"inputValue":[32]}],[1,"zonos-hello-dialog-footer",{"appearanceSettings":[16],"setShowCountrySelect":[16],"setShowLanguageSelect":[16]}],[1,"zonos-custom-message",{"icon":[1],"message":[1]}],[2,"zonos-virtual-scroll",{"renderItem":[16],"itemWidth":[2,"item-width"],"fallbackItemHeight":[2,"fallback-item-height"],"itemHeights":[16],"buffer":[2],"scrollTop":[32],"totalHeight":[32],"containerDimensions":[32]},null,{"itemHeights":["updateTotalHeight"],"fallbackItemHeight":["updateTotalHeight"]}]]],["p-8b57a34d",[[1,"zonos-address-update-dialog",{"continueLoading":[4,"continue-loading"],"dialogLoading":[4,"dialog-loading"],"dialogOpen":[4,"dialog-open"],"submitBtnType":[1,"submit-btn-type"],"submitBtnColor":[1,"submit-btn-color"],"isMobile":[4,"is-mobile"],"shippingAddress":[16],"billingAddress":[16],"translatedShippingAddress":[16],"translatedBillingAddress":[16],"showErrorBanner":[32],"translatedShippingAddressState":[32],"translatedBillingAddressState":[32]},null,{"translatedShippingAddress":["watchTranslatedShippingAddress"],"translatedBillingAddress":["watchTranslatedBillingAddress"]}],[2,"zonos-custom-address",{"type":[1],"titleText":[1,"title-text"],"defaultAddress":[16],"taxIdErrorMessage":[1,"tax-id-error-message"],"stripe":[32],"isDirtyAddress":[32],"isAddressFilled":[32],"isAddressLine1Entered":[32],"addressSuggestions":[32],"countryField":[32],"startGooglePlaceSuggestions":[32],"shipToCountries":[32],"shippingZones":[32],"city":[32],"country":[32],"firstName":[32],"lastName":[32],"line1":[32],"line2":[32],"phone":[32],"postalCode":[32],"state":[32],"cityError":[32],"stateError":[32],"postalCodeError":[32],"phoneError":[32],"firstNameError":[32],"lastNameError":[32],"isFirstInitialization":[32],"addressService":[32],"checkoutSessionId":[32]},null,{"checkoutSessionId":["isAddressFilledChanged"],"isAddressFilled":["isAddressFilledChanged"],"defaultAddress":["defaultAddressChanged"],"line1":["line1Changed"],"city":["formFieldsChanged"],"country":["formFieldsChanged","countryChanged"],"firstName":["formFieldsChanged"],"lastName":["formFieldsChanged"],"line2":["formFieldsChanged"],"phone":["formFieldsChanged"],"postalCode":["formFieldsChanged"],"state":["formFieldsChanged"],"addressService":["shouldEnabledCustomAddressChanged"],"shippingZones":["shippingZonesChanged"]}],[2,"zonos-address",{"type":[1],"titleText":[1,"title-text"],"defaultAddress":[16],"taxIdErrorMessage":[1,"tax-id-error-message"],"stripe":[32],"isDirtyAddress":[32],"isAddressFilled":[32],"checkoutSessionId":[32],"prevCountry":[32],"prevPostalCode":[32]},null,{"checkoutSessionId":["isAddressFilledChanged"],"isAddressFilled":["isAddressFilledChanged"],"stripe":["watchInitStripe"],"defaultAddress":["defaultAddressChanged"]}],[2,"zonos-link-authentication",{"titleText":[1,"title-text"],"defaultEmail":[1,"default-email"],"isEmailError":[4,"is-email-error"],"stripe":[32],"isStagingMode":[32],"clientSecret":[32]},null,{"isStagingMode":["watchIsStagingMode"],"stripe":["watchInitStripe"],"clientSecret":["watchInitStripe"],"defaultEmail":["watchDefaultEmail"]}],[1,"zonos-checkbox",{"backgroundColor":[1,"background-color"],"label":[1],"isChecked":[4,"is-checked"],"isDisabled":[4,"is-disabled"],"size":[2],"fontSize":[1,"font-size"],"borderStyle":[1,"border-style"]},[[1,"click","onClick"]]],[1,"zonos-address-suggestions",{"type":[1],"suggestions":[16],"selectedSuggestionId":[32],"localSuggestions":[32],"lastHoveredSuggestionId":[32]},null,{"suggestions":["suggestionsChanged"]}],[1,"zonos-dialog",{"open":[4],"headerText":[1,"header-text"],"width":[1],"height":[1],"minHeight":[1,"min-height"],"noHeader":[4,"no-header"],"noBodyPadding":[4,"no-body-padding"],"noBorder":[4,"no-border"],"borderStyle":[1,"border-style"],"noCloseButton":[4,"no-close-button"],"noClickOutside":[4,"no-click-outside"],"mobile":[4],"isLoading":[4,"is-loading"],"isMobile":[32]},[[9,"resize","handleWindowResize"],[4,"keydown","handleKeyDown"]]],[2,"zonos-stripe-phone-input",{"autoComplete":[1,"auto-complete"],"countryOptions":[16],"disabled":[4],"error":[1],"inputLabel":[1,"input-label"],"overridePrimaryColor":[1,"override-primary-color"],"overrideSecondaryColor":[1,"override-secondary-color"],"inputValue":[1,"input-value"],"countryCode":[1,"country-code"],"minWidth":[1,"min-width"],"selectedCountry":[32],"phoneNumber":[32],"isFocused":[32],"isSelectOpen":[32]},null,{"countryOptions":["onCountryOptionsChange"],"selectedCountry":["onSelectedCountryChange"],"inputValue":["onPhoneNumberChange"]}],[1,"zonos-address-display",{"currentAddress":[16],"addressType":[1,"address-type"]}],[1,"zonos-address-form",{"currentAddress":[16],"translatedAddress":[16],"addressType":[1,"address-type"],"localAddress":[32]},null,{"translatedAddress":["watchCurrentAddress"]}],[1,"zonos-stripe-select",{"name":[1],"selectedValue":[1,"selected-value"],"selectLabel":[1,"select-label"],"overridePrimaryColor":[1,"override-primary-color"],"overrideSecondaryColor":[1,"override-secondary-color"],"isDisabled":[4,"is-disabled"],"isError":[4,"is-error"],"error":[1],"selectPlaceholder":[1,"select-placeholder"],"options":[16],"autoComplete":[1,"auto-complete"],"value":[1025],"required":[4],"isClearable":[4,"is-clearable"],"minWidth":[1,"min-width"],"internalValue":[32],"internalOptions":[32]},null,{"options":["onOptionsChange"],"selectedValue":["onSelectedValueChange"],"value":["onValueChange"]}]]],["p-0595e3f8",[[2,"zonos-customer-info",{"continueLoading":[4,"continue-loading"],"submitBtnType":[1,"submit-btn-type"],"submitBtnColor":[1,"submit-btn-color"],"isMobile":[4,"is-mobile"],"defaultAddress":[16],"shouldUseCustomAddressFormOverride":[4,"should-use-custom-address-form-override"],"showErrorBanner":[32],"shippingCountry":[32],"isCheckingForRestrictedItems":[32],"isValidatingAddress":[32],"taxIdErrorMessage":[32],"invalidShippingCharacterList":[32],"invalidBillingCharacterList":[32],"openAddressValidationDialog":[32],"isEmailError":[32],"recordedFormTypeUsed":[32],"selectedCountryCode":[32],"genericSettings":[32],"addressFormRenderType":[32]},null,{"showErrorBanner":["watchShowErrorBanner"],"shouldUseCustomAddressFormOverride":["watchShouldEnabledCustomAddress"],"genericSettings":["watchShouldEnabledCustomAddress"],"selectedCountryCode":["watchShouldEnabledCustomAddress"]}],[2,"zonos-checkout-payment",{"submitBtnType":[1,"submit-btn-type"],"continueLoading":[4,"continue-loading"],"submitBtnColor":[1,"submit-btn-color"],"isMobile":[4,"is-mobile"],"overridePrimaryColor":[1,"override-primary-color"],"showErrorBanner":[32],"hasStripePaymentError":[32],"stagingOrderCreateErrorMessage":[32],"internalContinueLoading":[32]},null,{"continueLoading":["continueLoadingWatcher"],"hasStripePaymentError":["stripePaymentErrorWatcher"]}],[1,"zonos-checkout-footer",{"mobile":[4],"dataTheme":[1,"data-theme"],"showLanguageDialog":[32],"isMobile":[32]},[[4,"click","handleGlobalClick"]],{"mobile":["handleMobileChange"]}],[2,"zonos-shipping",{"continueLoading":[4,"continue-loading"],"submitBtnColor":[1,"submit-btn-color"],"submitBtnType":[1,"submit-btn-type"],"selectedShippingMethod":[32],"collapsedDAPOptions":[32],"isSelecting":[32],"showErrorBanner":[32],"serviceLevelsDDP":[32],"serviceLevelsDAP":[32],"serviceLevelsOther":[32],"serviceLevelsAll":[32],"displayBaseCurrency":[32],"shippingData":[32]}],[1,"zonos-cart-subtotal",{"submitBtnType":[1,"submit-btn-type"],"submitBtnColor":[1,"submit-btn-color"],"loading":[32]}],[1,"zonos-cart-restricted-items",{"hide":[4],"errorImages":[32],"internalCollapsed":[32],"firstRender":[32]}],[1,"zonos-checkout-finish",{"borderRadius":[1,"border-radius"],"storybookForceStatus":[1,"storybook-force-status"],"overrideNotification":[16],"isLoading":[32],"notificationType":[32],"notificationTitle":[32],"notificationMessages":[32],"notificationActionText":[32],"order":[32],"isWaitingToRedirect":[32]}],[1,"zonos-confirm-dialog",{"dialogTitle":[1,"dialog-title"],"dialogIntent":[1,"dialog-intent"],"dialogSubtitle":[1,"dialog-subtitle"],"submitBtnColor":[1,"submit-btn-color"],"dialogConfirmBtnText":[1,"dialog-confirm-btn-text"],"dialogWidth":[2,"dialog-width"],"dialogCancelBtnText":[1,"dialog-cancel-btn-text"],"dialogType":[1,"dialog-type"],"isMobile":[4,"is-mobile"],"dialogOpen":[4,"dialog-open"],"noClickOutside":[4,"no-click-outside"]},[[4,"keydown","handleKeyDown"]]],[1,"zonos-checkout-progress-tabs",{"tabColor":[1,"tab-color"],"backgroundColor":[1,"background-color"],"setTabItems":[64],"setTabSelected":[64]}],[1,"zonos-review",{"mobile":[4],"collapsed":[4],"isMobile":[32]},[[9,"resize","handleWindowResize"]]],[1,"zonos-cart-items",{"errorImages":[32]}],[1,"zonos-currency-toggle",{"errorImages":[32]}],[1,"zonos-loading-overlay",{"open":[4],"spinnerColor":[1,"spinner-color"],"size":[2]}],[1,"zonos-rest-state",{"restStateSubtitle":[1,"rest-state-subtitle"],"restStateTitle":[1,"rest-state-title"],"restStateType":[1,"rest-state-type"],"isErrorImageLoad":[32]}]]]]'),e))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zonos/elements",
3
- "version": "1.3.211",
3
+ "version": "1.3.212",
4
4
  "description": "Zonos component UI for Stripe elements",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.cjs.js",
@@ -1 +0,0 @@
1
- var __awaiter=this&&this.__awaiter||function(e,t,r,o){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function a(e){try{d(o.next(e))}catch(e){i(e)}}function s(e){try{d(o["throw"](e))}catch(e){i(e)}}function d(e){e.done?r(e.value):n(e.value).then(a,s)}d((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,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(t){return d([e,t])}}function d(s){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(r=0)),r)try{if(o=1,n&&(i=s[0]&2?n["return"]:s[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;if(n=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:r.label++;return{value:s[1],done:false};case 5:r.label++;n=s[1];s=[0];continue;case 7:s=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){r.label=s[1];break}if(s[0]===6&&r.label<i[1]){r.label=i[1];i=s;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(s);break}if(i[2])r.ops.pop();r.trys.pop();continue}s=t.call(e,r)}catch(e){s=[6,e];n=0}finally{o=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,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++){if(i||!(o in t)){if(!i)i=Array.prototype.slice.call(t,0,o);i[o]=t[o]}}return e.concat(i||Array.prototype.slice.call(t))};import{z as zonosStore,c as createStore}from"./zonosStore-c456b933.js";import{s as storageStore,l as localizationStore,t as translate,f as filterValidTests,b as storageStoreSetEnabledVariantTestKeys}from"./localization-f1b9c0ef.js";import{l as log,f as fallbackApiList,h as handleFetch,g as getIsTestMode,a as getIsStagingMode,s as sendErrorLog,d as allLogs,b as logError,j as jsonParse}from"./handleFetch-dd74bbb1.js";import{i as isDarkColor}from"./isDarkColor-1f58b6be.js";import{g as getBorderRadius}from"./getBorderRadius-87593ff4.js";var getTranslatedAddress=function(e){var t=e.currentAddress,r=e.translatedAddress;var o,n,i,a,s,d;var c=t.value.address,l=c.city,u=c.country,v=c.line1,S=c.line2,p=c.postal_code,f=c.state;var h=t.value.name||[t.value.firstName,t.value.lastName].join(" ");return{city:((o=r.city)===null||o===void 0?void 0:o[l])||l,country:u,line1:((n=r.line1)===null||n===void 0?void 0:n[v])||v,line2:((i=r.line2)===null||i===void 0?void 0:i[S||""])||S||"",name:((a=r.name)===null||a===void 0?void 0:a[h])||h,phone:t.value.phone||"",postal_code:((s=r.postal_code)===null||s===void 0?void 0:s[p])||p,state:((d=r.state)===null||d===void 0?void 0:d[f])||f}};var prepCartCalculateLandedCost=function(e){var t;var r=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var o=stripeStore.stripeLinkEventData;var n=stripeStore.stripeAddressEventData;var i=stripeStore.stripeShippingSameAsBilling?stripeStore.stripeAddressEventData:stripeStore.stripeBillingAddressEventData;if(!n||!i){throw new Error("Missing stripe address data")}var a=getTranslatedAddress({currentAddress:n,translatedAddress:stripeStore.translatedAddress.address});var s=a.name.split(" ")[0]||"";var d=a.name.split(" ").splice(1).join(" ")||"";var c=getTranslatedAddress({currentAddress:i,translatedAddress:stripeStore.translatedAddress.address});var l=c.name.split(" ")[0]||"";var u=c.name.split(" ").splice(1).join(" ")||"";return{billingAddress:{addressLine1:c.line1,addressLine2:c.line2||"",city:c.city,country:c.country,postalCode:c.postal_code,state:c.state},billingContact:{firstName:l,lastName:u,phone:c.phone},cartCurrencyCode:(t=cartStore.items[0])===null||t===void 0?void 0:t.currencyCode,cartId:e,checkoutSessionId:storageStore.checkoutSessionId||"",contact:{companyName:stripeStore.companyName,email:o===null||o===void 0?void 0:o.value.email,firstName:s,lastName:d,phone:a.phone},isTest:!!r,landedCostAdjustments:cartStore.promoCode?[{amount:0,productId:null,promoCode:cartStore.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToTaxId:stripeStore.taxId,shippingAddress:{addressLine1:a.line1,addressLine2:a.line2,city:a.city,country:a.country,postalCode:a.postal_code,state:a.state}}};var prepCalculateLandedCost=function(){var e=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var t=stripeStore.stripeLinkEventData;var r=stripeStore.stripeAddressEventData;var o=stripeStore.stripeShippingSameAsBilling?stripeStore.stripeAddressEventData:stripeStore.stripeBillingAddressEventData;log({stripeAddressData:r,stripeBillingAddressData:o},"info");if(!r||!o){throw new Error("Missing stripe address data")}var n=getTranslatedAddress({currentAddress:r,translatedAddress:stripeStore.translatedAddress.address});var i=n.name.split(" ")[0]||"";var a=n.name.split(" ").splice(1).join(" ")||"";var s=getTranslatedAddress({currentAddress:o,translatedAddress:stripeStore.translatedAddress.address});var d=s.name.split(" ")[0]||"";var c=s.name.split(" ").splice(1).join(" ")||"";var l=cartStore.adjustments.map((function(e){return{amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}}));var u=cartStore.promoCode?__spreadArray([{amount:0,productId:null,promoCode:cartStore.promoCode,sku:null,type:"PROMO_CODE"}],l,true):l;return{billingAddress:{addressLine1:s.line1,addressLine2:s.line2||"",city:s.city,country:s.country,postalCode:s.postal_code,state:s.state},billingContact:{firstName:d,lastName:c,phone:s.phone},checkoutSessionId:storageStore.checkoutSessionId||"",contact:{companyName:stripeStore.companyName,email:t===null||t===void 0?void 0:t.value.email,firstName:i,lastName:a,phone:n.phone},isTest:e,items:cartStore.items,landedCostAdjustments:u,shipToTaxId:stripeStore.taxId,shippingAddress:{addressLine1:n.line1,addressLine2:n.line2,city:n.city,country:n.country,postalCode:n.postal_code,state:n.state}}};var triggerBuildLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a,s,d,c,l;return __generator(this,(function(u){switch(u.label){case 0:a=prepCalculateLandedCost();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:fallbackApiList["vercel"]})];case 1:s=u.sent();if(!s||!((t=s.checkoutSessionWorkflow)===null||t===void 0?void 0:t.length)&&((r=s.errors)===null||r===void 0?void 0:r.length)){throw new Error("Failed to build landed cost: ".concat(((n=(o=s===null||s===void 0?void 0:s.errors)===null||o===void 0?void 0:o[0])===null||n===void 0?void 0:n.message)||"Unknown error"))}return[4,handleFetch("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:d=u.sent(),c=d.errors,l=d.json;if(!l||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 calculateLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a,s;return __generator(this,(function(d){switch(d.label){case 0:r=zonosStore.checkoutSettings.buildLandedCost;if(!r)return[3,2];return[4,triggerBuildLandedCost(r)];case 1:o=d.sent();return[2,o];case 2:return[4,handleFetch("/api/zonos-elements/calculate-landed-cost",{body:prepCalculateLandedCost(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:n=d.sent(),i=n.errors,a=n.json;if(i.length||!a){s=((t=i[0])===null||t===void 0?void 0:t.message)==="The user aborted a request.";if(s){throw new Error("The landed cost calculation request was aborted to initiate a new one.")}i.forEach((function(e){console.warn("Error calculating landed cost: ".concat(e.message))}));if(!a){throw new Error("Failed to calculate landed cost")}return[2,a]}return[2,a]}}))}))};var cartCalculateLandedCost=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,c;var l=e.abortController,u=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4,handleFetch("/api/zonos-elements/cart-calculate-landed-cost",{body:prepCartCalculateLandedCost(u),method:"POST",signal:l===null||l===void 0?void 0:l.signal})];case 1:i=e.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."||((r=a[0])===null||r===void 0?void 0:r.message.includes("signal is aborted"))||((o=a[0])===null||o===void 0?void 0:o.message.includes("The operation was aborted"))||((n=a[0])===null||n===void 0?void 0:n.message.includes("Fetch is aborted"));c=d?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(c)}return[2,s]}}))}))};var __rest=undefined&&undefined.__rest||function(e,t){var r={};for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0)r[o]=e[o];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++){if(t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n]))r[o[n]]=e[o[n]]}return r};var calculateLandedCostNormalized=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i;return __generator(this,(function(a){switch(a.label){case 0:t=window.Zonos.cartId;if(!!t)return[3,2];return[4,calculateLandedCost(e)];case 1:r=a.sent();return[2,r];case 2:return[4,cartCalculateLandedCost({abortController:e,cartId:t})];case 3:o=a.sent(),n=o.cartWorkflow,i=__rest(o,["cartWorkflow"]);return[2,Object.assign(Object.assign({},i),{itemCreateWorkflow:n.items})]}}))}))};var trackConversionEvent=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,c;var l=e.checkoutSessionId,u=e.eventName,v=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:o=Date.now();n=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:l,eventCreated:o,eventName:u});i=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);a=getIsTestMode()||getIsStagingMode();if((a||i)&&!window.Zonos.zonosConversionTest){return[2]}s=localizationStore.selectedCountryCode;d=zonosStore.organizationId;if(!l){void sendErrorLog({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(u,'" - No checkout session id found')],metadata:{allLogs:allLogs,checkoutSessionId:l,eventName:u,metadata:v,organizationId:d,trackEventLogs:n}});return[2]}if(!d){void sendErrorLog({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(u,'" - No organization id found')],metadata:{allLogs:allLogs,checkoutSessionId:l,eventName:u,metadata:v,organizationId:d,trackEventLogs:n}})}c={checkoutSessionId:l,countryCode:s,eventCreated:o,eventName:u,metadata:Object.assign(Object.assign({},v),{trackEventLogs:n}),organizationId:d};return[4,handleFetch("/api/zonos-elements/track-conversion-event",{body:c,method:"POST"})];case 1:e.sent();return[2]}}))}))};var getExcludeAddressFieldsObject=function(e){var t=e.address,r=e.invalidAdddressList;if(!t){return}if(!r){return}var o={};if(r.city){o.city=t.city}if(r.line1){o.line1=t.line1}if(r.line2){o.line2=t.line2}if(r.postal_code){o.postal_code=t.postal_code}if(r.state){o.state=t.state}if(r.name){o.name=t.name}return Object.keys(o).length?o:undefined};var buildTranslateRequest=function(e){var t=e.addressInvalidCharactersList,r=e.billingAddressInvalidCharactersList,o=e.stripeAddressEventData,n=e.stripeBillingAddressEventData,i=e.stripeShippingSameAsBilling;var a,s,d,c;var l=!!(o===null||o===void 0?void 0:o.complete);var u=i?l:!!(n===null||n===void 0?void 0:n.complete);if(!l||!u){return null}if(!t&&!r){return null}var v=o.value;var S=(n===null||n===void 0?void 0:n.value)||null;var p=v.firstName||((a=v.name)===null||a===void 0?void 0:a.split(" ")[0]);var f=v.lastName||((s=v.name)===null||s===void 0?void 0:s.split(" ")[1]);var h="".concat(p," ").concat(f);var m=v.firstName||((d=S===null||S===void 0?void 0:S.name)===null||d===void 0?void 0:d.split(" ")[0]);var g=v.lastName||((c=S===null||S===void 0?void 0:S.name)===null||c===void 0?void 0:c.split(" ")[1]);var y=m&&g?"".concat(m," ").concat(g):"";var w=v.address;var C=S===null||S===void 0?void 0:S.address;return{address:getExcludeAddressFieldsObject({address:Object.assign(Object.assign({},w),{name:h}),invalidAdddressList:t}),billingAddress:!i?getExcludeAddressFieldsObject({address:C?Object.assign(Object.assign({},C),{name:y}):null,invalidAdddressList:r}):undefined,destinationCountry:w.country}};var sortServiceLevelOptionsByAmount=function(e){var t=e.sort((function(e,t){return e.amount-t.amount}));return t};var getCheckoutSession=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o;return __generator(this,(function(n){switch(n.label){case 0:if(!storageStore.checkoutSessionId){return[2,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",storageStore.checkoutSessionId);return[4,handleFetch("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:t=n.sent(),r=t.errors,o=t.json;return[2,{errors:r,json:o}]}}))}))};var validateCheckoutSession=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o;return __generator(this,(function(n){switch(n.label){case 0:return[4,getCheckoutSession()];case 1:t=n.sent(),r=t.errors,o=t.json;if(r.length||!o){logError("Failed to retrieve checkout session info before confirming payment ",r);void sendErrorLog({endpoint:"validateCheckoutSession",errors:r.map((function(e){return e.message})),metadata:{allLogs:allLogs}});return[2,{errorMessage:translate("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:false}]}if(!((e=o.checkoutSession.landedCost)===null||e===void 0?void 0:e.id)){logError("Landed cost is not found in the checkout session before confirming payment.");void sendErrorLog({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:allLogs}});return[2,{errorMessage:translate('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 addressRuleStyle=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:zonosStore.appearance.fontSizeInputValue?"".concat(zonosStore.appearance.fontSizeInputValue,"px"):undefined,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:zonosStore.appearance.fontSizeInputLabel?"".concat(zonosStore.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 defaultVariable=function(e){var t=e.borderStyle,r=e.theme;switch(r){case"DARK":return{borderRadius:getBorderRadius({overrideBorderStyle:t}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:getBorderRadius({overrideBorderStyle:t}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var _m=createStore((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:{}}}})),stripeStoreOnChange=_m.onChange,reset$1=_m.reset,stripeStore=_m.state;var getStripeOptions=function(e){var t=e.clientSecret,r=e.overrideBorderRadius,o=e.overridePrimaryColor,n=e.overrideSecondaryColor,i=e.overrideTheme,a=e.paypalEnabled;var s=o||zonosStore.appearance.colorPrimary;var d=n||zonosStore.appearance.colorSecondary;var c=s&&isDarkColor(s)?"night":"flat";var l=i==="DARK"?"night":"flat";var u=a?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},addressRuleStyle({theme:i||"LIGHT"})),theme:i?l:c,variables:Object.assign(Object.assign({},defaultVariable({borderStyle:r,theme:"LIGHT"})),{colorPrimary:d})},clientSecret:t||undefined,customerSessionClientSecret:stripeStore.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],u,true),locale:localizationStore.selectedLocale}};var stripeStoreCleanupDomesticShippingSession=function(){window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")};var stripeStoreSaveDomesticShippingSession=function(e){window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))};var stripeStoreGetDomesticShippingSession=function(){var e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return jsonParse(e)};var initStripeElements=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i;return __generator(this,(function(a){o=stripeStore.clientSecret;if(!stripeStore.stripe){log("Skip. Stripe is not initialized");return[2]}n=getStripeOptions({clientSecret:o,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(n)===JSON.stringify(stripeStore.stripeElementsOptions);if(!stripeStore.stripeElements||!stripeStore.stripeElementsForBillingAddress){stripeStore.stripeElements=(t=stripeStore.stripe)===null||t===void 0?void 0:t.elements(n);stripeStore.stripeElementsOptions=n;log("Stripe elements initialized");stripeStore.stripeElementsForBillingAddress=(r=stripeStore.stripe)===null||r===void 0?void 0:r.elements(n);log("Stripe elements for billing address initialized");return[2]}if(!i){stripeStore.stripeElements.update(n);stripeStore.stripeElementsForBillingAddress.update(n);stripeStore.stripeElementsOptions=n;void stripeStore.stripeElements.fetchUpdates()}log("Stripe elements updated");return[2]}))}))};var stripeStoreReset=function(){sessionStorage.removeItem("zonos--client-secret");reset$1();stripeStore.stripe=window.Zonos.stripe};var checkIsAddressOutdatedForValidation=function(){var e,t,r,o;var n=JSON.stringify((e=stripeStore.stripeAddressUsedWhenValidatingAddress)===null||e===void 0?void 0:e.value)!==JSON.stringify((t=stripeStore.stripeAddressEventData)===null||t===void 0?void 0:t.value);var i=!stripeStore.stripeShippingSameAsBilling&&JSON.stringify((r=stripeStore.stripeBillingAddressEventData)===null||r===void 0?void 0:r.value)!==JSON.stringify((o=stripeStore.stripeBillingAddressUsedWhenValidatingAddress)===null||o===void 0?void 0:o.value);return n||i};var checkIsAddressOutdatedForAsyncAddressUpdate=function(){var e,t,r,o,n,i;var a=JSON.stringify((e=stripeStore.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.value);var s=JSON.stringify((r=stripeStore.stripeAddressUsedWhenAsyncAddressUpdate)===null||r===void 0?void 0:r.value)!==JSON.stringify((o=stripeStore.stripeAddressEventData)===null||o===void 0?void 0:o.value);var d=!stripeStore.stripeShippingSameAsBilling&&JSON.stringify((n=stripeStore.stripeBillingAddressUsedWhenAsyncAddressUpdate)===null||n===void 0?void 0:n.value)!==JSON.stringify((i=stripeStore.stripeBillingAddressEventData)===null||i===void 0?void 0:i.value);var c=stripeStore.taxIdUsedWhenAsyncAddressUpdate!==stripeStore.taxId;var l=stripeStore.companyNameUsedWhenAsyncAddressUpdate!==stripeStore.companyName;return a||s||d||c||l};var buildAddressForPartyCreate=function(e){var t=e.address,r=e.firstName,o=e.lastName,n=e.name,i=e.phone;var a=(n===null||n===void 0?void 0:n.split(" ")[0])||r||"";var s=(n===null||n===void 0?void 0:n.split(" ")[1])||o||"";if(!a||!s){void sendErrorLog({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,firstName:r,lastName:o,name:n}})}if(!i){void sendErrorLog({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,phone:i}})}return{city:t.city,country:t.country,firstName:a,lastName:s,line1:t.line1,line2:t.line2,phone:i||"",postal_code:t.postal_code,state:t.state}};var stripeStoreAsyncAddressUpdate=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d,c,l,u;return __generator(this,(function(v){switch(v.label){case 0:if(!((e=stripeStore.stripeAddressEventData)===null||e===void 0?void 0:e.complete)||!stripeStore.stripeShippingSameAsBilling&&!((t=stripeStore.stripeBillingAddressEventData)===null||t===void 0?void 0:t.complete)||!stripeStore.stripeBillingAddressEventData){return[2,{partiesCreated:false}]}if(!cartStore.landedCostData){return[2,{partiesCreated:false}]}n=(r=cartStore.landedCostData.find(Boolean))===null||r===void 0?void 0:r.landedCost.rootId;if(!n){void sendErrorLog({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId}});return[2,{partiesCreated:false}]}i=checkIsAddressOutdatedForAsyncAddressUpdate();if(!i){return[2,{partiesCreated:false}]}a=buildAddressForPartyCreate({address:stripeStore.stripeAddressEventData.value.address,firstName:stripeStore.stripeAddressEventData.value.firstName,lastName:stripeStore.stripeAddressEventData.value.lastName,name:stripeStore.stripeAddressEventData.value.name,phone:stripeStore.stripeAddressEventData.value.phone});s=stripeStore.stripeShippingSameAsBilling?a:buildAddressForPartyCreate({address:stripeStore.stripeBillingAddressEventData.value.address,firstName:stripeStore.stripeBillingAddressEventData.value.firstName,lastName:stripeStore.stripeBillingAddressEventData.value.lastName,name:stripeStore.stripeBillingAddressEventData.value.name,phone:stripeStore.stripeBillingAddressEventData.value.phone});d=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,handleFetch("/api/zonos-elements/create-parties",{body:{address:a,billingAddress:s,companyName:stripeStore.companyName,email:((o=stripeStore.stripeLinkEventData)===null||o===void 0?void 0:o.value.email)||"",isTest:d,rootId:n,taxId:stripeStore.taxId},method:"POST"})];case 1:c=v.sent(),l=c.errors,u=c.json;if(l.length||!u){logError("Error occurs when creating parties",JSON.stringify(l,null,2));void sendErrorLog({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,errors:l,json:u}});return[2,{partiesCreated:false}]}stripeStore.companyNameUsedWhenAsyncAddressUpdate=stripeStore.companyName;stripeStore.stripeAddressUsedWhenAsyncAddressUpdate=stripeStore.stripeAddressEventData;stripeStore.stripeBillingAddressUsedWhenAsyncAddressUpdate=stripeStore.stripeBillingAddressEventData;stripeStore.taxIdUsedWhenAsyncAddressUpdate=stripeStore.taxId;stripeStore.partyBillingId=u.billToPartyId;stripeStore.partyShippingId=u.shipToPartyId;return[2,{partiesCreated:true}]}}))}))};var buildAddressForLCPrefetch=function(e){return{countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}};var checkIsAddressOutdatedForLCPrefetch=function(){var e,t;var r=JSON.stringify((e=stripeStore.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.value);var o=stripeStore.stripeAddressEventData&&JSON.stringify(buildAddressForLCPrefetch(stripeStore.stripeAddressEventData.value))!==JSON.stringify(stripeStore.stripeAddressUsedWhenFetchingLC);var n=!stripeStore.stripeShippingSameAsBilling&&stripeStore.stripeBillingAddressEventData&&JSON.stringify(buildAddressForLCPrefetch(stripeStore.stripeBillingAddressEventData.value))!==JSON.stringify(stripeStore.stripeBillingAddressUsedWhenFetchingLC);return r||o||n};var isPrefetchInfoOutdated=function(){var e;var t=cartStore.landedCostData&&((e=cartStore.landedCostData.find(Boolean))===null||e===void 0?void 0:e.subtotals.items)!==cartStore.subtotal;var r=checkIsAddressOutdatedForLCPrefetch();log("isPrefetchInfoOutdated","info",{isAddressOutdated:r});return!cartStore.landedCostData&&!stripeStore.isFetchingLandedCost||r||t};var getCountryField=function(e){var t,r;var o=(t=zonosStore.genericSettings)===null||t===void 0?void 0:t.countryFields;var n=(r=zonosStore.genericSettings)===null||r===void 0?void 0:r.stripeCountryFieldLabels;var i=n&&e in n?n[e]:null;var a=o&&e in o?o[e]:null;if(cartStore.addressFormRenderType==="stripe"){return i||a}return a};var isAddressReadyToRequestLandedCost=function(){var e,t,r,o;var n=!!((e=stripeStore.stripeLinkEventData)===null||e===void 0?void 0:e.complete);var i=!!((t=stripeStore.stripeAddressEventData)===null||t===void 0?void 0:t.complete);var a=stripeStore.stripeShippingSameAsBilling?i:!!((r=stripeStore.stripeBillingAddressEventData)===null||r===void 0?void 0:r.complete);var s=((o=stripeStore.stripeAddressEventData)===null||o===void 0?void 0:o.value.address.country)||"US";var d=getCountryField(s);if(i&&a&&n){return true}if(!d||!stripeStore.stripeAddressEventData){return i&&a&&n}var c=stripeStore.stripeAddressEventData.value.address.line1.length>0;var l=stripeStore.stripeAddressEventData.value.firstName&&stripeStore.stripeAddressEventData.value.lastName;var u=!d.stateRequired||d.stateRequired&&stripeStore.stripeAddressEventData.value.address.state.length>0;var v=!d.zipRequired||d.zipRequired&&stripeStore.stripeAddressEventData.value.address.postal_code.length>=3;var S=stripeStore.stripeAddressEventData.value.phone&&stripeStore.stripeAddressEventData.value.phone.length>0;return n&&l&&c&&u&&v&&S};var stripeCalculateLandedCost=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d,c,l;return __generator(this,(function(u){switch(u.label){case 0:t=new AbortController;stripeStore.fetchingLandedCostAbortController=t;cartStoreResetCartItems();return[4,calculateLandedCostNormalized(t)];case 1:r=u.sent(),o=r.checkoutSessionWorkflow,n=r.errors,i=r.itemCreateWorkflow,a=r.landedCostCalculateWorkflow,s=r.partyCreateWorkflow,d=r.shipmentRatingCalculateWorkflow;cartStore.customQuotingError=((e=n===null||n===void 0?void 0:n.find((function(e){var t;return((t=e.extensions)===null||t===void 0?void 0:t.ruleMessageType)==="CUSTOM"})))===null||e===void 0?void 0:e.message)||null;cartStore.shippingData=sortServiceLevelOptionsByAmount((d===null||d===void 0?void 0:d.filter(Boolean))||[]);cartStoreCheckItemRestrictions(i);stripeStore.fetchingLandedCostAbortController=null;cartStore.partiesData=(s===null||s===void 0?void 0:s.filter(Boolean))||[];cartStore.landedCostData=(o===null||o===void 0?void 0:o.map((function(e){var t=a===null||a===void 0?void 0:a.find((function(t){return(t===null||t===void 0?void 0:t.id)===e.landedCostId}));if(!t){return null}return Object.assign(Object.assign({},e),{landedCost:t})})).filter(Boolean))||[];c=storageStore.checkoutSessionId;if(o===null||o===void 0?void 0:o.length){void trackConversionEvent({checkoutSessionId:c,eventName:"checkout_quoteReceived"})}l=cartStore.promoCodeApplied&&!cartStore.landedCostData.find((function(e){var t;return(t=e.landedCost.appliedAdjustments)===null||t===void 0?void 0:t.find((function(e){return e.type==="PROMO_CODE"}))}));cartStore.promoCodeError=l;if(!l){sessionStorage.setItem("zonos--promo-code",cartStore.promoCode)}return[2]}}))}))};var stripeStorePrefetchLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a,s,d,c,l,u,v,S,p;return __generator(this,(function(f){switch(f.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=isPrefetchInfoOutdated();d=isAddressReadyToRequestLandedCost();if(!d){return[2,{isRequestNotReady:true}]}if(s){(t=stripeStore.fetchingLandedCostAbortController)===null||t===void 0?void 0:t.abort();stripeStore.fetchingLandedCostAbortController=null}if(!s&&!a){return[2,{isRequestNotReady:false}]}if(i){stripeStore.isFetchingLandedCost=false;setTimeout((function(){stripeStore.isFetchingLandedCost=true}),300)}else{stripeStore.isFetchingLandedCost=true}if(stripeStore.stripeAddressEventData){stripeStore.stripeAddressUsedWhenFetchingLC={countryCode:stripeStore.stripeAddressEventData.value.address.country,postalCode:stripeStore.stripeAddressEventData.value.address.postal_code,state:stripeStore.stripeAddressEventData.value.address.state}}if(stripeStore.stripeBillingAddressEventData){stripeStore.stripeBillingAddressUsedWhenFetchingLC={countryCode:stripeStore.stripeBillingAddressEventData.value.address.country,postalCode:stripeStore.stripeBillingAddressEventData.value.address.postal_code,state:stripeStore.stripeBillingAddressEventData.value.address.state}}if(stripeStore.stripeLinkEventData){stripeStore.stripeLinkUsedWhenFetchingLC=Object.assign({},stripeStore.stripeLinkEventData)}f.label=1;case 1:f.trys.push([1,3,,7]);cartStoreResetCartItems();return[4,stripeCalculateLandedCost()];case 2:f.sent();c=(r=cartStore.shippingData)===null||r===void 0?void 0:r.find(Boolean);l=(o=cartStore.landedCostData)===null||o===void 0?void 0:o.find((function(e){return e.landedCost.shipmentRating.id===(c===null||c===void 0?void 0:c.id)}));u=!!l?l.subtotals:null;if(u){cartStoreApplySubtotals({method:(l===null||l===void 0?void 0:l.landedCost.method)||"DDP",subtotals:u})}return[3,7];case 3:v=f.sent();cartStore.landedCostData=[];cartStore.shippingData=[];S=["The landed cost calculation request was aborted to initiate a new one."];if(!(v instanceof Error&&v.message&&!S.includes(v.message)))return[3,6];if(!(i<1))return[3,5];return[4,stripeStorePrefetchLandedCost(Object.assign(Object.assign({},e),{retries:(i||0)+1}))];case 4:f.sent();return[2,{isRequestNotReady:false}];case 5:p=(n=stripeStore.stripeAddressEventData)===null||n===void 0?void 0:n.value;void sendErrorLog({endpoint:"Failed to fetch landed cost (".concat(i," retries)"),errors:[v.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:p}});f.label=6;case 6:logError(v);return[3,7];case 7:stripeStore.isFetchingLandedCost=false;return[2,{isRequestNotReady:false}]}}))}))};var stripeStoreApplyPromoCode=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o;return __generator(this,(function(n){switch(n.label){case 0:return[4,stripeStorePrefetchLandedCost({applyingPromocode:true})];case 1:n.sent();if(cartStore.step==="payment"){cartStorePreviousStep()}return[4,stripeStoreAsyncAddressUpdate()];case 2:n.sent();r=(e=cartStore.shippingData)===null||e===void 0?void 0:e.find(Boolean);o=(t=cartStore.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCost.id===(r===null||r===void 0?void 0:r.id)}));if(!r||!o){return[2]}return[4,cartStoreUpdateSelectedShippingOption(r,o.landedCostId)];case 3:n.sent();return[2]}}))}))};var stripeStoreResetPromoCode=function(){cartStore.promoCode="";sessionStorage.removeItem("zonos--promo-code");cartStore.promoCodeError=false;cartStore.promoCodeApplied=false};var stripeStoreRemovePromoCode=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:if(cartStore.step==="payment"){cartStorePreviousStep()}stripeStoreResetPromoCode();return[4,stripeStoreApplyPromoCode()];case 1:e.sent();return[2]}}))}))};var stripeStoreMessageBasedOnStatus=function(e){var t=[];var r=true;switch(e){case"succeeded":{t=[translate("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."),"",translate("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.")];r=false;break}case"requires_capture":case"processing":{t=[translate("Payment processing. We'll update you when payment is received.")];r=false;break}case"requires_payment_method":{t=[translate("Payment failed. Please try another payment method.")];break}case"requires_action":{r=false;t=[translate("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}default:{t=[translate("Something went wrong.")];break}}return{isError:r,messages:t}};var stripeStoreHandleInventoryCheck=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d,s;return __generator(this,(function(c){switch(c.label){case 0:r=zonosStore.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,handleFetch("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:n=c.sent(),i=n.errors,a=n.json;if(i.length||!a){logError("Error occurs when handling inventory refund","warn",JSON.stringify(i));return[2,null]}if(!a.available||a.status===204){return[2,translate("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")]}if(a.available||a.status===200){stripeStore.shouldInventoryRefund=true;return[2,null]}return[2,null];case 2:if(typeof r!=="function"){return[2,null]}c.label=3;case 3:c.trys.push([3,5,,6]);return[4,r({items:cartStore.items})];case 4:s=c.sent();return[2,s];case 5:d=c.sent();s=d instanceof Error?d.message:"Unknown error";void sendErrorLog({endpoint:"onInventoryCheck",errors:["cartId: ".concat(window.Zonos.cartId," - ").concat(s)],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:cartStore.items}});throw d;case 6:return[2]}}))}))};var stripeStoreHandleInventoryRefund=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r;return __generator(this,(function(o){switch(o.label){case 0:r=!!((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||!r){return[2]}return[4,handleFetch("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:o.sent();return[2]}}))}))};var stripeStoreRetrievePayment=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,c;var l=e.clientSecret,u=e.storybookForceStatus;return __generator(this,(function(e){switch(e.label){case 0:if(u){t=stripeStoreMessageBasedOnStatus(u),r=t.isError,o=t.messages;return[2,{error:r,messages:o}]}n=l||stripeStore.clientSecret;if(!stripeStore.stripe||!n){logError("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[translate("Something went wrong.")]}]}return[4,stripeStore.stripe.retrievePaymentIntent(n)];case 1:i=e.sent().paymentIntent;a=i===null||i===void 0?void 0:i.status;s=stripeStoreMessageBasedOnStatus(a),d=s.isError,c=s.messages;return[2,{error:d,messages:c,paymentIntentId:i===null||i===void 0?void 0:i.id,paymentMethod:i===null||i===void 0?void 0:i.payment_method,status:a}]}}))}))};var stripeStoreConfirmPayment=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d,c,l,u;return __generator(this,(function(v){switch(v.label){case 0:r=!!((e=stripeStore.stripePaymentEventData)===null||e===void 0?void 0:e.complete);o=stripeStore.stripeElements;n=stripeStore.stripe;i=stripeStore.clientSecret;stripeStore.customErrorMessage=null;if(!((t=cartStore.selectedLandedCost)===null||t===void 0?void 0:t.landedCost.id)){throw new Error("Attempted to confirm the payment when no landed cost is found in store")}return[4,validateCheckoutSession()];case 1:a=v.sent();if(!a.valid){stripeStore.customErrorMessage=a.errorMessage;throw new Error(a.errorMessage)}s=storageStore.checkoutSessionId;if(!(n&&o&&r&&i&&s))return[3,3];d=new URL(window.location.href);d.searchParams.set("payment_intent_client_secret",i);d.searchParams.set("zonosCheckoutSessionId",s);void trackConversionEvent({checkoutSessionId:s,eventName:"checkout_paymentInfoCompleted"});return[4,n.confirmPayment({confirmParams:{return_url:d.toString()},elements:o,redirect:"if_required"})];case 2:c=v.sent(),l=c.error,u=c.paymentIntent;log("Payment intent confirmed","info",{error:l,paymentIntent:u});if((u===null||u===void 0?void 0:u.status)==="requires_action"){throw new Error(translate("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."))}if(l){if(l.type==="card_error"||l.type==="validation_error"){throw new Error(l.message)}if(l.type==="invalid_request_error"){if(l.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}if(u.status==="requires_payment_method"){throw new Error(translate("Payment failed. Please try another payment method."))}v.label=3;case 3:return[2]}}))}))};var getCheckoutSessionBody=function(){var e;var t=cartStore.items.reduce((function(e,t){return e+t.amount*t.quantity}),0);var r=storageStore.enabledVariantTestKeys||[];var o={adjustmentsAmount:cartStore.adjustments.reduce((function(e,t){return e+t.amount}),0),cartId:window.Zonos.cartId,currency:((e=cartStore.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",customerAuthenticationToken:cartStore.customerAuthenticationToken||undefined,itemsAmount:t,metadata:[{key:"language",value:localizationStore.selectedLocale}],presentmentCountryCode:localizationStore.selectedCountryCode,skipPaymentIntent:stripeStore.skipPaymentIntent,varianceTestInput:r};return o};var stripeStoreGetPaymentIntent=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n;return __generator(this,(function(i){switch(i.label){case 0:if(!storageStore.checkoutSessionId){void sendErrorLog({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId}});cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[2]}return[4,handleFetch("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:storageStore.checkoutSessionId},method:"POST"})];case 1:t=i.sent(),r=t.errors,o=t.json;n=(e=o===null||o===void 0?void 0:o.checkoutSessionPaymentIntentCreate)===null||e===void 0?void 0:e.clientSecret;if(r.length||!n){logError("Error occurs when getting payment intent",JSON.stringify(r,null,2));void sendErrorLog({endpoint:"Error creating payment intent",errors:r.map((function(e){return e.message})),metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,clientSecret:n}});cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[2]}cartStoreSetCheckoutSession(o.checkoutSessionPaymentIntentCreate);return[2]}}))}))};var stripeStoreInitCheckoutSession=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s;return __generator(this,(function(d){switch(d.label){case 0:if(!localizationStore.targetCurrency){logError("Failed to create checkout session - missing localizationStore.targetCurrency");return[2,false]}stripeStore.isFetchingSession=true;r=getCheckoutSessionBody();log("Checkout session body","info",r);return[4,handleFetch("/api/zonos-elements/create-checkout-session",{body:r,method:"POST"})];case 1:o=d.sent(),n=o.errors,i=o.json;stripeStore.isFetchingSession=false;if(n.length||!i){a=(e=n.find((function(e){return e.message})))===null||e===void 0?void 0:e.message;if(Array.isArray(a)&&a.some((function(e){return e.message==="Cart is expired."}))){throw new Error("Cart is expired.")}logError("Error occurred when creating checkout session",JSON.stringify(n,null,2));return[2,false]}s=i.checkoutSessionCreate;cartStoreSetCheckoutSession(s);cartStoreApplySubtotals({method:((t=s.landedCost)===null||t===void 0?void 0:t.method)||"DDP",subtotals:s.subtotals});log("Exchange rate updated for cart items (checkout session create)","info",cartStore.exchangeRate);log("done-init-checkout-session");return[2,true]}}))}))};var stripeStoreUpdateCheckoutSessionBaseCurrency=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r;return __generator(this,(function(o){switch(o.label){case 0:e=storageStore.checkoutSessionId;if(!e){logError("Failed to update checkout session base currency");return[2,false]}if(zonosStore.checkoutSettings.allowedSettlementCurrencies==="LOCAL"){log('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency');return[2,true]}return[4,handleFetch("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:stripeStore.checkoutSettlementCurrency},method:"POST"})];case 1:t=o.sent().json;r=t===null||t===void 0?void 0:t.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;if(!t||r!==stripeStore.checkoutSettlementCurrency){logError("Failed to update checkout session base currency");return[2,false]}log('Updated checkout session to settlement currency "'.concat(r,'".'));return[2,true]}}))}))};var stripeStoreUpdateCheckoutSession=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n;var i=e.adjustmentsAmount,a=e.cartId,s=e.currency,d=e.id,c=e.itemsAmount,l=e.landedCostId,u=e.presentmentCountryCode;return __generator(this,(function(e){switch(e.label){case 0:t=storageStore.enabledVariantTestKeys||[];return[4,handleFetch("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:i,billToPartyId:stripeStore.partyBillingId,cartId:a,currency:s,customerAuthenticationToken:cartStore.customerAuthenticationToken||undefined,id:d,itemsAmount:c,landedCostId:l,metadata:[{key:"language",value:localizationStore.selectedLocale}],presentmentCountryCode:u,shipToPartyId:stripeStore.partyShippingId,skipPaymentIntent:stripeStore.skipPaymentIntent,varianceTestInput:t},method:"POST"})];case 1:r=e.sent(),o=r.errors,n=r.json;if(o.length||!n){logError("Error occurs when updating checkout session",JSON.stringify(o,null,2));return[2,{errors:o,json:n}]}return[2,{errors:[],json:n}]}}))}))};var buildTranslatedAddress=function(e){var t,r,o,n,i,a;var s=e.currentAddress,d=e.translatedAddressResult;var c={};if(!d){return c}var l=d.city,u=d.line1,v=d.line2,S=d.name,p=d.postal_code,f=d.state;if(s.city&&l){c.city=(t={},t[s.city]=l,t)}if(s.line1&&u){c.line1=(r={},r[s.line1]=u,r)}if(s.line2&&v){c.line2=(o={},o[s.line2]=v,o)}if(s.postal_code&&p){c.postal_code=(n={},n[s.postal_code]=p,n)}if(s.state&&f){c.state=(i={},i[s.state]=f,i)}if(s.name&&S){c.name=(a={},a[s.name]=S,a)}return c};var stripeStoreTranslateAddressToLatin=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,c,l,u;var v=e.addressInvalidCharactersList,S=e.billingAddressInvalidCharactersList;return __generator(this,(function(e){switch(e.label){case 0:i=buildTranslateRequest({addressInvalidCharactersList:v,billingAddressInvalidCharactersList:S,stripeAddressEventData:stripeStore.stripeAddressEventData,stripeBillingAddressEventData:stripeStore.stripeBillingAddressEventData,stripeShippingSameAsBilling:stripeStore.stripeShippingSameAsBilling});if(!i){stripeStore.translatedAddress={address:{},billingAddress:{}};return[2]}a=checkIsAddressOutdatedForValidation();if(!a){return[2]}return[4,handleFetch("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),d=s.errors,c=s.json;if(d.length||!c){logError("Error occurs when translating address to latin",JSON.stringify(d,null,2));stripeStore.translatedAddress={address:{},billingAddress:{}};return[2]}stripeStore.stripeAddressUsedWhenValidatingAddress=stripeStore.stripeAddressEventData;stripeStore.stripeBillingAddressUsedWhenValidatingAddress=stripeStore.stripeBillingAddressEventData;l=(t=stripeStore.stripeAddressEventData)===null||t===void 0?void 0:t.value.address;u=(r=stripeStore.stripeBillingAddressEventData)===null||r===void 0?void 0:r.value.address;stripeStore.translatedAddress={address:l?buildTranslatedAddress({currentAddress:Object.assign(Object.assign({},l),{name:(o=stripeStore.stripeAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:c.address||null}):{},billingAddress:!stripeStore.stripeShippingSameAsBilling?buildTranslatedAddress({currentAddress:Object.assign(Object.assign({},u),{name:(n=stripeStore.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value.name}),translatedAddressResult:c.billingAddress||null}):{}};return[2]}}))}))};stripeStoreOnChange("clientSecret",(function(e){if(e&&stripeStore.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var _o=createStore((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:getIsStagingMode(),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}})),cartStoreOnChange=_o.onChange,reset=_o.reset,cartStore=_o.state;var getTransitUnit=function(e){switch(e){case"DAYS":return translate("days");case"WEEKS":return translate("weeks");case"BUSINESS_DAYS":default:return translate("business days")}};var cartStoreGetShippingTransitInfo=function(e){var t;var r=(t=e.shippingProfile)===null||t===void 0?void 0:t.transitTime;if(!(r===null||r===void 0?void 0:r.min)||!(r===null||r===void 0?void 0:r.max)||!(r===null||r===void 0?void 0:r.type)){return null}return{maxTransit:r.max,minTransit:r.min,unit:getTransitUnit(r.type)}};var getMatchItem=function(e){var t=e.item1,r=e.item2;if(!t||!r){return false}return r.sku&&t.sku&&t.sku===r.sku||r.description&&t.description&&t.description===r.description||t.name&&r.name&&t.name===r.name};var cartStoreCheckItemRestrictions=function(e){log("Checking item restrictions");var t=e.map((function(e){if(!e.restriction){return null}var t=e.restriction;var r=cartStore.items.find((function(t){return getMatchItem({item1:t,item2:e})}));return Object.assign(Object.assign({matchedItem:r},e),{restriction:t})})).filter(Boolean);cartStore.restrictedItems=t;cartStore.items=cartStore.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:!!t.find((function(t){return getMatchItem({item1:t,item2:e})}))})}));return{cartItems:cartStore.items,restrictedItems:t}};var cartStoreReset=function(){storageStore.checkoutSessionId=null;reset()};var cartStoreUpdateToErrorState=function(e){var t=e.messages,r=e.title;cartStoreReset();stripeStoreReset();cartStore.step="error";cartStore.error={messages:t,title:r}};var cartStoreApplySubtotals=function(e){var t=e.dutiesTaxesFeesEstimate,r=e.method,o=e.subtotals;cartStore.exchangeRate=o.exchangeRate;cartStore.adjustmentTotal=o.adjustments;cartStore.dutiesTaxesFees=r==="DAP"?null:o.landedCostTotal;cartStore.subtotal=o.items;cartStore.total=o.total;cartStore.currency=o.presentmentCurrencyCode;cartStore.dutiesTaxesFeesEstimate=t||null};var cartStoreHasOneEligibleItem=function(){var e=cartStore.items.filter((function(e){return e.amount>0}));return!!e.find((function(e){return!e.isRestricted}))};var cartStoreSetCheckoutSession=function(e){var t,r,o,n,i;stripeStore.clientSecret=e.clientSecret;stripeStore.stripeCustomerSessionClientSecret=e.customerSessionClientSecret;stripeStore.customerProfile=e.customerProfile;cartStore.checkoutSession=e;if(!e.id){void sendErrorLog({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:allLogs,checkoutSession:e}})}if(e.id){storageStore.checkoutSessionId=e.id}var a=filterValidTests(e.varianceTestResults||[]);storageStoreSetEnabledVariantTestKeys(a);var s=((o=(r=(t=cartStore.checkoutSession)===null||t===void 0?void 0:t.metadata)===null||r===void 0?void 0:r.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||o===void 0?void 0:o.value)||((i=(n=window.Zonos.cartData)===null||n===void 0?void 0:n.metadata.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||i===void 0?void 0:i.value)||null;if(s){log("Found externalConfirmationPageURL: ".concat(s));cartStore.externalConfirmationPageURL=s}};var cartStoreReCalculateTotal=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a;var s=e.adjustmentsAmount,d=e.cartId,c=e.currency,l=e.dutiesTaxesFeesEstimate,u=e.itemsAmount,v=e.landedCostId,S=e.shouldInitSessionOnFailure;return __generator(this,(function(e){switch(e.label){case 0:if(v&&cartStore.selectedLandedCost){r=cartStore.selectedLandedCost.subtotals;cartStoreApplySubtotals({dutiesTaxesFeesEstimate:l,method:cartStore.landedCostMethod,subtotals:r});log("Exchange rate updated for cart items (landed cost subtotal)","info",cartStore.exchangeRate)}if(!storageStore.checkoutSessionId){log("Could not update cart total without checkout session id","info");return[2,false]}return[4,stripeStoreUpdateCheckoutSession({adjustmentsAmount:s,billToPartyId:stripeStore.partyBillingId,cartId:d,currency:c,id:storageStore.checkoutSessionId,itemsAmount:u,landedCostId:v,presentmentCountryCode:localizationStore.selectedCountryCode,shipToPartyId:stripeStore.partyShippingId,varianceTestInput:storageStore.enabledVariantTestKeys||[]})];case 1:o=e.sent(),n=o.errors,i=o.json;if(!(n.length>0||!i))return[3,4];logError("Error occurs when updating checkout session.");if(!S)return[3,3];log("Initiating checkout session on failure","info");return[4,stripeStoreInitCheckoutSession()];case 2:a=e.sent();log("stripeStoreInitCheckoutSession: ".concat(a));if(!a){cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[2,false]}return[2,true];case 3:return[2,false];case 4:if(!v){cartStoreApplySubtotals({method:((t=i.checkoutSessionUpdate.landedCost)===null||t===void 0?void 0:t.method)||"DDP",subtotals:i.checkoutSessionUpdate.subtotals});log("Exchange rate updated for cart items (checkout session update)","info",cartStore.exchangeRate)}cartStoreSetCheckoutSession(i.checkoutSessionUpdate);return[2,true]}}))}))};var cartStoreGetMethod=function(e){if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method};var cartStoreUpdateSelectedShippingOption=function(e,t){return __awaiter(void 0,void 0,void 0,(function(){var r,o,n,i,a,s,d,c,l,u,v,S,p,f,h,m,g,y,w,C,b,A,O,_;return __generator(this,(function(k){switch(k.label){case 0:cartStore.selectedShippingOption=e;S=cartStoreGetShippingTransitInfo(cartStore.selectedShippingOption);if(S){p=S.maxTransit,f=S.minTransit,h=S.unit;cartStore.selectedShippingOptionTransitTime="".concat(f,"-").concat(p," ").concat(h)}else{cartStore.selectedShippingOptionTransitTime=""}m=(r=cartStore.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCostId===t}));cartStore.selectedLandedCost=m||null;if(!m){return[2,false]}g=((o=m.landedCost.amountSubtotals)===null||o===void 0?void 0:o.landedCostTotal)||0;y=m.subtotals.exchangeRate.rate;w=g*y;if(w){log("DAP quote, using estimate: ".concat(w),"info")}cartStore.landedCostMethod=cartStoreGetMethod(m.landedCost);cartStore.shipping=m.subtotals.shipping;C=((n=m===null||m===void 0?void 0:m.landedCost)===null||n===void 0?void 0:n.landedCostGuaranteeCode)==="ZONOS";b=!!((a=(i=m===null||m===void 0?void 0:m.landedCost)===null||i===void 0?void 0:i.deMinimis)===null||a===void 0?void 0:a.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));cartStore.isSelectedShippingAboveDeminimis=b;cartStore.isSelectedShippingGuarantee=C;return[4,cartStoreReCalculateTotal({adjustmentsAmount:cartStore.adjustmentTotal,billToPartyId:stripeStore.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:w,landedCostId:(s=m.landedCost)===null||s===void 0?void 0:s.id,shipToPartyId:stripeStore.partyShippingId,varianceTestInput:storageStore.enabledVariantTestKeys||[]})];case 1:A=k.sent();O=(d=cartStore.items.find(Boolean))===null||d===void 0?void 0:d.currencyCode;_=((c=stripeStore.stripeAddressEventData)===null||c===void 0?void 0:c.value.address.country)||"US";stripeStore.shouldRenderPayInUsdButton=O==="USD"&&zonosStore.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((l=cartStore.checkoutSession)===null||l===void 0?void 0:l.subtotals.presentmentCurrencyCode)!=="USD"&&!!((v=(u=zonosStore.genericSettings)===null||u===void 0?void 0:u.usdSettlementCountryEnabled)===null||v===void 0?void 0:v.includes(_));return[2,A]}}))}))};var cartStoreStartCheckoutInterval=function(e){var t=e.isPreview,r=e.sessionTimeout;if(t){return}var o=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout");var n=o&&!isNaN(parseInt(o,10))?parseInt(o,10):r;log("==START CHECKOUT TIMEOUT - ".concat(n,"=="));cartStore.checkoutTimeoutInterval=setTimeout((function(){cartStore.checkoutSessionTimeoutShow=true}),n)};var cartStoreClearCheckoutInterval=function(){if(cartStore.checkoutTimeoutInterval){clearTimeout(cartStore.checkoutTimeoutInterval);cartStore.checkoutTimeoutInterval=null}};var getCartItemToUse=function(e){return e.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}))};var cartStoreResetCartItems=function(){cartStore.items=cartStore.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));cartStore.restrictedItems=[]};var cartStoreUpdateItems=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n;var i=e.adjustments,a=e.cartItems;return __generator(this,(function(e){switch(e.label){case 0:cartStore.adjustments=i;cartStore.items=getCartItemToUse(a);r=(t=a.find(Boolean))===null||t===void 0?void 0:t.currencyCode;o=a.reduce((function(e,t){return e+t.amount*t.quantity}),0);n=i.reduce((function(e,t){return e+t.amount}),0);if(!r||!o){return[2]}cartStore.currency=r;stripeStore.isFetchingSession=true;return[4,cartStoreReCalculateTotal({adjustmentsAmount:n,billToPartyId:stripeStore.partyBillingId,cartId:window.Zonos.cartId,currency:r,dutiesTaxesFeesEstimate:0,itemsAmount:o,shipToPartyId:stripeStore.partyShippingId,shouldInitSessionOnFailure:true,varianceTestInput:storageStore.enabledVariantTestKeys||[]})];case 1:e.sent();stripeStore.isFetchingSession=false;return[2]}}))}))};var cartStoreResetSelectedShippingOption=function(){cartStore.selectedShippingOption=null;cartStore.isSelectedShippingAboveDeminimis=false;cartStore.isSelectedShippingGuarantee=false;cartStore.selectedShippingOptionTransitTime="";cartStore.dutiesTaxesFees=0;cartStore.dutiesTaxesFeesEstimate=0;cartStore.shipping=0;cartStore.total=cartStore.subtotal};var cartStorePreviousStep=function(){if(cartStore.step==="shipping"){cartStore.step="customer-info";cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{"customer-info":Object.assign(Object.assign({},cartStore.tabItems.shipping),{isDone:false})})}else if(cartStore.step==="payment"){cartStore.step="shipping";cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{shipping:Object.assign(Object.assign({},cartStore.tabItems.shipping),{isDone:false})})}else if(cartStore.step==="finish"){cartStore.step="payment";cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{payment:Object.assign(Object.assign({},cartStore.tabItems.payment),{isDone:false})})}};var cartStoreNextStep=function(){if(cartStore.step==="customer-info"){cartStore.step="shipping";cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{"customer-info":Object.assign(Object.assign({},cartStore.tabItems["customer-info"]),{isDone:true})})}else if(cartStore.step==="shipping"){cartStore.step="payment";cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{shipping:Object.assign(Object.assign({},cartStore.tabItems.shipping),{isDone:true})})}else if(cartStore.step==="payment"){cartStore.step="finish"}};var cartStoreResetTabItems=function(){cartStore.step="customer-info";cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{"customer-info":Object.assign(Object.assign({},cartStore.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},cartStore.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},cartStore.tabItems.shipping),{isDone:false})});cartStoreResetSelectedShippingOption()};export{cartStoreHasOneEligibleItem as A,stripeStoreApplyPromoCode as B,stripeStoreRemovePromoCode as C,stripeStoreResetPromoCode as D,stripeStoreMessageBasedOnStatus as E,stripeStoreTranslateAddressToLatin as F,cartStoreOnChange as G,stripeStoreAsyncAddressUpdate as H,cartStoreUpdateSelectedShippingOption as I,cartStoreGetShippingTransitInfo as J,sortServiceLevelOptionsByAmount as K,cartStoreGetMethod as L,stripeStoreCleanupDomesticShippingSession as a,stripeStoreSaveDomesticShippingSession as b,stripeStore as c,stripeStoreRetrievePayment as d,cartStore as e,cartStoreUpdateItems as f,cartStoreReset as g,cartStoreResetTabItems as h,initStripeElements as i,cartStoreClearCheckoutInterval as j,stripeStoreInitCheckoutSession as k,stripeStoreGetPaymentIntent as l,cartStoreStartCheckoutInterval as m,getCheckoutSessionBody as n,cartStoreUpdateToErrorState as o,cartStoreSetCheckoutSession as p,stripeStorePrefetchLandedCost as q,cartStoreNextStep as r,stripeStoreGetDomesticShippingSession as s,trackConversionEvent as t,stripeStoreUpdateCheckoutSessionBaseCurrency as u,stripeStoreHandleInventoryCheck as v,stripeStoreConfirmPayment as w,stripeStoreHandleInventoryRefund as x,stripeStoreReset as y,validateCheckoutSession as z};
@@ -1 +0,0 @@
1
- import{r as o,h as s,H as t,a as i}from"./p-b30c2ad9.js";import{l as a}from"./p-749a0fc6.js";import{f as e}from"./p-7ce093aa.js";import{c as n}from"./p-b4b7f705.js";import"./p-2eec2d7c.js";import"./p-04a01cb1.js";const h=class{constructor(s){o(this,s),this.countryCode=a.selectedCountryCode}render(){if(!this.el.shadowRoot||!this.countryCode)return null;const o=`https://zonos-store-assets.s3.amazonaws.com/images/elements-flags/${this.countryCode}.svg`,i=e();return s(t,{class:"zonos--elements",style:this.size?{"--zonos--font-family":i,height:`${this.size}px`,width:`${this.size}px`}:{"--zonos--font-family":i}},s("div",{class:n(["flag-container"])},s("div",{class:"flag-icon",style:{backgroundImage:`url(${o})`}})))}get el(){return i(this)}};h.style=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{display:-ms-inline-flexbox;display:inline-flex}:host .flag-container{position:relative;overflow:hidden;width:100%;height:100%}:host .flag-icon{position:absolute;top:0;left:0;width:100%;height:100%;background-position:center;background-repeat:no-repeat;background-size:cover}";export{h as zonos_country_flag}
@@ -1 +0,0 @@
1
- import{r as e,c as t,h as o,H as i}from"./p-b30c2ad9.js";import{c as n}from"./p-3b1ef4b2.js";import{i as s,e as r,s as c,a as l}from"./p-749a0fc6.js";import{z as a,e as d,f as h}from"./p-7ce093aa.js";import{g as u,i as p,a as f}from"./p-e7b0c156.js";import{h as m,b as v,l as g}from"./p-2eec2d7c.js";import"./p-56e0ed65.js";import"./p-2b9c124d.js";import"./p-04a01cb1.js";const w=e=>{const t=document.querySelector(e);if(!document.querySelector("zonos-hello")&&t){const e=document.createElement("zonos-hello");return t.appendChild(e),!0}return!1},y=e=>{switch(e){case"BOTTOM_RIGHT":default:return"bottom-right";case"BOTTOM_LEFT":return"bottom-left";case"TOP_LEFT":return"top-left";case"TOP_RIGHT":return"top-right"}},S=({position:e="bottom-right"})=>{const t=".zonos--hello-mobile-wrapper";if(document.querySelector(t))return t;const o=document.createElement("div");return o.className="zonos--hello-mobile-wrapper",o.style.position="fixed","top-right"===e&&(o.style.top="72px",o.style.right="24px"),"top-left"===e&&(o.style.top="72px",o.style.left="24px"),"bottom-right"===e&&(o.style.bottom="72px",o.style.right="24px"),"bottom-left"===e&&(o.style.bottom="72px",o.style.left="24px"),o.style.zIndex="2147483647",document.body.appendChild(o),t},b=async e=>{if(window.Zonos.isLegacyCheckout)return void g("Hello is disabled when isLegacyCheckout","info");const{anchorElementSelector:t}=e;let o=t;if(!e.anchorElementSelector&&e.desktopLocation){const e=S({position:"bottom-right"});o=e}if(o&&s(o)){if(g("Hello init complete"),!w(o)){const t=new MutationObserver((()=>{w(o)&&t.disconnect()}));t.observe(document.body,{childList:!0,subtree:!0}),setTimeout((()=>{w(o)}),1e3),setTimeout((()=>{if(e.notFoundElementFallback){g(`Hello anchor selector ${e.anchorElementSelector} not found after 3 seconds, falling back to 'notFoundElementFallback': ${e.notFoundElementFallback}`,"info");const t=S({position:y(e.notFoundElementFallback)});w(t)}}),3e3)}}else v(`Selector anchorElementSelector "${e.anchorElementSelector}" is not a valid selector.`)};class z{constructor(e,t){this.targetId=e,this.allowedEvents=t,this.listeners=new Map,this.handleMessage=e=>{var t,o,i;const n=e.data,s=(null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||(null===(i=null===(o=this.iframe)||void 0===o?void 0:o.contentDocument)||void 0===i?void 0:i.defaultView);if(e.source!==s)return;if(!this.isValidMessage(n))return;const r=this.listeners.get(n.type);null==r||r.forEach((e=>{try{e(n.payload)}catch(e){v("Error in event listener:",e)}}))},this.initializeEventListeners(),this.iframe=document.getElementById(this.targetId)}initializeEventListeners(){window.addEventListener("message",this.handleMessage)}isValidMessage(e){if(!e||"object"!=typeof e)return!1;const t=e;return t.id===this.targetId&&"string"==typeof t.type&&this.allowedEvents.includes(t.type)&&void 0!==t.payload}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),g(`[CheckoutAddressService] listening to ${e}`,"info");const o=t,i=this.listeners.get(e);return i&&i.add(o),()=>{const t=this.listeners.get(e);t&&t.delete(o)}}destroy(){window.removeEventListener("message",this.handleMessage),this.listeners.clear()}}class I extends z{constructor(){g("=== [Google Places Service] Initializing","info"),super(p.GOOGLE_PLACES,["fetchAutocompleteSuggestions","initializeGooglePlacesService","placeSelected","onFetchAutocompleteSuggestions","onInitializeGooglePlacesService","onPlaceSelected"])}sendMessage(e,t){var o;if(!(null===(o=this.iframe)||void 0===o?void 0:o.contentWindow))return;const i={id:this.targetId,logType:window.Zonos.iframeLogType,payload:t,type:e};g(`GooglePlacesService] parent --\x3e ${e}`,"info",t),this.iframe.contentWindow.postMessage(i,"*")}initialize(){this.sendMessage("initializeGooglePlacesService",{})}fetchSuggestions({country:e,query:t,type:o}){e&&this.sendMessage("fetchAutocompleteSuggestions",{request:{includedRegionCodes:[e],input:t},type:o})}selectPlace({placeId:e,type:t}){this.sendMessage("placeSelected",{placeId:e,type:t})}}class j{constructor(){this.googlePlaceInitialized=!1,g("=== [CheckoutAddressService] Initializing","info"),this.googlePlaces=new I,this.googlePlaces.on("onInitializeGooglePlacesService",(()=>{g("=== [CheckoutAddressService] parent <-- onInitializeGooglePlacesService","info"),this.googlePlaceInitialized=!0})),this.initialize()}initialize(){this.googlePlaces.initialize()}onInitializeGooglePlacesService(e){return this.googlePlaces.on("onInitializeGooglePlacesService",(()=>{g("[CheckoutAddressService] parent <-- onInitializeGooglePlacesService"),e()}))}isGooglePlaceInitialized(){return this.googlePlaceInitialized}onAddressSuggestions(e){return this.suggestionsCallback=e,this.googlePlaces.on("onFetchAutocompleteSuggestions",((...t)=>{g(`[CheckoutAddressService] parent <-- onFetchAutocompleteSuggestions ${t[0].type}`,"info",...t),e(...t)}))}onAddressSelected(e){return this.placeSelectedCallback=e,this.googlePlaces.on("onPlaceSelected",((...t)=>{g(`[CheckoutAddressService] parent <-- onPlaceSelected ${t[0].type}`,"info",...t),e(...t)}))}getAddressSuggestions({country:e,query:t,type:o}){this.googlePlaceInitialized&&this.googlePlaces.fetchSuggestions({country:e,query:t,type:o})}selectAddress({placeId:e,type:t}){this.googlePlaces.selectPlace({placeId:e,type:t})}destroy(){this.googlePlaces.destroy(),this.suggestionsCallback&&(this.suggestionsCallback=void 0),this.placeSelectedCallback&&(this.placeSelectedCallback=void 0)}}const k=class{constructor(o){e(this,o),this.paypalInitEvent=t(this,"paypalInitEvent",7),this.stripeInitEvent=t(this,"stripeInitEvent",7)}async initCheckoutElement(e){var t;e?(n.stripe=e,((t=a.checkoutSettings).placeOrderButtonSelector||t.alwaysTriggerInternationalCheckoutSelector||window.Zonos.cartData)&&(!t.placeOrderButtonSelector||s(t.placeOrderButtonSelector)?!t.alwaysTriggerInternationalCheckoutSelector||s(t.alwaysTriggerInternationalCheckoutSelector)?(()=>{if(!document.querySelector("zonos-checkout")){const e=document.createElement("zonos-checkout");document.body.appendChild(e)}})():v(`Selector alwaysTriggerInternationalCheckoutSelector "${t.alwaysTriggerInternationalCheckoutSelector}" is not a valid selector`):v(`Selector checkoutButtonAnchor "${t.placeOrderButtonSelector}" is not a valid selector`)),g("init checkout element")):g("Stripe is not loaded yet - cannot init checkout element","warn")}initZonosNotification(){if(document.querySelector("zonos-notification"))return;const e=document.createElement("zonos-notification");document.body.appendChild(e)}async setupGoogleFont(e){var t,o;const i=e||h();if("Inter"===i){if(!e)return;g("[FONT] Just applied Inter , but no need to inject since we already inject Inter on start","warn"),a.appearance=Object.assign(Object.assign({},a.appearance),{fontFamily:e})}const n=new URLSearchParams;n.set("family",i);const{errors:s,json:r}=await m(`/api/zonos-elements/get-font-detail?${n.toString()}`);if(s.length>0)return g(`Failed to load font ${i}`,"warn"),void(a.appearance=Object.assign(Object.assign({},a.appearance),{fontFamily:"Inter"}));const c=null==r?void 0:r.fontUrl;c&&(null===(o=(t=window.Zonos).injectSupportGoogleFont)||void 0===o||o.call(t,c)),e&&(g(`[FONT] ${e} font override applied`),a.appearance=Object.assign(Object.assign({},a.appearance),{fontFamily:e}))}handleLocationChange(){b(a.helloSettings)}initHistoryListener(){const e=history.pushState;history.pushState=function(){return window.dispatchEvent(new window.Event("pushstate")),window.dispatchEvent(new window.Event("locationchange")),e.apply(this,arguments)};const t=history.replaceState;history.replaceState=function(){return window.dispatchEvent(new window.Event("replacestate")),window.dispatchEvent(new window.Event("locationchange")),t.apply(this,arguments)}}injectCustomHTML(e){if(!e)return;if(!window.Zonos.isLegacyCheckout)return void g("=== Skip injecting custom HTML for hosted checkout","info");g("=== Injecting custom HTML for hosted checkout");const t=document.createElement("template");t.innerHTML=e,t.content.querySelectorAll("script").forEach((e=>{const t=document.createElement("script");e.src?(t.src=e.src,t.async=e.async):t.textContent=e.innerHTML,document.body.appendChild(t)}))}async initGooglePlacesService(e){const t=null==e?void 0:e.genericSettings;if(!t)return;const o=t.signedTokenGooglePlaces;o&&f({id:p.GOOGLE_PLACES,onload:()=>{a.checkoutAddressService=new j},src:`https://route.elements.zonos.com/iframe/google-maps?signedToken=${o}`})}async componentWillLoad(){this.initHistoryListener(),a.zonosApiKey=this.zonosApiKey,(async()=>{var e,t,o,i,n,s;const{errors:c,json:l,zonosMode:h}=await(async()=>{if(window.Zonos.cartSettings)return{errors:[],json:window.Zonos.cartSettings,zonosMode:window.Zonos.zonosMode};const e=u(),t=new URLSearchParams;e.overrideShouldEnabledCustomAddress&&t.set("overrideShouldEnabledCustomAddress",e.overrideShouldEnabledCustomAddress);const{errors:o,json:i,zonosMode:n}=await m(`/api/zonos-elements/zonos-settings?${t.toString()}`);return o.length?(v("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings"),{errors:o,json:null,zonosMode:n}):{errors:[],json:i,zonosMode:n}})();if("403"===(null===(t=null===(e=c[0])||void 0===e?void 0:e.type)||void 0===t?void 0:t.toString()))return void g("Failed to load zonos settings. This domain may not have access","warn");const p=(null===(o=null==l?void 0:l.checkoutSettings)||void 0===o?void 0:o.customHTML)||"";this.injectCustomHTML(p),this.initZonosNotification();const f=window.Zonos.isLegacyCheckout&&!!window.Zonos.cartData&&"CLOSE_MODAL"===(null===(i=this.config.checkoutSettings)||void 0===i?void 0:i.successBehavior),w=Object.assign(Object.assign({},this.config),{appearance:Object.assign(Object.assign({},this.config.appearance),{logoUrl:(()=>{var e,t,o;return window.Zonos.isLegacyCheckout?(null===(e=null==l?void 0:l.appearanceSettings)||void 0===e?void 0:e.logoUrl)||(null===(t=this.config.appearance)||void 0===t?void 0:t.logoUrl):null===(o=this.config.appearance)||void 0===o?void 0:o.logoUrl})()}),checkoutSettings:this.config.checkoutSettings?Object.assign(Object.assign({},this.config.checkoutSettings),{allowedSettlementCurrencies:void 0,captureDelay:void 0,subscriptionStatus:void 0,successBehavior:f?"ZONOS_SUCCESS_PAGE":this.config.checkoutSettings.successBehavior,successRedirectUrl:f?(null===(n=window.Zonos.cartData)||void 0===n?void 0:n.storeBaseUrl)||(null==l?void 0:l.onlineStoreSettings.url):this.config.checkoutSettings.successRedirectUrl}):void 0});d({overrideSettings:w,zonosSettings:l}),a.zonosMode=h,this.setupGoogleFont(),"DISABLED"===a.helloSettings.visibilityStatus&&g("=== Hello is disabled by store owner ===","warn"),a.helloSettings&&"ENABLED"===a.helloSettings.visibilityStatus&&(g("Initializing hello"),b(a.helloSettings)),await r();const y=(null===(s=null==l?void 0:l.checkoutSettings)||void 0===s?void 0:s.externalServiceTokens.find((e=>"STRIPE_PUBLISHABLE_TOKEN"===e.type)))||null;if(y&&this.stripeInitEvent){if("INACTIVE"===a.checkoutSettings.subscriptionStatus)return g('=== Checkout subscription is "INACTIVE" - Cancel initializing for Checkout ===',"warn"),void g("zonos controller loaded");if("DISABLED"===a.checkoutSettings.visibilityStatus)return g("=== Checkout is disabled by store owner ===","warn"),void g("zonos controller loaded");this.stripeInitEvent.emit({publishableKey:y.token}),this.initGooglePlacesService(l)}else g("Checkout failed to load -- missing publishable key","warn")})()}async showNotification(e){const t=document.querySelector("zonos-notification");t?t.showNotification(e):g("Failed to show notification - zonos-notification not found","warn")}async reset(){c.checkoutSessionId=null,n.clientSecret=""}async overrideConfig(e){d({overrideSettings:e,zonosSettings:null})}async overrideCountry(e){g(`Override country code to ${e}`),l(e)}async getAppearanceSetting(){return a.appearance}async updateOrganizationName(e){a.organizationName=e}render(){return o(i,{key:"62c0b3079d64f05800da24daa19e0e1e3a890bca",class:"zonos--elements"})}};k.style=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{visibility:hidden;opacity:0;height:0}";export{k as zonos_controller}
@@ -1 +0,0 @@
1
- import{z as e,c as t}from"./p-7ce093aa.js";import{s as o,l as n,t as r,f as s,b as i}from"./p-749a0fc6.js";import{l as a,f as d,h as l,g as c,a as u,s as v,d as m,b as p,j as h}from"./p-2eec2d7c.js";import{i as y}from"./p-56e0ed65.js";import{g as w}from"./p-2b9c124d.js";const g=({currentAddress:e,translatedAddress:t})=>{var o,n,r,s,i,a;const{city:d,country:l,line1:c,line2:u,postal_code:v,state:m}=e.value.address,p=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===(r=t.line2)||void 0===r?void 0:r[u||""])||u||"",name:(null===(s=t.name)||void 0===s?void 0:s[p])||p,phone:e.value.phone||"",postal_code:(null===(i=t.postal_code)||void 0===i?void 0:i[v])||v,state:(null===(a=t.state)||void 0===a?void 0:a[m])||m}},f=e=>{var t;const n="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),r=N.stripeLinkEventData,s=N.stripeAddressEventData,i=N.stripeShippingSameAsBilling?N.stripeAddressEventData:N.stripeBillingAddressEventData;if(!s||!i)throw new Error("Missing stripe address data");const a=g({currentAddress:s,translatedAddress:N.translatedAddress.address}),d=a.name.split(" ")[0]||"",l=a.name.split(" ").splice(1).join(" ")||"",c=g({currentAddress:i,translatedAddress:N.translatedAddress.address}),u=c.name.split(" ")[0]||"",v=c.name.split(" ").splice(1).join(" ")||"";return{billingAddress:{addressLine1:c.line1,addressLine2:c.line2||"",city:c.city,country:c.country,postalCode:c.postal_code,state:c.state},billingContact:{firstName:u,lastName:v,phone:c.phone},cartCurrencyCode:null===(t=oe.items[0])||void 0===t?void 0:t.currencyCode,cartId:e,checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:N.companyName,email:null==r?void 0:r.value.email,firstName:d,lastName:l,phone:a.phone},isTest:!!n,landedCostAdjustments:oe.promoCode?[{amount:0,productId:null,promoCode:oe.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToTaxId:N.taxId,shippingAddress:{addressLine1:a.line1,addressLine2:a.line2,city:a.city,country:a.country,postalCode:a.postal_code,state:a.state}}},b=()=>{const e="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),t=N.stripeLinkEventData,n=N.stripeAddressEventData,r=N.stripeShippingSameAsBilling?N.stripeAddressEventData:N.stripeBillingAddressEventData;if(a({stripeAddressData:n,stripeBillingAddressData:r},"info"),!n||!r)throw new Error("Missing stripe address data");const s=g({currentAddress:n,translatedAddress:N.translatedAddress.address}),i=s.name.split(" ")[0]||"",d=s.name.split(" ").splice(1).join(" ")||"",l=g({currentAddress:r,translatedAddress:N.translatedAddress.address}),c=l.name.split(" ")[0]||"",u=l.name.split(" ").splice(1).join(" ")||"",v=oe.adjustments.map((e=>({amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}))),m=oe.promoCode?[{amount:0,productId:null,promoCode:oe.promoCode,sku:null,type:"PROMO_CODE"},...v]:v;return{billingAddress:{addressLine1:l.line1,addressLine2:l.line2||"",city:l.city,country:l.country,postalCode:l.postal_code,state:l.state},billingContact:{firstName:c,lastName:u,phone:l.phone},checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:N.companyName,email:null==t?void 0:t.value.email,firstName:i,lastName:d,phone:s.phone},isTest:e,items:oe.items,landedCostAdjustments:m,shipToTaxId:N.taxId,shippingAddress:{addressLine1:s.line1,addressLine2:s.line2,city:s.city,country:s.country,postalCode:s.postal_code,state:s.state}}};const S=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,r,s;const i=b(),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===(r=null===(n=null==a?void 0:a.errors)||void 0===n?void 0:n[0])||void 0===r?void 0:r.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===(s=c.find(Boolean))||void 0===s?void 0:s.message)||"Unknown error"}`);return a})(n);return e}const{errors:r,json:s}=await l("/api/zonos-elements/calculate-landed-cost",{body:b(),method:"POST",signal:null==t?void 0:t.signal});if(r.length||!s){if("The user aborted a request."===(null===(o=r[0])||void 0===o?void 0:o.message))throw new Error("The landed cost calculation request was aborted to initiate a new one.");if(r.forEach((e=>{console.warn(`Error calculating landed cost: ${e.message}`)})),!s)throw new Error("Failed to calculate landed cost");return s}return s})(t);const n=await(async({abortController:e,cartId:t})=>{var o,n,r,s;const{errors:i,json:a}=await l("/api/zonos-elements/cart-calculate-landed-cost",{body:f(t),method:"POST",signal:null==e?void 0:e.signal});if(i.length||!a){const e="The user aborted a request."===(null===(o=i[0])||void 0===o?void 0:o.message)||(null===(n=i[0])||void 0===n?void 0:n.message.includes("signal is aborted"))||(null===(r=i[0])||void 0===r?void 0:r.message.includes("The operation was aborted"))||(null===(s=i[0])||void 0===s?void 0:s.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 a})({abortController:t,cartId:o}),{cartWorkflow:r}=n,s=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 r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(n,["cartWorkflow"]);return Object.assign(Object.assign({},s),{itemCreateWorkflow:r.items})},C=async({checkoutSessionId:t,eventName:o,metadata:r})=>{var s,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===(s=window.Zonos)||void 0===s?void 0:s.zonosQaUrl)||!!(null===(i=window.Zonos)||void 0===i?void 0:i.debug);if((c()||u()||p)&&!window.Zonos.zonosConversionTest)return;const h=n.selectedCountryCode,y=e.organizationId;if(!t)return void v({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No checkout session id found`],metadata:{allLogs:m,checkoutSessionId:t,eventName:o,metadata:r,organizationId:y,trackEventLogs:d}});y||v({endpoint:"trackConversionEventMetric",errors:[`Event "${o}" - No organization id found`],metadata:{allLogs:m,checkoutSessionId:t,eventName:o,metadata:r,organizationId:y,trackEventLogs:d}});const w={checkoutSessionId:t,countryCode:h,eventCreated:a,eventName:o,metadata:Object.assign(Object.assign({},r),{trackEventLogs:d}),organizationId:y};await l("/api/zonos-elements/track-conversion-event",{body:w,method:"POST"})},O=({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},A=e=>e.sort(((e,t)=>e.amount-t.amount)),k=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),v({endpoint:"validateCheckoutSession",errors:t.map((e=>e.message)),metadata:{allLogs:m}}),{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."),v({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:m}}),{errorMessage:r('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:!1})},I=({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},j=({borderStyle:e,theme:t})=>"DARK"===t?{borderRadius:w({overrideBorderStyle:e}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"}:{borderRadius:w({overrideBorderStyle:e}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"},{onChange:T,reset:E,state:N}=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:{}}}))),P=()=>{window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")},L=e=>{window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))},D=()=>{const e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return h(e)},x=async t=>{var o,r;const s=N.clientSecret;if(!N.stripe)return void a("Skip. Stripe is not initialized");const i=(({clientSecret:t,overrideBorderRadius:o,overridePrimaryColor:r,overrideSecondaryColor:s,overrideTheme:i,paypalEnabled:a})=>{const d=r||e.appearance.colorPrimary,l=s||e.appearance.colorSecondary,c=d&&y(d)?"night":"flat",u="DARK"===i?"night":"flat",v=a?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},I({theme:i||"LIGHT"})),theme:i?u:c,variables:Object.assign(Object.assign({},j({borderStyle:o,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:t||void 0,customerSessionClientSecret:N.stripeCustomerSessionClientSecret||void 0,externalPaymentMethodTypes:[...v],locale:n.selectedLocale}})({clientSecret:s,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}),d=JSON.stringify(i)===JSON.stringify(N.stripeElementsOptions);if(!N.stripeElements||!N.stripeElementsForBillingAddress)return N.stripeElements=null===(o=N.stripe)||void 0===o?void 0:o.elements(i),N.stripeElementsOptions=i,a("Stripe elements initialized"),N.stripeElementsForBillingAddress=null===(r=N.stripe)||void 0===r?void 0:r.elements(i),void a("Stripe elements for billing address initialized");d||(N.stripeElements.update(i),N.stripeElementsForBillingAddress.update(i),N.stripeElementsOptions=i,N.stripeElements.fetchUpdates()),a("Stripe elements updated")},R=()=>{sessionStorage.removeItem("zonos--client-secret"),E(),N.stripe=window.Zonos.stripe},_=({address:e,firstName:t,lastName:n,name:r,phone:s})=>{const i=(null==r?void 0:r.split(" ")[0])||t||"",a=(null==r?void 0:r.split(" ")[1])||n||"";return i&&a||v({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,firstName:t,lastName:n,name:r}}),s||v({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,phone:s}}),{city:e.city,country:e.country,firstName:i,lastName:a,line1:e.line1,line2:e.line2,phone:s||"",postal_code:e.postal_code,state:e.state}},z=async()=>{var e,t,n,r;if(!(null===(e=N.stripeAddressEventData)||void 0===e?void 0:e.complete)||!N.stripeShippingSameAsBilling&&!(null===(t=N.stripeBillingAddressEventData)||void 0===t?void 0:t.complete)||!N.stripeBillingAddressEventData)return{partiesCreated:!1};if(!oe.landedCostData)return{partiesCreated:!1};const s=null===(n=oe.landedCostData.find(Boolean))||void 0===n?void 0:n.landedCost.rootId;if(!s)return v({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId}}),{partiesCreated:!1};const i=(()=>{var e,t,o,n,r,s;const i=JSON.stringify(null===(e=N.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=N.stripeLinkEventData)||void 0===t?void 0:t.value),a=JSON.stringify(null===(o=N.stripeAddressUsedWhenAsyncAddressUpdate)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=N.stripeAddressEventData)||void 0===n?void 0:n.value),d=!N.stripeShippingSameAsBilling&&JSON.stringify(null===(r=N.stripeBillingAddressUsedWhenAsyncAddressUpdate)||void 0===r?void 0:r.value)!==JSON.stringify(null===(s=N.stripeBillingAddressEventData)||void 0===s?void 0:s.value);return i||a||d||N.taxIdUsedWhenAsyncAddressUpdate!==N.taxId||N.companyNameUsedWhenAsyncAddressUpdate!==N.companyName})();if(!i)return{partiesCreated:!1};const a=_({address:N.stripeAddressEventData.value.address,firstName:N.stripeAddressEventData.value.firstName,lastName:N.stripeAddressEventData.value.lastName,name:N.stripeAddressEventData.value.name,phone:N.stripeAddressEventData.value.phone}),d=N.stripeShippingSameAsBilling?a:_({address:N.stripeBillingAddressEventData.value.address,firstName:N.stripeBillingAddressEventData.value.firstName,lastName:N.stripeBillingAddressEventData.value.lastName,name:N.stripeBillingAddressEventData.value.name,phone:N.stripeBillingAddressEventData.value.phone}),c="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:u,json:h}=await l("/api/zonos-elements/create-parties",{body:{address:a,billingAddress:d,companyName:N.companyName,email:(null===(r=N.stripeLinkEventData)||void 0===r?void 0:r.value.email)||"",isTest:c,rootId:s,taxId:N.taxId},method:"POST"});return u.length||!h?(p("Error occurs when creating parties",JSON.stringify(u,null,2)),v({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,errors:u,json:h}}),{partiesCreated:!1}):(N.companyNameUsedWhenAsyncAddressUpdate=N.companyName,N.stripeAddressUsedWhenAsyncAddressUpdate=N.stripeAddressEventData,N.stripeBillingAddressUsedWhenAsyncAddressUpdate=N.stripeBillingAddressEventData,N.taxIdUsedWhenAsyncAddressUpdate=N.taxId,N.partyBillingId=h.billToPartyId,N.partyShippingId=h.shipToPartyId,{partiesCreated:!0})},U=e=>({countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}),B=async t=>{var n,r,s,i;const d=(null==t?void 0:t.retries)||0,l=!!(null==t?void 0:t.applyingPromocode),c=(()=>{var e;const t=oe.landedCostData&&(null===(e=oe.landedCostData.find(Boolean))||void 0===e?void 0:e.subtotals.items)!==oe.subtotal,o=(()=>{var e,t;const o=JSON.stringify(null===(e=N.stripeLinkUsedWhenFetchingLC)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=N.stripeLinkEventData)||void 0===t?void 0:t.value),n=N.stripeAddressEventData&&JSON.stringify(U(N.stripeAddressEventData.value))!==JSON.stringify(N.stripeAddressUsedWhenFetchingLC),r=!N.stripeShippingSameAsBilling&&N.stripeBillingAddressEventData&&JSON.stringify(U(N.stripeBillingAddressEventData.value))!==JSON.stringify(N.stripeBillingAddressUsedWhenFetchingLC);return o||n||r})();return a("isPrefetchInfoOutdated","info",{isAddressOutdated:o}),!oe.landedCostData&&!N.isFetchingLandedCost||o||t})();if(!(()=>{var t,o,n,r;const s=!!(null===(t=N.stripeLinkEventData)||void 0===t?void 0:t.complete),i=!!(null===(o=N.stripeAddressEventData)||void 0===o?void 0:o.complete),a=N.stripeShippingSameAsBilling?i:!!(null===(n=N.stripeBillingAddressEventData)||void 0===n?void 0:n.complete),d=(t=>{var o,n;const r=null===(o=e.genericSettings)||void 0===o?void 0:o.countryFields,s=null===(n=e.genericSettings)||void 0===n?void 0:n.stripeCountryFieldLabels;return"stripe"===oe.addressFormRenderType&&(s&&t in s?s[t]:null)||(r&&t in r?r[t]:null)})((null===(r=N.stripeAddressEventData)||void 0===r?void 0:r.value.address.country)||"US");return!!(i&&a&&s)||(d&&N.stripeAddressEventData?s&&N.stripeAddressEventData.value.firstName&&N.stripeAddressEventData.value.lastName&&N.stripeAddressEventData.value.address.line1.length>0&&(!d.stateRequired||d.stateRequired&&N.stripeAddressEventData.value.address.state.length>0)&&(!d.zipRequired||d.zipRequired&&N.stripeAddressEventData.value.address.postal_code.length>=3)&&N.stripeAddressEventData.value.phone&&N.stripeAddressEventData.value.phone.length>0:i&&a&&s)})())return{isRequestNotReady:!0};if(c&&(null===(n=N.fetchingLandedCostAbortController)||void 0===n||n.abort(),N.fetchingLandedCostAbortController=null),!c&&!l)return{isRequestNotReady:!1};d?(N.isFetchingLandedCost=!1,setTimeout((()=>{N.isFetchingLandedCost=!0}),300)):N.isFetchingLandedCost=!0,N.stripeAddressEventData&&(N.stripeAddressUsedWhenFetchingLC={countryCode:N.stripeAddressEventData.value.address.country,postalCode:N.stripeAddressEventData.value.address.postal_code,state:N.stripeAddressEventData.value.address.state}),N.stripeBillingAddressEventData&&(N.stripeBillingAddressUsedWhenFetchingLC={countryCode:N.stripeBillingAddressEventData.value.address.country,postalCode:N.stripeBillingAddressEventData.value.address.postal_code,state:N.stripeBillingAddressEventData.value.address.state}),N.stripeLinkEventData&&(N.stripeLinkUsedWhenFetchingLC=Object.assign({},N.stripeLinkEventData));try{we(),await(async()=>{var e;const t=new AbortController;N.fetchingLandedCostAbortController=t,we();const{checkoutSessionWorkflow:n,errors:r,itemCreateWorkflow:s,landedCostCalculateWorkflow:i,partyCreateWorkflow:a,shipmentRatingCalculateWorkflow:d}=await S(t);oe.customQuotingError=(null===(e=null==r?void 0:r.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,oe.shippingData=A((null==d?void 0:d.filter(Boolean))||[]),ie(s),N.fetchingLandedCostAbortController=null,oe.partiesData=(null==a?void 0:a.filter(Boolean))||[],oe.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)&&C({checkoutSessionId:o.checkoutSessionId,eventName:"checkout_quoteReceived"});const l=oe.promoCodeApplied&&!oe.landedCostData.find((e=>{var t;return null===(t=e.landedCost.appliedAdjustments)||void 0===t?void 0:t.find((e=>"PROMO_CODE"===e.type))}));oe.promoCodeError=l,l||sessionStorage.setItem("zonos--promo-code",oe.promoCode)})();const e=null===(r=oe.shippingData)||void 0===r?void 0:r.find(Boolean),t=null===(s=oe.landedCostData)||void 0===s?void 0:s.find((t=>t.landedCost.shipmentRating.id===(null==e?void 0:e.id))),n=t?t.subtotals:null;n&&le({method:(null==t?void 0:t.landedCost.method)||"DDP",subtotals:n})}catch(e){if(oe.landedCostData=[],oe.shippingData=[],e instanceof Error&&e.message&&!["The landed cost calculation request was aborted to initiate a new one."].includes(e.message)){if(d<1)return await B(Object.assign(Object.assign({},t),{retries:(d||0)+1})),{isRequestNotReady:!1};const o=null===(i=N.stripeAddressEventData)||void 0===i?void 0:i.value;v({endpoint:`Failed to fetch landed cost (${d} retries)`,errors:[e.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:o}})}p(e)}return N.isFetchingLandedCost=!1,{isRequestNotReady:!1}},F=async()=>{var e,t;await B({applyingPromocode:!0}),"payment"===oe.step&&fe(),await z();const o=null===(e=oe.shippingData)||void 0===e?void 0:e.find(Boolean),n=null===(t=oe.landedCostData)||void 0===t?void 0:t.find((e=>e.landedCost.id===(null==o?void 0:o.id)));o&&n&&await pe(o,n.landedCostId)},J=()=>{oe.promoCode="",sessionStorage.removeItem("zonos--promo-code"),oe.promoCodeError=!1,oe.promoCodeApplied=!1},$=async()=>{"payment"===oe.step&&fe(),J(),await F()},M=e=>{let t=[],o=!0;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.")],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.")];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}},W=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?(N.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:oe.items})}catch(e){const t=e instanceof Error?e.message:"Unknown error";throw v({endpoint:"onInventoryCheck",errors:[`cartId: ${window.Zonos.cartId} - ${t}`],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:oe.items}}),e}},q=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"})},Y=async({clientSecret:e,storybookForceStatus:t})=>{if(t){const{isError:e,messages:o}=M(t);return{error:e,messages:o}}const o=e||N.clientSecret;if(!N.stripe||!o)return p("Failed to retrieve payment intent. Stripe is not initialized"),{error:!0,message:[r("Something went wrong.")]};const{paymentIntent:n}=await N.stripe.retrievePaymentIntent(o),s=null==n?void 0:n.status,{isError:i,messages:a}=M(s);return{error:i,messages:a,paymentIntentId:null==n?void 0:n.id,paymentMethod:null==n?void 0:n.payment_method,status:s}},H=async()=>{var e,t;const n=!!(null===(e=N.stripePaymentEventData)||void 0===e?void 0:e.complete),s=N.stripeElements,i=N.stripe,d=N.clientSecret;if(N.customErrorMessage=null,!(null===(t=oe.selectedLandedCost)||void 0===t?void 0:t.landedCost.id))throw new Error("Attempted to confirm the payment when no landed cost is found in store");const l=await k();if(!l.valid)throw N.customErrorMessage=l.errorMessage,new Error(l.errorMessage);const c=o.checkoutSessionId;if(i&&s&&n&&d&&c){const e=new URL(window.location.href);e.searchParams.set("payment_intent_client_secret",d),e.searchParams.set("zonosCheckoutSessionId",c),C({checkoutSessionId:c,eventName:"checkout_paymentInfoCompleted"});const{error:t,paymentIntent:o}=await i.confirmPayment({confirmParams:{return_url:e.toString()},elements:s,redirect:"if_required"});if(a("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."))}},K=()=>{var e;const t=oe.items.reduce(((e,t)=>e+t.amount*t.quantity),0),r=o.enabledVariantTestKeys||[];return{adjustmentsAmount:oe.adjustments.reduce(((e,t)=>e+t.amount),0),cartId:window.Zonos.cartId,currency:(null===(e=oe.items.find(Boolean))||void 0===e?void 0:e.currencyCode)||"",customerAuthenticationToken:oe.customerAuthenticationToken||void 0,itemsAmount:t,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:n.selectedCountryCode,skipPaymentIntent:N.skipPaymentIntent,varianceTestInput:r}},G=async()=>{var e;if(!o.checkoutSessionId)return v({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:m,cartId:window.Zonos.cartId}}),void de({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)),v({endpoint:"Error creating payment intent",errors:t.map((e=>e.message)),metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,clientSecret:s}}),void de({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")});ue(n.checkoutSessionPaymentIntentCreate)},V=async()=>{var e,t;if(!n.targetCurrency)return p("Failed to create checkout session - missing localizationStore.targetCurrency"),!1;N.isFetchingSession=!0;const o=K();a("Checkout session body","info",o);const{errors:r,json:s}=await l("/api/zonos-elements/create-checkout-session",{body:o,method:"POST"});if(N.isFetchingSession=!1,r.length||!s){const t=null===(e=r.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(r,null,2)),!1}const i=s.checkoutSessionCreate;return ue(i),le({method:(null===(t=i.landedCost)||void 0===t?void 0:t.method)||"DDP",subtotals:i.subtotals}),a("Exchange rate updated for cart items (checkout session create)","info",oe.exchangeRate),a("done-init-checkout-session"),!0},Z=async()=>{const t=o.checkoutSessionId;if(!t)return p("Failed to update checkout session base currency"),!1;if("LOCAL"===e.checkoutSettings.allowedSettlementCurrencies)return a('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:N.checkoutSettlementCurrency},method:"POST"}),r=null==n?void 0:n.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;return n&&r===N.checkoutSettlementCurrency?(a(`Updated checkout session to settlement currency "${r}".`),!0):(p("Failed to update checkout session base currency"),!1)},Q=({currentAddress:e,translatedAddressResult:t})=>{const o={};if(!t)return o;const{city:n,line1:r,line2:s,name:i,postal_code:a,state:d}=t;return e.city&&n&&(o.city={[e.city]:n}),e.line1&&r&&(o.line1={[e.line1]:r}),e.line2&&s&&(o.line2={[e.line2]:s}),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},X=async({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t})=>{var o,n,r,s;const i=(({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:o,stripeBillingAddressEventData:n,stripeShippingSameAsBilling:r})=>{var s,i,a,d;const l=!!(null==o?void 0:o.complete);if(!l||!(r?l:null==n?void 0:n.complete))return null;if(!e&&!t)return null;const c=o.value,u=(null==n?void 0:n.value)||null,v=`${c.firstName||(null===(s=c.name)||void 0===s?void 0:s.split(" ")[0])} ${c.lastName||(null===(i=c.name)||void 0===i?void 0:i.split(" ")[1])}`,m=c.firstName||(null===(a=null==u?void 0:u.name)||void 0===a?void 0:a.split(" ")[0]),p=c.lastName||(null===(d=null==u?void 0:u.name)||void 0===d?void 0:d.split(" ")[1]),h=m&&p?`${m} ${p}`:"",y=c.address,w=null==u?void 0:u.address;return{address:O({address:Object.assign(Object.assign({},y),{name:v}),invalidAdddressList:e}),billingAddress:r?void 0:O({address:w?Object.assign(Object.assign({},w),{name:h}):null,invalidAdddressList:t}),destinationCountry:y.country}})({addressInvalidCharactersList:e,billingAddressInvalidCharactersList:t,stripeAddressEventData:N.stripeAddressEventData,stripeBillingAddressEventData:N.stripeBillingAddressEventData,stripeShippingSameAsBilling:N.stripeShippingSameAsBilling});if(!i)return void(N.translatedAddress={address:{},billingAddress:{}});const a=(()=>{var e,t,o,n;const r=JSON.stringify(null===(e=N.stripeAddressUsedWhenValidatingAddress)||void 0===e?void 0:e.value)!==JSON.stringify(null===(t=N.stripeAddressEventData)||void 0===t?void 0:t.value),s=!N.stripeShippingSameAsBilling&&JSON.stringify(null===(o=N.stripeBillingAddressEventData)||void 0===o?void 0:o.value)!==JSON.stringify(null===(n=N.stripeBillingAddressUsedWhenValidatingAddress)||void 0===n?void 0:n.value);return r||s})();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(N.translatedAddress={address:{},billingAddress:{}});N.stripeAddressUsedWhenValidatingAddress=N.stripeAddressEventData,N.stripeBillingAddressUsedWhenValidatingAddress=N.stripeBillingAddressEventData;const u=null===(o=N.stripeAddressEventData)||void 0===o?void 0:o.value.address,v=null===(n=N.stripeBillingAddressEventData)||void 0===n?void 0:n.value.address;N.translatedAddress={address:u?Q({currentAddress:Object.assign(Object.assign({},u),{name:null===(r=N.stripeAddressEventData)||void 0===r?void 0:r.value.name}),translatedAddressResult:c.address||null}):{},billingAddress:N.stripeShippingSameAsBilling?{}:Q({currentAddress:Object.assign(Object.assign({},v),{name:null===(s=N.stripeBillingAddressEventData)||void 0===s?void 0:s.value.name}),translatedAddressResult:c.billingAddress||null})}};T("clientSecret",(e=>{e&&N.stripe&&sessionStorage.setItem("zonos--client-secret",e),e||sessionStorage.removeItem("zonos--client-secret")}));const{onChange:ee,reset:te,state:oe}=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}))),ne=e=>{switch(e){case"DAYS":return r("days");case"WEEKS":return r("weeks");default:return r("business days")}},re=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:ne(o.type)}:null},se=({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),ie=e=>{a("Checking item restrictions");const t=e.map((e=>{if(!e.restriction)return null;const{restriction:t}=e,o=oe.items.find((t=>se({item1:t,item2:e})));return Object.assign(Object.assign({matchedItem:o},e),{restriction:t})})).filter(Boolean);return oe.restrictedItems=t,oe.items=oe.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!!t.find((t=>se({item1:t,item2:e})))}))),{cartItems:oe.items,restrictedItems:t}},ae=()=>{o.checkoutSessionId=null,te()},de=({messages:e,title:t})=>{ae(),R(),oe.step="error",oe.error={messages:e,title:t}},le=({dutiesTaxesFeesEstimate:e,method:t,subtotals:o})=>{oe.exchangeRate=o.exchangeRate,oe.adjustmentTotal=o.adjustments,oe.dutiesTaxesFees="DAP"===t?null:o.landedCostTotal,oe.subtotal=o.items,oe.total=o.total,oe.currency=o.presentmentCurrencyCode,oe.dutiesTaxesFeesEstimate=e||null},ce=()=>!!oe.items.filter((e=>e.amount>0)).find((e=>!e.isRestricted)),ue=e=>{var t,n,r,d,l;N.clientSecret=e.clientSecret,N.stripeCustomerSessionClientSecret=e.customerSessionClientSecret,N.customerProfile=e.customerProfile,oe.checkoutSession=e,e.id||v({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:m,checkoutSession:e}}),e.id&&(o.checkoutSessionId=e.id);const c=s(e.varianceTestResults||[]);i(c);const u=(null===(r=null===(n=null===(t=oe.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===r?void 0:r.value)||(null===(l=null===(d=window.Zonos.cartData)||void 0===d?void 0:d.metadata.find((e=>"externalConfirmationPageURL"===(null==e?void 0:e.key))))||void 0===l?void 0:l.value)||null;u&&(a(`Found externalConfirmationPageURL: ${u}`),oe.externalConfirmationPageURL=u)},ve=async({adjustmentsAmount:e,cartId:t,currency:s,dutiesTaxesFeesEstimate:i,itemsAmount:d,landedCostId:c,shouldInitSessionOnFailure:u})=>{var v;if(c&&oe.selectedLandedCost&&(le({dutiesTaxesFeesEstimate:i,method:oe.landedCostMethod,subtotals:oe.selectedLandedCost.subtotals}),a("Exchange rate updated for cart items (landed cost subtotal)","info",oe.exchangeRate)),!o.checkoutSessionId)return a("Could not update cart total without checkout session id","info"),!1;const{errors:m,json:h}=await(async({adjustmentsAmount:e,cartId:t,currency:r,id:s,itemsAmount:i,landedCostId:a,presentmentCountryCode:d})=>{const c=o.enabledVariantTestKeys||[],{errors:u,json:v}=await l("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:e,billToPartyId:N.partyBillingId,cartId:t,currency:r,customerAuthenticationToken:oe.customerAuthenticationToken||void 0,id:s,itemsAmount:i,landedCostId:a,metadata:[{key:"language",value:n.selectedLocale}],presentmentCountryCode:d,shipToPartyId:N.partyShippingId,skipPaymentIntent:N.skipPaymentIntent,varianceTestInput:c},method:"POST"});return u.length||!v?(p("Error occurs when updating checkout session",JSON.stringify(u,null,2)),{errors:u,json:v}):{errors:[],json:v}})({adjustmentsAmount:e,billToPartyId:N.partyBillingId,cartId:t,currency:s,id:o.checkoutSessionId,itemsAmount:d,landedCostId:c,presentmentCountryCode:n.selectedCountryCode,shipToPartyId:N.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]});if(m.length>0||!h){if(p("Error occurs when updating checkout session."),u){a("Initiating checkout session on failure","info");const e=await V();return a(`stripeStoreInitCheckoutSession: ${e}`),!!e||(de({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 c||(le({method:(null===(v=h.checkoutSessionUpdate.landedCost)||void 0===v?void 0:v.method)||"DDP",subtotals:h.checkoutSessionUpdate.subtotals}),a("Exchange rate updated for cart items (checkout session update)","info",oe.exchangeRate)),ue(h.checkoutSessionUpdate),!0},me=e=>"DAP"===e.method&&e.remittance.length&&"ZONOS"===e.landedCostGuaranteeCode?"DDP":e.method,pe=async(t,n)=>{var r,s,i,d,l,c,u,v,m,p,h;oe.selectedShippingOption=t;const y=re(oe.selectedShippingOption);if(y){const{maxTransit:e,minTransit:t,unit:o}=y;oe.selectedShippingOptionTransitTime=`${t}-${e} ${o}`}else oe.selectedShippingOptionTransitTime="";const w=null===(r=oe.landedCostData)||void 0===r?void 0:r.find((e=>e.landedCostId===n));if(oe.selectedLandedCost=w||null,!w)return!1;const g=((null===(s=w.landedCost.amountSubtotals)||void 0===s?void 0:s.landedCostTotal)||0)*w.subtotals.exchangeRate.rate;g&&a(`DAP quote, using estimate: ${g}`,"info"),oe.landedCostMethod=me(w.landedCost),oe.shipping=w.subtotals.shipping;const f="ZONOS"===(null===(i=null==w?void 0:w.landedCost)||void 0===i?void 0:i.landedCostGuaranteeCode),b=!!(null===(l=null===(d=null==w?void 0:w.landedCost)||void 0===d?void 0:d.deMinimis)||void 0===l?void 0:l.find((e=>["DUTY","TAX"].includes(e.type)&&"ABOVE"===e.threshold)));oe.isSelectedShippingAboveDeminimis=b,oe.isSelectedShippingGuarantee=f;const S=await ve({adjustmentsAmount:oe.adjustmentTotal,billToPartyId:N.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:g,landedCostId:null===(c=w.landedCost)||void 0===c?void 0:c.id,shipToPartyId:N.partyShippingId,varianceTestInput:o.enabledVariantTestKeys||[]}),C=null===(u=oe.items.find(Boolean))||void 0===u?void 0:u.currencyCode,O=(null===(v=N.stripeAddressEventData)||void 0===v?void 0:v.value.address.country)||"US";return N.shouldRenderPayInUsdButton="USD"===C&&"LOCAL_AND_USD"===e.checkoutSettings.allowedSettlementCurrencies&&"USD"!==(null===(m=oe.checkoutSession)||void 0===m?void 0:m.subtotals.presentmentCurrencyCode)&&!!(null===(h=null===(p=e.genericSettings)||void 0===p?void 0:p.usdSettlementCountryEnabled)||void 0===h?void 0:h.includes(O)),S},he=({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;a(`==START CHECKOUT TIMEOUT - ${n}==`),oe.checkoutTimeoutInterval=setTimeout((()=>{oe.checkoutSessionTimeoutShow=!0}),n)},ye=()=>{oe.checkoutTimeoutInterval&&(clearTimeout(oe.checkoutTimeoutInterval),oe.checkoutTimeoutInterval=null)},we=()=>{oe.items=oe.items.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1}))),oe.restrictedItems=[]},ge=async({adjustments:e,cartItems:t})=>{var n;oe.adjustments=e,oe.items=t.map((e=>Object.assign(Object.assign({},e),{isRestricted:!1})));const r=null===(n=t.find(Boolean))||void 0===n?void 0:n.currencyCode,s=t.reduce(((e,t)=>e+t.amount*t.quantity),0),i=e.reduce(((e,t)=>e+t.amount),0);r&&s&&(oe.currency=r,N.isFetchingSession=!0,await ve({adjustmentsAmount:i,billToPartyId:N.partyBillingId,cartId:window.Zonos.cartId,currency:r,dutiesTaxesFeesEstimate:0,itemsAmount:s,shipToPartyId:N.partyShippingId,shouldInitSessionOnFailure:!0,varianceTestInput:o.enabledVariantTestKeys||[]}),N.isFetchingSession=!1)},fe=()=>{"shipping"===oe.step?(oe.step="customer-info",oe.tabItems=Object.assign(Object.assign({},oe.tabItems),{"customer-info":Object.assign(Object.assign({},oe.tabItems.shipping),{isDone:!1})})):"payment"===oe.step?(oe.step="shipping",oe.tabItems=Object.assign(Object.assign({},oe.tabItems),{shipping:Object.assign(Object.assign({},oe.tabItems.shipping),{isDone:!1})})):"finish"===oe.step&&(oe.step="payment",oe.tabItems=Object.assign(Object.assign({},oe.tabItems),{payment:Object.assign(Object.assign({},oe.tabItems.payment),{isDone:!1})}))},be=()=>{"customer-info"===oe.step?(oe.step="shipping",oe.tabItems=Object.assign(Object.assign({},oe.tabItems),{"customer-info":Object.assign(Object.assign({},oe.tabItems["customer-info"]),{isDone:!0})})):"shipping"===oe.step?(oe.step="payment",oe.tabItems=Object.assign(Object.assign({},oe.tabItems),{shipping:Object.assign(Object.assign({},oe.tabItems.shipping),{isDone:!0})})):"payment"===oe.step&&(oe.step="finish")},Se=()=>{oe.step="customer-info",oe.tabItems=Object.assign(Object.assign({},oe.tabItems),{"customer-info":Object.assign(Object.assign({},oe.tabItems["customer-info"]),{isDone:!1}),payment:Object.assign(Object.assign({},oe.tabItems.payment),{isDone:!1}),shipping:Object.assign(Object.assign({},oe.tabItems.shipping),{isDone:!1})}),oe.selectedShippingOption=null,oe.isSelectedShippingAboveDeminimis=!1,oe.isSelectedShippingGuarantee=!1,oe.selectedShippingOptionTransitTime="",oe.dutiesTaxesFees=0,oe.dutiesTaxesFeesEstimate=0,oe.shipping=0,oe.total=oe.subtotal};export{ce as A,F as B,$ as C,J as D,M as E,X as F,ee as G,z as H,pe as I,re as J,A as K,me as L,P as a,L as b,N as c,Y as d,oe as e,ge as f,ae as g,Se as h,x as i,ye as j,V as k,G as l,he as m,K as n,de as o,ue as p,B as q,be as r,D as s,C as t,Z as u,W as v,H as w,q as x,R as y,k as z}