@zonos/elements 1.3.254 → 1.3.255

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 (147) hide show
  1. package/dist/cjs/{cart-77640463.js → cart-4ef52500.js} +1 -1
  2. package/dist/cjs/{hasInclusivePrice-e93c64fd.js → hasInclusivePrice-4419d03e.js} +1 -1
  3. package/dist/cjs/index.cjs.js +7 -7
  4. package/dist/cjs/{invoice-211ef96c.js → invoice-3494b21e.js} +2 -2
  5. package/dist/cjs/{isCollectMobileTablet-14fb5ab4.js → isCollectMobileTablet-92955ce6.js} +2 -2
  6. package/dist/cjs/{localization-be7afc1b.js → localization-75f4ec05.js} +3 -0
  7. package/dist/cjs/{paypal-c61ef042.js → paypal-cc3a730b.js} +2 -2
  8. package/dist/cjs/{placeTestOrder-0f7477c8.js → placeTestOrder-13901275.js} +2 -2
  9. package/dist/cjs/{renderCheckoutCurrency-1ac02803.js → renderCheckoutCurrency-0003992c.js} +2 -2
  10. package/dist/cjs/zonos-address-display_8.cjs.entry.js +2 -2
  11. package/dist/cjs/zonos-address_4.cjs.entry.js +2 -2
  12. package/dist/cjs/zonos-card_5.cjs.entry.js +3 -3
  13. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +6 -6
  14. package/dist/cjs/zonos-checkout.cjs.entry.js +3 -3
  15. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +2 -2
  16. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +6 -6
  17. package/dist/cjs/zonos-collect.cjs.entry.js +4 -4
  18. package/dist/cjs/zonos-controller.cjs.entry.js +2 -2
  19. package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
  20. package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
  21. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
  22. package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
  23. package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +4 -4
  24. package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +6 -6
  25. package/dist/cjs/zonos-invoice.cjs.entry.js +4 -4
  26. package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
  27. package/dist/cjs/zonos-store-credit.cjs.entry.js +3 -3
  28. package/dist/collection/components/store/hello/localization.js +3 -0
  29. package/dist/esm/{cart-394c9ddb.js → cart-f4e43d1a.js} +1 -1
  30. package/dist/esm/{hasInclusivePrice-f0322e1c.js → hasInclusivePrice-0439b7f4.js} +1 -1
  31. package/dist/esm/index.js +7 -7
  32. package/dist/esm/{invoice-5ae81ae5.js → invoice-3d8f3fa8.js} +2 -2
  33. package/dist/esm/{isCollectMobileTablet-15b668d6.js → isCollectMobileTablet-0402aa32.js} +2 -2
  34. package/dist/esm/{localization-0ebc8356.js → localization-026da80b.js} +3 -0
  35. package/dist/esm/{paypal-b6fa3ec3.js → paypal-07bd6b7c.js} +2 -2
  36. package/dist/esm/{placeTestOrder-5756cbc3.js → placeTestOrder-39de11f4.js} +2 -2
  37. package/dist/esm/{renderCheckoutCurrency-5f3e06ea.js → renderCheckoutCurrency-743f7c77.js} +2 -2
  38. package/dist/esm/zonos-address-display_8.entry.js +2 -2
  39. package/dist/esm/zonos-address_4.entry.js +2 -2
  40. package/dist/esm/zonos-card_5.entry.js +3 -3
  41. package/dist/esm/zonos-cart-items_12.entry.js +6 -6
  42. package/dist/esm/zonos-checkout.entry.js +3 -3
  43. package/dist/esm/zonos-collect-cart-items_3.entry.js +2 -2
  44. package/dist/esm/zonos-collect-finish_6.entry.js +6 -6
  45. package/dist/esm/zonos-collect.entry.js +4 -4
  46. package/dist/esm/zonos-controller.entry.js +2 -2
  47. package/dist/esm/zonos-country-flag.entry.js +1 -1
  48. package/dist/esm/zonos-country-select_4.entry.js +1 -1
  49. package/dist/esm/zonos-hello-dialog.entry.js +2 -2
  50. package/dist/esm/zonos-hello.entry.js +1 -1
  51. package/dist/esm/zonos-invoice-cart-items_2.entry.js +4 -4
  52. package/dist/esm/zonos-invoice-finish_5.entry.js +6 -6
  53. package/dist/esm/zonos-invoice.entry.js +4 -4
  54. package/dist/esm/zonos-language-select_2.entry.js +1 -1
  55. package/dist/esm/zonos-store-credit.entry.js +3 -3
  56. package/dist/esm-es5/{cart-394c9ddb.js → cart-f4e43d1a.js} +1 -1
  57. package/dist/esm-es5/{hasInclusivePrice-f0322e1c.js → hasInclusivePrice-0439b7f4.js} +1 -1
  58. package/dist/esm-es5/index.js +1 -1
  59. package/dist/esm-es5/{invoice-5ae81ae5.js → invoice-3d8f3fa8.js} +1 -1
  60. package/dist/esm-es5/{isCollectMobileTablet-15b668d6.js → isCollectMobileTablet-0402aa32.js} +1 -1
  61. package/dist/esm-es5/{localization-0ebc8356.js → localization-026da80b.js} +1 -1
  62. package/dist/esm-es5/{paypal-b6fa3ec3.js → paypal-07bd6b7c.js} +2 -2
  63. package/dist/esm-es5/{placeTestOrder-5756cbc3.js → placeTestOrder-39de11f4.js} +1 -1
  64. package/dist/esm-es5/{renderCheckoutCurrency-5f3e06ea.js → renderCheckoutCurrency-743f7c77.js} +1 -1
  65. package/dist/esm-es5/zonos-address-display_8.entry.js +1 -1
  66. package/dist/esm-es5/zonos-address_4.entry.js +1 -1
  67. package/dist/esm-es5/zonos-card_5.entry.js +1 -1
  68. package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
  69. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  70. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  71. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
  72. package/dist/esm-es5/zonos-collect.entry.js +1 -1
  73. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  74. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  75. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  76. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  77. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  78. package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
  79. package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
  80. package/dist/esm-es5/zonos-invoice.entry.js +1 -1
  81. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  82. package/dist/esm-es5/zonos-store-credit.entry.js +1 -1
  83. package/dist/scripts/index.js +1 -1
  84. package/dist/scripts/loadZonos.js +1 -1
  85. package/dist/scripts/zonos.js +1 -1
  86. package/dist/zonos-elements/index.esm.js +1 -1
  87. package/dist/zonos-elements/{p-efa69c89.entry.js → p-0649737d.entry.js} +1 -1
  88. package/dist/zonos-elements/{p-dcef3647.system.js → p-06b4aa32.system.js} +1 -1
  89. package/dist/zonos-elements/{p-09d7a5cb.system.js → p-0aa1c8c2.system.js} +1 -1
  90. package/dist/zonos-elements/{p-cc9620e5.system.entry.js → p-0d4af7e9.system.entry.js} +1 -1
  91. package/dist/zonos-elements/{p-92d91395.system.entry.js → p-12f480c9.system.entry.js} +1 -1
  92. package/dist/zonos-elements/{p-27fad55a.system.js → p-16a80e3c.system.js} +1 -1
  93. package/dist/zonos-elements/{p-615b5d13.entry.js → p-1bdac1d3.entry.js} +1 -1
  94. package/dist/zonos-elements/p-1ed9ef0b.js +1 -0
  95. package/dist/zonos-elements/{p-97fb5ad5.entry.js → p-231edcca.entry.js} +1 -1
  96. package/dist/zonos-elements/{p-a5fb864a.system.entry.js → p-274a5d11.system.entry.js} +1 -1
  97. package/dist/zonos-elements/{p-daaaa8f1.system.entry.js → p-27e41b44.system.entry.js} +1 -1
  98. package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
  99. package/dist/zonos-elements/{p-3d757163.entry.js → p-2affd4e6.entry.js} +1 -1
  100. package/dist/zonos-elements/p-2b10f633.system.js +1 -0
  101. package/dist/zonos-elements/{p-95f7f2a0.entry.js → p-2baa21b1.entry.js} +1 -1
  102. package/dist/zonos-elements/{p-cf69bcc4.system.js → p-31d1b874.system.js} +1 -1
  103. package/dist/zonos-elements/{p-93dec11b.entry.js → p-33fc0c8f.entry.js} +1 -1
  104. package/dist/zonos-elements/{p-b37a85f0.system.entry.js → p-3730d555.system.entry.js} +1 -1
  105. package/dist/zonos-elements/{p-a1e23675.system.entry.js → p-3814aac3.system.entry.js} +1 -1
  106. package/dist/zonos-elements/{p-13041752.js → p-3ac97c01.js} +1 -1
  107. package/dist/zonos-elements/{p-8abeab5a.entry.js → p-3e03b2e8.entry.js} +1 -1
  108. package/dist/zonos-elements/{p-321e7920.system.js → p-50aac43c.system.js} +1 -1
  109. package/dist/zonos-elements/{p-bdaf2a38.entry.js → p-5359ba71.entry.js} +1 -1
  110. package/dist/zonos-elements/{p-8dfa0bb8.system.entry.js → p-5678c5b5.system.entry.js} +1 -1
  111. package/dist/zonos-elements/{p-b49b8da4.system.entry.js → p-568c5700.system.entry.js} +1 -1
  112. package/dist/zonos-elements/p-5e3e5e3e.system.js +1 -0
  113. package/dist/zonos-elements/{p-0da3cc62.system.entry.js → p-66758e30.system.entry.js} +1 -1
  114. package/dist/zonos-elements/{p-a95ac160.entry.js → p-6ce8374e.entry.js} +1 -1
  115. package/dist/zonos-elements/p-768430fe.js +1 -0
  116. package/dist/zonos-elements/{p-4f23732f.js → p-835c0bd4.js} +1 -1
  117. package/dist/zonos-elements/{p-d65cfa9b.system.entry.js → p-9b12f023.system.entry.js} +1 -1
  118. package/dist/zonos-elements/{p-07ca3347.system.entry.js → p-9d9792b9.system.entry.js} +1 -1
  119. package/dist/zonos-elements/{p-fce715f1.system.entry.js → p-9e98a256.system.entry.js} +1 -1
  120. package/dist/zonos-elements/{p-c1ae7391.system.entry.js → p-a1835bae.system.entry.js} +1 -1
  121. package/dist/zonos-elements/{p-2c2e5ee6.entry.js → p-a6cc56ba.entry.js} +1 -1
  122. package/dist/zonos-elements/{p-fbccfa3e.system.js → p-aabb921f.system.js} +1 -1
  123. package/dist/zonos-elements/{p-57b27c60.js → p-af83f0c2.js} +1 -1
  124. package/dist/zonos-elements/{p-1162b685.entry.js → p-b20c7f8c.entry.js} +1 -1
  125. package/dist/zonos-elements/{p-4a38ea5e.system.entry.js → p-b45538a7.system.entry.js} +1 -1
  126. package/dist/zonos-elements/{p-4df85216.entry.js → p-b6c78f82.entry.js} +1 -1
  127. package/dist/zonos-elements/p-b84be447.js +1 -0
  128. package/dist/zonos-elements/{p-29f7950c.js → p-c398711f.js} +1 -1
  129. package/dist/zonos-elements/{p-a0ac3ca2.system.entry.js → p-cc364b26.system.entry.js} +1 -1
  130. package/dist/zonos-elements/{p-a5adc047.system.entry.js → p-d168be79.system.entry.js} +1 -1
  131. package/dist/zonos-elements/{p-d8610393.entry.js → p-d2bba4dc.entry.js} +1 -1
  132. package/dist/zonos-elements/{p-c6047442.system.entry.js → p-d397560e.system.entry.js} +1 -1
  133. package/dist/zonos-elements/{p-8efb79ab.entry.js → p-d938fb86.entry.js} +1 -1
  134. package/dist/zonos-elements/{p-620ba943.js → p-dafafa07.js} +1 -1
  135. package/dist/zonos-elements/{p-c2121663.system.entry.js → p-db0b35a2.system.entry.js} +1 -1
  136. package/dist/zonos-elements/{p-11d6de1a.entry.js → p-db993fdb.entry.js} +1 -1
  137. package/dist/zonos-elements/{p-2bdc2206.entry.js → p-e12f7a97.entry.js} +1 -1
  138. package/dist/zonos-elements/{p-920d9189.entry.js → p-f888db89.entry.js} +1 -1
  139. package/dist/zonos-elements/{p-2c9c750e.system.js → p-f9705736.system.js} +1 -1
  140. package/dist/zonos-elements/{p-9ff90151.entry.js → p-fbe22363.entry.js} +1 -1
  141. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  142. package/package.json +1 -1
  143. package/dist/zonos-elements/p-0dd5a4b8.system.js +0 -1
  144. package/dist/zonos-elements/p-1282495f.system.js +0 -1
  145. package/dist/zonos-elements/p-2b118454.js +0 -1
  146. package/dist/zonos-elements/p-ac353826.js +0 -1
  147. package/dist/zonos-elements/p-ca19a10a.js +0 -1
