@zonos/elements 1.5.0 → 1.5.2

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 (428) hide show
  1. package/dist/cjs/{TaxId-Q6aDqqWv.js → TaxId-ChhNwG04.js} +36 -0
  2. package/dist/cjs/{cart-B6Aty-21.js → cart-BJpqPdFU.js} +100 -64
  3. package/dist/cjs/{collect-DnrvaXUI.js → collect-CyUttsvB.js} +4 -4
  4. package/dist/cjs/{debounce-Cd2emZPn.js → debounce-BhgA8_3W.js} +2 -2
  5. package/dist/cjs/{debounce-vY0QYT6o.js → debounce-DRPMxNew.js} +1 -1
  6. package/dist/cjs/{getBorderRadius-CyYZw4qq.js → getBorderRadius-CJ_95w3o.js} +1 -1
  7. package/dist/cjs/{getMissingRequiredShippingFields-D03ICqss.js → getMissingRequiredShippingFields-DEbNbRAZ.js} +1 -1
  8. package/dist/cjs/{handleFetch-DQLhurnE.js → handleFetch-DVfjFTYO.js} +181 -71
  9. package/dist/cjs/{hasInclusivePrice-CPCoVeU3.js → hasInclusivePrice-CEPf3_FG.js} +1 -1
  10. package/dist/cjs/index.cjs.js +116 -13
  11. package/dist/cjs/{invoice-Cj8W7NW0.js → invoice-DzRkkpLu.js} +4 -4
  12. package/dist/cjs/loader.cjs.js +1 -1
  13. package/dist/cjs/{localization-BzNeXeDe.js → localization-BhNVhLZs.js} +725 -89
  14. package/dist/cjs/{paypal-CuKshRmZ.js → paypal-DCSqbdjW.js} +5 -5
  15. package/dist/cjs/{placeTestOrder-7czjwkjm.js → placeTestOrder-Bkip4PUT.js} +3 -3
  16. package/dist/cjs/{renderCheckoutCurrency-BH8t2b2x.js → renderCheckoutCurrency-BDvEZ3Hv.js} +2 -2
  17. package/dist/cjs/shouldRenderShortAddressCodeInput-gpu_bMfp.js +21 -0
  18. package/dist/cjs/{shouldShowLanguageSelect-yAbtCmd8.js → shouldShowLanguageSelect-NOVWOU53.js} +1 -1
  19. package/dist/cjs/{submitGtag-D79e8u6s.js → submitGtag-D4sB7w4z.js} +2 -2
  20. package/dist/cjs/{throttle-zSVRQLC0.js → taxIdFields-e4OCgr8K.js} +57 -2
  21. package/dist/cjs/taxIdRules-BBj8kQxJ.js +58 -0
  22. package/dist/cjs/{updateCheckoutSessionAttributes-jMtfOL2m.js → updateCheckoutSessionAttributes-KxwcsKhM.js} +2 -2
  23. package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +26 -31
  24. package/dist/cjs/zonos-address-display_2.cjs.entry.js +4 -4
  25. package/dist/cjs/zonos-address_4.cjs.entry.js +28 -31
  26. package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +8 -7
  27. package/dist/cjs/zonos-badge.cjs.entry.js +1 -1
  28. package/dist/cjs/zonos-banner.cjs.entry.js +1 -1
  29. package/dist/cjs/zonos-button_3.cjs.entry.js +2 -2
  30. package/dist/cjs/zonos-card_5.cjs.entry.js +9 -8
  31. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +91 -86
  32. package/dist/cjs/zonos-checkbox_2.cjs.entry.js +2 -2
  33. package/dist/cjs/zonos-checkout.cjs.entry.js +15 -14
  34. package/dist/cjs/zonos-collapse.cjs.entry.js +1 -1
  35. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +7 -6
  36. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +13 -12
  37. package/dist/cjs/zonos-collect.cjs.entry.js +10 -9
  38. package/dist/cjs/zonos-controller.cjs.entry.js +10 -9
  39. package/dist/cjs/zonos-country-flag.cjs.entry.js +3 -3
  40. package/dist/cjs/zonos-country-select_4.cjs.entry.js +4 -4
  41. package/dist/cjs/zonos-elements.cjs.js +1 -1
  42. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +5 -5
  43. package/dist/cjs/zonos-hello.cjs.entry.js +5 -5
  44. package/dist/cjs/zonos-input.cjs.entry.js +2 -2
  45. package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +9 -8
  46. package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +13 -12
  47. package/dist/cjs/zonos-invoice.cjs.entry.js +10 -9
  48. package/dist/cjs/zonos-language-select_2.cjs.entry.js +3 -3
  49. package/dist/cjs/zonos-logo.cjs.entry.js +1 -1
  50. package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +8 -7
  51. package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +2 -2
  52. package/dist/cjs/zonos-stripe-input.cjs.entry.js +2 -2
  53. package/dist/cjs/zonos-text.cjs.entry.js +1 -1
  54. package/dist/cjs/zonos-v-stack.cjs.entry.js +1 -1
  55. package/dist/cjs/{zonosStore-Bx9jK82G.js → zonosStore-CDV83QyK.js} +2 -0
  56. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +8 -7
  57. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +4 -3
  58. package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +12 -4
  59. package/dist/collection/components/main/zonos-controller.js +3 -2
  60. package/dist/collection/components/store/checkout/cart.js +3 -2
  61. package/dist/collection/components/store/checkout/stripe.js +20 -21
  62. package/dist/collection/components/store/storageStore.js +7 -6
  63. package/dist/collection/components/store/translationStore/strings.arabic.js +35 -2
  64. package/dist/collection/components/store/translationStore/strings.base.js +35 -2
  65. package/dist/collection/components/store/translationStore/strings.chinese.js +35 -2
  66. package/dist/collection/components/store/translationStore/strings.danish.js +35 -2
  67. package/dist/collection/components/store/translationStore/strings.dutch.js +35 -2
  68. package/dist/collection/components/store/translationStore/strings.french.js +35 -2
  69. package/dist/collection/components/store/translationStore/strings.german.js +35 -2
  70. package/dist/collection/components/store/translationStore/strings.hebrew.js +35 -2
  71. package/dist/collection/components/store/translationStore/strings.indonesian.js +35 -2
  72. package/dist/collection/components/store/translationStore/strings.italian.js +35 -2
  73. package/dist/collection/components/store/translationStore/strings.japanese.js +35 -2
  74. package/dist/collection/components/store/translationStore/strings.korean.js +35 -2
  75. package/dist/collection/components/store/translationStore/strings.norwegian.js +35 -2
  76. package/dist/collection/components/store/translationStore/strings.polish.js +35 -2
  77. package/dist/collection/components/store/translationStore/strings.portuguese.js +35 -2
  78. package/dist/collection/components/store/translationStore/strings.russian.js +35 -2
  79. package/dist/collection/components/store/translationStore/strings.spanish.js +35 -2
  80. package/dist/collection/components/store/translationStore/strings.swedish.js +35 -2
  81. package/dist/collection/components/store/translationStore/strings.turkish.js +35 -2
  82. package/dist/collection/components/store/translationStore/strings.vietnamese.js +35 -2
  83. package/dist/collection/components/store/zonosStore.js +2 -1
  84. package/dist/collection/components/stripe/zonos-address/zonos-address.css +5 -0
  85. package/dist/collection/components/stripe/zonos-address/zonos-address.js +37 -22
  86. package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.css +5 -0
  87. package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +34 -21
  88. package/dist/collection/components/utils/__tests__/helpers/blockStorage.js +24 -0
  89. package/dist/collection/components/utils/api/getExchangeRate.js +2 -1
  90. package/dist/collection/components/utils/api/prepCalculateLandedCost.js +24 -35
  91. package/dist/collection/components/utils/checkout/getCheckoutTaxIdPayload.js +16 -0
  92. package/dist/collection/components/utils/checkout/getTaxIdFieldState.js +26 -0
  93. package/dist/collection/components/utils/checkout/resolveTaxIdSelection.js +23 -0
  94. package/dist/collection/components/utils/checkout/shouldRenderTaxIdInput.js +7 -11
  95. package/dist/collection/components/utils/checkout/taxIdFields.js +29 -0
  96. package/dist/collection/components/utils/handleFetch.js +19 -9
  97. package/dist/collection/components/utils/hello/countryOverrideStorage.js +17 -40
  98. package/dist/collection/components/utils/logging/installConstructorCapture.js +58 -0
  99. package/dist/collection/components/utils/logging/reportBlockedStorage.js +34 -0
  100. package/dist/collection/components/utils/logging/sendErrorLog.js +8 -1
  101. package/dist/collection/components/utils/logging/startZonosInit.js +35 -0
  102. package/dist/collection/components/utils/logging/thrownMessage.js +16 -0
  103. package/dist/collection/components/utils/safeStorage.js +39 -0
  104. package/dist/collection/components/utils/taxId/taxIdRules.js +44 -0
  105. package/dist/collection/components/utils/taxIdValidationResult.js +57 -58
  106. package/dist/collection/index.js +1 -0
  107. package/dist/collection/scripts/_getZonosQaUrl.js +3 -2
  108. package/dist/collection/scripts/_zonosBase.js +6 -2
  109. package/dist/collection/types/checkout/TaxId.js +31 -0
  110. package/dist/collection/types/generated/graphql.frontend.types.js +0 -16
  111. package/dist/collection/types/generated/graphql.internal.types.js +215 -1
  112. package/dist/esm/{TaxId-Cye-evFK.js → TaxId-DMIgN_sT.js} +32 -1
  113. package/dist/esm/{cart-BoQp8Ema.js → cart-BS5mSI8x.js} +100 -65
  114. package/dist/esm/{collect-Eo4gtyql.js → collect-B9ZxDDl7.js} +4 -4
  115. package/dist/esm/{debounce-BR3PaG8X.js → debounce-DHj2iHA1.js} +1 -1
  116. package/dist/esm/{debounce-CrmpwbEE.js → debounce-DWqMT4lo.js} +2 -2
  117. package/dist/esm/{getBorderRadius-DYfkeXdx.js → getBorderRadius-BiGd45jw.js} +1 -1
  118. package/dist/esm/{getMissingRequiredShippingFields-Ks6_tpjn.js → getMissingRequiredShippingFields-BkEV865q.js} +1 -1
  119. package/dist/esm/{handleFetch-D5GYDF-O.js → handleFetch-BFVO7oAR.js} +178 -72
  120. package/dist/esm/{hasInclusivePrice-CbEfIhI5.js → hasInclusivePrice-zSvDReDb.js} +1 -1
  121. package/dist/esm/index.js +106 -13
  122. package/dist/esm/{invoice-S1KahJ_Z.js → invoice-6iTuS6ek.js} +4 -4
  123. package/dist/esm/loader.js +1 -1
  124. package/dist/esm/{localization-BIh-4pc_.js → localization-CXHiWcJp.js} +725 -89
  125. package/dist/esm/{paypal-DNfvnuUU.js → paypal-BE_NVBoy.js} +5 -5
  126. package/dist/esm/{placeTestOrder-CQaMKFOg.js → placeTestOrder-BXA9K9Iy.js} +3 -3
  127. package/dist/esm/{renderCheckoutCurrency-C2Tw73uR.js → renderCheckoutCurrency-KMa4HlAf.js} +2 -2
  128. package/dist/esm/shouldRenderShortAddressCodeInput-Bc8k2vN0.js +19 -0
  129. package/dist/esm/{shouldShowLanguageSelect-CCD7gpSY.js → shouldShowLanguageSelect-BI_ApEsQ.js} +1 -1
  130. package/dist/esm/{submitGtag-df9AQ2zL.js → submitGtag-C5xzFHjG.js} +2 -2
  131. package/dist/esm/taxIdFields-BUKnHMaL.js +139 -0
  132. package/dist/esm/taxIdRules-xYlx7ZXW.js +47 -0
  133. package/dist/esm/{updateCheckoutSessionAttributes-4Jq6V4pO.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +2 -2
  134. package/dist/esm/zonos-address-completion-dialog_7.entry.js +24 -29
  135. package/dist/esm/zonos-address-display_2.entry.js +4 -4
  136. package/dist/esm/zonos-address_4.entry.js +26 -29
  137. package/dist/esm/zonos-airwallex-payment.entry.js +8 -7
  138. package/dist/esm/zonos-badge.entry.js +1 -1
  139. package/dist/esm/zonos-banner.entry.js +1 -1
  140. package/dist/esm/zonos-button_3.entry.js +2 -2
  141. package/dist/esm/zonos-card_5.entry.js +9 -8
  142. package/dist/esm/zonos-cart-items_12.entry.js +90 -85
  143. package/dist/esm/zonos-checkbox_2.entry.js +2 -2
  144. package/dist/esm/zonos-checkout.entry.js +15 -14
  145. package/dist/esm/zonos-collapse.entry.js +1 -1
  146. package/dist/esm/zonos-collect-cart-items_3.entry.js +7 -6
  147. package/dist/esm/zonos-collect-finish_6.entry.js +13 -12
  148. package/dist/esm/zonos-collect.entry.js +10 -9
  149. package/dist/esm/zonos-controller.entry.js +10 -9
  150. package/dist/esm/zonos-country-flag.entry.js +3 -3
  151. package/dist/esm/zonos-country-select_4.entry.js +4 -4
  152. package/dist/esm/zonos-elements.js +1 -1
  153. package/dist/esm/zonos-hello-dialog.entry.js +5 -5
  154. package/dist/esm/zonos-hello.entry.js +5 -5
  155. package/dist/esm/zonos-input.entry.js +2 -2
  156. package/dist/esm/zonos-invoice-cart-items_2.entry.js +9 -8
  157. package/dist/esm/zonos-invoice-finish_5.entry.js +13 -12
  158. package/dist/esm/zonos-invoice.entry.js +10 -9
  159. package/dist/esm/zonos-language-select_2.entry.js +3 -3
  160. package/dist/esm/zonos-logo.entry.js +1 -1
  161. package/dist/esm/zonos-policy-consent_2.entry.js +8 -7
  162. package/dist/esm/zonos-shipping-rich-radio.entry.js +2 -2
  163. package/dist/esm/zonos-stripe-input.entry.js +2 -2
  164. package/dist/esm/zonos-text.entry.js +1 -1
  165. package/dist/esm/zonos-v-stack.entry.js +1 -1
  166. package/dist/esm/{zonosStore-msUlqmSD.js → zonosStore-BXP9FvIt.js} +2 -1
  167. package/dist/esm-es5/{TaxId-Cye-evFK.js → TaxId-DMIgN_sT.js} +2 -1
  168. package/dist/esm-es5/{cart-BoQp8Ema.js → cart-BS5mSI8x.js} +42 -31
  169. package/dist/esm-es5/{collect-Eo4gtyql.js → collect-B9ZxDDl7.js} +1 -1
  170. package/dist/esm-es5/{debounce-BR3PaG8X.js → debounce-DHj2iHA1.js} +7 -7
  171. package/dist/esm-es5/debounce-DWqMT4lo.js +1 -0
  172. package/dist/esm-es5/getBorderRadius-BiGd45jw.js +8 -0
  173. package/dist/esm-es5/{getMissingRequiredShippingFields-Ks6_tpjn.js → getMissingRequiredShippingFields-BkEV865q.js} +3 -3
  174. package/dist/esm-es5/handleFetch-BFVO7oAR.js +73 -0
  175. package/dist/esm-es5/{hasInclusivePrice-CbEfIhI5.js → hasInclusivePrice-zSvDReDb.js} +1 -1
  176. package/dist/esm-es5/index.js +30 -12
  177. package/dist/esm-es5/{invoice-S1KahJ_Z.js → invoice-6iTuS6ek.js} +1 -1
  178. package/dist/esm-es5/loader.js +1 -1
  179. package/dist/esm-es5/localization-CXHiWcJp.js +345 -0
  180. package/dist/esm-es5/{paypal-DNfvnuUU.js → paypal-BE_NVBoy.js} +1 -1
  181. package/dist/esm-es5/{placeTestOrder-CQaMKFOg.js → placeTestOrder-BXA9K9Iy.js} +1 -1
  182. package/dist/esm-es5/{renderCheckoutCurrency-C2Tw73uR.js → renderCheckoutCurrency-KMa4HlAf.js} +1 -1
  183. package/dist/esm-es5/shouldRenderShortAddressCodeInput-Bc8k2vN0.js +8 -0
  184. package/dist/esm-es5/{shouldShowLanguageSelect-CCD7gpSY.js → shouldShowLanguageSelect-BI_ApEsQ.js} +1 -1
  185. package/dist/esm-es5/{submitGtag-df9AQ2zL.js → submitGtag-C5xzFHjG.js} +1 -1
  186. package/dist/esm-es5/taxIdFields-BUKnHMaL.js +46 -0
  187. package/dist/esm-es5/taxIdRules-xYlx7ZXW.js +6 -0
  188. package/dist/esm-es5/{updateCheckoutSessionAttributes-4Jq6V4pO.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +1 -1
  189. package/dist/esm-es5/zonos-address-completion-dialog_7.entry.js +253 -254
  190. package/dist/esm-es5/zonos-address-display_2.entry.js +1 -1
  191. package/dist/esm-es5/zonos-address_4.entry.js +8 -9
  192. package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
  193. package/dist/esm-es5/zonos-badge.entry.js +1 -1
  194. package/dist/esm-es5/zonos-banner.entry.js +1 -1
  195. package/dist/esm-es5/zonos-button_3.entry.js +1 -1
  196. package/dist/esm-es5/zonos-card_5.entry.js +6 -6
  197. package/dist/esm-es5/zonos-cart-items_12.entry.js +137 -136
  198. package/dist/esm-es5/zonos-checkbox_2.entry.js +1 -1
  199. package/dist/esm-es5/zonos-checkout.entry.js +3 -3
  200. package/dist/esm-es5/zonos-collapse.entry.js +1 -1
  201. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  202. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
  203. package/dist/esm-es5/zonos-collect.entry.js +6 -6
  204. package/dist/esm-es5/zonos-controller.entry.js +5 -5
  205. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  206. package/dist/esm-es5/zonos-country-select_4.entry.js +2 -2
  207. package/dist/esm-es5/zonos-elements.js +1 -1
  208. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  209. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  210. package/dist/esm-es5/zonos-input.entry.js +1 -1
  211. package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +2 -2
  212. package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
  213. package/dist/esm-es5/zonos-invoice.entry.js +3 -3
  214. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  215. package/dist/esm-es5/zonos-logo.entry.js +1 -1
  216. package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
  217. package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
  218. package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
  219. package/dist/esm-es5/zonos-text.entry.js +1 -1
  220. package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
  221. package/dist/esm-es5/{zonosStore-msUlqmSD.js → zonosStore-BXP9FvIt.js} +1 -1
  222. package/dist/scripts/index.d.ts +103 -1
  223. package/dist/scripts/index.js +1 -1
  224. package/dist/scripts/loadZonos.js +1 -1
  225. package/dist/scripts/zonos.js +1 -1
  226. package/dist/types/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.d.ts +4 -0
  227. package/dist/types/components/store/checkout/stripe.d.ts +9 -0
  228. package/dist/types/components/store/translationStore/strings.arabic.d.ts +34 -1
  229. package/dist/types/components/store/translationStore/strings.base.d.ts +34 -1
  230. package/dist/types/components/store/translationStore/strings.chinese.d.ts +34 -1
  231. package/dist/types/components/store/translationStore/strings.danish.d.ts +34 -1
  232. package/dist/types/components/store/translationStore/strings.dutch.d.ts +34 -1
  233. package/dist/types/components/store/translationStore/strings.french.d.ts +34 -1
  234. package/dist/types/components/store/translationStore/strings.german.d.ts +34 -1
  235. package/dist/types/components/store/translationStore/strings.hebrew.d.ts +34 -1
  236. package/dist/types/components/store/translationStore/strings.indonesian.d.ts +34 -1
  237. package/dist/types/components/store/translationStore/strings.italian.d.ts +34 -1
  238. package/dist/types/components/store/translationStore/strings.japanese.d.ts +34 -1
  239. package/dist/types/components/store/translationStore/strings.korean.d.ts +34 -1
  240. package/dist/types/components/store/translationStore/strings.norwegian.d.ts +34 -1
  241. package/dist/types/components/store/translationStore/strings.polish.d.ts +34 -1
  242. package/dist/types/components/store/translationStore/strings.portuguese.d.ts +34 -1
  243. package/dist/types/components/store/translationStore/strings.russian.d.ts +34 -1
  244. package/dist/types/components/store/translationStore/strings.spanish.d.ts +34 -1
  245. package/dist/types/components/store/translationStore/strings.swedish.d.ts +34 -1
  246. package/dist/types/components/store/translationStore/strings.turkish.d.ts +34 -1
  247. package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +34 -1
  248. package/dist/types/components/store/zonosStore.d.ts +2 -1
  249. package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +4 -1
  250. package/dist/types/components/stripe/zonos-custom-address/zonos-custom-address.d.ts +4 -1
  251. package/dist/types/components/utils/__tests__/helpers/blockStorage.d.ts +3 -0
  252. package/dist/types/components/utils/checkout/getCheckoutTaxIdPayload.d.ts +6 -0
  253. package/dist/types/components/utils/checkout/getTaxIdFieldState.d.ts +18 -0
  254. package/dist/types/components/utils/checkout/resolveTaxIdSelection.d.ts +12 -0
  255. package/dist/types/components/utils/checkout/shouldRenderTaxIdInput.d.ts +2 -1
  256. package/dist/types/components/utils/checkout/taxIdFields.d.ts +11 -0
  257. package/dist/types/components/utils/logging/installConstructorCapture.d.ts +20 -0
  258. package/dist/types/components/utils/logging/reportBlockedStorage.d.ts +16 -0
  259. package/dist/types/components/utils/logging/startZonosInit.d.ts +5 -0
  260. package/dist/types/components/utils/logging/thrownMessage.d.ts +1 -0
  261. package/dist/types/components/utils/safeStorage.d.ts +4 -0
  262. package/dist/types/components/utils/taxId/taxIdRules.d.ts +37 -0
  263. package/dist/types/components/utils/taxIdValidationResult.d.ts +8 -2
  264. package/dist/types/components.d.ts +22 -0
  265. package/dist/types/index.d.ts +1 -0
  266. package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +5 -0
  267. package/dist/types/types/checkout/TaxId.d.ts +45 -0
  268. package/dist/types/types/checkout/api/CalculateLandedCost.d.ts +11 -0
  269. package/dist/types/types/checkout/api/CreateParty.d.ts +2 -0
  270. package/dist/types/types/generated/graphql.frontend.types.d.ts +0 -22
  271. package/dist/types/types/generated/graphql.frontend.types.ts +0 -51
  272. package/dist/types/types/generated/graphql.internal.types.d.ts +270 -1
  273. package/dist/types/types/generated/graphql.internal.types.ts +341 -1
  274. package/dist/types/types/utils/ZonosSettings.d.ts +5 -0
  275. package/dist/zonos-elements/index.esm.js +1 -1
  276. package/dist/zonos-elements/p-08b01c96.entry.js +1 -0
  277. package/dist/zonos-elements/{p-c961caaf.entry.js → p-0909ef77.entry.js} +1 -1
  278. package/dist/zonos-elements/{p-23352709.system.entry.js → p-13015d34.system.entry.js} +4 -4
  279. package/dist/zonos-elements/{p-6c41b00c.entry.js → p-13d5b2f9.entry.js} +1 -1
  280. package/dist/zonos-elements/{p-5b80aff2.system.entry.js → p-150047b3.system.entry.js} +25 -25
  281. package/dist/zonos-elements/p-1986cc37.entry.js +1 -0
  282. package/dist/zonos-elements/{p-CBx5nYet.system.js → p-1OG3IJgY.system.js} +1 -1
  283. package/dist/zonos-elements/{p-d3d0656a.entry.js → p-1a5acbcd.entry.js} +1 -1
  284. package/dist/zonos-elements/{p-756d303f.system.entry.js → p-20eb00de.system.entry.js} +1 -1
  285. package/dist/zonos-elements/{p-9c33f7ed.system.entry.js → p-30bf4700.system.entry.js} +1 -1
  286. package/dist/zonos-elements/{p-d168023b.entry.js → p-3466bcba.entry.js} +1 -1
  287. package/dist/zonos-elements/p-383343c7.entry.js +1 -0
  288. package/dist/zonos-elements/{p-06030d3b.system.entry.js → p-3a506614.system.entry.js} +54 -54
  289. package/dist/zonos-elements/p-43c0ebe9.entry.js +1 -0
  290. package/dist/zonos-elements/{p-acd50b0b.entry.js → p-4612facd.entry.js} +1 -1
  291. package/dist/zonos-elements/{p-244e0302.system.entry.js → p-4715045c.system.entry.js} +1 -1
  292. package/dist/zonos-elements/p-4b65f192.entry.js +1 -0
  293. package/dist/zonos-elements/{p-5967a1c1.system.entry.js → p-573a4e7c.system.entry.js} +6 -6
  294. package/dist/zonos-elements/p-59fc32af.entry.js +1 -0
  295. package/dist/zonos-elements/{p-d82fd8a9.system.entry.js → p-5a296dbc.system.entry.js} +117 -116
  296. package/dist/zonos-elements/{p-193d9722.entry.js → p-61312d5b.entry.js} +1 -1
  297. package/dist/zonos-elements/{p-6abec43f.system.entry.js → p-68325c5a.system.entry.js} +4 -4
  298. package/dist/zonos-elements/{p-0b81f8b9.system.entry.js → p-6db7317a.system.entry.js} +6 -6
  299. package/dist/zonos-elements/{p-51400242.system.entry.js → p-709d1561.system.entry.js} +3 -3
  300. package/dist/zonos-elements/p-71d29603.entry.js +1 -0
  301. package/dist/zonos-elements/{p-7bd99479.system.entry.js → p-7214c953.system.entry.js} +21 -21
  302. package/dist/zonos-elements/p-74659d88.entry.js +1 -0
  303. package/dist/zonos-elements/{p-55916c90.entry.js → p-7f1bea9b.entry.js} +1 -1
  304. package/dist/zonos-elements/{p-0fca452b.entry.js → p-7fe83919.entry.js} +1 -1
  305. package/dist/zonos-elements/{p-1c150f26.entry.js → p-821e413a.entry.js} +1 -1
  306. package/dist/zonos-elements/{p-c403f004.system.entry.js → p-82e45d0c.system.entry.js} +1 -1
  307. package/dist/zonos-elements/{p-1409de3b.system.entry.js → p-88e20e99.system.entry.js} +1 -1
  308. package/dist/zonos-elements/{p-195f6e38.system.entry.js → p-89a3c4db.system.entry.js} +1 -1
  309. package/dist/zonos-elements/p-8ac26831.entry.js +1 -0
  310. package/dist/zonos-elements/{p-a40fd99b.system.entry.js → p-8f9f859f.system.entry.js} +39 -40
  311. package/dist/zonos-elements/{p-92fe9a1f.system.entry.js → p-902cca23.system.entry.js} +1 -1
  312. package/dist/zonos-elements/{p-0a4a7742.system.entry.js → p-93860183.system.entry.js} +1 -1
  313. package/dist/zonos-elements/{p-b5882fbb.system.entry.js → p-9449b4f4.system.entry.js} +1 -1
  314. package/dist/zonos-elements/{p-31043c2e.system.entry.js → p-96b250d8.system.entry.js} +298 -299
  315. package/dist/zonos-elements/p-97729873.entry.js +1 -0
  316. package/dist/zonos-elements/{p-1bac5ac1.system.entry.js → p-990fcf81.system.entry.js} +1 -1
  317. package/dist/zonos-elements/{p-7f031592.system.entry.js → p-9b3668a4.system.entry.js} +155 -155
  318. package/dist/zonos-elements/{p-249c1ee1.system.entry.js → p-9df31243.system.entry.js} +3 -3
  319. package/dist/zonos-elements/p-BD-9rD53.js +1 -0
  320. package/dist/zonos-elements/p-BI6VAB5B.js +1 -0
  321. package/dist/zonos-elements/p-BJFa5RwX.js +1 -0
  322. package/dist/zonos-elements/p-BJ_kE5rM.js +1 -0
  323. package/dist/zonos-elements/{p-Be3Hpms1.system.js → p-BKUlQxBd.system.js} +1 -1
  324. package/dist/zonos-elements/p-BUfCTQXY.system.js +528 -0
  325. package/dist/zonos-elements/{p-CZD8WvyY.system.js → p-BnQyot7Y.system.js} +23 -23
  326. package/dist/zonos-elements/p-Bu9WCfUC.system.js +2 -2
  327. package/dist/zonos-elements/{p-0mGRBGcf.js → p-C-zdj7MK.js} +1 -1
  328. package/dist/zonos-elements/p-C5fs3rIR.js +1 -0
  329. package/dist/zonos-elements/{p-sz4L-ZnB.js → p-CJmWr75U.js} +1 -1
  330. package/dist/zonos-elements/{p-XDxdMlQl.system.js → p-CMneHjck.system.js} +15 -15
  331. package/dist/zonos-elements/p-CP7KnfR3.system.js +245 -0
  332. package/dist/zonos-elements/p-CVRbGFV3.js +1 -0
  333. package/dist/zonos-elements/p-CYxMfUL7.system.js +1 -0
  334. package/dist/zonos-elements/p-Cl5yV0ak.js +1 -0
  335. package/dist/zonos-elements/{p-kaOxUR9u.system.js → p-Cp1IAJvW.system.js} +5 -5
  336. package/dist/zonos-elements/{p-W82paT5F.js → p-CqB9AfBf.js} +1 -1
  337. package/dist/zonos-elements/p-CzKlS3E-.system.js +6 -0
  338. package/dist/zonos-elements/p-D-Lnf8mS.system.js +345 -0
  339. package/dist/zonos-elements/p-D0DkOoAw.system.js +73 -0
  340. package/dist/zonos-elements/{p-c9QtIdJX.js → p-D4xpkSsK.js} +1 -1
  341. package/dist/zonos-elements/p-DATNIakn.js +1 -0
  342. package/dist/zonos-elements/{p-D4MevhAL.system.js → p-DC1OPJDq.system.js} +3 -3
  343. package/dist/zonos-elements/{p-8PPEbm_0.system.js → p-DIab60nK.system.js} +12 -12
  344. package/dist/zonos-elements/p-DKnphvmJ.js +1 -0
  345. package/dist/zonos-elements/{p-Cye-evFK.js → p-DMIgN_sT.js} +1 -1
  346. package/dist/zonos-elements/{p-BuU_p5DP.system.js → p-DTgUqgwV.system.js} +2 -2
  347. package/dist/zonos-elements/p-DW7I0zOF.js +1 -0
  348. package/dist/zonos-elements/{p-DoEHepOc.system.js → p-DXlojp_Y.system.js} +1 -1
  349. package/dist/zonos-elements/p-DqVePqqx.system.js +8 -0
  350. package/dist/zonos-elements/{p-B4Ufchqh.system.js → p-DrS-0mk7.system.js} +3 -3
  351. package/dist/zonos-elements/{p-7abqRc9V.js → p-DrbN3rPL.js} +2 -2
  352. package/dist/zonos-elements/{p-Cby4EkFu.system.js → p-DsBuZ6ob.system.js} +2 -1
  353. package/dist/zonos-elements/{p-DI2vXnXc.system.js → p-Dv5a-V6w.system.js} +1 -1
  354. package/dist/zonos-elements/p-Dwg61Ft_.js +1 -0
  355. package/dist/zonos-elements/{p-474e8a92.system.entry.js → p-a1022808.system.entry.js} +1 -1
  356. package/dist/zonos-elements/{p-17c7ea4a.system.entry.js → p-a3c147d2.system.entry.js} +3 -3
  357. package/dist/zonos-elements/p-aK18R41t.js +1 -0
  358. package/dist/zonos-elements/{p-83aa1c8c.entry.js → p-ad04bba2.entry.js} +1 -1
  359. package/dist/zonos-elements/p-af4ad54b.entry.js +1 -0
  360. package/dist/zonos-elements/p-af741506.entry.js +1 -0
  361. package/dist/zonos-elements/{p-a938c174.entry.js → p-b51010b9.entry.js} +1 -1
  362. package/dist/zonos-elements/{p-6db7c0b1.system.entry.js → p-b540c636.system.entry.js} +2 -2
  363. package/dist/zonos-elements/p-bac94956.entry.js +1 -0
  364. package/dist/zonos-elements/{p-69c3e367.system.entry.js → p-bb1b414a.system.entry.js} +9 -9
  365. package/dist/zonos-elements/{p-b79036fc.entry.js → p-bfa9e32a.entry.js} +1 -1
  366. package/dist/zonos-elements/{p-dfc87b10.system.entry.js → p-c33b8f6a.system.entry.js} +1 -1
  367. package/dist/zonos-elements/p-cf6bf7a4.entry.js +1 -0
  368. package/dist/zonos-elements/{p-CEK_Wk6v.system.js → p-dJcbnNlE.system.js} +1 -1
  369. package/dist/zonos-elements/p-db40b9c3.entry.js +1 -0
  370. package/dist/zonos-elements/p-dd003161.entry.js +1 -0
  371. package/dist/zonos-elements/{p-2603dce0.entry.js → p-e216cc8c.entry.js} +1 -1
  372. package/dist/zonos-elements/p-e374aaa4.entry.js +1 -0
  373. package/dist/zonos-elements/{p-155ed3d3.system.entry.js → p-e43470f7.system.entry.js} +21 -21
  374. package/dist/zonos-elements/p-ebc7ea54.system.entry.js +13 -0
  375. package/dist/zonos-elements/{p-11defdca.system.entry.js → p-f2ed52bc.system.entry.js} +8 -8
  376. package/dist/zonos-elements/{p-d4d2b39e.entry.js → p-fddf3556.entry.js} +1 -1
  377. package/dist/zonos-elements/p-gEViRqvf.js +1 -0
  378. package/dist/zonos-elements/{p-BpDCLBwW.js → p-n5PZKz1k.js} +1 -1
  379. package/dist/zonos-elements/{p-C_z9WL8a.js → p-r-YGHhLa.js} +1 -1
  380. package/dist/zonos-elements/{p-XqkqjeNV.system.js → p-yv7ekcdG.system.js} +2 -2
  381. package/dist/zonos-elements/{p-DQZncB2d.system.js → p-zsTASoh2.system.js} +3 -3
  382. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  383. package/package.json +1 -1
  384. package/dist/cjs/shouldRenderTaxIdInput-TxekHCp7.js +0 -43
  385. package/dist/esm/shouldRenderTaxIdInput-CKyZ6Zni.js +0 -40
  386. package/dist/esm/throttle-Cvlvb-dm.js +0 -85
  387. package/dist/esm-es5/debounce-CrmpwbEE.js +0 -1
  388. package/dist/esm-es5/getBorderRadius-DYfkeXdx.js +0 -8
  389. package/dist/esm-es5/handleFetch-D5GYDF-O.js +0 -60
  390. package/dist/esm-es5/localization-BIh-4pc_.js +0 -348
  391. package/dist/esm-es5/shouldRenderTaxIdInput-CKyZ6Zni.js +0 -17
  392. package/dist/esm-es5/throttle-Cvlvb-dm.js +0 -46
  393. package/dist/zonos-elements/p-06fe2939.entry.js +0 -1
  394. package/dist/zonos-elements/p-24f3c547.entry.js +0 -1
  395. package/dist/zonos-elements/p-30b3c9d3.entry.js +0 -1
  396. package/dist/zonos-elements/p-39ee1558.entry.js +0 -1
  397. package/dist/zonos-elements/p-3a2da031.entry.js +0 -1
  398. package/dist/zonos-elements/p-4679f0ec.entry.js +0 -1
  399. package/dist/zonos-elements/p-4806b264.system.entry.js +0 -13
  400. package/dist/zonos-elements/p-5873ab8e.entry.js +0 -1
  401. package/dist/zonos-elements/p-725e29bb.entry.js +0 -1
  402. package/dist/zonos-elements/p-BGktDPwA.system.js +0 -1
  403. package/dist/zonos-elements/p-Bi-s0fp_.system.js +0 -17
  404. package/dist/zonos-elements/p-CFbfEmjN.js +0 -1
  405. package/dist/zonos-elements/p-CUaf1cEg.js +0 -1
  406. package/dist/zonos-elements/p-CXxvn4GX.system.js +0 -227
  407. package/dist/zonos-elements/p-CcJF6xhQ.js +0 -1
  408. package/dist/zonos-elements/p-Cxuiqv1I.js +0 -1
  409. package/dist/zonos-elements/p-D-bZg-Pc.js +0 -1
  410. package/dist/zonos-elements/p-DE4a-QD5.js +0 -1
  411. package/dist/zonos-elements/p-DOD2I44l.system.js +0 -348
  412. package/dist/zonos-elements/p-DS-qw_qc.system.js +0 -517
  413. package/dist/zonos-elements/p-DZ2mevDK.js +0 -1
  414. package/dist/zonos-elements/p-DnjGkbEy.js +0 -1
  415. package/dist/zonos-elements/p-FRWZayxL.js +0 -1
  416. package/dist/zonos-elements/p-Mrz_lnC1.js +0 -1
  417. package/dist/zonos-elements/p-ad9ff14c.entry.js +0 -1
  418. package/dist/zonos-elements/p-bb3546c0.entry.js +0 -1
  419. package/dist/zonos-elements/p-c1cbfdba.entry.js +0 -1
  420. package/dist/zonos-elements/p-c47ce656.entry.js +0 -1
  421. package/dist/zonos-elements/p-c9d5d8f1.entry.js +0 -1
  422. package/dist/zonos-elements/p-clDfq9AL.js +0 -1
  423. package/dist/zonos-elements/p-d74bc3e8.entry.js +0 -1
  424. package/dist/zonos-elements/p-d8b312e5.entry.js +0 -1
  425. package/dist/zonos-elements/p-db87b0dd.entry.js +0 -1
  426. package/dist/zonos-elements/p-defc2d18.entry.js +0 -1
  427. package/dist/zonos-elements/p-rVp8hgWw.js +0 -1
  428. package/dist/zonos-elements/p-zVLAvre1.system.js +0 -60
@@ -0,0 +1,528 @@
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=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=s(0),a["throw"]=s(1),a["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-DTgUqgwV.system.js","./p-D-Lnf8mS.system.js","./p-CzKlS3E-.system.js","./p-DsBuZ6ob.system.js","./p-BbgqQIHv.system.js","./p-D0DkOoAw.system.js","./p-DW-fW8yR.system.js","./p-zsTASoh2.system.js"],(function(e){"use strict";var r,n,t,o,i,a,s,u,d,l,c,v,f,p,m,h,y,w,g,b,_,S,O,A,C,k,I;return{setters:[function(e){r=e.c;n=e.z;t=e.e},function(e){o=e.s;i=e.t;a=e.m;s=e.l;u=e.f;d=e.e},function(e){l=e.b;c=e.e},function(e){v=e.e;f=e.i},function(e){p=e.l;m=e.b},function(e){h=e.h;y=e.l;w=e.f;g=e.g;b=e.a;_=e.s;S=e.c;O=e.e;A=e.b;C=e.j},function(e){k=e.i},function(e){I=e.g}],execute:function(){var T=this;var P=e("g",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t;return __generator(this,(function(i){switch(i.label){case 0:if(!o.checkoutSessionId){return[2/*return*/,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",o.checkoutSessionId);return[4/*yield*/,h("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:r=i.sent(),n=r.errors,t=r.json;return[2/*return*/,{errors:n,json:t}]}}))}))}));var E=r((function(){return{amountToApply:null,appliedAmount:null,availableBalance:null,error:null,isApplying:false,isEnabled:false,orderIdCreated:null,remainingBalance:null,useFullBalance:true}})),N=E.reset,j=E.state;e("R",j);
2
+ /**
3
+ * Reset store credit store to initial state
4
+ */var D=e("S",(function(){N()}));
5
+ /**
6
+ * Set the available balance from the checkout session's customerProfile.storeCreditBalance
7
+ */var L=function(e){p("Store credit balance from session","info",e);j.availableBalance=e};
8
+ /**
9
+ * Re-fetch the store credit balance from the checkout session.
10
+ * Called when the payment step loads to ensure the balance is fresh.
11
+ */var x=e("a7",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,o,i;return __generator(this,(function(a){switch(a.label){case 0:return[4/*yield*/,P()];case 1:n=a.sent(),t=n.errors,o=n.json;if(t.length||!o){y("Failed to refresh store credit balance");return[2/*return*/]}i=(r=(e=o.checkoutSession.customerProfile)===null||e===void 0?void 0:e.storeCreditBalance)!==null&&r!==void 0?r:null;L(i);return[2/*return*/]}}))}))}));
12
+ /**
13
+ * Apply store credit to the checkout session.
14
+ * This must be called BEFORE payment confirmation.
15
+ * The amount/mode are already set via checkout session update with storeCreditApplication.
16
+ */var R=e("A",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,i,a,s,u,s;return __generator(this,(function(d){switch(d.label){case 0:r=o.checkoutSessionId;if(!r){n="No checkout session found";y(n);j.error=n;return[2/*return*/,{error:n,success:false}]}p("Applying store credit","info",{checkoutSessionId:r});j.isApplying=true;j.error=null;d.label=1;case 1:d.trys.push([1,3,,4]);return[4/*yield*/,h("/api/zonos-elements/store-credit/apply",{body:{checkoutSessionId:r},method:"POST"})];case 2:t=d.sent(),i=t.errors,a=t.json;if(i.length>0||!a){s=((e=i[0])===null||e===void 0?void 0:e.message)||"Failed to apply store credit";y(s);j.error=s;j.isApplying=false;return[2/*return*/,{error:s,success:false}]}j.appliedAmount=a.amountApplied;j.remainingBalance=a.remainingBalance;j.isApplying=false;p("Store credit applied","info",{amountApplied:a.amountApplied,remainingBalance:a.remainingBalance});return[2/*return*/,{error:null,success:true}];case 3:u=d.sent();s=u instanceof Error?u.message:"Failed to apply store credit";y(s);j.error=s;j.isApplying=false;return[2/*return*/,{error:s,success:false}];case 4:return[2/*return*/]}}))}))}));
17
+ /**
18
+ * Enable or disable store credit usage.
19
+ * When enabling, defaults to full balance mode.
20
+ * When disabling, clears the amount.
21
+ */var U=e("a3",(function(e){j.isEnabled=e;j.error=null;if(!e){j.amountToApply=null}}));
22
+ /**
23
+ * Set the amount of store credit to apply
24
+ * Validates against available balance and cart total
25
+ */var z=e("a6",(function(e){if(e===null){j.amountToApply=null;j.error=null;return}
26
+ // Validate amount
27
+ if(e<=0){j.error="Amount must be greater than zero";return}if(j.availableBalance!==null&&e>j.availableBalance){j.error="Amount exceeds available balance";return}var r=sr.total+(sr.storeCredit||0);if(e>r){j.error="Amount exceeds order total";return}j.error=null;j.amountToApply=e}));
28
+ /**
29
+ * Toggle whether to use full balance or custom amount.
30
+ * When switching to custom mode, clears the applied amount so the user
31
+ * must explicitly apply via the Apply button.
32
+ */var B=e("a4",(function(e){j.useFullBalance=e;j.error=null;if(e&&j.availableBalance!==null){var r=sr.total+(sr.storeCredit||0);var n=Math.min(j.availableBalance,r);j.amountToApply=n}else if(!e){j.amountToApply=null}}));
33
+ /**
34
+ * Get the storeCreditApplication input for checkout session update.
35
+ * Sends mode: 'NONE' when store credit is not being used to clear any
36
+ * previously applied store credit on the backend.
37
+ */var F=function(){if(!j.isEnabled||j.amountToApply===null){return{mode:"NONE"}}if(j.useFullBalance){return{mode:"FULL"}}return{amount:j.amountToApply,mode:"PARTIAL"}};
38
+ /**
39
+ * Get the effective amount to apply based on settings
40
+ */var q=e("K",(function(){if(!j.isEnabled||j.availableBalance===null){return 0}if(j.useFullBalance){return Math.min(j.availableBalance,sr.total+(sr.storeCredit||0))}return j.amountToApply||0}));
41
+ /**
42
+ * Check whether the effective store credit amount covers the full order total.
43
+ * When true, the Stripe/PayPal payment flow should be skipped and
44
+ * `storeCreditStoreCreateOrder` should be used instead.
45
+ *
46
+ * Relies on the backend's computed `cartStore.total` (remaining amount to pay
47
+ * after store credit) rather than a client-side comparison, which avoids issues
48
+ * with currency mismatches or rounding.
49
+ */var J=e("B",(function(){
50
+ // Only consider full coverage after the backend has confirmed store credit
51
+ // was applied (cartStore.storeCredit > 0) and the remaining total is 0.
52
+ return j.amountToApply!==null&&j.amountToApply>0&&sr.storeCredit>0&&sr.total<=0}));
53
+ /**
54
+ * Create an order paid entirely by store credit.
55
+ * Should only be called when `storeCreditStoreCoversFullAmount()` is true.
56
+ */var M=e("D",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,i,a,s,u,d,l,c,d;return __generator(this,(function(v){switch(v.label){case 0:t=o.checkoutSessionId;if(!t){i="No checkout session found";y(i);j.error=i;return[2/*return*/,{error:i,orderId:null,success:false}]}p("Creating store credit order","info",{checkoutSessionId:t});v.label=1;case 1:v.trys.push([1,3,,4]);return[4/*yield*/,h("/api/zonos-elements/store-credit/order-create",{body:{checkoutSessionId:t},method:"POST"})];case 2:a=v.sent(),s=a.errors,u=a.json;if(s.length>0||!u){d=((e=s[0])===null||e===void 0?void 0:e.message)||"Failed to create store credit order";y(d);j.error=d;return[2/*return*/,{error:d,orderId:null,success:false}]}l=((n=(r=u.checkoutSessionStoreCreditOrderCreate)===null||r===void 0?void 0:r.order)===null||n===void 0?void 0:n.id)||null;j.orderIdCreated=l;p("Store credit order created","info",{orderId:l});return[2/*return*/,{error:null,orderId:l,success:true}];case 3:c=v.sent();d=c instanceof Error?c.message:"Failed to create store credit order";y(d);j.error=d;return[2/*return*/,{error:d,orderId:null,success:false}];case 4:return[2/*return*/]}}))}))}));var W=["termsAndConditions","privacyPolicy","refundPolicy","shippingPolicy","warrantyPolicy"];
57
+ // Reuses the lowercase `'Privacy policy'` key already translated in 19 locales
58
+ // (also used by the checkout footer) — the other four are new keys that follow
59
+ // the same lowercase convention for visual consistency in the joined consent line.
60
+ var Y={privacyPolicy:"Privacy policy",refundPolicy:"Refund policy",shippingPolicy:"Shipping policy",termsAndConditions:"Terms and conditions",warrantyPolicy:"Warranty policy"};var H=r({accepted:false,acceptedAt:null,locked:false,showError:false}),K=H.reset,G=H.state;e({p:K,G:G});
61
+ /**
62
+ * Returns the list of policies the merchant has configured (non-empty link).
63
+ * Policies are returned in a fixed display order so the rendered list is
64
+ * deterministic across renders and across locales. URLs that aren't absolute
65
+ * http(s) URLs are filtered out as defense-in-depth against `javascript:` or
66
+ * other unexpected schemes slipping through the backend validation.
67
+ *
68
+ * Reads from `zonosStore.checkoutSettings` (not `window.Zonos.cartSettings`)
69
+ * so the consent UI works when zonos-elements is consumed via the npm package,
70
+ * where `cartSettings` is not populated.
71
+ */var V=e("a2",(function(){var e=n.checkoutSettings.merchantPolicyLinks;if(!e){return[]}return W.reduce((function(r,n){var t,o;var a=(o=(t=e[n])===null||t===void 0?void 0:t.link)===null||o===void 0?void 0:o.trim();if(!a||!/^https?:\/\//i.test(a)){return r}r.push({key:n,name:i(Y[n]),url:a});return r}),[])}));var Z=e("y",(function(){return V().length>0}));
72
+ /**
73
+ * Checks if the tax ID input should be rendered based on the company name and country code.
74
+ */var Q=function(e){var r=e.companyName,n=e.countryCode,t=e.shouldRequirePeruTaxId;if(l({countryCode:n,shouldRequirePeruTaxId:t})){return true}
75
+ // Only show the tax ID input if the country is in the EU and the company name is provided
76
+ if(v.includes(n)){return r.trim().length>0}
77
+ // If country require tax id, show the input
78
+ return f(n)};
79
+ /** Whether the field is showing, and which of this country's types is selected. */var X=e("V",(function(e){var r=e.companyName,n=e.countryCode,t=e.shouldRequirePeruTaxId,o=e.taxIdType;var i;var a=c({countryCode:n,shouldRequirePeruTaxId:t});var s=(i=a===null||a===void 0?void 0:a.find((function(e){return e.value===o})))!==null&&i!==void 0?i:null;var u=Q({companyName:r,countryCode:n,shouldRequirePeruTaxId:t});return{rendered:u,selectedType:s,
80
+ // A multi-type country sends a number only after the shopper picks a type.
81
+ send:u&&(!a||!!s),typeOptions:a}}));
82
+ /** Tax id to send for the destination, or null while the field is hidden. */var $=function(e){var r=X({companyName:_e.companyName,countryCode:e,shouldRequirePeruTaxId:t(),taxIdType:_e.taxIdType}),n=r.selectedType,o=r.send;if(!o){return null}return Object.assign({taxId:_e.taxId},n?{taxIdType:n.value}:{})};
83
+ /**
84
+ * Extract first name and last name from the name string
85
+ * If first name and last name are provided, use them
86
+ * If name is provided, extract and return the first and last name from the name string
87
+ * If neither are provided, return an empty object
88
+ */var ee=e("U",(function(e){var r=e.firstName,n=e.lastName,t=e.name;var o;if(!t&&!r&&!n){return{firstName:"",lastName:""}}
89
+ // Use first name and last name if they are provided
90
+ 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 re=function(e){var r=$(e);if(!r){return{}}return Object.assign({shipToTaxId:r.taxId},r.taxIdType?{shipToTaxIdType:r.taxIdType}:{})};
91
+ /**
92
+ * Extract value from translated object
93
+ */var ne=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,p=d.postal_code,m=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[p])||p,state:((u=n.state)===null||u===void 0?void 0:u[m])||m}};
94
+ /**
95
+ * Similar to prepCalculateLandedCost except it only uses cart ID
96
+ */var te=function(e){var r;var n=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";
97
+ // maybe we don't need email now for prefetch the landed cost
98
+ var t=_e.stripeLinkEventData;var i=_e.stripeAddressEventData;var s=_e.stripeShippingSameAsBilling?_e.stripeAddressEventData:_e.stripeBillingAddressEventData;if(!i||!s){throw new Error("Missing stripe address data")}
99
+ // Attempt to get translated address if available
100
+ var u=ne({currentAddress:i,translatedAddress:_e.translatedAddress.address});var d=ee({name:u.name}),l=d.firstName,c=d.lastName;var v=ne({currentAddress:s,translatedAddress:_e.translatedAddress.address});var f=ee({name:v.name}),p=f.firstName,m=f.lastName;var h=a()||"US";var y=re(u.country);return Object.assign(Object.assign({billingAddress:{addressLine1:v.line1,addressLine2:v.line2||"",city:v.city,country:v.country,postalCode:v.postal_code,state:v.state},billingContact:{
101
+ // firstName and lastName should be valid now since stripe only mark
102
+ // the address as complete when both fields are filled.
103
+ firstName:p,lastName:m,phone:v.phone},
104
+ // Use the first item's currency code
105
+ cartCurrencyCode:(r=sr.items[0])===null||r===void 0?void 0:r.currencyCode,cartId:e,checkoutSessionCountry:h,checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:_e.companyName,email:t===null||t===void 0?void 0:t.value.email,
106
+ // firstName and lastName should be valid now since stripe only mark
107
+ // the address as complete when both fields are filled.
108
+ firstName:l,lastName:c,phone:u.phone},isTest:!!n,landedCostAdjustments:sr.promoCode?[{amount:0,productId:null,promoCode:sr.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToShortAddressCode:_e.shortAddressCode},y),{shippingAddress:{addressLine1:u.line1,addressLine2:u.line2,city:u.city,country:u.country,postalCode:u.postal_code,state:u.state}})};var oe=function(){var e=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";
109
+ // maybe we don't need email now for prefetch the landed cost
110
+ var r=_e.stripeLinkEventData;var n=_e.stripeAddressEventData;var t=_e.stripeShippingSameAsBilling?_e.stripeAddressEventData:_e.stripeBillingAddressEventData;p({stripeAddressData:n,stripeBillingAddressData:t},"info");if(!n||!t){throw new Error("Missing stripe address data")}
111
+ // Attempt to get translated address if available
112
+ var i=ne({currentAddress:n,translatedAddress:_e.translatedAddress.address});var a=ee({name:i.name}),s=a.firstName,u=a.lastName;var d=ne({currentAddress:t,translatedAddress:_e.translatedAddress.address});var l=ee({name:d.name}),c=l.firstName,v=l.lastName;var f=sr.adjustments.map((function(e){return{amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}}));var m=sr.promoCode?__spreadArray([{amount:0,productId:null,promoCode:sr.promoCode,sku:null,type:"PROMO_CODE"}],f,true):f;var h=re(i.country);return Object.assign(Object.assign({billingAddress:{addressLine1:d.line1,addressLine2:d.line2||"",city:d.city,country:d.country,postalCode:d.postal_code,state:d.state},billingContact:{
113
+ // firstName and lastName should be valid now since stripe only mark
114
+ // the address as complete when both fields are filled.
115
+ firstName:c,lastName:v,phone:d.phone},checkoutSessionId:o.checkoutSessionId||"",contact:{companyName:_e.companyName,email:r===null||r===void 0?void 0:r.value.email,
116
+ // firstName and lastName should be valid now since stripe only mark
117
+ // the address as complete when both fields are filled.
118
+ firstName:s,lastName:u,phone:i.phone},isTest:e,items:sr.items,landedCostAdjustments:m,shipToShortAddressCode:_e.shortAddressCode},h),{shippingAddress:{addressLine1:i.line1,addressLine2:i.line2,city:i.city,country:i.country,postalCode:i.postal_code,state:i.state}})};var ie=function(e){return __awaiter(T,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l;return __generator(this,(function(c){switch(c.label){case 0:a=oe();return[4/*yield*/,e({billingAddress:a.billingAddress,billingContact:a.billingContact,checkoutSessionId:a.checkoutSessionId,contact:a.contact,landedCostAdjustments:a.landedCostAdjustments,
119
+ // zonosApiKey should always be available
120
+ publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:a.shippingAddress,zonosApiRoute:w["vercel"]},{promoCode:sr.promoCode})];case 1:s=c.sent();if(!s||
121
+ // Only show errors if there are no rate back (checkoutSessionWorkflow) and there are errors
122
+ !((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/*yield*/,h("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:u=c.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/*return*/,s]}}))}))};var ae=function(e){return __awaiter(T,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/*break*/,2];return[4/*yield*/,ie(t)];case 1:o=d.sent();return[2/*return*/,o];case 2:return[4/*yield*/,h("/api/zonos-elements/calculate-landed-cost",{body:oe(),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.")}
123
+ // We want to show any successful quotes even if there are errors
124
+ a.forEach((function(e){
125
+ // eslint-disable-next-line no-console
126
+ console.warn("Error calculating landed cost: ".concat(e.message))}));if(!s){throw new Error("Failed to calculate landed cost")}return[2/*return*/,s]}return[2/*return*/,s]}}))}))};var se=function(e){return __awaiter(T,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l;var c=e.abortController,v=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4/*yield*/,h("/api/zonos-elements/cart-calculate-landed-cost",{body:te(v),method:"POST",signal:c===null||c===void 0?void 0:c.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/*return*/,u]}}))}))};var ue=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 de=function(e){return __awaiter(T,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/*break*/,2];return[4/*yield*/,ae(e)];case 1:n=a.sent();return[2/*return*/,n];case 2:return[4/*yield*/,se({abortController:e,cartId:r})];case 3:t=a.sent(),o=t.cartWorkflow,i=ue(t,["cartWorkflow"]);return[2/*return*/,Object.assign(Object.assign({},i),{itemCreateWorkflow:o.items})]}}))}))};var le=e("t",(function(e){return __awaiter(T,[e],void 0,(function(e){var r,t,o,i,a,u,d,l,c;var v=e.checkoutSessionId,f=e.eventName,p=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:o=Date.now();i=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:v,eventCreated:o,eventName:f});a=
127
+ // if the url includes zonos.com and not hosted checkout (checkout.zonos.com), it means we are on the development site (dashboard, preview zonos domain or main zonos.com)
128
+ 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=g()||b();if((u||a)&&
129
+ // if found, it means we want to test the conversion event in development site, or test mode and staging mode
130
+ !window.Zonos.zonosConversionTest){return[2/*return*/]}d=s.selectedCountryCode;l=n.organizationId;if(!v){void _({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(f,'" - No checkout session id found')],metadata:{allLogs:m,checkoutSessionId:v,eventName:f,metadata:p,organizationId:l,trackEventLogs:i}});
131
+ // checkoutSessionId is required for tracking conversion events to work properly
132
+ return[2/*return*/]}if(!l){void _({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(f,'" - No organization id found')],metadata:{allLogs:m,checkoutSessionId:v,eventName:f,metadata:p,organizationId:l,trackEventLogs:i}})}c={checkoutSessionId:v,countryCode:d,eventCreated:o,eventName:f,metadata:Object.assign(Object.assign({},p),{trackEventLogs:i}),organizationId:l};return[4/*yield*/,h("/api/zonos-elements/track-conversion-event",{body:c,method:"POST"})];case 1:e.sent();return[2/*return*/]}}))}))}));
133
+ /**
134
+ * This function generates an object that contains the fields of an address that have invalid characters.
135
+ *
136
+ * @param {Object} params - The parameters for the function.
137
+ * @param {Address | null} params.address - The address to check for invalid characters.
138
+ * @param {ReturnType<typeof containsNonLatinChars> | null} params.invalidAdddressList - The list of address fields that contain invalid characters.
139
+ *
140
+ * @returns {Partial<Address> | undefined} - An object that contains the fields of the address that have invalid characters. If no fields have invalid characters, the function returns undefined.
141
+ */var ce=function(e){var r=e.address,n=e.invalidAdddressList;if(!r){return}
142
+ // if there are no invalid characters, return an empty object
143
+ 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}
144
+ // return null if there are no fields to exclude
145
+ return Object.keys(t).length?t:undefined};
146
+ /**
147
+ * This function builds the request body for validating an address. It checks if the address and billing address are ready and if they contain any invalid characters.
148
+ * If there are non-latin character to translate, returns an object with the address fields that have invalid characters, the destination country, and the first and last name.
149
+ * If the conditions are not met, it returns null.
150
+ *
151
+ * @param {Object} params - The parameters for the function.
152
+ * @param {ReturnType<typeof containsNonLatinChars> | null} params.addressInvalidCharactersList - The list of address fields that contain invalid characters.
153
+ * @param {ReturnType<typeof containsNonLatinChars> | null} params.billingAddressInvalidCharactersList - The list of billing address fields that contain invalid characters.
154
+ * @param {StripeAddressEventData} params.stripeAddressEventData - The Stripe event data for the address.
155
+ * @param {StripeAddressEventData} params.stripeBillingAddressEventData - The Stripe event data for the billing address.
156
+ * @param {boolean} params.stripeShippingSameAsBilling - A flag indicating whether the shipping address is the same as the billing address.
157
+ *
158
+ * @returns {ValidateAddressRequest | null} - An object that contains the address fields that have invalid characters, the destination country, and the first and last name. If the conditions are not met, the function returns null.
159
+ */var ve=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);
160
+ // only translate if both address and billing address are ready
161
+ if(!a||!s){return null}
162
+ // only translate if there are invalid characters
163
+ if(!r&&!n){return null}var u=t.value;var d=(o===null||o===void 0?void 0:o.value)||null;
164
+ // Returns undefined if the name is Latin so it won't be included in the request body
165
+ var l=ee({firstName:u.firstName,lastName:u.lastName,name:u.name}),c=l.firstName,v=l.lastName;var f="".concat(c," ").concat(v);var p=ee({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)||""}),m=p.firstName,h=p.lastName;var y=m&&h?"".concat(m," ").concat(h):"";var w=u.address;var g=d===null||d===void 0?void 0:d.address;return{address:ce({address:Object.assign(Object.assign({},w),{name:f}),invalidAdddressList:r}),
166
+ // only include billing address if it's different from the shipping address
167
+ billingAddress:!i?ce({address:g?Object.assign(Object.assign({},g),{name:y}):null,invalidAdddressList:n}):undefined,destinationCountry:w.country}};
168
+ /**
169
+ * Sorts service levels with lower cost first
170
+ */var fe=e("a0",(function(e){var r=e.sort((function(e,r){return e.amount-r.amount}));return r}));
171
+ /**
172
+ * Validate checkout session before confirming payment
173
+ */var pe=e("C",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,o,a;return __generator(this,(function(s){switch(s.label){case 0:return[4/*yield*/,P()];case 1:n=s.sent(),t=n.errors,o=n.json;if(t.length||!o){y("Failed to retrieve checkout session info before confirming payment ",t);void _({endpoint:"validateCheckoutSession",errors:t.map((function(e){return e.message})),metadata:{allLogs:m}});return[2/*return*/,{errorMessage:i("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:false}]}a=!!(((e=o.checkoutSession.order)===null||e===void 0?void 0:e.id)&&!o.checkoutSession.completedAt);if(!a&&!((r=o.checkoutSession.landedCost)===null||r===void 0?void 0:r.id)){y("Landed cost is not found in the checkout session before confirming payment.");void _({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:m}});return[2/*return*/,{errorMessage:i('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:false}]}return[2/*return*/,{errorMessage:"",valid:true}]}}))}))}));var me=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,
174
+ // need to reset everything and the paddingTop to default, otherwise the paddingTop will not be updated.
175
+ padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",
176
+ // any value here will be add up to the default paddingTop (20px).
177
+ 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 he=function(e){var r=e.borderStyle,n=e.theme;switch(n){case"DARK":return{borderRadius:I({overrideBorderStyle:r}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:I({overrideBorderStyle:r}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var ye={Airwallex:"AIRWALLEX",Paypal:"PAYPAL",Stripe:"STRIPE"};var we=r((function(){return{checkoutSettlementCurrency:"USD",clientSecret:S("session","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,
178
+ /**
179
+ * Default to skip payment intent, only create payment intent when "skipPaymentIntent" in url's query params is set "0"
180
+ * @default true
181
+ */
182
+ 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:"",taxIdType:"",taxIdTypeUsedWhenAsyncAddressUpdate:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}})),ge=we.onChange,be=we.reset,_e=we.state;e({J:ge,b:_e});var Se=function(e){var r=e.clientSecret,t=e.overrideBorderRadius,o=e.overridePrimaryColor,i=e.overrideSecondaryColor,a=e.overrideTheme,u=e.paypalEnabled;var d=o||n.appearance.colorPrimary;var l=i||n.appearance.colorSecondary;var c=window.Zonos.isCollect||window.Zonos.isInvoice?n.appearance.theme==="DARK":d&&k(d);var v=c?"night":"flat";
183
+ // if overrideTheme is provided, use it. Otherwise, use theme based on primary color
184
+ var f=a==="DARK"?"night":"flat";var p=u?["external_paypal"]:[];
185
+ // If client secret is Stripe format, use it
186
+ var m=(r===null||r===void 0?void 0:r.includes("_secret_"))?r:undefined;return{appearance:{labels:"floating",rules:Object.assign({},me({theme:a||"LIGHT"})),
187
+ // get contrast theme color base on primary color
188
+ theme:a?f:v,variables:Object.assign(Object.assign({},he({borderStyle:t,theme:"LIGHT"})),{
189
+ // use the button background color for input glow color
190
+ colorPrimary:l})},
191
+ // Client secret can be undefined since we will load other elements that doesn't require client secret first, then load client secret and render one that requires it later
192
+ clientSecret:m,customerSessionClientSecret:_e.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],p,true),locale:s.selectedLocale}};var Oe=e("u",(function(){A("session","zonos--bigcommerce-domestic-checkout-shipping")}));
193
+ // Save shipping address to session storage
194
+ var Ae=e("a",(function(e){O("session","zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))}));var Ce=e("s",(function(){var e=S("session","zonos--bigcommerce-domestic-checkout-shipping");return C(e)}));var ke=e("i",(function(e){return __awaiter(T,void 0,void 0,(function(){var r,n,t,o,i;return __generator(this,(function(a){t=_e.clientSecret;if(!_e.stripe){p("Skip. Stripe is not initialized");return[2/*return*/]}o=Se({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(_e.stripeElementsOptions);if(!_e.stripeElements||!_e.stripeElementsForBillingAddress){
195
+ // init stripe elements for billing address
196
+ _e.stripeElementsForBillingAddress=(r=_e.stripe)===null||r===void 0?void 0:r.elements(o);p("Stripe elements for billing address initialized");
197
+ // init stripe elements if it doesn't exist
198
+ _e.stripeElements=(n=_e.stripe)===null||n===void 0?void 0:n.elements(o);
199
+ // save stripe elements options for later comparison
200
+ _e.stripeElementsOptions=o;p("Stripe elements initialized");return[2/*return*/]}if(!i){
201
+ // update elements with new option if it already exists
202
+ _e.stripeElements.update(o);
203
+ // update elements for stripe billing address
204
+ _e.stripeElementsForBillingAddress.update(o);
205
+ // save stripe elements options for later comparison
206
+ _e.stripeElementsOptions=o;void _e.stripeElements.fetchUpdates()}p("Stripe elements updated");return[2/*return*/]}))}))}));var Ie=e("H",(function(){
207
+ // clean clientSecret so that we can start the new one.
208
+ A("session","zonos--client-secret");
209
+ // cleanup stripe elements
210
+ be();
211
+ // set stripe back to window.Zonos.stripe
212
+ _e.stripe=window.Zonos.stripe}));var Te=function(){var e,r,n,t;var o=JSON.stringify((e=_e.stripeAddressUsedWhenValidatingAddress)===null||e===void 0?void 0:e.value)!==JSON.stringify((r=_e.stripeAddressEventData)===null||r===void 0?void 0:r.value);var i=!_e.stripeShippingSameAsBilling&&JSON.stringify((n=_e.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value)!==JSON.stringify((t=_e.stripeBillingAddressUsedWhenValidatingAddress)===null||t===void 0?void 0:t.value);return o||i};var Pe=function(){var e,r,n,t,o,i,a,s;
213
+ /**
214
+ * If user updates the address after prefetching the landed cost, should always create and attach
215
+ * @caveat this will cause the scenario goes wrong after prefetching landed cost, with the current logic, it won't create party because nothing change after the prefetch happened
216
+ */var u=(e=sr.partiesData.find((function(e){return e.type==="DESTINATION"})))===null||e===void 0?void 0:e.id;var d=(r=sr.partiesData.find((function(e){return e.type==="PAYOR"})))===null||r===void 0?void 0:r.id;
217
+ // If haven't prefetched landed cost, there is no need to update address async
218
+ if(!u||!d){return false}
219
+ // If we don't have landed cost parties data, should way
220
+ if(_e.partyShippingId!==u||_e.partyBillingId!==d){return true}var l=JSON.stringify((n=_e.stripeLinkUsedWhenFetchingLC)===null||n===void 0?void 0:n.value)!==JSON.stringify((t=_e.stripeLinkEventData)===null||t===void 0?void 0:t.value);var c=JSON.stringify((o=_e.stripeAddressUsedWhenAsyncAddressUpdate)===null||o===void 0?void 0:o.value)!==JSON.stringify((i=_e.stripeAddressEventData)===null||i===void 0?void 0:i.value);var v=!_e.stripeShippingSameAsBilling&&JSON.stringify((a=_e.stripeBillingAddressUsedWhenAsyncAddressUpdate)===null||a===void 0?void 0:a.value)!==JSON.stringify((s=_e.stripeBillingAddressEventData)===null||s===void 0?void 0:s.value);var f=_e.taxIdUsedWhenAsyncAddressUpdate!==_e.taxId||_e.taxIdTypeUsedWhenAsyncAddressUpdate!==_e.taxIdType;var p=_e.companyNameUsedWhenAsyncAddressUpdate!==_e.companyName;return l||c||v||f||p};var Ee=e("a1",(function(e){var r=e.address,n=e.firstName,t=e.lastName,i=e.name,a=e.phone;var s=ee({firstName:n,lastName:t,name:i}),u=s.firstName,d=s.lastName;if(!u||!d){void _({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,firstName:n,lastName:t,name:i}})}if(!a){void _({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.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 Ne=e("Y",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,i,a,s,u,d,l,c,v,f,p;return __generator(this,(function(w){switch(w.label){case 0:if(!((e=_e.stripeAddressEventData)===null||e===void 0?void 0:e.complete)||!_e.stripeShippingSameAsBilling&&!((r=_e.stripeBillingAddressEventData)===null||r===void 0?void 0:r.complete)||!_e.stripeBillingAddressEventData){return[2/*return*/,{partiesCreated:false}]}
221
+ // If there is no landed cost data, no need to create parties
222
+ if(!sr.landedCostData){return[2/*return*/,{partiesCreated:false}]}a=(n=sr.landedCostData.find(Boolean))===null||n===void 0?void 0:n.landedCost.rootId;if(!a){
223
+ // do nothing if we don't have selected landed cost
224
+ void _({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId}});return[2/*return*/,{partiesCreated:false}]}s=Pe();if(!s){return[2/*return*/,{partiesCreated:false}]}u=Ee({address:_e.stripeAddressEventData.value.address,firstName:_e.stripeAddressEventData.value.firstName,lastName:_e.stripeAddressEventData.value.lastName,name:_e.stripeAddressEventData.value.name,phone:_e.stripeAddressEventData.value.phone});d=_e.stripeShippingSameAsBilling?u:Ee({address:_e.stripeBillingAddressEventData.value.address,firstName:_e.stripeBillingAddressEventData.value.firstName,lastName:_e.stripeBillingAddressEventData.value.lastName,name:_e.stripeBillingAddressEventData.value.name,phone:_e.stripeBillingAddressEventData.value.phone});l=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";c=$(u.country);return[4/*yield*/,h("/api/zonos-elements/create-parties",{body:Object.assign({address:u,billingAddress:d,companyName:_e.companyName,email:((t=_e.stripeLinkEventData)===null||t===void 0?void 0:t.value.email)||"",isTest:l,rootId:a,shortAddressCode:_e.shortAddressCode,taxId:(i=c===null||c===void 0?void 0:c.taxId)!==null&&i!==void 0?i:""},(c===null||c===void 0?void 0:c.taxIdType)?{taxIdType:c.taxIdType}:{}),method:"POST"})];case 1:v=w.sent(),f=v.errors,p=v.json;if(f.length||!p){y("Error occurs when creating parties",JSON.stringify(f,null,2));void _({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,errors:f,json:p}});return[2/*return*/,{partiesCreated:false}]}_e.companyNameUsedWhenAsyncAddressUpdate=_e.companyName;_e.stripeAddressUsedWhenAsyncAddressUpdate=_e.stripeAddressEventData;_e.stripeBillingAddressUsedWhenAsyncAddressUpdate=_e.stripeBillingAddressEventData;_e.taxIdTypeUsedWhenAsyncAddressUpdate=_e.taxIdType;_e.taxIdUsedWhenAsyncAddressUpdate=_e.taxId;_e.partyBillingId=p.billToPartyId;_e.partyShippingId=p.shipToPartyId;
225
+ // Update parties data with the new parties id
226
+ sr.partiesData=sr.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/*return*/,{partiesCreated:true}]}}))}))}));
227
+ /**
228
+ * Extract only the necessary address info for landed cost prefetch
229
+ */var je=function(e){return{countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}};var De=function(){var e,r;var n=JSON.stringify((e=_e.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((r=_e.stripeLinkEventData)===null||r===void 0?void 0:r.value);var t=_e.stripeAddressEventData&&JSON.stringify(je(_e.stripeAddressEventData.value))!==JSON.stringify(_e.stripeAddressUsedWhenFetchingLC);var o=!_e.stripeShippingSameAsBilling&&_e.stripeBillingAddressEventData&&JSON.stringify(je(_e.stripeBillingAddressEventData.value))!==JSON.stringify(_e.stripeBillingAddressUsedWhenFetchingLC);return n||t||o};
230
+ /**
231
+ * Check if the address and email info used when fetching landed cost with the current email and address info are different
232
+ * Purpose is to resend the request if the info used when fetching landed cost is different from the current info
233
+ */var Le=function(){var e;
234
+ // Mark the landed cost is outdated since the item total amount has changed (items total didn't match with the cart subtotal)
235
+ var r=sr.landedCostData&&((e=sr.landedCostData.find(Boolean))===null||e===void 0?void 0:e.subtotals.items)!==sr.subtotal;var n=De();p("isPrefetchInfoOutdated","info",{isAddressOutdated:n});
236
+ // if landed cost data is not available, we need to fetch it
237
+ return!sr.landedCostData&&!_e.isFetchingLandedCost||n||r};var xe=e("X",(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;
238
+ /**
239
+ * If the address form is using Stripe component, use Stripe country field label if there is one, if not just use one from our countryFieldLabel data
240
+ * stripeCountryFieldLabels is the list we collect from Stripe, and extract only country that state/zip is required and different from what we have in our countryFieldLabel data
241
+ **/if(sr.addressFormRenderType==="stripe"){return a||s}return s}));var Re=function(){var e,r,n,t;var o=!!((e=_e.stripeLinkEventData)===null||e===void 0?void 0:e.complete);var i=!!((r=_e.stripeAddressEventData)===null||r===void 0?void 0:r.complete);var a=_e.stripeShippingSameAsBilling?i:!!((n=_e.stripeBillingAddressEventData)===null||n===void 0?void 0:n.complete);var s=((t=_e.stripeAddressEventData)===null||t===void 0?void 0:t.value.address.country)||"US";var u=xe(s);if(i&&a&&o){return true}
242
+ // Only send landed cost request if the address is complete when we can't get the country field
243
+ if(!u||!_e.stripeAddressEventData){return i&&a&&o}var d=_e.stripeAddressEventData.value.address.line1.length>0;var l=_e.stripeAddressEventData.value.firstName&&_e.stripeAddressEventData.value.lastName;var c=!u.stateRequired||u.stateRequired&&_e.stripeAddressEventData.value.address.state.length>0;var v=!u.zipRequired||u.zipRequired&&_e.stripeAddressEventData.value.address.postal_code.length>=3;var f=_e.stripeAddressEventData.value.phone&&_e.stripeAddressEventData.value.phone.length>0;return o&&l&&d&&c&&v&&f};var Ue=function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,i,a,s,u,d,l,c;return __generator(this,(function(v){switch(v.label){case 0:r=new AbortController;_e.fetchingLandedCostAbortController=r;
244
+ // Reset cart items to non-restricted state and restricted item list
245
+ Cr();return[4/*yield*/,de(r)];case 1:n=v.sent(),t=n.checkoutSessionWorkflow,i=n.errors,a=n.itemCreateWorkflow,s=n.landedCostCalculateWorkflow,u=n.partyCreateWorkflow,d=n.shipmentRatingCalculateWorkflow;
246
+ // Surface a custom "no quote" message when either a rule (ruleMessageType CUSTOM) or a country
247
+ // constraint (source COUNTRY_CONSTRAINT) blocked shipment rating with an authored message.
248
+ sr.customQuotingError=((e=i===null||i===void 0?void 0:i.find((function(e){var r,n;return((r=e.extensions)===null||r===void 0?void 0:r.ruleMessageType)==="CUSTOM"||((n=e.extensions)===null||n===void 0?void 0:n.source)==="COUNTRY_CONSTRAINT"})))===null||e===void 0?void 0:e.message)||null;sr.shippingData=fe((d===null||d===void 0?void 0:d.filter(Boolean))||[]);
249
+ // check and update cart items with restrictions
250
+ cr(a);
251
+ // reset abort controller after we are done
252
+ _e.fetchingLandedCostAbortController=null;sr.partiesData=(u===null||u===void 0?void 0:u.filter(Boolean))||[];
253
+ // update cart store with landed cost info
254
+ sr.landedCostData=(t===null||t===void 0?void 0:t.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=o.checkoutSessionId;if(t===null||t===void 0?void 0:t.length){void le({checkoutSessionId:l,eventName:"checkout_quoteReceived"})}c=sr.promoCodeApplied&&!sr.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"}))}));sr.promoCodeError=c;
255
+ // When promocode is valid, set promoCode to session storage so if user close the modal, we can still reapply for them
256
+ if(!c){O("session","zonos--promo-code",sr.promoCode)}return[2/*return*/]}}))}))};var ze=e("w",(function(e){return __awaiter(T,void 0,void 0,(function(){var r,n,t,o,i,a,s,u,d,l,c,v,f,p;return __generator(this,(function(m){switch(m.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=Le();u=Re();
257
+ // Should not do anything if the address is not ready to request landed cost
258
+ if(!u){return[2/*return*/,{isRequestNotReady:true}]}if(s){
259
+ // if the info used when fetching landed cost is different from the current info, abort the previous request
260
+ (r=_e.fetchingLandedCostAbortController)===null||r===void 0?void 0:r.abort();_e.fetchingLandedCostAbortController=null}
261
+ // Do not fetch if we are not ready or data is not outdated
262
+ if(!s&&!a){return[2/*return*/,{isRequestNotReady:false}]}
263
+ // If there is retries, stop loading for a moment and then showing the spinner again (this is just so customer can see that checkout is doing something and not stuck)
264
+ if(i){_e.isFetchingLandedCost=false;setTimeout((function(){_e.isFetchingLandedCost=true}),300)}else{_e.isFetchingLandedCost=true}if(_e.stripeAddressEventData){_e.stripeAddressUsedWhenFetchingLC={countryCode:_e.stripeAddressEventData.value.address.country,postalCode:_e.stripeAddressEventData.value.address.postal_code,state:_e.stripeAddressEventData.value.address.state}}if(_e.stripeBillingAddressEventData){_e.stripeBillingAddressUsedWhenFetchingLC={countryCode:_e.stripeBillingAddressEventData.value.address.country,postalCode:_e.stripeBillingAddressEventData.value.address.postal_code,state:_e.stripeBillingAddressEventData.value.address.state}}if(_e.stripeLinkEventData){_e.stripeLinkUsedWhenFetchingLC=Object.assign({},_e.stripeLinkEventData)}m.label=1;case 1:m.trys.push([1,3,,7]);
265
+ // Reset cart items to non-restricted state and restricted item list
266
+ Cr();
267
+ // fetch and apply landed cost
268
+ return[4/*yield*/,Ue()];case 2:
269
+ // fetch and apply landed cost
270
+ m.sent();d=(n=sr.shippingData)===null||n===void 0?void 0:n.find(Boolean);l=(t=sr.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){
271
+ // prefetch landed cost will not update shipping and taxes since we haven't selected shipping method yet
272
+ mr({method:(l===null||l===void 0?void 0:l.landedCost.method)||"DDP",subtotals:c})}return[3/*break*/,7];case 3:v=m.sent();
273
+ // default to empty array if we failed to fetch landed cost, so we can show the error message
274
+ sr.landedCostData=[];sr.shippingData=[];f=["The landed cost calculation request was aborted to initiate a new one."];if(!(v instanceof Error&&v.message&&!f.includes(v.message)))return[3/*break*/,6];if(!(i<1))return[3/*break*/,5];
275
+ // retry fetching landed cost one more time
276
+ return[4/*yield*/,ze(Object.assign(Object.assign({},e),{retries:(i||0)+1}))];case 4:
277
+ // retry fetching landed cost one more time
278
+ m.sent();return[2/*return*/,{isRequestNotReady:false}];case 5:p=(o=_e.stripeAddressEventData)===null||o===void 0?void 0:o.value;void _({endpoint:"Failed to fetch landed cost (".concat(i," retries)"),errors:[v.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:p}});m.label=6;case 6:y(v);return[3/*break*/,7];case 7:_e.isFetchingLandedCost=false;return[2/*return*/,{isRequestNotReady:false}]}}))}))}));var Be=e("N",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t;return __generator(this,(function(o){switch(o.label){case 0:return[4/*yield*/,ze({applyingPromocode:true})];case 1:o.sent();
279
+ // Go back to shipping step if we are in payment step so user can reselect shipping method
280
+ if(sr.step==="payment"){Tr()}
281
+ // async update address with new root id from the new quote
282
+ return[4/*yield*/,Ne()];case 2:
283
+ // async update address with new root id from the new quote
284
+ o.sent();n=(e=sr.shippingData)===null||e===void 0?void 0:e.find(Boolean);t=(r=sr.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*/]}return[4/*yield*/,_r({applySubtotalsOnly:false,landedCostId:t.landedCostId,selectedShippingOption:n})];case 3:o.sent();return[2/*return*/]}}))}))}));var Fe=e("P",(function(){sr.promoCode="";A("session","zonos--promo-code");
285
+ // reset promocode error state
286
+ sr.promoCodeError=false;sr.promoCodeApplied=false}));var qe=e("O",(function(){return __awaiter(T,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:
287
+ // Go back to shipping step if we are in payment step so user can reselect shipping method
288
+ if(sr.step==="payment"){Tr()}Fe();return[4/*yield*/,Be()];case 1:e.sent();return[2/*return*/]}}))}))}));var Je=e("Q",(function(e){var r=[];var n=true;var t=window.Zonos.isCollect;var o=window.Zonos.isInvoice;
289
+ // Inspect the PaymentIntent `status` to indicate the status of the payment
290
+ // to your customer.
291
+
292
+ // Some payment methods will [immediately succeed or fail][0] upon
293
+ // confirmation, while others will first enter a `processing` state.
294
+
295
+ // [0]: https://stripe.com/docs/payments/payment-methods#payment-notification
296
+ switch(e){case"succeeded":{r=[i("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."),"",i("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=[i("Thank you for submitting your payment. We appreciate your prompt attention."),"",i("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=[i("Payment processing. We'll update you when payment is received.")];n=false;break}case"requires_payment_method":{r=[i("Payment failed. Please try another payment method.")];if(t){r=[i("Payment failed. Please reload the page and try another payment method.")]}break}case"requires_action":{n=false;r=[i("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}default:{r=[i("Something went wrong.")];break}}return{isError:n,messages:r}}));
297
+ /**
298
+ * Handle inventory check and returns error message if the callback provided.
299
+ */var Me=e("n",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,t,o,a,s,u,d,l,d;return __generator(this,(function(c){switch(c.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/*break*/,2];return[4/*yield*/,h("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:a=c.sent(),s=a.errors,u=a.json;if(s.length||!u){y("Error occurs when handling inventory refund","warn",JSON.stringify(s));return[2/*return*/,null]}
300
+ // Proceed if the item is available
301
+ if(!u.available||u.status===204){return[2/*return*/,i("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){_e.shouldInventoryRefund=true;return[2/*return*/,null]}return[2/*return*/,null];case 2:if(typeof t!=="function"){return[2/*return*/,null]}c.label=3;case 3:c.trys.push([3,5,,6]);return[4/*yield*/,t({items:sr.items},{translate:i,zonosApiRoute:w["vercel"]})];case 4:d=c.sent();return[2/*return*/,d];case 5:l=c.sent();d=l instanceof Error?l.message:"Unknown error";void _({endpoint:"onInventoryCheck",errors:["cartId: ".concat(window.Zonos.cartId," - ").concat(d)],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:sr.items}});throw l;case 6:return[2/*return*/]}}))}))}));
302
+ /**
303
+ * Handle inventory check and returns error message if the callback provided.
304
+ */var We=e("F",(function(){return __awaiter(T,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);
305
+ // inventory refund is only available for legacy checkout and store has referenceId in metadata
306
+ if(!window.Zonos.isLegacyCheckout||!window.Zonos.cartData||!n){return[2/*return*/]}
307
+ // handle inventory check on legacy checkout
308
+ return[4/*yield*/,h("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:
309
+ // handle inventory check on legacy checkout
310
+ t.sent();return[2/*return*/]}}))}))}));var Ye=e("c",(function(e){return __awaiter(T,[e],void 0,(function(e){var r,n,t,o,a,s,u,d,l;var c=e.clientSecret,v=e.storybookForceStatus;return __generator(this,(function(e){switch(e.label){case 0:if(v){r=Je(v),n=r.isError,t=r.messages;return[2/*return*/,{error:n,messages:t}]}o=c||_e.clientSecret;if(!_e.stripe||!o){y("Failed to retrieve payment intent. Stripe is not initialized");return[2/*return*/,{error:true,message:[i("Something went wrong.")]}]}
311
+ // A client secret that isn't a Stripe payment intent secret (e.g. an Airwallex
312
+ // secret) can't be evaluated by Stripe. Do not treat it as a successful Stripe
313
+ // payment — return an error so callers don't run success analytics / order
314
+ // polling off a secret Stripe never confirmed.
315
+ if(!o.includes("_secret_")){return[2/*return*/,{error:true,messages:[i("Something went wrong.")]}]}return[4/*yield*/,_e.stripe.retrievePaymentIntent(o)];case 1:a=e.sent().paymentIntent;s=a===null||a===void 0?void 0:a.status;u=Je(s),d=u.isError,l=u.messages;return[2/*return*/,{amount:a===null||a===void 0?void 0:a.amount,currency:a===null||a===void 0?void 0:a.currency,error:d,messages:l,paymentIntentId:a===null||a===void 0?void 0:a.id,paymentMethod:a===null||a===void 0?void 0:a.payment_method,status:s}]}}))}))}));var He=e("E",(function(e){return __awaiter(T,void 0,void 0,(function(){var r,n,t,a,s,u,d,l,c,v,f,m;return __generator(this,(function(h){switch(h.label){case 0:t=!!((r=_e.stripePaymentEventData)===null||r===void 0?void 0:r.complete);a=_e.stripeElements;s=_e.stripe;u=_e.clientSecret;_e.customErrorMessage=null;if(!((n=sr.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/*yield*/,pe()];case 1:d=h.sent();if(!d.valid){_e.customErrorMessage=d.errorMessage;throw new Error(d.errorMessage)}l=o.checkoutSessionId;if(!(s&&a&&t&&u&&l))return[3/*break*/,3];c=new URL(window.location.href);c.searchParams.set("payment_intent_client_secret",u);c.searchParams.set("zonosCheckoutSessionId",l);void le({checkoutSessionId:l,eventName:"checkout_paymentInfoCompleted"});return[4/*yield*/,s.confirmPayment({confirmParams:{return_url:c.toString()},elements:a,redirect:"if_required"})];case 2:v=h.sent(),f=v.error,m=v.paymentIntent;p("Payment intent confirmed","info",{error:f,paymentIntent:m});if((m===null||m===void 0?void 0:m.status)==="requires_action"){throw new Error(i("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."))}if(f){if(f.type==="card_error"||f.type==="validation_error"){throw new Error(f.message)}if(f.type==="invalid_request_error"){if(f.code==="payment_intent_unexpected_state"){
316
+ // PaymentIntent was canceled or expired, or status is `require_capture`.
317
+ // don't throw error here because we will reset the checkout session last step
318
+ return[2/*return*/]}}throw new Error("An unexpected error occurred.")}if(m.status==="requires_payment_method"){
319
+ // Failed to confirm payment, allows user to try another payment method
320
+ throw new Error(i("Payment failed. Please try another payment method."))}h.label=3;case 3:return[2/*return*/]}}))}))}));
321
+ /**
322
+ * Builds the single `merchantPolicyConsent` metadata entry that records the buyer's
323
+ * acceptance of the merchant policies (Terms and Conditions, Privacy Policy, etc.).
324
+ * Returns null when consent has not been accepted or when no policies are configured.
325
+ *
326
+ * The recorded value captures which policies were shown, the URLs the buyer
327
+ * agreed to, the active locale, and the snapshotted acceptance timestamp.
328
+ */var Ke=function(){if(!G.accepted){return null}var e=V();if(!e.length){return null}return{key:"merchantPolicyConsent",value:JSON.stringify({
329
+ // Use the timestamp snapshotted when the buyer first accepted, so any
330
+ // later session-metadata update keeps the original moment of consent
331
+ // for audit purposes. Fall back to "now" as a safety net for the
332
+ // unlikely case the store value was cleared between accept and write.
333
+ acceptedAt:G.acceptedAt||(new Date).toISOString(),locale:s.selectedLocale,policies:e.reduce((function(e,r){e[r.key]=r.url;return e}),{})})}};
334
+ /**
335
+ * Allow overriding the checkout session payment processor via a `paymentProcessor`
336
+ * URL query param (e.g. `?paymentProcessor=AIRWALLEX`). The processor is normally
337
+ * determined server-side by the billing company; this override is primarily used
338
+ * for testing. Returns `undefined` when the param is missing or not a valid
339
+ * processor.
340
+ */var Ge=function(){var e=new URLSearchParams(window.location.search).get("paymentProcessor");var r=function(e){return Object.values(ye).some((function(r){return r===e}))};return e&&r(e)?e:undefined};var Ve=e("q",(function(){var e;var r=sr.items.reduce((function(e,r){return e+r.amount*r.quantity}),0);var n=o.enabledVariantTestKeys||[];var t={adjustmentsAmount:sr.adjustments.reduce((function(e,r){return e+r.amount}),0),cartId:window.Zonos.cartId,currency:((e=sr.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",customerAuthenticationToken:sr.customerAuthenticationToken||undefined,isCollect:!!window.Zonos.isCollect,isInvoice:!!window.Zonos.isInvoice,itemsAmount:r,metadata:[{key:"language",value:s.selectedLocale}],paymentProcessor:Ge(),presentmentCountryCode:s.selectedCountryCode,skipPaymentIntent:_e.skipPaymentIntent,varianceTestInput:n};return t}));var Ze=e("l",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,a;return __generator(this,(function(s){switch(s.label){case 0:if(!o.checkoutSessionId){
341
+ // We want to log the error anytime we fail to create a checkout session
342
+ void _({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:m,cartId:window.Zonos.cartId}});pr({messages:[i("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:i("Error creating Checkout")});return[2/*return*/]}return[4/*yield*/,h("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:o.checkoutSessionId},method:"POST"})];case 1:r=s.sent(),n=r.errors,t=r.json;a=(e=t===null||t===void 0?void 0:t.checkoutSessionPaymentIntentCreate)===null||e===void 0?void 0:e.clientSecret;if(n.length||!a){y("Error occurs when getting payment intent",JSON.stringify(n,null,2));
343
+ // We want to log the error anytime we fail to create a payment intent
344
+ void _({endpoint:"Error creating payment intent",errors:n.map((function(e){return e.message})),metadata:{allLogs:m,cartId:window.Zonos.cartId,checkoutSessionId:o.checkoutSessionId,clientSecret:a}});pr({messages:[i("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:i("Error creating Checkout")});return[2/*return*/]}
345
+ // update cart store checkout session with updated from checkout session payment intent creation call so the checkout session and payment intent are in sync
346
+ wr(t.checkoutSessionPaymentIntentCreate);return[2/*return*/]}}))}))}));
347
+ /**
348
+ * Init checkout session
349
+ * @returns {boolean} whether or not the checkout session is successfully created
350
+ */var Qe=e("k",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,o,i,a,u;return __generator(this,(function(d){switch(d.label){case 0:if(!s.targetCurrency){y("Failed to create checkout session - missing localizationStore.targetCurrency");return[2/*return*/,false]}_e.isFetchingSession=true;n=Ve();p("Checkout session body","info",n);return[4/*yield*/,h("/api/zonos-elements/create-checkout-session",{body:n,method:"POST"})];case 1:t=d.sent(),o=t.errors,i=t.json;_e.isFetchingSession=false;if(o.length||!i){a=(e=o.find((function(e){return e.message})))===null||e===void 0?void 0:e.message;
351
+ // check if the error is related to expired cart and thow error so we can show error message accordingly
352
+ if(Array.isArray(a)&&a.some((function(e){return e.message==="Cart is expired."}))){throw new Error("Cart is expired.")}y("Error occurred when creating checkout session",JSON.stringify(o,null,2));return[2/*return*/,false]}u=i.checkoutSessionCreate;
353
+ // update cart store with updated information
354
+ wr(u);mr({method:((r=u.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:u.subtotals});p("Exchange rate updated for cart items (checkout session create)","info",sr.exchangeRate);p("done-init-checkout-session");return[2/*return*/,true]}}))}))}));var Xe=e("z",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r,t;return __generator(this,(function(i){switch(i.label){case 0:e=o.checkoutSessionId;
355
+ // Checkout session id should be available at this point
356
+ if(!e){y("Failed to update checkout session base currency");return[2/*return*/,false]}
357
+ // Only update checkout session currency if setting is enabled
358
+ if(n.checkoutSettings.allowedSettlementCurrencies==="LOCAL"){p('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency');return[2/*return*/,true]}return[4/*yield*/,h("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:_e.checkoutSettlementCurrency},method:"POST"})];case 1:r=i.sent().json;t=r===null||r===void 0?void 0:r.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;
359
+ // S
360
+ if(!r||t!==_e.checkoutSettlementCurrency){y("Failed to update checkout session base currency");return[2/*return*/,false]}p('Updated checkout session to settlement currency "'.concat(t,'".'));return[2/*return*/,true]}}))}))}));
361
+ /**
362
+ * Update checkout session. Use for updating amount with landed cost id, or update session when cart items change
363
+ */var $e=function(e){return __awaiter(T,[e],void 0,(function(e){var r,n,t,i;var a=e.adjustmentsAmount,u=e.cartId,d=e.currency,l=e.id,c=e.itemsAmount,v=e.landedCostId,f=e.presentmentCountryCode,p=e.storeCreditApplication;return __generator(this,(function(e){switch(e.label){case 0:r=o.enabledVariantTestKeys||[];return[4/*yield*/,h("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:a,billToPartyId:_e.partyBillingId,cartId:u,currency:d,customerAuthenticationToken:sr.customerAuthenticationToken||undefined,id:l,itemsAmount:c,landedCostId:v,metadata:[{key:"language",value:s.selectedLocale}],presentmentCountryCode:f,shipToPartyId:_e.partyShippingId,skipPaymentIntent:_e.skipPaymentIntent,storeCreditApplication:p,varianceTestInput:r},method:"POST"})];case 1:n=e.sent(),t=n.errors,i=n.json;if(t.length||!i){y("Error occurs when updating checkout session",JSON.stringify(t,null,2));return[2/*return*/,{errors:t,json:i}]}return[2/*return*/,{errors:[],json:i}]}}))}))};
364
+ /**
365
+ * Pushes the buyer's policy consent into the checkout session's metadata via the
366
+ * dedicated metadata-only mutation. Called from the payment continue handler so
367
+ * consent is persisted to the session before Stripe's confirmPayment fires.
368
+ *
369
+ * Uses `checkoutSessionUpdateMetadata` — not the full `checkoutSessionUpdate` —
370
+ * because this fires at the end of the payment phase, when we don't want to
371
+ * touch landed-cost / cart / party state. No-op when no policies are configured,
372
+ * when consent hasn't been accepted, or when there is no active session ID.
373
+ */var er=e("T",(function(){return __awaiter(T,void 0,void 0,(function(){var e,r;return __generator(this,(function(n){switch(n.label){case 0:e=Ke();if(!e){return[2/*return*/,{errors:[]}]}if(!o.checkoutSessionId){return[2/*return*/,{errors:[]}]}return[4/*yield*/,h("/api/zonos-elements/update-checkout-session-metadata",{body:{id:o.checkoutSessionId,metadata:[e]},method:"POST"})];case 1:r=n.sent().errors;if(r.length){
374
+ // Surface failures loudly so we have observability on consent records that
375
+ // didn't persist — callers don't block payment, but the failure is logged.
376
+ y("Failed to record merchant policy consent on checkout session",JSON.stringify(r,null,2));return[2/*return*/,{errors:r.map((function(e){return e.message||"Unknown error"}))}]}return[2/*return*/,{errors:[]}]}}))}))}));
377
+ /**
378
+ * This function builds a translated address object from the current address and the translated address result.
379
+ * It checks each field in the current address and if it exists in the translated address result, it adds it to the translated address object.
380
+ * The key of each field in the translated address object is the current address's field value and the value is the corresponding translated address's field value.
381
+ *
382
+ * @param {Object} params - The parameters for the function.
383
+ * @param {Address} params.currentAddress - The current address information.
384
+ * @param {Address} params.translatedAddressResult - The translated address result.
385
+ *
386
+ * @returns {TranslatedAddress} - An object containing the translated address. Each field is an object with the current address's field value as the key and the translated address's field value as the value.
387
+ */var rr=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,p=u.postal_code,m=u.state;
388
+ // If we have translated address, add it to the translated address object
389
+ 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&&p){d.postal_code=(o={},o[s.postal_code]=p,o)}if(s.state&&m){d.state=(i={},i[s.state]=m,i)}if(s.name&&f){d.name=(a={},a[s.name]=f,a)}return d};
390
+ /**
391
+ * This function translates an address to Latin characters using the Zonos API.
392
+ * It first builds the request body for the API call. If there's no request body, it resets the translated address in the store and returns.
393
+ * If the address is not outdated, it returns without making the API call.
394
+ * It then makes a POST request to the Zonos API to validate and translate the address. If the API call fails, it resets the translated address in the store and returns.
395
+ * If the API call is successful, it sets the current address and billing address in the store and builds the translated address and billing address from the API response.
396
+ *
397
+ * @param {Object} params - The parameters for the function.
398
+ * @param {ReturnType<typeof containsNonLatinChars> | null} params.addressInvalidCharactersList - The list of address fields that contain invalid characters.
399
+ * @param {ReturnType<typeof containsNonLatinChars> | null} params.billingAddressInvalidCharactersList - The list of billing address fields that contain invalid characters.
400
+ */var nr=e("W",(function(e){return __awaiter(T,[e],void 0,(function(e){var r,n,t,o,i,a,s,u,d,l,c;var v=e.addressInvalidCharactersList,f=e.billingAddressInvalidCharactersList;return __generator(this,(function(e){switch(e.label){case 0:i=ve({addressInvalidCharactersList:v,billingAddressInvalidCharactersList:f,stripeAddressEventData:_e.stripeAddressEventData,stripeBillingAddressEventData:_e.stripeBillingAddressEventData,stripeShippingSameAsBilling:_e.stripeShippingSameAsBilling});if(!i){
401
+ // reset translated address if we don't have any address to translate
402
+ _e.translatedAddress={address:{},billingAddress:{}};return[2/*return*/]}a=Te();if(!a){return[2/*return*/]}return[4/*yield*/,h("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),u=s.errors,d=s.json;if(u.length||!d){y("Error occurs when translating address to latin",JSON.stringify(u,null,2));
403
+ // reset translated address if we Failed to translate and let user manually fix it
404
+ _e.translatedAddress={address:{},billingAddress:{}};return[2/*return*/]}
405
+ // Set current address to the store so we can compare it later to determine if we need to re-translate the address
406
+ _e.stripeAddressUsedWhenValidatingAddress=_e.stripeAddressEventData;_e.stripeBillingAddressUsedWhenValidatingAddress=_e.stripeBillingAddressEventData;l=(r=_e.stripeAddressEventData)===null||r===void 0?void 0:r.value.address;c=(n=_e.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value.address;
407
+ // Set the translated address to the store so we can populate it to the address element for user to update
408
+ _e.translatedAddress={address:l?rr({currentAddress:Object.assign(Object.assign({},l),{name:(t=_e.stripeAddressEventData)===null||t===void 0?void 0:t.value.name}),translatedAddressResult:d.address||null}):{},billingAddress:!_e.stripeShippingSameAsBilling?rr({currentAddress:Object.assign(Object.assign({},c),{name:(o=_e.stripeBillingAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:d.billingAddress||null}):{}};return[2/*return*/]}}))}))}));ge("clientSecret",(function(e){
409
+ // update stripe elements when client secret changes
410
+ if(e&&_e.stripe){O("session","zonos--client-secret",e)}if(!e){A("session","zonos--client-secret")}}));
411
+ /**
412
+ * EU 3-EUR cutover (05CHECK-893): when shipping to an EU country with a POSTAL
413
+ * service level whose DAP landed cost has remittance available, we keep treating
414
+ * the quote as DAP (duties paid upon delivery) instead of converting it to DDP.
415
+ * The cart subtotals then show taxes and fees as collected while duties are
416
+ * estimated and paid on delivery.
417
+ *
418
+ * @see [[cartStoreGetMethod]] for the DAP/DDP conversion this guards.
419
+ */var tr=e("M",(function(e){var r=e.deliveryType,n=e.landedCost,t=e.shipToCountry;return n.method==="DAP"&&r==="POSTAL"&&n.remittance.length>0&&!!t&&v.includes(t)}));var or=r((function(){return{addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:false,checkoutTimeoutInterval:null,currency:"USD",customMessage:[],customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:false,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,isStagingMode:b(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:S("session","zonos--promo-code")||"",
420
+ // When user clicked applied button, save promocode into session storage for later use. So if session has promocode, applied button is clicked
421
+ promoCodeApplied:!!S("session","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"},
422
+ // eslint-disable-next-line sort-keys/sort-keys-fix
423
+ payment:{index:3,isDone:false,label:"Payment",value:"payment"}},total:0}})),ir=or.onChange,ar=or.reset,sr=or.state;e({I:ir,d:sr});var ur=function(e){switch(e){case"DAYS":return i("days");case"WEEKS":return i("weeks");case"BUSINESS_DAYS":default:return i("business days")}};
424
+ /**
425
+ * Format shipping transit info to be displayed on UI
426
+ * @returns
427
+ * - expectedDate: Thursday, Aug 12
428
+ * - maxTransit: 5
429
+ * - minTransit: 3
430
+ */var dr=e("_",(function(e){var r;var n=(r=e.shippingProfile)===null||r===void 0?void 0:r.transitTime;
431
+ // Don't care about falsy 0 values because this is international shipping and 0 days is not feasible
432
+ 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:ur(n.type)}}));var lr=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};
433
+ /**
434
+ * Check and set restricted items in cart
435
+ */var cr=function(e){p("Checking item restrictions");var r=e.map((function(e){if(!e.restriction){return null}var r=e.restriction;var n=sr.items.find((function(r){return lr({item1:r,item2:e})}));return Object.assign(Object.assign({matchedItem:n},e),{restriction:r})})).filter(Boolean);sr.restrictedItems=r;
436
+ // remove items that are restricted from cart
437
+ sr.items=sr.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:!!r.find((function(r){return lr({item1:r,item2:e})}))})}));return{cartItems:sr.items,restrictedItems:r}};var vr=null;var fr=e("f",(function(){o.checkoutSessionId=null;
438
+ // clear pending store credit debounce timer
439
+ if(vr){clearTimeout(vr);vr=null}
440
+ // reset store credit store
441
+ D();
442
+ // reset cart store
443
+ ar()}));var pr=e("r",(function(e){var r=e.messages,n=e.title;fr();Ie();sr.step="error";sr.error={messages:r,title:n}}));var mr=function(e){var r=e.dutiesTaxesFeesEstimate,n=e.method,t=e.subtotals;var o;
444
+ // update exchange rate so we can use it to display cart items
445
+ sr.exchangeRate=t.exchangeRate;sr.adjustmentTotal=t.adjustments;sr.dutiesTaxesFees=n==="DAP"?null:t.landedCostTotal;sr.storeCredit=(o=t.storeCredit)!==null&&o!==void 0?o:0;sr.subtotal=t.items;sr.total=t.total;sr.currency=t.presentmentCurrencyCode;sr.dutiesTaxesFeesEstimate=r||null};
446
+ /**
447
+ * Detect if there are any items in cart that are not restricted and have positive amount, exclude negative amount items
448
+ */var hr=e("L",(function(){
449
+ // filter all items with positive amount
450
+ var e=sr.items.filter((function(e){return e.amount>0}));
451
+ // only check restricted status for items with positive amount
452
+ // if there is no item restricted found => all items are restricted
453
+ return!!e.find((function(e){return!e.isRestricted}))}));
454
+ /**
455
+ * An order-modification payment-only session (skip-to-payment, no shipping
456
+ * step): a session tied to an order that hasn't completed yet, meaning the
457
+ * shopper is only paying a delta against an already-approved landed cost.
458
+ * Single source of truth for this detection — previously duplicated inline
459
+ * at each call site, which let one of them (the forceDialogOpen/preview init
460
+ * path) miss it entirely.
461
+ */var yr=e("m",(function(){var e,r;return!!(((r=(e=sr.checkoutSession)===null||e===void 0?void 0:e.order)===null||r===void 0?void 0:r.id)&&!sr.checkoutSession.completedAt)}));var wr=e("v",(function(e){var r,n,t,i,a,s,l;
462
+ // update stripe store with updated information
463
+ _e.clientSecret=e.clientSecret;_e.stripeCustomerSessionClientSecret=e.customerSessionClientSecret;_e.customerProfile=e.customerProfile;sr.checkoutSession=e;
464
+ // Populate store credit balance from checkout session customer profile
465
+ L((n=(r=e.customerProfile)===null||r===void 0?void 0:r.storeCreditBalance)!==null&&n!==void 0?n:null);if(!e.id){
466
+ // Log error to track down the issue
467
+ void _({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:m,checkoutSession:e}})}
468
+ // Only update checkout session id if it's not empty
469
+ if(e.id){o.checkoutSessionId=e.id}
470
+ // Filter the response to only include test keys that we support and then save it to the session
471
+ var c=u(e.varianceTestResults||[]);d(c);
472
+ // Check if there is a redirect URL in the metadata to override
473
+ var v=((a=(i=(t=sr.checkoutSession)===null||t===void 0?void 0:t.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)||(
474
+ // Sometimes externalConfirmationPageURL is not in checkoutSession create/update, check if there is a redirect URL in the cart metadata to override
475
+ (l=(s=window.Zonos.cartData)===null||s===void 0?void 0:s.metadata.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||l===void 0?void 0:l.value)||null;if(v){p("Found externalConfirmationPageURL: ".concat(v));sr.externalConfirmationPageURL=v}}));var gr=function(e){return __awaiter(T,[e],void 0,(function(e){var r,n,t,a,u,d;var l=e.adjustmentsAmount,c=e.cartId,v=e.currency,f=e.dutiesTaxesFeesEstimate,m=e.itemsAmount,h=e.landedCostId,w=e.shouldInitSessionOnFailure;return __generator(this,(function(e){switch(e.label){case 0:if(h&&sr.selectedLandedCost){n=sr.selectedLandedCost.subtotals;mr({dutiesTaxesFeesEstimate:f,method:sr.landedCostMethod,subtotals:n});p("Exchange rate updated for cart items (landed cost subtotal)","info",sr.exchangeRate)}
476
+ // update checkout session
477
+ if(!o.checkoutSessionId){p("Could not update cart total without checkout session id","info");return[2/*return*/,false]}return[4/*yield*/,$e({adjustmentsAmount:l,cartId:c,currency:v,id:o.checkoutSessionId,itemsAmount:m,landedCostId:h,presentmentCountryCode:s.selectedCountryCode})];case 1:t=e.sent(),a=t.errors,u=t.json;if(!(a.length>0||!u))return[3/*break*/,4];y("Error occurs when updating checkout session.");if(!w)return[3/*break*/,3];p("Initiating checkout session on failure","info");return[4/*yield*/,Qe()];case 2:d=e.sent();p("stripeStoreInitCheckoutSession: ".concat(d));if(!d){pr({messages:[i("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:i("Error creating Checkout")});return[2/*return*/,false]}return[2/*return*/,true];case 3:return[2/*return*/,false];case 4:if(!h){
478
+ // This is when we first open the checkout modal and we just want to get info from the old cart session.
479
+ // use subtotals from checkout session to update cart total
480
+ mr({method:((r=u.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:u.checkoutSessionUpdate.subtotals});p("Exchange rate updated for cart items (checkout session update)","info",sr.exchangeRate)}wr(u.checkoutSessionUpdate);return[2/*return*/,true]}}))}))};
481
+ /**
482
+ * For some service levels, the landed cost that's DAP and we do remittance on behalf of the merchant, these landed cost should be treated as DDP
483
+ */var br=e("$",(function(e,r){var t,o,i,a;
484
+ // If the landed cost is DAP and the country is domestic, then treat it as DDP since no duty or fee is due at the door
485
+ if(e.method==="DAP"&&((o=(t=n.genericSettings)===null||t===void 0?void 0:t.domesticCountries)===null||o===void 0?void 0:o.includes(((i=_e.stripeAddressEventData)===null||i===void 0?void 0:i.value.address.country)||"US"))){return"DDP"}
486
+ // EU 3-EUR cutover (05CHECK-893): keep EU POSTAL remittance quotes as DAP so
487
+ // the shopper is told duties are paid upon delivery, even though we remit.
488
+ if(tr({deliveryType:r,landedCost:e,shipToCountry:(a=_e.stripeAddressEventData)===null||a===void 0?void 0:a.value.address.country})){return"DAP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method}));var _r=e("Z",(function(e){return __awaiter(T,[e],void 0,(function(e){var r,t,o,i,a,s,u,d,l,c,v,f,m,h,y,w,g,b,_,S,O,A,C,k,I,T;var P=e.applySubtotalsOnly,E=e.landedCostId,N=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:p("Updating selected shipping option","info",{landedCostId:E,selectedShippingOption:N});sr.selectedShippingOption=N;m=dr(sr.selectedShippingOption);if(m){h=m.maxTransit,y=m.minTransit,w=m.unit;sr.selectedShippingOptionTransitTime="".concat(y,"-").concat(h," ").concat(w)}else{sr.selectedShippingOptionTransitTime=""}g=(r=sr.landedCostData)===null||r===void 0?void 0:r.find((function(e){return e.landedCostId===E}));
489
+ // save selected landed cost for later use
490
+ sr.selectedLandedCost=g||null;if(!g){
491
+ // do nothing if we can't find landed cost for selected shipping option
492
+ return[2/*return*/,false]}b=((t=g.landedCost.amountSubtotals)===null||t===void 0?void 0:t.landedCostTotal)||0;_=g.subtotals.exchangeRate.rate;S=b*_;if(S){p("DAP quote, using estimate: ".concat(S),"info")}sr.landedCostMethod=br(g.landedCost,(o=N.shippingProfile)===null||o===void 0?void 0:o.serviceLevel.deliveryType);
493
+ // update shipping value and dutiesTaxFees on selectedShippingOption change
494
+ sr.shipping=g.subtotals.shipping;O=((i=g===null||g===void 0?void 0:g.landedCost)===null||i===void 0?void 0:i.landedCostGuaranteeCode)==="ZONOS";A=!!((s=(a=g===null||g===void 0?void 0:g.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"})));sr.isSelectedShippingAboveDeminimis=A;sr.isSelectedShippingGuarantee=O;C=false;if(!P)return[3/*break*/,1];k=g.subtotals;mr({dutiesTaxesFeesEstimate:S,method:sr.landedCostMethod,subtotals:k});p("Exchange rate updated for cart items (landed cost subtotal)","info",sr.exchangeRate);C=true;return[3/*break*/,3];case 1:return[4/*yield*/,gr({adjustmentsAmount:sr.adjustmentTotal,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:S,landedCostId:(u=g.landedCost)===null||u===void 0?void 0:u.id})];case 2:
495
+ // update session with selected landed cost
496
+ C=e.sent();e.label=3;case 3:I=(d=sr.items.find(Boolean))===null||d===void 0?void 0:d.currencyCode;T=((l=_e.stripeAddressEventData)===null||l===void 0?void 0:l.value.address.country)||"US";
497
+ // Only show pay in USD button if item's currency is in USD, the setting is enabled and the order presentment currency is not USD, also only in USD settlement ship to country list
498
+ _e.shouldRenderPayInUsdButton=I==="USD"&&n.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((c=sr.checkoutSession)===null||c===void 0?void 0:c.subtotals.presentmentCurrencyCode)!=="USD"&&!!((f=(v=n.genericSettings)===null||v===void 0?void 0:v.usdSettlementCountryEnabled)===null||f===void 0?void 0:f.includes(T));return[2/*return*/,C]}}))}))}));var Sr=e("o",(function(e){var r=e.isPreview,n=e.sessionTimeout;
499
+ // do nothing if in preview mode
500
+ if(r){return}var t=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout");var o=
501
+ // timeout query is mainly for testing purpose
502
+ t&&!isNaN(parseInt(t,10))?parseInt(t,10):n;p("==START CHECKOUT TIMEOUT - ".concat(o,"=="));sr.checkoutTimeoutInterval=setTimeout((function(){sr.checkoutSessionTimeoutShow=true}),o)}));var Or=e("j",(function(){if(sr.checkoutTimeoutInterval){clearTimeout(sr.checkoutTimeoutInterval);sr.checkoutTimeoutInterval=null}}));var Ar=function(e){return e.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}))};var Cr=function(){
503
+ // mark all items as not restricted
504
+ sr.items=sr.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));sr.restrictedItems=[]};var kr=e("e",(function(e){return __awaiter(T,[e],void 0,(function(e){var r,n,t,o;var i=e.adjustments,a=e.cartItems,s=e.landedCostId,u=e.shouldInitSessionOnFailure,d=u===void 0?true:u;return __generator(this,(function(e){switch(e.label){case 0:
505
+ // Update adjustments and items
506
+ sr.adjustments=i;sr.items=Ar(a);n=(r=a.find(Boolean))===null||r===void 0?void 0:r.currencyCode;t=a.reduce((function(e,r){return e+r.amount*r.quantity}),0);o=i.reduce((function(e,r){return e+r.amount}),0);if(!n||!t){
507
+ // do nothing if we can't get currency or total
508
+ return[2/*return*/]}sr.currency=n;
509
+ // set loading state here because this is the first load checkout session when we already have checkout session id stored
510
+ _e.isFetchingSession=true;return[4/*yield*/,gr({adjustmentsAmount:o,cartId:window.Zonos.cartId,currency:n,dutiesTaxesFeesEstimate:0,itemsAmount:t,landedCostId:s,shouldInitSessionOnFailure:d})];case 1:e.sent();_e.isFetchingSession=false;return[2/*return*/]}}))}))}));var Ir=function(){sr.selectedShippingOption=null;sr.isSelectedShippingAboveDeminimis=false;sr.isSelectedShippingGuarantee=false;sr.selectedShippingOptionTransitTime="";sr.dutiesTaxesFees=0;sr.dutiesTaxesFeesEstimate=0;sr.shipping=0;
511
+ // reset total to subtotal
512
+ sr.total=sr.subtotal};var Tr=function(){if(sr.step==="shipping"){sr.step="customer-info";
513
+ // set shipping step to done
514
+ sr.tabItems=Object.assign(Object.assign({},sr.tabItems),{"customer-info":Object.assign(Object.assign({},sr.tabItems.shipping),{isDone:false})})}else if(sr.step==="payment"){sr.step="shipping";
515
+ // set shipping step to done
516
+ sr.tabItems=Object.assign(Object.assign({},sr.tabItems),{shipping:Object.assign(Object.assign({},sr.tabItems.shipping),{isDone:false})})}else if(sr.step==="finish"){sr.step="payment";
517
+ // set shipping step to done
518
+ sr.tabItems=Object.assign(Object.assign({},sr.tabItems),{payment:Object.assign(Object.assign({},sr.tabItems.payment),{isDone:false})})}};var Pr=e("x",(function(){if(sr.step==="customer-info"){sr.step="shipping";
519
+ // set customer-info step to done
520
+ sr.tabItems=Object.assign(Object.assign({},sr.tabItems),{"customer-info":Object.assign(Object.assign({},sr.tabItems["customer-info"]),{isDone:true})})}else if(sr.step==="shipping"){sr.step="payment";
521
+ // set shipping step to done
522
+ sr.tabItems=Object.assign(Object.assign({},sr.tabItems),{shipping:Object.assign(Object.assign({},sr.tabItems.shipping),{isDone:true})})}else if(sr.step==="payment"){sr.step="finish"}}));var Er=e("h",(function(){sr.step="customer-info";sr.tabItems=Object.assign(Object.assign({},sr.tabItems),{"customer-info":Object.assign(Object.assign({},sr.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},sr.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},sr.tabItems.shipping),{isDone:false})});Ir()}));var Nr=function(){return __awaiter(T,void 0,void 0,(function(){var e,r,n,t,i,a,u,d,l;return __generator(this,(function(c){switch(c.label){case 0:if(!o.checkoutSessionId){p("Could not update store credit without checkout session id","info");return[2/*return*/]}n=sr.selectedLandedCost;t=sr.currency||((e=sr.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"";i=sr.adjustments.reduce((function(e,r){return e+r.amount}),0);a=sr.items.reduce((function(e,r){return e+r.amount*r.quantity}),0);return[4/*yield*/,$e({adjustmentsAmount:i,cartId:window.Zonos.cartId,currency:t,id:o.checkoutSessionId,itemsAmount:a,landedCostId:n===null||n===void 0?void 0:n.landedCostId,presentmentCountryCode:s.selectedCountryCode,storeCreditApplication:F()})];case 1:u=c.sent(),d=u.errors,l=u.json;if(d.length>0||!l){y("Error updating checkout session with store credit");return[2/*return*/]}
523
+ // Apply updated subtotals from the response
524
+ mr({method:((r=l.checkoutSessionUpdate.landedCost)===null||r===void 0?void 0:r.method)||"DDP",subtotals:l.checkoutSessionUpdate.subtotals});wr(l.checkoutSessionUpdate);return[2/*return*/]}}))}))};
525
+ /**
526
+ * Update the checkout session with the current store credit selection.
527
+ * Debounced to prevent multiple rapid requests when store changes cascade.
528
+ */var jr=e("a5",(function(){if(vr){clearTimeout(vr)}vr=setTimeout((function(){vr=null;void Nr()}),300)}))}}}));