@zonos/elements 1.3.219 → 1.3.220

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 (274) hide show
  1. package/dist/cjs/{cart-9a2b32e4.js → cart-9a9ae4b9.js} +2 -2
  2. package/dist/cjs/index.cjs.js +7 -7
  3. package/dist/cjs/{isCollectMobileTablet-7e57fd90.js → isCollectMobileTablet-7a9413e3.js} +12 -9
  4. package/dist/cjs/{localization-b12edb2a.js → localization-0169b27d.js} +1 -1
  5. package/dist/cjs/{paypal-e80871d0.js → paypal-9ee374a0.js} +3 -3
  6. package/dist/cjs/{placeTestOrder-8222fe95.js → placeTestOrder-0dfff170.js} +2 -2
  7. package/dist/cjs/{translationStore-20a6d8bf.js → translationStore-0c67178f.js} +60 -0
  8. package/dist/cjs/zonos-address_11.cjs.entry.js +40 -28
  9. package/dist/cjs/zonos-badge.cjs.entry.js +3 -3
  10. package/dist/cjs/zonos-banner_2.cjs.entry.js +4 -4
  11. package/dist/cjs/zonos-button_3.cjs.entry.js +3 -3
  12. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +11 -14
  13. package/dist/cjs/zonos-checkout.cjs.entry.js +4 -4
  14. package/dist/cjs/zonos-collapse.cjs.entry.js +2 -2
  15. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +6 -6
  16. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +44 -43
  17. package/dist/cjs/zonos-collect.cjs.entry.js +5 -5
  18. package/dist/cjs/zonos-component.cjs.entry.js +1 -1
  19. package/dist/cjs/zonos-confirm-dialog_2.cjs.entry.js +5 -5
  20. package/dist/cjs/zonos-controller.cjs.entry.js +4 -4
  21. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
  22. package/dist/cjs/zonos-country-select_4.cjs.entry.js +11 -11
  23. package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +14 -6
  24. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +6 -6
  25. package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
  26. package/dist/cjs/zonos-input.cjs.entry.js +4 -4
  27. package/dist/cjs/zonos-language-select_2.cjs.entry.js +6 -6
  28. package/dist/cjs/zonos-link.cjs.entry.js +1 -1
  29. package/dist/cjs/zonos-logo.cjs.entry.js +2 -2
  30. package/dist/cjs/zonos-stripe-input.cjs.entry.js +4 -4
  31. package/dist/cjs/zonos-toggle.cjs.entry.js +2 -2
  32. package/dist/cjs/zonos-tooltip.cjs.entry.js +2 -2
  33. package/dist/cjs/zonos-v-stack.cjs.entry.js +2 -2
  34. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-payment/zonos-checkout-payment.js +0 -3
  35. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +1 -1
  36. package/dist/collection/components/checkout/zonos-collect/zonos-collect-finish/zonos-collect-finish.css +6 -0
  37. package/dist/collection/components/checkout/zonos-collect/zonos-collect-finish/zonos-collect-finish.js +23 -21
  38. package/dist/collection/components/checkout/zonos-collect/zonos-collect-footer/zonos-collect-footer.js +3 -3
  39. package/dist/collection/components/checkout/zonos-collect/zonos-collect-review/zonos-collect-review.css +3 -0
  40. package/dist/collection/components/checkout/zonos-collect/zonos-collect-review/zonos-collect-review.js +3 -3
  41. package/dist/collection/components/checkout/zonos-collect/zonos-collect-subtotal/zonos-collect-subtotal.js +7 -7
  42. package/dist/collection/components/common/zonos-badge/zonos-badge.js +3 -3
  43. package/dist/collection/components/common/zonos-button/zonos-button.js +3 -3
  44. package/dist/collection/components/common/zonos-card/zonos-card.js +4 -4
  45. package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.js +3 -3
  46. package/dist/collection/components/common/zonos-checkout-progress-tabs/zonos-checkout-progress-tabs.js +3 -3
  47. package/dist/collection/components/common/zonos-collapse/zonos-collapse.js +2 -2
  48. package/dist/collection/components/common/zonos-confirm-dialog/zonos-confirm-dialog.js +3 -3
  49. package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +3 -3
  50. package/dist/collection/components/common/zonos-custom-message/zonos-custom-message.js +2 -2
  51. package/dist/collection/components/common/zonos-dialog/zonos-dialog.js +3 -3
  52. package/dist/collection/components/common/zonos-h-stack/zonos-h-stack.js +2 -2
  53. package/dist/collection/components/common/zonos-input/zonos-input.js +4 -4
  54. package/dist/collection/components/common/zonos-language-select/zonos-language-select.js +2 -2
  55. package/dist/collection/components/common/zonos-link/zonos-link.js +1 -1
  56. package/dist/collection/components/common/zonos-loading-overlay/zonos-loading-overlay.js +1 -1
  57. package/dist/collection/components/common/zonos-logo/zonos-logo.js +2 -2
  58. package/dist/collection/components/common/zonos-rest-state/zonos-rest-state.js +3 -3
  59. package/dist/collection/components/common/zonos-select-dialog-header/zonos-select-dialog-header.js +2 -2
  60. package/dist/collection/components/common/zonos-skeleton/zonos-skeleton.js +1 -1
  61. package/dist/collection/components/common/zonos-stripe-input/zonos-stripe-input.js +4 -4
  62. package/dist/collection/components/common/zonos-stripe-phone-input/zonos-stripe-phone-input.js +5 -5
  63. package/dist/collection/components/common/zonos-stripe-select/zonos-stripe-select.js +5 -5
  64. package/dist/collection/components/common/zonos-toggle/zonos-toggle.js +2 -2
  65. package/dist/collection/components/common/zonos-tooltip/zonos-tooltip.js +2 -2
  66. package/dist/collection/components/common/zonos-v-stack/zonos-v-stack.js +2 -2
  67. package/dist/collection/components/common/zonos-virtual-scroll/zonos-virtual-scroll.js +2 -2
  68. package/dist/collection/components/component-template/zonos-component/zonos-component.js +1 -1
  69. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/zonos-hello-dialog-footer.js +2 -2
  70. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +4 -4
  71. package/dist/collection/components/main/zonos-controller.js +1 -1
  72. package/dist/collection/components/paypal/zonos-paypal-payment.js +1 -1
  73. package/dist/collection/components/store/checkout/collect.js +10 -7
  74. package/dist/collection/components/store/translationStore/strings.arabic.js +3 -0
  75. package/dist/collection/components/store/translationStore/strings.base.js +3 -0
  76. package/dist/collection/components/store/translationStore/strings.chinese.js +3 -0
  77. package/dist/collection/components/store/translationStore/strings.danish.js +3 -0
  78. package/dist/collection/components/store/translationStore/strings.dutch.js +3 -0
  79. package/dist/collection/components/store/translationStore/strings.french.js +3 -0
  80. package/dist/collection/components/store/translationStore/strings.german.js +3 -0
  81. package/dist/collection/components/store/translationStore/strings.hebrew.js +3 -0
  82. package/dist/collection/components/store/translationStore/strings.indonesian.js +3 -0
  83. package/dist/collection/components/store/translationStore/strings.italian.js +3 -0
  84. package/dist/collection/components/store/translationStore/strings.japanese.js +3 -0
  85. package/dist/collection/components/store/translationStore/strings.korean.js +3 -0
  86. package/dist/collection/components/store/translationStore/strings.norwegian.js +3 -0
  87. package/dist/collection/components/store/translationStore/strings.polish.js +3 -0
  88. package/dist/collection/components/store/translationStore/strings.portuguese.js +3 -0
  89. package/dist/collection/components/store/translationStore/strings.russian.js +3 -0
  90. package/dist/collection/components/store/translationStore/strings.spanish.js +3 -0
  91. package/dist/collection/components/store/translationStore/strings.swedish.js +3 -0
  92. package/dist/collection/components/store/translationStore/strings.turkish.js +3 -0
  93. package/dist/collection/components/store/translationStore/strings.vietnamese.js +3 -0
  94. package/dist/collection/components/stripe/zonos-address/zonos-address.js +2 -2
  95. package/dist/collection/components/stripe/zonos-custom-address/zonos-address-suggestions/zonos-address-suggestions.js +2 -2
  96. package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +2 -2
  97. package/dist/collection/components/stripe/zonos-link-authentication/zonos-link-authentication.js +15 -3
  98. package/dist/collection/components/stripe/zonos-payment/zonos-payment.js +9 -1
  99. package/dist/collection/types/generated/graphql.internal.types.js +10 -0
  100. package/dist/esm/{cart-acf4ebf5.js → cart-b2dd578c.js} +2 -2
  101. package/dist/esm/index.js +7 -7
  102. package/dist/esm/{isCollectMobileTablet-b72b81c5.js → isCollectMobileTablet-7f9a5e2b.js} +12 -9
  103. package/dist/esm/{localization-8646f526.js → localization-d7125e4e.js} +1 -1
  104. package/dist/esm/{paypal-2fa930eb.js → paypal-555bbf1e.js} +3 -3
  105. package/dist/esm/{placeTestOrder-d1ad9cf6.js → placeTestOrder-2d67c1a9.js} +2 -2
  106. package/dist/esm/{translationStore-c9743292.js → translationStore-13502f49.js} +60 -0
  107. package/dist/esm/zonos-address_11.entry.js +40 -28
  108. package/dist/esm/zonos-badge.entry.js +3 -3
  109. package/dist/esm/zonos-banner_2.entry.js +4 -4
  110. package/dist/esm/zonos-button_3.entry.js +3 -3
  111. package/dist/esm/zonos-cart-items_12.entry.js +11 -14
  112. package/dist/esm/zonos-checkout.entry.js +4 -4
  113. package/dist/esm/zonos-collapse.entry.js +2 -2
  114. package/dist/esm/zonos-collect-cart-items_3.entry.js +6 -6
  115. package/dist/esm/zonos-collect-finish_6.entry.js +44 -43
  116. package/dist/esm/zonos-collect.entry.js +5 -5
  117. package/dist/esm/zonos-component.entry.js +1 -1
  118. package/dist/esm/zonos-confirm-dialog_2.entry.js +5 -5
  119. package/dist/esm/zonos-controller.entry.js +4 -4
  120. package/dist/esm/zonos-country-flag.entry.js +2 -2
  121. package/dist/esm/zonos-country-select_4.entry.js +11 -11
  122. package/dist/esm/zonos-empty-state-payment_4.entry.js +14 -6
  123. package/dist/esm/zonos-hello-dialog.entry.js +6 -6
  124. package/dist/esm/zonos-hello.entry.js +2 -2
  125. package/dist/esm/zonos-input.entry.js +4 -4
  126. package/dist/esm/zonos-language-select_2.entry.js +6 -6
  127. package/dist/esm/zonos-link.entry.js +1 -1
  128. package/dist/esm/zonos-logo.entry.js +2 -2
  129. package/dist/esm/zonos-stripe-input.entry.js +4 -4
  130. package/dist/esm/zonos-toggle.entry.js +2 -2
  131. package/dist/esm/zonos-tooltip.entry.js +2 -2
  132. package/dist/esm/zonos-v-stack.entry.js +2 -2
  133. package/dist/esm-es5/{cart-acf4ebf5.js → cart-b2dd578c.js} +1 -1
  134. package/dist/esm-es5/index.js +1 -1
  135. package/dist/esm-es5/isCollectMobileTablet-7f9a5e2b.js +1 -0
  136. package/dist/esm-es5/{localization-8646f526.js → localization-d7125e4e.js} +1 -1
  137. package/dist/esm-es5/{paypal-2fa930eb.js → paypal-555bbf1e.js} +2 -2
  138. package/dist/esm-es5/{placeTestOrder-d1ad9cf6.js → placeTestOrder-2d67c1a9.js} +1 -1
  139. package/dist/esm-es5/translationStore-13502f49.js +1 -0
  140. package/dist/esm-es5/zonos-address_11.entry.js +1 -1
  141. package/dist/esm-es5/zonos-badge.entry.js +1 -1
  142. package/dist/esm-es5/zonos-banner_2.entry.js +1 -1
  143. package/dist/esm-es5/zonos-button_3.entry.js +1 -1
  144. package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
  145. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  146. package/dist/esm-es5/zonos-collapse.entry.js +1 -1
  147. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  148. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
  149. package/dist/esm-es5/zonos-collect.entry.js +1 -1
  150. package/dist/esm-es5/zonos-component.entry.js +1 -1
  151. package/dist/esm-es5/zonos-confirm-dialog_2.entry.js +1 -1
  152. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  153. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  154. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  155. package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
  156. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  157. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  158. package/dist/esm-es5/zonos-input.entry.js +1 -1
  159. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  160. package/dist/esm-es5/zonos-link.entry.js +1 -1
  161. package/dist/esm-es5/zonos-logo.entry.js +1 -1
  162. package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
  163. package/dist/esm-es5/zonos-toggle.entry.js +1 -1
  164. package/dist/esm-es5/zonos-tooltip.entry.js +1 -1
  165. package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
  166. package/dist/scripts/index.d.ts +5 -4
  167. package/dist/scripts/index.js +1 -1
  168. package/dist/scripts/loadZonos.js +1 -1
  169. package/dist/scripts/zonos.js +1 -1
  170. package/dist/types/components/checkout/zonos-collect/zonos-collect-finish/zonos-collect-finish.d.ts +1 -0
  171. package/dist/types/components/store/translationStore/strings.arabic.d.ts +3 -0
  172. package/dist/types/components/store/translationStore/strings.base.d.ts +3 -0
  173. package/dist/types/components/store/translationStore/strings.chinese.d.ts +3 -0
  174. package/dist/types/components/store/translationStore/strings.danish.d.ts +3 -0
  175. package/dist/types/components/store/translationStore/strings.dutch.d.ts +3 -0
  176. package/dist/types/components/store/translationStore/strings.french.d.ts +3 -0
  177. package/dist/types/components/store/translationStore/strings.german.d.ts +3 -0
  178. package/dist/types/components/store/translationStore/strings.hebrew.d.ts +3 -0
  179. package/dist/types/components/store/translationStore/strings.indonesian.d.ts +3 -0
  180. package/dist/types/components/store/translationStore/strings.italian.d.ts +3 -0
  181. package/dist/types/components/store/translationStore/strings.japanese.d.ts +3 -0
  182. package/dist/types/components/store/translationStore/strings.korean.d.ts +3 -0
  183. package/dist/types/components/store/translationStore/strings.norwegian.d.ts +3 -0
  184. package/dist/types/components/store/translationStore/strings.polish.d.ts +3 -0
  185. package/dist/types/components/store/translationStore/strings.portuguese.d.ts +3 -0
  186. package/dist/types/components/store/translationStore/strings.russian.d.ts +3 -0
  187. package/dist/types/components/store/translationStore/strings.spanish.d.ts +3 -0
  188. package/dist/types/components/store/translationStore/strings.swedish.d.ts +3 -0
  189. package/dist/types/components/store/translationStore/strings.turkish.d.ts +3 -0
  190. package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +3 -0
  191. package/dist/types/components/stripe/zonos-link-authentication/zonos-link-authentication.d.ts +1 -1
  192. package/dist/types/types/generated/graphql.internal.types.d.ts +205 -16
  193. package/dist/types/types/generated/graphql.internal.types.ts +218 -16
  194. package/dist/zonos-elements/index.esm.js +1 -1
  195. package/dist/zonos-elements/{p-d045e2e5.entry.js → p-02667a58.entry.js} +1 -1
  196. package/dist/zonos-elements/{p-c0a54cf6.system.js → p-031d646e.system.js} +1 -1
  197. package/dist/zonos-elements/{p-c3c9b089.entry.js → p-0e07e1d6.entry.js} +1 -1
  198. package/dist/zonos-elements/p-126087a2.system.entry.js +1 -0
  199. package/dist/zonos-elements/{p-03980f76.entry.js → p-14f9bc8c.entry.js} +1 -1
  200. package/dist/zonos-elements/p-27d9abab.js +1 -0
  201. package/dist/zonos-elements/p-2813d72e.system.js +1 -0
  202. package/dist/zonos-elements/{p-10797d2b.system.entry.js → p-295d9c07.system.entry.js} +1 -1
  203. package/dist/zonos-elements/{p-485416ec.js → p-2a6c964d.js} +1 -1
  204. package/dist/zonos-elements/{p-b12ec9f2.system.entry.js → p-2b3c7c77.system.entry.js} +1 -1
  205. package/dist/zonos-elements/{p-6696617a.system.entry.js → p-2b8897d1.system.entry.js} +1 -1
  206. package/dist/zonos-elements/{p-d351ece6.system.entry.js → p-30432622.system.entry.js} +1 -1
  207. package/dist/zonos-elements/{p-9c0b78bf.system.entry.js → p-3462e9e4.system.entry.js} +1 -1
  208. package/dist/zonos-elements/{p-23293a0b.entry.js → p-372c2fc5.entry.js} +1 -1
  209. package/dist/zonos-elements/{p-195b33b6.system.entry.js → p-3c1b1be1.system.entry.js} +1 -1
  210. package/dist/zonos-elements/{p-69fd1b88.js → p-40a4266f.js} +1 -1
  211. package/dist/zonos-elements/{p-f74a6b78.system.entry.js → p-421dfb66.system.entry.js} +1 -1
  212. package/dist/zonos-elements/{p-009c3ac5.system.entry.js → p-4f8563ad.system.entry.js} +1 -1
  213. package/dist/zonos-elements/{p-3c9714a8.system.entry.js → p-52d35358.system.entry.js} +1 -1
  214. package/dist/zonos-elements/{p-d26cffba.entry.js → p-567f7de7.entry.js} +1 -1
  215. package/dist/zonos-elements/p-5d9410da.entry.js +1 -0
  216. package/dist/zonos-elements/{p-f129a83b.system.entry.js → p-637b22ee.system.entry.js} +1 -1
  217. package/dist/zonos-elements/{p-61c2c336.entry.js → p-63a42823.entry.js} +1 -1
  218. package/dist/zonos-elements/{p-8ca25e6c.entry.js → p-6b3a0874.entry.js} +1 -1
  219. package/dist/zonos-elements/p-73c1e91f.js +1 -0
  220. package/dist/zonos-elements/{p-909d36bf.entry.js → p-759ef3ca.entry.js} +1 -1
  221. package/dist/zonos-elements/{p-c8784a01.system.entry.js → p-79d8c3f3.system.entry.js} +1 -1
  222. package/dist/zonos-elements/{p-2c9381be.entry.js → p-7c4e7651.entry.js} +1 -1
  223. package/dist/zonos-elements/{p-70b81bbc.entry.js → p-7d2d2c94.entry.js} +1 -1
  224. package/dist/zonos-elements/{p-e455f060.system.entry.js → p-7e5bd9af.system.entry.js} +1 -1
  225. package/dist/zonos-elements/p-7ecbb2cb.entry.js +1 -0
  226. package/dist/zonos-elements/p-81b357f7.system.js +1 -1
  227. package/dist/zonos-elements/{p-f17fde5f.system.js → p-82e88a33.system.js} +1 -1
  228. package/dist/zonos-elements/{p-873b698a.entry.js → p-849b47aa.entry.js} +1 -1
  229. package/dist/zonos-elements/{p-0cec2dd2.system.entry.js → p-8dd47520.system.entry.js} +1 -1
  230. package/dist/zonos-elements/{p-772ac0b7.js → p-932600b7.js} +1 -1
  231. package/dist/zonos-elements/{p-b1bd9fe7.system.entry.js → p-960e0ab1.system.entry.js} +1 -1
  232. package/dist/zonos-elements/p-9c5b8239.system.js +1 -0
  233. package/dist/zonos-elements/p-9fdd3264.system.entry.js +1 -0
  234. package/dist/zonos-elements/{p-58afbe2b.entry.js → p-a08a005d.entry.js} +1 -1
  235. package/dist/zonos-elements/p-a10de7fb.entry.js +1 -0
  236. package/dist/zonos-elements/p-a49b5e7f.system.entry.js +1 -0
  237. package/dist/zonos-elements/{p-23735db6.entry.js → p-a5b0a636.entry.js} +1 -1
  238. package/dist/zonos-elements/{p-dfb92907.entry.js → p-a77ed1b9.entry.js} +1 -1
  239. package/dist/zonos-elements/{p-750b7f32.system.entry.js → p-a800965d.system.entry.js} +1 -1
  240. package/dist/zonos-elements/{p-aca272ea.entry.js → p-b3d5bcf9.entry.js} +1 -1
  241. package/dist/zonos-elements/{p-2323ff0f.system.entry.js → p-b669050d.system.entry.js} +1 -1
  242. package/dist/zonos-elements/{p-95461a1b.system.entry.js → p-b9e9b82f.system.entry.js} +1 -1
  243. package/dist/zonos-elements/{p-e2a45188.system.entry.js → p-ba18c5f5.system.entry.js} +1 -1
  244. package/dist/zonos-elements/{p-106ae0f1.entry.js → p-bbf48b31.entry.js} +1 -1
  245. package/dist/zonos-elements/{p-b5406d26.entry.js → p-c4b3c878.entry.js} +1 -1
  246. package/dist/zonos-elements/{p-2cc031b3.js → p-c7b57886.js} +2 -2
  247. package/dist/zonos-elements/{p-a7204d41.entry.js → p-c803753e.entry.js} +1 -1
  248. package/dist/zonos-elements/{p-29499a5f.entry.js → p-cbb01de9.entry.js} +1 -1
  249. package/dist/zonos-elements/{p-6dd63754.system.js → p-ce15d62d.system.js} +1 -1
  250. package/dist/zonos-elements/{p-1fe5d4da.system.entry.js → p-d291e964.system.entry.js} +1 -1
  251. package/dist/zonos-elements/{p-07bea979.system.js → p-d3485a03.system.js} +1 -1
  252. package/dist/zonos-elements/{p-f0be0ca9.system.entry.js → p-de626806.system.entry.js} +1 -1
  253. package/dist/zonos-elements/{p-56ee6d4b.system.entry.js → p-e5388438.system.entry.js} +1 -1
  254. package/dist/zonos-elements/{p-0d6c6a38.entry.js → p-e77b6e42.entry.js} +1 -1
  255. package/dist/zonos-elements/{p-d63696ac.system.js → p-ea8aff21.system.js} +1 -1
  256. package/dist/zonos-elements/{p-34a37ce7.system.entry.js → p-eb6a35ce.system.entry.js} +1 -1
  257. package/dist/zonos-elements/{p-60c61982.system.entry.js → p-ee6f8c02.system.entry.js} +1 -1
  258. package/dist/zonos-elements/{p-2a9681b4.entry.js → p-f4fa8720.entry.js} +1 -1
  259. package/dist/zonos-elements/{p-26573347.entry.js → p-fa90adb8.entry.js} +1 -1
  260. package/dist/zonos-elements/{p-bfbc081f.entry.js → p-fe7e2dc4.entry.js} +1 -1
  261. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  262. package/package.json +1 -1
  263. package/dist/esm-es5/isCollectMobileTablet-b72b81c5.js +0 -1
  264. package/dist/esm-es5/translationStore-c9743292.js +0 -1
  265. package/dist/zonos-elements/p-5e372fb9.entry.js +0 -1
  266. package/dist/zonos-elements/p-5ff4f9df.system.js +0 -1
  267. package/dist/zonos-elements/p-6761091e.entry.js +0 -1
  268. package/dist/zonos-elements/p-6761286d.js +0 -1
  269. package/dist/zonos-elements/p-6e8aae27.system.entry.js +0 -1
  270. package/dist/zonos-elements/p-81e23f30.system.js +0 -1
  271. package/dist/zonos-elements/p-87e2a777.entry.js +0 -1
  272. package/dist/zonos-elements/p-986ebccc.js +0 -1
  273. package/dist/zonos-elements/p-ddb29c2a.system.entry.js +0 -1
  274. package/dist/zonos-elements/p-eb54ece4.system.entry.js +0 -1
