@zonos/elements 1.3.274 → 1.3.276

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 (355) hide show
  1. package/dist/cjs/{cart-660e115c.js → cart-65e8da66.js} +41 -15
  2. package/dist/cjs/{cleanHtmlMarkdown-31da84b7.js → cleanHtmlMarkdown-57147de7.js} +180 -356
  3. package/dist/cjs/{collect-286a9d04.js → collect-37c177ab.js} +3 -3
  4. package/dist/cjs/{debounce-7990f5ea.js → debounce-9a712c79.js} +1 -1
  5. package/dist/cjs/{getBorderRadius-fc683d94.js → getBorderRadius-4da24d7c.js} +1 -1
  6. package/dist/cjs/{getContrastColor-d5134ef3.js → getContrastColor-2fb235b8.js} +2 -2
  7. package/dist/cjs/{hasInclusivePrice-b35e81aa.js → hasInclusivePrice-798ce42d.js} +1 -1
  8. package/dist/cjs/index.cjs.js +7 -7
  9. package/dist/cjs/{invoice-f032089f.js → invoice-96f5c802.js} +3 -3
  10. package/dist/cjs/{isContrastColor-76592c92.js → isContrastColor-ef24b7aa.js} +1 -1
  11. package/dist/cjs/{isDarkColor-5d6ca405.js → isDarkColor-ebc74b4d.js} +1 -1
  12. package/dist/cjs/{localization-f4a64f6f.js → localization-90650d7d.js} +61 -1
  13. package/dist/cjs/{paypal-125259ab.js → paypal-1952f6ec.js} +5 -5
  14. package/dist/cjs/{placeTestOrder-02001a99.js → placeTestOrder-30191a8f.js} +2 -2
  15. package/dist/cjs/{renderCheckoutCurrency-cad156a7.js → renderCheckoutCurrency-fd35b4ef.js} +2 -2
  16. package/dist/cjs/{submitGtag-4906b161.js → submitGtag-74762255.js} +1 -1
  17. package/dist/cjs/{throttle-02c2e917.js → throttle-34f7abf1.js} +2 -2
  18. package/dist/cjs/{updateCheckoutSessionAttributes-47d73942.js → updateCheckoutSessionAttributes-f595319d.js} +1 -1
  19. package/dist/cjs/zonos-address-display_8.cjs.entry.js +444 -202
  20. package/dist/cjs/zonos-address_4.cjs.entry.js +7 -7
  21. package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +7 -6
  22. package/dist/cjs/zonos-badge.cjs.entry.js +1 -1
  23. package/dist/cjs/zonos-banner.cjs.entry.js +1 -1
  24. package/dist/cjs/zonos-button_3.cjs.entry.js +3 -3
  25. package/dist/cjs/zonos-card_5.cjs.entry.js +9 -8
  26. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +83 -18
  27. package/dist/cjs/zonos-checkbox_2.cjs.entry.js +3 -3
  28. package/dist/cjs/zonos-checkout.cjs.entry.js +11 -10
  29. package/dist/cjs/zonos-collapse.cjs.entry.js +1 -1
  30. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +7 -6
  31. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +12 -11
  32. package/dist/cjs/zonos-collect.cjs.entry.js +10 -9
  33. package/dist/cjs/zonos-controller.cjs.entry.js +7 -6
  34. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
  35. package/dist/cjs/zonos-country-select_4.cjs.entry.js +1514 -1692
  36. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +3 -3
  37. package/dist/cjs/zonos-hello.cjs.entry.js +3 -3
  38. package/dist/cjs/zonos-input.cjs.entry.js +2 -2
  39. package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +8 -7
  40. package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +12 -11
  41. package/dist/cjs/zonos-invoice.cjs.entry.js +10 -9
  42. package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
  43. package/dist/cjs/zonos-logo.cjs.entry.js +1 -1
  44. package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +7 -6
  45. package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +5 -5
  46. package/dist/cjs/zonos-stripe-input.cjs.entry.js +3 -3
  47. package/dist/cjs/zonos-text.cjs.entry.js +1 -1
  48. package/dist/cjs/zonos-v-stack.cjs.entry.js +1 -1
  49. package/dist/collection/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.js +52 -1
  50. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +1 -1
  51. package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +18 -2
  52. package/dist/collection/components/common/zonos-stripe-phone-input/zonos-stripe-phone-input.js +1 -1
  53. package/dist/collection/components/main/zonos-controller.js +1 -1
  54. package/dist/collection/components/store/checkout/cart.js +21 -11
  55. package/dist/collection/components/store/translationStore/strings.arabic.js +3 -0
  56. package/dist/collection/components/store/translationStore/strings.base.js +3 -0
  57. package/dist/collection/components/store/translationStore/strings.chinese.js +3 -0
  58. package/dist/collection/components/store/translationStore/strings.danish.js +3 -0
  59. package/dist/collection/components/store/translationStore/strings.dutch.js +3 -0
  60. package/dist/collection/components/store/translationStore/strings.french.js +3 -0
  61. package/dist/collection/components/store/translationStore/strings.german.js +3 -0
  62. package/dist/collection/components/store/translationStore/strings.hebrew.js +3 -0
  63. package/dist/collection/components/store/translationStore/strings.indonesian.js +3 -0
  64. package/dist/collection/components/store/translationStore/strings.italian.js +3 -0
  65. package/dist/collection/components/store/translationStore/strings.japanese.js +3 -0
  66. package/dist/collection/components/store/translationStore/strings.korean.js +3 -0
  67. package/dist/collection/components/store/translationStore/strings.norwegian.js +3 -0
  68. package/dist/collection/components/store/translationStore/strings.polish.js +3 -0
  69. package/dist/collection/components/store/translationStore/strings.portuguese.js +3 -0
  70. package/dist/collection/components/store/translationStore/strings.russian.js +3 -0
  71. package/dist/collection/components/store/translationStore/strings.spanish.js +3 -0
  72. package/dist/collection/components/store/translationStore/strings.swedish.js +3 -0
  73. package/dist/collection/components/store/translationStore/strings.turkish.js +3 -0
  74. package/dist/collection/components/store/translationStore/strings.vietnamese.js +3 -0
  75. package/dist/collection/components/utils/checkout/isEuDapRemittance.js +15 -0
  76. package/dist/collection/types/generated/graphql.internal.types.js +78 -0
  77. package/dist/esm/{cart-23e29950.js → cart-402dcde5.js} +41 -16
  78. package/dist/esm/{cleanHtmlMarkdown-5f7856f2.js → cleanHtmlMarkdown-87d195f6.js} +180 -356
  79. package/dist/esm/{collect-a235299d.js → collect-b88fe4ca.js} +3 -3
  80. package/dist/esm/{debounce-58e4ff3e.js → debounce-c8d67b17.js} +1 -1
  81. package/dist/esm/{getBorderRadius-d23f47a6.js → getBorderRadius-dc982fe6.js} +1 -1
  82. package/dist/esm/{getContrastColor-f0bd5b65.js → getContrastColor-af895b60.js} +2 -2
  83. package/dist/esm/{hasInclusivePrice-5e106f84.js → hasInclusivePrice-1589fef9.js} +1 -1
  84. package/dist/esm/index.js +7 -7
  85. package/dist/esm/{invoice-78f069c7.js → invoice-5eb27944.js} +3 -3
  86. package/dist/esm/{isContrastColor-fbddacb6.js → isContrastColor-089de6ac.js} +1 -1
  87. package/dist/esm/{isDarkColor-566f04c5.js → isDarkColor-039ef212.js} +1 -1
  88. package/dist/esm/{localization-17546792.js → localization-d49867ed.js} +61 -1
  89. package/dist/esm/{paypal-5bc6b0d0.js → paypal-2d4c9d01.js} +5 -5
  90. package/dist/esm/{placeTestOrder-e842854a.js → placeTestOrder-2ba7c3f2.js} +2 -2
  91. package/dist/esm/{renderCheckoutCurrency-e3953f67.js → renderCheckoutCurrency-ef71083e.js} +2 -2
  92. package/dist/esm/{submitGtag-c7ea1f2a.js → submitGtag-dc54f5b9.js} +1 -1
  93. package/dist/esm/{throttle-f09d0659.js → throttle-44bfb6b5.js} +2 -2
  94. package/dist/esm/{updateCheckoutSessionAttributes-40e301a4.js → updateCheckoutSessionAttributes-e0a282d9.js} +1 -1
  95. package/dist/esm/zonos-address-display_8.entry.js +444 -202
  96. package/dist/esm/zonos-address_4.entry.js +7 -7
  97. package/dist/esm/zonos-airwallex-payment.entry.js +7 -6
  98. package/dist/esm/zonos-badge.entry.js +1 -1
  99. package/dist/esm/zonos-banner.entry.js +1 -1
  100. package/dist/esm/zonos-button_3.entry.js +3 -3
  101. package/dist/esm/zonos-card_5.entry.js +9 -8
  102. package/dist/esm/zonos-cart-items_12.entry.js +83 -18
  103. package/dist/esm/zonos-checkbox_2.entry.js +3 -3
  104. package/dist/esm/zonos-checkout.entry.js +11 -10
  105. package/dist/esm/zonos-collapse.entry.js +1 -1
  106. package/dist/esm/zonos-collect-cart-items_3.entry.js +7 -6
  107. package/dist/esm/zonos-collect-finish_6.entry.js +12 -11
  108. package/dist/esm/zonos-collect.entry.js +10 -9
  109. package/dist/esm/zonos-controller.entry.js +7 -6
  110. package/dist/esm/zonos-country-flag.entry.js +2 -2
  111. package/dist/esm/zonos-country-select_4.entry.js +1514 -1692
  112. package/dist/esm/zonos-hello-dialog.entry.js +3 -3
  113. package/dist/esm/zonos-hello.entry.js +3 -3
  114. package/dist/esm/zonos-input.entry.js +2 -2
  115. package/dist/esm/zonos-invoice-cart-items_2.entry.js +8 -7
  116. package/dist/esm/zonos-invoice-finish_5.entry.js +12 -11
  117. package/dist/esm/zonos-invoice.entry.js +10 -9
  118. package/dist/esm/zonos-language-select_2.entry.js +2 -2
  119. package/dist/esm/zonos-logo.entry.js +1 -1
  120. package/dist/esm/zonos-policy-consent_2.entry.js +7 -6
  121. package/dist/esm/zonos-shipping-rich-radio.entry.js +5 -5
  122. package/dist/esm/zonos-stripe-input.entry.js +3 -3
  123. package/dist/esm/zonos-text.entry.js +1 -1
  124. package/dist/esm/zonos-v-stack.entry.js +1 -1
  125. package/dist/esm-es5/cart-402dcde5.js +1 -0
  126. package/dist/esm-es5/cleanHtmlMarkdown-87d195f6.js +1 -0
  127. package/dist/esm-es5/{collect-a235299d.js → collect-b88fe4ca.js} +1 -1
  128. package/dist/esm-es5/{debounce-58e4ff3e.js → debounce-c8d67b17.js} +1 -1
  129. package/dist/esm-es5/{getBorderRadius-d23f47a6.js → getBorderRadius-dc982fe6.js} +1 -1
  130. package/dist/esm-es5/{getContrastColor-f0bd5b65.js → getContrastColor-af895b60.js} +1 -1
  131. package/dist/esm-es5/{hasInclusivePrice-5e106f84.js → hasInclusivePrice-1589fef9.js} +1 -1
  132. package/dist/esm-es5/index.js +1 -1
  133. package/dist/esm-es5/{invoice-78f069c7.js → invoice-5eb27944.js} +1 -1
  134. package/dist/esm-es5/{isContrastColor-fbddacb6.js → isContrastColor-089de6ac.js} +1 -1
  135. package/dist/esm-es5/{isDarkColor-566f04c5.js → isDarkColor-039ef212.js} +1 -1
  136. package/dist/esm-es5/localization-d49867ed.js +1 -0
  137. package/dist/esm-es5/{paypal-5bc6b0d0.js → paypal-2d4c9d01.js} +1 -1
  138. package/dist/esm-es5/{placeTestOrder-e842854a.js → placeTestOrder-2ba7c3f2.js} +1 -1
  139. package/dist/esm-es5/{renderCheckoutCurrency-e3953f67.js → renderCheckoutCurrency-ef71083e.js} +1 -1
  140. package/dist/esm-es5/{submitGtag-c7ea1f2a.js → submitGtag-dc54f5b9.js} +1 -1
  141. package/dist/esm-es5/throttle-44bfb6b5.js +1 -0
  142. package/dist/esm-es5/{updateCheckoutSessionAttributes-40e301a4.js → updateCheckoutSessionAttributes-e0a282d9.js} +1 -1
  143. package/dist/esm-es5/zonos-address-display_8.entry.js +1 -1
  144. package/dist/esm-es5/zonos-address_4.entry.js +1 -1
  145. package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
  146. package/dist/esm-es5/zonos-badge.entry.js +1 -1
  147. package/dist/esm-es5/zonos-banner.entry.js +1 -1
  148. package/dist/esm-es5/zonos-button_3.entry.js +1 -1
  149. package/dist/esm-es5/zonos-card_5.entry.js +1 -1
  150. package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
  151. package/dist/esm-es5/zonos-checkbox_2.entry.js +1 -1
  152. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  153. package/dist/esm-es5/zonos-collapse.entry.js +1 -1
  154. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  155. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
  156. package/dist/esm-es5/zonos-collect.entry.js +1 -1
  157. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  158. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  159. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  160. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  161. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  162. package/dist/esm-es5/zonos-input.entry.js +1 -1
  163. package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
  164. package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
  165. package/dist/esm-es5/zonos-invoice.entry.js +1 -1
  166. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  167. package/dist/esm-es5/zonos-logo.entry.js +1 -1
  168. package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
  169. package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
  170. package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
  171. package/dist/esm-es5/zonos-text.entry.js +1 -1
  172. package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
  173. package/dist/scripts/analyticsRelayOnInit.js +1 -1
  174. package/dist/scripts/blurCurrencyOnInit.js +1 -1
  175. package/dist/scripts/index.d.ts +11 -0
  176. package/dist/scripts/index.js +1 -1
  177. package/dist/scripts/loadZonos.js +1 -1
  178. package/dist/scripts/zonos.js +1 -1
  179. package/dist/types/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.d.ts +8 -0
  180. package/dist/types/components/store/checkout/cart.d.ts +2 -2
  181. package/dist/types/components/store/translationStore/strings.arabic.d.ts +3 -0
  182. package/dist/types/components/store/translationStore/strings.base.d.ts +3 -0
  183. package/dist/types/components/store/translationStore/strings.chinese.d.ts +3 -0
  184. package/dist/types/components/store/translationStore/strings.danish.d.ts +3 -0
  185. package/dist/types/components/store/translationStore/strings.dutch.d.ts +3 -0
  186. package/dist/types/components/store/translationStore/strings.french.d.ts +3 -0
  187. package/dist/types/components/store/translationStore/strings.german.d.ts +3 -0
  188. package/dist/types/components/store/translationStore/strings.hebrew.d.ts +3 -0
  189. package/dist/types/components/store/translationStore/strings.indonesian.d.ts +3 -0
  190. package/dist/types/components/store/translationStore/strings.italian.d.ts +3 -0
  191. package/dist/types/components/store/translationStore/strings.japanese.d.ts +3 -0
  192. package/dist/types/components/store/translationStore/strings.korean.d.ts +3 -0
  193. package/dist/types/components/store/translationStore/strings.norwegian.d.ts +3 -0
  194. package/dist/types/components/store/translationStore/strings.polish.d.ts +3 -0
  195. package/dist/types/components/store/translationStore/strings.portuguese.d.ts +3 -0
  196. package/dist/types/components/store/translationStore/strings.russian.d.ts +3 -0
  197. package/dist/types/components/store/translationStore/strings.spanish.d.ts +3 -0
  198. package/dist/types/components/store/translationStore/strings.swedish.d.ts +3 -0
  199. package/dist/types/components/store/translationStore/strings.turkish.d.ts +3 -0
  200. package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +3 -0
  201. package/dist/types/components/utils/checkout/isEuDapRemittance.d.ts +15 -0
  202. package/dist/types/types/generated/graphql.internal.types.d.ts +94 -0
  203. package/dist/types/types/generated/graphql.internal.types.ts +114 -7
  204. package/dist/zonos-elements/index.esm.js +1 -1
  205. package/dist/zonos-elements/{p-ccd14aa5.entry.js → p-0745e440.entry.js} +1 -1
  206. package/dist/zonos-elements/{p-59b10526.entry.js → p-08e78d79.entry.js} +1 -1
  207. package/dist/zonos-elements/{p-c846a5f3.system.entry.js → p-0ad6a92b.system.entry.js} +1 -1
  208. package/dist/zonos-elements/p-0b321037.system.entry.js +1 -0
  209. package/dist/zonos-elements/{p-b59fc3fa.system.entry.js → p-0e1f13ff.system.entry.js} +1 -1
  210. package/dist/zonos-elements/p-10715fee.system.entry.js +1 -0
  211. package/dist/zonos-elements/p-144a380d.entry.js +1 -0
  212. package/dist/zonos-elements/{p-c6823974.system.entry.js → p-15097876.system.entry.js} +1 -1
  213. package/dist/zonos-elements/{p-9f5fb332.js → p-1735a69b.js} +1 -1
  214. package/dist/zonos-elements/p-18135660.entry.js +1 -0
  215. package/dist/zonos-elements/{p-055ef910.entry.js → p-1992fd91.entry.js} +1 -1
  216. package/dist/zonos-elements/p-1e4dcd29.entry.js +1 -0
  217. package/dist/zonos-elements/{p-daf57db3.system.entry.js → p-293183c1.system.entry.js} +1 -1
  218. package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
  219. package/dist/zonos-elements/{p-a1a05de4.system.entry.js → p-29c1703c.system.entry.js} +1 -1
  220. package/dist/zonos-elements/p-2e0d813f.system.js +1 -0
  221. package/dist/zonos-elements/{p-d25759fb.system.js → p-2ea73ca2.system.js} +1 -1
  222. package/dist/zonos-elements/p-30e9a6d7.system.js +1 -0
  223. package/dist/zonos-elements/{p-33d4be28.js → p-34d6eb83.js} +1 -1
  224. package/dist/zonos-elements/p-35fd0fdb.js +1 -0
  225. package/dist/zonos-elements/p-3b479012.js +1 -0
  226. package/dist/zonos-elements/{p-d5e66ea6.entry.js → p-3cf22558.entry.js} +1 -1
  227. package/dist/zonos-elements/p-3cfa4880.js +1 -0
  228. package/dist/zonos-elements/{p-896fb969.js → p-3d28353a.js} +1 -1
  229. package/dist/zonos-elements/{p-328fd90e.entry.js → p-3e058b4e.entry.js} +1 -1
  230. package/dist/zonos-elements/p-3feff726.entry.js +1 -0
  231. package/dist/zonos-elements/{p-0a54dae6.system.entry.js → p-429ab545.system.entry.js} +1 -1
  232. package/dist/zonos-elements/p-42ba4da5.system.entry.js +1 -0
  233. package/dist/zonos-elements/p-45535a81.js +1 -0
  234. package/dist/zonos-elements/p-48627415.system.entry.js +1 -0
  235. package/dist/zonos-elements/{p-f053975e.system.js → p-496accce.system.js} +1 -1
  236. package/dist/zonos-elements/p-4a1c9fa1.entry.js +1 -0
  237. package/dist/zonos-elements/{p-86a9f048.system.entry.js → p-4a6f9c5e.system.entry.js} +1 -1
  238. package/dist/zonos-elements/p-4b06044f.js +1 -0
  239. package/dist/zonos-elements/p-4d29dcc8.entry.js +1 -0
  240. package/dist/zonos-elements/{p-1f31f5a0.system.entry.js → p-4e6e9a3c.system.entry.js} +1 -1
  241. package/dist/zonos-elements/{p-12a05647.entry.js → p-4efd7178.entry.js} +1 -1
  242. package/dist/zonos-elements/p-521cbeea.entry.js +1 -0
  243. package/dist/zonos-elements/p-534057ad.system.entry.js +1 -0
  244. package/dist/zonos-elements/p-55195dab.entry.js +1 -0
  245. package/dist/zonos-elements/p-58b56c69.entry.js +1 -0
  246. package/dist/zonos-elements/{p-10571f94.system.entry.js → p-5aee5de5.system.entry.js} +1 -1
  247. package/dist/zonos-elements/p-5c30d04b.js +1 -0
  248. package/dist/zonos-elements/p-5ce88ef3.system.entry.js +1 -0
  249. package/dist/zonos-elements/{p-2a1247f4.system.entry.js → p-5d3ea491.system.entry.js} +1 -1
  250. package/dist/zonos-elements/{p-dcef2202.entry.js → p-5d4201d5.entry.js} +1 -1
  251. package/dist/zonos-elements/p-5e3b0ef4.entry.js +1 -0
  252. package/dist/zonos-elements/{p-80df7e0b.system.entry.js → p-6146bfaa.system.entry.js} +1 -1
  253. package/dist/zonos-elements/{p-e548b8ec.entry.js → p-62609f19.entry.js} +1 -1
  254. package/dist/zonos-elements/p-628fe742.system.entry.js +1 -0
  255. package/dist/zonos-elements/{p-91b921a4.system.js → p-647438d6.system.js} +1 -1
  256. package/dist/zonos-elements/p-67dac4e5.system.entry.js +1 -0
  257. package/dist/zonos-elements/p-684e27da.system.js +1 -0
  258. package/dist/zonos-elements/{p-14018649.system.js → p-6ad0f720.system.js} +1 -1
  259. package/dist/zonos-elements/{p-45d74be2.system.js → p-6f324051.system.js} +1 -1
  260. package/dist/zonos-elements/p-77ac8bfe.entry.js +1 -0
  261. package/dist/zonos-elements/{p-4df08fc4.js → p-7bdce9d4.js} +1 -1
  262. package/dist/zonos-elements/p-82341c15.entry.js +1 -0
  263. package/dist/zonos-elements/p-864525b4.system.entry.js +1 -0
  264. package/dist/zonos-elements/p-89befc63.system.entry.js +1 -0
  265. package/dist/zonos-elements/{p-c83bc4b3.entry.js → p-8c54aaec.entry.js} +1 -1
  266. package/dist/zonos-elements/{p-306e5499.system.entry.js → p-998f9df5.system.entry.js} +1 -1
  267. package/dist/zonos-elements/{p-3eba657b.system.entry.js → p-99e8743e.system.entry.js} +1 -1
  268. package/dist/zonos-elements/p-9fab45aa.system.js +1 -0
  269. package/dist/zonos-elements/{p-42948a52.js → p-a02ff788.js} +1 -1
  270. package/dist/zonos-elements/p-a1bd3a53.system.js +1 -0
  271. package/dist/zonos-elements/{p-e9c8a235.js → p-a3bc7e97.js} +1 -1
  272. package/dist/zonos-elements/p-a3c116d6.system.js +1 -0
  273. package/dist/zonos-elements/{p-5aa35d1c.system.entry.js → p-a3d3ce5d.system.entry.js} +1 -1
  274. package/dist/zonos-elements/{p-27e50593.system.entry.js → p-a44591f6.system.entry.js} +1 -1
  275. package/dist/zonos-elements/p-a7050d1e.system.entry.js +1 -0
  276. package/dist/zonos-elements/p-ac1b60c8.system.entry.js +1 -0
  277. package/dist/zonos-elements/{p-e8cb382e.entry.js → p-ac9b9f7d.entry.js} +1 -1
  278. package/dist/zonos-elements/{p-2197d6ab.js → p-b1c86a5b.js} +1 -1
  279. package/dist/zonos-elements/{p-cc508de8.entry.js → p-b5f67807.entry.js} +1 -1
  280. package/dist/zonos-elements/p-b7e4f1f5.entry.js +1 -0
  281. package/dist/zonos-elements/p-c209e36d.js +1 -0
  282. package/dist/zonos-elements/p-c750a2e0.system.entry.js +1 -0
  283. package/dist/zonos-elements/p-cc6ad18a.js +1 -0
  284. package/dist/zonos-elements/{p-c1463da7.entry.js → p-d1e84608.entry.js} +1 -1
  285. package/dist/zonos-elements/{p-9c3276c8.entry.js → p-d5945ddc.entry.js} +1 -1
  286. package/dist/zonos-elements/{p-5d65be06.system.js → p-d706852e.system.js} +1 -1
  287. package/dist/zonos-elements/p-d7bda14d.js +1 -0
  288. package/dist/zonos-elements/{p-df55536b.entry.js → p-daab3824.entry.js} +1 -1
  289. package/dist/zonos-elements/{p-7d9d2407.system.js → p-dab78981.system.js} +1 -1
  290. package/dist/zonos-elements/{p-990d1495.system.entry.js → p-db65c60b.system.entry.js} +1 -1
  291. package/dist/zonos-elements/{p-bc919de1.system.js → p-e977562b.system.js} +1 -1
  292. package/dist/zonos-elements/{p-abd485df.entry.js → p-ee434a71.entry.js} +1 -1
  293. package/dist/zonos-elements/{p-3dc3596b.js → p-f1aea919.js} +1 -1
  294. package/dist/zonos-elements/{p-62c68aee.system.js → p-f2768c92.system.js} +1 -1
  295. package/dist/zonos-elements/p-f29bcf8b.system.js +1 -0
  296. package/dist/zonos-elements/{p-1a4083be.system.js → p-f2d50796.system.js} +1 -1
  297. package/dist/zonos-elements/p-f3a73132.entry.js +1 -0
  298. package/dist/zonos-elements/{p-f72642de.entry.js → p-f59514e9.entry.js} +1 -1
  299. package/dist/zonos-elements/{p-52bd7be3.system.js → p-f61c0eef.system.js} +1 -1
  300. package/dist/zonos-elements/p-ffbf87c8.system.entry.js +1 -0
  301. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  302. package/package.json +12 -35
  303. package/dist/esm-es5/cart-23e29950.js +0 -1
  304. package/dist/esm-es5/cleanHtmlMarkdown-5f7856f2.js +0 -1
  305. package/dist/esm-es5/localization-17546792.js +0 -1
  306. package/dist/esm-es5/throttle-f09d0659.js +0 -1
  307. package/dist/zonos-elements/p-013575f2.entry.js +0 -1
  308. package/dist/zonos-elements/p-08b48608.entry.js +0 -1
  309. package/dist/zonos-elements/p-0b59076d.system.entry.js +0 -1
  310. package/dist/zonos-elements/p-14d6542f.system.js +0 -1
  311. package/dist/zonos-elements/p-1678d8b4.system.entry.js +0 -1
  312. package/dist/zonos-elements/p-171d0f9f.system.js +0 -1
  313. package/dist/zonos-elements/p-18af6aaa.system.js +0 -1
  314. package/dist/zonos-elements/p-1a105d6e.system.entry.js +0 -1
  315. package/dist/zonos-elements/p-31577ebd.entry.js +0 -1
  316. package/dist/zonos-elements/p-33910e8b.js +0 -1
  317. package/dist/zonos-elements/p-3b28fc76.js +0 -1
  318. package/dist/zonos-elements/p-41619f29.js +0 -1
  319. package/dist/zonos-elements/p-46e72a90.entry.js +0 -1
  320. package/dist/zonos-elements/p-49d8a10f.entry.js +0 -1
  321. package/dist/zonos-elements/p-4a960329.system.entry.js +0 -1
  322. package/dist/zonos-elements/p-4b371b65.entry.js +0 -1
  323. package/dist/zonos-elements/p-539bc46c.js +0 -1
  324. package/dist/zonos-elements/p-5dd86dd9.system.js +0 -1
  325. package/dist/zonos-elements/p-6c19310e.system.entry.js +0 -1
  326. package/dist/zonos-elements/p-7eb47eb0.entry.js +0 -1
  327. package/dist/zonos-elements/p-8af57c2a.js +0 -1
  328. package/dist/zonos-elements/p-8c4761d1.system.entry.js +0 -1
  329. package/dist/zonos-elements/p-8e77a3cd.system.entry.js +0 -1
  330. package/dist/zonos-elements/p-90d22087.system.js +0 -1
  331. package/dist/zonos-elements/p-919c5500.entry.js +0 -1
  332. package/dist/zonos-elements/p-9574695a.system.js +0 -1
  333. package/dist/zonos-elements/p-9581bffb.js +0 -1
  334. package/dist/zonos-elements/p-97917371.system.entry.js +0 -1
  335. package/dist/zonos-elements/p-9b003a15.system.entry.js +0 -1
  336. package/dist/zonos-elements/p-9cd41234.system.entry.js +0 -1
  337. package/dist/zonos-elements/p-a968ccba.entry.js +0 -1
  338. package/dist/zonos-elements/p-ac8cfdc0.js +0 -1
  339. package/dist/zonos-elements/p-ad961f5d.entry.js +0 -1
  340. package/dist/zonos-elements/p-b5c01288.system.entry.js +0 -1
  341. package/dist/zonos-elements/p-bf8c98ab.system.js +0 -1
  342. package/dist/zonos-elements/p-c13d2e3f.entry.js +0 -1
  343. package/dist/zonos-elements/p-cd34ecf2.js +0 -1
  344. package/dist/zonos-elements/p-df6fbf3f.entry.js +0 -1
  345. package/dist/zonos-elements/p-e643346a.entry.js +0 -1
  346. package/dist/zonos-elements/p-e8ec88a9.system.entry.js +0 -1
  347. package/dist/zonos-elements/p-e9afd736.system.entry.js +0 -1
  348. package/dist/zonos-elements/p-f0eb6317.system.entry.js +0 -1
  349. package/dist/zonos-elements/p-f1cc659c.js +0 -1
  350. package/dist/zonos-elements/p-f53c8a9f.entry.js +0 -1
  351. /package/dist/cjs/{zonosStore-45a87908.js → zonosStore-fee716c9.js} +0 -0
  352. /package/dist/esm/{zonosStore-8e19daff.js → zonosStore-b7d3f9b0.js} +0 -0
  353. /package/dist/esm-es5/{zonosStore-8e19daff.js → zonosStore-b7d3f9b0.js} +0 -0
  354. /package/dist/zonos-elements/{p-3e7ee89d.system.js → p-47a1d469.system.js} +0 -0
  355. /package/dist/zonos-elements/{p-701d9a7c.js → p-9a417eeb.js} +0 -0
