scip-query 0.23.0 → 0.26.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 (650) hide show
  1. package/CHANGELOG.md +491 -2
  2. package/README.md +111 -122
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/by-kind-PRVFAGTQ.js +2 -0
  5. package/dist/call-graph-DVPAQV2F.js +2 -0
  6. package/dist/call-graph-evidence-CUtj8V2I.d.ts +19 -0
  7. package/dist/chunk-2FSBGL5P.js +2 -0
  8. package/dist/chunk-2HLAFUCY.js +2 -0
  9. package/dist/chunk-2IWUT6CJ.js +3 -0
  10. package/dist/chunk-2KNN7GTQ.js +2 -0
  11. package/dist/chunk-2LHXRE2B.js +8 -0
  12. package/dist/{chunk-EG2CPZMJ.js → chunk-2YXE77TJ.js} +2 -2
  13. package/dist/chunk-36SGVCGX.js +2 -0
  14. package/dist/chunk-3ABBFPTP.js +2 -0
  15. package/dist/chunk-3IVFU4FD.js +3 -0
  16. package/dist/chunk-3JIQS44J.js +7 -0
  17. package/dist/chunk-3ZRB6DNK.js +7 -0
  18. package/dist/{chunk-6YTSKJJ3.js → chunk-42EOW5VI.js} +1 -1
  19. package/dist/{chunk-6I6L7Z62.js → chunk-4BHGBMNO.js} +2 -2
  20. package/dist/chunk-4BP3UBDG.js +2 -0
  21. package/dist/chunk-4D6RO7G4.js +2 -0
  22. package/dist/chunk-4FEWQ6RH.js +2 -0
  23. package/dist/chunk-4IGEOBG7.js +2 -0
  24. package/dist/chunk-4QZXBUKC.js +2 -0
  25. package/dist/chunk-4WBDEVX2.js +4 -0
  26. package/dist/chunk-4WCUBZU3.js +8 -0
  27. package/dist/chunk-4WTUBQ36.js +40 -0
  28. package/dist/chunk-4XQ4O6IM.js +3 -0
  29. package/dist/chunk-55UQAMZO.js +4 -0
  30. package/dist/chunk-5D2LVK7O.js +125 -0
  31. package/dist/chunk-5IYJ56TT.js +2 -0
  32. package/dist/chunk-5PLMJC7Q.js +2 -0
  33. package/dist/chunk-5TNQJUR2.js +5 -0
  34. package/dist/chunk-62BDNPMI.js +2 -0
  35. package/dist/chunk-64DZ5TXR.js +7 -0
  36. package/dist/chunk-65245JCM.js +2 -0
  37. package/dist/chunk-6FFVZZL4.js +2 -0
  38. package/dist/chunk-6KO5JHAR.js +2 -0
  39. package/dist/chunk-6LRXOOSX.js +2 -0
  40. package/dist/chunk-6LSEIIF7.js +2 -0
  41. package/dist/chunk-6YMNWD3H.js +6 -0
  42. package/dist/chunk-72AD6ZRR.js +5 -0
  43. package/dist/chunk-73AAKPUC.js +4 -0
  44. package/dist/chunk-76CZ77DF.js +2 -0
  45. package/dist/chunk-7VPEEAAG.js +2 -0
  46. package/dist/chunk-7WTPQ4NX.js +14 -0
  47. package/dist/chunk-7Y5T6XDP.js +2 -0
  48. package/dist/chunk-A2IIGFMJ.js +5 -0
  49. package/dist/chunk-AB5KCTEV.js +2 -0
  50. package/dist/chunk-AC566WBP.js +6 -0
  51. package/dist/chunk-AGWFSTXC.js +3 -0
  52. package/dist/chunk-AOSIYPTA.js +2 -0
  53. package/dist/chunk-AUVEWPIF.js +2 -0
  54. package/dist/chunk-B56T42J3.js +25 -0
  55. package/dist/chunk-BIQEF5NE.js +2 -0
  56. package/dist/chunk-BL6XJKTA.js +3 -0
  57. package/dist/chunk-BMKOQJRI.js +2 -0
  58. package/dist/chunk-BOZ4EXBB.js +3 -0
  59. package/dist/chunk-BUTWYEPH.js +2 -0
  60. package/dist/chunk-BZB4QPIP.js +2 -0
  61. package/dist/{chunk-ILTDAWEF.js → chunk-CE357GEE.js} +4 -4
  62. package/dist/chunk-CFN45HFP.js +2 -0
  63. package/dist/chunk-CFYMZFXT.js +368 -0
  64. package/dist/chunk-CN5EH7O3.js +2 -0
  65. package/dist/chunk-D254DNNQ.js +4 -0
  66. package/dist/chunk-D3FDISIC.js +2 -0
  67. package/dist/chunk-D3NX5XIE.js +3 -0
  68. package/dist/chunk-DA7RPPDF.js +3 -0
  69. package/dist/chunk-DDMC3FON.js +3 -0
  70. package/dist/chunk-DIO3FUSG.js +2 -0
  71. package/dist/chunk-DJ2NNSUK.js +3 -0
  72. package/dist/chunk-DKYQIM3C.js +18 -0
  73. package/dist/{chunk-JTQVMR42.js → chunk-DOOEL2IV.js} +2 -2
  74. package/dist/chunk-DVFP6PZI.js +2 -0
  75. package/dist/chunk-E3FDPXZK.js +2 -0
  76. package/dist/chunk-E7YNJLCB.js +2 -0
  77. package/dist/chunk-EFGW5JPH.js +2 -0
  78. package/dist/chunk-EJVTR244.js +13 -0
  79. package/dist/chunk-EOV7RTRZ.js +2 -0
  80. package/dist/chunk-ETOIKRHO.js +2 -0
  81. package/dist/chunk-EYK3ZAO2.js +3 -0
  82. package/dist/chunk-F2V2LPET.js +52 -0
  83. package/dist/chunk-F4LUHJTF.js +2 -0
  84. package/dist/chunk-F4PUT6IT.js +2 -0
  85. package/dist/chunk-F56GCXXS.js +5 -0
  86. package/dist/chunk-FC2EVQRM.js +2 -0
  87. package/dist/chunk-FL7NBMHP.js +3 -0
  88. package/dist/chunk-FMRN2TRL.js +3 -0
  89. package/dist/chunk-FVULPZDF.js +20 -0
  90. package/dist/chunk-GCKCF5FL.js +43 -0
  91. package/dist/chunk-GH2PYF46.js +2 -0
  92. package/dist/chunk-GHJAGXIP.js +2 -0
  93. package/dist/{chunk-WIWY3CRX.js → chunk-GMVSHUKZ.js} +2 -2
  94. package/dist/chunk-GS6KDO4R.js +2 -0
  95. package/dist/chunk-GUUBXNN7.js +2 -0
  96. package/dist/chunk-GVWX5T43.js +80 -0
  97. package/dist/chunk-GZKFETP5.js +2 -0
  98. package/dist/chunk-H4EQHO6J.js +9 -0
  99. package/dist/chunk-H73WY2RM.js +2 -0
  100. package/dist/chunk-H75GSPRV.js +60 -0
  101. package/dist/chunk-HDR3AHSV.js +61 -0
  102. package/dist/chunk-HQBSL74Y.js +2 -0
  103. package/dist/chunk-HRRFKWPZ.js +2 -0
  104. package/dist/chunk-HXENDJC6.js +2 -0
  105. package/dist/chunk-IIBAZNSW.js +21 -0
  106. package/dist/chunk-INLMWEUU.js +12 -0
  107. package/dist/chunk-IWQPAF4F.js +2 -0
  108. package/dist/chunk-IZJ6YUKP.js +35 -0
  109. package/dist/chunk-J2TMAIN5.js +60 -0
  110. package/dist/chunk-J5FJMODQ.js +142 -0
  111. package/dist/chunk-J7HZPIO3.js +2 -0
  112. package/dist/chunk-JEVRKFRL.js +2 -0
  113. package/dist/chunk-JFXSGAEB.js +30 -0
  114. package/dist/chunk-JVRTHGFS.js +3 -0
  115. package/dist/chunk-JYWEX7RR.js +360 -0
  116. package/dist/chunk-K3YL22N6.js +2 -0
  117. package/dist/chunk-K4CN7GXK.js +12 -0
  118. package/dist/chunk-K5TBVXU4.js +30 -0
  119. package/dist/chunk-KDDIE2DP.js +9 -0
  120. package/dist/chunk-KHWRRPV4.js +2 -0
  121. package/dist/chunk-KI6NBKDY.js +14 -0
  122. package/dist/chunk-KU3QRSTH.js +2 -0
  123. package/dist/chunk-KZBJWZJB.js +2 -0
  124. package/dist/chunk-L7GFM3NP.js +3 -0
  125. package/dist/chunk-LMO6PK3V.js +35 -0
  126. package/dist/chunk-LN4YXJJU.js +2 -0
  127. package/dist/chunk-LOVIZBJ4.js +43 -0
  128. package/dist/chunk-LPCRK4A2.js +11 -0
  129. package/dist/chunk-MMHZKBFA.js +2 -0
  130. package/dist/{chunk-M2O5NY6W.js → chunk-MOQQBQRD.js} +2 -2
  131. package/dist/chunk-N2WN6I3L.js +2 -0
  132. package/dist/chunk-N3ORQT7L.js +2 -0
  133. package/dist/chunk-NAZ3RAIW.js +2 -0
  134. package/dist/chunk-NDUNO5JQ.js +2 -0
  135. package/dist/chunk-NEIWRNAZ.js +4 -0
  136. package/dist/chunk-NJJMVD65.js +2 -0
  137. package/dist/chunk-NLOQOBXI.js +20 -0
  138. package/dist/chunk-NOLZOVCU.js +2 -0
  139. package/dist/chunk-NOWINRRN.js +2 -0
  140. package/dist/chunk-NZAXKGRL.js +16 -0
  141. package/dist/chunk-O2C4UILI.js +2 -0
  142. package/dist/chunk-O3RHA6ZT.js +3 -0
  143. package/dist/chunk-O4UZSPPI.js +3 -0
  144. package/dist/chunk-OGFV2BUX.js +2 -0
  145. package/dist/chunk-OZCJXZK6.js +499 -0
  146. package/dist/chunk-P6ODM7BY.js +2 -0
  147. package/dist/{chunk-XBGWL66K.js → chunk-PAVGPRHJ.js} +2 -2
  148. package/dist/chunk-PH52RA7D.js +2 -0
  149. package/dist/chunk-PKN354TH.js +3 -0
  150. package/dist/chunk-PWOASWEG.js +11 -0
  151. package/dist/chunk-QIWXRW72.js +2 -0
  152. package/dist/chunk-QJRMOK5N.js +2 -0
  153. package/dist/{chunk-YXPUP5G2.js → chunk-QOIXNWQR.js} +2 -2
  154. package/dist/chunk-QXEUDXBT.js +3 -0
  155. package/dist/chunk-QYUVVBMR.js +6 -0
  156. package/dist/chunk-QZ7KQZRN.js +2 -0
  157. package/dist/chunk-R6LQBUDH.js +2 -0
  158. package/dist/chunk-RBS42E55.js +20 -0
  159. package/dist/chunk-RSJKPCFX.js +26 -0
  160. package/dist/chunk-S6CZA3MV.js +2 -0
  161. package/dist/chunk-STMVAHJP.js +2 -0
  162. package/dist/chunk-SYVPTTVW.js +2 -0
  163. package/dist/chunk-T3I6NHBH.js +2 -0
  164. package/dist/chunk-T6DK3ZP7.js +2 -0
  165. package/dist/chunk-TKD34PHN.js +4 -0
  166. package/dist/chunk-TNNQFH7W.js +2 -0
  167. package/dist/chunk-TNV7SSUF.js +2 -0
  168. package/dist/chunk-TO7ZR3EH.js +8 -0
  169. package/dist/chunk-TOU3CHK4.js +2 -0
  170. package/dist/chunk-TRBI4UKT.js +2 -0
  171. package/dist/chunk-TZCVNCAN.js +4 -0
  172. package/dist/chunk-U4LZA5LL.js +3 -0
  173. package/dist/chunk-U5RIG3JP.js +3 -0
  174. package/dist/chunk-UP5KXN2I.js +2 -0
  175. package/dist/chunk-UQFR3NDH.js +5 -0
  176. package/dist/chunk-UXYXF7GV.js +2 -0
  177. package/dist/chunk-VB3GOKOS.js +2 -0
  178. package/dist/chunk-VF5JZICY.js +2 -0
  179. package/dist/chunk-VTY3VK6E.js +2 -0
  180. package/dist/chunk-VX2O4RIS.js +2 -0
  181. package/dist/chunk-WKPV2TDZ.js +2 -0
  182. package/dist/chunk-WOFQ5DTB.js +2 -0
  183. package/dist/chunk-WS4C6TCK.js +2 -0
  184. package/dist/chunk-WXU3DGPU.js +2 -0
  185. package/dist/chunk-X6RMKHJQ.js +81 -0
  186. package/dist/{chunk-4ILJCCXV.js → chunk-XHMN6ZX7.js} +2 -2
  187. package/dist/chunk-XHTVFLWW.js +2 -0
  188. package/dist/chunk-XKIDJCIK.js +2 -0
  189. package/dist/chunk-XTYTYZPT.js +2 -0
  190. package/dist/chunk-Y2JHHTTA.js +2 -0
  191. package/dist/chunk-YGVRMGYN.js +4 -0
  192. package/dist/chunk-YNQCGEQE.js +2 -0
  193. package/dist/chunk-YOQVEXVE.js +14 -0
  194. package/dist/chunk-YRT2WLYY.js +2 -0
  195. package/dist/chunk-YTAP5Y2G.js +2 -0
  196. package/dist/chunk-YTYWI7VB.js +2 -0
  197. package/dist/chunk-YULZRALL.js +2 -0
  198. package/dist/chunk-Z33WQG4Q.js +2 -0
  199. package/dist/chunk-ZGTYGDMF.js +16 -0
  200. package/dist/chunk-ZHMRSZFD.js +43 -0
  201. package/dist/chunk-ZHSP366W.js +10 -0
  202. package/dist/chunk-ZIBYCYKK.js +7 -0
  203. package/dist/{chunk-GAS2LJMP.js → chunk-ZLADLUE6.js} +3 -3
  204. package/dist/chunk-ZO4YXUT6.js +4 -0
  205. package/dist/{chunk-HYO3NP5Q.js → chunk-ZR4HBC2H.js} +2 -2
  206. package/dist/cli-main.js +6 -6
  207. package/dist/cli.js +1 -1
  208. package/dist/{code-B17qEMbt.d.ts → code-BNyrCF3_.d.ts} +3 -2
  209. package/dist/code-IL5WH3NZ.js +2 -0
  210. package/dist/code-result-json-ANTBEDFP.js +4 -0
  211. package/dist/command-descriptors-HEEMDHTU.js +222 -0
  212. package/dist/deps-EOWFC6FD.js +2 -0
  213. package/dist/direct-navigation-Y5B6OSIQ.js +3 -0
  214. package/dist/{exploration-topology-BG4v30HZ.d.ts → exploration-topology-CSgEyAz-.d.ts} +3 -1
  215. package/dist/files-K4AI3JUM.js +2 -0
  216. package/dist/frontend-profile-roles-D7eCum8P.d.ts +10 -0
  217. package/dist/{health-CPp2Jf1Z.d.ts → health-BtfmNrfa.d.ts} +58 -74
  218. package/dist/hierarchy-6W5NDIFI.js +2 -0
  219. package/dist/imports-WH365QY4.js +2 -0
  220. package/dist/index.d.ts +13 -1
  221. package/dist/index.js +1 -1
  222. package/dist/members-K3PHMF5S.js +2 -0
  223. package/dist/methods-E7KVMBX4.js +2 -0
  224. package/dist/output-continuation-command-BJSY67SN.js +3 -0
  225. package/dist/output-pagination-UZJ5ACIX.js +24 -0
  226. package/dist/postinstall.js +1 -1
  227. package/dist/project-reindex-EP24WT4X.js +3 -0
  228. package/dist/queries/affected.js +1 -1
  229. package/dist/queries/architecture.d.ts +15 -4
  230. package/dist/queries/architecture.js +1 -1
  231. package/dist/queries/bottlenecks.js +1 -1
  232. package/dist/queries/by-kind.js +1 -1
  233. package/dist/queries/call-graph.d.ts +3 -1
  234. package/dist/queries/call-graph.js +1 -1
  235. package/dist/queries/change-surface.d.ts +1 -0
  236. package/dist/queries/change-surface.js +1 -1
  237. package/dist/queries/cleanup-plan.d.ts +3 -3
  238. package/dist/queries/cleanup-plan.js +1 -1
  239. package/dist/queries/co-change.d.ts +20 -2
  240. package/dist/queries/co-change.js +1 -1
  241. package/dist/queries/code.d.ts +1 -1
  242. package/dist/queries/code.js +1 -1
  243. package/dist/queries/complexity.d.ts +6 -3
  244. package/dist/queries/complexity.js +1 -1
  245. package/dist/queries/context.d.ts +1 -7
  246. package/dist/queries/context.js +1 -1
  247. package/dist/queries/coupling.js +1 -1
  248. package/dist/queries/cycles.js +1 -1
  249. package/dist/queries/dead.d.ts +2 -0
  250. package/dist/queries/dead.js +1 -1
  251. package/dist/queries/decorative-checkers.js +1 -1
  252. package/dist/queries/dependence-slice.d.ts +46 -22
  253. package/dist/queries/dependence-slice.js +1 -1
  254. package/dist/queries/dependency-depth.d.ts +1 -7
  255. package/dist/queries/dependency-depth.js +1 -1
  256. package/dist/queries/deps.js +1 -1
  257. package/dist/queries/diff-impact.d.ts +3 -1
  258. package/dist/queries/diff-impact.js +1 -1
  259. package/dist/queries/doc-drift.js +1 -1
  260. package/dist/queries/drift.d.ts +1 -1
  261. package/dist/queries/drift.js +1 -1
  262. package/dist/queries/duplicate-bodies.d.ts +29 -2
  263. package/dist/queries/duplicate-bodies.js +1 -1
  264. package/dist/queries/entry-map.d.ts +2 -4
  265. package/dist/queries/entry-map.js +1 -1
  266. package/dist/queries/evidence.d.ts +121 -61
  267. package/dist/queries/evidence.js +1 -1
  268. package/dist/queries/fan.js +1 -1
  269. package/dist/queries/files.js +1 -1
  270. package/dist/queries/health.d.ts +1 -1
  271. package/dist/queries/health.js +1 -1
  272. package/dist/queries/hierarchy.d.ts +2 -2
  273. package/dist/queries/hierarchy.js +1 -1
  274. package/dist/queries/hotspots.d.ts +1 -1
  275. package/dist/queries/hotspots.js +1 -1
  276. package/dist/queries/imports.d.ts +1 -0
  277. package/dist/queries/imports.js +1 -1
  278. package/dist/queries/incomplete-migration.d.ts +3 -3
  279. package/dist/queries/incomplete-migration.js +1 -1
  280. package/dist/queries/index.d.ts +17 -65
  281. package/dist/queries/index.js +1 -1
  282. package/dist/queries/locality-candidates.d.ts +4 -4
  283. package/dist/queries/locality-candidates.js +1 -1
  284. package/dist/queries/members.d.ts +2 -2
  285. package/dist/queries/members.js +1 -1
  286. package/dist/queries/methods.js +1 -1
  287. package/dist/queries/not-implemented.d.ts +2 -6
  288. package/dist/queries/not-implemented.js +1 -1
  289. package/dist/queries/outline.js +1 -1
  290. package/dist/queries/passthrough-candidates.d.ts +9 -1
  291. package/dist/queries/passthrough-candidates.js +1 -1
  292. package/dist/queries/react-component-duplicates.d.ts +19 -3
  293. package/dist/queries/react-component-duplicates.js +1 -1
  294. package/dist/queries/react-hook-candidates.d.ts +22 -3
  295. package/dist/queries/react-hook-candidates.js +1 -1
  296. package/dist/queries/react-large-component-pressure.d.ts +17 -3
  297. package/dist/queries/react-large-component-pressure.js +1 -1
  298. package/dist/queries/recent-duplicates.js +1 -1
  299. package/dist/queries/redundant-reexports.d.ts +4 -14
  300. package/dist/queries/redundant-reexports.js +1 -1
  301. package/dist/queries/refs.d.ts +4 -1
  302. package/dist/queries/refs.js +1 -1
  303. package/dist/queries/review.d.ts +188 -0
  304. package/dist/queries/review.js +2 -0
  305. package/dist/queries/similar-files.d.ts +7 -10
  306. package/dist/queries/similar-files.js +1 -1
  307. package/dist/queries/similar-signatures.js +1 -1
  308. package/dist/queries/similar.d.ts +19 -1
  309. package/dist/queries/similar.js +1 -1
  310. package/dist/queries/slice-cohesion.d.ts +205 -0
  311. package/dist/queries/slice-cohesion.js +2 -0
  312. package/dist/queries/source-inspection.d.ts +6 -202
  313. package/dist/queries/source-inspection.js +1 -1
  314. package/dist/queries/source-search.d.ts +2 -3
  315. package/dist/queries/source-search.js +1 -1
  316. package/dist/queries/stats.d.ts +1 -0
  317. package/dist/queries/stats.js +1 -1
  318. package/dist/queries/surface.js +1 -1
  319. package/dist/queries/symbols.js +1 -1
  320. package/dist/queries/system.d.ts +4 -2
  321. package/dist/queries/system.js +1 -1
  322. package/dist/queries/test-quality.d.ts +1 -1
  323. package/dist/queries/test-quality.js +1 -1
  324. package/dist/queries/twin-drift.d.ts +23 -7
  325. package/dist/queries/twin-drift.js +1 -1
  326. package/dist/queries/unused-imports.js +1 -1
  327. package/dist/queries/unused-params.d.ts +3 -15
  328. package/dist/queries/unused-params.js +1 -1
  329. package/dist/queries/vue-component-duplicates.js +1 -1
  330. package/dist/queries/vue-composable-candidates.js +1 -1
  331. package/dist/queries/vue-large-view-pressure.js +1 -1
  332. package/dist/query-service-fastpath.js +5 -5
  333. package/dist/query-service-server.js +4 -4
  334. package/dist/refs-CCBJG7WK.js +2 -0
  335. package/dist/refs-pagination-DRNLVU4S.js +2 -0
  336. package/dist/reindex-worker.js +79 -29
  337. package/dist/reindex.js +45 -45
  338. package/dist/repository-cache-worker.js +2 -0
  339. package/dist/runtime.d.ts +8 -8
  340. package/dist/runtime.js +3 -4
  341. package/dist/rust-semantic-session-server.js +1 -1
  342. package/dist/rust-semantic-session-worker.js +1 -1
  343. package/dist/rust-semantic-worker.js +1 -1
  344. package/dist/service-queries-2WAJI7R6.js +6 -0
  345. package/dist/source-inspection-91U9zdO3.d.ts +341 -0
  346. package/dist/{source-search-types-Dwz8KeuW.d.ts → source-search-types-DWGYNg8M.d.ts} +15 -2
  347. package/dist/stats-G7DIV6VU.js +2 -0
  348. package/dist/surface-IO55UALI.js +2 -0
  349. package/dist/system-ZBMSHJXU.js +2 -0
  350. package/dist/{queries/trace.d.ts → trace-BMjw3prn.d.ts} +1 -18
  351. package/dist/typescript-indexer.js +2 -0
  352. package/dist/typescript-mailbox-worker.js +1 -1
  353. package/dist/watch-server.js +3 -3
  354. package/docs/AGENT_GUIDE.md +19 -128
  355. package/docs/CLI_JSON_OUTPUT.md +21 -17
  356. package/docs/COMMAND_REFERENCE.md +34 -49
  357. package/docs/CURRENT_COMMANDS.md +123 -0
  358. package/docs/DETECTOR_EVIDENCE_CONTRACTS.md +0 -40
  359. package/docs/DETECTOR_GUIDE.md +55 -12
  360. package/docs/PRODUCT_VISION.md +135 -0
  361. package/docs/PROPERTY_TESTING.md +73 -0
  362. package/docs/REVIEW.md +76 -0
  363. package/docs/SKILLS.md +51 -0
  364. package/docs/WINDOWS_SIDECAR_RELEASE.md +12 -3
  365. package/docs/accuracy-audit-checklist.md +70 -13
  366. package/docs/analyzer-inventory.md +2 -2
  367. package/docs/locality-analyzer-design.md +9 -9
  368. package/package.json +18 -80
  369. package/scripts/evidence-product-contract.mjs +7 -3
  370. package/scripts/record-review-coverage.mjs +118 -0
  371. package/scripts/scip-windows-provenance.mjs +29 -19
  372. package/skills/scip-architecture-review/SKILL.md +57 -0
  373. package/skills/scip-architecture-review/agents/openai.yaml +4 -0
  374. package/skills/scip-architecture-review/references/design-checks.md +17 -0
  375. package/skills/scip-explore/SKILL.md +15 -59
  376. package/skills/scip-explore/agents/openai.yaml +3 -3
  377. package/skills/scip-explore/references/external-evidence.md +2 -2
  378. package/skills/scip-explore/references/information-model.md +26 -29
  379. package/skills/scip-explore/scripts/capture-evidence.mjs +68 -34
  380. package/skills/scip-integrity-audit/SKILL.md +53 -181
  381. package/skills/scip-integrity-audit/agents/openai.yaml +3 -3
  382. package/skills/scip-integrity-audit/references/integrity-probes.md +27 -0
  383. package/skills/scip-plan/SKILL.md +39 -65
  384. package/skills/scip-plan/agents/openai.yaml +2 -2
  385. package/skills/scip-query/SKILL.md +28 -81
  386. package/skills/scip-query/agents/openai.yaml +2 -2
  387. package/skills/scip-query/references/command-guide.md +169 -0
  388. package/skills/scip-setup/SKILL.md +4 -2
  389. package/skills/scip-setup/agents/openai.yaml +3 -3
  390. package/dist/by-kind-XI2CSWEY.js +0 -2
  391. package/dist/call-graph-UONR6JR5.js +0 -2
  392. package/dist/call-graph-evidence-lZa2dwQA.d.ts +0 -11
  393. package/dist/chunk-26CT72HM.js +0 -2
  394. package/dist/chunk-2E7CX53V.js +0 -2
  395. package/dist/chunk-2GRUZAQF.js +0 -43
  396. package/dist/chunk-2LDBDR6J.js +0 -29
  397. package/dist/chunk-2OOY75BW.js +0 -2
  398. package/dist/chunk-2R3V3PSD.js +0 -4
  399. package/dist/chunk-2WC2OEDO.js +0 -4
  400. package/dist/chunk-35NLDRZC.js +0 -2
  401. package/dist/chunk-3AF4TUFK.js +0 -3
  402. package/dist/chunk-3D3QG236.js +0 -2
  403. package/dist/chunk-3FHOF22C.js +0 -21
  404. package/dist/chunk-3JKSW6LJ.js +0 -2
  405. package/dist/chunk-3L2ZBPEX.js +0 -133
  406. package/dist/chunk-3PJABJSU.js +0 -2
  407. package/dist/chunk-3SVF22I5.js +0 -2
  408. package/dist/chunk-3WR4E3A3.js +0 -3
  409. package/dist/chunk-4FTZ4P5G.js +0 -2
  410. package/dist/chunk-4UX2F3JX.js +0 -2
  411. package/dist/chunk-4WNW27SX.js +0 -2
  412. package/dist/chunk-5ENOG4VP.js +0 -61
  413. package/dist/chunk-64BFSI5I.js +0 -2
  414. package/dist/chunk-66DVSJQG.js +0 -455
  415. package/dist/chunk-6HFCYNYE.js +0 -9
  416. package/dist/chunk-6PQNKL3G.js +0 -3
  417. package/dist/chunk-6V5CNXL6.js +0 -2
  418. package/dist/chunk-6VVV4WRR.js +0 -4
  419. package/dist/chunk-7BWFZPPZ.js +0 -2
  420. package/dist/chunk-7CYG22FH.js +0 -2
  421. package/dist/chunk-7F45LJKI.js +0 -2
  422. package/dist/chunk-7IWV2EG3.js +0 -3
  423. package/dist/chunk-7KCZELVM.js +0 -2
  424. package/dist/chunk-AFHTBORT.js +0 -2
  425. package/dist/chunk-AVRYW5OZ.js +0 -2
  426. package/dist/chunk-B3X6KU75.js +0 -2
  427. package/dist/chunk-B5D7QPBE.js +0 -4
  428. package/dist/chunk-BBCIS4DX.js +0 -16
  429. package/dist/chunk-BDUVI7TO.js +0 -3
  430. package/dist/chunk-BE7ZZTMC.js +0 -2
  431. package/dist/chunk-BHVUJOCQ.js +0 -3
  432. package/dist/chunk-BJT7LSPK.js +0 -3
  433. package/dist/chunk-BKVWUP7Y.js +0 -2
  434. package/dist/chunk-BQGB4HBD.js +0 -2
  435. package/dist/chunk-BRV7PIFF.js +0 -2
  436. package/dist/chunk-CEEZJXEF.js +0 -2
  437. package/dist/chunk-CIYLO6SI.js +0 -7
  438. package/dist/chunk-CJZXN4NU.js +0 -2
  439. package/dist/chunk-CNO7TOKL.js +0 -2
  440. package/dist/chunk-COF23M5F.js +0 -2
  441. package/dist/chunk-CWFP7GM5.js +0 -2
  442. package/dist/chunk-D2DHWI3D.js +0 -2
  443. package/dist/chunk-D4N5SQ2M.js +0 -4
  444. package/dist/chunk-DBRSYFXR.js +0 -2
  445. package/dist/chunk-DHUIOLDT.js +0 -2
  446. package/dist/chunk-DIRJWYBM.js +0 -6
  447. package/dist/chunk-DIUFNHRJ.js +0 -35
  448. package/dist/chunk-DRENNWRG.js +0 -2
  449. package/dist/chunk-DTZCKZEU.js +0 -4
  450. package/dist/chunk-DULC3QFP.js +0 -5
  451. package/dist/chunk-DYGHBZ2N.js +0 -16
  452. package/dist/chunk-E5R6AQ73.js +0 -40
  453. package/dist/chunk-E73UNJTF.js +0 -38
  454. package/dist/chunk-EKV5HX33.js +0 -2
  455. package/dist/chunk-EQHFIL6T.js +0 -3
  456. package/dist/chunk-ESIQ66Z7.js +0 -2
  457. package/dist/chunk-EVFUMY4R.js +0 -3
  458. package/dist/chunk-F7DY272B.js +0 -2
  459. package/dist/chunk-FBN2FGXG.js +0 -2
  460. package/dist/chunk-FDLOBR6P.js +0 -4
  461. package/dist/chunk-FESCRNVV.js +0 -5
  462. package/dist/chunk-FFRKR4EQ.js +0 -2
  463. package/dist/chunk-FGA2U4OR.js +0 -8
  464. package/dist/chunk-FIQRSHVM.js +0 -2
  465. package/dist/chunk-FPYLNQPT.js +0 -2
  466. package/dist/chunk-FRUSVINH.js +0 -2
  467. package/dist/chunk-GSP44ENC.js +0 -2
  468. package/dist/chunk-GUFSG5TX.js +0 -2
  469. package/dist/chunk-GYIZ4NXB.js +0 -2
  470. package/dist/chunk-GZIUDL6G.js +0 -2
  471. package/dist/chunk-H5EXS3HM.js +0 -2
  472. package/dist/chunk-HCXEQRFF.js +0 -18
  473. package/dist/chunk-HEHOQQKH.js +0 -2
  474. package/dist/chunk-HKGFPJ4T.js +0 -4
  475. package/dist/chunk-HLZTEXRA.js +0 -2
  476. package/dist/chunk-HOENASQM.js +0 -3
  477. package/dist/chunk-HVF5VBG6.js +0 -2
  478. package/dist/chunk-I55I7XXP.js +0 -2
  479. package/dist/chunk-IDFEUFKS.js +0 -2
  480. package/dist/chunk-IHGQTTVW.js +0 -2
  481. package/dist/chunk-IICPE7B2.js +0 -20
  482. package/dist/chunk-IL676XCC.js +0 -18
  483. package/dist/chunk-IW5XQG5G.js +0 -2
  484. package/dist/chunk-IZDPJ2QI.js +0 -2
  485. package/dist/chunk-J66VOFW6.js +0 -5
  486. package/dist/chunk-JFMEXGFE.js +0 -2
  487. package/dist/chunk-JGKUET5J.js +0 -3
  488. package/dist/chunk-JS4PGXMV.js +0 -3
  489. package/dist/chunk-JWTGMPIT.js +0 -80
  490. package/dist/chunk-JYR66JN5.js +0 -5
  491. package/dist/chunk-KFOYCQAJ.js +0 -9
  492. package/dist/chunk-KLFEXGQA.js +0 -2
  493. package/dist/chunk-KMVGRIO2.js +0 -2
  494. package/dist/chunk-KYSDI3GE.js +0 -5
  495. package/dist/chunk-L6PJPETJ.js +0 -29
  496. package/dist/chunk-LDVT66YM.js +0 -2
  497. package/dist/chunk-LEECKFCJ.js +0 -2
  498. package/dist/chunk-LMZ5PRUV.js +0 -2
  499. package/dist/chunk-LQRQN2XA.js +0 -2
  500. package/dist/chunk-LXABEJX3.js +0 -2
  501. package/dist/chunk-MNV5FSBW.js +0 -3
  502. package/dist/chunk-MPQ4OTBM.js +0 -2
  503. package/dist/chunk-MTDBHTSF.js +0 -2
  504. package/dist/chunk-MV3CDXPI.js +0 -38
  505. package/dist/chunk-MWN53KRN.js +0 -60
  506. package/dist/chunk-MXNGIEPU.js +0 -3
  507. package/dist/chunk-N2ZSIIGR.js +0 -117
  508. package/dist/chunk-N5B2NILC.js +0 -5
  509. package/dist/chunk-NJITK2GP.js +0 -2
  510. package/dist/chunk-NOGJXYFO.js +0 -2
  511. package/dist/chunk-NOYBFVJA.js +0 -554
  512. package/dist/chunk-NWQXSFFU.js +0 -3
  513. package/dist/chunk-ODDUPDP7.js +0 -13
  514. package/dist/chunk-OLIWTZI3.js +0 -3
  515. package/dist/chunk-OLNV6I6U.js +0 -2
  516. package/dist/chunk-OR2E3AGZ.js +0 -2
  517. package/dist/chunk-OSR2GEHQ.js +0 -2
  518. package/dist/chunk-OSSESPDX.js +0 -3
  519. package/dist/chunk-OWOOWNJ5.js +0 -7
  520. package/dist/chunk-P42EIXTA.js +0 -2
  521. package/dist/chunk-PJFGPYTU.js +0 -2
  522. package/dist/chunk-PP7KNN7L.js +0 -2
  523. package/dist/chunk-PU7T5QYQ.js +0 -2
  524. package/dist/chunk-PWWAJSKV.js +0 -74
  525. package/dist/chunk-PZL5T7SU.js +0 -73
  526. package/dist/chunk-QBE3YX64.js +0 -23
  527. package/dist/chunk-QGVTFRY2.js +0 -7
  528. package/dist/chunk-QOJONDS7.js +0 -2
  529. package/dist/chunk-QU5XRYB5.js +0 -4
  530. package/dist/chunk-QUU5OBVK.js +0 -11
  531. package/dist/chunk-RBLQNW26.js +0 -20
  532. package/dist/chunk-RTQ7NEKG.js +0 -81
  533. package/dist/chunk-SQXRS7BG.js +0 -4
  534. package/dist/chunk-SSK6LDPC.js +0 -2
  535. package/dist/chunk-SZHGTCPP.js +0 -7
  536. package/dist/chunk-T4N4P2K5.js +0 -16
  537. package/dist/chunk-TA3QKLLU.js +0 -2
  538. package/dist/chunk-TEBQMNVI.js +0 -43
  539. package/dist/chunk-TPFHAQ2G.js +0 -2
  540. package/dist/chunk-TQPCBMWT.js +0 -5
  541. package/dist/chunk-TQZV7KV4.js +0 -2
  542. package/dist/chunk-TRNAEQ6P.js +0 -3
  543. package/dist/chunk-TY7CRN3Z.js +0 -2
  544. package/dist/chunk-UHFYCMZO.js +0 -35
  545. package/dist/chunk-UICY4GTQ.js +0 -7
  546. package/dist/chunk-UVGEWT4Y.js +0 -26
  547. package/dist/chunk-UXW33INU.js +0 -29
  548. package/dist/chunk-VMPRET3I.js +0 -5
  549. package/dist/chunk-VNLGKHS6.js +0 -6
  550. package/dist/chunk-VQILFTEH.js +0 -2
  551. package/dist/chunk-VUPHCS7Y.js +0 -57
  552. package/dist/chunk-VVZSBTSU.js +0 -23
  553. package/dist/chunk-VZRNID6A.js +0 -2
  554. package/dist/chunk-W5OXRYGE.js +0 -7
  555. package/dist/chunk-W6STWDQI.js +0 -57
  556. package/dist/chunk-W7CXK74K.js +0 -2
  557. package/dist/chunk-WB3WYIRE.js +0 -4
  558. package/dist/chunk-WDNVY4E7.js +0 -20
  559. package/dist/chunk-WK46TNUM.js +0 -3
  560. package/dist/chunk-WNTFFKAX.js +0 -12
  561. package/dist/chunk-WOIKCX6A.js +0 -2
  562. package/dist/chunk-WUN6KBHV.js +0 -2
  563. package/dist/chunk-WYCTJDVR.js +0 -2
  564. package/dist/chunk-WYPL7GF7.js +0 -2
  565. package/dist/chunk-XDAUYDFT.js +0 -2
  566. package/dist/chunk-XDQMU3BT.js +0 -2
  567. package/dist/chunk-XFA4SSO3.js +0 -3
  568. package/dist/chunk-XGZEP6GR.js +0 -8
  569. package/dist/chunk-XPDPNWTQ.js +0 -368
  570. package/dist/chunk-XRYABF57.js +0 -8
  571. package/dist/chunk-YBGKCQIS.js +0 -2
  572. package/dist/chunk-YEN6CYC7.js +0 -16
  573. package/dist/chunk-YF5IB2LF.js +0 -2
  574. package/dist/chunk-YI2AWIHC.js +0 -3
  575. package/dist/chunk-YPWBKGFU.js +0 -2
  576. package/dist/chunk-YPWHBBIS.js +0 -2
  577. package/dist/chunk-YSH6U3L4.js +0 -3
  578. package/dist/chunk-YU5DZUZI.js +0 -10
  579. package/dist/chunk-YWO5DDRC.js +0 -16
  580. package/dist/chunk-Z4CDXYNQ.js +0 -2
  581. package/dist/chunk-ZF5KHH7C.js +0 -2
  582. package/dist/chunk-ZOHS7AQV.js +0 -21
  583. package/dist/chunk-ZTI4SBFV.js +0 -3
  584. package/dist/code-MI6F2TTU.js +0 -2
  585. package/dist/code-result-json-FXALY4HE.js +0 -2
  586. package/dist/command-descriptors-P34VABY5.js +0 -343
  587. package/dist/dataflow-4KEMJPC6.js +0 -2
  588. package/dist/dependence-slice-R7FPWD5M.js +0 -2
  589. package/dist/deps-7EMQUYUT.js +0 -2
  590. package/dist/direct-navigation-6YO234F2.js +0 -3
  591. package/dist/entry-map-KOOLR26E.js +0 -2
  592. package/dist/files-OPIPJIGZ.js +0 -2
  593. package/dist/graph-evidence-Bjyky2V4.d.ts +0 -126
  594. package/dist/hierarchy-QPD2CAER.js +0 -2
  595. package/dist/imports-M6HUXRXC.js +0 -2
  596. package/dist/members-I5MEFOCT.js +0 -2
  597. package/dist/methods-5JYGGHXA.js +0 -2
  598. package/dist/next-anchor-candidates-BwMczMvX.d.ts +0 -90
  599. package/dist/output-continuation-command-UPQAAKBP.js +0 -3
  600. package/dist/output-pagination-3OFL2MJV.js +0 -19
  601. package/dist/project-reindex-UKKQ5PLS.js +0 -3
  602. package/dist/queries/anchors.d.ts +0 -123
  603. package/dist/queries/anchors.js +0 -2
  604. package/dist/queries/complexity-hotspots.d.ts +0 -40
  605. package/dist/queries/complexity-hotspots.js +0 -2
  606. package/dist/queries/convergence.d.ts +0 -33
  607. package/dist/queries/convergence.js +0 -2
  608. package/dist/queries/dataflow.d.ts +0 -77
  609. package/dist/queries/dataflow.js +0 -2
  610. package/dist/queries/deep-chains.d.ts +0 -5
  611. package/dist/queries/deep-chains.js +0 -2
  612. package/dist/queries/extract-candidates.d.ts +0 -52
  613. package/dist/queries/extract-candidates.js +0 -2
  614. package/dist/queries/isolated.d.ts +0 -24
  615. package/dist/queries/isolated.js +0 -2
  616. package/dist/queries/plan-context.d.ts +0 -33
  617. package/dist/queries/plan-context.js +0 -2
  618. package/dist/queries/reference-neighborhood.d.ts +0 -4
  619. package/dist/queries/reference-neighborhood.js +0 -2
  620. package/dist/queries/reference-reachability.d.ts +0 -48
  621. package/dist/queries/reference-reachability.js +0 -2
  622. package/dist/queries/self-audit.d.ts +0 -63
  623. package/dist/queries/self-audit.js +0 -2
  624. package/dist/queries/similar-chains.d.ts +0 -48
  625. package/dist/queries/similar-chains.js +0 -2
  626. package/dist/queries/slice.d.ts +0 -4
  627. package/dist/queries/slice.js +0 -2
  628. package/dist/queries/stale-abstractions.d.ts +0 -72
  629. package/dist/queries/stale-abstractions.js +0 -2
  630. package/dist/queries/system-map.d.ts +0 -449
  631. package/dist/queries/system-map.js +0 -2
  632. package/dist/queries/trace.js +0 -2
  633. package/dist/queries/twin-ab.d.ts +0 -66
  634. package/dist/queries/twin-ab.js +0 -2
  635. package/dist/queries/value-flow.d.ts +0 -43
  636. package/dist/queries/value-flow.js +0 -2
  637. package/dist/queries/wrapper-candidates.d.ts +0 -34
  638. package/dist/queries/wrapper-candidates.js +0 -2
  639. package/dist/refs-PSU4JZZW.js +0 -2
  640. package/dist/refs-pagination-JG6CJMRC.js +0 -2
  641. package/dist/slice-HYRATV64.js +0 -2
  642. package/dist/source-snippet-_wrcgmZc.d.ts +0 -15
  643. package/dist/stats-OOJ74B32.js +0 -2
  644. package/dist/surface-VTGDYWF5.js +0 -2
  645. package/dist/symbol-resolution-WD5EU5JE.js +0 -2
  646. package/dist/system-LRQNFOR2.js +0 -2
  647. package/dist/trace-F4B6OLL4.js +0 -2
  648. package/dist/value-flow-VRPZY72V.js +0 -2
  649. package/skills/concrete-plan/SKILL.md +0 -8
  650. package/skills/concrete-plan/agents/openai.yaml +0 -4
