@zonos/elements 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/dist/cjs/{cart-CiXlehwQ.js → cart-BJpqPdFU.js} +13 -13
  2. package/dist/cjs/{collect-Drr8fY-q.js → collect-CyUttsvB.js} +3 -3
  3. package/dist/cjs/{getMissingRequiredShippingFields-DI6qF1z3.js → getMissingRequiredShippingFields-DEbNbRAZ.js} +1 -1
  4. package/dist/cjs/{handleFetch-DQLhurnE.js → handleFetch-DVfjFTYO.js} +181 -71
  5. package/dist/cjs/{hasInclusivePrice-84KS94yH.js → hasInclusivePrice-CEPf3_FG.js} +1 -1
  6. package/dist/cjs/index.cjs.js +104 -12
  7. package/dist/cjs/{invoice-5hVfSXpb.js → invoice-DzRkkpLu.js} +3 -3
  8. package/dist/cjs/{localization-B2mjW0Xa.js → localization-BhNVhLZs.js} +24 -48
  9. package/dist/cjs/{paypal-pd8Nz_R_.js → paypal-DCSqbdjW.js} +4 -4
  10. package/dist/cjs/{placeTestOrder-DrI8rD9o.js → placeTestOrder-Bkip4PUT.js} +3 -3
  11. package/dist/cjs/{renderCheckoutCurrency-u5q8YdUb.js → renderCheckoutCurrency-BDvEZ3Hv.js} +2 -2
  12. package/dist/cjs/{shouldShowLanguageSelect-gBg4KeTQ.js → shouldShowLanguageSelect-NOVWOU53.js} +1 -1
  13. package/dist/cjs/{submitGtag-Rc-S3PnH.js → submitGtag-D4sB7w4z.js} +1 -1
  14. package/dist/cjs/{taxIdFields-BrIaPTcd.js → taxIdFields-e4OCgr8K.js} +2 -2
  15. package/dist/cjs/{updateCheckoutSessionAttributes-d0IKpwW8.js → updateCheckoutSessionAttributes-KxwcsKhM.js} +1 -1
  16. package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +5 -5
  17. package/dist/cjs/zonos-address-display_2.cjs.entry.js +2 -2
  18. package/dist/cjs/zonos-address_4.cjs.entry.js +4 -4
  19. package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +4 -4
  20. package/dist/cjs/zonos-card_5.cjs.entry.js +5 -5
  21. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +18 -18
  22. package/dist/cjs/zonos-checkout.cjs.entry.js +9 -9
  23. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +3 -3
  24. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +9 -9
  25. package/dist/cjs/zonos-collect.cjs.entry.js +6 -6
  26. package/dist/cjs/zonos-controller.cjs.entry.js +6 -6
  27. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
  28. package/dist/cjs/zonos-country-select_4.cjs.entry.js +3 -3
  29. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +3 -3
  30. package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
  31. package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +5 -5
  32. package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +9 -9
  33. package/dist/cjs/zonos-invoice.cjs.entry.js +6 -6
  34. package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
  35. package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +4 -4
  36. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +8 -7
  37. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +4 -3
  38. package/dist/collection/components/main/zonos-controller.js +3 -2
  39. package/dist/collection/components/store/checkout/cart.js +3 -2
  40. package/dist/collection/components/store/checkout/stripe.js +10 -9
  41. package/dist/collection/components/store/storageStore.js +7 -6
  42. package/dist/collection/components/utils/__tests__/helpers/blockStorage.js +24 -0
  43. package/dist/collection/components/utils/api/getExchangeRate.js +2 -1
  44. package/dist/collection/components/utils/handleFetch.js +19 -9
  45. package/dist/collection/components/utils/hello/countryOverrideStorage.js +17 -40
  46. package/dist/collection/components/utils/logging/installConstructorCapture.js +58 -0
  47. package/dist/collection/components/utils/logging/reportBlockedStorage.js +34 -0
  48. package/dist/collection/components/utils/logging/sendErrorLog.js +8 -1
  49. package/dist/collection/components/utils/logging/startZonosInit.js +35 -0
  50. package/dist/collection/components/utils/logging/thrownMessage.js +16 -0
  51. package/dist/collection/components/utils/safeStorage.js +39 -0
  52. package/dist/collection/scripts/_getZonosQaUrl.js +3 -2
  53. package/dist/collection/scripts/_zonosBase.js +6 -2
  54. package/dist/collection/types/generated/graphql.frontend.types.js +0 -16
  55. package/dist/collection/types/generated/graphql.internal.types.js +215 -1
  56. package/dist/esm/{cart-DmJkjiDE.js → cart-BS5mSI8x.js} +13 -13
  57. package/dist/esm/{collect-BV5GTPmh.js → collect-B9ZxDDl7.js} +3 -3
  58. package/dist/esm/{getMissingRequiredShippingFields-DljgpDZe.js → getMissingRequiredShippingFields-BkEV865q.js} +1 -1
  59. package/dist/esm/{handleFetch-D5GYDF-O.js → handleFetch-BFVO7oAR.js} +178 -72
  60. package/dist/esm/{hasInclusivePrice-DhGXpH2D.js → hasInclusivePrice-zSvDReDb.js} +1 -1
  61. package/dist/esm/index.js +104 -12
  62. package/dist/esm/{invoice-CO-iqlni.js → invoice-6iTuS6ek.js} +3 -3
  63. package/dist/esm/{localization-DHM91diu.js → localization-CXHiWcJp.js} +24 -48
  64. package/dist/esm/{paypal-BfW5aLJw.js → paypal-BE_NVBoy.js} +4 -4
  65. package/dist/esm/{placeTestOrder-CyWUFhxD.js → placeTestOrder-BXA9K9Iy.js} +3 -3
  66. package/dist/esm/{renderCheckoutCurrency-B31ZNkUv.js → renderCheckoutCurrency-KMa4HlAf.js} +2 -2
  67. package/dist/esm/{shouldShowLanguageSelect-DwSfSHar.js → shouldShowLanguageSelect-BI_ApEsQ.js} +1 -1
  68. package/dist/esm/{submitGtag-BEFrutel.js → submitGtag-C5xzFHjG.js} +1 -1
  69. package/dist/esm/{taxIdFields-ByEYfsO5.js → taxIdFields-BUKnHMaL.js} +2 -2
  70. package/dist/esm/{updateCheckoutSessionAttributes-B0bQH0uw.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +1 -1
  71. package/dist/esm/zonos-address-completion-dialog_7.entry.js +5 -5
  72. package/dist/esm/zonos-address-display_2.entry.js +2 -2
  73. package/dist/esm/zonos-address_4.entry.js +4 -4
  74. package/dist/esm/zonos-airwallex-payment.entry.js +4 -4
  75. package/dist/esm/zonos-card_5.entry.js +5 -5
  76. package/dist/esm/zonos-cart-items_12.entry.js +18 -18
  77. package/dist/esm/zonos-checkout.entry.js +9 -9
  78. package/dist/esm/zonos-collect-cart-items_3.entry.js +3 -3
  79. package/dist/esm/zonos-collect-finish_6.entry.js +9 -9
  80. package/dist/esm/zonos-collect.entry.js +6 -6
  81. package/dist/esm/zonos-controller.entry.js +6 -6
  82. package/dist/esm/zonos-country-flag.entry.js +2 -2
  83. package/dist/esm/zonos-country-select_4.entry.js +3 -3
  84. package/dist/esm/zonos-hello-dialog.entry.js +3 -3
  85. package/dist/esm/zonos-hello.entry.js +2 -2
  86. package/dist/esm/zonos-invoice-cart-items_2.entry.js +5 -5
  87. package/dist/esm/zonos-invoice-finish_5.entry.js +9 -9
  88. package/dist/esm/zonos-invoice.entry.js +6 -6
  89. package/dist/esm/zonos-language-select_2.entry.js +2 -2
  90. package/dist/esm/zonos-policy-consent_2.entry.js +4 -4
  91. package/dist/esm-es5/{cart-DmJkjiDE.js → cart-BS5mSI8x.js} +58 -58
  92. package/dist/esm-es5/{collect-BV5GTPmh.js → collect-B9ZxDDl7.js} +1 -1
  93. package/dist/esm-es5/{getMissingRequiredShippingFields-DljgpDZe.js → getMissingRequiredShippingFields-BkEV865q.js} +1 -1
  94. package/dist/esm-es5/handleFetch-BFVO7oAR.js +73 -0
  95. package/dist/esm-es5/{hasInclusivePrice-DhGXpH2D.js → hasInclusivePrice-zSvDReDb.js} +1 -1
  96. package/dist/esm-es5/index.js +26 -8
  97. package/dist/esm-es5/{invoice-CO-iqlni.js → invoice-6iTuS6ek.js} +1 -1
  98. package/dist/esm-es5/{localization-DHM91diu.js → localization-CXHiWcJp.js} +6 -9
  99. package/dist/esm-es5/{paypal-BfW5aLJw.js → paypal-BE_NVBoy.js} +1 -1
  100. package/dist/esm-es5/{placeTestOrder-CyWUFhxD.js → placeTestOrder-BXA9K9Iy.js} +1 -1
  101. package/dist/esm-es5/{renderCheckoutCurrency-B31ZNkUv.js → renderCheckoutCurrency-KMa4HlAf.js} +2 -2
  102. package/dist/esm-es5/{shouldShowLanguageSelect-DwSfSHar.js → shouldShowLanguageSelect-BI_ApEsQ.js} +1 -1
  103. package/dist/esm-es5/{submitGtag-BEFrutel.js → submitGtag-C5xzFHjG.js} +1 -1
  104. package/dist/esm-es5/{taxIdFields-ByEYfsO5.js → taxIdFields-BUKnHMaL.js} +2 -2
  105. package/dist/esm-es5/{updateCheckoutSessionAttributes-B0bQH0uw.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +1 -1
  106. package/dist/esm-es5/zonos-address-completion-dialog_7.entry.js +1 -1
  107. package/dist/esm-es5/zonos-address-display_2.entry.js +1 -1
  108. package/dist/esm-es5/zonos-address_4.entry.js +1 -1
  109. package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
  110. package/dist/esm-es5/zonos-card_5.entry.js +6 -6
  111. package/dist/esm-es5/zonos-cart-items_12.entry.js +127 -127
  112. package/dist/esm-es5/zonos-checkout.entry.js +3 -3
  113. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  114. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
  115. package/dist/esm-es5/zonos-collect.entry.js +6 -6
  116. package/dist/esm-es5/zonos-controller.entry.js +5 -5
  117. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  118. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  119. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  120. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  121. package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
  122. package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
  123. package/dist/esm-es5/zonos-invoice.entry.js +3 -3
  124. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  125. package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
  126. package/dist/scripts/index.d.ts +6 -0
  127. package/dist/scripts/index.js +1 -1
  128. package/dist/scripts/loadZonos.js +1 -1
  129. package/dist/scripts/zonos.js +1 -1
  130. package/dist/types/components/utils/__tests__/helpers/blockStorage.d.ts +3 -0
  131. package/dist/types/components/utils/logging/installConstructorCapture.d.ts +20 -0
  132. package/dist/types/components/utils/logging/reportBlockedStorage.d.ts +16 -0
  133. package/dist/types/components/utils/logging/startZonosInit.d.ts +5 -0
  134. package/dist/types/components/utils/logging/thrownMessage.d.ts +1 -0
  135. package/dist/types/components/utils/safeStorage.d.ts +4 -0
  136. package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +5 -0
  137. package/dist/types/types/generated/graphql.frontend.types.d.ts +0 -22
  138. package/dist/types/types/generated/graphql.frontend.types.ts +0 -51
  139. package/dist/types/types/generated/graphql.internal.types.d.ts +270 -1
  140. package/dist/types/types/generated/graphql.internal.types.ts +341 -1
  141. package/dist/zonos-elements/index.esm.js +1 -1
  142. package/dist/zonos-elements/{p-8fa6cfff.entry.js → p-08b01c96.entry.js} +1 -1
  143. package/dist/zonos-elements/{p-3e705c9b.entry.js → p-0909ef77.entry.js} +1 -1
  144. package/dist/zonos-elements/{p-2b63865a.system.entry.js → p-13015d34.system.entry.js} +1 -1
  145. package/dist/zonos-elements/{p-2d513aa3.entry.js → p-13d5b2f9.entry.js} +1 -1
  146. package/dist/zonos-elements/{p-46a839d2.system.entry.js → p-150047b3.system.entry.js} +16 -16
  147. package/dist/zonos-elements/{p-6e691736.entry.js → p-1986cc37.entry.js} +1 -1
  148. package/dist/zonos-elements/{p-vTIygnHq.system.js → p-1OG3IJgY.system.js} +1 -1
  149. package/dist/zonos-elements/{p-189cc594.system.entry.js → p-30bf4700.system.entry.js} +1 -1
  150. package/dist/zonos-elements/{p-4917b74d.entry.js → p-3466bcba.entry.js} +1 -1
  151. package/dist/zonos-elements/{p-12b24ebb.entry.js → p-383343c7.entry.js} +1 -1
  152. package/dist/zonos-elements/{p-5585db86.system.entry.js → p-3a506614.system.entry.js} +36 -36
  153. package/dist/zonos-elements/{p-46b9f0cf.entry.js → p-43c0ebe9.entry.js} +1 -1
  154. package/dist/zonos-elements/{p-84e76348.entry.js → p-4b65f192.entry.js} +1 -1
  155. package/dist/zonos-elements/{p-216a908d.system.entry.js → p-573a4e7c.system.entry.js} +6 -6
  156. package/dist/zonos-elements/{p-1fda4aec.system.entry.js → p-5a296dbc.system.entry.js} +87 -87
  157. package/dist/zonos-elements/{p-960070d0.system.entry.js → p-68325c5a.system.entry.js} +4 -4
  158. package/dist/zonos-elements/{p-53eac12f.system.entry.js → p-6db7317a.system.entry.js} +13 -13
  159. package/dist/zonos-elements/{p-1199baef.system.entry.js → p-709d1561.system.entry.js} +1 -1
  160. package/dist/zonos-elements/p-71d29603.entry.js +1 -0
  161. package/dist/zonos-elements/{p-064d8829.system.entry.js → p-7214c953.system.entry.js} +23 -23
  162. package/dist/zonos-elements/{p-65817880.entry.js → p-7fe83919.entry.js} +1 -1
  163. package/dist/zonos-elements/p-8ac26831.entry.js +1 -0
  164. package/dist/zonos-elements/{p-cccaad60.system.entry.js → p-8f9f859f.system.entry.js} +9 -9
  165. package/dist/zonos-elements/{p-f5f95990.system.entry.js → p-96b250d8.system.entry.js} +14 -14
  166. package/dist/zonos-elements/{p-678b9214.entry.js → p-97729873.entry.js} +1 -1
  167. package/dist/zonos-elements/{p-f3d9a380.system.entry.js → p-9b3668a4.system.entry.js} +144 -144
  168. package/dist/zonos-elements/{p-d8f375da.system.entry.js → p-9df31243.system.entry.js} +1 -1
  169. package/dist/zonos-elements/p-BI6VAB5B.js +1 -0
  170. package/dist/zonos-elements/p-BJFa5RwX.js +1 -0
  171. package/dist/zonos-elements/p-BJ_kE5rM.js +1 -0
  172. package/dist/zonos-elements/{p-XoQH3S7Z.system.js → p-BKUlQxBd.system.js} +1 -1
  173. package/dist/zonos-elements/{p-DprOoI2W.system.js → p-BUfCTQXY.system.js} +154 -154
  174. package/dist/zonos-elements/{p-CBUz18kA.system.js → p-BnQyot7Y.system.js} +23 -23
  175. package/dist/zonos-elements/p-Bu9WCfUC.system.js +1 -1
  176. package/dist/zonos-elements/{p-CMo3ZweU.js → p-C-zdj7MK.js} +1 -1
  177. package/dist/zonos-elements/{p-iAIzUA4k.js → p-C5fs3rIR.js} +1 -1
  178. package/dist/zonos-elements/{p-D1e9zNDA.js → p-CJmWr75U.js} +1 -1
  179. package/dist/zonos-elements/{p-Dtu_Japy.system.js → p-CMneHjck.system.js} +39 -39
  180. package/dist/zonos-elements/p-CP7KnfR3.system.js +245 -0
  181. package/dist/zonos-elements/p-CVRbGFV3.js +1 -0
  182. package/dist/zonos-elements/p-Cl5yV0ak.js +1 -0
  183. package/dist/zonos-elements/{p-CGNVm52g.system.js → p-Cp1IAJvW.system.js} +5 -5
  184. package/dist/zonos-elements/{p-6vSUiBfr.system.js → p-D-Lnf8mS.system.js} +50 -53
  185. package/dist/zonos-elements/p-D0DkOoAw.system.js +73 -0
  186. package/dist/zonos-elements/p-D4xpkSsK.js +1 -0
  187. package/dist/zonos-elements/p-DATNIakn.js +1 -0
  188. package/dist/zonos-elements/{p-CbhN65lj.system.js → p-DC1OPJDq.system.js} +1 -1
  189. package/dist/zonos-elements/{p-CHKKvuiz.js → p-DKnphvmJ.js} +1 -1
  190. package/dist/zonos-elements/{p-ojtNq-r5.system.js → p-DXlojp_Y.system.js} +1 -1
  191. package/dist/zonos-elements/{p-C9XLkmmb.system.js → p-DrS-0mk7.system.js} +1 -1
  192. package/dist/zonos-elements/{p-DpwmHU8R.js → p-DrbN3rPL.js} +2 -2
  193. package/dist/zonos-elements/{p-BrQ8n8NS.system.js → p-Dv5a-V6w.system.js} +3 -3
  194. package/dist/zonos-elements/{p-55813e9f.system.entry.js → p-a3c147d2.system.entry.js} +3 -3
  195. package/dist/zonos-elements/{p-DiMEP3mh.js → p-aK18R41t.js} +1 -1
  196. package/dist/zonos-elements/p-af4ad54b.entry.js +1 -0
  197. package/dist/zonos-elements/{p-1e6db427.entry.js → p-af741506.entry.js} +1 -1
  198. package/dist/zonos-elements/{p-2ca826b9.system.entry.js → p-b540c636.system.entry.js} +1 -1
  199. package/dist/zonos-elements/{p-636b71d4.entry.js → p-bac94956.entry.js} +1 -1
  200. package/dist/zonos-elements/{p-941a95a1.system.entry.js → p-bb1b414a.system.entry.js} +5 -5
  201. package/dist/zonos-elements/{p-e7fdb2c9.entry.js → p-bfa9e32a.entry.js} +1 -1
  202. package/dist/zonos-elements/p-cf6bf7a4.entry.js +1 -0
  203. package/dist/zonos-elements/p-dJcbnNlE.system.js +7 -0
  204. package/dist/zonos-elements/{p-7dc7f328.entry.js → p-db40b9c3.entry.js} +1 -1
  205. package/dist/zonos-elements/{p-d3345b2c.entry.js → p-dd003161.entry.js} +1 -1
  206. package/dist/zonos-elements/{p-ef5344ea.entry.js → p-e374aaa4.entry.js} +1 -1
  207. package/dist/zonos-elements/{p-6410fa11.system.entry.js → p-e43470f7.system.entry.js} +22 -22
  208. package/dist/zonos-elements/{p-fda89981.system.entry.js → p-ebc7ea54.system.entry.js} +3 -3
  209. package/dist/zonos-elements/{p-1cc42a98.system.entry.js → p-f2ed52bc.system.entry.js} +16 -16
  210. package/dist/zonos-elements/p-gEViRqvf.js +1 -0
  211. package/dist/zonos-elements/{p-DgUrB-1a.system.js → p-yv7ekcdG.system.js} +2 -2
  212. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  213. package/package.json +1 -1
  214. package/dist/esm-es5/handleFetch-D5GYDF-O.js +0 -60
  215. package/dist/zonos-elements/p-107f287b.entry.js +0 -1
  216. package/dist/zonos-elements/p-25eb99d4.entry.js +0 -1
  217. package/dist/zonos-elements/p-8f9d8795.entry.js +0 -1
  218. package/dist/zonos-elements/p-BMPYH-LT.js +0 -1
  219. package/dist/zonos-elements/p-C70h5mKA.js +0 -1
  220. package/dist/zonos-elements/p-CTiqplrr.js +0 -1
  221. package/dist/zonos-elements/p-Ch1w0Lr7.js +0 -1
  222. package/dist/zonos-elements/p-D1SmY_fZ.js +0 -1
  223. package/dist/zonos-elements/p-D6xXnsM_.js +0 -1
  224. package/dist/zonos-elements/p-DE4a-QD5.js +0 -1
  225. package/dist/zonos-elements/p-DQrMfUzi.system.js +0 -227
  226. package/dist/zonos-elements/p-DZdkJHK9.system.js +0 -7
  227. package/dist/zonos-elements/p-U33isUJG.js +0 -1
  228. package/dist/zonos-elements/p-ebe157b5.entry.js +0 -1
  229. package/dist/zonos-elements/p-zVLAvre1.system.js +0 -60
@@ -1 +1 @@
1
- import{c as n,z as e}from"./p-CqB9AfBf.js";import{t,l as r,s as i}from"./p-CTiqplrr.js";import{l as o,h as a,s}from"./p-DE4a-QD5.js";import{l as u,b as c}from"./p-BJmZPrZl.js";import{d as l,Z as d,b as f,a1 as v}from"./p-BMPYH-LT.js";function m(n,e){(null==e||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function p(n,e,t,r,i,o,a){try{var s=n[o](a),u=s.value}catch(n){return void t(n)}s.done?e(u):Promise.resolve(u).then(r,i)}function h(n){return function(){var e=this,t=arguments;return new Promise((function(r,i){var o=n.apply(e,t);function a(n){p(o,r,i,a,s,"next",n)}function s(n){p(o,r,i,a,s,"throw",n)}a(void 0)}))}}function y(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function w(n,e){return e&&function(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}(n.prototype,e),n}function b(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function g(n,e){return null!=e&&"undefined"!=typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](n):n instanceof e}function k(n){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{},r=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})))),r.forEach((function(e){b(n,e,t[e])}))}return n}function x(n,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):function(n){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e.push.apply(e,t)}return e}(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))})),n}function E(n,e){return function(n){if(Array.isArray(n))return n}(n)||function(n,e){var t=null==n?null:"undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(null!=t){var r,i,o=[],a=!0,s=!1;try{for(t=t.call(n);!(a=(r=t.next()).done)&&(o.push(r.value),o.length!==e);a=!0);}catch(n){s=!0,i=n}finally{try{a||null==t.return||t.return()}finally{if(s)throw i}}return o}}(n,e)||N(n,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function I(n){return function(n){if(Array.isArray(n))return m(n)}(n)||function(n){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}(n)||N(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(n){return n&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n}function N(n,e){if(n){if("string"==typeof n)return m(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);return"Object"===t&&n.constructor&&(t=n.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?m(n,e):void 0}}function C(n,e){var t,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(n,a)}catch(n){o=[6,n],r=0}finally{t=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var T,D,P,R,O,j=function(n){return n.production="prod",n.demo="demo",n.staging="staging",n}(j||{}),A="airTracker_unknown",_={appName:A,appVersion:A,env:"staging",isWebappContainer:!1,delay:2e3,errorRepeatTime:3,enableErrorMonitoring:!1,assetSpeedMonitoringWhiteList:[],enableDetectPageChange:!1,enableRecordPageRetention:!1,hideSearchParams:!1,useSessionStorageForSessionId:!1,assetSpeedMonitoringWhiteListByMFE:{}},L={appName:A,env:"staging",sessionId:A,deviceId:A},U=function(){var n=new WeakSet;return function(e,t){if(g(t,Error))return"Error.message: ".concat(t.message," \n Error.stack: ").concat(t.stack);if("object"===(void 0===t?"undefined":S(t))&&null!==t){if(n.has(t))return"[Circular ".concat(e||"root","]");n.add(t)}return"function"==typeof t?"function":"symbol"===(void 0===t?"undefined":S(t))?"symbol":void 0===t?null:t}},M=function(n){if("string"==typeof n)return n;try{return g(n,Error)?(JSON.stringify(n,U())||"undefined").replace(/"/gim,""):JSON.stringify(n,U())}catch(n){return'{"error":"error happen when airTracker stringify"}'}},F=function(n){var e=n.method,t=void 0===e?"post":e,r=n.url,i=n.data,o=n.success,a=n.fail;if((s=i)&&!/^\s*$/.test(s)&&(s=(s=(s=s.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@")).replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]")).replace(/(?:^|:|,)(?:\s*\[)+/g,""),/^[\],:{}\s]*$/.test(s))){var s,u=new XMLHttpRequest;u.addEventListener("readystatechange",(function(){4===u.readyState&&(u.status>=400||0===u.status?null==a||a(u.response):null==o||o(u.response))})),u.open(t,r),u.setRequestHeader("Content-Type","application/json"),u.send(i)}},K="onCommonUpdated",H="AIR_ANALYTICS_DEVICE_ID",q="AIR_ANALYTICS_SESSION_ID",B=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(n){var e=16*Math.random()|0;return("x"===n?e:3&e|8).toString(16)}))},z=function(n){var e,t,r;return n.config.getMFEName?n.config.getMFEName():(null===(r=location)||void 0===r||null===(t=r.pathname)||void 0===t||null===(e=t.split("/"))||void 0===e?void 0:e[2])||"unknown"},W=function(n){return"string"==typeof n?n.split("?")[1]||"":n},X=function(n){return"string"==typeof n&&n.startsWith("//")?"undefined"!=typeof location&&"https:"===location.protocol:/^https/.test(n)},V=function(n){return"number"==typeof n||"string"==typeof n?n:-1},G=function(n,e){var t,r=!1;if(!e.config.isWebappContainer)return J(n,e.config.assetSpeedMonitoringWhiteList);var i=z(e);return r||J(n,null===(t=e.config.assetSpeedMonitoringWhiteListByMFE)||void 0===t?void 0:t[i])},J=function(n,e){if(!(null==e?void 0:e.length))return!1;for(var t=0;t<e.length;t++){var r=e[t];if(g(r,RegExp)&&r.test(n))return!0;if("string"==typeof r&&n.includes(r))return!0}return!1},$=function(n,e){return Math.round(100*(n-e))/100},Q=function(n){return function(e){var t,r,i=z(n),o=n.config.isWebappContainer?k({},n.commonData||{},(null===(t=n.MFECommonDataMap)||void 0===t?void 0:t[i])||{}):n.commonData,a=Array.isArray(e)?e:[e];if(0!==a.length){var s,u=M({commonData:o,data:a}),c={method:"post",url:(s=n.commonData.env,"prod"==s?"https://o11y.airwallex.com/airtracker/logs":"demo"==s?"https://o11y-demo.airwallex.com/airtracker/logs":"https://o11y-staging.airwallex.com/airtracker/logs"),data:u};"function"==typeof(null===(r=navigator)||void 0===r?void 0:r.sendBeacon)&&navigator.sendBeacon(c.url,u)||F(c)}}},Y=function(n){return function(e){var t,r,i,o=z(n),a={commonData:n.config.isWebappContainer?k({},n.commonData||{},(null===(t=n.MFECommonDataMap)||void 0===t?void 0:t[o])||{}):n.commonData,data:Array.isArray(e)?e:[e]},s=M(a),u={method:"post",url:(i=n.commonData.env,"prod"==i?"https://o11y.airwallex.com/airtracker/metrics":"demo"==i?"https://o11y-demo.airwallex.com/airtracker/metrics":"https://o11y-staging.airwallex.com/airtracker/metrics"),data:s};"function"==typeof(null===(r=navigator)||void 0===r?void 0:r.sendBeacon)&&navigator.sendBeacon(u.url,s)||F(u)}},Z=function(n,e){var t,r=[],i=n.config;return window.addEventListener("beforeunload",(function(){r.length>0&&(n.immediateSendPipe(r.splice(0,r.length)),t&&clearTimeout(t))})),function(o,a){if(r.push(o),n.lifeCycle.on(K,(function(){r.length>0&&(null==a||a(r.splice(0,r.length)),n.lifeCycle.remove(K),t&&clearTimeout(t))})),r.length>=e)return null==a||a(r.splice(0,r.length)),void(t&&clearTimeout(t));t&&clearTimeout(t),t=setTimeout((function(){t=null,r.length>0&&(null==a||a(r.splice(0,r.length)),n.lifeCycle.remove(K))}),i.delay)}},nn=function(){},en=function(n){if(!n||!n.reduce||!n.length)throw new TypeError("createPipeline need at least one function param");return 1===n.length?function(e,t){n[0](e,t||nn)}:n.reduce((function(n,e){return function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:nn;return n(t,(function(n){return null==e?void 0:e(n,r)}))}}))},tn=function(){function n(){var e=this;y(this,n),this.emit=function(n,t){if(e){var r,i=e.eventsList[n];if(null==i?void 0:i.length){i=i.slice();for(var o=0;o<i.length;o++){r=i[o];try{var a=r.callback.apply(e,[t]);if(1===r.type&&e.remove(n,r.callback),!1===a)break}catch(n){throw n}}}return e}},this.eventsList={}}return w(n,[{key:"indexOf",value:function(n,e){for(var t=0;t<n.length;t++)if(n[t].callback===e)return t;return-1}},{key:"on",value:function(n,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(this){var r=this.eventsList[n];return r||(this.eventsList[n]=[],r=this.eventsList[n]),-1===this.indexOf(r,e)?(r.push({name:n,type:t||0,callback:e}),this):this}}},{key:"one",value:function(n,e){this.on(n,e,1)}},{key:"remove",value:function(n,e){if(this){var t=this.eventsList[n];if(!t)return null;if(!e){try{delete this.eventsList[n]}catch(n){}return null}if(t.length){var r=this.indexOf(t,e);t.splice(r,1)}return this}}},{key:"clear",value:function(){this.eventsList={}}}]),n}(),rn=function(){function n(e){y(this,n),this.name="",this.isInit=!1,this.name=e.name,this.option=e}return w(n,[{key:"patch",value:function(n){var e,t;this.isInit||(this.isInit=!0,null===(t=this.option)||void 0===t||null===(e=t.setUp)||void 0===e||e.call(this.option,n))}},{key:"uninstall",value:function(){var n,e;null===(e=this.option)||void 0===e||null===(n=e.destroy)||void 0===n||n.apply(this),this.isInit=!1}}]),n}(),on=function(n){var e="".concat(M(n.message)||""," @ (").concat(M(n.filename)||"",":").concat(n.lineno||0,":").concat(n.colno||0,")\n").concat(M(n.error||""));T.normalLogPipeLine({severity:"autoDetectError",eventName:"windowOnError",extraInfo:{error:e}})},an=function(n){var e=n&&M(n.reason);T.normalLogPipeLine({severity:"autoDetectError",eventName:"promiseError",extraInfo:{error:e}})},sn=function(n){var e=(null==n?void 0:n.target)||(null==n?void 0:n.srcElement);if(e){var t=(null==e?void 0:e.src)||(null==e?void 0:e.href),r=e.tagName,i="unknown";if("string"==typeof t&&r){if(window.location.href.indexOf(t)>-1)return;if(/\.js$/.test(t))i="script";else if(/\.css$/.test(t))i="css";else switch(r.toLowerCase()){case"script":i="script";break;case"link":i="css";break;case"img":i="image";break;case"audio":case"video":i="media";break;default:return}T.normalLogPipeLine({severity:"autoDetectError",eventName:"staticFileLoadError",extraInfo:{staticFileType:i,error:"".concat(r," load fail: ").concat(t)}})}}},un=new rn({name:"errorDetectionPlugin",setUp:function(n){T=n,window.addEventListener("error",on),window.addEventListener("unhandledrejection",an),window.document.addEventListener("error",sn,!0)},destroy:function(){window.removeEventListener("unhandledrejection",an),window.document.removeEventListener("error",sn,!0),window.removeEventListener("error",on)}}),cn=["img","css","script","link","audio","video","iframe"],ln="resource",dn=function(n){var e,t=n.name;return{url:(e=t,"string"==typeof e?(e.split("?")[0]||"").slice(0,200):e),method:"get",duration:Number(n.duration.toFixed(2)),type:"static",isHttps:X(t),urlQuery:W(t),domainLookup:V(n.domainLookupEnd-n.domainLookupStart),connectTime:V(n.connectEnd-n.connectStart)}},fn=function(n,e){for(var t=0,r=n.length;t<r;t++){var i=n[t];-1!==cn.indexOf(i.initiatorType)&&G(i.name,e)&&e.normalLogPipeLine({severity:"performance",eventName:"assets_speed",extraInfo:{log:dn(i)}})}},vn=new rn({name:"assetsSpeedPlugin",setUp:function(n){if(void 0!==window.performance&&"function"==typeof window.performance.clearResourceTimings&&"function"==typeof window.performance.getEntriesByType&&"function"==typeof window.performance.now){var e=0;window.performance.onresourcetimingbufferfull=function(){e=0,window.performance.clearResourceTimings()},"function"==typeof window.PerformanceObserver?(fn(window.performance.getEntriesByType(ln),n),(P=new window.PerformanceObserver((function(e){fn(e.getEntries(),n)}))).observe({entryTypes:[ln]})):D=setInterval((function(){var t=window.performance.getEntriesByType(ln),r=t.slice(e);e=t.length,fn(r,n)}),3e3)}},destroy:function(){null==P||P.disconnect(),D&&clearInterval(D)}}),mn=new rn({name:"onPageChangePlugin",setUp:function(){var n=h((function(n){var e,t,r,i;return C(this,(function(){return t=null===(e=location)||void 0===e?void 0:e.href,r=document.querySelector("body"),i=function(e){var t,r,i,o,a;n.normalLogPipeLine({severity:"autoDetectEvent",eventName:"onPageChange",extraInfo:{prevHref:e.prevHref,href:(null===(t=location)||void 0===t?void 0:t.href)||"",hostname:null===(r=location)||void 0===r?void 0:r.hostname,pathName:null===(i=location)||void 0===i?void 0:i.pathname,protocol:null===(o=location)||void 0===o?void 0:o.protocol,search:null===(a=location)||void 0===a?void 0:a.search}})},i({prevHref:""}),(R=new MutationObserver((function(){if(location.href!==t){var n=t;t=location.href,i({prevHref:n})}}))).observe(r||document,{subtree:!0,childList:!0}),[2]}))}));return function(e){return n.apply(this,arguments)}}(),destroy:function(){null==R||R.disconnect()}}),pn=new rn({name:"onPageRetentionPlugin",setUp:function(){var n=h((function(n){var e,t,r,i,o,a;return C(this,(function(){return void 0===document.visibilityState||(t=null===(e=location)||void 0===e?void 0:e.href,r=document.querySelector("body"),(o=function(){i=Date.now()})(),document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState?a({href:location.href,leftReason:"visibilityChange"}):"visible"===document.visibilityState&&o()})),window.addEventListener("beforeunload",(function(){a({href:location.href,sendImmediate:!0,leftReason:"pageClose"})})),a=function(e){var t=e.href,r=e.sendImmediate,o=e.leftReason;if(i){var a=Date.now()-i;if(0!==a){i=void 0;var s={severity:"autoDetectEvent",eventName:"onPageRetention",extraInfo:{href:t,duration:a,leftReason:o}};r?n.ImmediatePipeline(s):n.normalLogPipeLine(s)}}},(O=new MutationObserver((function(){if(location.href!==t){var n=t;t=location.href,a({href:n,leftReason:"nextPage"}),o()}}))).observe(r||document,{subtree:!0,childList:!0})),[2]}))}));return function(e){return n.apply(this,arguments)}}(),destroy:function(){null==O||O.disconnect()}}),hn=function(){return Date.now().toString(36)+Math.random().toString(36).substring(2,15)},yn=function(n,e){return![/authenticate\/heartbeat/,/papluginlogs\/.*/,/airtracker\/.*/,/o11y(-staging|-demo)?\.airwallex\.com/,/\.(png|jpe?g|gif|svg|ico|webp|avif|css|js|json|woff2?|ttf|eot|map|txt|csv|xml)(\?.*)?(#.*)?$/i].some((function(e){return e.test(n)}))&&J(n,e||[/^https?:\/\/[^\/]*\.airwallex\.com($|\/)/])},wn=function(n){return Math.round(100*n)/100},bn=function(n,e){var t,r,i,o,a,s,u,c,l,d,f,v,m,p,h,y,w,b,g,E=n.url,I=n.method,S=n.errorType,N=n.errorDetail,C=function(n){var e=n.startTime,t=n.endTime,r=n.entries;if(0!==r.length){if(1===r.length)return r[0];var i=r.filter((function(n){return n.startTime>=e&&t&&n.responseEnd<=t})).sort((function(n,e){return n.startTime-e.startTime}));return null==i?void 0:i[0]}}(n),T=new URL(E,window.location.href),D=T.href,P=T.protocol,R=C?(i=(t=C).duration,o=t.responseStart,a=t.connectEnd,s=t.connectStart,u=t.domainLookupEnd,c=t.domainLookupStart,l=t.requestStart,d=t.secureConnectionStart,f=t.redirectEnd,v=t.redirectStart,m=t.responseStatus,p=t.responseEnd,h=t.encodedBodySize,y=t.decodedBodySize,w=t.transferSize,b=t.deliveryType,g=t.initiatorType,{startTime:wn(r=t.startTime),totalDuration:wn(i),timeToFirstByte:$(o,r),tcpDuration:$(a,s),dnsDuration:$(u,c),tlsDuration:$(l,d),redirectDuration:$(f,v),responseDuration:$(p,o),encodeResponseSize:h,decodeResponseSize:y,transferSize:w,deliveryType:b,statusCode:m,initiatorType:g}):{};return{severity:"autoDetectEvent",eventName:"httpClientMetrics",extraInfo:k(x(k({httpUrl:D,method:I,scheme:P},S&&{errorType:S},N&&{errorDetail:N},R),{statusCode:(null==R?void 0:R.statusCode)||(null==n?void 0:n.responseStatus),startTime:(null==R?void 0:R.startTime)||(null==n?void 0:n.startTime),initiatorType:(null==R?void 0:R.initiatorType)||(null==n?void 0:n.initiatorType)}),e)}},gn=function(n){return n&&"object"===(void 0===n?"undefined":S(n))&&"errors"in n&&Array.isArray(n.errors)&&n.errors.every((function(n){return n&&"object"===(void 0===n?"undefined":S(n))&&"message"in n}))},kn="awx_airtracker_api_performance_queue",xn="awx_airtracker_api_performance_plugin_loaded",En="undefined"!=typeof window?window:"undefined"!=typeof global?global:{};En[kn]=En[kn]||[];var In=function(n,e,t){setTimeout((function(){var r=bn(n,t);e.observerPipeline(r),En[kn]=En[kn].filter((function(e){return e.id!==n.id}))}),300)},Sn=function(n,e){setTimeout((function(){var t=En[kn].find((function(e){return e.id===n}));if(t){var r=bn(t,{exceptionType:"timeout-without-response"});e.observerPipeline(r),En[kn]=En[kn].filter((function(e){return e.id!==n}))}}),1e4)},Nn=new rn({name:"apiPerformancePlugin",setUp:function(){var n=h((function(n){var e,t;return C(this,(function(){return En[xn]||(null===(e=n.config)||void 0===e?void 0:e.enableRecordAPIPerformance)&&Math.random()<((null===(t=n.config)||void 0===t?void 0:t.enableRecordAPIPerformancePercentage)||0)&&(En[xn]=!0,function(n){var e;(function(n){var e=XMLHttpRequest.prototype.open,t=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(t,r,i,o,a){try{var s,u=hn();this.__requestId=u;var c=g(r,URL)?r.href:new URL(r,window.location.href).href;if(!yn(c,null===(s=n.config)||void 0===s?void 0:s.enableRecordAPIPerformanceWhitelist))return e.call(this,t,r,null==i||i,o,a);var l={id:u,startTime:performance.now(),method:t,url:c,entries:[],initiatorType:"xmlhttprequest"};return En[kn].push(l),Sn(u,n),e.call(this,t,r,null==i||i,o,a)}catch(s){return n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Inject XHR open error",error:s}}),e.call(this,t,r,null==i||i,o,a)}},XMLHttpRequest.prototype.send=function(){for(var e=this,r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];try{var a=En[kn].find((function(n){return n.id===e.__requestId}));if(!a)return t.apply(this,i);var s=this;return this.addEventListener("loadend",h((function(){var e,t,r,i,o,u,c;return C(this,(function(l){switch(l.label){case 0:if(e=performance.now(),t=e-a.startTime,0===(r=s.status))return[2];a.endTime=e,a.duration=t,a.responseStatus=r,l.label=1;case 1:return l.trys.push([1,6,,7]),""!==s.responseType&&"text"!==s.responseType?[3,2]:(i=s.responseText,[3,5]);case 2:return"json"!==s.responseType?[3,3]:(i=s.response,[3,5]);case 3:return"blob"!==s.responseType||"application/json"!==(null==(o=s.response)?void 0:o.type)?[3,5]:[4,o.text()];case 4:i=l.sent(),l.label=5;case 5:return(u=i&&"string"==typeof i?JSON.parse(i):i)&&gn(u)&&(a.errorType="graphqlError",a.errorDetail=u.errors),[3,7];case 6:return c=l.sent(),n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Parse response body error in XHR",url:null==a?void 0:a.url,error:c}}),[3,7];case 7:return In(a,n),[2]}}))}))),this.addEventListener("error",(function(){In(a,n,{exceptionType:"network-error"})})),this.addEventListener("abort",(function(){In(a,n,{exceptionType:"abort-error"})})),this.addEventListener("timeout",(function(){In(a,n,{exceptionType:"timeout-error"})})),t.apply(this,i)}catch(e){throw n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"InjectXHR send error",error:e}}),e}}})(n),function(n){var e=window.fetch;window.fetch=h((function(){var t,r,i,o,a,s,u,c,l,d,f,v,m,p,h,y,w=arguments;return C(this,(function(b){switch(b.label){case 0:for(t=w.length,r=new Array(t),i=0;i<t;i++)r[i]=w[i];return s=new URL(g(r[0],Request)?r[0].url:String(r[0]),window.location.href).href,yn(s,null===(o=n.config)||void 0===o?void 0:o.enableRecordAPIPerformanceWhitelist)?[3,2]:[4,e.apply(this,r)];case 1:return[2,b.sent()];case 2:return b.trys.push([2,9,,10]),c=performance.now(),l=hn(),a={id:l,startTime:c,method:(null===(u=g(r[0],Request)?r[0]:r[1])||void 0===u?void 0:u.method)||"GET",url:s,entries:[],initiatorType:"fetch"},En[kn].push(a),Sn(l,n),[4,e.apply(this,r)];case 3:d=b.sent(),f=performance.now(),a.endTime=f,a.duration=f-c,a.responseStatus=d.status,v=d.clone(),b.label=4;case 4:return b.trys.push([4,7,,8]),v.ok?[4,v.json()]:[3,6];case 5:(m=b.sent())&&gn(m)&&(a.errorType="graphqlError",a.errorDetail=m.errors),b.label=6;case 6:return[3,8];case 7:return p=b.sent(),n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Parse response body error in fetch",url:null==a?void 0:a.url,error:p}}),[3,8];case 8:return In(a,n),[2,d];case 9:throw h=b.sent(),a&&a.id&&En[kn].find((function(n){return n.id===(null==a?void 0:a.id)}))?(y="fetch-error",g(h,TypeError)?y="network-error":g(h,DOMException)&&"AbortError"===h.name&&(y="abort-error"),In(a,n,{exceptionType:y})):n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Inject fetch error",error:h}}),h;case 10:return[2]}}))}))}(n),(null===(e=window)||void 0===e?void 0:e.PerformanceObserver)?new window.PerformanceObserver((function(n){n.getEntries().forEach((function(n){var e=n;"fetch"!==e.initiatorType&&"xmlhttprequest"!==e.initiatorType||En[kn].filter((function(n){return n.url===e.name})).forEach((function(n){n.entries.push(e)}))}))})).observe({entryTypes:["resource"],buffered:!0}):n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{error:"PerformanceObserver Not Supported"}})}(n)),[2]}))}));return function(e){return n.apply(this,arguments)}}()}),Cn=function(){function n(e){var t,r,i=this,o=e.config,a=e.plugins,s=void 0===a?[]:a;y(this,n),this.config=_,this.lifeCycle=new tn,this.plugins=[],this._commonData=L,this._MFECommonDataMap={},this.timeMap={},this.packedDataConvert=function(n){var e,t,r=n.extraInfo,o=k({severity:n.severity,eventName:n.eventName,currentHref:i.config.hideSearchParams?((null===(e=location)||void 0===e?void 0:e.href)||"").split("?")[0]||"":(null===(t=location)||void 0===t?void 0:t.href)||""},r);return i.config.isWebappContainer&&(o.MFEName=z(i)),o},this.normalPipelineObj=en([Z(this,8),(t=this,r={},function(n,e){var i="number"==typeof t.config.errorRepeatTime?t.config.errorRepeatTime:5;if(0===i)return null==e?void 0:e(n);null==e||e(n.filter((function(n){return"autoDetectError"!=n.severity||(r[n.error]=r[n.error]||0,r[n.error]+=1,!(r[n.error]>i))})))}),Q(this)]),this.observerPipelineObj=en([Z(this,8),Y(this)]),this.immediateSendPipe=Q(this),this.observerPipeline=function(n){var e=i.packedDataConvert({severity:n.severity,eventName:n.eventName,extraInfo:n.extraInfo});return i.observerPipelineObj(e)},this.normalLogPipeLine=function(n){var e=i.packedDataConvert({severity:n.severity,eventName:n.eventName,extraInfo:n.extraInfo});return i.config.disableThrottle?i.immediateSendPipe(e):i.normalPipelineObj(e)},this.ImmediatePipeline=function(n){var e=i.packedDataConvert({severity:n.severity,eventName:n.eventName,extraInfo:n.extraInfo});return i.immediateSendPipe(e)},this.plugins=I(s),this.setConfig(o),this.initCommonData(o),this.lifeCycle.emit("onInit"),o.enableErrorMonitoring&&this.plugins.push(un),((null==o?void 0:o.assetSpeedMonitoringWhiteList)&&o.assetSpeedMonitoringWhiteList.length>0||o.isWebappContainer)&&this.plugins.push(vn),(null==o?void 0:o.enableDetectPageChange)&&this.plugins.push(mn),(null==o?void 0:o.enableRecordPageRetention)&&this.plugins.push(pn),(null==o?void 0:o.enableRecordAPIPerformance)&&(null==o?void 0:o.enableRecordAPIPerformancePercentage)&&o.enableRecordAPIPerformancePercentage>0&&o.enableRecordAPIPerformancePercentage<=1&&this.plugins.push(Nn),this.installPlugins()}return w(n,[{key:"installPlugins",value:function(){var n=this;this.plugins.forEach((function(e){e.patch(n)}))}},{key:"commonData",get:function(){return this._commonData}},{key:"MFECommonDataMap",get:function(){return this._MFECommonDataMap}},{key:"initCommonData",value:function(n){this._commonData.sessionId=n.useSessionStorageForSessionId?function(){try{var n=window.sessionStorage.getItem(q);return n||(n=B(),window.sessionStorage.setItem(q,n)),n}catch(n){return B()}}():B(),this._commonData.deviceId=function(){try{var n=window.localStorage.getItem(H);return n||(n=B(),window.localStorage.setItem(H,n)),n}catch(n){}}()||A,this._commonData.riskDeviceId=function(){try{return window.localStorage.getItem("AWX_RISK_ID")||void 0}catch(n){}}(),this._commonData.networkType=function(){var n,e,t="",r=navigator.userAgent.match(/NetType\/(\w+)/);if(r)t=E(r,2)[1];else if(null===(n=navigator)||void 0===n?void 0:n.connection){var i,o,a,s;t=(null===(o=navigator)||void 0===o||null===(i=o.connection)||void 0===i?void 0:i.effectiveType)||(null===(s=navigator)||void 0===s||null===(a=s.connection)||void 0===a?void 0:a.type)}return t||(t="unknown"),e=t,(e=String(e).toLowerCase()).indexOf("4g")>=0?"net4g":e.indexOf("wifi")>=0?"wifi":e.indexOf("5g")>=0?"net5g":e.indexOf("3g")>=0?"net3g":e.indexOf("2g")>=0?"net2g":"unknown"}()||"unknown",this._commonData.env=n.env||this._commonData.env,this._commonData.accountId=n.accountId||A,this._commonData.appVersion=n.appVersion,this._commonData.appName=n.appName,this._commonData.sdkVersion="3.1.0",this.lifeCycle.emit("onCommonDataInit",this.commonData)}},{key:"updateCommonDataBasedOnConfig",value:function(n){this.lifeCycle.emit(K,this._commonData),this._commonData.env=n.env||this._commonData.env,this._commonData.appName=n.appName||this._commonData.appName,this._commonData.env=n.env||this._commonData.env,this._commonData.accountId=n.accountId||this._commonData.accountId,this._commonData.appVersion=n.appVersion||this._commonData.appVersion}},{key:"updateCommonData",value:function(n){this.lifeCycle.emit(K,this._commonData),this._commonData=k({},this._commonData,n)}},{key:"removeCommonDataByKey",value:function(n){var e=this;this.lifeCycle.emit(K,this._commonData),setTimeout((function(){n.forEach((function(n){delete e._commonData[n]}))}),1e3)}},{key:"addToMFECommonData",value:function(n){var e,t=n.MFEName,r=n.MFECommonData;this.config.isWebappContainer&&t&&r&&(this._MFECommonDataMap=x(k({},this._MFECommonDataMap||{}),b({},t,k({},(null===(e=this._MFECommonDataMap)||void 0===e?void 0:e[t])||{},r))))}},{key:"setConfig",value:function(n){var e=this;this.config.isWebappContainer||(Object.entries(n).forEach((function(n){var t=E(n,2),r=t[0],i=t[1];void 0!==(void 0===i?"undefined":S(i))&&function(n,t){e.config[n]=t}(r,i)})),this.lifeCycle.emit("onConfigInit",this.config),this.updateCommonDataBasedOnConfig(n))}},{key:"verbose",value:function(n,e){this.normalLogPipeLine({severity:"verbose",eventName:n,extraInfo:e})}},{key:"httpLog",value:function(n,e){this.normalLogPipeLine({severity:"http",eventName:n,extraInfo:e})}},{key:"info",value:function(n,e){this.normalLogPipeLine({severity:"info",eventName:n,extraInfo:e})}},{key:"warn",value:function(n,e){this.normalLogPipeLine({severity:"warn",eventName:n,extraInfo:e})}},{key:"error",value:function(n,e){console.error("error",n),this.normalLogPipeLine({severity:"error",eventName:n,extraInfo:e})}},{key:"businessLog",value:function(n,e){this.normalLogPipeLine({severity:"info",eventName:n,extraInfo:x(k({},e),{isBusinessLog:!0})})}},{key:"reportDuration",value:function(n,e,t){"string"==typeof n?"number"==typeof e?e<0||e>6e4?console.warn("reportDuration: duration (second param) must between 0 and 60000"):this.normalLogPipeLine({severity:"speed",eventName:n,extraInfo:k({duration:e},t)}):console.warn("reportDuration: duration (second param) must be number"):console.warn("reportDuration: eventName (first param) must be a string")}},{key:"getTimerKey",value:function(n){var e=z(this);return this.config.isWebappContainer?"".concat(e,"_").concat(n):n}},{key:"timeStart",value:function(n){"string"==typeof n?(this.timeMap[this.getTimerKey(n)]&&console.warn("Timer ".concat(n," already exists")),this.timeMap[this.getTimerKey(n)]=Date.now()):console.warn("time: first param must be a string")}},{key:"timeEnd",value:function(n,e){if("string"==typeof n)if(this.timeMap[this.getTimerKey(n)]){var t=Date.now()-this.timeMap[this.getTimerKey(n)]+(e||0);this.normalLogPipeLine({severity:"speed",eventName:n,extraInfo:{duration:t}}),delete this.timeMap[this.getTimerKey(n)]}else console.warn("Timer key :".concat(n," does not exist"));else console.warn("timeEnd: first param must be a string")}},{key:"addToAssetSpeedWhiteListByMFE",value:function(n){var e,t,r,i,o=n.MFEName,a=n.whiteList;this.config.isWebappContainer&&o&&(null==a?void 0:a.length)&&(this.config.assetSpeedMonitoringWhiteListByMFE||(this.config.assetSpeedMonitoringWhiteListByMFE={}),(null===(e=this.config.assetSpeedMonitoringWhiteListByMFE)||void 0===e?void 0:e[o])?null===(i=this.config.assetSpeedMonitoringWhiteListByMFE)||void 0===i||null===(r=i[o])||void 0===r||(t=r).push.apply(t,I(a)):this.config.assetSpeedMonitoringWhiteListByMFE=x(k({},this.config.assetSpeedMonitoringWhiteListByMFE),b({},o,a)))}},{key:"destroy",value:function(){this.config.isWebappContainer||this.plugins.forEach((function(n){n.uninstall()}))}}]),n}(),Tn=Cn,Dn=function(n,e){return Dn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,e){n.__proto__=e}||function(n,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t])},Dn(n,e)};function Pn(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=n}Dn(n,e),n.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t)}var Rn=function(){return Rn=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},Rn.apply(this,arguments)};function On(n,e,t,r){return new(t||(t=Promise))((function(e,i){function o(n){try{s(r.next(n))}catch(n){i(n)}}function a(n){try{s(r.throw(n))}catch(n){i(n)}}function s(n){var r;n.done?e(n.value):(r=n.value,r instanceof t?r:new t((function(n){n(r)}))).then(o,a)}s((r=r.apply(n,[])).next())}))}function jn(n,e){var t,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(t=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(n,a)}catch(n){s=[6,n],r=0}finally{t=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function An(n,e){for(var t,r=0,i=e.length;r<i;r++)!t&&r in e||(t||(t=Array.prototype.slice.call(e,0,r)),t[r]=e[r]);return n.concat(t||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var _n,Ln,Un,Mn={dev:j.staging,staging:j.staging,demo:j.demo,prod:j.production},Fn=function(n){if("object"!=typeof n)return n;try{var e=JSON.parse(JSON.stringify(n));return Object.keys(e).forEach((function(n){"string"==typeof n&&["auth","code"].some((function(e){return n.includes(e)}))&&(e[n]="***")})),e}catch(e){return n}},Kn=function(n,e){var t,r;null===(r=null===(t=window._AirwallexSDKs)||void 0===t?void 0:t.airTracker)||void 0===r||r.error(n,Rn(Rn({},e),{context:"components-sdk"}))},Hn=function(n,e){var t;null===(t=window._AirwallexSDKs.airTracker)||void 0===t||t.info(n,Rn(Rn({},e),{context:"components-sdk"}))},qn=function(n){function e(e){var t=n.call(this,e)||this;return t.code="LOAD_SCRIPT_ERROR",t}return Pn(e,n),e}(Error);!function(n){n.dev="dev",n.staging="staging",n.demo="demo",n.prod="prod",n.sandbox="sandbox"}(Un||(Un={}));var Bn,zn=((_n={})[Un.dev]="https://checkout-staging.airwallex.com",_n[Un.staging]="https://checkout-staging.airwallex.com",_n[Un.demo]="https://checkout-demo.airwallex.com",_n[Un.prod]="https://checkout.airwallex.com",_n[Un.sandbox]="https://checkout.sandbox.airwallex.com",_n),Wn=((Ln={})[Un.dev]="https://static-staging.airwallex.com",Ln[Un.staging]="https://static-staging.airwallex.com",Ln[Un.demo]="https://static-demo.airwallex.com",Ln[Un.prod]="https://static.airwallex.com",Ln[Un.sandbox]="https://static.sandbox.airwallex.com",Ln),Xn="sdkController",Vn="payments",Gn={kyc:"/widgets/kyc/sdk/v1/index.js",rfi:"/widgets/kycRfi/sdk/v1/index.js",paymentsKyb:"/widgets/paymentsKyb/sdk/v1/index.js",sdkController:"/widgets/sdk-controller/sdk/v1/index.js",payouts:"/widgets/payouts/sdk/v1/index.js",payments:"/assets/elements.bundle.min.js",sca:"/hosted-sca/sdk/v1/index.js",taxForm:"/widgets/taxForm/sdk/v1/index.js",billing:"/widgets/checkout/sdk/v1/index.js",balance:"/widgets/embedded-balance/sdk/v1/index.js"},Jn={kyc:"kyc",paymentsKyb:"paymentsKyb",kycRfi:"rfi",transactionRfi:"rfi",paymentEnablementRfi:"rfi",lendingRfi:"rfi",mrmRfi:"rfi",payoutForm:"payouts",beneficiaryForm:"payouts",hpp:"payments",cvc:"payments",card:"payments",expiry:"payments",dropIn:"payments",cardNumber:"payments",applePayButton:"payments",googlePayButton:"payments",krCardNumber:"payments",krCardIdentifier:"payments",krCardExpiry:"payments",krCardPswFirstTwo:"payments",scaSetup:"sca",scaVerify:"sca",scaManagement:"sca",taxForm:"taxForm",embeddedCheckout:"billing",balanceOverview:"balance",balanceDetail:"balance",balanceActivities:"balance",balanceActivityDetails:"balance",balanceHistoryChart:"balance",balanceInfo:"balance",balanceScheduledTransactions:"balance",balanceList:"balance"},$n={payments:["hpp","cvc","card","expiry","dropIn","cardNumber","applePayButton","googlePayButton","krCardNumber","krCardIdentifier","krCardExpiry","krCardPswFirstTwo"],payouts:["payoutForm","beneficiaryForm"],onboarding:["kyc","paymentsKyb"],risk:["scaSetup","scaVerify","scaManagement","transactionRfi","kycRfi","paymentEnablementRfi","lendingRfi","mrmRfi"],billing:["embeddedCheckout"],balance:["balanceOverview","balanceDetail","balanceActivities","balanceHistoryChart","balanceInfo","balanceScheduledTransactions","balanceList","balanceActivityDetails"]},Qn={billing:["payments"]},Yn=["payments","sca","billing"],Zn=function(n){function e(e){var t=n.call(this,e)||this;return t.code="INVALID_STATIC_RESOURCE_ERROR",t}return Pn(e,n),e}(Error),ne=Date.now(),ee=function(n){return Jn[n]},te=function(n){var e=n.reduce((function(n,e){return n.concat((t=e,Object.keys($n).includes(t)?$n[e]:e));var t}),[]);return Array.from(new Set(e)).map((function(n){return{elementName:n,sdkName:ee(n)}}))},re=function(n){return"payments"===n?"payment":n},ie=function(n){var e=n.name,t=n.env,r=function(n,e){var t=n===Vn?zn:Wn;return t[e]||t.prod}(e,void 0===t?Un.prod:t),i=Gn[e];if(!i)throw Kn("[components-sdk] Element static resource not found",{sdkName:e}),new Zn("Element ".concat(e," static resource URL is invalid."));return"".concat(r).concat(i,"?ts=").concat(ne)},oe=function(){return Math.floor(performance.now())},ae=function(n){function e(e){var t=n.call(this,e)||this;return t.code="INSTANCE_NOT_FOUND_ERROR",t}return Pn(e,n),e}(Error),se=new Map,ue=function(n){var e=n.scriptName,t=ie({name:e,env:n.env}),r=se.get(e);if(r)return r;var i=function(n){return On(void 0,0,void 0,(function(){var e,t;return jn(this,(function(r){switch(r.label){case 0:if("undefined"==typeof window)throw new Error("Please load script in browser environment");e=0,t=function(){return On(void 0,0,void 0,(function(){var t,r,i;return jn(this,(function(){return t=oe(),e>0&&n.includes("?ts=")&&((r=new URL(n,window.location.href)).searchParams.set("ts","".concat(Date.now())),n=r.toString()),i=function(n){var e=document.createElement("script");return e.src=n,e.type="module",(document.head||document.body).appendChild(e),e}(n),[2,new Promise((function(r,o){i.addEventListener("load",(function(){var i=oe();Hn("[components-sdk] SDK script loaded",{scriptUrl:n,start:t,latency:i-t,end:i,retryCount:e}),r(!0)})),i.addEventListener("error",(function(r){i.remove(),console.error(r);var a=oe();Kn("[components-sdk] Failed to load script",{scriptUrl:n,error:r,start:t,latency:a-t,end:a,retryCount:e}),o(new qn("Failed to load Airwallex SDK scripts: ".concat(n)))}))}))]}))}))},r.label=1;case 1:if(!(e<3))return[3,7];r.label=2;case 2:return r.trys.push([2,4,,6]),[4,t()];case 3:return[2,r.sent()];case 4:return r.sent(),e++,[4,(void 0===i&&(i=500),new Promise((function(n){return window.setTimeout(n,i)})))];case 5:return r.sent(),[3,6];case 6:return[3,1];case 7:throw Kn("[components-sdk] Failed to load script after retry",{scriptUrl:n,retryCount:e}),new qn("Failed to load Airwallex SDK scripts: ".concat(n))}var i}))}))}(t);return se.set(e,i),i},ce=function(n){var e=n.env,t=n.scriptName;return On(void 0,0,void 0,(function(){var n;return jn(this,(function(r){switch(r.label){case 0:return(n=Qn[t]||[]).length>0?[4,Promise.all(n.map((function(n){return ue({env:e,scriptName:n})})))]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2,ue({env:e,scriptName:t})]}}))}))},le=function(n){return On(void 0,0,void 0,(function(){return jn(this,(function(){if("undefined"==typeof window)throw new Error("Please call the `init()` function in a browser environment.");var e,t;return t=n.clientId,void 0===(e=n.env)&&(e=j.production),window._AirwallexSDKs.airTracker||(window._AirwallexSDKs.airTracker=new Tn({config:{appName:"components-sdk",appVersion:"1.35.1",env:Mn[e]||j.production}}),window._AirwallexSDKs.airTracker.updateCommonData({clientId:t})),window,Hn("[components-sdk] SDK init start",{options:Fn(n),start:oe()}),Bn=new Promise((function(e,t){var r,i=Rn(Rn({},n),{env:n.env&&Un[n.env]?n.env:Un.prod});window.AirwallexComponentsSDK.__env__=i.env;var o=ue({env:i.env,scriptName:Xn}).then((function(){return window._AirwallexSDKs.__controller__.init(i)})),a=null!==(r=n.enabledElements)&&void 0!==r?r:[],s=function(n){return Array.from(new Set(te(n).map((function(n){return n.sdkName})).filter((function(n){return Yn.includes(n)}))))}(a),u=s.map((function(n){return ce({env:i.env,scriptName:n}).then((function(){return o})).then((function(){var e=window._AirwallexSDKs[re(n)];if(!e)throw Kn("[components-sdk] SDK instance not found",{functionsNamespace:n,windowSDKInstanceName:re(n)}),new ae("SDK instance not found");return window._AirwallexSDKs.__controller__.registerFunctions({functionsNamespace:n,instance:e})}))})),c=te(a).map((function(n){var e=n.sdkName,t=n.elementName;return ce({scriptName:e,env:i.env}).then((function(){return o})).then((function(){var n=window._AirwallexSDKs[re(e)];if(!n)throw Kn("[components-sdk] SDK instance not found",{sdkName:e,windowSDKInstanceName:re(e)}),new ae("SDK instance not found");return window._AirwallexSDKs.__controller__.registerElement({sdkName:e,elementName:t,instance:n})}))}));Promise.all(An(An([o],u),c)).then((function(){Hn("[components-sdk] SDK initialized",{options:Fn(n),start:oe()}),e(Yn.reduce((function(n,e){var t;return Rn(Rn({},n),((t={})[e]=window._AirwallexSDKs.__controller__.internalSDKs[e],t))}),{}))})).catch((function(n){n.code||Kn("[components-sdk] Unexpected errors when init",{error:n}),t(n)}))})),[2,Bn]}))}))},de=function(n,e){return On(void 0,0,void 0,(function(){var t,r,i,o,a;return jn(this,(function(s){switch(s.label){case 0:if(!n)throw new Error("Element type is missing. Please specify a valid element.");if(Hn("[components-sdk] SDK createElement start",{elementName:n,options:Fn(e),timestamp:oe()}),!Bn)throw function(){var n;null===(n=window._AirwallexSDKs.airTracker)||void 0===n||n.warn("[components-sdk] Did not call init before createElement",Rn(Rn({},void 0),{context:"components-sdk"}))}(),new Error("Please initialize the Element before creating it.");return[4,Bn];case 1:if(s.sent(),!(t=ee(n)))throw new Error("`createElement()` with type `".concat(n,"` is not supported. Please specify a valid Element type."));r=oe(),s.label=2;case 2:return s.trys.push([2,6,,7]),[4,ce({scriptName:t,env:window.AirwallexComponentsSDK.__env__||Un.prod})];case 3:return s.sent(),[4,window._AirwallexSDKs.__controller__.registerElement({sdkName:t,elementName:n,instance:window._AirwallexSDKs[re(t)]})];case 4:return s.sent(),[4,window._AirwallexSDKs.__controller__.createElement(n,e)];case 5:return i=s.sent(),o=oe(),Hn("[components-sdk] SDK createElement being called",{elementName:n,options:Fn(e),start:r,latency:o-r,end:o}),[3,7];case 6:if((a=s.sent()).code)throw a;return Kn("[components-sdk] Unexpected errors when createElement",{error:a}),[3,7];case 7:return[2,i]}}))}))},fe=[Xn,Vn],ve=function(){fe.forEach((function(n){var e=ie({name:n,env:Un.prod}),t=document.createElement("link");t.href=e,t.rel="modulepreload",t.as="script",(document.head||document.body).appendChild(t)}))};"undefined"==typeof document||"undefined"==typeof window||("loading"===document.readyState?document.addEventListener("DOMContentLoaded",ve):ve()),"undefined"!=typeof window&&(window.AirwallexComponentsSDK||Object.defineProperties(window,{AirwallexComponentsSDK:{value:{},writable:!1},_AirwallexSDKs:{value:{},writable:!1}}),window.AirwallexComponentsSDK.init=le,window.AirwallexComponentsSDK.createElement=de);const{onChange:me,reset:pe,state:he}=n((()=>({clientSecret:null,currency:null,hasPaymentError:!1,isReady:!1,paymentConfirmed:!1,paymentIntentId:null}))),ye=n=>"AIRWALLEX"===n.paymentProcessor&&(n.clientSecret&&(he.clientSecret=n.clientSecret),n.paymentIntentId&&(he.paymentIntentId=n.paymentIntentId),!!he.clientSecret||(o("Airwallex checkout session is missing the client secret"),!1)),we={ar:"ar",da:"da",de:"de",en:"en",es:"es",fr:"fr",id:"id",it:"it",ja:"ja",ko:"ko",nl:"nl",pl:"pl",pt:"pt",ru:"ru",sv:"sv",zh:"zh"},be=n=>we[n]||"en";let ge=null;const ke=async()=>!!he.isReady||(ge||(ge=le({enabledElements:["payments"],env:e.zonosMode&&"production"!==e.zonosMode||"LIVE"!==e.checkoutSettings.mode?"demo":"prod",locale:be(r.selectedLocale)}).then((()=>(he.isReady=!0,u("Airwallex SDK initialized"),!0))).catch((n=>(o(n),ge=null,!1)))),ge),xe=["SUCCEEDED","REQUIRES_CAPTURE","PENDING_REVIEW","PENDING"],Ee=n=>!!n&&xe.includes(n),Ie=n=>{switch(n){case"SUCCEEDED":return{isError:!1,messages:[t("Thank you for submitting your payment. We appreciate your prompt attention."),"",t("A confirmation email with your payment details has been sent for your records. If you have any questions or need support, our team is here to help.")]};case"PENDING":case"PENDING_REVIEW":case"REQUIRES_CAPTURE":return{isError:!1,messages:[t("Payment processing. We'll update you when payment is received.")]};case"REQUIRES_CUSTOMER_ACTION":return{isError:!1,messages:[t("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]};case"CANCELLED":case"REQUIRES_PAYMENT_METHOD":return{isError:!0,messages:[t("Payment failed. Please reload the page and try another payment method.")]};default:return{isError:!0,messages:[t("Something went wrong.")]}}},Se=async n=>{const{errors:e,json:t}=await a("/api/zonos-elements/collect/airwallex-payment-intent",{body:{paymentIntentId:n},method:"POST"});return e.length||!t?(o("Failed to retrieve Airwallex payment intent",e),{status:null}):{status:t.airwallexPaymentIntent.status}},{state:Ne}=n((()=>({amountDutyTaxFeeTotal:null,amountTotalPaid:null,collectLogoUrl:null,isFetchingShippingInfo:!0,landedCostShortId:null,originCompanyName:null,partyBillingId:null,paymentProcessor:null,shippingAddress:null}))),Ce=async({landedCostId:n,retries:t=5})=>{var r,i,o,u,c,d,f,v,m,p;Ne.isFetchingShippingInfo=!0;const h=await a("/api/zonos-elements/collect/get-shipping-info-by-lc-id",{body:{landedCostId:n},method:"POST"});if(h.errors.length)return t>0?(await new Promise((n=>setTimeout(n,1e3))),Ce({landedCostId:n,retries:t-1})):null;Ne.landedCostShortId=(null===(r=h.json)||void 0===r?void 0:r.landedCostShortId)||null,Ne.isFetchingShippingInfo=!1,Ne.shippingAddress=(null===(i=h.json)||void 0===i?void 0:i.shipping)||null;const y=null===(o=l.checkoutSession)||void 0===o?void 0:o.landedCost,w=null===(u=l.checkoutSession)||void 0===u?void 0:u.subtotals,b=((null===(c=null==y?void 0:y.amountSubtotals)||void 0===c?void 0:c.shipping)||0)+((null===(d=null==y?void 0:y.amountSubtotals)||void 0===d?void 0:d.items)||0);Ne.amountTotalPaid=b*((null===(f=null==w?void 0:w.exchangeRate)||void 0===f?void 0:f.rate)||1),Ne.amountDutyTaxFeeTotal=((null==w?void 0:w.duties)||0)+((null==w?void 0:w.taxes)||0)+((null==w?void 0:w.fees)||0),Ne.originCompanyName=(null===(m=null===(v=h.json)||void 0===v?void 0:v.origin)||void 0===m?void 0:m.companyName)||null,Ne.collectLogoUrl=(null===(p=h.json)||void 0===p?void 0:p.collectLogoUrl)||null,0===Ne.amountTotalPaid&&s({endpoint:"COLLECT_NO_TOTAL_PAID",errors:[],metadata:{landedCostId:n,organizationId:e.organizationId}})},Te=async()=>{var n,e,t,r;if(!(null===(n=f.stripeBillingAddressEventData)||void 0===n?void 0:n.complete))return{partiesCreated:!1};const u=null===(t=null===(e=l.checkoutSession)||void 0===e?void 0:e.landedCost)||void 0===t?void 0:t.rootId;if(!u)return s({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:i.checkoutSessionId}}),{partiesCreated:!1};if(!i.checkoutSessionId)return s({endpoint:"COLLECT_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:c,cartId:window.Zonos.cartId,landedCostRootId:u}}),{partiesCreated:!1};const d=v({address:f.stripeBillingAddressEventData.value.address,firstName:f.stripeBillingAddressEventData.value.firstName,lastName:f.stripeBillingAddressEventData.value.lastName,name:f.stripeBillingAddressEventData.value.name,phone:f.stripeBillingAddressEventData.value.phone}),m="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:p,json:h}=await a("/api/zonos-elements/create-billing-party",{body:{billingAddress:d,checkoutSessionId:i.checkoutSessionId,companyName:f.companyName,email:(null===(r=f.stripeLinkEventData)||void 0===r?void 0:r.value.email)||"",isTest:m,rootId:u},method:"POST"});return p.length||!h?(o("Error occurs when creating billing party",JSON.stringify(p,null,2)),s({endpoint:"COLLECT_BILLING_PARTY_CREATE_FAILED",errors:["[COLLECT] Failed to create billing party"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:i.checkoutSessionId,errors:p,json:h}}),{partiesCreated:!1}):(Ne.partyBillingId=h.billToPartyId,{partiesCreated:!0})},De=async n=>{const e=n.landedCost;return!!e&&(l.landedCostData=[Object.assign(Object.assign({},n),{landedCost:Object.assign({},e),landedCostId:e.id})],d({applySubtotalsOnly:!0,landedCostId:e.id,selectedShippingOption:e.shipmentRating}))};export{ye as a,he as b,Ne as c,Se as d,Ee as e,ke as f,De as g,Ce as h,Te as i,Ie as j,pe as k,de as l,be as m,me as n}
1
+ import{c as n,z as e}from"./p-CqB9AfBf.js";import{t,l as r,s as i}from"./p-CVRbGFV3.js";import{l as o,h as a,s}from"./p-gEViRqvf.js";import{l as u,b as c}from"./p-BJmZPrZl.js";import{d as l,Z as d,b as f,a1 as v}from"./p-BJ_kE5rM.js";function m(n,e){(null==e||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function p(n,e,t,r,i,o,a){try{var s=n[o](a),u=s.value}catch(n){return void t(n)}s.done?e(u):Promise.resolve(u).then(r,i)}function h(n){return function(){var e=this,t=arguments;return new Promise((function(r,i){var o=n.apply(e,t);function a(n){p(o,r,i,a,s,"next",n)}function s(n){p(o,r,i,a,s,"throw",n)}a(void 0)}))}}function y(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function w(n,e){return e&&function(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}(n.prototype,e),n}function b(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function g(n,e){return null!=e&&"undefined"!=typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](n):n instanceof e}function k(n){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{},r=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})))),r.forEach((function(e){b(n,e,t[e])}))}return n}function x(n,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):function(n){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);e.push.apply(e,t)}return e}(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))})),n}function E(n,e){return function(n){if(Array.isArray(n))return n}(n)||function(n,e){var t=null==n?null:"undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(null!=t){var r,i,o=[],a=!0,s=!1;try{for(t=t.call(n);!(a=(r=t.next()).done)&&(o.push(r.value),o.length!==e);a=!0);}catch(n){s=!0,i=n}finally{try{a||null==t.return||t.return()}finally{if(s)throw i}}return o}}(n,e)||N(n,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function I(n){return function(n){if(Array.isArray(n))return m(n)}(n)||function(n){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}(n)||N(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(n){return n&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n}function N(n,e){if(n){if("string"==typeof n)return m(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);return"Object"===t&&n.constructor&&(t=n.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?m(n,e):void 0}}function C(n,e){var t,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(n,a)}catch(n){o=[6,n],r=0}finally{t=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var T,D,R,P,O,j=function(n){return n.production="prod",n.demo="demo",n.staging="staging",n}(j||{}),A="airTracker_unknown",_={appName:A,appVersion:A,env:"staging",isWebappContainer:!1,delay:2e3,errorRepeatTime:3,enableErrorMonitoring:!1,assetSpeedMonitoringWhiteList:[],enableDetectPageChange:!1,enableRecordPageRetention:!1,hideSearchParams:!1,useSessionStorageForSessionId:!1,assetSpeedMonitoringWhiteListByMFE:{}},L={appName:A,env:"staging",sessionId:A,deviceId:A},U=function(){var n=new WeakSet;return function(e,t){if(g(t,Error))return"Error.message: ".concat(t.message," \n Error.stack: ").concat(t.stack);if("object"===(void 0===t?"undefined":S(t))&&null!==t){if(n.has(t))return"[Circular ".concat(e||"root","]");n.add(t)}return"function"==typeof t?"function":"symbol"===(void 0===t?"undefined":S(t))?"symbol":void 0===t?null:t}},M=function(n){if("string"==typeof n)return n;try{return g(n,Error)?(JSON.stringify(n,U())||"undefined").replace(/"/gim,""):JSON.stringify(n,U())}catch(n){return'{"error":"error happen when airTracker stringify"}'}},F=function(n){var e=n.method,t=void 0===e?"post":e,r=n.url,i=n.data,o=n.success,a=n.fail;if((s=i)&&!/^\s*$/.test(s)&&(s=(s=(s=s.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@")).replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]")).replace(/(?:^|:|,)(?:\s*\[)+/g,""),/^[\],:{}\s]*$/.test(s))){var s,u=new XMLHttpRequest;u.addEventListener("readystatechange",(function(){4===u.readyState&&(u.status>=400||0===u.status?null==a||a(u.response):null==o||o(u.response))})),u.open(t,r),u.setRequestHeader("Content-Type","application/json"),u.send(i)}},K="onCommonUpdated",H="AIR_ANALYTICS_DEVICE_ID",q="AIR_ANALYTICS_SESSION_ID",B=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(n){var e=16*Math.random()|0;return("x"===n?e:3&e|8).toString(16)}))},z=function(n){var e,t,r;return n.config.getMFEName?n.config.getMFEName():(null===(r=location)||void 0===r||null===(t=r.pathname)||void 0===t||null===(e=t.split("/"))||void 0===e?void 0:e[2])||"unknown"},V=function(n){return"string"==typeof n?n.split("?")[1]||"":n},W=function(n){return"string"==typeof n&&n.startsWith("//")?"undefined"!=typeof location&&"https:"===location.protocol:/^https/.test(n)},X=function(n){return"number"==typeof n||"string"==typeof n?n:-1},G=function(n,e){var t,r=!1;if(!e.config.isWebappContainer)return J(n,e.config.assetSpeedMonitoringWhiteList);var i=z(e);return r||J(n,null===(t=e.config.assetSpeedMonitoringWhiteListByMFE)||void 0===t?void 0:t[i])},J=function(n,e){if(!(null==e?void 0:e.length))return!1;for(var t=0;t<e.length;t++){var r=e[t];if(g(r,RegExp)&&r.test(n))return!0;if("string"==typeof r&&n.includes(r))return!0}return!1},$=function(n,e){return Math.round(100*(n-e))/100},Q=function(n){return function(e){var t,r,i=z(n),o=n.config.isWebappContainer?k({},n.commonData||{},(null===(t=n.MFECommonDataMap)||void 0===t?void 0:t[i])||{}):n.commonData,a=Array.isArray(e)?e:[e];if(0!==a.length){var s,u=M({commonData:o,data:a}),c={method:"post",url:(s=n.commonData.env,"prod"==s?"https://o11y.airwallex.com/airtracker/logs":"demo"==s?"https://o11y-demo.airwallex.com/airtracker/logs":"https://o11y-staging.airwallex.com/airtracker/logs"),data:u};"function"==typeof(null===(r=navigator)||void 0===r?void 0:r.sendBeacon)&&navigator.sendBeacon(c.url,u)||F(c)}}},Y=function(n){return function(e){var t,r,i,o=z(n),a={commonData:n.config.isWebappContainer?k({},n.commonData||{},(null===(t=n.MFECommonDataMap)||void 0===t?void 0:t[o])||{}):n.commonData,data:Array.isArray(e)?e:[e]},s=M(a),u={method:"post",url:(i=n.commonData.env,"prod"==i?"https://o11y.airwallex.com/airtracker/metrics":"demo"==i?"https://o11y-demo.airwallex.com/airtracker/metrics":"https://o11y-staging.airwallex.com/airtracker/metrics"),data:s};"function"==typeof(null===(r=navigator)||void 0===r?void 0:r.sendBeacon)&&navigator.sendBeacon(u.url,s)||F(u)}},Z=function(n,e){var t,r=[],i=n.config;return window.addEventListener("beforeunload",(function(){r.length>0&&(n.immediateSendPipe(r.splice(0,r.length)),t&&clearTimeout(t))})),function(o,a){if(r.push(o),n.lifeCycle.on(K,(function(){r.length>0&&(null==a||a(r.splice(0,r.length)),n.lifeCycle.remove(K),t&&clearTimeout(t))})),r.length>=e)return null==a||a(r.splice(0,r.length)),void(t&&clearTimeout(t));t&&clearTimeout(t),t=setTimeout((function(){t=null,r.length>0&&(null==a||a(r.splice(0,r.length)),n.lifeCycle.remove(K))}),i.delay)}},nn=function(){},en=function(n){if(!n||!n.reduce||!n.length)throw new TypeError("createPipeline need at least one function param");return 1===n.length?function(e,t){n[0](e,t||nn)}:n.reduce((function(n,e){return function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:nn;return n(t,(function(n){return null==e?void 0:e(n,r)}))}}))},tn=function(){function n(){var e=this;y(this,n),this.emit=function(n,t){if(e){var r,i=e.eventsList[n];if(null==i?void 0:i.length){i=i.slice();for(var o=0;o<i.length;o++){r=i[o];try{var a=r.callback.apply(e,[t]);if(1===r.type&&e.remove(n,r.callback),!1===a)break}catch(n){throw n}}}return e}},this.eventsList={}}return w(n,[{key:"indexOf",value:function(n,e){for(var t=0;t<n.length;t++)if(n[t].callback===e)return t;return-1}},{key:"on",value:function(n,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(this){var r=this.eventsList[n];return r||(this.eventsList[n]=[],r=this.eventsList[n]),-1===this.indexOf(r,e)?(r.push({name:n,type:t||0,callback:e}),this):this}}},{key:"one",value:function(n,e){this.on(n,e,1)}},{key:"remove",value:function(n,e){if(this){var t=this.eventsList[n];if(!t)return null;if(!e){try{delete this.eventsList[n]}catch(n){}return null}if(t.length){var r=this.indexOf(t,e);t.splice(r,1)}return this}}},{key:"clear",value:function(){this.eventsList={}}}]),n}(),rn=function(){function n(e){y(this,n),this.name="",this.isInit=!1,this.name=e.name,this.option=e}return w(n,[{key:"patch",value:function(n){var e,t;this.isInit||(this.isInit=!0,null===(t=this.option)||void 0===t||null===(e=t.setUp)||void 0===e||e.call(this.option,n))}},{key:"uninstall",value:function(){var n,e;null===(e=this.option)||void 0===e||null===(n=e.destroy)||void 0===n||n.apply(this),this.isInit=!1}}]),n}(),on=function(n){var e="".concat(M(n.message)||""," @ (").concat(M(n.filename)||"",":").concat(n.lineno||0,":").concat(n.colno||0,")\n").concat(M(n.error||""));T.normalLogPipeLine({severity:"autoDetectError",eventName:"windowOnError",extraInfo:{error:e}})},an=function(n){var e=n&&M(n.reason);T.normalLogPipeLine({severity:"autoDetectError",eventName:"promiseError",extraInfo:{error:e}})},sn=function(n){var e=(null==n?void 0:n.target)||(null==n?void 0:n.srcElement);if(e){var t=(null==e?void 0:e.src)||(null==e?void 0:e.href),r=e.tagName,i="unknown";if("string"==typeof t&&r){if(window.location.href.indexOf(t)>-1)return;if(/\.js$/.test(t))i="script";else if(/\.css$/.test(t))i="css";else switch(r.toLowerCase()){case"script":i="script";break;case"link":i="css";break;case"img":i="image";break;case"audio":case"video":i="media";break;default:return}T.normalLogPipeLine({severity:"autoDetectError",eventName:"staticFileLoadError",extraInfo:{staticFileType:i,error:"".concat(r," load fail: ").concat(t)}})}}},un=new rn({name:"errorDetectionPlugin",setUp:function(n){T=n,window.addEventListener("error",on),window.addEventListener("unhandledrejection",an),window.document.addEventListener("error",sn,!0)},destroy:function(){window.removeEventListener("unhandledrejection",an),window.document.removeEventListener("error",sn,!0),window.removeEventListener("error",on)}}),cn=["img","css","script","link","audio","video","iframe"],ln="resource",dn=function(n){var e,t=n.name;return{url:(e=t,"string"==typeof e?(e.split("?")[0]||"").slice(0,200):e),method:"get",duration:Number(n.duration.toFixed(2)),type:"static",isHttps:W(t),urlQuery:V(t),domainLookup:X(n.domainLookupEnd-n.domainLookupStart),connectTime:X(n.connectEnd-n.connectStart)}},fn=function(n,e){for(var t=0,r=n.length;t<r;t++){var i=n[t];-1!==cn.indexOf(i.initiatorType)&&G(i.name,e)&&e.normalLogPipeLine({severity:"performance",eventName:"assets_speed",extraInfo:{log:dn(i)}})}},vn=new rn({name:"assetsSpeedPlugin",setUp:function(n){if(void 0!==window.performance&&"function"==typeof window.performance.clearResourceTimings&&"function"==typeof window.performance.getEntriesByType&&"function"==typeof window.performance.now){var e=0;window.performance.onresourcetimingbufferfull=function(){e=0,window.performance.clearResourceTimings()},"function"==typeof window.PerformanceObserver?(fn(window.performance.getEntriesByType(ln),n),(R=new window.PerformanceObserver((function(e){fn(e.getEntries(),n)}))).observe({entryTypes:[ln]})):D=setInterval((function(){var t=window.performance.getEntriesByType(ln),r=t.slice(e);e=t.length,fn(r,n)}),3e3)}},destroy:function(){null==R||R.disconnect(),D&&clearInterval(D)}}),mn=new rn({name:"onPageChangePlugin",setUp:function(){var n=h((function(n){var e,t,r,i;return C(this,(function(){return t=null===(e=location)||void 0===e?void 0:e.href,r=document.querySelector("body"),i=function(e){var t,r,i,o,a;n.normalLogPipeLine({severity:"autoDetectEvent",eventName:"onPageChange",extraInfo:{prevHref:e.prevHref,href:(null===(t=location)||void 0===t?void 0:t.href)||"",hostname:null===(r=location)||void 0===r?void 0:r.hostname,pathName:null===(i=location)||void 0===i?void 0:i.pathname,protocol:null===(o=location)||void 0===o?void 0:o.protocol,search:null===(a=location)||void 0===a?void 0:a.search}})},i({prevHref:""}),(P=new MutationObserver((function(){if(location.href!==t){var n=t;t=location.href,i({prevHref:n})}}))).observe(r||document,{subtree:!0,childList:!0}),[2]}))}));return function(e){return n.apply(this,arguments)}}(),destroy:function(){null==P||P.disconnect()}}),pn=new rn({name:"onPageRetentionPlugin",setUp:function(){var n=h((function(n){var e,t,r,i,o,a;return C(this,(function(){return void 0===document.visibilityState||(t=null===(e=location)||void 0===e?void 0:e.href,r=document.querySelector("body"),(o=function(){i=Date.now()})(),document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState?a({href:location.href,leftReason:"visibilityChange"}):"visible"===document.visibilityState&&o()})),window.addEventListener("beforeunload",(function(){a({href:location.href,sendImmediate:!0,leftReason:"pageClose"})})),a=function(e){var t=e.href,r=e.sendImmediate,o=e.leftReason;if(i){var a=Date.now()-i;if(0!==a){i=void 0;var s={severity:"autoDetectEvent",eventName:"onPageRetention",extraInfo:{href:t,duration:a,leftReason:o}};r?n.ImmediatePipeline(s):n.normalLogPipeLine(s)}}},(O=new MutationObserver((function(){if(location.href!==t){var n=t;t=location.href,a({href:n,leftReason:"nextPage"}),o()}}))).observe(r||document,{subtree:!0,childList:!0})),[2]}))}));return function(e){return n.apply(this,arguments)}}(),destroy:function(){null==O||O.disconnect()}}),hn=function(){return Date.now().toString(36)+Math.random().toString(36).substring(2,15)},yn=function(n,e){return![/authenticate\/heartbeat/,/papluginlogs\/.*/,/airtracker\/.*/,/o11y(-staging|-demo)?\.airwallex\.com/,/\.(png|jpe?g|gif|svg|ico|webp|avif|css|js|json|woff2?|ttf|eot|map|txt|csv|xml)(\?.*)?(#.*)?$/i].some((function(e){return e.test(n)}))&&J(n,e||[/^https?:\/\/[^\/]*\.airwallex\.com($|\/)/])},wn=function(n){return Math.round(100*n)/100},bn=function(n,e){var t,r,i,o,a,s,u,c,l,d,f,v,m,p,h,y,w,b,g,E=n.url,I=n.method,S=n.errorType,N=n.errorDetail,C=function(n){var e=n.startTime,t=n.endTime,r=n.entries;if(0!==r.length){if(1===r.length)return r[0];var i=r.filter((function(n){return n.startTime>=e&&t&&n.responseEnd<=t})).sort((function(n,e){return n.startTime-e.startTime}));return null==i?void 0:i[0]}}(n),T=new URL(E,window.location.href),D=T.href,R=T.protocol,P=C?(i=(t=C).duration,o=t.responseStart,a=t.connectEnd,s=t.connectStart,u=t.domainLookupEnd,c=t.domainLookupStart,l=t.requestStart,d=t.secureConnectionStart,f=t.redirectEnd,v=t.redirectStart,m=t.responseStatus,p=t.responseEnd,h=t.encodedBodySize,y=t.decodedBodySize,w=t.transferSize,b=t.deliveryType,g=t.initiatorType,{startTime:wn(r=t.startTime),totalDuration:wn(i),timeToFirstByte:$(o,r),tcpDuration:$(a,s),dnsDuration:$(u,c),tlsDuration:$(l,d),redirectDuration:$(f,v),responseDuration:$(p,o),encodeResponseSize:h,decodeResponseSize:y,transferSize:w,deliveryType:b,statusCode:m,initiatorType:g}):{};return{severity:"autoDetectEvent",eventName:"httpClientMetrics",extraInfo:k(x(k({httpUrl:D,method:I,scheme:R},S&&{errorType:S},N&&{errorDetail:N},P),{statusCode:(null==P?void 0:P.statusCode)||(null==n?void 0:n.responseStatus),startTime:(null==P?void 0:P.startTime)||(null==n?void 0:n.startTime),initiatorType:(null==P?void 0:P.initiatorType)||(null==n?void 0:n.initiatorType)}),e)}},gn=function(n){return n&&"object"===(void 0===n?"undefined":S(n))&&"errors"in n&&Array.isArray(n.errors)&&n.errors.every((function(n){return n&&"object"===(void 0===n?"undefined":S(n))&&"message"in n}))},kn="awx_airtracker_api_performance_queue",xn="awx_airtracker_api_performance_plugin_loaded",En="undefined"!=typeof window?window:"undefined"!=typeof global?global:{};En[kn]=En[kn]||[];var In=function(n,e,t){setTimeout((function(){var r=bn(n,t);e.observerPipeline(r),En[kn]=En[kn].filter((function(e){return e.id!==n.id}))}),300)},Sn=function(n,e){setTimeout((function(){var t=En[kn].find((function(e){return e.id===n}));if(t){var r=bn(t,{exceptionType:"timeout-without-response"});e.observerPipeline(r),En[kn]=En[kn].filter((function(e){return e.id!==n}))}}),1e4)},Nn=new rn({name:"apiPerformancePlugin",setUp:function(){var n=h((function(n){var e,t;return C(this,(function(){return En[xn]||(null===(e=n.config)||void 0===e?void 0:e.enableRecordAPIPerformance)&&Math.random()<((null===(t=n.config)||void 0===t?void 0:t.enableRecordAPIPerformancePercentage)||0)&&(En[xn]=!0,function(n){var e;(function(n){var e=XMLHttpRequest.prototype.open,t=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(t,r,i,o,a){try{var s,u=hn();this.__requestId=u;var c=g(r,URL)?r.href:new URL(r,window.location.href).href;if(!yn(c,null===(s=n.config)||void 0===s?void 0:s.enableRecordAPIPerformanceWhitelist))return e.call(this,t,r,null==i||i,o,a);var l={id:u,startTime:performance.now(),method:t,url:c,entries:[],initiatorType:"xmlhttprequest"};return En[kn].push(l),Sn(u,n),e.call(this,t,r,null==i||i,o,a)}catch(s){return n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Inject XHR open error",error:s}}),e.call(this,t,r,null==i||i,o,a)}},XMLHttpRequest.prototype.send=function(){for(var e=this,r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];try{var a=En[kn].find((function(n){return n.id===e.__requestId}));if(!a)return t.apply(this,i);var s=this;return this.addEventListener("loadend",h((function(){var e,t,r,i,o,u,c;return C(this,(function(l){switch(l.label){case 0:if(e=performance.now(),t=e-a.startTime,0===(r=s.status))return[2];a.endTime=e,a.duration=t,a.responseStatus=r,l.label=1;case 1:return l.trys.push([1,6,,7]),""!==s.responseType&&"text"!==s.responseType?[3,2]:(i=s.responseText,[3,5]);case 2:return"json"!==s.responseType?[3,3]:(i=s.response,[3,5]);case 3:return"blob"!==s.responseType||"application/json"!==(null==(o=s.response)?void 0:o.type)?[3,5]:[4,o.text()];case 4:i=l.sent(),l.label=5;case 5:return(u=i&&"string"==typeof i?JSON.parse(i):i)&&gn(u)&&(a.errorType="graphqlError",a.errorDetail=u.errors),[3,7];case 6:return c=l.sent(),n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Parse response body error in XHR",url:null==a?void 0:a.url,error:c}}),[3,7];case 7:return In(a,n),[2]}}))}))),this.addEventListener("error",(function(){In(a,n,{exceptionType:"network-error"})})),this.addEventListener("abort",(function(){In(a,n,{exceptionType:"abort-error"})})),this.addEventListener("timeout",(function(){In(a,n,{exceptionType:"timeout-error"})})),t.apply(this,i)}catch(e){throw n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"InjectXHR send error",error:e}}),e}}})(n),function(n){var e=window.fetch;window.fetch=h((function(){var t,r,i,o,a,s,u,c,l,d,f,v,m,p,h,y,w=arguments;return C(this,(function(b){switch(b.label){case 0:for(t=w.length,r=new Array(t),i=0;i<t;i++)r[i]=w[i];return s=new URL(g(r[0],Request)?r[0].url:String(r[0]),window.location.href).href,yn(s,null===(o=n.config)||void 0===o?void 0:o.enableRecordAPIPerformanceWhitelist)?[3,2]:[4,e.apply(this,r)];case 1:return[2,b.sent()];case 2:return b.trys.push([2,9,,10]),c=performance.now(),l=hn(),a={id:l,startTime:c,method:(null===(u=g(r[0],Request)?r[0]:r[1])||void 0===u?void 0:u.method)||"GET",url:s,entries:[],initiatorType:"fetch"},En[kn].push(a),Sn(l,n),[4,e.apply(this,r)];case 3:d=b.sent(),f=performance.now(),a.endTime=f,a.duration=f-c,a.responseStatus=d.status,v=d.clone(),b.label=4;case 4:return b.trys.push([4,7,,8]),v.ok?[4,v.json()]:[3,6];case 5:(m=b.sent())&&gn(m)&&(a.errorType="graphqlError",a.errorDetail=m.errors),b.label=6;case 6:return[3,8];case 7:return p=b.sent(),n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Parse response body error in fetch",url:null==a?void 0:a.url,error:p}}),[3,8];case 8:return In(a,n),[2,d];case 9:throw h=b.sent(),a&&a.id&&En[kn].find((function(n){return n.id===(null==a?void 0:a.id)}))?(y="fetch-error",g(h,TypeError)?y="network-error":g(h,DOMException)&&"AbortError"===h.name&&(y="abort-error"),In(a,n,{exceptionType:y})):n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{message:"Inject fetch error",error:h}}),h;case 10:return[2]}}))}))}(n),(null===(e=window)||void 0===e?void 0:e.PerformanceObserver)?new window.PerformanceObserver((function(n){n.getEntries().forEach((function(n){var e=n;"fetch"!==e.initiatorType&&"xmlhttprequest"!==e.initiatorType||En[kn].filter((function(n){return n.url===e.name})).forEach((function(n){n.entries.push(e)}))}))})).observe({entryTypes:["resource"],buffered:!0}):n.normalLogPipeLine({severity:"warn",eventName:"apiPerformancePluginError",extraInfo:{error:"PerformanceObserver Not Supported"}})}(n)),[2]}))}));return function(e){return n.apply(this,arguments)}}()}),Cn=function(){function n(e){var t,r,i=this,o=e.config,a=e.plugins,s=void 0===a?[]:a;y(this,n),this.config=_,this.lifeCycle=new tn,this.plugins=[],this._commonData=L,this._MFECommonDataMap={},this.timeMap={},this.packedDataConvert=function(n){var e,t,r=n.extraInfo,o=k({severity:n.severity,eventName:n.eventName,currentHref:i.config.hideSearchParams?((null===(e=location)||void 0===e?void 0:e.href)||"").split("?")[0]||"":(null===(t=location)||void 0===t?void 0:t.href)||""},r);return i.config.isWebappContainer&&(o.MFEName=z(i)),o},this.normalPipelineObj=en([Z(this,8),(t=this,r={},function(n,e){var i="number"==typeof t.config.errorRepeatTime?t.config.errorRepeatTime:5;if(0===i)return null==e?void 0:e(n);null==e||e(n.filter((function(n){return"autoDetectError"!=n.severity||(r[n.error]=r[n.error]||0,r[n.error]+=1,!(r[n.error]>i))})))}),Q(this)]),this.observerPipelineObj=en([Z(this,8),Y(this)]),this.immediateSendPipe=Q(this),this.observerPipeline=function(n){var e=i.packedDataConvert({severity:n.severity,eventName:n.eventName,extraInfo:n.extraInfo});return i.observerPipelineObj(e)},this.normalLogPipeLine=function(n){var e=i.packedDataConvert({severity:n.severity,eventName:n.eventName,extraInfo:n.extraInfo});return i.config.disableThrottle?i.immediateSendPipe(e):i.normalPipelineObj(e)},this.ImmediatePipeline=function(n){var e=i.packedDataConvert({severity:n.severity,eventName:n.eventName,extraInfo:n.extraInfo});return i.immediateSendPipe(e)},this.plugins=I(s),this.setConfig(o),this.initCommonData(o),this.lifeCycle.emit("onInit"),o.enableErrorMonitoring&&this.plugins.push(un),((null==o?void 0:o.assetSpeedMonitoringWhiteList)&&o.assetSpeedMonitoringWhiteList.length>0||o.isWebappContainer)&&this.plugins.push(vn),(null==o?void 0:o.enableDetectPageChange)&&this.plugins.push(mn),(null==o?void 0:o.enableRecordPageRetention)&&this.plugins.push(pn),(null==o?void 0:o.enableRecordAPIPerformance)&&(null==o?void 0:o.enableRecordAPIPerformancePercentage)&&o.enableRecordAPIPerformancePercentage>0&&o.enableRecordAPIPerformancePercentage<=1&&this.plugins.push(Nn),this.installPlugins()}return w(n,[{key:"installPlugins",value:function(){var n=this;this.plugins.forEach((function(e){e.patch(n)}))}},{key:"commonData",get:function(){return this._commonData}},{key:"MFECommonDataMap",get:function(){return this._MFECommonDataMap}},{key:"initCommonData",value:function(n){this._commonData.sessionId=n.useSessionStorageForSessionId?function(){try{var n=window.sessionStorage.getItem(q);return n||(n=B(),window.sessionStorage.setItem(q,n)),n}catch(n){return B()}}():B(),this._commonData.deviceId=function(){try{var n=window.localStorage.getItem(H);return n||(n=B(),window.localStorage.setItem(H,n)),n}catch(n){}}()||A,this._commonData.riskDeviceId=function(){try{return window.localStorage.getItem("AWX_RISK_ID")||void 0}catch(n){}}(),this._commonData.networkType=function(){var n,e,t="",r=navigator.userAgent.match(/NetType\/(\w+)/);if(r)t=E(r,2)[1];else if(null===(n=navigator)||void 0===n?void 0:n.connection){var i,o,a,s;t=(null===(o=navigator)||void 0===o||null===(i=o.connection)||void 0===i?void 0:i.effectiveType)||(null===(s=navigator)||void 0===s||null===(a=s.connection)||void 0===a?void 0:a.type)}return t||(t="unknown"),e=t,(e=String(e).toLowerCase()).indexOf("4g")>=0?"net4g":e.indexOf("wifi")>=0?"wifi":e.indexOf("5g")>=0?"net5g":e.indexOf("3g")>=0?"net3g":e.indexOf("2g")>=0?"net2g":"unknown"}()||"unknown",this._commonData.env=n.env||this._commonData.env,this._commonData.accountId=n.accountId||A,this._commonData.appVersion=n.appVersion,this._commonData.appName=n.appName,this._commonData.sdkVersion="3.1.0",this.lifeCycle.emit("onCommonDataInit",this.commonData)}},{key:"updateCommonDataBasedOnConfig",value:function(n){this.lifeCycle.emit(K,this._commonData),this._commonData.env=n.env||this._commonData.env,this._commonData.appName=n.appName||this._commonData.appName,this._commonData.env=n.env||this._commonData.env,this._commonData.accountId=n.accountId||this._commonData.accountId,this._commonData.appVersion=n.appVersion||this._commonData.appVersion}},{key:"updateCommonData",value:function(n){this.lifeCycle.emit(K,this._commonData),this._commonData=k({},this._commonData,n)}},{key:"removeCommonDataByKey",value:function(n){var e=this;this.lifeCycle.emit(K,this._commonData),setTimeout((function(){n.forEach((function(n){delete e._commonData[n]}))}),1e3)}},{key:"addToMFECommonData",value:function(n){var e,t=n.MFEName,r=n.MFECommonData;this.config.isWebappContainer&&t&&r&&(this._MFECommonDataMap=x(k({},this._MFECommonDataMap||{}),b({},t,k({},(null===(e=this._MFECommonDataMap)||void 0===e?void 0:e[t])||{},r))))}},{key:"setConfig",value:function(n){var e=this;this.config.isWebappContainer||(Object.entries(n).forEach((function(n){var t=E(n,2),r=t[0],i=t[1];void 0!==(void 0===i?"undefined":S(i))&&function(n,t){e.config[n]=t}(r,i)})),this.lifeCycle.emit("onConfigInit",this.config),this.updateCommonDataBasedOnConfig(n))}},{key:"verbose",value:function(n,e){this.normalLogPipeLine({severity:"verbose",eventName:n,extraInfo:e})}},{key:"httpLog",value:function(n,e){this.normalLogPipeLine({severity:"http",eventName:n,extraInfo:e})}},{key:"info",value:function(n,e){this.normalLogPipeLine({severity:"info",eventName:n,extraInfo:e})}},{key:"warn",value:function(n,e){this.normalLogPipeLine({severity:"warn",eventName:n,extraInfo:e})}},{key:"error",value:function(n,e){console.error("error",n),this.normalLogPipeLine({severity:"error",eventName:n,extraInfo:e})}},{key:"businessLog",value:function(n,e){this.normalLogPipeLine({severity:"info",eventName:n,extraInfo:x(k({},e),{isBusinessLog:!0})})}},{key:"reportDuration",value:function(n,e,t){"string"==typeof n?"number"==typeof e?e<0||e>6e4?console.warn("reportDuration: duration (second param) must between 0 and 60000"):this.normalLogPipeLine({severity:"speed",eventName:n,extraInfo:k({duration:e},t)}):console.warn("reportDuration: duration (second param) must be number"):console.warn("reportDuration: eventName (first param) must be a string")}},{key:"getTimerKey",value:function(n){var e=z(this);return this.config.isWebappContainer?"".concat(e,"_").concat(n):n}},{key:"timeStart",value:function(n){"string"==typeof n?(this.timeMap[this.getTimerKey(n)]&&console.warn("Timer ".concat(n," already exists")),this.timeMap[this.getTimerKey(n)]=Date.now()):console.warn("time: first param must be a string")}},{key:"timeEnd",value:function(n,e){if("string"==typeof n)if(this.timeMap[this.getTimerKey(n)]){var t=Date.now()-this.timeMap[this.getTimerKey(n)]+(e||0);this.normalLogPipeLine({severity:"speed",eventName:n,extraInfo:{duration:t}}),delete this.timeMap[this.getTimerKey(n)]}else console.warn("Timer key :".concat(n," does not exist"));else console.warn("timeEnd: first param must be a string")}},{key:"addToAssetSpeedWhiteListByMFE",value:function(n){var e,t,r,i,o=n.MFEName,a=n.whiteList;this.config.isWebappContainer&&o&&(null==a?void 0:a.length)&&(this.config.assetSpeedMonitoringWhiteListByMFE||(this.config.assetSpeedMonitoringWhiteListByMFE={}),(null===(e=this.config.assetSpeedMonitoringWhiteListByMFE)||void 0===e?void 0:e[o])?null===(i=this.config.assetSpeedMonitoringWhiteListByMFE)||void 0===i||null===(r=i[o])||void 0===r||(t=r).push.apply(t,I(a)):this.config.assetSpeedMonitoringWhiteListByMFE=x(k({},this.config.assetSpeedMonitoringWhiteListByMFE),b({},o,a)))}},{key:"destroy",value:function(){this.config.isWebappContainer||this.plugins.forEach((function(n){n.uninstall()}))}}]),n}(),Tn=Cn,Dn=function(n,e){return Dn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,e){n.__proto__=e}||function(n,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t])},Dn(n,e)};function Rn(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=n}Dn(n,e),n.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t)}var Pn=function(){return Pn=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},Pn.apply(this,arguments)};function On(n,e,t,r){return new(t||(t=Promise))((function(e,i){function o(n){try{s(r.next(n))}catch(n){i(n)}}function a(n){try{s(r.throw(n))}catch(n){i(n)}}function s(n){var r;n.done?e(n.value):(r=n.value,r instanceof t?r:new t((function(n){n(r)}))).then(o,a)}s((r=r.apply(n,[])).next())}))}function jn(n,e){var t,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(t=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(n,a)}catch(n){s=[6,n],r=0}finally{t=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function An(n,e){for(var t,r=0,i=e.length;r<i;r++)!t&&r in e||(t||(t=Array.prototype.slice.call(e,0,r)),t[r]=e[r]);return n.concat(t||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var _n,Ln,Un,Mn={dev:j.staging,staging:j.staging,demo:j.demo,prod:j.production},Fn=function(n){if("object"!=typeof n)return n;try{var e=JSON.parse(JSON.stringify(n));return Object.keys(e).forEach((function(n){"string"==typeof n&&["auth","code"].some((function(e){return n.includes(e)}))&&(e[n]="***")})),e}catch(e){return n}},Kn=function(n,e){var t,r;null===(r=null===(t=window._AirwallexSDKs)||void 0===t?void 0:t.airTracker)||void 0===r||r.error(n,Pn(Pn({},e),{context:"components-sdk"}))},Hn=function(n,e){var t;null===(t=window._AirwallexSDKs.airTracker)||void 0===t||t.info(n,Pn(Pn({},e),{context:"components-sdk"}))},qn=function(n){function e(e){var t=n.call(this,e)||this;return t.code="LOAD_SCRIPT_ERROR",t}return Rn(e,n),e}(Error);!function(n){n.dev="dev",n.staging="staging",n.demo="demo",n.prod="prod",n.sandbox="sandbox"}(Un||(Un={}));var Bn,zn=((_n={})[Un.dev]="https://checkout-staging.airwallex.com",_n[Un.staging]="https://checkout-staging.airwallex.com",_n[Un.demo]="https://checkout-demo.airwallex.com",_n[Un.prod]="https://checkout.airwallex.com",_n[Un.sandbox]="https://checkout.sandbox.airwallex.com",_n),Vn=((Ln={})[Un.dev]="https://static-staging.airwallex.com",Ln[Un.staging]="https://static-staging.airwallex.com",Ln[Un.demo]="https://static-demo.airwallex.com",Ln[Un.prod]="https://static.airwallex.com",Ln[Un.sandbox]="https://static.sandbox.airwallex.com",Ln),Wn="sdkController",Xn="payments",Gn={kyc:"/widgets/kyc/sdk/v1/index.js",rfi:"/widgets/kycRfi/sdk/v1/index.js",paymentsKyb:"/widgets/paymentsKyb/sdk/v1/index.js",sdkController:"/widgets/sdk-controller/sdk/v1/index.js",payouts:"/widgets/payouts/sdk/v1/index.js",payments:"/assets/elements.bundle.min.js",sca:"/hosted-sca/sdk/v1/index.js",taxForm:"/widgets/taxForm/sdk/v1/index.js",billing:"/widgets/checkout/sdk/v1/index.js",balance:"/widgets/embedded-balance/sdk/v1/index.js"},Jn={kyc:"kyc",paymentsKyb:"paymentsKyb",kycRfi:"rfi",transactionRfi:"rfi",paymentEnablementRfi:"rfi",lendingRfi:"rfi",mrmRfi:"rfi",payoutForm:"payouts",beneficiaryForm:"payouts",hpp:"payments",cvc:"payments",card:"payments",expiry:"payments",dropIn:"payments",cardNumber:"payments",applePayButton:"payments",googlePayButton:"payments",krCardNumber:"payments",krCardIdentifier:"payments",krCardExpiry:"payments",krCardPswFirstTwo:"payments",scaSetup:"sca",scaVerify:"sca",scaManagement:"sca",taxForm:"taxForm",embeddedCheckout:"billing",balanceOverview:"balance",balanceDetail:"balance",balanceActivities:"balance",balanceActivityDetails:"balance",balanceHistoryChart:"balance",balanceInfo:"balance",balanceScheduledTransactions:"balance",balanceList:"balance"},$n={payments:["hpp","cvc","card","expiry","dropIn","cardNumber","applePayButton","googlePayButton","krCardNumber","krCardIdentifier","krCardExpiry","krCardPswFirstTwo"],payouts:["payoutForm","beneficiaryForm"],onboarding:["kyc","paymentsKyb"],risk:["scaSetup","scaVerify","scaManagement","transactionRfi","kycRfi","paymentEnablementRfi","lendingRfi","mrmRfi"],billing:["embeddedCheckout"],balance:["balanceOverview","balanceDetail","balanceActivities","balanceHistoryChart","balanceInfo","balanceScheduledTransactions","balanceList","balanceActivityDetails"]},Qn={billing:["payments"]},Yn=["payments","sca","billing"],Zn=function(n){function e(e){var t=n.call(this,e)||this;return t.code="INVALID_STATIC_RESOURCE_ERROR",t}return Rn(e,n),e}(Error),ne=Date.now(),ee=function(n){return Jn[n]},te=function(n){var e=n.reduce((function(n,e){return n.concat((t=e,Object.keys($n).includes(t)?$n[e]:e));var t}),[]);return Array.from(new Set(e)).map((function(n){return{elementName:n,sdkName:ee(n)}}))},re=function(n){return"payments"===n?"payment":n},ie=function(n){var e=n.name,t=n.env,r=function(n,e){var t=n===Xn?zn:Vn;return t[e]||t.prod}(e,void 0===t?Un.prod:t),i=Gn[e];if(!i)throw Kn("[components-sdk] Element static resource not found",{sdkName:e}),new Zn("Element ".concat(e," static resource URL is invalid."));return"".concat(r).concat(i,"?ts=").concat(ne)},oe=function(){return Math.floor(performance.now())},ae=function(n){function e(e){var t=n.call(this,e)||this;return t.code="INSTANCE_NOT_FOUND_ERROR",t}return Rn(e,n),e}(Error),se=new Map,ue=function(n){var e=n.scriptName,t=ie({name:e,env:n.env}),r=se.get(e);if(r)return r;var i=function(n){return On(void 0,0,void 0,(function(){var e,t;return jn(this,(function(r){switch(r.label){case 0:if("undefined"==typeof window)throw new Error("Please load script in browser environment");e=0,t=function(){return On(void 0,0,void 0,(function(){var t,r,i;return jn(this,(function(){return t=oe(),e>0&&n.includes("?ts=")&&((r=new URL(n,window.location.href)).searchParams.set("ts","".concat(Date.now())),n=r.toString()),i=function(n){var e=document.createElement("script");return e.src=n,e.type="module",(document.head||document.body).appendChild(e),e}(n),[2,new Promise((function(r,o){i.addEventListener("load",(function(){var i=oe();Hn("[components-sdk] SDK script loaded",{scriptUrl:n,start:t,latency:i-t,end:i,retryCount:e}),r(!0)})),i.addEventListener("error",(function(r){i.remove(),console.error(r);var a=oe();Kn("[components-sdk] Failed to load script",{scriptUrl:n,error:r,start:t,latency:a-t,end:a,retryCount:e}),o(new qn("Failed to load Airwallex SDK scripts: ".concat(n)))}))}))]}))}))},r.label=1;case 1:if(!(e<3))return[3,7];r.label=2;case 2:return r.trys.push([2,4,,6]),[4,t()];case 3:return[2,r.sent()];case 4:return r.sent(),e++,[4,(void 0===i&&(i=500),new Promise((function(n){return window.setTimeout(n,i)})))];case 5:return r.sent(),[3,6];case 6:return[3,1];case 7:throw Kn("[components-sdk] Failed to load script after retry",{scriptUrl:n,retryCount:e}),new qn("Failed to load Airwallex SDK scripts: ".concat(n))}var i}))}))}(t);return se.set(e,i),i},ce=function(n){var e=n.env,t=n.scriptName;return On(void 0,0,void 0,(function(){var n;return jn(this,(function(r){switch(r.label){case 0:return(n=Qn[t]||[]).length>0?[4,Promise.all(n.map((function(n){return ue({env:e,scriptName:n})})))]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2,ue({env:e,scriptName:t})]}}))}))},le=function(n){return On(void 0,0,void 0,(function(){return jn(this,(function(){if("undefined"==typeof window)throw new Error("Please call the `init()` function in a browser environment.");var e,t;return t=n.clientId,void 0===(e=n.env)&&(e=j.production),window._AirwallexSDKs.airTracker||(window._AirwallexSDKs.airTracker=new Tn({config:{appName:"components-sdk",appVersion:"1.35.1",env:Mn[e]||j.production}}),window._AirwallexSDKs.airTracker.updateCommonData({clientId:t})),window,Hn("[components-sdk] SDK init start",{options:Fn(n),start:oe()}),Bn=new Promise((function(e,t){var r,i=Pn(Pn({},n),{env:n.env&&Un[n.env]?n.env:Un.prod});window.AirwallexComponentsSDK.__env__=i.env;var o=ue({env:i.env,scriptName:Wn}).then((function(){return window._AirwallexSDKs.__controller__.init(i)})),a=null!==(r=n.enabledElements)&&void 0!==r?r:[],s=function(n){return Array.from(new Set(te(n).map((function(n){return n.sdkName})).filter((function(n){return Yn.includes(n)}))))}(a),u=s.map((function(n){return ce({env:i.env,scriptName:n}).then((function(){return o})).then((function(){var e=window._AirwallexSDKs[re(n)];if(!e)throw Kn("[components-sdk] SDK instance not found",{functionsNamespace:n,windowSDKInstanceName:re(n)}),new ae("SDK instance not found");return window._AirwallexSDKs.__controller__.registerFunctions({functionsNamespace:n,instance:e})}))})),c=te(a).map((function(n){var e=n.sdkName,t=n.elementName;return ce({scriptName:e,env:i.env}).then((function(){return o})).then((function(){var n=window._AirwallexSDKs[re(e)];if(!n)throw Kn("[components-sdk] SDK instance not found",{sdkName:e,windowSDKInstanceName:re(e)}),new ae("SDK instance not found");return window._AirwallexSDKs.__controller__.registerElement({sdkName:e,elementName:t,instance:n})}))}));Promise.all(An(An([o],u),c)).then((function(){Hn("[components-sdk] SDK initialized",{options:Fn(n),start:oe()}),e(Yn.reduce((function(n,e){var t;return Pn(Pn({},n),((t={})[e]=window._AirwallexSDKs.__controller__.internalSDKs[e],t))}),{}))})).catch((function(n){n.code||Kn("[components-sdk] Unexpected errors when init",{error:n}),t(n)}))})),[2,Bn]}))}))},de=function(n,e){return On(void 0,0,void 0,(function(){var t,r,i,o,a;return jn(this,(function(s){switch(s.label){case 0:if(!n)throw new Error("Element type is missing. Please specify a valid element.");if(Hn("[components-sdk] SDK createElement start",{elementName:n,options:Fn(e),timestamp:oe()}),!Bn)throw function(){var n;null===(n=window._AirwallexSDKs.airTracker)||void 0===n||n.warn("[components-sdk] Did not call init before createElement",Pn(Pn({},void 0),{context:"components-sdk"}))}(),new Error("Please initialize the Element before creating it.");return[4,Bn];case 1:if(s.sent(),!(t=ee(n)))throw new Error("`createElement()` with type `".concat(n,"` is not supported. Please specify a valid Element type."));r=oe(),s.label=2;case 2:return s.trys.push([2,6,,7]),[4,ce({scriptName:t,env:window.AirwallexComponentsSDK.__env__||Un.prod})];case 3:return s.sent(),[4,window._AirwallexSDKs.__controller__.registerElement({sdkName:t,elementName:n,instance:window._AirwallexSDKs[re(t)]})];case 4:return s.sent(),[4,window._AirwallexSDKs.__controller__.createElement(n,e)];case 5:return i=s.sent(),o=oe(),Hn("[components-sdk] SDK createElement being called",{elementName:n,options:Fn(e),start:r,latency:o-r,end:o}),[3,7];case 6:if((a=s.sent()).code)throw a;return Kn("[components-sdk] Unexpected errors when createElement",{error:a}),[3,7];case 7:return[2,i]}}))}))},fe=[Wn,Xn],ve=function(){fe.forEach((function(n){var e=ie({name:n,env:Un.prod}),t=document.createElement("link");t.href=e,t.rel="modulepreload",t.as="script",(document.head||document.body).appendChild(t)}))};"undefined"==typeof document||"undefined"==typeof window||("loading"===document.readyState?document.addEventListener("DOMContentLoaded",ve):ve()),"undefined"!=typeof window&&(window.AirwallexComponentsSDK||Object.defineProperties(window,{AirwallexComponentsSDK:{value:{},writable:!1},_AirwallexSDKs:{value:{},writable:!1}}),window.AirwallexComponentsSDK.init=le,window.AirwallexComponentsSDK.createElement=de);const{onChange:me,reset:pe,state:he}=n((()=>({clientSecret:null,currency:null,hasPaymentError:!1,isReady:!1,paymentConfirmed:!1,paymentIntentId:null}))),ye=n=>"AIRWALLEX"===n.paymentProcessor&&(n.clientSecret&&(he.clientSecret=n.clientSecret),n.paymentIntentId&&(he.paymentIntentId=n.paymentIntentId),!!he.clientSecret||(o("Airwallex checkout session is missing the client secret"),!1)),we={ar:"ar",da:"da",de:"de",en:"en",es:"es",fr:"fr",id:"id",it:"it",ja:"ja",ko:"ko",nl:"nl",pl:"pl",pt:"pt",ru:"ru",sv:"sv",zh:"zh"},be=n=>we[n]||"en";let ge=null;const ke=async()=>!!he.isReady||(ge||(ge=le({enabledElements:["payments"],env:e.zonosMode&&"production"!==e.zonosMode||"LIVE"!==e.checkoutSettings.mode?"demo":"prod",locale:be(r.selectedLocale)}).then((()=>(he.isReady=!0,u("Airwallex SDK initialized"),!0))).catch((n=>(o(n),ge=null,!1)))),ge),xe=["SUCCEEDED","REQUIRES_CAPTURE","PENDING_REVIEW","PENDING"],Ee=n=>!!n&&xe.includes(n),Ie=n=>{switch(n){case"SUCCEEDED":return{isError:!1,messages:[t("Thank you for submitting your payment. We appreciate your prompt attention."),"",t("A confirmation email with your payment details has been sent for your records. If you have any questions or need support, our team is here to help.")]};case"PENDING":case"PENDING_REVIEW":case"REQUIRES_CAPTURE":return{isError:!1,messages:[t("Payment processing. We'll update you when payment is received.")]};case"REQUIRES_CUSTOMER_ACTION":return{isError:!1,messages:[t("Your selected payment method requires additional verification. Please follow the instructions provided by your payment provider to complete the transaction.")]};case"CANCELLED":case"REQUIRES_PAYMENT_METHOD":return{isError:!0,messages:[t("Payment failed. Please reload the page and try another payment method.")]};default:return{isError:!0,messages:[t("Something went wrong.")]}}},Se=async n=>{const{errors:e,json:t}=await a("/api/zonos-elements/collect/airwallex-payment-intent",{body:{paymentIntentId:n},method:"POST"});return e.length||!t?(o("Failed to retrieve Airwallex payment intent",e),{status:null}):{status:t.airwallexPaymentIntent.status}},{state:Ne}=n((()=>({amountDutyTaxFeeTotal:null,amountTotalPaid:null,collectLogoUrl:null,isFetchingShippingInfo:!0,landedCostShortId:null,originCompanyName:null,partyBillingId:null,paymentProcessor:null,shippingAddress:null}))),Ce=async({landedCostId:n,retries:t=5})=>{var r,i,o,u,c,d,f,v,m,p;Ne.isFetchingShippingInfo=!0;const h=await a("/api/zonos-elements/collect/get-shipping-info-by-lc-id",{body:{landedCostId:n},method:"POST"});if(h.errors.length)return t>0?(await new Promise((n=>setTimeout(n,1e3))),Ce({landedCostId:n,retries:t-1})):null;Ne.landedCostShortId=(null===(r=h.json)||void 0===r?void 0:r.landedCostShortId)||null,Ne.isFetchingShippingInfo=!1,Ne.shippingAddress=(null===(i=h.json)||void 0===i?void 0:i.shipping)||null;const y=null===(o=l.checkoutSession)||void 0===o?void 0:o.landedCost,w=null===(u=l.checkoutSession)||void 0===u?void 0:u.subtotals,b=((null===(c=null==y?void 0:y.amountSubtotals)||void 0===c?void 0:c.shipping)||0)+((null===(d=null==y?void 0:y.amountSubtotals)||void 0===d?void 0:d.items)||0);Ne.amountTotalPaid=b*((null===(f=null==w?void 0:w.exchangeRate)||void 0===f?void 0:f.rate)||1),Ne.amountDutyTaxFeeTotal=((null==w?void 0:w.duties)||0)+((null==w?void 0:w.taxes)||0)+((null==w?void 0:w.fees)||0),Ne.originCompanyName=(null===(m=null===(v=h.json)||void 0===v?void 0:v.origin)||void 0===m?void 0:m.companyName)||null,Ne.collectLogoUrl=(null===(p=h.json)||void 0===p?void 0:p.collectLogoUrl)||null,0===Ne.amountTotalPaid&&s({endpoint:"COLLECT_NO_TOTAL_PAID",errors:[],metadata:{landedCostId:n,organizationId:e.organizationId}})},Te=async()=>{var n,e,t,r;if(!(null===(n=f.stripeBillingAddressEventData)||void 0===n?void 0:n.complete))return{partiesCreated:!1};const u=null===(t=null===(e=l.checkoutSession)||void 0===e?void 0:e.landedCost)||void 0===t?void 0:t.rootId;if(!u)return s({endpoint:"PF_NO_SELECTED_LANDED_COST",errors:["No selected landed cost"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:i.checkoutSessionId}}),{partiesCreated:!1};if(!i.checkoutSessionId)return s({endpoint:"COLLECT_NO_CHECKOUT_SESSION_ID",errors:["No checkout session id"],metadata:{allLogs:c,cartId:window.Zonos.cartId,landedCostRootId:u}}),{partiesCreated:!1};const d=v({address:f.stripeBillingAddressEventData.value.address,firstName:f.stripeBillingAddressEventData.value.firstName,lastName:f.stripeBillingAddressEventData.value.lastName,name:f.stripeBillingAddressEventData.value.name,phone:f.stripeBillingAddressEventData.value.phone}),m="1"===new URLSearchParams(window.location.search).get("zonosE2ETest"),{errors:p,json:h}=await a("/api/zonos-elements/create-billing-party",{body:{billingAddress:d,checkoutSessionId:i.checkoutSessionId,companyName:f.companyName,email:(null===(r=f.stripeLinkEventData)||void 0===r?void 0:r.value.email)||"",isTest:m,rootId:u},method:"POST"});return p.length||!h?(o("Error occurs when creating billing party",JSON.stringify(p,null,2)),s({endpoint:"COLLECT_BILLING_PARTY_CREATE_FAILED",errors:["[COLLECT] Failed to create billing party"],metadata:{allLogs:c,cartId:window.Zonos.cartId,checkoutSessionId:i.checkoutSessionId,errors:p,json:h}}),{partiesCreated:!1}):(Ne.partyBillingId=h.billToPartyId,{partiesCreated:!0})},De=async n=>{const e=n.landedCost;return!!e&&(l.landedCostData=[Object.assign(Object.assign({},n),{landedCost:Object.assign({},e),landedCostId:e.id})],d({applySubtotalsOnly:!0,landedCostId:e.id,selectedShippingOption:e.shipmentRating}))};export{ye as a,he as b,Ne as c,Se as d,Ee as e,ke as f,De as g,Ce as h,Te as i,Ie as j,pe as k,de as l,be as m,me as n}
@@ -1 +1 @@
1
- import{U as e}from"./p-BMPYH-LT.js";const l=3,a=({countryField:l,event:a})=>{var o,t,n;if(!a)return[];const{value:s}=a,i=[],{lastName:r}=e({firstName:s.firstName,lastName:s.lastName,name:s.name});return r.trim()||i.push({key:"lastName"}),(null==l?void 0:l.stateRequired)&&!(null===(o=s.address.state)||void 0===o?void 0:o.trim())&&i.push({key:"state"}),(null==l?void 0:l.zipRequired)&&(null!==(n=null===(t=s.address.postal_code)||void 0===t?void 0:t.trim().length)&&void 0!==n?n:0)<3&&i.push({key:"postal_code"}),i};export{l as M,a as g}
1
+ import{U as e}from"./p-BJ_kE5rM.js";const l=3,a=({countryField:l,event:a})=>{var o,t,n;if(!a)return[];const{value:s}=a,i=[],{lastName:r}=e({firstName:s.firstName,lastName:s.lastName,name:s.name});return r.trim()||i.push({key:"lastName"}),(null==l?void 0:l.stateRequired)&&!(null===(o=s.address.state)||void 0===o?void 0:o.trim())&&i.push({key:"state"}),(null==l?void 0:l.zipRequired)&&(null!==(n=null===(t=s.address.postal_code)||void 0===t?void 0:t.trim().length)&&void 0!==n?n:0)<3&&i.push({key:"postal_code"}),i};export{l as M,a as g}
@@ -1 +1 @@
1
- import{z as o}from"./p-CqB9AfBf.js";import{g as t}from"./p-DE4a-QD5.js";import{l as e}from"./p-BJmZPrZl.js";const n="zonos-analytic",i={fbq:!1,gtag:!1},a=[];let d=!1;const s=()=>"undefined"!=typeof window&&window.parent!==window,r=()=>{d||(d=!0,window.addEventListener("message",(o=>{var t;if("zonos-analytics-relay-ready"!==(null===(t=o.data)||void 0===t?void 0:t.type))return;const e=o.data.provider||"gtag";i[e]=!0,void 0!==window.Zonos&&("gtag"===e?window.Zonos.googleAnalyticReady=!0:window.Zonos.facebookPixelReady=!0),(()=>{const o=[];for(;a.length>0;){const t=a.shift();if(i[t.provider])try{window.parent.postMessage({event:t.event,fbqMode:t.fbqMode,metadata:t.payload,provider:t.provider,type:n},"*")}catch(o){}else o.push(t)}a.push(...o)})()})))},w=()=>{if(s()){r();try{const o=void 0!==window.Zonos?window.Zonos:void 0;window.parent.postMessage({facebookPixelId:null==o?void 0:o.facebookPixelId,googleAnalyticId:null==o?void 0:o.googleAnalyticId,type:"zonos-analytics-relay-ping"},"*")}catch(o){}}},c=o=>{if(r(),i[o.provider])try{window.parent.postMessage({event:o.event,fbqMode:o.fbqMode,metadata:o.payload,provider:o.provider,type:n},"*")}catch(o){}else a.push(o),w()},l=s,f=()=>{s()&&(i.gtag&&i.fbq||w())},p=({event:n,metadata:i})=>{if(!(()=>{const t=o.checkoutSettings.analyticsProviders.find((o=>"GOOGLE_ANALYTICS"===o.type));return!!t&&"ENABLED"===t.status})())return;const a=t(),d=Object.assign(Object.assign({},i),a&&{isTestMode:!0}),s=Object.fromEntries(Object.entries(d).filter((([o,t])=>null!==t)));l()?c({event:n,payload:s,provider:"gtag"}):"function"==typeof window.gtag&&(e("Zonos submits gtag event","log",n),window.gtag("event",n,s))};export{c as a,f as e,l as i,p as s}
1
+ import{z as o}from"./p-CqB9AfBf.js";import{g as t}from"./p-gEViRqvf.js";import{l as e}from"./p-BJmZPrZl.js";const n="zonos-analytic",i={fbq:!1,gtag:!1},a=[];let d=!1;const s=()=>"undefined"!=typeof window&&window.parent!==window,r=()=>{d||(d=!0,window.addEventListener("message",(o=>{var t;if("zonos-analytics-relay-ready"!==(null===(t=o.data)||void 0===t?void 0:t.type))return;const e=o.data.provider||"gtag";i[e]=!0,void 0!==window.Zonos&&("gtag"===e?window.Zonos.googleAnalyticReady=!0:window.Zonos.facebookPixelReady=!0),(()=>{const o=[];for(;a.length>0;){const t=a.shift();if(i[t.provider])try{window.parent.postMessage({event:t.event,fbqMode:t.fbqMode,metadata:t.payload,provider:t.provider,type:n},"*")}catch(o){}else o.push(t)}a.push(...o)})()})))},w=()=>{if(s()){r();try{const o=void 0!==window.Zonos?window.Zonos:void 0;window.parent.postMessage({facebookPixelId:null==o?void 0:o.facebookPixelId,googleAnalyticId:null==o?void 0:o.googleAnalyticId,type:"zonos-analytics-relay-ping"},"*")}catch(o){}}},c=o=>{if(r(),i[o.provider])try{window.parent.postMessage({event:o.event,fbqMode:o.fbqMode,metadata:o.payload,provider:o.provider,type:n},"*")}catch(o){}else a.push(o),w()},l=s,f=()=>{s()&&(i.gtag&&i.fbq||w())},v=({event:n,metadata:i})=>{if(!(()=>{const t=o.checkoutSettings.analyticsProviders.find((o=>"GOOGLE_ANALYTICS"===o.type));return!!t&&"ENABLED"===t.status})())return;const a=t(),d=Object.assign(Object.assign({},i),a&&{isTestMode:!0}),s=Object.fromEntries(Object.entries(d).filter((([o,t])=>null!==t)));l()?c({event:n,payload:s,provider:"gtag"}):"function"==typeof window.gtag&&(e("Zonos submits gtag event","log",n),window.gtag("event",n,s))};export{c as a,f as e,l as i,v as s}
@@ -1,4 +1,4 @@
1
- var __awaiter=this&&this.__awaiter||function(r,n,e,t){function o(r){return r instanceof e?r:new e((function(n){n(r)}))}return new(e||(e=Promise))((function(e,i){function a(r){try{c(t.next(r))}catch(r){i(r)}}function u(r){try{c(t["throw"](r))}catch(r){i(r)}}function c(r){r.done?e(r.value):o(r.value).then(a,u)}c((t=t.apply(r,n||[])).next())}))};var __generator=this&&this.__generator||function(r,n){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=u(0),a["throw"]=u(1),a["return"]=u(2),typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(r){return function(n){return c([r,n])}}function c(u){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(e=0)),e)try{if(t=1,o&&(i=u[0]&2?o["return"]:u[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,u[1])).done)return i;if(o=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:e.label++;return{value:u[1],done:false};case 5:e.label++;o=u[1];u=[0];continue;case 7:u=e.ops.pop();e.trys.pop();continue;default:if(!(i=e.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){e.label=u[1];break}if(u[0]===6&&e.label<i[1]){e.label=i[1];i=u;break}if(i&&e.label<i[2]){e.label=i[2];e.ops.push(u);break}if(i[2])e.ops.pop();e.trys.pop();continue}u=n.call(r,e)}catch(r){u=[6,r];o=0}finally{t=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};System.register(["./p-DTgUqgwV.system.js","./p-DprOoI2W.system.js","./p-6vSUiBfr.system.js","./p-zVLAvre1.system.js","./p-B3GRrRtL.system.js","./p-BbgqQIHv.system.js","./p-ojtNq-r5.system.js"],(function(r){"use strict";var n,e,t,o,i,a,u,c,s,f,d,l,v,p,y,h,b,w,m,_,j,P,k,g,O,E,I;return{setters:[function(r){n=r.z;e=r.c},function(r){t=r.x;o=r.j;i=r.t;a=r.y;u=r.G;c=r.C;s=r.b;f=r.d;d=r.n;l=r.A;v=r.T;p=r.B;y=r.D;h=r.K},function(r){b=r.s;w=r.t},function(r){m=r.h;_=r.g;j=r.l;P=r.j},function(r){k=r.i},function(r){g=r.l},function(r){O=r.i;E=r.a;I=r.s}],execute:function(){
1
+ var __awaiter=this&&this.__awaiter||function(n,r,e,t){function o(n){return n instanceof e?n:new e((function(r){r(n)}))}return new(e||(e=Promise))((function(e,i){function a(n){try{c(t.next(n))}catch(n){i(n)}}function u(n){try{c(t["throw"](n))}catch(n){i(n)}}function c(n){n.done?e(n.value):o(n.value).then(a,u)}c((t=t.apply(n,r||[])).next())}))};var __generator=this&&this.__generator||function(n,r){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},t,o,i,a=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return a.next=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(r){return c([n,r])}}function c(u){if(t)throw new TypeError("Generator is already executing.");while(a&&(a=0,u[0]&&(e=0)),e)try{if(t=1,o&&(i=u[0]&2?o["return"]:u[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,u[1])).done)return i;if(o=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:e.label++;return{value:u[1],done:false};case 5:e.label++;o=u[1];u=[0];continue;case 7:u=e.ops.pop();e.trys.pop();continue;default:if(!(i=e.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){e.label=u[1];break}if(u[0]===6&&e.label<i[1]){e.label=i[1];i=u;break}if(i&&e.label<i[2]){e.label=i[2];e.ops.push(u);break}if(i[2])e.ops.pop();e.trys.pop();continue}u=r.call(n,e)}catch(n){u=[6,n];o=0}finally{t=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};System.register(["./p-DTgUqgwV.system.js","./p-BUfCTQXY.system.js","./p-D-Lnf8mS.system.js","./p-D0DkOoAw.system.js","./p-B3GRrRtL.system.js","./p-BbgqQIHv.system.js","./p-DXlojp_Y.system.js"],(function(n){"use strict";var r,e,t,o,i,a,u,c,s,f,d,l,v,p,y,h,b,w,m,_,j,P,k,g,O,E,I;return{setters:[function(n){r=n.z;e=n.c},function(n){t=n.x;o=n.j;i=n.t;a=n.y;u=n.G;c=n.C;s=n.b;f=n.d;d=n.n;l=n.A;v=n.T;p=n.B;y=n.D;h=n.K},function(n){b=n.s;w=n.t},function(n){m=n.h;_=n.g;j=n.l;P=n.j},function(n){k=n.i},function(n){g=n.l},function(n){O=n.i;E=n.a;I=n.s}],execute:function(){
2
2
  /*!
3
3
  * paypal-js v8.4.2 (2025-09-04T17:21:30.135Z)
4
4
  * Copyright 2020-present, PayPal, Inc. All rights reserved.
@@ -30,45 +30,45 @@ var __awaiter=this&&this.__awaiter||function(r,n,e,t){function o(r){return r ins
30
30
  PERFORMANCE OF THIS SOFTWARE.
31
31
  ***************************************************************************** */
32
32
  /* global Reflect, Promise, SuppressedError, Symbol */
33
- var S=this;function A(r,n){var e={};for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&n.indexOf(t)<0)e[t]=r[t];if(r!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,t=Object.getOwnPropertySymbols(r);o<t.length;o++){if(n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(r,t[o]))e[t[o]]=r[t[o]]}return e}typeof SuppressedError==="function"?SuppressedError:function(r,n,e){var t=new Error(e);return t.name="SuppressedError",t.error=r,t.suppressed=n,t};function x(r,n){var e=document.querySelector('script[src="'.concat(r,'"]'));if(e===null)return null;var t=q(r,n);
33
+ var S=this;function A(n,r){var e={};for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&r.indexOf(t)<0)e[t]=n[t];if(n!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,t=Object.getOwnPropertySymbols(n);o<t.length;o++){if(r.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(n,t[o]))e[t[o]]=n[t[o]]}return e}typeof SuppressedError==="function"?SuppressedError:function(n,r,e){var t=new Error(e);return t.name="SuppressedError",t.error=n,t.suppressed=r,t};function x(n,r){var e=document.querySelector('script[src="'.concat(n,'"]'));if(e===null)return null;var t=D(n,r);
34
34
  // ignore the data-uid-auto attribute that gets auto-assigned to every script tag
35
35
  var o=e.cloneNode();delete o.dataset.uidAuto;
36
36
  // check if the new script has the same number of data attributes
37
37
  if(Object.keys(o.dataset).length!==Object.keys(t.dataset).length){return null}var i=true;
38
38
  // check if the data attribute values are the same
39
- Object.keys(o.dataset).forEach((function(r){if(o.dataset[r]!==t.dataset[r]){i=false}}));return i?e:null}function B(r){var n=r.url,e=r.attributes,t=r.onSuccess,o=r.onError;var i=q(n,e);i.onerror=o;i.onload=t;document.head.insertBefore(i,document.head.firstElementChild)}function L(r){var n=r.sdkBaseUrl,e=r.environment,t=A(r,["sdkBaseUrl","environment"]);var o=n||C(e);var i=t;var a=Object.keys(i).filter((function(r){return typeof i[r]!=="undefined"&&i[r]!==null&&i[r]!==""})).reduce((function(r,n){var e=i[n].toString();n=T(n);if(n.substring(0,4)==="data"||n==="crossorigin"){r.attributes[n]=e}else{r.queryParams[n]=e}return r}),{queryParams:{},attributes:{}}),u=a.queryParams,c=a.attributes;if(u["merchant-id"]&&u["merchant-id"].indexOf(",")!==-1){c["data-merchant-id"]=u["merchant-id"];u["merchant-id"]="*"}return{url:"".concat(o,"?").concat(z(u)),attributes:c}}function T(r){var n=function(r,n){return(n?"-":"")+r.toLowerCase()};return r.replace(/[A-Z]+(?![a-z])|[A-Z]/g,n)}function z(r){var n="";Object.keys(r).forEach((function(e){if(n.length!==0)n+="&";n+=e+"="+r[e]}));return n}function C(r){
39
+ Object.keys(o.dataset).forEach((function(n){if(o.dataset[n]!==t.dataset[n]){i=false}}));return i?e:null}function B(n){var r=n.url,e=n.attributes,t=n.onSuccess,o=n.onError;var i=D(r,e);i.onerror=o;i.onload=t;document.head.insertBefore(i,document.head.firstElementChild)}function T(n){var r=n.sdkBaseUrl,e=n.environment,t=A(n,["sdkBaseUrl","environment"]);var o=r||z(e);var i=t;var a=Object.keys(i).filter((function(n){return typeof i[n]!=="undefined"&&i[n]!==null&&i[n]!==""})).reduce((function(n,r){var e=i[r].toString();r=L(r);if(r.substring(0,4)==="data"||r==="crossorigin"){n.attributes[r]=e}else{n.queryParams[r]=e}return n}),{queryParams:{},attributes:{}}),u=a.queryParams,c=a.attributes;if(u["merchant-id"]&&u["merchant-id"].indexOf(",")!==-1){c["data-merchant-id"]=u["merchant-id"];u["merchant-id"]="*"}return{url:"".concat(o,"?").concat(C(u)),attributes:c}}function L(n){var r=function(n,r){return(r?"-":"")+n.toLowerCase()};return n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,r)}function C(n){var r="";Object.keys(n).forEach((function(e){if(r.length!==0)r+="&";r+=e+"="+n[e]}));return r}function z(n){
40
40
  // Keeping production as default to maintain backward compatibility.
41
41
  // In the future this logic needs to be changed to use sandbox domain as default instead of production.
42
- return r==="sandbox"?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js"}function q(r,n){if(n===void 0){n={}}var e=document.createElement("script");e.src=r;Object.keys(n).forEach((function(r){e.setAttribute(r,n[r]);if(r==="data-csp-nonce"){e.setAttribute("nonce",n["data-csp-nonce"])}}));return e}
42
+ return n==="sandbox"?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js"}function D(n,r){if(r===void 0){r={}}var e=document.createElement("script");e.src=n;Object.keys(r).forEach((function(n){e.setAttribute(n,r[n]);if(n==="data-csp-nonce"){e.setAttribute("nonce",r["data-csp-nonce"])}}));return e}
43
43
  /**
44
44
  * Load the Paypal JS SDK script asynchronously.
45
45
  *
46
46
  * @param {Object} options - used to configure query parameters and data attributes for the JS SDK.
47
47
  * @param {PromiseConstructor} [PromisePonyfill=window.Promise] - optional Promise Constructor ponyfill.
48
48
  * @return {Promise<Object>} paypalObject - reference to the global window PayPal object.
49
- */function M(r,n){if(n===void 0){n=Promise}F(r,n);
49
+ */function M(n,r){if(r===void 0){r=Promise}F(n,r);
50
50
  // resolve with null when running in Node or Deno
51
- if(typeof document==="undefined")return n.resolve(null);var e=L(r),t=e.url,o=e.attributes;var i=o["data-namespace"]||"paypal";var a=R(i);if(!o["data-js-sdk-library"]){o["data-js-sdk-library"]="paypal-js"}
51
+ if(typeof document==="undefined")return r.resolve(null);var e=T(n),t=e.url,o=e.attributes;var i=o["data-namespace"]||"paypal";var a=R(i);if(!o["data-js-sdk-library"]){o["data-js-sdk-library"]="paypal-js"}
52
52
  // resolve with the existing global paypal namespace when a script with the same params already exists
53
- if(x(t,o)&&a){return n.resolve(a)}return D({url:t,attributes:o},n).then((function(){var r=R(i);if(r){return r}throw new Error("The window.".concat(i," global variable is not available."))}))}
53
+ if(x(t,o)&&a){return r.resolve(a)}return q({url:t,attributes:o},r).then((function(){var n=R(i);if(n){return n}throw new Error("The window.".concat(i," global variable is not available."))}))}
54
54
  /**
55
55
  * Load a custom script asynchronously.
56
56
  *
57
57
  * @param {Object} options - used to set the script url and attributes.
58
58
  * @param {PromiseConstructor} [PromisePonyfill=window.Promise] - optional Promise Constructor ponyfill.
59
59
  * @return {Promise<void>} returns a promise to indicate if the script was successfully loaded.
60
- */function D(r,n){if(n===void 0){n=Promise}F(r,n);var e=r.url,t=r.attributes;if(typeof e!=="string"||e.length===0){throw new Error("Invalid url.")}if(typeof t!=="undefined"&&typeof t!=="object"){throw new Error("Expected attributes to be an object.")}return new n((function(r,n){
60
+ */function q(n,r){if(r===void 0){r=Promise}F(n,r);var e=n.url,t=n.attributes;if(typeof e!=="string"||e.length===0){throw new Error("Invalid url.")}if(typeof t!=="undefined"&&typeof t!=="object"){throw new Error("Expected attributes to be an object.")}return new r((function(n,r){
61
61
  // resolve with undefined when running in Node or Deno
62
- if(typeof document==="undefined")return r();B({url:e,attributes:t,onSuccess:function(){return r()},onError:function(){var r=new Error('The script "'.concat(e,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return n(r)}})}))}function R(r){
62
+ if(typeof document==="undefined")return n();B({url:e,attributes:t,onSuccess:function(){return n()},onError:function(){var n=new Error('The script "'.concat(e,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return r(n)}})}))}function R(n){
63
63
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
- return window[r]}function F(r,n){if(typeof r!=="object"||r===null){throw new Error("Expected an options object.")}var e=r.environment;if(e&&e!=="production"&&e!=="sandbox"){throw new Error('The `environment` option must be either "production" or "sandbox".')}if(typeof n!=="undefined"&&typeof n!=="function"){throw new Error("Expected PromisePonyfill to be a function.")}}var N=function(r){return __awaiter(S,[r],void 0,(function(r){var n,e,t;var o=r.checkoutSessionId,i=r.paypalMockResponse;return __generator(this,(function(r){switch(r.label){case 0:return[4/*yield*/,m("/api/zonos-elements/capture-paypal-order",{body:{checkoutSessionId:o,paypalMockResponse:i},method:"POST"})];case 1:n=r.sent(),e=n.errors,t=n.json;return[2/*return*/,{errors:e,json:t}]}}))}))};var U=function(r){return __awaiter(S,[r],void 0,(function(r){var n,e,t;var o=r.checkoutSessionId,i=r.intent;return __generator(this,(function(r){switch(r.label){case 0:return[4/*yield*/,m("/api/zonos-elements/create-paypal-order",{body:{checkoutSessionId:o,intent:i},method:"POST"})];case 1:n=r.sent(),e=n.errors,t=n.json;return[2/*return*/,{errors:e,json:t}]}}))}))};var H=undefined&&undefined.__rest||function(r,n){var e={};for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&n.indexOf(t)<0)e[t]=r[t];if(r!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,t=Object.getOwnPropertySymbols(r);o<t.length;o++){if(n.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(r,t[o]))e[t[o]]=r[t[o]]}return e};
64
+ return window[n]}function F(n,r){if(typeof n!=="object"||n===null){throw new Error("Expected an options object.")}var e=n.environment;if(e&&e!=="production"&&e!=="sandbox"){throw new Error('The `environment` option must be either "production" or "sandbox".')}if(typeof r!=="undefined"&&typeof r!=="function"){throw new Error("Expected PromisePonyfill to be a function.")}}var U=function(n){return __awaiter(S,[n],void 0,(function(n){var r,e,t;var o=n.checkoutSessionId,i=n.paypalMockResponse;return __generator(this,(function(n){switch(n.label){case 0:return[4/*yield*/,m("/api/zonos-elements/capture-paypal-order",{body:{checkoutSessionId:o,paypalMockResponse:i},method:"POST"})];case 1:r=n.sent(),e=r.errors,t=r.json;return[2/*return*/,{errors:e,json:t}]}}))}))};var N=function(n){return __awaiter(S,[n],void 0,(function(n){var r,e,t;var o=n.checkoutSessionId,i=n.intent;return __generator(this,(function(n){switch(n.label){case 0:return[4/*yield*/,m("/api/zonos-elements/create-paypal-order",{body:{checkoutSessionId:o,intent:i},method:"POST"})];case 1:r=n.sent(),e=r.errors,t=r.json;return[2/*return*/,{errors:e,json:t}]}}))}))};var Y=undefined&&undefined.__rest||function(n,r){var e={};for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&r.indexOf(t)<0)e[t]=n[t];if(n!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,t=Object.getOwnPropertySymbols(n);o<t.length;o++){if(r.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(n,t[o]))e[t[o]]=n[t[o]]}return e};
65
65
  /**
66
66
  * Mapping from our internal event names (GA-style) to Facebook Pixel standard event names.
67
67
  * @see https://developers.facebook.com/docs/meta-pixel/reference#standard-events
68
68
  *
69
69
  * Events without an entry have no FB standard equivalent — they are still fired as a custom event
70
70
  * via `fbq('trackCustom', ...)` so merchants can target them.
71
- */var V={purchase:"Purchase","zonos-checkout-payment-info":"AddPaymentInfo","zonos-checkout-start":"InitiateCheckout"};var Y=function(r){var n;return(n=V[r])!==null&&n!==void 0?n:null};var Z=function(r){if(!r)return false;return Array.isArray(r.items)};
71
+ */var H={purchase:"Purchase","zonos-checkout-payment-info":"AddPaymentInfo","zonos-checkout-start":"InitiateCheckout"};var X=function(n){var r;return(r=H[n])!==null&&r!==void 0?r:null};var Z=function(n){if(!n)return false;return Array.isArray(n.items)};
72
72
  /**
73
73
  * Convert a GA-style event payload into a Facebook Pixel parameter object.
74
74
  *
@@ -77,12 +77,12 @@ return window[r]}function F(r,n){if(typeof r!=="object"||r===null){throw new Err
77
77
  * and `content_type: 'product'`. Other primitive params (e.g. `checkoutSessionId`,
78
78
  * `paymentMethod`, `serviceLevelId`) are forwarded as-is so merchants can build
79
79
  * custom audiences on them.
80
- */var G=function(r){if(!r)return{};if(!Z(r)){
80
+ */var G=function(n){if(!n)return{};if(!Z(n)){
81
81
  // Forward primitive metadata as-is for custom events
82
- return Object.assign({},r)}var n=r.currency,e=r.items,t=r.transaction_id,o=r.value,i=H(r,["currency","items","transaction_id","value"]);var a=e.map((function(r){return{id:r.item_id,item_price:r.price,quantity:r.quantity}}));var u=e.map((function(r){return r.item_id}));var c=e.reduce((function(r,n){return r+n.quantity}),0);var s=Object.assign(Object.assign({},i),{content_ids:u,content_type:"product",contents:a,num_items:c});if(t){s.order_id=t}if(n!==undefined){s.currency=n}if(o!==undefined){s.value=o}return s};var K=function(){var r=n.checkoutSettings.analyticsProviders.find((function(r){return r.type==="FACEBOOK_PIXEL"}));return!!r&&r.status==="ENABLED"};var Q=function(r,n,e){if(O()){
82
+ return Object.assign({},n)}var r=n.currency,e=n.items,t=n.transaction_id,o=n.value,i=Y(n,["currency","items","transaction_id","value"]);var a=e.map((function(n){return{id:n.item_id,item_price:n.price,quantity:n.quantity}}));var u=e.map((function(n){return n.item_id}));var c=e.reduce((function(n,r){return n+r.quantity}),0);var s=Object.assign(Object.assign({},i),{content_ids:u,content_type:"product",contents:a,num_items:c});if(t){s.order_id=t}if(r!==undefined){s.currency=r}if(o!==undefined){s.value=o}return s};var Q=function(){var n=r.checkoutSettings.analyticsProviders.find((function(n){return n.type==="FACEBOOK_PIXEL"}));return!!n&&n.status==="ENABLED"};var V=function(n,r,e){if(O()){
83
83
  // fbq does not work in the iframe (Facebook Pixel must be on the parent for proper attribution).
84
84
  // Relay to parent which will call fbq() once the FB Pixel script is ready.
85
- E({event:n,fbqMode:r,payload:e,provider:"fbq"});return}if(typeof window.fbq==="function"){g("Zonos submits fbq event","log","".concat(r,":").concat(n));window.fbq(r,n,e)}};
85
+ E({event:r,fbqMode:n,payload:e,provider:"fbq"});return}if(typeof window.fbq==="function"){g("Zonos submits fbq event","log","".concat(n,":").concat(r));window.fbq(n,r,e)}};
86
86
  /**
87
87
  * Submit a Facebook Pixel event matching the gtag event payload shape.
88
88
  *
@@ -94,14 +94,14 @@ E({event:n,fbqMode:r,payload:e,provider:"fbq"});return}if(typeof window.fbq==="f
94
94
  * FB-formatted parameters.
95
95
  *
96
96
  * @see https://developers.facebook.com/docs/meta-pixel/reference
97
- */var W=function(r){var n=r.event,e=r.metadata;if(!K()){return}var t=_();var o=G(e);var i=Object.assign(Object.assign({},o),t&&{isTestMode:true});
97
+ */var K=function(n){var r=n.event,e=n.metadata;if(!Q()){return}var t=_();var o=G(e);var i=Object.assign(Object.assign({},o),t&&{isTestMode:true});
98
98
  // filter null values
99
- var a=Object.fromEntries(Object.entries(i).filter((function(r){var n=r[0],e=r[1];return e!==null})));
99
+ var a=Object.fromEntries(Object.entries(i).filter((function(n){var r=n[0],e=n[1];return e!==null})));
100
100
  // 1) Always emit the original event as a custom event so merchants can target zonos-xxx names.
101
- Q("trackCustom",n,a);
101
+ V("trackCustom",r,a);
102
102
  // 2) Emit FB standard equivalent if one exists. Skipped when the event itself is the standard
103
103
  // name to avoid double-firing (e.g. 'purchase' -> 'Purchase').
104
- var u=Y(n);if(u&&u!==n){Q("track",u,a)}};
104
+ var u=X(r);if(u&&u!==r){V("track",u,a)}};
105
105
  /**
106
106
  * Fan out an analytics event to every enabled provider.
107
107
  *
@@ -111,30 +111,30 @@ var u=Y(n);if(u&&u!==n){Q("track",u,a)}};
111
111
  * (e.g. `purchase` → `Purchase`, `zonos-checkout-start` → `InitiateCheckout`).
112
112
  *
113
113
  * Each submitter no-ops when its provider is disabled in `analyticsProviders` settings.
114
- */var X=r("s",(function(r){I(r);W(r)}));var J=e((function(){return{intent:"capture",orderIdCreated:null,paypal:null,paypalButtons:[],paypalClientId:"",paypalErrorMessage:null}})),$=J.onChange,rr=J.reset,nr=J.state;r({e:$,c:rr,a:nr});var er=function(r){return __awaiter(S,[r],void 0,(function(r){var n,e,t,o,i,a,u;var c=r.checkoutSessionId;return __generator(this,(function(r){switch(r.label){case 0:t=nr.intent.toUpperCase();return[4/*yield*/,U({checkoutSessionId:c,intent:t})];case 1:o=r.sent(),i=o.errors,a=o.json;u=(n=a===null||a===void 0?void 0:a.paypalOrderCreate)===null||n===void 0?void 0:n.paypalOrderId;if(i.length||!u){throw new Error(((e=i.find(Boolean))===null||e===void 0?void 0:e.message)||"An unexpected error occurred when creating paypal order.")}return[2/*return*/,u]}}))}))};var tr=function(r){return __awaiter(S,[r],void 0,(function(r){var n,e,t,o,i,a;var u=r.checkoutSessionId,c=r.paypalMockResponse;return __generator(this,(function(r){switch(r.label){case 0:return[4/*yield*/,N({checkoutSessionId:u,paypalMockResponse:c})];case 1:t=r.sent(),o=t.errors,i=t.json;a=(n=i===null||i===void 0?void 0:i.paypalOrderCapture.order)===null||n===void 0?void 0:n.id;if(o.length||!a){throw new Error(((e=o.find(Boolean))===null||e===void 0?void 0:e.message)||w("An unexpected error occurred when processing PayPal order."))}return[2/*return*/,a]}}))}))};var or=function(r){var n=r.error;var e;var t=P(n.message);var o=(e=t===null||t===void 0?void 0:t.errors.find(Boolean))===null||e===void 0?void 0:e.message;var i=(o===null||o===void 0?void 0:o.match(/\[(.*?)\] (.*)/i))||[];if(!i){nr.paypalErrorMessage=w("An unexpected error occurred when processing PayPal order.")}var a=i[2]||w("An unexpected error occurred when processing PayPal order.");
114
+ */var J=n("s",(function(n){I(n);K(n)}));var W=e((function(){return{intent:"capture",orderIdCreated:null,paypal:null,paypalButtons:[],paypalClientId:"",paypalErrorMessage:null}})),$=W.onChange,nn=W.reset,rn=W.state;n({e:$,c:nn,a:rn});var en=function(n){return __awaiter(S,[n],void 0,(function(n){var r,e,t,o,i,a,u;var c=n.checkoutSessionId;return __generator(this,(function(n){switch(n.label){case 0:t=rn.intent.toUpperCase();return[4/*yield*/,N({checkoutSessionId:c,intent:t})];case 1:o=n.sent(),i=o.errors,a=o.json;u=(r=a===null||a===void 0?void 0:a.paypalOrderCreate)===null||r===void 0?void 0:r.paypalOrderId;if(i.length||!u){throw new Error(((e=i.find(Boolean))===null||e===void 0?void 0:e.message)||"An unexpected error occurred when creating paypal order.")}return[2/*return*/,u]}}))}))};var tn=function(n){return __awaiter(S,[n],void 0,(function(n){var r,e,t,o,i,a;var u=n.checkoutSessionId,c=n.paypalMockResponse;return __generator(this,(function(n){switch(n.label){case 0:return[4/*yield*/,U({checkoutSessionId:u,paypalMockResponse:c})];case 1:t=n.sent(),o=t.errors,i=t.json;a=(r=i===null||i===void 0?void 0:i.paypalOrderCapture.order)===null||r===void 0?void 0:r.id;if(o.length||!a){throw new Error(((e=o.find(Boolean))===null||e===void 0?void 0:e.message)||w("An unexpected error occurred when processing PayPal order."))}return[2/*return*/,a]}}))}))};var on=function(n){var r=n.error;var e;var t=P(r.message);var o=(e=t===null||t===void 0?void 0:t.errors.find(Boolean))===null||e===void 0?void 0:e.message;var i=(o===null||o===void 0?void 0:o.match(/\[(.*?)\] (.*)/i))||[];if(!i){rn.paypalErrorMessage=w("An unexpected error occurred when processing PayPal order.")}var a=i[2]||w("An unexpected error occurred when processing PayPal order.");
115
115
  // show the error message
116
- nr.paypalErrorMessage=a};
116
+ rn.paypalErrorMessage=a};
117
117
  /**
118
118
  * This function generates the options for the PayPal button component.
119
119
  * It first retrieves the primary color from the store and checks if it contrasts with PayPal's gold color.
120
120
  * It then returns an object with the createOrder function and the style for the PayPal button.
121
121
  * The createOrder function makes a call to the PayPal API to create an order and returns the order ID.
122
122
  * The style object sets the border radius, color, and shape of the PayPal button.
123
- */var ir=function(r){var e=r.checkoutSessionId,b=r.onPaypalFail,m=r.onPaypalSessionDone,_=r.overrideBorderRaidus,P=r.overridePrimaryColor;var g=P||n.appearance.colorPrimary;
123
+ */var an=function(n){var e=n.checkoutSessionId,b=n.onPaypalFail,m=n.onPaypalSessionDone,_=n.overrideBorderRaidus,P=n.overridePrimaryColor;var g=P||r.appearance.colorPrimary;
124
124
  // Paypal gold color
125
125
  var O="#ffc33a";
126
126
  // check if the paypal gold color is contrast to the background
127
- var E=k({backgroundColor1:O,backgroundColor2:g||""});return{createOrder:function(){return __awaiter(S,void 0,void 0,(function(){var r,n,_,P,k,g,O,E,I,S,A;return __generator(this,(function(x){switch(x.label){case 0:
127
+ var E=k({backgroundColor1:O,backgroundColor2:g||""});return{createOrder:function(){return __awaiter(S,void 0,void 0,(function(){var n,r,_,P,k,g,O,E,I,S,A;return __generator(this,(function(x){switch(x.label){case 0:
128
128
  // Clicking on the paypal button should trigger the paymentInfoCompleted event
129
129
  void i({checkoutSessionId:e,eventName:"checkout_paymentInfoCompleted",metadata:{paymentMethod:"paypal"}});
130
130
  // Block PayPal submit when the merchant requires policy consent and the
131
131
  // buyer hasn't accepted. Mirrors the Pay-button gate so both flows enforce
132
132
  // the same legal contract.
133
- if(a()&&!u.accepted){u.showError=true;(r=document.querySelector("zonos-policy-consent"))===null||r===void 0?void 0:r.scrollIntoView({behavior:"smooth"});b===null||b===void 0?void 0:b();return[2/*return*/,""]}n=a();if(n){u.locked=true}_=false;x.label=1;case 1:x.trys.push([1,13,14,15]);return[4/*yield*/,c()];case 2:P=x.sent();if(!P.valid){nr.paypalErrorMessage=P.errorMessage;
133
+ if(a()&&!u.accepted){u.showError=true;(n=document.querySelector("zonos-policy-consent"))===null||n===void 0?void 0:n.scrollIntoView({behavior:"smooth"});b===null||b===void 0?void 0:b();return[2/*return*/,""]}r=a();if(r){u.locked=true}_=false;x.label=1;case 1:x.trys.push([1,13,14,15]);return[4/*yield*/,c()];case 2:P=x.sent();if(!P.valid){rn.paypalErrorMessage=P.errorMessage;
134
134
  // reset stripe error message
135
- s.hasPaymentError=false;s.customErrorMessage=null;X({event:"zonos-checkout-payment-fail",metadata:{checkoutSessionId:e}});b===null||b===void 0?void 0:b();return[2/*return*/,""]}
135
+ s.hasPaymentError=false;s.customErrorMessage=null;J({event:"zonos-checkout-payment-fail",metadata:{checkoutSessionId:e}});b===null||b===void 0?void 0:b();return[2/*return*/,""]}
136
136
  // reset paypal error banner
137
- nr.paypalErrorMessage=null;
137
+ rn.paypalErrorMessage=null;
138
138
  // reset inventory check error message
139
139
  f.inventoryCheckErrorMessage=null;x.label=3;case 3:x.trys.push([3,5,,6]);
140
140
  // check inventory before proceeding to payment
@@ -144,7 +144,7 @@ k.inventoryCheckErrorMessage=x.sent();return[3/*break*/,6];case 5:g=x.sent();
144
144
  // If user provide callback and it throw an exception, default to this message and stop the payment.
145
145
  f.inventoryCheckErrorMessage=w("Unable to check inventory. Please try again.");return[3/*break*/,6];case 6:
146
146
  // Don't proceed to payment if there's an error message
147
- if(f.inventoryCheckErrorMessage){return[2/*return*/,""]}O=h();if(!(O>0))return[3/*break*/,8];return[4/*yield*/,l()];case 7:E=x.sent();if(!E.success){nr.paypalErrorMessage=E.error||w("Unable to apply store credit. Please try again.");b===null||b===void 0?void 0:b();return[2/*return*/,""]}x.label=8;case 8:
147
+ if(f.inventoryCheckErrorMessage){return[2/*return*/,""]}O=h();if(!(O>0))return[3/*break*/,8];return[4/*yield*/,l()];case 7:E=x.sent();if(!E.success){rn.paypalErrorMessage=E.error||w("Unable to apply store credit. Please try again.");b===null||b===void 0?void 0:b();return[2/*return*/,""]}x.label=8;case 8:
148
148
  // Persist consent into the checkout session metadata BEFORE either
149
149
  // branch creates the order — both the store-credit-only path and the
150
150
  // real PayPal path need the consent recorded. A transient failure here
@@ -158,36 +158,36 @@ return[4/*yield*/,v()];case 9:
158
158
  // is logged (via `logError` inside the helper) but does NOT block the
159
159
  // order: blocking on a flaky network would gate buyers from paying,
160
160
  // and the buyer's consent intent is already captured client-side.
161
- x.sent();if(!p())return[3/*break*/,11];return[4/*yield*/,y()];case 10:I=x.sent();if(!I.success){nr.paypalErrorMessage=I.error||w("Unable to place order with store credit. Please try again.");b===null||b===void 0?void 0:b();return[2/*return*/,""]}m===null||m===void 0?void 0:m({orderId:I.orderId||""});t();o();
161
+ x.sent();if(!p())return[3/*break*/,11];return[4/*yield*/,y()];case 10:I=x.sent();if(!I.success){rn.paypalErrorMessage=I.error||w("Unable to place order with store credit. Please try again.");b===null||b===void 0?void 0:b();return[2/*return*/,""]}m===null||m===void 0?void 0:m({orderId:I.orderId||""});t();o();
162
162
  // Store-credit-only success: the cart advances to the next step
163
163
  // and the store reset on close will handle the lock cleanup.
164
- _=true;return[2/*return*/,""];case 11:return[4/*yield*/,er({checkoutSessionId:e})];case 12:S=x.sent();
164
+ _=true;return[2/*return*/,""];case 11:return[4/*yield*/,en({checkoutSessionId:e})];case 12:S=x.sent();
165
165
  // Successful hand-off to PayPal — the popup opens next and onApprove
166
166
  // will fire on completion. Keep the lock set so closes/resets later
167
167
  // clean up; an empty ID falls through to the unlock in `finally`.
168
- _=!!S;return[2/*return*/,S];case 13:A=x.sent();j("Failed to create paypal order",A);nr.paypalErrorMessage=w("Failed to create PayPal order. Please try again, or consider using an alternative method.");
168
+ _=!!S;return[2/*return*/,S];case 13:A=x.sent();j("Failed to create paypal order",A);rn.paypalErrorMessage=w("Failed to create PayPal order. Please try again, or consider using an alternative method.");
169
169
  // reset stripe error message
170
- s.hasPaymentError=false;s.customErrorMessage=null;X({event:"zonos-checkout-payment-fail",metadata:{checkoutSessionId:e}});
170
+ s.hasPaymentError=false;s.customErrorMessage=null;J({event:"zonos-checkout-payment-fail",metadata:{checkoutSessionId:e}});
171
171
  // trigger fail event
172
172
  b===null||b===void 0?void 0:b();return[2/*return*/,""];case 14:
173
173
  // Clear the lock unless we successfully handed off the order — on
174
174
  // failures the buyer needs to be able to uncheck and retry.
175
- if(n&&!_){u.locked=false}return[7/*endfinally*/];case 15:return[2/*return*/]}}))}))},onApprove:function(r,n){return __awaiter(S,void 0,void 0,(function(){var r,n;return __generator(this,(function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);
175
+ if(r&&!_){u.locked=false}return[7/*endfinally*/];case 15:return[2/*return*/]}}))}))},onApprove:function(n,r){return __awaiter(S,void 0,void 0,(function(){var n,r;return __generator(this,(function(i){switch(i.label){case 0:i.trys.push([0,2,,3]);
176
176
  // reset paypal error banner
177
- nr.paypalErrorMessage=null;
177
+ rn.paypalErrorMessage=null;
178
178
  // submit google tag when the form is complete
179
- X({event:"zonos-checkout-payment-info",metadata:{checkoutSessionId:e,paymentMethod:"paypal"}});return[4/*yield*/,tr({checkoutSessionId:e,paypalMockResponse:window.Zonos._paypalMockResponse})];case 1:r=i.sent();nr.orderIdCreated=r;m===null||m===void 0?void 0:m({orderId:r});t();
179
+ J({event:"zonos-checkout-payment-info",metadata:{checkoutSessionId:e,paymentMethod:"paypal"}});return[4/*yield*/,tn({checkoutSessionId:e,paypalMockResponse:window.Zonos._paypalMockResponse})];case 1:n=i.sent();rn.orderIdCreated=n;m===null||m===void 0?void 0:m({orderId:n});t();
180
180
  // clear the checkout session timeout timer when purchase is complete
181
- o();return[3/*break*/,3];case 2:n=i.sent();j("==== Failed to capture paypal order",n);if(n instanceof Error){return[2/*return*/,or({error:n})]}b===null||b===void 0?void 0:b();return[3/*break*/,3];case 3:return[2/*return*/]}}))}))},style:{
181
+ o();return[3/*break*/,3];case 2:r=i.sent();j("==== Failed to capture paypal order",r);if(r instanceof Error){return[2/*return*/,on({error:r})]}b===null||b===void 0?void 0:b();return[3/*break*/,3];case 3:return[2/*return*/]}}))}))},style:{
182
182
  // @ts-ignore
183
- borderRadius:_==="SHARP"?0:10,color:E?"gold":"blue",shape:"rect"}}};var ar=function(){if(!nr.paypalButtons.length){
183
+ borderRadius:_==="SHARP"?0:10,color:E?"gold":"blue",shape:"rect"}}};var un=function(){if(!rn.paypalButtons.length){
184
184
  // Do nothing if the buttons array is already empty
185
185
  return}
186
186
  // Close all paypal buttons so we can re-init them
187
- nr.paypalButtons.forEach((function(r){return __awaiter(S,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:return[4/*yield*/,r.close()];case 1:n.sent();return[2/*return*/]}}))}))}));
187
+ rn.paypalButtons.forEach((function(n){return __awaiter(S,void 0,void 0,(function(){return __generator(this,(function(r){switch(r.label){case 0:return[4/*yield*/,n.close()];case 1:r.sent();return[2/*return*/]}}))}))}));
188
188
  // clean up the buttons
189
- nr.paypalButtons=[]};var ur=r("b",(function(r){return __awaiter(S,[r],void 0,(function(r){var e,t,o,i,a,u;var c=r.currency;return __generator(this,(function(r){switch(r.label){case 0:t=!!((e=n.checkoutSettings.externalPaymentMethods)===null||e===void 0?void 0:e.find((function(r){return r.type==="PAYPAL"&&r.status==="ENABLED"})));if(!t){g("=== Paypal is disabled for this store","warn");return[2/*return*/]}o=n.checkoutSettings.externalServiceTokens.find((function(r){return r.type==="PAYPAL_CLIENT_ID"}));if(!o){g("Failed to load paypal -- missing paypal publishable key","warn");return[2/*return*/]}i=(!n.zonosMode||n.zonosMode==="production")&&n.checkoutSettings.mode==="LIVE"?"production":"sandbox";a=n.checkoutSettings.captureDelay&&n.checkoutSettings.captureDelay>0;nr.intent=a?"authorize":"capture";g("==== Paypal order intent","info",nr.intent);
189
+ rn.paypalButtons=[]};var cn=n("b",(function(n){return __awaiter(S,[n],void 0,(function(n){var e,t,o,i,a,u;var c=n.currency;return __generator(this,(function(n){switch(n.label){case 0:t=!!((e=r.checkoutSettings.externalPaymentMethods)===null||e===void 0?void 0:e.find((function(n){return n.type==="PAYPAL"&&n.status==="ENABLED"})));if(!t){g("=== Paypal is disabled for this store","warn");return[2/*return*/]}o=r.checkoutSettings.externalServiceTokens.find((function(n){return n.type==="PAYPAL_CLIENT_ID"}));if(!o){g("Failed to load paypal -- missing paypal publishable key","warn");return[2/*return*/]}i=(!r.zonosMode||r.zonosMode==="production")&&r.checkoutSettings.mode==="LIVE"?"production":"sandbox";a=r.checkoutSettings.captureDelay&&r.checkoutSettings.captureDelay>0;rn.intent=a?"authorize":"capture";g("==== Paypal order intent","info",rn.intent);
190
190
  // send paypal publishable key out to load paypal
191
- u=window.Zonos;return[4/*yield*/,M({clientId:o.token,currency:c,environment:i,intent:nr.intent})];case 1:
191
+ u=window.Zonos;return[4/*yield*/,M({clientId:o.token,currency:c,environment:i,intent:rn.intent})];case 1:
192
192
  // send paypal publishable key out to load paypal
193
- u.paypal=r.sent();nr.paypal=window.Zonos.paypal;g("==== Paypal script loaded");return[2/*return*/]}}))}))}));var cr=r("d",(function(r){var n;var e=window.Zonos.paypal;if(!e){g("Paypal is not available");return null}var t=b.checkoutSessionId;if(!t){g("Paypal is not available due to checkoutSessionId is not available");return null}g("==== Loading Paypal buttons");ar();var o=[(n=e.FUNDING)===null||n===void 0?void 0:n.PAYPAL].filter(Boolean);nr.paypalButtons=o.map((function(n){var o;var i=null;try{i=((o=e.Buttons)===null||o===void 0?void 0:o.call(e,Object.assign(Object.assign({},ir(Object.assign({checkoutSessionId:t,fundingSource:n},r))),{fundingSource:n})))||null}catch(r){g("===== Failed to load paypal's \"".concat(n,'" button'),"warn",r)}if(i===null||i===void 0?void 0:i.isEligible()){g("==== Paypal button ".concat(n," loaded"));return i}return null})).filter(Boolean);return nr.paypalButtons}));var sr=r("p",(function(){var r,e;var t=((e=(r=n.checkoutSettings.externalPaymentMethods)===null||r===void 0?void 0:r.find((function(r){return r.type==="PAYPAL"})))===null||e===void 0?void 0:e.status)==="ENABLED";return t||!!nr.paypalButtons.length}))}}}));
193
+ u.paypal=n.sent();rn.paypal=window.Zonos.paypal;g("==== Paypal script loaded");return[2/*return*/]}}))}))}));var sn=n("d",(function(n){var r;var e=window.Zonos.paypal;if(!e){g("Paypal is not available");return null}var t=b.checkoutSessionId;if(!t){g("Paypal is not available due to checkoutSessionId is not available");return null}g("==== Loading Paypal buttons");un();var o=[(r=e.FUNDING)===null||r===void 0?void 0:r.PAYPAL].filter(Boolean);rn.paypalButtons=o.map((function(r){var o;var i=null;try{i=((o=e.Buttons)===null||o===void 0?void 0:o.call(e,Object.assign(Object.assign({},an(Object.assign({checkoutSessionId:t,fundingSource:r},n))),{fundingSource:r})))||null}catch(n){g("===== Failed to load paypal's \"".concat(r,'" button'),"warn",n)}if(i===null||i===void 0?void 0:i.isEligible()){g("==== Paypal button ".concat(r," loaded"));return i}return null})).filter(Boolean);return rn.paypalButtons}));var fn=n("p",(function(){var n,e;var t=((e=(n=r.checkoutSettings.externalPaymentMethods)===null||n===void 0?void 0:n.find((function(n){return n.type==="PAYPAL"})))===null||e===void 0?void 0:e.status)==="ENABLED";return t||!!rn.paypalButtons.length}))}}}));