@@ -1,1805 +1,1627 @@
1
1
  import { r as registerInstance, h, a as Host, g as getElement } from './index-cfd394c8.js';
2
- import { c as localizationStoreUpdateSelectedCountryCode, t as translate, l as localizationStore } from './localization-17546792.js';
3
- import { f as zonosStoreFontFamily } from './zonosStore-8e19daff.js';
2
+ import { c as localizationStoreUpdateSelectedCountryCode, t as translate, l as localizationStore } from './localization-d49867ed.js';
3
+ import { f as zonosStoreFontFamily } from './zonosStore-b7d3f9b0.js';
4
4
  import { f as formatStringWithLinks } from './formatStringWithLinks-9e819405.js';
5
- import { i as isDarkColor } from './isDarkColor-566f04c5.js';
5
+ import { i as isDarkColor } from './isDarkColor-039ef212.js';
6
6
  import { l as languages } from './ILanguage-cd6acb72.js';
7
7
  import { c as classes } from './classes-0d95c529.js';
8
8
  import './handleFetch-a844cac1.js';
9
9
  import './VarianceTest-572cecf5.js';
10
10
 
11
11
  /**
12
- * Fuse.js v7.1.0 - Lightweight fuzzy-search (http://fusejs.io)
12
+ * Fuse.js v7.4.2 - Lightweight fuzzy-search (http://fusejs.io)
13
13
  *
14
- * Copyright (c) 2025 Kiro Risk (http://kiro.me)
14
+ * Copyright (c) 2026 Kiro Risk (http://kiro.me)
15
15
  * All Rights Reserved. Apache Software License 2.0
16
16
  *
17
17
  * http://www.apache.org/licenses/LICENSE-2.0
18
18
  */
19
-
19
+ //#region src/helpers/typeGuards.ts
20
20
  function isArray(value) {
21
- return !Array.isArray
22
- ? getTag(value) === '[object Array]'
23
- : Array.isArray(value)
21
+ return !Array.isArray ? getTag(value) === "[object Array]" : Array.isArray(value);
24
22
  }
25
-
26
- // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js
27
- const INFINITY = 1 / 0;
28
23
  function baseToString(value) {
29
- // Exit early for strings to avoid a performance hit in some environments.
30
- if (typeof value == 'string') {
31
- return value
32
- }
33
- let result = value + '';
34
- return result == '0' && 1 / value == -INFINITY ? '-0' : result
24
+ if (typeof value == "string") return value;
25
+ if (typeof value === "bigint") return value.toString();
26
+ const result = value + "";
27
+ return result == "0" && 1 / value == -Infinity ? "-0" : result;
35
28
  }
36
-
37
29
  function toString(value) {
38
- return value == null ? '' : baseToString(value)
30
+ return value == null ? "" : baseToString(value);
39
31
  }
40
-
41
32
  function isString(value) {
42
- return typeof value === 'string'
33
+ return typeof value === "string";
43
34
  }
44
-
45
35
  function isNumber(value) {
46
- return typeof value === 'number'
36
+ return typeof value === "number";
47
37
  }
48
-
49
- // Adapted from: https://github.com/lodash/lodash/blob/master/isBoolean.js
50
38
  function isBoolean(value) {
51
- return (
52
- value === true ||
53
- value === false ||
54
- (isObjectLike(value) && getTag(value) == '[object Boolean]')
55
- )
39
+ return value === true || value === false || isObjectLike(value) && getTag(value) == "[object Boolean]";
56
40
  }
57
-
58
41
  function isObject(value) {
59
- return typeof value === 'object'
42
+ return typeof value === "object";
60
43
  }
61
-
62
- // Checks if `value` is object-like.
63
44
  function isObjectLike(value) {
64
- return isObject(value) && value !== null
45
+ return isObject(value) && value !== null;
65
46
  }
66
-
67
47
  function isDefined(value) {
68
- return value !== undefined && value !== null
48
+ return value !== void 0 && value !== null;
69
49
  }
70
-
71
50
  function isBlank(value) {
72
- return !value.trim().length
51
+ return !value.trim().length;
73
52
  }
74
-
75
- // Gets the `toStringTag` of `value`.
76
- // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/getTag.js
77
53
  function getTag(value) {
78
- return value == null
79
- ? value === undefined
80
- ? '[object Undefined]'
81
- : '[object Null]'
82
- : Object.prototype.toString.call(value)
54
+ return value == null ? value === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(value);
83
55
  }
84
56
 
85
- const EXTENDED_SEARCH_UNAVAILABLE = 'Extended search is not available';
86
-
57
+ //#endregion
58
+ //#region src/core/errorMessages.ts
87
59
  const INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
