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.
- package/CHANGELOG.md +491 -2
- package/README.md +111 -122
- package/dist/augment-vue-worker.js +1 -1
- package/dist/by-kind-PRVFAGTQ.js +2 -0
- package/dist/call-graph-DVPAQV2F.js +2 -0
- package/dist/call-graph-evidence-CUtj8V2I.d.ts +19 -0
- package/dist/chunk-2FSBGL5P.js +2 -0
- package/dist/chunk-2HLAFUCY.js +2 -0
- package/dist/chunk-2IWUT6CJ.js +3 -0
- package/dist/chunk-2KNN7GTQ.js +2 -0
- package/dist/chunk-2LHXRE2B.js +8 -0
- package/dist/{chunk-EG2CPZMJ.js → chunk-2YXE77TJ.js} +2 -2
- package/dist/chunk-36SGVCGX.js +2 -0
- package/dist/chunk-3ABBFPTP.js +2 -0
- package/dist/chunk-3IVFU4FD.js +3 -0
- package/dist/chunk-3JIQS44J.js +7 -0
- package/dist/chunk-3ZRB6DNK.js +7 -0
- package/dist/{chunk-6YTSKJJ3.js → chunk-42EOW5VI.js} +1 -1
- package/dist/{chunk-6I6L7Z62.js → chunk-4BHGBMNO.js} +2 -2
- package/dist/chunk-4BP3UBDG.js +2 -0
- package/dist/chunk-4D6RO7G4.js +2 -0
- package/dist/chunk-4FEWQ6RH.js +2 -0
- package/dist/chunk-4IGEOBG7.js +2 -0
- package/dist/chunk-4QZXBUKC.js +2 -0
- package/dist/chunk-4WBDEVX2.js +4 -0
- package/dist/chunk-4WCUBZU3.js +8 -0
- package/dist/chunk-4WTUBQ36.js +40 -0
- package/dist/chunk-4XQ4O6IM.js +3 -0
- package/dist/chunk-55UQAMZO.js +4 -0
- package/dist/chunk-5D2LVK7O.js +125 -0
- package/dist/chunk-5IYJ56TT.js +2 -0
- package/dist/chunk-5PLMJC7Q.js +2 -0
- package/dist/chunk-5TNQJUR2.js +5 -0
- package/dist/chunk-62BDNPMI.js +2 -0
- package/dist/chunk-64DZ5TXR.js +7 -0
- package/dist/chunk-65245JCM.js +2 -0
- package/dist/chunk-6FFVZZL4.js +2 -0
- package/dist/chunk-6KO5JHAR.js +2 -0
- package/dist/chunk-6LRXOOSX.js +2 -0
- package/dist/chunk-6LSEIIF7.js +2 -0
- package/dist/chunk-6YMNWD3H.js +6 -0
- package/dist/chunk-72AD6ZRR.js +5 -0
- package/dist/chunk-73AAKPUC.js +4 -0
- package/dist/chunk-76CZ77DF.js +2 -0
- package/dist/chunk-7VPEEAAG.js +2 -0
- package/dist/chunk-7WTPQ4NX.js +14 -0
- package/dist/chunk-7Y5T6XDP.js +2 -0
- package/dist/chunk-A2IIGFMJ.js +5 -0
- package/dist/chunk-AB5KCTEV.js +2 -0
- package/dist/chunk-AC566WBP.js +6 -0
- package/dist/chunk-AGWFSTXC.js +3 -0
- package/dist/chunk-AOSIYPTA.js +2 -0
- package/dist/chunk-AUVEWPIF.js +2 -0
- package/dist/chunk-B56T42J3.js +25 -0
- package/dist/chunk-BIQEF5NE.js +2 -0
- package/dist/chunk-BL6XJKTA.js +3 -0
- package/dist/chunk-BMKOQJRI.js +2 -0
- package/dist/chunk-BOZ4EXBB.js +3 -0
- package/dist/chunk-BUTWYEPH.js +2 -0
- package/dist/chunk-BZB4QPIP.js +2 -0
- package/dist/{chunk-ILTDAWEF.js → chunk-CE357GEE.js} +4 -4
- package/dist/chunk-CFN45HFP.js +2 -0
- package/dist/chunk-CFYMZFXT.js +368 -0
- package/dist/chunk-CN5EH7O3.js +2 -0
- package/dist/chunk-D254DNNQ.js +4 -0
- package/dist/chunk-D3FDISIC.js +2 -0
- package/dist/chunk-D3NX5XIE.js +3 -0
- package/dist/chunk-DA7RPPDF.js +3 -0
- package/dist/chunk-DDMC3FON.js +3 -0
- package/dist/chunk-DIO3FUSG.js +2 -0
- package/dist/chunk-DJ2NNSUK.js +3 -0
- package/dist/chunk-DKYQIM3C.js +18 -0
- package/dist/{chunk-JTQVMR42.js → chunk-DOOEL2IV.js} +2 -2
- package/dist/chunk-DVFP6PZI.js +2 -0
- package/dist/chunk-E3FDPXZK.js +2 -0
- package/dist/chunk-E7YNJLCB.js +2 -0
- package/dist/chunk-EFGW5JPH.js +2 -0
- package/dist/chunk-EJVTR244.js +13 -0
- package/dist/chunk-EOV7RTRZ.js +2 -0
- package/dist/chunk-ETOIKRHO.js +2 -0
- package/dist/chunk-EYK3ZAO2.js +3 -0
- package/dist/chunk-F2V2LPET.js +52 -0
- package/dist/chunk-F4LUHJTF.js +2 -0
- package/dist/chunk-F4PUT6IT.js +2 -0
- package/dist/chunk-F56GCXXS.js +5 -0
- package/dist/chunk-FC2EVQRM.js +2 -0
- package/dist/chunk-FL7NBMHP.js +3 -0
- package/dist/chunk-FMRN2TRL.js +3 -0
- package/dist/chunk-FVULPZDF.js +20 -0
- package/dist/chunk-GCKCF5FL.js +43 -0
- package/dist/chunk-GH2PYF46.js +2 -0
- package/dist/chunk-GHJAGXIP.js +2 -0
- package/dist/{chunk-WIWY3CRX.js → chunk-GMVSHUKZ.js} +2 -2
- package/dist/chunk-GS6KDO4R.js +2 -0
- package/dist/chunk-GUUBXNN7.js +2 -0
- package/dist/chunk-GVWX5T43.js +80 -0
- package/dist/chunk-GZKFETP5.js +2 -0
- package/dist/chunk-H4EQHO6J.js +9 -0
- package/dist/chunk-H73WY2RM.js +2 -0
- package/dist/chunk-H75GSPRV.js +60 -0
- package/dist/chunk-HDR3AHSV.js +61 -0
- package/dist/chunk-HQBSL74Y.js +2 -0
- package/dist/chunk-HRRFKWPZ.js +2 -0
- package/dist/chunk-HXENDJC6.js +2 -0
- package/dist/chunk-IIBAZNSW.js +21 -0
- package/dist/chunk-INLMWEUU.js +12 -0
- package/dist/chunk-IWQPAF4F.js +2 -0
- package/dist/chunk-IZJ6YUKP.js +35 -0
- package/dist/chunk-J2TMAIN5.js +60 -0
- package/dist/chunk-J5FJMODQ.js +142 -0
- package/dist/chunk-J7HZPIO3.js +2 -0
- package/dist/chunk-JEVRKFRL.js +2 -0
- package/dist/chunk-JFXSGAEB.js +30 -0
- package/dist/chunk-JVRTHGFS.js +3 -0
- package/dist/chunk-JYWEX7RR.js +360 -0
- package/dist/chunk-K3YL22N6.js +2 -0
- package/dist/chunk-K4CN7GXK.js +12 -0
- package/dist/chunk-K5TBVXU4.js +30 -0
- package/dist/chunk-KDDIE2DP.js +9 -0
- package/dist/chunk-KHWRRPV4.js +2 -0
- package/dist/chunk-KI6NBKDY.js +14 -0
- package/dist/chunk-KU3QRSTH.js +2 -0
- package/dist/chunk-KZBJWZJB.js +2 -0
- package/dist/chunk-L7GFM3NP.js +3 -0
- package/dist/chunk-LMO6PK3V.js +35 -0
- package/dist/chunk-LN4YXJJU.js +2 -0
- package/dist/chunk-LOVIZBJ4.js +43 -0
- package/dist/chunk-LPCRK4A2.js +11 -0
- package/dist/chunk-MMHZKBFA.js +2 -0
- package/dist/{chunk-M2O5NY6W.js → chunk-MOQQBQRD.js} +2 -2
- package/dist/chunk-N2WN6I3L.js +2 -0
- package/dist/chunk-N3ORQT7L.js +2 -0
- package/dist/chunk-NAZ3RAIW.js +2 -0
- package/dist/chunk-NDUNO5JQ.js +2 -0
- package/dist/chunk-NEIWRNAZ.js +4 -0
- package/dist/chunk-NJJMVD65.js +2 -0
- package/dist/chunk-NLOQOBXI.js +20 -0
- package/dist/chunk-NOLZOVCU.js +2 -0
- package/dist/chunk-NOWINRRN.js +2 -0
- package/dist/chunk-NZAXKGRL.js +16 -0
- package/dist/chunk-O2C4UILI.js +2 -0
- package/dist/chunk-O3RHA6ZT.js +3 -0
- package/dist/chunk-O4UZSPPI.js +3 -0
- package/dist/chunk-OGFV2BUX.js +2 -0
- package/dist/chunk-OZCJXZK6.js +499 -0
- package/dist/chunk-P6ODM7BY.js +2 -0
- package/dist/{chunk-XBGWL66K.js → chunk-PAVGPRHJ.js} +2 -2
- package/dist/chunk-PH52RA7D.js +2 -0
- package/dist/chunk-PKN354TH.js +3 -0
- package/dist/chunk-PWOASWEG.js +11 -0
- package/dist/chunk-QIWXRW72.js +2 -0
- package/dist/chunk-QJRMOK5N.js +2 -0
- package/dist/{chunk-YXPUP5G2.js → chunk-QOIXNWQR.js} +2 -2
- package/dist/chunk-QXEUDXBT.js +3 -0
- package/dist/chunk-QYUVVBMR.js +6 -0
- package/dist/chunk-QZ7KQZRN.js +2 -0
- package/dist/chunk-R6LQBUDH.js +2 -0
- package/dist/chunk-RBS42E55.js +20 -0
- package/dist/chunk-RSJKPCFX.js +26 -0
- package/dist/chunk-S6CZA3MV.js +2 -0
- package/dist/chunk-STMVAHJP.js +2 -0
- package/dist/chunk-SYVPTTVW.js +2 -0
- package/dist/chunk-T3I6NHBH.js +2 -0
- package/dist/chunk-T6DK3ZP7.js +2 -0
- package/dist/chunk-TKD34PHN.js +4 -0
- package/dist/chunk-TNNQFH7W.js +2 -0
- package/dist/chunk-TNV7SSUF.js +2 -0
- package/dist/chunk-TO7ZR3EH.js +8 -0
- package/dist/chunk-TOU3CHK4.js +2 -0
- package/dist/chunk-TRBI4UKT.js +2 -0
- package/dist/chunk-TZCVNCAN.js +4 -0
- package/dist/chunk-U4LZA5LL.js +3 -0
- package/dist/chunk-U5RIG3JP.js +3 -0
- package/dist/chunk-UP5KXN2I.js +2 -0
- package/dist/chunk-UQFR3NDH.js +5 -0
- package/dist/chunk-UXYXF7GV.js +2 -0
- package/dist/chunk-VB3GOKOS.js +2 -0
- package/dist/chunk-VF5JZICY.js +2 -0
- package/dist/chunk-VTY3VK6E.js +2 -0
- package/dist/chunk-VX2O4RIS.js +2 -0
- package/dist/chunk-WKPV2TDZ.js +2 -0
- package/dist/chunk-WOFQ5DTB.js +2 -0
- package/dist/chunk-WS4C6TCK.js +2 -0
- package/dist/chunk-WXU3DGPU.js +2 -0
- package/dist/chunk-X6RMKHJQ.js +81 -0
- package/dist/{chunk-4ILJCCXV.js → chunk-XHMN6ZX7.js} +2 -2
- package/dist/chunk-XHTVFLWW.js +2 -0
- package/dist/chunk-XKIDJCIK.js +2 -0
- package/dist/chunk-XTYTYZPT.js +2 -0
- package/dist/chunk-Y2JHHTTA.js +2 -0
- package/dist/chunk-YGVRMGYN.js +4 -0
- package/dist/chunk-YNQCGEQE.js +2 -0
- package/dist/chunk-YOQVEXVE.js +14 -0
- package/dist/chunk-YRT2WLYY.js +2 -0
- package/dist/chunk-YTAP5Y2G.js +2 -0
- package/dist/chunk-YTYWI7VB.js +2 -0
- package/dist/chunk-YULZRALL.js +2 -0
- package/dist/chunk-Z33WQG4Q.js +2 -0
- package/dist/chunk-ZGTYGDMF.js +16 -0
- package/dist/chunk-ZHMRSZFD.js +43 -0
- package/dist/chunk-ZHSP366W.js +10 -0
- package/dist/chunk-ZIBYCYKK.js +7 -0
- package/dist/{chunk-GAS2LJMP.js → chunk-ZLADLUE6.js} +3 -3
- package/dist/chunk-ZO4YXUT6.js +4 -0
- package/dist/{chunk-HYO3NP5Q.js → chunk-ZR4HBC2H.js} +2 -2
- package/dist/cli-main.js +6 -6
- package/dist/cli.js +1 -1
- package/dist/{code-B17qEMbt.d.ts → code-BNyrCF3_.d.ts} +3 -2
- package/dist/code-IL5WH3NZ.js +2 -0
- package/dist/code-result-json-ANTBEDFP.js +4 -0
- package/dist/command-descriptors-HEEMDHTU.js +222 -0
- package/dist/deps-EOWFC6FD.js +2 -0
- package/dist/direct-navigation-Y5B6OSIQ.js +3 -0
- package/dist/{exploration-topology-BG4v30HZ.d.ts → exploration-topology-CSgEyAz-.d.ts} +3 -1
- package/dist/files-K4AI3JUM.js +2 -0
- package/dist/frontend-profile-roles-D7eCum8P.d.ts +10 -0
- package/dist/{health-CPp2Jf1Z.d.ts → health-BtfmNrfa.d.ts} +58 -74
- package/dist/hierarchy-6W5NDIFI.js +2 -0
- package/dist/imports-WH365QY4.js +2 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +1 -1
- package/dist/members-K3PHMF5S.js +2 -0
- package/dist/methods-E7KVMBX4.js +2 -0
- package/dist/output-continuation-command-BJSY67SN.js +3 -0
- package/dist/output-pagination-UZJ5ACIX.js +24 -0
- package/dist/postinstall.js +1 -1
- package/dist/project-reindex-EP24WT4X.js +3 -0
- package/dist/queries/affected.js +1 -1
- package/dist/queries/architecture.d.ts +15 -4
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +3 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +1 -0
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +3 -3
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +20 -2
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +1 -1
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity.d.ts +6 -3
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/context.d.ts +1 -7
- package/dist/queries/context.js +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dead.d.ts +2 -0
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/dependence-slice.d.ts +46 -22
- package/dist/queries/dependence-slice.js +1 -1
- package/dist/queries/dependency-depth.d.ts +1 -7
- package/dist/queries/dependency-depth.js +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.d.ts +3 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +29 -2
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/entry-map.d.ts +2 -4
- package/dist/queries/entry-map.js +1 -1
- package/dist/queries/evidence.d.ts +121 -61
- package/dist/queries/evidence.js +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +1 -1
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +2 -2
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +1 -0
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +3 -3
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +17 -65
- package/dist/queries/index.js +1 -1
- package/dist/queries/locality-candidates.d.ts +4 -4
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.d.ts +2 -2
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.d.ts +2 -6
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +9 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +19 -3
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.d.ts +22 -3
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.d.ts +17 -3
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +4 -14
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.d.ts +4 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/review.d.ts +188 -0
- package/dist/queries/review.js +2 -0
- package/dist/queries/similar-files.d.ts +7 -10
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +19 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice-cohesion.d.ts +205 -0
- package/dist/queries/slice-cohesion.js +2 -0
- package/dist/queries/source-inspection.d.ts +6 -202
- package/dist/queries/source-inspection.js +1 -1
- package/dist/queries/source-search.d.ts +2 -3
- package/dist/queries/source-search.js +1 -1
- package/dist/queries/stats.d.ts +1 -0
- package/dist/queries/stats.js +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.d.ts +4 -2
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.d.ts +1 -1
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/twin-drift.d.ts +23 -7
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.d.ts +3 -15
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/query-service-fastpath.js +5 -5
- package/dist/query-service-server.js +4 -4
- package/dist/refs-CCBJG7WK.js +2 -0
- package/dist/refs-pagination-DRNLVU4S.js +2 -0
- package/dist/reindex-worker.js +79 -29
- package/dist/reindex.js +45 -45
- package/dist/repository-cache-worker.js +2 -0
- package/dist/runtime.d.ts +8 -8
- package/dist/runtime.js +3 -4
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/service-queries-2WAJI7R6.js +6 -0
- package/dist/source-inspection-91U9zdO3.d.ts +341 -0
- package/dist/{source-search-types-Dwz8KeuW.d.ts → source-search-types-DWGYNg8M.d.ts} +15 -2
- package/dist/stats-G7DIV6VU.js +2 -0
- package/dist/surface-IO55UALI.js +2 -0
- package/dist/system-ZBMSHJXU.js +2 -0
- package/dist/{queries/trace.d.ts → trace-BMjw3prn.d.ts} +1 -18
- package/dist/typescript-indexer.js +2 -0
- package/dist/typescript-mailbox-worker.js +1 -1
- package/dist/watch-server.js +3 -3
- package/docs/AGENT_GUIDE.md +19 -128
- package/docs/CLI_JSON_OUTPUT.md +21 -17
- package/docs/COMMAND_REFERENCE.md +34 -49
- package/docs/CURRENT_COMMANDS.md +123 -0
- package/docs/DETECTOR_EVIDENCE_CONTRACTS.md +0 -40
- package/docs/DETECTOR_GUIDE.md +55 -12
- package/docs/PRODUCT_VISION.md +135 -0
- package/docs/PROPERTY_TESTING.md +73 -0
- package/docs/REVIEW.md +76 -0
- package/docs/SKILLS.md +51 -0
- package/docs/WINDOWS_SIDECAR_RELEASE.md +12 -3
- package/docs/accuracy-audit-checklist.md +70 -13
- package/docs/analyzer-inventory.md +2 -2
- package/docs/locality-analyzer-design.md +9 -9
- package/package.json +18 -80
- package/scripts/evidence-product-contract.mjs +7 -3
- package/scripts/record-review-coverage.mjs +118 -0
- package/scripts/scip-windows-provenance.mjs +29 -19
- package/skills/scip-architecture-review/SKILL.md +57 -0
- package/skills/scip-architecture-review/agents/openai.yaml +4 -0
- package/skills/scip-architecture-review/references/design-checks.md +17 -0
- package/skills/scip-explore/SKILL.md +15 -59
- package/skills/scip-explore/agents/openai.yaml +3 -3
- package/skills/scip-explore/references/external-evidence.md +2 -2
- package/skills/scip-explore/references/information-model.md +26 -29
- package/skills/scip-explore/scripts/capture-evidence.mjs +68 -34
- package/skills/scip-integrity-audit/SKILL.md +53 -181
- package/skills/scip-integrity-audit/agents/openai.yaml +3 -3
- package/skills/scip-integrity-audit/references/integrity-probes.md +27 -0
- package/skills/scip-plan/SKILL.md +39 -65
- package/skills/scip-plan/agents/openai.yaml +2 -2
- package/skills/scip-query/SKILL.md +28 -81
- package/skills/scip-query/agents/openai.yaml +2 -2
- package/skills/scip-query/references/command-guide.md +169 -0
- package/skills/scip-setup/SKILL.md +4 -2
- package/skills/scip-setup/agents/openai.yaml +3 -3
- package/dist/by-kind-XI2CSWEY.js +0 -2
- package/dist/call-graph-UONR6JR5.js +0 -2
- package/dist/call-graph-evidence-lZa2dwQA.d.ts +0 -11
- package/dist/chunk-26CT72HM.js +0 -2
- package/dist/chunk-2E7CX53V.js +0 -2
- package/dist/chunk-2GRUZAQF.js +0 -43
- package/dist/chunk-2LDBDR6J.js +0 -29
- package/dist/chunk-2OOY75BW.js +0 -2
- package/dist/chunk-2R3V3PSD.js +0 -4
- package/dist/chunk-2WC2OEDO.js +0 -4
- package/dist/chunk-35NLDRZC.js +0 -2
- package/dist/chunk-3AF4TUFK.js +0 -3
- package/dist/chunk-3D3QG236.js +0 -2
- package/dist/chunk-3FHOF22C.js +0 -21
- package/dist/chunk-3JKSW6LJ.js +0 -2
- package/dist/chunk-3L2ZBPEX.js +0 -133
- package/dist/chunk-3PJABJSU.js +0 -2
- package/dist/chunk-3SVF22I5.js +0 -2
- package/dist/chunk-3WR4E3A3.js +0 -3
- package/dist/chunk-4FTZ4P5G.js +0 -2
- package/dist/chunk-4UX2F3JX.js +0 -2
- package/dist/chunk-4WNW27SX.js +0 -2
- package/dist/chunk-5ENOG4VP.js +0 -61
- package/dist/chunk-64BFSI5I.js +0 -2
- package/dist/chunk-66DVSJQG.js +0 -455
- package/dist/chunk-6HFCYNYE.js +0 -9
- package/dist/chunk-6PQNKL3G.js +0 -3
- package/dist/chunk-6V5CNXL6.js +0 -2
- package/dist/chunk-6VVV4WRR.js +0 -4
- package/dist/chunk-7BWFZPPZ.js +0 -2
- package/dist/chunk-7CYG22FH.js +0 -2
- package/dist/chunk-7F45LJKI.js +0 -2
- package/dist/chunk-7IWV2EG3.js +0 -3
- package/dist/chunk-7KCZELVM.js +0 -2
- package/dist/chunk-AFHTBORT.js +0 -2
- package/dist/chunk-AVRYW5OZ.js +0 -2
- package/dist/chunk-B3X6KU75.js +0 -2
- package/dist/chunk-B5D7QPBE.js +0 -4
- package/dist/chunk-BBCIS4DX.js +0 -16
- package/dist/chunk-BDUVI7TO.js +0 -3
- package/dist/chunk-BE7ZZTMC.js +0 -2
- package/dist/chunk-BHVUJOCQ.js +0 -3
- package/dist/chunk-BJT7LSPK.js +0 -3
- package/dist/chunk-BKVWUP7Y.js +0 -2
- package/dist/chunk-BQGB4HBD.js +0 -2
- package/dist/chunk-BRV7PIFF.js +0 -2
- package/dist/chunk-CEEZJXEF.js +0 -2
- package/dist/chunk-CIYLO6SI.js +0 -7
- package/dist/chunk-CJZXN4NU.js +0 -2
- package/dist/chunk-CNO7TOKL.js +0 -2
- package/dist/chunk-COF23M5F.js +0 -2
- package/dist/chunk-CWFP7GM5.js +0 -2
- package/dist/chunk-D2DHWI3D.js +0 -2
- package/dist/chunk-D4N5SQ2M.js +0 -4
- package/dist/chunk-DBRSYFXR.js +0 -2
- package/dist/chunk-DHUIOLDT.js +0 -2
- package/dist/chunk-DIRJWYBM.js +0 -6
- package/dist/chunk-DIUFNHRJ.js +0 -35
- package/dist/chunk-DRENNWRG.js +0 -2
- package/dist/chunk-DTZCKZEU.js +0 -4
- package/dist/chunk-DULC3QFP.js +0 -5
- package/dist/chunk-DYGHBZ2N.js +0 -16
- package/dist/chunk-E5R6AQ73.js +0 -40
- package/dist/chunk-E73UNJTF.js +0 -38
- package/dist/chunk-EKV5HX33.js +0 -2
- package/dist/chunk-EQHFIL6T.js +0 -3
- package/dist/chunk-ESIQ66Z7.js +0 -2
- package/dist/chunk-EVFUMY4R.js +0 -3
- package/dist/chunk-F7DY272B.js +0 -2
- package/dist/chunk-FBN2FGXG.js +0 -2
- package/dist/chunk-FDLOBR6P.js +0 -4
- package/dist/chunk-FESCRNVV.js +0 -5
- package/dist/chunk-FFRKR4EQ.js +0 -2
- package/dist/chunk-FGA2U4OR.js +0 -8
- package/dist/chunk-FIQRSHVM.js +0 -2
- package/dist/chunk-FPYLNQPT.js +0 -2
- package/dist/chunk-FRUSVINH.js +0 -2
- package/dist/chunk-GSP44ENC.js +0 -2
- package/dist/chunk-GUFSG5TX.js +0 -2
- package/dist/chunk-GYIZ4NXB.js +0 -2
- package/dist/chunk-GZIUDL6G.js +0 -2
- package/dist/chunk-H5EXS3HM.js +0 -2
- package/dist/chunk-HCXEQRFF.js +0 -18
- package/dist/chunk-HEHOQQKH.js +0 -2
- package/dist/chunk-HKGFPJ4T.js +0 -4
- package/dist/chunk-HLZTEXRA.js +0 -2
- package/dist/chunk-HOENASQM.js +0 -3
- package/dist/chunk-HVF5VBG6.js +0 -2
- package/dist/chunk-I55I7XXP.js +0 -2
- package/dist/chunk-IDFEUFKS.js +0 -2
- package/dist/chunk-IHGQTTVW.js +0 -2
- package/dist/chunk-IICPE7B2.js +0 -20
- package/dist/chunk-IL676XCC.js +0 -18
- package/dist/chunk-IW5XQG5G.js +0 -2
- package/dist/chunk-IZDPJ2QI.js +0 -2
- package/dist/chunk-J66VOFW6.js +0 -5
- package/dist/chunk-JFMEXGFE.js +0 -2
- package/dist/chunk-JGKUET5J.js +0 -3
- package/dist/chunk-JS4PGXMV.js +0 -3
- package/dist/chunk-JWTGMPIT.js +0 -80
- package/dist/chunk-JYR66JN5.js +0 -5
- package/dist/chunk-KFOYCQAJ.js +0 -9
- package/dist/chunk-KLFEXGQA.js +0 -2
- package/dist/chunk-KMVGRIO2.js +0 -2
- package/dist/chunk-KYSDI3GE.js +0 -5
- package/dist/chunk-L6PJPETJ.js +0 -29
- package/dist/chunk-LDVT66YM.js +0 -2
- package/dist/chunk-LEECKFCJ.js +0 -2
- package/dist/chunk-LMZ5PRUV.js +0 -2
- package/dist/chunk-LQRQN2XA.js +0 -2
- package/dist/chunk-LXABEJX3.js +0 -2
- package/dist/chunk-MNV5FSBW.js +0 -3
- package/dist/chunk-MPQ4OTBM.js +0 -2
- package/dist/chunk-MTDBHTSF.js +0 -2
- package/dist/chunk-MV3CDXPI.js +0 -38
- package/dist/chunk-MWN53KRN.js +0 -60
- package/dist/chunk-MXNGIEPU.js +0 -3
- package/dist/chunk-N2ZSIIGR.js +0 -117
- package/dist/chunk-N5B2NILC.js +0 -5
- package/dist/chunk-NJITK2GP.js +0 -2
- package/dist/chunk-NOGJXYFO.js +0 -2
- package/dist/chunk-NOYBFVJA.js +0 -554
- package/dist/chunk-NWQXSFFU.js +0 -3
- package/dist/chunk-ODDUPDP7.js +0 -13
- package/dist/chunk-OLIWTZI3.js +0 -3
- package/dist/chunk-OLNV6I6U.js +0 -2
- package/dist/chunk-OR2E3AGZ.js +0 -2
- package/dist/chunk-OSR2GEHQ.js +0 -2
- package/dist/chunk-OSSESPDX.js +0 -3
- package/dist/chunk-OWOOWNJ5.js +0 -7
- package/dist/chunk-P42EIXTA.js +0 -2
- package/dist/chunk-PJFGPYTU.js +0 -2
- package/dist/chunk-PP7KNN7L.js +0 -2
- package/dist/chunk-PU7T5QYQ.js +0 -2
- package/dist/chunk-PWWAJSKV.js +0 -74
- package/dist/chunk-PZL5T7SU.js +0 -73
- package/dist/chunk-QBE3YX64.js +0 -23
- package/dist/chunk-QGVTFRY2.js +0 -7
- package/dist/chunk-QOJONDS7.js +0 -2
- package/dist/chunk-QU5XRYB5.js +0 -4
- package/dist/chunk-QUU5OBVK.js +0 -11
- package/dist/chunk-RBLQNW26.js +0 -20
- package/dist/chunk-RTQ7NEKG.js +0 -81
- package/dist/chunk-SQXRS7BG.js +0 -4
- package/dist/chunk-SSK6LDPC.js +0 -2
- package/dist/chunk-SZHGTCPP.js +0 -7
- package/dist/chunk-T4N4P2K5.js +0 -16
- package/dist/chunk-TA3QKLLU.js +0 -2
- package/dist/chunk-TEBQMNVI.js +0 -43
- package/dist/chunk-TPFHAQ2G.js +0 -2
- package/dist/chunk-TQPCBMWT.js +0 -5
- package/dist/chunk-TQZV7KV4.js +0 -2
- package/dist/chunk-TRNAEQ6P.js +0 -3
- package/dist/chunk-TY7CRN3Z.js +0 -2
- package/dist/chunk-UHFYCMZO.js +0 -35
- package/dist/chunk-UICY4GTQ.js +0 -7
- package/dist/chunk-UVGEWT4Y.js +0 -26
- package/dist/chunk-UXW33INU.js +0 -29
- package/dist/chunk-VMPRET3I.js +0 -5
- package/dist/chunk-VNLGKHS6.js +0 -6
- package/dist/chunk-VQILFTEH.js +0 -2
- package/dist/chunk-VUPHCS7Y.js +0 -57
- package/dist/chunk-VVZSBTSU.js +0 -23
- package/dist/chunk-VZRNID6A.js +0 -2
- package/dist/chunk-W5OXRYGE.js +0 -7
- package/dist/chunk-W6STWDQI.js +0 -57
- package/dist/chunk-W7CXK74K.js +0 -2
- package/dist/chunk-WB3WYIRE.js +0 -4
- package/dist/chunk-WDNVY4E7.js +0 -20
- package/dist/chunk-WK46TNUM.js +0 -3
- package/dist/chunk-WNTFFKAX.js +0 -12
- package/dist/chunk-WOIKCX6A.js +0 -2
- package/dist/chunk-WUN6KBHV.js +0 -2
- package/dist/chunk-WYCTJDVR.js +0 -2
- package/dist/chunk-WYPL7GF7.js +0 -2
- package/dist/chunk-XDAUYDFT.js +0 -2
- package/dist/chunk-XDQMU3BT.js +0 -2
- package/dist/chunk-XFA4SSO3.js +0 -3
- package/dist/chunk-XGZEP6GR.js +0 -8
- package/dist/chunk-XPDPNWTQ.js +0 -368
- package/dist/chunk-XRYABF57.js +0 -8
- package/dist/chunk-YBGKCQIS.js +0 -2
- package/dist/chunk-YEN6CYC7.js +0 -16
- package/dist/chunk-YF5IB2LF.js +0 -2
- package/dist/chunk-YI2AWIHC.js +0 -3
- package/dist/chunk-YPWBKGFU.js +0 -2
- package/dist/chunk-YPWHBBIS.js +0 -2
- package/dist/chunk-YSH6U3L4.js +0 -3
- package/dist/chunk-YU5DZUZI.js +0 -10
- package/dist/chunk-YWO5DDRC.js +0 -16
- package/dist/chunk-Z4CDXYNQ.js +0 -2
- package/dist/chunk-ZF5KHH7C.js +0 -2
- package/dist/chunk-ZOHS7AQV.js +0 -21
- package/dist/chunk-ZTI4SBFV.js +0 -3
- package/dist/code-MI6F2TTU.js +0 -2
- package/dist/code-result-json-FXALY4HE.js +0 -2
- package/dist/command-descriptors-P34VABY5.js +0 -343
- package/dist/dataflow-4KEMJPC6.js +0 -2
- package/dist/dependence-slice-R7FPWD5M.js +0 -2
- package/dist/deps-7EMQUYUT.js +0 -2
- package/dist/direct-navigation-6YO234F2.js +0 -3
- package/dist/entry-map-KOOLR26E.js +0 -2
- package/dist/files-OPIPJIGZ.js +0 -2
- package/dist/graph-evidence-Bjyky2V4.d.ts +0 -126
- package/dist/hierarchy-QPD2CAER.js +0 -2
- package/dist/imports-M6HUXRXC.js +0 -2
- package/dist/members-I5MEFOCT.js +0 -2
- package/dist/methods-5JYGGHXA.js +0 -2
- package/dist/next-anchor-candidates-BwMczMvX.d.ts +0 -90
- package/dist/output-continuation-command-UPQAAKBP.js +0 -3
- package/dist/output-pagination-3OFL2MJV.js +0 -19
- package/dist/project-reindex-UKKQ5PLS.js +0 -3
- package/dist/queries/anchors.d.ts +0 -123
- package/dist/queries/anchors.js +0 -2
- package/dist/queries/complexity-hotspots.d.ts +0 -40
- package/dist/queries/complexity-hotspots.js +0 -2
- package/dist/queries/convergence.d.ts +0 -33
- package/dist/queries/convergence.js +0 -2
- package/dist/queries/dataflow.d.ts +0 -77
- package/dist/queries/dataflow.js +0 -2
- package/dist/queries/deep-chains.d.ts +0 -5
- package/dist/queries/deep-chains.js +0 -2
- package/dist/queries/extract-candidates.d.ts +0 -52
- package/dist/queries/extract-candidates.js +0 -2
- package/dist/queries/isolated.d.ts +0 -24
- package/dist/queries/isolated.js +0 -2
- package/dist/queries/plan-context.d.ts +0 -33
- package/dist/queries/plan-context.js +0 -2
- package/dist/queries/reference-neighborhood.d.ts +0 -4
- package/dist/queries/reference-neighborhood.js +0 -2
- package/dist/queries/reference-reachability.d.ts +0 -48
- package/dist/queries/reference-reachability.js +0 -2
- package/dist/queries/self-audit.d.ts +0 -63
- package/dist/queries/self-audit.js +0 -2
- package/dist/queries/similar-chains.d.ts +0 -48
- package/dist/queries/similar-chains.js +0 -2
- package/dist/queries/slice.d.ts +0 -4
- package/dist/queries/slice.js +0 -2
- package/dist/queries/stale-abstractions.d.ts +0 -72
- package/dist/queries/stale-abstractions.js +0 -2
- package/dist/queries/system-map.d.ts +0 -449
- package/dist/queries/system-map.js +0 -2
- package/dist/queries/trace.js +0 -2
- package/dist/queries/twin-ab.d.ts +0 -66
- package/dist/queries/twin-ab.js +0 -2
- package/dist/queries/value-flow.d.ts +0 -43
- package/dist/queries/value-flow.js +0 -2
- package/dist/queries/wrapper-candidates.d.ts +0 -34
- package/dist/queries/wrapper-candidates.js +0 -2
- package/dist/refs-PSU4JZZW.js +0 -2
- package/dist/refs-pagination-JG6CJMRC.js +0 -2
- package/dist/slice-HYRATV64.js +0 -2
- package/dist/source-snippet-_wrcgmZc.d.ts +0 -15
- package/dist/stats-OOJ74B32.js +0 -2
- package/dist/surface-VTGDYWF5.js +0 -2
- package/dist/symbol-resolution-WD5EU5JE.js +0 -2
- package/dist/system-LRQNFOR2.js +0 -2
- package/dist/trace-F4B6OLL4.js +0 -2
- package/dist/value-flow-VRPZY72V.js +0 -2
- package/skills/concrete-plan/SKILL.md +0 -8
- package/skills/concrete-plan/agents/openai.yaml +0 -4
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var _p=Symbol.for("scip-query.project-file-listing-context.v1"),Dp=globalThis,Ec=Dp[_p],K=Ec&&typeof Ec=="object"?Ec:{};Dp[_p]=K;function GW(e){if(K.active)return e();let t=K.active,n=K.canonicalProjectRoots;K.active=new Map,K.canonicalProjectRoots=new Map;try{return e()}finally{K.active=t,K.canonicalProjectRoots=n}}function VW(){let e=K.active,t=K.canonicalProjectRoots;K.active=new Map,K.canonicalProjectRoots=new Map;let n=!1;return()=>{n||(n=!0,K.active=e,K.canonicalProjectRoots=t)}}function kp(e,t){let n=K.active?K.canonicalProjectRoots:void 0,r=n?.get(e);if(r!==void 0)return r;let i=t();return n?.set(e,i),i}function Ap(){return K.sequence??0}function qo(e,t,n){let r=K.active,i=r?.get(e);if(i&&i.pathBytes<=t)return i;let o=nR(n(),(K.sequence??0)+1);if(K.sequence=o.sequence,o.pathBytes>t)throw new RangeError(`Git project file listing exceeded ${t} path bytes.`);return r?.set(e,o),o}function Op(e,t){let n=K.active?.get(e);return n&&n.sequence>t?n.indexAllowsTreeFingerprintReuse:void 0}function*Ho(e){let t=0;for(;t<e.taggedOutput.length;){let n=e.taggedOutput.indexOf("\0",t);if(n<0)return;yield e.taggedOutput.slice(t+2,n),t=n+1}}function nR(e,t){let n=0,r=0,i=!0;for(;n<e.length;){let o=e.indexOf("\0",n);if(o<0||o<=n+2||e[n+1]!==" ")throw new Error("Git returned a malformed tagged project file listing.");let s=e[n];i&&=s==="H"||s==="?",r+=1,n=o+1}return{taggedOutput:e,pathBytes:Buffer.byteLength(e,"utf8")-r*2,indexAllowsTreeFingerprintReuse:i,sequence:t}}import{createHash as aR,randomUUID as cR}from"crypto";import{readdirSync as lR}from"fs";import{dirname as Gp,extname as uR,join as _c,relative as Vp,sep as Wp}from"path";import{fileURLToPath as dR}from"url";import{createRequire as pR}from"module";import{closeSync as Pc,fstatSync as zo,openSync as wc,readSync as Fc}from"fs";import{createHash as rR}from"crypto";var re=8*1024*1024,An=64*1024*1024,fe=512*1024*1024,iR=256*1024*1024,Wt=class extends Error{constructor(n,r,i,o,s){let a=i==="too-large"?`is ${o} bytes; the safety limit is ${s} bytes`:i==="not-regular"?"is not a regular file":"changed while it was being read";super(`${n} ${JSON.stringify(r)} ${a}`);this.inputKind=n;this.inputPath=r;this.reason=i;this.observedBytes=o;this.limitBytes=s;this.name="BoundedFileReadError"}inputKind;inputPath;reason;observedBytes;limitBytes;code="SCIP_QUERY_BOUNDED_FILE_READ"};function H(e,t){dn(t.maxBytes);let n=String(e),r=wc(e,"r");try{let i=zo(r);Bp(i,t,n);let o=Tc(r,i.size);return jp(i,zo(r),o.byteLength,t,n),o}finally{Pc(r)}}function Tc(e,t){dn(t);let n=Buffer.allocUnsafe(t),r=0;for(;r<n.length;){let i=Fc(e,n,r,n.length-r,r);if(i===0)break;r+=i}return n.subarray(0,r)}function z(e,t,n="utf8"){return H(e,t).toString(n)}function _(e,t){return z(e,{maxBytes:re,inputKind:t})}function oR(e,t){return z(e,{maxBytes:An,inputKind:t})}function Nc(e,t){dn(t.maxBytes);let n=[],r=Buffer.allocUnsafe(64*1024),i=0;for(;;){let o=Fc(e,r,0,r.length,null);if(o===0)break;if(i+=o,!Number.isSafeInteger(i)||i>t.maxBytes)throw new Wt(t.inputKind,`file descriptor ${e}`,"too-large",i,t.maxBytes);n.push(Buffer.from(r.subarray(0,o)))}return Buffer.concat(n,i)}function sR(e,t,n="utf8"){return Nc(e,t).toString(n)}function Mp(e,t){let n=wc(e,"r");try{return Nc(n,t)}finally{Pc(n)}}function Lc(e,t,n="utf8"){return Mp(e,t).toString(n)}function Sr(e,t,n){dn(t.maxBytes);let r=String(e),i=wc(e,"r");try{let o=zo(i);Bp(o,t,r);let s=Buffer.allocUnsafe(Math.min(1024*1024,Math.max(1,o.size))),a=0;for(;a<o.size;){let c=Fc(i,s,0,Math.min(s.length,o.size-a),a);if(c===0)break;n(s.subarray(0,c)),a+=c}return jp(o,zo(i),a,t,r),a}finally{Pc(i)}}function On(e,t){let n=rR("sha256");return Sr(e,t,r=>n.update(r)),n.digest("hex")}function jp(e,t,n,r,i){if(t.dev!==e.dev||t.ino!==e.ino||t.size!==e.size||t.mtimeMs!==e.mtimeMs||n!==e.size)throw new Wt(r.inputKind,i,"changed-during-read",t.size,r.maxBytes)}function Bp(e,t,n){if(!e.isFile())throw new Wt(t.inputKind,n,"not-regular",Number(e.size),t.maxBytes);if(e.size>t.maxBytes)throw new Wt(t.inputKind,n,"too-large",Number(e.size),t.maxBytes)}function dn(e){if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`maxBytes must be a non-negative safe integer; received ${e}`)}var $p=pR(import.meta.url),fi=mR(),Ko=fi.version,Dc=fi.path?Gp(fi.path):null,pi;function Up(){if(pi!==void 0)return pi;try{if(!fi.path)throw new Error("Package location unavailable");let e=Gp(fi.path),n=Vp(e,dR(import.meta.url)).startsWith(`src${Wp}`)?"src":"dist";pi=fR(e,n)}catch{pi=`unavailable:${cR()}`}return pi}function fR(e,t){let n=aR("sha256").update("scip-query-runtime-v2\0"),r=t==="src"?new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".json"]):new Set([".js",".mjs",".cjs",".json"]),i=qp(_c(e,t),r);if(i.length===0)throw new Error("Package runtime is empty");for(let o of[_c(e,"package.json"),...i]){let s=H(o,{maxBytes:re,inputKind:"Package runtime input"});n.update(Vp(e,o).split(Wp).join("/")).update("\0"),n.update(String(s.length)).update("\0").update(s)}return n.digest("hex").slice(0,16)}function qp(e,t){let n=[],r=lR(e,{withFileTypes:!0}).sort((i,o)=>i.name<o.name?-1:i.name>o.name?1:0);for(let i of r){let o=_c(e,i.name);if(i.isDirectory())n.push(...qp(o,t));else if(i.isFile())t.has(uR(i.name))&&n.push(o);else throw new Error(`Unsupported runtime entry: ${o}`)}return n}function mR(){for(let e of["../package.json","../../package.json"])try{let t=$p(e);if(t.name==="scip-query"&&typeof t.version=="string")return{version:t.version,path:$p.resolve(e)}}catch{}return{version:"0.0.0"}}import{createHash as kR}from"crypto";import{existsSync as AR,mkdirSync as OR}from"fs";import{dirname as pf,join as MR}from"path";import Bc from"better-sqlite3";function ft(e,t,n=[]){let r=Ac(e);if(Xp.has(r)||n.some(o=>Jo(r,o))||t.some(o=>Qp(r,o)))return"config";if(t.some(ef)&&/\.d\.(?:ts|mts|cts)$/.test(r.toLowerCase()))return"ambient";let i=Zp(r);return t.some(o=>(tf[o]??[]).includes(i))?"source":"other"}function Yp(e,t,n){let r=Ac(e);if(Xp.has(r)||n?.some(o=>Jo(r,o))||Qp(r,t)||ef(t)&&/\.d\.(?:ts|mts|cts)$/.test(r.toLowerCase()))return!0;let i=Zp(r);return(tf[t]??[]).includes(i)}function mi(e){if(typeof e!="object"||e===null)return null;let t=e;return!vR(t)||t.clojureConfigPath!==void 0&&typeof t.clojureConfigPath!="string"||!Array.isArray(t.files)||!t.files.every(kc)?null:t}function br(e){return{...e,files:e.files.map(({semanticHash:t,...n})=>n)}}function gi(e,t){return!e||!t?e===t:JSON.stringify(br(e))===JSON.stringify(br(t))}function gR(e,t,n,r){if(!n&&r)return{kind:"added",path:e,inputKind:t,after:r};if(n&&!r)return{kind:"deleted",path:e,inputKind:t,before:n};if(n&&r&&(n.hash!==r.hash||n.size!==r.size))return{kind:"modified",path:e,inputKind:t,before:n,after:r}}function yR(e,t){let n=e?.files??[],r=new Set;return e||r.add("prior-snapshot-unavailable"),e&&e.version!==t.version&&r.add("snapshot-version-changed"),(zp(n)||zp(t.files))&&r.add("duplicate-input-path"),[...n,...t.files].some(hR)&&r.add("unreadable-input"),[...r].sort()}function eU(e,t){let n=new Map((e?.files??[]).map(a=>[a.path,a])),r=new Map(t.files.map(a=>[a.path,a])),i=new Set([...n.keys(),...r.keys()]),o=[];for(let a of[...i].sort()){let c=n.get(a),l=r.get(a),u=ft(a,t.languages),d=gR(a,u,c,l);d&&o.push(d)}let s=yR(e,t);return{version:1,changes:o,projectIdentityChanged:e?!SR(e,t):!0,uncertainty:s}}function Hp(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function zp(e){return new Set(e.map(t=>t.path)).size!==e.length}function kc(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.path=="string"&&typeof t.size=="number"&&Number.isFinite(t.size)&&typeof t.hash=="string"&&(t.semanticHash===void 0||typeof t.semanticHash=="string")}function hR(e){return e.hash==="unreadable"||e.size<0}function SR(e,t){return Kp(e.languages,t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&Kp(e.typescriptProjects,t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function Kp(e,t){if(e.length!==t.length)return!1;let n=[...e].sort(),r=[...t].sort();return n.every((i,o)=>i===r[o])}var Xp=new Set([".scipquery.json"]),bR={typescript:["tsconfig.json"],javascript:["package.json"],java:["pom.xml","build.gradle"],scala:["build.sbt"],kotlin:["build.gradle.kts"],rust:["Cargo.toml"],python:["pyproject.toml","setup.py"],ruby:["Gemfile"],go:["go.mod"],cpp:["CMakeLists.txt","Makefile"],c:["CMakeLists.txt","Makefile"],csharp:["*.csproj","*.sln"],vb:["*.vbproj","*.sln"],dart:["pubspec.yaml"],php:["composer.json"],clojure:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"]},xR={typescript:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","tsconfig.*.json","jsconfig.json","jsconfig.*.json"],javascript:["package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","tsconfig.json","tsconfig.*.json","jsconfig.json","jsconfig.*.json"],java:["build.gradle.kts","settings.gradle","settings.gradle.kts","gradle.properties","gradle.lockfile","gradle-wrapper.properties"],scala:["plugins.sbt","build.properties"],kotlin:["pom.xml","build.gradle","settings.gradle","settings.gradle.kts","gradle.properties","gradle.lockfile","gradle-wrapper.properties"],rust:["Cargo.lock","rust-project.json","rust-toolchain","rust-toolchain.toml"],python:["setup.cfg","requirements*.txt","Pipfile","Pipfile.lock","poetry.lock","uv.lock"],ruby:["Gemfile.lock","gems.locked"],go:["go.sum","go.work","go.work.sum"],cpp:["compile_commands.json"],c:["compile_commands.json"],csharp:["Directory.Build.props","Directory.Build.targets","Directory.Packages.props","packages.lock.json","NuGet.Config","global.json"],vb:["Directory.Build.props","Directory.Build.targets","Directory.Packages.props","packages.lock.json","NuGet.Config","global.json"],dart:["pubspec.lock","analysis_options.yaml"],php:["composer.lock"],clojure:[]},Jp=new Map;function Qp(e,t){return bR[t].some(n=>Jo(e,n))||xR[t].some(n=>Jo(e,n))}function Jo(e,t){let n=Ac(t).replace(/^\.\//,"");if(!n)return!1;let r=e.split("/").at(-1)??e,i=n.includes("/")?e:r;if(!n.includes("*")&&!n.includes("?"))return i===n;let o=Jp.get(n);if(!o){let s=n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]");o=new RegExp(`^${s}$`),Jp.set(n,o)}return o.test(i)}function Ac(e){return e.replaceAll("\\","/").replace(/^\.\//,"")}function Zp(e){return e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:""}function ef(e){return e==="typescript"||e==="javascript"}var tf={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs",".vue"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"],clojure:[".clj",".cljs",".cljc"]};function vR(e){return!(typeof e.version!="number"||!Hp(e.languages)||typeof e.pnpmWorkspaces!="boolean"||typeof e.typescriptProjectMode!="string"||!Hp(e.typescriptProjects))}function Fe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Yo(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function nU(e){return Fe(e)&&Object.values(e).every(t=>typeof t=="string"||t===null)}function RR(e){return typeof e=="string"&&e.length>0}function R(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function yi(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var IR=/^[a-f0-9]{64}$/u;function nf(e){return typeof e=="string"&&IR.test(e)}function rU(e){return typeof e=="string"&&e.length>0&&e.length<=256&&!/[\0\r\n]/u.test(e)}function mt(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function iU(e){return Fe(e)&&e.name==="scip-query"&&RR(e.version)}var Xo=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"],sU=["entry-surface","generated-code","compatibility-shim","reflection-or-registration","test-fixture","intentional-twin","historical-coupling-ended","detector-counterexample"];var Oc=2,hi=3;var Mc=new Set(Xo);function Ct(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(s){return{kind:"malformed",reason:`invalid JSON: ${_R(s)}`}}if(!Fe(t))return{kind:"malformed",reason:"metadata must be a JSON object"};let n=t.version;if(!Number.isInteger(n))return{kind:"malformed",reason:"version must be an integer"};if(n!==Oc&&n!==hi)return{kind:"unsupported",version:n,direction:n<Oc?"older":"future"};let r=ER(t,n);if(r)return{kind:"malformed",reason:r};let i=t,o={metadata:i,capabilities:CR(i)};return n===Oc?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function pU(e){return e.kind==="legacy"||e.kind==="supported"?e.metadata:null}function rf(e){if(e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.stableGenerationIdentity)return null;let t=e.metadata;return JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages,scipCompanion:t.scipCompanion,sqliteLayoutVersion:t.version===hi?t.sqliteLayoutVersion:void 0})}function CR(e){let t=e.fingerprint!==void 0,n=Fe(e.fingerprint),r=e.indexedLanguages!==void 0,i=e.status==="complete",o=e.version===hi?e:null;return{usableForQuery:r,usableForEvidenceCache:t,publishableGeneration:i&&n&&r,stableGenerationIdentity:i&&t&&typeof e.updatedAt=="string",languageShardReuse:!!o?.languageFingerprints,typescriptProjectShardReuse:!!o?.typescriptProjectShards}}function ER(e,t){if(e.status!=="complete"&&e.status!=="partial")return"status must be complete or partial";if(e.updatedAt!==void 0&&!Yo(e.updatedAt))return"updatedAt must be a valid timestamp";let n=PR(e);return n||(t===hi?wR(e):null)}function PR(e){for(let t of["requestedLanguages","indexedLanguages"])if(e[t]!==void 0&&!FR(e[t]))return`${t} must contain unique supported languages`;return e.skipped!==void 0&&!TR(e.skipped)?"skipped must contain supported language/reason pairs":e.scipCompanion!==void 0&&e.scipCompanion!=="current"&&e.scipCompanion!=="deferred"?"scipCompanion must be current or deferred":null}function wR(e){return e.sqliteLayoutVersion!==void 0&&(!Number.isSafeInteger(e.sqliteLayoutVersion)||e.sqliteLayoutVersion<1)?"sqliteLayoutVersion must be a positive safe integer":e.languageFingerprints!==void 0&&!NR(e.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":e.typescriptProjectShards!==void 0&&!LR(e.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function fU(e){return e.version===hi&&e.sqliteLayoutVersion===1}function FR(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string"&&Mc.has(t))?!1:new Set(e).size===e.length}function TR(e){return Array.isArray(e)&&e.every(t=>Fe(t)&&typeof t.language=="string"&&Mc.has(t.language)&&typeof t.reason=="string")}function NR(e){return Fe(e)&&Object.entries(e).every(([t,n])=>Mc.has(t)&&Fe(n))}function LR(e){return Fe(e)&&Object.values(e).every(t=>Fe(t)&&Array.isArray(t.files)&&t.files.every(kc))}function _R(e){return e instanceof Error?e.message:String(e)}var of=[];function Ut(e){e.groups.length>0&&of.push(e)}function sf(e,t){let n=new Set(t.groups);for(let r of of)r.groups.some(i=>n.has(i))&&(t.file!==void 0&&r.clearFile?r.clearFile(e,t.file):r.clearAll(e))}var af=256;function jc(e){let t=e.maxEntries;if(t!==void 0){if(!Number.isSafeInteger(t)||t<1)throw new Error(`Per-database cache maxEntries must be a positive safe integer; received ${t}.`);return t}return e.clearGroups.includes("source-file")?af:void 0}function cf(e,t,n){e.delete(t),e.set(t,n)}function lf(e,t){if(t!==void 0)for(;e.size>t;){let n=e.keys().next().value;if(n===void 0)return;e.delete(n)}}function uf(){let e=new WeakMap;return{cache:e,ensure(t){let n=e.get(t);return n||(n=new Map,e.set(t,n)),n}}}function U(e,t){let{cache:n,ensure:r}=uf(),i=jc(t),o={get(s,a,c){let l=r(s);if(l.has(a)){let d=l.get(a);return cf(l,a,d),d}let u=c();return l.set(a,u),lf(l,i),u},has(s,a){return n.get(s)?.has(a)??!1},invalidate(s,a){n.get(s)?.delete(a)},invalidateAll(s){n.delete(s)},size(s){return n.get(s)?.size??0}};return Ut({name:e,groups:t.clearGroups,clearAll:s=>o.invalidateAll(s)}),o}function ie(e,t){let n=U(e,{clearGroups:[],maxEntries:jc(t)}),r=o=>o.replace(/\\/g,"/"),i={get:(o,s,a)=>n.get(o,r(s),a),has:(o,s)=>n.has(o,r(s)),invalidate:(o,s)=>n.invalidate(o,r(s)),invalidateAll:n.invalidateAll,size:n.size};return Ut({name:e,groups:t.clearGroups,clearAll:i.invalidateAll,clearFile:i.invalidate}),i}function oe(e,t){let n=new WeakMap,r={get(i,o){let s=n.get(i);if(s)return s.value;let a=o();return n.set(i,{value:a}),a},invalidate(i){n.delete(i)},has(i){return n.has(i)}};return Ut({name:e,groups:t.clearGroups,clearAll:i=>r.invalidate(i)}),r}var DR={clearGroups:["whole-project","source-file"],maxEntries:af};function pn(e){return Mn(e,DR)}function Mn(e,t){let{cache:n,ensure:r}=uf(),i=jc(t),o={get(s,a,c,l){a=a.replace(/\\/g,"/");let u=r(s),d=u.get(a);if(d&&d.source===c)return cf(u,a,d),d.value;let p=l();return u.set(a,{source:c,value:p}),lf(u,i),p},invalidate(s,a){n.get(s)?.delete(a.replace(/\\/g,"/"))},invalidateAll(s){n.delete(s)}};return Ut({name:e,groups:t.clearGroups,clearAll:s=>o.invalidateAll(s),clearFile:(s,a)=>o.invalidate(s,a)}),o}var jR="evidence.db";var BR=["source-facts","definition-exclusions","doc-path-tokens","react-component-behavior-profiles"],Zo=new Set(BR),$R=25e4,GR=512*1024*1024,VR=6e4,Qo=new WeakMap,WR=ie("evidence-content-hash",{clearGroups:["whole-project","source-file"]}),UR=U("evidence-project-fingerprint",{clearGroups:["whole-project"]}),Si="evidence-v1",jn="version NOT LIKE 'evidence-%'",df=null;function xe(){return df??=`${Si}+${Up()}`,df}function $(e){return kR("sha256").update(e).digest("hex")}function Se(e,t,n){return WR.get(e,t,()=>$(n))}function qt(e){return UR.get(e,"current",()=>{try{if(!e.generation.metadataRaw)return null;let t=Ct(e.generation.metadataRaw);if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.usableForEvidenceCache)return null;let n=t.metadata,r=[...n.indexedLanguages??[]].sort();return $(JSON.stringify({fingerprint:n.fingerprint,indexedLanguages:r,status:n.status}))}catch(t){return Bn("project fingerprint unavailable",t),null}})}function Bn(e,t){process.env.SCIP_QUERY_DEBUG&&console.error(`evidence-cache: ${e}: ${t instanceof Error?t.message:String(t)}`)}function gt(e){if(Qo.has(e))return Qo.get(e)??null;let t=null;try{let n=new Bc(e.config.evidenceDbPath??MR(pf(e.config.dbPath),jR));n.pragma("journal_mode = WAL"),n.pragma("busy_timeout = 5000"),n.pragma("synchronous = NORMAL"),n.exec(`
|
|
3
|
+
CREATE TABLE IF NOT EXISTS file_evidence (
|
|
4
|
+
kind TEXT NOT NULL,
|
|
5
|
+
relative_path TEXT NOT NULL,
|
|
6
|
+
content_hash TEXT NOT NULL,
|
|
7
|
+
version TEXT NOT NULL,
|
|
8
|
+
payload TEXT NOT NULL,
|
|
9
|
+
PRIMARY KEY (kind, relative_path)
|
|
10
|
+
);
|
|
11
|
+
CREATE TABLE IF NOT EXISTS project_evidence (
|
|
12
|
+
kind TEXT NOT NULL,
|
|
13
|
+
cache_key TEXT NOT NULL,
|
|
14
|
+
project_fingerprint TEXT NOT NULL,
|
|
15
|
+
version TEXT NOT NULL,
|
|
16
|
+
payload TEXT NOT NULL,
|
|
17
|
+
PRIMARY KEY (kind, cache_key)
|
|
18
|
+
);
|
|
19
|
+
CREATE TABLE IF NOT EXISTS semantic_callees (
|
|
20
|
+
relative_path TEXT NOT NULL,
|
|
21
|
+
symbol TEXT NOT NULL,
|
|
22
|
+
content_hash TEXT NOT NULL,
|
|
23
|
+
deps_digest TEXT NOT NULL,
|
|
24
|
+
version TEXT NOT NULL,
|
|
25
|
+
payload TEXT NOT NULL,
|
|
26
|
+
PRIMARY KEY (relative_path, symbol)
|
|
27
|
+
);
|
|
28
|
+
CREATE TABLE IF NOT EXISTS semantic_references (
|
|
29
|
+
relative_path TEXT NOT NULL,
|
|
30
|
+
symbol TEXT NOT NULL,
|
|
31
|
+
project_fingerprint TEXT NOT NULL,
|
|
32
|
+
version TEXT NOT NULL,
|
|
33
|
+
payload TEXT NOT NULL,
|
|
34
|
+
PRIMARY KEY (relative_path, symbol)
|
|
35
|
+
);
|
|
36
|
+
`);for(let r of["file_evidence","project_evidence"])n.prepare(`DELETE FROM ${r} WHERE version LIKE 'evidence-%' AND version != ?`).run(xe());t={evidence:n,shared:qR(e.config.sharedEvidenceDbPath),readFileEvidence:n.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),readLegacyFileEvidence:n.prepare(`SELECT payload FROM file_evidence
|
|
37
|
+
WHERE kind = ? AND relative_path = ? AND content_hash = ? AND ${jn}
|
|
38
|
+
ORDER BY version DESC
|
|
39
|
+
LIMIT 1`),existsFileEvidence:n.prepare("SELECT 1 AS present FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),existsLegacyFileEvidence:n.prepare(`SELECT 1 AS present FROM file_evidence
|
|
40
|
+
WHERE kind = ? AND relative_path = ? AND content_hash = ? AND ${jn}
|
|
41
|
+
LIMIT 1`),writeFileEvidence:n.prepare("INSERT OR REPLACE INTO file_evidence (kind, relative_path, content_hash, version, payload) VALUES (?, ?, ?, ?, ?)"),rekeyFileEvidence:n.prepare("UPDATE file_evidence SET content_hash = ?, version = ? WHERE kind = ? AND relative_path = ? AND content_hash = ?"),readProjectEvidence:n.prepare("SELECT payload FROM project_evidence WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND version = ?"),readLegacyProjectEvidence:n.prepare(`SELECT payload FROM project_evidence
|
|
42
|
+
WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND ${jn}
|
|
43
|
+
ORDER BY version DESC
|
|
44
|
+
LIMIT 1`),writeProjectEvidence:n.prepare("INSERT OR REPLACE INTO project_evidence (kind, cache_key, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)"),rekeyProjectEvidenceKind:n.prepare("UPDATE project_evidence SET project_fingerprint = ?, version = ? WHERE kind = ? AND project_fingerprint = ?"),readCallees:n.prepare(`SELECT payload FROM semantic_callees
|
|
45
|
+
WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCallees:n.prepare(`SELECT payload FROM semantic_callees
|
|
46
|
+
WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND ${jn}
|
|
47
|
+
ORDER BY version DESC
|
|
48
|
+
LIMIT 1`),readCalleesForFile:n.prepare(`SELECT symbol, payload FROM semantic_callees
|
|
49
|
+
WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCalleesForFile:n.prepare(`SELECT symbol, payload FROM semantic_callees
|
|
50
|
+
WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND ${jn}
|
|
51
|
+
ORDER BY symbol, version DESC`),writeCallees:n.prepare(`INSERT OR REPLACE INTO semantic_callees
|
|
52
|
+
(relative_path, symbol, content_hash, deps_digest, version, payload) VALUES (?, ?, ?, ?, ?, ?)`),dropStaleCallees:n.prepare("DELETE FROM semantic_callees WHERE relative_path = ? AND content_hash != ?"),readReferences:n.prepare(`SELECT payload FROM semantic_references
|
|
53
|
+
WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferences:n.prepare(`SELECT payload FROM semantic_references
|
|
54
|
+
WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND ${jn}
|
|
55
|
+
ORDER BY version DESC
|
|
56
|
+
LIMIT 1`),readReferencesForFile:n.prepare(`SELECT symbol, payload FROM semantic_references
|
|
57
|
+
WHERE relative_path = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferencesForFile:n.prepare(`SELECT symbol, payload FROM semantic_references
|
|
58
|
+
WHERE relative_path = ? AND project_fingerprint = ? AND ${jn}
|
|
59
|
+
ORDER BY symbol, version DESC`),writeReferences:n.prepare(`INSERT OR REPLACE INTO semantic_references
|
|
60
|
+
(relative_path, symbol, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)`),dropStaleReferences:n.prepare("DELETE FROM semantic_references WHERE relative_path = ? AND project_fingerprint != ?")}}catch(n){Bn("disabled (open failed)",n)}return Qo.set(e,t),t}function yt(e,t,n){Bn(`disabled (${t})`,n),Qo.set(e,null)}function qR(e){if(!e)return null;try{OR(pf(e),{recursive:!0});let t=new Bc(e);return t.pragma("journal_mode = WAL"),t.pragma("busy_timeout = 250"),t.pragma("synchronous = NORMAL"),t.exec(`
|
|
61
|
+
CREATE TABLE IF NOT EXISTS file_evidence (
|
|
62
|
+
kind TEXT NOT NULL,
|
|
63
|
+
relative_path TEXT NOT NULL,
|
|
64
|
+
content_hash TEXT NOT NULL,
|
|
65
|
+
version TEXT NOT NULL,
|
|
66
|
+
payload TEXT NOT NULL,
|
|
67
|
+
last_accessed_at INTEGER NOT NULL,
|
|
68
|
+
PRIMARY KEY (kind, relative_path, content_hash, version)
|
|
69
|
+
);
|
|
70
|
+
CREATE INDEX IF NOT EXISTS idx_file_evidence_lru
|
|
71
|
+
ON file_evidence(last_accessed_at, kind, relative_path, content_hash, version);
|
|
72
|
+
`),{evidence:t,readFileEvidence:t.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),existsFileEvidence:t.prepare("SELECT 1 AS present FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),writeFileEvidence:t.prepare(`INSERT INTO file_evidence (kind, relative_path, content_hash, version, payload, last_accessed_at)
|
|
73
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
74
|
+
ON CONFLICT(kind, relative_path, content_hash, version)
|
|
75
|
+
DO UPDATE SET payload = excluded.payload, last_accessed_at = excluded.last_accessed_at`),touchFileEvidence:t.prepare(`UPDATE file_evidence
|
|
76
|
+
SET last_accessed_at = ?
|
|
77
|
+
WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?
|
|
78
|
+
AND last_accessed_at < ?`)}}catch(t){return Bn("shared cache disabled (open failed)",t),null}}function es(e,t,n){Bn(`shared cache disabled (${t})`,n);try{e.shared?.evidence.close()}catch{}e.shared=null}function EU(e,t={}){if(!AR(e))return null;let n;try{n=new Bc(e),n.pragma("busy_timeout = 50"),n.exec(`CREATE INDEX IF NOT EXISTS idx_file_evidence_lru
|
|
79
|
+
ON file_evidence(last_accessed_at, kind, relative_path, content_hash, version)`),n.pragma("wal_checkpoint(TRUNCATE)");let r=n.prepare("SELECT COUNT(*) AS count FROM file_evidence").get().count,i=t.maxRows??$R,o=t.budgetBytes??GR,s=Number(n.pragma("page_size",{simple:!0})),a=Number(n.pragma("page_count",{simple:!0})),c=Number(n.pragma("freelist_count",{simple:!0})),l=Math.max(0,a-c)*s,u=r>0&&l>o?Math.min(r,Math.ceil((l-o)/Math.max(1,l/r))):0,d=Math.max(r-i,u);return d>0&&(n.prepare(`DELETE FROM file_evidence WHERE rowid IN (
|
|
80
|
+
SELECT rowid FROM file_evidence ORDER BY last_accessed_at ASC, rowid ASC LIMIT ?
|
|
81
|
+
)`).run(d),n.pragma("wal_checkpoint(TRUNCATE)")),{deletedRows:d,remainingRows:r-d}}catch(r){return Bn("shared cache maintenance skipped",r),null}finally{try{n?.close()}catch{}}}function ff(e,t,n,r){let i=gt(e);if(!i)return null;try{let o=i.readFileEvidence.get(t,n,r,xe())??i.readLegacyFileEvidence.get(t,n,r);if(o?.payload!==void 0)return o.payload;if(!Zo.has(t)||!i.shared)return null;try{let s=i.shared.readFileEvidence.get(t,n,r,xe());return s?.payload!==void 0&&gf(i.shared,t,n,r),s?.payload??null}catch(s){return es(i,"file_evidence read",s),null}}catch(o){return yt(e,"file_evidence read",o),null}}function mf(e,t,n,r){let i=gt(e);if(!i)return!1;try{if((i.existsFileEvidence.get(t,n,r,xe())??i.existsLegacyFileEvidence.get(t,n,r))?.present!==void 0)return!0;if(!Zo.has(t)||!i.shared)return!1;try{return i.shared.existsFileEvidence.get(t,n,r,xe())?.present===void 0?!1:(gf(i.shared,t,n,r),!0)}catch(s){return es(i,"file_evidence exists",s),!1}}catch(o){return yt(e,"file_evidence exists",o),!1}}function gf(e,t,n,r){let i=Date.now();try{e.touchFileEvidence.run(i,t,n,r,xe(),i-VR)}catch(o){Bn("shared file_evidence recency touch skipped",o)}}function yf(e,t,n,r,i){let o=gt(e);if(o)try{if(o.writeFileEvidence.run(t,n,r,xe(),i),Zo.has(t)&&o.shared)try{o.shared.writeFileEvidence.run(t,n,r,xe(),i,Date.now())}catch(s){es(o,"file_evidence write",s)}}catch(s){yt(e,"file_evidence write",s)}}function hf(e,t){if(t.length===0)return;let n=gt(e);if(n)try{n.evidence.transaction(()=>{for(let i of t)n.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,xe(),i.payload)})();try{n.evidence.pragma("wal_checkpoint(TRUNCATE)")}catch{}let r=t.filter(i=>Zo.has(i.kind));if(r.length>0&&n.shared)try{n.shared.evidence.transaction(()=>{for(let i of r)n.shared.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,xe(),i.payload,Date.now())})()}catch(i){es(n,"file_evidence batch write",i)}}catch(r){yt(e,"file_evidence batch write",r)}}function Sf(e,t,n,r){let i=gt(e);if(!i)return null;try{return(i.readProjectEvidence.get(t,n,r,xe())??i.readLegacyProjectEvidence.get(t,n,r))?.payload??null}catch(o){return yt(e,"project_evidence read",o),null}}function bf(e,t,n,r,i){let o=gt(e);if(o)try{o.writeProjectEvidence.run(t,n,r,xe(),i)}catch(s){yt(e,"project_evidence write",s)}}function PU(e,t,n,r){if(n===r)return 0;let i=gt(e);if(!i)return 0;try{return i.rekeyProjectEvidenceKind.run(r,xe(),t,n).changes}catch(o){return yt(e,"project_evidence kind rekey",o),0}}function wU(e,t,n,r){let i=gt(e);if(!i)return new Map;try{let o=i.readCalleesForFile.all(t,n,r,Si),s=i.readLegacyCalleesForFile.all(t,n,r);return xf([...s,...o])}catch(o){return yt(e,"semantic_callees bulk read",o),new Map}}function FU(e,t,n){let r=gt(e);if(!r)return new Map;try{let i=r.readReferencesForFile.all(t,n,Si),o=r.readLegacyReferencesForFile.all(t,n);return xf([...o,...i])}catch(i){return yt(e,"semantic_references bulk read",i),new Map}}function xf(e){let t=new Map;for(let n of e)t.set(n.symbol,n.payload);return t}function TU(e,t){if(t.length===0)return;let n=gt(e);if(n)try{n.evidence.transaction(()=>{let r=new Set;for(let i of t){let o=`${i.relativePath}\0${i.contentHash}`;r.has(o)||(r.add(o),n.dropStaleCallees.run(i.relativePath,i.contentHash)),n.writeCallees.run(i.relativePath,i.symbol,i.contentHash,i.depsDigest,Si,i.payload)}})()}catch(r){yt(e,"semantic_callees write",r)}}function NU(e,t){if(t.length===0)return;let n=gt(e);if(n)try{n.evidence.transaction(()=>{let r=new Set;for(let i of t){let o=`${i.relativePath}\0${i.projectFingerprint}`;r.has(o)||(r.add(o),n.dropStaleReferences.run(i.relativePath,i.projectFingerprint)),n.writeReferences.run(i.relativePath,i.symbol,i.projectFingerprint,Si,i.payload)}})()}catch(r){yt(e,"semantic_references write",r)}}import{appendFileSync as HR,mkdirSync as zR}from"fs";import{createHash as KR,randomUUID as JR}from"crypto";import{dirname as YR}from"path";import{performance as xr}from"perf_hooks";var Cf="SCIP_QUERY_PROFILE",Ef="SCIP_QUERY_PROFILE_OUT",Pf="SCIP_QUERY_PROFILE_COMMAND",wf="SCIP_QUERY_PROFILE_CACHE_STATE",$c="SCIP_QUERY_PROFILE_RUN_ID",Gc="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY",Vc="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND",Ff=[Cf,Ef,Pf,wf,$c,Gc,Vc],OU=new Set(Ff),vf=new Set,Rf=new Map,If=!1;function fn(){let e=process.env[Cf];return e==="1"||e==="true"}function XR(){return process.env[Ef]}function Tf(){return process.env[Pf]}function QR(){return process.env[wf]}function Nf(){let e=process.env[$c];if(e)return e;if(!fn())return;let t=JR();return process.env[$c]=t,t}function Lf(){return process.env[Gc]}function ZR(e){let t=Lf();if(t)return t;if(!fn())return;let n=Nf();if(!n)return;let r=e.projectFingerprint?"published-project":"run-only",i=bi(["profile-workload-v1",e.toolVersion,e.command,e.projectFingerprint??n]);return process.env[Gc]=i,process.env[Vc]=r,i}function bi(e){return KR("sha256").update(JSON.stringify(e)).digest("hex").slice(0,24)}function MU(){return Object.fromEntries(Ff.flatMap(e=>{let t=process.env[e];return t===void 0?[]:[[e,t]]}))}function se(e,t,n){if(!fn())return t();let r=xr.now();try{let i=t();return ts({type:"span",name:e,durationMs:Math.round(xr.now()-r),ok:!0,...ns(n)??{}}),i}catch(i){throw ts({type:"span",name:e,durationMs:Math.round(xr.now()-r),ok:!1,error:i instanceof Error?i.message:String(i),...ns(n)??{}}),i}}async function _f(e,t,n){if(!fn())return t();let r=xr.now();try{let i=await t();return ts({type:"span",name:e,durationMs:Math.round(xr.now()-r),ok:!0,...ns(n)??{}}),i}catch(i){throw ts({type:"span",name:e,durationMs:Math.round(xr.now()-r),ok:!1,error:i instanceof Error?i.message:String(i),...ns(n)??{}}),i}}function ts(e,t=XR()){let n=eI(e),r={timestamp:new Date().toISOString(),pid:process.pid,runId:Nf(),command:Tf(),cacheState:QR(),...n,...e},i=`${JSON.stringify(r)}
|
|
82
|
+
`;if(t)try{let o=YR(t);vf.has(o)||(zR(o,{recursive:!0}),vf.add(o)),HR(t,i);return}catch(o){If||(If=!0,process.stderr.write(`[profile] failed to write ${t}: ${o instanceof Error?o.message:String(o)}
|
|
83
|
+
`));return}fn()&&process.stderr.write(i)}function eI(e){let t=Lf()??ZR({command:Tf()??"unknown",toolVersion:"unknown",projectFingerprint:null});if(!t)return{};let n=process.env[Vc],r=typeof e.name=="string"?e.name:void 0;if(!r)return{workloadIdentity:t,workloadIdentityKind:n};let i=r.split(/[.:]/,1)[0]??r,o=`${t}\0${r}`,s=Rf.get(o);return s||(s=bi(["profile-subsystem-v1",t,r]),Rf.set(o,s)),{workloadIdentity:t,workloadIdentityKind:n,subsystem:i,subsystemWorkIdentity:s}}function ns(e){return typeof e=="function"?e():e}function Df(e){return`${e}+scip-query-symbols.6`}import{isAbsolute as kf,relative as tI}from"path";var Q=class extends Error{constructor(n,r){super(`refusing unsafe project file path ${JSON.stringify(n)} (${r})`);this.relativePath=n;this.reason=r;this.name="UnsafeProjectPathError"}relativePath;reason;code="SCIP_QUERY_UNSAFE_PROJECT_PATH"};function mn(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function ae(e){return e.replace(/\\/g,"/")}function Et(e,t){return mn(e)===mn(t)}function et(e,t){let n=tI(e,t);return n===""||!n.startsWith("..")&&!kf(n)}function ve(e){if(!e)throw new Q(e,"empty-path");if(e.includes("\0"))throw new Q(e,"nul-byte");if(kf(e)||/^[A-Za-z]:/.test(e)||e.startsWith("//")||e.startsWith("\\\\"))throw new Q(e,"absolute-path");let t=mn(e);if(t.split("/").some(r=>r===".."))throw new Q(e,"parent-traversal");if(!t||t===".")throw new Q(e,"empty-path");return t}import{spawnSync as nI}from"child_process";import{createHash as rI}from"crypto";import{existsSync as iI,lstatSync as is,realpathSync as oI}from"fs";import{dirname as sI,isAbsolute as Of,join as qc,relative as aI,resolve as $n,sep as cI}from"path";var ht={run(e,t){let n=Af(e,t);return n.kind==="success"?n.output:void 0},runResult:Af},lI=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],Hc=["status","--porcelain=v2","--branch","-z","--untracked-files=all"],vr=/^[0-9a-f]{40,64}$/;function KU(e,t,n=ht){if(!t||t.startsWith("-")||/[\0\r\n]/.test(t))throw new Error(`Invalid Git revision ${JSON.stringify(t)}.`);let r=n.runResult(e,["rev-parse","--verify","--end-of-options",`${t}^{commit}`]);if(r.kind!=="success"||!vr.test(r.output))throw new Error(`Git revision ${JSON.stringify(t)} does not resolve to exactly one commit.`);return r.output}function vi(e,t=ht){return uI(e,t)?.context}function uI(e,t=ht){let n=t.runResult(e,lI);if(n.kind==="success"){let i=pI(n.output);if(i){let o=fI(i,t);if(o)return Wc(o)}}let r=mI(e,t);return r?Wc(r):void 0}function dI(e,t=ht){if(!e.headCommit)return;let n=t.run(e.projectRoot,Hc);if(n===void 0)return;let r=zc(n);if(!(!r?.headCommit||r.headCommit!==e.headCommit))return{...e,clean:r.clean}}function JU(e,t,n=ht){if(!t.headCommit||!t.treeOid||!vr.test(t.headCommit)||!vr.test(t.treeOid)||n===ht&&!xI()||!yI(e,t))return;let r=dI({projectRoot:t.projectRoot,gitDir:t.gitDir,commonDir:t.commonDir,repositoryId:t.repositoryId,worktreeId:t.worktreeId,headCommit:t.headCommit,treeOid:t.treeOid,clean:!0},n);return r?Wc(r):void 0}function YU(e,t=ht,n={}){let r=t===ht&&n.cachedInventoryAfterSequence!==void 0?Op(e,n.cachedInventoryAfterSequence):void 0;if(r!==void 0)return r;let i=t.run(e,["ls-files","-v","-z"]);return i===void 0?!1:i.split("\0").filter(Boolean).every(o=>o.startsWith("H "))}function Wc(e){return{context:e,projectFileInventorySequence:Ap()}}function zc(e){let t=e.split("\0").filter(Boolean),n=t.find(i=>i.startsWith("# branch.oid "))?.slice(13),r=n==="(initial)"?void 0:n;if(!(r!==void 0&&!vr.test(r))&&n!==void 0)return{headCommit:r,clean:t.every(i=>i.startsWith("# "))}}function pI(e){let t=e.split(`
|
|
84
|
+
`).map(c=>c.trim());if(t.length!==5)return;let[n,r,i,o,s]=t;if(!n||!r||!i||!o||!s||!vr.test(o)||!vr.test(s))return;let a=Ae(n);return{root:a,gitDir:Ae(rs(a,r)),commonDir:Ae(rs(a,i)),headCommit:o,treeOid:s}}function fI(e,t){let n=t.run(e.root,Hc);if(n===void 0)return;let r=zc(n);return r?.headCommit!==e.headCommit?void 0:{...Mf(e.root,e.gitDir),commonDir:e.commonDir,repositoryId:xi("repository",e.commonDir),headCommit:e.headCommit,treeOid:e.treeOid,clean:r.clean}}function mI(e,t){let n=gI(e,t);if(n.kind!=="worktree")return;let r=n.identity,i=r.projectRoot,o=t.run(i,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=Ae(rs(i,o)),a=Uc(t.run(i,["rev-parse","--verify","HEAD"])),c=Uc(t.run(i,["rev-parse","--verify","HEAD^{tree}"])),l=t.run(i,Hc);if(l===void 0)return;let u=zc(l);if(!(!u||u.headCommit!==a))return{...r,commonDir:s,repositoryId:xi("repository",s),headCommit:a,treeOid:c,clean:u.clean}}function gI(e,t=ht){let n=t.runResult(e,["rev-parse","--show-toplevel"]);if(n.kind==="not-repository")return{kind:"non-git"};if(n.kind==="error")return n;let r=n.output.trim();if(!r)return{kind:"error",message:"Git returned an empty worktree root."};let i=Ae(r),o=t.run(i,["rev-parse","--absolute-git-dir"])?.trim();if(!o)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=Ae(rs(i,o));return{kind:"worktree",identity:Mf(i,s)}}function Mf(e,t){return{projectRoot:e,gitDir:t,worktreeId:xi("worktree",`${e}\0${t}`)}}function yI(e,t){try{let n=Ae(t.projectRoot),r=$n(e)===n?n:Ae(e);if(t.projectRoot!==n||!bI(n,r))return!1;let i=EI(n);if(!i||i!==t.gitDir)return!1;let o=SI(i);return!o||o!==t.commonDir?!1:t.worktreeId===xi("worktree",`${n}\0${i}`)&&t.repositoryId===xi("repository",o)}catch{return!1}}function hI(e,t,n){let r=jf(e,"gitdir: ",n);return r?Ae($n(t,r)):void 0}function SI(e){let t=qc(e,"commondir");try{let n=is(t);if(n.isSymbolicLink()||!n.isFile())return;let r=jf(t,"",n);return r?Ae($n(e,r)):void 0}catch(n){let r=n.code;return r==="ENOENT"||r==="ENOTDIR"?e:void 0}}function jf(e,t="",n=is(e)){if(!n.isFile()||n.isSymbolicLink()||n.size>4*1024)return;let r=z(e,{inputKind:"Git control path",maxBytes:4*1024}).split(/\r?\n/).filter(o=>o.length>0);if(r.length!==1||!r[0].startsWith(t))return;let i=r[0].slice(t.length);return i&&!i.includes("\0")?i:void 0}function bI(e,t){let n=aI(e,t);return n===""||!n.startsWith(`..${cI}`)&&n!==".."&&!Of(n)}function xI(e=process.env){return!(["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_NAMESPACE","GIT_REPLACE_REF_BASE","GIT_NO_REPLACE_OBJECTS","GIT_SHALLOW_FILE","GIT_GRAFT_FILE"].some(n=>e[n]!==void 0)||Object.keys(e).some(n=>n.startsWith("GIT_CONFIG_")))}function Bf(e,t=ht){let n=t.run(e,["worktree","list","--porcelain","-z"]);return n===void 0?[]:vI(n)}function vI(e){let t=[],n;for(let r of e.split("\0")){if(r===""){n&&t.push(n),n=void 0;continue}let{key:i,value:o}=RI(r);if(i==="worktree"){n&&t.push(n),n={path:Ae(o),detached:!1,bare:!1,prunable:!1,locked:!1};continue}n&&II(n,i,o)}return n&&t.push(n),t}function RI(e){let t=e.indexOf(" ");return{key:t<0?e:e.slice(0,t),value:t<0?"":e.slice(t+1)}}function II(e,t,n){t==="HEAD"?e.head=n:t==="branch"?e.branch=n:t==="detached"?e.detached=!0:t==="bare"?e.bare=!0:t==="prunable"?e.prunable=!0:t==="locked"&&(e.locked=!0)}function XU(e,t,n=ht){return Uc(n.run(e,t))}function rs(e,t){return Of(t)?t:$n(e,t)}function Ae(e){try{return oI(e)}catch{return $n(e)}}function xi(e,t){return rI("sha256").update(`${e}\0${t}`).digest("hex").slice(0,24)}function Uc(e){return e?.trim()||void 0}function Af(e,t){let n=nI("git",["-C",e,...t],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"],timeout:3e4,killSignal:"SIGKILL"});if(n.status===0)return{kind:"success",output:n.stdout.trimEnd()};let i=(typeof n.stderr=="string"?n.stderr.trim():"")||n.error?.message||`git exited with status ${n.status??"unknown"}`,o=n.error?.code;return(/not a git repository/i.test(i)||o==="ENOENT"&&iI($n(e)))&&!CI(e)?{kind:"not-repository"}:{kind:"error",message:i}}function CI(e){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let t=$n(e);for(;;){try{return is(qc(t,".git")),!0}catch(r){let i=r.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let n=sI(t);if(n===t)return!1;t=n}}function EI(e){let t=qc(e,".git"),n=is(t);if(!n.isSymbolicLink())return n.isDirectory()?Ae(t):n.isFile()?hI(t,e,n):void 0}import{readdirSync as PI}from"fs";function os(e){try{return PI(e,{withFileTypes:!0})}catch{return[]}}import{createRequire as TI}from"module";import{existsSync as NI,lstatSync as Wf,statSync as LI}from"fs";import T from"path";import{AsyncLocalStorage as wI}from"async_hooks";var FI=new wI;function Gn(e,t){let n=ss(e);if(!n||n.missing.has(t))return;let r=n.files.get(t);if(r)return r;let i=n.readBaseFile?.(t);return i&&n.files.set(t,i),i}function Vn(e,t){let n=ss(e);if(n)return n.missing.has(t)?"missing":n.paths.includes(t)?"present":"missing"}function $f(e,t){return ss(e)?.fingerprints.get(t)}function Wn(e){return ss(e)?.paths}function ss(e){let t=FI.getStore();if(t)return t.projectRoot===Ae(e)?t:void 0}var _I=TI(import.meta.url),Uf=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]),DI=18003;function as(e,t=[]){let n=T.resolve(e),r=t.flatMap(c=>jI(n,c));if(r.length>0)return Gf(n,Vf(r));let i=MI(n),o=Vf(i),s=BI(n,o)?[n,...o]:o,a=s.length>0?s:[n];return Gf(n,a)}function qf(e){return new Set(e.map(t=>t==="."?"tsconfig.json":`${t.replace(/\/$/u,"")}/tsconfig.json`))}function cs(e){let t=e.split("/").at(-1)?.toLowerCase();return t?.startsWith("tsconfig")===!0&&t.endsWith(".json")}var kI=/^\.scipquery-compiler-shard-\d+\.tsconfig\.json$/;function mq(e){return`.scipquery-compiler-shard-${e}.tsconfig.json`}function Hf(e){return kI.test(e)}function zf(e,t,n=[]){let r;try{r=_I("@ts-morph/common/dist/typescript.js")}catch{return null}let i=T.resolve(e),o=t==="workspace"?as(i,n):["."],s=new Set;for(let a of o){let c=a==="."?i:T.join(i,a),l=T.join(c,"tsconfig.json"),u=GI(r,i);if(!u.fileExists(l))return null;let d=r.readConfigFile(l,u.readFile);if(d.error)return null;let p=r.parseJsonConfigFileContent(d.config,u,c);if(p.errors.some(f=>f.code!==DI))return null;UI(i,p.fileNames,s)}return s}function gq(e,t,n,r){let i=T.resolve(e),o=new Set(r);for(let a of n)if(!AI(i,a,o))return!1;let s=t==="workspace"?as(i,n):["."];for(let a of s)if(!OI(i,a,o))return!1;return!0}function AI(e,t,n){let r=T.resolve(e,t);if(!et(e,r))return!0;try{let i=Wf(r);if(i.isSymbolicLink()||i.isFile()&&!n.has(Un(e,r)))return!1}catch{}return!0}function OI(e,t,n){let r=t==="."?e:T.join(e,t),i=T.join(r,"tsconfig.json");if(!Yf(e,i))return!0;let o=Un(e,i);if(!n.has(o))return!1;try{if(Wf(i).isSymbolicLink())return!1;let s=Xf(e,i);if(s.includes("extends")||s.includes("\\"))return!1}catch{return!1}return!0}function Gf(e,t){return[...new Set(t.map(n=>Un(e,n)))].sort((n,r)=>n.localeCompare(r))}function MI(e){let t=Wn(e);if(t)return t.flatMap(i=>{if(i.split("/").some(s=>Uf.has(s)))return[];let o=T.join(e,...i.split("/"));return Kf(e,o)?[T.dirname(o)]:[]});let n=[],r=[e];for(;r.length>0;){let i=r.pop(),o=os(i);for(let s of o){let a=T.join(i,s.name);qI(e,a,s,r,n)}}return n}function jI(e,t){let n=t.trim();if(!n)return[];let r=T.resolve(e,n);if(!et(e,r))return[];let i=Wn(e);if(i)return WI(e,r,i);try{let o=LI(r);if(o.isDirectory())return[r];if(o.isFile()&&Kc(T.basename(r)))return[T.dirname(r)]}catch{return[]}return[]}function Kf(e,t){if(!Kc(T.basename(t)))return!1;let n=Jf(e,t);return n?T.basename(t)==="tsconfig.json"||"include"in n||"files"in n||"references"in n:!1}function Kc(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function Vf(e){let t=[...new Set(e.map(n=>T.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&VI(n,r)))}function BI(e,t){if(t.length===0||t.some(r=>T.resolve(r)===e))return!1;let n=T.join(e,"tsconfig.json");return Yf(e,n)&&$I(e,n)}function $I(e,t){let r=Jf(e,t)?.include;return Array.isArray(r)?r.some(i=>typeof i=="string"&&i.trim()!==""&&!i.startsWith("!")&&(i.includes("/")||i.includes("**")||!T.extname(i))):!1}function Jf(e,t){try{let n=JSON.parse(Xf(e,t));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function Yf(e,t){let n=Un(e,t),r=Vn(e,n);return r?r==="present":NI(t)}function Xf(e,t){let n=Un(e,t);if(Wn(e)){let i=Gn(e,n);if(!i)throw Object.assign(new Error(`Snapshot file ${n} is missing.`),{code:"ENOENT"});return i.content.toString("utf8")}return _(t,"TypeScript project config")}function GI(e,t){let n=Wn(t);if(!n)return e.sys;let r=T.resolve(t),i=new Set(n),o=Qf(r,n),s=e,a=c=>{let l=T.resolve(c);return et(r,l)?Un(r,l):null};return{useCaseSensitiveFileNames:e.sys.useCaseSensitiveFileNames,fileExists(c){let l=a(c);return l===null?e.sys.fileExists(c):i.has(l)},readFile(c){let l=a(c);return l===null?e.sys.readFile(c):Gn(r,l)?.content.toString("utf8")},readDirectory(c,l,u,d,p){let f=T.resolve(c);return et(r,f)?s.matchFiles(f,l,u,d,e.sys.useCaseSensitiveFileNames,r,p,h=>o.get(T.resolve(h))??{files:[],directories:[]},h=>h):e.sys.readDirectory(c,l,u,d,p)}}}function Qf(e,t,n=T.join){let r=new Map,i=new Map,o=s=>{r.has(s)||r.set(s,new Set),i.has(s)||i.set(s,new Set)};o(e);for(let s of t){let a=s.split("/"),c=e;for(let l=0;l<a.length-1;l+=1){let u=a[l];o(c),i.get(c).add(u),c=n(c,u),o(c)}r.get(c).add(a.at(-1))}return new Map([...r].map(([s,a])=>[s,{files:[...a].sort(),directories:[...i.get(s)??[]].sort()}]))}function yq(e,t,n){let i=new Set(t),o=Qf("/",t,T.posix.join),s=e;if(typeof s.matchFiles!="function")throw new Error("TypeScript snapshot file matching is unavailable.");let a=c=>T.posix.relative("/",T.posix.resolve("/",c));return{useCaseSensitiveFileNames:!0,fileExists:c=>i.has(a(c)),directoryExists:c=>o.has(T.posix.resolve("/",c)),getDirectories:c=>o.get(T.posix.resolve("/",c))?.directories??[],getCurrentDirectory:()=>"/",realpath:c=>T.posix.resolve("/",c),readFile:c=>{let l=a(c);return i.has(l)?n(l):void 0},readDirectory:(c,l,u,d,p)=>s.matchFiles(T.posix.resolve("/",c),l,u,d,!0,"/",p,f=>o.get(T.posix.resolve("/",f))??{files:[],directories:[]},f=>f)}}function Un(e,t){let n=T.relative(e,t);return n?n.split(T.sep).join("/"):"."}function VI(e,t){let n=T.relative(e,t);return!!n&&!n.startsWith("..")&&!T.isAbsolute(n)}function WI(e,t,n){let r=Un(e,t);if(n.includes(r)&&Kc(T.basename(t)))return[T.dirname(t)];let i=r==="."?"":`${r}/`;return n.some(o=>o.startsWith(i))?[t]:[]}function UI(e,t,n){for(let r of t){let i=T.resolve(r);et(e,i)&&n.add(T.relative(e,i).split(T.sep).join("/"))}}function qI(e,t,n,r,i){if(n.isDirectory()){!Uf.has(n.name)&&!n.name.startsWith(".")&&r.push(t);return}n.isFile()&&Kf(e,t)&&i.push(T.dirname(t))}import{createHash as Xc}from"crypto";import{execFileSync as Zf}from"child_process";import{createRequire as HI}from"module";var zI=HI(import.meta.url),KI=/\.(?:[cm]?[jt]sx?)$/iu,JI=/\.[jt]sx$/iu,em=/(?:^|\/)package\.json$/iu,Ri,Jc=new Map;function tm(e,t){if(!Qc(e))return;let n=YI();if(n)try{let r=typeof t=="string"?t:t.toString("utf8"),i=JI.test(e)?n.LanguageVariant.JSX:n.LanguageVariant.Standard,o=n.createScanner(n.ScriptTarget.Latest,!1,i,r),s=Xc("sha256").update(`typescript-semantic-v1\0${i}\0`);return XI(n,o,s),s.digest("hex")}catch{return}}function Qc(e){return KI.test(e)}function Zc(e,t){if(em.test(e))try{let n=JSON.parse(typeof t=="string"?t:t.toString("utf8"));if(typeof n!="object"||n===null||Array.isArray(n))return;let{scripts:r,...i}=n;return Xc("sha256").update("typescript-package-json-v1\0").update(Yc(i)).digest("hex")}catch{return}}function el(e){return em.test(e)}function vq(e,t,n){if(!el(t)||!/^[a-f0-9]{64}$/u.test(n))return;let r=`${e}\0${t}\0${n}`;if(Jc.has(r))return Jc.get(r);let i;try{let o=Zf("git",["-C",e,"log","--all","--format=%H","--max-count=64","--",t],{encoding:"utf8",maxBuffer:1048576,timeout:5e3}).split(/\r?\n/u).filter(Boolean);for(let s of o){let a=Zf("git",["-C",e,"show",`${s}:${t}`],{encoding:null,maxBuffer:4194304,timeout:5e3});if(Xc("sha256").update(a).digest("hex")===n){i=Zc(t,a);break}}}catch{i=void 0}return Jc.set(r,i),i}function YI(){if(Ri!==void 0)return Ri;try{Ri=zI("typescript")}catch{Ri=null}return Ri}function Yc(e){return Array.isArray(e)?`[${e.map(Yc).join(",")}]`:typeof e=="object"&&e!==null?`{${Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>`${JSON.stringify(t)}:${Yc(n)}`).join(",")}}`:JSON.stringify(e)}function XI(e,t,n){let r=!1,i=!1;for(;;){let o=t.scan();if(o===e.SyntaxKind.EndOfFileToken)break;if(o===e.SyntaxKind.WhitespaceTrivia)continue;if(o===e.SyntaxKind.NewLineTrivia){r&&(i=!0);continue}i&&n.update("line-break\0");let s=t.getTokenText();n.update(`${o}\0${Buffer.byteLength(s)}\0`).update(s).update("\0"),r=!0,i=!1}}import{createHash as om,randomUUID as rC}from"crypto";import{chmodSync as sm,existsSync as Ir,linkSync as iC,lstatSync as Ii,readdirSync as nl,realpathSync as tt,unlinkSync as oC,writeSync as sC}from"fs";import{homedir as aC}from"os";import{basename as cC,dirname as us,isAbsolute as rm,join as Ve,resolve as ds}from"path";import{closeSync as QI,existsSync as ZI,fsyncSync as eC,mkdirSync as tC,openSync as nC}from"fs";import{dirname as nm}from"path";function Ht(e,t,n,r){let i=0;for(;i<t.length;){let o=n.writeFile(e,t,i,t.length-i);if(!Number.isSafeInteger(o)||o<=0||o>t.length-i)throw new Error(`${r} write did not make valid forward progress`);i+=o}}function Rr(e,t){if(t!=="win32")return!1;let n=e.code;return n==="EACCES"||n==="EBADF"||n==="EINVAL"||n==="EISDIR"||n==="EPERM"}var qn=Object.freeze({platform:process.platform,pathExists:e=>ZI(e),makeDirectory:e=>tC(e,{recursive:!0}),openFile:(e,t,n)=>nC(e,t,n),syncFile:e=>eC(e),closeFile:e=>QI(e)});function Te(e,t=qn){let n=[],r=e;for(;!t.pathExists(r);){n.push(r);let o=nm(r);if(o===r)throw new Error(`Cannot establish a durable directory path without an existing ancestor: ${e}`);r=o}let i="synced";for(let o of n.reverse())t.makeDirectory(o),i=Z(i,G(nm(o),t));return i}function G(e,t=qn){let n;try{n=t.openFile(e,"r")}catch(r){if(Rr(r,t.platform))return"unsupported";throw r}try{t.syncFile(n)}catch(r){try{t.closeFile(n)}catch{}if(Rr(r,t.platform))return"unsupported";throw r}return t.closeFile(n),"synced"}function Z(...e){return e.every(t=>t==="not-requested")?"not-requested":e.includes("unsupported")?"unsupported":"synced"}var am=1,Ei=".scip-query-cache-owner.json",lC=16*1024,cm=Object.freeze({...qn,randomToken:()=>rC(),linkFile:(e,t)=>iC(e,t),removeFile:e=>oC(e),writeFile:(e,t,n,r)=>sC(e,t,n,r)});function ls(e,t){return Object.assign(new Error(`refusing unsafe project dbPath ${JSON.stringify(e)} (${t}); use a repository-relative directory that remains inside the checkout`),{name:"UnsafeCachePathError",code:"SCIP_QUERY_UNSAFE_CACHE_PATH",configuredPath:e,reason:t})}function St(e,t){return Object.assign(new Error(`refusing unowned cache directory ${JSON.stringify(e)} (${t}); move unrelated data elsewhere or choose a new empty dbPath`),{name:"CacheOwnershipError",code:"SCIP_QUERY_CACHE_OWNERSHIP",cacheDir:e,reason:t})}function uC(e,t){let n=tt(e);return dC(n,rl(n,t))}function rl(e,t){let n=tt(e),r=process.env.SCIP_QUERY_CACHE_DIR;return r?ds(r):t?.dbPath?fC(n,t.dbPath):fs(n)}function ps(){let e=process.env.XDG_CACHE_HOME;return Ve(e||Ve(aC(),".cache"),"scip-query")}function fs(e){let t=ds(e);try{t=tt(t)}catch{}let n=om("sha256").update(t).digest("hex").slice(0,12);return Ve(ps(),"projects",n)}function ms(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);let t=Ve(ps(),"repositories",e);return pm(t),tt(t)}function il(e){return process.env.SCIP_QUERY_SHARED_CACHE!=="0"&&!process.env.SCIP_QUERY_CACHE_DIR&&!process.env.SCIP_QUERY_INDEX_DB&&!e?.dbPath}function Mq(e,t){let n=uC(e,t);return{cacheDir:n,dbPath:Ve(n,"index.db"),indexPath:Ve(n,"index.scip"),metaPath:Ve(n,"meta.json")}}function dC(e,t,n=cm){return pC(e,t,n).cacheDir}function pC(e,t,n=cm){let r=tt(e),i=Ir(t)?"synced":pm(t,n),o=tt(t),s=Ve(o,Ei);if(Ir(s))return tl(r,o),ol(s),Ci(o),{kind:"existing",cacheDir:o};im(o),hC(o),im(o);let c=`${JSON.stringify({schemaVersion:am,canonicalProjectRoot:r,canonicalCacheDir:o,creatorVersion:Ko},null,2)}
|
|
85
|
+
`;try{let l=SC(s,c,n),u=Z(i,l);return{kind:"published",cacheDir:o,achievedDurability:u==="synced"?"directory-durable":"file-flushed",directorySync:u}}catch(l){if(xC(l))return tl(r,o),{kind:"existing",cacheDir:o};throw l}}function tl(e,t){let n=tt(e),r=tt(t);return lm(r,n,r)}function jq(e){let t=Ii(e);if(t.isSymbolicLink()||!t.isDirectory())throw St(e,"cache path is not a regular directory");let n=tt(e);return lm(n,void 0,n)}function Bq(e,t){return Ir(Ve(t,Ei))?(tl(e,t),um(t),!0):!1}function fC(e,t){let n;try{n=ve(t)}catch(s){throw s instanceof Q?ls(t,s.reason):s}let r=ds(e,...n.split("/"));if(r===e||!et(e,r))throw ls(t,"outside-project");let i=mC(r),o=tt(i);if(!et(e,o)&&o!==e)throw ls(t,"symlink-escape");return r}function mC(e){let t=e;for(;!Ir(t);){let n=us(t);if(n===t)throw ls(e,"no-existing-ancestor");t=n}return t}function lm(e,t,n){let r=Ve(e,Ei);if(!Ir(r)||Ii(r).isSymbolicLink())throw St(e,"missing regular ownership record");let i=Ii(r);if(!i.isFile()||i.size>lC)throw St(e,"invalid ownership record file");let o=_(r,"cache ownership record"),s=gC(o,e);if(t!==void 0&&s.canonicalProjectRoot!==t)throw St(e,"ownership record belongs to a different project");if(s.canonicalCacheDir!==n)throw St(e,"ownership record names a different cache directory");return{record:s,ownerSha256:om("sha256").update(o).digest("hex"),physicalCacheDir:e}}function gC(e,t){try{let n=JSON.parse(e);if(n.schemaVersion!==am||typeof n.canonicalProjectRoot!="string"||typeof n.canonicalCacheDir!="string"||typeof n.creatorVersion!="string"||!rm(n.canonicalProjectRoot)||!rm(n.canonicalCacheDir))throw new Error("invalid fields");return n}catch(n){throw St(t,`malformed ownership record: ${n instanceof Error?n.message:String(n)}`)}}function im(e){let t=nl(e).filter(n=>n!==Ei&&!yC(n));if(t.length>0)throw St(e,`unrecognized existing entries: ${t.slice(0,3).join(", ")}`)}function yC(e){return e.startsWith(`${Ei}.tmp-`)||e.startsWith("git-worktree-context.json.tmp-")||[".scipquery-generations","affected-shadow-latest.json","affected-shadow.jsonl","agent-hooks","augment-vue-meta.json","cache-lifecycle.lock","evidence.db","evidence.db-shm","evidence.db-wal","health-report-cache.json","git-worktree-context.json","index.db","index.db-shm","index.db-wal","index.lock","index.scip","language-indexes","meta.json","reindex-activity.jsonl","shared-cache.json","typescript-index","typescript-scip-fragments","typescript-scip-overlays","typescript-semantic","typescript-shard-costs.json","watch-activity.json","watch-refresh-requests","watch-state.json","watch.lock"].includes(e)?!0:/^(?:reindex-|rust-|typescript-)/.test(e)}function hC(e){for(let t of nl(e)){let n=Ve(e,t);try{let r=Ii(n);if(r.isSymbolicLink())throw St(e,`legacy cache entry ${t} is a symlink`);if(r.isDirectory())Ci(n);else if(r.isFile())ol(n);else throw St(e,`legacy cache entry ${t} is not a file or directory`)}catch(r){if(dm(r))continue;throw r}}Ci(e)}function um(e,t=!1){try{let n=Ii(e);if(n.isSymbolicLink())throw St(e,"managed cache tree contains a symlink");if(n.isFile()){ol(e);return}if(!n.isDirectory())throw St(e,"managed cache tree contains a special file");Ci(e);for(let r of nl(e))um(Ve(e,r),!0)}catch(n){if(t&&dm(n))return;throw n}}function dm(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function pm(e,t=qn){let n=Te(e,t);return Ci(e),n}function SC(e,t,n){let r=`${e}.tmp-${process.pid}-${n.randomToken()}`,i,o=!1;try{i=n.openFile(r,"wx",384),o=!0,Ht(i,Buffer.from(t),n,"cache ownership record"),n.syncFile(i),n.closeFile(i),i=void 0,n.linkFile(r,e);let s=G(us(e),n);return n.removeFile(r),o=!1,Z(s,G(us(e),n))}finally{if(i!==void 0)try{n.closeFile(i)}catch{}if(o)try{n.removeFile(r)}catch{}}}function Ci(e){process.platform!=="win32"&&sm(e,448)}function ol(e){process.platform!=="win32"&&sm(e,384)}function bC(e){if(Ir(e))return tt(e);let t=tt(us(e));return Ve(t,cC(e))}function sl(e){return bC(ds(e))}function xC(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EEXIST"}import{closeSync as fm,existsSync as cl,openSync as vC,realpathSync as RC,renameSync as IC,unlinkSync as mm,writeSync as CC}from"fs";import{dirname as EC,join as PC,resolve as wC}from"path";import{AsyncLocalStorage as FC}from"async_hooks";var TC="fingerprint-stat-cache.json",gm=1,NC=8*1024*1024,al=new Map,ym=new FC;function zq(e,t,n){return ym.run({projectRoot:pl(e),cacheDir:wC(t)},n)}function hm(e){let t=ym.getStore();return t?.projectRoot===e?t.cacheDir:null}function LC(e){let t=pl(e);return al.get(t)?.get(hm(t))}function ll(e,t,n,r){let i=Sm(e),o=i.files.get(t);if(!(!o||!bm(o,n,r)))return i.hits+=1,{hash:o.hash,size:o.fingerprintSize,...o.semanticHash===void 0?{}:{semanticHash:o.semanticHash}}}function ul(e,t,n,r,i){if(i.hash==="unreadable"||i.size<0||!Number.isFinite(i.size))return;let o=Sm(e),s={kind:n,dev:r.dev,ino:r.ino,mtimeMs:r.mtimeMs,ctimeMs:r.ctimeMs,size:r.size,hash:i.hash,fingerprintSize:i.size,...i.semanticHash===void 0?{}:{semanticHash:i.semanticHash}},a=o.files.get(t);a&&jC(a,s)||(o.files.set(t,s),o.stores+=1,o.dirty=!0)}function dl(e){let t=LC(e);if(!(!t?.dirty||!t.cachePath))try{let n=EC(t.cachePath);if(!cl(n))return;BC(t.cachePath,kC(t)),t.dirty=!1}catch{}}function Sm(e){let t=pl(e),n=hm(t),r=al.get(t)??new Map,i=r.get(n);if(i)return i;let o=_C(t,n),s=DC(o),a={cachePath:o,files:s,dirty:!1,hits:0,stores:0};return r.set(n,a),al.set(t,r),a}function _C(e,t){try{let n=t??rl(e);return cl(n)?PC(n,TC):null}catch{return null}}function DC(e){let t=new Map;if(!e||!cl(e))return t;try{let n=JSON.parse(H(e,{inputKind:"fingerprint stat cache",maxBytes:NC}).toString("utf8"));if(!AC(n))return t;for(let[r,i]of Object.entries(n.files))i&&t.set(r,i)}catch{return t}return t}function kC(e){return{version:gm,files:Object.fromEntries(e.files)}}function AC(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.version!==gm||typeof t.files!="object"||t.files===null?!1:Object.values(t.files).every(OC)}function OC(e){if(typeof e!="object"||e===null)return!1;let t=e;return(t.kind==="file"||t.kind==="symlink")&&MC(t)&&typeof t.hash=="string"&&t.hash!=="unreadable"&&(t.semanticHash===void 0||typeof t.semanticHash=="string")}function MC(e){return Number.isFinite(e.dev)&&Number.isFinite(e.ino)&&Number.isFinite(e.mtimeMs)&&Number.isFinite(e.ctimeMs)&&Number.isFinite(e.size)&&Number.isFinite(e.fingerprintSize)}function bm(e,t,n){return e.kind===t&&e.dev===n.dev&&e.ino===n.ino&&e.mtimeMs===n.mtimeMs&&e.ctimeMs===n.ctimeMs&&e.size===n.size}function jC(e,t){return bm(e,t.kind,t)&&e.hash===t.hash&&e.fingerprintSize===t.fingerprintSize&&e.semanticHash===t.semanticHash}function BC(e,t){let n=`${e}.${process.pid}.tmp`;try{mm(n)}catch{}let r=Buffer.from(`${JSON.stringify(t)}
|
|
86
|
+
`,"utf8"),i=vC(n,"wx",384);try{Ht(i,r,{writeFile:(o,s,a,c)=>CC(o,s,a,c)},"fingerprint stat cache")}catch(o){throw fm(i),mm(n),o}fm(i),IC(n,e)}function pl(e){return RC(e)}import{execFileSync as GC}from"child_process";import{isUtf8 as xm}from"buffer";import{createHash as ml}from"crypto";import{closeSync as vm,fstatSync as Pi,lstatSync as gl,openSync as Rm,readSync as Im,readlinkSync as VC,realpathSync as wi}from"fs";import{isAbsolute as WC,join as yl,relative as UC,resolve as qC,sep as HC}from"path";var Cr=64*1024*1024,zC=1024*1024,KC=1024,Pt=class extends Error{constructor(n,r,i,o){super(`${n} ${JSON.stringify(r)} is ${i} bytes; the safety limit is ${o} bytes`);this.inputKind=n;this.inputPath=r;this.observedBytes=i;this.limitBytes=o;this.name="InputTooLargeError"}inputKind;inputPath;observedBytes;limitBytes;code="SCIP_QUERY_INPUT_TOO_LARGE"};function JC(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function Er(e,t,n={}){let r=ve(t),i=kp(e,()=>wi(e)),o=qC(i,...r.split("/"));if(!et(i,o)||o===i)throw new Q(t,"outside-project");let s=wi(o);if(!et(i,s)||s===i)throw new Q(t,"outside-project");let a=gl(s);if(!a.isFile())throw new Q(t,"not-a-file");let c={projectRoot:i,relativePath:r,absolutePath:s,size:a.size,mtimeMs:a.mtimeMs,device:a.dev,inode:a.ino},l=n.maxBytes??Cr;if(dn(l),c.size>l)throw new Pt(n.inputKind??"project file",c.relativePath,c.size,l);return c}function Hn(e,t,n={}){let r=ve(t),i=Vn(e,r);if(i)return bE(e,r,i,n);let o=Er(e,t,n),s=n.maxBytes??Cr,a=Rm(o.absolutePath,"r");try{let c=Pi(a);if(Fi(c,o,t),c.size>s)throw new Pt(n.inputKind??"project file",o.relativePath,c.size,s);let l=Tc(a,c.size),u=Pi(a);if(Fi(u,o,t),l.byteLength!==c.size||u.mtimeMs!==c.mtimeMs)throw new Q(t,"changed-during-read");return l}finally{vm(a)}}function hl(e,t,n,r={}){if(n.byteLength===0)throw new Error("Project file probe literal must not be empty.");let{matchedLiteralIndexes:i,...o}=hs(e,t,[n],r);return{...o,includesLiteral:i.length>0}}function hs(e,t,n,r={}){if(n.length===0||n.some(c=>c.byteLength===0))throw new Error("Project file probe literals must not be empty.");let i=ve(t),o=Vn(e,i);if(o){if(o==="missing")throw Object.assign(new Error(`Snapshot project file ${JSON.stringify(i)} does not exist.`),{code:"ENOENT"});return YC(e,i,n,r)}let s=Er(e,t,r),a=Rm(s.absolutePath,"r");try{let c=Pi(a);Fi(c,s,t);let{hash:l,containsNul:u,validUtf8:d,includesLiterals:p}=XC(a,c.size,t,n,r);Fi(Pi(a),s,t);let f=!u&&d,h=f?p.flatMap((x,m)=>x?[m]:[]):[],b=null;return h.length>0&&(b=QC(a,s,t)),{byteLength:c.size,isUtf8Text:f,matchedLiteralIndexes:h,bytes:b,...l?{sha256:l.digest("hex")}:{}}}finally{vm(a)}}function YC(e,t,n,r){let i=Gn(e,t);if(!i)throw new Q(t,"changed-during-read");let o=r.maxBytes??Cr;if(dn(o),i.size>o)throw new Pt(r.inputKind??"project file",t,i.size,o);let s=!i.content.includes(0)&&xm(i.content),a=n.map(Cm),c=s?eE(i.content,n,a):[];return{byteLength:i.size,isUtf8Text:s,matchedLiteralIndexes:c,bytes:c.length>0?Buffer.from(i.content):null,...r.computeSha256?{sha256:i.sha256}:{}}}function XC(e,t,n,r,i){let o=i.computeSha256?ml("sha256"):null,s=i.scratchBuffer??Buffer.allocUnsafe(zC);if(s.byteLength===0)throw new Error("Project file probe scratch buffer must not be empty.");let a=0,c=r.map(()=>!1),l=!1,u=!0,d=Buffer.alloc(0),p=r.map(()=>Buffer.alloc(0)),f=r.map(Cm),h=x=>{if(u){let m=d.byteLength>0?Buffer.concat([d,x]):x,g=ZC(m);u=xm(m.subarray(0,g)),d=Buffer.from(m.subarray(g))}},b=x=>{for(let m=0;m<r.length;m+=1){if(c[m])continue;let g=r[m],y=p[m];c[m]=tE(x,g,y,f[m]),p[m]=nE(x,g,y)}};for(;a<t;){let x=Im(e,s,0,Math.min(s.byteLength,t-a),a);if(x<=0)throw new Q(n,"changed-during-read");let m=s.subarray(0,x);o?.update(m),l||=m.includes(0),h(m),b(m),a+=x}return u&&=d.byteLength===0,{hash:o,containsNul:l,validUtf8:u,includesLiterals:c}}function QC(e,t,n){let r=Buffer.allocUnsafe(t.size),i=0;for(;i<r.byteLength;){let o=Im(e,r,i,r.byteLength-i,i);if(o<=0)throw new Q(n,"changed-during-read");i+=o}return Fi(Pi(e),t,n),r}function zn(e,t,n={}){return Hn(e,t,n).toString("utf8")}function Fi(e,t,n){if(!e.isFile()||e.dev!==t.device||e.ino!==t.inode||e.size!==t.size)throw new Q(n,"changed-during-read")}function ZC(e){if(e.byteLength===0)return 0;let t=e.byteLength-1,n=0;for(;t>=0&&n<3&&(e[t]&192)===128;)n+=1,t-=1;if(t<0)return e.byteLength;let r=e[t];return xE(r)>e.byteLength-t?t:e.byteLength}function eE(e,t,n){return t.flatMap((r,i)=>fl(e,r,n[i])?[i]:[])}function tE(e,t,n,r){if(fl(e,t,r))return!0;if(n.byteLength===0||t.byteLength===1)return!1;let i=e.subarray(0,Math.min(e.byteLength,t.byteLength-1));return fl(Buffer.concat([n,i]),t,r)}function fl(e,t,n){if(n<0)return e.includes(t);let r=t[n],i=e.indexOf(r),o=0;for(;i>=0;){if(o+=1,o>KC)return e.includes(t);let s=i-n;if(s>=0&&s+t.byteLength<=e.byteLength&&e.compare(t,0,t.byteLength,s,s+t.byteLength)===0)return!0;i=e.indexOf(r,i+1)}return!1}function Cm(e){for(let n=1;n<e.byteLength;n+=1){let r=e[n];if(r>=65&&r<=90)return n}let t=e[0];return t>=65&&t<=90?0:-1}function nE(e,t,n){let r=t.byteLength-1;if(r===0)return Buffer.alloc(0);if(e.byteLength>=r)return Buffer.from(e.subarray(e.byteLength-r));let i=Buffer.concat([n,e]);return Buffer.from(i.subarray(Math.max(0,i.byteLength-r)))}function bt(e){return typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}function rE(e,t){try{return Er(e,t),!0}catch(n){if(bt(n))return!1;throw n}}function Sl(e){let t=Wn(e);return t?t.filter(n=>n&&!ys(n)).sort():(yE(e)??hE(e)).filter(n=>n&&!ys(n)).sort()}function iE(e,t={}){let n=(t.includePaths??[]).map(ve),r=[...new Set([...Sl(e),...n])].filter(s=>!ys(s)).filter(s=>!t.language||Yp(s,t.language,t.markerFiles)).filter(s=>!t.includePath||t.includePath(s)).sort((s,a)=>s.localeCompare(a)),i=wi(e),o=r.flatMap(s=>Em(e,i,s));return dl(i),o}function Em(e,t,n){let r=oE(e,n);if(r)return r;let i=yl(e,n);try{let o=gl(i);return o.isSymbolicLink()?sE(t,n,i,o):aE(t,n,i,o)}catch(o){return bt(o)?[]:[{path:n,size:-1,hash:"unreadable"}]}}function oE(e,t){let n=$f(e,t);if(n)return[{path:t,size:n.fingerprintSize??n.size,hash:n.sha256}];if(Vn(e,t)==="present"){let r=Gn(e,t);if(r)return[{path:t,size:r.fingerprintSize??r.size,hash:r.sha256}]}return null}function sE(e,t,n,r){let i=ll(e,t,"symlink",gs(r));if(i)return[{path:t,size:i.size,hash:i.hash}];let o=wi(n),s=UC(e,o);if(s===".."||s.startsWith(`..${HC}`)||WC(s))throw new Error("external symlink");let a=VC(n),c=ml("sha256").update("symlink\0").update(a).digest("hex"),l=Buffer.byteLength(a);return ul(e,t,"symlink",gs(r),{hash:c,size:l}),[{path:t,size:l,hash:c}]}function aE(e,t,n,r){let i=Qc(t)||el(t),o=ll(e,t,"file",gs(r));if(o&&(!i||o.semanticHash!==void 0))return[{path:t,size:o.size,hash:o.hash,...o.semanticHash===void 0?{}:{semanticHash:o.semanticHash}}];let s=cE(n,t,i);return ul(e,t,"file",gs(r),s),[{path:t,...s}]}function cE(e,t,n){let r=ml("sha256"),i=n,o=[],s=Sr(e,{inputKind:"project fingerprint input",maxBytes:Cr},u=>{r.update(u),i&&o.push(Buffer.from(u))}),a=r.digest("hex"),c=i?Buffer.concat(o,s):void 0,l=c?tm(t,c)??Zc(t,c):void 0;return{size:s,hash:a,...l===void 0?{}:{semanticHash:l}}}function gs(e){return{dev:e.dev,ino:e.ino,mtimeMs:e.mtimeMs,ctimeMs:e.ctimeMs,size:e.size}}function Pr(e,t,n){let r=wr(t,n),i=[...r.typescriptProjects.filter(c=>mE(e,c)),...r.clojureConfigPath?[r.clojureConfigPath]:[]],o=r.languages.includes("typescript")?zf(e,r.typescriptProjectMode,r.typescriptProjects):null,s=r.languages.includes("typescript")?r.typescriptProjectMode==="workspace"?as(e,r.typescriptProjects):["."]:[],a=qf(s);return{...r,files:iE(e,{includePath:c=>{if(c===".scipquery.json")return!1;let l=ft(c,t,i);return l==="other"||l==="config"&&cs(c)&&!a.has(c)?!1:l!=="source"||!fE(c)||!o?!0:o.has(c)},includePaths:i})}}function lH(e,t){let n=new Set(t.files.map(o=>o.path)),r=Pr(e,t.languages,t),i=new Map(r.files.map(o=>[o.path,o]));return{...wr(t.languages,t),files:[...t.files.flatMap(o=>{let s=i.get(o.path);return s?[s]:[]}),...r.files.filter(o=>!n.has(o.path))]}}function uH(e,t,n,r,i,o){let s=b=>({mode:"full",fingerprint:Pr(e,t,n),reason:b}),a=lE(r,i,o);if(!a.ready)return s(a.reason);let{previous:c,journal:l}=a,u=wr(t,n);if(!pE(c,u))return s("project-input-configuration-changed");if(new Set(c.files.map(b=>b.path)).size!==c.files.length)return s("prior-project-input-snapshot-has-duplicate-paths");if(l.entries.length===0)return{mode:"delta",fingerprint:{...u,files:[...c.files].sort((b,x)=>b.path.localeCompare(x.path))},changedPaths:[]};let d=new Map(c.files.map(b=>[b.path,b])),p=uE(t,u,d,l);if(p)return s(p);let f=wi(e),h=dE(e,f,d,l);return h?s(h):(dl(f),{mode:"delta",fingerprint:{...u,files:[...d.values()].sort((b,x)=>b.path.localeCompare(x.path))},changedPaths:l.entries.map(b=>b.path).sort()})}function lE(e,t,n){return t?t.complete?n?t.baseGeneration!==n?{ready:!1,reason:"change-journal-base-mismatch"}:e?{ready:!0,previous:e,journal:t}:{ready:!1,reason:"prior-project-input-snapshot-unavailable"}:{ready:!1,reason:"accepted-generation-unavailable"}:{ready:!1,reason:`change-journal-incomplete:${t.incompleteReason??"unknown"}`}:{ready:!1,reason:"change-journal-unavailable"}}function uE(e,t,n,r){let i=[...t.typescriptProjects,...t.clojureConfigPath?[t.clojureConfigPath]:[]];for(let o of r.entries){let s=vE(o,n,e,i);if(s!==null)return s}return null}function dE(e,t,n,r){for(let i of r.entries){let o=Em(e,t,i.path);if(i.kind==="delete"){if(o.length!==0)return"deleted-source-is-still-readable";n.delete(i.path);continue}if(o.length!==1||o[0].hash==="unreadable"||o[0].size<0)return i.kind==="add"?"added-source-is-not-readable":"changed-source-no-longer-readable";n.set(i.path,o[0])}return null}function pE(e,t){return e.version===t.version&&e.typescriptSymbolIdentityVersion===t.typescriptSymbolIdentityVersion&&JSON.stringify([...e.languages].sort())===JSON.stringify(t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&JSON.stringify([...e.typescriptProjects].sort())===JSON.stringify(t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function fE(e){return/\.(?:[cm]?[jt]sx?|vue)$/iu.test(e)}function mE(e,t){let n;try{n=ve(t)}catch{return!1}let r=Vn(e,n);if(r)return r==="present";try{return gl(yl(e,n)).isFile()}catch(i){if(bt(i))return!1;throw i}}function wr(e,t){return{version:3,...e.includes("typescript")?{typescriptSymbolIdentityVersion:6}:{},languages:[...e].sort(),pnpmWorkspaces:t.typescriptProjectMode!=="workspace"&&t.pnpmWorkspaces===!0,typescriptProjectMode:t.typescriptProjectMode??"single",typescriptProjects:JC(t.typescriptProjects),clojureConfigPath:gE(t.clojureConfigPath)}}function gE(e){return e?.trim()||void 0}function yE(e){try{let t=qo(e,52428800,()=>GC("git",["-C",e,"ls-files","-co","-v","-z","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:104857600,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"}));return[...Ho(t)]}catch{return null}}function hE(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?yl(e,r):e,o=os(i);for(let s of o){let a=r?`${r}/${s.name}`:s.name;if(s.isDirectory()){ys(a)||n.push(a);continue}t.push(a)}}return t}function ys(e){let t=e.split("/");return e==="meta.json"||Hf(e)||t[0]===".scipquery"&&IE.has(t[1])||t.some(n=>SE.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var SE=new Set([".git","node_modules",".scipquery-cache",".scipquery-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);function bE(e,t,n,r){if(n==="missing")throw Object.assign(new Error(`Snapshot project file ${JSON.stringify(t)} does not exist.`),{code:"ENOENT"});let i=Gn(e,t);if(!i)throw new Q(t,"changed-during-read");let o=r.maxBytes??Cr;if(dn(o),i.size>o)throw new Pt(r.inputKind??"project file",t,i.size,o);return Buffer.from(i.content)}function xE(e){return(e&128)===0?1:(e&224)===192?2:(e&240)===224?3:(e&248)===240?4:0}function vE(e,t,n,r){let i=t.get(e.path);return ft(e.path,n,r)!=="source"?"non-source-project-input-changed":RE(e,i)}function RE(e,t){return e.kind==="add"&&t?"added-path-already-in-prior-project-input-snapshot":e.kind==="delete"&&!t?"deleted-path-not-in-prior-project-input-snapshot":e.kind==="change"&&!t?"changed-path-not-in-prior-project-input-snapshot":t&&(t.hash==="unreadable"||t.size<0)?"changed-path-was-unreadable":null}var IE=new Set(["events","ledger","releases","suppressions"]);import{basename as Pm}from"path";var CE=U("indexed-document-paths",{clearGroups:["whole-project"]});function Re(e,t={}){let n=EE(t);return[...CE.get(e,n,()=>{let i=t.scope?"AND relative_path LIKE ?":"",o=t.like?"AND relative_path LIKE ?":"",s=[...t.scope?[`%${t.scope}%`]:[],...t.like?[t.like]:[]],a=e.all(`SELECT relative_path
|
|
87
|
+
FROM documents
|
|
88
|
+
WHERE 1 = 1
|
|
89
|
+
${e.pathExclusionsFor("documents")}
|
|
90
|
+
${i}
|
|
91
|
+
${o}
|
|
92
|
+
ORDER BY relative_path`,...s).map(l=>l.relative_path),c=t.extensions?a.filter(l=>t.extensions.some(u=>l.toLowerCase().endsWith(u.toLowerCase()))):a;return t.includeIgnored===!1?c.filter(l=>!e.isIgnored(l)):c})]}function EE(e){let t=e.extensions?[...new Set(e.extensions.map(n=>n.toLowerCase()))].sort():null;return JSON.stringify({scope:e.scope??null,like:e.like??null,extensions:t,includeIgnored:e.includeIgnored!==!1})}function Fm(e,t,n){let r=Tm(t);if(!r)return[];let i=e.all(`SELECT relative_path
|
|
93
|
+
FROM documents
|
|
94
|
+
WHERE relative_path = ?
|
|
95
|
+
${e.pathExclusionsFor("documents")}`,r).filter(c=>!e.isIgnored(c.relative_path)).map(c=>({relativePath:c.relative_path,score:wm(c.relative_path,r)}));if(i.length>0)return i;let o=Re(e,{includeIgnored:!1}).map(c=>({relativePath:c,score:wm(c,r)})).filter(c=>c.score>0).sort((c,l)=>l.score-c.score||c.relativePath.localeCompare(l.relativePath)),s=o.filter(c=>c.score>=1100);if(s.length>0)return n.allowMultiple?s:[s[0]];if(n.requirePathMatch)return[];let a=o.filter(c=>c.score>=800);return a.length>0?n.allowMultiple?a:[a[0]]:n.allowMultiple?o:o.slice(0,1)}function wm(e,t){let n=Tm(e),r=Pm(n),i=Pm(t),o=0;return n===t&&(o+=1200),n.endsWith(`/${t}`)&&(o+=1100),r===i&&(o+=900),n.startsWith(`${t}/`)&&(o+=850),n.includes(t)&&(o+=250),o}function Tm(e){return e.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}import{createHash as PE}from"crypto";import{serialize as vl,deserialize as wE}from"v8";import{types as bl}from"util";var Nm=`node-v8:${process.versions.node}:${process.versions.v8}`,Lm=2e4,_m=16*1024*1024,Kn=null,xl=class{constructor(t,n){this.owner=t;this.parent=n}owner;parent;complete=!0;bytes=0;statements=new Map;reads=new Map;record(t,n,r,i){if(!this.complete)return;let o=this.statements.get(t);o===void 0&&(o=this.statements.size,this.statements.set(t,o),this.bytes+=t.length*2);let s=`${o}:${n}:${r}`,a=this.reads.get(s);if(a){a.digest!==i&&(this.complete=!1);return}if(this.bytes+=s.length*2+128,this.reads.size>=Lm||this.bytes>_m){this.complete=!1;return}this.reads.set(s,{statement:o,method:n,parameters:r,digest:i})}proof(){return this.complete?{version:1,encoding:Nm,statements:[...this.statements.keys()],reads:[...this.reads.values()]}:void 0}};function Dm(e,t){let n=new xl(e,Kn);Kn=n;try{let r=t();return bl.isPromise(r)&&We(),{result:r,proof:n.proof()}}catch(r){throw We(),r}finally{Kn=n.parent}}function We(){for(let e=Kn;e;e=e.parent)e.complete=!1}function Ss(e){for(let t=Kn;t;t=t.parent)if(t.owner===e)return!0;return!1}function Rl(e,t){if(!Kn)return t();let n=FE(e),r;try{r=t()}catch(i){throw We(),i}return n!==void 0&&TE(e,n,r),r}function FE(e){try{if(e.supported&&Il(e.parameters))return vl(e.parameters).toString("base64")}catch{}We()}function TE({owner:e,sql:t,method:n,parameters:r},i,o){try{if(vl(r).toString("base64")!==i){We();return}let s=Am(o);for(let a=Kn;a;a=a.parent)a.owner===e?a.record(t,n,i,s):a.complete=!1}catch{We()}}function km(e,t){let n=new Map;try{return NE(t)?t.reads.every(r=>{let i=n.get(r.statement);i||(i=e.prepare(t.statements[r.statement]),n.set(r.statement,i));let o=wE(Buffer.from(r.parameters,"base64"));return!Array.isArray(o)||!Il(o)?!1:Am(i[r.method](...o))===r.digest}):!1}catch{return!1}}function NE(e){return!e||e.version!==1||e.encoding!==Nm||!Array.isArray(e.statements)||!Array.isArray(e.reads)||e.reads.length>Lm||!e.statements.every(t=>typeof t=="string")||JSON.stringify(e).length*2>_m?!1:e.reads.every(t=>t&&Number.isSafeInteger(t.statement)&&t.statement>=0&&t.statement<e.statements.length&&(t.method==="get"||t.method==="all")&&typeof t.parameters=="string"&&typeof t.digest=="string")}function Il(e,t=0){return e==null||["string","number","bigint"].includes(typeof e)?!0:typeof e!="object"||bl.isProxy(e)||t>3?!1:ArrayBuffer.isView(e)?Buffer.isBuffer(e)&&!bl.isSharedArrayBuffer(e.buffer):LE(e)?Reflect.ownKeys(e).every(n=>{if(typeof n!="string")return!1;let r=Object.getOwnPropertyDescriptor(e,n);return"value"in r&&Il(r.value,t+1)}):!1}function LE(e){let t=Object.getPrototypeOf(e);return Array.isArray(e)||t===Object.prototype||t===null}function Am(e){return PE("sha256").update(vl(e)).digest("hex")}var _E=[me("source-facts",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/source-facts.ts"}),me("file-definitions",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/symbols/definition-catalog.ts"}),me("definition-exclusions",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/framework-patterns.ts"}),me("doc-path-tokens",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-products.test.ts",owner:"tests/storage/evidence-cache.test.ts"}),me("doc-path-evidence",{dependsOn:["content-hash","git-history","git-head","tool-version"],keyParts:["kind","relativePath","contentHash","trackedFiles","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/cleanup/doc-drift.ts"}),me("source-imports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),me("source-reexports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),me("source-fingerprints",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/definition-catalog.test.ts",owner:"src/queries/cleanup/similar.ts"}),me("consumer-file-usage",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/internal/consumer-evidence.ts"}),me("react-component-behavior-profiles",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/react-profile.ts"}),me("git-file-adds",{dependsOn:["git-head","git-history","tool-version"],keyParts:["kind","cacheKey","head","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/git-history.ts"}),me("typescript-reference-fragments",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-reference-fragments.test.ts",owner:"src/semantic/typescript/reference-fragment-shadow.ts"}),me("typescript-import-usage",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),me("typescript-signatures",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),me("runtime-boundary-http-roles",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/analysis/runtime-boundaries.test.ts",owner:"src/analysis/runtime-boundaries/http-summaries.ts"}),me("runtime-boundary-mount-imports",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/analysis/runtime-boundary-accuracy.test.ts",owner:"src/analysis/runtime-boundaries/http-mounts.ts"}),me("runtime-boundary-source-hashes",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/analysis/runtime-boundaries.test.ts",owner:"src/analysis/runtime-boundaries/graph.ts"}),me("runtime-boundary-direct-extraction",{dependsOn:["content-hash","direct-deps-digest","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/analysis/runtime-boundaries.test.ts",owner:"src/analysis/runtime-boundaries/graph.ts"}),Ti("file-dependency-graph",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","scope","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/file-dep-graph.test.ts",owner:"src/symbols/graph/file-dep-graph.ts"}),Ti("semantic-import-usage",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","relativePath","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),Ti("semantic-signatures",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","symbol","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),Ti("health-semantic-prewarm",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","scope","cliVersion","projectFingerprint","payloadVersion"],stalenessTest:"tests/runtime/cli-support.test.ts",owner:"src/runtime/cli-support.ts"}),Ti("typescript-hierarchy-targets",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","definitionSet","projectFingerprint","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/typescript/ts-morph-provider.ts"})];function ge(e){let t=new Map,n=e.invalidation.dependsOn.every(r=>r==="content-hash"||r==="tool-version");return{kind:e.kind,read(r,i,o){if(!n&&Ss(r.db))return null;let s=!1,a=0,c;if(fn()){let l=qt(r);if(l){let u=`${l}\0${i}\0${o}`;c=t.get(u),c||(c=bi(["evidence-product-file-read-v1",e.kind,l,i,o]),t.set(u,c))}}return se("evidence-product.file.read",()=>{let l=ff(r,e.kind,i,o);if(l===null)return null;a=l.length;try{let u=e.deserialize(l);return s=u!==null,u}catch{return null}},()=>({...c?{workIdentity:c,workOutcome:"computed"}:{},scope:"file",kind:e.kind,available:!0,hit:s,payloadBytes:a}))},has(r,i,o){return!n&&Ss(r.db)?!1:mf(r,e.kind,i,o)},write(r,i,o,s){yf(r,e.kind,i,o,e.serialize(s))},writeBatch(r,i){hf(r,i.map(o=>({kind:e.kind,relativePath:o.relativePath,contentHash:o.contentHash,payload:e.serialize(o.value)})))}}}function Om(e){let t=new Map;return{kind:e.kind,read(n,r,i){if(Ss(n.db))return null;let o=!1,s=0,a;if(fn()){let c=`${i}\0${r}`;a=t.get(c),a||(a=bi(["evidence-product-project-read-v1",e.kind,i,r]),t.set(c,a))}return se("evidence-product.project.read",()=>{let c=Sf(n,e.kind,r,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"project",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(n,r,i,o){bf(n,e.kind,r,i,e.serialize(o))}}}function ee(e){let t=_E.find(n=>n.kind===e);if(!t)throw new Error(`missing evidence product manifest entry for ${e}`);return t.invalidation}function me(e,t){return{scope:"file",kind:e,invalidation:{scope:"file",...t}}}function Ti(e,t){return{scope:"project",kind:e,invalidation:{scope:"project",...t}}}var bs=null,xs=null,Ni=null;function Fr(e,t){wt(e),Ni?.source(e,t)}function Ie(e){wt(e),Ni?.unavailable(e)}function Mm(e,t){xs?.(e,t)}function wt(e){bs?.(e)}function vs(e,t,n,r){let i=bs,o=xs,s=Ni;Ni=r?{source(a,c){s?.source(a,c),r.source(a,c)},unavailable(a){s?.unavailable(a),r.unavailable(a)}}:s,bs=i?a=>{i(a),e(a)}:e,xs=n?(a,c)=>{o?.(a,c),n(a,c)}:o;try{return t()}finally{bs=i,xs=o,Ni=s}}var DE=ie("source-text",{clearGroups:["whole-project","source-file"]}),kE=Mn("source-lines",{clearGroups:["whole-project","source-file"]});function L(e,t){let n=t.replace(/\\/g,"/");wt(n);let r=DE.get(e,n,()=>$m(e,n));return Bm(n,r)}function Li(e,t){let n=t.replace(/\\/g,"/");return wt(n),Bm(n,$m(e,n))}function Bm(e,t){return Fr(e,t.text),t.available||Ie(e),t.text}function $m(e,t){try{return{text:zn(e.config.projectRoot,t,{inputKind:"indexed source file"}),available:!0}}catch(n){if(Ie(t),bt(n))return{text:"",available:!1};throw n}}function TH(e){if(e.length===0)return[];let t=e.split(`
|
|
96
|
+
`);return e.endsWith(`
|
|
97
|
+
`)&&t.pop(),t}function zt(e,t){let n=t.replace(/\\/g,"/"),r=L(e,n);return kE.get(e,n,r,()=>r?r.split(`
|
|
98
|
+
`):[])}var AE=/^\s*(?:\/\/|#|\/\*+|\*)\s*scip-query[\s:-]*ignore(?:[\s:-]+([a-z][\w-]*))?(?![\w-])/i;function OE(e){let t=AE.exec(e);return t?t[1]?.toLowerCase()??"":null}function NH(e,t,n){return Gm(e,t,n).length>0}function LH(e,t,n,r){let i=jm(r);return Gm(e,t,n).some(o=>o===""||jm(o)===i)}function jm(e){let t=e.toLowerCase();return t==="dead-code"||t==="stale"?"dead":t==="wrapper"?"passthrough":t}function Gm(e,t,n){if(n<=0)return[];let r=zt(e,t);if(r.length===0)return[];let i=[];for(let o=n-1;o>=0&&o>=n-5;o-=1){let s=(r[o]??"").trim();if(s==="")continue;let a=OE(s);if(a!==null){i.push(a);continue}if(!ME(s))return i}return i}function ME(e){return["//","*","/*","@","#"].some(t=>e.startsWith(t))}import{setFlagsFromString as Vm}from"v8";import{runInNewContext as jE}from"vm";var Jn;function BE(){if(Jn!==void 0)return Jn;let e=globalThis.gc;if(typeof e=="function")return Jn=e,Jn;try{Vm("--expose_gc");let t=jE("gc");Vm("--no-expose_gc"),Jn=typeof t=="function"?t:null}catch{Jn=null}return Jn}function gn(){let e=BE();return e?(e(),!0):!1}var $E=512*1024*1024,Cl=0;function Wm(e,t=gn){!Number.isFinite(e)||e<=0||(Cl+=e,!(Cl<$E)&&(Cl=0,t()))}import{readdirSync as GE}from"fs";import{execFileSync as VE}from"child_process";import{extname as Rs,join as WE}from"path";var UE=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue",".rs",".py",".pyi",".java",".kt",".kts",".scala",".sc",".clj",".cljs",".cljc",".rb",".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx",".cs",".vb",".php",".dart"],VH=[".vue"],Um=[".tsx",".jsx"],qm=[".vue"],qE=[...Um,...qm],HE=new Set(Um),zE=new Set(qm),Hm=new Set(UE.map(e=>e.toLowerCase())),KE=[...Hm].sort().join(","),zm=new Set(["node_modules",".git","target","dist","build",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs","out","coverage",".scipquery-cache","__pycache__",".venv","venv",".idea",".vscode"]);function Ue(e,t={}){let n=t.includeIndexed??!0,r=t.includeAuxiliary??!0,i=t.extensions?.map(c=>c.toLowerCase()),o=i?new Set(i):Hm,s=i?[...o].sort().join(","):KE,a=`${n?"1":"0"}|${r?"1":"0"}|${s}`;return Km.get(e,a,()=>{let c=new Set;if(n)for(let l of Re(e,{includeIgnored:!1}))o.has(Rs(l).toLowerCase())&&c.add(l);return r&&ZE(e,o,n,c),[...c].sort()})}function WH(e,t={}){let n=!1,r=!1;for(let i of Ue(e,{extensions:qE})){if(t.scope&&!i.includes(t.scope))continue;let o=Rs(i).toLowerCase();if(n||=HE.has(o),r||=zE.has(o),n&&r)break}return{react:n,vue:r}}var Km=U("source-files",{clearGroups:["whole-project"]});Ut({name:"source-files-membership",groups:["source-file"],clearAll:e=>Km.invalidateAll(e)});function JE(e,t){return YE(e,t)??QE(e,t)}function YE(e,t){try{let n=VE("git",["ls-files","-z","--cached","--others","--exclude-standard"],{cwd:e,encoding:"utf-8",timeout:1e4,killSignal:"SIGKILL",stdio:["ignore","pipe","ignore"]}),r=new Set;for(let i of n.split("\0"))i&&(XE(i)||t.has(Rs(i).toLowerCase())&&r.add(i));return r}catch{return null}}function XE(e){return e.split("/").some(t=>zm.has(t))}function QE(e,t){let n=new Set,r=i=>{let o=i?WE(e,i):e,s=GE(o,{withFileTypes:!0});for(let a of s)if(!zm.has(a.name)){if(a.isDirectory()){r(i?`${i}/${a.name}`:a.name);continue}t.has(Rs(a.name).toLowerCase())&&n.add(i?`${i}/${a.name}`:a.name)}};return r(""),n}function ZE(e,t,n,r){for(let i of JE(e.config.projectRoot,t))e.isIgnored(i)||n&&r.has(i)||r.add(i)}import{createRequire as uP}from"module";import{existsSync as hn}from"fs";import{basename as Ym,dirname as qe,extname as Kt,join as nt,relative as yn,resolve as ye,sep as dP}from"path";import{existsSync as Pl,readdirSync as eP,statSync as tP}from"fs";import{join as Tr,relative as nP}from"path";function Jm(e){let t=rP(e)??aP(e);if(!t||t.length===0)return[];let n=[],r=new Set;for(let i of t)for(let o of cP(e,i)){if(r.has(o))continue;r.add(o);let s=lP(e,o);s&&n.push(s)}return n}function rP(e){let t=Tr(e,"pnpm-workspace.yaml");if(!Pl(t))return null;try{return iP(_(t,"pnpm workspace manifest"))}catch{return null}}function iP(e){let t=[],n=!1;for(let r of e.split(/\r?\n/)){let i=oP(r);if(!n){/^packages\s*:\s*$/.test(i.trim())&&(n=!0);continue}let o=/^\s+-\s*(.+)$/.exec(i);if(o){let s=sP(o[1].trim());s&&t.push(s);continue}if(i.trim()!=="")break}return t}function oP(e){let t=e.indexOf("#");return t===-1?e:e.slice(0,t)}function sP(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function aP(e){let t=Tr(e,"package.json");if(!Pl(t))return null;try{let n=JSON.parse(_(t,"workspace package manifest"));return n.workspaces?Array.isArray(n.workspaces)?n.workspaces:n.workspaces.packages??[]:null}catch{return null}}function cP(e,t){if(!t||t.startsWith("!")||t.includes("node_modules"))return[];if(!t.includes("*")){let s=Tr(e,t);return El(s)?[s]:[]}let n=t.indexOf("*"),r=t.slice(0,n).replace(/\/$/,""),i=t.slice(n+1).replace(/^\//,""),o=Tr(e,r||".");return El(o)?eP(o).map(s=>Tr(o,s,i)).filter(El):[]}function El(e){try{return tP(e).isDirectory()}catch{return!1}}function lP(e,t){let n=Tr(t,"package.json");if(!Pl(n))return null;try{let r=JSON.parse(_(n,"workspace package manifest"));return typeof r.name!="string"||r.name.length===0?null:{name:r.name,relativeDir:nP(e,t).replace(/\\/g,"/"),exports:r.exports}}catch{return null}}var pP=oe("indexed-paths",{clearGroups:[]}),fP=oe("indexed-path-digest",{clearGroups:[]}),mP=U("tsconfig-alias-config",{clearGroups:["whole-project"]}),gP=U("tsconfig-alias-config-for-dir",{clearGroups:["whole-project"]}),yP=uP(import.meta.url),_i;function hP(){if(_i!==void 0)return _i;try{_i=yP("typescript")}catch{_i=null}return _i}var SP=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"],bP=oe("workspace-packages",{clearGroups:["whole-project"]}),Yn=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],Is=[".py",".pyi"],He=[".java",".scala",".kt",".kts"],Cs=[".rs"],Es=[".rb"],Ps=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],Sn=[".cs",".vb"],ws=[".dart"],Xn=[".php"],Nr=[".clj",".cljs",".cljc"],xP=new Set(Yn),wl=new Set(Is),Xm=new Set(He),Fl=new Set(Cs),Tl=new Set(Es),Qm=new Set(Ps),Zm=new Set(Sn),Nl=new Set(ws),eg=new Set(Xn),tg=new Set(Nr),vP=[{extensions:Yn,lookup:xP},{extensions:Is,lookup:wl},{extensions:He,lookup:Xm},{extensions:Cs,lookup:Fl},{extensions:Es,lookup:Tl},{extensions:Ps,lookup:Qm},{extensions:Sn,lookup:Zm},{extensions:ws,lookup:Nl},{extensions:Xn,lookup:eg},{extensions:Nr,lookup:tg}];function Jt(e,t){return t.has(Kt(e).toLowerCase())}function RP(e){return Jt(e,wl)}function IP(e){return Jt(e,Xm)}function CP(e){return Jt(e,Fl)}function EP(e){return Jt(e,Tl)}function PP(e){return Jt(e,Qm)}function wP(e){return Jt(e,Zm)}function ng(e){return Kt(e).toLowerCase()===".vb"}function FP(e){return Jt(e,Nl)}function TP(e){return Jt(e,eg)}function NP(e){return Jt(e,tg)}function Ll(e){let t=Kt(e).toLowerCase();for(let n of vP)if(n.lookup.has(t))return n.extensions;return Yn}function LP(e){return IP(e)||wP(e)||TP(e)}function Oe(e,t,n){return RP(t)?Lr(e,t,n):CP(t)?Yt(e,t,n):EP(t)?Fs(e,t,n):PP(t)?Ts(e,t,n):LP(t)?ce(e,n.replace(/\\/g,"."),Ll(t)):FP(t)?Ns(e,t,n):NP(t)?_l(e,n):_P(e,t,n)}function _P(e,t,n){if(!n.startsWith(".")&&!n.startsWith("/"))return DP(e,t,n)??kP(e,n);let r=qe(nt(e.config.projectRoot,t)),i=ye(r,n),o=Xt(e);for(let s of kl(i)){let a=ae(yn(e.config.projectRoot,s));if(o.has(a)||hn(s))return a}return ae(yn(e.config.projectRoot,i))}function DP(e,t,n){let r=og(e,t);if(!r)return null;let i=Xt(e);for(let o of rg(r,n)){let s=ye(r.baseUrl,o);for(let a of kl(s)){let c=ae(yn(e.config.projectRoot,a));if(i.has(c)||hn(a))return c}}return null}function rz(e,t,n){let r=og(e,t);if(!r)return null;for(let i of rg(r,n)){let o=ye(r.baseUrl,i);if(hn(o))return ae(yn(e.config.projectRoot,o))}return null}function rg(e,t){let n=[];for(let[r,i]of Object.entries(e.paths)){let o=r.indexOf("*");if(o===-1){if(t!==r)continue;n.push(...i);continue}HP(r,o,t,i,n)}return n}function kP(e,t){let n=OP(AP(e),t);if(!n)return null;let r=Xt(e);for(let i of MP(n)){let o=ye(e.config.projectRoot,n.pkg.relativeDir,i);for(let s of kl(o)){let a=ae(yn(e.config.projectRoot,s));if(r.has(a)||hn(s))return a}}return null}function AP(e){return bP.get(e,()=>Jm(e.config.projectRoot))}function OP(e,t){let n=null;for(let r of e){let i=null;t===r.name?i="":t.startsWith(`${r.name}/`)&&(i=t.slice(r.name.length+1)),i!==null&&(!n||r.name.length>n.pkg.name.length)&&(n={pkg:r,subpath:i})}return n}function MP(e){let t=[],n=jP(e.pkg.exports,e.subpath);if(n){t.push(n.replace(/^\.\//u,""));let r=BP(n);r&&t.push(r)}return t.push(e.subpath?`src/${e.subpath}`:"src/index"),t}function jP(e,t){if(typeof e=="string")return t===""?e:null;if(!e||typeof e!="object")return null;let n=t===""?".":`./${t}`;return ig(e[n])}function ig(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;let t=e;for(let n of["types","import","default","require","node"]){let r=ig(t[n]);if(r)return r}return null}function BP(e){let t=e.replace(/^\.\//,"");return t.startsWith("dist/")?`src/${t.slice(5)}`:null}function og(e,t){let n=ae(qe(t));return gP.get(e,n,()=>$P(e,n))}function $P(e,t){let n=hP();if(!n)return null;let r=ye(e.config.projectRoot),i=ye(r,t);for(;i===r||i.startsWith(r+dP);){for(let s of SP){let a=nt(i,s);if(!hn(a))continue;let c=mP.get(e,a,()=>GP(n,a));if(c)return c}let o=qe(i);if(o===i)break;i=o}return null}function GP(e,t){try{let n=e.readConfigFile(t,e.sys.readFile);if(n.error||!n.config)return null;let r=e.parseJsonConfigFileContent(n.config,e.sys,qe(t)),i=r.options.paths;return!i||Object.keys(i).length===0?null:{baseUrl:r.options.baseUrl?ye(qe(t),r.options.baseUrl):qe(t),paths:i}}catch{return null}}function Lr(e,t,n){let r=Xt(e),i;if(n.startsWith(".")){let o=n.match(/^(\.+)(.*)$/);if(!o)return null;let s=o[1].length,a=o[2].replace(/^\./,""),c=qe(nt(e.config.projectRoot,t));for(let l=1;l<s;l++)c=qe(c);i=a?ye(c,a.replace(/\./g,"/")):c}else i=ye(e.config.projectRoot,n.replace(/\./g,"/"));for(let o of VP(i)){let s=ae(yn(e.config.projectRoot,o));if(r.has(s)||hn(o))return s}return null}function Yt(e,t,n){if(!n)return null;let r=n.replace(/\s+as\s+.+$/,"").trim();if(!r.startsWith("crate::")&&!r.startsWith("self::")&&!r.startsWith("super::"))return null;let i=qe(nt(e.config.projectRoot,t)),o;return r.startsWith("crate::")?o=ye(e.config.projectRoot,"src",r.slice(7).replace(/::/g,"/")):r.startsWith("self::")?o=ye(i,r.slice(6).replace(/::/g,"/")):o=ye(qe(i),r.slice(7).replace(/::/g,"/")),Dl(e,WP(o))}function Fs(e,t,n){let r=qe(nt(e.config.projectRoot,t)),i=ye(r,n);return Dl(e,UP(i))}function Ts(e,t,n){let r=qe(nt(e.config.projectRoot,t)),i=[ye(r,n),ye(e.config.projectRoot,n),ye(e.config.projectRoot,"include",n),ye(e.config.projectRoot,"src",n)];return Dl(e,i)}function ce(e,t,n){let r=Xt(e),i=t.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=i.replace(/\./g,"/"),s=i.split(".").pop()??i;for(let c of n){let l=`${o}${c}`,u=[...r].find(d=>d.endsWith(l));if(u)return u}for(let c of n){let l=[...r].find(u=>Ym(u)===`${s}${c}`);if(l)return l}let a=[...r].filter(c=>n.includes(Kt(c).toLowerCase())).filter(c=>c.includes(`/${o}/`)||c.includes(`/${s}/`)).sort((c,l)=>c.localeCompare(l));return a.length===1?a[0]:null}function Ns(e,t,n){let r=Xt(e);if(n.startsWith("package:")){let s=n.slice(8),a=s.indexOf("/");if(a<0)return null;let c=s.slice(a+1),l=ae(c.startsWith("lib/")?c:`lib/${c}`);return r.has(l)?l:null}let i=qe(nt(e.config.projectRoot,t)),o=ye(i,n);for(let s of qP(o)){let a=ae(yn(e.config.projectRoot,s));if(r.has(a)||hn(s))return a}return null}function _l(e,t){let n=t.replace(/-/g,"_").replace(/\./g,"/"),r=Xt(e);for(let i of Nr){let o=`${n}${i}`,s=[...r].find(a=>a.endsWith(o));if(s)return s}for(let i of Nr){let o=[...r].find(s=>Ym(s)===`${n.split("/").pop()}${i}`);if(o)return o}return null}function VP(e){let t=Kt(e);return wl.has(t)?[e]:[`${e}.py`,`${e}.pyi`,nt(e,"__init__.py"),nt(e,"__init__.pyi")]}function Dl(e,t){let n=Xt(e);for(let r of t){let i=ae(yn(e.config.projectRoot,r));if(n.has(i)||hn(r))return i}return null}function WP(e){let t=Kt(e);return Fl.has(t)?[e]:[`${e}.rs`,nt(e,"mod.rs")]}function UP(e){let t=Kt(e);return Tl.has(t)?[e]:[`${e}.rb`,nt(e,"index.rb")]}function qP(e){let t=Kt(e);return Nl.has(t)?[e]:[`${e}.dart`,e]}function kl(e){let t=Kt(e),n=new Set;if(t){n.add(e);for(let r of Yn)n.add(e.slice(0,-t.length)+r)}else for(let r of Yn)n.add(`${e}${r}`),n.add(nt(e,`index${r}`));return[...n]}function Xt(e){return pP.get(e,()=>new Set(Re(e,{includeIgnored:!1}).map(ae)))}function Al(e){return fP.get(e,()=>$([...Xt(e)].sort().join(`
|
|
99
|
+
`)))}function HP(e,t,n,r,i){let o=e.slice(0,t),s=e.slice(t+1);if(!n.startsWith(o)||!n.endsWith(s)||n.length<o.length+s.length)return;let a=n.slice(o.length,n.length-s.length);for(let c of r)i.push(c.includes("*")?c.replace("*",a):c)}function bn(e){return typeof e=="object"&&e!==null}function rt(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}import{basename as sy}from"path";function Ce(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ol(e){return e.replace(/'''[\s\S]*?'''/g,xn).replace(/"""[\s\S]*?"""/g,xn).replace(/#.*$/gm,xn).replace(/\/\/.*$/gm,xn).replace(/\/\*[\s\S]*?\*\//g,xn).replace(/`(?:\\[\s\S]|[^`])*`/g,xn).replace(/'(?:\\.|[^'\\\r\n])*'/g,xn).replace(/"(?:\\.|[^"\\\r\n])*"/g,xn)}function lz(e){return ag(e,{maskStrings:!1})}function uz(e){return ag(e,{maskStrings:!0})}function ag(e,t){let n="",r=0;for(;r<e.length;){let i=zP(e,r);if(i!==null){n+=sg(e,r,i),r=i;continue}let o=e[r];if(o==="`"||o==="'"||o==='"'){let s=KP(e,r,o);n+=t.maskStrings?sg(e,r,s):e.slice(r,s),r=s;continue}n+=o,r+=1}return n}function zP(e,t){if(e[t]!=="/")return null;if(e[t+1]==="/"){let n=e.indexOf(`
|
|
100
|
+
`,t);return n===-1?e.length:n}if(e[t+1]==="*"){let n=e.indexOf("*/",t+2);return n===-1?e.length:n+2}return null}function KP(e,t,n){let r=t+1;for(;r<e.length;){if(e[r]==="\\"){r+=2;continue}if(e[r]===n)return r+1;if(n!=="`"&&e[r]===`
|
|
101
|
+
`)break;r+=1}return r}function sg(e,t,n){let r="";for(let i=t;i<n;i+=1)r+=e[i]===`
|
|
102
|
+
`?`
|
|
103
|
+
`:" ";return r}function xn(e){return e.replace(/[^\r\n]/g," ")}Ut({name:"stripped-source-singleton",groups:["whole-project","source-file"],clearAll:()=>{Ls=null,Di=""},clearFile:()=>{Ls=null,Di=""}});var Ls=null,Di="";function JP(e){return Ls===e||(Ls=e,Di=Ol(e)),Di}function vn(e,t,n){let r=JP(e);return`${r.slice(0,t)}${" ".repeat(n-t)}${r.slice(n)}`}function Me(e,t){return new RegExp(`\\b${Ce(t)}\\b`,"m").test(e)}function _r(e,t){let n=new Set,r=new RegExp(`\\b${Ce(t)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let i of e.matchAll(r)){let o=i[1];o&&n.add(o)}return[...n]}function Ml(e){let t=0;for(let n of e)n==="("&&(t+=1),n===")"&&(t-=1);return t}import{extname as cg}from"path";var YP={".rs":"rust",".ts":"typescript",".mts":"typescript",".cts":"typescript",".tsx":"tsx",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".cjs":"javascript",".py":"python",".pyi":"python",".java":"java",".kt":"kotlin",".kts":"kotlin",".scala":"scala",".sc":"scala",".rb":"ruby",".c":"c",".h":"c",".cc":"cpp",".cpp":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".hxx":"cpp",".cs":"csharp",".php":"php",".vb":"vb",".clj":"clojure",".cljs":"clojure",".cljc":"clojure"};function B(e){return YP[cg(e).toLowerCase()]??null}function it(e){return cg(e).toLowerCase()===".vue"}var lg=new WeakMap,ug=new Set(["call_expression","call","new_expression","jsx_opening_element","jsx_self_closing_element","decorator","pair","string","string_literal","template_string","variable_declarator","function_declaration","generator_function_declaration","function_expression","arrow_function","method_definition","method_signature","function_signature","public_field_definition"]);function Ft(e,t){let n=Array.isArray(t)?t:[t];if(!n.every(o=>ug.has(o)))return e.descendantsOfType(t);let r=XP(e);return n.length===1?r.get(n[0])??[]:n.flatMap(o=>r.get(o)??[]).sort((o,s)=>o.startIndex-s.startIndex)}function dg(e,t){let n=e.walk(),r=0,i=!1;for(;!i;){if(t(n),n.gotoFirstChild()){r+=1;continue}for(;;){if(r===0){i=!0;break}if(n.gotoNextSibling())break;n.gotoParent(),r-=1}}}function XP(e){let t=lg.get(e);if(t)return t;let n=new Map;for(let r of e.descendantsOfType([...ug])){let i=r.type,o=n.get(i);o?o.push(r):n.set(i,[r])}return lg.set(e,n),n}function Ne(e,t){t(e);for(let n of e.namedChildren)Ne(n,t)}var QP=/(?:function|method|lambda)/u,pg=new WeakMap;function ZP(e){let t=pg.get(e);if(t)return t;let n=[];return dg(e,r=>{if(!r.nodeIsNamed)return;let i=r.nodeType;(i==="arrow_function"||QP.test(i))&&n.push(r.currentNode)}),pg.set(e,n),n}function ew(e,t,n){let r=null;for(let i of ZP(e))i.startPosition.row>t||i.endPosition.row<n||(!r||i.endIndex-i.startIndex<r.endIndex-r.startIndex)&&(r=i);return r}function jl(e,t,n){if(e.startPosition.row>t||e.endPosition.row<n)return null;for(let r of e.namedChildren){let i=jl(r,t,n);if(i)return i}return e}var ot=new Set(["arrow_function","closure_expression","constructor_declaration","function_declaration","function_definition","function_expression","generator_function","generator_function_declaration","function_item","lambda","lambda_expression","method","method_declaration","method_definition"]);function st(e,t,n,r,i={}){let o=i.startColumn!==void 0&&i.endColumn!==void 0,s=[],a=d=>{if(!(d.startPosition.row>t||d.endPosition.row<n)&&!(o&&(d.startPosition.row===t&&d.startPosition.column>i.startColumn||d.endPosition.row===n&&d.endPosition.column<i.endColumn))){s.push(d);for(let p of d.namedChildren)a(p)}};if(a(e),o){let d=s.sort((f,h)=>f.endIndex-f.startIndex-(h.endIndex-h.startIndex))[0];if(!d)return null;let p=d.childForFieldName("value");return p?Bl(p)??d:d}let c=s.filter(d=>r.has(d.type));if(c.length===0)return jl(e,t,n);let l=Math.min(...c.map(d=>d.endPosition.row-d.startPosition.row)),u=c.filter(d=>d.endPosition.row-d.startPosition.row===l);return u.length===1?u[0]:null}function te(e){let t=e;for(;["as_expression","satisfies_expression","type_assertion","parenthesized_expression","non_null_expression"].includes(t.type)&&t.namedChildren.length>0;){let n=t.namedChildren.filter(i=>i.type!=="comment"),r=t.type==="type_assertion"?n.at(-1):n[0];if(!r)break;t=r}return t}function Ai(e){if(e.type==="identifier")return e.text;let t=e.childForFieldName("name")??e.childForFieldName("pattern");return t?Ai(t):e.namedChildren.find(n=>n.type==="identifier")?.text??null}function _s(e){return(e.childForFieldName("parameters")??e.namedChildren.find(n=>/parameters/u.test(n.type)))?.namedChildren.map(Ai)??[]}function fg(e,t,n){if(!e)return;let r=new Set(t.filter(i=>i!==null));Ne(e,i=>{i.type!=="identifier"&&i.type!=="shorthand_property_identifier"||r.has(i.text)&&n.add(i.text)})}var ki=new Set(["arrow_function","function_expression","generator_function"]);function Bl(e){if(ki.has(e.type))return e;if(e.type!=="call_expression"||(e.childForFieldName("function")??e.namedChild(0))?.type!=="call_expression")return null;let r=((e.childForFieldName("arguments")??e.namedChildren.find(i=>i.type==="arguments"))?.namedChildren??[]).filter(i=>ki.has(i.type));return r.length===1?r[0]:null}import{createRequire as tw}from"module";var Dr=tw(import.meta.url),Oi=null,$l=!1;function mg(){if($l)return null;if(Oi)return Oi;try{return Oi=Dr("tree-sitter"),Oi}catch{return $l=!0,null}}function bz(e){if(e==="clojure")return"reader";let t=mg();if(!t)return"unavailable";let n=gg(e);if(!n)return"unavailable";try{return new t().setLanguage(n),"ast"}catch{return kr.add(e),"unavailable"}}var Gl=new Map,kr=new Set,nw=new Map([["rust","tree-sitter-rust"],["javascript","tree-sitter-javascript"],["python","tree-sitter-python"],["java","tree-sitter-java"],["kotlin","tree-sitter-kotlin"],["scala","tree-sitter-scala"],["ruby","tree-sitter-ruby"],["c","tree-sitter-c"],["cpp","tree-sitter-cpp"],["csharp","tree-sitter-c-sharp"]]);function rw(e){let t=nw.get(e);if(t)return Dr(t);switch(e){case"typescript":return Dr("tree-sitter-typescript").typescript;case"tsx":return Dr("tree-sitter-typescript").tsx;case"php":return Dr("tree-sitter-php").php;case"vb":{let n=Dr("tree-sitter-vb-dotnet");return n.language??n}default:return}}function gg(e){if(kr.has(e))return null;let t=Gl.get(e);if(t)return t;let n;try{if(e==="clojure")return kr.add(e),null;n=rw(e)}catch{return kr.add(e),null}return Gl.set(e,n),n}var Vl=new Map;function xz(){Oi=null,$l=!1,Gl.clear(),kr.clear(),Vl.clear(),aw.clear()}function iw(e){let t=Vl.get(e);if(t)return t;let n=gg(e);if(!n)return null;let r=mg();if(!r)return null;let i=new r;try{i.setLanguage(n)}catch{return kr.add(e),null}return Vl.set(e,i),i}function ow(e,t){return e.parse(r=>r>=t.length?null:t.slice(r,Math.min(t.length,r+16384)))}var sw=24;function Qn(e,t){let n=iw(e);if(!n)return null;try{let r=ow(n,t);return Wm(t.length*sw),r}catch{return null}}var aw=new Map;import{createRequire as cw}from"module";import{posix as Wl}from"path";var lw=pn("vue-sfc-units"),uw=cw(import.meta.url),dw;function pw(){return dw??=uw("@vue/compiler-sfc")}function Sg(...e){return pw().parse(...e)}function Ar(e,t){let n=bg(t),r=L(e,n);return lw.get(e,n,r,()=>Ul(e,n,r))}function bg(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function fw(e){let t=e?.toLowerCase();return!t||t==="js"||t==="javascript"||t==="jsx"?"javascript":t==="ts"||t==="typescript"?"typescript":t==="tsx"?"tsx":null}function Zn(e){return!e||e.body.length===0?0:e.body.split(`
|
|
104
|
+
`).length}function Ul(e,t,n){let r={relativePath:t,template:null,scripts:[],styles:[],customBlocks:[],errors:[]};if(!n)return r;let i;try{i=Sg(n,{filename:t})}catch(s){return r.errors.push(hg(s)),r}r.errors.push(...i.errors.map(hg));let{descriptor:o}=i;return o.template&&(r.template=Ds(e,t,"template",o.template)),o.script&&r.scripts.push(yg(e,t,o.script,!1)),o.scriptSetup&&r.scripts.push(yg(e,t,o.scriptSetup,!0)),r.styles=o.styles.map(s=>Ds(e,t,"style",s)),r.customBlocks=o.customBlocks.map(s=>Ds(e,t,"custom",s)),r.errors.push(...[r.template,...r.scripts,...r.styles,...r.customBlocks].flatMap(s=>s?.errors??[])),r}function yg(e,t,n,r){let i=Ds(e,t,"script",n);return{...i,kind:"script",setup:r,astLanguage:fw(i.lang)}}function Ds(e,t,n,r){let i=gw(r.attrs),o=typeof i.lang=="string"?i.lang:null,s=typeof i.src=="string"?i.src:typeof r.src=="string"?r.src:void 0;if(s){let c=mw(t,s);if(!c)return{kind:n,ownerPath:t,sourcePath:t,external:!0,src:s,attrs:i,lang:o,body:"",startLine:0,endLine:0,errors:[`Could not resolve Vue ${n} block source: ${s}`]};let l=L(e,c),u=l?Math.max(0,l.split(`
|
|
105
|
+
`).length-1):0;return{kind:n,ownerPath:t,sourcePath:c,external:!0,src:s,attrs:i,lang:o,body:l,startLine:0,endLine:u,errors:l?[]:[`Vue ${n} block source not found: ${c}`]}}let a=Math.max(0,r.loc.start.line-1);return{kind:n,ownerPath:t,sourcePath:t,external:!1,attrs:i,lang:o,body:r.content,startLine:a,endLine:Math.max(a,r.loc.end.line-1),errors:[]}}function mw(e,t){let n=t.split(/[?#]/,1)[0];if(!n||n.startsWith("/")||n.includes("://"))return null;let r=bg(Wl.normalize(Wl.join(Wl.dirname(e),n)));return r===".."||r.startsWith("../")?null:r}function gw(e){return{...e}}function hg(e){return e instanceof Error?e.message:String(e)}function Mi(e,t,n){let i=Ul(e,t,n).scripts.filter(s=>s.astLanguage&&s.body.length>0),o=i[0]?.astLanguage;return o?{body:i.map(s=>`${`
|
|
106
|
+
`.repeat(s.startLine)}${s.body}`).join(`
|
|
107
|
+
`),startLine:0,language:o}:null}var yw=Mn("ast-trees",{clearGroups:["whole-project","source-file"]});function ks(e,t,n,r){let i=yw.get(e,t,n,()=>{let o=r();return o?{tree:o,root:o.rootNode}:null})?.tree??null;return i||Ie(t),i}function D(e,t){if(it(t))return hw(e,t);let n=B(t);if(!n)return Ie(t),null;let r=L(e,t);return r?ks(e,t,r,()=>Qn(n,r)):(Ie(t),null)}function Or(e,t,n){if(Fr(t,n),it(t))return ks(e,t,n,()=>{let i=Mi(e,t,n);return i?Qn(i.language,`
|
|
108
|
+
`.repeat(i.startLine)+i.body):null});let r=B(t);return r?ks(e,t,n,()=>Qn(r,n)):(Ie(t),null)}function hw(e,t){let n=L(e,t);return n?ks(e,t,n,()=>{let r=Mi(e,t,n);if(!r)return null;let i=`
|
|
109
|
+
`.repeat(r.startLine)+r.body;return Qn(r.language,i)}):(Ie(t),null)}function ji(e){return e.type==="comment"||e.type==="line_comment"||e.type==="block_comment"}var Cg=["function_declaration","generator_function_declaration","method_definition","method_signature","function_signature"],Sw=new Set(Cg),bw=[...Cg,"variable_declarator","public_field_definition"],xw=["function_item","function_signature_item"],vw=["function_definition"],Rw=[],Iw=new Set([...ki,"closure_expression","lambda"]);function Eg(e){return e==="rust"?xw:e==="python"?vw:e==="typescript"||e==="tsx"||e==="javascript"?bw:Rw}function Mr(e,t){let n=Fg(e,t);if(n)return{name:n.name,startLine:n.definitionNode.startPosition.row,startColumn:n.definitionNode.startPosition.column,endLine:n.definitionNode.endPosition.row,endColumn:n.definitionNode.endPosition.column,paramCount:Rg(n.functionNode),params:xg(n.functionNode),paramsEndLine:vg(n.functionNode),isLiteralPassthrough:Ig(n.functionNode,t),branches:0};if(!wg(e.type,t))return null;let r=e.childForFieldName("name")??e.namedChildren.find(i=>i.type==="identifier"||i.type==="property_identifier");return r?{name:r.text,startLine:e.startPosition.row,startColumn:e.startPosition.column,endLine:e.endPosition.row,endColumn:e.endPosition.column,paramCount:Rg(e),params:xg(e),paramsEndLine:vg(e),isLiteralPassthrough:Ig(e,t),branches:0}:null}function Pg(e){return e.namedChildren.find(t=>t.type==="parameters"||t.type==="formal_parameters")}function jr(e,t){for(let n=e.parent;n;n=n.parent){let r=wg(n.type,t),i=ki.has(n.type);if(!r&&!Iw.has(n.type))continue;let o=i?Cw(n,t):null,s=o?.functionNode.startIndex===n.startIndex?o.definitionNode:n;return{name:s!==n?o.name:r?n.childForFieldName("name")?.text??null:null,startLine:s.startPosition.row,startColumn:s.startPosition.column,endLine:s.endPosition.row,endColumn:s.endPosition.column}}return null}function Cw(e,t){for(let n=e.parent;n;n=n.parent){let r=Fg(n,t);if(r?.functionNode.startIndex===e.startIndex)return r;if(!["arguments","call_expression","parenthesized_expression"].includes(n.type))break}return null}function xg(e){let t=Pg(e);if(!t)return[];let n=[];for(let r of t.namedChildren)if(!ji(r)){if(r.type==="identifier"){n.push({name:r.text,simple:!0});continue}n.push(Tw(r))}return n}function vg(e){let t=Pg(e);return t?t.endPosition.row:e.startPosition.row}function wg(e,t){return t==="rust"?e==="function_item"||e==="function_signature_item":t==="python"?e==="function_definition":t==="typescript"||t==="tsx"||t==="javascript"?Sw.has(e):!1}function Fg(e,t){return t!=="typescript"&&t!=="tsx"&&t!=="javascript"?null:e.type==="variable_declarator"||e.type==="public_field_definition"?Ew(e):null}function Ew(e){let t=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1);if(!t||!n)return null;let r=Bl(n);return r?{name:t.text,definitionNode:e,functionNode:r}:null}function Rg(e){let t=e.namedChildren.find(r=>r.type==="parameters"||r.type==="formal_parameters");if(!t)return 0;let n=0;for(let r of t.namedChildren)ji(r)||(n+=1);return n}function Ig(e,t){let n=e.namedChildren.find(l=>l.type==="block"||l.type==="statement_block");if(!n)return!1;let r=n.namedChildren.filter(l=>!ji(l));if(r.length!==1)return!1;let i=r[0],o=Pw(i,t);if(!o)return!1;let s=o.namedChildren.find(l=>l.type==="arguments"||l.type==="argument_list");if(!s)return!1;let a=s.namedChildren.filter(l=>!ji(l)),c=Fw(e);if(!c||a.length!==c.length)return!1;for(let l=0;l<c.length;l+=1){let u=a[l];if(u.type!=="identifier"||u.text!==c[l])return!1}return!0}function Pw(e,t){let n=ww(e,t);if(!n)return null;let r=t==="python"?"call":"call_expression";if(n.type!==r)return null;let i=n.childForFieldName("function")??n.namedChild(0);return i&&(i.type===r||i.type==="call_expression")?null:n}function ww(e,t){let n=null;return e.type==="return_statement"||e.type==="expression_statement"?n=e.namedChild(0)??null:t==="rust"&&(e.type==="call_expression"||e.type==="macro_invocation")&&(n=e),n}function Fw(e){let t=e.namedChildren.find(r=>r.type==="parameters"||r.type==="formal_parameters");if(!t)return null;let n=[];for(let r of t.namedChildren){if(r.childForFieldName("value")||r.type==="assignment_pattern"||r.type==="default_parameter")return null;if(r.type==="identifier"){n.push(r.text);continue}let i=r.namedChildren.find(o=>o.type==="identifier");i&&n.push(i.text)}return n}function Bz(e,t){let n=e.filter(o=>o.startLine<=t&&o.endLine>=t),r=Math.min(...n.map(o=>o.endLine-o.startLine)),i=n.filter(o=>o.endLine-o.startLine===r);return i.length===1?i[0]:null}function Tw(e){let t=e.namedChildren.some(i=>i.type.endsWith("_modifier"))||/^\s*(?:public|private|protected|readonly|override)\b/.test(e.text),n=e.childForFieldName("pattern");if(!t&&n&&n.type==="identifier")return{name:n.text,simple:!0};let r=e.namedChildren.find(i=>i.type==="identifier");return{name:n?.type==="identifier"?n.text:r?.text??"",simple:!1}}function Tt(e,t){let n=_w(e,t);if(!n)return null;let r=Hl(n)??(["typescript","tsx","javascript"].includes(t)?n:null);if(!r)return null;let i=r.text.replace(/^#/u,""),o=Ng(n);return{kind:Nw(e),calleeLeaf:i,calleeQualifier:o?Lw(n):void 0,calleeText:n.text,memberAccess:o,line:e.startPosition.row,targetExpressionRange:{startLine:n.startPosition.row,startColumn:n.startPosition.column,endLine:n.endPosition.row,endColumn:n.endPosition.column},targetRange:{startLine:r.startPosition.row,startColumn:r.startPosition.column,endLine:r.endPosition.row,endColumn:r.endPosition.column},owner:jr(e,t)}}function Nw(e){return Tg.has(e.type)?"jsx-render":e.type==="new_expression"?"new":"call"}var Tg=new Set(["jsx_opening_element","jsx_self_closing_element"]);function Lw(e){return(e.childForFieldName("object")??e.childForFieldName("value")??e.namedChild(0)??void 0)?.text||void 0}function _w(e,t){return t==="rust"?Dw(e):t==="python"?e.type!=="call"?null:e.childForFieldName("function")??e.namedChild(0):t==="typescript"||t==="tsx"||t==="javascript"?kw(e):null}function Dw(e){return e.type==="call_expression"?e.childForFieldName("function")??e.namedChild(0):e.type==="macro_invocation"?e.childForFieldName("macro")??e.namedChild(0):null}function kw(e){return e.type==="call_expression"?ql(e.childForFieldName("function")??e.namedChild(0)):e.type==="new_expression"?ql(e.childForFieldName("constructor")??e.namedChild(0)):Tg.has(e.type)?Ow(e):null}var Aw=new Set(["await_expression","parenthesized_expression","non_null_expression","as_expression","satisfies_expression","type_assertion"]);function ql(e){let t=e;for(;t&&Aw.has(t.type);){let n=t.type==="type_assertion"?t.namedChild(t.namedChildCount-1):t.namedChild(0);if(!n)return t;t=n}return t}function Ow(e){let t=e.childForFieldName("name")??e.namedChild(0);return t&&(t.type==="member_expression"||t.type==="nested_identifier"||(t.type==="identifier"||t.type==="jsx_identifier")&&/^[A-Z]/.test(t.text))?t:null}function Ng(e){switch(e.type){case"field_expression":case"member_expression":case"subscript_expression":case"nested_identifier":case"attribute":return!0;default:return!1}}function As(e){return Hl(e)?.text.replace(/^#/u,"")??null}var Mw=new Set(["super","identifier","type_identifier","field_identifier","property_identifier","private_property_identifier","shorthand_property_identifier","jsx_identifier"]);function Hl(e){if(Mw.has(e.type))return e;if(e.type==="subscript_expression")return jw(e);let t=null;return Ng(e)?t=e.namedChild(e.namedChildCount-1):e.type==="generic_function"?t=e.childForFieldName("function")??e.namedChild(0):e.type==="scoped_identifier"&&(t=e.childForFieldName("name")??e.namedChild(e.namedChildCount-1)),t?Hl(t):null}function jw(e){let t=ql(e.childForFieldName("index"));return t&&["string","number","template_string"].includes(t.type)?t:e}var Bw=new Set(["if_statement","conditional_expression","ternary_expression","for_statement","for_in_statement","for_of_statement","while_statement","do_statement","switch_case","case_statement","catch_clause","except_clause","elif_clause","match_arm"]);function Lg(e){return Bw.has(e.type)?1:e.type==="binary_expression"&&e.parent?.type!=="binary_expression"&&(e.text.includes("&&")||e.text.includes("||"))?$w(e.text):0}function $w(e){return(e.match(/&&|\|\|/g)??[]).length}var Gw=new Set(["identifier","type_identifier","field_identifier"]),Vw=new Set(["identifier"]),Ww=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","shorthand_property_identifier_pattern"]),Uw=new Set(["rust","python"]),qw=/\{([^{}]*)\}/g,Hw=/\b([A-Za-z_][\w]*)\b/g;function _g(e,t){return zw(t).has(e.type)}function Dg(e,t){return Uw.has(t)&&e.type==="string_content"}function zl(e){let t=0;for(let r of e.values()){let i=r[r.length-1];i!==void 0&&i>t&&(t=i)}let n=new Array(t+1);for(let r=0;r<=t;r+=1)n[r]=new Set;for(let[r,i]of e)for(let o of i)n[o].add(r);return n}function zw(e){return e==="rust"?Gw:e==="python"?Vw:Ww}function kg(e,t){let n=e.startPosition.row;for(let r of e.text.matchAll(qw)){let i=r[1]??"";for(let o of i.matchAll(Hw))o[1]&&t(o[1],n)}}var Kw=[/\bdefault\s*=\s*"([^"]+)"/g,/\bwith\s*=\s*"([^"]+)"/g,/\bserialize_with\s*=\s*"([^"]+)"/g,/\bdeserialize_with\s*=\s*"([^"]+)"/g,/\bskip_serializing_if\s*=\s*"([^"]+)"/g,/\bgetter\s*=\s*"([^"]+)"/g,/\brename_all_with\s*=\s*"([^"]+)"/g,/\bschema_with\s*=\s*"([^"]+)"/g],Jw=/^#!?\[\s*serde\s*\(/,Yw=/^#!?\[\s*schemars\s*\(/,Xw=/^#!?\[\s*validate\s*\(/,Qw=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]),Zw=new Set(["typescript","tsx","javascript"]);function Ag(e,t,n){if(!Zw.has(t)||e.type!=="call_expression")return;let r=e.childForFieldName("function")??e.namedChild(0);if(!r)return;let i=As(r);!i||!Qw.has(i)||eF(e,n)}function eF(e,t){let n=e.namedChildren.find(o=>o.type==="arguments");if(!n)return;let r=n.namedChild(0);if(!r||r.type!=="string")return;let i=r.namedChildren.find(o=>o.type==="string_fragment");i&&t.add(i.text)}function Og(e,t){let n=Jw.test(e),r=Yw.test(e),i=Xw.test(e);if(!(!n&&!r&&!i))for(let o of Kw){o.lastIndex=0;let s;for(;(s=o.exec(e))!==null;){let a=s[1],c=a.split("::").pop()??a;tF(c,a)||c&&t.add(c)}}}function tF(e,t){return e==="is_none"?/\bOption\b/.test(t):e==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(t)}function Mg(e,t){let n=new Map,r=(l,u)=>{if(l===u)return;let d=n.get(l);d||(d=new Set,n.set(l,d)),d.add(u)},i=t==="python"?new Set(["identifier"]):new Set(["type_identifier"]),o=(l,u)=>{let d=p=>{i.has(p.type)&&p.text!==u&&r(p.text,u);for(let f of p.children)d(f)};for(let p of l.children)d(p)};return t==="rust"?(()=>{for(let l of e.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let u=l.namedChildren.find(p=>p.type==="type_identifier")?.text;if(!u)continue;let d=l.namedChildren.find(p=>p.type==="field_declaration_list"||p.type==="enum_variant_list"||p.type==="ordered_field_declaration_list");d&&o(d,u),l.type==="type_item"&&o(l,u)}})():t==="python"?(()=>{for(let l of e.rootNode.descendantsOfType("class_definition")){let u=l.namedChildren.find(f=>f.type==="identifier")?.text;if(!u)continue;let d=l.childForFieldName("superclasses");d&&o(d,u);let p=l.namedChildren.find(f=>f.type==="block");if(p)for(let f of p.descendantsOfType("type"))for(let h of f.descendantsOfType("identifier"))r(h.text,u)}})():(()=>{for(let l of e.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let u=l.namedChildren.find(d=>d.type==="type_identifier")?.text;u&&o(l,u)}})(),n}var nF=new Map([["defn","function"],["defn-","function"],["defmacro","macro"],["defmacro-","macro"],["defmethod","method"]]),Kl=new Set(["catch","comment","def","defprotocol","defrecord","deftype","defmethod","defmacro","defmacro-","defn","defn-","do","doseq","dotimes","fn","for","if","let","loop","ns","quote","recur","throw","try","extend-protocol","extend-type","when","when-let","when-not"]);function jg(e){let t=[],n=[],r=[],i=new Map,o=[],s={line:0,index:0},a=(l,u)=>{let d=i.get(l);if(!d){i.set(l,[u]);return}d[d.length-1]!==u&&d.push(u)},c={callables:t,callSites:n,clojureMembers:r,recordIdentifier:a};for(;s.index<e.length;){let l=e[s.index];if(rF(e,l,s)||iF(l,s,o,c))continue;if(Yl(l)){s.index+=1;continue}let u=oF(e,s);u&&(aF(o[o.length-1],u),a(Nt(u.text),u.line))}return{language:"clojure",callables:t,callSites:n,clojureMembers:r,typeContainerMap:new Map,identifierLineMap:i,identifiersByLine:mF(i),fileIdentifiers:new Set(i.keys()),rustAttrReferencedNames:new Set,crossLanguageDispatchNames:new Set}}function rF(e,t,n){if(t===`
|
|
110
|
+
`)n.line+=1,n.index+=1;else if(/\s|,/.test(t))n.index+=1;else if(t===";")n.index=Os(e,n.index);else if(t==='"'){let r=Bi(e,n.index,n.line);n.line=r.line,n.index=r.index}else return!1;return!0}function iF(e,t,n,r){if(e==="("||e==="["||e==="{")n.push({kind:e,startLine:t.line,endLine:t.line,headTokens:[],tokens:[],children:[]});else if(e===")"||e==="]"||e==="}"){let i=n.pop();i&&(i.endLine=t.line,sF(i,r),n[n.length-1]?.children.push(i))}else return!1;return t.index+=1,!0}function oF(e,t){let n=t.line,r=t.index;for(;t.index<e.length&&!Xl(e[t.index]);)t.index+=1;let i=e.slice(r,t.index);return i?{text:i,line:n,column:r-e.lastIndexOf(`
|
|
111
|
+
`,r-1)-1}:null}function sF(e,t){if(e.kind!=="("||e.headTokens.length===0)return;let n=e.headTokens[0],r=Nt(n.text),i=nF.get(n.text);if(i){let s=e.headTokens[1];if(s){let a=Nt(s.text);t.recordIdentifier(a,s.line),t.callables.push({name:a,startLine:e.startLine,endLine:e.endLine,paramCount:0,params:[],paramsEndLine:s.line,isLiteralPassthrough:!1,clojureKind:i})}}if(cF(e,t),!r||Kl.has(n.text)||Kl.has(r)||r.startsWith(":"))return;let o=fF(n.text);t.callSites.push({calleeLeaf:o.leaf,calleeQualifier:o.qualifier,calleeText:o.text,memberAccess:!1,line:n.line,targetRange:{startLine:n.line,startColumn:n.column,endLine:n.line,endColumn:n.column+n.text.length}})}function aF(e,t){e&&(e.headTokens.length<2&&e.headTokens.push(t),e.tokens.length<200&&e.tokens.push(t))}function cF(e,t){let n=Nt(e.tokens[0]?.text??"");if(n==="extend-protocol"){uF(e,t);return}let r=lF(n);if(!r)return;let i=Nt(e.tokens[1]?.text??"");if(i)for(let o of Bg(e))Jl(t,i,r.ownerKind,o,r.memberKind)}function lF(e){switch(e){case"defprotocol":return{ownerKind:"protocol",memberKind:"protocol-method"};case"defrecord":return{ownerKind:"record",memberKind:"record-method"};case"deftype":return{ownerKind:"type",memberKind:"type-method"};case"extend-type":return{ownerKind:"extension",memberKind:"extension-method"};default:return null}}function uF(e,t){let n=Nt(e.tokens[1]?.text??"");for(let r of Bg(e)){n&&Jl(t,n,"extension",r,"extension-method");let i=pF(e,r.startLine);i&&i!==n&&Jl(t,i,"extension",r,"extension-method")}}function Bg(e){return e.children.filter(dF)}function dF(e){if(e.kind!=="(")return!1;let t=Nt(e.tokens[0]?.text??"");return!!(t&&!Kl.has(t)&&!t.startsWith(":"))}function Jl(e,t,n,r,i){let o=r.tokens[0],s=Nt(o?.text??"");!o||!s||(e.recordIdentifier(s,o.line),e.clojureMembers.push({ownerName:t,ownerKind:n,memberName:s,memberKind:i,startLine:r.startLine,endLine:r.endLine}))}function pF(e,t){let n=null;for(let r=2;r<e.tokens.length;r+=1){let i=e.tokens[r];if(i.line>t)break;let o=Nt(i.text);o&&!o.startsWith(":")&&(n=o)}return n}function Nt(e){return e.replace(/^#?['`~@]+/,"").split("/").pop()?.replace(/^\./,"")??""}function fF(e){let t=e.replace(/^#?['`~@]+/,""),n=t.lastIndexOf("/"),r=Nt(t);if(n<=0)return{leaf:r,text:t};let i=t.slice(0,n);return{leaf:r,qualifier:i,text:t}}function Os(e,t){let n=t;for(;n<e.length&&e[n]!==`
|
|
112
|
+
`;)n+=1;return n}function Bi(e,t,n){let r=t+1,i=n;for(;r<e.length;){let o=e[r];if(o==="\\"){r+=2;continue}if(o===`
|
|
113
|
+
`&&(i+=1),r+=1,o==='"')break}return{index:r,line:i}}function Yl(e){return e==="'"||e==="`"||e==="~"||e==="@"||e==="^"||e==="#"}function Xl(e){return/\s|,/.test(e)||e==="("||e===")"||e==="["||e==="]"||e==="{"||e==="}"||e==='"'||e===";"}function mF(e){let t=[];for(let[n,r]of e)for(let i of r)t[i]??=new Set,t[i].add(n);return t}var $g=15,yF=Mn("source-facts",{clearGroups:["whole-project","source-file"]}),Ql=ge({kind:"source-facts",invalidation:ee("source-facts"),serialize:bF,deserialize:xF});function J(e,t){return Zl(e,t).facts}function Zl(e,t){let n=L(e,t);if(!n)return{facts:null};let r=hF(e,t,n);return r?yF.get(e,t,n,()=>SF(e,t,r,n)):{facts:null}}function hF(e,t,n){return it(t)?Mi(e,t,n)?.language??null:B(t)}function SF(e,t,n,r){let i=Se(e,t,r),o=Ql.read(e,t,i);if(o&&o.language===n)return{facts:o};if(n==="clojure"){let c=jg(r);return Ql.write(e,t,i,c),{facts:c}}let s=D(e,t);if(!s)return{facts:null,unavailable:{language:n,reason:"parser-unavailable"}};let a=CF(s,n);return Ql.write(e,t,i,a),{facts:a}}function bF(e){let t={version:$g,language:e.language,callables:e.callables,callSites:e.callSites,clojureMembers:e.clojureMembers,typeContainerMap:[...e.typeContainerMap.entries()].map(([n,r])=>[n,[...r]]),identifierLineMap:[...e.identifierLineMap.entries()],rustAttrReferencedNames:[...e.rustAttrReferencedNames],crossLanguageDispatchNames:[...e.crossLanguageDispatchNames]};return JSON.stringify(t)}function xF(e){try{let t=JSON.parse(e);if(t.version!==$g||t.language==="clojure"&&(t.clojureMembers===void 0||t.callSites.some(r=>r.calleeText===void 0)))return null;let n=new Map(t.identifierLineMap);return{language:t.language,callables:t.callables,callSites:t.callSites,clojureMembers:t.clojureMembers??[],typeContainerMap:new Map(t.typeContainerMap.map(([r,i])=>[r,new Set(i)])),identifierLineMap:n,identifiersByLine:zl(n),fileIdentifiers:new Set(n.keys()),rustAttrReferencedNames:new Set(t.rustAttrReferencedNames),crossLanguageDispatchNames:new Set(t.crossLanguageDispatchNames)}}catch{return null}}function vF(e,t,n,r){let i=J(e,t);return i?IF(i,n,r)?.isLiteralPassthrough??!0:!0}function RF(e,t){return t.relativePath.includes(".clj-kondo/hooks/")?!0:J(e,t.relativePath)?.callables.find(r=>r.startLine===t.startLine&&r.endLine===t.endLine)?.clojureKind==="macro"}function IF(e,t,n){return e.callables.find(r=>r.startLine===t&&r.endLine===n)??null}function CF(e,t){let n=[],r=[],i=new Set,o=new Set,s=new Map,a=(u,d)=>{let p=s.get(u);if(!p){s.set(u,[d]);return}p[p.length-1]!==d&&p.push(d)},c=[],l=u=>{let d=Mr(u,t);d&&(d.branches=0,n.push(d),c.push(d));let p=Lg(u);if(p>0)for(let h of c)h.branches=(h.branches??0)+p;let f=Tt(u,t);f&&r.push(f),Ag(u,t,o),EF(u,t,i,a);for(let h of u.children)l(h);d&&c.pop()};return l(e.rootNode),{language:t,callables:n,callSites:r,clojureMembers:[],typeContainerMap:Mg(e,t),identifierLineMap:s,identifiersByLine:zl(s),fileIdentifiers:new Set(s.keys()),rustAttrReferencedNames:i,crossLanguageDispatchNames:o}}function EF(e,t,n,r){t==="rust"&&(e.type==="attribute_item"||e.type==="inner_attribute_item")&&Og(e.text,n),_g(e,t)&&r(e.text,e.startPosition.row),Dg(e,t)&&kg(e,r)}var Vg=new Set(["rust","typescript","tsx","javascript","python","clojure"]),PF=new Set(["rust","typescript","tsx","javascript","python"]),Wg=new Set(["typescript","tsx","javascript"]),eu=new WeakMap,Gg=new WeakMap;function tu(e,t){let n=J(e,t);return!n||!Vg.has(n.language)?null:n.callables.map(r=>({name:r.name,startLine:r.startLine,endLine:r.endLine}))}function nu(e,t){return Ms(e,t)?.map(({name:n,startLine:r,endLine:i})=>({name:n,startLine:r,endLine:i}))??null}function Ms(e,t){if(!PF.has(t))return null;let n=eu.get(e)?.get(t);if(n)return n;let r=[];for(let o of Ft(e,[...Eg(t)])){let s=Mr(o,t);s&&r.push({...s,branches:void 0})}let i=eu.get(e)??new Map;return i.set(t,r),eu.set(e,i),r}function $i(e,t){let n=B(t);if(!n||!Wg.has(n))return J(e,t)?.callables??null;let r=D(e,t)?.rootNode;return r?Ms(r,n):null}function Br(e,t){let n=B(t);if(n&&Wg.has(n)){let i=D(e,t)?.rootNode;if(!i)return null;let o=Gg.get(i);if(o)return o;let s=Ft(i,["call_expression","new_expression","jsx_opening_element","jsx_self_closing_element"]).flatMap(a=>{let c=Tt(a,n);return c?[c]:[]});return Gg.set(i,s),s}let r=J(e,t);return!r||!Vg.has(r.language)?null:r.callSites}import{createRequire as FF}from"module";var wF=new Set(["children","className","data","e","err","error","ev","event","false","id","idx","index","item","key","null","props","res","result","state","style","true","undefined","val","value"]);function js(e){return e.length<=2||wF.has(e)}function Bs(e,t){return e.split(t).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}var TF=pn("vue-template-facts"),NF=FF(import.meta.url),LF;function Gi(){return LF??=NF("@vue/compiler-dom")}var _F=new Set(["component","keep-alive","slot","suspense","teleport","template","transition","transition-group"]),DF=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]),kF=new Set(["div","span","template"]),AF=new Set(["as","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","false","finally","for","from","function","if","import","in","instanceof","let","new","null","of","return","super","switch","this","throw","true","try","typeof","undefined","var","void","while","with","yield"]);function $s(e,t){let n=t.replace(/\\/g,"/"),r=L(e,n);return TF.get(e,n,r,()=>OF(n,Ar(e,n).template))}function OF(e,t){let n={relativePath:e,template:t?{startLine:t.startLine,endLine:t.endLine}:null,componentTags:[],nativeTags:[],builtinTags:[],props:[],events:[],directives:[],slots:[],expressionIdentifiers:[],structuralTokens:[]};if(!t)return n;let r;try{r=Gi().parse(t.body,{comments:!1})}catch{return n}let i=new Set,o=s=>{s.trim()&&i.add(s)};return qg(r.children,t.startLine,n,o),n.structuralTokens=[...i].sort(),n}function qg(e,t,n,r){for(let i of e)if(i.type===Gi().NodeTypes.ELEMENT)MF(i,t,n,r),qg(i.children,t,n,r);else if(i.type===Gi().NodeTypes.INTERPOLATION){r("interpolation");let o=ru(i.content);o&&Hg(o,t,i.loc.start.line,n,r)}}function MF(e,t,n,r){let i=UF(e.tag),o={tag:e.tag,normalized:i,kind:WF(e),startLine:$r(t,e.loc.start.line),endLine:$r(t,e.loc.end.line)};o.kind==="component"?(n.componentTags.push(o),r(`component:${i}`)):o.kind==="builtin"?(n.builtinTags.push(o),r(`builtin:${i}`)):(n.nativeTags.push(o),kF.has(e.tag)||r(`native:${e.tag}`));for(let s of e.props)jF(s,t,n,r)}function jF(e,t,n,r){if(e.type===Gi().NodeTypes.ATTRIBUTE){let a=e.value?.content??null,c=Ug("prop",e.name,a,t,e.loc.start.line,e.loc.end.line);n.props.push(c),r(`prop:${e.name}`);return}let i=$F(e),o=ru(e.exp),s=Ug(BF(e.name),i,o,t,e.loc.start.line,e.loc.end.line);switch(s.kind){case"prop":n.props.push(s),r(`prop:${i}`);break;case"event":n.events.push(s),r(`event:${i}`);break;case"slot":n.slots.push(s),r(`slot:${i}`);break;case"directive":n.directives.push(s),r(`directive:${i}`);break}o&&Hg(o,t,e.loc.start.line,n,r)}function Ug(e,t,n,r,i,o){return{kind:e,name:t,value:n,startLine:$r(r,i),endLine:$r(r,o)}}function BF(e){switch(e){case"bind":case"model":return"prop";case"on":return"event";case"slot":return"slot";default:return"directive"}}function $F(e){let t=ru(e.arg);return t||e.name}function ru(e){if(!e)return null;let t=("content"in e&&typeof e.content=="string"?e.content:e.loc.source).trim();return t||null}function Hg(e,t,n,r,i){for(let o of GF(e)){let s={name:o,startLine:$r(t,n),endLine:$r(t,n)};r.expressionIdentifiers.push(s),i(`id:${o}`)}}function GF(e){let t=new Set,n=VF(e),r=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,i;for(;i=r.exec(n);){let o=i[0];AF.has(o)||js(o)||/^[A-Z_]+$/.test(o)||t.add(o)}return[...t].sort()}function VF(e){return e.replace(/\/\*[\s\S]*?\*\//g," ").replace(/\/\/.*$/gm," ").replace(/`(?:\\[\s\S]|\$\{([^}]*)\}|[^`\\])*`/g,(t,n)=>n??" ").replace(/'(?:\\[\s\S]|[^'\\])*'/g," ").replace(/"(?:\\[\s\S]|[^"\\])*"/g," ")}function WF(e){let t=e.tag;return e.tagType===Gi().ElementTypes.COMPONENT?"component":_F.has(t)?"builtin":DF.has(t)?"native":/^[A-Z]/.test(t)||t.includes("-")?"component":"native"}function UF(e){return Bs(e,/[-_:]/)}function $r(e,t){return e+Math.max(0,t-1)}var qF=new Set(["ref","shallowRef","reactive","computed","watch","watchEffect"]),HF=new Set(["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured"]),zF=new Set(["axios","fetch","runRequest","useAsyncData","useFetch","useResource"]),KF=new Set(["defineEmits","defineExpose","defineModel","defineOptions","defineProps","withDefaults"]),JF=new Set(["catch","for","function","if","return","switch","while"]);function Vs(e){let t={imports:[],functions:[],calls:[],composables:[],stores:[],reactivity:[],lifecycle:[],requests:[],macros:[],lineCount:0,externalLineCount:0,externalScriptPaths:[],unresolvedScripts:[]};for(let n of e.scripts){t.lineCount+=Zn(n),n.external&&(t.externalLineCount+=Zn(n),t.externalScriptPaths.push(n.sourcePath));for(let i of n.errors)t.unresolvedScripts.push({sourcePath:n.sourcePath,reason:i});if(!n.body||!n.astLanguage){n.astLanguage||t.unresolvedScripts.push({sourcePath:n.sourcePath,reason:`Unsupported Vue script language: ${n.lang??"unknown"}`});continue}t.imports.push(...ZF(n));let r=Qn(n.astLanguage,n.body);r?XF(n,r.rootNode,t):QF(n,t)}return YF(t),t.externalScriptPaths=Kg(t.externalScriptPaths),t}function YF(e){e.composables=Gr(e,"composable"),e.stores=Gr(e,"store"),e.reactivity=Gr(e,"reactivity"),e.lifecycle=Gr(e,"lifecycle"),e.requests=Gr(e,"request"),e.macros=Gr(e,"macro")}function Gr(e,t){return Kg(e.calls.filter(n=>n.categories.includes(t)).map(n=>n.name))}function XF(e,t,n){let r=new Set,i=new Set,o=s=>{let a=Mr(s,e.astLanguage);if(a){let l=`${a.name}:${a.startLine}:${a.endLine}`;i.has(l)||(i.add(l),n.functions.push({name:a.name,sourcePath:e.sourcePath,startLine:e.startLine+a.startLine,endLine:e.startLine+a.endLine,setup:e.setup}))}let c=Tt(s,e.astLanguage);if(c){let l=`${c.calleeLeaf}:${c.line}`;r.has(l)||(r.add(l),n.calls.push({name:c.calleeLeaf,sourcePath:e.sourcePath,line:e.startLine+c.line,categories:zg(c.calleeLeaf),setup:e.setup}))}for(let l of s.children)o(l)};o(t)}function QF(e,t){tT(e,t);for(let n of e.body.matchAll(/\bfunction\s+([A-Za-z_$][\w$]*)\b/g)){let r=n[1];if(!r)continue;let i=e.startLine+Gs(e.body,n.index??0);t.functions.push({name:r,sourcePath:e.sourcePath,startLine:i,endLine:i,setup:e.setup})}for(let n of e.body.matchAll(/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:async\s*)?(?:function\b|\([^)]*\)\s*=>|[A-Za-z_$][\w$]*\s*=>)/g)){let r=n[1];if(!r)continue;let i=e.startLine+Gs(e.body,n.index??0);t.functions.push({name:r,sourcePath:e.sourcePath,startLine:i,endLine:i,setup:e.setup})}}function ZF(e){let t=[];for(let n of e.body.matchAll(/\bimport\s+(?:type\s+)?([^'";]+?)\s+from\s+['"]([^'"]+)['"]/g)){let r=n[1]?.trim(),i=n[2];if(!r||!i)continue;let o=e.startLine+Gs(e.body,n.index??0);for(let s of eT(r))t.push({local:s,source:i,sourcePath:e.sourcePath,line:o,setup:e.setup})}return t}function eT(e){let t=[],r=e.split(",").map(s=>s.trim()).filter(Boolean)[0];r&&!r.startsWith("{")&&!r.startsWith("*")&&t.push(r);let i=/\{([^}]*)\}/.exec(e)?.[1];if(i)for(let s of i.split(",")){let a=s.trim();if(!a)continue;let c=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(a)?.[1];t.push(c??a.replace(/^type\s+/,"").trim())}let o=/\*\s+as\s+([A-Za-z_$][\w$]*)/.exec(e)?.[1];return o&&t.push(o),t.filter(s=>/^[A-Za-z_$][\w$]*$/.test(s))}function zg(e){let t=["call"];return/^use[A-Z0-9_]/.test(e)&&t.push("composable"),/^use[A-Z0-9_].*Store$/.test(e)&&t.push("store"),qF.has(e)&&t.push("reactivity"),HF.has(e)&&t.push("lifecycle"),zF.has(e)&&t.push("request"),KF.has(e)&&t.push("macro"),t}function Gs(e,t){let n=0;for(let r=0;r<t&&r<e.length;r+=1)e.charCodeAt(r)===10&&(n+=1);return n}function Kg(e){return[...new Set(e)].sort()}function tT(e,t){for(let n of e.body.matchAll(/\b([A-Za-z_$][\w$]*)\s*\(/g)){let r=n[1];!r||JF.has(r)||t.calls.push({name:r,sourcePath:e.sourcePath,line:e.startLine+Gs(e.body,n.index??0),categories:zg(r),setup:e.setup})}}var nT=new Set(["in","key","of"]),rT=new Set(["computed","defineEmits","defineProps","reactive","ref","watch","watchEffect"]),iT=pn("vue-component-behavior-profiles");function Jg(e,t={}){let n=Ue(e,{extensions:[".vue"]}).filter(i=>!t.scope||i.includes(t.scope)).sort();return(typeof t.scanLimit=="number"&&t.scanLimit>0?n.slice(0,t.scanLimit):n).map(i=>iu(e,i)).filter(i=>(t.minTemplateTokens===void 0||i.templateTokens.size>=t.minTemplateTokens)&&(t.minBehaviorTokens===void 0||i.behaviorTokens.size>=t.minBehaviorTokens))}function iu(e,t){let n=t.replace(/\\/g,"/"),r=L(e,n),i=iT.get(e,n,r,()=>oT(e,n,r));return aT(i)}function oT(e,t,n){let r=Ar(e,t),i=$s(e,t),o=Vs(r),s=uT(i),a=i.expressionIdentifiers.map(x=>x.name).filter(x=>!s.includes(x)).filter((x,m,g)=>g.indexOf(x)===m).sort(),c=i.componentTags.map(x=>x.normalized).filter((x,m,g)=>g.indexOf(x)===m).sort(),l=n?n.split(`
|
|
114
|
+
`).length:0,u=Zn(r.template),d=o.lineCount,p=r.styles.reduce((x,m)=>x+Zn(m),0),f=r.customBlocks.reduce((x,m)=>x+Zn(m),0),{lines:h,paths:b}=sT(e,t,o);return{file:t,sfc:r,templateFacts:i,scriptFacts:o,templateTokens:new Set(i.structuralTokens),behaviorTokens:lT(i,o,a),templateBindingNames:a,templateLocalNames:s,componentNames:c,sfcLines:l,totalLines:l+o.externalLineCount,templateLines:u,scriptLines:d,styleLines:p,externalScriptLines:o.externalLineCount,externalScriptPaths:o.externalScriptPaths,customBlockLines:f,delegatedComposableLines:h,delegatedComposablePaths:b}}function sT(e,t,n){let r=new Set;for(let s of n.composables){let a=n.imports.find(l=>l.local===s);if(!a)continue;let c=Oe(e,a.sourcePath,a.source);!c||c===t||r.add(c)}let i=[...r].sort();return{lines:i.reduce((s,a)=>{let c=L(e,a);return s+(c?c.split(`
|
|
115
|
+
`).length:0)},0),paths:i}}function aT(e){let t=cT(e.scriptFacts);return{...e,scriptFacts:t,templateTokens:new Set(e.templateTokens),behaviorTokens:new Set(e.behaviorTokens),templateBindingNames:[...e.templateBindingNames],templateLocalNames:[...e.templateLocalNames],componentNames:[...e.componentNames],externalScriptPaths:t.externalScriptPaths,delegatedComposablePaths:[...e.delegatedComposablePaths]}}function cT(e){return{...e,imports:e.imports.map(t=>({...t})),functions:e.functions.map(t=>({...t})),calls:e.calls.map(t=>({...t,categories:[...t.categories]})),composables:[...e.composables],stores:[...e.stores],reactivity:[...e.reactivity],lifecycle:[...e.lifecycle],requests:[...e.requests],macros:[...e.macros],externalScriptPaths:[...e.externalScriptPaths],unresolvedScripts:e.unresolvedScripts.map(t=>({...t}))}}function lT(e,t,n){let r=new Set;Vr(r,t.composables,"composable"),Vr(r,t.stores,"store"),Vr(r,t.reactivity,"reactivity"),Vr(r,t.lifecycle,"lifecycle"),Vr(r,t.requests,"request"),Vr(r,t.macros,"macro");for(let i of t.functions){if(rT.has(i.name))continue;r.add(`function:${i.name}`);let o=/^[a-z]+/.exec(i.name)?.[0]??null;o&&o.length>2&&o!==i.name&&r.add(`function-verb:${o}`)}for(let i of e.events)r.add(`template-event:${i.name}`);for(let i of n)r.add(`template-binding:${i}`);return r}function Vr(e,t,n){for(let r of t)e.add(`${n}:${r}`)}function uT(e){let t=new Set;for(let n of e.directives)if(n.name==="for"&&n.value)for(let r of dT(n.value))t.add(r);for(let n of e.slots)if(n.value)for(let r of Yg(n.value))t.add(r);return[...t].sort()}function dT(e){let t=/^(.*?)\s+(?:in|of)\s+/.exec(e.trim());return t?Yg(t[1]??""):[]}function Yg(e){let t=[];for(let n of e.matchAll(/\b[A-Za-z_$][\w$]*\b/g)){let r=n[0];nT.has(r)||t.push(r)}return t}import{extname as pT}from"path";var fT=[".tsx",".jsx"],Xg=new Set(["useActionState","useCallback","useContext","useDebugValue","useDeferredValue","useEffect","useId","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useOptimistic","useReducer","useRef","useState","useSyncExternalStore","useTransition"]),mT=new Set(["useEffect","useInsertionEffect","useLayoutEffect"]),gT=new Set(["useActionState","useOptimistic","useReducer","useRef","useState"]),yT=new Set(["useLocation","useNavigate","useParams","useSearchParams","useTranslation"]),hT=new Set(["axios","fetch","gql","graphql","mutate","query","request","useMutation","useQuery","useSuspenseQuery"]),ST=new Set(["add","apply","cancel","change","clear","close","create","delete","fetch","filter","handle","load","open","refresh","remove","render","reset","save","select","submit","toggle","update"]),bT=new Set(["aria-hidden","className","clipRule","d","fill","fillRule","height","role","stroke","strokeLinecap","strokeLinejoin","strokeWidth","style","viewBox","width","xmlns"]),xT=pn("react-component-behavior-profiles"),Qg=ge({kind:"react-component-behavior-profiles",invalidation:ee("react-component-behavior-profiles"),serialize:CT,deserialize:ET});function Zg(e,t={}){let n=Ue(e,{extensions:fT}).filter(i=>!t.scope||i.includes(t.scope)).sort();return(typeof t.scanLimit=="number"&&t.scanLimit>0?n.slice(0,t.scanLimit):n).flatMap(i=>ou(e,i)).filter(i=>(t.minJsxTokens===void 0||i.jsxTokens.size>=t.minJsxTokens)&&(t.minBehaviorTokens===void 0||i.behaviorTokens.size>=t.minBehaviorTokens))}function ou(e,t){let n=t.replace(/\\/g,"/"),r=L(e,n);return xT.get(e,n,r,()=>vT(e,n,r)).map(IT)}function vT(e,t,n){let r=Se(e,t,n),i=Qg.read(e,t,r);if(i)return i;let o=RT(e,t);return Qg.write(e,t,r,o),o}function RT(e,t){let n=wT(t);if(!n)return[];let r=D(e,t);if(!r)return[];let i=zt(e,t).length;return FT(r.rootNode,n).filter(s=>s.kind==="hook"||au(s.bodyNode)).map(s=>{let a=MT(s.bodyNode),c=UT(s.bodyNode,n);return{file:t,name:s.name,kind:s.kind,startLine:s.node.startPosition.row,endLine:s.node.endPosition.row,loc:Math.max(1,s.node.endPosition.row-s.node.startPosition.row+1),fileLines:i,jsxTokens:a.tokens,behaviorTokens:c.tokens,componentNames:Qt(a.componentNames),nativeTags:Qt(a.nativeTags),propNames:Qt(a.propNames),eventNames:Qt(a.eventNames),hookNames:Qt(c.hookNames),requestNames:Qt(c.requestNames),stateNames:Qt(c.stateNames),effectNames:Qt(c.effectNames),handlerNames:Qt(c.handlerNames)}})}function IT(e){return{...e,jsxTokens:new Set(e.jsxTokens),behaviorTokens:new Set(e.behaviorTokens),componentNames:[...e.componentNames],nativeTags:[...e.nativeTags],propNames:[...e.propNames],eventNames:[...e.eventNames],hookNames:[...e.hookNames],requestNames:[...e.requestNames],stateNames:[...e.stateNames],effectNames:[...e.effectNames],handlerNames:[...e.handlerNames]}}function CT(e){return JSON.stringify(e.map(t=>({...t,jsxTokens:[...t.jsxTokens],behaviorTokens:[...t.behaviorTokens]})))}function ET(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=[];for(let r of t){let i=PT(r);if(!i)return null;n.push(i)}return n}catch{return null}}function PT(e){if(!bn(e))return null;let{file:t,name:n,kind:r,startLine:i,endLine:o,loc:s,fileLines:a,jsxTokens:c,behaviorTokens:l,componentNames:u,nativeTags:d,propNames:p,eventNames:f,hookNames:h,requestNames:b,stateNames:x,effectNames:m,handlerNames:g}=e;if(typeof t!="string"||typeof n!="string"||!XT(r)||!Ws(i)||!Ws(o)||!Ws(s)||!Ws(a))return null;let y={jsxTokens:rt(c),behaviorTokens:rt(l),componentNames:rt(u),nativeTags:rt(d),propNames:rt(p),eventNames:rt(f),hookNames:rt(h),requestNames:rt(b),stateNames:rt(x),effectNames:rt(m),handlerNames:rt(g)};return Object.values(y).some(I=>I===null)?null:{file:t,name:n,kind:r,startLine:i,endLine:o,loc:s,fileLines:a,jsxTokens:new Set(y.jsxTokens),behaviorTokens:new Set(y.behaviorTokens),componentNames:y.componentNames,nativeTags:y.nativeTags,propNames:y.propNames,eventNames:y.eventNames,hookNames:y.hookNames,requestNames:y.requestNames,stateNames:y.stateNames,effectNames:y.effectNames,handlerNames:y.handlerNames}}function Ws(e){return typeof e=="number"&&Number.isFinite(e)}function wT(e){let t=pT(e).toLowerCase();return t!==".tsx"&&t!==".jsx"?null:B(e)}function FT(e,t){let n=[],r=new Set,i=o=>{let s=TT(o);if(s&&(!AT(o)||s.kind==="component")){let a=`${s.name}:${s.node.startIndex}:${s.node.endIndex}`;r.has(a)||(r.add(a),n.push(s))}for(let a of o.namedChildren)i(a)};return(t==="tsx"||t==="javascript")&&i(e),n}function TT(e){if(e.type==="class_declaration")return NT(e);if(e.type==="function_declaration"){let t=su(e);return!t||!ey(t)?null:{name:t,kind:ty(t),node:e,bodyNode:e}}return e.type!=="variable_declarator"?null:LT(e)}function NT(e){let t=su(e);if(!t||!/^[A-Z]/.test(t))return null;let n=_T(e);return!n||!DT(e)&&!au(n)?null:{name:t,kind:"component",node:e,bodyNode:n}}function LT(e){let t=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1),r=Vi(t);if(!r||!n||!ey(r))return null;let i=kT(n);return i?{name:r,kind:ty(r),node:e,bodyNode:i}:null}function _T(e){for(let t of e.namedChildren)if(t.type==="class_body")for(let n of t.namedChildren){if(n.type!=="method_definition")continue;if((n.childForFieldName("name")??n.namedChild(0))?.text==="render")return n}return null}function DT(e){return/\b(?:React\.)?(?:Pure)?Component\b/.test(e.text)}function ey(e){return/^[A-Z]/.test(e)||/^use[A-Z0-9_]/.test(e)}function ty(e){return/^use[A-Z0-9_]/.test(e)?"hook":"component"}function kT(e){if(e.type==="arrow_function"||e.type==="function_expression")return e;if(e.type!=="call_expression")return null;let t=OT(e);return t!=="memo"&&t!=="forwardRef"?null:e.namedChildren.find(i=>i.type==="arguments")?.namedChildren.find(i=>i.type==="arrow_function"||i.type==="function_expression")??null}function AT(e){let t=e.parent;for(;t;){if(t.type==="function_declaration"||t.type==="function_expression"||t.type==="arrow_function"||t.type==="method_definition")return!0;t=t.parent}return!1}function su(e){return Vi(e.childForFieldName("name")??e.namedChild(0))}function OT(e){let t=e.childForFieldName("function")??e.namedChild(0);return t?t.text.split(".").pop()??t.text:null}function au(e){return e.type.startsWith("jsx_")?!0:e.namedChildren.some(au)}function MT(e){let t={tokens:new Set,componentNames:new Set,nativeTags:new Set,propNames:new Set,eventNames:new Set},n=r=>{r.type==="jsx_opening_element"||r.type==="jsx_self_closing_element"?jT(r,t):r.type==="jsx_element"&&r.text.trimStart().startsWith("<>")?t.tokens.add("jsx:fragment"):r.type==="jsx_expression"?GT(r,t):r.type==="jsx_fragment"&&t.tokens.add("jsx:fragment");for(let i of r.children)n(i)};return n(e),t}function jT(e,t){let n=BT(e,t);for(let r of e.namedChildren)$T(r,t,n)}function BT(e,t){let n=VT(e),r=!1;if(n){let i=oy(n),o=i==="Fragment"||i==="React.Fragment";r=JT(i)&&!o,o?t.tokens.add("jsx:fragment"):r?(t.componentNames.add(i),t.tokens.add(`component:${i}`)):(t.nativeTags.add(i),t.tokens.add(`native:${i}`))}return r}function $T(e,t,n){if(e.type==="jsx_attribute"){let r=WT(e);if(!r)return;let i=oy(r);if(i.startsWith("on")&&i.length>2){let o=i.slice(2).replace(/^[A-Z]/,s=>s.toLowerCase());t.eventNames.add(o),t.tokens.add(`event:${o}`)}else bT.has(i)||(t.propNames.add(i),t.tokens.add(`${n?"prop":"native-prop"}:${i}`))}else e.type==="jsx_spread_attribute"&&t.tokens.add(ny(e))}function GT(e,t){let n=e.text;/^\{\s*\.\.\./.test(n)&&t.tokens.add(ny(e)),ry(e)&&t.tokens.add("jsx:conditional"),(n.includes(".map(")||n.includes(".flatMap("))&&t.tokens.add("jsx:list");for(let r of YT(n))js(r)||t.tokens.add(`binding:${r}`)}function ny(e){let t=/^\{\s*\.\.\.\s*([^}]+)\s*\}$/.exec(e.text)?.[1],n=e.namedChildren.find(o=>o.type!=="comment"),r=t??n?.text??"",i=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.exec(r.trim())?.[0];return i?`prop:spread:${i}`:"prop:spread"}function ry(e){return e.type==="ternary_expression"||e.type==="conditional_expression"?!0:e.namedChildren.some(ry)}function VT(e){for(let t of e.namedChildren)if(t.type==="identifier"||t.type==="jsx_identifier"||t.type==="property_identifier"||t.type==="member_expression"||t.type==="jsx_member_expression")return t.text;return/^<\s*([A-Za-z][\w$.]*)/.exec(e.text)?.[1]??null}function WT(e){for(let t of e.namedChildren)if(t.type==="property_identifier"||t.type==="identifier"||t.type==="jsx_identifier")return t.text;return/^([A-Za-z_$][\w$:-]*)/.exec(e.text)?.[1]??null}function UT(e,t){let n={tokens:new Set,hookNames:new Set,requestNames:new Set,stateNames:new Set,effectNames:new Set,handlerNames:new Set},r=i=>{if(i.type==="call_expression"){let o=Tt(i,t);o&&qT(o.calleeLeaf,n)}else if(i.type==="variable_declarator")zT(i,n);else if(i.type==="function_declaration"){let o=su(i);o&&iy(o,n)}for(let o of i.namedChildren)r(o)};return r(e),n}function qT(e,t){/^use[A-Z0-9_]/.test(e)&&(t.hookNames.add(e),!Xg.has(e)&&!yT.has(e)&&t.tokens.add(`hook:${e}`)),Xg.has(e)&&t.tokens.add(`react-hook:${e}`),mT.has(e)&&(t.effectNames.add(e),t.tokens.add(`effect:${e}`)),gT.has(e)&&t.tokens.add(`state-hook:${e}`),HT(e)&&(t.requestNames.add(e),t.tokens.add(`request:${e}`))}function HT(e){if(hT.has(e))return!0;let t=/^use([A-Z0-9_].*)$/.exec(e)?.[1];return t?/(Query|Mutation|Fetch|Resource)$/.test(t):!1}function zT(e,t){let n=e.childForFieldName("name")??e.namedChild(0),r=e.childForFieldName("value")??e.namedChild(1);if(n?.type==="array_pattern"&&r?.text.includes("useState")){let o=n.namedChildren.find(a=>Vi(a)),s=Vi(o);s&&(t.stateNames.add(s),t.tokens.add(`state:${s}`))}let i=Vi(n);i&&iy(i,t)}function iy(e,t){let n=KT(e);!n||!ST.has(n)||(t.handlerNames.add(e),t.tokens.add(`handler:${e}`),t.tokens.add(`handler-verb:${n}`))}function KT(e){let t=e.startsWith("handle")&&e.length>6?e.slice(6).replace(/^[A-Z]/,n=>n.toLowerCase()):e;return/^[a-z]+/.exec(t)?.[0]??null}function JT(e){return/^[A-Z]/.test(e)||e.includes(".")}function oy(e){return e.replace(/^this\./,"").replace(/\$/g,".")}function Vi(e){return e&&(e.type==="identifier"||e.type==="property_identifier"||e.type==="shorthand_property_identifier"||/^[A-Za-z_$][\w$]*$/.test(e.text))?e.text:null}function YT(e){let t=[];for(let n of e.matchAll(/\b[A-Za-z_$][\w$]*\b/g)){let r=n[0];t.includes(r)||t.push(r)}return t}function Qt(e){return[...e].sort()}function XT(e){return e==="component"||e==="hook"}function n2(e){return{capability:(t,n)=>QT(t,n),reactProfiles:(t={})=>Zg(e,t),reactProfilesForFile:t=>ou(e,t),vueProfiles:(t={})=>Jg(e,t),vueProfileForFile:t=>iu(e,t),vueTemplateFacts:t=>$s(e,t),vueScriptFacts:t=>Vs(Ar(e,t))}}function QT(e,t){let n=e.startsWith("react-")?"react":"vue";if(t===void 0)return{slot:e,available:!0,framework:n};let r=t.replace(/\\/g,"/").toLowerCase();return n==="react"&&!r.endsWith(".tsx")&&!r.endsWith(".jsx")?{slot:e,available:!1,framework:n,reason:"React behavior profiles are only available for .tsx and .jsx files"}:n==="vue"&&!r.endsWith(".vue")?{slot:e,available:!1,framework:n,reason:"Vue behavior facts are only available for .vue files"}:{slot:e,available:!0,framework:n}}function ZT(e,t,n={}){let r=J(e,t);if(!r)return[];let i=[];if(n.includeCrossLanguageDispatchNames)for(let o of r.crossLanguageDispatchNames)i.push({name:o,kind:"cross-language-dispatch",occurrences:1});if(n.includeRustAttributeNames&&r.language==="rust")for(let o of r.rustAttrReferencedNames)i.push({name:o,kind:"rust-attribute",occurrences:1});return i}var eN=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]);function je(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let o=e[i];(o==="{"||o==="["||o==="(")&&n++,(o==="}"||o==="]"||o===")")&&n--,o===","&&n===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function ze(e,t){for(let n of e.namedChildren)if(n.type===t)return n;return null}function le(e,t){let n=new Set,r=(i,o)=>{let s=o||t.has(i.type);!s&&eN.has(i.type)&&n.add(i.text);for(let a of i.children)r(a,s)};return r(e.rootNode,!1),n}function xt(e,t,n,r,i,o,s){return{importedName:i,localName:o,sourcePath:s??ce(e,r,Ll(t)),kind:"named",used:Me(n,o),usedMembers:[]}}function ne(e,t,n,r,i="named",o={}){return{importedName:e,localName:t,sourcePath:n,kind:i,used:r.has(t),usedMembers:[],isTypeOnly:o.isTypeOnly}}function Zt(e,t,n,r,i="named",o=[],s={}){return{importedName:e,localName:t,sourcePath:n,kind:i,used:r,usedMembers:o,isTypeOnly:s.isTypeOnly}}function er(e,t){return{importedName:e,localName:null,sourcePath:t,kind:"side-effect",used:!0,usedMembers:[]}}function tr(e,t,n={}){return{importedName:e,localName:n.localName??null,sourcePath:t,kind:"namespace",used:n.used??!0,usedMembers:n.usedMembers??[],isTypeOnly:n.isTypeOnly}}function at(e,t,n){let r=[];for(let i of e.matchAll(t)){let o=i[0];if(!o||typeof i.index!="number")continue;let s=vn(e,i.index,i.index+o.length);for(let a of n(i,s))r.push(a)}return r}function ct(e,t,n,r,i){let o=Or(e,t,i);if(o){let s=n(o);if(s)return s}return r()}function Us(e,t,n,r,i){let o=Or(e,t,i),s=B(t),a=s?n[s]:void 0;return o&&a?a(o):r()}function ay(e,t,n){return ct(e,t,r=>nN(e,t,r),()=>tN(e,t,n),n)}function tN(e,t,n){return at(n,/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm,(r,i)=>{let o=r[1]?.trim();if(!o)return[];let s=sy(o).replace(/\.[^.]+$/,"");return[Zt(o,s,Ts(e,t,o),Me(i,s))]})}function nN(e,t,n){let r=le(n,new Set(["preproc_include"])),i=[];for(let o of n.rootNode.descendantsOfType("preproc_include")){let s=null;for(let c of o.namedChildren){if(c.type==="system_lib_string"){s=c.text.replace(/^<|>$/g,"");break}if(c.type==="string_literal"){s=c.namedChildren.find(u=>u.type==="string_content")?.text??c.text.replace(/^"|"$/g,"");break}}if(!s)continue;let a=sy(s).replace(/\.[^.]+$/,"");i.push(ne(s,a,Ts(e,t,s),r))}return i}var rN=new Set([":require",":require-macros",":use"]),lu=String.raw`A-Za-z0-9_$*+!?.<>=-`;function ly(e,t,n){let r=hN(n);if(!r)return[];let i=yN(n,r.start,r.end),o=[];for(let s of r.children.slice(2)){if(s.type!=="list"||s.children.length===0)continue;let a=lt(s.children[0]);if(a)for(let c of iN(e,s,a,i))o.push(c)}return o}function iN(e,t,n,r){let i=[];if(rN.has(n)){for(let o of aN(t.children.slice(1)))i.push(...sN(e,o,r));return i}if(n===":import")for(let o of dN(t.children.slice(1)))i.push(o);return i}function oN(e){return e.type==="list"&<(e.children[0])==="ns"}function sN(e,t,n){let r=_l(e,t.namespace),i=t.alias??t.namespace,o=fN(n,i),s=[{importedName:t.namespace,localName:i,sourcePath:r,kind:"namespace",used:t.refers.length>0||t.referAll||o.length>0||mN(n,t.namespace),usedMembers:o}];t.referAll&&s.push({importedName:"*",localName:null,sourcePath:r,kind:"side-effect",used:!0,usedMembers:[]});for(let a of t.refers)s.push({importedName:a,localName:a,sourcePath:r,kind:"named",used:gN(n,a),usedMembers:[]});return s}function aN(e){return e.flatMap(t=>qs(t,null))}function qs(e,t){return e.type==="atom"?e.text.startsWith(":")?[]:[{namespace:uu(t,e.text),alias:null,refers:[],referAll:!1}]:e.type==="vector"?e.children.length>0&<(e.children[0])===null?e.children.flatMap(n=>qs(n,t)):uN(e,t):e.type==="list"?cN(e,t):[]}function cN(e,t){if(e.children.length===0)return[];let n=lt(e.children[0]);return n?n.startsWith(":")?[]:e.children.slice(1).flatMap(r=>qs(r,uu(t,n))):e.children.flatMap(r=>qs(r,t))}function lN(e,t){lt(t)===":all"?e.referAll=!0:(t.type==="vector"||t.type==="list")&&e.refers.push(...t.children.map(lt).filter(pN))}function uN(e,t){let n=lt(e.children[0]);if(!n||n.startsWith(":"))return[];let r={namespace:uu(t,n),alias:null,refers:[],referAll:!1};for(let i=1;i<e.children.length;i+=1){let o=lt(e.children[i]);if(!o?.startsWith(":"))continue;let s=e.children[i+1];if((o===":as"||o===":as-alias")&&s){r.alias=lt(s),i+=1;continue}o===":refer"&&s&&(lN(r,s),i+=1)}return[r]}function dN(e){let t=[];for(let n of e){if(n.type==="atom"){let i=n.text.split(".").pop()??n.text;t.push(Zt(i,i,null,!0));continue}if(n.type!=="vector")continue;let r=lt(n.children[0]);if(r)for(let i of n.children.slice(1)){let o=lt(i);o&&t.push(Zt(`${r}.${o}`,o,null,!0))}}return t}function uu(e,t){return e?`${e}.${t}`:t}function lt(e){return e?.type==="atom"?e.text:null}function pN(e){return!!(e&&!e.startsWith(":"))}function fN(e,t){let n=new Set,r=new RegExp(`${du()}${Ce(t)}\\s*/\\s*([${lu}]+)`,"g");for(let i of e.matchAll(r)){let o=i[1];o&&n.add(o)}return[...n]}function mN(e,t){return new RegExp(`${du()}${Ce(t)}\\s*/`,"m").test(e)}function gN(e,t){return new RegExp(`${du()}${Ce(t)}(?![${lu}])`,"m").test(e)}function du(){return`(?<![${lu}])`}function yN(e,t,n){let r="",i=0;for(;i<e.length;){if(i>=t&&i<n){r+=e[i]===`
|
|
116
|
+
`?`
|
|
117
|
+
`:" ",i+=1;continue}let o=e[i];if(o===";"){let s=Os(e,i);r+=cy(e.slice(i,s)),i=s;continue}if(o==='"'){let s=Bi(e,i,0).index;r+=cy(e.slice(i,s)),i=s;continue}r+=o,i+=1}return r}function hN(e){let t=0;for(;t<e.length&&(t=pu(e,t),!(t>=e.length));){let n=Hs(e,t);if(!n){t+=1;continue}if(oN(n.form))return n.form;t=n.index}return null}function Hs(e,t){let n=pu(e,t);if(e.startsWith("#?@",n)||e.startsWith("#?",n))return bN(e,n);if(e.startsWith("#_",n)){let r=Hs(e,n+2);return r?{form:{type:"atom",text:"",start:n,end:r.index},index:r.index}:null}for(;Yl(e[n]);)n+=1;return SN(e,n)}function SN(e,t){let n=e[t];return n?n==="("?cu(e,t,"list",")"):n==="["?cu(e,t,"vector","]"):n==="{"?cu(e,t,"map","}"):n==='"'?{form:{type:"atom",text:"",start:t,end:Bi(e,t,0).index},index:Bi(e,t,0).index}:vN(e,t):null}function bN(e,t){let n=e.startsWith("#?@",t)?3:2,r=Hs(e,t+n);return r?{form:{type:"list",children:r.form.type==="list"||r.form.type==="vector"||r.form.type==="map"?xN(r.form.children):[],start:t,end:r.index},index:r.index}:null}function xN(e){let t=[];for(let n=0;n<e.length;n+=2){let r=lt(e[n]),i=e[n+1];r?.startsWith(":")&&i&&t.push(i)}return t}function cu(e,t,n,r){let i=[],o=t+1;for(;o<e.length;){if(o=pu(e,o),e[o]===r)return{form:{type:n,children:i,start:t,end:o+1},index:o+1};let s=Hs(e,o);if(!s){o+=1;continue}s.form.type==="atom"&&s.form.text===""||i.push(s.form),o=s.index}return{form:{type:n,children:i,start:t,end:e.length},index:e.length}}function vN(e,t){let n=t;for(;n<e.length&&!Xl(e[n]);)n+=1;return{form:{type:"atom",text:e.slice(t,n),start:t,end:n},index:n}}function pu(e,t){let n=t;for(;n<e.length;){let r=e[n];if(/\s|,/.test(r)){n+=1;continue}if(r===";"){n=Os(e,n);continue}break}return n}function cy(e){return e.replace(/[^\r\n]/g," ")}function uy(e,t,n){let r=[];for(let i of n.matchAll(/^[ \t]*import\s+['"]([^'"]+)['"](?:\s+as\s+([A-Za-z_]\w*))?[\s\S]*?;$/gm)){let o=i[1]?.trim(),s=i[2]?.trim()??null,a=i[0];if(!o||!a||typeof i.index!="number")continue;let c=vn(n,i.index,i.index+a.length);r.push({importedName:o,localName:s,sourcePath:Ns(e,t,o),kind:s?"namespace":"side-effect",used:s?Me(c,s):!0,usedMembers:s?_r(c,s):[]})}return r}function dy(e,t,n){let r=[];for(let i of n.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=i[1]?.trim();o&&r.push({specifier:o,sourcePath:Ns(e,t,o)})}return r}function py(e,t,n){return Us(e,t,{csharp:r=>IN(e,t,r),vb:r=>RN(e,t,r)},()=>{let r=ng(t)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;return at(n,r,(i,o)=>{let s=i[1]?.trim();if(!s)return[];let[a,c]=s.split(/\s*=\s*/),l=!!c,u=(l?c:a)?.trim()??s,d=u.split(".").pop()??u,p=l?a?.trim()??d:d;return[xt(e,t,o,u,d,p,ce(e,u,Sn))]})},n)}function RN(e,t,n){let r=le(n,new Set(["imports_statement"])),i=[];for(let o of n.rootNode.descendantsOfType("imports_statement")){let s=o.namedChildren.filter(p=>p.type==="namespace_name");if(s.length===0)continue;let a=s[s.length-1],c=s.length>1?s[0]:null,l=a.text,u=l.split(".").pop()??l,d=c?.text??u;i.push(ne(u,d,ce(e,l,Sn),r,c?"namespace":"named"))}return i}function IN(e,t,n){let r=le(n,new Set(["using_directive"])),i=[];for(let o of n.rootNode.descendantsOfType("using_directive")){let s=o.namedChildren;if(s.length===0)continue;let a=null,c;s.length>=2&&s[0].type==="identifier"&&(s[1].type==="qualified_name"||s[1].type==="identifier")?(a=s[0],c=s[1]):c=s[s.length-1];let l=c.text,u=l.split(".").pop()??l,d=a?.text??u;i.push(ne(u,d,ce(e,l,Sn),r,a?"namespace":"named"))}return i}var CN=ie("vue-non-script-identifiers",{clearGroups:["whole-project","source-file"]});function fy(e,t){return CN.get(e,t,()=>{let n=new Set,r=L(e,t);if(!r)return n;let o=r.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g,s=>s.replace(/[^\r\n]/g," ")).replace(/<!--[\s\S]*?-->/g,s=>s.replace(/[^\r\n]/g," ")).replace(/\/\*[\s\S]*?\*\//g,s=>s.replace(/[^\r\n]/g," "));for(let s of o.matchAll(/[A-Za-z_$][\w$]*/g))n.add(s[0]);return n})}function fu(e,t,n){return ct(e,t,r=>PN(e,t,r),()=>EN(e,t,n),n)}function EN(e,t,n){return MN(n).flatMap(r=>jN(e,t,r.clause,r.specifier,r.start,r.end,n))}function PN(e,t,n){let r=wN(e,t,n),i=[];for(let o of n.rootNode.descendantsOfType("import_statement"))i.push(...FN(e,t,n,o,r));return i}function wN(e,t,n){let r=le(n,new Set(["import_statement"]));if(it(t))for(let i of fy(e,t))r.add(i);return r}function FN(e,t,n,r,i){let o=DN(r);if(!o)return[];let s=Oe(e,t,o),a=ze(r,"import_clause");return a?TN(n,a,s,i,kN(r.text)):[er("*",s)]}function TN(e,t,n,r,i){let o=[];for(let s of t.namedChildren)if(s.type==="identifier")o.push(NN(s.text,n,r,i));else if(s.type==="namespace_import"){let a=LN(e,s,n,r,i);a&&o.push(a)}else s.type==="named_imports"&&o.push(..._N(s,n,r,i));return o}function NN(e,t,n,r){return ne("default",e,t,n,"default",{isTypeOnly:r})}function LN(e,t,n,r,i){let s=ze(t,"identifier")?.text??"";if(!s)return null;let a=ON(e,s);return tr("*",n,{localName:s,usedMembers:a,isTypeOnly:i,used:a.length>0||r.has(s)})}function _N(e,t,n,r){let i=[];for(let o of e.namedChildren){if(o.type!=="import_specifier")continue;let s=o.namedChild(0),a=o.namedChild(1);if(!s)continue;let c=s.text,l=a?.text??c;i.push(ne(c,l,t,n,"named",{isTypeOnly:r||AN(o.text)}))}return i}function DN(e){let t=ze(e,"string");if(!t)return null;let n=ze(t,"string_fragment");return n?n.text:null}function kN(e){return/^\s*import\s+type\b/.test(e)}function AN(e){return/^\s*type\b/.test(e.trim())}function ON(e,t){let n=new Set;for(let r of e.rootNode.descendantsOfType("member_expression")){let i=r.namedChild(0),o=r.namedChild(1);!i||!o||i.type!=="identifier"||i.text!==t||(o.type==="property_identifier"||o.type==="identifier")&&n.add(o.text)}return[...n]}function MN(e){let t=[],n=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(n)){let o=i[0],s=i[1],a=i[2];!o||!a||typeof i.index!="number"||t.push({clause:s,specifier:a,start:i.index,end:i.index+o.length})}let r=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(r)){let o=i[0],s=i[1];!o||!s||typeof i.index!="number"||t.push({clause:null,specifier:s,start:i.index,end:i.index+o.length})}return t.sort((i,o)=>i.start-o.start)}function jN(e,t,n,r,i,o,s){let a=Oe(e,t,r),c=vn(s,i,o);return n?BN(n).map(u=>({...u,sourcePath:a})).map(u=>{if(u.kind==="namespace"){let d=_r(c,u.localName);return tr(u.importedName,u.sourcePath,{localName:u.localName,usedMembers:d,used:d.length>0||Me(c,u.localName),isTypeOnly:u.isTypeOnly})}return u.kind==="side-effect"?er(u.importedName,u.sourcePath):Zt(u.importedName,u.localName??"",u.sourcePath,u.localName?Me(c,u.localName):!1,u.kind,[],{isTypeOnly:u.isTypeOnly})}):[er("*",a)]}function BN(e){let t=e.trim(),n=/^type\b/.test(t),r=t.replace(/^type\s+/,""),[i,o]=$N(r),s=[];return i&&s.push(...my(i,n)),o&&s.push(...my(o,n)),s}function my(e,t){let n=e.trim();if(!n)return[];if(n.startsWith("{")){let r=n.slice(1,-1).trim();return r?je(r).map(i=>{let o=i.trim(),s=t||/^type\b/.test(o),a=o.replace(/^type\s+/,""),[c,l]=a.split(/\s+as\s+/);return{importedName:c.trim(),localName:(l??c).trim(),kind:"named",isTypeOnly:s}}):[]}return n.startsWith("* as ")?[{importedName:"*",localName:n.slice(5).trim(),kind:"namespace",isTypeOnly:t}]:[{importedName:"default",localName:n,kind:"default",isTypeOnly:t}]}function $N(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r==="{"&&t++,r==="}"&&t--,r===","&&t===0)return[e.slice(0,n).trim(),e.slice(n+1).trim()]}return[e.trim(),null]}function mu(e,t,n){let r=D(e,t);return r?HN(e,t,r):GN(e,t,n)}function GN(e,t,n){return[...VN(e,t,n),...WN(e,t,n),...UN(e,t,n)]}function VN(e,t,n){let r=[],i=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of n.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=o[2]??"",c=je(s).map(d=>qN(d.trim())).filter(d=>!!d),l=Wr(n,o.index),u=Wr(n,o.index+o[0].length-1);r.push({kind:"named",sourcePath:Oe(e,t,a),names:c,startLine:l,endLine:u})}return r}function WN(e,t,n){let r=[],i=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of n.matchAll(i)){if(typeof o.index!="number")continue;let s=o[2]??"",a=Wr(n,o.index),c=Wr(n,o.index+o[0].length-1);r.push({kind:"star-as",sourcePath:Oe(e,t,s),names:o[1]?[o[1]]:[],startLine:a,endLine:c})}return r}function UN(e,t,n){let r=[],i=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of n.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=Wr(n,o.index),c=Wr(n,o.index+o[0].length-1);r.push({kind:"star",sourcePath:Oe(e,t,s),names:[],startLine:a,endLine:c})}return r}function qN(e){if(!e)return null;let t=e.replace(/^type\s+/,"").trim();if(!t)return null;let n=t.match(/^(\w+)\s+as\s+(\w+)$/);if(n)return n[2]??null;let r=t.match(/^(\w+)$/);return r?r[1]??null:null}function Wr(e,t){let n=0;for(let r=0;r<t&&r<e.length;r++)e.charCodeAt(r)===10&&n++;return n}function HN(e,t,n){let r=[];for(let i of n.rootNode.descendantsOfType("export_statement")){let o=zN(e,t,i);if(o===void 0)continue;let s=i.startPosition.row,a=i.endPosition.row,c=KN(i,o,s,a);r.push(c)}return r}function zN(e,t,n){let r=ze(n,"string");if(!r)return;let i=ze(r,"string_fragment");if(i)return Oe(e,t,i.text)}function KN(e,t,n,r){let i=ze(e,"export_clause");if(i){let s=[];for(let a of i.namedChildren){if(a.type!=="export_specifier")continue;let c=a.namedChild(0),l=a.namedChild(1);c&&s.push((l??c).text)}return{kind:"named",sourcePath:t,names:s,startLine:n,endLine:r}}let o=ze(e,"namespace_export");if(o){let s=o.namedChildren.find(a=>a.type==="identifier"||a.type==="type_identifier")?.text;return{kind:"star-as",sourcePath:t,names:s?[s]:[],startLine:n,endLine:r}}return{kind:"star",sourcePath:t,names:[],startLine:n,endLine:r}}function gy(e,t,n){return Us(e,t,{java:r=>JN(e,t,r),kotlin:r=>YN(e,t,r),scala:r=>XN(e,t,r)},()=>at(n,/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm,(r,i)=>{let o=r[1]?.trim();return o?eL(e,t,o,i):[]}),n)}function JN(e,t,n){let r=le(n,new Set(["import_declaration"])),i=[];for(let o of n.rootNode.descendantsOfType("import_declaration")){let s=o.children.some(d=>d.type==="asterisk"),c=o.namedChildren.find(d=>d.type==="scoped_identifier")??o.namedChildren.find(d=>d.type==="identifier");if(!c)continue;let l=c.text;if(s){i.push(tr("*",ce(e,l,He)));continue}let u=l.split(".").pop()??l;i.push(ne(u,u,ce(e,l,He),r))}return i}function YN(e,t,n){let r=le(n,new Set(["import_header","import_list"])),i=[];for(let o of n.rootNode.descendantsOfType("import_header")){let s=o.namedChildren.find(f=>f.type==="identifier");if(!s)continue;let a=o.namedChildren.some(f=>f.type==="wildcard_import"),c=o.namedChildren.find(f=>f.type==="import_alias");if(a){i.push(tr("*",ce(e,s.text,He)));continue}let l=s.text,u=l.split(".").pop()??l,p=c?.namedChild(0)?.text??u;i.push(ne(u,p,ce(e,l,He),r))}return i}function XN(e,t,n){let r=le(n,new Set(["import_declaration"])),i=[];for(let o of n.rootNode.descendantsOfType("import_declaration")){let s=o.namedChildren.find(l=>l.type==="namespace_selectors"||l.type==="namespace_wildcard"),a=o.namedChildren.filter(l=>l!==s&&(l.type==="identifier"||l.type==="stable_identifier")),c=a.map(l=>l.text).join(".");if(c){if(s?.type==="namespace_wildcard"){i.push(tr("*",ce(e,c,He)));continue}if(s?.type==="namespace_selectors"){for(let l of s.namedChildren){let u=ZN(e,c,l,r);u&&i.push(u)}continue}i.push(QN(e,c,a,r))}}return i}function QN(e,t,n,r){let i=n[n.length-1]?.text??t,o=n.slice(0,-1).map(s=>s.text).join(".")||t;return ne(i,i,ce(e,o&&n.length>1?`${o}.${i}`:t,He),r)}function ZN(e,t,n,r){if(n.type==="arrow_renamed_identifier"){let[o,s]=n.namedChildren;if(!o)return null;let a=o.text,c=s?.text??a;return a==="_"?null:ne(a,c,ce(e,`${t}.${a}`,He),r)}if(n.type!=="identifier")return null;let i=n.text;return ne(i,i,ce(e,`${t}.${i}`,He),r)}function eL(e,t,n,r){if(n.includes("{")&&n.includes("}")){let i=n.slice(0,n.indexOf("{")).replace(/\.$/,"").trim(),o=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim();return je(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.includes("=>")?a.split(/\s*=>\s*/):a.split(/\s+as\s+/),u=c?.trim();if(!u||u==="_")return[];let d=(l??u.split(".").pop()??u).trim(),p=u==="_"?i:`${i}.${u}`.replace(/\.\./g,".");return[xt(e,t,r,p,u,d)]})}return[xt(e,t,r,n,n.split(".").pop()??n,n.split(".").pop()??n)]}function hy(e,t,n){return ct(e,t,r=>tL(e,t,r),()=>at(n,/^[ \t]*use\s+(.+?)\s*;$/gm,(r,i)=>{let o=r[1]?.trim();return o?je(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.split(/\s+as\s+/i),u=c?.trim()??a,d=u.split("\\").pop()??u,p=(l??d).trim();return[xt(e,t,i,u,d,p,ce(e,u.replace(/\\/g,"."),Xn))]}):[]}),n)}function tL(e,t,n){let r=le(n,new Set(["namespace_use_declaration"])),i=[],o=(s,a,c)=>{i.push(ne(a,c,ce(e,s.replace(/\\/g,"."),Xn),r))};for(let s of n.rootNode.descendantsOfType("namespace_use_declaration")){let a=s.namedChildren.find(c=>c.type==="namespace_use_group");if(a){let c=s.namedChildren.find(l=>l.type==="namespace_name")?.text??"";yy(a.namedChildren,c,o);continue}yy(s.namedChildren,"",o)}return i}function yy(e,t,n){for(let r of e){if(r.type!=="namespace_use_clause")continue;let{importedName:i,localName:o,qualified:s}=nL(r,t);i&&n(s,i,o)}}function nL(e,t){let n=e.namedChildren.find(l=>l.type==="qualified_name"),r=e.namedChildren.filter(l=>l.type==="name"),i="";n?i=n.text:r.length>=1&&(i=r[0].text);let o=n&&r.length>0?r[r.length-1]:null,s=i.split("\\").pop()??i,a=o?.text??s,c=t?`${t}\\${i}`:i;return{importedName:s,localName:a,qualified:c}}function Sy(e,t,n){return ct(e,t,r=>rL(e,t,r),()=>sL(n).flatMap(r=>cL(e,t,r,n)),n)}function rL(e,t,n){let r=le(n,new Set(["import_statement","import_from_statement"])),i=[];for(let o of n.rootNode.descendantsOfType("import_statement"))for(let s of o.namedChildren){let a=by(s);if(!a)continue;let c=Lr(e,t,a.qualifiedName);i.push({importedName:a.qualifiedName,localName:a.localName,sourcePath:c,kind:"namespace",used:r.has(a.localName),usedMembers:[]})}for(let o of n.rootNode.descendantsOfType("import_from_statement")){let s=o.namedChild(0);if(!s)continue;let a=oL(s);if(a===null)continue;let c=Lr(e,t,a);iL(o,c,r,i)}return i}function iL(e,t,n,r){for(let i=1;i<e.namedChildCount;i+=1){let o=e.namedChild(i);if(o.type==="wildcard_import"){r.push({importedName:"*",localName:null,sourcePath:t,kind:"side-effect",used:!0,usedMembers:[]});continue}let s=by(o);s&&r.push({importedName:s.qualifiedName,localName:s.localName,sourcePath:t,kind:"named",used:n.has(s.localName),usedMembers:[]})}}function by(e){if(e.type==="aliased_import"){let t=e.namedChild(0),n=e.namedChild(1);return!t||!n?null:{qualifiedName:t.text,localName:n.text}}if(e.type==="dotted_name"){let t=e.text;return{qualifiedName:t,localName:t.split(".")[0]??t}}return e.type==="identifier"?{qualifiedName:e.text,localName:e.text}:null}function oL(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let t=ze(e,"import_prefix")?.text??"",n=ze(e,"dotted_name")?.text??"";return`${t}${n}`}return null}function sL(e){let t=e.split(`
|
|
118
|
+
`),n=[],r=0;for(let i=0;i<t.length;i++){let o=t[i],s=o.trimStart(),a=r;if(r+=o.length+1,!s.startsWith("import ")&&!s.startsWith("from "))continue;let c=o,l=a+o.length,u=Ml(o);for(;i+1<t.length&&(u>0||c.trimEnd().endsWith("\\"));){i++;let p=t[i];c+=`
|
|
119
|
+
${p}`,l+=1+p.length,u+=Ml(p),r+=p.length+1}let d=aL(c);d&&n.push({...d,start:a,end:l})}return n}function aL(e){let t=e.replace(/\\\s*\n/g," ").trim();if(t.startsWith("import "))return{kind:"import",module:null,clause:t.slice(7).trim()};let n=t.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!n)return null;let r=n[2].trim();return r.startsWith("(")&&r.endsWith(")")&&(r=r.slice(1,-1).trim()),{kind:"from",module:n[1],clause:r}}function cL(e,t,n,r){let i=vn(r,n.start,n.end),o=n.clause.replace(/\n/g," ").trim();if(n.kind==="import")return je(o).flatMap(c=>{let l=c.trim().replace(/,$/,"");if(!l)return[];let[u,d]=l.split(/\s+as\s+/),p=u.trim(),f=(d??p.split(".")[0]??p).trim(),h=Lr(e,t,p),b=_r(i,f);return[{importedName:p,localName:f,sourcePath:h,kind:"namespace",used:Me(i,f)||b.length>0,usedMembers:b}]});let s=n.module?Lr(e,t,n.module):null,a=[];for(let c of je(o)){let l=c.trim().replace(/,$/,"");if(!l)continue;if(l==="*"){a.push({importedName:"*",localName:null,sourcePath:s,kind:"side-effect",used:!0,usedMembers:[]});continue}let[u,d]=l.split(/\s+as\s+/),p=(d??u).trim();a.push({importedName:u.trim(),localName:p,sourcePath:s,kind:"named",used:Me(i,p),usedMembers:[]})}return a}import{basename as lL}from"path";function xy(e,t,n){return ct(e,t,r=>dL(e,t,r),()=>uL(e,t,n),n)}function uL(e,t,n){return at(n,/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm,(r,i)=>{let o=r[1],s=r[2];if(!o||!s)return[];let a=o==="require_relative"?Fs(e,t,s):null;if(a){let c=vy(s);return[Zt(c,c,a,Me(i,c))]}return[er(s,a)]})}function dL(e,t,n){let r=le(n,new Set([])),i=[],o=new Set(["require","require_relative","load"]);for(let s of n.rootNode.descendantsOfType("call")){let a=s.namedChild(0);if(!a||a.type!=="identifier"||!o.has(a.text))continue;let c=pL(s);if(!c)continue;let l=a.text==="require_relative"?Fs(e,t,c):null;if(l){let u=vy(c);i.push(ne(u,u,l,r))}else i.push(er(c,l))}return i}function pL(e){let n=e.namedChildren.find(r=>r.type==="argument_list")?.namedChild(0);if(!(!n||n.type!=="string"))return n.namedChildren.find(r=>r.type==="string_content")?.text}function vy(e){return Bs(lL(e).replace(/\.[^.]+$/,""),/_/)}function Ry(e,t,n){return ct(e,t,r=>fL(e,t,r),()=>at(n,/^[ \t]*use\s+(.+?)\s*;$/gm,(r,i)=>{let o=r[1]?.trim();return o?yL(e,t,o,i):[]}),n)}function fL(e,t,n){let r=le(n,new Set(["use_declaration"])),i=[];for(let o of n.rootNode.descendantsOfType("use_declaration")){let s=o.namedChild(0);if(s)for(let a of Wi(s,"")){if(!a.importedName||a.importedName==="*")continue;let c=Yt(e,t,a.qualifiedName)??Yt(e,t,a.qualifiedName.split("::").slice(0,-1).join("::"));i.push(ne(a.importedName,a.localName,c,r))}}return i}function Wi(e,t){let n=gL(e,t);if(n)return n;switch(e.type){case"scoped_use_list":return mL(e,t);case"use_list":{let r=[];for(let i of e.namedChildren)r.push(...Wi(i,t));return r}case"use_as_clause":{let r=e.namedChild(0),i=e.namedChild(1);if(!r||!i)return[];let o=Wi(r,t),s=i.text;return o.map(a=>({...a,localName:s}))}case"use_wildcard":{let r=e.namedChild(0),i=r?r.text:"";return[{qualifiedName:zs(t,`${i}::*`),importedName:"*",localName:"*"}]}default:return[]}}function mL(e,t){let n=e.namedChild(0),r=e.namedChild(1);if(!n||!r)return[];let i=zs(t,n.text),o=[];for(let s of r.namedChildren)o.push(...Wi(s,i));return o}function gL(e,t){switch(e.type){case"identifier":case"super":case"crate":{let n=e.text;return[{qualifiedName:zs(t,n),importedName:n,localName:n}]}case"self":{let n=t.split("::").filter(Boolean).pop()??"self";return[{qualifiedName:t||"self",importedName:n,localName:n}]}case"scoped_identifier":{let n=e.text,r=n.split("::").pop()??n;return[{qualifiedName:zs(t,n),importedName:r,localName:r}]}default:return null}}function zs(e,t){return e?t?`${e}::${t}`:e:t}function yL(e,t,n,r){let i=n.trim();if(i.includes("{")&&i.includes("}")){let u=i.slice(0,i.indexOf("{")).replace(/::$/,"").trim(),d=i.slice(i.indexOf("{")+1,i.lastIndexOf("}")).trim();return je(d).flatMap(p=>{let f=p.trim();if(!f)return[];if(f==="self"){let y=u.split("::").filter(Boolean).pop();return y?[xt(e,t,r,u,y,y)]:[]}let[h,b]=f.split(/\s+as\s+/),x=h?.trim();if(!x)return[];let m=(b??x.split("::").pop()??x).trim(),g=`${u}::${x}`.replace(/::::/g,"::");return[xt(e,t,r,g,x.split("::").pop()??x,m,Yt(e,t,u))]})}let[o,s]=i.split(/\s+as\s+/),a=o?.trim()??i,c=(s??a.split("::").pop()??a).trim(),l=Yt(e,t,a)??Yt(e,t,a.split("::").slice(0,-1).join("::"));return[xt(e,t,r,a,a.split("::").pop()??a,c,l)]}function Iy(e,t,n){let r=D(e,t);if(r)return hL(e,t,r);let i=[];for(let o of n.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let s=o[1]?.trim();s&&i.push(...bL(e,t,s))}return i}function hL(e,t,n){let r=[];for(let i of n.rootNode.descendantsOfType("use_declaration")){if(!SL(i))continue;let o=i.namedChildren.find(s=>s.type!=="visibility_modifier");if(o)for(let s of Wi(o,""))s.importedName&&r.push(gu(e,t,s.qualifiedName))}return r}function SL(e){for(let t of e.children)if(t.type==="visibility_modifier"&&t.text.startsWith("pub"))return!0;return!1}function bL(e,t,n){let r=n.trim();if(r.includes("{")&&r.includes("}")){let i=r.slice(0,r.indexOf("{")).replace(/::$/,"").trim(),o=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim();return je(o).flatMap(s=>{let a=s.trim();if(!a||a==="self")return[];let[c]=a.split(/\s+as\s+/),l=`${i}::${c?.trim()??a}`.replace(/::::/g,"::");return[gu(e,t,l)]})}return[gu(e,t,r)]}function gu(e,t,n){return{specifier:n,sourcePath:Yt(e,t,n)??Yt(e,t,n.split("::").slice(0,-1).join("::"))}}function Rn({language:e,extensions:t,imports:n,parseImports:r}){return{language:e,extensions:t,capabilities:{imports:n},parseImports:r}}function Cy(e,t){let n=t.toLowerCase();for(let r of e)for(let i of r.extensions)if(n.endsWith(i))return r;return null}var xL={language:"javascript",extensions:Yn,capabilities:{imports:"ast-with-regex-fallback",reExports:"ast-with-regex-fallback"},parseImports:fu,parseReExports:mu},vL=Rn({language:"python",extensions:Is,imports:"ast-with-regex-fallback",parseImports:Sy}),RL=Rn({language:"jvm",extensions:He,imports:"ast-dispatch-with-regex-fallback",parseImports:gy}),IL={language:"rust",extensions:Cs,capabilities:{imports:"ast-with-regex-fallback",exports:"ast-with-regex-fallback"},parseImports:Ry,parseExports:Iy},CL=Rn({language:"ruby",extensions:Es,imports:"ast-with-regex-fallback",parseImports:xy}),EL=Rn({language:"c/cpp",extensions:Ps,imports:"ast-with-regex-fallback",parseImports:ay}),PL=Rn({language:"dotnet",extensions:Sn,imports:"ast-dispatch-with-regex-fallback",parseImports:py}),wL={language:"dart",extensions:ws,capabilities:{imports:"regex-only",exports:"regex-only"},parseImports:uy,parseExports:dy},FL=Rn({language:"php",extensions:Xn,imports:"ast-with-regex-fallback",parseImports:hy}),TL=Rn({language:"clojure",extensions:Nr,imports:"regex-only",parseImports:ly}),Ey=[xL,vL,RL,IL,CL,EL,PL,wL,FL,TL];function Ui(e){return Cy(Ey,e)}function kJ(e){return Ey.find(n=>n.language===e)?.capabilities??null}var yu={clearGroups:["whole-project","source-file"]},NL=ie("source-imports",yu),LL=ie("source-exports",yu),_L=ie("source-reexports",yu),Py=ge({kind:"source-imports",invalidation:ee("source-imports"),serialize:DL,deserialize:kL}),wy=ge({kind:"source-reexports",invalidation:ee("source-reexports"),serialize:AL,deserialize:OL});function Lt(e,t){let n=ae(t);return _L.get(e,n,()=>{let r=Ui(n);if(!r?.parseReExports)return[];let i=L(e,n);if(!i)return[];let o=Se(e,n,i),s=Al(e),a=wy.read(e,n,o);if(a?.resolutionFingerprint===s)return a.reExports;let c=r.parseReExports(e,n,i);return wy.write(e,n,o,{resolutionFingerprint:s,reExports:c}),c})}function vt(e,t){let n=ae(t);return NL.get(e,n,()=>{let r=Ui(n);if(!r)return[];let i=L(e,n);return i?Fy(e,n,i,r):[]})}function Ks(e,t){let n=ae(t),r=Ui(n);if(!r)return[];let i;try{i=zn(e.config.projectRoot,n,{inputKind:"indexed source file"})}catch(o){if(bt(o))return[];throw o}return Fy(e,n,i,r)}function Fy(e,t,n,r){let i=Se(e,t,n),o=Al(e),s=Py.read(e,t,i);if(s?.resolutionFingerprint===o)return s.imports;let a=r.parseImports(e,t,n);return Py.write(e,t,i,{parserVersion:2,resolutionFingerprint:o,imports:a}),a}function Ty(e,t,n){let r=vt(e,t).filter(i=>i.kind==="named"&&i.isTypeOnly!==!0&&i.localName===n&&i.sourcePath!==null);return r.length===1?r[0]:null}function UJ(e,t){let n=ae(t);return LL.get(e,n,()=>{let r=Ui(n);if(!r?.parseExports)return[];let i=L(e,n);return i?r.parseExports(e,n,i):[]})}function DL(e){return JSON.stringify(e)}function kL(e){try{let t=JSON.parse(e);return!bn(t)||t.parserVersion!==2||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.imports)?null:{parserVersion:2,resolutionFingerprint:t.resolutionFingerprint,imports:t.imports}}catch{return null}}function AL(e){return JSON.stringify(e)}function OL(e){try{let t=JSON.parse(e);return!bn(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.reExports)?null:{resolutionFingerprint:t.resolutionFingerprint,reExports:t.reExports}}catch{return null}}var Js=Om({kind:"file-dependency-graph",invalidation:ee("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:UL}),ML=U("file-dep-graph",{clearGroups:["whole-project"]});function Ly(e,t,n){if(n.length===0)return[];let r=new Set(n),i=Ur(e),o=new Set;return t==="forward"?jL(i,r,o):BL(i,r,o),[...o].sort()}function jL(e,t,n){for(let r of t)for(let i of e.get(r)??[])t.has(i)||n.add(i)}function BL(e,t,n){for(let[r,i]of e)if(!t.has(r))for(let o of t)i.has(o)&&n.add(r)}function Ur(e,t,n={}){let r=n.scipEdges??"all-references",i=n.sourceEdges??"imports-and-reexports",o=Hi(t,r,i);return ML.get(e,o,()=>{let s=new Set(Re(e,{includeIgnored:!1})),a=qt(e),c=0,l=0,u=null,d=!1,p=0,f=0,h=null;return se("file-dep-graph.product",()=>{if(a){let g=Js.read(e,o,a);if(g){d=!0,h=g.construction;let y=Dy(g);return c=g.sourceFileCount,l=g.sourceEdgeCount,p=g.scipEdgeCount,f=y.size,u=g.sourceDependencyFingerprint,y}}let b=i==="none"?{files:[],edges:[],fingerprint:$("no-source-dependency-fallback")}:se("file-dep-graph.source-imports",()=>{let g=VL(e,s,t,i);return c=g.files.length,l=g.edges.length,u=g.fingerprint,g},()=>({scope:t??null,sourceEdges:i,files:c,edges:l})),x=new Map,m=(g,y)=>qi(e,x,s,g,y);se("file-dep-graph.scip-edges",()=>{for(let g of JL(e,t,r))p=(p??0)+1,m(g.from_file,g.to_file)},()=>({scope:t??null,edges:p}));for(let g of b.edges)m(g.fromFile,g.toFile);return f=x.size,a&&(h="full",Js.write(e,o,a,{version:2,construction:"full",sourceDependencyFingerprint:b.fingerprint,sourceFileCount:b.files.length,sourceEdgeCount:b.edges.length,scipEdgeCount:p,edgeCount:ky(x),graph:_y(x)})),x},()=>({scope:t??null,available:a!==null,hit:d,construction:h,files:c,sourceEdges:l,sourceEdgeMode:i,scipEdges:p,graphFiles:f,sourceDependencyFingerprint:u}))})}function ZJ(e){return $L(e,"none")}function eY(e,t="imports-and-reexports"){let n=Hi(void 0,"all-references",t),r=qt(e);if(!r)return null;let i=Js.read(e,n,r);return i?{cacheKey:n,sourceEdges:t,graph:Dy(i)}:null}function $L(e,t){let n=Hi(void 0,"all-references",t),r=Ur(e,void 0,{sourceEdges:t});return{cacheKey:n,sourceEdges:t,graph:r}}function tY(e,t,n,r){let i=t.sourceEdges??"imports-only",o=qt(e);if(!o)return!1;let s=r??GL(e,t,n);if(!s)return!1;let a=new Set(Re(e,{includeIgnored:!1})),c=Hi(void 0,"all-references",i);return Js.write(e,c,o,{version:2,construction:"carried",sourceDependencyFingerprint:null,sourceFileCount:a.size,sourceEdgeCount:null,scipEdgeCount:null,edgeCount:ky(s),graph:_y(s)}),!0}function GL(e,t,n,r=[]){let i=t.sourceEdges??"imports-only",o=Hi(void 0,"all-references",i);if(t.cacheKey!==o)return null;let s=se("file-dep-graph.carry.indexed-files",()=>new Set(Re(e,{includeIgnored:!1}))),a=new Set(n),c=new Map;se("file-dep-graph.carry.reuse",()=>{if(r.length===0)for(let[u,d]of t.graph)a.has(u)||c.set(u,d);else QL(e,c,s,t.graph,a)});let l=se("file-dep-graph.carry.scip-edges",()=>YL(e,a,"all-references"));for(let u of l)qi(e,c,s,u.from_file,u.to_file);return se("file-dep-graph.carry.source-edges",()=>{for(let u of a)s.has(u)&&XL(e,c,s,u,i)}),c}async function nY(e,t={}){let n=Re(e,{includeIgnored:!1}),r=Math.max(1,Math.floor(t.batchSize??64)),i=t.collectGarbage??gn,o=0;for(let s=0;s<n.length;s+=r){for(let a of n.slice(s,s+r))Ks(e,a),Lt(e,a),o+=1;t.onBatch?.({files:o,total:n.length}),i(),await t.yieldToEventLoop?.()}return{files:o}}function VL(e,t,n,r){let i=[],o=[];for(let s of t)n&&!s.includes(n)||(i.push(s),ZL(e,s,r,o));return{files:i,edges:o,fingerprint:WL(i,o)}}function WL(e,t){let n=t.map(r=>`${r.fromFile}\0${r.toFile}`).sort();return $(JSON.stringify({files:e,edges:n}))}function Hi(e,t,n){return`edge-mode-v4:${t}:${n}:${e??"<all>"}`}function _y(e){return[...e].map(([t,n])=>[t,[...n].sort()]).sort(([t],[n])=>t.localeCompare(n))}function Dy(e){return new Map(e.graph.map(([t,n])=>[t,new Set(n)]))}function UL(e){let t=JSON.parse(e);return qL(t)?t:null}function qL(e){return HL(e)?Array.isArray(e.graph)&&e.graph.every(KL):!1}function HL(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===2&&(t.construction==="full"||t.construction==="carried")&&zL(t.sourceDependencyFingerprint)&&typeof t.sourceFileCount=="number"&&Ny(t.sourceEdgeCount)&&Ny(t.scipEdgeCount)&&typeof t.edgeCount=="number"}function zL(e){return e===null||typeof e=="string"}function Ny(e){return e===null||typeof e=="number"}function ky(e){let t=0;for(let n of e.values())t+=n.size;return t}function KL(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&Array.isArray(e[1])&&e[1].every(t=>typeof t=="string")}function JL(e,t,n){let r=t?"AND d1.relative_path LIKE ?":"",i=t?[`%${t}%`]:[],o=n==="imports-only"?"AND m.role = 2":"AND m.role != 1";return e.all(`SELECT DISTINCT
|
|
120
|
+
d1.relative_path AS from_file,
|
|
121
|
+
d2.relative_path AS to_file
|
|
122
|
+
FROM mentions m
|
|
123
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
124
|
+
JOIN documents d1 ON c.document_id = d1.id
|
|
125
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
126
|
+
JOIN (
|
|
127
|
+
SELECT m2.symbol_id, c2.document_id
|
|
128
|
+
FROM mentions m2
|
|
129
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
130
|
+
WHERE m2.role = 1
|
|
131
|
+
GROUP BY m2.symbol_id
|
|
132
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
133
|
+
JOIN documents d2 ON sym_def.document_id = d2.id
|
|
134
|
+
WHERE d1.id != d2.id
|
|
135
|
+
${o}
|
|
136
|
+
${e.pathExclusionsFor("d1","d2")}
|
|
137
|
+
${r}`,...i)}function YL(e,t,n){let r=[...t].sort();if(r.length===0)return[];let i=n==="imports-only"?"AND m.role = 2":"AND m.role != 1",o=[];for(let s=0;s<r.length;s+=500){let a=r.slice(s,s+500),c=a.map(()=>"?").join(", ");o.push(...e.all(`SELECT DISTINCT
|
|
138
|
+
d1.relative_path AS from_file,
|
|
139
|
+
d2.relative_path AS to_file
|
|
140
|
+
FROM documents d1
|
|
141
|
+
CROSS JOIN chunks c
|
|
142
|
+
CROSS JOIN mentions m
|
|
143
|
+
CROSS JOIN global_symbols gs
|
|
144
|
+
CROSS JOIN chunks c2
|
|
145
|
+
CROSS JOIN documents d2
|
|
146
|
+
WHERE d1.relative_path IN (${c})
|
|
147
|
+
AND c.document_id = d1.id
|
|
148
|
+
AND m.chunk_id = c.id
|
|
149
|
+
AND gs.id = m.symbol_id
|
|
150
|
+
AND c2.id = (
|
|
151
|
+
SELECT m2.chunk_id
|
|
152
|
+
FROM mentions m2
|
|
153
|
+
WHERE m2.symbol_id = gs.id AND m2.role = 1
|
|
154
|
+
ORDER BY m2.chunk_id
|
|
155
|
+
LIMIT 1
|
|
156
|
+
)
|
|
157
|
+
AND d2.id = c2.document_id
|
|
158
|
+
AND d1.id != d2.id
|
|
159
|
+
${i}
|
|
160
|
+
${e.pathExclusionsFor("d1","d2")}`,...a))}return o}function qi(e,t,n,r,i){if(r===i||e.isIgnored(r)||e.isIgnored(i)||!n.has(i))return;let o=t.get(r);o||(o=new Set,t.set(r,o)),o.add(i)}function XL(e,t,n,r,i){if(i!=="none")for(let o of Ks(e,r))o.sourcePath&&qi(e,t,n,r,o.sourcePath);if(i==="imports-and-reexports")for(let o of Lt(e,r))o.sourcePath&&qi(e,t,n,r,o.sourcePath)}function QL(e,t,n,r,i){for(let[o,s]of r)if(!(i.has(o)||!n.has(o)))for(let a of s)qi(e,t,n,o,a)}function ZL(e,t,n,r){for(let i of Ks(e,t))i.sourcePath&&r.push({fromFile:t,toFile:i.sourcePath});if(n==="imports-and-reexports")for(let i of Lt(e,t))i.sourcePath&&r.push({fromFile:t,toFile:i.sourcePath})}var e_={"/":"namespace","#":"type",".":"term","[":"type-param",":":"meta","!":"macro"};function Ke(e){if(e.startsWith("local "))return{kind:"local",id:e.slice(6),raw:e};let t=e.split(" ");if(t.length<4)return{scheme:t[0]??"",manager:t[1]??"",packageName:t[2]??"",version:"",descriptors:[],raw:e};let n=t[0],r=t[1],i=e.slice(n.length+1+r.length+1),o;if(i.startsWith("`")){let l=i.indexOf("`",1);l===-1?(o=i.slice(1),i=""):(o=i.slice(1,l),i=i.slice(l+2))}else{let l=i.indexOf(" ");l===-1?(o=i,i=""):(o=i.slice(0,l),i=i.slice(l+1))}let s,a=i.indexOf(" ");a===-1?(s=i,i=""):(s=i.slice(0,a),i=i.slice(a+1));let c=t_(i);return{scheme:n,manager:r,packageName:o,version:s,descriptors:c,raw:e}}function Le(e){let t=Ke(e);if("kind"in t)return null;for(let n=t.descriptors.length-2;n>=0;n--){let r=t.descriptors[n];if(r?.suffix==="type")return r.name}return null}function t_(e){let t=[],n=0;for(;n<e.length;){let r=n_(e,n,t.length===0)??r_(e,n);r.descriptor&&t.push(r.descriptor),n=r.next}return t}function n_(e,t,n){if(e[t]==="["){let i=e.indexOf("]",t+1);return{descriptor:{name:e.slice(t+1,i===-1?void 0:i),suffix:"type-param"},next:i===-1?e.length:i+1}}if(e[t]!=="("||!(n||t===0||Oy(e[t-1])))return;let r=e.indexOf(")",t+1);if(!(r===-1||e[r+1]==="."))return{descriptor:{name:e.slice(t+1,r),suffix:"parameter"},next:r+1}}function r_(e,t){if(e[t]==="`"){let r=e.indexOf("`",t+1);return r===-1?{descriptor:{name:e.slice(t+1),suffix:"term"},next:e.length}:Ay(e,e.slice(t+1,r),r+1)}let n=t;for(;t<e.length&&!Oy(e[t]);)t++;return Ay(e,e.slice(n,t),t)}function Ay(e,t,n){if(n>=e.length)return{descriptor:t?{name:t,suffix:"term"}:void 0,next:n};if(e[n]==="("){let i=e.indexOf(")",n+1);return i===-1?{descriptor:{name:t,suffix:"term"},next:n+1}:{descriptor:{name:t,suffix:"method"},next:i+(e[i+1]==="."?2:1)}}let r=e_[e[n]];return{descriptor:r?{name:t,suffix:r}:void 0,next:n+1}}function Oy(e){return e==="/"||e==="#"||e==="."||e==="("||e==="["||e===":"||e==="!"}function In(e){let t=Ke(e);if("kind"in t&&t.kind==="local")return`local:${t.id}`;let n=t;if(n.descriptors.length===0)return n.raw;let r=[];for(let i of n.descriptors){let o=i_(i);o&&r.push(o)}return r.join(":")}function i_(e){let t=e.suffix==="namespace"?o_(e.name):e.name;return t?e.suffix==="method"?`${t}()`:t:""}function o_(e){return e.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/,"").replace(/\.(py|pyi)$/,"").replace(/\.(rs)$/,"").replace(/\.(java|scala|kt|kts)$/,"").replace(/\.(rb)$/,"").replace(/\.(go)$/,"").replace(/\.(cs|vb)$/,"").replace(/\.(dart)$/,"").replace(/\.(php)$/,"").replace(/\.(c|cc|cpp|cxx|h|hpp)$/,"")}function Y(e){let t=Ke(e);if("kind"in t&&t.kind==="local")return t.id;let n=t;return n.descriptors.length===0?"":n.descriptors[n.descriptors.length-1].name}function iY(e){let t=Ke(e);if("kind"in t&&t.kind==="local")return t.id;let n=t.descriptors,r=n[n.length-1];if(!r)return"";let i=n[n.length-2];return i&&i.suffix==="type"?`${i.name} ${r.name}`:r.name}function oY(e){let t=Ke(e);if("kind"in t&&t.kind==="local")return null;let n=t.descriptors,r=n[n.length-2];return r&&r.suffix==="type"?r.name:null}function nr(e){let t=Ke(e);if("kind"in t&&t.kind==="local")return null;let n=t;return n.descriptors[n.descriptors.length-1]?.suffix??null}function zi(e){return e.endsWith("().")||nr(e)==="method"}function qr(e){let t=nr(e);return t==="method"?!0:t!=="term"?!1:e.endsWith("().")?!0:e.startsWith("rust-analyzer ")&&e.includes("#")?!1:e.startsWith("scip-typescript ")?!/#[A-Za-z0-9_$]+\.$/.test(e):!0}function My(e){return nr(e)==="namespace"}var s_=/^rust-analyzer\b.*[\s/]impl#\[[^\]]+\]\[[^\]]+\]/;function sY(e){return s_.test(e)}var a_=new Set(["test","tests","_tests"]);function aY(e){let t=Ke(e);if("kind"in t)return!1;for(let n=0;n<t.descriptors.length-1;n+=1){let r=t.descriptors[n];if(r?.suffix==="namespace"&&r.name&&a_.has(r.name))return!0}return!1}function cY(e,t){let n=Ke(e),r=Ke(t);if("kind"in n||"kind"in r)return!1;let i=n.descriptors,o=r.descriptors;if(o.length!==i.length+1)return!1;for(let s=0;s<i.length;s++){let a=i[s],c=o[s];if(a.name!==c.name||a.suffix!==c.suffix)return!1}return!0}function lY(e,t){let n=Ke(e),r=Ke(t);if("kind"in n||"kind"in r)return!1;let i=n.descriptors,o=r.descriptors;if(o.length<=i.length)return!1;for(let s=0;s<i.length;s++){let a=i[s],c=o[s];if(a.name!==c.name||a.suffix!==c.suffix)return!1}return!0}import{fromBinary as By}from"@bufbuild/protobuf";import{DocumentSchema as $y,SymbolRole as Gy}from"@c4312/scip";import{zstdDecompressSync as Vy}from"zlib";var c_=U("definition-occurrence-ranges",{clearGroups:["whole-project","definition-catalog"],maxEntries:64});function l_(e,t){return c_.get(e,t,()=>{let n=new Map;for(let r of e.all("SELECT c.occurrences FROM chunks c JOIN documents d ON d.id = c.document_id WHERE d.relative_path = ? ORDER BY c.chunk_index",t))for(let[i,o]of u_(r.occurrences))n.has(i)||n.set(i,o);return n})}function u_(e){let t=new Map;if(!e||e.length<=1)return t;try{for(let n of By($y,Vy(e)).occurrences){let r=d_(n);r&&n.symbol&&!t.has(n.symbol)&&t.set(n.symbol,r)}}catch{}return t}function d_(e){let t=e.range;if(!(!(e.symbolRoles&Gy.Definition)||t.length<3))return{start_line:t[0],start_char:t[1],end_line:t.length===4?t[2]:t[0],end_char:t.length===4?t[3]:t[2]}}function Cn(e,t){return e.all(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.start_char, der.end_line, der.end_char, d.relative_path, gs.display_name, gs.documentation
|
|
161
|
+
FROM global_symbols gs
|
|
162
|
+
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
163
|
+
JOIN documents d ON der.document_id = d.id
|
|
164
|
+
WHERE ${t.where}
|
|
165
|
+
${e.pathExclusionsFor("d")}
|
|
166
|
+
${Wy(t.orderBy)}
|
|
167
|
+
${Uy(t.limit)}`,...t.params??[])}function rr(e,t){return e.all(`SELECT
|
|
168
|
+
gs.id,
|
|
169
|
+
gs.symbol,
|
|
170
|
+
c.document_id,
|
|
171
|
+
MIN(c.start_line) AS start_line,
|
|
172
|
+
0 AS start_char,
|
|
173
|
+
MAX(c.end_line) AS end_line,
|
|
174
|
+
0 AS end_char,
|
|
175
|
+
d.relative_path,
|
|
176
|
+
gs.display_name,
|
|
177
|
+
gs.documentation
|
|
178
|
+
FROM global_symbols gs
|
|
179
|
+
JOIN mentions m ON m.symbol_id = gs.id
|
|
180
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
181
|
+
JOIN documents d ON c.document_id = d.id
|
|
182
|
+
WHERE m.role = 1
|
|
183
|
+
AND ${t.where}
|
|
184
|
+
${e.pathExclusionsFor("d")}
|
|
185
|
+
GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path, gs.display_name, gs.documentation
|
|
186
|
+
${Wy(t.orderBy)}
|
|
187
|
+
${Uy(t.limit)}`,...t.params??[]).map(n=>({...n,...l_(e,n.relative_path).get(n.symbol)}))}function Wy(e){return e?`ORDER BY ${e}`:""}function Uy(e){return typeof e=="number"?`LIMIT ${e}`:""}function hu(e){return!e||!e.trim()?null:e.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim()||null}function Su(e){if(!e)return null;let t=jy(e);if(t)return t.replace(/\n/g," ");let n=e.indexOf("|");if(n===-1)return e.replace(/\n/g," ");let r=e.slice(n+1);return(jy(r)??r).replace(/\n/g," ")}function jy(e){return/^```(?:\w+)?\s*\n?([\s\S]*?)\n?```/.exec(e.trimStart())?.[1]?.trim()||null}var p_=U("reference-occurrence-lines",{clearGroups:["whole-project","source-file"],maxEntries:64});function Ki(e,t,n){let r=p_.get(e,t,()=>{let i=e.all("SELECT c.occurrences FROM chunks c JOIN documents d ON d.id = c.document_id WHERE d.relative_path = ? ORDER BY c.chunk_index",t);if(i.length===0)return null;let o=new Map;try{for(let s of i){if(!s.occurrences||s.occurrences.length<=1)return null;let{occurrences:a}=By($y,Vy(s.occurrences));f_(a,o)}}catch{return null}return new Map([...o].map(([s,a])=>[s,[...a].sort((c,l)=>c-l)]))});return r===null?null:r.get(n)??[]}function f_(e,t){for(let n of e){if(!n.symbol||(n.symbolRoles&Gy.Definition)!==0)continue;let r=n.range[0];if(r===void 0||!Number.isSafeInteger(r)||r<0)continue;let i=t.get(n.symbol)??new Set;i.add(r),t.set(n.symbol,i)}}function Ys(e){return{forFile(t,n){return qy(e,t,n)},forFiles(t,n){let r=new Map;for(let i of t)r.set(i,qy(e,i,n));return r}}}function qy(e,t,n){let r={file:t},i=n.facts||n.identifiers;return n.text&&(r.text=L(e,t)),n.lines&&(r.lines=zt(e,t)),n.ast&&(r.ast=D(e,t)),n.imports&&(r.imports=vt(e,t)),n.reexports&&(r.reexports=Lt(e,t)),i&&m_(e,t,n,r),r}function m_(e,t,n,r){let i=Zl(e,t),o=i.facts;n.facts&&(r.facts=o),i.unavailable&&(r.sourceFactsUnavailable=i.unavailable),n.identifiers&&o&&(r.identifiers=o.fileIdentifiers,r.identifierLineMap=o.identifierLineMap)}function g_(e,t={}){if(Le(e.symbol)!==null)return t.includeClassMemberFallbacks===!0;let i=(e.documentation??"").replace(/^```\w*\s*/,"").replace(/\s*```$/,"").trim();return/^(?:var|let|const|function|class|interface|type|enum)\b/.test(i)}function en(e,t,n={}){let r=new Map;for(let o of t)e.length>0&&!g_(o,{includeClassMemberFallbacks:n.includeClassMemberFallbacks})||r.set(o.id,o);for(let o of e)r.set(o.id,o);let i=[...r.values()];return n.sort?i.sort((o,s)=>o.start_line-s.start_line||o.end_line-s.end_line||o.symbol.localeCompare(s.symbol)):i}function jY(e){let t=new Map;for(let n of e){if(!n.leaf)continue;let r=t.get(n.leaf)??[];r.push(n),t.set(n.leaf,r)}return t}var y_=ie("file-definitions",{clearGroups:["definition-catalog"]}),h_=oe("scoped-matched-definitions",{clearGroups:["definition-catalog"]}),S_=ie("file-function-like-definitions",{clearGroups:["definition-catalog"]}),Hy=new WeakMap;function k(e,t,n={},r){return wt(t),n.includeClassMemberFallbacks?xu(e,t,void 0,{includeClassMemberFallbacks:!0},r):y_.get(e,t,()=>{let i=_t(r,"evidence-read",()=>Jy(e,t));if(i)return i;let o=xu(e,t,void 0,n,r);return _t(r,"evidence-write",()=>{let s=qt(e),a=Ys(e).forFile(t,{text:!0}).text;s&&a&&Ky.write(e,t,Se(e,t,a),{projectFingerprint:s,definitions:o.map(c=>({...c}))})}),o})}function b_(e,t){return wt(t),S_.get(e,t,()=>{let n=Jy(e,t);return n?n.filter(r=>r.isFunctionLike):xu(e,t,r=>r.isFunctionLike)})}var Ky=ge({kind:"file-definitions",invalidation:ee("file-definitions"),serialize:x_,deserialize:v_});function Jy(e,t){let n=qt(e);if(!n)return null;let r=Ys(e).forFile(t,{text:!0}).text;if(!r)return null;let i=Ky.read(e,t,Se(e,t,r));return i?R_(i,n,t):null}function x_(e){return JSON.stringify(e)}function v_(e){try{let t=JSON.parse(e);return!bn(t)||typeof t.projectFingerprint!="string"||!Array.isArray(t.definitions)?null:{projectFingerprint:t.projectFingerprint,definitions:t.definitions}}catch{return null}}function R_(e,t,n){if(e.projectFingerprint!==t)return null;let r=[];for(let i of e.definitions){let o=I_(i,n);if(!o)return null;r.push(o)}return r}function I_(e,t){return!bn(e)||!C_(e)||!E_(e,t)||!P_(e)||!w_(e)?null:{symbolId:e.symbolId,symbol:e.symbol,documentId:e.documentId,startLine:e.startLine,startChar:e.startChar,endLine:e.endLine,endChar:e.endChar,relativePath:e.relativePath,leaf:e.leaf,parentTypeName:e.parentTypeName,isFunctionLike:e.isFunctionLike,isTypeLike:e.isTypeLike,kind:e.kind,documentation:e.documentation,enclosingSymbol:e.enclosingSymbol}}function C_(e){return typeof e.symbolId=="number"&&typeof e.symbol=="string"&&typeof e.documentId=="number"}function E_(e,t){return typeof e.startLine=="number"&&(typeof e.startChar=="number"||e.startChar===void 0)&&typeof e.endLine=="number"&&(typeof e.endChar=="number"||e.endChar===void 0)&&e.relativePath===t}function P_(e){return typeof e.leaf=="string"&&(typeof e.parentTypeName=="string"||e.parentTypeName===null)&&typeof e.isFunctionLike=="boolean"&&typeof e.isTypeLike=="boolean"&&(typeof e.kind=="number"||e.kind===null)}function w_(e){return(typeof e.documentation=="string"||e.documentation===null)&&(typeof e.enclosingSymbol=="string"||e.enclosingSymbol===null)}function xu(e,t,n,r={},i){let o=_t(i,"primary-rows",()=>F_(e,t)),s=_t(i,"fallback-rows",()=>T_(e,t)),a=_t(i,"merge-rows",()=>en(o,s,{sort:!0,includeClassMemberFallbacks:r.includeClassMemberFallbacks}).map(vu));return n&&(a=a.filter(n)),_t(i,"range-correction",()=>Iu(e,t,a,i,r.rangeCorrectionEvidence))}function _t(e,t,n){return e?e(t,n):n()}function F_(e,t){return e.all(`SELECT
|
|
188
|
+
gs.id,
|
|
189
|
+
gs.symbol,
|
|
190
|
+
der.document_id,
|
|
191
|
+
der.start_line,
|
|
192
|
+
der.start_char,
|
|
193
|
+
der.end_line,
|
|
194
|
+
der.end_char,
|
|
195
|
+
d.relative_path,
|
|
196
|
+
gs.display_name,
|
|
197
|
+
gs.kind,
|
|
198
|
+
gs.documentation,
|
|
199
|
+
gs.enclosing_symbol
|
|
200
|
+
FROM global_symbols gs
|
|
201
|
+
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
202
|
+
JOIN documents d ON der.document_id = d.id
|
|
203
|
+
WHERE d.relative_path = ?
|
|
204
|
+
${e.symbolNoiseFor("gs")}
|
|
205
|
+
ORDER BY der.start_line, der.end_line`,t)}function T_(e,t){return e.all(`SELECT
|
|
206
|
+
gs.id,
|
|
207
|
+
gs.symbol,
|
|
208
|
+
c.document_id,
|
|
209
|
+
MIN(c.start_line) AS start_line,
|
|
210
|
+
0 AS start_char,
|
|
211
|
+
MAX(c.end_line) AS end_line,
|
|
212
|
+
0 AS end_char,
|
|
213
|
+
d.relative_path,
|
|
214
|
+
gs.display_name,
|
|
215
|
+
gs.kind,
|
|
216
|
+
gs.documentation,
|
|
217
|
+
gs.enclosing_symbol
|
|
218
|
+
FROM global_symbols gs
|
|
219
|
+
JOIN mentions m ON m.symbol_id = gs.id
|
|
220
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
221
|
+
JOIN documents d ON c.document_id = d.id
|
|
222
|
+
WHERE d.relative_path = ?
|
|
223
|
+
AND m.role = 1
|
|
224
|
+
${e.symbolNoiseFor("gs")}
|
|
225
|
+
GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
|
|
226
|
+
ORDER BY start_line, end_line`,t)}function vu(e){return{symbolId:e.id,symbol:e.symbol,documentId:e.document_id,startLine:e.start_line,startChar:e.start_char??0,endLine:e.end_line,endChar:e.end_char??0,relativePath:e.relative_path,leaf:Y(e.symbol),parentTypeName:Le(e.symbol),isFunctionLike:qr(e.symbol),isTypeLike:nr(e.symbol)==="type",kind:e.kind??null,documentation:e.documentation??null,enclosingSymbol:e.enclosing_symbol??null}}function Xs(e,t={}){return L_(e,t.scope)}function Yy(e,t){let n=new Set(t);if(n.size===0)return[];let r=N_(e,[...n]);return Re(e,{includeIgnored:!1}).filter(i=>r.has(i)).flatMap(i=>k(e,i)).filter(i=>n.has(i.symbol))}function N_(e,t){let n=new Set;for(let r=0;r<t.length;r+=400){let i=t.slice(r,r+400),o=e.all(`WITH requested AS (SELECT id FROM global_symbols WHERE symbol IN (${i.map(()=>"?").join(",")}))
|
|
227
|
+
SELECT d.relative_path FROM requested r
|
|
228
|
+
JOIN defn_enclosing_ranges der ON der.symbol_id = r.id
|
|
229
|
+
JOIN documents d ON d.id = der.document_id
|
|
230
|
+
UNION
|
|
231
|
+
SELECT d.relative_path FROM requested r
|
|
232
|
+
JOIN mentions m ON m.symbol_id = r.id AND m.role = 1
|
|
233
|
+
JOIN chunks c ON c.id = m.chunk_id
|
|
234
|
+
JOIN documents d ON d.id = c.document_id`,...i);for(let s of o)n.add(s.relative_path)}return n}function L_(e,t){return Re(e,{scope:t,includeIgnored:!1}).flatMap(n=>k(e,n)).filter(n=>!e.isIgnored(n.relativePath))}function BY(e,t){return Re(e,{scope:t,includeIgnored:!1}).flatMap(n=>b_(e,n)).filter(n=>!e.isIgnored(n.relativePath))}function $Y(e,t){let n=h_.get(e,()=>new WeakMap),r=n.get(t.symbolMatches);r||(r=new Map,n.set(t.symbolMatches,r));let i=JSON.stringify({scope:t.scope??null,sqlPrefilter:t.sqlPrefilter??null}),o=r.get(i);if(o)return[...o];let s=zy(__(e,t.scope,t.sqlPrefilter)),a=zy(D_(e,t.scope,t.sqlPrefilter)),c=new Set([...s.keys(),...a.keys()]),l=[];for(let u of[...c].sort()){if(e.isIgnored(u))continue;let d=en(s.get(u)??[],a.get(u)??[],{sort:!0}).filter(p=>t.symbolMatches(p.symbol));d.length!==0&&l.push(...Iu(e,u,d.map(vu)))}return r.set(i,l),[...l]}function __(e,t,n){let r=t?"AND d.relative_path LIKE ?":"",i=n?`AND ${Xy("gs",n)}`:"",o=t?[`%${t}%`]:[];return e.all(`SELECT
|
|
235
|
+
gs.id,
|
|
236
|
+
gs.symbol,
|
|
237
|
+
der.document_id,
|
|
238
|
+
der.start_line,
|
|
239
|
+
der.start_char,
|
|
240
|
+
der.end_line,
|
|
241
|
+
der.end_char,
|
|
242
|
+
d.relative_path,
|
|
243
|
+
gs.display_name,
|
|
244
|
+
gs.kind,
|
|
245
|
+
gs.documentation,
|
|
246
|
+
gs.enclosing_symbol
|
|
247
|
+
FROM global_symbols gs
|
|
248
|
+
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
249
|
+
JOIN documents d ON der.document_id = d.id
|
|
250
|
+
WHERE 1 = 1
|
|
251
|
+
${e.pathExclusionsFor("d")}
|
|
252
|
+
${r}
|
|
253
|
+
${i}
|
|
254
|
+
${e.symbolNoiseFor("gs")}
|
|
255
|
+
ORDER BY d.relative_path, der.start_line, der.end_line`,...o)}function D_(e,t,n){let r=t?"AND d.relative_path LIKE ?":"",i=n?`AND ${Xy("gs",n)}`:"",o=t?[`%${t}%`]:[];return e.all(`SELECT
|
|
256
|
+
gs.id,
|
|
257
|
+
gs.symbol,
|
|
258
|
+
c.document_id,
|
|
259
|
+
MIN(c.start_line) AS start_line,
|
|
260
|
+
0 AS start_char,
|
|
261
|
+
MAX(c.end_line) AS end_line,
|
|
262
|
+
0 AS end_char,
|
|
263
|
+
d.relative_path,
|
|
264
|
+
gs.display_name,
|
|
265
|
+
gs.kind,
|
|
266
|
+
gs.documentation,
|
|
267
|
+
gs.enclosing_symbol
|
|
268
|
+
FROM global_symbols gs
|
|
269
|
+
JOIN mentions m ON m.symbol_id = gs.id
|
|
270
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
271
|
+
JOIN documents d ON c.document_id = d.id
|
|
272
|
+
WHERE m.role = 1
|
|
273
|
+
AND NOT EXISTS (
|
|
274
|
+
SELECT 1
|
|
275
|
+
FROM defn_enclosing_ranges existing_der
|
|
276
|
+
WHERE existing_der.symbol_id = gs.id
|
|
277
|
+
)
|
|
278
|
+
${e.pathExclusionsFor("d")}
|
|
279
|
+
${r}
|
|
280
|
+
${i}
|
|
281
|
+
${e.symbolNoiseFor("gs")}
|
|
282
|
+
GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
|
|
283
|
+
ORDER BY d.relative_path, start_line, end_line`,...o)}function k_(e){return`(${e}.symbol LIKE '%().' OR ${e}.symbol LIKE '%()')`}function Xy(e,t){return t==="callable"?k_(e):A_(e)}function A_(e){return`(${e}.symbol LIKE '%.' OR ${e}.symbol LIKE '%()')`}function zy(e){let t=new Map;for(let n of e){let r=t.get(n.relative_path);r?r.push(n):t.set(n.relative_path,[n])}return t}function GY(e,t,n={}){if(t.length===0)return[];let r=t.flatMap(i=>k(e,i)).filter(i=>!e.isIgnored(i.relativePath));return n.onlyDocumented&&(r=r.filter(i=>i.documentation!==null&&i.documentation!=="")),n.sort&&(r=r.sort((i,o)=>i.relativePath.localeCompare(o.relativePath)||i.startLine-o.startLine||i.endLine-o.endLine)),r.map(i=>({startLine:i.startLine,endLine:i.endLine,symbol:i.symbol,shortName:In(i.symbol),signature:hu(Su(i.documentation)),relativePath:i.relativePath,enclosingSymbol:i.enclosingSymbol}))}function Ru(e){let t=new Map,n=e.map((r,i)=>({definition:r,index:i,span:r.endLine-r.startLine})).sort((r,i)=>r.span-i.span||r.index-i.index);for(let{definition:r}of n)for(let i=r.startLine;i<=r.endLine;i+=1)t.has(i)||t.set(i,r);return t}function Hr(e,t){let n=Hy.get(e);return n||(n=Ru(e),Hy.set(e,n)),n.get(t)??null}function Qs(e,t){let n=k(e,t.relative_path).find(r=>r.symbolId===t.id)??(Le(t.symbol)===null||!qr(t.symbol)?void 0:Iu(e,t.relative_path,[vu(t)])[0]);return n?{symbolId:n.symbolId,symbol:n.symbol,documentId:n.documentId,startLine:n.startLine,startChar:n.startChar,endLine:n.endLine,endChar:n.endChar,relativePath:n.relativePath}:{symbolId:t.id,symbol:t.symbol,documentId:t.document_id,startLine:t.start_line,startChar:t.start_char??0,endLine:t.end_line,endChar:t.end_char??0,relativePath:t.relative_path}}function Iu(e,t,n,r,i){let o=_t(r,"range-correction.source-text",()=>i?i.source:Ys(e).forFile(t,{text:!0}).text),s=_t(r,"range-correction.callable-sites",()=>i?i.callables:O_(e,t));return s?_t(r,"range-correction.ast-correction",()=>V_(n,s,o)):o?_t(r,"range-correction.regex-fallback",()=>M_(n,o)):n}function O_(e,t){let n=B(t),r=n&&D(e,t)?.rootNode;return(n&&r&&nu(r,n))??tu(e,t)}function M_(e,t){let n=t.split(/\r?\n/),r=j_(e,n),i=B_(e,r),o=$_(i,n);return G_(e,o)}function j_(e,t){let n=e.some(i=>Zs(i.symbol))?Y_(t):null,r=new Map;for(let i of e)r.set(i.symbolId,J_(t,n,i));return r}function B_(e,t){return e.filter(n=>Zs(n.symbol)).map(n=>({definition:n,startLine:t.get(n.symbolId)??n.startLine})).sort((n,r)=>n.startLine-r.startLine||n.definition.startLine-r.definition.startLine||n.definition.symbol.localeCompare(r.definition.symbol))}function $_(e,t){let n=new Map;for(let r=0;r<e.length;r+=1){let i=e[r],o=e[r+1],s=o?Math.max(i.startLine,o.startLine-1):t.length-1;n.set(i.definition.symbolId,{startLine:i.startLine,endLine:X_(t,i.definition,i.startLine,s)})}return n}function G_(e,t){return e.map(n=>{let r=t.get(n.symbolId);return r?{...n,startLine:r.startLine,endLine:r.endLine}:n})}function V_(e,t,n=null){let r,i=s=>K_(s,n?r??=n.split(/\r?\n/):null),o=new Map;for(let s of t){let a=o.get(s.name);a?a.push(s):o.set(s.name,[s])}return e.map(s=>{if(!z_(s)||!s.leaf)return i(s);let a=o.get(s.leaf);if(!a||a.length===0)return i(s);let c=n?W_(s,a,n):null;if(c)return{...s,startLine:c.startLine,endLine:c.endLine};let l=a[0],u=Math.abs(l.startLine-s.startLine);for(let d=1;d<a.length;d+=1){let p=a[d],f=Math.abs(p.startLine-s.startLine);f<u&&(l=p,u=f)}return{...s,startLine:l.startLine,endLine:l.endLine}})}function W_(e,t,n){let r=U_(e.symbol);if(!r)return null;let i=n.split(/\r?\n/),o=new RegExp(`\\b${Ce(r)}\\b`);for(let s of t){let a=q_(i,s.startLine);if(a&&o.test(a))return s}return null}function U_(e){return e.match(/\/impl#\[([^\]]+)\]/)?.[1]??null}function q_(e,t){for(let n=t;n>=0;n-=1){let r=e[n]?.trim()??"";if(r){if(/^impl\b/.test(r))return H_(e,n,t);if(/^(?:struct|enum|trait|mod)\b/.test(r))return null}}return null}function H_(e,t,n){let r=[];for(let i=t;i<=n;i+=1){let o=e[i]??"";if(r.push(o),o.includes("{"))break}return r.join(" ")}function z_(e){return Zs(e.symbol)?!0:nr(e.symbol)==="term"&&Le(e.symbol)===null}function K_(e,t){if(!t||!e.leaf||nr(e.symbol)!=="term"||Le(e.symbol)!==null)return e;let n=Ce(e.leaf),r=new RegExp(`\\b(?:export\\s+)?(?:const|let|var)\\s+${n}\\b`),i=t.findIndex(o=>r.test(o));return i>=0?{...e,startLine:i,endLine:i}:e}function J_(e,t,n){if(!Zs(n.symbol))return n.startLine;let r=Math.max(0,Math.min(n.startLine,e.length-1));if(!t)return r;let i=t.get(n.leaf);if(!i||i.length===0)return r;let o=null;for(let s of i){let a=Math.abs(s-n.startLine);(!o||a<o.distance)&&(o={line:s,distance:a})}return o?.line??r}function Y_(e){let t=/\b(?:function|def|fn)\s+([A-Za-z_$][\w$]*)/g,n=/\b([A-Za-z_$][\w$]*)\s*[:=]\s*(?:async\s*)?(?:function\b|\()/g,r=/^\s*(?:(?:export|public|private|protected|static|readonly|async|abstract|get|set)\s+)*([A-Za-z_$][\w$]*)\s*(?:<[^(]*>)?\s*\(/,i=/\b([A-Za-z_$][\w$]*)\s*\(/g,o=new Map,s=(a,c)=>{let l=o.get(a);if(!l){o.set(a,[c]);return}l[l.length-1]!==c&&l.push(c)};for(let a=0;a<e.length;a+=1){let c=e[a]??"";bu(c,t,a,s),bu(c,n,a,s);let l=c.match(r);l?.[1]&&s(l[1],a),bu(c,i,a,s)}return o}function X_(e,t,n,r){let i=Math.max(n,Math.min(e.length-1,r)),o=Math.max(n,Math.min(i,t.endLine)),s={braceDepth:0,parenDepth:0,sawOpeningBrace:!1};for(let a=n;a<=i;a+=1){let c=Q_(e[a]??"");if(Z_(c,s),s.sawOpeningBrace&&s.braceDepth===0||!s.sawOpeningBrace&&s.parenDepth===0&&a>=o)return a}return o}function Q_(e){let t="",n={quote:null,escaping:!1};for(let r=0;r<e.length;r+=1){let i=e[r],o=e[r+1];if(!n.quote&&i==="/"&&o==="/"){t+=" ".repeat(e.length-r);break}if(n.quote){eD(n,i),t+=" ";continue}if(i==='"'||i==="'"||i==="`"){n.quote=i,t+=" ";continue}t+=i}return t}function Zs(e){return e.includes("().")}function VY(e){let t=Ke(e);if("kind"in t)return[];let n=[];for(let r=t.descriptors.length-2;r>=0;r-=1){let i=t.descriptors[r];i?.suffix==="type"&&i.name&&n.push(i.name)}return n}function bu(e,t,n,r){for(let i of e.matchAll(t))i[1]&&r(i[1],n)}function Z_(e,t){for(let n of e)n==="{"?(t.braceDepth+=1,t.sawOpeningBrace=!0):n==="}"?t.braceDepth=Math.max(0,t.braceDepth-1):n==="("?t.parenDepth+=1:n===")"&&(t.parenDepth=Math.max(0,t.parenDepth-1))}function eD(e,t){if(e.escaping){e.escaping=!1;return}if(t==="\\"){e.escaping=!0;return}t===e.quote&&(e.quote=null)}import{createHash as tD}from"crypto";import{isUtf8 as Zy}from"buffer";import{TextDecoder as nD}from"util";var eh=new nD("utf-8",{fatal:!0}),rD=oe("repository-text-indexed-documents",{clearGroups:[]}),iD=oe("repository-text-indexed-fingerprints",{clearGroups:[]});function oD(e){return Sl(e.config.projectRoot)}function Ji(e,t){let n=ve(t),r;try{r=Hn(e.config.projectRoot,n,{inputKind:"repository text file"})}catch(o){if(Ie(n),bt(o)||o instanceof Pt)return null;throw o}Fr(n,r.toString("utf8"));let i=cD(r);return i===null?(Zy(r)||Ie(n),null):th(n,r,i,Yi(e),nh(e))}function ZY(e,t,n){let r=oD(e).filter(m=>!t.scope||m.includes(t.scope)),i=Yi(e),o=nh(e),s=[],a=[],c=[],l=0,u=0,d={aligned:0,stale:0,unavailable:0},p=sD(t.literalBytes),f=p.length>0?Buffer.allocUnsafe(1024*1024):void 0,h=(m,g,y)=>{l+=g,u+=1;let I=Cu(m,y,i,o);d[I.state]+=1},b=(m,g)=>{let y=p.length===1?hl(e.config.projectRoot,m,p[0],{inputKind:"repository text file",computeSha256:g,scratchBuffer:f}):hs(e.config.projectRoot,m,p,{inputKind:"repository text file",computeSha256:g,scratchBuffer:f});if(!y.isUtf8Text)return s.push(m),null;let I=y.sha256;h(m,y.byteLength,I);let w="matchedLiteralIndexes"in y?y.matchedLiteralIndexes:y.includesLiteral?[0]:[];return w.length===0||!y.bytes?null:{bytes:y.bytes,knownSha256:I,matchedLiteralIndexes:w}},x=m=>{try{return p.length>0?b(m,o.has(m)):{bytes:Hn(e.config.projectRoot,m,{inputKind:"repository text file"}),knownSha256:void 0,matchedLiteralIndexes:[]}}catch(g){return g instanceof Pt?(c.push(m),null):(bt(g)||a.push(m),null)}};for(let m of r){let g=x(m);if(!g)continue;let{bytes:y,matchedLiteralIndexes:I}=g,w=g.knownSha256;if(p.length===0&&!rh(y)){s.push(m);continue}if(p.length===0){l+=y.byteLength,u+=1,w=o.has(m)?ih(y):void 0;let C=Cu(m,w,i,o);d[C.state]+=1}if(t.includeBytes&&!t.includeBytes(m,y))continue;let j=eh.decode(y);n(th(m,y,j,i,o,w),I)}return{candidateFiles:r.length,scannedTextFiles:u,semanticFiles:d,scannedBytes:l,skippedBinaryPaths:s,skippedUnreadablePaths:a,skippedOversizedPaths:c}}function sD(e){return e?Buffer.isBuffer(e)?[e]:[...e]:[]}function th(e,t,n,r,i,o){let s=o??ih(t);return{relativePath:e,text:n,bytes:t.byteLength,freshness:{exactText:{state:"current",basis:"working-tree-read",sha256:s},semantic:Cu(e,s,r,i)}}}function Cu(e,t,n,r){if(!r.has(e))return{state:"unavailable",basis:"no-compiler-document"};let i=n.get(e);return!i||!t?{state:"unavailable",basis:"fingerprint-unavailable"}:{state:i===t?"aligned":"stale",basis:"indexed-input-fingerprint"}}function nh(e){return rD.get(e,()=>new Set(e.all(`SELECT documents.relative_path FROM documents WHERE 1 = 1 ${e.pathExclusionsFor("documents")}`).map(t=>t.relative_path)))}function Yi(e){return iD.get(e,()=>aD(e.generation.metadataRaw))}function aD(e){let t=new Map;if(!e)return t;let n=Ct(e);if(n.kind!=="legacy"&&n.kind!=="supported")return t;let r=n.metadata.fingerprint;if(!Qy(r)||!Array.isArray(r.files))return t;for(let i of r.files)!Qy(i)||typeof i.path!="string"||typeof i.hash!="string"||t.set(i.path,i.hash);return t}function cD(e){return rh(e)?eh.decode(e):null}function rh(e){return!e.includes(0)&&Zy(e)}function ih(e){return tD("sha256").update(e).digest("hex")}function Qy(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var lD=U("symbol-resolution",{clearGroups:[]});function aX(e,t){return uD(e,t).match}function uD(e,t){return lD.get(e,t,()=>{let n=ch(e,t.trim()).filter(s=>!e.isIgnored(s.relative_path));if(n.length>0)return zr(e,n);let r=SD(e,t);if(r&&!e.isIgnored(r.relative_path))return zr(e,[r]);let i=dD(e,t);if(i.length>0)return zr(e,i);let o=pD(e,t);return o.length>0?zr(e,o):yD(e,t)})}function dD(e,t){let n=t.trim().replace(/\(\)$/u,""),r=n.lastIndexOf(":");if(r<=0||r===n.length-1||n.startsWith("local:"))return[];let i=n.slice(r+1);if(!/^[\p{L}_$][\p{L}\p{N}_$]*$/u.test(i))return[];let o=[`/${i}().`,`/${i}.`,`/${i}#`,`#${i}().`,`#${i}.`,`/${i}/`],s=`gs.display_name = ? OR ${o.map(()=>"instr(gs.symbol, ?) > 0").join(" OR ")}`,a=[i,...o],c=Cn(e,{where:s,params:a,orderBy:"d.relative_path, der.start_line",limit:200}),l=c.length>0?[]:rr(e,{where:s,params:a,orderBy:"d.relative_path, start_line",limit:200}),u=en(c,l).filter(d=>!e.isIgnored(d.relative_path)).filter(d=>In(d.symbol).replace(/\(\)$/u,"")===n);return[...new Map(u.map(d=>[`${d.symbol}\0${d.relative_path}`,d])).values()]}function pD(e,t){let n=ea(t),r=Eu(n);if(!r)return[];let i=`%${r.path}%`,o=r.leaf;return fD(e,i,o,n)}function fD(e,t,n,r){let i=en([],[...mD(e,t,n),...gD(e,t,n)]).filter(o=>!e.isIgnored(o.relative_path)).filter(o=>Kr(o,r)>1);return i.sort((o,s)=>Kr(s,r)-Kr(o,r)||o.end_line-o.start_line-(s.end_line-s.start_line)||o.start_line-s.start_line||o.symbol.localeCompare(s.symbol)),i}function mD(e,t,n){return Cn(e,{where:"d.relative_path LIKE ? AND (gs.display_name = ? OR gs.symbol LIKE ?)",params:[t,n,`%/${n}.%`]})}function gD(e,t,n){return rr(e,{where:"d.relative_path LIKE ? AND (gs.display_name = ? OR gs.symbol LIKE ?)",params:[t,n,`%/${n}.%`]})}function yD(e,t){let n=ea(t),r=FD(t),i=RD(e,r),o=TD(i,t,n).filter(a=>!e.isIgnored(a.relative_path));if(o.length>0)return zr(e,o);let s=[];for(let a of i){if(e.isIgnored(a.relative_path))continue;let c=wD(a,t,n,r);c<=0||s.push({row:a,score:c})}return s.sort((a,c)=>c.score-a.score||a.row.end_line-a.row.start_line-(c.row.end_line-c.row.start_line)||a.row.relative_path.localeCompare(c.row.relative_path)||a.row.symbol.localeCompare(c.row.symbol)),zr(e,s.map(a=>a.row))}function zr(e,t){let n=t.map(i=>Qs(e,i)),r=n[0]??null;return{match:r,candidates:r?hD(n,r):[],total:n.length}}function hD(e,t){let n=new Set([`${t.symbolId}:${t.relativePath}:${t.startLine}`]),r=[];for(let i of e){let o=`${i.symbolId}:${i.relativePath}:${i.startLine}`;if(!n.has(o)&&(n.add(o),r.push({symbol:i.symbol,shortName:In(i.symbol),relativePath:i.relativePath,startLine:i.startLine}),r.length>=5))break}return r}function SD(e,t){let n=t.match(/^(.+):(\d+)(?:-(\d+))?$/);if(!n)return;let[,r,i,o]=n,s=Fm(e,r,{allowMultiple:!1,requirePathMatch:!0})[0]?.relativePath;if(!s)return;let a=Math.max(0,parseInt(i,10)-1),c=o?Math.max(a,parseInt(o,10)-1):a;return bD(e,s,a,c)??xD(e,s,a,c)}function bD(e,t,n,r){return Cn(e,{where:"d.relative_path = ? AND der.start_line <= ? AND der.end_line >= ?",params:[t,n,r],orderBy:"(der.end_line - der.start_line) ASC",limit:1})[0]}function xD(e,t,n,r){return rr(e,{where:"d.relative_path = ? AND c.start_line <= ? AND c.end_line >= ?",params:[t,n,r],orderBy:"(MAX(c.end_line) - MIN(c.start_line)) ASC",limit:1})[0]}function cX(e,t){let n=ch(e,t).find(r=>!e.isIgnored(r.relative_path));return n?Qs(e,n):null}function ch(e,t){let n=Cn(e,{where:"gs.symbol = ?",params:[t],orderBy:"d.relative_path, der.start_line"}),r=n.length>0?[]:rr(e,{where:"gs.symbol = ?",params:[t],orderBy:"d.relative_path, start_line"});return en(n,r)}function Xi(e,t){if("symbol"in t&&"relativePath"in t)return t;let n=vD(e,t.symbolId)[0];return n?Qs(e,n):null}function vD(e,t){let n=Cn(e,{where:"gs.id = ?",params:[t],orderBy:"der.start_line, der.end_line"}),r=rr(e,{where:"gs.id = ?",params:[t],orderBy:"start_line, end_line"});return en(n,r)}function RD(e,t){let n=t.map(()=>"(gs.symbol LIKE ? OR d.relative_path LIKE ? OR COALESCE(gs.display_name, '') LIKE ?)"),r=t.flatMap(a=>{let c=`%${a}%`;return[c,c,c]}),i=n.join(`
|
|
284
|
+
AND `),o=Cn(e,{where:i,params:r,limit:200}),s=rr(e,{where:i,params:r,limit:200});return en(o,s)}function lh(e){return e.reduce((t,[n,r,i])=>t+(r.includes(n)?i:0),0)}function ID(e,t,n){let r=n.replace(/\(\)$/,"");return lh([[e.raw,[t,n],1150],[e.short,[t,n],1100],[e.display,[r],1180],[e.leaf,[r],1160],[`${e.leaf}()`,[t,n],955]])}function CD(e,t,n){let r=n.replace(/\(\)$/,""),i=lh([[e.raw,[t,n],1e3],[e.short,[t,n],950],[e.path,[t,n],925],[e.display,[r],850],[e.leaf,[r],825],[`${e.leaf}()`,[t,n],820]]),o=[n,t].some(a=>e.path.endsWith(`/${a}`)),s=[n,r,`${r}()`].some(a=>e.short.endsWith(`:${a}`));return i+(o?875:0)+(s?800:0)}function ED(e,t,n){let r=[[e.raw,120],[e.short,140],[e.path,140],[e.display,110]],i=r.reduce((s,[a,c])=>s+(a.includes(t)?c:0),0),o=n.every(s=>r.some(([a])=>a.includes(s.toLowerCase())));return i+(o?100+n.length*15:0)}function PD(e,t,n){let r=Eu(n);if(!r||!e.path.includes(r.path.toLowerCase()))return 0;let i=r.leaf.toLowerCase();return 360+(i&&(e.leaf===i||`${e.leaf}()`===i||`${e.leaf}()`==`${i}()`)?700:0)+(zi(t)?180:0)}function wD(e,t,n,r){let i={raw:e.symbol,short:In(e.symbol),leaf:Y(e.symbol),display:e.display_name??"",path:e.relative_path},o={raw:i.raw.toLowerCase(),short:i.short.toLowerCase(),leaf:i.leaf.toLowerCase(),display:i.display.toLowerCase(),path:i.path.toLowerCase()},s=n.toLowerCase(),a=ID(i,t.trim(),n)+CD(o,t.toLowerCase(),s)+ED(o,s,r)+PD(o,e.symbol,n);return qr(e.symbol)&&o.leaf===s.replace(/\(\)$/,"")&&(a+=60),!/[/:.]/.test(n)&&My(e.symbol)&&(a-=160),a-Math.min(50,Math.max(0,e.end_line-e.start_line))}function Eu(e){let t=e.trim().replace(/\\/g,"/"),n=t.lastIndexOf("/");if(n<=0||n===t.length-1)return null;let r=t.slice(n+1).replace(/\(\)$/,"");return!r||r.includes(".")?null:{path:t.slice(0,n),leaf:r}}function ea(e){return e.trim().replace(/\(\)$/,"").replace(/\(.*$/,"")}function FD(e){let t=ea(e),n=t.split(/[^A-Za-z0-9_]+/).map(r=>r.trim()).filter(r=>r.length>0);return n.length>0?[...new Set(n)]:[t]}function TD(e,t,n){let r=t.trim(),i=e.filter(a=>{let c=In(a.symbol),l=Y(a.symbol),u=(a.display_name??"").trim();return a.symbol===r||c===r||c===n||ah(l,r,n)||ah(u,r,n)||Kr(a,n)>1||a.relative_path===r});if(i.length===0)return[];let o=n.replace(/\(\)$/u,""),s=i.filter(a=>Y(a.symbol)===o);if(s.length>0){s.sort((c,l)=>oh(c,l,n));let a=s.filter(c=>qr(c.symbol));return a.length>0?a:s}return i.sort((a,c)=>oh(a,c,n)),i}function oh(e,t,n){return Kr(t,n)-Kr(e,n)||e.end_line-e.start_line-(t.end_line-t.start_line)||e.relative_path.localeCompare(t.relative_path)||e.symbol.localeCompare(t.symbol)}function Kr(e,t){let n=Eu(t);if(!n)return 0;let r=e.relative_path.toLowerCase(),i=Y(e.symbol).toLowerCase(),o=n.path.toLowerCase(),s=n.leaf.toLowerCase();return r.includes(o)?i!==s?1:zi(e.symbol)?Le(e.symbol)===null?5:4:Le(e.symbol)===null?3:2:0}function lX(e,t,n=5){let r=sh(t);if(!r)return[];let i=Cn(e,{where:"1 = 1",orderBy:"d.relative_path, der.start_line",limit:5e3}),o=new Map;for(let s of i){if(e.isIgnored(s.relative_path))continue;let a=In(s.symbol),c=Y(s.symbol),l=s.display_name??c,u=[a,c,l].filter(f=>f.trim().length>0),d=Math.min(...u.map(f=>ND(sh(f),r))),p=o.get(a);(!p||d<p.distance)&&o.set(a,{shortName:a,distance:d})}return[...o.values()].sort((s,a)=>s.distance-a.distance||s.shortName.localeCompare(a.shortName)).slice(0,n).map(s=>s.shortName)}function sh(e){return ea(e).toLowerCase().replace(/[^a-z0-9_]+/g,"")}function ND(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;let n=Array.from({length:t.length+1},(r,i)=>i);for(let r=0;r<e.length;r++){let i=[r+1];for(let o=0;o<t.length;o++){let s=e[r]===t[o]?0:1;i[o+1]=Math.min(i[o]+1,n[o+1]+1,n[o]+s)}n=i}return n[t.length]}function ah(e,t,n){return e===t||e===n||`${e}()`===t}function Pu(e,t){let n=uh(e);return n?t.filter(r=>uh(r.file)===n):t}function dh(e,t,n,r,i){let o=vt(e,t);return r?LD(e,t,n,o,i):DD(t,n,o)}function LD(e,t,n,r,i){let o=i?.match(/^[A-Za-z_$][\w$]*/u)?.[0];if(!o)return null;let s=new Set(r.filter(a=>a.localName===o||a.importedName===o).map(a=>a.sourcePath).filter(a=>!!a));for(let a of n)for(let c of s)if(Et(c,a.file))return a;if(o==="this"||o==="self"||o==="cls"){let a=n.filter(c=>c.file===t&&Le(c.symbol)!==null);if(a.length===1)return a[0]}return _D(e,t,n,r,o)}function _D(e,t,n,r,i){let o=kD(L(e,t)??"",i);if(o.size===0)return null;let s=new Set(r.filter(c=>o.has(c.localName??c.importedName)).map(c=>c.sourcePath).filter(c=>!!c)),a=n.filter(c=>o.has(Le(c.symbol)??"")&&(c.file===t||[...s].some(l=>Et(l,c.file))));return a.length===1?a[0]:null}function DD(e,t,n){let r=t.filter(a=>Le(a.symbol)===null),i=r.find(a=>a.file===e);if(i)return i;let o=Y(t[0].symbol),s=n.filter(a=>a.kind!=="namespace"&&a.kind!=="side-effect"&&(a.localName===o||a.localName===null&&a.importedName===o));if(s.length>0){let a=r.filter(c=>s.some(l=>l.sourcePath!==null&&Et(l.sourcePath,c.file)));return a.length===1?a[0]:null}return r.length===1?r[0]:null}function kD(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),r=new Set,i=[new RegExp(`\\b${n}\\s*:\\s*([A-Za-z_$][\\w$]*)`,"gu"),new RegExp(`\\b${n}\\s*=\\s*(?:new\\s+)?([A-Za-z_$][\\w$]*)\\s*\\(`,"gu")];for(let o of i)for(let s of e.matchAll(o))r.add(s[1]);return r.size===1?r:new Set}function uh(e){let t=B(e);return t?t==="typescript"||t==="tsx"||t==="javascript"?"javascript-family":t:null}var AD=oe("global-leaf-index",{clearGroups:["whole-project"]});function Qi(e){return AD.get(e,()=>{let t=e.all(`SELECT gs.id, gs.symbol,
|
|
285
|
+
COALESCE(der_doc.relative_path, mention_doc.relative_path) AS relative_path
|
|
286
|
+
FROM global_symbols gs
|
|
287
|
+
LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
|
|
288
|
+
LEFT JOIN documents der_doc ON der_doc.id = der.document_id
|
|
289
|
+
LEFT JOIN (
|
|
290
|
+
SELECT m.symbol_id, MIN(d.relative_path) AS relative_path
|
|
291
|
+
FROM mentions m
|
|
292
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
293
|
+
JOIN documents d ON c.document_id = d.id
|
|
294
|
+
WHERE m.role = 1
|
|
295
|
+
GROUP BY m.symbol_id
|
|
296
|
+
) mention_doc ON mention_doc.symbol_id = gs.id
|
|
297
|
+
WHERE 1 = 1
|
|
298
|
+
${e.symbolNoiseFor("gs")}`),n=new Map;for(let r of t){if(!r.relative_path||e.isIgnored(r.relative_path))continue;let i=Y(r.symbol);if(!i)continue;let o=n.get(i);o||(o=[],n.set(i,o)),o.some(s=>s.symbolId===r.id)||o.push({symbol:r.symbol,symbolId:r.id,file:r.relative_path})}return n})}function ta(e,t,n,r={}){if(!n)return[];let i=L(e,t);return i?i.indexOf(n)===-1?[]:(wu(e,t).get(n)??[]).filter(s=>!OD(s,r)):[]}function OD(e,t){return typeof t.excludeStartLine=="number"&&typeof t.excludeEndLine=="number"&&e>=t.excludeStartLine&&e<=t.excludeEndLine}var MD=ie("file-identifiers",{clearGroups:["whole-project","source-file"]});function ph(e,t){let n=J(e,t);return n?n.fileIdentifiers:MD.get(e,t,()=>new Set(wu(e,t).keys()))}var jD=ie("file-ident-lines",{clearGroups:["whole-project","source-file"]});function wu(e,t){let n=J(e,t);return n?n.identifierLineMap:jD.get(e,t,()=>$D(e,t))}var BD=ie("file-idents-by-line",{clearGroups:["whole-project","source-file"]});function fh(e,t){let n=J(e,t);return n?n.identifiersByLine:BD.get(e,t,()=>{let r=wu(e,t),i=0;for(let s of r.values()){let a=s[s.length-1];a!==void 0&&a>i&&(i=a)}let o=new Array(i+1);for(let s=0;s<=i;s+=1)o[s]=new Set;for(let[s,a]of r)for(let c of a)o[c].add(s);return o})}function $D(e,t){let n=new Map,r=(a,c)=>{let l=n.get(a);if(!l){n.set(a,[c]);return}l[l.length-1]!==c&&l.push(c)},i=L(e,t);if(!i)return n;let o=Ol(i).split(/\r?\n/),s=/\b([A-Za-z_$][\w$]*)\b/g;for(let a=0;a<o.length;a+=1){let c=o[a]??"";for(let l of c.matchAll(s))l[1]&&r(l[1],a)}return n}var mh=/[A-Za-z_$][A-Za-z0-9_$]*/g,gh=/^[A-Za-z_$][A-Za-z0-9_$]*$/,GD=512;function Fu(e){let t=[],n=!1;for(let r of e)r&&(n=!0,gh.test(r)||t.push(r));return{candidateNames:e,hasUsableCandidate:n,nonIdentifierNames:t}}function yh(e,t){let n=UD(t)?t:Fu(t);return n.candidateNames.size===0||!n.hasUsableCandidate?!0:n.candidateNames.size<=GD?VD(e,n.candidateNames):WD(e,n)}function VD(e,t){for(let n of t)if(n){if(gh.test(n)){if(qD(n).test(e))return!0;continue}if(e.includes(n))return!0}return!1}function WD(e,t){mh.lastIndex=0;let n;for(;(n=mh.exec(e))!==null;)if(t.candidateNames.has(n[0]))return!0;for(let r of t.nonIdentifierNames)if(e.includes(r))return!0;return!1}function UD(e){return"candidateNames"in e}function qD(e){return new RegExp(`(?<![A-Za-z_$0-9])${Ce(e)}(?![A-Za-z_$0-9])`)}var HD=ie("source-import-paths-by-local-name",{clearGroups:["whole-project","source-file"]});function Sh(e,t){let n=mn(t);return HD.get(e,n,()=>zD(e,n))}function zD(e,t){let n=new Map;for(let r of vt(e,t)){if(!r.sourcePath)continue;let i=r.localName??r.importedName;if(i&&hh(n,i,r.sourcePath),r.kind==="namespace")for(let o of r.usedMembers)hh(n,o,r.sourcePath)}return n}function hh(e,t,n){let r=e.get(t);r||(r=new Set,e.set(t,r)),r.add(n)}function bh(e){let t=new Set;for(let n of e.values())for(let r of n)t.add(r);return t}function Tu(e,t,n){let r=Qi(e).get(n);if(!r||r.length===0)return[];if(r.length===1)return[Zi(r[0])];let i=r.filter(c=>c.file===t);if(i.length>0)return i.map(Zi);let o=Sh(e,t),s=QD(r,o.get(n));if(s.length>0)return s;let a=bh(o);for(let c of a){let l=r.filter(u=>Et(c,u.file));if(l.length>0&&l.length===r.length)return l.map(Zi)}return[]}function GX(e,t,n){let r=Tu(e,t,n);if(r.length>0)return r;let i=Qi(e).get(n);return!i||i.length===0?[]:i.map(Zi)}function xh(e,t,n={}){let r=JD(e,t);if(!r)return[];let i=Xi(e,t);if(n.semantic!==!1&&n.semanticEvidence){let s=n.semanticEvidence.references(e,{...i,leaf:r.identifier,parentTypeName:null,isFunctionLike:!1,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:null});if(s.length>0){let a=KD(e,i.symbol,s);return na(e,a)}}let o=new Map;for(let s of Ue(e)){let a=YD(e,r,s);a.length>0&&o.set(s,a)}return na(e,o)}function KD(e,t,n){let r=new Map;for(let i of n){let o=r.get(i.file)??[];o.push(i.line),r.set(i.file,o)}for(let i of Ue(e)){let o=Ki(e,i,t);o!==null&&r.set(i,o)}return r}function JD(e,t){let n=Xi(e,t);if(!n)return null;let r=Y(n.symbol);return r?{symbolId:n.symbolId,symbol:n.symbol,relativePath:n.relativePath,startLine:n.startLine,endLine:n.endLine,identifier:r}:null}function YD(e,t,n){let r=Ki(e,n,t.symbol);if(r!==null)return r;let i=L(e,n);return!i||i.indexOf(t.identifier)===-1?[]:n!==t.relativePath&&!Tu(e,n,t.identifier).some(s=>s.symbolId===t.symbolId)?[]:ta(e,n,t.identifier,n===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{})}function VX(e,t,n={}){let r=new Map;for(let c of t){if(!c.leaf)continue;let l=r.get(c.leaf)??[];l.push(c),r.set(c.leaf,l)}if(r.size===0)return new Map;let i=new Set(t.map(c=>c.symbolId)),o=new Set(r.keys()),s=Fu(o),a=new Map;for(let c of Ue(e)){if(n.skipPath?.(c)||!yh(L(e,c),s))continue;let l=ph(e,c);l.size!==0&&XD(e,c,l,r,i,a)}return a}function XD(e,t,n,r,i,o){for(let s of n)if(r.has(s))for(let a of Tu(e,t,s)){if(!i.has(a.symbolId)||t===a.relativePath)continue;let c=o.get(a.symbolId);c||(c=new Set,o.set(a.symbolId,c)),c.add(t)}}function Zi(e){return{symbolId:e.symbolId,symbol:e.symbol,relativePath:e.file}}function na(e,t){let n=[],r=new Set;for(let[i,o]of t){let s=k(e,i);for(let a of o){let c=Hr(s,a),l=`${i}|${a}|${c?.symbol??""}`;r.has(l)||(r.add(l),n.push({file:i,line:a,enclosingSymbol:c?.symbol??null}))}}return n}function QD(e,t){if(t)for(let n of t){let r=e.filter(i=>Et(n,i.file));if(r.length>0)return r.map(Zi)}return[]}function UX(e,t){return ia(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT
|
|
299
|
+
m.symbol_id,
|
|
300
|
+
d.relative_path,
|
|
301
|
+
COUNT(*) AS ref_count
|
|
302
|
+
FROM mentions m
|
|
303
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
304
|
+
JOIN documents d ON c.document_id = d.id
|
|
305
|
+
WHERE m.role != 1
|
|
306
|
+
${r}
|
|
307
|
+
${e.pathExclusionsFor("d")}
|
|
308
|
+
GROUP BY m.symbol_id, d.relative_path`,...n??[])})}function qX(e,t){return ia(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT DISTINCT m.symbol_id, d.relative_path
|
|
309
|
+
FROM mentions m
|
|
310
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
311
|
+
JOIN documents d ON c.document_id = d.id
|
|
312
|
+
WHERE m.role != 1
|
|
313
|
+
${r}
|
|
314
|
+
${e.pathExclusionsFor("d")}`,...n??[])}).filter(n=>n.symbol_id!==null)}function HX(e,t){return ia(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT DISTINCT m.symbol_id
|
|
315
|
+
FROM mentions m
|
|
316
|
+
WHERE m.role != 1
|
|
317
|
+
${r}`,...n??[])}).filter(n=>n.symbol_id!==null)}function ra(e,t){let n=ia(e,t,o=>{let s=o?`AND m.symbol_id IN (${o.map(()=>"?").join(",")})`:"";return e.all(`SELECT m.symbol_id, d.relative_path, c.document_id,
|
|
318
|
+
c.start_line AS chunk_start, c.end_line AS chunk_end
|
|
319
|
+
FROM mentions m
|
|
320
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
321
|
+
JOIN documents d ON c.document_id = d.id
|
|
322
|
+
WHERE m.role != 1
|
|
323
|
+
${s}
|
|
324
|
+
${e.pathExclusionsFor("d")}`,...o??[])}),r=new Map;for(let o of n){let s=`${o.symbol_id}\0${o.document_id}\0${o.chunk_start}\0${o.chunk_end}`;r.set(s,o)}let i=t?new Map(t.map((o,s)=>[o,s])):null;return[...r.values()].sort((o,s)=>(i?(i.get(o.symbol_id)??0)-(i.get(s.symbol_id)??0):0)||o.relative_path.localeCompare(s.relative_path)||o.chunk_start-s.chunk_start||o.chunk_end-s.chunk_end||o.symbol_id-s.symbol_id)}function ia(e,t,n){if(!t)return n();if(t.length===0)return[];let r=[];for(let i=0;i<t.length;i+=750)r.push(...n(t.slice(i,i+750)));return r}function ZD(e,t){return Nu(e,[t]).get(t.symbolId)??[]}function Nu(e,t){let n=t.map(o=>({symbolId:o.symbolId,prelude:ik(e,o)})).filter(o=>o.prelude!==null),r=tk(e,n.map(o=>o.symbolId)),i=new Map;for(let{symbolId:o,prelude:s}of n){let a=ek(e,r.get(o)??new Map,s.match,s.identifier);i.set(o,na(e,a))}return i}function eQ(e,t,n={}){return Lu(e,t,n).map(r=>({file:r.file,line:r.line,enclosingSymbol:r.enclosingSymbol}))}function Lu(e,t,n={}){let r=xh(e,t,{semantic:n.semantic,semanticEvidence:n.semanticEvidence}),i=r.length>0?vh(r,"source-attribution"):vh(ZD(e,t),"scip-reference-chunk");return n.includeIgnored===!0?i:i.filter(o=>!e.isIgnored(o.file))}function vh(e,t){return e.map(n=>({...n,provenance:t}))}function ek(e,t,n,r){let i=new Map;for(let[o,s]of t)i.set(o,nk(e,o,s,n,r));return i}function tk(e,t){let n=new Map;for(let r of ra(e,t)){if(e.isIgnored(r.relative_path))continue;let i=n.get(r.symbol_id);i||(i=new Map,n.set(r.symbol_id,i));let o=i.get(r.relative_path);o||(o=[],i.set(r.relative_path,o)),o.push({start_line:r.chunk_start,end_line:r.chunk_end})}return n}function nk(e,t,n,r,i){let o=r.symbol?Ki(e,t,r.symbol):null;if(o!==null)return o;let s=t===r.relativePath?{excludeStartLine:r.startLine,excludeEndLine:r.endLine}:{},a=i?ta(e,t,i,s):[];return n.flatMap(c=>rk(a,c))}function rk(e,t){let n=e.filter(r=>r>=t.start_line&&r<=t.end_line);return n.length>0?n:[t.start_line]}function ik(e,t){let n=Xi(e,t);return n?{match:n,identifier:Y(n.symbol)||null}:null}function Dt(e){return e?`${e.startLine}:${e.startColumn}:${e.endLine}:${e.endColumn}`:""}function tn(e,t,n,r){let i=new Map;if(n.length===0)return i;r??=$i(e,t)??[];let o=new Set;for(let s of n){let a=ir(e,t,s,r);if(!a||a.startColumn===void 0||a.endColumn===void 0)continue;let c=Dt({...a,startColumn:a.startColumn,endColumn:a.endColumn});i.has(c)?o.add(c):i.set(c,s)}for(let s of o)i.delete(s);return i}function ir(e,t,n,r=$i(e,t)??[]){let i=Y(n.symbol),o=i==="<constructor>"?"constructor":i,s=r.filter(c=>c.name===o&&c.startLine>=n.startLine&&c.endLine<=n.endLine&&(c.startLine!==n.startLine||c.startColumn===void 0||c.startColumn>=(n.startChar??0))&&(c.endLine!==n.endLine||c.endColumn===void 0||!n.endChar||c.endColumn<=n.endChar)),a=s.filter(c=>!s.some(l=>l!==c&&(l.startLine<c.startLine||l.startLine===c.startLine&&(l.startColumn??0)<(c.startColumn??0))&&(l.endLine>c.endLine||l.endLine===c.endLine&&(l.endColumn??Number.MAX_SAFE_INTEGER)>=(c.endColumn??0))));return a.length===1?a[0]:void 0}import{SymbolInformation_Kind as X}from"@c4312/scip";var Rh=new Map(Object.entries(X).filter(([e,t])=>Number.isInteger(Number(e))&&typeof t=="string").map(([e,t])=>[Number(e),t])),sQ=new Map([...Rh.entries()].map(([e,t])=>[t.toLowerCase(),e]));function aQ(e){return Rh.get(e)??"Unknown"}function Ih(){return[X.Function,X.Method,X.Macro,X.Constructor,X.Getter,X.Setter,X.StaticMethod,X.SingletonMethod,X.AbstractMethod,X.ProtocolMethod,X.TraitMethod]}function Ch(){return[X.Class,X.Interface,X.Struct,X.Trait,X.Type,X.TypeAlias,X.Enum,X.Union,X.Protocol]}import{ts as Je}from"@ts-morph/common";import{createHash as ok}from"crypto";import{ts as v}from"@ts-morph/common";function Eh(e){return"elements"in e?e.elements.flatMap(t=>"name"in t?Eh(t.name):[]):[e.text]}var dQ="typescript-function-local-v1";function _u(e){return ok("sha256").update(e).digest("hex")}function pQ(e,t){let{sourceFile:n,checker:r,errors:i}=eo(e,t),o=[];function s(a,c){if(oa(a)){let u=lk(a,n),d=[...c,u];o.push(uk(a,n,d.join("."),r)),v.forEachChild(a,p=>s(p,d));return}let l=(v.isClassDeclaration(a)||v.isClassExpression(a))&&a.name?a.name.text:v.isVariableDeclaration(a)&&a.initializer&&!oa(a.initializer)||v.isModuleDeclaration(a)?a.name.getText(n):null;v.forEachChild(a,u=>s(u,l?[...c,l]:c))}return i.length===0&&s(n,[]),{sourceFile:n,checker:r,functions:o,exports:i.length?[]:sk(n),errors:i}}function sk(e){let t=[];for(let n of e.statements){let r=ak(n,e);r&&t.push({file:e.fileName,startLine:e.getLineAndCharacterOfPosition(n.getStart(e)).line+1,endLine:e.getLineAndCharacterOfPosition(n.getEnd()-1).line+1,names:r,syntax:v.isVariableStatement(n)?"VariableStatement":v.SyntaxKind[n.kind],...v.isExportDeclaration(n)&&n.moduleSpecifier?{from:v.isStringLiteralLike(n.moduleSpecifier)?n.moduleSpecifier.text:n.moduleSpecifier.getText(e)}:{}})}return t}function ak(e,t){if(v.isExportDeclaration(e)){let n=e.exportClause;return n?v.isNamedExports(n)?n.elements.map(r=>r.name.text):[n.name.text]:["*"]}return v.isExportAssignment(e)?[e.isExportEquals?"export=":"default"]:ck(e,t)}function ck(e,t){let n=v.canHaveModifiers(e)?v.getModifiers(e):void 0;if(n?.some(r=>r.kind===v.SyntaxKind.ExportKeyword))return n.some(r=>r.kind===v.SyntaxKind.DefaultKeyword)?["default"]:v.isVariableStatement(e)?e.declarationList.declarations.flatMap(r=>Eh(r.name)):"name"in e&&e.name?[e.name.getText(t)]:[]}function oa(e){return v.isFunctionLike(e)&&"body"in e&&!!e.body}function lk(e,t){if(v.isConstructorDeclaration(e))return"constructor";if(v.isGetAccessor(e))return`get ${e.name.getText(t)}`;if(v.isSetAccessor(e))return`set ${e.name.getText(t)}`;if(e.name)return e.name.getText(t);let n=e.parent;if(v.isVariableDeclaration(n)||v.isPropertyAssignment(n)||v.isPropertyDeclaration(n))return n.name.getText(t);if(v.isCallExpression(n))return`<callback:${n.expression.getText(t)}:${n.arguments.indexOf(e)}>`;let r=t.getLineAndCharacterOfPosition(e.getStart(t));return`<anonymous@${r.line+1}:${r.character+1}>`}function uk(e,t,n,r){let i=new Du(t);i.visit(e.body,0);let o=i.contributions,s=e.getStart(t),a=e.getEnd(),c=mk(e,t,r);return{name:n,file:t.fileName,startLine:t.getLineAndCharacterOfPosition(s).line+1,endLine:t.getLineAndCharacterOfPosition(a-1).line+1,startOffset:s,endOffset:a,sourceHash:_u(t.text.slice(s,a)),bodyHash:_u(c.exact.join(`
|
|
325
|
+
`)),renamedBodyHash:_u(c.renamed.join(`
|
|
326
|
+
`)),tokenCount:c.exact.length,cyclomatic:1+o.reduce((l,u)=>l+u.cyclomatic,0),cognitive:o.reduce((l,u)=>l+u.cognitive,0),contributions:o}}var Du=class{constructor(t){this.file=t}file;contributions=[];visit(t,n){if(!oa(t)){if(v.isIfStatement(t)){this.visitIf(t,n);return}if(dk(t)||v.isCatchClause(t)||v.isConditionalExpression(t)){this.add(t,v.SyntaxKind[t.kind],1,n+1),v.forEachChild(t,r=>this.visit(r,n+1));return}if(v.isSwitchStatement(t)){this.add(t,"switch",0,n+1),this.visit(t.expression,n),this.visit(t.caseBlock,n+1);return}v.isCaseClause(t)&&this.add(t,"case",1,0),this.recordLogicalOperator(t),this.recordLabeledJump(t),v.forEachChild(t,r=>this.visit(r,n))}}visitIf(t,n){let r=v.isIfStatement(t.parent)&&t.parent.elseStatement===t;this.add(t,r?"else-if":"if",1,r?1:n+1),this.visit(t.expression,n),this.visit(t.thenStatement,n+1),t.elseStatement&&(v.isIfStatement(t.elseStatement)||this.add(t.elseStatement,"else",0,1),this.visit(t.elseStatement,v.isIfStatement(t.elseStatement)?n:n+1))}recordLogicalOperator(t){if(!v.isBinaryExpression(t)||!pk(t.operatorToken.kind))return;let n=t.operatorToken.kind,r=fk(t),i=v.isBinaryExpression(r)&&r.operatorToken.kind===n;this.add(t.operatorToken,v.tokenToString(n)??"logical",1,n===v.SyntaxKind.QuestionQuestionToken||i?0:1)}recordLabeledJump(t){(v.isBreakStatement(t)||v.isContinueStatement(t))&&t.label&&this.add(t,"labeled-jump",0,1)}add(t,n,r,i){let o=this.file.getLineAndCharacterOfPosition(t.getStart(this.file));this.contributions.push({line:o.line+1,column:o.character+1,kind:n,cyclomatic:r,cognitive:i})}};function dk(e){return v.isForStatement(e)||v.isForInStatement(e)||v.isForOfStatement(e)||v.isWhileStatement(e)||v.isDoStatement(e)}function pk(e){return e===v.SyntaxKind.AmpersandAmpersandToken||e===v.SyntaxKind.BarBarToken||e===v.SyntaxKind.QuestionQuestionToken}function fk(e){let t=e.parent;for(;v.isParenthesizedExpression(t);)t=t.parent;return t}function mk(e,t,n){let r=new Map,i=l=>{if(v.isIdentifier(l)){let u=n.getSymbolAtLocation(l);u&&!r.has(u)&&r.set(u,`local:${r.size}`)}else for(let u of l.elements)v.isBindingElement(u)&&i(u.name)};for(let l of e.parameters)i(l.name);let o=l=>{oa(l)||(v.isVariableDeclaration(l)&&i(l.name),v.forEachChild(l,o))};o(e.body);let s=[],a=[],c=l=>{let u=l.getChildren(t);if(u.length>0){for(let h of u)c(h);return}let d=l.getText(t);if(!d)return;s.push(`${l.kind}:${d}`);let p=v.isIdentifier(l)&&!gk(l)?n.getSymbolAtLocation(l):void 0,f=p?r.get(p)??d:d;a.push(`${l.kind}:${f}`)};return c(e.body),{exact:s,renamed:a}}function gk(e){let t=e.parent;return v.isShorthandPropertyAssignment(t)?!0:v.isBindingElement(t)?yk(e,t):v.isPropertyAccessExpression(t)||v.isPropertyAssignment(t)||v.isMethodDeclaration(t)?t.name===e:!1}function yk(e,t){return t.propertyName?t.propertyName===e:t.name===e&&!t.dotDotDotToken&&v.isObjectBindingPattern(t.parent)}function eo(e,t){let n=v.createSourceFile(e,t,v.ScriptTarget.Latest,!0),i=(n.parseDiagnostics??[]).map(s=>{let a=n.getLineAndCharacterOfPosition(s.start??0).line+1;return`${e}:${a}: ${v.flattenDiagnosticMessageText(s.messageText," ")}`}),o;return{sourceFile:n,get checker(){return o??=hk(n)},errors:i}}function hk(e){let t=r=>r===e.fileName||r==="/"+e.fileName,n={getSourceFile:r=>t(r)?e:void 0,getDefaultLibFileName:()=>"",writeFile:()=>{},getCurrentDirectory:()=>"/",getDirectories:()=>[],fileExists:t,readFile:r=>t(r)?e.text:void 0,useCaseSensitiveFileNames:()=>!0,getCanonicalFileName:r=>r,getNewLine:()=>`
|
|
327
|
+
`};return v.createProgram([e.fileName],{noLib:!0,noResolve:!0,allowJs:!0,target:v.ScriptTarget.Latest},n).getTypeChecker()}function ku(e,t){let n=[],r=(o,s,a)=>{if(!o)return;let c=Je.isStringLiteralLike(o);n.push({specifier:c?o.text:o.getText(e),literal:c,line:e.getLineAndCharacterOfPosition(o.getStart(e)).line+1,kind:s,syntax:a})},i=o=>{if(Je.isImportDeclaration(o))r(o.moduleSpecifier,bk(o),"import");else if(Je.isExportDeclaration(o))r(o.moduleSpecifier,xk(o),"reexport");else if(Je.isImportEqualsDeclaration(o)&&Je.isExternalModuleReference(o.moduleReference))r(o.moduleReference.expression,o.isTypeOnly?"type":"value","require");else if(Je.isImportTypeNode(o)&&Je.isLiteralTypeNode(o.argument))r(o.argument.literal,"type","type-import");else if(Je.isCallExpression(o)){let s=Sk(o,t);s&&r(o.arguments[0],"value",s)}Je.forEachChild(o,i)};return i(e),n}function Ph(e,t){let n=eo(e,t);return n.errors.length?null:ku(n.sourceFile,()=>n.checker)}function Sk(e,t){if(e.expression.kind===Je.SyntaxKind.ImportKeyword)return"dynamic-import";if(Je.isIdentifier(e.expression)&&e.expression.text==="require"&&!(typeof t=="function"?t():t).getSymbolAtLocation(e.expression))return"require"}function bk(e){let t=e.importClause;if(t?.isTypeOnly)return"type";let n=t?.namedBindings;return!t?.name&&n&&Je.isNamedImports(n)&&n.elements.length>0&&n.elements.every(r=>r.isTypeOnly)?"type":"value"}function xk(e){let t=e.exportClause;return e.isTypeOnly||t&&Je.isNamedExports(t)&&t.elements.length>0&&t.elements.every(n=>n.isTypeOnly)?"type":"value"}import{extname as Uk}from"path";import{ts as F}from"@ts-morph/common";import{ts as O}from"@ts-morph/common";function sa(e){for(let t=e.parent;t;t=t.parent)if(O.isFunctionLike(t))return t;return null}function aa(e,t,n=new Set){let r=new Set;for(e=q(e);O.isIdentifier(e)&&!r.has(e);){r.add(e);let i=Be(e,t);if(!i||n.has(i))return;if(!O.isVariableDeclaration(i)||!i.initializer||!(i.parent.flags&O.NodeFlags.Const)||!O.isIdentifier(q(i.initializer)))return i;e=q(i.initializer)}}function Be(e,t){if(O.isIdentifier(e)){let n=O.isShorthandPropertyAssignment(e.parent)?t.getShorthandAssignmentValueSymbol(e.parent):t.getSymbolAtLocation(e);return n?.valueDeclaration??n?.declarations?.find(r=>O.isImportSpecifier(r)||O.isImportClause(r)||O.isNamespaceImport(r))}if(e.kind===O.SyntaxKind.ThisKeyword){for(let n=e.parent;n;n=n.parent)if(O.isFunctionLike(n)&&!O.isArrowFunction(n))return n}}function wh(e){for(;O.isBindingElement(e);)e=e.parent.parent;return O.isParameter(e)}function q(e){for(;O.isParenthesizedExpression(e)||O.isAsExpression(e)||O.isTypeAssertionExpression(e)||O.isSatisfiesExpression(e)||O.isNonNullExpression(e);)e=e.expression;return e}function to(e,t,n=new Set,r=new Set){if(e=q(e),O.isPropertyAccessExpression(e)||O.isElementAccessExpression(e)){let s=to(e.expression,t,n,r);if(!s)return;let a=O.isPropertyAccessExpression(e)?e.name.text:kt(e.argumentExpression);return{...s,path:[...s.path,a]}}let i=Be(e,t);if(!i||r.has(i))return;if(r.add(i),n.has(i))return{binding:i,path:[],reassigned:!0};let o=vk(i);return o?to(o,t,n,r):{binding:i,path:[],reassigned:!1}}function vk(e){if(!O.isVariableDeclaration(e)||!e.initializer||!(e.parent.flags&O.NodeFlags.Const))return;let t=q(e.initializer);return O.isIdentifier(t)||O.isPropertyAccessExpression(t)||O.isElementAccessExpression(t)?t:void 0}function kt(e){return e=q(e),O.isStringLiteralLike(e)||O.isNumericLiteral(e)?e.text:null}function no(e,t){return e.slice(0,Math.min(e.length,t.length)).every((n,r)=>n===null||t[r]===null||n===t[r])}function Fh(e,t,n){let r=q(e),i=new Set;for(;O.isIdentifier(r);){let o=Be(r,t);if(!o||i.has(o))return null;let s=Rk(o,n);if(!s)return null;i.add(o),r=q(s)}return r}function Rk(e,t){return O.isVariableDeclaration(e)&&e.parent.flags&O.NodeFlags.Const&&!t.has(e)?e.initializer:void 0}import{ts as S}from"@ts-morph/common";function Th(e,t){let n=new Set,r=u=>{for(let d of wk(u)){let p=Be(d,t);p&&n.add(p)}S.isCallExpression(u)&&Pk(u,t,n),S.forEachChild(u,r)};r(e);let i,o=()=>i??=Ik(e,t),s,a=()=>s??=Ck(o(),t),c,l=()=>c??=Ek(e,t,o().aliases);return{written:n,hasEscapedValue(u,d){return At(u,t,o().aliases,new Set,d).some(p=>l().some(f=>f.binding===p.binding&&f.path.length<=p.path.length&&no(f.path,p.path)))},usesParameter(u){return At(u,t,o().aliases).some(({binding:d})=>wh(d))},hasWrite(u,d,p,f,h=u){let b=to(u,t,n);if(b)return b.reassigned||d&&At(u,t,o().aliases,new Set,p).some(x=>(a().get(x.binding)??[]).some(m=>(!h||!(m.source.getStart()<=h.getStart()&&m.source.end>=h.end))&&(f||m.path.length<=x.path.length)&&no(m.path,x.path)))}}}function Ik(e,t){let n=new Map,r=[],i=[],o=s=>{Lk(s,t,n),r.push(...Fk(s)),(S.isCallExpression(s)||S.isNewExpression(s))&&i.push(s),S.forEachChild(s,o)};o(e);for(let s of i)Tk(s,t,n);return{aliases:n,memberWrites:r,calls:i}}function Ck({aliases:e,memberWrites:t,calls:n},r){let i=new Map,o=(s,a,c,l)=>{for(let u of At(s,r,e,new Set,a)){let d=i.get(u.binding)??[];d.push({path:u.path,source:c,unknown:l}),i.set(u.binding,d)}};for(let s of t)o(s,[],s,!1);for(let s of n)for(let a of Nk(s,r)){if(!a.unknown){o(a.target,a.path,s,!1);continue}for(let c of la(a.target,r,e,new Set,a.path.slice(0,-1))){let l=i.get(c.binding)??[];l.push({path:c.path,source:s,unknown:!0}),i.set(c.binding,l)}}return i}function Ek(e,t,n){let r=t.getSymbolAtLocation(e);return r?t.getExportsOfModule(r).flatMap(i=>{let s=(i.flags&S.SymbolFlags.Alias?t.getAliasedSymbol(i):i).valueDeclaration;if(!s||s.getSourceFile()!==e)return[];let a=S.isVariableDeclaration(s)?s.initializer:s;return a?la(a,t,n,new Set).filter(c=>c.binding!==s):[]}):[]}function Pk(e,t,n){if(!S.isCallExpression(e)||e.questionDotToken)return;let r=q(e.expression);if(!(!S.isIdentifier(r)||r.text!=="eval"||Be(r,t)))for(let i of t.getSymbolsInScope(e,S.SymbolFlags.Value|S.SymbolFlags.Alias)){let o=i.valueDeclaration??i.declarations?.[0];o&&n.add(o)}}function Nh(e){if(S.isBinaryExpression(e)&&e.operatorToken.kind>=S.SyntaxKind.FirstAssignment&&e.operatorToken.kind<=S.SyntaxKind.LastAssignment)return e.left;if((S.isPrefixUnaryExpression(e)||S.isPostfixUnaryExpression(e))&&(e.operator===S.SyntaxKind.PlusPlusToken||e.operator===S.SyntaxKind.MinusMinusToken))return e.operand;if(S.isForOfStatement(e)||S.isForInStatement(e))return e.initializer}function wk(e){let t=Nh(e);return t?_h(t):[]}function Lh(e){let t=q(e);return t!==e?[t]:S.isSpreadElement(e)||S.isSpreadAssignment(e)?[e.expression]:S.isArrayLiteralExpression(e)?e.elements:S.isObjectLiteralExpression(e)?e.properties:S.isPropertyAssignment(e)?[e.initializer]:S.isBinaryExpression(e)&&e.operatorToken.kind===S.SyntaxKind.EqualsToken?[e.left]:[]}function _h(e){return S.isIdentifier(e)?[e]:S.isShorthandPropertyAssignment(e)?[e.name]:Lh(e).flatMap(_h)}function Fk(e){let t=S.isDeleteExpression(e)?e.expression:Nh(e);return t?Dh(t):[]}function Dh(e){return S.isPropertyAccessExpression(e)||S.isElementAccessExpression(e)?[e]:Lh(e).flatMap(Dh)}function Tk(e,t,n){let r=ua(e.expression,t);if(!r)return;let i=q(e.expression);(S.isPropertyAccessExpression(i)||S.isElementAccessExpression(i))&&Au(r,{expression:i.expression,path:[]},n);for(let[o,s]of r.parameters.entries()){let a=e.arguments?.[o];a&&!S.isSpreadElement(a)&&!s.dotDotDotToken&&Jr(s.name,{expression:a,path:[]},t,n)}}function ua(e,t){if(e=q(e),S.isArrowFunction(e)||S.isFunctionExpression(e))return e;let n=S.isElementAccessExpression(e)?kt(e.argumentExpression):null,r=n!==null&&S.isElementAccessExpression(e)?t.getTypeAtLocation(e.expression).getProperty(n):t.getSymbolAtLocation(e),i=S.isIdentifier(e)?Be(e,t):r?.valueDeclaration,o=i&&(S.isVariableDeclaration(i)||S.isPropertyAssignment(i))?i.initializer:i;return o&&S.isFunctionLike(o)&&"body"in o&&o.body?o:void 0}function da(e){let t=e.body;if(!t)return[];if(!S.isBlock(t))return[t];let n=[],r=i=>{S.isFunctionLike(i)||(S.isReturnStatement(i)&&i.expression&&n.push(i.expression),S.forEachChild(i,r))};return r(t),n}function Nk(e,t){let n=q(e.expression),r=e.arguments??[],i=Gk(e,t);if(i)return i;if(ua(n,t))return[];let o=[...r];return(S.isPropertyAccessExpression(n)||S.isElementAccessExpression(n))&&o.push(n.expression),o.map(s=>({target:S.isSpreadElement(s)?s.expression:s,path:S.isIdentifier(s)&&S.isNamespaceImport(Be(s,t)??s)?[null,null]:[null],unknown:!0}))}function Lk(e,t,n){if(S.isVariableDeclaration(e)&&e.initializer&&Jr(e.name,{expression:e.initializer,path:[]},t,n),S.isBinaryExpression(e)&&[S.SyntaxKind.EqualsToken,S.SyntaxKind.AmpersandAmpersandEqualsToken,S.SyntaxKind.BarBarEqualsToken,S.SyntaxKind.QuestionQuestionEqualsToken].includes(e.operatorToken.kind)&&Jr(e.left,{expression:e.right,path:[]},t,n),S.isForOfStatement(e)){let r=S.isVariableDeclarationList(e.initializer)?e.initializer.declarations[0]?.name:e.initializer;r&&Jr(r,{expression:e.expression,path:[null]},t,n)}}function Jr(e,t,n,r){if(e=q(e),S.isPropertyAccessExpression(e)||S.isElementAccessExpression(e)){let i=to(e,n);i&&Au(i.binding,{...t,targetPath:i.path},r);return}if(S.isIdentifier(e)){Au(Be(e,n),t,r);return}for(let i of _k(e))Jr(i.target,{...t,path:[...t.path,...i.path],shallowCopy:t.shallowCopy||i.shallowCopy,arrayRestOffset:i.arrayRestOffset??t.arrayRestOffset},n,r),i.fallback&&Jr(i.target,{expression:i.fallback,path:[]},n,r)}function Au(e,t,n){if(!e)return;let r=n.get(e)??[];r.push(t),n.set(e,r)}function _k(e){return S.isObjectBindingPattern(e)||S.isArrayBindingPattern(e)?e.elements.flatMap((t,n)=>{if(!S.isBindingElement(t))return[];if(t.dotDotDotToken)return[{target:t.name,path:[],shallowCopy:!0,...S.isArrayBindingPattern(e)?{arrayRestOffset:n}:{}}];let r=S.isArrayBindingPattern(e)?String(n):ca(t.propertyName??t.name);return[{target:t.name,path:[r],fallback:t.initializer}]}):S.isObjectLiteralExpression(e)?e.properties.flatMap(t=>S.isSpreadAssignment(t)?[{target:t.expression,path:[],shallowCopy:!0}]:S.isPropertyAssignment(t)?[{target:t.initializer,path:[ca(t.name)]}]:S.isShorthandPropertyAssignment(t)?[{target:t.name,path:[t.name.text],fallback:t.objectAssignmentInitializer}]:[]):S.isArrayLiteralExpression(e)?e.elements.map((t,n)=>({target:t,path:[String(n)]})):S.isBinaryExpression(e)&&e.operatorToken.kind===S.SyntaxKind.EqualsToken?[{target:e.left,path:[],fallback:e.right}]:[]}function ca(e){return S.isIdentifier(e)?e.text:kt(S.isComputedPropertyName(e)?e.expression:e)}function At(e,t,n,r=new Set,i=[]){if(e=q(e),S.isPropertyAccessExpression(e)||S.isElementAccessExpression(e)){let c=S.isPropertyAccessExpression(e)?e.name.text:kt(e.argumentExpression);return At(e.expression,t,n,r,[c,...i])}let o=Bk(e);if(o)return o.flatMap(c=>At(c,t,n,r,i));if(S.isCallExpression(e))return $k(e,t,n,r,i);if(S.isObjectLiteralExpression(e)||S.isArrayLiteralExpression(e))return Ah(e,i).flatMap(c=>At(c.expression,t,n,r,c.path));let s=Be(e,t);if(!s||r.has(s))return[];let a=new Set(r).add(s);return[{binding:s,path:i},...(n.get(s)??[]).flatMap(c=>{let l=kh(c,i);return l?At(c.expression,t,n,a,l):[]})]}function kh(e,t){let n=e.targetPath??[];if(e.targetPath&&t.length<=n.length||n.length>t.length||!no(n,t))return null;let r=t.slice(n.length);if(e.shallowCopy&&r.length<2)return null;if(e.arrayRestOffset!==void 0){let[i,...o]=r;return[...e.path,i===null?null:String(Number(i)+e.arrayRestOffset),...o]}return[...e.path,...r]}function Ah(e,t){return t.length<2?[]:S.isObjectLiteralExpression(e)?Dk(e,t):Ak(e,t)}function Dk(e,t){let n=[];for(let r of[...e.properties].reverse()){if(S.isSpreadAssignment(r)){n.push({expression:r.expression,path:t});continue}let i=ca(r.name);if(!(t[0]!==null&&i!==null&&i!==t[0])&&(n.push(...kk(r).map(o=>({expression:o,path:t.slice(1)}))),t[0]!==null&&i===t[0]))break}return n}function kk(e){return S.isPropertyAssignment(e)?[e.initializer]:S.isShorthandPropertyAssignment(e)?[e.name]:S.isGetAccessorDeclaration(e)?da(e):S.isMethodDeclaration(e)?[e]:[]}function Ak(e,t){let n=t[0]===null||e.elements.some(S.isSpreadElement);return e.elements.flatMap((r,i)=>!n&&String(i)!==t[0]?[]:S.isSpreadElement(r)?[{expression:r.expression,path:[null,...t.slice(1)]}]:[{expression:r,path:t.slice(1)}])}function la(e,t,n,r,i=[]){let o=q(e);if(r.has(o))return[];let s=new Set(r).add(o),a=l=>la(l.expression,t,n,s,l.path);if(S.isPropertyAccessExpression(o)||S.isElementAccessExpression(o)){let l=S.isPropertyAccessExpression(o)?o.name.text:kt(o.argumentExpression);return a({expression:o.expression,path:[l,...i]})}let c=Be(o,t);if(c){if(r.has(c))return[];let l=(n.get(c)??[]).flatMap(u=>{let d=Ok(u,i);return d?la(u.expression,t,n,new Set(s).add(c),d):[]});return[{binding:c,path:[...i,null]},...l]}return Mk(o,i,t).flatMap(a)}function Ok(e,t){let n=e.targetPath;if(n&&t.length<n.length&&no(n,t))return e.path;let r=e.shallowCopy&&t.length===0?[null,null]:[...t,null],i=kh(e,r);return i?i.slice(0,-1):null}function Mk(e,t,n){if(S.isFunctionLike(e)&&"body"in e&&e.body)return da(e).map(r=>({expression:r,path:t}));if(S.isObjectLiteralExpression(e)||S.isArrayLiteralExpression(e)){let r=t.length?[...t,null]:[null,null];return Ah(e,r).map(i=>({...i,path:i.path.slice(0,-1)}))}return S.isConditionalExpression(e)?[e.whenTrue,e.whenFalse].map(r=>({expression:r,path:t})):S.isBinaryExpression(e)?[e.left,e.right].map(r=>({expression:r,path:t})):S.isCallExpression(e)||S.isNewExpression(e)?jk(e,t,n):[]}function jk(e,t,n){let r=ua(e.expression,n);return(r?da(r):[...e.arguments??[]]).map(o=>({expression:S.isSpreadElement(o)?o.expression:o,path:t}))}function Bk(e){if(S.isConditionalExpression(e))return[e.whenTrue,e.whenFalse];if(!S.isBinaryExpression(e))return null;let t=e.operatorToken.kind;return t===S.SyntaxKind.EqualsToken?[e.right]:[S.SyntaxKind.AmpersandAmpersandToken,S.SyntaxKind.BarBarToken,S.SyntaxKind.QuestionQuestionToken,S.SyntaxKind.AmpersandAmpersandEqualsToken,S.SyntaxKind.BarBarEqualsToken,S.SyntaxKind.QuestionQuestionEqualsToken].includes(t)?[e.left,e.right]:null}function $k(e,t,n,r,i){if(Mh(e,t)==="Object.assign")return e.arguments.flatMap((s,a)=>a===0||i.length>=2?At(s,t,n,r,i):[]);let o=ua(e.expression,t);return!o||r.has(o)?[]:da(o).flatMap(s=>At(s,t,n,new Set(r).add(o),i))}function Gk(e,t){let n=e.arguments??[],r=n[0];if(!r)return null;switch(Mh(e,t)){case"Reflect.set":return Vk(r,n,t);case"Object.defineProperty":return Oh(n[2])?[{target:r,path:[null],unknown:!0}]:[{target:r,path:[n[1]?kt(n[1]):null],unknown:!1}];case"Object.defineProperties":return Wk(n[1])?[{target:r,path:[null],unknown:!0}]:Ou(n[1]).map(i=>({target:r,path:[i],unknown:!1}));case"Object.assign":return n.slice(1).flatMap(Ou).map(i=>({target:r,path:[i],unknown:!1}));default:return null}}function Vk(e,t,n){let r=t[1]?kt(t[1]):null,i=t[3]??e,o=r===null?void 0:n.getTypeAtLocation(e).getProperty(r)?.valueDeclaration,s=q(e),a=!!o&&[S.SyntaxKind.PropertyAssignment,S.SyntaxKind.PropertyDeclaration,S.SyntaxKind.MethodDeclaration].includes(o.kind),l=S.isObjectLiteralExpression(s)&&s.properties.length===0||t[3]===void 0&&a;return[{target:i,path:l?[r]:[null],unknown:!l}]}function Oh(e){return!e||Ou(e).some(t=>t===null||t==="get"||t==="set")}function Wk(e){let t=e&&q(e);return!t||!S.isObjectLiteralExpression(t)?!0:t.properties.some(n=>!S.isPropertyAssignment(n)||Oh(n.initializer))}function Ou(e){let t=q(e);return S.isObjectLiteralExpression(t)?t.properties.map(n=>S.isSpreadAssignment(n)?null:ca(n.name)):[null]}function Mh(e,t){let n=q(e.expression);return!S.isCallExpression(e)||!S.isPropertyAccessExpression(n)||!S.isIdentifier(n.expression)||Be(n.expression,t)?null:`${n.expression.text}.${n.name.text}`}var qk=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"]),jh=new WeakMap;function M(e,t){let n=jh.get(t);if(n)return n;let r=qk.has(Uk(e))?eo(e,t.text):null,i=r&&r.errors.length===0?r:null,o,s=()=>o??=Hk(t,i),a,c=()=>a??=zk(t),l,u=()=>l===void 0?l=i?Th(i.sourceFile,i.checker):null:l,d=new Set,p=()=>u()?.written??d,f=m=>s().expressions.get(`${m.startIndex}:${m.endIndex}`),h=m=>{let g=s().identifiers.get(m.startIndex);if(!(!g||!r))return Be(g,r.checker)},b=(m,g=!1,y=[],I=!0,w=m)=>{let j=f(m);if(!j||!r)return!1;let C=w?f(w)??j:null;return u()?.hasWrite(j,g,y,I,C)??!!h(pa(m))},x={available:!!r&&r.errors.length===0,moduleReferences(){return r&&r.errors.length===0?ku(r.sourceFile,()=>r.checker).map(m=>({...m,line:m.line+t.startPosition.row})):[]},constantInitializer(m){let g=h(m);return!g||!F.isVariableDeclaration(g)||!g.initializer||!(g.parent.flags&F.NodeFlags.Const)||p().has(g)?null:c().get(`${g.initializer.getStart()}:${g.initializer.end}`)??null},callableValue(m){let g=f(m);if(!g||!r)return null;let y=aa(g,r.checker,p()),I=y&&F.isVariableDeclaration(y)?y.initializer:y;return eA(I,c())},hasObservedWrite:b,hasEscapedValue(m,g){let y=f(m);return!!y&&!!u()?.hasEscapedValue(y,g)},hasObservedCallableWrite(m,g=[],y=m){return b(m,!0,g,!1,y)},callableParameters(m){let g=[...s().expressions.values()].filter(y=>F.isFunctionLike(y)&&y.end+t.startIndex===m.endIndex&&y.getStart()+t.startIndex<=m.startIndex);return g.length!==1||!F.isFunctionLike(g[0])?null:g[0].parameters.filter(y=>y.name.getText()!=="this").map(y=>y.dotDotDotToken?"rest":y.initializer?"default":F.isIdentifier(y.name)?"direct":"destructured")},hasLocalBinding(m){let g=s().identifiers.get(pa(m).startIndex);return!!g&&!!r?.checker.getSymbolAtLocation(g)?.declarations?.length},isParameterBinding(m){let g=f(m);return!!g&&!!u()?.usesParameter(g)},valueDeclaration(m){if(!r)return null;let g=f(m),y=g&&aa(g,r.checker,p());if(!y||!F.isVariableDeclaration(y)||!F.isIdentifier(y.name))return null;let I=r.sourceFile.getLineAndCharacterOfPosition(y.getStart()),w=r.sourceFile.getLineAndCharacterOfPosition(y.end);return{name:y.name.text,startLine:I.line+t.startPosition.row,startColumn:I.character+(I.line===0?t.startPosition.column:0),endLine:w.line+t.startPosition.row,endColumn:w.character+(w.line===0?t.startPosition.column:0)}},importedValue(m){let g=f(m);return g&&r?ro(g,r.checker,new Set):null},constructedValue(m){let g=f(m);return g&&r?Bh(g,r.checker,new Set):null},resource(m){let g=pa(m),y=h(g);if(!y)return{resourceKey:`access:${m.startIndex}:${m.endIndex}`,identityBasis:"source-access-occurrence"};let I=m.text.slice(g.endIndex-m.startIndex).trim();return{resourceKey:`binding:${y.getStart()}:${y.end}:${I}`,identityBasis:"compiler-binding-access-path"}},isCaptured(m){let g=s().identifiers.get(m.startIndex),y=h(m),I=y&&sa(y),w=g&&sa(g);return!!I&&!!w&&I!==w},directParameterPosition(m){let g=f(m),y=g&&q(g);if(!y||!F.isIdentifier(y)||!r)return null;let I=aa(y,r.checker,p());if(!I||!F.isParameter(I)||!F.isIdentifier(I.name)||sa(y)!==I.parent||p().has(I))return null;let j=I.parent.parameters.filter(C=>C.name.getText()!=="this").indexOf(I);return j>=0?j:null},tupleElements(m){let g=f(m);if(!g||!r||b(m,!0))return null;let y=Fh(g,r.checker,p());if(!y||!F.isArrayLiteralExpression(y)||y.elements.some(w=>F.isSpreadElement(w)||F.isOmittedExpression(w)))return null;let I=y.elements.map(w=>c().get(`${w.getStart()}:${w.end}`));return I.every(w=>!!w)?I:null}};return jh.set(t,x),x}function Hk(e,t){let n=new Map,r=new Map;if(t){let i=o=>{let s=o.getStart(t.sourceFile)+e.startIndex;F.isIdentifier(o)&&n.set(s,o),r.set(`${s}:${o.end+e.startIndex}`,o),F.forEachChild(o,i)};i(t.sourceFile)}return{identifiers:n,expressions:r}}function zk(e){let t=new Map,n=r=>{t.set(`${r.startIndex-e.startIndex}:${r.endIndex-e.startIndex}`,r);for(let i of r.namedChildren)n(i)};return n(e),t}function Bh(e,t,n){if(n.has(e))return null;if(n.add(e),F.isCallExpression(e)||F.isNewExpression(e))return ro(e.expression,t,new Set);if(!F.isIdentifier(e))return null;let r=t.getSymbolAtLocation(e)?.valueDeclaration;return r&&F.isVariableDeclaration(r)&&r.initializer&&r.parent.flags&F.NodeFlags.Const?Bh(r.initializer,t,n):null}function ro(e,t,n){if(n.has(e))return null;if(n.add(e),e=q(e),F.isPropertyAccessExpression(e)||F.isElementAccessExpression(e)){let r=ro(e.expression,t,n),i=F.isPropertyAccessExpression(e)?e.name.text:kt(e.argumentExpression);return r&&i!==null&&(r.member===null||r.member==="default")?{module:r.module,member:i}:null}return F.isCallExpression(e)?Jk(e,t):Kk(e,t,n)}function Kk(e,t,n){if(!F.isIdentifier(e))return null;let r=t.getSymbolAtLocation(e)?.declarations?.[0];return r?F.isVariableDeclaration(r)&&r.initializer&&r.parent.flags&F.NodeFlags.Const?ro(r.initializer,t,n):F.isBindingElement(r)?Qk(r,t,n):Xk(r):null}function Jk(e,t){if(!F.isIdentifier(e.expression)||e.expression.text!=="require")return null;let n=e.arguments[0];return t.getSymbolAtLocation(e.expression)?.valueDeclaration||e.arguments.length!==1||!n||!F.isStringLiteralLike(n)?null:{module:n.text,member:null}}function Yk(e){return F.isImportSpecifier(e)&&!e.isTypeOnly?{member:(e.propertyName??e.name).text}:F.isNamespaceImport(e)?{member:null}:F.isImportClause(e)&&!e.isTypeOnly?{member:"default"}:null}function Xk(e){let t=Yk(e);if(!t)return null;let{member:n}=t;for(let r=e.parent;r;r=r.parent){if(F.isImportClause(r)&&r.isTypeOnly)return null;if(F.isImportDeclaration(r))return F.isStringLiteralLike(r.moduleSpecifier)?{module:r.moduleSpecifier.text,member:n}:null}return null}function Qk(e,t,n){if(!F.isObjectBindingPattern(e.parent)||e.dotDotDotToken||e.initializer)return null;let r=e.parent.parent;if(!F.isVariableDeclaration(r)||!r.initializer||!(r.parent.flags&F.NodeFlags.Const))return null;let i=ro(r.initializer,t,n),o=e.propertyName??e.name;if(!i||i.member!==null)return null;let s=Zk(o);return s===null?null:{module:i.module,member:s}}function Zk(e){return F.isIdentifier(e)||F.isStringLiteralLike(e)?e.text:null}function pa(e){let t=e.childForFieldName("object")??e.childForFieldName("array");return t?pa(t):e}function eA(e,t){if(!e||!(F.isFunctionDeclaration(e)||F.isFunctionExpression(e)||F.isArrowFunction(e)))return null;let n=t.get(`${e.getStart()}:${e.end}`);return n?.type==="export_statement"?n.childForFieldName("declaration"):n??null}var tA=4;function fa(e,t,n,r={}){return $h(e,t,n,r.maxReexportDepth??tA,0,new Set)}function $h(e,t,n,r,i,o){let s=`${t}\0${n}`;if(o.has(s)||i>r)return[];o.add(s);let a=k(e,t).filter(c=>c.leaf===n);return a.length>0?a:Lt(e,t).flatMap(c=>c.sourcePath?c.kind==="named"&&!c.names.includes(n)?[]:$h(e,c.sourcePath,n,r,i+1,new Set(o)):[])}import{ts as Yr}from"@ts-morph/common";var Mu=new WeakMap;function io(e){if(e.type!=="string"&&e.type!=="template_string")return null;if(Mu.has(e))return Mu.get(e);let t=nA(e.text);return Mu.set(e,t),t}function nA(e){let t=Yr.createSourceFile("literal.ts",e,Yr.ScriptTarget.Latest,!1,Yr.ScriptKind.TS);if(t.parseDiagnostics.length>0||t.statements.length!==1)return null;let n=t.statements[0];if(!Yr.isExpressionStatement(n))return null;let r=n.expression;return Yr.isStringLiteralLike(r)?{value:r.text,interpolated:!1}:Yr.isTemplateExpression(r)?{value:r.head.text+r.templateSpans.map(i=>"{}"+i.literal.text).join(""),interpolated:!0}:null}function oo(e,t,n){if(e.length!==3&&e.length!==4)return;let r=e[0],i=e.length===4?e[2]:r,o=Gh(n[r],e[1],t),s=Gh(n[i],e[e.length-1],t);if(!(o===void 0||s===void 0)&&!(i<r||i===r&&s<o))return{startLine:r,startColumn:o,endLine:i,endColumn:s}}function Gh(e,t,n){if(e===void 0||!Number.isSafeInteger(t)||t<0)return;let r=n||([...e.slice(0,t)].every(i=>i.charCodeAt(0)<128)?"UTF-16":void 0);switch(r){case"UTF-16":return t<=e.length?t:void 0;case"UTF-8":case"UTF-32":return rA(e,t,r);default:return}}function rA(e,t,n){let r=0,i=0;for(let o of e){if(r===t)return i;if(r+=n==="UTF-8"?Buffer.byteLength(o,"utf8"):1,i+=o.length,r>t)return}return r===t?i:void 0}import{fromBinary as iA}from"@bufbuild/protobuf";import{DocumentSchema as oA,SymbolRole as ma}from"@c4312/scip";import{zstdDecompressSync as sA}from"zlib";var aA=U("scip-chunk-occurrence-targets",{clearGroups:["whole-project","definition-catalog","source-file"],maxEntries:256}),cA=oe("scip-chunk-occurrence-definitions",{clearGroups:["whole-project","definition-catalog"]}),Vh=1,lA=oe("scip-chunk-occurrence-data-present",{clearGroups:["whole-project"]});function ju(e){return lA.get(e,()=>{let t=e.get("SELECT length(occurrences) AS size FROM chunks LIMIT 1");return t!==void 0&&(t.size??0)>Vh})}function so(e,t){return aA.get(e,t,()=>uA(e,t))}function Bu(e,t){return`${e}\0${t}`}function uA(e,t){let n=e.get("SELECT id, position_encoding FROM documents WHERE relative_path = ?",t);if(!n)return{available:!1,reason:"no-document"};let r=e.all("SELECT occurrences FROM chunks WHERE document_id = ? ORDER BY chunk_index",n.id);if(r.length===0)return ju(e)?{available:!0,targets:[],externalLeafKeys:new Set,locals:[]}:{available:!1,reason:"no-occurrence-data"};let i={targets:[],externalLeafKeys:new Set,locals:[],externalRanges:[]},o=zt(e,t);for(let s of r){let a=dA(s.occurrences);if(!a)return{available:!1,reason:"no-occurrence-data"};let c=pA(e,a);for(let l of a)fA(l,n.position_encoding,o,c,i)}return{available:!0,...i}}function dA(e){if(!e||e.length<=Vh)return null;try{return iA(oA,new Uint8Array(sA(e))).occurrences}catch{return null}}function pA(e,t){let n=cA.get(e,()=>new Map),r=new Set(t.filter(s=>s.symbol&&!s.symbol.startsWith("local ")&&!(s.symbolRoles&ma.Definition)).map(s=>s.symbol)),i=[...r].filter(s=>!n.has(s)),o=Yy(e,i);for(let s of i)n.set(s,null);for(let s of o)n.set(s.symbol,s);for(let s of r){let a=n.get(s);a&&wt(a.relativePath)}return n}function fA(e,t,n,r,i){if(!e.symbol)return;let o=e.range[0];if(!Number.isInteger(o))return;let s=oo(e.range,t,n);if(e.symbol.startsWith("local ")){s&&i.externalRanges.push(s),s&&i.locals.push(mA(e.symbol,s,e.symbolRoles));return}if((e.symbolRoles&ma.Definition)!==0)return;let a=r.get(e.symbol);if(a){i.targets.push({sourceLine:o,...s?{sourceRange:s}:{},definition:a});return}s&&i.externalRanges.push(s);let c=gA(e.symbol);c&&i.externalLeafKeys.add(Bu(o,c))}function mA(e,t,n){return{symbol:e,line:t.startLine,startChar:t.startColumn,endLine:t.endLine,endChar:t.endColumn,definition:(n&ma.Definition)!==0,write:(n&ma.WriteAccess)!==0}}function gA(e){if(e.startsWith("local "))return null;try{let t=Y(e);return t.length>0?t:null}catch{return null}}function Ot(e,t){return!!(e&&t&&e.startLine===t.startLine&&e.startColumn===t.startColumn&&e.endLine===t.endLine&&e.endColumn===t.endColumn)}function ao(e,t,n){let r=M(e.file,e.root).importedValue(t),i=r?.member??n;if(!r||!i)return null;let o=r.member!==null?yA(e,t):null;if(o)return o;let s=Oe(e.db,e.file,r.module),a=s?fa(e.db,s,i):[];return a.length===1?a[0]:null}function yA(e,t){let n=te(t);if(n.type!=="identifier"||Ji(e.db,e.file)?.freshness.semantic.state==="stale")return null;let r={startLine:n.startPosition.row,startColumn:n.startPosition.column,endLine:n.endPosition.row,endColumn:n.endPosition.column},i=so(e.db,e.file);if(!i.available)return null;let o=i.targets.filter(a=>a.definition.relativePath!==e.file&&Ot(a.sourceRange,r)),s=new Map(o.map(a=>[a.definition.symbol,a.definition]));return s.size===1?[...s.values()][0]:null}function ga(e,t){let n=D(e.db,t.relativePath)?.rootNode,r=n&&Vu(n,t);return n&&r?{context:{...e,file:t.relativePath,root:n},declaration:r}:null}function $u(e,t,n){let r=M(e.file,e.root);if(r.hasEscapedValue(t,n))return!0;let i=r.valueDeclaration(t);if(!i)return!1;let o=k(e.db,e.file).filter(c=>c.leaf===i.name&&c.startLine===i.startLine&&(c.startChar??0)<=i.startColumn&&c.endLine>=i.endLine);if(o.length!==1)return!1;let s=o[0].symbol,a=Gu(e.db,s);return Mm(s,a),a.some(c=>c!==e.file&&hA(e,c,s,n))}function Gu(e,t){return e.all(`SELECT DISTINCT d.relative_path FROM global_symbols gs
|
|
328
|
+
JOIN mentions m ON m.symbol_id = gs.id JOIN chunks c ON c.id = m.chunk_id
|
|
329
|
+
JOIN documents d ON d.id = c.document_id WHERE gs.symbol = ?`,t).map(n=>n.relative_path).sort()}function hA(e,t,n,r){let i=Ji(e.db,t),o=D(e.db,t)?.rootNode,s=so(e.db,t);if(!o||!i||i.freshness.semantic.state==="stale"||!s.available)return!0;let a=s.targets.filter(d=>d.definition.symbol===n),c=M(t,o);if(!c.available||a.length===0)return!0;let l=new Set(a),u=!1;return Ne(o,d=>{if(u||!["identifier","property_identifier","shorthand_property_identifier","string","string_fragment","number"].includes(d.type))return;let p={startLine:d.startPosition.row,startColumn:d.startPosition.column,endLine:d.endPosition.row,endColumn:d.endPosition.column},f=a.filter(b=>Ot(b.sourceRange,p));if(f.length===0)return;for(let b of f)l.delete(b);let h=SA(d);u=!h||c.hasObservedWrite(h,!0,r,!1,null)}),u||l.size>0}function SA(e){let t=e.type==="string_fragment"?e.parent??e:e,n=t.parent&&(e.type==="property_identifier"||t.parent.type==="subscript_expression")?t.parent:t;return["identifier","shorthand_property_identifier","member_expression","subscript_expression"].includes(n.type)?n:null}function ya(e,t){let n=M(e.file,e.root).callableValue(t);if(n)return{context:e,callable:n};let r=ao(e,t),i=r&&ga(e,r);if(!i)return null;let o=i.declaration,s=["function_declaration","function_expression","arrow_function","generator_function_declaration"].includes(o.type)?o:M(i.context.file,i.context.root).callableValue(o);return s?{context:i.context,callable:s}:null}function Vu(e,t){let n=[];for(let r of Ft(e,["variable_declarator","function_declaration","generator_function_declaration","function_expression","arrow_function"])){let i=r.childForFieldName("name"),o=!i&&t.symbol.endsWith("/default().")&&xA(r);!o&&i?.text!==t.leaf||r.startPosition.row!==t.startLine||r.endPosition.row>t.endLine||r.startPosition.column<(t.startChar??0)||r.endPosition.row===t.endLine&&t.endChar&&r.endPosition.column>t.endChar||n.push(o?r:i)}return n.length===1?n[0]:null}function En(e,t,n=[],r=new Set,i={file:e.file,node:t}){let o=te(t),s=`${e.file}:${o.startIndex}:${o.endIndex}:${JSON.stringify(n)}`;if(r.has(s))return!1;let a=new Set(r).add(s),c=M(e.file,e.root);if(c.hasObservedCallableWrite(o,n,i.file===e.file?i.node:void 0))return!0;let l=ha(o),u=l?.base??o,d=[...l?.properties??[],...n],p=c.constantInitializer(u);if(p)return En(e,p,d,a,i);let f=c.importedValue(u);if(!f)return!1;let h=ao(e,u,d[0]),b=h&&ga(e,h);if(!b)return!1;let x=f.member===null?d.slice(1):d;return En(b.context,b.declaration,x,a,i)}function ha(e){let t=te(e);if(!["member_expression","subscript_expression"].includes(t.type))return null;let n=t.childForFieldName("object"),r=t.type==="member_expression"?t.childForFieldName("property"):t.childForFieldName("index"),i=r?bA(r):null;if(!n||i===null)return null;let o=ha(n);return o?{base:o.base,properties:[...o.properties,i]}:{base:te(n),properties:[i]}}function bA(e){if(e.type==="property_identifier")return e.text;if(e.type==="number"){let n=Number(e.text.replaceAll("_",""));return Number.isFinite(n)?String(n):null}let t=io(e);return t&&!t.interpolated?t.value:null}function xA(e){let t=e;for(;t.parent;){let n=te(t.parent);if(n.startIndex!==e.startIndex||n.endIndex!==e.endIndex)break;t=t.parent}return t.parent?.type==="export_statement"}import{existsSync as RA}from"fs";import{SymbolRole as IA}from"@c4312/scip";import{deserializeSCIP as vA}from"@c4312/scip";function Wh(e,t){return vA(H(e,{inputKind:t,maxBytes:fe}))}var Wu=new WeakMap;function Mt(e,t){if(Ji(e,t)?.freshness.semantic.state==="stale")return null;let n=so(e,t);if(n.available)return{targets:n.targets,externalLeafKeys:n.externalLeafKeys,externalRanges:n.externalRanges,locals:n.locals};if(n.reason==="no-document")return null;if(ju(e))return{targets:[],externalLeafKeys:new Set,locals:[]};let r=FA(e);return r?{targets:r.byFile.get(t)??[],externalLeafKeys:new Set,externalRanges:r.externalByFile.get(t)??[],locals:[]}:null}function Uh(e,t,n,r,i){let o=Br(e,t)??J(e,t)?.callSites,s=(o??[]).filter(f=>f.line>=n&&f.line<=r);if(!o||s.length===0)return{available:!!o,targets:[],resolvedCallsites:0,unresolvedCallsites:0};let a=Mt(e,t);if(!a)return{available:!1,targets:[],resolvedCallsites:0,unresolvedCallsites:s.length};let c=[],l=[],u=0,d=0,p=0;for(let f of s){let h=a.targets.filter(g=>Ot(g.sourceRange,f.targetRange)),b=new Map(h.map(g=>[g.definition.symbol,g]));if(i&&![...b.keys()].some(g=>i.has(g))||(p++,l.push(...[...b.values()].map(g=>({...g,sourceLine:f.line,sourceOwner:f.owner,calleeLeaf:g.definition.leaf}))),qu(e,t,f))||b.size!==1)continue;let x=[...b.values()][0],m=Uu(e,t,f,x.definition);m.implementationStatus==="established"&&d++,u++,c.push({...x,...m,sourceLine:f.line,sourceOwner:f.owner,calleeLeaf:x.definition.leaf})}return{available:!0,targets:c,resolvedCallsites:u,unresolvedCallsites:p-u,declarations:l,implementationUnresolvedCallsites:p-d}}function Uu(e,t,n,r){let i=Hu(e,t,n);if(!i?.bindings.available){let s=J(e,t)?.language;return s==="typescript"||s==="javascript"?{implementationStatus:"unresolved",implementationReason:"source-binding-unavailable"}:{implementationStatus:"established"}}if(n.kind==="new"&&!n.memberAccess&&(r.isTypeLike||r.leaf==="<constructor>"))return EA(e,r);let o=ya({db:e,file:t,root:i.root},i.target);return o&&o.context.file===r.relativePath&&CA(r,o.callable)?{implementationStatus:"established"}:{implementationStatus:"unresolved",implementationReason:n.memberAccess?"member-value-and-runtime-dispatch-unproved":"indirect-callable-value-unproved"}}function CA(e,t){let{startLine:n,startChar:r,endLine:i,endChar:o}=e;if(r===void 0||o===void 0||n===i&&r>=o)return!1;let s=t.startPosition,a=t.endPosition;return(s.row>n||s.row===n&&s.column>=r)&&(a.row<i||a.row===i&&a.column<=o)}function EA(e,t){let n=D(e,t.relativePath)?.rootNode,r;return n&&Ne(n,o=>{["class_declaration","abstract_class_declaration","class"].includes(o.type)&&PA(o,t)&&(!r||o.endIndex-o.startIndex<r.endIndex-r.startIndex)&&(r=o)}),r?r.namedChildren.some(o=>o.type==="decorator")||r.parent?.type==="export_statement"&&r.parent.namedChildren.some(o=>o.type==="decorator")?{implementationStatus:"unresolved",implementationReason:"class-decorator-runtime-constructor-unproved"}:{implementationStatus:"established"}:{implementationStatus:"unresolved",implementationReason:"constructor-source-unproved"}}function PA(e,t){let{startLine:n,startChar:r,endLine:i,endChar:o}=t;return r===void 0||o===void 0?!1:(e.startPosition.row<n||e.startPosition.row===n&&e.startPosition.column<=r)&&(e.endPosition.row>i||e.endPosition.row===i&&e.endPosition.column>=o)}function qu(e,t,n){let r=Hu(e,t,n);return r?En({db:e,file:t,root:r.root},r.target):!1}function I6(e,t,n){let r=Hu(e,t,n);return r?.bindings.isParameterBinding(r.target)??!1}function Hu(e,t,n){let r=n.targetExpressionRange??n.targetRange,i=D(e,t)?.rootNode;if(!r||!i)return null;let o=st(i,r.startLine,r.endLine,ot,r);return o?{root:i,target:o,bindings:M(t,i)}:null}function wA(e,t,n,r){let i=Mt(e,t);return i?{available:!0,targets:i.targets.filter(o=>o.sourceLine>=n&&o.sourceLine<=r)}:{available:!1,targets:[]}}function C6(e,t,n,r){let i=Mt(e,t);return i?{available:!0,targets:i.targets.filter(o=>o.sourceLine>=n&&o.sourceLine<=r&&LA(e,o.definition)).map(o=>qh(e,t,o))}:{available:!1,targets:[]}}function E6(e,t,n,r){let i=wA(e,t,n,r);return{available:i.available,targets:i.targets.filter(o=>o.definition.isTypeLike).map(o=>qh(e,t,o))}}function qh(e,t,n){let r=D(e,t),i=J(e,t)?.language,o=n.sourceRange,s=r&&o&&st(r.rootNode,o.startLine,o.endLine,ot,o),a=s&&i?jr(s,i):void 0;if(a){let u=tn(e,t,k(e,t)).get(Dt(a));return{...n,calleeLeaf:n.definition.leaf,sourceOwner:a,sourceDefinition:u??null}}let c=o?k(e,t).filter(u=>u.startLine<=o.startLine&&u.endLine>=o.endLine&&(u.startLine!==o.startLine||(u.startChar??0)<=o.startColumn)&&(u.endLine!==o.endLine||u.endChar===void 0||u.endChar>=o.endColumn)):[],l=c.filter(u=>!c.some(d=>d!==u&&d.startLine>=u.startLine&&d.endLine<=u.endLine&&(d.startLine!==u.startLine||(d.startChar??0)>=(u.startChar??0))&&(d.endLine!==u.endLine||(d.endChar??1/0)<=(u.endChar??1/0))));return{...n,calleeLeaf:n.definition.leaf,sourceOwner:a??void 0,sourceDefinition:l.length===1?l[0]:null}}function FA(e){if(We(),Wu.has(e))return Wu.get(e)??null;let t=TA(e);return Wu.set(e,t),t}function TA(e){if(!e.generation.indexPath||!RA(e.generation.indexPath))return null;try{let t=Xs(e),n=new Map(t.map(s=>[s.symbol,s])),r=Wh(e.generation.indexPath,"SCIP source-range call-target index"),i=new Map,o=new Map;for(let s of r.documents??[]){let a=s.relativePath;if(!a||e.isIgnored(a))continue;let{targets:c,externalRanges:l}=NA(e,a,s,n);i.set(a,c),o.set(a,l)}return{byFile:i,externalByFile:o}}catch{return null}}function NA(e,t,n,r){let i=[],o=[],s=zt(e,t),a={1:"UTF-8",2:"UTF-16",3:"UTF-32"}[n.positionEncoding];for(let c of n.occurrences??[]){if(!c.symbol||(c.symbolRoles&IA.Definition)!==0)continue;let l=r.get(c.symbol),u=c.range?.[0];if(!Number.isInteger(u))continue;let d=oo(c.range,a,s);if(!l){d&&o.push(d);continue}i.push({sourceLine:u,...d?{sourceRange:d}:{},definition:l})}return{targets:i,externalRanges:o}}function LA(e,t){if(!t.isFunctionLike)return!1;let n=$i(e,t.relativePath);return!n||n.some(r=>r.name===t.leaf&&r.startLine===t.startLine&&r.endLine===t.endLine)?!0:_A(t)}function _A(e){let t=e.documentation;if(!t)return!1;let n=e.leaf.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`\\bfunction\\s+${n}\\s*(?:<[^>]*>)?\\s*\\(`,"u").test(t)||new RegExp(`\\b(?:const|let|var)\\s+${n}\\s*:\\s*(?:<[^>]*>\\s*)?\\([^\\n]*\\)\\s*=>`,"u").test(t)}function G6(e,t,n={}){let r=Jh(e,[t],{additive:n.additive,semantic:n.semantic,semanticEvidence:n.semanticEvidence}),i=n.callableOnly?(r.get(t.symbolId)??[]).filter(o=>zi(o.symbol)||o.source==="ast-callsite"||o.source==="scip-occurrence"||o.source==="scip-declaration"):r.get(t.symbolId)??[];return typeof n.limit=="number"?i.slice(0,n.limit):i}function V6(e,t,n){return DA(e,[t],n).get(t.symbolId)??[]}function DA(e,t,n){let r=MA(e)?BA(e,t,{semantic:n.semantic!==!1,semanticEvidence:n.semanticEvidence}):jA(e,n.semanticEvidence);return typeof n.limit!="number"?new Map(t.map(i=>[i.symbolId,r.get(i.symbolId)??[]])):new Map(t.map(i=>[i.symbolId,(r.get(i.symbolId)??[]).slice(0,n.limit)]))}var kA=oe("caller-rows",{clearGroups:["whole-project"]}),AA=oe("targeted-caller-strategy",{clearGroups:["whole-project"]}),OA=2e4;function MA(e){return AA.get(e,()=>(e.get("SELECT COUNT(*) AS count FROM global_symbols")?.count??0)>OA)}function jA(e,t){return kA.get(e,()=>{let n=Xs(e),r=Jh(e,n,{semanticEvidence:t}),i=new Map;for(let a of n)i.set(a.symbol,a.symbolId);let o=new Map,s=new Map;for(let a of n){let c=r.get(a.symbolId);!c||c.length===0||iO(a,c,i,o,s)}return o})}function BA(e,t,n){let r=n.semantic&&n.semanticEvidence?t.flatMap(u=>{let d=WA(e,u);return d?[d]:[]}):[],i=new Map(r.map(u=>[u.symbolId,u])),o=n.semanticEvidence?.referenceMap(e,r)??new Map,s=Nu(e,t),a=$A(e,t),c=new Map,l={astCallersByTarget:a,resolvedReferences:s,definitionBySymbolId:i,semanticReferences:o};for(let u of t)c.set(u.symbolId,GA(e,u,l));return c}function $A(e,t){let n=new Set(t.map(a=>a.symbol)),i=[...new Set(t.flatMap(a=>Ly(e,"reverse",[a.relativePath])))].flatMap(a=>k(e,a)),o=new Map,s=Yh(e,i);for(let a of i)for(let c of s.get(a.symbolId)??[]){if(!n.has(c.symbol))continue;let l=o.get(c.symbol)??[];l.push({symbol:a.symbol,file:a.relativePath,source:"caller-map-inversion",callEvidence:c.source}),o.set(c.symbol,l)}return o}function GA(e,t,n){let r=[],i=new Set,o=s=>{if(s.symbol===t.symbol)return;let a=`${s.symbol}|${s.file}`;i.has(a)||(i.add(a),r.push(s))};for(let s of n.astCallersByTarget.get(t.symbol)??[])o(s);for(let s of n.resolvedReferences.get(t.symbolId)??[])s.file!==t.relativePath&&o({symbol:s.enclosingSymbol??s.file,file:s.file,source:"resolved-reference"});return VA(e,t,n,o),r}function VA(e,t,n,r){let i=n.definitionBySymbolId.get(t.symbolId);if(i)for(let o of n.semanticReferences.get(i.symbolId)??[]){if(o.file===t.relativePath||e.isIgnored(o.file))continue;let s=Hr(k(e,o.file),o.line);r({symbol:s?.symbol??o.file,file:o.file,source:"semantic-reference"})}}function WA(e,t){let n=Ih().join(", "),r=Ch().join(", ");return e.get(`SELECT
|
|
330
|
+
d.id AS documentId,
|
|
331
|
+
gs.id AS symbolId,
|
|
332
|
+
gs.symbol,
|
|
333
|
+
d.relative_path AS relativePath,
|
|
334
|
+
COALESCE(der.start_line, c.start_line) AS startLine,
|
|
335
|
+
COALESCE(der.end_line, c.end_line) AS endLine,
|
|
336
|
+
COALESCE(gs.display_name, '') AS leaf,
|
|
337
|
+
NULL AS parentTypeName,
|
|
338
|
+
CASE WHEN gs.kind IN (${n}) OR gs.symbol LIKE '%().' THEN 1 ELSE 0 END AS isFunctionLike,
|
|
339
|
+
CASE WHEN gs.kind IN (${r}) THEN 1 ELSE 0 END AS isTypeLike,
|
|
340
|
+
gs.kind AS kind,
|
|
341
|
+
gs.documentation AS documentation,
|
|
342
|
+
gs.enclosing_symbol AS enclosingSymbol
|
|
343
|
+
FROM global_symbols gs
|
|
344
|
+
LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
|
|
345
|
+
LEFT JOIN chunks c ON c.document_id = der.document_id
|
|
346
|
+
JOIN documents d ON d.id = COALESCE(der.document_id, c.document_id)
|
|
347
|
+
WHERE gs.id = ?
|
|
348
|
+
LIMIT 1`,t.symbolId)??null}function Jh(e,t,n={}){if(t.length===0)return new Map;let r=n.additive??!1,{astDefs:i,chunkOnlyDefs:o}=oO(e,t),s=new Map,a=new Map,c=u=>{for(let[d,p]of u){let f=s.get(d);f||(f=[],s.set(d,f));let h=a.get(d);h||(h=new Map,a.set(d,h));for(let b of p){let x=`${b.symbol}|${b.chunkId}`,m=h.get(x);if(m){zh(m.source)==="candidate"&&zh(b.source)==="exact"&&Object.assign(m,b);continue}let g={...b};h.set(x,g),f.push(g)}}};i.length>0&&c(Yh(e,i)),n.semantic!==!1&&n.semanticEvidence&&c(rO(n.semanticEvidence.calleeMap(e,t)));let l=r?t:o;return l.length>0&&c(YA(e,l)),s}function Yh(e,t){let n=new Map,r=zA(t,n),i=Qi(e);for(let[o,s]of r){let a=Br(e,o);if(!a)continue;let c=Ru(s),l=tn(e,o,s),u=qA(Mt(e,o));for(let d of a){let p=d.owner===void 0?c.get(d.line):l.get(Dt(d.owner));if(!p)continue;let f=UA(e,o,i,d,u);f&&n.get(p.symbolId).push(f)}}return n}function UA(e,t,n,r,i){if(qu(e,t,r))return null;let o=r.targetRange?Ku(r.targetRange):null;if(i&&o){let a=HA(i,o);if(a){let l=Uu(e,t,r,a.definition).implementationStatus==="unresolved"?"scip-declaration":r.owner!==void 0?"scip-occurrence":"ast-callsite";return Hh(a,r,l)}if(i.targetsByRange.has(o)||i.externalRanges.has(o))return null}if(i?.externalLeafKeys.has(Bu(r.line,r.calleeLeaf)))return null;let s=KA(e,t,n,r);return s?Hh(s,r,"ast-callsite"):null}function Hh(e,t,n){return{symbol:e.symbol,file:e.file,chunkId:t.line,source:n,callsiteLine:t.line,...t.kind==="jsx-render"?{kind:"jsx-render"}:{}}}function Ku(e){return`${e.startLine}:${e.startColumn}:${e.endLine}:${e.endColumn}`}function qA(e){if(!e)return null;let t=new Map;for(let n of e.targets){if(!n.sourceRange)continue;let r=Ku(n.sourceRange),i=t.get(r)??[];i.push(n.definition),t.set(r,i)}return{targetsByRange:t,externalLeafKeys:e.externalLeafKeys,externalRanges:new Set((e.externalRanges??[]).map(Ku))}}function HA(e,t){let n=e.targetsByRange.get(t);if(!n?.length)return null;let r=n[0];return n.some(i=>i.symbol!==r.symbol)?null:{symbol:r.symbol,file:r.relativePath,definition:r}}function zh(e){return e==="scip-occurrence"||e==="semantic-callee"?"exact":"candidate"}function zA(e,t){let n=new Map;for(let r of e){let i=n.get(r.relativePath);i?i.push(r):n.set(r.relativePath,[r]),t.set(r.symbolId,[])}for(let r of n.values())r.sort((i,o)=>i.endLine-i.startLine-(o.endLine-o.startLine));return n}function KA(e,t,n,r){let i=Ty(e,t,r.calleeLeaf);if(i){let a=Pu(t,n.get(i.importedName)??[]).filter(c=>Et(i.sourcePath,c.file));return a.length===1?a[0]:null}let o=Pu(t,n.get(r.calleeLeaf)??[]);if(o.length===0)return null;let s=JA(e,t,o,r.calleeQualifier);return s||dh(e,t,o,r.memberAccess,r.calleeQualifier)}function JA(e,t,n,r){if(!r||B(t)!=="clojure")return null;let o=vt(e,t).filter(s=>s.kind==="namespace"&&s.localName===r&&s.sourcePath).map(s=>s.sourcePath);for(let s of o){let a=n.find(c=>Et(s,c.file));if(a)return a}return n.find(s=>/`([^`]+)`\//.exec(s.symbol)?.[1]===r)??null}function YA(e,t){if(t.length===0)return new Map;let n=XA(e,t),r=new Map;for(let[i,o]of nO(t)){let s=n.byDoc.get(i)??[];for(let[a,c]of QA(e,o,s,n))r.set(a,c)}return r}function XA(e,t){let r=zu(t.map(u=>u.documentId)).flatMap(u=>e.all(`SELECT c.document_id, c.id AS chunk_id, c.start_line, c.end_line, m.symbol_id
|
|
349
|
+
FROM mentions m
|
|
350
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
351
|
+
WHERE m.role != 1
|
|
352
|
+
AND c.document_id IN (${u.map(()=>"?").join(",")})`,...u)),i=new Map;for(let u of r)i.has(u.document_id)||i.set(u.document_id,[]),i.get(u.document_id).push(u);let s=zu(r.map(u=>u.symbol_id)).flatMap(u=>e.all(`SELECT gs.id AS symbol_id, gs.symbol,
|
|
353
|
+
COALESCE(der.document_id, def_chunk.document_id) AS document_id
|
|
354
|
+
FROM global_symbols gs
|
|
355
|
+
LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
|
|
356
|
+
LEFT JOIN (
|
|
357
|
+
SELECT m.symbol_id, MIN(c.document_id) AS document_id
|
|
358
|
+
FROM mentions m
|
|
359
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
360
|
+
WHERE m.role = 1
|
|
361
|
+
AND m.symbol_id IN (${u.map(()=>"?").join(",")})
|
|
362
|
+
GROUP BY m.symbol_id
|
|
363
|
+
) def_chunk ON def_chunk.symbol_id = gs.id
|
|
364
|
+
WHERE gs.id IN (${u.map(()=>"?").join(",")})`,...u,...u)),a=zu([...t.map(u=>u.documentId),...s.flatMap(u=>u.document_id===null?[]:[u.document_id])]),c=new Map(a.flatMap(u=>e.all(`SELECT id, relative_path FROM documents
|
|
365
|
+
WHERE id IN (${u.map(()=>"?").join(",")})`,...u).map(d=>[d.id,d.relative_path]))),l=new Map;for(let u of s)l.has(u.symbol_id)||l.set(u.symbol_id,{symbol:u.symbol,file:u.document_id!==null?c.get(u.document_id)??"":""});return{byDoc:i,docPaths:c,calleeInfo:l}}function QA(e,t,n,r){let i=new Map,o=[...n].sort((l,u)=>l.start_line-u.start_line||l.end_line-u.end_line),s=[...t].sort((l,u)=>l.startLine-u.startLine||l.endLine-u.endLine),a=new Set,c=0;for(let l of s){for(;c<o.length&&o[c].start_line<=l.endLine;)a.add(o[c]),c+=1;for(let u of a)u.end_line<l.startLine&&a.delete(u);i.set(l.symbolId,tO(e,l,a,r))}return i}function ZA(e,t,n){let r=new Set;if(!t)return r;let i=fh(e,t),o=Math.max(0,n.startLine),s=Math.min(i.length-1,n.endLine);for(let a=o;a<=s;a+=1)for(let c of i[a])r.add(c);return r}function eO(e,t,n,r){if(!(e.start_line>=t.startLine&&e.end_line<=t.endLine)){if(!(e.start_line<=t.endLine&&e.end_line>=t.startLine))return!1;let s=Y(n);if(!s||!r().has(s))return!1}return!0}function tO(e,t,n,{docPaths:r,calleeInfo:i}){let o=new Set,s=[],a=null,c=()=>a??=ZA(e,r.get(t.documentId)??"",t);for(let l of n){if(l.symbol_id===t.symbolId)continue;let u=i.get(l.symbol_id);if(!u||!eO(l,t,u.symbol,c))continue;let d=`${u.symbol}|${l.chunk_id}`;o.has(d)||(o.add(d),s.push({...u,chunkId:l.chunk_id,source:"scip-chunk"}))}return s}var Kh=500;function zu(e){let t=[...new Set(e)],n=[];for(let r=0;r<t.length;r+=Kh)n.push(t.slice(r,r+Kh));return n}function nO(e){let t=new Map;for(let n of e){let r=t.get(n.documentId);r?r.push(n):t.set(n.documentId,[n])}return t}function rO(e){let t=new Map;for(let[n,r]of e){let i=[];for(let o of r)i.push({symbol:o.symbol,file:o.file,chunkId:-1,source:"semantic-callee",...o.callsiteLine===void 0?{}:{callsiteLine:o.callsiteLine},...o.kind==="jsx-render"?{kind:"jsx-render"}:{}});t.set(n,i)}return t}function iO(e,t,n,r,i){for(let o of t){let s=n.get(o.symbol);if(s===void 0||s===e.symbolId)continue;let a=r.get(s);a||(a=[],r.set(s,a),i.set(s,new Set));let c=`${e.symbol}|${e.relativePath}`;i.get(s).has(c)||(i.get(s).add(c),a.push({symbol:e.symbol,file:e.relativePath,source:"caller-map-inversion",callEvidence:o.source}))}}function oO(e,t){let n=[],r=[];for(let i of t)B(i.relativePath)&&Br(e,i.relativePath)!==null?n.push(i):r.push(i);return{astDefs:n,chunkOnlyDefs:r}}import{execFileSync as Xh,spawnSync as sO}from"child_process";import{platform as aO}from"os";import{resolve as cO}from"path";var Qh=aO()==="win32";function K6(e,t=sO){try{return t(e,["--version"],{stdio:"ignore",timeout:1e4}).status===0}catch{return!1}}function Zh(e){let t=Qh?"where":"which";try{return Xh(t,[e],{stdio:"pipe",timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}var lO=/\.(?:c|m)?js$/i,uO=/\.(?:exe|com)$/i;function J6(e,t){return lO.test(e)?{binary:process.execPath,args:[e,...t]}:{binary:e,args:[...t]}}function dO(e,t){return Xh(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL"})}function eS(e,t={}){let n=t.isWindows??Qh,r=t.lookup??dO,i;try{i=r(n?"where":"which",[e])}catch{return null}let o=i.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);if(!n){let s=o[0];return s?cO(s):null}return o.find(s=>uO.test(s))??null}import{execFileSync as rS}from"child_process";import{createHash as pO}from"crypto";import{existsSync as co,statSync as fO}from"fs";import{createRequire as mO}from"module";import{platform as gO}from"os";import{dirname as tS,join as Xr}from"path";var yO=mO(import.meta.url),a5={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function Ju(e){return[e.indexerBinary,...e.binaryAliases??[]]}function hO(e){let t=Ju(e);return t.length===1?t[0]:t.join(" or ")}function Yu(e){if(e.bundledNpmPackage==="@sourcegraph/scip-typescript"){let t=nS(e);if(t)return t}for(let t of Ju(e)){let n=eS(t);if(n)return n}return nS(e)}function c5(e){return Yu(e)!==null||SO(e)}function SO(e){return iS(e)!==null}function nS(e){let t=iS(e);if(!t)return null;if(e.bundledNpmPackage==="@sourcegraph/scip-typescript"){if(!Dc)return null;let i=Xr(Dc,"dist","typescript-indexer.js");return co(i)?i:null}let r=JSON.parse(_(t,"indexer package manifest")).bin;if(!r)return null;if(typeof r=="string")return Xr(tS(t),r);for(let i of Ju(e)){let o=r[i];if(o)return Xr(tS(t),o)}return null}function iS(e){if(!e.bundledNpmPackage)return null;try{return yO.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function bO(e,t){for(let n of e.projectLocalBinaries??[]){let r=Xr(t,n);if(co(r))return r}return null}function xO(e,t){for(let n of e.projectLocalBinaries??[]){let r=Xr(t,n);if(co(r))return oS(t,n,r)}return null}function l5(e,t){let n=vO(e,t);if(!n||n.canonicalPath!==t.canonicalPath||n.sha256!==t.sha256||n.size!==t.size||n.mtimeMs!==t.mtimeMs||n.device!==t.device||n.inode!==t.inode||n.executable!==t.executable)throw new Error(`refusing changed project-local indexer ${t.relativePath}; review the current file and rerun with --trust-project-tools`)}function vO(e,t){try{return oS(e,t.relativePath,t.configuredPath)}catch{return null}}function oS(e,t,n){let r={maxBytes:268435456,inputKind:"project-local indexer"},i=Er(e,t,r),o=Hn(e,t,r),s=fO(i.absolutePath);return{configuredPath:n,canonicalPath:i.absolutePath,relativePath:t,sha256:pO("sha256").update(o).digest("hex"),size:i.size,mtimeMs:i.mtimeMs,device:i.device,inode:i.inode,executable:(s.mode&73)!==0}}function RO(e,t,n={}){return(n.trustProjectTools?xO(e,t)?.canonicalPath:null)??Yu(e)}function u5(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||Xu(n,t))return t;let r=sS(n,t);return r?{...t,DOTNET_ROOT:r}:t}function d5(e,t,n={}){let r=hO(e),i=t?RO(e,t,n):Yu(e);if(!i)return{language:e.language,binaryLabel:r,installed:!1,runnable:!1,resolvedBinary:null,installUrl:e.installUrl,...t&&bO(e,t)?{note:"project-local indexer available only with --trust-project-tools"}:{}};if(e.indexerBinary!=="scip-dotnet")return{language:e.language,binaryLabel:r,installed:!0,runnable:!0,resolvedBinary:i};let o=IO(i);return{language:e.language,binaryLabel:r,installed:!0,runnable:o.runnable,resolvedBinary:i,installUrl:e.installUrl,note:o.note}}function IO(e){if(Xu(e,process.env))return{runnable:!0};let t=sS(e,process.env);if(t)return{runnable:!0,note:`using .NET 9 runtime from ${t}`};let n=aS(process.env);return{runnable:!1,note:n.length>0?`.NET 9 runtime still unavailable after checking ${n.join(", ")}`:"binary is present, but scip-dotnet still needs a .NET 9 runtime"}}function sS(e,t){for(let n of aS(t))if(Xu(e,{...t,DOTNET_ROOT:n}))return n;return null}function aS(e){let t=[],n=e.DOTNET_ROOT;if(n&&co(n)&&t.push(n),gO()==="darwin"&&Zh("brew"))try{let r=rS("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),i=Xr(r,"libexec");co(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function Xu(e,t){try{return rS(e,["--version"],{stdio:"pipe",env:t,timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}function or(e){try{return process.kill(e,0),!0}catch(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EPERM"}}var CO=new Set(["aix","android","darwin","freebsd","haiku","linux","openbsd","sunos","win32","cygwin","netbsd"]);function nn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return t.version!==1||!EO(t)||typeof t.platform!="string"||!CO.has(t.platform)||typeof t.startToken!="string"||t.startToken.trim()===""?null:{version:1,pid:t.pid,platform:t.platform,startToken:t.startToken}}function Ye(e,t){return e.version===t.version&&e.pid===t.pid&&e.platform===t.platform&&e.startToken===t.startToken}function EO(e){return typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0}import{execFileSync as PO}from"child_process";import{platform as wO}from"os";var FO=1e3,cS=16*1024,Qu;function rn(e,t=uS){if(!Number.isSafeInteger(e)||e<=0)return null;let n=e===process.pid&&t===uS;if(n&&Qu)return{...Qu};try{let r=TO(e,t);if(!r)return null;let i={version:1,pid:e,platform:t.platform,startToken:r};return n&&(Qu=i),{...i}}catch{return null}}function TO(e,t){if(t.platform==="linux"||t.platform==="android")return NO(t.readFile(`/proc/${e}/stat`));if(t.platform==="win32"){let n=`([DateTimeOffset](Get-Process -Id ${e} -ErrorAction Stop).StartTime).ToUnixTimeMilliseconds()`;return lS(t.run("powershell.exe",["-NoProfile","-NonInteractive","-Command",n]))}return t.platform==="darwin"||t.platform==="freebsd"||t.platform==="openbsd"||t.platform==="netbsd"?lS(t.run("ps",["-p",String(e),"-o","lstart="])):null}function NO(e){let t=e.lastIndexOf(")");if(t<0)return null;let r=e.slice(t+1).trim().split(/\s+/)[19];return r&&/^\d+$/.test(r)?r:null}function lS(e){let t=e.trim();return t===""?null:t}var uS={platform:wO(),readFile(e){return Lc(e,{maxBytes:cS,inputKind:"process identity pseudo-file"})},run(e,t){return PO(e,[...t],{encoding:"utf8",timeout:FO,maxBuffer:cS,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"]})}};function on(){return performance.now()}function x5(e,t,n,r,i,o){if(e>0)return n;let s=Math.max(0,Math.min(o,t-1));return Math.min(i,r*2**s)}import{randomUUID as AO}from"crypto";import{closeSync as OO,existsSync as MO,fsyncSync as jO,linkSync as BO,mkdirSync as $O,openSync as GO,renameSync as VO,unlinkSync as WO,writeSync as UO}from"fs";import{dirname as pS}from"path";import{chmodSync as LO,constants as _O,copyFileSync as DO}from"fs";import{dirname as kO}from"path";var dS=Object.freeze({...qn,copyFile:(e,t)=>DO(e,t,_O.COPYFILE_FICLONE),chmodFile:(e,t)=>LO(e,t)});function lo(e,t,n={}){let r=n.runtime??dS,i=kO(t),o=Te(i,r);r.copyFile(e,t),n.mode!==void 0&&r.chmodFile(t,n.mode);let s=r.openFile(t,"r");try{r.syncFile(s)}finally{r.closeFile(s)}return Z(o,G(i,r))}var fS=Object.freeze({platform:process.platform,randomToken:()=>AO(),pathExists:e=>MO(e),makeDirectory:e=>$O(e,{recursive:!0}),openFile:(e,t,n)=>GO(e,t,n),writeFile:(e,t,n,r)=>UO(e,t,n,r),syncFile:e=>jO(e),closeFile:e=>OO(e),renameFile:(e,t)=>VO(e,t),linkFile:(e,t)=>BO(e,t),removeFile:e=>WO(e)});function Zu(e,t,n={}){let r=n.durability??"visibility",i=n.runtime??fS,o=pS(e),s=r==="durable"?Te(o,i):(i.makeDirectory(o),"not-requested"),a=`${e}.tmp-${i.randomToken()}`,c=typeof t=="string"?Buffer.from(t):t,l,u=!1;try{l=i.openFile(a,"wx",n.mode??384),u=!0,Ht(l,c,i,"atomic file"),r==="durable"&&i.syncFile(l),i.closeFile(l),l=void 0,i.renameFile(a,e),u=!1;let d=r==="durable"?Z(s,G(o,i)):"not-requested";return mS(r,d)}finally{gS(i,l,a,u)}}function Sa(e,t,n={}){let r=n.durability??"visibility",i=n.runtime??fS;if(!i.linkFile)throw new Error("Exclusive atomic file publication requires hard-link support.");let o=pS(e),s=r==="durable"?Te(o,i):(i.makeDirectory(o),"not-requested"),a=`${e}.tmp-${i.randomToken()}`,c=typeof t=="string"?Buffer.from(t):t,l,u=!1;try{l=i.openFile(a,"wx",n.mode??384),u=!0,Ht(l,c,i,"exclusive atomic file"),r==="durable"&&i.syncFile(l),i.closeFile(l),l=void 0,i.linkFile(a,e);let d=r==="durable"?G(o,i):"not-requested";i.removeFile(a),u=!1;let p=r==="durable"?Z(s,d,G(o,i)):"not-requested";return mS(r,p)}finally{gS(i,l,a,u)}}function mS(e,t){return{requestedDurability:e,achievedDurability:e==="visibility"?"visibility":t==="synced"?"directory-durable":"file-flushed",directorySync:t}}function gS(e,t,n,r){if(t!==void 0)try{e.closeFile(t)}catch{}if(r)try{e.removeFile(n)}catch{}}function Pn(e,t,n={}){Zu(e,yS(t,n),{durability:"visibility",runtime:n.runtime})}function Xe(e,t,n={}){return Zu(e,yS(t,n),{durability:"durable",runtime:n.runtime})}function yS(e,t){let n=JSON.stringify(e,null,t.spacing);return t.trailingNewline?`${n}
|
|
366
|
+
`:n}import{join as ba}from"path";var qO={"manual-cli":!0,setup:!0,"watch-source":!0,"watch-startup":!0,"watch-demand":!0,"watch-git-head":!0,"watch-git-index":!0,"watch-git-state":!0,unknown:!0};function ed(e){return typeof e=="string"&&Object.hasOwn(qO,e)}var W5=6,U5=1e4,HO="watch.lock",zO="watch-state.json",KO="watch-activity.json",JO="watch-refresh-requests";function q5(e){return{lockPath:ba(e,HO),statePath:ba(e,zO),activityPath:ba(e,KO),refreshRequestsPath:ba(e,JO)}}function H5(e){try{return YO(JSON.parse(_(e,"watch service state")))}catch{return null}}function YO(e){if(!be(e,{version:n=>n===1,protocolVersion:yi,pid:yi,projectRoot:ut,worktreeId:P(n=>ut(n)&&n.length>0),cliVersion:ut,startedAt:ue,heartbeatAt:ue,lastActivityAt:ue,idleDeadlineAt:P(ue),watcher:XO,indexGeneration:P(nf),lastError:P(QO),lastRefresh:P(ZO),reindexActivity:P(eM),refreshRequests:P(iM),typescriptSemantic:P(oM),typescriptIndex:P(sM)}))return null;if(e.processIdentity===void 0)return e;let t=nn(e.processIdentity);return!t||t.pid!==e.pid?null:{...e,processIdentity:t}}function ue(e){return Yo(e)}function be(e,t){return Fe(e)&&Object.entries(t).every(([n,r])=>r(e[n]))}function P(e){return t=>t===void 0||e(t)}function ut(e){return typeof e=="string"}function XO(e){if(!Fe(e))return!1;switch(e.state){case"idle":return!0;case"waiting":return be(e,{changedFiles:R,reindexAt:mt});case"indexing":return be(e,{startedAt:mt});case"cooldown":return be(e,{until:mt,dirty:nd});case"budget-paused":return be(e,{until:mt,dirty:nd,reason:ut,rebuilt:R,estimatedWriteBytes:R});case"draining":return be(e,{startedAt:mt,reason:ut});default:return!1}}function QO(e){return be(e,{at:ue,message:ut})}function ZO(e){return be(e,{trigger:t=>be(t,{kind:ed,detail:P(ut)}),result:t=>t==="rebuilt"||t==="reused"||t==="failed",startedAt:ue,completedAt:ue,durationMs:mt,indexedLanguages:P(t=>Array.isArray(t)&&t.every(td)),skipped:P(t=>Array.isArray(t)&&t.every(n=>be(n,{language:td,reason:ut}))),error:P(ut)})}function td(e){return ut(e)&&Xo.includes(e)}function hS(e){return e==="complete"||e==="partial"||e==="unavailable"}function eM(e){return be(e,{confidence:P(hS),recordsRead:P(R),invalidRecords:P(R),skippedRecords:P(R),readErrors:P(R),ignoredPartialTailBytes:P(R),windowStartedAt:ue,windowEndedAt:ue,runs:R,rebuilt:R,fullRebuilds:P(R),reused:R,failed:R,suppressed:R,estimatedLogicalOutputBytes:mt,estimatedWriteBytes:P(R),reflinkedBytes:P(R),fallbackCopiedBytes:P(R),oldestRebuildAt:P(ue),oldestWriteAt:P(ue),languageAttribution:P(hS),attributedRuns:P(R),unattributedRuns:P(R),invalidLanguageDetails:P(R),byTrigger:t=>Fe(t)&&Object.entries(t).every(([n,r])=>ed(n)&&(r===void 0||R(r))),byLanguage:P(nM),automatic:P(tM)})}function tM(e){return be(e,{runs:R,rebuilt:R,fullRebuilds:R,estimatedWriteBytes:R,oldestRebuildAt:P(ue),oldestWriteAt:P(ue)})}function nM(e){return Fe(e)&&Object.entries(e).every(([t,n])=>td(t)&&rM(n))}function rM(e){return be(e,{runs:R,rebuilt:R,reused:R,producedOutputBytes:R,durationMs:mt})?e.rebuilt+e.reused===e.runs:!1}function iM(e){return be(e,{pending:R,claimed:R,completed:R,expired:R,invalid:R,oldestPendingAt:P(ue)})}function SS(e){return e==="idle"||e==="ready"||e==="unavailable"||e==="error"}function oM(e){return be(e,{protocolVersion:yi,state:SS,requests:R,sessionsCreated:R,sessionsReused:R,sessionsRefreshed:R,sessionsReplaced:R,projectsCreated:R,lastRequestAt:P(ue),lastError:P(ut),busyUntil:P(ue),mailbox:P(bS)})}function nd(e){return typeof e=="boolean"}function sM(e){return be(e,{protocolVersion:yi,state:SS,requests:R,sessionsCreated:R,sessionsReplaced:R,sessionsEvicted:P(R),activeSessions:P(R),maxActiveSessions:P(R),heapUsedBytes:P(R),heapLimitBytes:P(R),softMemoryLimitBytes:P(R),retireRequested:P(nd),initializations:R,programUpdates:R,documentsEmitted:R,documentsRemoved:R,lastRequestAt:P(ue),lastDurationMs:P(mt),lastError:P(ut),busyUntil:P(ue),mailbox:P(bS)})}function bS(e){return be(e,{pending:R,inflight:R,responses:R,deadLetters:R,invalid:R,totalItems:R,totalBytes:mt,oldestPendingAt:P(ue)})?e.totalItems===e.pending+e.inflight+e.responses+e.deadLetters:!1}import{getHeapStatistics as wM}from"v8";var aM=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function xa(e){let t=e.toLowerCase();return aM.some(n=>t.endsWith(n))}function Ra(e){let t=va(e.projectFiles),n=new Set(t),r=new Map(e.snapshot.files.map(p=>[p.path,p])),i=e.snapshot.files.filter(p=>{let f=ft(p.path,["typescript"]);return f==="config"||f==="ambient"}).map(p=>p.path),o=va([...t,...i]),s=o.find(p=>!r.has(p)),a=new Set(e.snapshot.files.map(p=>p.path)).size!==e.snapshot.files.length,c=!s&&o.some(p=>xS(r.get(p))),l=$(JSON.stringify({pnpmWorkspaces:e.snapshot.pnpmWorkspaces,typescriptProjectMode:e.snapshot.typescriptProjectMode,typescriptProjects:va(e.snapshot.typescriptProjects),membership:t})),u,d;return{identityFor(p,f){if(!n.has(p))return Qr("target-outside-project");if(a)return Qr("duplicate-input-path");if(s)return Qr("missing-input-fingerprint");if(c)return Qr("unreadable-input");let h=[],b,x;if(e.graph===null)h.push("dependency-graph-unavailable"),x="whole-project",b=o;else{let y=p===u&&d?d:cM(p,e.graph);if(u=p,d=y,y.find(w=>!r.has(w)))return Qr("missing-input-fingerprint");if(b=va([...y,...i]),b.some(w=>xS(r.get(w))))return Qr("unreadable-input");x="dependency-closure"}let m=b.map(y=>lM(r.get(y)));return{version:1,key:$(JSON.stringify({version:1,engineIdentity:e.engineIdentity,schemaVersion:f,projectIdentity:l,inputs:m})),mode:x,inputFiles:b,reasons:h}}}}function cM(e,t){let n=new Set,r=[e];for(let i=0;i<r.length;i+=1){let o=r[i];if(!(o===void 0||n.has(o))){n.add(o);for(let s of[...t.get(o)??[]].sort())n.has(s)||r.push(s)}}return[...n].sort()}function lM(e){return e.semanticHash===void 0?{path:e.path,size:e.size,hash:e.hash}:{path:e.path,semanticHash:e.semanticHash}}function xS(e){return e.size<0||e.hash==="unreadable"}function Qr(e){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[e]}}function va(e){return[...new Set(e)].sort()}import{realpathSync as mM}from"fs";import{createRequire as gM}from"module";import{dirname as RS,resolve as IS}from"path";import{getHeapStatistics as uM}from"v8";var dM=2560,pM=1.25;function fM(e){let t=e/1048576;return Math.max(0,Math.floor((t-dM)/pM))}function vS(){return fM(uM().heap_size_limit)}var CS=gM(import.meta.url),uo,Ia;function yM(){if(uo!==void 0)return uo;try{uo=CS("ts-morph")}catch{uo=null}return uo}function Ca(){if(Ia)return Ia;let e=yM();if(!e)return"ts-morph:unavailable";let t="unknown";try{t=CS("ts-morph/package.json").version??"unknown"}catch{}return Ia=`ts-morph:${t}:typescript:${e.ts.version}`,Ia}function i4(e,t,n={}){return SM(e,t).map(r=>xM(e,r,n))}var hM=3;function SM(e,t){let n=[],r=new Set,i=(o,s)=>{let a=IS(o);if(r.has(a))return;r.add(a);let c=s<hM?bM(e,a):[];if(c.length===0){n.push(a);return}for(let l of c)i(l,s+1)};for(let o of t)i(o,0);return n}function bM(e,t){try{let n=e.ts,r=n.readConfigFile(t,n.sys.readFile);if(r.error||!r.config)return[];let i=n.parseJsonConfigFileContent(r.config,n.sys,RS(t),void 0,t);return i.fileNames.length>0||!i.projectReferences?.length?[]:i.projectReferences.map(o=>n.resolveProjectReferencePath(o)).filter(o=>n.sys.fileExists(o))}catch{return[]}}function xM(e,t,n){let r=null,i,o,s=()=>(i===void 0&&(i=RM(e,t)),i),a=()=>{if(o===void 0){let c=n.fileBudget??vS(),l=s();o=(l===null?0:Math.ceil(l.size/2))>c*vM?"file-closure":"project"}return o};return{tsconfigPath:t,get project(){return r??=new e.Project({tsConfigFilePath:t,skipFileDependencyResolution:!0,...a()==="file-closure"?{skipAddingFilesFromTsConfig:!0}:{}}),r},get loaded(){return r!==null},get fileNames(){return s()},get scope(){return a()}}}var vM=1.35,o4="TypeScript project-wide semantics are unavailable: a compiler project is file-scoped because its tsconfig lists more files than the worker heap can hold.";function s4(e){return e.some(t=>t.scope==="file-closure")}function RM(e,t){try{let n=e.ts,r=n.readConfigFile(t,n.sys.readFile);if(r.error||!r.config)return null;let i=n.parseJsonConfigFileContent(r.config,n.sys,RS(t),void 0,t),o=new Set;for(let s of i.fileNames){let a=IS(s);o.add(a);try{o.add(mM(a))}catch{}}return o}catch{return null}}function a4(e,t,n){return{language:"typescript",availability:()=>({available:!1,reason:e,tsconfigPath:t,tsconfigPaths:n}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}var IM=oe("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function po(e,t,n){let r=IM.get(e,()=>CM(e));if(!r)return null;let i=`${n}\0${t}`,o=r.identities.get(i);if(o)return o;let s=r.builder.identityFor(t,n);return r.identities.set(i,s),s}function sr(e){return Re(e,{includeIgnored:!1}).filter(xa).sort()}function CM(e){try{if(!e.generation.metadataRaw)return null;let t=Ct(e.generation.metadataRaw);if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.usableForEvidenceCache)return null;let n=mi(t.metadata.fingerprint);return n?{builder:Ra({projectFiles:sr(e),snapshot:n,graph:Ur(e),engineIdentity:Ca()}),identities:new Map}:null}catch{return null}}function wS(e,t){let n=rd(e);for(let r of t.values())n.add(r);return n.finish()}function rd(e){let t=new Map(e.map(r=>[r.symbol,r])),n=new Map(e.map(r=>[r.symbolId,[]]));return{add(r){for(let i of r){let o=t.get(i.targetSymbol);o&&n.get(o.symbolId).push(i.location)}},finish(){for(let[r,i]of n)n.set(r,EM(i));return n}}}function FS(e,t,n){let r=PS(e,t),i=PS(e,n),o=[...r].filter(d=>!i.has(d)).sort(),s=[...i].filter(d=>!r.has(d)).sort(),a=ES(e,t),c=ES(e,n),l=[...a].filter(d=>!c.has(d)).sort(),u=[...c].filter(d=>!a.has(d)).sort();return{passed:o.length===0&&s.length===0,expectedCount:r.size,actualCount:i.size,missing:o,extra:s,callerFiles:{passed:l.length===0&&u.length===0,expectedCount:a.size,actualCount:c.size,missing:l,extra:u}}}function ES(e,t){let n=new Set;for(let r of e)for(let i of t.get(r.symbolId)??[])i.file!==r.relativePath&&n.add(`${r.symbol}\0${i.file}`);return n}function S4(e,t,n){let r=new Set(n),i=new Map(n.map(o=>[o,[]]));for(let o of e)for(let s of t.get(o.symbolId)??[])r.has(s.file)&&i.get(s.file).push({targetSymbol:o.symbol,location:s});for(let[o,s]of i)i.set(o,PM(s));return i}function PS(e,t){let n=new Set;for(let r of e)for(let i of t.get(r.symbolId)??[])n.add(`${r.symbol}\0${i.file}\0${i.line}\0${i.column}`);return n}function EM(e){let t=new Map;for(let n of e)t.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...t.values()].sort(TS)}function PM(e){let t=new Map;for(let n of e){let{location:r}=n;t.set(`${n.targetSymbol}\0${r.file}\0${r.line}\0${r.column}`,n)}return[...t.values()].sort((n,r)=>n.targetSymbol.localeCompare(r.targetSymbol)||TS(n.location,r.location))}function TS(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.column-t.column}var mo="typescript-reference-fragment-v2",NS=128,Zr=ge({kind:"typescript-reference-fragments",invalidation:ee("typescript-reference-fragments"),serialize:e=>JSON.stringify(e),deserialize:_M});function L4(e,t,n,r=e,i,o=new Set(n.keys())){let s=sr(e),a=Ra({projectFiles:s,snapshot:t,graph:i??Ur(e),engineIdentity:Ca()}),c=[],l=0;for(let[d,p]of n){let f=a.identityFor(d,mo).key;if(!f){l+=1;continue}c.push({relativePath:d,contentHash:f,value:[...p]})}let u=s.filter(d=>!o.has(d)&&!n.has(d)).length;return Zr.writeBatch(r,c),{affectedFiles:c.length,carriedFiles:u,skippedAffectedFiles:l}}function _4(e,t,n,r){let i=t.filter(s=>xa(s.relativePath));if(i.length===0)return fo("no TypeScript definitions");let o=fo("shadow did not run");return se("typescript.reference-fragments.shadow",()=>{try{let s=r(i[0].relativePath);if(!s.availability().available||!s.referenceFragmentsForFiles)return o=fo("TypeScript reference fragment provider is unavailable"),o;let a=sr(e),c=new Set(a),l=new Map;for(let f of id(a)){let h=s.referenceFragmentsForFiles(f);if(f.some(b=>!h.has(b)))return o=fo("TypeScript reference fragment provider returned an incomplete batch"),o;for(let b of f)l.set(b,h.get(b)??[])}let u=wS(i,l),d=FS(i,FM(n,c),u);if(!d.passed)return o={state:"failing",files:a.length,keyedFiles:0,writtenFiles:0,...d},o;let p=kM(e,a,l);return Zr.writeBatch(e,p),o={state:"passing",files:a.length,keyedFiles:p.length,writtenFiles:p.length,...d},o}catch(s){return o=fo(s instanceof Error?s.message:String(s)),o}},()=>({...o}))}function FM(e,t){return new Map([...e].map(([n,r])=>[n,r.filter(i=>t.has(i.file))]))}function D4(e,t,n){if(t.length===0)return{references:new Map,files:0,cacheHits:0,cacheMisses:0,computedFiles:0};let r="fallback",i=0,o=0,s=0,a=0;return se("typescript.reference-fragments.materialize",()=>{try{let c=sr(e);i=c.length;let l=rd(t),u=[];for(let p of c){let f=po(e,p,mo);if(!f?.key)return null;let h=Zr.read(e,p,f.key);h===null?(s+=1,u.push({file:p,contentHash:f.key})):(o+=1,l.add(h))}return s===0?(r="hit",{references:l.finish(),files:i,cacheHits:o,cacheMisses:s,computedFiles:a}):NM(e,u,n,p=>{for(let{fragments:f}of p)l.add(f);a+=p.length})?(r="computed",{references:l.finish(),files:i,cacheHits:o,cacheMisses:s,computedFiles:a}):null}catch{return null}},()=>({state:r,files:i,cacheHits:o,cacheMisses:s,computedFiles:a}))}function id(e){let t=[];for(let n=0;n<e.length;n+=NS)t.push(e.slice(n,n+NS));return t}var TM=.75;function LS(e){return{heapUsedFraction:()=>{let t=wM();return t.heap_size_limit>0?t.used_heap_size/t.heap_size_limit:0},collect:gn,release:()=>sf(e,{groups:["semantic-provider"]})}}function _S(e,t=TM){return e.heapUsedFraction()<t||e.collect()&&e.heapUsedFraction()<t?!1:(e.release(),!0)}function NM(e,t,n,r,i=LS(e)){for(let o of id(t)){let s=DS(e,o,n);if(!s)return!1;r(s),_S(i)}return!0}function DS(e,t,n){let r=t.map(({file:s})=>s),i=n(r[0]);if(!i.availability().available||!i.referenceFragmentsForFiles)return null;let o=i.referenceFragmentsForFiles(r);return r.some(s=>!o.has(s))?null:(Zr.writeBatch(e,t.map(({file:s,contentHash:a})=>({relativePath:s,contentHash:a,value:o.get(s)??[]}))),r.map(s=>({file:s,fragments:o.get(s)??[]})))}function k4(e){let t=sr(e),n=0;for(let r of t){let i=po(e,r,mo);if(!i?.key)return null;Zr.has(e,r,i.key)||(n+=1)}return{files:t.length,missing:n}}var LM=()=>new Promise(e=>setImmediate(e));async function A4(e,t,n={}){let r=n.yieldToEventLoop??LM,i=n.probe??LS(e),o="fallback",s=0,a=0,c=0,l=0;return _f("typescript.reference-fragments.warm",async()=>{try{let u=sr(e),d=n.files?new Set(n.files):null,p=d?u.filter(h=>d.has(h)):u;s=p.length;let f=[];for(let h of p){let b=po(e,h,mo);if(!b?.key)return null;Zr.has(e,h,b.key)?a+=1:(c+=1,f.push({file:h,contentHash:b.key}))}if(f.length===0)return o="hit",{files:s,cacheHits:a,cacheMisses:c,computedFiles:l};for(let h of id(f)){let b=DS(e,h,t);if(!b)return null;l+=b.length,_S(i),n.onBatch?.({computedFiles:l,missingFiles:f.length}),await r()}return o="computed",{files:s,cacheHits:a,cacheMisses:c,computedFiles:l}}catch{return null}},()=>({state:o,files:s,cacheHits:a,cacheMisses:c,computedFiles:l}))}function fo(e){return{state:"unavailable",files:0,keyedFiles:0,writtenFiles:0,expectedCount:0,actualCount:0,missing:[],extra:[],reason:e}}function _M(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(DM)?null:t}catch{return null}}function DM(e){if(!e||typeof e!="object")return!1;let t=e,n=t.location;return typeof t.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}function kM(e,t,n){let r=[];for(let i of t){let o=po(e,i,mo);o?.key&&r.push({relativePath:i,contentHash:o.key,value:n.get(i)??[]})}return r}function Ea(e,t){return e.reason instanceof Error?e.reason:new Error(t)}function kS(e,t){if(e?.aborted)throw Ea(e,t)}import{randomUUID as AM}from"crypto";import{closeSync as OM,fsyncSync as MM,linkSync as jM,mkdirSync as BM,openSync as $M,statSync as GM,unlinkSync as VM,writeSync as WM}from"fs";import{dirname as ad}from"path";var cd="scip-query-process-lock",ld=1,Pa=Object.freeze({wallNow:()=>Date.now(),isProcessAlive:or,readProcessIdentity:rn,randomToken:()=>AM(),makeDirectory:e=>BM(e,{recursive:!0}),openFile:(e,t,n)=>$M(e,t,n),writeFile:(e,t,n,r)=>WM(e,t,n,r),syncFile:e=>MM(e),closeFile:e=>OM(e),linkFile:(e,t)=>jM(e,t),readFile:e=>_(e,"process lock record"),statFile:e=>{let t=GM(e);return{dev:t.dev,ino:t.ino,size:t.size,mtimeMs:t.mtimeMs}},removeFile:e=>VM(e)}),wa=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.pid;return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?{pid:t}:null};function Fa(e,t){let n=t.runtime??Pa;n.makeDirectory(ad(e));let r;for(let i=0;i<2;i+=1)try{return{kind:"acquired",lock:AS(e,t,n),...r?{reclaimed:r}:{}}}catch(o){if(o.code!=="EEXIST")throw o;let s=ei(e,{parseLegacy:t.parseLegacy,runtime:n});if(i===0&&KM(e,s,{creationGraceMs:t.creationGraceMs,parseLegacy:t.parseLegacy,runtime:n})){r=s;continue}return{kind:"contended",observation:s}}return{kind:"contended",observation:ei(e,{parseLegacy:t.parseLegacy,runtime:n})}}function ei(e,t={}){let n=t.runtime??Pa,r,i;try{r=n.statFile(e),i=n.readFile(e)}catch(c){return c.code==="ENOENT"?{state:"missing"}:{state:"malformed"}}let o;try{o=JSON.parse(i)}catch{return{state:"malformed",raw:i,identity:r}}let s=UM(o);if(s)return{state:"valid",raw:i,identity:r,record:s,owner:XM(s),parsed:o};let a=t.parseLegacy?.(o)??null;return a?{state:"legacy",raw:i,identity:r,owner:a,parsed:o}:{state:"malformed",raw:i,identity:r,parsed:o}}function UM(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(!HM(t)||!zM(t))return null;let n=qM(t);if(!n)return null;let{processIdentity:r}=n;return{protocol:cd,version:ld,kind:t.kind,pid:t.pid,token:t.token,...r?{processIdentity:r}:{},startedAt:t.startedAt,...t.detail?{detail:t.detail}:{}}}function qM(e){let t=e.processIdentity===void 0?null:nn(e.processIdentity);return e.processIdentity!==void 0&&(!t||t.pid!==e.pid)?null:{processIdentity:t}}function HM(e){return e.protocol===cd&&e.version===ld&&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 zM(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 KM(e,t,n={}){let r=n.runtime??Pa;if(!od(t,r))return!1;let i=YM(`${e}.reclaim`,r);if(!i)return!1;try{let o=ei(e,{parseLegacy:n.parseLegacy,runtime:r});return!MS(t,o)||!od(o,r)?!1:ud(e,r)}finally{i.release()}}function AS(e,t,n){let r=t.directoryDurability??"durable",i=t.pid??process.pid,o=n.randomToken(),s=t.processIdentity===void 0?n.readProcessIdentity(i):t.processIdentity,a={protocol:cd,version:ld,kind:t.kind,pid:i,token:o,...s?{processIdentity:s}:{},startedAt:new Date(n.wallNow()).toISOString(),...t.detail?{detail:t.detail}:{}},c=`${e}.${o}.candidate`;QM(c,a,n);try{n.linkFile(c,e)}catch(u){throw sd(c,n),u}if(sd(c,n),r==="durable")try{jS(ad(e),n)}catch(u){throw JM(e,a,n),u}let l=!1;return{path:e,record:a,release:()=>l?!1:(l=!0,OS(e,a,n,r))}}function JM(e,t,n=Pa){return OS(e,t,n,"durable")}function OS(e,t,n,r){let i=ei(e,{runtime:n});return i.state!=="valid"||!i.record||i.record.pid!==t.pid||i.record.token!==t.token||t.processIdentity&&(!i.record.processIdentity||!Ye(t.processIdentity,i.record.processIdentity))?!1:ud(e,n,r)}function YM(e,t){for(let n=0;n<2;n+=1)try{return AS(e,{kind:"reclaim-guard",runtime:t},t)}catch(r){if(r.code!=="EEXIST"||!ZM(e,t,n))return null}return null}function od(e,t){if(e.state==="missing")return!1;if(e.owner){if(!t.isProcessAlive(e.owner.pid))return!0;if(!e.owner.processIdentity)return!1;let n=t.readProcessIdentity(e.owner.pid);return n!==null&&!Ye(e.owner.processIdentity,n)}return!1}function MS(e,t){return e.state===t.state&&e.raw===t.raw&&e.identity!==void 0&&t.identity!==void 0&&e.identity.dev===t.identity.dev&&e.identity.ino===t.identity.ino&&e.identity.size===t.identity.size&&e.identity.mtimeMs===t.identity.mtimeMs}function XM(e){return{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}}function jS(e,t){let n;try{n=t.openFile(e,"r")}catch(r){if(Rr(r,process.platform))return;throw r}try{t.syncFile(n)}catch(r){if(!Rr(r,process.platform))throw r}finally{t.closeFile(n)}}function ud(e,t,n="durable"){try{return t.removeFile(e),n==="durable"&&jS(ad(e),t),!0}catch{return!1}}function sd(e,t){try{t.removeFile(e)}catch{}}function QM(e,t,n){let r=n.openFile(e,"wx",384),i;try{Ht(r,Buffer.from(`${JSON.stringify(t)}
|
|
367
|
+
`),n,"process lock"),n.syncFile(r)}catch(o){i=o}try{n.closeFile(r)}catch(o){i??=o}if(i!==void 0)throw sd(e,n),i}function ZM(e,t,n){let r=ei(e,{runtime:t});if(n>0||!od(r,t))return!1;let i=ei(e,{runtime:t});return MS(r,i)?ud(e,t):!1}import{join as ej}from"path";function BS(e,t={}){return sn(ej(e,"gc.lock"),t)}function sn(e,t={}){let n=t.waitMs??0,r=t.pollMs??10,i=t.now??on,o=i()+n;do{let s=GS(e,t.directoryDurability);if(s)return VS(s);let a=o-i();if(a<=0)return null;tj(Math.min(r,a))}while(i()<=o);return null}async function $S(e,t={}){let n=t.waitMs??0,r=t.pollMs??10,i=t.now??on,o=i()+n;do{kS(t.signal,"Lock acquisition was aborted.");let s=GS(e,t.directoryDurability);if(s)return VS(s);let a=o-i();if(a<=0)return null;await nj(Math.min(r,a),t.signal)}while(i()<=o);return null}function GS(e,t){let n=Fa(e,{kind:"generic",parseLegacy:wa,...t?{directoryDurability:t}:{}});return n.kind==="acquired"?n.lock:null}function VS(e){return{release:()=>{e.release()}}}function tj(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}function nj(e,t){return t?.aborted?Promise.reject(Ea(t,"Lock acquisition was aborted.")):new Promise((n,r)=>{let i=setTimeout(()=>{t?.removeEventListener("abort",o),n()},e),o=()=>{clearTimeout(i),t?.removeEventListener("abort",o),r(t?Ea(t,"Lock acquisition was aborted."):new Error("Lock acquisition was aborted."))};t?.addEventListener("abort",o,{once:!0})})}import{createHash as rj,randomUUID as ij}from"crypto";import{existsSync as ti,mkdirSync as oj,readdirSync as sj,rmSync as qS,statSync as HS}from"fs";import{basename as aj,dirname as Ta,join as Qe}from"path";var ar=1,fd=1,yo=".scipquery-generations",Na="manifest.json",zS="readers",cj="gc.lock",lj=128,go=new Map,KS={pid:process.pid,now:()=>new Date,randomToken:()=>ij(),isProcessAlive:or,readProcessIdentity:rn};function de(e){return Qe(Ta(e),yo)}function La(e){return Qe(de(e),cj)}function JS(e,t=KS){let n=sn(La(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=gd(e);if(i.source!=="immutable")return{generation:i,release(){}};let o=t.randomToken();if(!/^[A-Za-z0-9._-]+$/.test(o))throw new Error("SQLite generation reader token is unsafe.");let s=Qe(de(e.dbPath),zS);oj(s,{recursive:!0}),r=Qe(s,`${t.pid}-${o}.json`);let a=t.readProcessIdentity(t.pid);Pn(r,{version:1,token:o,generationIdentity:i.identity,pid:t.pid,...a?{processIdentity:a}:{},acquiredAt:t.now().toISOString()},{spacing:2,trailingNewline:!0});let c=!1;return{generation:i,release(){c||!r||(c=!0,qS(r,{force:!0}))}}}finally{n.release()}}function md(e,t,n=KS,r={}){let i=Qe(de(e),zS);if(!ti(i))return{protectedGenerations:new Set,activeLeases:0,staleLeasesRemoved:0,malformedLeases:0};let o=new Set,s=0,a=0,c=0;for(let l of sj(i,{withFileTypes:!0})){if(!l.isFile()||!l.name.endsWith(".json"))continue;let u=Qe(i,l.name),d=Ij(u);if(!d){c+=1;for(let p of t)o.add(p);continue}if(!fj(d,n)){r.removeStale!==!1&&(qS(u,{force:!0}),a+=1);continue}s+=1,o.add(d.generationIdentity)}return{protectedGenerations:o,activeLeases:s,staleLeasesRemoved:a,malformedLeases:c}}function uj(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,n=t.processIdentity===void 0?null:nn(t.processIdentity);return!dj(t)||!pj(t,n)?null:{version:1,token:t.token,generationIdentity:t.generationIdentity,pid:t.pid,...n?{processIdentity:n}:{},acquiredAt:t.acquiredAt}}function dj(e){return e.version===1&&typeof e.token=="string"&&e.token.trim()!==""&&typeof e.generationIdentity=="string"&&/^[a-f0-9]{64}$/.test(e.generationIdentity)}function pj(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 fj(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let n=t.readProcessIdentity(e.pid);return n===null||Ye(e.processIdentity,n)}function wn(e){try{let t=JSON.parse(_(Qe(de(e),"state.json"),"SQLite generation state"));return hj(t)?t:null}catch{return null}}function ni(e,t){return ho(de(e),t)}function ho(e,t){try{let n=JSON.parse(_(Qe(e,t,Na),"SQLite generation manifest"));return yj(n,t)?n:null}catch{return null}}function gd(e){let t=wn(e.dbPath);if(t){let n=mj(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(ti(Qe(Ta(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return gj(e,t?.currentGeneration)}function a8(e){let t=wn(e);if(t)return t.currentGeneration;try{let n=Qe(Ta(e),"meta.json"),r=ti(n)?_(n,"reindex metadata"):void 0;return YS(e,r)}catch{return null}}function Fn(e){return rf(Ct(e))??e}function mj(e,t){try{let n=Qe(de(e.dbPath),t),r=ni(e.dbPath,t);if(!r)return null;let i=dd(n,r.database),o=r.index?dd(n,r.index):void 0,s=r.metadata?dd(n,r.metadata):void 0;return!XS(i,r.database)||!US(o,r.index)||!US(s,r.metadata)?null:{identity:t,databasePath:i,...o?{indexPath:o}:{},...s?{metadataPath:s,metadataRaw:_(s,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function gj(e,t){let n=an(e.dbPath),r=Qe(Ta(e.dbPath),"meta.json"),i=ti(r)?_(r,"reindex metadata"):void 0,o=ti(e.indexPath)?e.indexPath:void 0;return{identity:t??YS(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:r,metadataRaw:i},source:"legacy",databaseFileIdentity:n}}function YS(e,t){let n=rj("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&n.update(Fn(t)),n.update(`\0${an(e)}`),n.digest("hex")}function an(e){let t=HS(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function dd(e,t){if(aj(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return Qe(e,t.file)}function XS(e,t){if(!ti(e))return!1;let n=WS(e);if(!n||n.size!==t.size)return!1;let r=`${e}\0${t.sha256}\0${n.identity}`;if(go.has(r))return!0;let i=On(e,{inputKind:"immutable SQLite generation artifact",maxBytes:t.size}),o=WS(e);if(!o||o.identity!==n.identity||i!==t.sha256)return!1;for(go.set(r,!0);go.size>lj;){let s=go.keys().next().value;if(s===void 0)break;go.delete(s)}return!0}function WS(e){let t=HS(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function yj(e,t){return e.version===fd&&e.identity===t&&pd(e.database)&&(e.index===void 0||pd(e.index))&&(e.metadata===void 0||pd(e.metadata))}function pd(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 hj(e){return e.version===ar&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&Sj(e.stableMirrors)&&bj(e.previousGeneration)&&xj(e.publication)}function Sj(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 bj(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 xj(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 vj(t,n)&&Rj(t)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}function vj(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 Rj(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 US(e,t){return!t||!!(e&&XS(e,t))}function Ij(e){let t;try{t=uj(JSON.parse(_(e,"SQLite generation reader lease")))}catch{t=null}return t}import Cj from"better-sqlite3";var Ej=["busy_timeout = 5000","query_only = ON","temp_store = MEMORY","cache_size = -64000","mmap_size = 268435456"],yd=class{constructor(t,n){this.connection=t;this.releaseGenerationReader=n}connection;releaseGenerationReader;active=!0;initialize(t){try{for(let n of Ej)this.connection.pragma(n);t(this.connection)}catch(n){try{this.close()}catch(r){throw new AggregateError([n,r],"SQLite initialization and rollback both failed.",{cause:r})}throw n}}close(){if(!this.active)return;this.active=!1;let t,n;try{this.connection.close()}catch(r){t=r}try{this.releaseGenerationReader()}catch(r){n=r}if(t!==void 0&&n!==void 0)throw new AggregateError([t,n],"SQLite connection close and generation-reader release both failed.");if(t!==void 0)throw t;if(n!==void 0)throw n}},Pj=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".scipquery-cache","__pycache__",".venv","venv"],_a=class{db;config;generation;pathFilter;connection;connectionOwnership;statementCache=new Map;constructor(t,n){this.config=t,this.pathFilter=n??null;let r=Nj(t),i=new yd(r.db,r.release);try{i.initialize(Tj),this.generation=r.generation,this.connection=r.db,this.connectionOwnership=i,this.db=wj(r.db)}catch(o){try{i.close()}catch(s){throw new AggregateError([o,s],"SQLite construction and rollback both failed.",{cause:s})}throw o}}isIgnored(t){return this.pathFilter?.isIgnored(t)??!1}get localSymbolPredicate(){return`(
|
|
368
|
+
EXISTS (
|
|
369
|
+
SELECT 1
|
|
370
|
+
FROM defn_enclosing_ranges local_der
|
|
371
|
+
JOIN documents local_d ON local_der.document_id = local_d.id
|
|
372
|
+
WHERE local_der.symbol_id = gs.id
|
|
373
|
+
${this.pathExclusionsFor("local_d").trimStart()}
|
|
374
|
+
)
|
|
375
|
+
OR EXISTS (
|
|
376
|
+
SELECT 1
|
|
377
|
+
FROM mentions local_m
|
|
378
|
+
JOIN chunks local_c ON local_m.chunk_id = local_c.id
|
|
379
|
+
JOIN documents local_d ON local_c.document_id = local_d.id
|
|
380
|
+
WHERE local_m.symbol_id = gs.id
|
|
381
|
+
AND local_m.role = 1
|
|
382
|
+
${this.pathExclusionsFor("local_d").trimStart()}
|
|
383
|
+
)
|
|
384
|
+
)`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(n=>Pj.flatMap(r=>[`AND ${n}.relative_path NOT LIKE '${r}/%'`,`AND ${n}.relative_path NOT LIKE '%/${r}/%'`])).join(`
|
|
385
|
+
`)}symbolNoiseFor(t){return`AND ${t}.symbol NOT LIKE '%().(%' AND ${t}.symbol NOT LIKE '%typeLiteral%'`}all(t,...n){return this.statement(t).all(...n)}get(t,...n){return this.statement(t).get(...n)}close(){this.statementCache.clear(),this.connectionOwnership.close()}statement(t){let n=this.statementCache.get(t);return n||(n=QS(this.connection,this.db,t),this.statementCache.set(t,n)),n}};function wj(e){let t={prepare(n){return QS(e,t,n)}};return Object.freeze(t)}function QS(e,t,n){try{let r=e.prepare(n);if(!r.readonly||!r.reader)throw new Error("ScipDatabase.db only permits read-only statements that return rows.");return Fj(r,t)}catch(r){throw We(),r}}function Fj(e,t){let n=e.readonly&&e.reader,r=()=>{n=!1,We()},i={get:(...o)=>Rl({owner:t,sql:e.source,method:"get",parameters:o,supported:n},()=>e.get(...o)),all:(...o)=>Rl({owner:t,sql:e.source,method:"all",parameters:o,supported:n},()=>e.all(...o)),iterate:(...o)=>(We(),e.iterate(...o)),pluck(o){return r(),o===void 0?e.pluck():e.pluck(o),i},expand(o){return r(),o===void 0?e.expand():e.expand(o),i},raw(o){return r(),o===void 0?e.raw():e.raw(o),i},bind(...o){return r(),e.bind(...o),i},columns:()=>(We(),e.columns()),safeIntegers(o){return r(),o===void 0?e.safeIntegers():e.safeIntegers(o),i}};return Object.freeze(i)}function Tj(e){if(!e.prepare("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = 'documents'").get())return;let n=e.prepare("SELECT relative_path FROM documents").iterate();for(let r of n)ve(r.relative_path)}function Nj(e){for(let t=0;t<4;t+=1){let n=JS(e),r=n.generation,i;try{i=new Cj(r.databasePath,{readonly:!0,fileMustExist:!0})}catch(o){throw n.release(),o}if(r.source==="immutable")return{db:i,generation:r,release:n.release};try{let o=gd(e);if(r.databaseFileIdentity===an(r.databasePath)&&o.source==="legacy"&&o.identity===r.identity&&o.databaseFileIdentity===r.databaseFileIdentity&&o.metadataRaw===r.metadataRaw)return{db:i,generation:r,release:n.release}}catch(o){throw i.close(),n.release(),o}i.close(),n.release()}throw new Error("SQLite index publication changed repeatedly while opening a coherent generation.")}function m8(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function y8(e){let t=e?.match(/--max[-_]old[-_]space[-_]size(?:=|\s+)(\d+)/u);if(!t)return;let n=Number.parseInt(t[1],10);return Number.isInteger(n)&&n>0?n:void 0}function h8(e,t){return[(e??"").replace(/(?:^|\s)--max[-_]old[-_]space[-_]size(?:=|\s+)\d+/gu," ").trim(),`--max-old-space-size=${t}`].filter(Boolean).join(" ")}import Lj from"ignore";import{existsSync as ZS,readdirSync as _j}from"fs";import{dirname as hd,isAbsolute as eb,join as Da,relative as Dj,resolve as kj}from"path";function I8(e){let t=Lj();return Aj(e,t)||t.add(jj),{isIgnored:r=>Sd(t,e,r),filter:r=>r.filter(i=>!Sd(t,e,i))}}function Aj(e,t){let n=new Set,r=(s,a)=>{if(!(n.has(s)||!ZS(s)))try{let c=z(s,{maxBytes:re,inputKind:"gitignore file"});t.add(a?Oj(c,a):c),n.add(s)}catch{}},i=hd(e),o=0;for(;i!==hd(i)&&o<5&&(r(Da(i,".gitignore"),""),!ZS(Da(i,".git")));)i=hd(i),o++;return tb(e,"",t,r),n.size>0}function tb(e,t,n,r){let i=t?Da(e,t):e;r(Da(i,".gitignore"),t);let o;try{o=_j(i,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name===".git")continue;let a=t?`${t}/${s.name}`:s.name;Sd(n,e,`${a}/`)||tb(e,a,n,r)}}function Oj(e,t){let n=t.replaceAll("\\","/").replace(/\/+$/,"");return e.split(/\r?\n/).map(r=>Mj(r,n)).join(`
|
|
386
|
+
`)}function Mj(e,t){let n=e.trimStart();if(!n||n.startsWith("#"))return e;let r=e.slice(0,e.length-n.length),i=n.startsWith("!"),o=i?n.slice(1):n;if(!o||o.startsWith("#"))return e;let s=$j(o,t);return`${r}${i?"!":""}${s}`}var jj=`
|
|
387
|
+
# Dependencies
|
|
388
|
+
node_modules/
|
|
389
|
+
vendor/
|
|
390
|
+
.bundle/
|
|
391
|
+
|
|
392
|
+
# Build output
|
|
393
|
+
dist/
|
|
394
|
+
build/
|
|
395
|
+
out/
|
|
396
|
+
target/
|
|
397
|
+
bin/
|
|
398
|
+
obj/
|
|
399
|
+
|
|
400
|
+
# Python
|
|
401
|
+
__pycache__/
|
|
402
|
+
*.pyc
|
|
403
|
+
*.pyo
|
|
404
|
+
.venv/
|
|
405
|
+
venv/
|
|
406
|
+
.env/
|
|
407
|
+
env/
|
|
408
|
+
*.egg-info/
|
|
409
|
+
|
|
410
|
+
# Rust
|
|
411
|
+
target/
|
|
412
|
+
|
|
413
|
+
# Java / Kotlin / Scala
|
|
414
|
+
*.class
|
|
415
|
+
.gradle/
|
|
416
|
+
.mvn/
|
|
417
|
+
|
|
418
|
+
# C# / .NET
|
|
419
|
+
bin/
|
|
420
|
+
obj/
|
|
421
|
+
packages/
|
|
422
|
+
|
|
423
|
+
# Go
|
|
424
|
+
vendor/
|
|
425
|
+
|
|
426
|
+
# Dart
|
|
427
|
+
.dart_tool/
|
|
428
|
+
build/
|
|
429
|
+
|
|
430
|
+
# PHP
|
|
431
|
+
vendor/
|
|
432
|
+
|
|
433
|
+
# IDE / OS
|
|
434
|
+
.idea/
|
|
435
|
+
.vscode/
|
|
436
|
+
*.swp
|
|
437
|
+
*.swo
|
|
438
|
+
.DS_Store
|
|
439
|
+
Thumbs.db
|
|
440
|
+
|
|
441
|
+
# Type definitions (often noise in queries)
|
|
442
|
+
*.d.ts
|
|
443
|
+
`;function Sd(e,t,n){let r=Bj(t,n);if(!r)return!1;try{return e.ignores(r)}catch{return!1}}function Bj(e,t){if(!t||t===".")return null;if(!eb(t)&&!t.startsWith(".."))return t.replaceAll("\\","/");let n=eb(t)?t:kj(e,t),r=Dj(e,n).replaceAll("\\","/");return!r||r==="."||r.startsWith("..")?null:r}function $j(e,t){let n=e.startsWith("/"),r=n?e.slice(1):e;return(r.endsWith("/")?r.slice(0,-1):r).includes("/")||n?`${t}/${r}`:`${t}/**/${r}`}import{execFileSync as Gj}from"child_process";import{existsSync as Vj,readdirSync as nb}from"fs";import{extname as rb,join as ib}from"path";var ob=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Wj=[{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 ka(e){let t=[],n=Uj(e),r=Kj(e);for(let i of Wj){if(qj(e,i.files)){t.push(i.language);continue}if(Hj(n,i.globs)){t.push(i.language);continue}Xj(r,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&bd(t,"javascript"),Qj(t,r),t}function Uj(e){try{return nb(e)}catch{return[]}}function qj(e,t){return t?.length?t.some(n=>Vj(ib(e,n))):!1}function Hj(e,t){return t?.length?e.some(n=>t.some(r=>zj(n,r))):!1}function zj(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 Kj(e){let t=Yj(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=nb(i,{withFileTypes:!0})}catch{continue}Jj(i,o,r,n)}return n}function Jj(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=ib(e,i.name);if(i.isDirectory()){ob.has(i.name)||n.push(o);continue}let s=rb(i.name).toLowerCase();s&&r.add(s)}}function Yj(e){try{let t=qo(e,26214400,()=>Gj("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 Ho(t)){if(r.split("/").some(o=>ob.has(o)))continue;let i=rb(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function Xj(e,t){return t?.length?t.some(n=>e.has(n)):!1}function bd(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}function Qj(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?bd(e,"cpp"):n||bd(e,"c")}}import Zj from"better-sqlite3";var eB=25,tB=new Set(["typescript","javascript"]);function D8(e,t,n){let r=null;try{r=new Zj(e,{readonly:!0,fileMustExist:!0});let i=new Set(r.prepare("SELECT relative_path FROM documents").pluck().all().map(mn)),o=nB(t,n),s=new Set([...o.values()].flatMap(u=>[...u])),a=[...s].filter(u=>!i.has(u)).sort();if(a.length===0)return{state:"complete",expectedDocumentCount:s.size,actualDocumentCount:i.size};let c=new Set(a),l=n.filter(u=>[...o.get(u)??[]].some(d=>c.has(d)));return{state:"incomplete",expectedDocumentCount:s.size,actualDocumentCount:i.size,missingDocumentCount:a.length,missingPaths:a.slice(0,eB),affectedLanguages:l}}catch(i){return{state:"unavailable",reason:i instanceof Error?i.message:String(i)}}finally{r?.close()}}function nB(e,t){let n=new Map,r=t.filter(i=>tB.has(i));for(let i of r)n.set(i,new Set);for(let i of e.files){let o=mn(i.path);for(let s of r)ft(o,[s])==="source"&&n.get(s).add(o)}return n}import{existsSync as cb,readdirSync as lb,rmSync as ub}from"fs";import{join as ri}from"path";import{create as pb,fromBinary as fb,toBinary as z8}from"@bufbuild/protobuf";import{deserializeSCIP as xd,DocumentSchema as mb,IndexSchema as gb,serializeSCIP as yb}from"@c4312/scip";import{existsSync as rB,mkdirSync as iB,renameSync as oB,writeFileSync as sB}from"fs";import{join as aB}from"path";import{deflateRawSync as cB,inflateRawSync as lB}from"zlib";function ab(e){iB(e.blobDir,{recursive:!0});let t=aB(e.blobDir,`${e.blobHash}.scipdoc`);if(rB(t)){let r=H(t,{maxBytes:An,inputKind:e.inputKind});if(r.byteLength!==e.bytes.byteLength||$(r)!==e.blobHash)throw new Error(`existing ${e.inputKind} is corrupt: ${e.relativePath}`);return}let n=`${t}.${process.pid}.${Date.now()}.tmp`;sB(n,e.bytes),oB(n,t)}var sb=class{constructor(t=64*1024*1024,n=2e4){this.maxBytes=t;this.maxEntries=n}maxBytes;maxEntries;values=new Map;pending=new Map;bytes=0;get(t){return this.lookup(t)?.read()}lookup(t){let n=this.values.get(t)??this.pending.get(t);if(n!==void 0)return this.pending.delete(t),this.values.delete(t),this.values.set(t,n),{blobHash:n.blobHash,byteLength:n.length,read:()=>n.load?n.load():n.compressed?lB(n.bytes,{maxOutputLength:n.length}):n.bytes===null?null:Uint8Array.from(n.bytes)}}protectForGeneration(){for(let[t,n]of this.values)this.pending.set(t,n);this.values.clear()}set(t,n){if(this.delete(t),(n?.byteLength??0)>this.maxBytes)return;let i=uB(n),o=i.bytes?.byteLength??0;for(;this.bytes+o>this.maxBytes||this.values.size+this.pending.size>=this.maxEntries;){let s=this.values.keys().next().value;if(s===void 0)return;this.delete(s)}this.values.set(t,i),this.bytes+=o}setReference(t,n){this.delete(t.relativePath),!(this.values.size+this.pending.size>=this.maxEntries)&&this.values.set(t.relativePath,{blobHash:t.blobHash,length:t.byteLength,bytes:null,compressed:!1,load:n})}delete(t){let n=this.values.get(t)??this.pending.get(t);this.bytes-=n?.bytes?.byteLength??0,this.values.delete(t),this.pending.delete(t)}};function uB(e){let t=e===null?null:$(e),n=e?.byteLength??0,r=e&&n>=1024?cB(e,{level:1}):null;return r&&r.byteLength<n?{bytes:r,length:n,compressed:!0,blobHash:t}:{bytes:e===null?null:Uint8Array.from(e),length:n,compressed:!1,blobHash:t}}var vd=1,So="typescript-scip-fragments";function X8(e){let t=new Set,n=[];for(let o of e){let s=Aa(o.relativePath);if(t.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(t.add(s),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${s}`);let a=fb(mb,o.bytes);if(a.relativePath!==s)throw new Error(`TypeScript fragment path mismatch: expected ${s}, got ${a.relativePath}`);n.push(a)}let r=yb(pb(gb,{documents:n,externalSymbols:[]})),i=xd(r);if(i.documents.length!==n.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return r}function dB(e){let t=ri(e,So);return{rootDir:t,blobDir:ri(t,"blobs"),generationDir:ri(t,"generations")}}function hb(e){let t=pB(e);return fB(t.baseIndex,t.completeDocuments,"assembled")}function pB(e){let t=xd(e.baseIndexBytes);Rd(t.metadata,bB(e)),SB(t.externalSymbols);let n=xB(e),r=new Set,i=[],o=[],s=[];for(let a of t.documents){let c=Aa(a.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);r.add(c);let l=n.get(c);if(!l){i.push(a);continue}if(n.delete(c),l.bytes===null){s.push(c);continue}let u=db(c,l.bytes);i.push(u),o.push(u)}for(let a of[...n.keys()].sort()){let c=n.get(a);if(c.bytes===null)continue;if(r.has(a))throw new Error(`duplicate TypeScript SCIP document path: ${a}`);r.add(a);let l=db(a,c.bytes);i.push(l),o.push(l)}return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:s}}function db(e,t){let n=fb(mb,t);if(n.relativePath!==e)throw new Error(`TypeScript fragment path mismatch: expected ${e}, got ${n.relativePath}`);return n}function fB(e,t,n){let r=yb(pb(gb,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=xd(r);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${n} TypeScript SCIP index failed structural verification`);return r}function Q8(e,t){let n=dB(e);if(!cb(n.generationDir))return;let r=new Set(t.map(s=>hB(s))),i=lb(n.generationDir).filter(s=>s.endsWith(".json")),o=new Set;for(let s of i.filter(a=>r.has(a))){let a=mB(z(ri(n.generationDir,s),{maxBytes:re,inputKind:"TypeScript fragment manifest"}));for(let c of a.documents)o.add(`${c.blobHash}.scipdoc`)}for(let s of i)r.has(s)||ub(ri(n.generationDir,s),{force:!0});if(cb(n.blobDir))for(let s of lb(n.blobDir))o.has(s)||ub(ri(n.blobDir,s),{force:!0})}function mB(e){let t=JSON.parse(e);gB(t);let n=new Set;for(let r of t.documents){if(yB(r),Aa(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript fragment record");n.add(r.relativePath)}return t}function gB(e){if(e.version!==vd||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 yB(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 hB(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${$(e)}.json`}function SB(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function Rd(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!==Df(t))throw new Error("TypeScript SCIP shard producer identity changed")}function bB(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function Aa(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 xB(e){let t=new Map;for(let n of e.fragments){let r=Aa(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 Z8(e,t,n){let r=e.files.filter(i=>{let o=ft(i.path,e.languages);return o==="ambient"||o==="config"&&(!cs(i.path)||n.has(i.path))}).map(i=>{let s=ft(i.path,e.languages)==="config"?i.semanticHash:void 0;return{path:i.path,size:s===void 0?i.size:0,hash:s??i.hash}}).sort((i,o)=>i.path.localeCompare(o.path));return`typescript-project-v3:${$(JSON.stringify({version:3,producerIdentity:t,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),nonSourceInputs:r}))}`}function eZ(e,t){return $(JSON.stringify({version:1,producerIdentity:t,snapshot:br(e)}))}import{fromBinary as PB}from"@bufbuild/protobuf";import{MetadataSchema as wB}from"@c4312/scip";var dt=class extends Error{},vB=0,RB=1,Sb=2,IB=5;function Id(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 dt("varint exceeds the safe integer range");if((o&128)===0)return{value:r,pos:t};if(i+=7,i>63)throw new dt("varint is longer than 64 bits")}throw new dt("varint runs past the end of the buffer")}function*_e(e,t=0,n=e.length){let r=t;for(;r<n;){let i=r,o=Id(e,r,n);r=o.pos;let s=Math.floor(o.value/8),a=o.value%8;if(s===0)throw new dt("field number 0 is invalid");let c=r,l=0;if(a===vB){let u=Id(e,r,n);l=u.value,r=u.pos}else if(a===Sb){let u=Id(e,r,n);if(c=u.pos,r=u.pos+u.value,r>n)throw new dt("length-delimited field runs past the end of the buffer")}else if(a===RB)r+=8;else if(a===IB)r+=4;else throw new dt(`unsupported wire type ${a}`);if(r>n)throw new dt("field value runs past the end of the buffer");yield{fieldNumber:s,wireType:a,fieldStart:i,valueStart:c,valueEnd:r,fieldEnd:r,varint:l}}}function bo(e){if(!Number.isSafeInteger(e)||e<0)throw new dt(`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 Oa(e){return bo(e*8+Sb)}var CB=1,EB=3;function xo(e){let t=new TextDecoder,n;for(let r of _e(e))if(!(r.fieldNumber!==CB||r.wireType!==2))for(let i of _e(e,r.valueStart,r.valueEnd)){if(i.fieldNumber!==EB||i.wireType!==2)continue;let o=t.decode(e.subarray(i.valueStart,i.valueEnd));o&&(n=o)}return n}import{existsSync as ja,readdirSync as Cd,rmSync as bb}from"fs";import{join as jt}from"path";var Ba=1,vo="typescript-scip-overlays",xb="typescript-project-v3:";function FB(e){let t=Ib(e.cacheDir,e.previousGenerationIdentity);LB(e,t);let n=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),r=new Set;for(let o of e.fragments){let s=$a(o.relativePath);if(r.has(s))throw new Error(`duplicate TypeScript overlay: ${s}`);r.add(s),n.set(s,DB(e.cacheDir,o))}if(NB(e,n,r),r.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:Ba,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...n.values()].sort((o,s)=>o.relativePath.localeCompare(s.relativePath))};return kB(e.cacheDir,i),i}function fZ(e){let t=[],n=!1,r=new TextDecoder("utf-8",{fatal:!0});for(let i of _e(e.indexBytes)){if(i.wireType!==2)continue;let o=e.indexBytes.subarray(i.valueStart,i.valueEnd);if(i.fieldNumber===1)Rd(PB(wB,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 s=TB(o,r);t.push({relativePath:s,bytes:o,occurrences:0,symbols:0,referenceFragments:[]})}}}if(!n)throw new Error("TypeScript overlay seed has no producer identity");return FB({...e,previousGenerationIdentity:e.generationIdentity,nextGenerationIdentity:e.generationIdentity,baseShardCurrent:!0,fragments:t})}function TB(e,t){let n;for(let r of _e(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 NB(e,t,n){for(let r of e.retainedDocuments??[]){Cb(r);let i=$a(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}`);Rb(e.cacheDir,r),n.add(i)}}function LB(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=_B(e,t);if(t&&t.projectIdentity!==e.projectIdentity&&!e.allowProjectIdentityChange&&!n)throw new Error("TypeScript overlay project identity changed")}function _B(e,t){return e.allowLegacyProjectIdentityMigration===!0&&t!==null&&!t.projectIdentity.startsWith(xb)&&e.projectIdentity.startsWith(xb)}function mZ(e){let t=Ib(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=Rb(e.cacheDir,r);return{relativePath:r.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return hb({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:n})}function Rb(e,t){let n=H(jt(Ro(e),"blobs",`${t.blobHash}.scipdoc`),{maxBytes:An,inputKind:"TypeScript overlay blob"});if(n.byteLength!==t.byteLength||$(n)!==t.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${t.relativePath}`);return n}function gZ(e,t){let n=Ro(e),r=jt(n,"generations");if(!ja(r))return;let i=new Set(t.map(Pd)),o=new Set;for(let a of Cd(r).filter(c=>i.has(c))){let c=Ed(z(jt(r,a),{maxBytes:re,inputKind:"TypeScript overlay manifest"}));for(let l of c.overlays)l.blobHash&&o.add(`${l.blobHash}.scipdoc`)}for(let a of Cd(r))i.has(a)||bb(jt(r,a),{force:!0});let s=jt(n,"blobs");if(ja(s))for(let a of Cd(s))o.has(a)||bb(jt(s,a),{force:!0})}function Ib(e,t){let n=jt(Ro(e),"generations",Pd(t));if(!ja(n))return null;let r=Ed(z(n,{maxBytes:re,inputKind:"TypeScript overlay manifest"}));if(r.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return r}function DB(e,t){let n=$a(t.relativePath);if(t.bytes===null)return{relativePath:n,blobHash:null,byteLength:0};let r=Buffer.from(t.bytes),i=$(r);return ab({blobDir:jt(Ro(e),"blobs"),blobHash:i,bytes:r,relativePath:n,inputKind:"TypeScript overlay blob"}),{relativePath:n,blobHash:i,byteLength:r.byteLength}}function kB(e,t){let n=jt(Ro(e),"generations",Pd(t.generationIdentity));if(ja(n)){let r=Ed(z(n,{maxBytes:re,inputKind:"TypeScript overlay manifest"}));if(vb(r)!==vb(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}Pn(n,t,{spacing:2,trailingNewline:!0})}function Ed(e){let t=JSON.parse(e);AB(t);let n=new Set;for(let r of t.overlays){if(Cb(r),$a(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript overlay record");n.add(r.relativePath)}return t}function AB(e){if(e.version!==Ba||!Ma(e.producerIdentity)||!Ma(e.projectIdentity)||!Ma(e.baseGenerationIdentity)||!Ma(e.generationIdentity)||typeof e.createdAt!="string"||!Number.isFinite(Date.parse(e.createdAt))||!Array.isArray(e.overlays))throw new Error("invalid TypeScript overlay manifest")}function Ma(e){return typeof e=="string"&&e!==""}function Cb(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 Ro(e){return jt(e,vo)}function Pd(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${$(e)}.json`}function vb(e){return $(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function $a(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{writeSync as OB}from"fs";function pt(e,t,n="File"){let r=0;for(;r<t.byteLength;){let i=OB(e,t,r,t.byteLength-r);if(i<=0)throw new Error(`${n} write made no forward progress.`);r+=i}}import{closeSync as Eb,openSync as MB,renameSync as jB,rmSync as BB}from"fs";import{create as Ga,fromBinary as Pb,toBinary as $B}from"@bufbuild/protobuf";import{DocumentSchema as Va,IndexSchema as GB,MetadataSchema as VB,PositionEncoding as wd,SymbolInformationSchema as WB,SymbolRole as wb}from"@c4312/scip";var Fd=2,UB=3,qB=1,HB=2,zB=3,KB=4,JB=6,YB=1,XB=2,QB=3;function PZ(e){let t;try{t=H(e,{inputKind:"SCIP sanitization input",maxBytes:fe})}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}try{return ZB(t,e)}catch(n){if(n instanceof dt)return{removedDefinitionOccurrences:0,touchedDocuments:0};throw n}}function ZB(e,t){let n=new TextDecoder,r=new Set;e0(e,n,r);let i=0,o=0,s=[],a=i0(e);for(let c of _e(e)){if(c.wireType!==2||c.fieldNumber!==Fd)continue;let l=n0(e,c,n,r,a);Db(l)&&(i+=l.removed,o+=l.symbols.length,s.push({field:c,repair:l}))}return s.length>0&&r0(e,t,s),Nb(i,s.length,o)}function Fb(e,t,n,r){if((t&wb.Definition)!==0){if(!e){r.removed++;return}e.startsWith("local ")||n.has(e)||(n.add(e),r.symbols.push(e))}}function Tb(e,t){return Db(t)?Ga(Va,{...e,positionEncoding:t.positionEncoding??e.positionEncoding,occurrences:e.occurrences.filter(n=>n.symbol||(n.symbolRoles&wb.Definition)===0),symbols:[...e.symbols,...t.symbols.map(n=>Ga(WB,{symbol:n}))]}):e}function Nb(e,t,n){return{removedDefinitionOccurrences:e,touchedDocuments:t,...n>0?{recoveredDefinitionSymbols:n}:{}}}function e0(e,t,n){for(let r of _e(e))r.wireType===2&&(r.fieldNumber===Fd?t0(e,r,t,n):r.fieldNumber===UB&&Lb(e,r,t,n))}function t0(e,t,n,r){for(let i of _e(e,t.valueStart,t.valueEnd))i.wireType===2&&(i.fieldNumber===qB?ve(n.decode(e.subarray(i.valueStart,i.valueEnd))):i.fieldNumber===zB&&Lb(e,i,n,r))}function Lb(e,t,n,r){for(let i of _e(e,t.valueStart,t.valueEnd)){if(i.wireType!==2||i.fieldNumber!==YB)continue;let o=n.decode(e.subarray(i.valueStart,i.valueEnd));o&&r.add(o)}}function n0(e,t,n,r,i){let o={removed:0,symbols:[]},s="",a=wd.UnspecifiedPositionEncoding;for(let c of _e(e,t.valueStart,t.valueEnd)){if(c.fieldNumber===KB&&c.wireType===2&&(s=n.decode(e.subarray(c.valueStart,c.valueEnd))),c.fieldNumber===JB&&c.wireType===0&&(a=c.varint),c.wireType!==2||c.fieldNumber!==HB)continue;let{symbol:l,symbolRoles:u}=o0(e,c,n);Fb(l,u,r,o)}return o.positionEncoding=Td(s,a,i),o}function r0(e,t,n){let r=`${t}.sanitize-tmp`,i=MB(r,"w",384);try{let o=0;for(let{field:s,repair:a}of n){pt(i,e.subarray(o,s.fieldStart));let c=Tb(Pb(Va,e.subarray(s.valueStart,s.valueEnd)),a),l=$B(Va,c);pt(i,Oa(Fd)),pt(i,bo(l.byteLength)),pt(i,l),o=s.fieldEnd}pt(i,e.subarray(o))}catch(o){throw Eb(i),BB(r,{force:!0}),o}Eb(i),jB(r,t)}function _b(e){let t=new Set;for(let s of e.documents){ve(s.relativePath);for(let a of s.symbols)a.symbol&&t.add(a.symbol)}for(let s of e.externalSymbols)s.symbol&&t.add(s.symbol);let n=0,r=0,i=0,o=e.documents.map(s=>{let a={removed:0,symbols:[]};for(let l of s.occurrences)Fb(l.symbol,l.symbolRoles,t,a);a.positionEncoding=Td(s.language,s.positionEncoding,e.metadata);let c=Tb(s,a);return c!==s&&i++,n+=a.removed,r+=a.symbols.length,c});return{index:i===0?e:Ga(GB,{...e,documents:o}),...Nb(n,i,r)}}function Db(e){return e.removed>0||e.symbols.length>0||e.positionEncoding!==void 0}function Td(e,t,n){if(t===wd.UnspecifiedPositionEncoding&&!(e!==""&&e!=="python")&&!(n?.toolInfo?.name!=="scip-python"||!["0.7.4","0.7.5"].includes(n.toolInfo.version)))return wd.UTF16CodeUnitOffsetFromLineStart}function Nd(e,t){let n=Td(e.language,e.positionEncoding,t);return n===void 0?e:Ga(Va,{...e,positionEncoding:n})}function i0(e){let t;for(let n of _e(e)){if(n.fieldNumber!==1||n.wireType!==2)continue;let r=Pb(VB,e.subarray(n.valueStart,n.valueEnd));if(!r.toolInfo||t&&JSON.stringify(t.toolInfo)!==JSON.stringify(r.toolInfo))return;t=r}return t}function o0(e,t,n){let r="",i=0;for(let o of _e(e,t.valueStart,t.valueEnd))o.fieldNumber===XB&&o.wireType===2?r=n.decode(e.subarray(o.valueStart,o.valueEnd)):o.fieldNumber===QB&&o.wireType===0&&(i=o.varint);return{symbol:r,symbolRoles:i}}import{writeSync as s0,closeSync as Io,openSync as Ld,readSync as a0,renameSync as c0,rmSync as Mb,statSync as l0,writeFileSync as jb}from"fs";import{create as Co,fromBinary as u0,toBinary as d0}from"@bufbuild/protobuf";import{deserializeSCIP as Bb,serializeSCIP as $b,DocumentSchema as p0,IndexSchema as kb,MetadataSchema as _d,SymbolInformationSchema as f0,SymbolRole as m0}from"@c4312/scip";function Gb(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1){let i=e[0];return Co(kb,{...i,documents:i.documents.map(o=>Nd(o,i.metadata))})}let t=g0(e),n=y0(e.flatMap(i=>i.documents.map(o=>Nd(o,i.metadata)))),r=Wb(e.flatMap(i=>i.externalSymbols??[]));return Co(kb,{metadata:t,documents:n,externalSymbols:r})}function OZ(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>Bb(H(i,{inputKind:"SCIP merge input",maxBytes:fe}))),r=Gb(n);return jb(t,$b(r)),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function MZ(e,t){if(e.length===0)throw new Error("Cannot concatenate zero SCIP files");let n=0;for(let o of e)if(n+=l0(o).size,n>fe)throw new Error(`Concatenated SCIP output exceeds the ${fe}-byte artifact limit. Reduce the indexed project scope or use compatible cached generations.`);let r=Buffer.allocUnsafe(1024*1024),i=Ld(t,"w",384);try{for(let o of e){let s=Ld(o,"r");try{let a=0;for(;(a=a0(s,r,0,r.byteLength,null))>0;){let c=0;for(;c<a;)c+=s0(i,r,c,a-c)}}finally{Io(s)}}}catch(o){throw Io(i),Mb(t,{force:!0}),o}Io(i)}function jZ(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=se("reindex.publish.scip-output.deserialize",()=>e.map(o=>Bb(H(o,{inputKind:"SCIP merge input",maxBytes:fe})))),r=se("reindex.publish.scip-output.merge",()=>Gb(n)),i=se("reindex.publish.scip-output.sanitize",()=>_b(r));return se("reindex.publish.scip-output.serialize",()=>jb(t,$b(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 Ab=1;function Vb(e,t,n){let r=H(e,{inputKind:"SCIP normalization input",maxBytes:fe}),i=xo(r),o=[];for(let c of _e(r))c.fieldNumber===Ab&&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 s=`${e}.rebase-tmp`,a=Ld(s,"w",384);try{let c=0;for(let l of o){pt(a,r.subarray(c,l.fieldStart));let u=u0(_d,r.subarray(l.valueStart,l.valueEnd));u.projectRoot=n;let d=d0(_d,u);pt(a,Oa(Ab)),pt(a,bo(d.byteLength)),pt(a,d),c=l.fieldEnd}pt(a,r.subarray(c))}catch(c){throw Io(a),Mb(s,{force:!0}),c}Io(a),c0(s,e)}function g0(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:Co(_d,{...t,toolInfo:void 0})}function y0(e){let t=new Map;for(let n of e){let r=t.get(n.relativePath);if(!r){t.set(n.relativePath,n);continue}h0(r,n),t.set(n.relativePath,Co(p0,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:S0([...r.occurrences,...n.occurrences]),symbols:Wb([...r.symbols,...n.symbols]),text:r.text||n.text,positionEncoding:r.occurrences.length?r.positionEncoding:n.positionEncoding}))}return[...t.values()]}function h0(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=Ob(e),r=Ob(t);for(let[i,o]of r){let s=n.get(i);if(s!==void 0&&(o.length===0||JSON.stringify(s)!==JSON.stringify(o)))throw new Error(`Cannot merge ${e.relativePath}: conflicting document-local identity ${i}.`)}}function Ob(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&m0.Definition)!==0&&r.add(JSON.stringify(Dd(n.range))),t.set(n.symbol,r)}return new Map([...t].map(([n,r])=>[n,[...r].sort()]))}function Dd(e){return e.length===3?[e[0],e[1],e[0],e[2]]:e}function S0(e){let t=new Set,n=[];for(let r of e){let i=JSON.stringify({...r,range:Dd(r.range),enclosingRange:Dd(r.enclosingRange)});t.has(i)||(t.add(i),n.push(r))}return n}function Wb(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,Co(f0,{symbol:r.symbol,documentation:x0([...r.documentation,...n.documentation]),relationships:b0([...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 b0(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 x0(e){return[...new Set(e)]}import{createHash as $d,randomUUID as v0}from"crypto";import{closeSync as R0,copyFileSync as I0,existsSync as V,mkdirSync as C0,openSync as E0,readSync as P0,readdirSync as Gd,renameSync as Od,rmSync as cr,statSync as lr}from"fs";import{basename as qb,dirname as Rt,join as A,relative as Ub}from"path";import Hb from"better-sqlite3";var Md=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});async function XZ(e,t){let n=Rt(e),r=A(n,"index.scip"),i=A(n,"meta.json"),o=await $S(A(n,"index.lock"),{waitMs:1e4});if(!o)throw new Error(`Another index writer is active for ${n}.`);let s=`${e}.augment-${v0()}`,a=`${s}.meta.json`;try{if(!V(e)||!V(i)||!V(r))throw new Error("Standalone augmentation requires a published index; run scip-query reindex first.");let c=zb(e,r,i),l=new Hb(e,{readonly:!0,fileMustExist:!0});try{await l.backup(s)}finally{l.close()}let u=await t(s);return I0(i,a),Vd({outputDb:e,outputScip:r,metaPath:i,tempOutputDb:s,tempMetaPath:a,tempOutputScip:r,preserveOutputScip:!0,...c?.publication?{publication:c.publication}:{}}),u}finally{try{for(let c of[s,`${s}-wal`,`${s}-shm`,`${s}-journal`,a])cr(c,{force:!0})}finally{o.release()}}}function Vd(e){let t=de(e.outputDb),n=A0(e);e.onStage?.("after-recovery-retained");let r=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=O0(e,n),o=Ud({generationRoot:t,databasePath:e.tempOutputDb,indexPath:V(r)?r:void 0,verifiedIndexArtifact:i,metadataPath:V(e.tempMetaPath)?e.tempMetaPath:void 0}),s=(e.now??(()=>new Date))().toISOString(),a={version:ar,currentGeneration:o.identity,artifactSet:"immutable-v1",...n?{previousGeneration:n}:{},...e.publication?{publication:e.publication}:{},publishedAt:s},c=Xe(A(t,"state.json"),a,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||Bd(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),H0(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),Bd(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let l=o.identity,u={...a,stableMirrors:Wd(e.outputDb,e.outputScip)};Xe(A(t,"state.json"),u,{spacing:2,trailingNewline:!0});let d=Kb(e.outputDb,{now:e.now}),p=Z(o.directorySync,c.directorySync);return{currentGeneration:l,...n?{previousGeneration:n}:{},retention:d,achievedDurability:p==="synced"?"directory-durable":"file-flushed",directorySync:p}}function zb(e,t,n,r=()=>new Date){if(!V(e))return null;let i=wn(e),o=A(de(e),"state.json");if(J0(e,i))return i;let s=de(e),a=!i&&V(o)?j0(n,e,t):void 0;if(a&&!ho(s,a))return null;let c=Ud({generationRoot:s,databasePath:e,indexPath:V(t)?t:void 0,metadataPath:V(n)?n:void 0,forcedIdentity:i?.currentGeneration??a}),l=K0(c.identity,e,t,i,r);return Xe(A(s,"state.json"),l,{spacing:2,trailingNewline:!0}),l}function QZ(e,t,n=()=>new Date){if(!V(e)||!V(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let r=wn(e),i=de(e),o=Ud({generationRoot:i,databasePath:e,indexPath:V(A(Rt(e),"index.scip"))?A(Rt(e),"index.scip"):void 0,metadataPath:t}),s=r&&r.currentGeneration!==o.identity?Qb(e,r.currentGeneration):void 0,a={version:ar,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:Wd(e,A(Rt(e),"index.scip")),...s?{previousGeneration:s}:{},...r?.publication?{publication:r.publication}:{},publishedAt:n().toISOString()};return Xe(A(de(e),"state.json"),a,{spacing:2,trailingNewline:!0}),Kb(e,{now:n}),a}function Kb(e,t={}){let n=_0(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=sn(La(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 w0(e,t,n,i)}catch(s){let a={state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:n,at:i,reason:s instanceof Error?s.message:String(s)};try{Xb(e,a)}catch{}return a}finally{o.release()}}function w0(e,t,n,r){let i=wn(e),o=Jb(e),s=md(e,o.map(h=>h.identity),{isProcessAlive:t.isProcessAlive??or,readProcessIdentity:t.readProcessIdentity??rn}),a=new Set(s.protectedGenerations);i?.currentGeneration&&a.add(i.currentGeneration),i?.previousGeneration?.generationIdentity&&a.add(i.previousGeneration.generationIdentity);let{generationCount:c,logicalBytes:l,removedGenerations:u,removedLogicalBytes:d}=T0(o,a,n,t),p=c>n.maxGenerations||l>n.maxLogicalBytes,f={state:p?"protected":u>0?"collected":"within-bounds",generationCount:c,logicalBytes:l,protectedGenerations:a.size,activeReaderLeases:s.activeLeases,staleReaderLeasesRemoved:s.staleLeasesRemoved,malformedReaderLeases:s.malformedLeases,removedGenerations:u,removedLogicalBytes:d,limits:n,at:r,...p?{reason:F0(s.malformedLeases)}:{}};return Xb(e,f),f}function F0(e){return e>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}function T0(e,t,n,r){let i=e.length,o=e.reduce((c,l)=>c+l.logicalBytes,0),s=0,a=0;for(let c of e){if(i<=n.maxGenerations&&o<=n.maxLogicalBytes)break;t.has(c.identity)||(r.onBeforeRemove?.(c.identity),cr(c.path,{recursive:!0,force:!0}),i-=1,o-=c.logicalBytes,s+=1,a+=c.logicalBytes)}return{generationCount:i,logicalBytes:o,removedGenerations:s,removedLogicalBytes:a}}function ZZ(e){let t=de(e);if(!V(t))return{state:"absent",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:{...Md},reason:"local immutable generation store does not exist"};let n=D0(e),r=n?.limits??{...Md},i=sn(La(e),{waitMs:0});if(!i)return N0(r,n);try{return L0(e,r,n)}catch(o){return{state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:r,...n?{lastCollection:n}:{},reason:o instanceof Error?o.message:String(o)}}finally{i.release()}}function N0(e,t){return{state:"deferred",generationCount:t?.generationCount??0,logicalBytes:t?.logicalBytes??0,protectedGenerations:t?.protectedGenerations??0,activeReaderLeases:t?.activeReaderLeases??0,malformedReaderLeases:t?.malformedReaderLeases??0,limits:e,...t?{lastCollection:t}:{},reason:"another process owns local generation retention"}}function L0(e,t,n){let r=Jb(e),i=wn(e),o=md(e,r.map(a=>a.identity),{isProcessAlive:or,readProcessIdentity:rn},{removeStale:!1}),s=new Set(o.protectedGenerations);return i?.currentGeneration&&s.add(i.currentGeneration),i?.previousGeneration?.generationIdentity&&s.add(i.previousGeneration.generationIdentity),{state:"managed",generationCount:r.length,logicalBytes:r.reduce((a,c)=>a+c.logicalBytes,0),...r[0]?{oldestGenerationAt:new Date(r[0].modifiedAtMs).toISOString()}:{},protectedGenerations:s.size,activeReaderLeases:o.activeLeases,malformedReaderLeases:o.malformedLeases,limits:t,...n?{lastCollection:n}:{},...o.malformedLeases>0?{reason:"malformed reader ownership evidence prevents unsafe collection"}:{}}}function _0(e={}){let t={...Md,...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 Jb(e){let t=de(e);return V(t)?Gd(t,{withFileTypes:!0}).filter(n=>n.isDirectory()&&/^[a-f0-9]{64}$/.test(n.name)).map(n=>{let r=A(t,n.name),i=ho(t,n.name),o=i?i.database.size+(i.index?.size??0)+(i.metadata?.size??0):Yb(r);return{identity:n.name,path:r,logicalBytes:o,modifiedAtMs:lr(r).mtimeMs}}).sort((n,r)=>n.modifiedAtMs-r.modifiedAtMs||n.identity.localeCompare(r.identity)):[]}function Yb(e){let t=0;for(let n of Gd(e,{withFileTypes:!0})){let r=A(e,n.name);n.isDirectory()?t+=Yb(r):n.isFile()&&(t+=lr(r).size)}return t}function Xb(e,t){Pn(A(de(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function D0(e){try{let t=JSON.parse(_(A(de(e),"gc.json"),"local SQLite generation GC status"));return!t||!Y0(t.state)||!Number.isSafeInteger(t.generationCount)||t.generationCount<0||!Number.isFinite(t.logicalBytes)||t.logicalBytes<0||!Number.isFinite(Date.parse(t.at))?void 0:t}catch{return}}function Ua(e,t=A(Rt(e),"meta.json")){let n=A(de(e),"state.json");if(!V(n))return{state:"legacy",statePath:n};let r=wn(e);if(!r)return{state:"invalid",statePath:n,reason:"generation state is malformed"};try{let i=ni(e,r.currentGeneration),o=i!==null,s=i?k0(e,t,i,r):!1,a=r.previousGeneration?V(A(Rt(e),r.previousGeneration.databasePath)):!0;return!s||!o||!a?{state:"drifted",statePath:n,currentMatches:s,recoveryExists:a,generation:r,reason:X0(o,s)}:{state:"current",statePath:n,currentMatches:s,recoveryExists:a,generation:r}}catch(i){return{state:"drifted",statePath:n,currentMatches:!1,recoveryExists:!1,generation:r,reason:i instanceof Error?i.message:String(i)}}}function k0(e,t,n,r){if(!Q0(e,r)||!jd(e,n.database))return!1;let i=A(Rt(e),"index.scip");if(n.index&&!jd(i,n.index))return!1;if(!n.metadata)return!V(t);if(!V(t))return!1;let o=A(de(e),n.identity,n.metadata.file);return V(o)&&Fn(_(t,"reindex metadata"))===Fn(_(o,"immutable reindex metadata"))}function jd(e,t){return V(e)&&lr(e).isFile()&&lr(e).size===t.size}function A0(e){let t=zb(e.outputDb,e.outputScip,e.metaPath);return t?Qb(e.outputDb,t.currentGeneration):void 0}function O0(e,t){if(!e.preserveOutputScip)return;if(!t)throw new Error("deferred SCIP publication requires an accepted immutable generation");let n=Ua(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=ni(e.outputDb,t.generationIdentity);if(!r?.index||!jd(e.outputScip,r.index))throw new Error("deferred SCIP publication requires the verified accepted index artifact");return r.index}function Wd(e,t){return{databaseFileIdentity:an(e),...V(t)?{indexFileIdentity:an(t)}:{}}}function Qb(e,t){let n=A(de(e),t),r=ni(e,t);if(!r)throw new Error("Cannot retain recovery artifacts without a valid generation manifest.");let i=A(n,r.database.file),o=r.metadata?A(n,r.metadata.file):void 0;return{generationIdentity:t,databasePath:Ub(Rt(e),i),...o?{metadataPath:Ub(Rt(e),o)}:{}}}function M0(e){if(V(e))for(let t of Gd(e,{withFileTypes:!0}))t.isDirectory()&&t.name.endsWith(".tmp")&&cr(A(e,t.name),{recursive:!0,force:!0})}function j0(e,t,n=A(Rt(t),"index.scip")){let r=$d("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(Wa(t)),V(n)&&r.update(`\0${Wa(n)}`),V(e)&&r.update(`\0${Fn(_(e,"reindex metadata"))}`),r.digest("hex")}function Ud(e){z0(e.databasePath);let t=kd(e.databasePath),n=e.indexPath?e.verifiedIndexArtifact?V0(e.indexPath,e.verifiedIndexArtifact):kd(e.indexPath):void 0,r=e.metadataPath?kd(e.metadataPath):void 0,i=e.forcedIdentity??G0(t,n,e.metadataPath),o=A(e.generationRoot,i),s=A(o,Na);if(V(s))return $0(e,i,o,t,n);let a=[Te(e.generationRoot)];M0(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;cr(c,{recursive:!0,force:!0}),C0(c,{recursive:!0});try{B0(e,c,t,n,r,a);let l=Xe(A(c,Na),{version:fd,identity:i,database:t,...n?{index:n}:{},...r?{metadata:r}:{}},{spacing:2,trailingNewline:!0});l.directorySync!=="not-requested"&&a.push(l.directorySync),a.push(G(c)),Od(c,o),a.push(G(e.generationRoot))}finally{cr(c,{recursive:!0,force:!0})}return{identity:i,directorySync:Z(...a)}}function B0(e,t,n,r,i,o){o.push(Ad(e.databasePath,A(t,n.file))),r&&e.indexPath&&o.push(Ad(e.indexPath,A(t,r.file))),i&&e.metadataPath&&o.push(Ad(e.metadataPath,A(t,i.file)))}function $0(e,t,n,r,i){let o=ho(e.generationRoot,t);if(o&&Zb(n,o.database,r)&&U0(n,o.index,i)&&q0(n,o.metadata,e.metadataPath))return{identity:t,directorySync:G(e.generationRoot)};throw new Error(`SQLite generation ${t} already exists with different or corrupt artifacts.`)}function G0(e,t,n){let r=$d("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(e.sha256),t&&r.update(`\0${t.sha256}`),n&&r.update(`\0${Fn(_(n,"reindex metadata"))}`),r.digest("hex")}function kd(e){return{file:qb(e),size:lr(e).size,sha256:Wa(e)}}function V0(e,t){if(t.file!==qb(e)||lr(e).size!==t.size)throw new Error(`verified SQLite generation artifact changed before publication: ${e}`);return t}function Wa(e){let t=$d("sha256"),n=E0(e,"r"),r=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=W0(n,r);if(i===0)break;t.update(r.subarray(0,i))}}finally{R0(n)}return t.digest("hex")}function W0(e,t){let n=0;for(;n<t.length;){let r=P0(e,t,n,t.length-n,null);if(n+=r,r===0)break}return n}function Ad(e,t){return lo(e,t,{mode:292})}function Zb(e,t,n){let r=A(e,t.file);return t.file===n.file&&t.size===n.size&&t.sha256===n.sha256&&V(r)&&lr(r).size===t.size&&Wa(r)===t.sha256}function U0(e,t,n){return!t||!n?t===n:Zb(e,t,n)}function q0(e,t,n){if(!t||!n)return t===void 0&&n===void 0;let r=A(e,t.file);return V(r)&&Fn(_(r,"stored reindex metadata"))===Fn(_(n,"candidate reindex metadata"))}function H0(e,t){for(let n of["-wal","-shm","-journal"])cr(`${t}${n}`,{force:!0});Bd(e,t)}function z0(e){let t=new Hb(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 Bd(e,t){cr(`${t}.tmp-replace`,{force:!0}),Od(e,`${t}.tmp-replace`),Od(`${t}.tmp-replace`,t)}function K0(e,t,n,r,i){return{version:ar,currentGeneration:e,artifactSet:"immutable-v1",stableMirrors:Wd(t,n),...r?.previousGeneration?{previousGeneration:r.previousGeneration}:{},...r?.publication?{publication:r.publication}:{},publishedAt:r?.publishedAt??i().toISOString()}}function J0(e,t){return t?.artifactSet==="immutable-v1"&&!!ni(e,t.currentGeneration)}function Y0(e){return e==="within-bounds"||e==="collected"||e==="protected"||e==="deferred"||e==="error"}function X0(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 Q0(e,t){return!(t.stableMirrors&&(t.stableMirrors.databaseFileIdentity!==an(e)||t.stableMirrors.indexFileIdentity!==void 0&&t.stableMirrors.indexFileIdentity!==an(A(Rt(e),"index.scip"))))}import{createHash as sx,randomUUID as o$}from"crypto";import{existsSync as $t,lstatSync as Kd,mkdirSync as ii,mkdtempSync as ax,readdirSync as cx,realpathSync as lx,renameSync as ur,rmSync as Tn,statSync as Ja}from"fs";import{dirname as zd,join as E,resolve as cn}from"path";import{setTimeout as s$}from"timers/promises";import{pathToFileURL as rx}from"url";import a$ from"better-sqlite3";import{lstatSync as Z0,readdirSync as e$}from"fs";import{join as t$,relative as n$,resolve as qd,sep as r$}from"path";var Eo=1,Hd="language-indexes",ex=["index.db","index.scip","meta.json"],tx=[Hd,So,vo];function qa(e){let t=[];for(let n of ex)i$(e,n),t.push(n);for(let n of tx)nx(e,n,t);return{version:Eo,files:t.sort()}}function Ha(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(!ex.includes(e)&&!tx.includes(n))throw new Error(`index artifact path is not shareable: ${e}`);return e}function Bt(e,t){let n=Ha(t),r=qd(e),i=qd(r,...n.split("/"));if(i!==r&&!i.startsWith(`${r}${r$}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function nx(e,t,n){let r=t$(e,t),i;try{i=e$(r,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let s=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${s}`);o.isDirectory()?nx(e,s,n):o.isFile()&&n.push(Ha(s))}}function i$(e,t){let n=Bt(e,t),r;try{r=Z0(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(n$(qd(e),n).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var Jd=1,ix="SCIP_QUERY_SHARED_CACHE",c$=2,za=JSON.stringify({cliVersion:Ko,typescriptSymbolIdentityVersion:6,artifactCatalogVersion:Eo,postIndexAugmentationSchemaVersion:c$,sqliteGenerationStoreVersion:ar,typescriptFragmentStoreVersion:vd,typescriptOverlayStoreVersion:Ba}),Yd="manifest.json",ux="shared-cache.json",l$=6e4,Xd=[Hd,So,vo];function Ya(e,t){if(!e.clean||!e.treeOid)return;let n=bx(JSON.stringify({version:Jd,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:br(t),producerIdentity:za}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:za,generationId:n,repositoryCacheDir:ms(e.repositoryId)}}function L3(e,t,n){if(!$$(n))return!1;let r=Ya(e,n);if(!r)return!1;try{let i=hx(t);if(!i||i.repositoryId!==e.repositoryId||i.worktreeId!==e.worktreeId)return!1;let o=JSON.parse(z(E(r.repositoryCacheDir,"worktrees",`${i.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:re}));return u$(o,i,e,t,r)?ln(r,!1)!==null:!1}catch{return!1}}function u$(e,t,n,r,i){return!(e.version!==1||e.repositoryId!==t.repositoryId||e.worktreeId!==t.worktreeId||cn(e.projectRoot)!==cn(n.projectRoot)||e.treeOid!==n.treeOid||cn(e.localCacheDir)!==cn(r)||e.ownershipChecksum!==Xa(e)||e.baseGenerationId!==i.generationId||e.activeGenerationId!==i.generationId)}function dx(e,t,n){if(process.env[ix]==="0")return`${ix}=0`;if(!il(n))return"explicit cache or database override";if(sl(zd(t))!==sl(fs(e))||t!==E(zd(t),"index.db"))return"index database is outside the managed worktree cache"}function _3(e,t,n){if(!il(t))return;let r=n??vi(e);return r?E(ms(r.repositoryId),"evidence.db"):void 0}function ln(e,t=!0){let n=Zd(e),r;try{r=gx(z(E(n,Yd),{inputKind:"shared-generation manifest",maxBytes:re}))}catch{return null}if(!G$(r,e)||!k$(n))return null;if(!t)return r;try{for(let i of r.artifacts){let o=Bt(n,i.path),s=Ja(o);if(!s.isFile()||s.size!==i.size||On(o,{inputKind:"shared-generation artifact",maxBytes:fe})!==i.sha256)return null}}catch{return null}return r}function px(e,t,n,r){if(!e.treeOid)return null;let i=wr(t,n),o=E(ps(),"repositories",e.repositoryId),s;try{let l=Kd(o);if(!l.isDirectory()||l.isSymbolicLink())return null;s=lx(o)}catch{return null}let a=E(s,"generations"),c=[];try{d$(a,e,i,c)}catch{return null}c.sort((l,u)=>{let d=l.treeOid===e.treeOid?0:1,p=u.treeOid===e.treeOid?0:1;if(d!==p)return d-p;if(r){let h=ox(l.fingerprint,r)-ox(u.fingerprint,r);if(h!==0)return h}return Date.parse(u.createdAt)-Date.parse(l.createdAt)||l.generationId.localeCompare(u.generationId)});for(let l of c){let u={repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:l.treeOid,fingerprint:l.fingerprint,producerIdentity:l.producerIdentity,generationId:l.generationId,repositoryCacheDir:s},d=ln(u);if(d)return{snapshot:u,manifest:d}}return null}function d$(e,t,n,r){for(let i of cx(e)){if(!/^[a-f0-9]{64}$/.test(i))continue;let o=E(e,i),s;try{s=Kd(o)}catch{continue}if(!(!s.isDirectory()||s.isSymbolicLink()))try{let a=gx(z(E(o,Yd),{inputKind:"shared-generation baseline manifest",maxBytes:re}));p$(a,i,t,n)&&r.push(a)}catch{continue}}}function p$(e,t,n,r){return e.generationId===t&&e.repositoryId===n.repositoryId&&e.producerIdentity===za&&A$(e.fingerprint,r)}function fx(e){let t=sn(E(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 f$(e)}finally{t.release()}}function f$(e){let t=ln(e.snapshot);if(t)return mx(e.snapshot,t);if(!No(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let n=yx(e.sourceCacheDir);if(!n)throw new Error("source index artifacts are incomplete");let r=qa(e.sourceCacheDir),i=E(e.snapshot.repositoryCacheDir,"generations"),o=[Te(i)],s=ax(E(i,`.tmp-${process.pid}-`));try{let a=y$(e,r.files,s,o),c=g$(e,s,n),l={version:Jd,artifactCatalogVersion:Eo,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:c,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:a.sort((f,h)=>f.path.localeCompare(h.path))},u=Xe(E(s,Yd),l,{spacing:2,trailingNewline:!0});u.directorySync!=="not-requested"&&o.push(u.directorySync),e.onPublicationStage?.("after-manifest-flushed"),o.push(G(s)),e.onPublicationStage?.("after-staging-directory-synced");let d=m$(e.snapshot,s);if(d)return d;e.onPublicationStage?.("after-generation-renamed"),o.push(G(i)),e.onPublicationStage?.("after-generations-directory-synced");let p=Z(...o);return{kind:"published",manifest:l,achievedDurability:p==="synced"?"directory-durable":"file-flushed",directorySync:p}}finally{Tn(s,{recursive:!0,force:!0})}}function m$(e,t){let n=Zd(e);try{if($t(n)&&!ln(e)){let r=`${n}.corrupt-${process.pid}-${Date.now()}`;ur(n,r),Tn(r,{recursive:!0,force:!0})}ur(t,n)}catch(r){let i=ln(e);if(i)return mx(e,i);throw r}}function g$(e,t,n){let r=xo(H(E(t,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:fe}));if(!r)throw new Error("shared SCIP generation has no project root metadata");let i=tp(e.sourceProjectRoot);if(r!==i)throw new Error("shared SCIP generation root does not match its source worktree");if(yx(e.sourceCacheDir)!==n||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");return r}function y$(e,t,n,r){let i=[];for(let o of t){let s=Bt(e.sourceCacheDir,o),a=Bt(n,o);r.push(To(s,a,292)),e.onPublicationStage?.("after-artifact-flushed",o);let c=Ja(a).size;i.push({path:o,size:c,sha256:On(a,{inputKind:"staged shared-generation artifact",maxBytes:fe})})}return i}function mx(e,t){let n=G(E(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:n==="synced"?"directory-durable":"file-flushed",directorySync:n}}function Ka(e){let t=Zd(e.snapshot);ii(e.targetCacheDir,{recursive:!0});let n=sn(E(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=ax(E(e.targetCacheDir,".shared-hydrate-")),B$(e.manifest,e.snapshot),S$(e.manifest,t,r),b$(e,r),!No(r,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=O$(e.targetCacheDir,r),o=!0,M$(r,e.targetCacheDir,i),Vd({tempOutputScip:E(r,"index.scip"),tempOutputDb:E(r,"index.db"),tempMetaPath:E(r,"meta.json"),outputScip:E(e.targetCacheDir,"index.scip"),outputDb:E(e.targetCacheDir,"index.db"),metaPath:E(e.targetCacheDir,"meta.json"),now:e.now}),h$(e.targetCacheDir),e.persistLease!==!1&&Qd(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(s){throw o&&i&&j$(e.targetCacheDir,i),s}finally{r&&Tn(r,{recursive:!0,force:!0}),n.release()}}function h$(e){let t=Ua(E(e,"index.db"),E(e,"meta.json"));if(t.state==="invalid"||t.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${t.reason}`)}function S$(e,t,n){for(let r of e.artifacts){let i=Bt(t,r.path),o=Bt(n,r.path);if(To(i,o),Ja(o).size!==r.size||On(o,{inputKind:"hydrated shared-generation artifact",maxBytes:fe})!==r.sha256)throw new Error(`shared artifact is corrupt: ${r.path}`)}}function b$(e,t){let n=tp(e.targetProjectRoot);if(n!==e.manifest.scipProjectRoot)for(let r of e.manifest.artifacts)r.path.endsWith(".scip")&&Vb(Bt(t,r.path),e.manifest.scipProjectRoot,n)}function D3(e,t,n,r){let i=dx(e,n.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=r??vi(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean)return R$(o,e,t,n);let{languages:s,fingerprint:a,snapshot:c}=x$(o,e,t);if(!c)return{kind:"missed",reason:"clean committed snapshot is unavailable"};let l=ln(c);if(l)return Ka({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId};let u=_$(c,e);return u?(l=u.manifest,Ka({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e,action:"peer-imported"}),{kind:"peer-imported",generationId:c.generationId,sourceProjectRoot:u.sourceProjectRoot}):v$(o,e,t,n,s,a)}catch(o){return{kind:"failed",reason:o instanceof Error?o.message:String(o)}}}function x$(e,t,n){let r=n.languages??ka(t),i=Pr(t,r,Fo(n)),o=Ya(e,i);return{languages:r,fingerprint:i,snapshot:o}}function v$(e,t,n,r,i,o){if(!$t(r.dbPath)){let s=px(e,i,Fo(n),o);if(s)return xx(s,r.cacheDir,t)}return wo(e,r.cacheDir,"missed",void 0,"no exact shared or peer generation exists"),{kind:"missed",reason:"no exact shared or peer generation exists"}}function R$(e,t,n,r){if($t(r.dbPath))return wo(e,r.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"};let i=n.languages??ka(t),o=Pr(t,i,Fo(n)),s=px(e,i,Fo(n),o);return s?xx(s,r.cacheDir,t):(wo(e,r.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"})}function k3(e,t,n,r){let i=dx(e,n.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=r??vi(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean)return wo(o,n.cacheDir,"missed",void 0,"worktree is not a clean committed snapshot"),{kind:"missed",reason:"worktree is not a clean committed snapshot"};let s=t.languages??ka(e),a=Pr(e,s,Fo(t)),c=Ya(o,a);if(!c)return wo(o,n.cacheDir,"missed",void 0,"worktree is not a clean committed snapshot"),{kind:"missed",reason:"worktree is not a clean committed snapshot"};let l=ln(c);return l?C$(l,c,n,e,a):I$(c,n,e,a,s)}catch(o){return{kind:"failed",reason:o instanceof Error?o.message:String(o)}}}function I$(e,t,n,r,i){let o=Qa(t.cacheDir);return!o||!gi(mi(o.fingerprint),r)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...i].sort())?{kind:"missed",reason:"local metadata does not match the clean worktree snapshot"}:No(t.cacheDir,n,r)?(fx({snapshot:e,sourceCacheDir:t.cacheDir,sourceProjectRoot:n,sourceStillValid:()=>{let s=vi(n);return(s?Ya(s,r):void 0)?.generationId===e.generationId}}),Qd(e,t.cacheDir,"built"),{kind:"built",generationId:e.generationId}):{kind:"missed",reason:"local index artifacts are incomplete or incompatible"}}function C$(e,t,n,r,i){return No(n.cacheDir,r,i)?(Qd(t,n.cacheDir,"local-fresh"),{kind:"local-fresh"}):(Ka({snapshot:t,manifest:e,targetCacheDir:n.cacheDir,targetProjectRoot:r}),{kind:"attached",generationId:t.generationId})}async function A3(e,t={}){let n=t.timeoutMs??3e4,r=t.pollMs??100,i=t.now??on,o=i()+n,s=E(e.repositoryCacheDir,"locks"),a=E(s,`${e.generationId}.lock`);for(;i()<=o;){if(ln(e))return{kind:"generation-ready"};let c=Fa(a,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:wa});if(c.kind==="acquired")return{kind:"owner",release:()=>c.lock.release()};let l=o-i();if(l<=0)break;await s$(Math.min(r,l))}return ln(e)?{kind:"generation-ready"}:{kind:"timeout"}}function Qd(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:Xa(i)};return ep(e.repositoryCacheDir,o,!0),o}function E$(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:Xa(r)};return ep(e.repositoryCacheDir,i,!0),i}function wo(e,t,n,r=void 0,i=void 0){let o={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,lastAction:n,...i?{lastReason:i}:{},lastSeenAt:(r??(()=>new Date))().toISOString()},s={...o,ownershipChecksum:Xa(o)},a=ms(e.repositoryId),c=P$(a,s);return c||(ep(a,s,!1),s)}function P$(e,t){try{let n=hx(t.localCacheDir);if(!n||n.repositoryId!==t.repositoryId||n.worktreeId!==t.worktreeId)return null;let r=JSON.parse(z(E(e,"worktrees",`${t.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:re})),i=Date.parse(t.lastSeenAt)-Date.parse(r.lastSeenAt);return w$(r,t)&&Number.isFinite(i)&&i<l$?r:null}catch{return null}}function w$(e,t){return e.version===t.version&&e.repositoryId===t.repositoryId&&e.worktreeId===t.worktreeId&&e.projectRoot===t.projectRoot&&e.treeOid===t.treeOid&&e.localCacheDir===t.localCacheDir&&U$(e,t)}function Xa(e){return bx(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:cn(e.projectRoot),localCacheDir:cn(e.localCacheDir)}))}function gx(e){let t=JSON.parse(e);if(!F$(t)||!T$(t))throw new Error("invalid shared generation manifest");if(!N$(t))throw new Error("invalid shared generation manifest");let n=new Set;for(let r of t.artifacts){if(L$(r),Ha(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 F$(e){return e.version===Jd&&e.artifactCatalogVersion===Eo&&typeof e.generationId=="string"&&/^[a-f0-9]{64}$/.test(e.generationId)&&typeof e.repositoryId=="string"&&/^[a-f0-9]{24}$/.test(e.repositoryId)}function T$(e){return typeof e.treeOid=="string"&&e.treeOid!==""&&typeof e.producerIdentity=="string"&&e.producerIdentity===za&&typeof e.sourceProjectRoot=="string"&&typeof e.scipProjectRoot=="string"}function N$(e){return typeof e.createdAt=="string"&&Number.isFinite(Date.parse(e.createdAt))&&!!e.fingerprint&&Array.isArray(e.artifacts)}function L$(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 To(e,t,n=384){return lo(e,t,{mode:n})}function _$(e,t){for(let n of Bf(t)){if(cn(n.path)===cn(t))continue;let r=fs(n.path),i=Qa(r);if(!(!i||JSON.stringify(i.fingerprint)!==JSON.stringify(e.fingerprint)||JSON.stringify([...i.indexedLanguages??[]].sort())!==JSON.stringify([...e.fingerprint.languages].sort()))&&No(r,n.path,e.fingerprint))try{return{manifest:fx({snapshot:e,sourceCacheDir:r,sourceProjectRoot:n.path}).manifest,sourceProjectRoot:n.path}}catch{continue}}return null}function D$(e,t,n){ii(e,{recursive:!0}),Xe(E(e,ux),{version:1,repositoryId:t,worktreeId:n},{spacing:2,trailingNewline:!0})}function yx(e){try{let t=qa(e),n=sx("sha256");for(let r of t.files){let i=Bt(e,r),o=Ja(i).size;n.update(r).update("\0").update(String(o)).update("\0"),Sr(i,{inputKind:"source-generation artifact",maxBytes:fe},s=>n.update(s)),n.update("\0")}return n.digest("hex")}catch{return null}}function Qa(e){try{let t=Ct(z(E(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:re}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function k$(e){return Qa(e)?.scipCompanion!=="deferred"}function Fo(e){return{pnpmWorkspaces:e.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:e.indexer?.typescript?.projectMode,typescriptProjects:e.indexer?.typescript?.projects,clojureConfigPath:e.indexer?.clojure?.configPath}}function A$(e,t){if(e.typescriptSymbolIdentityVersion!==t.typescriptSymbolIdentityVersion)return!1;let n=wr(e.languages,e);return JSON.stringify(n)===JSON.stringify(t)}function ox(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,s]of n)r.get(o)!==s&&(i+=1);for(let o of r.keys())n.has(o)||(i+=1);return i}function Zd(e){return E(e.repositoryCacheDir,"generations",e.generationId)}function hx(e){let t=JSON.parse(z(E(e,ux),{inputKind:"worktree cache pointer",maxBytes:re}));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 ep(e,t,n){let r=BS(e,{waitMs:5e3});if(!r)throw new Error("repository cache cleanup is busy");try{if(n){let o=t.activeGenerationId??t.baseGenerationId;if(!o||!$t(E(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=E(e,"worktrees");ii(i,{recursive:!0}),Xe(E(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),D$(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{r.release()}}function O$(e,t){let n=E(t,".rollback"),r=new Map,i=new Map;ii(n,{recursive:!0});for(let a of["index.scip","index.db","meta.json"]){let c=E(e,a),l=$t(c);r.set(a,l),l&&To(c,E(n,"stable",a))}for(let a of Xd){let c=E(e,a),l=$t(c);if(l){let u=Kd(c);if(!u.isDirectory()||u.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${a}`)}i.set(a,l)}let o=E(e,yo),s=$t(o);return s&&Sx(o,E(n,"sqlite-generations")),{root:n,stableFiles:r,managedDirectories:i,generationStoreExisted:s}}function M$(e,t,n){for(let r of Xd){let i=E(t,r);if(n.managedDirectories.get(r)){let s=E(n.root,"managed",r);ii(zd(s),{recursive:!0}),ur(i,s)}let o=E(e,r);$t(o)&&ur(o,i)}}function j$(e,t){for(let i of Xd){let o=E(e,i),s=E(t.root,"managed",i);t.managedDirectories.get(i)?$t(s)&&(Tn(o,{recursive:!0,force:!0}),ur(s,o)):Tn(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let s=E(e,i);if(!o){Tn(s,{force:!0});continue}let a=`${s}.shared-restore-${o$()}`;To(E(t.root,"stable",i),a),Tn(s,{force:!0}),ur(a,s)}let n=E(e,yo);Tn(n,{recursive:!0,force:!0});let r=E(t.root,"sqlite-generations");t.generationStoreExisted&&$t(r)&&ur(r,n)}function Sx(e,t){ii(t,{recursive:!0});for(let n of cx(e,{withFileTypes:!0})){let r=E(e,n.name),i=E(t,n.name);if(n.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${r}`);n.isDirectory()?Sx(r,i):n.isFile()&&To(r,i)}}function B$(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||!gi(e.fingerprint,t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function No(e,t,n,r=!0,i=!0){try{let o=Qa(e);if(W$(o,n))return Po("source validation rejected metadata"),!1;let s=qa(e),a=Ua(E(e,"index.db"),E(e,"meta.json"));if(r?a.state!=="current":a.state==="invalid"||a.state==="drifted")return Po(`source validation rejected SQLite generation state ${a.state}`),!1;if(!V$(e,i))return!1;let c=tp(t),u=(i?s.files.filter(d=>d.endsWith(".scip")):["index.scip"]).every(d=>{let p=xo(H(Bt(e,d),{inputKind:"shared SCIP validation artifact",maxBytes:fe}));return p!==c&&Po(`source validation rejected SCIP root for ${d}: ${String(p)}`),p===c});return u||Po("source validation rejected SCIP project roots"),u}catch(o){return Po(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function Po(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function tp(e){try{return rx(lx(e)).href}catch{return rx(cn(e)).href}}function $$(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 bx(e){return sx("sha256").update(e).digest("hex")}function G$(e,t){return!(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||!gi(e.fingerprint,t.fingerprint))}function V$(e,t){let n=new a$(E(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 W$(e,t){return!e||e.scipCompanion==="deferred"||!gi(mi(e.fingerprint),t)||JSON.stringify([...e.indexedLanguages??[]].sort())!==JSON.stringify([...t.languages].sort())}function U$(e,t){return e.baseGenerationId===t.baseGenerationId&&e.activeGenerationId===t.activeGenerationId&&e.ownershipChecksum===t.ownershipChecksum&&e.lastAction===t.lastAction&&e.lastReason===t.lastReason}function xx(e,t,n){return Ka({snapshot:e.snapshot,manifest:e.manifest,targetCacheDir:t,targetProjectRoot:n,persistLease:!1,lockWaitMs:0}),E$(e.snapshot,t),{kind:"overlay"}}import{spawn as Q$}from"child_process";import{platform as Lx}from"os";import{performance as _x}from"perf_hooks";import{execFileSync as Rx}from"child_process";import{platform as q$}from"os";var Ix=1e3,Cx=2*1024*1024,H$=25;function Ex(e,t,n=Nx){let r=n.readIdentity(e),i=new Map;return r&&i.set(e,r),{rootPid:e,rootIdentity:r,ownsProcessGroup:t,knownMembers:i}}async function Px(e,t,n=Nx){if(!e.rootIdentity)return z$(e,t,n);let r=wx(e,n);if(r==="mismatch")return{reaped:!1,reason:"identity-mismatch",detail:`Process ${e.rootPid} no longer has the identity owned by this runner.`};if(r==="exited"&&!Fx(e,n))return{reaped:!0,reason:"terminated"};if(n.platform==="win32")return K$(e,t,n);let i=vx(e,"SIGTERM",n);if(await Lo(e,t.gracefulMs,n))return{reaped:!0,reason:"terminated"};let s=vx(e,"SIGKILL",n);return await Lo(e,t.forceMs,n)?{reaped:!0,reason:"terminated"}:s?{reaped:!1,reason:s.reason,detail:s.detail}:i?{reaped:!1,reason:i.reason,detail:i.detail}:{reaped:!1,reason:"deadline",detail:`Process tree ${e.rootPid} did not exit before its termination deadline.`}}async function z$(e,t,n){let r=await Lo(e,t.gracefulMs+t.forceMs,n);return{reaped:r,reason:r?"terminated":"identity-unavailable",detail:r?void 0:`Could not establish the birth identity of process ${e.rootPid}.`}}async function K$(e,t,n){try{n.terminateWindowsTree(e.rootPid)}catch(i){let o=await Lo(e,t.forceMs,n);return{reaped:o,reason:o?"terminated":"signal-failed",detail:o?void 0:np(i)}}let r=await Lo(e,t.forceMs,n);return{reaped:r,reason:r?"terminated":"deadline"}}function wx(e,t){let n=t.readIdentity(e.rootPid);if(!n)return"exited";if(!e.rootIdentity||!Ye(e.rootIdentity,n))return"mismatch";e.knownMembers.set(e.rootPid,n);for(let r of t.listDescendantPids(e.rootPid)){let i=t.readIdentity(r);i&&e.knownMembers.set(r,i)}return"owned"}function vx(e,t,n){let r=wx(e,n);if(r==="mismatch")return{reason:"identity-mismatch",detail:`Process ${e.rootPid} changed identity before ${t}.`};if(r==="owned"&&e.ownsProcessGroup)try{return n.signal(-e.rootPid,t),null}catch(i){if(!Tx(i))return{reason:"signal-failed",detail:np(i)}}return X$(e,t,n)}async function Lo(e,t,n){let r=n.now()+t;for(;Fx(e,n);){if(n.now()>=r)return!1;await n.sleep(Math.min(H$,Math.max(1,r-n.now())))}return!0}function Fx(e,t){if(!e.rootIdentity&&t.isProcessAlive(e.rootPid))return!0;for(let n of e.knownMembers.values()){let r=t.readIdentity(n.pid);if(r&&Ye(n,r))return!0}return!!(e.ownsProcessGroup&&t.isProcessGroupAlive(e.rootPid))}function J$(e){let t=Y$(!1),n=new Map;for(let s of t.split(/\r?\n/)){let a=/^\s*(\d+)\s+(\d+)\s*$/.exec(s);if(!a)continue;let c=Number(a[1]),l=Number(a[2]),u=n.get(l)??[];u.push(c),n.set(l,u)}let r=[],i=[...n.get(e)??[]],o=new Set;for(;i.length>0;){let s=i.pop();o.has(s)||(o.add(s),r.push(s),i.push(...n.get(s)??[]))}return r}function Y$(e){return Rx("ps",["-axo",e?"pid=,ppid=,rss=":"pid=,ppid="],{encoding:"utf8",timeout:Ix,maxBuffer:Cx,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"]})}function Tx(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ESRCH"}function np(e){return e instanceof Error?e.message:String(e)}var Nx={platform:q$(),now:Date.now,readIdentity:rn,isProcessAlive(e){try{return process.kill(e,0),!0}catch(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EPERM"}},isProcessGroupAlive(e){if(this.platform==="win32")return!1;try{return process.kill(-e,0),!0}catch(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EPERM"}},listDescendantPids(e){if(this.platform==="win32")return[];try{return J$(e)}catch{return[]}},signal(e,t){process.kill(e,t)},terminateWindowsTree(e){Rx("taskkill.exe",["/PID",String(e),"/T","/F"],{timeout:Ix,maxBuffer:Cx,stdio:"ignore",windowsHide:!0})},async sleep(e){await new Promise(t=>setTimeout(t,e))}};function X$(e,t,n){let r=null;for(let i of e.knownMembers.values()){let o=n.readIdentity(i.pid);if(!(!o||!Ye(i,o)))try{n.signal(i.pid,t)}catch(s){!Tx(s)&&r===null&&(r=np(s))}}return r===null?null:{reason:"signal-failed",detail:r}}var q3={probe:1e4,git:3e4,analysis:18e4,install:3e5,indexer:6e5},Do=class extends Error{constructor(n,r,i,o={}){super(i,o.cause===void 0?void 0:{cause:o.cause});this.kind=n;this.label=r;this.name="BoundedProcessError",this.timedOut=o.timedOut??!1,this.reaped=o.reaped??!1,this.stdout=o.stdout??"",this.stderr=o.stderr??"",this.stdoutTruncated=o.stdoutTruncated??!1,this.stderrTruncated=o.stderrTruncated??!1}kind;label;timedOut;reaped;stdout;stderr;stdoutTruncated;stderrTruncated};function _o(e,t){if(!Number.isFinite(e)||e<=0)throw new TypeError(`${t} must be a positive finite number.`)}function Dx(e,t,n,r){let i=Math.max(0,r-n);i>0&&e.push(t.subarray(0,i))}function kx(e,t,n){let r=Buffer.concat([...e,t]);e.length=0,e.push(r.subarray(Math.max(0,r.length-n)))}function H3(e){_o(e.timeoutMs,"timeoutMs"),_o(e.maxStdoutBytes,"maxStdoutBytes"),_o(e.maxStderrBytes,"maxStderrBytes");let t=e.terminationGraceMs??1e3;_o(t,"terminationGraceMs");let n=e.terminationForceMs??t;return _o(n,"terminationForceMs"),new Promise((r,i)=>{let o=_x.now(),s=Lx()!=="win32"&&process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1",a=Lx()!=="win32"&&!s,c;try{c=Q$(e.command,[...e.args??[]],{cwd:e.cwd,env:e.env,detached:a?!0:e.detached,stdio:["pipe","pipe","pipe"]})}catch(C){let N=C instanceof Error?C.message:String(C);i(new Do("spawn",e.label,`${e.label} could not start: ${N}`,{cause:C,reaped:!0}));return}let l=[],u=[],d=0,p=0,f=!1,h=!1,b=null,x=!1,m=c.pid===void 0?null:Ex(c.pid,a),g=()=>{clearTimeout(w),e.signal?.removeEventListener("abort",j)},y=C=>{if(x||!b)return;x=!0,g();let N=Buffer.concat(l).toString("utf8"),Pe=Buffer.concat(u).toString("utf8"),ke=C.reaped||!C.detail?"":` Process-tree cleanup failed: ${C.detail}`;i(new Do(b.kind,e.label,`${b.message}${ke}`,{timedOut:b.timedOut,reaped:C.reaped,stdout:N,stderr:Pe,stdoutTruncated:f,stderrTruncated:h}))},I=C=>{if(!(b||x)){if(b=C,!m){y({reaped:c.pid===void 0,reason:c.pid===void 0?"terminated":"identity-unavailable"});return}Px(m,{gracefulMs:t,forceMs:n}).then(y,N=>{y({reaped:!1,reason:"signal-failed",detail:N instanceof Error?N.message:String(N)})})}},w=setTimeout(()=>{I({kind:"timeout",timedOut:!0,message:`${e.label} timed out after ${e.timeoutMs}ms.`})},e.timeoutMs);w.unref();let j=()=>{I({kind:"aborted",timedOut:!1,message:`${e.label} was cancelled.`})};e.signal?.addEventListener("abort",j,{once:!0}),e.signal?.aborted&&j(),c.stdout.on("data",C=>{let N=Buffer.isBuffer(C)?C:Buffer.from(C);e.outputLimitBehavior==="truncate-tail"?kx(l,N,e.maxStdoutBytes):Dx(l,N,d,e.maxStdoutBytes),d+=N.length,d>e.maxStdoutBytes&&(f=!0,e.outputLimitBehavior!=="truncate-tail"&&I({kind:"stdout-limit",timedOut:!1,message:`${e.label} exceeded stdout limit (${e.maxStdoutBytes} bytes).`}))}),c.stderr.on("data",C=>{let N=Buffer.isBuffer(C)?C:Buffer.from(C);e.outputLimitBehavior==="truncate-tail"?kx(u,N,e.maxStderrBytes):Dx(u,N,p,e.maxStderrBytes),p+=N.length,p>e.maxStderrBytes&&(h=!0,e.outputLimitBehavior!=="truncate-tail"&&I({kind:"stderr-limit",timedOut:!1,message:`${e.label} exceeded stderr limit (${e.maxStderrBytes} bytes).`}))}),c.on("error",C=>{if(!x&&!b){if(c.pid===void 0){g(),x=!0,i(new Do("spawn",e.label,`${e.label} could not start: ${C.message}`,{cause:C,reaped:!0}));return}I({kind:"spawn",timedOut:!1,message:`${e.label} failed after start: ${C.message}`})}}),c.on("close",(C,N)=>{if(x||b)return;x=!0,g();let Pe=Buffer.concat(l).toString("utf8"),ke=Buffer.concat(u).toString("utf8");r({status:C,signal:N,stdout:Pe,stderr:ke,timedOut:!1,durationMs:_x.now()-o,stdoutTruncated:f,stderrTruncated:h})}),e.input===void 0?c.stdin.end():c.stdin.end(e.input)})}function J3(e){return/(^|\/)(node_modules|dist|build|coverage|\.git|\.scipquery|\.next|\.nuxt|\.turbo|\.cache)(\/|$)/.test(e)}function Y3(e){switch(e){case"entry":case"source":case"worker":return 0;case"barrel":return 1;case"test":return 2}}function Ax(e){let t=ae(e);return eG(t)?"test":tG(t)?"worker":rG(t)?"entry":iG(t)?"barrel":"source"}var Z$=[/(?:^|\/)(?:e2e|cypress|playwright)\//i,/\.(?:test|spec)\.[a-z0-9]+$/i,/(?:^|\/)(?:_)?test_[^/]+$/i,/(?:^|\/)spec_[^/]+$/i,/(?:^|\/)[^/]+_test\.[a-z0-9]+$/i,/(?:^|\/)[^/]+_tests\.rs$/i,/(?:^|\/)tests\.rs$/i,/(?:^|\/)[^/]+_spec\.[a-z0-9]+$/i,/(?:^|\/)__tests__\//i,/(?:^|\/)test\//i,/(?:^|\/)tests\//i,/(?:^|\/)__fixtures__\//i,/(?:^|\/)__mocks__\//i,/(?:^|\/)test-support\//i,/(?:^|\/)test-utils\//i,/(?:^|\/)testing\//i];function eG(e){return Z$.some(t=>t.test(e))}function tG(e){return/(?:^|\/)[^/]*worker\.(?:ts|tsx|js|mjs|cjs|rs|py|go)$/.test(e)}var nG=new Set(["cli.ts","cli.js","postinstall.ts","postinstall.js","main.ts","main.js","main.rs","main.go","main.py","build.rs","lib.rs"]);function rG(e){let t=e.split("/"),n=t[t.length-1]??e;return nG.has(n)||/\bsrc\/bin\/[^/]+\.rs$/.test(e)||/(?:^|\/)examples\/[^/]+\.rs$/.test(e)||/(?:^|\/)tests\/[^/]+\.rs$/.test(e)||/(?:^|\/)benches\/[^/]+\.rs$/.test(e)?!0:n==="index.ts"||n==="index.js"?/(?:^|\/)(?:apps|services)\/[^/]+\/src\/index\.(?:ts|js)$/.test(e)?!0:t.length<=2:!1}function iG(e){return e==="index.ts"||e==="index.js"||e.endsWith("/index.ts")||e.endsWith("/index.js")||e.endsWith("/mod.rs")||e.endsWith("/__init__.py")}import{createHash as rp,randomUUID as Wx}from"crypto";import{closeSync as aG,existsSync as un,fstatSync as cG,lstatSync as si,mkdirSync as lG,openSync as uG,readdirSync as Nn,readSync as dG,renameSync as ip,rmSync as It}from"fs";import{basename as oi,dirname as op,join as W}from"path";function Ox(e){return Za(e,oG)}function Q3(e){return Za(e,sG)}function Za(e,t){return Array.isArray(e)?`[${e.map(n=>Za(n,t)).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).sort(([n],[r])=>t(n,r)).map(([n,r])=>`${JSON.stringify(n)}:${Za(r,t)}`).join(",")}}`:JSON.stringify(e)}function oG(e,t){return e.localeCompare(t)}function sG(e,t){return e<t?-1:e>t?1:0}var sp=1,pG=Object.freeze({maxItems:1024,maxBytes:512*1024*1024,maxItemBytes:64*1024*1024,maxBatch:16,claimLeaseMs:5*6e4,responseRetentionMs:10*6e4,deadLetterRetentionMs:1440*6e4,temporaryRetentionMs:6e4,cleanupBatch:64}),Gt=class extends Error{constructor(n,r,i,o){let s=n==="item-too-large"?`request is ${o} bytes; per-item limit is ${i.maxItemBytes}`:n==="item-capacity"?`mailbox has ${r.totalItems} retained items; limit is ${i.maxItems}`:n==="byte-capacity"?`mailbox retains ${r.totalBytes} bytes and the request adds ${o}; limit is ${i.maxBytes}`:"another writer held the admission coordinator through the bounded wait";super(`Mailbox backpressure: ${s}. Retry after the service drains or expires retained work.`);this.code=n;this.status=r;this.limits=i;this.attemptedBytes=o;this.name="MailboxBackpressureError"}code;status;limits;attemptedBytes},Ux=".owner.json",ap={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function l9(e){return{rootDir:e,pendingDir:W(e,"pending"),inflightDir:W(e,"inflight"),responseDir:W(e,"responses"),deadLetterDir:W(e,"dead-letter"),legacyRequestDir:W(e,"requests")}}function ai(e={}){let t={...pG,...e};for(let[n,r]of Object.entries(t))if(!Number.isFinite(r)||r<=0||!Number.isInteger(r))throw new Error(`Mailbox limit ${n} must be a positive integer.`);return t}function ec(e){let t=[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir].map(n=>Te(n));return Z(...t)}function u9(e,t){return rp("sha256").update(Ox({namespace:e,payload:t})).digest("hex")}function qx(e){if(!/^[a-f0-9]{64}$/.test(e))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${e}`}function d9(e,t,n={}){let r=ai(n.limits),i=n.nowMs??Date.now(),o=ec(e);return _G(t),lp(e,r,n.admissionLockTimeoutMs??2e3,n.monotonicNow??on,n.durability??"durable",()=>{cp(e,i,r);let s=W(e.pendingDir,`${t.id}.json`),a=W(e.responseDir,`${t.id}.json`),c=jx(e,t.id);if(c){let d=Bx(c,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:d.deadlineAtMs??t.deadlineAtMs}}let l=`${JSON.stringify(t)}
|
|
444
|
+
`,u=Buffer.byteLength(l);GG(e,u,r),n.onBeforePublish?.();try{let d=n.durability??"durable",p=Sa(s,l,{durability:d}),f=d==="durable"?Z(o,p.directorySync):"not-requested";return{disposition:"accepted",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:t.deadlineAtMs,achievedDurability:p.achievedDurability,directorySync:f}}catch(d){if(d.code!=="EEXIST")throw d;let p=jx(e,t.id);if(!p)throw d;let f=Bx(p,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:f.deadlineAtMs??t.deadlineAtMs}}})}function fG(e,t){if(!t.ownerId.trim())throw new Error("Mailbox claim owner identity is required.");BG(t.owner);let n=t.nowMs??Date.now(),r=ai(t.limits),i=ec(e);try{return lp(e,r,2e3,t.monotonicNow??on,t.durability??"durable",()=>yG(e,t.ownerId,n,r,t.liveness??ap,t.owner??{pid:process.pid},i,t.durability??"durable",t.onClaimStage))}catch(o){if(o instanceof Gt&&o.code==="admission-busy")return[];throw o}}function p9(e,t){return!Vx(e.pendingDir)&&!Vx(e.legacyRequestDir)?[]:fG(e,t)}function mG(e,t){let{paths:n,ownerId:r,ownerDirectory:i,nowMs:o,limits:s,ownerDirectorySync:a,durability:c,onClaimStage:l}=t,u=W(n.responseDir,`${e.header.id}.json`);if(un(u))return It(e.path,{force:!0}),null;let d=Math.max(o+s.claimLeaseMs,(e.header.deadlineAtMs??o)+5e3),p=`${tc(e.originalFile)}.${d}.claim`,f=W(i,p);try{ip(e.path,f)}catch(m){let g=m.code;if(g==="ENOENT"||g==="EEXIST")return null;throw m}l?.("after-claim-renamed");let h=c==="durable"?G(op(e.path)):"not-requested";l?.("after-source-directory-synced");let b=c==="durable"?G(i):"not-requested";l?.("after-destination-directory-synced");let x=Z(a,h,b);return gG(e,t,f,d,x)}function gG(e,t,n,r,i){let{ownerId:o,nowMs:s}=t;return{requestId:e.header.id,ownerId:o,path:n,originalFile:e.originalFile,claimedAtMs:s,claimExpiresAtMs:r,byteLength:e.byteLength,...e.header.operationKey?{operationKey:e.header.operationKey}:{},...e.header.clientId?{clientId:e.header.clientId}:{},...e.header.enqueuedAtMs===void 0?{}:{enqueuedAtMs:e.header.enqueuedAtMs},...e.header.deadlineAtMs===void 0?{}:{deadlineAtMs:e.header.deadlineAtMs},legacy:e.legacy,directorySync:i}}function yG(e,t,n,r,i,o,s,a,c){cp(e,n,r,i);let l=W(e.inflightDir,tc(t)),u=[...$x(e.pendingDir,!1),...$x(e.legacyRequestDir,!0)].sort((h,b)=>h.orderAtMs-b.orderAtMs||h.header.id.localeCompare(b.header.id)||h.path.localeCompare(b.path)),d=a==="durable"?s:"not-requested";u.length>0&&(a==="durable"?d=Z(d,Te(l)):lG(l,{recursive:!0}),c?.("after-owner-directory-durable"),NG(l,t,o,a),c?.("after-owner-record-published"));let p={paths:e,ownerId:t,ownerDirectory:l,nowMs:n,limits:r,ownerDirectorySync:d,durability:a,onClaimStage:c},f=[];for(let h of u){if(f.length>=r.maxBatch)break;let b=mG(h,p);b&&f.push(b)}return f}function f9(e,t={}){let n=ai(t);if(e.byteLength>n.maxItemBytes)throw new Gt("item-too-large",{pending:0,inflight:1,responses:0,deadLetters:0,invalid:0,totalItems:1,totalBytes:e.byteLength},n,e.byteLength);return z(e.path,{maxBytes:n.maxItemBytes,inputKind:"bounded mailbox item"})}function hG(e,t,n,r={}){let i=r.nowMs??Date.now(),o=ai(r.limits),s=SG(t,n,i,o),a=Buffer.byteLength(`${JSON.stringify(s)}
|
|
445
|
+
`);bG(e,t,a,o,i);let c=r.durability??"durable";if(PG(e,t,s,c),r.onAfterResponsePublished?.(),It(t.path,{force:!0}),c==="durable"){let l=op(t.path);G(un(l)?l:e.inflightDir)}}function SG(e,t,n,r){let i=e.deadlineAtMs===void 0?n+r.responseRetentionMs:Math.min(n+r.responseRetentionMs,Math.max(e.deadlineAtMs,n)+Hx),o={mailboxVersion:sp,operationKey:e.operationKey??`legacy-${e.requestId}`,clientId:e.clientId??"legacy",...e.deadlineAtMs===void 0?{}:{deadlineAtMs:e.deadlineAtMs},completedAtMs:n,expiresAtMs:i};return{...o,...t,...o}}function bG(e,t,n,r,i){let o=ko(e);if(n>r.maxItemBytes)throw new Gt("item-too-large",o,r,n);let s=Math.max(0,o.totalBytes-t.byteLength)+n;if(s>r.maxBytes&&s>o.totalBytes&&(vG(e,i).removed>0&&(o=ko(e),s=Math.max(0,o.totalBytes-t.byteLength)+n),s>r.maxBytes&&s>o.totalBytes))throw new Gt("byte-capacity",o,r,n)}var Hx=3e4,xG=4096;function vG(e,t){let n={removed:0,bytesFreed:0},r;try{r=Nn(e.responseDir)}catch{return n}for(let i of r){if(!i.endsWith(".json"))continue;let o=W(e.responseDir,i),s,a;try{let d=uG(o,"r");try{a=cG(d).size;let p=Buffer.alloc(Math.min(xG,a));dG(d,p,0,p.length,0),s=p.toString("utf8")}finally{aG(d)}}catch{continue}let c=Mx(s,"expiresAtMs"),l=Mx(s,"deadlineAtMs");if(c!==null&&c<=t||l!==null&&l+Hx<=t)try{It(o,{force:!0}),n.removed+=1,n.bytesFreed+=a}catch{}}return n}function Mx(e,t){let n=new RegExp(`"${t}":(\\d+)`).exec(e);if(!n)return null;let r=Number(n[1]);return Number.isSafeInteger(r)?r:null}function m9(e,t,n,r,i={}){let o=i.nowMs??Date.now(),s=ai(i.limits);if(hG(e,t,n,{...i,nowMs:o,limits:s}),!un(t.path)){let a=W(e.deadLetterDir,`${jG(t.requestId)}.${o}.${rp("sha256").update(r).digest("hex").slice(0,12)}.json`),c={mailboxVersion:sp,requestId:t.requestId,ownerId:t.ownerId,rejectedAtMs:o,reason:r,originalFile:t.originalFile},l=Buffer.byteLength(`${JSON.stringify(c,null,2)}
|
|
446
|
+
`),u=ko(e);u.totalItems<s.maxItems&&u.totalBytes+l<=s.maxBytes&&Xe(a,c,{spacing:2,trailingNewline:!0})}}function g9(e,t={}){let n=t.nowMs??Date.now(),r=ai(t.limits);return ec(e),lp(e,r,2e3,t.monotonicNow??on,"durable",()=>cp(e,n,r,t.liveness??ap))}function RG(e,t,n,r,i){let o=W(e.responseDir,`${t.requestId}.json`);if(un(o))return It(t.path,{force:!0}),i.completedClaimsRemoved++,!0;if(t.claimExpiresAtMs>n||LG(e,t.ownerId,r)!=="dead")return!1;let s=W(e.pendingDir,t.originalFile);try{ip(t.path,s),i.reclaimed++}catch(a){if(a.code!=="EEXIST")throw a;It(t.path,{force:!0})}return G(op(t.path)),G(e.pendingDir),!0}function IG(e,t,n,r,i){for(let o of dp(e.inflightDir)){if(n<=0)break;RG(e,o,t,r,i)&&n--}return n}function CG(e,t,n){if(!oi(e).includes(".tmp-"))return!1;let r;try{r=si(e).mtimeMs}catch(i){if(i.code==="ENOENT")return!1;throw i}return r+n>t?!1:(It(e,{force:!0}),!0)}function EG(e,t,n,r,i){for(let o of[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir]){if(r<=0)break;for(let s of Kx(o)){if(r<=0)break;CG(s,t,n.temporaryRetentionMs)&&(i.temporaryFilesRemoved++,r--)}}}function cp(e,t,n,r=ap){let i={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=n.cleanupBatch;return o=IG(e,t,o,r,i),o=Gx(e.responseDir,o,(s,a)=>a+n.responseRetentionMs,t,()=>{i.responsesRemoved++}),o=Gx(e.deadLetterDir,o,(s,a)=>a+n.deadLetterRetentionMs,t,()=>{i.deadLettersRemoved++}),EG(e,t,n,o,i),OG(e.inflightDir),i}function ko(e){ec(e);let t=[...dr(e.pendingDir).map(c=>({path:c,pending:!0})),...dr(e.legacyRequestDir).map(c=>({path:c,pending:!0}))],n=dp(e.inflightDir).map(c=>({path:c.path,pending:!1})),r=dr(e.responseDir).map(c=>({path:c,pending:!1})),i=dr(e.deadLetterDir).map(c=>({path:c,pending:!1})),o=[...t,...n,...r,...i],s=0,a;for(let c of t){let l=Ao(c.path);if(!l){s++;continue}let u=l.enqueuedAtMs;if(u===void 0)try{u=si(c.path).mtimeMs}catch(d){if(d.code==="ENOENT")continue;throw d}a=a===void 0?u:Math.min(a,u)}return{pending:t.length,inflight:n.length,responses:r.length,deadLetters:i.length,invalid:s,totalItems:o.length,totalBytes:o.reduce((c,l)=>c+MG(l.path),0),...a===void 0?{}:{oldestPendingAt:new Date(a).toISOString()}}}function PG(e,t,n,r){let i=W(e.responseDir,`${t.requestId}.json`),o=`${JSON.stringify(n)}
|
|
447
|
+
`;try{Sa(i,o,{durability:r})}catch(s){if(s.code!=="EEXIST")throw s;let a=Ao(i),c=t.operationKey??`legacy-${t.requestId}`;if(a?.operationKey!==c)throw new Error(`Mailbox completion ${t.requestId} conflicts with an existing operation.`,{cause:s})}}function lp(e,t,n,r,i,o){let s=W(e.rootDir,".admission.lock"),a=`${process.pid}-${Wx()}`,c=r()+Math.max(0,n);for(;!wG(e.rootDir,s,a,i);){if(FG(s),r()>=c)throw new Gt("admission-busy",ko(e),t,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return o()}finally{try{up(s).ownerToken===a&&(It(s,{recursive:!0,force:!0}),i==="durable"&&G(e.rootDir))}catch{}}}function wG(e,t,n,r){let i=`${JSON.stringify({ownerToken:n,pid:process.pid,acquiredAtMs:Date.now()})}
|
|
448
|
+
`;try{return Sa(t,i,{durability:r}),!0}catch(o){if(o.code==="EEXIST")return!1;try{up(t).ownerToken===n&&(It(t,{force:!0}),r==="durable"&&G(e))}catch{}throw o}}function FG(e){let t=null;try{let r=up(e);typeof r.ownerToken=="string"&&Number.isSafeInteger(r.pid)&&Number(r.pid)>0&&(t=Number(r.pid))}catch{}if(t===null||TG(t))return;let n=`${e}.stale-${Wx()}`;try{ip(e,n)}catch(r){let i=r.code;if(i==="ENOENT"||i==="EEXIST")return;throw r}It(n,{recursive:!0,force:!0})}function up(e){try{return JSON.parse(_(e,"mailbox lock record"))}catch(t){if(t.code!=="EISDIR"&&!(t instanceof Wt&&t.reason==="not-regular"))throw t;return JSON.parse(_(W(e,"owner.json"),"mailbox lock owner record"))}}function TG(e){try{return process.kill(e,0),!0}catch(t){let n=t.code;return n==="EPERM"||n!=="ESRCH"}}function NG(e,t,n,r){let i=W(e,Ux),o=n.processIdentity,s=zx(i);if(s&&s.ownerId===t&&s.pid===n.pid&&VG(s.processIdentity,o))return;if(dr(e).some(c=>c.endsWith(".claim")))throw new Error(`Mailbox owner identity ${t} collides with retained work from another process instance.`);let a={version:1,ownerId:t,pid:n.pid,...o?{processIdentity:o}:{}};r==="durable"?Xe(i,a):Pn(i,a)}function LG(e,t,n){let r=zx(W(e.inflightDir,tc(t),Ux));if(!r)return"unknown";if(!n.isProcessAlive(r.pid))return"dead";if(!r.processIdentity)return"live";let i=n.readProcessIdentity(r.pid);return i?Ye(r.processIdentity,i)?"live":"dead":"unknown"}function zx(e){try{let t=JSON.parse(_(e,"mailbox owner record"));if(!$G(t))return null;let n=t.processIdentity===void 0?null:nn(t.processIdentity);return t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{version:1,ownerId:t.ownerId,pid:t.pid,...n?{processIdentity:n}:{}}}catch{return null}}function jx(e,t){for(let n of[W(e.pendingDir,`${t}.json`),W(e.legacyRequestDir,`${t}.json`),W(e.responseDir,`${t}.json`)])if(un(n))return n;for(let n of dp(e.inflightDir))if(n.requestId===t)return n.path;return null}function Bx(e,t,n){let r=Ao(e);if(r?.operationKey===t)return r;if(oi(e)===`${qx(t)}.json`)return{id:n,operationKey:t};throw new Error(`Mailbox operation ${n} conflicts with an existing retained record.`)}function _G(e){if(e.mailboxVersion!==sp||e.id!==qx(e.operationKey)||!e.clientId.trim()||!Number.isFinite(e.enqueuedAtMs)||!Number.isFinite(e.deadlineAtMs)||e.deadlineAtMs<e.enqueuedAtMs)throw new Error("Mailbox request has an invalid lifecycle identity.")}function $x(e,t){return dr(e).filter(n=>n.endsWith(".json")).map(n=>{let r=si(n),i=oi(n,".json"),o=Ao(n)??{id:i};return{path:n,originalFile:oi(n),header:o,byteLength:r.size,orderAtMs:o.enqueuedAtMs??r.mtimeMs,legacy:t}})}function DG(e){let t=/^(.*)\.(\d+)\.claim$/.exec(e);if(!t)return null;let n=Jx(t[1]),r=Number(t[2]);return n===null||oi(n)!==n||!n.endsWith(".json")||!Number.isSafeInteger(r)?null:{originalFile:n,claimExpiresAtMs:r}}function kG(e,t,n){let r=DG(n);if(!r)return null;let{originalFile:i,claimExpiresAtMs:o}=r,s=W(e,n),a=Ao(s)??{id:oi(i,".json")},c;try{c=si(s)}catch(l){if(l.code==="ENOENT")return null;throw l}return{requestId:a.id,ownerId:t,path:s,originalFile:i,claimedAtMs:c.mtimeMs,claimExpiresAtMs:o,byteLength:c.size,...a.operationKey?{operationKey:a.operationKey}:{},...a.clientId?{clientId:a.clientId}:{},...a.enqueuedAtMs===void 0?{}:{enqueuedAtMs:a.enqueuedAtMs},...a.deadlineAtMs===void 0?{}:{deadlineAtMs:a.deadlineAtMs},legacy:a.operationKey===void 0}}function AG(e,t){let n=[];for(let r of Nn(e,{withFileTypes:!0})){if(!r.isFile()||!r.name.endsWith(".claim"))continue;let i=kG(e,t,r.name);i&&n.push(i)}return n}function dp(e){if(!un(e))return[];let t=[];for(let n of Nn(e,{withFileTypes:!0})){if(!n.isDirectory())continue;let r=Jx(n.name);r!==null&&t.push(...AG(W(e,n.name),r))}return t.sort((n,r)=>n.claimedAtMs-r.claimedAtMs||n.path.localeCompare(r.path))}function Ao(e){try{let t=JSON.parse(_(e,"mailbox record"));return typeof t.id!="string"||!t.id?null:{id:t.id,...typeof t.operationKey=="string"?{operationKey:t.operationKey}:{},...typeof t.clientId=="string"?{clientId:t.clientId}:{},...typeof t.enqueuedAtMs=="number"?{enqueuedAtMs:t.enqueuedAtMs}:{},...typeof t.deadlineAtMs=="number"?{deadlineAtMs:t.deadlineAtMs}:{}}}catch{return null}}function Gx(e,t,n,r,i){for(let o of dr(e)){if(t<=0)break;let s;try{s=si(o)}catch(a){if(a.code==="ENOENT")continue;throw a}n(o,s.mtimeMs)>r||(It(o,{force:!0}),i(),t--)}return t}function dr(e){return un(e)?Nn(e,{withFileTypes:!0}).filter(t=>t.isFile()).map(t=>W(e,t.name)).sort():[]}function Vx(e){try{return Nn(e).some(t=>t.endsWith(".json"))}catch{return!1}}function Kx(e){if(!un(e))return[];let t=[];for(let n of Nn(e,{withFileTypes:!0})){let r=W(e,n.name);n.isFile()?t.push(r):n.isDirectory()&&t.push(...Kx(r))}return t.sort()}function OG(e){if(un(e))for(let t of Nn(e,{withFileTypes:!0})){if(!t.isDirectory())continue;let n=W(e,t.name);Nn(n).some(r=>r.endsWith(".claim"))||It(n,{recursive:!0,force:!0})}}function MG(e){try{return si(e).size}catch{return 0}}function tc(e){return Buffer.from(e,"utf8").toString("base64url")}function Jx(e){try{let t=Buffer.from(e,"base64url").toString("utf8");return tc(t)===e?t:null}catch{return null}}function jG(e){return/^[a-z0-9][a-z0-9-]{0,127}$/i.test(e)?e:`invalid-${rp("sha256").update(e).digest("hex")}`}function BG(e){if(e&&(!Number.isSafeInteger(e.pid)||e.pid<=0||e.processIdentity!==void 0&&e.processIdentity.pid!==e.pid))throw new Error("Mailbox claim process identity is invalid.")}function $G(e){return!(e.version!==1||typeof e.ownerId!="string"||!e.ownerId||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0)}function GG(e,t,n){let r=ko(e);if(t>n.maxItemBytes)throw new Gt("item-too-large",r,n,t);if(r.totalItems+1>n.maxItems)throw new Gt("item-capacity",r,n,t);if(r.totalBytes+t>n.maxBytes)throw new Gt("byte-capacity",r,n,t)}function VG(e,t){return!!(!e&&!t||e&&t&&Ye(e,t))}function Oo(e,t=[]){return $(JSON.stringify({observations:e.map(({resolution:n,...r})=>r),bodies:t}))}function Yx(e,t){let{dbPath:n,indexPath:r,evidenceDbPath:i,sharedEvidenceDbPath:o,...s}=e.config;return $(JSON.stringify({configuration:s,files:t.map(a=>[a,e.isIgnored(a)])}))}function Mo(e){if(WG(e))return{result:structuredClone(e.previous.result),record:e.previous,reused:!0};let t=new _a(e.db.config,{isIgnored:n=>e.db.isIgnored(n)});try{return t.generation.identity!==e.db.generation.identity?{result:e.compute(e.db),reused:!1}:UG(t,e)}finally{t.close()}}function WG(e){let t=e.previous;if(!t||t.build!==xe()||t.scope!==e.scope||t.seeds!==e.seeds||!Array.isArray(t.sources)||!Array.isArray(t.result?.errors)||t.result.errors.length>0)return!1;let n=Yi(e.db);return t.sources.every(i=>i&&typeof i.file=="string"&&typeof i.hash=="string"&&(n.get(i.file)??null)===i.indexedHash&&Xx(e.db,i.file)===i.hash)&&(e.compilerFactsUnchanged||km(e.db.db,t.database))}function UG(e,t){let n=new Set,r=new Map,i=new Map,o=!0,{result:s,proof:a}=Dm(e.db,()=>vs(u=>n.add(u.replace(/\\/g,"/")),()=>t.compute(e),void 0,{source(u,d){if(u=u.replace(/\\/g,"/"),i.get(u)===d)return;i.set(u,d);let p=$(d),f=r.get(u);f!==void 0&&f!==p&&(o=!1),r.set(u,p)},unavailable(){o=!1}})),c=Yi(e),l=[...n].sort().map(u=>({file:u,hash:r.get(u),indexedHash:c.get(u)??null}));return!o||s.errors.length>0||l.some(({file:u,hash:d})=>d===void 0||Xx(e,u)!==d)?{result:s,reused:!1}:{result:s,reused:!1,record:{build:xe(),scope:t.scope,seeds:t.seeds,sources:l,database:a,result:structuredClone(s)}}}function Xx(e,t){try{return $(zn(e.config.projectRoot,t,{inputKind:"runtime phase input"}))}catch{return null}}import{createHash as Wo}from"crypto";import{setImmediate as Yv}from"timers/promises";import{createRequire as eW}from"module";var nc=8;function rc(e,t,n){return hp(Qx(e,t,fp(n),0,new Set))}function mp(e,t,n){return gp(e,t,n,0,new Set)}function Qx(e,t,n,r,i){if(r>nc)return[];let o=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(n);return o?Zx(e,t,o[1],o[2],r,i):/^[A-Za-z_$][\w$]*$/u.test(n)?ev(e,t,n,r,i):[]}function Zx(e,t,n,r,i,o){let s=gp(e,t,n,i+1,new Set(o)).flatMap(a=>te(a.initializer).namedChildren.flatMap(c=>qG(e,a.definition,c,r,i,o)));return hp(s)}function qG(e,t,n,r,i,o){if(n.type==="pair"){let a=n.childForFieldName("key")??n.namedChild(0);if(YG(a)!==r)return[];let c=n.childForFieldName("value")??n.namedChild(1);return c?Qx(e,t.relativePath,fp(c.text),i+1,new Set(o)):[]}if(/(?:method|function)/u.test(n.type))return HG(e,t,n,r);if(n.type!=="spread_element")return[];let s=n.namedChild(0);return s?gp(e,t.relativePath,fp(s.text),i+1,new Set(o)).flatMap(a=>Zx(e,a.definition.relativePath,a.definition.leaf,r,i+1,new Set(o))):[]}function HG(e,t,n,r){if((n.childForFieldName("name")??n.namedChild(0))?.text!==r)return[];let o=KG(e,t.relativePath,r,n);return o.length>0?o:[zG(t,r,n)]}function zG(e,t,n){return{documentId:e.documentId,symbolId:-1,symbol:`source-callable:${e.relativePath}:${n.startPosition.row}:${n.startPosition.column}:${n.endPosition.row}:${n.endPosition.column}:${t}`,relativePath:e.relativePath,startLine:n.startPosition.row,startChar:n.startPosition.column,endLine:n.endPosition.row,endChar:n.endPosition.column,leaf:t,parentTypeName:e.leaf,isFunctionLike:!0,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:e.symbol}}function gp(e,t,n,r,i){return r>nc||!/^[A-Za-z_$][\w$]*$/u.test(n)?[]:ev(e,t,n,r,i).flatMap(o=>{let s=D(e,o.relativePath)?.rootNode,a=s?JG(s,o.leaf):null;return a?[{definition:o,initializer:a}]:[]})}function ev(e,t,n,r,i){if(r>nc)return[];let o=`${t}\0${n}`;if(i.has(o))return[];i.add(o);let s=k(e,t).filter(l=>l.leaf===n);if(s.length>0)return s;let a=yp(e,t,n);if(a.length>0)return a;let c=vt(e,t).find(l=>l.localName===n&&l.sourcePath);if(c?.sourcePath){let l=c.kind==="namespace"||c.importedName==="default"?n:c.importedName;return pp(e,c.sourcePath,l,r+1,new Set(i))}return pp(e,t,n,r+1,new Set(i))}function yp(e,t,n){let r=e.get("SELECT id FROM documents WHERE relative_path = ?",t)?.id;return r===void 0?[]:(J(e,t)?.callables??[]).filter(i=>i.name===n).map(i=>({documentId:r,symbolId:-1,symbol:`source-callable:${t}:${i.startLine}:${i.startColumn}:${i.endLine}:${i.endColumn}:${n}`,relativePath:t,startLine:i.startLine,startChar:i.startColumn??0,endLine:i.endLine,endChar:i.endColumn??0,leaf:n,parentTypeName:null,isFunctionLike:!0,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:null}))}function pp(e,t,n,r,i){if(r>nc)return[];let o=k(e,t).filter(s=>s.leaf===n);return o.length>0?o:hp(Lt(e,t).flatMap(s=>s.sourcePath?s.kind==="named"&&!s.names.includes(n)?[]:pp(e,s.sourcePath,n,r+1,new Set(i)):[]))}function KG(e,t,n,r){return k(e,t).filter(i=>i.leaf===n&&i.startLine<=r.startPosition.row&&i.endLine>=r.endPosition.row)}function JG(e,t){let n=null;return Ne(e,r=>{n||r.type!=="variable_declarator"||(r.childForFieldName("name")??r.namedChild(0))?.text.trim()!==t||(n=r.childForFieldName("value")??r.namedChild(1))}),n}function YG(e){return e?.text.replace(/^['"`]|['"`]$/gu,"")??null}function fp(e){return e.replace(/\s+/gu,"").replace(/^\.\.\./u,"")}function hp(e){return[...new Map(e.map(t=>[t.symbol,t])).values()]}function Ln(e,t){let n=M(e.file,e.root);if(n.hasObservedWrite(t))return{value:t.text,evidence:"expression",term:{kind:"unknown",reason:"binding-observed-write"}};let r=n.valueDeclaration(t);if(r){let u=k(e.db,e.file).filter(d=>d.leaf===r.name&&d.startLine===r.startLine&&(d.startChar??0)<=r.startColumn&&d.endLine>=r.endLine);return u.length===1?{value:t.text,evidence:"identifier",term:{kind:"symbol",symbol:u[0].symbol}}:{value:t.text,evidence:"identifier",term:{kind:"symbol",symbol:`${e.file}:${r.startLine}:${r.startColumn}:${r.endLine}:${r.endColumn}`}}}let i={startLine:t.startPosition.row,startColumn:t.startPosition.column,endLine:t.endPosition.row,endColumn:t.endPosition.column},o=Mt(e.db,e.file)?.targets.filter(u=>Ot(u.sourceRange,i))??[],s=new Set(o.map(u=>u.definition.symbol));if(s.size===1)return{value:t.text,evidence:"identifier",term:{kind:"symbol",symbol:[...s][0]}};let a=k(e.db,e.file).filter(u=>u.leaf===t.text&&u.startLine===i.startLine&&(u.startChar??0)<=i.startColumn&&u.endLine>=i.endLine);if(a.length===1)return{value:t.text,evidence:"identifier",term:{kind:"symbol",symbol:a[0].symbol}};let c=n.importedValue(t);if(c?.member){let u=Oe(e.db,e.file,c.module),d=u?fa(e.db,u,c.member):[];if(d.length===1)return{value:t.text,evidence:"identifier",term:{kind:"symbol",symbol:d[0].symbol}}}let l=n.resource(t);return{value:t.text,term:{kind:"symbol",symbol:`${e.file}:${l.resourceKey}`},evidence:l.identityBasis==="compiler-binding-access-path"?"identifier":"expression"}}function tv(e,t){let n=M(e.file,e.root);if(En(e,t))return null;let r={startLine:t.startPosition.row,startColumn:t.startPosition.column,endLine:t.endPosition.row,endColumn:t.endPosition.column},i=Mt(e.db,e.file)?.targets.filter(l=>Ot(l.sourceRange,r)&&l.definition.isFunctionLike)??[],o=new Map(i.map(l=>[l.definition.symbol,l.definition]));if(o.size===1)return[...o.values()][0];let s=Ln(e,t);if(s.evidence==="expression"||s.term?.kind!=="symbol")return null;let a=s.term.symbol,c=k(e.db,e.file).filter(l=>l.symbol===a&&l.isFunctionLike);return c.length===1?c[0]:XG(e,t,n)}function XG(e,t,n){let r=n.callableValue(t),i=n.valueDeclaration(t)?.name??r?.childForFieldName("name")?.text;if(!r||!i)return null;let o=yp(e.db,e.file,i).filter(s=>s.startLine<=r.startPosition.row&&s.endLine===r.endPosition.row&&(s.startLine!==r.startPosition.row||(s.startChar??0)<=r.startPosition.column)&&s.endChar===r.endPosition.column);return o.length===1?o[0]:null}function Sp(e){return e.precision?e.precision:e.term?iv(e.term):e.evidence==="expression"?"unknown":e.evidence==="identifier"?"symbolic":"literal"}function nv(e){return rv(e.map(Sp))}function rv(e){return["unknown","symbolic","constrained-pattern","finite-set"].find(t=>e.includes(t))??"literal"}function iv(e){switch(e.kind){case"literal":return"literal";case"finite-set":return"finite-set";case"pattern":return"constrained-pattern";case"parameter":case"symbol":return"symbolic";case"concat":return rv(e.parts.map(iv));default:return"unknown"}}function ic(e,t,n){if(!e)return{kind:"absent"};if(e.type!=="object")return{kind:"unknown"};let r={kind:"absent"};for(let i of e.namedChildren)r=QG(i,t,n)??r;return r}function QG(e,t,n){if(e.type==="comment")return null;if(e.type==="shorthand_property_identifier")return e.text===t?{kind:"value",node:e}:null;if(e.type!=="pair")return{kind:"unknown"};let r=e.childForFieldName("key"),i=ZG(r,n);if(i===null)return{kind:"unknown"};if(i!==t)return null;let o=e.childForFieldName("value");return o?{kind:"value",node:o}:{kind:"unknown"}}function ZG(e,t){return e?e.type==="property_identifier"?e.text:t(e):null}var ov=8;function $e(e,t){return t?pr(e,t,0,new Set):null}function pr(e,t,n,r){if(n>ov)return Ee(t,"value-evaluation-depth");let i=te(t),o=u1(e.file,i);if(o)return f1(e.file,i,o.term,o.value,o.precision);if(i.type==="binary_expression"&&i.childForFieldName("operator")?.text==="+"){let c=g1(e,i,n,r);if(c)return c}let s=i.text.trim();if(["identifier","shorthand_property_identifier"].includes(i.type))return o1(e,s,i,n,r);let a=ha(i);return a?s1(e,a.base,a.properties,i,n,r):i.type==="call_expression"||i.type==="call"?e1(e,i,n,r):Ee(i,`unsupported-expression:${i.type}`)}function e1(e,t,n,r){let i=t.childForFieldName("function");if(!i)return Ee(t,"call-target-unresolved");if(t.childForFieldName("arguments")?.namedChildren.some(p=>sc(e,p)))return Ee(t,"call-argument-normal-completion-unproved");if(En(e,i))return Ee(t,"call-target-written");let o=ya(e,i);if(!o)return Ee(t,"call-target-unresolved");let{context:s,callable:a}=o;if(a.childForFieldName("parameters")?.namedChildren.some(p=>i1(s,p)))return Ee(t,"call-parameter-normal-completion-unproved");let c=`${s.file}:${a.startIndex}:${a.endIndex}`;if(r.has(c))return Ee(t,"call-return-cycle");let l=t1(s,a);if(!l)return Ee(t,"call-return-not-unconditional-synchronous-expression");let u=new Set(r).add(c),d=pr(s,l,n+1,u);return d?ac(t,"bounded-call-return",d):Ee(t,"call-return-unresolved")}function t1(e,t){if(t.children.some(o=>o.type==="async"||o.type==="*")||t.type.includes("generator"))return null;let n=t.childForFieldName("body");if(!n)return null;if(t.type==="arrow_function"&&n.type!=="statement_block")return n;let r=n.namedChildren.filter(o=>o.type!=="comment"),i=r.at(-1);return!i||i.type!=="return_statement"||r.slice(0,-1).some(o=>!["lexical_declaration","variable_declaration","function_declaration"].includes(o.type)||sc(e,o))?null:i.childForFieldName("argument")??i.namedChild(0)}function sc(e,t,n=0,r=!1){if(n>ov)return!0;let i=te(t);if(["function_declaration","function_expression","arrow_function","generator_function_declaration","generator_function","number","true","false","null","regex","comment"].includes(i.type))return!1;let o=io(i);if(o)return o.interpolated;let s=a=>sc(e,a,n+1,r);if(["lexical_declaration","variable_declaration","array"].includes(i.type))return i.namedChildren.some(s);if(i.type==="variable_declarator"){let a=i.childForFieldName("value");return i.childForFieldName("name")?.type!=="identifier"||!!a&&s(a)}return i.type==="object"?i.namedChildren.some(a=>r1(a,s)):["identifier","shorthand_property_identifier"].includes(i.type)?n1(e,i,s,r):!0}function n1(e,t,n,r){let i=M(e.file,e.root);if(!r&&i.isParameterBinding(t))return!1;let o=i.constantInitializer(t);return!o||o.endIndex>=t.startIndex||n(o)}function r1(e,t){if(e.type==="comment")return!1;if(e.type==="shorthand_property_identifier")return t(e);let n=e.childForFieldName("key")??e.childForFieldName("name");if(!n||n.type==="computed_property_name")return!0;if(e.type==="method_definition")return!1;let r=e.childForFieldName("value");return e.type!=="pair"||!r||t(r)}function i1(e,t){if(t.type==="comment")return!1;let n=t.childForFieldName("pattern")??t.childForFieldName("name")??t.namedChild(0)??t;if((n.type==="rest_pattern"?n.namedChild(0):n)?.type!=="identifier")return!0;let i=t.childForFieldName("value");return!!i&&sc(e,i,0,!0)}function o1(e,t,n,r,i){let o=M(e.file,e.root),s=`${e.file}:${o.resource(n).resourceKey}`;if(i.has(s))return Ee(n,"value-cycle");let a=new Set(i).add(s),c=o.constantInitializer(n);if(c){let u=pr(e,c,r+1,a);return u?ac(n,"local-constant",u):Ee(n,"non-foldable-local")}let l=ao(e,n);return l?y1(e,l,n,r,a):oc(n,t,"unresolved-or-nonconstant-binding")}function s1(e,t,n,r,i,o){let s=a1(e,t,n);if(typeof s=="string")return Ee(r,s);let{context:a}=s,c=s.node;for(let u of s.properties){c=c1(a,c);let d=ic(c,u,p=>{let f=pr(a,l1(p),i+1,new Set(o));return f?.precision==="literal"&&["literal","constant"].includes(f.evidence)?f.value:null});if(d.kind!=="value")return Ee(r,`member-property-${d.kind}:${u}`);c=d.node}let l=pr(a,c,i+1,new Set(o));return l?ac(r,"member-constant",l):Ee(r,"member-value-unresolved")}function a1(e,t,n){let r=M(e.file,e.root);if(r.hasObservedWrite(t,!0,n))return"member-base-observed-write";let i=r.constantInitializer(t);if(i)return $u(e,t,n)?"member-shared-write-or-coverage-unproved":{context:e,node:i,properties:n};let o=ao(e,t,n[0]);if(!o)return"member-binding-unresolved";let s=ga(e,o);if(!s)return"member-definition-unparsed";let a=M(s.context.file,s.context.root),c=r.importedValue(t)?.member===null?n.slice(1):n;if(a.hasObservedWrite(s.declaration,!0,c))return"member-base-observed-write";if($u(s.context,s.declaration,c))return"member-shared-write-or-coverage-unproved";let l=a.constantInitializer(s.declaration);return l?{context:s.context,node:l,properties:c}:"member-base-nonconstant"}function c1(e,t){let n=te(t),r=new Set,i=M(e.file,e.root);for(;n.type==="identifier"&&!r.has(n.startIndex);){r.add(n.startIndex);let o=i.constantInitializer(n);if(!o)break;n=te(o)}return n}function l1(e){return e.type==="computed_property_name"?e.namedChild(0)??e:e}function u1(e,t){let n=B(e);return n==="typescript"||n==="tsx"||n==="javascript"||it(e)?d1(t):p1(t)}function d1(e){let t=io(e);return t?t.interpolated?{term:{kind:"pattern",language:"template",value:t.value},value:t.value,precision:"constrained-pattern"}:{term:{kind:"literal",value:t.value},value:t.value,precision:"literal"}:null}function p1(e){if(e.type!=="string"&&e.type!=="string_literal")return null;let t=e.text.trim(),n=t[0];if(n!=="'"&&n!=='"'&&n!=="`"||t.at(-1)!==n)return null;let r=t.slice(1,-1);return t.startsWith(n.repeat(3))||["\\","$","#",`
|
|
449
|
+
`,"\r"].some(i=>r.includes(i))?null:{term:{kind:"literal",value:r},value:r,precision:"literal"}}function f1(e,t,n,r,i){return{value:r,evidence:"literal",term:n,precision:i,derivation:cc("direct-literal","direct",e,t)}}function m1(e,t,n,r,i,o){return{value:r,evidence:"constant",term:n,precision:i,derivation:{...cc("constant-concatenation","mechanically-derived",e,t),inputFactIds:o.flatMap(s=>s.derivation.inputFactIds),sourceSpans:o.flatMap(s=>s.derivation.sourceSpans)}}}function ac(e,t,n,r){return n.evidence==="expression"?{...n,derivation:{kind:"heuristic",rule:t,ruleVersion:"1",inputFactIds:[...n.derivation.inputFactIds,...r?[r]:[]],sourceSpans:n.derivation.sourceSpans}}:{...n,evidence:"constant",derivation:{kind:"mechanically-derived",rule:t,ruleVersion:"1",inputFactIds:[...n.derivation.inputFactIds,...r?[r]:[]],sourceSpans:n.derivation.sourceSpans}}}function oc(e,t,n){return{value:e.text.trim(),evidence:"expression",term:{kind:"symbol",symbol:t},precision:"symbolic",derivation:cc(n,"heuristic","",e)}}function Ee(e,t){return{value:e.text.trim(),evidence:"expression",term:{kind:"unknown",reason:t},precision:"unknown",derivation:cc(t,"heuristic","",e)}}function cc(e,t,n,r){return{kind:t,rule:e,ruleVersion:"1",inputFactIds:[],sourceSpans:n?[{file:n,startLine:r.startPosition.row,endLine:r.endPosition.row}]:[]}}function g1(e,t,n,r){let i=t.namedChildren.map(o=>pr(e,o,n+1,new Set(r)));if(i.length>=2&&i.every(o=>o!==null)){let o=c=>c.precision==="literal"||c.precision==="constrained-pattern";if(!i.some(o))return Ee(t,"addition-operands-unproved");let s={kind:"concat",parts:i.map(c=>c.term)},a=i.map(c=>o(c)?c.value:"{}").join("");return m1(e.file,t,s,a,i.some(c=>c.precision!=="literal")?"constrained-pattern":"literal",i)}return null}function y1(e,t,n,r,i){let o=D(e.db,t.relativePath)?.rootNode;if(!o)return oc(n,t.symbol,"import-definition-unparsed");let s=Vu(o,t),a=s&&M(t.relativePath,o).constantInitializer(s);if(!a)return oc(n,t.symbol,"import-definition-non-value");let c=pr({db:e.db,file:t.relativePath,root:o},a,r+1,i);return c?ac(n,"imported-constant",c,t.symbol):oc(n,t.symbol,"import-value-unresolved")}function lc(e,t){let n=t.childForFieldName("function");if(!n||!["fetch","globalThis.fetch","window.fetch","self.fetch"].includes(n.text.replace(/\s+/gu,"")))return!1;let r=M(e.file,e.root);return r.available&&!r.hasLocalBinding(n)}function ci(e,t,n){return ic(t,n,r=>{let i=$e(e,r);return i&&["literal","constant"].includes(i.evidence)&&i.precision==="literal"?i.value:null})}function uc(e,t){let n=ci(t,e,"method");if(n.kind==="absent")return"GET";if(n.kind==="unknown")return null;let r=$e(t,n.node);return r&&r.precision==="literal"&&["literal","constant"].includes(r.evidence)?r.value.toUpperCase():null}import{createHash as h1}from"crypto";function dc(e){let t=e.replaceAll("\\","/");return Ax(t)==="test"?/(?:^|\/)__fixtures__\//iu.test(t)?"fixture":"test":/(?:^|\/)(?:fixtures?|testdata)\//iu.test(t)?"fixture":/(?:^|\/)(?:examples?|demos?|previews?)\//iu.test(t)?"example":/(?:^|\/)(?:generated|dist|build|coverage)\//iu.test(t)||/\.generated\./iu.test(t)?"generated":/^(?:scripts?|tools?)\//iu.test(t)?"script":"production"}var S1=new WeakMap,dv=new Set(["delete","get","head","options","patch","post","put"]),pv=new Map([["express",new Set(["default","Router",null])],["fastify",new Set(["default","fastify",null])],["hono",new Set(["Hono"])],["koa-router",new Set(["default",null])],["@koa/router",new Set(["default","Router",null])]]),b1=new Set(["findFirst","findMany","findUnique","from","get","select"]),x1=new Set(["create","delete","insert","remove","update","upsert"]),v1=new Set(["execute","query","raw"]),sv=/(?:\b(?:name|id)|['"`](?:name|id)['"`])\s*:/u,av=/(?:^\s*|[,{]\s*)(?:async\s+)?['"`]?(?:execute|handler|invoke|run)['"`]?\s*(?::|\([^)]*\)\s*\{)/mu,cv=/\b[A-Za-z_$][\w$-]*[_-][\w$-]*\s*\(/u,lv=/\b(?:use|call|invoke|run|via|with|read|stop)(?:\s+the)?(?:\s+(?:tool|capability|command))?\s+[A-Za-z_$][\w$-]*\s*\(/iu,xp=[w1(),C1(),I1(),T1(),D1(),k1(),O1()],R1=new Set(["exec","execFile","execFileSync","execSync","fork","spawn","spawnSync"]);function I1(){return{id:"builtin.node-child-process",supports:e=>e.includes("child_process"),extract:e=>{let t=M(e.file,e.root),n=[];return _n(e.root,"call_expression",r=>{let i=r.childForFieldName("function"),o=i&&t.importedValue(i),s=o&&["node:child_process","child_process"].includes(o.module)?o.member:null;if(!s||!R1.has(s))return;let a=mr(r),c=Ze(a[0],e)??{value:a[0]?.text.trim()||"<missing>",evidence:"expression"},l=["exec","execFile","execFileSync","execSync"].includes(s)?"process.exec":"process.spawn";n.push(De(e,r,"builtin.node-child-process",l,[{name:"operation",value:s,evidence:"literal"},{name:"executable",...c}],"exact","node-child-process-import"))}),n}}}function Ge(e,t,n,r){let i=pc(r,"runtime-boundaries.context.ast",t,()=>n===void 0?D(e,t):Or(e,t,n));if(!i)return Ie(t),null;let o=i.rootNode;n!==void 0&&S1.set(o,i);let s=n??L(e,t),a,c=()=>{if(a)return a;let l=pc(r,"runtime-boundaries.context.callable-sites",t,()=>{let d=B(t);return(d?Ms(o,d):null)??J(e,t)?.callables??null}),u=pc(r,"runtime-boundaries.context.definitions",t,()=>k(e,t,{rangeCorrectionEvidence:{source:s,callables:l}},(d,p)=>pc(r,`runtime-boundaries.context.definitions.${d}`,t,p)));return a={definitions:u,owners:tn(e,t,u,l??[])}};return{db:e,file:t,source:s,root:o,ownerAt:l=>{let{definitions:u,owners:d}=c(),p=B(t),f=p?jr(l,p):null,h=u.filter(x=>!x.isFunctionLike&&x.startLine<=l.startPosition.row&&x.endLine>=l.endPosition.row),b=f?d.get(Dt(f)):h.length===1?h[0]:null;return{file:t,symbol:b?.symbol??null,name:f?.name??b?.leaf??null,startLine:f?.startLine??b?.startLine??l.startPosition.row,endLine:f?.endLine??b?.endLine??l.endPosition.row,startColumn:f?.startColumn??b?.startChar??l.startPosition.column,endColumn:f?.endColumn??b?.endChar??l.endPosition.column}}}}function pc(e,t,n,r){return e?e(t,r,{file:n}):r()}function C1(){return{id:"builtin.effect-httpapi",supports:e=>e.includes("effect/unstable/httpapi")||e.includes("@effect/platform"),extract:e=>{let t=[],n="HttpApiGroup",r="HttpApiBuilder";return _n(e.root,"call_expression",i=>{let o=gv(i);if(!o)return;let s=mr(i);if(fv(e,o.receiver,"HttpApiEndpoint")&&dv.has(o.member)){E1(t,e,i,o.member,s,n);return}P1(t,e,i,o.member,s,r)}),t}}}function E1(e,t,n,r,i,o){let s=Ze(i[0],t),a=Ze(i[1],t),c=mv(n,o,"make",0,t);if(!s||!a||!c)return;let l=r.toUpperCase();e.push(De(t,n,"builtin.effect-httpapi","http.handle",[{name:"method",value:l,evidence:"literal"},{name:"path",...a}],fr([{name:"path",...a}]),"effect-httpapi-endpoint-declaration")),e.push(De(t,n,"builtin.effect-httpapi","framework.declare",bp(c,s),fr(bp(c,s)),"effect-httpapi-operation-declaration"))}function P1(e,t,n,r,i,o){if(!["handle","handleRaw"].includes(r))return;let s=mv(n,o,"group",1,t),a=Ze(i[0],t),c=i[1];if(!s||!a||!c)return;let l=bp(s,a),u=tv(t,c),d=De(t,n,"builtin.effect-httpapi","framework.handle",l,u?fr(l):"candidate","effect-httpapi-handler-registration");u&&(d.owner={file:u.relativePath,symbol:u.symbol,name:u.leaf,startLine:u.startLine,endLine:u.endLine,startColumn:u.startChar,endColumn:u.endChar}),e.push(d)}function bp(e,t){return[{name:"adapter",value:"effect-httpapi",evidence:"literal"},{name:"group",...e},{name:"operation",...t}]}function fv(e,t,n){let r=M(e.file,e.root).importedValue(t);return r?(r.module==="effect/unstable/httpapi"||r.module==="@effect/platform")&&r.member===n||r.module===`@effect/platform/${n}`&&r.member===null:!1}function mv(e,t,n,r,i){let o=e.parent;for(;o;){if(o.type==="call_expression"){let s=uv(o,t,n,r,i);if(s)return s;let a=o.childForFieldName("function")??o.namedChild(0),c=null;if(a&&xv(a,l=>{!c&&l.type==="call_expression"&&(c=uv(l,t,n,r,i))}),c)return c}o=o.parent}return null}function uv(e,t,n,r,i){let o=gv(e);return!o||o.member!==n||!fv(i,o.receiver,t)?null:Ze(mr(e)[r],i)}function gv(e){let t=e.childForFieldName("function")??e.namedChild(0);if(!t||!["member_expression","subscript_expression"].includes(t.type))return null;let n=t.childForFieldName("object")??t.namedChild(0),r=t.childForFieldName("property")??t.childForFieldName("index")??t.namedChild(1);return!n||!r?null:{receiver:n,member:r.text.replace(/^['"`]|['"`]$/gu,"")}}function w1(){return{id:"builtin.http",supports:e=>/\bfetch\s*\(|\baxios\b|\b(?:app|router|server)\s*\.\s*(?:get|post|put|patch|delete|options|head)\s*\(/u.test(e)||fc(e,["axios",...pv.keys()])||/\b(?:FastAPI|Flask|APIRouter|axum|Router::new)\b/u.test(e),extract:e=>{let t=[],n=s=>{let a=/^@[^\s(]+\.(get|post|put|patch|delete|options|head)\s*\(\s*(['"`])([^'"`]+)\2/iu.exec(s.text.trim());!a||!fc(e.source,["fastapi","flask"])||t.push(De(e,s,"builtin.http","http.handle",[{name:"method",value:a[1].toUpperCase(),evidence:"literal"},{name:"path",value:a[3],evidence:"literal"}],"candidate","framework-decorator-receiver-unverified"))},r=(s,a)=>{let c=Ze(a[0],e),l=/^\s*(get|post|put|patch|delete|options|head)\s*\(/iu.exec(a[1]?.text??"")?.[1];!c||!l||t.push(De(e,s,"builtin.http","http.handle",[{name:"method",value:l.toUpperCase(),evidence:"literal"},{name:"path",...c}],"candidate","framework-route-receiver-unverified"))},i=(s,a)=>{let c=Ze(a[0],e);if(!c)return;let l=uc(a[1],e),u=[...l?[{name:"method",value:l,evidence:"literal"}]:[],{name:"path",...c}];t.push(De(e,s,"builtin.http","http.request",u,l?fr(u):"candidate","call-expression"))},o=(s,a,c)=>{if(!dv.has(c))return;let l=F1(e,s,c);if(!l)return;let u=Ze(a[0],e);u&&t.push(De(e,s,"builtin.http",l.action,[{name:"method",value:c.toUpperCase(),evidence:"literal"},{name:"path",...u},...l.action==="http.handle"?[{name:"router",...Ln(e,l.router)}]:[]],fr([{name:"path",...u}]),l.evidence))};return _n(e.root,["decorator","call_expression"],s=>{if(s.type==="decorator")return n(s);if(s.type!=="call_expression")return;let a=gc(s);if(!a)return;let c=a.split(".").at(-1)??"",l=mr(s);if(c==="route"&&fc(e.source,["axum"]))return r(s,l);if(lc(e,s))return i(s,l);o(s,l,c)}),t}}}function F1(e,t,n){let r=t.childForFieldName("function");if(!r)return null;let i=M(e.file,e.root),o=r.childForFieldName("object"),s=o&&i.constructedValue(o);if(s&&pv.get(s.module)?.has(s.member))return{action:"http.handle",evidence:"framework-adapter",router:o};let a=i.importedValue(r);return a?.module==="axios"&&a.member===n?{action:"http.request",evidence:"client-adapter"}:null}function T1(){return{id:"builtin.capability-registry",supports:e=>sv.test(e)&&av.test(e)||cv.test(e)||lv.test(e),extract:e=>{let t=[],n=new Set,r=[];return sv.test(e.source)&&av.test(e.source)&&r.push("pair"),(cv.test(e.source)||lv.test(e.source))&&r.push("string","string_literal","template_string"),_n(e.root,r,i=>{if(i.type==="pair"){N1(t,n,e,i);return}L1(t,n,e,i)}),t}}}function N1(e,t,n,r){let i=r.childForFieldName("key")??r.namedChild(0),o=r.childForFieldName("value")??r.namedChild(1),s=i?.text.replace(/^['"`]|['"`]$/gu,"");if(s!=="name"&&s!=="id")return;let a=G1(r);if(!a)return;let c=yv(o,n);if(!c||c.evidence!=="literal")return;let l=`handle\0${c.value}\0${a.startPosition.row}`;t.has(l)||(t.add(l),e.push(De(n,a,"builtin.capability-registry","registry.handle",[{name:"key",...c}],"exact","capability-descriptor")))}function L1(e,t,n,r){if(!["string","string_literal","template_string"].includes(r.type))return;let i=r.text.replace(/^['"`]|['"`]$/gu,"");for(let o of i.matchAll(/\b([A-Za-z_$][\w$-]*)\s*\(/gu)){let s=o[1];if(!_1(i,s,o.index))continue;let a=`reference\0${s}\0${r.startPosition.row}`;t.has(a)||(t.add(a),e.push(De(n,r,"builtin.capability-registry","registry.reference",[{name:"key",value:s,evidence:"literal"}],"exact","capability-instruction-reference")))}}function _1(e,t,n){if(t.includes("_")||t.includes("-"))return!0;let r=e.slice(Math.max(0,n-64),n);return/\b(?:use|call|invoke|run|via|with|read|stop)(?:\s+the)?(?:\s+(?:tool|capability|command))?\s*$/iu.test(r)}function D1(){return{id:"builtin.registry",supports:e=>/(?:Handlers?|Registry|Routes?)\b/iu.test(e),extract:e=>{let t=[];return _n(e.root,["pair","call_expression"],n=>{if(n.type==="pair"){K1(e,n,t);return}if(n.type!=="call_expression")return;let r=n.childForFieldName("function")??n.namedChild(0);if(!r||r.type!=="subscript_expression")return;let i=r.childForFieldName("object"),o=Ze(r.childForFieldName("index"),e);if(!i||!o)return;let s=Ln(e,i);t.push(De(e,n,"builtin.registry","registry.dispatch",[{name:"registry",...s},{name:"key",...o}],fr([{name:"registry",...s},{name:"key",...o}]),"indexed-access-call"))}),t}}}function k1(){return{id:"builtin.persistence",supports:e=>/\b(?:db|database|prisma|drizzle|[A-Za-z_$][\w$]*(?:Repository|Repo))\b[^;]{0,1024}?\.\s*(?:findFirst|findMany|findUnique|from|get|select|create|delete|insert|remove|update|upsert|execute|query|raw|transaction)(?:\s*<[^()]{1,512}>)?\s*\(/iu.test(e),extract:e=>{let t=[],n=q1(e.root);return _n(e.root,"call_expression",r=>{let i=gc(r);if(!i)return;let o=i.split("."),s=o.at(-1)??"",a=mr(r),c=a[0]?.text??"",l=U1(s,c);if(!l)return;let u=Sv(o,n);if(!u)return;let d=A1(a[0],e)??H1(c),p=z1(u,o,s,d);if(!p)return;let f=J1(s,l,c);t.push(De(e,r,"builtin.persistence",l,[{name:"resource",...p}],"candidate",`${f}-receiver-and-resource-identity-unverified`))}),t}}}function A1(e,t){if(!e)return null;let n=e.text.replace(/\s+/gu,"");return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/u.test(n)?{value:n.split(".").at(-1),evidence:"identifier",term:{kind:"symbol",symbol:n}}:Ze(e,t)}function O1(){return{id:"builtin.queue",supports:e=>fc(e,["amqplib","bullmq","kafkajs","@aws-sdk/client-sqs","rabbitmq"])&&/\.(?:sendToQueue|consume|send|subscribe)\s*\(/u.test(e),extract:e=>{let t=[];return _n(e.root,"call_expression",n=>{let r=gc(n);if(!r)return;let i=r.split(".").at(-1)??"",o=mr(n),s=Y1(i);if(!s)return;let a=i==="send"||i==="subscribe"?B1(o[0],"topic",e):Ze(o[0],e);a&&t.push(De(e,n,"builtin.queue",s,[{name:"address",...a}],"candidate","queue-receiver-and-broker-identity-unverified"))}),t}}}function De(e,t,n,r,i,o,s){let a=e.ownerAt(t),c=JSON.stringify({extractor:n,action:r,file:e.file,line:t.startPosition.row,startColumn:t.startPosition.column,endLine:t.endPosition.row,endColumn:t.endPosition.column,keyParts:i});return{id:`boundary:${h1("sha256").update(c).digest("hex").slice(0,16)}`,extractor:n,action:r,owner:a,source:{file:e.file,startLine:t.startPosition.row,endLine:t.endPosition.row,startColumn:t.startPosition.column,endColumn:t.endPosition.column},keyParts:i,evidence:s,strength:o,protocol:r.split(".")[0]??r,role:M1(r),executionDomain:j1(e.file),derivation:{kind:o==="candidate"?"heuristic":o==="derived"?"mechanically-derived":"direct",rule:s,ruleVersion:"1",inputFactIds:i.flatMap(l=>l.derivation?.inputFactIds??[]),sourceSpans:[{file:e.file,startLine:t.startPosition.row,endLine:t.endPosition.row},...i.flatMap(l=>l.derivation?.sourceSpans??[])]},valuePrecision:nv(i),modality:"may",resolution:"unresolved",sourceScope:dc(e.file)}}function M1(e){let t=e.split(".").at(-1)??e;return["handle","subscribe","consume","read"].includes(t)?"consumer":["request","publish","send","write","dispatch","reference","invoke","spawn","exec"].includes(t)?"producer":"observe"}function j1(e){let t=e.replaceAll("\\","/"),n=/^(apps|services|packages)\/([^/]+)/u.exec(t);return n?`${n[1]}/${n[2]}`:null}function fc(e,t){return t.some(n=>{let r=n.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`(?:\\bfrom\\s+${r}\\b|\\buse\\s+${r}\\b|(?:\\bfrom\\s*|\\brequire\\s*\\(\\s*)['"]${r}(?:[/']|"))`,"u").test(e)})}function mc(e,t,n,r,i,o,s){return De(e,t,n,r,i,o,s)}function gc(e){return(e.childForFieldName("function")??e.namedChild(0))?.text.replace(/\s+/gu,"")??null}function mr(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function Ze(e,t){let n=$e(t,e);return n?{value:n.value,evidence:n.evidence,term:n.term,precision:n.precision,derivation:n.derivation}:null}function B1(e,t,n){let r=ci(n,e??void 0,t);return r.kind==="value"?Ze(r.node,n):null}function yv(e,t){if(!e)return null;let n=Ze(e,t);if(n?.evidence==="literal"||n?.evidence==="constant")return n;let r=e.text.trim();return/^[A-Za-z_$][\w$]*$/u.test(r)?{value:r,evidence:"identifier",term:{kind:"symbol",symbol:r}}:n}function fr(e,t="exact"){return t==="candidate"||e.some(n=>n.evidence==="expression"||["unknown","constrained-pattern","finite-set"].includes(Sp(n)))?"candidate":t==="derived"||e.some(n=>n.evidence==="constant")?"derived":"exact"}function $1(e){let t=e.parent,n=t?.parent??null;for(;n&&["as_expression","satisfies_expression","type_assertion","parenthesized_expression"].includes(n.type);)n=n.parent;if(!t||!n||n.type!=="variable_declarator")return null;let r=n.childForFieldName("name")??n.namedChild(0),i=r?.text??"";return/(?:handlers?|registry|routes?)$/iu.test(i)?r:null}function vp(e){return/(?:function|lambda|method)/u.test(e.type)||e.type==="arrow_function"}function hv(e){return vp(e)||e.type==="member_expression"?!0:e.type==="identifier"&&/(?:command|controller|dispatch|handle|handler)/iu.test(e.text)}function G1(e){let t=e.parent;for(;t&&t.type!=="variable_declarator";){if(["object","object_literal","dictionary"].includes(t.type)){for(let n of t.namedChildren)if(V1(n))return t}t=t.parent}return null}function V1(e){if(e.type==="pair"&&W1(e))return!0;let t=e.childForFieldName("name")??e.namedChild(0);return!!(t&&["execute","handler","invoke","run"].includes(t.text.replace(/^['"`]|['"`]$/gu,""))&&/(?:function|method)/u.test(e.type))}function W1(e){let t=e.childForFieldName("key")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1),r=t?.text.replace(/^['"`]|['"`]$/gu,"");return!!r&&["execute","handler","invoke","run"].includes(r)&&!!n&&hv(n)}function Sv(e,t=new Set){let n=e.slice(0,-1).map(r=>r.replace(/\([^)]*\)/gu,""));return n.some(r=>/^(?:prisma|drizzle)$/iu.test(r))?"orm":n.some(r=>/(?:Repository|Repo)$/u.test(r))?"repository":n.some(r=>/^(?:db|database)$/iu.test(r)||t.has(r))?"database":null}function U1(e,t){if(b1.has(e))return"database.read";if(x1.has(e))return"database.write";if(!v1.has(e))return null;let n=/\b(SELECT|INSERT|UPDATE|DELETE)\b/iu.exec(t)?.[1]?.toUpperCase();return n==="SELECT"?"database.read":n?"database.write":null}function q1(e){let t=new Set;return _n(e,"call_expression",n=>{let r=gc(n);if(!r)return;let i=r.split(".");if(!(i.at(-1)!=="transaction"||!Sv(i)))for(let o of mr(n)){if(!vp(o))continue;let a=(o.childForFieldName("parameters")??o.namedChildren.find(l=>/parameters/u.test(l.type)))?.namedChildren[0],c=a?Ai(a):null;c&&t.add(c)}}),t}function H1(e){let t=bv(e);return t?{value:t,evidence:"identifier",term:{kind:"symbol",symbol:t}}:null}function z1(e,t,n,r){if(e==="orm"&&t.length>=3)return{value:t.at(-2).replace(/\([^)]*\)/gu,""),evidence:"identifier"};if(e==="repository"){let o=t.at(-2)?.replace(/(?:Repository|Repo)$/u,"");return o?{value:o,evidence:"identifier"}:null}if(!r)return null;if(n==="from"||n==="insert")return r;let i=bv(r.value);return i?{value:i,evidence:r.evidence}:null}function bv(e){return/\b(?:from|into|update|table)\s+(?:\$\{\s*)?['"`]?([A-Za-z_$][\w$.-]*)/iu.exec(e)?.[1]??null}function xv(e,t){t(e);for(let n of e.namedChildren)xv(n,t)}function _n(e,t,n){for(let r of Ft(e,t))n(r)}function K1(e,t,n){let r=$1(t);if(!r)return;let i=t.childForFieldName("key")??t.namedChild(0),o=t.childForFieldName("value")??t.namedChild(1),s=yv(i,e);if(!s||!o||!hv(o))return;let a=Ln(e,r),c=ci(e,t.parent??void 0,s.value);if(c.kind==="value"&&c.node.startIndex!==o.startIndex)return;let u=!M(e.file,e.root).hasObservedWrite(r,!0)&&c.kind==="value"&&vp(o)?"exact":"candidate";n.push(De(e,t,"builtin.registry","registry.handle",[{name:"registry",...a},{name:"key",...s}],fr([{name:"registry",...a},{name:"key",...s}],u),"object-member"))}function J1(e,t,n){return e==="insert"?"persistence-insert":t==="database.read"&&/\bFOR\s+UPDATE\s+SKIP\s+LOCKED\b/iu.test(n)?"persistence-skip-locked-claim":"persistence-adapter"}function Y1(e){return e==="sendToQueue"||e==="send"?"queue.send":e==="consume"||e==="subscribe"?"queue.consume":null}var X1=U("resolved-call-syntax",{clearGroups:[]}),Rp=U("resolved-call-sites",{clearGroups:[]}),Q1=U("resolved-call-sites-reference-evidence",{clearGroups:[]});function Ip(e,t){return Rp.get(e,t.symbolId,()=>Rv(e,t,Z1(e,t)))}function vv(e,t){let n=[...new Map(t.map(o=>[o.symbolId,o])).values()],r=n.filter(o=>!Rp.has(e,o.symbolId)),i=Iv(e,r);return new Map(n.map(o=>[o.symbolId,Rp.get(e,o.symbolId,()=>Rv(e,o,i.get(o.symbolId)??[]))]))}function Rv(e,t,n){let r=[],i=[],o=new Set,s=new Set;for(let a of n){o.add(a.file);let c=X1.get(e,a.file,()=>tV(e,a.file));if(!c){i.push({callee:t,file:a.file,line:a.startLine,reason:"ast-unavailable",candidates:0,referenceProvenance:a.provenance});continue}let l=Uh(e,a.file,a.startLine,a.endLine,new Set([t.symbol]));if(!l.available){i.push({callee:t,file:a.file,line:a.startLine,reason:"compiler-binding-unavailable",candidates:0,referenceProvenance:a.provenance});continue}let u=tn(e,a.file,k(e,a.file));for(let d of l.targets.filter(p=>p.definition.symbol===t.symbol)){if(d.implementationStatus==="unresolved"){i.push({callee:t,file:a.file,line:d.sourceLine,reason:"implementation-unresolved",candidates:1,referenceProvenance:a.provenance});continue}let p=c.calls.filter(b=>Ot(b.targetRange,d.sourceRange));if(p.length!==1){i.push({callee:t,file:a.file,line:d.sourceLine,reason:p.length?"ambiguous-call":"call-not-found",candidates:p.length,referenceProvenance:a.provenance});continue}let f=p[0],h=`${a.file}\0${f.callNode.startIndex}\0${f.callNode.endIndex}`;s.has(h)||(s.add(h),r.push({callee:t,caller:u.get(Dt(d.sourceOwner??null))??null,file:a.file,line:f.callNode.startPosition.row,startLine:f.callNode.startPosition.row,endLine:f.callNode.endPosition.row,targetText:f.targetNode.text,callNode:f.callNode,targetNode:f.targetNode,arguments:f.arguments,referenceProvenance:a.provenance}))}}return{sites:r,unresolved:i,filesVisited:o.size}}function Z1(e,t){return Iv(e,[t]).get(t.symbolId)??[]}function Iv(e,t){if(!eV(e))return new Map(t.map(r=>[r.symbolId,Lu(e,r,{semantic:!1}).map(i=>({file:i.file,startLine:i.line,endLine:i.line,provenance:i.provenance}))]));let n=new Map;for(let r of ra(e,t.map(i=>i.symbolId))){let i=n.get(r.symbol_id)??[];i.push({file:r.relative_path,startLine:r.chunk_start,endLine:r.chunk_end,provenance:"scip-reference-chunk"}),n.set(r.symbol_id,i)}return new Map(t.map(r=>[r.symbolId,n.get(r.symbolId)??[]]))}function eV(e){return Q1.get(e,"project",()=>!!e.get("SELECT 1 AS present FROM mentions WHERE role != 1 LIMIT 1"))}function tV(e,t){let n=D(e,t)?.rootNode,r=B(t);if(!n||!r)return null;let i=[];for(let o of Ft(n,["call_expression","call","new_expression"])){let s=Tt(o,r),a=o.childForFieldName("function")??o.childForFieldName("constructor")??o.namedChild(0);if(!s||!a)continue;let c=o.childForFieldName("arguments")??o.namedChildren.find(l=>l.type==="arguments");i.push({callNode:o,targetNode:a,targetRange:s.targetRange,arguments:c?.namedChildren.filter(l=>l.type!=="comment")??[]})}return{calls:i}}var nV=U("call-parameter-value-flow",{clearGroups:[]});function jo(e,t){let n=`${t.callee.symbolId}\0${t.file}\0${t.callNode.startIndex}\0${t.callNode.endIndex}`;return nV.get(e,n,()=>rV(e,t,iV(e,t)))}function rV(e,t,n){let r=D(e,t.callee.relativePath)?.rootNode,i=ir(e,t.callee.relativePath,t.callee),o=r&&i?st(r,i.startLine,i.endLine,ot,i):null,s=r?M(t.callee.relativePath,r):null;if(s&&!s.available)return n;let a=o&&s?s.callableParameters(o):null,c=a?.indexOf("rest")??-1,l=p=>a?c>=0&&p>=c?"callee-parameter-transform":p>=a.length?"argument-without-parameter":a[p]==="direct"?null:"callee-parameter-transform":"callee-parameter-unavailable",u=n.transfers.filter(p=>l(p.calleePosition)===null),d=n.transfers.flatMap(p=>{let f=l(p.calleePosition);return f?[{calleePosition:p.calleePosition,argumentText:p.argumentText,proof:p.proof,reason:f}]:[]});return{...n,transfers:u,unknown:[...n.unknown.map(p=>({...p,reason:l(p.calleePosition)??p.reason})),...d]}}function Bo(e,t){let n=new Set(t);return[...new Set(e.transfers.flatMap(r=>n.has(r.calleePosition)?[r.callerPosition]:[]))].sort((r,i)=>r-i)}function iV(e,t){let n={file:t.file,startLine:t.startLine,endLine:t.endLine,startColumn:t.callNode.startPosition.column,endColumn:t.callNode.endPosition.column};if(!t.caller)return{callee:t.callee,caller:null,call:n,transfers:[],unknown:t.arguments.map((d,p)=>({calleePosition:p,argumentText:d.text.trim(),reason:"caller-unavailable",proof:n}))};let r=D(e,t.caller.relativePath)?.rootNode,i=ir(e,t.file,t.caller),o=r&&i?st(r,i.startLine,i.endLine,ot,i):null;if(!o)return{callee:t.callee,caller:t.caller,call:n,transfers:[],unknown:t.arguments.map((d,p)=>({calleePosition:p,argumentText:d.text.trim(),reason:"caller-syntax-unavailable",proof:n}))};let s=M(t.file,r),a=!1,c=[],l=[];return t.arguments.flatMap(d=>{if(d.type!=="spread_element")return[d];let p=d.namedChild(0);return(p&&s.tupleElements(p))??[d]}).forEach((d,p)=>{let f=d.text.trim();a||=["spread_element","list_splat","dictionary_splat"].includes(d.type);let h=a?null:s.available?s.directParameterPosition(d):oV(e,t.file,o,d);h!==null?c.push({calleePosition:p,callerPosition:h,argumentText:f,proof:n}):l.push({calleePosition:p,argumentText:f,reason:"argument-not-direct-parameter",proof:n})}),{callee:t.callee,caller:t.caller,call:n,transfers:c,unknown:l}}function oV(e,t,n,r){if(r.type!=="identifier")return null;let i=Mt(e,t)?.locals??[],o=l=>i.find(u=>u.line===l.startPosition.row&&u.startChar===l.startPosition.column&&u.endLine===l.endPosition.row&&u.endChar===l.endPosition.column)?.symbol,s=o(r);if(!s)return null;let c=(n.childForFieldName("parameters")?.namedChildren.filter(l=>l.type!=="comment")??[]).findIndex(l=>{let u=l.childForFieldName("pattern")??l.childForFieldName("name")??l;return u.type==="identifier"&&o(u)===s});return c<0?null:c}var sV=8,aV=8;function Ev(e,t){let n=[],r=lV(e,t,n);return{summaries:[...r.summaries.values()],filesInspected:r.filesInspected,errors:n}}function Pv(e,t,n){let r=[...n.errors],i=new Map(n.summaries.map(a=>[a.definition.symbol,a])),o=uV(e,t,i,r),s=yV(e,t,r);return{observations:FV([...o.observations,...s]),bodySummaries:i.size,discriminatorSummaries:o.summaries,filesInspected:n.filesInspected,errors:r}}function cV(e,t,n,r,i){for(let o of Ip(e,t.definition).sites){if(!n(o.file))continue;let a=o.caller;if(!a)continue;let c=Bo(jo(e,o),t.parameterIndexes);if(c.length===0)continue;let l={definition:a,parameterIndexes:Dv(c),depth:t.depth+1,proofSpans:[...t.proofSpans,{file:o.file,startLine:o.startLine,endLine:o.endLine}]};IV(r,l)&&i.push(r.get(a.symbol))}}function lV(e,t,n){let r=new Map,i=[],o=new Map,s=c=>{if(o.has(c))return o.get(c)??null;let l=Ge(e,c);return o.set(c,l),l},a=new Map([...new Set(t.map(c=>c.definition.relativePath))].flatMap(c=>k(e,c)).map(c=>[Cv(c),c]));for(let c of t){let l=a.get(Cv(c.definition));if(!l){n.push(`builtin.carrier body summary definition is unavailable: ${c.definition.symbol}`);continue}let u={...c,definition:l,depth:0,proofSpans:[{file:c.definition.relativePath,startLine:c.definition.startLine,endLine:c.definition.endLine}]};r.set(c.definition.symbol,u),i.push(u)}for(;i.length>0;){let c=i.shift();if(!(c.depth>=sV))try{cV(e,c,s,r,i)}catch(l){n.push(`builtin.carrier body summary failed for ${c.definition.relativePath}: ${Pp(l)}`)}}return{summaries:r,filesInspected:new Set(t.map(c=>c.definition.relativePath)).size}}function Cv(e){return`${e.symbol}\0${e.relativePath}\0${e.startLine}\0${e.startChar}`}function uV(e,t,n,r){let i={summaries:new Map,queue:[],produced:[]};for(let o of t){let s=pV(e,o,n);s&&mV(o,s,i)}for(;i.queue.length>0;){let o=i.queue.shift();if(!(o.depth>=aV))try{gV(e,o,i)}catch(s){r.push(`builtin.carrier discriminator summary failed for ${o.definition.relativePath}: ${Pp(s)}`)}}return{observations:i.produced,summaries:i.summaries.size}}function wv(e,t){let n=CV(t);e.summaries.has(n)||(e.summaries.set(n,t),e.queue.push(t))}function dV(e,t,n,r){let i=Nv(n.root,t.source.startLine),o=i.find(l=>l.startPosition.row===t.source.startLine)??i[0];if(!o)return null;let s=Ep(o);if(!s)return null;let a=rc(e,t.source.file,s.text);if(a.length!==1)return null;let c=r.get(a[0].symbol);return c?{boundaryCall:o,bodySummary:c}:null}function pV(e,t,n){if(t.action!=="http.request"||t.strength==="candidate"||t.sourceScope!=="production")return null;let r=Tv(t);if(!r)return null;let i=Ge(e,t.source.file);if(!i)return null;let o=dV(e,t,i,n);if(!o)return null;let{boundaryCall:s,bodySummary:a}=o,c=t.owner.symbol?k(e,t.owner.file).find(d=>d.symbol===t.owner.symbol):null;if(!c)return null;let l=EV(i,c),u=hc(s);return{carrier:r,context:i,owner:c,ownerParameters:l,args:u,bodySummary:a}}function fV(e,t,n,r){let{carrier:i,context:o,owner:s,ownerParameters:a}=t;for(let c of wV(r)){let l=Lv(c),u=_v(c);if(!l||!u)continue;let d=a.indexOf(u.text.trim());if(d>=0){let f={definition:s,carrier:i,field:l,parameterIndex:d,depth:0,proofObservationIds:[e.id],proofSpans:[e.source,{file:e.source.file,startLine:c.startPosition.row,endLine:c.endPosition.row}]};wv(n,f);continue}let p=$e(o,u);!p||p.precision!=="literal"||p.evidence==="expression"||n.produced.push(Cp(o,c,"carrier.publish",i,l,p.value,[e.id]))}}function mV(e,t,n){let{context:r,args:i,bodySummary:o}=t;for(let s of o.parameterIndexes){let a=PV(r,i[s]);a&&fV(e,t,n,a)}}function gV(e,t,n){for(let r of Ip(e,t.definition).sites){let i=Ge(e,r.file);if(!i)continue;let o=r.callNode,s=hc(o)[t.parameterIndex];if(!s)continue;let a=$e(i,s);a&&a.precision==="literal"&&a.evidence!=="expression"&&n.produced.push(Cp(i,o,"carrier.publish",t.carrier,t.field,a.value,t.proofObservationIds));let c=r.caller;if(!c)continue;let l=jo(e,r).transfers.find(d=>d.calleePosition===t.parameterIndex)?.callerPosition;if(l===void 0)continue;let u={...t,definition:c,parameterIndex:l,depth:t.depth+1,proofSpans:[...t.proofSpans,{file:r.file,startLine:r.startLine,endLine:r.endLine}]};wv(n,u)}}function yV(e,t,n){let r=[],i=t.filter(o=>o.action==="registry.handle"&&o.strength!=="candidate"&&o.sourceScope==="production");for(let o of t){if(o.action!=="http.handle"||o.strength==="candidate"||o.sourceScope!=="production")continue;let s=Tv(o);if(!s)continue;let a=Ge(e,o.source.file);if(!a)continue;let c=Nv(a.root,o.source.startLine)[0];if(c)for(let l of hc(c).slice(1)){let u=rc(e,o.source.file,l.text);for(let d of u)hV(e,o,s,d,i,r,n)}}return r}function hV(e,t,n,r,i,o,s){try{let a=Ge(e,r.relativePath);if(!a)return;let c=yc(a,r);if(!c)return;Ne(c,l=>SV(e,t,n,r,a,l,i,o))}catch(a){s.push(`builtin.carrier consumer analysis failed for ${r.relativePath}: ${Pp(a)}`)}}function SV(e,t,n,r,i,o,s,a){if(o.type!=="call_expression")return;let c=Ep(o);if(!c)return;let l=/^([A-Za-z_$][\w$]*)\s*\[\s*([A-Za-z_$][\w$]*)\s*\]$/u.exec(c.text.trim());if(!l)return;let u=l[1],d=l[2],p=vV(e,i,r,d);if(!p)return;let f=RV(e,r.relativePath,u);for(let h of s)bV(e,t,n,p,f,h,a)}function bV(e,t,n,r,i,o,s){let a=o.keyParts.find(d=>d.name==="registry")?.value,c=o.keyParts.find(d=>d.name==="key")?.value;if(!a||!c||!i.some(d=>d.file===o.source.file&&d.binding===a))return;let l=Ge(e,o.source.file),u=l?st(l.root,o.source.startLine,o.source.endLine,ot,o.source):null;!l||!u||s.push(Cp(l,u,"carrier.consume",n,r,c,[t.id,o.id]))}function Fv(e){let t=k(e.db,e.file),n=new Map;return Ne(e.root,r=>{if(r.type!=="pair"||Lv(r)?.toLowerCase()!=="body")return;let i=_v(r);if(!i||!/\bJSON\.stringify\s*\(/u.test(i.text))return;let o=Hr(t,r.startPosition.row),s=xV(r);if(!o||!s)return;let a=_s(s),c=new Set;fg(i,a,c);let l=n.get(o.symbol)??new Set;a.forEach((u,d)=>{u&&c.has(u)&&l.add(d)}),l.size>0&&n.set(o.symbol,l)}),t.flatMap(r=>{let i=n.get(r.symbol),{symbol:o,relativePath:s,startLine:a,startChar:c,endLine:l,endChar:u}=r;return i?[{definition:{symbol:o,relativePath:s,startLine:a,startChar:c,endLine:l,endChar:u},parameterIndexes:[...i].sort((d,p)=>d-p)}]:[]})}function xV(e){let t=e.parent;for(;t;){if(/(?:function|method|lambda)/u.test(t.type)||t.type==="arrow_function")return t;t=t.parent}return null}function vV(e,t,n,r){let i=yc(t,n);if(!i)return null;let o=new RegExp(`\\.body\\??\\.${Ce(r)}\\b`,"u");if(o.test(i.text))return r;let s=null;if(Ne(i,u=>{if(s||u.type!=="variable_declarator")return;let d=u.childForFieldName("name")??u.namedChild(0),p=u.childForFieldName("value")??u.namedChild(1);!d||!p||!new RegExp(`(?:^|[,{}])\\s*${Ce(r)}\\s*(?:[,}]|$)`,"u").test(d.text)||p.type==="call_expression"&&(s=Ep(p)?.text??null)}),!s)return null;let a=rc(e,n.relativePath,s);if(a.length!==1)return null;let c=Ge(e,a[0].relativePath),l=c?yc(c,a[0]):null;return l&&o.test(l.text)&&new RegExp(`\\b${Ce(r)}\\s*[,}]`,"u").test(l.text)?r:null}function RV(e,t,n){let r=[];for(let i of mp(e,t,n)){let o=te(i.initializer);if(o.type==="call_expression")for(let s of hc(o)){let a=s.text.trim();if(/^[A-Za-z_$][\w$]*$/u.test(a))for(let c of mp(e,i.definition.relativePath,a))r.push({file:c.definition.relativePath,binding:c.definition.leaf})}}return[...new Map(r.map(i=>[`${i.file}\0${i.binding}`,i])).values()]}function Cp(e,t,n,r,i,o,s){let c=mc(e,t,"builtin.carrier",n,[{name:"carrier",value:r,evidence:"constant",term:{kind:"literal",value:r}},{name:"field",value:i,evidence:"literal",term:{kind:"literal",value:i}},{name:"value",value:o,evidence:"constant",term:{kind:"literal",value:o}}],"candidate","http-body-registry-discriminator-unverified-flow");return c.derivation={kind:"mechanically-derived",rule:"http-body-registry-discriminator",ruleVersion:"1",inputFactIds:[...s],sourceSpans:[c.source]},c}function Tv(e){let t=e.keyParts.find(r=>r.name==="method"&&r.evidence!=="expression")?.value,n=e.keyParts.find(r=>r.name==="path"&&r.evidence!=="expression")?.value;return t&&n?`${t.toUpperCase()} ${n}`:null}function IV(e,t){let n=e.get(t.definition.symbol);if(!n)return e.set(t.definition.symbol,t),!0;let r=Dv([...n.parameterIndexes,...t.parameterIndexes]);return r.length===n.parameterIndexes.length&&t.depth>=n.depth?!1:(e.set(t.definition.symbol,{...n,parameterIndexes:r,depth:Math.min(n.depth,t.depth),proofSpans:[...n.proofSpans,...t.proofSpans]}),!0)}function CV(e){return`${e.definition.symbol}\0${e.carrier}\0${e.field}\0${e.parameterIndex}`}function EV(e,t){let n=yc(e,t);return n?_s(n):[]}function Nv(e,t){let n=[];return Ne(e,r=>{r.type==="call_expression"&&r.startPosition.row<=t&&r.endPosition.row>=t&&n.push(r)}),n.sort((r,i)=>r.endIndex-r.startIndex-(i.endIndex-i.startIndex))}function Ep(e){return e.childForFieldName("function")??e.namedChild(0)}function hc(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function PV(e,t){if(!t)return null;let n=t.text.trim();if(!/^[A-Za-z_$][\w$]*$/u.test(n))return te(t);let r=null;return Ne(e.root,i=>{r||i.type!=="variable_declarator"||(i.childForFieldName("name")??i.namedChild(0))?.text.trim()!==n||(r=i.childForFieldName("value")??i.namedChild(1))}),r?te(r):te(t)}function wV(e){let t=te(e);return t.type==="object"?t.namedChildren.filter(n=>n.type==="pair"||n.type==="shorthand_property_identifier"):[]}function Lv(e){return e.type==="shorthand_property_identifier"?e.text:(e.childForFieldName("key")??e.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"")??null}function _v(e){return e.type==="shorthand_property_identifier"?e:e.childForFieldName("value")??e.namedChild(1)}function Dv(e){return[...new Set(e)].sort((t,n)=>t-n)}function FV(e){return[...new Map(e.map(t=>[t.id,t])).values()]}function Pp(e){return e instanceof Error?e.message:String(e)}function yc(e,t){let n=ir(e.db,e.file,t);return t.symbol.startsWith("source-callable:")?st(e.root,t.startLine,t.endLine,ot,{startColumn:t.startChar,endColumn:t.endChar}):n?st(e.root,n.startLine,n.endLine,ot,n):null}import{createHash as Av}from"crypto";var kv=ge({kind:"runtime-boundary-mount-imports",invalidation:ee("runtime-boundary-mount-imports"),serialize:JSON.stringify,deserialize:e=>e==="true"?!0:e==="false"?!1:null});function Ov(e,t){let n=TV(t),r=[],i=LV(e),o=[...i.frontiers],s=[...n].flatMap(([c,l])=>l.map(u=>({identity:c,handler:u,visited:new Set([c])}))),a=new Map;for(let c of i.mounts){let l=a.get(c.targetIdentity)??[];l.push(c),a.set(c.targetIdentity,l)}for(let c=0;c<s.length;c++){let l=s[c];for(let u of a.get(l.identity)??[]){if(r.length>=1e4)return o.push(Sc(u.source,"http-mount-composition-limit",["remaining-mount-paths"])),{observations:r,filesInspected:i.filesInspected,mounts:i.mounts.length,frontiers:o};let d=NV(l,u,r,o);d&&s.push(d)}}return{observations:r,filesInspected:i.filesInspected,mounts:i.mounts.length,frontiers:o}}function TV(e){let t=new Map;for(let n of e){if(n.action!=="http.handle"||n.sourceScope!=="production"||n.strength==="candidate")continue;let r=n.keyParts.find(o=>o.name==="router");if(r?.term?.kind!=="symbol"||r.evidence==="expression")continue;let i=t.get(r.term.symbol)??[];i.push(n),t.set(r.term.symbol,i)}return t}function NV(e,t,n,r){let i=t.receiver.term;if(i?.kind!=="symbol")return null;if(e.visited.has(i.symbol))return r.push(Sc(t.source,"http-mount-cycle",["acyclic-router-path"])),null;let o=n.length;return MV(t,e.handler,n),n.length===o?null:{identity:i.symbol,handler:n.at(-1),visited:new Set(e.visited).add(i.symbol)}}function Sc(e,t,n){return{observationId:`mount:${e.file}:${e.startLine}:${e.startColumn}:${t}`,reason:t,missingKeyParts:n,sourceScope:"production",kind:"value-flow",action:"http.handle",strength:"candidate",source:e}}function LV(e){let t=[],n=[],r=Ue(e);for(let i of r){if(!["typescript","tsx","javascript"].includes(B(i)??""))continue;let o=L(e,i),s=Av("sha256").update(o).digest("hex");if(kv.read(e,i,s)===!1)continue;let a=Ph(i,o);if(!a)continue;let c=a.some(u=>u.literal&&u.specifier==="express");if(kv.write(e,i,s,c),!c)continue;let l=Ge(e,i,o);l&&jv(l.root,u=>kV(l,u,t,n))}return{mounts:t,filesInspected:r.length,frontiers:n}}function _V(e,t){if(t.type!=="call_expression")return null;let n=t.childForFieldName("function")??t.namedChild(0);if(n?.type!=="member_expression"||n.childForFieldName("property")?.text!=="use")return null;let r=n.childForFieldName("object");return r&&Mv(e,r)?r:null}function Mv(e,t){let n=M(e.file,e.root).constructedValue(t);return n?.module==="express"&&[null,"default","Router"].includes(n.member)}function DV(e,t){let n=t[0];if(!n)return null;let r=$e(e,n);return r&&r.evidence!=="expression"&&r.precision==="literal"?{prefix:r,routers:t.slice(1)}:t.length===1||Mv(e,n)?{prefix:{value:"/",evidence:"constant",term:{kind:"literal",value:"/"}},routers:t}:null}function kV(e,t,n,r){let i=_V(e,t);if(!i)return;let o={file:e.file,startLine:t.startPosition.row,startColumn:t.startPosition.column,endLine:t.endPosition.row,endColumn:t.endPosition.column},s=DV(e,OV(t));if(!s){r.push(Sc(o,"http-mount-prefix-unresolved",["literal-prefix"]));return}for(let a of s.routers){let c=Ln(e,a);if(c.evidence==="expression"||c.term?.kind!=="symbol"){r.push(Sc(o,"http-mount-target-unresolved",["router-instance-binding"]));continue}n.push({file:e.file,line:t.startPosition.row,prefix:s.prefix,targetIdentity:c.term.symbol,receiver:{name:"router",...Ln(e,i)},source:o})}}function AV(e,t){let n=e==="/"?"":e.replace(/\/+$/u,""),r=t.startsWith("/")?t:`/${t}`;return`${n}${r}`||"/"}function OV(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function jv(e,t){t(e);for(let n of e.namedChildren)jv(n,t)}function MV(e,t,n){let r=t.keyParts.find(a=>a.name==="path");if(!r||r.evidence==="expression")return;let i=AV(e.prefix.value,r.value),o=t.keyParts.map(a=>a.name==="router"?e.receiver:a.name==="path"?{name:"path",value:i,evidence:"constant",term:{kind:"concat",parts:[e.prefix.term??{kind:"literal",value:e.prefix.value},r.term??{kind:"literal",value:r.value}]},derivation:{kind:"mechanically-derived",rule:"http.mount-prefix",ruleVersion:"1",inputFactIds:[t.id],sourceSpans:[t.source,e.source,...e.prefix.derivation?.sourceSpans??[],...r.derivation?.sourceSpans??[]]}}:a),s=`${t.id}\0${e.file}\0${e.line}:${e.source.startColumn}\0${i}`;n.push({...t,id:`boundary:${Av("sha256").update(s).digest("hex").slice(0,16)}`,keyParts:o,strength:"derived",evidence:"framework-mount-composition",derivation:{kind:"mechanically-derived",rule:"http.mount-prefix",ruleVersion:"1",inputFactIds:[t.id],sourceSpans:[t.source,e.source]},resolution:"unresolved"})}function li(e){return[...new Map(e.map(t=>[t.observationId,t])).values()].sort((t,n)=>t.observationId.localeCompare(n.observationId))}import{createHash as jV}from"crypto";var $o=new Set(["DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT"]),BV=8;function wp(e){return e.filter(t=>t.action==="http.request"&&!!t.owner.symbol&&(t.evidence==="call-expression"||t.evidence==="client-adapter"))}var Bv=ge({kind:"runtime-boundary-http-roles",invalidation:ee("runtime-boundary-http-roles"),serialize:HV,deserialize:zV});function Gv(e,t,n){let r=n??((m,g)=>g()),i=new Map,o=[],s=[],a=new Set,c=[],l=[],u=new Map,d=new Map,p=new Map,f=m=>{if(u.has(m))return u.get(m)??null;let g=Ge(e,m);return u.set(m,g),g},h=m=>{let g=d.get(m);if(g)return g;let y=k(e,m);return d.set(m,y),y},b=(m,g,y)=>{let I=p.get(m.file);if(!I){let N=Se(e,m.file,m.source),Pe=Bv.read(e,m.file,N)??[];I={contentHash:N,roles:new Map(Pe.map(ke=>[ke.symbol,ke])),dirty:!1},p.set(m.file,I)}let w=`v2:${g.symbol}:${y.startLine}:${y.startColumn}:${y.endLine}:${y.endColumn}`,j=I.roles.get(w);if(j)return j;let C=UV(m,y);return I.roles.set(w,{symbol:w,...C}),I.dirty=!0,C};r("runtime-boundaries.http-summary.seed",()=>{for(let m of wp(t)){let g=h(m.owner.file).find(j=>j.symbol===m.owner.symbol);if(!g)continue;let y=f(g.relativePath);if(!y)continue;let I=b(y,g,m.source),w={definition:g,...I,depth:0,proofObservationIds:[m.id],proofSpans:[m.source]};Vv(i,w)&&o.push(w)}});let x={db:e,summaries:i,queue:o,derived:s,filesInspected:a,errors:c,frontiers:l,contextForFile:f};for(;o.length>0;){let m=o.splice(0,o.length),g=r("runtime-boundaries.http-summary.resolve-call-sites",()=>vv(e,m.map(y=>y.definition)),{batchSize:m.length});r("runtime-boundaries.http-summary.process-call-sites",()=>{for(let y of m)$V(y,g,x)},{batchSize:m.length})}return Bv.writeBatch(e,[...p.entries()].flatMap(([m,g])=>g.dirty?[{relativePath:m,contentHash:g.contentHash,value:[...g.roles.values()].sort((y,I)=>y.symbol.localeCompare(I.symbol))}]:[])),{observations:s,frontiers:li(l),summaries:i.size,filesInspected:a.size,errors:c,summarySymbols:Go([...i.values()].map(m=>m.definition.symbol)),inspectedFiles:[...a].sort()}}function $V(e,t,n){let{errors:r,frontiers:i}=n;if(!(e.depth>=BV))try{let o=t.get(e.definition.symbolId);if(!o)return;i.push(...o.unresolved.map(s=>VV(e,s)));for(let s of o.sites)GV(e,s,n)}catch(o){r.push(`builtin.http-summary failed for ${e.definition.relativePath}:${e.definition.startLine+1}: ${o instanceof Error?o.message:String(o)}`)}}function GV(e,t,n){let{db:r,summaries:i,queue:o,derived:s,filesInspected:a,contextForFile:c}=n,l=c(t.file);if(!l)return;a.add(t.file);let u=t.callNode,d=WV(e,u,l);d&&s.push(d);let p=t.caller;if(!p)return;let f=KV(r,e,t),h={definition:p,...f,constantMethods:Go([...e.constantMethods,...qV(e,u,l)]),depth:e.depth+1,proofObservationIds:Go([...e.proofObservationIds,...d?[d.id]:[]]),proofSpans:[...e.proofSpans,{file:t.file,startLine:t.startLine,endLine:t.endLine}]};Vv(i,h)&&o.push(h)}function VV(e,t){let n=Go([...e.pathParameterIndexes.length>0?["path"]:[],...e.methodParameterIndexes.length>0&&e.constantMethods.length!==1?["method"]:[]]),r=e.constantMethods.length===1?e.constantMethods[0]:"?",i=`${e.definition.symbol}\0${t.file}\0${t.line}\0${t.reason}`;return{observationId:`frontier:${jV("sha256").update(i).digest("hex").slice(0,16)}`,kind:"call-resolution",action:"http.request",strength:"candidate",source:{file:t.file,startLine:t.line,endLine:t.line},ownerShortName:null,address:`method=${r??"?"} path=?`,reason:`Compiler identity found a reference to ${e.definition.leaf}, but exact call recovery stopped with ${t.reason} (${t.candidates} syntax candidate(s)); HTTP value propagation did not cross this site.`,missingKeyParts:n.length>0?n:["call"],sourceScope:dc(t.file)}}function WV(e,t,n){let r=Fp(t);if(r.some(d=>d.type==="spread_element"))return null;let i=e.pathParameterIndexes.flatMap(d=>{let p=$e(n,r[d]);return p&&p.evidence!=="expression"&&JV(p.value)?[{index:d,value:p}]:[]}),o=e.methodParameterIndexes.flatMap(d=>{let p=$e(n,r[d]),f=p?.value.toUpperCase();return p&&f&&p.precision==="literal"&&p.evidence!=="expression"&&$o.has(f)?[{index:d,value:{...p,value:f}}]:[]}),s=Go([...e.constantMethods,...o.map(d=>d.value.value)]);if(i.length!==1||s.length!==1)return null;let a=i[0].value,c=o.find(d=>d.value.value===s[0])?.value,l=[{name:"method",value:s[0],evidence:c?"constant":"literal",term:c?.term??{kind:"literal",value:s[0]},precision:"literal",derivation:c?.derivation},{name:"path",value:a.value,evidence:"constant",term:a.term,precision:a.precision,derivation:a.derivation}],u=mc(n,t,"builtin.http-summary","http.request",l,"derived","compiler-resolved-http-summary");return u.derivation={kind:"mechanically-derived",rule:"compiler-resolved-http-summary",ruleVersion:"1",inputFactIds:e.proofObservationIds,sourceSpans:[...e.proofSpans,u.source]},u}function UV(e,t){let n={pathParameterIndexes:[],methodParameterIndexes:[],constantMethods:[]};if(t.startColumn===void 0||t.endColumn===void 0)return n;let r=st(e.root,t.startLine,t.endLine,ot,t);if(r?.type!=="call_expression")return n;let i=M(e.file,e.root),o=r.childForFieldName("function"),s=o&&i.importedValue(o),a=lc(e,r),c=s?.module==="axios"&&s.member?s.member.toUpperCase():null;if(!a&&(!c||!$o.has(c)))return n;let l=Fp(r);if(l.some(h=>h.type==="spread_element"))return n;let u=l[0]?i.directParameterPosition(l[0]):null,d=a?ci(e,l[1],"method"):null,p=d?.kind==="value"?i.directParameterPosition(d.node):null,f=a?uc(l[1],e):c;return{pathParameterIndexes:u===null?[]:[u],methodParameterIndexes:p===null?[]:[p],constantMethods:f&&$o.has(f)?[f]:[]}}function qV(e,t,n){let r=Fp(t);return r.some(i=>i.type==="spread_element")?[]:e.methodParameterIndexes.flatMap(i=>{let o=$e(n,r[i]);return o&&o.precision==="literal"&&["constant","literal"].includes(o.evidence)&&$o.has(o.value.toUpperCase())?[o.value.toUpperCase()]:[]})}function HV(e){return e.map(t=>[encodeURIComponent(t.symbol),t.pathParameterIndexes.join(","),t.methodParameterIndexes.join(","),t.constantMethods.join(",")].join(" ")).join(`
|
|
450
|
+
`)}function zV(e){if(!e)return[];let t=[];for(let n of e.split(`
|
|
451
|
+
`)){let r=n.split(" ");if(r.length!==4)return null;let i=$v(r[1]),o=$v(r[2]),s=r[3]?r[3].split(","):[];if(i===null||o===null||s.some(a=>!$o.has(a)))return null;t.push({symbol:decodeURIComponent(r[0]),pathParameterIndexes:i,methodParameterIndexes:o,constantMethods:s})}return t}function $v(e){if(!e)return[];let t=e.split(",").map(Number);return t.every(n=>Number.isSafeInteger(n)&&n>=0)?t:null}function KV(e,t,n){let r=jo(e,n);return{pathParameterIndexes:Bo(r,t.pathParameterIndexes),methodParameterIndexes:Bo(r,t.methodParameterIndexes)}}function Vv(e,t){if(t.pathParameterIndexes.length===0)return!1;let n=JSON.stringify([t.definition.symbol,t.pathParameterIndexes,t.methodParameterIndexes,t.constantMethods]),r=e.get(n);return r&&r.depth<=t.depth?!1:(e.set(n,t),!0)}function Fp(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function JV(e){return e.startsWith("/")||/^https?:\/\//iu.test(e)}function Go(e){return[...new Set(e)].sort()}var YV=32;function Wv(e){let t=wp(e.observations),n=XV(t,e.previous),r=(c,l)=>Mo({db:e.db,scope:e.scope,seeds:Oo(c),compilerFactsUnchanged:e.compilerFactsUnchanged,previous:l?.record,compute:u=>Gv(u,c,e.profileSpan)}),i=n.map(c=>({...c,phase:r(c.seeds,c.previous)}));if(!QV(i.map(c=>c.phase.result))){let c=r(t);return{result:c.result,partitions:c.record?[{observationIds:t.map(l=>l.id),record:c.record}]:void 0,reused:!1,filesVisited:c.result.filesInspected}}let o=i.map(c=>c.phase.result),s=new Set(o.flatMap(c=>c.inspectedFiles));return{result:{observations:o.flatMap(c=>c.observations),frontiers:li(o.flatMap(c=>c.frontiers)),summaries:o.reduce((c,l)=>c+l.summaries,0),filesInspected:s.size,errors:o.flatMap(c=>c.errors),summarySymbols:o.flatMap(c=>c.summarySymbols).sort(),inspectedFiles:[...s].sort()},partitions:i.every(c=>c.phase.record)?i.map(c=>({observationIds:c.seeds.map(l=>l.id),record:c.phase.record})):void 0,reused:i.every(c=>c.phase.reused),filesVisited:new Set(i.filter(c=>!c.phase.reused).flatMap(c=>c.phase.result.inspectedFiles)).size}}function XV(e,t){if(!e.length)return[{seeds:e,previous:t?.find(i=>i.observationIds?.length===0)}];if(!t?.length||t.length>=YV)return[{seeds:e,previous:void 0}];let n=new Map(e.map(i=>[i.id,i])),r=[];for(let i of t){if(!Array.isArray(i?.observationIds))return[{seeds:e,previous:void 0}];let o=new Set(i.observationIds),s=e.filter(a=>n.has(a.id)&&o.has(a.id));for(let a of s)n.delete(a.id);s.length&&r.push({seeds:s,previous:i})}return(n.size||!r.length)&&r.push({seeds:[...n.values()]}),r}function QV(e){if(e.length===1)return!0;let t=new Set;for(let n of e){if(n.errors.length||!Array.isArray(n.summarySymbols)||!Array.isArray(n.inspectedFiles))return!1;for(let r of n.summarySymbols){if(t.has(r))return!1;t.add(r)}}return!0}import{createHash as ZV}from"crypto";function Hv(e){let t=Uv(e.filter(r=>r.action==="database.read"&&r.evidence.startsWith("persistence-skip-locked-claim"))),n=Uv(e.filter(r=>r.action==="database.write"&&r.evidence.startsWith("persistence-insert")));return e.flatMap(r=>r.action==="database.write"&&r.evidence.startsWith("persistence-insert")?Tp(r).flatMap(i=>{let o=t.get(i)?.[0];return o?[qv(r,o,i,"queue.send")]:[]}):r.action==="database.read"&&r.evidence.startsWith("persistence-skip-locked-claim")?Tp(r).flatMap(i=>{let o=n.get(i)?.[0];return o?[qv(r,o,i,"queue.consume")]:[]}):[])}function Uv(e){let t=new Map;for(let n of e)for(let r of Tp(n)){let i=t.get(r);i?i.push(n):t.set(r,[n])}for(let n of t.values())n.sort((r,i)=>r.id.localeCompare(i.id));return t}function Tp(e){return e.keyParts.filter(t=>t.name==="resource").map(t=>t.value)}function qv(e,t,n,r){let i=`database:${n}`,o=r==="queue.send"?"database-queue-insert":"database-queue-skip-locked-claim",s=[e.id,r,i,o].join("\0");return{...e,id:`boundary:${ZV("sha256").update(s).digest("hex").slice(0,16)}`,extractor:"builtin.database-queue",action:r,keyParts:[{name:"address",value:i,evidence:"identifier",term:{kind:"symbol",symbol:n},derivation:{kind:"mechanically-derived",rule:"database-work-queue.resource",ruleVersion:"1",inputFactIds:[e.id,t.id],sourceSpans:[e.source,t.source]}}],evidence:o,strength:"candidate",protocol:"queue",role:r==="queue.send"?"producer":"consumer",derivation:{kind:"mechanically-derived",rule:"database-work-queue.insert-skip-locked",ruleVersion:"1",inputFactIds:[e.id,t.id],sourceSpans:[e.source,t.source]},valuePrecision:"symbolic",resolution:"unresolved"}}var ui="runtime-boundaries-v32",tW=eW(import.meta.url),pe=tW("typescript"),nW=new Set([pe.SyntaxKind.WhitespaceTrivia,pe.SyntaxKind.NewLineTrivia,pe.SyntaxKind.SingleLineCommentTrivia,pe.SyntaxKind.MultiLineCommentTrivia]),rW=new Set([pe.SyntaxKind.NoSubstitutionTemplateLiteral,pe.SyntaxKind.TemplateHead,pe.SyntaxKind.TemplateMiddle,pe.SyntaxKind.TemplateTail]),di=[{id:"http.method-path",unresolvedIdentity:"HTTP deployment and server instance identity are not established by a matching method and path.",protocol:"http",producerActions:["http.request"],consumerActions:["http.handle"],keyNames:["method","path"],traversable:!0},{id:"registry.identity-key",protocol:"registry",producerActions:["registry.dispatch"],consumerActions:["registry.handle"],keyNames:["registry","key"],traversable:!0},{id:"registry.capability-key",unresolvedIdentity:"A named capability in instruction text does not prove registration in the active tool registry or execution of that capability.",protocol:"registry",producerActions:["registry.reference"],consumerActions:["registry.handle"],keyNames:["key"],traversable:!0,requireUniqueConsumer:!0},{id:"queue.address",unresolvedIdentity:"Queue broker and namespace identity are not established by a matching address.",protocol:"queue",producerActions:["queue.send"],consumerActions:["queue.consume"],keyNames:["address"],traversable:!0},{id:"carrier.discriminator",protocol:"carrier",producerActions:["carrier.publish"],consumerActions:["carrier.consume"],keyNames:["carrier","field","value"],traversable:!0},{id:"resource.identity",protocol:"database",producerActions:["database.write"],consumerActions:["database.read"],keyNames:["resource"],traversable:!1},{id:"framework.effect-httpapi-operation",unresolvedIdentity:"Effect API instance identity and builder receiver flow are not established by matching group and operation names.",protocol:"framework",producerActions:[],consumerActions:["framework.handle"],declarationActions:["framework.declare"],keyNames:["adapter","group","operation"],traversable:!0,linkFrom:"declaration",requireUniquePair:!0}],iW=64;async function oW(e,t={}){let{files:n,previousFileCoverage:r,incrementallyReusable:i,retainedFileCoverage:o,retainedObservations:s,filesToExtract:a}=sW(e,t),c=[],l=r?.reduce((we,Cc)=>we+Cc.observationIds.length,0)??0,u=performance.now(),d=await lW(e,a,t.profileSpan);Dn(c,"direct-extraction",u,a.length,d.observations.length,{filesVisited:a.length,filesReused:o.length,factsReused:s.length,factsInvalidated:Math.max(0,l-s.length)});let p=[...o,...d.fileCoverage].sort((we,Cc)=>we.file.localeCompare(Cc.file)),f=bW(p),h=p.flatMap(we=>we.extractionErrors),b=Vo([...s,...d.observations]),x=Vo([...b,...Hv(b)]),m=Yx(e,n),g=!t.forceDerivedRebuild&&t.previousGraph?.extractorVersion===ui?t.previousGraph.phaseRecords:void 0,y=t.compilerFactsUnchanged===!0,I={};u=performance.now();let w=Wv({db:e,scope:m,observations:x,compilerFactsUnchanged:y,previous:g?.httpPartitions,profileSpan:t.profileSpan}),j=w.result;I.httpPartitions=w.partitions,Dn(c,"http-summary",u,x.length,j.observations.length,{filesVisited:w.filesVisited,...w.reused?{filesReused:j.filesInspected,factsReused:j.observations.length+j.frontiers.length,factsInvalidated:0}:{}}),f.set("builtin.wrapper",{id:"builtin.wrapper",applicableFiles:j.filesInspected,observations:j.observations.length,errors:j.errors.length}),h.push(...j.errors);let C=Vo([...x,...j.observations]);await zv(w.reused),u=performance.now();let N=Ov(e,C);Dn(c,"http-mount",u,C.length,N.observations.length,{filesVisited:N.filesInspected});let Pe=Vo([...C,...N.observations]);u=performance.now();let ke=p.flatMap(we=>we.bodySummaries??[]),he=Mo({db:e,scope:m,seeds:Oo([],ke),compilerFactsUnchanged:y,previous:g?.body,compute:we=>Ev(we,ke)});I.body=he.record,Dn(c,"body-summary",u,ke.length,he.result.summaries.length,{filesVisited:he.reused?0:he.result.filesInspected,...he.reused?{factsReused:he.result.summaries.length,factsInvalidated:0}:{}}),await zv(he.reused),u=performance.now();let yr=Mo({db:e,scope:m,seeds:Oo(Pe,he.result),compilerFactsUnchanged:y,previous:g?.carrier,compute:we=>Pv(we,Pe,he.result)}),Vt=yr.result;I.carrier=yr.record,Dn(c,"carrier",u,Pe.length,Vt.observations.length,{filesVisited:yr.reused?0:Vt.filesInspected,...yr.reused?{filesReused:Vt.filesInspected,factsReused:Vt.observations.length,factsInvalidated:0}:{}}),f.set("builtin.carrier",{id:"builtin.carrier",applicableFiles:Vt.bodySummaries,observations:Vt.observations.length,errors:Vt.errors.length}),h.push(...Vt.errors);let kn=Vo([...Pe,...Vt.observations]);u=performance.now();let hr=vW(kn);Dn(c,"relations",u,kn.length,hr.length),u=performance.now();let Np=wW(kn,hr);Dn(c,"links",u,hr.length,Np.length),FW(kn,hr),u=performance.now();let Lp=li([...TW(kn,hr),...j.frontiers,...N.frontiers]);return Dn(c,"frontiers",u,kn.length,Lp.length),{schemaVersion:2,extractorVersion:ui,observations:kn,relationGroups:hr,links:Np,frontiers:Lp,coverage:{filesScanned:n.length,filesWithAst:p.filter(we=>we.hasAst).length,filesWithoutAst:p.filter(we=>!we.hasAst).length,...i?{filesReused:o.length}:{},extractors:[...f.values()],extractionErrors:h,phases:c},fileCoverage:p,phaseRecords:I}}async function zv(e){e||(gn(),await Yv())}function sW(e,t){let n=Ue(e),r=new Set(n),i=new Set((t.affectedFiles??[]).map(xW)),o=t.previousGraph?.fileCoverage;aW(e,o,i);let s=i.size>0&&t.previousGraph?.extractorVersion===ui&&o!==void 0&&o.length===t.previousGraph.coverage.filesScanned,a=s?o.filter(d=>r.has(d.file)&&!i.has(d.file)):[],c=new Set(a.flatMap(d=>d.observationIds)),l=s?t.previousGraph.observations.filter(d=>c.has(d.id)&&r.has(d.source.file)):[],u=s?n.filter(d=>i.has(d)):n;return{files:n,affectedFiles:i,previousFileCoverage:o,incrementallyReusable:s,retainedFileCoverage:a,retainedObservations:l,filesToExtract:u}}function aW(e,t,n){if(n.size!==0)for(let r of t??[]){if(!r.dependsOnReferenceSet)continue;let i=Li(e,r.file);Xv(e,r.file,Se(e,r.file,i))||n.add(r.file)}}function Dn(e,t,n,r,i,o={}){e.push({id:t,durationMs:Math.max(0,performance.now()-n),inputFacts:r,outputFacts:i,...o})}var cW=256;async function lW(e,t,n){let r=[],i=[],o=n??((d,p)=>p()),s=[],a=[],c=new Map,l=d=>{let p=c.get(d);if(p!==void 0)return p;let f=Se(e,d,Li(e,d));return c.set(d,f),f},u=0;for(let d of t){u+=1,u>=cW&&(u=0,gn(),await Yv());let p=o("runtime-boundaries.file.read",()=>Li(e,d)),f=Se(e,d,p);c.set(d,f);let h=o("runtime-boundaries.file.direct-product",()=>Xv(e,d,f,l));if(h){r.push(...h.observations),i.push(h.coverage);continue}let b=o("runtime-boundaries.file.supports",()=>xp.filter(C=>C.supports(p))),x=/\bJSON\.stringify\s*\(/u.test(p)&&/\bbody\s*:/u.test(p),m=o("runtime-boundaries.file.hashes",()=>{let C=Kv.read(e,d,f);if(C)return C;let N=gW(d,p);return s.push({relativePath:d,contentHash:f,value:N}),N}),g=new Set,y=new Map,I=!0,w=[],j=vs(C=>g.add(C),()=>{let C=b.length>0||x?Ge(e,d,p,n):null,N={file:d,hasAst:C!==null||SW(d,p),syntaxHash:m.syntaxHash,shapeHash:m.shapeHash,bodySummaries:C&&x?Fv(C):[],observationIds:[],extractors:[],extractionErrors:[]};if(C)for(let Pe of b){let ke={id:Pe.id,applicableFiles:1,observations:0,errors:0};try{let he=hW(n,`runtime-boundaries.extractor.${Pe.id}`,d,()=>Pe.extract(C));ke.observations=he.length,w.push(...he),N.observationIds.push(...he.map(yr=>yr.id))}catch(he){Ie(d),ke.errors=1,N.extractionErrors.push(`${Pe.id} failed for ${d}: ${he instanceof Error?he.message:String(he)}`)}N.extractors.push(ke)}return N},(C,N)=>y.set(C,N),{source(){},unavailable(){I=!1}});y.size>0&&(j.dependsOnReferenceSet=!0),r.push(...w),i.push(j),I&&(g.delete(d),a.push({relativePath:d,contentHash:f,value:{extractorVersion:ui,deps:[...g].sort().map(C=>({path:C,contentHash:l(C)})),symbolReferences:[...y].map(([C,N])=>({symbol:C,files:[...N]})),observations:w,coverage:j}}))}return s.length>0&&Kv.writeBatch(e,s),a.length>0&&Qv.writeBatch(e,a),{observations:r,fileCoverage:i}}var Kv=ge({kind:"runtime-boundary-source-hashes",invalidation:ee("runtime-boundary-source-hashes"),serialize:e=>JSON.stringify(e),deserialize:e=>{try{let t=JSON.parse(e);return typeof t.syntaxHash=="string"&&typeof t.shapeHash=="string"?{syntaxHash:t.syntaxHash,shapeHash:t.shapeHash}:null}catch{return null}}});function Xv(e,t,n,r=i=>Se(e,i,Li(e,i))){let i=Qv.read(e,t,n);return!i||i.extractorVersion!==ui||i.coverage.dependsOnReferenceSet&&!i.symbolReferences?.length||!uW(e,i.symbolReferences)?null:i.deps.every(o=>r(o.path)===o.contentHash)?i:null}function uW(e,t){return t===void 0?!0:Array.isArray(t)?t.every(n=>n&&typeof n.symbol=="string"&&Array.isArray(n.files)&&JSON.stringify(Gu(e,n.symbol))===JSON.stringify(n.files)):!1}var Qv=ge({kind:"runtime-boundary-direct-extraction",invalidation:ee("runtime-boundary-direct-extraction"),serialize:e=>JSON.stringify(e),deserialize:e=>{try{let t=JSON.parse(e);return typeof t.extractorVersion!="string"||!Array.isArray(t.deps)||!Array.isArray(t.observations)||typeof t.coverage!="object"||t.coverage===null||!t.deps.every(n=>typeof n=="object"&&n!==null&&typeof n.path=="string"&&typeof n.contentHash=="string")?null:t}catch{return null}}});function dW(e){let t=[0];for(let n=0;n<e.length;n+=1)e.charCodeAt(n)===10&&t.push(n+1);return t}function pW(e,t,n){return t===pe.SyntaxKind.CloseBraceToken&&n.length>0&&n.at(-1)===0&&(t=e.reScanTemplateToken(!1)),t}function fW(e,t,n){for(;e[t+1]!==void 0&&e[t+1]<=n;)t+=1;return t}function Jv(e,t,n,r,i){e.update(`${t}\0${i?n:""}\0${r}\0`)}function mW(e,t){e===pe.SyntaxKind.TemplateHead?t.push(0):e===pe.SyntaxKind.TemplateTail?t.pop():e===pe.SyntaxKind.OpenBraceToken&&t.length>0?t[t.length-1]+=1:e===pe.SyntaxKind.CloseBraceToken&&t.length>0&&t.at(-1)>0&&(t[t.length-1]-=1)}function gW(e,t){if(!/\.(?:[cm]?[jt]sx?)$/iu.test(e)){let l=Wo("sha256").update(t).digest("hex");return{syntaxHash:l,shapeHash:l}}let n=/\.[jt]sx$/iu.test(e)?pe.LanguageVariant.JSX:pe.LanguageVariant.Standard,r=pe.createScanner(pe.ScriptTarget.Latest,!1,n,t),i=Wo("sha256"),o=Wo("sha256"),s=[],a=dW(t),c=0;for(let l=r.scan();l!==pe.SyntaxKind.EndOfFileToken;l=r.scan()){if(l=pW(r,l,s),nW.has(l))continue;let u=r.getTokenText();c=fW(a,c,r.getTokenPos()),Jv(i,l,u,c,!0),Jv(o,l,u,c,!rW.has(l)&&!yW(l,u)),mW(l,s)}return{syntaxHash:i.digest("hex"),shapeHash:o.digest("hex")}}function yW(e,t){if(e!==pe.SyntaxKind.StringLiteral||t.length<2)return!1;let n=t.slice(1,-1);return n.startsWith("/")||n.includes("://")}function hW(e,t,n,r){return e?e(t,r,{file:n}):r()}function SW(e,t){return t?it(e)?/<script\b/iu.test(t):B(e)!==null:!1}function bW(e){let t=new Map(xp.map(n=>[n.id,{id:n.id,applicableFiles:0,observations:0,errors:0}]));for(let n of e)for(let r of n.extractors){let i=t.get(r.id);i&&(i.applicableFiles+=r.applicableFiles,i.observations+=r.observations,i.errors+=r.errors)}return t}function xW(e){return e.replaceAll("\\","/").replace(/^\.\//u,"")}function vW(e){let t=new Map;for(let n of di){let r=new Set([...n.producerActions,...n.consumerActions,...n.declarationActions??[]]);for(let i of e)RW(t,n,r,i)}return[...t.values()].map(IW).sort(DW)}function RW(e,t,n,r){if(!n.has(r.action)||r.strength==="candidate")return;let i=LW(r,t.keyNames);if(!i)return;let o=i.map(u=>`${u.name}=${eR(u.name,u.value)}`).join("\0"),s=r.sourceScope==="production"?"production":r.sourceScope,a=`${t.id}\0${s}\0${o}`,c=`boundary-group:${Wo("sha256").update(a).digest("hex").slice(0,16)}`,l=e.get(c)??{id:c,protocol:t.protocol,joinRule:t.id,normalizedKey:o,keyParts:i,producerIds:[],consumerIds:[],declarationIds:[],derivation:{kind:"mechanically-derived",rule:t.id,ruleVersion:"2",inputFactIds:[],sourceSpans:[]}};t.producerActions.includes(r.action)&&l.producerIds.push(r.id),t.consumerActions.includes(r.action)&&l.consumerIds.push(r.id),t.declarationActions?.includes(r.action)&&l.declarationIds.push(r.id),l.derivation.inputFactIds.push(r.id),l.derivation.sourceSpans.push(r.source),e.set(c,l)}function IW(e){return{...e,producerIds:bc(e.producerIds),consumerIds:bc(e.consumerIds),declarationIds:bc(e.declarationIds),derivation:{...e.derivation,inputFactIds:bc(e.derivation.inputFactIds),sourceSpans:[...new Map(e.derivation.sourceSpans.map(t=>[`${t.file}:${t.startLine}:${t.startColumn}:${t.endLine}:${t.endColumn}`,t])).values()]}}}function CW(e,t,n){return n.length===0||e.consumerIds.length===0||t.requireUniquePair&&(n.length!==1||e.consumerIds.length!==1)||t.requireUniqueConsumer&&e.consumerIds.length!==1?!1:n.length*e.consumerIds.length<=iW}function EW(e){let t=di.find(r=>r.id===e.joinRule);if(!t?.traversable)return[];let n=t.linkFrom==="declaration"?e.declarationIds:e.producerIds;return CW(e,t,n)?n:[]}function PW(e,t,n,r){let i=r.get(t),o=r.get(n);if(!i||!o||_W(i,o))return null;let s=di.find(l=>l.id===e.joinRule)?.unresolvedIdentity?"candidate":i.strength==="derived"||o.strength==="derived"?"derived":"exact",a=`${e.joinRule}\0${t}\0${n}`;return{id:`boundary-link:${Wo("sha256").update(a).digest("hex").slice(0,16)}`,from:t,to:n,joinRule:e.joinRule,matchedKeyParts:e.keyParts,strength:s,derivation:{kind:"mechanically-derived",rule:e.joinRule,ruleVersion:"2",inputFactIds:[t,n],sourceSpans:[i.source,o.source]}}}function wW(e,t){let n=new Map(e.map(i=>[i.id,i])),r=new Map;for(let i of t){let o=EW(i);for(let s of o)for(let a of i.consumerIds){let c=PW(i,s,a,n);c&&r.set(c.id,c)}}return[...r.values()].sort(kW)}function FW(e,t){let n=new Set(t.filter(Zv).flatMap(Uo)),r=new Set(t.filter(NW).flatMap(Uo));for(let i of e)i.resolution=n.has(i.id)?"locally-linked":r.has(i.id)?"ambiguous":"unresolved"}function TW(e,t){let n=new Set(e.filter(o=>o.strength!=="candidate").map(o=>`${o.action}\0${o.source.file}\0${o.source.startLine}:${o.source.startColumn}\0${o.source.endLine}:${o.source.endColumn}`)),r=new Set(t.flatMap(Uo)),i=new Set(t.filter(Zv).flatMap(Uo));return e.filter(o=>o.sourceScope==="production").filter(o=>o.strength!=="candidate"||!n.has(`${o.action}\0${o.source.file}\0${o.source.startLine}:${o.source.startColumn}\0${o.source.endLine}:${o.source.endColumn}`)).filter(o=>!i.has(o.id)).map(o=>{let s=o.keyParts.filter(l=>l.evidence==="expression"||l.value.length===0).map(l=>l.name),c=t.filter(l=>Uo(l).includes(o.id)).map(l=>di.find(u=>u.id===l.joinRule)?.unresolvedIdentity).find(Boolean)??(s.length>0?`${o.extractor} observed ${o.action}, but ${s.join(", ")} remained symbolic or unknown.`:o.resolution==="ambiguous"?`${o.extractor} established the address for ${o.action}, but more than one indexed peer has the same runtime key.`:r.has(o.id)?`${o.extractor} established the address for ${o.action}, but the indexed production scope contains no counterpart role in that relation group.`:`${o.extractor} observed ${o.action}, but no supported factorization rule could establish its addressed relation.`);return{observationId:o.id,reason:c,missingKeyParts:s,sourceScope:o.sourceScope}}).sort((o,s)=>o.observationId.localeCompare(s.observationId))}function Uo(e){return[...e.producerIds,...e.consumerIds,...e.declarationIds]}function Zv(e){let t=di.find(r=>r.id===e.joinRule);if(!t||t.unresolvedIdentity||t.requireUniqueConsumer&&e.consumerIds.length!==1)return!1;let n=t.linkFrom==="declaration"?e.declarationIds:e.producerIds;return n.length===0||e.consumerIds.length===0?!1:!t.requireUniquePair||n.length===1&&e.consumerIds.length===1}function NW(e){let t=di.find(r=>r.id===e.joinRule);if(!t?.requireUniquePair&&!t?.requireUniqueConsumer)return!1;let n=t.linkFrom==="declaration"?e.declarationIds:e.producerIds;return n.length>0&&e.consumerIds.length>0&&(e.consumerIds.length!==1||t.requireUniquePair===!0&&n.length!==1)}function LW(e,t){let n=[];for(let r of t){let i=e.keyParts.find(s=>s.name===r);if(!i||i.evidence==="expression"||i.value.length===0)return null;let o=r==="registry"&&i.term?.kind==="symbol"?i.term.symbol:i.value;n.push({...i,value:eR(r,o)})}return n}function eR(e,t){return e==="method"?t.toUpperCase():t}function _W(e,t){return e.id===t.id||e.source.file===t.source.file&&e.source.startLine===t.source.startLine&&e.source.startColumn!==void 0&&e.source.startColumn===t.source.startColumn&&e.source.endLine===t.source.endLine&&e.source.endColumn===t.source.endColumn}function Vo(e){return[...new Map(e.map(t=>[t.id,t])).values()].sort((t,n)=>t.source.file.localeCompare(n.source.file)||t.source.startLine-n.source.startLine||t.action.localeCompare(n.action))}function bc(e){return[...new Set(e)].sort()}function DW(e,t){return e.joinRule.localeCompare(t.joinRule)||e.normalizedKey.localeCompare(t.normalizedKey)}function kW(e,t){return e.joinRule.localeCompare(t.joinRule)||e.from.localeCompare(t.from)||e.to.localeCompare(t.to)}import AW from"better-sqlite3";var vc="scip_query_runtime_boundaries",gr="scip_query_runtime_observations",Rc="scip_query_runtime_relation_groups",Ic="scip_query_runtime_relation_participants";function OW(e,t){let n=new AW(e);try{n.exec(`
|
|
452
|
+
CREATE TABLE IF NOT EXISTS ${vc} (
|
|
453
|
+
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
454
|
+
schema_version INTEGER NOT NULL,
|
|
455
|
+
extractor_version TEXT NOT NULL,
|
|
456
|
+
payload TEXT NOT NULL
|
|
457
|
+
)
|
|
458
|
+
`),jW(n),n.transaction(()=>{n.prepare(`INSERT OR REPLACE INTO ${vc} (singleton, schema_version, extractor_version, payload) VALUES (1, ?, ?, ?)`).run(t.schemaVersion,t.extractorVersion,JSON.stringify(t)),n.prepare(`DELETE FROM ${gr}`).run(),n.prepare(`DELETE FROM ${Ic}`).run(),n.prepare(`DELETE FROM ${Rc}`).run();let r=n.prepare(`INSERT INTO ${gr}
|
|
459
|
+
(id, protocol, action, role, strength, source_scope, resolution, file, start_line, end_line, owner_symbol, payload)
|
|
460
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);for(let s of t.observations)r.run(s.id,s.protocol,s.action,s.role,s.strength,s.sourceScope,s.resolution,s.source.file,s.source.startLine,s.source.endLine,s.owner.symbol,JSON.stringify(s));let i=n.prepare(`INSERT INTO ${Rc} (id, protocol, join_rule, normalized_key, payload) VALUES (?, ?, ?, ?, ?)`),o=n.prepare(`INSERT INTO ${Ic} (group_id, observation_id, participant_role) VALUES (?, ?, ?)`);for(let s of t.relationGroups){i.run(s.id,s.protocol,s.joinRule,s.normalizedKey,JSON.stringify(s));for(let a of s.producerIds)o.run(s.id,a,"producer");for(let a of s.consumerIds)o.run(s.id,a,"consumer");for(let a of s.declarationIds)o.run(s.id,a,"declaration")}})()}finally{n.close()}}function MW(e,t={}){if(!BW(e,gr))return tR(e)?.observations??[];let n=[],r=[];return xc(n,r,"protocol",t.protocols),xc(n,r,"action",t.actions),xc(n,r,"source_scope",t.sourceScopes),xc(n,r,"file",t.files),e.all(`SELECT payload FROM ${gr}${n.length>0?` WHERE ${n.join(" AND ")}`:""} ORDER BY file, start_line, id`,...r).flatMap(o=>$W(o.payload))}function jW(e){e.exec(`
|
|
461
|
+
CREATE TABLE IF NOT EXISTS ${gr} (
|
|
462
|
+
id TEXT PRIMARY KEY,
|
|
463
|
+
protocol TEXT NOT NULL,
|
|
464
|
+
action TEXT NOT NULL,
|
|
465
|
+
role TEXT NOT NULL,
|
|
466
|
+
strength TEXT NOT NULL,
|
|
467
|
+
source_scope TEXT NOT NULL,
|
|
468
|
+
resolution TEXT NOT NULL,
|
|
469
|
+
file TEXT NOT NULL,
|
|
470
|
+
start_line INTEGER NOT NULL,
|
|
471
|
+
end_line INTEGER NOT NULL,
|
|
472
|
+
owner_symbol TEXT,
|
|
473
|
+
payload TEXT NOT NULL
|
|
474
|
+
);
|
|
475
|
+
CREATE INDEX IF NOT EXISTS idx_runtime_observations_protocol_action_scope
|
|
476
|
+
ON ${gr}(protocol, action, source_scope);
|
|
477
|
+
CREATE INDEX IF NOT EXISTS idx_runtime_observations_file_line
|
|
478
|
+
ON ${gr}(file, start_line);
|
|
479
|
+
|
|
480
|
+
CREATE TABLE IF NOT EXISTS ${Rc} (
|
|
481
|
+
id TEXT PRIMARY KEY,
|
|
482
|
+
protocol TEXT NOT NULL,
|
|
483
|
+
join_rule TEXT NOT NULL,
|
|
484
|
+
normalized_key TEXT NOT NULL,
|
|
485
|
+
payload TEXT NOT NULL
|
|
486
|
+
);
|
|
487
|
+
CREATE INDEX IF NOT EXISTS idx_runtime_groups_protocol_key
|
|
488
|
+
ON ${Rc}(protocol, join_rule, normalized_key);
|
|
489
|
+
|
|
490
|
+
CREATE TABLE IF NOT EXISTS ${Ic} (
|
|
491
|
+
group_id TEXT NOT NULL,
|
|
492
|
+
observation_id TEXT NOT NULL,
|
|
493
|
+
participant_role TEXT NOT NULL,
|
|
494
|
+
PRIMARY KEY (group_id, observation_id, participant_role)
|
|
495
|
+
);
|
|
496
|
+
CREATE INDEX IF NOT EXISTS idx_runtime_participants_observation
|
|
497
|
+
ON ${Ic}(observation_id, participant_role);
|
|
498
|
+
`)}function BW(e,t){return!!e.get("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",t)}function xc(e,t,n,r){!r||r.length===0||(e.push(`${n} IN (${r.map(()=>"?").join(", ")})`),t.push(...r))}function $W(e){try{return[JSON.parse(e)]}catch{return[]}}function tR(e){if(!e.get("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",vc))return null;let n=e.get(`SELECT schema_version, payload FROM ${vc} WHERE singleton = 1`);if(!n||n.schema_version!==2)return null;try{let r=JSON.parse(n.payload);return r.schemaVersion===2&&Array.isArray(r.observations)&&Array.isArray(r.relationGroups)&&Array.isArray(r.links)?r:null}catch{return null}}export{ft as a,Yp as b,mi as c,gi as d,eU as e,bR as f,Q as g,mn as h,ae as i,Et as j,et as k,ve as l,re as m,An as n,fe as o,iR as p,Wt as q,H as r,z as s,_ as t,oR as u,sR as v,On as w,GW as x,VW as y,ht as z,KU as A,vi as B,uI as C,dI as D,JU as E,YU as F,gI as G,xI as H,Bf as I,XU as J,rs as K,Ae as L,as as M,qf as N,cs as O,mq as P,Hf as Q,zf as R,gq as S,yq as T,vq as U,Ht as V,Rr as W,Te as X,G as Y,Z,Ko as _,Up as $,rl as aa,ps as ba,fs as ca,il as da,Mq as ea,tl as fa,jq as ga,Bq as ha,sl as ia,zq as ja,JC as ka,Er as la,Hn as ma,zn as na,bt as oa,rE as pa,Sl as qa,iE as ra,Pr as sa,lH as ta,uH as ua,wr as va,Fe as wa,Yo as xa,nU as ya,R as za,yi as Aa,nf as Ba,rU as Ca,mt as Da,iU as Ea,Xo as Fa,sU as Ga,hi as Ha,Ct as Ia,pU as Ja,rf as Ka,CR as La,fU as Ma,Ut as Na,sf as Oa,U as Pa,ie as Qa,oe as Ra,pn as Sa,jR as Ta,$ as Ua,Se as Va,qt as Wa,EU as Xa,PU as Ya,wU as Za,FU as _a,TU as $a,NU as ab,Re as bb,Fm as cb,Jm as db,cP as eb,Nr as fb,Oe as gb,rz as hb,bn as ib,rt as jb,fn as kb,Tf as lb,Nf as mb,Lf as nb,ZR as ob,MU as pb,se as qb,_f as rb,ts as sb,ge as tb,Om as ub,ee as vb,L as wb,TH as xb,zt as yb,OE as zb,NH as Ab,LH as Bb,Ce as Cb,Ol as Db,lz as Eb,uz as Fb,Ml as Gb,B as Hb,it as Ib,Ft as Jb,Ne as Kb,ew as Lb,jl as Mb,ot as Nb,st as Ob,gn as Pb,bz as Qb,xz as Rb,D as Sb,jr as Tb,Bz as Ub,Lg as Vb,J as Wb,Zl as Xb,vF as Yb,RF as Zb,tu as _b,Br as $b,VH as ac,zm as bc,Ue as cc,WH as dc,n2 as ec,ZT as fc,zs as gc,kJ as hc,Lt as ic,vt as jc,Ks as kc,Ty as lc,UJ as mc,Ly as nc,Ur as oc,ZJ as pc,eY as qc,tY as rc,GL as sc,nY as tc,Ys as uc,Ke as vc,Le as wc,In as xc,Y as yc,iY as zc,oY as Ac,nr as Bc,zi as Cc,qr as Dc,My as Ec,sY as Fc,aY as Gc,cY as Hc,lY as Ic,l_ as Jc,hu as Kc,Su as Lc,Ki as Mc,jY as Nc,k as Oc,Xs as Pc,L_ as Qc,BY as Rc,$Y as Sc,GY as Tc,Hr as Uc,VY as Vc,J3 as Wc,Y3 as Xc,Ax as Yc,oD as Zc,Ji as _c,ZY as $c,aX as ad,uD as bd,cX as cd,lX as dd,Dt as ed,tn as fd,ir as gd,ta as hd,wu as id,UX as jd,qX as kd,HX as ld,ra as md,Pu as nd,dh as od,Qi as pd,Fu as qd,yh as rd,Sh as sd,bh as td,Tu as ud,GX as vd,JD as wd,YD as xd,VX as yd,ZD as zd,eQ as Ad,Lu as Bd,Rh as Cd,sQ as Dd,aQ as Ed,Ih as Fd,Eh as Gd,dQ as Hd,_u as Id,pQ as Jd,eo as Kd,ku as Ld,M as Md,fa as Nd,oo as Od,Ot as Pd,Mt as Qd,Uh as Rd,I6 as Sd,wA as Td,C6 as Ud,E6 as Vd,qh as Wd,LA as Xd,G6 as Yd,V6 as Zd,DA as _d,Jh as $d,zh as ae,K6 as be,Zh as ce,J6 as de,eS as ee,a5 as fe,hO as ge,Yu as he,c5 as ie,bO as je,xO as ke,l5 as le,u5 as me,d5 as ne,or as oe,nn as pe,Ye as qe,rn as re,on as se,x5 as te,Ox as ue,Q3 as ve,Zu as we,Sa as xe,Pn as ye,Xe as ze,sp as Ae,Gt as Be,l9 as Ce,ec as De,u9 as Ee,qx as Fe,d9 as Ge,p9 as He,f9 as Ie,hG as Je,m9 as Ke,g9 as Le,ko as Me,Px as Ne,ed as Oe,W5 as Pe,U5 as Qe,q5 as Re,H5 as Se,ue as Te,aM as Ue,xa as Ve,dM as We,pM as Xe,yM as Ye,i4 as Ze,o4 as _e,s4 as $e,a4 as af,S4 as bf,po as cf,L4 as df,_4 as ef,D4 as ff,k4 as gf,A4 as hf,Ea as if,kS as jf,Pa as kf,wa as lf,Fa as mf,ei as nf,KM as of,BS as pf,sn as qf,$S as rf,JS as sf,wn as tf,a8 as uf,_a as vf,$e as wf,dc as xf,Ip as yf,jo as zf,ui as Af,oW as Bf,OW as Cf,MW as Df,tR as Ef,m8 as Ff,y8 as Gf,h8 as Hf,I8 as If,ka as Jf,D8 as Kf,sb as Lf,X8 as Mf,Q8 as Nf,Z8 as Of,eZ as Pf,_e as Qf,bo as Rf,Oa as Sf,FB as Tf,fZ as Uf,mZ as Vf,Rb as Wf,gZ as Xf,Ib as Yf,pt as Zf,PZ as _f,OZ as $f,MZ as ag,jZ as bg,XZ as cg,Vd as dg,zb as eg,QZ as fg,ZZ as gg,Ua as hg,Ya as ig,L3 as jg,dx as kg,_3 as lg,ln as mg,px as ng,fx as og,Ka as pg,D3 as qg,k3 as rg,A3 as sg,Qd as tg,E$ as ug,Xa as vg,q3 as wg,Do as xg,H3 as yg};
|
|
499
|
+
//# sourceMappingURL=chunk-OZCJXZK6.js.map
|