@delali/narsil 0.3.1-next.155 → 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 (195) hide show
  1. package/NOTICE +45 -0
  2. package/dist/{analysis-change-3TFIHT5E.mjs → analysis-change-5BQOQ4BF.mjs} +25 -18
  3. package/dist/{react-native/chunks/analysis-change-entry-JLL42PH6.mjs → analysis-change-entry-TXX6JSMX.mjs} +1 -1
  4. package/dist/browser/{analysis-change-TC36BU47.mjs → analysis-change-435CUEPZ.mjs} +8 -7
  5. package/dist/{analysis-change-entry-KA6JAO4X.mjs → browser/analysis-change-entry-HZXKPPGV.mjs} +1 -1
  6. package/dist/browser/{chunk-A5KUEGDY.mjs → chunk-2CFI5VVV.mjs} +2 -2
  7. package/dist/browser/{chunk-BXM5XOCA.mjs → chunk-2TI4SSUP.mjs} +2 -2
  8. package/dist/browser/{chunk-CJSYBQ4J.mjs → chunk-3SSRJMFN.mjs} +1 -1
  9. package/dist/browser/{chunk-SMEQ36NT.mjs → chunk-3V7DNNZL.mjs} +458 -622
  10. package/dist/browser/{chunk-RRO3EV4C.mjs → chunk-4NGKC4H4.mjs} +7 -7
  11. package/dist/browser/{chunk-ABCXENU5.mjs → chunk-6LWDPLTB.mjs} +1 -1
  12. package/dist/browser/{chunk-FNIFPFB7.mjs → chunk-7U3WVJUP.mjs} +2 -2
  13. package/dist/browser/{chunk-KKAMCABR.mjs → chunk-BHFQATSC.mjs} +1 -1
  14. package/dist/browser/{chunk-IKDKX5VQ.mjs → chunk-CRE3G7F3.mjs} +3 -3
  15. package/dist/browser/{chunk-56W3HQVJ.mjs → chunk-EA63E3D2.mjs} +4 -4
  16. package/dist/browser/{chunk-K5AXJBLL.mjs → chunk-IZXVW2ZJ.mjs} +3 -3
  17. package/dist/browser/{chunk-RND5CLX3.mjs → chunk-K4Q6KX3R.mjs} +16 -16
  18. package/dist/browser/{chunk-XY4VVBBO.mjs → chunk-KZWSX6BH.mjs} +2 -2
  19. package/dist/browser/{chunk-3UIEB4QF.mjs → chunk-MGI4BCXC.mjs} +2 -2
  20. package/dist/browser/chunk-MOG4OVDK.mjs +51 -0
  21. package/dist/browser/{chunk-RQBUNZQW.mjs → chunk-NQAME3RK.mjs} +2 -2
  22. package/dist/browser/{chunk-LFIWRCEA.mjs → chunk-NXQG7DRA.mjs} +29 -6
  23. package/dist/browser/{chunk-JVBP5EYO.mjs → chunk-SSTPBZZX.mjs} +7 -7
  24. package/dist/browser/{chunk-JIJXMI42.mjs → chunk-STOWQFT3.mjs} +1 -1
  25. package/dist/browser/{chunk-26A5JFT2.mjs → chunk-TK63WFXK.mjs} +2 -1
  26. package/dist/browser/{chunk-4EWUGZYZ.mjs → chunk-U4YDIBUT.mjs} +2 -2
  27. package/dist/browser/{chunk-K4GCSZLI.mjs → chunk-VLJQW4J6.mjs} +2985 -2985
  28. package/dist/browser/{chunk-SUDNZKPL.mjs → chunk-WI4MR75E.mjs} +1 -1
  29. package/dist/browser/{chunk-5TCXK5SB.mjs → chunk-WN464PTL.mjs} +1 -1
  30. package/dist/browser/{cold-module-NEUGHUPA.mjs → cold-module-2EHCIV4K.mjs} +15 -14
  31. package/dist/browser/{durability-wiring-CVGPRO6D.mjs → durability-wiring-A7BVG2DW.mjs} +20 -19
  32. package/dist/browser/{engine-hooks-YXMPHZKZ.mjs → engine-hooks-E4UD67JD.mjs} +7 -6
  33. package/dist/browser/geo-index-HHWGMNIS.mjs +1386 -0
  34. package/dist/browser/{import-OM6QAW45.mjs → import-DXYB6756.mjs} +8 -7
  35. package/dist/browser/{module-E33X4AOK.mjs → module-NIYMEA5R.mjs} +11 -10
  36. package/dist/browser/{module-3HNFCBJ5.mjs → module-TCT66FWA.mjs} +6 -6
  37. package/dist/browser/{phrase-module-ZXXU7S3B.mjs → phrase-module-HAT3TLZN.mjs} +1 -1
  38. package/dist/browser/{restore-hooks-IF2ZROUP.mjs → restore-hooks-YPN4ZFCY.mjs} +10 -9
  39. package/dist/browser/{restore-queue-ZBS7CJA6.mjs → restore-queue-G3RQGL3Y.mjs} +3 -3
  40. package/dist/browser/{retention-ASWUHAYI.mjs → retention-ZWVMNC3Q.mjs} +9 -8
  41. package/dist/browser/{snapshot-PN7ZW6Q4.mjs → snapshot-VEQNIE6C.mjs} +24 -23
  42. package/dist/browser/{start-ZIRB7MQ2.mjs → start-BM442C6R.mjs} +11 -10
  43. package/dist/browser/{write-HMDYCTV2.mjs → write-2EVMZWDE.mjs} +12 -11
  44. package/dist/{chunk-2MANFZJ3.mjs → chunk-25KDNIZZ.mjs} +1 -1
  45. package/dist/{chunk-3HHQLEEQ.mjs → chunk-2UV4QBHW.mjs} +7 -7
  46. package/dist/{chunk-BY6ZDGYS.mjs → chunk-3HYC4JRF.mjs} +1 -1
  47. package/dist/{chunk-HW5TNXBO.mjs → chunk-46KY2PJD.mjs} +7 -6
  48. package/dist/{chunk-SY3EWKQY.mjs → chunk-4KKXNJM6.mjs} +1 -1
  49. package/dist/{chunk-VQEUR6T6.mjs → chunk-5VV4R6P7.mjs} +3040 -3040
  50. package/dist/chunk-6HTGOXIK.mjs +875 -0
  51. package/dist/{chunk-RSVULW4Q.mjs → chunk-6I6AYAXS.mjs} +4 -4
  52. package/dist/chunk-7GFE3PEY.mjs +40 -0
  53. package/dist/{chunk-3R4UZWQG.mjs → chunk-7LXHHCXZ.mjs} +15 -15
  54. package/dist/{chunk-JUKYYXSP.mjs → chunk-7V5IUP2T.mjs} +1 -31
  55. package/dist/{chunk-4BYWRYPM.mjs → chunk-A4L7YTKX.mjs} +52 -89
  56. package/dist/{chunk-WQRN64Q6.mjs → chunk-BU4SAIC4.mjs} +1 -1
  57. package/dist/{chunk-5FVU47TB.mjs → chunk-BWZ3P4MU.mjs} +3 -3
  58. package/dist/{chunk-LC3FDWTX.mjs → chunk-CITFCZKF.mjs} +3 -2
  59. package/dist/{chunk-PCRA7HTI.mjs → chunk-CSLGFPFQ.mjs} +1 -1
  60. package/dist/{chunk-VHBNF4MA.mjs → chunk-DP5C7YFQ.mjs} +2 -2
  61. package/dist/{chunk-3HB3PEC6.mjs → chunk-DWEPMFJE.mjs} +5 -5
  62. package/dist/{chunk-KMUNHGBQ.mjs → chunk-EFBDHH5P.mjs} +29 -28
  63. package/dist/{chunk-DCNKVEDB.mjs → chunk-FAKFUDZZ.mjs} +5 -6
  64. package/dist/chunk-FB6463IN.mjs +1499 -0
  65. package/dist/{chunk-KFLK5NA2.mjs → chunk-FCJ553HS.mjs} +1 -1
  66. package/dist/{chunk-SG3JBNHY.mjs → chunk-FJKKCV4D.mjs} +1 -1
  67. package/dist/{chunk-H6VIGE62.mjs → chunk-FNGAM5B7.mjs} +10 -9
  68. package/dist/{chunk-VGF7CFRP.mjs → chunk-FRBFVQFN.mjs} +5 -4
  69. package/dist/{chunk-QH3YIQP4.mjs → chunk-FYOVBEMM.mjs} +2 -2
  70. package/dist/chunk-G6HRSGOU.mjs +74 -0
  71. package/dist/{chunk-DUOLGBTE.mjs → chunk-HFPMMRQT.mjs} +3 -3
  72. package/dist/{chunk-ZHCUZZE5.mjs → chunk-HHBUCIUY.mjs} +1 -1
  73. package/dist/{chunk-ZTW5WTGG.mjs → chunk-I2KPOLOZ.mjs} +3 -3
  74. package/dist/{chunk-L7ZD4L3K.mjs → chunk-I53G4JAU.mjs} +7 -6
  75. package/dist/{chunk-YEDIDCR7.mjs → chunk-I5B7RXU7.mjs} +91 -22
  76. package/dist/{react-native/chunks/chunk-KWRW5U65.mjs → chunk-J4IJTTEX.mjs} +1 -1
  77. package/dist/{chunk-S2EQU2GE.mjs → chunk-JDJBQLRO.mjs} +9 -9
  78. package/dist/{chunk-KPIV4RUC.mjs → chunk-JWRUUCWD.mjs} +2 -2
  79. package/dist/{chunk-KBKEXQZA.mjs → chunk-K5QFDYST.mjs} +1 -1
  80. package/dist/{chunk-DIBHI6W5.mjs → chunk-KF4EXSM4.mjs} +2 -2
  81. package/dist/{chunk-Q7G3BV3Y.mjs → chunk-KKQC526K.mjs} +19 -11
  82. package/dist/{chunk-4KRC2APY.mjs → chunk-L6V6BST3.mjs} +6 -19
  83. package/dist/{chunk-U4BS74YN.mjs → chunk-MQOJIO5B.mjs} +1 -1
  84. package/dist/chunk-ORN5BLL7.mjs +11 -0
  85. package/dist/{chunk-ZAUJFLEN.mjs → chunk-P5ZI2P2W.mjs} +122 -1697
  86. package/dist/{chunk-AILVAOLX.mjs → chunk-PWC4VB3Q.mjs} +2 -2
  87. package/dist/{chunk-J4IWBIVY.mjs → chunk-QOW2JPUI.mjs} +5 -5
  88. package/dist/{chunk-PHQNACDT.mjs → chunk-RDXO6JST.mjs} +2 -2
  89. package/dist/chunk-RLOES5SX.mjs +31 -0
  90. package/dist/{chunk-6L3XJXGU.mjs → chunk-SA5LOGO3.mjs} +1 -1
  91. package/dist/chunk-SQJWAIF4.mjs +12 -0
  92. package/dist/{react-native/chunks/chunk-PPEPTUVV.mjs → chunk-TBC3XUL2.mjs} +29 -6
  93. package/dist/chunk-TDIK6NTV.mjs +10 -0
  94. package/dist/{chunk-MT2NRTA6.mjs → chunk-TGS5UXBE.mjs} +3 -3
  95. package/dist/{chunk-KBDBPVLN.mjs → chunk-TZ3355VS.mjs} +1 -1
  96. package/dist/{chunk-Q622CTMC.mjs → chunk-TZTRKM33.mjs} +1 -1
  97. package/dist/{react-native/chunks/chunk-JV6VQY2S.mjs → chunk-U55XJEIG.mjs} +2 -1
  98. package/dist/{chunk-Z2BE2MAM.mjs → chunk-VTTRFF2C.mjs} +28 -15
  99. package/dist/{chunk-KXCVQWOR.mjs → chunk-WX4LAO6M.mjs} +3 -3
  100. package/dist/{chunk-BDRIVYOK.mjs → chunk-XAXKV65G.mjs} +1 -1
  101. package/dist/{chunk-UZRZKNNZ.mjs → chunk-XXHN7J46.mjs} +1 -1
  102. package/dist/{chunk-H4KHPLHJ.mjs → chunk-YTWZVGCB.mjs} +1 -1
  103. package/dist/{chunk-QUJHMPTP.mjs → chunk-Z2KAFCRT.mjs} +2 -2
  104. package/dist/{chunk-SMVH6JBE.mjs → chunk-ZKP7G7TV.mjs} +1 -1
  105. package/dist/{cold-module-7XXCEGTZ.mjs → cold-module-6MO2XJF2.mjs} +29 -23
  106. package/dist/direct-executor-FTMYY3TI.mjs +34 -0
  107. package/dist/distribution/coordinator/etcd.mjs +2 -2
  108. package/dist/distribution/coordinator/in-memory.mjs +2 -2
  109. package/dist/distribution.mjs +57 -51
  110. package/dist/{durability-wiring-NCKUC5EO.mjs → durability-wiring-VIF5MOSY.mjs} +41 -34
  111. package/dist/{engine-hooks-DHCMOADY.mjs → engine-hooks-EGUGNZYE.mjs} +24 -17
  112. package/dist/geo-index-MRH5JMIR.mjs +1387 -0
  113. package/dist/{import-NBFXFCSG.mjs → import-XKDPJQDP.mjs} +24 -17
  114. package/dist/index.browser.mjs +6 -5
  115. package/dist/index.d.ts +127 -2
  116. package/dist/index.mjs +23 -16
  117. package/dist/index.react-native.mjs +12 -10
  118. package/dist/invalidation/filesystem.mjs +2 -2
  119. package/dist/{long-query-thread-J4DVRM4A.mjs → long-query-thread-YA4IAYSY.mjs} +25 -20
  120. package/dist/{module-DWKPBSMN.mjs → module-FQ4JWNQJ.mjs} +26 -19
  121. package/dist/{module-UN76TF7I.mjs → module-N55W4Q5C.mjs} +9 -9
  122. package/dist/{paged-partition-archive-DPNWVSK2.mjs → paged-partition-archive-PXW5XAYU.mjs} +32 -26
  123. package/dist/partial-words.mjs +8 -6
  124. package/dist/pattern.mjs +4 -3
  125. package/dist/persistence/durability/checkpoint-worker.mjs +30 -21
  126. package/dist/{phrase-module-ZI4WSQVH.mjs → phrase-module-XW5MKWP5.mjs} +3 -2
  127. package/dist/query-suggestions/merge-worker.mjs +25 -18
  128. package/dist/query-suggestions.browser.mjs +12 -11
  129. package/dist/query-suggestions.mjs +34 -27
  130. package/dist/react-native/chunks/{analysis-change-6BPDPH6K.mjs → analysis-change-LT5QBQ3H.mjs} +13 -11
  131. package/dist/{browser/analysis-change-entry-4MH3CZXH.mjs → react-native/chunks/analysis-change-entry-SCVWK6OU.mjs} +1 -1
  132. package/dist/react-native/chunks/{chunk-7PXRWYUU.mjs → chunk-2PRHILX3.mjs} +53 -19
  133. package/dist/react-native/chunks/{chunk-C3PTWYKT.mjs → chunk-3JWDECAZ.mjs} +4 -4
  134. package/dist/{chunk-R6A773WK.mjs → react-native/chunks/chunk-3WI35N75.mjs} +1 -1
  135. package/dist/react-native/chunks/{chunk-CUH5F57W.mjs → chunk-4JYO3JD2.mjs} +2 -2
  136. package/dist/react-native/chunks/{chunk-3JIBF3XT.mjs → chunk-DNXOMPAQ.mjs} +1 -1
  137. package/dist/react-native/chunks/chunk-DXRSEWA2.mjs +12 -0
  138. package/dist/{chunk-YTJCGKM4.mjs → react-native/chunks/chunk-EJ33LCHV.mjs} +29 -6
  139. package/dist/react-native/chunks/{chunk-EIOYM5TO.mjs → chunk-ENLMYKSX.mjs} +3024 -3054
  140. package/dist/react-native/chunks/chunk-FHPW7P2O.mjs +40 -0
  141. package/dist/{chunk-4UMZ7KQL.mjs → react-native/chunks/chunk-FTZHMRD2.mjs} +2 -1
  142. package/dist/react-native/chunks/{chunk-OL3WDV53.mjs → chunk-G43IPIDG.mjs} +3 -3
  143. package/dist/react-native/chunks/{chunk-4Y53T4YE.mjs → chunk-GXX3DQXP.mjs} +5 -19
  144. package/dist/react-native/chunks/{chunk-GIZTJXYW.mjs → chunk-KV46CT4D.mjs} +2 -2
  145. package/dist/react-native/chunks/{chunk-HUOYZJ3Q.mjs → chunk-MIP4SOR6.mjs} +1419 -711
  146. package/dist/react-native/chunks/{chunk-ALOIBXWN.mjs → chunk-MUWD2H2S.mjs} +2 -2
  147. package/dist/react-native/chunks/{chunk-4LCEN2IU.mjs → chunk-NB3LP33V.mjs} +2 -2
  148. package/dist/react-native/chunks/{chunk-VXGE4ZXL.mjs → chunk-PDRWWPKV.mjs} +17 -17
  149. package/dist/react-native/chunks/{chunk-N2WUOWLL.mjs → chunk-POPDAGH6.mjs} +7 -7
  150. package/dist/react-native/chunks/{chunk-GJFXPHXI.mjs → chunk-QUKQNI3H.mjs} +3 -3
  151. package/dist/react-native/chunks/{chunk-KTTAU63H.mjs → chunk-SK2PWYDH.mjs} +2 -2
  152. package/dist/react-native/chunks/{chunk-7GRCBBME.mjs → chunk-TP6KCKER.mjs} +2 -2
  153. package/dist/react-native/chunks/{chunk-KJIG57UD.mjs → chunk-UQ4OAXKU.mjs} +7 -7
  154. package/dist/react-native/chunks/{chunk-PEHS2UO3.mjs → chunk-VWUDIOT6.mjs} +3 -3
  155. package/dist/react-native/chunks/{chunk-JLIIWJUV.mjs → chunk-YZW4CHM6.mjs} +50 -11
  156. package/dist/react-native/chunks/{chunk-QJXTNPLQ.mjs → chunk-ZLWVW734.mjs} +1 -1
  157. package/dist/react-native/chunks/{chunk-TYIRMPD3.mjs → chunk-ZXZFN7FI.mjs} +1 -1
  158. package/dist/react-native/chunks/{cold-module-5PHF6DZR.mjs → cold-module-KVZYUGRY.mjs} +19 -17
  159. package/dist/react-native/chunks/{durability-wiring-KO565FZC.mjs → durability-wiring-34OYO32E.mjs} +27 -25
  160. package/dist/react-native/chunks/{engine-hooks-MVRRHH6B.mjs → engine-hooks-M7JV46NH.mjs} +13 -11
  161. package/dist/react-native/chunks/geo-index-PX3BIHAH.mjs +1387 -0
  162. package/dist/react-native/chunks/{import-YVZA4V4V.mjs → import-H6AQREWI.mjs} +14 -12
  163. package/dist/react-native/chunks/{module-ZL5ZG6YB.mjs → module-LBZPGOWH.mjs} +15 -13
  164. package/dist/react-native/chunks/{module-H5MVPSP2.mjs → module-TTEVPRCW.mjs} +8 -8
  165. package/dist/react-native/chunks/{phrase-module-RTVKEWJT.mjs → phrase-module-QK22HSQ2.mjs} +1 -1
  166. package/dist/react-native/chunks/{restore-hooks-SILFPU6B.mjs → restore-hooks-IBGIY3DR.mjs} +17 -15
  167. package/dist/react-native/chunks/{restore-queue-HSYP2AEC.mjs → restore-queue-ZZX54AH7.mjs} +3 -3
  168. package/dist/react-native/chunks/{retention-7I7UAWYK.mjs → retention-EW4TTDFB.mjs} +18 -16
  169. package/dist/react-native/chunks/{snapshot-EZYB6SLF.mjs → snapshot-REYVIN3X.mjs} +31 -29
  170. package/dist/react-native/chunks/{start-SHVZ72I5.mjs → start-BQK6KN3R.mjs} +18 -16
  171. package/dist/react-native/chunks/{write-JUESXHDL.mjs → write-FQAYCZF5.mjs} +16 -14
  172. package/dist/react-native/partial-words.mjs +7 -6
  173. package/dist/react-native/pattern.mjs +1 -1
  174. package/dist/react-native/query-suggestions.mjs +19 -17
  175. package/dist/react-native/sync.mjs +7 -7
  176. package/dist/react-native/synonyms.mjs +92 -24
  177. package/dist/{restore-hooks-HZ3ILAMO.mjs → restore-hooks-CDERDEF4.mjs} +28 -21
  178. package/dist/{restore-queue-JVGENGGE.mjs → restore-queue-7NNSTROA.mjs} +3 -3
  179. package/dist/{retention-HROPV2QU.mjs → retention-QSVBBNRM.mjs} +28 -21
  180. package/dist/server.mjs +45 -39
  181. package/dist/{snapshot-4HS2G2UM.mjs → snapshot-RH4NSKIZ.mjs} +44 -38
  182. package/dist/{start-UTWHGH42.mjs → start-MCKCOGIW.mjs} +31 -24
  183. package/dist/sync/filesystem.mjs +3 -3
  184. package/dist/sync.browser.mjs +5 -5
  185. package/dist/sync.mjs +5 -5
  186. package/dist/synonyms.mjs +7 -6
  187. package/dist/{thread-6MOXY2KD.mjs → thread-O4SBJJJS.mjs} +24 -19
  188. package/dist/vector/search-worker.mjs +6 -6
  189. package/dist/workers/entry.mjs +17 -6
  190. package/dist/{write-GTTWWRRG.mjs → write-3FK7NG3Y.mjs} +26 -19
  191. package/package.json +15 -8
  192. package/dist/chunk-DJHHF2L5.mjs +0 -17
  193. package/dist/chunk-HNVVEQP7.mjs +0 -44
  194. package/dist/direct-executor-G5TK7NLA.mjs +0 -29
  195. package/dist/browser/{chunk-4WCVMOU3.mjs → chunk-XAWNZ4G2.mjs} +10 -10