@@ -0,0 +1,2 @@
1
+ import{c as zt,d as M}from"./chunk-YTAP5Y2G.js";import{a as Ft}from"./chunk-NDUNO5JQ.js";import{c as A}from"./chunk-X6RMKHJQ.js";import{d as he,f as Ot}from"./chunk-JEVRKFRL.js";import{b as Bt,c as Wt}from"./chunk-BL6XJKTA.js";import{a as me,c as U,d as G}from"./chunk-O4UZSPPI.js";import{a as Ie}from"./chunk-B3PYOSCX.js";import{e as Z}from"./chunk-HGFDYOVB.js";import{a as _t,b as qt,c as Se,d as $t}from"./chunk-QZ7KQZRN.js";import{C as Be,b as ge,c as k,d as X,g as jt,h as Nt,i as _e,j as qe,m as $e}from"./chunk-TKD34PHN.js";import{H as Lt,N as Ct,O as Mt,a as Fe,c as Pt,d as pe,e as ye,o as je,q as Dt,r as At,t as kt}from"./chunk-U5RIG3JP.js";import{a as w,b as Ne,c as h,f as v,h as x,i as I,k as Tt,l as z}from"./chunk-62BDNPMI.js";import{createHash as yr,randomUUID as gr}from"crypto";import{existsSync as H,mkdirSync as mr,readdirSync as hr,rmSync as Vt,statSync as Yt}from"fs";import{basename as Sr,dirname as be,join as b}from"path";var F=1,Ue=1,te=".scipquery-generations",we="manifest.json",Jt="readers",Ir="gc.lock",br=128,ee=new Map,Qt={pid:process.pid,now:()=>new Date,randomToken:()=>gr(),isProcessAlive:Ie,readProcessIdentity:Se};function m(e){return b(be(e),te)}function He(e){return b(m(e),Ir)}function Da(e,t=Qt){let n=M(He(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=Er(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 a=b(m(e.dbPath),Jt);mr(a,{recursive:!0}),r=b(a,`${t.pid}-${o}.json`);let s=t.readProcessIdentity(t.pid);U(r,{version:1,token:o,generationIdentity:i.identity,pid:t.pid,...s?{processIdentity:s}:{},acquiredAt:t.now().toISOString()},{spacing:2,trailingNewline:!0});let c=!1;return{generation:i,release(){c||!r||(c=!0,Vt(r,{force:!0}))}}}finally{n.release()}}function Kt(e,t,n=Qt,r={}){let i=b(m(e),Jt);if(!H(i))return{protectedGenerations:new Set,activeLeases:0,staleLeasesRemoved:0,malformedLeases:0};let o=new Set,a=0,s=0,c=0;for(let d of hr(i,{withFileTypes:!0})){if(!d.isFile()||!d.name.endsWith(".json"))continue;let u=b(i,d.name),p=Mr(u);if(!p){c+=1;for(let g of t)o.add(g);continue}if(!Rr(p,n)){r.removeStale!==!1&&(Vt(u,{force:!0}),s+=1);continue}a+=1,o.add(p.generationIdentity)}return{protectedGenerations:o,activeLeases:a,staleLeasesRemoved:s,malformedLeases:c}}function wr(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,n=t.processIdentity===void 0?null:_t(t.processIdentity);return!vr(t)||!xr(t,n)?null:{version:1,token:t.token,generationIdentity:t.generationIdentity,pid:t.pid,...n?{processIdentity:n}:{},acquiredAt:t.acquiredAt}}function vr(e){return e.version===1&&typeof e.token=="string"&&e.token.trim()!==""&&typeof e.generationIdentity=="string"&&/^[a-f0-9]{64}$/.test(e.generationIdentity)}function xr(e,t){return typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0&&typeof e.acquiredAt=="string"&&Number.isFinite(Date.parse(e.acquiredAt))&&(e.processIdentity===void 0||!!(t&&t.pid===e.pid))}function Rr(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let n=t.readProcessIdentity(e.pid);return n===null||qt(e.processIdentity,n)}function j(e){try{let t=JSON.parse(I(b(m(e),"state.json"),"SQLite generation state"));return Dr(t)?t:null}catch{return null}}function V(e,t){return ne(m(e),t)}function ne(e,t){try{let n=JSON.parse(I(b(e,t,we),"SQLite generation manifest"));return Tr(n,t)?n:null}catch{return null}}function Er(e){let t=j(e.dbPath);if(t){let n=Gr(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(H(b(be(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return Pr(e,t?.currentGeneration)}function Aa(e){let t=j(e);if(t)return t.currentGeneration;try{let n=b(be(e),"meta.json"),r=H(n)?I(n,"reindex metadata"):void 0;return Xt(e,r)}catch{return null}}function L(e){return Ot(he(e))??e}function Gr(e,t){try{let n=b(m(e.dbPath),t),r=V(e.dbPath,t);if(!r)return null;let i=We(n,r.database),o=r.index?We(n,r.index):void 0,a=r.metadata?We(n,r.metadata):void 0;return!Zt(i,r.database)||!Ht(o,r.index)||!Ht(a,r.metadata)?null:{identity:t,databasePath:i,...o?{indexPath:o}:{},...a?{metadataPath:a,metadataRaw:I(a,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function Pr(e,t){let n=N(e.dbPath),r=b(be(e.dbPath),"meta.json"),i=H(r)?I(r,"reindex metadata"):void 0,o=H(e.indexPath)?e.indexPath:void 0;return{identity:t??Xt(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:r,metadataRaw:i},source:"legacy",databaseFileIdentity:n}}function Xt(e,t){let n=yr("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&n.update(L(t)),n.update(`\0${N(e)}`),n.digest("hex")}function N(e){let t=Yt(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function We(e,t){if(Sr(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return b(e,t.file)}function Zt(e,t){if(!H(e))return!1;let n=Ut(e);if(!n||n.size!==t.size)return!1;let r=`${e}\0${t.sha256}\0${n.identity}`;if(ee.has(r))return!0;let i=z(e,{inputKind:"immutable SQLite generation artifact",maxBytes:t.size}),o=Ut(e);if(!o||o.identity!==n.identity||i!==t.sha256)return!1;for(ee.set(r,!0);ee.size>br;){let a=ee.keys().next().value;if(a===void 0)break;ee.delete(a)}return!0}function Ut(e){let t=Yt(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function Tr(e,t){return e.version===Ue&&e.identity===t&&ze(e.database)&&(e.index===void 0||ze(e.index))&&(e.metadata===void 0||ze(e.metadata))}function ze(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 Dr(e){return e.version===F&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&Ar(e.stableMirrors)&&kr(e.previousGeneration)&&Lr(e.publication)}function Ar(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 kr(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 Lr(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 Cr(t,n)&&Or(t)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}function Cr(e,t){return(e.mode==="incremental"||e.mode==="full")&&e.validation==="passed"&&e.converterDurationMs!==void 0&&t.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=0)}function Or(e){return(e.scipCompanion===void 0||e.scipCompanion==="current"||e.scipCompanion==="deferred")&&(e.typescriptOverlayGeneration===void 0||typeof e.typescriptOverlayGeneration=="string"&&!!e.typescriptOverlayGeneration)&&(e.scipCompanion!=="deferred"||!!e.typescriptOverlayGeneration)}function Ht(e,t){return!t||!!(e&&Zt(e,t))}function Mr(e){let t;try{t=wr(JSON.parse(I(e,"SQLite generation reader lease")))}catch{t=null}return t}import{existsSync as en,readdirSync as tn,rmSync as nn}from"fs";import{join as Y}from"path";import{create as on,fromBinary as an,toBinary as Na}from"@bufbuild/protobuf";import{deserializeSCIP as Ve,DocumentSchema as sn,IndexSchema as cn,serializeSCIP as dn}from"@c4312/scip";var Ye=1,re="typescript-scip-fragments";function Ba(e){let t=new Set,n=[];for(let o of e){let a=ve(o.relativePath);if(t.has(a))throw new Error(`duplicate TypeScript fragment replacement: ${a}`);if(t.add(a),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${a}`);let s=an(sn,o.bytes);if(s.relativePath!==a)throw new Error(`TypeScript fragment path mismatch: expected ${a}, got ${s.relativePath}`);n.push(s)}let r=dn(on(cn,{documents:n,externalSymbols:[]})),i=Ve(r);if(i.documents.length!==n.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return r}function Fr(e){let t=Y(e,re);return{rootDir:t,blobDir:Y(t,"blobs"),generationDir:Y(t,"generations")}}function ln(e){let t=jr(e);return Nr(t.baseIndex,t.completeDocuments,"assembled")}function jr(e){let t=Ve(e.baseIndexBytes);Je(t.metadata,zr(e)),Wr(t.externalSymbols);let n=Ur(e),r=new Set,i=[],o=[],a=[];for(let s of t.documents){let c=ve(s.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);r.add(c);let d=n.get(c);if(!d){i.push(s);continue}if(n.delete(c),d.bytes===null){a.push(c);continue}let u=rn(c,d.bytes);i.push(u),o.push(u)}for(let s of[...n.keys()].sort()){let c=n.get(s);if(c.bytes===null)continue;if(r.has(s))throw new Error(`duplicate TypeScript SCIP document path: ${s}`);r.add(s);let d=rn(s,c.bytes);i.push(d),o.push(d)}return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:a}}function rn(e,t){let n=an(sn,t);if(n.relativePath!==e)throw new Error(`TypeScript fragment path mismatch: expected ${e}, got ${n.relativePath}`);return n}function Nr(e,t,n){let r=dn(on(cn,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=Ve(r);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${n} TypeScript SCIP index failed structural verification`);return r}function Wa(e,t){let n=Fr(e);if(!en(n.generationDir))return;let r=new Set(t.map(a=>Br(a))),i=tn(n.generationDir).filter(a=>a.endsWith(".json")),o=new Set;for(let a of i.filter(s=>r.has(s))){let s=_r(x(Y(n.generationDir,a),{maxBytes:w,inputKind:"TypeScript fragment manifest"}));for(let c of s.documents)o.add(`${c.blobHash}.scipdoc`)}for(let a of i)r.has(a)||nn(Y(n.generationDir,a),{force:!0});if(en(n.blobDir))for(let a of tn(n.blobDir))o.has(a)||nn(Y(n.blobDir,a),{force:!0})}function _r(e){let t=JSON.parse(e);qr(t);let n=new Set;for(let r of t.documents){if($r(r),ve(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript fragment record");n.add(r.relativePath)}return t}function qr(e){if(e.version!==Ye||typeof e.producerIdentity!="string"||typeof e.projectIdentity!="string"||typeof e.generationIdentity!="string"||typeof e.createdAt!="string"||!Number.isFinite(Date.parse(e.createdAt))||!Array.isArray(e.documents))throw new Error("invalid TypeScript fragment generation manifest")}function $r(e){if(!e||typeof e.relativePath!="string"||typeof e.blobHash!="string"||!/^[a-f0-9]{64}$/.test(e.blobHash)||typeof e.byteLength!="number"||!Number.isInteger(e.byteLength)||e.byteLength<0||typeof e.documentIdentity!="string"||!e.documentIdentity)throw new Error("invalid TypeScript fragment record")}function Br(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${A(e)}.json`}function Wr(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function Je(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!==Ct(t))throw new Error("TypeScript SCIP shard producer identity changed")}function zr(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function ve(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}function Ur(e){let t=new Map;for(let n of e.fragments){let r=ve(n.relativePath);if(t.has(r))throw new Error(`duplicate TypeScript fragment replacement: ${r}`);t.set(r,n)}if(t.size===0)throw new Error("TypeScript index assembly requires at least one replacement");return t}function za(e,t,n){let r=e.files.filter(i=>{let o=Fe(i.path,e.languages);return o==="ambient"||o==="config"&&(!Lt(i.path)||n.has(i.path))}).map(i=>{let a=Fe(i.path,e.languages)==="config"?i.semanticHash:void 0;return{path:i.path,size:a===void 0?i.size:0,hash:a??i.hash}}).sort((i,o)=>i.path.localeCompare(o.path));return`typescript-project-v3:${A(JSON.stringify({version:3,producerIdentity:t,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),nonSourceInputs:r}))}`}function Ua(e,t){return A(JSON.stringify({version:1,producerIdentity:t,snapshot:pe(e)}))}import{fromBinary as Kr}from"@bufbuild/protobuf";import{MetadataSchema as Xr}from"@c4312/scip";var R=class extends Error{},Hr=0,Vr=1,un=2,Yr=5;function Qe(e,t,n){let r=0,i=0;for(;t<n;){let o=e[t];if(t+=1,i<53)r+=(o&127)*2**i;else if((o&127)!==0)throw new R("varint exceeds the safe integer range");if((o&128)===0)return{value:r,pos:t};if(i+=7,i>63)throw new R("varint is longer than 64 bits")}throw new R("varint runs past the end of the buffer")}function*S(e,t=0,n=e.length){let r=t;for(;r<n;){let i=r,o=Qe(e,r,n);r=o.pos;let a=Math.floor(o.value/8),s=o.value%8;if(a===0)throw new R("field number 0 is invalid");let c=r,d=0;if(s===Hr){let u=Qe(e,r,n);d=u.value,r=u.pos}else if(s===un){let u=Qe(e,r,n);if(c=u.pos,r=u.pos+u.value,r>n)throw new R("length-delimited field runs past the end of the buffer")}else if(s===Vr)r+=8;else if(s===Yr)r+=4;else throw new R(`unsupported wire type ${s}`);if(r>n)throw new R("field value runs past the end of the buffer");yield{fieldNumber:a,wireType:s,fieldStart:i,valueStart:c,valueEnd:r,fieldEnd:r,varint:d}}}function ie(e){if(!Number.isSafeInteger(e)||e<0)throw new R(`cannot encode varint ${e}`);let t=[],n=e;do{let r=n%128;n=Math.floor(n/128),n>0&&(r|=128),t.push(r)}while(n>0);return Uint8Array.from(t)}function xe(e){return ie(e*8+un)}var Jr=1,Qr=3;function oe(e){let t=new TextDecoder,n;for(let r of S(e))if(!(r.fieldNumber!==Jr||r.wireType!==2))for(let i of S(e,r.valueStart,r.valueEnd)){if(i.fieldNumber!==Qr||i.wireType!==2)continue;let o=t.decode(e.subarray(i.valueStart,i.valueEnd));o&&(n=o)}return n}import{existsSync as Ee,readdirSync as Ke,rmSync as fn}from"fs";import{join as P}from"path";var Ge=1,ae="typescript-scip-overlays",pn="typescript-project-v3:";function Zr(e){let t=mn(e.cacheDir,e.previousGenerationIdentity);ni(e,t);let n=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),r=new Set;for(let o of e.fragments){let a=Pe(o.relativePath);if(r.has(a))throw new Error(`duplicate TypeScript overlay: ${a}`);r.add(a),n.set(a,ii(e.cacheDir,o))}if(ti(e,n,r),r.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:Ge,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,a)=>o.relativePath.localeCompare(a.relativePath))};return oi(e.cacheDir,i),i}function is(e){let t=[],n=!1,r=new TextDecoder("utf-8",{fatal:!0});for(let i of S(e.indexBytes)){if(i.wireType!==2)continue;let o=e.indexBytes.subarray(i.valueStart,i.valueEnd);if(i.fieldNumber===1)Je(Kr(Xr,o),e.packageVersion),n=!0;else{if(i.fieldNumber===3)throw new Error("TypeScript overlay seed cannot contain external symbols");if(i.fieldNumber===2){let a=ei(o,r);t.push({relativePath:a,bytes:o,occurrences:0,symbols:0,referenceFragments:[]})}}}if(!n)throw new Error("TypeScript overlay seed has no producer identity");return Zr({...e,previousGenerationIdentity:e.generationIdentity,nextGenerationIdentity:e.generationIdentity,baseShardCurrent:!0,fragments:t})}function ei(e,t){let n;for(let r of S(e))r.fieldNumber===1&&r.wireType===2&&(n=t.decode(e.subarray(r.valueStart,r.valueEnd)));if(!n)throw new Error("TypeScript overlay seed document has no path");return n}function ti(e,t,n){for(let r of e.retainedDocuments??[]){hn(r);let i=Pe(r.relativePath);if(n.has(i))throw new Error(`duplicate TypeScript overlay: ${i}`);let o=t.get(i);if(!r.blobHash||!o||o.blobHash!==r.blobHash||o.byteLength!==r.byteLength)throw new Error(`retained TypeScript overlay does not match its accepted blob: ${i}`);gn(e.cacheDir,r),n.add(i)}}function ni(e,t){if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t?.producerIdentity!==void 0&&t.producerIdentity!==e.producerIdentity)throw new Error("TypeScript overlay producer identity changed");let n=ri(e,t);if(t&&t.projectIdentity!==e.projectIdentity&&!e.allowProjectIdentityChange&&!n)throw new Error("TypeScript overlay project identity changed")}function ri(e,t){return e.allowLegacyProjectIdentityMigration===!0&&t!==null&&!t.projectIdentity.startsWith(pn)&&e.projectIdentity.startsWith(pn)}function os(e){let t=mn(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=gn(e.cacheDir,r);return{relativePath:r.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return ln({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:n})}function gn(e,t){let n=v(P(se(e),"blobs",`${t.blobHash}.scipdoc`),{maxBytes:Ne,inputKind:"TypeScript overlay blob"});if(n.byteLength!==t.byteLength||A(n)!==t.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${t.relativePath}`);return n}function as(e,t){let n=se(e),r=P(n,"generations");if(!Ee(r))return;let i=new Set(t.map(Ze)),o=new Set;for(let s of Ke(r).filter(c=>i.has(c))){let c=Xe(x(P(r,s),{maxBytes:w,inputKind:"TypeScript overlay manifest"}));for(let d of c.overlays)d.blobHash&&o.add(`${d.blobHash}.scipdoc`)}for(let s of Ke(r))i.has(s)||fn(P(r,s),{force:!0});let a=P(n,"blobs");if(Ee(a))for(let s of Ke(a))o.has(s)||fn(P(a,s),{force:!0})}function mn(e,t){let n=P(se(e),"generations",Ze(t));if(!Ee(n))return null;let r=Xe(x(n,{maxBytes:w,inputKind:"TypeScript overlay manifest"}));if(r.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return r}function ii(e,t){let n=Pe(t.relativePath);if(t.bytes===null)return{relativePath:n,blobHash:null,byteLength:0};let r=Buffer.from(t.bytes),i=A(r);return Ft({blobDir:P(se(e),"blobs"),blobHash:i,bytes:r,relativePath:n,inputKind:"TypeScript overlay blob"}),{relativePath:n,blobHash:i,byteLength:r.byteLength}}function oi(e,t){let n=P(se(e),"generations",Ze(t.generationIdentity));if(Ee(n)){let r=Xe(x(n,{maxBytes:w,inputKind:"TypeScript overlay manifest"}));if(yn(r)!==yn(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}U(n,t,{spacing:2,trailingNewline:!0})}function Xe(e){let t=JSON.parse(e);ai(t);let n=new Set;for(let r of t.overlays){if(hn(r),Pe(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript overlay record");n.add(r.relativePath)}return t}function ai(e){if(e.version!==Ge||!Re(e.producerIdentity)||!Re(e.projectIdentity)||!Re(e.baseGenerationIdentity)||!Re(e.generationIdentity)||typeof e.createdAt!="string"||!Number.isFinite(Date.parse(e.createdAt))||!Array.isArray(e.overlays))throw new Error("invalid TypeScript overlay manifest")}function Re(e){return typeof e=="string"&&e!==""}function hn(e){let t=e;if(!t||typeof t.relativePath!="string"||t.blobHash!==null&&(typeof t.blobHash!="string"||!/^[a-f0-9]{64}$/.test(t.blobHash))||!Number.isInteger(t.byteLength)||t.byteLength<0||t.blobHash===null&&t.byteLength!==0)throw new Error("invalid TypeScript overlay record")}function se(e){return P(e,ae)}function Ze(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${A(e)}.json`}function yn(e){return A(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function Pe(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{execFileSync as si}from"child_process";import{existsSync as ci,readdirSync as Sn}from"fs";import{extname as In,join as bn}from"path";var wn=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),di=[{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 fs(e){let t=[],n=li(e),r=yi(e);for(let i of di){if(ui(e,i.files)){t.push(i.language);continue}if(fi(n,i.globs)){t.push(i.language);continue}hi(r,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&et(t,"javascript"),Si(t,r),t}function li(e){try{return Sn(e)}catch{return[]}}function ui(e,t){return t?.length?t.some(n=>ci(bn(e,n))):!1}function fi(e,t){return t?.length?e.some(n=>t.some(r=>pi(n,r))):!1}function pi(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 yi(e){let t=mi(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=Sn(i,{withFileTypes:!0})}catch{continue}gi(i,o,r,n)}return n}function gi(e,t,n,r){for(let i of t){if(i.name.startsWith(".")&&!i.name.endsWith("proj")&&!i.name.endsWith("sln")&&i.isDirectory())continue;let o=bn(e,i.name);if(i.isDirectory()){wn.has(i.name)||n.push(o);continue}let a=In(i.name).toLowerCase();a&&r.add(a)}}function mi(e){try{let t=Dt(e,26214400,()=>si("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 At(t)){if(r.split("/").some(o=>wn.has(o)))continue;let i=In(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function hi(e,t){return t?.length?t.some(n=>e.has(n)):!1}function et(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}function Si(e,t){if(e.includes("cpp")&&e.includes("c")){let n=t.has(".c"),r=[".cc",".cpp",".cxx"].some(i=>t.has(i));n&&!r?et(e,"cpp"):n||et(e,"c")}}import{writeSync as Ii}from"fs";function E(e,t,n="File"){let r=0;for(;r<t.byteLength;){let i=Ii(e,t,r,t.byteLength-r);if(i<=0)throw new Error(`${n} write made no forward progress.`);r+=i}}import{closeSync as vn,openSync as bi,renameSync as wi,rmSync as vi}from"fs";import{create as Te,fromBinary as xn,toBinary as xi}from"@bufbuild/protobuf";import{DocumentSchema as De,IndexSchema as Ri,MetadataSchema as Ei,PositionEncoding as tt,SymbolInformationSchema as Gi,SymbolRole as Rn}from"@c4312/scip";var nt=2,Pi=3,Ti=1,Di=2,Ai=3,ki=4,Li=6,Ci=1,Oi=2,Mi=3;function xs(e){let t;try{t=v(e,{inputKind:"SCIP sanitization input",maxBytes:h})}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}try{return Fi(t,e)}catch(n){if(n instanceof R)return{removedDefinitionOccurrences:0,touchedDocuments:0};throw n}}function Fi(e,t){let n=new TextDecoder,r=new Set;ji(e,n,r);let i=0,o=0,a=[],s=$i(e);for(let c of S(e)){if(c.wireType!==2||c.fieldNumber!==nt)continue;let d=_i(e,c,n,r,s);An(d)&&(i+=d.removed,o+=d.symbols.length,a.push({field:c,repair:d}))}return a.length>0&&qi(e,t,a),Pn(i,a.length,o)}function En(e,t,n,r){if((t&Rn.Definition)!==0){if(!e){r.removed++;return}e.startsWith("local ")||n.has(e)||(n.add(e),r.symbols.push(e))}}function Gn(e,t){return An(t)?Te(De,{...e,positionEncoding:t.positionEncoding??e.positionEncoding,occurrences:e.occurrences.filter(n=>n.symbol||(n.symbolRoles&Rn.Definition)===0),symbols:[...e.symbols,...t.symbols.map(n=>Te(Gi,{symbol:n}))]}):e}function Pn(e,t,n){return{removedDefinitionOccurrences:e,touchedDocuments:t,...n>0?{recoveredDefinitionSymbols:n}:{}}}function ji(e,t,n){for(let r of S(e))r.wireType===2&&(r.fieldNumber===nt?Ni(e,r,t,n):r.fieldNumber===Pi&&Tn(e,r,t,n))}function Ni(e,t,n,r){for(let i of S(e,t.valueStart,t.valueEnd))i.wireType===2&&(i.fieldNumber===Ti?je(n.decode(e.subarray(i.valueStart,i.valueEnd))):i.fieldNumber===Ai&&Tn(e,i,n,r))}function Tn(e,t,n,r){for(let i of S(e,t.valueStart,t.valueEnd)){if(i.wireType!==2||i.fieldNumber!==Ci)continue;let o=n.decode(e.subarray(i.valueStart,i.valueEnd));o&&r.add(o)}}function _i(e,t,n,r,i){let o={removed:0,symbols:[]},a="",s=tt.UnspecifiedPositionEncoding;for(let c of S(e,t.valueStart,t.valueEnd)){if(c.fieldNumber===ki&&c.wireType===2&&(a=n.decode(e.subarray(c.valueStart,c.valueEnd))),c.fieldNumber===Li&&c.wireType===0&&(s=c.varint),c.wireType!==2||c.fieldNumber!==Di)continue;let{symbol:d,symbolRoles:u}=Bi(e,c,n);En(d,u,r,o)}return o.positionEncoding=rt(a,s,i),o}function qi(e,t,n){let r=`${t}.sanitize-tmp`,i=bi(r,"w",384);try{let o=0;for(let{field:a,repair:s}of n){E(i,e.subarray(o,a.fieldStart));let c=Gn(xn(De,e.subarray(a.valueStart,a.valueEnd)),s),d=xi(De,c);E(i,xe(nt)),E(i,ie(d.byteLength)),E(i,d),o=a.fieldEnd}E(i,e.subarray(o))}catch(o){throw vn(i),vi(r,{force:!0}),o}vn(i),wi(r,t)}function Dn(e){let t=new Set;for(let a of e.documents){je(a.relativePath);for(let s of a.symbols)s.symbol&&t.add(s.symbol)}for(let a of e.externalSymbols)a.symbol&&t.add(a.symbol);let n=0,r=0,i=0,o=e.documents.map(a=>{let s={removed:0,symbols:[]};for(let d of a.occurrences)En(d.symbol,d.symbolRoles,t,s);s.positionEncoding=rt(a.language,a.positionEncoding,e.metadata);let c=Gn(a,s);return c!==a&&i++,n+=s.removed,r+=s.symbols.length,c});return{index:i===0?e:Te(Ri,{...e,documents:o}),...Pn(n,i,r)}}function An(e){return e.removed>0||e.symbols.length>0||e.positionEncoding!==void 0}function rt(e,t,n){if(t===tt.UnspecifiedPositionEncoding&&!(e!==""&&e!=="python")&&!(n?.toolInfo?.name!=="scip-python"||!["0.7.4","0.7.5"].includes(n.toolInfo.version)))return tt.UTF16CodeUnitOffsetFromLineStart}function it(e,t){let n=rt(e.language,e.positionEncoding,t);return n===void 0?e:Te(De,{...e,positionEncoding:n})}function $i(e){let t;for(let n of S(e)){if(n.fieldNumber!==1||n.wireType!==2)continue;let r=xn(Ei,e.subarray(n.valueStart,n.valueEnd));if(!r.toolInfo||t&&JSON.stringify(t.toolInfo)!==JSON.stringify(r.toolInfo))return;t=r}return t}function Bi(e,t,n){let r="",i=0;for(let o of S(e,t.valueStart,t.valueEnd))o.fieldNumber===Oi&&o.wireType===2?r=n.decode(e.subarray(o.valueStart,o.valueEnd)):o.fieldNumber===Mi&&o.wireType===0&&(i=o.varint);return{symbol:r,symbolRoles:i}}import{writeSync as Wi,closeSync as ce,openSync as ot,readSync as zi,renameSync as Ui,rmSync as On,statSync as Hi,writeFileSync as Mn}from"fs";import{create as de,fromBinary as Vi,toBinary as Yi}from"@bufbuild/protobuf";import{deserializeSCIP as Fn,serializeSCIP as jn,DocumentSchema as Ji,IndexSchema as kn,MetadataSchema as at,SymbolInformationSchema as Qi,SymbolRole as Ki}from"@c4312/scip";function Nn(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1){let i=e[0];return de(kn,{...i,documents:i.documents.map(o=>it(o,i.metadata))})}let t=Xi(e),n=Zi(e.flatMap(i=>i.documents.map(o=>it(o,i.metadata)))),r=qn(e.flatMap(i=>i.externalSymbols??[]));return de(kn,{metadata:t,documents:n,externalSymbols:r})}function Cs(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>Fn(v(i,{inputKind:"SCIP merge input",maxBytes:h}))),r=Nn(n);return Mn(t,jn(r)),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function Os(e,t){if(e.length===0)throw new Error("Cannot concatenate zero SCIP files");let n=0;for(let o of e)if(n+=Hi(o).size,n>h)throw new Error(`Concatenated SCIP output exceeds the ${h}-byte artifact limit. Reduce the indexed project scope or use compatible cached generations.`);let r=Buffer.allocUnsafe(1024*1024),i=ot(t,"w",384);try{for(let o of e){let a=ot(o,"r");try{let s=0;for(;(s=zi(a,r,0,r.byteLength,null))>0;){let c=0;for(;c<s;)c+=Wi(i,r,c,s-c)}}finally{ce(a)}}}catch(o){throw ce(i),On(t,{force:!0}),o}ce(i)}function Ms(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=Z("reindex.publish.scip-output.deserialize",()=>e.map(o=>Fn(v(o,{inputKind:"SCIP merge input",maxBytes:h})))),r=Z("reindex.publish.scip-output.merge",()=>Nn(n)),i=Z("reindex.publish.scip-output.sanitize",()=>Dn(r));return Z("reindex.publish.scip-output.serialize",()=>Mn(t,jn(i.index))),{documentCount:i.index.documents.length,externalSymbolCount:i.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:i.removedDefinitionOccurrences,...i.recoveredDefinitionSymbols?{recoveredDefinitionSymbols:i.recoveredDefinitionSymbols}:{},touchedDocuments:i.touchedDocuments}}var Ln=1;function _n(e,t,n){let r=v(e,{inputKind:"SCIP normalization input",maxBytes:h}),i=oe(r),o=[];for(let c of S(r))c.fieldNumber===Ln&&c.wireType===2&&o.push(c);if(o.length===0)throw new Error("Cannot rebase a SCIP index without metadata");if((i??"")!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${i??""}`);let a=`${e}.rebase-tmp`,s=ot(a,"w",384);try{let c=0;for(let d of o){E(s,r.subarray(c,d.fieldStart));let u=Vi(at,r.subarray(d.valueStart,d.valueEnd));u.projectRoot=n;let p=Yi(at,u);E(s,xe(Ln)),E(s,ie(p.byteLength)),E(s,p),c=d.fieldEnd}E(s,r.subarray(c))}catch(c){throw ce(s),On(a,{force:!0}),c}ce(s),Ui(a,e)}function Xi(e){let t=e[0]?.metadata;if(!t)return;let n=t.projectRoot;for(let i of e.slice(1)){let o=i.metadata?.projectRoot;if(n&&o&&o!==n)throw new Error(`Cannot merge SCIP indexes with different project roots: ${n} vs ${o}`)}return e.every(i=>JSON.stringify(i.metadata?.toolInfo)===JSON.stringify(t.toolInfo))?t:de(at,{...t,toolInfo:void 0})}function Zi(e){let t=new Map;for(let n of e){let r=t.get(n.relativePath);if(!r){t.set(n.relativePath,n);continue}eo(r,n),t.set(n.relativePath,de(Ji,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:to([...r.occurrences,...n.occurrences]),symbols:qn([...r.symbols,...n.symbols]),text:r.text||n.text,positionEncoding:r.occurrences.length?r.positionEncoding:n.positionEncoding}))}return[...t.values()]}function eo(e,t){for(let i of["language","text"])if(e[i]&&t[i]&&e[i]!==t[i])throw new Error(`Cannot merge ${e.relativePath}: conflicting ${i}. Reindex one consistent source snapshot.`);if(e.occurrences.length&&t.occurrences.length&&e.positionEncoding!==t.positionEncoding)throw new Error(`Cannot merge ${e.relativePath}: incompatible column encodings.`);let n=Cn(e),r=Cn(t);for(let[i,o]of r){let a=n.get(i);if(a!==void 0&&(o.length===0||JSON.stringify(a)!==JSON.stringify(o)))throw new Error(`Cannot merge ${e.relativePath}: conflicting document-local identity ${i}.`)}}function Cn(e){let t=new Map;for(let n of e.occurrences){if(!n.symbol.startsWith("local "))continue;let r=t.get(n.symbol)??new Set;(n.symbolRoles&Ki.Definition)!==0&&r.add(JSON.stringify(st(n.range))),t.set(n.symbol,r)}return new Map([...t].map(([n,r])=>[n,[...r].sort()]))}function st(e){return e.length===3?[e[0],e[1],e[0],e[2]]:e}function to(e){let t=new Set,n=[];for(let r of e){let i=JSON.stringify({...r,range:st(r.range),enclosingRange:st(r.enclosingRange)});t.has(i)||(t.add(i),n.push(r))}return n}function qn(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,de(Qi,{symbol:r.symbol,documentation:ro([...r.documentation,...n.documentation]),relationships:no([...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 no(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 ro(e){return[...new Set(e)]}import{createHash as pt,randomUUID as _s}from"crypto";import{closeSync as io,copyFileSync as $s,existsSync as y,mkdirSync as oo,openSync as ao,readSync as so,readdirSync as yt,renameSync as lt,rmSync as J,statSync as _}from"fs";import{basename as Bn,dirname as T,join as f,relative as $n}from"path";import co from"better-sqlite3";var lo=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function Wn(e){let t=m(e.outputDb),n=So(e);e.onStage?.("after-recovery-retained");let r=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=Io(e,n),o=mt({generationRoot:t,databasePath:e.tempOutputDb,indexPath:y(r)?r:void 0,verifiedIndexArtifact:i,metadataPath:y(e.tempMetaPath)?e.tempMetaPath:void 0}),a=(e.now??(()=>new Date))().toISOString(),s={version:F,currentGeneration:o.identity,artifactSet:"immutable-v1",...n?{previousGeneration:n}:{},...e.publication?{publication:e.publication}:{},publishedAt:a},c=G(f(t,"state.json"),s,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||ft(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),Do(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),ft(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let d=o.identity,u={...s,stableMirrors:gt(e.outputDb,e.outputScip)};G(f(t,"state.json"),u,{spacing:2,trailingNewline:!0});let p=zn(e.outputDb,{now:e.now}),g=X(o.directorySync,c.directorySync);return{currentGeneration:d,...n?{previousGeneration:n}:{},retention:p,achievedDurability:g==="synced"?"directory-durable":"file-flushed",directorySync:g}}function uo(e,t,n,r=()=>new Date){if(!y(e))return null;let i=j(e),o=f(m(e),"state.json");if(Lo(e,i))return i;let a=m(e),s=!i&&y(o)?wo(n,e,t):void 0;if(s&&!ne(a,s))return null;let c=mt({generationRoot:a,databasePath:e,indexPath:y(t)?t:void 0,metadataPath:y(n)?n:void 0,forcedIdentity:i?.currentGeneration??s}),d=ko(c.identity,e,t,i,r);return G(f(a,"state.json"),d,{spacing:2,trailingNewline:!0}),d}function Ks(e,t,n=()=>new Date){if(!y(e)||!y(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let r=j(e),i=m(e),o=mt({generationRoot:i,databasePath:e,indexPath:y(f(T(e),"index.scip"))?f(T(e),"index.scip"):void 0,metadataPath:t}),a=r&&r.currentGeneration!==o.identity?Vn(e,r.currentGeneration):void 0,s={version:F,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:gt(e,f(T(e),"index.scip")),...a?{previousGeneration:a}:{},...r?.publication?{publication:r.publication}:{},publishedAt:n().toISOString()};return G(f(m(e),"state.json"),s,{spacing:2,trailingNewline:!0}),zn(e,{now:n}),s}function zn(e,t={}){let n=go(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=M(He(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{return fo(e,t,n,i)}catch(a){let s={state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:n,at:i,reason:a instanceof Error?a.message:String(a)};try{Hn(e,s)}catch{}return s}finally{o.release()}}function fo(e,t,n,r){let i=j(e),o=mo(e),a=Kt(e,o.map(W=>W.identity),{isProcessAlive:t.isProcessAlive??Ie,readProcessIdentity:t.readProcessIdentity??Se}),s=new Set(a.protectedGenerations);i?.currentGeneration&&s.add(i.currentGeneration),i?.previousGeneration?.generationIdentity&&s.add(i.previousGeneration.generationIdentity);let{generationCount:c,logicalBytes:d,removedGenerations:u,removedLogicalBytes:p}=yo(o,s,n,t),g=c>n.maxGenerations||d>n.maxLogicalBytes,K={state:g?"protected":u>0?"collected":"within-bounds",generationCount:c,logicalBytes:d,protectedGenerations:s.size,activeReaderLeases:a.activeLeases,staleReaderLeasesRemoved:a.staleLeasesRemoved,malformedReaderLeases:a.malformedLeases,removedGenerations:u,removedLogicalBytes:p,limits:n,at:r,...g?{reason:po(a.malformedLeases)}:{}};return Hn(e,K),K}function po(e){return e>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}function yo(e,t,n,r){let i=e.length,o=e.reduce((c,d)=>c+d.logicalBytes,0),a=0,s=0;for(let c of e){if(i<=n.maxGenerations&&o<=n.maxLogicalBytes)break;t.has(c.identity)||(r.onBeforeRemove?.(c.identity),J(c.path,{recursive:!0,force:!0}),i-=1,o-=c.logicalBytes,a+=1,s+=c.logicalBytes)}return{generationCount:i,logicalBytes:o,removedGenerations:a,removedLogicalBytes:s}}function go(e={}){let t={...lo,...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 mo(e){let t=m(e);return y(t)?yt(t,{withFileTypes:!0}).filter(n=>n.isDirectory()&&/^[a-f0-9]{64}$/.test(n.name)).map(n=>{let r=f(t,n.name),i=ne(t,n.name),o=i?i.database.size+(i.index?.size??0)+(i.metadata?.size??0):Un(r);return{identity:n.name,path:r,logicalBytes:o,modifiedAtMs:_(r).mtimeMs}}).sort((n,r)=>n.modifiedAtMs-r.modifiedAtMs||n.identity.localeCompare(r.identity)):[]}function Un(e){let t=0;for(let n of yt(e,{withFileTypes:!0})){let r=f(e,n.name);n.isDirectory()?t+=Un(r):n.isFile()&&(t+=_(r).size)}return t}function Hn(e,t){U(f(m(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function ke(e,t=f(T(e),"meta.json")){let n=f(m(e),"state.json");if(!y(n))return{state:"legacy",statePath:n};let r=j(e);if(!r)return{state:"invalid",statePath:n,reason:"generation state is malformed"};try{let i=V(e,r.currentGeneration),o=i!==null,a=i?ho(e,t,i,r):!1,s=r.previousGeneration?y(f(T(e),r.previousGeneration.databasePath)):!0;return!a||!o||!s?{state:"drifted",statePath:n,currentMatches:a,recoveryExists:s,generation:r,reason:Co(o,a)}:{state:"current",statePath:n,currentMatches:a,recoveryExists:s,generation:r}}catch(i){return{state:"drifted",statePath:n,currentMatches:!1,recoveryExists:!1,generation:r,reason:i instanceof Error?i.message:String(i)}}}function ho(e,t,n,r){if(!Oo(e,r)||!ut(e,n.database))return!1;let i=f(T(e),"index.scip");if(n.index&&!ut(i,n.index))return!1;if(!n.metadata)return!y(t);if(!y(t))return!1;let o=f(m(e),n.identity,n.metadata.file);return y(o)&&L(I(t,"reindex metadata"))===L(I(o,"immutable reindex metadata"))}function ut(e,t){return y(e)&&_(e).isFile()&&_(e).size===t.size}function So(e){let t=uo(e.outputDb,e.outputScip,e.metaPath);return t?Vn(e.outputDb,t.currentGeneration):void 0}function Io(e,t){if(!e.preserveOutputScip)return;if(!t)throw new Error("deferred SCIP publication requires an accepted immutable generation");let n=ke(e.outputDb,e.metaPath);if(n.state!=="current"||n.generation.currentGeneration!==t.generationIdentity){let i=n.state==="current"?"generation identity changed":"reason"in n?n.reason:`generation state is ${n.state}`;throw new Error(`deferred SCIP publication requires a verified accepted companion: ${i}`)}let r=V(e.outputDb,t.generationIdentity);if(!r?.index||!ut(e.outputScip,r.index))throw new Error("deferred SCIP publication requires the verified accepted index artifact");return r.index}function gt(e,t){return{databaseFileIdentity:N(e),...y(t)?{indexFileIdentity:N(t)}:{}}}function Vn(e,t){let n=f(m(e),t),r=V(e,t);if(!r)throw new Error("Cannot retain recovery artifacts without a valid generation manifest.");let i=f(n,r.database.file),o=r.metadata?f(n,r.metadata.file):void 0;return{generationIdentity:t,databasePath:$n(T(e),i),...o?{metadataPath:$n(T(e),o)}:{}}}function bo(e){if(y(e))for(let t of yt(e,{withFileTypes:!0}))t.isDirectory()&&t.name.endsWith(".tmp")&&J(f(e,t.name),{recursive:!0,force:!0})}function wo(e,t,n=f(T(t),"index.scip")){let r=pt("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(Ae(t)),y(n)&&r.update(`\0${Ae(n)}`),y(e)&&r.update(`\0${L(I(e,"reindex metadata"))}`),r.digest("hex")}function mt(e){Ao(e.databasePath);let t=ct(e.databasePath),n=e.indexPath?e.verifiedIndexArtifact?Eo(e.indexPath,e.verifiedIndexArtifact):ct(e.indexPath):void 0,r=e.metadataPath?ct(e.metadataPath):void 0,i=e.forcedIdentity??Ro(t,n,e.metadataPath),o=f(e.generationRoot,i),a=f(o,we);if(y(a))return xo(e,i,o,t,n);let s=[ge(e.generationRoot)];bo(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;J(c,{recursive:!0,force:!0}),oo(c,{recursive:!0});try{vo(e,c,t,n,r,s);let d=G(f(c,we),{version:Ue,identity:i,database:t,...n?{index:n}:{},...r?{metadata:r}:{}},{spacing:2,trailingNewline:!0});d.directorySync!=="not-requested"&&s.push(d.directorySync),s.push(k(c)),lt(c,o),s.push(k(e.generationRoot))}finally{J(c,{recursive:!0,force:!0})}return{identity:i,directorySync:X(...s)}}function vo(e,t,n,r,i,o){o.push(dt(e.databasePath,f(t,n.file))),r&&e.indexPath&&o.push(dt(e.indexPath,f(t,r.file))),i&&e.metadataPath&&o.push(dt(e.metadataPath,f(t,i.file)))}function xo(e,t,n,r,i){let o=ne(e.generationRoot,t);if(o&&Yn(n,o.database,r)&&Po(n,o.index,i)&&To(n,o.metadata,e.metadataPath))return{identity:t,directorySync:k(e.generationRoot)};throw new Error(`SQLite generation ${t} already exists with different or corrupt artifacts.`)}function Ro(e,t,n){let r=pt("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(e.sha256),t&&r.update(`\0${t.sha256}`),n&&r.update(`\0${L(I(n,"reindex metadata"))}`),r.digest("hex")}function ct(e){return{file:Bn(e),size:_(e).size,sha256:Ae(e)}}function Eo(e,t){if(t.file!==Bn(e)||_(e).size!==t.size)throw new Error(`verified SQLite generation artifact changed before publication: ${e}`);return t}function Ae(e){let t=pt("sha256"),n=ao(e,"r"),r=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=Go(n,r);if(i===0)break;t.update(r.subarray(0,i))}}finally{io(n)}return t.digest("hex")}function Go(e,t){let n=0;for(;n<t.length;){let r=so(e,t,n,t.length-n,null);if(n+=r,r===0)break}return n}function dt(e,t){return me(e,t,{mode:292})}function Yn(e,t,n){let r=f(e,t.file);return t.file===n.file&&t.size===n.size&&t.sha256===n.sha256&&y(r)&&_(r).size===t.size&&Ae(r)===t.sha256}function Po(e,t,n){return!t||!n?t===n:Yn(e,t,n)}function To(e,t,n){if(!t||!n)return t===void 0&&n===void 0;let r=f(e,t.file);return y(r)&&L(I(r,"stored reindex metadata"))===L(I(n,"candidate reindex metadata"))}function Do(e,t){for(let n of["-wal","-shm","-journal"])J(`${t}${n}`,{force:!0});ft(e,t)}function Ao(e){let t=new co(e,{fileMustExist:!0});try{if(t.pragma("wal_checkpoint(TRUNCATE)").some(i=>i.busy!==0))throw new Error(`SQLite publication has an active writer or reader: ${e}`);let r=t.pragma("quick_check");if(r.length!==1||r[0]?.quick_check!=="ok")throw new Error(`SQLite publication rejected an invalid database: ${e}`)}finally{t.close()}}function ft(e,t){J(`${t}.tmp-replace`,{force:!0}),lt(e,`${t}.tmp-replace`),lt(`${t}.tmp-replace`,t)}function ko(e,t,n,r,i){return{version:F,currentGeneration:e,artifactSet:"immutable-v1",stableMirrors:gt(t,n),...r?.previousGeneration?{previousGeneration:r.previousGeneration}:{},...r?.publication?{publication:r.publication}:{},publishedAt:r?.publishedAt??i().toISOString()}}function Lo(e,t){return t?.artifactSet==="immutable-v1"&&!!V(e,t.currentGeneration)}function Co(e,t){return e?t?"retained recovery database is missing":"stable database or metadata no longer matches the published generation":"published immutable generation is missing"}function Oo(e,t){return!(t.stableMirrors&&(t.stableMirrors.databaseFileIdentity!==N(e)||t.stableMirrors.indexFileIdentity!==void 0&&t.stableMirrors.indexFileIdentity!==N(f(T(e),"index.scip"))))}import{createHash as tr,randomUUID as $o}from"crypto";import{existsSync as O,lstatSync as bt,mkdirSync as Q,mkdtempSync as nr,readdirSync as rr,realpathSync as ir,renameSync as $,rmSync as C,statSync as Me}from"fs";import{dirname as It,join as l,resolve as q}from"path";import{setTimeout as Bo}from"timers/promises";import{pathToFileURL as Xn}from"url";import Wo from"better-sqlite3";import{lstatSync as Mo,readdirSync as Fo}from"fs";import{join as jo,relative as No,resolve as ht,sep as _o}from"path";var le=1,St="language-indexes",Jn=["index.db","index.scip","meta.json"],Qn=[St,re,ae];function Le(e){let t=[];for(let n of Jn)qo(e,n),t.push(n);for(let n of Qn)Kn(e,n,t);return{version:le,files:t.sort()}}function Ce(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(!Jn.includes(e)&&!Qn.includes(n))throw new Error(`index artifact path is not shareable: ${e}`);return e}function D(e,t){let n=Ce(t),r=ht(e),i=ht(r,...n.split("/"));if(i!==r&&!i.startsWith(`${r}${_o}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function Kn(e,t,n){let r=jo(e,t),i;try{i=Fo(r,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let a=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${a}`);o.isDirectory()?Kn(e,a,n):o.isFile()&&n.push(Ce(a))}}function qo(e,t){let n=D(e,t),r;try{r=Mo(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(No(ht(e),n).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var wt=1,Zn="SCIP_QUERY_SHARED_CACHE",zo=2,Oe=JSON.stringify({cliVersion:Mt,typescriptSymbolIdentityVersion:6,artifactCatalogVersion:le,postIndexAugmentationSchemaVersion:zo,sqliteGenerationStoreVersion:F,typescriptFragmentStoreVersion:Ye,typescriptOverlayStoreVersion:Ge}),vt="manifest.json",or="shared-cache.json";var xt=[St,re,ae];function Uo(e,t){if(!e.clean||!e.treeOid)return;let n=pr(JSON.stringify({version:wt,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:pe(t),producerIdentity:Oe}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:Oe,generationId:n,repositoryCacheDir:_e(e.repositoryId)}}function kc(e,t,n){if(!ga(n))return!1;let r=Uo(e,n);if(!r)return!1;try{let i=la(t);if(!i||i.repositoryId!==e.repositoryId||i.worktreeId!==e.worktreeId)return!1;let o=JSON.parse(x(l(r.repositoryCacheDir,"worktrees",`${i.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:w}));return Ho(o,i,e,t,r)?B(r,!1)!==null:!1}catch{return!1}}function Ho(e,t,n,r,i){return!(e.version!==1||e.repositoryId!==t.repositoryId||e.worktreeId!==t.worktreeId||q(e.projectRoot)!==q(n.projectRoot)||e.treeOid!==n.treeOid||q(e.localCacheDir)!==q(r)||e.ownershipChecksum!==Rt(e)||e.baseGenerationId!==i.generationId||e.activeGenerationId!==i.generationId)}function Lc(e,t,n){if(process.env[Zn]==="0")return`${Zn}=0`;if(!qe(n))return"explicit cache or database override";if($e(It(t))!==$e(Nt(e))||t!==l(It(t),"index.db"))return"index database is outside the managed worktree cache"}function Cc(e,t,n){if(!qe(t))return;let r=n??kt(e);return r?l(_e(r.repositoryId),"evidence.db"):void 0}function B(e,t=!0){let n=Et(e),r;try{r=sr(x(l(n,vt),{inputKind:"shared-generation manifest",maxBytes:w}))}catch{return null}if(!ma(r,e)||!ca(n))return null;if(!t)return r;try{for(let i of r.artifacts){let o=D(n,i.path),a=Me(o);if(!a.isFile()||a.size!==i.size||z(o,{inputKind:"shared-generation artifact",maxBytes:h})!==i.sha256)return null}}catch{return null}return r}function Oc(e,t,n,r){if(!e.treeOid)return null;let i=Be(t,n),o=l(jt(),"repositories",e.repositoryId),a;try{let d=bt(o);if(!d.isDirectory()||d.isSymbolicLink())return null;a=ir(o)}catch{return null}let s=l(a,"generations"),c=[];try{Vo(s,e,i,c)}catch{return null}c.sort((d,u)=>{let p=d.treeOid===e.treeOid?0:1,g=u.treeOid===e.treeOid?0:1;if(p!==g)return p-g;if(r){let W=er(d.fingerprint,r)-er(u.fingerprint,r);if(W!==0)return W}return Date.parse(u.createdAt)-Date.parse(d.createdAt)||d.generationId.localeCompare(u.generationId)});for(let d of c){let u={repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:d.treeOid,fingerprint:d.fingerprint,producerIdentity:d.producerIdentity,generationId:d.generationId,repositoryCacheDir:a},p=B(u);if(p)return{snapshot:u,manifest:p}}return null}function Vo(e,t,n,r){for(let i of rr(e)){if(!/^[a-f0-9]{64}$/.test(i))continue;let o=l(e,i),a;try{a=bt(o)}catch{continue}if(!(!a.isDirectory()||a.isSymbolicLink()))try{let s=sr(x(l(o,vt),{inputKind:"shared-generation baseline manifest",maxBytes:w}));Yo(s,i,t,n)&&r.push(s)}catch{continue}}}function Yo(e,t,n,r){return e.generationId===t&&e.repositoryId===n.repositoryId&&e.producerIdentity===Oe&&da(e.fingerprint,r)}function Mc(e){let t=M(l(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 Jo(e)}finally{t.release()}}function Jo(e){let t=B(e.snapshot);if(t)return ar(e.snapshot,t);if(!fr(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let n=cr(e.sourceCacheDir);if(!n)throw new Error("source index artifacts are incomplete");let r=Le(e.sourceCacheDir),i=l(e.snapshot.repositoryCacheDir,"generations"),o=[ge(i)],a=nr(l(i,`.tmp-${process.pid}-`));try{let s=Xo(e,r.files,a,o),c=Ko(e,a,n),d={version:wt,artifactCatalogVersion:le,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:s.sort((K,W)=>K.path.localeCompare(W.path))},u=G(l(a,vt),d,{spacing:2,trailingNewline:!0});u.directorySync!=="not-requested"&&o.push(u.directorySync),e.onPublicationStage?.("after-manifest-flushed"),o.push(k(a)),e.onPublicationStage?.("after-staging-directory-synced");let p=Qo(e.snapshot,a);if(p)return p;e.onPublicationStage?.("after-generation-renamed"),o.push(k(i)),e.onPublicationStage?.("after-generations-directory-synced");let g=X(...o);return{kind:"published",manifest:d,achievedDurability:g==="synced"?"directory-durable":"file-flushed",directorySync:g}}finally{C(a,{recursive:!0,force:!0})}}function Qo(e,t){let n=Et(e);try{if(O(n)&&!B(e)){let r=`${n}.corrupt-${process.pid}-${Date.now()}`;$(n,r),C(r,{recursive:!0,force:!0})}$(t,n)}catch(r){let i=B(e);if(i)return ar(e,i);throw r}}function Ko(e,t,n){let r=oe(v(l(t,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:h}));if(!r)throw new Error("shared SCIP generation has no project root metadata");let i=Gt(e.sourceProjectRoot);if(r!==i)throw new Error("shared SCIP generation root does not match its source worktree");if(cr(e.sourceCacheDir)!==n||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");return r}function Xo(e,t,n,r){let i=[];for(let o of t){let a=D(e.sourceCacheDir,o),s=D(n,o);r.push(fe(a,s,292)),e.onPublicationStage?.("after-artifact-flushed",o);let c=Me(s).size;i.push({path:o,size:c,sha256:z(s,{inputKind:"staged shared-generation artifact",maxBytes:h})})}return i}function ar(e,t){let n=k(l(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:n==="synced"?"directory-durable":"file-flushed",directorySync:n}}function Fc(e){let t=Et(e.snapshot);Q(e.targetCacheDir,{recursive:!0});let n=M(l(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{if(r=nr(l(e.targetCacheDir,".shared-hydrate-")),ya(e.manifest,e.snapshot),ea(e.manifest,t,r),ta(e,r),!fr(r,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=ua(e.targetCacheDir,r),o=!0,fa(r,e.targetCacheDir,i),Wn({tempOutputScip:l(r,"index.scip"),tempOutputDb:l(r,"index.db"),tempMetaPath:l(r,"meta.json"),outputScip:l(e.targetCacheDir,"index.scip"),outputDb:l(e.targetCacheDir,"index.db"),metaPath:l(e.targetCacheDir,"meta.json"),now:e.now}),Zo(e.targetCacheDir),e.persistLease!==!1&&na(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(a){throw o&&i&&pa(e.targetCacheDir,i),a}finally{r&&C(r,{recursive:!0,force:!0}),n.release()}}function Zo(e){let t=ke(l(e,"index.db"),l(e,"meta.json"));if(t.state==="invalid"||t.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${t.reason}`)}function ea(e,t,n){for(let r of e.artifacts){let i=D(t,r.path),o=D(n,r.path);if(fe(i,o),Me(o).size!==r.size||z(o,{inputKind:"hydrated shared-generation artifact",maxBytes:h})!==r.sha256)throw new Error(`shared artifact is corrupt: ${r.path}`)}}function ta(e,t){let n=Gt(e.targetProjectRoot);if(n!==e.manifest.scipProjectRoot)for(let r of e.manifest.artifacts)r.path.endsWith(".scip")&&_n(D(t,r.path),e.manifest.scipProjectRoot,n)}async function jc(e,t={}){let n=t.timeoutMs??3e4,r=t.pollMs??100,i=t.now??$t,o=i()+n,a=l(e.repositoryCacheDir,"locks"),s=l(a,`${e.generationId}.lock`);for(;i()<=o;){if(B(e))return{kind:"generation-ready"};let c=Wt(s,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:Bt});if(c.kind==="acquired")return{kind:"owner",release:()=>c.lock.release()};let d=o-i();if(d<=0)break;await Bo(Math.min(r,d))}return B(e)?{kind:"generation-ready"}:{kind:"timeout"}}function na(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:Rt(i)};return lr(e.repositoryCacheDir,o,!0),o}function Nc(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:Rt(r)};return lr(e.repositoryCacheDir,i,!0),i}function Rt(e){return pr(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:q(e.projectRoot),localCacheDir:q(e.localCacheDir)}))}function sr(e){let t=JSON.parse(e);if(!ra(t)||!ia(t))throw new Error("invalid shared generation manifest");if(!oa(t))throw new Error("invalid shared generation manifest");let n=new Set;for(let r of t.artifacts){if(aa(r),Ce(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 ra(e){return e.version===wt&&e.artifactCatalogVersion===le&&typeof e.generationId=="string"&&/^[a-f0-9]{64}$/.test(e.generationId)&&typeof e.repositoryId=="string"&&/^[a-f0-9]{24}$/.test(e.repositoryId)}function ia(e){return typeof e.treeOid=="string"&&e.treeOid!==""&&typeof e.producerIdentity=="string"&&e.producerIdentity===Oe&&typeof e.sourceProjectRoot=="string"&&typeof e.scipProjectRoot=="string"}function oa(e){return typeof e.createdAt=="string"&&Number.isFinite(Date.parse(e.createdAt))&&!!e.fingerprint&&Array.isArray(e.artifacts)}function aa(e){if(!e||typeof e.path!="string"||typeof e.size!="number"||e.size<0||typeof e.sha256!="string"||!/^[a-f0-9]{64}$/.test(e.sha256))throw new Error("invalid shared generation artifact")}function fe(e,t,n=384){return me(e,t,{mode:n})}function sa(e,t,n){Q(e,{recursive:!0}),G(l(e,or),{version:1,repositoryId:t,worktreeId:n},{spacing:2,trailingNewline:!0})}function cr(e){try{let t=Le(e),n=tr("sha256");for(let r of t.files){let i=D(e,r),o=Me(i).size;n.update(r).update("\0").update(String(o)).update("\0"),Tt(i,{inputKind:"source-generation artifact",maxBytes:h},a=>n.update(a)),n.update("\0")}return n.digest("hex")}catch{return null}}function dr(e){try{let t=he(x(l(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:w}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function ca(e){return dr(e)?.scipCompanion!=="deferred"}function da(e,t){if(e.typescriptSymbolIdentityVersion!==t.typescriptSymbolIdentityVersion)return!1;let n=Be(e.languages,e);return JSON.stringify(n)===JSON.stringify(t)}function er(e,t){let n=new Map(e.files.map(o=>[o.path,`${o.size}\0${o.hash}`])),r=new Map(t.files.map(o=>[o.path,`${o.size}\0${o.hash}`])),i=0;for(let[o,a]of n)r.get(o)!==a&&(i+=1);for(let o of r.keys())n.has(o)||(i+=1);return i}function Et(e){return l(e.repositoryCacheDir,"generations",e.generationId)}function la(e){let t=JSON.parse(x(l(e,or),{inputKind:"worktree cache pointer",maxBytes:w}));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 lr(e,t,n){let r=zt(e,{waitMs:5e3});if(!r)throw new Error("repository cache cleanup is busy");try{if(n){let o=t.activeGenerationId??t.baseGenerationId;if(!o||!O(l(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=l(e,"worktrees");Q(i,{recursive:!0}),G(l(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),sa(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{r.release()}}function ua(e,t){let n=l(t,".rollback"),r=new Map,i=new Map;Q(n,{recursive:!0});for(let s of["index.scip","index.db","meta.json"]){let c=l(e,s),d=O(c);r.set(s,d),d&&fe(c,l(n,"stable",s))}for(let s of xt){let c=l(e,s),d=O(c);if(d){let u=bt(c);if(!u.isDirectory()||u.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${s}`)}i.set(s,d)}let o=l(e,te),a=O(o);return a&&ur(o,l(n,"sqlite-generations")),{root:n,stableFiles:r,managedDirectories:i,generationStoreExisted:a}}function fa(e,t,n){for(let r of xt){let i=l(t,r);if(n.managedDirectories.get(r)){let a=l(n.root,"managed",r);Q(It(a),{recursive:!0}),$(i,a)}let o=l(e,r);O(o)&&$(o,i)}}function pa(e,t){for(let i of xt){let o=l(e,i),a=l(t.root,"managed",i);t.managedDirectories.get(i)?O(a)&&(C(o,{recursive:!0,force:!0}),$(a,o)):C(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let a=l(e,i);if(!o){C(a,{force:!0});continue}let s=`${a}.shared-restore-${$o()}`;fe(l(t.root,"stable",i),s),C(a,{force:!0}),$(s,a)}let n=l(e,te);C(n,{recursive:!0,force:!0});let r=l(t.root,"sqlite-generations");t.generationStoreExisted&&O(r)&&$(r,n)}function ur(e,t){Q(t,{recursive:!0});for(let n of rr(e,{withFileTypes:!0})){let r=l(e,n.name),i=l(t,n.name);if(n.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${r}`);n.isDirectory()?ur(r,i):n.isFile()&&fe(r,i)}}function ya(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||!ye(e.fingerprint,t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function fr(e,t,n,r=!0,i=!0){try{let o=dr(e);if(Sa(o,n))return ue("source validation rejected metadata"),!1;let a=Le(e),s=ke(l(e,"index.db"),l(e,"meta.json"));if(r?s.state!=="current":s.state==="invalid"||s.state==="drifted")return ue(`source validation rejected SQLite generation state ${s.state}`),!1;if(!ha(e,i))return!1;let c=Gt(t),u=(i?a.files.filter(p=>p.endsWith(".scip")):["index.scip"]).every(p=>{let g=oe(v(D(e,p),{inputKind:"shared SCIP validation artifact",maxBytes:h}));return g!==c&&ue(`source validation rejected SCIP root for ${p}: ${String(g)}`),g===c});return u||ue("source validation rejected SCIP project roots"),u}catch(o){return ue(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function ue(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function Gt(e){try{return Xn(ir(e)).href}catch{return Xn(q(e)).href}}function ga(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"&&(n.semanticHash===void 0||typeof n.semanticHash=="string"))}function pr(e){return tr("sha256").update(e).digest("hex")}function ma(e,t){return!(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||!ye(e.fingerprint,t.fingerprint))}function ha(e,t){let n=new Wo(l(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(t){if(n.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else n.pragma("schema_version",{simple:!0})}finally{n.close()}return!0}function Sa(e,t){return!e||e.scipCompanion==="deferred"||!ye(Pt(e.fingerprint),t)||JSON.stringify([...e.indexedLanguages??[]].sort())!==JSON.stringify([...t.languages].sort())}export{Ba as a,Wa as b,za as c,Ua as d,Da as e,j as f,Er as g,Aa as h,N as i,S as j,ie as k,xe as l,Zr as m,is as n,os as o,gn as p,as as q,mn as r,fs as s,xs as t,Cs as u,Os as v,Ms as w,Wn as x,uo as y,Ks as z,ke as A,Uo as B,kc as C,Lc as D,Cc as E,B as F,Oc as G,Mc as H,Fc as I,jc as J,na as K,Nc as L,Rt as M};
2
+ //# sourceMappingURL=chunk-BIQEF5NE.js.map
@@ -0,0 +1,3 @@
1
+ import{a as v}from"./chunk-B3PYOSCX.js";import{a as I,b as k,c as R}from"./chunk-QZ7KQZRN.js";import{a as w,b as y}from"./chunk-2HLAFUCY.js";import{i as g}from"./chunk-62BDNPMI.js";import{randomUUID as A}from"crypto";import{closeSync as x,fsyncSync as N,linkSync as _,mkdirSync as C,openSync as T,statSync as M,unlinkSync as q,writeSync as z}from"fs";import{dirname as P}from"path";var F="scip-query-process-lock",m=1,a=Object.freeze({wallNow:()=>Date.now(),isProcessAlive:v,readProcessIdentity:R,randomToken:()=>A(),makeDirectory:e=>C(e,{recursive:!0}),openFile:(e,r,t)=>T(e,r,t),writeFile:(e,r,t,o)=>z(e,r,t,o),syncFile:e=>N(e),closeFile:e=>x(e),linkFile:(e,r)=>_(e,r),readFile:e=>g(e,"process lock record"),statFile:e=>{let r=M(e);return{dev:r.dev,ino:r.ino,size:r.size,mtimeMs:r.mtimeMs}},removeFile:e=>q(e)}),te=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e.pid;return typeof r=="number"&&Number.isSafeInteger(r)&&r>0?{pid:r}:null};function oe(e,r){let t=r.runtime??a;t.makeDirectory(P(e));let o;for(let i=0;i<2;i+=1)try{return{kind:"acquired",lock:O(e,r,t),...o?{reclaimed:o}:{}}}catch(n){if(n.code!=="EEXIST")throw n;let c=d(e,{parseLegacy:r.parseLegacy,runtime:t});if(i===0&&j(e,c,{creationGraceMs:r.creationGraceMs,parseLegacy:r.parseLegacy,runtime:t})){o=c;continue}return{kind:"contended",observation:c}}return{kind:"contended",observation:d(e,{parseLegacy:r.parseLegacy,runtime:t})}}function d(e,r={}){let t=r.runtime??a,o,i;try{o=t.statFile(e),i=t.readFile(e)}catch(l){return l.code==="ENOENT"?{state:"missing"}:{state:"malformed"}}let n;try{n=JSON.parse(i)}catch{return{state:"malformed",raw:i,identity:o}}let c=G(n);if(c)return{state:"valid",raw:i,identity:o,record:c,owner:B(c),parsed:n};let s=r.parseLegacy?.(n)??null;return s?{state:"legacy",raw:i,identity:o,owner:s,parsed:n}:{state:"malformed",raw:i,identity:o,parsed:n}}function G(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e;if(!J(r)||!K(r))return null;let t=h(r);if(!t)return null;let{processIdentity:o}=t;return{protocol:F,version:m,kind:r.kind,pid:r.pid,token:r.token,...o?{processIdentity:o}:{},startedAt:r.startedAt,...r.detail?{detail:r.detail}:{}}}function h(e){let r=e.processIdentity===void 0?null:I(e.processIdentity);return e.processIdentity!==void 0&&(!r||r.pid!==e.pid)?null:{processIdentity:r}}function J(e){return e.protocol===F&&e.version===m&&typeof e.kind=="string"&&e.kind.trim()!==""&&typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0&&typeof e.token=="string"&&e.token.trim()!==""}function K(e){return typeof e.startedAt=="string"&&Number.isFinite(Date.parse(e.startedAt))&&(e.detail===void 0||typeof e.detail=="object"&&e.detail!==null&&!Array.isArray(e.detail))}function j(e,r,t={}){let o=t.runtime??a;if(!f(r,o))return!1;let i=$(`${e}.reclaim`,o);if(!i)return!1;try{let n=d(e,{parseLegacy:t.parseLegacy,runtime:o});return!D(r,n)||!f(n,o)?!1:p(e,o)}finally{i.release()}}function O(e,r,t){let o=r.directoryDurability??"durable",i=r.pid??process.pid,n=t.randomToken(),c=r.processIdentity===void 0?t.readProcessIdentity(i):r.processIdentity,s={protocol:F,version:m,kind:r.kind,pid:i,token:n,...c?{processIdentity:c}:{},startedAt:new Date(t.wallNow()).toISOString(),...r.detail?{detail:r.detail}:{}},l=`${e}.${n}.candidate`;V(l,s,t);try{t.linkFile(l,e)}catch(u){throw L(l,t),u}if(L(l,t),o==="durable")try{E(P(e),t)}catch(u){throw U(e,s,t),u}let b=!1;return{path:e,record:s,release:()=>b?!1:(b=!0,S(e,s,t,o))}}function U(e,r,t=a){return S(e,r,t,"durable")}function S(e,r,t,o){let i=d(e,{runtime:t});return i.state!=="valid"||!i.record||i.record.pid!==r.pid||i.record.token!==r.token||r.processIdentity&&(!i.record.processIdentity||!k(r.processIdentity,i.record.processIdentity))?!1:p(e,t,o)}function $(e,r){for(let t=0;t<2;t+=1)try{return O(e,{kind:"reclaim-guard",runtime:r},r)}catch(o){if(o.code!=="EEXIST"||!X(e,r,t))return null}return null}function f(e,r){if(e.state==="missing")return!1;if(e.owner){if(!r.isProcessAlive(e.owner.pid))return!0;if(!e.owner.processIdentity)return!1;let t=r.readProcessIdentity(e.owner.pid);return t!==null&&!k(e.owner.processIdentity,t)}return!1}function D(e,r){return e.state===r.state&&e.raw===r.raw&&e.identity!==void 0&&r.identity!==void 0&&e.identity.dev===r.identity.dev&&e.identity.ino===r.identity.ino&&e.identity.size===r.identity.size&&e.identity.mtimeMs===r.identity.mtimeMs}function B(e){return{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}}function E(e,r){let t;try{t=r.openFile(e,"r")}catch(o){if(y(o,process.platform))return;throw o}try{r.syncFile(t)}catch(o){if(!y(o,process.platform))throw o}finally{r.closeFile(t)}}function p(e,r,t="durable"){try{return r.removeFile(e),t==="durable"&&E(P(e),r),!0}catch{return!1}}function L(e,r){try{r.removeFile(e)}catch{}}function V(e,r,t){let o=t.openFile(e,"wx",384),i;try{w(o,Buffer.from(`${JSON.stringify(r)}
2
+ `),t,"process lock"),t.syncFile(o)}catch(n){i=n}try{t.closeFile(o)}catch(n){i??=n}if(i!==void 0)throw L(e,t),i}function X(e,r,t){let o=d(e,{runtime:r});if(t>0||!f(o,r))return!1;let i=d(e,{runtime:r});return D(o,i)?p(e,r):!1}export{a,te as b,oe as c,d,j as e};
3
+ //# sourceMappingURL=chunk-BL6XJKTA.js.map
@@ -0,0 +1,2 @@
1
+ import{a as m,b as g}from"./chunk-5PLMJC7Q.js";import{c as u}from"./chunk-NOLZOVCU.js";import{b as d}from"./chunk-GCKCF5FL.js";function b(n,e={}){let{minSimilarity:s=.5,limit:t=20,scope:o,filePattern:l}=e,r=e.minDeps??(l?1:4),{profiles:i,distinctiveDeps:a}=D(n,{scope:o,minDeps:r}),p=m(i,f=>f.deps);return g({profiles:i,limit:t,filePattern:l,overrunFactor:5,candidateIndex:p,profile:{name:"similar-files"},compare:(f,c)=>v(f,c,s,a,r)})}function D(n,e){let{scope:s,minDeps:t}=e,o=d(n),{universalDeps:l,distinctiveDeps:r}=P(o),i=[];for(let[a,p]of o){if(s&&!a.includes(s))continue;let f=new Set([...p].filter(c=>!l.has(c)));f.size>=t&&i.push({file:a,deps:f})}return{profiles:i,distinctiveDeps:r}}function P(n){let e=new Set,s=new Set,t=n.size;if(t===0)return{universalDeps:e,distinctiveDeps:s};let o=new Map;for(let r of n.values())for(let i of r)o.set(i,(o.get(i)??0)+1);let l=Math.max(3,Math.ceil(t*.03));for(let[r,i]of o)i>=5&&i/t>.3?e.add(r):i<=l&&s.add(r);return{universalDeps:e,distinctiveDeps:s}}function v(n,e,s,t,o){let l=new Set;for(let f of n.deps)e.deps.has(f)&&l.add(f);if(l.size<Math.min(3,o))return null;let r=0;for(let f of l)t.has(f)&&r++;if(r<Math.min(2,o))return null;let i=u(n.deps,e.deps);if(i<s)return null;let a=S(n.deps,e.deps),p=S(e.deps,n.deps);return{fileA:n.file,fileB:e.file,similarity:i,evidenceBasis:"filtered-dependency-overlap",sharedDeps:[...l],uniqueToA:a,uniqueToB:p}}function S(n,e){let s=[];for(let t of n)e.has(t)||s.push(t);return s}export{b as a};
2
+ //# sourceMappingURL=chunk-BMKOQJRI.js.map
@@ -0,0 +1,3 @@
1
+ import{a as Ce,b as te,d as we}from"./chunk-TZCVNCAN.js";import{a as Ee}from"./chunk-7VPEEAAG.js";import{a as xe}from"./chunk-PAVGPRHJ.js";import{a as he,c as U}from"./chunk-H73WY2RM.js";import{d as me,y as ye}from"./chunk-ZHMRSZFD.js";import{a as be,d as Se}from"./chunk-KU3QRSTH.js";import{b as pe,c as fe}from"./chunk-CN5EH7O3.js";import{k as de}from"./chunk-J5FJMODQ.js";import{c as ue}from"./chunk-GZKFETP5.js";import{a as ce}from"./chunk-HRRFKWPZ.js";import{c as ge}from"./chunk-YULZRALL.js";import{M as ee}from"./chunk-U5RIG3JP.js";function si(e,t={}){let i=new we(e).productionCallableDefinitions({scope:t.scope,requireCallableSymbol:!0,includeSuppressed:!0}),r=et(e,i),o=t.search?.trim().toLocaleLowerCase();return i.map(s=>tt(e,s,r.get(s.symbolId)??[])).filter(s=>s!==null).map(s=>s.result).filter(s=>!o||it(s).includes(o)).sort(rt)}function et(e,t){let n=t.filter(i=>Fe(e,i.relativePath)||te(e,i.symbol,i.relativePath).length>0);return ye(e,n,{semantic:!1,semanticEvidence:Ee})}function tt(e,t,n){let i=nt(e,t),r=i.length>0,o=Fe(e,t.relativePath)&&n.length===0;if(!r&&!o)return null;let s=[...i];return o&&s.push("entry-surface-without-indexed-caller"),{definition:t,result:{symbol:t.symbol,shortName:ge(t.symbol),file:t.relativePath,startLine:t.startLine,endLine:t.endLine,documentation:t.documentation,confidence:i.some(a=>a!=="package-public-export")?"root":"candidate",evidence:s,observedCallerCount:n.length}}}function Fe(e,t){return Ce(e,t)||/(?:^|\/)entry\.(?:ts|tsx|js|jsx|mjs|cjs)$/.test(t)}function nt(e,t){let n=te(e,t.symbol,t.relativePath),i=[];return Te(n,["package-surface-file","transitive-package-surface"])&&xe(e,t)&&i.push("package-public-export"),n.includes("rust-public-library")&&i.push("rust-public-library"),n.includes("framework-entrypoint")&&i.push("framework-dispatched-export"),Te(n,["configured-file","configured-path-prefix","configured-qualified-var","configured-symbol-pattern"])&&i.push("configured-entry-root"),i}function Te(e,t){return t.some(n=>e.includes(n))}function it(e){return[e.symbol,e.shortName,e.file,e.documentation??"",...e.evidence].join(`
2
+ `).toLocaleLowerCase()}function rt(e,t){return Ae(e.confidence)-Ae(t.confidence)||e.file.localeCompare(t.file)||e.startLine-t.startLine||e.symbol.localeCompare(t.symbol)}function Ae(e){return e==="root"?0:1}import{join as Cn}from"path";import{createRequire as ot}from"module";import{resolve as q}from"path";var st=ot(import.meta.url),O,ve=new Map;function Pe(e,t,n){let i=at();if(!i)return V("The TypeScript compiler runtime is unavailable.");let r=ct(i,Ne(i,e,t)),o=r.getSourceFile(q(t))??r.getSourceFile(t);if(!o)return V(`The TypeScript compiler did not materialize ${t}.`);let s=r.getSyntacticDiagnostics(o);if(s.length)return V(s.map(u=>{let p=o.getLineAndCharacterOfPosition(u.start??0);return`TypeScript syntax error at ${t}:${p.line+1}: ${i.flattenDiagnosticMessageText(u.messageText," ")}`}).join("; "));let a={ts:i,sourceFile:o,checker:r.getTypeChecker(),points:new Map,edges:new Map,unsupported:new Set,nextCfgId:0},l=pt(i,o,n);if(l.length===0)return V("No function-like construct intersects the selected source range.");let c=new Map(l.map(u=>[u,mt(o,u)])),d=l.map(u=>yt(a,u,gt(i,u,c),c.get(u)));for(let u of d)Mt(a,u),en(a,u),sn(a,u);un(a,d);let f=[...a.unsupported].sort();return{points:[...a.points.values()].map(({node:u,...p})=>p).sort(gn),edges:[...a.edges.values()].sort((u,p)=>u.id.localeCompare(p.id)),coverage:{status:f.length===0?"complete":"partial",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:f}}}function at(){if(O!==void 0)return O;try{O=st("typescript")}catch{O=fe()?.ts??null}return O}var ne=null,G=null,ie=null;function Ie(e){return ne||(ne={target:e.ScriptTarget.ESNext,module:e.ModuleKind.ESNext,moduleResolution:e.ModuleResolutionKind.Bundler,skipLibCheck:!0,noResolve:!0,libReplacement:!1}),ne}var I=new Map,lt=8;function Ne(e,t,n){let i=q(n),r=I.get(i);if(r&&r.text===t)return I.delete(i),I.set(i,r),r.sourceFile;let o=e.createSourceFile(i,t,Ie(e).target,!0,dt(e,i));for(I.set(i,{text:t,sourceFile:o});I.size>lt;){let s=I.keys().next().value;if(s===void 0)break;I.delete(s)}return o}function ct(e,t){let n=t.fileName,i=t.text,r=Ie(e),o=e.createCompilerHost(r,!0),s=o.getSourceFile.bind(o),a=o.readFile.bind(o),l=o.fileExists.bind(o);if(!G||!ie){let u=o.getCurrentDirectory(),p=o.getCanonicalFileName.bind(o);G=e.createModuleResolutionCache(u,p,r),ie=e.createTypeReferenceDirectiveResolutionCache(u,p,r,G.getPackageJsonInfoCache())}let c=G,d=ie;r.types===void 0&&(r.types=e.getAutomaticTypeDirectiveNames(r,o)),o.getModuleResolutionCache=()=>c;let f=new Set(r.types??[]);return o.resolveModuleNameLiterals=(u,p,y,S,b)=>u.map(g=>f.has(ut(g.text))?e.resolveModuleName(g.text,p,S,o,c,y,e.getModeForUsageLocation(b,g,S)):{resolvedModule:void 0}),o.resolveTypeReferenceDirectiveReferences=(u,p,y,S)=>u.map(b=>e.resolveTypeReferenceDirective(typeof b=="string"?b:b.fileName,p,S,o,y,d)),o.getSourceFile=(u,p,y,S)=>{if(q(u)===n)return t;let b=ve.get(u);if(b)return b;let g=s(u,p,y,S);return g&&ve.set(u,g),g},o.readFile=u=>q(u)===n?i:a(u),o.fileExists=u=>q(u)===n||l(u),e.createProgram([n],r,o)}function ut(e){if(e.startsWith(".")||e.startsWith("/"))return"";let t=e.split("/");return e.startsWith("@")?t.length>=2?`${t[0].slice(1)}__${t[1]}`:"":t[0]??""}function dt(e,t){return/\.tsx$/iu.test(t)?e.ScriptKind.TSX:/\.[cm]?js$/iu.test(t)?e.ScriptKind.JS:/\.jsx$/iu.test(t)?e.ScriptKind.JSX:e.ScriptKind.TS}function pt(e,t,n){let i=[],r=(o,s=!1)=>{if(ke(e,o)){let a=t.getLineAndCharacterOfPosition(o.getStart(t)).line,l=t.getLineAndCharacterOfPosition(o.getEnd()).line;s||=!n||ft(t,o,a,l,n),s&&i.push(o)}o.forEachChild(a=>r(a,s))};return t.forEachChild(r),i.sort((o,s)=>o.getStart(t)-s.getStart(t))}function ft(e,t,n,i,r){if(r.startColumn===void 0||r.endColumn===void 0)return n<=r.endLine&&i>=r.startLine;let o=e.getPositionOfLineAndCharacter(r.startLine,r.startColumn),s=e.getPositionOfLineAndCharacter(r.endLine,r.endColumn);return(t.name??t).getStart(e)>=o&&t.end<=s}function ke(e,t){return e.isFunctionLike(t)&&"body"in t&&t.body!==void 0}function mt(e,t){return`callable:${encodeURIComponent(e.fileName)}:${t.getStart(e)}:${t.getEnd()}`}function gt(e,t,n){for(let i=t.parent;i;i=i.parent)if(ke(e,i)&&n.has(i))return n.get(i);return null}function yt(e,t,n,i){let r=new Map,o=E(e,r,"exit",null),s=t.body,a=o.id;if(s&&e.ts.isBlock(s))a=B(e,r,[...s.statements],o.id,{breakTarget:null,continueTarget:null,throwTarget:null,exitId:o.id});else if(s){let c=E(e,r,"statement",s);h(r,c.id,o.id),a=c.id}let l=E(e,r,"entry",t);return h(r,l.id,a),{id:i,node:t,parentId:n,cfg:r,entryId:l.id,exitId:o.id}}function B(e,t,n,i,r){let o=i;for(let s=n.length-1;s>=0;s-=1)o=L(e,t,n[s],o,r);return o}function L(e,t,n,i,r){let o=e.ts;if(o.isBlock(n))return B(e,t,[...n.statements],i,r);if(o.isIfStatement(n))return ht(e,t,n,i,r);let s=Sn(e,t,n,i,r);return s!==null?s:o.isSwitchStatement(n)?Et(e,t,n,i,r):o.isTryStatement(n)?Tt(e,t,n,i,r):o.isExpressionStatement(n)?z(e,t,n.expression,i):xt(e,t,n,i,r)??wt(e,t,n,i)}function ht(e,t,n,i,r){let o=E(e,t,"predicate",n.expression),s=L(e,t,n.thenStatement,i,r),a=n.elseStatement?L(e,t,n.elseStatement,i,r):i;return h(t,o.id,s),h(t,o.id,a),o.id}function bt(e,t,n,i,r){let o=E(e,t,"predicate",n.expression),s=L(e,t,n.statement,o.id,{...r,breakTarget:i,continueTarget:o.id});return h(t,o.id,s),h(t,o.id,i),e.ts.isDoStatement(n)?s:o.id}function St(e,t,n,i,r){let o=E(e,t,"predicate",n.condition??n),s=n.incrementor?E(e,t,"statement",n.incrementor):null;s&&h(t,s.id,o.id);let a=s?.id??o.id,l=L(e,t,n.statement,a,{...r,breakTarget:i,continueTarget:a});if(h(t,o.id,l),n.condition&&h(t,o.id,i),!n.initializer)return o.id;let c=E(e,t,"statement",n.initializer);return h(t,c.id,o.id),c.id}function Ct(e,t,n,i,r){e.unsupported.add("for-in/for-of loop variables are drawn from the iterable as a whole; per-element flow is not modeled.");let o=E(e,t,"predicate",n.expression),s=E(e,t,"statement",n.initializer),a=L(e,t,n.statement,o.id,{...r,breakTarget:i,continueTarget:o.id});return h(t,o.id,s.id),h(t,o.id,i),h(t,s.id,a),o.id}function Et(e,t,n,i,r){e.unsupported.add("switch fallthrough is represented conservatively; discriminant-to-case value refinement is unsupported.");let o=E(e,t,"predicate",n.expression),s=i,a=[];for(let l=n.caseBlock.clauses.length-1;l>=0;l-=1){let c=n.caseBlock.clauses[l];s=B(e,t,[...c.statements],s,{...r,breakTarget:i}),a.push(s)}for(let l of a)h(t,o.id,l);return h(t,o.id,i),o.id}function xt(e,t,n,i,r){let o=e.ts;if(o.isReturnStatement(n)||o.isThrowStatement(n)){let s=E(e,t,"statement",n),a=o.isThrowStatement(n)?r.throwTarget??r.exitId:r.exitId;return h(t,s.id,a),s.id}if(o.isBreakStatement(n)||o.isContinueStatement(n)){let s=o.isBreakStatement(n)?"break":"continue",a=r[`${s}Target`],l=E(e,t,"statement",n);return a||e.unsupported.add(`A ${s} statement could not be attached to a structured target.`),h(t,l.id,a??i),l.id}return null}function wt(e,t,n,i){let r=E(e,t,"statement",n);return h(t,r.id,i),r.id}function z(e,t,n,i){let r=e.ts;if(r.isParenthesizedExpression(n))return z(e,t,n.expression,i);if(r.isConditionalExpression(n)){let s=E(e,t,"predicate",n.condition);return h(t,s.id,z(e,t,n.whenTrue,i)),h(t,s.id,z(e,t,n.whenFalse,i)),s.id}if(r.isBinaryExpression(n)&&De(r,n.operatorToken.kind)){let s=E(e,t,"predicate",n.left);return h(t,s.id,i),h(t,s.id,z(e,t,n.right,i)),s.id}let o=E(e,t,"statement",n);return h(t,o.id,i),o.id}function De(e,t){return t===e.SyntaxKind.AmpersandAmpersandToken||t===e.SyntaxKind.BarBarToken||t===e.SyntaxKind.QuestionQuestionToken}function Tt(e,t,n,i,r){let o=e.ts,s=n.finallyBlock?B(e,t,[...n.finallyBlock.statements],i,r):null,a=s??i,{catchEntry:l,catchNodes:c}=At(e,t,n.catchClause,a,s,r),d=l??s??r.throwTarget,f=new Set(t.keys()),u=B(e,t,[...n.tryBlock.statements],a,{...r,throwTarget:d}),p=[...t.keys()].filter(S=>!f.has(S)),y=E(e,t,"statement",null);return h(t,y.id,u),d&&(h(t,y.id,d),Me(e,t,p,d)),s&&l&&Me(e,t,c,s),n.finallyBlock&&vt(o,n.tryBlock,n.catchClause?.block)&&e.unsupported.add("A finally block after return, break, or continue inside its try or catch is not sequenced in the local compiler CFG."),y.id}function At(e,t,n,i,r,o){let s=null,a=[];if(n){let l=new Set(t.keys()),c={...o,throwTarget:r??o.throwTarget},d=B(e,t,[...n.block.statements],i,c);if(s=d,n.variableDeclaration){let f=E(e,t,"statement",n.variableDeclaration);h(t,f.id,d),s=f.id}a=[...t.keys()].filter(f=>!l.has(f))}return{catchEntry:s,catchNodes:a}}function Me(e,t,n,i){for(let r of n)Ft(e,t.get(r))&&h(t,r,i)}function Ft(e,t){let n=t.ast;if(!n||t.kind==="exit"||t.kind==="entry")return!1;let i=e.ts;return!(i.isReturnStatement(n)||i.isThrowStatement(n)||i.isBreakOrContinueStatement(n))}function vt(e,...t){let n=!1,i=r=>{if(!(n||e.isFunctionLike(r))){if(e.isReturnStatement(r)||e.isBreakOrContinueStatement(r)){n=!0;return}r.forEachChild(i)}};for(let r of t)r&&i(r);return n}function E(e,t,n,i){let r={id:`cfg:${e.nextCfgId++}`,kind:n,ast:i,successors:new Set,predecessors:new Set,definitions:[],uses:[],displayPoint:null,invalidatesAllDefinitions:!1};return t.set(r.id,r),r}function h(e,t,n){e.get(t).successors.add(n),e.get(n).predecessors.add(t)}function Mt(e,t){let n=t.cfg.get(t.entryId);yn(e,t,n);for(let i of t.cfg.values())!i.ast||i.kind==="entry"||i.kind==="exit"||(i.kind==="predicate"&&(i.displayPoint=W(e,i.ast,"predicate",null,"predicate",t.id)),Nt(e,t,i,i.ast),Rt(e,i,i.ast),!i.displayPoint&&i.definitions.length===0&&i.uses.length===0&&(i.displayPoint=W(e,i.ast,"statement",null,fn(e,i.ast),t.id)))}function Rt(e,t,n){let i=e.ts,r=o=>{if(!i.isFunctionLike(o)){if(i.isClassDeclaration(o)||i.isClassExpression(o)){Pt(i,o)&&(e.unsupported.add("Class initialization, static blocks, and computed members can execute effects outside the local control-flow model."),t.invalidatesAllDefinitions=!0);return}It(e,o)&&(e.unsupported.add("Direct eval can read and write lexical bindings; its dynamically parsed source is not modeled."),t.invalidatesAllDefinitions=!0),o.forEachChild(r)}};r(n)}function Pt(e,t){return!!t.heritageClauses?.length||t.members.some(n=>e.isClassStaticBlockDeclaration(n)||e.isPropertyDeclaration(n)&&!!n.initializer||!!n.name&&e.isComputedPropertyName(n.name))}function It(e,t){let n=e.ts;return!n.isCallExpression(t)||!n.isIdentifier(t.expression)||t.expression.text!=="eval"?!1:(e.checker.getSymbolAtLocation(t.expression)?.declarations??[]).every(r=>r.getSourceFile().isDeclarationFile)}function Nt(e,t,n,i){let r=e.ts,o=s=>{if(!(s!==i&&r.isFunctionLike(s))&&!kt(e,t,n,s)&&!(r.isFunctionDeclaration(s)||r.isClassDeclaration(s)||r.isInterfaceDeclaration(s))){if($e(e,s)){let a=je(e,t.id,s);a&&n.uses.push(a),r.isPropertyAccessExpression(s)&&o(s.expression);return}s.forEachChild(o)}};o(i),n.uses=We(n.uses)}function kt(e,t,n,i){let r=e.ts;if(r.isVariableDeclaration(i))Bt(e,t,n,i);else if(Dt(r,i))n.uses.push(...v(e,t.id,i,n));else if(r.isBinaryExpression(i)&&qe(r,i.operatorToken.kind))Lt(e,t,n,i);else if(Be(r,i))$t(e,t,n,i);else if(r.isDeleteExpression(i))Le(e,n);else return!1;return!0}function Dt(e,t){return e.isConditionalExpression(t)||e.isBinaryExpression(t)&&De(e,t.operatorToken.kind)}function Bt(e,t,n,i){let r=e.ts,o=i.initializer??Xt(r,i);oe(e,i.initializer);let s=o?v(e,t.id,o,n):[],a=se(e,i.name,l=>s.push(...v(e,t.id,l,n)));if(n.uses.push(...s),a.length===0&&r.isIdentifier(i.name)){n.invalidatesAllDefinitions=!0,e.unsupported.add("A variable declaration could not be resolved to a compiler symbol.");return}re(e,t.id,n,a,s)}function Lt(e,t,n,i){let r=e.ts;i.operatorToken.kind===r.SyntaxKind.EqualsToken&&oe(e,i.right);let o=v(e,t.id,i.right,n);i.operatorToken.kind!==r.SyntaxKind.EqualsToken&&o.push(...v(e,t.id,i.left,n));let s=R(e,t.id,i.left,n,o);if(n.uses.push(...o),!s){n.invalidatesAllDefinitions=!0,e.unsupported.add("Dynamic assignment targets are not included in reaching definitions.");return}re(e,t.id,n,s,o)}function $t(e,t,n,i){let r=v(e,t.id,i.operand,n),o=R(e,t.id,i.operand,n,r)??[];n.uses.push(...r),re(e,t.id,n,o,r)}function re(e,t,n,i,r){let o=r.map(s=>s.point.id);for(let s of i)n.definitions.push({point:W(e,s.node,"definition",s.symbolKey,s.name,t),rhsUseIds:o,partial:s.partial??!1})}function v(e,t,n,i){let r=[],o=s=>{if(!e.ts.isFunctionLike(s)){if(e.ts.isDeleteExpression(s)){Le(e,i);return}if(Be(e.ts,s)){i.invalidatesAllDefinitions=!0;let a=e.sourceFile.getLineAndCharacterOfPosition(s.getStart(e.sourceFile));e.unsupported.add(`Nested increment/decrement at ${e.sourceFile.fileName}:${a.line+1} is not included in ordered local definition-use flow.`),o(s.operand);return}if(e.ts.isBinaryExpression(s)&&qe(e.ts,s.operatorToken.kind)){i.invalidatesAllDefinitions=!0,e.unsupported.add("Nested assignment expressions are not included in ordered local definition-use flow."),s.operatorToken.kind!==e.ts.SyntaxKind.EqualsToken&&o(s.left),o(s.right);return}if($e(e,s)){let a=je(e,t,s);a&&r.push(a),e.ts.isPropertyAccessExpression(s)&&o(s.expression);return}s.forEachChild(o)}};return o(n),We(r)}function Be(e,t){return(e.isPrefixUnaryExpression(t)||e.isPostfixUnaryExpression(t))&&(t.operator===e.SyntaxKind.PlusPlusToken||t.operator===e.SyntaxKind.MinusMinusToken)}function oe(e,t){if(!t)return;let n=jt(e.ts,t);if(n){for(let r of n)oe(e,r);return}if(!J(e,t)||!Ot(e,t))return;let i=e.sourceFile.getLineAndCharacterOfPosition(t.getStart(e.sourceFile));e.unsupported.add(`Object alias at ${e.sourceFile.fileName}:${i.line+1} is not included in local points-to flow.`)}function jt(e,t){if(e.isObjectLiteralExpression(t))return t.properties.map(i=>Kt(e,i));if(e.isArrayLiteralExpression(t))return t.elements.map(i=>e.isSpreadElement(i)?i.expression:i);if(e.isConditionalExpression(t))return[t.whenTrue,t.whenFalse];let n=Ut(e,t);return n?[n]:void 0}function Kt(e,t){if(e.isPropertyAssignment(t))return t.initializer;if(e.isShorthandPropertyAssignment(t))return t.name;if(e.isSpreadAssignment(t))return t.expression}function Ut(e,t){if(e.isParenthesizedExpression(t)||e.isAsExpression(t)||e.isSatisfiesExpression(t)||e.isNonNullExpression(t)||e.isTypeAssertionExpression(t))return t.expression}function Le(e,t){t.invalidatesAllDefinitions=!0,e.unsupported.add("Property deletion is not included in local mutation flow; prior reaching definitions are invalidated.")}function Ot(e,t){let n=e.ts,i=e.checker.getTypeAtLocation(t);return(i.isUnionOrIntersection()?i.types:[i]).some(o=>(o.flags&(n.TypeFlags.Object|n.TypeFlags.Any|n.TypeFlags.Unknown|n.TypeFlags.TypeParameter|n.TypeFlags.NonPrimitive))!==0)}function $e(e,t){if(e.ts.isPropertyAccessExpression(t))return!0;if(!e.ts.isIdentifier(t))return!1;let n=t.parent;return!(zt(e.ts,t)||e.ts.isLabeledStatement(n)||e.ts.isBreakOrContinueStatement(n)||Wt(e.ts,t))}function zt(e,t){let n=t.parent;return!!(e.isPropertyAccessExpression(n)&&n.name===t||"name"in n&&n.name===t&&qt(e,n)||e.isPropertyAssignment(n)&&n.name===t||e.isBindingElement(n)&&n.propertyName===t)}function qt(e,t){return e.isVariableDeclaration(t)||e.isParameter(t)||e.isFunctionDeclaration(t)||e.isFunctionExpression(t)||e.isClassDeclaration(t)||e.isMethodDeclaration(t)||e.isPropertyDeclaration(t)||e.isInterfaceDeclaration(t)||e.isTypeAliasDeclaration(t)||hn(e,t)}function Wt(e,t){for(let n=t.parent;n;n=n.parent){if(e.isExpression(n)||e.isStatement(n)||e.isSourceFile(n))return!1;if(e.isTypeNode(n))return!0}return!1}function je(e,t,n){let i=j(e,n);return i?{point:W(e,i.node,"use",i.symbolKey,i.name,t),property:e.ts.isPropertyAccessExpression(n)}:null}function se(e,t,n){let i=e.ts;if(i.isIdentifier(t)){let o=j(e,t);return o?[o]:[]}let r=[];for(let o of t.elements)i.isOmittedExpression(o)||(o.initializer&&n&&n(o.initializer),r.push(...se(e,o.name,n)));return r}function R(e,t,n,i,r){let o=e.ts,s=_t(o,n);if(s)return R(e,t,s,i,r);if(o.isIdentifier(n)||o.isPropertyAccessExpression(n)){let a=j(e,n);return a?[{...a,partial:!1}]:null}return o.isElementAccessExpression(n)?Ht(e,t,n,i,r):o.isObjectLiteralExpression(n)?Gt(e,t,n,i,r):o.isArrayLiteralExpression(n)?Jt(e,t,n,i,r):null}function _t(e,t){return e.isParenthesizedExpression(t)||e.isAsExpression(t)||e.isTypeAssertionExpression(t)||e.isNonNullExpression(t)?t.expression:null}function Ht(e,t,n,i,r){let o=j(e,n.expression);return o?(r.push(...v(e,t,n.expression,i)),r.push(...v(e,t,n.argumentExpression,i)),[{node:n,symbolKey:o.symbolKey,name:`${o.name}[\u2026]`,partial:!0}]):null}function Gt(e,t,n,i,r){let o=[];for(let s of n.properties){let a=Vt(e,t,s,i,r);if(!a)return null;o.push(...a)}return o}function Vt(e,t,n,i,r){let o=e.ts;if(o.isShorthandPropertyAssignment(n)){let s=e.checker.getShorthandAssignmentValueSymbol(n),a=s?Ke(e,s):null,l=a?[{node:n.name,symbolKey:a,name:n.name.text,partial:!1}]:null;return n.objectAssignmentInitializer&&r.push(...v(e,t,n.objectAssignmentInitializer,i)),l}return o.isPropertyAssignment(n)?R(e,t,n.initializer,i,r):o.isSpreadAssignment(n)?R(e,t,n.expression,i,r):null}function Jt(e,t,n,i,r){let o=e.ts,s=[];for(let a of n.elements){if(o.isOmittedExpression(a))continue;let l;if(o.isSpreadElement(a)?l=R(e,t,a.expression,i,r):o.isBinaryExpression(a)&&a.operatorToken.kind===o.SyntaxKind.EqualsToken?(r.push(...v(e,t,a.right,i)),l=R(e,t,a.left,i,r)):l=R(e,t,a,i,r),!l)return null;s.push(...l)}return s}function Xt(e,t){let n=t.parent;if(!n||!e.isVariableDeclarationList(n))return null;let i=n.parent;return i&&(e.isForOfStatement(i)||e.isForInStatement(i))&&i.initializer===n?i.expression:null}function j(e,t){let n=e.ts;if(n.isIdentifier(t)){let i=Yt(e,t);return i?{node:t,symbolKey:i,name:t.text}:null}if(n.isPropertyAccessExpression(t)){let i=J(e,t.expression);return i?{node:t,symbolKey:`${i.symbolKey}.${t.name.text}`,name:t.getText(e.sourceFile)}:null}return t.kind===n.SyntaxKind.ThisKeyword?{node:t,symbolKey:Qt(e,t),name:"this"}:bn(n,t)?j(e,t.expression):((n.isArrayLiteralExpression(t)||n.isObjectLiteralExpression(t))&&e.unsupported.add("Heap aggregate identity and destructured assignment are not included in local points-to flow."),null)}function J(e,t){let n=e.ts;return n.isIdentifier(t)||n.isPropertyAccessExpression(t)||t.kind===n.SyntaxKind.ThisKeyword?j(e,t):n.isParenthesizedExpression(t)||n.isNonNullExpression(t)||n.isAsExpression(t)||n.isTypeAssertionExpression(t)||n.isSatisfiesExpression(t)?J(e,t.expression):null}function Qt(e,t){let n=e.ts,i=encodeURIComponent(e.sourceFile.fileName);for(let r=t.parent;r;r=r.parent)if(!n.isArrowFunction(r)){if(n.isClassLike(r))return`symbol:${i}:${r.getStart(e.sourceFile)}:this`;if(n.isFunctionLike(r)){let o=r.parent;return o&&(n.isClassLike(o)||n.isObjectLiteralExpression(o))?`symbol:${i}:${o.getStart(e.sourceFile)}:this`:`symbol:${i}:${r.getStart(e.sourceFile)}:this`}}return`symbol:${i}:0:this`}function Yt(e,t){let n=t.parent,i=n&&e.ts.isShorthandPropertyAssignment(n)&&n.name===t?e.checker.getShorthandAssignmentValueSymbol(n)??e.checker.getSymbolAtLocation(t):e.checker.getSymbolAtLocation(t);return i?Ke(e,i):null}function Ke(e,t){let n=t;if((n.flags&e.ts.SymbolFlags.Alias)!==0)try{n=e.checker.getAliasedSymbol(n)}catch{}let i=n.valueDeclaration??n.declarations?.[0];return i?`symbol:${encodeURIComponent(i.getSourceFile().fileName)}:${i.getStart()}:${n.getName()}`:`symbol:${n.getName()}`}function W(e,t,n,i,r,o){let s=t.getStart(e.sourceFile),a=t.getEnd(),l=e.sourceFile.getLineAndCharacterOfPosition(s),c=`flow-point:${encodeURIComponent(e.sourceFile.fileName)}:${s}:${a}:${n}:${encodeURIComponent(i??r)}`,d=e.points.get(c);if(d)return d;let f={id:c,kind:n,name:r,symbolKey:i,callableId:o,start:s,end:a,line:l.line,column:l.character,node:t};return e.points.set(c,f),f}function D(e){return new Uint32Array(e+31>>>5)}function Ue(e,t){return(e[t>>>5]&1<<(t&31))!==0}function X(e,t){e[t>>>5]|=1<<(t&31)}function Zt(e,t){for(let n=0;n<e.length;n+=1){let i=e[n];for(;i!==0;){let r=i&-i;t((n<<5)+(31-Math.clz32(r))),i^=r}}}function Oe(e,t,n){let i=new Set,r=[],o=[],s=l=>{i.add(l),o.push({id:l,successors:[...n(e.get(l))],cursor:0})};for(s(t);o.length>0;){let l=o[o.length-1];if(l.cursor<l.successors.length){let c=l.successors[l.cursor];l.cursor+=1,i.has(c)||s(c)}else r.push(l.id),o.pop()}let a=r.reverse();for(let l of e.keys())i.has(l)||a.push(l);return a}function en(e,t){let n=[...t.cfg.values()].flatMap(g=>g.definitions),i=new Map;n.forEach((g,C)=>i.set(g.point.id,C));let r=rn(n),o=new Map;for(let[g,C]of r)o.set(g,C.map(T=>i.get(T.point.id)));let s=Oe(t.cfg,t.entryId,g=>g.successors),a=new Map;s.forEach((g,C)=>a.set(g,C));let l=s.map(g=>t.cfg.get(g)),c=n.length,d=l.map(()=>D(c)),f=l.map(()=>D(c));l.forEach((g,C)=>{for(let T of on(g.definitions)){if(!T.partial)for(let A of o.get(T.point.symbolKey)??[])X(f[C],A);X(d[C],i.get(T.point.id))}});let u=l.map(()=>D(c)),p=l.map(()=>D(c)),y=new Uint8Array(l.length).fill(1),S=l.map((g,C)=>C),b=0;for(;b<S.length;){let g=S[b];b+=1,y[g]=0;let C=l[g],T=u[g];T.fill(0),tn(C,a,p,T),nn(C,T,p[g],d[g],f[g])&&ze(C.successors,a,y,S)}l.forEach((g,C)=>{let T=u[C];for(let A of g.uses){let M=g.definitions.filter(w=>w.point.symbolKey===A.point.symbolKey&&w.point.start<A.point.start&&!w.rhsUseIds.includes(A.point.id)).sort((w,H)=>H.point.start-w.point.start)[0],x=M?[M]:(o.get(A.point.symbolKey??"")??[]).filter(w=>Ue(T,w)).map(w=>n[w]);for(let w of x)$(e,"reaching-definition",w.point.id,A.point.id,"exact","A CFG path reaches this use without an intervening definition.")}for(let A of g.definitions)for(let M of A.rhsUseIds)$(e,"value-source",M,A.point.id,"exact","This right-hand-side use supplies the new definition.")})}function tn(e,t,n,i){for(let r of e.predecessors){let o=n[t.get(r)];for(let s=0;s<o.length;s+=1)i[s]|=o[s]}}function nn(e,t,n,i,r){let o=!1;for(let s=0;s<n.length;s+=1){let a=(e.invalidatesAllDefinitions?i[s]:t[s]&~r[s]|i[s])>>>0;a!==n[s]&&(n[s]=a,o=!0)}return o}function ze(e,t,n,i){for(let r of e){let o=t.get(r);n[o]===0&&(n[o]=1,i.push(o))}}function rn(e){let t=new Map;for(let n of e){if(!n.point.symbolKey)continue;let i=t.get(n.point.symbolKey)??[];i.push(n),t.set(n.point.symbolKey,i)}return t}function on(e){let t=new Map;for(let n of e)n.point.symbolKey&&t.set(n.point.symbolKey,n);return[...t.values()]}function sn(e,t){let{order:n,sets:i}=an(t),r=new Map;n.forEach((s,a)=>r.set(s,a));let o=r.get(t.exitId);for(let s of t.cfg.values()){if(s.kind!=="predicate"||!s.displayPoint)continue;for(let l of s.uses)$(e,"value-source",l.point.id,s.displayPoint.id,"exact","The predicate evaluates this variable occurrence to choose its control-flow successor.");if(s.successors.size<2)continue;let a=i[r.get(s.id)];for(let l of s.successors)Zt(i[r.get(l)],c=>{if(c===o||Ue(a,c))return;let d=t.cfg.get(n[c]),f=[...d.definitions.map(u=>u.point),...d.uses.map(u=>u.point),...d.displayPoint?[d.displayPoint]:[]];for(let u of mn(f))$(e,"control-dependence",s.displayPoint.id,u.id,"exact","The target postdominates a branch successor but does not postdominate the predicate.")})}}function an(e){let t=Oe(e.cfg,e.exitId,f=>f.predecessors),n=new Map;t.forEach((f,u)=>n.set(f,u));let i=t.length,r=n.get(e.exitId),o=t.map((f,u)=>{let p=D(i);if(u===r)X(p,u);else{p.fill(4294967295);let y=p.length*32-i;y>0&&(p[p.length-1]=4294967295>>>y)}return p}),s=t.map(f=>e.cfg.get(f)),a=new Uint8Array(i).fill(1),l=s.map((f,u)=>u),c=0,d=D(i);for(;c<l.length;){let f=l[c];if(c+=1,a[f]=0,f===r)continue;let u=s[f];u.successors.size===0||(d.fill(4294967295),ln(u,n,o,d),X(d,f),!cn(o[f],d))||ze(u.predecessors,n,a,l)}return{order:t,sets:o}}function ln(e,t,n,i){for(let r of e.successors){let o=n[t.get(r)];for(let s=0;s<i.length;s+=1)i[s]&=o[s]}}function cn(e,t){let n=!1;for(let i=0;i<e.length;i+=1)t[i]!==e[i]&&(e[i]=t[i],n=!0);return n}function un(e,t){let n=new Map(t.map(r=>[r.id,r.parentId])),i=dn(t);for(let r of t)for(let o of[...r.cfg.values()].flatMap(s=>s.uses))o.point.symbolKey&&pn(e,o,i.get(o.point.symbolKey)??[],n);[...e.edges.values()].some(r=>r.kind==="closure-capture")&&e.unsupported.add("Closure capture identity is known, but invocation order and intervening writes remain candidate flow."),[...e.edges.values()].some(r=>r.kind==="field-definition-to-use")&&e.unsupported.add("Cross-callable field flow lacks receiver points-to and invocation-order analysis.")}function dn(e){let t=e.flatMap(i=>[...i.cfg.values()].flatMap(r=>r.definitions.map(o=>o.point))),n=new Map;for(let i of t){if(!i.symbolKey)continue;let r=n.get(i.symbolKey)??[];r.push(i),n.set(i.symbolKey,r)}return n}function pn(e,t,n,i){for(let r of n)Re(r.callableId,t.point.callableId,i)||Re(t.point.callableId,r.callableId,i)?$(e,"closure-capture",r.id,t.point.id,"candidate","Compiler identity proves a shared lexical binding, but closure invocation and intervening writes remain unresolved."):t.property&&r.callableId!==t.point.callableId&&$(e,"field-definition-to-use",r.id,t.point.id,"candidate","Compiler identity matches the field; cross-callable receiver and execution order remain unresolved.")}function Re(e,t,n){for(let i=n.get(t)??null;i;i=n.get(i)??null)if(i===e)return!0;return!1}function $(e,t,n,i,r,o){let s=`local-flow-edge:${t}:${encodeURIComponent(n)}:${encodeURIComponent(i)}`;e.edges.set(s,{id:s,kind:t,fromPointId:n,toPointId:i,strength:r,reason:o})}function qe(e,t){return t>=e.SyntaxKind.FirstAssignment&&t<=e.SyntaxKind.LastAssignment}function fn(e,t){let n=t.getText(e.sourceFile).replace(/\s+/gu," ").trim();return n.length>80?`${n.slice(0,77)}...`:n||e.ts.SyntaxKind[t.kind]||"statement"}function We(e){return[...new Map(e.map(t=>[t.point.id,t])).values()]}function mn(e){return[...new Map(e.map(t=>[t.id,t])).values()]}function gn(e,t){return e.start-t.start||e.kind.localeCompare(t.kind)||e.id.localeCompare(t.id)}function V(e){return{points:[],edges:[],coverage:{status:"unsupported",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:[e]}}}function yn(e,t,n){for(let i of t.node.parameters){let r=se(e,i.name);if(r.length===0&&e.ts.isIdentifier(i.name)){e.unsupported.add("A parameter binding could not be resolved to a compiler symbol.");continue}for(let o of r)n.definitions.push({point:W(e,o.node,"parameter-definition",o.symbolKey,o.name,t.id),rhsUseIds:[],partial:!1})}}function hn(e,t){return e.isImportSpecifier(t)||e.isImportClause(t)||e.isNamespaceImport(t)}function bn(e,t){return e.isParenthesizedExpression(t)||e.isAsExpression(t)||e.isTypeAssertionExpression(t)||e.isNonNullExpression(t)}function Sn(e,t,n,i,r){let o=e.ts;return o.isWhileStatement(n)||o.isDoStatement(n)?bt(e,t,n,i,r):o.isForStatement(n)?St(e,t,n,i,r):o.isForInStatement(n)||o.isForOfStatement(n)?Ct(e,t,n,i,r):null}var En=ue("typescript-local-flow",{clearGroups:["whole-project","source-file","semantic-provider"]});function _e(e,t,n,i,r={}){if(t=t.replace(/\\/g,"/"),!pe(t))return null;let o=`${t}\0${n}\0${i}\0${r.startColumn??""}\0${r.endColumn??""}`;return En.get(e,o,()=>{let s=de(e,t);return s?Pe(s,Cn(e.config.projectRoot,t),{startLine:n,endLine:i,...r}):{points:[],edges:[],coverage:{status:"unsupported",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:[`Current source is unavailable for ${t}.`]}}})}function Ci(e,t,n={}){let{file:i,line:r,maxDepth:o,maxEdges:s,direction:a}=wn(t,n),l=_e(e,i,r-1,r-1),c=l?.coverage??{status:"unsupported",basis:"typescript-compiler-cfg-reaching-definitions",unsupported:["Function-local slicing currently requires TypeScript or JavaScript source."]},d=An(l?.points??[],r,n),f=xn(c,d.length),u={kind:"dependence-slice",direction:a,criterion:t,...n.variable!==void 0?{variable:n.variable}:{},resolution:f,candidates:d,points:[],edges:[],coverage:{status:"incomplete",basis:"function-local-dependence",model:c,omittedEdges:0,omittedPoints:0,depthLimited:!1,candidateEdges:0}},p=d[0];if(f!=="matched"||!p||!l)return u;let y=new Map(l.points.map(x=>[x.id,x])),S=Fn(l,y,p.callableId,a),{selected:b,reached:g,depthFrontier:C}=vn(S,p.id,a,o);u.edges=[...b.values()].slice(0,s);let T=new Set([p.id,...u.edges.flatMap(x=>[x.fromPointId,x.toPointId])]);u.points=[...T].map(x=>y.get(x)).sort((x,w)=>x.start-w.start||x.id.localeCompare(w.id));let A=b.size-u.edges.length,M=C.size>0;return u.coverage={status:c.status!=="complete"?"incomplete":A>0||M?"bounded":"complete",basis:"function-local-dependence",model:c,omittedEdges:A,omittedPoints:g.size-T.size,depthLimited:M,candidateEdges:l.edges.filter(x=>x.strength==="candidate"&&(g.has(x.fromPointId)||g.has(x.toPointId))).length},u}function xn(e,t){return e.status==="unsupported"?"unsupported":t===1?"matched":t>1?"ambiguous":"missing"}function wn(e,t){let n=/^(.*):([1-9]\d*)$/u.exec(e);if(!n)throw new Error("A dependence slice requires an exact file:line, with --variable or --column when ambiguous. Use evidence for symbol relationships.");let i=Number(n[2]),r=t.maxDepth??Number.MAX_SAFE_INTEGER,o=t.maxEdges??200;Tn(i,t.column,r,o);let s=t.direction??"backward";if(s!=="backward"&&s!=="forward")throw new Error("Slice direction must be backward or forward.");return{file:n[1],line:i,maxDepth:r,maxEdges:o,direction:s}}function Tn(e,t,n,i){for(let[r,o]of[["line",e],["depth",n],["max-edges",i]])if(!Number.isSafeInteger(o)||o<(r==="line"?1:0))throw new RangeError(`Invalid slice ${r}: ${o}.`);if(t!==void 0&&(!Number.isSafeInteger(t)||t<1))throw new RangeError("Slice column must be a positive safe integer.")}function An(e,t,n){let i=e.filter(r=>r.line===t-1&&["use","definition","parameter-definition"].includes(r.kind)&&(n.variable===void 0||r.name===n.variable));if(n.column!==void 0){let r=n.column-1;i=i.filter(s=>r>=s.column&&r<s.column+s.end-s.start);let o=Math.min(...i.map(s=>s.end-s.start));i=i.filter(s=>s.end-s.start===o)}return i}function Fn(e,t,n,i){let r=new Map;for(let o of e.edges){if(o.strength!=="exact"||t.get(o.fromPointId)?.callableId!==n||t.get(o.toPointId)?.callableId!==n)continue;let s=i==="backward"?o.toPointId:o.fromPointId,a=r.get(s)??[];a.push(o),r.set(s,a)}return r}function vn(e,t,n,i){let r=new Set([t]),o=new Map,s=[{id:t,depth:0}],a=new Set;for(let l=0;l<s.length;l++){let c=s[l],d=e.get(c.id)??[];if(c.depth>=i){for(let f of d)a.add(f.id);continue}for(let f of d){o.set(f.id,{...f,traversalDepth:c.depth+1});let u=n==="backward"?f.fromPointId:f.toPointId;r.has(u)||(r.add(u),s.push({id:u,depth:c.depth+1}))}}for(let l of o.keys())a.delete(l);return{selected:o,reached:r,depthFrontier:a}}function Q(e){let t=new Map,n=[],i=new Map,r=new Map,o=new Set,s=[],a=0,l=u=>(e.get(u)??[]).values();function c(u,p){i.set(u,a),r.set(u,a),a+=1,s.push(u),o.add(u),p.push({node:u,iter:l(u),pendingChild:null})}function d(u){if(r.get(u)!==i.get(u))return;let p=[];for(;;){let y=s.pop();if(o.delete(y),p.push(y),t.set(y,n.length),y===u)break}n.push(p)}function f(u){let p=u[u.length-1];if(p.pendingChild!==null){let b=p.pendingChild;p.pendingChild=null,r.set(p.node,Math.min(r.get(p.node),r.get(b)))}let y=p.iter.next();if(y.done){d(p.node),u.pop();return}let S=y.value;i.has(S)?o.has(S)&&r.set(p.node,Math.min(r.get(p.node),i.get(S))):(p.pendingChild=S,c(S,u))}for(let u of e.keys()){if(i.has(u))continue;let p=[];for(c(u,p);p.length>0;)f(p)}return{components:n,componentOf:t}}function _(e,t){let n=He(e),i=He(t);if(n.endsWith("/**")){let r=n.slice(0,-3);return i===r||i.startsWith(`${r}/`)}if(n.endsWith("/*")){let r=n.slice(0,-2);if(!i.startsWith(`${r}/`))return!1;let o=i.slice(r.length+1);return o.length>0&&!o.includes("/")}return n==="**"?!0:n==="*"?i.length>0&&!i.includes("/"):n===i}function He(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/+$/,"")}function Ai(e,t){let n=(e?.boundaries??[]).filter(i=>i.paths.some(r=>_(r,t)));return n.length===1?n[0].name:null}import P from"path";import{ts as N}from"@ts-morph/common";var Mn={allowJs:!0,moduleResolution:N.ModuleResolutionKind.Node10};function Rn(e,t,n){let i=new Set(e),r=new Map,o=[],s=p=>{if(r.has(p))return r.get(p);if(!(!p.endsWith(".json")||!i.has(p)))try{let y=n(p);return y!==void 0&&r.set(p,y),y}catch(y){o.push(`${p}: configuration unavailable: ${y instanceof Error?y.message:String(y)}`);return}},a=ee(N,e,s),l=Pn(t),c=In(i,l,a,o),d=new Set,f=kn(i,l,s,o,d);for(let p of e)(p==="package.json"||p.endsWith("/package.json"))&&s(p);i.has(".scipquery.json")&&s(".scipquery.json");let u=ee(N,e,p=>r.get(p));return{inputs:r,inventory:i,configs:c,packages:f,host:Dn(u,f),problems:o,architecture:Bn(r.get(".scipquery.json"),o),resolutionCaches:new Map,fileConfigs:new Map,ambiguousPackages:d}}function Pn(e){let t=new Set(["."]);for(let n of e){let i=P.posix.dirname(n);for(;!t.has(i);)t.add(i),i=P.posix.dirname(i)}return t}function In(e,t,n,i){let r=[...t].flatMap(a=>["tsconfig.json","jsconfig.json"].map(c=>P.posix.join(a,c)).filter(c=>e.has(c)).slice(0,1)),o=new Set,s=[];for(let a=0;a<r.length;a++){let l=r[a];if(o.has(l))continue;o.add(l);let c=Nn(l,n,i);if(!c)continue;let d="/"+l;s.push({file:l,directory:P.posix.dirname(d),files:new Set(c.fileNames),options:c.options});for(let f of c.projectReferences??[]){let u=f.path.endsWith(".json")?f.path:P.posix.join(f.path,"tsconfig.json");r.push(u.replace(/^\//,""))}}return s}function Nn(e,t,n){let i="/"+e,r=N.readConfigFile(i,t.readFile);if(r.error){n.push(`${e}: ${N.flattenDiagnosticMessageText(r.error.messageText," ")}`);return}let o=N.parseJsonConfigFileContent(r.config,t,P.posix.dirname(i),void 0,i);for(let s of o.errors)s.code!==18003&&s.code!==18002&&n.push(`${e}: ${N.flattenDiagnosticMessageText(s.messageText," ")}`);return o}function kn(e,t,n,i,r){let o=new Map;for(let s of t){let a=P.posix.join(s,"package.json");if(e.has(a))try{let l=JSON.parse(n(a)??"{}");if(!ce(l)||typeof l.name!="string"||r.has(l.name))continue;let c=o.get(l.name);if(c&&c!==s){i.push(`${a}: repository package name ${l.name} is also declared in ${c}.`),r.add(l.name),o.delete(l.name);continue}o.set(l.name,s)}catch{i.push(`${a}: malformed package metadata.`)}}return o}function Dn(e,t){let n=i=>{let r="/node_modules/",o=i.lastIndexOf(r);if(o<0)return i;let s=i.slice(o+r.length),a=Y(s),l=t.get(a);return l===void 0?i:P.posix.join("/",l,s.slice(a.length))};return{...e,fileExists:i=>e.fileExists(n(i)),readFile:i=>e.readFile(n(i)),directoryExists:i=>i.endsWith("/node_modules")||e.directoryExists?.(n(i))===!0,realpath:n}}function Y(e){return e.startsWith("@")?e.split("/").slice(0,2).join("/"):e.split("/")[0]}function ae(e,t){let n=e.fileConfigs.get(t);if(n)return n;let i="/"+t,r=e.configs.filter(l=>l.files.has(i)),o=r.length?r:e.configs.filter(l=>i.startsWith(l.directory.replace(/\/$/,"")+"/")),s=Math.max(...o.map(l=>l.directory.length)),a=o.length?o.filter(l=>l.directory.length===s):[{file:"",directory:"/",files:new Set,options:Mn}];return e.fileConfigs.set(t,a),a}function Ge(e,t,n){return n.startsWith(".")||n.startsWith("/")||n.startsWith("#")||e.packages.has(Y(n))?!0:ae(e,t).some(i=>Object.keys(i.options.paths??{}).some(r=>{let[o,s]=r.split("*");return s===void 0?n===r:n.startsWith(o)&&n.endsWith(s)}))}function Bn(e,t){if(e===void 0)return;let n=Se(e);if(n.kind==="malformed"||n.kind==="unsupported"){t.push(`.scipquery.json: ${n.kind==="malformed"?n.reason:"unsupported schema version"}`);return}let i=[];if(be(n.config,i),i.some(r=>r.level==="error")){t.push(...i.map(r=>`.scipquery.json ${r.path}: ${r.message}`));return}return n.config.architecture}import k from"path";import{isBuiltin as Ln}from"module";import{ts as Ve}from"@ts-morph/common";function Ui(e,t,n,i){let r=[],o=ae(n,e.fileName);for(let s of me(e,i)){let{literal:a,...l}=s,c=a?$n(n,t,e.fileName,s.specifier,o):{resolution:"dynamic"};r.push({...l,file:e.fileName,role:U(e.fileName)==="test"?"test":"production",configs:o.map(d=>d.file).filter(Boolean),...c})}return r}function $n(e,t,n,i,r){if(Ln(i))return{resolution:"builtin"};let o=jn(e,n,i);if(o)return{resolution:"excluded",target:o};if(e.ambiguousPackages.has(Y(i)))return{resolution:"ambiguous",alternatives:[]};let s=r.map(c=>{let d=e.resolutionCaches.get(c.file);return d||(d=Ve.createModuleResolutionCache("/",f=>f,{allowJs:!0,...c.options}),e.resolutionCaches.set(c.file,d)),Ve.resolveModuleName(i,"/"+n,{allowJs:!0,...c.options},e.host,d).resolvedModule?.resolvedFileName}),a=[...new Set(s.filter(c=>c!==void 0).map(c=>k.posix.normalize(e.host.realpath?.(c)??c).replace(/^\//,"")))];if(a.length>1||a.length===1&&s.some(c=>!c))return{resolution:"ambiguous",alternatives:a};let l=a[0];return l?{resolution:t.has(l)?"internal":"excluded",target:l}:Kn(e,n,i)}function jn(e,t,n){if(!n.startsWith("."))return;let i=k.posix.normalize(k.posix.join(k.posix.dirname(t),n));return e.inventory.has(i)&&!/\.[cm]?[jt]sx?$/.test(i)?i:void 0}function Kn(e,t,n){let i=k.posix.normalize(k.posix.join(k.posix.dirname(t),n));return n.startsWith(".")&&he(i)?{resolution:"excluded",excludedReason:`Requested managed output ${i}; build/install existence is not established by the source inventory.`}:{resolution:Ge(e,t,n)?"missing":"external"}}function _i(e,t,n,i={}){let r=i.scope?{scope:i.scope,limitations:["A file-filtered projection cannot establish repository-wide cycle freedom, size compliance or unused allowances. Rerun architecture without --scope for full policy evaluation."]}:{},o=e,s=Qe(e,t),a=Zn(e,n);e=a.graph;let l={excludedTestEdges:a.excludedTestEdges,basis:"production-imports-including-types",cycleMeaning:"Boundary cycles concern declared groups. File cycle members, when present, concern observed imports including types and deferred imports; neither establishes a runtime initialization failure."};if(!n||n.boundaries.length===0)return{configured:!1,dependencyRoles:l,boundaries:[],edges:[],forbiddenEdges:[],reciprocalPairs:[],cycles:[],coarseBoundaries:[],staleAllowances:[],boundaryLimits:[],fragileEdges:[],testBoundaryViolations:[],coverage:{...r,totalFiles:s.length,mappedFiles:0,unmappedFiles:s,ambiguousFiles:[]},policyCoverage:{declaredRows:0,totalBoundaries:0,missingRows:[],requiresCompletePolicy:!1,requiresCompleteCoverage:!1,requiresMinimalPolicy:!1}};let{resolved:c,filesByBoundary:d,unmappedFiles:f,ambiguousFiles:u}=Un(s,n),p=Je(e,c,n),y=new Map([...o].map(([m,F])=>[m,new Set([...F].filter(Z=>!e.get(m)?.has(Z)))])),S=Je(y,c,n),b=p,g=new Map(b.map(m=>[K(m.from,m.to),m])),C=new Map(n.boundaries.map(m=>[m.name,new Set]));for(let m of b)C.get(m.from).add(m.to);let T=On(b,g),A=Q(e).components.filter(m=>m.length>1&&new Set(m.map(F=>c.get(F)).filter(Boolean)).size>1),{components:M}=Q(C),x=M.filter(m=>m.length>1).map(m=>{let F=Wn(m,b,n.requireAcyclic===!0),Z=new Set(m),le=A.filter(Ye=>Ye.every(Ze=>Z.has(c.get(Ze)??""))).flat();return{...F,origin:le.length>0?"contains-file-cycle":"grouping-only",fileCycleMembers:[...new Set(le)].sort()}}).sort((m,F)=>F.boundaries.length-m.boundaries.length||m.boundaries.join("/").localeCompare(F.boundaries.join("/"))),w=n.allowedDependencies??{},H=n.boundaries.map(m=>m.name).filter(m=>!Object.hasOwn(w,m)).sort();return{configured:!0,dependencyRoles:l,testEdges:S,testForbiddenEdges:S.filter(m=>m.policyStatus==="forbidden"),boundaries:n.boundaries.map(m=>({name:m.name,paths:[...m.paths],fileCount:d.get(m.name).size,dependencyPolicyDeclared:Object.hasOwn(w,m.name)})).sort((m,F)=>m.name.localeCompare(F.name)),edges:p,forbiddenEdges:b.filter(m=>m.policyStatus==="forbidden"),reciprocalPairs:T,cycles:x,staleAllowances:i.scope?[]:Vn(n,[...b,...S],d),boundaryLimits:Jn(n,b,d),fragileEdges:b.filter(m=>m.fragile),testBoundaryViolations:i.testBoundaryViolations??[],coarseBoundaries:_n(e,d,i.isModuleHierarchyFile,n.requireResolvedBoundaries===!0,m=>n.boundaries.find(F=>F.name===m)?.subUnits??"directory"),coverage:{...r,totalFiles:s.length,mappedFiles:c.size,unmappedFiles:f,ambiguousFiles:u},policyCoverage:{declaredRows:n.boundaries.length-H.length,totalBoundaries:n.boundaries.length,missingRows:H,requiresCompletePolicy:n.requireCompletePolicy===!0,requiresCompleteCoverage:n.requireCompleteCoverage===!0,requiresMinimalPolicy:n.requireMinimalPolicy===!0}}}function Un(e,t){let n=new Map,i=new Map(t.boundaries.map(s=>[s.name,new Set])),r=[],o=[];for(let s of e){let a=t.boundaries.filter(l=>l.paths.some(c=>_(c,s))).map(l=>l.name).sort();if(a.length===0)r.push(s);else if(a.length>1)o.push({file:s,boundaries:a});else{let l=a[0];n.set(s,l),i.get(l).add(s)}}return{resolved:n,filesByBoundary:i,unmappedFiles:r,ambiguousFiles:o}}function On(e,t){let n=[];for(let i of e){if(i.from>=i.to)continue;let r=t.get(K(i.to,i.from));r&&n.push({boundaries:[i.from,i.to],forward:i,reverse:r})}return n}function Qe(e,t){let n=new Set(t);for(let[i,r]of e){n.add(i);for(let o of r)n.add(o)}return[...n].sort()}function zn(e,t){let n=[...e.fileEdges].sort((i,r)=>i.fromFile.localeCompare(r.fromFile)||i.toFile.localeCompare(r.toFile));return{from:e.from,to:e.to,policyStatus:qn(t,e.from,e.to),fileEdgeCount:n.length,importerCount:e.importers.size,importedFileCount:e.importedFiles.size,examples:n.slice(0,5),fragile:n.length===1}}function qn(e,t,n){return!e.allowedDependencies||!Object.hasOwn(e.allowedDependencies,t)?"undeclared":e.allowedDependencies[t].includes(n)?"allowed":"forbidden"}function Wn(e,t,n){let i=[...e].sort(),r=new Set(i),o=t.filter(a=>r.has(a.from)&&r.has(a.to)),s=Math.min(...o.map(a=>a.fileEdgeCount));return{boundaries:i,internalEdges:o,narrowestEdges:o.filter(a=>a.fileEdgeCount===s),violatesPolicy:n}}function _n(e,t,n=Xn,i=!1,r=()=>"directory"){let o=[];for(let[s,a]of t){let l=r(s)==="file"?u=>u:Qn,c=[...a].filter(u=>!n(u));if(c.length<2)continue;let{edges:d,subGraph:f}=Hn(e,c,l);for(let u of Gn(s,i,d,f))o.push(u)}return o.sort((s,a)=>a.subUnits.length-s.subUnits.length||s.boundary.localeCompare(a.boundary))}function Hn(e,t,n){let i=new Set(t),r=new Map,o=new Map;for(let s of t)o.set(n(s),new Set);for(let s of t)for(let a of e.get(s)??[]){if(!i.has(a))continue;let l=n(s),c=n(a);if(l===c)continue;let d=K(l,c),f=r.get(d);f||(f={from:l,to:c,fileEdges:[]},r.set(d,f)),f.fileEdges.push({fromFile:s,toFile:a}),o.get(l).add(c)}return{edges:r,subGraph:o}}function Gn(e,t,n,i){let r=[],{components:o}=Q(i);for(let s of o){if(s.length<2)continue;let a=new Set(s),l=[...n.values()].filter(d=>a.has(d.from)&&a.has(d.to)).map(d=>({from:d.from,to:d.to,fileEdgeCount:d.fileEdges.length,examples:d.fileEdges.slice(0,5)})).sort((d,f)=>d.from.localeCompare(f.from)||d.to.localeCompare(f.to)),c=Math.min(...l.map(d=>d.fileEdgeCount));r.push({boundary:e,violatesPolicy:t,subUnits:[...s].sort(),internalEdges:l,narrowestEdges:l.filter(d=>d.fileEdgeCount===c)})}return r}function Vn(e,t,n){let i=new Set(t.map(a=>K(a.from,a.to))),r=e.allowedDependencies??{},o=new Set(e.boundaries.map(a=>a.name)),s=[];for(let[a,l]of Object.entries(r))if(n.get(a)?.size)for(let c of l)!o.has(c)||i.has(K(a,c))||s.push({from:a,to:c});return s.sort((a,l)=>a.from.localeCompare(l.from)||a.to.localeCompare(l.to))}function Jn(e,t,n){let i=[],r=new Map;for(let o of t)r.set(o.from,(r.get(o.from)??0)+1);for(let o of e.boundaries){Xe(i,o.name,"fan-out",r.get(o.name)??0,e.maxBoundaryFanOut);let s=o.maxFiles??e.maxBoundaryFiles;Xe(i,o.name,"files",n.get(o.name)?.size??0,s)}return i.sort((o,s)=>o.boundary.localeCompare(s.boundary)||o.kind.localeCompare(s.kind))}function Xn(e){let t=U(e);return t==="test"||t==="entry"}function Qn(e){let t=e.lastIndexOf("/");return t===-1?".":e.slice(0,t)}function K(e,t){return`${e}\0${t}`}function Yn(e,t){return e.from.localeCompare(t.from)||e.to.localeCompare(t.to)}function Zn(e,t){let n=new Set(Qe(e,[]).filter(o=>U(o)==="test"||/(^|\/)(fixtures|benchmarks)(\/|$)/.test(o)||(t?.testPaths??[]).some(s=>_(s,o)))),i=new Map,r=0;for(let[o,s]of e){let a=new Set;for(let l of s)n.has(o)||n.has(l)?r++:a.add(l);i.set(o,a)}return{graph:i,excludedTestEdges:r}}function Je(e,t,n){let i=new Map;for(let[r,o]of e){let s=t.get(r);if(s)for(let a of o){let l=t.get(a);if(!l||s===l)continue;let c=K(s,l),d=i.get(c);d||(d={from:s,to:l,fileEdges:[],importers:new Set,importedFiles:new Set},i.set(c,d)),d.fileEdges.push({fromFile:r,toFile:a}),d.importers.add(r),d.importedFiles.add(a)}}return[...i.values()].map(r=>zn(r,n)).sort(Yn)}function Xe(e,t,n,i,r){r!==void 0&&i>r&&e.push({boundary:t,kind:n,observed:i,limit:r})}export{Q as a,_ as b,Ai as c,Rn as d,Ui as e,_i as f,si as g,Ci as h};
3
+ //# sourceMappingURL=chunk-BOZ4EXBB.js.map
@@ -0,0 +1,2 @@
1
+ import{a as de}from"./chunk-NOWINRRN.js";import{a as le,b as ce,c as ue}from"./chunk-N2WN6I3L.js";import{b as ae}from"./chunk-6LSEIIF7.js";import{a as se}from"./chunk-BGBBVSH4.js";import{b as q}from"./chunk-KZBJWZJB.js";import{b as oe}from"./chunk-FMRN2TRL.js";import{a as v}from"./chunk-72AD6ZRR.js";import{d as ie,x as re}from"./chunk-5D2LVK7O.js";import{g as ne}from"./chunk-A2IIGFMJ.js";var Be=10,Ue=4,Ae=3,Q=5,Ie=.5,pe=80,Ke=3,D=new Set(["statement","predicate","return","throw"]),B=/^use[A-Z0-9_]/u,je=/^use(?:[A-Z0-9_]\w*)?Effect$/u,ze=/(?:^|\/)(?:scripts?|bin|tools?|tooling|migrations?|integration-tests?|e2e)\//u,Te=new Set(["get","has","at","find","findLast","findIndex","findLastIndex","includes","indexOf","lastIndexOf","keys","values","entries","forEach","map","filter","flatMap","reduce","reduceRight","some","every","slice","concat","join","toString","toJSON","toSorted","toReversed","toSpliced","with","startsWith","endsWith","match","matchAll","test","exec","search","localeCompare","trim","trimStart","trimEnd","split","replace","replaceAll","toLowerCase","toUpperCase","padStart","padEnd","charAt","charCodeAt","codePointAt","substring","repeat","normalize","isArray","from","of","assign","freeze","hasOwn","getOwnPropertyNames","stringify","parse","toFixed","toISOString","getTime","valueOf","then","catch","finally","size","length"]),fe=new Set(["map","filter","flatMap","slice","concat","keys","values","entries","from","of","toSorted","toReversed","toSpliced","with","join","reduce","reduceRight","some","every","includes","has","indexOf","lastIndexOf","findIndex","size","length","toString","toJSON","then","catch","finally","trim","split","replace","replaceAll","toLowerCase","toUpperCase","startsWith","endsWith","match","test","exec","localeCompare","padStart","padEnd","charAt","charCodeAt","codePointAt","substring","repeat","normalize"]);function Mn(e,t={}){let{scope:n,symbol:i,minLoc:r=12,minStatements:o,minClusterUnits:s,limit:a=20,scanLimit:u,onProgress:l}=t,p={files:new Map},d={minStatements:o,minClusterUnits:s,detail:t.detail??i!==void 0};if(i){let g=We(e,i);if(!g)return[];let h=ye(e,g,d,p);return h?[h]:[]}let S=new ae(e);return de({candidates:()=>S.productionCallableDefinitions({scope:n,minLoc:r,excludeTypesFiles:!0,requireFunctionLikeSymbol:!0,sortByLocDesc:!0}),scanLimit:u,orderScanned:(g,h)=>g.relativePath.localeCompare(h.relativePath)||g.startLine-h.startLine,filterCandidate:g=>q(g.relativePath)&&!ne(e,g.relativePath,g.startLine,"extract"),profile:{name:"slice-cohesion"},onProgress:l,onProfile:t.onProfile,evaluate:g=>{let h=ye(e,g,d,p);return h?.splitCandidate?h:null},orderResults:_e,limit:a})}function _e(e,t){return me(e.actionTier)-me(t.actionTier)||Number(e.operational)-Number(t.operational)||Se(e.archetype)-Se(t.archetype)||he(e)-he(t)||ge(t)-ge(e)||t.separableStatements-e.separableStatements||t.loc-e.loc}function me(e){return e==="signal"?0:1}function Se(e){switch(e){case"calculation":return 0;case"react-hook":return 1;case"react-component":return 2;case"orchestration":return 3}}function he(e){let t=new Set(e.clusters.filter(n=>n.role==="extraction").map(n=>n.kind));return t.has("calculation")?0:t.has("operation")||t.has("hook")?1:2}function ge(e){return e.clusters.filter(t=>t.role==="extraction"&&t.narrow).reduce((t,n)=>t+n.units.length,0)}function We(e,t){let n=oe(e,t);if(n.candidates.length>0)throw new Error(`Ambiguous symbol: ${t}. Use an exact SCIP symbol or file:line.`);let i=n.match;if(!i)return null;let r=re(e,i.relativePath);return r.find(o=>o.symbolId===i.symbolId)??r.find(o=>o.symbol===i.symbol)??null}function ye(e,t,n={},i={files:new Map}){let r={minStatements:n.minStatements??Be,minClusterUnits:n.minClusterUnits??Ue},o=n.detail??!0,s=He(e,t,i);if(!s)return null;let{ts:a,sourceFile:u,callable:l,flow:p}=s,d=Ze(a,u,l,t.relativePath),S=gt(d,p,t.relativePath),g=At(d,S),h=d.units.filter(w=>D.has(w.kind)).map(w=>w.index),m=new Set(h),C=Ve(d,S,g,m),M=C.filter(w=>!w.guard),k=qt(M,h.length),L=new Set(C.flatMap(w=>w.units)),{clusters:f,preamble:b}=qe(M,L,d,S,r),c=new Set(f.flatMap(w=>w.outputs)),y=M.filter(w=>!c.has(w.id)).map(w=>w.id),T=new Set(C.flatMap(w=>w.fullSlice??[])),E=h.filter(w=>!T.has(w)&&!L.has(w)&&d.units[w].kind==="statement"),X=f.filter(w=>w.role==="extraction"),Pe=X.reduce((w,V)=>w+V.units.length,0),_=h.length>=r.minStatements&&X.length>=1,$e=[...p.coverage.unsupported],W={status:p.coverage.status==="complete"&&S.candidateEdges===0?"complete":"partial",model:"function-local-flow",basis:"typescript-local-flow-backward-slices",unsupported:$e,candidateEdges:S.candidateEdges,candidateEdgeEffect:"merge-only"},H=nn(d,M),Y=rn(_,H,f,W),De=C.filter(w=>w.guard).length,ee={body:d,flow:S,thresholds:r,archetype:H,clusters:f,preamble:b,orphans:E,guards:De,coverage:W},Re=o?C:C.map(({slice:w,fullSlice:V,...te})=>te);return{symbol:t.symbol,shortName:ie(t.symbol),relativePath:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:se(t),archetype:H,operational:ze.test(t.relativePath),...o?{units:d.units.map(({node:w,start:V,end:te,...Oe})=>Oe)}:{},statementCount:h.length,outputs:Re,metrics:k,clusters:f,preambleOnlyOutputs:y,preamble:b,orphans:E,separableStatements:Pe,splitCandidate:_,actionTier:Y.tier,tierReason:Y.reason,evidenceReasons:on(h.length,C,k,ee),recommendation:sn(_,M,k,ee),coverage:W}}function He(e,t,n){if(!q(t.relativePath))return null;let i=le();if(!i)return null;let r=Ge(e,t.relativePath,n);if(!r)return null;let o=Qe(i,r,t);if(!o)return null;let s=ce(e,t.relativePath,t.startLine,t.endLine);return!s||s.coverage.status==="unsupported"?null:{ts:i,sourceFile:r,callable:o,flow:s}}function Ve(e,t,n,i){let r=l=>{let p=[],d=new Set,S=[...t.controlDeps[l]];for(;S.length>0;){let g=S.pop();d.has(g)||(d.add(g),e.guardPredicates.has(g)?S.push(...t.controlDeps[g]):p.push(g))}return p},o=l=>e.handlerDeps.get(l)??[],s=l=>[...t.dataDeps[l],...r(l),...o(l)],a=l=>[...t.dataDeps[l],...t.controlDeps[l],...o(l)],u=n.map(l=>{let p=Ht(l,t),d=[...be(p,s)].filter(h=>i.has(h)),S=[...be(p,a)].filter(h=>i.has(h)),g=e.guardUnits.has(l.unit)||(l.kind==="throw"||l.kind==="return")&&l.seedPoints===null&&d.every(h=>h===l.unit);return{seed:l,guard:g,slice:new Set(d),fullSlice:new Set(S)}});return Vt(u)}function qe(e,t,n,i,r){let o=new Set(Gt(e,t,n,i)),s=Ce(e,o,n,i,r);for(;;){let u=new Map;s.forEach((p,d)=>p.outputs.forEach(S=>u.set(S,d)));let l=[...o].filter(p=>{let d=new Set;for(let S of e){let g=u.get(S.id);g!==void 0&&j(S).includes(p)&&d.add(g)}return d.size<=1});if(l.length===0)break;for(let p of l)o.delete(p);s=Ce(e,o,n,i,r)}let a=[...o].sort(P);return{clusters:s,preamble:a}}function j(e){return e.slice??[]}function P(e,t){return e-t}function Ge(e,t,n){let i=n.files.get(t);if(i!==void 0)return i;let r=ue(e,t);return n.files.set(t,r),r}function Qe(e,t,n){let i=null,r=o=>{if(i)return;let s=t.getLineAndCharacterOfPosition(o.getStart(t)).line,a=t.getLineAndCharacterOfPosition(o.getEnd()).line;if(!(a<n.startLine||s>n.endLine)){if(e.isFunctionLike(o)&&"body"in o&&o.body!==void 0&&s>=n.startLine&&a<=n.endLine){i=o;return}o.forEachChild(r)}};return t.forEachChild(r),i}function Je(e,t){return e.isReturnStatement(t)?"return":e.isThrowStatement(t)?"throw":e.isBreakOrContinueStatement(t)?"jump":e.isFunctionDeclaration(t)||e.isClassDeclaration(t)||e.isInterfaceDeclaration(t)||e.isTypeAliasDeclaration(t)||e.isEnumDeclaration(t)?"declaration":e.isEmptyStatement(t)?null:"statement"}function Ze(e,t,n,i){let{units:r,guardPredicates:o,guardUnits:s,enclosingPredicates:a,awaitUnits:u,handlerDeps:l}=Xe(e,t,n),{paramNames:p,localNames:d,calleeSpans:S,closureNodes:g,containers:h,aliases:m,stateSetters:C}=Ye(e,t,n),M=[];for(let c=n.parent;c;c=c.parent)e.isFunctionLike(c)&&M.push({start:c.getStart(t),end:c.getEnd()});let k=new Map;for(let c of r){if(!D.has(c.kind))continue;let y=rt(e,c.node);y.length>0&&k.set(c.index,y)}let L=n.name&&"text"in n.name?String(n.name.text):"",f=k.size>0&&(/\.[jt]sx$/iu.test(i)||B.test(L)),b={ts:e,sourceFile:t,callable:n,units:r,paramNames:p,localNames:d,guardPredicates:o,guardUnits:s,enclosingPredicates:a,awaitUnits:u,calleeSpans:S,closures:new Map,containers:h,aliases:m,enclosingRanges:M,handlerDeps:l,stateSetters:C,hookCalls:k,react:f};return b.closures=pt(b,g),b}function Xe(e,t,n){let i=[],r=new Set,o=new Set,s=[],a=new Map,u=[],l=n.body,p=(c,y)=>{let T=y.getStart(t),E=y.getEnd();i.push({index:0,kind:c,node:y,start:T,end:E,startLine:t.getLineAndCharacterOfPosition(T).line,endLine:t.getLineAndCharacterOfPosition(E).line,label:dt(t,y)}),a.set(y,[...s])},d=(c,y)=>{s.push(c),y(),s.pop()},S=c=>{p("predicate",c.expression);let y=!c.elseStatement&&lt(e,c.thenStatement,ct(e,c));y&&r.add(c.expression);let T=i.length;d(c.expression,()=>{if(m(c.thenStatement),y)for(let E of i.slice(T))o.add(E.node);c.elseStatement&&m(c.elseStatement)})},g=c=>{let y=i.length;m(c.tryBlock);let T=i.length;c.catchClause&&(c.catchClause.variableDeclaration&&p("statement",c.catchClause.variableDeclaration),m(c.catchClause.block)),c.finallyBlock&&m(c.finallyBlock),u.push({tryNodes:i.slice(y,T).map(E=>E.node),handlerNodes:i.slice(T).map(E=>E.node)})},h=c=>{if(e.isWhileStatement(c)||e.isDoStatement(c))return p("predicate",c.expression),d(c.expression,()=>m(c.statement)),!0;if(e.isForStatement(c)){c.initializer&&p("statement",c.initializer),c.condition&&p("predicate",c.condition);let y=c.condition??c;return d(y,()=>{c.incrementor&&p("statement",c.incrementor),m(c.statement)}),!0}return e.isForInStatement(c)||e.isForOfStatement(c)?(p("predicate",c.expression),d(c.expression,()=>{p("statement",c.initializer),m(c.statement)}),!0):!1},m=c=>{if(e.isBlock(c)){for(let T of c.statements)m(T);return}if(e.isIfStatement(c)){S(c);return}if(h(c))return;if(e.isSwitchStatement(c)){p("predicate",c.expression),d(c.expression,()=>{for(let T of c.caseBlock.clauses)for(let E of T.statements)m(E)});return}if(e.isTryStatement(c)){g(c);return}if(e.isLabeledStatement(c)){m(c.statement);return}let y=Je(e,c);y&&p(y,c)};if(e.isBlock(l))for(let c of l.statements)m(c);else p("return",l);i.sort((c,y)=>c.start-y.start);let C=new Map;i.forEach((c,y)=>{c.index=y,C.set(c.node,y)});let M=new Set(i.filter(c=>r.has(c.node)).map(c=>c.index)),k=new Set(i.filter(c=>o.has(c.node)).map(c=>c.index)),L=i.map(c=>(a.get(c.node)??[]).map(y=>C.get(y)).filter(y=>y!==void 0)),f=new Set(i.filter(c=>D.has(c.kind)&&ut(e,c.node)).map(c=>c.index)),b=new Map;for(let c of u){let y=c.tryNodes.map(T=>C.get(T)).filter(T=>D.has(i[T].kind));for(let T of c.handlerNodes){let E=C.get(T);b.set(E,[...b.get(E)??[],...y])}}return{units:i,guardPredicates:M,guardUnits:k,enclosingPredicates:L,awaitUnits:f,handlerDeps:b}}function Ye(e,t,n){let i=n.body,r=new Set;for(let f of n.parameters)for(let b of v(f.name))r.add(b);let o=new Set,s=new Set,a=new Map,u=new Set,l=new Map,p=new Map,d=(f,b)=>{if(!b||b===f)return;let c=l.get(f)??new Set;c.add(b),l.set(f,c)},S=(f,b)=>{for(let c of F(e,b))for(let y of f)d(y,c)},g=(f,b)=>{let c=x(e,b);if(I(e,c)){for(let y of f)u.add(y);return}S(f,c)},h=f=>{let b=v(f.name);for(let E of b)o.add(E);let c=f.initializer?x(e,f.initializer):null,y=c?tt(e,c):null;if(y&&e.isIdentifier(f.name)){a.set(f.name.text,y);return}if(f.initializer){g(b,f.initializer);let E=nt(e,f);E&&p.set(E.setter,E.state);return}let T=st(e,f);T&&S(b,x(e,T))},m=f=>{let b=x(e,f.left),c=x(e,f.right);e.isIdentifier(b)?g([b.text],f.right):e.isIdentifier(c)&&d(c.text,N(e,b))},C=f=>{let b=x(e,f.expression);if(!e.isPropertyAccessExpression(b)&&!e.isElementAccessExpression(b)||e.isPropertyAccessExpression(b)&&Te.has(b.name.text))return;let c=N(e,b);for(let y of f.arguments){let T=x(e,y);e.isIdentifier(T)&&d(T.text,c)}},M=f=>{if(e.isParameter(f)&&f.parent!==n)for(let b of v(f.name))o.add(b);else if(e.isFunctionDeclaration(f)||e.isClassDeclaration(f))et(e,f,o,a);else if(e.isCatchClause(f)&&f.variableDeclaration)for(let b of v(f.variableDeclaration.name))o.add(b)},k=f=>{e.isCallExpression(f)||e.isNewExpression(f)?s.add(`${f.expression.getStart(t)}:${f.expression.getEnd()}`):e.isTaggedTemplateExpression(f)&&s.add(`${f.tag.getStart(t)}:${f.tag.getEnd()}`)},L=f=>{e.isVariableDeclaration(f)?h(f):e.isBinaryExpression(f)&&f.operatorToken.kind===e.SyntaxKind.EqualsToken?m(f):e.isCallExpression(f)?C(f):M(f),k(f),f.forEachChild(L)};return L(i),{paramNames:r,localNames:o,calleeSpans:s,closureNodes:a,containers:u,aliases:l,stateSetters:p}}function et(e,t,n,i){t.name&&(n.add(t.name.text),e.isFunctionDeclaration(t)&&t.body&&i.set(t.name.text,t))}function tt(e,t){if(e.isArrowFunction(t)||e.isFunctionExpression(t))return t;if(e.isCallExpression(t)&&U(e,x(e,t.expression))==="useCallback"&&t.arguments.length>0){let i=x(e,t.arguments[0]);if(e.isArrowFunction(i)||e.isFunctionExpression(i))return i}return null}function nt(e,t){if(!e.isArrayBindingPattern(t.name)||!t.initializer)return null;let n=x(e,t.initializer);if(!e.isCallExpression(n))return null;let i=U(e,x(e,n.expression));return!i||!B.test(i)?null:it(e,t.name)}function it(e,t){let[n,i]=t.elements;return!n||!i||e.isOmittedExpression(n)||e.isOmittedExpression(i)||!e.isIdentifier(n.name)||!e.isIdentifier(i.name)?null:{state:n.name.text,setter:i.name.text}}function U(e,t){return e.isIdentifier(t)?t.text:e.isPropertyAccessExpression(t)?t.name.text:null}function rt(e,t){let n=[],i=r=>{if(!e.isFunctionLike(r)){if(e.isCallExpression(r)){let o=U(e,x(e,r.expression));o&&B.test(o)&&n.push(o)}r.forEachChild(i)}};return i(t),n}function I(e,t){if(e.isArrayLiteralExpression(t)||e.isObjectLiteralExpression(t)||e.isNewExpression(t))return!0;if(e.isBinaryExpression(t)){let n=t.operatorToken.kind;if(n===e.SyntaxKind.QuestionQuestionToken||n===e.SyntaxKind.BarBarToken)return I(e,x(e,t.right))}return e.isConditionalExpression(t)?I(e,x(e,t.whenTrue))||I(e,x(e,t.whenFalse)):!1}function F(e,t){let n=x(e,t);if(e.isIdentifier(n))return[n.text];if(n.kind===e.SyntaxKind.ThisKeyword)return["this"];if(e.isBinaryExpression(n)){let i=n.operatorToken.kind;return i===e.SyntaxKind.QuestionQuestionToken||i===e.SyntaxKind.BarBarToken?[...F(e,n.left),...F(e,n.right)]:[]}return e.isConditionalExpression(n)?[...F(e,n.whenTrue),...F(e,n.whenFalse)]:ot(e,n)}function ot(e,t){if(e.isPropertyAccessExpression(t))return fe.has(t.name.text)?[]:F(e,t.expression);if(e.isElementAccessExpression(t))return F(e,t.expression);if(e.isCallExpression(t)){let n=x(e,t.expression);return e.isPropertyAccessExpression(n)?fe.has(n.name.text)?[]:F(e,n.expression):[]}return[]}function st(e,t){let n=t.parent;if(!n||!e.isVariableDeclarationList(n))return null;let i=n.parent;return i&&(e.isForOfStatement(i)||e.isForInStatement(i))&&i.initializer===n?i.expression:null}function at(e,t){let n=new Set([t]),i=[t];for(;i.length>0;){let r=i.pop();if(A(e,r))for(let o of e.aliases.get(r)??[])n.has(o)||(n.add(o),i.push(o))}return n}function lt(e,t,n){let i=e.isBlock(t)?t.statements:[t];if(i.length===0)return!1;let r=i[i.length-1];if(!e.isReturnStatement(r)&&!e.isThrowStatement(r))return!1;let o=new Set(n);if(!un(e,i.slice(0,-1),o))return!1;if(!e.isReturnStatement(r)||!r.expression)return!0;let s=!1,a=u=>{s||(e.isIdentifier(u)&&Ee(e,u)&&o.has(u.text)?s=!0:u.forEachChild(a))};return a(r.expression),!s}function ct(e,t){let n=new Set;for(let i=t.parent;i&&!e.isFunctionLike(i);i=i.parent){if(!e.isIterationStatement(i,!1))continue;let r=o=>{if(e.isVariableDeclaration(o))for(let s of v(o.name))n.add(s);o.forEachChild(r)};r(i)}return n}function ut(e,t){let n=!1,i=r=>{if(!(n||e.isFunctionLike(r)&&r!==t)){if(e.isAwaitExpression(r)||e.isForOfStatement(r)&&r.awaitModifier!==void 0){n=!0;return}r.forEachChild(i)}};return i(t),n}function dt(e,t){let n=t.getText(e).replace(/\s+/gu," ").trim();return n.length>pe?`${n.slice(0,pe-3)}...`:n}function pt(e,t){let n=new Map;for(let[r,o]of t)n.set(r,mt(e,o,t));let i=!0;for(;i;){i=!1;for(let r of n.values())ht(r,n)&&(i=!0)}return n}function ft(e,t){let n=new Set;for(let r of t.parameters)for(let o of v(r.name))n.add(o);let i=r=>{if(e.isVariableDeclaration(r)||e.isParameter(r))for(let o of v(r.name))n.add(o);else(e.isFunctionDeclaration(r)||e.isClassDeclaration(r))&&r.name&&n.add(r.name.text);r.forEachChild(i)};return t.body&&i(t.body),n}function mt(e,t,n){let{ts:i}=e,r=ft(i,t),o={reads:new Set,writes:new Set,stateWrites:new Set,calls:new Set},s=a=>{if(i.isTypeNode(a))return;let u=J(e,a);u&&!r.has(u)&&o.writes.add(u),i.isCallExpression(a)&&St(e,a,r,n,o),i.isIdentifier(a)&&Ee(i,a)&&!r.has(a.text)&&o.reads.add(a.text),a.kind===i.SyntaxKind.ThisKeyword&&o.reads.add("this"),a.forEachChild(s)};return t.body&&s(t.body),o}function St(e,t,n,i,r){let o=x(e.ts,t.expression);if(!e.ts.isIdentifier(o)||n.has(o.text))return;i.has(o.text)&&r.calls.add(o.text);let s=e.stateSetters.get(o.text);s&&r.stateWrites.add(s)}function ht(e,t){let n=!1;for(let i of e.calls){let r=t.get(i);r&&(G(r.reads,e.reads)&&(n=!0),G(r.writes,e.writes)&&(n=!0),G(r.stateWrites,e.stateWrites)&&(n=!0))}return n}function G(e,t){let n=!1;for(let i of e)t.has(i)||(t.add(i),n=!0);return n}function Ee(e,t){let n=t.parent;return!(!n||dn(e,t,n)||e.isLabeledStatement(n)||e.isBreakOrContinueStatement(n))}function gt(e,t,n){let i=yt(e,t),{reachedUses:r,...o}=bt(e,t,i),s=Ct(e,i,r,o.paramReads,n),a=Ft(e);return Et(e.units,i,a,o),{...i,...o,...s,writesByUnit:a.byUnit,stateWritesByUnit:a.stateWritesByUnit}}function yt(e,t){let{units:n}=e,i=e.callable.getStart(e.sourceFile),r=e.callable.getEnd(),o=e.callable.body.getStart(e.sourceFile),s=new Map,a=new Map;for(let u of t.points){if(u.start<i||u.end>r)continue;if(s.set(u.id,u),u.start<o){a.set(u.id,-1);continue}let l=kt(n,u.start);l!==null&&a.set(u.id,l)}return{pointById:s,unitOfPoint:a}}function Me(e,t,n){let i=e.get(t);i||(i=new Set,e.set(t,i)),i.add(n)}function bt(e,t,n){let{units:i}=e,r=i.map(()=>new Set),o=i.map(()=>new Set),s=new Map,a=i.map(()=>new Set),l={dataDeps:r,controlDeps:o,pointDeps:s,paramReads:a,candidateEdges:0,reachedUses:new Set};for(let p of t.edges){let d=xt(n,p);d&&wt(p,d,l)}return e.enclosingPredicates.forEach((p,d)=>{for(let S of p)S!==d&&o[d].add(S)}),l}function xt(e,t){let{pointById:n,unitOfPoint:i}=e,r=n.get(t.fromPointId),o=n.get(t.toPointId);if(!r||!o)return null;let s=i.get(r.id),a=i.get(o.id);return s===void 0||a===void 0||a===-1?null:{from:r,to:o,fromUnit:s,toUnit:a}}function wt(e,t,n){let{from:i,to:r,fromUnit:o,toUnit:s}=t,{reachedUses:a,paramReads:u,controlDeps:l,dataDeps:p,pointDeps:d}=n;if(e.kind!=="control-dependence"&&a.add(r.id),o===-1){e.kind!=="control-dependence"&&u[s].add(z(i.name));return}o!==s&&(e.strength==="candidate"&&(n.candidateEdges+=1),e.kind==="control-dependence"?l[s].add(o):(p[s].add(o),Me(d,r.id,o)))}function Ct(e,t,n,i,r){let{units:o}=e,{pointById:s,unitOfPoint:a}=t,u=o.map(()=>new Set),l=o.map(()=>new Set),p=new Map;for(let d of s.values()){let S=a.get(d.id);if(S===void 0||S===-1)continue;if(d.kind==="definition"){mn(d,S,l,p);continue}if(d.kind!=="use"||n.has(d.id))continue;let g=Tt(e,d,r);if(!g)continue;(g.kind==="parameter"?i:u)[S].add(g.name)}return{definitionsByUnitName:p,outerReads:u,definedNames:l}}function Tt(e,t,n){if(e.calleeSpans.has(`${t.start}:${t.end}`)||t.name.includes("("))return null;let i=z(t.name);return e.paramNames.has(i)?{kind:"parameter",name:i}:e.localNames.has(i)?null:i==="this"||vt(t.symbolKey,n,e.enclosingRanges)?{kind:"outer",name:i}:null}function Et(e,t,n,i){let{writes:r,reads:o}=n,{dataDeps:s,pointDeps:a}=i,u=Mt(t);for(let l of r){let p=e[l.unit].start;for(let d of u.get(l.base)??[])d.unit===l.unit||d.start<=p||(s[d.unit].add(l.unit),Me(a,d.id,l.unit));Sn(e,l,o,p,s)}}function Mt(e){let{pointById:t,unitOfPoint:n}=e,i=new Map;for(let r of t.values()){if(r.kind!=="use")continue;let o=n.get(r.id);if(o===void 0||o===-1)continue;let s=z(r.name),a=i.get(s)??[];a.push({id:r.id,start:r.start,unit:o}),i.set(s,a)}return i}function kt(e,t){let n=0,i=e.length-1,r=-1;for(;n<=i;){let o=n+i>>1;e[o].start<=t?(r=o,n=o+1):i=o-1}return r<0?null:t<e[r].end?r:null}function z(e){let t=e.search(/[.[?!(]/u);return t<0?e:e.slice(0,t)}function Lt(e){if(!e)return null;let t=e.split(":");if(t.length<4)return null;let n=Number(t[2]);if(!Number.isSafeInteger(n))return null;try{return{fileName:decodeURIComponent(t[1]).replace(/\\/gu,"/"),offset:n}}catch{return null}}function ke(e,t,n,i){let r=Lt(e);return r?r.fileName.endsWith(t.replace(/\\/gu,"/"))&&r.offset>=n&&r.offset<i:!1}function vt(e,t,n){return n.some(i=>ke(e,t,i.start,i.end))}function Ft(e){let t=[],n=[],i=new Map,r=new Map,o=(s,a,u)=>{let l=i.get(s);l||(l={local:new Set,external:new Set},i.set(s,l));let p=u?at(e,a):new Set([a]);for(let d of p)A(e,d)?(l.local.add(d),t.push({unit:s,base:d})):(u||d!==a)&&(l.external.add(d),u&&(d==="this"||e.paramNames.has(d))&&t.push({unit:s,base:d}))};for(let s of e.units)D.has(s.kind)&&Nt(e,s,o,n,r);return{writes:t,reads:n,byUnit:i,stateWritesByUnit:r}}function Nt(e,t,n,i,r){let{ts:o}=e,s=Le(o,t.node);if(s){let u=J(e,s);u&&n(t.index,u,Rt(e,s))}for(let u of Bt(e,t.node)){for(let l of u.writes)n(t.index,l,!0);for(let l of u.reads)A(e,l)&&i.push({unit:t.index,base:l})}for(let u of Ot(e,t.node))n(t.index,u,!0);let a=Pt(e,t.node);if(a.length>0){r.set(t.index,a);for(let u of a)n(t.index,u,!0)}}function Pt(e,t){let{ts:n}=e,i=new Set,r=(o,s)=>{if(!(n.isFunctionLike(o)&&o!==t&&!s)){if(n.isCallExpression(o)){let a=x(n,o.expression);$t(e,a,i);let u=U(n,a);if(u&&je.test(u)){Dt(n,o,s,r);return}}o.forEachChild(a=>r(a,s))}};return r(t,!1),[...i]}function $t(e,t,n){let{ts:i}=e;if(i.isIdentifier(t)){let r=e.stateSetters.get(t.text);r&&n.add(r);let o=e.closures.get(t.text);if(o)for(let s of o.stateWrites)n.add(s)}}function Dt(e,t,n,i){for(let r of t.arguments){let o=x(e,r);(e.isArrowFunction(o)||e.isFunctionExpression(o))&&o.body?i(o.body,!0):i(r,n)}}function Rt(e,t){let{ts:n}=e;if(n.isCallExpression(t)||n.isDeleteExpression(t))return!0;let i=n.isBinaryExpression(t)?t.left:n.isPrefixUnaryExpression(t)||n.isPostfixUnaryExpression(t)?t.operand:null;return i!==null&&!n.isIdentifier(x(n,i))}function Ot(e,t){let{ts:n}=e,i=[],r=o=>{if(n.isCallExpression(o)||n.isNewExpression(o))for(let s of o.arguments??[]){let a=x(n,s);n.isIdentifier(a)&&e.containers.has(a.text)&&i.push(a.text)}o.forEachChild(r)};return r(t),i}function Bt(e,t){let{ts:n}=e,i=[],r=o=>{if(n.isCallExpression(o)){let s=x(n,o.expression);if(n.isIdentifier(s)){let a=e.closures.get(s.text);a&&i.push(a)}}o.forEachChild(r)};return r(t),i}function Le(e,t){let n=e.isExpressionStatement(t)?t.expression:e.isExpression(t)?t:null;return n?x(e,n):null}function x(e,t){let n=t;for(;;)if(e.isParenthesizedExpression(n)||e.isAwaitExpression(n)||e.isVoidExpression(n))n=n.expression;else if(e.isAsExpression(n)||e.isSatisfiesExpression(n)||e.isNonNullExpression(n)||e.isTypeAssertionExpression(n))n=n.expression;else return n}function J(e,t){let{ts:n}=e;return n.isBinaryExpression(t)&&Ut(n,t.operatorToken.kind)?N(n,t.left):n.isPrefixUnaryExpression(t)||n.isPostfixUnaryExpression(t)?t.operator===n.SyntaxKind.PlusPlusToken||t.operator===n.SyntaxKind.MinusMinusToken?N(n,t.operand):null:n.isDeleteExpression(t)?N(n,t.expression):n.isCallExpression(t)?pn(n,t):null}function Ut(e,t){return t>=e.SyntaxKind.FirstAssignment&&t<=e.SyntaxKind.LastAssignment}function N(e,t){let n=x(e,t);for(;;)if(e.isPropertyAccessExpression(n)||e.isElementAccessExpression(n))n=x(e,n.expression);else{if(e.isIdentifier(n))return n.text;if(n.kind===e.SyntaxKind.ThisKeyword)return"this";if(e.isCallExpression(n))n=x(e,n.expression);else return null}}function A(e,t){return t!=="this"&&!e.paramNames.has(t)&&e.localNames.has(t)}function At(e,t){let n=[],i=[...t.pointById.values()].filter(r=>r.kind==="use");for(let r of e.units)if(r.kind==="return")n.push(...It(e,r,i));else if(r.kind==="throw")n.push({id:`throw@${r.startLine+1}`,kind:"throw",label:r.label,line:r.startLine,unit:r.index,group:`throw@${r.startLine+1}`,hook:!1,seedPoints:null});else if(r.kind==="statement"){let o=Kt(e,t,r);o&&n.push(o)}return n}function It(e,t,n){let{ts:i,sourceFile:r}=e,o=t.startLine,s=i.isReturnStatement(t.node)?t.node.expression:t.node;if(!s)return[];let a=x(i,s);return i.isObjectLiteralExpression(a)&&a.properties.length>=2?a.properties.map(u=>{let l=Wt(i,r,u),p=u.getStart(r),d=u.getEnd();return{id:`return.${l}@${o+1}`,kind:"return-property",label:`return.${l}`,line:o,unit:t.index,group:`return.${l}`,hook:!1,seedPoints:n.filter(S=>S.start>=p&&S.end<=d)}}):[{id:`return@${o+1}`,kind:"return",label:"return",line:o,unit:t.index,group:"return",hook:!1,seedPoints:null}]}function ve(e,t){return{id:`write:${t}@${e.startLine+1}`,kind:"mutation",label:e.label,line:e.startLine,unit:e.index,group:`write:${t}@${e.startLine+1}`,hook:!1,seedPoints:null}}function Kt(e,t,n){let{ts:i}=e,r=Le(i,n.node);if(!r)return null;let o=J(e,r),s=t.writesByUnit.get(n.index);if(o!==null&&A(e,o)){let a=s?[...s.external]:[];return a.length>0?ve(n,a[0]):null}return i.isCallExpression(r)||i.isNewExpression(r)||i.isTaggedTemplateExpression(r)?zt(e,n,r,o,s):jt(e,n,r,o,t)}function jt(e,t,n,i,r){return i===null||i!=="this"&&!e.paramNames.has(i)&&_t(e,n,r,t)?null:ve(t,i)}function zt(e,t,n,i,r){let{ts:o,sourceFile:s}=e,a=o.isTaggedTemplateExpression(n)?n.tag:x(o,n.expression);if(i===null&&fn(e,a,r))return null;let u=K(a.getText(s)),l=o.isTaggedTemplateExpression(n)?null:U(o,a);return{id:`call:${u}@${t.startLine+1}`,kind:"effect-call",label:`${u}(\u2026)`,line:t.startLine,unit:t.index,group:`call:${u}@${t.startLine+1}`,hook:l!==null&&B.test(l),seedPoints:null}}function _t(e,t,n,i){let{ts:r}=e,o=r.isBinaryExpression(t)?t.left:r.isPrefixUnaryExpression(t)||r.isPostfixUnaryExpression(t)?t.operand:null;if(!o)return!1;let s=x(r,o);if(!r.isIdentifier(s)||!e.localNames.has(s.text))return!1;let a=n.definitionsByUnitName.get(`${i.index}\0${s.text}`);if(!a)return!0;let u=e.callable.getStart(e.sourceFile),l=e.callable.getEnd();return ke(a.symbolKey,e.sourceFile.fileName,u,l)}function Wt(e,t,n){if(e.isSpreadAssignment(n))return`...${K(n.expression.getText(t))}`;let i=n.name;return i?e.isIdentifier(i)||e.isPrivateIdentifier(i)||e.isStringLiteral(i)||e.isNumericLiteral(i)?i.text:K(i.getText(t)):K(n.getText(t))}function K(e){let t=e.replace(/\s+/gu," ").trim();return t.length>40?`${t.slice(0,37)}...`:t}function Ht(e,t){if(e.seedPoints===null)return[e.unit];let n=new Set;for(let i of e.seedPoints)for(let r of t.pointDeps.get(i.id)??[])n.add(r);return[...n]}function be(e,t){let n=new Set(e),i=[...e];for(;i.length>0;){let r=i.pop();for(let o of t(r))n.has(o)||(n.add(o),i.push(o))}return n}function Vt(e){let t=new Map,n=[];for(let o of e){if(o.guard){n.push(o);continue}let s=t.get(o.seed.group)??[];s.push(o),t.set(o.seed.group,s)}let i=new Map;e.forEach((o,s)=>i.set(o.seed.id,s));let r=[];for(let o of n)r.push({output:xe([o],!0),order:i.get(o.seed.id)});for(let o of t.values())r.push({output:xe(o,!1),order:Math.min(...o.map(s=>i.get(s.seed.id)))});return r.sort((o,s)=>o.order-s.order).map(o=>o.output)}function xe(e,t){let n=[...e].sort((s,a)=>s.seed.line-a.seed.line)[0],i=[...new Set(e.flatMap(s=>[...s.slice]))].sort(P),r=[...new Set(e.flatMap(s=>[...s.fullSlice]))].sort(P),o=[...new Set(e.map(s=>s.seed.unit))].sort(P);return{id:e.length===1?n.seed.id:`${n.seed.label}@${n.seed.line+1}`,kind:n.seed.kind,label:n.seed.label,line:n.seed.line,units:o,guard:t,hook:e.some(s=>s.seed.hook),sliceSize:i.length,fullSliceSize:r.length,slice:i,fullSlice:r}}function qt(e,t){if(e.length===0||t===0)return{tightness:0,fullTightness:0,sliceShare:0,fullSliceShare:0,overlap:0,superglue:0,glue:0};let n=we(e.map(j)),i=we(e.map(s=>s.fullSlice??[])),r=new Map;for(let s of e)for(let a of s.fullSlice??[])r.set(a,(r.get(a)??0)+1);let o=s=>s.reduce((a,u)=>a+u,0)/s.length;return{tightness:R(n.size/t),fullTightness:R(i.size/t),sliceShare:R(o(e.map(s=>s.sliceSize))/t),fullSliceShare:R(o(e.map(s=>s.fullSliceSize))/t),overlap:R(o(e.map(s=>s.sliceSize===0?0:n.size/s.sliceSize))),superglue:i.size,glue:[...r.values()].filter(s=>s>=2).length}}function we(e){if(e.length===0)return new Set;let t=new Set(e[0]);for(let n of e.slice(1)){let i=new Set(n);t=new Set([...t].filter(r=>i.has(r)))}return t}function R(e){return Math.round(e*100)/100}function Gt(e,t,n,i){let r=new Map;for(let l of e)for(let p of j(l))r.set(p,(r.get(p)??0)+1);let o=new Set;for(let l of i.writesByUnit.values())for(let p of l.local)o.add(p);let s=new Set([...r].filter(([l,p])=>p>=2&&!t.has(l)&&n.units[l].kind!=="predicate"&&![...i.definedNames[l]].some(d=>o.has(d))&&[...i.controlDeps[l]].every(d=>n.guardPredicates.has(d))&&(i.dataDeps[l].size===0||p>=e.length*Ie)).map(([l])=>l)),a=new Set,u=!0;for(;u;){u=!1;for(let l of s)a.has(l)||[...i.dataDeps[l]].every(p=>a.has(p))&&(a.add(l),u=!0)}return[...a].sort(P)}function Ce(e,t,n,i,r){let o=e.map(l=>j(l).filter(p=>!t.has(p))),s=Qt(e,o),a=[];for(let l of s.values()){let p=[...new Set(l.flatMap(d=>o[d]))].sort(P);p.length!==0&&a.push(Xt(e,l,p,t,n,i,r))}a.sort((l,p)=>p.units.length-l.units.length||en(l,p));let u=a.find(l=>l.role==="extraction");return u&&(u.role="remainder"),a}function Qt(e,t){let n=e.map((s,a)=>a),i=s=>{for(;n[s]!==s;)n[s]=n[n[s]],s=n[s];return s},r=new Map;t.forEach((s,a)=>{for(let u of s){let l=r.get(u);l===void 0?r.set(u,a):n[i(a)]=i(l)}});let o=new Map;return e.forEach((s,a)=>{let u=i(a),l=o.get(u)??[];l.push(a),o.set(u,l)}),o}function Jt(e,t,n,i){let r=new Set,o=[];for(let s of e){for(let a of i.paramReads[s])r.add(a);for(let a of i.outerReads[s])r.add(a);Zt(i,s,t,r);for(let a of n.hookCalls.get(s)??[])o.push(`${a}@${n.units[s].startLine+1}`)}return{inputs:r,hooks:o}}function Zt(e,t,n,i){for(let r of e.dataDeps[t])if(n.has(r))for(let o of e.definedNames[r])i.add(o)}function Xt(e,t,n,i,r,o,s){let{inputs:a,hooks:u}=Jt(n,i,r,o),l=t.map(h=>e[h]),p=l.every(h=>h.kind==="throw"),d=tn(n.map(h=>r.units[h])),S=d.reduce((h,m)=>h+m.endLine-m.startLine+1,0),g=n.length>=s.minClusterUnits&&!p&&S>=Ae;return{outputs:l.map(h=>h.id),units:n,lineRanges:d,inputs:[...a].sort(),kind:Yt(l,u,n.some(h=>r.awaitUnits.has(h))),role:g?"extraction":"below-threshold",narrow:a.size<=Q,hooks:u,guardOnly:p}}function Yt(e,t,n){if(t.length>0||e.some(o=>o.hook))return"hook";let i=e.some(o=>o.kind==="return"||o.kind==="return-property"),r=n||e.some(o=>o.kind==="effect-call"||o.kind==="mutation");return i?r?"operation":"calculation":"effects"}function en(e,t){return(e.lineRanges[0]?.startLine??0)-(t.lineRanges[0]?.startLine??0)}function tn(e){let t=[];for(let n of[...e].sort((i,r)=>i.startLine-r.startLine)){let i=t[t.length-1];i&&n.startLine<=i.endLine+1?i.endLine=Math.max(i.endLine,n.endLine):t.push({startLine:n.startLine,endLine:n.endLine})}return t}function nn(e,t){let n=Ne(e);return e.react?B.test(n)?"react-hook":"react-component":t.length>=Ke&&t.every(i=>i.kind==="effect-call")?"orchestration":"calculation"}function rn(e,t,n,i){if(!e)return{tier:"support",reason:"No split meets the selected output and statement thresholds."};if(i.status!=="complete")return{tier:"support",reason:`${t==="orchestration"?"Orchestration root: disjoint slices are expected. ":""}Local flow is partial (${Z(i)}), so a dropped dependency could join the clusters; the seam is unproven.`};if(t==="orchestration")return{tier:"support",reason:"The body matches an operation-sequencing pattern; disjoint slices alone do not justify splitting it."};let r=n.filter(s=>s.role==="extraction"),o=r.filter(s=>s.narrow);return o.length===0?{tier:"support",reason:`Local slices are disjoint, but each of the ${r.length} extraction(s) has more than ${Q} observed input names.`}:{tier:"signal",reason:`Local flow model complete; ${o.length} extraction(s) with at most ${Q} observed input names; review captured state and ordering before planning an extraction.`}}function Z(e){return e.unsupported[0]??"candidate dependencies or unsupported constructs present"}function on(e,t,n,i){let{body:r,flow:o,clusters:s,preamble:a,orphans:u,coverage:l}=i,p=t.filter(m=>m.guard).length,d=[`${e} statements, ${t.length-p} value output(s), ${p} guard exit(s); ${i.archetype}`,`tightness ${n.tightness.toFixed(2)} (with guards ${n.fullTightness.toFixed(2)}); overlap ${n.overlap.toFixed(2)}; local model only`];s.filter(m=>m.role!=="below-threshold").forEach((m,C)=>{d.push(`cluster ${C+1} (${m.kind}, ${m.role}): ${m.units.length} statements at ${O(m.lineRanges)} produce ${m.outputs.join(", ")}`+(m.role==="extraction"?m.inputs.length>0?`; takes ${$(m.inputs)}`:"; takes no parameters":""))});let S=s.filter(m=>m.role==="below-threshold"&&!m.guardOnly);if(S.length>0&&d.push(`${S.length} cluster(s) below --min-cluster ${i.thresholds.minClusterUnits} stay in place: ${S.map(m=>`${O(m.lineRanges)} (${m.outputs.join(", ")})`).join("; ")}`),a.length>0){let m=[...new Set(a.flatMap(C=>[...o.definedNames[C]]))];d.push(`${a.length} shared setup statement(s) derived only from inputs`+(m.length>0?`: ${$(m)}`:""))}if(u.length>0){let m=[...new Set(u.map(C=>r.units[C].startLine+1))];d.push(`${u.length} statement(s) reach no output: ${m.map(C=>`line ${C}`).join(", ")}`)}let g=[...r.handlerDeps.keys()].filter(m=>D.has(r.units[m].kind)).length;g>0&&d.push(`${g} catch/finally statement(s) were kept with the try block they handle`);let h=[...new Set([...o.stateWritesByUnit.values()].flat())];return h.length>0&&d.push(`state written at render time or in effects was treated as a dependency of later reads: ${$(h)}`),l.status!=="complete"&&d.push(`local flow partial: ${Z(l)}`),l.candidateEdges>0&&d.push(`${l.candidateEdges} candidate flow edge(s) (closure capture or field flow) were treated as dependencies; they can merge clusters but never separate them`),d}function $(e,t=8){return e.length>t?`${e.slice(0,t).join(", ")}, +${e.length-t} more`:e.join(", ")}function O(e,t=6){let n=e.map(i=>i.startLine===i.endLine?`line ${i.startLine+1}`:`lines ${i.startLine+1}-${i.endLine+1}`);return n.length>t?`${n.slice(0,t).join(", ")}, +${n.length-t} more ranges`:n.join(", ")}function sn(e,t,n,i){let{body:r,clusters:o,coverage:s,archetype:a}=i,u=Ne(r);if(!e)return an(t,n,i);let l=o.filter(m=>m.role==="extraction"),p=o.find(m=>m.role==="remainder"),d=(m,C)=>`${C+1}) ${cn(m)}: ${O(m.lineRanges)} producing ${Fe(m.outputs)}`+(m.inputs.length>0?` from (${$(m.inputs,6)})`:" from no parameters")+(m.narrow?"":` [wide interface: ${m.inputs.length} parameters]`)+(m.hooks.length>0?` [hooks: ${$(m.hooks,4)}]`:""),S=l.map(d).join("; "),g=ln(i,p);if(s.status!=="complete")return`${a==="orchestration"?"Preserve sequencing and treat it as an orchestration root. ":""}Inspect before extracting: local flow is partial (${Z(s)}). Candidate seam(s): ${S}. ${g}`.trim();if(a==="orchestration")return`${u} sequences ${l.length+1} independent operations (${S}); treat it as an orchestration root, not a cohesion defect, unless the steps serve unrelated purposes.`;let h=l.every(m=>m.kind==="effects")?" Advisory: an effect sequence may be intentional orchestration; confirm the steps serve a separate purpose before moving them.":"";return`Review a possible extraction from ${u}: ${S}. ${g}${h}`.trim()}function an(e,t,n){let{clusters:i}=n;if(e.length===0)return"No value output was found; the body has nothing to slice.";if(e.length===1)return"One value output; cohesion is trivially complete.";let r=new Set(i.flatMap(l=>l.outputs)),o=e.filter(l=>!r.has(l.id)).length,s=i.filter(l=>l.role==="below-threshold"&&!l.guardOnly),a=[];if(i.length===0)return`The ${e.length} value outputs read only shared setup derived from the inputs (${n.preamble.length} statement(s)); nothing separates them; keep the function whole.`;a.push(`The ${e.length} value outputs form ${i.length} cluster(s)`+(o>0?`, and ${o} of them read only shared setup`:""));let u=i.length===1?i[0]:null;return u&&u.outputs.length>1&&a.push(`${t.superglue} statement(s) feed every output and ${t.glue} feed more than one`+(t.superglue===0?"; the outputs are chained through shared statements, branch predicates, or state writes rather than one common root":"")),s.length>0&&a.push(`${s.length} cluster(s) stay below --min-cluster ${n.thresholds.minClusterUnits}: ${s.map(l=>O(l.lineRanges,2)).join("; ")}`),`${a.join("; ")}; keep the function whole.`}function Fe(e,t=4){let n=e.map(i=>i.replace(/@\d+$/u,""));return n.length>t?`${n.slice(0,t).join(", ")}, +${n.length-t} more`:n.join(", ")}function ln(e,t){let{flow:n,clusters:i,preamble:r,guards:o,thresholds:s}=e,a=[];if(t&&a.push(`the largest computation (${O(t.lineRanges,4)} producing ${Fe(t.outputs)})`),r.length>0){let l=[...new Set(r.flatMap(p=>[...n.definedNames[p]]))];a.push(`${r.length} shared setup statement(s)${l.length>0?` (${$(l,4)})`:""}`)}let u=i.filter(l=>l.role==="below-threshold"&&!l.guardOnly);return u.length>0&&a.push(`${u.length} smaller cluster(s) below --min-cluster ${s.minClusterUnits}`),o>0&&a.push(`${o} guard exit(s)`),a.length>0?`Stays in place: ${a.join(", ")}.`:""}function cn(e){switch(e.kind){case"calculation":return"pure calculation candidate";case"operation":return"operation candidate (awaits or effects inside; not pure)";case"hook":return"custom hook candidate (hooks stay unconditional and in order)";case"effects":return"effect sequence candidate"}}function Ne(e){let t=e.callable.name;return t&&"text"in t?String(t.text):"this function"}function un(e,t,n){for(let i of t)if(e.isVariableStatement(i))for(let r of i.declarationList.declarations)for(let o of v(r.name))n.add(o);else if(!e.isExpressionStatement(i))return!1;return!0}function dn(e,t,n){return!!(e.isPropertyAccessExpression(n)&&n.name===t||e.isPropertyAssignment(n)&&n.name===t||e.isBindingElement(n)&&n.propertyName===t||"name"in n&&n.name===t&&!e.isShorthandPropertyAssignment(n))}function pn(e,t){let n=x(e,t.expression);return e.isPropertyAccessExpression(n)?Te.has(n.name.text)?null:N(e,n):e.isElementAccessExpression(n)?N(e,n):null}function fn(e,t,n){let{ts:i}=e;if(i.isIdentifier(t)){let r=e.closures.get(t.text);if(r&&![...r.writes].some(o=>!A(e,o)))return!0}return!!(n&&n.local.size>0&&n.external.size===0)}function mn(e,t,n,i){n[t].add(z(e.name));let r=`${t}\0${e.name}`;i.has(r)||i.set(r,e)}function Sn(e,t,n,i,r){for(let o of n)o.unit===t.unit||o.base!==t.base||e[o.unit].start<=i||r[o.unit].add(t.unit)}export{Mn as a,ye as b};
2
+ //# sourceMappingURL=chunk-BUTWYEPH.js.map
@@ -0,0 +1,2 @@
1
+ import{b as c}from"./chunk-WOFQ5DTB.js";import{c as r,e as p,g as s,h as l}from"./chunk-3JIQS44J.js";import{c as a}from"./chunk-HRRFKWPZ.js";import{join as S}from"path";var u=3,b=2,x="typescript-semantic";function k(e){let n=S(e,x),i=p(n);return{...i,requestDir:i.legacyRequestDir}}function A(e){let n=JSON.parse(e),i=n.protocolVersion,o=i===b;if(!o&&i!==u||!E(n)||!o&&!M(n))throw new Error("TypeScript semantic service received an invalid mailbox request.");if(!o){let t=n,y=s("typescript-semantic-v3",{generation:t.generation,profileEnvironment:t.profileEnvironment,request:t.request});if(t.operationKey!==y)throw new Error("TypeScript semantic service received a mismatched mailbox operation identity.");return t}let m=s("typescript-semantic-v2",{id:n.id,generation:n.generation,request:n.request});return{protocolVersion:u,mailboxVersion:r,id:n.id,operationKey:m,clientId:"legacy-v2",enqueuedAtMs:n.deadlineAtMs,deadlineAtMs:n.deadlineAtMs,generation:n.generation,...n.profileEnvironment?{profileEnvironment:n.profileEnvironment}:{},request:n.request}}function E(e){return typeof e.id=="string"&&typeof e.generation=="string"&&typeof e.deadlineAtMs=="number"&&Number.isFinite(e.deadlineAtMs)&&(e.profileEnvironment===void 0||a(e.profileEnvironment))&&!!e.request&&g(e.request)}function M(e){return e.mailboxVersion===r&&typeof e.operationKey=="string"&&/^[a-f0-9]{64}$/.test(e.operationKey)&&e.id===l(e.operationKey)&&typeof e.clientId=="string"&&e.clientId!==""&&typeof e.enqueuedAtMs=="number"&&Number.isFinite(e.enqueuedAtMs)&&e.deadlineAtMs>=e.enqueuedAtMs}function g(e){if(!v(e))return!1;let n=e;switch(n.kind){case"availability":return!0;case"import-usage":return typeof n.file=="string";case"reference-fragments":return c(n.files)!==null;case"references":return T(n);case"callees":case"callee-coverage":return d(n.definitions);case"signature":return f(n.definition);default:return!1}}function d(e){return Array.isArray(e)&&e.every(f)}function f(e){if(!e||typeof e!="object")return!1;let n=e;return typeof n.symbolId=="number"&&typeof n.documentId=="number"&&typeof n.symbol=="string"&&typeof n.relativePath=="string"&&typeof n.leaf=="string"&&typeof n.startLine=="number"&&typeof n.endLine=="number"}function v(e){return!!e&&typeof e=="object"&&e!==null&&"kind"in e}function T(e){return d(e.definitions)&&(e.exact===void 0||typeof e.exact=="boolean")}export{u as a,k as b,A as c};
2
+ //# sourceMappingURL=chunk-BZB4QPIP.js.map
@@ -1,4 +1,4 @@
1
- import{a as s}from"./chunk-BRV7PIFF.js";var _=`SELECT COUNT(*) AS shared
1
+ import{c as s}from"./chunk-AOSIYPTA.js";var c=`SELECT COUNT(*) AS shared
2
2
  FROM (
3
3
  SELECT definition_m.symbol_id
4
4
  FROM documents definition_d
@@ -23,7 +23,7 @@ import{a as s}from"./chunk-BRV7PIFF.js";var _=`SELECT COUNT(*) AS shared
23
23
  JOIN documents reference_d ON reference_d.id = reference_c.document_id
24
24
  WHERE definition_d.relative_path = ?
25
25
  AND reference_d.relative_path = ?
26
- )`;function l(e,i,n){let r=s(e,i)??i,t=s(e,n)??n,o=e.get(_,r,t,t,r);return{...c(r,t,o?.shared??0)}}function N(e,i,n){return l(e,i,n)}function f(e,i={}){let{limit:n=20,scope:r}=i,t=r?"AND def_d.relative_path LIKE ? AND ref_d.relative_path LIKE ?":"",o=r?[`%${r}%`,`%${r}%`]:[];return e.all(`SELECT
26
+ )`;function l(e,n,r){let i=s(e,n),t=s(e,r);if(!i||!t)throw new Error("Coupling requires two uniquely resolved indexed files. Use exact project paths.");if(i===t)throw new Error("Coupling requires two distinct files.");let d=e.get(c,i,t,t,i);return{..._(i,t,d?.shared??0)}}function N(e,n,r){return l(e,n,r)}function f(e,n={}){let{limit:r=20,scope:i}=n,t=i?"AND instr(def_d.relative_path, ?) > 0 AND instr(ref_d.relative_path, ?) > 0":"",d=i?[i,i]:[];return e.all(`SELECT
27
27
  CASE WHEN def_d.relative_path < ref_d.relative_path THEN def_d.relative_path ELSE ref_d.relative_path END AS file1,
28
28
  CASE WHEN def_d.relative_path < ref_d.relative_path THEN ref_d.relative_path ELSE def_d.relative_path END AS file2,
29
29
  COUNT(DISTINCT gs.id) AS shared
@@ -45,5 +45,5 @@ import{a as s}from"./chunk-BRV7PIFF.js";var _=`SELECT COUNT(*) AS shared
45
45
  ${t}
46
46
  GROUP BY file1, file2
47
47
  ORDER BY shared DESC, file1, file2
48
- LIMIT ?`,...o,n).filter(d=>!e.isIgnored(d.file1)&&!e.isIgnored(d.file2)).map(d=>c(d.file1,d.file2,d.shared))}function h(e,i={}){return f(e,i)}function c(e,i,n){return{file1:e,file2:i,sharedSymbols:n,actionTier:"signal",couplingKind:"shared-symbol-coupling",evidenceReasons:[`${n} symbol(s) are defined in one file and referenced by the other`],recommendation:"Review whether the shared symbol surface is an intentional boundary or hidden coordination pressure before moving code."}}export{l as a,N as b,f as c,h as d};
49
- //# sourceMappingURL=chunk-ILTDAWEF.js.map
48
+ LIMIT ?`,...d,r).filter(o=>!e.isIgnored(o.file1)&&!e.isIgnored(o.file2)).map(o=>_(o.file1,o.file2,o.shared))}function h(e,n={}){return f(e,n)}function _(e,n,r){return{file1:e,file2:n,sharedSymbols:r,actionTier:"signal",couplingKind:"shared-symbol-coupling",evidenceReasons:[`${r} symbol(s) are defined in one file and referenced by the other`],recommendation:"Review whether the shared symbol surface is an intentional boundary or hidden coordination pressure before moving code."}}export{l as a,N as b,f as c,h as d};
49
+ //# sourceMappingURL=chunk-CE357GEE.js.map
@@ -0,0 +1,2 @@
1
+ import{b as l}from"./chunk-AOSIYPTA.js";import{a as n}from"./chunk-GCKCF5FL.js";import{D as i}from"./chunk-5D2LVK7O.js";function d(e,r){let s=l(e,r);if(s.length===0)return{files:[],symbols:[],dependsOn:[],dependedOnBy:[]};let o=s.filter(t=>!e.isIgnored(t)).sort(),m=i(e,o,{sort:!0}),a=n(e,"forward",s).filter(t=>!e.isIgnored(t)),p=n(e,"reverse",s).filter(t=>!e.isIgnored(t));return{files:o,symbols:m,dependsOn:a,dependedOnBy:p}}function u(e,r){return d(e,r)}export{d as a,u as b};
2
+ //# sourceMappingURL=chunk-CFN45HFP.js.map