@zonos/elements 1.3.18-alpha.2 → 1.3.18-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (334) hide show
  1. package/README.md +341 -96
  2. package/dist/cjs/{cart-941a31dd.js → cart-5468dfd1.js} +29 -84
  3. package/dist/cjs/index.cjs.js +624 -0
  4. package/dist/cjs/logError-4e2f2020.js +58 -0
  5. package/dist/cjs/{submitGtag-9210b4fe.js → submitGtag-127a220f.js} +3 -2
  6. package/dist/cjs/zonos-address_8.cjs.entry.js +13 -12
  7. package/dist/cjs/zonos-badge_2.cjs.entry.js +3 -3
  8. package/dist/cjs/zonos-button_3.cjs.entry.js +3 -3
  9. package/dist/cjs/zonos-card_2.cjs.entry.js +7 -6
  10. package/dist/cjs/zonos-cart-items_11.cjs.entry.js +11 -10
  11. package/dist/cjs/zonos-checkout.cjs.entry.js +15 -14
  12. package/dist/cjs/zonos-controller.cjs.entry.js +25 -20
  13. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -1
  14. package/dist/cjs/zonos-country-select_3.cjs.entry.js +6 -5
  15. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -1
  16. package/dist/cjs/zonos-hello.cjs.entry.js +10 -9
  17. package/dist/cjs/zonos-input.cjs.entry.js +4 -4
  18. package/dist/cjs/zonos-link.cjs.entry.js +1 -1
  19. package/dist/cjs/zonos-payment.cjs.entry.js +3 -2
  20. package/dist/collection/__mocks__/zonos-url/index.js +1 -0
  21. package/dist/collection/__tests__/build-utils/urlCheckOne.js +1 -1
  22. package/dist/collection/collection-manifest.json +1 -1
  23. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +4 -9
  24. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +3 -3
  25. package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +3 -3
  26. package/dist/collection/components/common/zonos-badge/zonos-badge.js +3 -3
  27. package/dist/collection/components/common/zonos-button/zonos-button.js +3 -3
  28. package/dist/collection/components/common/zonos-card/zonos-card.js +3 -3
  29. package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.js +3 -3
  30. package/dist/collection/components/common/zonos-checkout-progress-tabs/zonos-checkout-progress-tabs.js +3 -3
  31. package/dist/collection/components/common/zonos-collapse/zonos-collapse.js +2 -2
  32. package/dist/collection/components/common/zonos-confirm-dialog/zonos-confirm-dialog.js +3 -3
  33. package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +2 -2
  34. package/dist/collection/components/common/zonos-custom-message/zonos-custom-message.js +2 -2
  35. package/dist/collection/components/common/zonos-dialog/zonos-dialog.js +3 -3
  36. package/dist/collection/components/common/zonos-input/zonos-input.js +4 -4
  37. package/dist/collection/components/common/zonos-language-select/zonos-language-select.js +2 -2
  38. package/dist/collection/components/common/{component-template/zonos-link → zonos-link}/zonos-link.js +1 -1
  39. package/dist/collection/components/main/zonos-controller.js +10 -6
  40. package/dist/collection/components/stripe/zonos-address/zonos-address.js +3 -3
  41. package/dist/collection/environment.js +0 -2
  42. package/dist/collection/index.js +1 -0
  43. package/dist/collection/scripts/_extractZonosQaUrl.js +26 -0
  44. package/dist/collection/scripts/_getZonosQaUrl.js +40 -0
  45. package/dist/collection/scripts/{loadStripe.js → _loadStripe.js} +1 -1
  46. package/dist/collection/scripts/{zonosBase.js → _zonosBase.js} +29 -6
  47. package/dist/collection/scripts/index.js +2 -0
  48. package/dist/collection/types/generated/graphql.customer.types.js +1 -0
  49. package/dist/collection/types/generated/graphql.frontend.types.js +1 -0
  50. package/dist/esm/{cart-cc593c2b.js → cart-63d120e1.js} +2 -55
  51. package/dist/esm/index.js +621 -0
  52. package/dist/esm/logError-c456c092.js +55 -0
  53. package/dist/esm/{submitGtag-e50f903f.js → submitGtag-35bb3945.js} +2 -1
  54. package/dist/esm/zonos-address_8.entry.js +11 -10
  55. package/dist/esm/zonos-badge_2.entry.js +3 -3
  56. package/dist/esm/zonos-button_3.entry.js +3 -3
  57. package/dist/esm/zonos-card_2.entry.js +7 -6
  58. package/dist/esm/zonos-cart-items_11.entry.js +11 -10
  59. package/dist/esm/zonos-checkout.entry.js +3 -2
  60. package/dist/esm/zonos-controller.entry.js +8 -3
  61. package/dist/esm/zonos-country-flag.entry.js +2 -1
  62. package/dist/esm/zonos-country-select_3.entry.js +6 -5
  63. package/dist/esm/zonos-hello-dialog.entry.js +2 -1
  64. package/dist/esm/zonos-hello.entry.js +2 -1
  65. package/dist/esm/zonos-input.entry.js +4 -4
  66. package/dist/esm/zonos-link.entry.js +1 -1
  67. package/dist/esm/zonos-payment.entry.js +2 -1
  68. package/dist/esm-es5/cart-63d120e1.js +1 -0
  69. package/dist/esm-es5/index.js +1 -0
  70. package/dist/esm-es5/logError-c456c092.js +1 -0
  71. package/dist/esm-es5/submitGtag-35bb3945.js +1 -0
  72. package/dist/esm-es5/zonos-address_8.entry.js +1 -1
  73. package/dist/esm-es5/zonos-badge_2.entry.js +1 -1
  74. package/dist/esm-es5/zonos-button_3.entry.js +1 -1
  75. package/dist/esm-es5/zonos-card_2.entry.js +1 -1
  76. package/dist/esm-es5/zonos-cart-items_11.entry.js +1 -1
  77. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  78. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  79. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  80. package/dist/esm-es5/zonos-country-select_3.entry.js +1 -1
  81. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  82. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  83. package/dist/esm-es5/zonos-input.entry.js +1 -1
  84. package/dist/esm-es5/zonos-link.entry.js +1 -1
  85. package/dist/esm-es5/zonos-payment.entry.js +1 -1
  86. package/dist/scripts/index.d.ts +3908 -0
  87. package/dist/scripts/index.js +1 -0
  88. package/dist/scripts/loadZonos.d.ts +3954 -0
  89. package/dist/scripts/loadZonos.js +1 -1
  90. package/dist/scripts/zonos.js +1 -1
  91. package/dist/types/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.d.ts +5 -7
  92. package/dist/types/components/checkout/zonos-checkout/zonos-checkout.d.ts +2 -2
  93. package/dist/types/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.d.ts +2 -2
  94. package/dist/types/components/main/zonos-controller.d.ts +1 -1
  95. package/dist/types/components/store/checkout/stripe.d.ts +1 -1
  96. package/dist/types/components/store/zonosStore.d.ts +1 -1
  97. package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +2 -2
  98. package/dist/types/components/utils/styles.d.ts +1 -0
  99. package/dist/types/components.d.ts +22 -14
  100. package/dist/types/index.d.ts +1 -0
  101. package/dist/types/scripts/_extractZonosQaUrl.d.ts +11 -0
  102. package/dist/types/scripts/_getZonosQaUrl.d.ts +4 -0
  103. package/dist/types/scripts/{loadStripe.d.ts → _loadStripe.d.ts} +1 -1
  104. package/dist/types/scripts/{zonosBase.d.ts → _zonosBase.d.ts} +36 -2
  105. package/dist/types/scripts/index.d.ts +2 -0
  106. package/dist/types/types/checkout/CheckoutConfig.d.ts +5 -0
  107. package/dist/types/types/checkout/api/CalculateLandedCostRequest.d.ts +9 -0
  108. package/dist/types/types/generated/graphql.customer.types.d.ts +1 -0
  109. package/dist/types/types/generated/graphql.customer.types.ts +3 -0
  110. package/dist/types/types/generated/graphql.frontend.types.d.ts +1 -0
  111. package/dist/types/types/generated/graphql.frontend.types.ts +1 -0
  112. package/dist/types/types/global.d.ts +1 -1
  113. package/dist/zonos-elements/index.esm.js +1 -0
  114. package/dist/zonos-elements/p-023c764c.system.entry.js +1 -0
  115. package/dist/zonos-elements/p-06b6ce37.system.entry.js +1 -0
  116. package/dist/zonos-elements/p-07c53d83.entry.js +1 -0
  117. package/dist/zonos-elements/{p-9aab3ad7.entry.js → p-0d5b5bcc.entry.js} +1 -1
  118. package/dist/zonos-elements/p-200b661c.entry.js +1 -0
  119. package/dist/zonos-elements/p-3b66df06.system.entry.js +1 -0
  120. package/dist/zonos-elements/{p-020a9b86.entry.js → p-3ba8838a.entry.js} +1 -1
  121. package/dist/zonos-elements/p-428c034a.entry.js +1 -0
  122. package/dist/zonos-elements/p-43b2d28d.system.entry.js +1 -0
  123. package/dist/zonos-elements/p-47a42a30.js +1 -0
  124. package/dist/zonos-elements/{p-d0bc8902.system.entry.js → p-4f72bfee.system.entry.js} +1 -1
  125. package/dist/zonos-elements/p-4fc1459c.entry.js +1 -0
  126. package/dist/zonos-elements/p-4fca8fd5.system.entry.js +1 -0
  127. package/dist/zonos-elements/{p-9e9c318b.entry.js → p-58fc8ec1.entry.js} +1 -1
  128. package/dist/zonos-elements/p-63db40b9.system.js +1 -0
  129. package/dist/zonos-elements/{p-c20e5430.entry.js → p-6cb9812b.entry.js} +1 -1
  130. package/dist/zonos-elements/p-6df1fc3a.system.entry.js +1 -0
  131. package/dist/zonos-elements/p-6f6f160d.entry.js +1 -0
  132. package/dist/zonos-elements/p-7c78e340.entry.js +1 -0
  133. package/dist/zonos-elements/p-808fa731.js +1 -0
  134. package/dist/zonos-elements/p-80f174b9.system.js +1 -0
  135. package/dist/zonos-elements/p-85f3d13f.system.js +1 -0
  136. package/dist/zonos-elements/p-8aeb0629.entry.js +1 -0
  137. package/dist/zonos-elements/p-9288fd21.system.entry.js +1 -0
  138. package/dist/zonos-elements/p-98ad4ab3.system.entry.js +1 -0
  139. package/dist/zonos-elements/p-b1567fa3.system.entry.js +1 -0
  140. package/dist/zonos-elements/p-b81562f5.entry.js +1 -0
  141. package/dist/zonos-elements/{p-96b8c9ba.system.entry.js → p-bdfa3705.system.entry.js} +1 -1
  142. package/dist/zonos-elements/p-cfae51c1.system.js +1 -0
  143. package/dist/zonos-elements/p-d6eb260c.entry.js +1 -0
  144. package/dist/zonos-elements/p-dc40a60c.entry.js +1 -0
  145. package/dist/zonos-elements/{p-3e26d7b3.system.entry.js → p-dda78e8e.system.entry.js} +1 -1
  146. package/dist/zonos-elements/p-de405d7e.system.entry.js +1 -0
  147. package/dist/zonos-elements/p-e0bf9666.system.js +1 -1
  148. package/dist/zonos-elements/p-eaa335e1.js +1 -0
  149. package/dist/zonos-elements/{p-e13bfbda.system.entry.js → p-ed3524ae.system.entry.js} +1 -1
  150. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  151. package/package.json +4 -2
  152. package/dist/components/ILanguage.js +0 -24
  153. package/dist/components/classes.js +0 -12
  154. package/dist/components/containsNonLatinChars.js +0 -21
  155. package/dist/components/formatCurrency.js +0 -11
  156. package/dist/components/getBorderRadius.js +0 -18
  157. package/dist/components/index.d.ts +0 -33
  158. package/dist/components/index.js +0 -1
  159. package/dist/components/isCheckoutMobile.js +0 -6
  160. package/dist/components/isColorVariable.js +0 -14
  161. package/dist/components/isDarkColor.js +0 -1199
  162. package/dist/components/stripe.js +0 -1691
  163. package/dist/components/submitGtag.js +0 -19
  164. package/dist/components/trackConversionEvent.js +0 -37
  165. package/dist/components/translationStore.js +0 -5611
  166. package/dist/components/zonos-address-display.d.ts +0 -11
  167. package/dist/components/zonos-address-display.js +0 -6
  168. package/dist/components/zonos-address-display2.js +0 -64
  169. package/dist/components/zonos-address-form.d.ts +0 -11
  170. package/dist/components/zonos-address-form.js +0 -6
  171. package/dist/components/zonos-address-form2.js +0 -84
  172. package/dist/components/zonos-address-update-dialog.d.ts +0 -11
  173. package/dist/components/zonos-address-update-dialog.js +0 -6
  174. package/dist/components/zonos-address-update-dialog2.js +0 -264
  175. package/dist/components/zonos-address.d.ts +0 -11
  176. package/dist/components/zonos-address.js +0 -6
  177. package/dist/components/zonos-address2.js +0 -176
  178. package/dist/components/zonos-badge.d.ts +0 -11
  179. package/dist/components/zonos-badge.js +0 -6
  180. package/dist/components/zonos-badge2.js +0 -61
  181. package/dist/components/zonos-banner.d.ts +0 -11
  182. package/dist/components/zonos-banner.js +0 -6
  183. package/dist/components/zonos-banner2.js +0 -95
  184. package/dist/components/zonos-button.d.ts +0 -11
  185. package/dist/components/zonos-button.js +0 -6
  186. package/dist/components/zonos-button2.js +0 -186
  187. package/dist/components/zonos-card.d.ts +0 -11
  188. package/dist/components/zonos-card.js +0 -6
  189. package/dist/components/zonos-card2.js +0 -57
  190. package/dist/components/zonos-cart-items.d.ts +0 -11
  191. package/dist/components/zonos-cart-items.js +0 -6
  192. package/dist/components/zonos-cart-items2.js +0 -57
  193. package/dist/components/zonos-cart-restricted-items.d.ts +0 -11
  194. package/dist/components/zonos-cart-restricted-items.js +0 -6
  195. package/dist/components/zonos-cart-restricted-items2.js +0 -135
  196. package/dist/components/zonos-cart-subtotal.d.ts +0 -11
  197. package/dist/components/zonos-cart-subtotal.js +0 -6
  198. package/dist/components/zonos-cart-subtotal2.js +0 -91
  199. package/dist/components/zonos-checkbox.d.ts +0 -11
  200. package/dist/components/zonos-checkbox.js +0 -6
  201. package/dist/components/zonos-checkbox2.js +0 -96
  202. package/dist/components/zonos-checkout-finish.d.ts +0 -11
  203. package/dist/components/zonos-checkout-finish.js +0 -6
  204. package/dist/components/zonos-checkout-finish2.js +0 -246
  205. package/dist/components/zonos-checkout-footer.d.ts +0 -11
  206. package/dist/components/zonos-checkout-footer.js +0 -6
  207. package/dist/components/zonos-checkout-footer2.js +0 -125
  208. package/dist/components/zonos-checkout-payment.d.ts +0 -11
  209. package/dist/components/zonos-checkout-payment.js +0 -6
  210. package/dist/components/zonos-checkout-payment2.js +0 -104
  211. package/dist/components/zonos-checkout-progress-tabs.d.ts +0 -11
  212. package/dist/components/zonos-checkout-progress-tabs.js +0 -6
  213. package/dist/components/zonos-checkout-progress-tabs2.js +0 -138
  214. package/dist/components/zonos-checkout.d.ts +0 -11
  215. package/dist/components/zonos-checkout.js +0 -1051
  216. package/dist/components/zonos-collapse.d.ts +0 -11
  217. package/dist/components/zonos-collapse.js +0 -6
  218. package/dist/components/zonos-collapse2.js +0 -78
  219. package/dist/components/zonos-component.d.ts +0 -11
  220. package/dist/components/zonos-component.js +0 -48
  221. package/dist/components/zonos-confirm-dialog.d.ts +0 -11
  222. package/dist/components/zonos-confirm-dialog.js +0 -6
  223. package/dist/components/zonos-confirm-dialog2.js +0 -161
  224. package/dist/components/zonos-controller.d.ts +0 -11
  225. package/dist/components/zonos-controller.js +0 -309
  226. package/dist/components/zonos-country-flag.d.ts +0 -11
  227. package/dist/components/zonos-country-flag.js +0 -6
  228. package/dist/components/zonos-country-flag2.js +0 -54
  229. package/dist/components/zonos-country-select.d.ts +0 -11
  230. package/dist/components/zonos-country-select.js +0 -6
  231. package/dist/components/zonos-country-select2.js +0 -1891
  232. package/dist/components/zonos-custom-message.d.ts +0 -11
  233. package/dist/components/zonos-custom-message.js +0 -6
  234. package/dist/components/zonos-custom-message2.js +0 -72
  235. package/dist/components/zonos-customer-info.d.ts +0 -11
  236. package/dist/components/zonos-customer-info.js +0 -6
  237. package/dist/components/zonos-customer-info2.js +0 -316
  238. package/dist/components/zonos-dialog.d.ts +0 -11
  239. package/dist/components/zonos-dialog.js +0 -6
  240. package/dist/components/zonos-dialog2.js +0 -136
  241. package/dist/components/zonos-hello-dialog-footer.d.ts +0 -11
  242. package/dist/components/zonos-hello-dialog-footer.js +0 -6
  243. package/dist/components/zonos-hello-dialog-footer2.js +0 -83
  244. package/dist/components/zonos-hello-dialog.d.ts +0 -11
  245. package/dist/components/zonos-hello-dialog.js +0 -6
  246. package/dist/components/zonos-hello-dialog2.js +0 -305
  247. package/dist/components/zonos-hello.d.ts +0 -11
  248. package/dist/components/zonos-hello.js +0 -879
  249. package/dist/components/zonos-icon.d.ts +0 -11
  250. package/dist/components/zonos-icon.js +0 -6
  251. package/dist/components/zonos-icon2.js +0 -55
  252. package/dist/components/zonos-input.d.ts +0 -11
  253. package/dist/components/zonos-input.js +0 -6
  254. package/dist/components/zonos-input2.js +0 -78
  255. package/dist/components/zonos-language-select.d.ts +0 -11
  256. package/dist/components/zonos-language-select.js +0 -6
  257. package/dist/components/zonos-language-select2.js +0 -88
  258. package/dist/components/zonos-link-authentication.d.ts +0 -11
  259. package/dist/components/zonos-link-authentication.js +0 -6
  260. package/dist/components/zonos-link-authentication2.js +0 -80
  261. package/dist/components/zonos-link.d.ts +0 -11
  262. package/dist/components/zonos-link.js +0 -43
  263. package/dist/components/zonos-logo.d.ts +0 -11
  264. package/dist/components/zonos-logo.js +0 -49
  265. package/dist/components/zonos-notification.d.ts +0 -11
  266. package/dist/components/zonos-notification.js +0 -6
  267. package/dist/components/zonos-notification2.js +0 -92
  268. package/dist/components/zonos-payment.d.ts +0 -11
  269. package/dist/components/zonos-payment.js +0 -6
  270. package/dist/components/zonos-payment2.js +0 -77
  271. package/dist/components/zonos-review.d.ts +0 -11
  272. package/dist/components/zonos-review.js +0 -6
  273. package/dist/components/zonos-review2.js +0 -89
  274. package/dist/components/zonos-select-dialog-header.d.ts +0 -11
  275. package/dist/components/zonos-select-dialog-header.js +0 -6
  276. package/dist/components/zonos-select-dialog-header2.js +0 -71
  277. package/dist/components/zonos-shipping-rich-radio.d.ts +0 -11
  278. package/dist/components/zonos-shipping-rich-radio.js +0 -6
  279. package/dist/components/zonos-shipping-rich-radio2.js +0 -88
  280. package/dist/components/zonos-shipping.d.ts +0 -11
  281. package/dist/components/zonos-shipping.js +0 -6
  282. package/dist/components/zonos-shipping2.js +0 -159
  283. package/dist/components/zonos-spinner.d.ts +0 -11
  284. package/dist/components/zonos-spinner.js +0 -6
  285. package/dist/components/zonos-spinner2.js +0 -43
  286. package/dist/components/zonos-text.d.ts +0 -11
  287. package/dist/components/zonos-text.js +0 -6
  288. package/dist/components/zonos-text2.js +0 -182
  289. package/dist/components/zonos-tooltip.d.ts +0 -11
  290. package/dist/components/zonos-tooltip.js +0 -6
  291. package/dist/components/zonos-tooltip2.js +0 -48
  292. package/dist/components/zonos-v-stack.d.ts +0 -11
  293. package/dist/components/zonos-v-stack.js +0 -6
  294. package/dist/components/zonos-v-stack2.js +0 -38
  295. package/dist/components/zonosStore.js +0 -2881
  296. package/dist/esm-es5/cart-cc593c2b.js +0 -1
  297. package/dist/esm-es5/submitGtag-e50f903f.js +0 -1
  298. package/dist/scripts/checkIfLoadVersionDomain.js +0 -1
  299. package/dist/scripts/extractZonosQaUrl.js +0 -1
  300. package/dist/scripts/getTempCartById.js +0 -1
  301. package/dist/scripts/loadStripe.js +0 -1
  302. package/dist/scripts/stripe.js +0 -1
  303. package/dist/scripts/zonosBase.js +0 -1
  304. package/dist/zonos-elements/p-04030a48.entry.js +0 -1
  305. package/dist/zonos-elements/p-0e892292.entry.js +0 -1
  306. package/dist/zonos-elements/p-0fac99e7.entry.js +0 -1
  307. package/dist/zonos-elements/p-1795c760.system.entry.js +0 -1
  308. package/dist/zonos-elements/p-24ac1c6f.entry.js +0 -1
  309. package/dist/zonos-elements/p-26a60a6e.entry.js +0 -1
  310. package/dist/zonos-elements/p-32744531.entry.js +0 -1
  311. package/dist/zonos-elements/p-35ac375a.system.entry.js +0 -1
  312. package/dist/zonos-elements/p-3bc88c3c.system.entry.js +0 -1
  313. package/dist/zonos-elements/p-4caaaaeb.system.entry.js +0 -1
  314. package/dist/zonos-elements/p-50ea2036.system.js +0 -1
  315. package/dist/zonos-elements/p-5e783394.entry.js +0 -1
  316. package/dist/zonos-elements/p-6366e7e3.entry.js +0 -1
  317. package/dist/zonos-elements/p-7c8ee4b9.system.entry.js +0 -1
  318. package/dist/zonos-elements/p-80ea85b8.entry.js +0 -1
  319. package/dist/zonos-elements/p-8da16d53.system.js +0 -1
  320. package/dist/zonos-elements/p-98a0b694.system.entry.js +0 -1
  321. package/dist/zonos-elements/p-b98cdf39.system.entry.js +0 -1
  322. package/dist/zonos-elements/p-d7b8c1c1.system.entry.js +0 -1
  323. package/dist/zonos-elements/p-dd0fd351.entry.js +0 -1
  324. package/dist/zonos-elements/p-e015cb0e.js +0 -1
  325. package/dist/zonos-elements/p-e1fbd05d.system.entry.js +0 -1
  326. package/dist/zonos-elements/p-e553dd19.js +0 -1
  327. package/dist/zonos-elements/p-e6fa0ebc.system.js +0 -1
  328. package/dist/zonos-elements/p-f6546bf4.system.entry.js +0 -1
  329. /package/dist/collection/components/common/{component-template/zonos-link → zonos-link}/zonos-link.css +0 -0
  330. /package/dist/collection/scripts/{checkIfLoadVersionDomain.js → _checkIfLoadVersionDomain.js} +0 -0
  331. /package/dist/collection/scripts/{stripe.js → _stripe.js} +0 -0
  332. /package/dist/types/components/common/{component-template/zonos-link → zonos-link}/zonos-link.d.ts +0 -0
  333. /package/dist/types/scripts/{checkIfLoadVersionDomain.d.ts → _checkIfLoadVersionDomain.d.ts} +0 -0
  334. /package/dist/types/scripts/{stripe.d.ts → _stripe.d.ts} +0 -0
