scip-query 0.17.1 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/{chunk-HZVG4KID.js → chunk-2A7LUMZP.js} +2 -2
  3. package/dist/{chunk-WENI5ZDR.js → chunk-4H7T7FIM.js} +2 -2
  4. package/dist/{chunk-V7MX6YUF.js → chunk-4QBRVI7D.js} +2 -2
  5. package/dist/chunk-4XTPZ5CR.js +9 -0
  6. package/dist/chunk-6AITNECC.js +928 -0
  7. package/dist/chunk-6JSTKSZH.js +3 -0
  8. package/dist/{chunk-2DUWNJKE.js → chunk-7LERNHDG.js} +2 -2
  9. package/dist/{chunk-75H6GOND.js → chunk-7ROLM67J.js} +2 -2
  10. package/dist/{chunk-RPPV6Y4K.js → chunk-7VR5TNOI.js} +2 -2
  11. package/dist/chunk-A2GX3PYV.js +5 -0
  12. package/dist/{chunk-E5HPTSRD.js → chunk-APCXCRED.js} +2 -2
  13. package/dist/{chunk-5QSMW5IO.js → chunk-ATC4MEVA.js} +2 -2
  14. package/dist/chunk-AWYKDRYV.js +2 -0
  15. package/dist/{chunk-QYBCGCY5.js → chunk-AY44MGWS.js} +2 -2
  16. package/dist/{chunk-WT34AUWL.js → chunk-BEGHYHOQ.js} +2 -2
  17. package/dist/{chunk-JYBP5ZIR.js → chunk-BPMBOZAN.js} +2 -2
  18. package/dist/{chunk-BW4VDICR.js → chunk-C7MBQSIC.js} +2 -2
  19. package/dist/{chunk-KWQKWY6M.js → chunk-CHJ3QROR.js} +2 -2
  20. package/dist/{chunk-BBTVIIOI.js → chunk-CVWX24IY.js} +2 -2
  21. package/dist/chunk-DJI446FQ.js +18 -0
  22. package/dist/{chunk-CSMPXDYE.js → chunk-ELLPMCWA.js} +2 -2
  23. package/dist/{chunk-35DURZXI.js → chunk-FVLZB54V.js} +2 -2
  24. package/dist/{chunk-WGDIA2TU.js → chunk-G6DDSHMD.js} +2 -2
  25. package/dist/{chunk-OP5JXGDV.js → chunk-IG6X65MG.js} +2 -2
  26. package/dist/{chunk-KZ2LZBQT.js → chunk-IKMOYFUM.js} +2 -2
  27. package/dist/{chunk-G4IUQW27.js → chunk-IS7DZ7TB.js} +2 -2
  28. package/dist/{chunk-HGO3D2JD.js → chunk-J7IMQRCU.js} +2 -2
  29. package/dist/{chunk-OBPR6E5Z.js → chunk-K4XL4HOK.js} +2 -2
  30. package/dist/{chunk-W3HSUCRG.js → chunk-K53GNKY3.js} +2 -2
  31. package/dist/{chunk-5N5ZC566.js → chunk-K65T4TJS.js} +2 -2
  32. package/dist/{chunk-OC7XDK62.js → chunk-KA7RMBVU.js} +2 -2
  33. package/dist/{chunk-IKAJI4SI.js → chunk-KJOKTZUE.js} +2 -2
  34. package/dist/chunk-KSD6IWF4.js +38 -0
  35. package/dist/{chunk-SQJ72PQW.js → chunk-LEKXKHIQ.js} +4 -4
  36. package/dist/{chunk-2TM23JYJ.js → chunk-LFPQFRCX.js} +2 -2
  37. package/dist/{chunk-Y5BOEWAE.js → chunk-LL5NQB5V.js} +2 -2
  38. package/dist/{chunk-FY6RCFDH.js → chunk-MBVHEPHQ.js} +2 -2
  39. package/dist/{chunk-SSH2NPYS.js → chunk-MFIA6EIT.js} +2 -2
  40. package/dist/{chunk-HYRSGWFX.js → chunk-N3JH45WR.js} +2 -2
  41. package/dist/{chunk-KWMRY4RN.js → chunk-NJD4C5G5.js} +3 -3
  42. package/dist/{chunk-UKUISUS6.js → chunk-NJTIAQY7.js} +2 -2
  43. package/dist/{chunk-LG33DNTZ.js → chunk-NX2YAXVQ.js} +2 -2
  44. package/dist/{chunk-VDHEX6YO.js → chunk-O5A7BTMA.js} +2 -2
  45. package/dist/{chunk-FZXN37RN.js → chunk-O7NA5FCA.js} +2 -2
  46. package/dist/{chunk-U3JW5AYG.js → chunk-OINSINYW.js} +2 -2
  47. package/dist/{chunk-CKRVVBM6.js → chunk-OQFA2SUQ.js} +2 -2
  48. package/dist/{chunk-DQYG5JHT.js → chunk-OQFPCIXO.js} +2 -2
  49. package/dist/{chunk-PPAT3XUL.js → chunk-P6FOIU7O.js} +2 -2
  50. package/dist/{chunk-7H37Z4UO.js → chunk-PQD7P6WB.js} +2 -2
  51. package/dist/{chunk-Y4BBVPRK.js → chunk-Q4GKL4CC.js} +2 -2
  52. package/dist/{chunk-IZLWLO4X.js → chunk-ROMKXEUM.js} +2 -2
  53. package/dist/{chunk-BTYDBDX5.js → chunk-RUV4KHWA.js} +2 -2
  54. package/dist/{chunk-O56VBJKB.js → chunk-S22ICAWV.js} +2 -2
  55. package/dist/chunk-SALRDXWM.js +121 -0
  56. package/dist/{chunk-MON5XXTG.js → chunk-SON6DQNK.js} +2 -2
  57. package/dist/{chunk-W2I4QAW7.js → chunk-SSGACGAD.js} +2 -2
  58. package/dist/{chunk-PA2MQKXD.js → chunk-SUYCF4SX.js} +2 -2
  59. package/dist/chunk-SXDXR5FH.js +2 -0
  60. package/dist/{chunk-TR7C5HOC.js → chunk-T4P27T6S.js} +2 -2
  61. package/dist/{chunk-O27267B6.js → chunk-U4G4UYLB.js} +2 -2
  62. package/dist/{chunk-MBDBNQBW.js → chunk-W7FNZKX5.js} +2 -2
  63. package/dist/chunk-WD3PAQJT.js +10 -0
  64. package/dist/{chunk-623AZLTE.js → chunk-XLJORP6N.js} +2 -2
  65. package/dist/chunk-XTF6ELXT.js +3 -0
  66. package/dist/{chunk-7Z5UT44B.js → chunk-YMFHC5J2.js} +2 -2
  67. package/dist/{chunk-HJYHSTCP.js → chunk-YYYERNQL.js} +2 -2
  68. package/dist/chunk-Z4MCFCGX.js +3 -0
  69. package/dist/cli.js +3 -1528
  70. package/dist/command-descriptors-7UUURHWT.js +599 -0
  71. package/dist/direct-navigation-CVCFER5G.js +3 -0
  72. package/dist/index.js +1 -1
  73. package/dist/queries/affected.js +1 -1
  74. package/dist/queries/bottlenecks.js +1 -1
  75. package/dist/queries/call-graph.js +1 -1
  76. package/dist/queries/change-surface.js +1 -1
  77. package/dist/queries/cleanup-plan.js +1 -1
  78. package/dist/queries/co-change.d.ts +2 -0
  79. package/dist/queries/co-change.js +1 -1
  80. package/dist/queries/code.js +1 -1
  81. package/dist/queries/complexity-hotspots.js +1 -1
  82. package/dist/queries/complexity.js +1 -1
  83. package/dist/queries/convergence.js +1 -1
  84. package/dist/queries/coupling.js +1 -1
  85. package/dist/queries/dataflow.js +1 -1
  86. package/dist/queries/dead.js +1 -1
  87. package/dist/queries/decorative-checkers.js +1 -1
  88. package/dist/queries/deps.js +1 -1
  89. package/dist/queries/diff-gate.js +1 -1
  90. package/dist/queries/diff-impact.js +1 -1
  91. package/dist/queries/doc-drift.js +1 -1
  92. package/dist/queries/drift.js +1 -1
  93. package/dist/queries/duplicate-bodies.js +1 -1
  94. package/dist/queries/extract-candidates.js +1 -1
  95. package/dist/queries/fan.js +1 -1
  96. package/dist/queries/health.js +1 -1
  97. package/dist/queries/hierarchy.js +1 -1
  98. package/dist/queries/hotspots.js +1 -1
  99. package/dist/queries/imports.js +1 -1
  100. package/dist/queries/incomplete-migration.js +1 -1
  101. package/dist/queries/index.js +1 -1
  102. package/dist/queries/isolated.js +1 -1
  103. package/dist/queries/locality-candidates.js +1 -1
  104. package/dist/queries/members.js +1 -1
  105. package/dist/queries/methods.js +1 -1
  106. package/dist/queries/not-implemented.js +1 -1
  107. package/dist/queries/outline.js +1 -1
  108. package/dist/queries/passthrough-candidates.js +1 -1
  109. package/dist/queries/plan-context.d.ts +2 -0
  110. package/dist/queries/plan-context.js +1 -1
  111. package/dist/queries/recent-duplicates.js +1 -1
  112. package/dist/queries/redundant-reexports.js +1 -1
  113. package/dist/queries/refs.js +1 -1
  114. package/dist/queries/self-audit.js +1 -1
  115. package/dist/queries/similar-signatures.js +1 -1
  116. package/dist/queries/similar.js +1 -1
  117. package/dist/queries/slice.js +1 -1
  118. package/dist/queries/stale-abstractions.js +1 -1
  119. package/dist/queries/surface.js +1 -1
  120. package/dist/queries/symbols.js +1 -1
  121. package/dist/queries/system.js +1 -1
  122. package/dist/queries/test-quality.js +1 -1
  123. package/dist/queries/trace.js +1 -1
  124. package/dist/queries/twin-ab.js +1 -1
  125. package/dist/queries/twin-drift.js +1 -1
  126. package/dist/queries/unused-imports.js +1 -1
  127. package/dist/queries/unused-params.js +1 -1
  128. package/dist/queries/wrapper-candidates.js +1 -1
  129. package/dist/reindex-worker.js +1 -1
  130. package/dist/reindex.js +1 -1
  131. package/dist/runtime.js +1 -1
  132. package/dist/watch-server.js +4 -4
  133. package/docs/COMMAND_REFERENCE.md +3 -0
  134. package/package.json +1 -1
  135. package/dist/chunk-2HCWAL42.js +0 -3
  136. package/dist/chunk-3YEBIYXL.js +0 -38
  137. package/dist/chunk-6TJERPN3.js +0 -2
  138. package/dist/chunk-E7BTIEAY.js +0 -2
  139. package/dist/chunk-EUMETOTD.js +0 -21
  140. package/dist/chunk-GRHA5NGF.js +0 -2
  141. package/dist/chunk-IHD2CHMX.js +0 -10
  142. package/dist/chunk-U267E6YN.js +0 -120
  143. package/dist/chunk-X566NT42.js +0 -9