88
-
89
- const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) =>
90
- `Invalid value for key ${key}`;
91
-
92
- const PATTERN_LENGTH_TOO_LARGE = (max) =>
93
- `Pattern length exceeds max of ${max}.`;
94
-
60
+ const INVALID_DOC_INDEX = "Invalid doc index: must be a non-negative integer within the bounds of the docs array";
61
+ const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) => `Invalid value for key ${key}`;
62
+ const PATTERN_LENGTH_TOO_LARGE = (max) => `Pattern length exceeds max of ${max}.`;
95
63
  const MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`;
64
+ const INVALID_KEY_WEIGHT_VALUE = (key) => `Property 'weight' in key '${key}' must be a positive integer`;
65
+ const FUSE_MATCH_TOKEN_SEARCH_UNSUPPORTED = "Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.";
96
66
 
97
- const INVALID_KEY_WEIGHT_VALUE = (key) =>
98
- `Property 'weight' in key '${key}' must be a positive integer`;
99
-
67
+ //#endregion
68
+ //#region src/tools/KeyStore.ts
100
69
  const hasOwn = Object.prototype.hasOwnProperty;
101
-
102
- class KeyStore {
103
- constructor(keys) {
104
- this._keys = [];
105
- this._keyMap = {};
106
-
107
- let totalWeight = 0;
108
-
109
- keys.forEach((key) => {
110
- let obj = createKey(key);
111
-
112
- this._keys.push(obj);
113
- this._keyMap[obj.id] = obj;
114
-
115
- totalWeight += obj.weight;
116
- });
117
-
118
- // Normalize weights so that their sum is equal to 1
119
- this._keys.forEach((key) => {
120
- key.weight /= totalWeight;
121
- });
122
- }
123
- get(keyId) {
124
- return this._keyMap[keyId]
125
- }
126
- keys() {
127
- return this._keys
128
- }
129
- toJSON() {
130
- return JSON.stringify(this._keys)
131
- }
132
- }
133
-
70
+ var KeyStore = class {
71
+ constructor(keys) {
72
+ this._keys = [];
73
+ this._keyMap = {};
74
+ let totalWeight = 0;
75
+ keys.forEach((key) => {
76
+ const obj = createKey(key);
77
+ this._keys.push(obj);
78
+ this._keyMap[obj.id] = obj;
79
+ totalWeight += obj.weight;
80
+ });
81
+ this._keys.forEach((key) => {
82
+ key.weight /= totalWeight;
83
+ });
84
+ }
85
+ get(keyId) {
86
+ return this._keyMap[keyId];
87
+ }
88
+ keys() {
89
+ return this._keys;
90
+ }
91
+ toJSON() {
92
+ return JSON.stringify(this._keys);
93
+ }
94
+ };
134
95
  function createKey(key) {
135
- let path = null;
136
- let id = null;
137
- let src = null;
138
- let weight = 1;
139
- let getFn = null;
140
-
141
- if (isString(key) || isArray(key)) {
142
- src = key;
143
- path = createKeyPath(key);
144
- id = createKeyId(key);
145
- } else {
146
- if (!hasOwn.call(key, 'name')) {
147
- throw new Error(MISSING_KEY_PROPERTY('name'))
148
- }
149
-
150
- const name = key.name;
151
- src = name;
152
-
153
- if (hasOwn.call(key, 'weight')) {
154
- weight = key.weight;
155
-
156
- if (weight <= 0) {
157
- throw new Error(INVALID_KEY_WEIGHT_VALUE(name))
158
- }
159
- }
160
-
161
- path = createKeyPath(name);
162
- id = createKeyId(name);
163
- getFn = key.getFn;
164
- }
165
-
166
- return { path, id, weight, src, getFn }
96
+ let path = null;
97
+ let id = null;
98
+ let src = null;
99
+ let weight = 1;
100
+ let getFn = null;
101
+ if (isString(key) || isArray(key)) {
102
+ src = key;
103
+ path = createKeyPath(key);
104
+ id = createKeyId(key);
105
+ } else {
106
+ if (!hasOwn.call(key, "name")) throw new Error(MISSING_KEY_PROPERTY("name"));
107
+ const name = key.name;
108
+ src = name;
109
+ if (hasOwn.call(key, "weight") && key.weight !== void 0) {
110
+ weight = key.weight;
111
+ if (weight <= 0) throw new Error(INVALID_KEY_WEIGHT_VALUE(createKeyId(name)));
112
+ }
113
+ path = createKeyPath(name);
114
+ id = createKeyId(name);
115
+ getFn = key.getFn ?? null;
116
+ }
117
+ return {
118
+ path,
119
+ id,
120
+ weight,
121
+ src,
122
+ getFn
123
+ };
167
124
  }
168
-
169
125
  function createKeyPath(key) {
170
- return isArray(key) ? key : key.split('.')
126
+ return isArray(key) ? key : key.split(".");
171
127
  }
172
-
173
128
  function createKeyId(key) {
174
- return isArray(key) ? key.join('.') : key
129
+ return isArray(key) ? key.join(".") : key;
175
130
  }
176
131
 
132
+ //#endregion
133
+ //#region src/helpers/get.ts
177
134
  function get(obj, path) {
178
- let list = [];
179
- let arr = false;
180
-
181
- const deepGet = (obj, path, index) => {
182
- if (!isDefined(obj)) {
183
- return
184
- }
185
- if (!path[index]) {
186
- // If there's no path left, we've arrived at the object we care about.
187
- list.push(obj);
188
- } else {
189
- let key = path[index];
190
-
191
- const value = obj[key];
192
-
193
- if (!isDefined(value)) {
194
- return
195
- }
196
-
197
- // If we're at the last value in the path, and if it's a string/number/bool,
198
- // add it to the list
199
- if (
200
- index === path.length - 1 &&
201
- (isString(value) || isNumber(value) || isBoolean(value))
202
- ) {
203
- list.push(toString(value));
204
- } else if (isArray(value)) {
205
- arr = true;
206
- // Search each item in the array.
207
- for (let i = 0, len = value.length; i < len; i += 1) {
208
- deepGet(value[i], path, index + 1);
209
- }
210
- } else if (path.length) {
211
- // An object. Recurse further.
212
- deepGet(value, path, index + 1);
213
- }
214
- }
215
- };
216
-
217
- // Backwards compatibility (since path used to be a string)
218
- deepGet(obj, isString(path) ? path.split('.') : path, 0);
219
-
220
- return arr ? list : list[0]
135
+ const list = [];
136
+ let arr = false;
137
+ const deepGet = (obj, path, index, arrayIndex) => {
138
+ if (!isDefined(obj)) return;
139
+ if (!path[index]) list.push(arrayIndex !== void 0 ? {
140
+ v: obj,
141
+ i: arrayIndex
142
+ } : obj);
143
+ else {
144
+ const value = obj[path[index]];
145
+ if (!isDefined(value)) return;
146
+ if (index === path.length - 1 && (isString(value) || isNumber(value) || isBoolean(value) || typeof value === "bigint")) list.push(arrayIndex !== void 0 ? {
147
+ v: toString(value),
148
+ i: arrayIndex
149
+ } : toString(value));
150
+ else if (isArray(value)) {
151
+ arr = true;
152
+ for (let i = 0, len = value.length; i < len; i += 1) deepGet(value[i], path, index + 1, i);
153
+ } else if (path.length) deepGet(value, path, index + 1, arrayIndex);
154
+ }
155
+ };
156
+ deepGet(obj, isString(path) ? path.split(".") : path, 0);
157
+ return arr ? list : list[0];
221
158
  }
222
159
 
160
+ //#endregion
161
+ //#region src/core/config.ts
223
162
  const MatchOptions = {
224
- // Whether the matches should be included in the result set. When `true`, each record in the result
225
- // set will include the indices of the matched characters.
226
- // These can consequently be used for highlighting purposes.
227
- includeMatches: false,
228
- // When `true`, the matching function will continue to the end of a search pattern even if
229
- // a perfect match has already been located in the string.
230
- findAllMatches: false,
231
- // Minimum number of characters that must be matched before a result is considered a match
232
- minMatchCharLength: 1
163
+ includeMatches: false,
164
+ findAllMatches: false,
165
+ minMatchCharLength: 1
233
166
  };
234
-
235
167
  const BasicOptions = {
236
- // When `true`, the algorithm continues searching to the end of the input even if a perfect
237
- // match is found before the end of the same input.
238
- isCaseSensitive: false,
239
- // When `true`, the algorithm will ignore diacritics (accents) in comparisons
240
- ignoreDiacritics: false,
241
- // When true, the matching function will continue to the end of a search pattern even if
242
- includeScore: false,
243
- // List of properties that will be searched. This also supports nested properties.
244
- keys: [],
245
- // Whether to sort the result list, by score
246
- shouldSort: true,
247
- // Default sort function: sort by ascending score, ascending index
248
- sortFn: (a, b) =>
249
- a.score === b.score ? (a.idx < b.idx ? -1 : 1) : a.score < b.score ? -1 : 1
168
+ isCaseSensitive: false,
169
+ ignoreDiacritics: false,
170
+ includeScore: false,
171
+ keys: [],
172
+ shouldSort: true,
173
+ sortFn: (a, b) => a.score === b.score ? a.idx < b.idx ? -1 : 1 : a.score < b.score ? -1 : 1
250
174
  };
251
-
252
175
  const FuzzyOptions = {
253
- // Approximately where in the text is the pattern expected to be found?
254
- location: 0,
255
- // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
256
- // (of both letters and location), a threshold of '1.0' would match anything.
257
- threshold: 0.6,
258
- // Determines how close the match must be to the fuzzy location (specified above).
259
- // An exact letter match which is 'distance' characters away from the fuzzy location
260
- // would score as a complete mismatch. A distance of '0' requires the match be at
261
- // the exact location specified, a threshold of '1000' would require a perfect match
262
- // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
263
- distance: 100
176
+ location: 0,
177
+ threshold: .6,
178
+ distance: 100
264
179
  };
265
-
266
180
  const AdvancedOptions = {
267
- // When `true`, it enables the use of unix-like search commands
268
- useExtendedSearch: false,
269
- // The get function to use when fetching an object's properties.
270
- // The default will search nested paths *ie foo.bar.baz*
271
- getFn: get,
272
- // When `true`, search will ignore `location` and `distance`, so it won't matter
273
- // where in the string the pattern appears.
274
- // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
275
- ignoreLocation: false,
276
- // When `true`, the calculation for the relevance score (used for sorting) will
277
- // ignore the field-length norm.
278
- // More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
279
- ignoreFieldNorm: false,
280
- // The weight to determine how much field length norm effects scoring.
281
- fieldNormWeight: 1
282
- };
283
-
284
- var Config = {
285
- ...BasicOptions,
286
- ...MatchOptions,
287
- ...FuzzyOptions,
288
- ...AdvancedOptions
181
+ useExtendedSearch: false,
182
+ useTokenSearch: false,
183
+ tokenize: void 0,
184
+ tokenMatch: "any",
185
+ getFn: get,
186
+ ignoreLocation: false,
187
+ ignoreFieldNorm: false,
188
+ fieldNormWeight: 1
289
189
  };
190
+ const Config = Object.freeze({
191
+ ...BasicOptions,
192
+ ...MatchOptions,
193
+ ...FuzzyOptions,
194
+ ...AdvancedOptions
195
+ });
290
196
 
291
- const SPACE = /[^ ]+/g;
292
-
293
- // Field-length norm: the shorter the field, the higher the weight.
294
- // Set to 3 decimals to reduce index size.
197
+ //#endregion
198
+ //#region src/tools/fieldNorm.ts
295
199
  function norm(weight = 1, mantissa = 3) {
296
- const cache = new Map();
297
- const m = Math.pow(10, mantissa);
298
-
299
- return {
300
- get(value) {
301
- const numTokens = value.match(SPACE).length;
302
-
303
- if (cache.has(numTokens)) {
304
- return cache.get(numTokens)
305
- }
306
-
307
- // Default function is 1/sqrt(x), weight makes that variable
308
- const norm = 1 / Math.pow(numTokens, 0.5 * weight);
309
-
310
- // In place of `toFixed(mantissa)`, for faster computation
311
- const n = parseFloat(Math.round(norm * m) / m);
312
-
313
- cache.set(numTokens, n);
314
-
315
- return n
316
- },
317
- clear() {
318
- cache.clear();
319
- }
320
- }
321
- }
322
-
323
- class FuseIndex {
324
- constructor({
325
- getFn = Config.getFn,
326
- fieldNormWeight = Config.fieldNormWeight
327
- } = {}) {
328
- this.norm = norm(fieldNormWeight, 3);
329
- this.getFn = getFn;
330
- this.isCreated = false;
331
-
332
- this.setIndexRecords();
333
- }
334
- setSources(docs = []) {
335
- this.docs = docs;
336
- }
337
- setIndexRecords(records = []) {
338
- this.records = records;
339
- }
340
- setKeys(keys = []) {
341
- this.keys = keys;
342
- this._keysMap = {};
343
- keys.forEach((key, idx) => {
344
- this._keysMap[key.id] = idx;
345
- });
346
- }
347
- create() {
348
- if (this.isCreated || !this.docs.length) {
349
- return
350
- }
351
-
352
- this.isCreated = true;
353
-
354
- // List is Array<String>
355
- if (isString(this.docs[0])) {
356
- this.docs.forEach((doc, docIndex) => {
357
- this._addString(doc, docIndex);
358
- });
359
- } else {
360
- // List is Array<Object>
361
- this.docs.forEach((doc, docIndex) => {
362
- this._addObject(doc, docIndex);
363
- });
364
- }
365
-
366
- this.norm.clear();
367
- }
368
- // Adds a doc to the end of the index
369
- add(doc) {
370
- const idx = this.size();
371
-
372
- if (isString(doc)) {
373
- this._addString(doc, idx);
374
- } else {
375
- this._addObject(doc, idx);
376
- }
377
- }
378
- // Removes the doc at the specified index of the index
379
- removeAt(idx) {
380
- this.records.splice(idx, 1);
381
-
382
- // Change ref index of every subsquent doc
383
- for (let i = idx, len = this.size(); i < len; i += 1) {
384
- this.records[i].i -= 1;
385
- }
386
- }
387
- getValueForItemAtKeyId(item, keyId) {
388
- return item[this._keysMap[keyId]]
389
- }
390
- size() {
391
- return this.records.length
392
- }
393
- _addString(doc, docIndex) {
394
- if (!isDefined(doc) || isBlank(doc)) {
395
- return
396
- }
397
-
398
- let record = {
399
- v: doc,
400
- i: docIndex,
401
- n: this.norm.get(doc)
402
- };
403
-
404
- this.records.push(record);
405
- }
406
- _addObject(doc, docIndex) {
407
- let record = { i: docIndex, $: {} };
408
-
409
- // Iterate over every key (i.e, path), and fetch the value at that key
410
- this.keys.forEach((key, keyIndex) => {
411
- let value = key.getFn ? key.getFn(doc) : this.getFn(doc, key.path);
412
-
413
- if (!isDefined(value)) {
414
- return
415
- }
416
-
417
- if (isArray(value)) {
418
- let subRecords = [];
419
- const stack = [{ nestedArrIndex: -1, value }];
420
-
421
- while (stack.length) {
422
- const { nestedArrIndex, value } = stack.pop();
423
-
424
- if (!isDefined(value)) {
425
- continue
426
- }
427
-
428
- if (isString(value) && !isBlank(value)) {
429
- let subRecord = {
430
- v: value,
431
- i: nestedArrIndex,
432
- n: this.norm.get(value)
433
- };
434
-
435
- subRecords.push(subRecord);
436
- } else if (isArray(value)) {
437
- value.forEach((item, k) => {
438
- stack.push({
439
- nestedArrIndex: k,
440
- value: item
441
- });
442
- });
443
- } else ;
444
- }
445
- record.$[keyIndex] = subRecords;
446
- } else if (isString(value) && !isBlank(value)) {
447
- let subRecord = {
448
- v: value,
449
- n: this.norm.get(value)
450
- };
451
-
452
- record.$[keyIndex] = subRecord;
453
- }
454
- });
455
-
456
- this.records.push(record);
457
- }
458
- toJSON() {
459
- return {
460
- keys: this.keys,
461
- records: this.records
462
- }
463
- }
200
+ const cache = /* @__PURE__ */ new Map();
201
+ const m = Math.pow(10, mantissa);
202
+ return {
203
+ get(value) {
204
+ let numTokens = 1;
205
+ let inSpace = false;
206
+ for (let i = 0; i < value.length; i++) if (value.charCodeAt(i) === 32) {
207
+ if (!inSpace) {
208
+ numTokens++;
209
+ inSpace = true;
210
+ }
211
+ } else inSpace = false;
212
+ if (cache.has(numTokens)) return cache.get(numTokens);
213
+ const n = Math.round(m / Math.pow(numTokens, .5 * weight)) / m;
214
+ cache.set(numTokens, n);
215
+ return n;
216
+ },
217
+ clear() {
218
+ cache.clear();
219
+ }
220
+ };
464
221
  }
465
222
 
466
- function createIndex(
467
- keys,
468
- docs,
469
- { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}
470
- ) {
471
- const myIndex = new FuseIndex({ getFn, fieldNormWeight });
472
- myIndex.setKeys(keys.map(createKey));
473
- myIndex.setSources(docs);
474
- myIndex.create();
475
- return myIndex
223
+ //#endregion
224
+ //#region src/tools/FuseIndex.ts
225
+ var FuseIndex = class {
226
+ constructor({ getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) {
227
+ this.norm = norm(fieldNormWeight, 3);
228
+ this.getFn = getFn;
229
+ this.isCreated = false;
230
+ this.docs = [];
231
+ this.keys = [];
232
+ this._keysMap = {};
233
+ this.setIndexRecords();
234
+ }
235
+ setSources(docs = []) {
236
+ this.docs = docs;
237
+ }
238
+ setIndexRecords(records = []) {
239
+ this.records = records;
240
+ }
241
+ setKeys(keys = []) {
242
+ this.keys = keys;
243
+ this._keysMap = {};
244
+ keys.forEach((key, idx) => {
245
+ this._keysMap[key.id] = idx;
246
+ });
247
+ }
248
+ create() {
249
+ if (this.isCreated || !this.docs.length) return;
250
+ this.isCreated = true;
251
+ const len = this.docs.length;
252
+ this.records = new Array(len);
253
+ let recordCount = 0;
254
+ if (isString(this.docs[0])) for (let i = 0; i < len; i++) {
255
+ const record = this._createStringRecord(this.docs[i], i);
256
+ if (record) this.records[recordCount++] = record;
257
+ }
258
+ else for (let i = 0; i < len; i++) this.records[recordCount++] = this._createObjectRecord(this.docs[i], i);
259
+ this.records.length = recordCount;
260
+ this.norm.clear();
261
+ }
262
+ add(doc, docIndex) {
263
+ if (!Number.isInteger(docIndex) || docIndex < 0) throw new Error(INVALID_DOC_INDEX);
264
+ if (isString(doc)) {
265
+ const record = this._createStringRecord(doc, docIndex);
266
+ if (record) this.records.push(record);
267
+ return record;
268
+ }
269
+ const record = this._createObjectRecord(doc, docIndex);
270
+ this.records.push(record);
271
+ return record;
272
+ }
273
+ removeAt(idx) {
274
+ if (!Number.isInteger(idx) || idx < 0) throw new Error(INVALID_DOC_INDEX);
275
+ for (let i = 0, len = this.records.length; i < len; i += 1) if (this.records[i].i === idx) {
276
+ this.records.splice(i, 1);
277
+ break;
278
+ }
279
+ for (let i = 0, len = this.records.length; i < len; i += 1) if (this.records[i].i > idx) this.records[i].i -= 1;
280
+ }
281
+ removeAll(indices) {
282
+ const toRemove = /* @__PURE__ */ new Set();
283
+ for (const v of indices) if (Number.isInteger(v) && v >= 0) toRemove.add(v);
284
+ if (toRemove.size === 0) return;
285
+ this.records = this.records.filter((r) => !toRemove.has(r.i));
286
+ const sorted = Array.from(toRemove).sort((a, b) => a - b);
287
+ for (const record of this.records) {
288
+ let lo = 0;
289
+ let hi = sorted.length;
290
+ while (lo < hi) {
291
+ const mid = lo + hi >>> 1;
292
+ if (sorted[mid] < record.i) lo = mid + 1;
293
+ else hi = mid;
294
+ }
295
+ record.i -= lo;
296
+ }
297
+ }
298
+ getValueForItemAtKeyId(item, keyId) {
299
+ return item[this._keysMap[keyId]];
300
+ }
301
+ size() {
302
+ return this.records.length;
303
+ }
304
+ _createStringRecord(doc, docIndex) {
305
+ if (!isDefined(doc) || isBlank(doc)) return null;
306
+ return {
307
+ v: doc,
308
+ i: docIndex,
309
+ n: this.norm.get(doc)
310
+ };
311
+ }
312
+ _createObjectRecord(doc, docIndex) {
313
+ const record = {
314
+ i: docIndex,
315
+ $: {}
316
+ };
317
+ for (let keyIndex = 0, keyLen = this.keys.length; keyIndex < keyLen; keyIndex++) {
318
+ const key = this.keys[keyIndex];
319
+ const value = key.getFn ? key.getFn(doc) : this.getFn(doc, key.path);
320
+ if (!isDefined(value)) continue;
321
+ if (isArray(value)) {
322
+ const subRecords = [];
323
+ for (let i = 0, len = value.length; i < len; i += 1) {
324
+ const item = value[i];
325
+ if (!isDefined(item)) continue;
326
+ if (isString(item)) {
327
+ if (!isBlank(item)) {
328
+ const subRecord = {
329
+ v: item,
330
+ i,
331
+ n: this.norm.get(item)
332
+ };
333
+ subRecords.push(subRecord);
334
+ }
335
+ } else if (isDefined(item.v)) {
336
+ const text = isString(item.v) ? item.v : toString(item.v);
337
+ if (!isBlank(text)) {
338
+ const subRecord = {
339
+ v: text,
340
+ i: item.i,
341
+ n: this.norm.get(text)
342
+ };
343
+ subRecords.push(subRecord);
344
+ }
345
+ }
346
+ }
347
+ record.$[keyIndex] = subRecords;
348
+ } else if (isString(value) && !isBlank(value)) {
349
+ const subRecord = {
350
+ v: value,
351
+ n: this.norm.get(value)
352
+ };
353
+ record.$[keyIndex] = subRecord;
354
+ }
355
+ }
356
+ return record;
357
+ }
358
+ toJSON() {
359
+ return {
360
+ keys: this.keys.map(({ getFn, ...key }) => key),
361
+ records: this.records
362
+ };
363
+ }
364
+ };
365
+ function createIndex(keys, docs, { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) {
366
+ const myIndex = new FuseIndex({
367
+ getFn,
368
+ fieldNormWeight
369
+ });
370
+ myIndex.setKeys(keys.map(createKey));
371
+ myIndex.setSources(docs);
372
+ myIndex.create();
373
+ return myIndex;
476
374
  }
477
-
478
- function parseIndex(
479
- data,
480
- { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}
481
- ) {
482
- const { keys, records } = data;
483
- const myIndex = new FuseIndex({ getFn, fieldNormWeight });
484
- myIndex.setKeys(keys);
485
- myIndex.setIndexRecords(records);
486
- return myIndex
375
+ function parseIndex(data, { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) {
376
+ const { keys, records } = data;
377
+ const myIndex = new FuseIndex({
378
+ getFn,
379
+ fieldNormWeight
380
+ });
381
+ myIndex.setKeys(keys);
382
+ myIndex.setIndexRecords(records);
383
+ return myIndex;
487
384
  }
488
385
 
489
- function computeScore$1(
490
- pattern,
491
- {
492
- errors = 0,
493
- currentLocation = 0,
494
- expectedLocation = 0,
495
- distance = Config.distance,
496
- ignoreLocation = Config.ignoreLocation
497
- } = {}
498
- ) {
499
- const accuracy = errors / pattern.length;
500
-
501
- if (ignoreLocation) {
502
- return accuracy
503
- }
504
-
505
- const proximity = Math.abs(expectedLocation - currentLocation);
506
-
507
- if (!distance) {
508
- // Dodge divide by zero error.
509
- return proximity ? 1.0 : accuracy
510
- }
511
-
512
- return accuracy + proximity / distance
386
+ //#endregion
387
+ //#region src/search/bitap/convertMaskToIndices.ts
388
+ function convertMaskToIndices(matchmask = [], minMatchCharLength = Config.minMatchCharLength) {
389
+ const indices = [];
390
+ let start = -1;
391
+ let end = -1;
392
+ let i = 0;
393
+ for (let len = matchmask.length; i < len; i += 1) {
394
+ const match = matchmask[i];
395
+ if (match && start === -1) start = i;
396
+ else if (!match && start !== -1) {
397
+ end = i - 1;
398
+ if (end - start + 1 >= minMatchCharLength) indices.push([start, end]);
399
+ start = -1;
400
+ }
401
+ }
402
+ if (matchmask[i - 1] && i - start >= minMatchCharLength) indices.push([start, i - 1]);
403
+ return indices;
513
404
  }
514
405
 
515
- function convertMaskToIndices(
516
- matchmask = [],
517
- minMatchCharLength = Config.minMatchCharLength
518
- ) {
519
- let indices = [];
520
- let start = -1;
521
- let end = -1;
522
- let i = 0;
523
-
524
- for (let len = matchmask.length; i < len; i += 1) {
525
- let match = matchmask[i];
526
- if (match && start === -1) {
527
- start = i;
528
- } else if (!match && start !== -1) {
529
- end = i - 1;
530
- if (end - start + 1 >= minMatchCharLength) {
531
- indices.push([start, end]);
532
- }
533
- start = -1;
534
- }
535
- }
536
-
537
- // (i-1 - start) + 1 => i - start
538
- if (matchmask[i - 1] && i - start >= minMatchCharLength) {
539
- indices.push([start, i - 1]);
540
- }
541
-
542
- return indices
543
- }
544
-
545
- // Machine word size
546
- const MAX_BITS = 32;
547
-
548
- function search(
549
- text,
550
- pattern,
551
- patternAlphabet,
552
- {
553
- location = Config.location,
554
- distance = Config.distance,
555
- threshold = Config.threshold,
556
- findAllMatches = Config.findAllMatches,
557
- minMatchCharLength = Config.minMatchCharLength,
558
- includeMatches = Config.includeMatches,
559
- ignoreLocation = Config.ignoreLocation
560
- } = {}
561
- ) {
562
- if (pattern.length > MAX_BITS) {
563
- throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS))
564
- }
565
-
566
- const patternLen = pattern.length;
567
- // Set starting location at beginning text and initialize the alphabet.
568
- const textLen = text.length;
569
- // Handle the case when location > text.length
570
- const expectedLocation = Math.max(0, Math.min(location, textLen));
571
- // Highest score beyond which we give up.
572
- let currentThreshold = threshold;
573
- // Is there a nearby exact match? (speedup)
574
- let bestLocation = expectedLocation;
575
-
576
- // Performance: only computer matches when the minMatchCharLength > 1
577
- // OR if `includeMatches` is true.
578
- const computeMatches = minMatchCharLength > 1 || includeMatches;
579
- // A mask of the matches, used for building the indices
580
- const matchMask = computeMatches ? Array(textLen) : [];
581
-
582
- let index;
583
-
584
- // Get all exact matches, here for speed up
585
- while ((index = text.indexOf(pattern, bestLocation)) > -1) {
586
- let score = computeScore$1(pattern, {
587
- currentLocation: index,
588
- expectedLocation,
589
- distance,
590
- ignoreLocation
591
- });
592
-
593
- currentThreshold = Math.min(score, currentThreshold);
594
- bestLocation = index + patternLen;
595
-
596
- if (computeMatches) {
597
- let i = 0;
598
- while (i < patternLen) {
599
- matchMask[index + i] = 1;
600
- i += 1;
601
- }
602
- }
603
- }
604
-
605
- // Reset the best location
606
- bestLocation = -1;
607
-
608
- let lastBitArr = [];
609
- let finalScore = 1;
610
- let binMax = patternLen + textLen;
611
-
612
- const mask = 1 << (patternLen - 1);
613
-
614
- for (let i = 0; i < patternLen; i += 1) {
615
- // Scan for the best match; each iteration allows for one more error.
616
- // Run a binary search to determine how far from the match location we can stray
617
- // at this error level.
618
- let binMin = 0;
619
- let binMid = binMax;
620
-
621
- while (binMin < binMid) {
622
- const score = computeScore$1(pattern, {
623
- errors: i,
624
- currentLocation: expectedLocation + binMid,
625
- expectedLocation,
626
- distance,
627
- ignoreLocation
628
- });
629
-
630
- if (score <= currentThreshold) {
631
- binMin = binMid;
632
- } else {
633
- binMax = binMid;
634
- }
635
-
636
- binMid = Math.floor((binMax - binMin) / 2 + binMin);
637
- }
638
-
639
- // Use the result from this iteration as the maximum for the next.
640
- binMax = binMid;
641
-
642
- let start = Math.max(1, expectedLocation - binMid + 1);
643
- let finish = findAllMatches
644
- ? textLen
645
- : Math.min(expectedLocation + binMid, textLen) + patternLen;
646
-
647
- // Initialize the bit array
648
- let bitArr = Array(finish + 2);
649
-
650
- bitArr[finish + 1] = (1 << i) - 1;
651
-
652
- for (let j = finish; j >= start; j -= 1) {
653
- let currentLocation = j - 1;
654
- let charMatch = patternAlphabet[text.charAt(currentLocation)];
655
-
656
- if (computeMatches) {
657
- // Speed up: quick bool to int conversion (i.e, `charMatch ? 1 : 0`)
658
- matchMask[currentLocation] = +!!charMatch;
659
- }
660
-
661
- // First pass: exact match
662
- bitArr[j] = ((bitArr[j + 1] << 1) | 1) & charMatch;
663
-
664
- // Subsequent passes: fuzzy match
665
- if (i) {
666
- bitArr[j] |=
667
- ((lastBitArr[j + 1] | lastBitArr[j]) << 1) | 1 | lastBitArr[j + 1];
668
- }
669
-
670
- if (bitArr[j] & mask) {
671
- finalScore = computeScore$1(pattern, {
672
- errors: i,
673
- currentLocation,
674
- expectedLocation,
675
- distance,
676
- ignoreLocation
677
- });
678
-
679
- // This match will almost certainly be better than any existing match.
680
- // But check anyway.
681
- if (finalScore <= currentThreshold) {
682
- // Indeed it is
683
- currentThreshold = finalScore;
684
- bestLocation = currentLocation;
685
-
686
- // Already passed `loc`, downhill from here on in.
687
- if (bestLocation <= expectedLocation) {
688
- break
689
- }
690
-
691
- // When passing `bestLocation`, don't exceed our current distance from `expectedLocation`.
692
- start = Math.max(1, 2 * expectedLocation - bestLocation);
693
- }
694
- }
695
- }
696
-
697
- // No hope for a (better) match at greater error levels.
698
- const score = computeScore$1(pattern, {
699
- errors: i + 1,
700
- currentLocation: expectedLocation,
701
- expectedLocation,
702
- distance,
703
- ignoreLocation
704
- });
705
-
706
- if (score > currentThreshold) {
707
- break
708
- }
709
-
710
- lastBitArr = bitArr;
711
- }
712
-
713
- const result = {
714
- isMatch: bestLocation >= 0,
715
- // Count exact matches (those with a score of 0) to be "almost" exact
716
- score: Math.max(0.001, finalScore)
717
- };
718
-
719
- if (computeMatches) {
720
- const indices = convertMaskToIndices(matchMask, minMatchCharLength);
721
- if (!indices.length) {
722
- result.isMatch = false;
723
- } else if (includeMatches) {
724
- result.indices = indices;
725
- }
726
- }
727
-
728
- return result
406
+ //#endregion
407
+ //#region src/search/bitap/search.ts
408
+ function search(text, pattern, patternAlphabet, { location = Config.location, distance = Config.distance, threshold = Config.threshold, findAllMatches = Config.findAllMatches, minMatchCharLength = Config.minMatchCharLength, includeMatches = Config.includeMatches, ignoreLocation = Config.ignoreLocation } = {}) {
409
+ if (pattern.length > 32) throw new Error(PATTERN_LENGTH_TOO_LARGE(32));
410
+ const patternLen = pattern.length;
411
+ const textLen = text.length;
412
+ const expectedLocation = Math.max(0, Math.min(location, textLen));
413
+ let currentThreshold = threshold;
414
+ let bestLocation = expectedLocation;
415
+ const calcScore = (errors, currentLocation) => {
416
+ const accuracy = errors / patternLen;
417
+ if (ignoreLocation) return accuracy;
418
+ const proximity = Math.abs(expectedLocation - currentLocation);
419
+ if (!distance) return proximity ? 1 : accuracy;
420
+ return accuracy + proximity / distance;
421
+ };
422
+ const computeMatches = minMatchCharLength > 1 || includeMatches;
423
+ const matchMask = computeMatches ? Array(textLen) : [];
424
+ let index;
425
+ while ((index = text.indexOf(pattern, bestLocation)) > -1) {
426
+ const score = calcScore(0, index);
427
+ currentThreshold = Math.min(score, currentThreshold);
428
+ bestLocation = index + patternLen;
429
+ if (computeMatches) {
430
+ let i = 0;
431
+ while (i < patternLen) {
432
+ matchMask[index + i] = 1;
433
+ i += 1;
434
+ }
435
+ }
436
+ }
437
+ bestLocation = -1;
438
+ let lastBitArr = [];
439
+ let finalScore = 1;
440
+ let bestErrors = 0;
441
+ let binMax = patternLen + textLen;
442
+ const mask = 1 << patternLen - 1;
443
+ for (let i = 0; i < patternLen; i += 1) {
444
+ let binMin = 0;
445
+ let binMid = binMax;
446
+ while (binMin < binMid) {
447
+ if (calcScore(i, expectedLocation + binMid) <= currentThreshold) binMin = binMid;
448
+ else binMax = binMid;
449
+ binMid = Math.floor((binMax - binMin) / 2 + binMin);
450
+ }
451
+ binMax = binMid;
452
+ let start = Math.max(1, expectedLocation - binMid + 1);
453
+ const finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen;
454
+ const bitArr = Array(finish + 2);
455
+ bitArr[finish + 1] = (1 << i) - 1;
456
+ for (let j = finish; j >= start; j -= 1) {
457
+ const currentLocation = j - 1;
458
+ const charMatch = patternAlphabet[text[currentLocation]];
459
+ bitArr[j] = (bitArr[j + 1] << 1 | 1) & charMatch;
460
+ if (i) bitArr[j] |= (lastBitArr[j + 1] | lastBitArr[j]) << 1 | 1 | lastBitArr[j + 1];
461
+ if (bitArr[j] & mask) {
462
+ finalScore = calcScore(i, currentLocation);
463
+ if (finalScore <= currentThreshold) {
464
+ currentThreshold = finalScore;
465
+ bestLocation = currentLocation;
466
+ bestErrors = i;
467
+ if (bestLocation <= expectedLocation) break;
468
+ start = Math.max(1, 2 * expectedLocation - bestLocation);
469
+ }
470
+ }
471
+ }
472
+ if (calcScore(i + 1, expectedLocation) > currentThreshold) break;
473
+ lastBitArr = bitArr;
474
+ }
475
+ if (computeMatches && bestLocation >= 0) {
476
+ const matchEnd = Math.min(textLen - 1, bestLocation + patternLen - 1 + bestErrors);
477
+ for (let k = bestLocation; k <= matchEnd; k += 1) if (patternAlphabet[text[k]]) matchMask[k] = 1;
478
+ }
479
+ const result = {
480
+ isMatch: bestLocation >= 0,
481
+ score: Math.max(.001, finalScore)
482
+ };
483
+ if (computeMatches) {
484
+ const indices = convertMaskToIndices(matchMask, minMatchCharLength);
485
+ if (!indices.length) result.isMatch = false;
486
+ else if (includeMatches) result.indices = indices;
487
+ }
488
+ return result;
729
489
  }
730
490
 
491
+ //#endregion
492
+ //#region src/search/bitap/createPatternAlphabet.ts
731
493
  function createPatternAlphabet(pattern) {
732
- let mask = {};
733
-
734
- for (let i = 0, len = pattern.length; i < len; i += 1) {
735
- const char = pattern.charAt(i);
736
- mask[char] = (mask[char] || 0) | (1 << (len - i - 1));
737
- }
738
-
739
- return mask
740
- }
741
-
742
- const stripDiacritics = String.prototype.normalize
743
- ? ((str) => str.normalize('NFD').replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g, ''))
744
- : ((str) => str);
745
-
746
- class BitapSearch {
747
- constructor(
748
- pattern,
749
- {
750
- location = Config.location,
751
- threshold = Config.threshold,
752
- distance = Config.distance,
753
- includeMatches = Config.includeMatches,
754
- findAllMatches = Config.findAllMatches,
755
- minMatchCharLength = Config.minMatchCharLength,
756
- isCaseSensitive = Config.isCaseSensitive,
757
- ignoreDiacritics = Config.ignoreDiacritics,
758
- ignoreLocation = Config.ignoreLocation
759
- } = {}
760
- ) {
761
- this.options = {
762
- location,
763
- threshold,
764
- distance,
765
- includeMatches,
766
- findAllMatches,
767
- minMatchCharLength,
768
- isCaseSensitive,
769
- ignoreDiacritics,
770
- ignoreLocation
771
- };
772
-
773
- pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
774
- pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
775
- this.pattern = pattern;
776
-
777
- this.chunks = [];
778
-
779
- if (!this.pattern.length) {
780
- return
781
- }
782
-
783
- const addChunk = (pattern, startIndex) => {
784
- this.chunks.push({
785
- pattern,
786
- alphabet: createPatternAlphabet(pattern),
787
- startIndex
788
- });
789
- };
790
-
791
- const len = this.pattern.length;
792
-
793
- if (len > MAX_BITS) {
794
- let i = 0;
795
- const remainder = len % MAX_BITS;
796
- const end = len - remainder;
797
-
798
- while (i < end) {
799
- addChunk(this.pattern.substr(i, MAX_BITS), i);
800
- i += MAX_BITS;
801
- }
802
-
803
- if (remainder) {
804
- const startIndex = len - MAX_BITS;
805
- addChunk(this.pattern.substr(startIndex), startIndex);
806
- }
807
- } else {
808
- addChunk(this.pattern, 0);
809
- }
810
- }
811
-
812
- searchIn(text) {
813
- const { isCaseSensitive, ignoreDiacritics, includeMatches } = this.options;
814
-
815
- text = isCaseSensitive ? text : text.toLowerCase();
816
- text = ignoreDiacritics ? stripDiacritics(text) : text;
817
-
818
- // Exact match
819
- if (this.pattern === text) {
820
- let result = {
821
- isMatch: true,
822
- score: 0
823
- };
824
-
825
- if (includeMatches) {
826
- result.indices = [[0, text.length - 1]];
827
- }
828
-
829
- return result
830
- }
831
-
832
- // Otherwise, use Bitap algorithm
833
- const {
834
- location,
835
- distance,
836
- threshold,
837
- findAllMatches,
838
- minMatchCharLength,
839
- ignoreLocation
840
- } = this.options;
841
-
842
- let allIndices = [];
843
- let totalScore = 0;
844
- let hasMatches = false;
845
-
846
- this.chunks.forEach(({ pattern, alphabet, startIndex }) => {
847
- const { isMatch, score, indices } = search(text, pattern, alphabet, {
848
- location: location + startIndex,
849
- distance,
850
- threshold,
851
- findAllMatches,
852
- minMatchCharLength,
853
- includeMatches,
854
- ignoreLocation
855
- });
856
-
857
- if (isMatch) {
858
- hasMatches = true;
859
- }
860
-
861
- totalScore += score;
862
-
863
- if (isMatch && indices) {
864
- allIndices = [...allIndices, ...indices];
865
- }
866
- });
867
-
868
- let result = {
869
- isMatch: hasMatches,
870
- score: hasMatches ? totalScore / this.chunks.length : 1
871
- };
872
-
873
- if (hasMatches && includeMatches) {
874
- result.indices = allIndices;
875
- }
876
-
877
- return result
878
- }
494
+ const mask = {};
495
+ for (let i = 0, len = pattern.length; i < len; i += 1) {
496
+ const char = pattern.charAt(i);
497
+ mask[char] = (mask[char] || 0) | 1 << len - i - 1;
498
+ }
499
+ return mask;
879
500
  }
880
501
 
881
- class BaseMatch {
882
- constructor(pattern) {
883
- this.pattern = pattern;
884
- }
885
- static isMultiMatch(pattern) {
886
- return getMatch(pattern, this.multiRegex)
887
- }
888
- static isSingleMatch(pattern) {
889
- return getMatch(pattern, this.singleRegex)
890
- }
891
- search(/*text*/) {}
502
+ //#endregion
503
+ //#region src/helpers/mergeIndices.ts
504
+ function mergeIndices(indices) {
505
+ if (indices.length <= 1) return indices;
506
+ indices.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
507
+ const merged = [indices[0]];
508
+ for (let i = 1, len = indices.length; i < len; i += 1) {
509
+ const last = merged[merged.length - 1];
510
+ const curr = indices[i];
511
+ if (curr[0] <= last[1] + 1) last[1] = Math.max(last[1], curr[1]);
512
+ else merged.push(curr);
513
+ }
514
+ return merged;
892
515
  }
893
516
 
894
- function getMatch(pattern, exp) {
895
- const matches = pattern.match(exp);
896
- return matches ? matches[1] : null
897
- }
898
-
899
- // Token: 'file
900
-
901
- class ExactMatch extends BaseMatch {
902
- constructor(pattern) {
903
- super(pattern);
904
- }
905
- static get type() {
906
- return 'exact'
907
- }
908
- static get multiRegex() {
909
- return /^="(.*)"$/
910
- }
911
- static get singleRegex() {
912
- return /^=(.*)$/
913
- }
914
- search(text) {
915
- const isMatch = text === this.pattern;
916
-
917
- return {
918
- isMatch,
919
- score: isMatch ? 0 : 1,
920
- indices: [0, this.pattern.length - 1]
921
- }
922
- }
923
- }
924
-
925
- // Token: !fire
926
-
927
- class InverseExactMatch extends BaseMatch {
928
- constructor(pattern) {
929
- super(pattern);
930
- }
931
- static get type() {
932
- return 'inverse-exact'
933
- }
934
- static get multiRegex() {
935
- return /^!"(.*)"$/
936
- }
937
- static get singleRegex() {
938
- return /^!(.*)$/
939
- }
940
- search(text) {
941
- const index = text.indexOf(this.pattern);
942
- const isMatch = index === -1;
943
-
944
- return {
945
- isMatch,
946
- score: isMatch ? 0 : 1,
947
- indices: [0, text.length - 1]
948
- }
949
- }
950
- }
951
-
952
- // Token: ^file
953
-
954
- class PrefixExactMatch extends BaseMatch {
955
- constructor(pattern) {
956
- super(pattern);
957
- }
958
- static get type() {
959
- return 'prefix-exact'
960
- }
961
- static get multiRegex() {
962
- return /^\^"(.*)"$/
963
- }
964
- static get singleRegex() {
965
- return /^\^(.*)$/
966
- }
967
- search(text) {
968
- const isMatch = text.startsWith(this.pattern);
969
-
970
- return {
971
- isMatch,
972
- score: isMatch ? 0 : 1,
973
- indices: [0, this.pattern.length - 1]
974
- }
975
- }
976
- }
977
-
978
- // Token: !^fire
979
-
980
- class InversePrefixExactMatch extends BaseMatch {
981
- constructor(pattern) {
982
- super(pattern);
983
- }
984
- static get type() {
985
- return 'inverse-prefix-exact'
986
- }
987
- static get multiRegex() {
988
- return /^!\^"(.*)"$/
989
- }
990
- static get singleRegex() {
991
- return /^!\^(.*)$/
992
- }
993
- search(text) {
994
- const isMatch = !text.startsWith(this.pattern);
995
-
996
- return {
997
- isMatch,
998
- score: isMatch ? 0 : 1,
999
- indices: [0, text.length - 1]
1000
- }
1001
- }
1002
- }
1003
-
1004
- // Token: .file$
1005
-
1006
- class SuffixExactMatch extends BaseMatch {
1007
- constructor(pattern) {
1008
- super(pattern);
1009
- }
1010
- static get type() {
1011
- return 'suffix-exact'
1012
- }
1013
- static get multiRegex() {
1014
- return /^"(.*)"\$$/
1015
- }
1016
- static get singleRegex() {
1017
- return /^(.*)\$$/
1018
- }
1019
- search(text) {
1020
- const isMatch = text.endsWith(this.pattern);
1021
-
1022
- return {
1023
- isMatch,
1024
- score: isMatch ? 0 : 1,
1025
- indices: [text.length - this.pattern.length, text.length - 1]
1026
- }
1027
- }
1028
- }
1029
-
1030
- // Token: !.file$
517
+ //#endregion
518
+ //#region src/helpers/diacritics.ts
519
+ const NON_DECOMPOSABLE_MAP = {
520
+ "ł": "l",
521
+ "Ł": "L",
522
+ "đ": "d",
523
+ "Đ": "D",
524
+ "ø": "o",
525
+ "Ø": "O",
526
+ "ħ": "h",
527
+ "Ħ": "H",
528
+ "ŧ": "t",
529
+ "Ŧ": "T",
530
+ "ı": "i",
531
+ "ß": "ss"
532
+ };
533
+ const NON_DECOMPOSABLE_RE = new RegExp("[" + Object.keys(NON_DECOMPOSABLE_MAP).join("") + "]", "g");
534
+ const stripDiacritics = typeof String.prototype.normalize === "function" ? (str) => str.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g, "").replace(NON_DECOMPOSABLE_RE, (ch) => NON_DECOMPOSABLE_MAP[ch]) : (str) => str;
535
+
536
+ //#endregion
537
+ //#region src/search/bitap/index.ts
538
+ var BitapSearch = class {
539
+ constructor(pattern, { location = Config.location, threshold = Config.threshold, distance = Config.distance, includeMatches = Config.includeMatches, findAllMatches = Config.findAllMatches, minMatchCharLength = Config.minMatchCharLength, isCaseSensitive = Config.isCaseSensitive, ignoreDiacritics = Config.ignoreDiacritics, ignoreLocation = Config.ignoreLocation } = {}) {
540
+ this.options = {
541
+ location,
542
+ threshold,
543
+ distance,
544
+ includeMatches,
545
+ findAllMatches,
546
+ minMatchCharLength,
547
+ isCaseSensitive,
548
+ ignoreDiacritics,
549
+ ignoreLocation
550
+ };
551
+ pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
552
+ pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
553
+ this.pattern = pattern;
554
+ this.chunks = [];
555
+ if (!this.pattern.length) return;
556
+ const addChunk = (pattern, startIndex) => {
557
+ this.chunks.push({
558
+ pattern,
559
+ alphabet: createPatternAlphabet(pattern),
560
+ startIndex
561
+ });
562
+ };
563
+ const len = this.pattern.length;
564
+ if (len > 32) {
565
+ let i = 0;
566
+ const remainder = len % 32;
567
+ const end = len - remainder;
568
+ while (i < end) {
569
+ addChunk(this.pattern.substr(i, 32), i);
570
+ i += 32;
571
+ }
572
+ if (remainder) {
573
+ const startIndex = len - 32;
574
+ addChunk(this.pattern.substr(startIndex), startIndex);
575
+ }
576
+ } else addChunk(this.pattern, 0);
577
+ }
578
+ searchIn(text) {
579
+ const { isCaseSensitive, ignoreDiacritics, includeMatches } = this.options;
580
+ text = isCaseSensitive ? text : text.toLowerCase();
581
+ text = ignoreDiacritics ? stripDiacritics(text) : text;
582
+ if (this.pattern === text) {
583
+ const result = {
584
+ isMatch: true,
585
+ score: 0
586
+ };
587
+ if (includeMatches) result.indices = [[0, text.length - 1]];
588
+ return result;
589
+ }
590
+ const { location, distance, threshold, findAllMatches, minMatchCharLength, ignoreLocation } = this.options;
591
+ const allIndices = [];
592
+ let totalScore = 0;
593
+ let hasMatches = false;
594
+ this.chunks.forEach(({ pattern, alphabet, startIndex }) => {
595
+ const { isMatch, score, indices } = search(text, pattern, alphabet, {
596
+ location: location + startIndex,
597
+ distance,
598
+ threshold,
599
+ findAllMatches,
600
+ minMatchCharLength,
601
+ includeMatches,
602
+ ignoreLocation
603
+ });
604
+ if (isMatch) hasMatches = true;
605
+ totalScore += score;
606
+ if (isMatch && indices) allIndices.push(...indices);
607
+ });
608
+ const result = {
609
+ isMatch: hasMatches,
610
+ score: hasMatches ? totalScore / this.chunks.length : 1
611
+ };
612
+ if (hasMatches && includeMatches) result.indices = mergeIndices(allIndices);
613
+ return result;
614
+ }
615
+ };
1031
616
 
1032
- class InverseSuffixExactMatch extends BaseMatch {
1033
- constructor(pattern) {
1034
- super(pattern);
1035
- }
1036
- static get type() {
1037
- return 'inverse-suffix-exact'
1038
- }
1039
- static get multiRegex() {
1040
- return /^!"(.*)"\$$/
1041
- }
1042
- static get singleRegex() {
1043
- return /^!(.*)\$$/
1044
- }
1045
- search(text) {
1046
- const isMatch = !text.endsWith(this.pattern);
1047
- return {
1048
- isMatch,
1049
- score: isMatch ? 0 : 1,
1050
- indices: [0, text.length - 1]
1051
- }
1052
- }
617
+ //#endregion
618
+ //#region src/search/extended/matchers.ts
619
+ const MULTI_MATCH_TYPES = new Set(["fuzzy", "include"]);
620
+ function isInverse(type) {
621
+ return type.startsWith("inverse");
1053
622
  }
623
+ const matchers = [
624
+ {
625
+ type: "exact",
626
+ multiRegex: /^="(.*)"$/,
627
+ singleRegex: /^=(.*)$/,
628
+ create: (pattern) => ({
629
+ type: "exact",
630
+ search(text) {
631
+ const isMatch = text === pattern;
632
+ return {
633
+ isMatch,
634
+ score: isMatch ? 0 : 1,
635
+ indices: [0, pattern.length - 1]
636
+ };
637
+ }
638
+ })
639
+ },
640
+ {
641
+ type: "include",
642
+ multiRegex: /^'"(.*)"$/,
643
+ singleRegex: /^'(.*)$/,
644
+ create: (pattern) => ({
645
+ type: "include",
646
+ search(text) {
647
+ let location = 0;
648
+ let index;
649
+ const indices = [];
650
+ const patternLen = pattern.length;
651
+ while ((index = text.indexOf(pattern, location)) > -1) {
652
+ location = index + patternLen;
653
+ indices.push([index, location - 1]);
654
+ }
655
+ const isMatch = !!indices.length;
656
+ return {
657
+ isMatch,
658
+ score: isMatch ? 0 : 1,
659
+ indices
660
+ };
661
+ }
662
+ })
663
+ },
664
+ {
665
+ type: "prefix-exact",
666
+ multiRegex: /^\^"(.*)"$/,
667
+ singleRegex: /^\^(.*)$/,
668
+ create: (pattern) => ({
669
+ type: "prefix-exact",
670
+ search(text) {
671
+ const isMatch = text.startsWith(pattern);
672
+ return {
673
+ isMatch,
674
+ score: isMatch ? 0 : 1,
675
+ indices: [0, pattern.length - 1]
676
+ };
677
+ }
678
+ })
679
+ },
680
+ {
681
+ type: "inverse-prefix-exact",
682
+ multiRegex: /^!\^"(.*)"$/,
683
+ singleRegex: /^!\^(.*)$/,
684
+ create: (pattern) => ({
685
+ type: "inverse-prefix-exact",
686
+ search(text) {
687
+ const isMatch = !text.startsWith(pattern);
688
+ return {
689
+ isMatch,
690
+ score: isMatch ? 0 : 1,
691
+ indices: [0, text.length - 1]
692
+ };
693
+ }
694
+ })
695
+ },
696
+ {
697
+ type: "inverse-suffix-exact",
698
+ multiRegex: /^!"(.*)"\$$/,
699
+ singleRegex: /^!(.*)\$$/,
700
+ create: (pattern) => ({
701
+ type: "inverse-suffix-exact",
702
+ search(text) {
703
+ const isMatch = !text.endsWith(pattern);
704
+ return {
705
+ isMatch,
706
+ score: isMatch ? 0 : 1,
707
+ indices: [0, text.length - 1]
708
+ };
709
+ }
710
+ })
711
+ },
712
+ {
713
+ type: "suffix-exact",
714
+ multiRegex: /^"(.*)"\$$/,
715
+ singleRegex: /^(.*)\$$/,
716
+ create: (pattern) => ({
717
+ type: "suffix-exact",
718
+ search(text) {
719
+ const isMatch = text.endsWith(pattern);
720
+ return {
721
+ isMatch,
722
+ score: isMatch ? 0 : 1,
723
+ indices: [text.length - pattern.length, text.length - 1]
724
+ };
725
+ }
726
+ })
727
+ },
728
+ {
729
+ type: "inverse-exact",
730
+ multiRegex: /^!"(.*)"$/,
731
+ singleRegex: /^!(.*)$/,
732
+ create: (pattern) => ({
733
+ type: "inverse-exact",
734
+ search(text) {
735
+ const isMatch = text.indexOf(pattern) === -1;
736
+ return {
737
+ isMatch,
738
+ score: isMatch ? 0 : 1,
739
+ indices: [0, text.length - 1]
740
+ };
741
+ }
742
+ })
743
+ },
744
+ {
745
+ type: "fuzzy",
746
+ multiRegex: /^"(.*)"$/,
747
+ singleRegex: /^(.*)$/,
748
+ create: (pattern, options = {}) => {
749
+ const bitap = new BitapSearch(pattern, {
750
+ location: options.location ?? Config.location,
751
+ threshold: options.threshold ?? Config.threshold,
752
+ distance: options.distance ?? Config.distance,
753
+ includeMatches: options.includeMatches ?? Config.includeMatches,
754
+ findAllMatches: options.findAllMatches ?? Config.findAllMatches,
755
+ minMatchCharLength: options.minMatchCharLength ?? Config.minMatchCharLength,
756
+ isCaseSensitive: options.isCaseSensitive ?? Config.isCaseSensitive,
757
+ ignoreDiacritics: options.ignoreDiacritics ?? Config.ignoreDiacritics,
758
+ ignoreLocation: options.ignoreLocation ?? Config.ignoreLocation
759
+ });
760
+ return {
761
+ type: "fuzzy",
762
+ search(text) {
763
+ return bitap.searchIn(text);
764
+ }
765
+ };
766
+ }
767
+ }
768
+ ];
1054
769
 
1055
- class FuzzyMatch extends BaseMatch {
1056
- constructor(
1057
- pattern,
1058
- {
1059
- location = Config.location,
1060
- threshold = Config.threshold,
1061
- distance = Config.distance,
1062
- includeMatches = Config.includeMatches,
1063
- findAllMatches = Config.findAllMatches,
1064
- minMatchCharLength = Config.minMatchCharLength,
1065
- isCaseSensitive = Config.isCaseSensitive,
1066
- ignoreDiacritics = Config.ignoreDiacritics,
1067
- ignoreLocation = Config.ignoreLocation
1068
- } = {}
1069
- ) {
1070
- super(pattern);
1071
- this._bitapSearch = new BitapSearch(pattern, {
1072
- location,
1073
- threshold,
1074
- distance,
1075
- includeMatches,
1076
- findAllMatches,
1077
- minMatchCharLength,
1078
- isCaseSensitive,
1079
- ignoreDiacritics,
1080
- ignoreLocation
1081
- });
1082
- }
1083
- static get type() {
1084
- return 'fuzzy'
1085
- }
1086
- static get multiRegex() {
1087
- return /^"(.*)"$/
1088
- }
1089
- static get singleRegex() {
1090
- return /^(.*)$/
1091
- }
1092
- search(text) {
1093
- return this._bitapSearch.searchIn(text)
1094
- }
770
+ //#endregion
771
+ //#region src/search/extended/parseQuery.ts
772
+ const matchersLen = matchers.length;
773
+ const ESCAPED_PIPE = "\0";
774
+ const OR_TOKEN = "|";
775
+ function tokenize(pattern) {
776
+ const tokens = [];
777
+ const len = pattern.length;
778
+ let i = 0;
779
+ while (i < len) {
780
+ while (i < len && pattern[i] === " ") i++;
781
+ if (i >= len) break;
782
+ let j = i;
783
+ while (j < len && pattern[j] !== " " && pattern[j] !== "\"") j++;
784
+ if (j < len && pattern[j] === "\"") {
785
+ j++;
786
+ while (j < len) {
787
+ if (pattern[j] === "\"") {
788
+ const next = j + 1;
789
+ if (next >= len || pattern[next] === " ") {
790
+ j++;
791
+ break;
792
+ }
793
+ if (pattern[next] === "$" && (next + 1 >= len || pattern[next + 1] === " ")) {
794
+ j += 2;
795
+ break;
796
+ }
797
+ }
798
+ j++;
799
+ }
800
+ tokens.push(pattern.substring(i, j));
801
+ i = j;
802
+ } else {
803
+ while (j < len && pattern[j] !== " ") j++;
804
+ tokens.push(pattern.substring(i, j));
805
+ i = j;
806
+ }
807
+ }
808
+ return tokens;
1095
809
  }
1096
-
1097
- // Token: 'file
1098
-
1099
- class IncludeMatch extends BaseMatch {
1100
- constructor(pattern) {
1101
- super(pattern);
1102
- }
1103
- static get type() {
1104
- return 'include'
1105
- }
1106
- static get multiRegex() {
1107
- return /^'"(.*)"$/
1108
- }
1109
- static get singleRegex() {
1110
- return /^'(.*)$/
1111
- }
1112
- search(text) {
1113
- let location = 0;
1114
- let index;
1115
-
1116
- const indices = [];
1117
- const patternLen = this.pattern.length;
1118
-
1119
- // Get all exact matches
1120
- while ((index = text.indexOf(this.pattern, location)) > -1) {
1121
- location = index + patternLen;
1122
- indices.push([index, location - 1]);
1123
- }
1124
-
1125
- const isMatch = !!indices.length;
1126
-
1127
- return {
1128
- isMatch,
1129
- score: isMatch ? 0 : 1,
1130
- indices
1131
- }
1132
- }
810
+ function getMatch(pattern, exp) {
811
+ const matches = pattern.match(exp);
812
+ return matches ? matches[1] : null;
1133
813
  }
1134
-
1135
- // ❗Order is important. DO NOT CHANGE.
1136
- const searchers = [
1137
- ExactMatch,
1138
- IncludeMatch,
1139
- PrefixExactMatch,
1140
- InversePrefixExactMatch,
1141
- InverseSuffixExactMatch,
1142
- SuffixExactMatch,
1143
- InverseExactMatch,
1144
- FuzzyMatch
1145
- ];
1146
-
1147
- const searchersLen = searchers.length;
1148
-
1149
- // Regex to split by spaces, but keep anything in quotes together
1150
- const SPACE_RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;
1151
- const OR_TOKEN = '|';
1152
-
1153
- // Return a 2D array representation of the query, for simpler parsing.
1154
- // Example:
1155
- // "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]]
1156
814
  function parseQuery(pattern, options = {}) {
1157
- return pattern.split(OR_TOKEN).map((item) => {
1158
- let query = item
1159
- .trim()
1160
- .split(SPACE_RE)
1161
- .filter((item) => item && !!item.trim());
1162
-
1163
- let results = [];
1164
- for (let i = 0, len = query.length; i < len; i += 1) {
1165
- const queryItem = query[i];
1166
-
1167
- // 1. Handle multiple query match (i.e, once that are quoted, like `"hello world"`)
1168
- let found = false;
1169
- let idx = -1;
1170
- while (!found && ++idx < searchersLen) {
1171
- const searcher = searchers[idx];
1172
- let token = searcher.isMultiMatch(queryItem);
1173
- if (token) {
1174
- results.push(new searcher(token, options));
1175
- found = true;
1176
- }
1177
- }
1178
-
1179
- if (found) {
1180
- continue
1181
- }
1182
-
1183
- // 2. Handle single query matches (i.e, once that are *not* quoted)
1184
- idx = -1;
1185
- while (++idx < searchersLen) {
1186
- const searcher = searchers[idx];
1187
- let token = searcher.isSingleMatch(queryItem);
1188
- if (token) {
1189
- results.push(new searcher(token, options));
1190
- break
1191
- }
1192
- }
1193
- }
1194
-
1195
- return results
1196
- })
815
+ return pattern.replace(/\\\|/g, ESCAPED_PIPE).split(OR_TOKEN).map((item) => {
816
+ const query = tokenize(item.replace(/\u0000/g, "|").trim()).filter((item) => item && !!item.trim());
817
+ const results = [];
818
+ for (let i = 0, len = query.length; i < len; i += 1) {
819
+ const queryItem = query[i];
820
+ let found = false;
821
+ let idx = -1;
822
+ while (!found && ++idx < matchersLen) {
823
+ const def = matchers[idx];
824
+ const token = getMatch(queryItem, def.multiRegex);
825
+ if (token) {
826
+ results.push(def.create(token, options));
827
+ found = true;
828
+ }
829
+ }
830
+ if (found) continue;
831
+ idx = -1;
832
+ while (++idx < matchersLen) {
833
+ const def = matchers[idx];
834
+ const token = getMatch(queryItem, def.singleRegex);
835
+ if (token) {
836
+ results.push(def.create(token, options));
837
+ break;
838
+ }
839
+ }
840
+ }
841
+ return results;
842
+ });
1197
843
  }
1198
844
 
1199
- // These extended matchers can return an array of matches, as opposed
1200
- // to a singl match
1201
- const MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]);
1202
-
1203
- /**
1204
- * Command-like searching
1205
- * ======================
1206
- *
1207
- * Given multiple search terms delimited by spaces.e.g. `^jscript .python$ ruby !java`,
1208
- * search in a given text.
1209
- *
1210
- * Search syntax:
1211
- *
1212
- * | Token | Match type | Description |
1213
- * | ----------- | -------------------------- | -------------------------------------- |
1214
- * | `jscript` | fuzzy-match | Items that fuzzy match `jscript` |
1215
- * | `=scheme` | exact-match | Items that are `scheme` |
1216
- * | `'python` | include-match | Items that include `python` |
1217
- * | `!ruby` | inverse-exact-match | Items that do not include `ruby` |
1218
- * | `^java` | prefix-exact-match | Items that start with `java` |
1219
- * | `!^earlang` | inverse-prefix-exact-match | Items that do not start with `earlang` |
1220
- * | `.js$` | suffix-exact-match | Items that end with `.js` |
1221
- * | `!.go$` | inverse-suffix-exact-match | Items that do not end with `.go` |
1222
- *
1223
- * A single pipe character acts as an OR operator. For example, the following
1224
- * query matches entries that start with `core` and end with either`go`, `rb`,
1225
- * or`py`.
1226
- *
1227
- * ```
1228
- * ^core go$ | rb$ | py$
1229
- * ```
1230
- */
1231
- class ExtendedSearch {
1232
- constructor(
1233
- pattern,
1234
- {
1235
- isCaseSensitive = Config.isCaseSensitive,
1236
- ignoreDiacritics = Config.ignoreDiacritics,
1237
- includeMatches = Config.includeMatches,
1238
- minMatchCharLength = Config.minMatchCharLength,
1239
- ignoreLocation = Config.ignoreLocation,
1240
- findAllMatches = Config.findAllMatches,
1241
- location = Config.location,
1242
- threshold = Config.threshold,
1243
- distance = Config.distance
1244
- } = {}
1245
- ) {
1246
- this.query = null;
1247
- this.options = {
1248
- isCaseSensitive,
1249
- ignoreDiacritics,
1250
- includeMatches,
1251
- minMatchCharLength,
1252
- findAllMatches,
1253
- ignoreLocation,
1254
- location,
1255
- threshold,
1256
- distance
1257
- };
1258
-
1259
- pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
1260
- pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
1261
- this.pattern = pattern;
1262
- this.query = parseQuery(this.pattern, this.options);
1263
- }
1264
-
1265
- static condition(_, options) {
1266
- return options.useExtendedSearch
1267
- }
1268
-
1269
- searchIn(text) {
1270
- const query = this.query;
1271
-
1272
- if (!query) {
1273
- return {
1274
- isMatch: false,
1275
- score: 1
1276
- }
1277
- }
1278
-
1279
- const { includeMatches, isCaseSensitive, ignoreDiacritics } = this.options;
1280
-
1281
- text = isCaseSensitive ? text : text.toLowerCase();
1282
- text = ignoreDiacritics ? stripDiacritics(text) : text;
1283
-
1284
- let numMatches = 0;
1285
- let allIndices = [];
1286
- let totalScore = 0;
1287
-
1288
- // ORs
1289
- for (let i = 0, qLen = query.length; i < qLen; i += 1) {
1290
- const searchers = query[i];
1291
-
1292
- // Reset indices
1293
- allIndices.length = 0;
1294
- numMatches = 0;
1295
-
1296
- // ANDs
1297
- for (let j = 0, pLen = searchers.length; j < pLen; j += 1) {
1298
- const searcher = searchers[j];
1299
- const { isMatch, indices, score } = searcher.search(text);
1300
-
1301
- if (isMatch) {
1302
- numMatches += 1;
1303
- totalScore += score;
1304
- if (includeMatches) {
1305
- const type = searcher.constructor.type;
1306
- if (MultiMatchSet.has(type)) {
1307
- allIndices = [...allIndices, ...indices];
1308
- } else {
1309
- allIndices.push(indices);
1310
- }
1311
- }
1312
- } else {
1313
- totalScore = 0;
1314
- numMatches = 0;
1315
- allIndices.length = 0;
1316
- break
1317
- }
1318
- }
1319
-
1320
- // OR condition, so if TRUE, return
1321
- if (numMatches) {
1322
- let result = {
1323
- isMatch: true,
1324
- score: totalScore / numMatches
1325
- };
1326
-
1327
- if (includeMatches) {
1328
- result.indices = allIndices;
1329
- }
1330
-
1331
- return result
1332
- }
1333
- }
1334
-
1335
- // Nothing was matched
1336
- return {
1337
- isMatch: false,
1338
- score: 1
1339
- }
1340
- }
1341
- }
845
+ //#endregion
846
+ //#region src/search/extended/index.ts
847
+ var ExtendedSearch = class {
848
+ constructor(pattern, { isCaseSensitive = Config.isCaseSensitive, ignoreDiacritics = Config.ignoreDiacritics, includeMatches = Config.includeMatches, minMatchCharLength = Config.minMatchCharLength, ignoreLocation = Config.ignoreLocation, findAllMatches = Config.findAllMatches, location = Config.location, threshold = Config.threshold, distance = Config.distance } = {}) {
849
+ this.query = null;
850
+ this.options = {
851
+ isCaseSensitive,
852
+ ignoreDiacritics,
853
+ includeMatches,
854
+ minMatchCharLength,
855
+ findAllMatches,
856
+ ignoreLocation,
857
+ location,
858
+ threshold,
859
+ distance
860
+ };
861
+ pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
862
+ pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
863
+ this.pattern = pattern;
864
+ this.query = parseQuery(this.pattern, this.options);
865
+ }
866
+ static condition(_, options) {
867
+ return options.useExtendedSearch;
868
+ }
869
+ searchIn(text) {
870
+ const query = this.query;
871
+ if (!query) return {
872
+ isMatch: false,
873
+ score: 1
874
+ };
875
+ const { includeMatches, isCaseSensitive, ignoreDiacritics } = this.options;
876
+ text = isCaseSensitive ? text : text.toLowerCase();
877
+ text = ignoreDiacritics ? stripDiacritics(text) : text;
878
+ let numMatches = 0;
879
+ const allIndices = [];
880
+ let totalScore = 0;
881
+ let hasInverse = false;
882
+ for (let i = 0, qLen = query.length; i < qLen; i += 1) {
883
+ const searchers = query[i];
884
+ allIndices.length = 0;
885
+ numMatches = 0;
886
+ hasInverse = false;
887
+ for (let j = 0, pLen = searchers.length; j < pLen; j += 1) {
888
+ const matcher = searchers[j];
889
+ const { isMatch, indices, score } = matcher.search(text);
890
+ if (isMatch) {
891
+ numMatches += 1;
892
+ totalScore += score;
893
+ if (isInverse(matcher.type)) hasInverse = true;
894
+ if (includeMatches) if (MULTI_MATCH_TYPES.has(matcher.type)) allIndices.push(...indices);
895
+ else allIndices.push(indices);
896
+ } else {
897
+ totalScore = 0;
898
+ numMatches = 0;
899
+ allIndices.length = 0;
900
+ hasInverse = false;
901
+ break;
902
+ }
903
+ }
904
+ if (numMatches) {
905
+ const result = {
906
+ isMatch: true,
907
+ score: totalScore / numMatches
908
+ };
909
+ if (hasInverse) result.hasInverse = true;
910
+ if (includeMatches) result.indices = mergeIndices(allIndices);
911
+ return result;
912
+ }
913
+ }
914
+ return {
915
+ isMatch: false,
916
+ score: 1
917
+ };
918
+ }
919
+ };
1342
920
 