@@ -1,1891 +0,0 @@
1
- import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
- import { f as localizationStoreUpdateSelectedCountryCode, a as localizationStore } from './stripe.js';
3
- import { a as zonosStoreFontFamily } from './zonosStore.js';
4
- import { d as defineCustomElement$7 } from './zonos-button2.js';
5
- import { d as defineCustomElement$6 } from './zonos-country-flag2.js';
6
- import { d as defineCustomElement$5 } from './zonos-icon2.js';
7
- import { d as defineCustomElement$4 } from './zonos-select-dialog-header2.js';
8
- import { d as defineCustomElement$3 } from './zonos-spinner2.js';
9
- import { d as defineCustomElement$2 } from './zonos-text2.js';
10
- import { d as defineCustomElement$1 } from './zonos-v-stack2.js';
11
-
12
- /**
13
- * Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io)
14
- *
15
- * Copyright (c) 2023 Kiro Risk (http://kiro.me)
16
- * All Rights Reserved. Apache Software License 2.0
17
- *
18
- * http://www.apache.org/licenses/LICENSE-2.0
19
- */
20
-
21
- function isArray(value) {
22
- return !Array.isArray
23
- ? getTag(value) === '[object Array]'
24
- : Array.isArray(value)
25
- }
26
-
27
- // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js
28
- const INFINITY = 1 / 0;
29
- function baseToString(value) {
30
- // Exit early for strings to avoid a performance hit in some environments.
31
- if (typeof value == 'string') {
32
- return value
33
- }
34
- let result = value + '';
35
- return result == '0' && 1 / value == -INFINITY ? '-0' : result
36
- }
37
-
38
- function toString(value) {
39
- return value == null ? '' : baseToString(value)
40
- }
41
-
42
- function isString(value) {
43
- return typeof value === 'string'
44
- }
45
-
46
- function isNumber(value) {
47
- return typeof value === 'number'
48
- }
49
-
50
- // Adapted from: https://github.com/lodash/lodash/blob/master/isBoolean.js
51
- function isBoolean(value) {
52
- return (
53
- value === true ||
54
- value === false ||
55
- (isObjectLike(value) && getTag(value) == '[object Boolean]')
56
- )
57
- }
58
-
59
- function isObject(value) {
60
- return typeof value === 'object'
61
- }
62
-
63
- // Checks if `value` is object-like.
64
- function isObjectLike(value) {
65
- return isObject(value) && value !== null
66
- }
67
-
68
- function isDefined(value) {
69
- return value !== undefined && value !== null
70
- }
71
-
72
- function isBlank(value) {
73
- return !value.trim().length
74
- }
75
-
76
- // Gets the `toStringTag` of `value`.
77
- // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/getTag.js
78
- function getTag(value) {
79
- return value == null
80
- ? value === undefined
81
- ? '[object Undefined]'
82
- : '[object Null]'
83
- : Object.prototype.toString.call(value)
84
- }
85
-
86
- const EXTENDED_SEARCH_UNAVAILABLE = 'Extended search is not available';
87
-
88
- const INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
89
-
90
- const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) =>
91
- `Invalid value for key ${key}`;
92
-
93
- const PATTERN_LENGTH_TOO_LARGE = (max) =>
94
- `Pattern length exceeds max of ${max}.`;
95
-
96
- const MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`;
97
-
98
- const INVALID_KEY_WEIGHT_VALUE = (key) =>
99
- `Property 'weight' in key '${key}' must be a positive integer`;
100
-
101
- const hasOwn = Object.prototype.hasOwnProperty;
102
-
103
- class KeyStore {
104
- constructor(keys) {
105
- this._keys = [];
106
- this._keyMap = {};
107
-
108
- let totalWeight = 0;
109
-
110
- keys.forEach((key) => {
111
- let obj = createKey(key);
112
-
113
- this._keys.push(obj);
114
- this._keyMap[obj.id] = obj;
115
-
116
- totalWeight += obj.weight;
117
- });
118
-
119
- // Normalize weights so that their sum is equal to 1
120
- this._keys.forEach((key) => {
121
- key.weight /= totalWeight;
122
- });
123
- }
124
- get(keyId) {
125
- return this._keyMap[keyId]
126
- }
127
- keys() {
128
- return this._keys
129
- }
130
- toJSON() {
131
- return JSON.stringify(this._keys)
132
- }
133
- }
134
-
135
- function createKey(key) {
136
- let path = null;
137
- let id = null;
138
- let src = null;
139
- let weight = 1;
140
- let getFn = null;
141
-
142
- if (isString(key) || isArray(key)) {
143
- src = key;
144
- path = createKeyPath(key);
145
- id = createKeyId(key);
146
- } else {
147
- if (!hasOwn.call(key, 'name')) {
148
- throw new Error(MISSING_KEY_PROPERTY('name'))
149
- }
150
-
151
- const name = key.name;
152
- src = name;
153
-
154
- if (hasOwn.call(key, 'weight')) {
155
- weight = key.weight;
156
-
157
- if (weight <= 0) {
158
- throw new Error(INVALID_KEY_WEIGHT_VALUE(name))
159
- }
160
- }
161
-
162
- path = createKeyPath(name);
163
- id = createKeyId(name);
164
- getFn = key.getFn;
165
- }
166
-
167
- return { path, id, weight, src, getFn }
168
- }
169
-
170
- function createKeyPath(key) {
171
- return isArray(key) ? key : key.split('.')
172
- }
173
-
174
- function createKeyId(key) {
175
- return isArray(key) ? key.join('.') : key
176
- }
177
-
178
- function get(obj, path) {
179
- let list = [];
180
- let arr = false;
181
-
182
- const deepGet = (obj, path, index) => {
183
- if (!isDefined(obj)) {
184
- return
185
- }
186
- if (!path[index]) {
187
- // If there's no path left, we've arrived at the object we care about.
188
- list.push(obj);
189
- } else {
190
- let key = path[index];
191
-
192
- const value = obj[key];
193
-
194
- if (!isDefined(value)) {
195
- return
196
- }
197
-
198
- // If we're at the last value in the path, and if it's a string/number/bool,
199
- // add it to the list
200
- if (
201
- index === path.length - 1 &&
202
- (isString(value) || isNumber(value) || isBoolean(value))
203
- ) {
204
- list.push(toString(value));
205
- } else if (isArray(value)) {
206
- arr = true;
207
- // Search each item in the array.
208
- for (let i = 0, len = value.length; i < len; i += 1) {
209
- deepGet(value[i], path, index + 1);
210
- }
211
- } else if (path.length) {
212
- // An object. Recurse further.
213
- deepGet(value, path, index + 1);
214
- }
215
- }
216
- };
217
-
218
- // Backwards compatibility (since path used to be a string)
219
- deepGet(obj, isString(path) ? path.split('.') : path, 0);
220
-
221
- return arr ? list : list[0]
222
- }
223
-
224
- const MatchOptions = {
225
- // Whether the matches should be included in the result set. When `true`, each record in the result
226
- // set will include the indices of the matched characters.
227
- // These can consequently be used for highlighting purposes.
228
- includeMatches: false,
229
- // When `true`, the matching function will continue to the end of a search pattern even if
230
- // a perfect match has already been located in the string.
231
- findAllMatches: false,
232
- // Minimum number of characters that must be matched before a result is considered a match
233
- minMatchCharLength: 1
234
- };
235
-
236
- const BasicOptions = {
237
- // When `true`, the algorithm continues searching to the end of the input even if a perfect
238
- // match is found before the end of the same input.
239
- isCaseSensitive: false,
240
- // When true, the matching function will continue to the end of a search pattern even if
241
- includeScore: false,
242
- // List of properties that will be searched. This also supports nested properties.
243
- keys: [],
244
- // Whether to sort the result list, by score
245
- shouldSort: true,
246
- // Default sort function: sort by ascending score, ascending index
247
- sortFn: (a, b) =>
248
- a.score === b.score ? (a.idx < b.idx ? -1 : 1) : a.score < b.score ? -1 : 1
249
- };
250
-
251
- const FuzzyOptions = {
252
- // Approximately where in the text is the pattern expected to be found?
253
- location: 0,
254
- // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
255
- // (of both letters and location), a threshold of '1.0' would match anything.
256
- threshold: 0.6,
257
- // Determines how close the match must be to the fuzzy location (specified above).
258
- // An exact letter match which is 'distance' characters away from the fuzzy location
259
- // would score as a complete mismatch. A distance of '0' requires the match be at
260
- // the exact location specified, a threshold of '1000' would require a perfect match
261
- // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
262
- distance: 100
263
- };
264
-
265
- const AdvancedOptions = {
266
- // When `true`, it enables the use of unix-like search commands
267
- useExtendedSearch: false,
268
- // The get function to use when fetching an object's properties.
269
- // The default will search nested paths *ie foo.bar.baz*
270
- getFn: get,
271
- // When `true`, search will ignore `location` and `distance`, so it won't matter
272
- // where in the string the pattern appears.
273
- // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
274
- ignoreLocation: false,
275
- // When `true`, the calculation for the relevance score (used for sorting) will
276
- // ignore the field-length norm.
277
- // More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
278
- ignoreFieldNorm: false,
279
- // The weight to determine how much field length norm effects scoring.
280
- fieldNormWeight: 1
281
- };
282
-
283
- var Config = {
284
- ...BasicOptions,
285
- ...MatchOptions,
286
- ...FuzzyOptions,
287
- ...AdvancedOptions
288
- };
289
-
290
- const SPACE = /[^ ]+/g;
291
-
292
- // Field-length norm: the shorter the field, the higher the weight.
293
- // Set to 3 decimals to reduce index size.
294
- function norm(weight = 1, mantissa = 3) {
295
- const cache = new Map();
296
- const m = Math.pow(10, mantissa);
297
-
298
- return {
299
- get(value) {
300
- const numTokens = value.match(SPACE).length;
301
-
302
- if (cache.has(numTokens)) {
303
- return cache.get(numTokens)
304
- }
305
-
306
- // Default function is 1/sqrt(x), weight makes that variable
307
- const norm = 1 / Math.pow(numTokens, 0.5 * weight);
308
-
309
- // In place of `toFixed(mantissa)`, for faster computation
310
- const n = parseFloat(Math.round(norm * m) / m);
311
-
312
- cache.set(numTokens, n);
313
-
314
- return n
315
- },
316
- clear() {
317
- cache.clear();
318
- }
319
- }
320
- }
321
-
322
- class FuseIndex {
323
- constructor({
324
- getFn = Config.getFn,
325
- fieldNormWeight = Config.fieldNormWeight
326
- } = {}) {
327
- this.norm = norm(fieldNormWeight, 3);
328
- this.getFn = getFn;
329
- this.isCreated = false;
330
-
331
- this.setIndexRecords();
332
- }
333
- setSources(docs = []) {
334
- this.docs = docs;
335
- }
336
- setIndexRecords(records = []) {
337
- this.records = records;
338
- }
339
- setKeys(keys = []) {
340
- this.keys = keys;
341
- this._keysMap = {};
342
- keys.forEach((key, idx) => {
343
- this._keysMap[key.id] = idx;
344
- });
345
- }
346
- create() {
347
- if (this.isCreated || !this.docs.length) {
348
- return
349
- }
350
-
351
- this.isCreated = true;
352
-
353
- // List is Array<String>
354
- if (isString(this.docs[0])) {
355
- this.docs.forEach((doc, docIndex) => {
356
- this._addString(doc, docIndex);
357
- });
358
- } else {
359
- // List is Array<Object>
360
- this.docs.forEach((doc, docIndex) => {
361
- this._addObject(doc, docIndex);
362
- });
363
- }
364
-
365
- this.norm.clear();
366
- }
367
- // Adds a doc to the end of the index
368
- add(doc) {
369
- const idx = this.size();
370
-
371
- if (isString(doc)) {
372
- this._addString(doc, idx);
373
- } else {
374
- this._addObject(doc, idx);
375
- }
376
- }
377
- // Removes the doc at the specified index of the index
378
- removeAt(idx) {
379
- this.records.splice(idx, 1);
380
-
381
- // Change ref index of every subsquent doc
382
- for (let i = idx, len = this.size(); i < len; i += 1) {
383
- this.records[i].i -= 1;
384
- }
385
- }
386
- getValueForItemAtKeyId(item, keyId) {
387
- return item[this._keysMap[keyId]]
388
- }
389
- size() {
390
- return this.records.length
391
- }
392
- _addString(doc, docIndex) {
393
- if (!isDefined(doc) || isBlank(doc)) {
394
- return
395
- }
396
-
397
- let record = {
398
- v: doc,
399
- i: docIndex,
400
- n: this.norm.get(doc)
401
- };
402
-
403
- this.records.push(record);
404
- }
405
- _addObject(doc, docIndex) {
406
- let record = { i: docIndex, $: {} };
407
-
408
- // Iterate over every key (i.e, path), and fetch the value at that key
409
- this.keys.forEach((key, keyIndex) => {
410
- let value = key.getFn ? key.getFn(doc) : this.getFn(doc, key.path);
411
-
412
- if (!isDefined(value)) {
413
- return
414
- }
415
-
416
- if (isArray(value)) {
417
- let subRecords = [];
418
- const stack = [{ nestedArrIndex: -1, value }];
419
-
420
- while (stack.length) {
421
- const { nestedArrIndex, value } = stack.pop();
422
-
423
- if (!isDefined(value)) {
424
- continue
425
- }
426
-
427
- if (isString(value) && !isBlank(value)) {
428
- let subRecord = {
429
- v: value,
430
- i: nestedArrIndex,
431
- n: this.norm.get(value)
432
- };
433
-
434
- subRecords.push(subRecord);
435
- } else if (isArray(value)) {
436
- value.forEach((item, k) => {
437
- stack.push({
438
- nestedArrIndex: k,
439
- value: item
440
- });
441
- });
442
- } else ;
443
- }
444
- record.$[keyIndex] = subRecords;
445
- } else if (isString(value) && !isBlank(value)) {
446
- let subRecord = {
447
- v: value,
448
- n: this.norm.get(value)
449
- };
450
-
451
- record.$[keyIndex] = subRecord;
452
- }
453
- });
454
-
455
- this.records.push(record);
456
- }
457
- toJSON() {
458
- return {
459
- keys: this.keys,
460
- records: this.records
461
- }
462
- }
463
- }
464
-
465
- function createIndex(
466
- keys,
467
- docs,
468
- { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}
469
- ) {
470
- const myIndex = new FuseIndex({ getFn, fieldNormWeight });
471
- myIndex.setKeys(keys.map(createKey));
472
- myIndex.setSources(docs);
473
- myIndex.create();
474
- return myIndex
475
- }
476
-
477
- function parseIndex(
478
- data,
479
- { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}
480
- ) {
481
- const { keys, records } = data;
482
- const myIndex = new FuseIndex({ getFn, fieldNormWeight });
483
- myIndex.setKeys(keys);
484
- myIndex.setIndexRecords(records);
485
- return myIndex
486
- }
487
-
488
- function computeScore$1(
489
- pattern,
490
- {
491
- errors = 0,
492
- currentLocation = 0,
493
- expectedLocation = 0,
494
- distance = Config.distance,
495
- ignoreLocation = Config.ignoreLocation
496
- } = {}
497
- ) {
498
- const accuracy = errors / pattern.length;
499
-
500
- if (ignoreLocation) {
501
- return accuracy
502
- }
503
-
504
- const proximity = Math.abs(expectedLocation - currentLocation);
505
-
506
- if (!distance) {
507
- // Dodge divide by zero error.
508
- return proximity ? 1.0 : accuracy
509
- }
510
-
511
- return accuracy + proximity / distance
512
- }
513
-
514
- function convertMaskToIndices(
515
- matchmask = [],
516
- minMatchCharLength = Config.minMatchCharLength
517
- ) {
518
- let indices = [];
519
- let start = -1;
520
- let end = -1;
521
- let i = 0;
522
-
523
- for (let len = matchmask.length; i < len; i += 1) {
524
- let match = matchmask[i];
525
- if (match && start === -1) {
526
- start = i;
527
- } else if (!match && start !== -1) {
528
- end = i - 1;
529
- if (end - start + 1 >= minMatchCharLength) {
530
- indices.push([start, end]);
531
- }
532
- start = -1;
533
- }
534
- }
535
-
536
- // (i-1 - start) + 1 => i - start
537
- if (matchmask[i - 1] && i - start >= minMatchCharLength) {
538
- indices.push([start, i - 1]);
539
- }
540
-
541
- return indices
542
- }
543
-
544
- // Machine word size
545
- const MAX_BITS = 32;
546
-
547
- function search(
548
- text,
549
- pattern,
550
- patternAlphabet,
551
- {
552
- location = Config.location,
553
- distance = Config.distance,
554
- threshold = Config.threshold,
555
- findAllMatches = Config.findAllMatches,
556
- minMatchCharLength = Config.minMatchCharLength,
557
- includeMatches = Config.includeMatches,
558
- ignoreLocation = Config.ignoreLocation
559
- } = {}
560
- ) {
561
- if (pattern.length > MAX_BITS) {
562
- throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS))
563
- }
564
-
565
- const patternLen = pattern.length;
566
- // Set starting location at beginning text and initialize the alphabet.
567
- const textLen = text.length;
568
- // Handle the case when location > text.length
569
- const expectedLocation = Math.max(0, Math.min(location, textLen));
570
- // Highest score beyond which we give up.
571
- let currentThreshold = threshold;
572
- // Is there a nearby exact match? (speedup)
573
- let bestLocation = expectedLocation;
574
-
575
- // Performance: only computer matches when the minMatchCharLength > 1
576
- // OR if `includeMatches` is true.
577
- const computeMatches = minMatchCharLength > 1 || includeMatches;
578
- // A mask of the matches, used for building the indices
579
- const matchMask = computeMatches ? Array(textLen) : [];
580
-
581
- let index;
582
-
583
- // Get all exact matches, here for speed up
584
- while ((index = text.indexOf(pattern, bestLocation)) > -1) {
585
- let score = computeScore$1(pattern, {
586
- currentLocation: index,
587
- expectedLocation,
588
- distance,
589
- ignoreLocation
590
- });
591
-
592
- currentThreshold = Math.min(score, currentThreshold);
593
- bestLocation = index + patternLen;
594
-
595
- if (computeMatches) {
596
- let i = 0;
597
- while (i < patternLen) {
598
- matchMask[index + i] = 1;
599
- i += 1;
600
- }
601
- }
602
- }
603
-
604
- // Reset the best location
605
- bestLocation = -1;
606
-
607
- let lastBitArr = [];
608
- let finalScore = 1;
609
- let binMax = patternLen + textLen;
610
-
611
- const mask = 1 << (patternLen - 1);
612
-
613
- for (let i = 0; i < patternLen; i += 1) {
614
- // Scan for the best match; each iteration allows for one more error.
615
- // Run a binary search to determine how far from the match location we can stray
616
- // at this error level.
617
- let binMin = 0;
618
- let binMid = binMax;
619
-
620
- while (binMin < binMid) {
621
- const score = computeScore$1(pattern, {
622
- errors: i,
623
- currentLocation: expectedLocation + binMid,
624
- expectedLocation,
625
- distance,
626
- ignoreLocation
627
- });
628
-
629
- if (score <= currentThreshold) {
630
- binMin = binMid;
631
- } else {
632
- binMax = binMid;
633
- }
634
-
635
- binMid = Math.floor((binMax - binMin) / 2 + binMin);
636
- }
637
-
638
- // Use the result from this iteration as the maximum for the next.
639
- binMax = binMid;
640
-
641
- let start = Math.max(1, expectedLocation - binMid + 1);
642
- let finish = findAllMatches
643
- ? textLen
644
- : Math.min(expectedLocation + binMid, textLen) + patternLen;
645
-
646
- // Initialize the bit array
647
- let bitArr = Array(finish + 2);
648
-
649
- bitArr[finish + 1] = (1 << i) - 1;
650
-
651
- for (let j = finish; j >= start; j -= 1) {
652
- let currentLocation = j - 1;
653
- let charMatch = patternAlphabet[text.charAt(currentLocation)];
654
-
655
- if (computeMatches) {
656
- // Speed up: quick bool to int conversion (i.e, `charMatch ? 1 : 0`)
657
- matchMask[currentLocation] = +!!charMatch;
658
- }
659
-
660
- // First pass: exact match
661
- bitArr[j] = ((bitArr[j + 1] << 1) | 1) & charMatch;
662
-
663
- // Subsequent passes: fuzzy match
664
- if (i) {
665
- bitArr[j] |=
666
- ((lastBitArr[j + 1] | lastBitArr[j]) << 1) | 1 | lastBitArr[j + 1];
667
- }
668
-
669
- if (bitArr[j] & mask) {
670
- finalScore = computeScore$1(pattern, {
671
- errors: i,
672
- currentLocation,
673
- expectedLocation,
674
- distance,
675
- ignoreLocation
676
- });
677
-
678
- // This match will almost certainly be better than any existing match.
679
- // But check anyway.
680
- if (finalScore <= currentThreshold) {
681
- // Indeed it is
682
- currentThreshold = finalScore;
683
- bestLocation = currentLocation;
684
-
685
- // Already passed `loc`, downhill from here on in.
686
- if (bestLocation <= expectedLocation) {
687
- break
688
- }
689
-
690
- // When passing `bestLocation`, don't exceed our current distance from `expectedLocation`.
691
- start = Math.max(1, 2 * expectedLocation - bestLocation);
692
- }
693
- }
694
- }
695
-
696
- // No hope for a (better) match at greater error levels.
697
- const score = computeScore$1(pattern, {
698
- errors: i + 1,
699
- currentLocation: expectedLocation,
700
- expectedLocation,
701
- distance,
702
- ignoreLocation
703
- });
704
-
705
- if (score > currentThreshold) {
706
- break
707
- }
708
-
709
- lastBitArr = bitArr;
710
- }
711
-
712
- const result = {
713
- isMatch: bestLocation >= 0,
714
- // Count exact matches (those with a score of 0) to be "almost" exact
715
- score: Math.max(0.001, finalScore)
716
- };
717
-
718
- if (computeMatches) {
719
- const indices = convertMaskToIndices(matchMask, minMatchCharLength);
720
- if (!indices.length) {
721
- result.isMatch = false;
722
- } else if (includeMatches) {
723
- result.indices = indices;
724
- }
725
- }
726
-
727
- return result
728
- }
729
-
730
- function createPatternAlphabet(pattern) {
731
- let mask = {};
732
-
733
- for (let i = 0, len = pattern.length; i < len; i += 1) {
734
- const char = pattern.charAt(i);
735
- mask[char] = (mask[char] || 0) | (1 << (len - i - 1));
736
- }
737
-
738
- return mask
739
- }
740
-
741
- class BitapSearch {
742
- constructor(
743
- pattern,
744
- {
745
- location = Config.location,
746
- threshold = Config.threshold,
747
- distance = Config.distance,
748
- includeMatches = Config.includeMatches,
749
- findAllMatches = Config.findAllMatches,
750
- minMatchCharLength = Config.minMatchCharLength,
751
- isCaseSensitive = Config.isCaseSensitive,
752
- ignoreLocation = Config.ignoreLocation
753
- } = {}
754
- ) {
755
- this.options = {
756
- location,
757
- threshold,
758
- distance,
759
- includeMatches,
760
- findAllMatches,
761
- minMatchCharLength,
762
- isCaseSensitive,
763
- ignoreLocation
764
- };
765
-
766
- this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
767
-
768
- this.chunks = [];
769
-
770
- if (!this.pattern.length) {
771
- return
772
- }
773
-
774
- const addChunk = (pattern, startIndex) => {
775
- this.chunks.push({
776
- pattern,
777
- alphabet: createPatternAlphabet(pattern),
778
- startIndex
779
- });
780
- };
781
-
782
- const len = this.pattern.length;
783
-
784
- if (len > MAX_BITS) {
785
- let i = 0;
786
- const remainder = len % MAX_BITS;
787
- const end = len - remainder;
788
-
789
- while (i < end) {
790
- addChunk(this.pattern.substr(i, MAX_BITS), i);
791
- i += MAX_BITS;
792
- }
793
-
794
- if (remainder) {
795
- const startIndex = len - MAX_BITS;
796
- addChunk(this.pattern.substr(startIndex), startIndex);
797
- }
798
- } else {
799
- addChunk(this.pattern, 0);
800
- }
801
- }
802
-
803
- searchIn(text) {
804
- const { isCaseSensitive, includeMatches } = this.options;
805
-
806
- if (!isCaseSensitive) {
807
- text = text.toLowerCase();
808
- }
809
-
810
- // Exact match
811
- if (this.pattern === text) {
812
- let result = {
813
- isMatch: true,
814
- score: 0
815
- };
816
-
817
- if (includeMatches) {
818
- result.indices = [[0, text.length - 1]];
819
- }
820
-
821
- return result
822
- }
823
-
824
- // Otherwise, use Bitap algorithm
825
- const {
826
- location,
827
- distance,
828
- threshold,
829
- findAllMatches,
830
- minMatchCharLength,
831
- ignoreLocation
832
- } = this.options;
833
-
834
- let allIndices = [];
835
- let totalScore = 0;
836
- let hasMatches = false;
837
-
838
- this.chunks.forEach(({ pattern, alphabet, startIndex }) => {
839
- const { isMatch, score, indices } = search(text, pattern, alphabet, {
840
- location: location + startIndex,
841
- distance,
842
- threshold,
843
- findAllMatches,
844
- minMatchCharLength,
845
- includeMatches,
846
- ignoreLocation
847
- });
848
-
849
- if (isMatch) {
850
- hasMatches = true;
851
- }
852
-
853
- totalScore += score;
854
-
855
- if (isMatch && indices) {
856
- allIndices = [...allIndices, ...indices];
857
- }
858
- });
859
-
860
- let result = {
861
- isMatch: hasMatches,
862
- score: hasMatches ? totalScore / this.chunks.length : 1
863
- };
864
-
865
- if (hasMatches && includeMatches) {
866
- result.indices = allIndices;
867
- }
868
-
869
- return result
870
- }
871
- }
872
-
873
- class BaseMatch {
874
- constructor(pattern) {
875
- this.pattern = pattern;
876
- }
877
- static isMultiMatch(pattern) {
878
- return getMatch(pattern, this.multiRegex)
879
- }
880
- static isSingleMatch(pattern) {
881
- return getMatch(pattern, this.singleRegex)
882
- }
883
- search(/*text*/) {}
884
- }
885
-
886
- function getMatch(pattern, exp) {
887
- const matches = pattern.match(exp);
888
- return matches ? matches[1] : null
889
- }
890
-
891
- // Token: 'file
892
-
893
- class ExactMatch extends BaseMatch {
894
- constructor(pattern) {
895
- super(pattern);
896
- }
897
- static get type() {
898
- return 'exact'
899
- }
900
- static get multiRegex() {
901
- return /^="(.*)"$/
902
- }
903
- static get singleRegex() {
904
- return /^=(.*)$/
905
- }
906
- search(text) {
907
- const isMatch = text === this.pattern;
908
-
909
- return {
910
- isMatch,
911
- score: isMatch ? 0 : 1,
912
- indices: [0, this.pattern.length - 1]
913
- }
914
- }
915
- }
916
-
917
- // Token: !fire
918
-
919
- class InverseExactMatch extends BaseMatch {
920
- constructor(pattern) {
921
- super(pattern);
922
- }
923
- static get type() {
924
- return 'inverse-exact'
925
- }
926
- static get multiRegex() {
927
- return /^!"(.*)"$/
928
- }
929
- static get singleRegex() {
930
- return /^!(.*)$/
931
- }
932
- search(text) {
933
- const index = text.indexOf(this.pattern);
934
- const isMatch = index === -1;
935
-
936
- return {
937
- isMatch,
938
- score: isMatch ? 0 : 1,
939
- indices: [0, text.length - 1]
940
- }
941
- }
942
- }
943
-
944
- // Token: ^file
945
-
946
- class PrefixExactMatch extends BaseMatch {
947
- constructor(pattern) {
948
- super(pattern);
949
- }
950
- static get type() {
951
- return 'prefix-exact'
952
- }
953
- static get multiRegex() {
954
- return /^\^"(.*)"$/
955
- }
956
- static get singleRegex() {
957
- return /^\^(.*)$/
958
- }
959
- search(text) {
960
- const isMatch = text.startsWith(this.pattern);
961
-
962
- return {
963
- isMatch,
964
- score: isMatch ? 0 : 1,
965
- indices: [0, this.pattern.length - 1]
966
- }
967
- }
968
- }
969
-
970
- // Token: !^fire
971
-
972
- class InversePrefixExactMatch extends BaseMatch {
973
- constructor(pattern) {
974
- super(pattern);
975
- }
976
- static get type() {
977
- return 'inverse-prefix-exact'
978
- }
979
- static get multiRegex() {
980
- return /^!\^"(.*)"$/
981
- }
982
- static get singleRegex() {
983
- return /^!\^(.*)$/
984
- }
985
- search(text) {
986
- const isMatch = !text.startsWith(this.pattern);
987
-
988
- return {
989
- isMatch,
990
- score: isMatch ? 0 : 1,
991
- indices: [0, text.length - 1]
992
- }
993
- }
994
- }
995
-
996
- // Token: .file$
997
-
998
- class SuffixExactMatch extends BaseMatch {
999
- constructor(pattern) {
1000
- super(pattern);
1001
- }
1002
- static get type() {
1003
- return 'suffix-exact'
1004
- }
1005
- static get multiRegex() {
1006
- return /^"(.*)"\$$/
1007
- }
1008
- static get singleRegex() {
1009
- return /^(.*)\$$/
1010
- }
1011
- search(text) {
1012
- const isMatch = text.endsWith(this.pattern);
1013
-
1014
- return {
1015
- isMatch,
1016
- score: isMatch ? 0 : 1,
1017
- indices: [text.length - this.pattern.length, text.length - 1]
1018
- }
1019
- }
1020
- }
1021
-
1022
- // Token: !.file$
1023
-
1024
- class InverseSuffixExactMatch extends BaseMatch {
1025
- constructor(pattern) {
1026
- super(pattern);
1027
- }
1028
- static get type() {
1029
- return 'inverse-suffix-exact'
1030
- }
1031
- static get multiRegex() {
1032
- return /^!"(.*)"\$$/
1033
- }
1034
- static get singleRegex() {
1035
- return /^!(.*)\$$/
1036
- }
1037
- search(text) {
1038
- const isMatch = !text.endsWith(this.pattern);
1039
- return {
1040
- isMatch,
1041
- score: isMatch ? 0 : 1,
1042
- indices: [0, text.length - 1]
1043
- }
1044
- }
1045
- }
1046
-
1047
- class FuzzyMatch extends BaseMatch {
1048
- constructor(
1049
- pattern,
1050
- {
1051
- location = Config.location,
1052
- threshold = Config.threshold,
1053
- distance = Config.distance,
1054
- includeMatches = Config.includeMatches,
1055
- findAllMatches = Config.findAllMatches,
1056
- minMatchCharLength = Config.minMatchCharLength,
1057
- isCaseSensitive = Config.isCaseSensitive,
1058
- ignoreLocation = Config.ignoreLocation
1059
- } = {}
1060
- ) {
1061
- super(pattern);
1062
- this._bitapSearch = new BitapSearch(pattern, {
1063
- location,
1064
- threshold,
1065
- distance,
1066
- includeMatches,
1067
- findAllMatches,
1068
- minMatchCharLength,
1069
- isCaseSensitive,
1070
- ignoreLocation
1071
- });
1072
- }
1073
- static get type() {
1074
- return 'fuzzy'
1075
- }
1076
- static get multiRegex() {
1077
- return /^"(.*)"$/
1078
- }
1079
- static get singleRegex() {
1080
- return /^(.*)$/
1081
- }
1082
- search(text) {
1083
- return this._bitapSearch.searchIn(text)
1084
- }
1085
- }
1086
-
1087
- // Token: 'file
1088
-
1089
- class IncludeMatch extends BaseMatch {
1090
- constructor(pattern) {
1091
- super(pattern);
1092
- }
1093
- static get type() {
1094
- return 'include'
1095
- }
1096
- static get multiRegex() {
1097
- return /^'"(.*)"$/
1098
- }
1099
- static get singleRegex() {
1100
- return /^'(.*)$/
1101
- }
1102
- search(text) {
1103
- let location = 0;
1104
- let index;
1105
-
1106
- const indices = [];
1107
- const patternLen = this.pattern.length;
1108
-
1109
- // Get all exact matches
1110
- while ((index = text.indexOf(this.pattern, location)) > -1) {
1111
- location = index + patternLen;
1112
- indices.push([index, location - 1]);
1113
- }
1114
-
1115
- const isMatch = !!indices.length;
1116
-
1117
- return {
1118
- isMatch,
1119
- score: isMatch ? 0 : 1,
1120
- indices
1121
- }
1122
- }
1123
- }
1124
-
1125
- // ❗Order is important. DO NOT CHANGE.
1126
- const searchers = [
1127
- ExactMatch,
1128
- IncludeMatch,
1129
- PrefixExactMatch,
1130
- InversePrefixExactMatch,
1131
- InverseSuffixExactMatch,
1132
- SuffixExactMatch,
1133
- InverseExactMatch,
1134
- FuzzyMatch
1135
- ];
1136
-
1137
- const searchersLen = searchers.length;
1138
-
1139
- // Regex to split by spaces, but keep anything in quotes together
1140
- const SPACE_RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;
1141
- const OR_TOKEN = '|';
1142
-
1143
- // Return a 2D array representation of the query, for simpler parsing.
1144
- // Example:
1145
- // "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]]
1146
- function parseQuery(pattern, options = {}) {
1147
- return pattern.split(OR_TOKEN).map((item) => {
1148
- let query = item
1149
- .trim()
1150
- .split(SPACE_RE)
1151
- .filter((item) => item && !!item.trim());
1152
-
1153
- let results = [];
1154
- for (let i = 0, len = query.length; i < len; i += 1) {
1155
- const queryItem = query[i];
1156
-
1157
- // 1. Handle multiple query match (i.e, once that are quoted, like `"hello world"`)
1158
- let found = false;
1159
- let idx = -1;
1160
- while (!found && ++idx < searchersLen) {
1161
- const searcher = searchers[idx];
1162
- let token = searcher.isMultiMatch(queryItem);
1163
- if (token) {
1164
- results.push(new searcher(token, options));
1165
- found = true;
1166
- }
1167
- }
1168
-
1169
- if (found) {
1170
- continue
1171
- }
1172
-
1173
- // 2. Handle single query matches (i.e, once that are *not* quoted)
1174
- idx = -1;
1175
- while (++idx < searchersLen) {
1176
- const searcher = searchers[idx];
1177
- let token = searcher.isSingleMatch(queryItem);
1178
- if (token) {
1179
- results.push(new searcher(token, options));
1180
- break
1181
- }
1182
- }
1183
- }
1184
-
1185
- return results
1186
- })
1187
- }
1188
-
1189
- // These extended matchers can return an array of matches, as opposed
1190
- // to a singl match
1191
- const MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]);
1192
-
1193
- /**
1194
- * Command-like searching
1195
- * ======================
1196
- *
1197
- * Given multiple search terms delimited by spaces.e.g. `^jscript .python$ ruby !java`,
1198
- * search in a given text.
1199
- *
1200
- * Search syntax:
1201
- *
1202
- * | Token | Match type | Description |
1203
- * | ----------- | -------------------------- | -------------------------------------- |
1204
- * | `jscript` | fuzzy-match | Items that fuzzy match `jscript` |
1205
- * | `=scheme` | exact-match | Items that are `scheme` |
1206
- * | `'python` | include-match | Items that include `python` |
1207
- * | `!ruby` | inverse-exact-match | Items that do not include `ruby` |
1208
- * | `^java` | prefix-exact-match | Items that start with `java` |
1209
- * | `!^earlang` | inverse-prefix-exact-match | Items that do not start with `earlang` |
1210
- * | `.js$` | suffix-exact-match | Items that end with `.js` |
1211
- * | `!.go$` | inverse-suffix-exact-match | Items that do not end with `.go` |
1212
- *
1213
- * A single pipe character acts as an OR operator. For example, the following
1214
- * query matches entries that start with `core` and end with either`go`, `rb`,
1215
- * or`py`.
1216
- *
1217
- * ```
1218
- * ^core go$ | rb$ | py$
1219
- * ```
1220
- */
1221
- class ExtendedSearch {
1222
- constructor(
1223
- pattern,
1224
- {
1225
- isCaseSensitive = Config.isCaseSensitive,
1226
- includeMatches = Config.includeMatches,
1227
- minMatchCharLength = Config.minMatchCharLength,
1228
- ignoreLocation = Config.ignoreLocation,
1229
- findAllMatches = Config.findAllMatches,
1230
- location = Config.location,
1231
- threshold = Config.threshold,
1232
- distance = Config.distance
1233
- } = {}
1234
- ) {
1235
- this.query = null;
1236
- this.options = {
1237
- isCaseSensitive,
1238
- includeMatches,
1239
- minMatchCharLength,
1240
- findAllMatches,
1241
- ignoreLocation,
1242
- location,
1243
- threshold,
1244
- distance
1245
- };
1246
-
1247
- this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
1248
- this.query = parseQuery(this.pattern, this.options);
1249
- }
1250
-
1251
- static condition(_, options) {
1252
- return options.useExtendedSearch
1253
- }
1254
-
1255
- searchIn(text) {
1256
- const query = this.query;
1257
-
1258
- if (!query) {
1259
- return {
1260
- isMatch: false,
1261
- score: 1
1262
- }
1263
- }
1264
-
1265
- const { includeMatches, isCaseSensitive } = this.options;
1266
-
1267
- text = isCaseSensitive ? text : text.toLowerCase();
1268
-
1269
- let numMatches = 0;
1270
- let allIndices = [];
1271
- let totalScore = 0;
1272
-
1273
- // ORs
1274
- for (let i = 0, qLen = query.length; i < qLen; i += 1) {
1275
- const searchers = query[i];
1276
-
1277
- // Reset indices
1278
- allIndices.length = 0;
1279
- numMatches = 0;
1280
-
1281
- // ANDs
1282
- for (let j = 0, pLen = searchers.length; j < pLen; j += 1) {
1283
- const searcher = searchers[j];
1284
- const { isMatch, indices, score } = searcher.search(text);
1285
-
1286
- if (isMatch) {
1287
- numMatches += 1;
1288
- totalScore += score;
1289
- if (includeMatches) {
1290
- const type = searcher.constructor.type;
1291
- if (MultiMatchSet.has(type)) {
1292
- allIndices = [...allIndices, ...indices];
1293
- } else {
1294
- allIndices.push(indices);
1295
- }
1296
- }
1297
- } else {
1298
- totalScore = 0;
1299
- numMatches = 0;
1300
- allIndices.length = 0;
1301
- break
1302
- }
1303
- }
1304
-
1305
- // OR condition, so if TRUE, return
1306
- if (numMatches) {
1307
- let result = {
1308
- isMatch: true,
1309
- score: totalScore / numMatches
1310
- };
1311
-
1312
- if (includeMatches) {
1313
- result.indices = allIndices;
1314
- }
1315
-
1316
- return result
1317
- }
1318
- }
1319
-
1320
- // Nothing was matched
1321
- return {
1322
- isMatch: false,
1323
- score: 1
1324
- }
1325
- }
1326
- }
1327
-
1328
- const registeredSearchers = [];
1329
-
1330
- function register(...args) {
1331
- registeredSearchers.push(...args);
1332
- }
1333
-
1334
- function createSearcher(pattern, options) {
1335
- for (let i = 0, len = registeredSearchers.length; i < len; i += 1) {
1336
- let searcherClass = registeredSearchers[i];
1337
- if (searcherClass.condition(pattern, options)) {
1338
- return new searcherClass(pattern, options)
1339
- }
1340
- }
1341
-
1342
- return new BitapSearch(pattern, options)
1343
- }
1344
-
1345
- const LogicalOperator = {
1346
- AND: '$and',
1347
- OR: '$or'
1348
- };
1349
-
1350
- const KeyType = {
1351
- PATH: '$path',
1352
- PATTERN: '$val'
1353
- };
1354
-
1355
- const isExpression = (query) =>
1356
- !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
1357
-
1358
- const isPath = (query) => !!query[KeyType.PATH];
1359
-
1360
- const isLeaf = (query) =>
1361
- !isArray(query) && isObject(query) && !isExpression(query);
1362
-
1363
- const convertToExplicit = (query) => ({
1364
- [LogicalOperator.AND]: Object.keys(query).map((key) => ({
1365
- [key]: query[key]
1366
- }))
1367
- });
1368
-
1369
- // When `auto` is `true`, the parse function will infer and initialize and add
1370
- // the appropriate `Searcher` instance
1371
- function parse(query, options, { auto = true } = {}) {
1372
- const next = (query) => {
1373
- let keys = Object.keys(query);
1374
-
1375
- const isQueryPath = isPath(query);
1376
-
1377
- if (!isQueryPath && keys.length > 1 && !isExpression(query)) {
1378
- return next(convertToExplicit(query))
1379
- }
1380
-
1381
- if (isLeaf(query)) {
1382
- const key = isQueryPath ? query[KeyType.PATH] : keys[0];
1383
-
1384
- const pattern = isQueryPath ? query[KeyType.PATTERN] : query[key];
1385
-
1386
- if (!isString(pattern)) {
1387
- throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key))
1388
- }
1389
-
1390
- const obj = {
1391
- keyId: createKeyId(key),
1392
- pattern
1393
- };
1394
-
1395
- if (auto) {
1396
- obj.searcher = createSearcher(pattern, options);
1397
- }
1398
-
1399
- return obj
1400
- }
1401
-
1402
- let node = {
1403
- children: [],
1404
- operator: keys[0]
1405
- };
1406
-
1407
- keys.forEach((key) => {
1408
- const value = query[key];
1409
-
1410
- if (isArray(value)) {
1411
- value.forEach((item) => {
1412
- node.children.push(next(item));
1413
- });
1414
- }
1415
- });
1416
-
1417
- return node
1418
- };
1419
-
1420
- if (!isExpression(query)) {
1421
- query = convertToExplicit(query);
1422
- }
1423
-
1424
- return next(query)
1425
- }
1426
-
1427
- // Practical scoring function
1428
- function computeScore(
1429
- results,
1430
- { ignoreFieldNorm = Config.ignoreFieldNorm }
1431
- ) {
1432
- results.forEach((result) => {
1433
- let totalScore = 1;
1434
-
1435
- result.matches.forEach(({ key, norm, score }) => {
1436
- const weight = key ? key.weight : null;
1437
-
1438
- totalScore *= Math.pow(
1439
- score === 0 && weight ? Number.EPSILON : score,
1440
- (weight || 1) * (ignoreFieldNorm ? 1 : norm)
1441
- );
1442
- });
1443
-
1444
- result.score = totalScore;
1445
- });
1446
- }
1447
-
1448
- function transformMatches(result, data) {
1449
- const matches = result.matches;
1450
- data.matches = [];
1451
-
1452
- if (!isDefined(matches)) {
1453
- return
1454
- }
1455
-
1456
- matches.forEach((match) => {
1457
- if (!isDefined(match.indices) || !match.indices.length) {
1458
- return
1459
- }
1460
-
1461
- const { indices, value } = match;
1462
-
1463
- let obj = {
1464
- indices,
1465
- value
1466
- };
1467
-
1468
- if (match.key) {
1469
- obj.key = match.key.src;
1470
- }
1471
-
1472
- if (match.idx > -1) {
1473
- obj.refIndex = match.idx;
1474
- }
1475
-
1476
- data.matches.push(obj);
1477
- });
1478
- }
1479
-
1480
- function transformScore(result, data) {
1481
- data.score = result.score;
1482
- }
1483
-
1484
- function format(
1485
- results,
1486
- docs,
1487
- {
1488
- includeMatches = Config.includeMatches,
1489
- includeScore = Config.includeScore
1490
- } = {}
1491
- ) {
1492
- const transformers = [];
1493
-
1494
- if (includeMatches) transformers.push(transformMatches);
1495
- if (includeScore) transformers.push(transformScore);
1496
-
1497
- return results.map((result) => {
1498
- const { idx } = result;
1499
-
1500
- const data = {
1501
- item: docs[idx],
1502
- refIndex: idx
1503
- };
1504
-
1505
- if (transformers.length) {
1506
- transformers.forEach((transformer) => {
1507
- transformer(result, data);
1508
- });
1509
- }
1510
-
1511
- return data
1512
- })
1513
- }
1514
-
1515
- class Fuse {
1516
- constructor(docs, options = {}, index) {
1517
- this.options = { ...Config, ...options };
1518
-
1519
- if (
1520
- this.options.useExtendedSearch &&
1521
- !true
1522
- ) {
1523
- throw new Error(EXTENDED_SEARCH_UNAVAILABLE)
1524
- }
1525
-
1526
- this._keyStore = new KeyStore(this.options.keys);
1527
-
1528
- this.setCollection(docs, index);
1529
- }
1530
-
1531
- setCollection(docs, index) {
1532
- this._docs = docs;
1533
-
1534
- if (index && !(index instanceof FuseIndex)) {
1535
- throw new Error(INCORRECT_INDEX_TYPE)
1536
- }
1537
-
1538
- this._myIndex =
1539
- index ||
1540
- createIndex(this.options.keys, this._docs, {
1541
- getFn: this.options.getFn,
1542
- fieldNormWeight: this.options.fieldNormWeight
1543
- });
1544
- }
1545
-
1546
- add(doc) {
1547
- if (!isDefined(doc)) {
1548
- return
1549
- }
1550
-
1551
- this._docs.push(doc);
1552
- this._myIndex.add(doc);
1553
- }
1554
-
1555
- remove(predicate = (/* doc, idx */) => false) {
1556
- const results = [];
1557
-
1558
- for (let i = 0, len = this._docs.length; i < len; i += 1) {
1559
- const doc = this._docs[i];
1560
- if (predicate(doc, i)) {
1561
- this.removeAt(i);
1562
- i -= 1;
1563
- len -= 1;
1564
-
1565
- results.push(doc);
1566
- }
1567
- }
1568
-
1569
- return results
1570
- }
1571
-
1572
- removeAt(idx) {
1573
- this._docs.splice(idx, 1);
1574
- this._myIndex.removeAt(idx);
1575
- }
1576
-
1577
- getIndex() {
1578
- return this._myIndex
1579
- }
1580
-
1581
- search(query, { limit = -1 } = {}) {
1582
- const {
1583
- includeMatches,
1584
- includeScore,
1585
- shouldSort,
1586
- sortFn,
1587
- ignoreFieldNorm
1588
- } = this.options;
1589
-
1590
- let results = isString(query)
1591
- ? isString(this._docs[0])
1592
- ? this._searchStringList(query)
1593
- : this._searchObjectList(query)
1594
- : this._searchLogical(query);
1595
-
1596
- computeScore(results, { ignoreFieldNorm });
1597
-
1598
- if (shouldSort) {
1599
- results.sort(sortFn);
1600
- }
1601
-
1602
- if (isNumber(limit) && limit > -1) {
1603
- results = results.slice(0, limit);
1604
- }
1605
-
1606
- return format(results, this._docs, {
1607
- includeMatches,
1608
- includeScore
1609
- })
1610
- }
1611
-
1612
- _searchStringList(query) {
1613
- const searcher = createSearcher(query, this.options);
1614
- const { records } = this._myIndex;
1615
- const results = [];
1616
-
1617
- // Iterate over every string in the index
1618
- records.forEach(({ v: text, i: idx, n: norm }) => {
1619
- if (!isDefined(text)) {
1620
- return
1621
- }
1622
-
1623
- const { isMatch, score, indices } = searcher.searchIn(text);
1624
-
1625
- if (isMatch) {
1626
- results.push({
1627
- item: text,
1628
- idx,
1629
- matches: [{ score, value: text, norm, indices }]
1630
- });
1631
- }
1632
- });
1633
-
1634
- return results
1635
- }
1636
-
1637
- _searchLogical(query) {
1638
-
1639
- const expression = parse(query, this.options);
1640
-
1641
- const evaluate = (node, item, idx) => {
1642
- if (!node.children) {
1643
- const { keyId, searcher } = node;
1644
-
1645
- const matches = this._findMatches({
1646
- key: this._keyStore.get(keyId),
1647
- value: this._myIndex.getValueForItemAtKeyId(item, keyId),
1648
- searcher
1649
- });
1650
-
1651
- if (matches && matches.length) {
1652
- return [
1653
- {
1654
- idx,
1655
- item,
1656
- matches
1657
- }
1658
- ]
1659
- }
1660
-
1661
- return []
1662
- }
1663
-
1664
- const res = [];
1665
- for (let i = 0, len = node.children.length; i < len; i += 1) {
1666
- const child = node.children[i];
1667
- const result = evaluate(child, item, idx);
1668
- if (result.length) {
1669
- res.push(...result);
1670
- } else if (node.operator === LogicalOperator.AND) {
1671
- return []
1672
- }
1673
- }
1674
- return res
1675
- };
1676
-
1677
- const records = this._myIndex.records;
1678
- const resultMap = {};
1679
- const results = [];
1680
-
1681
- records.forEach(({ $: item, i: idx }) => {
1682
- if (isDefined(item)) {
1683
- let expResults = evaluate(expression, item, idx);
1684
-
1685
- if (expResults.length) {
1686
- // Dedupe when adding
1687
- if (!resultMap[idx]) {
1688
- resultMap[idx] = { idx, item, matches: [] };
1689
- results.push(resultMap[idx]);
1690
- }
1691
- expResults.forEach(({ matches }) => {
1692
- resultMap[idx].matches.push(...matches);
1693
- });
1694
- }
1695
- }
1696
- });
1697
-
1698
- return results
1699
- }
1700
-
1701
- _searchObjectList(query) {
1702
- const searcher = createSearcher(query, this.options);
1703
- const { keys, records } = this._myIndex;
1704
- const results = [];
1705
-
1706
- // List is Array<Object>
1707
- records.forEach(({ $: item, i: idx }) => {
1708
- if (!isDefined(item)) {
1709
- return
1710
- }
1711
-
1712
- let matches = [];
1713
-
1714
- // Iterate over every key (i.e, path), and fetch the value at that key
1715
- keys.forEach((key, keyIndex) => {
1716
- matches.push(
1717
- ...this._findMatches({
1718
- key,
1719
- value: item[keyIndex],
1720
- searcher
1721
- })
1722
- );
1723
- });
1724
-
1725
- if (matches.length) {
1726
- results.push({
1727
- idx,
1728
- item,
1729
- matches
1730
- });
1731
- }
1732
- });
1733
-
1734
- return results
1735
- }
1736
- _findMatches({ key, value, searcher }) {
1737
- if (!isDefined(value)) {
1738
- return []
1739
- }
1740
-
1741
- let matches = [];
1742
-
1743
- if (isArray(value)) {
1744
- value.forEach(({ v: text, i: idx, n: norm }) => {
1745
- if (!isDefined(text)) {
1746
- return
1747
- }
1748
-
1749
- const { isMatch, score, indices } = searcher.searchIn(text);
1750
-
1751
- if (isMatch) {
1752
- matches.push({
1753
- score,
1754
- key,
1755
- value: text,
1756
- idx,
1757
- norm,
1758
- indices
1759
- });
1760
- }
1761
- });
1762
- } else {
1763
- const { v: text, n: norm } = value;
1764
-
1765
- const { isMatch, score, indices } = searcher.searchIn(text);
1766
-
1767
- if (isMatch) {
1768
- matches.push({ score, key, value: text, norm, indices });
1769
- }
1770
- }
1771
-
1772
- return matches
1773
- }
1774
- }
1775
-
1776
- Fuse.version = '7.0.0';
1777
- Fuse.createIndex = createIndex;
1778
- Fuse.parseIndex = parseIndex;
1779
- Fuse.config = Config;
1780
-
1781
- {
1782
- Fuse.parseQuery = parse;
1783
- }
1784
-
1785
- {
1786
- register(ExtendedSearch);
1787
- }
1788
-
1789
- const GreenCheckDuotoneIcon = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
1790
- <path d="M7.99996 2.6665C5.05444 2.6665 2.66663 5.05432 2.66663 7.99984C2.66663 10.9454 5.05444 13.3332 7.99996 13.3332C10.9455 13.3332 13.3333 10.9454 13.3333 7.99984C13.3333 5.05432 10.9455 2.6665 7.99996 2.6665Z" fill="#AFF8C3"/>
1791
- <path fill-rule="evenodd" clip-rule="evenodd" d="M10.1403 6.10535C10.3582 6.27488 10.3975 6.58902 10.228 6.80699L8.01055 9.65797C7.76436 9.97449 7.29646 10.0036 7.01291 9.72008L5.81307 8.52024C5.61781 8.32498 5.61781 8.0084 5.81307 7.81314C6.00833 7.61787 6.32492 7.61787 6.52018 7.81314L7.45301 8.74597L9.43862 6.19305C9.60815 5.97508 9.92229 5.93581 10.1403 6.10535Z" fill="#246627"/>
1792
- </svg>
1793
- `;
1794
-
1795
- const zonosCountrySelectCss = ":host{font-family:var(--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--country-select{position:relative}:host .zonos--country-select .zonos--country-select-header{position:-webkit-sticky;position:sticky;top:0;background:var(--zonos-elements-surface-color);z-index:11}:host .zonos--country-select .zonos--country-select-input{padding:8px;border-radius:var(--zonos-elements-radius-4);border:var(--zonos-elements-border)}:host .zonos--country-select .zonos--country-select-content{padding:16px;padding-top:0px}:host .zonos--country-select .zonos--country-select-country{display:-ms-flexbox;display:flex;gap:16px;padding:8px;-ms-flex-align:center;align-items:center;border-radius:var(--zonos-elements-radius-4);cursor:pointer;width:100%;border:none;background:none}:host .zonos--country-select .zonos--country-select-country:hover{background:var(--zonos-elements-gray-100)}:host .zonos--country-select .zonos--country-select-country .zonos--country-flag{border-radius:var(--zonos-elements-radius-4);width:24px;height:18px;position:relative;overflow:hidden;-webkit-box-shadow:var(--zonos-elements-v3-shadow-medium);box-shadow:var(--zonos-elements-v3-shadow-medium);z-index:10;justify-self:center}@media (max-width: 768px){:host .zonos--country-select .zonos--country-select-country .zonos--country-flag{border-radius:var(--zonos-elements-radius-4);width:24px}}";
1796
- const ZonosCountrySelectStyle0 = zonosCountrySelectCss;
1797
-
1798
- const ZonosCountrySelect = /*@__PURE__*/ proxyCustomElement(class ZonosCountrySelect extends HTMLElement {
1799
- constructor() {
1800
- super();
1801
- this.__registerHost();
1802
- this.__attachShadow();
1803
- this.countrySelected = (countryCode) => {
1804
- // mutate the selected country code in store
1805
- void localizationStoreUpdateSelectedCountryCode(countryCode);
1806
- this.handleOnClose();
1807
- };
1808
- this.handleInputChange = (event) => {
1809
- const input = event.target;
1810
- this.inputValue = input.value;
1811
- };
1812
- this.handleOnClose = () => { };
1813
- this.inputValue = '';
1814
- }
1815
- componentDidRender() {
1816
- var _a, _b;
1817
- // focus the input on render
1818
- (_b = (_a = this.ele.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.zonos--country-select-input')) === null || _b === void 0 ? void 0 : _b.focus();
1819
- }
1820
- render() {
1821
- const { shippingZoneCountries } = localizationStore;
1822
- const countries = shippingZoneCountries
1823
- ? Object.values(shippingZoneCountries)
1824
- : [];
1825
- const fuse = new Fuse(countries, {
1826
- keys: ['displayName'],
1827
- });
1828
- const fuseObject = fuse.search(this.inputValue.toLowerCase());
1829
- const filteredCountries = this.inputValue
1830
- ? fuseObject.map(country => country.item)
1831
- : countries.sort((a, b) => a.displayName.localeCompare(b.displayName));
1832
- return (h(Host, { key: '67675ff9b37f110026ced223509104eb8ad805c0', class: "zonos--elements", style: {
1833
- '--font-family': zonosStoreFontFamily(),
1834
- } }, h("div", { key: '83d69dde89f0fafadf344ca0be017f43c468f154', class: "zonos--country-select" }, h("zonos-v-stack", { key: '8262345817217ba3f27ecf433ff56712b8018ae7', class: "zonos--country-select-header", spacing: 8 }, h("zonos-select-dialog-header", { key: '80ef94a9a2b1d7bdd835a9b31b09663f28b0532a', handleOnClose: () => this.handleOnClose(), label: "Select a country" }, h("input", { key: 'd3151d1287ee98b697e35f1f755694b250f089a3', class: "zonos--country-select-input", onInput: this.handleInputChange, placeholder: "Search countries", value: this.inputValue }))), h("div", { key: 'f98ff12368e49125f7fc2409f84bcbaef2143809', class: "zonos--country-select-content" }, filteredCountries.map(country => (h("button", { class: "zonos--country-select-country", onClick: () => this.countrySelected(country.code) }, h("zonos-country-flag", { class: "zonos--country-flag", countryCode: country.code }), h("zonos-text", { textColor: "gray-800" }, country.displayName), country.code === localizationStore.selectedCountryCode && (h("zonos-icon", { content: GreenCheckDuotoneIcon, size: 20 })))))))));
1835
- }
1836
- get ele() { return this; }
1837
- static get style() { return ZonosCountrySelectStyle0; }
1838
- }, [1, "zonos-country-select", {
1839
- "handleOnClose": [16],
1840
- "inputValue": [32]
1841
- }]);
1842
- function defineCustomElement() {
1843
- if (typeof customElements === "undefined") {
1844
- return;
1845
- }
1846
- const components = ["zonos-country-select", "zonos-button", "zonos-country-flag", "zonos-icon", "zonos-select-dialog-header", "zonos-spinner", "zonos-text", "zonos-v-stack"];
1847
- components.forEach(tagName => { switch (tagName) {
1848
- case "zonos-country-select":
1849
- if (!customElements.get(tagName)) {
1850
- customElements.define(tagName, ZonosCountrySelect);
1851
- }
1852
- break;
1853
- case "zonos-button":
1854
- if (!customElements.get(tagName)) {
1855
- defineCustomElement$7();
1856
- }
1857
- break;
1858
- case "zonos-country-flag":
1859
- if (!customElements.get(tagName)) {
1860
- defineCustomElement$6();
1861
- }
1862
- break;
1863
- case "zonos-icon":
1864
- if (!customElements.get(tagName)) {
1865
- defineCustomElement$5();
1866
- }
1867
- break;
1868
- case "zonos-select-dialog-header":
1869
- if (!customElements.get(tagName)) {
1870
- defineCustomElement$4();
1871
- }
1872
- break;
1873
- case "zonos-spinner":
1874
- if (!customElements.get(tagName)) {
1875
- defineCustomElement$3();
1876
- }
1877
- break;
1878
- case "zonos-text":
1879
- if (!customElements.get(tagName)) {
1880
- defineCustomElement$2();
1881
- }
1882
- break;
1883
- case "zonos-v-stack":
1884
- if (!customElements.get(tagName)) {
1885
- defineCustomElement$1();
1886
- }
1887
- break;
1888
- } });
1889
- }
1890
-
1891
- export { ZonosCountrySelect as Z, defineCustomElement as d };