@delali/narsil 0.3.1-next.157 → 0.3.1-next.160

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 (565) hide show
  1. package/dist/adapters/filesystem.mjs +3 -3
  2. package/dist/adapters/gcs.mjs +3 -3
  3. package/dist/adapters/indexeddb.mjs +1 -1
  4. package/dist/adapters/s3.mjs +3 -3
  5. package/dist/browser/{chunk-N23GL72Q.mjs → chunk-4RNSFVWI.mjs} +20777 -19056
  6. package/dist/browser/chunk-MMHIIL5B.mjs +564 -0
  7. package/dist/browser/chunk-MZHQ65VI.mjs +1228 -0
  8. package/dist/browser/chunk-WC2DEXWU.mjs +29 -0
  9. package/dist/browser/{chunk-VLJQW4J6.mjs → core-leaf-TJAGWPZZ.mjs} +4674 -3102
  10. package/dist/{react-native/chunks/durability-config-QXVZEO7T.mjs → browser/durability-config-SGB5ZP5K.mjs} +8 -3
  11. package/dist/browser/embed-RF2MPGAO.mjs +222 -0
  12. package/dist/{react-native/chunks/geo-index-PX3BIHAH.mjs → browser/geo-index-GNHY4PUB.mjs} +190 -93
  13. package/dist/{react-native/chunks/module-TTEVPRCW.mjs → browser/module-362VSIGR.mjs} +1570 -275
  14. package/dist/browser/msgpack-leaf-44XNWSSY.mjs +302 -0
  15. package/dist/browser/optional-reads-XMVPG6HG.mjs +3230 -0
  16. package/dist/browser/optional-writes-WMZX4OEC.mjs +3196 -0
  17. package/dist/browser/phrase-module-22TKMXWI.mjs +616 -0
  18. package/dist/browser/resolve-vector-text-KI65IHMD.mjs +60 -0
  19. package/dist/browser/{restore-hooks-IE3GGYHG.mjs → restore-queue-S4BWOGMU.mjs} +98 -24
  20. package/dist/{react-native/chunks/runtime-R5E3TB3J.mjs → browser/runtime-NU6VOVH2.mjs} +61 -25
  21. package/dist/browser/segment-codec-leaf-A427QJUX.mjs +554 -0
  22. package/dist/browser/segment-merge-leaf-7BZ54JPI.mjs +1636 -0
  23. package/dist/browser/storage-leaf-X6CNRHJS.mjs +18221 -0
  24. package/dist/browser/store-leaf-AEMTAVHX.mjs +2069 -0
  25. package/dist/browser/{chunk-GFAZPSWK.mjs → suggestions-leaf-3Y6MR6OF.mjs} +441 -119
  26. package/dist/browser/worker-copies-WQCPP3TS.mjs +2750 -0
  27. package/dist/{capabilities-D3AoBJoF.d.ts → capabilities-BKDrry0z.d.ts} +2 -2
  28. package/dist/chunk-2JRERUNZ.mjs +217 -0
  29. package/dist/chunk-2RIS76RJ.mjs +212 -0
  30. package/dist/chunk-3B775F3C.mjs +252 -0
  31. package/dist/{chunk-24FNVRKB.mjs → chunk-3D6RZGJH.mjs} +3 -3
  32. package/dist/{chunk-INJYO3BU.mjs → chunk-4CAMH7FO.mjs} +1 -1
  33. package/dist/{chunk-U476IXKQ.mjs → chunk-4PY4JYMY.mjs} +2 -1
  34. package/dist/chunk-6EZW2GQL.mjs +978 -0
  35. package/dist/chunk-75UNINFA.mjs +271 -0
  36. package/dist/chunk-77AUVDQ5.mjs +7 -0
  37. package/dist/{chunk-JTYPJF3T.mjs → chunk-7MWYORQC.mjs} +2 -2
  38. package/dist/{chunk-TGP5M5R7.mjs → chunk-7T4LAYT4.mjs} +1 -1
  39. package/dist/{chunk-XIHUI4KB.mjs → chunk-AB27FWZM.mjs} +8 -3
  40. package/dist/{chunk-FUD5XSZ5.mjs → chunk-BXM7XM4G.mjs} +7 -3
  41. package/dist/{chunk-HJJI72X7.mjs → chunk-C7YQHCSO.mjs} +1 -1
  42. package/dist/{chunk-RVGRFOGN.mjs → chunk-D456ZFPQ.mjs} +2 -1
  43. package/dist/{chunk-KKQC526K.mjs → chunk-E2F6LZR3.mjs} +19 -21
  44. package/dist/{chunk-SMOOSIAW.mjs → chunk-FE3MRIBN.mjs} +104 -13
  45. package/dist/{chunk-KYYABCSW.mjs → chunk-FETZYCH7.mjs} +15 -1
  46. package/dist/{chunk-XXJZMTZT.mjs → chunk-FVZ5DB6Y.mjs} +3 -2
  47. package/dist/{chunk-EYD7K3H6.mjs → chunk-GF4K7IUK.mjs} +317 -120
  48. package/dist/chunk-GXCDWLQI.mjs +193 -0
  49. package/dist/{chunk-IIRIG7H5.mjs → chunk-H64YDF5M.mjs} +3 -3
  50. package/dist/{browser/chunk-VY5KW3HN.mjs → chunk-HOOR4CP5.mjs} +63 -7
  51. package/dist/chunk-IB4BYLE3.mjs +127 -0
  52. package/dist/{chunk-3C7MTCCI.mjs → chunk-IE3Q62QD.mjs} +2 -2
  53. package/dist/chunk-IH3G6SJO.mjs +40 -0
  54. package/dist/chunk-JV74RKCY.mjs +3041 -0
  55. package/dist/{chunk-ZPZ3YGXV.mjs → chunk-K67I3RF4.mjs} +261 -101
  56. package/dist/chunk-KLVMK3R5.mjs +47 -0
  57. package/dist/{chunk-5VV4R6P7.mjs → chunk-LAWIJRMJ.mjs} +4154 -2577
  58. package/dist/chunk-LF4GB4PO.mjs +281 -0
  59. package/dist/chunk-NC4QLCZC.mjs +59 -0
  60. package/dist/chunk-OOO54OVC.mjs +627 -0
  61. package/dist/chunk-OUWZKNO3.mjs +207 -0
  62. package/dist/{chunk-FJKKCV4D.mjs → chunk-P5YLI5ED.mjs} +343 -182
  63. package/dist/{chunk-4ZTHGTVX.mjs → chunk-PTTMGRG5.mjs} +9 -10
  64. package/dist/{react-native/chunks/chunk-DZ7H7D2C.mjs → chunk-Q3ZZH5Z7.mjs} +6 -0
  65. package/dist/{browser/chunk-EKMGCRSR.mjs → chunk-QBVTYY4J.mjs} +2 -9
  66. package/dist/{chunk-W5EB5XKI.mjs → chunk-R4CE4IVU.mjs} +341 -183
  67. package/dist/chunk-S2POFTLN.mjs +10 -0
  68. package/dist/{chunk-KJ3RTZDJ.mjs → chunk-S3BSDBF7.mjs} +10 -3
  69. package/dist/{chunk-4LMSZAK6.mjs → chunk-SHGN3QIF.mjs} +69 -13
  70. package/dist/chunk-SXIRM4MX.mjs +3549 -0
  71. package/dist/{chunk-TBC3XUL2.mjs → chunk-TGPKS2UM.mjs} +47 -1
  72. package/dist/chunk-TINW4BSH.mjs +31301 -0
  73. package/dist/{cold-module-VOJXMNZB.mjs → chunk-TSLV5P2J.mjs} +397 -80
  74. package/dist/{chunk-HHBUCIUY.mjs → chunk-TW543F33.mjs} +3 -3
  75. package/dist/chunk-U6B7DUQW.mjs +788 -0
  76. package/dist/{chunk-OQLD2BSW.mjs → chunk-V3SGPXWQ.mjs} +8 -9
  77. package/dist/chunk-W34VJXY7.mjs +4723 -0
  78. package/dist/chunk-YETKPX5M.mjs +5 -0
  79. package/dist/chunk-ZQ6QY42L.mjs +59 -0
  80. package/dist/{client-kqSMevVi.d.ts → client-CTp8RRiK.d.ts} +4 -4
  81. package/dist/client.d.ts +8 -8
  82. package/dist/client.mjs +66 -18
  83. package/dist/{config-B4v_Htpu.d.ts → config-PCNzWjHL.d.ts} +6 -3
  84. package/dist/{config-CTP01fns.d.ts → config-_WT5grSL.d.ts} +3 -3
  85. package/dist/core-leaf-KXFGP74A.mjs +7 -0
  86. package/dist/digest-leaf-KXBGKYHZ.mjs +1 -0
  87. package/dist/direct-executor-MKTZBR26.mjs +16 -0
  88. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  89. package/dist/distribution/coordinator/etcd.mjs +7 -4
  90. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  91. package/dist/distribution/coordinator/in-memory.mjs +1 -2
  92. package/dist/distribution/transport/grpc.mjs +7 -2
  93. package/dist/distribution/transport/tcp.mjs +7 -1
  94. package/dist/distribution.d.ts +7 -7
  95. package/dist/distribution.mjs +1199 -1092
  96. package/dist/{browser/durability-config-TIYKW6XX.mjs → durability-config-XV4XR7Y4.mjs} +7 -3
  97. package/dist/embed-4H7RTBVL.mjs +221 -0
  98. package/dist/embeddings/openai.mjs +2 -2
  99. package/dist/{engine-CkPn2PWE.d.ts → engine-DBRVR_d-.d.ts} +1252 -1239
  100. package/dist/{browser/geo-index-OTV7VPIR.mjs → geo-index-2ZMMWWSK.mjs} +190 -93
  101. package/dist/{index-C4AmUnl1.d.ts → index-Ck9w5WHz.d.ts} +1 -1
  102. package/dist/index.browser.mjs +4 -16
  103. package/dist/index.d.ts +1495 -78
  104. package/dist/index.mjs +14 -50
  105. package/dist/index.react-native.mjs +11 -28
  106. package/dist/invalidation/filesystem.mjs +1 -2
  107. package/dist/languages/albanian.mjs +1 -1
  108. package/dist/languages/amharic.mjs +1 -1
  109. package/dist/languages/arabic.mjs +1 -1
  110. package/dist/languages/armenian.mjs +1 -1
  111. package/dist/languages/azerbaijani.mjs +1 -1
  112. package/dist/languages/bambara.mjs +1 -1
  113. package/dist/languages/basque.mjs +1 -1
  114. package/dist/languages/belarusian.mjs +1 -1
  115. package/dist/languages/bengali.mjs +1 -1
  116. package/dist/languages/bosnian.mjs +1 -1
  117. package/dist/languages/breton.mjs +1 -1
  118. package/dist/languages/bulgarian.mjs +1 -1
  119. package/dist/languages/burmese.mjs +1 -1
  120. package/dist/languages/catalan.mjs +1 -1
  121. package/dist/languages/chinese.mjs +1 -1
  122. package/dist/languages/croatian.mjs +1 -1
  123. package/dist/languages/czech.mjs +1 -1
  124. package/dist/languages/dagbani.mjs +1 -1
  125. package/dist/languages/danish.mjs +1 -1
  126. package/dist/languages/dutch.mjs +1 -1
  127. package/dist/languages/english.mjs +1 -1
  128. package/dist/languages/esperanto.mjs +1 -1
  129. package/dist/languages/estonian.mjs +1 -1
  130. package/dist/languages/ewe.mjs +1 -1
  131. package/dist/languages/faroese.mjs +1 -1
  132. package/dist/languages/fijian.mjs +1 -1
  133. package/dist/languages/finnish.mjs +1 -1
  134. package/dist/languages/french.mjs +1 -1
  135. package/dist/languages/ga.mjs +1 -1
  136. package/dist/languages/galician.mjs +1 -1
  137. package/dist/languages/georgian.mjs +1 -1
  138. package/dist/languages/german.mjs +1 -1
  139. package/dist/languages/greek.mjs +1 -1
  140. package/dist/languages/guarani.mjs +1 -1
  141. package/dist/languages/gujarati.mjs +1 -1
  142. package/dist/languages/haitian-creole.mjs +1 -1
  143. package/dist/languages/hausa.mjs +1 -1
  144. package/dist/languages/hawaiian.mjs +1 -1
  145. package/dist/languages/hebrew.mjs +1 -1
  146. package/dist/languages/hindi.mjs +1 -1
  147. package/dist/languages/hungarian.mjs +1 -1
  148. package/dist/languages/icelandic.mjs +1 -1
  149. package/dist/languages/igbo.mjs +1 -1
  150. package/dist/languages/indonesian.mjs +1 -1
  151. package/dist/languages/irish.mjs +1 -1
  152. package/dist/languages/italian.mjs +1 -1
  153. package/dist/languages/japanese.mjs +1 -1
  154. package/dist/languages/kannada.mjs +1 -1
  155. package/dist/languages/kazakh.mjs +1 -1
  156. package/dist/languages/khmer.mjs +1 -1
  157. package/dist/languages/kinyarwanda.mjs +1 -1
  158. package/dist/languages/kirundi.mjs +1 -1
  159. package/dist/languages/korean.mjs +1 -1
  160. package/dist/languages/kurmanji.mjs +1 -1
  161. package/dist/languages/kyrgyz.mjs +1 -1
  162. package/dist/languages/lao.mjs +1 -1
  163. package/dist/languages/latin.mjs +1 -1
  164. package/dist/languages/latvian.mjs +1 -1
  165. package/dist/languages/lingala.mjs +1 -1
  166. package/dist/languages/lithuanian.mjs +1 -1
  167. package/dist/languages/luxembourgish.mjs +1 -1
  168. package/dist/languages/macedonian.mjs +1 -1
  169. package/dist/languages/malagasy.mjs +1 -1
  170. package/dist/languages/malay.mjs +1 -1
  171. package/dist/languages/malayalam.mjs +1 -1
  172. package/dist/languages/maltese.mjs +1 -1
  173. package/dist/languages/maori.mjs +1 -1
  174. package/dist/languages/marathi.mjs +1 -1
  175. package/dist/languages/nepali.mjs +1 -1
  176. package/dist/languages/norwegian.mjs +1 -1
  177. package/dist/languages/oromo.mjs +1 -1
  178. package/dist/languages/persian.mjs +1 -1
  179. package/dist/languages/polish.mjs +1 -1
  180. package/dist/languages/portuguese.mjs +1 -1
  181. package/dist/languages/punjabi.mjs +1 -1
  182. package/dist/languages/romanian.mjs +1 -1
  183. package/dist/languages/russian.mjs +1 -1
  184. package/dist/languages/samoan.mjs +1 -1
  185. package/dist/languages/sanskrit.mjs +1 -1
  186. package/dist/languages/scottish-gaelic.mjs +1 -1
  187. package/dist/languages/serbian.mjs +1 -1
  188. package/dist/languages/shona.mjs +1 -1
  189. package/dist/languages/sinhala.mjs +1 -1
  190. package/dist/languages/slovak.mjs +1 -1
  191. package/dist/languages/slovenian.mjs +1 -1
  192. package/dist/languages/sorani.mjs +1 -1
  193. package/dist/languages/spanish.mjs +1 -1
  194. package/dist/languages/swahili.mjs +1 -1
  195. package/dist/languages/swedish.mjs +1 -1
  196. package/dist/languages/tagalog.mjs +1 -1
  197. package/dist/languages/tamil.mjs +1 -1
  198. package/dist/languages/tatar.mjs +1 -1
  199. package/dist/languages/telugu.mjs +1 -1
  200. package/dist/languages/thai.mjs +1 -1
  201. package/dist/languages/tibetan.mjs +1 -1
  202. package/dist/languages/tigrinya.mjs +1 -1
  203. package/dist/languages/tongan.mjs +1 -1
  204. package/dist/languages/turkish.mjs +1 -1
  205. package/dist/languages/twi.mjs +1 -1
  206. package/dist/languages/ukrainian.mjs +1 -1
  207. package/dist/languages/urdu.mjs +1 -1
  208. package/dist/languages/vietnamese.mjs +1 -1
  209. package/dist/languages/welsh.mjs +1 -1
  210. package/dist/languages/wolof.mjs +1 -1
  211. package/dist/languages/xhosa.mjs +1 -1
  212. package/dist/languages/yoruba.mjs +1 -1
  213. package/dist/languages/zulu.mjs +1 -1
  214. package/dist/{long-query-thread-QDFQSJD6.mjs → long-query-thread-JMGNGF6V.mjs} +74 -58
  215. package/dist/{module-N55W4Q5C.mjs → module-ZJ6ARG6V.mjs} +444 -111
  216. package/dist/msgpack-leaf-5WFRP6JM.mjs +9 -0
  217. package/dist/optional-reads-BR3BOVZW.mjs +3373 -0
  218. package/dist/optional-writes-DDFHYUOH.mjs +218 -0
  219. package/dist/{paged-partition-archive-RLRGOXDX.mjs → paged-partition-archive-G576XGVE.mjs} +29 -69
  220. package/dist/partial-words.browser.mjs +1649 -0
  221. package/dist/partial-words.mjs +15 -14
  222. package/dist/{chunk-CITFCZKF.mjs → pattern.browser.mjs} +153 -186
  223. package/dist/pattern.mjs +6 -8
  224. package/dist/persistence/durability/checkpoint-worker.d.ts +32 -24
  225. package/dist/persistence/durability/checkpoint-worker.mjs +27 -59
  226. package/dist/phrase-module-XK3T44VU.mjs +634 -0
  227. package/dist/query-actions-OMXJEC2J.mjs +118 -0
  228. package/dist/query-suggestions/merge-worker.mjs +18 -54
  229. package/dist/query-suggestions.browser.mjs +26 -227
  230. package/dist/query-suggestions.d.ts +2 -2
  231. package/dist/query-suggestions.mjs +16 -67
  232. package/dist/react-native/chunks/chunk-4EXKQ2IB.mjs +565 -0
  233. package/dist/react-native/chunks/chunk-52QD7CBJ.mjs +52 -0
  234. package/dist/react-native/chunks/chunk-72OKYHZL.mjs +969 -0
  235. package/dist/react-native/chunks/chunk-AQOWRH2C.mjs +802 -0
  236. package/dist/react-native/chunks/{chunk-4COWCEY7.mjs → chunk-FTQ7JNMU.mjs} +341 -180
  237. package/dist/react-native/chunks/chunk-G3CUQ333.mjs +42 -0
  238. package/dist/react-native/chunks/{chunk-EJ33LCHV.mjs → chunk-HRDMIQ63.mjs} +53 -1
  239. package/dist/react-native/chunks/{chunk-4AV5PPH6.mjs → chunk-IY6U6HRA.mjs} +63 -7
  240. package/dist/react-native/chunks/chunk-J2NQW353.mjs +212 -0
  241. package/dist/react-native/chunks/chunk-L4R5ITVG.mjs +29047 -0
  242. package/dist/react-native/chunks/{chunk-OXM66LO6.mjs → chunk-OK3WUA6N.mjs} +2 -10
  243. package/dist/react-native/chunks/{chunk-MVXELMJX.mjs → chunk-PVMEHBQO.mjs} +1 -1
  244. package/dist/{browser/chunk-SRMZXJSL.mjs → react-native/chunks/chunk-TQ26BKBH.mjs} +6 -0
  245. package/dist/{browser/chunk-GPPOG6PT.mjs → react-native/chunks/chunk-VUJCSQG5.mjs} +3 -1
  246. package/dist/react-native/chunks/{chunk-ENLMYKSX.mjs → chunk-XEGKQKLY.mjs} +5385 -3114
  247. package/dist/react-native/chunks/chunk-YOTP2FPE.mjs +232 -0
  248. package/dist/react-native/chunks/chunk-ZIU6TWXG.mjs +127 -0
  249. package/dist/react-native/chunks/core-leaf-5B4JXCVA.mjs +6 -0
  250. package/dist/react-native/chunks/digest-leaf-X6OIFDIU.mjs +1 -0
  251. package/dist/{durability-config-GE4U7MCZ.mjs → react-native/chunks/durability-config-3IOXIPYZ.mjs} +7 -3
  252. package/dist/react-native/chunks/embed-3WQ2CCR5.mjs +221 -0
  253. package/dist/{geo-index-MRH5JMIR.mjs → react-native/chunks/geo-index-QEYKEVPH.mjs} +190 -93
  254. package/dist/react-native/chunks/{chunk-CKNRFDTZ.mjs → gzip.react-native-DLO4WW27.mjs} +2 -1
  255. package/dist/{browser/module-TCT66FWA.mjs → react-native/chunks/module-VUA27HZZ.mjs} +1018 -540
  256. package/dist/react-native/chunks/msgpack-leaf-TR66ZVAX.mjs +7 -0
  257. package/dist/react-native/chunks/optional-reads-WDTLLHUT.mjs +3364 -0
  258. package/dist/react-native/chunks/optional-writes-FZV3QW34.mjs +267 -0
  259. package/dist/react-native/chunks/phrase-module-KCQWVXYZ.mjs +635 -0
  260. package/dist/react-native/chunks/resolve-vector-text-LXRYXF7M.mjs +59 -0
  261. package/dist/react-native/chunks/restore-queue-EI2V2I4S.mjs +179 -0
  262. package/dist/{browser/runtime-OTAGEFQW.mjs → react-native/chunks/runtime-BUCSAK4U.mjs} +61 -25
  263. package/dist/react-native/chunks/segment-codec-leaf-6ULP7H3I.mjs +12 -0
  264. package/dist/react-native/chunks/segment-merge-leaf-F4GQZNK6.mjs +13 -0
  265. package/dist/react-native/chunks/storage-leaf-OAXBU2L6.mjs +18042 -0
  266. package/dist/react-native/chunks/store-leaf-GY2ZZFXB.mjs +14 -0
  267. package/dist/react-native/chunks/{chunk-WW2X2AEI.mjs → suggestions-leaf-SQEZ4IBS.mjs} +332 -118
  268. package/dist/react-native/chunks/worker-copies-EEHSCFJW.mjs +2627 -0
  269. package/dist/react-native/partial-words.mjs +954 -35
  270. package/dist/react-native/pattern.mjs +238 -111
  271. package/dist/react-native/query-suggestions.mjs +33 -239
  272. package/dist/react-native/sync.mjs +95 -52
  273. package/dist/react-native/synonyms.mjs +256 -112
  274. package/dist/react.d.ts +9 -9
  275. package/dist/react.mjs +6 -0
  276. package/dist/{rerank-MQ37IYRV.mjs → rerank-Y6MWBMTT.mjs} +17 -8
  277. package/dist/rerankers/http.mjs +2 -2
  278. package/dist/resolve-vector-text-4PDRTPNQ.mjs +2 -0
  279. package/dist/restore-queue-KPYSRJ4A.mjs +184 -0
  280. package/dist/runtime-4GKUIAKV.mjs +595 -0
  281. package/dist/{schema-Jwt928nJ.d.ts → schema-C_7yRJLt.d.ts} +1 -1
  282. package/dist/segment-codec-leaf-6IFBSBPN.mjs +17 -0
  283. package/dist/segment-merge-leaf-VE3FUSVE.mjs +17 -0
  284. package/dist/server.d.ts +33 -13
  285. package/dist/server.mjs +81 -100
  286. package/dist/{browser/durability-wiring-GVZEE46O.mjs → storage-leaf-HMIIOUYN.mjs} +2334 -931
  287. package/dist/store-leaf-M7T7SUZJ.mjs +19 -0
  288. package/dist/stored-values-BWIMpiT_.d.ts +25 -0
  289. package/dist/suggestions-leaf-Q3Q5D6XV.mjs +53 -0
  290. package/dist/sync/filesystem.d.ts +3 -3
  291. package/dist/sync/filesystem.mjs +27 -11
  292. package/dist/sync/indexeddb.browser.mjs +287 -0
  293. package/dist/sync/indexeddb.d.ts +3 -3
  294. package/dist/sync/indexeddb.mjs +7 -2
  295. package/dist/sync.browser.mjs +88 -72
  296. package/dist/sync.d.ts +4 -4
  297. package/dist/sync.mjs +89 -59
  298. package/dist/{chunk-I5B7RXU7.mjs → synonyms.browser.mjs} +248 -135
  299. package/dist/synonyms.mjs +15 -11
  300. package/dist/{tasks-CoNjxbop.d.ts → tasks-B4tT4vmP.d.ts} +4 -4
  301. package/dist/thread-SNILJXX3.mjs +30 -0
  302. package/dist/{types-DPMjfOr_.d.ts → types-CTg0KaMy.d.ts} +2 -2
  303. package/dist/vector/search-worker.d.ts +7 -1
  304. package/dist/vector/search-worker.mjs +9 -13
  305. package/dist/worker-copies-ZLZS2CUM.mjs +2152 -0
  306. package/dist/workers/entry.mjs +60 -30
  307. package/openapi.json +66 -50
  308. package/package.json +233 -8
  309. package/dist/analysis-change-CKEMM2MC.mjs +0 -55
  310. package/dist/analysis-change-entry-SEDMJ6MW.mjs +0 -1
  311. package/dist/archive-history-E4R73RWD.mjs +0 -29
  312. package/dist/browser/analysis-change-ZKGJFENM.mjs +0 -942
  313. package/dist/browser/analysis-change-entry-5BFUVMHJ.mjs +0 -1
  314. package/dist/browser/archive-history-4IP5XQZY.mjs +0 -29
  315. package/dist/browser/chunk-25MTVDYD.mjs +0 -432
  316. package/dist/browser/chunk-3I27KXQD.mjs +0 -34
  317. package/dist/browser/chunk-3NLMB5CC.mjs +0 -217
  318. package/dist/browser/chunk-4RD3AFSB.mjs +0 -32
  319. package/dist/browser/chunk-5W3MMTLG.mjs +0 -19
  320. package/dist/browser/chunk-5YWB3E2W.mjs +0 -92
  321. package/dist/browser/chunk-7IGKGWSQ.mjs +0 -79
  322. package/dist/browser/chunk-AI5UI46D.mjs +0 -12
  323. package/dist/browser/chunk-ATEBYXP6.mjs +0 -10
  324. package/dist/browser/chunk-BLT4RHCJ.mjs +0 -241
  325. package/dist/browser/chunk-C26SPCGQ.mjs +0 -2636
  326. package/dist/browser/chunk-C4FJ3WDY.mjs +0 -177
  327. package/dist/browser/chunk-CXNTHHA7.mjs +0 -63
  328. package/dist/browser/chunk-DSXIBE6N.mjs +0 -78
  329. package/dist/browser/chunk-DUH6QUVU.mjs +0 -2374
  330. package/dist/browser/chunk-ELV4OZOI.mjs +0 -29
  331. package/dist/browser/chunk-EXQZGUQH.mjs +0 -193
  332. package/dist/browser/chunk-G64Q6OJF.mjs +0 -96
  333. package/dist/browser/chunk-HOZW3PKP.mjs +0 -9
  334. package/dist/browser/chunk-HUCSHDTB.mjs +0 -100
  335. package/dist/browser/chunk-JPTQZWJQ.mjs +0 -10
  336. package/dist/browser/chunk-K3IPRX6D.mjs +0 -2559
  337. package/dist/browser/chunk-ML7THVLJ.mjs +0 -38
  338. package/dist/browser/chunk-MY2XKH22.mjs +0 -40
  339. package/dist/browser/chunk-NLWTBAGB.mjs +0 -111
  340. package/dist/browser/chunk-NXQG7DRA.mjs +0 -318
  341. package/dist/browser/chunk-OEDCEZXJ.mjs +0 -92
  342. package/dist/browser/chunk-OIZS5KIX.mjs +0 -6
  343. package/dist/browser/chunk-RA6LSBCM.mjs +0 -43
  344. package/dist/browser/chunk-TK63WFXK.mjs +0 -90
  345. package/dist/browser/chunk-TY7L6OXO.mjs +0 -69
  346. package/dist/browser/chunk-U3JOQGWX.mjs +0 -19
  347. package/dist/browser/chunk-U4YDIBUT.mjs +0 -653
  348. package/dist/browser/chunk-UATIJ4KU.mjs +0 -21
  349. package/dist/browser/chunk-UKOWD2K5.mjs +0 -315
  350. package/dist/browser/chunk-UTMHUHUV.mjs +0 -150
  351. package/dist/browser/chunk-V43N6TZO.mjs +0 -857
  352. package/dist/browser/chunk-VI7BQR4U.mjs +0 -21
  353. package/dist/browser/chunk-WN464PTL.mjs +0 -375
  354. package/dist/browser/chunk-WXLBZJMT.mjs +0 -25
  355. package/dist/browser/chunk-X7TXYUKO.mjs +0 -86
  356. package/dist/browser/chunk-XAWNZ4G2.mjs +0 -151
  357. package/dist/browser/chunk-Y6IBAUNO.mjs +0 -561
  358. package/dist/browser/chunk-ZI2V4VD7.mjs +0 -21
  359. package/dist/browser/cold-module-YNUUDNOM.mjs +0 -761
  360. package/dist/browser/engine-hooks-HBVS6YM4.mjs +0 -18
  361. package/dist/browser/gzip-5S7ROJFJ.mjs +0 -1
  362. package/dist/browser/import-5ESVMFDJ.mjs +0 -20
  363. package/dist/browser/methods-KTQCSIN4.mjs +0 -30
  364. package/dist/browser/module-NDSQLPMQ.mjs +0 -25
  365. package/dist/browser/operations-OJ3BXS55.mjs +0 -5
  366. package/dist/browser/phrase-module-HAT3TLZN.mjs +0 -328
  367. package/dist/browser/pool-3JLET5RO.mjs +0 -297
  368. package/dist/browser/release-HYXPVJVS.mjs +0 -32
  369. package/dist/browser/restore-queue-LQBBTODR.mjs +0 -55
  370. package/dist/browser/retention-TY3L3BFN.mjs +0 -211
  371. package/dist/browser/snapshot-5FHPPCNZ.mjs +0 -965
  372. package/dist/browser/start-2UZTOBG5.mjs +0 -26
  373. package/dist/browser/sync-state-P5XG6LTQ.mjs +0 -15
  374. package/dist/browser/write-ULXAN5B4.mjs +0 -196
  375. package/dist/chunk-2NE7VCYE.mjs +0 -212
  376. package/dist/chunk-2ROUFMQX.mjs +0 -543
  377. package/dist/chunk-37CD3OKS.mjs +0 -87
  378. package/dist/chunk-3MXV3VHR.mjs +0 -46
  379. package/dist/chunk-3OH67G7R.mjs +0 -214
  380. package/dist/chunk-4B7JIGQD.mjs +0 -106
  381. package/dist/chunk-5YNRKI2C.mjs +0 -81
  382. package/dist/chunk-6HTGOXIK.mjs +0 -875
  383. package/dist/chunk-6OEGXLBX.mjs +0 -57
  384. package/dist/chunk-6RC4K46J.mjs +0 -86
  385. package/dist/chunk-7GFE3PEY.mjs +0 -40
  386. package/dist/chunk-7GXJUJ24.mjs +0 -49
  387. package/dist/chunk-7V5IUP2T.mjs +0 -63
  388. package/dist/chunk-A4L7YTKX.mjs +0 -458
  389. package/dist/chunk-BEZH7VEH.mjs +0 -23
  390. package/dist/chunk-BNL5OPRV.mjs +0 -634
  391. package/dist/chunk-BTPGQC6Z.mjs +0 -27
  392. package/dist/chunk-C7XQYG6U.mjs +0 -50
  393. package/dist/chunk-CQZXZ75V.mjs +0 -562
  394. package/dist/chunk-CWS55TEX.mjs +0 -242
  395. package/dist/chunk-CZQ33DLW.mjs +0 -78
  396. package/dist/chunk-EEBCDP36.mjs +0 -32
  397. package/dist/chunk-FB6463IN.mjs +0 -1499
  398. package/dist/chunk-FCJ553HS.mjs +0 -655
  399. package/dist/chunk-FEZVDOWX.mjs +0 -6996
  400. package/dist/chunk-FOCV4CBZ.mjs +0 -87
  401. package/dist/chunk-FQBFZAWG.mjs +0 -27
  402. package/dist/chunk-G6HRSGOU.mjs +0 -74
  403. package/dist/chunk-GES7U2PM.mjs +0 -68
  404. package/dist/chunk-GH4WQ22V.mjs +0 -34
  405. package/dist/chunk-GPWMUPCA.mjs +0 -1126
  406. package/dist/chunk-GQPTDQCL.mjs +0 -54
  407. package/dist/chunk-HJSN7UYG.mjs +0 -10
  408. package/dist/chunk-I54T6CQP.mjs +0 -117
  409. package/dist/chunk-IPN7S4KX.mjs +0 -130
  410. package/dist/chunk-J4IJTTEX.mjs +0 -226
  411. package/dist/chunk-JSV6OQ4C.mjs +0 -74
  412. package/dist/chunk-K4ZIGL2O.mjs +0 -290
  413. package/dist/chunk-KAKQ74LS.mjs +0 -53
  414. package/dist/chunk-KCQYFO4K.mjs +0 -62
  415. package/dist/chunk-KHKIRS5D.mjs +0 -113
  416. package/dist/chunk-KOKM4PQN.mjs +0 -52
  417. package/dist/chunk-KP7TYHWT.mjs +0 -92
  418. package/dist/chunk-KZ3NX2P7.mjs +0 -21
  419. package/dist/chunk-L5ORED7V.mjs +0 -25
  420. package/dist/chunk-LDNCLRZU.mjs +0 -218
  421. package/dist/chunk-LHKOSI2J.mjs +0 -58
  422. package/dist/chunk-LQG5G2LY.mjs +0 -39
  423. package/dist/chunk-MATMVH65.mjs +0 -9
  424. package/dist/chunk-MP7ABPTD.mjs +0 -189
  425. package/dist/chunk-MW6BR4QP.mjs +0 -316
  426. package/dist/chunk-MWD5VPN7.mjs +0 -21
  427. package/dist/chunk-ODYKO5TO.mjs +0 -101
  428. package/dist/chunk-OG7UGJ6F.mjs +0 -63
  429. package/dist/chunk-ORN5BLL7.mjs +0 -11
  430. package/dist/chunk-OYABFKTW.mjs +0 -1974
  431. package/dist/chunk-P5LANSH6.mjs +0 -121
  432. package/dist/chunk-PELHVTO7.mjs +0 -24
  433. package/dist/chunk-PIH5SJ4N.mjs +0 -7481
  434. package/dist/chunk-PSZI4O24.mjs +0 -253
  435. package/dist/chunk-PV2CG7EJ.mjs +0 -886
  436. package/dist/chunk-PWGYQXML.mjs +0 -470
  437. package/dist/chunk-Q2UL2TPC.mjs +0 -21
  438. package/dist/chunk-QHPYS427.mjs +0 -66
  439. package/dist/chunk-QJVOLKU6.mjs +0 -111
  440. package/dist/chunk-QLDABJZM.mjs +0 -20
  441. package/dist/chunk-QYRNLLLI.mjs +0 -99
  442. package/dist/chunk-RCX4WNLC.mjs +0 -151
  443. package/dist/chunk-RFBLQLLZ.mjs +0 -16
  444. package/dist/chunk-RIHIVFIQ.mjs +0 -240
  445. package/dist/chunk-RLOES5SX.mjs +0 -31
  446. package/dist/chunk-RWURUDSP.mjs +0 -2639
  447. package/dist/chunk-RZWWB2XR.mjs +0 -96
  448. package/dist/chunk-S5LN746F.mjs +0 -10
  449. package/dist/chunk-SOI6LTHM.mjs +0 -216
  450. package/dist/chunk-SQJWAIF4.mjs +0 -12
  451. package/dist/chunk-TDIK6NTV.mjs +0 -10
  452. package/dist/chunk-TQXHPFWT.mjs +0 -177
  453. package/dist/chunk-U55XJEIG.mjs +0 -18
  454. package/dist/chunk-UD5HIS4U.mjs +0 -382
  455. package/dist/chunk-UHICS3JI.mjs +0 -83
  456. package/dist/chunk-UJDJB3NE.mjs +0 -913
  457. package/dist/chunk-VD7J552I.mjs +0 -28
  458. package/dist/chunk-VSLSGASN.mjs +0 -30
  459. package/dist/chunk-VZ2ONHEE.mjs +0 -3715
  460. package/dist/chunk-W7OSSKH5.mjs +0 -1427
  461. package/dist/chunk-WZ7YV54N.mjs +0 -152
  462. package/dist/chunk-X5CV2E2B.mjs +0 -1
  463. package/dist/chunk-Y4WPNHMC.mjs +0 -50
  464. package/dist/chunk-YEKL4JBK.mjs +0 -96
  465. package/dist/chunk-ZXNQEW43.mjs +0 -18
  466. package/dist/chunk-ZYAY26KG.mjs +0 -29
  467. package/dist/direct-executor-V5DRIECI.mjs +0 -34
  468. package/dist/durability-wiring-3TD62MBI.mjs +0 -4072
  469. package/dist/engine-hooks-HA3SBOBR.mjs +0 -54
  470. package/dist/gzip-F4HMIEEQ.mjs +0 -1
  471. package/dist/import-GPKLTSKA.mjs +0 -56
  472. package/dist/methods-7IOINERF.mjs +0 -30
  473. package/dist/module-JYHFTVPS.mjs +0 -63
  474. package/dist/operations-G5EP6JPX.mjs +0 -5
  475. package/dist/phrase-module-XW5MKWP5.mjs +0 -330
  476. package/dist/pool-Y4A46T36.mjs +0 -298
  477. package/dist/react-native/chunks/analysis-change-QUVDNABS.mjs +0 -934
  478. package/dist/react-native/chunks/analysis-change-entry-OC4XASBF.mjs +0 -1
  479. package/dist/react-native/chunks/archive-history-MJKUQLSU.mjs +0 -29
  480. package/dist/react-native/chunks/chunk-2PRHILX3.mjs +0 -529
  481. package/dist/react-native/chunks/chunk-3NQOVO3K.mjs +0 -1
  482. package/dist/react-native/chunks/chunk-3WI35N75.mjs +0 -226
  483. package/dist/react-native/chunks/chunk-4DII3ZSM.mjs +0 -73
  484. package/dist/react-native/chunks/chunk-4J74WHQM.mjs +0 -177
  485. package/dist/react-native/chunks/chunk-4NWR3NGS.mjs +0 -151
  486. package/dist/react-native/chunks/chunk-5CQX3XXV.mjs +0 -17
  487. package/dist/react-native/chunks/chunk-5MSX5FRT.mjs +0 -858
  488. package/dist/react-native/chunks/chunk-6OFDUYVX.mjs +0 -92
  489. package/dist/react-native/chunks/chunk-6VBXNFLE.mjs +0 -9
  490. package/dist/react-native/chunks/chunk-6ZELFCK5.mjs +0 -315
  491. package/dist/react-native/chunks/chunk-AAAETEJK.mjs +0 -27
  492. package/dist/react-native/chunks/chunk-AM7RSBPF.mjs +0 -32
  493. package/dist/react-native/chunks/chunk-BITYFZSZ.mjs +0 -242
  494. package/dist/react-native/chunks/chunk-C5G6TJ7A.mjs +0 -140
  495. package/dist/react-native/chunks/chunk-CHPTFFJM.mjs +0 -43
  496. package/dist/react-native/chunks/chunk-DIYDOIM4.mjs +0 -10
  497. package/dist/react-native/chunks/chunk-DMIFXZ3Q.mjs +0 -432
  498. package/dist/react-native/chunks/chunk-DVDX4SDR.mjs +0 -375
  499. package/dist/react-native/chunks/chunk-DXRSEWA2.mjs +0 -12
  500. package/dist/react-native/chunks/chunk-F753DA54.mjs +0 -23
  501. package/dist/react-native/chunks/chunk-FHPW7P2O.mjs +0 -40
  502. package/dist/react-native/chunks/chunk-FTZHMRD2.mjs +0 -18
  503. package/dist/react-native/chunks/chunk-HJBJBH26.mjs +0 -34
  504. package/dist/react-native/chunks/chunk-IAENKE2D.mjs +0 -21
  505. package/dist/react-native/chunks/chunk-IO2SMUQD.mjs +0 -10
  506. package/dist/react-native/chunks/chunk-IYNT75CE.mjs +0 -111
  507. package/dist/react-native/chunks/chunk-JDOEEMEF.mjs +0 -38
  508. package/dist/react-native/chunks/chunk-JWUCMVRK.mjs +0 -15
  509. package/dist/react-native/chunks/chunk-KSBYEMCB.mjs +0 -100
  510. package/dist/react-native/chunks/chunk-KU646XXT.mjs +0 -164
  511. package/dist/react-native/chunks/chunk-LU3Y3P63.mjs +0 -68
  512. package/dist/react-native/chunks/chunk-LVIKKAA6.mjs +0 -93
  513. package/dist/react-native/chunks/chunk-LZSLNSUN.mjs +0 -193
  514. package/dist/react-native/chunks/chunk-MJDQU5MW.mjs +0 -1225
  515. package/dist/react-native/chunks/chunk-NNE4VDMM.mjs +0 -8
  516. package/dist/react-native/chunks/chunk-NVVRSRX5.mjs +0 -78
  517. package/dist/react-native/chunks/chunk-OCSLSH27.mjs +0 -22723
  518. package/dist/react-native/chunks/chunk-PB2YXVQW.mjs +0 -29
  519. package/dist/react-native/chunks/chunk-PJHAB5ZY.mjs +0 -79
  520. package/dist/react-native/chunks/chunk-PSWKQVVT.mjs +0 -9
  521. package/dist/react-native/chunks/chunk-RDWG33MM.mjs +0 -79
  522. package/dist/react-native/chunks/chunk-SK2PWYDH.mjs +0 -654
  523. package/dist/react-native/chunks/chunk-SUPXRTMD.mjs +0 -96
  524. package/dist/react-native/chunks/chunk-TORU2OHQ.mjs +0 -218
  525. package/dist/react-native/chunks/chunk-U4KSKA4Z.mjs +0 -23
  526. package/dist/react-native/chunks/chunk-UNUFZ2QY.mjs +0 -68
  527. package/dist/react-native/chunks/chunk-WBYQRHDY.mjs +0 -86
  528. package/dist/react-native/chunks/chunk-WVWJNUMN.mjs +0 -2562
  529. package/dist/react-native/chunks/chunk-YH7QY657.mjs +0 -288
  530. package/dist/react-native/chunks/chunk-YZW4CHM6.mjs +0 -562
  531. package/dist/react-native/chunks/chunk-ZNZ6CPAZ.mjs +0 -562
  532. package/dist/react-native/chunks/chunk-ZVQMBF2H.mjs +0 -63
  533. package/dist/react-native/chunks/chunk-ZWAIN4GG.mjs +0 -2636
  534. package/dist/react-native/chunks/chunk-ZZT7CEN7.mjs +0 -92
  535. package/dist/react-native/chunks/cold-module-N6KFNNZA.mjs +0 -773
  536. package/dist/react-native/chunks/durability-wiring-RN64S2TL.mjs +0 -4984
  537. package/dist/react-native/chunks/engine-hooks-CWA5CKCA.mjs +0 -30
  538. package/dist/react-native/chunks/gzip.react-native-HLEPDKZ3.mjs +0 -3
  539. package/dist/react-native/chunks/import-5UAWBRJP.mjs +0 -32
  540. package/dist/react-native/chunks/methods-6W5U4C3H.mjs +0 -30
  541. package/dist/react-native/chunks/module-6RP4ZCBW.mjs +0 -37
  542. package/dist/react-native/chunks/operations-GNRMD6EX.mjs +0 -5
  543. package/dist/react-native/chunks/phrase-module-QK22HSQ2.mjs +0 -329
  544. package/dist/react-native/chunks/pool-JR3NJCAF.mjs +0 -297
  545. package/dist/react-native/chunks/release-2SIHZWDO.mjs +0 -32
  546. package/dist/react-native/chunks/restore-hooks-ENFMDTWC.mjs +0 -127
  547. package/dist/react-native/chunks/restore-queue-4R6AASE5.mjs +0 -55
  548. package/dist/react-native/chunks/retention-5GTFT3GR.mjs +0 -223
  549. package/dist/react-native/chunks/snapshot-5LGPQXFS.mjs +0 -976
  550. package/dist/react-native/chunks/start-ZQJVZ5DN.mjs +0 -38
  551. package/dist/react-native/chunks/sync-state-PASCIHHT.mjs +0 -15
  552. package/dist/react-native/chunks/write-6BRYIIZ7.mjs +0 -208
  553. package/dist/release-SMR4WJD4.mjs +0 -32
  554. package/dist/restore-hooks-HXLIEB4A.mjs +0 -153
  555. package/dist/restore-queue-LZH7LMLR.mjs +0 -55
  556. package/dist/retention-3K7ARGAG.mjs +0 -66
  557. package/dist/runtime-COIUORCN.mjs +0 -177
  558. package/dist/snapshot-O7ICP7NJ.mjs +0 -783
  559. package/dist/start-S4PFP6RS.mjs +0 -66
  560. package/dist/sync-state-ZWHLAFLE.mjs +0 -15
  561. package/dist/thread-YLJ3ZPQ3.mjs +0 -50
  562. package/dist/write-2OBJGLFS.mjs +0 -233
  563. /package/dist/browser/{chunk-M3MQE2X7.mjs → digest-leaf-64IPRPZD.mjs} +0 -0
  564. /package/dist/browser/{chunk-JNOAKDUM.mjs → gzip-JF3S6PPT.mjs} +0 -0
  565. /package/dist/{chunk-ZXNNR73R.mjs → gzip-2UCZW2MM.mjs} +0 -0