@@ -1,13 +1,14 @@
1
1
  import { emitSyncChange, withOpenIndex, oneAtATime } from './chunk-ML7THVLJ.mjs';
2
2
  import { createRequestId, isValidWorkerResponse } from './chunk-VI7BQR4U.mjs';
3
3
  import { DEFAULT_MAX_RERANK_WINDOW, DEFAULT_RERANK_TIMEOUT_MS } from './chunk-JPTQZWJQ.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, isPlainObject, MAX_NESTING_DEPTH, extractVectorFieldsFromSchema, isWordIndexedFieldType, readHeapStatistics, VECTOR_PATTERN, parseFieldType, isStringValuedBase, withSortableOption, isGeopointOrVectorType, isListBase, MAX_DOCUMENT_BYTES } from './chunk-JIJXMI42.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';
5
5
  import { fnv1a, FNV_OFFSET_BASIS, fnv1aContinue, fnv1aContinueTaggedNumbers } from './chunk-RA6LSBCM.mjs';
6
- 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';
7
- import { createDocIdMap, turnsAreBudgeted, turnIsSpent, yieldTurn, indexChangeOutsideExternalWaits, changeIndexOutsideExternalWaits, detectRuntime, resolveWorkerEntry, missingWorkerEntry, countWrite, MIN_OVERSAMPLE, noteThreadSlotGone, threadSlotOfWorker } from './chunk-4WCVMOU3.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';
8
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';
9
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';
10
- import { singleFoldTable, appendFoldedCodePoint, EARLIER_RELEASE_MIN_M, MIN_M, MAX_M, compareCodePoints, toReducedSortValue, compareComparableValues, defaultSortMode, holdsUnpairedSurrogate, readSortField, truncateSortString, exceedsCodePoints, toComparableSortValue, SORT_VALUE_MAX_CODE_POINTS, compareComparableKeys, sortModeOf, isSortMode, SORT_MODES, compareSortValues, codePointCount } from './chunk-LFIWRCEA.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';
11
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';
12
13
  import { ErrorCodes, NarsilError, createNarsilError } from './chunk-SRMZXJSL.mjs';
13
14
  import { Decoder, decode, encode } from '@msgpack/msgpack';