921
+ //#endregion
922
+ //#region src/core/register.ts
1343
923
  const registeredSearchers = [];
1344
-
1345
924
  function register(...args) {
1346
- registeredSearchers.push(...args);
925
+ registeredSearchers.push(...args);
1347
926
  }
1348
-
1349
927
  function createSearcher(pattern, options) {
1350
- for (let i = 0, len = registeredSearchers.length; i < len; i += 1) {
1351
- let searcherClass = registeredSearchers[i];
1352
- if (searcherClass.condition(pattern, options)) {
1353
- return new searcherClass(pattern, options)
1354
- }
1355
- }
1356
-
1357
- return new BitapSearch(pattern, options)
928
+ for (let i = 0, len = registeredSearchers.length; i < len; i += 1) {
929
+ const searcherClass = registeredSearchers[i];
930
+ if (searcherClass.condition(pattern, options)) return new searcherClass(pattern, options);
931
+ }
932
+ return new BitapSearch(pattern, options);
1358
933
  }
1359
934
 
935
+ //#endregion
936
+ //#region src/core/queryParser.ts
1360
937
  const LogicalOperator = {
1361
- AND: '$and',
1362
- OR: '$or'
938
+ AND: "$and",
939
+ OR: "$or"
1363
940
  };
1364
-
1365
941
  const KeyType = {
1366
- PATH: '$path',
1367
- PATTERN: '$val'
942
+ PATH: "$path",
943
+ PATTERN: "$val"
1368
944
  };