@@ -1,16 +1,785 @@
1
- import { spellingCountsOf, encodePartialSpellings, countSpelling, PARTIAL_WORD_RUN_CODE_POINTS, FROZEN_PARTIAL_REMOVED_ENTRY_BYTES, sameFields, countDocumentSpellings, GROWING_PARTIAL_ENTRY_BYTES, GROWING_PARTIAL_RUN_BYTES, GROWING_PARTIAL_RUN_MEMBER_BYTES, GROWING_PARTIAL_PENDING_ENTRY_BYTES, partitionDocumentFrequency, visitDocumentSpellings, visitDocumentSurfaceSpellings, codePointCountOf, GROWING_PARTIAL_PENDING_ENTRIES_PER_ENTRY } from './chunks/chunk-KU646XXT.mjs';
2
- import { fuzzyTermMatches } from './chunks/chunk-UNUFZ2QY.mjs';
3
- import { encodeStringBlob, tokenize, resolveStopWords, transformToken } from './chunks/chunk-2PRHILX3.mjs';
4
- import './chunks/chunk-4COWCEY7.mjs';
5
- import './chunks/chunk-5CQX3XXV.mjs';
6
- import './chunks/chunk-6VBXNFLE.mjs';
7
- import './chunks/chunk-C5G6TJ7A.mjs';
8
- import './chunks/chunk-3WI35N75.mjs';
9
- import { compareCodePoints, codePointCount } from './chunks/chunk-EJ33LCHV.mjs';
10
- import './chunks/chunk-DXRSEWA2.mjs';
11
- import { PARTIAL_WORD_MIN_CODE_POINTS, PARTIAL_WORDS_ADDED_PER_QUERY, DEFAULT_FUZZY_PREFIX_LENGTH } from './chunks/chunk-AAAETEJK.mjs';
12
- import './chunks/chunk-FTZHMRD2.mjs';
13
- import './chunks/chunk-DZ7H7D2C.mjs';
1
+ import { spellingCountsOf, encodePartialSpellings, countSpelling, SurfaceTable, SURFACE_TABLE_START_CAPACITY, StringPlan, SegmentRefusal, reserveStrings, grownCapacity, PARTIAL_WORD_RUN_CODE_POINTS, encodeStringBlob, sameFields, countDocumentSpellings, tokenize, GROWING_PARTIAL_ENTRY_BYTES, GROWING_PARTIAL_RUN_BYTES, GROWING_PARTIAL_RUN_MEMBER_BYTES, GROWING_PARTIAL_PENDING_ENTRY_BYTES, RUN_TABLE_START_CAPACITY, TERM_REGION_GROWTH_FACTOR, RUN_MEMBER_START_CAPACITY, SLICE_CAPACITIES, TERM_SLOT_LOAD_DENOMINATOR, TERM_SLOT_LOAD_NUMERATOR, PoolPlan, requireRoom, releaseRange, requireSegment, termText, partitionDocumentFrequency, visitDocumentSpellings, visitDocumentSurfaceSpellings, resolveStopWords, transformToken, expansionSource, liveFrequency, codePointCountOf, GROWING_PARTIAL_PENDING_ENTRIES_PER_ENTRY, typedRegion, regionsOverlap, mergeText } from './chunks/chunk-L4R5ITVG.mjs';
2
+ import './chunks/chunk-52QD7CBJ.mjs';
3
+ import { PARTIAL_WORD_MIN_CODE_POINTS, PARTIAL_WORDS_ADDED_PER_QUERY, DEFAULT_FUZZY_PREFIX_LENGTH, FNV_OFFSET_BASIS, FNV_PRIME } from './chunks/chunk-XEGKQKLY.mjs';
4
+ import { fuzzyTermMatches, storedText } from './chunks/chunk-4EXKQ2IB.mjs';
5
+ import './chunks/chunk-G3CUQ333.mjs';
6
+ import './chunks/chunk-PVMEHBQO.mjs';
7
+ import './chunks/chunk-YOTP2FPE.mjs';
8
+ import './chunks/chunk-FTQ7JNMU.mjs';
9
+ import { compareCodePoints, codePointCount } from './chunks/chunk-HRDMIQ63.mjs';
10
+ import './chunks/chunk-VUJCSQG5.mjs';
11
+ import { NarsilError, ErrorCodes } from './chunks/chunk-TQ26BKBH.mjs';
12
+
13
+ // src/core/expansion/partial-bindings.ts
14
+ var PARTIAL_BUDGET;
15
+ var PARTIAL_RUN_POINTS;
16
+ var captureExpansionSource;
17
+ var expansionDictionary;
18
+ var expansionText;
19
+ var expansionToken;
20
+ var readExpansion;
21
+ var validExpansionText;
22
+ function bindPartialExpansionCode(code) {
23
+ ({
24
+ PARTIAL_BUDGET,
25
+ PARTIAL_RUN_POINTS,
26
+ captureExpansionSource,
27
+ expansionDictionary,
28
+ expansionText,
29
+ expansionToken,
30
+ readExpansion,
31
+ validExpansionText
32
+ } = code);
33
+ }
34
+
35
+ // src/core/segment-writes/runs.ts
36
+ function hashRun(points) {
37
+ let hash = FNV_OFFSET_BASIS;
38
+ for (const point of points) {
39
+ for (let byte = 0; byte < 4; byte++) hash = Math.imul(hash ^ point >>> byte * 8 & 255, FNV_PRIME);
40
+ }
41
+ return hash >>> 0;
42
+ }
43
+ function compareRuns(left, right) {
44
+ for (let at = 0; at < 3; at++) if (left[at] !== right[at]) return left[at] < right[at] ? -1 : 1;
45
+ return 0;
46
+ }
47
+ function equalRun(table, ordinal, points) {
48
+ for (let at = 0; at < 3; at++) if (table.runs[ordinal * 3 + at] !== points[at]) return false;
49
+ return true;
50
+ }
51
+ function collectRuns(spellings) {
52
+ const members = [];
53
+ for (let at = 0; at < spellings.size; at++) {
54
+ if (spellings.added[at] === 0 || spellings.points[at] <= 3) continue;
55
+ const spelling = spellings.ordinals[at];
56
+ let first = 0;
57
+ let second = 0;
58
+ let seen = 0;
59
+ for (const character of spellings.texts[at]) {
60
+ const point = character.codePointAt(0) ?? 0;
61
+ if (++seen >= 3) members.push({ points: [first, second, point], spelling });
62
+ first = second;
63
+ second = point;
64
+ }
65
+ }
66
+ members.sort((left, right) => compareRuns(left.points, right.points) || left.spelling - right.spelling);
67
+ let kept = 0;
68
+ for (const member of members) {
69
+ const previous = members[kept - 1];
70
+ if (previous === void 0 || compareRuns(previous.points, member.points) !== 0 || previous.spelling !== member.spelling)
71
+ members[kept++] = member;
72
+ }
73
+ members.length = kept;
74
+ return members;
75
+ }
76
+ var RunPlan = class {
77
+ constructor(table, members) {
78
+ this.table = table;
79
+ this.members = members;
80
+ this.pool = new PoolPlan().begin(table, table.members);
81
+ for (let first = 0; first < members.length; ) {
82
+ let end = first + 1;
83
+ while (end < members.length && compareRuns(members[first].points, members[end].points) === 0) end++;
84
+ const source = { start: 0, length: 0, sliceClass: 255 };
85
+ const change = {
86
+ first,
87
+ length: end - first,
88
+ ordinal: 0,
89
+ slot: 0,
90
+ oldLength: 0,
91
+ added: false,
92
+ source,
93
+ target: source
94
+ };
95
+ this.locate(change);
96
+ if (!change.added) this.previousSlice(change);
97
+ requireRoom(change.length <= 4294967295 - change.oldLength);
98
+ const length = change.oldLength + change.length;
99
+ change.target = length > change.source.length ? this.pool.allocate(length) : change.source;
100
+ this.changes.push(change);
101
+ first = end;
102
+ }
103
+ this.pool.check();
104
+ }
105
+ pool;
106
+ changes = [];
107
+ placed = /* @__PURE__ */ new Set();
108
+ added = 0;
109
+ publish() {
110
+ const table = this.table;
111
+ this.pool.publish();
112
+ for (const change of this.changes) {
113
+ const ordinal = change.ordinal;
114
+ if (change.added) {
115
+ const points = this.members[change.first].points;
116
+ for (let at = 0; at < 3; at++) table.runs[ordinal * 3 + at] = points[at];
117
+ table.slots[change.slot] = ordinal + 1;
118
+ }
119
+ const target = change.target.start;
120
+ if (change.oldLength > 0 && target !== change.source.start)
121
+ table.members.copyWithin(target, change.source.start, change.source.start + change.oldLength);
122
+ for (let at = 0; at < change.length; at++)
123
+ table.members[target + change.oldLength + at] = this.members[change.first + at].spelling;
124
+ table.listStart[ordinal] = target;
125
+ table.listLength[ordinal] = change.oldLength + change.length;
126
+ table.listClass[ordinal] = change.target.sliceClass;
127
+ }
128
+ for (const change of this.changes) {
129
+ if (change.source.sliceClass !== 255 && change.source.start !== change.target.start)
130
+ releaseRange(table, table.members, change.source.start, change.source.length, change.source.sliceClass);
131
+ }
132
+ table.header[0] += this.added;
133
+ }
134
+ locate(change) {
135
+ const table = this.table;
136
+ const points = this.members[change.first].points;
137
+ const mask = table.slots.length - 1;
138
+ let slot = hashRun(points) & mask;
139
+ let available = -1;
140
+ for (let scanned = 0; scanned < table.slots.length; scanned++) {
141
+ if (!this.placed.has(slot)) {
142
+ const entry = table.slots[slot];
143
+ if (entry > 0 && entry <= table.header[0] && equalRun(table, entry - 1, points)) {
144
+ change.ordinal = entry - 1;
145
+ change.slot = slot;
146
+ return;
147
+ }
148
+ if (entry <= 0) {
149
+ if (available < 0) available = slot;
150
+ else if (entry === 0) {
151
+ const ordinal = table.header[0] + this.added;
152
+ requireRoom(ordinal < table.listStart.length && ordinal < 2147483647);
153
+ change.ordinal = ordinal;
154
+ change.slot = available;
155
+ change.added = true;
156
+ this.placed.add(available);
157
+ this.added++;
158
+ return;
159
+ }
160
+ }
161
+ }
162
+ slot = slot + 1 & mask;
163
+ }
164
+ requireRoom(false);
165
+ }
166
+ previousSlice(change) {
167
+ const table = this.table;
168
+ const ordinal = change.ordinal;
169
+ const sliceClass = table.listClass[ordinal];
170
+ const start = table.listStart[ordinal];
171
+ requireSegment(sliceClass < table.sliceCapacities.length && start <= table.allocation[0]);
172
+ const capacity = table.sliceCapacities[sliceClass];
173
+ const length = table.listLength[ordinal];
174
+ requireSegment(capacity <= table.allocation[0] - start && length <= capacity);
175
+ change.source = { start, length: capacity, sliceClass };
176
+ change.oldLength = length;
177
+ }
178
+ };
179
+ function hasSpelling(members, first, end, spelling) {
180
+ let low = first;
181
+ let high = end;
182
+ while (low < high) {
183
+ const middle = low + Math.floor((high - low) / 2);
184
+ if (members[middle].spelling < spelling) low = middle + 1;
185
+ else high = middle;
186
+ }
187
+ return low < end && members[low].spelling === spelling;
188
+ }
189
+ function removalOrdinal(table, points) {
190
+ const mask = table.slots.length - 1;
191
+ let slot = hashRun(points) & mask;
192
+ for (let scanned = 0; scanned < table.slots.length; scanned++) {
193
+ const entry = table.slots[slot];
194
+ if (entry === 0) break;
195
+ if (entry > 0 && entry <= table.header[0] && equalRun(table, entry - 1, points)) return entry - 1;
196
+ slot = slot + 1 & mask;
197
+ }
198
+ throw new SegmentRefusal(1);
199
+ }
200
+ function checkRemoval(table, ordinal, members, first, end) {
201
+ const start = table.listStart[ordinal];
202
+ const length = table.listLength[ordinal];
203
+ const allocated = table.allocation[0];
204
+ const kind = table.listClass[ordinal];
205
+ requireSegment(
206
+ allocated <= table.members.length && start <= allocated && kind < table.sliceCapacities.length && length <= table.sliceCapacities[kind] && table.sliceCapacities[kind] <= allocated - start
207
+ );
208
+ let found = first;
209
+ for (let at = start; at < start + length; at++) {
210
+ const spelling = table.members[at];
211
+ requireSegment(at === start || spelling > table.members[at - 1]);
212
+ if (found < end && spelling === members[found].spelling) found++;
213
+ }
214
+ requireSegment(found === end);
215
+ }
216
+ function prepareRunRemoval(table, members) {
217
+ const changes = [];
218
+ for (let first = 0; first < members.length; ) {
219
+ let end = first + 1;
220
+ while (end < members.length && compareRuns(members[first].points, members[end].points) === 0) end++;
221
+ const ordinal = removalOrdinal(table, members[first].points);
222
+ checkRemoval(table, ordinal, members, first, end);
223
+ changes.push({ ordinal, first, end });
224
+ first = end;
225
+ }
226
+ changes.sort((left, right) => table.listStart[left.ordinal] - table.listStart[right.ordinal]);
227
+ for (let at = 1; at < changes.length; at++) {
228
+ const previous = changes[at - 1].ordinal;
229
+ requireSegment(
230
+ table.listStart[previous] + table.sliceCapacities[table.listClass[previous]] <= table.listStart[changes[at].ordinal]
231
+ );
232
+ }
233
+ return () => {
234
+ for (const { ordinal, first, end } of changes) {
235
+ const start = table.listStart[ordinal];
236
+ const length = table.listLength[ordinal];
237
+ let kept = 0;
238
+ for (let at = start; at < start + length; at++) {
239
+ const spelling = table.members[at];
240
+ if (!hasSpelling(members, first, end, spelling)) table.members[start + kept++] = spelling;
241
+ }
242
+ table.listLength[ordinal] = kept;
243
+ }
244
+ };
245
+ }
246
+
247
+ // src/core/segment-writes/run-table.ts
248
+ var COUNT = 0;
249
+ var SLOT_CAPACITY = 2;
250
+ var HEADER_WORDS = 8;
251
+ var RUN_POINTS = 3;
252
+ var LAST_SLOT_CAPACITY = 2147483648;
253
+ var LAST_RUN_COUNT = 2147483647;
254
+ var NO_FREE_SLICE = 4294967295;
255
+ function hashRun2(runs, at) {
256
+ let hash = FNV_OFFSET_BASIS;
257
+ for (let index = at; index < at + RUN_POINTS; index++) {
258
+ const point = runs[index];
259
+ for (let byte = 0; byte < 4; byte++) hash = Math.imul(hash ^ point >>> byte * 8 & 255, FNV_PRIME);
260
+ }
261
+ return hash >>> 0;
262
+ }
263
+ var RunTable = class {
264
+ header = new Uint32Array(HEADER_WORDS);
265
+ slots = new Int32Array(RUN_TABLE_START_CAPACITY * TERM_REGION_GROWTH_FACTOR);
266
+ runs = new Uint32Array(RUN_TABLE_START_CAPACITY * RUN_POINTS);
267
+ listStart = new Uint32Array(RUN_TABLE_START_CAPACITY);
268
+ listLength = new Uint32Array(RUN_TABLE_START_CAPACITY);
269
+ listClass = new Uint8Array(RUN_TABLE_START_CAPACITY);
270
+ members = new Uint32Array(RUN_MEMBER_START_CAPACITY);
271
+ allocation = new Uint32Array(2);
272
+ freeHeads = new Uint32Array(SLICE_CAPACITIES.length).fill(NO_FREE_SLICE);
273
+ sliceCapacities = SLICE_CAPACITIES;
274
+ constructor() {
275
+ this.header[SLOT_CAPACITY] = this.slots.length;
276
+ }
277
+ reserve(count, members) {
278
+ if (!Number.isInteger(count) || count < this.header[COUNT] || count > LAST_RUN_COUNT)
279
+ throw new NarsilError(ErrorCodes.CONFIG_INVALID, "The run table exceeds its slot layout");
280
+ let slots = this.slots;
281
+ let slotCapacity = slots.length;
282
+ while (count * TERM_SLOT_LOAD_DENOMINATOR >= slotCapacity * TERM_SLOT_LOAD_NUMERATOR) {
283
+ slotCapacity *= TERM_REGION_GROWTH_FACTOR;
284
+ if (slotCapacity > LAST_SLOT_CAPACITY)
285
+ throw new NarsilError(ErrorCodes.CONFIG_INVALID, "The run table exceeds its slot layout");
286
+ }
287
+ if (slotCapacity > slots.length) slots = this.rehash(slotCapacity);
288
+ let runs = this.runs;
289
+ let starts = this.listStart;
290
+ let lengths = this.listLength;
291
+ let classes = this.listClass;
292
+ if (count > starts.length) {
293
+ const capacity = Math.min(LAST_RUN_COUNT, Math.max(count, starts.length * TERM_REGION_GROWTH_FACTOR));
294
+ runs = new Uint32Array(capacity * RUN_POINTS);
295
+ starts = new Uint32Array(capacity);
296
+ lengths = new Uint32Array(capacity);
297
+ classes = new Uint8Array(capacity);
298
+ runs.set(this.runs);
299
+ starts.set(this.listStart);
300
+ lengths.set(this.listLength);
301
+ classes.set(this.listClass);
302
+ }
303
+ let values = this.members;
304
+ if (members > values.length) {
305
+ values = new Uint32Array(grownCapacity(values.length, members));
306
+ values.set(this.members.subarray(0, this.allocation[0]));
307
+ }
308
+ this.slots = slots;
309
+ this.header[SLOT_CAPACITY] = slotCapacity;
310
+ this.runs = runs;
311
+ this.listStart = starts;
312
+ this.listLength = lengths;
313
+ this.listClass = classes;
314
+ this.members = values;
315
+ }
316
+ byteLength() {
317
+ return this.header.byteLength + this.slots.byteLength + this.runs.byteLength + this.listStart.byteLength + this.listLength.byteLength + this.listClass.byteLength + this.members.byteLength + this.allocation.byteLength + this.freeHeads.byteLength;
318
+ }
319
+ trim() {
320
+ const count = Math.max(RUN_TABLE_START_CAPACITY, this.header[COUNT]);
321
+ let capacity = RUN_TABLE_START_CAPACITY * TERM_REGION_GROWTH_FACTOR;
322
+ while (count * TERM_SLOT_LOAD_DENOMINATOR >= capacity * TERM_SLOT_LOAD_NUMERATOR)
323
+ capacity *= TERM_REGION_GROWTH_FACTOR;
324
+ const columns = {
325
+ slots: capacity < this.slots.length ? this.rehash(capacity) : this.slots,
326
+ runs: this.runs.slice(0, count * RUN_POINTS),
327
+ listStart: this.listStart.slice(0, count),
328
+ listLength: this.listLength.slice(0, count),
329
+ listClass: this.listClass.slice(0, count),
330
+ members: this.members.slice(0, Math.max(RUN_MEMBER_START_CAPACITY, this.allocation[0]))
331
+ };
332
+ Object.assign(this, columns);
333
+ this.header[SLOT_CAPACITY] = this.slots.length;
334
+ }
335
+ rehash(capacity) {
336
+ const slots = new Int32Array(capacity);
337
+ const mask = capacity - 1;
338
+ for (const entry of this.slots) {
339
+ if (entry <= 0) continue;
340
+ let slot = hashRun2(this.runs, (entry - 1) * RUN_POINTS) & mask;
341
+ while (slots[slot] !== 0) slot = slot + 1 & mask;
342
+ slots[slot] = entry;
343
+ }
344
+ return slots;
345
+ }
346
+ };
347
+
348
+ // src/core/segment-writes/spelling-table.ts
349
+ var SpellingTable = class extends SurfaceTable {
350
+ codePoints = new Uint32Array(SURFACE_TABLE_START_CAPACITY);
351
+ runs = new RunTable();
352
+ load(source, terms) {
353
+ this.reserveWords(new Set(source.spellings));
354
+ const plan = new StringPlan(this.strings);
355
+ for (let at = 0; at < source.spellings.length; at++) {
356
+ const token = terms.ids.get(source.tokens[at]);
357
+ if (token === void 0 || terms.frequencyAt(token) === 0) continue;
358
+ const spelling = source.spellings[at];
359
+ const entry = plan.prepare(spelling);
360
+ if (plan.counts[entry] === 0) plan.tokens[entry] = token;
361
+ plan.counts[entry] += source.counts[at];
362
+ let points = 0;
363
+ for (const _point of spelling) points++;
364
+ plan.points[entry] = points;
365
+ if (plan.counts[entry] > 4294967295) throw new SegmentRefusal(8);
366
+ }
367
+ plan.check();
368
+ const runs = new RunPlan(this.runs, collectRuns(plan));
369
+ plan.publish();
370
+ for (let at = 0; at < plan.size; at++) {
371
+ const ordinal = plan.ordinals[at];
372
+ this.token[ordinal] = plan.tokens[at];
373
+ this.count[ordinal] = plan.counts[at];
374
+ this.codePoints[ordinal] = plan.points[at];
375
+ }
376
+ runs.publish();
377
+ }
378
+ reserveWords(words) {
379
+ const spellings = /* @__PURE__ */ new Set();
380
+ const plan = new StringPlan(this.strings);
381
+ for (const word of words) {
382
+ let points = 0;
383
+ for (const _point of word) points++;
384
+ if (points <= 3) continue;
385
+ spellings.add(word);
386
+ plan.points[plan.prepare(word)] = points;
387
+ }
388
+ reserveStrings(this, spellings);
389
+ const members = collectRuns(plan);
390
+ if (members.length === 0) return;
391
+ const count = this.runs.header[0] + members.length;
392
+ this.runs.reserve(count, this.runs.members.length);
393
+ for (; ; ) {
394
+ try {
395
+ new RunPlan(this.runs, members);
396
+ return;
397
+ } catch (error) {
398
+ if (!(error instanceof SegmentRefusal) || error.status !== 3) throw error;
399
+ this.runs.reserve(count, grownCapacity(this.runs.members.length, this.runs.members.length + 1));
400
+ }
401
+ }
402
+ }
403
+ reserve(entries, units2) {
404
+ const prepared = this.prepareCapacity(entries, units2);
405
+ let points = this.codePoints;
406
+ if (prepared.capacity > points.length) {
407
+ points = new Uint32Array(prepared.capacity);
408
+ points.set(this.codePoints);
409
+ }
410
+ prepared.apply();
411
+ this.codePoints = points;
412
+ }
413
+ byteLength() {
414
+ return super.byteLength() + this.codePoints.byteLength + this.runs.byteLength();
415
+ }
416
+ };
417
+
418
+ // src/core/segment-writes/vacuum-runs.ts
419
+ var RunVacuum = class {
420
+ constructor(table, mapping) {
421
+ this.table = table;
422
+ this.mapping = mapping;
423
+ this.sourceCount = table.header[0];
424
+ const end = table.allocation[0];
425
+ requireSegment(end <= table.members.length && table.allocation[1] <= end);
426
+ let previous = 0;
427
+ for (const capacity of table.sliceCapacities) {
428
+ requireSegment(capacity > previous);
429
+ previous = capacity;
430
+ }
431
+ this.members = new Uint32Array(end);
432
+ for (let at = 0; at < this.sourceCount; at++) this.collect(at);
433
+ requireSegment(this.runs.length < table.slots.length);
434
+ this.slices.sort((left, right) => left.start - right.start);
435
+ for (let at = 1; at < this.slices.length; at++)
436
+ requireSegment(this.slices[at].start - this.slices[at - 1].start >= this.slices[at - 1].length);
437
+ }
438
+ runs = [];
439
+ members;
440
+ slices = [];
441
+ memberCount = 0;
442
+ sourceCount;
443
+ validSlot(ordinal, points) {
444
+ const table = this.table;
445
+ const mask = table.slots.length - 1;
446
+ let slot = hashRun(points) & mask;
447
+ for (let seen = 0; seen < table.slots.length; seen++) {
448
+ const entry = table.slots[slot];
449
+ if (entry === 0) return false;
450
+ if (entry > 0 && entry <= this.sourceCount && points.every((point, at) => point === table.runs[(entry - 1) * 3 + at]))
451
+ return entry - 1 === ordinal;
452
+ slot = slot + 1 & mask;
453
+ }
454
+ return false;
455
+ }
456
+ collect(ordinal) {
457
+ const table = this.table;
458
+ const start = table.listStart[ordinal];
459
+ const length = table.listLength[ordinal];
460
+ const end = table.allocation[0];
461
+ const kind = table.listClass[ordinal];
462
+ const points = Array.from(table.runs.subarray(ordinal * 3, ordinal * 3 + 3));
463
+ requireSegment(kind < table.sliceCapacities.length && start <= end && this.validSlot(ordinal, points));
464
+ const size = table.sliceCapacities[kind];
465
+ requireSegment(size <= end - start && length <= size);
466
+ this.slices.push({ start, length: size });
467
+ const run = { points, start: this.memberCount, length: 0, sliceClass: 0 };
468
+ for (let at = start; at < start + length; at++) {
469
+ const member = table.members[at];
470
+ requireSegment(member < this.mapping.length && (at === start || table.members[at - 1] < member));
471
+ const target = this.mapping[member];
472
+ if (target === 4294967295) continue;
473
+ requireSegment(this.memberCount < end);
474
+ this.members[this.memberCount++] = target;
475
+ run.length++;
476
+ }
477
+ if (run.length === 0) return;
478
+ while (run.sliceClass < table.sliceCapacities.length && table.sliceCapacities[run.sliceClass] < run.length)
479
+ run.sliceClass++;
480
+ requireSegment(
481
+ run.sliceClass < table.sliceCapacities.length && table.sliceCapacities[run.sliceClass] <= end - run.start
482
+ );
483
+ this.memberCount = run.start + table.sliceCapacities[run.sliceClass];
484
+ this.runs.push(run);
485
+ }
486
+ publish() {
487
+ const table = this.table;
488
+ table.slots.fill(0);
489
+ const mask = table.slots.length - 1;
490
+ for (let at = 0; at < this.runs.length; at++) {
491
+ const run = this.runs[at];
492
+ table.runs.set(run.points, at * 3);
493
+ let slot = hashRun(run.points) & mask;
494
+ while (table.slots[slot] !== 0) slot = slot + 1 & mask;
495
+ table.slots[slot] = at + 1;
496
+ table.listStart[at] = run.start;
497
+ table.listLength[at] = run.length;
498
+ table.listClass[at] = run.sliceClass;
499
+ table.members.set(this.members.subarray(run.start, run.start + run.length), run.start);
500
+ }
501
+ table.listLength.fill(0, this.runs.length, this.sourceCount);
502
+ table.header[0] = this.runs.length;
503
+ table.allocation[0] = this.memberCount;
504
+ table.allocation[1] = 0;
505
+ table.freeHeads.fill(4294967295);
506
+ }
507
+ };
508
+
509
+ // src/core/expansion/partial-regions.ts
510
+ function unsigned(value) {
511
+ requireSegment(Number.isInteger(value) && value >= 0 && value <= 4294967295);
512
+ }
513
+ function readPartialExpansion(input, requests, outStarts, outSegments, outTokens, outFactors) {
514
+ requireSegment(Array.isArray(input) && input.length <= 4294967295);
515
+ requireSegment(Array.isArray(requests) && requests.length <= 4294967295);
516
+ const sources = input.map((source) => {
517
+ requireSegment(typeof source === "object" && source !== null);
518
+ const raw = { ...source };
519
+ requireSegment(raw.runs === null || typeof raw.runs === "object" && raw.runs !== null);
520
+ return { segment: captureExpansionSource(raw.segment), runs: raw.runs === null ? null : { ...raw.runs } };
521
+ });
522
+ const words = requests.map((request) => {
523
+ requireSegment(typeof request === "object" && request !== null);
524
+ return { ...request };
525
+ });
526
+ const held = readExpansion(
527
+ sources.map((source) => source.segment),
528
+ words.flatMap((word) => [word.written, word.own]),
529
+ outSegments,
530
+ outTokens,
531
+ outFactors
532
+ );
533
+ const starts = typedRegion(outStarts, "Uint32Array");
534
+ requireSegment(starts !== null);
535
+ const outputs = [starts, held.segments, held.tokens, held.factors];
536
+ for (let at = 1; at < outputs.length; at++) requireSegment(!regionsOverlap(starts, outputs[at]));
537
+ for (const region of held.arrays) requireSegment(!regionsOverlap(starts, region));
538
+ const runs = sources.map((source, at) => {
539
+ const raw = source.runs;
540
+ requireSegment(held.sources[at].growing === null || raw === null);
541
+ if (raw === null) return null;
542
+ const points = typedRegion(raw.runs, "Uint32Array");
543
+ const offsets = typedRegion(raw.offsets, "Uint32Array");
544
+ const members = typedRegion(raw.members, "Uint32Array");
545
+ requireSegment(points !== null && offsets !== null && members !== null);
546
+ requireSegment(points.length % 3 === 0 && points.length / 3 <= 4294967295);
547
+ requireSegment(offsets.length === points.length / 3 + 1 && members.length <= 4294967295);
548
+ for (const output of outputs)
549
+ for (const region of [points, offsets, members]) requireSegment(!regionsOverlap(output, region));
550
+ return { runs: points, offsets, members };
551
+ });
552
+ const queries = words.map((word) => {
553
+ unsigned(word.tolerance);
554
+ unsigned(word.prefixLength);
555
+ return { ...word, written: expansionText(word.written), own: expansionText(word.own) };
556
+ });
557
+ requireRoom(starts.length >= words.length + 1);
558
+ return { ...held, starts, runs, queries };
559
+ }
560
+
561
+ // src/core/expansion/partial-source.ts
562
+ function growingRun(table, points) {
563
+ const mask = table.slots.length - 1;
564
+ let slot = hashRun(points) & mask;
565
+ for (let scanned = 0; scanned < table.slots.length; scanned++) {
566
+ const entry = table.slots[slot];
567
+ if (entry === 0) return -1;
568
+ if (entry > 0 && entry <= table.header[0]) {
569
+ const start = (entry - 1) * PARTIAL_RUN_POINTS;
570
+ if (points.every((point, at) => point === table.runs[start + at])) return entry - 1;
571
+ }
572
+ slot = slot + 1 & mask;
573
+ }
574
+ return -1;
575
+ }
576
+ function frozenRun(table, points) {
577
+ let low = 0;
578
+ let high = table.runs.length / PARTIAL_RUN_POINTS;
579
+ while (low < high) {
580
+ const middle = low + Math.floor((high - low) / 2);
581
+ const start = middle * PARTIAL_RUN_POINTS;
582
+ const difference = table.runs[start] - points[0] || table.runs[start + 1] - points[1] || table.runs[start + 2] - points[2];
583
+ if (difference === 0) return middle;
584
+ if (difference < 0) low = middle + 1;
585
+ else high = middle;
586
+ }
587
+ return -1;
588
+ }
589
+ function partialMembers(source, frozenRuns, points) {
590
+ const growing = source.growing?.spellings?.runs;
591
+ if (growing === void 0 && frozenRuns === null) return null;
592
+ let selected = null;
593
+ for (let at = 0; at + PARTIAL_RUN_POINTS <= points.length; at++) {
594
+ const triple = points.slice(at, at + PARTIAL_RUN_POINTS);
595
+ let members;
596
+ if (growing !== void 0) {
597
+ const run = growingRun(growing, triple);
598
+ if (run < 0) return null;
599
+ const start = growing.listStart[run];
600
+ const count = growing.listLength[run];
601
+ const kind = growing.listClass[run];
602
+ const allocated = growing.allocation[0];
603
+ if (kind >= growing.sliceCapacities.length || allocated > growing.members.length || start > allocated) return null;
604
+ const capacity = growing.sliceCapacities[kind];
605
+ if (count > capacity || capacity > allocated - start) return null;
606
+ members = growing.members.subarray(start, start + count);
607
+ } else {
608
+ if (frozenRuns === null) return null;
609
+ const run = frozenRun(frozenRuns, triple);
610
+ if (run < 0) return null;
611
+ const start = frozenRuns.offsets[run];
612
+ const end = frozenRuns.offsets[run + 1];
613
+ if (start > end || end > frozenRuns.members.length) return null;
614
+ members = frozenRuns.members.subarray(start, end);
615
+ }
616
+ if (selected === null || members.length < selected.length) selected = members;
617
+ }
618
+ return selected;
619
+ }
620
+ function partialSpelling(source, ordinal) {
621
+ let text;
622
+ let token;
623
+ if (source.growing !== null) {
624
+ const table = source.growing.spellings;
625
+ if (table === null || ordinal >= table.strings.header[0] || table.count[ordinal] === 0) return null;
626
+ const start = table.strings.termOffset[ordinal];
627
+ const length = table.strings.termLength[ordinal];
628
+ if (start > table.strings.header[4] || length > table.strings.header[4] - start || length > 1073741824) return null;
629
+ text = storedText(table.strings.units, start, length);
630
+ token = table.token[ordinal];
631
+ } else {
632
+ const table = source.frozen?.spellings;
633
+ const state = source.state;
634
+ if (table === void 0 || table === null || state === null || ordinal >= table.counts.length || state.removedSpellings[ordinal] >= table.counts[ordinal])
635
+ return null;
636
+ text = mergeText(table, ordinal);
637
+ token = source.frozen?.spellingTokens[ordinal] ?? 4294967295;
638
+ }
639
+ return text === null || !validExpansionText(text) ? null : { text, token };
640
+ }
641
+
642
+ // src/core/expansion/partial.ts
643
+ var expandPartialWords = (...args) => {
644
+ try {
645
+ const held = readPartialExpansion(...args);
646
+ const dictionaries = held.sources.map(expansionDictionary);
647
+ const lengths = held.queries.map((query) => codePointCount(query.written));
648
+ const eligible = Math.min(PARTIAL_BUDGET, lengths.filter((length) => length >= PARTIAL_RUN_POINTS).length);
649
+ const output = [];
650
+ const starts = [0];
651
+ let order = 0;
652
+ for (let queryAt = 0; queryAt < held.queries.length; queryAt++) {
653
+ const query = held.queries[queryAt];
654
+ if (lengths[queryAt] < PARTIAL_RUN_POINTS || order >= PARTIAL_BUDGET) {
655
+ starts.push(output.length);
656
+ continue;
657
+ }
658
+ const share = Math.floor(PARTIAL_BUDGET / eligible) + (order++ < PARTIAL_BUDGET % eligible ? 1 : 0);
659
+ const points = Array.from(query.written, (character) => character.codePointAt(0) ?? 0);
660
+ const candidates = /* @__PURE__ */ new Map();
661
+ for (let segment = 0; segment < held.sources.length; segment++) {
662
+ const source = held.sources[segment];
663
+ const dictionary = dictionaries[segment];
664
+ for (const entry of partialMembers(source, held.runs[segment], points) ?? []) {
665
+ const spelling = partialSpelling(source, entry);
666
+ if (spelling === null || !spelling.text.includes(query.written)) continue;
667
+ const length = codePointCount(spelling.text);
668
+ if (length <= points.length) continue;
669
+ const text = termText(dictionary, spelling.token);
670
+ if (text === null || !validExpansionText(text) || liveFrequency(dictionary, spelling.token) === 0) continue;
671
+ if (fuzzyTermMatches(query.own, text, query.tolerance, query.prefixLength)) continue;
672
+ const previous = candidates.get(text);
673
+ if (previous !== void 0) {
674
+ previous.length = Math.min(previous.length, length);
675
+ if (segment < previous.segment || segment === previous.segment && spelling.token < previous.token) {
676
+ previous.segment = segment;
677
+ previous.token = spelling.token;
678
+ }
679
+ } else candidates.set(text, { text, segment, token: spelling.token, length, documents: 0 });
680
+ }
681
+ }
682
+ const ranked = [...candidates.values()];
683
+ for (const candidate of ranked) {
684
+ for (const dictionary of dictionaries) {
685
+ const token = expansionToken(dictionary, candidate.text);
686
+ if (token !== null) candidate.documents += liveFrequency(dictionary, token);
687
+ }
688
+ }
689
+ ranked.sort((left, right) => right.documents - left.documents || compareCodePoints(left.text, right.text));
690
+ for (let at = 0; at < Math.min(share, ranked.length); at++) {
691
+ const candidate = ranked[at];
692
+ output.push({ segment: candidate.segment, token: candidate.token, factor: points.length / candidate.length });
693
+ }
694
+ starts.push(output.length);
695
+ }
696
+ requireRoom(
697
+ output.length <= held.segments.length && output.length <= held.tokens.length && output.length <= held.factors.length
698
+ );
699
+ for (let at = 0; at < output.length; at++) {
700
+ held.segments[at] = output[at].segment;
701
+ held.tokens[at] = output[at].token;
702
+ held.factors[at] = output[at].factor;
703
+ }
704
+ held.starts.set(starts);
705
+ return output.length;
706
+ } catch (error) {
707
+ if (error instanceof SegmentRefusal) return -error.status;
708
+ throw error;
709
+ }
710
+ };
711
+
712
+ // src/core/expansion/partial-host.ts
713
+ function sourceOf(state, analysis) {
714
+ state.partialWords.readerFor(analysis);
715
+ const source = expansionSource(state);
716
+ if (source === null) return null;
717
+ if (source.growing !== null) {
718
+ let spellings = state.partialWords.growingRegions?.() ?? null;
719
+ if (spellings === null) {
720
+ const encoded = state.partialWords.spellings();
721
+ const terms = state.invertedIdx.livePostings?.terms;
722
+ if (encoded !== null && terms !== void 0) {
723
+ const table2 = new SpellingTable();
724
+ table2.load(encoded, terms);
725
+ spellings = table2;
726
+ }
727
+ }
728
+ return { segment: { ...source, growing: { ...source.growing, spellings } }, runs: null };
729
+ }
730
+ const held = state.partialWords.removalState?.();
731
+ if (held === void 0 || held === null || source.frozen === null || source.state === null)
732
+ return { segment: source, runs: null };
733
+ const { table, removed } = held;
734
+ return {
735
+ segment: {
736
+ ...source,
737
+ growing: null,
738
+ frozen: {
739
+ ...source.frozen,
740
+ spellings: { text: table.spellings, offsets: table.spellingOffsets, counts: table.spellingCounts },
741
+ spellingTokens: table.spellingTokens
742
+ },
743
+ state: { ...source.state, removedSpellings: removed }
744
+ },
745
+ runs: { runs: table.runs, offsets: table.runOffsets, members: table.runEntries }
746
+ };
747
+ }
748
+ function units(text) {
749
+ return Uint16Array.from({ length: text.length }, (_, at) => text.charCodeAt(at));
750
+ }
751
+ function partialAdditions(states, analysis, requests) {
752
+ if (analysis.fields.length === 0 || requests.length === 0) return requests.map(() => []);
753
+ const sources = [];
754
+ for (const state of states) {
755
+ const source = sourceOf(state, analysis);
756
+ if (source === null) return null;
757
+ sources.push(source);
758
+ }
759
+ const starts = new Uint32Array(requests.length + 1);
760
+ const segments = new Uint32Array(PARTIAL_BUDGET);
761
+ const tokens = new Uint32Array(PARTIAL_BUDGET);
762
+ const factors = new Float64Array(PARTIAL_BUDGET);
763
+ const queries = requests.map((request) => ({
764
+ written: units(request.written),
765
+ own: units(request.ownToken),
766
+ tolerance: request.tolerance,
767
+ prefixLength: request.prefixLength
768
+ }));
769
+ const count = expandPartialWords(sources, queries, starts, segments, tokens, factors);
770
+ if (count < 0)
771
+ throw new NarsilError(ErrorCodes.PARTITION_CORRUPTED, `The partial-word operation refused status ${-count}`);
772
+ return requests.map((_, query) => {
773
+ const added = [];
774
+ for (let at = starts[query]; at < starts[query + 1]; at++) {
775
+ const token = termText(expansionDictionary(sources[segments[at]].segment), tokens[at]);
776
+ if (token === null)
777
+ throw new NarsilError(ErrorCodes.PARTITION_CORRUPTED, "The partial-word addition refers to an invalid token");
778
+ added.push({ token, factor: factors[at] });
779
+ }
780
+ return added;
781
+ });
782
+ }
14
783
 
