scip-query 0.21.0 → 0.22.0

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 (496) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/dist/augment-vue-worker.js +1 -1
  3. package/dist/by-kind-4IYG2SKW.js +2 -0
  4. package/dist/call-graph-WQNXMNNN.js +2 -0
  5. package/dist/{chunk-AQDWTCDC.js → chunk-25GWKRUZ.js} +2 -2
  6. package/dist/chunk-2BTJALUS.js +454 -0
  7. package/dist/chunk-2KVU55CW.js +11 -0
  8. package/dist/{chunk-BBWPOMGU.js → chunk-2OXVP5U5.js} +2 -2
  9. package/dist/{chunk-D5W4UZY5.js → chunk-2RE5OCHZ.js} +2 -2
  10. package/dist/{chunk-2I3RSUWX.js → chunk-2XCGSDIT.js} +2 -2
  11. package/dist/{chunk-V7LQZTTZ.js → chunk-2YC7YNKT.js} +2 -2
  12. package/dist/chunk-3QXC54FQ.js +3 -0
  13. package/dist/{chunk-32A42O5B.js → chunk-3TJY6M3B.js} +2 -2
  14. package/dist/chunk-42W3LFUK.js +13 -0
  15. package/dist/chunk-44T4DUAA.js +2 -0
  16. package/dist/chunk-4GAQ6FI4.js +43 -0
  17. package/dist/{chunk-4S4DF62J.js → chunk-4HE7MVWD.js} +2 -2
  18. package/dist/{chunk-TGWNNMPF.js → chunk-4TQU4TX2.js} +2 -2
  19. package/dist/{chunk-SKUMCCC5.js → chunk-56NQAEPJ.js} +2 -2
  20. package/dist/chunk-57N6LN2A.js +3 -0
  21. package/dist/{chunk-LPGDO2XA.js → chunk-5H5WTJSD.js} +2 -2
  22. package/dist/{chunk-EA4SH4U5.js → chunk-5YRQIE2B.js} +2 -2
  23. package/dist/{chunk-O2RM7E7L.js → chunk-5ZMBRQFC.js} +4 -4
  24. package/dist/{chunk-ICHBVITH.js → chunk-6HRZQLOI.js} +2 -2
  25. package/dist/{chunk-WULAPQUD.js → chunk-6NC3YSPY.js} +2 -2
  26. package/dist/{chunk-IDPLC3FI.js → chunk-6VEFRPTD.js} +2 -2
  27. package/dist/{chunk-IOKWFRFQ.js → chunk-7C26EKLZ.js} +2 -2
  28. package/dist/{chunk-S3RTPPLQ.js → chunk-7IQXARSQ.js} +2 -2
  29. package/dist/chunk-7JYHQAH2.js +22 -0
  30. package/dist/chunk-7KSO2OAP.js +2 -0
  31. package/dist/{chunk-2ZBMOQGG.js → chunk-7U2YQSDE.js} +2 -2
  32. package/dist/{chunk-EKZRF57O.js → chunk-7XA3OM44.js} +2 -2
  33. package/dist/{chunk-4EXFZP6H.js → chunk-7XZGZBSQ.js} +2 -2
  34. package/dist/chunk-7YQOCABQ.js +2 -0
  35. package/dist/chunk-A77SCPW2.js +3 -0
  36. package/dist/chunk-AK3PYTIK.js +5 -0
  37. package/dist/chunk-AMIMMNA4.js +11 -0
  38. package/dist/{chunk-MOBF2GH6.js → chunk-AQ2PORIO.js} +2 -2
  39. package/dist/{chunk-YUFWLWIC.js → chunk-ARVO6TTW.js} +2 -2
  40. package/dist/chunk-AUY5BL74.js +2 -0
  41. package/dist/{chunk-RGCJ4646.js → chunk-AYPDH2LU.js} +2 -2
  42. package/dist/{chunk-73Z33VFI.js → chunk-AZS7YPCB.js} +2 -2
  43. package/dist/{chunk-SYUNTKO2.js → chunk-BDGTPN27.js} +2 -2
  44. package/dist/{chunk-BATIVRU2.js → chunk-BDHFVH2M.js} +2 -2
  45. package/dist/chunk-BECZLYNU.js +8 -0
  46. package/dist/chunk-BJT7LSPK.js +3 -0
  47. package/dist/{chunk-6SWA6B24.js → chunk-BTVKZGWT.js} +2 -2
  48. package/dist/{chunk-QD7IFBCR.js → chunk-BUTEIZKP.js} +2 -2
  49. package/dist/{chunk-UZFCZ7SJ.js → chunk-BVFYEEBH.js} +2 -2
  50. package/dist/{chunk-ICUQONOG.js → chunk-BWVQP3LB.js} +2 -2
  51. package/dist/chunk-BYDAFMSR.js +57 -0
  52. package/dist/{chunk-BHE44MHT.js → chunk-C76O5MDS.js} +2 -2
  53. package/dist/chunk-C7IJMOFP.js +134 -0
  54. package/dist/{chunk-CN2WGM7D.js → chunk-CBBHFNLX.js} +2 -2
  55. package/dist/{chunk-COTMS5KM.js → chunk-CKRWA452.js} +2 -2
  56. package/dist/{chunk-ANWGXPPN.js → chunk-CLG6DWVS.js} +2 -2
  57. package/dist/chunk-D2MVJSP4.js +21 -0
  58. package/dist/chunk-D35XIZGN.js +2 -0
  59. package/dist/{chunk-U7DR7MJD.js → chunk-DEAB5TGT.js} +2 -2
  60. package/dist/{chunk-6GJAP4OE.js → chunk-DJAO2OZJ.js} +2 -2
  61. package/dist/chunk-DKM723YF.js +79 -0
  62. package/dist/{chunk-4IIMPWMR.js → chunk-DPWKKNKI.js} +2 -2
  63. package/dist/chunk-E44IVWIJ.js +367 -0
  64. package/dist/chunk-EDMB6SSO.js +7 -0
  65. package/dist/{chunk-KWARB5FZ.js → chunk-EELG7D3Q.js} +2 -2
  66. package/dist/chunk-EELPBR7E.js +3 -0
  67. package/dist/chunk-EETGXQY7.js +3 -0
  68. package/dist/chunk-ENWQWA2R.js +2 -0
  69. package/dist/{chunk-HUZNZ3H2.js → chunk-ERCYGVAM.js} +2 -2
  70. package/dist/{chunk-WSG3DK5H.js → chunk-EWWY2ZFL.js} +2 -2
  71. package/dist/chunk-F24G5NBE.js +3 -0
  72. package/dist/{chunk-XRXCANFQ.js → chunk-F24QUEQP.js} +2 -2
  73. package/dist/{chunk-KFK7GF5C.js → chunk-FBCVASUG.js} +2 -2
  74. package/dist/{chunk-35IW3P4H.js → chunk-FELGD32K.js} +2 -2
  75. package/dist/{chunk-UNORWZIJ.js → chunk-FFJQZG6J.js} +5 -5
  76. package/dist/{chunk-5SE323LF.js → chunk-FGNCOQUX.js} +2 -2
  77. package/dist/chunk-FKGQOTKD.js +2 -0
  78. package/dist/chunk-GDRJB3SB.js +3 -0
  79. package/dist/chunk-GH5YSGZL.js +5 -0
  80. package/dist/{chunk-X7PJJYKX.js → chunk-GIQ6CSL4.js} +2 -2
  81. package/dist/{chunk-2RP27XLR.js → chunk-GPGRZJ3R.js} +2 -2
  82. package/dist/{chunk-IYV2YBHM.js → chunk-GQIDEID3.js} +2 -2
  83. package/dist/chunk-GRX7JOXQ.js +2 -0
  84. package/dist/{chunk-H46QMB7E.js → chunk-GVOMSPGL.js} +2 -2
  85. package/dist/{chunk-KTRGJLY7.js → chunk-GY7CCCEZ.js} +2 -2
  86. package/dist/{chunk-VNKYRJKN.js → chunk-H7CG6LOE.js} +2 -2
  87. package/dist/chunk-HCVJR2V4.js +3 -0
  88. package/dist/chunk-HG722PO7.js +3 -0
  89. package/dist/{chunk-LHTT5C3Z.js → chunk-HISEUIL2.js} +2 -2
  90. package/dist/{chunk-K5MZYZV7.js → chunk-HXOU4XNH.js} +2 -2
  91. package/dist/chunk-I6UTXNHU.js +6 -0
  92. package/dist/{chunk-I7PFL5P3.js → chunk-IJMD6BRI.js} +2 -2
  93. package/dist/{chunk-XXJ7WL3F.js → chunk-IKVNEGTW.js} +2 -2
  94. package/dist/chunk-IMKZEXZG.js +2 -0
  95. package/dist/chunk-ISIQLPJ2.js +61 -0
  96. package/dist/{chunk-DEUGHURX.js → chunk-ISWFRGJ6.js} +2 -2
  97. package/dist/chunk-IW5XQG5G.js +2 -0
  98. package/dist/chunk-IXESDH3J.js +2 -0
  99. package/dist/{chunk-FGB567HK.js → chunk-JAT6C3VX.js} +2 -2
  100. package/dist/{chunk-7TWP3MCP.js → chunk-JFQBRL3J.js} +2 -2
  101. package/dist/{chunk-Q7HB7BFJ.js → chunk-JHH5SCZ3.js} +2 -2
  102. package/dist/{chunk-ZHSARYVS.js → chunk-JJ62MTQH.js} +2 -2
  103. package/dist/chunk-JT6XX7QY.js +8 -0
  104. package/dist/{chunk-5H7IWVXJ.js → chunk-JUN5DOAK.js} +2 -2
  105. package/dist/{chunk-DOPCR5BY.js → chunk-K3XFWJI2.js} +2 -2
  106. package/dist/{chunk-Y4XQ7LES.js → chunk-KFOYCQAJ.js} +1 -1
  107. package/dist/{chunk-N5C65OFK.js → chunk-KFVSJX25.js} +2 -2
  108. package/dist/chunk-KK7GPALL.js +28 -0
  109. package/dist/{chunk-DHKBIOXF.js → chunk-KQHJEU6V.js} +2 -2
  110. package/dist/{chunk-WB6LGCFB.js → chunk-KZYID5KV.js} +2 -2
  111. package/dist/{chunk-KW6B5OL4.js → chunk-LO5JSW2C.js} +2 -2
  112. package/dist/{chunk-ZW44MCJM.js → chunk-LRI5OMPE.js} +2 -2
  113. package/dist/{chunk-HG5YI7PV.js → chunk-LXQUF2RP.js} +2 -2
  114. package/dist/{chunk-TM5XEDDR.js → chunk-MHIEP7EG.js} +2 -2
  115. package/dist/{chunk-FHV7NMFU.js → chunk-MSR2QRUE.js} +2 -2
  116. package/dist/chunk-N7FP5H5U.js +57 -0
  117. package/dist/{chunk-3653GTR7.js → chunk-NEIQPFBI.js} +2 -2
  118. package/dist/chunk-NK3JMP22.js +2 -0
  119. package/dist/{chunk-7IOAZRVL.js → chunk-NRBNAECH.js} +2 -2
  120. package/dist/{chunk-HGKEAP7F.js → chunk-NVSZNESQ.js} +2 -2
  121. package/dist/{chunk-R2MOKIVO.js → chunk-OJNK5ALA.js} +2 -2
  122. package/dist/{chunk-RFWAUHVW.js → chunk-OPSAW5DT.js} +2 -2
  123. package/dist/chunk-OTSPRVNW.js +2 -0
  124. package/dist/chunk-OXYAWIEA.js +2 -0
  125. package/dist/chunk-OZETODHH.js +2 -0
  126. package/dist/chunk-PBUH2P5S.js +3 -0
  127. package/dist/{chunk-QBANU5BQ.js → chunk-PIFTZEEM.js} +2 -2
  128. package/dist/{chunk-CKDOY6JA.js → chunk-PLJUQFQN.js} +2 -2
  129. package/dist/{chunk-JVZNWJBH.js → chunk-PLYUVM4F.js} +2 -2
  130. package/dist/chunk-PXXYQK55.js +2 -0
  131. package/dist/{chunk-WZQFY5S7.js → chunk-Q55NF3ZG.js} +2 -2
  132. package/dist/{chunk-OVPS2ILI.js → chunk-Q5TA4OY4.js} +2 -2
  133. package/dist/{chunk-OUB4J26T.js → chunk-Q6T2CAJL.js} +2 -2
  134. package/dist/chunk-Q7GBK5T7.js +81 -0
  135. package/dist/chunk-QKT4UI2Y.js +2 -0
  136. package/dist/{chunk-PIZY2GX6.js → chunk-QLBSG7U5.js} +2 -2
  137. package/dist/chunk-QWKHW6VZ.js +2 -0
  138. package/dist/{chunk-E7BJXRNV.js → chunk-R6M456QG.js} +2 -2
  139. package/dist/{chunk-MJNV7OCG.js → chunk-RDULNRSJ.js} +2 -2
  140. package/dist/{chunk-SSSJO4RG.js → chunk-RHHCLWQ6.js} +2 -2
  141. package/dist/chunk-RNKPYYYE.js +4 -0
  142. package/dist/{chunk-IXJ26KJJ.js → chunk-RPL3ARU7.js} +2 -2
  143. package/dist/{chunk-3EX7DNBC.js → chunk-RYOYJMGF.js} +2 -2
  144. package/dist/chunk-SB25YMEQ.js +2 -0
  145. package/dist/chunk-SV2LEFVM.js +2 -0
  146. package/dist/{chunk-ZBNL3QCY.js → chunk-SVHTMVA4.js} +3 -3
  147. package/dist/{chunk-6IEVHGWG.js → chunk-SWK4XPUS.js} +2 -2
  148. package/dist/chunk-T6QD2ZQB.js +43 -0
  149. package/dist/{chunk-VETXXOYU.js → chunk-TAYD3AE7.js} +2 -2
  150. package/dist/chunk-TD7VKJ2Y.js +117 -0
  151. package/dist/{chunk-UQ7XPRWU.js → chunk-TH6IC56G.js} +2 -2
  152. package/dist/{chunk-XVDMJMES.js → chunk-TKDNDQA7.js} +2 -2
  153. package/dist/{chunk-CSDDOUA4.js → chunk-TNG2FYS5.js} +2 -2
  154. package/dist/chunk-TQZV7KV4.js +2 -0
  155. package/dist/{chunk-AJVMVE7X.js → chunk-TUQIPUDS.js} +2 -2
  156. package/dist/chunk-TUSPIVZ3.js +4 -0
  157. package/dist/{chunk-ORBKAUCH.js → chunk-U2N2KE7A.js} +2 -2
  158. package/dist/{chunk-3PII3JI5.js → chunk-UAQ4T73O.js} +2 -2
  159. package/dist/{chunk-OFY4HTMI.js → chunk-UDY7MIAW.js} +2 -2
  160. package/dist/{chunk-WKPZCQLI.js → chunk-URSGGIZX.js} +2 -2
  161. package/dist/{chunk-UL4VJUMD.js → chunk-UT7TADJX.js} +2 -2
  162. package/dist/chunk-V4NG5OMS.js +554 -0
  163. package/dist/{chunk-2H4IAJHO.js → chunk-VMWUV6WB.js} +2 -2
  164. package/dist/{chunk-46JLFIGA.js → chunk-VTCIYFEK.js} +2 -2
  165. package/dist/chunk-VU6LIWHT.js +2 -0
  166. package/dist/chunk-VUSKPCUB.js +2 -0
  167. package/dist/{chunk-URMZLV2N.js → chunk-VXJJTQYE.js} +2 -2
  168. package/dist/{chunk-IPAL6DP2.js → chunk-VZ7NXSHV.js} +2 -2
  169. package/dist/{chunk-FUG6RPYY.js → chunk-WHADK6OS.js} +2 -2
  170. package/dist/chunk-WN3TCGJ4.js +2 -0
  171. package/dist/{chunk-B7ECWJAZ.js → chunk-WOOAY3PA.js} +2 -2
  172. package/dist/chunk-WRQXLNYE.js +9 -0
  173. package/dist/chunk-WSLEJSFR.js +2 -0
  174. package/dist/chunk-WYZIHUPZ.js +16 -0
  175. package/dist/{chunk-ZYREOING.js → chunk-XE33FV5W.js} +2 -2
  176. package/dist/chunk-XFMVKFSF.js +2 -0
  177. package/dist/{chunk-BBEDPVPB.js → chunk-XGGBK66W.js} +2 -2
  178. package/dist/{chunk-OFUBXBYX.js → chunk-XJX6LGHL.js} +2 -2
  179. package/dist/{chunk-Z3GCK3PD.js → chunk-XN22RGSR.js} +2 -2
  180. package/dist/{chunk-HWLCBKFE.js → chunk-XSWYJCAK.js} +2 -2
  181. package/dist/{chunk-IGKKTHJR.js → chunk-XU75YQN4.js} +2 -2
  182. package/dist/{chunk-E4EJBGDZ.js → chunk-Y2VM4CJC.js} +2 -2
  183. package/dist/{chunk-U7LRSQG6.js → chunk-Y334QQU5.js} +2 -2
  184. package/dist/{chunk-APLKXICZ.js → chunk-YAGYMBEX.js} +2 -2
  185. package/dist/{chunk-XITQLISP.js → chunk-YIHNPKWD.js} +2 -2
  186. package/dist/chunk-YXPUP5G2.js +11 -0
  187. package/dist/{chunk-6BJ7SOY7.js → chunk-Z2AWCTN6.js} +2 -2
  188. package/dist/{chunk-PHSPBQM6.js → chunk-Z2PZVKPR.js} +2 -2
  189. package/dist/{chunk-QXR5QPSF.js → chunk-ZAZGGSM3.js} +2 -2
  190. package/dist/{chunk-5236NQV3.js → chunk-ZGW4HLPD.js} +2 -2
  191. package/dist/chunk-ZOXKSQQB.js +2 -0
  192. package/dist/{chunk-BD6CV7PN.js → chunk-ZPASRBLF.js} +2 -2
  193. package/dist/{chunk-DMUGTKMD.js → chunk-ZYM4HOFA.js} +2 -2
  194. package/dist/{chunk-4ILHWBYF.js → chunk-ZZ3Z7D56.js} +2 -2
  195. package/dist/cli-main.js +4 -4
  196. package/dist/{code-CczEvHui.d.ts → code-B17qEMbt.d.ts} +1 -1
  197. package/dist/code-EQJFDT6I.js +2 -0
  198. package/dist/code-result-json-7UWIWBOO.js +2 -0
  199. package/dist/command-descriptors-ORNTVNYV.js +342 -0
  200. package/dist/{config-types-Cm-VSEBb.d.ts → config-types-B9B60MiR.d.ts} +10 -0
  201. package/dist/dataflow-6VL54GX5.js +2 -0
  202. package/dist/{db-LKJXAlNS.d.ts → db-BwIVAYNB.d.ts} +1 -1
  203. package/dist/dependence-slice-DT2NUHD2.js +2 -0
  204. package/dist/deps-DB7H5IKC.js +2 -0
  205. package/dist/direct-navigation-O3LUAYWQ.js +3 -0
  206. package/dist/entry-map-6K62RV3D.js +2 -0
  207. package/dist/files-MSLD7MO6.js +2 -0
  208. package/dist/{graph-evidence-CbUPCSKV.d.ts → graph-evidence-Bjyky2V4.d.ts} +1 -1
  209. package/dist/{health-Wl5G_LRt.d.ts → health-CPp2Jf1Z.d.ts} +1 -1
  210. package/dist/hierarchy-IVBXAKFA.js +2 -0
  211. package/dist/imports-FRAVZ3Y2.js +2 -0
  212. package/dist/index.d.ts +2 -2
  213. package/dist/index.js +1 -1
  214. package/dist/members-KJOJDYGO.js +2 -0
  215. package/dist/methods-2AYABBT3.js +2 -0
  216. package/dist/output-continuation-command-JHMPH6NC.js +3 -0
  217. package/dist/{output-pagination-VAWOGX4R.js → output-pagination-3OFL2MJV.js} +2 -2
  218. package/dist/project-reindex-HYO4WD7Z.js +3 -0
  219. package/dist/queries/affected.d.ts +2 -2
  220. package/dist/queries/affected.js +1 -1
  221. package/dist/queries/anchors.d.ts +2 -2
  222. package/dist/queries/anchors.js +1 -1
  223. package/dist/queries/architecture.d.ts +2 -2
  224. package/dist/queries/architecture.js +1 -1
  225. package/dist/queries/bottlenecks.d.ts +2 -2
  226. package/dist/queries/bottlenecks.js +1 -1
  227. package/dist/queries/by-kind.d.ts +2 -2
  228. package/dist/queries/by-kind.js +1 -1
  229. package/dist/queries/call-graph.d.ts +2 -2
  230. package/dist/queries/call-graph.js +1 -1
  231. package/dist/queries/change-surface.d.ts +2 -2
  232. package/dist/queries/change-surface.js +1 -1
  233. package/dist/queries/cleanup-plan.d.ts +2 -2
  234. package/dist/queries/cleanup-plan.js +1 -1
  235. package/dist/queries/co-change.d.ts +2 -2
  236. package/dist/queries/co-change.js +1 -1
  237. package/dist/queries/code.d.ts +3 -3
  238. package/dist/queries/code.js +1 -1
  239. package/dist/queries/complexity-hotspots.d.ts +2 -2
  240. package/dist/queries/complexity-hotspots.js +1 -1
  241. package/dist/queries/complexity.d.ts +13 -2
  242. package/dist/queries/complexity.js +1 -1
  243. package/dist/queries/context.d.ts +2 -2
  244. package/dist/queries/context.js +1 -1
  245. package/dist/queries/convergence.d.ts +2 -2
  246. package/dist/queries/convergence.js +1 -1
  247. package/dist/queries/coupling.d.ts +2 -2
  248. package/dist/queries/coupling.js +1 -1
  249. package/dist/queries/cycles.d.ts +2 -2
  250. package/dist/queries/cycles.js +1 -1
  251. package/dist/queries/dataflow.d.ts +2 -2
  252. package/dist/queries/dataflow.js +1 -1
  253. package/dist/queries/dead.d.ts +2 -2
  254. package/dist/queries/dead.js +1 -1
  255. package/dist/queries/decorative-checkers.d.ts +2 -2
  256. package/dist/queries/decorative-checkers.js +1 -1
  257. package/dist/queries/deep-chains.d.ts +2 -2
  258. package/dist/queries/deep-chains.js +1 -1
  259. package/dist/queries/dependence-slice.d.ts +3 -3
  260. package/dist/queries/dependence-slice.js +1 -1
  261. package/dist/queries/dependency-depth.d.ts +2 -2
  262. package/dist/queries/dependency-depth.js +1 -1
  263. package/dist/queries/deps.d.ts +2 -2
  264. package/dist/queries/deps.js +1 -1
  265. package/dist/queries/diff-impact.d.ts +2 -2
  266. package/dist/queries/diff-impact.js +1 -1
  267. package/dist/queries/doc-drift.d.ts +2 -2
  268. package/dist/queries/doc-drift.js +1 -1
  269. package/dist/queries/drift.d.ts +2 -2
  270. package/dist/queries/drift.js +1 -1
  271. package/dist/queries/duplicate-bodies.d.ts +2 -2
  272. package/dist/queries/duplicate-bodies.js +1 -1
  273. package/dist/queries/entry-map.d.ts +2 -2
  274. package/dist/queries/entry-map.js +1 -1
  275. package/dist/queries/evidence.d.ts +3 -3
  276. package/dist/queries/evidence.js +1 -1
  277. package/dist/queries/extract-candidates.d.ts +2 -2
  278. package/dist/queries/extract-candidates.js +1 -1
  279. package/dist/queries/fan.d.ts +2 -2
  280. package/dist/queries/fan.js +1 -1
  281. package/dist/queries/files.d.ts +2 -2
  282. package/dist/queries/files.js +1 -1
  283. package/dist/queries/health.d.ts +3 -3
  284. package/dist/queries/health.js +1 -1
  285. package/dist/queries/hierarchy.d.ts +2 -2
  286. package/dist/queries/hierarchy.js +1 -1
  287. package/dist/queries/hotspots.d.ts +2 -2
  288. package/dist/queries/hotspots.js +1 -1
  289. package/dist/queries/imports.d.ts +2 -2
  290. package/dist/queries/imports.js +1 -1
  291. package/dist/queries/incomplete-migration.d.ts +2 -2
  292. package/dist/queries/incomplete-migration.js +1 -1
  293. package/dist/queries/index.d.ts +5 -5
  294. package/dist/queries/index.js +1 -1
  295. package/dist/queries/isolated.d.ts +2 -2
  296. package/dist/queries/isolated.js +1 -1
  297. package/dist/queries/locality-candidates.d.ts +2 -2
  298. package/dist/queries/locality-candidates.js +1 -1
  299. package/dist/queries/members.d.ts +2 -2
  300. package/dist/queries/members.js +1 -1
  301. package/dist/queries/methods.d.ts +2 -2
  302. package/dist/queries/methods.js +1 -1
  303. package/dist/queries/not-implemented.d.ts +2 -2
  304. package/dist/queries/not-implemented.js +1 -1
  305. package/dist/queries/outline.d.ts +2 -2
  306. package/dist/queries/outline.js +1 -1
  307. package/dist/queries/passthrough-candidates.d.ts +2 -2
  308. package/dist/queries/passthrough-candidates.js +1 -1
  309. package/dist/queries/plan-context.d.ts +2 -2
  310. package/dist/queries/plan-context.js +1 -1
  311. package/dist/queries/react-component-duplicates.d.ts +2 -2
  312. package/dist/queries/react-component-duplicates.js +1 -1
  313. package/dist/queries/react-hook-candidates.d.ts +2 -2
  314. package/dist/queries/react-hook-candidates.js +1 -1
  315. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  316. package/dist/queries/react-large-component-pressure.js +1 -1
  317. package/dist/queries/recent-duplicates.d.ts +2 -2
  318. package/dist/queries/recent-duplicates.js +1 -1
  319. package/dist/queries/redundant-reexports.d.ts +2 -2
  320. package/dist/queries/redundant-reexports.js +1 -1
  321. package/dist/queries/reference-neighborhood.d.ts +2 -2
  322. package/dist/queries/reference-neighborhood.js +1 -1
  323. package/dist/queries/reference-reachability.d.ts +2 -2
  324. package/dist/queries/reference-reachability.js +1 -1
  325. package/dist/queries/refs.d.ts +2 -2
  326. package/dist/queries/refs.js +1 -1
  327. package/dist/queries/self-audit.d.ts +2 -2
  328. package/dist/queries/self-audit.js +1 -1
  329. package/dist/queries/similar-chains.d.ts +2 -2
  330. package/dist/queries/similar-chains.js +1 -1
  331. package/dist/queries/similar-files.d.ts +2 -2
  332. package/dist/queries/similar-files.js +1 -1
  333. package/dist/queries/similar-signatures.d.ts +2 -2
  334. package/dist/queries/similar-signatures.js +1 -1
  335. package/dist/queries/similar.d.ts +2 -2
  336. package/dist/queries/similar.js +1 -1
  337. package/dist/queries/slice.d.ts +2 -2
  338. package/dist/queries/slice.js +1 -1
  339. package/dist/queries/source-inspection.d.ts +4 -4
  340. package/dist/queries/source-inspection.js +1 -1
  341. package/dist/queries/source-search.d.ts +2 -2
  342. package/dist/queries/source-search.js +1 -1
  343. package/dist/queries/stale-abstractions.d.ts +2 -2
  344. package/dist/queries/stale-abstractions.js +1 -1
  345. package/dist/queries/stats.d.ts +2 -2
  346. package/dist/queries/surface.d.ts +2 -2
  347. package/dist/queries/surface.js +1 -1
  348. package/dist/queries/symbols.d.ts +2 -2
  349. package/dist/queries/symbols.js +1 -1
  350. package/dist/queries/system-map.d.ts +2 -2
  351. package/dist/queries/system-map.js +1 -1
  352. package/dist/queries/system.d.ts +2 -2
  353. package/dist/queries/system.js +1 -1
  354. package/dist/queries/test-quality.d.ts +2 -2
  355. package/dist/queries/test-quality.js +1 -1
  356. package/dist/queries/trace.d.ts +2 -2
  357. package/dist/queries/trace.js +1 -1
  358. package/dist/queries/twin-ab.d.ts +2 -2
  359. package/dist/queries/twin-ab.js +1 -1
  360. package/dist/queries/twin-drift.d.ts +2 -2
  361. package/dist/queries/twin-drift.js +1 -1
  362. package/dist/queries/unused-imports.d.ts +2 -2
  363. package/dist/queries/unused-imports.js +1 -1
  364. package/dist/queries/unused-params.d.ts +2 -2
  365. package/dist/queries/unused-params.js +1 -1
  366. package/dist/queries/value-flow.d.ts +3 -3
  367. package/dist/queries/value-flow.js +1 -1
  368. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  369. package/dist/queries/vue-component-duplicates.js +1 -1
  370. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  371. package/dist/queries/vue-composable-candidates.js +1 -1
  372. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  373. package/dist/queries/vue-large-view-pressure.js +1 -1
  374. package/dist/queries/wrapper-candidates.d.ts +2 -2
  375. package/dist/queries/wrapper-candidates.js +1 -1
  376. package/dist/query-service-fastpath.js +5 -5
  377. package/dist/query-service-server.js +2 -2
  378. package/dist/refs-ARMA6XUJ.js +2 -0
  379. package/dist/refs-pagination-VUGIWN6U.js +2 -0
  380. package/dist/reindex-worker.js +125 -66
  381. package/dist/reindex.d.ts +5 -3
  382. package/dist/reindex.js +135 -76
  383. package/dist/runtime.d.ts +5 -5
  384. package/dist/runtime.js +4 -4
  385. package/dist/rust-semantic-session-server.js +1 -1
  386. package/dist/rust-semantic-session-worker.js +1 -1
  387. package/dist/rust-semantic-worker.js +1 -1
  388. package/dist/{scip-cli-CppzF5MK.d.ts → scip-cli-H-n59izO.d.ts} +1 -1
  389. package/dist/slice-YOB5YFAM.js +2 -0
  390. package/dist/surface-VY5EFWTW.js +2 -0
  391. package/dist/symbol-resolution-DGQN4XIV.js +2 -0
  392. package/dist/system-2KQ3QD2P.js +2 -0
  393. package/dist/trace-HTIPTXAE.js +2 -0
  394. package/dist/typescript-mailbox-worker.js +1 -1
  395. package/dist/value-flow-5FV3VQI7.js +2 -0
  396. package/dist/watch-server.js +3 -3
  397. package/docs/CLI_JSON_OUTPUT.md +2 -2
  398. package/docs/COMMAND_REFERENCE.md +2 -2
  399. package/docs/schemas/project-config.schema.json +11 -1
  400. package/package.json +6 -5
  401. package/skills/scip-explore/SKILL.md +73 -3
  402. package/skills/scip-explore/agents/openai.yaml +3 -3
  403. package/skills/scip-explore/references/delegated-exploration.md +51 -0
  404. package/skills/scip-explore/references/external-evidence.md +72 -0
  405. package/skills/scip-explore/references/information-model.md +51 -0
  406. package/skills/scip-explore/scripts/capture-evidence.mjs +666 -0
  407. package/skills/scip-query/SKILL.md +22 -1
  408. package/dist/by-kind-CI3O6PQG.js +0 -2
  409. package/dist/call-graph-6QTUTXH7.js +0 -2
  410. package/dist/chunk-2COFMIVK.js +0 -60
  411. package/dist/chunk-35ELD3RM.js +0 -2
  412. package/dist/chunk-3FQ3KMCD.js +0 -2
  413. package/dist/chunk-3VLJ2DCA.js +0 -2
  414. package/dist/chunk-4DCKBY6T.js +0 -5
  415. package/dist/chunk-4N6QSEMZ.js +0 -10
  416. package/dist/chunk-4OE2JO6I.js +0 -2
  417. package/dist/chunk-4UUCUASK.js +0 -554
  418. package/dist/chunk-54EOGFBR.js +0 -2
  419. package/dist/chunk-5IZTXSOL.js +0 -117
  420. package/dist/chunk-5ZJH6DDE.js +0 -2
  421. package/dist/chunk-63MBA7EG.js +0 -3
  422. package/dist/chunk-6T7H2AFY.js +0 -3
  423. package/dist/chunk-7COHFNJK.js +0 -38
  424. package/dist/chunk-7HU2IJ2T.js +0 -3
  425. package/dist/chunk-7PPYXENX.js +0 -2
  426. package/dist/chunk-AA7K3XLM.js +0 -21
  427. package/dist/chunk-AUP6YI5M.js +0 -2
  428. package/dist/chunk-CA5RE6H7.js +0 -2
  429. package/dist/chunk-CT5SI2I4.js +0 -2
  430. package/dist/chunk-D5EKVZPI.js +0 -2
  431. package/dist/chunk-DMQ7ZKJG.js +0 -81
  432. package/dist/chunk-ELNRLMC5.js +0 -29
  433. package/dist/chunk-F7WQ337U.js +0 -308
  434. package/dist/chunk-FEQIQ26E.js +0 -2
  435. package/dist/chunk-FN6EJM6Q.js +0 -2
  436. package/dist/chunk-FTSQNONX.js +0 -2
  437. package/dist/chunk-G2F6T5BV.js +0 -2
  438. package/dist/chunk-G6OGPXJW.js +0 -9
  439. package/dist/chunk-GFLTPNWV.js +0 -3
  440. package/dist/chunk-GTDP2SKQ.js +0 -2
  441. package/dist/chunk-HEOMG7IM.js +0 -8
  442. package/dist/chunk-I3U2FN2T.js +0 -13
  443. package/dist/chunk-IUJ3ZFEE.js +0 -7
  444. package/dist/chunk-LXLD46LH.js +0 -21
  445. package/dist/chunk-MEI3PTUK.js +0 -2
  446. package/dist/chunk-MO226P4Q.js +0 -4
  447. package/dist/chunk-MYUKI5VN.js +0 -4
  448. package/dist/chunk-OIRWZIYL.js +0 -38
  449. package/dist/chunk-OIVZ7PW6.js +0 -438
  450. package/dist/chunk-PNISDVYC.js +0 -3
  451. package/dist/chunk-PQOL42AW.js +0 -2
  452. package/dist/chunk-PUVZNFVY.js +0 -11
  453. package/dist/chunk-PZEI2TVL.js +0 -4
  454. package/dist/chunk-Q2J2VZZT.js +0 -2
  455. package/dist/chunk-QDCCHMVZ.js +0 -2
  456. package/dist/chunk-QLQBZOJH.js +0 -3
  457. package/dist/chunk-S73HBCGI.js +0 -11
  458. package/dist/chunk-SDPA5DKN.js +0 -210
  459. package/dist/chunk-SEUJVWT2.js +0 -3
  460. package/dist/chunk-SF7X6QNW.js +0 -2
  461. package/dist/chunk-SWFAFA4G.js +0 -49
  462. package/dist/chunk-T6FRID7Y.js +0 -3
  463. package/dist/chunk-TNOHGHZQ.js +0 -2
  464. package/dist/chunk-U2GPTA5U.js +0 -3
  465. package/dist/chunk-URTX2BEA.js +0 -6
  466. package/dist/chunk-VGRUM7JI.js +0 -3
  467. package/dist/chunk-VWLIOEEF.js +0 -11
  468. package/dist/chunk-WK4FD4PG.js +0 -2
  469. package/dist/chunk-X434XZAI.js +0 -2
  470. package/dist/chunk-YIEFEPG6.js +0 -16
  471. package/dist/chunk-YRVERHJR.js +0 -49
  472. package/dist/chunk-ZD3Z54IW.js +0 -2
  473. package/dist/chunk-ZDVDSDFG.js +0 -4
  474. package/dist/code-EQL6ZBLH.js +0 -2
  475. package/dist/code-result-json-6E4J6LGZ.js +0 -2
  476. package/dist/command-descriptors-QH3G2OVD.js +0 -346
  477. package/dist/dataflow-2BLMUZBP.js +0 -2
  478. package/dist/dependence-slice-MGAJDZXB.js +0 -2
  479. package/dist/deps-GQMUYVKW.js +0 -2
  480. package/dist/direct-navigation-6RUJKLAV.js +0 -3
  481. package/dist/entry-map-V2NQP5JU.js +0 -2
  482. package/dist/files-VM53I4IU.js +0 -2
  483. package/dist/hierarchy-D553WRSZ.js +0 -2
  484. package/dist/imports-DOZAJWLW.js +0 -2
  485. package/dist/members-HE67475K.js +0 -2
  486. package/dist/methods-K5JK4PPH.js +0 -2
  487. package/dist/output-continuation-command-LKBUTNRL.js +0 -3
  488. package/dist/project-reindex-4ARU6QCM.js +0 -3
  489. package/dist/refs-NBHKL4UQ.js +0 -2
  490. package/dist/refs-pagination-BBVTIHMH.js +0 -2
  491. package/dist/slice-U6S6LBSB.js +0 -2
  492. package/dist/surface-C7SS5CDQ.js +0 -2
  493. package/dist/symbol-resolution-3FVEKDTJ.js +0 -2
  494. package/dist/system-6K2NOO5C.js +0 -2
  495. package/dist/trace-II5K2TMH.js +0 -2
  496. package/dist/value-flow-MKFUUE5B.js +0 -2
@@ -1,438 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createHash as ly}from"crypto";import{existsSync as uy,mkdirSync as dy}from"fs";import{dirname as kl,join as py}from"path";import ps from"better-sqlite3";function Et(e,t,n=[]){let r=ls(e);if(Il.has(r)||n.some(o=>di(r,o))||t.some(o=>El(r,o)))return"config";if(t.some(Rl)&&/\.d\.(?:ts|mts|cts)$/.test(r.toLowerCase()))return"ambient";let i=Pl(r);return t.some(o=>(wl[o]??[]).includes(i))?"source":"other"}function xl(e,t,n){let r=ls(e);if(Il.has(r)||n?.some(o=>di(r,o))||El(r,t)||Rl(t)&&/\.d\.(?:ts|mts|cts)$/.test(r.toLowerCase()))return!0;let i=Pl(r);return(wl[t]??[]).includes(i)}function vl(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.version!="number"||!yl(t.languages)||typeof t.pnpmWorkspaces!="boolean"||typeof t.typescriptProjectMode!="string"||!yl(t.typescriptProjects)||t.clojureConfigPath!==void 0&&typeof t.clojureConfigPath!="string"||!Array.isArray(t.files)||!t.files.every(cs)?null:t}function Ck(e,t){let n=new Map((e?.files??[]).map(a=>[a.path,a])),r=new Map(t.files.map(a=>[a.path,a])),i=new Set([...n.keys(),...r.keys()]),o=[];for(let a of[...i].sort()){let c=n.get(a),l=r.get(a),u=Et(a,t.languages);!c&&l?o.push({kind:"added",path:a,inputKind:u,after:l}):c&&!l?o.push({kind:"deleted",path:a,inputKind:u,before:c}):c&&l&&(c.hash!==l.hash||c.size!==l.size)&&o.push({kind:"modified",path:a,inputKind:u,before:c,after:l})}let s=new Set;return e||s.add("prior-snapshot-unavailable"),e&&e.version!==t.version&&s.add("snapshot-version-changed"),(hl(e?.files??[])||hl(t.files))&&s.add("duplicate-input-path"),[...e?.files??[],...t.files].some(Xg)&&s.add("unreadable-input"),{version:1,changes:o,projectIdentityChanged:e?!Yg(e,t):!0,uncertainty:[...s].sort()}}function yl(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function hl(e){return new Set(e.map(t=>t.path)).size!==e.length}function cs(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.path=="string"&&typeof t.size=="number"&&Number.isFinite(t.size)&&typeof t.hash=="string"}function Xg(e){return e.hash==="unreadable"||e.size<0}function Yg(e,t){return Sl(e.languages,t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&Sl(e.typescriptProjects,t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function Sl(e,t){if(e.length!==t.length)return!1;let n=[...e].sort(),r=[...t].sort();return n.every((i,o)=>i===r[o])}var Il=new Set([".scipquery.json"]),Qg={typescript:["tsconfig.json"],javascript:["package.json"],java:["pom.xml","build.gradle"],scala:["build.sbt"],kotlin:["build.gradle.kts"],rust:["Cargo.toml"],python:["pyproject.toml","setup.py"],ruby:["Gemfile"],go:["go.mod"],cpp:["CMakeLists.txt","Makefile"],c:["CMakeLists.txt","Makefile"],csharp:["*.csproj","*.sln"],vb:["*.vbproj","*.sln"],dart:["pubspec.yaml"],php:["composer.json"],clojure:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"]},Zg={typescript:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","tsconfig.*.json","jsconfig.json","jsconfig.*.json"],javascript:["package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","tsconfig.json","tsconfig.*.json","jsconfig.json","jsconfig.*.json"],java:["build.gradle.kts","settings.gradle","settings.gradle.kts","gradle.properties","gradle.lockfile","gradle-wrapper.properties"],scala:["plugins.sbt","build.properties"],kotlin:["pom.xml","build.gradle","settings.gradle","settings.gradle.kts","gradle.properties","gradle.lockfile","gradle-wrapper.properties"],rust:["Cargo.lock","rust-project.json","rust-toolchain","rust-toolchain.toml"],python:["setup.cfg","requirements*.txt","Pipfile","Pipfile.lock","poetry.lock","uv.lock"],ruby:["Gemfile.lock","gems.locked"],go:["go.sum","go.work","go.work.sum"],cpp:["compile_commands.json"],c:["compile_commands.json"],csharp:["Directory.Build.props","Directory.Build.targets","Directory.Packages.props","packages.lock.json","NuGet.Config","global.json"],vb:["Directory.Build.props","Directory.Build.targets","Directory.Packages.props","packages.lock.json","NuGet.Config","global.json"],dart:["pubspec.lock","analysis_options.yaml"],php:["composer.lock"],clojure:[]},bl=new Map;function El(e,t){return Qg[t].some(n=>di(e,n))||Zg[t].some(n=>di(e,n))}function di(e,t){let n=ls(t).replace(/^\.\//,"");if(!n)return!1;let r=e.split("/").at(-1)??e,i=n.includes("/")?e:r;if(!n.includes("*")&&!n.includes("?"))return i===n;let o=bl.get(n);if(!o){let s=n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]");o=new RegExp(`^${s}$`),bl.set(n,o)}return o.test(i)}function ls(e){return e.replaceAll("\\","/").replace(/^\.\//,"")}function Pl(e){return e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:""}function Rl(e){return e==="typescript"||e==="javascript"}var wl={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs",".vue"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"],clojure:[".clj",".cljs",".cljc"]};function Pt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function pi(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function x(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function Nk(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var ey=/^[a-f0-9]{64}$/u;function Tk(e){return typeof e=="string"&&ey.test(e)}function kk(e){return typeof e=="string"&&e.length>0&&e.length<=256&&!/[\0\r\n]/u.test(e)}function Cl(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}var fi=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"],Lk=["entry-surface","generated-code","compatibility-shim","reflection-or-registration","test-fixture","intentional-twin","historical-coupling-ended","detector-counterexample"];var us=2,Wt=3;var ds=new Set(fi);function Rt(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(s){return{kind:"malformed",reason:`invalid JSON: ${ay(s)}`}}if(!Pt(t))return{kind:"malformed",reason:"metadata must be a JSON object"};let n=t.version;if(!Number.isInteger(n))return{kind:"malformed",reason:"version must be an integer"};if(n!==us&&n!==Wt)return{kind:"unsupported",version:n,direction:n<us?"older":"future"};let r=ny(t,n);if(r)return{kind:"malformed",reason:r};let i=t,o={metadata:i,capabilities:ty(i)};return n===us?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function Bk(e){return e.kind==="legacy"||e.kind==="supported"?e.metadata:null}function Fl(e){if(e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.stableGenerationIdentity)return null;let t=e.metadata;return JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages,scipCompanion:t.scipCompanion,sqliteLayoutVersion:t.version===Wt?t.sqliteLayoutVersion:void 0})}function ty(e){let t=e.fingerprint!==void 0,n=Pt(e.fingerprint),r=e.indexedLanguages!==void 0,i=e.status==="complete",o=e.version===Wt?e:null;return{usableForQuery:r,usableForEvidenceCache:t,publishableGeneration:i&&n&&r,stableGenerationIdentity:i&&t&&typeof e.updatedAt=="string",languageShardReuse:!!o?.languageFingerprints,typescriptProjectShardReuse:!!o?.typescriptProjectShards}}function ny(e,t){if(e.status!=="complete"&&e.status!=="partial")return"status must be complete or partial";if(e.updatedAt!==void 0&&!pi(e.updatedAt))return"updatedAt must be a valid timestamp";for(let n of["requestedLanguages","indexedLanguages"])if(e[n]!==void 0&&!ry(e[n]))return`${n} must contain unique supported languages`;return e.skipped!==void 0&&!iy(e.skipped)?"skipped must contain supported language/reason pairs":e.scipCompanion!==void 0&&e.scipCompanion!=="current"&&e.scipCompanion!=="deferred"?"scipCompanion must be current or deferred":t===Wt&&e.sqliteLayoutVersion!==void 0&&(!Number.isSafeInteger(e.sqliteLayoutVersion)||e.sqliteLayoutVersion<1)?"sqliteLayoutVersion must be a positive safe integer":t===Wt&&e.languageFingerprints!==void 0&&!oy(e.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":t===Wt&&e.typescriptProjectShards!==void 0&&!sy(e.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function $k(e){return e.version===Wt&&e.sqliteLayoutVersion===1}function ry(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string"&&ds.has(t))?!1:new Set(e).size===e.length}function iy(e){return Array.isArray(e)&&e.every(t=>Pt(t)&&typeof t.language=="string"&&ds.has(t.language)&&typeof t.reason=="string")}function oy(e){return Pt(e)&&Object.entries(e).every(([t,n])=>ds.has(t)&&Pt(n))}function sy(e){return Pt(e)&&Object.values(e).every(t=>Pt(t)&&Array.isArray(t.files)&&t.files.every(cs))}function ay(e){return e instanceof Error?e.message:String(e)}var Nl=[];function En(e){e.groups.length>0&&Nl.push(e)}function Vk(e,t){let n=new Set(t.groups);for(let r of Nl)r.groups.some(i=>n.has(i))&&(t.file!==void 0&&r.clearFile?r.clearFile(e,t.file):r.clearAll(e))}function Tl(){let e=new WeakMap;return{cache:e,ensure(t){let n=e.get(t);return n||(n=new Map,e.set(t,n)),n}}}function C(e,t){let{cache:n,ensure:r}=Tl(),i={get(o,s,a){let c=r(o);if(c.has(s))return c.get(s);let l=a();return c.set(s,l),l},invalidate(o,s){n.get(o)?.delete(s)},invalidateAll(o){n.delete(o)},size(o){return n.get(o)?.size??0}};return En({name:e,groups:t.clearGroups,clearAll:o=>i.invalidateAll(o),clearFile:(o,s)=>i.invalidate(o,s)}),i}function He(e,t){let n=new WeakMap,r={get(i,o){let s=n.get(i);if(s)return s.value;let a=o();return n.set(i,{value:a}),a},invalidate(i){n.delete(i)},has(i){return n.has(i)}};return En({name:e,groups:t.clearGroups,clearAll:i=>r.invalidate(i)}),r}var cy={clearGroups:["whole-project","source-file"]};function wt(e){return zt(e,cy)}function zt(e,t){let{cache:n,ensure:r}=Tl(),i={get(o,s,a,c){let l=r(o),u=l.get(s);if(u&&u.source===a)return u.value;let d=c();return l.set(s,{source:a,value:d}),d},invalidate(o,s){n.get(o)?.delete(s)},invalidateAll(o){n.delete(o)}};return En({name:e,groups:t.clearGroups,clearAll:o=>i.invalidateAll(o),clearFile:(o,s)=>i.invalidate(o,s)}),i}var fy="evidence.db";var my=["source-facts","definition-exclusions","doc-path-tokens","react-component-behavior-profiles"],fs=new Set(my),gy=25e4,yy=512*1024*1024,hy=6e4,mi=new WeakMap,Sy=C("evidence-content-hash",{clearGroups:["whole-project","source-file"]}),by=C("evidence-project-fingerprint",{clearGroups:["whole-project"]}),be="evidence-v1",Pn="version NOT LIKE 'evidence-%'";function K(e){return ly("sha256").update(e).digest("hex")}function Ke(e,t,n){return Sy.get(e,t,()=>K(n))}function Ct(e){return by.get(e,"current",()=>{try{if(!e.generation.metadataRaw)return null;let t=Rt(e.generation.metadataRaw);if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.usableForEvidenceCache)return null;let n=t.metadata,r=[...n.indexedLanguages??[]].sort();return K(JSON.stringify({fingerprint:n.fingerprint,indexedLanguages:r,status:n.status}))}catch(t){return Ut("project fingerprint unavailable",t),null}})}function Ut(e,t){process.env.SCIP_QUERY_DEBUG&&console.error(`evidence-cache: ${e}: ${t instanceof Error?t.message:String(t)}`)}function ot(e){if(mi.has(e))return mi.get(e)??null;let t=null;try{let n=new ps(py(kl(e.config.dbPath),fy));n.pragma("journal_mode = WAL"),n.pragma("busy_timeout = 5000"),n.pragma("synchronous = NORMAL"),n.exec(`
3
- CREATE TABLE IF NOT EXISTS file_evidence (
4
- kind TEXT NOT NULL,
5
- relative_path TEXT NOT NULL,
6
- content_hash TEXT NOT NULL,
7
- version TEXT NOT NULL,
8
- payload TEXT NOT NULL,
9
- PRIMARY KEY (kind, relative_path)
10
- );
11
- CREATE TABLE IF NOT EXISTS project_evidence (
12
- kind TEXT NOT NULL,
13
- cache_key TEXT NOT NULL,
14
- project_fingerprint TEXT NOT NULL,
15
- version TEXT NOT NULL,
16
- payload TEXT NOT NULL,
17
- PRIMARY KEY (kind, cache_key)
18
- );
19
- CREATE TABLE IF NOT EXISTS semantic_callees (
20
- relative_path TEXT NOT NULL,
21
- symbol TEXT NOT NULL,
22
- content_hash TEXT NOT NULL,
23
- deps_digest TEXT NOT NULL,
24
- version TEXT NOT NULL,
25
- payload TEXT NOT NULL,
26
- PRIMARY KEY (relative_path, symbol)
27
- );
28
- CREATE TABLE IF NOT EXISTS semantic_references (
29
- relative_path TEXT NOT NULL,
30
- symbol TEXT NOT NULL,
31
- project_fingerprint TEXT NOT NULL,
32
- version TEXT NOT NULL,
33
- payload TEXT NOT NULL,
34
- PRIMARY KEY (relative_path, symbol)
35
- );
36
- `),t={evidence:n,shared:xy(e.config.sharedEvidenceDbPath),readFileEvidence:n.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),readLegacyFileEvidence:n.prepare(`SELECT payload FROM file_evidence
37
- WHERE kind = ? AND relative_path = ? AND content_hash = ? AND ${Pn}
38
- ORDER BY version DESC
39
- LIMIT 1`),writeFileEvidence:n.prepare("INSERT OR REPLACE INTO file_evidence (kind, relative_path, content_hash, version, payload) VALUES (?, ?, ?, ?, ?)"),readProjectEvidence:n.prepare("SELECT payload FROM project_evidence WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND version = ?"),readLegacyProjectEvidence:n.prepare(`SELECT payload FROM project_evidence
40
- WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND ${Pn}
41
- ORDER BY version DESC
42
- LIMIT 1`),writeProjectEvidence:n.prepare("INSERT OR REPLACE INTO project_evidence (kind, cache_key, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)"),readCallees:n.prepare(`SELECT payload FROM semantic_callees
43
- WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCallees:n.prepare(`SELECT payload FROM semantic_callees
44
- WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND ${Pn}
45
- ORDER BY version DESC
46
- LIMIT 1`),readCalleesForFile:n.prepare(`SELECT symbol, payload FROM semantic_callees
47
- WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCalleesForFile:n.prepare(`SELECT symbol, payload FROM semantic_callees
48
- WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND ${Pn}
49
- ORDER BY symbol, version DESC`),writeCallees:n.prepare(`INSERT OR REPLACE INTO semantic_callees
50
- (relative_path, symbol, content_hash, deps_digest, version, payload) VALUES (?, ?, ?, ?, ?, ?)`),dropStaleCallees:n.prepare("DELETE FROM semantic_callees WHERE relative_path = ? AND content_hash != ?"),readReferences:n.prepare(`SELECT payload FROM semantic_references
51
- WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferences:n.prepare(`SELECT payload FROM semantic_references
52
- WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND ${Pn}
53
- ORDER BY version DESC
54
- LIMIT 1`),readReferencesForFile:n.prepare(`SELECT symbol, payload FROM semantic_references
55
- WHERE relative_path = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferencesForFile:n.prepare(`SELECT symbol, payload FROM semantic_references
56
- WHERE relative_path = ? AND project_fingerprint = ? AND ${Pn}
57
- ORDER BY symbol, version DESC`),writeReferences:n.prepare(`INSERT OR REPLACE INTO semantic_references
58
- (relative_path, symbol, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)`),dropStaleReferences:n.prepare("DELETE FROM semantic_references WHERE relative_path = ? AND project_fingerprint != ?")}}catch(n){Ut("disabled (open failed)",n)}return mi.set(e,t),t}function st(e,t,n){Ut(`disabled (${t})`,n),mi.set(e,null)}function xy(e){if(!e)return null;try{dy(kl(e),{recursive:!0});let t=new ps(e);return t.pragma("journal_mode = WAL"),t.pragma("busy_timeout = 250"),t.pragma("synchronous = NORMAL"),t.exec(`
59
- CREATE TABLE IF NOT EXISTS file_evidence (
60
- kind TEXT NOT NULL,
61
- relative_path TEXT NOT NULL,
62
- content_hash TEXT NOT NULL,
63
- version TEXT NOT NULL,
64
- payload TEXT NOT NULL,
65
- last_accessed_at INTEGER NOT NULL,
66
- PRIMARY KEY (kind, relative_path, content_hash, version)
67
- );
68
- CREATE INDEX IF NOT EXISTS idx_file_evidence_lru
69
- ON file_evidence(last_accessed_at, kind, relative_path, content_hash, version);
70
- `),{evidence:t,readFileEvidence:t.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),writeFileEvidence:t.prepare(`INSERT INTO file_evidence (kind, relative_path, content_hash, version, payload, last_accessed_at)
71
- VALUES (?, ?, ?, ?, ?, ?)
72
- ON CONFLICT(kind, relative_path, content_hash, version)
73
- DO UPDATE SET payload = excluded.payload, last_accessed_at = excluded.last_accessed_at`),touchFileEvidence:t.prepare(`UPDATE file_evidence
74
- SET last_accessed_at = ?
75
- WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?
76
- AND last_accessed_at < ?`)}}catch(t){return Ut("shared cache disabled (open failed)",t),null}}function ms(e,t,n){Ut(`shared cache disabled (${t})`,n);try{e.shared?.evidence.close()}catch{}e.shared=null}function Qk(e,t={}){if(!uy(e))return null;let n;try{n=new ps(e),n.pragma("busy_timeout = 50"),n.exec(`CREATE INDEX IF NOT EXISTS idx_file_evidence_lru
77
- ON file_evidence(last_accessed_at, kind, relative_path, content_hash, version)`),n.pragma("wal_checkpoint(TRUNCATE)");let r=n.prepare("SELECT COUNT(*) AS count FROM file_evidence").get().count,i=t.maxRows??gy,o=t.budgetBytes??yy,s=Number(n.pragma("page_size",{simple:!0})),a=Number(n.pragma("page_count",{simple:!0})),c=Number(n.pragma("freelist_count",{simple:!0})),l=Math.max(0,a-c)*s,u=r>0&&l>o?Math.min(r,Math.ceil((l-o)/Math.max(1,l/r))):0,d=Math.max(r-i,u);return d>0&&(n.prepare(`DELETE FROM file_evidence WHERE rowid IN (
78
- SELECT rowid FROM file_evidence ORDER BY last_accessed_at ASC, rowid ASC LIMIT ?
79
- )`).run(d),n.pragma("wal_checkpoint(TRUNCATE)")),{deletedRows:d,remainingRows:r-d}}catch(r){return Ut("shared cache maintenance skipped",r),null}finally{try{n?.close()}catch{}}}function _l(e,t,n,r){let i=ot(e);if(!i)return null;try{let o=i.readFileEvidence.get(t,n,r,be)??i.readLegacyFileEvidence.get(t,n,r);if(o?.payload!==void 0)return o.payload;if(!fs.has(t)||!i.shared)return null;try{let s=i.shared.readFileEvidence.get(t,n,r,be);return s?.payload!==void 0&&vy(i.shared,t,n,r),s?.payload??null}catch(s){return ms(i,"file_evidence read",s),null}}catch(o){return st(e,"file_evidence read",o),null}}function vy(e,t,n,r){let i=Date.now();try{e.touchFileEvidence.run(i,t,n,r,be,i-hy)}catch(o){Ut("shared file_evidence recency touch skipped",o)}}function Ll(e,t,n,r,i){let o=ot(e);if(o)try{if(o.writeFileEvidence.run(t,n,r,be,i),fs.has(t)&&o.shared)try{o.shared.writeFileEvidence.run(t,n,r,be,i,Date.now())}catch(s){ms(o,"file_evidence write",s)}}catch(s){st(e,"file_evidence write",s)}}function Dl(e,t){if(t.length===0)return;let n=ot(e);if(n)try{n.evidence.transaction(()=>{for(let i of t)n.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,be,i.payload)})();let r=t.filter(i=>fs.has(i.kind));if(r.length>0&&n.shared)try{n.shared.evidence.transaction(()=>{for(let i of r)n.shared.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,be,i.payload,Date.now())})()}catch(i){ms(n,"file_evidence batch write",i)}}catch(r){st(e,"file_evidence batch write",r)}}function Al(e,t,n,r){let i=ot(e);if(!i)return null;try{return(i.readProjectEvidence.get(t,n,r,be)??i.readLegacyProjectEvidence.get(t,n,r))?.payload??null}catch(o){return st(e,"project_evidence read",o),null}}function Ol(e,t,n,r,i){let o=ot(e);if(o)try{o.writeProjectEvidence.run(t,n,r,be,i)}catch(s){st(e,"project_evidence write",s)}}function Zk(e,t,n,r){let i=ot(e);if(!i)return new Map;try{let o=i.readCalleesForFile.all(t,n,r,be),s=i.readLegacyCalleesForFile.all(t,n,r);return Ml([...s,...o])}catch(o){return st(e,"semantic_callees bulk read",o),new Map}}function e_(e,t,n){let r=ot(e);if(!r)return new Map;try{let i=r.readReferencesForFile.all(t,n,be),o=r.readLegacyReferencesForFile.all(t,n);return Ml([...o,...i])}catch(i){return st(e,"semantic_references bulk read",i),new Map}}function Ml(e){let t=new Map;for(let n of e)t.set(n.symbol,n.payload);return t}function t_(e,t){if(t.length===0)return;let n=ot(e);if(n)try{n.evidence.transaction(()=>{let r=new Set;for(let i of t){let o=`${i.relativePath}\0${i.contentHash}`;r.has(o)||(r.add(o),n.dropStaleCallees.run(i.relativePath,i.contentHash)),n.writeCallees.run(i.relativePath,i.symbol,i.contentHash,i.depsDigest,be,i.payload)}})()}catch(r){st(e,"semantic_callees write",r)}}function n_(e,t){if(t.length===0)return;let n=ot(e);if(n)try{n.evidence.transaction(()=>{let r=new Set;for(let i of t){let o=`${i.relativePath}\0${i.projectFingerprint}`;r.has(o)||(r.add(o),n.dropStaleReferences.run(i.relativePath,i.projectFingerprint)),n.writeReferences.run(i.relativePath,i.symbol,i.projectFingerprint,be,i.payload)}})()}catch(r){st(e,"semantic_references write",r)}}import{appendFileSync as Iy,mkdirSync as Ey}from"fs";import{createHash as Py,randomUUID as Ry}from"crypto";import{dirname as wy}from"path";import{performance as Rn}from"perf_hooks";var Gl="SCIP_QUERY_PROFILE",Vl="SCIP_QUERY_PROFILE_OUT",ql="SCIP_QUERY_PROFILE_COMMAND",Wl="SCIP_QUERY_PROFILE_CACHE_STATE",gs="SCIP_QUERY_PROFILE_RUN_ID",ys="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY",hs="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND",zl=[Gl,Vl,ql,Wl,gs,ys,hs],c_=new Set(zl),jl=new Set,Bl=new Map,$l=!1;function Ft(){let e=process.env[Gl];return e==="1"||e==="true"}function Cy(){return process.env[Vl]}function Ul(){return process.env[ql]}function Fy(){return process.env[Wl]}function Hl(){let e=process.env[gs];if(e)return e;if(!Ft())return;let t=Ry();return process.env[gs]=t,t}function Kl(){return process.env[ys]}function Ny(e){let t=Kl();if(t)return t;if(!Ft())return;let n=Hl();if(!n)return;let r=e.projectFingerprint?"published-project":"run-only",i=cr(["profile-workload-v1",e.toolVersion,e.command,e.projectFingerprint??n]);return process.env[ys]=i,process.env[hs]=r,i}function cr(e){return Py("sha256").update(JSON.stringify(e)).digest("hex").slice(0,24)}function l_(){return Object.fromEntries(zl.flatMap(e=>{let t=process.env[e];return t===void 0?[]:[[e,t]]}))}function ae(e,t,n){if(!Ft())return t();let r=Rn.now();try{let i=t();return gi({type:"span",name:e,durationMs:Math.round(Rn.now()-r),ok:!0,...yi(n)??{}}),i}catch(i){throw gi({type:"span",name:e,durationMs:Math.round(Rn.now()-r),ok:!1,error:i instanceof Error?i.message:String(i),...yi(n)??{}}),i}}async function u_(e,t,n){if(!Ft())return t();let r=Rn.now();try{let i=await t();return gi({type:"span",name:e,durationMs:Math.round(Rn.now()-r),ok:!0,...yi(n)??{}}),i}catch(i){throw gi({type:"span",name:e,durationMs:Math.round(Rn.now()-r),ok:!1,error:i instanceof Error?i.message:String(i),...yi(n)??{}}),i}}function gi(e,t=Cy()){let n=Ty(e),r={timestamp:new Date().toISOString(),pid:process.pid,runId:Hl(),command:Ul(),cacheState:Fy(),...n,...e},i=`${JSON.stringify(r)}
80
- `;if(t)try{let o=wy(t);jl.has(o)||(Ey(o,{recursive:!0}),jl.add(o)),Iy(t,i);return}catch(o){$l||($l=!0,process.stderr.write(`[profile] failed to write ${t}: ${o instanceof Error?o.message:String(o)}
81
- `));return}Ft()&&process.stderr.write(i)}function Ty(e){let t=Kl()??Ny({command:Ul()??"unknown",toolVersion:"unknown",projectFingerprint:null});if(!t)return{};let n=process.env[hs],r=typeof e.name=="string"?e.name:void 0;if(!r)return{workloadIdentity:t,workloadIdentityKind:n};let i=r.split(/[.:]/,1)[0]??r,o=`${t}\0${r}`,s=Bl.get(o);return s||(s=cr(["profile-subsystem-v1",t,r]),Bl.set(o,s)),{workloadIdentity:t,workloadIdentityKind:n,subsystem:i,subsystemWorkIdentity:s}}function yi(e){return typeof e=="function"?e():e}var Jl=Symbol.for("scip-query.project-file-listing-context.v1"),Xl=globalThis,Ss=Xl[Jl],M=Ss&&typeof Ss=="object"?Ss:{};Xl[Jl]=M;function p_(e){if(M.active)return e();let t=M.active,n=M.canonicalProjectRoots;M.active=new Map,M.canonicalProjectRoots=new Map;try{return e()}finally{M.active=t,M.canonicalProjectRoots=n}}function f_(){let e=M.active,t=M.canonicalProjectRoots;M.active=new Map,M.canonicalProjectRoots=new Map;let n=!1;return()=>{n||(n=!0,M.active=e,M.canonicalProjectRoots=t)}}function Yl(e,t){let n=M.active?M.canonicalProjectRoots:void 0,r=n?.get(e);if(r!==void 0)return r;let i=t();return n?.set(e,i),i}function Ql(){return M.sequence??0}function hi(e,t,n){let r=M.active,i=r?.get(e);if(i&&i.pathBytes<=t)return i;let o=ky(n(),(M.sequence??0)+1);if(M.sequence=o.sequence,o.pathBytes>t)throw new RangeError(`Git project file listing exceeded ${t} path bytes.`);return r?.set(e,o),o}function Zl(e,t){let n=M.active?.get(e);return n&&n.sequence>t?n.indexAllowsTreeFingerprintReuse:void 0}function*Si(e){let t=0;for(;t<e.taggedOutput.length;){let n=e.taggedOutput.indexOf("\0",t);if(n<0)return;yield e.taggedOutput.slice(t+2,n),t=n+1}}function ky(e,t){let n=0,r=0,i=!0;for(;n<e.length;){let o=e.indexOf("\0",n);if(o<0||o<=n+2||e[n+1]!==" ")throw new Error("Git returned a malformed tagged project file listing.");let s=e[n];i&&=s==="H"||s==="?",r+=1,n=o+1}return{taggedOutput:e,pathBytes:Buffer.byteLength(e,"utf8")-r*2,indexAllowsTreeFingerprintReuse:i,sequence:t}}import{createRequire as _y}from"module";var Ly=_y(import.meta.url),bi=Dy().version;function Dy(){for(let e of["../package.json","../../package.json"])try{return Ly(e)}catch{}return{version:"0.0.0"}}import{basename as eu}from"path";var Ay=C("indexed-document-paths",{clearGroups:["whole-project"]});function xe(e,t={}){let n=Oy(t);return[...Ay.get(e,n,()=>{let i=t.scope?"AND relative_path LIKE ?":"",o=t.like?"AND relative_path LIKE ?":"",s=[...t.scope?[`%${t.scope}%`]:[],...t.like?[t.like]:[]],a=e.all(`SELECT relative_path
82
- FROM documents
83
- WHERE 1 = 1
84
- ${e.pathExclusionsFor("documents")}
85
- ${i}
86
- ${o}
87
- ORDER BY relative_path`,...s).map(l=>l.relative_path),c=t.extensions?a.filter(l=>t.extensions.some(u=>l.toLowerCase().endsWith(u.toLowerCase()))):a;return t.includeIgnored===!1?c.filter(l=>!e.isIgnored(l)):c})]}function Oy(e){let t=e.extensions?[...new Set(e.extensions.map(n=>n.toLowerCase()))].sort():null;return JSON.stringify({scope:e.scope??null,like:e.like??null,extensions:t,includeIgnored:e.includeIgnored!==!1})}function nu(e,t,n){let r=ru(t);if(!r)return[];let i=e.all(`SELECT relative_path
88
- FROM documents
89
- WHERE relative_path = ?
90
- ${e.pathExclusionsFor("documents")}`,r).filter(c=>!e.isIgnored(c.relative_path)).map(c=>({relativePath:c.relative_path,score:tu(c.relative_path,r)}));if(i.length>0)return i;let o=xe(e,{includeIgnored:!1}).map(c=>({relativePath:c,score:tu(c,r)})).filter(c=>c.score>0).sort((c,l)=>l.score-c.score||c.relativePath.localeCompare(l.relativePath)),s=o.filter(c=>c.score>=1100);if(s.length>0)return n.allowMultiple?s:[s[0]];if(n.requirePathMatch)return[];let a=o.filter(c=>c.score>=800);return a.length>0?n.allowMultiple?a:[a[0]]:n.allowMultiple?o:o.slice(0,1)}function tu(e,t){let n=ru(e),r=eu(n),i=eu(t),o=0;return n===t&&(o+=1200),n.endsWith(`/${t}`)&&(o+=1100),r===i&&(o+=900),n.startsWith(`${t}/`)&&(o+=850),n.includes(t)&&(o+=250),o}function ru(e){return e.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}import{isAbsolute as iu,relative as My}from"path";var $=class extends Error{constructor(n,r){super(`refusing unsafe project file path ${JSON.stringify(n)} (${r})`);this.relativePath=n;this.reason=r;this.name="UnsafeProjectPathError"}relativePath;reason;code="SCIP_QUERY_UNSAFE_PROJECT_PATH"};function Nt(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function Y(e){return e.replace(/\\/g,"/")}function Ht(e,t){return Nt(e)===Nt(t)}function Fe(e,t){let n=My(e,t);return n===""||!n.startsWith("..")&&!iu(n)}function ve(e){if(!e)throw new $(e,"empty-path");if(e.includes("\0"))throw new $(e,"nul-byte");if(iu(e)||/^[A-Za-z]:/.test(e)||e.startsWith("//")||e.startsWith("\\\\"))throw new $(e,"absolute-path");let t=Nt(e);if(t.split("/").some(r=>r===".."))throw new $(e,"parent-traversal");if(!t||t===".")throw new $(e,"empty-path");return t}import{closeSync as bs,fstatSync as xi,openSync as xs,readFileSync as jy,readSync as ou}from"fs";import{createHash as By}from"crypto";var Q=8*1024*1024,Kt=64*1024*1024,pe=512*1024*1024,$y=256*1024*1024,Je=class extends Error{constructor(n,r,i,o,s){let a=i==="too-large"?`is ${o} bytes; the safety limit is ${s} bytes`:i==="not-regular"?"is not a regular file":"changed while it was being read";super(`${n} ${JSON.stringify(r)} ${a}`);this.inputKind=n;this.inputPath=r;this.reason=i;this.observedBytes=o;this.limitBytes=s;this.name="BoundedFileReadError"}inputKind;inputPath;reason;observedBytes;limitBytes;code="SCIP_QUERY_BOUNDED_FILE_READ"};function J(e,t){Xt(t.maxBytes);let n=String(e),r=xs(e,"r");try{let i=xi(r);au(i,t,n);let o=jy(r),s=xi(r);if(s.dev!==i.dev||s.ino!==i.ino||s.size!==i.size||o.byteLength!==i.size)throw new Je(t.inputKind,n,"changed-during-read",s.size,t.maxBytes);return o}finally{bs(r)}}function j(e,t,n="utf8"){return J(e,t).toString(n)}function F(e,t){return j(e,{maxBytes:Q,inputKind:t})}function Gy(e,t){return j(e,{maxBytes:Kt,inputKind:t})}function vs(e,t){Xt(t.maxBytes);let n=[],r=Buffer.allocUnsafe(64*1024),i=0;for(;;){let o=ou(e,r,0,r.length,null);if(o===0)break;if(i+=o,!Number.isSafeInteger(i)||i>t.maxBytes)throw new Je(t.inputKind,`file descriptor ${e}`,"too-large",i,t.maxBytes);n.push(Buffer.from(r.subarray(0,o)))}return Buffer.concat(n,i)}function Vy(e,t,n="utf8"){return vs(e,t).toString(n)}function su(e,t){let n=xs(e,"r");try{return vs(n,t)}finally{bs(n)}}function Is(e,t,n="utf8"){return su(e,t).toString(n)}function wn(e,t,n){Xt(t.maxBytes);let r=String(e),i=xs(e,"r");try{let o=xi(i);au(o,t,r);let s=Buffer.allocUnsafe(Math.min(1024*1024,Math.max(1,o.size))),a=0;for(;a<o.size;){let l=ou(i,s,0,Math.min(s.length,o.size-a),a);if(l===0)break;n(s.subarray(0,l)),a+=l}let c=xi(i);if(c.dev!==o.dev||c.ino!==o.ino||c.size!==o.size||a!==o.size)throw new Je(t.inputKind,r,"changed-during-read",c.size,t.maxBytes);return a}finally{bs(i)}}function Jt(e,t){let n=By("sha256");return wn(e,t,r=>n.update(r)),n.digest("hex")}function au(e,t,n){if(!e.isFile())throw new Je(t.inputKind,n,"not-regular",Number(e.size),t.maxBytes);if(e.size>t.maxBytes)throw new Je(t.inputKind,n,"too-large",Number(e.size),t.maxBytes)}function Xt(e){if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`maxBytes must be a non-negative safe integer; received ${e}`)}var qy=[fe("source-facts",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/source-facts.ts"}),fe("file-definitions",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/symbols/definition-catalog.ts"}),fe("definition-exclusions",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/framework-patterns.ts"}),fe("doc-path-tokens",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-products.test.ts",owner:"tests/storage/evidence-cache.test.ts"}),fe("doc-path-evidence",{dependsOn:["content-hash","git-history","git-head","tool-version"],keyParts:["kind","relativePath","contentHash","trackedFiles","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/cleanup/doc-drift.ts"}),fe("source-imports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),fe("source-reexports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),fe("source-fingerprints",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/definition-catalog.test.ts",owner:"src/queries/cleanup/similar.ts"}),fe("consumer-file-usage",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/internal/consumer-evidence.ts"}),fe("react-component-behavior-profiles",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/react-profile.ts"}),fe("git-file-adds",{dependsOn:["git-head","git-history","tool-version"],keyParts:["kind","cacheKey","head","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/git-history.ts"}),fe("typescript-reference-fragments",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-reference-fragments.test.ts",owner:"src/semantic/typescript/reference-fragment-shadow.ts"}),fe("typescript-import-usage",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),fe("typescript-signatures",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),vi("file-dependency-graph",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","scope","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/file-dep-graph.test.ts",owner:"src/symbols/graph/file-dep-graph.ts"}),vi("semantic-import-usage",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","relativePath","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),vi("semantic-signatures",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","symbol","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),vi("health-semantic-prewarm",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","scope","cliVersion","projectFingerprint","payloadVersion"],stalenessTest:"tests/runtime/cli-support.test.ts",owner:"src/runtime/cli-support.ts"})];function $e(e){let t=new Map;return{kind:e.kind,read(n,r,i){let o=!1,s=0,a;if(Ft()){let c=Ct(n);if(c){let l=`${c}\0${r}\0${i}`;a=t.get(l),a||(a=cr(["evidence-product-file-read-v1",e.kind,c,r,i]),t.set(l,a))}}return ae("evidence-product.file.read",()=>{let c=_l(n,e.kind,r,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"file",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(n,r,i,o){Ll(n,e.kind,r,i,e.serialize(o))},writeBatch(n,r){Dl(n,r.map(i=>({kind:e.kind,relativePath:i.relativePath,contentHash:i.contentHash,payload:e.serialize(i.value)})))}}}function cu(e){let t=new Map;return{kind:e.kind,read(n,r,i){let o=!1,s=0,a;if(Ft()){let c=`${i}\0${r}`;a=t.get(c),a||(a=cr(["evidence-product-project-read-v1",e.kind,i,r]),t.set(c,a))}return ae("evidence-product.project.read",()=>{let c=Al(n,e.kind,r,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"project",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(n,r,i,o){Ol(n,e.kind,r,i,e.serialize(o))}}}function Ie(e){let t=qy.find(n=>n.kind===e);if(!t)throw new Error(`missing evidence product manifest entry for ${e}`);return t.invalidation}function fe(e,t){return{scope:"file",kind:e,invalidation:{scope:"file",...t}}}function vi(e,t){return{scope:"project",kind:e,invalidation:{scope:"project",...t}}}import{spawnSync as Wy}from"child_process";import{createHash as zy}from"crypto";import{existsSync as Uy,lstatSync as Ei,realpathSync as Hy}from"fs";import{dirname as Ky,isAbsolute as uu,join as Rs,relative as Jy,resolve as Yt,sep as Xy}from"path";var Ge={run(e,t){let n=lu(e,t);return n.kind==="success"?n.output:void 0},runResult:lu},Yy=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],ws=["status","--porcelain=v2","--branch","-z","--untracked-files=all"],Cn=/^[0-9a-f]{40,64}$/;function B_(e,t,n=Ge){if(!t||t.startsWith("-")||/[\0\r\n]/.test(t))throw new Error(`Invalid Git revision ${JSON.stringify(t)}.`);let r=n.runResult(e,["rev-parse","--verify","--end-of-options",`${t}^{commit}`]);if(r.kind!=="success"||!Cn.test(r.output))throw new Error(`Git revision ${JSON.stringify(t)} does not resolve to exactly one commit.`);return r.output}function ur(e,t=Ge){return Qy(e,t)?.context}function Qy(e,t=Ge){let n=t.runResult(e,Yy);if(n.kind==="success"){let i=eh(n.output);if(i){let o=th(i,t);if(o)return Es(o)}}let r=nh(e,t);return r?Es(r):void 0}function Zy(e,t=Ge){if(!e.headCommit)return;let n=t.run(e.projectRoot,ws);if(n===void 0)return;let r=Cs(n);if(!(!r?.headCommit||r.headCommit!==e.headCommit))return{...e,clean:r.clean}}function $_(e,t,n=Ge){if(!t.headCommit||!t.treeOid||!Cn.test(t.headCommit)||!Cn.test(t.treeOid)||n===Ge&&!ch()||!ih(e,t))return;let r=Zy({projectRoot:t.projectRoot,gitDir:t.gitDir,commonDir:t.commonDir,repositoryId:t.repositoryId,worktreeId:t.worktreeId,headCommit:t.headCommit,treeOid:t.treeOid,clean:!0},n);return r?Es(r):void 0}function G_(e,t=Ge,n={}){let r=t===Ge&&n.cachedInventoryAfterSequence!==void 0?Zl(e,n.cachedInventoryAfterSequence):void 0;if(r!==void 0)return r;let i=t.run(e,["ls-files","-v","-z"]);return i===void 0?!1:i.split("\0").filter(Boolean).every(o=>o.startsWith("H "))}function Es(e){return{context:e,projectFileInventorySequence:Ql()}}function Cs(e){let t=e.split("\0").filter(Boolean),n=t.find(i=>i.startsWith("# branch.oid "))?.slice(13),r=n==="(initial)"?void 0:n;if(!(r!==void 0&&!Cn.test(r))&&n!==void 0)return{headCommit:r,clean:t.every(i=>i.startsWith("# "))}}function eh(e){let t=e.split(`
91
- `).map(c=>c.trim());if(t.length!==5)return;let[n,r,i,o,s]=t;if(!n||!r||!i||!o||!s||!Cn.test(o)||!Cn.test(s))return;let a=me(n);return{root:a,gitDir:me(Ii(a,r)),commonDir:me(Ii(a,i)),headCommit:o,treeOid:s}}function th(e,t){let n=t.run(e.root,ws);if(n===void 0)return;let r=Cs(n);return r?.headCommit!==e.headCommit?void 0:{...du(e.root,e.gitDir),commonDir:e.commonDir,repositoryId:lr("repository",e.commonDir),headCommit:e.headCommit,treeOid:e.treeOid,clean:r.clean}}function nh(e,t){let n=rh(e,t);if(n.kind!=="worktree")return;let r=n.identity,i=r.projectRoot,o=t.run(i,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=me(Ii(i,o)),a=Ps(t.run(i,["rev-parse","--verify","HEAD"])),c=Ps(t.run(i,["rev-parse","--verify","HEAD^{tree}"])),l=t.run(i,ws);if(l===void 0)return;let u=Cs(l);if(!(!u||u.headCommit!==a))return{...r,commonDir:s,repositoryId:lr("repository",s),headCommit:a,treeOid:c,clean:u.clean}}function rh(e,t=Ge){let n=t.runResult(e,["rev-parse","--show-toplevel"]);if(n.kind==="not-repository")return{kind:"non-git"};if(n.kind==="error")return n;let r=n.output.trim();if(!r)return{kind:"error",message:"Git returned an empty worktree root."};let i=me(r),o=t.run(i,["rev-parse","--absolute-git-dir"])?.trim();if(!o)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=me(Ii(i,o));return{kind:"worktree",identity:du(i,s)}}function du(e,t){return{projectRoot:e,gitDir:t,worktreeId:lr("worktree",`${e}\0${t}`)}}function ih(e,t){try{let n=me(t.projectRoot),r=Yt(e)===n?n:me(e);if(t.projectRoot!==n||!ah(n,r))return!1;let i=Rs(n,".git"),o=Ei(i);if(o.isSymbolicLink())return!1;let s=o.isDirectory()?me(i):o.isFile()?oh(i,n,o):void 0;if(!s||s!==t.gitDir)return!1;let a=sh(s);return!a||a!==t.commonDir?!1:t.worktreeId===lr("worktree",`${n}\0${s}`)&&t.repositoryId===lr("repository",a)}catch{return!1}}function oh(e,t,n){let r=pu(e,"gitdir: ",n);return r?me(Yt(t,r)):void 0}function sh(e){let t=Rs(e,"commondir");try{let n=Ei(t);if(n.isSymbolicLink()||!n.isFile())return;let r=pu(t,"",n);return r?me(Yt(e,r)):void 0}catch(n){let r=n.code;return r==="ENOENT"||r==="ENOTDIR"?e:void 0}}function pu(e,t="",n=Ei(e)){if(!n.isFile()||n.isSymbolicLink()||n.size>4*1024)return;let r=j(e,{inputKind:"Git control path",maxBytes:4*1024}).split(/\r?\n/).filter(o=>o.length>0);if(r.length!==1||!r[0].startsWith(t))return;let i=r[0].slice(t.length);return i&&!i.includes("\0")?i:void 0}function ah(e,t){let n=Jy(e,t);return n===""||!n.startsWith(`..${Xy}`)&&n!==".."&&!uu(n)}function ch(e=process.env){return!(["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_NAMESPACE","GIT_REPLACE_REF_BASE","GIT_NO_REPLACE_OBJECTS","GIT_SHALLOW_FILE","GIT_GRAFT_FILE"].some(n=>e[n]!==void 0)||Object.keys(e).some(n=>n.startsWith("GIT_CONFIG_")))}function fu(e,t=Ge){let n=t.run(e,["worktree","list","--porcelain","-z"]);return n===void 0?[]:lh(n)}function lh(e){let t=[],n;for(let r of e.split("\0")){if(r===""){n&&t.push(n),n=void 0;continue}let i=r.indexOf(" "),o=i<0?r:r.slice(0,i),s=i<0?"":r.slice(i+1);if(o==="worktree"){n&&t.push(n),n={path:me(s),detached:!1,bare:!1,prunable:!1,locked:!1};continue}n&&(o==="HEAD"?n.head=s:o==="branch"?n.branch=s:o==="detached"?n.detached=!0:o==="bare"?n.bare=!0:o==="prunable"?n.prunable=!0:o==="locked"&&(n.locked=!0))}return n&&t.push(n),t}function V_(e,t,n=Ge){return Ps(n.run(e,t))}function Ii(e,t){return uu(t)?t:Yt(e,t)}function me(e){try{return Hy(e)}catch{return Yt(e)}}function lr(e,t){return zy("sha256").update(`${e}\0${t}`).digest("hex").slice(0,24)}function Ps(e){return e?.trim()||void 0}function lu(e,t){let n=Wy("git",["-C",e,...t],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"],timeout:3e4,killSignal:"SIGKILL"});if(n.status===0)return{kind:"success",output:n.stdout.trimEnd()};let i=(typeof n.stderr=="string"?n.stderr.trim():"")||n.error?.message||`git exited with status ${n.status??"unknown"}`,o=n.error?.code;return(/not a git repository/i.test(i)||o==="ENOENT"&&Uy(Yt(e)))&&!uh(e)?{kind:"not-repository"}:{kind:"error",message:i}}function uh(e){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let t=Yt(e);for(;;){try{return Ei(Rs(t,".git")),!0}catch(r){let i=r.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let n=Ky(t);if(n===t)return!1;t=n}}import{createRequire as fh}from"module";import{existsSync as mh,lstatSync as gu,readdirSync as gh,statSync as yh}from"fs";import N from"path";import{AsyncLocalStorage as dh}from"async_hooks";var ph=new dh;function Qt(e,t){let n=Pi(e);if(!n||n.missing.has(t))return;let r=n.files.get(t);if(r)return r;let i=n.readBaseFile?.(t);return i&&n.files.set(t,i),i}function Zt(e,t){let n=Pi(e);if(n)return n.missing.has(t)?"missing":n.paths.includes(t)?"present":"missing"}function mu(e,t){return Pi(e)?.fingerprints.get(t)}function en(e){return Pi(e)?.paths}function Pi(e){let t=ph.getStore();if(t)return t.projectRoot===me(e)?t:void 0}var hh=fh(import.meta.url),yu=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function xu(e,t=[]){let n=N.resolve(e),r=t.flatMap(c=>bh(n,c));if(r.length>0)return hu(n,bu(r));let i=Sh(n),o=bu(i),s=xh(n,o)?[n,...o]:o,a=s.length>0?s:[n];return hu(n,a)}function vu(e,t,n=[]){let r;try{r=hh("@ts-morph/common/dist/typescript.js")}catch{return null}let i=N.resolve(e),o=t==="workspace"?xu(i,n):["."],s=new Set;for(let a of o){let c=a==="."?i:N.join(i,a),l=N.join(c,"tsconfig.json"),u=Ih(r,i);if(!u.fileExists(l))return null;let d=r.readConfigFile(l,u.readFile);if(d.error)return null;let p=r.parseJsonConfigFileContent(d.config,u,c);if(p.errors.length>0)return null;for(let f of p.fileNames){let m=N.resolve(f);Fe(i,m)&&s.add(N.relative(i,m).split(N.sep).join("/"))}}return s}function Z_(e,t,n,r){let i=N.resolve(e),o=new Set(r);for(let a of n){let c=N.resolve(i,a);if(Fe(i,c))try{let l=gu(c);if(l.isSymbolicLink()||l.isFile()&&!o.has(tn(i,c)))return!1}catch{}}let s=t==="workspace"?xu(i,n):["."];for(let a of s){let c=a==="."?i:N.join(i,a),l=N.join(c,"tsconfig.json");if(!Eu(i,l))continue;let u=tn(i,l);if(!o.has(u))return!1;try{if(gu(l).isSymbolicLink())return!1;let d=Pu(i,l);if(d.includes("extends")||d.includes("\\"))return!1}catch{return!1}}return!0}function hu(e,t){return[...new Set(t.map(n=>tn(e,n)))].sort((n,r)=>n.localeCompare(r))}function Sh(e){let t=en(e);if(t)return t.flatMap(i=>{if(i.split("/").some(s=>yu.has(s)))return[];let o=N.join(e,...i.split("/"));return Su(e,o)?[N.dirname(o)]:[]});let n=[],r=[e];for(;r.length>0;){let i=r.pop(),o;try{o=gh(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=N.join(i,s.name);if(s.isDirectory()){!yu.has(s.name)&&!s.name.startsWith(".")&&r.push(a);continue}s.isFile()&&Su(e,a)&&n.push(N.dirname(a))}}return n}function bh(e,t){let n=t.trim();if(!n)return[];let r=N.resolve(e,n);if(!Fe(e,r))return[];let i=en(e);if(i){let o=tn(e,r);if(i.includes(o)&&Fs(N.basename(r)))return[N.dirname(r)];let s=o==="."?"":`${o}/`;return i.some(a=>a.startsWith(s))?[r]:[]}try{let o=yh(r);if(o.isDirectory())return[r];if(o.isFile()&&Fs(N.basename(r)))return[N.dirname(r)]}catch{return[]}return[]}function Su(e,t){if(!Fs(N.basename(t)))return!1;let n=Iu(e,t);return n?N.basename(t)==="tsconfig.json"||"include"in n||"files"in n||"references"in n:!1}function Fs(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function bu(e){let t=[...new Set(e.map(n=>N.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&Ph(n,r)))}function xh(e,t){if(t.length===0||t.some(r=>N.resolve(r)===e))return!1;let n=N.join(e,"tsconfig.json");return Eu(e,n)&&vh(e,n)}function vh(e,t){let r=Iu(e,t)?.include;return Array.isArray(r)?r.some(i=>typeof i=="string"&&i.trim()!==""&&!i.startsWith("!")&&(i.includes("/")||i.includes("**")||!N.extname(i))):!1}function Iu(e,t){try{let n=JSON.parse(Pu(e,t));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function Eu(e,t){let n=tn(e,t),r=Zt(e,n);return r?r==="present":mh(t)}function Pu(e,t){let n=tn(e,t);if(en(e)){let i=Qt(e,n);if(!i)throw Object.assign(new Error(`Snapshot file ${n} is missing.`),{code:"ENOENT"});return i.content.toString("utf8")}return F(t,"TypeScript project config")}function Ih(e,t){let n=en(t);if(!n)return e.sys;let r=N.resolve(t),i=new Set(n),o=Eh(r,n),s=e,a=c=>{let l=N.resolve(c);return Fe(r,l)?tn(r,l):null};return{useCaseSensitiveFileNames:e.sys.useCaseSensitiveFileNames,fileExists(c){let l=a(c);return l===null?e.sys.fileExists(c):i.has(l)},readFile(c){let l=a(c);return l===null?e.sys.readFile(c):Qt(r,l)?.content.toString("utf8")},readDirectory(c,l,u,d,p){let f=N.resolve(c);return Fe(r,f)?s.matchFiles(f,l,u,d,e.sys.useCaseSensitiveFileNames,r,p,m=>o.get(N.resolve(m))??{files:[],directories:[]},m=>m):e.sys.readDirectory(c,l,u,d,p)}}}function Eh(e,t){let n=new Map,r=new Map,i=o=>{n.has(o)||n.set(o,new Set),r.has(o)||r.set(o,new Set)};i(e);for(let o of t){let s=o.split("/"),a=e;for(let c=0;c<s.length-1;c+=1){let l=s[c];i(a),r.get(a).add(l),a=N.join(a,l),i(a)}n.get(a).add(s.at(-1))}return new Map([...n].map(([o,s])=>[o,{files:[...s].sort(),directories:[...r.get(o)??[]].sort()}]))}function tn(e,t){let n=N.relative(e,t);return n?n.split(N.sep).join("/"):"."}function Ph(e,t){let n=N.relative(e,t);return!!n&&!n.startsWith("..")&&!N.isAbsolute(n)}import{createHash as Fu,randomUUID as Th}from"crypto";import{chmodSync as Nu,existsSync as Nn,linkSync as kh,lstatSync as dr,readdirSync as Ts,realpathSync as Ne,unlinkSync as _h,writeSync as Lh}from"fs";import{homedir as Dh}from"os";import{basename as Ah,dirname as wi,isAbsolute as wu,join as Ee,resolve as Ci}from"path";import{closeSync as Rh,existsSync as wh,fsyncSync as Ch,mkdirSync as Fh,openSync as Nh}from"fs";import{dirname as Ru}from"path";function at(e,t,n,r){let i=0;for(;i<t.length;){let o=n.writeFile(e,t,i,t.length-i);if(!Number.isSafeInteger(o)||o<=0||o>t.length-i)throw new Error(`${r} write did not make valid forward progress`);i+=o}}function Fn(e,t){if(t!=="win32")return!1;let n=e.code;return n==="EACCES"||n==="EBADF"||n==="EINVAL"||n==="EISDIR"||n==="EPERM"}var nn=Object.freeze({platform:process.platform,pathExists:e=>wh(e),makeDirectory:e=>Fh(e,{recursive:!0}),openFile:(e,t,n)=>Nh(e,t,n),syncFile:e=>Ch(e),closeFile:e=>Rh(e)});function ge(e,t=nn){let n=[],r=e;for(;!t.pathExists(r);){n.push(r);let o=Ru(r);if(o===r)throw new Error(`Cannot establish a durable directory path without an existing ancestor: ${e}`);r=o}let i="synced";for(let o of n.reverse())t.makeDirectory(o),i=X(i,L(Ru(o),t));return i}function L(e,t=nn){let n;try{n=t.openFile(e,"r")}catch(r){if(Fn(r,t.platform))return"unsupported";throw r}try{t.syncFile(n)}catch(r){try{t.closeFile(n)}catch{}if(Fn(r,t.platform))return"unsupported";throw r}return t.closeFile(n),"synced"}function X(...e){return e.every(t=>t==="not-requested")?"not-requested":e.includes("unsupported")?"unsupported":"synced"}var Tu=1,fr=".scip-query-cache-owner.json",Oh=16*1024,ku=Object.freeze({...nn,randomToken:()=>Th(),linkFile:(e,t)=>kh(e,t),removeFile:e=>_h(e),writeFile:(e,t,n,r)=>Lh(e,t,n,r)});function Ri(e,t){return Object.assign(new Error(`refusing unsafe project dbPath ${JSON.stringify(e)} (${t}); use a repository-relative directory that remains inside the checkout`),{name:"UnsafeCachePathError",code:"SCIP_QUERY_UNSAFE_CACHE_PATH",configuredPath:e,reason:t})}function Ve(e,t){return Object.assign(new Error(`refusing unowned cache directory ${JSON.stringify(e)} (${t}); move unrelated data elsewhere or choose a new empty dbPath`),{name:"CacheOwnershipError",code:"SCIP_QUERY_CACHE_OWNERSHIP",cacheDir:e,reason:t})}function Mh(e,t){let n=Ne(e);return jh(n,ks(n,t))}function ks(e,t){let n=Ne(e),r=process.env.SCIP_QUERY_CACHE_DIR;return r?Ci(r):t?.dbPath?$h(n,t.dbPath):Ni(n)}function Fi(){let e=process.env.XDG_CACHE_HOME;return Ee(e||Ee(Dh(),".cache"),"scip-query")}function Ni(e){let t=Ci(e);try{t=Ne(t)}catch{}let n=Fu("sha256").update(t).digest("hex").slice(0,12);return Ee(Fi(),"projects",n)}function Ti(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);let t=Ee(Fi(),"repositories",e);return Au(t),Ne(t)}function _s(e){return process.env.SCIP_QUERY_SHARED_CACHE!=="0"&&!process.env.SCIP_QUERY_CACHE_DIR&&!process.env.SCIP_QUERY_INDEX_DB&&!e?.dbPath}function gL(e,t){let n=Mh(e,t);return{cacheDir:n,dbPath:Ee(n,"index.db"),indexPath:Ee(n,"index.scip"),metaPath:Ee(n,"meta.json")}}function jh(e,t,n=ku){return Bh(e,t,n).cacheDir}function Bh(e,t,n=ku){let r=Ne(e),i=Nn(t)?"synced":Au(t,n),o=Ne(t),s=Ee(o,fr);if(Nn(s))return Ns(r,o),Ls(s),pr(o),{kind:"existing",cacheDir:o};Cu(o),Wh(o),Cu(o);let c=`${JSON.stringify({schemaVersion:Tu,canonicalProjectRoot:r,canonicalCacheDir:o,creatorVersion:bi},null,2)}
92
- `;try{let l=zh(s,c,n),u=X(i,l);return{kind:"published",cacheDir:o,achievedDurability:u==="synced"?"directory-durable":"file-flushed",directorySync:u}}catch(l){if(Hh(l))return Ns(r,o),{kind:"existing",cacheDir:o};throw l}}function Ns(e,t){let n=Ne(e),r=Ne(t);return _u(r,n,r)}function yL(e){let t=dr(e);if(t.isSymbolicLink()||!t.isDirectory())throw Ve(e,"cache path is not a regular directory");let n=Ne(e);return _u(n,void 0,n)}function hL(e,t){return Nn(Ee(t,fr))?(Ns(e,t),Lu(t),!0):!1}function $h(e,t){let n;try{n=ve(t)}catch(s){throw s instanceof $?Ri(t,s.reason):s}let r=Ci(e,...n.split("/"));if(r===e||!Fe(e,r))throw Ri(t,"outside-project");let i=Gh(r),o=Ne(i);if(!Fe(e,o)&&o!==e)throw Ri(t,"symlink-escape");return r}function Gh(e){let t=e;for(;!Nn(t);){let n=wi(t);if(n===t)throw Ri(e,"no-existing-ancestor");t=n}return t}function _u(e,t,n){let r=Ee(e,fr);if(!Nn(r)||dr(r).isSymbolicLink())throw Ve(e,"missing regular ownership record");let i=dr(r);if(!i.isFile()||i.size>Oh)throw Ve(e,"invalid ownership record file");let o=F(r,"cache ownership record"),s=Vh(o,e);if(t!==void 0&&s.canonicalProjectRoot!==t)throw Ve(e,"ownership record belongs to a different project");if(s.canonicalCacheDir!==n)throw Ve(e,"ownership record names a different cache directory");return{record:s,ownerSha256:Fu("sha256").update(o).digest("hex"),physicalCacheDir:e}}function Vh(e,t){try{let n=JSON.parse(e);if(n.schemaVersion!==Tu||typeof n.canonicalProjectRoot!="string"||typeof n.canonicalCacheDir!="string"||typeof n.creatorVersion!="string"||!wu(n.canonicalProjectRoot)||!wu(n.canonicalCacheDir))throw new Error("invalid fields");return n}catch(n){throw Ve(t,`malformed ownership record: ${n instanceof Error?n.message:String(n)}`)}}function Cu(e){let t=Ts(e).filter(n=>n!==fr&&!qh(n));if(t.length>0)throw Ve(e,`unrecognized existing entries: ${t.slice(0,3).join(", ")}`)}function qh(e){return e.startsWith(`${fr}.tmp-`)||e.startsWith("git-worktree-context.json.tmp-")||[".scipquery-generations","affected-shadow-latest.json","affected-shadow.jsonl","agent-hooks","augment-vue-meta.json","cache-lifecycle.lock","evidence.db","evidence.db-shm","evidence.db-wal","health-report-cache.json","git-worktree-context.json","index.db","index.db-shm","index.db-wal","index.lock","index.scip","language-indexes","meta.json","reindex-activity.jsonl","shared-cache.json","typescript-index","typescript-scip-fragments","typescript-scip-overlays","typescript-semantic","watch-activity.json","watch-refresh-requests","watch-state.json","watch.lock"].includes(e)?!0:/^(?:reindex-|rust-|typescript-)/.test(e)}function Wh(e){for(let t of Ts(e)){let n=Ee(e,t);try{let r=dr(n);if(r.isSymbolicLink())throw Ve(e,`legacy cache entry ${t} is a symlink`);if(r.isDirectory())pr(n);else if(r.isFile())Ls(n);else throw Ve(e,`legacy cache entry ${t} is not a file or directory`)}catch(r){if(Du(r))continue;throw r}}pr(e)}function Lu(e,t=!1){try{let n=dr(e);if(n.isSymbolicLink())throw Ve(e,"managed cache tree contains a symlink");if(n.isFile()){Ls(e);return}if(!n.isDirectory())throw Ve(e,"managed cache tree contains a special file");pr(e);for(let r of Ts(e))Lu(Ee(e,r),!0)}catch(n){if(t&&Du(n))return;throw n}}function Du(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function Au(e,t=nn){let n=ge(e,t);return pr(e),n}function zh(e,t,n){let r=`${e}.tmp-${process.pid}-${n.randomToken()}`,i,o=!1;try{i=n.openFile(r,"wx",384),o=!0,at(i,Buffer.from(t),n,"cache ownership record"),n.syncFile(i),n.closeFile(i),i=void 0,n.linkFile(r,e);let s=L(wi(e),n);return n.removeFile(r),o=!1,X(s,L(wi(e),n))}finally{if(i!==void 0)try{n.closeFile(i)}catch{}if(o)try{n.removeFile(r)}catch{}}}function pr(e){process.platform!=="win32"&&Nu(e,448)}function Ls(e){process.platform!=="win32"&&Nu(e,384)}function Uh(e){if(Nn(e))return Ne(e);let t=Ne(wi(e));return Ee(t,Ah(e))}function Ds(e){return Uh(Ci(e))}function Hh(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EEXIST"}import{execFileSync as lS}from"child_process";import{isUtf8 as Vu}from"buffer";import{createHash as $s}from"crypto";import{closeSync as zu,fstatSync as mr,lstatSync as Vs,openSync as Uu,readdirSync as uS,readFileSync as dS,readSync as qu,readlinkSync as pS,realpathSync as yr}from"fs";import{isAbsolute as fS,join as qs,relative as mS,resolve as gS,sep as yS}from"path";import{closeSync as Ou,existsSync as Os,openSync as Kh,realpathSync as Jh,renameSync as Xh,unlinkSync as Mu,writeSync as Yh}from"fs";import{dirname as Qh,join as Zh}from"path";var eS="fingerprint-stat-cache.json",ju=1,tS=8*1024*1024,As=new Map;function Ms(e,t,n,r){let i=Bu(e),o=i.files.get(t);if(!(!o||!$u(o,n,r)))return i.hits+=1,{hash:o.hash,size:o.fingerprintSize}}function js(e,t,n,r,i){if(i.hash==="unreadable"||i.size<0||!Number.isFinite(i.size))return;let o=Bu(e),s={kind:n,dev:r.dev,ino:r.ino,mtimeMs:r.mtimeMs,ctimeMs:r.ctimeMs,size:r.size,hash:i.hash,fingerprintSize:i.size},a=o.files.get(t);a&&aS(a,s)||(o.files.set(t,s),o.stores+=1,o.dirty=!0)}function Bs(e){let t=As.get(Gu(e));if(!(!t?.dirty||!t.cachePath))try{let n=Qh(t.cachePath);if(!Os(n))return;cS(t.cachePath,iS(t)),t.dirty=!1}catch{}}function Bu(e){let t=Gu(e),n=As.get(t);if(n)return n;let r=nS(t),i=rS(r),o={cachePath:r,files:i,dirty:!1,hits:0,stores:0};return As.set(t,o),o}function nS(e){try{let t=ks(e);return Os(t)?Zh(t,eS):null}catch{return null}}function rS(e){let t=new Map;if(!e||!Os(e))return t;try{let n=JSON.parse(J(e,{inputKind:"fingerprint stat cache",maxBytes:tS}).toString("utf8"));if(!oS(n))return t;for(let[r,i]of Object.entries(n.files))i&&t.set(r,i)}catch{return t}return t}function iS(e){return{version:ju,files:Object.fromEntries(e.files)}}function oS(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.version!==ju||typeof t.files!="object"||t.files===null?!1:Object.values(t.files).every(sS)}function sS(e){if(typeof e!="object"||e===null)return!1;let t=e;return(t.kind==="file"||t.kind==="symlink")&&Number.isFinite(t.dev)&&Number.isFinite(t.ino)&&Number.isFinite(t.mtimeMs)&&Number.isFinite(t.ctimeMs)&&Number.isFinite(t.size)&&Number.isFinite(t.fingerprintSize)&&typeof t.hash=="string"&&t.hash!=="unreadable"}function $u(e,t,n){return e.kind===t&&e.dev===n.dev&&e.ino===n.ino&&e.mtimeMs===n.mtimeMs&&e.ctimeMs===n.ctimeMs&&e.size===n.size}function aS(e,t){return $u(e,t.kind,t)&&e.hash===t.hash&&e.fingerprintSize===t.fingerprintSize}function cS(e,t){let n=`${e}.${process.pid}.tmp`;try{Mu(n)}catch{}let r=Buffer.from(`${JSON.stringify(t)}
93
- `,"utf8"),i=Kh(n,"wx",384);try{at(i,r,{writeFile:(o,s,a,c)=>Yh(o,s,a,c)},"fingerprint stat cache")}catch(o){throw Ou(i),Mu(n),o}Ou(i),Xh(n,e)}function Gu(e){return Jh(e)}var Tn=64*1024*1024,hS=1024*1024,SS=1024,rn=class extends Error{constructor(n,r,i,o){super(`${n} ${JSON.stringify(r)} is ${i} bytes; the safety limit is ${o} bytes`);this.inputKind=n;this.inputPath=r;this.observedBytes=i;this.limitBytes=o;this.name="InputTooLargeError"}inputKind;inputPath;observedBytes;limitBytes;code="SCIP_QUERY_INPUT_TOO_LARGE"};function bS(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function kn(e,t,n={}){let r=ve(t),i=Yl(e,()=>yr(e)),o=gS(i,...r.split("/"));if(!Fe(i,o)||o===i)throw new $(t,"outside-project");let s=yr(o);if(!Fe(i,s)||s===i)throw new $(t,"outside-project");let a=Vs(s);if(!a.isFile())throw new $(t,"not-a-file");let c={projectRoot:i,relativePath:r,absolutePath:s,size:a.size,mtimeMs:a.mtimeMs,device:a.dev,inode:a.ino},l=n.maxBytes??Tn;if(Xt(l),c.size>l)throw new rn(n.inputKind??"project file",c.relativePath,c.size,l);return c}function Li(e,t,n={}){let r=ve(t),i=Zt(e,r);if(i){if(i==="missing")throw Object.assign(new Error(`Snapshot project file ${JSON.stringify(r)} does not exist.`),{code:"ENOENT"});let c=Qt(e,r);if(!c)throw new $(r,"changed-during-read");let l=n.maxBytes??Tn;if(Xt(l),c.size>l)throw new rn(n.inputKind??"project file",r,c.size,l);return Buffer.from(c.content)}let o=kn(e,t,n),s=n.maxBytes??Tn,a=Uu(o.absolutePath,"r");try{let c=mr(a);if(gr(c,o,t),c.size>s)throw new rn(n.inputKind??"project file",o.relativePath,c.size,s);let l=dS(a),u=mr(a);if(gr(u,o,t),l.byteLength!==c.size)throw new $(t,"changed-during-read");return l}finally{zu(a)}}function xS(e,t,n,r={}){if(n.byteLength===0)throw new Error("Project file probe literal must not be empty.");let{matchedLiteralIndexes:i,...o}=Hu(e,t,[n],r);return{...o,includesLiteral:i.length>0}}function Hu(e,t,n,r={}){if(n.length===0||n.some(c=>c.byteLength===0))throw new Error("Project file probe literals must not be empty.");let i=ve(t),o=Zt(e,i);if(o){if(o==="missing")throw Object.assign(new Error(`Snapshot project file ${JSON.stringify(i)} does not exist.`),{code:"ENOENT"});let c=Qt(e,i);if(!c)throw new $(i,"changed-during-read");let l=r.maxBytes??Tn;if(Xt(l),c.size>l)throw new rn(r.inputKind??"project file",i,c.size,l);let u=!c.content.includes(0)&&Vu(c.content),d=n.map(Wu),p=u?IS(c.content,n,d):[];return{byteLength:c.size,isUtf8Text:u,matchedLiteralIndexes:p,bytes:p.length>0?Buffer.from(c.content):null,...r.computeSha256?{sha256:c.sha256}:{}}}let s=kn(e,t,r),a=Uu(s.absolutePath,"r");try{let c=mr(a);gr(c,s,t);let l=r.computeSha256?$s("sha256"):null,u=r.scratchBuffer??Buffer.allocUnsafe(hS);if(u.byteLength===0)throw new Error("Project file probe scratch buffer must not be empty.");let d=0,p=n.map(()=>!1),f=!1,m=!0,g=Buffer.alloc(0),y=n.map(()=>Buffer.alloc(0)),I=n.map(Wu);for(;d<c.size;){let T=qu(a,u,0,Math.min(u.byteLength,c.size-d),d);if(T<=0)throw new $(t,"changed-during-read");let b=u.subarray(0,T);if(l?.update(b),f||=b.includes(0),m){let v=g.byteLength>0?Buffer.concat([g,b]):b,E=vS(v);m=Vu(v.subarray(0,E)),g=Buffer.from(v.subarray(E))}for(let v=0;v<n.length;v+=1){if(p[v])continue;let E=n[v],O=y[v];p[v]=ES(b,E,O,I[v]),y[v]=PS(b,E,O)}d+=T}m&&=g.byteLength===0,gr(mr(a),s,t);let h=!f&&m,P=h?p.flatMap((T,b)=>T?[b]:[]):[],w=null;if(P.length>0){w=Buffer.allocUnsafe(c.size);let T=0;for(;T<w.byteLength;){let b=qu(a,w,T,w.byteLength-T,T);if(b<=0)throw new $(t,"changed-during-read");T+=b}gr(mr(a),s,t)}return{byteLength:c.size,isUtf8Text:h,matchedLiteralIndexes:P,bytes:w,...l?{sha256:l.digest("hex")}:{}}}finally{zu(a)}}function Ws(e,t,n={}){return Li(e,t,n).toString("utf8")}function gr(e,t,n){if(!e.isFile()||e.dev!==t.device||e.ino!==t.inode||e.size!==t.size)throw new $(n,"changed-during-read")}function vS(e){if(e.byteLength===0)return 0;let t=e.byteLength-1,n=0;for(;t>=0&&n<3&&(e[t]&192)===128;)n+=1,t-=1;if(t<0)return e.byteLength;let r=e[t];return((r&128)===0?1:(r&224)===192?2:(r&240)===224?3:(r&248)===240?4:0)>e.byteLength-t?t:e.byteLength}function IS(e,t,n){return t.flatMap((r,i)=>Gs(e,r,n[i])?[i]:[])}function ES(e,t,n,r){if(Gs(e,t,r))return!0;if(n.byteLength===0||t.byteLength===1)return!1;let i=e.subarray(0,Math.min(e.byteLength,t.byteLength-1));return Gs(Buffer.concat([n,i]),t,r)}function Gs(e,t,n){if(n<0)return e.includes(t);let r=t[n],i=e.indexOf(r),o=0;for(;i>=0;){if(o+=1,o>SS)return e.includes(t);let s=i-n;if(s>=0&&s+t.byteLength<=e.byteLength&&e.compare(t,0,t.byteLength,s,s+t.byteLength)===0)return!0;i=e.indexOf(r,i+1)}return!1}function Wu(e){for(let n=1;n<e.byteLength;n+=1){let r=e[n];if(r>=65&&r<=90)return n}let t=e[0];return t>=65&&t<=90?0:-1}function PS(e,t,n){let r=t.byteLength-1;if(r===0)return Buffer.alloc(0);if(e.byteLength>=r)return Buffer.from(e.subarray(e.byteLength-r));let i=Buffer.concat([n,e]);return Buffer.from(i.subarray(Math.max(0,i.byteLength-r)))}function _n(e){return typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}function RS(e,t){try{return kn(e,t),!0}catch(n){if(_n(n))return!1;throw n}}function wS(e){let t=en(e);return t?t.filter(n=>n&&!_i(n)).sort():(_S(e)??LS(e)).filter(n=>n&&!_i(n)).sort()}function CS(e,t={}){let n=(t.includePaths??[]).map(ve),r=[...new Set([...wS(e),...n])].filter(s=>!_i(s)).filter(s=>!t.language||xl(s,t.language,t.markerFiles)).filter(s=>!t.includePath||t.includePath(s)).sort(),i=yr(e),o=r.flatMap(s=>Ku(e,i,s));return Bs(i),o}function Ku(e,t,n){let r=mu(e,n);if(r)return[{path:n,size:r.fingerprintSize??r.size,hash:r.sha256}];if(Zt(e,n)==="present"){let o=Qt(e,n);if(o)return[{path:n,size:o.fingerprintSize??o.size,hash:o.sha256}]}let i=qs(e,n);try{let o=Vs(i);if(o.isSymbolicLink()){let u=Ms(t,n,"symlink",ki(o));if(u)return[{path:n,size:u.size,hash:u.hash}];let d=yr(i),p=mS(t,d);if(p===".."||p.startsWith(`..${yS}`)||fS(p))throw new Error("external symlink");let f=pS(i),m=$s("sha256").update("symlink\0").update(f).digest("hex"),g=Buffer.byteLength(f);return js(t,n,"symlink",ki(o),{hash:m,size:g}),[{path:n,size:g,hash:m}]}let s=Ms(t,n,"file",ki(o));if(s)return[{path:n,size:s.size,hash:s.hash}];let a=$s("sha256"),c=wn(i,{inputKind:"project fingerprint input",maxBytes:Tn},u=>a.update(u)),l=a.digest("hex");return js(t,n,"file",ki(o),{hash:l,size:c}),[{path:n,size:c,hash:l}]}catch(o){return _n(o)?[]:[{path:n,size:-1,hash:"unreadable"}]}}function ki(e){return{dev:e.dev,ino:e.ino,mtimeMs:e.mtimeMs,ctimeMs:e.ctimeMs,size:e.size}}function Di(e,t,n){let r=hr(t,n),i=[...r.typescriptProjects.filter(s=>TS(e,s)),...r.clojureConfigPath?[r.clojureConfigPath]:[]],o=r.languages.includes("typescript")?vu(e,r.typescriptProjectMode,r.typescriptProjects):null;return{...r,files:CS(e,{includePath:s=>{let a=Et(s,t,i);return a==="other"?!1:a!=="source"||!NS(s)||!o?!0:o.has(s)},includePaths:i})}}function ML(e,t,n,r,i,o){let s=d=>({mode:"full",fingerprint:Di(e,t,n),reason:d});if(!i)return s("change-journal-unavailable");if(!i.complete)return s(`change-journal-incomplete:${i.incompleteReason??"unknown"}`);if(!o)return s("accepted-generation-unavailable");if(i.baseGeneration!==o)return s("change-journal-base-mismatch");if(!r)return s("prior-project-input-snapshot-unavailable");let a=hr(t,n);if(!FS(r,a))return s("project-input-configuration-changed");if(new Set(r.files.map(d=>d.path)).size!==r.files.length)return s("prior-project-input-snapshot-has-duplicate-paths");if(i.entries.length===0)return{mode:"delta",fingerprint:{...a,files:[...r.files].sort((d,p)=>d.path.localeCompare(p.path))},changedPaths:[]};let c=[...a.typescriptProjects,...a.clojureConfigPath?[a.clojureConfigPath]:[]],l=new Map(r.files.map(d=>[d.path,d]));for(let d of i.entries){let p=l.get(d.path);if(Et(d.path,t,c)!=="source")return s("non-source-project-input-changed");if(d.kind==="add"&&p)return s("added-path-already-in-prior-project-input-snapshot");if(d.kind==="delete"&&!p)return s("deleted-path-not-in-prior-project-input-snapshot");if(d.kind==="change"&&!p)return s("changed-path-not-in-prior-project-input-snapshot");if(p&&(p.hash==="unreadable"||p.size<0))return s("changed-path-was-unreadable")}let u=yr(e);for(let d of i.entries){let p=Ku(e,u,d.path);if(d.kind==="delete"){if(p.length!==0)return s("deleted-source-is-still-readable");l.delete(d.path);continue}if(p.length!==1||p[0].hash==="unreadable"||p[0].size<0)return s(d.kind==="add"?"added-source-is-not-readable":"changed-source-no-longer-readable");l.set(d.path,p[0])}return Bs(u),{mode:"delta",fingerprint:{...a,files:[...l.values()].sort((d,p)=>d.path.localeCompare(p.path))},changedPaths:i.entries.map(d=>d.path).sort()}}function FS(e,t){return e.version===t.version&&JSON.stringify([...e.languages].sort())===JSON.stringify(t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&JSON.stringify([...e.typescriptProjects].sort())===JSON.stringify(t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function NS(e){return/\.(?:[cm]?[jt]sx?|vue)$/iu.test(e)}function TS(e,t){let n;try{n=ve(t)}catch{return!1}let r=Zt(e,n);if(r)return r==="present";try{return Vs(qs(e,n)).isFile()}catch(i){if(_n(i))return!1;throw i}}function hr(e,t){return{version:3,languages:[...e].sort(),pnpmWorkspaces:t.typescriptProjectMode!=="workspace"&&t.pnpmWorkspaces===!0,typescriptProjectMode:t.typescriptProjectMode??"single",typescriptProjects:bS(t.typescriptProjects),clojureConfigPath:kS(t.clojureConfigPath)}}function kS(e){return e?.trim()||void 0}function _S(e){try{let t=hi(e,52428800,()=>lS("git",["-C",e,"ls-files","-co","-v","-z","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:104857600,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"}));return[...Si(t)]}catch{return null}}function LS(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?qs(e,r):e,o;try{o=uS(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=r?`${r}/${s.name}`:s.name;if(s.isDirectory()){_i(a)||n.push(a);continue}t.push(a)}}return t}function _i(e){let t=e.split("/");return e==="meta.json"||t[0]===".scipquery"&&(t[1]==="events"||t[1]==="ledger"||t[1]==="releases"||t[1]==="suppressions")||t.some(n=>DS.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var DS=new Set([".git","node_modules",".scipquery-cache",".scipquery-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);var AS=C("source-text",{clearGroups:["whole-project","source-file"]}),OS=C("source-lines",{clearGroups:["whole-project","source-file"]});function R(e,t){let n=t.replace(/\\/g,"/");return AS.get(e,n,()=>{try{return Ws(e.config.projectRoot,n,{inputKind:"indexed source file"})}catch(r){if(_n(r))return"";throw r}})}function GL(e){if(e.length===0)return[];let t=e.split(`
94
- `);return e.endsWith(`
95
- `)&&t.pop(),t}function Sr(e,t){let n=t.replace(/\\/g,"/");return OS.get(e,n,()=>{let r=R(e,n);return r?r.split(`
96
- `):[]})}var MS=/^\s*(?:\/\/|#|\/\*+|\*)\s*scip-query[\s:-]*ignore(?:[\s:-]+(dead(?:-code)?|stale|wrapper|passthrough|drift|extract|similar|twin))?\b/i;function jS(e){let t=MS.exec(e);return t?t[1]??"":null}function VL(e,t,n){return Ju(e,t,n).length>0}function qL(e,t,n,r){let i=r.toLowerCase();return Ju(e,t,n).some(o=>o.toLowerCase()===i)}function Ju(e,t,n){if(n<=0)return[];let r=Sr(e,t);if(r.length===0)return[];let i=[];for(let o=n-1;o>=0&&o>=n-5;o-=1){let s=(r[o]??"").trim();if(s==="")continue;let a=jS(s);if(a!==null){i.push(a);continue}if(!s.startsWith("//")&&!s.startsWith("*")&&!s.startsWith("/*")&&!s.startsWith("@")&&!s.startsWith("#"))return i}return i}import{readdirSync as BS}from"fs";import{execFileSync as $S}from"child_process";import{extname as Ai,join as GS}from"path";var VS=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue",".rs",".py",".pyi",".java",".kt",".kts",".scala",".sc",".clj",".cljs",".cljc",".rb",".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx",".cs",".vb",".php",".dart"],XL=[".vue"],Xu=[".tsx",".jsx"],Yu=[".vue"],qS=[...Xu,...Yu],WS=new Set(Xu),zS=new Set(Yu),Qu=new Set(VS.map(e=>e.toLowerCase())),US=[...Qu].sort().join(","),Zu=new Set(["node_modules",".git","target","dist","build",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs","out","coverage",".scipquery-cache","__pycache__",".venv","venv",".idea",".vscode"]);function ye(e,t={}){let n=t.includeIndexed??!0,r=t.includeAuxiliary??!0,i=t.extensions?.map(c=>c.toLowerCase()),o=i?new Set(i):Qu,s=i?[...o].sort().join(","):US,a=`${n?"1":"0"}|${r?"1":"0"}|${s}`;return HS.get(e,a,()=>{let c=new Set;if(n)for(let l of xe(e,{includeIgnored:!1}))o.has(Ai(l).toLowerCase())&&c.add(l);if(r)for(let l of KS(e.config.projectRoot,o))e.isIgnored(l)||n&&c.has(l)||c.add(l);return[...c].sort()})}function YL(e,t={}){let n=!1,r=!1;for(let i of ye(e,{extensions:qS})){if(t.scope&&!i.includes(t.scope))continue;let o=Ai(i).toLowerCase();if(n||=WS.has(o),r||=zS.has(o),n&&r)break}return{react:n,vue:r}}var HS=C("source-files",{clearGroups:[]});function KS(e,t){return JS(e,t)??YS(e,t)}function JS(e,t){try{let n=$S("git",["ls-files","--cached","--others","--exclude-standard"],{cwd:e,encoding:"utf-8",timeout:1e4,killSignal:"SIGKILL",stdio:["ignore","pipe","ignore"]}),r=new Set;for(let i of n.split(`
97
- `)){let o=i.trim();o&&(XS(o)||t.has(Ai(o).toLowerCase())&&r.add(o))}return r}catch{return null}}function XS(e){return e.split("/").some(t=>Zu.has(t))}function YS(e,t){let n=new Set,r=i=>{let o=i?GS(e,i):e,s;try{s=BS(o,{withFileTypes:!0})}catch{return}for(let a of s)if(!Zu.has(a.name)){if(a.isDirectory()){r(i?`${i}/${a.name}`:a.name);continue}t.has(Ai(a.name).toLowerCase())&&n.add(i?`${i}/${a.name}`:a.name)}};return r(""),n}import{createRequire as cb}from"module";import{existsSync as an}from"fs";import{basename as td,dirname as Pe,extname as ct,join as Te,relative as on,resolve as Z,sep as lb}from"path";import{existsSync as Us,readdirSync as QS,statSync as ZS}from"fs";import{join as Ln,relative as eb}from"path";function ed(e){let t=tb(e)??ob(e);if(!t||t.length===0)return[];let n=[],r=new Set;for(let i of t)for(let o of sb(e,i)){if(r.has(o))continue;r.add(o);let s=ab(e,o);s&&n.push(s)}return n}function tb(e){let t=Ln(e,"pnpm-workspace.yaml");if(!Us(t))return null;try{return nb(F(t,"pnpm workspace manifest"))}catch{return null}}function nb(e){let t=[],n=!1;for(let r of e.split(/\r?\n/)){let i=rb(r);if(!n){/^packages\s*:\s*$/.test(i.trim())&&(n=!0);continue}let o=/^\s+-\s*(.+)$/.exec(i);if(o){let s=ib(o[1].trim());s&&t.push(s);continue}if(i.trim()!=="")break}return t}function rb(e){let t=e.indexOf("#");return t===-1?e:e.slice(0,t)}function ib(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function ob(e){let t=Ln(e,"package.json");if(!Us(t))return null;try{let n=JSON.parse(F(t,"workspace package manifest"));return n.workspaces?Array.isArray(n.workspaces)?n.workspaces:n.workspaces.packages??[]:null}catch{return null}}function sb(e,t){if(!t||t.startsWith("!")||t.includes("node_modules"))return[];if(!t.includes("*")){let s=Ln(e,t);return zs(s)?[s]:[]}let n=t.indexOf("*"),r=t.slice(0,n).replace(/\/$/,""),i=t.slice(n+1).replace(/^\//,""),o=Ln(e,r||".");return zs(o)?QS(o).map(s=>Ln(o,s,i)).filter(zs):[]}function zs(e){try{return ZS(e).isDirectory()}catch{return!1}}function ab(e,t){let n=Ln(t,"package.json");if(!Us(n))return null;try{let r=JSON.parse(F(n,"workspace package manifest"));return typeof r.name!="string"||r.name.length===0?null:{name:r.name,relativeDir:eb(e,t).replace(/\\/g,"/"),exports:r.exports}}catch{return null}}var ub=He("indexed-paths",{clearGroups:[]}),db=He("indexed-path-digest",{clearGroups:[]}),pb=C("tsconfig-alias-config",{clearGroups:["whole-project"]}),fb=C("tsconfig-alias-config-for-dir",{clearGroups:["whole-project"]}),mb=cb(import.meta.url),br;function gb(){if(br!==void 0)return br;try{br=mb("typescript")}catch{br=null}return br}var yb=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"],hb=He("workspace-packages",{clearGroups:["whole-project"]}),sn=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],Oi=[".py",".pyi"],Re=[".java",".scala",".kt",".kts"],Mi=[".rs"],ji=[".rb"],Bi=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],Tt=[".cs",".vb"],$i=[".dart"],cn=[".php"],Dn=[".clj",".cljs",".cljc"],Sb=new Set(sn),Hs=new Set(Oi),nd=new Set(Re),Ks=new Set(Mi),Js=new Set(ji),rd=new Set(Bi),id=new Set(Tt),Xs=new Set($i),od=new Set(cn),sd=new Set(Dn),bb=[{extensions:sn,lookup:Sb},{extensions:Oi,lookup:Hs},{extensions:Re,lookup:nd},{extensions:Mi,lookup:Ks},{extensions:ji,lookup:Js},{extensions:Bi,lookup:rd},{extensions:Tt,lookup:id},{extensions:$i,lookup:Xs},{extensions:cn,lookup:od},{extensions:Dn,lookup:sd}];function lt(e,t){return t.has(ct(e).toLowerCase())}function xb(e){return lt(e,Hs)}function vb(e){return lt(e,nd)}function Ib(e){return lt(e,Ks)}function Eb(e){return lt(e,Js)}function Pb(e){return lt(e,rd)}function Rb(e){return lt(e,id)}function ad(e){return ct(e).toLowerCase()===".vb"}function wb(e){return lt(e,Xs)}function Cb(e){return lt(e,od)}function Fb(e){return lt(e,sd)}function Ys(e){let t=ct(e).toLowerCase();for(let n of bb)if(n.lookup.has(t))return n.extensions;return sn}function Nb(e){return vb(e)||Rb(e)||Cb(e)}function Xe(e,t,n){return xb(t)?An(e,t,n):Ib(t)?ut(e,t,n):Eb(t)?Gi(e,t,n):Pb(t)?Vi(e,t,n):Nb(t)?W(e,n.replace(/\\/g,"."),Ys(t)):wb(t)?qi(e,t,n):Fb(t)?Qs(e,n):Tb(e,t,n)}function Tb(e,t,n){if(!n.startsWith(".")&&!n.startsWith("/"))return kb(e,t,n)??Lb(e,n);let r=Pe(Te(e.config.projectRoot,t)),i=Z(r,n),o=dt(e);for(let s of ea(i)){let a=Y(on(e.config.projectRoot,s));if(o.has(a)||an(s))return a}return Y(on(e.config.projectRoot,i))}function kb(e,t,n){let r=Bb(e,t);if(!r)return null;let i=dt(e);for(let o of _b(r,n)){let s=Z(r.baseUrl,o);for(let a of ea(s)){let c=Y(on(e.config.projectRoot,a));if(i.has(c)||an(a))return c}}return null}function _b(e,t){let n=[];for(let[r,i]of Object.entries(e.paths)){let o=r.indexOf("*");if(o===-1){if(t!==r)continue;n.push(...i);continue}let s=r.slice(0,o),a=r.slice(o+1);if(!t.startsWith(s)||!t.endsWith(a)||t.length<s.length+a.length)continue;let c=t.slice(s.length,t.length-a.length);for(let l of i)n.push(l.includes("*")?l.replace("*",c):l)}return n}function Lb(e,t){let n=Ab(Db(e),t);if(!n)return null;let r=dt(e);for(let i of Ob(n)){let o=Z(e.config.projectRoot,n.pkg.relativeDir,i);for(let s of ea(o)){let a=Y(on(e.config.projectRoot,s));if(r.has(a)||an(s))return a}}return null}function Db(e){return hb.get(e,()=>ed(e.config.projectRoot))}function Ab(e,t){let n=null;for(let r of e){let i=null;t===r.name?i="":t.startsWith(`${r.name}/`)&&(i=t.slice(r.name.length+1)),i!==null&&(!n||r.name.length>n.pkg.name.length)&&(n={pkg:r,subpath:i})}return n}function Ob(e){let t=[],n=Mb(e.pkg.exports,e.subpath);if(n){let r=jb(n);r&&t.push(r)}return t.push(e.subpath?`src/${e.subpath}`:"src/index"),t}function Mb(e,t){if(!e||typeof e!="object")return null;let n=t===""?".":`./${t}`;return cd(e[n])}function cd(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;let t=e;for(let n of["types","import","default","require","node"]){let r=cd(t[n]);if(r)return r}return null}function jb(e){let t=e.replace(/^\.\//,"");return t.startsWith("dist/")?`src/${t.slice(5)}`:null}function Bb(e,t){let n=Y(Pe(t));return fb.get(e,n,()=>$b(e,n))}function $b(e,t){let n=gb();if(!n)return null;let r=Z(e.config.projectRoot),i=Z(r,t);for(;i===r||i.startsWith(r+lb);){for(let s of yb){let a=Te(i,s);if(!an(a))continue;let c=pb.get(e,a,()=>Gb(n,a));if(c)return c}let o=Pe(i);if(o===i)break;i=o}return null}function Gb(e,t){try{let n=e.readConfigFile(t,e.sys.readFile);if(n.error||!n.config)return null;let r=e.parseJsonConfigFileContent(n.config,e.sys,Pe(t)),i=r.options.paths;return!i||Object.keys(i).length===0?null:{baseUrl:r.options.baseUrl?Z(Pe(t),r.options.baseUrl):Pe(t),paths:i}}catch{return null}}function An(e,t,n){let r=dt(e),i;if(n.startsWith(".")){let o=n.match(/^(\.+)(.*)$/);if(!o)return null;let s=o[1].length,a=o[2].replace(/^\./,""),c=Pe(Te(e.config.projectRoot,t));for(let l=1;l<s;l++)c=Pe(c);i=a?Z(c,a.replace(/\./g,"/")):c}else i=Z(e.config.projectRoot,n.replace(/\./g,"/"));for(let o of Vb(i)){let s=Y(on(e.config.projectRoot,o));if(r.has(s)||an(o))return s}return null}function ut(e,t,n){if(!n)return null;let r=n.replace(/\s+as\s+.+$/,"").trim();if(!r.startsWith("crate::")&&!r.startsWith("self::")&&!r.startsWith("super::"))return null;let i=Pe(Te(e.config.projectRoot,t)),o;return r.startsWith("crate::")?o=Z(e.config.projectRoot,"src",r.slice(7).replace(/::/g,"/")):r.startsWith("self::")?o=Z(i,r.slice(6).replace(/::/g,"/")):o=Z(Pe(i),r.slice(7).replace(/::/g,"/")),Zs(e,qb(o))}function Gi(e,t,n){let r=Pe(Te(e.config.projectRoot,t)),i=Z(r,n);return Zs(e,Wb(i))}function Vi(e,t,n){let r=Pe(Te(e.config.projectRoot,t)),i=[Z(r,n),Z(e.config.projectRoot,n),Z(e.config.projectRoot,"include",n),Z(e.config.projectRoot,"src",n)];return Zs(e,i)}function W(e,t,n){let r=dt(e),i=t.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=i.replace(/\./g,"/"),s=i.split(".").pop()??i;for(let c of n){let l=`${o}${c}`,u=[...r].find(d=>d.endsWith(l));if(u)return u}for(let c of n){let l=[...r].find(u=>td(u)===`${s}${c}`);if(l)return l}let a=[...r].filter(c=>n.includes(ct(c).toLowerCase())).filter(c=>c.includes(`/${o}/`)||c.includes(`/${s}/`)).sort((c,l)=>c.localeCompare(l));return a.length===1?a[0]:null}function qi(e,t,n){let r=dt(e);if(n.startsWith("package:")){let s=n.slice(8),a=s.indexOf("/");if(a<0)return null;let c=s.slice(a+1),l=Y(c.startsWith("lib/")?c:`lib/${c}`);return r.has(l)?l:null}let i=Pe(Te(e.config.projectRoot,t)),o=Z(i,n);for(let s of zb(o)){let a=Y(on(e.config.projectRoot,s));if(r.has(a)||an(s))return a}return null}function Qs(e,t){let n=t.replace(/-/g,"_").replace(/\./g,"/"),r=dt(e);for(let i of Dn){let o=`${n}${i}`,s=[...r].find(a=>a.endsWith(o));if(s)return s}for(let i of Dn){let o=[...r].find(s=>td(s)===`${n.split("/").pop()}${i}`);if(o)return o}return null}function Vb(e){let t=ct(e);return Hs.has(t)?[e]:[`${e}.py`,`${e}.pyi`,Te(e,"__init__.py"),Te(e,"__init__.pyi")]}function Zs(e,t){let n=dt(e);for(let r of t){let i=Y(on(e.config.projectRoot,r));if(n.has(i)||an(r))return i}return null}function qb(e){let t=ct(e);return Ks.has(t)?[e]:[`${e}.rs`,Te(e,"mod.rs")]}function Wb(e){let t=ct(e);return Js.has(t)?[e]:[`${e}.rb`,Te(e,"index.rb")]}function zb(e){let t=ct(e);return Xs.has(t)?[e]:[`${e}.dart`,e]}function ea(e){let t=ct(e),n=new Set;if(t){n.add(e);for(let r of sn)n.add(e.slice(0,-t.length)+r)}else for(let r of sn)n.add(`${e}${r}`),n.add(Te(e,`index${r}`));return[...n]}function dt(e){return ub.get(e,()=>new Set(xe(e,{includeIgnored:!1}).map(Y)))}function ta(e){return db.get(e,()=>K([...dt(e)].sort().join(`
98
- `)))}function kt(e){return typeof e=="object"&&e!==null}function ke(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}import{basename as Zd}from"path";function te(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ra(e){return e.replace(/'''[\s\S]*?'''/g,_t).replace(/"""[\s\S]*?"""/g,_t).replace(/#.*$/gm,_t).replace(/\/\/.*$/gm,_t).replace(/\/\*[\s\S]*?\*\//g,_t).replace(/`(?:\\[\s\S]|[^`])*`/g,_t).replace(/'(?:\\.|[^'\\\r\n])*'/g,_t).replace(/"(?:\\.|[^"\\\r\n])*"/g,_t)}function hD(e){return ld(e,{maskStrings:!1})}function SD(e){return ld(e,{maskStrings:!0})}function ld(e,t){let n="",r=0,i=e.length;for(;r<i;){if(e[r]==="/"&&e[r+1]==="/"){let s=e.indexOf(`
99
- `,r),a=s===-1?i:s;n+=na(e,r,a),r=a;continue}if(e[r]==="/"&&e[r+1]==="*"){let s=e.indexOf("*/",r+2),a=s===-1?i:s+2;n+=na(e,r,a),r=a;continue}let o=e[r];if(o==="`"||o==="'"||o==='"'){let s=o,a=r+1;for(;a<i;){if(e[a]==="\\"){a+=2;continue}if(e[a]===s){a+=1;break}if(s!=="`"&&e[a]===`
100
- `)break;a+=1}n+=t.maskStrings?na(e,r,a):e.slice(r,a),r=a;continue}n+=o,r+=1}return n}function na(e,t,n){let r="";for(let i=t;i<n;i+=1)r+=e[i]===`
101
- `?`
102
- `:" ";return r}function _t(e){return e.replace(/[^\r\n]/g," ")}var bD=zt("stripped-lines",{clearGroups:["whole-project","source-file"]});En({name:"stripped-source-singleton",groups:["whole-project","source-file"],clearAll:()=>{Wi=null,xr=""},clearFile:()=>{Wi=null,xr=""}});var Wi=null,xr="";function Ub(e){return Wi===e||(Wi=e,xr=ra(e)),xr}function Lt(e,t,n){let r=Ub(e);return`${r.slice(0,t)}${" ".repeat(n-t)}${r.slice(n)}`}function he(e,t){return new RegExp(`\\b${te(t)}\\b`,"m").test(e)}function On(e,t){let n=new Set,r=new RegExp(`\\b${te(t)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let i of e.matchAll(r)){let o=i[1];o&&n.add(o)}return[...n]}function ia(e){let t=0;for(let n of e)n==="("&&(t+=1),n===")"&&(t-=1);return t}import{extname as ud}from"path";var Hb={".rs":"rust",".ts":"typescript",".mts":"typescript",".cts":"typescript",".tsx":"tsx",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".cjs":"javascript",".py":"python",".pyi":"python",".java":"java",".kt":"kotlin",".kts":"kotlin",".scala":"scala",".sc":"scala",".rb":"ruby",".c":"c",".h":"c",".cc":"cpp",".cpp":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".hxx":"cpp",".cs":"csharp",".php":"php",".vb":"vb",".clj":"clojure",".cljs":"clojure",".cljc":"clojure"};function ne(e){return Hb[ud(e).toLowerCase()]??null}function Ye(e){return ud(e).toLowerCase()===".vue"}function re(e,t){t(e);for(let n of e.namedChildren)re(n,t)}function _e(e,t,n){let r=null;return re(e,i=>{!/(?:function|method|lambda)/u.test(i.type)&&i.type!=="arrow_function"||i.startPosition.row>t||i.endPosition.row<n||(!r||i.endIndex-i.startIndex<r.endIndex-r.startIndex)&&(r=i)}),r}function dd(e,t,n){if(e.startPosition.row>t||e.endPosition.row<n)return null;for(let r of e.namedChildren){let i=dd(r,t,n);if(i)return i}return e}function Le(e){let t=e;for(;["as_expression","satisfies_expression","type_assertion","parenthesized_expression"].includes(t.type)&&t.namedChildren.length>0;)t=t.namedChildren[0];return t}function vr(e){if(e.type==="identifier")return e.text;let t=e.childForFieldName("name")??e.childForFieldName("pattern");return t?vr(t):e.namedChildren.find(n=>n.type==="identifier")?.text??null}function Dt(e){return(e.childForFieldName("parameters")??e.namedChildren.find(n=>/parameters/u.test(n.type)))?.namedChildren.map(vr)??[]}import{createRequire as Kb}from"module";var ce=Kb(import.meta.url),Ir=null,oa=!1;function pd(){if(oa)return null;if(Ir)return Ir;try{return Ir=ce("tree-sitter"),Ir}catch{return oa=!0,null}}function RD(e){if(e==="clojure")return"reader";let t=pd();if(!t)return"unavailable";let n=fd(e);if(!n)return"unavailable";try{return new t().setLanguage(n),"ast"}catch{return Mn.add(e),"unavailable"}}var sa=new Map,Mn=new Set;function fd(e){if(Mn.has(e))return null;let t=sa.get(e);if(t)return t;let n;try{switch(e){case"rust":n=ce("tree-sitter-rust");break;case"typescript":n=ce("tree-sitter-typescript").typescript;break;case"tsx":n=ce("tree-sitter-typescript").tsx;break;case"javascript":n=ce("tree-sitter-javascript");break;case"python":n=ce("tree-sitter-python");break;case"java":n=ce("tree-sitter-java");break;case"kotlin":n=ce("tree-sitter-kotlin");break;case"scala":n=ce("tree-sitter-scala");break;case"ruby":n=ce("tree-sitter-ruby");break;case"c":n=ce("tree-sitter-c");break;case"cpp":n=ce("tree-sitter-cpp");break;case"csharp":n=ce("tree-sitter-c-sharp");break;case"php":n=ce("tree-sitter-php").php;break;case"vb":{let r=ce("tree-sitter-vb-dotnet");n=r.language??r;break}case"clojure":return Mn.add(e),null}}catch{return Mn.add(e),null}return sa.set(e,n),n}var aa=new Map;function wD(){Ir=null,oa=!1,sa.clear(),Mn.clear(),aa.clear(),Yb.clear()}function Jb(e){let t=aa.get(e);if(t)return t;let n=fd(e);if(!n)return null;let r=pd();if(!r)return null;let i=new r;try{i.setLanguage(n)}catch{return Mn.add(e),null}return aa.set(e,i),i}function Xb(e,t){return e.parse(r=>r>=t.length?null:t.slice(r,Math.min(t.length,r+16384)))}function ln(e,t){let n=Jb(e);if(!n)return null;try{return Xb(n,t)}catch{return null}}var Yb=new Map;import{createRequire as Qb}from"module";import{posix as ca}from"path";var Zb=wt("vue-sfc-units"),ex=Qb(import.meta.url),tx;function nx(){return tx??=ex("@vue/compiler-sfc")}function yd(...e){return nx().parse(...e)}function jn(e,t){let n=hd(t),r=R(e,n);return Zb.get(e,n,r,()=>la(e,n,r))}function hd(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function rx(e){let t=e?.toLowerCase();return!t||t==="js"||t==="javascript"||t==="jsx"?"javascript":t==="ts"||t==="typescript"?"typescript":t==="tsx"?"tsx":null}function un(e){return!e||e.body.length===0?0:e.body.split(`
103
- `).length}function la(e,t,n){let r={relativePath:t,template:null,scripts:[],styles:[],customBlocks:[],errors:[]};if(!n)return r;let i;try{i=yd(n,{filename:t})}catch(s){return r.errors.push(gd(s)),r}r.errors.push(...i.errors.map(gd));let{descriptor:o}=i;return o.template&&(r.template=zi(e,t,"template",o.template)),o.script&&r.scripts.push(md(e,t,o.script,!1)),o.scriptSetup&&r.scripts.push(md(e,t,o.scriptSetup,!0)),r.styles=o.styles.map(s=>zi(e,t,"style",s)),r.customBlocks=o.customBlocks.map(s=>zi(e,t,"custom",s)),r.errors.push(...[r.template,...r.scripts,...r.styles,...r.customBlocks].flatMap(s=>s?.errors??[])),r}function md(e,t,n,r){let i=zi(e,t,"script",n);return{...i,kind:"script",setup:r,astLanguage:rx(i.lang)}}function zi(e,t,n,r){let i=ox(r.attrs),o=typeof i.lang=="string"?i.lang:null,s=typeof i.src=="string"?i.src:typeof r.src=="string"?r.src:void 0;if(s){let c=ix(t,s);if(!c)return{kind:n,ownerPath:t,sourcePath:t,external:!0,src:s,attrs:i,lang:o,body:"",startLine:0,endLine:0,errors:[`Could not resolve Vue ${n} block source: ${s}`]};let l=R(e,c),u=l?Math.max(0,l.split(`
104
- `).length-1):0;return{kind:n,ownerPath:t,sourcePath:c,external:!0,src:s,attrs:i,lang:o,body:l,startLine:0,endLine:u,errors:l?[]:[`Vue ${n} block source not found: ${c}`]}}let a=Math.max(0,r.loc.start.line-1);return{kind:n,ownerPath:t,sourcePath:t,external:!1,attrs:i,lang:o,body:r.content,startLine:a,endLine:Math.max(a,r.loc.end.line-1),errors:[]}}function ix(e,t){let n=t.split(/[?#]/,1)[0];if(!n||n.startsWith("/")||n.includes("://"))return null;let r=hd(ca.normalize(ca.join(ca.dirname(e),n)));return r===".."||r.startsWith("../")?null:r}function ox(e){return{...e}}function gd(e){return e instanceof Error?e.message:String(e)}function Er(e,t,n){let i=la(e,t,n).scripts.filter(s=>s.astLanguage&&s.body.length>0),o=i[0]?.astLanguage;return o?{body:i.map(s=>`${`
105
- `.repeat(s.startLine)}${s.body}`).join(`
106
- `),startLine:0,language:o}:null}var Sd=zt("ast-trees",{clearGroups:["whole-project","source-file"]});function D(e,t){if(Ye(t))return sx(e,t);let n=ne(t);if(!n)return null;let r=R(e,t);return r?Sd.get(e,t,r,()=>ln(n,r)):null}function Pr(e,t,n){if(Ye(t)){let o=Er(e,t,n);if(!o)return null;let s=ln(o.language,`
107
- `.repeat(o.startLine)+o.body);return s?{tree:s,language:o.language}:null}let r=ne(t);if(!r)return null;let i=ln(r,n);return i?{tree:i,language:r}:null}function sx(e,t){let n=R(e,t);return n?Sd.get(e,t,n,()=>{let r=Er(e,t,n);if(!r)return null;let i=`
108
- `.repeat(r.startLine)+r.body;return ln(r.language,i)}):null}function Bn(e,t){let n=cx(e,t);if(!n)return null;let r=pt(n);if(!r)return null;let i=lx(n);return{calleeLeaf:r,calleeQualifier:i?ax(n):void 0,calleeText:n.text,memberAccess:i,line:e.startPosition.row}}function ax(e){return(e.childForFieldName("object")??e.childForFieldName("value")??e.namedChild(0)??void 0)?.text||void 0}function cx(e,t){if(t==="rust")return e.type==="call_expression"?e.childForFieldName("function")??e.namedChild(0):e.type==="macro_invocation"?e.childForFieldName("macro")??e.namedChild(0):null;if(t==="python")return e.type!=="call"?null:e.childForFieldName("function")??e.namedChild(0);if(t==="typescript"||t==="tsx"||t==="javascript"){if(e.type==="call_expression")return e.childForFieldName("function")??e.namedChild(0);if(e.type==="new_expression")return e.childForFieldName("constructor")??e.namedChild(0)}return null}function lx(e){switch(e.type){case"field_expression":case"member_expression":case"attribute":return!0;default:return!1}}function pt(e){switch(e.type){case"identifier":case"type_identifier":case"field_identifier":case"property_identifier":case"private_property_identifier":case"shorthand_property_identifier":return e.text.replace(/^#/u,"");case"field_expression":case"member_expression":case"attribute":{let t=e.namedChild(e.namedChildCount-1);return t?pt(t):null}case"generic_function":{let t=e.childForFieldName("function")??e.namedChild(0);return t?pt(t):null}case"scoped_identifier":{let t=e.childForFieldName("name")??e.namedChild(e.namedChildCount-1);return t?pt(t):null}case"super":case"self":case"this":return null;default:return null}}function Rr(e){return e.type==="comment"||e.type==="line_comment"||e.type==="block_comment"}var Rd=["function_declaration","generator_function_declaration","method_definition","method_signature","function_signature"],ux=new Set(Rd),dx=[...Rd,"variable_declarator","public_field_definition"],px=["function_item","function_signature_item"],fx=["function_definition"],mx=[],bd=new Set(["arrow_function","function_expression","generator_function"]);function wd(e){return e==="rust"?px:e==="python"?fx:e==="typescript"||e==="tsx"||e==="javascript"?dx:mx}function $n(e,t){let n=yx(e,t);if(n)return{name:n.name,startLine:n.definitionNode.startPosition.row,endLine:n.definitionNode.endPosition.row,paramCount:Ed(n.functionNode),params:xd(n.functionNode),paramsEndLine:vd(n.functionNode),isLiteralPassthrough:Pd(n.functionNode,t)};if(!gx(e.type,t))return null;let r=e.childForFieldName("name")??e.namedChildren.find(i=>i.type==="identifier"||i.type==="property_identifier");return r?{name:r.text,startLine:e.startPosition.row,endLine:e.endPosition.row,paramCount:Ed(e),params:xd(e),paramsEndLine:vd(e),isLiteralPassthrough:Pd(e,t)}:null}function Cd(e){return e.namedChildren.find(t=>t.type==="parameters"||t.type==="formal_parameters")}function xd(e){let t=Cd(e);if(!t)return[];let n=[];for(let r of t.namedChildren){if(Rr(r))continue;if(r.type==="identifier"){n.push({name:r.text,simple:!0});continue}let i=r.namedChildren.some(a=>a.type.endsWith("_modifier"))||/^\s*(?:public|private|protected|readonly|override)\b/.test(r.text),o=r.childForFieldName("pattern");if(!i&&o&&o.type==="identifier"){n.push({name:o.text,simple:!0});continue}let s=r.namedChildren.find(a=>a.type==="identifier");n.push({name:o?.type==="identifier"?o.text:s?.text??"",simple:!1})}return n}function vd(e){let t=Cd(e);return t?t.endPosition.row:e.startPosition.row}function gx(e,t){return t==="rust"?e==="function_item"||e==="function_signature_item":t==="python"?e==="function_definition":t==="typescript"||t==="tsx"||t==="javascript"?ux.has(e):!1}function yx(e,t){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript")return null;if(e.type==="variable_declarator"){let n=e.childForFieldName("name")??e.namedChild(0),r=e.childForFieldName("value")??e.namedChild(1);if(!n||!r)return null;let i=Id(r);return i?{name:n.text,definitionNode:e,functionNode:i}:null}if(e.type==="public_field_definition"){let n=e.childForFieldName("name")??e.namedChild(0),r=e.childForFieldName("value")??e.namedChild(1);if(!n||!r)return null;let i=Id(r);return i?{name:n.text,definitionNode:e,functionNode:i}:null}return null}function Id(e){if(bd.has(e.type))return e;if(e.type!=="call_expression"||(e.childForFieldName("function")??e.namedChild(0))?.type!=="call_expression")return null;let r=((e.childForFieldName("arguments")??e.namedChildren.find(i=>i.type==="arguments"))?.namedChildren??[]).filter(i=>bd.has(i.type));return r.length===1?r[0]:null}function Ed(e){let t=e.namedChildren.find(r=>r.type==="parameters"||r.type==="formal_parameters");if(!t)return 0;let n=0;for(let r of t.namedChildren)Rr(r)||(n+=1);return n}function Pd(e,t){let n=e.namedChildren.find(d=>d.type==="block"||d.type==="statement_block");if(!n)return!1;let r=n.namedChildren.filter(d=>!Rr(d));if(r.length!==1)return!1;let i=r[0],o=null;if(i.type==="return_statement"||i.type==="expression_statement"?o=i.namedChild(0)??null:t==="rust"&&(i.type==="call_expression"||i.type==="macro_invocation")&&(o=i),!o)return!1;let s=t==="python"?"call":"call_expression";if(o.type!==s)return!1;let a=o.namedChildren.find(d=>d.type==="arguments"||d.type==="argument_list");if(!a)return!1;let c=a.namedChildren.filter(d=>!Rr(d)),l=e.namedChildren.find(d=>d.type==="parameters"||d.type==="formal_parameters");if(!l)return!1;let u=[];for(let d of l.namedChildren){if(d.type==="identifier"){u.push(d.text);continue}let p=d.namedChildren.find(f=>f.type==="identifier");p&&u.push(p.text)}if(c.length!==u.length)return!1;for(let d=0;d<u.length;d+=1){let p=c[d];if(p.type!=="identifier"||p.text!==u[d])return!1}return!0}function WD(e,t){return e.filter(n=>n.startLine<=t&&n.endLine>=t).sort((n,r)=>n.endLine-n.startLine-(r.endLine-r.startLine)||n.startLine-r.startLine)[0]??null}var hx=new Set(["identifier","type_identifier","field_identifier"]),Sx=new Set(["identifier"]),bx=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","shorthand_property_identifier_pattern"]),xx=new Set(["rust","python"]),vx=/\{([^{}]*)\}/g,Ix=/\b([A-Za-z_][\w]*)\b/g;function Fd(e,t){return Ex(t).has(e.type)}function Nd(e,t){return xx.has(t)&&e.type==="string_content"}function ua(e){let t=0;for(let r of e.values()){let i=r[r.length-1];i!==void 0&&i>t&&(t=i)}let n=new Array(t+1);for(let r=0;r<=t;r+=1)n[r]=new Set;for(let[r,i]of e)for(let o of i)n[o].add(r);return n}function Ex(e){return e==="rust"?hx:e==="python"?Sx:bx}function Td(e,t){let n=e.startPosition.row;for(let r of e.text.matchAll(vx)){let i=r[1]??"";for(let o of i.matchAll(Ix))o[1]&&t(o[1],n)}}var Px=[/\bdefault\s*=\s*"([^"]+)"/g,/\bwith\s*=\s*"([^"]+)"/g,/\bserialize_with\s*=\s*"([^"]+)"/g,/\bdeserialize_with\s*=\s*"([^"]+)"/g,/\bskip_serializing_if\s*=\s*"([^"]+)"/g,/\bgetter\s*=\s*"([^"]+)"/g,/\brename_all_with\s*=\s*"([^"]+)"/g,/\bschema_with\s*=\s*"([^"]+)"/g],Rx=/^#!?\[\s*serde\s*\(/,wx=/^#!?\[\s*schemars\s*\(/,Cx=/^#!?\[\s*validate\s*\(/,Fx=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function kd(e,t,n){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript"||e.type!=="call_expression")return;let r=e.childForFieldName("function")??e.namedChild(0);if(!r)return;let i=pt(r);if(!i||!Fx.has(i))return;let o=e.namedChildren.find(c=>c.type==="arguments");if(!o)return;let s=o.namedChild(0);if(!s||s.type!=="string")return;let a=s.namedChildren.find(c=>c.type==="string_fragment");a&&n.add(a.text)}function _d(e,t){let n=Rx.test(e),r=wx.test(e),i=Cx.test(e);if(!(!n&&!r&&!i))for(let o of Px){o.lastIndex=0;let s;for(;(s=o.exec(e))!==null;){let a=s[1],c=a.split("::").pop()??a;c==="is_none"&&/\bOption\b/.test(a)||c==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(a)||c&&t.add(c)}}}function Ld(e,t){let n=new Map,r=(s,a)=>{if(s===a)return;let c=n.get(s);c||(c=new Set,n.set(s,c)),c.add(a)},i=t==="python"?new Set(["identifier"]):new Set(["type_identifier"]),o=(s,a)=>{let c=l=>{i.has(l.type)&&l.text!==a&&r(l.text,a);for(let u of l.children)c(u)};for(let l of s.children)c(l)};if(t==="rust")for(let s of e.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let a=s.namedChildren.find(l=>l.type==="type_identifier")?.text;if(!a)continue;let c=s.namedChildren.find(l=>l.type==="field_declaration_list"||l.type==="enum_variant_list"||l.type==="ordered_field_declaration_list");c&&o(c,a),s.type==="type_item"&&o(s,a)}else if(t==="python")for(let s of e.rootNode.descendantsOfType("class_definition")){let a=s.namedChildren.find(u=>u.type==="identifier")?.text;if(!a)continue;let c=s.childForFieldName("superclasses");c&&o(c,a);let l=s.namedChildren.find(u=>u.type==="block");if(l)for(let u of l.descendantsOfType("type"))for(let d of u.descendantsOfType("identifier"))d.text!==a&&r(d.text,a)}else for(let s of e.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let a=s.namedChildren.find(c=>c.type==="type_identifier")?.text;a&&o(s,a)}return n}var Nx=new Map([["defn","function"],["defn-","function"],["defmacro","macro"],["defmacro-","macro"],["defmethod","method"]]),da=new Set(["catch","comment","def","defprotocol","defrecord","deftype","defmethod","defmacro","defmacro-","defn","defn-","do","doseq","dotimes","fn","for","if","let","loop","ns","quote","recur","throw","try","extend-protocol","extend-type","when","when-let","when-not"]);function Dd(e){let t=[],n=[],r=[],i=new Map,o=[],s=0,a=0,c=(l,u)=>{let d=i.get(l);if(!d){i.set(l,[u]);return}d[d.length-1]!==u&&d.push(u)};for(;a<e.length;){let l=e[a];if(l===`
109
- `){s+=1,a+=1;continue}if(/\s|,/.test(l)){a+=1;continue}if(l===";"){a=Hi(e,a);continue}if(l==='"'){let m=Cr(e,a,s);s=m.line,a=m.index;continue}if(l==="("||l==="["||l==="{"){o.push({kind:l,startLine:s,endLine:s,headTokens:[],tokens:[],children:[]}),a+=1;continue}if(l===")"||l==="]"||l==="}"){let m=o.pop();m&&(m.endLine=s,Tx(m,{callables:t,callSites:n,clojureMembers:r,recordIdentifier:c}),o[o.length-1]?.children.push(m)),a+=1;continue}if(pa(l)){a+=1;continue}let u=s,d=a;for(;a<e.length&&!fa(e[a]);)a+=1;let p=e.slice(d,a);if(!p)continue;let f={text:p,line:u};kx(o[o.length-1],f),c(De(p),u)}return{language:"clojure",callables:t,callSites:n,clojureMembers:r,typeContainerMap:new Map,identifierLineMap:i,identifiersByLine:Ox(i),fileIdentifiers:new Set(i.keys()),rustAttrReferencedNames:new Set,crossLanguageDispatchNames:new Set}}function Tx(e,t){if(e.kind!=="("||e.headTokens.length===0)return;let n=e.headTokens[0],r=De(n.text),i=Nx.get(n.text);if(i){let s=e.headTokens[1];if(s){let a=De(s.text);t.recordIdentifier(a,s.line),t.callables.push({name:a,startLine:e.startLine,endLine:e.endLine,paramCount:0,params:[],paramsEndLine:s.line,isLiteralPassthrough:!1,clojureKind:i})}}if(_x(e,t),!r||da.has(n.text)||da.has(r)||r.startsWith(":"))return;let o=Ax(n.text);t.callSites.push({calleeLeaf:o.leaf,calleeQualifier:o.qualifier,calleeText:o.text,memberAccess:!1,line:n.line})}function kx(e,t){e&&(e.headTokens.length<2&&e.headTokens.push(t),e.tokens.length<200&&e.tokens.push(t))}function _x(e,t){let n=De(e.tokens[0]?.text??"");if(n==="defprotocol"){let r=De(e.tokens[1]?.text??"");if(!r)return;for(let i of Ui(e))wr(t,r,"protocol",i,"protocol-method");return}if(n==="defrecord"||n==="deftype"){let r=De(e.tokens[1]?.text??"");if(!r)return;let i=n==="defrecord"?"record":"type",o=n==="defrecord"?"record-method":"type-method";for(let s of Ui(e))wr(t,r,i,s,o);return}if(n==="extend-type"){let r=De(e.tokens[1]?.text??"");if(!r)return;for(let i of Ui(e))wr(t,r,"extension",i,"extension-method");return}if(n==="extend-protocol"){let r=De(e.tokens[1]?.text??"");for(let i of Ui(e)){r&&wr(t,r,"extension",i,"extension-method");let o=Dx(e,i.startLine);o&&o!==r&&wr(t,o,"extension",i,"extension-method")}}}function Ui(e){return e.children.filter(Lx)}function Lx(e){if(e.kind!=="(")return!1;let t=De(e.tokens[0]?.text??"");return!!(t&&!da.has(t)&&!t.startsWith(":"))}function wr(e,t,n,r,i){let o=r.tokens[0],s=De(o?.text??"");!o||!s||(e.recordIdentifier(s,o.line),e.clojureMembers.push({ownerName:t,ownerKind:n,memberName:s,memberKind:i,startLine:r.startLine,endLine:r.endLine}))}function Dx(e,t){let n=null;for(let r=2;r<e.tokens.length;r+=1){let i=e.tokens[r];if(i.line>t)break;let o=De(i.text);o&&!o.startsWith(":")&&(n=o)}return n}function De(e){return e.replace(/^#?['`~@]+/,"").split("/").pop()?.replace(/^\./,"")??""}function Ax(e){let t=e.replace(/^#?['`~@]+/,""),n=t.lastIndexOf("/"),r=De(t);if(n<=0)return{leaf:r,text:t};let i=t.slice(0,n);return{leaf:r,qualifier:i,text:t}}function Hi(e,t){let n=t;for(;n<e.length&&e[n]!==`
110
- `;)n+=1;return n}function Cr(e,t,n){let r=t+1,i=n;for(;r<e.length;){let o=e[r];if(o==="\\"){r+=2;continue}if(o===`
111
- `&&(i+=1),r+=1,o==='"')break}return{index:r,line:i}}function pa(e){return e==="'"||e==="`"||e==="~"||e==="@"||e==="^"||e==="#"}function fa(e){return/\s|,/.test(e)||e==="("||e===")"||e==="["||e==="]"||e==="{"||e==="}"||e==='"'||e===";"}function Ox(e){let t=[];for(let[n,r]of e)for(let i of r)t[i]??=new Set,t[i].add(n);return t}var Ad=6,Mx=zt("source-facts",{clearGroups:["whole-project","source-file"]}),ma=$e({kind:"source-facts",invalidation:Ie("source-facts"),serialize:$x,deserialize:Gx});function le(e,t){return ga(e,t).facts}function ga(e,t){let n=R(e,t);if(!n)return{facts:null};let r=jx(e,t,n);return r?Mx.get(e,t,n,()=>Bx(e,t,r,n)):{facts:null}}function jx(e,t,n){return Ye(t)?Er(e,t,n)?.language??null:ne(t)}function Bx(e,t,n,r){let i=Ke(e,t,r),o=ma.read(e,t,i);if(o&&o.language===n)return{facts:o};if(n==="clojure"){let c=Dd(r);return ma.write(e,t,i,c),{facts:c}}let s=D(e,t);if(!s)return{facts:null,unavailable:{language:n,reason:"parser-unavailable"}};let a=zx(s,n);return ma.write(e,t,i,a),{facts:a}}function $x(e){let t={version:Ad,language:e.language,callables:e.callables,callSites:e.callSites,clojureMembers:e.clojureMembers,typeContainerMap:[...e.typeContainerMap.entries()].map(([n,r])=>[n,[...r]]),identifierLineMap:[...e.identifierLineMap.entries()],rustAttrReferencedNames:[...e.rustAttrReferencedNames],crossLanguageDispatchNames:[...e.crossLanguageDispatchNames]};return JSON.stringify(t)}function Gx(e){try{let t=JSON.parse(e);if(t.version!==Ad||t.language==="clojure"&&(t.clojureMembers===void 0||t.callSites.some(r=>r.calleeText===void 0)))return null;let n=new Map(t.identifierLineMap);return{language:t.language,callables:t.callables,callSites:t.callSites,clojureMembers:t.clojureMembers??[],typeContainerMap:new Map(t.typeContainerMap.map(([r,i])=>[r,new Set(i)])),identifierLineMap:n,identifiersByLine:ua(n),fileIdentifiers:new Set(n.keys()),rustAttrReferencedNames:new Set(t.rustAttrReferencedNames),crossLanguageDispatchNames:new Set(t.crossLanguageDispatchNames)}}catch{return null}}function Vx(e,t,n,r){let i=le(e,t);return i?Wx(i,n,r)?.isLiteralPassthrough??!0:!0}function qx(e,t){return t.relativePath.includes(".clj-kondo/hooks/")?!0:le(e,t.relativePath)?.callables.find(r=>r.startLine===t.startLine&&r.endLine===t.endLine)?.clojureKind==="macro"}function Wx(e,t,n){return e.callables.find(r=>r.startLine===t&&r.endLine===n)??null}function zx(e,t){let n=[],r=[],i=new Set,o=new Set,s=new Map,a=(l,u)=>{let d=s.get(l);if(!d){s.set(l,[u]);return}d[d.length-1]!==u&&d.push(u)},c=l=>{let u=$n(l,t);u&&n.push(u);let d=Bn(l,t);d&&r.push(d),kd(l,t,o),t==="rust"&&(l.type==="attribute_item"||l.type==="inner_attribute_item")&&_d(l.text,i),Fd(l,t)&&a(l.text,l.startPosition.row),Nd(l,t)&&Td(l,a);for(let p of l.children)c(p)};return c(e.rootNode),{language:t,callables:n,callSites:r,clojureMembers:[],typeContainerMap:Ld(e,t),identifierLineMap:s,identifiersByLine:ua(s),fileIdentifiers:new Set(s.keys()),rustAttrReferencedNames:i,crossLanguageDispatchNames:o}}var Od=new Set(["rust","typescript","tsx","javascript","python","clojure"]),Ux=new Set(["rust","typescript","tsx","javascript","python"]);function Fr(e,t){let n=le(e,t);return!n||!Od.has(n.language)?null:n.callables.map(r=>({name:r.name,startLine:r.startLine,endLine:r.endLine}))}function ya(e,t){if(!Ux.has(t))return null;let n=[];for(let r of e.descendantsOfType([...wd(t)])){let i=$n(r,t);i&&n.push({name:i.name,startLine:i.startLine,endLine:i.endLine})}return n}function Hx(e,t){let n=le(e,t);return!n||!Od.has(n.language)?null:n.callSites}function Kx(e,t){return le(e,t)?.typeContainerMap??new Map}import{createRequire as Xx}from"module";var Jx=new Set(["children","className","data","e","err","error","ev","event","false","id","idx","index","item","key","null","props","res","result","state","style","true","undefined","val","value"]);function Ki(e){return e.length<=2||Jx.has(e)}function Ji(e,t){return e.split(t).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}var Yx=wt("vue-template-facts"),Qx=Xx(import.meta.url),Zx;function Nr(){return Zx??=Qx("@vue/compiler-dom")}var ev=new Set(["component","keep-alive","slot","suspense","teleport","template","transition","transition-group"]),tv=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]),nv=new Set(["div","span","template"]),rv=new Set(["as","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","false","finally","for","from","function","if","import","in","instanceof","let","new","null","of","return","super","switch","this","throw","true","try","typeof","undefined","var","void","while","with","yield"]);function Xi(e,t){let n=t.replace(/\\/g,"/"),r=R(e,n);return Yx.get(e,n,r,()=>iv(n,jn(e,n).template))}function iv(e,t){let n={relativePath:e,template:t?{startLine:t.startLine,endLine:t.endLine}:null,componentTags:[],nativeTags:[],builtinTags:[],props:[],events:[],directives:[],slots:[],expressionIdentifiers:[],structuralTokens:[]};if(!t)return n;let r;try{r=Nr().parse(t.body,{comments:!1})}catch{return n}let i=new Set,o=s=>{s.trim()&&i.add(s)};return jd(r.children,t.startLine,n,o),n.structuralTokens=[...i].sort(),n}function jd(e,t,n,r){for(let i of e)if(i.type===Nr().NodeTypes.ELEMENT)ov(i,t,n,r),jd(i.children,t,n,r);else if(i.type===Nr().NodeTypes.INTERPOLATION){r("interpolation");let o=ha(i.content);o&&Bd(o,t,i.loc.start.line,n,r)}}function ov(e,t,n,r){let i=pv(e.tag),o={tag:e.tag,normalized:i,kind:dv(e),startLine:Gn(t,e.loc.start.line),endLine:Gn(t,e.loc.end.line)};o.kind==="component"?(n.componentTags.push(o),r(`component:${i}`)):o.kind==="builtin"?(n.builtinTags.push(o),r(`builtin:${i}`)):(n.nativeTags.push(o),nv.has(e.tag)||r(`native:${e.tag}`));for(let s of e.props)sv(s,t,n,r)}function sv(e,t,n,r){if(e.type===Nr().NodeTypes.ATTRIBUTE){let a=e.value?.content??null,c=Md("prop",e.name,a,t,e.loc.start.line,e.loc.end.line);n.props.push(c),r(`prop:${e.name}`);return}let i=cv(e),o=ha(e.exp),s=Md(av(e.name),i,o,t,e.loc.start.line,e.loc.end.line);switch(s.kind){case"prop":n.props.push(s),r(`prop:${i}`);break;case"event":n.events.push(s),r(`event:${i}`);break;case"slot":n.slots.push(s),r(`slot:${i}`);break;case"directive":n.directives.push(s),r(`directive:${i}`);break}o&&Bd(o,t,e.loc.start.line,n,r)}function Md(e,t,n,r,i,o){return{kind:e,name:t,value:n,startLine:Gn(r,i),endLine:Gn(r,o)}}function av(e){switch(e){case"bind":case"model":return"prop";case"on":return"event";case"slot":return"slot";default:return"directive"}}function cv(e){let t=ha(e.arg);return t||e.name}function ha(e){if(!e)return null;let t=("content"in e&&typeof e.content=="string"?e.content:e.loc.source).trim();return t||null}function Bd(e,t,n,r,i){for(let o of lv(e)){let s={name:o,startLine:Gn(t,n),endLine:Gn(t,n)};r.expressionIdentifiers.push(s),i(`id:${o}`)}}function lv(e){let t=new Set,n=uv(e),r=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,i;for(;i=r.exec(n);){let o=i[0];rv.has(o)||Ki(o)||/^[A-Z_]+$/.test(o)||t.add(o)}return[...t].sort()}function uv(e){return e.replace(/\/\*[\s\S]*?\*\//g," ").replace(/\/\/.*$/gm," ").replace(/`(?:\\[\s\S]|\$\{([^}]*)\}|[^`\\])*`/g,(t,n)=>n??" ").replace(/'(?:\\[\s\S]|[^'\\])*'/g," ").replace(/"(?:\\[\s\S]|[^"\\])*"/g," ")}function dv(e){let t=e.tag;return e.tagType===Nr().ElementTypes.COMPONENT?"component":ev.has(t)?"builtin":tv.has(t)?"native":/^[A-Z]/.test(t)||t.includes("-")?"component":"native"}function pv(e){return Ji(e,/[-_:]/)}function Gn(e,t){return e+Math.max(0,t-1)}var fv=new Set(["ref","shallowRef","reactive","computed","watch","watchEffect"]),mv=new Set(["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured"]),gv=new Set(["axios","fetch","runRequest","useAsyncData","useFetch","useResource"]),yv=new Set(["defineEmits","defineExpose","defineModel","defineOptions","defineProps","withDefaults"]),hv=new Set(["catch","for","function","if","return","switch","while"]);function Qi(e){let t={imports:[],functions:[],calls:[],composables:[],stores:[],reactivity:[],lifecycle:[],requests:[],macros:[],lineCount:0,externalLineCount:0,externalScriptPaths:[],unresolvedScripts:[]};for(let n of e.scripts){t.lineCount+=un(n),n.external&&(t.externalLineCount+=un(n),t.externalScriptPaths.push(n.sourcePath));for(let i of n.errors)t.unresolvedScripts.push({sourcePath:n.sourcePath,reason:i});if(!n.body||!n.astLanguage){n.astLanguage||t.unresolvedScripts.push({sourcePath:n.sourcePath,reason:`Unsupported Vue script language: ${n.lang??"unknown"}`});continue}t.imports.push(...vv(n));let r=ln(n.astLanguage,n.body);r?bv(n,r.rootNode,t):xv(n,t)}return Sv(t),t.externalScriptPaths=Gd(t.externalScriptPaths),t}function Sv(e){e.composables=Vn(e,"composable"),e.stores=Vn(e,"store"),e.reactivity=Vn(e,"reactivity"),e.lifecycle=Vn(e,"lifecycle"),e.requests=Vn(e,"request"),e.macros=Vn(e,"macro")}function Vn(e,t){return Gd(e.calls.filter(n=>n.categories.includes(t)).map(n=>n.name))}function bv(e,t,n){let r=new Set,i=new Set,o=s=>{let a=$n(s,e.astLanguage);if(a){let l=`${a.name}:${a.startLine}:${a.endLine}`;i.has(l)||(i.add(l),n.functions.push({name:a.name,sourcePath:e.sourcePath,startLine:e.startLine+a.startLine,endLine:e.startLine+a.endLine,setup:e.setup}))}let c=Bn(s,e.astLanguage);if(c){let l=`${c.calleeLeaf}:${c.line}`;r.has(l)||(r.add(l),n.calls.push({name:c.calleeLeaf,sourcePath:e.sourcePath,line:e.startLine+c.line,categories:$d(c.calleeLeaf),setup:e.setup}))}for(let l of s.children)o(l)};o(t)}function xv(e,t){for(let n of e.body.matchAll(/\b([A-Za-z_$][\w$]*)\s*\(/g)){let r=n[1];!r||hv.has(r)||t.calls.push({name:r,sourcePath:e.sourcePath,line:e.startLine+Yi(e.body,n.index??0),categories:$d(r),setup:e.setup})}for(let n of e.body.matchAll(/\bfunction\s+([A-Za-z_$][\w$]*)\b/g)){let r=n[1];if(!r)continue;let i=e.startLine+Yi(e.body,n.index??0);t.functions.push({name:r,sourcePath:e.sourcePath,startLine:i,endLine:i,setup:e.setup})}for(let n of e.body.matchAll(/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:async\s*)?(?:function\b|\([^)]*\)\s*=>|[A-Za-z_$][\w$]*\s*=>)/g)){let r=n[1];if(!r)continue;let i=e.startLine+Yi(e.body,n.index??0);t.functions.push({name:r,sourcePath:e.sourcePath,startLine:i,endLine:i,setup:e.setup})}}function vv(e){let t=[];for(let n of e.body.matchAll(/\bimport\s+(?:type\s+)?([^'";]+?)\s+from\s+['"]([^'"]+)['"]/g)){let r=n[1]?.trim(),i=n[2];if(!r||!i)continue;let o=e.startLine+Yi(e.body,n.index??0);for(let s of Iv(r))t.push({local:s,source:i,sourcePath:e.sourcePath,line:o,setup:e.setup})}return t}function Iv(e){let t=[],r=e.split(",").map(s=>s.trim()).filter(Boolean)[0];r&&!r.startsWith("{")&&!r.startsWith("*")&&t.push(r);let i=/\{([^}]*)\}/.exec(e)?.[1];if(i)for(let s of i.split(",")){let a=s.trim();if(!a)continue;let c=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(a)?.[1];t.push(c??a.replace(/^type\s+/,"").trim())}let o=/\*\s+as\s+([A-Za-z_$][\w$]*)/.exec(e)?.[1];return o&&t.push(o),t.filter(s=>/^[A-Za-z_$][\w$]*$/.test(s))}function $d(e){let t=["call"];return/^use[A-Z0-9_]/.test(e)&&t.push("composable"),/^use[A-Z0-9_].*Store$/.test(e)&&t.push("store"),fv.has(e)&&t.push("reactivity"),mv.has(e)&&t.push("lifecycle"),gv.has(e)&&t.push("request"),yv.has(e)&&t.push("macro"),t}function Yi(e,t){let n=0;for(let r=0;r<t&&r<e.length;r+=1)e.charCodeAt(r)===10&&(n+=1);return n}function Gd(e){return[...new Set(e)].sort()}var Ev=new Set(["in","key","of"]),Pv=new Set(["computed","defineEmits","defineProps","reactive","ref","watch","watchEffect"]),Rv=wt("vue-component-behavior-profiles");function Vd(e,t={}){let n=ye(e,{extensions:[".vue"]}).filter(i=>!t.scope||i.includes(t.scope)).sort();return(typeof t.scanLimit=="number"&&t.scanLimit>0?n.slice(0,t.scanLimit):n).map(i=>Sa(e,i)).filter(i=>(t.minTemplateTokens===void 0||i.templateTokens.size>=t.minTemplateTokens)&&(t.minBehaviorTokens===void 0||i.behaviorTokens.size>=t.minBehaviorTokens))}function Sa(e,t){let n=t.replace(/\\/g,"/"),r=R(e,n),i=Rv.get(e,n,r,()=>wv(e,n,r));return Fv(i)}function wv(e,t,n){let r=jn(e,t),i=Xi(e,t),o=Qi(r),s=kv(i),a=i.expressionIdentifiers.map(y=>y.name).filter(y=>!s.includes(y)).filter((y,I,h)=>h.indexOf(y)===I).sort(),c=i.componentTags.map(y=>y.normalized).filter((y,I,h)=>h.indexOf(y)===I).sort(),l=n?n.split(`
112
- `).length:0,u=un(r.template),d=o.lineCount,p=r.styles.reduce((y,I)=>y+un(I),0),f=r.customBlocks.reduce((y,I)=>y+un(I),0),{lines:m,paths:g}=Cv(e,t,o);return{file:t,sfc:r,templateFacts:i,scriptFacts:o,templateTokens:new Set(i.structuralTokens),behaviorTokens:Tv(i,o,a),templateBindingNames:a,templateLocalNames:s,componentNames:c,sfcLines:l,totalLines:l+o.externalLineCount,templateLines:u,scriptLines:d,styleLines:p,externalScriptLines:o.externalLineCount,externalScriptPaths:o.externalScriptPaths,customBlockLines:f,delegatedComposableLines:m,delegatedComposablePaths:g}}function Cv(e,t,n){let r=new Set;for(let s of n.composables){let a=n.imports.find(l=>l.local===s);if(!a)continue;let c=Xe(e,a.sourcePath,a.source);!c||c===t||r.add(c)}let i=[...r].sort();return{lines:i.reduce((s,a)=>{let c=R(e,a);return s+(c?c.split(`
113
- `).length:0)},0),paths:i}}function Fv(e){let t=Nv(e.scriptFacts);return{...e,scriptFacts:t,templateTokens:new Set(e.templateTokens),behaviorTokens:new Set(e.behaviorTokens),templateBindingNames:[...e.templateBindingNames],templateLocalNames:[...e.templateLocalNames],componentNames:[...e.componentNames],externalScriptPaths:t.externalScriptPaths,delegatedComposablePaths:[...e.delegatedComposablePaths]}}function Nv(e){return{...e,imports:e.imports.map(t=>({...t})),functions:e.functions.map(t=>({...t})),calls:e.calls.map(t=>({...t,categories:[...t.categories]})),composables:[...e.composables],stores:[...e.stores],reactivity:[...e.reactivity],lifecycle:[...e.lifecycle],requests:[...e.requests],macros:[...e.macros],externalScriptPaths:[...e.externalScriptPaths],unresolvedScripts:e.unresolvedScripts.map(t=>({...t}))}}function Tv(e,t,n){let r=new Set;for(let i of t.composables)r.add(`composable:${i}`);for(let i of t.stores)r.add(`store:${i}`);for(let i of t.reactivity)r.add(`reactivity:${i}`);for(let i of t.lifecycle)r.add(`lifecycle:${i}`);for(let i of t.requests)r.add(`request:${i}`);for(let i of t.macros)r.add(`macro:${i}`);for(let i of t.functions){if(Pv.has(i.name))continue;r.add(`function:${i.name}`);let o=/^[a-z]+/.exec(i.name)?.[0]??null;o&&o.length>2&&o!==i.name&&r.add(`function-verb:${o}`)}for(let i of e.events)r.add(`template-event:${i.name}`);for(let i of n)r.add(`template-binding:${i}`);return r}function kv(e){let t=new Set;for(let n of e.directives)if(n.name==="for"&&n.value)for(let r of _v(n.value))t.add(r);for(let n of e.slots)if(n.value)for(let r of qd(n.value))t.add(r);return[...t].sort()}function _v(e){let t=/^(.*?)\s+(?:in|of)\s+/.exec(e.trim());return t?qd(t[1]??""):[]}function qd(e){let t=[];for(let n of e.matchAll(/\b[A-Za-z_$][\w$]*\b/g)){let r=n[0];Ev.has(r)||t.push(r)}return t}import{extname as Lv}from"path";var Dv=[".tsx",".jsx"],Wd=new Set(["useActionState","useCallback","useContext","useDebugValue","useDeferredValue","useEffect","useId","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useOptimistic","useReducer","useRef","useState","useSyncExternalStore","useTransition"]),Av=new Set(["useEffect","useInsertionEffect","useLayoutEffect"]),Ov=new Set(["useActionState","useOptimistic","useReducer","useRef","useState"]),Mv=new Set(["useLocation","useNavigate","useParams","useSearchParams","useTranslation"]),jv=new Set(["axios","fetch","gql","graphql","mutate","query","request","useMutation","useQuery","useSuspenseQuery"]),Bv=new Set(["add","apply","cancel","change","clear","close","create","delete","fetch","filter","handle","load","open","refresh","remove","render","reset","save","select","submit","toggle","update"]),$v=new Set(["aria-hidden","className","clipRule","d","fill","fillRule","height","role","stroke","strokeLinecap","strokeLinejoin","strokeWidth","style","viewBox","width","xmlns"]),Gv=wt("react-component-behavior-profiles"),zd=$e({kind:"react-component-behavior-profiles",invalidation:Ie("react-component-behavior-profiles"),serialize:zv,deserialize:Uv});function Jd(e,t={}){let n=ye(e,{extensions:Dv}).filter(i=>!t.scope||i.includes(t.scope)).sort();return(typeof t.scanLimit=="number"&&t.scanLimit>0?n.slice(0,t.scanLimit):n).flatMap(i=>xa(e,i)).filter(i=>(t.minJsxTokens===void 0||i.jsxTokens.size>=t.minJsxTokens)&&(t.minBehaviorTokens===void 0||i.behaviorTokens.size>=t.minBehaviorTokens))}function xa(e,t){let n=t.replace(/\\/g,"/"),r=R(e,n);return Gv.get(e,n,r,()=>Vv(e,n,r)).map(Wv)}function Vv(e,t,n){let r=Ke(e,t,n),i=zd.read(e,t,r);if(i)return i;let o=qv(e,t);return zd.write(e,t,r,o),o}function qv(e,t){let n=Kv(t);if(!n)return[];let r=D(e,t);if(!r)return[];let i=Sr(e,t).length;return Jv(r.rootNode,n).filter(s=>s.kind==="hook"||va(s.bodyNode)).map(s=>{let a=nI(s.bodyNode),c=aI(s.bodyNode,n);return{file:t,name:s.name,kind:s.kind,startLine:s.node.startPosition.row,endLine:s.node.endPosition.row,loc:Math.max(1,s.node.endPosition.row-s.node.startPosition.row+1),fileLines:i,jsxTokens:a.tokens,behaviorTokens:c.tokens,componentNames:ft(a.componentNames),nativeTags:ft(a.nativeTags),propNames:ft(a.propNames),eventNames:ft(a.eventNames),hookNames:ft(c.hookNames),requestNames:ft(c.requestNames),stateNames:ft(c.stateNames),effectNames:ft(c.effectNames),handlerNames:ft(c.handlerNames)}})}function Wv(e){return{...e,jsxTokens:new Set(e.jsxTokens),behaviorTokens:new Set(e.behaviorTokens),componentNames:[...e.componentNames],nativeTags:[...e.nativeTags],propNames:[...e.propNames],eventNames:[...e.eventNames],hookNames:[...e.hookNames],requestNames:[...e.requestNames],stateNames:[...e.stateNames],effectNames:[...e.effectNames],handlerNames:[...e.handlerNames]}}function zv(e){return JSON.stringify(e.map(t=>({...t,jsxTokens:[...t.jsxTokens],behaviorTokens:[...t.behaviorTokens]})))}function Uv(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=[];for(let r of t){let i=Hv(r);if(!i)return null;n.push(i)}return n}catch{return null}}function Hv(e){if(!kt(e))return null;let{file:t,name:n,kind:r,startLine:i,endLine:o,loc:s,fileLines:a,jsxTokens:c,behaviorTokens:l,componentNames:u,nativeTags:d,propNames:p,eventNames:f,hookNames:m,requestNames:g,stateNames:y,effectNames:I,handlerNames:h}=e;if(typeof t!="string"||typeof n!="string"||r!=="component"&&r!=="hook"||!Zi(i)||!Zi(o)||!Zi(s)||!Zi(a))return null;let P={jsxTokens:ke(c),behaviorTokens:ke(l),componentNames:ke(u),nativeTags:ke(d),propNames:ke(p),eventNames:ke(f),hookNames:ke(m),requestNames:ke(g),stateNames:ke(y),effectNames:ke(I),handlerNames:ke(h)};return Object.values(P).some(w=>w===null)?null:{file:t,name:n,kind:r,startLine:i,endLine:o,loc:s,fileLines:a,jsxTokens:new Set(P.jsxTokens),behaviorTokens:new Set(P.behaviorTokens),componentNames:P.componentNames,nativeTags:P.nativeTags,propNames:P.propNames,eventNames:P.eventNames,hookNames:P.hookNames,requestNames:P.requestNames,stateNames:P.stateNames,effectNames:P.effectNames,handlerNames:P.handlerNames}}function Zi(e){return typeof e=="number"&&Number.isFinite(e)}function Kv(e){let t=Lv(e).toLowerCase();return t!==".tsx"&&t!==".jsx"?null:ne(e)}function Jv(e,t){let n=[],r=new Set,i=o=>{let s=Xv(o);if(s&&(!eI(o)||s.kind==="component")){let a=`${s.name}:${s.node.startIndex}:${s.node.endIndex}`;r.has(a)||(r.add(a),n.push(s))}for(let a of o.namedChildren)i(a)};return(t==="tsx"||t==="javascript")&&i(e),n}function Xv(e){if(e.type==="class_declaration"){let o=ba(e);if(!o||!/^[A-Z]/.test(o))return null;let s=Yv(e);return!s||!Qv(e)&&!va(s)?null:{name:o,kind:"component",node:e,bodyNode:s}}if(e.type==="function_declaration"){let o=ba(e);return!o||!Ud(o)?null:{name:o,kind:Hd(o),node:e,bodyNode:e}}if(e.type!=="variable_declarator")return null;let t=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1),r=Tr(t);if(!r||!n||!Ud(r))return null;let i=Zv(n);return i?{name:r,kind:Hd(r),node:e,bodyNode:i}:null}function Yv(e){for(let t of e.namedChildren)if(t.type==="class_body")for(let n of t.namedChildren){if(n.type!=="method_definition")continue;if((n.childForFieldName("name")??n.namedChild(0))?.text==="render")return n}return null}function Qv(e){return/\b(?:React\.)?(?:Pure)?Component\b/.test(e.text)}function Ud(e){return/^[A-Z]/.test(e)||/^use[A-Z0-9_]/.test(e)}function Hd(e){return/^use[A-Z0-9_]/.test(e)?"hook":"component"}function Zv(e){if(e.type==="arrow_function"||e.type==="function_expression")return e;if(e.type!=="call_expression")return null;let t=tI(e);return t!=="memo"&&t!=="forwardRef"?null:e.namedChildren.find(i=>i.type==="arguments")?.namedChildren.find(i=>i.type==="arrow_function"||i.type==="function_expression")??null}function eI(e){let t=e.parent;for(;t;){if(t.type==="function_declaration"||t.type==="function_expression"||t.type==="arrow_function"||t.type==="method_definition")return!0;t=t.parent}return!1}function ba(e){return Tr(e.childForFieldName("name")??e.namedChild(0))}function tI(e){let t=e.childForFieldName("function")??e.namedChild(0);return t?t.text.split(".").pop()??t.text:null}function va(e){return e.type.startsWith("jsx_")?!0:e.namedChildren.some(va)}function nI(e){let t={tokens:new Set,componentNames:new Set,nativeTags:new Set,propNames:new Set,eventNames:new Set},n=r=>{r.type==="jsx_opening_element"||r.type==="jsx_self_closing_element"?rI(r,t):r.type==="jsx_element"&&r.text.trimStart().startsWith("<>")?t.tokens.add("jsx:fragment"):r.type==="jsx_expression"?iI(r,t):r.type==="jsx_fragment"&&t.tokens.add("jsx:fragment");for(let i of r.children)n(i)};return n(e),t}function rI(e,t){let n=oI(e),r=!1;if(n){let i=Kd(n),o=i==="Fragment"||i==="React.Fragment";r=pI(i)&&!o,o?t.tokens.add("jsx:fragment"):r?(t.componentNames.add(i),t.tokens.add(`component:${i}`)):(t.nativeTags.add(i),t.tokens.add(`native:${i}`))}for(let i of e.namedChildren)if(i.type==="jsx_attribute"){let o=sI(i);if(!o)continue;let s=Kd(o);if(s.startsWith("on")&&s.length>2){let a=s.slice(2).replace(/^[A-Z]/,c=>c.toLowerCase());t.eventNames.add(a),t.tokens.add(`event:${a}`)}else $v.has(s)||(t.propNames.add(s),t.tokens.add(`${r?"prop":"native-prop"}:${s}`))}else i.type==="jsx_spread_attribute"&&t.tokens.add(Xd(i))}function iI(e,t){let n=e.text;/^\{\s*\.\.\./.test(n)&&t.tokens.add(Xd(e)),Yd(e)&&t.tokens.add("jsx:conditional"),(n.includes(".map(")||n.includes(".flatMap("))&&t.tokens.add("jsx:list");for(let r of fI(n))Ki(r)||t.tokens.add(`binding:${r}`)}function Xd(e){let t=/^\{\s*\.\.\.\s*([^}]+)\s*\}$/.exec(e.text)?.[1],n=e.namedChildren.find(o=>o.type!=="comment"),r=t??n?.text??"",i=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.exec(r.trim())?.[0];return i?`prop:spread:${i}`:"prop:spread"}function Yd(e){return e.type==="ternary_expression"||e.type==="conditional_expression"?!0:e.namedChildren.some(Yd)}function oI(e){for(let t of e.namedChildren)if(t.type==="identifier"||t.type==="jsx_identifier"||t.type==="property_identifier"||t.type==="member_expression"||t.type==="jsx_member_expression")return t.text;return/^<\s*([A-Za-z][\w$.]*)/.exec(e.text)?.[1]??null}function sI(e){for(let t of e.namedChildren)if(t.type==="property_identifier"||t.type==="identifier"||t.type==="jsx_identifier")return t.text;return/^([A-Za-z_$][\w$:-]*)/.exec(e.text)?.[1]??null}function aI(e,t){let n={tokens:new Set,hookNames:new Set,requestNames:new Set,stateNames:new Set,effectNames:new Set,handlerNames:new Set},r=i=>{if(i.type==="call_expression"){let o=Bn(i,t);o&&cI(o.calleeLeaf,n)}else if(i.type==="variable_declarator")uI(i,n);else if(i.type==="function_declaration"){let o=ba(i);o&&Qd(o,n)}for(let o of i.namedChildren)r(o)};return r(e),n}function cI(e,t){/^use[A-Z0-9_]/.test(e)&&(t.hookNames.add(e),!Wd.has(e)&&!Mv.has(e)&&t.tokens.add(`hook:${e}`)),Wd.has(e)&&t.tokens.add(`react-hook:${e}`),Av.has(e)&&(t.effectNames.add(e),t.tokens.add(`effect:${e}`)),Ov.has(e)&&t.tokens.add(`state-hook:${e}`),lI(e)&&(t.requestNames.add(e),t.tokens.add(`request:${e}`))}function lI(e){if(jv.has(e))return!0;let t=/^use([A-Z0-9_].*)$/.exec(e)?.[1];return t?/(Query|Mutation|Fetch|Resource)$/.test(t):!1}function uI(e,t){let n=e.childForFieldName("name")??e.namedChild(0),r=e.childForFieldName("value")??e.namedChild(1);if(n?.type==="array_pattern"&&r?.text.includes("useState")){let o=n.namedChildren.find(a=>Tr(a)),s=Tr(o);s&&(t.stateNames.add(s),t.tokens.add(`state:${s}`))}let i=Tr(n);i&&Qd(i,t)}function Qd(e,t){let n=dI(e);!n||!Bv.has(n)||(t.handlerNames.add(e),t.tokens.add(`handler:${e}`),t.tokens.add(`handler-verb:${n}`))}function dI(e){let t=e.startsWith("handle")&&e.length>6?e.slice(6).replace(/^[A-Z]/,n=>n.toLowerCase()):e;return/^[a-z]+/.exec(t)?.[0]??null}function pI(e){return/^[A-Z]/.test(e)||e.includes(".")}function Kd(e){return e.replace(/^this\./,"").replace(/\$/g,".")}function Tr(e){return e&&(e.type==="identifier"||e.type==="property_identifier"||e.type==="shorthand_property_identifier"||/^[A-Za-z_$][\w$]*$/.test(e.text))?e.text:null}function fI(e){let t=[];for(let n of e.matchAll(/\b[A-Za-z_$][\w$]*\b/g)){let r=n[0];t.includes(r)||t.push(r)}return t}function ft(e){return[...e].sort()}function ZA(e){return{capability:(t,n)=>mI(t,n),reactProfiles:(t={})=>Jd(e,t),reactProfilesForFile:t=>xa(e,t),vueProfiles:(t={})=>Vd(e,t),vueProfileForFile:t=>Sa(e,t),vueTemplateFacts:t=>Xi(e,t),vueScriptFacts:t=>Qi(jn(e,t))}}function mI(e,t){let n=e.startsWith("react-")?"react":"vue";if(t===void 0)return{slot:e,available:!0,framework:n};let r=t.replace(/\\/g,"/").toLowerCase();return n==="react"&&!r.endsWith(".tsx")&&!r.endsWith(".jsx")?{slot:e,available:!1,framework:n,reason:"React behavior profiles are only available for .tsx and .jsx files"}:n==="vue"&&!r.endsWith(".vue")?{slot:e,available:!1,framework:n,reason:"Vue behavior facts are only available for .vue files"}:{slot:e,available:!0,framework:n}}function gI(e,t,n={}){let r=le(e,t);if(!r)return[];let i=[];if(n.includeCrossLanguageDispatchNames)for(let o of r.crossLanguageDispatchNames)i.push({name:o,kind:"cross-language-dispatch",occurrences:1});if(n.includeRustAttributeNames&&r.language==="rust")for(let o of r.rustAttrReferencedNames)i.push({name:o,kind:"rust-attribute",occurrences:1});return i}var yI=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]);function Se(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let o=e[i];(o==="{"||o==="["||o==="(")&&n++,(o==="}"||o==="]"||o===")")&&n--,o===","&&n===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function we(e,t){for(let n of e.namedChildren)if(n.type===t)return n;return null}function z(e,t){let n=new Set,r=(i,o)=>{let s=o||t.has(i.type);!s&&yI.has(i.type)&&n.add(i.text);for(let a of i.children)r(a,s)};return r(e.rootNode,!1),n}function qe(e,t,n,r,i,o,s){return{importedName:i,localName:o,sourcePath:s??W(e,r,Ys(t)),kind:"named",used:he(n,o),usedMembers:[]}}function G(e,t,n,r,i="named",o={}){return{importedName:e,localName:t,sourcePath:n,kind:i,used:r.has(t),usedMembers:[],isTypeOnly:o.isTypeOnly}}function mt(e,t,n,r,i="named",o=[],s={}){return{importedName:e,localName:t,sourcePath:n,kind:i,used:r,usedMembers:o,isTypeOnly:s.isTypeOnly}}function dn(e,t){return{importedName:e,localName:null,sourcePath:t,kind:"side-effect",used:!0,usedMembers:[]}}function pn(e,t,n={}){return{importedName:e,localName:n.localName??null,sourcePath:t,kind:"namespace",used:n.used??!0,usedMembers:n.usedMembers??[],isTypeOnly:n.isTypeOnly}}function Ae(e,t,n){let r=[];for(let i of e.matchAll(t)){let o=i[0];if(!o||typeof i.index!="number")continue;let s=Lt(e,i.index,i.index+o.length);for(let a of n(i,s))r.push(a)}return r}function Oe(e,t,n,r,i){let o=Pr(e,t,i)?.tree??null;if(o){let s=n(o);if(s)return s}return r()}function eo(e,t,n,r,i){let o=Pr(e,t,i)?.tree??null,s=ne(t),a=s?n[s]:void 0;return o&&a?a(o):r()}function ep(e,t,n){return Oe(e,t,r=>SI(e,t,r),()=>hI(e,t,n),n)}function hI(e,t,n){return Ae(n,/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm,(r,i)=>{let o=r[1]?.trim();if(!o)return[];let s=Zd(o).replace(/\.[^.]+$/,"");return[mt(o,s,Vi(e,t,o),he(i,s))]})}function SI(e,t,n){let r=z(n,new Set(["preproc_include"])),i=[];for(let o of n.rootNode.descendantsOfType("preproc_include")){let s=null;for(let c of o.namedChildren){if(c.type==="system_lib_string"){s=c.text.replace(/^<|>$/g,"");break}if(c.type==="string_literal"){s=c.namedChildren.find(u=>u.type==="string_content")?.text??c.text.replace(/^"|"$/g,"");break}}if(!s)continue;let a=Zd(s).replace(/\.[^.]+$/,"");i.push(G(s,a,Vi(e,t,s),r))}return i}var bI=new Set([":require",":require-macros",":use"]),Pa=String.raw`A-Za-z0-9_$*+!?.<>=-`;function np(e,t,n){let r=TI(n);if(!r)return[];let i=NI(n,r.start,r.end),o=[];for(let s of r.children.slice(2)){if(s.type!=="list"||s.children.length===0)continue;let a=Me(s.children[0]);if(a){if(bI.has(a)){for(let c of II(s.children.slice(1)))o.push(...vI(e,c,i));continue}if(a===":import")for(let c of PI(s.children.slice(1)))o.push(c)}}return o}function xI(e){return e.type==="list"&&Me(e.children[0])==="ns"}function vI(e,t,n){let r=Qs(e,t.namespace),i=t.alias??t.namespace,o=wI(n,i),s=[{importedName:t.namespace,localName:i,sourcePath:r,kind:"namespace",used:t.refers.length>0||t.referAll||o.length>0||CI(n,t.namespace),usedMembers:o}];t.referAll&&s.push({importedName:"*",localName:null,sourcePath:r,kind:"side-effect",used:!0,usedMembers:[]});for(let a of t.refers)s.push({importedName:a,localName:a,sourcePath:r,kind:"named",used:FI(n,a),usedMembers:[]});return s}function II(e){return e.flatMap(t=>to(t,null))}function to(e,t){if(e.type==="atom")return e.text.startsWith(":")?[]:[{namespace:Ea(t,e.text),alias:null,refers:[],referAll:!1}];if(e.type==="vector")return e.children.length>0&&Me(e.children[0])===null?e.children.flatMap(n=>to(n,t)):EI(e,t);if(e.type==="list"&&e.children.length>0){let n=Me(e.children[0]);return n?!n||n.startsWith(":")?[]:e.children.slice(1).flatMap(r=>to(r,Ea(t,n))):e.children.flatMap(r=>to(r,t))}return[]}function EI(e,t){let n=Me(e.children[0]);if(!n||n.startsWith(":"))return[];let r={namespace:Ea(t,n),alias:null,refers:[],referAll:!1};for(let i=1;i<e.children.length;i+=1){let o=Me(e.children[i]);if(!o?.startsWith(":"))continue;let s=e.children[i+1];if((o===":as"||o===":as-alias")&&s){r.alias=Me(s),i+=1;continue}o===":refer"&&s&&(Me(s)===":all"?r.referAll=!0:(s.type==="vector"||s.type==="list")&&r.refers.push(...s.children.map(Me).filter(RI)),i+=1)}return[r]}function PI(e){let t=[];for(let n of e){if(n.type==="atom"){let i=n.text.split(".").pop()??n.text;t.push(mt(i,i,null,!0));continue}if(n.type!=="vector")continue;let r=Me(n.children[0]);if(r)for(let i of n.children.slice(1)){let o=Me(i);o&&t.push(mt(`${r}.${o}`,o,null,!0))}}return t}function Ea(e,t){return e?`${e}.${t}`:t}function Me(e){return e?.type==="atom"?e.text:null}function RI(e){return!!(e&&!e.startsWith(":"))}function wI(e,t){let n=new Set,r=new RegExp(`${Ra()}${te(t)}\\s*/\\s*([${Pa}]+)`,"g");for(let i of e.matchAll(r)){let o=i[1];o&&n.add(o)}return[...n]}function CI(e,t){return new RegExp(`${Ra()}${te(t)}\\s*/`,"m").test(e)}function FI(e,t){return new RegExp(`${Ra()}${te(t)}(?![${Pa}])`,"m").test(e)}function Ra(){return`(?<![${Pa}])`}function NI(e,t,n){let r="",i=0;for(;i<e.length;){if(i>=t&&i<n){r+=e[i]===`
114
- `?`
115
- `:" ",i+=1;continue}let o=e[i];if(o===";"){let s=Hi(e,i);r+=tp(e.slice(i,s)),i=s;continue}if(o==='"'){let s=Cr(e,i,0).index;r+=tp(e.slice(i,s)),i=s;continue}r+=o,i+=1}return r}function TI(e){let t=0;for(;t<e.length&&(t=wa(e,t),!(t>=e.length));){let n=no(e,t);if(!n){t+=1;continue}if(xI(n.form))return n.form;t=n.index}return null}function no(e,t){let n=wa(e,t);if(e.startsWith("#?@",n)||e.startsWith("#?",n))return kI(e,n);if(e.startsWith("#_",n)){let i=no(e,n+2);return i?{form:{type:"atom",text:"",start:n,end:i.index},index:i.index}:null}for(;pa(e[n]);)n+=1;let r=e[n];return r?r==="("?Ia(e,n,"list",")"):r==="["?Ia(e,n,"vector","]"):r==="{"?Ia(e,n,"map","}"):r==='"'?{form:{type:"atom",text:"",start:n,end:Cr(e,n,0).index},index:Cr(e,n,0).index}:LI(e,n):null}function kI(e,t){let n=e.startsWith("#?@",t)?3:2,r=no(e,t+n);return r?{form:{type:"list",children:r.form.type==="list"||r.form.type==="vector"||r.form.type==="map"?_I(r.form.children):[],start:t,end:r.index},index:r.index}:null}function _I(e){let t=[];for(let n=0;n<e.length;n+=2){let r=Me(e[n]),i=e[n+1];r?.startsWith(":")&&i&&t.push(i)}return t}function Ia(e,t,n,r){let i=[],o=t+1;for(;o<e.length;){if(o=wa(e,o),e[o]===r)return{form:{type:n,children:i,start:t,end:o+1},index:o+1};let s=no(e,o);if(!s){o+=1;continue}s.form.type==="atom"&&s.form.text===""||i.push(s.form),o=s.index}return{form:{type:n,children:i,start:t,end:e.length},index:e.length}}function LI(e,t){let n=t;for(;n<e.length&&!fa(e[n]);)n+=1;return{form:{type:"atom",text:e.slice(t,n),start:t,end:n},index:n}}function wa(e,t){let n=t;for(;n<e.length;){let r=e[n];if(/\s|,/.test(r)){n+=1;continue}if(r===";"){n=Hi(e,n);continue}break}return n}function tp(e){return e.replace(/[^\r\n]/g," ")}function rp(e,t,n){let r=[];for(let i of n.matchAll(/^[ \t]*import\s+['"]([^'"]+)['"](?:\s+as\s+([A-Za-z_]\w*))?[\s\S]*?;$/gm)){let o=i[1]?.trim(),s=i[2]?.trim()??null,a=i[0];if(!o||!a||typeof i.index!="number")continue;let c=Lt(n,i.index,i.index+a.length);r.push({importedName:o,localName:s,sourcePath:qi(e,t,o),kind:s?"namespace":"side-effect",used:s?he(c,s):!0,usedMembers:s?On(c,s):[]})}return r}function ip(e,t,n){let r=[];for(let i of n.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=i[1]?.trim();o&&r.push({specifier:o,sourcePath:qi(e,t,o)})}return r}function op(e,t,n){return eo(e,t,{csharp:r=>AI(e,t,r),vb:r=>DI(e,t,r)},()=>{let r=ad(t)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;return Ae(n,r,(i,o)=>{let s=i[1]?.trim();if(!s)return[];let[a,c]=s.split(/\s*=\s*/),l=!!c,u=(l?c:a)?.trim()??s,d=u.split(".").pop()??u,p=l?a?.trim()??d:d;return[qe(e,t,o,u,d,p,W(e,u,Tt))]})},n)}function DI(e,t,n){let r=z(n,new Set(["imports_statement"])),i=[];for(let o of n.rootNode.descendantsOfType("imports_statement")){let s=o.namedChildren.filter(p=>p.type==="namespace_name");if(s.length===0)continue;let a=s[s.length-1],c=s.length>1?s[0]:null,l=a.text,u=l.split(".").pop()??l,d=c?.text??u;i.push(G(u,d,W(e,l,Tt),r,c?"namespace":"named"))}return i}function AI(e,t,n){let r=z(n,new Set(["using_directive"])),i=[];for(let o of n.rootNode.descendantsOfType("using_directive")){let s=o.namedChildren;if(s.length===0)continue;let a=null,c;s.length>=2&&s[0].type==="identifier"&&(s[1].type==="qualified_name"||s[1].type==="identifier")?(a=s[0],c=s[1]):c=s[s.length-1];let l=c.text,u=l.split(".").pop()??l,d=a?.text??u;i.push(G(u,d,W(e,l,Tt),r,a?"namespace":"named"))}return i}var OI=C("vue-non-script-identifiers",{clearGroups:["whole-project","source-file"]});function sp(e,t){return OI.get(e,t,()=>{let n=new Set,r=R(e,t);if(!r)return n;let o=r.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g,s=>s.replace(/[^\r\n]/g," ")).replace(/<!--[\s\S]*?-->/g,s=>s.replace(/[^\r\n]/g," ")).replace(/\/\*[\s\S]*?\*\//g,s=>s.replace(/[^\r\n]/g," "));for(let s of o.matchAll(/[A-Za-z_$][\w$]*/g))n.add(s[0]);return n})}function Ca(e,t,n){return Oe(e,t,r=>jI(e,t,r),()=>MI(e,t,n),n)}function MI(e,t,n){return JI(n).flatMap(r=>XI(e,t,r.clause,r.specifier,r.start,r.end,n))}function jI(e,t,n){let r=BI(e,t,n),i=[];for(let o of n.rootNode.descendantsOfType("import_statement"))i.push(...$I(e,t,n,o,r));return i}function BI(e,t,n){let r=z(n,new Set(["import_statement"]));if(Ye(t))for(let i of sp(e,t))r.add(i);return r}function $I(e,t,n,r,i){let o=zI(r);if(!o)return[];let s=Xe(e,t,o),a=we(r,"import_clause");return a?GI(n,a,s,i,UI(r.text)):[dn("*",s)]}function GI(e,t,n,r,i){let o=[];for(let s of t.namedChildren)if(s.type==="identifier")o.push(VI(s.text,n,r,i));else if(s.type==="namespace_import"){let a=qI(e,s,n,r,i);a&&o.push(a)}else s.type==="named_imports"&&o.push(...WI(s,n,r,i));return o}function VI(e,t,n,r){return G("default",e,t,n,"default",{isTypeOnly:r})}function qI(e,t,n,r,i){let s=we(t,"identifier")?.text??"";if(!s)return null;let a=KI(e,s);return pn("*",n,{localName:s,usedMembers:a,isTypeOnly:i,used:a.length>0||r.has(s)})}function WI(e,t,n,r){let i=[];for(let o of e.namedChildren){if(o.type!=="import_specifier")continue;let s=o.namedChild(0),a=o.namedChild(1);if(!s)continue;let c=s.text,l=a?.text??c;i.push(G(c,l,t,n,"named",{isTypeOnly:r||HI(o.text)}))}return i}function zI(e){let t=we(e,"string");if(!t)return null;let n=we(t,"string_fragment");return n?n.text:null}function UI(e){return/^\s*import\s+type\b/.test(e)}function HI(e){return/^\s*type\b/.test(e.trim())}function KI(e,t){let n=new Set;for(let r of e.rootNode.descendantsOfType("member_expression")){let i=r.namedChild(0),o=r.namedChild(1);!i||!o||i.type!=="identifier"||i.text!==t||(o.type==="property_identifier"||o.type==="identifier")&&n.add(o.text)}return[...n]}function JI(e){let t=[],n=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(n)){let o=i[0],s=i[1],a=i[2];!o||!a||typeof i.index!="number"||t.push({clause:s,specifier:a,start:i.index,end:i.index+o.length})}let r=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(r)){let o=i[0],s=i[1];!o||!s||typeof i.index!="number"||t.push({clause:null,specifier:s,start:i.index,end:i.index+o.length})}return t.sort((i,o)=>i.start-o.start)}function XI(e,t,n,r,i,o,s){let a=Xe(e,t,r),c=Lt(s,i,o);return n?YI(n).map(u=>({...u,sourcePath:a})).map(u=>{if(u.kind==="namespace"){let d=On(c,u.localName);return pn(u.importedName,u.sourcePath,{localName:u.localName,usedMembers:d,used:d.length>0||he(c,u.localName),isTypeOnly:u.isTypeOnly})}return u.kind==="side-effect"?dn(u.importedName,u.sourcePath):mt(u.importedName,u.localName??"",u.sourcePath,u.localName?he(c,u.localName):!1,u.kind,[],{isTypeOnly:u.isTypeOnly})}):[dn("*",a)]}function YI(e){let t=e.trim(),n=/^type\b/.test(t),r=t.replace(/^type\s+/,""),[i,o]=QI(r),s=[];return i&&s.push(...ap(i,n)),o&&s.push(...ap(o,n)),s}function ap(e,t){let n=e.trim();if(!n)return[];if(n.startsWith("{")){let r=n.slice(1,-1).trim();return r?Se(r).map(i=>{let o=i.trim(),s=t||/^type\b/.test(o),a=o.replace(/^type\s+/,""),[c,l]=a.split(/\s+as\s+/);return{importedName:c.trim(),localName:(l??c).trim(),kind:"named",isTypeOnly:s}}):[]}return n.startsWith("* as ")?[{importedName:"*",localName:n.slice(5).trim(),kind:"namespace",isTypeOnly:t}]:[{importedName:"default",localName:n,kind:"default",isTypeOnly:t}]}function QI(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r==="{"&&t++,r==="}"&&t--,r===","&&t===0)return[e.slice(0,n).trim(),e.slice(n+1).trim()]}return[e.trim(),null]}function Fa(e,t,n){let r=D(e,t);return r?iE(e,t,r):ZI(e,t,n)}function ZI(e,t,n){return[...eE(e,t,n),...tE(e,t,n),...nE(e,t,n)]}function eE(e,t,n){let r=[],i=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of n.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=o[2]??"",c=Se(s).map(d=>rE(d.trim())).filter(d=>!!d),l=qn(n,o.index),u=qn(n,o.index+o[0].length-1);r.push({kind:"named",sourcePath:Xe(e,t,a),names:c,startLine:l,endLine:u})}return r}function tE(e,t,n){let r=[],i=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of n.matchAll(i)){if(typeof o.index!="number")continue;let s=o[2]??"",a=qn(n,o.index),c=qn(n,o.index+o[0].length-1);r.push({kind:"star-as",sourcePath:Xe(e,t,s),names:o[1]?[o[1]]:[],startLine:a,endLine:c})}return r}function nE(e,t,n){let r=[],i=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of n.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=qn(n,o.index),c=qn(n,o.index+o[0].length-1);r.push({kind:"star",sourcePath:Xe(e,t,s),names:[],startLine:a,endLine:c})}return r}function rE(e){if(!e)return null;let t=e.replace(/^type\s+/,"").trim();if(!t)return null;let n=t.match(/^(\w+)\s+as\s+(\w+)$/);if(n)return n[2]??null;let r=t.match(/^(\w+)$/);return r?r[1]??null:null}function qn(e,t){let n=0;for(let r=0;r<t&&r<e.length;r++)e.charCodeAt(r)===10&&n++;return n}function iE(e,t,n){let r=[];for(let i of n.rootNode.descendantsOfType("export_statement")){let o=oE(e,t,i);if(o===void 0)continue;let s=i.startPosition.row,a=i.endPosition.row,c=sE(i,o,s,a);r.push(c)}return r}function oE(e,t,n){let r=we(n,"string");if(!r)return;let i=we(r,"string_fragment");if(i)return Xe(e,t,i.text)}function sE(e,t,n,r){let i=we(e,"export_clause");if(i){let s=[];for(let a of i.namedChildren){if(a.type!=="export_specifier")continue;let c=a.namedChild(0),l=a.namedChild(1);c&&s.push((l??c).text)}return{kind:"named",sourcePath:t,names:s,startLine:n,endLine:r}}let o=we(e,"namespace_export");if(o){let s=o.namedChildren.find(a=>a.type==="identifier"||a.type==="type_identifier")?.text;return{kind:"star-as",sourcePath:t,names:s?[s]:[],startLine:n,endLine:r}}return{kind:"star",sourcePath:t,names:[],startLine:n,endLine:r}}function cp(e,t,n){return eo(e,t,{java:r=>aE(e,t,r),kotlin:r=>cE(e,t,r),scala:r=>lE(e,t,r)},()=>Ae(n,/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm,(r,i)=>{let o=r[1]?.trim();return o?uE(e,t,o,i):[]}),n)}function aE(e,t,n){let r=z(n,new Set(["import_declaration"])),i=[];for(let o of n.rootNode.descendantsOfType("import_declaration")){let s=o.children.some(d=>d.type==="asterisk"),c=o.namedChildren.find(d=>d.type==="scoped_identifier")??o.namedChildren.find(d=>d.type==="identifier");if(!c)continue;let l=c.text;if(s){i.push(pn("*",W(e,l,Re)));continue}let u=l.split(".").pop()??l;i.push(G(u,u,W(e,l,Re),r))}return i}function cE(e,t,n){let r=z(n,new Set(["import_header","import_list"])),i=[];for(let o of n.rootNode.descendantsOfType("import_header")){let s=o.namedChildren.find(f=>f.type==="identifier");if(!s)continue;let a=o.namedChildren.some(f=>f.type==="wildcard_import"),c=o.namedChildren.find(f=>f.type==="import_alias");if(a){i.push(pn("*",W(e,s.text,Re)));continue}let l=s.text,u=l.split(".").pop()??l,p=c?.namedChild(0)?.text??u;i.push(G(u,p,W(e,l,Re),r))}return i}function lE(e,t,n){let r=z(n,new Set(["import_declaration"])),i=[];for(let o of n.rootNode.descendantsOfType("import_declaration")){let s=o.namedChildren.find(d=>d.type==="namespace_selectors"||d.type==="namespace_wildcard"),a=o.namedChildren.filter(d=>d!==s&&(d.type==="identifier"||d.type==="stable_identifier")),c=a.map(d=>d.text).join(".");if(!c)continue;if(s?.type==="namespace_wildcard"){i.push(pn("*",W(e,c,Re)));continue}if(s?.type==="namespace_selectors"){for(let d of s.namedChildren)if(d.type==="arrow_renamed_identifier"){let[p,f]=d.namedChildren;if(!p)continue;let m=p.text,g=f?.text??m;if(m==="_")continue;i.push(G(m,g,W(e,`${c}.${m}`,Re),r))}else if(d.type==="identifier"){let p=d.text;i.push(G(p,p,W(e,`${c}.${p}`,Re),r))}continue}let l=a[a.length-1]?.text??c,u=a.slice(0,-1).map(d=>d.text).join(".")||c;i.push(G(l,l,W(e,u&&a.length>1?`${u}.${l}`:c,Re),r))}return i}function uE(e,t,n,r){if(n.includes("{")&&n.includes("}")){let i=n.slice(0,n.indexOf("{")).replace(/\.$/,"").trim(),o=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim();return Se(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.includes("=>")?a.split(/\s*=>\s*/):a.split(/\s+as\s+/),u=c?.trim();if(!u||u==="_")return[];let d=(l??u.split(".").pop()??u).trim(),p=u==="_"?i:`${i}.${u}`.replace(/\.\./g,".");return[qe(e,t,r,p,u,d)]})}return[qe(e,t,r,n,n.split(".").pop()??n,n.split(".").pop()??n)]}function up(e,t,n){return Oe(e,t,r=>dE(e,t,r),()=>Ae(n,/^[ \t]*use\s+(.+?)\s*;$/gm,(r,i)=>{let o=r[1]?.trim();return o?Se(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.split(/\s+as\s+/i),u=c?.trim()??a,d=u.split("\\").pop()??u,p=(l??d).trim();return[qe(e,t,i,u,d,p,W(e,u.replace(/\\/g,"."),cn))]}):[]}),n)}function dE(e,t,n){let r=z(n,new Set(["namespace_use_declaration"])),i=[],o=(s,a,c)=>{i.push(G(a,c,W(e,s.replace(/\\/g,"."),cn),r))};for(let s of n.rootNode.descendantsOfType("namespace_use_declaration")){let a=s.namedChildren.find(c=>c.type==="namespace_use_group");if(a){let c=s.namedChildren.find(l=>l.type==="namespace_name")?.text??"";for(let l of a.namedChildren){if(l.type!=="namespace_use_clause")continue;let{importedName:u,localName:d,qualified:p}=lp(l,c);u&&o(p,u,d)}continue}for(let c of s.namedChildren){if(c.type!=="namespace_use_clause")continue;let{importedName:l,localName:u,qualified:d}=lp(c,"");l&&o(d,l,u)}}return i}function lp(e,t){let n=e.namedChildren.find(l=>l.type==="qualified_name"),r=e.namedChildren.filter(l=>l.type==="name"),i="";n?i=n.text:r.length>=1&&(i=r[0].text);let o=n&&r.length>0?r[r.length-1]:null,s=i.split("\\").pop()??i,a=o?.text??s,c=t?`${t}\\${i}`:i;return{importedName:s,localName:a,qualified:c}}function pp(e,t,n){return Oe(e,t,r=>pE(e,t,r),()=>mE(n).flatMap(r=>yE(e,t,r,n)),n)}function pE(e,t,n){let r=z(n,new Set(["import_statement","import_from_statement"])),i=[];for(let o of n.rootNode.descendantsOfType("import_statement"))for(let s of o.namedChildren){let a=dp(s);if(!a)continue;let c=An(e,t,a.qualifiedName);i.push({importedName:a.qualifiedName,localName:a.localName,sourcePath:c,kind:"namespace",used:r.has(a.localName),usedMembers:[]})}for(let o of n.rootNode.descendantsOfType("import_from_statement")){let s=o.namedChild(0);if(!s)continue;let a=fE(s);if(a===null)continue;let c=An(e,t,a);for(let l=1;l<o.namedChildCount;l+=1){let u=o.namedChild(l);if(u.type==="wildcard_import"){i.push({importedName:"*",localName:null,sourcePath:c,kind:"side-effect",used:!0,usedMembers:[]});continue}let d=dp(u);d&&i.push({importedName:d.qualifiedName,localName:d.localName,sourcePath:c,kind:"named",used:r.has(d.localName),usedMembers:[]})}}return i}function dp(e){if(e.type==="aliased_import"){let t=e.namedChild(0),n=e.namedChild(1);return!t||!n?null:{qualifiedName:t.text,localName:n.text}}if(e.type==="dotted_name"){let t=e.text;return{qualifiedName:t,localName:t.split(".")[0]??t}}return e.type==="identifier"?{qualifiedName:e.text,localName:e.text}:null}function fE(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let t=we(e,"import_prefix")?.text??"",n=we(e,"dotted_name")?.text??"";return`${t}${n}`}return null}function mE(e){let t=e.split(`
116
- `),n=[],r=0;for(let i=0;i<t.length;i++){let o=t[i],s=o.trimStart(),a=r;if(r+=o.length+1,!s.startsWith("import ")&&!s.startsWith("from "))continue;let c=o,l=a+o.length,u=ia(o);for(;i+1<t.length&&(u>0||c.trimEnd().endsWith("\\"));){i++;let p=t[i];c+=`
117
- ${p}`,l+=1+p.length,u+=ia(p),r+=p.length+1}let d=gE(c);d&&n.push({...d,start:a,end:l})}return n}function gE(e){let t=e.replace(/\\\s*\n/g," ").trim();if(t.startsWith("import "))return{kind:"import",module:null,clause:t.slice(7).trim()};let n=t.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!n)return null;let r=n[2].trim();return r.startsWith("(")&&r.endsWith(")")&&(r=r.slice(1,-1).trim()),{kind:"from",module:n[1],clause:r}}function yE(e,t,n,r){let i=Lt(r,n.start,n.end),o=n.clause.replace(/\n/g," ").trim();if(n.kind==="import")return Se(o).flatMap(c=>{let l=c.trim().replace(/,$/,"");if(!l)return[];let[u,d]=l.split(/\s+as\s+/),p=u.trim(),f=(d??p.split(".")[0]??p).trim(),m=An(e,t,p),g=On(i,f);return[{importedName:p,localName:f,sourcePath:m,kind:"namespace",used:he(i,f)||g.length>0,usedMembers:g}]});let s=n.module?An(e,t,n.module):null,a=[];for(let c of Se(o)){let l=c.trim().replace(/,$/,"");if(!l)continue;if(l==="*"){a.push({importedName:"*",localName:null,sourcePath:s,kind:"side-effect",used:!0,usedMembers:[]});continue}let[u,d]=l.split(/\s+as\s+/),p=(d??u).trim();a.push({importedName:u.trim(),localName:p,sourcePath:s,kind:"named",used:he(i,p),usedMembers:[]})}return a}import{basename as hE}from"path";function fp(e,t,n){return Oe(e,t,r=>bE(e,t,r),()=>SE(e,t,n),n)}function SE(e,t,n){return Ae(n,/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm,(r,i)=>{let o=r[1],s=r[2];if(!o||!s)return[];let a=o==="require_relative"?Gi(e,t,s):null;if(a){let c=mp(s);return[mt(c,c,a,he(i,c))]}return[dn(s,a)]})}function bE(e,t,n){let r=z(n,new Set([])),i=[],o=new Set(["require","require_relative","load"]);for(let s of n.rootNode.descendantsOfType("call")){let a=s.namedChild(0);if(!a||a.type!=="identifier"||!o.has(a.text))continue;let l=s.namedChildren.find(f=>f.type==="argument_list")?.namedChild(0);if(!l||l.type!=="string")continue;let d=l.namedChildren.find(f=>f.type==="string_content")?.text;if(!d)continue;let p=a.text==="require_relative"?Gi(e,t,d):null;if(p){let f=mp(d);i.push(G(f,f,p,r))}else i.push(dn(d,p))}return i}function mp(e){return Ji(hE(e).replace(/\.[^.]+$/,""),/_/)}function gp(e,t,n){return Oe(e,t,r=>xE(e,t,r),()=>Ae(n,/^[ \t]*use\s+(.+?)\s*;$/gm,(r,i)=>{let o=r[1]?.trim();return o?vE(e,t,o,i):[]}),n)}function xE(e,t,n){let r=z(n,new Set(["use_declaration"])),i=[];for(let o of n.rootNode.descendantsOfType("use_declaration")){let s=o.namedChild(0);if(s)for(let a of kr(s,"")){if(!a.importedName||a.importedName==="*")continue;let c=ut(e,t,a.qualifiedName)??ut(e,t,a.qualifiedName.split("::").slice(0,-1).join("::"));i.push(G(a.importedName,a.localName,c,r))}}return i}function kr(e,t){switch(e.type){case"identifier":case"super":case"crate":{let n=e.text;return[{qualifiedName:ro(t,n),importedName:n,localName:n}]}case"self":{let n=t.split("::").filter(Boolean).pop()??"self";return[{qualifiedName:t||"self",importedName:n,localName:n}]}case"scoped_identifier":{let n=e.text,r=n.split("::").pop()??n;return[{qualifiedName:ro(t,n),importedName:r,localName:r}]}case"scoped_use_list":{let n=e.namedChild(0),r=e.namedChild(1);if(!n||!r)return[];let i=ro(t,n.text),o=[];for(let s of r.namedChildren)o.push(...kr(s,i));return o}case"use_list":{let n=[];for(let r of e.namedChildren)n.push(...kr(r,t));return n}case"use_as_clause":{let n=e.namedChild(0),r=e.namedChild(1);if(!n||!r)return[];let i=kr(n,t),o=r.text;return i.map(s=>({...s,localName:o}))}case"use_wildcard":{let n=e.namedChild(0),r=n?n.text:"";return[{qualifiedName:ro(t,`${r}::*`),importedName:"*",localName:"*"}]}default:return[]}}function ro(e,t){return e?t?`${e}::${t}`:e:t}function vE(e,t,n,r){let i=n.trim();if(i.includes("{")&&i.includes("}")){let u=i.slice(0,i.indexOf("{")).replace(/::$/,"").trim(),d=i.slice(i.indexOf("{")+1,i.lastIndexOf("}")).trim();return Se(d).flatMap(p=>{let f=p.trim();if(!f)return[];if(f==="self"){let P=u.split("::").filter(Boolean).pop();return P?[qe(e,t,r,u,P,P)]:[]}let[m,g]=f.split(/\s+as\s+/),y=m?.trim();if(!y)return[];let I=(g??y.split("::").pop()??y).trim(),h=`${u}::${y}`.replace(/::::/g,"::");return[qe(e,t,r,h,y.split("::").pop()??y,I,ut(e,t,u))]})}let[o,s]=i.split(/\s+as\s+/),a=o?.trim()??i,c=(s??a.split("::").pop()??a).trim(),l=ut(e,t,a)??ut(e,t,a.split("::").slice(0,-1).join("::"));return[qe(e,t,r,a,a.split("::").pop()??a,c,l)]}function yp(e,t,n){let r=D(e,t);if(r)return IE(e,t,r);let i=[];for(let o of n.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let s=o[1]?.trim();s&&i.push(...PE(e,t,s))}return i}function IE(e,t,n){let r=[];for(let i of n.rootNode.descendantsOfType("use_declaration")){if(!EE(i))continue;let o=i.namedChildren.find(s=>s.type!=="visibility_modifier");if(o)for(let s of kr(o,""))s.importedName&&r.push(Na(e,t,s.qualifiedName))}return r}function EE(e){for(let t of e.children)if(t.type==="visibility_modifier"&&t.text.startsWith("pub"))return!0;return!1}function PE(e,t,n){let r=n.trim();if(r.includes("{")&&r.includes("}")){let i=r.slice(0,r.indexOf("{")).replace(/::$/,"").trim(),o=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim();return Se(o).flatMap(s=>{let a=s.trim();if(!a||a==="self")return[];let[c]=a.split(/\s+as\s+/),l=`${i}::${c?.trim()??a}`.replace(/::::/g,"::");return[Na(e,t,l)]})}return[Na(e,t,r)]}function Na(e,t,n){return{specifier:n,sourcePath:ut(e,t,n)??ut(e,t,n.split("::").slice(0,-1).join("::"))}}function At({language:e,extensions:t,imports:n,parseImports:r}){return{language:e,extensions:t,capabilities:{imports:n},parseImports:r}}function hp(e,t){let n=t.toLowerCase();for(let r of e)for(let i of r.extensions)if(n.endsWith(i))return r;return null}var RE={language:"javascript",extensions:sn,capabilities:{imports:"ast-with-regex-fallback",reExports:"ast-with-regex-fallback"},parseImports:Ca,parseReExports:Fa},wE=At({language:"python",extensions:Oi,imports:"ast-with-regex-fallback",parseImports:pp}),CE=At({language:"jvm",extensions:Re,imports:"ast-dispatch-with-regex-fallback",parseImports:cp}),FE={language:"rust",extensions:Mi,capabilities:{imports:"ast-with-regex-fallback",exports:"ast-with-regex-fallback"},parseImports:gp,parseExports:yp},NE=At({language:"ruby",extensions:ji,imports:"ast-with-regex-fallback",parseImports:fp}),TE=At({language:"c/cpp",extensions:Bi,imports:"ast-with-regex-fallback",parseImports:ep}),kE=At({language:"dotnet",extensions:Tt,imports:"ast-dispatch-with-regex-fallback",parseImports:op}),_E={language:"dart",extensions:$i,capabilities:{imports:"regex-only",exports:"regex-only"},parseImports:rp,parseExports:ip},LE=At({language:"php",extensions:cn,imports:"ast-with-regex-fallback",parseImports:up}),DE=At({language:"clojure",extensions:Dn,imports:"regex-only",parseImports:np}),Sp=[RE,wE,CE,FE,NE,TE,kE,_E,LE,DE];function io(e){return hp(Sp,e)}function NM(e){return Sp.find(n=>n.language===e)?.capabilities??null}var Ta={clearGroups:["whole-project","source-file"]},AE=C("source-imports",Ta),OE=C("source-exports",Ta),ME=C("source-reexports",Ta),bp=$e({kind:"source-imports",invalidation:Ie("source-imports"),serialize:jE,deserialize:BE}),xp=$e({kind:"source-reexports",invalidation:Ie("source-reexports"),serialize:$E,deserialize:GE});function Ot(e,t){let n=Y(t);return ME.get(e,n,()=>{let r=io(n);if(!r?.parseReExports)return[];let i=R(e,n);if(!i)return[];let o=Ke(e,n,i),s=ta(e),a=xp.read(e,n,o);if(a?.resolutionFingerprint===s)return a.reExports;let c=r.parseReExports(e,n,i);return xp.write(e,n,o,{resolutionFingerprint:s,reExports:c}),c})}function U(e,t){let n=Y(t);return AE.get(e,n,()=>{let r=io(n);if(!r)return[];let i=R(e,n);if(!i)return[];let o=Ke(e,n,i),s=ta(e),a=bp.read(e,n,o);if(a?.resolutionFingerprint===s)return a.imports;let c=r.parseImports(e,n,i);return bp.write(e,n,o,{parserVersion:2,resolutionFingerprint:s,imports:c}),c})}function jM(e,t,n){let r=U(e,t).filter(i=>i.kind==="named"&&i.isTypeOnly!==!0&&i.localName===n&&i.sourcePath!==null);return r.length===1?r[0]:null}function BM(e,t){let n=Y(t);return OE.get(e,n,()=>{let r=io(n);if(!r?.parseExports)return[];let i=R(e,n);return i?r.parseExports(e,n,i):[]})}function jE(e){return JSON.stringify(e)}function BE(e){try{let t=JSON.parse(e);return!kt(t)||t.parserVersion!==2||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.imports)?null:{parserVersion:2,resolutionFingerprint:t.resolutionFingerprint,imports:t.imports}}catch{return null}}function $E(e){return JSON.stringify(e)}function GE(e){try{let t=JSON.parse(e);return!kt(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.reExports)?null:{resolutionFingerprint:t.resolutionFingerprint,reExports:t.reExports}}catch{return null}}var ka=cu({kind:"file-dependency-graph",invalidation:Ie("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:UE}),VE=C("file-dep-graph",{clearGroups:["whole-project"]});function HM(e,t,n){if(n.length===0)return[];let r=new Set(n),i=Wn(e),o=new Set;if(t==="forward")for(let s of r)for(let a of i.get(s)??[])r.has(a)||o.add(a);else for(let[s,a]of i)if(!r.has(s))for(let c of r)a.has(c)&&o.add(s);return[...o].sort()}function Wn(e,t,n={}){let r=n.scipEdges??"all-references",i=n.sourceEdges??"imports-only",o=_a(t,r,i);return VE.get(e,o,()=>{let s=new Set(xe(e,{includeIgnored:!1})),a=Ct(e),c=0,l=0,u=null,d=!1,p=0,f=0,m=null;return ae("file-dep-graph.product",()=>{if(a){let h=ka.read(e,o,a);if(h){d=!0,m=h.construction;let P=zE(h);return c=h.sourceFileCount,l=h.sourceEdgeCount,p=h.scipEdgeCount,f=P.size,u=h.sourceDependencyFingerprint,P}}let g=ae("file-dep-graph.source-imports",()=>{let h=qE(e,s,t,i);return c=h.files.length,l=h.edges.length,u=h.fingerprint,h},()=>({scope:t??null,sourceEdges:i,files:c,edges:l})),y=new Map,I=(h,P)=>oo(e,y,s,h,P);ae("file-dep-graph.scip-edges",()=>{for(let h of XE(e,t,r))p=(p??0)+1,I(h.from_file,h.to_file)},()=>({scope:t??null,edges:p}));for(let h of g.edges)I(h.fromFile,h.toFile);return f=y.size,a&&(m="full",ka.write(e,o,a,{version:2,construction:"full",sourceDependencyFingerprint:g.fingerprint,sourceFileCount:g.files.length,sourceEdgeCount:g.edges.length,scipEdgeCount:p,edgeCount:Ip(y),graph:vp(y)})),y},()=>({scope:t??null,available:a!==null,hit:d,construction:m,files:c,sourceEdges:l,sourceEdgeMode:i,scipEdges:p,graphFiles:f,sourceDependencyFingerprint:u}))})}function KM(e){let t=_a(void 0,"all-references","imports-only"),n=Wn(e);return{cacheKey:t,graph:KE(n)}}function JM(e,t,n){let r=Ct(e);if(!r)return!1;let i=_a(void 0,"all-references","imports-only");if(t.cacheKey!==i)return!1;let o=new Set(xe(e,{includeIgnored:!1})),s=new Set(n),a=new Map;for(let[c,l]of t.graph)if(!(s.has(c)||!o.has(c)))for(let u of l)oo(e,a,o,c,u);for(let c of YE(e,s,"all-references"))oo(e,a,o,c.from_file,c.to_file);for(let c of s)if(o.has(c))for(let l of U(e,c))l.sourcePath&&oo(e,a,o,c,l.sourcePath);return ka.write(e,i,r,{version:2,construction:"carried",sourceDependencyFingerprint:null,sourceFileCount:o.size,sourceEdgeCount:null,scipEdgeCount:null,edgeCount:Ip(a),graph:vp(a)}),!0}function qE(e,t,n,r){let i=[],o=[];for(let s of t)if(!(n&&!s.includes(n))){i.push(s);for(let a of U(e,s))a.sourcePath&&o.push({fromFile:s,toFile:a.sourcePath});if(r==="imports-and-reexports")for(let a of Ot(e,s))a.sourcePath&&o.push({fromFile:s,toFile:a.sourcePath})}return{files:i,edges:o,fingerprint:WE(i,o)}}function WE(e,t){let n=t.map(r=>`${r.fromFile}\0${r.toFile}`).sort();return K(JSON.stringify({files:e,edges:n}))}function _a(e,t,n){return`edge-mode-v4:${t}:${n}:${e??"<all>"}`}function vp(e){return[...e].map(([t,n])=>[t,[...n].sort()]).sort(([t],[n])=>t.localeCompare(n))}function zE(e){return new Map(e.graph.map(([t,n])=>[t,new Set(n)]))}function UE(e){let t=JSON.parse(e);return HE(t)?t:null}function HE(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===2&&(t.construction==="full"||t.construction==="carried")&&(t.sourceDependencyFingerprint===null||typeof t.sourceDependencyFingerprint=="string")&&typeof t.sourceFileCount=="number"&&(t.sourceEdgeCount===null||typeof t.sourceEdgeCount=="number")&&(t.scipEdgeCount===null||typeof t.scipEdgeCount=="number")&&typeof t.edgeCount=="number"&&Array.isArray(t.graph)&&t.graph.every(JE)}function KE(e){return new Map([...e].map(([t,n])=>[t,new Set(n)]))}function Ip(e){let t=0;for(let n of e.values())t+=n.size;return t}function JE(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&Array.isArray(e[1])&&e[1].every(t=>typeof t=="string")}function XE(e,t,n){let r=t?"AND d1.relative_path LIKE ?":"",i=t?[`%${t}%`]:[],o=n==="imports-only"?"AND m.role = 2":"AND m.role != 1";return e.all(`SELECT DISTINCT
118
- d1.relative_path AS from_file,
119
- d2.relative_path AS to_file
120
- FROM mentions m
121
- JOIN chunks c ON m.chunk_id = c.id
122
- JOIN documents d1 ON c.document_id = d1.id
123
- JOIN global_symbols gs ON m.symbol_id = gs.id
124
- JOIN (
125
- SELECT m2.symbol_id, c2.document_id
126
- FROM mentions m2
127
- JOIN chunks c2 ON m2.chunk_id = c2.id
128
- WHERE m2.role = 1
129
- GROUP BY m2.symbol_id
130
- ) sym_def ON sym_def.symbol_id = gs.id
131
- JOIN documents d2 ON sym_def.document_id = d2.id
132
- WHERE d1.id != d2.id
133
- ${o}
134
- ${e.pathExclusionsFor("d1","d2")}
135
- ${r}`,...i)}function YE(e,t,n){let r=[...t].sort();if(r.length===0)return[];let i=n==="imports-only"?"AND m.role = 2":"AND m.role != 1",o=[];for(let s=0;s<r.length;s+=500){let a=r.slice(s,s+500),c=a.map(()=>"?").join(", ");o.push(...e.all(`SELECT DISTINCT
136
- d1.relative_path AS from_file,
137
- d2.relative_path AS to_file
138
- FROM mentions m
139
- JOIN chunks c ON m.chunk_id = c.id
140
- JOIN documents d1 ON c.document_id = d1.id
141
- JOIN global_symbols gs ON m.symbol_id = gs.id
142
- JOIN (
143
- SELECT m2.symbol_id, c2.document_id
144
- FROM mentions m2
145
- JOIN chunks c2 ON m2.chunk_id = c2.id
146
- WHERE m2.role = 1
147
- GROUP BY m2.symbol_id
148
- ) sym_def ON sym_def.symbol_id = gs.id
149
- JOIN documents d2 ON sym_def.document_id = d2.id
150
- WHERE d1.id != d2.id
151
- ${i}
152
- ${e.pathExclusionsFor("d1","d2")}
153
- AND d1.relative_path IN (${c})`,...a))}return o}function oo(e,t,n,r,i){if(r===i||e.isIgnored(r)||e.isIgnored(i)||!n.has(i))return;let o=t.get(r);o||(o=new Set,t.set(r,o)),o.add(i)}var QE={"/":"namespace","#":"type",".":"term","[":"type-param",":":"meta","!":"macro"};function We(e){if(e.startsWith("local "))return{kind:"local",id:e.slice(6),raw:e};let t=e.split(" ");if(t.length<4)return{scheme:t[0]??"",manager:t[1]??"",packageName:t[2]??"",version:"",descriptors:[],raw:e};let n=t[0],r=t[1],i=e.slice(n.length+1+r.length+1),o;if(i.startsWith("`")){let l=i.indexOf("`",1);l===-1?(o=i.slice(1),i=""):(o=i.slice(1,l),i=i.slice(l+2))}else{let l=i.indexOf(" ");l===-1?(o=i,i=""):(o=i.slice(0,l),i=i.slice(l+1))}let s,a=i.indexOf(" ");a===-1?(s=i,i=""):(s=i.slice(0,a),i=i.slice(a+1));let c=ZE(i);return{scheme:n,manager:r,packageName:o,version:s,descriptors:c,raw:e}}function ue(e){let t=We(e);if("kind"in t)return null;for(let n=t.descriptors.length-2;n>=0;n--){let r=t.descriptors[n];if(r?.suffix==="type")return r.name}return null}function ZE(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="["){let o=e.indexOf("]",n+1);if(o===-1){t.push({name:e.slice(n+1),suffix:"type-param"});break}t.push({name:e.slice(n+1,o),suffix:"type-param"}),n=o+1;continue}if(e[n]==="("&&(t.length===0||n===0||Ep(e[n-1]))){let o=e.indexOf(")",n+1);if(o!==-1&&e[o+1]!=="."){t.push({name:e.slice(n+1,o),suffix:"parameter"}),n=o+1;continue}}let r;if(e[n]==="`"){let o=e.indexOf("`",n+1);if(o===-1){r=e.slice(n+1),t.push({name:r,suffix:"term"});break}r=e.slice(n+1,o),n=o+1}else{let o=n;for(;n<e.length&&!Ep(e[n]);)n++;r=e.slice(o,n)}if(n>=e.length){r&&t.push({name:r,suffix:"term"});break}let i=e[n];if(i==="("){let o=e.indexOf(")",n+1);o!==-1&&e[o+1]==="."?(t.push({name:r,suffix:"method"}),n=o+2):o!==-1?(t.push({name:r,suffix:"method"}),n=o+1):(t.push({name:r,suffix:"term"}),n++)}else{let o=QE[i];o&&t.push({name:r,suffix:o}),n+=1}}return t}function Ep(e){return e==="/"||e==="#"||e==="."||e==="("||e==="["||e===":"||e==="!"}function Mt(e){let t=We(e);if("kind"in t&&t.kind==="local")return`local:${t.id}`;let n=t;if(n.descriptors.length===0)return n.raw;let r=[];for(let i of n.descriptors){let o=eP(i);o&&r.push(o)}return r.join(":")}function eP(e){let t=e.suffix==="namespace"?tP(e.name):e.name;return t?e.suffix==="method"?`${t}()`:t:""}function tP(e){return e.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/,"").replace(/\.(py|pyi)$/,"").replace(/\.(rs)$/,"").replace(/\.(java|scala|kt|kts)$/,"").replace(/\.(rb)$/,"").replace(/\.(go)$/,"").replace(/\.(cs|vb)$/,"").replace(/\.(dart)$/,"").replace(/\.(php)$/,"").replace(/\.(c|cc|cpp|cxx|h|hpp)$/,"")}function de(e){let t=We(e);if("kind"in t&&t.kind==="local")return t.id;let n=t;return n.descriptors.length===0?"":n.descriptors[n.descriptors.length-1].name}function fn(e){let t=We(e);if("kind"in t&&t.kind==="local")return null;let n=t;return n.descriptors[n.descriptors.length-1]?.suffix??null}function La(e){return e.endsWith("().")||fn(e)==="method"}function zn(e){let t=fn(e);return t==="method"?!0:t!=="term"?!1:e.endsWith("().")?!0:e.startsWith("rust-analyzer ")&&e.includes("#")?!1:e.startsWith("scip-typescript ")?!/#[A-Za-z0-9_$]+\.$/.test(e):!0}function Pp(e){return fn(e)==="namespace"}var nP=/^rust-analyzer\b.*[\s/]impl#\[[^\]]+\]\[[^\]]+\]/;function YM(e){return nP.test(e)}var rP=new Set(["test","tests","_tests"]);function QM(e){let t=We(e);if("kind"in t)return!1;for(let n=0;n<t.descriptors.length-1;n+=1){let r=t.descriptors[n];if(r?.suffix==="namespace"&&r.name&&rP.has(r.name))return!0}return!1}function ZM(e,t){let n=We(e),r=We(t);if("kind"in n||"kind"in r)return!1;let i=n.descriptors,o=r.descriptors;if(o.length!==i.length+1)return!1;for(let s=0;s<i.length;s++){let a=i[s],c=o[s];if(a.name!==c.name||a.suffix!==c.suffix)return!1}return!0}function ej(e,t){let n=We(e),r=We(t);if("kind"in n||"kind"in r)return!1;let i=n.descriptors,o=r.descriptors;if(o.length<=i.length)return!1;for(let s=0;s<i.length;s++){let a=i[s],c=o[s];if(a.name!==c.name||a.suffix!==c.suffix)return!1}return!0}function so(e){return{forFile(t,n){return Rp(e,t,n)},forFiles(t,n){let r=new Map;for(let i of t)r.set(i,Rp(e,i,n));return r}}}function Rp(e,t,n){let r={file:t},i=n.facts||n.identifiers;if(n.text&&(r.text=R(e,t)),n.lines&&(r.lines=Sr(e,t)),n.ast&&(r.ast=D(e,t)),n.imports&&(r.imports=U(e,t)),n.reexports&&(r.reexports=Ot(e,t)),i){let o=ga(e,t),s=o.facts;n.facts&&(r.facts=s),o.unavailable&&(r.sourceFactsUnavailable=o.unavailable),n.identifiers&&s&&(r.identifiers=s.fileIdentifiers,r.identifierLineMap=s.identifierLineMap)}return r}function jt(e,t){return e.all(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.start_char, der.end_line, der.end_char, d.relative_path, gs.display_name, gs.documentation
154
- FROM global_symbols gs
155
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
156
- JOIN documents d ON der.document_id = d.id
157
- WHERE ${t.where}
158
- ${e.pathExclusionsFor("d")}
159
- ${Cp(t.orderBy)}
160
- ${Fp(t.limit)}`,...t.params??[])}function mn(e,t){return e.all(`SELECT
161
- gs.id,
162
- gs.symbol,
163
- c.document_id,
164
- MIN(c.start_line) AS start_line,
165
- 0 AS start_char,
166
- MAX(c.end_line) AS end_line,
167
- 0 AS end_char,
168
- d.relative_path,
169
- gs.display_name,
170
- gs.documentation
171
- FROM global_symbols gs
172
- JOIN mentions m ON m.symbol_id = gs.id
173
- JOIN chunks c ON m.chunk_id = c.id
174
- JOIN documents d ON c.document_id = d.id
175
- WHERE m.role = 1
176
- AND ${t.where}
177
- ${e.pathExclusionsFor("d")}
178
- GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path, gs.display_name, gs.documentation
179
- ${Cp(t.orderBy)}
180
- ${Fp(t.limit)}`,...t.params??[])}function Cp(e){return e?`ORDER BY ${e}`:""}function Fp(e){return typeof e=="number"?`LIMIT ${e}`:""}function Da(e){return!e||!e.trim()?null:e.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim()||null}function Aa(e){if(!e)return null;let t=wp(e);if(t)return t.replace(/\n/g," ");let n=e.indexOf("|");if(n===-1)return e.replace(/\n/g," ");let r=e.slice(n+1);return(wp(r)??r).replace(/\n/g," ")}function wp(e){return/^```(?:\w+)?\s*\n?([\s\S]*?)\n?```/.exec(e.trimStart())?.[1]?.trim()||null}function iP(e,t={}){if(ue(e.symbol)!==null)return t.includeClassMemberFallbacks===!0;let i=(e.documentation??"").replace(/^```\w*\s*/,"").replace(/\s*```$/,"").trim();return/^(?:var|let|const|function|class|interface|type|enum)\b/.test(i)}function gt(e,t,n={}){let r=new Map;for(let o of t)e.length>0&&!iP(o,{includeClassMemberFallbacks:n.includeClassMemberFallbacks})||r.set(o.id,o);for(let o of e)r.set(o.id,o);let i=[...r.values()];return n.sort?i.sort((o,s)=>o.start_line-s.start_line||o.end_line-s.end_line||o.symbol.localeCompare(s.symbol)):i}function Pj(e){let t=new Map;for(let n of e){if(!n.leaf)continue;let r=t.get(n.leaf)??[];r.push(n),t.set(n.leaf,r)}return t}var oP=C("file-definitions",{clearGroups:["definition-catalog"]}),sP=He("scoped-matched-definitions",{clearGroups:["definition-catalog"]}),aP=C("file-function-like-definitions",{clearGroups:["definition-catalog"]}),Np=new WeakMap;function A(e,t,n={},r){return n.includeClassMemberFallbacks?Oa(e,t,void 0,{includeClassMemberFallbacks:!0},r):oP.get(e,t,()=>{let i=Qe(r,"evidence-read",()=>Lp(e,t));if(i)return i;let o=Oa(e,t,void 0,n,r);return Qe(r,"evidence-write",()=>{let s=Ct(e),a=so(e).forFile(t,{text:!0}).text;s&&a&&_p.write(e,t,Ke(e,t,a),{projectFingerprint:s,definitions:o.map(c=>({...c}))})}),o})}function cP(e,t){return aP.get(e,t,()=>{let n=Lp(e,t);return n?n.filter(r=>r.isFunctionLike):Oa(e,t,r=>r.isFunctionLike)})}var _p=$e({kind:"file-definitions",invalidation:Ie("file-definitions"),serialize:lP,deserialize:uP});function Lp(e,t){let n=Ct(e);if(!n)return null;let r=so(e).forFile(t,{text:!0}).text;if(!r)return null;let i=_p.read(e,t,Ke(e,t,r));return i?dP(i,n,t):null}function lP(e){return JSON.stringify(e)}function uP(e){try{let t=JSON.parse(e);return!kt(t)||typeof t.projectFingerprint!="string"||!Array.isArray(t.definitions)?null:{projectFingerprint:t.projectFingerprint,definitions:t.definitions}}catch{return null}}function dP(e,t,n){if(e.projectFingerprint!==t)return null;let r=[];for(let i of e.definitions){let o=pP(i,n);if(!o)return null;r.push(o)}return r}function pP(e,t){return!kt(e)||typeof e.symbolId!="number"||typeof e.symbol!="string"||typeof e.documentId!="number"||typeof e.startLine!="number"||typeof e.startChar!="number"&&e.startChar!==void 0||typeof e.endLine!="number"||typeof e.endChar!="number"&&e.endChar!==void 0||e.relativePath!==t||typeof e.leaf!="string"||typeof e.parentTypeName!="string"&&e.parentTypeName!==null||typeof e.isFunctionLike!="boolean"||typeof e.isTypeLike!="boolean"||typeof e.kind!="number"&&e.kind!==null||typeof e.documentation!="string"&&e.documentation!==null||typeof e.enclosingSymbol!="string"&&e.enclosingSymbol!==null?null:{symbolId:e.symbolId,symbol:e.symbol,documentId:e.documentId,startLine:e.startLine,startChar:e.startChar,endLine:e.endLine,endChar:e.endChar,relativePath:e.relativePath,leaf:e.leaf,parentTypeName:e.parentTypeName,isFunctionLike:e.isFunctionLike,isTypeLike:e.isTypeLike,kind:e.kind,documentation:e.documentation,enclosingSymbol:e.enclosingSymbol}}function Oa(e,t,n,r={},i){let o=Qe(i,"primary-rows",()=>fP(e,t)),s=Qe(i,"fallback-rows",()=>mP(e,t)),a=Qe(i,"merge-rows",()=>gt(o,s,{sort:!0,includeClassMemberFallbacks:r.includeClassMemberFallbacks}).map(Ma));return n&&(a=a.filter(n)),Qe(i,"range-correction",()=>ja(e,t,a,i,r.rangeCorrectionEvidence))}function Qe(e,t,n){return e?e(t,n):n()}function fP(e,t){return e.all(`SELECT
181
- gs.id,
182
- gs.symbol,
183
- der.document_id,
184
- der.start_line,
185
- der.start_char,
186
- der.end_line,
187
- der.end_char,
188
- d.relative_path,
189
- gs.display_name,
190
- gs.kind,
191
- gs.documentation,
192
- gs.enclosing_symbol
193
- FROM global_symbols gs
194
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
195
- JOIN documents d ON der.document_id = d.id
196
- WHERE d.relative_path = ?
197
- ${e.symbolNoiseFor("gs")}
198
- ORDER BY der.start_line, der.end_line`,t)}function mP(e,t){return e.all(`SELECT
199
- gs.id,
200
- gs.symbol,
201
- c.document_id,
202
- MIN(c.start_line) AS start_line,
203
- 0 AS start_char,
204
- MAX(c.end_line) AS end_line,
205
- 0 AS end_char,
206
- d.relative_path,
207
- gs.display_name,
208
- gs.kind,
209
- gs.documentation,
210
- gs.enclosing_symbol
211
- FROM global_symbols gs
212
- JOIN mentions m ON m.symbol_id = gs.id
213
- JOIN chunks c ON m.chunk_id = c.id
214
- JOIN documents d ON c.document_id = d.id
215
- WHERE d.relative_path = ?
216
- AND m.role = 1
217
- ${e.symbolNoiseFor("gs")}
218
- GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
219
- ORDER BY start_line, end_line`,t)}function Ma(e){return{symbolId:e.id,symbol:e.symbol,documentId:e.document_id,startLine:e.start_line,startChar:e.start_char??0,endLine:e.end_line,endChar:e.end_char??0,relativePath:e.relative_path,leaf:de(e.symbol),parentTypeName:ue(e.symbol),isFunctionLike:zn(e.symbol),isTypeLike:fn(e.symbol)==="type",kind:e.kind??null,documentation:e.documentation??null,enclosingSymbol:e.enclosing_symbol??null}}function Rj(e,t={}){return gP(e,t.scope)}function gP(e,t){return xe(e,{scope:t,includeIgnored:!1}).flatMap(n=>A(e,n)).filter(n=>!e.isIgnored(n.relativePath))}function wj(e,t){return xe(e,{scope:t,includeIgnored:!1}).flatMap(n=>cP(e,n)).filter(n=>!e.isIgnored(n.relativePath))}function Cj(e,t){let n=sP.get(e,()=>new WeakMap),r=n.get(t.symbolMatches);r||(r=new Map,n.set(t.symbolMatches,r));let i=JSON.stringify({scope:t.scope??null,sqlPrefilter:t.sqlPrefilter??null}),o=r.get(i);if(o)return[...o];let s=Tp(yP(e,t.scope,t.sqlPrefilter)),a=Tp(hP(e,t.scope,t.sqlPrefilter)),c=new Set([...s.keys(),...a.keys()]),l=[];for(let u of[...c].sort()){if(e.isIgnored(u))continue;let d=gt(s.get(u)??[],a.get(u)??[],{sort:!0}).filter(p=>t.symbolMatches(p.symbol));d.length!==0&&l.push(...ja(e,u,d.map(Ma)))}return r.set(i,l),[...l]}function yP(e,t,n){let r=t?"AND d.relative_path LIKE ?":"",i=n?`AND ${Dp("gs",n)}`:"",o=t?[`%${t}%`]:[];return e.all(`SELECT
220
- gs.id,
221
- gs.symbol,
222
- der.document_id,
223
- der.start_line,
224
- der.start_char,
225
- der.end_line,
226
- der.end_char,
227
- d.relative_path,
228
- gs.display_name,
229
- gs.kind,
230
- gs.documentation,
231
- gs.enclosing_symbol
232
- FROM global_symbols gs
233
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
234
- JOIN documents d ON der.document_id = d.id
235
- WHERE 1 = 1
236
- ${e.pathExclusionsFor("d")}
237
- ${r}
238
- ${i}
239
- ${e.symbolNoiseFor("gs")}
240
- ORDER BY d.relative_path, der.start_line, der.end_line`,...o)}function hP(e,t,n){let r=t?"AND d.relative_path LIKE ?":"",i=n?`AND ${Dp("gs",n)}`:"",o=t?[`%${t}%`]:[];return e.all(`SELECT
241
- gs.id,
242
- gs.symbol,
243
- c.document_id,
244
- MIN(c.start_line) AS start_line,
245
- 0 AS start_char,
246
- MAX(c.end_line) AS end_line,
247
- 0 AS end_char,
248
- d.relative_path,
249
- gs.display_name,
250
- gs.kind,
251
- gs.documentation,
252
- gs.enclosing_symbol
253
- FROM global_symbols gs
254
- JOIN mentions m ON m.symbol_id = gs.id
255
- JOIN chunks c ON m.chunk_id = c.id
256
- JOIN documents d ON c.document_id = d.id
257
- WHERE m.role = 1
258
- AND NOT EXISTS (
259
- SELECT 1
260
- FROM defn_enclosing_ranges existing_der
261
- WHERE existing_der.symbol_id = gs.id
262
- )
263
- ${e.pathExclusionsFor("d")}
264
- ${r}
265
- ${i}
266
- ${e.symbolNoiseFor("gs")}
267
- GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
268
- ORDER BY d.relative_path, start_line, end_line`,...o)}function SP(e){return`(${e}.symbol LIKE '%().' OR ${e}.symbol LIKE '%()')`}function Dp(e,t){return t==="callable"?SP(e):bP(e)}function bP(e){return`(${e}.symbol LIKE '%.' OR ${e}.symbol LIKE '%()')`}function Tp(e){let t=new Map;for(let n of e){let r=t.get(n.relative_path);r?r.push(n):t.set(n.relative_path,[n])}return t}function Fj(e,t,n={}){if(t.length===0)return[];let r=t.flatMap(i=>A(e,i)).filter(i=>!e.isIgnored(i.relativePath));return n.onlyDocumented&&(r=r.filter(i=>i.documentation!==null&&i.documentation!=="")),n.sort&&(r=r.sort((i,o)=>i.relativePath.localeCompare(o.relativePath)||i.startLine-o.startLine||i.endLine-o.endLine)),r.map(i=>({startLine:i.startLine,endLine:i.endLine,symbol:i.symbol,shortName:Mt(i.symbol),signature:Da(Aa(i.documentation)),relativePath:i.relativePath,enclosingSymbol:i.enclosingSymbol}))}function xP(e){let t=new Map,n=e.map((r,i)=>({definition:r,index:i,span:r.endLine-r.startLine})).sort((r,i)=>r.span-i.span||r.index-i.index);for(let{definition:r}of n)for(let i=r.startLine;i<=r.endLine;i+=1)t.has(i)||t.set(i,r);return t}function Un(e,t){let n=Np.get(e);return n||(n=xP(e),Np.set(e,n)),n.get(t)??null}function ao(e,t){let n=A(e,t.relative_path).find(r=>r.symbolId===t.id)??(ue(t.symbol)===null||!zn(t.symbol)?void 0:ja(e,t.relative_path,[Ma(t)])[0]);return n?{symbolId:n.symbolId,symbol:n.symbol,documentId:n.documentId,startLine:n.startLine,startChar:n.startChar,endLine:n.endLine,endChar:n.endChar,relativePath:n.relativePath}:{symbolId:t.id,symbol:t.symbol,documentId:t.document_id,startLine:t.start_line,startChar:t.start_char??0,endLine:t.end_line,endChar:t.end_char??0,relativePath:t.relative_path}}function ja(e,t,n,r,i){let o=Qe(r,"range-correction.source-text",()=>i?i.source:so(e).forFile(t,{text:!0}).text),s=Qe(r,"range-correction.callable-sites",()=>i?i.callables:Fr(e,t));return s?Qe(r,"range-correction.ast-correction",()=>wP(n,s,o)):o?Qe(r,"range-correction.regex-fallback",()=>vP(n,o)):n}function vP(e,t){let n=t.split(/\r?\n/),r=IP(e,n),i=EP(e,r),o=PP(i,n);return RP(e,o)}function IP(e,t){let n=e.some(i=>co(i.symbol))?LP(t):null,r=new Map;for(let i of e)r.set(i.symbolId,_P(t,n,i));return r}function EP(e,t){return e.filter(n=>co(n.symbol)).map(n=>({definition:n,startLine:t.get(n.symbolId)??n.startLine})).sort((n,r)=>n.startLine-r.startLine||n.definition.startLine-r.definition.startLine||n.definition.symbol.localeCompare(r.definition.symbol))}function PP(e,t){let n=new Map;for(let r=0;r<e.length;r+=1){let i=e[r],o=e[r+1],s=o?Math.max(i.startLine,o.startLine-1):t.length-1;n.set(i.definition.symbolId,{startLine:i.startLine,endLine:DP(t,i.definition,i.startLine,s)})}return n}function RP(e,t){return e.map(n=>{let r=t.get(n.symbolId);return r?{...n,startLine:r.startLine,endLine:r.endLine}:n})}function wP(e,t,n=null){let r=new Map;for(let i of t){let o=r.get(i.name);o?o.push(i):r.set(i.name,[i])}return e.map(i=>{if(!kP(i)||!i.leaf)return kp(i,n);let o=r.get(i.leaf);if(!o||o.length===0)return kp(i,n);let s=n?CP(i,o,n):null;if(s)return{...i,startLine:s.startLine,endLine:s.endLine};let a=o[0],c=Math.abs(a.startLine-i.startLine);for(let l=1;l<o.length;l+=1){let u=o[l],d=Math.abs(u.startLine-i.startLine);d<c&&(a=u,c=d)}return{...i,startLine:a.startLine,endLine:a.endLine}})}function CP(e,t,n){let r=FP(e.symbol);if(!r)return null;let i=n.split(/\r?\n/),o=new RegExp(`\\b${te(r)}\\b`);for(let s of t){let a=NP(i,s.startLine);if(a&&o.test(a))return s}return null}function FP(e){return e.match(/\/impl#\[([^\]]+)\]/)?.[1]??null}function NP(e,t){for(let n=t;n>=0;n-=1){let r=e[n]?.trim()??"";if(r){if(/^impl\b/.test(r))return TP(e,n,t);if(/^(?:struct|enum|trait|mod)\b/.test(r))return null}}return null}function TP(e,t,n){let r=[];for(let i=t;i<=n;i+=1){let o=e[i]??"";if(r.push(o),o.includes("{"))break}return r.join(" ")}function kP(e){return co(e.symbol)?!0:fn(e.symbol)==="term"&&ue(e.symbol)===null}function kp(e,t){if(!t||!e.leaf||fn(e.symbol)!=="term"||ue(e.symbol)!==null)return e;let n=te(e.leaf),r=new RegExp(`\\b(?:export\\s+)?(?:const|let|var)\\s+${n}\\b`),o=t.split(/\r?\n/).findIndex(s=>r.test(s));return o>=0?{...e,startLine:o,endLine:o}:e}function _P(e,t,n){if(!co(n.symbol))return n.startLine;let r=Math.max(0,Math.min(n.startLine,e.length-1));if(!t)return r;let i=t.get(n.leaf);if(!i||i.length===0)return r;let o=null;for(let s of i){let a=Math.abs(s-n.startLine);(!o||a<o.distance)&&(o={line:s,distance:a})}return o?.line??r}function LP(e){let t=/\b(?:function|def|fn)\s+([A-Za-z_$][\w$]*)/g,n=/\b([A-Za-z_$][\w$]*)\s*[:=]\s*(?:async\s*)?(?:function\b|\()/g,r=/^\s*(?:(?:export|public|private|protected|static|readonly|async|abstract|get|set)\s+)*([A-Za-z_$][\w$]*)\s*(?:<[^(]*>)?\s*\(/,i=/\b([A-Za-z_$][\w$]*)\s*\(/g,o=new Map,s=(a,c)=>{let l=o.get(a);if(!l){o.set(a,[c]);return}l[l.length-1]!==c&&l.push(c)};for(let a=0;a<e.length;a+=1){let c=e[a]??"";for(let u of c.matchAll(t))u[1]&&s(u[1],a);for(let u of c.matchAll(n))u[1]&&s(u[1],a);let l=c.match(r);l?.[1]&&s(l[1],a);for(let u of c.matchAll(i))u[1]&&s(u[1],a)}return o}function DP(e,t,n,r){let i=Math.max(n,Math.min(e.length-1,r)),o=Math.max(n,Math.min(i,t.endLine)),s=0,a=0,c=!1;for(let l=n;l<=i;l+=1){let u=AP(e[l]??"");for(let d of u)d==="{"?(s+=1,c=!0):d==="}"?s=Math.max(0,s-1):d==="("?a+=1:d===")"&&(a=Math.max(0,a-1));if(c&&s===0||!c&&a===0&&l>=o)return l}return o}function AP(e){let t="",n=null,r=!1;for(let i=0;i<e.length;i+=1){let o=e[i],s=e[i+1];if(!n&&o==="/"&&s==="/"){t+=" ".repeat(e.length-i);break}if(n){if(r){r=!1,t+=" ";continue}if(o==="\\"){r=!0,t+=" ";continue}o===n&&(n=null),t+=" ";continue}if(o==='"'||o==="'"||o==="`"){n=o,t+=" ";continue}t+=o}return t}function co(e){return e.includes("().")}function Nj(e){let t=We(e);if("kind"in t)return[];let n=[];for(let r=t.descriptors.length-2;r>=0;r-=1){let i=t.descriptors[r];i?.suffix==="type"&&i.name&&n.push(i.name)}return n}var OP=C("symbol-resolution",{clearGroups:[]});function jj(e,t){return MP(e,t).match}function MP(e,t){return OP.get(e,t,()=>{let n=Mp(e,t.trim()).filter(s=>!e.isIgnored(s.relative_path));if(n.length>0)return Hn(e,n);let r=zP(e,t);if(r&&!e.isIgnored(r.relative_path))return Hn(e,[r]);let i=jP(e,t);if(i.length>0)return Hn(e,i);let o=BP(e,t);return o.length>0?Hn(e,o):qP(e,t)})}function jP(e,t){let n=t.trim().replace(/\(\)$/u,""),r=n.lastIndexOf(":");if(r<=0||r===n.length-1||n.startsWith("local:"))return[];let i=n.slice(r+1);if(!/^[\p{L}_$][\p{L}\p{N}_$]*$/u.test(i))return[];let o=[`/${i}().`,`/${i}.`,`/${i}#`,`#${i}().`,`#${i}.`,`/${i}/`],s=`gs.display_name = ? OR ${o.map(()=>"instr(gs.symbol, ?) > 0").join(" OR ")}`,a=[i,...o],c=jt(e,{where:s,params:a,orderBy:"d.relative_path, der.start_line",limit:200}),l=c.length>0?[]:mn(e,{where:s,params:a,orderBy:"d.relative_path, start_line",limit:200}),u=gt(c,l).filter(d=>!e.isIgnored(d.relative_path)).filter(d=>Mt(d.symbol).replace(/\(\)$/u,"")===n);return[...new Map(u.map(d=>[`${d.symbol}\0${d.relative_path}`,d])).values()]}function BP(e,t){let n=lo(t),r=Ba(n);if(!r)return[];let i=`%${r.path}%`,o=r.leaf;return $P(e,i,o,n)}function $P(e,t,n,r){let i=gt([],[...GP(e,t,n),...VP(e,t,n)]).filter(o=>!e.isIgnored(o.relative_path)).filter(o=>Kn(o,r)>1);return i.sort((o,s)=>Kn(s,r)-Kn(o,r)||o.end_line-o.start_line-(s.end_line-s.start_line)||o.start_line-s.start_line||o.symbol.localeCompare(s.symbol)),i}function GP(e,t,n){return jt(e,{where:"d.relative_path LIKE ? AND (gs.display_name = ? OR gs.symbol LIKE ?)",params:[t,n,`%/${n}.%`]})}function VP(e,t,n){return mn(e,{where:"d.relative_path LIKE ? AND (gs.display_name = ? OR gs.symbol LIKE ?)",params:[t,n,`%/${n}.%`]})}function qP(e,t){let n=lo(t),r=YP(t),i=JP(e,r),o=QP(i,t,n).filter(a=>!e.isIgnored(a.relative_path));if(o.length>0)return Hn(e,o);let s=[];for(let a of i){if(e.isIgnored(a.relative_path))continue;let c=XP(a,t,n,r);c<=0||s.push({row:a,score:c})}return s.sort((a,c)=>c.score-a.score||a.row.end_line-a.row.start_line-(c.row.end_line-c.row.start_line)||a.row.relative_path.localeCompare(c.row.relative_path)||a.row.symbol.localeCompare(c.row.symbol)),Hn(e,s.map(a=>a.row))}function Hn(e,t){let n=t.map(i=>ao(e,i)),r=n[0]??null;return{match:r,candidates:r?WP(n,r):[],total:n.length}}function WP(e,t){let n=new Set([`${t.symbolId}:${t.relativePath}:${t.startLine}`]),r=[];for(let i of e){let o=`${i.symbolId}:${i.relativePath}:${i.startLine}`;if(!n.has(o)&&(n.add(o),r.push({symbol:i.symbol,shortName:Mt(i.symbol),relativePath:i.relativePath,startLine:i.startLine}),r.length>=5))break}return r}function zP(e,t){let n=t.match(/^(.+):(\d+)(?:-(\d+))?$/);if(!n)return;let[,r,i,o]=n,s=nu(e,r,{allowMultiple:!1,requirePathMatch:!0})[0]?.relativePath;if(!s)return;let a=Math.max(0,parseInt(i,10)-1),c=o?Math.max(a,parseInt(o,10)-1):a;return UP(e,s,a,c)??HP(e,s,a,c)}function UP(e,t,n,r){return jt(e,{where:"d.relative_path = ? AND der.start_line <= ? AND der.end_line >= ?",params:[t,n,r],orderBy:"(der.end_line - der.start_line) ASC",limit:1})[0]}function HP(e,t,n,r){return mn(e,{where:"d.relative_path = ? AND c.start_line <= ? AND c.end_line >= ?",params:[t,n,r],orderBy:"(MAX(c.end_line) - MIN(c.start_line)) ASC",limit:1})[0]}function Bj(e,t){let n=Mp(e,t).find(r=>!e.isIgnored(r.relative_path));return n?ao(e,n):null}function Mp(e,t){let n=jt(e,{where:"gs.symbol = ?",params:[t],orderBy:"d.relative_path, der.start_line"}),r=n.length>0?[]:mn(e,{where:"gs.symbol = ?",params:[t],orderBy:"d.relative_path, start_line"});return gt(n,r)}function _r(e,t){if("symbol"in t&&"relativePath"in t)return t;let n=KP(e,t.symbolId)[0];return n?ao(e,n):null}function KP(e,t){let n=jt(e,{where:"gs.id = ?",params:[t],orderBy:"der.start_line, der.end_line"}),r=mn(e,{where:"gs.id = ?",params:[t],orderBy:"start_line, end_line"});return gt(n,r)}function JP(e,t){let n=t.map(()=>"(gs.symbol LIKE ? OR d.relative_path LIKE ? OR COALESCE(gs.display_name, '') LIKE ?)"),r=t.flatMap(a=>{let c=`%${a}%`;return[c,c,c]}),i=n.join(`
269
- AND `),o=jt(e,{where:i,params:r,limit:200}),s=mn(e,{where:i,params:r,limit:200});return gt(o,s)}function XP(e,t,n,r){let i=t.trim(),o=n,s=o.replace(/\(\)$/,""),a=t.toLowerCase(),c=n.toLowerCase(),l=c.replace(/\(\)$/,""),u=e.symbol,d=Mt(e.symbol),p=de(e.symbol),f=e.display_name??"",m=e.symbol.toLowerCase(),g=d.toLowerCase(),y=p.toLowerCase(),I=f.toLowerCase(),h=e.relative_path.toLowerCase(),P=/[/:.]/.test(n),w=Ba(n),T=w?.leaf.toLowerCase(),b=0;return(u===i||u===o)&&(b+=1150),(d===i||d===o)&&(b+=1100),f===s&&(b+=1180),p===s&&(b+=1160),(`${p}()`===i||`${p}()`===o)&&(b+=955),(m===a||m===c)&&(b+=1e3),(g===a||g===c)&&(b+=950),(h===a||h===c)&&(b+=925),(h.endsWith(`/${c}`)||h.endsWith(`/${a}`))&&(b+=875),I===l&&(b+=850),y===l&&(b+=825),(`${y}()`===a||`${y}()`===c)&&(b+=820),(g.endsWith(`:${c}`)||g.endsWith(`:${l}`)||g.endsWith(`:${l}()`))&&(b+=800),m.includes(c)&&(b+=120),g.includes(c)&&(b+=140),h.includes(c)&&(b+=140),I.includes(c)&&(b+=110),r.every(v=>{let E=v.toLowerCase();return m.includes(E)||g.includes(E)||h.includes(E)||I.includes(E)})&&(b+=100+r.length*15),w&&h.includes(w.path.toLowerCase())&&(b+=360,T&&(y===T||`${y}()`===T||`${y}()`==`${T}()`)&&(b+=700),La(e.symbol)&&(b+=180)),zn(e.symbol)&&y===l&&(b+=60),!P&&Pp(e.symbol)&&(b-=160),b-=Math.min(50,Math.max(0,e.end_line-e.start_line)),b}function Ba(e){let t=e.trim().replace(/\\/g,"/"),n=t.lastIndexOf("/");if(n<=0||n===t.length-1)return null;let r=t.slice(n+1).replace(/\(\)$/,"");return!r||r.includes(".")?null:{path:t.slice(0,n),leaf:r}}function lo(e){return e.trim().replace(/\(\)$/,"").replace(/\(.*$/,"")}function YP(e){let t=lo(e),n=t.split(/[^A-Za-z0-9_]+/).map(r=>r.trim()).filter(r=>r.length>0);return n.length>0?[...new Set(n)]:[t]}function QP(e,t,n){let r=t.trim(),i=e.filter(a=>{let c=Mt(a.symbol),l=de(a.symbol),u=(a.display_name??"").trim();return a.symbol===r||c===r||c===n||l===r||l===n||`${l}()`===r||u===r||u===n||`${u}()`===r||Kn(a,n)>1||a.relative_path===r});if(i.length===0)return[];let o=n.replace(/\(\)$/u,""),s=i.filter(a=>de(a.symbol)===o);if(s.length>0){s.sort((c,l)=>Ap(c,l,n));let a=s.filter(c=>zn(c.symbol));return a.length>0?a:s}return i.sort((a,c)=>Ap(a,c,n)),i}function Ap(e,t,n){return Kn(t,n)-Kn(e,n)||e.end_line-e.start_line-(t.end_line-t.start_line)||e.relative_path.localeCompare(t.relative_path)||e.symbol.localeCompare(t.symbol)}function Kn(e,t){let n=Ba(t);if(!n)return 0;let r=e.relative_path.toLowerCase(),i=de(e.symbol).toLowerCase(),o=n.path.toLowerCase(),s=n.leaf.toLowerCase();return r.includes(o)?i!==s?1:La(e.symbol)?ue(e.symbol)===null?5:4:ue(e.symbol)===null?3:2:0}function $j(e,t,n=5){let r=Op(t);if(!r)return[];let i=jt(e,{where:"1 = 1",orderBy:"d.relative_path, der.start_line",limit:5e3}),o=new Map;for(let s of i){if(e.isIgnored(s.relative_path))continue;let a=Mt(s.symbol),c=de(s.symbol),l=s.display_name??c,u=[a,c,l].filter(f=>f.trim().length>0),d=Math.min(...u.map(f=>ZP(Op(f),r))),p=o.get(a);(!p||d<p.distance)&&o.set(a,{shortName:a,distance:d})}return[...o.values()].sort((s,a)=>s.distance-a.distance||s.shortName.localeCompare(a.shortName)).slice(0,n).map(s=>s.shortName)}function Op(e){return lo(e).toLowerCase().replace(/[^a-z0-9_]+/g,"")}function ZP(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;let n=Array.from({length:t.length+1},(r,i)=>i);for(let r=0;r<e.length;r++){let i=[r+1];for(let o=0;o<t.length;o++){let s=e[r]===t[o]?0:1;i[o+1]=Math.min(i[o]+1,n[o+1]+1,n[o]+s)}n=i}return n[t.length]}function Jj(e,t){let n=jp(e);return n?t.filter(r=>jp(r.file)===n):t}function Xj(e,t,n,r,i){let o=U(e,t);if(r){let u=i?.match(/^[A-Za-z_$][\w$]*/u)?.[0];if(!u)return null;let d=new Set(o.filter(g=>g.localName===u||g.importedName===u).map(g=>g.sourcePath).filter(g=>!!g));for(let g of n)for(let y of d)if(Ht(y,g.file))return g;if(u==="this"||u==="self"||u==="cls"){let g=n.filter(y=>y.file===t&&ue(y.symbol)!==null);if(g.length===1)return g[0]}let p=eR(R(e,t)??"",u);if(p.size===0)return null;let f=new Set(o.filter(g=>p.has(g.localName??g.importedName)).map(g=>g.sourcePath).filter(g=>!!g)),m=n.filter(g=>p.has(ue(g.symbol)??"")&&(g.file===t||[...f].some(y=>Ht(y,g.file))));return m.length===1?m[0]:null}let s=n.filter(u=>ue(u.symbol)===null),a=s.find(u=>u.file===t);if(a)return a;let c=de(n[0].symbol),l=o.filter(u=>u.kind!=="namespace"&&u.kind!=="side-effect"&&(u.localName===c||u.localName===null&&u.importedName===c));if(l.length>0){let u=s.filter(d=>l.some(p=>p.sourcePath!==null&&Ht(p.sourcePath,d.file)));return u.length===1?u[0]:null}return s.length===1?s[0]:null}function eR(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),r=new Set,i=[new RegExp(`\\b${n}\\s*:\\s*([A-Za-z_$][\\w$]*)`,"gu"),new RegExp(`\\b${n}\\s*=\\s*(?:new\\s+)?([A-Za-z_$][\\w$]*)\\s*\\(`,"gu")];for(let o of i)for(let s of e.matchAll(o))r.add(s[1]);return r.size===1?r:new Set}function jp(e){let t=ne(e);return t?t==="typescript"||t==="tsx"||t==="javascript"?"javascript-family":t:null}var tR=He("global-leaf-index",{clearGroups:["whole-project"]});function $a(e){return tR.get(e,()=>{let t=e.all(`SELECT gs.id, gs.symbol,
270
- COALESCE(der_doc.relative_path, mention_doc.relative_path) AS relative_path
271
- FROM global_symbols gs
272
- LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
273
- LEFT JOIN documents der_doc ON der_doc.id = der.document_id
274
- LEFT JOIN (
275
- SELECT m.symbol_id, MIN(d.relative_path) AS relative_path
276
- FROM mentions m
277
- JOIN chunks c ON m.chunk_id = c.id
278
- JOIN documents d ON c.document_id = d.id
279
- WHERE m.role = 1
280
- GROUP BY m.symbol_id
281
- ) mention_doc ON mention_doc.symbol_id = gs.id
282
- WHERE 1 = 1
283
- ${e.symbolNoiseFor("gs")}`),n=new Map;for(let r of t){if(!r.relative_path||e.isIgnored(r.relative_path))continue;let i=de(r.symbol);if(!i)continue;let o=n.get(i);o||(o=[],n.set(i,o)),o.some(s=>s.symbolId===r.id)||o.push({symbol:r.symbol,symbolId:r.id,file:r.relative_path})}return n})}function uo(e,t,n,r={}){if(!n)return[];let i=R(e,t);return i?i.indexOf(n)===-1?[]:(Ga(e,t).get(n)??[]).filter(s=>!nR(s,r)):[]}function nR(e,t){return typeof t.excludeStartLine=="number"&&typeof t.excludeEndLine=="number"&&e>=t.excludeStartLine&&e<=t.excludeEndLine}var rR=C("file-identifiers",{clearGroups:["whole-project","source-file"]});function Bp(e,t){let n=le(e,t);return n?n.fileIdentifiers:rR.get(e,t,()=>new Set(Ga(e,t).keys()))}var iR=C("file-ident-lines",{clearGroups:["whole-project","source-file"]});function Ga(e,t){let n=le(e,t);return n?n.identifierLineMap:iR.get(e,t,()=>sR(e,t))}var oR=C("file-idents-by-line",{clearGroups:["whole-project","source-file"]});function nB(e,t){let n=le(e,t);return n?n.identifiersByLine:oR.get(e,t,()=>{let r=Ga(e,t),i=0;for(let s of r.values()){let a=s[s.length-1];a!==void 0&&a>i&&(i=a)}let o=new Array(i+1);for(let s=0;s<=i;s+=1)o[s]=new Set;for(let[s,a]of r)for(let c of a)o[c].add(s);return o})}function sR(e,t){let n=new Map,r=(a,c)=>{let l=n.get(a);if(!l){n.set(a,[c]);return}l[l.length-1]!==c&&l.push(c)},i=R(e,t);if(!i)return n;let o=ra(i).split(/\r?\n/),s=/\b([A-Za-z_$][\w$]*)\b/g;for(let a=0;a<o.length;a+=1){let c=o[a]??"";for(let l of c.matchAll(s))l[1]&&r(l[1],a)}return n}var $p=/[A-Za-z_$][A-Za-z0-9_$]*/g,Gp=/^[A-Za-z_$][A-Za-z0-9_$]*$/,aR=512;function Va(e){let t=[],n=!1;for(let r of e)r&&(n=!0,Gp.test(r)||t.push(r));return{candidateNames:e,hasUsableCandidate:n,nonIdentifierNames:t}}function Vp(e,t){let n=cR(t)?t:Va(t);if(n.candidateNames.size===0||!n.hasUsableCandidate)return!0;if(n.candidateNames.size<=aR){for(let i of n.candidateNames)if(i){if(Gp.test(i)){if(lR(i).test(e))return!0;continue}if(e.includes(i))return!0}return!1}$p.lastIndex=0;let r;for(;(r=$p.exec(e))!==null;)if(n.candidateNames.has(r[0]))return!0;for(let i of n.nonIdentifierNames)if(e.includes(i))return!0;return!1}function cR(e){return"candidateNames"in e}function lR(e){return new RegExp(`(?<![A-Za-z_$0-9])${te(e)}(?![A-Za-z_$0-9])`)}var uR=C("source-import-paths-by-local-name",{clearGroups:["whole-project","source-file"]});function Wp(e,t){let n=Nt(t);return uR.get(e,n,()=>dR(e,n))}function dR(e,t){let n=new Map;for(let r of U(e,t)){if(!r.sourcePath)continue;let i=r.localName??r.importedName;if(i&&qp(n,i,r.sourcePath),r.kind==="namespace")for(let o of r.usedMembers)qp(n,o,r.sourcePath)}return n}function qp(e,t,n){let r=e.get(t);r||(r=new Set,e.set(t,r)),r.add(n)}function qa(e,t,n){let r=$a(e).get(n);if(!r||r.length===0)return[];if(r.length===1)return[Lr(r[0])];let i=r.filter(c=>c.file===t);if(i.length>0)return i.map(Lr);let o=Wp(e,t),s=o.get(n);if(s)for(let c of s){let l=r.filter(u=>Ht(c,u.file));if(l.length>0)return l.map(Lr)}let a=new Set;for(let c of o.values())for(let l of c)a.add(l);for(let c of a){let l=r.filter(u=>Ht(c,u.file));if(l.length>0&&l.length===r.length)return l.map(Lr)}return[]}function xB(e,t,n){let r=qa(e,t,n);if(r.length>0)return r;let i=$a(e).get(n);return!i||i.length===0?[]:i.map(Lr)}function zp(e,t,n={}){let r=pR(e,t);if(!r)return[];let i=_r(e,t);if(n.semantic!==!1&&n.semanticEvidence){let s=n.semanticEvidence.references(e,{...i,leaf:r.identifier,parentTypeName:null,isFunctionLike:!1,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:null});if(s.length>0){let a=new Map;for(let c of s){let l=a.get(c.file)??[];l.push(c.line),a.set(c.file,l)}return po(e,a)}}let o=new Map;for(let s of ye(e)){let a=fR(e,r,s);a.length>0&&o.set(s,a)}return po(e,o)}function pR(e,t){let n=_r(e,t);if(!n)return null;let r=de(n.symbol);return r?{symbolId:n.symbolId,relativePath:n.relativePath,startLine:n.startLine,endLine:n.endLine,identifier:r}:null}function fR(e,t,n){let r=R(e,n);return!r||r.indexOf(t.identifier)===-1?[]:n!==t.relativePath&&!qa(e,n,t.identifier).some(o=>o.symbolId===t.symbolId)?[]:uo(e,n,t.identifier,n===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{})}function vB(e,t,n={}){let r=new Map;for(let c of t){if(!c.leaf)continue;let l=r.get(c.leaf)??[];l.push(c),r.set(c.leaf,l)}if(r.size===0)return new Map;let i=new Set(t.map(c=>c.symbolId)),o=new Set(r.keys()),s=Va(o),a=new Map;for(let c of ye(e)){if(n.skipPath?.(c)||!Vp(R(e,c),s))continue;let l=Bp(e,c);if(l.size!==0){for(let u of l)if(r.has(u))for(let d of qa(e,c,u)){if(!i.has(d.symbolId)||c===d.relativePath)continue;let p=a.get(d.symbolId);p||(p=new Set,a.set(d.symbolId,p)),p.add(c)}}}return a}function Lr(e){return{symbolId:e.symbolId,symbol:e.symbol,relativePath:e.file}}function po(e,t){let n=[],r=new Set;for(let[i,o]of t){let s=A(e,i);for(let a of o){let c=Un(s,a),l=`${i}|${a}|${c?.symbol??""}`;r.has(l)||(r.add(l),n.push({file:i,line:a,enclosingSymbol:c?.symbol??null}))}}return n}function EB(e,t){return fo(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT
284
- m.symbol_id,
285
- d.relative_path,
286
- COUNT(*) AS ref_count
287
- FROM mentions m
288
- JOIN chunks c ON m.chunk_id = c.id
289
- JOIN documents d ON c.document_id = d.id
290
- WHERE m.role != 1
291
- ${r}
292
- ${e.pathExclusionsFor("d")}
293
- GROUP BY m.symbol_id, d.relative_path`,...n??[])})}function PB(e,t){return fo(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT DISTINCT m.symbol_id, d.relative_path
294
- FROM mentions m
295
- JOIN chunks c ON m.chunk_id = c.id
296
- JOIN documents d ON c.document_id = d.id
297
- WHERE m.role != 1
298
- ${r}
299
- ${e.pathExclusionsFor("d")}`,...n??[])}).filter(n=>n.symbol_id!==null)}function RB(e,t){return fo(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT DISTINCT m.symbol_id
300
- FROM mentions m
301
- WHERE m.role != 1
302
- ${r}`,...n??[])}).filter(n=>n.symbol_id!==null)}function Up(e,t){return fo(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT DISTINCT m.symbol_id, d.relative_path, c.document_id,
303
- c.start_line AS chunk_start, c.end_line AS chunk_end
304
- FROM mentions m
305
- JOIN chunks c ON m.chunk_id = c.id
306
- JOIN documents d ON c.document_id = d.id
307
- WHERE m.role != 1
308
- ${r}
309
- ${e.pathExclusionsFor("d")}
310
- ORDER BY d.relative_path, c.start_line`,...n??[])})}function fo(e,t,n){if(!t)return n();if(t.length===0)return[];let r=[];for(let i=0;i<t.length;i+=750)r.push(...n(t.slice(i,i+750)));return r}function mR(e,t){return gR(e,[t]).get(t.symbolId)??[]}function gR(e,t){let n=t.map(o=>({symbolId:o.symbolId,prelude:xR(e,o)})).filter(o=>o.prelude!==null),r=hR(e,n.map(o=>o.symbolId)),i=new Map;for(let{symbolId:o,prelude:s}of n){let a=yR(e,r.get(o)??new Map,s.match,s.identifier);i.set(o,po(e,a))}return i}function _B(e,t,n={}){return Wa(e,t,n).map(r=>({file:r.file,line:r.line,enclosingSymbol:r.enclosingSymbol}))}function Wa(e,t,n={}){let r=zp(e,t,{semantic:n.semantic,semanticEvidence:n.semanticEvidence}),i=r.length>0?Hp(r,"source-attribution"):Hp(mR(e,t),"scip-reference-chunk");return n.includeIgnored===!0?i:i.filter(o=>!e.isIgnored(o.file))}function Hp(e,t){return e.map(n=>({...n,provenance:t}))}function yR(e,t,n,r){let i=new Map;for(let[o,s]of t)i.set(o,SR(e,o,s,n,r));return i}function hR(e,t){let n=new Map;for(let r of Up(e,t)){if(e.isIgnored(r.relative_path))continue;let i=n.get(r.symbol_id);i||(i=new Map,n.set(r.symbol_id,i));let o=i.get(r.relative_path);o||(o=[],i.set(r.relative_path,o)),o.push({start_line:r.chunk_start,end_line:r.chunk_end})}return n}function SR(e,t,n,r,i){let o=t===r.relativePath?{excludeStartLine:r.startLine,excludeEndLine:r.endLine}:{},s=i?uo(e,t,i,o):[];return n.flatMap(a=>bR(s,a))}function bR(e,t){let n=e.filter(r=>r>=t.start_line&&r<=t.end_line);return n.length>0?n:[t.start_line]}function xR(e,t){let n=_r(e,t);return n?{match:n,identifier:de(n.symbol)||null}:null}import{execFileSync as Kp,spawnSync as vR}from"child_process";import{platform as IR}from"os";import{resolve as ER}from"path";var Jp=IR()==="win32";function MB(e,t=vR){try{return t(e,["--version"],{stdio:"ignore",timeout:1e4}).status===0}catch{return!1}}function Xp(e){let t=Jp?"where":"which";try{return Kp(t,[e],{stdio:"pipe",timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}var PR=/\.(?:c|m)?js$/i,RR=/\.(?:exe|com)$/i;function jB(e,t){return PR.test(e)?{binary:process.execPath,args:[e,...t]}:{binary:e,args:[...t]}}function wR(e,t){return Kp(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL"})}function Yp(e,t={}){let n=t.isWindows??Jp,r=t.lookup??wR,i;try{i=r(n?"where":"which",[e])}catch{return null}let o=i.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);if(!n){let s=o[0];return s?ER(s):null}return o.find(s=>RR.test(s))??null}import{execFileSync as Zp}from"child_process";import{createHash as CR}from"crypto";import{existsSync as mo,statSync as FR}from"fs";import{createRequire as NR}from"module";import{platform as TR}from"os";import{dirname as Qp,join as Dr}from"path";var kR=NR(import.meta.url),JB={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function za(e){return[e.indexerBinary,...e.binaryAliases??[]]}function _R(e){let t=za(e);return t.length===1?t[0]:t.join(" or ")}function Ua(e){for(let t of za(e)){let n=Yp(t);if(n)return n}return DR(e)}function XB(e){return Ua(e)!==null||LR(e)}function LR(e){return ef(e)!==null}function DR(e){let t=ef(e);if(!t)return null;let r=JSON.parse(F(t,"indexer package manifest")).bin;if(!r)return null;if(typeof r=="string")return Dr(Qp(t),r);for(let i of za(e)){let o=r[i];if(o)return Dr(Qp(t),o)}return null}function ef(e){if(!e.bundledNpmPackage)return null;try{return kR.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function AR(e,t){for(let n of e.projectLocalBinaries??[]){let r=Dr(t,n);if(mo(r))return r}return null}function OR(e,t){for(let n of e.projectLocalBinaries??[]){let r=Dr(t,n);if(mo(r))return tf(t,n,r)}return null}function YB(e,t){let n=MR(e,t);if(!n||n.canonicalPath!==t.canonicalPath||n.sha256!==t.sha256||n.size!==t.size||n.mtimeMs!==t.mtimeMs||n.device!==t.device||n.inode!==t.inode||n.executable!==t.executable)throw new Error(`refusing changed project-local indexer ${t.relativePath}; review the current file and rerun with --trust-project-tools`)}function MR(e,t){try{return tf(e,t.relativePath,t.configuredPath)}catch{return null}}function tf(e,t,n){let r={maxBytes:268435456,inputKind:"project-local indexer"},i=kn(e,t,r),o=Li(e,t,r),s=FR(i.absolutePath);return{configuredPath:n,canonicalPath:i.absolutePath,relativePath:t,sha256:CR("sha256").update(o).digest("hex"),size:i.size,mtimeMs:i.mtimeMs,device:i.device,inode:i.inode,executable:(s.mode&73)!==0}}function jR(e,t,n={}){return(n.trustProjectTools?OR(e,t)?.canonicalPath:null)??Ua(e)}function QB(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||Ha(n,t))return t;let r=nf(n,t);return r?{...t,DOTNET_ROOT:r}:t}function ZB(e,t,n={}){let r=_R(e),i=t?jR(e,t,n):Ua(e);if(!i)return{language:e.language,binaryLabel:r,installed:!1,runnable:!1,resolvedBinary:null,installUrl:e.installUrl,...t&&AR(e,t)?{note:"project-local indexer available only with --trust-project-tools"}:{}};if(e.indexerBinary!=="scip-dotnet")return{language:e.language,binaryLabel:r,installed:!0,runnable:!0,resolvedBinary:i};let o=BR(i);return{language:e.language,binaryLabel:r,installed:!0,runnable:o.runnable,resolvedBinary:i,installUrl:e.installUrl,note:o.note}}function BR(e){if(Ha(e,process.env))return{runnable:!0};let t=nf(e,process.env);if(t)return{runnable:!0,note:`using .NET 9 runtime from ${t}`};let n=rf(process.env);return{runnable:!1,note:n.length>0?`.NET 9 runtime still unavailable after checking ${n.join(", ")}`:"binary is present, but scip-dotnet still needs a .NET 9 runtime"}}function nf(e,t){for(let n of rf(t))if(Ha(e,{...t,DOTNET_ROOT:n}))return n;return null}function rf(e){let t=[],n=e.DOTNET_ROOT;if(n&&mo(n)&&t.push(n),TR()==="darwin"&&Xp("brew"))try{let r=Zp("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),i=Dr(r,"libexec");mo(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function Ha(e,t){try{return Zp(e,["--version"],{stdio:"pipe",env:t,timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}function gn(e){try{return process.kill(e,0),!0}catch(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EPERM"}}var $R=new Set(["aix","android","darwin","freebsd","haiku","linux","openbsd","sunos","win32","cygwin","netbsd"]);function yt(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return t.version!==1||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.platform!="string"||!$R.has(t.platform)||typeof t.startToken!="string"||t.startToken.trim()===""?null:{version:1,pid:t.pid,platform:t.platform,startToken:t.startToken}}function je(e,t){return e.version===t.version&&e.pid===t.pid&&e.platform===t.platform&&e.startToken===t.startToken}import{execFileSync as GR}from"child_process";import{platform as VR}from"os";var qR=1e3,of=16*1024,Ka;function ht(e,t=af){if(!Number.isSafeInteger(e)||e<=0)return null;let n=e===process.pid&&t===af;if(n&&Ka)return{...Ka};try{let r=WR(e,t);if(!r)return null;let i={version:1,pid:e,platform:t.platform,startToken:r};return n&&(Ka=i),{...i}}catch{return null}}function WR(e,t){if(t.platform==="linux"||t.platform==="android")return zR(t.readFile(`/proc/${e}/stat`));if(t.platform==="win32"){let n=`([DateTimeOffset](Get-Process -Id ${e} -ErrorAction Stop).StartTime).ToUnixTimeMilliseconds()`;return sf(t.run("powershell.exe",["-NoProfile","-NonInteractive","-Command",n]))}return t.platform==="darwin"||t.platform==="freebsd"||t.platform==="openbsd"||t.platform==="netbsd"?sf(t.run("ps",["-p",String(e),"-o","lstart="])):null}function zR(e){let t=e.lastIndexOf(")");if(t<0)return null;let r=e.slice(t+1).trim().split(/\s+/)[19];return r&&/^\d+$/.test(r)?r:null}function sf(e){let t=e.trim();return t===""?null:t}var af={platform:VR(),readFile(e){return Is(e,{maxBytes:of,inputKind:"process identity pseudo-file"})},run(e,t){return GR(e,[...t],{encoding:"utf8",timeout:qR,maxBuffer:of,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"]})}};function yn(){return performance.now()}import{randomUUID as XR}from"crypto";import{closeSync as YR,existsSync as QR,fsyncSync as ZR,linkSync as ew,mkdirSync as tw,openSync as nw,renameSync as rw,unlinkSync as iw,writeSync as ow}from"fs";import{dirname as lf}from"path";import{chmodSync as UR,constants as HR,copyFileSync as KR}from"fs";import{dirname as JR}from"path";var cf=Object.freeze({...nn,copyFile:(e,t)=>KR(e,t,HR.COPYFILE_FICLONE),chmodFile:(e,t)=>UR(e,t)});function Ar(e,t,n={}){let r=n.runtime??cf,i=JR(t),o=ge(i,r);r.copyFile(e,t),n.mode!==void 0&&r.chmodFile(t,n.mode);let s=r.openFile(t,"r");try{r.syncFile(s)}finally{r.closeFile(s)}return X(o,L(i,r))}var uf=Object.freeze({platform:process.platform,randomToken:()=>XR(),pathExists:e=>QR(e),makeDirectory:e=>tw(e,{recursive:!0}),openFile:(e,t,n)=>nw(e,t,n),writeFile:(e,t,n,r)=>ow(e,t,n,r),syncFile:e=>ZR(e),closeFile:e=>YR(e),renameFile:(e,t)=>rw(e,t),linkFile:(e,t)=>ew(e,t),removeFile:e=>iw(e)});function Ja(e,t,n={}){let r=n.durability??"visibility",i=n.runtime??uf,o=lf(e),s=r==="durable"?ge(o,i):(i.makeDirectory(o),"not-requested"),a=`${e}.tmp-${i.randomToken()}`,c=typeof t=="string"?Buffer.from(t):t,l,u=!1;try{l=i.openFile(a,"wx",n.mode??384),u=!0,at(l,c,i,"atomic file"),r==="durable"&&i.syncFile(l),i.closeFile(l),l=void 0,i.renameFile(a,e),u=!1;let d=r==="durable"?X(s,L(o,i)):"not-requested";return df(r,d)}finally{if(l!==void 0)try{i.closeFile(l)}catch{}if(u)try{i.removeFile(a)}catch{}}}function Xa(e,t,n={}){let r=n.durability??"visibility",i=n.runtime??uf;if(!i.linkFile)throw new Error("Exclusive atomic file publication requires hard-link support.");let o=lf(e),s=r==="durable"?ge(o,i):(i.makeDirectory(o),"not-requested"),a=`${e}.tmp-${i.randomToken()}`,c=typeof t=="string"?Buffer.from(t):t,l,u=!1;try{l=i.openFile(a,"wx",n.mode??384),u=!0,at(l,c,i,"exclusive atomic file"),r==="durable"&&i.syncFile(l),i.closeFile(l),l=void 0,i.linkFile(a,e);let d=r==="durable"?L(o,i):"not-requested";i.removeFile(a),u=!1;let p=r==="durable"?X(s,d,L(o,i)):"not-requested";return df(r,p)}finally{if(l!==void 0)try{i.closeFile(l)}catch{}if(u)try{i.removeFile(a)}catch{}}}function df(e,t){return{requestedDurability:e,achievedDurability:e==="visibility"?"visibility":t==="synced"?"directory-durable":"file-flushed",directorySync:t}}function Jn(e,t,n={}){Ja(e,pf(t,n),{durability:"visibility",runtime:n.runtime})}function Ze(e,t,n={}){return Ja(e,pf(t,n),{durability:"durable",runtime:n.runtime})}function pf(e,t){let n=JSON.stringify(e,null,t.spacing);return t.trailingNewline?`${n}
311
- `:n}import{join as go}from"path";var F0=6,N0=1e4,sw="watch.lock",aw="watch-state.json",cw="watch-activity.json",lw="watch-refresh-requests";function T0(e){return{lockPath:go(e,sw),statePath:go(e,aw),activityPath:go(e,cw),refreshRequestsPath:go(e,lw)}}function k0(e){try{return uw(JSON.parse(F(e,"watch service state")))}catch{return null}}function uw(e){if(!e||typeof e!="object")return null;let t=e;if(t.version!==1||typeof t.protocolVersion!="number"||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||t.worktreeId!==void 0&&(typeof t.worktreeId!="string"||t.worktreeId.length===0)||typeof t.cliVersion!="string"||!ee(t.startedAt)||!ee(t.heartbeatAt)||!ee(t.lastActivityAt)||!dw(t.watcher)||t.idleDeadlineAt!==void 0&&!ee(t.idleDeadlineAt))return null;if(t.processIdentity!==void 0){let n=yt(t.processIdentity);if(!n||n.pid!==t.pid)return null;t.processIdentity=n}return t.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(t.indexGeneration)||t.lastError!==void 0&&!pw(t.lastError)||t.lastRefresh!==void 0&&!fw(t.lastRefresh)||t.reindexActivity!==void 0&&!mw(t.reindexActivity)||t.refreshRequests!==void 0&&!yw(t.refreshRequests)||t.typescriptSemantic!==void 0&&!hw(t.typescriptSemantic)||t.typescriptIndex!==void 0&&!Sw(t.typescriptIndex)?null:t}function ee(e){return pi(e)}function dw(e){if(!e||typeof e!="object"||!("state"in e))return!1;let t=e;switch(t.state){case"idle":return!0;case"waiting":return ie(t.changedFiles)&&ie(t.reindexAt);case"indexing":return ie(t.startedAt);case"cooldown":return ie(t.until)&&typeof t.dirty=="boolean";case"budget-paused":return ie(t.until)&&typeof t.dirty=="boolean"&&typeof t.reason=="string"&&x(t.rebuilt)&&x(t.estimatedWriteBytes);case"draining":return ie(t.startedAt)&&typeof t.reason=="string";default:return!1}}function pw(e){if(!e||typeof e!="object")return!1;let t=e;return ee(t.at)&&typeof t.message=="string"}function fw(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.trigger?.kind=="string"&&typeof t.result=="string"&&ee(t.startedAt)&&ee(t.completedAt)&&ie(t.durationMs)}function mw(e){if(!e||typeof e!="object")return!1;let t=e;return t.confidence!==void 0&&t.confidence!=="complete"&&t.confidence!=="partial"&&t.confidence!=="unavailable"||t.recordsRead!==void 0&&!x(t.recordsRead)||t.invalidRecords!==void 0&&!x(t.invalidRecords)||t.skippedRecords!==void 0&&!x(t.skippedRecords)||t.readErrors!==void 0&&!x(t.readErrors)||t.ignoredPartialTailBytes!==void 0&&!x(t.ignoredPartialTailBytes)||!ee(t.windowStartedAt)||!ee(t.windowEndedAt)||!x(t.runs)||!x(t.rebuilt)||t.fullRebuilds!==void 0&&!x(t.fullRebuilds)||!x(t.reused)||!x(t.failed)||!x(t.suppressed)||!ie(t.estimatedLogicalOutputBytes)||t.estimatedWriteBytes!==void 0&&!x(t.estimatedWriteBytes)||t.reflinkedBytes!==void 0&&!x(t.reflinkedBytes)||t.fallbackCopiedBytes!==void 0&&!x(t.fallbackCopiedBytes)||t.oldestRebuildAt!==void 0&&!ee(t.oldestRebuildAt)||t.oldestWriteAt!==void 0&&!ee(t.oldestWriteAt)||t.languageAttribution!==void 0&&t.languageAttribution!=="complete"&&t.languageAttribution!=="partial"&&t.languageAttribution!=="unavailable"||t.attributedRuns!==void 0&&!x(t.attributedRuns)||t.unattributedRuns!==void 0&&!x(t.unattributedRuns)||t.invalidLanguageDetails!==void 0&&!x(t.invalidLanguageDetails)||t.estimatedLogicalOutputBytes<0||!t.byTrigger||typeof t.byTrigger!="object"||Array.isArray(t.byTrigger)||t.byLanguage!==void 0&&!gw(t.byLanguage)?!1:Object.values(t.byTrigger).every(n=>n===void 0||x(n))}function gw(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;for(let[t,n]of Object.entries(e)){if(!fi.includes(t)||!n||typeof n!="object")return!1;let r=n;if(!x(r.runs)||!x(r.rebuilt)||!x(r.reused)||!x(r.producedOutputBytes)||!Cl(r.durationMs)||r.rebuilt+r.reused!==r.runs)return!1}return!0}function yw(e){if(!e||typeof e!="object")return!1;let t=e;return x(t.pending)&&x(t.claimed)&&x(t.completed)&&x(t.expired)&&x(t.invalid)&&(t.oldestPendingAt===void 0||ee(t.oldestPendingAt))}function hw(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.protocolVersion=="number"&&(t.state==="idle"||t.state==="ready"||t.state==="unavailable"||t.state==="error")&&ie(t.requests)&&ie(t.sessionsCreated)&&ie(t.sessionsReused)&&ie(t.sessionsRefreshed)&&ie(t.sessionsReplaced)&&ie(t.projectsCreated)&&(t.lastRequestAt===void 0||ee(t.lastRequestAt))&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||ee(t.busyUntil))&&(t.mailbox===void 0||ff(t.mailbox))}function Sw(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.protocolVersion=="number"&&(t.state==="idle"||t.state==="ready"||t.state==="unavailable"||t.state==="error")&&x(t.requests)&&x(t.sessionsCreated)&&x(t.sessionsReplaced)&&(t.sessionsEvicted===void 0||x(t.sessionsEvicted))&&(t.activeSessions===void 0||x(t.activeSessions))&&(t.maxActiveSessions===void 0||x(t.maxActiveSessions))&&(t.heapUsedBytes===void 0||x(t.heapUsedBytes))&&(t.heapLimitBytes===void 0||x(t.heapLimitBytes))&&(t.softMemoryLimitBytes===void 0||x(t.softMemoryLimitBytes))&&(t.retireRequested===void 0||typeof t.retireRequested=="boolean")&&x(t.initializations)&&x(t.programUpdates)&&x(t.documentsEmitted)&&x(t.documentsRemoved)&&(t.lastRequestAt===void 0||ee(t.lastRequestAt))&&(t.lastDurationMs===void 0||ie(t.lastDurationMs)&&t.lastDurationMs>=0)&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||ee(t.busyUntil))&&(t.mailbox===void 0||ff(t.mailbox))}function ff(e){if(!e||typeof e!="object")return!1;let t=e;return x(t.pending)&&x(t.inflight)&&x(t.responses)&&x(t.deadLetters)&&x(t.invalid)&&x(t.totalItems)&&ie(t.totalBytes)&&t.totalBytes>=0&&t.totalItems===t.pending+t.inflight+t.responses+t.deadLetters&&(t.oldestPendingAt===void 0||ee(t.oldestPendingAt))}function ie(e){return typeof e=="number"&&Number.isFinite(e)}function yo(e,t){return e.reason instanceof Error?e.reason:new Error(t)}function mf(e,t){if(e?.aborted)throw yo(e,t)}import{randomUUID as bw}from"crypto";import{closeSync as xw,fsyncSync as vw,linkSync as Iw,mkdirSync as Ew,openSync as Pw,statSync as Rw,unlinkSync as ww,writeSync as Cw}from"fs";import{dirname as tc}from"path";var Qa="scip-query-process-lock",Za=1,ho=Object.freeze({wallNow:()=>Date.now(),isProcessAlive:gn,readProcessIdentity:ht,randomToken:()=>bw(),makeDirectory:e=>Ew(e,{recursive:!0}),openFile:(e,t,n)=>Pw(e,t,n),writeFile:(e,t,n,r)=>Cw(e,t,n,r),syncFile:e=>vw(e),closeFile:e=>xw(e),linkFile:(e,t)=>Iw(e,t),readFile:e=>F(e,"process lock record"),statFile:e=>{let t=Rw(e);return{dev:t.dev,ino:t.ino,size:t.size,mtimeMs:t.mtimeMs}},removeFile:e=>ww(e)});function So(e,t){let n=t.runtime??ho;n.makeDirectory(tc(e));let r;for(let i=0;i<2;i+=1)try{return{kind:"acquired",lock:gf(e,t,n),...r?{reclaimed:r}:{}}}catch(o){if(o.code!=="EEXIST")throw o;let s=Xn(e,{parseLegacy:t.parseLegacy,runtime:n});if(i===0&&Nw(e,s,{creationGraceMs:t.creationGraceMs,parseLegacy:t.parseLegacy,runtime:n})){r=s;continue}return{kind:"contended",observation:s}}return{kind:"contended",observation:Xn(e,{parseLegacy:t.parseLegacy,runtime:n})}}function Xn(e,t={}){let n=t.runtime??ho,r,i;try{r=n.statFile(e),i=n.readFile(e)}catch(c){return c.code==="ENOENT"?{state:"missing"}:{state:"malformed"}}let o;try{o=JSON.parse(i)}catch{return{state:"malformed",raw:i,identity:r}}let s=Fw(o);if(s)return{state:"valid",raw:i,identity:r,record:s,owner:_w(s),parsed:o};let a=t.parseLegacy?.(o)??null;return a?{state:"legacy",raw:i,identity:r,owner:a,parsed:o}:{state:"malformed",raw:i,identity:r,parsed:o}}function Fw(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.protocol!==Qa||t.version!==Za||typeof t.kind!="string"||t.kind.trim()===""||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.token!="string"||t.token.trim()===""||typeof t.startedAt!="string"||!Number.isFinite(Date.parse(t.startedAt))||t.detail!==void 0&&(typeof t.detail!="object"||t.detail===null||Array.isArray(t.detail)))return null;let n=t.processIdentity===void 0?null:yt(t.processIdentity);return t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{protocol:Qa,version:Za,kind:t.kind,pid:t.pid,token:t.token,...n?{processIdentity:n}:{},startedAt:t.startedAt,...t.detail?{detail:t.detail}:{}}}function Nw(e,t,n={}){let r=n.runtime??ho;if(!ec(t,r))return!1;let i=kw(`${e}.reclaim`,r);if(!i)return!1;try{let o=Xn(e,{parseLegacy:n.parseLegacy,runtime:r});return!hf(t,o)||!ec(o,r)?!1:nc(e,r)}finally{i.release()}}function gf(e,t,n){let r=t.directoryDurability??"durable",i=t.pid??process.pid,o=n.randomToken(),s=t.processIdentity===void 0?n.readProcessIdentity(i):t.processIdentity,a={protocol:Qa,version:Za,kind:t.kind,pid:i,token:o,...s?{processIdentity:s}:{},startedAt:new Date(n.wallNow()).toISOString(),...t.detail?{detail:t.detail}:{}},c=`${e}.${o}.candidate`,l=n.openFile(c,"wx",384),u;try{at(l,Buffer.from(`${JSON.stringify(a)}
312
- `),n,"process lock"),n.syncFile(l)}catch(p){u=p}try{n.closeFile(l)}catch(p){u??=p}if(u!==void 0)throw Ya(c,n),u;try{n.linkFile(c,e)}catch(p){throw Ya(c,n),p}if(Ya(c,n),r==="durable")try{Sf(tc(e),n)}catch(p){throw Tw(e,a,n),p}let d=!1;return{path:e,record:a,release:()=>d?!1:(d=!0,yf(e,a,n,r))}}function Tw(e,t,n=ho){return yf(e,t,n,"durable")}function yf(e,t,n,r){let i=Xn(e,{runtime:n});return i.state!=="valid"||!i.record||i.record.pid!==t.pid||i.record.token!==t.token||t.processIdentity&&(!i.record.processIdentity||!je(t.processIdentity,i.record.processIdentity))?!1:nc(e,n,r)}function kw(e,t){for(let n=0;n<2;n+=1)try{return gf(e,{kind:"reclaim-guard",runtime:t},t)}catch(r){if(r.code!=="EEXIST")return null;let i=Xn(e,{runtime:t});if(n>0||!ec(i,t))return null;let o=Xn(e,{runtime:t});if(!hf(i,o)||!nc(e,t))return null}return null}function ec(e,t){if(e.state==="missing")return!1;if(e.owner){if(!t.isProcessAlive(e.owner.pid))return!0;if(!e.owner.processIdentity)return!1;let n=t.readProcessIdentity(e.owner.pid);return n!==null&&!je(e.owner.processIdentity,n)}return!1}function hf(e,t){return e.state===t.state&&e.raw===t.raw&&e.identity!==void 0&&t.identity!==void 0&&e.identity.dev===t.identity.dev&&e.identity.ino===t.identity.ino&&e.identity.size===t.identity.size&&e.identity.mtimeMs===t.identity.mtimeMs}function _w(e){return{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}}function Sf(e,t){let n;try{n=t.openFile(e,"r")}catch(r){if(Fn(r,process.platform))return;throw r}try{t.syncFile(n)}catch(r){if(!Fn(r,process.platform))throw r}finally{t.closeFile(n)}}function nc(e,t,n="durable"){try{return t.removeFile(e),n==="durable"&&Sf(tc(e),t),!0}catch{return!1}}function Ya(e,t){try{t.removeFile(e)}catch{}}import{join as Lw}from"path";var Dw=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.pid;return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?{pid:t}:null};function bf(e,t={}){return St(Lw(e,"gc.lock"),t)}function St(e,t={}){let n=t.waitMs??0,r=t.pollMs??10,i=t.now??yn,o=i()+n;do{let s=xf(e,t.directoryDurability);if(s)return vf(s);let a=o-i();if(a<=0)return null;Aw(Math.min(r,a))}while(i()<=o);return null}async function U0(e,t={}){let n=t.waitMs??0,r=t.pollMs??10,i=t.now??yn,o=i()+n;do{mf(t.signal,"Lock acquisition was aborted.");let s=xf(e,t.directoryDurability);if(s)return vf(s);let a=o-i();if(a<=0)return null;await Ow(Math.min(r,a),t.signal)}while(i()<=o);return null}function xf(e,t){let n=So(e,{kind:"generic",parseLegacy:Dw,...t?{directoryDurability:t}:{}});return n.kind==="acquired"?n.lock:null}function vf(e){return{release:()=>{e.release()}}}function Aw(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}function Ow(e,t){return t?.aborted?Promise.reject(yo(t,"Lock acquisition was aborted.")):new Promise((n,r)=>{let i=setTimeout(()=>{t?.removeEventListener("abort",o),n()},e),o=()=>{clearTimeout(i),t?.removeEventListener("abort",o),r(t?yo(t,"Lock acquisition was aborted."):new Error("Lock acquisition was aborted."))};t?.addEventListener("abort",o,{once:!0})})}import{createHash as Mw,randomUUID as jw}from"crypto";import{existsSync as Yn,mkdirSync as Bw,readdirSync as $w,rmSync as Ef,statSync as Pf}from"fs";import{basename as Gw,dirname as bo,join as Ce}from"path";var hn=1,sc=1,Mr=".scipquery-generations",xo="manifest.json",Rf="readers",Vw="gc.lock",qw=128,Or=new Map,wf={pid:process.pid,now:()=>new Date,randomToken:()=>jw(),isProcessAlive:gn,readProcessIdentity:ht};function H(e){return Ce(bo(e),Mr)}function vo(e){return Ce(H(e),Vw)}function Cf(e,t=wf){let n=St(vo(e.dbPath),{waitMs:5e3,directoryDurability:"recoverable"});if(!n)throw new Error("SQLite generation retention is busy; retry opening the index.");let r;try{let i=cc(e);if(i.source!=="immutable")return{generation:i,release(){}};let o=t.randomToken();if(!/^[A-Za-z0-9._-]+$/.test(o))throw new Error("SQLite generation reader token is unsafe.");let s=Ce(H(e.dbPath),Rf);Bw(s,{recursive:!0}),r=Ce(s,`${t.pid}-${o}.json`);let a=t.readProcessIdentity(t.pid);Jn(r,{version:1,token:o,generationIdentity:i.identity,pid:t.pid,...a?{processIdentity:a}:{},acquiredAt:t.now().toISOString()},{spacing:2,trailingNewline:!0});let c=!1;return{generation:i,release(){c||!r||(c=!0,Ef(r,{force:!0}))}}}finally{n.release()}}function ac(e,t,n=wf,r={}){let i=Ce(H(e),Rf);if(!Yn(i))return{protectedGenerations:new Set,activeLeases:0,staleLeasesRemoved:0,malformedLeases:0};let o=new Set,s=0,a=0,c=0;for(let l of $w(i,{withFileTypes:!0})){if(!l.isFile()||!l.name.endsWith(".json"))continue;let u=Ce(i,l.name),d;try{d=Ww(JSON.parse(F(u,"SQLite generation reader lease")))}catch{d=null}if(!d){c+=1;for(let p of t)o.add(p);continue}if(!zw(d,n)){r.removeStale!==!1&&(Ef(u,{force:!0}),a+=1);continue}s+=1,o.add(d.generationIdentity)}return{protectedGenerations:o,activeLeases:s,staleLeasesRemoved:a,malformedLeases:c}}function Ww(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,n=t.processIdentity===void 0?null:yt(t.processIdentity);return t.version!==1||typeof t.token!="string"||t.token.trim()===""||typeof t.generationIdentity!="string"||!/^[a-f0-9]{64}$/.test(t.generationIdentity)||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.acquiredAt!="string"||!Number.isFinite(Date.parse(t.acquiredAt))||t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{version:1,token:t.token,generationIdentity:t.generationIdentity,pid:t.pid,...n?{processIdentity:n}:{},acquiredAt:t.acquiredAt}}function zw(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let n=t.readProcessIdentity(e.pid);return n===null||je(e.processIdentity,n)}function Bt(e){try{let t=JSON.parse(F(Ce(H(e),"state.json"),"SQLite generation state"));return Jw(t)?t:null}catch{return null}}function Io(e,t){return jr(H(e),t)}function jr(e,t){try{let n=JSON.parse(F(Ce(e,t,xo),"SQLite generation manifest"));return Kw(n,t)?n:null}catch{return null}}function cc(e){let t=Bt(e.dbPath);if(t){let n=Uw(e,t.currentGeneration);if(n)return n;if(t.artifactSet==="immutable-v1")throw new Error(`Published SQLite generation ${t.currentGeneration} is missing or invalid.`)}if(Yn(Ce(bo(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return Hw(e,t?.currentGeneration)}function i$(e){let t=Bt(e);if(t)return t.currentGeneration;try{let n=Ce(bo(e),"meta.json"),r=Yn(n)?F(n,"reindex metadata"):void 0;return Ff(e,r)}catch{return null}}function $t(e){return Fl(Rt(e))??e}function Uw(e,t){try{let n=Ce(H(e.dbPath),t),r=Io(e.dbPath,t);if(!r)return null;let i=rc(n,r.database),o=r.index?rc(n,r.index):void 0,s=r.metadata?rc(n,r.metadata):void 0;return!ic(i,r.database)||r.index&&(!o||!ic(o,r.index))||r.metadata&&(!s||!ic(s,r.metadata))?null:{identity:t,databasePath:i,...o?{indexPath:o}:{},...s?{metadataPath:s,metadataRaw:F(s,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function Hw(e,t){let n=bt(e.dbPath),r=Ce(bo(e.dbPath),"meta.json"),i=Yn(r)?F(r,"reindex metadata"):void 0,o=Yn(e.indexPath)?e.indexPath:void 0;return{identity:t??Ff(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:r,metadataRaw:i},source:"legacy",databaseFileIdentity:n}}function Ff(e,t){let n=Mw("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&n.update($t(t)),n.update(`\0${bt(e)}`),n.digest("hex")}function bt(e){let t=Pf(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function rc(e,t){if(Gw(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return Ce(e,t.file)}function ic(e,t){if(!Yn(e))return!1;let n=If(e);if(!n||n.size!==t.size)return!1;let r=`${e}\0${t.sha256}\0${n.identity}`;if(Or.has(r))return!0;let i=Jt(e,{inputKind:"immutable SQLite generation artifact",maxBytes:t.size}),o=If(e);if(!o||o.identity!==n.identity||i!==t.sha256)return!1;for(Or.set(r,!0);Or.size>qw;){let s=Or.keys().next().value;if(s===void 0)break;Or.delete(s)}return!0}function If(e){let t=Pf(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function Kw(e,t){return e.version===sc&&e.identity===t&&oc(e.database)&&(e.index===void 0||oc(e.index))&&(e.metadata===void 0||oc(e.metadata))}function oc(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.file=="string"&&!!t.file&&Number.isSafeInteger(t.size)&&(t.size??-1)>=0&&typeof t.sha256=="string"&&/^[a-f0-9]{64}$/.test(t.sha256)}function Jw(e){return e.version===hn&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&Xw(e.stableMirrors)&&Yw(e.previousGeneration)&&Qw(e.publication)}function Xw(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.databaseFileIdentity=="string"&&!!t.databaseFileIdentity&&(t.indexFileIdentity===void 0||typeof t.indexFileIdentity=="string"&&!!t.indexFileIdentity)}function Yw(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.generationIdentity=="string"&&!!t.generationIdentity&&typeof t.databasePath=="string"&&!!t.databasePath&&(t.metadataPath===void 0||typeof t.metadataPath=="string"&&!!t.metadataPath)}function Qw(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,n=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(r=>r!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&n.every(r=>typeof r=="number"&&Number.isFinite(r)&&r>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}var Zw=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function Eo(e){let t=e.toLowerCase();return Zw.some(n=>t.endsWith(n))}function Ro(e){let t=Po(e.projectFiles),n=new Set(t),r=new Map(e.snapshot.files.map(d=>[d.path,d])),i=e.snapshot.files.filter(d=>{let p=Et(d.path,["typescript"]);return p==="config"||p==="ambient"}).map(d=>d.path),o=Po([...t,...i]),s=o.find(d=>!r.has(d)),a=new Set(e.snapshot.files.map(d=>d.path)).size!==e.snapshot.files.length,c=!s&&o.some(d=>Nf(r.get(d))),l=K(JSON.stringify({pnpmWorkspaces:e.snapshot.pnpmWorkspaces,typescriptProjectMode:e.snapshot.typescriptProjectMode,typescriptProjects:Po(e.snapshot.typescriptProjects),membership:t})),u=new Map;return{identityFor(d,p){if(!n.has(d))return Qn("target-outside-project");if(a)return Qn("duplicate-input-path");if(s)return Qn("missing-input-fingerprint");if(c)return Qn("unreadable-input");let f=[],m,g;if(e.graph===null)f.push("dependency-graph-unavailable"),g="whole-project",m=o;else{let h=tC(d,e.graph,u);if(h.find(w=>!r.has(w)))return Qn("missing-input-fingerprint");if(m=Po([...h,...i]),m.some(w=>Nf(r.get(w))))return Qn("unreadable-input");g="dependency-closure"}let y=m.map(h=>nC(r.get(h)));return{version:1,key:K(JSON.stringify({version:1,engineIdentity:e.engineIdentity,schemaVersion:p,projectIdentity:l,inputs:y})),mode:g,inputFiles:m,reasons:f}}}}function eC(e,t){let n=new Set,r=[e];for(let i=0;i<r.length;i+=1){let o=r[i];if(!(o===void 0||n.has(o))){n.add(o);for(let s of[...t.get(o)??[]].sort())n.has(s)||r.push(s)}}return[...n].sort()}function tC(e,t,n){let r=n.get(e);if(r)return r;let i=eC(e,t);return n.set(e,i),i}function nC(e){return{path:e.path,size:e.size,hash:e.hash}}function Nf(e){return e.size<0||e.hash==="unreadable"}function Qn(e){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[e]}}function Po(e){return[...new Set(e)].sort()}import{createRequire as rC}from"module";var Tf=rC(import.meta.url),Br,wo;function iC(){if(Br!==void 0)return Br;try{Br=Tf("ts-morph")}catch{Br=null}return Br}function Co(){if(wo)return wo;let e=iC();if(!e)return"ts-morph:unavailable";let t="unknown";try{t=Tf("ts-morph/package.json").version??"unknown"}catch{}return wo=`ts-morph:${t}:typescript:${e.ts.version}`,wo}function d$(e,t){return t.map(n=>({tsconfigPath:n,project:new e.Project({tsConfigFilePath:n,skipFileDependencyResolution:!0})}))}function p$(e,t,n){return{language:"typescript",availability:()=>({available:!1,reason:e,tsconfigPath:t,tsconfigPaths:n}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}var oC=He("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function lc(e,t,n){let r=oC.get(e,()=>sC(e));if(!r)return null;let i=`${n}\0${t}`,o=r.identities.get(i);if(o)return o;let s=r.builder.identityFor(t,n);return r.identities.set(i,s),s}function $r(e){return xe(e,{includeIgnored:!1}).filter(Eo).sort()}function sC(e){try{if(!e.generation.metadataRaw)return null;let t=Rt(e.generation.metadataRaw);if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.usableForEvidenceCache)return null;let n=vl(t.metadata.fingerprint);return n?{builder:Ro({projectFiles:$r(e),snapshot:n,graph:Wn(e),engineIdentity:Co()}),identities:new Map}:null}catch{return null}}function Fo(e,t){let n=new Map(e.map(i=>[i.symbol,i])),r=new Map(e.map(i=>[i.symbolId,[]]));for(let i of t.values())for(let o of i){let s=n.get(o.targetSymbol);s&&r.get(s.symbolId).push(o.location)}for(let[i,o]of r)r.set(i,aC(o));return r}function Lf(e,t,n){let r=_f(e,t),i=_f(e,n),o=[...r].filter(d=>!i.has(d)).sort(),s=[...i].filter(d=>!r.has(d)).sort(),a=kf(e,t),c=kf(e,n),l=[...a].filter(d=>!c.has(d)).sort(),u=[...c].filter(d=>!a.has(d)).sort();return{passed:o.length===0&&s.length===0,expectedCount:r.size,actualCount:i.size,missing:o,extra:s,callerFiles:{passed:l.length===0&&u.length===0,expectedCount:a.size,actualCount:c.size,missing:l,extra:u}}}function kf(e,t){let n=new Set;for(let r of e)for(let i of t.get(r.symbolId)??[])i.file!==r.relativePath&&n.add(`${r.symbol}\0${i.file}`);return n}function E$(e,t,n){let r=new Set(n),i=new Map(n.map(o=>[o,[]]));for(let o of e)for(let s of t.get(o.symbolId)??[])r.has(s.file)&&i.get(s.file).push({targetSymbol:o.symbol,location:s});for(let[o,s]of i)i.set(o,cC(s));return i}function _f(e,t){let n=new Set;for(let r of e)for(let i of t.get(r.symbolId)??[])n.add(`${r.symbol}\0${i.file}\0${i.line}\0${i.column}`);return n}function aC(e){let t=new Map;for(let n of e)t.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...t.values()].sort(Df)}function cC(e){let t=new Map;for(let n of e){let{location:r}=n;t.set(`${n.targetSymbol}\0${r.file}\0${r.line}\0${r.column}`,n)}return[...t.values()].sort((n,r)=>n.targetSymbol.localeCompare(r.targetSymbol)||Df(n.location,r.location))}function Df(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.column-t.column}var uc="typescript-reference-fragment-v2",To=$e({kind:"typescript-reference-fragments",invalidation:Ie("typescript-reference-fragments"),serialize:e=>JSON.stringify(e),deserialize:uC});function L$(e,t,n,r=e){let i=$r(e),o=Ro({projectFiles:i,snapshot:t,graph:Wn(e),engineIdentity:Co()}),s=[...n].map(([a,c])=>({relativePath:a,contentHash:o.identityFor(a,uc).key,value:[...c]}));if(s.some(a=>a.contentHash===null))throw new Error("TypeScript reference fragment identity is unavailable for an affected document.");return To.writeBatch(r,s.map(a=>({...a,contentHash:a.contentHash}))),s.length}function D$(e,t,n,r){let i=t.filter(s=>Eo(s.relativePath));if(i.length===0)return No("no TypeScript definitions");let o=No("shadow did not run");return ae("typescript.reference-fragments.shadow",()=>{try{let s=r(i[0].relativePath);if(!s.availability().available||!s.referenceFragmentsForFiles)return o=No("TypeScript reference fragment provider is unavailable"),o;let a=$r(e),c=new Set(a),l=s.referenceFragmentsForFiles(a),u=Fo(i,l),d=Lf(i,lC(n,c),u);if(!d.passed)return o={state:"failing",files:a.length,keyedFiles:0,writtenFiles:0,...d},o;let p=[];for(let f of a){let m=lc(e,f,uc);m?.key&&p.push({relativePath:f,contentHash:m.key,value:l.get(f)??[]})}return To.writeBatch(e,p),o={state:"passing",files:a.length,keyedFiles:p.length,writtenFiles:p.length,...d},o}catch(s){return o=No(s instanceof Error?s.message:String(s)),o}},()=>({...o}))}function lC(e,t){return new Map([...e].map(([n,r])=>[n,r.filter(i=>t.has(i.file))]))}function A$(e,t,n){if(t.length===0)return{references:new Map,files:0,cacheHits:0,cacheMisses:0,computedFiles:0};let r="fallback",i=0,o=0,s=0,a=0;return ae("typescript.reference-fragments.materialize",()=>{try{let c=$r(e);i=c.length;let l=new Map,u=new Map,d=[];for(let m of c){let g=lc(e,m,uc);if(!g?.key)return null;l.set(m,g.key);let y=To.read(e,m,g.key);y===null?(s+=1,d.push(m)):(o+=1,u.set(m,y))}if(s===0)return r="hit",{references:Fo(t,u),files:i,cacheHits:o,cacheMisses:s,computedFiles:a};let p=n(t[0].relativePath);if(!p.availability().available||!p.referenceFragmentsForFiles)return null;let f=p.referenceFragmentsForFiles(d);if(d.some(m=>!f.has(m)))return null;a=f.size,To.writeBatch(e,d.map(m=>({relativePath:m,contentHash:l.get(m),value:f.get(m)??[]})));for(let[m,g]of f)u.set(m,g);return r="computed",{references:Fo(t,u),files:i,cacheHits:o,cacheMisses:s,computedFiles:a}}catch{return null}},()=>({state:r,files:i,cacheHits:o,cacheMisses:s,computedFiles:a}))}function No(e){return{state:"unavailable",files:0,keyedFiles:0,writtenFiles:0,expectedCount:0,actualCount:0,missing:[],extra:[],reason:e}}function uC(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(dC)?null:t}catch{return null}}function dC(e){if(!e||typeof e!="object")return!1;let t=e,n=t.location;return typeof t.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}import pC from"better-sqlite3";var fC=["busy_timeout = 5000","query_only = ON","temp_store = MEMORY","cache_size = -64000","mmap_size = 268435456"],dc=class{constructor(t,n){this.connection=t;this.releaseGenerationReader=n}connection;releaseGenerationReader;active=!0;initialize(t){try{for(let n of fC)this.connection.pragma(n);t(this.connection)}catch(n){try{this.close()}catch(r){throw new AggregateError([n,r],"SQLite initialization and rollback both failed.",{cause:r})}throw n}}close(){if(!this.active)return;this.active=!1;let t,n;try{this.connection.close()}catch(r){t=r}try{this.releaseGenerationReader()}catch(r){n=r}if(t!==void 0&&n!==void 0)throw new AggregateError([t,n],"SQLite connection close and generation-reader release both failed.");if(t!==void 0)throw t;if(n!==void 0)throw n}},mC=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".scipquery-cache","__pycache__",".venv","venv"],Af=class{db;config;generation;pathFilter;connection;connectionOwnership;statementCache=new Map;constructor(t,n){this.config=t,this.pathFilter=n??null;let r=SC(t),i=new dc(r.db,r.release);try{i.initialize(hC),this.generation=r.generation,this.connection=r.db,this.connectionOwnership=i,this.db=gC(r.db)}catch(o){try{i.close()}catch(s){throw new AggregateError([o,s],"SQLite construction and rollback both failed.",{cause:s})}throw o}}isIgnored(t){return this.pathFilter?.isIgnored(t)??!1}get localSymbolPredicate(){return`(
313
- EXISTS (
314
- SELECT 1
315
- FROM defn_enclosing_ranges local_der
316
- JOIN documents local_d ON local_der.document_id = local_d.id
317
- WHERE local_der.symbol_id = gs.id
318
- ${this.pathExclusionsFor("local_d").trimStart()}
319
- )
320
- OR EXISTS (
321
- SELECT 1
322
- FROM mentions local_m
323
- JOIN chunks local_c ON local_m.chunk_id = local_c.id
324
- JOIN documents local_d ON local_c.document_id = local_d.id
325
- WHERE local_m.symbol_id = gs.id
326
- AND local_m.role = 1
327
- ${this.pathExclusionsFor("local_d").trimStart()}
328
- )
329
- )`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(n=>mC.flatMap(r=>[`AND ${n}.relative_path NOT LIKE '${r}/%'`,`AND ${n}.relative_path NOT LIKE '%/${r}/%'`])).join(`
330
- `)}symbolNoiseFor(t){return`AND ${t}.symbol NOT LIKE '%().(%' AND ${t}.symbol NOT LIKE '%typeLiteral%'`}all(t,...n){return this.statement(t).all(...n)}get(t,...n){return this.statement(t).get(...n)}close(){this.statementCache.clear(),this.connectionOwnership.close()}statement(t){let n=this.statementCache.get(t);return n||(n=this.connection.prepare(t),this.statementCache.set(t,n)),n}};function gC(e){return Object.freeze({prepare(t){let n=e.prepare(t);if(!n.readonly||!n.reader)throw new Error("ScipDatabase.db only permits read-only statements that return rows.");return yC(n)}})}function yC(e){let t={get:(...n)=>e.get(...n),all:(...n)=>e.all(...n),iterate:(...n)=>e.iterate(...n),pluck(n){return n===void 0?e.pluck():e.pluck(n),t},expand(n){return n===void 0?e.expand():e.expand(n),t},raw(n){return n===void 0?e.raw():e.raw(n),t},bind(...n){return e.bind(...n),t},columns:()=>e.columns(),safeIntegers(n){return n===void 0?e.safeIntegers():e.safeIntegers(n),t}};return Object.freeze(t)}function hC(e){if(!e.prepare("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = 'documents'").get())return;let n=e.prepare("SELECT relative_path FROM documents").iterate();for(let r of n)ve(r.relative_path)}function SC(e){for(let t=0;t<4;t+=1){let n=Cf(e),r=n.generation,i;try{i=new pC(r.databasePath,{readonly:!0,fileMustExist:!0})}catch(o){throw n.release(),o}if(r.source==="immutable")return{db:i,generation:r,release:n.release};try{let o=cc(e);if(r.databaseFileIdentity===bt(r.databasePath)&&o.source==="legacy"&&o.identity===r.identity&&o.databaseFileIdentity===r.databaseFileIdentity&&o.metadataRaw===r.metadataRaw)return{db:i,generation:r,release:n.release}}catch(o){throw i.close(),n.release(),o}i.close(),n.release()}throw new Error("SQLite index publication changed repeatedly while opening a coherent generation.")}import bC from"ignore";import{existsSync as Of,readdirSync as xC}from"fs";import{dirname as pc,isAbsolute as Mf,join as ko,relative as vC,resolve as IC}from"path";function z$(e){let t=bC();return EC(e,t)||t.add(wC),{isIgnored:r=>fc(t,e,r),filter:r=>r.filter(i=>!fc(t,e,i))}}function EC(e,t){let n=new Set,r=(s,a)=>{if(!(n.has(s)||!Of(s)))try{let c=j(s,{maxBytes:Q,inputKind:"gitignore file"});t.add(a?PC(c,a):c),n.add(s)}catch{}},i=pc(e),o=0;for(;i!==pc(i)&&o<5&&(r(ko(i,".gitignore"),""),!Of(ko(i,".git")));)i=pc(i),o++;return jf(e,"",t,r),n.size>0}function jf(e,t,n,r){let i=t?ko(e,t):e;r(ko(i,".gitignore"),t);let o;try{o=xC(i,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name===".git")continue;let a=t?`${t}/${s.name}`:s.name;fc(n,e,`${a}/`)||jf(e,a,n,r)}}function PC(e,t){let n=t.replaceAll("\\","/").replace(/\/+$/,"");return e.split(/\r?\n/).map(r=>RC(r,n)).join(`
331
- `)}function RC(e,t){let n=e.trimStart();if(!n||n.startsWith("#"))return e;let r=e.slice(0,e.length-n.length),i=n.startsWith("!"),o=i?n.slice(1):n;if(!o||o.startsWith("#"))return e;let s=o.startsWith("/"),a=s?o.slice(1):o,u=(a.endsWith("/")?a.slice(0,-1):a).includes("/")||s?`${t}/${a}`:`${t}/**/${a}`;return`${r}${i?"!":""}${u}`}var wC=`
332
- # Dependencies
333
- node_modules/
334
- vendor/
335
- .bundle/
336
-
337
- # Build output
338
- dist/
339
- build/
340
- out/
341
- target/
342
- bin/
343
- obj/
344
-
345
- # Python
346
- __pycache__/
347
- *.pyc
348
- *.pyo
349
- .venv/
350
- venv/
351
- .env/
352
- env/
353
- *.egg-info/
354
-
355
- # Rust
356
- target/
357
-
358
- # Java / Kotlin / Scala
359
- *.class
360
- .gradle/
361
- .mvn/
362
-
363
- # C# / .NET
364
- bin/
365
- obj/
366
- packages/
367
-
368
- # Go
369
- vendor/
370
-
371
- # Dart
372
- .dart_tool/
373
- build/
374
-
375
- # PHP
376
- vendor/
377
-
378
- # IDE / OS
379
- .idea/
380
- .vscode/
381
- *.swp
382
- *.swo
383
- .DS_Store
384
- Thumbs.db
385
-
386
- # Type definitions (often noise in queries)
387
- *.d.ts
388
- `;function fc(e,t,n){let r=CC(t,n);if(!r)return!1;try{return e.ignores(r)}catch{return!1}}function CC(e,t){if(!t||t===".")return null;if(!Mf(t)&&!t.startsWith(".."))return t.replaceAll("\\","/");let n=Mf(t)?t:IC(e,t),r=vC(e,n).replaceAll("\\","/");return!r||r==="."||r.startsWith("..")?null:r}import{execFileSync as FC}from"child_process";import{existsSync as NC,readdirSync as $f}from"fs";import{extname as Gf,join as Vf}from"path";var qf=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),TC=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function _o(e){let t=[],n=kC(e),r=AC(e);for(let i of TC){if(_C(e,i.files)){t.push(i.language);continue}if(LC(n,i.globs)){t.push(i.language);continue}MC(r,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&Bf(t,"javascript"),t.includes("cpp")&&!r.has(".c")&&Bf(t,"c"),t}function kC(e){try{return $f(e)}catch{return[]}}function _C(e,t){return t?.length?t.some(n=>NC(Vf(e,n))):!1}function LC(e,t){return t?.length?e.some(n=>t.some(r=>DC(n,r))):!1}function DC(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[n,r]=t.split("*");return e.startsWith(n??"")&&e.endsWith(r??"")}function AC(e){let t=OC(e);if(t)return t;let n=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let o;try{o=$f(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=Vf(i,s.name);if(s.isDirectory()){qf.has(s.name)||r.push(a);continue}let c=Gf(s.name).toLowerCase();c&&n.add(c)}}return n}function OC(e){try{let t=hi(e,26214400,()=>FC("git",["-C",e,"ls-files","-co","-v","-z","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:52428800,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"})),n=new Set;for(let r of Si(t)){if(r.split("/").some(o=>qf.has(o)))continue;let i=Gf(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function MC(e,t){return t?.length?t.some(n=>e.has(n)):!1}function Bf(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import jC from"better-sqlite3";var BC=25,$C=new Set(["typescript","javascript"]);function tG(e,t,n){let r=null;try{r=new jC(e,{readonly:!0,fileMustExist:!0});let i=new Set(r.prepare("SELECT relative_path FROM documents").pluck().all().map(Nt)),o=GC(t,n),s=new Set([...o.values()].flatMap(u=>[...u])),a=[...s].filter(u=>!i.has(u)).sort();if(a.length===0)return{state:"complete",expectedDocumentCount:s.size,actualDocumentCount:i.size};let c=new Set(a),l=n.filter(u=>[...o.get(u)??[]].some(d=>c.has(d)));return{state:"incomplete",expectedDocumentCount:s.size,actualDocumentCount:i.size,missingDocumentCount:a.length,missingPaths:a.slice(0,BC),affectedLanguages:l}}catch(i){return{state:"unavailable",reason:i instanceof Error?i.message:String(i)}}finally{r?.close()}}function GC(e,t){let n=new Map,r=t.filter(i=>$C.has(i));for(let i of r)n.set(i,new Set);for(let i of e.files){let o=Nt(i.path);for(let s of r)Et(o,[s])==="source"&&n.get(s).add(o)}return n}import{existsSync as zf,readdirSync as Uf,rmSync as Hf}from"fs";import{join as Zn}from"path";import{create as Jf,fromBinary as Xf,toBinary as dG}from"@bufbuild/protobuf";import{deserializeSCIP as mc,DocumentSchema as Yf,IndexSchema as Qf,serializeSCIP as Zf}from"@c4312/scip";import{existsSync as VC,mkdirSync as qC,renameSync as WC,writeFileSync as zC}from"fs";import{join as UC}from"path";function Wf(e){qC(e.blobDir,{recursive:!0});let t=UC(e.blobDir,`${e.blobHash}.scipdoc`);if(VC(t)){let r=J(t,{maxBytes:Kt,inputKind:e.inputKind});if(r.byteLength!==e.bytes.byteLength||K(r)!==e.blobHash)throw new Error(`existing ${e.inputKind} is corrupt: ${e.relativePath}`);return}let n=`${t}.${process.pid}.${Date.now()}.tmp`;zC(n,e.bytes),WC(n,t)}var gc=1,Gr="typescript-scip-fragments";function gG(e){if(e.length===0)throw new Error("affected TypeScript mini index requires documents");let t=new Set,n=[];for(let o of e){let s=Lo(o.relativePath);if(t.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(t.add(s),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${s}`);let a=Xf(Yf,o.bytes);if(a.relativePath!==s)throw new Error(`TypeScript fragment path mismatch: expected ${s}, got ${a.relativePath}`);n.push(a)}let r=Zf(Jf(Qf,{documents:n,externalSymbols:[]})),i=mc(r);if(i.documents.length!==n.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return r}function HC(e){let t=Zn(e,Gr);return{rootDir:t,blobDir:Zn(t,"blobs"),generationDir:Zn(t,"generations")}}function em(e){let t=KC(e);return JC(t.baseIndex,t.completeDocuments,"assembled")}function KC(e){let t=mc(e.baseIndexBytes);ZC(t.metadata,eF(e)),QC(t.externalSymbols);let n=new Map;for(let a of e.fragments){let c=Lo(a.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);n.set(c,a)}if(n.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let r=new Set,i=[],o=[],s=[];for(let a of t.documents){let c=Lo(a.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);r.add(c);let l=n.get(c);if(!l){i.push(a);continue}if(n.delete(c),l.bytes===null){s.push(c);continue}let u=Kf(c,l.bytes);i.push(u),o.push(u)}for(let a of[...n.keys()].sort()){let c=n.get(a);if(c.bytes===null)throw new Error(`TypeScript fragment deletion has no prior document: ${a}`);if(r.has(a))throw new Error(`duplicate TypeScript SCIP document path: ${a}`);r.add(a);let l=Kf(a,c.bytes);i.push(l),o.push(l)}return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:s}}function Kf(e,t){let n=Xf(Yf,t);if(n.relativePath!==e)throw new Error(`TypeScript fragment path mismatch: expected ${e}, got ${n.relativePath}`);return n}function JC(e,t,n){let r=Zf(Jf(Qf,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=mc(r);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${n} TypeScript SCIP index failed structural verification`);return r}function yG(e,t){let n=HC(e);if(!zf(n.generationDir))return;let r=new Set(t.map(s=>YC(s))),i=Uf(n.generationDir).filter(s=>s.endsWith(".json")),o=new Set;for(let s of i.filter(a=>r.has(a))){let a=XC(j(Zn(n.generationDir,s),{maxBytes:Q,inputKind:"TypeScript fragment manifest"}));for(let c of a.documents)o.add(`${c.blobHash}.scipdoc`)}for(let s of i)r.has(s)||Hf(Zn(n.generationDir,s),{force:!0});if(zf(n.blobDir))for(let s of Uf(n.blobDir))o.has(s)||Hf(Zn(n.blobDir,s),{force:!0})}function XC(e){let t=JSON.parse(e);if(t.version!==gc||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let n=new Set;for(let r of t.documents){if(!r||typeof r.relativePath!="string"||typeof r.blobHash!="string"||!/^[a-f0-9]{64}$/.test(r.blobHash)||typeof r.byteLength!="number"||!Number.isInteger(r.byteLength)||r.byteLength<0||typeof r.documentIdentity!="string"||!r.documentIdentity)throw new Error("invalid TypeScript fragment record");if(Lo(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript fragment record");n.add(r.relativePath)}return t}function YC(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${K(e)}.json`}function QC(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function ZC(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let n=e,r=n.toolInfo??n.tool_info;if(!r||typeof r!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=r;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function eF(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function Lo(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}import{existsSync as Do,readdirSync as yc,rmSync as tm}from"fs";import{join as et}from"path";var Ao=1;var Vr="typescript-scip-overlays";function RG(e){let t=rm(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t&&(t.producerIdentity!==e.producerIdentity||t.projectIdentity!==e.projectIdentity))throw new Error("TypeScript overlay producer or project identity changed");let n=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),r=new Set;for(let o of e.fragments){let s=bc(o.relativePath);if(r.has(s))throw new Error(`duplicate TypeScript overlay: ${s}`);r.add(s),n.set(s,tF(e.cacheDir,o))}if(r.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:Ao,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...n.values()].sort((o,s)=>o.relativePath.localeCompare(s.relativePath))};return nF(e.cacheDir,i),i}function wG(e){let t=rm(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let n=t.overlays.map(r=>{if(r.blobHash===null)return{relativePath:r.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=J(et(qr(e.cacheDir),"blobs",`${r.blobHash}.scipdoc`),{maxBytes:Kt,inputKind:"TypeScript overlay blob"});if(i.byteLength!==r.byteLength||K(i)!==r.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${r.relativePath}`);return{relativePath:r.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return em({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:n})}function CG(e,t){let n=qr(e),r=et(n,"generations");if(!Do(r))return;let i=new Set(t.map(Sc)),o=new Set;for(let a of yc(r).filter(c=>i.has(c))){let c=hc(j(et(r,a),{maxBytes:Q,inputKind:"TypeScript overlay manifest"}));for(let l of c.overlays)l.blobHash&&o.add(`${l.blobHash}.scipdoc`)}for(let a of yc(r))i.has(a)||tm(et(r,a),{force:!0});let s=et(n,"blobs");if(Do(s))for(let a of yc(s))o.has(a)||tm(et(s,a),{force:!0})}function rm(e,t){let n=et(qr(e),"generations",Sc(t));if(!Do(n))return null;let r=hc(j(n,{maxBytes:Q,inputKind:"TypeScript overlay manifest"}));if(r.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return r}function tF(e,t){let n=bc(t.relativePath);if(t.bytes===null)return{relativePath:n,blobHash:null,byteLength:0};let r=Buffer.from(t.bytes),i=K(r);return Wf({blobDir:et(qr(e),"blobs"),blobHash:i,bytes:r,relativePath:n,inputKind:"TypeScript overlay blob"}),{relativePath:n,blobHash:i,byteLength:r.byteLength}}function nF(e,t){let n=et(qr(e),"generations",Sc(t.generationIdentity));if(Do(n)){let r=hc(j(n,{maxBytes:Q,inputKind:"TypeScript overlay manifest"}));if(nm(r)!==nm(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}Jn(n,t,{spacing:2,trailingNewline:!0})}function hc(e){let t=JSON.parse(e);if(t.version!==Ao||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let n=new Set;for(let r of t.overlays){if(!r||typeof r.relativePath!="string"||r.blobHash!==null&&(typeof r.blobHash!="string"||!/^[a-f0-9]{64}$/.test(r.blobHash))||!Number.isInteger(r.byteLength)||r.byteLength<0||r.blobHash===null&&r.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(bc(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript overlay record");n.add(r.relativePath)}return t}function qr(e){return et(e,Vr)}function Sc(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${K(e)}.json`}function nm(e){return K(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function bc(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}import{writeFileSync as rF}from"fs";import{create as im}from"@bufbuild/protobuf";import{deserializeSCIP as iF,DocumentSchema as oF,IndexSchema as sF,serializeSCIP as aF,SymbolRole as cF}from"@c4312/scip";function DG(e){let t;try{t=iF(J(e,{inputKind:"SCIP sanitization input",maxBytes:pe}))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let n=xc(t);return n.removedDefinitionOccurrences>0&&rF(e,aF(n.index)),{removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function xc(e){let t=new Set;for(let o of e.documents){ve(o.relativePath);for(let s of o.symbols)s.symbol&&t.add(s.symbol)}for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let n=0,r=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&cF.Definition)===0||t.has(a.symbol)?!0:(n+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(im(oF,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:n===0?e:im(sF,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}import{writeFileSync as vc}from"fs";import{create as Wr}from"@bufbuild/protobuf";import{deserializeSCIP as Ic,serializeSCIP as Ec,DocumentSchema as lF,IndexSchema as om,MetadataSchema as uF,SymbolInformationSchema as dF}from"@c4312/scip";function sm(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=fF(e),n=mF(e.flatMap(i=>i.documents??[])),r=cm(e.flatMap(i=>i.externalSymbols??[]));return Wr(om,{metadata:t,documents:n,externalSymbols:r})}function VG(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>Ic(J(i,{inputKind:"SCIP merge input",maxBytes:pe}))),r=sm(n);return vc(t,Ec(r)),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function qG(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=ae("reindex.publish.scip-output.deserialize",()=>e.map(o=>Ic(J(o,{inputKind:"SCIP merge input",maxBytes:pe})))),r=ae("reindex.publish.scip-output.merge",()=>sm(n)),i=ae("reindex.publish.scip-output.sanitize",()=>xc(r));return ae("reindex.publish.scip-output.serialize",()=>vc(t,Ec(i.index))),{documentCount:i.index.documents.length,externalSymbolCount:i.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:i.removedDefinitionOccurrences,touchedDocuments:i.touchedDocuments}}function pF(e,t,n){let r=e.metadata;if(!r)throw new Error("Cannot rebase a SCIP index without metadata");if(r.projectRoot!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${r.projectRoot}`);return Wr(om,{metadata:Wr(uF,{...r,projectRoot:n}),documents:e.documents,externalSymbols:e.externalSymbols})}function am(e,t,n){let r=Ic(J(e,{inputKind:"SCIP normalization input",maxBytes:pe})),i=pF(r,t,n);vc(e,Ec(i))}function fF(e){let t=e[0]?.metadata;if(!t)return;let n=t.projectRoot;for(let r of e.slice(1)){let i=r.metadata?.projectRoot;if(n&&i&&i!==n)throw new Error(`Cannot merge SCIP indexes with different project roots: ${n} vs ${i}`)}return t}function mF(e){let t=new Map;for(let n of e){let r=t.get(n.relativePath);if(!r){t.set(n.relativePath,n);continue}t.set(n.relativePath,Wr(lF,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:gF([...r.occurrences,...n.occurrences]),symbols:cm([...r.symbols,...n.symbols]),text:hF(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function gF(e){let t=new Set,n=[];for(let r of e){let i=JSON.stringify(r);t.has(i)||(t.add(i),n.push(r))}return n}function cm(e){let t=new Map;for(let n of e){let r=t.get(n.symbol);if(!r){t.set(n.symbol,n);continue}t.set(n.symbol,Wr(dF,{symbol:r.symbol,documentation:SF([...r.documentation,...n.documentation]),relationships:yF([...r.relationships,...n.relationships]),kind:r.kind||n.kind,displayName:r.displayName||n.displayName,enclosingSymbol:r.enclosingSymbol||n.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??n.signatureDocumentation}))}return[...t.values()]}function yF(e){let t=new Set,n=[];for(let r of e){let i=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),n.push(r))}return n}function hF(e,t){return e?t?e.length>=t.length?e:t:e:t}function SF(e){return[...new Set(e)]}import{createHash as Nc}from"crypto";import{closeSync as bF,existsSync as _,mkdirSync as xF,openSync as vF,readSync as IF,readdirSync as Tc,renameSync as Cc,rmSync as zr,statSync as er}from"fs";import{basename as pm,dirname as tt,join as k,relative as lm}from"path";var Fc=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function fm(e){let t=H(e.outputDb),n=CF(e);e.onStage?.("after-recovery-retained");let r=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=Lc({generationRoot:t,databasePath:e.tempOutputDb,indexPath:_(r)?r:void 0,metadataPath:_(e.tempMetaPath)?e.tempMetaPath:void 0}),o=(e.now??(()=>new Date))().toISOString(),s={version:hn,currentGeneration:i.identity,artifactSet:"immutable-v1",...n?{previousGeneration:n}:{},...e.publication?{publication:e.publication}:{},publishedAt:o},a=Ze(k(t,"state.json"),s,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||wc(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),wc(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),wc(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let c=i.identity,l={...s,stableMirrors:_c(e.outputDb,e.outputScip)};Ze(k(t,"state.json"),l,{spacing:2,trailingNewline:!0});let u=mm(e.outputDb,{now:e.now}),d=X(i.directorySync,a.directorySync);return{currentGeneration:c,...n?{previousGeneration:n}:{},retention:u,achievedDurability:d==="synced"?"directory-durable":"file-flushed",directorySync:d}}function EF(e,t,n,r=()=>new Date){if(!_(e))return null;let i=Bt(e),o=k(H(e),"state.json");if(i?.artifactSet==="immutable-v1"&&Io(e,i.currentGeneration))return i;let s=H(e),a=!i&&_(o)?NF(n,e,t):void 0;if(a&&!jr(s,a))return null;let c=Lc({generationRoot:s,databasePath:e,indexPath:_(t)?t:void 0,metadataPath:_(n)?n:void 0,forcedIdentity:i?.currentGeneration??a}),l={version:hn,currentGeneration:c.identity,artifactSet:"immutable-v1",stableMirrors:_c(e,t),...i?.previousGeneration?{previousGeneration:i.previousGeneration}:{},...i?.publication?{publication:i.publication}:{},publishedAt:i?.publishedAt??r().toISOString()};return Ze(k(s,"state.json"),l,{spacing:2,trailingNewline:!0}),l}function t1(e,t,n=()=>new Date){if(!_(e)||!_(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let r=Bt(e),i=H(e),o=Lc({generationRoot:i,databasePath:e,indexPath:_(k(tt(e),"index.scip"))?k(tt(e),"index.scip"):void 0,metadataPath:t}),s=r&&r.currentGeneration!==o.identity?hm(e,r.currentGeneration):void 0,a={version:hn,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:_c(e,k(tt(e),"index.scip")),...s?{previousGeneration:s}:{},...r?.publication?{publication:r.publication}:{},publishedAt:n().toISOString()};return Ze(k(H(e),"state.json"),a,{spacing:2,trailingNewline:!0}),mm(e,{now:n}),a}function mm(e,t={}){let n=PF(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=St(vo(e),{waitMs:0});if(!o)return{state:"deferred",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:n,at:i,reason:"another process owns local generation retention"};try{let s=Bt(e),a=gm(e),c=ac(e,a.map(y=>y.identity),{isProcessAlive:t.isProcessAlive??gn,readProcessIdentity:t.readProcessIdentity??ht}),l=new Set(c.protectedGenerations);s?.currentGeneration&&l.add(s.currentGeneration),s?.previousGeneration?.generationIdentity&&l.add(s.previousGeneration.generationIdentity);let u=a.length,d=a.reduce((y,I)=>y+I.logicalBytes,0),p=0,f=0;for(let y of a){if(u<=n.maxGenerations&&d<=n.maxLogicalBytes)break;l.has(y.identity)||(t.onBeforeRemove?.(y.identity),zr(y.path,{recursive:!0,force:!0}),u-=1,d-=y.logicalBytes,p+=1,f+=y.logicalBytes)}let m=u>n.maxGenerations||d>n.maxLogicalBytes,g={state:m?"protected":p>0?"collected":"within-bounds",generationCount:u,logicalBytes:d,protectedGenerations:l.size,activeReaderLeases:c.activeLeases,staleReaderLeasesRemoved:c.staleLeasesRemoved,malformedReaderLeases:c.malformedLeases,removedGenerations:p,removedLogicalBytes:f,limits:n,at:i,...m?{reason:c.malformedLeases>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}:{}};return um(e,g),g}catch(s){let a={state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:n,at:i,reason:s instanceof Error?s.message:String(s)};try{um(e,a)}catch{}return a}finally{o.release()}}function n1(e){let t=H(e);if(!_(t))return{state:"absent",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:{...Fc},reason:"local immutable generation store does not exist"};let n=RF(e),r=n?.limits??{...Fc},i=St(vo(e),{waitMs:0});if(!i)return{state:"deferred",generationCount:n?.generationCount??0,logicalBytes:n?.logicalBytes??0,protectedGenerations:n?.protectedGenerations??0,activeReaderLeases:n?.activeReaderLeases??0,malformedReaderLeases:n?.malformedReaderLeases??0,limits:r,...n?{lastCollection:n}:{},reason:"another process owns local generation retention"};try{let o=gm(e),s=Bt(e),a=ac(e,o.map(l=>l.identity),{isProcessAlive:gn,readProcessIdentity:ht},{removeStale:!1}),c=new Set(a.protectedGenerations);return s?.currentGeneration&&c.add(s.currentGeneration),s?.previousGeneration?.generationIdentity&&c.add(s.previousGeneration.generationIdentity),{state:"managed",generationCount:o.length,logicalBytes:o.reduce((l,u)=>l+u.logicalBytes,0),...o[0]?{oldestGenerationAt:new Date(o[0].modifiedAtMs).toISOString()}:{},protectedGenerations:c.size,activeReaderLeases:a.activeLeases,malformedReaderLeases:a.malformedLeases,limits:r,...n?{lastCollection:n}:{},...a.malformedLeases>0?{reason:"malformed reader ownership evidence prevents unsafe collection"}:{}}}catch(o){return{state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:r,...n?{lastCollection:n}:{},reason:o instanceof Error?o.message:String(o)}}finally{i.release()}}function PF(e={}){let t={...Fc,...e};if(!Number.isSafeInteger(t.maxGenerations)||t.maxGenerations<2)throw new Error("Local SQLite generation retention must keep at least current and previous generations.");if(!Number.isSafeInteger(t.maxLogicalBytes)||t.maxLogicalBytes<=0)throw new Error("Local SQLite generation byte retention must be a positive safe integer.");return t}function gm(e){let t=H(e);return _(t)?Tc(t,{withFileTypes:!0}).filter(n=>n.isDirectory()&&/^[a-f0-9]{64}$/.test(n.name)).map(n=>{let r=k(t,n.name),i=jr(t,n.name),o=i?i.database.size+(i.index?.size??0)+(i.metadata?.size??0):ym(r);return{identity:n.name,path:r,logicalBytes:o,modifiedAtMs:er(r).mtimeMs}}).sort((n,r)=>n.modifiedAtMs-r.modifiedAtMs||n.identity.localeCompare(r.identity)):[]}function ym(e){let t=0;for(let n of Tc(e,{withFileTypes:!0})){let r=k(e,n.name);n.isDirectory()?t+=ym(r):n.isFile()&&(t+=er(r).size)}return t}function um(e,t){Jn(k(H(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function RF(e){try{let t=JSON.parse(F(k(H(e),"gc.json"),"local SQLite generation GC status"));return!t||t.state!=="within-bounds"&&t.state!=="collected"&&t.state!=="protected"&&t.state!=="deferred"&&t.state!=="error"||!Number.isSafeInteger(t.generationCount)||t.generationCount<0||!Number.isFinite(t.logicalBytes)||t.logicalBytes<0||!Number.isFinite(Date.parse(t.at))?void 0:t}catch{return}}function kc(e,t=k(tt(e),"meta.json")){let n=k(H(e),"state.json");if(!_(n))return{state:"legacy",statePath:n};let r=Bt(e);if(!r)return{state:"invalid",statePath:n,reason:"generation state is malformed"};try{let i=Io(e,r.currentGeneration),o=i!==null,s=i?wF(e,t,i,r):!1,a=r.previousGeneration?_(k(tt(e),r.previousGeneration.databasePath)):!0;return!s||!o||!a?{state:"drifted",statePath:n,currentMatches:s,recoveryExists:a,generation:r,reason:o?s?"retained recovery database is missing":"stable database or metadata no longer matches the published generation":"published immutable generation is missing"}:{state:"current",statePath:n,currentMatches:s,recoveryExists:a,generation:r}}catch(i){return{state:"drifted",statePath:n,currentMatches:!1,recoveryExists:!1,generation:r,reason:i instanceof Error?i.message:String(i)}}}function wF(e,t,n,r){if(r.stableMirrors&&(r.stableMirrors.databaseFileIdentity!==bt(e)||r.stableMirrors.indexFileIdentity!==void 0&&r.stableMirrors.indexFileIdentity!==bt(k(tt(e),"index.scip")))||!dm(e,n.database))return!1;let i=k(tt(e),"index.scip");if(n.index&&!dm(i,n.index))return!1;if(!n.metadata)return!_(t);if(!_(t))return!1;let o=k(H(e),n.identity,n.metadata.file);return _(o)&&$t(F(t,"reindex metadata"))===$t(F(o,"immutable reindex metadata"))}function dm(e,t){return _(e)&&er(e).isFile()&&er(e).size===t.size}function CF(e){let t=EF(e.outputDb,e.outputScip,e.metaPath);return t?hm(e.outputDb,t.currentGeneration):void 0}function _c(e,t){return{databaseFileIdentity:bt(e),..._(t)?{indexFileIdentity:bt(t)}:{}}}function hm(e,t){let n=k(H(e),t),r=k(n,pm(e)),i=k(n,"meta.json");return{generationIdentity:t,databasePath:lm(tt(e),r),..._(i)?{metadataPath:lm(tt(e),i)}:{}}}function FF(e){if(_(e))for(let t of Tc(e,{withFileTypes:!0}))t.isDirectory()&&t.name.endsWith(".tmp")&&zr(k(e,t.name),{recursive:!0,force:!0})}function NF(e,t,n=k(tt(t),"index.scip")){let r=Nc("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(Oo(t)),_(n)&&r.update(`\0${Oo(n)}`),_(e)&&r.update(`\0${$t(F(e,"reindex metadata"))}`),r.digest("hex")}function Lc(e){let t=Pc(e.databasePath),n=e.indexPath?Pc(e.indexPath):void 0,r=e.metadataPath?Pc(e.metadataPath):void 0,i=e.forcedIdentity??TF(t,n,e.metadataPath),o=k(e.generationRoot,i),s=k(o,xo);if(_(s)){let l=jr(e.generationRoot,i);if(l&&Sm(o,l.database,t)&&_F(o,l.index,n)&&LF(o,l.metadata,e.metadataPath))return{identity:i,directorySync:L(e.generationRoot)};throw new Error(`SQLite generation ${i} already exists with different or corrupt artifacts.`)}let a=[ge(e.generationRoot)];FF(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;zr(c,{recursive:!0,force:!0}),xF(c,{recursive:!0});try{a.push(Rc(e.databasePath,k(c,t.file))),n&&e.indexPath&&a.push(Rc(e.indexPath,k(c,n.file))),r&&e.metadataPath&&a.push(Rc(e.metadataPath,k(c,r.file)));let l=Ze(k(c,xo),{version:sc,identity:i,database:t,...n?{index:n}:{},...r?{metadata:r}:{}},{spacing:2,trailingNewline:!0});l.directorySync!=="not-requested"&&a.push(l.directorySync),a.push(L(c)),Cc(c,o),a.push(L(e.generationRoot))}finally{zr(c,{recursive:!0,force:!0})}return{identity:i,directorySync:X(...a)}}function TF(e,t,n){let r=Nc("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(e.sha256),t&&r.update(`\0${t.sha256}`),n&&r.update(`\0${$t(F(n,"reindex metadata"))}`),r.digest("hex")}function Pc(e){return{file:pm(e),size:er(e).size,sha256:Oo(e)}}function Oo(e){let t=Nc("sha256"),n=vF(e,"r"),r=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=kF(n,r);if(i===0)break;t.update(r.subarray(0,i))}}finally{bF(n)}return t.digest("hex")}function kF(e,t){let n=0;for(;n<t.length;){let r=IF(e,t,n,t.length-n,null);if(n+=r,r===0)break}return n}function Rc(e,t){return Ar(e,t,{mode:292})}function Sm(e,t,n){let r=k(e,t.file);return t.file===n.file&&t.size===n.size&&t.sha256===n.sha256&&_(r)&&er(r).size===t.size&&Oo(r)===t.sha256}function _F(e,t,n){return!t||!n?t===n:Sm(e,t,n)}function LF(e,t,n){if(!t||!n)return t===void 0&&n===void 0;let r=k(e,t.file);return _(r)&&$t(F(r,"stored reindex metadata"))===$t(F(n,"candidate reindex metadata"))}function wc(e,t){zr(`${t}.tmp-replace`,{force:!0}),Cc(e,`${t}.tmp-replace`),Cc(`${t}.tmp-replace`,t)}import{createHash as wm,randomUUID as $F}from"crypto";import{existsSync as vt,lstatSync as Oc,mkdirSync as tr,mkdtempSync as Cm,readdirSync as Fm,realpathSync as Nm,renameSync as Sn,rmSync as Gt,statSync as Vo}from"fs";import{dirname as Mc,join as S,resolve as xt}from"path";import{setTimeout as GF}from"timers/promises";import{pathToFileURL as Im}from"url";import{deserializeSCIP as Tm}from"@c4312/scip";import VF from"better-sqlite3";import{lstatSync as DF,readdirSync as AF}from"fs";import{join as OF,relative as MF,resolve as Dc,sep as jF}from"path";var Ur=1,Ac="language-indexes",bm=["index.db","index.scip","meta.json"],xm=[Ac,Gr,Vr];function Mo(e){let t=[];for(let n of bm)BF(e,n),t.push(n);for(let n of xm)vm(e,n,t);return{version:Ur,files:t.sort()}}function jo(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(r=>!r||r==="."||r===".."))throw new Error(`invalid index artifact path: ${e}`);let n=t[0];if(!bm.includes(e)&&!xm.includes(n))throw new Error(`index artifact path is not shareable: ${e}`);return e}function nt(e,t){let n=jo(t),r=Dc(e),i=Dc(r,...n.split("/"));if(i!==r&&!i.startsWith(`${r}${jF}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function vm(e,t,n){let r=OF(e,t),i;try{i=AF(r,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let s=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${s}`);o.isDirectory()?vm(e,s,n):o.isFile()&&n.push(jo(s))}}function BF(e,t){let n=nt(e,t),r;try{r=DF(n)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!r.isFile()||r.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(MF(Dc(e),n).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var $c=1,Em="SCIP_QUERY_SHARED_CACHE",qF=2,$o=JSON.stringify({cliVersion:bi,artifactCatalogVersion:Ur,postIndexAugmentationSchemaVersion:qF,sqliteGenerationStoreVersion:hn,typescriptFragmentStoreVersion:gc,typescriptOverlayStoreVersion:Ao}),Gc="manifest.json",km="shared-cache.json",WF=6e4,Vc=[Ac,Gr,Vr];function Go(e,t){if(!e.clean||!e.treeOid)return;let n=Mm(JSON.stringify({version:$c,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:t,producerIdentity:$o}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:$o,generationId:n,repositoryCacheDir:Ti(e.repositoryId)}}function L1(e,t,n){if(!rN(n))return!1;let r=Go(e,n);if(!r)return!1;try{let i=Am(t);if(!i||i.repositoryId!==e.repositoryId||i.worktreeId!==e.worktreeId)return!1;let o=JSON.parse(j(S(r.repositoryCacheDir,"worktrees",`${i.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:Q}));return o.version!==1||o.repositoryId!==i.repositoryId||o.worktreeId!==i.worktreeId||xt(o.projectRoot)!==xt(e.projectRoot)||o.treeOid!==e.treeOid||xt(o.localCacheDir)!==xt(t)||o.ownershipChecksum!==qo(o)||o.baseGenerationId!==r.generationId||o.activeGenerationId!==r.generationId?!1:It(r,!1)!==null}catch{return!1}}function _m(e,t,n){if(process.env[Em]==="0")return`${Em}=0`;if(!_s(n))return"explicit cache or database override";if(Ds(Mc(t))!==Ds(Ni(e))||t!==S(Mc(t),"index.db"))return"index database is outside the managed worktree cache"}function D1(e,t,n){if(!_s(t))return;let r=n??ur(e);return r?S(Ti(r.repositoryId),"evidence.db"):void 0}function It(e,t=!0){let n=Wc(e),r;try{r=Dm(j(S(n,Gc),{inputKind:"shared-generation manifest",maxBytes:Q}))}catch{return null}if(r.generationId!==e.generationId||r.repositoryId!==e.repositoryId||r.treeOid!==e.treeOid||r.producerIdentity!==e.producerIdentity||JSON.stringify(r.fingerprint)!==JSON.stringify(e.fingerprint))return null;if(!t)return r;try{for(let i of r.artifacts){let o=nt(n,i.path),s=Vo(o);if(!s.isFile()||s.size!==i.size||Jt(o,{inputKind:"shared-generation artifact",maxBytes:pe})!==i.sha256)return null}}catch{return null}return r}function zF(e,t,n){if(!e.treeOid)return null;let r=hr(t,n),i=S(Fi(),"repositories",e.repositoryId),o;try{let c=Oc(i);if(!c.isDirectory()||c.isSymbolicLink())return null;o=Nm(i)}catch{return null}let s=S(o,"generations"),a=[];try{for(let c of Fm(s)){if(!/^[a-f0-9]{64}$/.test(c))continue;let l=S(s,c),u;try{u=Oc(l)}catch{continue}if(!(!u.isDirectory()||u.isSymbolicLink()))try{let d=Dm(j(S(l,Gc),{inputKind:"shared-generation baseline manifest",maxBytes:Q}));d.generationId===c&&d.repositoryId===e.repositoryId&&d.treeOid===e.treeOid&&d.producerIdentity===$o&&QF(d.fingerprint,r)&&a.push(d)}catch{continue}}}catch{return null}a.sort((c,l)=>Date.parse(l.createdAt)-Date.parse(c.createdAt)||c.generationId.localeCompare(l.generationId));for(let c of a){let l={repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:c.fingerprint,producerIdentity:c.producerIdentity,generationId:c.generationId,repositoryCacheDir:o},u=It(l);if(u)return{snapshot:l,manifest:u}}return null}function Lm(e){let t=St(S(e.snapshot.repositoryCacheDir,"locks",`${e.snapshot.generationId}.publish.lock`));if(!t)throw new Error(`shared generation publication is already in progress for ${e.snapshot.generationId}`);try{return UF(e)}finally{t.release()}}function UF(e){let t=It(e.snapshot);if(t)return Pm(e.snapshot,t);if(!Jr(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let n=Rm(e.sourceCacheDir);if(!n)throw new Error("source index artifacts are incomplete");let r=Mo(e.sourceCacheDir),i=S(e.snapshot.repositoryCacheDir,"generations"),o=[ge(i)],s=Cm(S(i,`.tmp-${process.pid}-`));try{let a=[];for(let m of r.files){let g=nt(e.sourceCacheDir,m),y=nt(s,m);o.push(Xr(g,y,292)),e.onPublicationStage?.("after-artifact-flushed",m);let I=Vo(y).size;a.push({path:m,size:I,sha256:Jt(y,{inputKind:"staged shared-generation artifact",maxBytes:pe})})}let c=Tm(J(S(s,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:pe})).metadata?.projectRoot;if(!c)throw new Error("shared SCIP generation has no project root metadata");let l=Uc(e.sourceProjectRoot);if(c!==l)throw new Error("shared SCIP generation root does not match its source worktree");if(Rm(e.sourceCacheDir)!==n||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let u={version:$c,artifactCatalogVersion:Ur,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:c,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:a.sort((m,g)=>m.path.localeCompare(g.path))},d=Ze(S(s,Gc),u,{spacing:2,trailingNewline:!0});d.directorySync!=="not-requested"&&o.push(d.directorySync),e.onPublicationStage?.("after-manifest-flushed"),o.push(L(s)),e.onPublicationStage?.("after-staging-directory-synced");let p=Wc(e.snapshot);try{if(vt(p)&&!It(e.snapshot)){let m=`${p}.corrupt-${process.pid}-${Date.now()}`;Sn(p,m),Gt(m,{recursive:!0,force:!0})}Sn(s,p)}catch(m){let g=It(e.snapshot);if(g)return Pm(e.snapshot,g);throw m}e.onPublicationStage?.("after-generation-renamed"),o.push(L(i)),e.onPublicationStage?.("after-generations-directory-synced");let f=X(...o);return{kind:"published",manifest:u,achievedDurability:f==="synced"?"directory-durable":"file-flushed",directorySync:f}}finally{Gt(s,{recursive:!0,force:!0})}}function Pm(e,t){let n=L(S(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:n==="synced"?"directory-durable":"file-flushed",directorySync:n}}function Bo(e){let t=Wc(e.snapshot);tr(e.targetCacheDir,{recursive:!0});let n=St(S(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:e.lockWaitMs??3e4});if(!n)throw new Error("timed out waiting for another cache hydration");let r,i,o=!1;try{r=Cm(S(e.targetCacheDir,".shared-hydrate-")),nN(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let l=nt(t,c.path),u=nt(r,c.path);if(Xr(l,u),Vo(u).size!==c.size||Jt(u,{inputKind:"hydrated shared-generation artifact",maxBytes:pe})!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let s=Uc(e.targetProjectRoot);if(s!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&am(nt(r,c.path),e.manifest.scipProjectRoot,s);if(!Jr(r,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=ZF(e.targetCacheDir,r),o=!0,eN(r,e.targetCacheDir,i),fm({tempOutputScip:S(r,"index.scip"),tempOutputDb:S(r,"index.db"),tempMetaPath:S(r,"meta.json"),outputScip:S(e.targetCacheDir,"index.scip"),outputDb:S(e.targetCacheDir,"index.db"),metaPath:S(e.targetCacheDir,"meta.json"),now:e.now});let a=kc(S(e.targetCacheDir,"index.db"),S(e.targetCacheDir,"meta.json"));if(a.state==="invalid"||a.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${a.reason}`);e.persistLease!==!1&&jc(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(s){throw o&&i&&tN(e.targetCacheDir,i),s}finally{r&&Gt(r,{recursive:!0,force:!0}),n.release()}}function A1(e,t,n,r){let i=_m(e,n.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=r??ur(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean){if(vt(n.dbPath))return Kr(o,n.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"};let d=t.languages??_o(e),p=zF(o,d,Bc(t));return p?(Bo({snapshot:p.snapshot,manifest:p.manifest,targetCacheDir:n.cacheDir,targetProjectRoot:e,persistLease:!1,lockWaitMs:0}),HF(p.snapshot,n.cacheDir),{kind:"overlay"}):(Kr(o,n.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"})}let s=t.languages??_o(e),a=Di(e,s,Bc(t)),c=Go(o,a);if(!c)return{kind:"missed",reason:"clean committed snapshot is unavailable"};let l=It(c);if(l)return Bo({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId};let u=XF(c,e);return u?(l=u.manifest,Bo({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e,action:"peer-imported"}),{kind:"peer-imported",generationId:c.generationId,sourceProjectRoot:u.sourceProjectRoot}):(Kr(o,n.cacheDir,"missed",void 0,"no exact shared or peer generation exists"),{kind:"missed",reason:"no exact shared or peer generation exists"})}catch(o){return{kind:"failed",reason:o instanceof Error?o.message:String(o)}}}function O1(e,t,n,r){let i=_m(e,n.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=r??ur(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean)return Kr(o,n.cacheDir,"missed",void 0,"worktree is not a clean committed snapshot"),{kind:"missed",reason:"worktree is not a clean committed snapshot"};let s=t.languages??_o(e),a=Di(e,s,Bc(t)),c=Go(o,a);if(!c)return Kr(o,n.cacheDir,"missed",void 0,"worktree is not a clean committed snapshot"),{kind:"missed",reason:"worktree is not a clean committed snapshot"};let l=It(c);if(l)return Jr(n.cacheDir,e,a)?(jc(c,n.cacheDir,"local-fresh"),{kind:"local-fresh"}):(Bo({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId});let u=qc(n.cacheDir);return!u||JSON.stringify(u.fingerprint)!==JSON.stringify(a)||JSON.stringify([...u.indexedLanguages??[]].sort())!==JSON.stringify([...s].sort())?{kind:"missed",reason:"local metadata does not match the clean worktree snapshot"}:Jr(n.cacheDir,e,a)?(Lm({snapshot:c,sourceCacheDir:n.cacheDir,sourceProjectRoot:e,sourceStillValid:()=>{let d=ur(e);return(d?Go(d,a):void 0)?.generationId===c.generationId}}),jc(c,n.cacheDir,"built"),{kind:"built",generationId:c.generationId}):{kind:"missed",reason:"local index artifacts are incomplete or incompatible"}}catch(o){return{kind:"failed",reason:o instanceof Error?o.message:String(o)}}}async function M1(e,t={}){let n=t.timeoutMs??3e4,r=t.pollMs??100,i=t.now??yn,o=i()+n,s=S(e.repositoryCacheDir,"locks"),a=S(s,`${e.generationId}.lock`),c=l=>{if(!l||typeof l!="object"||Array.isArray(l))return null;let u=l.pid;return typeof u=="number"&&Number.isSafeInteger(u)&&u>0?{pid:u}:null};for(;i()<=o;){if(It(e))return{kind:"generation-ready"};let l=So(a,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:c});if(l.kind==="acquired")return{kind:"owner",release:()=>l.lock.release()};let u=o-i();if(u<=0)break;await GF(Math.min(r,u))}return It(e)?{kind:"generation-ready"}:{kind:"timeout"}}function jc(e,t,n,r=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:n,lastSeenAt:(r??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:qo(i)};return zc(e.repositoryCacheDir,o,!0),o}function HF(e,t,n=void 0){let r={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,lastAction:"overlay",lastReason:`private cache forked from shared baseline ${e.generationId}`,lastSeenAt:(n??(()=>new Date))().toISOString()},i={...r,ownershipChecksum:qo(r)};return zc(e.repositoryCacheDir,i,!0),i}function Kr(e,t,n,r=void 0,i=void 0){let o={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,lastAction:n,...i?{lastReason:i}:{},lastSeenAt:(r??(()=>new Date))().toISOString()},s={...o,ownershipChecksum:qo(o)},a=Ti(e.repositoryId),c=KF(a,s);return c||(zc(a,s,!1),s)}function KF(e,t){try{let n=Am(t.localCacheDir);if(!n||n.repositoryId!==t.repositoryId||n.worktreeId!==t.worktreeId)return null;let r=JSON.parse(j(S(e,"worktrees",`${t.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:Q})),i=Date.parse(t.lastSeenAt)-Date.parse(r.lastSeenAt);return JF(r,t)&&Number.isFinite(i)&&i<WF?r:null}catch{return null}}function JF(e,t){return e.version===t.version&&e.repositoryId===t.repositoryId&&e.worktreeId===t.worktreeId&&e.projectRoot===t.projectRoot&&e.treeOid===t.treeOid&&e.localCacheDir===t.localCacheDir&&e.baseGenerationId===t.baseGenerationId&&e.activeGenerationId===t.activeGenerationId&&e.ownershipChecksum===t.ownershipChecksum&&e.lastAction===t.lastAction&&e.lastReason===t.lastReason}function qo(e){return Mm(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:xt(e.projectRoot),localCacheDir:xt(e.localCacheDir)}))}function Dm(e){let t=JSON.parse(e);if(t.version!==$c||t.artifactCatalogVersion!==Ur||typeof t.generationId!="string"||!/^[a-f0-9]{64}$/.test(t.generationId)||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.treeOid!="string"||!t.treeOid||typeof t.producerIdentity!="string"||t.producerIdentity!==$o||typeof t.sourceProjectRoot!="string"||typeof t.scipProjectRoot!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!t.fingerprint||!Array.isArray(t.artifacts))throw new Error("invalid shared generation manifest");let n=new Set;for(let r of t.artifacts){if(!r||typeof r.path!="string"||typeof r.size!="number"||r.size<0||typeof r.sha256!="string"||!/^[a-f0-9]{64}$/.test(r.sha256))throw new Error("invalid shared generation artifact");if(jo(r.path),n.has(r.path))throw new Error(`duplicate shared generation artifact: ${r.path}`);n.add(r.path)}for(let r of["index.db","index.scip","meta.json"])if(!n.has(r))throw new Error(`shared generation is missing ${r}`);return t}function Xr(e,t,n=384){return Ar(e,t,{mode:n})}function XF(e,t){for(let n of fu(t)){if(xt(n.path)===xt(t))continue;let r=Ni(n.path),i=qc(r);if(!(!i||JSON.stringify(i.fingerprint)!==JSON.stringify(e.fingerprint)||JSON.stringify([...i.indexedLanguages??[]].sort())!==JSON.stringify([...e.fingerprint.languages].sort()))&&Jr(r,n.path,e.fingerprint))try{return{manifest:Lm({snapshot:e,sourceCacheDir:r,sourceProjectRoot:n.path}).manifest,sourceProjectRoot:n.path}}catch{continue}}return null}function YF(e,t,n){tr(e,{recursive:!0}),Ze(S(e,km),{version:1,repositoryId:t,worktreeId:n},{spacing:2,trailingNewline:!0})}function Rm(e){try{let t=Mo(e),n=wm("sha256");for(let r of t.files){let i=nt(e,r),o=Vo(i).size;n.update(r).update("\0").update(String(o)).update("\0"),wn(i,{inputKind:"source-generation artifact",maxBytes:pe},s=>n.update(s)),n.update("\0")}return n.digest("hex")}catch{return null}}function qc(e){try{let t=Rt(j(S(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:Q}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function Bc(e){return{pnpmWorkspaces:e.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:e.indexer?.typescript?.projectMode,typescriptProjects:e.indexer?.typescript?.projects,clojureConfigPath:e.indexer?.clojure?.configPath}}function QF(e,t){let n=hr(e.languages,e);return JSON.stringify(n)===JSON.stringify(t)}function Wc(e){return S(e.repositoryCacheDir,"generations",e.generationId)}function Am(e){let t=JSON.parse(j(S(e,km),{inputKind:"worktree cache pointer",maxBytes:Q}));return t.version!==1||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.worktreeId!="string"||!/^[a-f0-9]{24}$/.test(t.worktreeId)?null:{version:t.version,repositoryId:t.repositoryId,worktreeId:t.worktreeId}}function zc(e,t,n){let r=bf(e,{waitMs:5e3});if(!r)throw new Error("repository cache cleanup is busy");try{if(n){let o=t.activeGenerationId??t.baseGenerationId;if(!o||!vt(S(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=S(e,"worktrees");tr(i,{recursive:!0}),Ze(S(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),YF(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{r.release()}}function ZF(e,t){let n=S(t,".rollback"),r=new Map,i=new Map;tr(n,{recursive:!0});for(let a of["index.scip","index.db","meta.json"]){let c=S(e,a),l=vt(c);r.set(a,l),l&&Xr(c,S(n,"stable",a))}for(let a of Vc){let c=S(e,a),l=vt(c);if(l){let u=Oc(c);if(!u.isDirectory()||u.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${a}`)}i.set(a,l)}let o=S(e,Mr),s=vt(o);return s&&Om(o,S(n,"sqlite-generations")),{root:n,stableFiles:r,managedDirectories:i,generationStoreExisted:s}}function eN(e,t,n){for(let r of Vc){let i=S(t,r);if(n.managedDirectories.get(r)){let s=S(n.root,"managed",r);tr(Mc(s),{recursive:!0}),Sn(i,s)}let o=S(e,r);vt(o)&&Sn(o,i)}}function tN(e,t){for(let i of Vc){let o=S(e,i),s=S(t.root,"managed",i);t.managedDirectories.get(i)?vt(s)&&(Gt(o,{recursive:!0,force:!0}),Sn(s,o)):Gt(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let s=S(e,i);if(!o){Gt(s,{force:!0});continue}let a=`${s}.shared-restore-${$F()}`;Xr(S(t.root,"stable",i),a),Gt(s,{force:!0}),Sn(a,s)}let n=S(e,Mr);Gt(n,{recursive:!0,force:!0});let r=S(t.root,"sqlite-generations");t.generationStoreExisted&&vt(r)&&Sn(r,n)}function Om(e,t){tr(t,{recursive:!0});for(let n of Fm(e,{withFileTypes:!0})){let r=S(e,n.name),i=S(t,n.name);if(n.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${r}`);n.isDirectory()?Om(r,i):n.isFile()&&Xr(r,i)}}function nN(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||JSON.stringify(e.fingerprint)!==JSON.stringify(t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function Jr(e,t,n,r=!0,i=!0){try{let o=qc(e);if(!o||JSON.stringify(o.fingerprint)!==JSON.stringify(n)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...n.languages].sort()))return Hr("source validation rejected metadata"),!1;let s=Mo(e),a=kc(S(e,"index.db"),S(e,"meta.json"));if(r?a.state!=="current":a.state==="invalid"||a.state==="drifted")return Hr(`source validation rejected SQLite generation state ${a.state}`),!1;let c=new VF(S(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let l=Uc(t),d=(i?s.files.filter(p=>p.endsWith(".scip")):["index.scip"]).every(p=>{let f=Tm(J(nt(e,p),{inputKind:"shared SCIP validation artifact",maxBytes:pe})).metadata?.projectRoot;return f!==l&&Hr(`source validation rejected SCIP root for ${p}: ${String(f)}`),f===l});return d||Hr("source validation rejected SCIP project roots"),d}catch(o){return Hr(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function Hr(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function Uc(e){try{return Im(Nm(e)).href}catch{return Im(xt(e)).href}}function rN(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===3&&Array.isArray(t.languages)&&typeof t.pnpmWorkspaces=="boolean"&&(t.typescriptProjectMode==="single"||t.typescriptProjectMode==="workspace")&&Array.isArray(t.typescriptProjects)&&Array.isArray(t.files)&&t.files.every(n=>n!==null&&typeof n=="object"&&typeof n.path=="string"&&typeof n.size=="number"&&typeof n.hash=="string")}function Mm(e){return wm("sha256").update(e).digest("hex")}import{spawn as cN}from"child_process";import{platform as Km}from"os";import{performance as Jm}from"perf_hooks";import{execFileSync as $m}from"child_process";import{platform as iN}from"os";var Gm=1e3,Vm=2*1024*1024,oN=25;function qm(e,t,n=Hm){let r=n.readIdentity(e),i=new Map;return r&&i.set(e,r),{rootPid:e,rootIdentity:r,ownsProcessGroup:t,knownMembers:i}}async function Wm(e,t,n=Hm){if(!e.rootIdentity){let c=await Yr(e,t.gracefulMs+t.forceMs,n);return{reaped:c,reason:c?"terminated":"identity-unavailable",detail:c?void 0:`Could not establish the birth identity of process ${e.rootPid}.`}}let r=zm(e,n);if(r==="mismatch")return{reaped:!1,reason:"identity-mismatch",detail:`Process ${e.rootPid} no longer has the identity owned by this runner.`};if(r==="exited"&&!Um(e,n))return{reaped:!0,reason:"terminated"};if(n.platform==="win32"){try{n.terminateWindowsTree(e.rootPid)}catch(l){let u=await Yr(e,t.forceMs,n);return{reaped:u,reason:u?"terminated":"signal-failed",detail:u?void 0:Hc(l)}}let c=await Yr(e,t.forceMs,n);return{reaped:c,reason:c?"terminated":"deadline"}}let i=jm(e,"SIGTERM",n);if(await Yr(e,t.gracefulMs,n))return{reaped:!0,reason:"terminated"};let s=jm(e,"SIGKILL",n);return await Yr(e,t.forceMs,n)?{reaped:!0,reason:"terminated"}:s?{reaped:!1,reason:s.reason,detail:s.detail}:i?{reaped:!1,reason:i.reason,detail:i.detail}:{reaped:!1,reason:"deadline",detail:`Process tree ${e.rootPid} did not exit before its termination deadline.`}}function zm(e,t){let n=t.readIdentity(e.rootPid);if(!n)return"exited";if(!e.rootIdentity||!je(e.rootIdentity,n))return"mismatch";e.knownMembers.set(e.rootPid,n);for(let r of t.listDescendantPids(e.rootPid)){let i=t.readIdentity(r);i&&e.knownMembers.set(r,i)}return"owned"}function jm(e,t,n){let r=zm(e,n);if(r==="mismatch")return{reason:"identity-mismatch",detail:`Process ${e.rootPid} changed identity before ${t}.`};if(r==="owned"&&e.ownsProcessGroup)try{return n.signal(-e.rootPid,t),null}catch(o){if(!Bm(o))return{reason:"signal-failed",detail:Hc(o)}}let i=null;for(let o of e.knownMembers.values()){let s=n.readIdentity(o.pid);if(!(!s||!je(o,s)))try{n.signal(o.pid,t)}catch(a){!Bm(a)&&i===null&&(i=Hc(a))}}return i===null?null:{reason:"signal-failed",detail:i}}async function Yr(e,t,n){let r=n.now()+t;for(;Um(e,n);){if(n.now()>=r)return!1;await n.sleep(Math.min(oN,Math.max(1,r-n.now())))}return!0}function Um(e,t){if(!e.rootIdentity&&t.isProcessAlive(e.rootPid))return!0;for(let n of e.knownMembers.values()){let r=t.readIdentity(n.pid);if(r&&je(n,r))return!0}return!!(e.ownsProcessGroup&&t.isProcessGroupAlive(e.rootPid))}function sN(e){let t=aN(!1),n=new Map;for(let s of t.split(/\r?\n/)){let a=/^\s*(\d+)\s+(\d+)\s*$/.exec(s);if(!a)continue;let c=Number(a[1]),l=Number(a[2]),u=n.get(l)??[];u.push(c),n.set(l,u)}let r=[],i=[...n.get(e)??[]],o=new Set;for(;i.length>0;){let s=i.pop();o.has(s)||(o.add(s),r.push(s),i.push(...n.get(s)??[]))}return r}function aN(e){return $m("ps",["-axo",e?"pid=,ppid=,rss=":"pid=,ppid="],{encoding:"utf8",timeout:Gm,maxBuffer:Vm,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"]})}function Bm(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ESRCH"}function Hc(e){return e instanceof Error?e.message:String(e)}var Hm={platform:iN(),now:Date.now,readIdentity:ht,isProcessAlive(e){try{return process.kill(e,0),!0}catch(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EPERM"}},isProcessGroupAlive(e){if(this.platform==="win32")return!1;try{return process.kill(-e,0),!0}catch(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EPERM"}},listDescendantPids(e){if(this.platform==="win32")return[];try{return sN(e)}catch{return[]}},signal(e,t){process.kill(e,t)},terminateWindowsTree(e){$m("taskkill.exe",["/PID",String(e),"/T","/F"],{timeout:Gm,maxBuffer:Vm,stdio:"ignore",windowsHide:!0})},async sleep(e){await new Promise(t=>setTimeout(t,e))}};var H1={probe:1e4,git:3e4,analysis:18e4,install:3e5,indexer:6e5},Zr=class extends Error{constructor(n,r,i,o={}){super(i,o.cause===void 0?void 0:{cause:o.cause});this.kind=n;this.label=r;this.name="BoundedProcessError",this.timedOut=o.timedOut??!1,this.reaped=o.reaped??!1,this.stdout=o.stdout??"",this.stderr=o.stderr??"",this.stdoutTruncated=o.stdoutTruncated??!1,this.stderrTruncated=o.stderrTruncated??!1}kind;label;timedOut;reaped;stdout;stderr;stdoutTruncated;stderrTruncated};function Qr(e,t){if(!Number.isFinite(e)||e<=0)throw new TypeError(`${t} must be a positive finite number.`)}function Xm(e,t,n,r){let i=Math.max(0,r-n);i>0&&e.push(t.subarray(0,i))}function Ym(e,t,n){let r=Buffer.concat([...e,t]);e.length=0,e.push(r.subarray(Math.max(0,r.length-n)))}function K1(e){Qr(e.timeoutMs,"timeoutMs"),Qr(e.maxStdoutBytes,"maxStdoutBytes"),Qr(e.maxStderrBytes,"maxStderrBytes");let t=e.terminationGraceMs??1e3;Qr(t,"terminationGraceMs");let n=e.terminationForceMs??t;return Qr(n,"terminationForceMs"),new Promise((r,i)=>{let o=Jm.now(),s=Km()!=="win32"&&process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1",a=Km()!=="win32"&&!s,c;try{c=cN(e.command,[...e.args??[]],{cwd:e.cwd,env:e.env,detached:a?!0:e.detached,stdio:["pipe","pipe","pipe"]})}catch(v){i(new Zr("spawn",e.label,`${e.label} could not start.`,{cause:v,reaped:!0}));return}let l=[],u=[],d=0,p=0,f=!1,m=!1,g=null,y=!1,I=c.pid===void 0?null:qm(c.pid,a),h=()=>{clearTimeout(T),e.signal?.removeEventListener("abort",b)},P=v=>{if(y||!g)return;y=!0,h();let E=Buffer.concat(l).toString("utf8"),O=Buffer.concat(u).toString("utf8"),B=v.reaped||!v.detail?"":` Process-tree cleanup failed: ${v.detail}`;i(new Zr(g.kind,e.label,`${g.message}${B}`,{timedOut:g.timedOut,reaped:v.reaped,stdout:E,stderr:O,stdoutTruncated:f,stderrTruncated:m}))},w=v=>{if(!(g||y)){if(g=v,!I){P({reaped:c.pid===void 0,reason:c.pid===void 0?"terminated":"identity-unavailable"});return}Wm(I,{gracefulMs:t,forceMs:n}).then(P,E=>{P({reaped:!1,reason:"signal-failed",detail:E instanceof Error?E.message:String(E)})})}},T=setTimeout(()=>{w({kind:"timeout",timedOut:!0,message:`${e.label} timed out after ${e.timeoutMs}ms.`})},e.timeoutMs);T.unref();let b=()=>{w({kind:"aborted",timedOut:!1,message:`${e.label} was cancelled.`})};e.signal?.addEventListener("abort",b,{once:!0}),e.signal?.aborted&&b(),c.stdout.on("data",v=>{let E=Buffer.isBuffer(v)?v:Buffer.from(v);e.outputLimitBehavior==="truncate-tail"?Ym(l,E,e.maxStdoutBytes):Xm(l,E,d,e.maxStdoutBytes),d+=E.length,d>e.maxStdoutBytes&&(f=!0,e.outputLimitBehavior!=="truncate-tail"&&w({kind:"stdout-limit",timedOut:!1,message:`${e.label} exceeded stdout limit (${e.maxStdoutBytes} bytes).`}))}),c.stderr.on("data",v=>{let E=Buffer.isBuffer(v)?v:Buffer.from(v);e.outputLimitBehavior==="truncate-tail"?Ym(u,E,e.maxStderrBytes):Xm(u,E,p,e.maxStderrBytes),p+=E.length,p>e.maxStderrBytes&&(m=!0,e.outputLimitBehavior!=="truncate-tail"&&w({kind:"stderr-limit",timedOut:!1,message:`${e.label} exceeded stderr limit (${e.maxStderrBytes} bytes).`}))}),c.on("error",v=>{if(!y&&!g){if(c.pid===void 0){h(),y=!0,i(new Zr("spawn",e.label,`${e.label} could not start: ${v.message}`,{cause:v,reaped:!0}));return}w({kind:"spawn",timedOut:!1,message:`${e.label} failed after start: ${v.message}`})}}),c.on("close",(v,E)=>{if(y||g)return;y=!0,h();let O=Buffer.concat(l).toString("utf8"),B=Buffer.concat(u).toString("utf8");r({status:v,signal:E,stdout:O,stderr:B,timedOut:!1,durationMs:Jm.now()-o,stdoutTruncated:f,stderrTruncated:m})}),e.input===void 0?c.stdin.end():c.stdin.end(e.input)})}function Y1(e){switch(e){case"entry":case"source":case"worker":return 0;case"barrel":return 1;case"test":return 2}}function Qm(e){let t=Y(e);return lN(t)?"test":uN(t)?"worker":dN(t)?"entry":pN(t)?"barrel":"source"}function lN(e){return!!(/\.(?:test|spec)\.[a-z0-9]+$/i.test(e)||/(?:^|\/)(?:_)?test_[^/]+$/i.test(e)||/(?:^|\/)spec_[^/]+$/i.test(e)||/(?:^|\/)[^/]+_test\.[a-z0-9]+$/i.test(e)||/(?:^|\/)[^/]+_tests\.rs$/i.test(e)||/(?:^|\/)tests\.rs$/i.test(e)||/(?:^|\/)[^/]+_spec\.[a-z0-9]+$/i.test(e)||/(?:^|\/)__tests__\//i.test(e)||/(?:^|\/)test\//i.test(e)||/(?:^|\/)tests\//i.test(e)||/(?:^|\/)__fixtures__\//i.test(e)||/(?:^|\/)__mocks__\//i.test(e)||/(?:^|\/)test-support\//i.test(e)||/(?:^|\/)test-utils\//i.test(e)||/(?:^|\/)testing\//i.test(e))}function uN(e){return/(?:^|\/)[^/]*worker\.(?:ts|tsx|js|mjs|cjs|rs|py|go)$/.test(e)}function dN(e){let t=e.split("/"),n=t[t.length-1]??e;return n==="cli.ts"||n==="cli.js"||n==="postinstall.ts"||n==="postinstall.js"||n==="main.ts"||n==="main.js"||n==="main.rs"||n==="main.go"||n==="main.py"||n==="build.rs"||n==="lib.rs"||/\bsrc\/bin\/[^/]+\.rs$/.test(e)||/(?:^|\/)examples\/[^/]+\.rs$/.test(e)||/(?:^|\/)tests\/[^/]+\.rs$/.test(e)||/(?:^|\/)benches\/[^/]+\.rs$/.test(e)?!0:n==="index.ts"||n==="index.js"?/(?:^|\/)(?:apps|services)\/[^/]+\/src\/index\.(?:ts|js)$/.test(e)?!0:t.length<=2:!1}function pN(e){return e==="index.ts"||e==="index.js"||e.endsWith("/index.ts")||e.endsWith("/index.js")||e.endsWith("/mod.rs")||e.endsWith("/__init__.py")}import{createHash as gN,randomUUID as ig}from"crypto";import{existsSync as ir,lstatSync as ti,mkdirSync as rV,readdirSync as rr,renameSync as og,rmSync as Vt}from"fs";import{basename as zo,dirname as yN,join as V}from"path";function Zm(e){return Wo(e,fN)}function Z1(e){return Wo(e,mN)}function Wo(e,t){return Array.isArray(e)?`[${e.map(n=>Wo(n,t)).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).sort(([n],[r])=>t(n,r)).map(([n,r])=>`${JSON.stringify(n)}:${Wo(r,t)}`).join(",")}}`:JSON.stringify(e)}function fN(e,t){return e.localeCompare(t)}function mN(e,t){return e<t?-1:e>t?1:0}var hN=1,SN=Object.freeze({maxItems:1024,maxBytes:512*1024*1024,maxItemBytes:64*1024*1024,maxBatch:16,claimLeaseMs:5*6e4,responseRetentionMs:10*6e4,deadLetterRetentionMs:1440*6e4,temporaryRetentionMs:6e4,cleanupBatch:64}),nr=class extends Error{constructor(n,r,i,o){let s=n==="item-too-large"?`request is ${o} bytes; per-item limit is ${i.maxItemBytes}`:n==="item-capacity"?`mailbox has ${r.totalItems} retained items; limit is ${i.maxItems}`:n==="byte-capacity"?`mailbox retains ${r.totalBytes} bytes and the request adds ${o}; limit is ${i.maxBytes}`:"another writer held the admission coordinator through the bounded wait";super(`Mailbox backpressure: ${s}. Retry after the service drains or expires retained work.`);this.code=n;this.status=r;this.limits=i;this.attemptedBytes=o;this.name="MailboxBackpressureError"}code;status;limits;attemptedBytes},bN=".owner.json",xN={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function uV(e){return{rootDir:e,pendingDir:V(e,"pending"),inflightDir:V(e,"inflight"),responseDir:V(e,"responses"),deadLetterDir:V(e,"dead-letter"),legacyRequestDir:V(e,"requests")}}function vN(e={}){let t={...SN,...e};for(let[n,r]of Object.entries(t))if(!Number.isFinite(r)||r<=0||!Number.isInteger(r))throw new Error(`Mailbox limit ${n} must be a positive integer.`);return t}function sg(e){let t=[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir].map(n=>ge(n));return X(...t)}function dV(e,t){return gN("sha256").update(Zm({namespace:e,payload:t})).digest("hex")}function ag(e){if(!/^[a-f0-9]{64}$/.test(e))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${e}`}function pV(e,t,n={}){let r=vN(n.limits),i=n.nowMs??Date.now(),o=sg(e);return NN(t),EN(e,r,n.admissionLockTimeoutMs??2e3,n.monotonicNow??yn,n.durability??"durable",()=>{IN(e,i,r);let s=V(e.pendingDir,`${t.id}.json`),a=V(e.responseDir,`${t.id}.json`),c=eg(e,t.id);if(c){let p=tg(c,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:p.deadlineAtMs??t.deadlineAtMs}}let l=`${JSON.stringify(t)}
389
- `,u=Buffer.byteLength(l),d=cg(e);if(u>r.maxItemBytes)throw new nr("item-too-large",d,r,u);if(d.totalItems+1>r.maxItems)throw new nr("item-capacity",d,r,u);if(d.totalBytes+u>r.maxBytes)throw new nr("byte-capacity",d,r,u);n.onBeforePublish?.();try{let p=n.durability??"durable",f=Xa(s,l,{durability:p}),m=p==="durable"?X(o,f.directorySync):"not-requested";return{disposition:"accepted",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:t.deadlineAtMs,achievedDurability:f.achievedDurability,directorySync:m}}catch(p){if(p.code!=="EEXIST")throw p;let f=eg(e,t.id);if(!f)throw p;let m=tg(f,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:m.deadlineAtMs??t.deadlineAtMs}}})}function IN(e,t,n,r=xN){let i={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=n.cleanupBatch;for(let s of Jc(e.inflightDir)){if(o<=0)break;let a=V(e.responseDir,`${s.requestId}.json`);if(ir(a)){Vt(s.path,{force:!0}),i.completedClaimsRemoved++,o--;continue}if(s.claimExpiresAtMs>t||CN(e,s.ownerId,r)!=="dead")continue;let c=V(e.pendingDir,s.originalFile);try{og(s.path,c),i.reclaimed++}catch(l){if(l.code!=="EEXIST")throw l;Vt(s.path,{force:!0})}L(yN(s.path)),L(e.pendingDir),o--}o=ng(e.responseDir,o,(s,a)=>a+n.responseRetentionMs,t,()=>{i.responsesRemoved++}),o=ng(e.deadLetterDir,o,(s,a)=>a+n.deadLetterRetentionMs,t,()=>{i.deadLettersRemoved++});for(let s of[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir]){if(o<=0)break;for(let a of lg(s)){if(o<=0)break;if(!zo(a).includes(".tmp-"))continue;let c;try{c=ti(a).mtimeMs}catch(l){if(l.code==="ENOENT")continue;throw l}c+n.temporaryRetentionMs>t||(Vt(a,{force:!0}),i.temporaryFilesRemoved++,o--)}}return TN(e.inflightDir),i}function cg(e){sg(e);let t=[...ei(e.pendingDir).map(c=>({path:c,pending:!0})),...ei(e.legacyRequestDir).map(c=>({path:c,pending:!0}))],n=Jc(e.inflightDir).map(c=>({path:c.path,pending:!1})),r=ei(e.responseDir).map(c=>({path:c,pending:!1})),i=ei(e.deadLetterDir).map(c=>({path:c,pending:!1})),o=[...t,...n,...r,...i],s=0,a;for(let c of t){let l=Xc(c.path);if(!l){s++;continue}let u=l.enqueuedAtMs;if(u===void 0)try{u=ti(c.path).mtimeMs}catch(d){if(d.code==="ENOENT")continue;throw d}a=a===void 0?u:Math.min(a,u)}return{pending:t.length,inflight:n.length,responses:r.length,deadLetters:i.length,invalid:s,totalItems:o.length,totalBytes:o.reduce((c,l)=>c+kN(l.path),0),...a===void 0?{}:{oldestPendingAt:new Date(a).toISOString()}}}function EN(e,t,n,r,i,o){let s=V(e.rootDir,".admission.lock"),a=`${process.pid}-${ig()}`,c=r()+Math.max(0,n);for(;!PN(e.rootDir,s,a,i);){if(RN(s),r()>=c)throw new nr("admission-busy",cg(e),t,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return o()}finally{try{Kc(s).ownerToken===a&&(Vt(s,{recursive:!0,force:!0}),i==="durable"&&L(e.rootDir))}catch{}}}function PN(e,t,n,r){let i=`${JSON.stringify({ownerToken:n,pid:process.pid,acquiredAtMs:Date.now()})}
390
- `;try{return Xa(t,i,{durability:r}),!0}catch(o){if(o.code==="EEXIST")return!1;try{Kc(t).ownerToken===n&&(Vt(t,{force:!0}),r==="durable"&&L(e))}catch{}throw o}}function RN(e){let t=null;try{let r=Kc(e);typeof r.ownerToken=="string"&&Number.isSafeInteger(r.pid)&&Number(r.pid)>0&&(t=Number(r.pid))}catch{}if(t===null||wN(t))return;let n=`${e}.stale-${ig()}`;try{og(e,n)}catch(r){let i=r.code;if(i==="ENOENT"||i==="EEXIST")return;throw r}Vt(n,{recursive:!0,force:!0})}function Kc(e){try{return JSON.parse(F(e,"mailbox lock record"))}catch(t){if(t.code!=="EISDIR"&&!(t instanceof Je&&t.reason==="not-regular"))throw t;return JSON.parse(F(V(e,"owner.json"),"mailbox lock owner record"))}}function wN(e){try{return process.kill(e,0),!0}catch(t){let n=t.code;return n==="EPERM"||n!=="ESRCH"}}function CN(e,t,n){let r=FN(V(e.inflightDir,ug(t),bN));if(!r)return"unknown";if(!n.isProcessAlive(r.pid))return"dead";if(!r.processIdentity)return"live";let i=n.readProcessIdentity(r.pid);return i?je(r.processIdentity,i)?"live":"dead":"unknown"}function FN(e){try{let t=JSON.parse(F(e,"mailbox owner record"));if(t.version!==1||typeof t.ownerId!="string"||!t.ownerId||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0)return null;let n=t.processIdentity===void 0?null:yt(t.processIdentity);return t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{version:1,ownerId:t.ownerId,pid:t.pid,...n?{processIdentity:n}:{}}}catch{return null}}function eg(e,t){for(let n of[V(e.pendingDir,`${t}.json`),V(e.legacyRequestDir,`${t}.json`),V(e.responseDir,`${t}.json`)])if(ir(n))return n;for(let n of Jc(e.inflightDir))if(n.requestId===t)return n.path;return null}function tg(e,t,n){let r=Xc(e);if(r?.operationKey===t)return r;if(zo(e)===`${ag(t)}.json`)return{id:n,operationKey:t};throw new Error(`Mailbox operation ${n} conflicts with an existing retained record.`)}function NN(e){if(e.mailboxVersion!==hN||e.id!==ag(e.operationKey)||!e.clientId.trim()||!Number.isFinite(e.enqueuedAtMs)||!Number.isFinite(e.deadlineAtMs)||e.deadlineAtMs<e.enqueuedAtMs)throw new Error("Mailbox request has an invalid lifecycle identity.")}function Jc(e){if(!ir(e))return[];let t=[];for(let n of rr(e,{withFileTypes:!0})){if(!n.isDirectory())continue;let r=rg(n.name);if(r===null)continue;let i=V(e,n.name);for(let o of rr(i,{withFileTypes:!0})){if(!o.isFile()||!o.name.endsWith(".claim"))continue;let s=/^(.*)\.(\d+)\.claim$/.exec(o.name);if(!s)continue;let a=rg(s[1]),c=Number(s[2]);if(a===null||zo(a)!==a||!a.endsWith(".json")||!Number.isSafeInteger(c))continue;let l=V(i,o.name),u=Xc(l)??{id:zo(a,".json")},d;try{d=ti(l)}catch(p){if(p.code==="ENOENT")continue;throw p}t.push({requestId:u.id,ownerId:r,path:l,originalFile:a,claimedAtMs:d.mtimeMs,claimExpiresAtMs:c,byteLength:d.size,...u.operationKey?{operationKey:u.operationKey}:{},...u.clientId?{clientId:u.clientId}:{},...u.enqueuedAtMs===void 0?{}:{enqueuedAtMs:u.enqueuedAtMs},...u.deadlineAtMs===void 0?{}:{deadlineAtMs:u.deadlineAtMs},legacy:u.operationKey===void 0})}}return t.sort((n,r)=>n.claimedAtMs-r.claimedAtMs||n.path.localeCompare(r.path))}function Xc(e){try{let t=JSON.parse(F(e,"mailbox record"));return typeof t.id!="string"||!t.id?null:{id:t.id,...typeof t.operationKey=="string"?{operationKey:t.operationKey}:{},...typeof t.clientId=="string"?{clientId:t.clientId}:{},...typeof t.enqueuedAtMs=="number"?{enqueuedAtMs:t.enqueuedAtMs}:{},...typeof t.deadlineAtMs=="number"?{deadlineAtMs:t.deadlineAtMs}:{}}}catch{return null}}function ng(e,t,n,r,i){for(let o of ei(e)){if(t<=0)break;let s;try{s=ti(o)}catch(a){if(a.code==="ENOENT")continue;throw a}n(o,s.mtimeMs)>r||(Vt(o,{force:!0}),i(),t--)}return t}function ei(e){return ir(e)?rr(e,{withFileTypes:!0}).filter(t=>t.isFile()).map(t=>V(e,t.name)).sort():[]}function lg(e){if(!ir(e))return[];let t=[];for(let n of rr(e,{withFileTypes:!0})){let r=V(e,n.name);n.isFile()?t.push(r):n.isDirectory()&&t.push(...lg(r))}return t.sort()}function TN(e){if(ir(e))for(let t of rr(e,{withFileTypes:!0})){if(!t.isDirectory())continue;let n=V(e,t.name);rr(n).some(r=>r.endsWith(".claim"))||Vt(n,{recursive:!0,force:!0})}}function kN(e){try{return ti(e).size}catch{return 0}}function ug(e){return Buffer.from(e,"utf8").toString("base64url")}function rg(e){try{let t=Buffer.from(e,"base64url").toString("utf8");return ug(t)===e?t:null}catch{return null}}var _N=4;function bn(e,t,n,r={}){return dg(e,t,n,r.maxReexportDepth??_N,0,new Set)}function dg(e,t,n,r,i,o){let s=`${t}\0${n}`;if(o.has(s)||i>r)return[];o.add(s);let a=A(e,t).filter(c=>c.leaf===n);return a.length>0?a:Ot(e,t).flatMap(c=>c.sourcePath?c.kind==="named"&&!c.names.includes(n)?[]:dg(e,c.sourcePath,n,r,i+1,new Set(o)):[])}import{createHash as Ug}from"crypto";import{createHash as JN}from"crypto";var Uo=8;function or(e,t,n){return tl(pg(e,t,Zc(n),0,new Set))}function el(e,t,n){return Yc(e,t,n,0,new Set)}function pg(e,t,n,r,i){if(r>Uo)return[];let o=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(n);return o?fg(e,t,o[1],o[2],r,i):/^[A-Za-z_$][\w$]*$/u.test(n)?mg(e,t,n,r,i):[]}function fg(e,t,n,r,i,o){let s=[];for(let a of Yc(e,t,n,i+1,new Set(o))){let c=Le(a.initializer);for(let l of c.namedChildren){if(l.type==="pair"){let u=l.childForFieldName("key")??l.namedChild(0);if(MN(u)!==r)continue;let d=l.childForFieldName("value")??l.namedChild(1);d&&s.push(...pg(e,a.definition.relativePath,Zc(d.text),i+1,new Set(o)));continue}if(/(?:method|function)/u.test(l.type)){if((l.childForFieldName("name")??l.namedChild(0))?.text!==r)continue;let d=AN(e,a.definition.relativePath,r,l);s.push(...d.length>0?d:[LN(a.definition,r,l)]);continue}if(l.type==="spread_element"){let u=l.namedChild(0);if(!u)continue;for(let d of Yc(e,a.definition.relativePath,Zc(u.text),i+1,new Set(o)))s.push(...fg(e,d.definition.relativePath,d.definition.leaf,r,i+1,new Set(o)))}}}return tl(s)}function LN(e,t,n){return{documentId:e.documentId,symbolId:-1,symbol:`source-callable:${e.relativePath}:${n.startPosition.row}:${t}`,relativePath:e.relativePath,startLine:n.startPosition.row,startChar:n.startPosition.column,endLine:n.endPosition.row,endChar:n.endPosition.column,leaf:t,parentTypeName:e.leaf,isFunctionLike:!0,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:e.symbol}}function Yc(e,t,n,r,i){return r>Uo||!/^[A-Za-z_$][\w$]*$/u.test(n)?[]:mg(e,t,n,r,i).flatMap(o=>{let s=D(e,o.relativePath)?.rootNode,a=s?ON(s,o.leaf):null;return a?[{definition:o,initializer:a}]:[]})}function mg(e,t,n,r,i){if(r>Uo)return[];let o=`${t}\0${n}`;if(i.has(o))return[];i.add(o);let s=A(e,t).filter(l=>l.leaf===n);if(s.length>0)return s;let a=DN(e,t,n);if(a.length>0)return a;let c=U(e,t).find(l=>l.localName===n&&l.sourcePath);if(c?.sourcePath){let l=c.kind==="namespace"||c.importedName==="default"?n:c.importedName;return Qc(e,c.sourcePath,l,r+1,new Set(i))}return Qc(e,t,n,r+1,new Set(i))}function DN(e,t,n){let r=e.get("SELECT id FROM documents WHERE relative_path = ?",t)?.id;return r===void 0?[]:(le(e,t)?.callables??[]).filter(i=>i.name===n).map(i=>({documentId:r,symbolId:-1,symbol:`source-callable:${t}:${i.startLine}:${n}`,relativePath:t,startLine:i.startLine,startChar:0,endLine:i.endLine,endChar:0,leaf:n,parentTypeName:null,isFunctionLike:!0,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:null}))}function Qc(e,t,n,r,i){if(r>Uo)return[];let o=A(e,t).filter(s=>s.leaf===n);return o.length>0?o:tl(Ot(e,t).flatMap(s=>s.sourcePath?s.kind==="named"&&!s.names.includes(n)?[]:Qc(e,s.sourcePath,n,r+1,new Set(i)):[]))}function AN(e,t,n,r){return A(e,t).filter(i=>i.leaf===n&&i.startLine<=r.startPosition.row&&i.endLine>=r.endPosition.row)}function ON(e,t){let n=null;return re(e,r=>{n||r.type!=="variable_declarator"||(r.childForFieldName("name")??r.namedChild(0))?.text.trim()!==t||(n=r.childForFieldName("value")??r.namedChild(1))}),n}function MN(e){return e?.text.replace(/^['"`]|['"`]$/gu,"")??null}function Zc(e){return e.replace(/\s+/gu,"").replace(/^\.\.\./u,"")}function tl(e){return[...new Map(e.map(t=>[t.symbol,t])).values()]}function Ho(e){let t=e.replaceAll("\\","/");return Qm(t)==="test"?/(?:^|\/)__fixtures__\//iu.test(t)?"fixture":"test":/(?:^|\/)(?:fixtures?|testdata)\//iu.test(t)?"fixture":/(?:^|\/)(?:examples?|demos?|previews?)\//iu.test(t)?"example":/(?:^|\/)(?:generated|dist|build|coverage)\//iu.test(t)||/\.generated\./iu.test(t)?"generated":/^(?:scripts?|tools?)\//iu.test(t)?"script":"production"}var jN=8;function Ue(e,t){return t?sr(e,t,0,new Set):null}function sr(e,t,n,r){if(n>jN)return rt(t,"value-evaluation-depth");let i=Le(t),o=WN(i);if(o)return zN(e.file,i,o.term,o.value,o.precision);if(i.type==="binary_expression"&&/\+/u.test(i.text)){let c=i.namedChildren.map(l=>sr(e,l,n+1,new Set(r)));if(c.length>=2&&c.every(l=>l!==null)){let l={kind:"concat",parts:c.map(d=>d.term)},u=c.map(d=>d.value).join("");return UN(e.file,i,l,u,c.some(d=>d.precision!=="literal")?"constrained-pattern":"literal",c)}}let s=i.text.trim();if(/^[A-Za-z_$][\w$]*$/u.test(s))return VN(e,s,i,n,r);let a=HN(i);return a?qN(e,a.base,a.properties,i,n,r):i.type==="call_expression"||i.type==="call"?BN(e,i,n,r):rt(i,`unsupported-expression:${i.type}`)}function BN(e,t,n,r){let o=(t.childForFieldName("function")??t.namedChild(0))?.text.replace(/\s+/gu,"").replace(/<.*>$/u,"")??"",s=$N(e,o);if(s.length!==1)return rt(t,s.length===0?"call-target-unresolved":"call-target-ambiguous");let a=s[0],c=`${a.relativePath}\0${a.symbol}`;if(r.has(c))return rt(t,"call-return-cycle");let l=D(e.db,a.relativePath)?.rootNode;if(!l)return rt(t,"call-target-unparsed");let u=_e(l,a.startLine,a.endLine);if(!u)return rt(t,"call-target-syntax-unavailable");let d=GN(u);if(!d)return rt(t,"call-return-not-single-expression");let p=new Set(r);p.add(c);let f=sr({db:e.db,file:a.relativePath,root:l},d,n+1,p);return f?Ko(t,"bounded-call-return",f,a.symbol):rt(t,"call-return-unresolved")}function $N(e,t){if(/^[A-Za-z_$][\w$]*$/u.test(t)){let i=A(e.db,e.file).filter(s=>s.isFunctionLike&&s.leaf===t);if(i.length>0)return i;let o=U(e.db,e.file).find(s=>s.localName===t&&s.sourcePath&&s.kind!=="namespace");return o?.sourcePath?bn(e.db,o.sourcePath,o.importedName==="default"?t:o.importedName).filter(s=>s.isFunctionLike):[]}let n=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(t);if(!n)return[];let r=U(e.db,e.file).find(i=>i.kind==="namespace"&&i.localName===n[1]&&i.sourcePath);return r?.sourcePath?bn(e.db,r.sourcePath,n[2]).filter(i=>i.isFunctionLike):[]}function GN(e){let t=e.childForFieldName("body");if(e.type==="arrow_function"&&t&&t.type!=="statement_block")return t;let n=[];return gg(t??e,t??e,n),n.length!==1?null:n[0].childForFieldName("argument")??n[0].namedChild(0)}function gg(e,t,n){if(!(t!==e&&(/(?:function|method|lambda)/u.test(t.type)||t.type==="arrow_function"))){if(t.type==="return_statement"){n.push(t);return}for(let r of t.namedChildren)gg(e,r,n)}}function VN(e,t,n,r,i){let o=`${e.file}\0${t}`;if(i.has(o))return rt(n,"value-cycle");i.add(o);let s=nl(e.root,t);if(s){let m=sr(e,s,r+1,i);return m?Ko(n,"local-constant",m):rt(n,"non-foldable-local")}let a=U(e.db,e.file).find(m=>m.localName===t&&m.sourcePath);if(!a?.sourcePath)return ze(n,t,"unresolved-identifier");if(a.kind==="namespace")return ze(n,t,"namespace-import-requires-property");let c=a.importedName==="default"?t:a.importedName,l=bn(e.db,a.sourcePath,c);if(l.length!==1)return ze(n,t,l.length===0?"import-definition-missing":"import-definition-ambiguous");let u=l[0],d=D(e.db,u.relativePath)?.rootNode;if(!d)return ze(n,u.symbol,"import-definition-unparsed");let p=nl(d,u.leaf);if(!p)return ze(n,u.symbol,"import-definition-non-value");let f=sr({db:e.db,file:u.relativePath,root:d},p,r+1,i);return f?Ko(n,"imported-constant",f,u.symbol):ze(n,u.symbol,"import-value-unresolved")}function qN(e,t,n,r,i,o){let s=U(e.db,e.file).find(f=>f.localName===t&&f.sourcePath),a=e.file,c=t,l;if(s?.sourcePath){s.kind==="namespace"?(c=n[0]??"",n=n.slice(1)):c=s.importedName==="default"?t:s.importedName;let f=bn(e.db,s.sourcePath,c);if(f.length!==1)return ze(r,`${t}.${n.join(".")}`,f.length===0?"member-definition-missing":"member-definition-ambiguous");a=f[0].relativePath,c=f[0].leaf,l=f[0].symbol}let u=a===e.file?e.root:D(e.db,a)?.rootNode;if(!u)return ze(r,l??t,"member-definition-unparsed");let d=nl(u,c);if(!d)return ze(r,l??t,"member-base-non-value");for(let f of n){let m=Le(d);if(d=KN(m,f),!d)return ze(r,l??`${t}.${n.join(".")}`,`member-property-missing:${f}`)}let p=sr({db:e.db,file:a,root:u},d,i+1,o);return p?Ko(r,"member-constant",p,l):ze(r,l??t,"member-value-unresolved")}function WN(e){let t=e.text.trim(),n=t[0];if(n!=="'"&&n!=='"'&&n!=="`"||t.at(-1)!==n)return null;let r=t.slice(1,-1);if(n!=="`"||!r.includes("${"))return{term:{kind:"literal",value:r},value:r,precision:"literal"};let i=[],o=0,s=/\$\{([^}]*)\}/gu;for(let a of r.matchAll(s)){let c=a.index??0;c>o&&i.push({kind:"literal",value:r.slice(o,c)}),i.push({kind:"unknown",reason:`template-hole:${a[1]?.trim()||"expression"}`}),o=c+a[0].length}return o<r.length&&i.push({kind:"literal",value:r.slice(o)}),{term:{kind:"pattern",language:"template",value:r.replace(s,"{}")},value:r.replace(s,"{}"),precision:"constrained-pattern"}}function zN(e,t,n,r,i){return{value:r,evidence:"literal",term:n,precision:i,derivation:Jo("direct-literal","direct",e,t)}}function UN(e,t,n,r,i,o){return{value:r,evidence:"constant",term:n,precision:i,derivation:{...Jo("constant-concatenation","mechanically-derived",e,t),inputFactIds:o.flatMap(s=>s.derivation.inputFactIds),sourceSpans:o.flatMap(s=>s.derivation.sourceSpans)}}}function Ko(e,t,n,r){return n.evidence==="expression"?{...n,derivation:{kind:"heuristic",rule:t,ruleVersion:"1",inputFactIds:[...n.derivation.inputFactIds,...r?[r]:[]],sourceSpans:n.derivation.sourceSpans}}:{...n,evidence:"constant",derivation:{kind:"mechanically-derived",rule:t,ruleVersion:"1",inputFactIds:[...n.derivation.inputFactIds,...r?[r]:[]],sourceSpans:n.derivation.sourceSpans}}}function ze(e,t,n){return{value:e.text.trim(),evidence:"expression",term:{kind:"symbol",symbol:t},precision:"symbolic",derivation:Jo(n,"heuristic","",e)}}function rt(e,t){return{value:e.text.trim(),evidence:"expression",term:{kind:"unknown",reason:t},precision:"unknown",derivation:Jo(t,"heuristic","",e)}}function Jo(e,t,n,r){return{kind:t,rule:e,ruleVersion:"1",inputFactIds:[],sourceSpans:n?[{file:n,startLine:r.startPosition.row,endLine:r.endPosition.row}]:[]}}function HN(e){let t=e.text.replace(/\s+/gu,"");if(!/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)+$/u.test(t))return null;let[n,...r]=t.split(".");return n?{base:n,properties:r}:null}function nl(e,t){let n=null;return re(e,r=>{if(n||r.type!=="variable_declarator"||(r.childForFieldName("name")??r.namedChild(0))?.text.trim()!==t)return;let o=r.parent;!o||o.type!=="lexical_declaration"||!/^\s*(?:export\s+)?const\b/u.test(o.text)||(n=r.childForFieldName("value")??r.namedChild(1))}),n}function KN(e,t){for(let n of e.namedChildren)if(!(n.type!=="pair"||(n.childForFieldName("key")??n.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"")!==t))return n.childForFieldName("value")??n.namedChild(1);return null}var Eg=new Set(["delete","get","head","options","patch","post","put"]),XN=/(?:^|\.)(?:app|router|server)$/u,YN=new Set(["findFirst","findMany","findUnique","from","get","select"]),QN=new Set(["create","delete","insert","remove","update","upsert"]),ZN=new Set(["execute","query","raw"]),yg=/(?:\b(?:name|id)|['"`](?:name|id)['"`])\s*:/u,hg=/(?:^\s*|[,{]\s*)(?:async\s+)?['"`]?(?:execute|handler|invoke|run)['"`]?\s*(?::|\([^)]*\)\s*\{)/mu,Sg=/\b[A-Za-z_$][\w$-]*[_-][\w$-]*\s*\(/u,bg=/\b(?:use|call|invoke|run|via|with|read|stop)(?:\s+the)?(?:\s+(?:tool|capability|command))?\s+[A-Za-z_$][\w$-]*\s*\(/iu,ol=[rT(),nT(),eT(),iT(),sT(),aT(),lT()],il=new Set(["exec","execFile","execFileSync","execSync","fork","spawn","spawnSync"]);function eT(){return{id:"builtin.node-child-process",supports:e=>/(?:from\s*|require\s*\(\s*)['"](?:node:)?child_process['"]/u.test(e)&&/\b(?:exec|execFile|execFileSync|execSync|fork|spawn|spawnSync)\s*\(/u.test(e),extract:e=>{let t=tT(e.source),n=[];return qt(e.root,"call_expression",r=>{let i=oi(r);if(!i)return;let o=t.direct.get(i),s=/^(.*?)\.([A-Za-z_$][\w$]*)$/u.exec(i),a=s&&t.namespaces.has(s[1])?s[2]:null,c=o??a;if(!c||!il.has(c))return;let l=xn(r),u=Be(l[0],e)??{value:l[0]?.text.trim()||"<missing>",evidence:"expression"},d=["exec","execFile","execFileSync","execSync"].includes(c)?"process.exec":"process.spawn";n.push(oe(e,r,"builtin.node-child-process",d,[{name:"operation",value:c,evidence:"literal"},{name:"executable",...u}],"exact","node-child-process-import"))}),n}}}function tT(e){let t=new Map,n=new Set,r=String.raw`['"](?:node:)?child_process['"]`,i=new RegExp(String.raw`\bimport\s*\{([^}]*)\}\s*from\s*${r}`,"gu");for(let c of e.matchAll(i))for(let l of(c[1]??"").split(",")){let u=/^\s*([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?\s*$/u.exec(l);u&&il.has(u[1])&&t.set(u[2]??u[1],u[1])}let o=new RegExp(String.raw`\b(?:const|let)\s*\{([^}]*)\}\s*=\s*require\s*\(\s*${r}\s*\)`,"gu");for(let c of e.matchAll(o))for(let l of(c[1]??"").split(",")){let u=/^\s*([A-Za-z_$][\w$]*)(?:\s*:\s*([A-Za-z_$][\w$]*))?\s*$/u.exec(l);u&&il.has(u[1])&&t.set(u[2]??u[1],u[1])}let s=new RegExp(String.raw`\bimport\s*\*\s*as\s*([A-Za-z_$][\w$]*)\s*from\s*${r}`,"gu");for(let c of e.matchAll(s))n.add(c[1]);let a=new RegExp(String.raw`\b(?:const|let)\s+([A-Za-z_$][\w$]*)\s*=\s*require\s*\(\s*${r}\s*\)`,"gu");for(let c of e.matchAll(a))n.add(c[1]);return{direct:t,namespaces:n}}function se(e,t,n,r){let i=ni(r,"runtime-boundaries.context.ast",t,()=>D(e,t)?.rootNode);if(!i)return null;let o=n??R(e,t),s,a,c,l=()=>(a!==void 0||(a=ni(r,"runtime-boundaries.context.callable-sites",t,()=>{let u=ne(t);return(u?ya(i,u):null)??Fr(e,t)})),a);return{db:e,file:t,source:o,root:i,get constants(){return c??=ni(r,"runtime-boundaries.context.constants",t,()=>gT(i)),c},ownerAt:u=>{let p=(s??=ni(r,"runtime-boundaries.context.definitions",t,()=>A(e,t,{rangeCorrectionEvidence:{source:o,callables:l()}},(g,y)=>ni(r,`runtime-boundaries.context.definitions.${g}`,t,y)))).filter(g=>g.startLine<=u&&g.endLine>=u).sort((g,y)=>g.endLine-g.startLine-(y.endLine-y.startLine)||g.startLine-y.startLine)[0];if(p)return{file:t,symbol:p.symbol,name:p.leaf,startLine:p.startLine,endLine:p.endLine};let m=(l()??[]).filter(g=>g.startLine<=u&&g.endLine>=u).sort((g,y)=>g.endLine-g.startLine-(y.endLine-y.startLine)||g.startLine-y.startLine)[0];return{file:t,symbol:null,name:m?.name??null,startLine:m?.startLine??u,endLine:m?.endLine??u}}}}function ni(e,t,n,r){return e?e(t,r,{file:n}):r()}function nT(){return{id:"builtin.effect-httpapi",supports:e=>ri(e,"HttpApiEndpoint").size>0||ri(e,"HttpApiBuilder").size>0,extract:e=>{let t=[],n=ri(e.source,"HttpApiEndpoint"),r=ri(e.source,"HttpApiGroup"),i=ri(e.source,"HttpApiBuilder");return qt(e.root,"call_expression",o=>{let s=Pg(o);if(!s)return;let a=xn(o);if(n.has(s.receiver)&&Eg.has(s.member)){let g=Be(a[0],e),y=Be(a[1],e),I=vg(o,r,"make",0,e);if(!g||!y||!I)return;let h=s.member.toUpperCase();t.push(oe(e,o,"builtin.effect-httpapi","http.handle",[{name:"method",value:h,evidence:"literal"},{name:"path",...y}],it([{name:"path",...y}]),"effect-httpapi-endpoint-declaration")),t.push(oe(e,o,"builtin.effect-httpapi","framework.declare",rl(I,g),it(rl(I,g)),"effect-httpapi-operation-declaration"));return}if(!["handle","handleRaw"].includes(s.member))return;let c=vg(o,i,"group",1,e),l=Be(a[0],e),u=a[1];if(!c||!l||!u)return;let d=rl(c,l),p=or(e.db,e.file,u.text),f=oe(e,o,"builtin.effect-httpapi","framework.handle",d,p.length===1?it(d):"candidate","effect-httpapi-handler-registration"),m=p[0];p.length===1&&m&&(f.owner={file:m.relativePath,symbol:m.symbol,name:m.leaf,startLine:m.startLine,endLine:m.endLine}),t.push(f)}),t}}}function rl(e,t){return[{name:"adapter",value:"effect-httpapi",evidence:"literal"},{name:"group",...e},{name:"operation",...t}]}function ri(e,t){let n=new Set,r=/\bimport\s*\{([\s\S]*?)\}\s*from\s*['"]([^'"]+)['"]/gu;for(let o of e.matchAll(r)){let s=o[2]??"";if(xg(s))for(let a of(o[1]??"").split(",")){let c=a.trim().replace(/^type\s+/u,""),l=/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/u.exec(c);l?.[1]===t&&n.add(l[2]??l[1])}}let i=/\bimport\s*\*\s*as\s*([A-Za-z_$][\w$]*)\s*from\s*['"]([^'"]+)['"]/gu;for(let o of e.matchAll(i)){let s=o[2]??"";s.endsWith(`/${t}`)&&xg(s)&&n.add(o[1])}return n}function xg(e){return e==="effect/unstable/httpapi"||e==="@effect/platform"||e.startsWith("@effect/platform/HttpApi")}function vg(e,t,n,r,i){let o=e.parent;for(;o;){if(o.type==="call_expression"){let s=Ig(o,t,n,r,i);if(s)return s;let a=o.childForFieldName("function")??o.namedChild(0),c=null;if(a&&al(a,l=>{!c&&l.type==="call_expression"&&(c=Ig(l,t,n,r,i))}),c)return c}o=o.parent}return null}function Ig(e,t,n,r,i){let o=Pg(e);return!o||o.member!==n||!t.has(o.receiver)?null:Be(xn(e)[r],i)}function Pg(e){let t=e.childForFieldName("function")??e.namedChild(0);if(!t||!["member_expression","subscript_expression"].includes(t.type))return null;let n=t.childForFieldName("object")??t.namedChild(0),r=t.childForFieldName("property")??t.childForFieldName("index")??t.namedChild(1);return!n||!r?null:{receiver:n.text.replace(/\s+/gu,""),member:r.text.replace(/^['"`]|['"`]$/gu,"")}}function rT(){return{id:"builtin.http",supports:e=>/\bfetch\s*\(|\baxios\b|\b(?:app|router|server)\s*\.\s*(?:get|post|put|patch|delete|options|head)\s*\(/u.test(e)||ii(e,["axios"])||/\b(?:FastAPI|Flask|APIRouter|axum|Router::new)\b/u.test(e),extract:e=>{let t=[];return qt(e.root,["decorator","call_expression"],n=>{if(n.type==="decorator"){let p=/^@[^\s(]+\.(get|post|put|patch|delete|options|head)\s*\(\s*(['"`])([^'"`]+)\2/iu.exec(n.text.trim());if(!p||!ii(e.source,["fastapi","flask"]))return;t.push(oe(e,n,"builtin.http","http.handle",[{name:"method",value:p[1].toUpperCase(),evidence:"literal"},{name:"path",value:p[3],evidence:"literal"}],"exact","framework-decorator"));return}if(n.type!=="call_expression")return;let r=oi(n);if(!r)return;let i=r.split(".").at(-1)?.toLowerCase()??"",o=r.includes(".")?r.slice(0,r.lastIndexOf(".")):"",s=xn(n);if(i==="route"&&ii(e.source,["axum"])){let p=Be(s[0],e),f=/^\s*(get|post|put|patch|delete|options|head)\s*\(/iu.exec(s[1]?.text??"")?.[1];if(!p||!f)return;t.push(oe(e,n,"builtin.http","http.handle",[{name:"method",value:f.toUpperCase(),evidence:"literal"},{name:"path",...p}],it([{name:"path",...p}]),"framework-adapter"));return}if(r==="fetch"||r.endsWith(".fetch")){let p=Be(s[0],e);if(!p)return;let m=/\bmethod\s*:\s*['"`]([A-Za-z]+)['"`]/u.exec(s[1]?.text??"")?.[1]?.toUpperCase()??(s[1]?null:"GET"),g=[...m?[{name:"method",value:m,evidence:"literal"}]:[],{name:"path",...p}];t.push(oe(e,n,"builtin.http","http.request",g,m?it(g):"candidate","call-expression"));return}if(!Eg.has(i))return;let a=Be(s[0],e);if(!a)return;let c=i.toUpperCase();if(XN.test(o)&&ii(e.source,["express","fastify","hono","koa-router","@koa/router"])){t.push(oe(e,n,"builtin.http","http.handle",[{name:"method",value:c,evidence:"literal"},{name:"path",...a}],it([{name:"path",...a}]),"framework-adapter"));return}let u=pT(e.source,["axios"]),d=o.split(".")[0]??"";u.has(d)&&t.push(oe(e,n,"builtin.http","http.request",[{name:"method",value:c,evidence:"literal"},{name:"path",...a}],it([{name:"path",...a}]),"client-adapter"))}),t}}}function iT(){return{id:"builtin.capability-registry",supports:e=>yg.test(e)&&hg.test(e)||Sg.test(e)||bg.test(e),extract:e=>{let t=[],n=new Set,r=[];return yg.test(e.source)&&hg.test(e.source)&&r.push("pair"),(Sg.test(e.source)||bg.test(e.source))&&r.push("string","string_literal","template_string"),qt(e.root,r,i=>{if(i.type==="pair"){let s=i.childForFieldName("key")??i.namedChild(0),a=i.childForFieldName("value")??i.namedChild(1),c=s?.text.replace(/^['"`]|['"`]$/gu,"");if(c!=="name"&&c!=="id")return;let l=Rg(a,e),u=hT(i);if(!l||l.evidence!=="literal"||!u)return;let d=`handle\0${l.value}\0${u.startPosition.row}`;if(n.has(d))return;n.add(d),t.push(oe(e,u,"builtin.capability-registry","registry.handle",[{name:"key",...l}],"exact","capability-descriptor"));return}if(!["string","string_literal","template_string"].includes(i.type))return;let o=i.text.replace(/^['"`]|['"`]$/gu,"");for(let s of o.matchAll(/\b([A-Za-z_$][\w$-]*)\s*\(/gu)){let a=s[1];if(!oT(o,a,s.index))continue;let c=`reference\0${a}\0${i.startPosition.row}`;n.has(c)||(n.add(c),t.push(oe(e,i,"builtin.capability-registry","registry.reference",[{name:"key",value:a,evidence:"literal"}],"exact","capability-instruction-reference")))}}),t}}}function oT(e,t,n){if(t.includes("_")||t.includes("-"))return!0;let r=e.slice(Math.max(0,n-64),n);return/\b(?:use|call|invoke|run|via|with|read|stop)(?:\s+the)?(?:\s+(?:tool|capability|command))?\s*$/iu.test(r)}function sT(){return{id:"builtin.registry",supports:e=>/(?:Handlers?|Registry|Routes?)\b/iu.test(e),extract:e=>{let t=[];return qt(e.root,["pair","call_expression"],n=>{if(n.type==="pair"){let o=yT(n);if(!o)return;let s=n.childForFieldName("key")??n.namedChild(0),a=n.childForFieldName("value")??n.namedChild(1),c=Rg(s,e);if(!c||!a||!wg(a))return;let l=sl(a)?"exact":"candidate";t.push(oe(e,n,"builtin.registry","registry.handle",[{name:"registry",value:o,evidence:"identifier"},{name:"key",...c}],it([{name:"key",...c}],l),"object-member"));return}if(n.type!=="call_expression")return;let r=n.childForFieldName("function")??n.namedChild(0);if(!r)return;let i=/^([A-Za-z_$][\w$]*)\s*\[\s*(['"`])([^'"`]+)\2\s*\]$/u.exec(r.text.trim());i&&t.push(oe(e,n,"builtin.registry","registry.dispatch",[{name:"registry",value:i[1],evidence:"identifier"},{name:"key",value:i[3],evidence:"literal"}],"exact","indexed-access-call"))}),t}}}function aT(){return{id:"builtin.persistence",supports:e=>/\b(?:db|database|prisma|drizzle|[A-Za-z_$][\w$]*(?:Repository|Repo))\b[^;]{0,1024}?\.\s*(?:findFirst|findMany|findUnique|from|get|select|create|delete|insert|remove|update|upsert|execute|query|raw|transaction)(?:\s*<[^()]{1,512}>)?\s*\(/iu.test(e),extract:e=>{let t=[],n=bT(e.root);return qt(e.root,"call_expression",r=>{let i=oi(r);if(!i)return;let o=i.split("."),s=o.at(-1)??"",a=xn(r),c=a[0]?.text??"",l=ST(s,c);if(!l)return;let u=Cg(o,n);if(!u)return;let d=cT(a[0],e)??xT(c),p=vT(u,o,s,d);if(!p)return;let f=s==="insert"?"persistence-insert":l==="database.read"&&/\bFOR\s+UPDATE\s+SKIP\s+LOCKED\b/iu.test(c)?"persistence-skip-locked-claim":"persistence-adapter";t.push(oe(e,r,"builtin.persistence",l,[{name:"resource",...p}],it([{name:"resource",...p}]),f))}),t}}}function cT(e,t){if(!e)return null;let n=e.text.replace(/\s+/gu,"");return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/u.test(n)?{value:n.split(".").at(-1),evidence:"identifier",term:{kind:"symbol",symbol:n}}:Be(e,t)}function lT(){return{id:"builtin.queue",supports:e=>ii(e,["amqplib","bullmq","kafkajs","@aws-sdk/client-sqs","rabbitmq"])&&/\.(?:sendToQueue|consume|send|subscribe)\s*\(/u.test(e),extract:e=>{let t=[];return qt(e.root,"call_expression",n=>{let r=oi(n);if(!r)return;let i=r.split(".").at(-1)??"",o=xn(n),s=i==="sendToQueue"||i==="send"?"queue.send":i==="consume"||i==="subscribe"?"queue.consume":null;if(!s)return;let a=i==="send"||i==="subscribe"?fT(o[0],"topic",e):Be(o[0],e);a&&t.push(oe(e,n,"builtin.queue",s,[{name:"address",...a}],it([{name:"address",...a}]),"framework-adapter"))}),t}}}function oe(e,t,n,r,i,o,s){let a=e.ownerAt(t.startPosition.row),c=JSON.stringify({extractor:n,action:r,file:e.file,line:t.startPosition.row,keyParts:i});return{id:`boundary:${JN("sha256").update(c).digest("hex").slice(0,16)}`,extractor:n,action:r,owner:a,source:{file:e.file,startLine:t.startPosition.row,endLine:t.endPosition.row},keyParts:i,evidence:s,strength:o,protocol:r.split(".")[0]??r,role:uT(r),executionDomain:dT(e.file),derivation:{kind:o==="candidate"?"heuristic":o==="derived"?"mechanically-derived":"direct",rule:s,ruleVersion:"1",inputFactIds:i.flatMap(l=>l.derivation?.inputFactIds??[]),sourceSpans:[{file:e.file,startLine:t.startPosition.row,endLine:t.endPosition.row},...i.flatMap(l=>l.derivation?.sourceSpans??[])]},valuePrecision:i.some(l=>l.evidence==="expression")?"unknown":i.some(l=>l.evidence==="identifier")?"symbolic":"literal",modality:"may",resolution:"unresolved",sourceScope:Ho(e.file)}}function uT(e){let t=e.split(".").at(-1)??e;return["handle","subscribe","consume","read"].includes(t)?"consumer":["request","publish","send","write","dispatch","reference","invoke","spawn","exec"].includes(t)?"producer":"observe"}function dT(e){let t=e.replaceAll("\\","/"),n=/^(apps|services|packages)\/([^/]+)/u.exec(t);return n?`${n[1]}/${n[2]}`:null}function ii(e,t){return t.some(n=>{let r=n.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`(?:\\bfrom\\s+${r}\\b|\\buse\\s+${r}\\b|(?:\\bfrom\\s*|\\brequire\\s*\\(\\s*)['"]${r}(?:[/']|"))`,"u").test(e)})}function pT(e,t){let n=new Set;for(let r of t){let i=r.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),o=new RegExp(`(?:import\\s+([A-Za-z_$][\\w$]*)[^;]*?\\sfrom\\s*|(?:const|let)\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*require\\s*\\(\\s*)['"]${i}(?:[/']|")`,"gu");for(let s of e.matchAll(o)){let a=s[1]??s[2];a&&n.add(a)}}return n}function Xo(e,t,n,r,i,o,s){return oe(e,t,n,r,i,o,s)}function oi(e){return(e.childForFieldName("function")??e.namedChild(0))?.text.replace(/\s+/gu,"")??null}function xn(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function Be(e,t){let n=Ue(t,e);return n?{value:n.value,evidence:n.evidence,term:n.term,derivation:n.derivation}:null}function fT(e,t,n){if(!e)return null;let r=e.namedChildren.find(o=>o.type!=="pair"?!1:(o.childForFieldName("key")??o.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"")===t),i=r?.childForFieldName("value")??r?.namedChild(1);return Be(i,n)}function Rg(e,t){if(!e)return null;let n=Be(e,t);if(n?.evidence==="literal"||n?.evidence==="constant")return n;let r=e.text.trim();return/^[A-Za-z_$][\w$]*$/u.test(r)?{value:r,evidence:"identifier",term:{kind:"symbol",symbol:r}}:n}function it(e,t="exact"){return t==="candidate"||e.some(n=>n.evidence==="expression")?"candidate":t==="derived"||e.some(n=>n.evidence==="constant")?"derived":"exact"}function mT(e){let t=e.text.trim(),n=t[0];if(n!=="'"&&n!=='"'&&n!=="`"||t.at(-1)!==n)return null;let r=t.slice(1,-1);return n==="`"&&r.includes("${")?null:r}function gT(e){let t=new Map;return al(e,n=>{if(n.type!=="variable_declarator")return;let r=n.childForFieldName("name")??n.namedChild(0),i=n.childForFieldName("value")??n.namedChild(1);if(!r||!i||!/^[A-Za-z_$][\w$]*$/u.test(r.text))return;let o=mT(i);o!==null&&t.set(r.text,o)}),t}function yT(e){let t=e.parent,n=t?.parent??null;for(;n&&["as_expression","satisfies_expression","type_assertion","parenthesized_expression"].includes(n.type);)n=n.parent;if(!t||!n||n.type!=="variable_declarator")return null;let i=(n.childForFieldName("name")??n.namedChild(0))?.text??"";return/(?:handlers?|registry|routes?)$/iu.test(i)?i:null}function sl(e){return/(?:function|lambda|method)/u.test(e.type)||e.type==="arrow_function"}function wg(e){return sl(e)||e.type==="member_expression"?!0:e.type==="identifier"&&/(?:command|controller|dispatch|handle|handler)/iu.test(e.text)}function hT(e){let t=e.parent;for(;t&&t.type!=="variable_declarator";){if(["object","object_literal","dictionary"].includes(t.type))for(let n of t.namedChildren){if(n.type==="pair"){let i=n.childForFieldName("key")??n.namedChild(0),o=n.childForFieldName("value")??n.namedChild(1),s=i?.text.replace(/^['"`]|['"`]$/gu,"");if(s&&["execute","handler","invoke","run"].includes(s)&&o&&wg(o))return t}let r=n.childForFieldName("name")??n.namedChild(0);if(r&&["execute","handler","invoke","run"].includes(r.text.replace(/^['"`]|['"`]$/gu,""))&&/(?:function|method)/u.test(n.type))return t}t=t.parent}return null}function Cg(e,t=new Set){let n=e.slice(0,-1).map(r=>r.replace(/\([^)]*\)/gu,""));return n.some(r=>/^(?:prisma|drizzle)$/iu.test(r))?"orm":n.some(r=>/(?:Repository|Repo)$/u.test(r))?"repository":n.some(r=>/^(?:db|database)$/iu.test(r)||t.has(r))?"database":null}function ST(e,t){if(YN.has(e))return"database.read";if(QN.has(e))return"database.write";if(!ZN.has(e))return null;let n=/\b(SELECT|INSERT|UPDATE|DELETE)\b/iu.exec(t)?.[1]?.toUpperCase();return n==="SELECT"?"database.read":n?"database.write":null}function bT(e){let t=new Set;return qt(e,"call_expression",n=>{let r=oi(n);if(!r)return;let i=r.split(".");if(!(i.at(-1)!=="transaction"||!Cg(i)))for(let o of xn(n)){if(!sl(o))continue;let a=(o.childForFieldName("parameters")??o.namedChildren.find(l=>/parameters/u.test(l.type)))?.namedChildren[0],c=a?vr(a):null;c&&t.add(c)}}),t}function xT(e){let t=Fg(e);return t?{value:t,evidence:"identifier",term:{kind:"symbol",symbol:t}}:null}function vT(e,t,n,r){if(e==="orm"&&t.length>=3)return{value:t.at(-2).replace(/\([^)]*\)/gu,""),evidence:"identifier"};if(e==="repository"){let o=t.at(-2)?.replace(/(?:Repository|Repo)$/u,"");return o?{value:o,evidence:"identifier"}:null}if(!r)return null;if(n==="from"||n==="insert")return r;let i=Fg(r.value);return i?{value:i,evidence:r.evidence}:null}function Fg(e){return/\b(?:from|into|update|table)\s+(?:\$\{\s*)?['"`]?([A-Za-z_$][\w$.-]*)/iu.exec(e)?.[1]??null}function al(e,t){t(e);for(let n of e.namedChildren)al(n,t)}function qt(e,t,n){for(let r of e.descendantsOfType(t))n(r)}var IT=C("resolved-call-syntax",{clearGroups:[]}),ET=C("resolved-call-sites",{clearGroups:[]});function si(e,t){return ET.get(e,t.symbolId,()=>PT(e,t))}function PT(e,t){let n=[],r=[],i=new Set,o=new Set;for(let s of Wa(e,t,{semantic:!1})){i.add(s.file);let a=IT.get(e,s.file,()=>RT(e,s.file));if(!a){r.push({callee:t,file:s.file,line:s.line,reason:"ast-unavailable",candidates:0,referenceProvenance:s.provenance});continue}let c=(a.byLeaf.get(t.leaf)??[]).filter(({callNode:d})=>d.startPosition.row<=s.line&&d.endPosition.row>=s.line);if(c.length!==1){r.push({callee:t,file:s.file,line:s.line,reason:c.length===0?"call-not-found":"ambiguous-call",candidates:c.length,referenceProvenance:s.provenance});continue}let l=c[0],u=`${s.file}\0${l.callNode.startIndex}\0${l.callNode.endIndex}`;o.has(u)||(o.add(u),n.push({callee:t,caller:Un(A(e,s.file),l.callNode.startPosition.row),file:s.file,line:s.line,startLine:l.callNode.startPosition.row,endLine:l.callNode.endPosition.row,targetText:l.targetNode.text,callNode:l.callNode,targetNode:l.targetNode,arguments:l.arguments,referenceProvenance:s.provenance}))}return{sites:n,unresolved:r,filesVisited:i.size}}function RT(e,t){let n=D(e,t)?.rootNode;if(!n)return null;let r=new Map;return Ng(n,i=>{if(i.type!=="call_expression"&&i.type!=="call")return;let o=i.childForFieldName("function")??i.namedChild(0);if(!o)return;let s=pt(o);if(!s)return;let a=i.childForFieldName("arguments")??i.namedChildren.find(u=>u.type==="arguments"),c={callNode:i,targetNode:o,arguments:a?.namedChildren??[]},l=r.get(s);l?l.push(c):r.set(s,[c])}),{byLeaf:r}}function Ng(e,t){t(e);for(let n of e.namedChildren)Ng(n,t)}var wT=C("call-parameter-value-flow",{clearGroups:[]});function ai(e,t){let n=`${t.callee.symbolId}\0${t.file}\0${t.callNode.startIndex}\0${t.callNode.endIndex}`;return wT.get(e,n,()=>CT(e,t))}function ci(e,t){let n=new Set(t);return[...new Set(e.transfers.flatMap(r=>n.has(r.calleePosition)?[r.callerPosition]:[]))].sort((r,i)=>r-i)}function CT(e,t){let n={file:t.file,startLine:t.startLine,endLine:t.endLine};if(!t.caller)return{callee:t.callee,caller:null,call:n,transfers:[],unknown:t.arguments.map((c,l)=>({calleePosition:l,argumentText:c.text.trim(),reason:"caller-unavailable",proof:n}))};let r=D(e,t.caller.relativePath)?.rootNode,i=r?_e(r,t.caller.startLine,t.caller.endLine):null;if(!i)return{callee:t.callee,caller:t.caller,call:n,transfers:[],unknown:t.arguments.map((c,l)=>({calleePosition:l,argumentText:c.text.trim(),reason:"caller-syntax-unavailable",proof:n}))};let o=Dt(i),s=[],a=[];return t.arguments.forEach((c,l)=>{let u=c.text.trim(),d=o.indexOf(u);d>=0?s.push({calleePosition:l,callerPosition:d,argumentText:u,proof:n}):a.push({calleePosition:l,argumentText:u,reason:"argument-not-direct-parameter",proof:n})}),{callee:t.callee,caller:t.caller,call:n,transfers:s,unknown:a}}var FT=8,NT=8;function kg(e,t){let n=[],r=TT(e,n),i=r.summaries,o=kT(e,t,i,n),s=_T(e,t,n);return{observations:qT([...o.observations,...s]),bodySummaries:i.size,discriminatorSummaries:o.summaries,filesInspected:r.filesInspected,errors:n}}function TT(e,t){let n=new Map,r=[],i=ye(e);for(let o of i){let s=R(e,o);if(!/\bJSON\.stringify\s*\(/u.test(s)||!/\bbody\s*:/u.test(s))continue;let a=se(e,o);if(a)for(let[c,l]of LT(a)){let u={definition:c,parameterIndexes:l,depth:0,proofSpans:[{file:o,startLine:c.startLine,endLine:c.endLine}]};n.set(c.symbol,u),r.push(u)}}for(;r.length>0;){let o=r.shift();if(!(o.depth>=FT))try{for(let s of si(e,o.definition).sites){if(!se(e,s.file))continue;let c=s.caller;if(!c)continue;let l=ci(ai(e,s),o.parameterIndexes);if(l.length===0)continue;let u={definition:c,parameterIndexes:Og(l),depth:o.depth+1,proofSpans:[...o.proofSpans,{file:s.file,startLine:s.startLine,endLine:s.endLine}]};MT(n,u)&&r.push(n.get(c.symbol))}}catch(s){t.push(`builtin.carrier body summary failed for ${o.definition.relativePath}: ${ul(s)}`)}}return{summaries:n,filesInspected:i.length}}function kT(e,t,n,r){let i=new Map,o=[],s=[];for(let a of t){if(a.action!=="http.request"||a.strength==="candidate"||a.sourceScope!=="production")continue;let c=_g(a);if(!c)continue;let l=se(e,a.source.file);if(!l)continue;let u=Lg(l.root,a.source.startLine),d=u.find(h=>h.startPosition.row===a.source.startLine)??u[0];if(!d)continue;let p=ll(d);if(!p)continue;let f=or(e,a.source.file,p.text);if(f.length!==1)continue;let m=n.get(f[0].symbol);if(!m)continue;let g=a.owner.symbol?A(e,a.owner.file).find(h=>h.symbol===a.owner.symbol):null;if(!g)continue;let y=jT(l,g),I=Yo(d);for(let h of m.parameterIndexes){let P=$T(l,I[h]);if(P)for(let w of GT(P)){let T=Dg(w),b=Ag(w);if(!T||!b)continue;let v=y.indexOf(b.text.trim());if(v>=0){let O={definition:g,carrier:c,field:T,parameterIndex:v,depth:0,proofObservationIds:[a.id],proofSpans:[a.source,{file:a.source.file,startLine:w.startPosition.row,endLine:w.endPosition.row}]},B=Tg(O);i.has(B)||(i.set(B,O),o.push(O));continue}let E=Ue(l,b);!E||E.evidence==="expression"||s.push(cl(l,w,"carrier.publish",c,T,E.value,[a.id]))}}}for(;o.length>0;){let a=o.shift();if(!(a.depth>=NT))try{for(let c of si(e,a.definition).sites){let l=se(e,c.file);if(!l)continue;let u=c.callNode,d=Yo(u)[a.parameterIndex];if(!d)continue;let p=Ue(l,d);p&&p.evidence!=="expression"&&s.push(cl(l,u,"carrier.publish",a.carrier,a.field,p.value,a.proofObservationIds));let f=c.caller;if(!f)continue;let m=ai(e,c).transfers.find(I=>I.calleePosition===a.parameterIndex)?.callerPosition;if(m===void 0)continue;let g={...a,definition:f,parameterIndex:m,depth:a.depth+1,proofSpans:[...a.proofSpans,{file:c.file,startLine:c.startLine,endLine:c.endLine}]},y=Tg(g);i.has(y)||(i.set(y,g),o.push(g))}}catch(c){r.push(`builtin.carrier discriminator summary failed for ${a.definition.relativePath}: ${ul(c)}`)}}return{observations:s,summaries:i.size}}function _T(e,t,n){let r=[],i=t.filter(o=>o.action==="registry.handle"&&o.strength!=="candidate"&&o.sourceScope==="production");for(let o of t){if(o.action!=="http.handle"||o.strength==="candidate"||o.sourceScope!=="production")continue;let s=_g(o);if(!s)continue;let a=se(e,o.source.file);if(!a)continue;let c=Lg(a.root,o.source.startLine)[0];if(c)for(let l of Yo(c).slice(1)){let u=or(e,o.source.file,l.text);for(let d of u)try{let p=se(e,d.relativePath);if(!p)continue;let f=_e(p.root,d.startLine,d.endLine);if(!f)continue;re(f,m=>{if(m.type!=="call_expression")return;let g=ll(m);if(!g)return;let y=/^([A-Za-z_$][\w$]*)\s*\[\s*([A-Za-z_$][\w$]*)\s*\]$/u.exec(g.text.trim());if(!y)return;let I=y[1],h=y[2],P=AT(e,p,d,h);if(!P)return;let w=OT(e,d.relativePath,I);for(let T of i){let b=T.keyParts.find(B=>B.name==="registry")?.value,v=T.keyParts.find(B=>B.name==="key")?.value;if(!b||!v||!w.some(B=>B.file===T.source.file&&B.binding===b))continue;let E=se(e,T.source.file),O=E?BT(E.root,T.source.startLine):null;!E||!O||r.push(cl(E,O,"carrier.consume",s,P,v,[o.id,T.id]))}})}catch(p){n.push(`builtin.carrier consumer analysis failed for ${d.relativePath}: ${ul(p)}`)}}}return r}function LT(e){let t=A(e.db,e.file),n=new Map;return re(e.root,r=>{if(r.type!=="pair"||Dg(r)?.toLowerCase()!=="body")return;let i=Ag(r);if(!i||!/\bJSON\.stringify\s*\(/u.test(i.text))return;let o=Un(t,r.startPosition.row),s=DT(r);if(!o||!s)return;let a=Dt(s),c=new Set;VT(i,a,c);let l=n.get(o.symbol)??new Set;a.forEach((u,d)=>{u&&c.has(u)&&l.add(d)}),l.size>0&&n.set(o.symbol,l)}),t.flatMap(r=>{let i=n.get(r.symbol);return i?[[r,[...i].sort((o,s)=>o-s)]]:[]})}function DT(e){let t=e.parent;for(;t;){if(/(?:function|method|lambda)/u.test(t.type)||t.type==="arrow_function")return t;t=t.parent}return null}function AT(e,t,n,r){let i=_e(t.root,n.startLine,n.endLine);if(!i)return null;let o=new RegExp(`\\.body\\??\\.${te(r)}\\b`,"u");if(o.test(i.text))return r;let s=null;if(re(i,u=>{if(s||u.type!=="variable_declarator")return;let d=u.childForFieldName("name")??u.namedChild(0),p=u.childForFieldName("value")??u.namedChild(1);!d||!p||!new RegExp(`(?:^|[,{}])\\s*${te(r)}\\s*(?:[,}]|$)`,"u").test(d.text)||p.type==="call_expression"&&(s=ll(p)?.text??null)}),!s)return null;let a=or(e,n.relativePath,s);if(a.length!==1)return null;let c=se(e,a[0].relativePath),l=c?_e(c.root,a[0].startLine,a[0].endLine):null;return l&&o.test(l.text)&&new RegExp(`\\b${te(r)}\\s*[,}]`,"u").test(l.text)?r:null}function OT(e,t,n){let r=[];for(let i of el(e,t,n)){let o=Le(i.initializer);if(o.type==="call_expression")for(let s of Yo(o)){let a=s.text.trim();if(/^[A-Za-z_$][\w$]*$/u.test(a))for(let c of el(e,i.definition.relativePath,a))r.push({file:c.definition.relativePath,binding:c.definition.leaf})}}return[...new Map(r.map(i=>[`${i.file}\0${i.binding}`,i])).values()]}function cl(e,t,n,r,i,o,s){let c=Xo(e,t,"builtin.carrier",n,[{name:"carrier",value:r,evidence:"constant",term:{kind:"literal",value:r}},{name:"field",value:i,evidence:"literal",term:{kind:"literal",value:i}},{name:"value",value:o,evidence:"constant",term:{kind:"literal",value:o}}],"derived","http-body-registry-discriminator");return c.derivation={kind:"mechanically-derived",rule:"http-body-registry-discriminator",ruleVersion:"1",inputFactIds:[...s],sourceSpans:[c.source]},c}function _g(e){let t=e.keyParts.find(r=>r.name==="method"&&r.evidence!=="expression")?.value,n=e.keyParts.find(r=>r.name==="path"&&r.evidence!=="expression")?.value;return t&&n?`${t.toUpperCase()} ${n}`:null}function MT(e,t){let n=e.get(t.definition.symbol);if(!n)return e.set(t.definition.symbol,t),!0;let r=Og([...n.parameterIndexes,...t.parameterIndexes]);return r.length===n.parameterIndexes.length&&t.depth>=n.depth?!1:(e.set(t.definition.symbol,{...n,parameterIndexes:r,depth:Math.min(n.depth,t.depth),proofSpans:[...n.proofSpans,...t.proofSpans]}),!0)}function Tg(e){return`${e.definition.symbol}\0${e.carrier}\0${e.field}\0${e.parameterIndex}`}function jT(e,t){let n=_e(e.root,t.startLine,t.endLine);return n?Dt(n):[]}function BT(e,t){let n=null;return re(e,r=>{r.startPosition.row>t||r.endPosition.row<t||(!n||r.endIndex-r.startIndex<n.endIndex-n.startIndex)&&(n=r)}),n}function Lg(e,t){let n=[];return re(e,r=>{r.type==="call_expression"&&r.startPosition.row<=t&&r.endPosition.row>=t&&n.push(r)}),n.sort((r,i)=>r.endIndex-r.startIndex-(i.endIndex-i.startIndex))}function ll(e){return e.childForFieldName("function")??e.namedChild(0)}function Yo(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function $T(e,t){if(!t)return null;let n=t.text.trim();if(!/^[A-Za-z_$][\w$]*$/u.test(n))return Le(t);let r=null;return re(e.root,i=>{r||i.type!=="variable_declarator"||(i.childForFieldName("name")??i.namedChild(0))?.text.trim()!==n||(r=i.childForFieldName("value")??i.namedChild(1))}),r?Le(r):Le(t)}function GT(e){let t=Le(e);return t.type==="object"?t.namedChildren.filter(n=>n.type==="pair"||n.type==="shorthand_property_identifier"):[]}function Dg(e){return e.type==="shorthand_property_identifier"?e.text:(e.childForFieldName("key")??e.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"")??null}function Ag(e){return e.type==="shorthand_property_identifier"?e:e.childForFieldName("value")??e.namedChild(1)}function VT(e,t,n){let r=new Set(e.text.match(/[A-Za-z_$][\w$]*/gu)??[]);for(let i of t)i&&r.has(i)&&n.add(i)}function Og(e){return[...new Set(e)].sort((t,n)=>t-n)}function qT(e){return[...new Map(e.map(t=>[t.id,t])).values()]}function ul(e){return e instanceof Error?e.message:String(e)}import{createHash as WT}from"crypto";function Mg(e,t){let n=new Map;for(let o of t){if(o.action!=="http.handle"||o.sourceScope!=="production")continue;let s=n.get(o.source.file)??[];s.push(o),n.set(o.source.file,s)}let r=[],i=zT(e);for(let o of i.mounts)for(let s of o.targetFiles)for(let a of n.get(s)??[]){let c=a.keyParts.find(p=>p.name==="path");if(!c||c.evidence==="expression")continue;let l=HT(o.prefix.value,c.value),u=a.keyParts.map(p=>p.name==="path"?{name:"path",value:l,evidence:"constant",term:{kind:"concat",parts:[o.prefix.term??{kind:"literal",value:o.prefix.value},c.term??{kind:"literal",value:c.value}]},derivation:{kind:"mechanically-derived",rule:"http.mount-prefix",ruleVersion:"1",inputFactIds:[a.id],sourceSpans:[a.source,{file:o.file,startLine:o.line,endLine:o.line},...o.prefix.derivation?.sourceSpans??[],...c.derivation?.sourceSpans??[]]}}:p),d=`${a.id}\0${o.file}\0${o.line}\0${l}`;r.push({...a,id:`boundary:${WT("sha256").update(d).digest("hex").slice(0,16)}`,keyParts:u,strength:"derived",evidence:"framework-mount-composition",derivation:{kind:"mechanically-derived",rule:"http.mount-prefix",ruleVersion:"1",inputFactIds:[a.id],sourceSpans:[a.source,{file:o.file,startLine:o.line,endLine:o.line}]},resolution:"unresolved"}),a.strength="candidate",a.resolution="unresolved"}return{observations:r,filesInspected:i.filesInspected,mounts:i.mounts.length}}function zT(e){let t=[],n=ye(e);for(let r of n){let i=R(e,r);if(!KT(i))continue;let o=se(e,r);o&&jg(o.root,s=>{if(s.type!=="call_expression")return;let a=s.childForFieldName("function")??s.namedChild(0);if(!a||!a.text.replace(/\s+/gu,"").endsWith(".use"))return;let c=JT(s);if(c.length<2)return;let l=Ue(o,c[0]);if(!l||l.evidence==="expression")return;let u=UT(e,r,c[1]);u.length!==0&&t.push({file:r,line:s.startPosition.row,prefix:{value:l.value,evidence:l.evidence,term:l.term,derivation:l.derivation},targetFiles:u})})}return{mounts:t,filesInspected:n.length}}function UT(e,t,n){let r=n.text.replace(/\s+/gu,""),i=/^([A-Za-z_$][\w$]*)/u.exec(r)?.[1];if(!i)return[];let o=U(e,t).find(c=>c.localName===i&&c.sourcePath);if(!o?.sourcePath)return[t];if(o.kind==="namespace")return[o.sourcePath];let s=o.importedName==="default"?i:o.importedName,a=bn(e,o.sourcePath,s);return[...new Set(a.map(c=>c.relativePath))]}function HT(e,t){let n=e==="/"?"":e.replace(/\/+$/u,""),r=t.startsWith("/")?t:`/${t}`;return`${n}${r}`||"/"}function KT(e){return/(?:\bfrom\s*|\brequire\s*\(\s*)['"](?:express|fastify|hono|koa-router|@koa\/router)(?:[/']|")/u.test(e)}function JT(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function jg(e,t){t(e);for(let n of e.namedChildren)jg(n,t)}import{createHash as XT}from"crypto";function Qo(e){return[...new Map(e.map(t=>[t.observationId,t])).values()].sort((t,n)=>t.observationId.localeCompare(n.observationId))}var dl=new Set(["DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT"]),YT=8;function Gg(e,t){let n=new Map,r=[],i=[],o=new Set,s=[],a=[];for(let c of t){if(c.action!=="http.request"||!c.owner.symbol||c.evidence!=="call-expression"&&c.evidence!=="client-adapter")continue;let l=A(e,c.owner.file).find(f=>f.symbol===c.owner.symbol);if(!l)continue;let u=se(e,l.relativePath);if(!u)continue;let d=Bg(u,l),p={definition:l,...d,constantMethods:c.keyParts.flatMap(f=>f.name==="method"&&f.evidence!=="expression"&&dl.has(f.value.toUpperCase())?[f.value.toUpperCase()]:[]),depth:0,proofObservationIds:[c.id],proofSpans:[c.source]};$g(n,p)&&r.push(n.get(l.symbol))}for(;r.length>0;){let c=r.shift();if(!(c.depth>=YT))try{let l=si(e,c.definition);a.push(...l.unresolved.map(u=>QT(c,u)));for(let u of l.sites){let d=se(e,u.file);if(!d)continue;o.add(u.file);let p=u.callNode,f=ZT(c,p,d);f&&i.push(f);let m=u.caller;if(!m)continue;let g=Bg(d,m),y=ek(e,c,u),I={definition:m,pathParameterIndexes:Zo([...g.pathParameterIndexes,...y.pathParameterIndexes]),methodParameterIndexes:Zo([...g.methodParameterIndexes,...y.methodParameterIndexes]),constantMethods:ar([...c.constantMethods,...g.constantMethods]),depth:c.depth+1,proofObservationIds:ar([...c.proofObservationIds,...f?[f.id]:[]]),proofSpans:[...c.proofSpans,{file:u.file,startLine:u.startLine,endLine:u.endLine}]};$g(n,I)&&r.push(n.get(m.symbol))}}catch(l){s.push(`builtin.http-summary failed for ${c.definition.relativePath}:${c.definition.startLine+1}: ${l instanceof Error?l.message:String(l)}`)}}return{observations:i,frontiers:Qo(a),summaries:n.size,filesInspected:o.size,errors:s}}function QT(e,t){let n=ar([...e.pathParameterIndexes.length>0?["path"]:[],...e.methodParameterIndexes.length>0&&e.constantMethods.length!==1?["method"]:[]]),r=e.constantMethods.length===1?e.constantMethods[0]:"?",i=`${e.definition.symbol}\0${t.file}\0${t.line}\0${t.reason}`;return{observationId:`frontier:${XT("sha256").update(i).digest("hex").slice(0,16)}`,kind:"call-resolution",action:"http.request",strength:"candidate",source:{file:t.file,startLine:t.line,endLine:t.line},ownerShortName:null,address:`method=${r??"?"} path=?`,reason:`Compiler identity found a reference to ${e.definition.leaf}, but exact call recovery stopped with ${t.reason} (${t.candidates} syntax candidate(s)); HTTP value propagation did not cross this site.`,missingKeyParts:n.length>0?n:["call"],sourceScope:Ho(t.file)}}function ZT(e,t,n){let r=Vg(t),i=e.pathParameterIndexes.flatMap(d=>{let p=Ue(n,r[d]);return p&&p.evidence!=="expression"&&nk(p.value)?[{index:d,value:p}]:[]}),o=e.methodParameterIndexes.flatMap(d=>{let p=Ue(n,r[d]),f=p?.value.toUpperCase();return p&&f&&p.evidence!=="expression"&&dl.has(f)?[{index:d,value:{...p,value:f}}]:[]}),s=ar([...e.constantMethods,...o.map(d=>d.value.value)]);if(i.length!==1||s.length!==1)return null;let a=i[0].value,c=o.find(d=>d.value.value===s[0])?.value,l=[{name:"method",value:s[0],evidence:c?"constant":"literal",term:c?.term??{kind:"literal",value:s[0]},derivation:c?.derivation},{name:"path",value:a.value,evidence:"constant",term:a.term,derivation:a.derivation}],u=Xo(n,t,"builtin.http-summary","http.request",l,"derived","compiler-resolved-http-summary");return u.derivation={kind:"mechanically-derived",rule:"compiler-resolved-http-summary",ruleVersion:"1",inputFactIds:e.proofObservationIds,sourceSpans:[...e.proofSpans,u.source]},u}function Bg(e,t){let n=_e(e.root,t.startLine,t.endLine);if(!n)return{pathParameterIndexes:[],methodParameterIndexes:[],constantMethods:[]};let r=Dt(n),i=new Set,o=new Set,s=new Set;return re(n,a=>{if(a.type==="call_expression"&&((a.childForFieldName("function")??a.namedChild(0))?.text.replace(/\s+/gu,"").split(".").at(-1)??"")==="fetch"){let f=Vg(a);li(f[0],r,i);let m=tk(f[1],"method");if(m){li(m,r,o);let g=Ue(e,m),y=g?.value.toUpperCase();y&&g?.evidence!=="expression"&&dl.has(y)&&s.add(y)}else li(f[1],r,o)}if(a.type!=="pair")return;let c=a.childForFieldName("key")??a.namedChild(0),l=a.childForFieldName("value")??a.namedChild(1),u=c?.text.replace(/^['"`]|['"`]$/gu,"").toLowerCase();(u==="url"||u==="path"||u==="endpoint")&&li(l,r,i),(u==="init"||u==="requestinit"||u==="options")&&li(l,r,o)}),{pathParameterIndexes:r.flatMap((a,c)=>a&&i.has(a)?[c]:[]),methodParameterIndexes:r.flatMap((a,c)=>a&&o.has(a)?[c]:[]),constantMethods:[...s].sort()}}function ek(e,t,n){let r=ai(e,n);return{pathParameterIndexes:ci(r,t.pathParameterIndexes),methodParameterIndexes:ci(r,t.methodParameterIndexes)}}function $g(e,t){let n=e.get(t.definition.symbol);if(!n)return e.set(t.definition.symbol,t),!0;let r=Zo([...n.pathParameterIndexes,...t.pathParameterIndexes]),i=Zo([...n.methodParameterIndexes,...t.methodParameterIndexes]),o=ar([...n.constantMethods,...t.constantMethods]);return r.length!==n.pathParameterIndexes.length||i.length!==n.methodParameterIndexes.length||o.length!==n.constantMethods.length||t.depth<n.depth?(e.set(t.definition.symbol,{...n,pathParameterIndexes:r,methodParameterIndexes:i,constantMethods:o,depth:Math.min(n.depth,t.depth),proofObservationIds:ar([...n.proofObservationIds,...t.proofObservationIds]),proofSpans:[...n.proofSpans,...t.proofSpans]}),!0):!1}function tk(e,t){if(!e)return null;for(let n of e.namedChildren)if(!(n.type!=="pair"||(n.childForFieldName("key")??n.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"").toLowerCase()!==t))return n.childForFieldName("value")??n.namedChild(1);return null}function li(e,t,n){if(!e)return;let r=new Set(e.text.match(/[A-Za-z_$][\w$]*/gu)??[]);for(let i of t)i&&r.has(i)&&n.add(i)}function Vg(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function nk(e){return e.startsWith("/")||/^https?:\/\//iu.test(e)}function Zo(e){return[...new Set(e)].sort((t,n)=>t-n)}function ar(e){return[...new Set(e)].sort()}import{createHash as rk}from"crypto";function zg(e){let t=qg(e.filter(r=>r.action==="database.read"&&r.evidence==="persistence-skip-locked-claim")),n=qg(e.filter(r=>r.action==="database.write"&&r.evidence==="persistence-insert"));return e.flatMap(r=>r.action==="database.write"&&r.evidence==="persistence-insert"?pl(r).flatMap(i=>{let o=t.get(i)?.[0];return o?[Wg(r,o,i,"queue.send")]:[]}):r.action==="database.read"&&r.evidence==="persistence-skip-locked-claim"?pl(r).flatMap(i=>{let o=n.get(i)?.[0];return o?[Wg(r,o,i,"queue.consume")]:[]}):[])}function qg(e){let t=new Map;for(let n of e)for(let r of pl(n)){let i=t.get(r);i?i.push(n):t.set(r,[n])}for(let n of t.values())n.sort((r,i)=>r.id.localeCompare(i.id));return t}function pl(e){return e.keyParts.filter(t=>t.name==="resource").map(t=>t.value)}function Wg(e,t,n,r){let i=`database:${n}`,o=r==="queue.send"?"database-queue-insert":"database-queue-skip-locked-claim",s=[e.id,r,i,o].join("\0");return{...e,id:`boundary:${rk("sha256").update(s).digest("hex").slice(0,16)}`,extractor:"builtin.database-queue",action:r,keyParts:[{name:"address",value:i,evidence:"identifier",term:{kind:"symbol",symbol:n},derivation:{kind:"mechanically-derived",rule:"database-work-queue.resource",ruleVersion:"1",inputFactIds:[e.id,t.id],sourceSpans:[e.source,t.source]}}],evidence:o,strength:"derived",protocol:"queue",role:r==="queue.send"?"producer":"consumer",derivation:{kind:"mechanically-derived",rule:"database-work-queue.insert-skip-locked",ruleVersion:"1",inputFactIds:[e.id,t.id],sourceSpans:[e.source,t.source]},valuePrecision:"symbolic",resolution:"unresolved"}}var fl="runtime-boundaries-v15",ns=[{id:"http.method-path",protocol:"http",producerActions:["http.request"],consumerActions:["http.handle"],keyNames:["method","path"],traversable:!0},{id:"registry.identity-key",protocol:"registry",producerActions:["registry.dispatch"],consumerActions:["registry.handle"],keyNames:["registry","key"],traversable:!0},{id:"registry.capability-key",protocol:"registry",producerActions:["registry.reference"],consumerActions:["registry.handle"],keyNames:["key"],traversable:!0,requireUniqueConsumer:!0},{id:"queue.address",protocol:"queue",producerActions:["queue.send"],consumerActions:["queue.consume"],keyNames:["address"],traversable:!0},{id:"carrier.discriminator",protocol:"carrier",producerActions:["carrier.publish"],consumerActions:["carrier.consume"],keyNames:["carrier","field","value"],traversable:!0},{id:"resource.identity",protocol:"database",producerActions:["database.write"],consumerActions:["database.read"],keyNames:["resource"],traversable:!1},{id:"framework.effect-httpapi-operation",protocol:"framework",producerActions:[],consumerActions:["framework.handle"],declarationActions:["framework.declare"],keyNames:["adapter","group","operation"],traversable:!0,linkFrom:"declaration",requireUniquePair:!0}],ik=64;function ok(e,t={}){let n=ye(e),r=new Set(n),i=new Set((t.affectedFiles??[]).map(uk)),o=t.previousGraph?.fileCoverage,s=i.size>0&&t.previousGraph?.extractorVersion===fl&&o!==void 0&&o.length===t.previousGraph.coverage.filesScanned,a=s?o.filter(q=>r.has(q.file)&&!i.has(q.file)):[],c=new Set(a.flatMap(q=>q.observationIds)),l=s?t.previousGraph.observations.filter(q=>c.has(q.id)&&r.has(q.source.file)):[],u=s?n.filter(q=>i.has(q)):n,d=[],p=o?.reduce((q,as)=>q+as.observationIds.length,0)??0,f=performance.now(),m=sk(e,u,t.profileSpan);vn(d,"direct-extraction",f,u.length,m.observations.length,{filesVisited:u.length,filesReused:a.length,factsReused:l.length,factsInvalidated:Math.max(0,p-l.length)});let g=[...a,...m.fileCoverage].sort((q,as)=>q.file.localeCompare(as.file)),y=lk(g),I=g.flatMap(q=>q.extractionErrors),h=ui([...l,...m.observations]),P=ui([...h,...zg(h)]);f=performance.now();let w=Gg(e,P);vn(d,"http-summary",f,P.length,w.observations.length,{filesVisited:w.filesInspected}),y.set("builtin.wrapper",{id:"builtin.wrapper",applicableFiles:w.filesInspected,observations:w.observations.length,errors:w.errors.length}),I.push(...w.errors);let T=ui([...P,...w.observations]);f=performance.now();let b=Mg(e,T);vn(d,"http-mount",f,T.length,b.observations.length,{filesVisited:b.filesInspected});let v=ui([...T,...b.observations]);f=performance.now();let E=kg(e,v);vn(d,"carrier",f,v.length,E.observations.length,{filesVisited:E.filesInspected}),y.set("builtin.carrier",{id:"builtin.carrier",applicableFiles:E.bodySummaries,observations:E.observations.length,errors:E.errors.length}),I.push(...E.errors);let O=ui([...v,...E.observations]);f=performance.now();let B=dk(O);vn(d,"relations",f,O.length,B.length),f=performance.now();let ml=fk(O,B);vn(d,"links",f,B.length,ml.length),mk(O,B),f=performance.now();let gl=Qo([...gk(O,B),...w.frontiers]);return vn(d,"frontiers",f,O.length,gl.length),{schemaVersion:2,extractorVersion:fl,observations:O,relationGroups:B,links:ml,frontiers:gl,coverage:{filesScanned:n.length,filesWithAst:g.filter(q=>q.hasAst).length,filesWithoutAst:g.filter(q=>!q.hasAst).length,...s?{filesReused:a.length}:{},extractors:[...y.values()],extractionErrors:I,phases:d},fileCoverage:g}}function vn(e,t,n,r,i,o={}){e.push({id:t,durationMs:Math.max(0,performance.now()-n),inputFacts:r,outputFacts:i,...o})}function sk(e,t,n){let r=[],i=[];for(let o of t){let s=R(e,o),a=ol.filter(u=>u.supports(s)),c=a.length>0?se(e,o,s,n):null,l={file:o,hasAst:c!==null||ck(o,s),observationIds:[],extractors:[],extractionErrors:[]};if(c)for(let u of a){let d={id:u.id,applicableFiles:1,observations:0,errors:0};try{let p=ak(n,`runtime-boundaries.extractor.${u.id}`,o,()=>u.extract(c));d.observations=p.length,r.push(...p),l.observationIds.push(...p.map(f=>f.id))}catch(p){d.errors=1,l.extractionErrors.push(`${u.id} failed for ${o}: ${p instanceof Error?p.message:String(p)}`)}l.extractors.push(d)}i.push(l)}return{observations:r,fileCoverage:i}}function ak(e,t,n,r){return e?e(t,r,{file:n}):r()}function ck(e,t){return t?Ye(e)?/<script\b/iu.test(t):ne(e)!==null:!1}function lk(e){let t=new Map(ol.map(n=>[n.id,{id:n.id,applicableFiles:0,observations:0,errors:0}]));for(let n of e)for(let r of n.extractors){let i=t.get(r.id);i&&(i.applicableFiles+=r.applicableFiles,i.observations+=r.observations,i.errors+=r.errors)}return t}function uk(e){return e.replaceAll("\\","/").replace(/^\.\//u,"")}function dk(e){let t=new Map;for(let n of ns){let r=new Set([...n.producerActions,...n.consumerActions,...n.declarationActions??[]]);for(let i of e){if(!r.has(i.action)||i.strength==="candidate")continue;let o=hk(i,n.keyNames);if(!o)continue;let s=o.map(d=>`${d.name}=${Kg(d.name,d.value)}`).join("\0"),a=i.sourceScope==="production"?"production":i.sourceScope,c=`${n.id}\0${a}\0${s}`,l=`boundary-group:${Ug("sha256").update(c).digest("hex").slice(0,16)}`,u=t.get(l)??{id:l,protocol:n.protocol,joinRule:n.id,normalizedKey:s,keyParts:o,producerIds:[],consumerIds:[],declarationIds:[],derivation:{kind:"mechanically-derived",rule:n.id,ruleVersion:"2",inputFactIds:[],sourceSpans:[]}};n.producerActions.includes(i.action)&&u.producerIds.push(i.id),n.consumerActions.includes(i.action)&&u.consumerIds.push(i.id),n.declarationActions?.includes(i.action)&&u.declarationIds.push(i.id),u.derivation.inputFactIds.push(i.id),u.derivation.sourceSpans.push(i.source),t.set(l,u)}}return[...t.values()].map(pk).sort(bk)}function pk(e){return{...e,producerIds:es(e.producerIds),consumerIds:es(e.consumerIds),declarationIds:es(e.declarationIds),derivation:{...e.derivation,inputFactIds:es(e.derivation.inputFactIds),sourceSpans:[...new Map(e.derivation.sourceSpans.map(t=>[`${t.file}:${t.startLine}:${t.endLine}`,t])).values()]}}}function fk(e,t){let n=new Map(e.map(i=>[i.id,i])),r=new Map;for(let i of t){let o=ns.find(a=>a.id===i.joinRule);if(!o?.traversable)continue;let s=o.linkFrom==="declaration"?i.declarationIds:i.producerIds;if(!(s.length===0||i.consumerIds.length===0)&&!(o.requireUniquePair&&(s.length!==1||i.consumerIds.length!==1))&&!(o.requireUniqueConsumer&&i.consumerIds.length!==1)&&!(s.length*i.consumerIds.length>ik))for(let a of s)for(let c of i.consumerIds){let l=n.get(a),u=n.get(c);if(!l||!u||Sk(l,u))continue;let d=l.strength==="derived"||u.strength==="derived"?"derived":"exact",p=`${i.joinRule}\0${a}\0${c}`,f={id:`boundary-link:${Ug("sha256").update(p).digest("hex").slice(0,16)}`,from:a,to:c,joinRule:i.joinRule,matchedKeyParts:i.keyParts,strength:d,derivation:{kind:"mechanically-derived",rule:i.joinRule,ruleVersion:"2",inputFactIds:[a,c],sourceSpans:[l.source,u.source]}};r.set(f.id,f)}}return[...r.values()].sort(xk)}function mk(e,t){let n=new Set(t.filter(Hg).flatMap(ts)),r=new Set(t.filter(yk).flatMap(ts));for(let i of e)i.resolution=n.has(i.id)?"locally-linked":r.has(i.id)?"ambiguous":"unresolved"}function gk(e,t){let n=new Set(e.filter(o=>o.strength!=="candidate").map(o=>`${o.action}\0${o.source.file}\0${o.source.startLine}\0${o.source.endLine}`)),r=new Set(t.flatMap(ts)),i=new Set(t.filter(Hg).flatMap(ts));return e.filter(o=>o.sourceScope==="production").filter(o=>o.strength!=="candidate"||!n.has(`${o.action}\0${o.source.file}\0${o.source.startLine}\0${o.source.endLine}`)).filter(o=>!i.has(o.id)).map(o=>{let s=o.keyParts.filter(c=>c.evidence==="expression"||c.value.length===0).map(c=>c.name),a=s.length>0?`${o.extractor} observed ${o.action}, but ${s.join(", ")} remained symbolic or unknown.`:o.resolution==="ambiguous"?`${o.extractor} established the address for ${o.action}, but more than one indexed peer has the same runtime key.`:r.has(o.id)?`${o.extractor} established the address for ${o.action}, but the indexed production scope contains no counterpart role in that relation group.`:`${o.extractor} observed ${o.action}, but no supported factorization rule could establish its addressed relation.`;return{observationId:o.id,reason:a,missingKeyParts:s,sourceScope:o.sourceScope}}).sort((o,s)=>o.observationId.localeCompare(s.observationId))}function ts(e){return[...e.producerIds,...e.consumerIds,...e.declarationIds]}function Hg(e){let t=ns.find(r=>r.id===e.joinRule);if(!t)return!1;let n=t.linkFrom==="declaration"?e.declarationIds:e.producerIds;return n.length===0||e.consumerIds.length===0?!1:!t.requireUniquePair||n.length===1&&e.consumerIds.length===1}function yk(e){let t=ns.find(r=>r.id===e.joinRule);if(!t?.requireUniquePair)return!1;let n=t.linkFrom==="declaration"?e.declarationIds:e.producerIds;return n.length>0&&e.consumerIds.length>0&&(n.length!==1||e.consumerIds.length!==1)}function hk(e,t){let n=[];for(let r of t){let i=e.keyParts.find(o=>o.name===r);if(!i||i.evidence==="expression"||i.value.length===0)return null;n.push({...i,value:Kg(r,i.value)})}return n}function Kg(e,t){if(e==="method")return t.toUpperCase();if(e!=="path")return t;let n=t.startsWith("/")?t:`/${t}`;return n.length>1?n.replace(/\/+$/u,""):n}function Sk(e,t){return e.source.file===t.source.file&&e.source.startLine===t.source.startLine}function ui(e){return[...new Map(e.map(t=>[t.id,t])).values()].sort((t,n)=>t.source.file.localeCompare(n.source.file)||t.source.startLine-n.source.startLine||t.action.localeCompare(n.action))}function es(e){return[...new Set(e)].sort()}function bk(e,t){return e.joinRule.localeCompare(t.joinRule)||e.normalizedKey.localeCompare(t.normalizedKey)}function xk(e,t){return e.joinRule.localeCompare(t.joinRule)||e.from.localeCompare(t.from)||e.to.localeCompare(t.to)}import vk from"better-sqlite3";var is="scip_query_runtime_boundaries",In="scip_query_runtime_observations",os="scip_query_runtime_relation_groups",ss="scip_query_runtime_relation_participants";function Ik(e,t){let n=new vk(e);try{n.exec(`
391
- CREATE TABLE IF NOT EXISTS ${is} (
392
- singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
393
- schema_version INTEGER NOT NULL,
394
- extractor_version TEXT NOT NULL,
395
- payload TEXT NOT NULL
396
- )
397
- `),Pk(n),n.transaction(()=>{n.prepare(`INSERT OR REPLACE INTO ${is} (singleton, schema_version, extractor_version, payload) VALUES (1, ?, ?, ?)`).run(t.schemaVersion,t.extractorVersion,JSON.stringify(t)),n.prepare(`DELETE FROM ${In}`).run(),n.prepare(`DELETE FROM ${ss}`).run(),n.prepare(`DELETE FROM ${os}`).run();let r=n.prepare(`INSERT INTO ${In}
398
- (id, protocol, action, role, strength, source_scope, resolution, file, start_line, end_line, owner_symbol, payload)
399
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);for(let s of t.observations)r.run(s.id,s.protocol,s.action,s.role,s.strength,s.sourceScope,s.resolution,s.source.file,s.source.startLine,s.source.endLine,s.owner.symbol,JSON.stringify(s));let i=n.prepare(`INSERT INTO ${os} (id, protocol, join_rule, normalized_key, payload) VALUES (?, ?, ?, ?, ?)`),o=n.prepare(`INSERT INTO ${ss} (group_id, observation_id, participant_role) VALUES (?, ?, ?)`);for(let s of t.relationGroups){i.run(s.id,s.protocol,s.joinRule,s.normalizedKey,JSON.stringify(s));for(let a of s.producerIds)o.run(s.id,a,"producer");for(let a of s.consumerIds)o.run(s.id,a,"consumer");for(let a of s.declarationIds)o.run(s.id,a,"declaration")}})()}finally{n.close()}}function Ek(e,t={}){if(!Rk(e,In))return Jg(e)?.observations??[];let n=[],r=[];return rs(n,r,"protocol",t.protocols),rs(n,r,"action",t.actions),rs(n,r,"source_scope",t.sourceScopes),rs(n,r,"file",t.files),e.all(`SELECT payload FROM ${In}${n.length>0?` WHERE ${n.join(" AND ")}`:""} ORDER BY file, start_line, id`,...r).flatMap(o=>wk(o.payload))}function Pk(e){e.exec(`
400
- CREATE TABLE IF NOT EXISTS ${In} (
401
- id TEXT PRIMARY KEY,
402
- protocol TEXT NOT NULL,
403
- action TEXT NOT NULL,
404
- role TEXT NOT NULL,
405
- strength TEXT NOT NULL,
406
- source_scope TEXT NOT NULL,
407
- resolution TEXT NOT NULL,
408
- file TEXT NOT NULL,
409
- start_line INTEGER NOT NULL,
410
- end_line INTEGER NOT NULL,
411
- owner_symbol TEXT,
412
- payload TEXT NOT NULL
413
- );
414
- CREATE INDEX IF NOT EXISTS idx_runtime_observations_protocol_action_scope
415
- ON ${In}(protocol, action, source_scope);
416
- CREATE INDEX IF NOT EXISTS idx_runtime_observations_file_line
417
- ON ${In}(file, start_line);
418
-
419
- CREATE TABLE IF NOT EXISTS ${os} (
420
- id TEXT PRIMARY KEY,
421
- protocol TEXT NOT NULL,
422
- join_rule TEXT NOT NULL,
423
- normalized_key TEXT NOT NULL,
424
- payload TEXT NOT NULL
425
- );
426
- CREATE INDEX IF NOT EXISTS idx_runtime_groups_protocol_key
427
- ON ${os}(protocol, join_rule, normalized_key);
428
-
429
- CREATE TABLE IF NOT EXISTS ${ss} (
430
- group_id TEXT NOT NULL,
431
- observation_id TEXT NOT NULL,
432
- participant_role TEXT NOT NULL,
433
- PRIMARY KEY (group_id, observation_id, participant_role)
434
- );
435
- CREATE INDEX IF NOT EXISTS idx_runtime_participants_observation
436
- ON ${ss}(observation_id, participant_role);
437
- `)}function Rk(e,t){return!!e.get("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",t)}function rs(e,t,n,r){!r||r.length===0||(e.push(`${n} IN (${r.map(()=>"?").join(", ")})`),t.push(...r))}function wk(e){try{return[JSON.parse(e)]}catch{return[]}}function Jg(e){if(!e.get("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",is))return null;let n=e.get(`SELECT schema_version, payload FROM ${is} WHERE singleton = 1`);if(!n||n.schema_version!==2)return null;try{let r=JSON.parse(n.payload);return r.schemaVersion===2&&Array.isArray(r.observations)&&Array.isArray(r.relationGroups)&&Array.isArray(r.links)?r:null}catch{return null}}export{Et as a,xl as b,vl as c,Ck as d,Qg as e,Pt as f,pi as g,x as h,Nk as i,Tk as j,kk as k,Cl as l,fi as m,Lk as n,Wt as o,Rt as p,Bk as q,Fl as r,ty as s,$k as t,En as u,Vk as v,C as w,He as x,wt as y,K as z,Ke as A,Ct as B,Qk as C,Zk as D,e_ as E,t_ as F,n_ as G,xe as H,nu as I,$ as J,Nt as K,Y as L,Ht as M,Fe as N,ve as O,Q as P,Kt as Q,pe as R,$y as S,Je as T,J as U,j as V,F as W,Gy as X,Vy as Y,Jt as Z,ed as _,sb as $,Dn as aa,Xe as ba,kt as ca,ke as da,Ft as ea,Ul as fa,Hl as ga,Kl as ha,Ny as ia,l_ as ja,ae as ka,u_ as la,gi as ma,$e as na,cu as oa,Ie as pa,p_ as qa,f_ as ra,Ge as sa,B_ as ta,ur as ua,Qy as va,Zy as wa,$_ as xa,G_ as ya,rh as za,ch as Aa,fu as Ba,V_ as Ca,Ii as Da,me as Ea,xu as Fa,Z_ as Ga,at as Ha,Fn as Ia,ge as Ja,L as Ka,X as La,bi as Ma,ks as Na,Fi as Oa,Ni as Pa,_s as Qa,gL as Ra,Ns as Sa,yL as Ta,hL as Ua,Ds as Va,rn as Wa,bS as Xa,kn as Ya,Li as Za,xS as _a,Hu as $a,Ws as ab,_n as bb,RS as cb,wS as db,CS as eb,Di as fb,ML as gb,hr as hb,R as ib,GL as jb,Sr as kb,jS as lb,VL as mb,qL as nb,te as ob,ra as pb,hD as qb,SD as rb,ia as sb,ne as tb,Ye as ub,re as vb,_e as wb,dd as xb,RD as yb,wD as zb,D as Ab,WD as Bb,le as Cb,Vx as Db,qx as Eb,Fr as Fb,Hx as Gb,Kx as Hb,XL as Ib,Zu as Jb,ye as Kb,YL as Lb,ZA as Mb,gI as Nb,ro as Ob,NM as Pb,Ot as Qb,U as Rb,jM as Sb,BM as Tb,HM as Ub,Wn as Vb,KM as Wb,JM as Xb,so as Yb,We as Zb,ue as _b,Mt as $b,de as ac,fn as bc,La as cc,zn as dc,Pp as ec,YM as fc,QM as gc,ZM as hc,ej as ic,Da as jc,Aa as kc,Pj as lc,A as mc,Rj as nc,gP as oc,wj as pc,Cj as qc,Fj as rc,xP as sc,Un as tc,Nj as uc,Y1 as vc,Qm as wc,uo as xc,Ga as yc,nB as zc,jj as Ac,MP as Bc,Bj as Cc,$j as Dc,EB as Ec,PB as Fc,RB as Gc,Up as Hc,Jj as Ic,Xj as Jc,$a as Kc,Va as Lc,Vp as Mc,Wp as Nc,qa as Oc,xB as Pc,pR as Qc,fR as Rc,vB as Sc,mR as Tc,gR as Uc,_B as Vc,Wa as Wc,MB as Xc,Xp as Yc,jB as Zc,Yp as _c,JB as $c,_R as ad,Ua as bd,XB as cd,AR as dd,OR as ed,YB as fd,QB as gd,ZB as hd,gn as id,yt as jd,je as kd,ht as ld,yn as md,Zm as nd,Z1 as od,Ja as pd,Xa as qd,Jn as rd,Ze as sd,hN as td,uV as ud,dV as vd,ag as wd,pV as xd,Wm as yd,F0 as zd,N0 as Ad,sw as Bd,T0 as Cd,k0 as Dd,ee as Ed,Zw as Fd,Eo as Gd,iC as Hd,d$ as Id,p$ as Jd,E$ as Kd,yo as Ld,mf as Md,ho as Nd,So as Od,Xn as Pd,Nw as Qd,bf as Rd,St as Sd,U0 as Td,i$ as Ud,Ro as Vd,lc as Wd,L$ as Xd,D$ as Yd,A$ as Zd,Ho as _d,bn as $d,Ue as ae,si as be,ai as ce,fl as de,ok as ee,Ik as fe,Ek as ge,Jg as he,Af as ie,z$ as je,_o as ke,tG as le,gG as me,yG as ne,RG as oe,wG as pe,CG as qe,DG as re,VG as se,qG as te,fm as ue,EF as ve,t1 as we,n1 as xe,kc as ye,Go as ze,L1 as Ae,_m as Be,D1 as Ce,It as De,zF as Ee,Lm as Fe,Bo as Ge,A1 as He,O1 as Ie,M1 as Je,jc as Ke,HF as Le,qo as Me,H1 as Ne,Zr as Oe,K1 as Pe};
438
- //# sourceMappingURL=chunk-OIVZ7PW6.js.map