@zonos/elements 1.3.7-alpha.0 → 1.3.7

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 (286) hide show
  1. package/dist/cjs/{cart-ecc80eb0.js → cart-eee85bda.js} +145 -100
  2. package/dist/cjs/formatStringWithLinks-52341fc7.js +17 -0
  3. package/dist/cjs/{getBorderRadius-834c321d.js → getBorderRadius-d8f18958.js} +1 -1
  4. package/dist/cjs/{isDarkColor-924e6a7a.js → isDarkColor-57860b44.js} +1 -1
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/submitGtag-a2e1f652.js +55 -0
  7. package/dist/cjs/zonos-address_4.cjs.entry.js +21 -16
  8. package/dist/cjs/zonos-badge_2.cjs.entry.js +6 -6
  9. package/dist/cjs/zonos-banner.cjs.entry.js +1 -1
  10. package/dist/cjs/zonos-button_3.cjs.entry.js +8 -8
  11. package/dist/cjs/zonos-card_2.cjs.entry.js +8 -8
  12. package/dist/cjs/zonos-cart-items_9.cjs.entry.js +35 -33
  13. package/dist/cjs/zonos-checkout.cjs.entry.js +159 -23
  14. package/dist/cjs/zonos-component.cjs.entry.js +1 -1
  15. package/dist/cjs/zonos-controller.cjs.entry.js +28 -9
  16. package/dist/cjs/zonos-country-flag.cjs.entry.js +4 -4
  17. package/dist/cjs/zonos-country-select_3.cjs.entry.js +18 -10
  18. package/dist/cjs/zonos-elements.cjs.js +1 -1
  19. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +9 -7
  20. package/dist/cjs/zonos-hello.cjs.entry.js +25 -11
  21. package/dist/cjs/zonos-link.cjs.entry.js +24 -0
  22. package/dist/cjs/zonos-logo.cjs.entry.js +3 -3
  23. package/dist/cjs/zonos-notification.cjs.entry.js +1 -1
  24. package/dist/cjs/zonos-payment.cjs.entry.js +6 -7
  25. package/dist/cjs/zonos-select-dialog-header_2.cjs.entry.js +5 -5
  26. package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +3 -3
  27. package/dist/cjs/zonos-text.cjs.entry.js +1 -1
  28. package/dist/cjs/{zonosStore-49d4c92a.js → zonosStore-138c5555.js} +5 -3
  29. package/dist/collection/collection-manifest.json +1 -0
  30. package/dist/collection/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.js +1 -6
  31. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +19 -10
  32. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-payment/zonos-checkout-payment.css +3 -0
  33. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +41 -20
  34. package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.css +3 -0
  35. package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +2 -0
  36. package/dist/collection/components/checkout/zonos-checkout/zonos-review/zonos-review.js +1 -6
  37. package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.css +3 -0
  38. package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +5 -0
  39. package/dist/collection/components/common/component-template/zonos-link/zonos-link.css +54 -0
  40. package/dist/collection/components/common/component-template/zonos-link/zonos-link.js +97 -0
  41. package/dist/collection/components/common/zonos-badge/zonos-badge.js +3 -3
  42. package/dist/collection/components/common/zonos-button/zonos-button.css +2 -0
  43. package/dist/collection/components/common/zonos-button/zonos-button.js +4 -4
  44. package/dist/collection/components/common/zonos-card/zonos-card.js +2 -2
  45. package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.js +3 -3
  46. package/dist/collection/components/common/zonos-collapse/zonos-collapse.js +13 -6
  47. package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +8 -2
  48. package/dist/collection/components/common/zonos-custom-message/zonos-custom-message.js +4 -2
  49. package/dist/collection/components/common/zonos-dialog/zonos-dialog.js +3 -3
  50. package/dist/collection/components/common/zonos-language-select/zonos-language-select.js +2 -2
  51. package/dist/collection/components/common/zonos-logo/zonos-logo.js +2 -2
  52. package/dist/collection/components/common/zonos-select-dialog-header/zonos-select-dialog-header.js +2 -2
  53. package/dist/collection/components/common/zonos-shipping-rich-radio/zonos-shipping-rich-radio.js +1 -1
  54. package/dist/collection/components/common/zonos-tooltip/zonos-tooltip.js +2 -2
  55. package/dist/collection/components/common/zonos-v-stack/zonos-v-stack.js +2 -2
  56. package/dist/collection/components/component-template/zonos-component/zonos-component.js +1 -1
  57. package/dist/collection/components/hello/zonos-hello/zonos-hello.js +52 -13
  58. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/zonos-hello-dialog-footer.js +2 -2
  59. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +5 -3
  60. package/dist/collection/components/main/zonos-controller.js +1 -2
  61. package/dist/collection/components/store/checkout/cart.js +2 -2
  62. package/dist/collection/components/store/checkout/stripe.js +26 -4
  63. package/dist/collection/components/store/hello/localization.js +7 -6
  64. package/dist/collection/components/store/zonosStore.js +5 -3
  65. package/dist/collection/components/stripe/zonos-address/zonos-address.js +1 -1
  66. package/dist/collection/components/stripe/zonos-link-authentication/zonos-link-authentication.js +3 -3
  67. package/dist/collection/components/stripe/zonos-payment/zonos-payment.js +3 -3
  68. package/dist/collection/components/utils/api/getLocaleMessages.js +2 -2
  69. package/dist/collection/components/utils/api/trackConversionEvent.js +22 -0
  70. package/dist/collection/components/utils/checkout/isShippableCountry.js +15 -0
  71. package/dist/collection/components/utils/checkout/watchBigcommerceDomesticCheckout.js +111 -0
  72. package/dist/collection/components/utils/formatStringWithLinks.js +13 -0
  73. package/dist/collection/components/utils/handleFetch.js +1 -1
  74. package/dist/collection/components/utils/hello/currencyConversion/defaultCurrencyConverter.js +25 -28
  75. package/dist/collection/components/utils/hello/currencyConversion/getCurrencyElements.js +2 -3
  76. package/dist/collection/components/utils/hello/currencyConversion/getInitialElementAmount.js +8 -6
  77. package/dist/collection/components/utils/hello/initHello.js +23 -3
  78. package/dist/collection/components/utils/logging/log.js +19 -14
  79. package/dist/collection/components/utils/logging/logError.js +2 -2
  80. package/dist/collection/components/utils/logging/sendErrorLog.js +12 -0
  81. package/dist/collection/scripts/checkIfLoadVersionDomain.js +35 -0
  82. package/dist/collection/scripts/zonosBase.js +21 -34
  83. package/dist/collection/styles/stripe/addressRuleStyle.js +4 -0
  84. package/dist/collection/types/generated/graphql.customer.types.js +1 -4
  85. package/dist/collection/types/generated/graphql.frontend.types.js +3 -0
  86. package/dist/components/stripe.js +140 -98
  87. package/dist/components/trackConversionEvent.js +24 -0
  88. package/dist/components/zonos-address2.js +1 -1
  89. package/dist/components/zonos-badge2.js +3 -3
  90. package/dist/components/zonos-button2.js +5 -5
  91. package/dist/components/zonos-card2.js +2 -2
  92. package/dist/components/zonos-cart-subtotal2.js +1 -6
  93. package/dist/components/zonos-checkbox2.js +3 -3
  94. package/dist/components/zonos-checkout-finish2.js +32 -12
  95. package/dist/components/zonos-checkout-payment2.js +1 -1
  96. package/dist/components/zonos-checkout.js +158 -20
  97. package/dist/components/zonos-collapse2.js +13 -6
  98. package/dist/components/zonos-component.js +1 -1
  99. package/dist/components/zonos-controller.js +25 -6
  100. package/dist/components/zonos-country-select2.js +9 -3
  101. package/dist/components/zonos-custom-message2.js +18 -3
  102. package/dist/components/zonos-customer-info2.js +3 -1
  103. package/dist/components/zonos-dialog2.js +3 -3
  104. package/dist/components/zonos-hello-dialog-footer2.js +2 -2
  105. package/dist/components/zonos-hello-dialog2.js +6 -5
  106. package/dist/components/zonos-hello.js +24 -9
  107. package/dist/components/zonos-language-select2.js +3 -3
  108. package/dist/components/zonos-link-authentication2.js +3 -4
  109. package/dist/components/zonos-link.d.ts +11 -0
  110. package/dist/components/zonos-link.js +43 -0
  111. package/dist/components/zonos-logo.js +2 -2
  112. package/dist/components/zonos-payment2.js +3 -4
  113. package/dist/components/zonos-review2.js +1 -6
  114. package/dist/components/zonos-select-dialog-header2.js +2 -2
  115. package/dist/components/zonos-shipping-rich-radio2.js +1 -1
  116. package/dist/components/zonos-shipping2.js +7 -2
  117. package/dist/components/zonos-tooltip2.js +2 -2
  118. package/dist/components/zonos-v-stack2.js +2 -2
  119. package/dist/components/zonosStore.js +5 -3
  120. package/dist/esm/{cart-2a0a6871.js → cart-e261efc1.js} +143 -101
  121. package/dist/esm/formatStringWithLinks-9e819405.js +15 -0
  122. package/dist/esm/{getBorderRadius-0c7dfcf0.js → getBorderRadius-19787feb.js} +1 -1
  123. package/dist/esm/{isDarkColor-d0a57fd2.js → isDarkColor-2344e7a5.js} +1 -1
  124. package/dist/esm/loader.js +1 -1
  125. package/dist/esm/submitGtag-dfc6f1dc.js +51 -0
  126. package/dist/esm/zonos-address_4.entry.js +21 -16
  127. package/dist/esm/zonos-badge_2.entry.js +6 -6
  128. package/dist/esm/zonos-banner.entry.js +1 -1
  129. package/dist/esm/zonos-button_3.entry.js +8 -8
  130. package/dist/esm/zonos-card_2.entry.js +8 -8
  131. package/dist/esm/zonos-cart-items_9.entry.js +35 -33
  132. package/dist/esm/zonos-checkout.entry.js +159 -23
  133. package/dist/esm/zonos-component.entry.js +1 -1
  134. package/dist/esm/zonos-controller.entry.js +28 -9
  135. package/dist/esm/zonos-country-flag.entry.js +4 -4
  136. package/dist/esm/zonos-country-select_3.entry.js +19 -11
  137. package/dist/esm/zonos-elements.js +1 -1
  138. package/dist/esm/zonos-hello-dialog.entry.js +9 -7
  139. package/dist/esm/zonos-hello.entry.js +25 -11
  140. package/dist/esm/zonos-link.entry.js +20 -0
  141. package/dist/esm/zonos-logo.entry.js +3 -3
  142. package/dist/esm/zonos-notification.entry.js +1 -1
  143. package/dist/esm/zonos-payment.entry.js +6 -7
  144. package/dist/esm/zonos-select-dialog-header_2.entry.js +5 -5
  145. package/dist/esm/zonos-shipping-rich-radio.entry.js +3 -3
  146. package/dist/esm/zonos-text.entry.js +1 -1
  147. package/dist/esm/{zonosStore-dec6bd7e.js → zonosStore-00bce01b.js} +5 -3
  148. package/dist/esm-es5/{cart-2a0a6871.js → cart-e261efc1.js} +1 -1
  149. package/dist/esm-es5/formatStringWithLinks-9e819405.js +1 -0
  150. package/dist/esm-es5/{getBorderRadius-0c7dfcf0.js → getBorderRadius-19787feb.js} +1 -1
  151. package/dist/esm-es5/{isDarkColor-d0a57fd2.js → isDarkColor-2344e7a5.js} +1 -1
  152. package/dist/esm-es5/loader.js +1 -1
  153. package/dist/esm-es5/submitGtag-dfc6f1dc.js +1 -0
  154. package/dist/esm-es5/zonos-address_4.entry.js +1 -1
  155. package/dist/esm-es5/zonos-badge_2.entry.js +1 -1
  156. package/dist/esm-es5/zonos-banner.entry.js +1 -1
  157. package/dist/esm-es5/zonos-button_3.entry.js +1 -1
  158. package/dist/esm-es5/zonos-card_2.entry.js +1 -1
  159. package/dist/esm-es5/zonos-cart-items_9.entry.js +1 -1
  160. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  161. package/dist/esm-es5/zonos-component.entry.js +1 -1
  162. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  163. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  164. package/dist/esm-es5/zonos-country-select_3.entry.js +1 -1
  165. package/dist/esm-es5/zonos-elements.js +1 -1
  166. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  167. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  168. package/dist/esm-es5/zonos-link.entry.js +1 -0
  169. package/dist/esm-es5/zonos-logo.entry.js +1 -1
  170. package/dist/esm-es5/zonos-notification.entry.js +1 -1
  171. package/dist/esm-es5/zonos-payment.entry.js +1 -1
  172. package/dist/esm-es5/zonos-select-dialog-header_2.entry.js +1 -1
  173. package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
  174. package/dist/esm-es5/zonos-text.entry.js +1 -1
  175. package/dist/esm-es5/{zonosStore-dec6bd7e.js → zonosStore-00bce01b.js} +1 -1
  176. package/dist/scripts/checkIfLoadVersionDomain.js +1 -0
  177. package/dist/scripts/loadStripe.js +1 -1
  178. package/dist/scripts/loadZonos.js +1 -1
  179. package/dist/scripts/stripe.js +1 -1
  180. package/dist/scripts/zonos.js +1 -1
  181. package/dist/scripts/zonosBase.js +1 -1
  182. package/dist/types/components/checkout/zonos-checkout/zonos-checkout.d.ts +1 -1
  183. package/dist/types/components/common/component-template/zonos-link/zonos-link.d.ts +19 -0
  184. package/dist/types/components/common/zonos-collapse/zonos-collapse.d.ts +1 -0
  185. package/dist/types/components/common/zonos-country-select/zonos-country-select.d.ts +2 -0
  186. package/dist/types/components/hello/zonos-hello/zonos-hello.d.ts +9 -3
  187. package/dist/types/components/store/checkout/cart.d.ts +6 -3
  188. package/dist/types/components/store/checkout/stripe.d.ts +22 -1
  189. package/dist/types/components/store/hello/localization.d.ts +2 -3
  190. package/dist/types/components/store/zonosStore.d.ts +1 -0
  191. package/dist/types/components/utils/api/trackConversionEvent.d.ts +3 -0
  192. package/dist/types/components/utils/checkout/isShippableCountry.d.ts +1 -0
  193. package/dist/types/components/utils/checkout/watchBigcommerceDomesticCheckout.d.ts +20 -0
  194. package/dist/types/components/utils/formatStringWithLinks.d.ts +1 -0
  195. package/dist/types/components/utils/hello/currencyConversion/getCurrencyElements.d.ts +1 -1
  196. package/dist/types/components/utils/logging/log.d.ts +1 -1
  197. package/dist/types/components/utils/logging/sendErrorLog.d.ts +7 -0
  198. package/dist/types/components.d.ts +53 -3
  199. package/dist/types/scripts/checkIfLoadVersionDomain.d.ts +13 -0
  200. package/dist/types/scripts/zonosBase.d.ts +2 -0
  201. package/dist/types/types/checkout/CheckoutConfig.d.ts +1 -1
  202. package/dist/types/types/generated/graphql.customer.types.d.ts +8 -53
  203. package/dist/types/types/generated/graphql.customer.types.ts +18 -62
  204. package/dist/types/types/generated/graphql.frontend.types.d.ts +8 -0
  205. package/dist/types/types/generated/graphql.frontend.types.ts +18 -0
  206. package/dist/zonos-elements/p-066c5893.system.js +1 -1
  207. package/dist/zonos-elements/p-07966463.entry.js +1 -0
  208. package/dist/zonos-elements/p-0c0aa552.js +1 -0
  209. package/dist/zonos-elements/{p-dfd3edcf.entry.js → p-0c91720b.entry.js} +1 -1
  210. package/dist/zonos-elements/p-1119dddf.system.entry.js +1 -0
  211. package/dist/zonos-elements/p-127b480c.entry.js +1 -0
  212. package/dist/zonos-elements/{p-e855966f.system.entry.js → p-143dc0d9.system.entry.js} +1 -1
  213. package/dist/zonos-elements/p-14c3ef38.entry.js +1 -0
  214. package/dist/zonos-elements/{p-55970b10.system.entry.js → p-14d27ce1.system.entry.js} +1 -1
  215. package/dist/zonos-elements/{p-7d1d862f.system.entry.js → p-165d469e.system.entry.js} +1 -1
  216. package/dist/zonos-elements/p-17e87be1.entry.js +1 -0
  217. package/dist/zonos-elements/{p-a95c034c.entry.js → p-1e0dd491.entry.js} +1 -1
  218. package/dist/zonos-elements/{p-34efed1d.entry.js → p-279d1c5f.entry.js} +1 -1
  219. package/dist/zonos-elements/p-2d6557ee.system.js +1 -0
  220. package/dist/zonos-elements/p-314be538.system.entry.js +1 -0
  221. package/dist/zonos-elements/{p-79b910bf.system.entry.js → p-328b7f6f.system.entry.js} +1 -1
  222. package/dist/zonos-elements/p-354603b3.system.entry.js +1 -0
  223. package/dist/zonos-elements/{p-1f85a98c.system.entry.js → p-389599d3.system.entry.js} +1 -1
  224. package/dist/zonos-elements/p-3a1e685f.entry.js +1 -0
  225. package/dist/zonos-elements/{p-a219689f.entry.js → p-3b23e462.entry.js} +1 -1
  226. package/dist/zonos-elements/{p-591eb6dd.system.js → p-49f6a985.system.js} +1 -1
  227. package/dist/zonos-elements/p-4fb77a38.system.entry.js +1 -0
  228. package/dist/zonos-elements/{p-5b44abc8.system.js → p-5496951a.system.js} +1 -1
  229. package/dist/zonos-elements/{p-06652d87.system.entry.js → p-58e2f6a1.system.entry.js} +1 -1
  230. package/dist/zonos-elements/{p-cc63a29f.system.entry.js → p-5c176b23.system.entry.js} +1 -1
  231. package/dist/zonos-elements/p-5d9a000a.system.entry.js +1 -0
  232. package/dist/zonos-elements/p-5f4ba44c.entry.js +1 -0
  233. package/dist/zonos-elements/{p-88a55076.system.entry.js → p-61e5cf29.system.entry.js} +1 -1
  234. package/dist/zonos-elements/p-69e2c59e.entry.js +1 -0
  235. package/dist/zonos-elements/p-745cd869.system.entry.js +1 -0
  236. package/dist/zonos-elements/p-78ba2928.system.js +1 -0
  237. package/dist/zonos-elements/{p-67737613.system.entry.js → p-799d8a17.system.entry.js} +1 -1
  238. package/dist/zonos-elements/{p-375c472a.system.entry.js → p-79b24786.system.entry.js} +1 -1
  239. package/dist/zonos-elements/p-7b87b82f.js +1 -0
  240. package/dist/zonos-elements/{p-e2770968.system.entry.js → p-7c45ce37.system.entry.js} +1 -1
  241. package/dist/zonos-elements/p-7f4f45b3.entry.js +1 -0
  242. package/dist/zonos-elements/{p-2d2e1831.entry.js → p-857cfe35.entry.js} +1 -1
  243. package/dist/zonos-elements/{p-ec4d08b3.system.js → p-91797d4e.system.js} +1 -1
  244. package/dist/zonos-elements/{p-34c03be2.js → p-95e0fc06.js} +1 -1
  245. package/dist/zonos-elements/p-9e6b489d.system.entry.js +1 -0
  246. package/dist/zonos-elements/p-9f4e02a1.entry.js +1 -0
  247. package/dist/zonos-elements/{p-afe40057.entry.js → p-a3cc0f84.entry.js} +1 -1
  248. package/dist/zonos-elements/p-a87561b8.js +1 -0
  249. package/dist/zonos-elements/{p-e161a08c.entry.js → p-ac0a7b8f.entry.js} +1 -1
  250. package/dist/zonos-elements/{p-549c181b.system.js → p-b4725505.system.js} +1 -1
  251. package/dist/zonos-elements/p-c060d475.js +1 -0
  252. package/dist/zonos-elements/p-c2e58ee1.system.entry.js +1 -0
  253. package/dist/zonos-elements/{p-9878a770.js → p-da767f8b.js} +1 -1
  254. package/dist/zonos-elements/p-dd9e8589.entry.js +1 -0
  255. package/dist/zonos-elements/p-f11a3d9e.entry.js +1 -0
  256. package/dist/zonos-elements/{p-8aeb4679.system.entry.js → p-f6eaef7b.system.entry.js} +1 -1
  257. package/dist/zonos-elements/{p-c7098c3b.entry.js → p-f7c36fcc.entry.js} +1 -1
  258. package/dist/zonos-elements/{p-a4de3fb2.entry.js → p-ff64ddc5.entry.js} +1 -1
  259. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  260. package/package.json +1 -1
  261. package/dist/cjs/submitGtag-907e71d3.js +0 -21
  262. package/dist/collection/scripts/extractZonosQaUrl.js +0 -26
  263. package/dist/esm/submitGtag-a38aed23.js +0 -19
  264. package/dist/esm-es5/submitGtag-a38aed23.js +0 -1
  265. package/dist/types/scripts/extractZonosQaUrl.d.ts +0 -11
  266. package/dist/zonos-elements/p-0057e374.entry.js +0 -1
  267. package/dist/zonos-elements/p-0c72fb79.system.entry.js +0 -1
  268. package/dist/zonos-elements/p-290c3670.entry.js +0 -1
  269. package/dist/zonos-elements/p-2f1e1cbb.system.entry.js +0 -1
  270. package/dist/zonos-elements/p-33080cde.system.entry.js +0 -1
  271. package/dist/zonos-elements/p-561e44d6.entry.js +0 -1
  272. package/dist/zonos-elements/p-5c4dc123.js +0 -1
  273. package/dist/zonos-elements/p-656c836b.entry.js +0 -1
  274. package/dist/zonos-elements/p-8d645a00.entry.js +0 -1
  275. package/dist/zonos-elements/p-a3d72a33.entry.js +0 -1
  276. package/dist/zonos-elements/p-a93c594f.entry.js +0 -1
  277. package/dist/zonos-elements/p-b10ff468.entry.js +0 -1
  278. package/dist/zonos-elements/p-b6992dc2.system.entry.js +0 -1
  279. package/dist/zonos-elements/p-bce46c41.js +0 -1
  280. package/dist/zonos-elements/p-c56d4a44.entry.js +0 -1
  281. package/dist/zonos-elements/p-cbb1e700.system.js +0 -1
  282. package/dist/zonos-elements/p-cd8bd5e9.system.entry.js +0 -1
  283. package/dist/zonos-elements/p-d36faf87.system.entry.js +0 -1
  284. package/dist/zonos-elements/p-e2c6ad57.entry.js +0 -1
  285. package/dist/zonos-elements/p-ea93943a.system.entry.js +0 -1
  286. package/dist/zonos-elements/p-f455e08c.js +0 -1