@@ -0,0 +1 @@
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-b2dd578c.js";import{s as storageStore}from"./localization-d7125e4e.js";import{h as handleFetch,s as sendErrorLog,d as allLogs,b as logError}from"./handleFetch-99218189.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};export{isCollectTablet as a,collectStoreInitShippingInfo as b,collectStoreUpdateSelectedShippingOption as c,collectStoreAsyncAddressUpdate as d,collectStore as e,isCollectMobile as i};
@@ -1 +1 @@
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-c9743292.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
+ 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-13502f49.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,4 +1,4 @@
1
- var __awaiter=this&&this.__awaiter||function(r,e,t,o){function n(r){return r instanceof t?r:new t((function(e){e(r)}))}return new(t||(t=Promise))((function(t,a){function i(r){try{c(o.next(r))}catch(r){a(r)}}function u(r){try{c(o["throw"](r))}catch(r){a(r)}}function c(r){r.done?t(r.value):n(r.value).then(i,u)}c((o=o.apply(r,e||[])).next())}))};var __generator=this&&this.__generator||function(r,e){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:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function u(r){return function(e){return c([r,e])}}function c(u){if(o)throw new TypeError("Generator is already executing.");while(i&&(i=0,u[0]&&(t=0)),t)try{if(o=1,n&&(a=u[0]&2?n["return"]:u[0]?n["throw"]||((a=n["return"])&&a.call(n),0):n.next)&&!(a=a.call(n,u[1])).done)return a;if(n=0,a)u=[u[0]&2,a.value];switch(u[0]){case 0:case 1:a=u;break;case 4:t.label++;return{value:u[1],done:false};case 5:t.label++;n=u[1];u=[0];continue;case 7:u=t.ops.pop();t.trys.pop();continue;default:if(!(a=t.trys,a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){t.label=u[1];break}if(u[0]===6&&t.label<a[1]){t.label=a[1];a=u;break}if(a&&t.label<a[2]){t.label=a[2];t.ops.push(u);break}if(a[2])t.ops.pop();t.trys.pop();continue}u=e.call(r,t)}catch(r){u=[6,r];n=0}finally{o=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};import{z as zonosStore,c as createStore}from"./zonosStore-c456b933.js";import{t as trackConversionEvent,z as validateCheckoutSession,c as stripeStore,e as cartStore,v as stripeStoreHandleInventoryCheck,r as cartStoreNextStep,j as cartStoreClearCheckoutInterval}from"./cart-acf4ebf5.js";import{s as storageStore}from"./localization-8646f526.js";import{t as translate}from"./translationStore-c9743292.js";import{h as handleFetch,l as log,b as logError,j as jsonParse}from"./handleFetch-99218189.js";import{t as tinycolor}from"./isDarkColor-1f58b6be.js";
1
+ var __awaiter=this&&this.__awaiter||function(r,e,t,o){function n(r){return r instanceof t?r:new t((function(e){e(r)}))}return new(t||(t=Promise))((function(t,a){function i(r){try{l(o.next(r))}catch(r){a(r)}}function u(r){try{l(o["throw"](r))}catch(r){a(r)}}function l(r){r.done?t(r.value):n(r.value).then(i,u)}l((o=o.apply(r,e||[])).next())}))};var __generator=this&&this.__generator||function(r,e){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:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function u(r){return function(e){return l([r,e])}}function l(u){if(o)throw new TypeError("Generator is already executing.");while(i&&(i=0,u[0]&&(t=0)),t)try{if(o=1,n&&(a=u[0]&2?n["return"]:u[0]?n["throw"]||((a=n["return"])&&a.call(n),0):n.next)&&!(a=a.call(n,u[1])).done)return a;if(n=0,a)u=[u[0]&2,a.value];switch(u[0]){case 0:case 1:a=u;break;case 4:t.label++;return{value:u[1],done:false};case 5:t.label++;n=u[1];u=[0];continue;case 7:u=t.ops.pop();t.trys.pop();continue;default:if(!(a=t.trys,a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){t.label=u[1];break}if(u[0]===6&&t.label<a[1]){t.label=a[1];a=u;break}if(a&&t.label<a[2]){t.label=a[2];t.ops.push(u);break}if(a[2])t.ops.pop();t.trys.pop();continue}u=e.call(r,t)}catch(r){u=[6,r];n=0}finally{o=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};import{z as zonosStore,c as createStore}from"./zonosStore-c456b933.js";import{t as trackConversionEvent,z as validateCheckoutSession,c as stripeStore,e as cartStore,v as stripeStoreHandleInventoryCheck,r as cartStoreNextStep,j as cartStoreClearCheckoutInterval}from"./cart-b2dd578c.js";import{s as storageStore}from"./localization-d7125e4e.js";import{t as translate}from"./translationStore-13502f49.js";import{h as handleFetch,l as log,b as logError,j as jsonParse}from"./handleFetch-99218189.js";import{t as tinycolor}from"./isDarkColor-1f58b6be.js";
2
2
  /*!
3
3
  * paypal-js v8.1.0 (2024-06-07T16:55:00.122Z)
4
4
  * Copyright 2020-present, PayPal, Inc. All rights reserved.
@@ -14,4 +14,4 @@ var __awaiter=this&&this.__awaiter||function(r,e,t,o){function n(r){return r ins
14
14
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
- */function findScript(r,e){var t=document.querySelector('script[src="'.concat(r,'"]'));if(t===null)return null;var o=createScriptElement(r,e);var n=t.cloneNode();delete n.dataset.uidAuto;if(Object.keys(n.dataset).length!==Object.keys(o.dataset).length){return null}var a=true;Object.keys(n.dataset).forEach((function(r){if(n.dataset[r]!==o.dataset[r]){a=false}}));return a?t:null}function insertScriptElement(r){var e=r.url,t=r.attributes,o=r.onSuccess,n=r.onError;var a=createScriptElement(e,t);a.onerror=n;a.onload=o;document.head.insertBefore(a,document.head.firstElementChild)}function processOptions(r){var e=r.environment;var t=e==="sandbox"?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js";delete r.environment;if(r.sdkBaseUrl){t=r.sdkBaseUrl;delete r.sdkBaseUrl}var o=r;var n=Object.keys(o).filter((function(r){return typeof o[r]!=="undefined"&&o[r]!==null&&o[r]!==""})).reduce((function(r,e){var t=o[e].toString();e=camelCaseToKebabCase(e);if(e.substring(0,4)==="data"||e==="crossorigin"){r.attributes[e]=t}else{r.queryParams[e]=t}return r}),{queryParams:{},attributes:{}}),a=n.queryParams,i=n.attributes;if(a["merchant-id"]&&a["merchant-id"].indexOf(",")!==-1){i["data-merchant-id"]=a["merchant-id"];a["merchant-id"]="*"}return{url:"".concat(t,"?").concat(objectToQueryString(a)),attributes:i}}function camelCaseToKebabCase(r){var e=function(r,e){return(e?"-":"")+r.toLowerCase()};return r.replace(/[A-Z]+(?![a-z])|[A-Z]/g,e)}function objectToQueryString(r){var e="";Object.keys(r).forEach((function(t){if(e.length!==0)e+="&";e+=t+"="+r[t]}));return e}function createScriptElement(r,e){if(e===void 0){e={}}var t=document.createElement("script");t.src=r;Object.keys(e).forEach((function(r){t.setAttribute(r,e[r]);if(r==="data-csp-nonce"){t.setAttribute("nonce",e["data-csp-nonce"])}}));return t}function loadScript(r,e){if(e===void 0){e=Promise}validateArguments(r,e);if(typeof document==="undefined")return e.resolve(null);var t=processOptions(r),o=t.url,n=t.attributes;var a=n["data-namespace"]||"paypal";var i=getPayPalWindowNamespace(a);if(!n["data-js-sdk-library"]){n["data-js-sdk-library"]="paypal-js"}if(findScript(o,n)&&i){return e.resolve(i)}return loadCustomScript({url:o,attributes:n},e).then((function(){var r=getPayPalWindowNamespace(a);if(r){return r}throw new Error("The window.".concat(a," global variable is not available."))}))}function loadCustomScript(r,e){if(e===void 0){e=Promise}validateArguments(r,e);var t=r.url,o=r.attributes;if(typeof t!=="string"||t.length===0){throw new Error("Invalid url.")}if(typeof o!=="undefined"&&typeof o!=="object"){throw new Error("Expected attributes to be an object.")}return new e((function(r,e){if(typeof document==="undefined")return r();insertScriptElement({url:t,attributes:o,onSuccess:function(){return r()},onError:function(){var r=new Error('The script "'.concat(t,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return e(r)}})}))}function getPayPalWindowNamespace(r){return window[r]}function validateArguments(r,e){if(typeof r!=="object"||r===null){throw new Error("Expected an options object.")}var t=r.environment;if(t&&t!=="production"&&t!=="sandbox"){throw new Error('The `environment` option must be either "production" or "sandbox".')}if(typeof e!=="undefined"&&typeof e!=="function"){throw new Error("Expected PromisePonyfill to be a function.")}}var paypalCaptureOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,o;var n=r.checkoutSessionId,a=r.paypalMockResponse;return __generator(this,(function(r){switch(r.label){case 0:return[4,handleFetch("/api/zonos-elements/capture-paypal-order",{body:{checkoutSessionId:n,paypalMockResponse:a},method:"POST"})];case 1:e=r.sent(),t=e.errors,o=e.json;return[2,{errors:t,json:o}]}}))}))};var paypalCreateOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,o;var n=r.checkoutSessionId,a=r.intent;return __generator(this,(function(r){switch(r.label){case 0:return[4,handleFetch("/api/zonos-elements/create-paypal-order",{body:{checkoutSessionId:n,intent:a},method:"POST"})];case 1:e=r.sent(),t=e.errors,o=e.json;return[2,{errors:t,json:o}]}}))}))};var isContrastColor=function(r){var e=r.backgroundColor1,t=r.backgroundColor2;var o=tinycolor.readability(e,t);return o>2.5};var submitGtag=function(r){var e=zonosStore.checkoutSettings.analyticsProviders.find((function(r){return r.type==="GOOGLE_ANALYTICS"}));if(!e||(e===null||e===void 0?void 0:e.status)==="DISABLED"){return}if(typeof window.gtag==="function"){log("Zonos submits gtag event","log",r);window.gtag("event",r,{})}};var _c=createStore((function(){return{intent:"capture",orderIdCreated:null,paypal:null,paypalButtons:[],paypalClientId:"",paypalErrorMessage:null}})),paypalStoreOnChange=_c.onChange,paypalStoreReset=_c.reset,paypalStore=_c.state;var paypalStoreCreaterOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,o,n,a,i,u;var c=r.checkoutSessionId;return __generator(this,(function(r){switch(r.label){case 0:o=paypalStore.intent.toUpperCase();return[4,paypalCreateOrder({checkoutSessionId:c,intent:o})];case 1:n=r.sent(),a=n.errors,i=n.json;u=(e=i===null||i===void 0?void 0:i.paypalOrderCreate)===null||e===void 0?void 0:e.paypalOrderId;if(a.length||!u){throw new Error(((t=a.find(Boolean))===null||t===void 0?void 0:t.message)||"An unexpected error occurred when creating paypal order.")}return[2,u]}}))}))};var paypalStoreCaptureOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,o,n,a,i;var u=r.checkoutSessionId,c=r.paypalMockResponse;return __generator(this,(function(r){switch(r.label){case 0:return[4,paypalCaptureOrder({checkoutSessionId:u,paypalMockResponse:c})];case 1:o=r.sent(),n=o.errors,a=o.json;i=(e=a===null||a===void 0?void 0:a.paypalOrderCapture.order)===null||e===void 0?void 0:e.id;if(n.length||!i){throw new Error(((t=n.find(Boolean))===null||t===void 0?void 0:t.message)||translate("An unexpected error occurred when processing PayPal order."))}return[2,i]}}))}))};var paypalErrorHandler=function(r){var e=r.error;var t;var o=jsonParse(e.message);var n=(t=o===null||o===void 0?void 0:o.errors.find(Boolean))===null||t===void 0?void 0:t.message;var a=(n===null||n===void 0?void 0:n.match(/\[(.*?)\] (.*)/i))||[];if(!a){paypalStore.paypalErrorMessage=translate("An unexpected error occurred when processing PayPal order.")}var i=a[2]||translate("An unexpected error occurred when processing PayPal order.");paypalStore.paypalErrorMessage=i};var paypalButtonOptions=function(r){var e=r.checkoutSessionId,t=r.onPaypalFail,o=r.onPaypalSessionDone,n=r.overrideBorderRaidus,a=r.overridePrimaryColor;var i=a||zonosStore.appearance.colorPrimary;var u="#ffc33a";var c=isContrastColor({backgroundColor1:u,backgroundColor2:i||""});return{createOrder:function(){return __awaiter(void 0,void 0,void 0,(function(){var r,o,n,a,i;return __generator(this,(function(u){switch(u.label){case 0:void trackConversionEvent({checkoutSessionId:e,eventName:"checkout_paymentInfoCompleted",metadata:{paymentMethod:"paypal"}});return[4,validateCheckoutSession()];case 1:r=u.sent();if(!r.valid){paypalStore.paypalErrorMessage=r.errorMessage;stripeStore.hasPaymentError=false;stripeStore.customErrorMessage=null;t===null||t===void 0?void 0:t();return[2,""]}u.label=2;case 2:u.trys.push([2,8,,9]);paypalStore.paypalErrorMessage=null;cartStore.inventoryCheckErrorMessage=null;u.label=3;case 3:u.trys.push([3,5,,6]);o=cartStore;return[4,stripeStoreHandleInventoryCheck()];case 4:o.inventoryCheckErrorMessage=u.sent();return[3,6];case 5:n=u.sent();cartStore.inventoryCheckErrorMessage=translate("Unable to check inventory. Please try again.");return[3,6];case 6:if(cartStore.inventoryCheckErrorMessage){return[2,""]}return[4,paypalStoreCreaterOrder({checkoutSessionId:e})];case 7:a=u.sent();return[2,a];case 8:i=u.sent();logError("Failed to create paypal order",i);paypalStore.paypalErrorMessage=translate("Failed to create PayPal order. Please try again, or consider using an alternative method.");stripeStore.hasPaymentError=false;stripeStore.customErrorMessage=null;t===null||t===void 0?void 0:t();return[2,""];case 9:return[2]}}))}))},onApprove:function(r,n){return __awaiter(void 0,void 0,void 0,(function(){var r,n;return __generator(this,(function(a){switch(a.label){case 0:a.trys.push([0,2,,3]);paypalStore.paypalErrorMessage=null;submitGtag("zonos-checkout-payment-info");return[4,paypalStoreCaptureOrder({checkoutSessionId:e,paypalMockResponse:window.Zonos._paypalMockResponse})];case 1:r=a.sent();paypalStore.orderIdCreated=r;o===null||o===void 0?void 0:o({orderId:r});cartStoreNextStep();cartStoreClearCheckoutInterval();return[3,3];case 2:n=a.sent();logError("==== Failed to capture paypal order",n);if(n instanceof Error){return[2,paypalErrorHandler({error:n})]}t===null||t===void 0?void 0:t();return[3,3];case 3:return[2]}}))}))},style:{borderRadius:n==="SHARP"?0:10,color:c?"gold":"blue",shape:"rect"}}};var paypalStoreResetButtons=function(){if(!paypalStore.paypalButtons.length){return}paypalStore.paypalButtons.forEach((function(r){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,r.close()];case 1:e.sent();return[2]}}))}))}));paypalStore.paypalButtons=[]};var paypalInitScript=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,o,n,a,i;var u=r.currency;return __generator(this,(function(r){switch(r.label){case 0:t=!!((e=zonosStore.checkoutSettings.externalPaymentMethods)===null||e===void 0?void 0:e.find((function(r){return r.type==="PAYPAL"&&r.status==="ENABLED"})));if(!t){log("=== Paypal is disabled for this store","warn");return[2]}o=zonosStore.checkoutSettings.externalServiceTokens.find((function(r){return r.type==="PAYPAL_CLIENT_ID"}));if(!o){log("Failed to load paypal -- missing paypal publishable key","warn");return[2]}n=(!zonosStore.zonosMode||zonosStore.zonosMode==="production")&&zonosStore.checkoutSettings.mode==="LIVE"?"production":"sandbox";a=zonosStore.checkoutSettings.captureDelay&&zonosStore.checkoutSettings.captureDelay>0;paypalStore.intent=a?"authorize":"capture";log("==== Paypal order intent","info",paypalStore.intent);i=window.Zonos;return[4,loadScript({clientId:o.token,currency:u,environment:n,intent:paypalStore.intent})];case 1:i.paypal=r.sent();paypalStore.paypal=window.Zonos.paypal;log("==== Paypal script loaded");return[2]}}))}))};var paypalStoreInitButtons=function(r){var e;var t=window.Zonos.paypal;if(!t){log("Paypal is not available");return null}var o=storageStore.checkoutSessionId;if(!o){log("Paypal is not available due to checkoutSessionId is not available");return null}log("==== Loading Paypal buttons");paypalStoreResetButtons();var n=[(e=t.FUNDING)===null||e===void 0?void 0:e.PAYPAL].filter(Boolean);paypalStore.paypalButtons=n.map((function(e){var n;var a=null;try{a=((n=t.Buttons)===null||n===void 0?void 0:n.call(t,Object.assign(Object.assign({},paypalButtonOptions(Object.assign({checkoutSessionId:o,fundingSource:e},r))),{fundingSource:e})))||null}catch(r){log("===== Failed to load paypal's \"".concat(e,'" button'),"warn",r)}if(a===null||a===void 0?void 0:a.isEligible()){log("==== Paypal button ".concat(e," loaded"));return a}return null})).filter(Boolean);return paypalStore.paypalButtons};var paypalStoreHasPaypalEnabled=function(){var r,e;var t=((e=(r=zonosStore.checkoutSettings.externalPaymentMethods)===null||r===void 0?void 0:r.find((function(r){return r.type==="PAYPAL"})))===null||e===void 0?void 0:e.status)==="ENABLED";return t||!!paypalStore.paypalButtons.length};export{paypalStore as a,paypalInitScript as b,paypalStoreReset as c,paypalStoreInitButtons as d,paypalStoreOnChange as e,isContrastColor as i,paypalStoreHasPaypalEnabled as p,submitGtag as s};
17
+ */function findScript(r,e){var t=document.querySelector('script[src="'.concat(r,'"]'));if(t===null)return null;var o=createScriptElement(r,e);var n=t.cloneNode();delete n.dataset.uidAuto;if(Object.keys(n.dataset).length!==Object.keys(o.dataset).length){return null}var a=true;Object.keys(n.dataset).forEach((function(r){if(n.dataset[r]!==o.dataset[r]){a=false}}));return a?t:null}function insertScriptElement(r){var e=r.url,t=r.attributes,o=r.onSuccess,n=r.onError;var a=createScriptElement(e,t);a.onerror=n;a.onload=o;document.head.insertBefore(a,document.head.firstElementChild)}function processOptions(r){var e=r.environment;var t=e==="sandbox"?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js";delete r.environment;if(r.sdkBaseUrl){t=r.sdkBaseUrl;delete r.sdkBaseUrl}var o=r;var n=Object.keys(o).filter((function(r){return typeof o[r]!=="undefined"&&o[r]!==null&&o[r]!==""})).reduce((function(r,e){var t=o[e].toString();e=camelCaseToKebabCase(e);if(e.substring(0,4)==="data"||e==="crossorigin"){r.attributes[e]=t}else{r.queryParams[e]=t}return r}),{queryParams:{},attributes:{}}),a=n.queryParams,i=n.attributes;if(a["merchant-id"]&&a["merchant-id"].indexOf(",")!==-1){i["data-merchant-id"]=a["merchant-id"];a["merchant-id"]="*"}return{url:"".concat(t,"?").concat(objectToQueryString(a)),attributes:i}}function camelCaseToKebabCase(r){var e=function(r,e){return(e?"-":"")+r.toLowerCase()};return r.replace(/[A-Z]+(?![a-z])|[A-Z]/g,e)}function objectToQueryString(r){var e="";Object.keys(r).forEach((function(t){if(e.length!==0)e+="&";e+=t+"="+r[t]}));return e}function createScriptElement(r,e){if(e===void 0){e={}}var t=document.createElement("script");t.src=r;Object.keys(e).forEach((function(r){t.setAttribute(r,e[r]);if(r==="data-csp-nonce"){t.setAttribute("nonce",e["data-csp-nonce"])}}));return t}function loadScript(r,e){if(e===void 0){e=Promise}validateArguments(r,e);if(typeof document==="undefined")return e.resolve(null);var t=processOptions(r),o=t.url,n=t.attributes;var a=n["data-namespace"]||"paypal";var i=getPayPalWindowNamespace(a);if(!n["data-js-sdk-library"]){n["data-js-sdk-library"]="paypal-js"}if(findScript(o,n)&&i){return e.resolve(i)}return loadCustomScript({url:o,attributes:n},e).then((function(){var r=getPayPalWindowNamespace(a);if(r){return r}throw new Error("The window.".concat(a," global variable is not available."))}))}function loadCustomScript(r,e){if(e===void 0){e=Promise}validateArguments(r,e);var t=r.url,o=r.attributes;if(typeof t!=="string"||t.length===0){throw new Error("Invalid url.")}if(typeof o!=="undefined"&&typeof o!=="object"){throw new Error("Expected attributes to be an object.")}return new e((function(r,e){if(typeof document==="undefined")return r();insertScriptElement({url:t,attributes:o,onSuccess:function(){return r()},onError:function(){var r=new Error('The script "'.concat(t,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return e(r)}})}))}function getPayPalWindowNamespace(r){return window[r]}function validateArguments(r,e){if(typeof r!=="object"||r===null){throw new Error("Expected an options object.")}var t=r.environment;if(t&&t!=="production"&&t!=="sandbox"){throw new Error('The `environment` option must be either "production" or "sandbox".')}if(typeof e!=="undefined"&&typeof e!=="function"){throw new Error("Expected PromisePonyfill to be a function.")}}var paypalCaptureOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,o;var n=r.checkoutSessionId,a=r.paypalMockResponse;return __generator(this,(function(r){switch(r.label){case 0:return[4,handleFetch("/api/zonos-elements/capture-paypal-order",{body:{checkoutSessionId:n,paypalMockResponse:a},method:"POST"})];case 1:e=r.sent(),t=e.errors,o=e.json;return[2,{errors:t,json:o}]}}))}))};var paypalCreateOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,o;var n=r.checkoutSessionId,a=r.intent;return __generator(this,(function(r){switch(r.label){case 0:return[4,handleFetch("/api/zonos-elements/create-paypal-order",{body:{checkoutSessionId:n,intent:a},method:"POST"})];case 1:e=r.sent(),t=e.errors,o=e.json;return[2,{errors:t,json:o}]}}))}))};var isContrastColor=function(r){var e=r.backgroundColor1,t=r.backgroundColor2;var o=tinycolor.readability(e,t);return o>2.5};var submitGtag=function(r){var e=zonosStore.checkoutSettings.analyticsProviders.find((function(r){return r.type==="GOOGLE_ANALYTICS"}));if(!e||(e===null||e===void 0?void 0:e.status)==="DISABLED"){return}if(typeof window.gtag==="function"){log("Zonos submits gtag event","log",r);window.gtag("event",r,{})}};var _c=createStore((function(){return{intent:"capture",orderIdCreated:null,paypal:null,paypalButtons:[],paypalClientId:"",paypalErrorMessage:null}})),paypalStoreOnChange=_c.onChange,paypalStoreReset=_c.reset,paypalStore=_c.state;var paypalStoreCreaterOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,o,n,a,i,u;var l=r.checkoutSessionId;return __generator(this,(function(r){switch(r.label){case 0:o=paypalStore.intent.toUpperCase();return[4,paypalCreateOrder({checkoutSessionId:l,intent:o})];case 1:n=r.sent(),a=n.errors,i=n.json;u=(e=i===null||i===void 0?void 0:i.paypalOrderCreate)===null||e===void 0?void 0:e.paypalOrderId;if(a.length||!u){throw new Error(((t=a.find(Boolean))===null||t===void 0?void 0:t.message)||"An unexpected error occurred when creating paypal order.")}return[2,u]}}))}))};var paypalStoreCaptureOrder=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,o,n,a,i;var u=r.checkoutSessionId,l=r.paypalMockResponse;return __generator(this,(function(r){switch(r.label){case 0:return[4,paypalCaptureOrder({checkoutSessionId:u,paypalMockResponse:l})];case 1:o=r.sent(),n=o.errors,a=o.json;i=(e=a===null||a===void 0?void 0:a.paypalOrderCapture.order)===null||e===void 0?void 0:e.id;if(n.length||!i){throw new Error(((t=n.find(Boolean))===null||t===void 0?void 0:t.message)||translate("An unexpected error occurred when processing PayPal order."))}return[2,i]}}))}))};var paypalErrorHandler=function(r){var e=r.error;var t;var o=jsonParse(e.message);var n=(t=o===null||o===void 0?void 0:o.errors.find(Boolean))===null||t===void 0?void 0:t.message;var a=(n===null||n===void 0?void 0:n.match(/\[(.*?)\] (.*)/i))||[];if(!a){paypalStore.paypalErrorMessage=translate("An unexpected error occurred when processing PayPal order.")}var i=a[2]||translate("An unexpected error occurred when processing PayPal order.");paypalStore.paypalErrorMessage=i};var paypalButtonOptions=function(r){var e=r.checkoutSessionId,t=r.onPaypalFail,o=r.onPaypalSessionDone,n=r.overrideBorderRaidus,a=r.overridePrimaryColor;var i=a||zonosStore.appearance.colorPrimary;var u="#ffc33a";var l=isContrastColor({backgroundColor1:u,backgroundColor2:i||""});return{createOrder:function(){return __awaiter(void 0,void 0,void 0,(function(){var r,o,n,a,i;return __generator(this,(function(u){switch(u.label){case 0:void trackConversionEvent({checkoutSessionId:e,eventName:"checkout_paymentInfoCompleted",metadata:{paymentMethod:"paypal"}});return[4,validateCheckoutSession()];case 1:r=u.sent();if(!r.valid){paypalStore.paypalErrorMessage=r.errorMessage;stripeStore.hasPaymentError=false;stripeStore.customErrorMessage=null;t===null||t===void 0?void 0:t();return[2,""]}u.label=2;case 2:u.trys.push([2,8,,9]);paypalStore.paypalErrorMessage=null;cartStore.inventoryCheckErrorMessage=null;u.label=3;case 3:u.trys.push([3,5,,6]);o=cartStore;return[4,stripeStoreHandleInventoryCheck()];case 4:o.inventoryCheckErrorMessage=u.sent();return[3,6];case 5:n=u.sent();cartStore.inventoryCheckErrorMessage=translate("Unable to check inventory. Please try again.");return[3,6];case 6:if(cartStore.inventoryCheckErrorMessage){return[2,""]}return[4,paypalStoreCreaterOrder({checkoutSessionId:e})];case 7:a=u.sent();return[2,a];case 8:i=u.sent();logError("Failed to create paypal order",i);paypalStore.paypalErrorMessage=translate("Failed to create PayPal order. Please try again, or consider using an alternative method.");stripeStore.hasPaymentError=false;stripeStore.customErrorMessage=null;t===null||t===void 0?void 0:t();return[2,""];case 9:return[2]}}))}))},onApprove:function(r,n){return __awaiter(void 0,void 0,void 0,(function(){var r,n;return __generator(this,(function(a){switch(a.label){case 0:a.trys.push([0,2,,3]);paypalStore.paypalErrorMessage=null;submitGtag("zonos-checkout-payment-info");return[4,paypalStoreCaptureOrder({checkoutSessionId:e,paypalMockResponse:window.Zonos._paypalMockResponse})];case 1:r=a.sent();paypalStore.orderIdCreated=r;o===null||o===void 0?void 0:o({orderId:r});cartStoreNextStep();cartStoreClearCheckoutInterval();return[3,3];case 2:n=a.sent();logError("==== Failed to capture paypal order",n);if(n instanceof Error){return[2,paypalErrorHandler({error:n})]}t===null||t===void 0?void 0:t();return[3,3];case 3:return[2]}}))}))},style:{borderRadius:n==="SHARP"?0:10,color:l?"gold":"blue",shape:"rect"}}};var paypalStoreResetButtons=function(){if(!paypalStore.paypalButtons.length){return}paypalStore.paypalButtons.forEach((function(r){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,r.close()];case 1:e.sent();return[2]}}))}))}));paypalStore.paypalButtons=[]};var paypalInitScript=function(r){return __awaiter(void 0,[r],void 0,(function(r){var e,t,o,n,a,i;var u=r.currency;return __generator(this,(function(r){switch(r.label){case 0:t=!!((e=zonosStore.checkoutSettings.externalPaymentMethods)===null||e===void 0?void 0:e.find((function(r){return r.type==="PAYPAL"&&r.status==="ENABLED"})));if(!t){log("=== Paypal is disabled for this store","warn");return[2]}o=zonosStore.checkoutSettings.externalServiceTokens.find((function(r){return r.type==="PAYPAL_CLIENT_ID"}));if(!o){log("Failed to load paypal -- missing paypal publishable key","warn");return[2]}n=(!zonosStore.zonosMode||zonosStore.zonosMode==="production")&&zonosStore.checkoutSettings.mode==="LIVE"?"production":"sandbox";a=zonosStore.checkoutSettings.captureDelay&&zonosStore.checkoutSettings.captureDelay>0;paypalStore.intent=a?"authorize":"capture";log("==== Paypal order intent","info",paypalStore.intent);i=window.Zonos;return[4,loadScript({clientId:o.token,currency:u,environment:n,intent:paypalStore.intent})];case 1:i.paypal=r.sent();paypalStore.paypal=window.Zonos.paypal;log("==== Paypal script loaded");return[2]}}))}))};var paypalStoreInitButtons=function(r){var e;var t=window.Zonos.paypal;if(!t){log("Paypal is not available");return null}var o=storageStore.checkoutSessionId;if(!o){log("Paypal is not available due to checkoutSessionId is not available");return null}log("==== Loading Paypal buttons");paypalStoreResetButtons();var n=[(e=t.FUNDING)===null||e===void 0?void 0:e.PAYPAL].filter(Boolean);paypalStore.paypalButtons=n.map((function(e){var n;var a=null;try{a=((n=t.Buttons)===null||n===void 0?void 0:n.call(t,Object.assign(Object.assign({},paypalButtonOptions(Object.assign({checkoutSessionId:o,fundingSource:e},r))),{fundingSource:e})))||null}catch(r){log("===== Failed to load paypal's \"".concat(e,'" button'),"warn",r)}if(a===null||a===void 0?void 0:a.isEligible()){log("==== Paypal button ".concat(e," loaded"));return a}return null})).filter(Boolean);return paypalStore.paypalButtons};var paypalStoreHasPaypalEnabled=function(){var r,e;var t=((e=(r=zonosStore.checkoutSettings.externalPaymentMethods)===null||r===void 0?void 0:r.find((function(r){return r.type==="PAYPAL"})))===null||e===void 0?void 0:e.status)==="ENABLED";return t||!!paypalStore.paypalButtons.length};export{paypalStore as a,paypalInitScript as b,paypalStoreReset as c,paypalStoreInitButtons as d,paypalStoreOnChange as e,isContrastColor as i,paypalStoreHasPaypalEnabled as p,submitGtag as s};
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(r,t,e,n){function o(r){return r instanceof e?r:new e((function(t){t(r)}))}return new(e||(e=Promise))((function(e,a){function i(r){try{u(n.next(r))}catch(r){a(r)}}function c(r){try{u(n["throw"](r))}catch(r){a(r)}}function u(r){r.done?e(r.value):o(r.value).then(i,c)}u((n=n.apply(r,t||[])).next())}))};var __generator=this&&this.__generator||function(r,t){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,o,a,i;return i={next:c(0),throw:c(1),return:c(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(r){return function(t){return u([r,t])}}function u(c){if(n)throw new TypeError("Generator is already executing.");while(i&&(i=0,c[0]&&(e=0)),e)try{if(n=1,o&&(a=c[0]&2?o["return"]:c[0]?o["throw"]||((a=o["return"])&&a.call(o),0):o.next)&&!(a=a.call(o,c[1])).done)return a;if(o=0,a)c=[c[0]&2,a.value];switch(c[0]){case 0:case 1:a=c;break;case 4:e.label++;return{value:c[1],done:false};case 5:e.label++;o=c[1];c=[0];continue;case 7:c=e.ops.pop();e.trys.pop();continue;default:if(!(a=e.trys,a=a.length>0&&a[a.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){e.label=c[1];break}if(c[0]===6&&e.label<a[1]){e.label=a[1];a=c;break}if(a&&e.label<a[2]){e.label=a[2];e.ops.push(c);break}if(a[2])e.ops.pop();e.trys.pop();continue}c=t.call(r,e)}catch(r){c=[6,r];o=0}finally{n=a=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}};import{e as cartStore}from"./cart-acf4ebf5.js";import{d as currencyFormat,s as storageStore}from"./localization-8646f526.js";import{b as logError,h as handleFetch}from"./handleFetch-99218189.js";var getDisplayCurrency=function(){var r,t;var e=cartStore.displayBaseCurrency;var n=e&&((r=cartStore.exchangeRate)===null||r===void 0?void 0:r.sourceCurrencyCode)?(t=cartStore.exchangeRate)===null||t===void 0?void 0:t.sourceCurrencyCode:cartStore.currency;return n};var renderCheckoutCurrency=function(r){var t=r.amount,e=r.isForeign;var n,o;var a=((n=cartStore.exchangeRate)===null||n===void 0?void 0:n.rate)||1;var i=cartStore.currency;var c=(o=cartStore.items[0])===null||o===void 0?void 0:o.currencyCode;if(c===i){return currencyFormat({amount:t,currency:i})}var u=cartStore.displayBaseCurrency;var s=getDisplayCurrency();if(e){var f=u?t/a:t;return currencyFormat({amount:f,currency:s})}var l=u?t:t*a;return currencyFormat({amount:l,currency:s})};var placeTestOrder=function(){return __awaiter(void 0,void 0,void 0,(function(){var r,t,e,n,o,a,i,c,u;return __generator(this,(function(s){switch(s.label){case 0:e=(r=cartStore.partiesData.find((function(r){return r.type==="DESTINATION"})))===null||r===void 0?void 0:r.id;n=(t=cartStore.partiesData.find((function(r){return r.type==="PAYOR"})))===null||t===void 0?void 0:t.id;o=storageStore.checkoutSessionId;if(!o||!n||!e){logError("Missing required data",{billToPartyId:n,checkoutSessionId:o,shipToPartyId:e});return[2,{errors:["Missing required data"],json:null}]}a={billToPartyId:n,checkoutSessionId:o,shipToPartyId:e};return[4,handleFetch("/api/zonos-elements/place-test-order",{body:a,method:"POST"})];case 1:i=s.sent(),c=i.errors,u=i.json;if(c.length||!u){logError("Error occurs when placing test order",c);return[2,{errors:c.map((function(r){return r.message})),json:null}]}return[2,{errors:[],json:u}]}}))}))};export{placeTestOrder as p,renderCheckoutCurrency as r};
1
+ var __awaiter=this&&this.__awaiter||function(r,t,e,n){function o(r){return r instanceof e?r:new e((function(t){t(r)}))}return new(e||(e=Promise))((function(e,a){function i(r){try{u(n.next(r))}catch(r){a(r)}}function c(r){try{u(n["throw"](r))}catch(r){a(r)}}function u(r){r.done?e(r.value):o(r.value).then(i,c)}u((n=n.apply(r,t||[])).next())}))};var __generator=this&&this.__generator||function(r,t){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,o,a,i;return i={next:c(0),throw:c(1),return:c(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(r){return function(t){return u([r,t])}}function u(c){if(n)throw new TypeError("Generator is already executing.");while(i&&(i=0,c[0]&&(e=0)),e)try{if(n=1,o&&(a=c[0]&2?o["return"]:c[0]?o["throw"]||((a=o["return"])&&a.call(o),0):o.next)&&!(a=a.call(o,c[1])).done)return a;if(o=0,a)c=[c[0]&2,a.value];switch(c[0]){case 0:case 1:a=c;break;case 4:e.label++;return{value:c[1],done:false};case 5:e.label++;o=c[1];c=[0];continue;case 7:c=e.ops.pop();e.trys.pop();continue;default:if(!(a=e.trys,a=a.length>0&&a[a.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){e.label=c[1];break}if(c[0]===6&&e.label<a[1]){e.label=a[1];a=c;break}if(a&&e.label<a[2]){e.label=a[2];e.ops.push(c);break}if(a[2])e.ops.pop();e.trys.pop();continue}c=t.call(r,e)}catch(r){c=[6,r];o=0}finally{n=a=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}};import{e as cartStore}from"./cart-b2dd578c.js";import{d as currencyFormat,s as storageStore}from"./localization-d7125e4e.js";import{b as logError,h as handleFetch}from"./handleFetch-99218189.js";var getDisplayCurrency=function(){var r,t;var e=cartStore.displayBaseCurrency;var n=e&&((r=cartStore.exchangeRate)===null||r===void 0?void 0:r.sourceCurrencyCode)?(t=cartStore.exchangeRate)===null||t===void 0?void 0:t.sourceCurrencyCode:cartStore.currency;return n};var renderCheckoutCurrency=function(r){var t=r.amount,e=r.isForeign;var n,o;var a=((n=cartStore.exchangeRate)===null||n===void 0?void 0:n.rate)||1;var i=cartStore.currency;var c=(o=cartStore.items[0])===null||o===void 0?void 0:o.currencyCode;if(c===i){return currencyFormat({amount:t,currency:i})}var u=cartStore.displayBaseCurrency;var s=getDisplayCurrency();if(e){var l=u?t/a:t;return currencyFormat({amount:l,currency:s})}var d=u?t:t*a;return currencyFormat({amount:d,currency:s})};var placeTestOrder=function(){return __awaiter(void 0,void 0,void 0,(function(){var r,t,e,n,o,a,i,c,u;return __generator(this,(function(s){switch(s.label){case 0:e=(r=cartStore.partiesData.find((function(r){return r.type==="DESTINATION"})))===null||r===void 0?void 0:r.id;n=(t=cartStore.partiesData.find((function(r){return r.type==="PAYOR"})))===null||t===void 0?void 0:t.id;o=storageStore.checkoutSessionId;if(!o||!n||!e){logError("Missing required data",{billToPartyId:n,checkoutSessionId:o,shipToPartyId:e});return[2,{errors:["Missing required data"],json:null}]}a={billToPartyId:n,checkoutSessionId:o,shipToPartyId:e};return[4,handleFetch("/api/zonos-elements/place-test-order",{body:a,method:"POST"})];case 1:i=s.sent(),c=i.errors,u=i.json;if(c.length||!u){logError("Error occurs when placing test order",c);return[2,{errors:c.map((function(r){return r.message})),json:null}]}return[2,{errors:[],json:u}]}}))}))};export{placeTestOrder as p,renderCheckoutCurrency as r};