@zonos/elements 1.3.223 → 1.3.224

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 (263) hide show
  1. package/dist/cjs/VarianceTest-bec00ea8.js +91 -0
  2. package/dist/cjs/{cart-3a2a062c.js → cart-af017ac3.js} +41 -40
  3. package/dist/cjs/{debounce-465a4328.js → debounce-2c9f3f1e.js} +1 -1
  4. package/dist/cjs/{getBorderRadius-1b5e33cf.js → getBorderRadius-c7d9f676.js} +1 -1
  5. package/dist/cjs/{handleFetch-45f35cac.js → handleFetch-954f30e1.js} +5 -82
  6. package/dist/cjs/index.cjs.js +40 -37
  7. package/dist/cjs/{isDarkColor-428965f4.js → isDarkColor-994c38e4.js} +1 -1
  8. package/dist/cjs/{localization-12e7e934.js → localization-21030292.js} +82 -24
  9. package/dist/cjs/{paypal-a1377508.js → paypal-2b22f0f5.js} +17 -16
  10. package/dist/cjs/{placeTestOrder-6fcce33e.js → placeTestOrder-9cde1ca4.js} +3 -3
  11. package/dist/cjs/{renderFallback-39ba034b.js → renderFallback-9300dbaf.js} +8 -7
  12. package/dist/cjs/{translationStore-951ed4b4.js → translationStore-ce2c700d.js} +1 -1
  13. package/dist/cjs/{updateCheckoutSessionAttributes-c0853fdd.js → updateCheckoutSessionAttributes-a4899e90.js} +2 -2
  14. package/dist/cjs/zonos-address_11.cjs.entry.js +16 -16
  15. package/dist/cjs/zonos-badge.cjs.entry.js +2 -2
  16. package/dist/cjs/zonos-banner_2.cjs.entry.js +3 -3
  17. package/dist/cjs/zonos-button_3.cjs.entry.js +4 -4
  18. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +25 -25
  19. package/dist/cjs/zonos-checkout.cjs.entry.js +68 -67
  20. package/dist/cjs/zonos-collapse.cjs.entry.js +2 -2
  21. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +8 -8
  22. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +19 -19
  23. package/dist/cjs/zonos-collect.cjs.entry.js +20 -20
  24. package/dist/cjs/zonos-confirm-dialog_2.cjs.entry.js +4 -4
  25. package/dist/cjs/zonos-controller.cjs.entry.js +40 -39
  26. package/dist/cjs/zonos-country-flag.cjs.entry.js +5 -5
  27. package/dist/cjs/zonos-country-select_4.cjs.entry.js +6 -6
  28. package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +14 -14
  29. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +5 -5
  30. package/dist/cjs/zonos-hello.cjs.entry.js +12 -12
  31. package/dist/cjs/zonos-input.cjs.entry.js +3 -3
  32. package/dist/cjs/zonos-language-select_2.cjs.entry.js +5 -5
  33. package/dist/cjs/zonos-logo.cjs.entry.js +2 -2
  34. package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +3 -3
  35. package/dist/cjs/zonos-stripe-input.cjs.entry.js +5 -5
  36. package/dist/cjs/zonos-text.cjs.entry.js +2 -2
  37. package/dist/cjs/zonos-toggle.cjs.entry.js +2 -2
  38. package/dist/cjs/zonos-v-stack.cjs.entry.js +2 -2
  39. package/dist/cjs/{zonosStore-f8ee56aa.js → zonosStore-5d489c65.js} +8 -2
  40. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.css +4 -0
  41. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +1 -0
  42. package/dist/collection/components/common/zonos-stripe-input/zonos-stripe-input.css +1 -0
  43. package/dist/collection/components/main/zonos-controller.js +1 -1
  44. package/dist/collection/components/store/hello/localization.js +12 -9
  45. package/dist/collection/components/store/zonosStore.js +8 -1
  46. package/dist/collection/components/utils/api/getZonosSettings.js +2 -0
  47. package/dist/collection/components/utils/hello/currencyConversion/currencyDisplay.js +2 -0
  48. package/dist/collection/components/utils/hello/currencyConversion/defaultCurrencyConverter.js +5 -0
  49. package/dist/collection/components/utils/logging/sendLoadCheckoutFacadeLog.js +1 -1
  50. package/dist/collection/components/utils/logging/sendLoadNativeCheckoutLog.js +1 -1
  51. package/dist/collection/scripts/_zonosBase.js +3 -0
  52. package/dist/collection/types/generated/graphql.internal.types.js +3 -0
  53. package/dist/collection/utils/performBlurCurrency.js +50 -0
  54. package/dist/esm/VarianceTest-572cecf5.js +86 -0
  55. package/dist/esm/{cart-7f06662c.js → cart-11b87221.js} +7 -6
  56. package/dist/esm/{debounce-c34d1270.js → debounce-f081e4d8.js} +1 -1
  57. package/dist/esm/{getBorderRadius-87593ff4.js → getBorderRadius-6281d902.js} +1 -1
  58. package/dist/esm/{handleFetch-99218189.js → handleFetch-a844cac1.js} +2 -76
  59. package/dist/esm/index.js +13 -9
  60. package/dist/esm/{isDarkColor-1f58b6be.js → isDarkColor-83e0c27e.js} +1 -1
  61. package/dist/esm/{localization-192886e4.js → localization-9320a65d.js} +71 -13
  62. package/dist/esm/{paypal-53f1b4a1.js → paypal-338a4350.js} +7 -6
  63. package/dist/esm/{placeTestOrder-95cbb623.js → placeTestOrder-d28f33c2.js} +3 -3
  64. package/dist/esm/{renderFallback-6352363c.js → renderFallback-28ef3364.js} +5 -4
  65. package/dist/esm/{translationStore-fb98a08d.js → translationStore-7eebaa41.js} +1 -1
  66. package/dist/esm/{updateCheckoutSessionAttributes-92f42882.js → updateCheckoutSessionAttributes-160720f6.js} +2 -2
  67. package/dist/esm/zonos-address_11.entry.js +9 -9
  68. package/dist/esm/zonos-badge.entry.js +2 -2
  69. package/dist/esm/zonos-banner_2.entry.js +3 -3
  70. package/dist/esm/zonos-button_3.entry.js +4 -4
  71. package/dist/esm/zonos-cart-items_12.entry.js +12 -12
  72. package/dist/esm/zonos-checkout.entry.js +15 -14
  73. package/dist/esm/zonos-collapse.entry.js +2 -2
  74. package/dist/esm/zonos-collect-cart-items_3.entry.js +8 -8
  75. package/dist/esm/zonos-collect-finish_6.entry.js +11 -11
  76. package/dist/esm/zonos-collect.entry.js +10 -10
  77. package/dist/esm/zonos-confirm-dialog_2.entry.js +4 -4
  78. package/dist/esm/zonos-controller.entry.js +10 -9
  79. package/dist/esm/zonos-country-flag.entry.js +5 -5
  80. package/dist/esm/zonos-country-select_4.entry.js +6 -6
  81. package/dist/esm/zonos-empty-state-payment_4.entry.js +9 -9
  82. package/dist/esm/zonos-hello-dialog.entry.js +5 -5
  83. package/dist/esm/zonos-hello.entry.js +6 -6
  84. package/dist/esm/zonos-input.entry.js +3 -3
  85. package/dist/esm/zonos-language-select_2.entry.js +5 -5
  86. package/dist/esm/zonos-logo.entry.js +2 -2
  87. package/dist/esm/zonos-shipping-rich-radio.entry.js +3 -3
  88. package/dist/esm/zonos-stripe-input.entry.js +5 -5
  89. package/dist/esm/zonos-text.entry.js +2 -2
  90. package/dist/esm/zonos-toggle.entry.js +2 -2
  91. package/dist/esm/zonos-v-stack.entry.js +2 -2
  92. package/dist/esm/{zonosStore-c456b933.js → zonosStore-e3d0493a.js} +8 -2
  93. package/dist/esm-es5/VarianceTest-572cecf5.js +1 -0
  94. package/dist/esm-es5/cart-11b87221.js +1 -0
  95. package/dist/esm-es5/{debounce-c34d1270.js → debounce-f081e4d8.js} +1 -1
  96. package/dist/esm-es5/{getBorderRadius-87593ff4.js → getBorderRadius-6281d902.js} +1 -1
  97. package/dist/esm-es5/handleFetch-a844cac1.js +1 -0
  98. package/dist/esm-es5/index.js +1 -1
  99. package/dist/esm-es5/{isDarkColor-1f58b6be.js → isDarkColor-83e0c27e.js} +1 -1
  100. package/dist/esm-es5/localization-9320a65d.js +1 -0
  101. package/dist/esm-es5/{paypal-53f1b4a1.js → paypal-338a4350.js} +2 -2
  102. package/dist/esm-es5/{placeTestOrder-95cbb623.js → placeTestOrder-d28f33c2.js} +1 -1
  103. package/dist/esm-es5/renderFallback-28ef3364.js +1 -0
  104. package/dist/esm-es5/{translationStore-fb98a08d.js → translationStore-7eebaa41.js} +1 -1
  105. package/dist/esm-es5/{updateCheckoutSessionAttributes-92f42882.js → updateCheckoutSessionAttributes-160720f6.js} +1 -1
  106. package/dist/esm-es5/zonos-address_11.entry.js +1 -1
  107. package/dist/esm-es5/zonos-badge.entry.js +1 -1
  108. package/dist/esm-es5/zonos-banner_2.entry.js +1 -1
  109. package/dist/esm-es5/zonos-button_3.entry.js +1 -1
  110. package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
  111. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  112. package/dist/esm-es5/zonos-collapse.entry.js +1 -1
  113. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  114. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
  115. package/dist/esm-es5/zonos-collect.entry.js +1 -1
  116. package/dist/esm-es5/zonos-confirm-dialog_2.entry.js +1 -1
  117. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  118. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  119. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  120. package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
  121. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  122. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  123. package/dist/esm-es5/zonos-input.entry.js +1 -1
  124. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  125. package/dist/esm-es5/zonos-logo.entry.js +1 -1
  126. package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
  127. package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
  128. package/dist/esm-es5/zonos-text.entry.js +1 -1
  129. package/dist/esm-es5/zonos-toggle.entry.js +1 -1
  130. package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
  131. package/dist/esm-es5/zonosStore-e3d0493a.js +1 -0
  132. package/dist/scripts/blurCurrencyOnInit.js +1 -0
  133. package/dist/scripts/index.d.ts +38 -6
  134. package/dist/scripts/index.js +1 -1
  135. package/dist/scripts/loadZonos.js +1 -1
  136. package/dist/scripts/zonos.js +1 -1
  137. package/dist/types/scripts/_zonosBase.d.ts +8 -3
  138. package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +7 -3
  139. package/dist/types/types/checkout/api/NormalizedTempCart.d.ts +2 -2
  140. package/dist/types/types/generated/graphql.internal.types.d.ts +13 -2
  141. package/dist/types/types/generated/graphql.internal.types.ts +13 -2
  142. package/dist/types/types/global.d.ts +8 -0
  143. package/dist/types/types/utils/ZonosSettings.d.ts +8 -2
  144. package/dist/types/utils/performBlurCurrency.d.ts +2 -0
  145. package/dist/zonos-elements/base.css +1 -0
  146. package/dist/zonos-elements/index.esm.js +1 -1
  147. package/dist/zonos-elements/p-01174496.system.js +1 -0
  148. package/dist/zonos-elements/p-0260fd13.js +1 -0
  149. package/dist/zonos-elements/{p-e970f2aa.system.entry.js → p-04c1dc63.system.entry.js} +1 -1
  150. package/dist/zonos-elements/p-0a377722.js +1 -0
  151. package/dist/zonos-elements/p-0a92e3fd.entry.js +1 -0
  152. package/dist/zonos-elements/{p-8350937d.system.entry.js → p-0b6a3a09.system.entry.js} +1 -1
  153. package/dist/zonos-elements/p-0d82e1fd.entry.js +1 -0
  154. package/dist/zonos-elements/{p-a7485913.system.js → p-0ec82d78.system.js} +2 -2
  155. package/dist/zonos-elements/{p-2b9c124d.js → p-0ffd710e.js} +1 -1
  156. package/dist/zonos-elements/p-112c6453.system.js +1 -0
  157. package/dist/zonos-elements/{p-62fa680d.system.js → p-182da73f.system.js} +1 -1
  158. package/dist/zonos-elements/p-1868a283.entry.js +1 -0
  159. package/dist/zonos-elements/{p-ba18c5f5.system.entry.js → p-1a67ae71.system.entry.js} +1 -1
  160. package/dist/zonos-elements/{p-520bd291.system.entry.js → p-1b9cc0e2.system.entry.js} +1 -1
  161. package/dist/zonos-elements/p-1c5ba523.js +1 -0
  162. package/dist/zonos-elements/p-1ef793d0.entry.js +1 -0
  163. package/dist/zonos-elements/{p-0ed63ce0.system.js → p-23c46dfa.system.js} +1 -1
  164. package/dist/zonos-elements/{p-e7f8595f.system.js → p-24e26a2c.system.js} +1 -1
  165. package/dist/zonos-elements/p-252fa1da.entry.js +1 -0
  166. package/dist/zonos-elements/{p-53b46925.entry.js → p-2616ba72.entry.js} +1 -1
  167. package/dist/zonos-elements/p-2657f099.system.entry.js +1 -0
  168. package/dist/zonos-elements/{p-7d2d2c94.entry.js → p-2dc38ef3.entry.js} +1 -1
  169. package/dist/zonos-elements/{p-12ce9746.system.entry.js → p-360d7101.system.entry.js} +1 -1
  170. package/dist/zonos-elements/{p-19f25feb.system.entry.js → p-375994d1.system.entry.js} +1 -1
  171. package/dist/zonos-elements/{p-ee6f8c02.system.entry.js → p-38f42f10.system.entry.js} +1 -1
  172. package/dist/zonos-elements/{p-4637f365.system.entry.js → p-4004c838.system.entry.js} +1 -1
  173. package/dist/zonos-elements/p-41dd1cb8.js +1 -0
  174. package/dist/zonos-elements/{p-e63b8b24.system.js → p-433d76b4.system.js} +1 -1
  175. package/dist/zonos-elements/{p-a77ed1b9.entry.js → p-4523b982.entry.js} +1 -1
  176. package/dist/zonos-elements/{p-fc27467b.entry.js → p-4ce3489a.entry.js} +1 -1
  177. package/dist/zonos-elements/{p-a61a9b65.system.entry.js → p-4da7b6a8.system.entry.js} +1 -1
  178. package/dist/zonos-elements/{p-7b56e345.js → p-4dfe97ad.js} +2 -2
  179. package/dist/zonos-elements/{p-cd1ebef9.system.js → p-57413c34.system.js} +1 -1
  180. package/dist/zonos-elements/{p-4d9ad3b1.system.entry.js → p-576d76fa.system.entry.js} +1 -1
  181. package/dist/zonos-elements/p-5c43ecdf.system.entry.js +1 -0
  182. package/dist/zonos-elements/{p-9fdd3264.system.entry.js → p-5f7a9b69.system.entry.js} +1 -1
  183. package/dist/zonos-elements/p-6092af05.entry.js +1 -0
  184. package/dist/zonos-elements/{p-9b062dfb.entry.js → p-67787bd4.entry.js} +1 -1
  185. package/dist/zonos-elements/{p-7c4e7651.entry.js → p-6bab9096.entry.js} +1 -1
  186. package/dist/zonos-elements/p-6d423364.entry.js +1 -0
  187. package/dist/zonos-elements/p-725605f6.system.js +1 -0
  188. package/dist/zonos-elements/p-7af39c98.js +1 -0
  189. package/dist/zonos-elements/{p-7f7abdf2.system.entry.js → p-7cee0e68.system.entry.js} +1 -1
  190. package/dist/zonos-elements/p-7eb8e2d4.js +1 -0
  191. package/dist/zonos-elements/p-81b357f7.system.js +1 -1
  192. package/dist/zonos-elements/p-820ad058.js +1 -0
  193. package/dist/zonos-elements/{p-5e3d2bd2.system.entry.js → p-873b6185.system.entry.js} +1 -1
  194. package/dist/zonos-elements/p-89c5164b.system.js +1 -0
  195. package/dist/zonos-elements/p-91f32c73.system.js +1 -0
  196. package/dist/zonos-elements/{p-245f6ad4.system.entry.js → p-9e03a145.system.entry.js} +1 -1
  197. package/dist/zonos-elements/{p-0ae53ff0.js → p-a199bb13.js} +1 -1
  198. package/dist/zonos-elements/p-ae3e4f2b.entry.js +1 -0
  199. package/dist/zonos-elements/{p-567f7de7.entry.js → p-b4bf2f03.entry.js} +1 -1
  200. package/dist/zonos-elements/p-b5b3f908.system.js +1 -0
  201. package/dist/zonos-elements/{p-a5b0a636.entry.js → p-b658c28a.entry.js} +1 -1
  202. package/dist/zonos-elements/{p-de626806.system.entry.js → p-b6ef4a5e.system.entry.js} +1 -1
  203. package/dist/zonos-elements/{p-4f8563ad.system.entry.js → p-b91df44b.system.entry.js} +1 -1
  204. package/dist/zonos-elements/{p-e8accbef.system.entry.js → p-ba334962.system.entry.js} +1 -1
  205. package/dist/zonos-elements/p-bccd49d7.system.entry.js +1 -0
  206. package/dist/zonos-elements/p-bdeb20cb.js +1 -0
  207. package/dist/zonos-elements/{p-a95d2034.system.entry.js → p-bfc0fc85.system.entry.js} +1 -1
  208. package/dist/zonos-elements/{p-c4b3c878.entry.js → p-c81f6387.entry.js} +1 -1
  209. package/dist/zonos-elements/{p-efa6203f.entry.js → p-c998e4ed.entry.js} +1 -1
  210. package/dist/zonos-elements/{p-9396059b.entry.js → p-cb0e6468.entry.js} +1 -1
  211. package/dist/zonos-elements/{p-421dfb66.system.entry.js → p-cb11d11b.system.entry.js} +1 -1
  212. package/dist/zonos-elements/p-cc599cd9.entry.js +1 -0
  213. package/dist/zonos-elements/p-ce4c6ae0.entry.js +1 -0
  214. package/dist/zonos-elements/{p-14f9bc8c.entry.js → p-d2f7ea09.entry.js} +1 -1
  215. package/dist/zonos-elements/{p-0c0fda23.js → p-d42b5113.js} +1 -1
  216. package/dist/zonos-elements/{p-00423fa0.system.js → p-d531b524.system.js} +1 -1
  217. package/dist/zonos-elements/p-d938f42f.system.js +1 -0
  218. package/dist/zonos-elements/{p-f4fa8720.entry.js → p-d96545ae.entry.js} +1 -1
  219. package/dist/zonos-elements/{p-eb6a35ce.system.entry.js → p-dc56b469.system.entry.js} +1 -1
  220. package/dist/zonos-elements/{p-45d288d0.system.entry.js → p-e00e5d64.system.entry.js} +1 -1
  221. package/dist/zonos-elements/{p-8194fcd8.entry.js → p-e60b988c.entry.js} +1 -1
  222. package/dist/zonos-elements/{p-56e0ed65.js → p-e688e493.js} +1 -1
  223. package/dist/zonos-elements/{p-295d9c07.system.entry.js → p-f548807d.system.entry.js} +1 -1
  224. package/dist/zonos-elements/{p-e7b05da2.entry.js → p-f912e9c3.entry.js} +1 -1
  225. package/dist/zonos-elements/zonos-elements.css +1 -1
  226. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  227. package/package.json +4 -3
  228. package/dist/cjs/VarianceTest-0cb1e118.js +0 -12
  229. package/dist/esm/VarianceTest-fef2d958.js +0 -10
  230. package/dist/esm-es5/VarianceTest-fef2d958.js +0 -1
  231. package/dist/esm-es5/cart-7f06662c.js +0 -1
  232. package/dist/esm-es5/handleFetch-99218189.js +0 -1
  233. package/dist/esm-es5/localization-192886e4.js +0 -1
  234. package/dist/esm-es5/renderFallback-6352363c.js +0 -1
  235. package/dist/esm-es5/zonosStore-c456b933.js +0 -1
  236. package/dist/zonos-elements/p-04a01cb1.js +0 -1
  237. package/dist/zonos-elements/p-062430f9.system.js +0 -1
  238. package/dist/zonos-elements/p-0e28207a.js +0 -1
  239. package/dist/zonos-elements/p-1cd1da90.system.js +0 -1
  240. package/dist/zonos-elements/p-2131fa8b.entry.js +0 -1
  241. package/dist/zonos-elements/p-30432622.system.entry.js +0 -1
  242. package/dist/zonos-elements/p-366ea017.entry.js +0 -1
  243. package/dist/zonos-elements/p-3f3c92db.system.entry.js +0 -1
  244. package/dist/zonos-elements/p-4a3abbf2.js +0 -1
  245. package/dist/zonos-elements/p-4dcbbd60.js +0 -1
  246. package/dist/zonos-elements/p-5a2dd041.system.js +0 -1
  247. package/dist/zonos-elements/p-640a6898.system.js +0 -1
  248. package/dist/zonos-elements/p-6afbbe66.entry.js +0 -1
  249. package/dist/zonos-elements/p-6cfe66fe.entry.js +0 -1
  250. package/dist/zonos-elements/p-6f6573a5.system.js +0 -1
  251. package/dist/zonos-elements/p-7ce093aa.js +0 -1
  252. package/dist/zonos-elements/p-9d863a3b.system.js +0 -1
  253. package/dist/zonos-elements/p-a435931e.system.entry.js +0 -1
  254. package/dist/zonos-elements/p-a8a312b2.js +0 -1
  255. package/dist/zonos-elements/p-a9b3cfe1.entry.js +0 -1
  256. package/dist/zonos-elements/p-abcefd25.entry.js +0 -1
  257. package/dist/zonos-elements/p-b76db2ac.js +0 -1
  258. package/dist/zonos-elements/p-bbf48b31.entry.js +0 -1
  259. package/dist/zonos-elements/p-bdf183a3.entry.js +0 -1
  260. package/dist/zonos-elements/p-d1b415cd.entry.js +0 -1
  261. package/dist/zonos-elements/p-d2098bef.entry.js +0 -1
  262. package/dist/zonos-elements/p-da200c19.system.js +0 -1
  263. package/dist/zonos-elements/p-df0cbde4.js +0 -1