@@ -1,120 +0,0 @@
1
- import{a as Rn,b as x,c as ft,d as Nn,e as Ce,f as _n,g as Dn}from"./chunk-SMBIGBGN.js";import{a as B,b as P}from"./chunk-3M2UCPFS.js";import{a as tr,b as rr,e as nr}from"./chunk-JHK2DMUQ.js";import{spawn as _s}from"child_process";import{closeSync as Ds,existsSync as As,mkdirSync as js,openSync as Fs,readFileSync as lr,rmSync as Me,writeFileSync as Os}from"fs";import{dirname as Ls,join as sr,resolve as pr}from"path";import{fileURLToPath as ef}from"url";import{spawnSync as xs}from"child_process";import{createHash as vs}from"crypto";import{existsSync as Is,lstatSync as Es,realpathSync as ws}from"fs";import{dirname as Cs,isAbsolute as ks,join as Ts,resolve as mt}from"path";var gt={run(e,t){let r=An(e,t);return r.kind==="success"?r.output:void 0},runResult:An};function jn(e,t=gt){let r=or(e,t);if(r.kind!=="worktree")return;let n=r.identity,i=n.projectRoot,o=t.run(i,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=ke(Fn(i,o)),a=ir(t.run(i,["rev-parse","--verify","HEAD"])),c=ir(t.run(i,["rev-parse","--verify","HEAD^{tree}"])),l=t.run(i,["status","--porcelain=v1","-z","--untracked-files=all"]);if(l!==void 0)return{...n,commonDir:s,repositoryId:On("repository",s),headCommit:a,treeOid:c,clean:l.length===0}}function or(e,t=gt){let r=t.runResult(e,["rev-parse","--show-toplevel"]);if(r.kind==="not-repository")return{kind:"non-git"};if(r.kind==="error")return r;let n=r.output.trim();if(!n)return{kind:"error",message:"Git returned an empty worktree root."};let i=ke(n),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=ke(Fn(i,o));return{kind:"worktree",identity:{projectRoot:i,gitDir:s,worktreeId:On("worktree",`${i}\0${s}`)}}}function Ps(e,t=gt){let r=t.run(e,["worktree","list","--porcelain","-z"]);return r===void 0?[]:Rs(r)}function Rs(e){let t=[],r;for(let n of e.split("\0")){if(n===""){r&&t.push(r),r=void 0;continue}let i=n.indexOf(" "),o=i<0?n:n.slice(0,i),s=i<0?"":n.slice(i+1);if(o==="worktree"){r&&t.push(r),r={path:ke(s),detached:!1,bare:!1,prunable:!1,locked:!1};continue}r&&(o==="HEAD"?r.head=s:o==="branch"?r.branch=s:o==="detached"?r.detached=!0:o==="bare"?r.bare=!0:o==="prunable"?r.prunable=!0:o==="locked"&&(r.locked=!0))}return r&&t.push(r),t}function Jd(e,t,r=gt){return ir(r.run(e,t))}function Fn(e,t){return ks(t)?t:mt(e,t)}function ke(e){try{return ws(e)}catch{return mt(e)}}function On(e,t){return vs("sha256").update(`${e}\0${t}`).digest("hex").slice(0,24)}function ir(e){return e?.trim()||void 0}function An(e,t){let r=xs("git",["-C",e,...t],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"]});if(r.status===0)return{kind:"success",output:r.stdout.trimEnd()};let i=(typeof r.stderr=="string"?r.stderr.trim():"")||r.error?.message||`git exited with status ${r.status??"unknown"}`,o=r.error?.code;return(/not a git repository/i.test(i)||o==="ENOENT"&&Is(mt(e)))&&!Ns(e)?{kind:"not-repository"}:{kind:"error",message:i}}function Ns(e){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let t=mt(e);for(;;){try{return Es(Ts(t,".git")),!0}catch(n){let i=n.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let r=Cs(t);if(r===t)return!1;t=r}}var of=4,sf=5e3,Ms="watch.lock",$s="watch-state.json",Ws="watch-activity.json";var Gs=2e3,Us=10;function Vs(e){return{lockPath:sr(e,Ms),statePath:sr(e,$s),activityPath:sr(e,Ws)}}function af(e,t){let r=ke(pr(e)),n=or(r);if(n.kind==="error")throw new Error(`Could not establish Git worktree identity for ${r}: ${n.message}`);return n.kind==="non-git"?{projectRoot:r,worktreeKind:"non-git",cliVersion:t}:{projectRoot:r,worktreeKind:"git",worktreeId:n.identity.worktreeId,cliVersion:t}}function cf(e){let t=e.runtime??Js,r=Vs(e.cacheDir),n=Bs(r.statePath),i=n?t.isProcessAlive(n.pid)?{kind:"live",state:n}:{kind:"stale",state:n,reason:"dead-process"}:{kind:"stopped"},o=qs("stop",i);if(o.kind==="signal-stop")return Ln(o.state.pid,e,t),ar(r,o.state.pid,t),{disposition:"stopped",pid:o.state.pid};if(o.kind==="clean-stale")return ar(r,o.state.pid,t),{disposition:"stopped",pid:o.state.pid};let s=$e(r.lockPath);return o.kind==="already-stopped"&&s&&t.isProcessAlive(s.pid)?(Ln(s.pid,e,t),ar(r,s.pid,t),{disposition:"stopped",pid:s.pid}):{disposition:"already-stopped"}}function Bs(e){try{return Hs(JSON.parse(lr(e,"utf8")))}catch{return null}}function lf(e,t){P(e,t)}function pf(e){try{let t=JSON.parse(lr(e,"utf8"));return t.version!==1||!I(t.at)||t.refreshRequestedAt!==void 0&&!I(t.refreshRequestedAt)||t.refreshDetail!==void 0&&typeof t.refreshDetail!="string"?null:{atMs:Date.parse(t.at),...t.refreshRequestedAt===void 0?{}:{refreshRequestedAtMs:Date.parse(t.refreshRequestedAt)},...t.refreshDetail===void 0?{}:{refreshDetail:t.refreshDetail}}}catch{return null}}function uf(e,t,r={}){let n=r.pid??process.pid,i=r.isProcessAlive??B,o=()=>{},s=$e(e);if(s&&i(s.pid))return{acquired:!1,lockPath:e,message:Mn(e,t,s),release:o};s&&Me(e,{force:!0}),js(Ls(e),{recursive:!0});let a;try{a=Fs(e,"wx")}catch(p){if(zs(p)==="EEXIST")return{acquired:!1,lockPath:e,message:Mn(e,t,$e(e)),release:o};throw p}let c={version:1,pid:n,projectRoot:pr(t),startedAt:(r.now??(()=>new Date))().toISOString()};Os(a,`${JSON.stringify(c)}
2
- `);let l=!1;return{acquired:!0,lockPath:e,message:"",release:()=>{if(l)return;l=!0,Ds(a);let p=$e(e);p?.pid===c.pid&&p.startedAt===c.startedAt&&Me(e,{force:!0})}}}function $e(e){try{let t=JSON.parse(lr(e,"utf-8"));return t.version!==1||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||!I(t.startedAt)?null:t}catch{return null}}function Hs(e){if(!e||typeof e!="object")return null;let t=e;return t.version!==1||typeof t.protocolVersion!="number"||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||t.worktreeId!==void 0&&(typeof t.worktreeId!="string"||t.worktreeId.length===0)||typeof t.cliVersion!="string"||!I(t.startedAt)||!I(t.heartbeatAt)||!I(t.lastActivityAt)||!Ks(t.watcher)||t.idleDeadlineAt!==void 0&&!I(t.idleDeadlineAt)||t.lastError!==void 0&&!Ys(t.lastError)||t.lastRefresh!==void 0&&!Xs(t.lastRefresh)||t.typescriptSemantic!==void 0&&!Qs(t.typescriptSemantic)||t.typescriptIndex!==void 0&&!Zs(t.typescriptIndex)?null:t}function qs(e,t){switch(e){case"status":return{kind:"report",classification:t};case"ensure":switch(t.kind){case"stopped":return{kind:"start"};case"stale":return t.reason==="old-heartbeat"?{kind:"replace",state:t.state}:{kind:"start"};case"live":return{kind:"reuse",state:t.state};case"incompatible":return{kind:"replace",state:t.state};default:return cr(t)}case"stop":switch(t.kind){case"stopped":return{kind:"already-stopped"};case"stale":return t.reason==="old-heartbeat"?{kind:"signal-stop",state:t.state}:{kind:"clean-stale",state:t.state};case"live":case"incompatible":return{kind:"signal-stop",state:t.state};default:return cr(t)}default:return cr(e)}}function df(e){return e.idleTimeoutMs===0||e.watcher.state!=="idle"?!1:e.nowMs-e.lastActivityAtMs>=e.idleTimeoutMs}function Ln(e,t,r){if(!r.isProcessAlive(e))return;r.signalProcess(e);let n=t.stopTimeoutMs??Gs,i=r.now()+n;for(;r.now()<=i;){if(!r.isProcessAlive(e))return;r.sleep(Us)}throw new Error(`scip-query watch service pid ${e} did not stop within ${n}ms.`)}function ar(e,t,r){Me(e.statePath,{force:!0}),Me(e.activityPath,{force:!0}),$e(e.lockPath)?.pid===t&&!r.isProcessAlive(t)&&Me(e.lockPath,{force:!0})}function Mn(e,t,r){return`error: scip-query watch is already running for ${pr(t)}${r?` (pid ${r.pid}, started ${r.startedAt}; lock: ${e})`:` (lock: ${e})`}. Stop that watcher before starting another.`}function zs(e){return typeof e=="object"&&e&&"code"in e?e.code:void 0}var Js={now:Date.now,isProcessAlive:B,spawnServer(e,t,r,n){if(!As(e))throw new Error(`Watch service helper was not found at ${e}. Run npm run build first.`);_s(process.execPath,[e,t,r,JSON.stringify(n)],{detached:!0,stdio:"ignore",env:{...process.env,SCIP_QUERY_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(e){process.kill(e,"SIGTERM")},sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)}};function I(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function Ks(e){if(!e||typeof e!="object"||!("state"in e))return!1;let t=e;switch(t.state){case"idle":return!0;case"waiting":return A(t.changedFiles)&&A(t.reindexAt);case"indexing":return A(t.startedAt);case"cooldown":return A(t.until)&&typeof t.dirty=="boolean";default:return!1}}function Ys(e){if(!e||typeof e!="object")return!1;let t=e;return I(t.at)&&typeof t.message=="string"}function Xs(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.trigger?.kind=="string"&&typeof t.result=="string"&&I(t.startedAt)&&I(t.completedAt)&&A(t.durationMs)}function Qs(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.protocolVersion=="number"&&(t.state==="idle"||t.state==="ready"||t.state==="unavailable"||t.state==="error")&&A(t.requests)&&A(t.sessionsCreated)&&A(t.sessionsReused)&&A(t.sessionsRefreshed)&&A(t.sessionsReplaced)&&A(t.projectsCreated)&&(t.lastRequestAt===void 0||I(t.lastRequestAt))&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||I(t.busyUntil))}function Zs(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.protocolVersion=="number"&&(t.state==="idle"||t.state==="ready"||t.state==="unavailable"||t.state==="error")&&le(t.requests)&&le(t.sessionsCreated)&&le(t.sessionsReplaced)&&le(t.initializations)&&le(t.programUpdates)&&le(t.documentsEmitted)&&le(t.documentsRemoved)&&(t.lastRequestAt===void 0||I(t.lastRequestAt))&&(t.lastDurationMs===void 0||A(t.lastDurationMs)&&t.lastDurationMs>=0)&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||I(t.busyUntil))}function A(e){return typeof e=="number"&&Number.isFinite(e)}function le(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}function cr(e){throw new Error(`Unhandled watch service value: ${JSON.stringify(e)}`)}import{readFileSync as ea,writeFileSync as gf,existsSync as ta,mkdirSync as ra,realpathSync as na}from"fs";import{isAbsolute as yf,join as X,relative as Sf,resolve as $n}from"path";import{createHash as ia}from"crypto";import{homedir as oa}from"os";var ur=".scipquery.json",sa=250,aa=0,ca=10*6e4,la={enabled:!1,debounceMs:sa,cooldownMs:aa,gitPollMs:2e3,idleTimeoutMs:ca,autoRefresh:!0,ignore:[]},pa=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var vf=new Set(pa);function If(e){let t=X(e,ur);if(!ta(t))return{};try{let r=ea(t,"utf-8");return JSON.parse(r)}catch(r){let n=r instanceof Error?r.message:String(r);throw r instanceof SyntaxError?new Error(`invalid ${ur} at ${t}: ${n}`,{cause:r}):new Error(`unable to read ${ur} at ${t}: ${n}`,{cause:r})}}function Ef(e){return{...la,...e.watch}}function ua(e,t){let r=process.env.SCIP_QUERY_CACHE_DIR;if(r)return dr(r);if(t?.dbPath)return dr($n(e,t.dbPath));let n=fr(e);return dr(n)}function Wn(){let e=process.env.XDG_CACHE_HOME;return X(e||X(oa(),".cache"),"scip-query")}function fr(e){let t=$n(e);try{t=na(t)}catch{}let r=ia("sha256").update(t).digest("hex").slice(0,12);return X(Wn(),"projects",r)}function mr(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);return X(Wn(),"repositories",e)}function gr(e){return process.env.SCIP_QUERY_SHARED_CACHE!=="0"&&!process.env.SCIP_QUERY_CACHE_DIR&&!process.env.SCIP_QUERY_INDEX_DB&&!e?.dbPath}function wf(e,t){let r=ua(e,t);return{cacheDir:r,dbPath:X(r,"index.db"),indexPath:X(r,"index.scip"),metaPath:X(r,"meta.json")}}function dr(e){return ra(e,{recursive:!0}),e}import{createHash as da}from"crypto";import{readFileSync as fa}from"fs";import{dirname as ma,join as ht}from"path";var ga=2,ha="typescript-index";function Rf(e){let t=ht(e,ha);return{rootDir:t,requestDir:ht(t,"requests"),responseDir:ht(t,"responses")}}function Nf(e){let t=JSON.parse(e);if(t.protocolVersion!==ga||typeof t.id!="string"||!t.id||typeof t.baseGeneration!="string"||!t.baseGeneration||typeof t.deadlineAtMs!="number"||!Number.isFinite(t.deadlineAtMs)||!ya(t.request))throw new Error("TypeScript index service received an invalid mailbox request.");return t}function _f(e){try{let t=JSON.parse(fa(ht(ma(e),"meta.json"),"utf8"));return t.version!==2&&t.version!==3||t.status!=="complete"||typeof t.updatedAt!="string"||t.fingerprint===void 0?null:da("sha256").update(JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages})).digest("hex")}catch{return null}}function ya(e){if(!e||typeof e!="object")return!1;let t=e,r=Gn(t.modifiedFiles)?t.modifiedFiles:null,n=Gn(t.affectedFiles)?t.affectedFiles:null;return t.kind==="emit-documents"&&typeof t.tsconfigPath=="string"&&!!t.tsconfigPath&&typeof t.projectArgument=="string"&&!!t.projectArgument&&typeof t.projectIdentity=="string"&&!!t.projectIdentity&&typeof t.producerIdentity=="string"&&!!t.producerIdentity&&r!==null&&r.length>0&&new Set(r).size===r.length&&n!==null&&n.length>0&&new Set(n).size===n.length&&r.every(i=>n.includes(i))}function Gn(e){return Array.isArray(e)&&e.every(t=>typeof t=="string"&&t.length>0)}import{randomUUID as Un}from"crypto";import{closeSync as Vn,mkdirSync as Sa,openSync as Bn,readFileSync as Hn,unlinkSync as qn,writeFileSync as zn}from"fs";import{dirname as ba,join as xa}from"path";function Jn(e,t={}){return hr(xa(e,"gc.lock"),t)}function hr(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??Date.now,o=Date.now()+r;Sa(ba(e),{recursive:!0});do{let s=Un();try{let a=Bn(e,"wx");try{let c={version:1,pid:process.pid,token:s,startedAt:new Date(i()).toISOString()};zn(a,`${JSON.stringify(c)}
3
- `)}finally{Vn(a)}return{release:()=>Yn(e,s)}}catch(a){if(a.code!=="EEXIST")return null;let c=Kn(e);if(c&&(c.pid===void 0||!B(c.pid))){va(e,c);continue}if(Date.now()>=o)return null;Ia(Math.min(n,Math.max(1,o-Date.now())))}}while(Date.now()<=o);return null}function Kn(e){try{let t=Hn(e,"utf8"),r=JSON.parse(t),n=typeof r.pid=="number"&&Number.isSafeInteger(r.pid)&&r.pid>0?r.pid:void 0;return{raw:t,...n===void 0?{}:{pid:n}}}catch{return null}}function va(e,t){let r=`${e}.reclaim`,n=Un(),i;try{i=Bn(r,"wx")}catch{return!1}try{zn(i,`${JSON.stringify({version:1,pid:process.pid,token:n,startedAt:new Date().toISOString()})}
4
- `)}finally{Vn(i)}try{let o=Kn(e);return!o||o.raw!==t.raw||o.pid!==void 0&&B(o.pid)?!1:(qn(e),!0)}catch{return!1}finally{Yn(r,n)}}function Yn(e,t){try{let r=JSON.parse(Hn(e,"utf8"));r.pid===process.pid&&r.token===t&&qn(e)}catch{}}function Ia(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}import Ea from"better-sqlite3";var wa=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".scipquery-cache","__pycache__",".venv","venv"],Xn=class{db;config;pathFilter;statementCache=new Map;constructor(t,r){this.config=t,this.pathFilter=r??null,this.db=new Ea(t.dbPath,{readonly:!0}),this.db.pragma("busy_timeout = 5000"),this.db.pragma("query_only = ON"),this.db.pragma("temp_store = MEMORY"),this.db.pragma("cache_size = -64000"),this.db.pragma("mmap_size = 268435456")}isIgnored(t){return this.pathFilter?.isIgnored(t)??!1}get localSymbolPredicate(){return`(
5
- EXISTS (
6
- SELECT 1
7
- FROM defn_enclosing_ranges local_der
8
- JOIN documents local_d ON local_der.document_id = local_d.id
9
- WHERE local_der.symbol_id = gs.id
10
- ${this.pathExclusionsFor("local_d").trimStart()}
11
- )
12
- OR EXISTS (
13
- SELECT 1
14
- FROM mentions local_m
15
- JOIN chunks local_c ON local_m.chunk_id = local_c.id
16
- JOIN documents local_d ON local_c.document_id = local_d.id
17
- WHERE local_m.symbol_id = gs.id
18
- AND local_m.role = 1
19
- ${this.pathExclusionsFor("local_d").trimStart()}
20
- )
21
- )`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(r=>wa.flatMap(n=>[`AND ${r}.relative_path NOT LIKE '${n}/%'`,`AND ${r}.relative_path NOT LIKE '%/${n}/%'`])).join(`
22
- `)}symbolNoiseFor(t){return`AND ${t}.symbol NOT LIKE '%().(%' AND ${t}.symbol NOT LIKE '%typeLiteral%'`}all(t,...r){return this.statement(t).all(...r)}get(t,...r){return this.statement(t).get(...r)}close(){this.statementCache.clear(),this.db.close()}statement(t){let r=this.statementCache.get(t);return r||(r=this.db.prepare(t),this.statementCache.set(t,r)),r}};import{createHash as Ca}from"crypto";import{existsSync as ka,mkdirSync as Ta,readFileSync as Pa}from"fs";import{dirname as yr,join as Qn}from"path";import Sr from"better-sqlite3";var Ra="evidence.db";var Na=["source-facts","definition-exclusions","doc-path-tokens","react-component-behavior-profiles"],br=new Set(Na),_a=25e4,Da=512*1024*1024;var yt=new WeakMap,Aa=x("evidence-content-hash",{clearGroups:["whole-project","source-file"]}),ja=x("evidence-project-fingerprint",{clearGroups:["whole-project"]}),Q="evidence-v1",Te="version NOT LIKE 'evidence-%'";function St(e){return Ca("sha256").update(e).digest("hex")}function We(e,t,r){return Aa.get(e,t,()=>St(r))}function Zn(e){return ja.get(e,"current",()=>{try{let t=JSON.parse(Pa(Qn(yr(e.config.dbPath),"meta.json"),"utf-8"));if(t.version!==2&&t.version!==3||t.status!=="complete"&&t.status!=="partial"||t.fingerprint===void 0)return null;let r=Array.isArray(t.indexedLanguages)?[...t.indexedLanguages].sort():[];return St(JSON.stringify({fingerprint:t.fingerprint,indexedLanguages:r,status:t.status}))}catch(t){return Pe("project fingerprint unavailable",t),null}})}function Pe(e,t){process.env.SCIP_QUERY_DEBUG&&console.error(`evidence-cache: ${e}: ${t instanceof Error?t.message:String(t)}`)}function Ge(e){if(yt.has(e))return yt.get(e)??null;let t=null;try{let r=new Sr(Qn(yr(e.config.dbPath),Ra));r.pragma("journal_mode = WAL"),r.pragma("busy_timeout = 5000"),r.pragma("synchronous = NORMAL"),r.exec(`
23
- CREATE TABLE IF NOT EXISTS file_evidence (
24
- kind TEXT NOT NULL,
25
- relative_path TEXT NOT NULL,
26
- content_hash TEXT NOT NULL,
27
- version TEXT NOT NULL,
28
- payload TEXT NOT NULL,
29
- PRIMARY KEY (kind, relative_path)
30
- );
31
- CREATE TABLE IF NOT EXISTS project_evidence (
32
- kind TEXT NOT NULL,
33
- cache_key TEXT NOT NULL,
34
- project_fingerprint TEXT NOT NULL,
35
- version TEXT NOT NULL,
36
- payload TEXT NOT NULL,
37
- PRIMARY KEY (kind, cache_key)
38
- );
39
- CREATE TABLE IF NOT EXISTS semantic_callees (
40
- relative_path TEXT NOT NULL,
41
- symbol TEXT NOT NULL,
42
- content_hash TEXT NOT NULL,
43
- deps_digest TEXT NOT NULL,
44
- version TEXT NOT NULL,
45
- payload TEXT NOT NULL,
46
- PRIMARY KEY (relative_path, symbol)
47
- );
48
- CREATE TABLE IF NOT EXISTS semantic_references (
49
- relative_path TEXT NOT NULL,
50
- symbol TEXT NOT NULL,
51
- project_fingerprint TEXT NOT NULL,
52
- version TEXT NOT NULL,
53
- payload TEXT NOT NULL,
54
- PRIMARY KEY (relative_path, symbol)
55
- );
56
- CREATE TABLE IF NOT EXISTS finding_outcome_ledger (
57
- check_name TEXT NOT NULL,
58
- finding_id TEXT NOT NULL,
59
- first_seen INTEGER NOT NULL,
60
- last_seen INTEGER NOT NULL,
61
- times_shown INTEGER NOT NULL,
62
- outcome TEXT NOT NULL,
63
- PRIMARY KEY (check_name, finding_id)
64
- );
65
- `),t={evidence:r,shared:Fa(e.config.sharedEvidenceDbPath),readFileEvidence:r.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),readLegacyFileEvidence:r.prepare(`SELECT payload FROM file_evidence
66
- WHERE kind = ? AND relative_path = ? AND content_hash = ? AND ${Te}
67
- ORDER BY version DESC
68
- LIMIT 1`),writeFileEvidence:r.prepare("INSERT OR REPLACE INTO file_evidence (kind, relative_path, content_hash, version, payload) VALUES (?, ?, ?, ?, ?)"),readProjectEvidence:r.prepare("SELECT payload FROM project_evidence WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND version = ?"),readLegacyProjectEvidence:r.prepare(`SELECT payload FROM project_evidence
69
- WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND ${Te}
70
- ORDER BY version DESC
71
- LIMIT 1`),writeProjectEvidence:r.prepare("INSERT OR REPLACE INTO project_evidence (kind, cache_key, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)"),readCallees:r.prepare(`SELECT payload FROM semantic_callees
72
- WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCallees:r.prepare(`SELECT payload FROM semantic_callees
73
- WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND ${Te}
74
- ORDER BY version DESC
75
- LIMIT 1`),readCalleesForFile:r.prepare(`SELECT symbol, payload FROM semantic_callees
76
- WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCalleesForFile:r.prepare(`SELECT symbol, payload FROM semantic_callees
77
- WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND ${Te}
78
- ORDER BY symbol, version DESC`),writeCallees:r.prepare(`INSERT OR REPLACE INTO semantic_callees
79
- (relative_path, symbol, content_hash, deps_digest, version, payload) VALUES (?, ?, ?, ?, ?, ?)`),dropStaleCallees:r.prepare("DELETE FROM semantic_callees WHERE relative_path = ? AND content_hash != ?"),readReferences:r.prepare(`SELECT payload FROM semantic_references
80
- WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferences:r.prepare(`SELECT payload FROM semantic_references
81
- WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND ${Te}
82
- ORDER BY version DESC
83
- LIMIT 1`),readReferencesForFile:r.prepare(`SELECT symbol, payload FROM semantic_references
84
- WHERE relative_path = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferencesForFile:r.prepare(`SELECT symbol, payload FROM semantic_references
85
- WHERE relative_path = ? AND project_fingerprint = ? AND ${Te}
86
- ORDER BY symbol, version DESC`),writeReferences:r.prepare(`INSERT OR REPLACE INTO semantic_references
87
- (relative_path, symbol, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)`),dropStaleReferences:r.prepare("DELETE FROM semantic_references WHERE relative_path = ? AND project_fingerprint != ?"),readFindingOutcomeLedger:r.prepare("SELECT check_name, finding_id, first_seen, last_seen, times_shown, outcome FROM finding_outcome_ledger"),deleteFindingOutcomeLedgerForCheck:r.prepare("DELETE FROM finding_outcome_ledger WHERE check_name = ?"),writeFindingOutcomeLedgerRow:r.prepare(`INSERT INTO finding_outcome_ledger
88
- (check_name, finding_id, first_seen, last_seen, times_shown, outcome) VALUES (?, ?, ?, ?, ?, ?)`)}}catch(r){Pe("disabled (open failed)",r)}return yt.set(e,t),t}function Ue(e,t,r){Pe(`disabled (${t})`,r),yt.set(e,null)}function Fa(e){if(!e)return null;try{Ta(yr(e),{recursive:!0});let t=new Sr(e);return t.pragma("journal_mode = WAL"),t.pragma("busy_timeout = 250"),t.pragma("synchronous = NORMAL"),t.exec(`
89
- CREATE TABLE IF NOT EXISTS file_evidence (
90
- kind TEXT NOT NULL,
91
- relative_path TEXT NOT NULL,
92
- content_hash TEXT NOT NULL,
93
- version TEXT NOT NULL,
94
- payload TEXT NOT NULL,
95
- last_accessed_at INTEGER NOT NULL,
96
- PRIMARY KEY (kind, relative_path, content_hash, version)
97
- );
98
- `),{evidence:t,readFileEvidence:t.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),writeFileEvidence:t.prepare(`INSERT INTO file_evidence (kind, relative_path, content_hash, version, payload, last_accessed_at)
99
- VALUES (?, ?, ?, ?, ?, ?)
100
- ON CONFLICT(kind, relative_path, content_hash, version)
101
- DO UPDATE SET payload = excluded.payload, last_accessed_at = excluded.last_accessed_at`)}}catch(t){return Pe("shared cache disabled (open failed)",t),null}}function xr(e,t,r){Pe(`shared cache disabled (${t})`,r);try{e.shared?.evidence.close()}catch{}e.shared=null}function Hf(e,t={}){if(!ka(e))return null;let r;try{r=new Sr(e),r.pragma("busy_timeout = 50"),r.pragma("wal_checkpoint(TRUNCATE)");let n=r.prepare("SELECT COUNT(*) AS count FROM file_evidence").get().count,i=t.maxRows??_a,o=t.budgetBytes??Da,s=Number(r.pragma("page_size",{simple:!0})),a=Number(r.pragma("page_count",{simple:!0})),c=Number(r.pragma("freelist_count",{simple:!0})),l=Math.max(0,a-c)*s,p=n>0&&l>o?Math.min(n,Math.ceil((l-o)/Math.max(1,l/n))):0,u=Math.max(n-i,p);return u>0&&(r.prepare(`DELETE FROM file_evidence WHERE rowid IN (
102
- SELECT rowid FROM file_evidence ORDER BY last_accessed_at ASC, rowid ASC LIMIT ?
103
- )`).run(u),r.pragma("wal_checkpoint(TRUNCATE)")),{deletedRows:u,remainingRows:n-u}}catch(n){return Pe("shared cache maintenance skipped",n),null}finally{try{r?.close()}catch{}}}function ei(e,t,r,n){let i=Ge(e);if(!i)return null;try{let o=i.readFileEvidence.get(t,r,n,Q)??i.readLegacyFileEvidence.get(t,r,n);if(o?.payload!==void 0)return o.payload;if(!br.has(t)||!i.shared)return null;try{return i.shared.readFileEvidence.get(t,r,n,Q)?.payload??null}catch(s){return xr(i,"file_evidence read",s),null}}catch(o){return Ue(e,"file_evidence read",o),null}}function ti(e,t,r,n,i){let o=Ge(e);if(o)try{if(o.writeFileEvidence.run(t,r,n,Q,i),br.has(t)&&o.shared)try{o.shared.writeFileEvidence.run(t,r,n,Q,i,Date.now())}catch(s){xr(o,"file_evidence write",s)}}catch(s){Ue(e,"file_evidence write",s)}}function ri(e,t){if(t.length===0)return;let r=Ge(e);if(r)try{r.evidence.transaction(()=>{for(let i of t)r.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,Q,i.payload)})();let n=t.filter(i=>br.has(i.kind));if(n.length>0&&r.shared)try{r.shared.evidence.transaction(()=>{for(let i of n)r.shared.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,Q,i.payload,Date.now())})()}catch(i){xr(r,"file_evidence batch write",i)}}catch(n){Ue(e,"file_evidence batch write",n)}}function ni(e,t,r,n){let i=Ge(e);if(!i)return null;try{return(i.readProjectEvidence.get(t,r,n,Q)??i.readLegacyProjectEvidence.get(t,r,n))?.payload??null}catch(o){return Ue(e,"project_evidence read",o),null}}function ii(e,t,r,n,i){let o=Ge(e);if(o)try{o.writeProjectEvidence.run(t,r,n,Q,i)}catch(s){Ue(e,"project_evidence write",s)}}function Re(e){return typeof e=="object"&&e!==null}function vr(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}function Yf(e){return!Re(e)||typeof e.version!="number"||vr(e.languages)===null||typeof e.pnpmWorkspaces!="boolean"||typeof e.typescriptProjectMode!="string"||vr(e.typescriptProjects)===null||e.clojureConfigPath!==void 0&&typeof e.clojureConfigPath!="string"||!Array.isArray(e.files)||!e.files.every(Oa)?null:e}function Xf(e,t){let r=new Map((e?.files??[]).map(a=>[a.path,a])),n=new Map(t.files.map(a=>[a.path,a])),i=new Set([...r.keys(),...n.keys()]),o=[];for(let a of[...i].sort()){let c=r.get(a),l=n.get(a),p=Dn(a,t.languages);!c&&l?o.push({kind:"added",path:a,inputKind:p,after:l}):c&&!l?o.push({kind:"deleted",path:a,inputKind:p,before:c}):c&&l&&(c.hash!==l.hash||c.size!==l.size)&&o.push({kind:"modified",path:a,inputKind:p,before:c,after:l})}let s=new Set;return e||s.add("prior-snapshot-unavailable"),e&&e.version!==t.version&&s.add("snapshot-version-changed"),(oi(e?.files??[])||oi(t.files))&&s.add("duplicate-input-path"),[...e?.files??[],...t.files].some(La)&&s.add("unreadable-input"),{version:1,changes:o,projectIdentityChanged:e?!Wa(e,t):!0,uncertainty:[...s].sort()}}function oi(e){return new Set(e.map(t=>t.path)).size!==e.length}function Oa(e){return Re(e)&&typeof e.path=="string"&&typeof e.size=="number"&&typeof e.hash=="string"}function La(e){return e.hash==="unreadable"||e.size<0}function Ma(e){let t=new Set;for(let r of e.uncertainty)t.add(r);e.projectIdentityChanged&&t.add("project-identity-changed");for(let r of e.changes)r.kind==="added"&&t.add("file-added"),r.kind==="deleted"&&t.add("file-deleted"),r.inputKind==="config"&&t.add("configuration-changed"),r.inputKind==="ambient"&&t.add("ambient-declaration-changed"),r.inputKind==="other"&&t.add("unclassified-input");return{fullProject:t.size>0,reasons:[...t].sort()}}function Qf(e,t,r){let n=e.changes.map(a=>a.path).sort();if(n.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:n,affectedFiles:[],reasons:[]};let i=new Set(r),o=Ma(e),s=new Set(o.reasons);return n.some(a=>!i.has(a))&&s.add("changed-file-outside-project"),t===null?(s.add("dependency-graph-unavailable"),si(n,i,s)):s.size>0?si(n,i,s):{mode:"closure",changedFiles:n,affectedFiles:$a(n,t,i),reasons:[]}}function si(e,t,r){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...r].sort()}}function $a(e,t,r){let n=new Map;for(let[s,a]of t)if(r.has(s))for(let c of a){if(!r.has(c))continue;let l=n.get(c)??new Set;l.add(s),n.set(c,l)}let i=new Set(e),o=[...e];for(let s=0;s<o.length;s+=1){let a=o[s];if(a!==void 0)for(let c of n.get(a)??[])i.has(c)||(i.add(c),o.push(c))}return[...i].sort()}function Wa(e,t){return ai(e.languages,t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&ai(e.typescriptProjects,t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function ai(e,t){if(e.length!==t.length)return!1;let r=[...e].sort(),n=[...t].sort();return r.every((i,o)=>i===n[o])}import{execFileSync as Ga}from"child_process";import{existsSync as Ua,readdirSync as li}from"fs";import{extname as pi,join as ui}from"path";var di=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Va=[{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 nm(e){let t=[],r=Ba(e),n=Ja(e);for(let i of Va){if(Ha(e,i.files)){t.push(i.language);continue}if(qa(r,i.globs)){t.push(i.language);continue}Ya(n,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&ci(t,"javascript"),t.includes("cpp")&&!n.has(".c")&&ci(t,"c"),t}function Ba(e){try{return li(e)}catch{return[]}}function Ha(e,t){return t?.length?t.some(r=>Ua(ui(e,r))):!1}function qa(e,t){return t?.length?e.some(r=>t.some(n=>za(r,n))):!1}function za(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[r,n]=t.split("*");return e.startsWith(r??"")&&e.endsWith(n??"")}function Ja(e){let t=Ka(e);if(t)return t;let r=new Set,n=[e];for(;n.length>0;){let i=n.pop();if(!i)continue;let o;try{o=li(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=ui(i,s.name);if(s.isDirectory()){di.has(s.name)||n.push(a);continue}let c=pi(s.name).toLowerCase();c&&r.add(c)}}return r}function Ka(e){try{let t=Ga("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}),r=new Set;for(let n of t.split(`
104
- `)){if(!n||n.split("/").some(o=>di.has(o)))continue;let i=pi(n).toLowerCase();i&&r.add(i)}return r}catch{return null}}function Ya(e,t){return t?.length?t.some(r=>e.has(r)):!1}function ci(e,t){let r=e.indexOf(t);r!==-1&&e.splice(r,1)}import{readFileSync as Xa,writeFileSync as Qa}from"fs";import{create as fi}from"@bufbuild/protobuf";import{deserializeSCIP as Za,DocumentSchema as ec,IndexSchema as tc,serializeSCIP as rc,SymbolRole as nc}from"@c4312/scip";function cm(e){let t;try{t=Za(Xa(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let r=Ir(t);return r.removedDefinitionOccurrences>0&&Qa(e,Buffer.from(rc(r.index))),{removedDefinitionOccurrences:r.removedDefinitionOccurrences,touchedDocuments:r.touchedDocuments}}function Ir(e){let t=new Set;for(let o of e.documents)for(let s of o.symbols)s.symbol&&t.add(s.symbol);for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let r=0,n=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&nc.Definition)===0||t.has(a.symbol)?!0:(r+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}n+=1,i.push(fi(ec,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:r===0?e:fi(tc,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:r,touchedDocuments:n}}import{readFileSync as Er,writeFileSync as wr}from"fs";import{create as Ve}from"@bufbuild/protobuf";import{deserializeSCIP as Cr,serializeSCIP as kr,DocumentSchema as ic,IndexSchema as mi,MetadataSchema as oc,SymbolInformationSchema as sc}from"@c4312/scip";function gi(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=cc(e),r=lc(e.flatMap(i=>i.documents??[])),n=yi(e.flatMap(i=>i.externalSymbols??[]));return Ve(mi,{metadata:t,documents:r,externalSymbols:n})}function mm(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>Cr(Er(i))),n=gi(r);return wr(t,Buffer.from(kr(n))),{documentCount:n.documents.length,externalSymbolCount:n.externalSymbols.length,inputCount:e.length}}function gm(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>Cr(Er(i))),n=Ir(gi(r));return wr(t,Buffer.from(kr(n.index))),{documentCount:n.index.documents.length,externalSymbolCount:n.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function ac(e,t,r){let n=e.metadata;if(!n)throw new Error("Cannot rebase a SCIP index without metadata");if(n.projectRoot!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${n.projectRoot}`);return Ve(mi,{metadata:Ve(oc,{...n,projectRoot:r}),documents:e.documents,externalSymbols:e.externalSymbols})}function hi(e,t,r){let n=Cr(Er(e)),i=ac(n,t,r);wr(e,Buffer.from(kr(i)))}function cc(e){let t=e[0]?.metadata;if(!t)return;let r=t.projectRoot;for(let n of e.slice(1)){let i=n.metadata?.projectRoot;if(r&&i&&i!==r)throw new Error(`Cannot merge SCIP indexes with different project roots: ${r} vs ${i}`)}return t}function lc(e){let t=new Map;for(let r of e){let n=t.get(r.relativePath);if(!n){t.set(r.relativePath,r);continue}t.set(r.relativePath,Ve(ic,{language:n.language||r.language,relativePath:n.relativePath||r.relativePath,occurrences:pc([...n.occurrences,...r.occurrences]),symbols:yi([...n.symbols,...r.symbols]),text:dc(n.text,r.text),positionEncoding:n.positionEncoding||r.positionEncoding}))}return[...t.values()]}function pc(e){let t=new Set,r=[];for(let n of e){let i=JSON.stringify(n);t.has(i)||(t.add(i),r.push(n))}return r}function yi(e){let t=new Map;for(let r of e){let n=t.get(r.symbol);if(!n){t.set(r.symbol,r);continue}t.set(r.symbol,Ve(sc,{symbol:n.symbol,documentation:fc([...n.documentation,...r.documentation]),relationships:uc([...n.relationships,...r.relationships]),kind:n.kind||r.kind,displayName:n.displayName||r.displayName,enclosingSymbol:n.enclosingSymbol||r.enclosingSymbol,signatureDocumentation:n.signatureDocumentation??r.signatureDocumentation}))}return[...t.values()]}function uc(e){let t=new Set,r=[];for(let n of e){let i=[n.symbol,n.isReference?"1":"0",n.isImplementation?"1":"0",n.isTypeDefinition?"1":"0",n.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),r.push(n))}return r}function dc(e,t){return e?t?e.length>=t.length?e:t:e:t}function fc(e){return[...new Set(e)]}import{createHash as Ic}from"crypto";import{existsSync as He,mkdirSync as Ec,readFileSync as ze,readdirSync as _r,renameSync as wc,rmSync as Ai,writeFileSync as Cc}from"fs";import{join as $}from"path";import{createHash as mc}from"crypto";import{existsSync as Pr,mkdirSync as gc,readFileSync as bt,readdirSync as bm,renameSync as hc,rmSync as xm,writeFileSync as yc}from"fs";import{join as Ne}from"path";import{create as bi,fromBinary as xi,toBinary as Sc}from"@bufbuild/protobuf";import{deserializeSCIP as xt,DocumentSchema as Rr,IndexSchema as vi,serializeSCIP as Ii}from"@c4312/scip";var vt=1,Be="typescript-scip-fragments";function Cm(e){if(e.length===0)throw new Error("affected TypeScript mini index requires documents");let t=new Set,r=[];for(let o of e){let s=pe(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=xi(Rr,o.bytes);if(a.relativePath!==s)throw new Error(`TypeScript fragment path mismatch: expected ${s}, got ${a.relativePath}`);r.push(a)}let n=Ii(bi(vi,{documents:r,externalSymbols:[]})),i=xt(n);if(i.documents.length!==r.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return n}function It(e){let t=Ne(e,Be);return{rootDir:t,blobDir:Ne(t,"blobs"),generationDir:Ne(t,"generations")}}function bc(e){let t=xt(e.indexBytes);_i(t.metadata,Di(e)),Ni(t.externalSymbols);let r=new Set,n=[];for(let o of t.documents){let s=pe(o.relativePath);if(r.has(s))throw new Error(`duplicate TypeScript SCIP document path: ${s}`);r.add(s);let a=Sc(Rr,o),c=e.documentIdentities.get(s)??(e.allowUntrackedDocuments?ue(JSON.stringify({version:1,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,untrackedDocument:s,contentHash:ue(a)})):null);if(!c)throw new Error(`missing TypeScript document identity: ${s}`);n.push(ki(e.cacheDir,{relativePath:s,bytes:a,occurrences:o.occurrences.length,symbols:o.symbols.length,referenceFragments:[]},c))}let i=Ti(e,n);return Pi(e.cacheDir,i),i}function km(e){let t=It(e.cacheDir);if(!Pr(Nr(t,e.generationIdentity)))return bc(e);let r=Ei({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity});if(!e.allowUntrackedDocuments&&r.manifest.documents.length!==e.documentIdentities.size)throw new Error("TypeScript fragment generation document identities changed");for(let n of r.manifest.documents){let i=e.documentIdentities.get(n.relativePath);if(!(i===void 0&&e.allowUntrackedDocuments)&&i!==n.documentIdentity)throw new Error(`TypeScript fragment generation document identity changed: ${n.relativePath}`)}return r.manifest}function Tm(e){let t=Ei({cacheDir:e.cacheDir,generationIdentity:e.previousGenerationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity}).manifest,r=new Map(t.documents.map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let s=pe(o.relativePath);if(n.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(n.add(s),!r.has(s))throw new Error(`TypeScript fragment replacement has no prior document: ${s}`);let a=e.documentIdentities.get(s);if(!a)throw new Error(`missing TypeScript document identity: ${s}`);o.bytes===null?r.delete(s):r.set(s,ki(e.cacheDir,o,a))}if(n.size===0)throw new Error("TypeScript fragment generation requires at least one replacement");let i=Ti(e,[...r.values()]);return Pi(e.cacheDir,i),i}function Ei(e){let t=It(e.cacheDir),r=Nr(t,e.generationIdentity),n;try{n=Ri(bt(r,"utf8"))}catch(o){throw new Error(`TypeScript fragment generation is unavailable: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(n.generationIdentity!==e.generationIdentity)throw new Error("TypeScript fragment generation identity does not match its manifest path");if(e.producerIdentity&&n.producerIdentity!==e.producerIdentity)throw new Error("TypeScript fragment producer identity changed");if(e.projectIdentity&&n.projectIdentity!==e.projectIdentity)throw new Error("TypeScript fragment project identity changed");let i=new Map;for(let o of n.documents){let s=Ne(t.blobDir,`${o.blobHash}.scipdoc`),a=bt(s);if(a.byteLength!==o.byteLength||ue(a)!==o.blobHash)throw new Error(`TypeScript fragment blob is corrupt: ${o.relativePath}`);i.set(o.relativePath,a)}return{manifest:n,fragments:i}}function wi(e){let t=Ci(e);return Tr(t.baseIndex,t.completeDocuments,"assembled")}function Pm(e){let t=Ci(e);return xc(t.deletedAffectedPaths),{completeIndexBytes:Tr(t.baseIndex,t.completeDocuments,"assembled"),affectedIndexBytes:Tr(t.baseIndex,t.affectedDocuments,"affected")}}function Ci(e){let t=xt(e.baseIndexBytes);_i(t.metadata,Di(e)),Ni(t.externalSymbols);let r=new Map;for(let a of e.fragments){let c=pe(a.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);r.set(c,a)}if(r.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let n=new Set,i=[],o=[],s=[];for(let a of t.documents){let c=pe(a.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);n.add(c);let l=r.get(c);if(!l){i.push(a);continue}if(r.delete(c),l.bytes===null){s.push(c);continue}let p=xi(Rr,l.bytes);if(p.relativePath!==c)throw new Error(`TypeScript fragment path mismatch: expected ${c}, got ${p.relativePath}`);i.push(p),o.push(p)}if(r.size>0)throw new Error(`TypeScript fragment replacement has no prior document: ${[...r.keys()].sort()[0]}`);return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:s}}function Tr(e,t,r){let n=Ii(bi(vi,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=xt(n);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${r} TypeScript SCIP index failed structural verification`);return n}function xc(e){if(e.length>0)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${e[0]}`)}function ki(e,t,r){if(t.bytes===null)throw new Error(`cannot persist an empty TypeScript fragment: ${t.relativePath}`);let n=pe(t.relativePath),i=Buffer.from(t.bytes),o=ue(i),s=It(e);gc(s.blobDir,{recursive:!0});let a=Ne(s.blobDir,`${o}.scipdoc`);if(Pr(a)){let c=bt(a);if(c.byteLength!==i.byteLength||ue(c)!==o)throw new Error(`existing TypeScript fragment blob is corrupt: ${n}`)}else{let c=`${a}.${process.pid}.${Date.now()}.tmp`;yc(c,i),hc(c,a)}return{relativePath:n,blobHash:o,byteLength:i.byteLength,documentIdentity:r}}function Ti(e,t){if(!e.producerIdentity||!e.projectIdentity||!e.generationIdentity)throw new Error("TypeScript fragment generation identities must be non-empty");let r=[...t].sort((n,i)=>n.relativePath.localeCompare(i.relativePath));if(new Set(r.map(n=>n.relativePath)).size!==r.length)throw new Error("TypeScript fragment generation contains duplicate document paths");return{version:vt,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),documents:r}}function Pi(e,t){let r=It(e),n=Nr(r,t.generationIdentity);if(Pr(n)){let i=Ri(bt(n,"utf8"));if(Si(i)!==Si(t))throw new Error(`TypeScript fragment generation is immutable: ${t.generationIdentity}`);return}P(n,t,{spacing:2,trailingNewline:!0})}function Si(e){return ue(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,documents:e.documents}))}function Ri(e){let t=JSON.parse(e);if(t.version!==vt||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let r=new Set;for(let n of t.documents){if(!n||typeof n.relativePath!="string"||typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash)||typeof n.byteLength!="number"||!Number.isInteger(n.byteLength)||n.byteLength<0||typeof n.documentIdentity!="string"||!n.documentIdentity)throw new Error("invalid TypeScript fragment record");if(pe(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript fragment record");r.add(n.relativePath)}return t}function Nr(e,t){return Ne(e.generationDir,vc(t))}function vc(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${ue(e)}.json`}function Ni(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function _i(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let r=e,n=r.toolInfo??r.tool_info;if(!n||typeof n!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=n;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function Di(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function pe(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 ue(e){return mc("sha256").update(e).digest("hex")}var Et=1,Fm=64*1024*1024,Je="typescript-scip-overlays";function Om(e){let t=Fi(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t&&(t.producerIdentity!==e.producerIdentity||t.projectIdentity!==e.projectIdentity))throw new Error("TypeScript overlay producer or project identity changed");let r=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let s=jr(o.relativePath);if(n.has(s))throw new Error(`duplicate TypeScript overlay: ${s}`);n.add(s),r.set(s,kc(e.cacheDir,o))}if(n.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:Et,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...r.values()].sort((o,s)=>o.relativePath.localeCompare(s.relativePath))};return Tc(e.cacheDir,i),i}function Lm(e){let t=Fi(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let r=t.overlays.map(n=>{if(n.blobHash===null)return{relativePath:n.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=ze($(Ke(e.cacheDir),"blobs",`${n.blobHash}.scipdoc`));if(i.byteLength!==n.byteLength||qe(i)!==n.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${n.relativePath}`);return{relativePath:n.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return wi({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:r})}function Mm(e,t){let r=Ke(e),n=$(r,"generations");if(!He(n))return;let i=new Set(t.map(Ar)),o=new Set;for(let a of _r(n).filter(c=>i.has(c))){let c=Dr(ze($(n,a),"utf8"));for(let l of c.overlays)l.blobHash&&o.add(`${l.blobHash}.scipdoc`)}for(let a of _r(n))i.has(a)||Ai($(n,a),{force:!0});let s=$(r,"blobs");if(He(s))for(let a of _r(s))o.has(a)||Ai($(s,a),{force:!0})}function Fi(e,t){let r=$(Ke(e),"generations",Ar(t));if(!He(r))return null;let n=Dr(ze(r,"utf8"));if(n.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return n}function kc(e,t){let r=jr(t.relativePath);if(t.bytes===null)return{relativePath:r,blobHash:null,byteLength:0};let n=Buffer.from(t.bytes),i=qe(n),o=$(Ke(e),"blobs");Ec(o,{recursive:!0});let s=$(o,`${i}.scipdoc`);if(He(s)){let a=ze(s);if(a.byteLength!==n.byteLength||qe(a)!==i)throw new Error(`existing TypeScript overlay blob is corrupt: ${r}`)}else{let a=`${s}.${process.pid}.${Date.now()}.tmp`;Cc(a,n),wc(a,s)}return{relativePath:r,blobHash:i,byteLength:n.byteLength}}function Tc(e,t){let r=$(Ke(e),"generations",Ar(t.generationIdentity));if(He(r)){let n=Dr(ze(r,"utf8"));if(ji(n)!==ji(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}P(r,t,{spacing:2,trailingNewline:!0})}function Dr(e){let t=JSON.parse(e);if(t.version!==Et||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let r=new Set;for(let n of t.overlays){if(!n||typeof n.relativePath!="string"||n.blobHash!==null&&(typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash))||!Number.isInteger(n.byteLength)||n.byteLength<0||n.blobHash===null&&n.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(jr(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript overlay record");r.add(n.relativePath)}return t}function Ke(e){return $(e,Je)}function Ar(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${qe(e)}.json`}function ji(e){return qe(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function jr(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}function qe(e){return Ic("sha256").update(e).digest("hex")}import{createHash as Pc}from"crypto";import{copyFileSync as Oi,existsSync as Z,linkSync as Rc,mkdirSync as Li,readFileSync as Wi,readdirSync as Mi,renameSync as Or,rmSync as Ct,statSync as Nc}from"fs";import{basename as wt,dirname as Ye,join as E,relative as $i}from"path";var _e=1,kt=".scipquery-generations";function Gi(e){let t=Tt(e.outputDb),r=_c(e,t);e.onStage?.("after-recovery-retained"),e.preserveOutputScip||Fr(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),Fr(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),Fr(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let n=Pt(e.metaPath,e.outputDb),i={version:_e,currentGeneration:n,...r?{previousGeneration:r}:{},...e.publication?{publication:e.publication}:{},publishedAt:(e.now??(()=>new Date))().toISOString()};return P(E(t,"state.json"),i,{spacing:2,trailingNewline:!0}),{currentGeneration:n,...r?{previousGeneration:r}:{}}}function Ui(e){try{let t=JSON.parse(Wi(E(Tt(e),"state.json"),"utf8"));return t.version!==_e||typeof t.currentGeneration!="string"||!t.currentGeneration||typeof t.publishedAt!="string"||!Number.isFinite(Date.parse(t.publishedAt))||!jc(t.previousGeneration)||!Fc(t.publication)?null:t}catch{return null}}function Bm(e,t,r=()=>new Date){if(!Z(e)||!Z(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let n=Ui(e),i={version:_e,currentGeneration:Pt(t,e),...n?.previousGeneration?{previousGeneration:n.previousGeneration}:{},...n?.publication?{publication:n.publication}:{},publishedAt:r().toISOString()};return P(E(Tt(e),"state.json"),i,{spacing:2,trailingNewline:!0}),i}function Lr(e,t=E(Ye(e),"meta.json")){let r=E(Tt(e),"state.json");if(!Z(r))return{state:"legacy",statePath:r};let n=Ui(e);if(!n)return{state:"invalid",statePath:r,reason:"generation state is malformed"};try{let i=Pt(t,e),o=n.currentGeneration===i,s=n.previousGeneration?Z(E(Ye(e),n.previousGeneration.databasePath)):!0;return!o||!s?{state:"drifted",statePath:r,currentMatches:o,recoveryExists:s,generation:n,reason:o?"retained recovery database is missing":"stable database or metadata no longer matches the published generation"}:{state:"current",statePath:r,currentMatches:o,recoveryExists:s,generation:n}}catch(i){return{state:"drifted",statePath:r,currentMatches:!1,recoveryExists:!1,generation:n,reason:i instanceof Error?i.message:String(i)}}}function Tt(e){return E(Ye(e),kt)}function _c(e,t){if(!Z(e.outputDb))return;let r=Pt(e.metaPath,e.outputDb),n=E(t,r),i=E(n,wt(e.outputDb)),o=Z(e.metaPath)?E(n,wt(e.metaPath)):void 0;if(!Z(i)){let s=`${n}.${process.pid}.${Date.now()}.tmp`;Ct(s,{recursive:!0,force:!0}),Li(s,{recursive:!0});let a=E(s,wt(e.outputDb));try{Rc(e.outputDb,a)}catch{Oi(e.outputDb,a)}o&&Oi(e.metaPath,E(s,wt(e.metaPath))),Li(t,{recursive:!0}),Or(s,n)}return Dc(t,r),{generationIdentity:r,databasePath:$i(Ye(e.outputDb),i),...o?{metadataPath:$i(Ye(e.outputDb),o)}:{}}}function Dc(e,t){for(let r of Mi(e,{withFileTypes:!0}))!r.isDirectory()||r.name===t||r.name.endsWith(".tmp")||Ct(E(e,r.name),{recursive:!0,force:!0});for(let r of Mi(e,{withFileTypes:!0}))r.isDirectory()&&r.name.endsWith(".tmp")&&Ct(E(e,r.name),{recursive:!0,force:!0})}function Pt(e,t){let r=Pc("sha256").update(`sqlite-generation-v${_e}\0`);Z(e)&&r.update(Ac(Wi(e,"utf8")));let n=Nc(t);return r.update(`\0${n.size}`),r.digest("hex")}function Ac(e){try{let t=JSON.parse(e);if((t.version===2||t.version===3)&&t.status==="complete"&&typeof t.updatedAt=="string"&&t.fingerprint!==void 0)return JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages,scipCompanion:t.scipCompanion})}catch{}return e}function Fr(e,t){Ct(`${t}.tmp-replace`,{force:!0}),Or(e,`${t}.tmp-replace`),Or(`${t}.tmp-replace`,t)}function jc(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 Fc(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,r=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(n=>n!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&r.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}import{createHash as Xi,randomUUID as Ur}from"crypto";import{closeSync as Qi,constants as Hc,copyFileSync as zi,existsSync as te,lstatSync as qc,mkdirSync as H,mkdtempSync as Zi,openSync as eo,readdirSync as zc,readFileSync as W,realpathSync as Jc,renameSync as de,rmSync as ee,statSync as Kc,unlinkSync as Wr,writeFileSync as to}from"fs";import{dirname as ro,join as f,resolve as et}from"path";import{setTimeout as Yc}from"timers/promises";import{pathToFileURL as Ji}from"url";import{deserializeSCIP as no}from"@c4312/scip";import Xc from"better-sqlite3";import{createRequire as Oc}from"module";var Lc=Oc(import.meta.url),Vi=Mc().version;function Mc(){for(let e of["../package.json","../../package.json"])try{return Lc(e)}catch{}return{version:"0.0.0"}}import{lstatSync as $c,readdirSync as Wc}from"fs";import{join as Gc,relative as Uc,resolve as Mr,sep as Vc}from"path";var Xe=1,$r="language-indexes",Bi=["index.db","index.scip","meta.json"],Hi=[$r,Be,Je];function Rt(e){let t=[];for(let r of Bi)Bc(e,r),t.push(r);for(let r of Hi)qi(e,r,t);return{version:Xe,files:t.sort()}}function Nt(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(n=>!n||n==="."||n===".."))throw new Error(`invalid index artifact path: ${e}`);let r=t[0];if(!Bi.includes(e)&&!Hi.includes(r))throw new Error(`index artifact path is not shareable: ${e}`);return e}function U(e,t){let r=Nt(t),n=Mr(e),i=Mr(n,...r.split("/"));if(i!==n&&!i.startsWith(`${n}${Vc}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function qi(e,t,r){let n=Gc(e,t),i;try{i=Wc(n,{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()?qi(e,s,r):o.isFile()&&r.push(Nt(s))}}function Bc(e,t){let r=U(e,t),n;try{n=$c(r)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!n.isFile()||n.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(Uc(Mr(e),r).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var Vr=1,Ki="SCIP_QUERY_SHARED_CACHE",Gr=JSON.stringify({cliVersion:Vi,artifactCatalogVersion:Xe,sqliteGenerationStoreVersion:_e,typescriptFragmentStoreVersion:vt,typescriptOverlayStoreVersion:Et}),io="manifest.json",Qc="shared-cache.json",Br=[$r,Be,Je];function yg(e,t){if(!e.clean||!e.treeOid)return;let r=rt(JSON.stringify({version:Vr,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:t,producerIdentity:Gr}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:Gr,generationId:r,repositoryCacheDir:mr(e.repositoryId)}}function Sg(e,t,r){if(process.env[Ki]==="0")return`${Ki}=0`;if(!gr(r))return"explicit cache or database override";if(et(t)!==et(f(fr(e),"index.db")))return"index database is outside the managed worktree cache"}function bg(e,t){if(!gr(t))return;let r=jn(e);return r?f(mr(r.repositoryId),"evidence.db"):void 0}function Ze(e,t=!0){let r=Hr(e),n;try{n=tl(W(f(r,io),"utf8"))}catch{return null}if(n.generationId!==e.generationId||n.repositoryId!==e.repositoryId||n.treeOid!==e.treeOid||n.producerIdentity!==e.producerIdentity||JSON.stringify(n.fingerprint)!==JSON.stringify(e.fingerprint))return null;if(!t)return n;try{for(let i of n.artifacts){let o=U(r,i.path),s=Kc(o);if(!s.isFile()||s.size!==i.size||rt(W(o))!==i.sha256)return null}}catch{return null}return n}function xg(e){let t=Ze(e.snapshot);if(t)return t;if(!ao(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let r=Yi(e.sourceCacheDir);if(!r)throw new Error("source index artifacts are incomplete");let n=Rt(e.sourceCacheDir),i=f(e.snapshot.repositoryCacheDir,"generations");H(i,{recursive:!0});let o=Zi(f(i,`.tmp-${process.pid}-`));try{let s=[];for(let u of n.files){let d=U(e.sourceCacheDir,u),m=U(o,u);tt(d,m);let h=W(m);s.push({path:u,size:h.byteLength,sha256:rt(h)})}let a=no(W(f(o,"index.scip"))).metadata?.projectRoot;if(!a)throw new Error("shared SCIP generation has no project root metadata");let c=qr(e.sourceProjectRoot);if(a!==c)throw new Error("shared SCIP generation root does not match its source worktree");if(Yi(e.sourceCacheDir)!==r||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let l={version:Vr,artifactCatalogVersion:Xe,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:a,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:s.sort((u,d)=>u.path.localeCompare(d.path))};P(f(o,io),l,{spacing:2,trailingNewline:!0});let p=Hr(e.snapshot);try{if(te(p)&&!Ze(e.snapshot)){let u=`${p}.corrupt-${process.pid}-${Date.now()}`;de(p,u),ee(u,{recursive:!0,force:!0})}de(o,p)}catch(u){let d=Ze(e.snapshot);if(d)return d;throw u}return l}finally{ee(o,{recursive:!0,force:!0})}}function vg(e){let t=Hr(e.snapshot);H(e.targetCacheDir,{recursive:!0});let r=hr(f(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:3e4});if(!r)throw new Error("timed out waiting for another cache hydration");let n,i,o=!1;try{n=Zi(f(e.targetCacheDir,".shared-hydrate-")),ll(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let l=U(t,c.path),p=U(n,c.path);tt(l,p);let u=W(p);if(u.byteLength!==c.size||rt(u)!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let s=qr(e.targetProjectRoot);if(s!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&hi(U(n,c.path),e.manifest.scipProjectRoot,s);if(!ao(n,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=sl(e.targetCacheDir,n),o=!0,al(n,e.targetCacheDir,i),Gi({tempOutputScip:f(n,"index.scip"),tempOutputDb:f(n,"index.db"),tempMetaPath:f(n,"meta.json"),outputScip:f(e.targetCacheDir,"index.scip"),outputDb:f(e.targetCacheDir,"index.db"),metaPath:f(e.targetCacheDir,"meta.json"),now:e.now});let a=Lr(f(e.targetCacheDir,"index.db"),f(e.targetCacheDir,"meta.json"));if(a.state==="invalid"||a.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${a.reason}`);Zc(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(s){throw o&&i&&cl(e.targetCacheDir,i),s}finally{n&&ee(n,{recursive:!0,force:!0}),r.release()}}async function Ig(e,t={}){let r=t.timeoutMs??3e4,n=t.pollMs??100,i=t.now??Date.now,o=i()+r,s=f(e.repositoryCacheDir,"locks"),a=f(s,`${e.generationId}.lock`);for(H(s,{recursive:!0});i()<=o;){if(Ze(e))return{kind:"generation-ready"};let c=Ur();try{let l=eo(a,"wx");try{to(l,`${JSON.stringify({version:1,pid:process.pid,token:c,generationId:e.generationId,startedAt:new Date(i()).toISOString()})}
105
- `)}finally{Qi(l)}return{kind:"owner",release:()=>{try{let p=JSON.parse(W(a,"utf8"));p.pid===process.pid&&p.token===c&&Wr(a)}catch{}}}}catch(l){if(l.code!=="EEXIST")return{kind:"timeout"};let p=oo(a);if(p&&(p.pid===void 0||!B(p.pid))){il(a,p);continue}await Yc(n)}}return Ze(e)?{kind:"generation-ready"}:{kind:"timeout"}}function Zc(e,t,r,n=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:r,lastSeenAt:(n??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:el(i)};return ol(e.repositoryCacheDir,o,!0),o}function el(e){return rt(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:et(e.projectRoot),localCacheDir:et(e.localCacheDir)}))}function tl(e){let t=JSON.parse(e);if(t.version!==Vr||t.artifactCatalogVersion!==Xe||typeof t.generationId!="string"||!/^[a-f0-9]{64}$/.test(t.generationId)||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.treeOid!="string"||!t.treeOid||typeof t.producerIdentity!="string"||t.producerIdentity!==Gr||typeof t.sourceProjectRoot!="string"||typeof t.scipProjectRoot!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!t.fingerprint||!Array.isArray(t.artifacts))throw new Error("invalid shared generation manifest");let r=new Set;for(let n of t.artifacts){if(!n||typeof n.path!="string"||typeof n.size!="number"||n.size<0||typeof n.sha256!="string"||!/^[a-f0-9]{64}$/.test(n.sha256))throw new Error("invalid shared generation artifact");if(Nt(n.path),r.has(n.path))throw new Error(`duplicate shared generation artifact: ${n.path}`);r.add(n.path)}for(let n of["index.db","index.scip","meta.json"])if(!r.has(n))throw new Error(`shared generation is missing ${n}`);return t}function tt(e,t){H(ro(t),{recursive:!0});try{zi(e,t,Hc.COPYFILE_FICLONE)}catch{zi(e,t)}}function rl(e,t,r){H(e,{recursive:!0}),P(f(e,Qc),{version:1,repositoryId:t,worktreeId:r},{spacing:2,trailingNewline:!0})}function Yi(e){try{let t=Rt(e),r=Xi("sha256");for(let n of t.files){let i=W(U(e,n));r.update(n).update("\0").update(String(i.byteLength)).update("\0").update(i).update("\0")}return r.digest("hex")}catch{return null}}function nl(e){try{return JSON.parse(W(f(e,"meta.json"),"utf8"))}catch{return}}function Hr(e){return f(e.repositoryCacheDir,"generations",e.generationId)}function oo(e){try{let t=W(e,"utf8"),r=JSON.parse(t),n=typeof r.pid=="number"&&Number.isSafeInteger(r.pid)&&r.pid>0?r.pid:void 0;return{raw:t,...n===void 0?{}:{pid:n}}}catch{return null}}function il(e,t){let r=`${e}.reclaim`,n=Ur(),i;try{i=eo(r,"wx")}catch{return!1}try{to(i,`${JSON.stringify({version:1,pid:process.pid,token:n,startedAt:new Date().toISOString()})}
106
- `)}finally{Qi(i)}try{let o=oo(e);return!o||o.raw!==t.raw||o.pid!==void 0&&B(o.pid)?!1:(Wr(e),!0)}catch{return!1}finally{try{let o=JSON.parse(W(r,"utf8"));o.pid===process.pid&&o.token===n&&Wr(r)}catch{}}}function ol(e,t,r){let n=Jn(e,{waitMs:5e3});if(!n)throw new Error("repository cache cleanup is busy");try{if(r){let o=t.activeGenerationId;if(!o||!te(f(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=f(e,"worktrees");H(i,{recursive:!0}),P(f(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),rl(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{n.release()}}function sl(e,t){let r=f(t,".rollback"),n=new Map,i=new Map;H(r,{recursive:!0});for(let a of["index.scip","index.db","meta.json"]){let c=f(e,a),l=te(c);n.set(a,l),l&&tt(c,f(r,"stable",a))}for(let a of Br){let c=f(e,a),l=te(c);if(l){let p=qc(c);if(!p.isDirectory()||p.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${a}`)}i.set(a,l)}let o=f(e,kt),s=te(o);return s&&so(o,f(r,"sqlite-generations")),{root:r,stableFiles:n,managedDirectories:i,generationStoreExisted:s}}function al(e,t,r){for(let n of Br){let i=f(t,n);if(r.managedDirectories.get(n)){let s=f(r.root,"managed",n);H(ro(s),{recursive:!0}),de(i,s)}let o=f(e,n);te(o)&&de(o,i)}}function cl(e,t){for(let i of Br){let o=f(e,i),s=f(t.root,"managed",i);t.managedDirectories.get(i)?te(s)&&(ee(o,{recursive:!0,force:!0}),de(s,o)):ee(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let s=f(e,i);if(!o){ee(s,{force:!0});continue}let a=`${s}.shared-restore-${Ur()}`;tt(f(t.root,"stable",i),a),ee(s,{force:!0}),de(a,s)}let r=f(e,kt);ee(r,{recursive:!0,force:!0});let n=f(t.root,"sqlite-generations");t.generationStoreExisted&&te(n)&&de(n,r)}function so(e,t){H(t,{recursive:!0});for(let r of zc(e,{withFileTypes:!0})){let n=f(e,r.name),i=f(t,r.name);if(r.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${n}`);r.isDirectory()?so(n,i):r.isFile()&&tt(n,i)}}function ll(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||JSON.stringify(e.fingerprint)!==JSON.stringify(t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function ao(e,t,r,n=!0,i=!0){try{let o=nl(e);if(o?.status!=="complete"||JSON.stringify(o.fingerprint)!==JSON.stringify(r)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...r.languages].sort()))return Qe("source validation rejected metadata"),!1;let s=Rt(e),a=Lr(f(e,"index.db"),f(e,"meta.json"));if(n?a.state!=="current":a.state==="invalid"||a.state==="drifted")return Qe(`source validation rejected SQLite generation state ${a.state}`),!1;let c=new Xc(f(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let l=qr(t),u=(i?s.files.filter(d=>d.endsWith(".scip")):["index.scip"]).every(d=>{let m=no(W(U(e,d))).metadata?.projectRoot;return m!==l&&Qe(`source validation rejected SCIP root for ${d}: ${String(m)}`),m===l});return u||Qe("source validation rejected SCIP project roots"),u}catch(o){return Qe(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function Qe(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function qr(e){try{return Ji(Jc(e)).href}catch{return Ji(et(e)).href}}function rt(e){return Xi("sha256").update(e).digest("hex")}import{readFileSync as co}from"fs";import{createRequire as pl}from"module";import{dirname as Yr,isAbsolute as ul,relative as fo,resolve as ne,sep as zr}from"path";var re=pl(import.meta.url),dl=1,lo="0.4.0";function fl(){try{let e=mo();if(!e.available)return e;let{packageRoot:t}=e,r=re.resolve("typescript",{paths:[t]}),n=re(r),{FileIndexer:i}=re(ne(t,"dist/src/FileIndexer.js")),{Input:o}=re(ne(t,"dist/src/Input.js")),{Packages:s}=re(ne(t,"dist/src/Packages.js")),a=re(ne(t,"dist/src/scip.js"));if(!i||!o||!s||!a.scip?.Document||!a.scip.Index)return{available:!1,reason:"scip-typescript document runtime has an unsupported module shape"};let c={packageVersion:e.packageVersion,typescript:n,Document:a.scip.Document,Index:a.scip.Index,FileIndexer:i,Input:o,Packages:s};return{available:!0,runtime:c,producerIdentity:Xr(c)}}catch(e){return{available:!1,reason:`scip-typescript document runtime unavailable: ${e instanceof Error?e.message:String(e)}`}}}function Tg(){let e=mo();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function mo(){try{let e=re.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(co(e,"utf8"));if(t.version!==lo)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${lo}`};let r=Yr(e),n=re.resolve("typescript/package.json",{paths:[r]}),i=JSON.parse(co(n,"utf8"));return typeof i.version!="string"||!i.version?{available:!1,reason:"scip-typescript TypeScript compiler version is unavailable"}:{available:!0,packageRoot:r,packageVersion:t.version,typescriptVersion:i.version,producerIdentity:go(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function Pg(e){let t=e.runtime===void 0?fl():e.runtime===null?{available:!1,reason:"scip-typescript document runtime unavailable"}:{available:!0,runtime:e.runtime,producerIdentity:Xr(e.runtime)};return t.available?{available:!0,emitter:new Jr(e,t.runtime)}:t}var Jr=class{producerIdentity;workspaceRoot;tsconfigPath;projectRoot;maxFileByteSize;runtime;host;config=null;includedFiles=new Set;program=null;checker=null;symbolTable=new Map;constructorTable=new Map;packages;fragments=new Map;stats={initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0,sourceNodesReused:0,sourceNodesReplaced:0,symbolEntriesPruned:0};constructor(t,r){this.workspaceRoot=ne(t.workspaceRoot),this.tsconfigPath=ne(this.workspaceRoot,t.tsconfigPath),this.projectRoot=t.projectRoot??gl(this.workspaceRoot,Yr(this.tsconfigPath)),this.maxFileByteSize=t.maxFileByteSize??1024*1024,this.runtime=r,this.producerIdentity=Xr(r);let n=po(r.typescript,this.tsconfigPath);this.config=n,this.host=new Kr(r.typescript,n.options,this.workspaceRoot),this.packages=new r.Packages(this.projectRoot)}initialize(){let t=performance.now(),r=this.config??po(this.runtime.typescript,this.tsconfigPath);this.includedFiles=new Set(r.fileNames.map(De)),this.program=this.runtime.typescript.createProgram(r.fileNames,r.options,this.host.compilerHost),this.checker=this.program.getTypeChecker(),this.stats.initializations+=1;let n=[];for(let i of this.program.getSourceFiles())this.includedFiles.has(De(i.fileName))&&n.push(this.emitSourceFile(i));return this.result(n,t)}advance(t){if(!this.program||!this.checker||!this.config)return this.initializeAndAdvance(t);let r=performance.now(),n=_t(t.modifiedFiles),i=_t(t.affectedFiles);this.validateIncrementalPaths(n,i);let o=this.program,s=new Map;for(let c of n){let l=nt(this.workspaceRoot,c),p=o.getSourceFile(l);if(!p)throw new Error(`modified TypeScript source is unavailable: ${c}`);s.set(c,p),this.stats.symbolEntriesPruned+=uo(this.symbolTable,p),this.stats.symbolEntriesPruned+=uo(this.constructorTable,p),this.host.invalidate(l)}this.program=this.runtime.typescript.createProgram(this.config.fileNames,this.config.options,this.host.compilerHost,o),this.checker=this.program.getTypeChecker(),this.stats.programUpdates+=1;for(let[c,l]of s)this.program.getSourceFile(nt(this.workspaceRoot,c))===l?this.stats.sourceNodesReused+=1:this.stats.sourceNodesReplaced+=1;let a=i.map(c=>{let l=nt(this.workspaceRoot,c),p=this.program.getSourceFile(l);if(!p)throw new Error(`affected TypeScript source is unavailable: ${c}`);return this.emitSourceFile(p)});return this.result(a,r)}fragment(t){return this.fragments.get(Dt(t))??null}snapshotStats(){return{...this.stats}}initializeAndAdvance(t){let r=this.initialize(),n=_t(t.modifiedFiles),i=_t(t.affectedFiles);this.validateIncrementalPaths(n,i);let o=new Set(i);return{...r,fragments:r.fragments.filter(s=>o.has(s.relativePath))}}validateIncrementalPaths(t,r){if(t.length===0)throw new Error("incremental TypeScript document update requires a modified file");if(r.length===0)throw new Error("incremental TypeScript document update requires an affected file");for(let n of t){let i=nt(this.workspaceRoot,n);if(!this.includedFiles.has(De(i)))throw new Error(`modified TypeScript file is outside the configured project: ${n}`)}for(let n of r){let i=nt(this.workspaceRoot,n);if(!this.includedFiles.has(De(i)))throw new Error(`affected TypeScript file is outside the configured project: ${n}`)}}emitSourceFile(t){if(!this.checker)throw new Error("TypeScript document emitter is not initialized");let r=Dt(fo(this.workspaceRoot,t.fileName)),n=new this.runtime.Document({relative_path:r,occurrences:[]});if(new this.runtime.FileIndexer(this.checker,{cwd:this.workspaceRoot,projectRoot:this.projectRoot,projectDisplayName:this.projectRoot,maxFileByteSizeNumber:this.maxFileByteSize},new this.runtime.Input(t.fileName,t.getText()),n,this.symbolTable,this.constructorTable,this.packages,t).index(),this.stats.documentsEmitted+=1,n.occurrences.length===0)return this.fragments.delete(r),this.stats.documentsRemoved+=1,{relativePath:r,bytes:null,occurrences:0,symbols:n.symbols.length,referenceFragments:[]};let o=n.serializeBinary();return this.fragments.set(r,o),{relativePath:r,bytes:o,occurrences:n.occurrences.length,symbols:n.symbols.length,referenceFragments:ml(r,n)}}result(t,r){return{producerIdentity:this.producerIdentity,fragments:t,durationMs:performance.now()-r,stats:this.snapshotStats()}}};function ml(e,t){let r=new Map;for(let n of t.occurrences){if(!n.symbol||(n.symbol_roles&1)!==0||n.range.length<3)continue;let i=n.range[0],o=n.range[1];if(!Number.isInteger(i)||!Number.isInteger(o))continue;let s={targetSymbol:n.symbol,location:{file:e,line:i,column:o}};r.set(`${n.symbol}\0${i}\0${o}`,s)}return[...r.values()].sort((n,i)=>n.targetSymbol.localeCompare(i.targetSymbol)||n.location.line-i.location.line||n.location.column-i.location.column)}var Kr=class{compilerHost;sourceFiles=new Map;constructor(t,r,n){let i=t.createCompilerHost(r),o=i.getSourceFile.bind(i);this.compilerHost={...i,getCurrentDirectory:()=>n,getSourceFile:(s,a,c,l)=>{let p=De(s);if(this.sourceFiles.has(p))return this.sourceFiles.get(p);let u=o(s,a,c,l);return this.sourceFiles.set(p,u),u}}}invalidate(t){this.sourceFiles.delete(De(t))}};function po(e,t){let r=e.readConfigFile(t,e.sys.readFile);if(r.error)throw new Error(e.formatDiagnostics([r.error],e.createCompilerHost({})));let n=e.parseJsonConfigFileContent(r.config,e.sys,Yr(t)),i=n.errors.filter(o=>o.code!==18003);if(i.length>0)throw new Error(e.formatDiagnostics(i,e.createCompilerHost({})));return n}function Xr(e){return go(e.packageVersion,e.typescript.version)}function go(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${dl}`}function gl(e,t){return Dt(fo(e,t))||"."}function nt(e,t){if(ul(t))throw new Error(`expected a project-relative path: ${t}`);let r=ne(e,t),n=e.endsWith(zr)?e:`${e}${zr}`;if(r!==e&&!r.startsWith(n))throw new Error(`path escapes the project root: ${t}`);return r}function _t(e){return[...new Set(e.map(Dt))].sort()}function Dt(e){return e.split(zr).join("/").replace(/^\.\//,"")}function De(e){return ne(e)}function uo(e,t){let r=0;for(let n of e.keys())if(hl(n)){try{if(n.getSourceFile()!==t)continue}catch{continue}e.delete(n),r+=1}return r}function hl(e){return!!(e&&typeof e=="object"&&"kind"in e&&"getSourceFile"in e)}var yl=[w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),w("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"}),At("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"}),At("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"}),At("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"}),At("health-semantic-prewarm",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","scope","cliVersion","projectFingerprint","payloadVersion"],stalenessTest:"tests/runtime/cli-support.test.ts",owner:"src/runtime/cli-support.ts"})];function it(e){let t=new Map;return{kind:e.kind,read(r,n,i){let o=!1,s=0,a;if(tr()){let c=Zn(r);if(c){let l=`${c}\0${n}\0${i}`;a=t.get(l),a||(a=rr(["evidence-product-file-read-v1",e.kind,c,n,i]),t.set(l,a))}}return nr("evidence-product.file.read",()=>{let c=ei(r,e.kind,n,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"file",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(r,n,i,o){ti(r,e.kind,n,i,e.serialize(o))},writeBatch(r,n){ri(r,n.map(i=>({kind:e.kind,relativePath:i.relativePath,contentHash:i.contentHash,payload:e.serialize(i.value)})))}}}function jg(e){let t=new Map;return{kind:e.kind,read(r,n,i){let o=!1,s=0,a;if(tr()){let c=`${i}\0${n}`;a=t.get(c),a||(a=rr(["evidence-product-project-read-v1",e.kind,i,n]),t.set(c,a))}return nr("evidence-product.project.read",()=>{let c=ni(r,e.kind,n,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(r,n,i,o){ii(r,e.kind,n,i,e.serialize(o))}}}function ot(e){let t=yl.find(r=>r.kind===e);if(!t)throw new Error(`missing evidence product manifest entry for ${e}`);return t.invalidation}function w(e,t){return{scope:"file",kind:e,invalidation:{scope:"file",...t}}}function At(e,t){return{scope:"project",kind:e,invalidation:{scope:"project",...t}}}import{isAbsolute as Sl,relative as bl}from"path";function C(e){return e.replace(/\\/g,"/")}function Lg(e,t){let r=bl(e,t);return r===""||!r.startsWith("..")&&!Sl(r)}var xl=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function $g(e){let t=e.toLowerCase();return xl.some(r=>t.endsWith(r))}import{createRequire as vl}from"module";var ho=vl(import.meta.url),st,jt;function Il(){if(st!==void 0)return st;try{st=ho("ts-morph")}catch{st=null}return st}function Ug(){if(jt)return jt;let e=Il();if(!e)return"ts-morph:unavailable";let t="unknown";try{t=ho("ts-morph/package.json").version??"unknown"}catch{}return jt=`ts-morph:${t}:typescript:${e.ts.version}`,jt}function Vg(e,t){return t.map(r=>({tsconfigPath:r,project:new e.Project({tsConfigFilePath:r,skipFileDependencyResolution:!0})}))}function Bg(e,t,r){return{language:"typescript",availability:()=>({available:!1,reason:e,tsconfigPath:t,tsconfigPaths:r}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function qg(e,t,r){let n=new Set(r),i=new Map(r.map(o=>[o,[]]));for(let o of e)for(let s of t.get(o.symbolId)??[])n.has(s.file)&&i.get(s.file).push({targetSymbol:o.symbol,location:s});for(let[o,s]of i)i.set(o,El(s));return i}function El(e){let t=new Map;for(let r of e){let{location:n}=r;t.set(`${r.targetSymbol}\0${n.file}\0${n.line}\0${n.column}`,r)}return[...t.values()].sort((r,n)=>r.targetSymbol.localeCompare(n.targetSymbol)||wl(r.location,n.location))}function wl(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.column-t.column}import{existsSync as Zr,readFileSync as en,readdirSync as Cl,statSync as kl}from"fs";import{join as Ae,relative as Tl}from"path";function yo(e){let t=Pl(e)??Dl(e);if(!t||t.length===0)return[];let r=[],n=new Set;for(let i of t)for(let o of Al(e,i)){if(n.has(o))continue;n.add(o);let s=jl(e,o);s&&r.push(s)}return r}function Pl(e){let t=Ae(e,"pnpm-workspace.yaml");if(!Zr(t))return null;try{return Rl(en(t,"utf8"))}catch{return null}}function Rl(e){let t=[],r=!1;for(let n of e.split(/\r?\n/)){let i=Nl(n);if(!r){/^packages\s*:\s*$/.test(i.trim())&&(r=!0);continue}let o=/^\s+-\s*(.+)$/.exec(i);if(o){let s=_l(o[1].trim());s&&t.push(s);continue}if(i.trim()!=="")break}return t}function Nl(e){let t=e.indexOf("#");return t===-1?e:e.slice(0,t)}function _l(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function Dl(e){let t=Ae(e,"package.json");if(!Zr(t))return null;try{let r=JSON.parse(en(t,"utf8"));return r.workspaces?Array.isArray(r.workspaces)?r.workspaces:r.workspaces.packages??[]:null}catch{return null}}function Al(e,t){if(!t||t.startsWith("!")||t.includes("node_modules"))return[];if(!t.includes("*")){let s=Ae(e,t);return Qr(s)?[s]:[]}let r=t.indexOf("*"),n=t.slice(0,r).replace(/\/$/,""),i=t.slice(r+1).replace(/^\//,""),o=Ae(e,n||".");return Qr(o)?Cl(o).map(s=>Ae(o,s,i)).filter(Qr):[]}function Qr(e){try{return kl(e).isDirectory()}catch{return!1}}function jl(e,t){let r=Ae(t,"package.json");if(!Zr(r))return null;try{let n=JSON.parse(en(r,"utf8"));return typeof n.name!="string"||n.name.length===0?null:{name:n.name,relativeDir:Tl(e,t).replace(/\\/g,"/"),exports:n.exports}}catch{return null}}import{createRequire as Fl}from"module";import{existsSync as ge}from"fs";import{basename as So,dirname as R,extname as q,join as j,relative as fe,resolve as b,sep as Ol}from"path";var Ll=ft("indexed-paths",{clearGroups:[]}),Ml=ft("indexed-path-digest",{clearGroups:[]}),$l=x("tsconfig-alias-config",{clearGroups:["whole-project"]}),Wl=x("tsconfig-alias-config-for-dir",{clearGroups:["whole-project"]}),Gl=Fl(import.meta.url),at;function Ul(){if(at!==void 0)return at;try{at=Gl("typescript")}catch{at=null}return at}var Vl=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"],Bl=ft("workspace-packages",{clearGroups:["whole-project"]}),me=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],Ft=[".py",".pyi"],N=[".java",".scala",".kt",".kts"],Ot=[".rs"],Lt=[".rb"],Mt=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],ie=[".cs",".vb"],$t=[".dart"],he=[".php"],je=[".clj",".cljs",".cljc"],Hl=new Set(me),tn=new Set(Ft),bo=new Set(N),rn=new Set(Ot),nn=new Set(Lt),xo=new Set(Mt),vo=new Set(ie),on=new Set($t),Io=new Set(he),Eo=new Set(je),ql=[{extensions:me,lookup:Hl},{extensions:Ft,lookup:tn},{extensions:N,lookup:bo},{extensions:Ot,lookup:rn},{extensions:Lt,lookup:nn},{extensions:Mt,lookup:xo},{extensions:ie,lookup:vo},{extensions:$t,lookup:on},{extensions:he,lookup:Io},{extensions:je,lookup:Eo}];function z(e,t){return t.has(q(e).toLowerCase())}function zl(e){return z(e,tn)}function Jl(e){return z(e,bo)}function Kl(e){return z(e,rn)}function Yl(e){return z(e,nn)}function Xl(e){return z(e,xo)}function Ql(e){return z(e,vo)}function wo(e){return q(e).toLowerCase()===".vb"}function Zl(e){return z(e,on)}function ep(e){return z(e,Io)}function tp(e){return z(e,Eo)}function sn(e){let t=q(e).toLowerCase();for(let r of ql)if(r.lookup.has(t))return r.extensions;return me}function rp(e){return Jl(e)||Ql(e)||ep(e)}function oe(e,t,r){return zl(t)?Fe(e,t,r):Kl(t)?J(e,t,r):Yl(t)?Wt(e,t,r):Xl(t)?Gt(e,t,r):rp(t)?y(e,r.replace(/\\/g,"."),sn(t)):Zl(t)?Ut(e,t,r):tp(t)?an(e,r):np(e,t,r)}function np(e,t,r){if(!r.startsWith(".")&&!r.startsWith("/"))return ip(e,t,r)??sp(e,r);let n=R(j(e.config.projectRoot,t)),i=b(n,r),o=K(e);for(let s of ln(i)){let a=C(fe(e.config.projectRoot,s));if(o.has(a)||ge(s))return a}return C(fe(e.config.projectRoot,i))}function ip(e,t,r){let n=dp(e,t);if(!n)return null;let i=K(e);for(let o of op(n,r)){let s=b(n.baseUrl,o);for(let a of ln(s)){let c=C(fe(e.config.projectRoot,a));if(i.has(c)||ge(a))return c}}return null}function op(e,t){let r=[];for(let[n,i]of Object.entries(e.paths)){let o=n.indexOf("*");if(o===-1){if(t!==n)continue;r.push(...i);continue}let s=n.slice(0,o),a=n.slice(o+1);if(!t.startsWith(s)||!t.endsWith(a)||t.length<s.length+a.length)continue;let c=t.slice(s.length,t.length-a.length);for(let l of i)r.push(l.includes("*")?l.replace("*",c):l)}return r}function sp(e,t){let r=cp(ap(e),t);if(!r)return null;let n=K(e);for(let i of lp(r)){let o=b(e.config.projectRoot,r.pkg.relativeDir,i);for(let s of ln(o)){let a=C(fe(e.config.projectRoot,s));if(n.has(a)||ge(s))return a}}return null}function ap(e){return Bl.get(e,()=>yo(e.config.projectRoot))}function cp(e,t){let r=null;for(let n of e){let i=null;t===n.name?i="":t.startsWith(`${n.name}/`)&&(i=t.slice(n.name.length+1)),i!==null&&(!r||n.name.length>r.pkg.name.length)&&(r={pkg:n,subpath:i})}return r}function lp(e){let t=[],r=pp(e.pkg.exports,e.subpath);if(r){let n=up(r);n&&t.push(n)}return t.push(e.subpath?`src/${e.subpath}`:"src/index"),t}function pp(e,t){if(!e||typeof e!="object")return null;let r=t===""?".":`./${t}`;return Co(e[r])}function Co(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;let t=e;for(let r of["types","import","default","require","node"]){let n=Co(t[r]);if(n)return n}return null}function up(e){let t=e.replace(/^\.\//,"");return t.startsWith("dist/")?`src/${t.slice(5)}`:null}function dp(e,t){let r=C(R(t));return Wl.get(e,r,()=>fp(e,r))}function fp(e,t){let r=Ul();if(!r)return null;let n=b(e.config.projectRoot),i=b(n,t);for(;i===n||i.startsWith(n+Ol);){for(let s of Vl){let a=j(i,s);if(!ge(a))continue;let c=$l.get(e,a,()=>mp(r,a));if(c)return c}let o=R(i);if(o===i)break;i=o}return null}function mp(e,t){try{let r=e.readConfigFile(t,e.sys.readFile);if(r.error||!r.config)return null;let n=e.parseJsonConfigFileContent(r.config,e.sys,R(t)),i=n.options.paths;return!i||Object.keys(i).length===0?null:{baseUrl:n.options.baseUrl?b(R(t),n.options.baseUrl):R(t),paths:i}}catch{return null}}function Fe(e,t,r){let n=K(e),i;if(r.startsWith(".")){let o=r.match(/^(\.+)(.*)$/);if(!o)return null;let s=o[1].length,a=o[2].replace(/^\./,""),c=R(j(e.config.projectRoot,t));for(let l=1;l<s;l++)c=R(c);i=a?b(c,a.replace(/\./g,"/")):c}else i=b(e.config.projectRoot,r.replace(/\./g,"/"));for(let o of gp(i)){let s=C(fe(e.config.projectRoot,o));if(n.has(s)||ge(o))return s}return null}function J(e,t,r){if(!r)return null;let n=r.replace(/\s+as\s+.+$/,"").trim();if(!n.startsWith("crate::")&&!n.startsWith("self::")&&!n.startsWith("super::"))return null;let i=R(j(e.config.projectRoot,t)),o;return n.startsWith("crate::")?o=b(e.config.projectRoot,"src",n.slice(7).replace(/::/g,"/")):n.startsWith("self::")?o=b(i,n.slice(6).replace(/::/g,"/")):o=b(R(i),n.slice(7).replace(/::/g,"/")),cn(e,hp(o))}function Wt(e,t,r){let n=R(j(e.config.projectRoot,t)),i=b(n,r);return cn(e,yp(i))}function Gt(e,t,r){let n=R(j(e.config.projectRoot,t)),i=[b(n,r),b(e.config.projectRoot,r),b(e.config.projectRoot,"include",r),b(e.config.projectRoot,"src",r)];return cn(e,i)}function y(e,t,r){let n=K(e),i=t.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=i.replace(/\./g,"/"),s=i.split(".").pop()??i;for(let c of r){let l=`${o}${c}`,p=[...n].find(u=>u.endsWith(l));if(p)return p}for(let c of r){let l=[...n].find(p=>So(p)===`${s}${c}`);if(l)return l}let a=[...n].filter(c=>r.includes(q(c).toLowerCase())).filter(c=>c.includes(`/${o}/`)||c.includes(`/${s}/`)).sort((c,l)=>c.localeCompare(l));return a.length===1?a[0]:null}function Ut(e,t,r){let n=K(e);if(r.startsWith("package:")){let s=r.slice(8),a=s.indexOf("/");if(a<0)return null;let c=s.slice(a+1),l=C(c.startsWith("lib/")?c:`lib/${c}`);return n.has(l)?l:null}let i=R(j(e.config.projectRoot,t)),o=b(i,r);for(let s of Sp(o)){let a=C(fe(e.config.projectRoot,s));if(n.has(a)||ge(s))return a}return null}function an(e,t){let r=t.replace(/-/g,"_").replace(/\./g,"/"),n=K(e);for(let i of je){let o=`${r}${i}`,s=[...n].find(a=>a.endsWith(o));if(s)return s}for(let i of je){let o=[...n].find(s=>So(s)===`${r.split("/").pop()}${i}`);if(o)return o}return null}function gp(e){let t=q(e);return tn.has(t)?[e]:[`${e}.py`,`${e}.pyi`,j(e,"__init__.py"),j(e,"__init__.pyi")]}function cn(e,t){let r=K(e);for(let n of t){let i=C(fe(e.config.projectRoot,n));if(r.has(i)||ge(n))return i}return null}function hp(e){let t=q(e);return rn.has(t)?[e]:[`${e}.rs`,j(e,"mod.rs")]}function yp(e){let t=q(e);return nn.has(t)?[e]:[`${e}.rb`,j(e,"index.rb")]}function Sp(e){let t=q(e);return on.has(t)?[e]:[`${e}.dart`,e]}function ln(e){let t=q(e),r=new Set;if(t){r.add(e);for(let n of me)r.add(e.slice(0,-t.length)+n)}else for(let n of me)r.add(`${e}${n}`),r.add(j(e,`index${n}`));return[...r]}function K(e){return Ll.get(e,()=>new Set(_n(e,{includeIgnored:!1}).map(C)))}function pn(e){return Ml.get(e,()=>St([...K(e)].sort().join(`
107
- `)))}import{readFileSync as bp}from"fs";import{join as xp}from"path";var vp=x("source-text",{clearGroups:["whole-project","source-file"]}),Ip=x("source-lines",{clearGroups:["whole-project","source-file"]});function _(e,t){let r=t.replace(/\\/g,"/");return vp.get(e,r,()=>{let n=xp(e.config.projectRoot,r);try{return bp(n,"utf-8")}catch(i){if(Ep(i))return"";throw i}})}function Ep(e){return typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}function lh(e,t){let r=t.replace(/\\/g,"/");return Ip.get(e,r,()=>{let n=_(e,r);return n?n.split(`
108
- `):[]})}import{basename as Xo}from"path";function ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function wp(e){return e.replace(/'''[\s\S]*?'''/g,se).replace(/"""[\s\S]*?"""/g,se).replace(/#.*$/gm,se).replace(/\/\/.*$/gm,se).replace(/\/\*[\s\S]*?\*\//g,se).replace(/`(?:\\[\s\S]|[^`])*`/g,se).replace(/'(?:\\.|[^'\\\r\n])*'/g,se).replace(/"(?:\\.|[^"\\\r\n])*"/g,se)}function se(e){return e.replace(/[^\r\n]/g," ")}var gh=Ce("stripped-lines",{clearGroups:["whole-project","source-file"]});Rn({name:"stripped-source-singleton",groups:["whole-project","source-file"],clearAll:()=>{Vt=null,ct=""},clearFile:()=>{Vt=null,ct=""}});var Vt=null,ct="";function Cp(e){return Vt===e||(Vt=e,ct=wp(e)),ct}function ae(e,t,r){let n=Cp(e);return`${n.slice(0,t)}${" ".repeat(r-t)}${n.slice(r)}`}function k(e,t){return new RegExp(`\\b${ye(t)}\\b`,"m").test(e)}function Oe(e,t){let r=new Set,n=new RegExp(`\\b${ye(t)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let i of e.matchAll(n)){let o=i[1];o&&r.add(o)}return[...r]}function un(e){let t=0;for(let r of e)r==="("&&(t+=1),r===")"&&(t-=1);return t}import{extname as ko}from"path";var kp={".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 Se(e){return kp[ko(e).toLowerCase()]??null}function be(e){return ko(e).toLowerCase()===".vue"}import{createRequire as Tp}from"module";var v=Tp(import.meta.url),Bt=null,To=!1;function Pp(){if(To)return null;if(Bt)return Bt;try{return Bt=v("tree-sitter"),Bt}catch{return To=!0,null}}var Po=new Map,Ht=new Set;function Rp(e){if(Ht.has(e))return null;let t=Po.get(e);if(t)return t;let r;try{switch(e){case"rust":r=v("tree-sitter-rust");break;case"typescript":r=v("tree-sitter-typescript").typescript;break;case"tsx":r=v("tree-sitter-typescript").tsx;break;case"javascript":r=v("tree-sitter-javascript");break;case"python":r=v("tree-sitter-python");break;case"java":r=v("tree-sitter-java");break;case"kotlin":r=v("tree-sitter-kotlin");break;case"scala":r=v("tree-sitter-scala");break;case"ruby":r=v("tree-sitter-ruby");break;case"c":r=v("tree-sitter-c");break;case"cpp":r=v("tree-sitter-cpp");break;case"csharp":r=v("tree-sitter-c-sharp");break;case"php":r=v("tree-sitter-php").php;break;case"vb":{let n=v("tree-sitter-vb-dotnet");r=n.language??n;break}case"clojure":return Ht.add(e),null}}catch{return Ht.add(e),null}return Po.set(e,r),r}var Ro=new Map;function Np(e){let t=Ro.get(e);if(t)return t;let r=Rp(e);if(!r)return null;let n=Pp();if(!n)return null;let i=new n;try{i.setLanguage(r)}catch{return Ht.add(e),null}return Ro.set(e,i),i}function _p(e,t){return e.parse(n=>n>=t.length?null:t.slice(n,Math.min(t.length,n+16384)))}function dn(e,t){let r=Np(e);if(!r)return null;try{return _p(r,t)}catch{return null}}import{posix as fn}from"path";import{parse as Dp}from"@vue/compiler-sfc";var Ch=Nn("vue-sfc-units");function Ap(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function jp(e){let t=e?.toLowerCase();return!t||t==="js"||t==="javascript"||t==="jsx"?"javascript":t==="ts"||t==="typescript"?"typescript":t==="tsx"?"tsx":null}function Do(e,t,r){let n={relativePath:t,template:null,scripts:[],styles:[],customBlocks:[],errors:[]};if(!r)return n;let i;try{i=Dp(r,{filename:t})}catch(s){return n.errors.push(_o(s)),n}n.errors.push(...i.errors.map(_o));let{descriptor:o}=i;return o.template&&(n.template=qt(e,t,"template",o.template)),o.script&&n.scripts.push(No(e,t,o.script,!1)),o.scriptSetup&&n.scripts.push(No(e,t,o.scriptSetup,!0)),n.styles=o.styles.map(s=>qt(e,t,"style",s)),n.customBlocks=o.customBlocks.map(s=>qt(e,t,"custom",s)),n.errors.push(...[n.template,...n.scripts,...n.styles,...n.customBlocks].flatMap(s=>s?.errors??[])),n}function No(e,t,r,n){let i=qt(e,t,"script",r);return{...i,kind:"script",setup:n,astLanguage:jp(i.lang)}}function qt(e,t,r,n){let i=Op(n.attrs),o=typeof i.lang=="string"?i.lang:null,s=typeof i.src=="string"?i.src:typeof n.src=="string"?n.src:void 0;if(s){let c=Fp(t,s);if(!c)return{kind:r,ownerPath:t,sourcePath:t,external:!0,src:s,attrs:i,lang:o,body:"",startLine:0,endLine:0,errors:[`Could not resolve Vue ${r} block source: ${s}`]};let l=_(e,c),p=l?Math.max(0,l.split(`
109
- `).length-1):0;return{kind:r,ownerPath:t,sourcePath:c,external:!0,src:s,attrs:i,lang:o,body:l,startLine:0,endLine:p,errors:l?[]:[`Vue ${r} block source not found: ${c}`]}}let a=Math.max(0,n.loc.start.line-1);return{kind:r,ownerPath:t,sourcePath:t,external:!1,attrs:i,lang:o,body:n.content,startLine:a,endLine:Math.max(a,n.loc.end.line-1),errors:[]}}function Fp(e,t){let r=t.split(/[?#]/,1)[0];if(!r||r.startsWith("/")||r.includes("://"))return null;let n=Ap(fn.normalize(fn.join(fn.dirname(e),r)));return n===".."||n.startsWith("../")?null:n}function Op(e){return{...e}}function _o(e){return e instanceof Error?e.message:String(e)}function zt(e,t,r){let i=Do(e,t,r).scripts.filter(s=>s.astLanguage&&s.body.length>0),o=i[0]?.astLanguage;return o?{body:i.map(s=>`${`
110
- `.repeat(s.startLine)}${s.body}`).join(`
111
- `),startLine:0,language:o}:null}var Ao=Ce("ast-trees",{clearGroups:["whole-project","source-file"]});function V(e,t){if(be(t))return Lp(e,t);let r=Se(t);if(!r)return null;let n=_(e,t);return n?Ao.get(e,t,n,()=>dn(r,n)):null}function Lp(e,t){let r=_(e,t);return r?Ao.get(e,t,r,()=>{let n=zt(e,t,r);if(!n)return null;let i=`
112
- `.repeat(n.startLine)+n.body;return dn(n.language,i)}):null}function jo(e,t){let r=Mp(e,t);if(!r)return null;let n=xe(r);return n?{calleeLeaf:n,memberAccess:$p(r),line:e.startPosition.row}:null}function Mp(e,t){if(t==="rust")return e.type==="call_expression"?e.childForFieldName("function")??e.namedChild(0):e.type==="macro_invocation"?e.childForFieldName("macro")??e.namedChild(0):null;if(t==="python")return e.type!=="call"?null:e.childForFieldName("function")??e.namedChild(0);if(t==="typescript"||t==="tsx"||t==="javascript"){if(e.type==="call_expression")return e.childForFieldName("function")??e.namedChild(0);if(e.type==="new_expression")return e.childForFieldName("constructor")??e.namedChild(0)}return null}function $p(e){switch(e.type){case"field_expression":case"member_expression":case"attribute":return!0;default:return!1}}function xe(e){switch(e.type){case"identifier":case"type_identifier":case"field_identifier":case"property_identifier":case"shorthand_property_identifier":return e.text;case"field_expression":case"member_expression":case"attribute":{let t=e.namedChild(e.namedChildCount-1);return t?xe(t):null}case"generic_function":{let t=e.childForFieldName("function")??e.namedChild(0);return t?xe(t):null}case"scoped_identifier":{let t=e.childForFieldName("name")??e.namedChild(e.namedChildCount-1);return t?xe(t):null}case"super":case"self":case"this":return null;default:return null}}function lt(e){return e.type==="comment"||e.type==="line_comment"||e.type==="block_comment"}var Wp=new Set(["function_declaration","method_definition","method_signature","function_signature"]);function $o(e,t){let r=Up(e,t);if(r)return{name:r.name,startLine:r.definitionNode.startPosition.row,endLine:r.definitionNode.endPosition.row,paramCount:Lo(r.functionNode),params:Fo(r.functionNode),paramsEndLine:Oo(r.functionNode),isLiteralPassthrough:Mo(r.functionNode,t)};if(!Gp(e.type,t))return null;let n=e.childForFieldName("name")??e.namedChildren.find(i=>i.type==="identifier"||i.type==="property_identifier");return n?{name:n.text,startLine:e.startPosition.row,endLine:e.endPosition.row,paramCount:Lo(e),params:Fo(e),paramsEndLine:Oo(e),isLiteralPassthrough:Mo(e,t)}:null}function Wo(e){return e.namedChildren.find(t=>t.type==="parameters"||t.type==="formal_parameters")}function Fo(e){let t=Wo(e);if(!t)return[];let r=[];for(let n of t.namedChildren){if(lt(n))continue;if(n.type==="identifier"){r.push({name:n.text,simple:!0});continue}let i=n.namedChildren.some(a=>a.type.endsWith("_modifier"))||/^\s*(?:public|private|protected|readonly|override)\b/.test(n.text),o=n.childForFieldName("pattern");if(!i&&o&&o.type==="identifier"){r.push({name:o.text,simple:!0});continue}let s=n.namedChildren.find(a=>a.type==="identifier");r.push({name:o?.type==="identifier"?o.text:s?.text??"",simple:!1})}return r}function Oo(e){let t=Wo(e);return t?t.endPosition.row:e.startPosition.row}function Gp(e,t){return t==="rust"?e==="function_item"||e==="function_signature_item":t==="python"?e==="function_definition":t==="typescript"||t==="tsx"||t==="javascript"?Wp.has(e):!1}function Up(e,t){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript")return null;if(e.type==="variable_declarator"){let r=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1);return!r||!n||n.type!=="arrow_function"&&n.type!=="function_expression"?null:{name:r.text,definitionNode:e,functionNode:n}}if(e.type==="public_field_definition"){let r=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1);return!r||!n||n.type!=="arrow_function"&&n.type!=="function_expression"?null:{name:r.text,definitionNode:e,functionNode:n}}return null}function Lo(e){let t=e.namedChildren.find(n=>n.type==="parameters"||n.type==="formal_parameters");if(!t)return 0;let r=0;for(let n of t.namedChildren)lt(n)||(r+=1);return r}function Mo(e,t){let r=e.namedChildren.find(u=>u.type==="block"||u.type==="statement_block");if(!r)return!1;let n=r.namedChildren.filter(u=>!lt(u));if(n.length!==1)return!1;let i=n[0],o=null;if(i.type==="return_statement"||i.type==="expression_statement"?o=i.namedChild(0)??null:t==="rust"&&(i.type==="call_expression"||i.type==="macro_invocation")&&(o=i),!o)return!1;let s=t==="python"?"call":"call_expression";if(o.type!==s)return!1;let a=o.namedChildren.find(u=>u.type==="arguments"||u.type==="argument_list");if(!a)return!1;let c=a.namedChildren.filter(u=>!lt(u)),l=e.namedChildren.find(u=>u.type==="parameters"||u.type==="formal_parameters");if(!l)return!1;let p=[];for(let u of l.namedChildren){if(u.type==="identifier"){p.push(u.text);continue}let d=u.namedChildren.find(m=>m.type==="identifier");d&&p.push(d.text)}if(c.length!==p.length)return!1;for(let u=0;u<p.length;u+=1){let d=c[u];if(d.type!=="identifier"||d.text!==p[u])return!1}return!0}var Vp=new Set(["identifier","type_identifier","field_identifier"]),Bp=new Set(["identifier"]),Hp=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","shorthand_property_identifier_pattern"]),qp=new Set(["rust","python"]),zp=/\{([^{}]*)\}/g,Jp=/\b([A-Za-z_][\w]*)\b/g;function Go(e,t){return Kp(t).has(e.type)}function Uo(e,t){return qp.has(t)&&e.type==="string_content"}function mn(e){let t=0;for(let n of e.values()){let i=n[n.length-1];i!==void 0&&i>t&&(t=i)}let r=new Array(t+1);for(let n=0;n<=t;n+=1)r[n]=new Set;for(let[n,i]of e)for(let o of i)r[o].add(n);return r}function Kp(e){return e==="rust"?Vp:e==="python"?Bp:Hp}function Vo(e,t){let r=e.startPosition.row;for(let n of e.text.matchAll(zp)){let i=n[1]??"";for(let o of i.matchAll(Jp))o[1]&&t(o[1],r)}}var Yp=[/\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],Xp=/^#!?\[\s*serde\s*\(/,Qp=/^#!?\[\s*schemars\s*\(/,Zp=/^#!?\[\s*validate\s*\(/,eu=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function Bo(e,t,r){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript"||e.type!=="call_expression")return;let n=e.childForFieldName("function")??e.namedChild(0);if(!n)return;let i=xe(n);if(!i||!eu.has(i))return;let o=e.namedChildren.find(c=>c.type==="arguments");if(!o)return;let s=o.namedChild(0);if(!s||s.type!=="string")return;let a=s.namedChildren.find(c=>c.type==="string_fragment");a&&r.add(a.text)}function Ho(e,t){let r=Xp.test(e),n=Qp.test(e),i=Zp.test(e);if(!(!r&&!n&&!i))for(let o of Yp){o.lastIndex=0;let s;for(;(s=o.exec(e))!==null;){let a=s[1],c=a.split("::").pop()??a;c==="is_none"&&/\bOption\b/.test(a)||c==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(a)||c&&t.add(c)}}}function qo(e,t){let r=new Map,n=(s,a)=>{if(s===a)return;let c=r.get(s);c||(c=new Set,r.set(s,c)),c.add(a)},i=t==="python"?new Set(["identifier"]):new Set(["type_identifier"]),o=(s,a)=>{let c=l=>{i.has(l.type)&&l.text!==a&&n(l.text,a);for(let p of l.children)c(p)};for(let l of s.children)c(l)};if(t==="rust")for(let s of e.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let a=s.namedChildren.find(l=>l.type==="type_identifier")?.text;if(!a)continue;let c=s.namedChildren.find(l=>l.type==="field_declaration_list"||l.type==="enum_variant_list"||l.type==="ordered_field_declaration_list");c&&o(c,a),s.type==="type_item"&&o(s,a)}else if(t==="python")for(let s of e.rootNode.descendantsOfType("class_definition")){let a=s.namedChildren.find(p=>p.type==="identifier")?.text;if(!a)continue;let c=s.childForFieldName("superclasses");c&&o(c,a);let l=s.namedChildren.find(p=>p.type==="block");if(l)for(let p of l.descendantsOfType("type"))for(let u of p.descendantsOfType("identifier"))u.text!==a&&n(u.text,a)}else for(let s of e.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let a=s.namedChildren.find(c=>c.type==="type_identifier")?.text;a&&o(s,a)}return r}var tu=new Map([["defn","function"],["defn-","function"],["defmacro","macro"],["defmacro-","macro"],["defmethod","method"]]),gn=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 zo(e){let t=[],r=[],n=[],i=new Map,o=[],s=0,a=0,c=(l,p)=>{let u=i.get(l);if(!u){i.set(l,[p]);return}u[u.length-1]!==p&&u.push(p)};for(;a<e.length;){let l=e[a];if(l===`
113
- `){s+=1,a+=1;continue}if(/\s|,/.test(l)){a+=1;continue}if(l===";"){a=Kt(e,a);continue}if(l==='"'){let h=ut(e,a,s);s=h.line,a=h.index;continue}if(l==="("||l==="["||l==="{"){o.push({kind:l,startLine:s,endLine:s,headTokens:[],tokens:[],children:[]}),a+=1;continue}if(l===")"||l==="]"||l==="}"){let h=o.pop();h&&(h.endLine=s,ru(h,{callables:t,callSites:r,clojureMembers:n,recordIdentifier:c}),o[o.length-1]?.children.push(h)),a+=1;continue}if(hn(l)){a+=1;continue}let p=s,u=a;for(;a<e.length&&!yn(e[a]);)a+=1;let d=e.slice(u,a);if(!d)continue;let m={text:d,line:p};nu(o[o.length-1],m),c(F(d),p)}return{language:"clojure",callables:t,callSites:r,clojureMembers:n,typeContainerMap:new Map,identifierLineMap:i,identifiersByLine:cu(i),fileIdentifiers:new Set(i.keys()),rustAttrReferencedNames:new Set,crossLanguageDispatchNames:new Set}}function ru(e,t){if(e.kind!=="("||e.headTokens.length===0)return;let r=e.headTokens[0],n=F(r.text),i=tu.get(r.text);if(i){let s=e.headTokens[1];if(s){let a=F(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(iu(e,t),!n||gn.has(r.text)||gn.has(n)||n.startsWith(":"))return;let o=au(r.text);t.callSites.push({calleeLeaf:o.leaf,calleeQualifier:o.qualifier,calleeText:o.text,memberAccess:!1,line:r.line})}function nu(e,t){e&&(e.headTokens.length<2&&e.headTokens.push(t),e.tokens.length<200&&e.tokens.push(t))}function iu(e,t){let r=F(e.tokens[0]?.text??"");if(r==="defprotocol"){let n=F(e.tokens[1]?.text??"");if(!n)return;for(let i of Jt(e))pt(t,n,"protocol",i,"protocol-method");return}if(r==="defrecord"||r==="deftype"){let n=F(e.tokens[1]?.text??"");if(!n)return;let i=r==="defrecord"?"record":"type",o=r==="defrecord"?"record-method":"type-method";for(let s of Jt(e))pt(t,n,i,s,o);return}if(r==="extend-type"){let n=F(e.tokens[1]?.text??"");if(!n)return;for(let i of Jt(e))pt(t,n,"extension",i,"extension-method");return}if(r==="extend-protocol"){let n=F(e.tokens[1]?.text??"");for(let i of Jt(e)){n&&pt(t,n,"extension",i,"extension-method");let o=su(e,i.startLine);o&&o!==n&&pt(t,o,"extension",i,"extension-method")}}}function Jt(e){return e.children.filter(ou)}function ou(e){if(e.kind!=="(")return!1;let t=F(e.tokens[0]?.text??"");return!!(t&&!gn.has(t)&&!t.startsWith(":"))}function pt(e,t,r,n,i){let o=n.tokens[0],s=F(o?.text??"");!o||!s||(e.recordIdentifier(s,o.line),e.clojureMembers.push({ownerName:t,ownerKind:r,memberName:s,memberKind:i,startLine:n.startLine,endLine:n.endLine}))}function su(e,t){let r=null;for(let n=2;n<e.tokens.length;n+=1){let i=e.tokens[n];if(i.line>t)break;let o=F(i.text);o&&!o.startsWith(":")&&(r=o)}return r}function F(e){return e.replace(/^#?['`~@]+/,"").split("/").pop()?.replace(/^\./,"")??""}function au(e){let t=e.replace(/^#?['`~@]+/,""),r=t.lastIndexOf("/"),n=F(t);if(r<=0)return{leaf:n,text:t};let i=t.slice(0,r);return{leaf:n,qualifier:i,text:t}}function Kt(e,t){let r=t;for(;r<e.length&&e[r]!==`
114
- `;)r+=1;return r}function ut(e,t,r){let n=t+1,i=r;for(;n<e.length;){let o=e[n];if(o==="\\"){n+=2;continue}if(o===`
115
- `&&(i+=1),n+=1,o==='"')break}return{index:n,line:i}}function hn(e){return e==="'"||e==="`"||e==="~"||e==="@"||e==="^"||e==="#"}function yn(e){return/\s|,/.test(e)||e==="("||e===")"||e==="["||e==="]"||e==="{"||e==="}"||e==='"'||e===";"}function cu(e){let t=[];for(let[r,n]of e)for(let i of n)t[i]??=new Set,t[i].add(r);return t}var Jo=3,lu=Ce("source-facts",{clearGroups:["whole-project","source-file"]}),Sn=it({kind:"source-facts",invalidation:ot("source-facts"),serialize:fu,deserialize:mu});function Ko(e,t){return pu(e,t).facts}function pu(e,t){let r=_(e,t);if(!r)return{facts:null};let n=uu(e,t,r);return n?lu.get(e,t,r,()=>du(e,t,n,r)):{facts:null}}function uu(e,t,r){return be(t)?zt(e,t,r)?.language??null:Se(t)}function du(e,t,r,n){let i=We(e,t,n),o=Sn.read(e,t,i);if(o&&o.language===r)return{facts:o};if(r==="clojure"){let c=zo(n);return Sn.write(e,t,i,c),{facts:c}}let s=V(e,t);if(!s)return{facts:null,unavailable:{language:r,reason:"parser-unavailable"}};let a=gu(s,r);return Sn.write(e,t,i,a),{facts:a}}function fu(e){let t={version:Jo,language:e.language,callables:e.callables,callSites:e.callSites,clojureMembers:e.clojureMembers,typeContainerMap:[...e.typeContainerMap.entries()].map(([r,n])=>[r,[...n]]),identifierLineMap:[...e.identifierLineMap.entries()],rustAttrReferencedNames:[...e.rustAttrReferencedNames],crossLanguageDispatchNames:[...e.crossLanguageDispatchNames]};return JSON.stringify(t)}function mu(e){try{let t=JSON.parse(e);if(t.version!==Jo||t.language==="clojure"&&(t.clojureMembers===void 0||t.callSites.some(n=>n.calleeText===void 0)))return null;let r=new Map(t.identifierLineMap);return{language:t.language,callables:t.callables,callSites:t.callSites,clojureMembers:t.clojureMembers??[],typeContainerMap:new Map(t.typeContainerMap.map(([n,i])=>[n,new Set(i)])),identifierLineMap:r,identifiersByLine:mn(r),fileIdentifiers:new Set(r.keys()),rustAttrReferencedNames:new Set(t.rustAttrReferencedNames),crossLanguageDispatchNames:new Set(t.crossLanguageDispatchNames)}}catch{return null}}function gu(e,t){let r=[],n=[],i=new Set,o=new Set,s=new Map,a=(l,p)=>{let u=s.get(l);if(!u){s.set(l,[p]);return}u[u.length-1]!==p&&u.push(p)},c=l=>{let p=$o(l,t);p&&r.push(p);let u=jo(l,t);u&&n.push(u),Bo(l,t,o),t==="rust"&&(l.type==="attribute_item"||l.type==="inner_attribute_item")&&Ho(l.text,i),Go(l,t)&&a(l.text,l.startPosition.row),Uo(l,t)&&Vo(l,a);for(let d of l.children)c(d)};return c(e.rootNode),{language:t,callables:r,callSites:n,clojureMembers:[],typeContainerMap:qo(e,t),identifierLineMap:s,identifiersByLine:mn(s),fileIdentifiers:new Set(s.keys()),rustAttrReferencedNames:i,crossLanguageDispatchNames:o}}var hu=new Set(["rust","typescript","tsx","javascript","python","clojure"]);function yu(e,t){let r=Ko(e,t);return!r||!hu.has(r.language)?null:r.callables.map(n=>({name:n.name,startLine:n.startLine,endLine:n.endLine}))}function Yo(e,t){return e.split(t).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")}var Su=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]);function T(e){let t=[],r=0,n=0;for(let i=0;i<e.length;i++){let o=e[i];(o==="{"||o==="["||o==="(")&&r++,(o==="}"||o==="]"||o===")")&&r--,o===","&&r===0&&(t.push(e.slice(n,i)),n=i+1)}return t.push(e.slice(n)),t}function D(e,t){for(let r of e.namedChildren)if(r.type===t)return r;return null}function S(e,t){let r=new Set,n=(i,o)=>{let s=o||t.has(i.type);!s&&Su.has(i.type)&&r.add(i.text);for(let a of i.children)n(a,s)};return n(e.rootNode,!1),r}function G(e,t,r,n,i,o,s){return{importedName:i,localName:o,sourcePath:s??y(e,n,sn(t)),kind:"named",used:k(r,o),usedMembers:[]}}function g(e,t,r,n,i="named",o={}){return{importedName:e,localName:t,sourcePath:r,kind:i,used:n.has(t),usedMembers:[],isTypeOnly:o.isTypeOnly}}function Y(e,t,r,n,i="named",o=[],s={}){return{importedName:e,localName:t,sourcePath:r,kind:i,used:n,usedMembers:o,isTypeOnly:s.isTypeOnly}}function ve(e,t){return{importedName:e,localName:null,sourcePath:t,kind:"side-effect",used:!0,usedMembers:[]}}function Ie(e,t,r={}){return{importedName:e,localName:r.localName??null,sourcePath:t,kind:"namespace",used:r.used??!0,usedMembers:r.usedMembers??[],isTypeOnly:r.isTypeOnly}}function O(e,t,r){let n=[];for(let i of e.matchAll(t)){let o=i[0];if(!o||typeof i.index!="number")continue;let s=ae(e,i.index,i.index+o.length);for(let a of r(i,s))n.push(a)}return n}function L(e,t,r,n){let i=V(e,t);if(i){let o=r(i);if(o)return o}return n()}function Yt(e,t,r,n){let i=V(e,t),o=Se(t),s=o?r[o]:void 0;return i&&s?s(i):n()}function Qo(e,t,r){return L(e,t,n=>xu(e,t,n),()=>bu(e,t,r))}function bu(e,t,r){return O(r,/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm,(n,i)=>{let o=n[1]?.trim();if(!o)return[];let s=Xo(o).replace(/\.[^.]+$/,"");return[Y(o,s,Gt(e,t,o),k(i,s))]})}function xu(e,t,r){let n=S(r,new Set(["preproc_include"])),i=[];for(let o of r.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(p=>p.type==="string_content")?.text??c.text.replace(/^"|"$/g,"");break}}if(!s)continue;let a=Xo(s).replace(/\.[^.]+$/,"");i.push(g(s,a,Gt(e,t,s),n))}return i}var vu=new Set([":require",":require-macros",":use"]),vn=String.raw`A-Za-z0-9_$*+!?.<>=-`;function es(e,t,r){let n=Du(r);if(!n)return[];let i=_u(r,n.start,n.end),o=[];for(let s of n.children.slice(2)){if(s.type!=="list"||s.children.length===0)continue;let a=M(s.children[0]);if(a){if(vu.has(a)){for(let c of wu(s.children.slice(1)))o.push(...Eu(e,c,i));continue}if(a===":import")for(let c of ku(s.children.slice(1)))o.push(c)}}return o}function Iu(e){return e.type==="list"&&M(e.children[0])==="ns"}function Eu(e,t,r){let n=an(e,t.namespace),i=t.alias??t.namespace,o=Pu(r,i),s=[{importedName:t.namespace,localName:i,sourcePath:n,kind:"namespace",used:t.refers.length>0||t.referAll||o.length>0||Ru(r,t.namespace),usedMembers:o}];t.referAll&&s.push({importedName:"*",localName:null,sourcePath:n,kind:"side-effect",used:!0,usedMembers:[]});for(let a of t.refers)s.push({importedName:a,localName:a,sourcePath:n,kind:"named",used:Nu(r,a),usedMembers:[]});return s}function wu(e){return e.flatMap(t=>Xt(t,null))}function Xt(e,t){if(e.type==="atom")return e.text.startsWith(":")?[]:[{namespace:xn(t,e.text),alias:null,refers:[],referAll:!1}];if(e.type==="vector")return e.children.length>0&&M(e.children[0])===null?e.children.flatMap(r=>Xt(r,t)):Cu(e,t);if(e.type==="list"&&e.children.length>0){let r=M(e.children[0]);return r?!r||r.startsWith(":")?[]:e.children.slice(1).flatMap(n=>Xt(n,xn(t,r))):e.children.flatMap(n=>Xt(n,t))}return[]}function Cu(e,t){let r=M(e.children[0]);if(!r||r.startsWith(":"))return[];let n={namespace:xn(t,r),alias:null,refers:[],referAll:!1};for(let i=1;i<e.children.length;i+=1){let o=M(e.children[i]);if(!o?.startsWith(":"))continue;let s=e.children[i+1];if((o===":as"||o===":as-alias")&&s){n.alias=M(s),i+=1;continue}o===":refer"&&s&&(M(s)===":all"?n.referAll=!0:(s.type==="vector"||s.type==="list")&&n.refers.push(...s.children.map(M).filter(Tu)),i+=1)}return[n]}function ku(e){let t=[];for(let r of e){if(r.type==="atom"){let i=r.text.split(".").pop()??r.text;t.push(Y(i,i,null,!0));continue}if(r.type!=="vector")continue;let n=M(r.children[0]);if(n)for(let i of r.children.slice(1)){let o=M(i);o&&t.push(Y(`${n}.${o}`,o,null,!0))}}return t}function xn(e,t){return e?`${e}.${t}`:t}function M(e){return e?.type==="atom"?e.text:null}function Tu(e){return!!(e&&!e.startsWith(":"))}function Pu(e,t){let r=new Set,n=new RegExp(`${In()}${ye(t)}\\s*/\\s*([${vn}]+)`,"g");for(let i of e.matchAll(n)){let o=i[1];o&&r.add(o)}return[...r]}function Ru(e,t){return new RegExp(`${In()}${ye(t)}\\s*/`,"m").test(e)}function Nu(e,t){return new RegExp(`${In()}${ye(t)}(?![${vn}])`,"m").test(e)}function In(){return`(?<![${vn}])`}function _u(e,t,r){let n="",i=0;for(;i<e.length;){if(i>=t&&i<r){n+=e[i]===`
116
- `?`
117
- `:" ",i+=1;continue}let o=e[i];if(o===";"){let s=Kt(e,i);n+=Zo(e.slice(i,s)),i=s;continue}if(o==='"'){let s=ut(e,i,0).index;n+=Zo(e.slice(i,s)),i=s;continue}n+=o,i+=1}return n}function Du(e){let t=0;for(;t<e.length&&(t=En(e,t),!(t>=e.length));){let r=Qt(e,t);if(!r){t+=1;continue}if(Iu(r.form))return r.form;t=r.index}return null}function Qt(e,t){let r=En(e,t);if(e.startsWith("#?@",r)||e.startsWith("#?",r))return Au(e,r);if(e.startsWith("#_",r)){let i=Qt(e,r+2);return i?{form:{type:"atom",text:"",start:r,end:i.index},index:i.index}:null}for(;hn(e[r]);)r+=1;let n=e[r];return n?n==="("?bn(e,r,"list",")"):n==="["?bn(e,r,"vector","]"):n==="{"?bn(e,r,"map","}"):n==='"'?{form:{type:"atom",text:"",start:r,end:ut(e,r,0).index},index:ut(e,r,0).index}:Fu(e,r):null}function Au(e,t){let r=e.startsWith("#?@",t)?3:2,n=Qt(e,t+r);return n?{form:{type:"list",children:n.form.type==="list"||n.form.type==="vector"||n.form.type==="map"?ju(n.form.children):[],start:t,end:n.index},index:n.index}:null}function ju(e){let t=[];for(let r=0;r<e.length;r+=2){let n=M(e[r]),i=e[r+1];n?.startsWith(":")&&i&&t.push(i)}return t}function bn(e,t,r,n){let i=[],o=t+1;for(;o<e.length;){if(o=En(e,o),e[o]===n)return{form:{type:r,children:i,start:t,end:o+1},index:o+1};let s=Qt(e,o);if(!s){o+=1;continue}s.form.type==="atom"&&s.form.text===""||i.push(s.form),o=s.index}return{form:{type:r,children:i,start:t,end:e.length},index:e.length}}function Fu(e,t){let r=t;for(;r<e.length&&!yn(e[r]);)r+=1;return{form:{type:"atom",text:e.slice(t,r),start:t,end:r},index:r}}function En(e,t){let r=t;for(;r<e.length;){let n=e[r];if(/\s|,/.test(n)){r+=1;continue}if(n===";"){r=Kt(e,r);continue}break}return r}function Zo(e){return e.replace(/[^\r\n]/g," ")}function ts(e,t,r){let n=[];for(let i of r.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=ae(r,i.index,i.index+a.length);n.push({importedName:o,localName:s,sourcePath:Ut(e,t,o),kind:s?"namespace":"side-effect",used:s?k(c,s):!0,usedMembers:s?Oe(c,s):[]})}return n}function rs(e,t,r){let n=[];for(let i of r.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=i[1]?.trim();o&&n.push({specifier:o,sourcePath:Ut(e,t,o)})}return n}function ns(e,t,r){return Yt(e,t,{csharp:n=>Lu(e,t,n),vb:n=>Ou(e,t,n)},()=>{let n=wo(t)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;return O(r,n,(i,o)=>{let s=i[1]?.trim();if(!s)return[];let[a,c]=s.split(/\s*=\s*/),l=!!c,p=(l?c:a)?.trim()??s,u=p.split(".").pop()??p,d=l?a?.trim()??u:u;return[G(e,t,o,p,u,d,y(e,p,ie))]})})}function Ou(e,t,r){let n=S(r,new Set(["imports_statement"])),i=[];for(let o of r.rootNode.descendantsOfType("imports_statement")){let s=o.namedChildren.filter(d=>d.type==="namespace_name");if(s.length===0)continue;let a=s[s.length-1],c=s.length>1?s[0]:null,l=a.text,p=l.split(".").pop()??l,u=c?.text??p;i.push(g(p,u,y(e,l,ie),n,c?"namespace":"named"))}return i}function Lu(e,t,r){let n=S(r,new Set(["using_directive"])),i=[];for(let o of r.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,p=l.split(".").pop()??l,u=a?.text??p;i.push(g(p,u,y(e,l,ie),n,a?"namespace":"named"))}return i}var Mu=x("vue-non-script-identifiers",{clearGroups:["whole-project","source-file"]});function is(e,t){return Mu.get(e,t,()=>{let r=new Set,n=_(e,t);if(!n)return r;let o=n.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))r.add(s[0]);return r})}function wn(e,t,r){return L(e,t,n=>Wu(e,t,n),()=>$u(e,t,r))}function $u(e,t,r){return Xu(r).flatMap(n=>Qu(e,t,n.clause,n.specifier,n.start,n.end,r))}function Wu(e,t,r){let n=Gu(e,t,r),i=[];for(let o of r.rootNode.descendantsOfType("import_statement"))i.push(...Uu(e,t,r,o,n));return i}function Gu(e,t,r){let n=S(r,new Set(["import_statement"]));if(be(t))for(let i of is(e,t))n.add(i);return n}function Uu(e,t,r,n,i){let o=zu(n);if(!o)return[];let s=oe(e,t,o),a=D(n,"import_clause");return a?Vu(r,a,s,i,Ju(n.text)):[ve("*",s)]}function Vu(e,t,r,n,i){let o=[];for(let s of t.namedChildren)if(s.type==="identifier")o.push(Bu(s.text,r,n,i));else if(s.type==="namespace_import"){let a=Hu(e,s,r,n,i);a&&o.push(a)}else s.type==="named_imports"&&o.push(...qu(s,r,n,i));return o}function Bu(e,t,r,n){return g("default",e,t,r,"default",{isTypeOnly:n})}function Hu(e,t,r,n,i){let s=D(t,"identifier")?.text??"";if(!s)return null;let a=Yu(e,s);return Ie("*",r,{localName:s,usedMembers:a,isTypeOnly:i,used:a.length>0||n.has(s)})}function qu(e,t,r,n){let i=[];for(let o of e.namedChildren){if(o.type!=="import_specifier")continue;let s=o.namedChild(0),a=o.namedChild(1);if(!s)continue;let c=s.text,l=a?.text??c;i.push(g(c,l,t,r,"named",{isTypeOnly:n||Ku(o.text)}))}return i}function zu(e){let t=D(e,"string");if(!t)return null;let r=D(t,"string_fragment");return r?r.text:null}function Ju(e){return/^\s*import\s+type\b/.test(e)}function Ku(e){return/^\s*type\b/.test(e.trim())}function Yu(e,t){let r=new Set;for(let n of e.rootNode.descendantsOfType("member_expression")){let i=n.namedChild(0),o=n.namedChild(1);!i||!o||i.type!=="identifier"||i.text!==t||(o.type==="property_identifier"||o.type==="identifier")&&r.add(o.text)}return[...r]}function Xu(e){let t=[],r=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(r)){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 n=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(n)){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 Qu(e,t,r,n,i,o,s){let a=oe(e,t,n),c=ae(s,i,o);return r?Zu(r).map(p=>({...p,sourcePath:a})).map(p=>{if(p.kind==="namespace"){let u=Oe(c,p.localName);return Ie(p.importedName,p.sourcePath,{localName:p.localName,usedMembers:u,used:u.length>0||k(c,p.localName),isTypeOnly:p.isTypeOnly})}return p.kind==="side-effect"?ve(p.importedName,p.sourcePath):Y(p.importedName,p.localName??"",p.sourcePath,p.localName?k(c,p.localName):!1,p.kind,[],{isTypeOnly:p.isTypeOnly})}):[ve("*",a)]}function Zu(e){let t=e.trim(),r=/^type\b/.test(t),n=t.replace(/^type\s+/,""),[i,o]=ed(n),s=[];return i&&s.push(...os(i,r)),o&&s.push(...os(o,r)),s}function os(e,t){let r=e.trim();if(!r)return[];if(r.startsWith("{")){let n=r.slice(1,-1).trim();return n?T(n).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 r.startsWith("* as ")?[{importedName:"*",localName:r.slice(5).trim(),kind:"namespace",isTypeOnly:t}]:[{importedName:"default",localName:r,kind:"default",isTypeOnly:t}]}function ed(e){let t=0;for(let r=0;r<e.length;r++){let n=e[r];if(n==="{"&&t++,n==="}"&&t--,n===","&&t===0)return[e.slice(0,r).trim(),e.slice(r+1).trim()]}return[e.trim(),null]}function Cn(e,t,r){let n=V(e,t);return n?sd(e,t,n):td(e,t,r)}function td(e,t,r){return[...rd(e,t,r),...nd(e,t,r),...id(e,t,r)]}function rd(e,t,r){let n=[],i=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=o[2]??"",c=T(s).map(u=>od(u.trim())).filter(u=>!!u),l=Le(r,o.index),p=Le(r,o.index+o[0].length-1);n.push({kind:"named",sourcePath:oe(e,t,a),names:c,startLine:l,endLine:p})}return n}function nd(e,t,r){let n=[],i=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[2]??"",a=Le(r,o.index),c=Le(r,o.index+o[0].length-1);n.push({kind:"star-as",sourcePath:oe(e,t,s),names:[],startLine:a,endLine:c})}return n}function id(e,t,r){let n=[],i=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=Le(r,o.index),c=Le(r,o.index+o[0].length-1);n.push({kind:"star",sourcePath:oe(e,t,s),names:[],startLine:a,endLine:c})}return n}function od(e){if(!e)return null;let t=e.replace(/^type\s+/,"").trim();if(!t)return null;let r=t.match(/^(\w+)\s+as\s+(\w+)$/);if(r)return r[2]??null;let n=t.match(/^(\w+)$/);return n?n[1]??null:null}function Le(e,t){let r=0;for(let n=0;n<t&&n<e.length;n++)e.charCodeAt(n)===10&&r++;return r}function sd(e,t,r){let n=[];for(let i of r.rootNode.descendantsOfType("export_statement")){let o=ad(e,t,i);if(o===void 0)continue;let s=i.startPosition.row,a=i.endPosition.row,c=cd(i,o,s,a);n.push(c)}return n}function ad(e,t,r){let n=D(r,"string");if(!n)return;let i=D(n,"string_fragment");if(i)return oe(e,t,i.text)}function cd(e,t,r,n){let i=D(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:r,endLine:n}}return D(e,"namespace_export")?{kind:"star-as",sourcePath:t,names:[],startLine:r,endLine:n}:{kind:"star",sourcePath:t,names:[],startLine:r,endLine:n}}function ss(e,t,r){return Yt(e,t,{java:n=>ld(e,t,n),kotlin:n=>pd(e,t,n),scala:n=>ud(e,t,n)},()=>O(r,/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm,(n,i)=>{let o=n[1]?.trim();return o?dd(e,t,o,i):[]}))}function ld(e,t,r){let n=S(r,new Set(["import_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("import_declaration")){let s=o.children.some(u=>u.type==="asterisk"),c=o.namedChildren.find(u=>u.type==="scoped_identifier")??o.namedChildren.find(u=>u.type==="identifier");if(!c)continue;let l=c.text;if(s){i.push(Ie("*",y(e,l,N)));continue}let p=l.split(".").pop()??l;i.push(g(p,p,y(e,l,N),n))}return i}function pd(e,t,r){let n=S(r,new Set(["import_header","import_list"])),i=[];for(let o of r.rootNode.descendantsOfType("import_header")){let s=o.namedChildren.find(m=>m.type==="identifier");if(!s)continue;let a=o.namedChildren.some(m=>m.type==="wildcard_import"),c=o.namedChildren.find(m=>m.type==="import_alias");if(a){i.push(Ie("*",y(e,s.text,N)));continue}let l=s.text,p=l.split(".").pop()??l,d=c?.namedChild(0)?.text??p;i.push(g(p,d,y(e,l,N),n))}return i}function ud(e,t,r){let n=S(r,new Set(["import_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("import_declaration")){let s=o.namedChildren.find(u=>u.type==="namespace_selectors"||u.type==="namespace_wildcard"),a=o.namedChildren.filter(u=>u!==s&&(u.type==="identifier"||u.type==="stable_identifier")),c=a.map(u=>u.text).join(".");if(!c)continue;if(s?.type==="namespace_wildcard"){i.push(Ie("*",y(e,c,N)));continue}if(s?.type==="namespace_selectors"){for(let u of s.namedChildren)if(u.type==="arrow_renamed_identifier"){let[d,m]=u.namedChildren;if(!d)continue;let h=d.text,Ee=m?.text??h;if(h==="_")continue;i.push(g(h,Ee,y(e,`${c}.${h}`,N),n))}else if(u.type==="identifier"){let d=u.text;i.push(g(d,d,y(e,`${c}.${d}`,N),n))}continue}let l=a[a.length-1]?.text??c,p=a.slice(0,-1).map(u=>u.text).join(".")||c;i.push(g(l,l,y(e,p&&a.length>1?`${p}.${l}`:c,N),n))}return i}function dd(e,t,r,n){if(r.includes("{")&&r.includes("}")){let i=r.slice(0,r.indexOf("{")).replace(/\.$/,"").trim(),o=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim();return T(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.includes("=>")?a.split(/\s*=>\s*/):a.split(/\s+as\s+/),p=c?.trim();if(!p||p==="_")return[];let u=(l??p.split(".").pop()??p).trim(),d=p==="_"?i:`${i}.${p}`.replace(/\.\./g,".");return[G(e,t,n,d,p,u)]})}return[G(e,t,n,r,r.split(".").pop()??r,r.split(".").pop()??r)]}function cs(e,t,r){return L(e,t,n=>fd(e,t,n),()=>O(r,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,i)=>{let o=n[1]?.trim();return o?T(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.split(/\s+as\s+/i),p=c?.trim()??a,u=p.split("\\").pop()??p,d=(l??u).trim();return[G(e,t,i,p,u,d,y(e,p.replace(/\\/g,"."),he))]}):[]}))}function fd(e,t,r){let n=S(r,new Set(["namespace_use_declaration"])),i=[],o=(s,a,c)=>{i.push(g(a,c,y(e,s.replace(/\\/g,"."),he),n))};for(let s of r.rootNode.descendantsOfType("namespace_use_declaration")){let a=s.namedChildren.find(c=>c.type==="namespace_use_group");if(a){let c=s.namedChildren.find(l=>l.type==="namespace_name")?.text??"";for(let l of a.namedChildren){if(l.type!=="namespace_use_clause")continue;let{importedName:p,localName:u,qualified:d}=as(l,c);p&&o(d,p,u)}continue}for(let c of s.namedChildren){if(c.type!=="namespace_use_clause")continue;let{importedName:l,localName:p,qualified:u}=as(c,"");l&&o(u,l,p)}}return i}function as(e,t){let r=e.namedChildren.find(l=>l.type==="qualified_name"),n=e.namedChildren.filter(l=>l.type==="name"),i="";r?i=r.text:n.length>=1&&(i=n[0].text);let o=r&&n.length>0?n[n.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 ps(e,t,r){return L(e,t,n=>md(e,t,n),()=>hd(r).flatMap(n=>Sd(e,t,n,r)))}function md(e,t,r){let n=S(r,new Set(["import_statement","import_from_statement"])),i=[];for(let o of r.rootNode.descendantsOfType("import_statement"))for(let s of o.namedChildren){let a=ls(s);if(!a)continue;let c=Fe(e,t,a.qualifiedName);i.push({importedName:a.qualifiedName,localName:a.localName,sourcePath:c,kind:"namespace",used:n.has(a.localName),usedMembers:[]})}for(let o of r.rootNode.descendantsOfType("import_from_statement")){let s=o.namedChild(0);if(!s)continue;let a=gd(s);if(a===null)continue;let c=Fe(e,t,a);for(let l=1;l<o.namedChildCount;l+=1){let p=o.namedChild(l);if(p.type==="wildcard_import"){i.push({importedName:"*",localName:null,sourcePath:c,kind:"side-effect",used:!0,usedMembers:[]});continue}let u=ls(p);u&&i.push({importedName:u.qualifiedName,localName:u.localName,sourcePath:c,kind:"named",used:n.has(u.localName),usedMembers:[]})}}return i}function ls(e){if(e.type==="aliased_import"){let t=e.namedChild(0),r=e.namedChild(1);return!t||!r?null:{qualifiedName:t.text,localName:r.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 gd(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let t=D(e,"import_prefix")?.text??"",r=D(e,"dotted_name")?.text??"";return`${t}${r}`}return null}function hd(e){let t=e.split(`
118
- `),r=[],n=0;for(let i=0;i<t.length;i++){let o=t[i],s=o.trimStart(),a=n;if(n+=o.length+1,!s.startsWith("import ")&&!s.startsWith("from "))continue;let c=o,l=a+o.length,p=un(o);for(;i+1<t.length&&(p>0||c.trimEnd().endsWith("\\"));){i++;let d=t[i];c+=`
119
- ${d}`,l+=1+d.length,p+=un(d),n+=d.length+1}let u=yd(c);u&&r.push({...u,start:a,end:l})}return r}function yd(e){let t=e.replace(/\\\s*\n/g," ").trim();if(t.startsWith("import "))return{kind:"import",module:null,clause:t.slice(7).trim()};let r=t.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!r)return null;let n=r[2].trim();return n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1).trim()),{kind:"from",module:r[1],clause:n}}function Sd(e,t,r,n){let i=ae(n,r.start,r.end),o=r.clause.replace(/\n/g," ").trim();if(r.kind==="import")return T(o).flatMap(c=>{let l=c.trim().replace(/,$/,"");if(!l)return[];let[p,u]=l.split(/\s+as\s+/),d=p.trim(),m=(u??d.split(".")[0]??d).trim(),h=Fe(e,t,d),Ee=Oe(i,m);return[{importedName:d,localName:m,sourcePath:h,kind:"namespace",used:k(i,m)||Ee.length>0,usedMembers:Ee}]});let s=r.module?Fe(e,t,r.module):null,a=[];for(let c of T(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[p,u]=l.split(/\s+as\s+/),d=(u??p).trim();a.push({importedName:p.trim(),localName:d,sourcePath:s,kind:"named",used:k(i,d),usedMembers:[]})}return a}import{basename as bd}from"path";function us(e,t,r){return L(e,t,n=>vd(e,t,n),()=>xd(e,t,r))}function xd(e,t,r){return O(r,/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm,(n,i)=>{let o=n[1],s=n[2];if(!o||!s)return[];let a=o==="require_relative"?Wt(e,t,s):null;if(a){let c=ds(s);return[Y(c,c,a,k(i,c))]}return[ve(s,a)]})}function vd(e,t,r){let n=S(r,new Set([])),i=[],o=new Set(["require","require_relative","load"]);for(let s of r.rootNode.descendantsOfType("call")){let a=s.namedChild(0);if(!a||a.type!=="identifier"||!o.has(a.text))continue;let l=s.namedChildren.find(m=>m.type==="argument_list")?.namedChild(0);if(!l||l.type!=="string")continue;let u=l.namedChildren.find(m=>m.type==="string_content")?.text;if(!u)continue;let d=a.text==="require_relative"?Wt(e,t,u):null;if(d){let m=ds(u);i.push(g(m,m,d,n))}else i.push(ve(u,d))}return i}function ds(e){return Yo(bd(e).replace(/\.[^.]+$/,""),/_/)}function fs(e,t,r){return L(e,t,n=>Id(e,t,n),()=>O(r,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,i)=>{let o=n[1]?.trim();return o?Ed(e,t,o,i):[]}))}function Id(e,t,r){let n=S(r,new Set(["use_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("use_declaration")){let s=o.namedChild(0);if(s)for(let a of dt(s,"")){if(!a.importedName||a.importedName==="*")continue;let c=J(e,t,a.qualifiedName)??J(e,t,a.qualifiedName.split("::").slice(0,-1).join("::"));i.push(g(a.importedName,a.localName,c,n))}}return i}function dt(e,t){switch(e.type){case"identifier":case"super":case"crate":{let r=e.text;return[{qualifiedName:Zt(t,r),importedName:r,localName:r}]}case"self":{let r=t.split("::").filter(Boolean).pop()??"self";return[{qualifiedName:t||"self",importedName:r,localName:r}]}case"scoped_identifier":{let r=e.text,n=r.split("::").pop()??r;return[{qualifiedName:Zt(t,r),importedName:n,localName:n}]}case"scoped_use_list":{let r=e.namedChild(0),n=e.namedChild(1);if(!r||!n)return[];let i=Zt(t,r.text),o=[];for(let s of n.namedChildren)o.push(...dt(s,i));return o}case"use_list":{let r=[];for(let n of e.namedChildren)r.push(...dt(n,t));return r}case"use_as_clause":{let r=e.namedChild(0),n=e.namedChild(1);if(!r||!n)return[];let i=dt(r,t),o=n.text;return i.map(s=>({...s,localName:o}))}case"use_wildcard":{let r=e.namedChild(0),n=r?r.text:"";return[{qualifiedName:Zt(t,`${n}::*`),importedName:"*",localName:"*"}]}default:return[]}}function Zt(e,t){return e?t?`${e}::${t}`:e:t}function Ed(e,t,r,n){let i=r.trim();if(i.includes("{")&&i.includes("}")){let p=i.slice(0,i.indexOf("{")).replace(/::$/,"").trim(),u=i.slice(i.indexOf("{")+1,i.lastIndexOf("}")).trim();return T(u).flatMap(d=>{let m=d.trim();if(!m)return[];if(m==="self"){let er=p.split("::").filter(Boolean).pop();return er?[G(e,t,n,p,er,er)]:[]}let[h,Ee]=m.split(/\s+as\s+/),we=h?.trim();if(!we)return[];let Ss=(Ee??we.split("::").pop()??we).trim(),bs=`${p}::${we}`.replace(/::::/g,"::");return[G(e,t,n,bs,we.split("::").pop()??we,Ss,J(e,t,p))]})}let[o,s]=i.split(/\s+as\s+/),a=o?.trim()??i,c=(s??a.split("::").pop()??a).trim(),l=J(e,t,a)??J(e,t,a.split("::").slice(0,-1).join("::"));return[G(e,t,n,a,a.split("::").pop()??a,c,l)]}function ms(e,t,r){let n=V(e,t);if(n)return wd(e,t,n);let i=[];for(let o of r.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let s=o[1]?.trim();s&&i.push(...kd(e,t,s))}return i}function wd(e,t,r){let n=[];for(let i of r.rootNode.descendantsOfType("use_declaration")){if(!Cd(i))continue;let o=i.namedChildren.find(s=>s.type!=="visibility_modifier");if(o)for(let s of dt(o,""))s.importedName&&n.push(kn(e,t,s.qualifiedName))}return n}function Cd(e){for(let t of e.children)if(t.type==="visibility_modifier"&&t.text.startsWith("pub"))return!0;return!1}function kd(e,t,r){let n=r.trim();if(n.includes("{")&&n.includes("}")){let i=n.slice(0,n.indexOf("{")).replace(/::$/,"").trim(),o=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim();return T(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[kn(e,t,l)]})}return[kn(e,t,n)]}function kn(e,t,r){return{specifier:r,sourcePath:J(e,t,r)??J(e,t,r.split("::").slice(0,-1).join("::"))}}function ce({language:e,extensions:t,imports:r,parseImports:n}){return{language:e,extensions:t,capabilities:{imports:r},parseImports:n}}function gs(e,t){let r=t.toLowerCase();for(let n of e)for(let i of n.extensions)if(r.endsWith(i))return n;return null}var Td={language:"javascript",extensions:me,capabilities:{imports:"ast-with-regex-fallback",reExports:"ast-with-regex-fallback"},parseImports:wn,parseReExports:Cn},Pd=ce({language:"python",extensions:Ft,imports:"ast-with-regex-fallback",parseImports:ps}),Rd=ce({language:"jvm",extensions:N,imports:"ast-dispatch-with-regex-fallback",parseImports:ss}),Nd={language:"rust",extensions:Ot,capabilities:{imports:"ast-with-regex-fallback",exports:"ast-with-regex-fallback"},parseImports:fs,parseExports:ms},_d=ce({language:"ruby",extensions:Lt,imports:"ast-with-regex-fallback",parseImports:us}),Dd=ce({language:"c/cpp",extensions:Mt,imports:"ast-with-regex-fallback",parseImports:Qo}),Ad=ce({language:"dotnet",extensions:ie,imports:"ast-dispatch-with-regex-fallback",parseImports:ns}),jd={language:"dart",extensions:$t,capabilities:{imports:"regex-only",exports:"regex-only"},parseImports:ts,parseExports:rs},Fd=ce({language:"php",extensions:he,imports:"ast-with-regex-fallback",parseImports:cs}),Od=ce({language:"clojure",extensions:je,imports:"regex-only",parseImports:es}),Ld=[Td,Pd,Rd,Nd,_d,Dd,Ad,jd,Fd,Od];function Tn(e){return gs(Ld,e)}var Pn={clearGroups:["whole-project","source-file"]},Md=x("source-imports",Pn),LS=x("source-exports",Pn),$d=x("source-reexports",Pn),hs=it({kind:"source-imports",invalidation:ot("source-imports"),serialize:Wd,deserialize:Gd}),ys=it({kind:"source-reexports",invalidation:ot("source-reexports"),serialize:Ud,deserialize:Vd});function MS(e,t){let r=C(t);return $d.get(e,r,()=>{let n=Tn(r);if(!n?.parseReExports)return[];let i=_(e,r);if(!i)return[];let o=We(e,r,i),s=pn(e),a=ys.read(e,r,o);if(a?.resolutionFingerprint===s)return a.reExports;let c=n.parseReExports(e,r,i);return ys.write(e,r,o,{resolutionFingerprint:s,reExports:c}),c})}function $S(e,t){let r=C(t);return Md.get(e,r,()=>{let n=Tn(r);if(!n)return[];let i=_(e,r);if(!i)return[];let o=We(e,r,i),s=pn(e),a=hs.read(e,r,o);if(a?.resolutionFingerprint===s)return a.imports;let c=n.parseImports(e,r,i);return hs.write(e,r,o,{resolutionFingerprint:s,imports:c}),c})}function Wd(e){return JSON.stringify(e)}function Gd(e){try{let t=JSON.parse(e);return!Re(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.imports)?null:{resolutionFingerprint:t.resolutionFingerprint,imports:t.imports}}catch{return null}}function Ud(e){return JSON.stringify(e)}function Vd(e){try{let t=JSON.parse(e);return!Re(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.reExports)?null:{resolutionFingerprint:t.resolutionFingerprint,reExports:t.reExports}}catch{return null}}export{jn as a,Ps as b,Jd as c,Fn as d,ke as e,Jn as f,hr as g,Xn as h,St as i,We as j,Zn as k,Hf as l,it as m,jg as n,ot as o,_ as p,lh as q,V as r,pu as s,yu as t,Lg as u,yo as v,Al as w,oe as x,Re as y,vr as z,ye as A,MS as B,$S as C,of as D,sf as E,Vs as F,af as G,cf as H,Bs as I,lf as J,pf as K,uf as L,df as M,xl as N,$g as O,Il as P,Ug as Q,Vg as R,Bg as S,qg as T,Yf as U,Xf as V,Ma as W,Qf as X,nm as Y,cm as Z,mm as _,gm as $,If as aa,Ef as ba,Wn as ca,fr as da,gr as ea,wf as fa,Cm as ga,km as ha,Tm as ia,Pm as ja,Fm as ka,Om as la,Lm as ma,Mm as na,Gi as oa,Bm as pa,Lr as qa,yg as ra,Sg as sa,bg as ta,Ze as ua,xg as va,vg as wa,Ig as xa,Zc as ya,el as za,Tg as Aa,Pg as Ba,ga as Ca,Rf as Da,Nf as Ea,_f as Fa};
120
- //# sourceMappingURL=chunk-U267E6YN.js.map
@@ -1,9 +0,0 @@
1
- import{a as _}from"./chunk-P5XHIJHI.js";import{d as P,v as M,x as v}from"./chunk-M2TRDR25.js";import{execFileSync as U}from"child_process";var j=2e3,S=50,J=64,Y=8,V=3,W=2160*60*60,X=/\b(?:fix(?:es|ed)?|bug|regression|hotfix)\b/i,Z=3,Q=/#\d+|\b[A-Z][A-Z0-9]+-\d+\b/g,q=/^([a-z][a-z0-9-]+)(?:\([^)]+\))?!?:/i;function ee(e){let t=P(e,{clearGroups:["whole-project"]});return(n,i)=>{let r=H(n.config.projectRoot);if(!r)return null;let o=t.has(n)?t.get(n,()=>({head:"",value:null})):null;return o&&o.head===r?o.value:(t.invalidate(n),t.get(n,()=>({head:r,value:i(n.config.projectRoot,r)})).value)}}function F(e){let t=P(e,{clearGroups:["whole-project"]});return(n,i,r)=>{let o=H(n.config.projectRoot);if(!o)return null;let a=t.has(n)?t.get(n,()=>({head:"",values:new Map})):null;(!a||a.head!==o)&&t.invalidate(n);let c=t.get(n,()=>({head:o,values:new Map}));if(c.values.has(i))return c.values.get(i)??null;let u=r(n.config.projectRoot,o);return c.values.set(i,u),u}}var te=F("git-commit-history");function ne(e,t={}){let n=t.historyMode??"bounded";return{capability:i=>ie(e,i),commitHistory:()=>x(e,n),fileChurn:()=>se(e,n),changeAmplification:()=>ae(e,n),trackedFiles:()=>le(e),fileAddRecords:()=>me(e,n),coChangePairs:(i={})=>be(e,i,n),coChangePairsForFiles:(i,r={})=>L(e,i,r,n),directionalCoChangePairsForFiles:(i,r={})=>ye(e,i,r,n)}}function x(e,t="bounded"){return te(e,y(t),(n,i)=>re(n,i,t))}function ie(e,t){let n=H(e.config.projectRoot);return n?{slot:t,available:!0,head:n}:{slot:t,available:!1,head:null,reason:"git history is unavailable for this project"}}function H(e){try{return C(e,["rev-parse","HEAD"]).trim()||null}catch{return null}}function C(e,t){return U("git",["-C",e,...t],{encoding:"utf-8",maxBuffer:64*1024*1024,stdio:["ignore","pipe","ignore"]})}function re(e,t,n){let i;try{i=C(e,["log","--no-merges","--name-only",...R(n),"--pretty=format:%x01%H%x00%ct%x00%s"])}catch{return null}return{head:t,...w(i,S)}}function oe(e){return X.test(e.subject)}function se(e,t){let n=x(e,t);if(!n)return null;let i=new Map;for(let r of n.commits){let o=oe(r);for(let a of r.files){let c=i.get(a)??{changes:0,fixChanges:0,lastChangedAt:0};c.changes+=1,o&&(c.fixChanges+=1),r.timestamp>c.lastChangedAt&&(c.lastChangedAt=r.timestamp),i.set(a,c)}}return i}function ae(e,t){let n=x(e,t);if(!n||n.commits.length===0)return null;let i=n.commits.map(r=>r.files.length).filter(r=>r>0).sort((r,o)=>r-o);return i.length===0?null:{medianFilesPerCommit:D(i,.5),p90FilesPerCommit:D(i,.9),commitsAnalyzed:i.length}}function D(e,t){let n=Math.min(e.length-1,Math.floor(e.length*t));return e[n]}var ce=ee("git-tracked-files");function le(e){return ce(e,t=>{try{let n=C(t,["ls-files"]);return new Set(n.split(`
2
- `).map(i=>i.trim()).filter(i=>i!==""))}catch{return null}})}var ue=F("git-file-adds"),O="__git__/file-adds",k=M({kind:"git-file-adds",invalidation:v("git-file-adds"),serialize:ge,deserialize:fe});function _e(e){return ne(e).fileAddRecords()}function me(e,t){let n=y(t);return ue(e,n,(i,r)=>de(e,i,r,t))}function de(e,t,n,i){let r=k.read(e,I(i),n);if(r)return r;let o=he(t,i);return o&&k.write(e,I(i),n,o),o}function ge(e){return JSON.stringify([...e.entries()])}function fe(e){if(!e)return null;try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=new Map;for(let i of t){if(!Array.isArray(i)||i.length!==2||typeof i[0]!="string")return null;let r=i[1];if(!r||typeof r.commitsAgo!="number"||!Number.isFinite(r.commitsAgo)||typeof r.addedAt!="number"||!Number.isFinite(r.addedAt))return null;n.set(i[0],{commitsAgo:r.commitsAgo,addedAt:r.addedAt})}return n}catch{return null}}function he(e,t){let n;try{n=C(e,["log","--no-merges","--find-renames","--name-status",...R(t),"--pretty=format:%x01%H%x00%ct%x00%s"])}catch{return null}let i=new Map,r=new Map,o=-1;for(let a of n.split("")){if(a.trim()==="")continue;o+=1;let c=a.indexOf(`
3
- `),u=c>=0?a.slice(0,c):a,[,m]=u.split("\0"),h=Number(m)||0;if(!(c<0))for(let l of a.slice(c+1).split(`
4
- `)){let s=pe(l);if(!s)continue;if(s.status==="R"&&s.from&&s.to){let p=r.get(s.to)??new Set([s.to]);r.set(s.from,p);continue}if(s.status!=="A"||!s.to)continue;let d={commitsAgo:o,addedAt:h};i.set(s.to,d);for(let p of r.get(s.to)??[])i.set(p,d)}}return i}function pe(e){let t=e.trim().split(" "),n=t[0]??"";if(!n)return null;let i=n[0]??"";if(i==="R"){let o=t[1],a=t[2];return o&&a?{status:i,from:o,to:a}:null}let r=t[1];return r?{status:i,to:r}:null}var z=F("git-co-change-pairs"),Ce=F("git-directional-co-change-pairs");function be(e,t,n){let i=`all\0${y(n)}\0${T(t)}`,r=z(e,i,()=>{let o=x(e,n);return o?G(o,t):null});return r&&[...r]}function L(e,t,n,i){if(t.size===0)return[];let r=`files\0${y(i)}\0${N(t)}\0${T(n)}`,o=z(e,r,()=>{let a=x(e,i);return a?G(a,n,t):null});return o&&[...o]}function ye(e,t,n,i){if(t.size===0)return[];let r=n.maxFilesPerCommit??S;if(t.size>J)return L(e,t,n,i);let o=`directional\0${y(i)}\0${N(t)}\0${T({...n,maxFilesPerCommit:r})}`,a=Ce(e,o,(c,u)=>{let m=Ae(c,u,t,r,i);return m?G(m,n,t):null});return a&&[...a]}function T(e){let t=e.minTogether??4,n=e.minConfidence??.6,i=e.maxFilesPerCommit??S;return`${t}\0${n}\0${i}`}function N(e){return[...e].sort().join("\0")}function G(e,t,n){let{minTogether:i=4,minConfidence:r=.6,maxFilesPerCommit:o=S}=t,a=new Map,c=new Map,u=e.newestAnalyzedAt??0;for(let l of e.commits){let s=[...new Set(l.files)].sort();if(s.length>o)continue;e.newestAnalyzedAt===void 0&&l.timestamp>u&&(u=l.timestamp);let d=Fe(s),p=n===void 0||s.some(g=>n.has(g));for(let g of s)a.set(g,(a.get(g)??0)+1);if(p)for(let g=0;g<s.length;g++)for(let b=g+1;b<s.length;b++){if(n&&!n.has(s[g])&&!n.has(s[b]))continue;let A=`${s[g]}\0${s[b]}`,f=c.get(A)??{together:0,focusedTogether:0,broadTogether:0,lastTogetherAt:0,timestamps:[],subjects:[]};f.together+=1,d?f.broadTogether+=1:f.focusedTogether+=1,l.timestamp>f.lastTogetherAt&&(f.lastTogetherAt=l.timestamp),f.timestamps.push(l.timestamp),f.subjects.push(l.subject),c.set(A,f)}}let m=[],h=u-W;for(let[l,s]of c){let d=s.together;if(d<i)continue;let[p,g]=l.split("\0"),b=a.get(p)??d,A=a.get(g)??d,f=Math.max(d/b,d/A);if(f<r)continue;let $=s.broadTogether/d,E=s.timestamps.filter(K=>K>=h).length;m.push({fileA:p,fileB:g,together:d,confidence:f,changesA:b,changesB:A,focusedTogether:s.focusedTogether,broadTogether:s.broadTogether,broadCommitRatio:$,lastTogetherAt:s.lastTogetherAt,recentTogether:E,commitScope:Pe(s.broadTogether,d),recency:E>0?"recent":"stale",subjectContext:He(s.subjects)})}return m.sort((l,s)=>s.together-l.together||s.confidence-l.confidence||l.fileA.localeCompare(s.fileA)),m}function Ae(e,t,n,i,r){let o;try{o=xe(e,r)}catch{return null}if(o.length===0)return{head:t,commits:[],skippedBulkCommits:0,newestAnalyzedAt:0};let a;try{a=C(e,["log","--no-merges","--format=%H",...R(r),"--",...[...n].sort()])}catch{return null}let c=new Set(o.map(s=>s.hash)),u=a.split(`
5
- `).map(s=>s.trim()).filter(s=>s!==""&&c.has(s)),m=Se(e,o,i);if(u.length===0)return{head:t,commits:[],skippedBulkCommits:0,newestAnalyzedAt:m};let h;try{h=C(e,["show","--no-walk=unsorted","--name-only","--pretty=format:%x01%H%x00%ct%x00%s",...u])}catch{return null}let l=w(h,i);return{head:t,...l,newestAnalyzedAt:m}}function xe(e,t){return C(e,["log","--no-merges","--format=%H%x00%ct",...R(t)]).split(`
6
- `).map(i=>i.trim()).filter(i=>i!=="").map(i=>{let[r,o]=i.split("\0");return{hash:r??"",timestamp:Number(o)||0}}).filter(i=>i.hash!=="")}function R(e){return e==="full"?[]:["-n",String(B())]}function B(){return _(process.env.SCIP_QUERY_GIT_HISTORY_MAX_COMMITS)??j}function y(e){return e==="full"?"full":`bounded:${B()}`}function I(e){let t=y(e);return t===`bounded:${j}`?O:`${O}:${t}`}function Se(e,t,n){for(let r=0;r<t.length;r+=20){let o=t.slice(r,r+20),a;try{a=C(e,["show","--no-walk=unsorted","--name-only","--pretty=format:%x01%H%x00%ct%x00%s",...o.map(u=>u.hash)])}catch{return t[0]?.timestamp??0}let c=w(a,n);if(c.commits.length>0)return c.commits[0].timestamp}return 0}function w(e,t){let n=[],i=0;for(let r of e.split("")){if(r.trim()==="")continue;let o=r.indexOf(`
7
- `),a=o>=0?r.slice(0,o):r,[c,u,m]=a.split("\0");if(!c||!u)continue;let h=o>=0?r.slice(o+1).split(`
8
- `).map(l=>l.trim()).filter(l=>l!==""):[];if(h.length>t){i+=1;continue}n.push({hash:c,timestamp:Number(u)||0,subject:m??"",files:h})}return{commits:n,skippedBulkCommits:i}}function Fe(e){return e.length>=Y?!0:Re(e).size>=V}function Re(e){let t=new Set;for(let n of e){let i=n.indexOf("/");t.add(i>=0?n.slice(0,i):".")}return t}function Pe(e,t){return e===0?"focused":e/t>=.5?"broad-sweep":"mixed"}function He(e){let t=new Set,n=[],i=[];for(let r of e){!i.includes(r)&&i.length<Z&&i.push(r);for(let o of Te(r))t.add(o);for(let o of r.match(Q)??[])n.includes(o)||n.push(o)}return{subjectLabels:[...t].sort(),issueRefs:n,sampleSubjects:i,externalIssueLabelStatus:"unavailable"}}function Te(e){let t=new Set,n=q.exec(e)?.[1]?.toLowerCase();return n&&t.add(Ge(n)),/\b(?:feat|feature)\b/i.test(e)&&t.add("feature"),/\b(?:fix(?:es|ed)?|bug|regression|hotfix)\b/i.test(e)&&t.add("fix"),/\b(?:docs?|documentation|guide|readme)\b/i.test(e)&&t.add("docs"),/\brefactor(?:ing|ed)?\b/i.test(e)&&t.add("refactor"),/\btests?\b/i.test(e)&&t.add("test"),/\b(?:release|version|v\d+\.\d+)\b/i.test(e)&&t.add("release"),/\bchore\b/i.test(e)&&t.add("chore"),/\bbuild\b/i.test(e)&&t.add("build"),/\bci\b/i.test(e)&&t.add("ci"),/\bperf(?:ormance)?\b/i.test(e)&&t.add("perf"),[...t]}function Ge(e){return e==="feat"?"feature":e}export{ne as a,C as b,_e as c};
9
- //# sourceMappingURL=chunk-X566NT42.js.map