1369
-
1370
- const isExpression = (query) =>
1371
- !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
1372
-
945
+ const isExpression = (query) => !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
1373
946
  const isPath = (query) => !!query[KeyType.PATH];
1374
-
1375
- const isLeaf = (query) =>
1376
- !isArray(query) && isObject(query) && !isExpression(query);
1377
-
1378
- const convertToExplicit = (query) => ({
1379
- [LogicalOperator.AND]: Object.keys(query).map((key) => ({
1380
- [key]: query[key]
1381
- }))
1382
- });
1383
-
1384
- // When `auto` is `true`, the parse function will infer and initialize and add
1385
- // the appropriate `Searcher` instance
947
+ const isLeaf = (query) => !isArray(query) && isObject(query) && !isExpression(query);
948
+ const convertToExplicit = (query) => ({ [LogicalOperator.AND]: Object.keys(query).map((key) => ({ [key]: query[key] })) });
1386
949
  function parse(query, options, { auto = true } = {}) {
1387
- const next = (query) => {
1388
- let keys = Object.keys(query);
1389
-
1390
- const isQueryPath = isPath(query);
1391
-
1392
- if (!isQueryPath && keys.length > 1 && !isExpression(query)) {
1393
- return next(convertToExplicit(query))
1394
- }
1395
-
1396
- if (isLeaf(query)) {
1397
- const key = isQueryPath ? query[KeyType.PATH] : keys[0];
1398
-
1399
- const pattern = isQueryPath ? query[KeyType.PATTERN] : query[key];
1400
-
1401
- if (!isString(pattern)) {
1402
- throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key))
1403
- }
1404
-
1405
- const obj = {
1406
- keyId: createKeyId(key),
1407
- pattern
1408
- };
1409
-
1410
- if (auto) {
1411
- obj.searcher = createSearcher(pattern, options);
1412
- }
1413
-
1414
- return obj
1415
- }
1416
-
1417
- let node = {
1418
- children: [],
1419
- operator: keys[0]
1420
- };
1421
-
1422
- keys.forEach((key) => {
1423
- const value = query[key];
1424
-
1425
- if (isArray(value)) {
1426
- value.forEach((item) => {
1427
- node.children.push(next(item));
1428
- });
1429
- }
1430
- });
1431
-
1432
- return node
1433
- };
1434
-
1435
- if (!isExpression(query)) {
1436
- query = convertToExplicit(query);
1437
- }
1438
-
1439
- return next(query)
950
+ const next = (query) => {
951
+ if (isString(query)) {
952
+ const obj = {
953
+ keyId: null,
954
+ pattern: query
955
+ };
956
+ if (auto) obj.searcher = createSearcher(query, options);
957
+ return obj;
958
+ }
959
+ const keys = Object.keys(query);
960
+ const isQueryPath = isPath(query);
961
+ if (!isQueryPath && keys.length > 1 && !isExpression(query)) return next(convertToExplicit(query));
962
+ if (isLeaf(query)) {
963
+ const key = isQueryPath ? query[KeyType.PATH] : keys[0];
964
+ const pattern = isQueryPath ? query[KeyType.PATTERN] : query[key];
965
+ if (!isString(pattern)) throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key));
966
+ const obj = {
967
+ keyId: createKeyId(key),
968
+ pattern
969
+ };
970
+ if (auto) obj.searcher = createSearcher(pattern, options);
971
+ return obj;
972
+ }
973
+ const node = {
974
+ children: [],
975
+ operator: keys[0]
976
+ };
977
+ keys.forEach((key) => {
978
+ const value = query[key];
979
+ if (isArray(value)) value.forEach((item) => {
980
+ node.children.push(next(item));
981
+ });
982
+ });
983
+ return node;
984
+ };
985
+ if (!isExpression(query)) query = convertToExplicit(query);
986
+ return next(query);
1440
987
  }