@@ -1 +0,0 @@
1
- var __awaiter=this&&this.__awaiter||function(e,t,r,o){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function a(e){try{d(o.next(e))}catch(e){i(e)}}function s(e){try{d(o["throw"](e))}catch(e){i(e)}}function d(e){e.done?r(e.value):n(e.value).then(a,s)}d((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(t){return d([e,t])}}function d(s){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,s[0]&&(r=0)),r)try{if(o=1,n&&(i=s[0]&2?n["return"]:s[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;if(n=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:r.label++;return{value:s[1],done:false};case 5:r.label++;n=s[1];s=[0];continue;case 7:s=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){r.label=s[1];break}if(s[0]===6&&r.label<i[1]){r.label=i[1];i=s;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(s);break}if(i[2])r.ops.pop();r.trys.pop();continue}s=t.call(e,r)}catch(e){s=[6,e];n=0}finally{o=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++){if(i||!(o in t)){if(!i)i=Array.prototype.slice.call(t,0,o);i[o]=t[o]}}return e.concat(i||Array.prototype.slice.call(t))};import{z as zonosStore,c as createStore}from"./zonosStore-c456b933.js";import{s as storageStore,l as localizationStore,f as filterValidTests,b as storageStoreSetEnabledVariantTestKeys}from"./localization-192886e4.js";import{t as translate}from"./translationStore-fb98a08d.js";import{l as log,f as fallbackApiList,h as handleFetch,g as getIsTestMode,a as getIsStagingMode,s as sendErrorLog,d as allLogs,b as logError,j as jsonParse}from"./handleFetch-99218189.js";import{i as isDarkColor}from"./isDarkColor-1f58b6be.js";import{g as getBorderRadius}from"./getBorderRadius-87593ff4.js";var extractName=function(e){var t=e.firstName,r=e.lastName,o=e.name;var n;if(!o&&!t&&!r){return{firstName:"",lastName:""}}var i=(o===null||o===void 0?void 0:o.split(/\s+/))||[];var a=(t===null||t===void 0?void 0:t.trim())||((n=i[0])===null||n===void 0?void 0:n.trim())||"";var s=(r===null||r===void 0?void 0:r.trim())||i.slice(1).join(" ").trim()||"";return{firstName:a,lastName:s}};var getTranslatedAddress=function(e){var t=e.currentAddress,r=e.translatedAddress;var o,n,i,a,s,d;var c=t.value.address,l=c.city,u=c.country,v=c.line1,S=c.line2,p=c.postal_code,f=c.state;var h=t.value.name||[t.value.firstName,t.value.lastName].join(" ");return{city:((o=r.city)===null||o===void 0?void 0:o[l])||l,country:u,line1:((n=r.line1)===null||n===void 0?void 0:n[v])||v,line2:((i=r.line2)===null||i===void 0?void 0:i[S||""])||S||"",name:((a=r.name)===null||a===void 0?void 0:a[h])||h,phone:t.value.phone||"",postal_code:((s=r.postal_code)===null||s===void 0?void 0:s[p])||p,state:((d=r.state)===null||d===void 0?void 0:d[f])||f}};var prepCartCalculateLandedCost=function(e){var t;var r=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var o=stripeStore.stripeLinkEventData;var n=stripeStore.stripeAddressEventData;var i=stripeStore.stripeShippingSameAsBilling?stripeStore.stripeAddressEventData:stripeStore.stripeBillingAddressEventData;if(!n||!i){throw new Error("Missing stripe address data")}var a=getTranslatedAddress({currentAddress:n,translatedAddress:stripeStore.translatedAddress.address});var s=extractName({name:a.name}),d=s.firstName,c=s.lastName;var l=getTranslatedAddress({currentAddress:i,translatedAddress:stripeStore.translatedAddress.address});var u=extractName({name:l.name}),v=u.firstName,S=u.lastName;return{billingAddress:{addressLine1:l.line1,addressLine2:l.line2||"",city:l.city,country:l.country,postalCode:l.postal_code,state:l.state},billingContact:{firstName:v,lastName:S,phone:l.phone},cartCurrencyCode:(t=cartStore.items[0])===null||t===void 0?void 0:t.currencyCode,cartId:e,checkoutSessionId:storageStore.checkoutSessionId||"",contact:{companyName:stripeStore.companyName,email:o===null||o===void 0?void 0:o.value.email,firstName:d,lastName:c,phone:a.phone},isTest:!!r,landedCostAdjustments:cartStore.promoCode?[{amount:0,productId:null,promoCode:cartStore.promoCode,sku:null,type:"PROMO_CODE"}]:[],shipToTaxId:stripeStore.taxId,shippingAddress:{addressLine1:a.line1,addressLine2:a.line2,city:a.city,country:a.country,postalCode:a.postal_code,state:a.state}}};var prepCalculateLandedCost=function(){var e=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";var t=stripeStore.stripeLinkEventData;var r=stripeStore.stripeAddressEventData;var o=stripeStore.stripeShippingSameAsBilling?stripeStore.stripeAddressEventData:stripeStore.stripeBillingAddressEventData;log({stripeAddressData:r,stripeBillingAddressData:o},"info");if(!r||!o){throw new Error("Missing stripe address data")}var n=getTranslatedAddress({currentAddress:r,translatedAddress:stripeStore.translatedAddress.address});var i=extractName({name:n.name}),a=i.firstName,s=i.lastName;var d=getTranslatedAddress({currentAddress:o,translatedAddress:stripeStore.translatedAddress.address});var c=extractName({name:d.name}),l=c.firstName,u=c.lastName;var v=cartStore.adjustments.map((function(e){return{amount:e.amount,name:e.description||null,productId:e.productId,sku:e.sku,type:e.type}}));var S=cartStore.promoCode?__spreadArray([{amount:0,productId:null,promoCode:cartStore.promoCode,sku:null,type:"PROMO_CODE"}],v,true):v;return{billingAddress:{addressLine1:d.line1,addressLine2:d.line2||"",city:d.city,country:d.country,postalCode:d.postal_code,state:d.state},billingContact:{firstName:l,lastName:u,phone:d.phone},checkoutSessionId:storageStore.checkoutSessionId||"",contact:{companyName:stripeStore.companyName,email:t===null||t===void 0?void 0:t.value.email,firstName:a,lastName:s,phone:n.phone},isTest:e,items:cartStore.items,landedCostAdjustments:S,shipToTaxId:stripeStore.taxId,shippingAddress:{addressLine1:n.line1,addressLine2:n.line2,city:n.city,country:n.country,postalCode:n.postal_code,state:n.state}}};var triggerBuildLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a,s,d,c,l;return __generator(this,(function(u){switch(u.label){case 0:a=prepCalculateLandedCost();return[4,e({billingAddress:a.billingAddress,billingContact:a.billingContact,checkoutSessionId:a.checkoutSessionId,contact:a.contact,landedCostAdjustments:a.landedCostAdjustments,publicCredential:window.Zonos.zonosApiKey||"",shippingAddress:a.shippingAddress,zonosApiRoute:fallbackApiList["vercel"]})];case 1:s=u.sent();if(!s||!((t=s.checkoutSessionWorkflow)===null||t===void 0?void 0:t.length)&&((r=s.errors)===null||r===void 0?void 0:r.length)){throw new Error("Failed to build landed cost: ".concat(((n=(o=s===null||s===void 0?void 0:s.errors)===null||o===void 0?void 0:o[0])===null||n===void 0?void 0:n.message)||"Unknown error"))}return[4,handleFetch("/api/zonos-elements/validate-landed-cost",{body:s,headers:{"Content-Type":"application/json"},method:"POST"})];case 2:d=u.sent(),c=d.errors,l=d.json;if(!l||c.length){throw new Error("Invalid landed cost object: ".concat(((i=c.find(Boolean))===null||i===void 0?void 0:i.message)||"Unknown error"))}return[2,s]}}))}))};var calculateLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a,s;return __generator(this,(function(d){switch(d.label){case 0:r=zonosStore.checkoutSettings.buildLandedCost;if(!r)return[3,2];return[4,triggerBuildLandedCost(r)];case 1:o=d.sent();return[2,o];case 2:return[4,handleFetch("/api/zonos-elements/calculate-landed-cost",{body:prepCalculateLandedCost(),method:"POST",signal:e===null||e===void 0?void 0:e.signal})];case 3:n=d.sent(),i=n.errors,a=n.json;if(i.length||!a){s=((t=i[0])===null||t===void 0?void 0:t.message)==="The user aborted a request.";if(s){throw new Error("The landed cost calculation request was aborted to initiate a new one.")}i.forEach((function(e){console.warn("Error calculating landed cost: ".concat(e.message))}));if(!a){throw new Error("Failed to calculate landed cost")}return[2,a]}return[2,a]}}))}))};var cartCalculateLandedCost=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,c,l;var u=e.abortController,v=e.cartId;return __generator(this,(function(e){switch(e.label){case 0:return[4,handleFetch("/api/zonos-elements/cart-calculate-landed-cost",{body:prepCartCalculateLandedCost(v),method:"POST",signal:u===null||u===void 0?void 0:u.signal})];case 1:a=e.sent(),s=a.errors,d=a.json;if(s.length||!d){c=typeof((t=s[0])===null||t===void 0?void 0:t.message)==="string"&&(((r=s[0])===null||r===void 0?void 0:r.message)==="The user aborted a request."||((o=s[0])===null||o===void 0?void 0:o.message.includes("signal is aborted"))||((n=s[0])===null||n===void 0?void 0:n.message.includes("The operation was aborted"))||((i=s[0])===null||i===void 0?void 0:i.message.includes("Fetch is aborted")));l=c?"The landed cost calculation request was aborted to initiate a new one.":"Failed to calculate landed cost";throw new Error(l)}return[2,d]}}))}))};var __rest=undefined&&undefined.__rest||function(e,t){var r={};for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0)r[o]=e[o];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++){if(t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n]))r[o[n]]=e[o[n]]}return r};var calculateLandedCostNormalized=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i;return __generator(this,(function(a){switch(a.label){case 0:t=window.Zonos.cartId;if(!!t)return[3,2];return[4,calculateLandedCost(e)];case 1:r=a.sent();return[2,r];case 2:return[4,cartCalculateLandedCost({abortController:e,cartId:t})];case 3:o=a.sent(),n=o.cartWorkflow,i=__rest(o,["cartWorkflow"]);return[2,Object.assign(Object.assign({},i),{itemCreateWorkflow:n.items})]}}))}))};var trackConversionEvent=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,c;var l=e.checkoutSessionId,u=e.eventName,v=e.metadata;return __generator(this,(function(e){switch(e.label){case 0:o=Date.now();n=__spreadArray([],window.Zonos.trackEventLogs,true);window.Zonos.trackEventLogs.push({checkoutSessionId:l,eventCreated:o,eventName:u});i=window.location.href.includes("zonos.com")&&!window.location.href.includes("checkout.zonos.com")||!!((t=window.Zonos)===null||t===void 0?void 0:t.zonosQaUrl)||!!((r=window.Zonos)===null||r===void 0?void 0:r.debug);a=getIsTestMode()||getIsStagingMode();if((a||i)&&!window.Zonos.zonosConversionTest){return[2]}s=localizationStore.selectedCountryCode;d=zonosStore.organizationId;if(!l){void sendErrorLog({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(u,'" - No checkout session id found')],metadata:{allLogs:allLogs,checkoutSessionId:l,eventName:u,metadata:v,organizationId:d,trackEventLogs:n}});return[2]}if(!d){void sendErrorLog({endpoint:"trackConversionEventMetric",errors:['Event "'.concat(u,'" - No organization id found')],metadata:{allLogs:allLogs,checkoutSessionId:l,eventName:u,metadata:v,organizationId:d,trackEventLogs:n}})}c={checkoutSessionId:l,countryCode:s,eventCreated:o,eventName:u,metadata:Object.assign(Object.assign({},v),{trackEventLogs:n}),organizationId:d};return[4,handleFetch("/api/zonos-elements/track-conversion-event",{body:c,method:"POST"})];case 1:e.sent();return[2]}}))}))};var getExcludeAddressFieldsObject=function(e){var t=e.address,r=e.invalidAdddressList;if(!t){return}if(!r){return}var o={};if(r.city){o.city=t.city}if(r.line1){o.line1=t.line1}if(r.line2){o.line2=t.line2}if(r.postal_code){o.postal_code=t.postal_code}if(r.state){o.state=t.state}if(r.name){o.name=t.name}return Object.keys(o).length?o:undefined};var buildTranslateRequest=function(e){var t=e.addressInvalidCharactersList,r=e.billingAddressInvalidCharactersList,o=e.stripeAddressEventData,n=e.stripeBillingAddressEventData,i=e.stripeShippingSameAsBilling;var a=!!(o===null||o===void 0?void 0:o.complete);var s=i?a:!!(n===null||n===void 0?void 0:n.complete);if(!a||!s){return null}if(!t&&!r){return null}var d=o.value;var c=(n===null||n===void 0?void 0:n.value)||null;var l=extractName({firstName:d.firstName,lastName:d.lastName,name:d.name}),u=l.firstName,v=l.lastName;var S="".concat(u," ").concat(v);var p=extractName({firstName:c===null||c===void 0?void 0:c.firstName,lastName:c===null||c===void 0?void 0:c.lastName,name:(c===null||c===void 0?void 0:c.name)||""}),f=p.firstName,h=p.lastName;var m=f&&h?"".concat(f," ").concat(h):"";var g=d.address;var y=c===null||c===void 0?void 0:c.address;return{address:getExcludeAddressFieldsObject({address:Object.assign(Object.assign({},g),{name:S}),invalidAdddressList:t}),billingAddress:!i?getExcludeAddressFieldsObject({address:y?Object.assign(Object.assign({},y),{name:m}):null,invalidAdddressList:r}):undefined,destinationCountry:g.country}};var sortServiceLevelOptionsByAmount=function(e){var t=e.sort((function(e,t){return e.amount-t.amount}));return t};var getCheckoutSession=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o;return __generator(this,(function(n){switch(n.label){case 0:if(!storageStore.checkoutSessionId){return[2,{errors:[{message:"No checkout session id found"}],json:null}]}e=new URLSearchParams;e.set("checkoutSessionId",storageStore.checkoutSessionId);return[4,handleFetch("/api/zonos-elements/get-checkout-session?".concat(e.toString()))];case 1:t=n.sent(),r=t.errors,o=t.json;return[2,{errors:r,json:o}]}}))}))};var validateCheckoutSession=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o;return __generator(this,(function(n){switch(n.label){case 0:return[4,getCheckoutSession()];case 1:t=n.sent(),r=t.errors,o=t.json;if(r.length||!o){logError("Failed to retrieve checkout session info before confirming payment ",r);void sendErrorLog({endpoint:"validateCheckoutSession",errors:r.map((function(e){return e.message})),metadata:{allLogs:allLogs}});return[2,{errorMessage:translate("Unable to retrieve the checkout session at the moment. Please try again or contact our support team."),valid:false}]}if(!((e=o.checkoutSession.landedCost)===null||e===void 0?void 0:e.id)){logError("Landed cost is not found in the checkout session before confirming payment.");void sendErrorLog({endpoint:"validateCheckoutSession",errors:["No landed cost found before confirming payment"],metadata:{allLogs:allLogs}});return[2,{errorMessage:translate('No shipment rating selected. Please go back to the "Shipping" step and select a shipment rating to proceed.'),valid:false}]}return[2,{errorMessage:"",valid:true}]}}))}))};var addressRuleStyle=function(e){var t=e.theme;var r={".AccordionItem":{color:"var(--colorText)"},".AccordionItem--selected":{color:"var(--colorText)"},".Action":{color:"var(--colorText)"},".Input":{boxShadow:"none",fontSize:zonosStore.appearance.fontSizeInputValue?"".concat(zonosStore.appearance.fontSizeInputValue,"px"):undefined,padding:"0",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"8px",paddingTop:"6px"},".Label--resting":{fontSize:zonosStore.appearance.fontSizeInputLabel?"".concat(zonosStore.appearance.fontSizeInputLabel,"px"):undefined},".PickerItem--highlight":{boxShadow:"0 0 0 2px var(--colorBackground)"},".PickerItem--highlight:hover":{backgroundColor:"var(--colorBackground)",boxShadow:"none"},".PickerItem--new":{color:"var(--colorText)"},".Tab--selected":{borderStyle:"solid",borderWidth:"1px"}};switch(t){case"DARK":{return Object.assign(Object.assign({},r),{".Action":Object.assign(Object.assign({},r[".Action"]),{color:"white"}),".PickerItem--new":Object.assign(Object.assign({},r[".PickerItem--new"]),{color:"white"})})}default:return r}};var defaultVariable=function(e){var t=e.borderStyle,r=e.theme;switch(r){case"DARK":return{borderRadius:getBorderRadius({overrideBorderStyle:t}),colorBackground:"#101117",colorBackgroundText:"#C5C6CA",colorText:"#C5C6CA",colorTextPlaceholder:"#C5C6CA"};default:return{borderRadius:getBorderRadius({overrideBorderStyle:t}),iconMenuColor:"var(--colorText)",iconMenuHoverColor:"var(--colorText)"}}};var _m=createStore((function(){return{checkoutSettlementCurrency:"USD",clientSecret:sessionStorage.getItem("zonos--client-secret")||"",companyName:"",companyNameUsedWhenAsyncAddressUpdate:"",customAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customBillingAddressErrors:{city:"",firstName:"",lastName:"",line1:"",phone:"",postalCode:"",showError:false,state:""},customErrorMessage:null,customerProfile:null,fetchingLandedCostAbortController:null,hasPaymentError:false,isFetchingLandedCost:false,isFetchingSession:false,partyBillingId:null,partyShippingId:null,shouldInventoryRefund:false,shouldRenderPayInUsdButton:false,skipPaymentIntent:new URLSearchParams(window.location.search).get("skipPaymentIntent")==="0"?false:true,stripe:null,stripeAddressElement:null,stripeAddressEventData:null,stripeAddressUsedWhenAsyncAddressUpdate:null,stripeAddressUsedWhenFetchingLC:null,stripeAddressUsedWhenValidatingAddress:null,stripeBillingAddressElement:null,stripeBillingAddressEventData:null,stripeBillingAddressUsedWhenAsyncAddressUpdate:null,stripeBillingAddressUsedWhenFetchingLC:null,stripeBillingAddressUsedWhenValidatingAddress:null,stripeCustomerSessionClientSecret:null,stripeElements:null,stripeElementsForBillingAddress:null,stripeElementsOptions:null,stripeLinkElement:null,stripeLinkEventData:null,stripeLinkUsedWhenFetchingLC:null,stripePaymentElement:null,stripePaymentEventData:null,stripeShippingSameAsBilling:true,taxId:"",taxIdUsedWhenAsyncAddressUpdate:"",translatedAddress:{address:{},billingAddress:{},firstName:{},lastName:{},name:{}}}})),stripeStoreOnChange=_m.onChange,reset$1=_m.reset,stripeStore=_m.state;var getStripeOptions=function(e){var t=e.clientSecret,r=e.overrideBorderRadius,o=e.overridePrimaryColor,n=e.overrideSecondaryColor,i=e.overrideTheme,a=e.paypalEnabled;var s=o||zonosStore.appearance.colorPrimary;var d=n||zonosStore.appearance.colorSecondary;var c=s&&isDarkColor(s)?"night":"flat";var l=i==="DARK"?"night":"flat";var u=a?["external_paypal"]:[];return{appearance:{labels:"floating",rules:Object.assign({},addressRuleStyle({theme:i||"LIGHT"})),theme:i?l:c,variables:Object.assign(Object.assign({},defaultVariable({borderStyle:r,theme:"LIGHT"})),{colorPrimary:d})},clientSecret:t||undefined,customerSessionClientSecret:stripeStore.stripeCustomerSessionClientSecret||undefined,externalPaymentMethodTypes:__spreadArray([],u,true),locale:localizationStore.selectedLocale}};var stripeStoreCleanupDomesticShippingSession=function(){window.sessionStorage.removeItem("zonos--bigcommerce-domestic-checkout-shipping")};var stripeStoreSaveDomesticShippingSession=function(e){window.sessionStorage.setItem("zonos--bigcommerce-domestic-checkout-shipping",JSON.stringify(e))};var stripeStoreGetDomesticShippingSession=function(){var e=window.sessionStorage.getItem("zonos--bigcommerce-domestic-checkout-shipping");return jsonParse(e)};var initStripeElements=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i;return __generator(this,(function(a){o=stripeStore.clientSecret;if(!stripeStore.stripe){log("Skip. Stripe is not initialized");return[2]}n=getStripeOptions({clientSecret:o,overrideBorderRadius:e===null||e===void 0?void 0:e.overrideBorderRadius,overridePrimaryColor:e===null||e===void 0?void 0:e.overridePrimaryColor,overrideSecondaryColor:e===null||e===void 0?void 0:e.overrideSecondaryColor,overrideTheme:e===null||e===void 0?void 0:e.overrideTheme,paypalEnabled:e===null||e===void 0?void 0:e.paypalEnabled});i=JSON.stringify(n)===JSON.stringify(stripeStore.stripeElementsOptions);if(!stripeStore.stripeElements||!stripeStore.stripeElementsForBillingAddress){stripeStore.stripeElementsForBillingAddress=(t=stripeStore.stripe)===null||t===void 0?void 0:t.elements(n);log("Stripe elements for billing address initialized");stripeStore.stripeElements=(r=stripeStore.stripe)===null||r===void 0?void 0:r.elements(n);stripeStore.stripeElementsOptions=n;log("Stripe elements initialized");return[2]}if(!i){stripeStore.stripeElements.update(n);stripeStore.stripeElementsForBillingAddress.update(n);stripeStore.stripeElementsOptions=n;void stripeStore.stripeElements.fetchUpdates()}log("Stripe elements updated");return[2]}))}))};var stripeStoreReset=function(){sessionStorage.removeItem("zonos--client-secret");reset$1();stripeStore.stripe=window.Zonos.stripe};var checkIsAddressOutdatedForValidation=function(){var e,t,r,o;var n=JSON.stringify((e=stripeStore.stripeAddressUsedWhenValidatingAddress)===null||e===void 0?void 0:e.value)!==JSON.stringify((t=stripeStore.stripeAddressEventData)===null||t===void 0?void 0:t.value);var i=!stripeStore.stripeShippingSameAsBilling&&JSON.stringify((r=stripeStore.stripeBillingAddressEventData)===null||r===void 0?void 0:r.value)!==JSON.stringify((o=stripeStore.stripeBillingAddressUsedWhenValidatingAddress)===null||o===void 0?void 0:o.value);return n||i};var checkIsAddressOutdatedForAsyncAddressUpdate=function(){var e,t,r,o,n,i;var a=JSON.stringify((e=stripeStore.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.value);var s=JSON.stringify((r=stripeStore.stripeAddressUsedWhenAsyncAddressUpdate)===null||r===void 0?void 0:r.value)!==JSON.stringify((o=stripeStore.stripeAddressEventData)===null||o===void 0?void 0:o.value);var d=!stripeStore.stripeShippingSameAsBilling&&JSON.stringify((n=stripeStore.stripeBillingAddressUsedWhenAsyncAddressUpdate)===null||n===void 0?void 0:n.value)!==JSON.stringify((i=stripeStore.stripeBillingAddressEventData)===null||i===void 0?void 0:i.value);var c=stripeStore.taxIdUsedWhenAsyncAddressUpdate!==stripeStore.taxId;var l=stripeStore.companyNameUsedWhenAsyncAddressUpdate!==stripeStore.companyName;return a||s||d||c||l};var stripeStoreBuildAddressForPartyCreate=function(e){var t=e.address,r=e.firstName,o=e.lastName,n=e.name,i=e.phone;var a=extractName({firstName:r,lastName:o,name:n}),s=a.firstName,d=a.lastName;if(!s||!d){void sendErrorLog({endpoint:"PARTY_CREATE_NO_NAME_FOUND",errors:["No name found"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,firstName:r,lastName:o,name:n}})}if(!i){void sendErrorLog({endpoint:"PARTY_CREATE_NO_PHONE_FOUND",errors:["No phone found"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,phone:i}})}return{city:t.city,country:t.country,firstName:s,lastName:d,line1:t.line1,line2:t.line2,phone:i||"",postal_code:t.postal_code,state:t.state}};var stripeStoreAsyncAddressUpdate=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d,c,l,u;return __generator(this,(function(v){switch(v.label){case 0:if(!((e=stripeStore.stripeAddressEventData)===null||e===void 0?void 0:e.complete)||!stripeStore.stripeShippingSameAsBilling&&!((t=stripeStore.stripeBillingAddressEventData)===null||t===void 0?void 0:t.complete)||!stripeStore.stripeBillingAddressEventData){return[2,{partiesCreated:false}]}if(!cartStore.landedCostData){return[2,{partiesCreated:false}]}n=(r=cartStore.landedCostData.find(Boolean))===null||r===void 0?void 0:r.landedCost.rootId;if(!n){void sendErrorLog({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId}});return[2,{partiesCreated:false}]}i=checkIsAddressOutdatedForAsyncAddressUpdate();if(!i){return[2,{partiesCreated:false}]}a=stripeStoreBuildAddressForPartyCreate({address:stripeStore.stripeAddressEventData.value.address,firstName:stripeStore.stripeAddressEventData.value.firstName,lastName:stripeStore.stripeAddressEventData.value.lastName,name:stripeStore.stripeAddressEventData.value.name,phone:stripeStore.stripeAddressEventData.value.phone});s=stripeStore.stripeShippingSameAsBilling?a:stripeStoreBuildAddressForPartyCreate({address:stripeStore.stripeBillingAddressEventData.value.address,firstName:stripeStore.stripeBillingAddressEventData.value.firstName,lastName:stripeStore.stripeBillingAddressEventData.value.lastName,name:stripeStore.stripeBillingAddressEventData.value.name,phone:stripeStore.stripeBillingAddressEventData.value.phone});d=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,handleFetch("/api/zonos-elements/create-parties",{body:{address:a,billingAddress:s,companyName:stripeStore.companyName,email:((o=stripeStore.stripeLinkEventData)===null||o===void 0?void 0:o.value.email)||"",isTest:d,rootId:n,taxId:stripeStore.taxId},method:"POST"})];case 1:c=v.sent(),l=c.errors,u=c.json;if(l.length||!u){logError("Error occurs when creating parties",JSON.stringify(l,null,2));void sendErrorLog({endpoint:"PF_PARTY_CREATE_FAILED",errors:["Failed to create parties"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,errors:l,json:u}});return[2,{partiesCreated:false}]}stripeStore.companyNameUsedWhenAsyncAddressUpdate=stripeStore.companyName;stripeStore.stripeAddressUsedWhenAsyncAddressUpdate=stripeStore.stripeAddressEventData;stripeStore.stripeBillingAddressUsedWhenAsyncAddressUpdate=stripeStore.stripeBillingAddressEventData;stripeStore.taxIdUsedWhenAsyncAddressUpdate=stripeStore.taxId;stripeStore.partyBillingId=u.billToPartyId;stripeStore.partyShippingId=u.shipToPartyId;return[2,{partiesCreated:true}]}}))}))};var buildAddressForLCPrefetch=function(e){return{countryCode:e.address.country,postalCode:e.address.postal_code,state:e.address.state}};var checkIsAddressOutdatedForLCPrefetch=function(){var e,t;var r=JSON.stringify((e=stripeStore.stripeLinkUsedWhenFetchingLC)===null||e===void 0?void 0:e.value)!==JSON.stringify((t=stripeStore.stripeLinkEventData)===null||t===void 0?void 0:t.value);var o=stripeStore.stripeAddressEventData&&JSON.stringify(buildAddressForLCPrefetch(stripeStore.stripeAddressEventData.value))!==JSON.stringify(stripeStore.stripeAddressUsedWhenFetchingLC);var n=!stripeStore.stripeShippingSameAsBilling&&stripeStore.stripeBillingAddressEventData&&JSON.stringify(buildAddressForLCPrefetch(stripeStore.stripeBillingAddressEventData.value))!==JSON.stringify(stripeStore.stripeBillingAddressUsedWhenFetchingLC);return r||o||n};var isPrefetchInfoOutdated=function(){var e;var t=cartStore.landedCostData&&((e=cartStore.landedCostData.find(Boolean))===null||e===void 0?void 0:e.subtotals.items)!==cartStore.subtotal;var r=checkIsAddressOutdatedForLCPrefetch();log("isPrefetchInfoOutdated","info",{isAddressOutdated:r});return!cartStore.landedCostData&&!stripeStore.isFetchingLandedCost||r||t};var getCountryField=function(e){var t,r;var o=(t=zonosStore.genericSettings)===null||t===void 0?void 0:t.countryFields;var n=(r=zonosStore.genericSettings)===null||r===void 0?void 0:r.stripeCountryFieldLabels;var i=n&&e in n?n[e]:null;var a=o&&e in o?o[e]:null;if(cartStore.addressFormRenderType==="stripe"){return i||a}return a};var isAddressReadyToRequestLandedCost=function(){var e,t,r,o;var n=!!((e=stripeStore.stripeLinkEventData)===null||e===void 0?void 0:e.complete);var i=!!((t=stripeStore.stripeAddressEventData)===null||t===void 0?void 0:t.complete);var a=stripeStore.stripeShippingSameAsBilling?i:!!((r=stripeStore.stripeBillingAddressEventData)===null||r===void 0?void 0:r.complete);var s=((o=stripeStore.stripeAddressEventData)===null||o===void 0?void 0:o.value.address.country)||"US";var d=getCountryField(s);if(i&&a&&n){return true}if(!d||!stripeStore.stripeAddressEventData){return i&&a&&n}var c=stripeStore.stripeAddressEventData.value.address.line1.length>0;var l=stripeStore.stripeAddressEventData.value.firstName&&stripeStore.stripeAddressEventData.value.lastName;var u=!d.stateRequired||d.stateRequired&&stripeStore.stripeAddressEventData.value.address.state.length>0;var v=!d.zipRequired||d.zipRequired&&stripeStore.stripeAddressEventData.value.address.postal_code.length>=3;var S=stripeStore.stripeAddressEventData.value.phone&&stripeStore.stripeAddressEventData.value.phone.length>0;return n&&l&&c&&u&&v&&S};var stripeCalculateLandedCost=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d,c,l;return __generator(this,(function(u){switch(u.label){case 0:t=new AbortController;stripeStore.fetchingLandedCostAbortController=t;cartStoreResetCartItems();return[4,calculateLandedCostNormalized(t)];case 1:r=u.sent(),o=r.checkoutSessionWorkflow,n=r.errors,i=r.itemCreateWorkflow,a=r.landedCostCalculateWorkflow,s=r.partyCreateWorkflow,d=r.shipmentRatingCalculateWorkflow;cartStore.customQuotingError=((e=n===null||n===void 0?void 0:n.find((function(e){var t;return((t=e.extensions)===null||t===void 0?void 0:t.ruleMessageType)==="CUSTOM"})))===null||e===void 0?void 0:e.message)||null;cartStore.shippingData=sortServiceLevelOptionsByAmount((d===null||d===void 0?void 0:d.filter(Boolean))||[]);cartStoreCheckItemRestrictions(i);stripeStore.fetchingLandedCostAbortController=null;cartStore.partiesData=(s===null||s===void 0?void 0:s.filter(Boolean))||[];cartStore.landedCostData=(o===null||o===void 0?void 0:o.map((function(e){var t=a===null||a===void 0?void 0:a.find((function(t){return(t===null||t===void 0?void 0:t.id)===e.landedCostId}));if(!t){return null}return Object.assign(Object.assign({},e),{landedCost:t})})).filter(Boolean))||[];c=storageStore.checkoutSessionId;if(o===null||o===void 0?void 0:o.length){void trackConversionEvent({checkoutSessionId:c,eventName:"checkout_quoteReceived"})}l=cartStore.promoCodeApplied&&!cartStore.landedCostData.find((function(e){var t;return(t=e.landedCost.appliedAdjustments)===null||t===void 0?void 0:t.find((function(e){return e.type==="PROMO_CODE"}))}));cartStore.promoCodeError=l;if(!l){sessionStorage.setItem("zonos--promo-code",cartStore.promoCode)}return[2]}}))}))};var stripeStorePrefetchLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a,s,d,c,l,u,v,S,p;return __generator(this,(function(f){switch(f.label){case 0:i=(e===null||e===void 0?void 0:e.retries)||0;a=!!(e===null||e===void 0?void 0:e.applyingPromocode);s=isPrefetchInfoOutdated();d=isAddressReadyToRequestLandedCost();if(!d){return[2,{isRequestNotReady:true}]}if(s){(t=stripeStore.fetchingLandedCostAbortController)===null||t===void 0?void 0:t.abort();stripeStore.fetchingLandedCostAbortController=null}if(!s&&!a){return[2,{isRequestNotReady:false}]}if(i){stripeStore.isFetchingLandedCost=false;setTimeout((function(){stripeStore.isFetchingLandedCost=true}),300)}else{stripeStore.isFetchingLandedCost=true}if(stripeStore.stripeAddressEventData){stripeStore.stripeAddressUsedWhenFetchingLC={countryCode:stripeStore.stripeAddressEventData.value.address.country,postalCode:stripeStore.stripeAddressEventData.value.address.postal_code,state:stripeStore.stripeAddressEventData.value.address.state}}if(stripeStore.stripeBillingAddressEventData){stripeStore.stripeBillingAddressUsedWhenFetchingLC={countryCode:stripeStore.stripeBillingAddressEventData.value.address.country,postalCode:stripeStore.stripeBillingAddressEventData.value.address.postal_code,state:stripeStore.stripeBillingAddressEventData.value.address.state}}if(stripeStore.stripeLinkEventData){stripeStore.stripeLinkUsedWhenFetchingLC=Object.assign({},stripeStore.stripeLinkEventData)}f.label=1;case 1:f.trys.push([1,3,,7]);cartStoreResetCartItems();return[4,stripeCalculateLandedCost()];case 2:f.sent();c=(r=cartStore.shippingData)===null||r===void 0?void 0:r.find(Boolean);l=(o=cartStore.landedCostData)===null||o===void 0?void 0:o.find((function(e){return e.landedCost.shipmentRating.id===(c===null||c===void 0?void 0:c.id)}));u=!!l?l.subtotals:null;if(u){cartStoreApplySubtotals({method:(l===null||l===void 0?void 0:l.landedCost.method)||"DDP",subtotals:u})}return[3,7];case 3:v=f.sent();cartStore.landedCostData=[];cartStore.shippingData=[];S=["The landed cost calculation request was aborted to initiate a new one."];if(!(v instanceof Error&&v.message&&!S.includes(v.message)))return[3,6];if(!(i<1))return[3,5];return[4,stripeStorePrefetchLandedCost(Object.assign(Object.assign({},e),{retries:(i||0)+1}))];case 4:f.sent();return[2,{isRequestNotReady:false}];case 5:p=(n=stripeStore.stripeAddressEventData)===null||n===void 0?void 0:n.value;void sendErrorLog({endpoint:"Failed to fetch landed cost (".concat(i," retries)"),errors:[v.message],metadata:{cartId:window.Zonos.cartId,shipToAddress:p}});f.label=6;case 6:logError(v);return[3,7];case 7:stripeStore.isFetchingLandedCost=false;return[2,{isRequestNotReady:false}]}}))}))};var stripeStoreApplyPromoCode=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o;return __generator(this,(function(n){switch(n.label){case 0:return[4,stripeStorePrefetchLandedCost({applyingPromocode:true})];case 1:n.sent();if(cartStore.step==="payment"){cartStorePreviousStep()}return[4,stripeStoreAsyncAddressUpdate()];case 2:n.sent();r=(e=cartStore.shippingData)===null||e===void 0?void 0:e.find(Boolean);o=(t=cartStore.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCost.id===(r===null||r===void 0?void 0:r.id)}));if(!r||!o){return[2]}return[4,cartStoreUpdateSelectedShippingOption({applySubtotalsOnly:false,landedCostId:o.landedCostId,selectedShippingOption:r})];case 3:n.sent();return[2]}}))}))};var stripeStoreResetPromoCode=function(){cartStore.promoCode="";sessionStorage.removeItem("zonos--promo-code");cartStore.promoCodeError=false;cartStore.promoCodeApplied=false};var stripeStoreRemovePromoCode=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:if(cartStore.step==="payment"){cartStorePreviousStep()}stripeStoreResetPromoCode();return[4,stripeStoreApplyPromoCode()];case 1:e.sent();return[2]}}))}))};var stripeStoreMessageBasedOnStatus=function(e){var t=[];var r=true;var o=window.Zonos.isCollect;switch(e){case"succeeded":{t=[translate("Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us."),"",translate("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time.")];if(o){t=[translate("Thank you for submitting your payment. We appreciate your prompt attention."),"",translate("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.")]}r=false;break}case"requires_capture":case"processing":{t=[translate("Payment processing. We'll update you when payment is received.")];r=false;break}case"requires_payment_method":{t=[translate("Payment failed. Please try another payment method.")];if(o){t=[translate("Payment failed. Please reload the page and try another payment method.")]}break}case"requires_action":{r=false;t=[translate("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]}default:{t=[translate("Something went wrong.")];break}}return{isError:r,messages:t}};var stripeStoreHandleInventoryCheck=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s,d,s;return __generator(this,(function(c){switch(c.label){case 0:r=zonosStore.checkoutSettings.onInventoryCheck;o=!!((t=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||t===void 0?void 0:t.value);if(!(window.Zonos.isLegacyCheckout&&window.Zonos.cartData&&o))return[3,2];return[4,handleFetch("/api/zonos-elements/legacy/inventory-check",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:n=c.sent(),i=n.errors,a=n.json;if(i.length||!a){logError("Error occurs when handling inventory refund","warn",JSON.stringify(i));return[2,null]}if(!a.available||a.status===204){return[2,translate("The item you're looking for is currently unavailable in our inventory. Please check back later or contact support for assistance with availability.")]}if(a.available||a.status===200){stripeStore.shouldInventoryRefund=true;return[2,null]}return[2,null];case 2:if(typeof r!=="function"){return[2,null]}c.label=3;case 3:c.trys.push([3,5,,6]);return[4,r({items:cartStore.items})];case 4:s=c.sent();return[2,s];case 5:d=c.sent();s=d instanceof Error?d.message:"Unknown error";void sendErrorLog({endpoint:"onInventoryCheck",errors:["cartId: ".concat(window.Zonos.cartId," - ").concat(s)],metadata:{cartId:window.Zonos.cartId,href:window.location.href,items:cartStore.items}});throw d;case 6:return[2]}}))}))};var stripeStoreHandleInventoryRefund=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r;return __generator(this,(function(o){switch(o.label){case 0:r=!!((t=(e=window.Zonos.cartData)===null||e===void 0?void 0:e.metadata.find((function(e){return e.key==="referenceId"})))===null||t===void 0?void 0:t.value);if(!window.Zonos.isLegacyCheckout||!window.Zonos.cartData||!r){return[2]}return[4,handleFetch("/api/zonos-elements/legacy/inventory-refund",{body:{cartData:window.Zonos.cartData},method:"POST"})];case 1:o.sent();return[2]}}))}))};var stripeStoreRetrievePayment=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,c;var l=e.clientSecret,u=e.storybookForceStatus;return __generator(this,(function(e){switch(e.label){case 0:if(u){t=stripeStoreMessageBasedOnStatus(u),r=t.isError,o=t.messages;return[2,{error:r,messages:o}]}n=l||stripeStore.clientSecret;if(!stripeStore.stripe||!n){logError("Failed to retrieve payment intent. Stripe is not initialized");return[2,{error:true,message:[translate("Something went wrong.")]}]}return[4,stripeStore.stripe.retrievePaymentIntent(n)];case 1:i=e.sent().paymentIntent;a=i===null||i===void 0?void 0:i.status;s=stripeStoreMessageBasedOnStatus(a),d=s.isError,c=s.messages;return[2,{error:d,messages:c,paymentIntentId:i===null||i===void 0?void 0:i.id,paymentMethod:i===null||i===void 0?void 0:i.payment_method,status:a}]}}))}))};var stripeStoreConfirmPayment=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,r,o,n,i,a,s,d,c,l,u,v;return __generator(this,(function(S){switch(S.label){case 0:o=!!((t=stripeStore.stripePaymentEventData)===null||t===void 0?void 0:t.complete);n=stripeStore.stripeElements;i=stripeStore.stripe;a=stripeStore.clientSecret;stripeStore.customErrorMessage=null;if(!((r=cartStore.selectedLandedCost)===null||r===void 0?void 0:r.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,validateCheckoutSession()];case 1:s=S.sent();if(!s.valid){stripeStore.customErrorMessage=s.errorMessage;throw new Error(s.errorMessage)}d=storageStore.checkoutSessionId;if(!(i&&n&&o&&a&&d))return[3,3];c=new URL(window.location.href);c.searchParams.set("payment_intent_client_secret",a);c.searchParams.set("zonosCheckoutSessionId",d);void trackConversionEvent({checkoutSessionId:d,eventName:"checkout_paymentInfoCompleted"});return[4,i.confirmPayment({confirmParams:{return_url:c.toString()},elements:n,redirect:"if_required"})];case 2:l=S.sent(),u=l.error,v=l.paymentIntent;log("Payment intent confirmed","info",{error:u,paymentIntent:v});if((v===null||v===void 0?void 0:v.status)==="requires_action"){throw new Error(translate("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction."))}if(u){if(u.type==="card_error"||u.type==="validation_error"){throw new Error(u.message)}if(u.type==="invalid_request_error"){if(u.code==="payment_intent_unexpected_state"){return[2]}}throw new Error("An unexpected error occurred.")}if(v.status==="requires_payment_method"){throw new Error(translate("Payment failed. Please try another payment method."))}S.label=3;case 3:return[2]}}))}))};var getCheckoutSessionBody=function(){var e;var t=cartStore.items.reduce((function(e,t){return e+t.amount*t.quantity}),0);var r=storageStore.enabledVariantTestKeys||[];var o={adjustmentsAmount:cartStore.adjustments.reduce((function(e,t){return e+t.amount}),0),cartId:window.Zonos.cartId,currency:((e=cartStore.items.find(Boolean))===null||e===void 0?void 0:e.currencyCode)||"",customerAuthenticationToken:cartStore.customerAuthenticationToken||undefined,isCollect:window.Zonos.isCollect,itemsAmount:t,metadata:[{key:"language",value:localizationStore.selectedLocale}],presentmentCountryCode:localizationStore.selectedCountryCode,skipPaymentIntent:stripeStore.skipPaymentIntent,varianceTestInput:r};return o};var stripeStoreGetPaymentIntent=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n;return __generator(this,(function(i){switch(i.label){case 0:if(!storageStore.checkoutSessionId){void sendErrorLog({endpoint:"Error creating payment intent",errors:["No checkout session id found when retrieving payment intent"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId}});cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[2]}return[4,handleFetch("/api/zonos-elements/create-payment-intent",{body:{checkoutSessionId:storageStore.checkoutSessionId},method:"POST"})];case 1:t=i.sent(),r=t.errors,o=t.json;n=(e=o===null||o===void 0?void 0:o.checkoutSessionPaymentIntentCreate)===null||e===void 0?void 0:e.clientSecret;if(r.length||!n){logError("Error occurs when getting payment intent",JSON.stringify(r,null,2));void sendErrorLog({endpoint:"Error creating payment intent",errors:r.map((function(e){return e.message})),metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,clientSecret:n}});cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[2]}cartStoreSetCheckoutSession(o.checkoutSessionPaymentIntentCreate);return[2]}}))}))};var stripeStoreInitCheckoutSession=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r,o,n,i,a,s;return __generator(this,(function(d){switch(d.label){case 0:if(!localizationStore.targetCurrency){logError("Failed to create checkout session - missing localizationStore.targetCurrency");return[2,false]}stripeStore.isFetchingSession=true;r=getCheckoutSessionBody();log("Checkout session body","info",r);return[4,handleFetch("/api/zonos-elements/create-checkout-session",{body:r,method:"POST"})];case 1:o=d.sent(),n=o.errors,i=o.json;stripeStore.isFetchingSession=false;if(n.length||!i){a=(e=n.find((function(e){return e.message})))===null||e===void 0?void 0:e.message;if(Array.isArray(a)&&a.some((function(e){return e.message==="Cart is expired."}))){throw new Error("Cart is expired.")}logError("Error occurred when creating checkout session",JSON.stringify(n,null,2));return[2,false]}s=i.checkoutSessionCreate;cartStoreSetCheckoutSession(s);cartStoreApplySubtotals({method:((t=s.landedCost)===null||t===void 0?void 0:t.method)||"DDP",subtotals:s.subtotals});log("Exchange rate updated for cart items (checkout session create)","info",cartStore.exchangeRate);log("done-init-checkout-session");return[2,true]}}))}))};var stripeStoreUpdateCheckoutSessionBaseCurrency=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,r;return __generator(this,(function(o){switch(o.label){case 0:e=storageStore.checkoutSessionId;if(!e){logError("Failed to update checkout session base currency");return[2,false]}if(zonosStore.checkoutSettings.allowedSettlementCurrencies==="LOCAL"){log('allowedSettlementCurrencies: "LOCAL". Skip updating checkout session base currency');return[2,true]}return[4,handleFetch("/api/zonos-elements/update-checkout-session-base-currency",{body:{checkoutSessionId:e,currencyCode:stripeStore.checkoutSettlementCurrency},method:"POST"})];case 1:t=o.sent().json;r=t===null||t===void 0?void 0:t.checkoutSessionBaseCurrencyUpdate.subtotals.presentmentCurrencyCode;if(!t||r!==stripeStore.checkoutSettlementCurrency){logError("Failed to update checkout session base currency");return[2,false]}log('Updated checkout session to settlement currency "'.concat(r,'".'));return[2,true]}}))}))};var stripeStoreUpdateCheckoutSession=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n;var i=e.adjustmentsAmount,a=e.cartId,s=e.currency,d=e.id,c=e.itemsAmount,l=e.landedCostId,u=e.presentmentCountryCode;return __generator(this,(function(e){switch(e.label){case 0:t=storageStore.enabledVariantTestKeys||[];return[4,handleFetch("/api/zonos-elements/update-checkout-session",{body:{adjustmentsAmount:i,billToPartyId:stripeStore.partyBillingId,cartId:a,currency:s,customerAuthenticationToken:cartStore.customerAuthenticationToken||undefined,id:d,itemsAmount:c,landedCostId:l,metadata:[{key:"language",value:localizationStore.selectedLocale}],presentmentCountryCode:u,shipToPartyId:stripeStore.partyShippingId,skipPaymentIntent:stripeStore.skipPaymentIntent,varianceTestInput:t},method:"POST"})];case 1:r=e.sent(),o=r.errors,n=r.json;if(o.length||!n){logError("Error occurs when updating checkout session",JSON.stringify(o,null,2));return[2,{errors:o,json:n}]}return[2,{errors:[],json:n}]}}))}))};var buildTranslatedAddress=function(e){var t,r,o,n,i,a;var s=e.currentAddress,d=e.translatedAddressResult;var c={};if(!d){return c}var l=d.city,u=d.line1,v=d.line2,S=d.name,p=d.postal_code,f=d.state;if(s.city&&l){c.city=(t={},t[s.city]=l,t)}if(s.line1&&u){c.line1=(r={},r[s.line1]=u,r)}if(s.line2&&v){c.line2=(o={},o[s.line2]=v,o)}if(s.postal_code&&p){c.postal_code=(n={},n[s.postal_code]=p,n)}if(s.state&&f){c.state=(i={},i[s.state]=f,i)}if(s.name&&S){c.name=(a={},a[s.name]=S,a)}return c};var stripeStoreTranslateAddressToLatin=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,c,l,u;var v=e.addressInvalidCharactersList,S=e.billingAddressInvalidCharactersList;return __generator(this,(function(e){switch(e.label){case 0:i=buildTranslateRequest({addressInvalidCharactersList:v,billingAddressInvalidCharactersList:S,stripeAddressEventData:stripeStore.stripeAddressEventData,stripeBillingAddressEventData:stripeStore.stripeBillingAddressEventData,stripeShippingSameAsBilling:stripeStore.stripeShippingSameAsBilling});if(!i){stripeStore.translatedAddress={address:{},billingAddress:{}};return[2]}a=checkIsAddressOutdatedForValidation();if(!a){return[2]}return[4,handleFetch("/api/zonos-elements/validate-address",{body:i,method:"POST"})];case 1:s=e.sent(),d=s.errors,c=s.json;if(d.length||!c){logError("Error occurs when translating address to latin",JSON.stringify(d,null,2));stripeStore.translatedAddress={address:{},billingAddress:{}};return[2]}stripeStore.stripeAddressUsedWhenValidatingAddress=stripeStore.stripeAddressEventData;stripeStore.stripeBillingAddressUsedWhenValidatingAddress=stripeStore.stripeBillingAddressEventData;l=(t=stripeStore.stripeAddressEventData)===null||t===void 0?void 0:t.value.address;u=(r=stripeStore.stripeBillingAddressEventData)===null||r===void 0?void 0:r.value.address;stripeStore.translatedAddress={address:l?buildTranslatedAddress({currentAddress:Object.assign(Object.assign({},l),{name:(o=stripeStore.stripeAddressEventData)===null||o===void 0?void 0:o.value.name}),translatedAddressResult:c.address||null}):{},billingAddress:!stripeStore.stripeShippingSameAsBilling?buildTranslatedAddress({currentAddress:Object.assign(Object.assign({},u),{name:(n=stripeStore.stripeBillingAddressEventData)===null||n===void 0?void 0:n.value.name}),translatedAddressResult:c.billingAddress||null}):{}};return[2]}}))}))};stripeStoreOnChange("clientSecret",(function(e){if(e&&stripeStore.stripe){sessionStorage.setItem("zonos--client-secret",e)}if(!e){sessionStorage.removeItem("zonos--client-secret")}}));var _o=createStore((function(){return{addressFormRenderType:"stripe",adjustmentTotal:0,adjustments:[],checkoutSession:null,checkoutSessionTimeoutShow:false,checkoutTimeoutInterval:null,currency:"USD",customQuotingError:null,customerAuthenticationToken:null,displayBaseCurrency:false,dutiesTaxesFees:null,dutiesTaxesFeesEstimate:null,error:null,exchangeRate:null,externalConfirmationPageURL:null,inventoryCheckErrorMessage:null,isSelectedShippingAboveDeminimis:false,isSelectedShippingGuarantee:false,isStagingMode:getIsStagingMode(),items:[],landedCostData:null,landedCostMethod:"DDP",partiesData:[],promoCode:sessionStorage.getItem("zonos--promo-code")||"",promoCodeApplied:!!sessionStorage.getItem("zonos--promo-code"),promoCodeError:false,restrictedItems:[],selectedLandedCost:null,selectedShippingOption:null,selectedShippingOptionExpectedDate:"",selectedShippingOptionTransitTime:"",shipping:0,shippingData:null,shouldHideDiscountInput:false,step:"customer-info",subtotal:0,tabItems:{"customer-info":{index:1,isDone:false,label:"Customer",value:"customer-info"},shipping:{index:2,isDone:false,label:"Shipping",value:"shipping"},payment:{index:3,isDone:false,label:"Payment",value:"payment"}},total:0}})),cartStoreOnChange=_o.onChange,reset=_o.reset,cartStore=_o.state;var getTransitUnit=function(e){switch(e){case"DAYS":return translate("days");case"WEEKS":return translate("weeks");case"BUSINESS_DAYS":default:return translate("business days")}};var cartStoreGetShippingTransitInfo=function(e){var t;var r=(t=e.shippingProfile)===null||t===void 0?void 0:t.transitTime;if(!(r===null||r===void 0?void 0:r.min)||!(r===null||r===void 0?void 0:r.max)||!(r===null||r===void 0?void 0:r.type)){return null}return{maxTransit:r.max,minTransit:r.min,unit:getTransitUnit(r.type)}};var getMatchItem=function(e){var t=e.item1,r=e.item2;if(!t||!r){return false}return r.sku&&t.sku&&t.sku===r.sku||r.description&&t.description&&t.description===r.description||t.name&&r.name&&t.name===r.name};var cartStoreCheckItemRestrictions=function(e){log("Checking item restrictions");var t=e.map((function(e){if(!e.restriction){return null}var t=e.restriction;var r=cartStore.items.find((function(t){return getMatchItem({item1:t,item2:e})}));return Object.assign(Object.assign({matchedItem:r},e),{restriction:t})})).filter(Boolean);cartStore.restrictedItems=t;cartStore.items=cartStore.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:!!t.find((function(t){return getMatchItem({item1:t,item2:e})}))})}));return{cartItems:cartStore.items,restrictedItems:t}};var cartStoreReset=function(){storageStore.checkoutSessionId=null;reset()};var cartStoreUpdateToErrorState=function(e){var t=e.messages,r=e.title;cartStoreReset();stripeStoreReset();cartStore.step="error";cartStore.error={messages:t,title:r}};var cartStoreApplySubtotals=function(e){var t=e.dutiesTaxesFeesEstimate,r=e.method,o=e.subtotals;cartStore.exchangeRate=o.exchangeRate;cartStore.adjustmentTotal=o.adjustments;cartStore.dutiesTaxesFees=r==="DAP"?null:o.landedCostTotal;cartStore.subtotal=o.items;cartStore.total=o.total;cartStore.currency=o.presentmentCurrencyCode;cartStore.dutiesTaxesFeesEstimate=t||null};var cartStoreHasOneEligibleItem=function(){var e=cartStore.items.filter((function(e){return e.amount>0}));return!!e.find((function(e){return!e.isRestricted}))};var cartStoreSetCheckoutSession=function(e){var t,r,o,n,i;stripeStore.clientSecret=e.clientSecret;stripeStore.stripeCustomerSessionClientSecret=e.customerSessionClientSecret;stripeStore.customerProfile=e.customerProfile;cartStore.checkoutSession=e;if(!e.id){void sendErrorLog({endpoint:"cartStoreSetCheckoutSession",errors:["Missing checkout session id in checkout session"],metadata:{allLogs:allLogs,checkoutSession:e}})}if(e.id){storageStore.checkoutSessionId=e.id}var a=filterValidTests(e.varianceTestResults||[]);storageStoreSetEnabledVariantTestKeys(a);var s=((o=(r=(t=cartStore.checkoutSession)===null||t===void 0?void 0:t.metadata)===null||r===void 0?void 0:r.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||o===void 0?void 0:o.value)||((i=(n=window.Zonos.cartData)===null||n===void 0?void 0:n.metadata.find((function(e){return(e===null||e===void 0?void 0:e.key)==="externalConfirmationPageURL"})))===null||i===void 0?void 0:i.value)||null;if(s){log("Found externalConfirmationPageURL: ".concat(s));cartStore.externalConfirmationPageURL=s}};var cartStoreReCalculateTotal=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a;var s=e.adjustmentsAmount,d=e.cartId,c=e.currency,l=e.dutiesTaxesFeesEstimate,u=e.itemsAmount,v=e.landedCostId,S=e.shouldInitSessionOnFailure;return __generator(this,(function(e){switch(e.label){case 0:if(v&&cartStore.selectedLandedCost){r=cartStore.selectedLandedCost.subtotals;cartStoreApplySubtotals({dutiesTaxesFeesEstimate:l,method:cartStore.landedCostMethod,subtotals:r});log("Exchange rate updated for cart items (landed cost subtotal)","info",cartStore.exchangeRate)}if(!storageStore.checkoutSessionId){log("Could not update cart total without checkout session id","info");return[2,false]}return[4,stripeStoreUpdateCheckoutSession({adjustmentsAmount:s,billToPartyId:stripeStore.partyBillingId,cartId:d,currency:c,id:storageStore.checkoutSessionId,itemsAmount:u,landedCostId:v,presentmentCountryCode:localizationStore.selectedCountryCode,shipToPartyId:stripeStore.partyShippingId,varianceTestInput:storageStore.enabledVariantTestKeys||[]})];case 1:o=e.sent(),n=o.errors,i=o.json;if(!(n.length>0||!i))return[3,4];logError("Error occurs when updating checkout session.");if(!S)return[3,3];log("Initiating checkout session on failure","info");return[4,stripeStoreInitCheckoutSession()];case 2:a=e.sent();log("stripeStoreInitCheckoutSession: ".concat(a));if(!a){cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[2,false]}return[2,true];case 3:return[2,false];case 4:if(!v){cartStoreApplySubtotals({method:((t=i.checkoutSessionUpdate.landedCost)===null||t===void 0?void 0:t.method)||"DDP",subtotals:i.checkoutSessionUpdate.subtotals});log("Exchange rate updated for cart items (checkout session update)","info",cartStore.exchangeRate)}cartStoreSetCheckoutSession(i.checkoutSessionUpdate);return[2,true]}}))}))};var cartStoreGetMethod=function(e){var t,r,o;if(e.method==="DAP"&&((r=(t=zonosStore.genericSettings)===null||t===void 0?void 0:t.domesticCountries)===null||r===void 0?void 0:r.includes(((o=stripeStore.stripeAddressEventData)===null||o===void 0?void 0:o.value.address.country)||"US"))){return"DDP"}if(e.method==="DAP"&&e.remittance.length&&e.landedCostGuaranteeCode==="ZONOS"){return"DDP"}return e.method};var cartStoreUpdateSelectedShippingOption=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n,i,a,s,d,c,l,u,v,S,p,f,h,m,g,y,w,C,b,A,O,_;var k=e.applySubtotalsOnly,I=e.landedCostId,E=e.selectedShippingOption;return __generator(this,(function(e){switch(e.label){case 0:log("Updating selected shipping option","info",{landedCostId:I,selectedShippingOption:E});cartStore.selectedShippingOption=E;v=cartStoreGetShippingTransitInfo(cartStore.selectedShippingOption);if(v){S=v.maxTransit,p=v.minTransit,f=v.unit;cartStore.selectedShippingOptionTransitTime="".concat(p,"-").concat(S," ").concat(f)}else{cartStore.selectedShippingOptionTransitTime=""}h=(t=cartStore.landedCostData)===null||t===void 0?void 0:t.find((function(e){return e.landedCostId===I}));cartStore.selectedLandedCost=h||null;if(!h){return[2,false]}m=((r=h.landedCost.amountSubtotals)===null||r===void 0?void 0:r.landedCostTotal)||0;g=h.subtotals.exchangeRate.rate;y=m*g;if(y){log("DAP quote, using estimate: ".concat(y),"info")}cartStore.landedCostMethod=cartStoreGetMethod(h.landedCost);cartStore.shipping=h.subtotals.shipping;w=((o=h===null||h===void 0?void 0:h.landedCost)===null||o===void 0?void 0:o.landedCostGuaranteeCode)==="ZONOS";C=!!((i=(n=h===null||h===void 0?void 0:h.landedCost)===null||n===void 0?void 0:n.deMinimis)===null||i===void 0?void 0:i.find((function(e){return["DUTY","TAX"].includes(e.type)&&e.threshold==="ABOVE"})));cartStore.isSelectedShippingAboveDeminimis=C;cartStore.isSelectedShippingGuarantee=w;b=false;if(!k)return[3,1];A=h.subtotals;cartStoreApplySubtotals({dutiesTaxesFeesEstimate:y,method:cartStore.landedCostMethod,subtotals:A});log("Exchange rate updated for cart items (landed cost subtotal)","info",cartStore.exchangeRate);b=true;return[3,3];case 1:return[4,cartStoreReCalculateTotal({adjustmentsAmount:cartStore.adjustmentTotal,billToPartyId:stripeStore.partyBillingId,cartId:window.Zonos.cartId,dutiesTaxesFeesEstimate:y,landedCostId:(a=h.landedCost)===null||a===void 0?void 0:a.id,shipToPartyId:stripeStore.partyShippingId,varianceTestInput:storageStore.enabledVariantTestKeys||[]})];case 2:b=e.sent();e.label=3;case 3:O=(s=cartStore.items.find(Boolean))===null||s===void 0?void 0:s.currencyCode;_=((d=stripeStore.stripeAddressEventData)===null||d===void 0?void 0:d.value.address.country)||"US";stripeStore.shouldRenderPayInUsdButton=O==="USD"&&zonosStore.checkoutSettings.allowedSettlementCurrencies==="LOCAL_AND_USD"&&((c=cartStore.checkoutSession)===null||c===void 0?void 0:c.subtotals.presentmentCurrencyCode)!=="USD"&&!!((u=(l=zonosStore.genericSettings)===null||l===void 0?void 0:l.usdSettlementCountryEnabled)===null||u===void 0?void 0:u.includes(_));return[2,b]}}))}))};var cartStoreStartCheckoutInterval=function(e){var t=e.isPreview,r=e.sessionTimeout;if(t){return}var o=new URLSearchParams(window.location.search).get("zonosCheckoutTimeout");var n=o&&!isNaN(parseInt(o,10))?parseInt(o,10):r;log("==START CHECKOUT TIMEOUT - ".concat(n,"=="));cartStore.checkoutTimeoutInterval=setTimeout((function(){cartStore.checkoutSessionTimeoutShow=true}),n)};var cartStoreClearCheckoutInterval=function(){if(cartStore.checkoutTimeoutInterval){clearTimeout(cartStore.checkoutTimeoutInterval);cartStore.checkoutTimeoutInterval=null}};var getCartItemToUse=function(e){return e.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}))};var cartStoreResetCartItems=function(){cartStore.items=cartStore.items.map((function(e){return Object.assign(Object.assign({},e),{isRestricted:false})}));cartStore.restrictedItems=[]};var cartStoreUpdateItems=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,r,o,n;var i=e.adjustments,a=e.cartItems,s=e.landedCostId,d=e.shouldInitSessionOnFailure,c=d===void 0?true:d;return __generator(this,(function(e){switch(e.label){case 0:cartStore.adjustments=i;cartStore.items=getCartItemToUse(a);r=(t=a.find(Boolean))===null||t===void 0?void 0:t.currencyCode;o=a.reduce((function(e,t){return e+t.amount*t.quantity}),0);n=i.reduce((function(e,t){return e+t.amount}),0);if(!r||!o){return[2]}cartStore.currency=r;stripeStore.isFetchingSession=true;return[4,cartStoreReCalculateTotal({adjustmentsAmount:n,billToPartyId:stripeStore.partyBillingId,cartId:window.Zonos.cartId,currency:r,dutiesTaxesFeesEstimate:0,itemsAmount:o,landedCostId:s,shipToPartyId:stripeStore.partyShippingId,shouldInitSessionOnFailure:c,varianceTestInput:storageStore.enabledVariantTestKeys||[]})];case 1:e.sent();stripeStore.isFetchingSession=false;return[2]}}))}))};var cartStoreResetSelectedShippingOption=function(){cartStore.selectedShippingOption=null;cartStore.isSelectedShippingAboveDeminimis=false;cartStore.isSelectedShippingGuarantee=false;cartStore.selectedShippingOptionTransitTime="";cartStore.dutiesTaxesFees=0;cartStore.dutiesTaxesFeesEstimate=0;cartStore.shipping=0;cartStore.total=cartStore.subtotal};var cartStorePreviousStep=function(){if(cartStore.step==="shipping"){cartStore.step="customer-info";cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{"customer-info":Object.assign(Object.assign({},cartStore.tabItems.shipping),{isDone:false})})}else if(cartStore.step==="payment"){cartStore.step="shipping";cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{shipping:Object.assign(Object.assign({},cartStore.tabItems.shipping),{isDone:false})})}else if(cartStore.step==="finish"){cartStore.step="payment";cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{payment:Object.assign(Object.assign({},cartStore.tabItems.payment),{isDone:false})})}};var cartStoreNextStep=function(){if(cartStore.step==="customer-info"){cartStore.step="shipping";cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{"customer-info":Object.assign(Object.assign({},cartStore.tabItems["customer-info"]),{isDone:true})})}else if(cartStore.step==="shipping"){cartStore.step="payment";cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{shipping:Object.assign(Object.assign({},cartStore.tabItems.shipping),{isDone:true})})}else if(cartStore.step==="payment"){cartStore.step="finish"}};var cartStoreResetTabItems=function(){cartStore.step="customer-info";cartStore.tabItems=Object.assign(Object.assign({},cartStore.tabItems),{"customer-info":Object.assign(Object.assign({},cartStore.tabItems["customer-info"]),{isDone:false}),payment:Object.assign(Object.assign({},cartStore.tabItems.payment),{isDone:false}),shipping:Object.assign(Object.assign({},cartStore.tabItems.shipping),{isDone:false})});cartStoreResetSelectedShippingOption()};export{stripeStoreOnChange as A,stripeStoreBuildAddressForPartyCreate as B,cartStoreUpdateSelectedShippingOption as C,cartStoreHasOneEligibleItem as D,stripeStoreApplyPromoCode as E,stripeStoreRemovePromoCode as F,stripeStoreResetPromoCode as G,stripeStoreMessageBasedOnStatus as H,stripeStoreTranslateAddressToLatin as I,extractName as J,cartStoreOnChange as K,stripeStoreAsyncAddressUpdate as L,cartStoreGetShippingTransitInfo as M,cartStoreGetMethod as N,sortServiceLevelOptionsByAmount as O,stripeStoreCleanupDomesticShippingSession as a,stripeStoreSaveDomesticShippingSession as b,stripeStore as c,stripeStoreRetrievePayment as d,cartStore as e,cartStoreUpdateItems as f,cartStoreReset as g,cartStoreResetTabItems as h,initStripeElements as i,cartStoreClearCheckoutInterval as j,stripeStoreInitCheckoutSession as k,stripeStoreGetPaymentIntent as l,cartStoreStartCheckoutInterval as m,getCheckoutSessionBody as n,cartStoreUpdateToErrorState as o,cartStoreSetCheckoutSession as p,stripeStorePrefetchLandedCost as q,cartStoreNextStep as r,stripeStoreGetDomesticShippingSession as s,trackConversionEvent as t,stripeStoreUpdateCheckoutSessionBaseCurrency as u,stripeStoreHandleInventoryCheck as v,stripeStoreConfirmPayment as w,stripeStoreHandleInventoryRefund as x,stripeStoreReset as y,validateCheckoutSession as z};
@@ -1 +0,0 @@
1
- var __awaiter=this&&this.__awaiter||function(e,n,r,o){function t(e){return e instanceof r?e:new r((function(n){n(e)}))}return new(r||(r=Promise))((function(r,a){function i(e){try{u(o.next(e))}catch(e){a(e)}}function s(e){try{u(o["throw"](e))}catch(e){a(e)}}function u(e){e.done?r(e.value):t(e.value).then(i,s)}u((o=o.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},o,t,a,i;return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(e){return function(n){return u([e,n])}}function u(s){if(o)throw new TypeError("Generator is already executing.");while(i&&(i=0,s[0]&&(r=0)),r)try{if(o=1,t&&(a=s[0]&2?t["return"]:s[0]?t["throw"]||((a=t["return"])&&a.call(t),0):t.next)&&!(a=a.call(t,s[1])).done)return a;if(t=0,a)s=[s[0]&2,a.value];switch(s[0]){case 0:case 1:a=s;break;case 4:r.label++;return{value:s[1],done:false};case 5:r.label++;t=s[1];s=[0];continue;case 7:s=r.ops.pop();r.trys.pop();continue;default:if(!(a=r.trys,a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){r.label=s[1];break}if(s[0]===6&&r.label<a[1]){r.label=a[1];a=s;break}if(a&&r.label<a[2]){r.label=a[2];r.ops.push(s);break}if(a[2])r.ops.pop();r.trys.pop();continue}s=n.call(e,r)}catch(e){s=[6,e];t=0}finally{o=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,r){if(r||arguments.length===2)for(var o=0,t=n.length,a;o<t;o++){if(a||!(o in n)){if(!a)a=Array.prototype.slice.call(n,0,o);a[o]=n[o]}}return e.concat(a||Array.prototype.slice.call(n))};var startTime=performance.now();var allLogs=[];var getElapsedTime=function(){var e=performance.now()-startTime;var n=e>1e3?"".concat((e/1e3).toFixed(2),"s"):"".concat(e.toFixed(2),"ms");return{elapsedTime:e,elapsedTimePretty:n}};var prepInfo=function(e){if(typeof e==="string"){return e}try{var n=JSON.stringify(e);return n}catch(n){if(e&&typeof e.toString==="function"){var r=e.toString();return r}return"Unable to stringify info"}};var log=function(e,n){var r=[];for(var o=2;o<arguments.length;o++){r[o-2]=arguments[o]}var t,a;var i=getElapsedTime().elapsedTimePretty;var s=__spreadArray(["(".concat(i,")")],r,true);var u=s.map(prepInfo).join(" ");allLogs.push([n,e,u].filter(Boolean).join(" "));var l=!!((t=window.Zonos)===null||t===void 0?void 0:t.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/);if(!l){return}var d=document.querySelector("iframe#zonos---debug-logging-iframe");if(!d){d=document.createElement("iframe");d.id="zonos---debug-logging-iframe";d.style.display="none";d.style.opacity="0";d.style.position="absolute";d.style.top="-9999px";d.style.left="-9999px";d.style.width="1px";d.style.height="1px";d.style.border="none";d.style.overflow="hidden";d.style.visibility="hidden";document.body.appendChild(d)}var c=((a=d.contentWindow)===null||a===void 0?void 0:a.window.console)||window.console;switch(n){case"warn":c.warn.apply(c,__spreadArray([e],s,false));break;case"info":c.info.apply(c,__spreadArray([e],s,false));break;case"error":c.error.apply(c,__spreadArray([e],s,false));break;default:c.groupCollapsed.apply(c,__spreadArray([e],s,false));c.trace();c.groupEnd();break}};var logError=function(e){var n=[];for(var r=1;r<arguments.length;r++){n[r-1]=arguments[r]}log.apply(void 0,__spreadArray([e,"error"],n,false))};var getIsStagingMode=function(){return window.location.search.includes("zonosStagingMode=1")};var getIsTestMode=function(){var e;return((e=window.Zonos.zonosApiKey)===null||e===void 0?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};var fallbackApiType=["cloudflare","vercel"];var MAIN_BASE_API_TYPE=fallbackApiType[0];var fallbackApiList={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"};var MAIN_BASE_API=fallbackApiList[MAIN_BASE_API_TYPE];var getNextFallbackApiType=function(e){if(e===void 0){e=MAIN_BASE_API_TYPE}var n=fallbackApiType.indexOf(e);var r=fallbackApiType[n+1];if(!r){return null}return r};var jsonParse=function(e){if(typeof e==="string"){try{var n=JSON.parse(e);return n}catch(e){return null}}return null};var checkoutBreakpoint=890;var isCheckoutMobile=function(e){return e||window.innerWidth<checkoutBreakpoint};var getNavigatorConnection=function(){var e="connection"in window.navigator?window.navigator.connection:null;var n="mozConnection"in window.navigator?window.navigator.mozConnection:null;var r="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;var o=e||n||r;return o};var getAdditionalLogMetadata=function(){var e="userAgentData"in window.navigator?window.navigator.userAgentData:null;var n=getNavigatorConnection();return{connectionDownlink:n===null||n===void 0?void 0:n.downlink,connectionEffectiveType:n===null||n===void 0?void 0:n.effectiveType,connectionRtt:n===null||n===void 0?void 0:n.rtt,connectionSaveData:n===null||n===void 0?void 0:n.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}};var blackListPaths=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"];var prepLoadTimeApiLog=function(e){var n=e.apiPath,r=e.apiType,o=e.loadTimeInternal,t=e.loadTimeTotal;if(blackListPaths.includes(n)){return}var a=t-o;if(a<0){return}var i=n.split("?")[0]||n;var s=getAdditionalLogMetadata();var u=typeof s.userAgent==="object"&&s.userAgent.mobile;var l={apiType:r,connectionType:s.connectionEffectiveType,href:i,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:isCheckoutMobile(u),loadTimeBrowserApi:a,loadTimeInternal:o,loadTimeTotal:t,metadata:Object.assign({},s),screenHeight:s.screenHeight,screenWidth:s.screenWidth,userAgent:typeof s.userAgent==="string"?s.userAgent:s.userAgent["brands"].map((function(e){return e.brand})).filter((function(e){return!/Not.*A.*Brand.*/.test(e)})).join(",")};window.Zonos.loadTimeApiInfoList.push(l)};var postReleaseReportingDuration=1*3600*1e3;var sendErrorLog=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,r,o,t,a;var i=e.endpoint,s=e.errors,u=e.metadata,l=e.shouldPostReleaseErrorReporting;return __generator(this,(function(e){log("sendErrorLog","warn",i,u,s);if(l){n=Number(window.Zonos.releaseDate);r=(new Date).getTime();if(r-n>postReleaseReportingDuration){return[2]}}o="userAgentData"in window.navigator?window.navigator.userAgentData:null;t={endpoint:i,errors:s,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:o&&o.brands.length>0?o:window.navigator.userAgent},u)};try{void fetch("".concat(MAIN_BASE_API,"/api/zonos-elements/log-error"),{body:JSON.stringify(t),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){a=getNextFallbackApiType();if(!a){return[2]}void fetch("".concat(fallbackApiList[a],"/api/zonos-elements/log-error"),{body:JSON.stringify(t),method:"POST"})}return[2]}))}))};var __rest=undefined&&undefined.__rest||function(e,n){var r={};for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0)r[o]=e[o];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var t=0,o=Object.getOwnPropertySymbols(e);t<o.length;t++){if(n.indexOf(o[t])<0&&Object.prototype.propertyIsEnumerable.call(e,o[t]))r[o[t]]=e[o[t]]}return r};var getResponseBody=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,r,o;var t=e.response,a=e.shouldLog,i=a===void 0?true:a,s=e.shouldThrow,u=s===void 0?false:s;return __generator(this,(function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);return[4,t.text()];case 1:n=e.sent();r=jsonParse(n);if(!r){throw new Error("Failed to parse content: ".concat(n))}return[2,r];case 2:o=e.sent();if(u){throw o}if(i){console.error(o)}return[2,null];case 3:return[2]}}))}))};var encodeString=function(e){try{var n=btoa(e).replace(/=/g,"");return n}catch(n){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}};var handleRequest=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,r,o,t,a,i,s,u,l,d,c,d,f,v,s,p,s;var w=e.basePathType,g=e.options,h=e.path;return __generator(this,(function(e){switch(e.label){case 0:r=window.Zonos.zonosQaUrlApi||fallbackApiList[w]||MAIN_BASE_API_TYPE;o=r+h;t=new URL(o);a=window.Zonos.cartId?"".concat(window.location.hostname,"-").concat(window.Zonos.cartId):window.location.hostname;t.searchParams.set("zToken",encodeString(a));e.label=1;case 1:e.trys.push([1,3,,4]);return[4,fetch(t.toString(),g)];case 2:n=e.sent();return[3,4];case 3:i=e.sent();if(i instanceof Error){return[2,{baseUrl:r,errors:[{message:i.message,type:"unknown"}],json:null,response:null,zonosMode:null}]}s="Failed to fetch";return[2,{baseUrl:r,errors:[{message:s,type:"unknown"}],json:null,response:null,zonosMode:null}];case 4:u=n.headers.get("Zonos-Mode");l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&u&&l){window.Zonos.modeAlerted=true}if(!n.ok)return[3,6];return[4,getResponseBody({response:n})];case 5:d=e.sent();return[2,{baseUrl:r,errors:[],json:d,response:n,zonosMode:u}];case 6:c=n.status.toString();e.label=7;case 7:e.trys.push([7,9,,10]);return[4,getResponseBody({response:n,shouldThrow:true})];case 8:d=e.sent();if(d&&"errors"in d&&Array.isArray(d.errors)){f=d.errors;v=f.map((function(e){if(typeof e==="string"){return{message:e,type:c}}return e}));return[2,{baseUrl:r,errors:v,json:null,response:n,zonosMode:u}]}s=JSON.stringify(d);return[2,{baseUrl:r,errors:[{message:s,type:c}],json:null,response:n,zonosMode:u}];case 9:p=e.sent();s="Unknown error";return[2,{baseUrl:r,errors:[{message:"".concat(c,": ").concat(s),type:c}],json:null,response:null,zonosMode:u}];case 10:return[2]}}))}))};var handleRequestWithFallback=function(e){return __awaiter(void 0,[e],void 0,(function(e){var n,r,o,t,a,i,s,u,l,d,c,f,v,p,w,g,h;var b=e.basePathType,y=e.options,_=e.path;return __generator(this,(function(e){switch(e.label){case 0:o=_.startsWith("/api/bigcommerce");t=o?"vercel":b;a=performance.now();return[4,handleRequest({basePathType:t,options:y,path:_})];case 1:i=e.sent(),s=i.errors,u=i.response,l=__rest(i,["errors","response"]);d=performance.now();c=d-a;log("".concat(_," (").concat(c.toFixed(2),"ms)"),"info");f=u===null||u===void 0?void 0:u.headers.get("Zonos-Duration");if((u===null||u===void 0?void 0:u.status)===200){prepLoadTimeApiLog({apiPath:_,apiType:t,loadTimeInternal:f?Number(f):0,loadTimeTotal:c})}v=getNextFallbackApiType(t);p=s.find((function(e){var n=e.type;return n==="unknown"}));w=s.find((function(e){var n=e.message;return typeof n==="string"&&(n.includes("signal is aborted")||n.includes("The operation was aborted")||n.includes("Fetch is aborted"))}));g=!!p||(u===null||u===void 0?void 0:u.status)===404||(u===null||u===void 0?void 0:u.status)===500;h=v&&g;if(g&&!w){void sendErrorLog({endpoint:fallbackApiList[t]+_,errors:s.map((function(e){var n=e.message;return"API: ".concat(n)})),metadata:{currentBasePath:t,nextFallbackApiType:v,requestHeaders:y===null||y===void 0?void 0:y.headers,requestPayload:jsonParse((n=y===null||y===void 0?void 0:y.body)===null||n===void 0?void 0:n.toString())||((r=y===null||y===void 0?void 0:y.body)===null||r===void 0?void 0:r.toString()),shouldCallFallback:h,status:u===null||u===void 0?void 0:u.status,statusText:u===null||u===void 0?void 0:u.statusText},shouldPostReleaseErrorReporting:true})}if(h){log('=== "'.concat(_,'" failed to fetch, trying next fallback ').concat(v));return[2,handleRequestWithFallback({basePathType:v,options:y,path:_})]}return[2,Object.assign({errors:s,response:u},l)]}}))}))};var handleFetch=function(e,n){return __awaiter(void 0,void 0,void 0,(function(){var r,o,t,a,i,s;return __generator(this,(function(u){r=__rest(n||{},[]);o=r.body?JSON.stringify(r.body):undefined;t=r.method||"GET";a=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":getIsStagingMode()?"1":undefined,"Zonos-Test-Mode":getIsTestMode()?"1":undefined,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},r.headers);Object.keys(a).forEach((function(e){return a[e]===undefined&&delete a[e]}));i=Object.assign(Object.assign({},r),{body:t==="GET"?undefined:o,headers:a,method:t});s=new URLSearchParams(window.location.search).get("useFallbackApi");return[2,handleRequestWithFallback({basePathType:s||MAIN_BASE_API_TYPE,options:i,path:e})]}))}))};export{getIsStagingMode as a,logError as b,getElapsedTime as c,allLogs as d,getAdditionalLogMetadata as e,fallbackApiList as f,getIsTestMode as g,handleFetch as h,isCheckoutMobile as i,jsonParse as j,log as l,sendErrorLog as s};
@@ -1 +0,0 @@
1
- var __awaiter=this&&this.__awaiter||function(e,r,t,o){function n(e){return e instanceof t?e:new t((function(r){r(e)}))}return new(t||(t=Promise))((function(t,a){function i(e){try{c(o.next(e))}catch(e){a(e)}}function l(e){try{c(o["throw"](e))}catch(e){a(e)}}function c(e){e.done?t(e.value):n(e.value).then(i,l)}c((o=o.apply(e,r||[])).next())}))};var __generator=this&&this.__generator||function(e,r){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},o,n,a,i;return i={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function l(e){return function(r){return c([e,r])}}function c(l){if(o)throw new TypeError("Generator is already executing.");while(i&&(i=0,l[0]&&(t=0)),t)try{if(o=1,n&&(a=l[0]&2?n["return"]:l[0]?n["throw"]||((a=n["return"])&&a.call(n),0):n.next)&&!(a=a.call(n,l[1])).done)return a;if(n=0,a)l=[l[0]&2,a.value];switch(l[0]){case 0:case 1:a=l;break;case 4:t.label++;return{value:l[1],done:false};case 5:t.label++;n=l[1];l=[0];continue;case 7:l=t.ops.pop();t.trys.pop();continue;default:if(!(a=t.trys,a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1];a=l;break}if(a&&t.label<a[2]){t.label=a[2];t.ops.push(l);break}if(a[2])t.ops.pop();t.trys.pop();continue}l=r.call(e,t)}catch(e){l=[6,e];n=0}finally{o=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:true}}};import{c as createStore,z as zonosStore}from"./zonosStore-c456b933.js";import{l as log,j as jsonParse,h as handleFetch,b as logError}from"./handleFetch-99218189.js";import{a as availableTestKeys}from"./VarianceTest-fef2d958.js";import{a as translationStoreUpdateLanguage}from"./translationStore-fb98a08d.js";var hasAtLeastOneAvailableTestKey=function(e){var r=!!e.find((function(e){return e.testKey in availableTestKeys}));if(!r){log("No available test key found in response","info",{response:e})}return!!e.find((function(e){return e.testKey in availableTestKeys}))};var filterValidTests=function(e){if(!hasAtLeastOneAvailableTestKey(e)){return[]}return e.filter((function(e){var r;var t=availableTestKeys[e.testKey]&&!e.selectedVariantKey;var o=e.selectedVariantKey&&!!((r=availableTestKeys[e.testKey])===null||r===void 0?void 0:r["availableVariants"].includes(e.selectedVariantKey));return t||o})).map((function(e){return Object.assign(Object.assign({},e),{expiresAt:e.expiresAt||Date.now()+VARIANT_TEST_KEY_EXPIRATION,selectedVariantKey:e.selectedVariantKey||null})}))};var VARIANT_TEST_KEY_EXPIRATION=60*60*24*1e3;var _d=createStore({checkoutSessionId:sessionStorage.getItem("zonos--checkout-session-id"),enabledVariantTestKeys:jsonParse(localStorage.getItem("zonos--enabled-variant-test-keys"))}),storageStoreOnChange=_d.onChange,storageStore=_d.state;storageStoreOnChange("enabledVariantTestKeys",(function(){var e;if(!((e=storageStore.enabledVariantTestKeys)===null||e===void 0?void 0:e.length)){localStorage.removeItem("zonos--enabled-variant-test-keys");return}localStorage.setItem("zonos--enabled-variant-test-keys",JSON.stringify(storageStore.enabledVariantTestKeys))}));storageStoreOnChange("checkoutSessionId",(function(){if(!storageStore.checkoutSessionId){sessionStorage.removeItem("zonos--checkout-session-id");return}sessionStorage.setItem("zonos--checkout-session-id",storageStore.checkoutSessionId)}));var storageStoreSetEnabledVariantTestKeys=function(e){storageStore.enabledVariantTestKeys=filterValidTests(e)};var getCountries=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,r,t,o;return __generator(this,(function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,handleFetch("/api/zonos-elements/get-countries",{method:"GET"})];case 1:e=n.sent(),r=e.errors,t=e.json;if(r.length||!t){return[2,null]}return[2,t];case 2:o=n.sent();return[2,null];case 3:return[2]}}))}))};var getCountryLandedCost=function(e){return __awaiter(void 0,void 0,void 0,(function(){var r,t,o,n,a;return __generator(this,(function(i){switch(i.label){case 0:if(!e){return[2,null]}t="/api/zonos-elements/country-landed-cost/".concat(e);return[4,handleFetch(t)];case 1:o=i.sent(),n=o.errors,a=o.json;if(n.length||!a){logError("Error fetching country landed cost: ".concat((r=n.find(Boolean))===null||r===void 0?void 0:r.message));return[2,null]}return[2,a||null]}}))}))};var defaultUsExchangeRate={exchangeRate:{rate:1,targetFormat:{currencyCode:"USD",decimalDelimiter:".",scale:2,symbol:"$",symbolLocation:"before",thousandsDelimiter:","}},maxAge:null};var getExchangeRate=function(e){return __awaiter(void 0,[e],void 0,(function(e){var r,t,o,n,a,i,l,c,u,s;var d=e.country,v=e.isGuaranteed,f=e.sourceCurrency,g=e.targetCurrency;return __generator(this,(function(e){switch(e.label){case 0:if(f===g&&!v){return[2,defaultUsExchangeRate]}t=new URLSearchParams;t.set("sourceCurrency",f);t.set("targetCurrency",g);t.set("isGuaranteed",String(v));t.set("country",d||"");return[4,handleFetch("/api/zonos-elements/exchange-rates?".concat(t.toString()))];case 1:o=e.sent(),n=o.errors,a=o.json;if(n.length||!a){logError("Error fetching country landed cost: ".concat((r=n.find(Boolean))===null||r===void 0?void 0:r.message));return[2,defaultUsExchangeRate]}i=a.exchangeRateCreate,l=i.rate,c=i.targetFormat;u=a.maxAge;if(l){sessionStorage.setItem(d+"_rate",JSON.stringify(l));s={rate:l,targetFormat:c};return[2,{exchangeRate:s,maxAge:u}]}return[2,defaultUsExchangeRate]}}))}))};var getInclusivePricing=function(e){return __awaiter(void 0,void 0,void 0,(function(){var r,t,o,n;return __generator(this,(function(a){switch(a.label){case 0:if(!e){return[2,null]}return[4,handleFetch("/api/zonos-elements/inclusive-prices/".concat(e))];case 1:t=a.sent(),o=t.errors,n=t.json;if(o.length||!n){logError("Error fetching country inclusive price setting: ".concat((r=o.find(Boolean))===null||r===void 0?void 0:r.message));return[2,null]}return[2,n||null]}}))}))};var getLocaleMessages=function(e){return __awaiter(void 0,[e],void 0,(function(e){var r,t,o,n,a;var i=e.countryCode,l=e.localeTo,c=e.storeId;return __generator(this,(function(e){switch(e.label){case 0:t=new URLSearchParams;t.set("countryCode",i);t.set("storeId",c.toString());if(l){t.set("localeTo",l)}return[4,handleFetch("/api/zonos-elements/locale-messages?".concat(t.toString()))];case 1:o=e.sent(),n=o.errors,a=o.json;if(n.length||!a){logError("Error fetching exchange rate",(r=n.find(Boolean))===null||r===void 0?void 0:r.message);return[2,[]]}return[2,a.locale_countryCodesPage]}}))}))};var validateCountryCode=function(e){if(e&&/^[A-Z]{2}$/.test(e)){return e}return null};var getZCountryUrlParam=function(e){var r=new URLSearchParams(e||window.location.search);var t=function(e){var t=r.get(e);return validateCountryCode(t)};var o=t("zCountry");var n=t("country");var a=t("customerCountry");return o||n||a};var getLocalization=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,r,t,o,n,a,i,l;return __generator(this,(function(c){switch(c.label){case 0:c.trys.push([0,2,,3]);e=new URL(window.location.href);r=window.sessionStorage.getItem("zonos--country");t=getZCountryUrlParam(e.searchParams)||r;o=new URLSearchParams;if(t){o.set("zCountry",t)}return[4,handleFetch("/api/zonos-elements/localization?".concat(o.toString()))];case 1:n=c.sent(),a=n.errors,i=n.json;if(a.length||!i){return[2,{country:null,locale:null}]}return[2,{country:i.country,locale:i.locale}];case 2:l=c.sent();return[2,{country:null,locale:null}];case 3:return[2]}}))}))};var getShippingZones=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,r,t,o,n,a,i;return __generator(this,(function(l){switch(l.label){case 0:if((e=window.Zonos.cartSettings)===null||e===void 0?void 0:e.shippingZones){return[2,window.Zonos.cartSettings.shippingZones.flatMap((function(e){return e===null||e===void 0?void 0:e.countryCodes})).filter(Boolean)]}return[4,handleFetch("/api/zonos-elements/shipping-zones")];case 1:o=l.sent(),n=o.errors,a=o.json;if(n.length||!a){logError("Error fetching shipping zones: ".concat((r=n.find(Boolean))===null||r===void 0?void 0:r.message));return[2,null]}i=(t=a===null||a===void 0?void 0:a.shippingZones)===null||t===void 0?void 0:t.flatMap((function(e){return e===null||e===void 0?void 0:e.countryCodes})).filter(Boolean);return[2,i||null]}}))}))};var currencyConvert=function(e){var r=localizationStore.exchangeRate;if(!r||!e||isNaN(e)){return e}var t=(r===null||r===void 0?void 0:r.targetFormat.scale)||2;var o=e*r.rate;var n=o.toFixed(t);return Number(n)};var numberFormat=function(e){var r=e.amount,t=e.currency,o=e.targetFormat;var n=t||localizationStore.targetCurrency;var a=(o===null||o===void 0?void 0:o.scale)||2;var i=window.navigator.userAgent.indexOf("MSIE ")!==-1;var l=typeof Intl==="object"&&Intl&&typeof Intl.NumberFormat==="function";if(i||!l){var c=Number(r).toFixed(a).replace(".","|dec|").replace(",",(o===null||o===void 0?void 0:o.thousandsDelimiter)||"").replace("|dec|",(o===null||o===void 0?void 0:o.decimalDelimiter)||"");return c}var u=new Intl.NumberFormat(window.navigator.language,{currency:n,currencyDisplay:"code",minimumFractionDigits:a,style:"currency"}).format(r);return u.replace(new RegExp("".concat(n,"\\s+")),"")};var currencyFormat=function(e){var r=e.amount,t=e.currency;if(isNaN(r)||r!==0&&!r){return""}var o=zonosStore.overrideCurrencyFormat;var n=localizationStore.exchangeRate;var a=t||localizationStore.targetCurrency;if(typeof o==="function"){return o({amount:r,currencyCode:a,numberFormat:function(e){var r=e.amount;return numberFormat({amount:r,currency:a,targetFormat:(n===null||n===void 0?void 0:n.targetFormat)||null})}})}var i=(n||{}).targetFormat;if(!i||!n){return"".concat(r.toFixed(2)," ").concat(a)}var l=i.scale||2;var c=window.navigator.userAgent.indexOf("MSIE ")!==-1;var u=typeof Intl==="object"&&Intl&&typeof Intl.NumberFormat==="function";if(c||!u){var s=Number(r).toFixed(l).replace(".","|dec|").replace(",",i.thousandsDelimiter||"").replace("|dec|",i.decimalDelimiter||"");var d="".concat(s).concat(i.currencyCode!=="USD"?" ".concat(i.currencyCode):"");return d}var v=(o===null||o===void 0?void 0:o.currencyDisplay)||"symbol";var f=new Intl.NumberFormat(window.navigator.language,{currency:a,currencyDisplay:v,minimumFractionDigits:l,style:"currency"}).format(r);var g=v==="code"?"".concat(f.replace(new RegExp("".concat(a,"\\s+")),"")," ").concat(a):f;return g};var currencyConvertAndFormat=function(e){var r=currencyConvert(e);var t=currencyFormat({amount:r});return t};var isValidSelector=function(e){try{document.createDocumentFragment().querySelector(e)}catch(e){return false}return true};var getCurrencyElements=function(e){var r=e||".money";if(!isValidSelector(r)){logError('Currency element selector "'.concat(r,'" is not valid.'));return null}var t=document.querySelectorAll(r);if(!t.length){log('No currency elements found with selector "'.concat(r,'"'),"warn");return null}return Array.from(t)};var getInitialElementAmount=function(e){var r;var t=e.getAttribute("data-domestic");var o=e.getAttribute("data-zintl");var n=(r=e.textContent)===null||r===void 0?void 0:r.replace(/[^\d.-]/g,"");if(!n){return null}if(!t||e.textContent!==o&&o){e.setAttribute("data-domestic",n);return parseFloat(n)}return parseFloat(t)};var convertCurrency=function(e){var r;var t=getInitialElementAmount(e);if(!t||isNaN(t)){return}var o=e.getAttribute("data-zintl");var n=parseFloat(e.getAttribute("data-zrate")||"1");var a=e.getAttribute("data-zcountry-code");var i=localizationStore.exchangeRate&&localizationStore.targetCurrency===localizationStore.exchangeRate.targetFormat.currencyCode;var l=((r=localizationStore.exchangeRate)===null||r===void 0?void 0:r.rate)||1;if(i&&(e.textContent!==o||l!==n||a!==localizationStore.selectedCountryCode)){var c=typeof zonosStore.currencyConverter==="function"&&zonosStore.currencyConverter({convert:currencyConvert,convertAndFormat:currencyConvertAndFormat,currencyCode:localizationStore.targetCurrency,format:function(e){return currencyFormat({amount:e})},originalAmount:t,selector:e});var u=c||currencyConvertAndFormat(t);if(u!==e.textContent){e.textContent=u}e.setAttribute("data-zrate",l.toString());e.setAttribute("data-zintl",u);e.setAttribute("data-zcountry-code",localizationStore.selectedCountryCode||"")}};var defaultCurrencyConverter=function(){var e=zonosStore.helloSettings.currencyElementSelector;var r=getCurrencyElements(e);if(!(r===null||r===void 0?void 0:r.length)){return}if(!localizationStore.exchangeRate){logError("Could not display currency. Exchange rate and format data is not available.");return}r.forEach((function(e){convertCurrency(e)}))};var currencyDisplay=function(){if(zonosStore.helloSettings.currencyBehavior==="DISABLED"||window.Zonos.isLegacyCheckout){return}defaultCurrencyConverter()};var getCurrencyCode=function(e){var r;var t=(r=localizationStore.shippingZoneCountries)===null||r===void 0?void 0:r[e];if(t){return t.currencyCode}return null};var setZCountryUrlParam=function(e){if(!e){return}var r=new URLSearchParams(window.location.search);var t=r.has("zCountry")||zonosStore.helloSettings.countryOverrideBehavior==="URL_PARAM";if(t){r.set("zCountry",e);var o="".concat(window.location.pathname,"?").concat(r.toString());window.history.replaceState(window.history.state,document.title,o)}};var _e=createStore({countryLandedCost:null,customMessages:[],exchangeRate:null,helloCountryList:null,inclusivePricing:null,isDisabledCountry:true,isShippableCountry:false,localizationLoaded:false,selectedCountryCode:null,selectedLocale:"en",shippingZoneCountries:null,targetCurrency:"USD"}),localizationDispose=_e.dispose,localizationStoreOnChange=_e.onChange,localizationStore=_e.state;var triggerGetExchangeRate=function(e){return __awaiter(void 0,void 0,void 0,(function(){var r,t,o;return __generator(this,(function(n){switch(n.label){case 0:return[4,getExchangeRate({country:localizationStore.selectedCountryCode,isGuaranteed:e,sourceCurrency:zonosStore.sourceCurrency,targetCurrency:localizationStore.targetCurrency})];case 1:r=n.sent(),t=r.exchangeRate,o=r.maxAge;if(t){localizationStore.exchangeRate=t;currencyDisplay()}return[2,{maxAge:o}]}}))}))};var DEFAULT_COUNTRY_CODE_LEGACY_CHECKOUT="CA";var getFallbackDefaultCountryCode=function(e){if(localizationStore.selectedCountryCode&&e.includes(localizationStore.selectedCountryCode)){return localizationStore.selectedCountryCode}return DEFAULT_COUNTRY_CODE_LEGACY_CHECKOUT};var startExchangeRateTimeout=function(e){var r=e.isGuaranteed,t=e.maxAge;if(localizationStore.exchangeRateTimeout){clearTimeout(localizationStore.exchangeRateTimeout)}var o=5*60;var n=t||o;localizationStore.exchangeRateTimeout=setTimeout((function(){return __awaiter(void 0,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return[4,triggerGetExchangeRate(r)];case 1:e=t.sent().maxAge;startExchangeRateTimeout({isGuaranteed:r,maxAge:e});return[2]}}))}))}),n*1e3)};var getNewLocalization=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,r,t,o,n,a,i,l;return __generator(this,(function(c){switch(c.label){case 0:log("get new localization store");r=localizationStore.isDisabledCountry,t=localizationStore.isShippableCountry,o=localizationStore.selectedCountryCode;if(!!window.Zonos.isLegacyCheckout)return[3,3];n=localizationStore;return[4,getCountryLandedCost(localizationStore.selectedCountryCode)];case 1:n.countryLandedCost=c.sent();a=localizationStore;return[4,getInclusivePricing(o)];case 2:a.inclusivePricing=((e=c.sent())===null||e===void 0?void 0:e.setting)||null;if(localizationStore.inclusivePricing){log("Inclusive price setting found for this country (".concat(o,") ").concat(JSON.stringify(localizationStore.inclusivePricing,null,2)))}return[3,4];case 3:log("Skipping country landed cost and inclusive pricing requests, because this is a legacy checkout");c.label=4;case 4:if(zonosStore.helloSettings.currencyBehavior==="DISABLED"||!t||r||!o){return[2]}i=zonosStore.checkoutSettings.visibilityStatus==="ENABLED";return[4,triggerGetExchangeRate(i)];case 5:l=c.sent().maxAge;startExchangeRateTimeout({isGuaranteed:i,maxAge:l});return[2]}}))}))};var getCustomMessages=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,r;return __generator(this,(function(t){switch(t.label){case 0:log("Getting custom messages for ".concat(localizationStore.selectedCountryCode));if(!localizationStore.selectedCountryCode||!zonosStore.storeId){return[2]}return[4,getLocaleMessages({countryCode:localizationStore.selectedCountryCode,localeTo:localizationStore.selectedLocale,storeId:zonosStore.storeId})];case 1:e=t.sent();r=e.flatMap((function(e){var r;return{countryCode:localizationStore.selectedCountryCode,message:(r=e.countryCodesPageMessageLinks.find(Boolean))===null||r===void 0?void 0:r.message.textTo,pageName:e.pageName}}));localizationStore.customMessages=r;return[2]}}))}))};var getOverrideLocale=function(){var e=new URL(window.location.href);var r=e.searchParams.get("zonosLocale");return r};var addInternationalHideClass=function(){if(localizationStore.isShippableCountry){document.body.classList.add("z-intl")}else{document.body.classList.remove("z-intl")}};var getValidCountryCode=function(e){if(e==="UK"){return"GB"}return e};var localizationStoreUpdateSelectedCountryCode=function(e){var r,t;log("Updating selected country code to ".concat(e));var o=!localizationStore.selectedCountryCode;localizationStore.selectedCountryCode=getValidCountryCode(e);var n=localizationStore.selectedCountryCode,a=localizationStore.shippingZoneCountries;var i=!!a&&!!n&&!!a[n]&&!zonosStore.disabledCountries.includes(n);localizationStore.isShippableCountry=i;log("".concat(localizationStore.selectedCountryCode," is a shippable country: ").concat(localizationStore.isShippableCountry));var l=!!n&&zonosStore.disabledCountries.includes(n);localizationStore.isDisabledCountry=l;log("".concat(localizationStore.selectedCountryCode," is a disabled country: ").concat(localizationStore.isDisabledCountry));addInternationalHideClass();if(!n){return}var c=getCurrencyCode(n);if(!o){(r=zonosStore.onCountryChange)===null||r===void 0?void 0:r.call(zonosStore,{countryCode:n,currencyCode:c,isShippableCountry:i})}if(!c){return}localizationStore.targetCurrency=c;void getNewLocalization();window.sessionStorage.setItem("zonos--country",n);setZCountryUrlParam(n);(t=document.querySelector("zonos-hello"))===null||t===void 0?void 0:t.setAttribute("z-country",n)};var initHelloCountryList=function(e){var r=zonosStore.helloSettings.showCountryList;var t=localizationStore.shippingZoneCountries;if(!r||r==="ONLY_SHIPPABLE"){localizationStore.helloCountryList=t;return}if(r==="ALL"){localizationStore.helloCountryList=e;return}localizationStore.helloCountryList=r.reduce((function(r,t){var o;var n=e===null||e===void 0?void 0:e[t];return n?Object.assign(Object.assign({},r),(o={},o[t]=n,o)):r}),{})};var updateCheckoutSessionLanguage=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,r,t;return __generator(this,(function(o){switch(o.label){case 0:if(!storageStore.checkoutSessionId){return[2,null]}return[4,handleFetch("/api/zonos-elements/update-checkout-session-metadata",{body:{id:storageStore.checkoutSessionId,metadata:[{key:"language",value:localizationStore.selectedLocale}]},method:"POST"})];case 1:e=o.sent(),r=e.errors,t=e.json;if(r.length||!t){logError("Error occurs when updating checkout session",JSON.stringify(r,null,2));return[2,{errors:r,json:t}]}return[2,{errors:[],json:t}]}}))}))};var localizationStoreUpdateSelectedLocale=function(e){localizationStore.selectedLocale=e;translationStoreUpdateLanguage(e);void updateCheckoutSessionLanguage();void getCustomMessages()};var initLocalizationStore=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,r,t,o,n,a,i,l,c;return __generator(this,(function(u){switch(u.label){case 0:return[4,Promise.all([getCountries(),getShippingZones(),getLocalization()])];case 1:e=u.sent(),r=e[0],t=e[1],o=e[2];n=t===null||t===void 0?void 0:t.reduce((function(e,t){var o;var n=r===null||r===void 0?void 0:r[t];return n?Object.assign(Object.assign({},e),(o={},o[t]=n,o)):e}),{});localizationStore.shippingZoneCountries=n||null;initHelloCountryList(r||{});a=o.country,i=o.locale;log("Country code from localization: ".concat(a));log("Locale from localization: ".concat(i));localizationStoreUpdateSelectedCountryCode(a);l=getOverrideLocale();localizationStoreUpdateSelectedLocale(l||i||"en");c=["dev.storybook.elements","dev.elements","dev.demo.elements","dev.dashboard"];if(!localizationStore.selectedCountryCode&&c.some((function(e){return window.location.origin.includes(e)}))){localizationStoreUpdateSelectedCountryCode("CA")}localizationStore.localizationLoaded=true;return[2]}}))}))};export{VARIANT_TEST_KEY_EXPIRATION as V,localizationStoreUpdateSelectedCountryCode as a,storageStoreSetEnabledVariantTestKeys as b,localizationStoreOnChange as c,currencyFormat as d,initLocalizationStore as e,filterValidTests as f,getZCountryUrlParam as g,setZCountryUrlParam as h,isValidSelector as i,currencyDisplay as j,currencyConvertAndFormat as k,localizationStore as l,currencyConvert as m,getFallbackDefaultCountryCode as n,storageStoreOnChange as o,localizationStoreUpdateSelectedLocale as p,storageStore as s};
@@ -1 +0,0 @@
1
- var __awaiter=this&&this.__awaiter||function(e,t,o,r){function n(e){return e instanceof o?e:new o((function(t){t(e)}))}return new(o||(o=Promise))((function(o,i){function l(e){try{s(r.next(e))}catch(e){i(e)}}function a(e){try{s(r["throw"](e))}catch(e){i(e)}}function s(e){e.done?o(e.value):n(e.value).then(l,a)}s((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,n,i,l;return l={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(l[Symbol.iterator]=function(){return this}),l;function a(e){return function(t){return s([e,t])}}function s(a){if(r)throw new TypeError("Generator is already executing.");while(l&&(l=0,a[0]&&(o=0)),o)try{if(r=1,n&&(i=a[0]&2?n["return"]:a[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;if(n=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:o.label++;return{value:a[1],done:false};case 5:o.label++;n=a[1];a=[0];continue;case 7:a=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){o=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(a[0]===6&&o.label<i[1]){o.label=i[1];i=a;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(a);break}if(i[2])o.ops.pop();o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e];n=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{c as createStore,z as zonosStore}from"./zonosStore-c456b933.js";import{c as stripeStore,B as stripeStoreBuildAddressForPartyCreate,e as cartStore,C as cartStoreUpdateSelectedShippingOption}from"./cart-7f06662c.js";import{s as storageStore}from"./localization-192886e4.js";import{h as handleFetch,s as sendErrorLog,d as allLogs,b as logError}from"./handleFetch-99218189.js";import{h}from"./index-55a03023.js";var _k=createStore((function(){return{amountDutyTaxFeeTotal:null,amountTotalPaid:null,isFetchingShippingInfo:true,landedCostShortId:null,originCompanyName:null,partyBillingId:null,shippingAddress:null}})),collectStoreReset=_k.reset,collectStore=_k.state;var collectStoreInitShippingInfo=function(e){return __awaiter(void 0,[e],void 0,(function(e){var t,o,r,n,i,l,a,s,c,d,u,p,S;var v=e.landedCostId,f=e.retries,h=f===void 0?5:f;return __generator(this,(function(e){switch(e.label){case 0:collectStore.isFetchingShippingInfo=true;return[4,handleFetch("/api/zonos-elements/collect/get-shipping-info-by-lc-id",{body:{landedCostId:v},method:"POST"})];case 1:d=e.sent();if(!d.errors.length)return[3,4];if(!(h>0))return[3,3];return[4,new Promise((function(e){return setTimeout(e,1e3)}))];case 2:e.sent();return[2,collectStoreInitShippingInfo({landedCostId:v,retries:h-1})];case 3:return[2,null];case 4:collectStore.landedCostShortId=((t=d.json)===null||t===void 0?void 0:t.landedCostShortId)||null;collectStore.isFetchingShippingInfo=false;collectStore.shippingAddress=((o=d.json)===null||o===void 0?void 0:o.shipping)||null;u=(r=cartStore.checkoutSession)===null||r===void 0?void 0:r.landedCost;p=(n=cartStore.checkoutSession)===null||n===void 0?void 0:n.subtotals;S=(((i=u===null||u===void 0?void 0:u.amountSubtotals)===null||i===void 0?void 0:i.shipping)||0)+(((l=u===null||u===void 0?void 0:u.amountSubtotals)===null||l===void 0?void 0:l.items)||0);collectStore.amountTotalPaid=S*(((a=p===null||p===void 0?void 0:p.exchangeRate)===null||a===void 0?void 0:a.rate)||1);collectStore.amountDutyTaxFeeTotal=((p===null||p===void 0?void 0:p.duties)||0)+((p===null||p===void 0?void 0:p.taxes)||0)+((p===null||p===void 0?void 0:p.fees)||0);collectStore.originCompanyName=((c=(s=d.json)===null||s===void 0?void 0:s.origin)===null||c===void 0?void 0:c.companyName)||null;if(collectStore.amountTotalPaid===0){void sendErrorLog({endpoint:"COLLECT_NO_TOTAL_PAID",errors:[],metadata:{landedCostId:v,organizationId:zonosStore.organizationId}})}return[2]}}))}))};var collectStoreAsyncAddressUpdate=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t,o,r,n,i,l,a,s,c;return __generator(this,(function(d){switch(d.label){case 0:if(!((e=stripeStore.stripeBillingAddressEventData)===null||e===void 0?void 0:e.complete)){return[2,{partiesCreated:false}]}n=(o=(t=cartStore.checkoutSession)===null||t===void 0?void 0:t.landedCost)===null||o===void 0?void 0:o.rootId;if(!n){void sendErrorLog({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId}});return[2,{partiesCreated:false}]}if(!storageStore.checkoutSessionId){void sendErrorLog({endpoint:"COLLECT_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,landedCostRootId:n}});return[2,{partiesCreated:false}]}i=stripeStoreBuildAddressForPartyCreate({address:stripeStore.stripeBillingAddressEventData.value.address,firstName:stripeStore.stripeBillingAddressEventData.value.firstName,lastName:stripeStore.stripeBillingAddressEventData.value.lastName,name:stripeStore.stripeBillingAddressEventData.value.name,phone:stripeStore.stripeBillingAddressEventData.value.phone});l=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,handleFetch("/api/zonos-elements/create-billing-party",{body:{billingAddress:i,checkoutSessionId:storageStore.checkoutSessionId,companyName:stripeStore.companyName,email:((r=stripeStore.stripeLinkEventData)===null||r===void 0?void 0:r.value.email)||"",isTest:l,rootId:n},method:"POST"})];case 1:a=d.sent(),s=a.errors,c=a.json;if(s.length||!c){logError("Error occurs when creating billing party",JSON.stringify(s,null,2));void sendErrorLog({endpoint:"COLLECT_BILLING_PARTY_CREATE_FAILED",errors:["[COLLECT] Failed to create billing party"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionId:storageStore.checkoutSessionId,errors:s,json:c}});return[2,{partiesCreated:false}]}collectStore.partyBillingId=c.billToPartyId;return[2,{partiesCreated:true}]}}))}))};var collectStoreUpdateSelectedShippingOption=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t;return __generator(this,(function(o){t=e.landedCost;if(!t){return[2,false]}cartStore.landedCostData=[Object.assign(Object.assign({},e),{landedCost:Object.assign({},t),landedCostId:t.id})];return[2,cartStoreUpdateSelectedShippingOption({applySubtotalsOnly:true,landedCostId:t.id,selectedShippingOption:t.shipmentRating})]}))}))};var collectTabletBreakpoint=1024;var collectMobileBreakpoint=768;var isCollectTablet=function(e){return e||window.innerWidth<collectTabletBreakpoint&&window.innerWidth>=collectMobileBreakpoint};var isCollectMobile=function(e){return e||window.innerWidth<collectMobileBreakpoint};var renderFallback=function(e){var t=e.content,o=e.isLoading,r=e.skeletonHeight,n=e.skeletonWidth;if(o){return h("zonos-skeleton",{skeletonHeight:r,skeletonWidth:n})}return t};export{isCollectTablet as a,collectStoreInitShippingInfo as b,collectStoreUpdateSelectedShippingOption as c,collectStoreAsyncAddressUpdate as d,collectStore as e,isCollectMobile as i,renderFallback as r};
@@ -1 +0,0 @@
1
- var __spreadArray=this&&this.__spreadArray||function(e,r,t){if(t||arguments.length===2)for(var a=0,n=r.length,s;a<n;a++){if(s||!(a in r)){if(!s)s=Array.prototype.slice.call(r,0,a);s[a]=r[a]}}return e.concat(s||Array.prototype.slice.call(r))};import{g as getRenderingRef,f as forceUpdate}from"./index-55a03023.js";import{a as availableTestKeys}from"./VarianceTest-fef2d958.js";var appendToMap=function(e,r,t){var a=e.get(r);if(!a){e.set(r,[t])}else if(!a.includes(t)){a.push(t)}};var debounce=function(e,r){var t;return function(){var a=[];for(var n=0;n<arguments.length;n++){a[n]=arguments[n]}if(t){clearTimeout(t)}t=setTimeout((function(){t=0;e.apply(void 0,a)}),r)}};var isConnected=function(e){return!("isConnected"in e)||e.isConnected};var cleanupElements=debounce((function(e){for(var r=0,t=e.keys();r<t.length;r++){var a=t[r];e.set(a,e.get(a).filter(isConnected))}}),2e3);var stencilSubscription=function(){if(typeof getRenderingRef!=="function"){return{}}var e=new Map;return{dispose:function(){return e.clear()},get:function(r){var t=getRenderingRef();if(t){appendToMap(e,r,t)}},set:function(r){var t=e.get(r);if(t){e.set(r,t.filter(forceUpdate))}cleanupElements(e)},reset:function(){e.forEach((function(e){return e.forEach(forceUpdate)}));cleanupElements(e)}}};var unwrap=function(e){return typeof e==="function"?e():e};var createObservableMap=function(e,r){if(r===void 0){r=function(e,r){return e!==r}}var t=unwrap(e);var a=new Map(Object.entries(t!==null&&t!==void 0?t:{}));var n={dispose:[],get:[],set:[],reset:[]};var s=function(){var r;a=new Map(Object.entries((r=unwrap(e))!==null&&r!==void 0?r:{}));n.reset.forEach((function(e){return e()}))};var i=function(){n.dispose.forEach((function(e){return e()}));s()};var o=function(e){n.get.forEach((function(r){return r(e)}));return a.get(e)};var c=function(e,t){var s=a.get(e);if(r(t,s,e)){a.set(e,t);n.set.forEach((function(r){return r(e,t,s)}))}};var u=typeof Proxy==="undefined"?{}:new Proxy(t,{get:function(e,r){return o(r)},ownKeys:function(e){return Array.from(a.keys())},getOwnPropertyDescriptor:function(){return{enumerable:true,configurable:true}},has:function(e,r){return a.has(r)},set:function(e,r,t){c(r,t);return true}});var v=function(e,r){n[e].push(r);return function(){removeFromArray(n[e],r)}};var l=function(r,t){var a=v("set",(function(e,a){if(e===r){t(a)}}));var n=v("reset",(function(){return t(unwrap(e)[r])}));return function(){a();n()}};var f=function(){var e=[];for(var r=0;r<arguments.length;r++){e[r]=arguments[r]}var t=e.reduce((function(e,r){if(r.set){e.push(v("set",r.set))}if(r.get){e.push(v("get",r.get))}if(r.reset){e.push(v("reset",r.reset))}if(r.dispose){e.push(v("dispose",r.dispose))}return e}),[]);return function(){return t.forEach((function(e){return e()}))}};var g=function(e){var r=a.get(e);n.set.forEach((function(t){return t(e,r,r)}))};return{state:u,get:o,set:c,on:v,onChange:l,use:f,dispose:i,reset:s,forceUpdate:g}};var removeFromArray=function(e,r){var t=e.indexOf(r);if(t>=0){e[t]=e[e.length-1];e.length--}};var createStore=function(e,r){var t=createObservableMap(e,r);t.use(stencilSubscription());return t};var commonjsGlobal=typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};function listCacheClear$1(){this.__data__=[];this.size=0}var _listCacheClear=listCacheClear$1;function eq$4(e,r){return e===r||e!==e&&r!==r}var eq_1=eq$4;var eq$3=eq_1;function assocIndexOf$4(e,r){var t=e.length;while(t--){if(eq$3(e[t][0],r)){return t}}return-1}var _assocIndexOf=assocIndexOf$4;var assocIndexOf$3=_assocIndexOf;var arrayProto=Array.prototype;var splice=arrayProto.splice;function listCacheDelete$1(e){var r=this.__data__,t=assocIndexOf$3(r,e);if(t<0){return false}var a=r.length-1;if(t==a){r.pop()}else{splice.call(r,t,1)}--this.size;return true}var _listCacheDelete=listCacheDelete$1;var assocIndexOf$2=_assocIndexOf;function listCacheGet$1(e){var r=this.__data__,t=assocIndexOf$2(r,e);return t<0?undefined:r[t][1]}var _listCacheGet=listCacheGet$1;var assocIndexOf$1=_assocIndexOf;function listCacheHas$1(e){return assocIndexOf$1(this.__data__,e)>-1}var _listCacheHas=listCacheHas$1;var assocIndexOf=_assocIndexOf;function listCacheSet$1(e,r){var t=this.__data__,a=assocIndexOf(t,e);if(a<0){++this.size;t.push([e,r])}else{t[a][1]=r}return this}var _listCacheSet=listCacheSet$1;var listCacheClear=_listCacheClear,listCacheDelete=_listCacheDelete,listCacheGet=_listCacheGet,listCacheHas=_listCacheHas,listCacheSet=_listCacheSet;function ListCache$4(e){var r=-1,t=e==null?0:e.length;this.clear();while(++r<t){var a=e[r];this.set(a[0],a[1])}}ListCache$4.prototype.clear=listCacheClear;ListCache$4.prototype["delete"]=listCacheDelete;ListCache$4.prototype.get=listCacheGet;ListCache$4.prototype.has=listCacheHas;ListCache$4.prototype.set=listCacheSet;var _ListCache=ListCache$4;var ListCache$3=_ListCache;function stackClear$1(){this.__data__=new ListCache$3;this.size=0}var _stackClear=stackClear$1;function stackDelete$1(e){var r=this.__data__,t=r["delete"](e);this.size=r.size;return t}var _stackDelete=stackDelete$1;function stackGet$1(e){return this.__data__.get(e)}var _stackGet=stackGet$1;function stackHas$1(e){return this.__data__.has(e)}var _stackHas=stackHas$1;var freeGlobal$1=typeof commonjsGlobal=="object"&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal;var _freeGlobal=freeGlobal$1;var freeGlobal=_freeGlobal;var freeSelf=typeof self=="object"&&self&&self.Object===Object&&self;var root$4=freeGlobal||freeSelf||Function("return this")();var _root=root$4;var root$3=_root;var Symbol$2=root$3.Symbol;var _Symbol=Symbol$2;var Symbol$1=_Symbol;var objectProto$a=Object.prototype;var hasOwnProperty$8=objectProto$a.hasOwnProperty;var nativeObjectToString$1=objectProto$a.toString;var symToStringTag$1=Symbol$1?Symbol$1.toStringTag:undefined;function getRawTag$1(e){var r=hasOwnProperty$8.call(e,symToStringTag$1),t=e[symToStringTag$1];try{e[symToStringTag$1]=undefined;var a=true}catch(e){}var n=nativeObjectToString$1.call(e);if(a){if(r){e[symToStringTag$1]=t}else{delete e[symToStringTag$1]}}return n}var _getRawTag=getRawTag$1;var objectProto$9=Object.prototype;var nativeObjectToString=objectProto$9.toString;function objectToString$1(e){return nativeObjectToString.call(e)}var _objectToString=objectToString$1;var Symbol=_Symbol,getRawTag=_getRawTag,objectToString=_objectToString;var nullTag="[object Null]",undefinedTag="[object Undefined]";var symToStringTag=Symbol?Symbol.toStringTag:undefined;function baseGetTag$4(e){if(e==null){return e===undefined?undefinedTag:nullTag}return symToStringTag&&symToStringTag in Object(e)?getRawTag(e):objectToString(e)}var _baseGetTag=baseGetTag$4;function isObject$7(e){var r=typeof e;return e!=null&&(r=="object"||r=="function")}var isObject_1=isObject$7;var baseGetTag$3=_baseGetTag,isObject$6=isObject_1;var asyncTag="[object AsyncFunction]",funcTag$1="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$3(e){if(!isObject$6(e)){return false}var r=baseGetTag$3(e);return r==funcTag$1||r==genTag||r==asyncTag||r==proxyTag}var isFunction_1=isFunction$3;var root$2=_root;var coreJsData$1=root$2["__core-js_shared__"];var _coreJsData=coreJsData$1;var coreJsData=_coreJsData;var maskSrcKey=function(){var e=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function isMasked$1(e){return!!maskSrcKey&&maskSrcKey in e}var _isMasked=isMasked$1;var funcProto$2=Function.prototype;var funcToString$2=funcProto$2.toString;function toSource$1(e){if(e!=null){try{return funcToString$2.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var _toSource=toSource$1;var isFunction$2=isFunction_1,isMasked=_isMasked,isObject$5=isObject_1,toSource=_toSource;var reRegExpChar=/[\\^$.*+?()[\]{}|]/g;var reIsHostCtor=/^\[object .+?Constructor\]$/;var funcProto$1=Function.prototype,objectProto$8=Object.prototype;var funcToString$1=funcProto$1.toString;var hasOwnProperty$7=objectProto$8.hasOwnProperty;var reIsNative=RegExp("^"+funcToString$1.call(hasOwnProperty$7).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(e){if(!isObject$5(e)||isMasked(e)){return false}var r=isFunction$2(e)?reIsNative:reIsHostCtor;return r.test(toSource(e))}var _baseIsNative=baseIsNative$1;function getValue$1(e,r){return e==null?undefined:e[r]}var _getValue=getValue$1;var baseIsNative=_baseIsNative,getValue=_getValue;function getNative$3(e,r){var t=getValue(e,r);return baseIsNative(t)?t:undefined}var _getNative=getNative$3;var getNative$2=_getNative,root$1=_root;var Map$3=getNative$2(root$1,"Map");var _Map=Map$3;var getNative$1=_getNative;var nativeCreate$4=getNative$1(Object,"create");var _nativeCreate=nativeCreate$4;var nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{};this.size=0}var _hashClear=hashClear$1;function hashDelete$1(e){var r=this.has(e)&&delete this.__data__[e];this.size-=r?1:0;return r}var _hashDelete=hashDelete$1;var nativeCreate$2=_nativeCreate;var HASH_UNDEFINED$1="__lodash_hash_undefined__";var objectProto$7=Object.prototype;var hasOwnProperty$6=objectProto$7.hasOwnProperty;function hashGet$1(e){var r=this.__data__;if(nativeCreate$2){var t=r[e];return t===HASH_UNDEFINED$1?undefined:t}return hasOwnProperty$6.call(r,e)?r[e]:undefined}var _hashGet=hashGet$1;var nativeCreate$1=_nativeCreate;var objectProto$6=Object.prototype;var hasOwnProperty$5=objectProto$6.hasOwnProperty;function hashHas$1(e){var r=this.__data__;return nativeCreate$1?r[e]!==undefined:hasOwnProperty$5.call(r,e)}var _hashHas=hashHas$1;var nativeCreate=_nativeCreate;var HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet$1(e,r){var t=this.__data__;this.size+=this.has(e)?0:1;t[e]=nativeCreate&&r===undefined?HASH_UNDEFINED:r;return this}var _hashSet=hashSet$1;var hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=_hashHas,hashSet=_hashSet;function Hash$1(e){var r=-1,t=e==null?0:e.length;this.clear();while(++r<t){var a=e[r];this.set(a[0],a[1])}}Hash$1.prototype.clear=hashClear;Hash$1.prototype["delete"]=hashDelete;Hash$1.prototype.get=hashGet;Hash$1.prototype.has=hashHas;Hash$1.prototype.set=hashSet;var _Hash=Hash$1;var Hash=_Hash,ListCache$2=_ListCache,Map$2=_Map;function mapCacheClear$1(){this.size=0;this.__data__={hash:new Hash,map:new(Map$2||ListCache$2),string:new Hash}}var _mapCacheClear=mapCacheClear$1;function isKeyable$1(e){var r=typeof e;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?e!=="__proto__":e===null}var _isKeyable=isKeyable$1;var isKeyable=_isKeyable;function getMapData$4(e,r){var t=e.__data__;return isKeyable(r)?t[typeof r=="string"?"string":"hash"]:t.map}var _getMapData=getMapData$4;var getMapData$3=_getMapData;function mapCacheDelete$1(e){var r=getMapData$3(this,e)["delete"](e);this.size-=r?1:0;return r}var _mapCacheDelete=mapCacheDelete$1;var getMapData$2=_getMapData;function mapCacheGet$1(e){return getMapData$2(this,e).get(e)}var _mapCacheGet=mapCacheGet$1;var getMapData$1=_getMapData;function mapCacheHas$1(e){return getMapData$1(this,e).has(e)}var _mapCacheHas=mapCacheHas$1;var getMapData=_getMapData;function mapCacheSet$1(e,r){var t=getMapData(this,e),a=t.size;t.set(e,r);this.size+=t.size==a?0:1;return this}var _mapCacheSet=mapCacheSet$1;var mapCacheClear=_mapCacheClear,mapCacheDelete=_mapCacheDelete,mapCacheGet=_mapCacheGet,mapCacheHas=_mapCacheHas,mapCacheSet=_mapCacheSet;function MapCache$1(e){var r=-1,t=e==null?0:e.length;this.clear();while(++r<t){var a=e[r];this.set(a[0],a[1])}}MapCache$1.prototype.clear=mapCacheClear;MapCache$1.prototype["delete"]=mapCacheDelete;MapCache$1.prototype.get=mapCacheGet;MapCache$1.prototype.has=mapCacheHas;MapCache$1.prototype.set=mapCacheSet;var _MapCache=MapCache$1;var ListCache$1=_ListCache,Map$1=_Map,MapCache=_MapCache;var LARGE_ARRAY_SIZE=200;function stackSet$1(e,r){var t=this.__data__;if(t instanceof ListCache$1){var a=t.__data__;if(!Map$1||a.length<LARGE_ARRAY_SIZE-1){a.push([e,r]);this.size=++t.size;return this}t=this.__data__=new MapCache(a)}t.set(e,r);this.size=t.size;return this}var _stackSet=stackSet$1;var ListCache=_ListCache,stackClear=_stackClear,stackDelete=_stackDelete,stackGet=_stackGet,stackHas=_stackHas,stackSet=_stackSet;function Stack$1(e){var r=this.__data__=new ListCache(e);this.size=r.size}Stack$1.prototype.clear=stackClear;Stack$1.prototype["delete"]=stackDelete;Stack$1.prototype.get=stackGet;Stack$1.prototype.has=stackHas;Stack$1.prototype.set=stackSet;var _Stack=Stack$1;var getNative=_getNative;var defineProperty$2=function(){try{var e=getNative(Object,"defineProperty");e({},"",{});return e}catch(e){}}();var _defineProperty=defineProperty$2;var defineProperty$1=_defineProperty;function baseAssignValue$3(e,r,t){if(r=="__proto__"&&defineProperty$1){defineProperty$1(e,r,{configurable:true,enumerable:true,value:t,writable:true})}else{e[r]=t}}var _baseAssignValue=baseAssignValue$3;var baseAssignValue$2=_baseAssignValue,eq$2=eq_1;function assignMergeValue$2(e,r,t){if(t!==undefined&&!eq$2(e[r],t)||t===undefined&&!(r in e)){baseAssignValue$2(e,r,t)}}var _assignMergeValue=assignMergeValue$2;function createBaseFor$1(e){return function(r,t,a){var n=-1,s=Object(r),i=a(r),o=i.length;while(o--){var c=i[e?o:++n];if(t(s[c],c,s)===false){break}}return r}}var _createBaseFor=createBaseFor$1;var createBaseFor=_createBaseFor;var baseFor$1=createBaseFor();var _baseFor=baseFor$1;var _cloneBuffer={exports:{}};(function(e,r){var t=_root;var a=r&&!r.nodeType&&r;var n=a&&"object"=="object"&&e&&!e.nodeType&&e;var s=n&&n.exports===a;var i=s?t.Buffer:undefined,o=i?i.allocUnsafe:undefined;function c(e,r){if(r){return e.slice()}var t=e.length,a=o?o(t):new e.constructor(t);e.copy(a);return a}e.exports=c})(_cloneBuffer,_cloneBuffer.exports);var root=_root;var Uint8Array$1=root.Uint8Array;var _Uint8Array=Uint8Array$1;var Uint8Array=_Uint8Array;function cloneArrayBuffer$1(e){var r=new e.constructor(e.byteLength);new Uint8Array(r).set(new Uint8Array(e));return r}var _cloneArrayBuffer=cloneArrayBuffer$1;var cloneArrayBuffer=_cloneArrayBuffer;function cloneTypedArray$1(e,r){var t=r?cloneArrayBuffer(e.buffer):e.buffer;return new e.constructor(t,e.byteOffset,e.length)}var _cloneTypedArray=cloneTypedArray$1;function copyArray$1(e,r){var t=-1,a=e.length;r||(r=Array(a));while(++t<a){r[t]=e[t]}return r}var _copyArray=copyArray$1;var isObject$4=isObject_1;var objectCreate=Object.create;var baseCreate$1=function(){function e(){}return function(r){if(!isObject$4(r)){return{}}if(objectCreate){return objectCreate(r)}e.prototype=r;var t=new e;e.prototype=undefined;return t}}();var _baseCreate=baseCreate$1;function overArg$1(e,r){return function(t){return e(r(t))}}var _overArg=overArg$1;var overArg=_overArg;var getPrototype$2=overArg(Object.getPrototypeOf,Object);var _getPrototype=getPrototype$2;var objectProto$5=Object.prototype;function isPrototype$2(e){var r=e&&e.constructor,t=typeof r=="function"&&r.prototype||objectProto$5;return e===t}var _isPrototype=isPrototype$2;var baseCreate=_baseCreate,getPrototype$1=_getPrototype,isPrototype$1=_isPrototype;function initCloneObject$1(e){return typeof e.constructor=="function"&&!isPrototype$1(e)?baseCreate(getPrototype$1(e)):{}}var _initCloneObject=initCloneObject$1;function isObjectLike$5(e){return e!=null&&typeof e=="object"}var isObjectLike_1=isObjectLike$5;var baseGetTag$2=_baseGetTag,isObjectLike$4=isObjectLike_1;var argsTag$1="[object Arguments]";function baseIsArguments$1(e){return isObjectLike$4(e)&&baseGetTag$2(e)==argsTag$1}var _baseIsArguments=baseIsArguments$1;var baseIsArguments=_baseIsArguments,isObjectLike$3=isObjectLike_1;var objectProto$4=Object.prototype;var hasOwnProperty$4=objectProto$4.hasOwnProperty;var propertyIsEnumerable=objectProto$4.propertyIsEnumerable;var isArguments$2=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isObjectLike$3(e)&&hasOwnProperty$4.call(e,"callee")&&!propertyIsEnumerable.call(e,"callee")};var isArguments_1=isArguments$2;var isArray$2=Array.isArray;var isArray_1=isArray$2;var MAX_SAFE_INTEGER$1=9007199254740991;function isLength$2(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=MAX_SAFE_INTEGER$1}var isLength_1=isLength$2;var isFunction$1=isFunction_1,isLength$1=isLength_1;function isArrayLike$3(e){return e!=null&&isLength$1(e.length)&&!isFunction$1(e)}var isArrayLike_1=isArrayLike$3;var isArrayLike$2=isArrayLike_1,isObjectLike$2=isObjectLike_1;function isArrayLikeObject$1(e){return isObjectLike$2(e)&&isArrayLike$2(e)}var isArrayLikeObject_1=isArrayLikeObject$1;var isBuffer$2={exports:{}};function stubFalse(){return false}var stubFalse_1=stubFalse;(function(e,r){var t=_root,a=stubFalse_1;var n=r&&!r.nodeType&&r;var s=n&&"object"=="object"&&e&&!e.nodeType&&e;var i=s&&s.exports===n;var o=i?t.Buffer:undefined;var c=o?o.isBuffer:undefined;var u=c||a;e.exports=u})(isBuffer$2,isBuffer$2.exports);var baseGetTag$1=_baseGetTag,getPrototype=_getPrototype,isObjectLike$1=isObjectLike_1;var objectTag$1="[object Object]";var funcProto=Function.prototype,objectProto$3=Object.prototype;var funcToString=funcProto.toString;var hasOwnProperty$3=objectProto$3.hasOwnProperty;var objectCtorString=funcToString.call(Object);function isPlainObject$1(e){if(!isObjectLike$1(e)||baseGetTag$1(e)!=objectTag$1){return false}var r=getPrototype(e);if(r===null){return true}var t=hasOwnProperty$3.call(r,"constructor")&&r.constructor;return typeof t=="function"&&t instanceof t&&funcToString.call(t)==objectCtorString}var isPlainObject_1=isPlainObject$1;var baseGetTag=_baseGetTag,isLength=isLength_1,isObjectLike=isObjectLike_1;var argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]";var arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]";var typedArrayTags={};typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=true;typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=false;function baseIsTypedArray$1(e){return isObjectLike(e)&&isLength(e.length)&&!!typedArrayTags[baseGetTag(e)]}var _baseIsTypedArray=baseIsTypedArray$1;function baseUnary$1(e){return function(r){return e(r)}}var _baseUnary=baseUnary$1;var _nodeUtil={exports:{}};(function(e,r){var t=_freeGlobal;var a=r&&!r.nodeType&&r;var n=a&&"object"=="object"&&e&&!e.nodeType&&e;var s=n&&n.exports===a;var i=s&&t.process;var o=function(){try{var e=n&&n.require&&n.require("util").types;if(e){return e}return i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=o})(_nodeUtil,_nodeUtil.exports);var baseIsTypedArray=_baseIsTypedArray,baseUnary=_baseUnary,nodeUtil=_nodeUtil.exports;var nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray;var isTypedArray$2=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray;var isTypedArray_1=isTypedArray$2;function safeGet$2(e,r){if(r==="constructor"&&typeof e[r]==="function"){return}if(r=="__proto__"){return}return e[r]}var _safeGet=safeGet$2;var baseAssignValue$1=_baseAssignValue,eq$1=eq_1;var objectProto$2=Object.prototype;var hasOwnProperty$2=objectProto$2.hasOwnProperty;function assignValue$1(e,r,t){var a=e[r];if(!(hasOwnProperty$2.call(e,r)&&eq$1(a,t))||t===undefined&&!(r in e)){baseAssignValue$1(e,r,t)}}var _assignValue=assignValue$1;var assignValue=_assignValue,baseAssignValue=_baseAssignValue;function copyObject$1(e,r,t,a){var n=!t;t||(t={});var s=-1,i=r.length;while(++s<i){var o=r[s];var c=a?a(t[o],e[o],o,t,e):undefined;if(c===undefined){c=e[o]}if(n){baseAssignValue(t,o,c)}else{assignValue(t,o,c)}}return t}var _copyObject=copyObject$1;function baseTimes$1(e,r){var t=-1,a=Array(e);while(++t<e){a[t]=r(t)}return a}var _baseTimes=baseTimes$1;var MAX_SAFE_INTEGER=9007199254740991;var reIsUint=/^(?:0|[1-9]\d*)$/;function isIndex$2(e,r){var t=typeof e;r=r==null?MAX_SAFE_INTEGER:r;return!!r&&(t=="number"||t!="symbol"&&reIsUint.test(e))&&(e>-1&&e%1==0&&e<r)}var _isIndex=isIndex$2;var baseTimes=_baseTimes,isArguments$1=isArguments_1,isArray$1=isArray_1,isBuffer$1=isBuffer$2.exports,isIndex$1=_isIndex,isTypedArray$1=isTypedArray_1;var objectProto$1=Object.prototype;var hasOwnProperty$1=objectProto$1.hasOwnProperty;function arrayLikeKeys$1(e,r){var t=isArray$1(e),a=!t&&isArguments$1(e),n=!t&&!a&&isBuffer$1(e),s=!t&&!a&&!n&&isTypedArray$1(e),i=t||a||n||s,o=i?baseTimes(e.length,String):[],c=o.length;for(var u in e){if((r||hasOwnProperty$1.call(e,u))&&!(i&&(u=="length"||n&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||isIndex$1(u,c)))){o.push(u)}}return o}var _arrayLikeKeys=arrayLikeKeys$1;function nativeKeysIn$1(e){var r=[];if(e!=null){for(var t in Object(e)){r.push(t)}}return r}var _nativeKeysIn=nativeKeysIn$1;var isObject$3=isObject_1,isPrototype=_isPrototype,nativeKeysIn=_nativeKeysIn;var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;function baseKeysIn$1(e){if(!isObject$3(e)){return nativeKeysIn(e)}var r=isPrototype(e),t=[];for(var a in e){if(!(a=="constructor"&&(r||!hasOwnProperty.call(e,a)))){t.push(a)}}return t}var _baseKeysIn=baseKeysIn$1;var arrayLikeKeys=_arrayLikeKeys,baseKeysIn=_baseKeysIn,isArrayLike$1=isArrayLike_1;function keysIn$2(e){return isArrayLike$1(e)?arrayLikeKeys(e,true):baseKeysIn(e)}var keysIn_1=keysIn$2;var copyObject=_copyObject,keysIn$1=keysIn_1;function toPlainObject$1(e){return copyObject(e,keysIn$1(e))}var toPlainObject_1=toPlainObject$1;var assignMergeValue$1=_assignMergeValue,cloneBuffer=_cloneBuffer.exports,cloneTypedArray=_cloneTypedArray,copyArray=_copyArray,initCloneObject=_initCloneObject,isArguments=isArguments_1,isArray=isArray_1,isArrayLikeObject=isArrayLikeObject_1,isBuffer=isBuffer$2.exports,isFunction=isFunction_1,isObject$2=isObject_1,isPlainObject=isPlainObject_1,isTypedArray=isTypedArray_1,safeGet$1=_safeGet,toPlainObject=toPlainObject_1;function baseMergeDeep$1(e,r,t,a,n,s,i){var o=safeGet$1(e,t),c=safeGet$1(r,t),u=i.get(c);if(u){assignMergeValue$1(e,t,u);return}var v=s?s(o,c,t+"",e,r,i):undefined;var l=v===undefined;if(l){var f=isArray(c),g=!f&&isBuffer(c),$=!f&&!g&&isTypedArray(c);v=c;if(f||g||$){if(isArray(o)){v=o}else if(isArrayLikeObject(o)){v=copyArray(o)}else if(g){l=false;v=cloneBuffer(c,true)}else if($){l=false;v=cloneTypedArray(c,true)}else{v=[]}}else if(isPlainObject(c)||isArguments(c)){v=o;if(isArguments(o)){v=toPlainObject(o)}else if(!isObject$2(o)||isFunction(o)){v=initCloneObject(c)}}else{l=false}}if(l){i.set(c,v);n(v,c,a,s,i);i["delete"](c)}assignMergeValue$1(e,t,v)}var _baseMergeDeep=baseMergeDeep$1;var Stack=_Stack,assignMergeValue=_assignMergeValue,baseFor=_baseFor,baseMergeDeep=_baseMergeDeep,isObject$1=isObject_1,keysIn=keysIn_1,safeGet=_safeGet;function baseMerge$1(e,r,t,a,n){if(e===r){return}baseFor(r,(function(s,i){n||(n=new Stack);if(isObject$1(s)){baseMergeDeep(e,r,i,t,baseMerge$1,a,n)}else{var o=a?a(safeGet(e,i),s,i+"",e,r,n):undefined;if(o===undefined){o=s}assignMergeValue(e,i,o)}}),keysIn)}var _baseMerge=baseMerge$1;function identity$2(e){return e}var identity_1=identity$2;function apply$1(e,r,t){switch(t.length){case 0:return e.call(r);case 1:return e.call(r,t[0]);case 2:return e.call(r,t[0],t[1]);case 3:return e.call(r,t[0],t[1],t[2])}return e.apply(r,t)}var _apply=apply$1;var apply=_apply;var nativeMax=Math.max;function overRest$1(e,r,t){r=nativeMax(r===undefined?e.length-1:r,0);return function(){var a=arguments,n=-1,s=nativeMax(a.length-r,0),i=Array(s);while(++n<s){i[n]=a[r+n]}n=-1;var o=Array(r+1);while(++n<r){o[n]=a[n]}o[r]=t(i);return apply(e,this,o)}}var _overRest=overRest$1;function constant$1(e){return function(){return e}}var constant_1=constant$1;var constant=constant_1,defineProperty=_defineProperty,identity$1=identity_1;var baseSetToString$1=!defineProperty?identity$1:function(e,r){return defineProperty(e,"toString",{configurable:true,enumerable:false,value:constant(r),writable:true})};var _baseSetToString=baseSetToString$1;var HOT_COUNT=800,HOT_SPAN=16;var nativeNow=Date.now;function shortOut$1(e){var r=0,t=0;return function(){var a=nativeNow(),n=HOT_SPAN-(a-t);t=a;if(n>0){if(++r>=HOT_COUNT){return arguments[0]}}else{r=0}return e.apply(undefined,arguments)}}var _shortOut=shortOut$1;var baseSetToString=_baseSetToString,shortOut=_shortOut;var setToString$1=shortOut(baseSetToString);var _setToString=setToString$1;var identity=identity_1,overRest=_overRest,setToString=_setToString;function baseRest$1(e,r){return setToString(overRest(e,r,identity),e+"")}var _baseRest=baseRest$1;var eq=eq_1,isArrayLike=isArrayLike_1,isIndex=_isIndex,isObject=isObject_1;function isIterateeCall$1(e,r,t){if(!isObject(t)){return false}var a=typeof r;if(a=="number"?isArrayLike(t)&&isIndex(r,t.length):a=="string"&&r in t){return eq(t[r],e)}return false}var _isIterateeCall=isIterateeCall$1;var baseRest=_baseRest,isIterateeCall=_isIterateeCall;function createAssigner$1(e){return baseRest((function(r,t){var a=-1,n=t.length,s=n>1?t[n-1]:undefined,i=n>2?t[2]:undefined;s=e.length>3&&typeof s=="function"?(n--,s):undefined;if(i&&isIterateeCall(t[0],t[1],i)){s=n<3?undefined:s;n=1}r=Object(r);while(++a<n){var o=t[a];if(o){e(r,o,a,s)}}return r}))}var _createAssigner=createAssigner$1;var baseMerge=_baseMerge,createAssigner=_createAssigner;var merge=createAssigner((function(e,r,t){baseMerge(e,r,t)}));var merge_1=merge;var mergeConfig=function(e,r){var t=[];for(var a=2;a<arguments.length;a++){t[a-2]=arguments[a]}var n=__spreadArray([e,r],t,true).filter(Boolean);return merge_1.apply(null,n)};var isInAvailableTestKey=function(e){return e in availableTestKeys};var _h=createStore((function(){return{appearance:{colorPrimary:"white",fontFamily:"Inter",logoUrl:"",style:"ROUNDED",theme:"LIGHT",zonosAttribution:"DISABLED"},checkoutAddressService:null,checkoutSettings:{allowedCharacterSets:"ALL",allowedSettlementCurrencies:"LOCAL",analyticsProviders:[],companyFieldsStatus:"DISABLED",defaultCartExpiration:3600,externalPaymentMethods:[],externalServiceTokens:[],mode:"TEST",orderNotifications:{abandonedCart:{delay:0,discountPercent:0,status:{active:"DISABLED",sendCopiesTo:[]}},orderCancelled:{active:"DISABLED",sendCopiesTo:[]},orderConfirmation:{active:"DISABLED",sendCopiesTo:[]},orderShipped:{active:"DISABLED",sendCopiesTo:[]}},organization:"",placeOrderButtonSelector:null,subscriptionStatus:"INACTIVE",successBehavior:"REDIRECT_TO_SUCCESS_PAGE",successRedirectUrl:"",visibilityStatus:"ENABLED"},currentHelloPage:"",disabledCountries:[],enabledVariantTestKeys:[],helloSettings:{anchorElementSelector:"",cartUrlPattern:"",countryOverrideBehavior:"URL_PARAM",currencyBehavior:"ENABLED",currencyElementSelector:".money",desktopLocation:"BOTTOM_RIGHT",excludedUrlPatterns:[],homepageUrlPattern:"",mobileLocation:"BOTTOM_RIGHT",mode:"LIVE",notFoundElementFallback:null,organization:"",peekMessageBehavior:"ENABLED",peekMessageDelay:0,productAddToCartElementSelector:"",productDescriptionElementSelector:"",productDetailUrlPattern:"",productListUrlPattern:"",productTitleElementSelector:"",restrictionBehavior:"DISABLED",showForCountries:"ONLY_SHIPPABLE",visibilityStatus:"ENABLED"},loadedConfig:false,onlineStoreSettings:{allowedDomains:[],url:""},organizationId:"",organizationName:"",sourceCurrency:"USD",storeId:null,stripeApiKey:"",zonosApiKey:"",zonosMode:null}})),zonosStoreDispose=_h.dispose,zonosStoreOnChange=_h.onChange,reset=_h.reset,zonosStore=_h.state;var savedZonosSettings=null;var getZonosStoreTheme=function(e){if(e==="SYSTEM"){return window.matchMedia("(prefers-color-scheme: dark)").matches?"DARK":"LIGHT"}return e};var zonosStoreInitSetting=function(e){var r=e.overrideSettings,t=e.zonosSettings;var a,n,s,i,o,c,u;reset();if(t){savedZonosSettings=t}var v=mergeConfig(zonosStore.appearance,(savedZonosSettings===null||savedZonosSettings===void 0?void 0:savedZonosSettings.appearanceSettings)||(t===null||t===void 0?void 0:t.appearanceSettings)||null,r===null||r===void 0?void 0:r.appearance);if(v.theme==="SYSTEM"){v.theme=getZonosStoreTheme(v.theme)}zonosStore.onlineStoreSettings=mergeConfig(zonosStore.onlineStoreSettings,(t===null||t===void 0?void 0:t.onlineStoreSettings)||null);zonosStore.disabledCountries=((a=t===null||t===void 0?void 0:t.checkoutSettings)===null||a===void 0?void 0:a.disabledCountries)||[];zonosStore.appearance=v;zonosStore.checkoutSettings=mergeConfig(zonosStore.checkoutSettings,(savedZonosSettings===null||savedZonosSettings===void 0?void 0:savedZonosSettings.checkoutSettings)||(t===null||t===void 0?void 0:t.checkoutSettings)||null,r===null||r===void 0?void 0:r.checkoutSettings);zonosStore.helloSettings=mergeConfig(zonosStore.helloSettings,(savedZonosSettings===null||savedZonosSettings===void 0?void 0:savedZonosSettings.helloSettings)||(t===null||t===void 0?void 0:t.helloSettings)||null,r===null||r===void 0?void 0:r.helloSettings);zonosStore.genericSettings=mergeConfig(zonosStore.genericSettings,(savedZonosSettings===null||savedZonosSettings===void 0?void 0:savedZonosSettings.genericSettings)||(t===null||t===void 0?void 0:t.genericSettings)||null);zonosStore.loadedConfig=true;zonosStore.enabledVariantTestKeys=((s=(n=t===null||t===void 0?void 0:t.checkoutSettings)===null||n===void 0?void 0:n.varianceTestRegistrations)===null||s===void 0?void 0:s.flatMap((function(e){var r=e.testKey;return isInAvailableTestKey(r)?r:[]})))||[];zonosStore.organizationId=((i=t===null||t===void 0?void 0:t.organization)===null||i===void 0?void 0:i.id)||"";zonosStore.organizationName=((o=t===null||t===void 0?void 0:t.organization)===null||o===void 0?void 0:o.name)||"";zonosStore.storeId=((u=(c=t===null||t===void 0?void 0:t.organization)===null||c===void 0?void 0:c.references)===null||u===void 0?void 0:u.storeId)||null;zonosStore.currencyConverter=r===null||r===void 0?void 0:r.currencyConverter;zonosStore.onCountryChange=r===null||r===void 0?void 0:r.onCountryChange;zonosStore.overrideCurrencyFormat=r===null||r===void 0?void 0:r.overrideCurrencyFormat;if(zonosStore.storeId){window.Zonos.storeId=zonosStore.storeId}};var zonosStoreFontFamily=function(){var e=zonosStore.appearance.fontFamily||"Inter";return e};export{_root as _,commonjsGlobal as a,_baseGetTag as b,createStore as c,isObject_1 as d,zonosStoreInitSetting as e,zonosStoreFontFamily as f,getZonosStoreTheme as g,zonosStoreOnChange as h,isObjectLike_1 as i,mergeConfig as m,zonosStore as z};
@@ -1 +0,0 @@
1
- const a={hosted_vs_native:{availableVariants:["hosted","native"]},test_A_B:{availableVariants:["A","B"]}};export{a}
@@ -1 +0,0 @@
1
- var __awaiter=this&&this.__awaiter||function(e,n,r,o){function t(e){return e instanceof r?e:new r((function(n){n(e)}))}return new(r||(r=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function u(e){try{s(o["throw"](e))}catch(e){i(e)}}function s(e){e.done?r(e.value):t(e.value).then(a,u)}s((o=o.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,t,i,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(e){return function(n){return s([e,n])}}function s(u){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(r=0)),r)try{if(o=1,t&&(i=u[0]&2?t["return"]:u[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,u[1])).done)return i;if(t=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:r.label++;return{value:u[1],done:false};case 5:r.label++;t=u[1];u=[0];continue;case 7:u=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){r.label=u[1];break}if(u[0]===6&&r.label<i[1]){r.label=i[1];i=u;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(u);break}if(i[2])r.ops.pop();r.trys.pop();continue}u=n.call(e,r)}catch(e){u=[6,e];t=0}finally{o=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,r){if(r||arguments.length===2)for(var o=0,t=n.length,i;o<t;o++){if(i||!(o in n)){if(!i)i=Array.prototype.slice.call(n,0,o);i[o]=n[o]}}return e.concat(i||Array.prototype.slice.call(n))};System.register([],(function(e){"use strict";return{execute:function(){var n=this;var r=performance.now();var o=e("d",[]);var t=e("c",(function(){var e=performance.now()-r;var n=e>1e3?"".concat((e/1e3).toFixed(2),"s"):"".concat(e.toFixed(2),"ms");return{elapsedTime:e,elapsedTimePretty:n}}));var i=function(e){if(typeof e==="string"){return e}try{var n=JSON.stringify(e);return n}catch(n){if(e&&typeof e.toString==="function"){var r=e.toString();return r}return"Unable to stringify info"}};var a=e("l",(function(e,n){var r=[];for(var a=2;a<arguments.length;a++){r[a-2]=arguments[a]}var u,s;var d=t().elapsedTimePretty;var c=__spreadArray(["(".concat(d,")")],r,true);var l=c.map(i).join(" ");o.push([n,e,l].filter(Boolean).join(" "));var f=!!((u=window.Zonos)===null||u===void 0?void 0:u.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/);if(!f){return}var v=document.querySelector("iframe#zonos---debug-logging-iframe");if(!v){v=document.createElement("iframe");v.id="zonos---debug-logging-iframe";v.style.display="none";v.style.opacity="0";v.style.position="absolute";v.style.top="-9999px";v.style.left="-9999px";v.style.width="1px";v.style.height="1px";v.style.border="none";v.style.overflow="hidden";v.style.visibility="hidden";document.body.appendChild(v)}var w=((s=v.contentWindow)===null||s===void 0?void 0:s.window.console)||window.console;switch(n){case"warn":w.warn.apply(w,__spreadArray([e],c,false));break;case"info":w.info.apply(w,__spreadArray([e],c,false));break;case"error":w.error.apply(w,__spreadArray([e],c,false));break;default:w.groupCollapsed.apply(w,__spreadArray([e],c,false));w.trace();w.groupEnd();break}}));var u=e("b",(function(e){var n=[];for(var r=1;r<arguments.length;r++){n[r-1]=arguments[r]}a.apply(void 0,__spreadArray([e,"error"],n,false))}));var s=e("a",(function(){return window.location.search.includes("zonosStagingMode=1")}));var d=e("g",(function(){var e;return((e=window.Zonos.zonosApiKey)===null||e===void 0?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")}));var c=["cloudflare","vercel"];var l=c[0];var f=e("f",{cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"});var v=f[l];var w=function(e){if(e===void 0){e=l}var n=c.indexOf(e);var r=c[n+1];if(!r){return null}return r};var p=e("j",(function(e){if(typeof e==="string"){try{var n=JSON.parse(e);return n}catch(e){return null}}return null}));var h=890;var b=e("i",(function(e){return e||window.innerWidth<h}));var y=function(){var e="connection"in window.navigator?window.navigator.connection:null;var n="mozConnection"in window.navigator?window.navigator.mozConnection:null;var r="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;var o=e||n||r;return o};var m=e("e",(function(){var e="userAgentData"in window.navigator?window.navigator.userAgentData:null;var n=y();return{connectionDownlink:n===null||n===void 0?void 0:n.downlink,connectionEffectiveType:n===null||n===void 0?void 0:n.effectiveType,connectionRtt:n===null||n===void 0?void 0:n.rtt,connectionSaveData:n===null||n===void 0?void 0:n.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}}));var g=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"];var _=function(e){var n=e.apiPath,r=e.apiType,o=e.loadTimeInternal,t=e.loadTimeTotal;if(g.includes(n)){return}var i=t-o;if(i<0){return}var a=n.split("?")[0]||n;var u=m();var s=typeof u.userAgent==="object"&&u.userAgent.mobile;var d={apiType:r,connectionType:u.connectionEffectiveType,href:a,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:b(s),loadTimeBrowserApi:i,loadTimeInternal:o,loadTimeTotal:t,metadata:Object.assign({},u),screenHeight:u.screenHeight,screenWidth:u.screenWidth,userAgent:typeof u.userAgent==="string"?u.userAgent:u.userAgent["brands"].map((function(e){return e.brand})).filter((function(e){return!/Not.*A.*Brand.*/.test(e)})).join(",")};window.Zonos.loadTimeApiInfoList.push(d)};var T=1*3600*1e3;var k=e("s",(function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i;var u=e.endpoint,s=e.errors,d=e.metadata,c=e.shouldPostReleaseErrorReporting;return __generator(this,(function(e){a("sendErrorLog","warn",u,d,s);if(c){n=Number(window.Zonos.releaseDate);r=(new Date).getTime();if(r-n>T){return[2]}}o="userAgentData"in window.navigator?window.navigator.userAgentData:null;t={endpoint:u,errors:s,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:o&&o.brands.length>0?o:window.navigator.userAgent},d)};try{void fetch("".concat(v,"/api/zonos-elements/log-error"),{body:JSON.stringify(t),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){i=w();if(!i){return[2]}void fetch("".concat(f[i],"/api/zonos-elements/log-error"),{body:JSON.stringify(t),method:"POST"})}return[2]}))}))}));var j=undefined&&undefined.__rest||function(e,n){var r={};for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0)r[o]=e[o];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var t=0,o=Object.getOwnPropertySymbols(e);t<o.length;t++){if(n.indexOf(o[t])<0&&Object.prototype.propertyIsEnumerable.call(e,o[t]))r[o[t]]=e[o[t]]}return r};var z=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o;var t=e.response,i=e.shouldLog,a=i===void 0?true:i,u=e.shouldThrow,s=u===void 0?false:u;return __generator(this,(function(e){switch(e.label){case 0:e.trys.push([0,2,,3]);return[4,t.text()];case 1:n=e.sent();r=p(n);if(!r){throw new Error("Failed to parse content: ".concat(n))}return[2,r];case 2:o=e.sent();if(s){throw o}if(a){console.error(o)}return[2,null];case 3:return[2]}}))}))};var A=function(e){try{var n=btoa(e).replace(/=/g,"");return n}catch(n){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}};var O=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i,a,u,s,d,c,v,c,w,p,u,h,u;var b=e.basePathType,y=e.options,m=e.path;return __generator(this,(function(e){switch(e.label){case 0:r=window.Zonos.zonosQaUrlApi||f[b]||l;o=r+m;t=new URL(o);i=window.Zonos.cartId?"".concat(window.location.hostname,"-").concat(window.Zonos.cartId):window.location.hostname;t.searchParams.set("zToken",A(i));e.label=1;case 1:e.trys.push([1,3,,4]);return[4,fetch(t.toString(),y)];case 2:n=e.sent();return[3,4];case 3:a=e.sent();if(a instanceof Error){return[2,{baseUrl:r,errors:[{message:a.message,type:"unknown"}],json:null,response:null,zonosMode:null}]}u="Failed to fetch";return[2,{baseUrl:r,errors:[{message:u,type:"unknown"}],json:null,response:null,zonosMode:null}];case 4:s=n.headers.get("Zonos-Mode");d=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&s&&d){window.Zonos.modeAlerted=true}if(!n.ok)return[3,6];return[4,z({response:n})];case 5:c=e.sent();return[2,{baseUrl:r,errors:[],json:c,response:n,zonosMode:s}];case 6:v=n.status.toString();e.label=7;case 7:e.trys.push([7,9,,10]);return[4,z({response:n,shouldThrow:true})];case 8:c=e.sent();if(c&&"errors"in c&&Array.isArray(c.errors)){w=c.errors;p=w.map((function(e){if(typeof e==="string"){return{message:e,type:v}}return e}));return[2,{baseUrl:r,errors:p,json:null,response:n,zonosMode:s}]}u=JSON.stringify(c);return[2,{baseUrl:r,errors:[{message:u,type:v}],json:null,response:n,zonosMode:s}];case 9:h=e.sent();u="Unknown error";return[2,{baseUrl:r,errors:[{message:"".concat(v,": ").concat(u),type:v}],json:null,response:null,zonosMode:s}];case 10:return[2]}}))}))};var S=function(e){return __awaiter(n,[e],void 0,(function(e){var n,r,o,t,i,u,s,d,c,l,v,h,b,y,m,g,T;var z=e.basePathType,A=e.options,P=e.path;return __generator(this,(function(e){switch(e.label){case 0:o=P.startsWith("/api/bigcommerce");t=o?"vercel":z;i=performance.now();return[4,O({basePathType:t,options:A,path:P})];case 1:u=e.sent(),s=u.errors,d=u.response,c=j(u,["errors","response"]);l=performance.now();v=l-i;a("".concat(P," (").concat(v.toFixed(2),"ms)"),"info");h=d===null||d===void 0?void 0:d.headers.get("Zonos-Duration");if((d===null||d===void 0?void 0:d.status)===200){_({apiPath:P,apiType:t,loadTimeInternal:h?Number(h):0,loadTimeTotal:v})}b=w(t);y=s.find((function(e){var n=e.type;return n==="unknown"}));m=s.find((function(e){var n=e.message;return typeof n==="string"&&(n.includes("signal is aborted")||n.includes("The operation was aborted")||n.includes("Fetch is aborted"))}));g=!!y||(d===null||d===void 0?void 0:d.status)===404||(d===null||d===void 0?void 0:d.status)===500;T=b&&g;if(g&&!m){void k({endpoint:f[t]+P,errors:s.map((function(e){var n=e.message;return"API: ".concat(n)})),metadata:{currentBasePath:t,nextFallbackApiType:b,requestHeaders:A===null||A===void 0?void 0:A.headers,requestPayload:p((n=A===null||A===void 0?void 0:A.body)===null||n===void 0?void 0:n.toString())||((r=A===null||A===void 0?void 0:A.body)===null||r===void 0?void 0:r.toString()),shouldCallFallback:T,status:d===null||d===void 0?void 0:d.status,statusText:d===null||d===void 0?void 0:d.statusText},shouldPostReleaseErrorReporting:true})}if(T){a('=== "'.concat(P,'" failed to fetch, trying next fallback ').concat(b));return[2,S({basePathType:b,options:A,path:P})]}return[2,Object.assign({errors:s,response:d},c)]}}))}))};var P=e("h",(function(e,r){return __awaiter(n,void 0,void 0,(function(){var n,o,t,i,a,u;return __generator(this,(function(c){n=j(r||{},[]);o=n.body?JSON.stringify(n.body):undefined;t=n.method||"GET";i=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":s()?"1":undefined,"Zonos-Test-Mode":d()?"1":undefined,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},n.headers);Object.keys(i).forEach((function(e){return i[e]===undefined&&delete i[e]}));a=Object.assign(Object.assign({},n),{body:t==="GET"?undefined:o,headers:i,method:t});u=new URLSearchParams(window.location.search).get("useFallbackApi");return[2,S({basePathType:u||l,options:a,path:e})]}))}))}))}}}));
@@ -1 +0,0 @@
1
- import{d as s}from"./p-0ae53ff0.js";import{h as t,b as e}from"./p-a8a312b2.js";const a={},o={},r=async({attributes:r,checkoutSessionId:i})=>{var u;if(a[i]||(a[i]=new Map),r.forEach((s=>{var t;s.value&&(null===(t=a[i])||void 0===t||t.set(s.key,s.value))})),r.length)return o[i]||(o[i]=(u=i,s((async()=>{var s,o;const r=Array.from((null===(s=a[u])||void 0===s?void 0:s.entries())||[]).map((([s,t])=>({key:s,value:t}))),{errors:i,json:n}=await t("/api/zonos-elements/update-checkout-session-attributes",{body:{attributes:r,id:u},method:"POST"});return i.length?(e("Error updating checkout session attributes",i),{success:!1}):(null===(o=a[u])||void 0===o||o.clear(),{success:!!(null==n?void 0:n.success)})}),1e3,{maxWait:5e3}))),o[i]()};export{r as u}
@@ -1 +0,0 @@
1
- var __awaiter=this&&this.__awaiter||function(n,e,t,i){function r(n){return n instanceof t?n:new t((function(e){e(n)}))}return new(t||(t=Promise))((function(t,o){function a(n){try{d(i.next(n))}catch(n){o(n)}}function u(n){try{d(i["throw"](n))}catch(n){o(n)}}function d(n){n.done?t(n.value):r(n.value).then(a,u)}d((i=i.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,r,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(n){return function(e){return d([n,e])}}function d(u){if(i)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(t=0)),t)try{if(i=1,r&&(o=u[0]&2?r["return"]:u[0]?r["throw"]||((o=r["return"])&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;if(r=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:t.label++;return{value:u[1],done:false};case 5:t.label++;r=u[1];u=[0];continue;case 7:u=t.ops.pop();t.trys.pop();continue;default:if(!(o=t.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){t.label=u[1];break}if(u[0]===6&&t.label<o[1]){t.label=o[1];o=u;break}if(o&&t.label<o[2]){t.label=o[2];t.ops.push(u);break}if(o[2])t.ops.pop();t.trys.pop();continue}u=e.call(n,t)}catch(n){u=[6,n];r=0}finally{i=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};System.register(["./p-9d863a3b.system.js","./p-6f6573a5.system.js","./p-640a6898.system.js","./p-062430f9.system.js","./p-5fc34563.system.js"],(function(n){"use strict";var e,t,i,r,o,a,u,d,l,s,c,f;return{setters:[function(n){e=n.c;t=n.z},function(n){i=n.c;r=n.B;o=n.e;a=n.C},function(n){u=n.s},function(n){d=n.h;l=n.s;s=n.d;c=n.b},function(n){f=n.h}],execute:function(){var v=this;var h=e((function(){return{amountDutyTaxFeeTotal:null,amountTotalPaid:null,isFetchingShippingInfo:true,landedCostShortId:null,originCompanyName:null,partyBillingId:null,shippingAddress:null}})),p=h.reset,w=h.state;n("e",w);var _=n("b",(function(n){return __awaiter(v,[n],void 0,(function(n){var e,i,r,a,u,s,c,f,v,h,p,m,y;var C=n.landedCostId,g=n.retries,I=g===void 0?5:g;return __generator(this,(function(n){switch(n.label){case 0:w.isFetchingShippingInfo=true;return[4,d("/api/zonos-elements/collect/get-shipping-info-by-lc-id",{body:{landedCostId:C},method:"POST"})];case 1:h=n.sent();if(!h.errors.length)return[3,4];if(!(I>0))return[3,3];return[4,new Promise((function(n){return setTimeout(n,1e3)}))];case 2:n.sent();return[2,_({landedCostId:C,retries:I-1})];case 3:return[2,null];case 4:w.landedCostShortId=((e=h.json)===null||e===void 0?void 0:e.landedCostShortId)||null;w.isFetchingShippingInfo=false;w.shippingAddress=((i=h.json)===null||i===void 0?void 0:i.shipping)||null;p=(r=o.checkoutSession)===null||r===void 0?void 0:r.landedCost;m=(a=o.checkoutSession)===null||a===void 0?void 0:a.subtotals;y=(((u=p===null||p===void 0?void 0:p.amountSubtotals)===null||u===void 0?void 0:u.shipping)||0)+(((s=p===null||p===void 0?void 0:p.amountSubtotals)===null||s===void 0?void 0:s.items)||0);w.amountTotalPaid=y*(((c=m===null||m===void 0?void 0:m.exchangeRate)===null||c===void 0?void 0:c.rate)||1);w.amountDutyTaxFeeTotal=((m===null||m===void 0?void 0:m.duties)||0)+((m===null||m===void 0?void 0:m.taxes)||0)+((m===null||m===void 0?void 0:m.fees)||0);w.originCompanyName=((v=(f=h.json)===null||f===void 0?void 0:f.origin)===null||v===void 0?void 0:v.companyName)||null;if(w.amountTotalPaid===0){void l({endpoint:"COLLECT_NO_TOTAL_PAID",errors:[],metadata:{landedCostId:C,organizationId:t.organizationId}})}return[2]}}))}))}));var m=n("d",(function(){return __awaiter(v,void 0,void 0,(function(){var n,e,t,a,f,v,h,p,_,m;return __generator(this,(function(y){switch(y.label){case 0:if(!((n=i.stripeBillingAddressEventData)===null||n===void 0?void 0:n.complete)){return[2,{partiesCreated:false}]}f=(t=(e=o.checkoutSession)===null||e===void 0?void 0:e.landedCost)===null||t===void 0?void 0:t.rootId;if(!f){void l({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:s,cartId:window.Zonos.cartId,checkoutSessionId:u.checkoutSessionId}});return[2,{partiesCreated:false}]}if(!u.checkoutSessionId){void l({endpoint:"COLLECT_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:s,cartId:window.Zonos.cartId,landedCostRootId:f}});return[2,{partiesCreated:false}]}v=r({address:i.stripeBillingAddressEventData.value.address,firstName:i.stripeBillingAddressEventData.value.firstName,lastName:i.stripeBillingAddressEventData.value.lastName,name:i.stripeBillingAddressEventData.value.name,phone:i.stripeBillingAddressEventData.value.phone});h=new URLSearchParams(window.location.search).get("zonosE2ETest")==="1";return[4,d("/api/zonos-elements/create-billing-party",{body:{billingAddress:v,checkoutSessionId:u.checkoutSessionId,companyName:i.companyName,email:((a=i.stripeLinkEventData)===null||a===void 0?void 0:a.value.email)||"",isTest:h,rootId:f},method:"POST"})];case 1:p=y.sent(),_=p.errors,m=p.json;if(_.length||!m){c("Error occurs when creating billing party",JSON.stringify(_,null,2));void l({endpoint:"COLLECT_BILLING_PARTY_CREATE_FAILED",errors:["[COLLECT] Failed to create billing party"],metadata:{allLogs:s,cartId:window.Zonos.cartId,checkoutSessionId:u.checkoutSessionId,errors:_,json:m}});return[2,{partiesCreated:false}]}w.partyBillingId=m.billToPartyId;return[2,{partiesCreated:true}]}}))}))}));var y=n("c",(function(n){return __awaiter(v,void 0,void 0,(function(){var e;return __generator(this,(function(t){e=n.landedCost;if(!e){return[2,false]}o.landedCostData=[Object.assign(Object.assign({},n),{landedCost:Object.assign({},e),landedCostId:e.id})];return[2,a({applySubtotalsOnly:true,landedCostId:e.id,selectedShippingOption:e.shipmentRating})]}))}))}));var C=1024;var g=768;var I=n("a",(function(n){return n||window.innerWidth<C&&window.innerWidth>=g}));var b=n("i",(function(n){return n||window.innerWidth<g}));var T=n("r",(function(n){var e=n.content,t=n.isLoading,i=n.skeletonHeight,r=n.skeletonWidth;if(t){return f("zonos-skeleton",{skeletonHeight:i,skeletonWidth:r})}return e}))}}}));