@delali/narsil 0.3.1-next.154 → 0.3.1-next.156

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 (329) hide show
  1. package/NOTICE +45 -0
  2. package/README.md +1 -0
  3. package/dist/adapters/filesystem.mjs +2 -2
  4. package/dist/adapters/gcs.mjs +2 -2
  5. package/dist/adapters/indexeddb.mjs +1 -1
  6. package/dist/adapters/s3.mjs +2 -2
  7. package/dist/{analysis-change-4GCRVRBW.mjs → analysis-change-5BQOQ4BF.mjs} +35 -28
  8. package/dist/{react-native/chunks/analysis-change-entry-TNLUC6IZ.mjs → analysis-change-entry-TXX6JSMX.mjs} +1 -1
  9. package/dist/archive-history-E4R73RWD.mjs +29 -0
  10. package/dist/browser/{analysis-change-IXWPXXJJ.mjs → analysis-change-435CUEPZ.mjs} +32 -12
  11. package/dist/{analysis-change-entry-KYGSXW4K.mjs → browser/analysis-change-entry-HZXKPPGV.mjs} +1 -1
  12. package/dist/browser/archive-history-4IP5XQZY.mjs +29 -0
  13. package/dist/browser/{chunk-4PD752F6.mjs → chunk-23XRXIBW.mjs} +1 -1
  14. package/dist/browser/{chunk-J433A7P3.mjs → chunk-2CFI5VVV.mjs} +5 -5
  15. package/dist/{react-native/chunks/chunk-3XKMRNRE.mjs → browser/chunk-2TI4SSUP.mjs} +27 -10
  16. package/dist/browser/chunk-3SSRJMFN.mjs +100 -0
  17. package/dist/browser/{chunk-2SHAKW2Z.mjs → chunk-3V7DNNZL.mjs} +515 -733
  18. package/dist/browser/{chunk-C4KS2QNF.mjs → chunk-4NGKC4H4.mjs} +9 -9
  19. package/dist/browser/{chunk-XRV72TJD.mjs → chunk-6LWDPLTB.mjs} +2 -2
  20. package/dist/browser/chunk-7IGKGWSQ.mjs +79 -0
  21. package/dist/browser/{chunk-VCOYGVP7.mjs → chunk-7U3WVJUP.mjs} +3 -3
  22. package/dist/browser/chunk-ATEBYXP6.mjs +10 -0
  23. package/dist/browser/chunk-BHFQATSC.mjs +432 -0
  24. package/dist/browser/chunk-CRE3G7F3.mjs +1007 -0
  25. package/dist/browser/{chunk-QXTPSX2H.mjs → chunk-EA63E3D2.mjs} +7 -7
  26. package/dist/{react-native/chunks/chunk-DCKMICOB.mjs → browser/chunk-EXQZGUQH.mjs} +1 -1
  27. package/dist/browser/{chunk-ML6HY7T7.mjs → chunk-G64Q6OJF.mjs} +1 -1
  28. package/dist/browser/chunk-GPPOG6PT.mjs +9 -0
  29. package/dist/browser/{chunk-EUNBNLKM.mjs → chunk-IZXVW2ZJ.mjs} +5 -5
  30. package/dist/browser/{chunk-G7LUMBSG.mjs → chunk-K4Q6KX3R.mjs} +30 -20
  31. package/dist/browser/{chunk-H6QFBMVE.mjs → chunk-KZWSX6BH.mjs} +3 -3
  32. package/dist/browser/chunk-M3MQE2X7.mjs +151 -0
  33. package/dist/browser/chunk-MGI4BCXC.mjs +63 -0
  34. package/dist/browser/chunk-MOG4OVDK.mjs +51 -0
  35. package/dist/browser/{chunk-W5X2UFWQ.mjs → chunk-NLWTBAGB.mjs} +12 -3
  36. package/dist/browser/{chunk-AYY6PIKL.mjs → chunk-NQAME3RK.mjs} +2 -2
  37. package/dist/browser/{chunk-7MEYN7V6.mjs → chunk-NXQG7DRA.mjs} +29 -14
  38. package/dist/browser/chunk-OEDCEZXJ.mjs +92 -0
  39. package/dist/{chunk-KUZKUONM.mjs → browser/chunk-SRMZXJSL.mjs} +1 -0
  40. package/dist/browser/chunk-SSTPBZZX.mjs +1106 -0
  41. package/dist/browser/{chunk-7TTWXUH6.mjs → chunk-STOWQFT3.mjs} +3 -2
  42. package/dist/browser/{chunk-26A5JFT2.mjs → chunk-TK63WFXK.mjs} +2 -1
  43. package/dist/browser/{chunk-SJB6VIZG.mjs → chunk-U3JOQGWX.mjs} +1 -1
  44. package/dist/browser/{chunk-AJ4HHOVT.mjs → chunk-U4YDIBUT.mjs} +4 -4
  45. package/dist/browser/{chunk-2FX6ROWR.mjs → chunk-VLJQW4J6.mjs} +2986 -2986
  46. package/dist/{react-native/chunks/chunk-3O57C2ZO.mjs → browser/chunk-WI4MR75E.mjs} +2 -2
  47. package/dist/browser/{chunk-3U3QR5YP.mjs → chunk-WN464PTL.mjs} +2 -2
  48. package/dist/browser/{chunk-U2E3HMYW.mjs → chunk-XAWNZ4G2.mjs} +11 -11
  49. package/dist/browser/{cold-module-VTUGDYNY.mjs → cold-module-2EHCIV4K.mjs} +20 -18
  50. package/dist/browser/durability-config-TIYKW6XX.mjs +89 -0
  51. package/dist/browser/{durability-wiring-GL4A7KDV.mjs → durability-wiring-A7BVG2DW.mjs} +50 -153
  52. package/dist/browser/engine-hooks-E4UD67JD.mjs +17 -0
  53. package/dist/browser/geo-index-HHWGMNIS.mjs +1386 -0
  54. package/dist/browser/import-DXYB6756.mjs +19 -0
  55. package/dist/browser/{methods-LMUTS7OI.mjs → methods-KTQCSIN4.mjs} +3 -3
  56. package/dist/browser/{module-M4JNBV6V.mjs → module-NIYMEA5R.mjs} +16 -14
  57. package/dist/browser/{module-EC3FYW7N.mjs → module-TCT66FWA.mjs} +10 -9
  58. package/dist/browser/operations-OJ3BXS55.mjs +5 -0
  59. package/dist/browser/{phrase-module-NPYUVX75.mjs → phrase-module-HAT3TLZN.mjs} +2 -2
  60. package/dist/browser/{pool-WCGDZHJP.mjs → pool-3JLET5RO.mjs} +1 -1
  61. package/dist/browser/restore-hooks-YPN4ZFCY.mjs +114 -0
  62. package/dist/browser/restore-queue-G3RQGL3Y.mjs +55 -0
  63. package/dist/browser/{retention-6QMRS5VK.mjs → retention-ZWVMNC3Q.mjs} +18 -15
  64. package/dist/browser/{runtime-3EW2AGB6.mjs → runtime-OTAGEFQW.mjs} +1 -1
  65. package/dist/browser/{snapshot-DN3CRVUQ.mjs → snapshot-VEQNIE6C.mjs} +71 -36
  66. package/dist/browser/start-BM442C6R.mjs +25 -0
  67. package/dist/browser/{write-WAWAFGKQ.mjs → write-2EVMZWDE.mjs} +16 -14
  68. package/dist/{capabilities-B3Brs1Rc.d.ts → capabilities-Da4ywVVl.d.ts} +35 -3
  69. package/dist/{chunk-K4B7OH65.mjs → chunk-25KDNIZZ.mjs} +2 -2
  70. package/dist/{chunk-O43Z4MS6.mjs → chunk-2NE7VCYE.mjs} +2 -2
  71. package/dist/chunk-2UV4QBHW.mjs +1092 -0
  72. package/dist/{chunk-3Y3J4V2R.mjs → chunk-3C7MTCCI.mjs} +1 -1
  73. package/dist/{chunk-TRISKD4Q.mjs → chunk-3HYC4JRF.mjs} +2 -2
  74. package/dist/{chunk-HVYICDY3.mjs → chunk-3OH67G7R.mjs} +1 -1
  75. package/dist/{chunk-PFKM7VNZ.mjs → chunk-46KY2PJD.mjs} +30 -11
  76. package/dist/{chunk-IJU7LL7D.mjs → chunk-4KKXNJM6.mjs} +5 -5
  77. package/dist/{chunk-IQ4R2I6N.mjs → chunk-5FLRXF73.mjs} +5 -1
  78. package/dist/{chunk-BPSKLCS7.mjs → chunk-5VV4R6P7.mjs} +3017 -3017
  79. package/dist/chunk-5YNRKI2C.mjs +81 -0
  80. package/dist/chunk-6HTGOXIK.mjs +875 -0
  81. package/dist/{chunk-7HCZWC7B.mjs → chunk-6I6AYAXS.mjs} +50 -8
  82. package/dist/{chunk-C6ASEFZI.mjs → chunk-6OEGXLBX.mjs} +1 -1
  83. package/dist/{chunk-DVWYODEB.mjs → chunk-6RC4K46J.mjs} +2 -2
  84. package/dist/chunk-7GFE3PEY.mjs +40 -0
  85. package/dist/{chunk-QKZHLADX.mjs → chunk-7LXHHCXZ.mjs} +28 -19
  86. package/dist/{chunk-JUKYYXSP.mjs → chunk-7V5IUP2T.mjs} +1 -31
  87. package/dist/{react-native/chunks/chunk-7GWPJDOA.mjs → chunk-A4L7YTKX.mjs} +53 -90
  88. package/dist/{chunk-Z3TNWCI5.mjs → chunk-BU4SAIC4.mjs} +3 -3
  89. package/dist/chunk-BWZ3P4MU.mjs +20 -0
  90. package/dist/{chunk-OKX2BBNW.mjs → chunk-CITFCZKF.mjs} +5 -4
  91. package/dist/{chunk-4HWZV5MK.mjs → chunk-CSLGFPFQ.mjs} +5 -5
  92. package/dist/chunk-DP5C7YFQ.mjs +543 -0
  93. package/dist/{chunk-RVKFI3A2.mjs → chunk-DWEPMFJE.mjs} +11 -8
  94. package/dist/{chunk-LSM2YTKM.mjs → chunk-EFBDHH5P.mjs} +87 -144
  95. package/dist/{chunk-NZMAXR2S.mjs → chunk-FAKFUDZZ.mjs} +121 -11
  96. package/dist/chunk-FB6463IN.mjs +1499 -0
  97. package/dist/{chunk-REL7LFLR.mjs → chunk-FCJ553HS.mjs} +3 -3
  98. package/dist/{chunk-MMEMEUOO.mjs → chunk-FJKKCV4D.mjs} +2 -2
  99. package/dist/{chunk-K7KLL263.mjs → chunk-FNGAM5B7.mjs} +14 -13
  100. package/dist/{chunk-DMQPFLGI.mjs → chunk-FRBFVQFN.mjs} +6 -5
  101. package/dist/{chunk-IBNLW3AV.mjs → chunk-FYOVBEMM.mjs} +20 -6
  102. package/dist/chunk-G6HRSGOU.mjs +74 -0
  103. package/dist/{chunk-USR7FQRZ.mjs → chunk-GH4WQ22V.mjs} +2 -2
  104. package/dist/chunk-GQPTDQCL.mjs +54 -0
  105. package/dist/{chunk-VREK3MYG.mjs → chunk-HFPMMRQT.mjs} +3 -3
  106. package/dist/{chunk-MLHNSAPK.mjs → chunk-HHBUCIUY.mjs} +3 -3
  107. package/dist/{chunk-YROWNOMH.mjs → chunk-HJJI72X7.mjs} +1 -1
  108. package/dist/{chunk-ECX4SGX6.mjs → chunk-I2KPOLOZ.mjs} +9 -9
  109. package/dist/{chunk-TV2L3BN7.mjs → chunk-I53G4JAU.mjs} +266 -265
  110. package/dist/{chunk-3A5KI24C.mjs → chunk-I54T6CQP.mjs} +1 -1
  111. package/dist/{chunk-NTZOXVUZ.mjs → chunk-I5B7RXU7.mjs} +93 -24
  112. package/dist/{chunk-YBJDOA2T.mjs → chunk-INJYO3BU.mjs} +1 -1
  113. package/dist/{react-native/chunks/chunk-KWRW5U65.mjs → chunk-J4IJTTEX.mjs} +1 -1
  114. package/dist/{chunk-X6NSJYQ3.mjs → chunk-JDJBQLRO.mjs} +13 -13
  115. package/dist/{chunk-MMBEANB2.mjs → chunk-JWRUUCWD.mjs} +3 -3
  116. package/dist/{chunk-AO2FAYIZ.mjs → chunk-K4ZIGL2O.mjs} +1 -1
  117. package/dist/{chunk-JFNKIBDT.mjs → chunk-K5QFDYST.mjs} +2 -2
  118. package/dist/{chunk-C73JLU4E.mjs → chunk-KF4EXSM4.mjs} +2 -2
  119. package/dist/{chunk-WCBA2LVZ.mjs → chunk-KHKIRS5D.mjs} +1 -1
  120. package/dist/{chunk-7QUGDVFC.mjs → chunk-KJ3RTZDJ.mjs} +1 -1
  121. package/dist/{chunk-HVKXNBFL.mjs → chunk-KKQC526K.mjs} +20 -12
  122. package/dist/chunk-KP7TYHWT.mjs +92 -0
  123. package/dist/{chunk-VMXSVVXG.mjs → chunk-L6V6BST3.mjs} +9 -22
  124. package/dist/{chunk-URPCYQVJ.mjs → chunk-LHKOSI2J.mjs} +1 -1
  125. package/dist/chunk-LNGE7SLY.mjs +151 -0
  126. package/dist/{react-native/chunks/chunk-CUNGPR5R.mjs → chunk-MP7ABPTD.mjs} +1 -0
  127. package/dist/{chunk-5KGYQT6W.mjs → chunk-MQOJIO5B.mjs} +26 -9
  128. package/dist/{chunk-Q3TCTQCC.mjs → chunk-NF4DT3IH.mjs} +1 -1
  129. package/dist/{chunk-3OFU3NJT.mjs → chunk-OIJ64LGT.mjs} +1 -1
  130. package/dist/chunk-ORN5BLL7.mjs +11 -0
  131. package/dist/{chunk-HWEDFLB7.mjs → chunk-P5ZI2P2W.mjs} +126 -1701
  132. package/dist/{chunk-466PYR4P.mjs → chunk-PWC4VB3Q.mjs} +2 -2
  133. package/dist/{chunk-B7S6YEBP.mjs → chunk-QJVOLKU6.mjs} +12 -3
  134. package/dist/{chunk-KCUIFVVW.mjs → chunk-QOW2JPUI.mjs} +9 -9
  135. package/dist/chunk-RDXO6JST.mjs +63 -0
  136. package/dist/chunk-RLOES5SX.mjs +31 -0
  137. package/dist/{chunk-YPUEV6ZC.mjs → chunk-RVGRFOGN.mjs} +1 -1
  138. package/dist/{chunk-JCLTESFN.mjs → chunk-RZWWB2XR.mjs} +1 -1
  139. package/dist/chunk-S5LN746F.mjs +10 -0
  140. package/dist/chunk-SA5LOGO3.mjs +470 -0
  141. package/dist/chunk-SQJWAIF4.mjs +12 -0
  142. package/dist/{chunk-YTJCGKM4.mjs → chunk-TBC3XUL2.mjs} +29 -6
  143. package/dist/chunk-TDIK6NTV.mjs +10 -0
  144. package/dist/chunk-TGS5UXBE.mjs +216 -0
  145. package/dist/{chunk-CP5RRPJR.mjs → chunk-TQXHPFWT.mjs} +1 -1
  146. package/dist/{chunk-7NTMUDC5.mjs → chunk-TZ3355VS.mjs} +5 -5
  147. package/dist/{chunk-Q7MS6P2J.mjs → chunk-TZTRKM33.mjs} +2 -2
  148. package/dist/{chunk-4UMZ7KQL.mjs → chunk-U55XJEIG.mjs} +2 -1
  149. package/dist/{chunk-S2N75OTN.mjs → chunk-UHICS3JI.mjs} +1 -1
  150. package/dist/{chunk-5FUOVJKG.mjs → chunk-VTTRFF2C.mjs} +32 -19
  151. package/dist/{chunk-62G63NMH.mjs → chunk-WX4LAO6M.mjs} +4 -4
  152. package/dist/{chunk-LTUGDMV4.mjs → chunk-WZ7YV54N.mjs} +1 -1
  153. package/dist/chunk-XAXKV65G.mjs +72 -0
  154. package/dist/chunk-XXHN7J46.mjs +101 -0
  155. package/dist/{chunk-PGVPE7GJ.mjs → chunk-YEKL4JBK.mjs} +1 -1
  156. package/dist/chunk-YTWZVGCB.mjs +382 -0
  157. package/dist/chunk-Z2KAFCRT.mjs +30 -0
  158. package/dist/{chunk-LKUE5GXS.mjs → chunk-ZKP7G7TV.mjs} +2 -2
  159. package/dist/{client-Df76GNKm.d.ts → client-DRv7UVeY.d.ts} +123 -11
  160. package/dist/client.d.ts +9 -8
  161. package/dist/client.mjs +65 -3
  162. package/dist/{cold-module-YLWMTTZG.mjs → cold-module-6MO2XJF2.mjs} +45 -39
  163. package/dist/{config-B8DP2VwR.d.ts → config-CoSig5Ox.d.ts} +22 -3
  164. package/dist/{config-05G_hy-1.d.ts → config-DMwffLKn.d.ts} +20 -5
  165. package/dist/direct-executor-FTMYY3TI.mjs +34 -0
  166. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  167. package/dist/distribution/coordinator/etcd.mjs +3 -3
  168. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  169. package/dist/distribution/coordinator/in-memory.mjs +2 -2
  170. package/dist/distribution/transport/grpc.mjs +4 -4
  171. package/dist/distribution/transport/in-memory.mjs +2 -2
  172. package/dist/distribution/transport/tcp.mjs +3 -3
  173. package/dist/distribution.d.ts +8 -8
  174. package/dist/distribution.mjs +6799 -5939
  175. package/dist/durability-config-GE4U7MCZ.mjs +89 -0
  176. package/dist/{durability-wiring-RHLXDIVF.mjs → durability-wiring-VIF5MOSY.mjs} +82 -179
  177. package/dist/embeddings/openai.mjs +2 -2
  178. package/dist/{sync-uXR7MmM7.d.ts → engine-CFxPYqEk.d.ts} +702 -2
  179. package/dist/engine-hooks-EGUGNZYE.mjs +54 -0
  180. package/dist/geo-index-MRH5JMIR.mjs +1387 -0
  181. package/dist/import-XKDPJQDP.mjs +56 -0
  182. package/dist/{index-nRqDM6uS.d.ts → index-C4AmUnl1.d.ts} +1 -1
  183. package/dist/index.browser.mjs +9 -7
  184. package/dist/index.d.ts +134 -9
  185. package/dist/index.mjs +33 -26
  186. package/dist/index.react-native.mjs +20 -17
  187. package/dist/invalidation/filesystem.mjs +2 -2
  188. package/dist/{long-query-thread-EMYTGSJP.mjs → long-query-thread-YA4IAYSY.mjs} +34 -28
  189. package/dist/{methods-ABM5ELBR.mjs → methods-7IOINERF.mjs} +3 -3
  190. package/dist/{module-MG7JMV2U.mjs → module-FQ4JWNQJ.mjs} +41 -34
  191. package/dist/{module-3OMJZUFT.mjs → module-N55W4Q5C.mjs} +14 -14
  192. package/dist/operations-G5EP6JPX.mjs +5 -0
  193. package/dist/{paged-partition-archive-UOLHOEZJ.mjs → paged-partition-archive-PXW5XAYU.mjs} +48 -38
  194. package/dist/partial-words.mjs +11 -9
  195. package/dist/pattern.mjs +6 -5
  196. package/dist/persistence/durability/checkpoint-worker.d.ts +8 -1
  197. package/dist/persistence/durability/checkpoint-worker.mjs +44 -35
  198. package/dist/{phrase-module-O3MDRQXP.mjs → phrase-module-XW5MKWP5.mjs} +4 -3
  199. package/dist/{pool-CQXYPFLG.mjs → pool-Y4A46T36.mjs} +1 -1
  200. package/dist/query-suggestions/merge-worker.d.ts +55 -0
  201. package/dist/query-suggestions/merge-worker.mjs +88 -0
  202. package/dist/query-suggestions-CBYkrQ5T.d.ts +311 -0
  203. package/dist/query-suggestions.browser.mjs +247 -0
  204. package/dist/query-suggestions.d.ts +20 -0
  205. package/dist/query-suggestions.mjs +69 -0
  206. package/dist/react-native/chunks/{analysis-change-EAYO3Y6Q.mjs → analysis-change-LT5QBQ3H.mjs} +43 -22
  207. package/dist/{browser/analysis-change-entry-FCSHFQSS.mjs → react-native/chunks/analysis-change-entry-SCVWK6OU.mjs} +1 -1
  208. package/dist/react-native/chunks/archive-history-MJKUQLSU.mjs +29 -0
  209. package/dist/{chunk-ZIFJXCKA.mjs → react-native/chunks/chunk-2PRHILX3.mjs} +54 -20
  210. package/dist/react-native/chunks/{chunk-VQSKZ3EZ.mjs → chunk-3JWDECAZ.mjs} +8 -8
  211. package/dist/{chunk-R6A773WK.mjs → react-native/chunks/chunk-3WI35N75.mjs} +1 -1
  212. package/dist/react-native/chunks/{chunk-75VWIY35.mjs → chunk-4DII3ZSM.mjs} +1 -1
  213. package/dist/react-native/chunks/{chunk-NKIZX26F.mjs → chunk-4J74WHQM.mjs} +2 -2
  214. package/dist/react-native/chunks/{chunk-UWDNZDWK.mjs → chunk-4JYO3JD2.mjs} +6 -6
  215. package/dist/react-native/chunks/chunk-5CQX3XXV.mjs +17 -0
  216. package/dist/react-native/chunks/chunk-6VBXNFLE.mjs +9 -0
  217. package/dist/react-native/chunks/{chunk-SJWDBRNP.mjs → chunk-6WA3C3DV.mjs} +1 -1
  218. package/dist/react-native/chunks/{chunk-OQQVRWZ2.mjs → chunk-C5G6TJ7A.mjs} +1 -1
  219. package/dist/react-native/chunks/{chunk-RVAEBN74.mjs → chunk-CKNRFDTZ.mjs} +1 -1
  220. package/dist/react-native/chunks/chunk-DIYDOIM4.mjs +10 -0
  221. package/dist/react-native/chunks/{chunk-O32RB3BL.mjs → chunk-DNXOMPAQ.mjs} +4 -4
  222. package/dist/react-native/chunks/{chunk-YBEW6YTR.mjs → chunk-DVDX4SDR.mjs} +2 -2
  223. package/dist/react-native/chunks/chunk-DXRSEWA2.mjs +12 -0
  224. package/dist/{browser/chunk-MYITLCHT.mjs → react-native/chunks/chunk-DZ7H7D2C.mjs} +1 -0
  225. package/dist/react-native/chunks/{chunk-PPEPTUVV.mjs → chunk-EJ33LCHV.mjs} +29 -6
  226. package/dist/react-native/chunks/{chunk-RYMDHGL4.mjs → chunk-ENLMYKSX.mjs} +3045 -3075
  227. package/dist/react-native/chunks/chunk-FHPW7P2O.mjs +40 -0
  228. package/dist/react-native/chunks/{chunk-JV6VQY2S.mjs → chunk-FTZHMRD2.mjs} +2 -1
  229. package/dist/react-native/chunks/{chunk-YHKZSLOC.mjs → chunk-G43IPIDG.mjs} +5 -5
  230. package/dist/react-native/chunks/{chunk-AUT7PMA4.mjs → chunk-GXX3DQXP.mjs} +8 -22
  231. package/dist/react-native/chunks/chunk-H3MDVPBO.mjs +151 -0
  232. package/dist/react-native/chunks/{chunk-DH3TVWWK.mjs → chunk-IYNT75CE.mjs} +12 -3
  233. package/dist/react-native/chunks/chunk-KV46CT4D.mjs +1007 -0
  234. package/dist/{browser/chunk-ZPTA75ZC.mjs → react-native/chunks/chunk-LZSLNSUN.mjs} +1 -1
  235. package/dist/react-native/chunks/{chunk-63YSZOXB.mjs → chunk-MIP4SOR6.mjs} +1480 -826
  236. package/dist/react-native/chunks/{chunk-ZBSWRSBG.mjs → chunk-MJDQU5MW.mjs} +1 -1
  237. package/dist/react-native/chunks/{chunk-GFYFQLJD.mjs → chunk-MUWD2H2S.mjs} +2 -2
  238. package/dist/react-native/chunks/{chunk-IOY2SM2P.mjs → chunk-MVXELMJX.mjs} +1 -1
  239. package/dist/{browser/chunk-TTD27VXX.mjs → react-native/chunks/chunk-NB3LP33V.mjs} +27 -10
  240. package/dist/react-native/chunks/{chunk-I5PGWQJF.mjs → chunk-PDRWWPKV.mjs} +33 -24
  241. package/dist/react-native/chunks/chunk-PJHAB5ZY.mjs +79 -0
  242. package/dist/react-native/chunks/{chunk-2CGSQM4O.mjs → chunk-POPDAGH6.mjs} +13 -13
  243. package/dist/react-native/chunks/{chunk-NP7DD4G5.mjs → chunk-QUKQNI3H.mjs} +5 -5
  244. package/dist/react-native/chunks/{chunk-EH5CFV6Z.mjs → chunk-RDWG33MM.mjs} +2 -2
  245. package/dist/react-native/chunks/{chunk-JX2RIAXH.mjs → chunk-SK2PWYDH.mjs} +5 -5
  246. package/dist/react-native/chunks/{chunk-ZYDKJXQJ.mjs → chunk-SUPXRTMD.mjs} +1 -1
  247. package/dist/react-native/chunks/chunk-TP6KCKER.mjs +63 -0
  248. package/dist/react-native/chunks/{chunk-JPAJWO6D.mjs → chunk-U4KSKA4Z.mjs} +1 -1
  249. package/dist/react-native/chunks/chunk-UQ4OAXKU.mjs +1106 -0
  250. package/dist/react-native/chunks/{chunk-VVFYOADG.mjs → chunk-VWUDIOT6.mjs} +6 -6
  251. package/dist/{browser/chunk-SIR3LMTV.mjs → react-native/chunks/chunk-WBYQRHDY.mjs} +2 -2
  252. package/dist/react-native/chunks/{chunk-C2H2QQFW.mjs → chunk-YH7QY657.mjs} +3 -3
  253. package/dist/react-native/chunks/{chunk-NCJS3WIY.mjs → chunk-YZW4CHM6.mjs} +51 -12
  254. package/dist/react-native/chunks/chunk-ZLWVW734.mjs +100 -0
  255. package/dist/react-native/chunks/chunk-ZXZFN7FI.mjs +432 -0
  256. package/dist/react-native/chunks/chunk-ZZT7CEN7.mjs +92 -0
  257. package/dist/react-native/chunks/{cold-module-TJL6AFAD.mjs → cold-module-KVZYUGRY.mjs} +31 -28
  258. package/dist/react-native/chunks/durability-config-QXVZEO7T.mjs +89 -0
  259. package/dist/react-native/chunks/{durability-wiring-RRDYJLLM.mjs → durability-wiring-34OYO32E.mjs} +60 -162
  260. package/dist/react-native/chunks/engine-hooks-M7JV46NH.mjs +30 -0
  261. package/dist/react-native/chunks/geo-index-PX3BIHAH.mjs +1387 -0
  262. package/dist/react-native/chunks/gzip.react-native-HLEPDKZ3.mjs +3 -0
  263. package/dist/react-native/chunks/import-H6AQREWI.mjs +32 -0
  264. package/dist/react-native/chunks/{methods-X6F36SJE.mjs → methods-6W5U4C3H.mjs} +3 -3
  265. package/dist/react-native/chunks/module-LBZPGOWH.mjs +36 -0
  266. package/dist/react-native/chunks/{module-S4DKSWMF.mjs → module-TTEVPRCW.mjs} +14 -13
  267. package/dist/react-native/chunks/operations-GNRMD6EX.mjs +5 -0
  268. package/dist/react-native/chunks/{phrase-module-JZ37TB7N.mjs → phrase-module-QK22HSQ2.mjs} +2 -2
  269. package/dist/react-native/chunks/{pool-RTGXJXPU.mjs → pool-JR3NJCAF.mjs} +1 -1
  270. package/dist/react-native/chunks/restore-hooks-IBGIY3DR.mjs +127 -0
  271. package/dist/react-native/chunks/restore-queue-ZZX54AH7.mjs +55 -0
  272. package/dist/react-native/chunks/{retention-PPCTP2VY.mjs → retention-EW4TTDFB.mjs} +29 -25
  273. package/dist/react-native/chunks/{runtime-KUATOLYB.mjs → runtime-R5E3TB3J.mjs} +1 -1
  274. package/dist/react-native/chunks/{snapshot-ZBIEOZTZ.mjs → snapshot-REYVIN3X.mjs} +80 -44
  275. package/dist/react-native/chunks/start-BQK6KN3R.mjs +38 -0
  276. package/dist/react-native/chunks/{write-2W4FTX7J.mjs → write-FQAYCZF5.mjs} +27 -24
  277. package/dist/react-native/partial-words.mjs +11 -9
  278. package/dist/react-native/pattern.mjs +4 -4
  279. package/dist/react-native/query-suggestions.mjs +260 -0
  280. package/dist/react-native/sync.mjs +78 -15
  281. package/dist/react-native/synonyms.mjs +95 -27
  282. package/dist/react.d.ts +11 -11
  283. package/dist/react.mjs +1 -0
  284. package/dist/{rerank-IZOB6NII.mjs → rerank-MQ37IYRV.mjs} +4 -4
  285. package/dist/rerankers/http.mjs +2 -2
  286. package/dist/restore-hooks-CDERDEF4.mjs +153 -0
  287. package/dist/restore-queue-7NNSTROA.mjs +55 -0
  288. package/dist/retention-QSVBBNRM.mjs +66 -0
  289. package/dist/{runtime-UZOC3NPY.mjs → runtime-COIUORCN.mjs} +5 -5
  290. package/dist/{schema-DDauvDOv.d.ts → schema-Jwt928nJ.d.ts} +1 -1
  291. package/dist/server.d.ts +108 -12
  292. package/dist/server.mjs +303 -50
  293. package/dist/{snapshot-NFX2EYN2.mjs → snapshot-RH4NSKIZ.mjs} +98 -61
  294. package/dist/start-MCKCOGIW.mjs +66 -0
  295. package/dist/sync/filesystem.d.ts +4 -4
  296. package/dist/sync/filesystem.mjs +6 -6
  297. package/dist/sync/indexeddb.d.ts +4 -4
  298. package/dist/sync/indexeddb.mjs +2 -2
  299. package/dist/sync.browser.mjs +74 -11
  300. package/dist/sync.d.ts +5 -5
  301. package/dist/sync.mjs +78 -16
  302. package/dist/synonyms.mjs +9 -8
  303. package/dist/{tasks-BShx8pdK.d.ts → tasks-qrJojgST.d.ts} +13 -5
  304. package/dist/thread-O4SBJJJS.mjs +50 -0
  305. package/dist/{types-SnO7_tAI.d.ts → types-BZCGjfLn.d.ts} +2 -3
  306. package/dist/vector/search-worker.d.ts +1 -1
  307. package/dist/vector/search-worker.mjs +8 -8
  308. package/dist/workers/entry.mjs +19 -8
  309. package/dist/{write-FGB62BHQ.mjs → write-3FK7NG3Y.mjs} +40 -33
  310. package/openapi.json +798 -7
  311. package/package.json +32 -8
  312. package/dist/browser/import-YI5GNB4H.mjs +0 -17
  313. package/dist/browser/operations-WVYLF72Q.mjs +0 -5
  314. package/dist/browser/restore-queue-TYIGDL5L.mjs +0 -41
  315. package/dist/chunk-37IVJLP6.mjs +0 -44
  316. package/dist/chunk-DJHHF2L5.mjs +0 -17
  317. package/dist/direct-executor-FI5GJHWX.mjs +0 -29
  318. package/dist/engine-DYu-e0oR.d.ts +0 -674
  319. package/dist/import-SRBNC6TE.mjs +0 -49
  320. package/dist/operations-PGOAY2KS.mjs +0 -5
  321. package/dist/react-native/chunks/chunk-TJMSKBEM.mjs +0 -25
  322. package/dist/react-native/chunks/gzip.react-native-DNB5YNFA.mjs +0 -3
  323. package/dist/react-native/chunks/import-JYBMEJPQ.mjs +0 -29
  324. package/dist/react-native/chunks/module-QT5HZAY4.mjs +0 -33
  325. package/dist/react-native/chunks/operations-RYKTSZQA.mjs +0 -5
  326. package/dist/react-native/chunks/restore-queue-ZBVIKJWI.mjs +0 -41
  327. package/dist/restore-queue-COI2GSSK.mjs +0 -41
  328. package/dist/retention-55WA7GPU.mjs +0 -58
  329. package/dist/thread-P2G2FWM2.mjs +0 -44