@@ -3,6 +3,7 @@ import { localizationStore } from "../../store/hello/localization";
3
3
  import { translate } from "../../store/translationStore";
4
4
  import { zonosStore } from "../../store/zonosStore";
5
5
  import { classes } from "../../utils/classes";
6
+ import { formatStringWithLinks } from "../../utils/formatStringWithLinks";
6
7
  import { currencyFormat } from "../../utils/hello/currencyConversion/currencyFormat";
7
8
  import { getHasMoreSpaceAbove } from "../../utils/hello/getHasMoreSpaceAbove";
8
9
  import { getHasMoreSpaceOnRight } from "../../utils/hello/getHasMoreSpaceOnRight";
@@ -91,18 +92,19 @@ export class ZonosHelloDialog {
91
92
  const animateFromBottom = this.dialogRef && getHasMoreSpaceAbove(this.dialogRef);
92
93
  const { customMessages } = localizationStore;
93
94
  const welcomeMessage = `${translate('Welcome to')} ${zonosStore.organizationName}!`;
94
- const defaultMessage = ((_a = customMessages.find(x => x.pageName === 'hello_default')) === null || _a === void 0 ? void 0 : _a.message) ||
95
+ const defaultMessageStr = ((_a = customMessages.find(x => x.pageName === 'hello_default')) === null || _a === void 0 ? void 0 : _a.message) ||
95
96
  translate('Know about duties and taxes before you buy. Shop with confidence!');
97
+ const defaultMessage = formatStringWithLinks(defaultMessageStr);
96
98
  const currentPage = this.getCurrentPageEnum();
97
99
  const filteredMessages = customMessages.filter(x => x.pageName === currentPage);
98
- return (h(Host, { key: '303f914b4511500edcd8d041ccfd52f0c48a7a85', class: "zonos--elements" }, h("div", { key: 'f52025ee53c0cdbbf20ecbb874e5639194b6507b', "aria-hidden": "true", class: classes([
100
+ return (h(Host, { key: 'd5ac86955cf9f9a22e47fe2154dee6e10f6a9361', class: "zonos--elements" }, h("div", { key: 'd34dd3f937330cd5fdd2d7a11dc321c215983146', "aria-hidden": "true", class: classes([
99
101
  'zonos--hello-dialog',
100
102
  animateLeft && 'zonos--hello-dialog-animate-from-left',
101
103
  animateFromBottom && 'zonos--hello-dialog-animate-from-bottom',
102
104
  !!this.mobileLocationOverride &&
103
105
  'zonos--hello-dialog-mobile-override',
104
106
  this.isOpen && 'zonos--hello-dialog-open',
105
- ]), ref: el => el && (this.dialogRef = el) }, !this.showCountrySelect && !this.showLanguageSelect && (h("div", null, h("div", { class: "zonos--hello-dialog-content" }, h("zonos-button", { class: "zonos--close-button", icon: h("zonos-icon", { "aria-label": "Close Zonos Hello dialog", content: RemoveIcon }), noBackground: true, onClick: () => this.setIsOpen(false) }), h("zonos-v-stack", { spacing: 24 }, h("zonos-country-flag", { class: "zonos--hello-country-flag", countryCode: selectedCountryCode }), h("zonos-v-stack", { class: "zonos--hello-dialog-header", spacing: 4 }, h("zonos-text", { type: "boldSubheader" }, welcomeMessage), h("zonos-text", { textColor: "gray-800" }, defaultMessage)), h("zonos-v-stack", { spacing: 8 }, this.restrictedItems.map(item => {
107
+ ]), ref: el => el && (this.dialogRef = el) }, !this.showCountrySelect && !this.showLanguageSelect && (h("div", null, h("div", { class: "zonos--hello-dialog-content" }, h("zonos-button", { class: "zonos--close-button", icon: h("zonos-icon", { "aria-label": "Close Zonos Hello dialog", content: RemoveIcon }), noBackground: true, onClick: () => this.setIsOpen(false) }), h("zonos-v-stack", { spacing: 24 }, h("zonos-country-flag", { class: "zonos--hello-country-flag", countryCode: selectedCountryCode }), h("zonos-v-stack", { class: "zonos--hello-dialog-header", spacing: 4 }, h("zonos-text", { type: "boldSubheader" }, welcomeMessage), h("zonos-text", { innerHTML: defaultMessage, textColor: "gray-800" })), h("zonos-v-stack", { spacing: 8 }, this.restrictedItems.map(item => {
106
108
  var _a;
107
109
  return item && (h("zonos-banner", { bannerTitle: item.name, intent: "error" }, (_a = item.itemRestrictions) === null || _a === void 0 ? void 0 : _a.map(x => (h("zonos-text", { textColor: "red-800" }, x === null || x === void 0 ? void 0 : x.note)))));
108
110
  }), h("zonos-card", { spacing: "12px" }, h("zonos-v-stack", { spacing: 12 }, h("div", { class: "zonos--flex-message" }, h("zonos-icon", { "aria-label": "Duty de minimis", content: BagIcon }), h("zonos-text", null, dutyDeMinimisMessage)), h("div", { class: "zonos--flex-message" }, h("zonos-icon", { "aria-label": "Tax de minimis", content: MoneyIcon }), h("zonos-text", null, taxDeMinimisMessage)))), filteredMessages.map(x => (h("zonos-custom-message", { icon: MessageIcon, message: x.message })))))), h("zonos-hello-dialog-footer", { appearanceSettings: this.appearanceSettings, setShowCountrySelect: value => this.setShowCountrySelect(value), setShowLanguageSelect: value => this.setShowLanguageSelect(value) }))), this.showCountrySelect && (h("div", null, h("zonos-country-select", { handleOnClose: () => this.setShowCountrySelect(false) }))), this.showLanguageSelect && (h("div", null, h("zonos-language-select", { handleOnClose: () => this.setShowLanguageSelect(false) }))))));
@@ -17,7 +17,6 @@ export class ZonosController {
17
17
  */
18
18
  async initCheckoutElement(stripe) {
19
19
  if (!stripe) {
20
- // eslint-disable-next-line no-console
21
20
  log('Stripe is not loaded yet - cannot init checkout element', 'warn');
22
21
  return;
23
22
  }
@@ -153,7 +152,7 @@ export class ZonosController {
153
152
  zonosStore.organizationName = organizationName;
154
153
  }
155
154
  render() {
156
- return h(Host, { key: '5650218b8eef4246ff1b131fcd1a06319800c2e3', class: "zonos--elements" });
155
+ return h(Host, { key: '0b734aaa82bd08277fb3a2694197b13242a4d0a6', class: "zonos--elements" });
157
156
  }
158
157
  static get is() { return "zonos-controller"; }
159
158
  static get encapsulation() { return "shadow"; }
@@ -85,14 +85,14 @@ const cartStoreReCalculateTotal = async ({ currency, itemsAmount, landedCostId,
85
85
  logError('Could not update cart total without checkout session id');
86
86
  return false;
87
87
  }
88
- const { json } = await stripeStoreUpdateCheckoutSession({
88
+ const { errors, json } = await stripeStoreUpdateCheckoutSession({
89
89
  currency,
90
90
  id: cartStore.checkoutSessionId,
91
91
  itemsAmount,
92
92
  landedCostId,
93
93
  presentmentCountryCode: localizationStore.selectedCountryCode,
94
94
  });
95
- if (!json) {
95
+ if (errors.length > 0 || !json) {
96
96
  // do nothing if we can't get checkout session
97
97
  logError('Error occurs when updating checkout session');
98
98
  cartStoreUpdateToErrorState({
@@ -6,6 +6,7 @@ import { zonosStore } from "../zonosStore";
6
6
  import { calculateLandedCost } from "../../utils/api/calculateLandedCost";
7
7
  import { handleFetch } from "../../utils/handleFetch";
8
8
  import { isDarkColor } from "../../utils/isDarkColor";
9
+ import { jsonParse } from "../../utils/jsonParse";
9
10
  import { log } from "../../utils/logging/log";
10
11
  import { logError } from "../../utils/logging/logError";
11
12
  import { addressRuleStyle } from "../../../styles/stripe/addressRuleStyle";
@@ -56,6 +57,17 @@ const getStripeOptions = ({ clientSecret, overrideBorderRaidus, overridePrimaryC
56
57
  locale: localizationStore.selectedLocale,
57
58
  };
58
59
  };
60
+ const stripeStoreCleanupDomesticShippingSession = () => {
61
+ window.sessionStorage.removeItem('zonos--bigcommerce-domestic-checkout-shipping');
62
+ };
63
+ // Save shipping address to session storage
64
+ const stripeStoreSaveDomesticShippingSession = (props) => {
65
+ window.sessionStorage.setItem('zonos--bigcommerce-domestic-checkout-shipping', JSON.stringify(props));
66
+ };
67
+ const stripeStoreGetDomesticShippingSession = () => {
68
+ const session = window.sessionStorage.getItem('zonos--bigcommerce-domestic-checkout-shipping');
69
+ return jsonParse(session);
70
+ };
59
71
  const initStripeElements = async (props) => {
60
72
  var _a, _b;
61
73
  const clientSecret = stripeStore.clientSecret;
@@ -157,12 +169,18 @@ const stripeStorePrefetchLandedCost = async () => {
157
169
  try {
158
170
  const abortController = new AbortController();
159
171
  stripeStore.fetchingLandedCostAbordController = abortController;
160
- const { checkoutSessionWorkflow, shipmentRatingCalculateWorkflow } = await calculateLandedCost(abortController);
172
+ const { checkoutSessionWorkflow, landedCostCalculateWorkflow, shipmentRatingCalculateWorkflow, } = await calculateLandedCost(abortController);
161
173
  // reset abort controller after we are done
162
174
  stripeStore.fetchingLandedCostAbordController = null;
163
175
  // update cart store with landed cost info
164
176
  cartStore.landedCostData =
165
- (checkoutSessionWorkflow === null || checkoutSessionWorkflow === void 0 ? void 0 : checkoutSessionWorkflow.filter(Boolean)) || null;
177
+ (checkoutSessionWorkflow === null || checkoutSessionWorkflow === void 0 ? void 0 : checkoutSessionWorkflow.map(checkoutSession => {
178
+ const foundLandedCost = landedCostCalculateWorkflow === null || landedCostCalculateWorkflow === void 0 ? void 0 : landedCostCalculateWorkflow.find(item => { var _a; return (item === null || item === void 0 ? void 0 : item.id) === ((_a = checkoutSession.landedCost) === null || _a === void 0 ? void 0 : _a.id); });
179
+ if (!foundLandedCost) {
180
+ return null;
181
+ }
182
+ return Object.assign(Object.assign({}, checkoutSession), { landedCost: foundLandedCost });
183
+ }).filter(Boolean)) || null;
166
184
  cartStore.shippingData =
167
185
  (shipmentRatingCalculateWorkflow === null || shipmentRatingCalculateWorkflow === void 0 ? void 0 : shipmentRatingCalculateWorkflow.filter(Boolean)) || null;
168
186
  // apply new subtotal and total, this is mainly to show items in the presentment currency
@@ -247,7 +265,11 @@ const stripeStoreRetrievePayment = async ({ clientSecret: _clientSecret, storybo
247
265
  const { paymentIntent } = await stripeStore.stripe.retrievePaymentIntent(clientSecret);
248
266
  const status = paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status;
249
267
  const { isError, messages } = getStripeMessageBasedOnStatus(status);
250
- return { error: isError, messages };
268
+ return {
269
+ error: isError,
270
+ messages,
271
+ paymentMethod: paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.payment_method,
272
+ };
251
273
  };
252
274
  const stripeStoreConfirmPayment = async () => {
253
275
  var _a, _b, _c;
@@ -347,4 +369,4 @@ onChange('clientSecret', clientSecret => {
347
369
  sessionStorage.removeItem('zonos--client-secret');
348
370
  }
349
371
  });
350
- export { initStripeElements, stripeStore, stripeStoreConfirmPayment, stripeStoreInitCheckoutSession, stripeStorePrefetchLandedCost, stripeStoreReset, stripeStoreRetrievePayment, stripeStoreUpdateCheckoutSession, };
372
+ export { initStripeElements, stripeStore, stripeStoreCleanupDomesticShippingSession, stripeStoreConfirmPayment, stripeStoreGetDomesticShippingSession, stripeStoreInitCheckoutSession, stripeStorePrefetchLandedCost, stripeStoreReset, stripeStoreRetrievePayment, stripeStoreSaveDomesticShippingSession, stripeStoreUpdateCheckoutSession, };
@@ -60,11 +60,9 @@ const getNewLocalization = async () => {
60
60
  !selectedCountryCode) {
61
61
  return;
62
62
  }
63
- if (zonosStore.sourceCurrency !== localizationStore.targetCurrency) {
64
- const isGuaranteed = zonosStore.checkoutSettings.visibilityStatus === 'ENABLED';
65
- const { maxAge } = await triggerGetExchangeRate(isGuaranteed);
66
- startExchangeRateTimeout({ isGuaranteed, maxAge });
67
- }
63
+ const isGuaranteed = zonosStore.checkoutSettings.visibilityStatus === 'ENABLED';
64
+ const { maxAge } = await triggerGetExchangeRate(isGuaranteed);
65
+ startExchangeRateTimeout({ isGuaranteed, maxAge });
68
66
  localizationStore.countryLandedCost = await getCountryLandedCost(localizationStore.selectedCountryCode);
69
67
  };
70
68
  const getCustomMessages = async () => {
@@ -91,7 +89,8 @@ const getOverrideLocale = () => {
91
89
  const zonosLocale = currentUrl.searchParams.get('zonosLocale');
92
90
  return zonosLocale;
93
91
  };
94
- const localizationStoreUpdateSelectedCountryCode = async (newSelectedCountryCode) => {
92
+ const localizationStoreUpdateSelectedCountryCode = (newSelectedCountryCode) => {
93
+ var _a;
95
94
  log('update selected country code');
96
95
  localizationStore.selectedCountryCode = newSelectedCountryCode;
97
96
  const { selectedCountryCode, shippingZoneCountries } = localizationStore;
@@ -115,6 +114,8 @@ const localizationStoreUpdateSelectedCountryCode = async (newSelectedCountryCode
115
114
  window.sessionStorage.setItem('zonos--country', selectedCountryCode);
116
115
  // Update the URL query param with the new country code
117
116
  setZCountryUrlParam(selectedCountryCode);
117
+ (_a = document
118
+ .querySelector('zonos-hello')) === null || _a === void 0 ? void 0 : _a.setAttribute('z-country', selectedCountryCode);
118
119
  };
119
120
  const initLocalizationStore = async () => {
120
121
  // all countries from countries.json, shipping zone and localization
@@ -64,6 +64,7 @@ const { reset, state: zonosStore } = createStore(() => ({
64
64
  restrictionBehavior: 'DISABLED',
65
65
  },
66
66
  loadedConfig: false,
67
+ organizationId: '',
67
68
  organizationName: '',
68
69
  sourceCurrency: 'USD',
69
70
  storeId: null,
@@ -76,7 +77,7 @@ let savedZonosSettings = null;
76
77
  * Init setting from zonos setting
77
78
  */
78
79
  const zonosStoreInitSetting = ({ overrideSettings, zonosSettings, }) => {
79
- var _a, _b, _c;
80
+ var _a, _b, _c, _d;
80
81
  reset();
81
82
  if (zonosSettings) {
82
83
  // save zonos settings to be used later
@@ -91,8 +92,9 @@ const zonosStoreInitSetting = ({ overrideSettings, zonosSettings, }) => {
91
92
  zonosStore.helloSettings = mergeConfig(zonosStore.helloSettings, (savedZonosSettings === null || savedZonosSettings === void 0 ? void 0 : savedZonosSettings.helloSettings) || (zonosSettings === null || zonosSettings === void 0 ? void 0 : zonosSettings.helloSettings) || null, overrideSettings === null || overrideSettings === void 0 ? void 0 : overrideSettings.helloSettings);
92
93
  // set flag to true to indicate that config is ready
93
94
  zonosStore.loadedConfig = true;
94
- zonosStore.organizationName = ((_a = zonosSettings === null || zonosSettings === void 0 ? void 0 : zonosSettings.organization) === null || _a === void 0 ? void 0 : _a.name) || '';
95
- zonosStore.storeId = ((_c = (_b = zonosSettings === null || zonosSettings === void 0 ? void 0 : zonosSettings.organization) === null || _b === void 0 ? void 0 : _b.references) === null || _c === void 0 ? void 0 : _c.storeId) || null;
95
+ zonosStore.organizationId = ((_a = zonosSettings === null || zonosSettings === void 0 ? void 0 : zonosSettings.organization) === null || _a === void 0 ? void 0 : _a.id) || '';
96
+ zonosStore.organizationName = ((_b = zonosSettings === null || zonosSettings === void 0 ? void 0 : zonosSettings.organization) === null || _b === void 0 ? void 0 : _b.name) || '';
97
+ zonosStore.storeId = ((_d = (_c = zonosSettings === null || zonosSettings === void 0 ? void 0 : zonosSettings.organization) === null || _c === void 0 ? void 0 : _c.references) === null || _d === void 0 ? void 0 : _d.storeId) || null;
96
98
  zonosStore.currencyConverter = overrideSettings === null || overrideSettings === void 0 ? void 0 : overrideSettings.currencyConverter;
97
99
  };
98
100
  const zonosStoreFontFamily = () => {
@@ -135,7 +135,7 @@ export class ZonosAddress {
135
135
  }
136
136
  render() {
137
137
  // this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
138
- return (h(Host, { key: 'b2aa1ee3f16ae4ebcce83b599c97aa80f09dc9d3', class: "zonos--address zonos--elements" }, h("zonos-text", { key: 'e37392d0add0ab8541f78131abdf9082fd2455b4', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), h("div", { key: 'd28d1908ee2f525455b0680e25cff3040093ad74', class: "zonos--address-component" })));
138
+ return (h(Host, { key: '8d762300d8f599a277806d861d13d2beb6a0a5a6', class: "zonos--address zonos--elements" }, h("zonos-text", { key: 'c355eece2f193cb0595ede434238f062b2c07c7c', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), h("div", { key: '59c3bd68cd67c8d733fd2ca5d9f4b4114c84db4a', class: "zonos--address-component" })));
139
139
  }
140
140
  static get is() { return "zonos-address"; }
141
141
  static get encapsulation() { return "scoped"; }
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { h, Host } from "@stencil/core";
3
3
  import { stripeStore, stripeStorePrefetchLandedCost, } from "../../store/checkout/stripe";
4
+ import { logError } from "../../utils/logging/logError";
4
5
  /**
5
6
  * This component is a wrapper for the stripe authentication element that would render default style object
6
7
  */
@@ -18,8 +19,7 @@ export class ZonosLinkAuthentication {
18
19
  stripeStore.stripeElements.create('linkAuthentication');
19
20
  const linkAuthenticationElementContainer = this.el.querySelector('.zonos--link-authentication-component');
20
21
  if (!linkAuthenticationElementContainer) {
21
- // eslint-disable-next-line no-console
22
- console.error('Cannot find container element for linkAuthenticationElement');
22
+ logError('Cannot find container element for linkAuthenticationElement');
23
23
  return;
24
24
  }
25
25
  linkAuthenticationElement.mount(linkAuthenticationElementContainer);
@@ -36,7 +36,7 @@ export class ZonosLinkAuthentication {
36
36
  }
37
37
  render() {
38
38
  // this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
39
- return (h(Host, { key: 'aec893e026a60bcbf81e93a3c63a842f97437dcc', class: "zonos--link-authentication zonos--elements" }, h("zonos-text", { key: '93c2c462d3a108364d2dfbc4aeab058f87bcc7b3', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), h("div", { key: '0098e20d87cce7547fc1abf26859c0d3765407cd', class: "zonos--link-authentication-component" })));
39
+ return (h(Host, { key: '671681b3ca3e95ab25a70cb44e84db7e2b3903e8', class: "zonos--link-authentication zonos--elements" }, h("zonos-text", { key: '8d20c795500e3ce27b92cdeb0446908e550f9f13', class: "zonos--title", type: "semiBoldLabel" }, this.titleText), h("div", { key: 'b8374d7d7a4844b4c2cf6363b8d2d225bb52b21d', class: "zonos--link-authentication-component" })));
40
40
  }
41
41
  static get is() { return "zonos-link-authentication"; }
42
42
  static get encapsulation() { return "scoped"; }
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { h, Host } from "@stencil/core";
3
3
  import { stripeStore } from "../../store/checkout/stripe";
4
+ import { logError } from "../../utils/logging/logError";
4
5
  /**
5
6
  * This component is a wrapper for the stripe authentication element that would render default style object
6
7
  */
@@ -21,8 +22,7 @@ export class ZonosPayment {
21
22
  });
22
23
  const paymentElementContainer = this.el.querySelector('.zonos--payment-component');
23
24
  if (!paymentElementContainer) {
24
- // eslint-disable-next-line no-console
25
- console.error('Cannot find container element for paymentElement');
25
+ logError('Cannot find container element for paymentElement');
26
26
  return;
27
27
  }
28
28
  paymentElement.mount(paymentElementContainer);
@@ -37,7 +37,7 @@ export class ZonosPayment {
37
37
  }
38
38
  render() {
39
39
  // this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
40
- return (h(Host, { key: 'd5b7717fa4b80da99ae6ba2d7cccbe318e091f8f', class: "zonos--payment zonos--elements" }, this.titleText && (h("zonos-text", { class: "zonos--title", type: "semiBoldLabel" }, this.titleText)), h("div", { key: '37bd2c2dcc59613857b9fd22d864c0d11b2a7319', class: "zonos--payment-component" })));
40
+ return (h(Host, { key: 'e10a4ce1a9ecf05ad8efaceeb861284a92e475d2', class: "zonos--payment zonos--elements" }, this.titleText && (h("zonos-text", { class: "zonos--title", type: "semiBoldLabel" }, this.titleText)), h("div", { key: 'a1b52de6a2cec2f707e00c39ebcd7752ad191af6', class: "zonos--payment-component" })));
41
41
  }
42
42
  static get is() { return "zonos-payment"; }
43
43
  static get encapsulation() { return "scoped"; }
@@ -1,11 +1,11 @@
1
1
  import { handleFetch } from "../handleFetch";
2
+ import { logError } from "../logging/logError";
2
3
  export const getLocaleMessages = async ({ countryCode, localeTo, storeId, }) => {
3
4
  var _a;
4
5
  const url = `${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/zonos-elements/locale-messages?countryCode=${countryCode}&storeId=${storeId}&localeTo=${localeTo}`;
5
6
  const { errors, json } = await handleFetch(url);
6
7
  if (errors.length || !json) {
7
- // eslint-disable-next-line no-console
8
- console.error('Error fetching exchange rate', (_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message);
8
+ logError('Error fetching exchange rate', (_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message);
9
9
  return [];
10
10
  }
11
11
  return json.locale_countryCodesPage;
@@ -0,0 +1,22 @@
1
+ import { localizationStore } from "../../store/hello/localization";
2
+ import { zonosStore } from "../../store/zonosStore";
3
+ import { handleFetch } from "../handleFetch";
4
+ export const trackConversionEvent = async (eventName, metadata) => {
5
+ // If a Zonos domain, we don't want analytics to be tracked
6
+ if (window.location.href.includes('zonos.com')) {
7
+ return;
8
+ }
9
+ const url = `${process.env.NEXT_PUBLIC_ZONOS_ROUTE_URL}/api/zonos-elements/track-conversion-event`;
10
+ const countryCode = localizationStore.selectedCountryCode;
11
+ const organizationId = zonosStore.organizationId;
12
+ const body = {
13
+ countryCode,
14
+ eventName,
15
+ metadata,
16
+ organizationId,
17
+ };
18
+ await handleFetch(url, {
19
+ body,
20
+ method: 'POST',
21
+ });
22
+ };
@@ -0,0 +1,15 @@
1
+ import { localizationStore } from "../../store/hello/localization";
2
+ import { log } from "../logging/log";
3
+ export const isShippableCountry = (showLog = true) => {
4
+ if (!localizationStore.localizationLoaded) {
5
+ return false;
6
+ }
7
+ // if localization is loaded and the localization is not a shippable country, keep the original click event
8
+ if (!localizationStore.isShippableCountry) {
9
+ if (showLog) {
10
+ log(`Checkout: not shippable country`);
11
+ }
12
+ return false;
13
+ }
14
+ return true;
15
+ };
@@ -0,0 +1,111 @@
1
+ import { stripeStoreCleanupDomesticShippingSession, stripeStoreGetDomesticShippingSession, stripeStoreSaveDomesticShippingSession, } from "../../store/checkout/stripe";
2
+ import { localizationStoreUpdateSelectedCountryCode } from "../../store/hello/localization";
3
+ import { zonosStore } from "../../store/zonosStore";
4
+ import { isShippableCountry } from "./isShippableCountry";
5
+ import { logError } from "../logging/logError";
6
+ import { sendErrorLog } from "../logging/sendErrorLog";
7
+ /**
8
+ * Watch for changes in domestic checkout step, this is to redirect user to home page and open checkout if user enters the ship to country that's in the shipping zone
9
+ * @note Only works on default bigcommerce checkout page
10
+ */
11
+ export const watchBigcommerceDomesticCheckout = ({ domesticRedirectedBtnSelector, onShippingAddressSessionFound, }) => {
12
+ if (!window.Zonos.isBigCommerce) {
13
+ return;
14
+ }
15
+ const observer = new MutationObserver(async () => {
16
+ const domesticRedirectedButton = document.querySelector(domesticRedirectedBtnSelector);
17
+ const shippingAddressSession = stripeStoreGetDomesticShippingSession();
18
+ // append a hidden button to the body if the shipping address session is found
19
+ if (!domesticRedirectedButton && shippingAddressSession) {
20
+ // create a hidden button to trigger the click event
21
+ const button = document.createElement('button');
22
+ button.style.display = 'none';
23
+ button.id = 'zonos--domestic-redirected-checkout-button';
24
+ document.body.appendChild(button);
25
+ onShippingAddressSessionFound === null || onShippingAddressSessionFound === void 0 ? void 0 : onShippingAddressSessionFound(shippingAddressSession);
26
+ // disconnect the observer after we found the shipping continue button
27
+ observer.disconnect();
28
+ return;
29
+ }
30
+ const shipToCountryElement = document.querySelector('select[name="shippingAddress.countryCode"]');
31
+ // make sure the continue button is available
32
+ const shippingCountinueBtnEle = document.querySelector('#checkout-shipping-continue');
33
+ if (!shipToCountryElement || !shippingCountinueBtnEle) {
34
+ // do nothing if shipping country and the continue button is not found
35
+ return;
36
+ }
37
+ // disconnect the observer after we found the shipping continue button
38
+ observer.disconnect();
39
+ shippingCountinueBtnEle.addEventListener('click', async (e) => {
40
+ var _a, _b;
41
+ const shippingCountry = shipToCountryElement.value;
42
+ if (!shippingCountry) {
43
+ // do nothing if shipping country is not found
44
+ return;
45
+ }
46
+ // update the country code in localization store and check if it's shippable
47
+ localizationStoreUpdateSelectedCountryCode(shippingCountry);
48
+ // do nothing if the country is still domestic
49
+ if (!isShippableCountry(false)) {
50
+ // cleanup the domestic shipping session if it's domestic because we will open the intl checkout after redirecting
51
+ stripeStoreCleanupDomesticShippingSession();
52
+ return;
53
+ }
54
+ // get value of shipping address state
55
+ const shipToFormElement = document.querySelector('form');
56
+ if (!shipToFormElement) {
57
+ return;
58
+ }
59
+ const formData = new FormData(shipToFormElement);
60
+ const shipAddress1Element = document.querySelector('input#addressLine1Input');
61
+ const shippingAddress = {
62
+ address1: (_a = formData.get('shippingAddress.address1')) !== null && _a !== void 0 ? _a :
63
+ // in Canada, the address1 is not included in the form, try to get value from input id instead.
64
+ (shipAddress1Element && shipAddress1Element.value),
65
+ address2: formData.get('shippingAddress.address2'),
66
+ city: formData.get('shippingAddress.city'),
67
+ countryCode: formData.get('shippingAddress.countryCode'),
68
+ firstName: formData.get('shippingAddress.firstName'),
69
+ lastName: formData.get('shippingAddress.lastName'),
70
+ phone: formData.get('shippingAddress.phone'),
71
+ postalCode: formData.get('shippingAddress.postalCode'),
72
+ stateOrProvince: (_b = formData.get('shippingAddress.stateOrProvince')) !== null && _b !== void 0 ? _b : formData.get('shippingAddress.stateOrProvinceCode'),
73
+ };
74
+ if (Object.values(shippingAddress).some(value => value === undefined || value === null)) {
75
+ logError('One or more shipping address field is missing', Object.entries(shippingAddress));
76
+ void sendErrorLog({
77
+ endpoint: 'No endpoint, domestic checkout form missing fields',
78
+ errors: [
79
+ 'Bigcommerce: One or more shipping address field is missing in the domestic checkout form',
80
+ JSON.stringify(Object.entries(shippingAddress)),
81
+ ],
82
+ metadata: {
83
+ domain: window.location.hostname,
84
+ storeId: zonosStore.storeId,
85
+ },
86
+ });
87
+ return;
88
+ }
89
+ // save the shipping address to session storage
90
+ stripeStoreSaveDomesticShippingSession({
91
+ address1: shippingAddress.address1,
92
+ address2: shippingAddress.address2,
93
+ city: shippingAddress.city,
94
+ countryCode: shippingAddress.countryCode,
95
+ firstName: shippingAddress.firstName,
96
+ lastName: shippingAddress.lastName,
97
+ phone: shippingAddress.phone,
98
+ postalCode: shippingAddress.postalCode,
99
+ state: shippingAddress.stateOrProvince,
100
+ });
101
+ e.preventDefault();
102
+ e.stopPropagation();
103
+ // redirect to home page, home page then will open the checkout dialog if having domestic shipping session
104
+ window.location.href = '/';
105
+ });
106
+ });
107
+ observer.observe(document.body, {
108
+ childList: true,
109
+ subtree: true,
110
+ });
111
+ };
@@ -0,0 +1,13 @@
1
+ export const formatStringWithLinks = (str) => {
2
+ // Match Markdown-style links or standalone URLs not in Markdown format
3
+ const linkRegex = /\[([^\]]+)\]\((https?:\/\/[^\s\)]+)\)|(https?:\/\/[^\s]+)/g;
4
+ const messageWithLinks = str.replace(linkRegex, (_match, text, markdownUrl, url) => {
5
+ if (markdownUrl) {
6
+ return `<zonos-link href="${markdownUrl}" target="_blank" rel="noopener noreferrer">${text}</zonos-link>`;
7
+ }
8
+ else {
9
+ return `<zonos-link href="${url}" target="_blank" rel="noopener noreferrer">${url}</zonos-link>`;
10
+ }
11
+ });
12
+ return messageWithLinks;
13
+ };
@@ -111,7 +111,7 @@ export const handleFetch = async (url, _opts) => {
111
111
  const modifiedUrl = new URL(url);
112
112
  modifiedUrl.searchParams.set('zToken', encodeString(window.location.hostname));
113
113
  // headers content type
114
- const headers = Object.assign({ 'Content-Type': 'application/json', 'Zonos-Is-BigCommerce': window.Zonos.isBigCommerce.toString(), 'Zonos-Referer': window.location.hostname, 'Zonos-Version': window.Zonos.version, credentialtoken: window.Zonos.zonosApiKey }, opts.headers);
114
+ const headers = Object.assign({ 'Content-Type': 'application/json', 'Zonos-Is-BigCommerce': window.Zonos.isBigCommerce.toString(), 'Zonos-Referer': window.location.hostname, 'Zonos-Version': window.Zonos.version, credentialtoken: window.Zonos.zonosApiKey || 'Empty credential token from zonos-elements' }, opts.headers);
115
115
  const options = Object.assign(Object.assign({}, opts), { body: method === 'GET' ? undefined : body, headers,
116
116
  method });
117
117
  return handleRequest(modifiedUrl.toString(), options);
@@ -1,13 +1,35 @@
1
1
  import { localizationStore } from "../../../store/hello/localization";
2
2
  import { zonosStore } from "../../../store/zonosStore";
3
- import { currencyConvert } from "./currencyConvert";
4
3
  import { currencyConvertAndFormat } from "./currencyConvertAndFormat";
5
4
  import { getCurrencyElements } from "./getCurrencyElements";
6
5
  import { getInitialElementAmount } from "./getInitialElementAmount";
7
6
  import { logError } from "../../logging/logError";
7
+ const convertCurrency = (element) => {
8
+ var _a;
9
+ const amount = getInitialElementAmount(element);
10
+ if (!amount || isNaN(amount)) {
11
+ return;
12
+ }
13
+ const currentIntlValue = element.getAttribute('data-zintl');
14
+ const currentCountryValue = element.getAttribute('data-zcountry-code');
15
+ // do nothing if the target currency is the same
16
+ const isExchangeRateReady = localizationStore.targetCurrency ===
17
+ ((_a = localizationStore.exchangeRate) === null || _a === void 0 ? void 0 : _a.targetFormat.currencyCode);
18
+ // if the current value on the element is different from the current intl value, update the data-zintl attribute
19
+ if (isExchangeRateReady &&
20
+ (element.textContent !== currentIntlValue ||
21
+ currentCountryValue !== localizationStore.selectedCountryCode)) {
22
+ const observedFormattedValue = currencyConvertAndFormat(amount);
23
+ element.textContent = observedFormattedValue;
24
+ // save the new value to the data-zintl attribute
25
+ element.setAttribute('data-zintl', observedFormattedValue);
26
+ element.setAttribute('data-zcountry-code', localizationStore.selectedCountryCode || '');
27
+ }
28
+ };
8
29
  export const defaultCurrencyConverter = () => {
9
30
  const { currencyElementSelector } = zonosStore.helloSettings;
10
31
  const currencyElements = getCurrencyElements(currencyElementSelector);
32
+ // do nothing if none of the currency elements are found
11
33
  if (!(currencyElements === null || currencyElements === void 0 ? void 0 : currencyElements.length)) {
12
34
  return;
13
35
  }
@@ -16,32 +38,7 @@ export const defaultCurrencyConverter = () => {
16
38
  return;
17
39
  }
18
40
  currencyElements.forEach((element) => {
19
- const amount = getInitialElementAmount(element);
20
- if (!amount || isNaN(amount)) {
21
- return;
22
- }
23
- element.setAttribute('data-zintl', currencyConvert(amount).toString());
24
- // Check if an observer is already attached to the element
25
- let observer = element._mutationObserver;
26
- if (!observer) {
27
- observer = new MutationObserver(() => {
28
- const observedFormattedValue = currencyConvertAndFormat(amount);
29
- element.textContent = observedFormattedValue;
30
- });
31
- observer.observe(element, {
32
- characterData: true,
33
- childList: true,
34
- });
35
- element._mutationObserver = observer;
36
- }
37
- // Temporarily disconnect the observer to prevent an infinite loop
38
- observer.disconnect();
39
- const formattedValue = currencyConvertAndFormat(amount);
40
- element.textContent = formattedValue;
41
- // Reconnect the observer after the update is complete
42
- observer.observe(element, {
43
- characterData: true,
44
- childList: true,
45
- });
41
+ // convert the currency and save the formatted value to the data-zintl attribute
42
+ convertCurrency(element);
46
43
  });
47
44
  };
@@ -4,15 +4,14 @@ import { logError } from "../../logging/logError";
4
4
  export const getCurrencyElements = (selector) => {
5
5
  const currencySelector = selector || '.money';
6
6
  if (!isValidSelector(currencySelector)) {
7
- // eslint-disable-next-line no-console
8
7
  logError(`Currency element selector "${currencySelector}" is not valid.`);
9
8
  return null;
10
9
  }
11
10
  const currencyElements = document.querySelectorAll(currencySelector);
12
11
  if (!currencyElements.length) {
13
- // eslint-disable-next-line no-console
14
12
  log(`No currency elements found with selector "${currencySelector}"`, 'warn');
15
13
  return null;
16
14
  }
17
- return currencyElements;
15
+ // return array of currency elements instead of a NodeList
16
+ return Array.from(currencyElements);
18
17
  };
@@ -1,12 +1,14 @@
1
1
  export const getInitialElementAmount = (element) => {
2
2
  var _a;
3
3
  const domesticValue = element.getAttribute('data-domestic');
4
- if (!domesticValue) {
5
- // Only keep numbers, decimal, and hyphens
6
- const cleanedText = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.replace(/[^\d.-]/g, '');
7
- if (!cleanedText) {
8
- return null;
9
- }
4
+ const intlValue = element.getAttribute('data-zintl');
5
+ // Only keep numbers, decimal, and hyphens
6
+ const cleanedText = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.replace(/[^\d.-]/g, '');
7
+ if (!cleanedText) {
8
+ return null;
9
+ }
10
+ // If the element has no data-domestic attribute, or the text content is different from the data-zintl attribute, set the data-domestic attribute
11
+ if (!domesticValue || element.textContent !== intlValue) {
10
12
  // Store the original value on the element once, and international on every new conversion
11
13
  element.setAttribute('data-domestic', cleanedText);
12
14
  return parseFloat(cleanedText);
@@ -1,13 +1,16 @@
1
1
  import { isValidSelector } from "../isValidSelector";
2
2
  import { log } from "../logging/log";
3
3
  import { logError } from "../logging/logError";
4
- const injectHelloComponent = (triggerAnchorElement) => {
4
+ const injectHelloComponent = (anchorElementSelector) => {
5
+ const triggerAnchorElement = document.querySelector(anchorElementSelector);
5
6
  // append checkout component if doesn't exist
6
7
  const helloElement = document.querySelector('zonos-hello');
7
8
  if (!helloElement && triggerAnchorElement) {
8
9
  const newHelloElement = document.createElement('zonos-hello');
9
10
  triggerAnchorElement.appendChild(newHelloElement);
11
+ return true;
10
12
  }
13
+ return false;
11
14
  };
12
15
  export const initHello = async (helloSettings) => {
13
16
  const { anchorElementSelector } = helloSettings;
@@ -16,7 +19,24 @@ export const initHello = async (helloSettings) => {
16
19
  logError(`Selector anchorElementSelector "${helloSettings.anchorElementSelector}" is not a valid selector.`);
17
20
  return;
18
21
  }
19
- const triggerElement = document.querySelector(anchorElementSelector);
20
22
  log('Hello init complete');
21
- injectHelloComponent(triggerElement);
23
+ const isHelloInjected = injectHelloComponent(anchorElementSelector);
24
+ // keep watching for the anchor element to be added to the DOM, then inject hello component
25
+ if (!isHelloInjected) {
26
+ const observer = new MutationObserver(() => {
27
+ const injected = injectHelloComponent(anchorElementSelector);
28
+ if (injected) {
29
+ // disconnect observer if hello is successfully injected
30
+ observer.disconnect();
31
+ }
32
+ });
33
+ observer.observe(document.body, {
34
+ childList: true,
35
+ subtree: true,
36
+ });
37
+ // kill observer after 5 seconds if the hello still not injected, if the hello still not injected after 10 seconds, it's likely that the selector the user doesn't want to use hello
38
+ setTimeout(() => {
39
+ observer.disconnect();
40
+ }, 5000);
41
+ }
22
42
  };