@@ -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 = [];
@@ -912,21 +934,6 @@ function registerEngineRerankAdapter(core, name, adapter) {
912
934
  core.rerankAdapters.set(name, adapter);
913
935
  }
914
936
 
915
- // src/geo/constants.ts
916
- var DEG_TO_RAD = Math.PI / 180;
917
- var MAX_LATITUDE_DEGREES = 90;
918
- var MAX_LONGITUDE_DEGREES = 180;
919
- var MIN_POLYGON_POINTS = 3;
920
- var ANTIMERIDIAN_SPAN_DEGREES = 180;
921
- var FULL_TURN_DEGREES = 360;
922
- var EARTH_RADIUS_METERS = 63710088e-1;
923
- var LOCATION_CODE_BITS_PER_AXIS = 26;
924
- var MAX_COVERING_CELLS = 16;
925
- var RADIUS_BOX_MARGIN_RATIO = 1.02;
926
- var RADIUS_BOX_MARGIN_RADIANS = 1e-9;
927
- var VINCENTY_MAX_ITERATIONS = 200;
928
- var VINCENTY_CONVERGENCE_THRESHOLD = 1e-12;
929
-
930
937
  // src/geo/coordinates.ts
931
938
  function isLatitude(value) {
932
939
  return value >= -MAX_LATITUDE_DEGREES && value <= MAX_LATITUDE_DEGREES;
@@ -1588,6 +1595,11 @@ function getFlatSchema(state, schema) {
1588
1595
  return state.flatSchemaCache;
1589
1596
  }
1590
1597
 
1598
+ // src/core/document-copy.browser.ts
1599
+ function copyStoredValue(value) {
1600
+ return structuredClone(value);
1601
+ }
1602
+
1591
1603
  // src/core/projection.ts
1592
1604
  function requireFieldPathList(paths, option) {
1593
1605
  if (paths === void 0) return;
@@ -1661,8 +1673,8 @@ function writePath(target, path, value) {
1661
1673
  }
1662
1674
  function cloneExcept(value, path, exclude) {
1663
1675
  const reachesDeeper = exclude.some((excluded) => excluded.length > path.length && covers(path, excluded));
1664
- if (!reachesDeeper) return structuredClone(value);
1665
- 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);
1666
1678
  const source = value;
1667
1679
  const kept = {};
1668
1680
  for (const key of Object.keys(source)) {
@@ -1701,7 +1713,7 @@ function projectionKeepsField(projection, fieldPath) {
1701
1713
  return !projection.exclude.some((excluded) => covers(excluded, path));
1702
1714
  }
1703
1715
  function cloneProjected(document, projection) {
1704
- if (projection === void 0 || projection.kind === "full") return structuredClone(document);
1716
+ if (projection === void 0 || projection.kind === "full") return copyStoredValue(document);
1705
1717
  if (projection.kind === "none") return {};
1706
1718
  if (projection.include === null) return cloneExcept(document, [], projection.exclude);
1707
1719
  return projectIncludedPaths(projection.include, projection.exclude, (path) => readProjectedPath(document, path));
@@ -2525,7 +2537,7 @@ var LivePostings = class {
2525
2537
  terms = new TermColumns(TERM_TABLE_START_CAPACITY);
2526
2538
  pool = new PostingPool(POSTING_POOL_START_ENTRIES);
2527
2539
  positions = new PositionPool(POSITION_POOL_START_VALUES);
2528
- retired = new Uint8Array(RETIRED_DOCUMENTS_START_CAPACITY);
2540
+ retired = new Uint32Array(RETIRED_DOCUMENTS_START_CAPACITY >>> 5);
2529
2541
  batchMode = false;
2530
2542
  dirty = /* @__PURE__ */ new Set();
2531
2543
  cachedViews = /* @__PURE__ */ new Map();
@@ -2612,7 +2624,7 @@ var LivePostings = class {
2612
2624
  this.repackIfSparse();
2613
2625
  }
2614
2626
  isRetired(internalId) {
2615
- return internalId < this.retired.length && this.retired[internalId] === 1;
2627
+ return bitsetHas(this.retired, internalId);
2616
2628
  }
2617
2629
  beginBatch() {
2618
2630
  this.batchMode = true;
@@ -2636,7 +2648,7 @@ var LivePostings = class {
2636
2648
  this.pool = new PostingPool(POSTING_POOL_START_ENTRIES);
2637
2649
  this.pool.epoch = epoch;
2638
2650
  this.positions = new PositionPool(POSITION_POOL_START_VALUES);
2639
- this.retired = new Uint8Array(RETIRED_DOCUMENTS_START_CAPACITY);
2651
+ this.retired = new Uint32Array(RETIRED_DOCUMENTS_START_CAPACITY >>> 5);
2640
2652
  this.dirty.clear();
2641
2653
  this.cachedViews.clear();
2642
2654
  this.compactedSlack = 0;
@@ -2645,12 +2657,13 @@ var LivePostings = class {
2645
2657
  return this.terms.byteLength() + this.pool.byteLength() + this.positions.values.byteLength + this.retired.byteLength;
2646
2658
  }
2647
2659
  retire(internalId) {
2648
- if (internalId >= this.retired.length) {
2649
- 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));
2650
2663
  grown.set(this.retired);
2651
2664
  this.retired = grown;
2652
2665
  }
2653
- this.retired[internalId] = 1;
2666
+ bitsetSet(this.retired, internalId);
2654
2667
  }
2655
2668
  purgeRetired() {
2656
2669
  const terms = this.terms;
@@ -2662,7 +2675,7 @@ var LivePostings = class {
2662
2675
  compact(ordinal) {
2663
2676
  if (this.terms.deadDocuments[ordinal] === 0) return;
2664
2677
  const retired = this.retired;
2665
- this.filterEntries(ordinal, (id) => id < retired.length && retired[id] === 1);
2678
+ this.filterEntries(ordinal, (id) => bitsetHas(retired, id));
2666
2679
  this.terms.deadDocuments[ordinal] = 0;
2667
2680
  }
2668
2681
  filterEntries(ordinal, drop) {
@@ -2882,6 +2895,7 @@ function createInvertedIndex(fieldNameTable) {
2882
2895
  return entries;
2883
2896
  }
2884
2897
  return {
2898
+ livePostings: postings,
2885
2899
  insert(token, internalId, termFrequency, fieldNameIndex2, positions) {
2886
2900
  postings.insert(token, internalId, termFrequency, fieldNameIndex2, positions);
2887
2901
  },
@@ -3387,420 +3401,54 @@ function patternIndexOf(indexes, fieldPath) {
3387
3401
  return index;
3388
3402
  }
3389
3403
 
3390
- // src/geo/cells.ts
3391
- var AXIS_CELLS = 2 ** LOCATION_CODE_BITS_PER_AXIS;
3392
- function axisCell(value, lowest, span) {
3393
- const cell = Math.floor((value - lowest) / span * AXIS_CELLS);
3394
- if (!(cell > 0)) return 0;
3395
- return cell >= AXIS_CELLS ? AXIS_CELLS - 1 : cell;
3396
- }
3397
- function latitudeCell(lat) {
3398
- return axisCell(lat, -MAX_LATITUDE_DEGREES, 2 * MAX_LATITUDE_DEGREES);
3399
- }
3400
- function longitudeCell(lon) {
3401
- return axisCell(lon, -MAX_LONGITUDE_DEGREES, FULL_TURN_DEGREES);
3402
- }
3403
- function interleave(row, column, bits) {
3404
- let code = 0;
3405
- for (let bit = bits - 1; bit >= 0; bit--) code = code * 4 + (row >>> bit & 1) * 2 + (column >>> bit & 1);
3406
- return code;
3407
- }
3408
- function locationCode(lat, lon) {
3409
- return interleave(latitudeCell(lat), longitudeCell(lon), LOCATION_CODE_BITS_PER_AXIS);
3410
- }
3411
- function appendBoxRanges(box, out) {
3412
- const south = latitudeCell(box.south);
3413
- const north = latitudeCell(box.north);
3414
- const west = longitudeCell(box.west);
3415
- const east = longitudeCell(box.east);
3416
- let level = LOCATION_CODE_BITS_PER_AXIS;
3417
- while (level > 0) {
3418
- const shift2 = LOCATION_CODE_BITS_PER_AXIS - level;
3419
- const rows = (north >>> shift2) - (south >>> shift2) + 1;
3420
- const columns = (east >>> shift2) - (west >>> shift2) + 1;
3421
- if (rows * columns <= MAX_COVERING_CELLS) break;
3422
- level--;
3423
- }
3424
- const shift = LOCATION_CODE_BITS_PER_AXIS - level;
3425
- const codesPerCell = 4 ** shift;
3426
- for (let row = south >>> shift; row <= north >>> shift; row++) {
3427
- for (let column = west >>> shift; column <= east >>> shift; column++) {
3428
- const from = interleave(row, column, level) * codesPerCell;
3429
- out.push({ from, to: from + codesPerCell });
3430
- }
3431
- }
3432
- }
3433
- function coveringRanges(boxes) {
3434
- const ranges = [];
3435
- for (const box of boxes) appendBoxRanges(box, ranges);
3436
- ranges.sort((left, right) => left.from - right.from);
3437
- const merged = [];
3438
- for (const range of ranges) {
3439
- const last = merged[merged.length - 1];
3440
- if (last !== void 0 && range.from <= last.to) {
3441
- if (range.to > last.to) last.to = range.to;
3442
- } else {
3443
- merged.push({ from: range.from, to: range.to });
3444
- }
3445
- }
3446
- return merged;
3447
- }
3448
- function longitudeBoxes(south, north, west, east) {
3449
- if (east - west >= FULL_TURN_DEGREES) {
3450
- return [{ south, north, west: -MAX_LONGITUDE_DEGREES, east: MAX_LONGITUDE_DEGREES }];
3451
- }
3452
- if (west < -MAX_LONGITUDE_DEGREES) {
3453
- return [
3454
- { south, north, west: west + FULL_TURN_DEGREES, east: MAX_LONGITUDE_DEGREES },
3455
- { south, north, west: -MAX_LONGITUDE_DEGREES, east }
3456
- ];
3457
- }
3458
- if (east > MAX_LONGITUDE_DEGREES) {
3459
- return [
3460
- { south, north, west, east: MAX_LONGITUDE_DEGREES },
3461
- { south, north, west: -MAX_LONGITUDE_DEGREES, east: east - FULL_TURN_DEGREES }
3462
- ];
3463
- }
3464
- return [{ south, north, west, east }];
3465
- }
3466
- function radiusBoxes(lat, lon, distanceMeters) {
3467
- const angle = distanceMeters / EARTH_RADIUS_METERS * RADIUS_BOX_MARGIN_RATIO + RADIUS_BOX_MARGIN_RADIANS;
3468
- const angleDegrees = angle / DEG_TO_RAD;
3469
- const south = lat - angleDegrees;
3470
- const north = lat + angleDegrees;
3471
- if (angle >= Math.PI || south <= -MAX_LATITUDE_DEGREES || north >= MAX_LATITUDE_DEGREES) {
3472
- return [
3473
- {
3474
- south: Math.max(south, -MAX_LATITUDE_DEGREES),
3475
- north: Math.min(north, MAX_LATITUDE_DEGREES),
3476
- west: -MAX_LONGITUDE_DEGREES,
3477
- east: MAX_LONGITUDE_DEGREES
3478
- }
3479
- ];
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;
3480
3409
  }
3481
- const spread = Math.asin(Math.sin(angle) / Math.cos(lat * DEG_TO_RAD)) / DEG_TO_RAD;
3482
- return longitudeBoxes(south, north, lon - spread, lon + spread);
3410
+ return false;
3483
3411
  }
3484
-
3485
- // src/geo/haversine.ts
3486
- function haversineDistance(lat1, lon1, lat2, lon2) {
3487
- const phi1 = lat1 * DEG_TO_RAD;
3488
- const phi2 = lat2 * DEG_TO_RAD;
3489
- const deltaPhi = (lat2 - lat1) * DEG_TO_RAD;
3490
- const deltaLambda = (lon2 - lon1) * DEG_TO_RAD;
3491
- const halfDeltaPhi = Math.sin(deltaPhi / 2);
3492
- const halfDeltaLambda = Math.sin(deltaLambda / 2);
3493
- const a = halfDeltaPhi * halfDeltaPhi + Math.cos(phi1) * Math.cos(phi2) * halfDeltaLambda * halfDeltaLambda;
3494
- const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
3495
- return EARTH_RADIUS_METERS * c;
3412
+ function schemaMayDeclare(schema, typeName) {
3413
+ return mayDeclare(schema, typeName, 1);
3496
3414
  }
3497
3415
 
3498
- // src/geo/edge-tree.ts
3499
- function buildLongitudeEdgeTree(lons) {
3500
- const n = lons.length;
3501
- const edges = [];
3502
- for (let i = 0; i < n; i++) {
3503
- if (lons[i] !== lons[i === 0 ? n - 1 : i - 1]) edges.push(i);
3504
- }
3505
- const lowOf = (i) => Math.min(lons[i], lons[i === 0 ? n - 1 : i - 1]);
3506
- edges.sort((left, right) => lowOf(left) - lowOf(right));
3507
- const count = edges.length;
3508
- const tree = {
3509
- from: new Int32Array(count),
3510
- to: new Int32Array(count),
3511
- low: new Float64Array(count),
3512
- high: new Float64Array(count),
3513
- subtreeHigh: new Float64Array(count)
3514
- };
3515
- edges.forEach((i, at) => {
3516
- const j = i === 0 ? n - 1 : i - 1;
3517
- tree.from[at] = i;
3518
- tree.to[at] = j;
3519
- tree.low[at] = Math.min(lons[i], lons[j]);
3520
- tree.high[at] = Math.max(lons[i], lons[j]);
3521
- });
3522
- const fillSubtreeHigh = (start, end) => {
3523
- if (start >= end) return Number.NEGATIVE_INFINITY;
3524
- const mid = start + end >>> 1;
3525
- const highest = Math.max(tree.high[mid], fillSubtreeHigh(start, mid), fillSubtreeHigh(mid + 1, end));
3526
- tree.subtreeHigh[mid] = highest;
3527
- return highest;
3528
- };
3529
- fillSubtreeHigh(0, count);
3530
- return tree;
3531
- }
3532
- function forEachEdgeSpanning(tree, lon, visit) {
3533
- const walk = (start, end) => {
3534
- if (start >= end) return;
3535
- const mid = start + end >>> 1;
3536
- if (tree.subtreeHigh[mid] <= lon) return;
3537
- walk(start, mid);
3538
- if (tree.low[mid] > lon) return;
3539
- if (lon < tree.high[mid]) visit(tree.from[mid], tree.to[mid]);
3540
- walk(mid + 1, end);
3541
- };
3542
- walk(0, tree.from.length);
3543
- }
3544
-
3545
- // src/geo/polygon.ts
3546
- function requirePolygonRing(points) {
3547
- if (!Array.isArray(points) || points.length < MIN_POLYGON_POINTS) {
3548
- throw new NarsilError(
3549
- ErrorCodes.SEARCH_INVALID_FILTER,
3550
- `A polygon encloses an area only with at least ${MIN_POLYGON_POINTS} points`,
3551
- { points: Array.isArray(points) ? points.length : typeof points, minimum: MIN_POLYGON_POINTS }
3552
- );
3553
- }
3554
- points.forEach((point, position) => {
3555
- const { lat, lon } = point ?? {};
3556
- if (typeof lat !== "number" || !Number.isFinite(lat) || typeof lon !== "number" || !Number.isFinite(lon)) {
3557
- throw new NarsilError(
3558
- ErrorCodes.SEARCH_INVALID_FILTER,
3559
- `A polygon point carries a finite "lat" and "lon", and the point at position ${position} does not`,
3560
- { 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
+ }
3561
3432
  );
3562
3433
  }
3563
- if (isLatitude(lat) && isLongitude(lon)) return;
3564
- throw new NarsilError(
3565
- ErrorCodes.SEARCH_INVALID_FILTER,
3566
- `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}`,
3567
- { position, lat, lon }
3568
- );
3569
- });
3570
- }
3571
- function signedArea(polygon) {
3572
- let area = 0;
3573
- for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
3574
- area += polygon[j].lon * polygon[i].lat - polygon[i].lon * polygon[j].lat;
3575
- }
3576
- return area;
3577
- }
3578
- function crossesAntimeridian(polygon) {
3579
- let west = Number.POSITIVE_INFINITY;
3580
- let east = Number.NEGATIVE_INFINITY;
3581
- for (const point of polygon) {
3582
- if (point.lon < west) west = point.lon;
3583
- if (point.lon > east) east = point.lon;
3584
- }
3585
- return east - west >= ANTIMERIDIAN_SPAN_DEGREES && signedArea(polygon) < 0;
3586
- }
3587
- function eastward(lon) {
3588
- return lon < 0 ? lon + FULL_TURN_DEGREES : lon;
3589
- }
3590
- function polygonContainment(polygon) {
3591
- const n = polygon.length;
3592
- if (n < MIN_POLYGON_POINTS) return () => false;
3593
- const unwrap = crossesAntimeridian(polygon);
3594
- const lats = new Float64Array(n);
3595
- const lons = new Float64Array(n);
3596
- for (let i = 0; i < n; i++) {
3597
- lats[i] = polygon[i].lat;
3598
- lons[i] = unwrap ? eastward(polygon[i].lon) : polygon[i].lon;
3599
- }
3600
- const edges = buildLongitudeEdgeTree(lons);
3601
- return (lat, rawLon) => {
3602
- const lon = unwrap ? eastward(rawLon) : rawLon;
3603
- let inside = false;
3604
- forEachEdgeSpanning(edges, lon, (i, j) => {
3605
- const intersectLat = lats[i] + (lats[j] - lats[i]) / (lons[j] - lons[i]) * (lon - lons[i]);
3606
- if (lat < intersectLat) inside = !inside;
3607
- });
3608
- return inside;
3609
- };
3610
- }
3611
- function polygonBoxes(polygon) {
3612
- if (polygon.length < MIN_POLYGON_POINTS) return [];
3613
- const unwrap = crossesAntimeridian(polygon);
3614
- let south = Number.POSITIVE_INFINITY;
3615
- let north = Number.NEGATIVE_INFINITY;
3616
- let west = Number.POSITIVE_INFINITY;
3617
- let east = Number.NEGATIVE_INFINITY;
3618
- for (const point of polygon) {
3619
- const lon = unwrap ? eastward(point.lon) : point.lon;
3620
- south = Math.min(south, point.lat);
3621
- north = Math.max(north, point.lat);
3622
- west = Math.min(west, lon);
3623
- east = Math.max(east, lon);
3624
- }
3625
- if (west >= MAX_LONGITUDE_DEGREES)
3626
- return longitudeBoxes(south, north, west - FULL_TURN_DEGREES, east - FULL_TURN_DEGREES);
3627
- return longitudeBoxes(south, north, west, east);
3628
- }
3629
-
3630
- // src/geo/vincenty.ts
3631
- var WGS84_A = 6378137;
3632
- var WGS84_F = 1 / 298.257223563;
3633
- var WGS84_B = WGS84_A * (1 - WGS84_F);
3634
- function vincentyDistance(lat1, lon1, lat2, lon2) {
3635
- const phi1 = lat1 * DEG_TO_RAD;
3636
- const phi2 = lat2 * DEG_TO_RAD;
3637
- const L = (lon2 - lon1) * DEG_TO_RAD;
3638
- const U1 = Math.atan((1 - WGS84_F) * Math.tan(phi1));
3639
- const U2 = Math.atan((1 - WGS84_F) * Math.tan(phi2));
3640
- const sinU1 = Math.sin(U1);
3641
- const cosU1 = Math.cos(U1);
3642
- const sinU2 = Math.sin(U2);
3643
- const cosU2 = Math.cos(U2);
3644
- let lambda = L;
3645
- let prevLambda;
3646
- let sinSigma = 0;
3647
- let cosSigma = 0;
3648
- let sigma = 0;
3649
- let sinAlpha = 0;
3650
- let cos2Alpha = 0;
3651
- let cos2SigmaM = 0;
3652
- let iterations = VINCENTY_MAX_ITERATIONS;
3653
- do {
3654
- const sinLambda = Math.sin(lambda);
3655
- const cosLambda = Math.cos(lambda);
3656
- const term1 = cosU2 * sinLambda;
3657
- const term2 = cosU1 * sinU2 - sinU1 * cosU2 * cosLambda;
3658
- sinSigma = Math.sqrt(term1 * term1 + term2 * term2);
3659
- if (sinSigma === 0) return 0;
3660
- cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
3661
- sigma = Math.atan2(sinSigma, cosSigma);
3662
- sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma;
3663
- cos2Alpha = 1 - sinAlpha * sinAlpha;
3664
- cos2SigmaM = cos2Alpha === 0 ? 0 : cosSigma - 2 * sinU1 * sinU2 / cos2Alpha;
3665
- const C = WGS84_F / 16 * cos2Alpha * (4 + WGS84_F * (4 - 3 * cos2Alpha));
3666
- prevLambda = lambda;
3667
- lambda = L + (1 - C) * WGS84_F * sinAlpha * (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
3668
- } while (Math.abs(lambda - prevLambda) > VINCENTY_CONVERGENCE_THRESHOLD && --iterations > 0);
3669
- if (iterations === 0) {
3670
- return haversineDistance(lat1, lon1, lat2, lon2);
3671
- }
3672
- const uSq = cos2Alpha * (WGS84_A * WGS84_A - WGS84_B * WGS84_B) / (WGS84_B * WGS84_B);
3673
- const A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
3674
- const B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
3675
- const deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
3676
- return WGS84_B * A * (sigma - deltaSigma);
3677
- }
3678
-
3679
- // src/geo/geo-index.ts
3680
- var REMOVED_DOC_ID = -1;
3681
- function firstAtOrAfter(entries, code) {
3682
- let lo = 0;
3683
- let hi = entries.length;
3684
- while (lo < hi) {
3685
- const mid = lo + hi >>> 1;
3686
- if (entries[mid].code < code) lo = mid + 1;
3687
- else hi = mid;
3688
- }
3689
- return lo;
3690
- }
3691
- function dropRemoved(entries) {
3692
- let write = 0;
3693
- for (let read = 0; read < entries.length; read++) {
3694
- if (entries[read].docId !== REMOVED_DOC_ID) entries[write++] = entries[read];
3695
- }
3696
- entries.length = write;
3697
- }
3698
- function mergeSortedPending(entries, pending) {
3699
- pending.sort((left2, right2) => left2.code - right2.code || left2.docId - right2.docId);
3700
- const mainLength = entries.length;
3701
- for (const entry of pending) entries.push(entry);
3702
- let left = mainLength - 1;
3703
- let right = pending.length - 1;
3704
- let write = entries.length - 1;
3705
- while (right >= 0) {
3706
- const later = left >= 0 ? entries[left] : void 0;
3707
- const next = pending[right];
3708
- if (later !== void 0 && (later.code > next.code || later.code === next.code && later.docId > next.docId)) {
3709
- entries[write--] = later;
3710
- left--;
3711
- } else {
3712
- entries[write--] = next;
3713
- right--;
3714
- }
3715
- }
3716
- }
3717
- function createGeoIndex() {
3718
- let entries = [];
3719
- let pending = [];
3720
- const byDocument = /* @__PURE__ */ new Map();
3721
- let removedCount = 0;
3722
- function ensureSorted() {
3723
- if (removedCount > 0) {
3724
- dropRemoved(entries);
3725
- dropRemoved(pending);
3726
- removedCount = 0;
3727
- }
3728
- if (pending.length === 0) return;
3729
- if (entries.length === 0) {
3730
- pending.sort((left, right) => left.code - right.code || left.docId - right.docId);
3731
- entries = pending;
3732
- } else {
3733
- mergeSortedPending(entries, pending);
3734
- }
3735
- pending = [];
3434
+ return loading2;
3736
3435
  }
3737
- function removeEntry(entry) {
3738
- byDocument.delete(entry.docId);
3739
- entry.docId = REMOVED_DOC_ID;
3740
- removedCount++;
3741
- const held = entries.length + pending.length;
3742
- if (removedCount >= Math.max(PENDING_REMOVAL_MERGE_FLOOR, held / PENDING_REMOVAL_MERGE_DIVISOR)) ensureSorted();
3743
- }
3744
- function matching(boxes, passes, inside) {
3745
- ensureSorted();
3746
- const within = /* @__PURE__ */ new Set();
3747
- for (const range of coveringRanges(boxes)) {
3748
- for (let at = firstAtOrAfter(entries, range.from); at < entries.length && entries[at].code < range.to; at++) {
3749
- if (passes(entries[at])) within.add(entries[at].docId);
3750
- }
3751
- }
3752
- if (inside) return within;
3753
- const outside = /* @__PURE__ */ new Set();
3754
- for (const entry of entries) {
3755
- if (!within.has(entry.docId)) outside.add(entry.docId);
3756
- }
3757
- return outside;
3758
- }
3759
- const index = {
3760
- insert(internalId, lat, lon) {
3761
- const existing = byDocument.get(internalId);
3762
- if (existing !== void 0) removeEntry(existing);
3763
- const entry = { lat, lon, docId: internalId, code: locationCode(lat, lon) };
3764
- pending.push(entry);
3765
- byDocument.set(internalId, entry);
3766
- },
3767
- remove(internalId) {
3768
- const existing = byDocument.get(internalId);
3769
- if (existing !== void 0) removeEntry(existing);
3770
- },
3771
- radiusQuery(lat, lon, distanceMeters, inside, highPrecision) {
3772
- const distanceFn = highPrecision ? vincentyDistance : haversineDistance;
3773
- return matching(
3774
- radiusBoxes(lat, lon, distanceMeters),
3775
- (entry) => distanceFn(lat, lon, entry.lat, entry.lon) <= distanceMeters,
3776
- inside
3777
- );
3778
- },
3779
- polygonQuery(points, inside) {
3780
- const contains = polygonContainment(points);
3781
- return matching(polygonBoxes(points), (entry) => contains(entry.lat, entry.lon), inside);
3782
- },
3783
- documentsBitset(capacity) {
3784
- const bits = createBitSet(capacity);
3785
- for (const docId of byDocument.keys()) bitsetSet(bits, docId);
3786
- return bits;
3787
- },
3788
- clear() {
3789
- entries = [];
3790
- pending = [];
3791
- byDocument.clear();
3792
- removedCount = 0;
3793
- },
3794
- serialize() {
3795
- ensureSorted();
3796
- 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;
3797
3441
  },
3798
- deserialize(data) {
3799
- index.clear();
3800
- for (const entry of data) index.insert(entry.docId, entry.lat, entry.lon);
3801
- }
3442
+ load,
3443
+ loadFor: (schema) => loaded2 !== null || !schemaMayDeclare(schema, typeName) ? null : load()
3802
3444
  };
3803
- 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);
3804
3452
  }
3805
3453
 
3806
3454
  // src/core/field-index/boolean.ts
@@ -3884,7 +3532,7 @@ function reversedUnits(value) {
3884
3532
  for (let at = value.length - 1; at >= 0; at--) reversed += value[at];
3885
3533
  return reversed;
3886
3534
  }
3887
- function firstAtOrAfter2(sorted, key) {
3535
+ function firstAtOrAfter(sorted, key) {
3888
3536
  let lo = 0;
3889
3537
  let hi = sorted.length;
3890
3538
  while (lo < hi) {
@@ -3942,7 +3590,7 @@ var ValueAffixes = class {
3942
3590
  }
3943
3591
  matching(column, start) {
3944
3592
  const found = [];
3945
- 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++) {
3946
3594
  if (!column.keys[at].startsWith(start)) break;
3947
3595
  found.push(column.values[at]);
3948
3596
  }
@@ -4180,7 +3828,7 @@ function removeFromPending(pending, marked, byDocument) {
4180
3828
  }
4181
3829
  pending.length = write;
4182
3830
  }
4183
- function mergeSortedPending2(entries, pending) {
3831
+ function mergeSortedPending(entries, pending) {
4184
3832
  pending.sort((a, b) => a.value - b.value);
4185
3833
  const mainLength = entries.length;
4186
3834
  for (const entry of pending) entries.push(entry);
@@ -4216,7 +3864,7 @@ function createNumericIndex() {
4216
3864
  pending.sort((a, b) => a.value - b.value);
4217
3865
  entries = pending;
4218
3866
  } else {
4219
- mergeSortedPending2(entries, pending);
3867
+ mergeSortedPending(entries, pending);
4220
3868
  }
4221
3869
  pending = [];
4222
3870
  }
@@ -4404,7 +4052,7 @@ function ensureFieldIndex(state, fieldPath, base) {
4404
4052
  } else if ((base === "enum" || base === "enum[]") && !state.enumIndexes.has(fieldPath)) {
4405
4053
  state.enumIndexes.set(fieldPath, createEnumIndex());
4406
4054
  } else if (base === "geopoint" && !state.geoIndexes.has(fieldPath)) {
4407
- state.geoIndexes.set(fieldPath, createGeoIndex());
4055
+ state.geoIndexes.set(fieldPath, createLoadedGeoIndex());
4408
4056
  }
4409
4057
  }
4410
4058
  function getOrCreateNumericIndex(state, fieldPath) {
@@ -5046,6 +4694,33 @@ function requireListLength(fieldPath, operator, values) {
5046
4694
  );
5047
4695
  }
5048
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
+
5049
4724
  // src/filters/operands/geo.ts
5050
4725
  function requireFlag(fieldPath, operator, flag, value) {
5051
4726
  if (value === void 0 || typeof value === "boolean") return;
@@ -6168,17 +5843,21 @@ function presentBitsetOf(state, fieldPath, type, capacity) {
6168
5843
  if (base === "number") present = state.numericIndexes.get(fieldPath)?.getAllDocIdsBitset(capacity);
6169
5844
  else if (base === "boolean") present = state.booleanIndexes.get(fieldPath)?.getAllDocIdsBitset(capacity);
6170
5845
  else if (base === "enum") present = state.enumIndexes.get(fieldPath)?.getAllDocIdsBitset(capacity);
6171
- else if (base === "geopoint") present = state.geoIndexes.get(fieldPath)?.documentsBitset(capacity);
5846
+ else if (base === "geopoint") present = geoDocumentsBitset(state, fieldPath, capacity);
6172
5847
  else if (base !== void 0 && keepsValueSize(base)) {
6173
5848
  present = state.sizeIndexes.get(fieldPath)?.getAllDocIdsBitset(capacity);
6174
5849
  }
6175
5850
  return present ?? createBitSet(capacity);
6176
5851
  }
6177
- function liveDocumentsBitset(state, capacity) {
5852
+ function bitsetOfDocuments(internalIds, capacity) {
6178
5853
  const bits = createBitSet(capacity);
6179
- for (const internalId of state.docStore.allInternalIds()) bitsetSet(bits, internalId);
5854
+ for (const internalId of internalIds) bitsetSet(bits, internalId);
6180
5855
  return bits;
6181
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
+ }
6182
5861
  function buildFilterContext(state, schema, meter) {
6183
5862
  const flat = getFlatSchema(state, schema);
6184
5863
  const capacity = state.docStore.internalIdCapacity();
@@ -6230,7 +5909,7 @@ function buildFilterContext(state, schema, meter) {
6230
5909
  },
6231
5910
  capacity,
6232
5911
  get allDocIdsBitset() {
6233
- cachedAllDocIdsBitset ??= liveDocumentsBitset(state, capacity);
5912
+ cachedAllDocIdsBitset ??= bitsetOfDocuments(state.docStore.allInternalIds(), capacity);
6234
5913
  return cachedAllDocIdsBitset;
6235
5914
  }
6236
5915
  };
@@ -6304,7 +5983,7 @@ function requireLoadedPhraseCode() {
6304
5983
  }
6305
5984
  function loadPhraseCode() {
6306
5985
  if (loading === null) {
6307
- loading = import('./phrase-module-ZXXU7S3B.mjs').then(
5986
+ loading = import('./phrase-module-HAT3TLZN.mjs').then(
6308
5987
  (code) => {
6309
5988
  loaded = code;
6310
5989
  return code;
@@ -6338,10 +6017,82 @@ function analyseQueryPhrases(term, language, analysis) {
6338
6017
  );
6339
6018
  }
6340
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
+
6341
6092
  // src/core/scorer.ts
6342
6093
  function computeIDF(docFrequency, totalDocs) {
6343
6094
  if (totalDocs === 0) return 0;
6344
- return Math.log((totalDocs - docFrequency + 0.5) / (docFrequency + 0.5) + 1);
6095
+ return log((totalDocs - docFrequency + 0.5) / (docFrequency + 0.5) + 1);
6345
6096
  }
6346
6097
  function pairKeepsBoundSound(k1, b) {
6347
6098
  return k1 >= 0 && k1 <= MAX_BM25_K1 && b >= 0 && b <= MAX_BM25_B;
@@ -6405,6 +6156,43 @@ function computeBM25WithIDF(termFrequency, idf, fieldLength, avgFieldLength, k1,
6405
6156
  return idf * (numerator / denominator);
6406
6157
  }
6407
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
+
6408
6196
  // src/core/partition/field-scoring.ts
6409
6197
  var NO_FIELD_VALUES = new Float64Array(0);
6410
6198
  function differentPairsOf(searchable, k1s, bs) {
@@ -6432,7 +6220,8 @@ function loadFieldScoring(state, fields, boost, averageFieldLengths, bm25) {
6432
6220
  lengthColumns: new Array(fieldCount).fill(null),
6433
6221
  k1s: perField === void 0 ? NO_FIELD_VALUES : new Float64Array(fieldCount),
6434
6222
  bs: perField === void 0 ? NO_FIELD_VALUES : new Float64Array(fieldCount),
6435
- boundPairs: [k1, b]
6223
+ boundPairs: [k1, b],
6224
+ nameRanks: fieldNameRanks(fieldNames)
6436
6225
  };
6437
6226
  for (let fieldIndex = 0; fieldIndex < fieldCount; fieldIndex++) {
6438
6227
  const fieldName = fieldNames[fieldIndex];
@@ -6535,12 +6324,18 @@ function termGroupOf(groups, token) {
6535
6324
  function typoMatchesFor(index, token, group, exact, tolerance, prefixLength) {
6536
6325
  if (group !== void 0) {
6537
6326
  if (!group.typoMatches || exact || tolerance === 0) return [];
6538
- 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;
6539
6332
  }
6540
- if (!exact) return index.fuzzyLookup(token, tolerance, prefixLength);
6541
6333
  const postingList = index.lookup(token);
6542
6334
  return postingList ? [{ token, postingList }] : [];
6543
6335
  }
6336
+ function byToken(left, right) {
6337
+ return compareCodePoints(left.token, right.token);
6338
+ }
6544
6339
  function resolveGroupMatches(context, group) {
6545
6340
  const frequencyOf = (token) => context.globalFrequency(token) ?? context.index.documentFrequency(token);
6546
6341
  const lookup = (token) => context.index.lookup(token);
@@ -6573,10 +6368,20 @@ function computeGroupContributions(context, matches, collect) {
6573
6368
  const { docIds, termFrequencies, fieldNameIndices, deletedDocs, hasDeleted, count } = postingColumns(
6574
6369
  match.postingList
6575
6370
  );
6576
- for (let pi = 0; pi < count; pi++) {
6577
- 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];
6578
6375
  if (hasDeleted && deletedDocs.has(internalId)) continue;
6579
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
+ }
6580
6385
  const fieldIndex = fieldNameIndices[pi];
6581
6386
  if (fields.searchable[fieldIndex] === 0) continue;
6582
6387
  const factor = partialMarks[fieldIndex] === 1 ? match.partialFactor : match.factor;
@@ -6854,7 +6659,7 @@ function mergeFieldIndexes(target, source, idMapping) {
6854
6659
  for (const [fieldPath, index] of source.geoIndexes) {
6855
6660
  let targetIndex = target.geoIndexes.get(fieldPath);
6856
6661
  if (targetIndex === void 0) {
6857
- targetIndex = createGeoIndex();
6662
+ targetIndex = createLoadedGeoIndex();
6858
6663
  target.geoIndexes.set(fieldPath, targetIndex);
6859
6664
  }
6860
6665
  for (const entry of index.serialize()) {
@@ -7281,15 +7086,30 @@ function firstEntryOf(docIds, count, internalId) {
7281
7086
  }
7282
7087
  return low;
7283
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
+ }
7284
7100
  function samePairQueryOrderScore(scans, internalId) {
7285
7101
  let score = 0;
7286
7102
  for (const scan of scans) {
7287
7103
  const { docIds, deletedDocs, hasDeleted, count } = scan.columns;
7288
7104
  if (hasDeleted && deletedDocs.has(internalId)) continue;
7289
- for (let entry = firstEntryOf(docIds, count, internalId); entry < count && docIds[entry] === internalId; entry++) {
7290
- if (scan.fields.searchable[scan.columns.fieldNameIndices[entry]] !== 1) continue;
7291
- 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;
7292
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);
7293
7113
  }
7294
7114
  return score;
7295
7115
  }
@@ -7298,10 +7118,14 @@ function fieldPairQueryOrderScore(scans, internalId) {
7298
7118
  for (const scan of scans) {
7299
7119
  const { docIds, deletedDocs, hasDeleted, count } = scan.columns;
7300
7120
  if (hasDeleted && deletedDocs.has(internalId)) continue;
7301
- for (let entry = firstEntryOf(docIds, count, internalId); entry < count && docIds[entry] === internalId; entry++) {
7302
- if (scan.fields.searchable[scan.columns.fieldNameIndices[entry]] !== 1) continue;
7303
- 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;
7304
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);
7305
7129
  }
7306
7130
  return score;
7307
7131
  }
@@ -7439,7 +7263,8 @@ function singleTermTopK(request) {
7439
7263
  lengthColumns: fieldLengthColumns,
7440
7264
  k1s,
7441
7265
  bs,
7442
- boundPairs
7266
+ boundPairs,
7267
+ nameRanks
7443
7268
  } = request.fields;
7444
7269
  const onePair = boundPairs.length === 2;
7445
7270
  const onlyK1 = boundPairs[0];
@@ -7479,12 +7304,14 @@ function singleTermTopK(request) {
7479
7304
  }
7480
7305
  let score = 0;
7481
7306
  let scored2 = false;
7482
- while (entry < end && docIds[entry] === internalId) {
7483
- 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];
7484
7311
  if (fieldSearchable[fieldIndex] === 1) {
7485
7312
  const fieldLength = fieldLengthOf(fieldLengthColumns, fieldIndex, internalId, fieldAvgLengths[fieldIndex]);
7486
7313
  score += (scoresAreZero ? 0 : computeBM25WithIDF(
7487
- termFrequencies[entry],
7314
+ termFrequencies[row],
7488
7315
  idf,
7489
7316
  fieldLength,
7490
7317
  fieldAvgLengths[fieldIndex],
@@ -7493,7 +7320,6 @@ function singleTermTopK(request) {
7493
7320
  )) * fieldBoosts[fieldIndex];
7494
7321
  scored2 = true;
7495
7322
  }
7496
- entry++;
7497
7323
  }
7498
7324
  if (!scored2) continue;
7499
7325
  totalMatched++;
@@ -7531,8 +7357,6 @@ function singleTermTopK(request) {
7531
7357
  }
7532
7358
  return { scored, totalMatched };
7533
7359
  }
7534
-
7535
- // src/core/partition/search.ts
7536
7360
  function globalDocFreqFor(docFreqs, term, fallback) {
7537
7361
  return Object.hasOwn(docFreqs, term) ? docFreqs[term] : fallback;
7538
7362
  }
@@ -7559,15 +7383,11 @@ function searchFulltext(state, params) {
7559
7383
  const totalDocs = globalStats?.totalDocuments ?? state.stats.totalDocuments;
7560
7384
  const avgFieldLengths = globalStats?.averageFieldLengths ?? state.stats.averageFieldLengths;
7561
7385
  const scoresAreZero = totalDocs === 0;
7562
- if (state.scoreBuffer === null) state.scoreBuffer = createScoreBuffer(state.docStore.internalIdCapacity());
7563
- const scoreBuffer = state.scoreBuffer;
7564
- beginScoring(scoreBuffer, state.docStore.internalIdCapacity());
7565
- const components = collectComponents ? /* @__PURE__ */ new Map() : null;
7566
7386
  const useIntersection = termMatch === "all" && queryTokens.length > 1;
7567
7387
  const fieldNames = state.fieldNameTable.names;
7568
7388
  const resolver = state.docStore.resolver();
7569
7389
  const fieldScoring = loadFieldScoring(state, fields, boost, avgFieldLengths, bm25Params);
7570
- const { searchable, boosts, averageLengths, lengthColumns, k1s, bs, boundPairs } = fieldScoring;
7390
+ const { searchable, boosts, averageLengths, lengthColumns, k1s, bs, boundPairs, nameRanks } = fieldScoring;
7571
7391
  const onePair = boundPairs.length === 2;
7572
7392
  const onlyK1 = boundPairs[0];
7573
7393
  const onlyB = boundPairs[1];
@@ -7584,6 +7404,10 @@ function searchFulltext(state, params) {
7584
7404
  return { scored: [], totalMatched: 0 };
7585
7405
  }
7586
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;
7587
7411
  function documentFrequency(token, list) {
7588
7412
  return globalStats ? globalDocFreqFor(globalStats.docFrequencies, token, list.docIdSet.size) : list.docIdSet.size;
7589
7413
  }
@@ -7592,25 +7416,35 @@ function searchFulltext(state, params) {
7592
7416
  for (let entry = 0; entry < rows.phrase.tokens.length; entry++) {
7593
7417
  idf += computeIDF(documentFrequency(rows.phrase.tokens[entry], rows.lists[entry]), totalDocs);
7594
7418
  }
7595
- for (let row = 0; row < rows.docIds.length; row++) {
7596
- const internalId = rows.docIds.values[row];
7597
- if (!bitsetHas(matched, internalId)) continue;
7598
- const fieldIndex = rows.fieldIndices.values[row];
7599
- const frequency = rows.frequencies.values[row];
7600
- const avgLen = averageLengths[fieldIndex];
7601
- const fieldLength = fieldLengthOf(lengthColumns, fieldIndex, internalId, avgLen);
7602
- const score = scoresAreZero ? 0 : computeBM25WithIDF(
7603
- frequency,
7604
- idf,
7605
- fieldLength,
7606
- avgLen,
7607
- onePair ? onlyK1 : k1s[fieldIndex],
7608
- 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
7609
7426
  );
7610
- addScore(scoreBuffer, internalId, score * boosts[fieldIndex]);
7611
- if (components !== null) {
7612
- recordComponents(components, internalId, fieldNames[fieldIndex], rows.phrase.key, frequency, fieldLength, idf);
7613
- }
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);
7614
7448
  }
7615
7449
  }
7616
7450
  const groupContext = {
@@ -7633,13 +7467,23 @@ function searchFulltext(state, params) {
7633
7467
  const docFreq = documentFrequency(token, postingList);
7634
7468
  return { token, docFreq, idf: computeIDF(docFreq, totalDocs), postingList };
7635
7469
  }
7636
- function scorePostings(match, onlyScored) {
7470
+ function scorePostings(match, only) {
7637
7471
  const { docIds, termFrequencies, fieldNameIndices, deletedDocs, hasDeleted, count } = postingColumns(
7638
7472
  match.postingList
7639
7473
  );
7640
- if (!onlyScored && !hasDeleted && filterBitset === void 0 && components === null) {
7641
- for (let pi = 0; pi < count; pi++) {
7642
- 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
+ }
7643
7487
  const fieldIndex = fieldNameIndices[pi];
7644
7488
  if (searchable[fieldIndex] === 0) continue;
7645
7489
  const avgLen = averageLengths[fieldIndex];
@@ -7656,11 +7500,19 @@ function searchFulltext(state, params) {
7656
7500
  }
7657
7501
  return;
7658
7502
  }
7659
- for (let pi = 0; pi < count; pi++) {
7660
- const internalId = docIds[pi];
7503
+ for (let at = 0; at < count; at++) {
7504
+ const internalId = docIds[at];
7661
7505
  if (hasDeleted && deletedDocs.has(internalId)) continue;
7662
7506
  if (filterBitset && !bitsetHas(filterBitset, internalId)) continue;
7663
- 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
+ }
7664
7516
  const fieldIndex = fieldNameIndices[pi];
7665
7517
  if (searchable[fieldIndex] === 0) continue;
7666
7518
  const termFrequency = termFrequencies[pi];
@@ -7688,10 +7540,10 @@ function searchFulltext(state, params) {
7688
7540
  }
7689
7541
  }
7690
7542
  }
7691
- function scoreGroup(group, onlyScored) {
7543
+ function scoreGroup(group, only) {
7692
7544
  if (group === null) return;
7693
7545
  for (const [internalId, contribution] of computeGroupContributions(groupContext, group, collectComponents)) {
7694
- if (onlyScored && !hasScore(scoreBuffer, internalId)) continue;
7546
+ if (only !== null && !bitsetHas(only, internalId)) continue;
7695
7547
  mergeGroupContribution(internalId, contribution);
7696
7548
  }
7697
7549
  }
@@ -7732,19 +7584,27 @@ function searchFulltext(state, params) {
7732
7584
  }
7733
7585
  resolved.push({ token: qt.token, matches, totalPostings, group: groupMatches });
7734
7586
  }
7735
- resolved.sort((a, b) => a.totalPostings - b.totalPostings);
7736
- for (let tokenIndex = 0; tokenIndex < resolved.length; tokenIndex++) {
7737
- const onlyScored = tokenIndex > 0;
7738
- for (const match of resolved[tokenIndex].matches) scorePostings(match, onlyScored);
7739
- 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);
7740
7600
  }
7741
7601
  } else {
7742
7602
  for (const qt of queryTokens) {
7743
7603
  const group = termGroupOf(termGroups, qt.token);
7744
7604
  for (const m of typoMatchesFor(state.invertedIdx, qt.token, group, exact, tolerance, prefixLength)) {
7745
- scorePostings(resolveMatch(m.token, m.postingList), false);
7605
+ scorePostings(resolveMatch(m.token, m.postingList), null);
7746
7606
  }
7747
- if (group !== void 0) scoreGroup(resolveGroupMatches(groupContext, group), false);
7607
+ if (group !== void 0) scoreGroup(resolveGroupMatches(groupContext, group), null);
7748
7608
  }
7749
7609
  }
7750
7610
  if (phraseMatches !== null) {
@@ -8030,7 +7890,7 @@ function mergePayloadFieldIndexes(target, payload, ordinalBase) {
8030
7890
  for (const entry of payload.geo) {
8031
7891
  let index = target.geoIndexes.get(entry.fieldPath);
8032
7892
  if (index === void 0) {
8033
- index = createGeoIndex();
7893
+ index = createLoadedGeoIndex();
8034
7894
  target.geoIndexes.set(entry.fieldPath, index);
8035
7895
  }
8036
7896
  for (let i = 0; i < entry.docIds.length; i++) {
@@ -8264,7 +8124,7 @@ function deserializePartition(state, data, clearFn, schema) {
8264
8124
  state.enumIndexes.set(path, idx);
8265
8125
  }
8266
8126
  for (const [path, entries] of Object.entries(data.fieldIndexes.geopoint)) {
8267
- const geoIdx = createGeoIndex();
8127
+ const geoIdx = createLoadedGeoIndex();
8268
8128
  const converted = entries.map((e) => ({
8269
8129
  lat: e.lat,
8270
8130
  lon: e.lon,
@@ -9668,22 +9528,22 @@ function createWriteLogRecorder() {
9668
9528
  const current = [null, null];
9669
9529
  return {
9670
9530
  open(owner) {
9671
- const log = { docIds: /* @__PURE__ */ new Set(), replaced: false };
9672
- current[owner] = log;
9531
+ const log2 = { docIds: /* @__PURE__ */ new Set(), replaced: false };
9532
+ current[owner] = log2;
9673
9533
  return {
9674
9534
  get partitionsReplaced() {
9675
- return log.replaced;
9535
+ return log2.replaced;
9676
9536
  },
9677
9537
  get pendingDocuments() {
9678
- return log.docIds.size;
9538
+ return log2.docIds.size;
9679
9539
  },
9680
9540
  takeWrittenDocIds() {
9681
- const taken = log.docIds;
9682
- log.docIds = /* @__PURE__ */ new Set();
9541
+ const taken = log2.docIds;
9542
+ log2.docIds = /* @__PURE__ */ new Set();
9683
9543
  return taken;
9684
9544
  },
9685
9545
  close() {
9686
- if (current[owner] === log) current[owner] = null;
9546
+ if (current[owner] === log2) current[owner] = null;
9687
9547
  }
9688
9548
  };
9689
9549
  },
@@ -9692,17 +9552,17 @@ function createWriteLogRecorder() {
9692
9552
  current[1]?.docIds.add(docId);
9693
9553
  },
9694
9554
  segmentWritten(segment) {
9695
- for (const log of current) {
9696
- if (log === null) continue;
9555
+ for (const log2 of current) {
9556
+ if (log2 === null) continue;
9697
9557
  for (const internalId of segment.docStore.allInternalIds()) {
9698
9558
  const docId = segment.docStore.getExternalId(internalId);
9699
- if (docId !== void 0) log.docIds.add(docId);
9559
+ if (docId !== void 0) log2.docIds.add(docId);
9700
9560
  }
9701
9561
  }
9702
9562
  },
9703
9563
  partitionsReplaced() {
9704
- for (const log of current) {
9705
- if (log !== null) log.replaced = true;
9564
+ for (const log2 of current) {
9565
+ if (log2 !== null) log2.replaced = true;
9706
9566
  }
9707
9567
  }
9708
9568
  };
@@ -11139,6 +10999,22 @@ async function runQueryAction(entry, action) {
11139
10999
  return { count: result.totalMatched };
11140
11000
  }
11141
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
+
11142
11018
  // src/core/partition/frozen/doc-table.ts
11143
11019
  function createFrozenDocTable(idTable, lengthColumns, documents, tombstones) {
11144
11020
  const capacity = idTable.count;
@@ -12376,7 +12252,7 @@ function createFrozenSurfaceSlot(load, documents, tableOnDisk) {
12376
12252
  for (const spelling of spellings) target.subtract(spelling, 1);
12377
12253
  }
12378
12254
  }
12379
- function loaded3() {
12255
+ function loaded2() {
12380
12256
  if (registry === null) {
12381
12257
  const built = createSurfaceRegistry();
12382
12258
  const forms = load();
@@ -12395,10 +12271,10 @@ function createFrozenSurfaceSlot(load, documents, tableOnDisk) {
12395
12271
  return {
12396
12272
  heldBytes: () => table?.heldBytes() ?? 0,
12397
12273
  reader: {
12398
- candidatesForPrefix: (prefix) => table !== void 0 && waitingRemovals.length === 0 ? table.candidatesForPrefix(prefix) : loaded3().candidatesForPrefix(prefix),
12399
- stemChangedTotalFor: (token) => loaded3().stemChangedTotalFor(token),
12400
- size: () => loaded3().size(),
12401
- 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()
12402
12278
  },
12403
12279
  tableStaysOnDisk() {
12404
12280
  return registry === null && tableOnDisk !== void 0;
@@ -12410,20 +12286,20 @@ function createFrozenSurfaceSlot(load, documents, tableOnDisk) {
12410
12286
  waitingRemovals.push(ordinal);
12411
12287
  },
12412
12288
  holdsAny() {
12413
- return loaded3().size() > 0;
12289
+ return loaded2().size() > 0;
12414
12290
  },
12415
12291
  holds(spelling) {
12416
- return loaded3().holds(spelling);
12292
+ return loaded2().holds(spelling);
12417
12293
  },
12418
12294
  subtractSpellings(ordinal, spellings) {
12419
12295
  uncounted ??= new Uint8Array(documents.count);
12420
12296
  uncounted[ordinal] = 1;
12421
12297
  if (spellings.length === 0) return;
12422
- const target = loaded3();
12298
+ const target = loaded2();
12423
12299
  for (const spelling of spellings) target.subtract(spelling, 1);
12424
12300
  },
12425
12301
  addKeptForms(target, mergedOrdinals, analysis) {
12426
- const source = loaded3();
12302
+ const source = loaded2();
12427
12303
  if (analysis === null) {
12428
12304
  addForms(target, source.serialize());
12429
12305
  return;
@@ -12825,7 +12701,7 @@ function storedFrequenciesOf(source) {
12825
12701
  function buildGeoReaders(entries) {
12826
12702
  const readers = /* @__PURE__ */ new Map();
12827
12703
  for (const entry of entries) {
12828
- const index = createGeoIndex();
12704
+ const index = createLoadedGeoIndex();
12829
12705
  for (let i = 0; i < entry.docIds.length; i++) {
12830
12706
  index.insert(entry.docIds[i], entry.latitudes[i], entry.longitudes[i]);
12831
12707
  }
@@ -12881,6 +12757,7 @@ function assembleFrozenSegment(segmentId, source, documentSource, sharedSnapshot
12881
12757
  sharedSnapshot,
12882
12758
  paged: pagedParts?.access ?? null,
12883
12759
  arrays: source,
12760
+ tombstones,
12884
12761
  invertedIdx: createFrozenInvertedReader(source.tokenTable, postingViews, counts),
12885
12762
  docStore,
12886
12763
  stats: buildStatsView(counts),
@@ -13664,7 +13541,7 @@ function indexFilterValue(indexes, ordinal, fieldPath, fieldType, value) {
13664
13541
  for (const entry of fieldType === "enum" ? [value] : value) index.insert(ordinal, entry);
13665
13542
  } else if (fieldType === "geopoint") {
13666
13543
  const point = value;
13667
- indexOf(indexes.geoIndexes, fieldPath, createGeoIndex).insert(ordinal, point.lat, point.lon);
13544
+ indexOf(indexes.geoIndexes, fieldPath, createLoadedGeoIndex).insert(ordinal, point.lat, point.lon);
13668
13545
  }
13669
13546
  }
13670
13547
  function refuseRepeatedDocIds(documents) {
@@ -13815,7 +13692,7 @@ async function attachSegments(entry, action) {
13815
13692
  growPartitionsTo(entry.manager, segment.partitionId);
13816
13693
  const surfaceForms = segment.survivingSurfaceForms;
13817
13694
  const spellings = surfaceForms === void 0 ? void 0 : NO_REMOVED_SPELLINGS;
13818
- const frozen = isPagedSnapshot(segment.snapshot) ? (await import('./module-E33X4AOK.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);
13819
13696
  for (const docId of segment.tombstonedDocIds ?? []) frozen.tombstoneDocument(docId, spellings);
13820
13697
  entry.manager.attachFrozenSegment(segment.partitionId, frozen);
13821
13698
  }
@@ -13870,7 +13747,7 @@ function runSegmentAction(entry, action) {
13870
13747
  case "attachSegments":
13871
13748
  return attachSegments(entry, action);
13872
13749
  case "adoptDiskSegments":
13873
- return import('./module-E33X4AOK.mjs').then((code) => code.adoptSegmentsOnWorker(entry.manager, action));
13750
+ return import('./module-NIYMEA5R.mjs').then((code) => code.adoptSegmentsOnWorker(entry.manager, action));
13874
13751
  case "compactSegments": {
13875
13752
  const partition = requireComposite(entry, action.indexName, action.partitionId, "compact");
13876
13753
  return mergeFrozenSegments(
@@ -13904,47 +13781,6 @@ function runSegmentAction(entry, action) {
13904
13781
  }
13905
13782
  }
13906
13783
 
13907
- // src/workers/vector-code.ts
13908
- var VECTOR_TYPE_NAME = "vector";
13909
- var loaded2 = null;
13910
- var loading2 = null;
13911
- function loadedVectorCode() {
13912
- return loaded2;
13913
- }
13914
- function requireLoadedVectorCode() {
13915
- if (loaded2 === null) throw new Error("The engine reached vector code before it loaded that code");
13916
- return loaded2;
13917
- }
13918
- function loadVectorCode() {
13919
- if (loaded2 !== null) return Promise.resolve(loaded2);
13920
- if (loading2 === null) {
13921
- loading2 = import('./module-3HNFCBJ5.mjs').then(
13922
- (code) => {
13923
- loaded2 = code;
13924
- return code;
13925
- },
13926
- (err) => {
13927
- loading2 = null;
13928
- throw err;
13929
- }
13930
- );
13931
- }
13932
- return loading2;
13933
- }
13934
- function mayDeclareVectorField(schema, depth) {
13935
- if (!isPlainObject(schema) || depth > MAX_NESTING_DEPTH + 1) return false;
13936
- for (const type of Object.values(schema)) {
13937
- if (typeof type === "string" ? type.includes(VECTOR_TYPE_NAME) : mayDeclareVectorField(type, depth + 1)) {
13938
- return true;
13939
- }
13940
- }
13941
- return false;
13942
- }
13943
- function loadVectorCodeFor(schema) {
13944
- if (loaded2 !== null || !mayDeclareVectorField(schema, 1)) return null;
13945
- return loadVectorCode();
13946
- }
13947
-
13948
13784
  // src/workers/vector-copies.ts
13949
13785
  function createHeldVectorCopies() {
13950
13786
  return { searchers: /* @__PURE__ */ new Map(), fields: /* @__PURE__ */ new Map(), builds: /* @__PURE__ */ new Map() };
@@ -14150,8 +13986,8 @@ function createDirectExecutor(options) {
14150
13986
  );
14151
13987
  }
14152
13988
  case "createIndex": {
14153
- const loading3 = loadVectorCodeFor(action.config.schema);
14154
- if (loading3 !== null) await loading3;
13989
+ const loading2 = loadSchemaCodeFor(action.config.schema);
13990
+ if (loading2 !== null) await loading2;
14155
13991
  const language = getLanguage(action.config.language ?? "english");
14156
13992
  const manager = addIndex(
14157
13993
  action.indexName,
@@ -14334,7 +14170,7 @@ var TEXT_REBUILD_SWITCH_BACKLOG_DOCUMENTS = 1e3;
14334
14170
  // src/partitioning/rewrite-spill-of.ts
14335
14171
  async function rewriteSpillOf(storage, manager, target) {
14336
14172
  if (storage === void 0 || (target?.config ?? manager.config).textStorage !== "disk") return null;
14337
- const { openRewriteSpill } = await import('./module-E33X4AOK.mjs');
14173
+ const { openRewriteSpill } = await import('./module-NIYMEA5R.mjs');
14338
14174
  return openRewriteSpill(storage, manager, target);
14339
14175
  }
14340
14176
 
@@ -14424,16 +14260,16 @@ async function rebuildTextIndexes(manager, hooks, target) {
14424
14260
  const partialWordAnalysis = target === void 0 ? manager.partialWordAnalysis : target.partialWordAnalysis;
14425
14261
  const spill = await rewriteSpillOf(hooks.rewriteStorage?.(), manager, target);
14426
14262
  while (hooks.isCurrent()) {
14427
- const log = manager.openWriteLog();
14263
+ const log2 = manager.openWriteLog();
14428
14264
  let swapped = false;
14429
14265
  try {
14430
- swapped = await rebuildOnce({ manager, log, hooks, language, partialWordAnalysis, options, spill });
14266
+ swapped = await rebuildOnce({ manager, log: log2, hooks, language, partialWordAnalysis, options, spill });
14431
14267
  if (swapped) {
14432
14268
  hooks.onRewriteSpill?.(spill);
14433
14269
  return true;
14434
14270
  }
14435
14271
  } finally {
14436
- log.close();
14272
+ log2.close();
14437
14273
  if (!swapped) await spill?.abandon();
14438
14274
  }
14439
14275
  }
@@ -14937,12 +14773,12 @@ function recoveryFailure(metadata, err) {
14937
14773
  });
14938
14774
  }
14939
14775
  async function createIndexFromMetadata(deps, metadata, loadData) {
14940
- const loadingVectorCode = loadData ? loadVectorCodeFor(metadata.schema) : null;
14941
- if (loadingVectorCode !== null) await loadingVectorCode;
14776
+ const loadingSchemaCode = loadData ? loadSchemaCodeFor(metadata.schema) : null;
14777
+ if (loadingSchemaCode !== null) await loadingSchemaCode;
14942
14778
  const existing = deps.indexRegistry.get(metadata.indexName);
14943
14779
  if (existing !== void 0) {
14944
14780
  if ((metadata.analysisGeneration ?? 0) > existing.analysisGeneration) {
14945
- const { adoptSavedAnalysis } = await import('./analysis-change-TC36BU47.mjs');
14781
+ const { adoptSavedAnalysis } = await import('./analysis-change-435CUEPZ.mjs');
14946
14782
  adoptSavedAnalysis(deps.executor.getManager(metadata.indexName), existing, metadata);
14947
14783
  }
14948
14784
  if (loadData && deps.executor.getManager(metadata.indexName) === void 0) {
@@ -16312,10 +16148,10 @@ async function replicateToWorkers(state, action) {
16312
16148
  }
16313
16149
  if (!copiesWillReceive(state, action.indexName)) return;
16314
16150
  const detached = detachCallerDocuments(state, action);
16315
- const loading3 = state.copyLoadBuffers.get(action.indexName);
16316
- if (loading3 !== void 0) {
16151
+ const loading2 = state.copyLoadBuffers.get(action.indexName);
16152
+ if (loading2 !== void 0) {
16317
16153
  queueForCopies(state, detached);
16318
- if (loading3.length % LOAD_BUFFER_YIELD_INTERVAL === 0) await yieldToEventLoop2();
16154
+ if (loading2.length % LOAD_BUFFER_YIELD_INTERVAL === 0) await yieldToEventLoop2();
16319
16155
  return;
16320
16156
  }
16321
16157
  const queue = state.replicationQueues.get(action.indexName);
@@ -16326,9 +16162,9 @@ async function replicateToWorkers(state, action) {
16326
16162
  }
16327
16163
  function queueForCopies(state, action) {
16328
16164
  if (!("indexName" in action)) return;
16329
- const loading3 = state.copyLoadBuffers.get(action.indexName);
16330
- if (loading3 !== void 0) {
16331
- loading3.push(action);
16165
+ const loading2 = state.copyLoadBuffers.get(action.indexName);
16166
+ if (loading2 !== void 0) {
16167
+ loading2.push(action);
16332
16168
  return;
16333
16169
  }
16334
16170
  if (state.workerPool === null || !state.scaledOutIndexes.has(action.indexName)) return;
@@ -17705,10 +17541,10 @@ function createWorkerOrchestrator(config, executor, indexRegistry, callbacks, ve
17705
17541
  stopRequestThreads: () => stopRequestThreads(state),
17706
17542
  desyncIndex: (indexName) => {
17707
17543
  state.desyncedIndexes.add(indexName);
17708
- const loading3 = state.copyTransitions.get(indexName);
17544
+ const loading2 = state.copyTransitions.get(indexName);
17709
17545
  const wasScaledOut = state.scaledOutIndexes.delete(indexName);
17710
17546
  if (wasScaledOut) withdrawCopies(indexName);
17711
- return wasScaledOut || loading3 !== void 0 && loading3.kind !== "drop";
17547
+ return wasScaledOut || loading2 !== void 0 && loading2.kind !== "drop";
17712
17548
  },
17713
17549
  async releaseIndexCopies(indexName) {
17714
17550
  const hold = state.copyReleaseHolds.get(indexName);
@@ -17768,7 +17604,7 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
17768
17604
  if (config?.lifecycle !== void 0 && durabilityTier === null) {
17769
17605
  throw new NarsilError(ErrorCodes.CONFIG_INVALID, "Index lifecycle settings require durability");
17770
17606
  }
17771
- const durabilityWiring = durabilityTier === null ? null : await import('./durability-wiring-CVGPRO6D.mjs');
17607
+ const durabilityWiring = durabilityTier === null ? null : await import('./durability-wiring-A7BVG2DW.mjs');
17772
17608
  const filesystemDurability = durabilityTier?.kind === "wal";
17773
17609
  const executor = createDirectExecutor({
17774
17610
  vectorWorkerCopies: vectorCopyPolicy,
@@ -17954,7 +17790,7 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
17954
17790
  requireManager,
17955
17791
  resumeChange: async (indexName) => {
17956
17792
  if ((indexRegistry.get(indexName)?.pendingAnalysis ?? null) === null) return;
17957
- await (await import('./analysis-change-entry-4MH3CZXH.mjs')).resumeChangeOf(engineCore, indexName);
17793
+ await (await import('./analysis-change-entry-HZXKPPGV.mjs')).resumeChangeOf(engineCore, indexName);
17958
17794
  },
17959
17795
  onClose: hooks?.onIndexClose,
17960
17796
  onOpen: (indexName) => {
@@ -18039,7 +17875,7 @@ async function startEngineCore(core, config) {
18039
17875
  checkHeapAfterRecovery(core);
18040
17876
  }
18041
17877
  if (core.invalidation) await core.invalidation.start();
18042
- if (core.durability) await (await import('./analysis-change-entry-4MH3CZXH.mjs')).resumeEveryChange(core);
17878
+ if (core.durability) await (await import('./analysis-change-entry-HZXKPPGV.mjs')).resumeEveryChange(core);
18043
17879
  if (config?.lifecycle === void 0) await core.analysisRebuild.reviewStaleIndexes();
18044
17880
  } catch (err) {
18045
17881
  await core.durability?.manager.shutdown().catch(() => void 0);
@@ -18342,8 +18178,8 @@ async function announceIndexDropped(core, name, config) {
18342
18178
  }
18343
18179
  async function createEngineIndex(core, config, name, requestedConfig, creation = {}) {
18344
18180
  const { indexUuid, adapterBinding = "required", appliesCreationLimits = false } = creation;
18345
- const loadingVectorCode = loadVectorCodeFor(requestedConfig.schema);
18346
- if (loadingVectorCode !== null) await loadingVectorCode;
18181
+ const loadingSchemaCode = loadSchemaCodeFor(requestedConfig.schema);
18182
+ if (loadingSchemaCode !== null) await loadingSchemaCode;
18347
18183
  core.guardShutdown();
18348
18184
  validateIndexName(name);
18349
18185
  if (core.indexRegistry.has(name)) {
@@ -18454,7 +18290,7 @@ async function dropEngineIndex(core, name) {
18454
18290
  const entry = core.requireIndex(name);
18455
18291
  const changeRecorded = () => entry.pendingAnalysis !== null || entry.durableAnalysis !== null;
18456
18292
  const abandonChange = async () => {
18457
- await (await import('./analysis-change-entry-4MH3CZXH.mjs')).abandonChangeOf(core, name);
18293
+ await (await import('./analysis-change-entry-HZXKPPGV.mjs')).abandonChangeOf(core, name);
18458
18294
  };
18459
18295
  if (changeRecorded()) await abandonChange();
18460
18296
  await core.indexState.drop(name, async () => {
@@ -20201,7 +20037,7 @@ function portabilityOperations(core, config, engine) {
20201
20037
  const { restoresInFlight } = core;
20202
20038
  const previous = restoresInFlight.get(indexName) ?? Promise.resolve();
20203
20039
  const restored = previous.then(async () => {
20204
- const { runRestore } = await import('./restore-queue-ZBS7CJA6.mjs');
20040
+ const { runRestore } = await import('./restore-queue-G3RQGL3Y.mjs');
20205
20041
  await runRestore(core, restoreHost, indexName, data, engine());
20206
20042
  });
20207
20043
  const settled2 = restored.then(
@@ -20232,7 +20068,7 @@ function portabilityOperations(core, config, engine) {
20232
20068
  return {
20233
20069
  snapshot(indexName, options) {
20234
20070
  return withOpenIndex2(indexName, async () => {
20235
- const { createSnapshot } = await import('./snapshot-PN7ZW6Q4.mjs');
20071
+ const { createSnapshot } = await import('./snapshot-VEQNIE6C.mjs');
20236
20072
  return createSnapshot(snapshotDepsOf(indexName), options?.queryHistory === true ? core : null);
20237
20073
  });
20238
20074
  },
@@ -20245,8 +20081,8 @@ function portabilityOperations(core, config, engine) {
20245
20081
  exportDocuments(indexName) {
20246
20082
  return withOpenIndex2(indexName, async () => {
20247
20083
  const [{ checkpointForArchive }, { documentExportStream }] = await Promise.all([
20248
- import('./snapshot-PN7ZW6Q4.mjs'),
20249
- import('./write-HMDYCTV2.mjs')
20084
+ import('./snapshot-VEQNIE6C.mjs'),
20085
+ import('./write-2EVMZWDE.mjs')
20250
20086
  ]);
20251
20087
  const header = indexConfigurationOf(core.requireIndex(indexName));
20252
20088
  return documentExportStream(header, await checkpointForArchive(snapshotDepsOf(indexName)));
@@ -20254,7 +20090,7 @@ function portabilityOperations(core, config, engine) {
20254
20090
  },
20255
20091
  importDocumentExport(indexName, data) {
20256
20092
  core.guardShutdown();
20257
- const imported = import('./import-OM6QAW45.mjs').then(
20093
+ const imported = import('./import-DXYB6756.mjs').then(
20258
20094
  ({ readDocumentExport }) => readDocumentExport(engine(), indexName, data)
20259
20095
  );
20260
20096
  return emitWriteEventAfter(core, indexName, imported);
@@ -22275,7 +22111,7 @@ function createNarsilFromCore(core, config) {
22275
22111
  const entry = requireIndex(indexName);
22276
22112
  await withOpenIndexWrite(indexName, async () => {
22277
22113
  if (entry.pendingAnalysis === null) return core.analysisRebuild.rebuild(indexName);
22278
- return (await import('./analysis-change-TC36BU47.mjs')).resumeAnalysisChange(core, indexName);
22114
+ return (await import('./analysis-change-435CUEPZ.mjs')).resumeAnalysisChange(core, indexName);
22279
22115
  });
22280
22116
  },
22281
22117
  async changeAnalysis(indexName, change) {
@@ -22283,7 +22119,7 @@ function createNarsilFromCore(core, config) {
22283
22119
  requireIndex(indexName);
22284
22120
  const changed = withOpenIndex2(
22285
22121
  indexName,
22286
- async () => (await import('./analysis-change-TC36BU47.mjs')).changeIndexAnalysis(core, indexName, change)
22122
+ async () => (await import('./analysis-change-435CUEPZ.mjs')).changeIndexAnalysis(core, indexName, change)
22287
22123
  );
22288
22124
  await emitWriteEventAfter(core, indexName, changed);
22289
22125
  },
@@ -22318,7 +22154,7 @@ function createNarsilFromCore(core, config) {
22318
22154
  const rebalanced = withOpenIndex2(
22319
22155
  indexName,
22320
22156
  () => withRenewedSyncEpoch(core, indexName, async () => {
22321
- const { executeRebalance } = await import('./analysis-change-TC36BU47.mjs');
22157
+ const { executeRebalance } = await import('./analysis-change-435CUEPZ.mjs');
22322
22158
  const running = executeRebalance(requireManager(indexName), indexName, targetPartitionCount, rebalanceCtx);
22323
22159
  releaseWrites();
22324
22160
  await running;
@@ -22403,8 +22239,8 @@ function createNarsilFromCore(core, config) {
22403
22239
  guardShutdown();
22404
22240
  requireIndex(indexName);
22405
22241
  const manager = executor.getManager(indexName);
22406
- const vectorCode = loadedVectorCode();
22407
- return manager === void 0 || vectorCode === null ? [] : vectorCode.getVectorMaintenanceStatus(manager);
22242
+ const vectorCode2 = loadedVectorCode();
22243
+ return manager === void 0 || vectorCode2 === null ? [] : vectorCode2.getVectorMaintenanceStatus(manager);
22408
22244
  },
22409
22245
  on(event, handler) {
22410
22246
  const key = event;
@@ -22442,7 +22278,7 @@ async function createNarsil(config) {
22442
22278
  await startEngineCore(core, runnableConfig);
22443
22279
  const engine = createNarsilFromCore(core, runnableConfig);
22444
22280
  if (runnableConfig?.querySuggestions !== void 0 || core.durability !== null) {
22445
- await (await import('./engine-hooks-YXMPHZKZ.mjs')).startQuerySuggestions(core, engine, runnableConfig);
22281
+ await (await import('./engine-hooks-E4UD67JD.mjs')).startQuerySuggestions(core, engine, runnableConfig);
22446
22282
  }
22447
22283
  return engine;
22448
22284
  }
@@ -22450,4 +22286,4 @@ async function createNarsil(config) {
22450
22286
  // src/index.ts
22451
22287
  var VERSION = "0.1.0";
22452
22288
 
22453
- 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, 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, 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 };
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 };