@zonos/elements 1.5.1 → 1.5.3

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 (250) hide show
  1. package/dist/cjs/_isBigCommerceNativeCheckout-3-xbKbAO.js +133 -0
  2. package/dist/cjs/{cart-CiXlehwQ.js → cart-C39TMSgB.js} +27 -13
  3. package/dist/cjs/{collect-Drr8fY-q.js → collect-lF9DenLk.js} +4 -4
  4. package/dist/cjs/{getMissingRequiredShippingFields-DI6qF1z3.js → getMissingRequiredShippingFields-svcnpumn.js} +1 -1
  5. package/dist/cjs/{handleFetch-DQLhurnE.js → handleFetch-DVfjFTYO.js} +181 -71
  6. package/dist/cjs/{hasInclusivePrice-84KS94yH.js → hasInclusivePrice-CEPf3_FG.js} +1 -1
  7. package/dist/cjs/index.cjs.js +158 -47
  8. package/dist/cjs/{invoice-5hVfSXpb.js → invoice-BD3pCr8P.js} +3 -3
  9. package/dist/cjs/{localization-B2mjW0Xa.js → localization-BhNVhLZs.js} +24 -48
  10. package/dist/cjs/{paypal-pd8Nz_R_.js → paypal-Bd1qmwiv.js} +4 -4
  11. package/dist/cjs/{placeTestOrder-DrI8rD9o.js → placeTestOrder-BMQRvX2q.js} +3 -3
  12. package/dist/cjs/{renderCheckoutCurrency-u5q8YdUb.js → renderCheckoutCurrency-DE2p8CT8.js} +2 -2
  13. package/dist/cjs/{shouldShowLanguageSelect-gBg4KeTQ.js → shouldShowLanguageSelect-NOVWOU53.js} +1 -1
  14. package/dist/cjs/{submitGtag-Rc-S3PnH.js → submitGtag-D4sB7w4z.js} +1 -1
  15. package/dist/cjs/{taxIdFields-BrIaPTcd.js → taxIdFields-BKbk2bhi.js} +2 -2
  16. package/dist/cjs/{updateCheckoutSessionAttributes-d0IKpwW8.js → updateCheckoutSessionAttributes-KxwcsKhM.js} +1 -1
  17. package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +6 -6
  18. package/dist/cjs/zonos-address-display_2.cjs.entry.js +2 -2
  19. package/dist/cjs/zonos-address_4.cjs.entry.js +4 -4
  20. package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +4 -4
  21. package/dist/cjs/zonos-card_5.cjs.entry.js +5 -5
  22. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +18 -18
  23. package/dist/cjs/zonos-checkout.cjs.entry.js +48 -22
  24. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +3 -3
  25. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +9 -9
  26. package/dist/cjs/zonos-collect.cjs.entry.js +6 -6
  27. package/dist/cjs/zonos-controller.cjs.entry.js +65 -40
  28. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
  29. package/dist/cjs/zonos-country-select_4.cjs.entry.js +3 -3
  30. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +3 -3
  31. package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
  32. package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +5 -5
  33. package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +9 -9
  34. package/dist/cjs/zonos-invoice.cjs.entry.js +6 -6
  35. package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
  36. package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +4 -4
  37. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +8 -7
  38. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +14 -4
  39. package/dist/collection/components/main/mountCheckoutWithoutStripe.js +12 -0
  40. package/dist/collection/components/main/zonos-controller.js +26 -10
  41. package/dist/collection/components/store/checkout/cart.js +3 -2
  42. package/dist/collection/components/store/checkout/stripe.js +23 -10
  43. package/dist/collection/components/store/storageStore.js +7 -6
  44. package/dist/collection/components/utils/__tests__/helpers/blockStorage.js +24 -0
  45. package/dist/collection/components/utils/api/getExchangeRate.js +2 -1
  46. package/dist/collection/components/utils/checkout/isBigCommerceCheckoutBypassEnabled.js +2 -1
  47. package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +32 -12
  48. package/dist/collection/components/utils/handleFetch.js +19 -9
  49. package/dist/collection/components/utils/hello/countryOverrideStorage.js +17 -40
  50. package/dist/collection/components/utils/logging/installConstructorCapture.js +58 -0
  51. package/dist/collection/components/utils/logging/reportBlockedStorage.js +34 -0
  52. package/dist/collection/components/utils/logging/sendErrorLog.js +8 -1
  53. package/dist/collection/components/utils/logging/startZonosInit.js +35 -0
  54. package/dist/collection/components/utils/logging/thrownMessage.js +16 -0
  55. package/dist/collection/components/utils/safeStorage.js +39 -0
  56. package/dist/collection/scripts/_bigcommerceCheckoutPath.js +16 -0
  57. package/dist/collection/scripts/_detectBigCommerceHost.js +12 -0
  58. package/dist/collection/scripts/_getZonosQaUrl.js +3 -2
  59. package/dist/collection/scripts/_isBigCommerceNativeCheckout.js +107 -0
  60. package/dist/collection/scripts/_loadStripe.js +15 -4
  61. package/dist/collection/scripts/_zonosBase.js +46 -33
  62. package/dist/collection/types/generated/graphql.frontend.types.js +0 -16
  63. package/dist/collection/types/generated/graphql.internal.types.js +215 -1
  64. package/dist/esm/_isBigCommerceNativeCheckout-Bb90IMVt.js +128 -0
  65. package/dist/esm/{cart-DmJkjiDE.js → cart-b84n0nhi.js} +26 -14
  66. package/dist/esm/{collect-BV5GTPmh.js → collect-B_AEVONL.js} +4 -4
  67. package/dist/esm/{getMissingRequiredShippingFields-DljgpDZe.js → getMissingRequiredShippingFields-EY10c34-.js} +1 -1
  68. package/dist/esm/{handleFetch-D5GYDF-O.js → handleFetch-BFVO7oAR.js} +178 -72
  69. package/dist/esm/{hasInclusivePrice-DhGXpH2D.js → hasInclusivePrice-DfEiyzw7.js} +1 -1
  70. package/dist/esm/index.js +158 -47
  71. package/dist/esm/{invoice-CO-iqlni.js → invoice-dQ0ONK5Q.js} +3 -3
  72. package/dist/esm/{localization-DHM91diu.js → localization-B5CRzthT.js} +25 -49
  73. package/dist/esm/{paypal-BfW5aLJw.js → paypal-CF_oM0B6.js} +4 -4
  74. package/dist/esm/{placeTestOrder-CyWUFhxD.js → placeTestOrder-BTpfyqPL.js} +3 -3
  75. package/dist/esm/{renderCheckoutCurrency-B31ZNkUv.js → renderCheckoutCurrency-CpeuDWx-.js} +2 -2
  76. package/dist/esm/{shouldShowLanguageSelect-DwSfSHar.js → shouldShowLanguageSelect-CJinx9-m.js} +1 -1
  77. package/dist/esm/{submitGtag-BEFrutel.js → submitGtag-C5xzFHjG.js} +1 -1
  78. package/dist/esm/{taxIdFields-ByEYfsO5.js → taxIdFields-BCyXnc9O.js} +2 -2
  79. package/dist/esm/{updateCheckoutSessionAttributes-B0bQH0uw.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +1 -1
  80. package/dist/esm/zonos-address-completion-dialog_7.entry.js +6 -6
  81. package/dist/esm/zonos-address-display_2.entry.js +2 -2
  82. package/dist/esm/zonos-address_4.entry.js +4 -4
  83. package/dist/esm/zonos-airwallex-payment.entry.js +4 -4
  84. package/dist/esm/zonos-card_5.entry.js +5 -5
  85. package/dist/esm/zonos-cart-items_12.entry.js +18 -18
  86. package/dist/esm/zonos-checkout.entry.js +48 -22
  87. package/dist/esm/zonos-collect-cart-items_3.entry.js +3 -3
  88. package/dist/esm/zonos-collect-finish_6.entry.js +9 -9
  89. package/dist/esm/zonos-collect.entry.js +6 -6
  90. package/dist/esm/zonos-controller.entry.js +65 -40
  91. package/dist/esm/zonos-country-flag.entry.js +2 -2
  92. package/dist/esm/zonos-country-select_4.entry.js +3 -3
  93. package/dist/esm/zonos-hello-dialog.entry.js +3 -3
  94. package/dist/esm/zonos-hello.entry.js +2 -2
  95. package/dist/esm/zonos-invoice-cart-items_2.entry.js +5 -5
  96. package/dist/esm/zonos-invoice-finish_5.entry.js +9 -9
  97. package/dist/esm/zonos-invoice.entry.js +6 -6
  98. package/dist/esm/zonos-language-select_2.entry.js +2 -2
  99. package/dist/esm/zonos-policy-consent_2.entry.js +4 -4
  100. package/dist/esm-es5/_isBigCommerceNativeCheckout-Bb90IMVt.js +40 -0
  101. package/dist/esm-es5/{cart-DmJkjiDE.js → cart-b84n0nhi.js} +59 -59
  102. package/dist/esm-es5/{collect-BV5GTPmh.js → collect-B_AEVONL.js} +2 -2
  103. package/dist/esm-es5/{getMissingRequiredShippingFields-DljgpDZe.js → getMissingRequiredShippingFields-EY10c34-.js} +3 -3
  104. package/dist/esm-es5/handleFetch-BFVO7oAR.js +73 -0
  105. package/dist/esm-es5/{hasInclusivePrice-DhGXpH2D.js → hasInclusivePrice-DfEiyzw7.js} +1 -1
  106. package/dist/esm-es5/index.js +94 -65
  107. package/dist/esm-es5/{invoice-CO-iqlni.js → invoice-dQ0ONK5Q.js} +1 -1
  108. package/dist/esm-es5/{localization-DHM91diu.js → localization-B5CRzthT.js} +7 -10
  109. package/dist/esm-es5/{paypal-BfW5aLJw.js → paypal-CF_oM0B6.js} +1 -1
  110. package/dist/esm-es5/{placeTestOrder-CyWUFhxD.js → placeTestOrder-BTpfyqPL.js} +1 -1
  111. package/dist/esm-es5/{renderCheckoutCurrency-B31ZNkUv.js → renderCheckoutCurrency-CpeuDWx-.js} +5 -5
  112. package/dist/esm-es5/{shouldShowLanguageSelect-DwSfSHar.js → shouldShowLanguageSelect-CJinx9-m.js} +1 -1
  113. package/dist/esm-es5/{submitGtag-BEFrutel.js → submitGtag-C5xzFHjG.js} +1 -1
  114. package/dist/esm-es5/{taxIdFields-ByEYfsO5.js → taxIdFields-BCyXnc9O.js} +1 -1
  115. package/dist/esm-es5/{updateCheckoutSessionAttributes-B0bQH0uw.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +1 -1
  116. package/dist/esm-es5/zonos-address-completion-dialog_7.entry.js +2 -2
  117. package/dist/esm-es5/zonos-address-display_2.entry.js +1 -1
  118. package/dist/esm-es5/zonos-address_4.entry.js +1 -1
  119. package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
  120. package/dist/esm-es5/zonos-card_5.entry.js +6 -6
  121. package/dist/esm-es5/zonos-cart-items_12.entry.js +127 -127
  122. package/dist/esm-es5/zonos-checkout.entry.js +22 -11
  123. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  124. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
  125. package/dist/esm-es5/zonos-collect.entry.js +1 -1
  126. package/dist/esm-es5/zonos-controller.entry.js +21 -12
  127. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  128. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  129. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  130. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  131. package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
  132. package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
  133. package/dist/esm-es5/zonos-invoice.entry.js +3 -3
  134. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  135. package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
  136. package/dist/scripts/index.d.ts +22 -0
  137. package/dist/scripts/index.js +1 -1
  138. package/dist/scripts/loadZonos.js +1 -1
  139. package/dist/scripts/zonos.js +1 -1
  140. package/dist/types/components/main/mountCheckoutWithoutStripe.d.ts +8 -0
  141. package/dist/types/components/store/checkout/stripe.d.ts +4 -1
  142. package/dist/types/components/utils/__tests__/helpers/blockStorage.d.ts +3 -0
  143. package/dist/types/components/utils/logging/installConstructorCapture.d.ts +20 -0
  144. package/dist/types/components/utils/logging/reportBlockedStorage.d.ts +16 -0
  145. package/dist/types/components/utils/logging/startZonosInit.d.ts +5 -0
  146. package/dist/types/components/utils/logging/thrownMessage.d.ts +1 -0
  147. package/dist/types/components/utils/safeStorage.d.ts +4 -0
  148. package/dist/types/scripts/_bigcommerceCheckoutPath.d.ts +12 -0
  149. package/dist/types/scripts/_detectBigCommerceHost.d.ts +5 -0
  150. package/dist/types/scripts/_isBigCommerceNativeCheckout.d.ts +21 -0
  151. package/dist/types/scripts/_zonosBase.d.ts +16 -0
  152. package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +5 -0
  153. package/dist/types/types/generated/graphql.frontend.types.d.ts +0 -22
  154. package/dist/types/types/generated/graphql.frontend.types.ts +0 -51
  155. package/dist/types/types/generated/graphql.internal.types.d.ts +270 -1
  156. package/dist/types/types/generated/graphql.internal.types.ts +341 -1
  157. package/dist/zonos-elements/index.esm.js +1 -1
  158. package/dist/zonos-elements/{p-8fa6cfff.entry.js → p-02faff47.entry.js} +1 -1
  159. package/dist/zonos-elements/{p-216a908d.system.entry.js → p-0c68cbbb.system.entry.js} +2 -2
  160. package/dist/zonos-elements/{p-vTIygnHq.system.js → p-1OG3IJgY.system.js} +1 -1
  161. package/dist/zonos-elements/{p-960070d0.system.entry.js → p-1cd2d097.system.entry.js} +3 -3
  162. package/dist/zonos-elements/{p-1e6db427.entry.js → p-255e411a.entry.js} +1 -1
  163. package/dist/zonos-elements/p-2c_UqKJL.system.js +7 -0
  164. package/dist/zonos-elements/{p-DprOoI2W.system.js → p-3AUMK-5E.system.js} +154 -154
  165. package/dist/zonos-elements/{p-d3345b2c.entry.js → p-3ee87d8b.entry.js} +1 -1
  166. package/dist/zonos-elements/{p-cccaad60.system.entry.js → p-42fa5694.system.entry.js} +10 -10
  167. package/dist/zonos-elements/p-49eaaab8.entry.js +1 -0
  168. package/dist/zonos-elements/{p-fda89981.system.entry.js → p-4ce4c49f.system.entry.js} +3 -3
  169. package/dist/zonos-elements/{p-f3d9a380.system.entry.js → p-5622fc50.system.entry.js} +263 -252
  170. package/dist/zonos-elements/{p-5585db86.system.entry.js → p-59457fd9.system.entry.js} +73 -64
  171. package/dist/zonos-elements/{p-65817880.entry.js → p-66398133.entry.js} +1 -1
  172. package/dist/zonos-elements/{p-d8f375da.system.entry.js → p-674323ac.system.entry.js} +1 -1
  173. package/dist/zonos-elements/{p-678b9214.entry.js → p-71d9a5b7.entry.js} +1 -1
  174. package/dist/zonos-elements/{p-189cc594.system.entry.js → p-81780f8f.system.entry.js} +2 -2
  175. package/dist/zonos-elements/{p-6e691736.entry.js → p-821b83a2.entry.js} +1 -1
  176. package/dist/zonos-elements/{p-1fda4aec.system.entry.js → p-877a82d2.system.entry.js} +94 -94
  177. package/dist/zonos-elements/p-8daec112.entry.js +1 -0
  178. package/dist/zonos-elements/{p-46a839d2.system.entry.js → p-93bc75fd.system.entry.js} +13 -13
  179. package/dist/zonos-elements/{p-2ca826b9.system.entry.js → p-976b3bf3.system.entry.js} +1 -1
  180. package/dist/zonos-elements/{p-84e76348.entry.js → p-9a4947a5.entry.js} +1 -1
  181. package/dist/zonos-elements/p-9f7693bf.entry.js +1 -0
  182. package/dist/zonos-elements/p-BIJM2Kj-.js +1 -0
  183. package/dist/zonos-elements/p-BJFa5RwX.js +1 -0
  184. package/dist/zonos-elements/{p-6vSUiBfr.system.js → p-BOh4ifdL.system.js} +51 -54
  185. package/dist/zonos-elements/p-BZAX-HmS.js +1 -0
  186. package/dist/zonos-elements/p-Bb90IMVt.js +1 -0
  187. package/dist/zonos-elements/p-Bu9WCfUC.system.js +1 -1
  188. package/dist/zonos-elements/{p-CbhN65lj.system.js → p-BvoPE_nb.system.js} +1 -1
  189. package/dist/zonos-elements/{p-iAIzUA4k.js → p-C3E55OqH.js} +1 -1
  190. package/dist/zonos-elements/{p-CBUz18kA.system.js → p-C3gF3UV5.system.js} +23 -23
  191. package/dist/zonos-elements/{p-XoQH3S7Z.system.js → p-CD2ahEZn.system.js} +1 -1
  192. package/dist/zonos-elements/p-CEBBLbvF.js +1 -0
  193. package/dist/zonos-elements/{p-CGNVm52g.system.js → p-CEV0O_IQ.system.js} +5 -5
  194. package/dist/zonos-elements/{p-D1e9zNDA.js → p-CJmWr75U.js} +1 -1
  195. package/dist/zonos-elements/{p-DgUrB-1a.system.js → p-CZ-uYiCo.system.js} +1 -1
  196. package/dist/zonos-elements/p-Cn2xE-9t.system.js +256 -0
  197. package/dist/zonos-elements/p-CtvXi9wL.system.js +41 -0
  198. package/dist/zonos-elements/{p-BrQ8n8NS.system.js → p-Cw_Qnyow.system.js} +3 -3
  199. package/dist/zonos-elements/p-CzXNXgyI.js +1 -0
  200. package/dist/zonos-elements/p-D0DkOoAw.system.js +73 -0
  201. package/dist/zonos-elements/p-D9OPKqLg.js +1 -0
  202. package/dist/zonos-elements/{p-ojtNq-r5.system.js → p-DXlojp_Y.system.js} +1 -1
  203. package/dist/zonos-elements/{p-DpwmHU8R.js → p-Df62LRNs.js} +2 -2
  204. package/dist/zonos-elements/{p-CHKKvuiz.js → p-Lsqrpzc5.js} +1 -1
  205. package/dist/zonos-elements/{p-C9XLkmmb.system.js → p-YQFbWtjn.system.js} +1 -1
  206. package/dist/zonos-elements/p-a27f48e4.entry.js +1 -0
  207. package/dist/zonos-elements/{p-941a95a1.system.entry.js → p-a6bb296c.system.entry.js} +7 -7
  208. package/dist/zonos-elements/{p-2b63865a.system.entry.js → p-abb85879.system.entry.js} +3 -3
  209. package/dist/zonos-elements/{p-12b24ebb.entry.js → p-b8653024.entry.js} +1 -1
  210. package/dist/zonos-elements/p-b9d7a3b6.entry.js +1 -0
  211. package/dist/zonos-elements/{p-f5f95990.system.entry.js → p-be067e12.system.entry.js} +15 -15
  212. package/dist/zonos-elements/p-bmrOH9oh.js +1 -0
  213. package/dist/zonos-elements/p-c185bc23.entry.js +1 -0
  214. package/dist/zonos-elements/{p-2d513aa3.entry.js → p-c6e78de2.entry.js} +1 -1
  215. package/dist/zonos-elements/{p-55813e9f.system.entry.js → p-ca97a1cd.system.entry.js} +3 -3
  216. package/dist/zonos-elements/{p-3e705c9b.entry.js → p-cbb96382.entry.js} +1 -1
  217. package/dist/zonos-elements/{p-53eac12f.system.entry.js → p-dbf4d156.system.entry.js} +14 -14
  218. package/dist/zonos-elements/{p-6410fa11.system.entry.js → p-df240119.system.entry.js} +16 -16
  219. package/dist/zonos-elements/{p-1cc42a98.system.entry.js → p-e16e4db6.system.entry.js} +17 -17
  220. package/dist/zonos-elements/{p-064d8829.system.entry.js → p-eb016dd8.system.entry.js} +20 -20
  221. package/dist/zonos-elements/{p-1199baef.system.entry.js → p-eb5c67a0.system.entry.js} +1 -1
  222. package/dist/zonos-elements/{p-ef5344ea.entry.js → p-ed8a7a7f.entry.js} +1 -1
  223. package/dist/zonos-elements/{p-4917b74d.entry.js → p-ef932fda.entry.js} +1 -1
  224. package/dist/zonos-elements/{p-e7fdb2c9.entry.js → p-f792ba5f.entry.js} +1 -1
  225. package/dist/zonos-elements/{p-DiMEP3mh.js → p-fZcKMzE-.js} +1 -1
  226. package/dist/zonos-elements/{p-CMo3ZweU.js → p-fdritVtG.js} +1 -1
  227. package/dist/zonos-elements/p-fffe6376.entry.js +1 -0
  228. package/dist/zonos-elements/p-gEViRqvf.js +1 -0
  229. package/dist/zonos-elements/{p-Dtu_Japy.system.js → p-v8IEjQ2z.system.js} +39 -39
  230. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  231. package/package.json +10 -10
  232. package/dist/esm-es5/handleFetch-D5GYDF-O.js +0 -60
  233. package/dist/zonos-elements/p-107f287b.entry.js +0 -1
  234. package/dist/zonos-elements/p-25eb99d4.entry.js +0 -1
  235. package/dist/zonos-elements/p-46b9f0cf.entry.js +0 -1
  236. package/dist/zonos-elements/p-636b71d4.entry.js +0 -1
  237. package/dist/zonos-elements/p-7dc7f328.entry.js +0 -1
  238. package/dist/zonos-elements/p-8f9d8795.entry.js +0 -1
  239. package/dist/zonos-elements/p-BMPYH-LT.js +0 -1
  240. package/dist/zonos-elements/p-C70h5mKA.js +0 -1
  241. package/dist/zonos-elements/p-CTiqplrr.js +0 -1
  242. package/dist/zonos-elements/p-Ch1w0Lr7.js +0 -1
  243. package/dist/zonos-elements/p-D1SmY_fZ.js +0 -1
  244. package/dist/zonos-elements/p-D6xXnsM_.js +0 -1
  245. package/dist/zonos-elements/p-DE4a-QD5.js +0 -1
  246. package/dist/zonos-elements/p-DQrMfUzi.system.js +0 -227
  247. package/dist/zonos-elements/p-DZdkJHK9.system.js +0 -7
  248. package/dist/zonos-elements/p-U33isUJG.js +0 -1
  249. package/dist/zonos-elements/p-ebe157b5.entry.js +0 -1
  250. package/dist/zonos-elements/p-zVLAvre1.system.js +0 -60
@@ -1 +0,0 @@
1
- import{l as r}from"./p-CTiqplrr.js";const o="gkjqw123",i="Kq93wqw3",l=()=>{var l;return null===(l=r.inclusivePricingConfigurations)||void 0===l?void 0:l.some((r=>{var l,v;return"ENABLED"===(null===(l=r.configurations[o])||void 0===l?void 0:l.status)||"ENABLED"===(null===(v=r.configurations[i])||void 0===v?void 0:v.status)}))};export{o as D,i as T,l as h}
@@ -1 +0,0 @@
1
- import{d as r}from"./p-BMPYH-LT.js";import{B as o,j as n}from"./p-CTiqplrr.js";const i=({amount:i,isForeign:u})=>{var t,a;const s=(null===(t=r.exchangeRate)||void 0===t?void 0:t.rate)||1,v=u?i:o(i),c=r.currency;if((null===(a=r.items[0])||void 0===a?void 0:a.currencyCode)===c)return n({amount:v,currency:c});const d=r.displayBaseCurrency,l=(()=>{var o,n;return r.displayBaseCurrency&&(null===(o=r.exchangeRate)||void 0===o?void 0:o.sourceCurrencyCode)?null===(n=r.exchangeRate)||void 0===n?void 0:n.sourceCurrencyCode:r.currency})();return n(u?{amount:d?v/s:v,currency:l}:{amount:d?v:v*s,currency:l})};export{i as r}
@@ -1 +0,0 @@
1
- import{c as e,z as o}from"./p-CqB9AfBf.js";import{d as a,Z as t,b as s,a1 as r}from"./p-BMPYH-LT.js";import{s as n}from"./p-CTiqplrr.js";import{h as d,s as i,l}from"./p-DE4a-QD5.js";import{b as c}from"./p-BJmZPrZl.js";const{state:p}=e((()=>({amountTotalDue:null,isFetchingPayorInfo:!0,landedCostShortId:null,partyBillingId:null,payorAddress:null}))),u=async({landedCostId:e,retries:t=5})=>{var s,r,n;p.isFetchingPayorInfo=!0;const l=await d("/api/zonos-elements/invoice/get-payor-info-by-lc-id",{body:{landedCostId:e},method:"POST"});if(l.errors.length)return t>0?(await new Promise((e=>setTimeout(e,1e3))),u({landedCostId:e,retries:t-1})):null;p.landedCostShortId=(null===(s=l.json)||void 0===s?void 0:s.landedCostShortId)||null,p.isFetchingPayorInfo=!1,p.payorAddress=(null===(r=l.json)||void 0===r?void 0:r.payor)||null;const c=null===(n=a.checkoutSession)||void 0===n?void 0:n.subtotals;p.amountTotalDue=(null==c?void 0:c.items)||0,0===p.amountTotalDue&&i({endpoint:"INVOICE_NO_TOTAL_DUE",errors:[],metadata:{landedCostId:e,organizationId:o.organizationId}})},I=async()=>{var e,o,t,u;if(!(null===(e=s.stripeBillingAddressEventData)||void 0===e?void 0:e.complete))return{partiesCreated:!1};const I=null===(t=null===(o=a.checkoutSession)||void 0===o?void 0:o.landedCost)||void 0===t?void 0:t.rootId;if(!I)return i({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId}}),{partiesCreated:!1};if(!n.checkoutSessionId)return i({endpoint:"INVOICE_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:c,cartId:window.Zonos.cartId,landedCostRootId:I}}),{partiesCreated:!1};const m=r({address:s.stripeBillingAddressEventData.value.address,firstName:s.stripeBillingAddressEventData.value.firstName,lastName:s.stripeBillingAddressEventData.value.lastName,name:s.stripeBillingAddressEventData.value.name,phone:s.stripeBillingAddressEventData.value.phone}),C="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:O,json:v}=await d("/api/zonos-elements/create-billing-party",{body:{billingAddress:m,checkoutSessionId:n.checkoutSessionId,companyName:s.companyName,email:(null===(u=s.stripeLinkEventData)||void 0===u?void 0:u.value.email)||"",isTest:C,rootId:I},method:"POST"});return O.length||!v?(l("Error occurs when creating billing party",JSON.stringify(O,null,2)),i({endpoint:"INVOICE_BILLING_PARTY_CREATE_FAILED",errors:["[INVOICE] Failed to create billing party"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:n.checkoutSessionId,errors:O,json:v}}),{partiesCreated:!1}):(p.partyBillingId=v.billToPartyId,{partiesCreated:!0})},m=async e=>{const o=e.landedCost;return!!o&&(a.landedCostData=[Object.assign(Object.assign({},e),{landedCost:Object.assign({},o),landedCostId:o.id})],t({applySubtotalsOnly:!0,landedCostId:o.id,selectedShippingOption:o.shipmentRating}))};export{u as a,I as b,p as c,m as i}
@@ -1 +0,0 @@
1
- import{l as o}from"./p-BJmZPrZl.js";const e=(e,...n)=>{o(e,"error",...n)},n=()=>window.location.search.includes("zonosStagingMode=1"),t=()=>{var o;return(null===(o=window.Zonos.zonosApiKey)||void 0===o?void 0:o.includes("test"))||window.location.search.includes("zonosTestMode=1")},r=["cloudflare","vercel"],s=r[0],a={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},i=a[s],l=(o=s)=>{const e=r.indexOf(o);return r[e+1]||null},d=o=>{if("string"==typeof o)try{return JSON.parse(o)}catch(o){return null}return null},c=o=>o||window.innerWidth<890,w=()=>{const o="userAgentData"in window.navigator?window.navigator.userAgentData:null,e=(()=>{const o="connection"in window.navigator?window.navigator.connection:null,e="mozConnection"in window.navigator?window.navigator.mozConnection:null,n="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return o||e||n})();return{connectionDownlink:null==e?void 0:e.downlink,connectionEffectiveType:null==e?void 0:e.effectiveType,connectionRtt:null==e?void 0:e.rtt,connectionSaveData:null==e?void 0:e.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:o&&o.brands.length>0?o:window.navigator.userAgent}},u=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],p=async({endpoint:e,errors:n,metadata:t,shouldPostReleaseErrorReporting:r})=>{if(o("sendErrorLog","warn",e,t,n),r){const o=Number(window.Zonos.releaseDate);if((new Date).getTime()-o>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,d={endpoint:e,errors:n,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},t)};try{fetch(`${i}/api/zonos-elements/log-error`,{body:JSON.stringify(d),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(o){const e=l();if(!e)return;fetch(`${a[e]}/api/zonos-elements/log-error`,{body:JSON.stringify(d),method:"POST"})}};var h=function(o,e){var n={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(n[t]=o[t]);if(null!=o&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(o);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(o,t[r])&&(n[t[r]]=o[t[r]])}return n};const m=async({response:o,shouldLog:e=!0,shouldThrow:n=!1})=>{try{const e=await o.text(),n=d(e);if(!n)throw new Error(`Failed to parse content: ${e}`);return n}catch(o){if(n)throw o;return e&&console.error(o),null}},b=async({basePathType:e,options:n,path:t})=>{var r,i;const f=t.startsWith("/api/bigcommerce")?"vercel":e,y=performance.now(),g=await(async({basePathType:o,options:e,path:n})=>{let t;const r=window.Zonos.zonosQaUrlApi||a[o]||s,i=new URL(r+n),l=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;i.searchParams.set("zToken",(o=>{try{return btoa(o).replace(/=/g,"")}catch(e){return o.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(l));try{t=await fetch(i.toString(),e)}catch(o){return o instanceof Error?{baseUrl:r,errors:[{message:o.message,type:"unknown"}],json:null,response:null,zonosMode:null}:{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const d=t.headers.get("Zonos-Mode"),c=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&d&&c&&(window.Zonos.modeAlerted=!0),t.ok)return{baseUrl:r,errors:[],json:await m({response:t}),response:t,zonosMode:d};const w=t.status.toString();try{const o=await m({response:t,shouldThrow:!0});return o&&"errors"in o&&Array.isArray(o.errors)?{baseUrl:r,errors:o.errors.map((o=>"string"==typeof o?{message:o,type:w}:o)),json:null,response:t,zonosMode:d}:{baseUrl:r,errors:[{message:JSON.stringify(o),type:w}],json:null,response:t,zonosMode:d}}catch(o){return{baseUrl:r,errors:[{message:`${w}: Unknown error`,type:w}],json:null,response:null,zonosMode:d}}})({basePathType:f,options:n,path:t}),{errors:v,response:T}=g,j=h(g,["errors","response"]),z=performance.now()-y;o(`${t} (${z.toFixed(2)}ms)`,"info");const O=null==T?void 0:T.headers.get("Zonos-Duration");200===(null==T?void 0:T.status)&&(({apiPath:o,apiType:e,loadTimeInternal:n,loadTimeTotal:t})=>{if(u.includes(o))return;const r=t-n;if(r<0)return;const s=o.split("?")[0]||o,a=w(),i={apiType:e,connectionType:a.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:c("object"==typeof a.userAgent&&a.userAgent.mobile),loadTimeBrowserApi:r,loadTimeInternal:n,loadTimeTotal:t,metadata:Object.assign({},a),screenHeight:a.screenHeight,screenWidth:a.screenWidth,userAgent:"string"==typeof a.userAgent?a.userAgent:a.userAgent.brands.map((o=>o.brand)).filter((o=>!/Not.*A.*Brand.*/.test(o))).join(",")};window.Zonos.loadTimeApiInfoList.push(i)})({apiPath:t,apiType:f,loadTimeInternal:O?Number(O):0,loadTimeTotal:z});const k=l(f),P=v.find((({type:o})=>"unknown"===o)),A=v.find((({message:o})=>"string"==typeof o&&(o.includes("signal is aborted")||o.includes("The operation was aborted")||o.includes("Fetch is aborted")))),M=!!P||404===(null==T?void 0:T.status)||500===(null==T?void 0:T.status),S=k&&M;return M&&!A&&p({endpoint:a[f]+t,errors:v.map((({message:o})=>`API: ${o}`)),metadata:{currentBasePath:f,nextFallbackApiType:k,requestHeaders:null==n?void 0:n.headers,requestPayload:d(null===(r=null==n?void 0:n.body)||void 0===r?void 0:r.toString())||(null===(i=null==n?void 0:n.body)||void 0===i?void 0:i.toString()),shouldCallFallback:S,status:null==T?void 0:T.status,statusText:null==T?void 0:T.statusText},shouldPostReleaseErrorReporting:!0}),S?(o(`=== "${t}" failed to fetch, trying next fallback ${k}`),b({basePathType:k,options:n,path:t})):Object.assign({errors:v,response:T},j)},f=async(o,e)=>{const r=h(e||{},[]),a=r.body?JSON.stringify(r.body):void 0,i=r.method||"GET",l=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":n()?"1":void 0,"Zonos-Test-Mode":t()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},r.headers);Object.keys(l).forEach((o=>void 0===l[o]&&delete l[o]));const d=Object.assign(Object.assign({},r),{body:"GET"===i?void 0:a,headers:l,method:i}),c=new URLSearchParams(window.location.search).get("useFallbackApi");return b({basePathType:c||s,options:d,path:o})};export{n as a,w as b,a as f,t as g,f as h,c as i,d as j,e as l,p as s}
@@ -1,227 +0,0 @@
1
- var __awaiter=this&&this.__awaiter||function(e,n,t,r){function o(e){return e instanceof t?e:new t((function(n){n(e)}))}return new(t||(t=Promise))((function(t,i){function u(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?t(e.value):o(e.value).then(u,a)}s((r=r.apply(e,n||[])).next())}))};var __generator=this&&this.__generator||function(e,n){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,u=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return u.next=a(0),u["throw"]=a(1),u["return"]=a(2),typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(e){return function(n){return s([e,n])}}function s(a){if(r)throw new TypeError("Generator is already executing.");while(u&&(u=0,a[0]&&(t=0)),t)try{if(r=1,o&&(i=a[0]&2?o["return"]:a[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;if(o=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:t.label++;return{value:a[1],done:false};case 5:t.label++;o=a[1];a=[0];continue;case 7:a=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){t.label=a[1];break}if(a[0]===6&&t.label<i[1]){t.label=i[1];i=a;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(a);break}if(i[2])t.ops.pop();t.trys.pop();continue}a=n.call(e,t)}catch(e){a=[6,e];o=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,n,t){if(t||arguments.length===2)for(var r=0,o=n.length,i;r<o;r++){if(i||!(r in n)){if(!i)i=Array.prototype.slice.call(n,0,r);i[r]=n[r]}}return e.concat(i||Array.prototype.slice.call(n))};System.register(["./p-CzKlS3E-.system.js","./p-DBOI98r5.system.js","./p-CKhl__Kc.system.js","./p-BbgqQIHv.system.js","./p-zVLAvre1.system.js","./p-smUku7Ku.system.js","./p-C29tlYn0.system.js","./p-DsBuZ6ob.system.js"],(function(e){"use strict";var n,t,r,o,i,u,a,s,c,d,l,f;return{setters:[function(n){e({curpRegex:n.c,isMexicoTaxIdType:n.i,isPeruTaxIdType:n.a,peruTaxIdTypeFromValue:n.p,stripTaxIdSeparators:n.s})},function(e){n=e.c},function(e){t=e.g;r=e.I},function(n){o=n.l;e("availableTestKeys",n.a)},function(e){i=e.g;u=e.a;a=e.h;s=e.l},function(n){c=n.g;d=n._;l=n.c;f=n.a;e({checkoutHiddenBtnSelector:n.c,checkoutHiddenInternationalBtnSelector:n.a,domesticRedirectedBtnSelector:n.d})},function(n){e("countryRequireShortAddressCode",n.c)},function(n){e({checkoutTaxIdTypeValues:n.a,countryRequireTaxId:n.c,euCountryCodes:n.e,isCountryRequireTaxId:n.i,peruTaxIdDigitLength:n.p,peruTaxIdFormatError:n.b,shipToTaxIdLabels:n.s,taxIdTypeOptions:n.t})}],execute:function(){var v=this;
2
- /**
3
- * Get the load version and url based on the loadScriptSrc and version
4
- * @returns
5
- */var m=function(e){var n=e.loadScriptSrc;if(!n){return{currentLoadScriptUrl:"",isForceLoadVersionDomain:false,isWhiteListed:false}}var t=[
6
- // local domain
7
- "dev.elements.zonos.com","dev.assets-checkout.zonos.com",
8
- // any domain with prefix , no need to version it
9
- ".js.zonos.com",
10
- // vercel git domain
11
- "zonos-elements-test-git","zonos-elements-git"];var r=[
12
- // force load version for qa domain, this is to test the load version behavior
13
- "qa.js.zonos.com"];
14
- // get the domain that's used to load the loadZonos.js
15
- var o=new URL(n).origin;var i=t.some((function(e){
16
- // check if the current domain is in the white listed domains
17
- return o.includes(e)}));var u=r.some((function(e){
18
- // check if the current domain is in the force load version domains list
19
- return o.includes(e)}));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:u,isWhiteListed:i}};var w=["jsdelivr","cdnjs","unpkg","vercel"];var p="jsdelivr";
20
- /**
21
- * Get the next cdn type in the fallback list
22
- * @param currentCdnType The current cdn type that want to get the next fallback url
23
- */var h=function(e){
24
- // get current index of the current fail cdn type in the fallback list
25
- var n=w.indexOf(e);
26
- // get the next fallback cdn type
27
- var t=w[n+1];return t||null};
28
- /**
29
- * Attempt to get test public credential to window.Zonos.zonosApiKey if needed
30
- */var y=function(){return __awaiter(v,void 0,void 0,(function(){var e,n,t,r,c,d;return __generator(this,(function(l){switch(l.label){case 0:e=i();n=u();
31
- // Do nothing if the test mode is not enabled or the public credential
32
- if(!e&&!n||!window.Zonos.zonosApiKey){return[2/*return*/,null]}o("[ZONOS - loadZonos] Attempt test public credential","info");
33
- // Try to get the test public credential if the test mode is enabled and the public credential key is not a test key
34
- if(!!window.Zonos.zonosApiKey.includes("credential_test")){o("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info");return[2/*return*/,null]}return[4/*yield*/,a("/api/get-test-public-credential")];case 1:t=l.sent(),r=t.errors,c=t.json;if(r.length||!c){s("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r);return[2/*return*/,null]}d=c.publicCredential;if(!d){s("[ZONOS - loadZonos] No test public key credential. Keep using production key");return[2/*return*/,null]}
35
- // Set the test public credential to the window object
36
- o("[ZONOS - loadZonos] Retrieve new test public token ".concat(d),"info");return[2/*return*/,d]}}))}))};
37
- /**
38
- * Extracts the zonosQaUrl from the url
39
- *
40
- * @param url - url to extract zonosQaUrl from
41
- *
42
- * **NOTE**: value of zonosQaUrl param should be without protocol, allowed characters are: a-z, A-Z, 0-9, -, _
43
- * @example
44
- * valid: https://www.zonos.com/?zonosQaUrl=some-feature-v988
45
- * invalid: https://www.zonos.com/?zonosQaUrl=https://zonos-something
46
- */var O=function(e){if(!e){return null}
47
- // get params from url
48
- var n=new URL(e).searchParams;var t=n.get("zonosQaUrl");if(!t){return null}var r=/[^a-zA-Z0-9-_]+/.test(t);if(!!r){return null}return t};
49
- /**
50
- * Get the Zonos QA URL and return it. Will remove `zonosQaUrl` from the url query if it doesn't exists.
51
- */var g=function(){
52
- /**
53
- * This is flag to force load cdn for testing purpose
54
- * When developing, if the script load is from `dev.elements.zonos.com`,
55
- * it would load script from that same domain instead of loading from cdn
56
- */
57
- var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=O(window.location.href);var t="https://v1.5.1.js.zonos.com";
58
- // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
59
- if(!n&&(t.includes("test.")||
60
- // Vercel git domain
61
- t.includes("test-"))){return t}
62
- // when local demo app is running, it needs to use the local dev script unless the qaUrl is set
63
- if(!n&&["dev.demo.elements.zonos.com","dev.checkout.elements.zonos.com","dev.storybook.elements.zonos.com"].includes(window.location.hostname)){return"https://dev.elements.zonos.com"}if(!n){return null}
64
- // If the qaUrl, use the dev-elements domain to forward the request to the dev server to quickly debug the issue
65
- if(n==="dev-elements"){return"https://dev.elements.zonos.com"}
66
- // The worker alias selects the API host only. Scripts stay on the normal CDN.
67
- if(n==="worker"){return null}var r="preview.js.zonos.com";var i="https://".concat(n,".").concat(r);o("[ZONOS-WARNING] using '".concat(i,"' for loading elements script"),"warn");
68
- // request to the url and check if the request has an error
69
- void fetch(i).then((function(){
70
- // cleanup checkout session to avoid using the prod session in preview domain
71
- window.sessionStorage.removeItem("zonos--checkout-session-id");window.sessionStorage.removeItem("zonos--client-secret")})).catch((function(){alert("[ZONOS-WARNING] '".concat(i,"' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE"));
72
- // remove the zonosQaUrl param from url
73
- var e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");var n=window.location.pathname;var t="".concat(n,"?").concat(e.toString());
74
- /**
75
- * Setting the state to null in window.history.replaceState can cause issues with rendering when using next/link and pressing the back button.
76
- * @ref https://github.com/vercel/next.js/issues/33233#issuecomment-1052349396
77
- **/window.history.replaceState(window.history.state,"",t);window.location.reload();return null}));return i};
78
- /* eslint-disable no-console */
79
- /** Loading stripe script extracted from stripe.js repository */var S="2025-02-24.acacia";var b="https://js.stripe.com/v3";var _=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var j=3;var z="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";var I=function(){var e=document.querySelectorAll('script[src^="'.concat(b,'"]'));for(var n=0;n<e.length;n++){var t=e[n];if(!t){continue}if(!_.test(t.src)){continue}return t}return null};var k=null;var T=function(e){var n="";var t=document.createElement("script");t.src="".concat(b).concat(n);var r=document.head||document.body;if(!r){s("Expected document.body not to be null. Stripe.js requires a <body> element.");return null}r.appendChild(t);return t};var N=function(e){
80
- // Ensure that we only attempt to load Stripe.js at most once
81
- if(k!==null){return k}k=new Promise((function(n,t){if(typeof window==="undefined"||typeof document==="undefined"){
82
- // Resolve to null when imported server side. This makes the module
83
- // safe to import in an isomorphic code base.
84
- n(null);return}if(window.Stripe){n(window.Stripe);return}try{var r=I();if(r&&e){console.warn(z)}else if(!r){r=T()}r===null||r===void 0?void 0:r.addEventListener("load",(function(){if(window.Stripe){n(window.Stripe)}else{t(new Error("Stripe.js not available"))}}));r===null||r===void 0?void 0:r.addEventListener("error",(function(){t(new Error("Failed to load Stripe.js"))}))}catch(e){t(e);return}}));return k};var A=function(e,n){if(!e||!e._registerWrapper){return}e._registerWrapper({name:"stripe-js",startTime:n})};var R=function(e){if(!("version"in e)){return}var n=e.version;return typeof n==="number"||typeof n==="string"?n:undefined};var Z=function(e,n,t){if(e===null){return null}var r=n[0],o=n[1];var i=Object.assign({},o);var u=R(e);var a=typeof u==="string"&&u!==j.toString();if(a){delete i.apiVersion}else{i.apiVersion=S}var s=e(r,i);A(s,t);return s};
85
- // Execute our own script injection after a tick to give users time to do their
86
- // own script injection.
87
- var E=function(){var e,n;return typeof window!=="undefined"&&(typeof((e=window.Zonos)===null||e===void 0?void 0:e.createCartId)==="function"||typeof((n=window.Zonos)===null||n===void 0?void 0:n.buildCartDetail)==="function")};var L=Promise.resolve().then((function(){
88
- // Skip eagerly loading Stripe when no checkout cart callback is configured
89
- // (e.g. a Hello-only integration). Stripe is loaded on demand instead.
90
- if(!E()){return null}return N(null)}));var U=false;L.catch((function(e){if(!U){
91
- // eslint-disable-next-line no-console
92
- console.warn(e)}}));var C=function(){var e=[];for(var n=0;n<arguments.length;n++){e[n]=arguments[n]}return __awaiter(v,void 0,void 0,(function(){var n,t,r,o;return __generator(this,(function(i){switch(i.label){case 0:U=true;t=Date.now();return[4/*yield*/,L];case 1:if(!((n=i.sent())!==null&&n!==void 0))return[3/*break*/,2];o=n;return[3/*break*/,4];case 2:return[4/*yield*/,N(null)];case 3:o=i.sent();i.label=4;case 4:r=o;return[2/*return*/,Z(r,e,t)]}}))}))};var x="tempCartUUID";
93
- /**
94
- * Simple function to get the cart id from the query param.
95
- */var P=function(){var e=new URLSearchParams(window.location.search);var n=e.get(x);return n};var D=function(e){return __awaiter(v,[e],void 0,(function(e){var n,r,u,s,d,l,f,v,m;var w=e.cartId,p=e.retries;return __generator(this,(function(e){switch(e.label){case 0:n=i();r=t();u=c()||undefined;s=new URLSearchParams;if(r.overrideShouldEnabledCustomAddress){s.set("overrideShouldEnabledCustomAddress",r.overrideShouldEnabledCustomAddress)}return[4/*yield*/,a("/api/zonos-elements/get-cart?".concat(s.toString()),{body:{isTestMode:n,renewCartExpirationToken:u,tempCartUUID:w},headers:{"Content-Type":"application/json"},method:"POST"})];case 1:d=e.sent(),l=d.errors,f=d.json,v=d.zonosMode;m=!f||l.length;if(!(m&&p))return[3/*break*/,3];o("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:p});
96
- // wait 1 second before retrying
97
- return[4/*yield*/,new Promise((function(e){return setTimeout(e,500)}))];case 2:
98
- // wait 1 second before retrying
99
- e.sent();return[2/*return*/,D({cartId:w,retries:p-1})];case 3:if(m){return[2/*return*/,null]}return[2/*return*/,Object.assign(Object.assign({},f),{zonosMode:v})]}}))}))};var F=function(e){return __awaiter(v,void 0,void 0,(function(){var n,t,r,i;return __generator(this,(function(u){switch(u.label){case 0:n=d(e),t=n.isDgsCartId,r=n.isLegacyCartId;if(!r&&!t){s("[ZONOS - loadZonos] invalid cart id");return[2/*return*/,null]}return[4/*yield*/,D({cartId:e,retries:5})];case 1:i=u.sent();o("[ZONOS - loadZonos] getting temp cart data","info",i);if(!i){s("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2/*return*/,null]}window.Zonos.storeId=i.cartData.storeId;window.Zonos.zonosApiKey=i.cartData.credentialToken;window.Zonos.zonosMode=i.zonosMode;return[2/*return*/,{cartData:i.cartData,settings:i.settings,storeFavicon:i.storeFaviconUrl,storeId:i.cartData.storeId,storeLogo:i.storeLogoUrl,zonosApiKey:i.cartData.credentialToken}]}}))}))};var M;
100
- /**
101
- * Get the load version and url based on the loadScriptSrc, if the domain that used to load `zonos.js` is in white listed domains, use currentLoadScriptUrl as the load url instead, if zonosQaUrl exists, it would also fall under the white listed domain
102
- */var B=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=m({loadScriptSrc:e===null||e===void 0?void 0:e.src}),t=n.currentLoadScriptUrl,r=n.isWhiteListed;if(r){return t}return null}();var K=Date.now();var G="https://v1.5.1.js.zonos.com";var V=B||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.5.1";var q="https://unpkg.com/@zonos/elements@1.5.1";var H="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.5.1";var W="https://fonts.googleapis.com";var Q=/^https:\/\/fonts\.googleapis\.com/;var Y=/** @class */function(){function e(){}return e}();e("Zonos",Y);M=Y;Y.doneInit=false;Y.cartSettings=null;
103
- // if query 'zonosDebug=1' param from url, debug mode is on
104
- Y.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Y.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Y._paypalMockResponse=null;Y.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Y.isBigCommerce=false;Y.releaseDate="1793041426949";Y.isLegacyCheckout=false;Y.googleAnalyticId=null;Y.googleAnalyticReady=false;Y.facebookPixelId=null;Y.facebookPixelReady=false;Y.startLoadTime=K;Y.domain=typeof window!=="undefined"?// domain that embeds the iframe
105
- window.location!=window.parent.location&&document.referrer||
106
- // current domain
107
- document.location.hostname:"";Y.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Y.overrideUseCustomAddressForm=false;Y.isCollect=false;Y.isInvoice=false;
108
- /**
109
- * By default, the package will load from npm
110
- */Y.isNpm=true;Y.zonosQaUrl=null;Y.zonosQaUrlApi=null;Y.trackEventLogs=[];Y.version="v".concat("1.5.1");Y.modeAlerted=false;Y.cartData=null;Y.paypal=null;Y.zonosMode=null;Y.IframeService=r;Y.getCurrentTimestamp=function(){return(new Date).getTime()};Y.zonosController=null;Y.loadTimeApiInfoList=[];Y.logIntervalId=null;Y.init=function(e){return __awaiter(v,void 0,void 0,(function(){var n,t,r,i,u,a,c,d,f,v,m,w,p,h,O;return __generator(this,(function(S){switch(S.label){case 0:n=e.appearance,t=e.checkoutSettings,r=e.currencyConverter,i=e.helloSettings,u=e.onCountryChange,a=e.overrideCurrencyFormat,c=e.storeId,d=e.zonosApiKey;M.cartId=P();
111
- // Expose the checkout cart callbacks on the global so Stripe loading can be
112
- // gated on whether at least one of them is configured.
113
- M.createCartId=t===null||t===void 0?void 0:t.createCartId;
114
- // eslint-disable-next-line @typescript-eslint/no-deprecated -- intentionally mirror the (deprecated) callback so Stripe loading can be gated on it
115
- M.buildCartDetail=t===null||t===void 0?void 0:t.buildCartDetail;if(M.doneInit){
116
- // do nothing if zonos is already initialized
117
- return[2/*return*/]}o("====== ZONOS DEBUG MODE: on (".concat(M.version,") ======"));M.zonosApiKey=d;M.storeId=c;
118
- // When not in iframe, providers are ready (gtag/fbq work directly). When in iframe, relay sets these after parent configures.
119
- if(typeof window!=="undefined"&&window.parent===window){M.googleAnalyticReady=true;M.facebookPixelReady=true}if(!M.isNpm)return[3/*break*/,4];o("====== ZONOS LOADING FROM NPM ======");f=g();
120
- // if zonosQaUrl is available, inject the script from the zonosQaUrl and then call init again
121
- if(f&&!window.isZonosPreview){o('====== RE-INJECT "zonos.js" FROM PRVIEW: '.concat(f," ======"),"info");v=document.createElement("script");v.src="".concat(f,"/dist/scripts/zonos.js");document.head.appendChild(v);v.addEventListener("load",(function(){window.Zonos.isNpm=M.isNpm;window.Zonos.isBigCommerce=M.isBigCommerce;window.Zonos.isLegacyCheckout=M.isLegacyCheckout;window.Zonos.zonosMode=M.zonosMode;
122
- // call init again after the script is loaded
123
- void window.Zonos.init(e)}));v.addEventListener("error",(function(){alert('[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: '.concat(f))}));
124
- // Set so won't inject the preview script again
125
- window.isZonosPreview=true;return[2/*return*/]}
126
- // zonosApiKey is required if tempCartUUID in query params are not provided
127
- if(!d&&!M.cartId){s("Zonos API key is required unless `tempCartUUID` is provided in url query params.");return[2/*return*/]}if(!(!M.cartData&&M.cartId))return[3/*break*/,2];o("Initialize cart data");return[4/*yield*/,F(M.cartId)];case 1:m=S.sent();if(!m){s("Failed to get cart data");return[2/*return*/]}M.cartData=m.cartData;M.zonosApiKey=m.zonosApiKey;M.cartSettings=m.settings;S.label=2;case 2:return[4/*yield*/,y()];case 3:w=S.sent();if(w){M.zonosApiKey=w}S.label=4;case 4:p=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");h=M.cartId&&M.cartData||!!p;
128
- // inject hidden button to body to trigger checkout right away if we have cartData or stripe client secret
129
- if(h){o("Cart data or stripe client secret is available, inject hidden button and trigger checkout");O=document.createElement("button");O.style.display="none";O.id="".concat(l);document.body.appendChild(O)}o("init zonos");M.restoreNativeBrowserFunctions();
130
- // inject custom script for hosted checkout if can find it in metadata
131
- M.injectCustomScriptForHostedCheckout();
132
- // inject zonos cdn
133
- M.injectZonosCdn();
134
- // inject css for zonos elements
135
- M.injectZonosCss();
136
- // inject fonts for zonos elements
137
- M.injectFonts();
138
- // inject checkout international button
139
- M.injectCheckoutInternationalButton();
140
- // init zonos controller
141
- M.injectController({config:{appearance:n,checkoutSettings:t,currencyConverter:r,helloSettings:i,onCountryChange:u,overrideCurrencyFormat:a}});M.doneInit=true;return[2/*return*/]}}))}))};
142
- /**
143
- * Inject the hidden international checkout button to trigger checkout regardless of shipping zones
144
- */Y.injectCheckoutInternationalButton=function(){if(!document.querySelector("#".concat(f))){
145
- // inject the hidden international checkout button
146
- var e=document.createElement("button");e.id=f;e.style.display="none";document.body.appendChild(e)}};Y.injectCustomScriptForHostedCheckout=function(){var e=M.cartData;var n=(e===null||e===void 0?void 0:e.metadata)||[];var t=n.find((function(e){return e.key==="customHeaderScript"}));var r=n.find((function(e){return e.key==="customFooterScript"}));
147
- // googleAnalyticId / facebookPixelId are set by customHTML in checkoutSettings (e.g. <script>window.Zonos.googleAnalyticId = "G-XXX"; window.Zonos.facebookPixelId = "1234567890";<\/script>), injected by zonos-controller
148
- // Only inject the script if checkout is on Zonos hosted checkout and custom script is available
149
- if(!window.Zonos.isLegacyCheckout||!t&&!r){o("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:t,isLegacyCheckout:window.Zonos.isLegacyCheckout});return}if(t){o("Injecting custom header script");var i=document.createElement("script");i.textContent=t.value;document.head.appendChild(i)}if(r){o("Injecting custom footer script");var i=document.createElement("script");i.textContent=r.value;document.body.appendChild(i)}};Y.displayCurrency=function(){var e=document.querySelector("zonos-hello");if(e){void e.displayCurrency()}};Y.triggerCheckoutInternational=function(){return __awaiter(v,void 0,void 0,(function(){var e;return __generator(this,(function(t){e=document.querySelector("#".concat(f));setTimeout((function(){if(e){e.dispatchEvent(n("click"))}}),10);return[2/*return*/]}))}))};
150
- // Called openHelloDialog because the main use case is to simply open the dialog
151
- Y.openHelloDialog=function(e){var n=document.querySelector("zonos-hello");if(n){void n.openHelloDialog(e!==null&&e!==void 0?e:true)}};Y.showNotification=function(e){var n;void((n=M.zonosController)===null||n===void 0?void 0:n.showNotification(e))};Y.updateOrganizationName=function(e){var n;void((n=M.zonosController)===null||n===void 0?void 0:n.updateOrganizationName(e))};Y.disablePlaceOrderButtons=function(e){var n=e.autoEnable,t=n===void 0?true:n,r=e.config,o=e.disable,i=e.placeOrderButtonSelector;var u;
152
- // if disablePlaceOrderButtonActivation is true, do nothing
153
- if((u=r.checkoutSettings)===null||u===void 0?void 0:u.disablePlaceOrderButtonActivation){return}
154
- // if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
155
- if(i){var a=document.querySelectorAll(i);var s=function(e){var n=e.target;
156
- // prevent default and propagation when the item has disabled attribute
157
- if(n.getAttribute("disabled")){e.preventDefault();e.stopPropagation()}};a.forEach((function(e){var n=e.getAttribute("data-zonos-checkout-attached");if(n){
158
- // do nothing if event is already attached
159
- return}if(o){e.setAttribute("disabled","true");
160
- // prevent the selector to perform default action when it's disabled
161
- e.addEventListener("click",s)}else{e.removeAttribute("disabled");
162
- // clean up the event listener
163
- e.removeEventListener("click",s)}}));
164
- // only auto enable if autoEnable is true and we are setting button disable
165
- if(t&&o){setTimeout((function(){
166
- // release it if zonos is not initialized after 5 seconds (this is to prevent the place order button from being disabled forever due to api)
167
- a.forEach((function(e){e.removeAttribute("disabled");
168
- // clean up the event listener if exists
169
- e.removeEventListener("click",s)}))}),5e3)}}};
170
- /**
171
- * Zonos elements and its dependencies are using the native browser functions.
172
- * This function will restore the native browser functions that are overridden by the merchant's polyfills.
173
- * If the URL parameter `useMerchantPolyfill=1` is present, keep the merchant's polyfills instead of restoring native browser functions. This allows testing checkout compatibility with merchant polyfills.
174
- */Y.restoreNativeBrowserFunctions=function(){var e;
175
- // If the URL parameter `useMerchantPolyfill=1` is present, keep the merchant's polyfills instead of restoring native browser functions.
176
- var n=new URL(window.location.href).searchParams.get("useMerchantPolyfill")==="1";if(n){return}var t="zonos---native-browser";var r=document.querySelector("iframe#".concat(t));if(!r){
177
- // add a hidden iframe
178
- r=document.createElement("iframe");r.id=t;r.style.display="none";r.style.opacity="0";r.style.position="absolute";r.style.top="-9999px";r.style.left="-9999px";r.style.width="1px";r.style.height="1px";r.style.border="none";r.style.overflow="hidden";r.style.visibility="hidden";document.body.appendChild(r)}
179
- /**
180
- * Override Array.from if the site is using the obsolete prototype.js (last updated 2015).
181
- * If old browser is being used and Array.from is not available, just use Array from the prototype.js polyfill
182
- */var o=((e=r.contentWindow)===null||e===void 0?void 0:e.window.Array.from)||Array.from;Array.from=o;document.body.removeChild(r)};Y.injectController=function(e){var n=e.config;var t,r;if(document.querySelector("zonos-controller")){return}
183
- // if placeOrderAnchor is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
184
- if((t=n.checkoutSettings)===null||t===void 0?void 0:t.placeOrderButtonSelector){var i=n.checkoutSettings.placeOrderButtonSelector;M.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:i});
185
- // create a mutation observer to see if any new elements that match our selector is added to the DOM
186
- var u=new MutationObserver((function(){M.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:i})}));u.observe(document.body,{childList:true,subtree:true})}
187
- // if alwaysTriggerInternationalCheckoutSelector is passed in the config for checkoutSettings, disable the place order button until zonos is initialized
188
- if((r=n.checkoutSettings)===null||r===void 0?void 0:r.alwaysTriggerInternationalCheckoutSelector){var a=n.checkoutSettings.alwaysTriggerInternationalCheckoutSelector;M.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a});
189
- // create a mutation observer to see if any new elements that match our selector is added to the DOM
190
- var u=new MutationObserver((function(){M.disablePlaceOrderButtons({config:n,disable:true,placeOrderButtonSelector:a})}));u.observe(document.body,{childList:true,subtree:true})}var c=document.createElement("zonos-controller");c.config=n;c.zonosApiKey=M.zonosApiKey||"";c.addEventListener("stripeInitEvent",(function(e){return __awaiter(v,void 0,void 0,(function(){var n,t;return __generator(this,(function(r){switch(r.label){case 0:n=e.detail;o("loading Stripe");return[4/*yield*/,C(n.publishableKey)];case 1:t=r.sent();if(!t){s("API seems to be invalid or missing. Failed to load Stripe");return[2/*return*/]}window.Zonos.stripe=t;if(window.Zonos.isCollect){void c.initCollectElement(t)}else if(window.Zonos.isInvoice){void c.initInvoiceElement(t)}else{void c.initCheckoutElement(t)}return[2/*return*/]}}))}))}));document.body.appendChild(c);
191
- // set zonos controller to be global
192
- M.zonosController=c;o("Zonos controller injected!")};Y.injectScript=function(e){var n=e.cdnType,t=e.isModule,r=e.theRestUrl;var i=M.getZonosUrl(n);var u="".concat(i,"/").concat(r);var a=function(){var e=document.querySelector('script[src="'.concat(u,'"]'));return!!e};if(a()){o('Zonos script "'.concat(u,'" already exists in the document'),"warn");return}var c=document.head||document.body;
193
- // init zonos elements when the zonosKey is valid
194
- // inject esmodule cdn for zonos elements
195
- var d=document.createElement("script");if(!!t){d.type="module"}else{d.noModule=true}d.src=u;d.crossOrigin="anonymous";d.onerror=function(){s("Failed to load ".concat(d.src));var e=h(n);
196
- // if next fallback cdn type exists, inject the script with the next fallback cdn type
197
- if(!e){return}M.injectScript({cdnType:e,isModule:t,theRestUrl:r})};c.appendChild(d)};
198
- /**
199
- * We now support loading Zonos via npm. For clients using npm, `zonosBase` will always load from the server side. Therefore, the `zonosLoadUrl` defined earlier won't work since it lacks access to client-side APIs such as `window` and `document`.
200
- */Y.getZonosUrl=function(e){var n=function(){switch(e){case"jsdelivr":return V;case"unpkg":return q;case"cdnjs":return H;case"vercel":return G}};
201
- // To ensure that sites using zonos-elements load the script from a specific domain when using npm, we need to check for zonosQaUrl and use it if available. Otherwise it will always load from the compiled versioned domain
202
- if(M.isNpm){var t=g();
203
- // Default to hard coded domain if zonosQaUrl is not available
204
- return t||n()}return n()};Y.injectZonosCdn=function(){
205
- // init zonos elements when the zonosKey is valid
206
- // inject esmodule cdn for zonos elements
207
- M.injectScript({cdnType:p,isModule:true,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"});
208
- // inject non module cdn for zonos elements
209
- M.injectScript({cdnType:p,isModule:false,theRestUrl:"dist/zonos-elements/zonos-elements.js"});o("Zonos cdn script injected!")};Y.injectStylesheet=function(e){var n=e.cdnType,t=e.theRestUrl;var r=M.getZonosUrl(n);var o=document.head||document.body;
210
- // inject preconnect css for zonos elements
211
- var i=document.createElement("link");i.rel="preconnect";i.href="".concat(G,"/");o.appendChild(i);
212
- // inject css for zonos elements
213
- var u=document.createElement("link");u.rel="stylesheet";u.href="".concat(r,"/").concat(t);u.onerror=function(){s("Failed to load ".concat(u.href));var e=h(n);
214
- // if the css failed to load, try to load the next fallback cdn if exists
215
- if(!e){return}M.injectStylesheet({cdnType:e,theRestUrl:t})};o.appendChild(u)};Y.injectZonosCss=function(){var e=function(){return!!document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')};if(e()){o("Zonos style links already injected","warn");return}
216
- // inject css for zonos elements
217
- M.injectStylesheet({cdnType:p,theRestUrl:"dist/zonos-elements/zonos-elements.css"});o("Zonos style css injected!")};Y.injectFonts=function(){var e=function(){var e=document.fonts.check("1em Inter");if(e){o("Inter font already loaded","warn");return}var n=document.querySelectorAll('link[rel="stylesheet"][href^="'.concat(W,'"]'));for(var t=0;t<n.length;t++){var r=n[t];if(!r){continue}if(Q.test(r.href)){continue}return r}return null};if(e()){o("Inter font already injected","warn");return}var n=document.head||document.body;
218
- // inject font css for zonos elements
219
- var t=document.createElement("link");t.rel="preconnect";t.href=W;n.appendChild(t);
220
- // inject font css for zonos elements
221
- var r=document.createElement("link");r.rel="stylesheet";r.href="".concat(W,"/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap");n.appendChild(r);o("Zonos font injected!")};
222
- // apply font for zonos elements and inject font if needed
223
- Y.setupGoogleFont=function(e){var n;void((n=M.zonosController)===null||n===void 0?void 0:n.setupGoogleFont(e))};
224
- // this function is to inject google font to the browser, not apply the font for zonos elements, to apply the font and inject font if needed, use `setupGoogleFont` instead
225
- Y.injectSupportGoogleFont=function(e){var n;o("[FONT] injecting ".concat(e));var t=(n=e.match(/family=(.*?):/))===null||n===void 0?void 0:n[1];var r=document.head||document.body;
226
- // inject font css for zonos elements
227
- if(!document.querySelector('link[rel="preconnect"][href^="'.concat(W,'"]'))){var i=document.createElement("link");i.rel="preconnect";i.href=W;r.appendChild(i)}if(document.querySelector('link[rel="stylesheet"][href="'.concat(e,'"]'))){o("[FONT] ".concat(t," font already injected"),"warn");return}var u=document.createElement("link");u.rel="stylesheet";u.href=e;r.appendChild(u);o("[FONT] ".concat(t," font injected!"))};var J=e("checkoutSessionMutableAttributeKeys",["ZONOS_FORM_TYPE_USING","APP_VERSION","APP_VERSION_NPM_INTEGRATION","LEGACY_CHECKOUT_FACADE"]);var $=e("checkoutSessionImmutableAttributeKeys",["ORDER_DUPLICATION_CONSENT","WITH_ABANDONED_CART_TOKEN"]);var X=e("checkoutSessionAttributeKeys",__spreadArray(__spreadArray([],J,true),$,true))}}}));
@@ -1,7 +0,0 @@
1
- System.register(["./p-6vSUiBfr.system.js"],(function(n){"use strict";var r;return{setters:[function(n){r=n.l}],execute:function(){
2
- /**
3
- * Since the backend and the frontend are using the same keys,
4
- * make sure to not change the key value below since if it changes
5
- * and the frontend script is cached, the formula may not work as expected.
6
- */
7
- var t=n("D","gkjqw123");var i=n("T","Kq93wqw3");var u=n("h",(function(){var n;return(n=r.inclusivePricingConfigurations)===null||n===void 0?void 0:n.some((function(n){var r,u;return((r=n.configurations[t])===null||r===void 0?void 0:r.status)==="ENABLED"||((u=n.configurations[i])===null||u===void 0?void 0:u.status)==="ENABLED"}))}))}}}));
@@ -1 +0,0 @@
1
- import{A as r}from"./p-CTiqplrr.js";const s=()=>r().length>1;export{s}
@@ -1 +0,0 @@
1
- import{r as t,d as e,h as o,a as i}from"./p-_lt63o7c.js";import{b as n}from"./p-BMPYH-LT.js";import{m as s,n as r,o as c,s as l,d as a}from"./p-CTiqplrr.js";import{z as d,a as u,b as h}from"./p-CqB9AfBf.js";import{g as p,i as m,a as f}from"./p-HeAZDwVW.js";import{h as w,l as v}from"./p-DE4a-QD5.js";import{l as g}from"./p-BJmZPrZl.js";import{e as y}from"./p-D1e9zNDA.js";import"./p-Dwg61Ft_.js";import"./p-DMIgN_sT.js";import"./p-YdrG78th.js";import"./p-r-YGHhLa.js";const S="zonos-domestic-element-hide-style",b="undefined"!=typeof document&&(()=>{try{return document.querySelector(":is(.zonos-is-probe)"),!0}catch(t){return!1}})(),z=t=>{const e=document.querySelector(t);if(!document.querySelector("zonos-hello")&&e){const t=document.createElement("zonos-hello");return e.appendChild(t),!0}return!1},j=t=>{switch(t){case"BOTTOM_RIGHT":default:return"bottom-right";case"BOTTOM_LEFT":return"bottom-left";case"TOP_LEFT":return"top-left";case"TOP_RIGHT":return"top-right"}},I=({position:t="bottom-right"})=>{const e=".zonos--hello-mobile-wrapper";if(document.querySelector(e))return e;const o=document.createElement("div");return o.className="zonos--hello-mobile-wrapper",o.style.position="fixed","top-right"===t&&(o.style.top="72px",o.style.right="24px"),"top-left"===t&&(o.style.top="72px",o.style.left="24px"),"bottom-right"===t&&(o.style.bottom="72px",o.style.right="24px"),"bottom-left"===t&&(o.style.bottom="72px",o.style.left="24px"),o.style.zIndex="2147483647",document.body.appendChild(o),e},O=async t=>{if(window.Zonos.isLegacyCheckout)return void g("Hello is disabled when isLegacyCheckout","info");const{anchorElementSelector:e}=t;let o=e;if(!t.anchorElementSelector&&t.desktopLocation){const t=I({position:"bottom-right"});o=t}if(o&&r(o)){if(g("Hello init complete"),!z(o)){const e=new MutationObserver((()=>{z(o)&&e.disconnect()}));e.observe(document.body,{childList:!0,subtree:!0}),setTimeout((()=>{z(o)}),1e3),setTimeout((()=>{if(t.notFoundElementFallback){g(`Hello anchor selector ${t.anchorElementSelector} not found after 3 seconds, falling back to 'notFoundElementFallback': ${t.notFoundElementFallback}`,"info");const e=I({position:j(t.notFoundElementFallback)});z(e)}}),3e3)}}else v(`Selector anchorElementSelector "${t.anchorElementSelector}" is not a valid selector.`)};class C{constructor(t,e){this.targetId=t,this.allowedEvents=e,this.listeners=new Map,this.handleMessage=t=>{var e,o,i;const n=t.data,s=(null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||(null===(i=null===(o=this.iframe)||void 0===o?void 0:o.contentDocument)||void 0===i?void 0:i.defaultView);if(t.source!==s)return;if(!this.isValidMessage(n))return;const r=this.listeners.get(n.type);null==r||r.forEach((t=>{try{t(n.payload)}catch(t){v("Error in event listener:",t)}}))},this.initializeEventListeners(),this.iframe=document.getElementById(this.targetId)}initializeEventListeners(){window.addEventListener("message",this.handleMessage)}isValidMessage(t){if(!t||"object"!=typeof t)return!1;const e=t;return e.id===this.targetId&&"string"==typeof e.type&&this.allowedEvents.includes(e.type)&&void 0!==e.payload}on(t,e){this.listeners.has(t)||this.listeners.set(t,new Set),g(`[CheckoutAddressService] listening to ${t}`,"info");const o=e,i=this.listeners.get(t);return i&&i.add(o),()=>{const e=this.listeners.get(t);e&&e.delete(o)}}destroy(){window.removeEventListener("message",this.handleMessage),this.listeners.clear()}}class k extends C{constructor(){g("=== [Google Places Service] Initializing","info"),super(m.GOOGLE_PLACES,["fetchAutocompleteSuggestions","initializeGooglePlacesService","placeSelected","onFetchAutocompleteSuggestions","onInitializeGooglePlacesService","onPlaceSelected"])}sendMessage(t,e){var o;if(!(null===(o=this.iframe)||void 0===o?void 0:o.contentWindow))return;const i={id:this.targetId,logType:window.Zonos.iframeLogType,payload:e,type:t};g(`GooglePlacesService] parent --\x3e ${t}`,"info",e),this.iframe.contentWindow.postMessage(i,"*")}initialize(){this.sendMessage("initializeGooglePlacesService",{})}fetchSuggestions({country:t,query:e,type:o}){t&&this.sendMessage("fetchAutocompleteSuggestions",{request:{includedRegionCodes:[t],input:e},type:o})}selectPlace({placeId:t,type:e}){this.sendMessage("placeSelected",{placeId:t,type:e})}}class A{constructor(){this.googlePlaceInitialized=!1,g("=== [CheckoutAddressService] Initializing","info"),this.googlePlaces=new k,this.googlePlaces.on("onInitializeGooglePlacesService",(()=>{g("=== [CheckoutAddressService] parent <-- onInitializeGooglePlacesService","info"),this.googlePlaceInitialized=!0})),this.initialize()}initialize(){this.googlePlaces.initialize()}onInitializeGooglePlacesService(t){return this.googlePlaces.on("onInitializeGooglePlacesService",(()=>{g("[CheckoutAddressService] parent <-- onInitializeGooglePlacesService"),t()}))}isGooglePlaceInitialized(){return this.googlePlaceInitialized}onAddressSuggestions(t){return this.suggestionsCallback=t,this.googlePlaces.on("onFetchAutocompleteSuggestions",((...e)=>{g(`[CheckoutAddressService] parent <-- onFetchAutocompleteSuggestions ${e[0].type}`,"info",...e),t(...e)}))}onAddressSelected(t){return this.placeSelectedCallback=t,this.googlePlaces.on("onPlaceSelected",((...e)=>{g(`[CheckoutAddressService] parent <-- onPlaceSelected ${e[0].type}`,"info",...e),t(...e)}))}getAddressSuggestions({country:t,query:e,type:o}){this.googlePlaceInitialized&&this.googlePlaces.fetchSuggestions({country:t,query:e,type:o})}selectAddress({placeId:t,type:e}){this.googlePlaces.selectPlace({placeId:t,type:e})}destroy(){this.googlePlaces.destroy(),this.suggestionsCallback&&(this.suggestionsCallback=void 0),this.placeSelectedCallback&&(this.placeSelectedCallback=void 0)}}const E=class{constructor(o){t(this,o),this.paypalInitEvent=e(this,"paypalInitEvent",7),this.stripeInitEvent=e(this,"stripeInitEvent",7)}async initCheckoutElement(t){var e;t?(n.stripe=t,((e=d.checkoutSettings).placeOrderButtonSelector||e.alwaysTriggerInternationalCheckoutSelector||window.Zonos.cartData)&&(!e.placeOrderButtonSelector||r(e.placeOrderButtonSelector)?!e.alwaysTriggerInternationalCheckoutSelector||r(e.alwaysTriggerInternationalCheckoutSelector)?(()=>{if(!document.querySelector("zonos-checkout")){const t=document.createElement("zonos-checkout");document.body.appendChild(t)}})():v(`Selector alwaysTriggerInternationalCheckoutSelector "${e.alwaysTriggerInternationalCheckoutSelector}" is not a valid selector`):v(`Selector checkoutButtonAnchor "${e.placeOrderButtonSelector}" is not a valid selector`)),g("init checkout element")):g("Stripe is not loaded yet - cannot init checkout element","warn")}async initCollectElement(t){t?(n.stripe=t,window.Zonos.cartData&&(()=>{if(!document.querySelector("zonos-collect")){const t=document.createElement("zonos-collect");document.body.appendChild(t)}})(),g("init Collect element")):g("Stripe is not loaded yet - cannot init Collect element","warn")}async initInvoiceElement(t){t?(n.stripe=t,window.Zonos.cartData&&(()=>{if(!document.querySelector("zonos-invoice")){const t=document.createElement("zonos-invoice");document.body.appendChild(t)}})(),g("init Invoice element")):g("Stripe is not loaded yet - cannot init Invoice element","warn")}initZonosNotification(){if(document.querySelector("zonos-notification"))return;const t=document.createElement("zonos-notification");document.body.appendChild(t)}async setupGoogleFont(t){var e,o;const i=t||u();if("Inter"===i){if(!t)return;g("[FONT] Just applied Inter , but no need to inject since we already inject Inter on start","warn"),d.appearance=Object.assign(Object.assign({},d.appearance),{fontFamily:t})}const n=new URLSearchParams;n.set("family",i);const{errors:s,json:r}=await w(`/api/zonos-elements/get-font-detail?${n.toString()}`);if(s.length>0)return g(`Failed to load font ${i}`,"warn"),void(d.appearance=Object.assign(Object.assign({},d.appearance),{fontFamily:"Inter"}));const c=null==r?void 0:r.fontUrl;c&&(null===(o=(e=window.Zonos).injectSupportGoogleFont)||void 0===o||o.call(e,c)),t&&(g(`[FONT] ${t} font override applied`),d.appearance=Object.assign(Object.assign({},d.appearance),{fontFamily:t}))}handleLocationChange(){O(d.helloSettings)}initHistoryListener(){const t=history.pushState;history.pushState=function(){return window.dispatchEvent(new window.Event("pushstate")),window.dispatchEvent(new window.Event("locationchange")),t.apply(this,arguments)};const e=history.replaceState;history.replaceState=function(){return window.dispatchEvent(new window.Event("replacestate")),window.dispatchEvent(new window.Event("locationchange")),e.apply(this,arguments)}}injectCustomHTML(t){if(!t)return;if(!window.Zonos.isLegacyCheckout||window.Zonos.isCollect||window.Zonos.isInvoice)return void g("=== Skip injecting custom HTML for hosted checkout","info");g("=== Injecting custom HTML for hosted checkout");const e=document.createElement("template");e.innerHTML=t,e.content.querySelectorAll("script").forEach((t=>{const e=document.createElement("script");t.src?(e.src=t.src,e.async=t.async):e.textContent=t.innerHTML,document.body.appendChild(e)})),y()}async initGooglePlacesService(t){const e=null==t?void 0:t.genericSettings;if(!e)return;const o=e.signedTokenGooglePlaces;o&&f({id:m.GOOGLE_PLACES,onload:()=>{d.checkoutAddressService=new A},src:`https://route.elements.zonos.com/iframe/google-maps?signedToken=${o}`})}buildBaseConfig(t){var e,o;const i=Object.assign(Object.assign({},this.config.checkoutSettings),{allowedSettlementCurrencies:void 0,captureDelay:void 0,subscriptionStatus:void 0});if(window.Zonos.isCollect||window.Zonos.isInvoice)return Object.assign(Object.assign({},this.config),{checkoutSettings:i,helloSettings:Object.assign(Object.assign({},this.config.helloSettings),{visibilityStatus:"DISABLED"})});if(!this.config.checkoutSettings)return Object.assign(Object.assign({},this.config),{checkoutSettings:void 0});const n=window.Zonos.isLegacyCheckout&&!!window.Zonos.cartData&&"CLOSE_MODAL"===(null===(e=this.config.checkoutSettings)||void 0===e?void 0:e.successBehavior);return Object.assign(Object.assign({},this.config),{checkoutSettings:Object.assign(Object.assign({},i),{successBehavior:n?"ZONOS_SUCCESS_PAGE":this.config.checkoutSettings.successBehavior,successRedirectUrl:n?(null===(o=window.Zonos.cartData)||void 0===o?void 0:o.storeBaseUrl)||(null==t?void 0:t.onlineStoreSettings.url):this.config.checkoutSettings.successRedirectUrl})})}async componentWillLoad(){this.initHistoryListener(),d.zonosApiKey=this.zonosApiKey,(async()=>{var t,e,o,i,n,r;const{errors:l,json:a,zonosMode:u}=await(async()=>{if(window.Zonos.cartSettings)return g("Reusing cached zonos settings"),{errors:[],json:window.Zonos.cartSettings,zonosMode:window.Zonos.zonosMode};const t=p(),e=new URLSearchParams;t.overrideShouldEnabledCustomAddress&&e.set("overrideShouldEnabledCustomAddress",t.overrideShouldEnabledCustomAddress);const o=s();o&&e.set("zCountry",o);const{errors:i,json:n,zonosMode:r}=await w(`/api/zonos-elements/zonos-settings?${e.toString()}`);return i.length?(v("Error occurred when getting zonos settings. If this is not an unauthorized error, it will use user settings or default settings"),{errors:i,json:null,zonosMode:r}):{errors:[],json:n,zonosMode:r}})();if("403"===(null===(e=null===(t=l[0])||void 0===t?void 0:t.type)||void 0===e?void 0:e.toString()))return void g("Failed to load zonos settings. This domain may not have access","warn");const m=(null===(o=null==a?void 0:a.checkoutSettings)||void 0===o?void 0:o.customHTML)||"";this.injectCustomHTML(m),this.initZonosNotification();const f=this.buildBaseConfig(a),y=Object.assign(Object.assign(Object.assign({},this.config),{appearance:Object.assign(Object.assign({},this.config.appearance),{logoUrl:(()=>{var t,e,o;return window.Zonos.isLegacyCheckout?(null===(t=null==a?void 0:a.appearanceSettings)||void 0===t?void 0:t.logoUrl)||(null===(e=this.config.appearance)||void 0===e?void 0:e.logoUrl):null===(o=this.config.appearance)||void 0===o?void 0:o.logoUrl})()})}),f);h({overrideSettings:y,zonosSettings:a}),d.zonosMode=u,(t=>{if("undefined"==typeof document||!t)return;const e=(({merchantSelector:t,supportsIs:e})=>e?`body.z-intl :is(${t})`:(t=>{const e=[];let o=0,i=0,n="";for(let s=0;s<t.length;s++){const r=t[s];if("("===r?o++:")"===r?o--:"["===r?i++:"]"===r&&i--,","===r&&0===o&&0===i){const t=n.trim();t&&e.push(t),n=""}else n+=r}const s=n.trim();return s&&e.push(s),e})(t).map((t=>`body.z-intl ${t}`)).join(", "))({merchantSelector:t,supportsIs:b});if(e.includes("<"))return void g(`Skip domesticElementSelector injection: "${t}" contains "<"`,"warn");try{document.querySelector(e)}catch(o){return void g(`Skip domesticElementSelector injection: "${t}" produced an invalid CSS selector ("${e}")`,"warn")}if(document.getElementById(S))return;const o=document.createElement("style");o.id=S,o.textContent=`${e} { display: none !important; }`,(document.head||document.body).appendChild(o),g("Zonos domestic element hide style injected")})(d.checkoutSettings.domesticElementSelector),this.setupGoogleFont(),"DISABLED"===d.helloSettings.visibilityStatus&&g("=== Hello is disabled by store owner ===","warn"),d.helloSettings&&"ENABLED"===d.helloSettings.visibilityStatus&&(g("Initializing hello"),O(d.helloSettings)),await c();const z=(null===(i=null==a?void 0:a.checkoutSettings)||void 0===i?void 0:i.externalServiceTokens.find((t=>"STRIPE_PUBLISHABLE_TOKEN"===t.type)))||null;if(!z||!this.stripeInitEvent)return void g("Checkout failed to load -- missing publishable key","warn");if(window.Zonos.isCollect||window.Zonos.isInvoice)return this.stripeInitEvent.emit({publishableKey:z.token}),void this.initGooglePlacesService(a);if("INACTIVE"===d.checkoutSettings.subscriptionStatus)return g('=== Checkout subscription is "INACTIVE" - Cancel initializing for Checkout ===',"warn"),void g("zonos controller loaded");if("DISABLED"===d.checkoutSettings.visibilityStatus)return g("=== Checkout is disabled by store owner ===","warn"),void g("zonos controller loaded");const j="function"==typeof(null===(n=d.checkoutSettings)||void 0===n?void 0:n.buildCartDetail)||"function"==typeof(null===(r=d.checkoutSettings)||void 0===r?void 0:r.createCartId),I=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret"),C=!(!window.Zonos.cartId||!window.Zonos.cartData)||!!I;j||C?(this.stripeInitEvent.emit({publishableKey:z.token}),this.initGooglePlacesService(a)):g("Skip loading Stripe because no cart callback (buildCartDetail/createCartId), prefetched cart, or payment client secret is present","warn")})()}async showNotification(t){const e=document.querySelector("zonos-notification");e?e.showNotification(t):g("Failed to show notification - zonos-notification not found","warn")}async reset(){l.checkoutSessionId=null,n.clientSecret=""}async overrideConfig(t){h({overrideSettings:t,zonosSettings:null})}async overrideCountry(t){g(`Override country code to ${t}`),a({isInitializing:!1,newSelectedCountryCode:t})}async getAppearanceSetting(){return d.appearance}async updateOrganizationName(t){d.organizationName=t}render(){return o(i,{key:"1714865012d806892f03e03896ee2f04aa1a729d",class:"zonos--elements"})}};E.style=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{visibility:hidden;opacity:0;height:0}";export{E as zonos_controller}
@@ -1,60 +0,0 @@
1
- var __awaiter=this&&this.__awaiter||function(n,e,r,o){function t(n){return n instanceof r?n:new r((function(e){e(n)}))}return new(r||(r=Promise))((function(r,i){function a(n){try{s(o.next(n))}catch(n){i(n)}}function u(n){try{s(o["throw"](n))}catch(n){i(n)}}function s(n){n.done?r(n.value):t(n.value).then(a,u)}s((o=o.apply(n,e||[])).next())}))};var __generator=this&&this.__generator||function(n,e){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,t,i,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=u(0),a["throw"]=u(1),a["return"]=u(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(n){return function(e){return s([n,e])}}function s(u){if(o)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(r=0)),r)try{if(o=1,t&&(i=u[0]&2?t["return"]:u[0]?t["throw"]||((i=t["return"])&&i.call(t),0):t.next)&&!(i=i.call(t,u[1])).done)return i;if(t=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:r.label++;return{value:u[1],done:false};case 5:r.label++;t=u[1];u=[0];continue;case 7:u=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){r.label=u[1];break}if(u[0]===6&&r.label<i[1]){r.label=i[1];i=u;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(u);break}if(i[2])r.ops.pop();r.trys.pop();continue}u=e.call(n,r)}catch(n){u=[6,n];t=0}finally{o=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(n,e,r){if(r||arguments.length===2)for(var o=0,t=e.length,i;o<t;o++){if(i||!(o in e)){if(!i)i=Array.prototype.slice.call(e,0,o);i[o]=e[o]}}return n.concat(i||Array.prototype.slice.call(e))};System.register(["./p-BbgqQIHv.system.js"],(function(n){"use strict";var e;return{setters:[function(n){e=n.l}],execute:function(){var r=this;var o=n("l",(function(n){var r=[];for(var o=1;o<arguments.length;o++){r[o-1]=arguments[o]}e.apply(void 0,__spreadArray([n,"error"],r,false))}));var t=n("a",(function(){return window.location.search.includes("zonosStagingMode=1")}));var i=n("g",(function(){var n;return((n=window.Zonos.zonosApiKey)===null||n===void 0?void 0:n.includes("test"))||window.location.search.includes("zonosTestMode=1")}));var a=["cloudflare","vercel"];var u=a[0];var s=n("f",{cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"});var c=s[u];
2
- /**
3
- * Next available fallback api type
4
- */var d=function(n){if(n===void 0){n=u}var e=a.indexOf(n);var r=a[e+1];if(!r){return null}return r};var l=n("j",(function(n){if(typeof n==="string"){try{
5
- // eslint-disable-next-line no-restricted-syntax
6
- var e=JSON.parse(n);return e}catch(n){return null}}return null}));var f=890;var v=n("i",(function(n){return n||window.innerWidth<f}));var w=function(){var n="connection"in window.navigator?// connection is not yet supported in all browsers
7
- window.navigator.connection:null;var e="mozConnection"in window.navigator?// mozConnection is not yet supported in all browsers
8
- window.navigator.mozConnection:null;var r="webkitConnection"in window.navigator?// webkitConnection is not yet supported in all browsers
9
- window.navigator.webkitConnection:null;var o=n||e||r;return o};var p=n("b",(function(){var n="userAgentData"in window.navigator?// userAgentData is not yet supported in all browsers
10
- window.navigator.userAgentData:null;var e=w();return{connectionDownlink:e===null||e===void 0?void 0:e.downlink,connectionEffectiveType:e===null||e===void 0?void 0:e.effectiveType,connectionRtt:e===null||e===void 0?void 0:e.rtt,connectionSaveData:e===null||e===void 0?void 0:e.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:n&&n.brands.length>0?n:window.navigator.userAgent}}));var h=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"];
11
- /**
12
- * Prepares the load time api log for the given API call to send to the server later
13
- * This function is used to prepare the load time api log for the given API call.
14
- * It adds the load time api log to the loadTimeApiInfoList.
15
- */var b=function(n){var e=n.apiPath,r=n.apiType,o=n.loadTimeInternal,t=n.loadTimeTotal;if(h.includes(e)){return}var i=t-o;
16
- // No need to record if the browser API load time is negative (cached)
17
- if(i<0){return}
18
- // e.g. /api/zonos-elements/log-script-load?zonosDebug=1 -> /api/zonos-elements/log-script-load
19
- var a=e.split("?")[0]||e;var u=p();var s=typeof u.userAgent==="object"&&u.userAgent.mobile;var c={apiType:r,connectionType:u.connectionEffectiveType,href:a,isHostedCheckout:window.Zonos.isLegacyCheckout,
20
- // Use the isMobileAgent to determine if the checkout is mobile, if it's not availabe, use the logic from isCheckoutMobile
21
- isMobile:v(s),loadTimeBrowserApi:i,loadTimeInternal:o,loadTimeTotal:t,metadata:Object.assign({},u),screenHeight:u.screenHeight,screenWidth:u.screenWidth,userAgent:typeof u.userAgent==="string"?u.userAgent:u.userAgent["brands"].map((function(n){return n.brand})).filter((function(n){return!/Not.*A.*Brand.*/.test(n)})).join(",")};window.Zonos.loadTimeApiInfoList.push(c)};
22
- /**
23
- * This is the time in milliseconds after release time that we will start sending error logs to the new API
24
- * @default 1 hour
25
- */var y=1*3600*1e3;// 1 hour
26
- var m=n("s",(function(n){return __awaiter(r,[n],void 0,(function(n){var r,o,t,i,a;var u=n.endpoint,l=n.errors,f=n.metadata,v=n.shouldPostReleaseErrorReporting;return __generator(this,(function(n){e("sendErrorLog","warn",u,f,l);if(v){r=Number(window.Zonos.releaseDate);o=(new Date).getTime();if(o-r>y){return[2/*return*/]}}t="userAgentData"in window.navigator?// userAgentData is not yet supported in all browsers
27
- window.navigator.userAgentData:null;i={endpoint:u,errors:l,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:t&&t.brands.length>0?t:window.navigator.userAgent},f)};try{
28
- // use native fetch because in handleFetch also calls sendErrorLog and it will possibly cause circular dependencies issue
29
- void fetch("".concat(c,"/api/zonos-elements/log-error"),{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(n){a=d();if(!a){return[2/*return*/]}
30
- // request to the fallback API if the first one fails
31
- void fetch("".concat(s[a],"/api/zonos-elements/log-error"),{body:JSON.stringify(i),method:"POST"})}return[2/*return*/]}))}))}));var g=undefined&&undefined.__rest||function(n,e){var r={};for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)&&e.indexOf(o)<0)r[o]=n[o];if(n!=null&&typeof Object.getOwnPropertySymbols==="function")for(var t=0,o=Object.getOwnPropertySymbols(n);t<o.length;t++){if(e.indexOf(o[t])<0&&Object.prototype.propertyIsEnumerable.call(n,o[t]))r[o[t]]=n[o[t]]}return r};var _=function(n){return __awaiter(r,[n],void 0,(function(n){var e,r,o;var t=n.response,i=n.shouldLog,a=i===void 0?true:i,u=n.shouldThrow,s=u===void 0?false:u;return __generator(this,(function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4/*yield*/,t.text()];case 1:e=n.sent();r=l(e);if(!r){throw new Error("Failed to parse content: ".concat(e))}return[2/*return*/,r];case 2:o=n.sent();if(s){throw o}if(a){
32
- // eslint-disable-next-line
33
- console.error(o)}return[2/*return*/,null];case 3:return[2/*return*/]}}))}))};var T=function(n){try{
34
- // encode the string, remove the "=" at the end of the encoded string
35
- var e=btoa(n).replace(/=/g,"");return e}catch(e){
36
- // return the reverse string if the encoding failed
37
- return n.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}};var j=function(n){return __awaiter(r,[n],void 0,(function(n){var e,r,o,t,i,a,c,d,l,f,v,f,w,p,c,h,c;var b=n.basePathType,y=n.options,m=n.path;return __generator(this,(function(n){switch(n.label){case 0:r=window.Zonos.zonosQaUrlApi||s[b]||u;o=r+m;t=new URL(o);i=window.Zonos.cartId?"".concat(window.location.hostname,"-").concat(window.Zonos.cartId):window.location.hostname;t.searchParams.set("zToken",T(i));n.label=1;case 1:n.trys.push([1,3,,4]);return[4/*yield*/,fetch(t.toString(),y)];case 2:e=n.sent();return[3/*break*/,4];case 3:a=n.sent();if(a instanceof Error){return[2/*return*/,{baseUrl:r,errors:[{message:a.message,type:"unknown"}],json:null,response:null,zonosMode:null}]}c="Failed to fetch";return[2/*return*/,{baseUrl:r,errors:[{message:c,type:"unknown"}],json:null,response:null,zonosMode:null}];case 4:d=e.headers.get("Zonos-Mode");l=window.Zonos.zonosQaUrl;
38
- // We only want to alert once if the user is in preview mode and it's also using production environment
39
- if(!window.Zonos.modeAlerted&&d&&l){window.Zonos.modeAlerted=true}if(!e.ok)return[3/*break*/,6];return[4/*yield*/,_({response:e})];case 5:f=n.sent();return[2/*return*/,{baseUrl:r,errors:[],json:f,response:e,zonosMode:d}];case 6:v=e.status.toString();n.label=7;case 7:n.trys.push([7,9,,10]);return[4/*yield*/,_({response:e,shouldThrow:true})];case 8:f=n.sent();
40
- // Parse and access "errors" from the response if possible
41
- if(f&&"errors"in f&&Array.isArray(f.errors)){w=f.errors;p=w.map((function(n){if(typeof n==="string"){return{message:n,type:v}}return n}));return[2/*return*/,{baseUrl:r,errors:p,json:null,response:e,zonosMode:d}]}c=JSON.stringify(f);return[2/*return*/,{baseUrl:r,errors:[{message:c,type:v}],json:null,response:e,zonosMode:d}];case 9:h=n.sent();c="Unknown error";return[2/*return*/,{baseUrl:r,errors:[{message:"".concat(v,": ").concat(c),type:v}],json:null,response:null,zonosMode:d}];case 10:return[2/*return*/]}}))}))};var k=function(n){return __awaiter(r,[n],void 0,(function(n){var r,o,t,i,a,u,c,f,v,w,p,h,y,_,T,O,z;var A=n.basePathType,S=n.options,M=n.path;return __generator(this,(function(n){switch(n.label){case 0:t=M.startsWith("/api/bigcommerce");i=t?"vercel":A;a=performance.now();return[4/*yield*/,j({basePathType:i,options:S,path:M})];case 1:u=n.sent(),c=u.errors,f=u.response,v=g(u,["errors","response"]);w=performance.now();p=w-a;
42
- // Send the load time api log
43
- e("".concat(M," (").concat(p.toFixed(2),"ms)"),"info");h=f===null||f===void 0?void 0:f.headers.get("Zonos-Duration");
44
- // Only record if the response status is 200, some endpoint will return 200 with error
45
- if((f===null||f===void 0?void 0:f.status)===200){b({apiPath:M,apiType:i,loadTimeInternal:h?Number(h):0,loadTimeTotal:p})}y=d(i);_=c.find((function(n){var e=n.type;return e==="unknown"}));T=c.find((function(n){var e=n.message;return typeof e==="string"&&(e.includes("signal is aborted")||e.includes("The operation was aborted")||e.includes("Fetch is aborted"))}));O=!!_||(f===null||f===void 0?void 0:f.status)===404||(f===null||f===void 0?void 0:f.status)===500;z=
46
- // If next fallback is available, and the error is unknown (Failed to fetch) or 404 or 500 (server error)
47
- y&&O;
48
- // Should log the error if it's unknown error
49
- if(O&&!T){void m({endpoint:s[i]+M,errors:c.map((function(n){var e=n.message;return"API: ".concat(e)})),metadata:{currentBasePath:i,nextFallbackApiType:y,requestHeaders:S===null||S===void 0?void 0:S.headers,requestPayload:l((r=S===null||S===void 0?void 0:S.body)===null||r===void 0?void 0:r.toString())||((o=S===null||S===void 0?void 0:S.body)===null||o===void 0?void 0:o.toString()),shouldCallFallback:z,status:f===null||f===void 0?void 0:f.status,statusText:f===null||f===void 0?void 0:f.statusText},
50
- // When the error is unknown, error reporting should be enabled for period of time after release, so we can monitor the error.
51
- shouldPostReleaseErrorReporting:true})}if(z){e('=== "'.concat(M,'" failed to fetch, trying next fallback ').concat(y));return[2/*return*/,k({basePathType:y,options:S,path:M})]}
52
- // No more fallbacks, just return the result
53
- return[2/*return*/,Object.assign({errors:c,response:f},v)]}}))}))};
54
- /**
55
- * Fetch request and will request to fallback API when the first one fails
56
- * @param path Path name of the request (e.g. /api/something/com).
57
- * @param _opts fetch options
58
- */var O=n("h",(function(n,e){return __awaiter(r,void 0,void 0,(function(){var r,o,a,s,c,d;return __generator(this,(function(l){r=g(e||{},[]);o=r.body?JSON.stringify(r.body):undefined;a=r.method||"GET";s=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":t()?"1":undefined,"Zonos-Test-Mode":i()?"1":undefined,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},r.headers);
59
- // filter all underfined headers
60
- Object.keys(s).forEach((function(n){return s[n]===undefined&&delete s[n]}));c=Object.assign(Object.assign({},r),{body:a==="GET"?undefined:o,headers:s,method:a});d=new URLSearchParams(window.location.search).get("useFallbackApi");return[2/*return*/,k({basePathType:d||u,options:c,path:n})]}))}))}))}}}));