@@ -1,15 +1,16 @@
1
+ import { emitSyncChange, withOpenIndex, oneAtATime } from './chunk-ML7THVLJ.mjs';
1
2
  import { createRequestId, isValidWorkerResponse } from './chunk-VI7BQR4U.mjs';
2
3
  import { DEFAULT_MAX_RERANK_WINDOW, DEFAULT_RERANK_TIMEOUT_MS } from './chunk-JPTQZWJQ.mjs';
3
- import { parsedTypeOf, flattenSchema, isSingleStringFieldType, partialFieldsOf, resolveIndexAnalysis, schemaFieldsOf, isWordIndexedBase, MIN_PATTERN_VALUE_LIMIT, MAX_PATTERN_VALUE_LIMIT, requireWithinFileLimit, HEADER_SIZE, payloadByteLength, checksumOfChunks, packEnvelopeWithEngineVersion, INDEX_CONFIGURATION_ENVELOPE_VERSION, DEFAULT_PATTERN_VALUE_LIMIT, MAX_DOCUMENT_NESTING_DEPTH, PROTOTYPE_POLLUTION_KEYS, encodeDocument, isPlainObject, MAX_NESTING_DEPTH, getLanguage, validateSchema, extractVectorFieldsFromSchema, readHeapStatistics, requireCreatableSchema, VECTOR_PATTERN, parseFieldType, isStringValuedBase, withSortableOption, isGeopointOrVectorType, isWordIndexedFieldType, isListBase, MAX_DOCUMENT_BYTES } from './chunk-7TTWXUH6.mjs';
4
+ import { parsedTypeOf, flattenSchema, isSingleStringFieldType, partialFieldsOf, resolveIndexAnalysis, schemaFieldsOf, isWordIndexedBase, MIN_PATTERN_VALUE_LIMIT, MAX_PATTERN_VALUE_LIMIT, requireWithinFileLimit, HEADER_SIZE, payloadByteLength, checksumOfChunks, packEnvelopeWithEngineVersion, INDEX_CONFIGURATION_ENVELOPE_VERSION, validateSchema, requireCreatableSchema, getLanguage, DEFAULT_PATTERN_VALUE_LIMIT, MAX_DOCUMENT_NESTING_DEPTH, PROTOTYPE_POLLUTION_KEYS, encodeDocument, extractVectorFieldsFromSchema, isPlainObject, isWordIndexedFieldType, readHeapStatistics, VECTOR_PATTERN, parseFieldType, isStringValuedBase, MAX_NESTING_DEPTH, withSortableOption, isGeopointOrVectorType, isListBase, MAX_DOCUMENT_BYTES } from './chunk-STOWQFT3.mjs';
4
5
  import { fnv1a, FNV_OFFSET_BASIS, fnv1aContinue, fnv1aContinueTaggedNumbers } from './chunk-RA6LSBCM.mjs';
5
- import { TARGET_BLOCK_ENTRIES, bitsetHas, createBitSet, LOOKUP_KEY_SCRATCH_BYTES, GrowableUint32, SEGMENT_TOKEN_TABLE_START, SEGMENT_POSTING_LOG_START, SEGMENT_POSITION_POOL_START, SEGMENT_FIELD_SCRATCH_START, bitsetIsEmpty, bitsetSet, SCORE_BUFFER_INITIAL_TOUCHED_CAPACITY, PRUNING_REJECTION_SLACK, bitsetOrInto, bitsetAndNotInto, bitsetAndInto, SORT_COLUMN_MINIMUM_REBUILD_THRESHOLD, SORT_COLUMN_REBUILD_FRACTION_SHIFT, bitsetFromSet } from './chunk-26A5JFT2.mjs';
6
- import { createDocIdMap, detectRuntime, resolveWorkerEntry, missingWorkerEntry, countWrite, turnIsSpent, yieldTurn, MIN_OVERSAMPLE, noteThreadSlotGone, threadSlotOfWorker, turnsAreBudgeted, indexChangeOutsideExternalWaits, changeIndexOutsideExternalWaits } from './chunk-U2E3HMYW.mjs';
7
- import { splitWorkerBudget, resolveWorkerCount, DEFAULT_REQUEST_TIMEOUT_MS, resolveRequestThreadCount, MAX_RENUMBERED_SEARCH_ATTEMPTS, SHUTDOWN_TIMEOUT_MS, DEFAULT_BACKPRESSURE_LIMIT, CONSECUTIVE_TIMEOUTS_BEFORE_DEATH } from './chunk-TY7L6OXO.mjs';
8
- import { MAX_INDEX_CONFIGURATION_BYTES, ABSOLUTE_WINDOWS_PATH_PATTERN, MODULE_URL_SCHEME_PATTERN, MAX_SWEEP_INTERVAL_MS, MIN_SWEEP_INTERVAL_MS, STATISTICS_BROADCAST_INTERVAL_MS, MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN, HEAP_PRESSURE_WARNING_FRACTION, MAX_SUGGEST_LIMIT, FOREIGN_STATS_TTL_MS, DEFAULT_SUGGEST_LIMIT, DEFAULT_LIMIT, DEFAULT_OFFSET, MIN_DOCUMENTS_FOR_SEGMENTS, HEAP_PRESSURE_REARM_FRACTION, BATCH_CHUNK_SIZE, MAX_DOC_ID_LENGTH } from './chunk-4RD3AFSB.mjs';
9
- import { singleFoldTable, appendFoldedCodePoint, EARLIER_RELEASE_MIN_M, MIN_M, MAX_M, compareCodePoints, toReducedSortValue, compareComparableValues, defaultSortMode, MAX_FILE_BYTES, holdsUnpairedSurrogate, readSortField, truncateSortString, exceedsCodePoints, toComparableSortValue, SORT_VALUE_MAX_CODE_POINTS, compareComparableKeys, sortModeOf, isSortMode, SORT_MODES, compareSortValues, codePointCount } from './chunk-7MEYN7V6.mjs';
10
- import { DEFAULT_FUZZY_PREFIX_LENGTH, MAX_CURSOR_LENGTH, MAX_CURSOR_ANCHOR_CODE_POINTS, MAX_SORT_FIELDS, MAX_SORT_FIELD_NAME_LENGTH, BM25_DISPLAYED_NAME_LENGTH, RESULT_WINDOW, DEFAULT_LINEAR_ALPHA, MIN_LINEAR_ALPHA, MAX_LINEAR_ALPHA, DEFAULT_RANK_CONSTANT, MIN_RANK_CONSTANT, DEFAULT_PAGE_SIZE, DEFAULT_MAX_PER_GROUP, PREFIX_MAX_EXPANSIONS, MAX_TOLERANCE, MAX_PREFIX_LENGTH } from './chunk-WXLBZJMT.mjs';
11
- import { emitSyncChange, withOpenIndex, oneAtATime } from './chunk-ML7THVLJ.mjs';
12
- import { ErrorCodes, NarsilError, createNarsilError } from './chunk-MYITLCHT.mjs';
6
+ import { MAX_LATITUDE_DEGREES, MAX_LONGITUDE_DEGREES, MIN_POLYGON_POINTS, highWord, SMALLEST_NORMAL_HIGH_WORD, MAGNITUDE_MASK, lowWord, INFINITE_HIGH_WORD, withHighWord } from './chunk-MOG4OVDK.mjs';
7
+ import { TARGET_BLOCK_ENTRIES, bitsetHas, createBitSet, LOOKUP_KEY_SCRATCH_BYTES, GrowableUint32, SEGMENT_TOKEN_TABLE_START, SEGMENT_POSTING_LOG_START, SEGMENT_POSITION_POOL_START, SEGMENT_FIELD_SCRATCH_START, bitsetIsEmpty, bitsetSet, SCORE_BUFFER_INITIAL_TOUCHED_CAPACITY, PRUNING_REJECTION_SLACK, bitsetOrInto, bitsetAndNotInto, FIELD_RUN_ENTRIES_START, bitsetAndInto, SORT_COLUMN_MINIMUM_REBUILD_THRESHOLD, SORT_COLUMN_REBUILD_FRACTION_SHIFT, bitsetFromSet } from './chunk-TK63WFXK.mjs';
8
+ import { createDocIdMap, turnsAreBudgeted, turnIsSpent, yieldTurn, indexChangeOutsideExternalWaits, changeIndexOutsideExternalWaits, detectRuntime, resolveWorkerEntry, missingWorkerEntry, countWrite, MIN_OVERSAMPLE, noteThreadSlotGone, threadSlotOfWorker } from './chunk-XAWNZ4G2.mjs';
9
+ import { splitWorkerBudget, resolveWorkerCount, resolveRequestThreadCount, DEFAULT_REQUEST_TIMEOUT_MS, MAX_RENUMBERED_SEARCH_ATTEMPTS, SHUTDOWN_TIMEOUT_MS, DEFAULT_BACKPRESSURE_LIMIT, CONSECUTIVE_TIMEOUTS_BEFORE_DEATH } from './chunk-TY7L6OXO.mjs';
10
+ import { MAX_INDEX_CONFIGURATION_BYTES, BATCH_CHUNK_SIZE, MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN, MAX_DOC_ID_LENGTH, ABSOLUTE_WINDOWS_PATH_PATTERN, MODULE_URL_SCHEME_PATTERN, MAX_SWEEP_INTERVAL_MS, MIN_SWEEP_INTERVAL_MS, STATISTICS_BROADCAST_INTERVAL_MS, HEAP_PRESSURE_WARNING_FRACTION, MAX_SUGGEST_LIMIT, FOREIGN_STATS_TTL_MS, DEFAULT_SUGGEST_LIMIT, DEFAULT_LIMIT, DEFAULT_OFFSET, MIN_DOCUMENTS_FOR_SEGMENTS, HEAP_PRESSURE_REARM_FRACTION } from './chunk-4RD3AFSB.mjs';
11
+ import { singleFoldTable, appendFoldedCodePoint, EARLIER_RELEASE_MIN_M, MIN_M, MAX_M, compareCodePoints, toReducedSortValue, compareComparableValues, defaultSortMode, withUnpairedSurrogatesReplaced, holdsUnpairedSurrogate, readSortField, truncateSortString, exceedsCodePoints, toComparableSortValue, SORT_VALUE_MAX_CODE_POINTS, compareComparableKeys, sortModeOf, isSortMode, SORT_MODES, compareSortValues, codePointCount } from './chunk-NXQG7DRA.mjs';
12
+ import { BM25_DISPLAYED_NAME_LENGTH, DEFAULT_FUZZY_PREFIX_LENGTH, MAX_CURSOR_LENGTH, MAX_CURSOR_ANCHOR_CODE_POINTS, MAX_SORT_FIELDS, MAX_SORT_FIELD_NAME_LENGTH, RESULT_WINDOW, DEFAULT_LINEAR_ALPHA, MIN_LINEAR_ALPHA, MAX_LINEAR_ALPHA, DEFAULT_RANK_CONSTANT, MIN_RANK_CONSTANT, DEFAULT_PAGE_SIZE, DEFAULT_MAX_PER_GROUP, PREFIX_MAX_EXPANSIONS, MAX_TOLERANCE, MAX_PREFIX_LENGTH } from './chunk-WXLBZJMT.mjs';
13
+ import { ErrorCodes, NarsilError, createNarsilError } from './chunk-SRMZXJSL.mjs';
13
14
  import { Decoder, decode, encode } from '@msgpack/msgpack';