1441
988
 
1442
- // Practical scoring function
1443
- function computeScore(
1444
- results,
1445
- { ignoreFieldNorm = Config.ignoreFieldNorm }
1446
- ) {
1447
- results.forEach((result) => {
1448
- let totalScore = 1;
1449
-
1450
- result.matches.forEach(({ key, norm, score }) => {
1451
- const weight = key ? key.weight : null;
1452
-
1453
- totalScore *= Math.pow(
1454
- score === 0 && weight ? Number.EPSILON : score,
1455
- (weight || 1) * (ignoreFieldNorm ? 1 : norm)
1456
- );
1457
- });
1458
-
1459
- result.score = totalScore;
1460
- });
989
+ //#endregion
990
+ //#region src/core/computeScore.ts
991
+ function computeScoreSingle(matches, { ignoreFieldNorm = Config.ignoreFieldNorm }) {
992
+ let totalScore = 1;
993
+ matches.forEach(({ key, norm, score }) => {
994
+ const weight = key ? key.weight : null;
995
+ totalScore *= Math.pow(score === 0 && weight ? Number.EPSILON : score, (weight || 1) * (ignoreFieldNorm ? 1 : norm));
996
+ });
997
+ return totalScore;
998
+ }
999
+ function computeScore(results, { ignoreFieldNorm = Config.ignoreFieldNorm }) {
1000
+ results.forEach((result) => {
1001
+ result.score = computeScoreSingle(result.matches, { ignoreFieldNorm });
1002
+ });
1461
1003
  }
1462
1004
 
1463
- function transformMatches(result, data) {
1464
- const matches = result.matches;
1465
- data.matches = [];
1466
-
1467
- if (!isDefined(matches)) {
1468
- return
1469
- }
1470
-
1471
- matches.forEach((match) => {
1472
- if (!isDefined(match.indices) || !match.indices.length) {
1473
- return
1474
- }
1475
-
1476
- const { indices, value } = match;
1477
-
1478
- let obj = {
1479
- indices,
1480
- value
1481
- };
1482
-
1483
- if (match.key) {
1484
- obj.key = match.key.src;
1485
- }
1486
-
1487
- if (match.idx > -1) {
1488
- obj.refIndex = match.idx;
1489
- }
1005
+ //#endregion
1006
+ //#region src/tools/MaxHeap.ts
1007
+ var MaxHeap = class {
1008
+ constructor(limit) {
1009
+ this.limit = limit;
1010
+ this.heap = [];
1011
+ }
1012
+ get size() {
1013
+ return this.heap.length;
1014
+ }
1015
+ shouldInsert(score) {
1016
+ return this.size < this.limit || score < this.heap[0].score;
1017
+ }
1018
+ insert(item) {
1019
+ if (this.size < this.limit) {
1020
+ this.heap.push(item);
1021
+ this._bubbleUp(this.size - 1);
1022
+ } else if (item.score < this.heap[0].score) {
1023
+ this.heap[0] = item;
1024
+ this._sinkDown(0);
1025
+ }
1026
+ }
1027
+ extractSorted(sortFn) {
1028
+ return this.heap.sort(sortFn);
1029
+ }
1030
+ _bubbleUp(i) {
1031
+ const heap = this.heap;
1032
+ while (i > 0) {
1033
+ const parent = i - 1 >> 1;
1034
+ if (heap[i].score <= heap[parent].score) break;
1035
+ const tmp = heap[i];
1036
+ heap[i] = heap[parent];
1037
+ heap[parent] = tmp;
1038
+ i = parent;
1039
+ }
1040
+ }
1041
+ _sinkDown(i) {
1042
+ const heap = this.heap;
1043
+ const len = heap.length;
1044
+ let largest = i;
1045
+ do {
1046
+ i = largest;
1047
+ const left = 2 * i + 1;
1048
+ const right = 2 * i + 2;
1049
+ if (left < len && heap[left].score > heap[largest].score) largest = left;
1050
+ if (right < len && heap[right].score > heap[largest].score) largest = right;
1051
+ if (largest !== i) {
1052
+ const tmp = heap[i];
1053
+ heap[i] = heap[largest];
1054
+ heap[largest] = tmp;
1055
+ }
1056
+ } while (largest !== i);
1057
+ }
1058
+ };
1490
1059
 
1491
- data.matches.push(obj);
1492
- });
1060
+ //#endregion
1061
+ //#region src/core/formatMatches.ts
1062
+ function formatMatches(result) {
1063
+ const matches = [];
1064
+ result.matches.forEach((match) => {
1065
+ if (!isDefined(match.indices) || !match.indices.length) return;
1066
+ const obj = {
1067
+ indices: match.indices,
1068
+ value: match.value
1069
+ };
1070
+ if (match.key) obj.key = match.key.id;
1071
+ if (match.idx > -1) obj.refIndex = match.idx;
1072
+ matches.push(obj);
1073
+ });
1074
+ return matches;
1493
1075
  }
1494
1076
 
1495
- function transformScore(result, data) {
1496
- data.score = result.score;
1077
+ //#endregion
1078
+ //#region src/core/format.ts
1079
+ function format(results, docs, { includeMatches = Config.includeMatches, includeScore = Config.includeScore } = {}) {
1080
+ return results.map((result) => {
1081
+ const { idx } = result;
1082
+ const data = {
1083
+ item: docs[idx],
1084
+ refIndex: idx
1085
+ };
1086
+ if (includeMatches) data.matches = formatMatches(result);
1087
+ if (includeScore) data.score = result.score;
1088
+ return data;
1089
+ });
1497
1090
  }
1498
1091
 
1499
- function format(
1500
- results,
1501
- docs,
1502
- {
1503
- includeMatches = Config.includeMatches,
1504
- includeScore = Config.includeScore
1505
- } = {}
1506
- ) {
1507
- const transformers = [];
1508
-
1509
- if (includeMatches) transformers.push(transformMatches);
1510
- if (includeScore) transformers.push(transformScore);
1511
-
1512
- return results.map((result) => {
1513
- const { idx } = result;
1514
-
1515
- const data = {
1516
- item: docs[idx],
1517
- refIndex: idx
1518
- };
1519
-
1520
- if (transformers.length) {
1521
- transformers.forEach((transformer) => {
1522
- transformer(result, data);
1523
- });
1524
- }
1525
-
1526
- return data
1527
- })
1092
+ //#endregion
1093
+ //#region src/search/token/analyzer.ts
1094
+ const DEFAULT_TOKEN = /[\p{L}\p{M}\p{N}_]+/gu;
1095
+ const warned = /* @__PURE__ */ new WeakSet();
1096
+ function warnNonGlobal(regex) {
1097
+ if (!warned.has(regex)) {
1098
+ warned.add(regex);
1099
+ console.warn(`[Fuse] tokenize regex ${regex} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`);
1100
+ }
1528
1101
  }
1102
+ function resolveTokenize(tokenize) {
1103
+ if (typeof tokenize === "function") {
1104
+ let validated = false;
1105
+ return (text) => {
1106
+ const result = tokenize(text);
1107
+ if (!validated) {
1108
+ validated = true;
1109
+ if (!Array.isArray(result) || result.some((t) => typeof t !== "string")) throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(result) ? "array containing non-strings" : typeof result}.`);
1110
+ }
1111
+ return result;
1112
+ };
1113
+ }
1114
+ if (tokenize instanceof RegExp) {
1115
+ if (!tokenize.global) warnNonGlobal(tokenize);
1116
+ return (text) => text.match(tokenize) || [];
1117
+ }
1118
+ return (text) => text.match(DEFAULT_TOKEN) || [];
1119
+ }
1120
+ function createAnalyzer({ isCaseSensitive = false, ignoreDiacritics = false, tokenize } = {}) {
1121
+ const tokenizeFn = resolveTokenize(tokenize);
1122
+ return { tokenize(text) {
1123
+ if (!isCaseSensitive) text = text.toLowerCase();
1124
+ if (ignoreDiacritics) text = stripDiacritics(text);
1125
+ return tokenizeFn(text);
1126
+ } };
1127
+ }
1128
+ var TokenSearch = class {
1129
+ static condition(_, options) {
1130
+ return options.useTokenSearch;
1131
+ }
1132
+ constructor(pattern, options) {
1133
+ this.options = options;
1134
+ this.analyzer = createAnalyzer({
1135
+ isCaseSensitive: options.isCaseSensitive,
1136
+ ignoreDiacritics: options.ignoreDiacritics,
1137
+ tokenize: options.tokenize
1138
+ });
1139
+ const queryTerms = this.analyzer.tokenize(pattern);
1140
+ const { df, fieldCount } = options._invertedIndex;
1141
+ this.termSearchers = [];
1142
+ this.idfWeights = [];
1143
+ for (const term of queryTerms) {
1144
+ this.termSearchers.push(new BitapSearch(term, {
1145
+ location: options.location,
1146
+ threshold: options.threshold,
1147
+ distance: options.distance,
1148
+ includeMatches: options.includeMatches,
1149
+ findAllMatches: options.findAllMatches,
1150
+ minMatchCharLength: options.minMatchCharLength,
1151
+ isCaseSensitive: options.isCaseSensitive,
1152
+ ignoreDiacritics: options.ignoreDiacritics,
1153
+ ignoreLocation: true
1154
+ }));
1155
+ const docFreq = df.get(term) || 0;
1156
+ const idf = Math.log(1 + (fieldCount - docFreq + .5) / (docFreq + .5));
1157
+ this.idfWeights.push(idf);
1158
+ }
1159
+ this.combineAll = options.tokenMatch === "all";
1160
+ this.numTerms = this.termSearchers.length;
1161
+ this.useMask = this.numTerms <= 31;
1162
+ }
1163
+ searchIn(text) {
1164
+ if (!this.termSearchers.length) return {
1165
+ isMatch: false,
1166
+ score: 1
1167
+ };
1168
+ const allIndices = [];
1169
+ let weightedScore = 0;
1170
+ let maxPossibleScore = 0;
1171
+ let matchedCount = 0;
1172
+ let matchedMask = 0;
1173
+ const matchedTerms = this.combineAll && !this.useMask ? /* @__PURE__ */ new Set() : null;
1174
+ for (let i = 0; i < this.termSearchers.length; i++) {
1175
+ const result = this.termSearchers[i].searchIn(text);
1176
+ const idf = this.idfWeights[i];
1177
+ maxPossibleScore += idf;
1178
+ if (result.isMatch) {
1179
+ matchedCount++;
1180
+ weightedScore += idf * (1 - result.score);
1181
+ if (result.indices) allIndices.push(...result.indices);
1182
+ if (this.combineAll) if (this.useMask) matchedMask |= 1 << i;
1183
+ else matchedTerms.add(i);
1184
+ }
1185
+ }
1186
+ if (matchedCount === 0) return {
1187
+ isMatch: false,
1188
+ score: 1
1189
+ };
1190
+ const normalized = maxPossibleScore > 0 ? 1 - weightedScore / maxPossibleScore : 0;
1191
+ const searchResult = {
1192
+ isMatch: true,
1193
+ score: Math.max(.001, normalized)
1194
+ };
1195
+ if (this.options.includeMatches && allIndices.length) searchResult.indices = mergeIndices(allIndices);
1196
+ if (this.combineAll) {
1197
+ if (this.useMask) searchResult.matchedMask = matchedMask;
1198
+ else searchResult.matchedTerms = matchedTerms;
1199
+ searchResult.termCount = this.numTerms;
1200
+ }
1201
+ return searchResult;
1202
+ }
1203
+ };
1529
1204
 
1530
- class Fuse {
1531
- constructor(docs, options = {}, index) {
1532
- this.options = { ...Config, ...options };
1533
-
1534
- if (
1535
- this.options.useExtendedSearch &&
1536
- !true
1537
- ) {
1538
- throw new Error(EXTENDED_SEARCH_UNAVAILABLE)
1539
- }
1540
-
1541
- this._keyStore = new KeyStore(this.options.keys);
1542
-
1543
- this.setCollection(docs, index);
1544
- }
1545
-
1546
- setCollection(docs, index) {
1547
- this._docs = docs;
1548
-
1549
- if (index && !(index instanceof FuseIndex)) {
1550
- throw new Error(INCORRECT_INDEX_TYPE)
1551
- }
1552
-
1553
- this._myIndex =
1554
- index ||
1555
- createIndex(this.options.keys, this._docs, {
1556
- getFn: this.options.getFn,
1557
- fieldNormWeight: this.options.fieldNormWeight
1558
- });
1559
- }
1560
-
1561
- add(doc) {
1562
- if (!isDefined(doc)) {
1563
- return
1564
- }
1565
-
1566
- this._docs.push(doc);
1567
- this._myIndex.add(doc);
1568
- }
1569
-
1570
- remove(predicate = (/* doc, idx */) => false) {
1571
- const results = [];
1572
-
1573
- for (let i = 0, len = this._docs.length; i < len; i += 1) {
1574
- const doc = this._docs[i];
1575
- if (predicate(doc, i)) {
1576
- this.removeAt(i);
1577
- i -= 1;
1578
- len -= 1;
1579
-
1580
- results.push(doc);
1581
- }
1582
- }
1583
-
1584
- return results
1585
- }
1586
-
1587
- removeAt(idx) {
1588
- this._docs.splice(idx, 1);
1589
- this._myIndex.removeAt(idx);
1590
- }
1591
-
1592
- getIndex() {
1593
- return this._myIndex
1594
- }
1595
-
1596
- search(query, { limit = -1 } = {}) {
1597
- const {
1598
- includeMatches,
1599
- includeScore,
1600
- shouldSort,
1601
- sortFn,
1602
- ignoreFieldNorm
1603
- } = this.options;
1604
-
1605
- let results = isString(query)
1606
- ? isString(this._docs[0])
1607
- ? this._searchStringList(query)
1608
- : this._searchObjectList(query)
1609
- : this._searchLogical(query);
1610
-
1611
- computeScore(results, { ignoreFieldNorm });
1612
-
1613
- if (shouldSort) {
1614
- results.sort(sortFn);
1615
- }
1616
-
1617
- if (isNumber(limit) && limit > -1) {
1618
- results = results.slice(0, limit);
1619
- }
1620
-
1621
- return format(results, this._docs, {
1622
- includeMatches,
1623
- includeScore
1624
- })
1625
- }
1626
-
1627
- _searchStringList(query) {
1628
- const searcher = createSearcher(query, this.options);
1629
- const { records } = this._myIndex;
1630
- const results = [];
1631
-
1632
- // Iterate over every string in the index
1633
- records.forEach(({ v: text, i: idx, n: norm }) => {
1634
- if (!isDefined(text)) {
1635
- return
1636
- }
1637
-
1638
- const { isMatch, score, indices } = searcher.searchIn(text);
1639
-
1640
- if (isMatch) {
1641
- results.push({
1642
- item: text,
1643
- idx,
1644
- matches: [{ score, value: text, norm, indices }]
1645
- });
1646
- }
1647
- });
1648
-
1649
- return results
1650
- }
1651
-
1652
- _searchLogical(query) {
1653
-
1654
- const expression = parse(query, this.options);
1655
-
1656
- const evaluate = (node, item, idx) => {
1657
- if (!node.children) {
1658
- const { keyId, searcher } = node;
1659
-
1660
- const matches = this._findMatches({
1661
- key: this._keyStore.get(keyId),
1662
- value: this._myIndex.getValueForItemAtKeyId(item, keyId),
1663
- searcher
1664
- });
1665
-
1666
- if (matches && matches.length) {
1667
- return [
1668
- {
1669
- idx,
1670
- item,
1671
- matches
1672
- }
1673
- ]
1674
- }
1675
-
1676
- return []
1677
- }
1678
-
1679
- const res = [];
1680
- for (let i = 0, len = node.children.length; i < len; i += 1) {
1681
- const child = node.children[i];
1682
- const result = evaluate(child, item, idx);
1683
- if (result.length) {
1684
- res.push(...result);
1685
- } else if (node.operator === LogicalOperator.AND) {
1686
- return []
1687
- }
1688
- }
1689
- return res
1690
- };
1691
-
1692
- const records = this._myIndex.records;
1693
- const resultMap = {};
1694
- const results = [];
1695
-
1696
- records.forEach(({ $: item, i: idx }) => {
1697
- if (isDefined(item)) {
1698
- let expResults = evaluate(expression, item, idx);
1699
-
1700
- if (expResults.length) {
1701
- // Dedupe when adding
1702
- if (!resultMap[idx]) {
1703
- resultMap[idx] = { idx, item, matches: [] };
1704
- results.push(resultMap[idx]);
1705
- }
1706
- expResults.forEach(({ matches }) => {
1707
- resultMap[idx].matches.push(...matches);
1708
- });
1709
- }
1710
- }
1711
- });
1712
-
1713
- return results
1714
- }
1715
-
1716
- _searchObjectList(query) {
1717
- const searcher = createSearcher(query, this.options);
1718
- const { keys, records } = this._myIndex;
1719
- const results = [];
1720
-
1721
- // List is Array<Object>
1722
- records.forEach(({ $: item, i: idx }) => {
1723
- if (!isDefined(item)) {
1724
- return
1725
- }
1726
-
1727
- let matches = [];
1728
-
1729
- // Iterate over every key (i.e, path), and fetch the value at that key
1730
- keys.forEach((key, keyIndex) => {
1731
- matches.push(
1732
- ...this._findMatches({
1733
- key,
1734
- value: item[keyIndex],
1735
- searcher
1736
- })
1737
- );
1738
- });
1739
-
1740
- if (matches.length) {
1741
- results.push({
1742
- idx,
1743
- item,
1744
- matches
1745
- });
1746
- }
1747
- });
1748
-
1749
- return results
1750
- }
1751
- _findMatches({ key, value, searcher }) {
1752
- if (!isDefined(value)) {
1753
- return []
1754
- }
1755
-
1756
- let matches = [];
1757
-
1758
- if (isArray(value)) {
1759
- value.forEach(({ v: text, i: idx, n: norm }) => {
1760
- if (!isDefined(text)) {
1761
- return
1762
- }
1763
-
1764
- const { isMatch, score, indices } = searcher.searchIn(text);
1765
-
1766
- if (isMatch) {
1767
- matches.push({
1768
- score,
1769
- key,
1770
- value: text,
1771
- idx,
1772
- norm,
1773
- indices
1774
- });
1775
- }
1776
- });
1777
- } else {
1778
- const { v: text, n: norm } = value;
1779
-
1780
- const { isMatch, score, indices } = searcher.searchIn(text);
1781
-
1782
- if (isMatch) {
1783
- matches.push({ score, key, value: text, norm, indices });
1784
- }
1785
- }
1786
-
1787
- return matches
1788
- }
1205
+ //#endregion
1206
+ //#region src/search/token/InvertedIndex.ts
1207
+ function addField(index, text, docIdx, analyzer) {
1208
+ const tokens = analyzer.tokenize(text);
1209
+ if (!tokens.length) return;
1210
+ index.fieldCount++;
1211
+ index.docFieldCount.set(docIdx, (index.docFieldCount.get(docIdx) || 0) + 1);
1212
+ const distinctTerms = new Set(tokens);
1213
+ let perDocTerms = index.docTermFieldHits.get(docIdx);
1214
+ if (!perDocTerms) {
1215
+ perDocTerms = /* @__PURE__ */ new Map();
1216
+ index.docTermFieldHits.set(docIdx, perDocTerms);
1217
+ }
1218
+ for (const term of distinctTerms) {
1219
+ perDocTerms.set(term, (perDocTerms.get(term) || 0) + 1);
1220
+ index.df.set(term, (index.df.get(term) || 0) + 1);
1221
+ }
1222
+ }
1223
+ function ingestRecord(index, record, keyCount, analyzer) {
1224
+ const { i: docIdx, v, $: fields } = record;
1225
+ if (v !== void 0) {
1226
+ addField(index, v, docIdx, analyzer);
1227
+ return;
1228
+ }
1229
+ if (!fields) return;
1230
+ for (let keyIdx = 0; keyIdx < keyCount; keyIdx++) {
1231
+ const value = fields[keyIdx];
1232
+ if (!value) continue;
1233
+ if (Array.isArray(value)) for (const sub of value) addField(index, sub.v, docIdx, analyzer);
1234
+ else addField(index, value.v, docIdx, analyzer);
1235
+ }
1789
1236
  }
1237
+ function buildInvertedIndex(records, keyCount, analyzer) {
1238
+ const index = {
1239
+ fieldCount: 0,
1240
+ df: /* @__PURE__ */ new Map(),
1241
+ docFieldCount: /* @__PURE__ */ new Map(),
1242
+ docTermFieldHits: /* @__PURE__ */ new Map()
1243
+ };
1244
+ for (const record of records) ingestRecord(index, record, keyCount, analyzer);
1245
+ return index;
1246
+ }
1247
+ function addToInvertedIndex(index, record, keyCount, analyzer) {
1248
+ ingestRecord(index, record, keyCount, analyzer);
1249
+ }
1250
+ function removeFromInvertedIndex(index, docIdx) {
1251
+ const fieldCount = index.docFieldCount.get(docIdx);
1252
+ if (fieldCount === void 0) return;
1253
+ index.fieldCount -= fieldCount;
1254
+ index.docFieldCount.delete(docIdx);
1255
+ const perDocTerms = index.docTermFieldHits.get(docIdx);
1256
+ if (!perDocTerms) return;
1257
+ for (const [term, hits] of perDocTerms) {
1258
+ const next = (index.df.get(term) || 0) - hits;
1259
+ if (next <= 0) index.df.delete(term);
1260
+ else index.df.set(term, next);
1261
+ }
1262
+ index.docTermFieldHits.delete(docIdx);
1263
+ }
1264
+ function removeAndShiftInvertedIndex(index, removedIndices) {
1265
+ if (removedIndices.length === 0) return;
1266
+ const sorted = Array.from(new Set(removedIndices)).sort((a, b) => a - b);
1267
+ for (const idx of sorted) removeFromInvertedIndex(index, idx);
1268
+ const shift = (oldIdx) => {
1269
+ let lo = 0;
1270
+ let hi = sorted.length;
1271
+ while (lo < hi) {
1272
+ const mid = lo + hi >>> 1;
1273
+ if (sorted[mid] < oldIdx) lo = mid + 1;
1274
+ else hi = mid;
1275
+ }
1276
+ return oldIdx - lo;
1277
+ };
1278
+ const firstRemoved = sorted[0];
1279
+ const shiftedDocFieldCount = /* @__PURE__ */ new Map();
1280
+ for (const [oldKey, count] of index.docFieldCount) shiftedDocFieldCount.set(oldKey > firstRemoved ? shift(oldKey) : oldKey, count);
1281
+ index.docFieldCount = shiftedDocFieldCount;
1282
+ const shiftedDocTermFieldHits = /* @__PURE__ */ new Map();
1283
+ for (const [oldKey, terms] of index.docTermFieldHits) shiftedDocTermFieldHits.set(oldKey > firstRemoved ? shift(oldKey) : oldKey, terms);
1284
+ index.docTermFieldHits = shiftedDocTermFieldHits;
1285
+ }
1286
+
1287
+ //#endregion
1288
+ //#region src/core/index.ts
1289
+ var Fuse = class {
1290
+ constructor(docs, options, index) {
1291
+ this.options = {
1292
+ ...Config,
1293
+ ...options
1294
+ };
1295
+ this._keyStore = new KeyStore(this.options.keys);
1296
+ this._docs = docs;
1297
+ this._myIndex = null;
1298
+ this._invertedIndex = null;
1299
+ this.setCollection(docs, index);
1300
+ this._lastQuery = null;
1301
+ this._lastSearcher = null;
1302
+ }
1303
+ _getSearcher(query) {
1304
+ if (this._lastQuery === query) return this._lastSearcher;
1305
+ const searcher = createSearcher(query, this._invertedIndex ? {
1306
+ ...this.options,
1307
+ _invertedIndex: this._invertedIndex
1308
+ } : this.options);
1309
+ this._lastQuery = query;
1310
+ this._lastSearcher = searcher;
1311
+ return searcher;
1312
+ }
1313
+ setCollection(docs, index) {
1314
+ this._docs = docs;
1315
+ if (index && !(index instanceof FuseIndex)) throw new Error(INCORRECT_INDEX_TYPE);
1316
+ this._myIndex = index || createIndex(this.options.keys, this._docs, {
1317
+ getFn: this.options.getFn,
1318
+ fieldNormWeight: this.options.fieldNormWeight
1319
+ });
1320
+ if (this.options.useTokenSearch) {
1321
+ const analyzer = createAnalyzer({
1322
+ isCaseSensitive: this.options.isCaseSensitive,
1323
+ ignoreDiacritics: this.options.ignoreDiacritics,
1324
+ tokenize: this.options.tokenize
1325
+ });
1326
+ this._invertedIndex = buildInvertedIndex(this._myIndex.records, this._myIndex.keys.length, analyzer);
1327
+ }
1328
+ this._invalidateSearcherCache();
1329
+ }
1330
+ add(doc) {
1331
+ if (!isDefined(doc)) return;
1332
+ this._docs.push(doc);
1333
+ const record = this._myIndex.add(doc, this._docs.length - 1);
1334
+ if (this._invertedIndex && record) {
1335
+ const analyzer = createAnalyzer({
1336
+ isCaseSensitive: this.options.isCaseSensitive,
1337
+ ignoreDiacritics: this.options.ignoreDiacritics,
1338
+ tokenize: this.options.tokenize
1339
+ });
1340
+ addToInvertedIndex(this._invertedIndex, record, this._myIndex.keys.length, analyzer);
1341
+ }
1342
+ this._invalidateSearcherCache();
1343
+ }
1344
+ remove(predicate = () => false) {
1345
+ const results = [];
1346
+ const indicesToRemove = [];
1347
+ for (let i = 0, len = this._docs.length; i < len; i += 1) if (predicate(this._docs[i], i)) {
1348
+ results.push(this._docs[i]);
1349
+ indicesToRemove.push(i);
1350
+ }
1351
+ if (indicesToRemove.length) {
1352
+ if (this._invertedIndex) removeAndShiftInvertedIndex(this._invertedIndex, indicesToRemove);
1353
+ const toRemove = new Set(indicesToRemove);
1354
+ this._docs = this._docs.filter((_, i) => !toRemove.has(i));
1355
+ this._myIndex.removeAll(indicesToRemove);
1356
+ this._invalidateSearcherCache();
1357
+ }
1358
+ return results;
1359
+ }
1360
+ removeAt(idx) {
1361
+ if (!Number.isInteger(idx) || idx < 0 || idx >= this._docs.length) throw new Error(INVALID_DOC_INDEX);
1362
+ if (this._invertedIndex) removeAndShiftInvertedIndex(this._invertedIndex, [idx]);
1363
+ const doc = this._docs.splice(idx, 1)[0];
1364
+ this._myIndex.removeAt(idx);
1365
+ this._invalidateSearcherCache();
1366
+ return doc;
1367
+ }
1368
+ _invalidateSearcherCache() {
1369
+ this._lastQuery = null;
1370
+ this._lastSearcher = null;
1371
+ }
1372
+ getIndex() {
1373
+ return this._myIndex;
1374
+ }
1375
+ search(query, options) {
1376
+ const { limit = -1 } = options || {};
1377
+ const { includeMatches, includeScore, shouldSort, sortFn, ignoreFieldNorm } = this.options;
1378
+ if (isString(query) && !query.trim()) {
1379
+ let docs = this._docs.map((item, idx) => ({
1380
+ item,
1381
+ refIndex: idx
1382
+ }));
1383
+ if (isNumber(limit) && limit > -1) docs = docs.slice(0, limit);
1384
+ return docs;
1385
+ }
1386
+ const useHeap = isNumber(limit) && limit > 0 && isString(query);
1387
+ let results;
1388
+ if (useHeap) {
1389
+ const heap = new MaxHeap(limit);
1390
+ if (isString(this._docs[0])) this._searchStringList(query, {
1391
+ heap,
1392
+ ignoreFieldNorm
1393
+ });
1394
+ else this._searchObjectList(query, {
1395
+ heap,
1396
+ ignoreFieldNorm
1397
+ });
1398
+ results = heap.extractSorted(sortFn);
1399
+ } else {
1400
+ results = isString(query) ? isString(this._docs[0]) ? this._searchStringList(query) : this._searchObjectList(query) : this._searchLogical(query);
1401
+ computeScore(results, { ignoreFieldNorm });
1402
+ if (shouldSort) results.sort(sortFn);
1403
+ if (isNumber(limit) && limit > -1) results = results.slice(0, limit);
1404
+ }
1405
+ return format(results, this._docs, {
1406
+ includeMatches,
1407
+ includeScore
1408
+ });
1409
+ }
1410
+ _searchStringList(query, { heap, ignoreFieldNorm } = {}) {
1411
+ const searcher = this._getSearcher(query);
1412
+ const requireAllTokens = this.options.useTokenSearch && this.options.tokenMatch === "all";
1413
+ const { records } = this._myIndex;
1414
+ const results = heap ? null : [];
1415
+ records.forEach(({ v: text, i: idx, n: norm }) => {
1416
+ if (!isDefined(text)) return;
1417
+ const searchResult = searcher.searchIn(text);
1418
+ if (searchResult.isMatch) {
1419
+ const match = {
1420
+ score: searchResult.score,
1421
+ value: text,
1422
+ norm,
1423
+ indices: searchResult.indices
1424
+ };
1425
+ if (requireAllTokens) {
1426
+ match.matchedMask = searchResult.matchedMask;
1427
+ match.matchedTerms = searchResult.matchedTerms;
1428
+ match.termCount = searchResult.termCount;
1429
+ }
1430
+ const matches = [match];
1431
+ if (!requireAllTokens || this._coversAllTokens(matches)) {
1432
+ const result = {
1433
+ item: text,
1434
+ idx,
1435
+ matches
1436
+ };
1437
+ if (heap) {
1438
+ result.score = computeScoreSingle(result.matches, { ignoreFieldNorm });
1439
+ if (heap.shouldInsert(result.score)) heap.insert(result);
1440
+ } else results.push(result);
1441
+ }
1442
+ }
1443
+ });
1444
+ return results;
1445
+ }
1446
+ _searchLogical(query) {
1447
+ const expression = parse(query, this.options);
1448
+ const evaluate = (node, item, idx) => {
1449
+ if (!("children" in node)) {
1450
+ const { keyId, searcher } = node;
1451
+ let matches;
1452
+ if (keyId === null) {
1453
+ matches = [];
1454
+ this._myIndex.keys.forEach((key, keyIndex) => {
1455
+ matches.push(...this._findMatches({
1456
+ key,
1457
+ value: item[keyIndex],
1458
+ searcher
1459
+ }));
1460
+ });
1461
+ } else matches = this._findMatches({
1462
+ key: this._keyStore.get(keyId),
1463
+ value: this._myIndex.getValueForItemAtKeyId(item, keyId),
1464
+ searcher
1465
+ });
1466
+ if (matches && matches.length) return [{
1467
+ idx,
1468
+ item,
1469
+ matches
1470
+ }];
1471
+ return [];
1472
+ }
1473
+ const { children, operator } = node;
1474
+ const res = [];
1475
+ for (let i = 0, len = children.length; i < len; i += 1) {
1476
+ const child = children[i];
1477
+ const result = evaluate(child, item, idx);
1478
+ if (result.length) res.push(...result);
1479
+ else if (operator === LogicalOperator.AND) return [];
1480
+ }
1481
+ return res;
1482
+ };
1483
+ const records = this._myIndex.records;
1484
+ const resultMap = /* @__PURE__ */ new Map();
1485
+ const results = [];
1486
+ records.forEach(({ $: item, i: idx }) => {
1487
+ if (isDefined(item)) {
1488
+ const expResults = evaluate(expression, item, idx);
1489
+ if (expResults.length) {
1490
+ if (!resultMap.has(idx)) {
1491
+ resultMap.set(idx, {
1492
+ idx,
1493
+ item,
1494
+ matches: []
1495
+ });
1496
+ results.push(resultMap.get(idx));
1497
+ }
1498
+ expResults.forEach(({ matches }) => {
1499
+ resultMap.get(idx).matches.push(...matches);
1500
+ });
1501
+ }
1502
+ }
1503
+ });
1504
+ return results;
1505
+ }
1506
+ _searchObjectList(query, { heap, ignoreFieldNorm } = {}) {
1507
+ const searcher = this._getSearcher(query);
1508
+ const requireAllTokens = this.options.useTokenSearch && this.options.tokenMatch === "all";
1509
+ const { keys, records } = this._myIndex;
1510
+ const results = heap ? null : [];
1511
+ records.forEach(({ $: item, i: idx }) => {
1512
+ if (!isDefined(item)) return;
1513
+ const matches = [];
1514
+ let anyKeyFailed = false;
1515
+ let hasInverse = false;
1516
+ keys.forEach((key, keyIndex) => {
1517
+ const keyMatches = this._findMatches({
1518
+ key,
1519
+ value: item[keyIndex],
1520
+ searcher
1521
+ });
1522
+ if (keyMatches.length) {
1523
+ matches.push(...keyMatches);
1524
+ if (keyMatches[0].hasInverse) hasInverse = true;
1525
+ } else anyKeyFailed = true;
1526
+ });
1527
+ if (hasInverse && anyKeyFailed) return;
1528
+ if (matches.length && (!requireAllTokens || this._coversAllTokens(matches))) {
1529
+ const result = {
1530
+ idx,
1531
+ item,
1532
+ matches
1533
+ };
1534
+ if (heap) {
1535
+ result.score = computeScoreSingle(result.matches, { ignoreFieldNorm });
1536
+ if (heap.shouldInsert(result.score)) heap.insert(result);
1537
+ } else results.push(result);
1538
+ }
1539
+ });
1540
+ return results;
1541
+ }
1542
+ _findMatches({ key, value, searcher }) {
1543
+ if (!isDefined(value)) return [];
1544
+ const matches = [];
1545
+ if (isArray(value)) value.forEach(({ v: text, i: idx, n: norm }) => {
1546
+ if (!isDefined(text)) return;
1547
+ const searchResult = searcher.searchIn(text);
1548
+ if (searchResult.isMatch) {
1549
+ const match = {
1550
+ score: searchResult.score,
1551
+ key,
1552
+ value: text,
1553
+ idx,
1554
+ norm,
1555
+ indices: searchResult.indices,
1556
+ hasInverse: searchResult.hasInverse
1557
+ };
1558
+ if (searchResult.termCount !== void 0) {
1559
+ match.matchedMask = searchResult.matchedMask;
1560
+ match.matchedTerms = searchResult.matchedTerms;
1561
+ match.termCount = searchResult.termCount;
1562
+ }
1563
+ matches.push(match);
1564
+ }
1565
+ });
1566
+ else {
1567
+ const { v: text, n: norm } = value;
1568
+ const searchResult = searcher.searchIn(text);
1569
+ if (searchResult.isMatch) {
1570
+ const match = {
1571
+ score: searchResult.score,
1572
+ key,
1573
+ value: text,
1574
+ norm,
1575
+ indices: searchResult.indices,
1576
+ hasInverse: searchResult.hasInverse
1577
+ };
1578
+ if (searchResult.termCount !== void 0) {
1579
+ match.matchedMask = searchResult.matchedMask;
1580
+ match.matchedTerms = searchResult.matchedTerms;
1581
+ match.termCount = searchResult.termCount;
1582
+ }
1583
+ matches.push(match);
1584
+ }
1585
+ }
1586
+ return matches;
1587
+ }
1588
+ _coversAllTokens(matches) {
1589
+ const termCount = matches.length ? matches[0].termCount : void 0;
1590
+ if (termCount === void 0) return true;
1591
+ if (termCount <= 31) {
1592
+ let coverage = 0;
1593
+ for (let i = 0; i < matches.length; i++) coverage |= matches[i].matchedMask || 0;
1594
+ return coverage === 2 ** termCount - 1;
1595
+ }
1596
+ const coverage = /* @__PURE__ */ new Set();
1597
+ for (let i = 0; i < matches.length; i++) {
1598
+ const terms = matches[i].matchedTerms;
1599
+ if (terms) for (const t of terms) coverage.add(t);
1600
+ }
1601
+ return coverage.size === termCount;
1602
+ }
1603
+ };
1790
1604
 
1791
- Fuse.version = '7.1.0';
1605
+ //#endregion
1606
+ //#region src/entry.ts
1607
+ Fuse.version = "7.4.2";
1792
1608
  Fuse.createIndex = createIndex;
1793
1609
  Fuse.parseIndex = parseIndex;
1794
1610
  Fuse.config = Config;
1795
-
1796
- {
1797
- Fuse.parseQuery = parse;
1798
- }
1799
-
1800
- {
1801
- register(ExtendedSearch);
1802
- }
1611
+ Fuse.match = function(pattern, text, options) {
1612
+ if (options && options.useTokenSearch) throw new Error(FUSE_MATCH_TOKEN_SEARCH_UNSUPPORTED);
1613
+ return createSearcher(pattern, {
1614
+ ...Config,
1615
+ ...options
1616
+ }).searchIn(text);
1617
+ };
1618
+ Fuse.parseQuery = parse;
1619
+ register(ExtendedSearch);
1620
+ register(TokenSearch);
1621
+ Fuse.use = function(...plugins) {
1622
+ plugins.forEach((plugin) => register(plugin));
1623
+ };
1624
+ var entry_default = Fuse;
1803
1625
 
1804
1626
  const GreenCheckDuotoneIcon = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
1805
1627
  <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"/>
@@ -1847,7 +1669,7 @@ const ZonosCountrySelect = class {
1847
1669
  render() {
1848
1670
  const { helloCountryList } = localizationStore;
1849
1671
  const countries = helloCountryList ? Object.values(helloCountryList) : [];
1850
- const fuse = new Fuse(countries, {
1672
+ const fuse = new entry_default(countries, {
1851
1673
  includeScore: true,
1852
1674
  keys: ['displayName'],
1853
1675
  threshold: 0.3,