@@ -1 +1 @@
1
- import{r as s,d as t,h as o,a as e,g as i}from"./p-ce75b047.js";import{t as n}from"./p-7d7ffb42.js";import{b as a,t as r,Q as l,E as d,q as c,d as h}from"./p-620ba943.js";import{s as p,r as u,t as m,q as f,l as z}from"./p-13041752.js";import{z as b,g,f as y}from"./p-058f6124.js";import{l as v,i as k,s as x}from"./p-41dd1cb8.js";import{a as w,s as C}from"./p-63a383f4.js";import{c as I}from"./p-b4b7f705.js";import{l as A}from"./p-0a377722.js";import{c as E,s as j}from"./p-6b361d2b.js";import{g as S}from"./p-f830f800.js";import"./p-908f13ae.js";import"./p-67897a0d.js";import"./p-1d42cd20.js";const D=class{constructor(o){s(this,o),this.invalidCharacters=t(this,"invalidCharacters",7),this.taxIdChanged=t(this,"taxIdChanged",7),this.storeUnsubscribeList=[],this.isAutoCompleteAdjusted=!1,this.defaultAddress=[],this.taxIdErrorMessage="",this.shortAddressCodeErrorMessage="",this.stripe=window.Zonos.stripe,this.isDirtyAddress=!1,this.isAddressFilled=!1,this.checkoutSessionId=p.checkoutSessionId,this.prevCountry=null,this.prevPostalCode=null,this.trackingSent=!1,this.prefetchLandedCost=n(c,1e3)}getStripeAddressInstance(){return"billing"===this.type?{stripeAddressElement:a.stripeBillingAddressElement,stripeAddressEventData:a.stripeBillingAddressEventData,stripeElements:a.stripeElementsForBillingAddress}:{stripeAddressElement:a.stripeAddressElement,stripeAddressEventData:a.stripeAddressEventData,stripeElements:a.stripeElements}}updateAddressEventData({event:s,type:t}){"billing"===t?a.stripeBillingAddressEventData=s:a.stripeAddressEventData=s,"shipping"===t&&s.value.address.line1.length&&this.prefetchLandedCost()}isAddressFilledChanged(){p.checkoutSessionId&&this.isAddressFilled&&!this.trackingSent&&"shipping"===this.type&&(this.trackingSent=!0,r({checkoutSessionId:p.checkoutSessionId,eventName:"checkout_customerInfoFilled"}))}updateAddressElement({stripeAddressElement:s,type:t}){"shipping"!==t?a.stripeBillingAddressElement=s:a.stripeAddressElement=s}async watchInitStripe(){this.stripe=window.Zonos.stripe;const{stripeAddressEventData:s,stripeElements:t}=this.getStripeAddressInstance();if(!this.stripe||!t)return void v("Stripe is not initialized. Couldn't load stripe element.");const o=this.defaultAddress.map((s=>Object.assign(Object.assign({},s),{name:s.name,phone:s.phone||void 0}))),e=z.shippingZoneCountries,i=e?Object.values(e).map((s=>s.code)):[],n=new URLSearchParams(window.location.search).has("zonosCheckoutAllCountries"),a="shipping"===this.type?i:[],r=(null==s?void 0:s.value.address.country)||u(a);A(`Stripe country code: ${r}`,"info");const d=t.create("address",{allowedCountries:n?[]:a,contacts:o.length&&!s?this.defaultAddress:[],defaultValues:{address:Object.assign(Object.assign({},null==s?void 0:s.value.address),{country:r}),firstName:null==s?void 0:s.value.firstName,lastName:null==s?void 0:s.value.lastName,phone:null==s?void 0:s.value.phone},display:{name:"split"},fields:{phone:"always"},mode:this.type,validation:{phone:{required:"always"}}});d.mount(this.el.querySelector(".zonos--address-component")),(null==s?void 0:s.value.address)&&(this.prevCountry=s.value.address.country,this.prevPostalCode=s.value.address.postal_code),d.on("change",(s=>{const t=s.value;if(!this.isDirtyAddress&&t.address.line1.length>=3){if(this.isDirtyAddress=!0,!this.isAutoCompleteAdjusted){const s=this.el.querySelector('iframe[src*="autocomplete-suggestions"]');s&&(s.style.zIndex="3"),this.isAutoCompleteAdjusted=!0}setTimeout((()=>{if(k())this.el.scrollIntoView({behavior:"smooth",block:"end"});else{const s="shipping"===this.type?100:600,t=this.el.closest(".zonos--group"),o=this.el.getBoundingClientRect().top+s;null==t||t.scrollTo({behavior:"smooth",top:o})}}),600)}const{firstName:o,lastName:e}=l({firstName:t.firstName,lastName:t.lastName,name:t.name});this.updateAddressEventData({event:Object.assign(Object.assign({},s),{elementMode:this.type,elementType:"address",value:Object.assign(Object.assign({},t),{firstName:o,lastName:e})}),type:this.type})})),this.updateAddressElement({stripeAddressElement:d,type:this.type})}defaultAddressChanged(s,t){if(JSON.stringify(t)===JSON.stringify(s))return;A("Reset address element when default address property is changed","info",{defaultAddress:this.defaultAddress});const o=this.getStripeAddressInstance().stripeAddressElement;null==o||o.clear(),null==o||o.destroy(),"shipping"===this.type?a.stripeAddressEventData=null:a.stripeBillingAddressEventData=null,this.watchInitStripe()}isInTaxIdCountry(s){return E.includes(s)}renderTaxIdInput(){var s;if("billing"===this.type)return null;const t=null===(s=a.stripeAddressEventData)||void 0===s?void 0:s.value.address.country;if(!t)return null;if(!this.isInTaxIdCountry(t))return null;if(!w({companyName:a.companyName,countryCode:t}))return null;const e=j[t];return o("div",{class:"zonos--tax-id-input"},o("zonos-stripe-input",{inputLabel:m(e.friendlyName),inputPlaceholder:e.placeholder,inputValue:a.taxId||"",isError:!!this.taxIdErrorMessage,onInputChange:s=>{a.taxId=s.detail,this.taxIdChanged.emit(s.detail)}}),this.taxIdErrorMessage&&o("zonos-text",{textColor:"red-600",type:"caption"},this.taxIdErrorMessage))}renderShortAddressCodeInput(){var s;if("billing"===this.type)return null;const t=null===(s=a.stripeAddressEventData)||void 0===s?void 0:s.value.address.country;return t&&C({countryCode:t})?o("div",{class:"zonos--short-address-code-input"},o("zonos-stripe-input",{inputLabel:m("Short address code"),inputPlaceholder:"RRRD2929",inputValue:a.shortAddressCode||"",isError:!!this.shortAddressCodeErrorMessage,onInputChange:s=>{a.shortAddressCode=s.detail}}),this.shortAddressCodeErrorMessage&&o("zonos-text",{textColor:"red-600",type:"caption"},this.shortAddressCodeErrorMessage)):null}renderCompanyNameInput(){return("billing"!==this.type||window.Zonos.isCollect||window.Zonos.isInvoice)&&("ENABLED"===b.checkoutSettings.companyFieldsStatus||window.Zonos.isCollect||window.Zonos.isInvoice)?o("zonos-stripe-input",{class:"zonos--company-name-input",inputLabel:m("Company name (optional)"),inputValue:a.companyName,onInputChange:s=>{a.companyName=s.detail}}):null}disconnectedCallback(){const s=this.getStripeAddressInstance().stripeAddressElement;null==s||s.destroy();try{this.storeUnsubscribeList.forEach((s=>s()))}catch(s){}}componentDidLoad(){const s=this.getStripeAddressInstance().stripeAddressEventData;this.isDirtyAddress=!!s&&s.value.address.line1.length>0,this.watchInitStripe(),this.checkoutSessionId=p.checkoutSessionId,this.storeUnsubscribeList=[f("checkoutSessionId",(()=>{this.checkoutSessionId=p.checkoutSessionId})),d("stripeElements",(()=>{"shipping"===this.type&&this.watchInitStripe()})),d("stripeElementsForBillingAddress",(()=>{"billing"===this.type&&this.watchInitStripe()}))]}render(){var s;return this.checkoutSessionId=p.checkoutSessionId,(null===(s=a.stripeAddressEventData)||void 0===s?void 0:s.complete)&&(this.isAddressFilled=!0),o(e,{key:"5dc571d7c5e706ae9cb90de70deee22847e5ba7e",class:I(["zonos--address","zonos--elements",`zonos--${this.type}-address`])},this.titleText&&o("zonos-text",{key:"a7c9f730bc9b64aa2c6e8cc24701e638481eac19",class:"zonos--title",type:"semiBoldLabel"},this.titleText),o("slot",{key:"3078529c201c7947ffc833485d46184bc79ab1d1",name:"below-title"}),this.renderCompanyNameInput(),this.renderTaxIdInput(),this.renderShortAddressCodeInput(),o("div",{key:"b4a9850ac30ad9c483e05743ff41b7de9756d826",class:"zonos--address-component"}))}get el(){return i(this)}static get watchers(){return{checkoutSessionId:["isAddressFilledChanged"],isAddressFilled:["isAddressFilledChanged"],stripe:["watchInitStripe"],defaultAddress:["defaultAddressChanged"]}}};D.style=".sc-zonos-address-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-address-h *.sc-zonos-address{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-address-h img.sc-zonos-address{max-width:100%}.sc-zonos-address-h dl.sc-zonos-address,.sc-zonos-address-h dd.sc-zonos-address,.sc-zonos-address-h h1.sc-zonos-address,.sc-zonos-address-h h2.sc-zonos-address,.sc-zonos-address-h h3.sc-zonos-address,.sc-zonos-address-h h4.sc-zonos-address,.sc-zonos-address-h h5.sc-zonos-address,.sc-zonos-address-h h6.sc-zonos-address,.sc-zonos-address-h hr.sc-zonos-address,.sc-zonos-address-h figure.sc-zonos-address,.sc-zonos-address-h p.sc-zonos-address,.sc-zonos-address-h pre.sc-zonos-address{margin:0}.sc-zonos-address-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-address-h .zonos--title.sc-zonos-address{margin-bottom:16px}.sc-zonos-address-h .zonos--company-name-input.sc-zonos-address,.sc-zonos-address-h .zonos--tax-id-input.sc-zonos-address,.sc-zonos-address-h .zonos--short-address-code-input.sc-zonos-address{margin-bottom:16px}.sc-zonos-address-h zonos-banner.sc-zonos-address{margin-top:8px}";const L=class{constructor(o){s(this,o),this.confirmClicked=t(this,"confirmClicked",7),this.cancelClicked=t(this,"cancelClicked",7),this.dialogTitle=m("Are you sure?"),this.dialogIntent="info",this.dialogSubtitle=null,this.dialogWidth=350,this.dialogType="confirm",this.isMobile=!1,this.noClickOutside=!1,this.clickOutsideDialogHandler=s=>{s.target!==s.currentTarget||this.noClickOutside||this.closeDialogHandler()}}handleKeyDown(s){"Escape"===s.key&&this.closeDialogHandler()}focusDialog(){this.dialogOpen&&setTimeout((()=>{var s,t;null===(t=null===(s=this.el.shadowRoot)||void 0===s?void 0:s.querySelector(".zonos--backdrop"))||void 0===t||t.focus()}),100)}confirmDialogHandler(){this.dialogOpen&&this.confirmClicked.emit()}closeDialogHandler(){this.dialogOpen&&this.cancelClicked.emit()}renderIcon(){switch(this.dialogIntent){case"info":return o("zonos-icon",{content:'<svg color="var(--zonos-elements-blue-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Z" data-is-secondary-color="true" fill="var(--zonos-elements-blue-400)"></path>\n <path d="M10.25 10.25a1.75 1.75 0 1 1 2.431 1.613c-.616.26-1.431.885-1.431 1.887a.75.75 0 0 0 1.5 0c0-.053.02-.128.108-.228.092-.104.236-.205.408-.278A3.25 3.25 0 1 0 8.75 10.25a.75.75 0 0 0 1.5 0Zm2.5 5.75a.75.75 0 0 0-1.5 0v.25a.75.75 0 0 0 1.5 0V16Z" fill="currentColor"></path>\n</svg>',iconColor:"blue-800"});case"danger":return o("zonos-icon",{content:'<svg color="var(--zonos-elements-red-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Z" data-is-secondary-color="true" fill="var(--zonos-elements-red-400)"></path>\n <path d="M12.75 9a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0V9Zm0 5.5a.75.75 0 0 0-1.5 0v.5a.75.75 0 0 0 1.5 0v-.5Z" fill="currentColor"></path>\n</svg>',iconColor:"red-800"});case"warn":return o("zonos-icon",{content:'<svg color="var(--zonos-elements-orange-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M14.46 5.492c-1.014-2.027-3.906-2.027-4.92 0L4.276 16.02c-.914 1.83.416 3.98 2.46 3.98h10.528c2.044 0 3.374-2.151 2.46-3.98L14.46 5.492Z" data-is-secondary-color="true" fill="var(--zonos-elements-orange-400)"></path>\n <path d="M12.75 10a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0V10Zm0 5.5a.75.75 0 0 0-1.5 0v.5a.75.75 0 0 0 1.5 0v-.5Z" fill="currentColor"></path>\n</svg>',iconColor:"orange-800"})}}getButtonConfirmVariant(){switch(this.dialogIntent){case"warn":return"warning";case"danger":return"danger";default:return"primary"}}render(){this.focusDialog();const s=S(),t=g(b.appearance.theme);return o(e,{key:"db0bfe0b8a125e806a97c9382faa938078000349",class:I([this.dialogOpen&&"open","zonos--elements"]),"data-dialog-type":this.dialogType,"data-theme":t,style:{"--zonos--border-radius":s,"--zonos--dialog-width":`${this.dialogWidth}px`,"--zonos--font-family":y()}},o("div",{key:"1676defad54705df4e9282bda6b5734592d0fb60",class:"zonos--backdrop",tabIndex:-1}),o("div",{key:"2a6ec6b5df7ea30304cfed5276e55618b40add93",class:I(["zonos--confirm-layout",this.dialogIntent]),onClick:s=>this.clickOutsideDialogHandler(s)},o("div",{key:"d1c8358c3fd98c27a469fe7443d1983c1c134a7c",class:"zonos--confirm-dialog",onBlur:()=>{this.focusDialog()}},o("div",{key:"137e9659aa7aec2e4604acf80809b35bce69ca79",class:"wrapper"},o("div",{key:"9c1057857ea095e7e88c8950469add2bc4c1318e",class:"icon-wrapper"},this.renderIcon()),o("div",{key:"48f0e0cd9ce62b425bae831d1387261bbd4162a1",class:"content"},o("div",{key:"0d3e681f350e5db547181beadf5c6bcf49a8bbd2",class:"title"},o("zonos-text",{key:"f16a43d2b3c9504911b1e36ba573873f80093c47",type:"subheader"},this.dialogTitle)),this.dialogSubtitle&&o("div",{key:"fd570f98bc736a68c16fedee72b1417dc6906fa6",class:"subtitle"},o("zonos-text",{key:"6785aa19dd44cf7f6fae7317e3924be6c6ee8af3",textColor:"gray-800"},this.dialogSubtitle))),o("div",{key:"4206cad3dcff0055fc5f3ea8e7c217ae33c63263",class:"footer"},"confirm"===this.dialogType&&o("zonos-button",{key:"72d1a216641d482bdbeae384963dcdff1cfc3f45",backgroundColor:"gray-0",class:"cancel-button",onClick:()=>this.closeDialogHandler(),size:"lg",withBoxShadow:!0},this.dialogCancelBtnText||m("Cancel")),o("zonos-button",{key:"a6a206eff11d1f42c33ef9113cc393d727c60f89",class:"confirm-button",onClick:()=>this.confirmDialogHandler(),size:"lg",variant:this.getButtonConfirmVariant()},this.dialogConfirmBtnText))))))}static get assetsDirs(){return["assets"]}get el(){return i(this)}};L.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 .zonos--backdrop,:host .zonos--confirm-layout{opacity:0;z-index:-999;visibility:hidden;-webkit-transition:opacity 0.3s, visibility 0.3s;transition:opacity 0.3s, visibility 0.3s}:host .zonos--backdrop{width:100vw;height:100vh;left:0;top:0;background:var(--zonos-elements-backdrop-color);position:fixed}:host .zonos--confirm-layout{width:100vw;height:100vh;left:0;top:0;position:fixed;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;color:var(--zonos-elements-text-color)}:host .zonos--confirm-dialog{position:relative;background:var(--zonos-elements-gray-0);max-width:90vw;max-height:90vh;width:var(--zonos--dialog-width);border-radius:var(--zonos--border-radius, 10px);outline:none;-webkit-box-shadow:var(--zonos-elements-v3-shadow-xxl);box-shadow:var(--zonos-elements-v3-shadow-xxl);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}:host .wrapper{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:24px;gap:24px}:host .icon-wrapper{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;height:40px;width:40px;border-radius:50%;background:var(--zonos-elements-blue-100)}:host .warn .icon-wrapper{background:var(--zonos-elements-orange-100)}:host .danger .icon-wrapper{background:var(--zonos-elements-red-100)}:host .footer{display:-ms-flexbox;display:flex;width:100%;gap:8px}:host .footer zonos-button{-ms-flex:1;flex:1}:host .content{display:-ms-flexbox;display:flex;gap:8px;-ms-flex-direction:column;flex-direction:column}:host .content zonos-text{text-align:center}:host(.open) .zonos--confirm-layout,:host(.open) .zonos--backdrop{visibility:visible}:host(.open) .zonos--backdrop{z-index:2147483009;opacity:0.65}:host(.open) .zonos--confirm-layout{opacity:1;z-index:2147483010;-webkit-transform:scale(1);transform:scale(1)}";const N=s=>/^[a-zA-Z0-9.%_+-]*@[a-zA-Z0-9][a-zA-Z0-9.-]*\.[a-zA-Z0-9]{2,}$/.test(s),Z=class{constructor(o){s(this,o),this.linkAuthenticationChange=t(this,"linkAuthenticationChange",7),this.storeUnsubscribeList=[],this.defaultEmail=null,this.isEmailError=!1,this.stripe=a.stripe,this.isStagingMode=h.isStagingMode,this.clientSecret=a.clientSecret,this.retriesInitializeLink=0,this.setCustomEmailInputToLinkEvent=s=>{const t=N(s);a.stripeLinkEventData={complete:!!t,elementType:"linkAuthentication",empty:!s,value:{email:s}}},this.handleNormalEmailInput=s=>{var t;this.setCustomEmailInputToLinkEvent(s.detail),null===(t=this.linkAuthenticationChange)||void 0===t||t.emit()}}watchIsStagingMode(){setTimeout((()=>{this.watchInitStripe()}),0)}async watchInitStripe(){if(!this.stripe||!a.stripeElements)return;if(h.isStagingMode||!this.clientSecret)return;const s=this.defaultEmail?{email:this.defaultEmail}:void 0;try{const t=a.stripeLinkElement||a.stripeElements.create("linkAuthentication",{defaultValues:s}),o=this.el.querySelector(".zonos--link-authentication-component");if(!o)return void v("Cannot find container element for linkAuthenticationElement");t.mount(o),t.on("change",(s=>{var t;a.stripeLinkEventData=s,null===(t=this.linkAuthenticationChange)||void 0===t||t.emit()})),a.stripeLinkElement=t,this.retriesInitializeLink=0,this.retriesInitializeLink>11&&(A("Stripe link element initialized","info",{retriesInitializeLink:this.retriesInitializeLink,stripe:this.stripe}),x({endpoint:"stripe-link-authentication-init-long-running",errors:["Stripe link element initialized after 20 retries - 10 seconds"],metadata:{retriesInitializeLink:this.retriesInitializeLink}}))}catch(s){s instanceof Error&&(this.retriesInitializeLink++,this.retriesInitializeLink<51&&(await new Promise((s=>setTimeout(s,500))),this.watchInitStripe()),51===this.retriesInitializeLink&&x({endpoint:"stripe-link-authentication-init-error",errors:[s.message],metadata:{retriesInitializeLink:this.retriesInitializeLink}}))}}watchDefaultEmail(s,t){var o,e;A("Default email is changed","info",{newDefaultEmail:s,oldDefaultEmail:t}),t!==s&&(s||(a.stripeLinkEventData=null),h.isStagingMode?this.setCustomEmailInputToLinkEvent(s||""):(null===(o=a.stripeLinkElement)||void 0===o||o.clear(),null===(e=a.stripeLinkElement)||void 0===e||e.destroy(),a.stripeLinkElement=null,a.stripeLinkEventData=null,A("Reset stripe link element when default email is changed","info",{defaultEmail:s}),this.watchInitStripe()))}disconnectedCallback(){try{this.storeUnsubscribeList.forEach((s=>s()))}catch(s){}}componentDidLoad(){this.storeUnsubscribeList=[d("stripeElements",(async()=>{this.watchInitStripe()})),d("clientSecret",(async()=>{this.clientSecret=a.clientSecret})),d("stripe",(async()=>{this.stripe=a.stripe}))],this.watchInitStripe(),this.defaultEmail&&this.setCustomEmailInputToLinkEvent(this.defaultEmail)}render(){return this.isStagingMode=h.isStagingMode,this.clientSecret=a.clientSecret,o(e,{class:"zonos--link-authentication zonos--elements",style:{"--zonos--border-radius":S()}},this.titleText&&o("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),(()=>{var s;return h.isStagingMode?o("zonos-stripe-input",{inputLabel:m("Email"),inputValue:this.defaultEmail||(null===(s=a.stripeLinkEventData)||void 0===s?void 0:s.value.email)||"",isError:this.isEmailError,onBlur:()=>{var s;const t=(null===(s=a.stripeLinkEventData)||void 0===s?void 0:s.value.email)||"";if(!t)return;const o=N(t);this.isEmailError=!o},onInputChange:this.handleNormalEmailInput}):o("div",{class:`zonos--link-authentication-component ${this.isEmailError&&"zonos--input-invalid"}`})})(),this.isEmailError&&o("zonos-text",{textColor:"red-600"},m("Please enter a valid email address.")))}get el(){return i(this)}static get watchers(){return{isStagingMode:["watchIsStagingMode"],stripe:["watchInitStripe"],clientSecret:["watchInitStripe"],defaultEmail:["watchDefaultEmail"]}}};Z.style=".sc-zonos-link-authentication-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-link-authentication-h *.sc-zonos-link-authentication{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-link-authentication-h img.sc-zonos-link-authentication{max-width:100%}.sc-zonos-link-authentication-h dl.sc-zonos-link-authentication,.sc-zonos-link-authentication-h dd.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h1.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h2.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h3.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h4.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h5.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h6.sc-zonos-link-authentication,.sc-zonos-link-authentication-h hr.sc-zonos-link-authentication,.sc-zonos-link-authentication-h figure.sc-zonos-link-authentication,.sc-zonos-link-authentication-h p.sc-zonos-link-authentication,.sc-zonos-link-authentication-h pre.sc-zonos-link-authentication{margin:0}.sc-zonos-link-authentication-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-link-authentication-h .zonos--title.sc-zonos-link-authentication{margin-bottom:16px}.sc-zonos-link-authentication-h .zonos--input-invalid.sc-zonos-link-authentication{border:2px solid var(--zonos-elements-red-600);border-radius:var(--zonos--border-radius)}";const B=class{constructor(t){s(this,t),this.open=!1,this.size=40}render(){return o(e,{key:"13154a3c9250f15d8dca292f0673c6465bfb15e0",class:I(["zonos--elements",this.open&&"zonos--open"])},o("div",{key:"4470fccd21e58bd7959ef3e20c8775ac637cace0",class:"zonos--loading-overlay"},o("zonos-spinner",{key:"5b32b821cea982866da56176eeaafd5d8958f25d",size:this.size,spinnerColor:this.spinnerColor})))}};B.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{position:fixed;inset:0;z-index:2147483010;pointer-events:none;display:block}:host .zonos--loading-overlay{position:fixed;inset:0;width:100vw;height:100vh;background:var(--zonos-elements-backdrop-color);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;opacity:0;visibility:hidden;-webkit-transition:opacity 0.3s ease, visibility 0.3s ease;transition:opacity 0.3s ease, visibility 0.3s ease;z-index:2147483010}:host(.zonos--open){pointer-events:auto}:host(.zonos--open) .zonos--loading-overlay{opacity:0.65;visibility:visible}";export{D as zonos_address,L as zonos_confirm_dialog,Z as zonos_link_authentication,B as zonos_loading_overlay}
1
+ import{r as s,d as t,h as o,a as e,g as i}from"./p-ce75b047.js";import{t as n}from"./p-7d7ffb42.js";import{b as a,t as r,Q as l,E as d,q as c,d as h}from"./p-dafafa07.js";import{s as p,r as u,t as f,q as m,l as z}from"./p-3ac97c01.js";import{z as b,g,f as y}from"./p-058f6124.js";import{l as v,i as k,s as x}from"./p-41dd1cb8.js";import{a as w,s as C}from"./p-63a383f4.js";import{c as I}from"./p-b4b7f705.js";import{l as A}from"./p-0a377722.js";import{c as E,s as j}from"./p-6b361d2b.js";import{g as S}from"./p-f830f800.js";import"./p-908f13ae.js";import"./p-67897a0d.js";import"./p-1d42cd20.js";const D=class{constructor(o){s(this,o),this.invalidCharacters=t(this,"invalidCharacters",7),this.taxIdChanged=t(this,"taxIdChanged",7),this.storeUnsubscribeList=[],this.isAutoCompleteAdjusted=!1,this.defaultAddress=[],this.taxIdErrorMessage="",this.shortAddressCodeErrorMessage="",this.stripe=window.Zonos.stripe,this.isDirtyAddress=!1,this.isAddressFilled=!1,this.checkoutSessionId=p.checkoutSessionId,this.prevCountry=null,this.prevPostalCode=null,this.trackingSent=!1,this.prefetchLandedCost=n(c,1e3)}getStripeAddressInstance(){return"billing"===this.type?{stripeAddressElement:a.stripeBillingAddressElement,stripeAddressEventData:a.stripeBillingAddressEventData,stripeElements:a.stripeElementsForBillingAddress}:{stripeAddressElement:a.stripeAddressElement,stripeAddressEventData:a.stripeAddressEventData,stripeElements:a.stripeElements}}updateAddressEventData({event:s,type:t}){"billing"===t?a.stripeBillingAddressEventData=s:a.stripeAddressEventData=s,"shipping"===t&&s.value.address.line1.length&&this.prefetchLandedCost()}isAddressFilledChanged(){p.checkoutSessionId&&this.isAddressFilled&&!this.trackingSent&&"shipping"===this.type&&(this.trackingSent=!0,r({checkoutSessionId:p.checkoutSessionId,eventName:"checkout_customerInfoFilled"}))}updateAddressElement({stripeAddressElement:s,type:t}){"shipping"!==t?a.stripeBillingAddressElement=s:a.stripeAddressElement=s}async watchInitStripe(){this.stripe=window.Zonos.stripe;const{stripeAddressEventData:s,stripeElements:t}=this.getStripeAddressInstance();if(!this.stripe||!t)return void v("Stripe is not initialized. Couldn't load stripe element.");const o=this.defaultAddress.map((s=>Object.assign(Object.assign({},s),{name:s.name,phone:s.phone||void 0}))),e=z.shippingZoneCountries,i=e?Object.values(e).map((s=>s.code)):[],n=new URLSearchParams(window.location.search).has("zonosCheckoutAllCountries"),a="shipping"===this.type?i:[],r=(null==s?void 0:s.value.address.country)||u(a);A(`Stripe country code: ${r}`,"info");const d=t.create("address",{allowedCountries:n?[]:a,contacts:o.length&&!s?this.defaultAddress:[],defaultValues:{address:Object.assign(Object.assign({},null==s?void 0:s.value.address),{country:r}),firstName:null==s?void 0:s.value.firstName,lastName:null==s?void 0:s.value.lastName,phone:null==s?void 0:s.value.phone},display:{name:"split"},fields:{phone:"always"},mode:this.type,validation:{phone:{required:"always"}}});d.mount(this.el.querySelector(".zonos--address-component")),(null==s?void 0:s.value.address)&&(this.prevCountry=s.value.address.country,this.prevPostalCode=s.value.address.postal_code),d.on("change",(s=>{const t=s.value;if(!this.isDirtyAddress&&t.address.line1.length>=3){if(this.isDirtyAddress=!0,!this.isAutoCompleteAdjusted){const s=this.el.querySelector('iframe[src*="autocomplete-suggestions"]');s&&(s.style.zIndex="3"),this.isAutoCompleteAdjusted=!0}setTimeout((()=>{if(k())this.el.scrollIntoView({behavior:"smooth",block:"end"});else{const s="shipping"===this.type?100:600,t=this.el.closest(".zonos--group"),o=this.el.getBoundingClientRect().top+s;null==t||t.scrollTo({behavior:"smooth",top:o})}}),600)}const{firstName:o,lastName:e}=l({firstName:t.firstName,lastName:t.lastName,name:t.name});this.updateAddressEventData({event:Object.assign(Object.assign({},s),{elementMode:this.type,elementType:"address",value:Object.assign(Object.assign({},t),{firstName:o,lastName:e})}),type:this.type})})),this.updateAddressElement({stripeAddressElement:d,type:this.type})}defaultAddressChanged(s,t){if(JSON.stringify(t)===JSON.stringify(s))return;A("Reset address element when default address property is changed","info",{defaultAddress:this.defaultAddress});const o=this.getStripeAddressInstance().stripeAddressElement;null==o||o.clear(),null==o||o.destroy(),"shipping"===this.type?a.stripeAddressEventData=null:a.stripeBillingAddressEventData=null,this.watchInitStripe()}isInTaxIdCountry(s){return E.includes(s)}renderTaxIdInput(){var s;if("billing"===this.type)return null;const t=null===(s=a.stripeAddressEventData)||void 0===s?void 0:s.value.address.country;if(!t)return null;if(!this.isInTaxIdCountry(t))return null;if(!w({companyName:a.companyName,countryCode:t}))return null;const e=j[t];return o("div",{class:"zonos--tax-id-input"},o("zonos-stripe-input",{inputLabel:f(e.friendlyName),inputPlaceholder:e.placeholder,inputValue:a.taxId||"",isError:!!this.taxIdErrorMessage,onInputChange:s=>{a.taxId=s.detail,this.taxIdChanged.emit(s.detail)}}),this.taxIdErrorMessage&&o("zonos-text",{textColor:"red-600",type:"caption"},this.taxIdErrorMessage))}renderShortAddressCodeInput(){var s;if("billing"===this.type)return null;const t=null===(s=a.stripeAddressEventData)||void 0===s?void 0:s.value.address.country;return t&&C({countryCode:t})?o("div",{class:"zonos--short-address-code-input"},o("zonos-stripe-input",{inputLabel:f("Short address code"),inputPlaceholder:"RRRD2929",inputValue:a.shortAddressCode||"",isError:!!this.shortAddressCodeErrorMessage,onInputChange:s=>{a.shortAddressCode=s.detail}}),this.shortAddressCodeErrorMessage&&o("zonos-text",{textColor:"red-600",type:"caption"},this.shortAddressCodeErrorMessage)):null}renderCompanyNameInput(){return("billing"!==this.type||window.Zonos.isCollect||window.Zonos.isInvoice)&&("ENABLED"===b.checkoutSettings.companyFieldsStatus||window.Zonos.isCollect||window.Zonos.isInvoice)?o("zonos-stripe-input",{class:"zonos--company-name-input",inputLabel:f("Company name (optional)"),inputValue:a.companyName,onInputChange:s=>{a.companyName=s.detail}}):null}disconnectedCallback(){const s=this.getStripeAddressInstance().stripeAddressElement;null==s||s.destroy();try{this.storeUnsubscribeList.forEach((s=>s()))}catch(s){}}componentDidLoad(){const s=this.getStripeAddressInstance().stripeAddressEventData;this.isDirtyAddress=!!s&&s.value.address.line1.length>0,this.watchInitStripe(),this.checkoutSessionId=p.checkoutSessionId,this.storeUnsubscribeList=[m("checkoutSessionId",(()=>{this.checkoutSessionId=p.checkoutSessionId})),d("stripeElements",(()=>{"shipping"===this.type&&this.watchInitStripe()})),d("stripeElementsForBillingAddress",(()=>{"billing"===this.type&&this.watchInitStripe()}))]}render(){var s;return this.checkoutSessionId=p.checkoutSessionId,(null===(s=a.stripeAddressEventData)||void 0===s?void 0:s.complete)&&(this.isAddressFilled=!0),o(e,{key:"5dc571d7c5e706ae9cb90de70deee22847e5ba7e",class:I(["zonos--address","zonos--elements",`zonos--${this.type}-address`])},this.titleText&&o("zonos-text",{key:"a7c9f730bc9b64aa2c6e8cc24701e638481eac19",class:"zonos--title",type:"semiBoldLabel"},this.titleText),o("slot",{key:"3078529c201c7947ffc833485d46184bc79ab1d1",name:"below-title"}),this.renderCompanyNameInput(),this.renderTaxIdInput(),this.renderShortAddressCodeInput(),o("div",{key:"b4a9850ac30ad9c483e05743ff41b7de9756d826",class:"zonos--address-component"}))}get el(){return i(this)}static get watchers(){return{checkoutSessionId:["isAddressFilledChanged"],isAddressFilled:["isAddressFilledChanged"],stripe:["watchInitStripe"],defaultAddress:["defaultAddressChanged"]}}};D.style=".sc-zonos-address-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-address-h *.sc-zonos-address{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-address-h img.sc-zonos-address{max-width:100%}.sc-zonos-address-h dl.sc-zonos-address,.sc-zonos-address-h dd.sc-zonos-address,.sc-zonos-address-h h1.sc-zonos-address,.sc-zonos-address-h h2.sc-zonos-address,.sc-zonos-address-h h3.sc-zonos-address,.sc-zonos-address-h h4.sc-zonos-address,.sc-zonos-address-h h5.sc-zonos-address,.sc-zonos-address-h h6.sc-zonos-address,.sc-zonos-address-h hr.sc-zonos-address,.sc-zonos-address-h figure.sc-zonos-address,.sc-zonos-address-h p.sc-zonos-address,.sc-zonos-address-h pre.sc-zonos-address{margin:0}.sc-zonos-address-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-address-h .zonos--title.sc-zonos-address{margin-bottom:16px}.sc-zonos-address-h .zonos--company-name-input.sc-zonos-address,.sc-zonos-address-h .zonos--tax-id-input.sc-zonos-address,.sc-zonos-address-h .zonos--short-address-code-input.sc-zonos-address{margin-bottom:16px}.sc-zonos-address-h zonos-banner.sc-zonos-address{margin-top:8px}";const L=class{constructor(o){s(this,o),this.confirmClicked=t(this,"confirmClicked",7),this.cancelClicked=t(this,"cancelClicked",7),this.dialogTitle=f("Are you sure?"),this.dialogIntent="info",this.dialogSubtitle=null,this.dialogWidth=350,this.dialogType="confirm",this.isMobile=!1,this.noClickOutside=!1,this.clickOutsideDialogHandler=s=>{s.target!==s.currentTarget||this.noClickOutside||this.closeDialogHandler()}}handleKeyDown(s){"Escape"===s.key&&this.closeDialogHandler()}focusDialog(){this.dialogOpen&&setTimeout((()=>{var s,t;null===(t=null===(s=this.el.shadowRoot)||void 0===s?void 0:s.querySelector(".zonos--backdrop"))||void 0===t||t.focus()}),100)}confirmDialogHandler(){this.dialogOpen&&this.confirmClicked.emit()}closeDialogHandler(){this.dialogOpen&&this.cancelClicked.emit()}renderIcon(){switch(this.dialogIntent){case"info":return o("zonos-icon",{content:'<svg color="var(--zonos-elements-blue-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Z" data-is-secondary-color="true" fill="var(--zonos-elements-blue-400)"></path>\n <path d="M10.25 10.25a1.75 1.75 0 1 1 2.431 1.613c-.616.26-1.431.885-1.431 1.887a.75.75 0 0 0 1.5 0c0-.053.02-.128.108-.228.092-.104.236-.205.408-.278A3.25 3.25 0 1 0 8.75 10.25a.75.75 0 0 0 1.5 0Zm2.5 5.75a.75.75 0 0 0-1.5 0v.25a.75.75 0 0 0 1.5 0V16Z" fill="currentColor"></path>\n</svg>',iconColor:"blue-800"});case"danger":return o("zonos-icon",{content:'<svg color="var(--zonos-elements-red-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Z" data-is-secondary-color="true" fill="var(--zonos-elements-red-400)"></path>\n <path d="M12.75 9a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0V9Zm0 5.5a.75.75 0 0 0-1.5 0v.5a.75.75 0 0 0 1.5 0v-.5Z" fill="currentColor"></path>\n</svg>',iconColor:"red-800"});case"warn":return o("zonos-icon",{content:'<svg color="var(--zonos-elements-orange-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" style="display: block;">\n <path d="M14.46 5.492c-1.014-2.027-3.906-2.027-4.92 0L4.276 16.02c-.914 1.83.416 3.98 2.46 3.98h10.528c2.044 0 3.374-2.151 2.46-3.98L14.46 5.492Z" data-is-secondary-color="true" fill="var(--zonos-elements-orange-400)"></path>\n <path d="M12.75 10a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0V10Zm0 5.5a.75.75 0 0 0-1.5 0v.5a.75.75 0 0 0 1.5 0v-.5Z" fill="currentColor"></path>\n</svg>',iconColor:"orange-800"})}}getButtonConfirmVariant(){switch(this.dialogIntent){case"warn":return"warning";case"danger":return"danger";default:return"primary"}}render(){this.focusDialog();const s=S(),t=g(b.appearance.theme);return o(e,{key:"db0bfe0b8a125e806a97c9382faa938078000349",class:I([this.dialogOpen&&"open","zonos--elements"]),"data-dialog-type":this.dialogType,"data-theme":t,style:{"--zonos--border-radius":s,"--zonos--dialog-width":`${this.dialogWidth}px`,"--zonos--font-family":y()}},o("div",{key:"1676defad54705df4e9282bda6b5734592d0fb60",class:"zonos--backdrop",tabIndex:-1}),o("div",{key:"2a6ec6b5df7ea30304cfed5276e55618b40add93",class:I(["zonos--confirm-layout",this.dialogIntent]),onClick:s=>this.clickOutsideDialogHandler(s)},o("div",{key:"d1c8358c3fd98c27a469fe7443d1983c1c134a7c",class:"zonos--confirm-dialog",onBlur:()=>{this.focusDialog()}},o("div",{key:"137e9659aa7aec2e4604acf80809b35bce69ca79",class:"wrapper"},o("div",{key:"9c1057857ea095e7e88c8950469add2bc4c1318e",class:"icon-wrapper"},this.renderIcon()),o("div",{key:"48f0e0cd9ce62b425bae831d1387261bbd4162a1",class:"content"},o("div",{key:"0d3e681f350e5db547181beadf5c6bcf49a8bbd2",class:"title"},o("zonos-text",{key:"f16a43d2b3c9504911b1e36ba573873f80093c47",type:"subheader"},this.dialogTitle)),this.dialogSubtitle&&o("div",{key:"fd570f98bc736a68c16fedee72b1417dc6906fa6",class:"subtitle"},o("zonos-text",{key:"6785aa19dd44cf7f6fae7317e3924be6c6ee8af3",textColor:"gray-800"},this.dialogSubtitle))),o("div",{key:"4206cad3dcff0055fc5f3ea8e7c217ae33c63263",class:"footer"},"confirm"===this.dialogType&&o("zonos-button",{key:"72d1a216641d482bdbeae384963dcdff1cfc3f45",backgroundColor:"gray-0",class:"cancel-button",onClick:()=>this.closeDialogHandler(),size:"lg",withBoxShadow:!0},this.dialogCancelBtnText||f("Cancel")),o("zonos-button",{key:"a6a206eff11d1f42c33ef9113cc393d727c60f89",class:"confirm-button",onClick:()=>this.confirmDialogHandler(),size:"lg",variant:this.getButtonConfirmVariant()},this.dialogConfirmBtnText))))))}static get assetsDirs(){return["assets"]}get el(){return i(this)}};L.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 .zonos--backdrop,:host .zonos--confirm-layout{opacity:0;z-index:-999;visibility:hidden;-webkit-transition:opacity 0.3s, visibility 0.3s;transition:opacity 0.3s, visibility 0.3s}:host .zonos--backdrop{width:100vw;height:100vh;left:0;top:0;background:var(--zonos-elements-backdrop-color);position:fixed}:host .zonos--confirm-layout{width:100vw;height:100vh;left:0;top:0;position:fixed;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;color:var(--zonos-elements-text-color)}:host .zonos--confirm-dialog{position:relative;background:var(--zonos-elements-gray-0);max-width:90vw;max-height:90vh;width:var(--zonos--dialog-width);border-radius:var(--zonos--border-radius, 10px);outline:none;-webkit-box-shadow:var(--zonos-elements-v3-shadow-xxl);box-shadow:var(--zonos-elements-v3-shadow-xxl);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}:host .wrapper{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:24px;gap:24px}:host .icon-wrapper{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;height:40px;width:40px;border-radius:50%;background:var(--zonos-elements-blue-100)}:host .warn .icon-wrapper{background:var(--zonos-elements-orange-100)}:host .danger .icon-wrapper{background:var(--zonos-elements-red-100)}:host .footer{display:-ms-flexbox;display:flex;width:100%;gap:8px}:host .footer zonos-button{-ms-flex:1;flex:1}:host .content{display:-ms-flexbox;display:flex;gap:8px;-ms-flex-direction:column;flex-direction:column}:host .content zonos-text{text-align:center}:host(.open) .zonos--confirm-layout,:host(.open) .zonos--backdrop{visibility:visible}:host(.open) .zonos--backdrop{z-index:2147483009;opacity:0.65}:host(.open) .zonos--confirm-layout{opacity:1;z-index:2147483010;-webkit-transform:scale(1);transform:scale(1)}";const N=s=>/^[a-zA-Z0-9.%_+-]*@[a-zA-Z0-9][a-zA-Z0-9.-]*\.[a-zA-Z0-9]{2,}$/.test(s),Z=class{constructor(o){s(this,o),this.linkAuthenticationChange=t(this,"linkAuthenticationChange",7),this.storeUnsubscribeList=[],this.defaultEmail=null,this.isEmailError=!1,this.stripe=a.stripe,this.isStagingMode=h.isStagingMode,this.clientSecret=a.clientSecret,this.retriesInitializeLink=0,this.setCustomEmailInputToLinkEvent=s=>{const t=N(s);a.stripeLinkEventData={complete:!!t,elementType:"linkAuthentication",empty:!s,value:{email:s}}},this.handleNormalEmailInput=s=>{var t;this.setCustomEmailInputToLinkEvent(s.detail),null===(t=this.linkAuthenticationChange)||void 0===t||t.emit()}}watchIsStagingMode(){setTimeout((()=>{this.watchInitStripe()}),0)}async watchInitStripe(){if(!this.stripe||!a.stripeElements)return;if(h.isStagingMode||!this.clientSecret)return;const s=this.defaultEmail?{email:this.defaultEmail}:void 0;try{const t=a.stripeLinkElement||a.stripeElements.create("linkAuthentication",{defaultValues:s}),o=this.el.querySelector(".zonos--link-authentication-component");if(!o)return void v("Cannot find container element for linkAuthenticationElement");t.mount(o),t.on("change",(s=>{var t;a.stripeLinkEventData=s,null===(t=this.linkAuthenticationChange)||void 0===t||t.emit()})),a.stripeLinkElement=t,this.retriesInitializeLink=0,this.retriesInitializeLink>11&&(A("Stripe link element initialized","info",{retriesInitializeLink:this.retriesInitializeLink,stripe:this.stripe}),x({endpoint:"stripe-link-authentication-init-long-running",errors:["Stripe link element initialized after 20 retries - 10 seconds"],metadata:{retriesInitializeLink:this.retriesInitializeLink}}))}catch(s){s instanceof Error&&(this.retriesInitializeLink++,this.retriesInitializeLink<51&&(await new Promise((s=>setTimeout(s,500))),this.watchInitStripe()),51===this.retriesInitializeLink&&x({endpoint:"stripe-link-authentication-init-error",errors:[s.message],metadata:{retriesInitializeLink:this.retriesInitializeLink}}))}}watchDefaultEmail(s,t){var o,e;A("Default email is changed","info",{newDefaultEmail:s,oldDefaultEmail:t}),t!==s&&(s||(a.stripeLinkEventData=null),h.isStagingMode?this.setCustomEmailInputToLinkEvent(s||""):(null===(o=a.stripeLinkElement)||void 0===o||o.clear(),null===(e=a.stripeLinkElement)||void 0===e||e.destroy(),a.stripeLinkElement=null,a.stripeLinkEventData=null,A("Reset stripe link element when default email is changed","info",{defaultEmail:s}),this.watchInitStripe()))}disconnectedCallback(){try{this.storeUnsubscribeList.forEach((s=>s()))}catch(s){}}componentDidLoad(){this.storeUnsubscribeList=[d("stripeElements",(async()=>{this.watchInitStripe()})),d("clientSecret",(async()=>{this.clientSecret=a.clientSecret})),d("stripe",(async()=>{this.stripe=a.stripe}))],this.watchInitStripe(),this.defaultEmail&&this.setCustomEmailInputToLinkEvent(this.defaultEmail)}render(){return this.isStagingMode=h.isStagingMode,this.clientSecret=a.clientSecret,o(e,{class:"zonos--link-authentication zonos--elements",style:{"--zonos--border-radius":S()}},this.titleText&&o("zonos-text",{class:"zonos--title",type:"semiBoldLabel"},this.titleText),(()=>{var s;return h.isStagingMode?o("zonos-stripe-input",{inputLabel:f("Email"),inputValue:this.defaultEmail||(null===(s=a.stripeLinkEventData)||void 0===s?void 0:s.value.email)||"",isError:this.isEmailError,onBlur:()=>{var s;const t=(null===(s=a.stripeLinkEventData)||void 0===s?void 0:s.value.email)||"";if(!t)return;const o=N(t);this.isEmailError=!o},onInputChange:this.handleNormalEmailInput}):o("div",{class:`zonos--link-authentication-component ${this.isEmailError&&"zonos--input-invalid"}`})})(),this.isEmailError&&o("zonos-text",{textColor:"red-600"},f("Please enter a valid email address.")))}get el(){return i(this)}static get watchers(){return{isStagingMode:["watchIsStagingMode"],stripe:["watchInitStripe"],clientSecret:["watchInitStripe"],defaultEmail:["watchDefaultEmail"]}}};Z.style=".sc-zonos-link-authentication-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-link-authentication-h *.sc-zonos-link-authentication{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-link-authentication-h img.sc-zonos-link-authentication{max-width:100%}.sc-zonos-link-authentication-h dl.sc-zonos-link-authentication,.sc-zonos-link-authentication-h dd.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h1.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h2.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h3.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h4.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h5.sc-zonos-link-authentication,.sc-zonos-link-authentication-h h6.sc-zonos-link-authentication,.sc-zonos-link-authentication-h hr.sc-zonos-link-authentication,.sc-zonos-link-authentication-h figure.sc-zonos-link-authentication,.sc-zonos-link-authentication-h p.sc-zonos-link-authentication,.sc-zonos-link-authentication-h pre.sc-zonos-link-authentication{margin:0}.sc-zonos-link-authentication-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-link-authentication-h .zonos--title.sc-zonos-link-authentication{margin-bottom:16px}.sc-zonos-link-authentication-h .zonos--input-invalid.sc-zonos-link-authentication{border:2px solid var(--zonos-elements-red-600);border-radius:var(--zonos--border-radius)}";const B=class{constructor(t){s(this,t),this.open=!1,this.size=40}render(){return o(e,{key:"13154a3c9250f15d8dca292f0673c6465bfb15e0",class:I(["zonos--elements",this.open&&"zonos--open"])},o("div",{key:"4470fccd21e58bd7959ef3e20c8775ac637cace0",class:"zonos--loading-overlay"},o("zonos-spinner",{key:"5b32b821cea982866da56176eeaafd5d8958f25d",size:this.size,spinnerColor:this.spinnerColor})))}};B.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{position:fixed;inset:0;z-index:2147483010;pointer-events:none;display:block}:host .zonos--loading-overlay{position:fixed;inset:0;width:100vw;height:100vh;background:var(--zonos-elements-backdrop-color);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;opacity:0;visibility:hidden;-webkit-transition:opacity 0.3s ease, visibility 0.3s ease;transition:opacity 0.3s ease, visibility 0.3s ease;z-index:2147483010}:host(.zonos--open){pointer-events:auto}:host(.zonos--open) .zonos--loading-overlay{opacity:0.65;visibility:visible}";export{D as zonos_address,L as zonos_confirm_dialog,Z as zonos_link_authentication,B as zonos_loading_overlay}
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,r,n,t){function o(e){return e instanceof n?e:new n((function(r){r(e)}))}return new(n||(n=Promise))((function(n,i){function a(e){try{u(t.next(e))}catch(e){i(e)}}function s(e){try{u(t["throw"](e))}catch(e){i(e)}}function u(e){e.done?n(e.value):o(e.value).then(a,s)}u((t=t.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(n=0)),n)try{if(t=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:n.label++;return{value:s[1],done:false};case 5:n.label++;o=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){n.label=s[1];break}if(s[0]===6&&n.label<i[1]){n.label=i[1];i=s;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(s);break}if(i[2])n.ops.pop();n.trys.pop();continue}s=r.call(e,n)}catch(e){s=[6,e];o=0}finally{t=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,r,n){if(n||arguments.length===2)for(var t=0,o=r.length,i;t<o;t++){if(i||!(t in r)){if(!i)i=Array.prototype.slice.call(r,0,t);i[t]=r[t]}}return e.concat(i||Array.prototype.slice.call(r))};System.register(["./p-ac30b7a8.system.js","./p-cf69bcc4.system.js","./p-d938f42f.system.js","./p-01174496.system.js","./p-d18a2b2c.system.js","./p-7501c637.system.js"],(function(e){"use strict";var r,n,t,o,i,a,s,u,d,l,c,v,f,m,p,h,w,g,y;return{setters:[function(e){r=e.c;n=e.z},function(e){t=e.s;o=e.l;i=e.e;a=e.t;s=e.f;u=e.b},function(e){d=e.l;l=e.b},function(e){c=e.h;v=e.l;f=e.f;m=e.g;p=e.a;h=e.s;w=e.j},function(e){g=e.i},function(e){y=e.g}],execute:function(){var b=this;var _=function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o;return __generator(this,(function(i){switch(i.label){case 0:if(!t.checkoutSessionId){return[2,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",t.checkoutSessionId);return[4,c("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:r=i.sent(),n=r.errors,o=r.json;return[2,{errors:n,json:o}]}}))}))};var S=r((function(){return{amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:false,isEnabled:false,orderIdCreated:null,remainingBalance:null,useFullBalance:true}})),O=S.onChange,A=S.reset,C=S.state;e("N",C);var k=e("O",(function(){A()}));var I=function(e){d("Store credit balance from session","info",e);C.availableBalance=e};var T=e("Z",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:return[4,_()];case 1:n=a.sent(),t=n.errors,o=n.json;if(t.length||!o){v("Failed to refresh store credit balance");return[2]}i=(r=(e=o.checkoutSession.customerProfile)===null||e===void 0?void 0:e.storeCreditBalance)!==null&&r!==void 0?r:null;I(i);return[2]}}))}))}));var E=e("w",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,s;return __generator(this,(function(l){switch(l.label){case 0:r=t.checkoutSessionId;if(!r){n="No checkout session found";v(n);C.error=n;return[2,{error:n,success:false}]}d("Applying store credit","info",{checkoutSessionId:r});C.isApplying=true;C.error=null;l.label=1;case 1:l.trys.push([1,3,,4]);return[4,c("/api/zonos-elements/store-credit/apply",{body:{checkoutSessionId:r},method:"POST"})];case 2:o=l.sent(),i=o.errors,a=o.json;if(i.length>0||!a){s=((e=i[0])===null||e===void 0?void 0:e.message)||"Failed to apply store credit";v(s);C.error=s;C.isApplying=false;return[2,{error:s,success:false}]}C.appliedAmount=a.amountApplied;C.remainingBalance=a.remainingBalance;C.isApplying=false;d("Store credit applied","info",{amountApplied:a.amountApplied,remainingBalance:a.remainingBalance});return[2,{error:null,success:true}];case 3:u=l.sent();s=u instanceof Error?u.message:"Failed to apply store credit";v(s);C.error=s;C.isApplying=false;return[2,{error:s,success:false}];case 4:return[2]}}))}))}));var N=e("V",(function(e){C.isEnabled=e;C.error=null;if(!e){C.amountToApply=null}}));var j=e("Y",(function(e){if(e===null){C.amountToApply=null;C.error=null;return}if(e<=0){C.error="Amount must be greater than zero";return}if(C.availableBalance!==null&&e>C.availableBalance){C.error="Amount exceeds available balance";return}var r=ze.total+(ze.storeCredit||0);if(e>r){C.error="Amount exceeds order total";return}C.error=null;C.amountToApply=e}));var P=e("W",(function(e){C.useFullBalance=e;C.error=null;if(e&&C.availableBalance!==null){var r=ze.total+(ze.storeCredit||0);var n=Math.min(C.availableBalance,r);C.amountToApply=n}else if(!e){C.amountToApply=null}}));var D=function(){if(!C.isEnabled||C.amountToApply===null){return{mode:"NONE"}}if(C.useFullBalance){return{mode:"FULL"}}return{amount:C.amountToApply,mode:"PARTIAL"}};var L=e("F",(function(){if(!C.isEnabled||C.availableBalance===null){return 0}if(C.useFullBalance){return Math.min(C.availableBalance,ze.total+(ze.storeCredit||0))}return C.amountToApply||0}));var x=e("x",(function(){return C.amountToApply!==null&&C.amountToApply>0&&ze.storeCredit>0&&ze.total<=0}));var R=e("z",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,l,f,m,l;return __generator(this,(function(p){switch(p.label){case 0:o=t.checkoutSessionId;if(!o){i="No checkout session found";v(i);C.error=i;return[2,{error:i,orderId:null,success:false}]}d("Creating store credit order","info",{checkoutSessionId:o});p.label=1;case 1:p.trys.push([1,3,,4]);return[4,c("/api/zonos-elements/store-credit/order-create",{body:{checkoutSessionId:o},method:"POST"})];case 2:a=p.sent(),s=a.errors,u=a.json;if(s.length>0||!u){l=((e=s[0])===null||e===void 0?void 0:e.message)||"Failed to create store credit order";v(l);C.error=l;return[2,{error:l,orderId:null,success:false}]}f=((n=(r=u.checkoutSessionStoreCreditOrderCreate)===null||r===void 0?void 0:r.order)===null||n===void 0?void 0:n.id)||null;C.orderIdCreated=f;d("Store credit order created","info",{orderId:f});return[2,{error:null,orderId:f,success:true}];case 3:m=p.sent();l=m instanceof Error?m.message:"Failed to create store credit order";v(l);C.error=l;return[2,{error:l,orderId:null,success:false}];case 4:return[2]}}))}))}));var U=e("Q",(function(e){var r=e.firstName,n=e.lastName,t=e.name;var o;if(!t&&!r&&!n){return{firstName:"",lastName:""}}var i=(t===null||t===void 0?void 0:t.split(/\s+/))||[];var a=(r===null||r===void 0?void 0:r.trim())||((o=i[0])===null||o===void 0?void 0:o.trim())||"";var s=(n===null||n===void 0?void 0:n.trim())||i.slice(1).join(" ").trim()||"";return{firstName:a,lastName:s}}));var z=function(e){var r=e.currentAddress,n=e.translatedAddress;var t,o,i,a,s,u;var d=r.value.address,l=d.city,c=d.country,v=d.line1,f=d.line2,m=d.postal_code,p=d.state;var h=r.value.name||[r.value.firstName,r.value.lastName].join(" ");return{city:((t=n.city)===null||t===void 0?void 0:t[l])||l,country:c,line1:((o=n.line1)===null||o===void 0?void 0:o[v])||v,line2:((i=n.line2)===null||i===void 0?void 0:i[f||""])||f||"",name:((a=n.name)===null||a===void 0?void 0:a[h])||h,phone:r.value.phone||"",postal_code:((s=n.postal_code)===null||s===void 0?void 0:s[m])||m,state:((u=n.state)===null||u===void 0?void 0:u[p])||p}};var B=function(e){var r;var n=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var a=ne.stripeLinkEventData;var s=ne.stripeAddressEventData;var u=ne.stripeShippingSameAsBilling?ne.stripeAddressEventData:ne.stripeBillingAddressEventData;if(!s||!u){throw new Error("Missing stripe address data")}var d=z({currentAddress:s,translatedAddress:ne.translatedAddress.address});var l=U({name:d.name}),c=l.firstName,v=l.lastName;var f=z({currentAddress:u,translatedAddress:ne.translatedAddress.address});var m=U({name:f.name}),p=m.firstName,h=m.lastName;var w=i()||"US";return{billingAddress:{addressLine1:f.line1,addressLine2:f.line2||"",city:f.city,country:f.country,postalCode:f.postal_code,state:f.state},billingContact:{firstName:p,lastName:h,phone:f.phone},cartCurrencyCode:(r=ze.items[0])===null||r===void 0?void 0:r.currencyCode,cartId:e,checkoutSessionCountry:w||o.selectedCountryCode||undefined,checkoutSessionId:t.checkoutSessionId||"",contact:{companyName:ne.companyName,email:a===null||a===void 0?void 0:a.value.email,firstName:c,lastName:v,phone:d.phone},isTest:!!n,landedCostAdjustments:ze.promoCode?[{amount:0,productId:null,promoCode:ze.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:ne.shortAddressCode,shipToTaxId:ne.taxId,shippingAddress:{addressLine1:d.line1,addressLine2:d.line2,city:d.city,country:d.country,postalCode:d.postal_code,state:d.state}}};var F=function(){var e=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var r=ne.stripeLinkEventData;var n=ne.stripeAddressEventData;var o=ne.stripeShippingSameAsBilling?ne.stripeAddressEventData:ne.stripeBillingAddressEventData;d({stripeAddressData:n,stripeBillingAddressData:o},"info");if(!n||!o){throw new Error("Missing stripe address data")}var i=z({currentAddress:n,translatedAddress:ne.translatedAddress.address});var a=U({name:i.name}),s=a.firstName,u=a.lastName;var l=z({currentAddress:o,translatedAddress:ne.translatedAddress.address});var c=U({name:l.name}),v=c.firstName,f=c.lastName;var m=ze.adjustments.map((function(e){return{amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}}));var p=ze.promoCode?__spreadArray([{amount:0,productId:null,promoCode:ze.promoCode,sku:null,type:"PROMO_CODE"}],m,true):m;return{billingAddress:{addressLine1:l.line1,addressLine2:l.line2||"",city:l.city,country:l.country,postalCode:l.postal_code,state:l.state},billingContact:{firstName:v,lastName:f,phone:l.phone},checkoutSessionId:t.checkoutSessionId||"",contact:{companyName:ne.companyName,email:r===null||r===void 0?void 0:r.value.email,firstName:s,lastName:u,phone:i.phone},isTest:e,items:ze.items,landedCostAdjustments:p,shipToShortAddressCode:ne.shortAddressCode,shipToTaxId:ne.taxId,shippingAddress:{addressLine1:i.line1,addressLine2:i.line2,city:i.city,country:i.country,postalCode:i.postal_code,state:i.state}}};var J=function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l;return __generator(this,(function(v){switch(v.label){case 0:a=F();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:f["vercel"]},{promoCode:ze.promoCode})];case 1:s=v.sent();if(!s||!((r=s.checkoutSessionWorkflow)===null||r===void 0?void 0:r.length)&&((n=s.errors)===null||n===void 0?void 0:n.length)){throw new Error("Failed to build landed cost: ".concat(((o=(t=s===null||s===void 0?void 0:s.errors)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.message)||"Unknown error"))}return[4,c("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:u=v.sent(),d=u.errors,l=u.json;if(!l||d.length){throw new Error("Invalid landed cost object: ".concat(((i=d.find(Boolean))===null||i===void 0?void 0:i.message)||"Unknown error"))}return[2,s]}}))}))};var M=function(e){return __awaiter(b,void 0,void 0,(function(){var r,t,o,i,a,s,u;return __generator(this,(function(d){switch(d.label){case 0:t=n.checkoutSettings.buildLandedCost;if(!t)return[3,2];return[4,J(t)];case 1:o=d.sent();return[2,o];case 2:return[4,c("/api/zonos-elements/calculate-landed-cost",{body:F(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:i=d.sent(),a=i.errors,s=i.json;if(a.length||!s){u=((r=a[0])===null||r===void 0?void 0:r.message)==="The user aborted a request.";if(u){throw new Error("The landed cost calculation request was aborted to initiate a new one.")}a.forEach((function(e){console.warn("Error calculating landed cost: ".concat(e.message))}));if(!s){throw new Error("Failed to calculate landed cost")}return[2,s]}return[2,s]}}))}))};var q=function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l;var v=e.abortController,f=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4,c("/api/zonos-elements/cart-calculate-landed-cost",{body:B(f),method:"POST",signal:v===null||v===void 0?void 0:v.signal})];case 1:a=e.sent(),s=a.errors,u=a.json;if(s.length||!u){d=typeof((r=s[0])===null||r===void 0?void 0:r.message)==="string"&&(((n=s[0])===null||n===void 0?void 0:n.message)==="The user aborted a request."||((t=s[0])===null||t===void 0?void 0:t.message.includes("signal is aborted"))||((o=s[0])===null||o===void 0?void 0:o.message.includes("The operation was aborted"))||((i=s[0])===null||i===void 0?void 0:i.message.includes("Fetch is aborted")));l=d?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(l)}return[2,u]}}))}))};var W=undefined&&undefined.__rest||function(e,r){var n={};for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0)n[t]=e[t];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,t=Object.getOwnPropertySymbols(e);o<t.length;o++){if(r.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o]))n[t[o]]=e[t[o]]}return n};var Y=function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:r=window.Zonos.cartId;if(!!r)return[3,2];return[4,M(e)];case 1:n=a.sent();return[2,n];case 2:return[4,q({abortController:e,cartId:r})];case 3:t=a.sent(),o=t.cartWorkflow,i=W(t,["cartWorkflow"]);return[2,Object.assign(Object.assign({},i),{itemCreateWorkflow:o.items})]}}))}))};var H=e("t",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,t,i,a,s,u,d,v,f;var w=e.checkoutSessionId,g=e.eventName,y=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:i=Date.now();a=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:w,eventCreated:i,eventName:g});s=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!((r=window.Zonos)===null||r===void 0?void 0:r.zonosQaUrl)||!!((t=window.Zonos)===null||t===void 0?void 0:t.debug);u=m()||p();if((u||s)&&!window.Zonos.zonosConversionTest){return[2]}d=o.selectedCountryCode;v=n.organizationId;if(!w){void h({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No checkout session id found')],metadata:{allLogs:l,checkoutSessionId:w,eventName:g,metadata:y,organizationId:v,trackEventLogs:a}});return[2]}if(!v){void h({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No organization id found')],metadata:{allLogs:l,checkoutSessionId:w,eventName:g,metadata:y,organizationId:v,trackEventLogs:a}})}f={checkoutSessionId:w,countryCode:d,eventCreated:i,eventName:g,metadata:Object.assign(Object.assign({},y),{trackEventLogs:a}),organizationId:v};return[4,c("/api/zonos-elements/track-conversion-event",{body:f,method:"POST"})];case 1:e.sent();return[2]}}))}))}));var K=function(e){var r=e.address,n=e.invalidAdddressList;if(!r){return}if(!n){return}var t={};if(n.city){t.city=r.city}if(n.line1){t.line1=r.line1}if(n.line2){t.line2=r.line2}if(n.postal_code){t.postal_code=r.postal_code}if(n.state){t.state=r.state}if(n.name){t.name=r.name}return Object.keys(t).length?t:undefined};var G=function(e){var r=e.addressInvalidCharactersList,n=e.billingAddressInvalidCharactersList,t=e.stripeAddressEventData,o=e.stripeBillingAddressEventData,i=e.stripeShippingSameAsBilling;var a=!!(t===null||t===void 0?void 0:t.complete);var s=i?a:!!(o===null||o===void 0?void 0:o.complete);if(!a||!s){return null}if(!r&&!n){return null}var u=t.value;var d=(o===null||o===void 0?void 0:o.value)||null;var l=U({firstName:u.firstName,lastName:u.lastName,name:u.name}),c=l.firstName,v=l.lastName;var f="".concat(c," ").concat(v);var m=U({firstName:d===null||d===void 0?void 0:d.firstName,lastName:d===null||d===void 0?void 0:d.lastName,name:(d===null||d===void 0?void 0:d.name)||""}),p=m.firstName,h=m.lastName;var w=p&&h?"".concat(p," ").concat(h):"";var g=u.address;var y=d===null||d===void 0?void 0:d.address;return{address:K({address:Object.assign(Object.assign({},g),{name:f}),invalidAdddressList:r}),billingAddress:!i?K({address:y?Object.assign(Object.assign({},y),{name:w}):null,invalidAdddressList:n}):undefined,destinationCountry:g.country}};var V=e("U",(function(e){var r=e.sort((function(e,r){return e.amount-r.amount}));return r}));var Z=e("y",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t;return __generator(this,(function(o){switch(o.label){case 0:return[4,_()];case 1:r=o.sent(),n=r.errors,t=r.json;if(n.length||!t){v("Failed to retrieve checkout session info before confirming payment ",n);void h({endpoint:"validateCheckoutSession",errors:n.map((function(e){return e.message})),metadata:{allLogs:l}});return[2,{errorMessage:a("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:false}]}if(!((e=t.checkoutSession.landedCost)===null||e===void 0?void 0:e.id)){v("Landed cost is not found in the checkout session before confirming payment.");void h({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:l}});return[2,{errorMessage:a('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:false}]}return[2,{errorMessage:"",valid:true}]}}))}))}));var Q=function(e){var r=e.theme;var t={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:n.appearance.fontSizeInputValue?"".concat(n.appearance.fontSizeInputValue,"px"):undefined,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:n.appearance.fontSizeInputLabel?"".concat(n.appearance.fontSizeInputLabel,"px"):undefined},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};switch(r){case"DARK":{return Object.assign(Object.assign({},t),{".Action":Object.assign(Object.assign({},t[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},t[".PickerItem--new"]),{color:"white"})})}default:return t}};var X=function(e){var r=e.borderStyle,n=e.theme;switch(n){case"DARK":return{borderRadius:y({overrideBorderStyle:r}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:y({overrideBorderStyle:r}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var $=r((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,shortAddressCode:"",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:{}}}})),ee=$.onChange,re=$.reset,ne=$.state;e({E:ee,b:ne});var te=function(e){var r=e.clientSecret,t=e.overrideBorderRadius,i=e.overridePrimaryColor,a=e.overrideSecondaryColor,s=e.overrideTheme,u=e.paypalEnabled;var d=i||n.appearance.colorPrimary;var l=a||n.appearance.colorSecondary;var c=window.Zonos.isCollect||window.Zonos.isInvoice?n.appearance.theme==="DARK":d&&g(d);var v=c?"night":"flat";var f=s==="DARK"?"night":"flat";var m=u?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},Q({theme:s||"LIGHT"})),theme:s?f:v,variables:Object.assign(Object.assign({},X({borderStyle:t,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:r||undefined,customerSessionClientSecret:ne.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],m,true),locale:o.selectedLocale}};var oe=e("o",(function(){window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")}));var ie=e("a",(function(e){window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))}));var ae=e("s",(function(){var e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return w(e)}));var se=e("i",(function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i;return __generator(this,(function(a){t=ne.clientSecret;if(!ne.stripe){d("Skip. Stripe is not initialized");return[2]}o=te({clientSecret:t,overrideBorderRadius:e===null||e===void 0?void 0:e.overrideBorderRadius,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideSecondaryColor:e===null||e===void 0?void 0:e.overrideSecondaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme,paypalEnabled:e===null||e===void 0?void 0:e.paypalEnabled});i=JSON.stringify(o)===JSON.stringify(ne.stripeElementsOptions);if(!ne.stripeElements||!ne.stripeElementsForBillingAddress){ne.stripeElementsForBillingAddress=(r=ne.stripe)===null||r===void 0?void 0:r.elements(o);d("Stripe elements for billing address initialized");ne.stripeElements=(n=ne.stripe)===null||n===void 0?void 0:n.elements(o);ne.stripeElementsOptions=o;d("Stripe elements initialized");return[2]}if(!i){ne.stripeElements.update(o);ne.stripeElementsForBillingAddress.update(o);ne.stripeElementsOptions=o;void ne.stripeElements.fetchUpdates()}d("Stripe elements updated");return[2]}))}))}));var ue=e("C",(function(){sessionStorage.removeItem("zonos--client-secret");re();ne.stripe=window.Zonos.stripe}));var de=function(){var e,r,n,t;var o=JSON.stringify((e=ne.stripeAddressUsedWhenValidatingAddress)===null||e===void 0?void 0:e.value)!==JSON.stringify((r=ne.stripeAddressEventData)===null||r===void 0?void 0:r.value);var i=!ne.stripeShippingSameAsBilling&&JSON.stringify((n=ne.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value)!==JSON.stringify((t=ne.stripeBillingAddressUsedWhenValidatingAddress)===null||t===void 0?void 0:t.value);return o||i};var le=function(){var e,r,n,t,o,i,a,s;var u=(e=ze.partiesData.find((function(e){return e.type==="DESTINATION"})))===null||e===void 0?void 0:e.id;var d=(r=ze.partiesData.find((function(e){return e.type==="PAYOR"})))===null||r===void 0?void 0:r.id;if(!u||!d){return false}if(ne.partyShippingId!==u||ne.partyBillingId!==d){return true}var l=JSON.stringify((n=ne.stripeLinkUsedWhenFetchingLC)===null||n===void 0?void 0:n.value)!==JSON.stringify((t=ne.stripeLinkEventData)===null||t===void 0?void 0:t.value);var c=JSON.stringify((o=ne.stripeAddressUsedWhenAsyncAddressUpdate)===null||o===void 0?void 0:o.value)!==JSON.stringify((i=ne.stripeAddressEventData)===null||i===void 0?void 0:i.value);var v=!ne.stripeShippingSameAsBilling&&JSON.stringify((a=ne.stripeBillingAddressUsedWhenAsyncAddressUpdate)===null||a===void 0?void 0:a.value)!==JSON.stringify((s=ne.stripeBillingAddressEventData)===null||s===void 0?void 0:s.value);var f=ne.taxIdUsedWhenAsyncAddressUpdate!==ne.taxId;var m=ne.companyNameUsedWhenAsyncAddressUpdate!==ne.companyName;return l||c||v||f||m};var ce=e("G",(function(e){var r=e.address,n=e.firstName,o=e.lastName,i=e.name,a=e.phone;var s=U({firstName:n,lastName:o,name:i}),u=s.firstName,d=s.lastName;if(!u||!d){void h({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,firstName:n,lastName:o,name:i}})}if(!a){void h({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,phone:a}})}return{city:r.city,country:r.country,firstName:u,lastName:d,line1:r.line1,line2:r.line2,phone:a||"",postal_code:r.postal_code,state:r.state}}));var ve=e("R",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,d,f,m,p;return __generator(this,(function(w){switch(w.label){case 0:if(!((e=ne.stripeAddressEventData)===null||e===void 0?void 0:e.complete)||!ne.stripeShippingSameAsBilling&&!((r=ne.stripeBillingAddressEventData)===null||r===void 0?void 0:r.complete)||!ne.stripeBillingAddressEventData){return[2,{partiesCreated:false}]}if(!ze.landedCostData){return[2,{partiesCreated:false}]}i=(n=ze.landedCostData.find(Boolean))===null||n===void 0?void 0:n.landedCost.rootId;if(!i){void h({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId}});return[2,{partiesCreated:false}]}a=le();if(!a){return[2,{partiesCreated:false}]}s=ce({address:ne.stripeAddressEventData.value.address,firstName:ne.stripeAddressEventData.value.firstName,lastName:ne.stripeAddressEventData.value.lastName,name:ne.stripeAddressEventData.value.name,phone:ne.stripeAddressEventData.value.phone});u=ne.stripeShippingSameAsBilling?s:ce({address:ne.stripeBillingAddressEventData.value.address,firstName:ne.stripeBillingAddressEventData.value.firstName,lastName:ne.stripeBillingAddressEventData.value.lastName,name:ne.stripeBillingAddressEventData.value.name,phone:ne.stripeBillingAddressEventData.value.phone});d=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,c("/api/zonos-elements/create-parties",{body:{address:s,billingAddress:u,companyName:ne.companyName,email:((o=ne.stripeLinkEventData)===null||o===void 0?void 0:o.value.email)||"",isTest:d,rootId:i,shortAddressCode:ne.shortAddressCode,taxId:ne.taxId},method:"POST"})];case 1:f=w.sent(),m=f.errors,p=f.json;if(m.length||!p){v("Error occurs when creating parties",JSON.stringify(m,null,2));void h({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,errors:m,json:p}});return[2,{partiesCreated:false}]}ne.companyNameUsedWhenAsyncAddressUpdate=ne.companyName;ne.stripeAddressUsedWhenAsyncAddressUpdate=ne.stripeAddressEventData;ne.stripeBillingAddressUsedWhenAsyncAddressUpdate=ne.stripeBillingAddressEventData;ne.taxIdUsedWhenAsyncAddressUpdate=ne.taxId;ne.partyBillingId=p.billToPartyId;ne.partyShippingId=p.shipToPartyId;ze.partiesData=ze.partiesData.map((function(e){if(e.type==="DESTINATION"&&e.id!==p.shipToPartyId){return Object.assign(Object.assign({},e),{id:p.shipToPartyId})}if(e.type==="PAYOR"&&e.id!==p.billToPartyId){return Object.assign(Object.assign({},e),{id:p.billToPartyId})}return e}));return[2,{partiesCreated:true}]}}))}))}));var fe=function(e){return{countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}};var me=function(){var e,r;var n=JSON.stringify((e=ne.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((r=ne.stripeLinkEventData)===null||r===void 0?void 0:r.value);var t=ne.stripeAddressEventData&&JSON.stringify(fe(ne.stripeAddressEventData.value))!==JSON.stringify(ne.stripeAddressUsedWhenFetchingLC);var o=!ne.stripeShippingSameAsBilling&&ne.stripeBillingAddressEventData&&JSON.stringify(fe(ne.stripeBillingAddressEventData.value))!==JSON.stringify(ne.stripeBillingAddressUsedWhenFetchingLC);return n||t||o};var pe=function(){var e;var r=ze.landedCostData&&((e=ze.landedCostData.find(Boolean))===null||e===void 0?void 0:e.subtotals.items)!==ze.subtotal;var n=me();d("isPrefetchInfoOutdated","info",{isAddressOutdated:n});return!ze.landedCostData&&!ne.isFetchingLandedCost||n||r};var he=function(e){var r,t;var o=(r=n.genericSettings)===null||r===void 0?void 0:r.countryFields;var i=(t=n.genericSettings)===null||t===void 0?void 0:t.stripeCountryFieldLabels;var a=i&&e in i?i[e]:null;var s=o&&e in o?o[e]:null;if(ze.addressFormRenderType==="stripe"){return a||s}return s};var we=function(){var e,r,n,t;var o=!!((e=ne.stripeLinkEventData)===null||e===void 0?void 0:e.complete);var i=!!((r=ne.stripeAddressEventData)===null||r===void 0?void 0:r.complete);var a=ne.stripeShippingSameAsBilling?i:!!((n=ne.stripeBillingAddressEventData)===null||n===void 0?void 0:n.complete);var s=((t=ne.stripeAddressEventData)===null||t===void 0?void 0:t.value.address.country)||"US";var u=he(s);if(i&&a&&o){return true}if(!u||!ne.stripeAddressEventData){return i&&a&&o}var d=ne.stripeAddressEventData.value.address.line1.length>0;var l=ne.stripeAddressEventData.value.firstName&&ne.stripeAddressEventData.value.lastName;var c=!u.stateRequired||u.stateRequired&&ne.stripeAddressEventData.value.address.state.length>0;var v=!u.zipRequired||u.zipRequired&&ne.stripeAddressEventData.value.address.postal_code.length>=3;var f=ne.stripeAddressEventData.value.phone&&ne.stripeAddressEventData.value.phone.length>0;return o&&l&&d&&c&&v&&f};var ge=function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,d,l,c;return __generator(this,(function(v){switch(v.label){case 0:r=new AbortController;ne.fetchingLandedCostAbortController=r;rr();return[4,Y(r)];case 1:n=v.sent(),o=n.checkoutSessionWorkflow,i=n.errors,a=n.itemCreateWorkflow,s=n.landedCostCalculateWorkflow,u=n.partyCreateWorkflow,d=n.shipmentRatingCalculateWorkflow;ze.customQuotingError=((e=i===null||i===void 0?void 0:i.find((function(e){var r;return((r=e.extensions)===null||r===void 0?void 0:r.ruleMessageType)==="CUSTOM"})))===null||e===void 0?void 0:e.message)||null;ze.shippingData=V((d===null||d===void 0?void 0:d.filter(Boolean))||[]);Me(a);ne.fetchingLandedCostAbortController=null;ze.partiesData=(u===null||u===void 0?void 0:u.filter(Boolean))||[];ze.landedCostData=(o===null||o===void 0?void 0:o.map((function(e){var r=s===null||s===void 0?void 0:s.find((function(r){return(r===null||r===void 0?void 0:r.id)===e.landedCostId}));if(!r){return null}return Object.assign(Object.assign({},e),{landedCost:r})})).filter(Boolean))||[];l=t.checkoutSessionId;if(o===null||o===void 0?void 0:o.length){void H({checkoutSessionId:l,eventName:"checkout_quoteReceived"})}c=ze.promoCodeApplied&&!ze.landedCostData.find((function(e){var r;return(r=e.landedCost.appliedAdjustments)===null||r===void 0?void 0:r.find((function(e){return e.type==="PROMO_CODE"}))}));ze.promoCodeError=c;if(!c){sessionStorage.setItem("zonos--promo-code",ze.promoCode)}return[2]}}))}))};var ye=e("q",(function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l,c,f,m,p;return __generator(this,(function(w){switch(w.label){case 0:i=(e===null||e===void 0?void 0:e.retries)||0;a=!!(e===null||e===void 0?void 0:e.applyingPromocode);s=pe();u=we();if(!u){return[2,{isRequestNotReady:true}]}if(s){(r=ne.fetchingLandedCostAbortController)===null||r===void 0?void 0:r.abort();ne.fetchingLandedCostAbortController=null}if(!s&&!a){return[2,{isRequestNotReady:false}]}if(i){ne.isFetchingLandedCost=false;setTimeout((function(){ne.isFetchingLandedCost=true}),300)}else{ne.isFetchingLandedCost=true}if(ne.stripeAddressEventData){ne.stripeAddressUsedWhenFetchingLC={countryCode:ne.stripeAddressEventData.value.address.country,postalCode:ne.stripeAddressEventData.value.address.postal_code,state:ne.stripeAddressEventData.value.address.state}}if(ne.stripeBillingAddressEventData){ne.stripeBillingAddressUsedWhenFetchingLC={countryCode:ne.stripeBillingAddressEventData.value.address.country,postalCode:ne.stripeBillingAddressEventData.value.address.postal_code,state:ne.stripeBillingAddressEventData.value.address.state}}if(ne.stripeLinkEventData){ne.stripeLinkUsedWhenFetchingLC=Object.assign({},ne.stripeLinkEventData)}w.label=1;case 1:w.trys.push([1,3,,7]);rr();return[4,ge()];case 2:w.sent();d=(n=ze.shippingData)===null||n===void 0?void 0:n.find(Boolean);l=(t=ze.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCost.shipmentRating.id===(d===null||d===void 0?void 0:d.id)}));c=!!l?l.subtotals:null;if(c){He({method:(l===null||l===void 0?void 0:l.landedCost.method)||"DDP",subtotals:c})}return[3,7];case 3:f=w.sent();ze.landedCostData=[];ze.shippingData=[];m=["The landed cost calculation request was aborted to initiate a new one."];if(!(f instanceof Error&&f.message&&!m.includes(f.message)))return[3,6];if(!(i<1))return[3,5];return[4,ye(Object.assign(Object.assign({},e),{retries:(i||0)+1}))];case 4:w.sent();return[2,{isRequestNotReady:false}];case 5:p=(o=ne.stripeAddressEventData)===null||o===void 0?void 0:o.value;void h({endpoint:"Failed to fetch landed cost (".concat(i," retries)"),errors:[f.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:p}});w.label=6;case 6:v(f);return[3,7];case 7:ne.isFetchingLandedCost=false;return[2,{isRequestNotReady:false}]}}))}))}));var be=e("J",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t;return __generator(this,(function(o){switch(o.label){case 0:return[4,ye({applyingPromocode:true})];case 1:o.sent();if(ze.step==="payment"){or()}return[4,ve()];case 2:o.sent();n=(e=ze.shippingData)===null||e===void 0?void 0:e.find(Boolean);t=(r=ze.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCost.id===(n===null||n===void 0?void 0:n.id)}));if(!n||!t){return[2]}return[4,Qe({applySubtotalsOnly:false,landedCostId:t.landedCostId,selectedShippingOption:n})];case 3:o.sent();return[2]}}))}))}));var _e=e("L",(function(){ze.promoCode="";sessionStorage.removeItem("zonos--promo-code");ze.promoCodeError=false;ze.promoCodeApplied=false}));var Se=e("K",(function(){return __awaiter(b,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:if(ze.step==="payment"){or()}_e();return[4,be()];case 1:e.sent();return[2]}}))}))}));var Oe=e("M",(function(e){var r=[];var n=true;var t=window.Zonos.isCollect;var o=window.Zonos.isInvoice;switch(e){case"succeeded":{r=[a("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"",a("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")];if(t||o){r=[a("Thank you for submitting your payment. We appreciate your prompt attention."),"",a("A confirmation email with your payment details has been sent for your records. If you have any questions or need support, our team is here to help.")]}n=false;break}case"requires_capture":case"processing":{r=[a("Payment processing. We'll update you when payment is received.")];n=false;break}case"requires_payment_method":{r=[a("Payment failed. Please try another payment method.")];if(t){r=[a("Payment failed. Please reload the page and try another payment method.")]}break}case"requires_action":{n=false;r=[a("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}default:{r=[a("Something went wrong.")];break}}return{isError:n,messages:r}}));var Ae=e("v",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,t,o,i,s,u,d,l,d;return __generator(this,(function(m){switch(m.label){case 0:t=n.checkoutSettings.onInventoryCheck;o=!!((r=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||r===void 0?void 0:r.value);if(!(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o))return[3,2];return[4,c("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:i=m.sent(),s=i.errors,u=i.json;if(s.length||!u){v("Error occurs when handling inventory refund","warn",JSON.stringify(s));return[2,null]}if(!u.available||u.status===204){return[2,a("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")]}if(u.available||u.status===200){ne.shouldInventoryRefund=true;return[2,null]}return[2,null];case 2:if(typeof t!=="function"){return[2,null]}m.label=3;case 3:m.trys.push([3,5,,6]);return[4,t({items:ze.items},{translate:a,zonosApiRoute:f["vercel"]})];case 4:d=m.sent();return[2,d];case 5:l=m.sent();d=l instanceof Error?l.message:"Unknown error";void h({endpoint:"onInventoryCheck",errors:["cartId: ".concat(window.Zonos.cartId," - ").concat(d)],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:ze.items}});throw l;case 6:return[2]}}))}))}));var Ce=e("B",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n;return __generator(this,(function(t){switch(t.label){case 0:n=!!((r=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||r===void 0?void 0:r.value);if(!window.Zonos.isLegacyCheckout||!window.Zonos.cartData||!n){return[2]}return[4,c("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:t.sent();return[2]}}))}))}));var ke=e("c",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,t,o,i,s,u,d,l;var c=e.clientSecret,f=e.storybookForceStatus;return __generator(this,(function(e){switch(e.label){case 0:if(f){r=Oe(f),n=r.isError,t=r.messages;return[2,{error:n,messages:t}]}o=c||ne.clientSecret;if(!ne.stripe||!o){v("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[a("Something went wrong.")]}]}return[4,ne.stripe.retrievePaymentIntent(o)];case 1:i=e.sent().paymentIntent;s=i===null||i===void 0?void 0:i.status;u=Oe(s),d=u.isError,l=u.messages;return[2,{amount:i===null||i===void 0?void 0:i.amount,currency:i===null||i===void 0?void 0:i.currency,error:d,messages:l,paymentIntentId:i===null||i===void 0?void 0:i.id,paymentMethod:i===null||i===void 0?void 0:i.payment_method,status:s}]}}))}))}));var Ie=e("A",(function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,o,i,s,u,l,c,v,f,m,p;return __generator(this,(function(h){switch(h.label){case 0:o=!!((r=ne.stripePaymentEventData)===null||r===void 0?void 0:r.complete);i=ne.stripeElements;s=ne.stripe;u=ne.clientSecret;ne.customErrorMessage=null;if(!((n=ze.selectedLandedCost)===null||n===void 0?void 0:n.landedCost.id)&&!(e===null||e===void 0?void 0:e.noLandedCostCheck)){throw new Error("Attempted to confirm the payment when no landed cost is found in store")}return[4,Z()];case 1:l=h.sent();if(!l.valid){ne.customErrorMessage=l.errorMessage;throw new Error(l.errorMessage)}c=t.checkoutSessionId;if(!(s&&i&&o&&u&&c))return[3,3];v=new URL(window.location.href);v.searchParams.set("payment_intent_client_secret",u);v.searchParams.set("zonosCheckoutSessionId",c);void H({checkoutSessionId:c,eventName:"checkout_paymentInfoCompleted"});return[4,s.confirmPayment({confirmParams:{return_url:v.toString()},elements:i,redirect:"if_required"})];case 2:f=h.sent(),m=f.error,p=f.paymentIntent;d("Payment intent confirmed","info",{error:m,paymentIntent:p});if((p===null||p===void 0?void 0:p.status)==="requires_action"){throw new Error(a("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."))}if(m){if(m.type==="card_error"||m.type==="validation_error"){throw new Error(m.message)}if(m.type==="invalid_request_error"){if(m.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}if(p.status==="requires_payment_method"){throw new Error(a("Payment failed. Please try another payment method."))}h.label=3;case 3:return[2]}}))}))}));var Te=e("m",(function(){var e;var r=ze.items.reduce((function(e,r){return e+r.amount*r.quantity}),0);var n=t.enabledVariantTestKeys||[];var i={adjustmentsAmount:ze.adjustments.reduce((function(e,r){return e+r.amount}),0),cartId:window.Zonos.cartId,currency:((e=ze.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",customerAuthenticationToken:ze.customerAuthenticationToken||undefined,isCollect:!!window.Zonos.isCollect,isInvoice:!!window.Zonos.isInvoice,itemsAmount:r,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:o.selectedCountryCode,skipPaymentIntent:ne.skipPaymentIntent,varianceTestInput:n};return i}));var Ee=e("k",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i;return __generator(this,(function(s){switch(s.label){case 0:if(!t.checkoutSessionId){void h({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:l,cartId:window.Zonos.cartId}});Ye({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2]}return[4,c("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:t.checkoutSessionId},method:"POST"})];case 1:r=s.sent(),n=r.errors,o=r.json;i=(e=o===null||o===void 0?void 0:o.checkoutSessionPaymentIntentCreate)===null||e===void 0?void 0:e.clientSecret;if(n.length||!i){v("Error occurs when getting payment intent",JSON.stringify(n,null,2));void h({endpoint:"Error creating payment intent",errors:n.map((function(e){return e.message})),metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,clientSecret:i}});Ye({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2]}Ge(o.checkoutSessionPaymentIntentCreate);return[2]}}))}))}));var Ne=e("j",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t,i,a,s,u;return __generator(this,(function(l){switch(l.label){case 0:if(!o.targetCurrency){v("Failed to create checkout session - missing localizationStore.targetCurrency");return[2,false]}ne.isFetchingSession=true;n=Te();d("Checkout session body","info",n);return[4,c("/api/zonos-elements/create-checkout-session",{body:n,method:"POST"})];case 1:t=l.sent(),i=t.errors,a=t.json;ne.isFetchingSession=false;if(i.length||!a){s=(e=i.find((function(e){return e.message})))===null||e===void 0?void 0:e.message;if(Array.isArray(s)&&s.some((function(e){return e.message==="Cart is expired."}))){throw new Error("Cart is expired.")}v("Error occurred when creating checkout session",JSON.stringify(i,null,2));return[2,false]}u=a.checkoutSessionCreate;Ge(u);He({method:((r=u.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:u.subtotals});d("Exchange rate updated for cart items (checkout session create)","info",ze.exchangeRate);d("done-init-checkout-session");return[2,true]}}))}))}));var je=e("u",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,o;return __generator(this,(function(i){switch(i.label){case 0:e=t.checkoutSessionId;if(!e){v("Failed to update checkout session base currency");return[2,false]}if(n.checkoutSettings.allowedSettlementCurrencies==="LOCAL"){d('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency');return[2,true]}return[4,c("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:ne.checkoutSettlementCurrency},method:"POST"})];case 1:r=i.sent().json;o=r===null||r===void 0?void 0:r.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;if(!r||o!==ne.checkoutSettlementCurrency){v("Failed to update checkout session base currency");return[2,false]}d('Updated checkout session to settlement currency "'.concat(o,'".'));return[2,true]}}))}))}));var Pe=function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,i,a;var s=e.adjustmentsAmount,u=e.cartId,d=e.currency,l=e.id,f=e.itemsAmount,m=e.landedCostId,p=e.presentmentCountryCode,h=e.storeCreditApplication;return __generator(this,(function(e){switch(e.label){case 0:r=t.enabledVariantTestKeys||[];return[4,c("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:s,billToPartyId:ne.partyBillingId,cartId:u,currency:d,customerAuthenticationToken:ze.customerAuthenticationToken||undefined,id:l,itemsAmount:f,landedCostId:m,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:p,shipToPartyId:ne.partyShippingId,skipPaymentIntent:ne.skipPaymentIntent,storeCreditApplication:h,varianceTestInput:r},method:"POST"})];case 1:n=e.sent(),i=n.errors,a=n.json;if(i.length||!a){v("Error occurs when updating checkout session",JSON.stringify(i,null,2));return[2,{errors:i,json:a}]}return[2,{errors:[],json:a}]}}))}))};var De=function(e){var r,n,t,o,i,a;var s=e.currentAddress,u=e.translatedAddressResult;var d={};if(!u){return d}var l=u.city,c=u.line1,v=u.line2,f=u.name,m=u.postal_code,p=u.state;if(s.city&&l){d.city=(r={},r[s.city]=l,r)}if(s.line1&&c){d.line1=(n={},n[s.line1]=c,n)}if(s.line2&&v){d.line2=(t={},t[s.line2]=v,t)}if(s.postal_code&&m){d.postal_code=(o={},o[s.postal_code]=m,o)}if(s.state&&p){d.state=(i={},i[s.state]=p,i)}if(s.name&&f){d.name=(a={},a[s.name]=f,a)}return d};var Le=e("P",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l,f;var m=e.addressInvalidCharactersList,p=e.billingAddressInvalidCharactersList;return __generator(this,(function(e){switch(e.label){case 0:i=G({addressInvalidCharactersList:m,billingAddressInvalidCharactersList:p,stripeAddressEventData:ne.stripeAddressEventData,stripeBillingAddressEventData:ne.stripeBillingAddressEventData,stripeShippingSameAsBilling:ne.stripeShippingSameAsBilling});if(!i){ne.translatedAddress={address:{},billingAddress:{}};return[2]}a=de();if(!a){return[2]}return[4,c("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),u=s.errors,d=s.json;if(u.length||!d){v("Error occurs when translating address to latin",JSON.stringify(u,null,2));ne.translatedAddress={address:{},billingAddress:{}};return[2]}ne.stripeAddressUsedWhenValidatingAddress=ne.stripeAddressEventData;ne.stripeBillingAddressUsedWhenValidatingAddress=ne.stripeBillingAddressEventData;l=(r=ne.stripeAddressEventData)===null||r===void 0?void 0:r.value.address;f=(n=ne.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value.address;ne.translatedAddress={address:l?De({currentAddress:Object.assign(Object.assign({},l),{name:(t=ne.stripeAddressEventData)===null||t===void 0?void 0:t.value.name}),translatedAddressResult:d.address||null}):{},billingAddress:!ne.stripeShippingSameAsBilling?De({currentAddress:Object.assign(Object.assign({},f),{name:(o=ne.stripeBillingAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:d.billingAddress||null}):{}};return[2]}}))}))}));ee("clientSecret",(function(e){if(e&&ne.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var xe=r((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:p(),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",storeCredit:0,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}})),Re=xe.onChange,Ue=xe.reset,ze=xe.state;e({D:Re,d:ze});var Be=function(e){switch(e){case"DAYS":return a("days");case"WEEKS":return a("weeks");case"BUSINESS_DAYS":default:return a("business days")}};var Fe=e("S",(function(e){var r;var n=(r=e.shippingProfile)===null||r===void 0?void 0:r.transitTime;if(!(n===null||n===void 0?void 0:n.min)||!(n===null||n===void 0?void 0:n.max)||!(n===null||n===void 0?void 0:n.type)){return null}return{maxTransit:n.max,minTransit:n.min,unit:Be(n.type)}}));var Je=function(e){var r=e.item1,n=e.item2;if(!r||!n){return false}return n.sku&&r.sku&&r.sku===n.sku||n.description&&r.description&&r.description===n.description||r.name&&n.name&&r.name===n.name};var Me=function(e){d("Checking item restrictions");var r=e.map((function(e){if(!e.restriction){return null}var r=e.restriction;var n=ze.items.find((function(r){return Je({item1:r,item2:e})}));return Object.assign(Object.assign({matchedItem:n},e),{restriction:r})})).filter(Boolean);ze.restrictedItems=r;ze.items=ze.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:!!r.find((function(r){return Je({item1:r,item2:e})}))})}));return{cartItems:ze.items,restrictedItems:r}};var qe=null;var We=e("f",(function(){t.checkoutSessionId=null;if(qe){clearTimeout(qe);qe=null}k();Ue()}));var Ye=e("n",(function(e){var r=e.messages,n=e.title;We();ue();ze.step="error";ze.error={messages:r,title:n}}));var He=function(e){var r=e.dutiesTaxesFeesEstimate,n=e.method,t=e.subtotals;var o;ze.exchangeRate=t.exchangeRate;ze.adjustmentTotal=t.adjustments;ze.dutiesTaxesFees=n==="DAP"?null:t.landedCostTotal;ze.storeCredit=(o=t.storeCredit)!==null&&o!==void 0?o:0;ze.subtotal=t.items;ze.total=t.total;ze.currency=t.presentmentCurrencyCode;ze.dutiesTaxesFeesEstimate=r||null};var Ke=e("I",(function(){var e=ze.items.filter((function(e){return e.amount>0}));return!!e.find((function(e){return!e.isRestricted}))}));var Ge=e("p",(function(e){var r,n,o,i,a,c,v;ne.clientSecret=e.clientSecret;ne.stripeCustomerSessionClientSecret=e.customerSessionClientSecret;ne.customerProfile=e.customerProfile;ze.checkoutSession=e;I((n=(r=e.customerProfile)===null||r===void 0?void 0:r.storeCreditBalance)!==null&&n!==void 0?n:null);if(!e.id){void h({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:l,checkoutSession:e}})}if(e.id){t.checkoutSessionId=e.id}var f=s(e.varianceTestResults||[]);u(f);var m=((a=(i=(o=ze.checkoutSession)===null||o===void 0?void 0:o.metadata)===null||i===void 0?void 0:i.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||a===void 0?void 0:a.value)||((v=(c=window.Zonos.cartData)===null||c===void 0?void 0:c.metadata.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||v===void 0?void 0:v.value)||null;if(m){d("Found externalConfirmationPageURL: ".concat(m));ze.externalConfirmationPageURL=m}}));var Ve=function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,i,s,u,l;var c=e.adjustmentsAmount,f=e.cartId,m=e.currency,p=e.dutiesTaxesFeesEstimate,h=e.itemsAmount,w=e.landedCostId,g=e.shouldInitSessionOnFailure;return __generator(this,(function(e){switch(e.label){case 0:if(w&&ze.selectedLandedCost){n=ze.selectedLandedCost.subtotals;He({dutiesTaxesFeesEstimate:p,method:ze.landedCostMethod,subtotals:n});d("Exchange rate updated for cart items (landed cost subtotal)","info",ze.exchangeRate)}if(!t.checkoutSessionId){d("Could not update cart total without checkout session id","info");return[2,false]}return[4,Pe({adjustmentsAmount:c,billToPartyId:ne.partyBillingId,cartId:f,currency:m,id:t.checkoutSessionId,itemsAmount:h,landedCostId:w,presentmentCountryCode:o.selectedCountryCode,shipToPartyId:ne.partyShippingId,varianceTestInput:t.enabledVariantTestKeys||[]})];case 1:i=e.sent(),s=i.errors,u=i.json;if(!(s.length>0||!u))return[3,4];v("Error occurs when updating checkout session.");if(!g)return[3,3];d("Initiating checkout session on failure","info");return[4,Ne()];case 2:l=e.sent();d("stripeStoreInitCheckoutSession: ".concat(l));if(!l){Ye({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2,false]}return[2,true];case 3:return[2,false];case 4:if(!w){He({method:((r=u.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:u.checkoutSessionUpdate.subtotals});d("Exchange rate updated for cart items (checkout session update)","info",ze.exchangeRate)}Ge(u.checkoutSessionUpdate);return[2,true]}}))}))};var Ze=e("T",(function(e){var r,t,o;if(e.method==="DAP"&&((t=(r=n.genericSettings)===null||r===void 0?void 0:r.domesticCountries)===null||t===void 0?void 0:t.includes(((o=ne.stripeAddressEventData)===null||o===void 0?void 0:o.value.address.country)||"US"))){return"DDP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method}));var Qe=e("H",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,o,i,a,s,u,l,c,v,f,m,p,h,w,g,y,b,_,S,O,A,C,k,I,T;var E=e.applySubtotalsOnly,N=e.landedCostId,j=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:d("Updating selected shipping option","info",{landedCostId:N,selectedShippingOption:j});ze.selectedShippingOption=j;p=Fe(ze.selectedShippingOption);if(p){h=p.maxTransit,w=p.minTransit,g=p.unit;ze.selectedShippingOptionTransitTime="".concat(w,"-").concat(h," ").concat(g)}else{ze.selectedShippingOptionTransitTime=""}y=(r=ze.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCostId===N}));ze.selectedLandedCost=y||null;if(!y){return[2,false]}b=((o=y.landedCost.amountSubtotals)===null||o===void 0?void 0:o.landedCostTotal)||0;_=y.subtotals.exchangeRate.rate;S=b*_;if(S){d("DAP quote, using estimate: ".concat(S),"info")}ze.landedCostMethod=Ze(y.landedCost);ze.shipping=y.subtotals.shipping;O=((i=y===null||y===void 0?void 0:y.landedCost)===null||i===void 0?void 0:i.landedCostGuaranteeCode)==="ZONOS";A=!!((s=(a=y===null||y===void 0?void 0:y.landedCost)===null||a===void 0?void 0:a.deMinimis)===null||s===void 0?void 0:s.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));ze.isSelectedShippingAboveDeminimis=A;ze.isSelectedShippingGuarantee=O;C=false;if(!E)return[3,1];k=y.subtotals;He({dutiesTaxesFeesEstimate:S,method:ze.landedCostMethod,subtotals:k});d("Exchange rate updated for cart items (landed cost subtotal)","info",ze.exchangeRate);C=true;return[3,3];case 1:return[4,Ve({adjustmentsAmount:ze.adjustmentTotal,billToPartyId:ne.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:S,landedCostId:(u=y.landedCost)===null||u===void 0?void 0:u.id,shipToPartyId:ne.partyShippingId,varianceTestInput:t.enabledVariantTestKeys||[]})];case 2:C=e.sent();e.label=3;case 3:I=(l=ze.items.find(Boolean))===null||l===void 0?void 0:l.currencyCode;T=((c=ne.stripeAddressEventData)===null||c===void 0?void 0:c.value.address.country)||"US";ne.shouldRenderPayInUsdButton=I==="USD"&&n.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((v=ze.checkoutSession)===null||v===void 0?void 0:v.subtotals.presentmentCurrencyCode)!=="USD"&&!!((m=(f=n.genericSettings)===null||f===void 0?void 0:f.usdSettlementCountryEnabled)===null||m===void 0?void 0:m.includes(T));return[2,C]}}))}))}));var Xe=e("l",(function(e){var r=e.isPreview,n=e.sessionTimeout;if(r){return}var t=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout");var o=t&&!isNaN(parseInt(t,10))?parseInt(t,10):n;d("==START CHECKOUT TIMEOUT - ".concat(o,"=="));ze.checkoutTimeoutInterval=setTimeout((function(){ze.checkoutSessionTimeoutShow=true}),o)}));var $e=e("h",(function(){if(ze.checkoutTimeoutInterval){clearTimeout(ze.checkoutTimeoutInterval);ze.checkoutTimeoutInterval=null}}));var er=function(e){return e.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}))};var rr=function(){ze.items=ze.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));ze.restrictedItems=[]};var nr=e("e",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,o,i;var a=e.adjustments,s=e.cartItems,u=e.landedCostId,d=e.shouldInitSessionOnFailure,l=d===void 0?true:d;return __generator(this,(function(e){switch(e.label){case 0:ze.adjustments=a;ze.items=er(s);n=(r=s.find(Boolean))===null||r===void 0?void 0:r.currencyCode;o=s.reduce((function(e,r){return e+r.amount*r.quantity}),0);i=a.reduce((function(e,r){return e+r.amount}),0);if(!n||!o){return[2]}ze.currency=n;ne.isFetchingSession=true;return[4,Ve({adjustmentsAmount:i,billToPartyId:ne.partyBillingId,cartId:window.Zonos.cartId,currency:n,dutiesTaxesFeesEstimate:0,itemsAmount:o,landedCostId:u,shipToPartyId:ne.partyShippingId,shouldInitSessionOnFailure:l,varianceTestInput:t.enabledVariantTestKeys||[]})];case 1:e.sent();ne.isFetchingSession=false;return[2]}}))}))}));var tr=function(){ze.selectedShippingOption=null;ze.isSelectedShippingAboveDeminimis=false;ze.isSelectedShippingGuarantee=false;ze.selectedShippingOptionTransitTime="";ze.dutiesTaxesFees=0;ze.dutiesTaxesFeesEstimate=0;ze.shipping=0;ze.total=ze.subtotal};var or=function(){if(ze.step==="shipping"){ze.step="customer-info";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{"customer-info":Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:false})})}else if(ze.step==="payment"){ze.step="shipping";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{shipping:Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:false})})}else if(ze.step==="finish"){ze.step="payment";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{payment:Object.assign(Object.assign({},ze.tabItems.payment),{isDone:false})})}};var ir=e("r",(function(){if(ze.step==="customer-info"){ze.step="shipping";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{"customer-info":Object.assign(Object.assign({},ze.tabItems["customer-info"]),{isDone:true})})}else if(ze.step==="shipping"){ze.step="payment";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{shipping:Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:true})})}else if(ze.step==="payment"){ze.step="finish"}}));var ar=e("g",(function(){ze.step="customer-info";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{"customer-info":Object.assign(Object.assign({},ze.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},ze.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:false})});tr()}));var sr=function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,i,a,s,u,l,c;return __generator(this,(function(f){switch(f.label){case 0:if(!t.checkoutSessionId){d("Could not update store credit without checkout session id","info");return[2]}n=ze.selectedLandedCost;i=ze.currency||((e=ze.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"";a=ze.adjustments.reduce((function(e,r){return e+r.amount}),0);s=ze.items.reduce((function(e,r){return e+r.amount*r.quantity}),0);return[4,Pe({adjustmentsAmount:a,cartId:window.Zonos.cartId,currency:i,id:t.checkoutSessionId,itemsAmount:s,landedCostId:n===null||n===void 0?void 0:n.landedCostId,presentmentCountryCode:o.selectedCountryCode,storeCreditApplication:D()})];case 1:u=f.sent(),l=u.errors,c=u.json;if(l.length>0||!c){v("Error updating checkout session with store credit");return[2]}He({method:((r=c.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:c.checkoutSessionUpdate.subtotals});Ge(c.checkoutSessionUpdate);return[2]}}))}))};var ur=e("X",(function(){if(qe){clearTimeout(qe)}qe=setTimeout((function(){qe=null;void sr()}),300)}))}}}));
1
+ var __awaiter=this&&this.__awaiter||function(e,r,n,t){function o(e){return e instanceof n?e:new n((function(r){r(e)}))}return new(n||(n=Promise))((function(n,i){function a(e){try{u(t.next(e))}catch(e){i(e)}}function s(e){try{u(t["throw"](e))}catch(e){i(e)}}function u(e){e.done?n(e.value):o(e.value).then(a,s)}u((t=t.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(s){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(n=0)),n)try{if(t=1,o&&(i=s[0]&2?o["return"]:s[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;if(o=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:n.label++;return{value:s[1],done:false};case 5:n.label++;o=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){n.label=s[1];break}if(s[0]===6&&n.label<i[1]){n.label=i[1];i=s;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(s);break}if(i[2])n.ops.pop();n.trys.pop();continue}s=r.call(e,n)}catch(e){s=[6,e];o=0}finally{t=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,r,n){if(n||arguments.length===2)for(var t=0,o=r.length,i;t<o;t++){if(i||!(t in r)){if(!i)i=Array.prototype.slice.call(r,0,t);i[t]=r[t]}}return e.concat(i||Array.prototype.slice.call(r))};System.register(["./p-ac30b7a8.system.js","./p-31d1b874.system.js","./p-d938f42f.system.js","./p-01174496.system.js","./p-d18a2b2c.system.js","./p-7501c637.system.js"],(function(e){"use strict";var r,n,t,o,i,a,s,u,d,l,c,v,f,m,p,h,w,g,y;return{setters:[function(e){r=e.c;n=e.z},function(e){t=e.s;o=e.l;i=e.e;a=e.t;s=e.f;u=e.b},function(e){d=e.l;l=e.b},function(e){c=e.h;v=e.l;f=e.f;m=e.g;p=e.a;h=e.s;w=e.j},function(e){g=e.i},function(e){y=e.g}],execute:function(){var b=this;var _=function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o;return __generator(this,(function(i){switch(i.label){case 0:if(!t.checkoutSessionId){return[2,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",t.checkoutSessionId);return[4,c("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:r=i.sent(),n=r.errors,o=r.json;return[2,{errors:n,json:o}]}}))}))};var S=r((function(){return{amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:false,isEnabled:false,orderIdCreated:null,remainingBalance:null,useFullBalance:true}})),O=S.onChange,A=S.reset,C=S.state;e("N",C);var k=e("O",(function(){A()}));var I=function(e){d("Store credit balance from session","info",e);C.availableBalance=e};var T=e("Z",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:return[4,_()];case 1:n=a.sent(),t=n.errors,o=n.json;if(t.length||!o){v("Failed to refresh store credit balance");return[2]}i=(r=(e=o.checkoutSession.customerProfile)===null||e===void 0?void 0:e.storeCreditBalance)!==null&&r!==void 0?r:null;I(i);return[2]}}))}))}));var E=e("w",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,s;return __generator(this,(function(l){switch(l.label){case 0:r=t.checkoutSessionId;if(!r){n="No checkout session found";v(n);C.error=n;return[2,{error:n,success:false}]}d("Applying store credit","info",{checkoutSessionId:r});C.isApplying=true;C.error=null;l.label=1;case 1:l.trys.push([1,3,,4]);return[4,c("/api/zonos-elements/store-credit/apply",{body:{checkoutSessionId:r},method:"POST"})];case 2:o=l.sent(),i=o.errors,a=o.json;if(i.length>0||!a){s=((e=i[0])===null||e===void 0?void 0:e.message)||"Failed to apply store credit";v(s);C.error=s;C.isApplying=false;return[2,{error:s,success:false}]}C.appliedAmount=a.amountApplied;C.remainingBalance=a.remainingBalance;C.isApplying=false;d("Store credit applied","info",{amountApplied:a.amountApplied,remainingBalance:a.remainingBalance});return[2,{error:null,success:true}];case 3:u=l.sent();s=u instanceof Error?u.message:"Failed to apply store credit";v(s);C.error=s;C.isApplying=false;return[2,{error:s,success:false}];case 4:return[2]}}))}))}));var N=e("V",(function(e){C.isEnabled=e;C.error=null;if(!e){C.amountToApply=null}}));var j=e("Y",(function(e){if(e===null){C.amountToApply=null;C.error=null;return}if(e<=0){C.error="Amount must be greater than zero";return}if(C.availableBalance!==null&&e>C.availableBalance){C.error="Amount exceeds available balance";return}var r=ze.total+(ze.storeCredit||0);if(e>r){C.error="Amount exceeds order total";return}C.error=null;C.amountToApply=e}));var P=e("W",(function(e){C.useFullBalance=e;C.error=null;if(e&&C.availableBalance!==null){var r=ze.total+(ze.storeCredit||0);var n=Math.min(C.availableBalance,r);C.amountToApply=n}else if(!e){C.amountToApply=null}}));var D=function(){if(!C.isEnabled||C.amountToApply===null){return{mode:"NONE"}}if(C.useFullBalance){return{mode:"FULL"}}return{amount:C.amountToApply,mode:"PARTIAL"}};var L=e("F",(function(){if(!C.isEnabled||C.availableBalance===null){return 0}if(C.useFullBalance){return Math.min(C.availableBalance,ze.total+(ze.storeCredit||0))}return C.amountToApply||0}));var x=e("x",(function(){return C.amountToApply!==null&&C.amountToApply>0&&ze.storeCredit>0&&ze.total<=0}));var R=e("z",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,l,f,m,l;return __generator(this,(function(p){switch(p.label){case 0:o=t.checkoutSessionId;if(!o){i="No checkout session found";v(i);C.error=i;return[2,{error:i,orderId:null,success:false}]}d("Creating store credit order","info",{checkoutSessionId:o});p.label=1;case 1:p.trys.push([1,3,,4]);return[4,c("/api/zonos-elements/store-credit/order-create",{body:{checkoutSessionId:o},method:"POST"})];case 2:a=p.sent(),s=a.errors,u=a.json;if(s.length>0||!u){l=((e=s[0])===null||e===void 0?void 0:e.message)||"Failed to create store credit order";v(l);C.error=l;return[2,{error:l,orderId:null,success:false}]}f=((n=(r=u.checkoutSessionStoreCreditOrderCreate)===null||r===void 0?void 0:r.order)===null||n===void 0?void 0:n.id)||null;C.orderIdCreated=f;d("Store credit order created","info",{orderId:f});return[2,{error:null,orderId:f,success:true}];case 3:m=p.sent();l=m instanceof Error?m.message:"Failed to create store credit order";v(l);C.error=l;return[2,{error:l,orderId:null,success:false}];case 4:return[2]}}))}))}));var U=e("Q",(function(e){var r=e.firstName,n=e.lastName,t=e.name;var o;if(!t&&!r&&!n){return{firstName:"",lastName:""}}var i=(t===null||t===void 0?void 0:t.split(/\s+/))||[];var a=(r===null||r===void 0?void 0:r.trim())||((o=i[0])===null||o===void 0?void 0:o.trim())||"";var s=(n===null||n===void 0?void 0:n.trim())||i.slice(1).join(" ").trim()||"";return{firstName:a,lastName:s}}));var z=function(e){var r=e.currentAddress,n=e.translatedAddress;var t,o,i,a,s,u;var d=r.value.address,l=d.city,c=d.country,v=d.line1,f=d.line2,m=d.postal_code,p=d.state;var h=r.value.name||[r.value.firstName,r.value.lastName].join(" ");return{city:((t=n.city)===null||t===void 0?void 0:t[l])||l,country:c,line1:((o=n.line1)===null||o===void 0?void 0:o[v])||v,line2:((i=n.line2)===null||i===void 0?void 0:i[f||""])||f||"",name:((a=n.name)===null||a===void 0?void 0:a[h])||h,phone:r.value.phone||"",postal_code:((s=n.postal_code)===null||s===void 0?void 0:s[m])||m,state:((u=n.state)===null||u===void 0?void 0:u[p])||p}};var B=function(e){var r;var n=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var a=ne.stripeLinkEventData;var s=ne.stripeAddressEventData;var u=ne.stripeShippingSameAsBilling?ne.stripeAddressEventData:ne.stripeBillingAddressEventData;if(!s||!u){throw new Error("Missing stripe address data")}var d=z({currentAddress:s,translatedAddress:ne.translatedAddress.address});var l=U({name:d.name}),c=l.firstName,v=l.lastName;var f=z({currentAddress:u,translatedAddress:ne.translatedAddress.address});var m=U({name:f.name}),p=m.firstName,h=m.lastName;var w=i()||"US";return{billingAddress:{addressLine1:f.line1,addressLine2:f.line2||"",city:f.city,country:f.country,postalCode:f.postal_code,state:f.state},billingContact:{firstName:p,lastName:h,phone:f.phone},cartCurrencyCode:(r=ze.items[0])===null||r===void 0?void 0:r.currencyCode,cartId:e,checkoutSessionCountry:w||o.selectedCountryCode||undefined,checkoutSessionId:t.checkoutSessionId||"",contact:{companyName:ne.companyName,email:a===null||a===void 0?void 0:a.value.email,firstName:c,lastName:v,phone:d.phone},isTest:!!n,landedCostAdjustments:ze.promoCode?[{amount:0,productId:null,promoCode:ze.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:ne.shortAddressCode,shipToTaxId:ne.taxId,shippingAddress:{addressLine1:d.line1,addressLine2:d.line2,city:d.city,country:d.country,postalCode:d.postal_code,state:d.state}}};var F=function(){var e=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var r=ne.stripeLinkEventData;var n=ne.stripeAddressEventData;var o=ne.stripeShippingSameAsBilling?ne.stripeAddressEventData:ne.stripeBillingAddressEventData;d({stripeAddressData:n,stripeBillingAddressData:o},"info");if(!n||!o){throw new Error("Missing stripe address data")}var i=z({currentAddress:n,translatedAddress:ne.translatedAddress.address});var a=U({name:i.name}),s=a.firstName,u=a.lastName;var l=z({currentAddress:o,translatedAddress:ne.translatedAddress.address});var c=U({name:l.name}),v=c.firstName,f=c.lastName;var m=ze.adjustments.map((function(e){return{amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}}));var p=ze.promoCode?__spreadArray([{amount:0,productId:null,promoCode:ze.promoCode,sku:null,type:"PROMO_CODE"}],m,true):m;return{billingAddress:{addressLine1:l.line1,addressLine2:l.line2||"",city:l.city,country:l.country,postalCode:l.postal_code,state:l.state},billingContact:{firstName:v,lastName:f,phone:l.phone},checkoutSessionId:t.checkoutSessionId||"",contact:{companyName:ne.companyName,email:r===null||r===void 0?void 0:r.value.email,firstName:s,lastName:u,phone:i.phone},isTest:e,items:ze.items,landedCostAdjustments:p,shipToShortAddressCode:ne.shortAddressCode,shipToTaxId:ne.taxId,shippingAddress:{addressLine1:i.line1,addressLine2:i.line2,city:i.city,country:i.country,postalCode:i.postal_code,state:i.state}}};var J=function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l;return __generator(this,(function(v){switch(v.label){case 0:a=F();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:f["vercel"]},{promoCode:ze.promoCode})];case 1:s=v.sent();if(!s||!((r=s.checkoutSessionWorkflow)===null||r===void 0?void 0:r.length)&&((n=s.errors)===null||n===void 0?void 0:n.length)){throw new Error("Failed to build landed cost: ".concat(((o=(t=s===null||s===void 0?void 0:s.errors)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.message)||"Unknown error"))}return[4,c("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:u=v.sent(),d=u.errors,l=u.json;if(!l||d.length){throw new Error("Invalid landed cost object: ".concat(((i=d.find(Boolean))===null||i===void 0?void 0:i.message)||"Unknown error"))}return[2,s]}}))}))};var M=function(e){return __awaiter(b,void 0,void 0,(function(){var r,t,o,i,a,s,u;return __generator(this,(function(d){switch(d.label){case 0:t=n.checkoutSettings.buildLandedCost;if(!t)return[3,2];return[4,J(t)];case 1:o=d.sent();return[2,o];case 2:return[4,c("/api/zonos-elements/calculate-landed-cost",{body:F(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:i=d.sent(),a=i.errors,s=i.json;if(a.length||!s){u=((r=a[0])===null||r===void 0?void 0:r.message)==="The user aborted a request.";if(u){throw new Error("The landed cost calculation request was aborted to initiate a new one.")}a.forEach((function(e){console.warn("Error calculating landed cost: ".concat(e.message))}));if(!s){throw new Error("Failed to calculate landed cost")}return[2,s]}return[2,s]}}))}))};var q=function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l;var v=e.abortController,f=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4,c("/api/zonos-elements/cart-calculate-landed-cost",{body:B(f),method:"POST",signal:v===null||v===void 0?void 0:v.signal})];case 1:a=e.sent(),s=a.errors,u=a.json;if(s.length||!u){d=typeof((r=s[0])===null||r===void 0?void 0:r.message)==="string"&&(((n=s[0])===null||n===void 0?void 0:n.message)==="The user aborted a request."||((t=s[0])===null||t===void 0?void 0:t.message.includes("signal is aborted"))||((o=s[0])===null||o===void 0?void 0:o.message.includes("The operation was aborted"))||((i=s[0])===null||i===void 0?void 0:i.message.includes("Fetch is aborted")));l=d?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(l)}return[2,u]}}))}))};var W=undefined&&undefined.__rest||function(e,r){var n={};for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0)n[t]=e[t];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,t=Object.getOwnPropertySymbols(e);o<t.length;o++){if(r.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o]))n[t[o]]=e[t[o]]}return n};var Y=function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:r=window.Zonos.cartId;if(!!r)return[3,2];return[4,M(e)];case 1:n=a.sent();return[2,n];case 2:return[4,q({abortController:e,cartId:r})];case 3:t=a.sent(),o=t.cartWorkflow,i=W(t,["cartWorkflow"]);return[2,Object.assign(Object.assign({},i),{itemCreateWorkflow:o.items})]}}))}))};var H=e("t",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,t,i,a,s,u,d,v,f;var w=e.checkoutSessionId,g=e.eventName,y=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:i=Date.now();a=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:w,eventCreated:i,eventName:g});s=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!((r=window.Zonos)===null||r===void 0?void 0:r.zonosQaUrl)||!!((t=window.Zonos)===null||t===void 0?void 0:t.debug);u=m()||p();if((u||s)&&!window.Zonos.zonosConversionTest){return[2]}d=o.selectedCountryCode;v=n.organizationId;if(!w){void h({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No checkout session id found')],metadata:{allLogs:l,checkoutSessionId:w,eventName:g,metadata:y,organizationId:v,trackEventLogs:a}});return[2]}if(!v){void h({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(g,'" - No organization id found')],metadata:{allLogs:l,checkoutSessionId:w,eventName:g,metadata:y,organizationId:v,trackEventLogs:a}})}f={checkoutSessionId:w,countryCode:d,eventCreated:i,eventName:g,metadata:Object.assign(Object.assign({},y),{trackEventLogs:a}),organizationId:v};return[4,c("/api/zonos-elements/track-conversion-event",{body:f,method:"POST"})];case 1:e.sent();return[2]}}))}))}));var K=function(e){var r=e.address,n=e.invalidAdddressList;if(!r){return}if(!n){return}var t={};if(n.city){t.city=r.city}if(n.line1){t.line1=r.line1}if(n.line2){t.line2=r.line2}if(n.postal_code){t.postal_code=r.postal_code}if(n.state){t.state=r.state}if(n.name){t.name=r.name}return Object.keys(t).length?t:undefined};var G=function(e){var r=e.addressInvalidCharactersList,n=e.billingAddressInvalidCharactersList,t=e.stripeAddressEventData,o=e.stripeBillingAddressEventData,i=e.stripeShippingSameAsBilling;var a=!!(t===null||t===void 0?void 0:t.complete);var s=i?a:!!(o===null||o===void 0?void 0:o.complete);if(!a||!s){return null}if(!r&&!n){return null}var u=t.value;var d=(o===null||o===void 0?void 0:o.value)||null;var l=U({firstName:u.firstName,lastName:u.lastName,name:u.name}),c=l.firstName,v=l.lastName;var f="".concat(c," ").concat(v);var m=U({firstName:d===null||d===void 0?void 0:d.firstName,lastName:d===null||d===void 0?void 0:d.lastName,name:(d===null||d===void 0?void 0:d.name)||""}),p=m.firstName,h=m.lastName;var w=p&&h?"".concat(p," ").concat(h):"";var g=u.address;var y=d===null||d===void 0?void 0:d.address;return{address:K({address:Object.assign(Object.assign({},g),{name:f}),invalidAdddressList:r}),billingAddress:!i?K({address:y?Object.assign(Object.assign({},y),{name:w}):null,invalidAdddressList:n}):undefined,destinationCountry:g.country}};var V=e("U",(function(e){var r=e.sort((function(e,r){return e.amount-r.amount}));return r}));var Z=e("y",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t;return __generator(this,(function(o){switch(o.label){case 0:return[4,_()];case 1:r=o.sent(),n=r.errors,t=r.json;if(n.length||!t){v("Failed to retrieve checkout session info before confirming payment ",n);void h({endpoint:"validateCheckoutSession",errors:n.map((function(e){return e.message})),metadata:{allLogs:l}});return[2,{errorMessage:a("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:false}]}if(!((e=t.checkoutSession.landedCost)===null||e===void 0?void 0:e.id)){v("Landed cost is not found in the checkout session before confirming payment.");void h({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:l}});return[2,{errorMessage:a('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:false}]}return[2,{errorMessage:"",valid:true}]}}))}))}));var Q=function(e){var r=e.theme;var t={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:n.appearance.fontSizeInputValue?"".concat(n.appearance.fontSizeInputValue,"px"):undefined,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:n.appearance.fontSizeInputLabel?"".concat(n.appearance.fontSizeInputLabel,"px"):undefined},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};switch(r){case"DARK":{return Object.assign(Object.assign({},t),{".Action":Object.assign(Object.assign({},t[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},t[".PickerItem--new"]),{color:"white"})})}default:return t}};var X=function(e){var r=e.borderStyle,n=e.theme;switch(n){case"DARK":return{borderRadius:y({overrideBorderStyle:r}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:y({overrideBorderStyle:r}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var $=r((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,shortAddressCode:"",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:{}}}})),ee=$.onChange,re=$.reset,ne=$.state;e({E:ee,b:ne});var te=function(e){var r=e.clientSecret,t=e.overrideBorderRadius,i=e.overridePrimaryColor,a=e.overrideSecondaryColor,s=e.overrideTheme,u=e.paypalEnabled;var d=i||n.appearance.colorPrimary;var l=a||n.appearance.colorSecondary;var c=window.Zonos.isCollect||window.Zonos.isInvoice?n.appearance.theme==="DARK":d&&g(d);var v=c?"night":"flat";var f=s==="DARK"?"night":"flat";var m=u?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},Q({theme:s||"LIGHT"})),theme:s?f:v,variables:Object.assign(Object.assign({},X({borderStyle:t,theme:"LIGHT"})),{colorPrimary:l})},clientSecret:r||undefined,customerSessionClientSecret:ne.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],m,true),locale:o.selectedLocale}};var oe=e("o",(function(){window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")}));var ie=e("a",(function(e){window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))}));var ae=e("s",(function(){var e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return w(e)}));var se=e("i",(function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i;return __generator(this,(function(a){t=ne.clientSecret;if(!ne.stripe){d("Skip. Stripe is not initialized");return[2]}o=te({clientSecret:t,overrideBorderRadius:e===null||e===void 0?void 0:e.overrideBorderRadius,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideSecondaryColor:e===null||e===void 0?void 0:e.overrideSecondaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme,paypalEnabled:e===null||e===void 0?void 0:e.paypalEnabled});i=JSON.stringify(o)===JSON.stringify(ne.stripeElementsOptions);if(!ne.stripeElements||!ne.stripeElementsForBillingAddress){ne.stripeElementsForBillingAddress=(r=ne.stripe)===null||r===void 0?void 0:r.elements(o);d("Stripe elements for billing address initialized");ne.stripeElements=(n=ne.stripe)===null||n===void 0?void 0:n.elements(o);ne.stripeElementsOptions=o;d("Stripe elements initialized");return[2]}if(!i){ne.stripeElements.update(o);ne.stripeElementsForBillingAddress.update(o);ne.stripeElementsOptions=o;void ne.stripeElements.fetchUpdates()}d("Stripe elements updated");return[2]}))}))}));var ue=e("C",(function(){sessionStorage.removeItem("zonos--client-secret");re();ne.stripe=window.Zonos.stripe}));var de=function(){var e,r,n,t;var o=JSON.stringify((e=ne.stripeAddressUsedWhenValidatingAddress)===null||e===void 0?void 0:e.value)!==JSON.stringify((r=ne.stripeAddressEventData)===null||r===void 0?void 0:r.value);var i=!ne.stripeShippingSameAsBilling&&JSON.stringify((n=ne.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value)!==JSON.stringify((t=ne.stripeBillingAddressUsedWhenValidatingAddress)===null||t===void 0?void 0:t.value);return o||i};var le=function(){var e,r,n,t,o,i,a,s;var u=(e=ze.partiesData.find((function(e){return e.type==="DESTINATION"})))===null||e===void 0?void 0:e.id;var d=(r=ze.partiesData.find((function(e){return e.type==="PAYOR"})))===null||r===void 0?void 0:r.id;if(!u||!d){return false}if(ne.partyShippingId!==u||ne.partyBillingId!==d){return true}var l=JSON.stringify((n=ne.stripeLinkUsedWhenFetchingLC)===null||n===void 0?void 0:n.value)!==JSON.stringify((t=ne.stripeLinkEventData)===null||t===void 0?void 0:t.value);var c=JSON.stringify((o=ne.stripeAddressUsedWhenAsyncAddressUpdate)===null||o===void 0?void 0:o.value)!==JSON.stringify((i=ne.stripeAddressEventData)===null||i===void 0?void 0:i.value);var v=!ne.stripeShippingSameAsBilling&&JSON.stringify((a=ne.stripeBillingAddressUsedWhenAsyncAddressUpdate)===null||a===void 0?void 0:a.value)!==JSON.stringify((s=ne.stripeBillingAddressEventData)===null||s===void 0?void 0:s.value);var f=ne.taxIdUsedWhenAsyncAddressUpdate!==ne.taxId;var m=ne.companyNameUsedWhenAsyncAddressUpdate!==ne.companyName;return l||c||v||f||m};var ce=e("G",(function(e){var r=e.address,n=e.firstName,o=e.lastName,i=e.name,a=e.phone;var s=U({firstName:n,lastName:o,name:i}),u=s.firstName,d=s.lastName;if(!u||!d){void h({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,firstName:n,lastName:o,name:i}})}if(!a){void h({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,phone:a}})}return{city:r.city,country:r.country,firstName:u,lastName:d,line1:r.line1,line2:r.line2,phone:a||"",postal_code:r.postal_code,state:r.state}}));var ve=e("R",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,d,f,m,p;return __generator(this,(function(w){switch(w.label){case 0:if(!((e=ne.stripeAddressEventData)===null||e===void 0?void 0:e.complete)||!ne.stripeShippingSameAsBilling&&!((r=ne.stripeBillingAddressEventData)===null||r===void 0?void 0:r.complete)||!ne.stripeBillingAddressEventData){return[2,{partiesCreated:false}]}if(!ze.landedCostData){return[2,{partiesCreated:false}]}i=(n=ze.landedCostData.find(Boolean))===null||n===void 0?void 0:n.landedCost.rootId;if(!i){void h({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId}});return[2,{partiesCreated:false}]}a=le();if(!a){return[2,{partiesCreated:false}]}s=ce({address:ne.stripeAddressEventData.value.address,firstName:ne.stripeAddressEventData.value.firstName,lastName:ne.stripeAddressEventData.value.lastName,name:ne.stripeAddressEventData.value.name,phone:ne.stripeAddressEventData.value.phone});u=ne.stripeShippingSameAsBilling?s:ce({address:ne.stripeBillingAddressEventData.value.address,firstName:ne.stripeBillingAddressEventData.value.firstName,lastName:ne.stripeBillingAddressEventData.value.lastName,name:ne.stripeBillingAddressEventData.value.name,phone:ne.stripeBillingAddressEventData.value.phone});d=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,c("/api/zonos-elements/create-parties",{body:{address:s,billingAddress:u,companyName:ne.companyName,email:((o=ne.stripeLinkEventData)===null||o===void 0?void 0:o.value.email)||"",isTest:d,rootId:i,shortAddressCode:ne.shortAddressCode,taxId:ne.taxId},method:"POST"})];case 1:f=w.sent(),m=f.errors,p=f.json;if(m.length||!p){v("Error occurs when creating parties",JSON.stringify(m,null,2));void h({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,errors:m,json:p}});return[2,{partiesCreated:false}]}ne.companyNameUsedWhenAsyncAddressUpdate=ne.companyName;ne.stripeAddressUsedWhenAsyncAddressUpdate=ne.stripeAddressEventData;ne.stripeBillingAddressUsedWhenAsyncAddressUpdate=ne.stripeBillingAddressEventData;ne.taxIdUsedWhenAsyncAddressUpdate=ne.taxId;ne.partyBillingId=p.billToPartyId;ne.partyShippingId=p.shipToPartyId;ze.partiesData=ze.partiesData.map((function(e){if(e.type==="DESTINATION"&&e.id!==p.shipToPartyId){return Object.assign(Object.assign({},e),{id:p.shipToPartyId})}if(e.type==="PAYOR"&&e.id!==p.billToPartyId){return Object.assign(Object.assign({},e),{id:p.billToPartyId})}return e}));return[2,{partiesCreated:true}]}}))}))}));var fe=function(e){return{countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}};var me=function(){var e,r;var n=JSON.stringify((e=ne.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((r=ne.stripeLinkEventData)===null||r===void 0?void 0:r.value);var t=ne.stripeAddressEventData&&JSON.stringify(fe(ne.stripeAddressEventData.value))!==JSON.stringify(ne.stripeAddressUsedWhenFetchingLC);var o=!ne.stripeShippingSameAsBilling&&ne.stripeBillingAddressEventData&&JSON.stringify(fe(ne.stripeBillingAddressEventData.value))!==JSON.stringify(ne.stripeBillingAddressUsedWhenFetchingLC);return n||t||o};var pe=function(){var e;var r=ze.landedCostData&&((e=ze.landedCostData.find(Boolean))===null||e===void 0?void 0:e.subtotals.items)!==ze.subtotal;var n=me();d("isPrefetchInfoOutdated","info",{isAddressOutdated:n});return!ze.landedCostData&&!ne.isFetchingLandedCost||n||r};var he=function(e){var r,t;var o=(r=n.genericSettings)===null||r===void 0?void 0:r.countryFields;var i=(t=n.genericSettings)===null||t===void 0?void 0:t.stripeCountryFieldLabels;var a=i&&e in i?i[e]:null;var s=o&&e in o?o[e]:null;if(ze.addressFormRenderType==="stripe"){return a||s}return s};var we=function(){var e,r,n,t;var o=!!((e=ne.stripeLinkEventData)===null||e===void 0?void 0:e.complete);var i=!!((r=ne.stripeAddressEventData)===null||r===void 0?void 0:r.complete);var a=ne.stripeShippingSameAsBilling?i:!!((n=ne.stripeBillingAddressEventData)===null||n===void 0?void 0:n.complete);var s=((t=ne.stripeAddressEventData)===null||t===void 0?void 0:t.value.address.country)||"US";var u=he(s);if(i&&a&&o){return true}if(!u||!ne.stripeAddressEventData){return i&&a&&o}var d=ne.stripeAddressEventData.value.address.line1.length>0;var l=ne.stripeAddressEventData.value.firstName&&ne.stripeAddressEventData.value.lastName;var c=!u.stateRequired||u.stateRequired&&ne.stripeAddressEventData.value.address.state.length>0;var v=!u.zipRequired||u.zipRequired&&ne.stripeAddressEventData.value.address.postal_code.length>=3;var f=ne.stripeAddressEventData.value.phone&&ne.stripeAddressEventData.value.phone.length>0;return o&&l&&d&&c&&v&&f};var ge=function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,d,l,c;return __generator(this,(function(v){switch(v.label){case 0:r=new AbortController;ne.fetchingLandedCostAbortController=r;rr();return[4,Y(r)];case 1:n=v.sent(),o=n.checkoutSessionWorkflow,i=n.errors,a=n.itemCreateWorkflow,s=n.landedCostCalculateWorkflow,u=n.partyCreateWorkflow,d=n.shipmentRatingCalculateWorkflow;ze.customQuotingError=((e=i===null||i===void 0?void 0:i.find((function(e){var r;return((r=e.extensions)===null||r===void 0?void 0:r.ruleMessageType)==="CUSTOM"})))===null||e===void 0?void 0:e.message)||null;ze.shippingData=V((d===null||d===void 0?void 0:d.filter(Boolean))||[]);Me(a);ne.fetchingLandedCostAbortController=null;ze.partiesData=(u===null||u===void 0?void 0:u.filter(Boolean))||[];ze.landedCostData=(o===null||o===void 0?void 0:o.map((function(e){var r=s===null||s===void 0?void 0:s.find((function(r){return(r===null||r===void 0?void 0:r.id)===e.landedCostId}));if(!r){return null}return Object.assign(Object.assign({},e),{landedCost:r})})).filter(Boolean))||[];l=t.checkoutSessionId;if(o===null||o===void 0?void 0:o.length){void H({checkoutSessionId:l,eventName:"checkout_quoteReceived"})}c=ze.promoCodeApplied&&!ze.landedCostData.find((function(e){var r;return(r=e.landedCost.appliedAdjustments)===null||r===void 0?void 0:r.find((function(e){return e.type==="PROMO_CODE"}))}));ze.promoCodeError=c;if(!c){sessionStorage.setItem("zonos--promo-code",ze.promoCode)}return[2]}}))}))};var ye=e("q",(function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l,c,f,m,p;return __generator(this,(function(w){switch(w.label){case 0:i=(e===null||e===void 0?void 0:e.retries)||0;a=!!(e===null||e===void 0?void 0:e.applyingPromocode);s=pe();u=we();if(!u){return[2,{isRequestNotReady:true}]}if(s){(r=ne.fetchingLandedCostAbortController)===null||r===void 0?void 0:r.abort();ne.fetchingLandedCostAbortController=null}if(!s&&!a){return[2,{isRequestNotReady:false}]}if(i){ne.isFetchingLandedCost=false;setTimeout((function(){ne.isFetchingLandedCost=true}),300)}else{ne.isFetchingLandedCost=true}if(ne.stripeAddressEventData){ne.stripeAddressUsedWhenFetchingLC={countryCode:ne.stripeAddressEventData.value.address.country,postalCode:ne.stripeAddressEventData.value.address.postal_code,state:ne.stripeAddressEventData.value.address.state}}if(ne.stripeBillingAddressEventData){ne.stripeBillingAddressUsedWhenFetchingLC={countryCode:ne.stripeBillingAddressEventData.value.address.country,postalCode:ne.stripeBillingAddressEventData.value.address.postal_code,state:ne.stripeBillingAddressEventData.value.address.state}}if(ne.stripeLinkEventData){ne.stripeLinkUsedWhenFetchingLC=Object.assign({},ne.stripeLinkEventData)}w.label=1;case 1:w.trys.push([1,3,,7]);rr();return[4,ge()];case 2:w.sent();d=(n=ze.shippingData)===null||n===void 0?void 0:n.find(Boolean);l=(t=ze.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCost.shipmentRating.id===(d===null||d===void 0?void 0:d.id)}));c=!!l?l.subtotals:null;if(c){He({method:(l===null||l===void 0?void 0:l.landedCost.method)||"DDP",subtotals:c})}return[3,7];case 3:f=w.sent();ze.landedCostData=[];ze.shippingData=[];m=["The landed cost calculation request was aborted to initiate a new one."];if(!(f instanceof Error&&f.message&&!m.includes(f.message)))return[3,6];if(!(i<1))return[3,5];return[4,ye(Object.assign(Object.assign({},e),{retries:(i||0)+1}))];case 4:w.sent();return[2,{isRequestNotReady:false}];case 5:p=(o=ne.stripeAddressEventData)===null||o===void 0?void 0:o.value;void h({endpoint:"Failed to fetch landed cost (".concat(i," retries)"),errors:[f.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:p}});w.label=6;case 6:v(f);return[3,7];case 7:ne.isFetchingLandedCost=false;return[2,{isRequestNotReady:false}]}}))}))}));var be=e("J",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t;return __generator(this,(function(o){switch(o.label){case 0:return[4,ye({applyingPromocode:true})];case 1:o.sent();if(ze.step==="payment"){or()}return[4,ve()];case 2:o.sent();n=(e=ze.shippingData)===null||e===void 0?void 0:e.find(Boolean);t=(r=ze.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCost.id===(n===null||n===void 0?void 0:n.id)}));if(!n||!t){return[2]}return[4,Qe({applySubtotalsOnly:false,landedCostId:t.landedCostId,selectedShippingOption:n})];case 3:o.sent();return[2]}}))}))}));var _e=e("L",(function(){ze.promoCode="";sessionStorage.removeItem("zonos--promo-code");ze.promoCodeError=false;ze.promoCodeApplied=false}));var Se=e("K",(function(){return __awaiter(b,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:if(ze.step==="payment"){or()}_e();return[4,be()];case 1:e.sent();return[2]}}))}))}));var Oe=e("M",(function(e){var r=[];var n=true;var t=window.Zonos.isCollect;var o=window.Zonos.isInvoice;switch(e){case"succeeded":{r=[a("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"",a("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")];if(t||o){r=[a("Thank you for submitting your payment. We appreciate your prompt attention."),"",a("A confirmation email with your payment details has been sent for your records. If you have any questions or need support, our team is here to help.")]}n=false;break}case"requires_capture":case"processing":{r=[a("Payment processing. We'll update you when payment is received.")];n=false;break}case"requires_payment_method":{r=[a("Payment failed. Please try another payment method.")];if(t){r=[a("Payment failed. Please reload the page and try another payment method.")]}break}case"requires_action":{n=false;r=[a("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}default:{r=[a("Something went wrong.")];break}}return{isError:n,messages:r}}));var Ae=e("v",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,t,o,i,s,u,d,l,d;return __generator(this,(function(m){switch(m.label){case 0:t=n.checkoutSettings.onInventoryCheck;o=!!((r=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||r===void 0?void 0:r.value);if(!(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o))return[3,2];return[4,c("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:i=m.sent(),s=i.errors,u=i.json;if(s.length||!u){v("Error occurs when handling inventory refund","warn",JSON.stringify(s));return[2,null]}if(!u.available||u.status===204){return[2,a("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")]}if(u.available||u.status===200){ne.shouldInventoryRefund=true;return[2,null]}return[2,null];case 2:if(typeof t!=="function"){return[2,null]}m.label=3;case 3:m.trys.push([3,5,,6]);return[4,t({items:ze.items},{translate:a,zonosApiRoute:f["vercel"]})];case 4:d=m.sent();return[2,d];case 5:l=m.sent();d=l instanceof Error?l.message:"Unknown error";void h({endpoint:"onInventoryCheck",errors:["cartId: ".concat(window.Zonos.cartId," - ").concat(d)],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:ze.items}});throw l;case 6:return[2]}}))}))}));var Ce=e("B",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n;return __generator(this,(function(t){switch(t.label){case 0:n=!!((r=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||r===void 0?void 0:r.value);if(!window.Zonos.isLegacyCheckout||!window.Zonos.cartData||!n){return[2]}return[4,c("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:t.sent();return[2]}}))}))}));var ke=e("c",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,t,o,i,s,u,d,l;var c=e.clientSecret,f=e.storybookForceStatus;return __generator(this,(function(e){switch(e.label){case 0:if(f){r=Oe(f),n=r.isError,t=r.messages;return[2,{error:n,messages:t}]}o=c||ne.clientSecret;if(!ne.stripe||!o){v("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[a("Something went wrong.")]}]}return[4,ne.stripe.retrievePaymentIntent(o)];case 1:i=e.sent().paymentIntent;s=i===null||i===void 0?void 0:i.status;u=Oe(s),d=u.isError,l=u.messages;return[2,{amount:i===null||i===void 0?void 0:i.amount,currency:i===null||i===void 0?void 0:i.currency,error:d,messages:l,paymentIntentId:i===null||i===void 0?void 0:i.id,paymentMethod:i===null||i===void 0?void 0:i.payment_method,status:s}]}}))}))}));var Ie=e("A",(function(e){return __awaiter(b,void 0,void 0,(function(){var r,n,o,i,s,u,l,c,v,f,m,p;return __generator(this,(function(h){switch(h.label){case 0:o=!!((r=ne.stripePaymentEventData)===null||r===void 0?void 0:r.complete);i=ne.stripeElements;s=ne.stripe;u=ne.clientSecret;ne.customErrorMessage=null;if(!((n=ze.selectedLandedCost)===null||n===void 0?void 0:n.landedCost.id)&&!(e===null||e===void 0?void 0:e.noLandedCostCheck)){throw new Error("Attempted to confirm the payment when no landed cost is found in store")}return[4,Z()];case 1:l=h.sent();if(!l.valid){ne.customErrorMessage=l.errorMessage;throw new Error(l.errorMessage)}c=t.checkoutSessionId;if(!(s&&i&&o&&u&&c))return[3,3];v=new URL(window.location.href);v.searchParams.set("payment_intent_client_secret",u);v.searchParams.set("zonosCheckoutSessionId",c);void H({checkoutSessionId:c,eventName:"checkout_paymentInfoCompleted"});return[4,s.confirmPayment({confirmParams:{return_url:v.toString()},elements:i,redirect:"if_required"})];case 2:f=h.sent(),m=f.error,p=f.paymentIntent;d("Payment intent confirmed","info",{error:m,paymentIntent:p});if((p===null||p===void 0?void 0:p.status)==="requires_action"){throw new Error(a("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."))}if(m){if(m.type==="card_error"||m.type==="validation_error"){throw new Error(m.message)}if(m.type==="invalid_request_error"){if(m.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}if(p.status==="requires_payment_method"){throw new Error(a("Payment failed. Please try another payment method."))}h.label=3;case 3:return[2]}}))}))}));var Te=e("m",(function(){var e;var r=ze.items.reduce((function(e,r){return e+r.amount*r.quantity}),0);var n=t.enabledVariantTestKeys||[];var i={adjustmentsAmount:ze.adjustments.reduce((function(e,r){return e+r.amount}),0),cartId:window.Zonos.cartId,currency:((e=ze.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",customerAuthenticationToken:ze.customerAuthenticationToken||undefined,isCollect:!!window.Zonos.isCollect,isInvoice:!!window.Zonos.isInvoice,itemsAmount:r,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:o.selectedCountryCode,skipPaymentIntent:ne.skipPaymentIntent,varianceTestInput:n};return i}));var Ee=e("k",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,o,i;return __generator(this,(function(s){switch(s.label){case 0:if(!t.checkoutSessionId){void h({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:l,cartId:window.Zonos.cartId}});Ye({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2]}return[4,c("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:t.checkoutSessionId},method:"POST"})];case 1:r=s.sent(),n=r.errors,o=r.json;i=(e=o===null||o===void 0?void 0:o.checkoutSessionPaymentIntentCreate)===null||e===void 0?void 0:e.clientSecret;if(n.length||!i){v("Error occurs when getting payment intent",JSON.stringify(n,null,2));void h({endpoint:"Error creating payment intent",errors:n.map((function(e){return e.message})),metadata:{allLogs:l,cartId:window.Zonos.cartId,checkoutSessionId:t.checkoutSessionId,clientSecret:i}});Ye({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2]}Ge(o.checkoutSessionPaymentIntentCreate);return[2]}}))}))}));var Ne=e("j",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,t,i,a,s,u;return __generator(this,(function(l){switch(l.label){case 0:if(!o.targetCurrency){v("Failed to create checkout session - missing localizationStore.targetCurrency");return[2,false]}ne.isFetchingSession=true;n=Te();d("Checkout session body","info",n);return[4,c("/api/zonos-elements/create-checkout-session",{body:n,method:"POST"})];case 1:t=l.sent(),i=t.errors,a=t.json;ne.isFetchingSession=false;if(i.length||!a){s=(e=i.find((function(e){return e.message})))===null||e===void 0?void 0:e.message;if(Array.isArray(s)&&s.some((function(e){return e.message==="Cart is expired."}))){throw new Error("Cart is expired.")}v("Error occurred when creating checkout session",JSON.stringify(i,null,2));return[2,false]}u=a.checkoutSessionCreate;Ge(u);He({method:((r=u.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:u.subtotals});d("Exchange rate updated for cart items (checkout session create)","info",ze.exchangeRate);d("done-init-checkout-session");return[2,true]}}))}))}));var je=e("u",(function(){return __awaiter(b,void 0,void 0,(function(){var e,r,o;return __generator(this,(function(i){switch(i.label){case 0:e=t.checkoutSessionId;if(!e){v("Failed to update checkout session base currency");return[2,false]}if(n.checkoutSettings.allowedSettlementCurrencies==="LOCAL"){d('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency');return[2,true]}return[4,c("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:ne.checkoutSettlementCurrency},method:"POST"})];case 1:r=i.sent().json;o=r===null||r===void 0?void 0:r.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;if(!r||o!==ne.checkoutSettlementCurrency){v("Failed to update checkout session base currency");return[2,false]}d('Updated checkout session to settlement currency "'.concat(o,'".'));return[2,true]}}))}))}));var Pe=function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,i,a;var s=e.adjustmentsAmount,u=e.cartId,d=e.currency,l=e.id,f=e.itemsAmount,m=e.landedCostId,p=e.presentmentCountryCode,h=e.storeCreditApplication;return __generator(this,(function(e){switch(e.label){case 0:r=t.enabledVariantTestKeys||[];return[4,c("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:s,billToPartyId:ne.partyBillingId,cartId:u,currency:d,customerAuthenticationToken:ze.customerAuthenticationToken||undefined,id:l,itemsAmount:f,landedCostId:m,metadata:[{key:"language",value:o.selectedLocale}],presentmentCountryCode:p,shipToPartyId:ne.partyShippingId,skipPaymentIntent:ne.skipPaymentIntent,storeCreditApplication:h,varianceTestInput:r},method:"POST"})];case 1:n=e.sent(),i=n.errors,a=n.json;if(i.length||!a){v("Error occurs when updating checkout session",JSON.stringify(i,null,2));return[2,{errors:i,json:a}]}return[2,{errors:[],json:a}]}}))}))};var De=function(e){var r,n,t,o,i,a;var s=e.currentAddress,u=e.translatedAddressResult;var d={};if(!u){return d}var l=u.city,c=u.line1,v=u.line2,f=u.name,m=u.postal_code,p=u.state;if(s.city&&l){d.city=(r={},r[s.city]=l,r)}if(s.line1&&c){d.line1=(n={},n[s.line1]=c,n)}if(s.line2&&v){d.line2=(t={},t[s.line2]=v,t)}if(s.postal_code&&m){d.postal_code=(o={},o[s.postal_code]=m,o)}if(s.state&&p){d.state=(i={},i[s.state]=p,i)}if(s.name&&f){d.name=(a={},a[s.name]=f,a)}return d};var Le=e("P",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l,f;var m=e.addressInvalidCharactersList,p=e.billingAddressInvalidCharactersList;return __generator(this,(function(e){switch(e.label){case 0:i=G({addressInvalidCharactersList:m,billingAddressInvalidCharactersList:p,stripeAddressEventData:ne.stripeAddressEventData,stripeBillingAddressEventData:ne.stripeBillingAddressEventData,stripeShippingSameAsBilling:ne.stripeShippingSameAsBilling});if(!i){ne.translatedAddress={address:{},billingAddress:{}};return[2]}a=de();if(!a){return[2]}return[4,c("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),u=s.errors,d=s.json;if(u.length||!d){v("Error occurs when translating address to latin",JSON.stringify(u,null,2));ne.translatedAddress={address:{},billingAddress:{}};return[2]}ne.stripeAddressUsedWhenValidatingAddress=ne.stripeAddressEventData;ne.stripeBillingAddressUsedWhenValidatingAddress=ne.stripeBillingAddressEventData;l=(r=ne.stripeAddressEventData)===null||r===void 0?void 0:r.value.address;f=(n=ne.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value.address;ne.translatedAddress={address:l?De({currentAddress:Object.assign(Object.assign({},l),{name:(t=ne.stripeAddressEventData)===null||t===void 0?void 0:t.value.name}),translatedAddressResult:d.address||null}):{},billingAddress:!ne.stripeShippingSameAsBilling?De({currentAddress:Object.assign(Object.assign({},f),{name:(o=ne.stripeBillingAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:d.billingAddress||null}):{}};return[2]}}))}))}));ee("clientSecret",(function(e){if(e&&ne.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var xe=r((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:p(),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",storeCredit:0,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}})),Re=xe.onChange,Ue=xe.reset,ze=xe.state;e({D:Re,d:ze});var Be=function(e){switch(e){case"DAYS":return a("days");case"WEEKS":return a("weeks");case"BUSINESS_DAYS":default:return a("business days")}};var Fe=e("S",(function(e){var r;var n=(r=e.shippingProfile)===null||r===void 0?void 0:r.transitTime;if(!(n===null||n===void 0?void 0:n.min)||!(n===null||n===void 0?void 0:n.max)||!(n===null||n===void 0?void 0:n.type)){return null}return{maxTransit:n.max,minTransit:n.min,unit:Be(n.type)}}));var Je=function(e){var r=e.item1,n=e.item2;if(!r||!n){return false}return n.sku&&r.sku&&r.sku===n.sku||n.description&&r.description&&r.description===n.description||r.name&&n.name&&r.name===n.name};var Me=function(e){d("Checking item restrictions");var r=e.map((function(e){if(!e.restriction){return null}var r=e.restriction;var n=ze.items.find((function(r){return Je({item1:r,item2:e})}));return Object.assign(Object.assign({matchedItem:n},e),{restriction:r})})).filter(Boolean);ze.restrictedItems=r;ze.items=ze.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:!!r.find((function(r){return Je({item1:r,item2:e})}))})}));return{cartItems:ze.items,restrictedItems:r}};var qe=null;var We=e("f",(function(){t.checkoutSessionId=null;if(qe){clearTimeout(qe);qe=null}k();Ue()}));var Ye=e("n",(function(e){var r=e.messages,n=e.title;We();ue();ze.step="error";ze.error={messages:r,title:n}}));var He=function(e){var r=e.dutiesTaxesFeesEstimate,n=e.method,t=e.subtotals;var o;ze.exchangeRate=t.exchangeRate;ze.adjustmentTotal=t.adjustments;ze.dutiesTaxesFees=n==="DAP"?null:t.landedCostTotal;ze.storeCredit=(o=t.storeCredit)!==null&&o!==void 0?o:0;ze.subtotal=t.items;ze.total=t.total;ze.currency=t.presentmentCurrencyCode;ze.dutiesTaxesFeesEstimate=r||null};var Ke=e("I",(function(){var e=ze.items.filter((function(e){return e.amount>0}));return!!e.find((function(e){return!e.isRestricted}))}));var Ge=e("p",(function(e){var r,n,o,i,a,c,v;ne.clientSecret=e.clientSecret;ne.stripeCustomerSessionClientSecret=e.customerSessionClientSecret;ne.customerProfile=e.customerProfile;ze.checkoutSession=e;I((n=(r=e.customerProfile)===null||r===void 0?void 0:r.storeCreditBalance)!==null&&n!==void 0?n:null);if(!e.id){void h({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:l,checkoutSession:e}})}if(e.id){t.checkoutSessionId=e.id}var f=s(e.varianceTestResults||[]);u(f);var m=((a=(i=(o=ze.checkoutSession)===null||o===void 0?void 0:o.metadata)===null||i===void 0?void 0:i.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||a===void 0?void 0:a.value)||((v=(c=window.Zonos.cartData)===null||c===void 0?void 0:c.metadata.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||v===void 0?void 0:v.value)||null;if(m){d("Found externalConfirmationPageURL: ".concat(m));ze.externalConfirmationPageURL=m}}));var Ve=function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,i,s,u,l;var c=e.adjustmentsAmount,f=e.cartId,m=e.currency,p=e.dutiesTaxesFeesEstimate,h=e.itemsAmount,w=e.landedCostId,g=e.shouldInitSessionOnFailure;return __generator(this,(function(e){switch(e.label){case 0:if(w&&ze.selectedLandedCost){n=ze.selectedLandedCost.subtotals;He({dutiesTaxesFeesEstimate:p,method:ze.landedCostMethod,subtotals:n});d("Exchange rate updated for cart items (landed cost subtotal)","info",ze.exchangeRate)}if(!t.checkoutSessionId){d("Could not update cart total without checkout session id","info");return[2,false]}return[4,Pe({adjustmentsAmount:c,billToPartyId:ne.partyBillingId,cartId:f,currency:m,id:t.checkoutSessionId,itemsAmount:h,landedCostId:w,presentmentCountryCode:o.selectedCountryCode,shipToPartyId:ne.partyShippingId,varianceTestInput:t.enabledVariantTestKeys||[]})];case 1:i=e.sent(),s=i.errors,u=i.json;if(!(s.length>0||!u))return[3,4];v("Error occurs when updating checkout session.");if(!g)return[3,3];d("Initiating checkout session on failure","info");return[4,Ne()];case 2:l=e.sent();d("stripeStoreInitCheckoutSession: ".concat(l));if(!l){Ye({messages:[a("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:a("Error creating Checkout")});return[2,false]}return[2,true];case 3:return[2,false];case 4:if(!w){He({method:((r=u.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:u.checkoutSessionUpdate.subtotals});d("Exchange rate updated for cart items (checkout session update)","info",ze.exchangeRate)}Ge(u.checkoutSessionUpdate);return[2,true]}}))}))};var Ze=e("T",(function(e){var r,t,o;if(e.method==="DAP"&&((t=(r=n.genericSettings)===null||r===void 0?void 0:r.domesticCountries)===null||t===void 0?void 0:t.includes(((o=ne.stripeAddressEventData)===null||o===void 0?void 0:o.value.address.country)||"US"))){return"DDP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method}));var Qe=e("H",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,o,i,a,s,u,l,c,v,f,m,p,h,w,g,y,b,_,S,O,A,C,k,I,T;var E=e.applySubtotalsOnly,N=e.landedCostId,j=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:d("Updating selected shipping option","info",{landedCostId:N,selectedShippingOption:j});ze.selectedShippingOption=j;p=Fe(ze.selectedShippingOption);if(p){h=p.maxTransit,w=p.minTransit,g=p.unit;ze.selectedShippingOptionTransitTime="".concat(w,"-").concat(h," ").concat(g)}else{ze.selectedShippingOptionTransitTime=""}y=(r=ze.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCostId===N}));ze.selectedLandedCost=y||null;if(!y){return[2,false]}b=((o=y.landedCost.amountSubtotals)===null||o===void 0?void 0:o.landedCostTotal)||0;_=y.subtotals.exchangeRate.rate;S=b*_;if(S){d("DAP quote, using estimate: ".concat(S),"info")}ze.landedCostMethod=Ze(y.landedCost);ze.shipping=y.subtotals.shipping;O=((i=y===null||y===void 0?void 0:y.landedCost)===null||i===void 0?void 0:i.landedCostGuaranteeCode)==="ZONOS";A=!!((s=(a=y===null||y===void 0?void 0:y.landedCost)===null||a===void 0?void 0:a.deMinimis)===null||s===void 0?void 0:s.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));ze.isSelectedShippingAboveDeminimis=A;ze.isSelectedShippingGuarantee=O;C=false;if(!E)return[3,1];k=y.subtotals;He({dutiesTaxesFeesEstimate:S,method:ze.landedCostMethod,subtotals:k});d("Exchange rate updated for cart items (landed cost subtotal)","info",ze.exchangeRate);C=true;return[3,3];case 1:return[4,Ve({adjustmentsAmount:ze.adjustmentTotal,billToPartyId:ne.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:S,landedCostId:(u=y.landedCost)===null||u===void 0?void 0:u.id,shipToPartyId:ne.partyShippingId,varianceTestInput:t.enabledVariantTestKeys||[]})];case 2:C=e.sent();e.label=3;case 3:I=(l=ze.items.find(Boolean))===null||l===void 0?void 0:l.currencyCode;T=((c=ne.stripeAddressEventData)===null||c===void 0?void 0:c.value.address.country)||"US";ne.shouldRenderPayInUsdButton=I==="USD"&&n.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((v=ze.checkoutSession)===null||v===void 0?void 0:v.subtotals.presentmentCurrencyCode)!=="USD"&&!!((m=(f=n.genericSettings)===null||f===void 0?void 0:f.usdSettlementCountryEnabled)===null||m===void 0?void 0:m.includes(T));return[2,C]}}))}))}));var Xe=e("l",(function(e){var r=e.isPreview,n=e.sessionTimeout;if(r){return}var t=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout");var o=t&&!isNaN(parseInt(t,10))?parseInt(t,10):n;d("==START CHECKOUT TIMEOUT - ".concat(o,"=="));ze.checkoutTimeoutInterval=setTimeout((function(){ze.checkoutSessionTimeoutShow=true}),o)}));var $e=e("h",(function(){if(ze.checkoutTimeoutInterval){clearTimeout(ze.checkoutTimeoutInterval);ze.checkoutTimeoutInterval=null}}));var er=function(e){return e.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}))};var rr=function(){ze.items=ze.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));ze.restrictedItems=[]};var nr=e("e",(function(e){return __awaiter(b,[e],void 0,(function(e){var r,n,o,i;var a=e.adjustments,s=e.cartItems,u=e.landedCostId,d=e.shouldInitSessionOnFailure,l=d===void 0?true:d;return __generator(this,(function(e){switch(e.label){case 0:ze.adjustments=a;ze.items=er(s);n=(r=s.find(Boolean))===null||r===void 0?void 0:r.currencyCode;o=s.reduce((function(e,r){return e+r.amount*r.quantity}),0);i=a.reduce((function(e,r){return e+r.amount}),0);if(!n||!o){return[2]}ze.currency=n;ne.isFetchingSession=true;return[4,Ve({adjustmentsAmount:i,billToPartyId:ne.partyBillingId,cartId:window.Zonos.cartId,currency:n,dutiesTaxesFeesEstimate:0,itemsAmount:o,landedCostId:u,shipToPartyId:ne.partyShippingId,shouldInitSessionOnFailure:l,varianceTestInput:t.enabledVariantTestKeys||[]})];case 1:e.sent();ne.isFetchingSession=false;return[2]}}))}))}));var tr=function(){ze.selectedShippingOption=null;ze.isSelectedShippingAboveDeminimis=false;ze.isSelectedShippingGuarantee=false;ze.selectedShippingOptionTransitTime="";ze.dutiesTaxesFees=0;ze.dutiesTaxesFeesEstimate=0;ze.shipping=0;ze.total=ze.subtotal};var or=function(){if(ze.step==="shipping"){ze.step="customer-info";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{"customer-info":Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:false})})}else if(ze.step==="payment"){ze.step="shipping";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{shipping:Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:false})})}else if(ze.step==="finish"){ze.step="payment";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{payment:Object.assign(Object.assign({},ze.tabItems.payment),{isDone:false})})}};var ir=e("r",(function(){if(ze.step==="customer-info"){ze.step="shipping";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{"customer-info":Object.assign(Object.assign({},ze.tabItems["customer-info"]),{isDone:true})})}else if(ze.step==="shipping"){ze.step="payment";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{shipping:Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:true})})}else if(ze.step==="payment"){ze.step="finish"}}));var ar=e("g",(function(){ze.step="customer-info";ze.tabItems=Object.assign(Object.assign({},ze.tabItems),{"customer-info":Object.assign(Object.assign({},ze.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},ze.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},ze.tabItems.shipping),{isDone:false})});tr()}));var sr=function(){return __awaiter(b,void 0,void 0,(function(){var e,r,n,i,a,s,u,l,c;return __generator(this,(function(f){switch(f.label){case 0:if(!t.checkoutSessionId){d("Could not update store credit without checkout session id","info");return[2]}n=ze.selectedLandedCost;i=ze.currency||((e=ze.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"";a=ze.adjustments.reduce((function(e,r){return e+r.amount}),0);s=ze.items.reduce((function(e,r){return e+r.amount*r.quantity}),0);return[4,Pe({adjustmentsAmount:a,cartId:window.Zonos.cartId,currency:i,id:t.checkoutSessionId,itemsAmount:s,landedCostId:n===null||n===void 0?void 0:n.landedCostId,presentmentCountryCode:o.selectedCountryCode,storeCreditApplication:D()})];case 1:u=f.sent(),l=u.errors,c=u.json;if(l.length>0||!c){v("Error updating checkout session with store credit");return[2]}He({method:((r=c.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:c.checkoutSessionUpdate.subtotals});Ge(c.checkoutSessionUpdate);return[2]}}))}))};var ur=e("X",(function(){if(qe){clearTimeout(qe)}qe=setTimeout((function(){qe=null;void sr()}),300)}))}}}));
@@ -1 +1 @@
1
- import{c as e,z as o}from"./p-058f6124.js";import{b as a,G as t,d as s,H as d}from"./p-620ba943.js";import{s as n}from"./p-13041752.js";import{h as r,s as i,l}from"./p-41dd1cb8.js";import{b as c}from"./p-0a377722.js";const{state:p}=e((()=>({amountTotalDue:null,isFetchingPayorInfo:!0,landedCostShortId:null,partyBillingId:null,payorAddress:null}))),u=async({landedCostId:e,retries:a=5})=>{var t,d,n;p.isFetchingPayorInfo=!0;const l=await r("/api/zonos-elements/invoice/get-payor-info-by-lc-id",{body:{landedCostId:e},method:"POST"});if(l.errors.length)return a>0?(await new Promise((e=>setTimeout(e,1e3))),u({landedCostId:e,retries:a-1})):null;p.landedCostShortId=(null===(t=l.json)||void 0===t?void 0:t.landedCostShortId)||null,p.isFetchingPayorInfo=!1,p.payorAddress=(null===(d=l.json)||void 0===d?void 0:d.payor)||null;const c=null===(n=s.checkoutSession)||void 0===n?void 0:n.subtotals;p.amountTotalDue=(null==c?void 0:c.items)||0,0===p.amountTotalDue&&i({endpoint:"INVOICE_NO_TOTAL_DUE",errors:[],metadata:{landedCostId:e,organizationId:o.organizationId}})},I=async()=>{var e,o,d,u;if(!(null===(e=a.stripeBillingAddressEventData)||void 0===e?void 0:e.complete))return{partiesCreated:!1};const I=null===(d=null===(o=s.checkoutSession)||void 0===o?void 0:o.landedCost)||void 0===d?void 0:d.rootId;if(!I)return i({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId}}),{partiesCreated:!1};if(!n.checkoutSessionId)return i({endpoint:"INVOICE_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:c,cartId:window.Zonos.cartId,landedCostRootId:I}}),{partiesCreated:!1};const m=t({address:a.stripeBillingAddressEventData.value.address,firstName:a.stripeBillingAddressEventData.value.firstName,lastName:a.stripeBillingAddressEventData.value.lastName,name:a.stripeBillingAddressEventData.value.name,phone:a.stripeBillingAddressEventData.value.phone}),C="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:O,json:v}=await r("/api/zonos-elements/create-billing-party",{body:{billingAddress:m,checkoutSessionId:n.checkoutSessionId,companyName:a.companyName,email:(null===(u=a.stripeLinkEventData)||void 0===u?void 0:u.value.email)||"",isTest:C,rootId:I},method:"POST"});return O.length||!v?(l("Error occurs when creating billing party",JSON.stringify(O,null,2)),i({endpoint:"INVOICE_BILLING_PARTY_CREATE_FAILED",errors:["[INVOICE] Failed to create billing party"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId,errors:O,json:v}}),{partiesCreated:!1}):(p.partyBillingId=v.billToPartyId,{partiesCreated:!0})},m=async e=>{const o=e.landedCost;return!!o&&(s.landedCostData=[Object.assign(Object.assign({},e),{landedCost:Object.assign({},o),landedCostId:o.id})],d({applySubtotalsOnly:!0,landedCostId:o.id,selectedShippingOption:o.shipmentRating}))};export{u as a,I as b,p as c,m as i}
1
+ import{c as e,z as o}from"./p-058f6124.js";import{b as a,G as t,d as s,H as d}from"./p-dafafa07.js";import{s as n}from"./p-3ac97c01.js";import{h as r,s as i,l}from"./p-41dd1cb8.js";import{b as c}from"./p-0a377722.js";const{state:p}=e((()=>({amountTotalDue:null,isFetchingPayorInfo:!0,landedCostShortId:null,partyBillingId:null,payorAddress:null}))),u=async({landedCostId:e,retries:a=5})=>{var t,d,n;p.isFetchingPayorInfo=!0;const l=await r("/api/zonos-elements/invoice/get-payor-info-by-lc-id",{body:{landedCostId:e},method:"POST"});if(l.errors.length)return a>0?(await new Promise((e=>setTimeout(e,1e3))),u({landedCostId:e,retries:a-1})):null;p.landedCostShortId=(null===(t=l.json)||void 0===t?void 0:t.landedCostShortId)||null,p.isFetchingPayorInfo=!1,p.payorAddress=(null===(d=l.json)||void 0===d?void 0:d.payor)||null;const c=null===(n=s.checkoutSession)||void 0===n?void 0:n.subtotals;p.amountTotalDue=(null==c?void 0:c.items)||0,0===p.amountTotalDue&&i({endpoint:"INVOICE_NO_TOTAL_DUE",errors:[],metadata:{landedCostId:e,organizationId:o.organizationId}})},I=async()=>{var e,o,d,u;if(!(null===(e=a.stripeBillingAddressEventData)||void 0===e?void 0:e.complete))return{partiesCreated:!1};const I=null===(d=null===(o=s.checkoutSession)||void 0===o?void 0:o.landedCost)||void 0===d?void 0:d.rootId;if(!I)return i({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId}}),{partiesCreated:!1};if(!n.checkoutSessionId)return i({endpoint:"INVOICE_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:c,cartId:window.Zonos.cartId,landedCostRootId:I}}),{partiesCreated:!1};const m=t({address:a.stripeBillingAddressEventData.value.address,firstName:a.stripeBillingAddressEventData.value.firstName,lastName:a.stripeBillingAddressEventData.value.lastName,name:a.stripeBillingAddressEventData.value.name,phone:a.stripeBillingAddressEventData.value.phone}),C="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:O,json:v}=await r("/api/zonos-elements/create-billing-party",{body:{billingAddress:m,checkoutSessionId:n.checkoutSessionId,companyName:a.companyName,email:(null===(u=a.stripeLinkEventData)||void 0===u?void 0:u.value.email)||"",isTest:C,rootId:I},method:"POST"});return O.length||!v?(l("Error occurs when creating billing party",JSON.stringify(O,null,2)),i({endpoint:"INVOICE_BILLING_PARTY_CREATE_FAILED",errors:["[INVOICE] Failed to create billing party"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId,errors:O,json:v}}),{partiesCreated:!1}):(p.partyBillingId=v.billToPartyId,{partiesCreated:!0})},m=async e=>{const o=e.landedCost;return!!o&&(s.landedCostData=[Object.assign(Object.assign({},e),{landedCost:Object.assign({},o),landedCostId:o.id})],d({applySubtotalsOnly:!0,landedCostId:o.id,selectedShippingOption:o.shipmentRating}))};export{u as a,I as b,p as c,m as i}
@@ -1 +1 @@
1
- import{r as o,h as n,a as s,F as i}from"./p-ce75b047.js";import{b as e,i as c,c as t,d as a,n as r,e as l,j as z,k as d,u as v,A as h,E as m,C as p,f as u}from"./p-620ba943.js";import{i as g,a as f,b,c as w}from"./p-57b27c60.js";import{p as x,a as y}from"./p-29f7950c.js";import{s as k,t as C,c as I,d as S,l as j}from"./p-13041752.js";import{z as O}from"./p-058f6124.js";import{b as L}from"./p-83666056.js";import{h as T,s as E,l as U,g as P}from"./p-41dd1cb8.js";import{i as _,a as A}from"./p-1f3549c6.js";import{c as N}from"./p-b4b7f705.js";import{l as D}from"./p-0a377722.js";import{l as B}from"./p-97aceb11.js";import"./p-67897a0d.js";import"./p-f830f800.js";import"./p-def2d465.js";import"./p-4f7d64f6.js";const F=class{constructor(n){o(this,n),this.storeUnsubscribeList=[],this.onChangeLocaleListener=()=>{},this.mobile=!1,this.tablet=!1,this.stripe=window.Zonos.stripe,this.showLanguageDialogMobile=!1,this.submitLoading=!1,this.collapseReviewMobile=!0,this.isMobile=!1,this.isTablet=!1,this.isOverlayLoading=!0,this.isCartCollected=!1,this.isCartExpired=!1,this.payInUsdConfirmDialogOpen=!1,this.inventoryCheckErrorMessage=null,this.confirmationId=null,this.clientSecret=e.clientSecret,this.stripeCustomerSessionClientSecret=e.stripeCustomerSessionClientSecret,this.getBaseCurrencySettlementInfo=()=>{const o=a.selectedLandedCost;if(!o)return null;const{landedCost:{amountSubtotals:n}}=o;return n?{settlementAmount:(n.discounts||0)+n.items+n.landedCostTotal+n.shipping}:null},this.applyStripeTheme=async()=>{const o=O.appearance.theme;await c({overrideTheme:this.isMobile?o:void 0,paypalEnabled:x()})},this.fetchCheckoutSession=async o=>{const{json:n}=await T("/api/zonos-elements/collect/get-checkout-session",{body:{checkoutSessionId:o},method:"POST"});return n},this.checkStripePaymentIntentStatus=async()=>{var o;const n=!!window.Zonos.cartData,s=new URL(window.location.href).searchParams,i=s.get("payment_intent_client_secret"),c=s.get("zonosCheckoutSessionId");if(D("Payment intent exist, checking stripe payment intent status"),!i)return D("No stripe client secret found in the URL, proceed to order if cart data is available"),{shouldAllowOrder:n};const{error:a,status:r}=await t({clientSecret:i});if(new URLSearchParams(window.location.search).get("redirect_status")&&c){D(a?"Payment intent failed, show status from error":"Payment intent is succeeded or in a good state to move forward, show success screen");const n=await this.fetchCheckoutSession(c);return this.confirmationId=(null===(o=null==n?void 0:n.checkoutSession.landedCost)||void 0===o?void 0:o.shortId)||null,k.checkoutSessionId=c,e.clientSecret=i,this.setToFinishStep(r),{shouldAllowOrder:!1}}return n?(D("Payment intent is not succeeded, proceed to order"),{shouldAllowOrder:!0}):(D("Cart data is not available, only check payment intent status, skip order."),{shouldAllowOrder:!1})}}resizeListener(){this.isMobile=_(this.mobile),this.isTablet=A(this.tablet)}async setToFinishStep(o){e.stripe=window.Zonos.stripe,a.step="finish",this.storybookPaymentStatusOverride=o,this.isOverlayLoading=!1}async initInvoiceCart(){var o,n,s,i,e,c,v,h,m,p,u;if(!window.Zonos.cartData)return;const b=null===(n=null===(o=window.Zonos.cartData)||void 0===o?void 0:o.items[0])||void 0===n?void 0:n.currencyCode;b&&(a.currency=b);const w=null===(i=null===(s=window.Zonos.cartData)||void 0===s?void 0:s.references)||void 0===i?void 0:i.checkoutSessionId,x=null===(c=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.references)||void 0===c?void 0:c.landedCostId;if(!x)return void r({messages:[C("Session does not have valid landed cost. Please contact [organizationName] for assistance.",{organizationName:O.organizationName})],title:C("Invalid session")});w?(D("Setting checkout session id from cart reference","info",w),k.checkoutSessionId=w):(D("Clear checkout session id from storage so we start from a fresh session for the invoice cart"),k.checkoutSessionId=null);const{shouldAllowOrder:y}=await this.checkStripePaymentIntentStatus();if(y){try{const{adjustments:o,cartItems:n}=L(window.Zonos.cartData);if(await l({adjustments:o,cartItems:n,landedCostId:x,shouldInitSessionOnFailure:!1}),!k.checkoutSessionId&&!w){const o=await z();if(D(`stripeStoreInitCheckoutSession: ${o}`),!o)throw new Error("Failed to initialize checkout session! The cart might be created with LIVE Invoice quote but being used with sandbox credential")}if((!a.checkoutSession||(null===(v=a.checkoutSession)||void 0===v?void 0:v.completedAt))&&w){const o=await this.fetchCheckoutSession(w);if(this.confirmationId=(null===(h=null==o?void 0:o.checkoutSession.landedCost)||void 0===h?void 0:h.shortId)||null,(null==o?void 0:o.checkoutSession.completedAt)&&o.checkoutSession.order)return void this.setToFinishStep("succeeded");if(null==o?void 0:o.checkoutSession.clientSecret){const{status:n}=await t({clientSecret:o.checkoutSession.clientSecret});if("processing"===n||"succeeded"===n)return void this.setToFinishStep(n)}throw E({endpoint:"INVALID_INVOICE_CHECKOUT_SESSION",errors:["Invalid checkout session, can not retrieve the checkout session after failing to update it"],metadata:{cartCheckoutSessionId:w,cartId:null===(m=window.Zonos.cartData)||void 0===m?void 0:m.id,cartLandedCostId:x}}),new Error("Invalid checkout session, can not retrieve the checkout session after failing to update it")}if(!a.checkoutSession)throw E({endpoint:"FAIL_TO_UPDATE_CREATE_INVOICE_CHECKOUT_SESSION",errors:["Could not update/create checkout session for this invoice cart"],metadata:{cartCheckoutSessionId:w||"N/A",cartId:null===(p=window.Zonos.cartData)||void 0===p?void 0:p.id,cartLandedCostId:x||"N/A"}}),new Error("Could not update/create checkout session for this invoice cart");d();const s=null===(u=a.checkoutSession)||void 0===u?void 0:u.landedCost;if(!s)throw new Error("Landed cost could not be found in checkout session after creating/updating them");await g(Object.assign(Object.assign({},a.checkoutSession),{id:k.checkoutSessionId||""})),f({landedCostId:s.id}),this.applyStripeTheme()}catch(o){U(o),r({messages:[C("Session does not have valid landed cost. Please contact [organizationName] for assistance.",{organizationName:O.organizationName})],title:C("Invalid session")})}this.isOverlayLoading=!1}}toggleLanguageDialog(){this.showLanguageDialogMobile=!this.showLanguageDialogMobile}async handleStripePaymentContinue(){var o,n,s,i;if(null===(o=e.stripeBillingAddressElement)||void 0===o||o.getValue(),null===(n=e.stripeLinkEventData)||void 0===n?void 0:n.complete)if(null===(s=e.stripeBillingAddressEventData)||void 0===s?void 0:s.complete)if("USD"!==e.checkoutSettlementCurrency||!e.shouldRenderPayInUsdButton||this.payInUsdConfirmDialogOpen){if(this.payInUsdConfirmDialogOpen=!1,y.paypalErrorMessage=null,e.hasPaymentError=!1,this.submitLoading=!0,a.inventoryCheckErrorMessage=null,!await v())return e.hasPaymentError=!0,e.customErrorMessage=C("Unable to complete payment in [currency]. Please try again or select a different currency. If the issue persists, contact our support team for assistance.",{currency:e.checkoutSettlementCurrency}),void(this.submitLoading=!1);await b();try{return await h({noLandedCostCheck:!0}),a.step="finish",void(this.confirmationId=w.landedCostShortId||(null===(i=a.selectedLandedCost)||void 0===i?void 0:i.landedCostId)||null)}catch(o){U(o),e.hasPaymentError=!0}this.submitLoading=!1}else this.payInUsdConfirmDialogOpen=!0;else{const o=document.querySelector(".zonos--billing-address");null==o||o.scrollIntoView({behavior:"smooth"})}else{const o=document.querySelector("zonos-link-authentication");null==o||o.scrollIntoView({behavior:"smooth"})}}componentWillLoad(){e.stripe=window.Zonos.stripe,a.step="payment",this.initInvoiceCart(),this.resizeListener(),this.storeUnsubscribeList=[m("clientSecret",(()=>{this.applyStripeTheme()})),I("selectedLocale",(()=>{this.applyStripeTheme()}))],D(`mobile: ${this.isMobile}`)}disconnectedCallback(){p(),u(),this.onChangeLocaleListener(),this.storeUnsubscribeList.forEach((o=>o()))}render(){this.clientSecret=e.clientSecret,e.stripeCustomerSessionClientSecret&&(this.stripeCustomerSessionClientSecret=e.stripeCustomerSessionClientSecret);const o=this.getBaseCurrencySettlementInfo(),{logoUrl:c,theme:t}=O.appearance,r=()=>{const o=`${c}?timestamp=${Date.now()}`;return n("div",{class:"zonos--logo"},o&&n("img",{alt:`${O.organizationName} logo`,src:o}))},l=P(),z=()=>{var o;const s=new URLSearchParams(window.location.search),e=s.get("zonosQaUrl"),c=s.get("zonosDebug"),t=null===(o=B.find((o=>o.code===j.selectedLocale)))||void 0===o?void 0:o.label;return n(i,null,n("zonos-h-stack",{class:"zonos--header-wrapper",spacing:16},n("div",{class:"zonos--logo-wrapper"},r(),l&&n("zonos-badge",{badgeColor:"orange",size:"small"},C("Test mode")),"1"===c&&n("zonos-badge",{badgeColor:"cyan",size:"small"},"debug"),e&&n("zonos-badge",{badgeColor:"purple",size:"small"},e)),n("div",{class:"zonos--header-right"},n("zonos-button",{backgroundColor:"gray-0",class:"zonos--header-right-button",onClick:()=>this.toggleLanguageDialog(),variant:"outline"},t,n("zonos-icon",{"aria-label":"Language select",content:'<svg color="var(--zonos-elements-gray-400)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M6.293 9.293a1 1 0 0 1 1.414 0L12 13.586l4.293-4.293a1 1 0 0 1 1.414 1.414l-4.93 4.93a1.1 1.1 0 0 1-1.555 0l-4.93-4.93a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>',iconColor:"gray-1200"})),n("div",{class:N(["zonos--invoice-language-dialog",this.showLanguageDialogMobile&&"zonos--invoice-language-dialog-open"])},n("zonos-language-select",{handleOnClose:()=>this.toggleLanguageDialog()})))))};return n(s,{class:N(["zonos--invoice zonos--elements",this.isMobile&&"mobile",this.isTablet&&"tablet"]),"data-theme":t},(()=>this.isOverlayLoading||e.isFetchingSession?null:n("div",{class:"zonos--content"},"finish"!==a.step&&"error"!==a.step&&n(i,null,(this.isMobile||this.isTablet)&&z(),n("div",{class:"zonos--left","data-theme":t},!this.isMobile&&!this.isTablet&&z(),n("zonos-text",{class:"zonos--title",type:"semiBoldSubheader"},C("Billing info")),n("zonos-v-stack",{spacing:16},n("zonos-link-authentication",{titleText:""}),n("zonos-address",{titleText:"",type:"billing"})),n("zonos-invoice-payment",{class:N(["zonos--invoice-container"]),continueLoading:this.submitLoading,onContinueClicked:async()=>{await this.handleStripePaymentContinue()}})),n("div",{class:"zonos--right","data-theme":t},!this.isMobile&&n("zonos-invoice-review",{mobile:this.isMobile,tablet:this.isTablet}),n("div",{class:"zonos--order-details-container"},!this.isMobile&&n("zonos-invoice-cart-items",null),this.isMobile&&n("zonos-invoice-order-details",{collapsed:this.collapseReviewMobile,mobile:this.isMobile,onCollapseClicked:()=>{this.collapseReviewMobile=!this.collapseReviewMobile}})),n("div",{class:"flex--wrapper"},!this.isMobile&&n("zonos-v-stack",{spacing:16},n("zonos-invoice-subtotal",null)),!this.isMobile&&!this.isTablet&&n("zonos-invoice-footer",{"data-theme":t,mobile:this.isMobile,tablet:this.isTablet})))),("finish"===a.step||"error"===a.step)&&n("div",{class:"zonos--done","data-theme":t},n("div",{class:"zonos--header"},r()),n("zonos-invoice-finish",{confirmationId:this.confirmationId,overrideNotification:"error"===a.step&&a.error?Object.assign(Object.assign({},a.error),{type:"error"}):void 0,storybookForceStatus:this.storybookPaymentStatusOverride})),(this.isMobile||this.isTablet||"finish"===a.step||"error"===a.step)&&n("zonos-invoice-footer",{"data-theme":t,mobile:this.isMobile,tablet:this.isTablet})))(),o&&n("zonos-confirm-dialog",{class:"zonos--pay-in-usd-dialog",dialogCancelBtnText:C("Cancel"),dialogConfirmBtnText:C("Pay [orderTotal]",{orderTotal:S({amount:o.settlementAmount,currency:"USD"})}),dialogIntent:"warn",dialogOpen:this.payInUsdConfirmDialogOpen,dialogSubtitle:C("By paying in USD, your card will be charged directly with no currency conversion. However, using a non-USD based card may result in additional currency conversion fees at the bank level."),dialogTitle:C("Pay in USD (United States Dollar)?"),dialogType:"confirm",dialogWidth:480,onCancelClicked:()=>{this.payInUsdConfirmDialogOpen=!1},onConfirmClicked:()=>this.handleStripePaymentContinue()}),n("zonos-loading-overlay",{open:this.isOverlayLoading}))}static get assetsDirs(){return["assets"]}};F.style=".sc-zonos-invoice-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-invoice-h *.sc-zonos-invoice{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-invoice-h img.sc-zonos-invoice{max-width:100%}.sc-zonos-invoice-h dl.sc-zonos-invoice,.sc-zonos-invoice-h dd.sc-zonos-invoice,.sc-zonos-invoice-h h1.sc-zonos-invoice,.sc-zonos-invoice-h h2.sc-zonos-invoice,.sc-zonos-invoice-h h3.sc-zonos-invoice,.sc-zonos-invoice-h h4.sc-zonos-invoice,.sc-zonos-invoice-h h5.sc-zonos-invoice,.sc-zonos-invoice-h h6.sc-zonos-invoice,.sc-zonos-invoice-h hr.sc-zonos-invoice,.sc-zonos-invoice-h figure.sc-zonos-invoice,.sc-zonos-invoice-h p.sc-zonos-invoice,.sc-zonos-invoice-h pre.sc-zonos-invoice{margin:0}.sc-zonos-invoice-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-invoice-h{z-index:2147483647;position:fixed;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;top:0;left:0;width:100%;height:100%;-ms-flex-align:center;align-items:center;background-color:var(--zonos-elements-gray-0)}.sc-zonos-invoice-h *.sc-zonos-invoice{-ms-scroll-chaining:none;overscroll-behavior:contain}.sc-zonos-invoice-h *.sc-zonos-invoice::-webkit-scrollbar{width:10px}.sc-zonos-invoice-h *.sc-zonos-invoice::-webkit-scrollbar-track{background:var(--zonos-elements-gray-50)}.sc-zonos-invoice-h *.sc-zonos-invoice::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-invoice-h *.sc-zonos-invoice::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;width:100%;-ms-flex-pack:center;justify-content:center}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice{-ms-flex:1;flex:1;padding:56px 80px 60px;max-width:800px}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice{background-color:var(--zonos--primary-color, var(--zonos-elements-gray-0));border-right:1px solid var(--zonos-elements-gray-200);overflow:auto;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:32px}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice{background-color:var(--zonos-elements-gray-0)}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--done.sc-zonos-invoice{width:100%;max-width:1400px;max-height:100%;height:calc(100% - 100px);overflow:hidden;-ms-flex-direction:column;flex-direction:column;background-color:var(--zonos-elements-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:24px;padding-bottom:50px}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--done.sc-zonos-invoice .zonos--header.sc-zonos-invoice{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--done.sc-zonos-invoice .zonos--logo.sc-zonos-invoice{margin-bottom:0}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--done.sc-zonos-invoice zonos-checkout-finish.sc-zonos-invoice{-ms-flex:1;flex:1}.sc-zonos-invoice-h .zonos--header-title.sc-zonos-invoice,.sc-zonos-invoice-h .zonos--header-wrapper.sc-zonos-invoice{max-width:800px}.sc-zonos-invoice-h .zonos--left.sc-zonos-invoice{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;position:relative}.sc-zonos-invoice-h .zonos--left.sc-zonos-invoice .zonos--wrapper.sc-zonos-invoice{padding:0 8px 8px}.sc-zonos-invoice-h .zonos--left.sc-zonos-invoice .zonos--payment-error-banner.sc-zonos-invoice{margin-top:24px}.sc-zonos-invoice-h .zonos--right.sc-zonos-invoice{position:relative;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-zonos-invoice-h .zonos--right.sc-zonos-invoice .zonos--order-details-container.sc-zonos-invoice{overflow:auto}.sc-zonos-invoice-h .zonos--wrapper.sc-zonos-invoice{overflow:auto;max-height:100%;position:relative}.sc-zonos-invoice-h .flex--wrapper.sc-zonos-invoice{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;max-height:100%}.sc-zonos-invoice-h .zonos--logo-wrapper.sc-zonos-invoice{display:-ms-flexbox;display:flex;gap:16px;-ms-flex-align:center;align-items:center;-ms-flex:1;flex:1}.sc-zonos-invoice-h .zonos--logo-wrapper.sc-zonos-invoice>*.sc-zonos-invoice{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}.sc-zonos-invoice-h .zonos--header-right.sc-zonos-invoice{display:none}.sc-zonos-invoice-h .zonos--logo.sc-zonos-invoice{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-invoice-h .zonos--logo.sc-zonos-invoice img.sc-zonos-invoice{max-height:70px;-o-object-position:left center;object-position:left center;-o-object-fit:contain;object-fit:contain}.sc-zonos-invoice-h .zonos--invoice-container.sc-zonos-invoice{overflow:visible}.mobile.sc-zonos-invoice-h,.tablet.sc-zonos-invoice-h{min-width:auto}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:auto;border-radius:0;max-height:100%;height:100%;border:0}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice{padding:12px;padding-bottom:76px}@media (max-width: 768px){.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice{padding-bottom:0}}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice{-ms-flex-order:2;order:2;border-right:none}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice{-ms-flex-order:1;order:1;padding-top:16px}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice .zonos--wrapper.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice .zonos--wrapper.sc-zonos-invoice{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;border:var(--zonos-elements-border);border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-10));background-color:var(--zonos-elements-gray-50);padding:12px;margin-top:32px}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice .zonos--review.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice .zonos--review.sc-zonos-invoice{margin-bottom:0}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice .zonos--cart-items.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice .zonos--cart-items.sc-zonos-invoice{margin-top:8px}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice zonos-checkout-footer.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice zonos-checkout-footer.sc-zonos-invoice{-ms-flex-order:3;order:3}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--wrapper.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--wrapper.sc-zonos-invoice{max-height:100%}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--footer.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--footer.sc-zonos-invoice{-ms-flex-order:3;order:3}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--done.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--done.sc-zonos-invoice{width:auto}.mobile.sc-zonos-invoice-h .zonos--cart-subtotal.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--cart-subtotal.sc-zonos-invoice{margin:0}.mobile.sc-zonos-invoice-h .zonos--header-wrapper.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--header-wrapper.sc-zonos-invoice{position:-webkit-sticky;position:sticky;top:0;width:100%;padding:16px;background-color:var(--zonos-elements-gray-0);z-index:3}.mobile.sc-zonos-invoice-h .zonos--header-title.sc-zonos-invoice,.mobile.sc-zonos-invoice-h .zonos--header-wrapper.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--header-title.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--header-wrapper.sc-zonos-invoice{max-width:800px;padding:0 16px}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice{overflow:auto;-ms-flex-pack:unset;justify-content:unset;-ms-flex-align:center;align-items:center;gap:24px}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice{overflow:visible;width:100%}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice{gap:32px}.mobile.sc-zonos-invoice-h .flex--wrapper.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .flex--wrapper.sc-zonos-invoice{margin-top:0}.mobile.sc-zonos-invoice-h zonos-collect-footer.sc-zonos-invoice,.tablet.sc-zonos-invoice-h zonos-collect-footer.sc-zonos-invoice{-ms-flex-order:3;order:3;left:0}.tablet.sc-zonos-invoice-h .zonos--header-wrapper.sc-zonos-invoice{padding-top:56px;top:-56px}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--header-right.sc-zonos-invoice{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.mobile.sc-zonos-invoice-h .zonos--header-wrapper.sc-zonos-invoice{padding-top:28px;top:-28px}.mobile.sc-zonos-invoice-h .zonos--invoice-language-dialog.sc-zonos-invoice{position:fixed;left:0;right:0;bottom:0;-webkit-transform-origin:bottom center;transform-origin:bottom center;width:100vw;background:var(--zonos-elements-surface-color);-webkit-box-shadow:var(--zonos-elements-v3-shadow-xl);box-shadow:var(--zonos-elements-v3-shadow-xl);border-radius:var(--zonos-elements-radius-12);max-width:100vw;max-height:500px;z-index:2147483011;overflow:auto;-webkit-transform:scale(0);transform:scale(0);opacity:0;-webkit-transition:opacity 0.3s ease-out, -webkit-transform 0.3s ease-out;transition:opacity 0.3s ease-out, -webkit-transform 0.3s ease-out;transition:transform 0.3s ease-out, opacity 0.3s ease-out;transition:transform 0.3s ease-out, opacity 0.3s ease-out, -webkit-transform 0.3s ease-out;-ms-scroll-chaining:none;overscroll-behavior:contain}.mobile.sc-zonos-invoice-h .zonos--invoice-language-dialog.sc-zonos-invoice::-webkit-scrollbar{width:10px}.mobile.sc-zonos-invoice-h .zonos--invoice-language-dialog.sc-zonos-invoice::-webkit-scrollbar-track{background:var(--zonos-elements-gray-50)}.mobile.sc-zonos-invoice-h .zonos--invoice-language-dialog.sc-zonos-invoice::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.mobile.sc-zonos-invoice-h .zonos--invoice-language-dialog.sc-zonos-invoice::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.mobile.sc-zonos-invoice-h .zonos--invoice-language-dialog.sc-zonos-invoice::-webkit-scrollbar-track{border-top-right-radius:var(--zonos-elements-radius-12);border-bottom-right-radius:var(--zonos-elements-radius-12)}.mobile.sc-zonos-invoice-h .zonos--invoice-language-dialog.zonos--invoice-language-dialog-open.sc-zonos-invoice{opacity:1;-webkit-transform:scale(1);transform:scale(1)}.iframed.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice{-ms-scroll-chaining:chained;overscroll-behavior:auto}";export{F as zonos_invoice}
1
+ import{r as o,h as n,a as s,F as i}from"./p-ce75b047.js";import{b as e,i as c,c as t,d as a,n as r,e as l,j as z,k as d,u as v,A as h,E as m,C as p,f as u}from"./p-dafafa07.js";import{i as f,a as g,b,c as w}from"./p-af83f0c2.js";import{p as x,a as y}from"./p-c398711f.js";import{s as k,t as C,c as I,d as S,l as j}from"./p-3ac97c01.js";import{z as O}from"./p-058f6124.js";import{b as L}from"./p-83666056.js";import{h as T,s as E,l as U,g as P}from"./p-41dd1cb8.js";import{i as _,a as A}from"./p-1f3549c6.js";import{c as N}from"./p-b4b7f705.js";import{l as D}from"./p-0a377722.js";import{l as B}from"./p-97aceb11.js";import"./p-67897a0d.js";import"./p-f830f800.js";import"./p-def2d465.js";import"./p-4f7d64f6.js";const F=class{constructor(n){o(this,n),this.storeUnsubscribeList=[],this.onChangeLocaleListener=()=>{},this.mobile=!1,this.tablet=!1,this.stripe=window.Zonos.stripe,this.showLanguageDialogMobile=!1,this.submitLoading=!1,this.collapseReviewMobile=!0,this.isMobile=!1,this.isTablet=!1,this.isOverlayLoading=!0,this.isCartCollected=!1,this.isCartExpired=!1,this.payInUsdConfirmDialogOpen=!1,this.inventoryCheckErrorMessage=null,this.confirmationId=null,this.clientSecret=e.clientSecret,this.stripeCustomerSessionClientSecret=e.stripeCustomerSessionClientSecret,this.getBaseCurrencySettlementInfo=()=>{const o=a.selectedLandedCost;if(!o)return null;const{landedCost:{amountSubtotals:n}}=o;return n?{settlementAmount:(n.discounts||0)+n.items+n.landedCostTotal+n.shipping}:null},this.applyStripeTheme=async()=>{const o=O.appearance.theme;await c({overrideTheme:this.isMobile?o:void 0,paypalEnabled:x()})},this.fetchCheckoutSession=async o=>{const{json:n}=await T("/api/zonos-elements/collect/get-checkout-session",{body:{checkoutSessionId:o},method:"POST"});return n},this.checkStripePaymentIntentStatus=async()=>{var o;const n=!!window.Zonos.cartData,s=new URL(window.location.href).searchParams,i=s.get("payment_intent_client_secret"),c=s.get("zonosCheckoutSessionId");if(D("Payment intent exist, checking stripe payment intent status"),!i)return D("No stripe client secret found in the URL, proceed to order if cart data is available"),{shouldAllowOrder:n};const{error:a,status:r}=await t({clientSecret:i});if(new URLSearchParams(window.location.search).get("redirect_status")&&c){D(a?"Payment intent failed, show status from error":"Payment intent is succeeded or in a good state to move forward, show success screen");const n=await this.fetchCheckoutSession(c);return this.confirmationId=(null===(o=null==n?void 0:n.checkoutSession.landedCost)||void 0===o?void 0:o.shortId)||null,k.checkoutSessionId=c,e.clientSecret=i,this.setToFinishStep(r),{shouldAllowOrder:!1}}return n?(D("Payment intent is not succeeded, proceed to order"),{shouldAllowOrder:!0}):(D("Cart data is not available, only check payment intent status, skip order."),{shouldAllowOrder:!1})}}resizeListener(){this.isMobile=_(this.mobile),this.isTablet=A(this.tablet)}async setToFinishStep(o){e.stripe=window.Zonos.stripe,a.step="finish",this.storybookPaymentStatusOverride=o,this.isOverlayLoading=!1}async initInvoiceCart(){var o,n,s,i,e,c,v,h,m,p,u;if(!window.Zonos.cartData)return;const b=null===(n=null===(o=window.Zonos.cartData)||void 0===o?void 0:o.items[0])||void 0===n?void 0:n.currencyCode;b&&(a.currency=b);const w=null===(i=null===(s=window.Zonos.cartData)||void 0===s?void 0:s.references)||void 0===i?void 0:i.checkoutSessionId,x=null===(c=null===(e=window.Zonos.cartData)||void 0===e?void 0:e.references)||void 0===c?void 0:c.landedCostId;if(!x)return void r({messages:[C("Session does not have valid landed cost. Please contact [organizationName] for assistance.",{organizationName:O.organizationName})],title:C("Invalid session")});w?(D("Setting checkout session id from cart reference","info",w),k.checkoutSessionId=w):(D("Clear checkout session id from storage so we start from a fresh session for the invoice cart"),k.checkoutSessionId=null);const{shouldAllowOrder:y}=await this.checkStripePaymentIntentStatus();if(y){try{const{adjustments:o,cartItems:n}=L(window.Zonos.cartData);if(await l({adjustments:o,cartItems:n,landedCostId:x,shouldInitSessionOnFailure:!1}),!k.checkoutSessionId&&!w){const o=await z();if(D(`stripeStoreInitCheckoutSession: ${o}`),!o)throw new Error("Failed to initialize checkout session! The cart might be created with LIVE Invoice quote but being used with sandbox credential")}if((!a.checkoutSession||(null===(v=a.checkoutSession)||void 0===v?void 0:v.completedAt))&&w){const o=await this.fetchCheckoutSession(w);if(this.confirmationId=(null===(h=null==o?void 0:o.checkoutSession.landedCost)||void 0===h?void 0:h.shortId)||null,(null==o?void 0:o.checkoutSession.completedAt)&&o.checkoutSession.order)return void this.setToFinishStep("succeeded");if(null==o?void 0:o.checkoutSession.clientSecret){const{status:n}=await t({clientSecret:o.checkoutSession.clientSecret});if("processing"===n||"succeeded"===n)return void this.setToFinishStep(n)}throw E({endpoint:"INVALID_INVOICE_CHECKOUT_SESSION",errors:["Invalid checkout session, can not retrieve the checkout session after failing to update it"],metadata:{cartCheckoutSessionId:w,cartId:null===(m=window.Zonos.cartData)||void 0===m?void 0:m.id,cartLandedCostId:x}}),new Error("Invalid checkout session, can not retrieve the checkout session after failing to update it")}if(!a.checkoutSession)throw E({endpoint:"FAIL_TO_UPDATE_CREATE_INVOICE_CHECKOUT_SESSION",errors:["Could not update/create checkout session for this invoice cart"],metadata:{cartCheckoutSessionId:w||"N/A",cartId:null===(p=window.Zonos.cartData)||void 0===p?void 0:p.id,cartLandedCostId:x||"N/A"}}),new Error("Could not update/create checkout session for this invoice cart");d();const s=null===(u=a.checkoutSession)||void 0===u?void 0:u.landedCost;if(!s)throw new Error("Landed cost could not be found in checkout session after creating/updating them");await f(Object.assign(Object.assign({},a.checkoutSession),{id:k.checkoutSessionId||""})),g({landedCostId:s.id}),this.applyStripeTheme()}catch(o){U(o),r({messages:[C("Session does not have valid landed cost. Please contact [organizationName] for assistance.",{organizationName:O.organizationName})],title:C("Invalid session")})}this.isOverlayLoading=!1}}toggleLanguageDialog(){this.showLanguageDialogMobile=!this.showLanguageDialogMobile}async handleStripePaymentContinue(){var o,n,s,i;if(null===(o=e.stripeBillingAddressElement)||void 0===o||o.getValue(),null===(n=e.stripeLinkEventData)||void 0===n?void 0:n.complete)if(null===(s=e.stripeBillingAddressEventData)||void 0===s?void 0:s.complete)if("USD"!==e.checkoutSettlementCurrency||!e.shouldRenderPayInUsdButton||this.payInUsdConfirmDialogOpen){if(this.payInUsdConfirmDialogOpen=!1,y.paypalErrorMessage=null,e.hasPaymentError=!1,this.submitLoading=!0,a.inventoryCheckErrorMessage=null,!await v())return e.hasPaymentError=!0,e.customErrorMessage=C("Unable to complete payment in [currency]. Please try again or select a different currency. If the issue persists, contact our support team for assistance.",{currency:e.checkoutSettlementCurrency}),void(this.submitLoading=!1);await b();try{return await h({noLandedCostCheck:!0}),a.step="finish",void(this.confirmationId=w.landedCostShortId||(null===(i=a.selectedLandedCost)||void 0===i?void 0:i.landedCostId)||null)}catch(o){U(o),e.hasPaymentError=!0}this.submitLoading=!1}else this.payInUsdConfirmDialogOpen=!0;else{const o=document.querySelector(".zonos--billing-address");null==o||o.scrollIntoView({behavior:"smooth"})}else{const o=document.querySelector("zonos-link-authentication");null==o||o.scrollIntoView({behavior:"smooth"})}}componentWillLoad(){e.stripe=window.Zonos.stripe,a.step="payment",this.initInvoiceCart(),this.resizeListener(),this.storeUnsubscribeList=[m("clientSecret",(()=>{this.applyStripeTheme()})),I("selectedLocale",(()=>{this.applyStripeTheme()}))],D(`mobile: ${this.isMobile}`)}disconnectedCallback(){p(),u(),this.onChangeLocaleListener(),this.storeUnsubscribeList.forEach((o=>o()))}render(){this.clientSecret=e.clientSecret,e.stripeCustomerSessionClientSecret&&(this.stripeCustomerSessionClientSecret=e.stripeCustomerSessionClientSecret);const o=this.getBaseCurrencySettlementInfo(),{logoUrl:c,theme:t}=O.appearance,r=()=>{const o=`${c}?timestamp=${Date.now()}`;return n("div",{class:"zonos--logo"},o&&n("img",{alt:`${O.organizationName} logo`,src:o}))},l=P(),z=()=>{var o;const s=new URLSearchParams(window.location.search),e=s.get("zonosQaUrl"),c=s.get("zonosDebug"),t=null===(o=B.find((o=>o.code===j.selectedLocale)))||void 0===o?void 0:o.label;return n(i,null,n("zonos-h-stack",{class:"zonos--header-wrapper",spacing:16},n("div",{class:"zonos--logo-wrapper"},r(),l&&n("zonos-badge",{badgeColor:"orange",size:"small"},C("Test mode")),"1"===c&&n("zonos-badge",{badgeColor:"cyan",size:"small"},"debug"),e&&n("zonos-badge",{badgeColor:"purple",size:"small"},e)),n("div",{class:"zonos--header-right"},n("zonos-button",{backgroundColor:"gray-0",class:"zonos--header-right-button",onClick:()=>this.toggleLanguageDialog(),variant:"outline"},t,n("zonos-icon",{"aria-label":"Language select",content:'<svg color="var(--zonos-elements-gray-400)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M6.293 9.293a1 1 0 0 1 1.414 0L12 13.586l4.293-4.293a1 1 0 0 1 1.414 1.414l-4.93 4.93a1.1 1.1 0 0 1-1.555 0l-4.93-4.93a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>',iconColor:"gray-1200"})),n("div",{class:N(["zonos--invoice-language-dialog",this.showLanguageDialogMobile&&"zonos--invoice-language-dialog-open"])},n("zonos-language-select",{handleOnClose:()=>this.toggleLanguageDialog()})))))};return n(s,{class:N(["zonos--invoice zonos--elements",this.isMobile&&"mobile",this.isTablet&&"tablet"]),"data-theme":t},(()=>this.isOverlayLoading||e.isFetchingSession?null:n("div",{class:"zonos--content"},"finish"!==a.step&&"error"!==a.step&&n(i,null,(this.isMobile||this.isTablet)&&z(),n("div",{class:"zonos--left","data-theme":t},!this.isMobile&&!this.isTablet&&z(),n("zonos-text",{class:"zonos--title",type:"semiBoldSubheader"},C("Billing info")),n("zonos-v-stack",{spacing:16},n("zonos-link-authentication",{titleText:""}),n("zonos-address",{titleText:"",type:"billing"})),n("zonos-invoice-payment",{class:N(["zonos--invoice-container"]),continueLoading:this.submitLoading,onContinueClicked:async()=>{await this.handleStripePaymentContinue()}})),n("div",{class:"zonos--right","data-theme":t},!this.isMobile&&n("zonos-invoice-review",{mobile:this.isMobile,tablet:this.isTablet}),n("div",{class:"zonos--order-details-container"},!this.isMobile&&n("zonos-invoice-cart-items",null),this.isMobile&&n("zonos-invoice-order-details",{collapsed:this.collapseReviewMobile,mobile:this.isMobile,onCollapseClicked:()=>{this.collapseReviewMobile=!this.collapseReviewMobile}})),n("div",{class:"flex--wrapper"},!this.isMobile&&n("zonos-v-stack",{spacing:16},n("zonos-invoice-subtotal",null)),!this.isMobile&&!this.isTablet&&n("zonos-invoice-footer",{"data-theme":t,mobile:this.isMobile,tablet:this.isTablet})))),("finish"===a.step||"error"===a.step)&&n("div",{class:"zonos--done","data-theme":t},n("div",{class:"zonos--header"},r()),n("zonos-invoice-finish",{confirmationId:this.confirmationId,overrideNotification:"error"===a.step&&a.error?Object.assign(Object.assign({},a.error),{type:"error"}):void 0,storybookForceStatus:this.storybookPaymentStatusOverride})),(this.isMobile||this.isTablet||"finish"===a.step||"error"===a.step)&&n("zonos-invoice-footer",{"data-theme":t,mobile:this.isMobile,tablet:this.isTablet})))(),o&&n("zonos-confirm-dialog",{class:"zonos--pay-in-usd-dialog",dialogCancelBtnText:C("Cancel"),dialogConfirmBtnText:C("Pay [orderTotal]",{orderTotal:S({amount:o.settlementAmount,currency:"USD"})}),dialogIntent:"warn",dialogOpen:this.payInUsdConfirmDialogOpen,dialogSubtitle:C("By paying in USD, your card will be charged directly with no currency conversion. However, using a non-USD based card may result in additional currency conversion fees at the bank level."),dialogTitle:C("Pay in USD (United States Dollar)?"),dialogType:"confirm",dialogWidth:480,onCancelClicked:()=>{this.payInUsdConfirmDialogOpen=!1},onConfirmClicked:()=>this.handleStripePaymentContinue()}),n("zonos-loading-overlay",{open:this.isOverlayLoading}))}static get assetsDirs(){return["assets"]}};F.style=".sc-zonos-invoice-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-invoice-h *.sc-zonos-invoice{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-invoice-h img.sc-zonos-invoice{max-width:100%}.sc-zonos-invoice-h dl.sc-zonos-invoice,.sc-zonos-invoice-h dd.sc-zonos-invoice,.sc-zonos-invoice-h h1.sc-zonos-invoice,.sc-zonos-invoice-h h2.sc-zonos-invoice,.sc-zonos-invoice-h h3.sc-zonos-invoice,.sc-zonos-invoice-h h4.sc-zonos-invoice,.sc-zonos-invoice-h h5.sc-zonos-invoice,.sc-zonos-invoice-h h6.sc-zonos-invoice,.sc-zonos-invoice-h hr.sc-zonos-invoice,.sc-zonos-invoice-h figure.sc-zonos-invoice,.sc-zonos-invoice-h p.sc-zonos-invoice,.sc-zonos-invoice-h pre.sc-zonos-invoice{margin:0}.sc-zonos-invoice-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-invoice-h{z-index:2147483647;position:fixed;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;top:0;left:0;width:100%;height:100%;-ms-flex-align:center;align-items:center;background-color:var(--zonos-elements-gray-0)}.sc-zonos-invoice-h *.sc-zonos-invoice{-ms-scroll-chaining:none;overscroll-behavior:contain}.sc-zonos-invoice-h *.sc-zonos-invoice::-webkit-scrollbar{width:10px}.sc-zonos-invoice-h *.sc-zonos-invoice::-webkit-scrollbar-track{background:var(--zonos-elements-gray-50)}.sc-zonos-invoice-h *.sc-zonos-invoice::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.sc-zonos-invoice-h *.sc-zonos-invoice::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice{display:-ms-flexbox;display:flex;height:100%;overflow:hidden;width:100%;-ms-flex-pack:center;justify-content:center}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice{-ms-flex:1;flex:1;padding:56px 80px 60px;max-width:800px}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice{background-color:var(--zonos--primary-color, var(--zonos-elements-gray-0));border-right:1px solid var(--zonos-elements-gray-200);overflow:auto;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:32px}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice{background-color:var(--zonos-elements-gray-0)}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--done.sc-zonos-invoice{width:100%;max-width:1400px;max-height:100%;height:calc(100% - 100px);overflow:hidden;-ms-flex-direction:column;flex-direction:column;background-color:var(--zonos-elements-gray-0);-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:24px;padding-bottom:50px}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--done.sc-zonos-invoice .zonos--header.sc-zonos-invoice{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;width:100%}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--done.sc-zonos-invoice .zonos--logo.sc-zonos-invoice{margin-bottom:0}.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--done.sc-zonos-invoice zonos-checkout-finish.sc-zonos-invoice{-ms-flex:1;flex:1}.sc-zonos-invoice-h .zonos--header-title.sc-zonos-invoice,.sc-zonos-invoice-h .zonos--header-wrapper.sc-zonos-invoice{max-width:800px}.sc-zonos-invoice-h .zonos--left.sc-zonos-invoice{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;position:relative}.sc-zonos-invoice-h .zonos--left.sc-zonos-invoice .zonos--wrapper.sc-zonos-invoice{padding:0 8px 8px}.sc-zonos-invoice-h .zonos--left.sc-zonos-invoice .zonos--payment-error-banner.sc-zonos-invoice{margin-top:24px}.sc-zonos-invoice-h .zonos--right.sc-zonos-invoice{position:relative;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-zonos-invoice-h .zonos--right.sc-zonos-invoice .zonos--order-details-container.sc-zonos-invoice{overflow:auto}.sc-zonos-invoice-h .zonos--wrapper.sc-zonos-invoice{overflow:auto;max-height:100%;position:relative}.sc-zonos-invoice-h .flex--wrapper.sc-zonos-invoice{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;max-height:100%}.sc-zonos-invoice-h .zonos--logo-wrapper.sc-zonos-invoice{display:-ms-flexbox;display:flex;gap:16px;-ms-flex-align:center;align-items:center;-ms-flex:1;flex:1}.sc-zonos-invoice-h .zonos--logo-wrapper.sc-zonos-invoice>*.sc-zonos-invoice{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}.sc-zonos-invoice-h .zonos--header-right.sc-zonos-invoice{display:none}.sc-zonos-invoice-h .zonos--logo.sc-zonos-invoice{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.sc-zonos-invoice-h .zonos--logo.sc-zonos-invoice img.sc-zonos-invoice{max-height:70px;-o-object-position:left center;object-position:left center;-o-object-fit:contain;object-fit:contain}.sc-zonos-invoice-h .zonos--invoice-container.sc-zonos-invoice{overflow:visible}.mobile.sc-zonos-invoice-h,.tablet.sc-zonos-invoice-h{min-width:auto}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:auto;border-radius:0;max-height:100%;height:100%;border:0}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice{padding:12px;padding-bottom:76px}@media (max-width: 768px){.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice{padding-bottom:0}}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice{-ms-flex-order:2;order:2;border-right:none}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice{-ms-flex-order:1;order:1;padding-top:16px}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice .zonos--wrapper.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice .zonos--wrapper.sc-zonos-invoice{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;border:var(--zonos-elements-border);border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-10));background-color:var(--zonos-elements-gray-50);padding:12px;margin-top:32px}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice .zonos--review.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice .zonos--review.sc-zonos-invoice{margin-bottom:0}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice .zonos--cart-items.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice .zonos--cart-items.sc-zonos-invoice{margin-top:8px}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice zonos-checkout-footer.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice zonos-checkout-footer.sc-zonos-invoice{-ms-flex-order:3;order:3}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--wrapper.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--wrapper.sc-zonos-invoice{max-height:100%}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--footer.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--footer.sc-zonos-invoice{-ms-flex-order:3;order:3}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--done.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--done.sc-zonos-invoice{width:auto}.mobile.sc-zonos-invoice-h .zonos--cart-subtotal.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--cart-subtotal.sc-zonos-invoice{margin:0}.mobile.sc-zonos-invoice-h .zonos--header-wrapper.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--header-wrapper.sc-zonos-invoice{position:-webkit-sticky;position:sticky;top:0;width:100%;padding:16px;background-color:var(--zonos-elements-gray-0);z-index:3}.mobile.sc-zonos-invoice-h .zonos--header-title.sc-zonos-invoice,.mobile.sc-zonos-invoice-h .zonos--header-wrapper.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--header-title.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--header-wrapper.sc-zonos-invoice{max-width:800px;padding:0 16px}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice{overflow:auto;-ms-flex-pack:unset;justify-content:unset;-ms-flex-align:center;align-items:center;gap:24px}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--left.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice{overflow:visible;width:100%}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--right.sc-zonos-invoice{gap:32px}.mobile.sc-zonos-invoice-h .flex--wrapper.sc-zonos-invoice,.tablet.sc-zonos-invoice-h .flex--wrapper.sc-zonos-invoice{margin-top:0}.mobile.sc-zonos-invoice-h zonos-collect-footer.sc-zonos-invoice,.tablet.sc-zonos-invoice-h zonos-collect-footer.sc-zonos-invoice{-ms-flex-order:3;order:3;left:0}.tablet.sc-zonos-invoice-h .zonos--header-wrapper.sc-zonos-invoice{padding-top:56px;top:-56px}.mobile.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice .zonos--header-right.sc-zonos-invoice{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.mobile.sc-zonos-invoice-h .zonos--header-wrapper.sc-zonos-invoice{padding-top:28px;top:-28px}.mobile.sc-zonos-invoice-h .zonos--invoice-language-dialog.sc-zonos-invoice{position:fixed;left:0;right:0;bottom:0;-webkit-transform-origin:bottom center;transform-origin:bottom center;width:100vw;background:var(--zonos-elements-surface-color);-webkit-box-shadow:var(--zonos-elements-v3-shadow-xl);box-shadow:var(--zonos-elements-v3-shadow-xl);border-radius:var(--zonos-elements-radius-12);max-width:100vw;max-height:500px;z-index:2147483011;overflow:auto;-webkit-transform:scale(0);transform:scale(0);opacity:0;-webkit-transition:opacity 0.3s ease-out, -webkit-transform 0.3s ease-out;transition:opacity 0.3s ease-out, -webkit-transform 0.3s ease-out;transition:transform 0.3s ease-out, opacity 0.3s ease-out;transition:transform 0.3s ease-out, opacity 0.3s ease-out, -webkit-transform 0.3s ease-out;-ms-scroll-chaining:none;overscroll-behavior:contain}.mobile.sc-zonos-invoice-h .zonos--invoice-language-dialog.sc-zonos-invoice::-webkit-scrollbar{width:10px}.mobile.sc-zonos-invoice-h .zonos--invoice-language-dialog.sc-zonos-invoice::-webkit-scrollbar-track{background:var(--zonos-elements-gray-50)}.mobile.sc-zonos-invoice-h .zonos--invoice-language-dialog.sc-zonos-invoice::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}.mobile.sc-zonos-invoice-h .zonos--invoice-language-dialog.sc-zonos-invoice::-webkit-scrollbar-thumb:hover{background:#d6d6d6}.mobile.sc-zonos-invoice-h .zonos--invoice-language-dialog.sc-zonos-invoice::-webkit-scrollbar-track{border-top-right-radius:var(--zonos-elements-radius-12);border-bottom-right-radius:var(--zonos-elements-radius-12)}.mobile.sc-zonos-invoice-h .zonos--invoice-language-dialog.zonos--invoice-language-dialog-open.sc-zonos-invoice{opacity:1;-webkit-transform:scale(1);transform:scale(1)}.iframed.sc-zonos-invoice-h .zonos--content.sc-zonos-invoice{-ms-scroll-chaining:chained;overscroll-behavior:auto}";export{F as zonos_invoice}