14
15
 
15
16
  // src/core/partition/partial-words/platform.browser.ts
@@ -215,6 +216,7 @@ var SMALL_DEVICE_TOKEN_CACHE_ENTRIES = 1e5;
215
216
  var MEDIUM_DEVICE_TOKEN_CACHE_ENTRIES = 25e4;
216
217
  var LARGE_DEVICE_TOKEN_CACHE_ENTRIES = 5e5;
217
218
  var DEFAULT_MIN_TOKEN_LENGTH = 1;
219
+ var DEFAULT_SPLIT_PATTERN = /[^\p{L}\p{M}\p{N}_'-]+/u;
218
220
 
219
221
  // src/core/tokenizer/normalize.ts
220
222
  var DOTTED_CAPITAL_I = "\u0130";
@@ -356,21 +358,21 @@ function evictOldestEntries(count) {
356
358
  }
357
359
  }
358
360
  }
361
+ function transformInTypeScript(raw, language, stem, removeDiacritics) {
362
+ let normalized = raw;
363
+ if (language.normalizer) normalized = language.normalizer(normalized);
364
+ if (removeDiacritics) normalized = stripDiacritics(normalized);
365
+ if (stem && language.stemmer) normalized = language.stemmer(normalized);
366
+ return normalized;
367
+ }
359
368
  function transformToken(raw, language, stem, removeDiacritics) {
360
369
  const flags = (stem ? "s" : "") + (removeDiacritics ? "d" : "");
361
370
  let bucket = getCacheBucket(language, flags);
362
371
  const cached = bucket.get(raw);
363
372
  if (cached !== void 0) return cached;
364
- let normalized = raw;
365
- if (language.normalizer) {
366
- normalized = language.normalizer(normalized);
367
- }
368
- if (removeDiacritics) {
369
- normalized = stripDiacritics(normalized);
370
- }
371
- if (stem && language.stemmer) {
372
- normalized = language.stemmer(normalized);
373
- }
373
+ const normalized = withUnpairedSurrogatesReplaced(
374
+ transformInTypeScript(raw, language, stem, removeDiacritics)
375
+ );
374
376
  if (normalizationCacheSize >= maxCacheSize) {
375
377
  evictOldestEntries(Math.max(1, maxCacheSize >>> 2));
376
378
  bucket = getCacheBucket(language, flags);
@@ -532,7 +534,6 @@ function producesSurfaceForms(language, options) {
532
534
  if (!options?.collectSurfaces || options.customTokenizer) return false;
533
535
  return (options.stem ?? true) && language.stemmer !== null;
534
536
  }
535
- var DEFAULT_SPLIT_PATTERN = /[^\p{L}\p{M}\p{N}_'-]+/u;
536
537
  function resolveStopWords(language, override) {
537
538
  if (!override) return language.stopWords;
538
539
  if (override instanceof Set) return override;
@@ -562,6 +563,18 @@ function stripPossessive(token) {
562
563
  }
563
564
  return token;
564
565
  }
566
+ function customTokensOf(tokenizer, text) {
567
+ const entries = tokenizer.tokenize(text);
568
+ let repaired = null;
569
+ for (let at = 0; at < entries.length; at++) {
570
+ const entry = entries[at];
571
+ const token = withUnpairedSurrogatesReplaced(entry.token);
572
+ if (token === entry.token) continue;
573
+ repaired ??= entries.slice();
574
+ repaired[at] = { token, position: entry.position };
575
+ }
576
+ return repaired ?? entries;
577
+ }
565
578
  function visitTokens(text, language, options, visit) {
566
579
  const {
567
580
  stem = true,
@@ -572,7 +585,9 @@ function visitTokens(text, language, options, visit) {
572
585
  stopWordOverride
573
586
  } = options ?? {};
574
587
  if (customTokenizer) {
575
- for (const entry of customTokenizer.tokenize(text)) visit(entry.token, entry.position, void 0, entry.token);
588
+ for (const entry of customTokensOf(customTokenizer, text)) {
589
+ visit(entry.token, entry.position, void 0, entry.token);
590
+ }
576
591
  return;
577
592
  }
578
593
  const rawParts = splitText(normalizeForSplitting(text), language);
@@ -591,10 +606,15 @@ function visitTokens(text, language, options, visit) {
591
606
  visit(processed, position, void 0, part);
592
607
  continue;
593
608
  }
594
- const surface = effectiveDiacritics ? transformToken(candidate, language, false, true) : candidate;
595
- visit(processed, position, surface === processed ? void 0 : surface, part);
609
+ const shown = effectiveDiacritics ? transformToken(candidate, language, false, true) : candidate;
610
+ visit(processed, position, surfaceOf(shown, processed), part);
596
611
  }
597
612
  }
613
+ function surfaceOf(shown, term) {
614
+ if (shown === term) return void 0;
615
+ const surface = withUnpairedSurrogatesReplaced(shown);
616
+ return surface === term ? void 0 : surface;
617
+ }
598
618
  function visitSurfaceSpellings(text, language, visit) {
599
619
  const rawParts = splitText(normalizeForSplitting(text), language);
600
620
  const minLength = language.tokenizer?.minTokenLength ?? DEFAULT_MIN_TOKEN_LENGTH;
@@ -603,12 +623,14 @@ function visitSurfaceSpellings(text, language, visit) {
603
623
  for (const part of rawParts) {
604
624
  const candidate = stripPossessives ? stripPossessive(part) : part;
605
625
  if (candidate.length < minLength) continue;
606
- visit(removeDiacritics ? transformToken(candidate, language, false, true) : candidate);
626
+ visit(
627
+ removeDiacritics ? transformToken(candidate, language, false, true) : withUnpairedSurrogatesReplaced(candidate)
628
+ );
607
629
  }
608
630
  }
609
631
  function tokenize(text, language, options) {
610
632
  if (options?.customTokenizer) {
611
- const customResult = options.customTokenizer.tokenize(text);
633
+ const customResult = customTokensOf(options.customTokenizer, text);
612
634
  return { tokens: customResult, originalTokens: customResult.map((entry) => entry.token) };
613
635
  }
614
636
  const tokens = [];
@@ -646,7 +668,8 @@ var NARSIL_CONFIG_KEYS = {
646
668
  lifecycle: true,
647
669
  patternWorkCap: true,
648
670
  events: true,
649
- memory: true
671
+ memory: true,
672
+ querySuggestions: true
650
673
  };
651
674
  var EVENT_NAMES = {
652
675
  write: true,
@@ -660,7 +683,9 @@ var EVENT_NAMES = {
660
683
  layoutUpgrade: true,
661
684
  checkpointHeld: true,
662
685
  durabilityError: true,
663
- invalidationError: true
686
+ invalidationError: true,
687
+ querySuggestionsBuild: true,
688
+ querySuggestionsWarning: true
664
689
  };
665
690
  var DURABILITY_CONFIG_KEYS = {
666
691
  tier: true,
@@ -909,21 +934,6 @@ function registerEngineRerankAdapter(core, name, adapter) {
909
934
  core.rerankAdapters.set(name, adapter);
910
935
  }
911
936
 
912
- // src/geo/constants.ts
913
- var DEG_TO_RAD = Math.PI / 180;
914
- var MAX_LATITUDE_DEGREES = 90;
915
- var MAX_LONGITUDE_DEGREES = 180;
916
- var MIN_POLYGON_POINTS = 3;
917
- var ANTIMERIDIAN_SPAN_DEGREES = 180;
918
- var FULL_TURN_DEGREES = 360;
919
- var EARTH_RADIUS_METERS = 63710088e-1;
920
- var LOCATION_CODE_BITS_PER_AXIS = 26;
921
- var MAX_COVERING_CELLS = 16;
922
- var RADIUS_BOX_MARGIN_RATIO = 1.02;
923
- var RADIUS_BOX_MARGIN_RADIANS = 1e-9;
924
- var VINCENTY_MAX_ITERATIONS = 200;
925
- var VINCENTY_CONVERGENCE_THRESHOLD = 1e-12;
926
-
927
937
  // src/geo/coordinates.ts
928
938
  function isLatitude(value) {
929
939
  return value >= -MAX_LATITUDE_DEGREES && value <= MAX_LATITUDE_DEGREES;
@@ -1585,6 +1595,11 @@ function getFlatSchema(state, schema) {
1585
1595
  return state.flatSchemaCache;
1586
1596
  }
1587
1597
 
1598
+ // src/core/document-copy.browser.ts
1599
+ function copyStoredValue(value) {
1600
+ return structuredClone(value);
1601
+ }
1602
+
1588
1603
  // src/core/projection.ts
1589
1604
  function requireFieldPathList(paths, option) {
1590
1605
  if (paths === void 0) return;
@@ -1658,8 +1673,8 @@ function writePath(target, path, value) {
1658
1673
  }
1659
1674
  function cloneExcept(value, path, exclude) {
1660
1675
  const reachesDeeper = exclude.some((excluded) => excluded.length > path.length && covers(path, excluded));
1661
- if (!reachesDeeper) return structuredClone(value);
1662
- if (typeof value !== "object" || value === null || Array.isArray(value)) return structuredClone(value);
1676
+ if (!reachesDeeper) return copyStoredValue(value);
1677
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return copyStoredValue(value);
1663
1678
  const source = value;
1664
1679
  const kept = {};
1665
1680
  for (const key of Object.keys(source)) {
@@ -1698,7 +1713,7 @@ function projectionKeepsField(projection, fieldPath) {
1698
1713
  return !projection.exclude.some((excluded) => covers(excluded, path));
1699
1714
  }
1700
1715
  function cloneProjected(document, projection) {
1701
- if (projection === void 0 || projection.kind === "full") return structuredClone(document);
1716
+ if (projection === void 0 || projection.kind === "full") return copyStoredValue(document);
1702
1717
  if (projection.kind === "none") return {};
1703
1718
  if (projection.include === null) return cloneExcept(document, [], projection.exclude);
1704
1719
  return projectIncludedPaths(projection.include, projection.exclude, (path) => readProjectedPath(document, path));
@@ -2522,7 +2537,7 @@ var LivePostings = class {
2522
2537
  terms = new TermColumns(TERM_TABLE_START_CAPACITY);
2523
2538
  pool = new PostingPool(POSTING_POOL_START_ENTRIES);
2524
2539
  positions = new PositionPool(POSITION_POOL_START_VALUES);
2525
- retired = new Uint8Array(RETIRED_DOCUMENTS_START_CAPACITY);
2540
+ retired = new Uint32Array(RETIRED_DOCUMENTS_START_CAPACITY >>> 5);
2526
2541
  batchMode = false;
2527
2542
  dirty = /* @__PURE__ */ new Set();
2528
2543
  cachedViews = /* @__PURE__ */ new Map();
@@ -2609,7 +2624,7 @@ var LivePostings = class {
2609
2624
  this.repackIfSparse();
2610
2625
  }
2611
2626
  isRetired(internalId) {
2612
- return internalId < this.retired.length && this.retired[internalId] === 1;
2627
+ return bitsetHas(this.retired, internalId);
2613
2628
  }
2614
2629
  beginBatch() {
2615
2630
  this.batchMode = true;
@@ -2633,7 +2648,7 @@ var LivePostings = class {
2633
2648
  this.pool = new PostingPool(POSTING_POOL_START_ENTRIES);
2634
2649
  this.pool.epoch = epoch;
2635
2650
  this.positions = new PositionPool(POSITION_POOL_START_VALUES);
2636
- this.retired = new Uint8Array(RETIRED_DOCUMENTS_START_CAPACITY);
2651
+ this.retired = new Uint32Array(RETIRED_DOCUMENTS_START_CAPACITY >>> 5);
2637
2652
  this.dirty.clear();
2638
2653
  this.cachedViews.clear();
2639
2654
  this.compactedSlack = 0;
@@ -2642,12 +2657,13 @@ var LivePostings = class {
2642
2657
  return this.terms.byteLength() + this.pool.byteLength() + this.positions.values.byteLength + this.retired.byteLength;
2643
2658
  }
2644
2659
  retire(internalId) {
2645
- if (internalId >= this.retired.length) {
2646
- const grown = new Uint8Array(Math.max(internalId + 1, this.retired.length * 2));
2660
+ const word = internalId >>> 5;
2661
+ if (word >= this.retired.length) {
2662
+ const grown = new Uint32Array(Math.max(word + 1, this.retired.length * 2));
2647
2663
  grown.set(this.retired);
2648
2664
  this.retired = grown;
2649
2665
  }
2650
- this.retired[internalId] = 1;
2666
+ bitsetSet(this.retired, internalId);
2651
2667
  }
2652
2668
  purgeRetired() {
2653
2669
  const terms = this.terms;
@@ -2659,7 +2675,7 @@ var LivePostings = class {
2659
2675
  compact(ordinal) {
2660
2676
  if (this.terms.deadDocuments[ordinal] === 0) return;
2661
2677
  const retired = this.retired;
2662
- this.filterEntries(ordinal, (id) => id < retired.length && retired[id] === 1);
2678
+ this.filterEntries(ordinal, (id) => bitsetHas(retired, id));
2663
2679
  this.terms.deadDocuments[ordinal] = 0;
2664
2680
  }
2665
2681
  filterEntries(ordinal, drop) {
@@ -2879,6 +2895,7 @@ function createInvertedIndex(fieldNameTable) {
2879
2895
  return entries;
2880
2896
  }
2881
2897
  return {
2898
+ livePostings: postings,
2882
2899
  insert(token, internalId, termFrequency, fieldNameIndex2, positions) {
2883
2900
  postings.insert(token, internalId, termFrequency, fieldNameIndex2, positions);
2884
2901
  },
@@ -3384,420 +3401,54 @@ function patternIndexOf(indexes, fieldPath) {
3384
3401
  return index;
3385
3402
  }
3386
3403
 
3387
- // src/geo/cells.ts
3388
- var AXIS_CELLS = 2 ** LOCATION_CODE_BITS_PER_AXIS;
3389
- function axisCell(value, lowest, span) {
3390
- const cell = Math.floor((value - lowest) / span * AXIS_CELLS);
3391
- if (!(cell > 0)) return 0;
3392
- return cell >= AXIS_CELLS ? AXIS_CELLS - 1 : cell;
3393
- }
3394
- function latitudeCell(lat) {
3395
- return axisCell(lat, -MAX_LATITUDE_DEGREES, 2 * MAX_LATITUDE_DEGREES);
3396
- }
3397
- function longitudeCell(lon) {
3398
- return axisCell(lon, -MAX_LONGITUDE_DEGREES, FULL_TURN_DEGREES);
3399
- }
3400
- function interleave(row, column, bits) {
3401
- let code = 0;
3402
- for (let bit = bits - 1; bit >= 0; bit--) code = code * 4 + (row >>> bit & 1) * 2 + (column >>> bit & 1);
3403
- return code;
3404
- }
3405
- function locationCode(lat, lon) {
3406
- return interleave(latitudeCell(lat), longitudeCell(lon), LOCATION_CODE_BITS_PER_AXIS);
3407
- }
3408
- function appendBoxRanges(box, out) {
3409
- const south = latitudeCell(box.south);
3410
- const north = latitudeCell(box.north);
3411
- const west = longitudeCell(box.west);
3412
- const east = longitudeCell(box.east);
3413
- let level = LOCATION_CODE_BITS_PER_AXIS;
3414
- while (level > 0) {
3415
- const shift2 = LOCATION_CODE_BITS_PER_AXIS - level;
3416
- const rows = (north >>> shift2) - (south >>> shift2) + 1;
3417
- const columns = (east >>> shift2) - (west >>> shift2) + 1;
3418
- if (rows * columns <= MAX_COVERING_CELLS) break;
3419
- level--;
3420
- }
3421
- const shift = LOCATION_CODE_BITS_PER_AXIS - level;
3422
- const codesPerCell = 4 ** shift;
3423
- for (let row = south >>> shift; row <= north >>> shift; row++) {
3424
- for (let column = west >>> shift; column <= east >>> shift; column++) {
3425
- const from = interleave(row, column, level) * codesPerCell;
3426
- out.push({ from, to: from + codesPerCell });
3427
- }
3428
- }
3429
- }
3430
- function coveringRanges(boxes) {
3431
- const ranges = [];
3432
- for (const box of boxes) appendBoxRanges(box, ranges);
3433
- ranges.sort((left, right) => left.from - right.from);
3434
- const merged = [];
3435
- for (const range of ranges) {
3436
- const last = merged[merged.length - 1];
3437
- if (last !== void 0 && range.from <= last.to) {
3438
- if (range.to > last.to) last.to = range.to;
3439
- } else {
3440
- merged.push({ from: range.from, to: range.to });
3441
- }
3442
- }
3443
- return merged;
3444
- }
3445
- function longitudeBoxes(south, north, west, east) {
3446
- if (east - west >= FULL_TURN_DEGREES) {
3447
- return [{ south, north, west: -MAX_LONGITUDE_DEGREES, east: MAX_LONGITUDE_DEGREES }];
3448
- }
3449
- if (west < -MAX_LONGITUDE_DEGREES) {
3450
- return [
3451
- { south, north, west: west + FULL_TURN_DEGREES, east: MAX_LONGITUDE_DEGREES },
3452
- { south, north, west: -MAX_LONGITUDE_DEGREES, east }
3453
- ];
3454
- }
3455
- if (east > MAX_LONGITUDE_DEGREES) {
3456
- return [
3457
- { south, north, west, east: MAX_LONGITUDE_DEGREES },
3458
- { south, north, west: -MAX_LONGITUDE_DEGREES, east: east - FULL_TURN_DEGREES }
3459
- ];
3460
- }
3461
- return [{ south, north, west, east }];
3462
- }
3463
- function radiusBoxes(lat, lon, distanceMeters) {
3464
- const angle = distanceMeters / EARTH_RADIUS_METERS * RADIUS_BOX_MARGIN_RATIO + RADIUS_BOX_MARGIN_RADIANS;
3465
- const angleDegrees = angle / DEG_TO_RAD;
3466
- const south = lat - angleDegrees;
3467
- const north = lat + angleDegrees;
3468
- if (angle >= Math.PI || south <= -MAX_LATITUDE_DEGREES || north >= MAX_LATITUDE_DEGREES) {
3469
- return [
3470
- {
3471
- south: Math.max(south, -MAX_LATITUDE_DEGREES),
3472
- north: Math.min(north, MAX_LATITUDE_DEGREES),
3473
- west: -MAX_LONGITUDE_DEGREES,
3474
- east: MAX_LONGITUDE_DEGREES
3475
- }
3476
- ];
3404
+ // src/schema/declared-types.ts
3405
+ function mayDeclare(schema, typeName, depth) {
3406
+ if (!isPlainObject(schema) || depth > MAX_NESTING_DEPTH + 1) return false;
3407
+ for (const type of Object.values(schema)) {
3408
+ if (typeof type === "string" ? type.includes(typeName) : mayDeclare(type, typeName, depth + 1)) return true;
3477
3409
  }
3478
- const spread = Math.asin(Math.sin(angle) / Math.cos(lat * DEG_TO_RAD)) / DEG_TO_RAD;
3479
- return longitudeBoxes(south, north, lon - spread, lon + spread);
3480
- }
3481
-
3482
- // src/geo/haversine.ts
3483
- function haversineDistance(lat1, lon1, lat2, lon2) {
3484
- const phi1 = lat1 * DEG_TO_RAD;
3485
- const phi2 = lat2 * DEG_TO_RAD;
3486
- const deltaPhi = (lat2 - lat1) * DEG_TO_RAD;
3487
- const deltaLambda = (lon2 - lon1) * DEG_TO_RAD;
3488
- const halfDeltaPhi = Math.sin(deltaPhi / 2);
3489
- const halfDeltaLambda = Math.sin(deltaLambda / 2);
3490
- const a = halfDeltaPhi * halfDeltaPhi + Math.cos(phi1) * Math.cos(phi2) * halfDeltaLambda * halfDeltaLambda;
3491
- const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
3492
- return EARTH_RADIUS_METERS * c;
3410
+ return false;
3493
3411
  }
3494
-
3495
- // src/geo/edge-tree.ts
3496
- function buildLongitudeEdgeTree(lons) {
3497
- const n = lons.length;
3498
- const edges = [];
3499
- for (let i = 0; i < n; i++) {
3500
- if (lons[i] !== lons[i === 0 ? n - 1 : i - 1]) edges.push(i);
3501
- }
3502
- const lowOf = (i) => Math.min(lons[i], lons[i === 0 ? n - 1 : i - 1]);
3503
- edges.sort((left, right) => lowOf(left) - lowOf(right));
3504
- const count = edges.length;
3505
- const tree = {
3506
- from: new Int32Array(count),
3507
- to: new Int32Array(count),
3508
- low: new Float64Array(count),
3509
- high: new Float64Array(count),
3510
- subtreeHigh: new Float64Array(count)
3511
- };
3512
- edges.forEach((i, at) => {
3513
- const j = i === 0 ? n - 1 : i - 1;
3514
- tree.from[at] = i;
3515
- tree.to[at] = j;
3516
- tree.low[at] = Math.min(lons[i], lons[j]);
3517
- tree.high[at] = Math.max(lons[i], lons[j]);
3518
- });
3519
- const fillSubtreeHigh = (start, end) => {
3520
- if (start >= end) return Number.NEGATIVE_INFINITY;
3521
- const mid = start + end >>> 1;
3522
- const highest = Math.max(tree.high[mid], fillSubtreeHigh(start, mid), fillSubtreeHigh(mid + 1, end));
3523
- tree.subtreeHigh[mid] = highest;
3524
- return highest;
3525
- };
3526
- fillSubtreeHigh(0, count);
3527
- return tree;
3528
- }
3529
- function forEachEdgeSpanning(tree, lon, visit) {
3530
- const walk = (start, end) => {
3531
- if (start >= end) return;
3532
- const mid = start + end >>> 1;
3533
- if (tree.subtreeHigh[mid] <= lon) return;
3534
- walk(start, mid);
3535
- if (tree.low[mid] > lon) return;
3536
- if (lon < tree.high[mid]) visit(tree.from[mid], tree.to[mid]);
3537
- walk(mid + 1, end);
3538
- };
3539
- walk(0, tree.from.length);
3412
+ function schemaMayDeclare(schema, typeName) {
3413
+ return mayDeclare(schema, typeName, 1);
3540
3414
  }
3541
3415
 
3542
- // src/geo/polygon.ts
3543
- function requirePolygonRing(points) {
3544
- if (!Array.isArray(points) || points.length < MIN_POLYGON_POINTS) {
3545
- throw new NarsilError(
3546
- ErrorCodes.SEARCH_INVALID_FILTER,
3547
- `A polygon encloses an area only with at least ${MIN_POLYGON_POINTS} points`,
3548
- { points: Array.isArray(points) ? points.length : typeof points, minimum: MIN_POLYGON_POINTS }
3549
- );
3550
- }
3551
- points.forEach((point, position) => {
3552
- const { lat, lon } = point ?? {};
3553
- if (typeof lat !== "number" || !Number.isFinite(lat) || typeof lon !== "number" || !Number.isFinite(lon)) {
3554
- throw new NarsilError(
3555
- ErrorCodes.SEARCH_INVALID_FILTER,
3556
- `A polygon point carries a finite "lat" and "lon", and the point at position ${position} does not`,
3557
- { position }
3416
+ // src/workers/code-loader.ts
3417
+ function codeLoader(importCode, typeName) {
3418
+ let loaded2 = null;
3419
+ let loading2 = null;
3420
+ function load() {
3421
+ if (loaded2 !== null) return Promise.resolve(loaded2);
3422
+ if (loading2 === null) {
3423
+ loading2 = importCode().then(
3424
+ (code) => {
3425
+ loaded2 = code;
3426
+ return code;
3427
+ },
3428
+ (err) => {
3429
+ loading2 = null;
3430
+ throw err;
3431
+ }
3558
3432
  );
3559
3433
  }
3560
- if (isLatitude(lat) && isLongitude(lon)) return;
3561
- throw new NarsilError(
3562
- ErrorCodes.SEARCH_INVALID_FILTER,
3563
- `A polygon point must hold a "lat" from -${MAX_LATITUDE_DEGREES} to ${MAX_LATITUDE_DEGREES} and a "lon" from -${MAX_LONGITUDE_DEGREES} to ${MAX_LONGITUDE_DEGREES}, while the point at position ${position} holds ${lat}, ${lon}`,
3564
- { position, lat, lon }
3565
- );
3566
- });
3567
- }
3568
- function signedArea(polygon) {
3569
- let area = 0;
3570
- for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
3571
- area += polygon[j].lon * polygon[i].lat - polygon[i].lon * polygon[j].lat;
3572
- }
3573
- return area;
3574
- }
3575
- function crossesAntimeridian(polygon) {
3576
- let west = Number.POSITIVE_INFINITY;
3577
- let east = Number.NEGATIVE_INFINITY;
3578
- for (const point of polygon) {
3579
- if (point.lon < west) west = point.lon;
3580
- if (point.lon > east) east = point.lon;
3581
- }
3582
- return east - west >= ANTIMERIDIAN_SPAN_DEGREES && signedArea(polygon) < 0;
3583
- }
3584
- function eastward(lon) {
3585
- return lon < 0 ? lon + FULL_TURN_DEGREES : lon;
3586
- }
3587
- function polygonContainment(polygon) {
3588
- const n = polygon.length;
3589
- if (n < MIN_POLYGON_POINTS) return () => false;
3590
- const unwrap = crossesAntimeridian(polygon);
3591
- const lats = new Float64Array(n);
3592
- const lons = new Float64Array(n);
3593
- for (let i = 0; i < n; i++) {
3594
- lats[i] = polygon[i].lat;
3595
- lons[i] = unwrap ? eastward(polygon[i].lon) : polygon[i].lon;
3596
- }
3597
- const edges = buildLongitudeEdgeTree(lons);
3598
- return (lat, rawLon) => {
3599
- const lon = unwrap ? eastward(rawLon) : rawLon;
3600
- let inside = false;
3601
- forEachEdgeSpanning(edges, lon, (i, j) => {
3602
- const intersectLat = lats[i] + (lats[j] - lats[i]) / (lons[j] - lons[i]) * (lon - lons[i]);
3603
- if (lat < intersectLat) inside = !inside;
3604
- });
3605
- return inside;
3606
- };
3607
- }
3608
- function polygonBoxes(polygon) {
3609
- if (polygon.length < MIN_POLYGON_POINTS) return [];
3610
- const unwrap = crossesAntimeridian(polygon);
3611
- let south = Number.POSITIVE_INFINITY;
3612
- let north = Number.NEGATIVE_INFINITY;
3613
- let west = Number.POSITIVE_INFINITY;
3614
- let east = Number.NEGATIVE_INFINITY;
3615
- for (const point of polygon) {
3616
- const lon = unwrap ? eastward(point.lon) : point.lon;
3617
- south = Math.min(south, point.lat);
3618
- north = Math.max(north, point.lat);
3619
- west = Math.min(west, lon);
3620
- east = Math.max(east, lon);
3621
- }
3622
- if (west >= MAX_LONGITUDE_DEGREES)
3623
- return longitudeBoxes(south, north, west - FULL_TURN_DEGREES, east - FULL_TURN_DEGREES);
3624
- return longitudeBoxes(south, north, west, east);
3625
- }
3626
-
3627
- // src/geo/vincenty.ts
3628
- var WGS84_A = 6378137;
3629
- var WGS84_F = 1 / 298.257223563;
3630
- var WGS84_B = WGS84_A * (1 - WGS84_F);
3631
- function vincentyDistance(lat1, lon1, lat2, lon2) {
3632
- const phi1 = lat1 * DEG_TO_RAD;
3633
- const phi2 = lat2 * DEG_TO_RAD;
3634
- const L = (lon2 - lon1) * DEG_TO_RAD;
3635
- const U1 = Math.atan((1 - WGS84_F) * Math.tan(phi1));
3636
- const U2 = Math.atan((1 - WGS84_F) * Math.tan(phi2));
3637
- const sinU1 = Math.sin(U1);
3638
- const cosU1 = Math.cos(U1);
3639
- const sinU2 = Math.sin(U2);
3640
- const cosU2 = Math.cos(U2);
3641
- let lambda = L;
3642
- let prevLambda;
3643
- let sinSigma = 0;
3644
- let cosSigma = 0;
3645
- let sigma = 0;
3646
- let sinAlpha = 0;
3647
- let cos2Alpha = 0;
3648
- let cos2SigmaM = 0;
3649
- let iterations = VINCENTY_MAX_ITERATIONS;
3650
- do {
3651
- const sinLambda = Math.sin(lambda);
3652
- const cosLambda = Math.cos(lambda);
3653
- const term1 = cosU2 * sinLambda;
3654
- const term2 = cosU1 * sinU2 - sinU1 * cosU2 * cosLambda;
3655
- sinSigma = Math.sqrt(term1 * term1 + term2 * term2);
3656
- if (sinSigma === 0) return 0;
3657
- cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
3658
- sigma = Math.atan2(sinSigma, cosSigma);
3659
- sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma;
3660
- cos2Alpha = 1 - sinAlpha * sinAlpha;
3661
- cos2SigmaM = cos2Alpha === 0 ? 0 : cosSigma - 2 * sinU1 * sinU2 / cos2Alpha;
3662
- const C = WGS84_F / 16 * cos2Alpha * (4 + WGS84_F * (4 - 3 * cos2Alpha));
3663
- prevLambda = lambda;
3664
- lambda = L + (1 - C) * WGS84_F * sinAlpha * (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
3665
- } while (Math.abs(lambda - prevLambda) > VINCENTY_CONVERGENCE_THRESHOLD && --iterations > 0);
3666
- if (iterations === 0) {
3667
- return haversineDistance(lat1, lon1, lat2, lon2);
3668
- }
3669
- const uSq = cos2Alpha * (WGS84_A * WGS84_A - WGS84_B * WGS84_B) / (WGS84_B * WGS84_B);
3670
- const A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
3671
- const B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
3672
- const deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
3673
- return WGS84_B * A * (sigma - deltaSigma);
3674
- }
3675
-
3676
- // src/geo/geo-index.ts
3677
- var REMOVED_DOC_ID = -1;
3678
- function firstAtOrAfter(entries, code) {
3679
- let lo = 0;
3680
- let hi = entries.length;
3681
- while (lo < hi) {
3682
- const mid = lo + hi >>> 1;
3683
- if (entries[mid].code < code) lo = mid + 1;
3684
- else hi = mid;
3685
- }
3686
- return lo;
3687
- }
3688
- function dropRemoved(entries) {
3689
- let write = 0;
3690
- for (let read = 0; read < entries.length; read++) {
3691
- if (entries[read].docId !== REMOVED_DOC_ID) entries[write++] = entries[read];
3692
- }
3693
- entries.length = write;
3694
- }
3695
- function mergeSortedPending(entries, pending) {
3696
- pending.sort((left2, right2) => left2.code - right2.code || left2.docId - right2.docId);
3697
- const mainLength = entries.length;
3698
- for (const entry of pending) entries.push(entry);
3699
- let left = mainLength - 1;
3700
- let right = pending.length - 1;
3701
- let write = entries.length - 1;
3702
- while (right >= 0) {
3703
- const later = left >= 0 ? entries[left] : void 0;
3704
- const next = pending[right];
3705
- if (later !== void 0 && (later.code > next.code || later.code === next.code && later.docId > next.docId)) {
3706
- entries[write--] = later;
3707
- left--;
3708
- } else {
3709
- entries[write--] = next;
3710
- right--;
3711
- }
3434
+ return loading2;
3712
3435
  }
3713
- }
3714
- function createGeoIndex() {
3715
- let entries = [];
3716
- let pending = [];
3717
- const byDocument = /* @__PURE__ */ new Map();
3718
- let removedCount = 0;
3719
- function ensureSorted() {
3720
- if (removedCount > 0) {
3721
- dropRemoved(entries);
3722
- dropRemoved(pending);
3723
- removedCount = 0;
3724
- }
3725
- if (pending.length === 0) return;
3726
- if (entries.length === 0) {
3727
- pending.sort((left, right) => left.code - right.code || left.docId - right.docId);
3728
- entries = pending;
3729
- } else {
3730
- mergeSortedPending(entries, pending);
3731
- }
3732
- pending = [];
3733
- }
3734
- function removeEntry(entry) {
3735
- byDocument.delete(entry.docId);
3736
- entry.docId = REMOVED_DOC_ID;
3737
- removedCount++;
3738
- const held = entries.length + pending.length;
3739
- if (removedCount >= Math.max(PENDING_REMOVAL_MERGE_FLOOR, held / PENDING_REMOVAL_MERGE_DIVISOR)) ensureSorted();
3740
- }
3741
- function matching(boxes, passes, inside) {
3742
- ensureSorted();
3743
- const within = /* @__PURE__ */ new Set();
3744
- for (const range of coveringRanges(boxes)) {
3745
- for (let at = firstAtOrAfter(entries, range.from); at < entries.length && entries[at].code < range.to; at++) {
3746
- if (passes(entries[at])) within.add(entries[at].docId);
3747
- }
3748
- }
3749
- if (inside) return within;
3750
- const outside = /* @__PURE__ */ new Set();
3751
- for (const entry of entries) {
3752
- if (!within.has(entry.docId)) outside.add(entry.docId);
3753
- }
3754
- return outside;
3755
- }
3756
- const index = {
3757
- insert(internalId, lat, lon) {
3758
- const existing = byDocument.get(internalId);
3759
- if (existing !== void 0) removeEntry(existing);
3760
- const entry = { lat, lon, docId: internalId, code: locationCode(lat, lon) };
3761
- pending.push(entry);
3762
- byDocument.set(internalId, entry);
3763
- },
3764
- remove(internalId) {
3765
- const existing = byDocument.get(internalId);
3766
- if (existing !== void 0) removeEntry(existing);
3767
- },
3768
- radiusQuery(lat, lon, distanceMeters, inside, highPrecision) {
3769
- const distanceFn = highPrecision ? vincentyDistance : haversineDistance;
3770
- return matching(
3771
- radiusBoxes(lat, lon, distanceMeters),
3772
- (entry) => distanceFn(lat, lon, entry.lat, entry.lon) <= distanceMeters,
3773
- inside
3774
- );
3775
- },
3776
- polygonQuery(points, inside) {
3777
- const contains = polygonContainment(points);
3778
- return matching(polygonBoxes(points), (entry) => contains(entry.lat, entry.lon), inside);
3779
- },
3780
- documentsBitset(capacity) {
3781
- const bits = createBitSet(capacity);
3782
- for (const docId of byDocument.keys()) bitsetSet(bits, docId);
3783
- return bits;
3784
- },
3785
- clear() {
3786
- entries = [];
3787
- pending = [];
3788
- byDocument.clear();
3789
- removedCount = 0;
3790
- },
3791
- serialize() {
3792
- ensureSorted();
3793
- return entries.map((entry) => ({ lat: entry.lat, lon: entry.lon, docId: entry.docId }));
3436
+ return {
3437
+ loaded: () => loaded2,
3438
+ require() {
3439
+ if (loaded2 === null) throw new Error(`The engine reached ${typeName} code before it loaded that code`);
3440
+ return loaded2;
3794
3441
  },
3795
- deserialize(data) {
3796
- index.clear();
3797
- for (const entry of data) index.insert(entry.docId, entry.lat, entry.lon);
3798
- }
3442
+ load,
3443
+ loadFor: (schema) => loaded2 !== null || !schemaMayDeclare(schema, typeName) ? null : load()
3799
3444
  };
3800
- return index;
3445
+ }
3446
+
3447
+ // src/geo/geo-code.ts
3448
+ var geoCode = codeLoader(() => import('./geo-index-HHWGMNIS.mjs'), "geopoint");
3449
+ var loadGeoCodeFor = geoCode.loadFor;
3450
+ function createLoadedGeoIndex() {
3451
+ return geoCode.require().createGeoIndex(PENDING_REMOVAL_MERGE_FLOOR, PENDING_REMOVAL_MERGE_DIVISOR);
3801
3452
  }
3802
3453
 
3803
3454
  // src/core/field-index/boolean.ts
@@ -3881,7 +3532,7 @@ function reversedUnits(value) {
3881
3532
  for (let at = value.length - 1; at >= 0; at--) reversed += value[at];
3882
3533
  return reversed;
3883
3534
  }
3884
- function firstAtOrAfter2(sorted, key) {
3535
+ function firstAtOrAfter(sorted, key) {
3885
3536
  let lo = 0;
3886
3537
  let hi = sorted.length;
3887
3538
  while (lo < hi) {
@@ -3939,7 +3590,7 @@ var ValueAffixes = class {
3939
3590
  }
3940
3591
  matching(column, start) {
3941
3592
  const found = [];
3942
- for (let at = firstAtOrAfter2(column.keys, start); at < column.keys.length; at++) {
3593
+ for (let at = firstAtOrAfter(column.keys, start); at < column.keys.length; at++) {
3943
3594
  if (!column.keys[at].startsWith(start)) break;
3944
3595
  found.push(column.values[at]);
3945
3596
  }
@@ -4177,7 +3828,7 @@ function removeFromPending(pending, marked, byDocument) {
4177
3828
  }
4178
3829
  pending.length = write;
4179
3830
  }
4180
- function mergeSortedPending2(entries, pending) {
3831
+ function mergeSortedPending(entries, pending) {
4181
3832
  pending.sort((a, b) => a.value - b.value);
4182
3833
  const mainLength = entries.length;
4183
3834
  for (const entry of pending) entries.push(entry);
@@ -4213,7 +3864,7 @@ function createNumericIndex() {
4213
3864
  pending.sort((a, b) => a.value - b.value);
4214
3865
  entries = pending;
4215
3866
  } else {
4216
- mergeSortedPending2(entries, pending);
3867
+ mergeSortedPending(entries, pending);
4217
3868
  }
4218
3869
  pending = [];
4219
3870
  }
@@ -4401,7 +4052,7 @@ function ensureFieldIndex(state, fieldPath, base) {
4401
4052
  } else if ((base === "enum" || base === "enum[]") && !state.enumIndexes.has(fieldPath)) {
4402
4053
  state.enumIndexes.set(fieldPath, createEnumIndex());
4403
4054
  } else if (base === "geopoint" && !state.geoIndexes.has(fieldPath)) {
4404
- state.geoIndexes.set(fieldPath, createGeoIndex());
4055
+ state.geoIndexes.set(fieldPath, createLoadedGeoIndex());
4405
4056
  }
4406
4057
  }
4407
4058
  function getOrCreateNumericIndex(state, fieldPath) {
@@ -5043,6 +4694,33 @@ function requireListLength(fieldPath, operator, values) {
5043
4694
  );
5044
4695
  }
5045
4696
 
4697
+ // src/geo/polygon-ring.ts
4698
+ function requirePolygonRing(points) {
4699
+ if (!Array.isArray(points) || points.length < MIN_POLYGON_POINTS) {
4700
+ throw new NarsilError(
4701
+ ErrorCodes.SEARCH_INVALID_FILTER,
4702
+ `A polygon encloses an area only with at least ${MIN_POLYGON_POINTS} points`,
4703
+ { points: Array.isArray(points) ? points.length : typeof points, minimum: MIN_POLYGON_POINTS }
4704
+ );
4705
+ }
4706
+ points.forEach((point, position) => {
4707
+ const { lat, lon } = point ?? {};
4708
+ if (typeof lat !== "number" || !Number.isFinite(lat) || typeof lon !== "number" || !Number.isFinite(lon)) {
4709
+ throw new NarsilError(
4710
+ ErrorCodes.SEARCH_INVALID_FILTER,
4711
+ `A polygon point carries a finite "lat" and "lon", and the point at position ${position} does not`,
4712
+ { position }
4713
+ );
4714
+ }
4715
+ if (isLatitude(lat) && isLongitude(lon)) return;
4716
+ throw new NarsilError(
4717
+ ErrorCodes.SEARCH_INVALID_FILTER,
4718
+ `A polygon point must hold a "lat" from -${MAX_LATITUDE_DEGREES} to ${MAX_LATITUDE_DEGREES} and a "lon" from -${MAX_LONGITUDE_DEGREES} to ${MAX_LONGITUDE_DEGREES}, while the point at position ${position} holds ${lat}, ${lon}`,
4719
+ { position, lat, lon }
4720
+ );
4721
+ });
4722
+ }
4723
+
5046
4724
  // src/filters/operands/geo.ts
5047
4725
  function requireFlag(fieldPath, operator, flag, value) {
5048
4726
  if (value === void 0 || typeof value === "boolean") return;
@@ -6165,17 +5843,21 @@ function presentBitsetOf(state, fieldPath, type, capacity) {
6165
5843
  if (base === "number") present = state.numericIndexes.get(fieldPath)?.getAllDocIdsBitset(capacity);
6166
5844
  else if (base === "boolean") present = state.booleanIndexes.get(fieldPath)?.getAllDocIdsBitset(capacity);
6167
5845
  else if (base === "enum") present = state.enumIndexes.get(fieldPath)?.getAllDocIdsBitset(capacity);
6168
- else if (base === "geopoint") present = state.geoIndexes.get(fieldPath)?.documentsBitset(capacity);
5846
+ else if (base === "geopoint") present = geoDocumentsBitset(state, fieldPath, capacity);
6169
5847
  else if (base !== void 0 && keepsValueSize(base)) {
6170
5848
  present = state.sizeIndexes.get(fieldPath)?.getAllDocIdsBitset(capacity);
6171
5849
  }
6172
5850
  return present ?? createBitSet(capacity);
6173
5851
  }
6174
- function liveDocumentsBitset(state, capacity) {
5852
+ function bitsetOfDocuments(internalIds, capacity) {
6175
5853
  const bits = createBitSet(capacity);
6176
- for (const internalId of state.docStore.allInternalIds()) bitsetSet(bits, internalId);
5854
+ for (const internalId of internalIds) bitsetSet(bits, internalId);
6177
5855
  return bits;
6178
5856
  }
5857
+ function geoDocumentsBitset(state, fieldPath, capacity) {
5858
+ const geoIndex = state.geoIndexes.get(fieldPath);
5859
+ return geoIndex === void 0 ? void 0 : bitsetOfDocuments(geoIndex.documentIds(), capacity);
5860
+ }
6179
5861
  function buildFilterContext(state, schema, meter) {
6180
5862
  const flat = getFlatSchema(state, schema);
6181
5863
  const capacity = state.docStore.internalIdCapacity();
@@ -6227,7 +5909,7 @@ function buildFilterContext(state, schema, meter) {
6227
5909
  },
6228
5910
  capacity,
6229
5911
  get allDocIdsBitset() {
6230
- cachedAllDocIdsBitset ??= liveDocumentsBitset(state, capacity);
5912
+ cachedAllDocIdsBitset ??= bitsetOfDocuments(state.docStore.allInternalIds(), capacity);
6231
5913
  return cachedAllDocIdsBitset;
6232
5914
  }
6233
5915
  };
@@ -6301,7 +5983,7 @@ function requireLoadedPhraseCode() {
6301
5983
  }
6302
5984
  function loadPhraseCode() {
6303
5985
  if (loading === null) {
6304
- loading = import('./phrase-module-NPYUVX75.mjs').then(
5986
+ loading = import('./phrase-module-HAT3TLZN.mjs').then(
6305
5987
  (code) => {
6306
5988
  loaded = code;
6307
5989
  return code;
@@ -6335,10 +6017,82 @@ function analyseQueryPhrases(term, language, analysis) {
6335
6017
  );
6336
6018
  }
6337
6019
 
6020
+ // src/math/log.ts
6021
+ var EXPONENT_BIAS = 1023;
6022
+ var EXPONENT_SHIFT = 20;
6023
+ var SUBNORMAL_SCALE_EXPONENT = 54;
6024
+ var ROUNDING_OFFSET = 614244;
6025
+ var HALVING_BIT = 1048576;
6026
+ var ONE_HIGH_WORD = 1072693248;
6027
+ var SIGNIFICAND_MASK = 1048575;
6028
+ var NEAR_ONE_LIMIT = 3;
6029
+ var LOWER_SPLIT = 398458;
6030
+ var UPPER_SPLIT = 440401;
6031
+ var LN2_HI = 0.6931471803691238;
6032
+ var LN2_LO = 19082149292705877e-26;
6033
+ var TWO54 = 18014398509481984;
6034
+ var TWO = 2;
6035
+ var THIRD = 0.3333333333333333;
6036
+ var HALF = 0.5;
6037
+ var LG1 = 0.6666666666666735;
6038
+ var LG2 = 0.3999999999940942;
6039
+ var LG3 = 0.2857142874366239;
6040
+ var LG4 = 0.22222198432149784;
6041
+ var LG5 = 0.1818357216161805;
6042
+ var LG6 = 0.15313837699209373;
6043
+ var LG7 = 0.14798198605116586;
6044
+ function nearOne(fraction, scale) {
6045
+ if (fraction === 0) {
6046
+ if (scale === 0) return 0;
6047
+ return scale * LN2_HI + scale * LN2_LO;
6048
+ }
6049
+ const cubic = fraction * fraction * (HALF - THIRD * fraction);
6050
+ if (scale === 0) return fraction - cubic;
6051
+ return scale * LN2_HI - (cubic - scale * LN2_LO - fraction);
6052
+ }
6053
+ function series(fraction, scale, significand) {
6054
+ const ratio = fraction / (TWO + fraction);
6055
+ const square = ratio * ratio;
6056
+ const below = significand - LOWER_SPLIT;
6057
+ const fourth = square * square;
6058
+ const above = UPPER_SPLIT - significand;
6059
+ const even = fourth * (LG2 + fourth * (LG4 + fourth * LG6));
6060
+ const odd = square * (LG1 + fourth * (LG3 + fourth * (LG5 + fourth * LG7)));
6061
+ const poly = odd + even;
6062
+ if ((below | above) > 0) {
6063
+ const halfSquare = HALF * fraction * fraction;
6064
+ if (scale === 0) return fraction - (halfSquare - ratio * (halfSquare + poly));
6065
+ return scale * LN2_HI - (halfSquare - (ratio * (halfSquare + poly) + scale * LN2_LO) - fraction);
6066
+ }
6067
+ if (scale === 0) return fraction - ratio * (fraction - poly);
6068
+ return scale * LN2_HI - (ratio * (fraction - poly) - scale * LN2_LO - fraction);
6069
+ }
6070
+ function log(value) {
6071
+ let high = highWord(value);
6072
+ let scale = 0;
6073
+ let scaled = value;
6074
+ if (high < SMALLEST_NORMAL_HIGH_WORD) {
6075
+ if ((high & MAGNITUDE_MASK | lowWord(value)) === 0) return Number.NEGATIVE_INFINITY;
6076
+ if (high < 0) return Number.NaN;
6077
+ scale -= SUBNORMAL_SCALE_EXPONENT;
6078
+ scaled *= TWO54;
6079
+ high = highWord(scaled);
6080
+ }
6081
+ if (high >= INFINITE_HIGH_WORD) return scaled + scaled;
6082
+ scale += (high >> EXPONENT_SHIFT) - EXPONENT_BIAS;
6083
+ const significand = high & SIGNIFICAND_MASK;
6084
+ const halving = significand + ROUNDING_OFFSET & HALVING_BIT;
6085
+ scaled = withHighWord(scaled, significand | halving ^ ONE_HIGH_WORD);
6086
+ scale += halving >> EXPONENT_SHIFT;
6087
+ const fraction = scaled - 1;
6088
+ if ((SIGNIFICAND_MASK & 2 + significand) < NEAR_ONE_LIMIT) return nearOne(fraction, scale);
6089
+ return series(fraction, scale, significand);
6090
+ }
6091
+
6338
6092
  // src/core/scorer.ts
6339
6093
  function computeIDF(docFrequency, totalDocs) {
6340
6094
  if (totalDocs === 0) return 0;
6341
- return Math.log((totalDocs - docFrequency + 0.5) / (docFrequency + 0.5) + 1);
6095
+ return log((totalDocs - docFrequency + 0.5) / (docFrequency + 0.5) + 1);
6342
6096
  }
6343
6097
  function pairKeepsBoundSound(k1, b) {
6344
6098
  return k1 >= 0 && k1 <= MAX_BM25_K1 && b >= 0 && b <= MAX_BM25_B;
@@ -6402,6 +6156,43 @@ function computeBM25WithIDF(termFrequency, idf, fieldLength, avgFieldLength, k1,
6402
6156
  return idf * (numerator / denominator);
6403
6157
  }
6404
6158
 
6159
+ // src/core/partition/field-order.ts
6160
+ var fieldRun = { entries: new Uint32Array(FIELD_RUN_ENTRIES_START), length: 0 };
6161
+ var ranksByFieldNames = /* @__PURE__ */ new WeakMap();
6162
+ var ONLY_FIELD_RANKS = new Uint32Array(1);
6163
+ function fieldNameRanks(fieldNames) {
6164
+ if (fieldNames.length < 2) return ONLY_FIELD_RANKS;
6165
+ const held = ranksByFieldNames.get(fieldNames);
6166
+ if (held !== void 0 && held.length === fieldNames.length) return held;
6167
+ const order = Array.from(fieldNames.keys()).sort(
6168
+ (left, right) => compareCodePoints(fieldNames[left], fieldNames[right])
6169
+ );
6170
+ const ranks = new Uint32Array(order.length);
6171
+ for (let rank = 0; rank < order.length; rank++) ranks[order[rank]] = rank;
6172
+ ranksByFieldNames.set(fieldNames, ranks);
6173
+ return ranks;
6174
+ }
6175
+ function orderRunByFieldName(docIds, fieldIndices, ranks, start, count) {
6176
+ let entries = fieldRun.entries;
6177
+ let end = start;
6178
+ for (; end < count && docIds[end] === docIds[start]; end++) {
6179
+ let slot = end - start;
6180
+ if (slot === entries.length) {
6181
+ const grown = new Uint32Array(slot * 2);
6182
+ grown.set(entries);
6183
+ entries = fieldRun.entries = grown;
6184
+ }
6185
+ const rank = ranks[fieldIndices[end]];
6186
+ while (slot > 0 && ranks[fieldIndices[entries[slot - 1]]] > rank) {
6187
+ entries[slot] = entries[slot - 1];
6188
+ slot--;
6189
+ }
6190
+ entries[slot] = end;
6191
+ }
6192
+ fieldRun.length = end - start;
6193
+ return entries;
6194
+ }
6195
+
6405
6196
  // src/core/partition/field-scoring.ts
6406
6197
  var NO_FIELD_VALUES = new Float64Array(0);
6407
6198
  function differentPairsOf(searchable, k1s, bs) {
@@ -6429,7 +6220,8 @@ function loadFieldScoring(state, fields, boost, averageFieldLengths, bm25) {
6429
6220
  lengthColumns: new Array(fieldCount).fill(null),
6430
6221
  k1s: perField === void 0 ? NO_FIELD_VALUES : new Float64Array(fieldCount),
6431
6222
  bs: perField === void 0 ? NO_FIELD_VALUES : new Float64Array(fieldCount),
6432
- boundPairs: [k1, b]
6223
+ boundPairs: [k1, b],
6224
+ nameRanks: fieldNameRanks(fieldNames)
6433
6225
  };
6434
6226
  for (let fieldIndex = 0; fieldIndex < fieldCount; fieldIndex++) {
6435
6227
  const fieldName = fieldNames[fieldIndex];
@@ -6532,12 +6324,18 @@ function termGroupOf(groups, token) {
6532
6324
  function typoMatchesFor(index, token, group, exact, tolerance, prefixLength) {
6533
6325
  if (group !== void 0) {
6534
6326
  if (!group.typoMatches || exact || tolerance === 0) return [];
6535
- return index.fuzzyLookup(token, tolerance, prefixLength).filter((match) => match.token !== token && group.synonyms?.has(match.token) !== true);
6327
+ return index.fuzzyLookup(token, tolerance, prefixLength).filter((match) => match.token !== token && group.synonyms?.has(match.token) !== true).sort(byToken);
6328
+ }
6329
+ if (!exact) {
6330
+ const matches = index.fuzzyLookup(token, tolerance, prefixLength);
6331
+ return matches.length > 1 ? matches.sort(byToken) : matches;
6536
6332
  }
6537
- if (!exact) return index.fuzzyLookup(token, tolerance, prefixLength);
6538
6333
  const postingList = index.lookup(token);
6539
6334
  return postingList ? [{ token, postingList }] : [];
6540
6335
  }
6336
+ function byToken(left, right) {
6337
+ return compareCodePoints(left.token, right.token);
6338
+ }
6541
6339
  function resolveGroupMatches(context, group) {
6542
6340
  const frequencyOf = (token) => context.globalFrequency(token) ?? context.index.documentFrequency(token);
6543
6341
  const lookup = (token) => context.index.lookup(token);
@@ -6570,10 +6368,20 @@ function computeGroupContributions(context, matches, collect) {
6570
6368
  const { docIds, termFrequencies, fieldNameIndices, deletedDocs, hasDeleted, count } = postingColumns(
6571
6369
  match.postingList
6572
6370
  );
6573
- for (let pi = 0; pi < count; pi++) {
6574
- const internalId = docIds[pi];
6371
+ let runStart = 0;
6372
+ let runEnd = 0;
6373
+ for (let at = 0; at < count; at++) {
6374
+ const internalId = docIds[at];
6575
6375
  if (hasDeleted && deletedDocs.has(internalId)) continue;
6576
6376
  if (filterBitset && !bitsetHas(filterBitset, internalId)) continue;
6377
+ let pi = at;
6378
+ if (at < runEnd) {
6379
+ pi = fieldRun.entries[at - runStart];
6380
+ } else if (at + 2 < count && docIds[at + 2] === internalId) {
6381
+ pi = orderRunByFieldName(docIds, fieldNameIndices, fields.nameRanks, at, count)[0];
6382
+ runStart = at;
6383
+ runEnd = at + fieldRun.length;
6384
+ }
6577
6385
  const fieldIndex = fieldNameIndices[pi];
6578
6386
  if (fields.searchable[fieldIndex] === 0) continue;
6579
6387
  const factor = partialMarks[fieldIndex] === 1 ? match.partialFactor : match.factor;
@@ -6851,7 +6659,7 @@ function mergeFieldIndexes(target, source, idMapping) {
6851
6659
  for (const [fieldPath, index] of source.geoIndexes) {
6852
6660
  let targetIndex = target.geoIndexes.get(fieldPath);
6853
6661
  if (targetIndex === void 0) {
6854
- targetIndex = createGeoIndex();
6662
+ targetIndex = createLoadedGeoIndex();
6855
6663
  target.geoIndexes.set(fieldPath, targetIndex);
6856
6664
  }
6857
6665
  for (const entry of index.serialize()) {
@@ -7278,15 +7086,30 @@ function firstEntryOf(docIds, count, internalId) {
7278
7086
  }
7279
7087
  return low;
7280
7088
  }
7089
+ function fieldOrderedRunScore(scan, start, internalId, total, entryScore) {
7090
+ const { docIds, fieldNameIndices, count } = scan.columns;
7091
+ const ordered = orderRunByFieldName(docIds, fieldNameIndices, scan.fields.nameRanks, start, count);
7092
+ let score = total;
7093
+ for (let at = 0; at < fieldRun.length; at++) {
7094
+ const row = ordered[at];
7095
+ if (scan.fields.searchable[fieldNameIndices[row]] !== 1) continue;
7096
+ score += entryScore(scan, row, internalId);
7097
+ }
7098
+ return score;
7099
+ }
7281
7100
  function samePairQueryOrderScore(scans, internalId) {
7282
7101
  let score = 0;
7283
7102
  for (const scan of scans) {
7284
7103
  const { docIds, deletedDocs, hasDeleted, count } = scan.columns;
7285
7104
  if (hasDeleted && deletedDocs.has(internalId)) continue;
7286
- for (let entry = firstEntryOf(docIds, count, internalId); entry < count && docIds[entry] === internalId; entry++) {
7287
- if (scan.fields.searchable[scan.columns.fieldNameIndices[entry]] !== 1) continue;
7288
- score += samePairEntryScore(scan, entry, internalId);
7105
+ const start = firstEntryOf(docIds, count, internalId);
7106
+ if (start + 1 < count && docIds[start + 1] === internalId) {
7107
+ score = fieldOrderedRunScore(scan, start, internalId, score, samePairEntryScore);
7108
+ continue;
7289
7109
  }
7110
+ if (start === count || docIds[start] !== internalId) continue;
7111
+ if (scan.fields.searchable[scan.columns.fieldNameIndices[start]] !== 1) continue;
7112
+ score += samePairEntryScore(scan, start, internalId);
7290
7113
  }
7291
7114
  return score;
7292
7115
  }
@@ -7295,10 +7118,14 @@ function fieldPairQueryOrderScore(scans, internalId) {
7295
7118
  for (const scan of scans) {
7296
7119
  const { docIds, deletedDocs, hasDeleted, count } = scan.columns;
7297
7120
  if (hasDeleted && deletedDocs.has(internalId)) continue;
7298
- for (let entry = firstEntryOf(docIds, count, internalId); entry < count && docIds[entry] === internalId; entry++) {
7299
- if (scan.fields.searchable[scan.columns.fieldNameIndices[entry]] !== 1) continue;
7300
- score += fieldPairEntryScore(scan, entry, internalId);
7121
+ const start = firstEntryOf(docIds, count, internalId);
7122
+ if (start + 1 < count && docIds[start + 1] === internalId) {
7123
+ score = fieldOrderedRunScore(scan, start, internalId, score, fieldPairEntryScore);
7124
+ continue;
7301
7125
  }
7126
+ if (start === count || docIds[start] !== internalId) continue;
7127
+ if (scan.fields.searchable[scan.columns.fieldNameIndices[start]] !== 1) continue;
7128
+ score += fieldPairEntryScore(scan, start, internalId);
7302
7129
  }
7303
7130
  return score;
7304
7131
  }
@@ -7436,7 +7263,8 @@ function singleTermTopK(request) {
7436
7263
  lengthColumns: fieldLengthColumns,
7437
7264
  k1s,
7438
7265
  bs,
7439
- boundPairs
7266
+ boundPairs,
7267
+ nameRanks
7440
7268
  } = request.fields;
7441
7269
  const onePair = boundPairs.length === 2;
7442
7270
  const onlyK1 = boundPairs[0];
@@ -7476,12 +7304,14 @@ function singleTermTopK(request) {
7476
7304
  }
7477
7305
  let score = 0;
7478
7306
  let scored2 = false;
7479
- while (entry < end && docIds[entry] === internalId) {
7480
- const fieldIndex = fieldNameIndices[entry];
7307
+ const ordered = entry + 2 < end && docIds[entry + 2] === internalId ? orderRunByFieldName(docIds, fieldNameIndices, nameRanks, entry, end) : null;
7308
+ for (let at = 0; entry < end && docIds[entry] === internalId; at++, entry++) {
7309
+ const row = ordered === null ? entry : ordered[at];
7310
+ const fieldIndex = fieldNameIndices[row];
7481
7311
  if (fieldSearchable[fieldIndex] === 1) {
7482
7312
  const fieldLength = fieldLengthOf(fieldLengthColumns, fieldIndex, internalId, fieldAvgLengths[fieldIndex]);
7483
7313
  score += (scoresAreZero ? 0 : computeBM25WithIDF(
7484
- termFrequencies[entry],
7314
+ termFrequencies[row],
7485
7315
  idf,
7486
7316
  fieldLength,
7487
7317
  fieldAvgLengths[fieldIndex],
@@ -7490,7 +7320,6 @@ function singleTermTopK(request) {
7490
7320
  )) * fieldBoosts[fieldIndex];
7491
7321
  scored2 = true;
7492
7322
  }
7493
- entry++;
7494
7323
  }
7495
7324
  if (!scored2) continue;
7496
7325
  totalMatched++;
@@ -7528,8 +7357,6 @@ function singleTermTopK(request) {
7528
7357
  }
7529
7358
  return { scored, totalMatched };
7530
7359
  }
7531
-
7532
- // src/core/partition/search.ts
7533
7360
  function globalDocFreqFor(docFreqs, term, fallback) {
7534
7361
  return Object.hasOwn(docFreqs, term) ? docFreqs[term] : fallback;
7535
7362
  }
@@ -7556,15 +7383,11 @@ function searchFulltext(state, params) {
7556
7383
  const totalDocs = globalStats?.totalDocuments ?? state.stats.totalDocuments;
7557
7384
  const avgFieldLengths = globalStats?.averageFieldLengths ?? state.stats.averageFieldLengths;
7558
7385
  const scoresAreZero = totalDocs === 0;
7559
- if (state.scoreBuffer === null) state.scoreBuffer = createScoreBuffer(state.docStore.internalIdCapacity());
7560
- const scoreBuffer = state.scoreBuffer;
7561
- beginScoring(scoreBuffer, state.docStore.internalIdCapacity());
7562
- const components = collectComponents ? /* @__PURE__ */ new Map() : null;
7563
7386
  const useIntersection = termMatch === "all" && queryTokens.length > 1;
7564
7387
  const fieldNames = state.fieldNameTable.names;
7565
7388
  const resolver = state.docStore.resolver();
7566
7389
  const fieldScoring = loadFieldScoring(state, fields, boost, avgFieldLengths, bm25Params);
7567
- const { searchable, boosts, averageLengths, lengthColumns, k1s, bs, boundPairs } = fieldScoring;
7390
+ const { searchable, boosts, averageLengths, lengthColumns, k1s, bs, boundPairs, nameRanks } = fieldScoring;
7568
7391
  const onePair = boundPairs.length === 2;
7569
7392
  const onlyK1 = boundPairs[0];
7570
7393
  const onlyB = boundPairs[1];
@@ -7581,6 +7404,10 @@ function searchFulltext(state, params) {
7581
7404
  return { scored: [], totalMatched: 0 };
7582
7405
  }
7583
7406
  const filterBitset = phraseMatches?.matched ?? params.filterBitset;
7407
+ if (state.scoreBuffer === null) state.scoreBuffer = createScoreBuffer(state.docStore.internalIdCapacity());
7408
+ const scoreBuffer = state.scoreBuffer;
7409
+ beginScoring(scoreBuffer, state.docStore.internalIdCapacity());
7410
+ const components = collectComponents ? /* @__PURE__ */ new Map() : null;
7584
7411
  function documentFrequency(token, list) {
7585
7412
  return globalStats ? globalDocFreqFor(globalStats.docFrequencies, token, list.docIdSet.size) : list.docIdSet.size;
7586
7413
  }
@@ -7589,25 +7416,35 @@ function searchFulltext(state, params) {
7589
7416
  for (let entry = 0; entry < rows.phrase.tokens.length; entry++) {
7590
7417
  idf += computeIDF(documentFrequency(rows.phrase.tokens[entry], rows.lists[entry]), totalDocs);
7591
7418
  }
7592
- for (let row = 0; row < rows.docIds.length; row++) {
7593
- const internalId = rows.docIds.values[row];
7594
- if (!bitsetHas(matched, internalId)) continue;
7595
- const fieldIndex = rows.fieldIndices.values[row];
7596
- const frequency = rows.frequencies.values[row];
7597
- const avgLen = averageLengths[fieldIndex];
7598
- const fieldLength = fieldLengthOf(lengthColumns, fieldIndex, internalId, avgLen);
7599
- const score = scoresAreZero ? 0 : computeBM25WithIDF(
7600
- frequency,
7601
- idf,
7602
- fieldLength,
7603
- avgLen,
7604
- onePair ? onlyK1 : k1s[fieldIndex],
7605
- onePair ? onlyB : bs[fieldIndex]
7419
+ for (let start = 0; start < rows.docIds.length; start += fieldRun.length) {
7420
+ const entries = orderRunByFieldName(
7421
+ rows.docIds.values,
7422
+ rows.fieldIndices.values,
7423
+ nameRanks,
7424
+ start,
7425
+ rows.docIds.length
7606
7426
  );
7607
- addScore(scoreBuffer, internalId, score * boosts[fieldIndex]);
7608
- if (components !== null) {
7609
- recordComponents(components, internalId, fieldNames[fieldIndex], rows.phrase.key, frequency, fieldLength, idf);
7610
- }
7427
+ for (let at = 0; at < fieldRun.length; at++) scorePhraseRow(rows, matched, entries[at], idf);
7428
+ }
7429
+ }
7430
+ function scorePhraseRow(rows, matched, row, idf) {
7431
+ const internalId = rows.docIds.values[row];
7432
+ if (!bitsetHas(matched, internalId)) return;
7433
+ const fieldIndex = rows.fieldIndices.values[row];
7434
+ const frequency = rows.frequencies.values[row];
7435
+ const avgLen = averageLengths[fieldIndex];
7436
+ const fieldLength = fieldLengthOf(lengthColumns, fieldIndex, internalId, avgLen);
7437
+ const score = scoresAreZero ? 0 : computeBM25WithIDF(
7438
+ frequency,
7439
+ idf,
7440
+ fieldLength,
7441
+ avgLen,
7442
+ onePair ? onlyK1 : k1s[fieldIndex],
7443
+ onePair ? onlyB : bs[fieldIndex]
7444
+ );
7445
+ addScore(scoreBuffer, internalId, score * boosts[fieldIndex]);
7446
+ if (components !== null) {
7447
+ recordComponents(components, internalId, fieldNames[fieldIndex], rows.phrase.key, frequency, fieldLength, idf);
7611
7448
  }
7612
7449
  }
7613
7450
  const groupContext = {
@@ -7630,13 +7467,23 @@ function searchFulltext(state, params) {
7630
7467
  const docFreq = documentFrequency(token, postingList);
7631
7468
  return { token, docFreq, idf: computeIDF(docFreq, totalDocs), postingList };
7632
7469
  }
7633
- function scorePostings(match, onlyScored) {
7470
+ function scorePostings(match, only) {
7634
7471
  const { docIds, termFrequencies, fieldNameIndices, deletedDocs, hasDeleted, count } = postingColumns(
7635
7472
  match.postingList
7636
7473
  );
7637
- if (!onlyScored && !hasDeleted && filterBitset === void 0 && components === null) {
7638
- for (let pi = 0; pi < count; pi++) {
7639
- const internalId = docIds[pi];
7474
+ let runStart = 0;
7475
+ let runEnd = 0;
7476
+ if (only === null && !hasDeleted && filterBitset === void 0 && components === null) {
7477
+ for (let at = 0; at < count; at++) {
7478
+ const internalId = docIds[at];
7479
+ let pi = at;
7480
+ if (at < runEnd) {
7481
+ pi = fieldRun.entries[at - runStart];
7482
+ } else if (at + 1 < count && docIds[at + 1] === internalId) {
7483
+ pi = orderRunByFieldName(docIds, fieldNameIndices, nameRanks, at, count)[0];
7484
+ runStart = at;
7485
+ runEnd = at + fieldRun.length;
7486
+ }
7640
7487
  const fieldIndex = fieldNameIndices[pi];
7641
7488
  if (searchable[fieldIndex] === 0) continue;
7642
7489
  const avgLen = averageLengths[fieldIndex];
@@ -7653,11 +7500,19 @@ function searchFulltext(state, params) {
7653
7500
  }
7654
7501
  return;
7655
7502
  }
7656
- for (let pi = 0; pi < count; pi++) {
7657
- const internalId = docIds[pi];
7503
+ for (let at = 0; at < count; at++) {
7504
+ const internalId = docIds[at];
7658
7505
  if (hasDeleted && deletedDocs.has(internalId)) continue;
7659
7506
  if (filterBitset && !bitsetHas(filterBitset, internalId)) continue;
7660
- if (onlyScored && !hasScore(scoreBuffer, internalId)) continue;
7507
+ if (only !== null && !bitsetHas(only, internalId)) continue;
7508
+ let pi = at;
7509
+ if (at < runEnd) {
7510
+ pi = fieldRun.entries[at - runStart];
7511
+ } else if (at + 1 < count && docIds[at + 1] === internalId) {
7512
+ pi = orderRunByFieldName(docIds, fieldNameIndices, nameRanks, at, count)[0];
7513
+ runStart = at;
7514
+ runEnd = at + fieldRun.length;
7515
+ }
7661
7516
  const fieldIndex = fieldNameIndices[pi];
7662
7517
  if (searchable[fieldIndex] === 0) continue;
7663
7518
  const termFrequency = termFrequencies[pi];
@@ -7685,10 +7540,10 @@ function searchFulltext(state, params) {
7685
7540
  }
7686
7541
  }
7687
7542
  }
7688
- function scoreGroup(group, onlyScored) {
7543
+ function scoreGroup(group, only) {
7689
7544
  if (group === null) return;
7690
7545
  for (const [internalId, contribution] of computeGroupContributions(groupContext, group, collectComponents)) {
7691
- if (onlyScored && !hasScore(scoreBuffer, internalId)) continue;
7546
+ if (only !== null && !bitsetHas(only, internalId)) continue;
7692
7547
  mergeGroupContribution(internalId, contribution);
7693
7548
  }
7694
7549
  }
@@ -7729,19 +7584,27 @@ function searchFulltext(state, params) {
7729
7584
  }
7730
7585
  resolved.push({ token: qt.token, matches, totalPostings, group: groupMatches });
7731
7586
  }
7732
- resolved.sort((a, b) => a.totalPostings - b.totalPostings);
7733
- for (let tokenIndex = 0; tokenIndex < resolved.length; tokenIndex++) {
7734
- const onlyScored = tokenIndex > 0;
7735
- for (const match of resolved[tokenIndex].matches) scorePostings(match, onlyScored);
7736
- scoreGroup(resolved[tokenIndex].group, onlyScored);
7587
+ let anchor = resolved[0];
7588
+ for (const term of resolved) if (term.totalPostings < anchor.totalPostings) anchor = term;
7589
+ for (const match of anchor.matches) scorePostings(match, null);
7590
+ scoreGroup(anchor.group, null);
7591
+ const anchorDocuments = createBitSet(state.docStore.internalIdCapacity());
7592
+ for (let index = 0; index < scoreBuffer.touchedCount; index++) {
7593
+ bitsetSet(anchorDocuments, scoreBuffer.touched[index]);
7594
+ }
7595
+ beginScoring(scoreBuffer, state.docStore.internalIdCapacity());
7596
+ components?.clear();
7597
+ for (const term of resolved) {
7598
+ for (const match of term.matches) scorePostings(match, anchorDocuments);
7599
+ scoreGroup(term.group, anchorDocuments);
7737
7600
  }
7738
7601
  } else {
7739
7602
  for (const qt of queryTokens) {
7740
7603
  const group = termGroupOf(termGroups, qt.token);
7741
7604
  for (const m of typoMatchesFor(state.invertedIdx, qt.token, group, exact, tolerance, prefixLength)) {
7742
- scorePostings(resolveMatch(m.token, m.postingList), false);
7605
+ scorePostings(resolveMatch(m.token, m.postingList), null);
7743
7606
  }
7744
- if (group !== void 0) scoreGroup(resolveGroupMatches(groupContext, group), false);
7607
+ if (group !== void 0) scoreGroup(resolveGroupMatches(groupContext, group), null);
7745
7608
  }
7746
7609
  }
7747
7610
  if (phraseMatches !== null) {
@@ -8027,7 +7890,7 @@ function mergePayloadFieldIndexes(target, payload, ordinalBase) {
8027
7890
  for (const entry of payload.geo) {
8028
7891
  let index = target.geoIndexes.get(entry.fieldPath);
8029
7892
  if (index === void 0) {
8030
- index = createGeoIndex();
7893
+ index = createLoadedGeoIndex();
8031
7894
  target.geoIndexes.set(entry.fieldPath, index);
8032
7895
  }
8033
7896
  for (let i = 0; i < entry.docIds.length; i++) {
@@ -8261,7 +8124,7 @@ function deserializePartition(state, data, clearFn, schema) {
8261
8124
  state.enumIndexes.set(path, idx);
8262
8125
  }
8263
8126
  for (const [path, entries] of Object.entries(data.fieldIndexes.geopoint)) {
8264
- const geoIdx = createGeoIndex();
8127
+ const geoIdx = createLoadedGeoIndex();
8265
8128
  const converted = entries.map((e) => ({
8266
8129
  lat: e.lat,
8267
8130
  lon: e.lon,
@@ -9665,22 +9528,22 @@ function createWriteLogRecorder() {
9665
9528
  const current = [null, null];
9666
9529
  return {
9667
9530
  open(owner) {
9668
- const log = { docIds: /* @__PURE__ */ new Set(), replaced: false };
9669
- current[owner] = log;
9531
+ const log2 = { docIds: /* @__PURE__ */ new Set(), replaced: false };
9532
+ current[owner] = log2;
9670
9533
  return {
9671
9534
  get partitionsReplaced() {
9672
- return log.replaced;
9535
+ return log2.replaced;
9673
9536
  },
9674
9537
  get pendingDocuments() {
9675
- return log.docIds.size;
9538
+ return log2.docIds.size;
9676
9539
  },
9677
9540
  takeWrittenDocIds() {
9678
- const taken = log.docIds;
9679
- log.docIds = /* @__PURE__ */ new Set();
9541
+ const taken = log2.docIds;
9542
+ log2.docIds = /* @__PURE__ */ new Set();
9680
9543
  return taken;
9681
9544
  },
9682
9545
  close() {
9683
- if (current[owner] === log) current[owner] = null;
9546
+ if (current[owner] === log2) current[owner] = null;
9684
9547
  }
9685
9548
  };
9686
9549
  },
@@ -9689,17 +9552,17 @@ function createWriteLogRecorder() {
9689
9552
  current[1]?.docIds.add(docId);
9690
9553
  },
9691
9554
  segmentWritten(segment) {
9692
- for (const log of current) {
9693
- if (log === null) continue;
9555
+ for (const log2 of current) {
9556
+ if (log2 === null) continue;
9694
9557
  for (const internalId of segment.docStore.allInternalIds()) {
9695
9558
  const docId = segment.docStore.getExternalId(internalId);
9696
- if (docId !== void 0) log.docIds.add(docId);
9559
+ if (docId !== void 0) log2.docIds.add(docId);
9697
9560
  }
9698
9561
  }
9699
9562
  },
9700
9563
  partitionsReplaced() {
9701
- for (const log of current) {
9702
- if (log !== null) log.replaced = true;
9564
+ for (const log2 of current) {
9565
+ if (log2 !== null) log2.replaced = true;
9703
9566
  }
9704
9567
  }
9705
9568
  };
@@ -11136,6 +10999,22 @@ async function runQueryAction(entry, action) {
11136
10999
  return { count: result.totalMatched };
11137
11000
  }
11138
11001
 
11002
+ // src/workers/vector-code.ts
11003
+ var vectorCode = codeLoader(() => import('./module-TCT66FWA.mjs'), "vector");
11004
+ var loadedVectorCode = vectorCode.loaded;
11005
+ var requireLoadedVectorCode = vectorCode.require;
11006
+ var loadVectorCode = vectorCode.load;
11007
+ var loadVectorCodeFor = vectorCode.loadFor;
11008
+
11009
+ // src/workers/schema-code.ts
11010
+ function loadSchemaCodeFor(schema) {
11011
+ const vectorCode2 = loadVectorCodeFor(schema);
11012
+ const geoCode2 = loadGeoCodeFor(schema);
11013
+ if (vectorCode2 === null) return geoCode2;
11014
+ if (geoCode2 === null) return vectorCode2;
11015
+ return Promise.all([vectorCode2, geoCode2]);
11016
+ }
11017
+
11139
11018
  // src/core/partition/frozen/doc-table.ts
11140
11019
  function createFrozenDocTable(idTable, lengthColumns, documents, tombstones) {
11141
11020
  const capacity = idTable.count;
@@ -12373,7 +12252,7 @@ function createFrozenSurfaceSlot(load, documents, tableOnDisk) {
12373
12252
  for (const spelling of spellings) target.subtract(spelling, 1);
12374
12253
  }
12375
12254
  }
12376
- function loaded3() {
12255
+ function loaded2() {
12377
12256
  if (registry === null) {
12378
12257
  const built = createSurfaceRegistry();
12379
12258
  const forms = load();
@@ -12392,10 +12271,10 @@ function createFrozenSurfaceSlot(load, documents, tableOnDisk) {
12392
12271
  return {
12393
12272
  heldBytes: () => table?.heldBytes() ?? 0,
12394
12273
  reader: {
12395
- candidatesForPrefix: (prefix) => table !== void 0 && waitingRemovals.length === 0 ? table.candidatesForPrefix(prefix) : loaded3().candidatesForPrefix(prefix),
12396
- stemChangedTotalFor: (token) => loaded3().stemChangedTotalFor(token),
12397
- size: () => loaded3().size(),
12398
- serialize: () => loaded3().serialize()
12274
+ candidatesForPrefix: (prefix) => table !== void 0 && waitingRemovals.length === 0 ? table.candidatesForPrefix(prefix) : loaded2().candidatesForPrefix(prefix),
12275
+ stemChangedTotalFor: (token) => loaded2().stemChangedTotalFor(token),
12276
+ size: () => loaded2().size(),
12277
+ serialize: () => loaded2().serialize()
12399
12278
  },
12400
12279
  tableStaysOnDisk() {
12401
12280
  return registry === null && tableOnDisk !== void 0;
@@ -12407,20 +12286,20 @@ function createFrozenSurfaceSlot(load, documents, tableOnDisk) {
12407
12286
  waitingRemovals.push(ordinal);
12408
12287
  },
12409
12288
  holdsAny() {
12410
- return loaded3().size() > 0;
12289
+ return loaded2().size() > 0;
12411
12290
  },
12412
12291
  holds(spelling) {
12413
- return loaded3().holds(spelling);
12292
+ return loaded2().holds(spelling);
12414
12293
  },
12415
12294
  subtractSpellings(ordinal, spellings) {
12416
12295
  uncounted ??= new Uint8Array(documents.count);
12417
12296
  uncounted[ordinal] = 1;
12418
12297
  if (spellings.length === 0) return;
12419
- const target = loaded3();
12298
+ const target = loaded2();
12420
12299
  for (const spelling of spellings) target.subtract(spelling, 1);
12421
12300
  },
12422
12301
  addKeptForms(target, mergedOrdinals, analysis) {
12423
- const source = loaded3();
12302
+ const source = loaded2();
12424
12303
  if (analysis === null) {
12425
12304
  addForms(target, source.serialize());
12426
12305
  return;
@@ -12822,7 +12701,7 @@ function storedFrequenciesOf(source) {
12822
12701
  function buildGeoReaders(entries) {
12823
12702
  const readers = /* @__PURE__ */ new Map();
12824
12703
  for (const entry of entries) {
12825
- const index = createGeoIndex();
12704
+ const index = createLoadedGeoIndex();
12826
12705
  for (let i = 0; i < entry.docIds.length; i++) {
12827
12706
  index.insert(entry.docIds[i], entry.latitudes[i], entry.longitudes[i]);
12828
12707
  }
@@ -12878,6 +12757,7 @@ function assembleFrozenSegment(segmentId, source, documentSource, sharedSnapshot
12878
12757
  sharedSnapshot,
12879
12758
  paged: pagedParts?.access ?? null,
12880
12759
  arrays: source,
12760
+ tombstones,
12881
12761
  invertedIdx: createFrozenInvertedReader(source.tokenTable, postingViews, counts),
12882
12762
  docStore,
12883
12763
  stats: buildStatsView(counts),
@@ -13661,7 +13541,7 @@ function indexFilterValue(indexes, ordinal, fieldPath, fieldType, value) {
13661
13541
  for (const entry of fieldType === "enum" ? [value] : value) index.insert(ordinal, entry);
13662
13542
  } else if (fieldType === "geopoint") {
13663
13543
  const point = value;
13664
- indexOf(indexes.geoIndexes, fieldPath, createGeoIndex).insert(ordinal, point.lat, point.lon);
13544
+ indexOf(indexes.geoIndexes, fieldPath, createLoadedGeoIndex).insert(ordinal, point.lat, point.lon);
13665
13545
  }
13666
13546
  }
13667
13547
  function refuseRepeatedDocIds(documents) {
@@ -13812,7 +13692,7 @@ async function attachSegments(entry, action) {
13812
13692
  growPartitionsTo(entry.manager, segment.partitionId);
13813
13693
  const surfaceForms = segment.survivingSurfaceForms;
13814
13694
  const spellings = surfaceForms === void 0 ? void 0 : NO_REMOVED_SPELLINGS;
13815
- const frozen = isPagedSnapshot(segment.snapshot) ? (await import('./module-M4JNBV6V.mjs')).createPagedFrozenSegment(segment.snapshot) : createSharedFrozenSegment(segment.snapshot, surfaceForms);
13695
+ const frozen = isPagedSnapshot(segment.snapshot) ? (await import('./module-NIYMEA5R.mjs')).createPagedFrozenSegment(segment.snapshot) : createSharedFrozenSegment(segment.snapshot, surfaceForms);
13816
13696
  for (const docId of segment.tombstonedDocIds ?? []) frozen.tombstoneDocument(docId, spellings);
13817
13697
  entry.manager.attachFrozenSegment(segment.partitionId, frozen);
13818
13698
  }
@@ -13867,7 +13747,7 @@ function runSegmentAction(entry, action) {
13867
13747
  case "attachSegments":
13868
13748
  return attachSegments(entry, action);
13869
13749
  case "adoptDiskSegments":
13870
- return import('./module-M4JNBV6V.mjs').then((code) => code.adoptSegmentsOnWorker(entry.manager, action));
13750
+ return import('./module-NIYMEA5R.mjs').then((code) => code.adoptSegmentsOnWorker(entry.manager, action));
13871
13751
  case "compactSegments": {
13872
13752
  const partition = requireComposite(entry, action.indexName, action.partitionId, "compact");
13873
13753
  return mergeFrozenSegments(
@@ -13901,47 +13781,6 @@ function runSegmentAction(entry, action) {
13901
13781
  }
13902
13782
  }
13903
13783
 
13904
- // src/workers/vector-code.ts
13905
- var VECTOR_TYPE_NAME = "vector";
13906
- var loaded2 = null;
13907
- var loading2 = null;
13908
- function loadedVectorCode() {
13909
- return loaded2;
13910
- }
13911
- function requireLoadedVectorCode() {
13912
- if (loaded2 === null) throw new Error("The engine reached vector code before it loaded that code");
13913
- return loaded2;
13914
- }
13915
- function loadVectorCode() {
13916
- if (loaded2 !== null) return Promise.resolve(loaded2);
13917
- if (loading2 === null) {
13918
- loading2 = import('./module-EC3FYW7N.mjs').then(
13919
- (code) => {
13920
- loaded2 = code;
13921
- return code;
13922
- },
13923
- (err) => {
13924
- loading2 = null;
13925
- throw err;
13926
- }
13927
- );
13928
- }
13929
- return loading2;
13930
- }
13931
- function mayDeclareVectorField(schema, depth) {
13932
- if (!isPlainObject(schema) || depth > MAX_NESTING_DEPTH + 1) return false;
13933
- for (const type of Object.values(schema)) {
13934
- if (typeof type === "string" ? type.includes(VECTOR_TYPE_NAME) : mayDeclareVectorField(type, depth + 1)) {
13935
- return true;
13936
- }
13937
- }
13938
- return false;
13939
- }
13940
- function loadVectorCodeFor(schema) {
13941
- if (loaded2 !== null || !mayDeclareVectorField(schema, 1)) return null;
13942
- return loadVectorCode();
13943
- }
13944
-
13945
13784
  // src/workers/vector-copies.ts
13946
13785
  function createHeldVectorCopies() {
13947
13786
  return { searchers: /* @__PURE__ */ new Map(), fields: /* @__PURE__ */ new Map(), builds: /* @__PURE__ */ new Map() };
@@ -14147,8 +13986,8 @@ function createDirectExecutor(options) {
14147
13986
  );
14148
13987
  }
14149
13988
  case "createIndex": {
14150
- const loading3 = loadVectorCodeFor(action.config.schema);
14151
- if (loading3 !== null) await loading3;
13989
+ const loading2 = loadSchemaCodeFor(action.config.schema);
13990
+ if (loading2 !== null) await loading2;
14152
13991
  const language = getLanguage(action.config.language ?? "english");
14153
13992
  const manager = addIndex(
14154
13993
  action.indexName,
@@ -14331,7 +14170,7 @@ var TEXT_REBUILD_SWITCH_BACKLOG_DOCUMENTS = 1e3;
14331
14170
  // src/partitioning/rewrite-spill-of.ts
14332
14171
  async function rewriteSpillOf(storage, manager, target) {
14333
14172
  if (storage === void 0 || (target?.config ?? manager.config).textStorage !== "disk") return null;
14334
- const { openRewriteSpill } = await import('./module-M4JNBV6V.mjs');
14173
+ const { openRewriteSpill } = await import('./module-NIYMEA5R.mjs');
14335
14174
  return openRewriteSpill(storage, manager, target);
14336
14175
  }
14337
14176
 
@@ -14421,16 +14260,16 @@ async function rebuildTextIndexes(manager, hooks, target) {
14421
14260
  const partialWordAnalysis = target === void 0 ? manager.partialWordAnalysis : target.partialWordAnalysis;
14422
14261
  const spill = await rewriteSpillOf(hooks.rewriteStorage?.(), manager, target);
14423
14262
  while (hooks.isCurrent()) {
14424
- const log = manager.openWriteLog();
14263
+ const log2 = manager.openWriteLog();
14425
14264
  let swapped = false;
14426
14265
  try {
14427
- swapped = await rebuildOnce({ manager, log, hooks, language, partialWordAnalysis, options, spill });
14266
+ swapped = await rebuildOnce({ manager, log: log2, hooks, language, partialWordAnalysis, options, spill });
14428
14267
  if (swapped) {
14429
14268
  hooks.onRewriteSpill?.(spill);
14430
14269
  return true;
14431
14270
  }
14432
14271
  } finally {
14433
- log.close();
14272
+ log2.close();
14434
14273
  if (!swapped) await spill?.abandon();
14435
14274
  }
14436
14275
  }
@@ -14643,91 +14482,6 @@ function createAnalysisRebuildCoordinator(config, deps) {
14643
14482
  };
14644
14483
  }
14645
14484
 
14646
- // src/engine/durability-config.ts
14647
- var WAL_ONLY_FIELDS = ["directory", "mode", "flushIntervalMs", "segmentMaxBytes", "compactionThreshold"];
14648
- function configError(message) {
14649
- return new NarsilError(ErrorCodes.CONFIG_INVALID, message);
14650
- }
14651
- function requireKnob(name, value, minimum) {
14652
- if (value === void 0) {
14653
- return;
14654
- }
14655
- if (typeof value !== "number" || !Number.isFinite(value) || value < minimum) {
14656
- throw configError(`durability.${name} must be a finite number of at least ${minimum}, got ${String(value)}`);
14657
- }
14658
- }
14659
- function requireValidDurabilityConfig(durability) {
14660
- if (durability.tier !== void 0 && durability.tier !== "wal" && durability.tier !== "snapshot") {
14661
- throw configError(`durability.tier must be "wal" or "snapshot", got "${String(durability.tier)}"`);
14662
- }
14663
- if (durability.mode !== void 0 && durability.mode !== "sync" && durability.mode !== "async") {
14664
- throw configError(`durability.mode must be "sync" or "async", got "${String(durability.mode)}"`);
14665
- }
14666
- requireKnob("checkpointIntervalMs", durability.checkpointIntervalMs, 0);
14667
- requireKnob("checkpointMutationThreshold", durability.checkpointMutationThreshold, 1);
14668
- requireKnob("flushIntervalMs", durability.flushIntervalMs, 0);
14669
- requireKnob("segmentMaxBytes", durability.segmentMaxBytes, 1);
14670
- if (durability.segmentMaxBytes !== void 0 && durability.segmentMaxBytes > MAX_FILE_BYTES) {
14671
- throw configError(
14672
- `durability.segmentMaxBytes must be at most ${MAX_FILE_BYTES}, the largest file that every implementation reads, got ${durability.segmentMaxBytes}`
14673
- );
14674
- }
14675
- requireKnob("compactionThreshold", durability.compactionThreshold, 1);
14676
- if (durability.tier === "snapshot") {
14677
- for (const field of WAL_ONLY_FIELDS) {
14678
- if (durability[field] !== void 0) {
14679
- throw configError(
14680
- `durability.${field} applies to the write-ahead log tier only and cannot combine with durability.tier "snapshot"`
14681
- );
14682
- }
14683
- }
14684
- }
14685
- }
14686
- function filesystemBackedDirectory(config) {
14687
- const adapterDirectory = config.persistence?.directory;
14688
- if (adapterDirectory !== void 0 && adapterDirectory.trim().length > 0) {
14689
- return adapterDirectory;
14690
- }
14691
- return null;
14692
- }
14693
- function resolveDurabilityTier(config) {
14694
- const filesystemDirectory = filesystemBackedDirectory(config);
14695
- if (config.durability) {
14696
- requireValidDurabilityConfig(config.durability);
14697
- }
14698
- if (config.durability?.tier === "snapshot") {
14699
- if (config.persistence === void 0) {
14700
- throw configError(
14701
- "Snapshot durability persists through a persistence adapter. Configure persistence, or remove durability.tier"
14702
- );
14703
- }
14704
- return { kind: "snapshot", config: { ...config.durability }, adapter: config.persistence };
14705
- }
14706
- if (config.durability) {
14707
- if (config.durability.directory !== void 0 && config.durability.directory.trim().length > 0) {
14708
- return { kind: "wal", config: { ...config.durability } };
14709
- }
14710
- if (filesystemDirectory !== null) {
14711
- return { kind: "wal", config: { ...config.durability, directory: filesystemDirectory } };
14712
- }
14713
- if (config.persistence !== void 0) {
14714
- throw configError(
14715
- "WAL durability requires a filesystem directory, but the configured persistence adapter is not filesystem-backed. Use a filesystem persistence adapter or set durability.directory"
14716
- );
14717
- }
14718
- throw configError(
14719
- "Durability requires a directory. Set durability.directory explicitly, or configure a filesystem persistence adapter"
14720
- );
14721
- }
14722
- if (config.persistence === void 0) {
14723
- return null;
14724
- }
14725
- if (filesystemDirectory !== null) {
14726
- return { kind: "wal", config: { directory: filesystemDirectory } };
14727
- }
14728
- return { kind: "snapshot", config: {}, adapter: config.persistence };
14729
- }
14730
-
14731
14485
  // src/engine/array-positions.ts
14732
14486
  function holdsStringArrayField(schema) {
14733
14487
  return schemaFieldsOf(schema).some((field) => field.base === "string[]");
@@ -15019,12 +14773,12 @@ function recoveryFailure(metadata, err) {
15019
14773
  });
15020
14774
  }
15021
14775
  async function createIndexFromMetadata(deps, metadata, loadData) {
15022
- const loadingVectorCode = loadData ? loadVectorCodeFor(metadata.schema) : null;
15023
- if (loadingVectorCode !== null) await loadingVectorCode;
14776
+ const loadingSchemaCode = loadData ? loadSchemaCodeFor(metadata.schema) : null;
14777
+ if (loadingSchemaCode !== null) await loadingSchemaCode;
15024
14778
  const existing = deps.indexRegistry.get(metadata.indexName);
15025
14779
  if (existing !== void 0) {
15026
14780
  if ((metadata.analysisGeneration ?? 0) > existing.analysisGeneration) {
15027
- const { adoptSavedAnalysis } = await import('./analysis-change-IXWPXXJJ.mjs');
14781
+ const { adoptSavedAnalysis } = await import('./analysis-change-435CUEPZ.mjs');
15028
14782
  adoptSavedAnalysis(deps.executor.getManager(metadata.indexName), existing, metadata);
15029
14783
  }
15030
14784
  if (loadData && deps.executor.getManager(metadata.indexName) === void 0) {
@@ -15080,7 +14834,8 @@ async function createIndexFromMetadata(deps, metadata, loadData) {
15080
14834
  analysisGeneration: metadata.analysisGeneration ?? 0,
15081
14835
  pendingAnalysis: metadata.pendingAnalysis ?? null,
15082
14836
  durableAnalysis: null,
15083
- sync: metadata.sync?.enabled === true ? (await import('./sync-state-P5XG6LTQ.mjs')).syncStateOfMetadata(metadata) : null
14837
+ sync: metadata.sync?.enabled === true ? (await import('./sync-state-P5XG6LTQ.mjs')).syncStateOfMetadata(metadata) : null,
14838
+ querySuggestions: metadata.querySuggestions ?? null
15084
14839
  });
15085
14840
  if (loadData) await deps.indexState().registerOpen(metadata.indexName);
15086
14841
  else deps.indexState().registerClosed(metadata.indexName);
@@ -16393,10 +16148,10 @@ async function replicateToWorkers(state, action) {
16393
16148
  }
16394
16149
  if (!copiesWillReceive(state, action.indexName)) return;
16395
16150
  const detached = detachCallerDocuments(state, action);
16396
- const loading3 = state.copyLoadBuffers.get(action.indexName);
16397
- if (loading3 !== void 0) {
16151
+ const loading2 = state.copyLoadBuffers.get(action.indexName);
16152
+ if (loading2 !== void 0) {
16398
16153
  queueForCopies(state, detached);
16399
- if (loading3.length % LOAD_BUFFER_YIELD_INTERVAL === 0) await yieldToEventLoop2();
16154
+ if (loading2.length % LOAD_BUFFER_YIELD_INTERVAL === 0) await yieldToEventLoop2();
16400
16155
  return;
16401
16156
  }
16402
16157
  const queue = state.replicationQueues.get(action.indexName);
@@ -16407,9 +16162,9 @@ async function replicateToWorkers(state, action) {
16407
16162
  }
16408
16163
  function queueForCopies(state, action) {
16409
16164
  if (!("indexName" in action)) return;
16410
- const loading3 = state.copyLoadBuffers.get(action.indexName);
16411
- if (loading3 !== void 0) {
16412
- loading3.push(action);
16165
+ const loading2 = state.copyLoadBuffers.get(action.indexName);
16166
+ if (loading2 !== void 0) {
16167
+ loading2.push(action);
16413
16168
  return;
16414
16169
  }
16415
16170
  if (state.workerPool === null || !state.scaledOutIndexes.has(action.indexName)) return;
@@ -17147,7 +16902,7 @@ async function startPool(state) {
17147
16902
  );
17148
16903
  }
17149
16904
  eligibleIndexNames(state);
17150
- const [factory, { createWorkerPool }] = await Promise.all([createWorkerFactory(), import('./pool-WCGDZHJP.mjs')]);
16905
+ const [factory, { createWorkerPool }] = await Promise.all([createWorkerFactory(), import('./pool-3JLET5RO.mjs')]);
17151
16906
  let started = null;
17152
16907
  const pool = createWorkerPool({
17153
16908
  count: state.keywordWorkerCount + state.longQueryWorkerCount,
@@ -17786,10 +17541,10 @@ function createWorkerOrchestrator(config, executor, indexRegistry, callbacks, ve
17786
17541
  stopRequestThreads: () => stopRequestThreads(state),
17787
17542
  desyncIndex: (indexName) => {
17788
17543
  state.desyncedIndexes.add(indexName);
17789
- const loading3 = state.copyTransitions.get(indexName);
17544
+ const loading2 = state.copyTransitions.get(indexName);
17790
17545
  const wasScaledOut = state.scaledOutIndexes.delete(indexName);
17791
17546
  if (wasScaledOut) withdrawCopies(indexName);
17792
- return wasScaledOut || loading3 !== void 0 && loading3.kind !== "drop";
17547
+ return wasScaledOut || loading2 !== void 0 && loading2.kind !== "drop";
17793
17548
  },
17794
17549
  async releaseIndexCopies(indexName) {
17795
17550
  const hold = state.copyReleaseHolds.get(indexName);
@@ -17838,18 +17593,18 @@ async function emitWriteEventAfter(source, indexName, write) {
17838
17593
  // src/engine/core.ts
17839
17594
  async function createEngineCore(config, hooks, capacityScope = "index") {
17840
17595
  validateWorkerConfig(config?.workers, config?.lifecycle);
17841
- const rerankSettings = config?.rerankTimeout === void 0 && config?.maxRerankWindow === void 0 ? { timeoutMs: DEFAULT_RERANK_TIMEOUT_MS, maxWindow: DEFAULT_MAX_RERANK_WINDOW } : (await import('./runtime-3EW2AGB6.mjs')).resolveRerankSettings(config);
17596
+ const rerankSettings = config?.rerankTimeout === void 0 && config?.maxRerankWindow === void 0 ? { timeoutMs: DEFAULT_RERANK_TIMEOUT_MS, maxWindow: DEFAULT_MAX_RERANK_WINDOW } : (await import('./runtime-OTAGEFQW.mjs')).resolveRerankSettings(config);
17842
17597
  const eventHandlers = eventHandlersOf(config?.events);
17843
17598
  const vectorWorkerCount = splitWorkerBudget(resolveWorkerCount(config?.workers?.count)).vector;
17844
17599
  const vectorCopyPolicy = {
17845
17600
  enabled: (config?.workers?.enabled ?? workersEnabledByDefault()) && vectorWorkerCount > 0,
17846
17601
  count: vectorWorkerCount
17847
17602
  };
17848
- const durabilityTier = config !== void 0 ? resolveDurabilityTier(config) : null;
17603
+ const durabilityTier = config !== void 0 && (config.durability || config.persistence !== void 0) ? (await import('./durability-config-TIYKW6XX.mjs')).resolveDurabilityTier(config) : null;
17849
17604
  if (config?.lifecycle !== void 0 && durabilityTier === null) {
17850
17605
  throw new NarsilError(ErrorCodes.CONFIG_INVALID, "Index lifecycle settings require durability");
17851
17606
  }
17852
- const durabilityWiring = durabilityTier === null ? null : await import('./durability-wiring-GL4A7KDV.mjs');
17607
+ const durabilityWiring = durabilityTier === null ? null : await import('./durability-wiring-A7BVG2DW.mjs');
17853
17608
  const filesystemDurability = durabilityTier?.kind === "wal";
17854
17609
  const executor = createDirectExecutor({
17855
17610
  vectorWorkerCopies: vectorCopyPolicy,
@@ -18035,7 +17790,7 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
18035
17790
  requireManager,
18036
17791
  resumeChange: async (indexName) => {
18037
17792
  if ((indexRegistry.get(indexName)?.pendingAnalysis ?? null) === null) return;
18038
- await (await import('./analysis-change-entry-FCSHFQSS.mjs')).resumeChangeOf(engineCore, indexName);
17793
+ await (await import('./analysis-change-entry-HZXKPPGV.mjs')).resumeChangeOf(engineCore, indexName);
18039
17794
  },
18040
17795
  onClose: hooks?.onIndexClose,
18041
17796
  onOpen: (indexName) => {
@@ -18095,6 +17850,7 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
18095
17850
  orchestrator,
18096
17851
  rebalanceRouter,
18097
17852
  rebalancingIndexes,
17853
+ restoresInFlight: /* @__PURE__ */ new Map(),
18098
17854
  waqMap,
18099
17855
  guardShutdown,
18100
17856
  requireIndex,
@@ -18119,7 +17875,7 @@ async function startEngineCore(core, config) {
18119
17875
  checkHeapAfterRecovery(core);
18120
17876
  }
18121
17877
  if (core.invalidation) await core.invalidation.start();
18122
- if (core.durability) await (await import('./analysis-change-entry-FCSHFQSS.mjs')).resumeEveryChange(core);
17878
+ if (core.durability) await (await import('./analysis-change-entry-HZXKPPGV.mjs')).resumeEveryChange(core);
18123
17879
  if (config?.lifecycle === void 0) await core.analysisRebuild.reviewStaleIndexes();
18124
17880
  } catch (err) {
18125
17881
  await core.durability?.manager.shutdown().catch(() => void 0);
@@ -18129,6 +17885,7 @@ async function startEngineCore(core, config) {
18129
17885
  }
18130
17886
  async function shutdownEngine(core) {
18131
17887
  const { executor, durability, indexRegistry, eventHandlers, orchestrator } = core;
17888
+ await core.querySuggestionHooks?.shutdown();
18132
17889
  core.indexState.dispose();
18133
17890
  if (durability) {
18134
17891
  await durability.manager.shutdown();
@@ -18157,7 +17914,7 @@ async function shutdownEngine(core) {
18157
17914
  }
18158
17915
  }
18159
17916
  if (core.rerankAdapters.size > 0) {
18160
- await (await import('./runtime-3EW2AGB6.mjs')).shutdownRerankAdapters(core.rerankAdapters);
17917
+ await (await import('./runtime-OTAGEFQW.mjs')).shutdownRerankAdapters(core.rerankAdapters);
18161
17918
  }
18162
17919
  await orchestrator.shutdown();
18163
17920
  await executor.shutdown();
@@ -18333,7 +18090,8 @@ function indexConfigurationOf(entry) {
18333
18090
  synonyms,
18334
18091
  entry.analysisGeneration
18335
18092
  );
18336
- return entry.sync === null ? payload : { ...payload, syncEpoch: entry.sync.epoch };
18093
+ const withSuggestions = { ...payload, ...entry.querySuggestions };
18094
+ return entry.sync === null ? withSuggestions : { ...withSuggestions, syncEpoch: entry.sync.epoch };
18337
18095
  }
18338
18096
  function requireConfigurationWithinSizeLimit(config, language) {
18339
18097
  const adapter = config.embedding?.adapter;
@@ -18420,8 +18178,8 @@ async function announceIndexDropped(core, name, config) {
18420
18178
  }
18421
18179
  async function createEngineIndex(core, config, name, requestedConfig, creation = {}) {
18422
18180
  const { indexUuid, adapterBinding = "required", appliesCreationLimits = false } = creation;
18423
- const loadingVectorCode = loadVectorCodeFor(requestedConfig.schema);
18424
- if (loadingVectorCode !== null) await loadingVectorCode;
18181
+ const loadingSchemaCode = loadSchemaCodeFor(requestedConfig.schema);
18182
+ if (loadingSchemaCode !== null) await loadingSchemaCode;
18425
18183
  core.guardShutdown();
18426
18184
  validateIndexName(name);
18427
18185
  if (core.indexRegistry.has(name)) {
@@ -18500,6 +18258,7 @@ async function createEngineIndex(core, config, name, requestedConfig, creation =
18500
18258
  const language = getLanguage(indexConfig.language ?? "english");
18501
18259
  if (appliesCreationLimits) requireConfigurationWithinSizeLimit(indexConfig, language);
18502
18260
  const synonyms = prepareConfiguredSynonyms(configured, language, appliesCreationLimits);
18261
+ await core.querySuggestionHooks?.beforeCreate(name);
18503
18262
  core.executor.createIndex(name, indexConfig, language, false, synonyms?.lookup ?? null);
18504
18263
  core.indexRegistry.set(name, {
18505
18264
  config: indexConfig,
@@ -18517,7 +18276,8 @@ async function createEngineIndex(core, config, name, requestedConfig, creation =
18517
18276
  analysisGeneration: 0,
18518
18277
  pendingAnalysis: null,
18519
18278
  durableAnalysis: null,
18520
- sync: null
18279
+ sync: null,
18280
+ querySuggestions: creation.querySuggestions ?? null
18521
18281
  });
18522
18282
  await core.indexState.registerOpen(name);
18523
18283
  if (core.durability) {
@@ -18530,10 +18290,11 @@ async function dropEngineIndex(core, name) {
18530
18290
  const entry = core.requireIndex(name);
18531
18291
  const changeRecorded = () => entry.pendingAnalysis !== null || entry.durableAnalysis !== null;
18532
18292
  const abandonChange = async () => {
18533
- await (await import('./analysis-change-entry-FCSHFQSS.mjs')).abandonChangeOf(core, name);
18293
+ await (await import('./analysis-change-entry-HZXKPPGV.mjs')).abandonChangeOf(core, name);
18534
18294
  };
18535
18295
  if (changeRecorded()) await abandonChange();
18536
18296
  await core.indexState.drop(name, async () => {
18297
+ await core.querySuggestionHooks?.beforeDrop(name);
18537
18298
  await core.analysisRebuild.abandon(name);
18538
18299
  if (changeRecorded()) await abandonChange();
18539
18300
  await core.orchestrator.closeIndex(name);
@@ -18551,6 +18312,7 @@ async function dropEngineIndex(core, name) {
18551
18312
  core.analysisRebuild.clearStale(name);
18552
18313
  if (entry.sync !== null) emitSyncChange(core.indexRegistry, { kind: "dropped", indexName: name });
18553
18314
  });
18315
+ await core.querySuggestionHooks?.afterDrop(name);
18554
18316
  await runLifecycleHook(core, "onIndexDrop", { indexName: name, config: entry.config });
18555
18317
  }
18556
18318
  function registerEngineEmbeddingAdapter(core, name, adapter) {
@@ -20163,7 +19925,7 @@ async function updateDocumentBatch(ctx, indexName, updates, options) {
20163
19925
  // src/engine/sync-epoch.ts
20164
19926
  async function holdSyncEpochChange(core, indexName) {
20165
19927
  if ((core.indexRegistry.get(indexName)?.sync ?? null) === null) return () => void 0;
20166
- return (await import('./operations-WVYLF72Q.mjs')).holdRenewedSyncEpoch(core, indexName);
19928
+ return (await import('./operations-OJ3BXS55.mjs')).holdRenewedSyncEpoch(core, indexName);
20167
19929
  }
20168
19930
  async function withRenewedSyncEpoch(core, indexName, change) {
20169
19931
  const release = await holdSyncEpochChange(core, indexName);
@@ -20255,6 +20017,9 @@ var engineCores = /* @__PURE__ */ new WeakMap();
20255
20017
  function bindEngineCore(engine, core) {
20256
20018
  engineCores.set(engine, core);
20257
20019
  }
20020
+ function engineCoreOf(engine) {
20021
+ return engineCores.get(engine);
20022
+ }
20258
20023
 
20259
20024
  // src/narsil/portability.ts
20260
20025
  function portabilityOperations(core, config, engine) {
@@ -20268,7 +20033,23 @@ function portabilityOperations(core, config, engine) {
20268
20033
  release();
20269
20034
  }
20270
20035
  }
20271
- const restoresInFlight = /* @__PURE__ */ new Map();
20036
+ function queueRestore(indexName, data) {
20037
+ const { restoresInFlight } = core;
20038
+ const previous = restoresInFlight.get(indexName) ?? Promise.resolve();
20039
+ const restored = previous.then(async () => {
20040
+ const { runRestore } = await import('./restore-queue-G3RQGL3Y.mjs');
20041
+ await runRestore(core, restoreHost, indexName, data, engine());
20042
+ });
20043
+ const settled2 = restored.then(
20044
+ () => void 0,
20045
+ () => void 0
20046
+ );
20047
+ restoresInFlight.set(indexName, settled2);
20048
+ void settled2.then(() => {
20049
+ if (restoresInFlight.get(indexName) === settled2) restoresInFlight.delete(indexName);
20050
+ });
20051
+ return restored;
20052
+ }
20272
20053
  const restoreHost = {
20273
20054
  getVectorFieldPaths,
20274
20055
  announceIndexCreated: (name, restoredConfig) => announceIndexCreated(core, name, restoredConfig),
@@ -20285,26 +20066,23 @@ function portabilityOperations(core, config, engine) {
20285
20066
  };
20286
20067
  }
20287
20068
  return {
20288
- snapshot(indexName) {
20069
+ snapshot(indexName, options) {
20289
20070
  return withOpenIndex2(indexName, async () => {
20290
- const { createSnapshot } = await import('./snapshot-DN3CRVUQ.mjs');
20291
- return createSnapshot(snapshotDepsOf(indexName));
20071
+ const { createSnapshot } = await import('./snapshot-VEQNIE6C.mjs');
20072
+ return createSnapshot(snapshotDepsOf(indexName), options?.queryHistory === true ? core : null);
20292
20073
  });
20293
20074
  },
20294
20075
  async restore(indexName, data) {
20295
20076
  core.guardShutdown();
20296
20077
  validateIndexName(indexName);
20297
- const restored = import('./restore-queue-TYIGDL5L.mjs').then(
20298
- ({ queueRestore }) => queueRestore(core, restoreHost, restoresInFlight, indexName, data)
20299
- );
20300
- await emitWriteEventAfter(core, indexName, restored);
20078
+ await emitWriteEventAfter(core, indexName, queueRestore(indexName, data));
20301
20079
  core.heapPressureNotifier.check(indexName);
20302
20080
  },
20303
20081
  exportDocuments(indexName) {
20304
20082
  return withOpenIndex2(indexName, async () => {
20305
20083
  const [{ checkpointForArchive }, { documentExportStream }] = await Promise.all([
20306
- import('./snapshot-DN3CRVUQ.mjs'),
20307
- import('./write-WAWAFGKQ.mjs')
20084
+ import('./snapshot-VEQNIE6C.mjs'),
20085
+ import('./write-2EVMZWDE.mjs')
20308
20086
  ]);
20309
20087
  const header = indexConfigurationOf(core.requireIndex(indexName));
20310
20088
  return documentExportStream(header, await checkpointForArchive(snapshotDepsOf(indexName)));
@@ -20312,7 +20090,7 @@ function portabilityOperations(core, config, engine) {
20312
20090
  },
20313
20091
  importDocumentExport(indexName, data) {
20314
20092
  core.guardShutdown();
20315
- const imported = import('./import-YI5GNB4H.mjs').then(
20093
+ const imported = import('./import-DXYB6756.mjs').then(
20316
20094
  ({ readDocumentExport }) => readDocumentExport(engine(), indexName, data)
20317
20095
  );
20318
20096
  return emitWriteEventAfter(core, indexName, imported);
@@ -21619,7 +21397,7 @@ function requireCursorDepth(cursor, signature, binding) {
21619
21397
  }
21620
21398
  function hybridSearchOf(params, context, limit, offset, cursorDepth) {
21621
21399
  if ((params.hybrid?.depth ?? null) === null) return executeHybridSearch(params, context, limit, offset, cursorDepth);
21622
- return import('./runtime-3EW2AGB6.mjs').then(
21400
+ return import('./runtime-OTAGEFQW.mjs').then(
21623
21401
  (runtime) => runtime.searchFixedDepthHybrid(params, context, { cursorDepth: cursorDepth ?? 0, offset, limit }, runtimeHost)
21624
21402
  );
21625
21403
  }
@@ -21629,7 +21407,7 @@ function executeQuery(request, callerContext) {
21629
21407
  if (loadingPhraseCode === null) return runQuery(request, callerContext);
21630
21408
  return loadingPhraseCode.then(() => runQuery(request, callerContext));
21631
21409
  }
21632
- return import('./runtime-3EW2AGB6.mjs').then(
21410
+ return import('./runtime-OTAGEFQW.mjs').then(
21633
21411
  (runtime) => runtime.executeRerankedQuery(request, callerContext, executeQuery, runtimeHost)
21634
21412
  );
21635
21413
  }
@@ -22028,7 +21806,7 @@ async function runEngineQuery(core, indexName, params, options) {
22028
21806
  const manager = core.requireManager(indexName);
22029
21807
  const scoped = scopedParams(params, options);
22030
21808
  await core.pluginRegistry.runHook("beforeSearch", { indexName, params: scoped });
22031
- const rerank = scoped.rerank === void 0 ? void 0 : await import('./runtime-3EW2AGB6.mjs');
21809
+ const rerank = scoped.rerank === void 0 ? void 0 : await import('./runtime-OTAGEFQW.mjs');
22032
21810
  const resolvedParams = await resolveVectorText(
22033
21811
  rerank === void 0 ? scoped : rerank.withRerankQueryText(scoped),
22034
21812
  entry.embeddingAdapter,
@@ -22150,8 +21928,8 @@ async function runEngineListDocuments(core, indexName, params, partitionIds) {
22150
21928
  // src/narsil/sync.ts
22151
21929
  function syncOperations(core) {
22152
21930
  return {
22153
- updateSync: async (indexName, setting) => (await import('./methods-LMUTS7OI.mjs')).updateSyncOf(core, indexName, setting),
22154
- getSync: async (indexName) => (await import('./methods-LMUTS7OI.mjs')).syncOf(core, indexName)
21931
+ updateSync: async (indexName, setting) => (await import('./methods-KTQCSIN4.mjs')).updateSyncOf(core, indexName, setting),
21932
+ getSync: async (indexName) => (await import('./methods-KTQCSIN4.mjs')).syncOf(core, indexName)
22155
21933
  };
22156
21934
  }
22157
21935
 
@@ -22333,7 +22111,7 @@ function createNarsilFromCore(core, config) {
22333
22111
  const entry = requireIndex(indexName);
22334
22112
  await withOpenIndexWrite(indexName, async () => {
22335
22113
  if (entry.pendingAnalysis === null) return core.analysisRebuild.rebuild(indexName);
22336
- return (await import('./analysis-change-IXWPXXJJ.mjs')).resumeAnalysisChange(core, indexName);
22114
+ return (await import('./analysis-change-435CUEPZ.mjs')).resumeAnalysisChange(core, indexName);
22337
22115
  });
22338
22116
  },
22339
22117
  async changeAnalysis(indexName, change) {
@@ -22341,7 +22119,7 @@ function createNarsilFromCore(core, config) {
22341
22119
  requireIndex(indexName);
22342
22120
  const changed = withOpenIndex2(
22343
22121
  indexName,
22344
- async () => (await import('./analysis-change-IXWPXXJJ.mjs')).changeIndexAnalysis(core, indexName, change)
22122
+ async () => (await import('./analysis-change-435CUEPZ.mjs')).changeIndexAnalysis(core, indexName, change)
22345
22123
  );
22346
22124
  await emitWriteEventAfter(core, indexName, changed);
22347
22125
  },
@@ -22376,7 +22154,7 @@ function createNarsilFromCore(core, config) {
22376
22154
  const rebalanced = withOpenIndex2(
22377
22155
  indexName,
22378
22156
  () => withRenewedSyncEpoch(core, indexName, async () => {
22379
- const { executeRebalance } = await import('./analysis-change-IXWPXXJJ.mjs');
22157
+ const { executeRebalance } = await import('./analysis-change-435CUEPZ.mjs');
22380
22158
  const running = executeRebalance(requireManager(indexName), indexName, targetPartitionCount, rebalanceCtx);
22381
22159
  releaseWrites();
22382
22160
  await running;
@@ -22461,8 +22239,8 @@ function createNarsilFromCore(core, config) {
22461
22239
  guardShutdown();
22462
22240
  requireIndex(indexName);
22463
22241
  const manager = executor.getManager(indexName);
22464
- const vectorCode = loadedVectorCode();
22465
- return manager === void 0 || vectorCode === null ? [] : vectorCode.getVectorMaintenanceStatus(manager);
22242
+ const vectorCode2 = loadedVectorCode();
22243
+ return manager === void 0 || vectorCode2 === null ? [] : vectorCode2.getVectorMaintenanceStatus(manager);
22466
22244
  },
22467
22245
  on(event, handler) {
22468
22246
  const key = event;
@@ -22498,10 +22276,14 @@ async function createNarsil(config) {
22498
22276
  const runnableConfig = await resolveRunnableConfig(config);
22499
22277
  const core = await createEngineCore(runnableConfig);
22500
22278
  await startEngineCore(core, runnableConfig);
22501
- return createNarsilFromCore(core, runnableConfig);
22279
+ const engine = createNarsilFromCore(core, runnableConfig);
22280
+ if (runnableConfig?.querySuggestions !== void 0 || core.durability !== null) {
22281
+ await (await import('./engine-hooks-E4UD67JD.mjs')).startQuerySuggestions(core, engine, runnableConfig);
22282
+ }
22283
+ return engine;
22502
22284
  }
22503
22285
 
22504
22286
  // src/index.ts
22505
22287
  var VERSION = "0.1.0";
22506
22288
 
22507
- export { ARRAY_POSITION_GAP, DEFAULT_BM25_B, DEFAULT_BM25_K1, DEFAULT_WRITE_AHEAD_QUEUE_MAX_SIZE, REBALANCE_CHUNK_SIZE, VERSION, arrayPositionsAreStale, assemblePagedFrozenSegment, buildPartialWordTableFrom, buildSegmentPayload, clearNormalizationCache, configureNormalizationCache, createCompositePartition, createEncodedDocumentSource, createFrozenSegment, createNarsil, createPartitionIndex, createPartitionManager, createPartitionRouter, createSharedFrozenSegment, decodeEveryStoredDocument, decodeMapWithoutFields, decodeStoredDocument, decodeSurfaceTable, deleteNestedValue, emitEngineEvent, encodeIndexConfiguration, encodeSurfaceTable, endOfValue, engineVersionParts, extractVectorFromDoc, fieldIndexRemapOf, freezeSegmentShared, generateId, getNestedValue, getNormalizationCacheSize, holdSyncEpochChange, holdsADiscardedField, insertDocumentVectors, isCompositePartition, isQuantizationMode, isStorageMode, loadVectorCodeFor, mergeDocFrequencies, mergeFieldIndexes2 as mergeFieldIndexes, mergeFieldLengths, mergePartialWords, mergeSegmentContents, mergeSurfaceForms2 as mergeSurfaceForms, messagePackUpperBoundBytes, packChecksummedEnvelope, packEnvelopeWithChecksum, parseVectorDimension, partitionStateOf, prepareConfiguredSynonyms, prepareDocumentVectors, prepareStoredSynonyms, raiseEarlierReleaseGraphSetting, readResidentMemory, rebuildTextIndexes, reconstructSchemaFromMetadata, registerPartialWordSearch, registerPatternSearch, registerSynonyms, removeDocumentVectors, requireConfigurationWithinSizeLimit, requireSurfaceFormsForPartialFields, resetNormalizationCache, resolvePartialWordAnalysis, resolvePartitionInsertOptions, rewriteSpillOf, rulesOfStoredSynonyms, scanPostingBlocks, segmentArraysOf, selectionKeeps, shareSegmentArrays, storedArrayPositionGap, survivorDocumentsOf, textRebuildTargetOf, toError2 as toError, validateEmbeddingConfig, validatePatternValueLimit, validateRequiredFieldsInSchema, validateTextStorage, validateVectorPromotion, validateVectorStorage, vectorsEqual, wrapFrozenTokenTable, yieldToEventLoop2 as yieldToEventLoop };
22289
+ export { ARRAY_POSITION_GAP, DEFAULT_BM25_B, DEFAULT_BM25_K1, DEFAULT_WRITE_AHEAD_QUEUE_MAX_SIZE, REBALANCE_CHUNK_SIZE, VERSION, arrayPositionsAreStale, assemblePagedFrozenSegment, buildPartialWordTableFrom, buildSegmentPayload, clearNormalizationCache, configureNormalizationCache, createCompositePartition, createEncodedDocumentSource, createEngineIndex, createFrozenSegment, createNarsil, createPartitionIndex, createPartitionManager, createPartitionRouter, createSharedFrozenSegment, decodeEveryStoredDocument, decodeMapWithoutFields, decodeStoredDocument, decodeSurfaceTable, deleteNestedValue, dropEngineIndex, emitEngineEvent, emitWriteEventAfter, encodeIndexConfiguration, encodeSurfaceTable, endOfValue, engineCoreOf, engineVersionParts, extractVectorFromDoc, fieldIndexRemapOf, freezeSegmentShared, generateId, getNestedValue, getNormalizationCacheSize, holdSyncEpochChange, holdsADiscardedField, insertDocumentVectors, isCompositePartition, isQuantizationMode, isStorageMode, loadSchemaCodeFor, mergeDocFrequencies, mergeFieldIndexes2 as mergeFieldIndexes, mergeFieldLengths, mergePartialWords, mergeSegmentContents, mergeSurfaceForms2 as mergeSurfaceForms, messagePackUpperBoundBytes, packChecksummedEnvelope, packEnvelopeWithChecksum, parseVectorDimension, partitionStateOf, prepareConfiguredSynonyms, prepareDocumentVectors, prepareStoredSynonyms, raiseEarlierReleaseGraphSetting, readResidentMemory, rebuildTextIndexes, reconstructSchemaFromMetadata, registerPartialWordSearch, registerPatternSearch, registerSynonyms, removeDocumentBatch, removeDocumentVectors, requireConfigurationWithinSizeLimit, requireSurfaceFormsForPartialFields, resetNormalizationCache, resolvePartialWordAnalysis, resolvePartitionInsertOptions, rewriteSpillOf, rulesOfStoredSynonyms, scanPostingBlocks, segmentArraysOf, selectionKeeps, shareSegmentArrays, storedArrayPositionGap, survivorDocumentsOf, textRebuildTargetOf, toError2 as toError, validateEmbeddingConfig, validatePatternValueLimit, validateRequiredFieldsInSchema, validateTextStorage, validateVectorPromotion, validateVectorStorage, vectorsEqual, wrapFrozenTokenTable, yieldToEventLoop2 as yieldToEventLoop };