15
784
  // src/core/partition/partial-words/text.ts
16
785
  var encoder = new TextEncoder();
@@ -84,7 +853,9 @@ function addedWordsFor(subs, readers, request) {
84
853
  const writtenLength = probe.codePoints.length;
85
854
  return ranked.map((word) => ({ token: word.token, factor: writtenLength / word.spellingLength }));
86
855
  }
87
- function expandPartialWords(subs, analysis, requests) {
856
+ function expandPartialWords2(subs, analysis, requests) {
857
+ const native = partialAdditions(subs, analysis, requests);
858
+ if (native !== null) return native;
88
859
  const readers = [];
89
860
  for (const sub of subs) {
90
861
  const reader = sub.partialWords.readerFor(analysis);
@@ -94,7 +865,7 @@ function expandPartialWords(subs, analysis, requests) {
94
865
  }
95
866
 
96
867
  // src/core/partition/partial-words/frozen-table.ts
97
- var decoder = new TextDecoder();
868
+ var decoder = new TextDecoder("utf-8", { ignoreBOM: true });
98
869
  function compareEntries(left, right) {
99
870
  return compareCodePoints(left.spelling, right.spelling) || left.tokenIndex - right.tokenIndex;
100
871
  }
@@ -159,11 +930,16 @@ function buildPartialWordTable(source, tokenTable) {
159
930
  runEntries
160
931
  };
161
932
  }
162
- function countTableSpellings(counts, table, tokenTable) {
933
+ function countTableSpellings(counts, table, tokenTable, removedCounts) {
163
934
  const { spellings, spellingOffsets, spellingTokens, spellingCounts } = table;
164
935
  for (let entry = 0; entry < spellingTokens.length; entry++) {
165
936
  const spelling = decoder.decode(spellings.subarray(spellingOffsets[entry], spellingOffsets[entry + 1]));
166
- countSpelling(counts, tokenTable.tokenAt(spellingTokens[entry]), spelling, spellingCounts[entry]);
937
+ countSpelling(
938
+ counts,
939
+ tokenTable.tokenAt(spellingTokens[entry]),
940
+ spelling,
941
+ Math.max(0, spellingCounts[entry] - (removedCounts?.[entry] ?? 0))
942
+ );
167
943
  }
168
944
  }
169
945
  function findRun(runs, first, second, third) {
@@ -208,14 +984,14 @@ function readPartialWordTable(table, tokenTable, removedCounts) {
208
984
  const start = spellingOffsets[entry];
209
985
  const end = spellingOffsets[entry + 1];
210
986
  if (end - start <= probe.utf8.length) continue;
211
- if ((removedCounts.get(entry) ?? 0) >= spellingCounts[entry]) continue;
987
+ if (removedCounts[entry] >= spellingCounts[entry]) continue;
212
988
  if (!utf8Contains(spellings, start, end, probe.utf8)) continue;
213
989
  const length = utf8CodePointCount(spellings, start, end);
214
990
  if (length <= probe.codePoints.length) continue;
215
991
  visit(tokenTable.tokenAt(spellingTokens[entry]), length);
216
992
  }
217
993
  },
218
- entryOf(spelling) {
994
+ entryOf(spelling, token) {
219
995
  const probe = partialWordProbe(spelling);
220
996
  if (probe.codePoints.length <= PARTIAL_WORD_RUN_CODE_POINTS) return -1;
221
997
  const run = narrowestRun(probe.codePoints);
@@ -223,10 +999,11 @@ function readPartialWordTable(table, tokenTable, removedCounts) {
223
999
  let exhausted = -1;
224
1000
  for (let member = runOffsets[run]; member < runOffsets[run + 1]; member++) {
225
1001
  const entry = runEntries[member];
1002
+ if (token !== void 0 && tokenTable.tokenAt(spellingTokens[entry]) !== token) continue;
226
1003
  const start = spellingOffsets[entry];
227
1004
  const end = spellingOffsets[entry + 1];
228
1005
  if (end - start !== probe.utf8.length || !utf8Contains(spellings, start, end, probe.utf8)) continue;
229
- if ((removedCounts.get(entry) ?? 0) < spellingCounts[entry]) return entry;
1006
+ if (removedCounts[entry] < spellingCounts[entry]) return entry;
230
1007
  if (exhausted < 0) exhausted = entry;
231
1008
  }
232
1009
  return exhausted;
@@ -287,38 +1064,48 @@ function subtractRemovedSpellings(counts, removed, analysis) {
287
1064
  function createFrozenPartialWordSlot(initial, tokenTable, documents) {
288
1065
  let table = initial;
289
1066
  let uncounted = null;
290
- let removedCounts = /* @__PURE__ */ new Map();
1067
+ let removedCounts = new Uint32Array(initial?.spellingCounts.length ?? 0);
291
1068
  let reader = initial === null ? null : readPartialWordTable(initial, tokenTable, removedCounts);
292
1069
  let pendingRemovals = [];
293
1070
  function isCounted(ordinal) {
294
- return uncounted === null || uncounted[ordinal] === 0;
1071
+ return (uncounted === null || uncounted[ordinal] === 0) && !documents.isTombstoned(ordinal);
1072
+ }
1073
+ function applyRemoval(changes) {
1074
+ if (table === null) return;
1075
+ for (const [entry, count] of changes)
1076
+ removedCounts[entry] = Math.min(table.spellingCounts[entry], removedCounts[entry] + count);
295
1077
  }
296
1078
  function subtractPendingRemovals(current, analysis) {
297
1079
  if (pendingRemovals.length === 0) return;
298
1080
  const removed = /* @__PURE__ */ new Map();
299
1081
  for (const ordinal of pendingRemovals) countRemovedSpellings(removed, documents.documentAt(ordinal), analysis);
300
- pendingRemovals = [];
301
1082
  const unstemmedSpelling = unstemmedSpellingsOf(analysis);
1083
+ const changes = /* @__PURE__ */ new Map();
302
1084
  for (const [spelling, count] of removed) {
303
1085
  let entry = current.entryOf(spelling);
304
1086
  if (entry < 0) {
305
1087
  const fallback = unstemmedSpelling(spelling);
306
1088
  if (fallback !== null) entry = current.entryOf(fallback);
307
1089
  }
308
- if (entry >= 0) removedCounts.set(entry, (removedCounts.get(entry) ?? 0) + count);
1090
+ if (entry >= 0) changes.set(entry, (changes.get(entry) ?? 0) + count);
309
1091
  }
1092
+ applyRemoval(changes);
1093
+ pendingRemovals = [];
310
1094
  }
311
1095
  function rebuild(analysis) {
312
- uncounted = tombstonedOrdinalsOf(documents);
1096
+ const excluded = tombstonedOrdinalsOf(documents);
313
1097
  const counts = /* @__PURE__ */ new Map();
314
1098
  for (let ordinal = 0; ordinal < documents.count; ordinal++) {
315
- if (isCounted(ordinal)) countDocumentSpellings(counts, documents.documentAt(ordinal), analysis, 1);
1099
+ if (excluded === null || excluded[ordinal] === 0)
1100
+ countDocumentSpellings(counts, documents.documentAt(ordinal), analysis, 1);
316
1101
  }
317
1102
  const rebuilt = buildPartialWordTable(encodePartialSpellings(analysis.fields, counts), tokenTable);
1103
+ const countsRemoved = new Uint32Array(rebuilt.spellingCounts.length);
1104
+ const rebuiltReader = readPartialWordTable(rebuilt, tokenTable, countsRemoved);
318
1105
  table = rebuilt;
319
- removedCounts = /* @__PURE__ */ new Map();
1106
+ uncounted = excluded;
1107
+ removedCounts = countsRemoved;
320
1108
  pendingRemovals = [];
321
- const rebuiltReader = readPartialWordTable(rebuilt, tokenTable, removedCounts);
322
1109
  reader = rebuiltReader;
323
1110
  return rebuiltReader;
324
1111
  }
@@ -337,20 +1124,43 @@ function createFrozenPartialWordSlot(initial, tokenTable, documents) {
337
1124
  return kept;
338
1125
  }
339
1126
  return {
1127
+ tokenForSpelling(spelling) {
1128
+ const entry = reader?.entryOf(spelling) ?? -1;
1129
+ return table === null || entry < 0 ? void 0 : tokenTable.tokenAt(table.spellingTokens[entry]);
1130
+ },
1131
+ removalState() {
1132
+ return table === null ? null : { table, removed: removedCounts };
1133
+ },
340
1134
  readerFor(analysis) {
341
1135
  if (analysis.fields.length === 0) return null;
1136
+ documents.settleRemovals();
342
1137
  if (table === null || reader === null || !sameFields(table.fields, analysis.fields)) return rebuild(analysis);
343
1138
  subtractPendingRemovals(reader, analysis);
344
1139
  return reader;
345
1140
  },
346
- afterRemoval(ordinal) {
347
- if (table !== null) pendingRemovals.push(ordinal);
1141
+ prepareRemoval(ordinal, spellings) {
1142
+ if (table === null || reader === null) return () => void 0;
1143
+ if (spellings === void 0)
1144
+ return () => {
1145
+ pendingRemovals.push(ordinal);
1146
+ };
1147
+ const changes = /* @__PURE__ */ new Map();
1148
+ for (const [token, bySpelling] of spellings ?? []) {
1149
+ for (const [spelling, count] of bySpelling) {
1150
+ const entry = reader.entryOf(spelling, token);
1151
+ if (entry >= 0) changes.set(entry, (changes.get(entry) ?? 0) + count);
1152
+ }
1153
+ }
1154
+ return () => applyRemoval(changes);
348
1155
  },
349
1156
  tableOfEveryDocument(analysis) {
350
1157
  if (table === null || uncounted !== null || !sameFields(table.fields, analysis.fields)) return null;
351
1158
  return table;
352
1159
  },
353
1160
  countKeptSpellings(counts, analysis, mergedOrdinals) {
1161
+ documents.settleRemovals();
1162
+ if (reader !== null && table !== null && sameFields(table.fields, analysis.fields))
1163
+ subtractPendingRemovals(reader, analysis);
354
1164
  if (table === null || !sameFields(table.fields, analysis.fields) || correctionsAgainstTable(mergedOrdinals) > keptCount(mergedOrdinals)) {
355
1165
  for (let ordinal = 0; ordinal < mergedOrdinals.length; ordinal++) {
356
1166
  if (mergedOrdinals[ordinal] >= 0) countDocumentSpellings(counts, documents.documentAt(ordinal), analysis, 1);
@@ -358,7 +1168,7 @@ function createFrozenPartialWordSlot(initial, tokenTable, documents) {
358
1168
  return;
359
1169
  }
360
1170
  const corrected = /* @__PURE__ */ new Map();
361
- countTableSpellings(corrected, table, tokenTable);
1171
+ countTableSpellings(corrected, table, tokenTable, removedCounts);
362
1172
  const removed = /* @__PURE__ */ new Map();
363
1173
  const returned = [];
364
1174
  for (let ordinal = 0; ordinal < mergedOrdinals.length; ordinal++) {
@@ -376,13 +1186,84 @@ function createFrozenPartialWordSlot(initial, tokenTable, documents) {
376
1186
  },
377
1187
  bytes() {
378
1188
  if (table === null) return 0;
379
- return partialWordTableBytes(table) + removedCounts.size * FROZEN_PARTIAL_REMOVED_ENTRY_BYTES;
1189
+ return partialWordTableBytes(table) + removedCounts.byteLength;
380
1190
  }
381
1191
  };
382
1192
  }
383
1193
 
1194
+ // src/core/partition/partial-words/growing-reader.ts
1195
+ function runOrdinal(table, points) {
1196
+ const mask = table.slots.length - 1;
1197
+ let slot = hashRun(points) & mask;
1198
+ for (let scanned = 0; scanned < table.slots.length; scanned++) {
1199
+ const entry = table.slots[slot];
1200
+ if (entry === 0) return -1;
1201
+ if (entry > 0) {
1202
+ const start = (entry - 1) * 3;
1203
+ if (table.runs[start] === points[0] && table.runs[start + 1] === points[1] && table.runs[start + 2] === points[2])
1204
+ return entry - 1;
1205
+ }
1206
+ slot = slot + 1 & mask;
1207
+ }
1208
+ return -1;
1209
+ }
1210
+ function contains(table, ordinal, text) {
1211
+ const strings = table.strings;
1212
+ const start = strings.termOffset[ordinal];
1213
+ const last = start + strings.termLength[ordinal] - text.length;
1214
+ for (let from = start; from <= last; from++) {
1215
+ let at = 0;
1216
+ while (at < text.length && strings.units[from + at] === text.charCodeAt(at)) at++;
1217
+ if (at === text.length) return true;
1218
+ }
1219
+ return false;
1220
+ }
1221
+ function growingSpellingReader(segment) {
1222
+ return {
1223
+ forEachContaining(probe, visit) {
1224
+ const table = segment.spellings;
1225
+ const points = probe.codePoints;
1226
+ if (table === null || points.length < 3) return;
1227
+ const runs = table.runs;
1228
+ const triple = [0, 0, 0];
1229
+ let narrowest = -1;
1230
+ for (let at = 0; at + 3 <= points.length; at++) {
1231
+ for (let unit = 0; unit < 3; unit++) triple[unit] = points[at + unit];
1232
+ const ordinal = runOrdinal(runs, triple);
1233
+ if (ordinal < 0) return;
1234
+ if (narrowest < 0 || runs.listLength[ordinal] < runs.listLength[narrowest]) narrowest = ordinal;
1235
+ }
1236
+ if (narrowest < 0) return;
1237
+ const start = runs.listStart[narrowest];
1238
+ const end = start + runs.listLength[narrowest];
1239
+ const terms = segment.postings.terms;
1240
+ for (let at = start; at < end; at++) {
1241
+ const spelling = runs.members[at];
1242
+ if (table.count[spelling] === 0 || table.codePoints[spelling] <= points.length) continue;
1243
+ if (contains(table, spelling, probe.text))
1244
+ visit(terms.tokens[table.token[spelling]], table.codePoints[spelling]);
1245
+ }
1246
+ },
1247
+ bytes: () => 0
1248
+ };
1249
+ }
1250
+ function growingSpellings(segment, fields) {
1251
+ const encoded = { fields: [...fields], tokens: [], spellings: [], counts: [] };
1252
+ const table = segment.spellings;
1253
+ if (table === null) return encoded;
1254
+ const terms = segment.postings.terms;
1255
+ for (const ordinal of table.liveEntries()) {
1256
+ encoded.tokens.push(terms.tokens[table.token[ordinal]]);
1257
+ encoded.spellings.push(table.textAt(ordinal));
1258
+ encoded.counts.push(table.count[ordinal]);
1259
+ }
1260
+ return encoded;
1261
+ }
1262
+
384
1263
  // src/core/partition/partial-words/growing-slot.ts
385
1264
  function createGrowingPartialWordSlot(view) {
1265
+ let source = null;
1266
+ let sourceReader = null;
386
1267
  let fields = [];
387
1268
  let everyDocumentPending = false;
388
1269
  const pending = /* @__PURE__ */ new Set();
@@ -508,8 +1389,8 @@ function createGrowingPartialWordSlot(view) {
508
1389
  }
509
1390
  return encoded;
510
1391
  }
511
- function applyCounts(source, direction) {
512
- for (const [token, byToken] of source) {
1392
+ function applyCounts(source2, direction) {
1393
+ for (const [token, byToken] of source2) {
513
1394
  for (const [spelling, count] of byToken) change(token, spelling, count * direction);
514
1395
  }
515
1396
  }
@@ -564,8 +1445,26 @@ function createGrowingPartialWordSlot(view) {
564
1445
  }
565
1446
  };
566
1447
  const slot = {
1448
+ growingRegions: () => source?.spellings ?? null,
1449
+ adopt(segment, nextFields) {
1450
+ resetSpellings();
1451
+ fields = [...nextFields];
1452
+ everyDocumentPending = false;
1453
+ source = segment;
1454
+ sourceReader = growingSpellingReader(segment);
1455
+ },
1456
+ detach() {
1457
+ if (source === null) return;
1458
+ const encoded = growingSpellings(source, fields);
1459
+ source = null;
1460
+ sourceReader = null;
1461
+ for (let at = 0; at < encoded.tokens.length; at++)
1462
+ change(encoded.tokens[at], encoded.spellings[at], encoded.counts[at]);
1463
+ },
567
1464
  readerFor(analysis) {
568
1465
  if (analysis.fields.length === 0) return null;
1466
+ if (sourceReader !== null && sameFields(fields, analysis.fields)) return sourceReader;
1467
+ slot.detach();
569
1468
  adoptFields(analysis.fields);
570
1469
  resolvePending(analysis);
571
1470
  addEntriesToRuns();
@@ -573,9 +1472,11 @@ function createGrowingPartialWordSlot(view) {
573
1472
  },
574
1473
  spellings() {
575
1474
  if (fields.length === 0 || everyDocumentPending || pending.size > 0) return null;
1475
+ if (source !== null) return growingSpellings(source, fields);
576
1476
  return encodedSpellings();
577
1477
  },
578
1478
  afterDocument(documentFields, internalId, spellings, direction) {
1479
+ if (source !== null) return;
579
1480
  if (documentFields.length === 0) return;
580
1481
  if (!sameFields(fields, documentFields)) {
581
1482
  const holdsOnlyThisDocument = direction === 1 && view.docStore.count() === 1;
@@ -594,6 +1495,7 @@ function createGrowingPartialWordSlot(view) {
594
1495
  },
595
1496
  afterMerge(spellings, internalIds) {
596
1497
  if (internalIds.length === 0) return;
1498
+ slot.detach();
597
1499
  if (fields.length === 0 && spellings !== null && view.docStore.count() === internalIds.length) {
598
1500
  adoptFields(spellings.fields);
599
1501
  everyDocumentPending = false;
@@ -608,10 +1510,14 @@ function createGrowingPartialWordSlot(view) {
608
1510
  }
609
1511
  },
610
1512
  forgetSpellings() {
1513
+ source = null;
1514
+ sourceReader = null;
611
1515
  resetSpellings();
612
1516
  everyDocumentPending = fields.length > 0;
613
1517
  },
614
1518
  clear() {
1519
+ source = null;
1520
+ sourceReader = null;
615
1521
  fields = [];
616
1522
  everyDocumentPending = false;
617
1523
  resetSpellings();
@@ -719,10 +1625,23 @@ function partialWordsToHighlight(queryTokens, writtenWords) {
719
1625
  // src/core/partition/partial-words/module.ts
720
1626
  var partialWordSearchModule = {
721
1627
  name: "partialWords",
1628
+ bindExpansionCode: bindPartialExpansionCode,
1629
+ createSpellingTable: () => new SpellingTable(),
1630
+ prepareSpellingRuns(table, plan) {
1631
+ const runs = new RunPlan(table, collectRuns(plan));
1632
+ return () => runs.publish();
1633
+ },
1634
+ prepareSpellingRemoval(table, plan) {
1635
+ return prepareRunRemoval(table, collectRuns(plan));
1636
+ },
1637
+ prepareSpellingVacuum(table, mapping) {
1638
+ const vacuum = new RunVacuum(table, mapping);
1639
+ return () => vacuum.publish();
1640
+ },
722
1641
  createGrowingSlot: createGrowingPartialWordSlot,
723
1642
  createFrozenSlot: createFrozenPartialWordSlot,
724
1643
  buildTable: buildPartialWordTable,
725
- expand: expandPartialWords,
1644
+ expand: expandPartialWords2,
726
1645
  countSpelling,
727
1646
  encodeSpellings: encodePartialSpellings,
728
1647
  spellingCountsOf,