@visulima/vis 1.0.0-alpha.29 → 1.0.0-alpha.30

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 (118) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/binx.js +1 -1
  4. package/dist/packem_chunks/bin.js +368 -367
  5. package/dist/packem_chunks/bloom-status.js +1 -1
  6. package/dist/packem_chunks/bloom-sync.js +1 -1
  7. package/dist/packem_chunks/config.js +15 -15
  8. package/dist/packem_chunks/doctor-probe.js +1 -1
  9. package/dist/packem_chunks/fix.js +1 -1
  10. package/dist/packem_chunks/handler.js +1 -1
  11. package/dist/packem_chunks/handler10.js +1 -1
  12. package/dist/packem_chunks/handler11.js +4 -4
  13. package/dist/packem_chunks/handler12.js +1 -1
  14. package/dist/packem_chunks/handler13.js +2 -2
  15. package/dist/packem_chunks/handler14.js +1 -1
  16. package/dist/packem_chunks/handler15.js +1 -1
  17. package/dist/packem_chunks/handler16.js +1 -1
  18. package/dist/packem_chunks/handler17.js +1 -1
  19. package/dist/packem_chunks/handler18.js +1 -1
  20. package/dist/packem_chunks/handler19.js +1 -1
  21. package/dist/packem_chunks/handler2.js +1 -1
  22. package/dist/packem_chunks/handler20.js +1 -1
  23. package/dist/packem_chunks/handler21.js +2 -2
  24. package/dist/packem_chunks/handler22.js +2 -2
  25. package/dist/packem_chunks/handler23.js +1 -1
  26. package/dist/packem_chunks/handler25.js +1 -1
  27. package/dist/packem_chunks/handler26.js +1 -1
  28. package/dist/packem_chunks/handler27.js +1 -1
  29. package/dist/packem_chunks/handler28.js +1 -1
  30. package/dist/packem_chunks/handler29.js +1 -1
  31. package/dist/packem_chunks/handler30.js +7 -7
  32. package/dist/packem_chunks/handler32.js +1 -1
  33. package/dist/packem_chunks/handler33.js +1 -1
  34. package/dist/packem_chunks/handler34.js +4 -4
  35. package/dist/packem_chunks/handler35.js +1 -1
  36. package/dist/packem_chunks/handler36.js +1 -1
  37. package/dist/packem_chunks/handler37.js +5 -5
  38. package/dist/packem_chunks/handler38.js +4 -4
  39. package/dist/packem_chunks/handler39.js +1 -1
  40. package/dist/packem_chunks/handler4.js +1 -1
  41. package/dist/packem_chunks/handler40.js +2 -2
  42. package/dist/packem_chunks/handler41.js +6 -6
  43. package/dist/packem_chunks/handler42.js +13 -13
  44. package/dist/packem_chunks/handler43.js +5 -5
  45. package/dist/packem_chunks/handler44.js +5 -5
  46. package/dist/packem_chunks/handler45.js +1 -1
  47. package/dist/packem_chunks/handler46.js +12 -12
  48. package/dist/packem_chunks/handler47.js +40 -40
  49. package/dist/packem_chunks/handler48.js +15 -15
  50. package/dist/packem_chunks/handler49.js +3 -3
  51. package/dist/packem_chunks/handler5.js +1 -1
  52. package/dist/packem_chunks/handler50.js +9 -9
  53. package/dist/packem_chunks/handler51.js +1 -1
  54. package/dist/packem_chunks/handler52.js +1 -1
  55. package/dist/packem_chunks/handler6.js +1 -1
  56. package/dist/packem_chunks/handler7.js +1 -1
  57. package/dist/packem_chunks/handler8.js +1 -1
  58. package/dist/packem_chunks/handler9.js +1 -1
  59. package/dist/packem_chunks/heal-accept.js +1 -1
  60. package/dist/packem_chunks/heal.js +1 -1
  61. package/dist/packem_chunks/help-command.js +7 -7
  62. package/dist/packem_chunks/index.js +6 -6
  63. package/dist/packem_chunks/keys-refresh.js +1 -1
  64. package/dist/packem_chunks/list.js +2 -2
  65. package/dist/packem_chunks/loader.js +1 -1
  66. package/dist/packem_chunks/loader2.js +1 -1
  67. package/dist/packem_chunks/prune.js +1 -1
  68. package/dist/packem_chunks/run.js +1 -1
  69. package/dist/packem_chunks/status.js +1 -1
  70. package/dist/packem_chunks/sync.js +1 -1
  71. package/dist/packem_chunks/sync2.js +1 -1
  72. package/dist/packem_chunks/tripwire.js +2 -2
  73. package/dist/packem_chunks/verify-lockfile.js +1 -1
  74. package/dist/packem_shared/Table-DoSoazT6-DwnyTUsA.js +12 -0
  75. package/dist/packem_shared/{advisories-DpgSuWDH.js → advisories-BxXiKFbL.js} +1 -1
  76. package/dist/packem_shared/{affected-shas-BkXXecyi.js → affected-shas-BdnlfiV1.js} +1 -1
  77. package/dist/packem_shared/{ai-fix-CfFWatGY.js → ai-fix-BkPUHA0z.js} +1 -1
  78. package/dist/packem_shared/{applyDefaults-DLvOqXGX.js → applyDefaults-BogleaFi.js} +1 -1
  79. package/dist/packem_shared/build-scripts-DE6U8jVq.js +1 -0
  80. package/dist/packem_shared/{cyclonedx-B04lIvwu.js → cyclonedx-BpGVHqSW.js} +1 -1
  81. package/dist/packem_shared/{dependency-scan-B9wTcLxf.js → dependency-scan-BUbOcMwX.js} +1 -1
  82. package/dist/packem_shared/{docker-DxA80dRx.js → docker-CTE3s4LW.js} +1 -1
  83. package/dist/packem_shared/{failure-log-n3j_-w8s.js → failure-log-34Wl3npC.js} +1 -1
  84. package/dist/packem_shared/glob-D_7bct6p-D8itOHsr.js +1 -0
  85. package/dist/packem_shared/{index-BfG9_znI.js → index-D1xC1Y_R.js} +1 -1
  86. package/dist/packem_shared/index-hoWfZmNo.js +30 -0
  87. package/dist/packem_shared/{lifecycle-NHIKDiCh.js → lifecycle-CXaqPGAQ.js} +2 -2
  88. package/dist/packem_shared/lockfile-CrT86D6d.js +1 -0
  89. package/dist/packem_shared/{lockfile-DAuTDwow.js → lockfile-Cu2BH6bl.js} +1 -1
  90. package/dist/packem_shared/{manifests-B7wUR3Rk.js → manifests-BzWpKW8F.js} +1 -1
  91. package/dist/packem_shared/{min-release-age-YyNI7gqV.js → min-release-age-BPVXwPUg.js} +2 -2
  92. package/dist/packem_shared/{native-config-sync-CgRIIRZV.js → native-config-sync-BRZZetn3.js} +8 -8
  93. package/dist/packem_shared/{osv-bloom-BQSIHt5h.js → osv-bloom-DSZcHLsM.js} +1 -1
  94. package/dist/packem_shared/{pm-runner-Ta_yz2uP.js → pm-runner-DmKT2FqF.js} +1 -1
  95. package/dist/packem_shared/{provenance-DoEp2uOo.js → provenance-DkCA8BrN.js} +1 -1
  96. package/dist/packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js +1 -0
  97. package/dist/packem_shared/{registry-keys-CD1xHavV.js → registry-keys-Mixm4eAY.js} +1 -1
  98. package/dist/packem_shared/{resolve-explicit-DpSc7RN2.js → resolve-explicit-D5E72FfN.js} +1 -1
  99. package/dist/packem_shared/runtime-check-CilFOqUU.js +1 -0
  100. package/dist/packem_shared/{s1ngularity-CIX7UcT5.js → s1ngularity-Qxc6tRRI.js} +1 -1
  101. package/dist/packem_shared/{scan-progress-CTVVf9WW.js → scan-progress-DVtCtI2z.js} +1 -1
  102. package/dist/packem_shared/{selectors-BU8aTRQm.js → selectors-DkgYFzdq.js} +1 -1
  103. package/dist/packem_shared/{signatures-BHM7cnqB.js → signatures-byuFrtAH.js} +1 -1
  104. package/dist/packem_shared/{toolchain-juKl-WgV.js → toolchain-DoG6b_G_.js} +2 -2
  105. package/dist/packem_shared/{typosquats-DRKU6d2S.js → typosquats-BiDxQj7R.js} +1 -1
  106. package/dist/packem_shared/{verify-DA80ja1b.js → verify-cLcZwKqe.js} +1 -1
  107. package/dist/packem_shared/{watch-DdR-pFzX.js → watch-DEL0yol9.js} +1 -1
  108. package/dist/packem_shared/{watch-loop-C8csFvRU.js → watch-loop-C31Ar7BX.js} +3 -3
  109. package/index.d.ts +201 -201
  110. package/index.js +26 -26
  111. package/package.json +10 -10
  112. package/dist/packem_shared/Table-3pFgIUZ2-DABgc6rj.js +0 -12
  113. package/dist/packem_shared/build-scripts-D-ysm_bS.js +0 -1
  114. package/dist/packem_shared/glob-MHJQjR39-CQ2GC0b_.js +0 -1
  115. package/dist/packem_shared/index-BDF8gawl.js +0 -29
  116. package/dist/packem_shared/lockfile-CoeFxWAv.js +0 -1
  117. package/dist/packem_shared/readFileSync-4c_c6Qey-6SWMDNdw.js +0 -1
  118. package/dist/packem_shared/runtime-check-Cbtb_Utb.js +0 -1
@@ -1,10 +1,10 @@
1
- var Pt=Object.defineProperty;var T=(e,t)=>Pt(e,"name",{value:t,configurable:!0});import{createRequire as It}from"node:module";import{I as we,e as Me,E as v,T as Re,j as ce,q as Te}from"../packem_shared/Table-3pFgIUZ2-DABgc6rj.js";import{m as Ot,a$ as Nt,a5 as s,a6 as u,n as r,l as We,aG as Ft,aH as Mt,aI as Et,aF as zt,w as L,af as Bt,aJ as Lt,aK as Je,b0 as Vt,r as _t,T as ot,h as Gt,a as lt,c as at,j as Ut,v as Ht,f as Kt,p as d,a7 as N,k as Yt,R as Wt,a4 as ct,s as Jt}from"./bin.js";import{M as J,i as Ae,$ as qt,a as Xt,C as dt}from"../packem_shared/readFileSync-4c_c6Qey-6SWMDNdw.js";import{n as ht,b as ei,j as ti}from"./config.js";import{x as Xe,A as pt,L as ii,F as si,T as ri,U as ni,a as oi,I as li}from"./handler41.js";import{A as gt,y as ai}from"../packem_shared/pm-runner-Ta_yz2uP.js";import{c as ci}from"../packem_shared/runtime-check-Cbtb_Utb.js";import{s as di}from"../packem_shared/scan-progress-CTVVf9WW.js";import{f as ui,l as hi,r as pi}from"../packem_shared/dependency-scan-B9wTcLxf.js";import{n as ft}from"../packem_shared/spinner-C8xs6QZv.js";import{g as gi,r as fi}from"../packem_shared/tabs-xZkm6Y_J.js";import{u as mi}from"../packem_shared/use-measured-height-Lea6TCVD.js";import{s as xi}from"../packem_shared/verify-DA80ja1b.js";const Dt=It(import.meta.url),Se=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,nt=T(e=>{if(typeof Se<"u"&&Se.versions&&Se.versions.node){const[t,i]=Se.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return Se.getBuiltinModule(e)}return Dt(e)},"__cjs_getBuiltinModule"),{statSync:Qt,rmSync:qe,writeFileSync:Zt,readFileSync:ut}=nt("node:fs"),{spawnSync:Ee}=nt("node:child_process");var yi=Object.defineProperty,Pe=T((e,t)=>yi(e,"name",{value:t,configurable:!0}),"r$2");const Ve=Pe(()=>J(Ot(),"doctor"),"getCacheDirectory"),ki=1800*1e3,Qe=Pe(e=>{if(!e)return"";try{return String(Qt(e).mtimeMs)}catch{return""}},"safeMtime"),wi=2,vi=Pe(e=>{const t=JSON.stringify({configMtime:Qe(e.configPath),lockfileMtime:Qe(e.lockfilePath),schema:wi,sections:[...e.sections].toSorted(),socketEnabled:e.socketEnabled,workspaceRoot:e.workspaceRoot});return Nt(Buffer.from(t))},"buildDoctorCacheKey"),bi=Pe(e=>{const t=J(Ve(),`${e}.json`);if(Ae(t))try{const i=ht(t);if(Date.now()-i.createdAt>i.ttlMs){qe(t,{force:!0});return}return{...i.results,sections:new Set(i.results.sections)}}catch{qe(t,{force:!0});return}},"readDoctorCache"),ji=Pe((e,t,i=ki)=>{ei(Ve());const o={createdAt:Date.now(),results:{...t,sections:[...t.sections]},ttlMs:i};Zt(J(Ve(),`${e}.json`),JSON.stringify(o,void 0,2),"utf8")},"writeDoctorCache");var $i=Object.defineProperty,M=T((e,t)=>$i(e,"name",{value:t,configurable:!0}),"n$1");const Oe="orphans",Si=M(()=>{if(process.platform!=="linux")return{id:"inotify",message:"inotify capacity check skipped (not Linux).",status:"skip"};let e;try{const t=ut("/proc/sys/fs/inotify/max_user_watches","utf8").trim(),i=Number.parseInt(t,10);Number.isFinite(i)&&i>0&&(e=i)}catch{return{id:"inotify",message:"Could not read /proc/sys/fs/inotify/max_user_watches.",status:"warn"}}return e===void 0?{id:"inotify",message:"inotify max_user_watches reported a non-numeric value.",status:"warn"}:e<65536?{detail:{maxWatches:e},id:"inotify",message:`inotify watcher limit is ${String(e)} — large monorepos can exhaust this. Bump now with \`sudo sysctl fs.inotify.max_user_watches=524288\` and persist via \`/etc/sysctl.d/99-vis.conf\` so it survives reboot.`,status:"warn"}:{detail:{maxWatches:e},id:"inotify",message:`inotify capacity OK (${String(e)} watches).`,status:"ok"}},"checkInotifyCapacity"),Ci=M(()=>{const e=!!process.stdin.isTTY,t=!!process.stdout.isTTY;return e&&t?{id:"tty",message:"Interactive TTY available — watch keybinds enabled.",status:"ok"}:!e&&!t?{id:"tty",message:"No TTY on stdin/stdout — running in CI / piped mode (keybinds disabled).",status:"skip"}:{detail:{stdin:String(e),stdout:String(t)},id:"tty",message:e?"stdin is a TTY but stdout is not — output is being captured; keybinds still work.":"stdout is a TTY but stdin is not — keybinds disabled (input is piped).",status:"skip"}},"checkTtyAvailability"),Ri=M(()=>{const e=process.pid;try{return process.platform==="win32"?yt(e):xt(e)}catch{return[]}},"listOrphanPids"),Ti=M(()=>{const e=process.pid;let t;try{t=process.platform==="win32"?yt(e):xt(e)}catch{return{id:Oe,message:"Could not enumerate processes (ps/tasklist failed).",status:"warn"}}if(t.length===0)return{id:Oe,message:"No orphaned vis/task-runner processes detected.",status:"ok"};if(t.length<=2)return{detail:{count:t.length,pids:t.join(",")},id:Oe,message:`${String(t.length)} possibly orphaned process(es) detected (PIDs: ${t.join(", ")}). Likely benign.`,status:"skip"};const i=process.platform==="win32"?t.map(o=>`taskkill /F /PID ${String(o)}`).join(" & "):`kill ${t.join(" ")}`;return{detail:{count:t.length,pids:t.join(",")},id:"orphans",message:`${String(t.length)} possibly orphaned vis/task-runner processes — run \`vis doctor --fix\` to clean them up, or kill them manually: ${i}`,status:"warn"}},"checkOrphanedRunners"),Ai=M((e={})=>{const t=e.enumerate??Ri,i=e.force===!0?"SIGKILL":"SIGTERM",o=e.kill??Ni,n=t(),l=[],c=[];for(const h of n)try{o(h,i),l.push(h)}catch(a){const g=a.code??a.message;if(g==="ESRCH"){l.push(h);continue}c.push({pid:h,reason:g})}return{failed:c,killed:l}},"killOrphanedRunners"),Pi=M(e=>Ee("taskkill",e,{encoding:"utf8"}),"defaultTaskkillRunner"),Ii=M((e,t)=>{process.kill(e,t)},"defaultProcessKill"),Di=M((e,t,i=Pi)=>{const o=t==="SIGKILL"?["/F","/PID",String(e)]:["/PID",String(e)],n=i(o);if(n.error)throw n.error;if(typeof n.status=="number"&&n.status!==0){const l=n.status===128?"ESRCH":`taskkill exited with code ${String(n.status)}`,c=new Error(l);throw c.code=l,c}},"killViaTaskkill"),Oi=M((e,t,i=Ii)=>{i(e,t)},"killViaSignal"),Ni=M((e,t)=>{if(process.platform==="win32"){Di(e,t);return}Oi(e,t)},"defaultKill"),mt=M((e,t)=>{const i=Ee(e,t,{encoding:"utf8"});if(i.error)throw i.error;if(typeof i.status=="number"&&i.status!==0)throw new Error(`${e} exited with code ${String(i.status)}`);return typeof i.stdout=="string"?i.stdout:""},"runProcessListing"),xt=M(e=>{const t=mt("ps",["-Ao","pid=,command="]),i=[];for(const o of t.split(`
2
- `)){if(o.length===0)continue;const n=/^\s*(\d+)\s+(.+)$/.exec(o);if(!n)continue;const l=Number.parseInt(n[1]??"",10),c=(n[2]??"").toLowerCase();!Number.isFinite(l)||l===e||(/(?:^|[ /])vis-native(?:\s|$|[-.])/.test(c)||/(?:^|[ /])vis\s+run\b/.test(c)||/(?:^|[ /])task-runner(?:\s|$|[-.])/.test(c))&&i.push(l)}return i},"listOrphansUnix"),yt=M(e=>{const t=mt("tasklist",["/FO","CSV","/NH"]),i=[];for(const o of t.split(/\r?\n/)){if(o.length===0)continue;const n=o.split(/","/).map(h=>h.replaceAll(/^"|"$/g,"")),l=(n[0]??"").toLowerCase(),c=Number.parseInt(n[1]??"",10);!Number.isFinite(c)||c===e||(l==="vis.exe"||l.startsWith("vis-native")||l.includes("task-runner"))&&i.push(c)}return i},"listOrphansWindows"),Fi=M(()=>{let e;try{const t=Ee("watchman",["--version"],{encoding:"utf8",timeout:2e3});if(t.error||typeof t.status=="number"&&t.status!==0)throw t.error??new Error("watchman exited non-zero");e=typeof t.stdout=="string"?t.stdout.trim():void 0}catch{return{id:"watchman",message:"Watchman not found — `vis` uses native fs.watch (fine for small repos). Install Watchman + `fb-watchman` to scale watch mode on large monorepos.",status:"skip"}}return{detail:e?{version:e}:void 0,id:"watchman",message:e?`Watchman available (${e}) — scalable watch backend in use.`:"Watchman available — scalable watch backend in use.",status:"ok"}},"checkWatchmanAvailability"),Mi=M((e=process.cwd())=>{let t="";try{t=ut(J(e,".gitattributes"),"utf8")}catch(i){if(i.code!=="ENOENT")return{id:"git-lfs",message:"Could not read .gitattributes.",status:"warn"}}if(!t.includes("filter=lfs"))return{id:"git-lfs",message:"No Git LFS tracking declared in .gitattributes.",status:"skip"};try{const i=Ee("git",["lfs","version"],{encoding:"utf8",timeout:2e3});if(i.error||typeof i.status=="number"&&i.status!==0)throw i.error??new Error("git-lfs not available")}catch{return{id:"git-lfs",message:"Repo tracks files via Git LFS but `git-lfs` is not installed — checked-out LFS files are pointer stubs, not real content. Install git-lfs and run `git lfs pull`.",status:"warn"}}return{id:"git-lfs",message:"Git LFS tracking declared and `git-lfs` is installed.",status:"ok"}},"checkGitLfsTracking"),Ei=M(e=>[Si(),Ci(),Fi(),Mi(e),Ti()],"runRuntimeDiagnostics");var zi=Object.defineProperty,ke=T((e,t)=>zi(e,"name",{value:t,configurable:!0}),"s$2");const ye=[{id:"dependencies",label:"Deps"},{id:"security",label:"Security"},{id:"optimization",label:"Optimize"},{id:"runtime",label:"Runtime"}],Fe=["dependencies","security","optimization","runtime"],me=ke(e=>{const t=new Map;for(const i of Fe)t.set(i,[]);for(const i of e)t.get(i.section).push(i);for(const[i,o]of t)o.length===0&&t.delete(i);return t},"groupBySection"),xe=ke((e,t,i,o)=>{let n=e.filter(l=>l.section===t);if(o&&(n=n.filter(l=>l.severity===o)),i){const l=i.toLowerCase();n=n.filter(c=>c.title.toLowerCase().includes(l))}return[...n]},"filterFindings"),Bi=ke(e=>{const t={dependencies:"idle",optimization:"idle",runtime:"idle",security:"idle"};for(const i of Fe)e.has(i)&&(t[i]="idle");return t},"initialStatus");class Ze{static{T(this,"DoctorStore")}static{ke(this,"DoctorStore")}#e;#i=new Set;constructor(t=[]){const i=Array.isArray(t)?{findings:t}:t,o=i.findings??[],n=i.activeSections??new Set(Fe),l=Fe.find(a=>n.has(a))??"dependencies",c=xe(o,l,"",void 0),h=Bi(n);if(o.length>0)for(const a of o)h[a.section]="done";this.#e={all:o,entries:c,filterActive:!1,filterText:"",filterType:l,focusedPanel:"list",grouped:me(c),pendingAction:void 0,sectionError:{},sectionMessage:{},sectionStatus:h,selectedIndex:0,severityFilter:void 0}}getSnapshot=ke(()=>this.#e,"getSnapshot");subscribe=ke(t=>(this.#i.add(t),()=>{this.#i.delete(t)}),"subscribe");setSelectedIndex(t){const i=Math.max(0,Math.min(t,this.#e.entries.length-1));i!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:i})}setFocusedPanel(t){t!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:t})}setFilterType(t){if(t===this.#e.filterType)return;const i=xe(this.#e.all,t,this.#e.filterText,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterType:t,grouped:me(i),selectedIndex:0})}setFilter(t){const i=xe(this.#e.all,this.#e.filterType,t,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterText:t,grouped:me(i),selectedIndex:0})}setFilterActive(t){if(t===this.#e.filterActive)return;if(t){this.#t({...this.#e,filterActive:!0});return}const i=xe(this.#e.all,this.#e.filterType,"",this.#e.severityFilter);this.#t({...this.#e,entries:i,filterActive:!1,filterText:"",grouped:me(i),selectedIndex:0})}setPendingAction(t){this.#t({...this.#e,pendingAction:t})}setSeverityFilter(t){if(t===this.#e.severityFilter)return;const i=xe(this.#e.all,this.#e.filterType,this.#e.filterText,t);this.#t({...this.#e,entries:i,grouped:me(i),selectedIndex:0,severityFilter:t})}startSection(t,i){this.#t({...this.#e,sectionMessage:{...this.#e.sectionMessage,[t]:i},sectionStatus:{...this.#e.sectionStatus,[t]:"running"}})}completeSection(t,i){const o=[...this.#e.all,...i],n=xe(o,this.#e.filterType,this.#e.filterText,this.#e.severityFilter),l={...this.#e.sectionMessage};delete l[t],this.#t({...this.#e,all:o,entries:n,grouped:me(n),sectionMessage:l,sectionStatus:{...this.#e.sectionStatus,[t]:"done"}})}failSection(t,i){this.#t({...this.#e,sectionError:{...this.#e.sectionError,[t]:i},sectionStatus:{...this.#e.sectionStatus,[t]:"error"}})}#t(t){this.#e=t;for(const i of this.#i)try{i()}catch{}}}var Li=Object.defineProperty,kt=T((e,t)=>Li(e,"name",{value:t,configurable:!0}),"r$1");const et={error:0,warn:1},Vi=kt(e=>!!e.acceptedRisk,"isAcknowledged"),wt=kt(e=>{const t=[];if(e.sections.has("dependencies")){for(const i of e.outdated)t.push({entry:i,id:`outdated:${i.packageName}`,kind:"outdated",section:"dependencies",severity:"warn",subtitle:`${i.currentRange} → ${i.newRange} (${i.updateType})`,title:i.packageName});for(const i of e.duplicates)t.push({id:`duplicate:${i.name}`,kind:"duplicate",pkg:i,section:"dependencies",severity:"warn",subtitle:`${String(i.versions.length)} versions installed`,title:i.name})}if(e.sections.has("security"))for(const i of e.outdated){if(i.vulnerabilities&&i.vulnerabilities.length>0){const o=i.vulnerabilities[0],n=Vi(i)?"warn":"error",l=i.vulnerabilities.length;t.push({entry:i,id:`vuln:${i.packageName}`,kind:"vulnerability",packageName:i.packageName,section:"security",severity:n,subtitle:l===1?`${o.severity} · ${o.id}`:`${String(l)} advisories · top: ${o.severity} ${o.id}`,title:i.packageName})}if(i.socketReport&&i.socketReport.alerts.length>0){const o=Math.round(i.socketReport.score.overall*100);t.push({entry:i,id:`socket:${i.packageName}`,kind:"socket",packageName:i.packageName,section:"security",severity:"warn",subtitle:`${String(i.socketReport.alerts.length)} alert${i.socketReport.alerts.length===1?"":"s"} · score ${String(o)}%`,title:i.packageName})}}if(e.sections.has("optimization"))for(const i of e.optimizations)t.push({entry:i,id:`opt:${i.packageName}`,kind:"optimization",section:"optimization",severity:"warn",subtitle:`${i.category} → ${i.replacement}`,title:i.packageName});if(e.sections.has("runtime"))for(const i of e.runtime)i.status==="warn"&&t.push({diagnostic:i,id:`runtime:${i.id}`,kind:"runtime",section:"runtime",severity:"warn",title:i.message});return t.sort((i,o)=>{if(i.section!==o.section){const n=["dependencies","security","optimization","runtime"];return n.indexOf(i.section)-n.indexOf(o.section)}return et[i.severity]-et[o.severity]}),t},"flattenFindings"),vt={dependencies:"Dependencies",optimization:"Optimization",runtime:"Runtime",security:"Security"};var _i=Object.defineProperty,Gi=T((e,t)=>_i(e,"name",{value:t,configurable:!0}),"a$2");const Ui={error:"red",warn:"yellow"},Hi={error:"✖",warn:"⚠"},Ki={error:" ERROR ",warn:" WARN "},Yi=Gi(({children:e,hint:t,message:i,severity:o,title:n})=>{const l=Ui[o];return s.jsxs(u,{borderColor:l,borderStyle:"single",flexDirection:"column",flexShrink:0,paddingX:1,children:[s.jsxs(u,{gap:1,children:[s.jsx(r,{backgroundColor:l,bold:!0,color:"black",children:Ki[o]}),s.jsx(r,{bold:!0,color:l,children:Hi[o]}),s.jsx(r,{bold:!0,wrap:"truncate-end",children:n})]}),s.jsx(r,{wrap:"truncate-end",children:i}),t?s.jsx(r,{dimColor:!0,wrap:"truncate-end",children:t}):null,e]})},"ConfigBanner");var Wi=Object.defineProperty,te=T((e,t)=>Wi(e,"name",{value:t,configurable:!0}),"d$2");const Ji={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},qi={critical:"red",high:"red",low:"gray",medium:"yellow"},Xi={major:"red",minor:"yellow",patch:"green"},R=te(({children:e,label:t,width:i=14})=>s.jsxs(u,{children:[s.jsx(u,{width:i,children:s.jsxs(r,{dimColor:!0,children:[t,":"]})}),typeof e=="string"?s.jsx(r,{children:e}):e]}),"FieldRow"),ne=te(({children:e})=>s.jsx(u,{marginTop:1,children:s.jsx(r,{bold:!0,color:"white",children:e})}),"SectionTitle"),Qi=te(({finding:e})=>{const{entry:t}=e,i=Xi[t.updateType]??"white";return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Current",children:t.currentRange}),s.jsxs(R,{label:"Target",children:[s.jsx(r,{children:t.newRange}),s.jsxs(r,{bold:!0,color:i,children:[" (",t.updateType,")"]})]}),s.jsx(R,{label:"Catalog",children:t.catalogName}),t.acceptedRisk?s.jsx(R,{label:"Risk ack",children:s.jsx(r,{dimColor:!0,children:t.acceptedRisk.reason??"(no reason recorded)"})}):null,s.jsx(ne,{children:"Action"}),s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis update"})," ","to apply this change."]})]})},"OutdatedDetail"),Zi=te(({finding:e})=>s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Versions",children:s.jsx(r,{children:String(e.pkg.versions.length)})}),s.jsx(ne,{children:"Installed versions"}),e.pkg.versions.map(t=>s.jsxs(r,{children:[" · ",t]},t)),s.jsx(ne,{children:"Action"}),s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis dedupe"})," ","to consolidate to a single resolution."]})]}),"DuplicateDetail"),es=te(({finding:e})=>{const t=e.entry.vulnerabilities??[];return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Package",children:e.packageName}),s.jsx(R,{label:"Current",children:e.entry.currentRange}),s.jsx(R,{label:"Advisories",children:String(t.length)}),e.entry.acceptedRisk?s.jsx(R,{label:"Risk ack",children:s.jsx(r,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,t.map(i=>{const o=Ji[i.severity]??"gray";return s.jsxs(u,{flexDirection:"column",marginTop:1,children:[s.jsxs(u,{children:[s.jsx(r,{bold:!0,color:o,children:i.severity}),s.jsx(r,{children:" "}),s.jsx(r,{children:i.id}),typeof i.cvssScore=="number"?s.jsxs(r,{dimColor:!0,children:[" · CVSS ",i.cvssScore.toFixed(1)]}):null]}),s.jsx(r,{wrap:"wrap",children:i.summary}),i.fixedVersions.length>0?s.jsxs(r,{dimColor:!0,children:["Fixed in: ",i.fixedVersions.join(", ")]}):null,i.aliases&&i.aliases.length>0?s.jsxs(r,{dimColor:!0,children:["Aliases: ",i.aliases.join(", ")]}):null]},i.id)})]})},"VulnerabilityDetail"),ts=te(({finding:e})=>{const t=e.entry.socketReport;if(!t)return s.jsx(r,{dimColor:!0,children:"No Socket report attached."});const i=Math.round(t.score.overall*100),o=We(t.score.overall);return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Package",children:e.packageName}),s.jsx(R,{label:"Overall",children:s.jsxs(r,{color:o,children:[String(i),"%"]})}),s.jsx(R,{label:"Alerts",children:String(t.alerts.length)}),e.entry.acceptedRisk?s.jsx(R,{label:"Risk ack",children:s.jsx(r,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,s.jsx(ne,{children:"Score breakdown"}),Object.entries(t.score).map(([n,l])=>{if(n==="overall")return null;const c=typeof l=="number"?l:0,h=Math.round(c*100),a=We(c);return s.jsxs(u,{children:[s.jsx(u,{width:14,children:s.jsxs(r,{dimColor:!0,children:[n,":"]})}),s.jsxs(r,{color:a,children:[String(h),"%"]})]},n)}),s.jsx(ne,{children:"Alerts"}),t.alerts.map((n,l)=>{const c=qi[n.severity]??"gray";return s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{children:[s.jsx(r,{bold:!0,color:c,children:n.severity}),s.jsx(r,{children:" "}),s.jsx(r,{children:n.type})]}),n.props?s.jsx(r,{dimColor:!0,wrap:"wrap",children:JSON.stringify(n.props)}):null]},`${n.type}-${String(l)}`)})]})},"SocketDetail"),is=te(({finding:e})=>{const{entry:t}=e;return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Package",children:t.packageName}),s.jsx(R,{label:"Category",children:t.category}),s.jsx(R,{label:"Replacement",children:t.replacement}),t.overrideSpec?s.jsx(R,{label:"Override",children:t.overrideSpec}):null,s.jsx(R,{label:"Codemod",children:s.jsx(r,{color:t.hasCodemod?"green":"gray",children:t.hasCodemod?"available":"not available"})}),t.docUrl?s.jsx(R,{label:"Guide",children:s.jsx(r,{color:"cyan",underline:!0,children:t.docUrl})}):null,s.jsx(ne,{children:"Action"}),t.hasCodemod?s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis optimize"})," ","to apply the codemod interactively."]}):t.overrideSpec?s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis optimize"})," ","to install the package override."]}):t.docUrl?s.jsx(r,{dimColor:!0,children:"No automated codemod. Open the migration guide above for the recommended alternative and steps."}):s.jsx(r,{dimColor:!0,children:"No automated codemod. Consult the package's docs or the e18e module-replacements guide for an alternative."})]})},"OptimizationDetail"),ss=te(({finding:e})=>{const{diagnostic:t}=e,i=t.status==="warn"?"yellow":t.status==="ok"?"green":"gray";return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Check",children:t.id}),s.jsx(R,{label:"Status",children:s.jsx(r,{color:i,children:t.status})}),s.jsx(ne,{children:"Message"}),s.jsx(r,{wrap:"wrap",children:t.message}),t.detail&&Object.keys(t.detail).length>0?s.jsxs(s.Fragment,{children:[s.jsx(ne,{children:"Details"}),Object.entries(t.detail).map(([o,n])=>s.jsxs(u,{children:[s.jsx(u,{width:20,children:s.jsxs(r,{dimColor:!0,children:[o,":"]})}),s.jsx(r,{children:String(n)})]},o))]}):null]})},"RuntimeDetail"),rs=te(({finding:e,focused:t,scrollRef:i})=>{const o=t?"white":"gray";if(!e)return s.jsx(u,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:s.jsx(r,{dimColor:!0,children:"No finding selected"})});let n;switch(e.kind){case"duplicate":{n=s.jsx(Zi,{finding:e});break}case"optimization":{n=s.jsx(is,{finding:e});break}case"outdated":{n=s.jsx(Qi,{finding:e});break}case"runtime":{n=s.jsx(ss,{finding:e});break}case"socket":{n=s.jsx(ts,{finding:e});break}case"vulnerability":{n=s.jsx(es,{finding:e});break}default:{n=s.jsx(r,{dimColor:!0,children:"Unknown finding kind."});break}}return s.jsxs(u,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[s.jsxs(u,{flexShrink:0,paddingTop:1,paddingX:2,children:[s.jsx(r,{bold:!0,color:"white",children:e.title}),s.jsxs(r,{dimColor:!0,children:[" ",vt[e.section]]})]}),s.jsxs(Ft,{flexGrow:1,flexShrink:1,paddingX:2,ref:i,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[s.jsx(r,{}),n]})]})},"DoctorDetailPanel");var ns=Object.defineProperty,Ie=T((e,t)=>ns(e,"name",{value:t,configurable:!0}),"c$2");const bt={error:"red",warn:"yellow"},os={error:"✖",warn:"⚠"},ls=Ie(e=>e.kind==="outdated"||e.kind==="vulnerability"||e.kind==="socket"?!!e.entry.acceptedRisk:!1,"hasAcceptedRisk"),as=Ie(({finding:e,isSelected:t})=>{const i=bt[e.severity],o=ls(e);return s.jsxs(u,{flexShrink:0,height:1,children:[s.jsx(r,{children:t?">":" "}),s.jsxs(r,{color:i,children:[" ",os[e.severity]," "]}),s.jsx(u,{flexGrow:1,children:s.jsx(r,{bold:t,inverse:t,wrap:"truncate",children:e.title})}),o?s.jsx(r,{color:"cyan",children:" ack"}):null,e.subtitle?s.jsxs(r,{dimColor:!0,wrap:"truncate",children:[" ",e.subtitle]}):null]})},"FindingRow"),cs=Ie(({count:e,section:t})=>s.jsxs(u,{flexShrink:0,height:1,marginTop:1,children:[s.jsx(r,{dimColor:!0,children:"▼ "}),s.jsx(r,{bold:!0,color:"white",children:vt[t].toUpperCase()}),s.jsxs(r,{dimColor:!0,children:[" (",e,")"]})]}),"SectionHeader"),ds=Ie(({count:e,label:t,status:i})=>s.jsxs(r,{children:[t,i==="running"?s.jsxs(r,{children:[" ",s.jsx(ft,{type:"dots"})]}):null,i==="error"?s.jsx(r,{bold:!0,color:"red",children:" ✖"}):s.jsxs(r,{dimColor:!0,children:[" (",String(e),")"]})]}),"TabLabel"),us=Ie(({elapsedMs:e,entries:t,filterActive:i,filterText:o,filterType:n,focused:l,fromCache:c=!1,grouped:h,onViewportHeightChange:a,scrollOffset:g,sectionCounts:y,sectionMessage:w,sectionStatus:A,selectedIndex:E,severityFilter:p,totalAll:P,viewportHeight:z})=>{const q=l?"white":"gray",{measuredHeight:V,ref:B}=mi(z,a);let S=0,G=0;for(const b of t)b.severity==="error"?S+=1:b.severity==="warn"&&(G+=1);const U=[];S>0&&U.push(`${String(S)} error${S===1?"":"s"}`),G>0&&U.push(`${String(G)} warn${G===1?"":"s"}`);const oe=U.length>0?` (${U.join(", ")})`:"",ie=(e/1e3).toFixed(1),_=[];for(const[b,j]of h){_.push(s.jsx(cs,{count:j.length,section:b},`hdr-${b}`));for(const X of j){const C=t.indexOf(X);_.push(s.jsx(as,{finding:X,isSelected:C===E},X.id))}}let F=0;for(const[,b]of h)F+=2+b.length;const K=F>V&&V>0;return s.jsxs(u,{borderColor:q,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[s.jsxs(u,{flexShrink:0,gap:1,paddingX:1,children:[s.jsx(r,{bold:!0,inverse:!0,children:" DOCTOR "}),s.jsxs(r,{wrap:"truncate",children:[t.length,t.length===P?"":`/${String(P)}`," finding",t.length===1?"":"s",oe]}),p?s.jsx(r,{bold:!0,color:bt[p],inverse:!0,children:` ${p.toUpperCase()} ONLY `}):null,c?s.jsx(r,{bold:!0,color:"cyan",inverse:!0,children:" CACHED "}):null,s.jsxs(r,{dimColor:!0,children:[" · ",ie,"s"]})]}),s.jsx(u,{flexShrink:0,paddingX:1,paddingY:1,children:s.jsx(gi,{isFocused:l,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:T(()=>{},"onChange"),showIndex:!1,value:n,children:ye.map(({id:b,label:j})=>s.jsx(fi,{name:b,children:s.jsx(ds,{count:y[b],label:j,status:A[b]})},b))})}),(()=>{const b=Object.keys(A).filter(j=>A[j]==="running"&&w[j]).map(j=>w[j]);return b.length===0?null:s.jsx(u,{flexShrink:0,paddingX:1,children:s.jsxs(r,{dimColor:!0,wrap:"truncate",children:[s.jsx(ft,{type:"dots"})," ",b.join(" · ")]})})})(),i&&s.jsxs(u,{flexShrink:0,paddingX:1,children:[s.jsx(r,{bold:!0,color:"white",children:"/ "}),s.jsx(r,{children:o}),s.jsx(r,{inverse:!0,children:" "})]}),s.jsxs(u,{flexDirection:"row",flexGrow:1,overflow:"hidden",ref:B,children:[s.jsx(u,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:s.jsx(u,{flexDirection:"column",marginTop:-g,children:_.length>0?_:s.jsx(u,{marginTop:1,children:s.jsx(r,{dimColor:!0,children:"No findings match the current filter."})})})}),K&&s.jsx(u,{flexShrink:0,marginLeft:1,marginRight:1,children:s.jsx(Mt,{contentHeight:F,placement:"inset",scrollOffset:g,style:"block",viewportHeight:V})})]},`list-${n}-${o}`)]})},"DoctorListPanel");var hs=Object.defineProperty,ze=T((e,t)=>hs(e,"name",{value:t,configurable:!0}),"g$1");const ps=ze(e=>{if(e.kind==="outdated")return{command:`vis update ${e.entry.packageName}`,description:`Update ${e.entry.packageName} to ${e.entry.newRange}`};if(e.kind==="duplicate")return{command:`vis dedupe ${e.pkg.name}`,description:`Dedupe ${e.pkg.name} (${String(e.pkg.versions.length)} versions)`}},"buildUpdateAction"),gs=ze(e=>{if(e.kind==="optimization")return{command:`vis optimize ${e.entry.packageName}`,description:`Replace ${e.entry.packageName} with ${e.entry.replacement}`}},"buildOptimizeAction"),fs=ze(e=>{if(e.kind!=="outdated"&&e.kind!=="vulnerability"&&e.kind!=="socket")return;const t=e.kind==="outdated"?e.entry.packageName:e.packageName,i=["// Add to vis.config.ts:","security: {"," acceptedRisks: {",` "${t}": {`,' reason: "explain why this risk is acceptable",',' expiresAt: "YYYY-MM-DD",'," },"," },","},"].join(`
3
- `);return{command:i,configSnippet:i,description:`Acknowledge risk for ${t}`}},"buildAckAction"),ms=100,xs=40,ys=10,ks=ze(({autoExitSeconds:e=0,banner:t,fromCache:i=!1,startedAt:o,store:n})=>{const{exit:l}=Et(),{columns:c,rows:h}=zt(),a=L.useSyncExternalStore(n.subscribe,n.getSnapshot),[g,y]=L.useState(!1),[w,A]=L.useState(!1),[E,p]=L.useState(0),[P,z]=L.useState(()=>Date.now());L.useEffect(()=>{const x=setInterval(()=>{z(Date.now())},1e3);return()=>{clearInterval(x)}},[]);const q=P-o,V=L.useRef(null),B=L.useRef(null),S=a.entries[a.selectedIndex]??null,G=L.useMemo(()=>{const x={dependencies:0,optimization:0,runtime:0,security:0};for(const m of a.all)x[m.section]+=1;return x},[a.all]),U=t?t.hint?5:4:0,oe=L.useMemo(()=>{for(const x of Object.keys(a.sectionStatus))if(a.sectionStatus[x]==="running"&&a.sectionMessage[x])return 1;return 0},[a.sectionStatus,a.sectionMessage]),ie=c>=ms,_=ie?Math.max(1,h-U-2):Math.floor(h*.55),F=Math.max(1,_-6-oe-(a.filterActive?1:0)),[K,b]=L.useState(F),j=K>0?K:F,X=L.useMemo(()=>{let x=0;for(const[,m]of a.grouped)x+=2+m.length;return x},[a.grouped]),C=Math.max(0,X-j),le=Math.min(E,C),ue=L.useCallback(x=>{let m=0,k=0;for(const[,$e]of a.grouped){m+=2;for(let ae=0;ae<$e.length;ae++){if(k===x)return m;m+=1,k+=1}}return m},[a.grouped]),I=L.useCallback(x=>{const m=ue(x);p(k=>m>k+j-2?Math.min(C,Math.max(0,m-j+2)):m<k+1?Math.max(0,m-1):k)},[ue,j,C]);if(L.useEffect(()=>{B.current?.scrollToTop()},[S?.id]),Bt((x,m)=>{if(x==="c"&&m.ctrl){l();return}if(!w){if(g){m.escape||x==="?"?y(!1):x==="q"?(y(!1),A(!0)):m.downArrow||x==="j"?V.current?.scrollBy(1):(m.upArrow||x==="k")&&V.current?.scrollBy(-1);return}if(x==="?"){y(!0);return}if(x==="q"){A(!0);return}if(m.tab){n.setFocusedPanel(a.focusedPanel==="list"?"detail":"list");return}if(a.filterActive){if(m.escape||m.return){n.setFilterActive(!1);return}if(m.backspace){p(0),n.setFilter(a.filterText.slice(0,-1));return}x&&!m.ctrl&&!m.meta&&(p(0),n.setFilter(a.filterText+x));return}if(a.focusedPanel==="list"&&(m.leftArrow||m.rightArrow)){const k=ye.findIndex(ae=>ae.id===a.filterType),$e=m.rightArrow?(k+1)%ye.length:(k-1+ye.length)%ye.length;p(0),B.current?.scrollToTop(),n.setFilterType(ye[$e].id);return}if(a.focusedPanel==="list"){if(m.downArrow||x==="j"){const k=Math.min(a.selectedIndex+1,a.entries.length-1);n.setSelectedIndex(k),I(k);return}if(m.upArrow||x==="k"){const k=Math.max(a.selectedIndex-1,0);n.setSelectedIndex(k),I(k);return}if(m.pageDown){const k=Math.min(a.selectedIndex+10,a.entries.length-1);n.setSelectedIndex(k),I(k);return}if(m.pageUp){const k=Math.max(a.selectedIndex-10,0);n.setSelectedIndex(k),I(k);return}if(m.home){n.setSelectedIndex(0),p(0);return}if(m.end){const k=a.entries.length-1;n.setSelectedIndex(k),I(k);return}if(x==="/"){n.setFilterActive(!0);return}if(x==="e"){n.setSeverityFilter(a.severityFilter==="error"?void 0:"error"),p(0);return}if(x==="w"){n.setSeverityFilter(a.severityFilter==="warn"?void 0:"warn"),p(0);return}if(x==="u"&&S){const k=ps(S);k&&(n.setPendingAction(k),l());return}if(x==="o"&&S){const k=gs(S);k&&(n.setPendingAction(k),l());return}if(x==="a"&&S){const k=fs(S);k&&(n.setPendingAction(k),l());return}if(x==="d"){n.setFocusedPanel("detail");return}return}if(m.escape||m.leftArrow){n.setFocusedPanel("list");return}if(m.downArrow||x==="j"){B.current?.scrollBy(1);return}if(m.upArrow||x==="k"){B.current?.scrollBy(-1);return}if(m.pageDown){B.current?.scrollBy(10);return}if(m.pageUp){B.current?.scrollBy(-10);return}if(m.home){B.current?.scrollToTop();return}m.end&&B.current?.scrollToBottom()}},{isActive:!0}),c<xs||h<ys)return s.jsx(u,{alignItems:"center",height:h,justifyContent:"center",width:c,children:s.jsxs(r,{color:"yellow",children:["Terminal too small (",c,"x",h,")"]})});const Q=a.focusedPanel==="detail",ee=[s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"q"}),s.jsx(r,{dimColor:!0,children:"QUIT"})]},"q"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"?"}),s.jsx(r,{dimColor:!0,children:"HELP"})]},"?"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"↑↓"}),s.jsx(r,{dimColor:!0,children:Q?"SCROLL":"NAV"})]},"nav"),Q?s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"←/Esc"}),s.jsx(r,{dimColor:!0,children:"LIST"})]},"lr"):s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"←→"}),s.jsx(r,{dimColor:!0,children:"SECTION"})]},"lr"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"/"}),s.jsx(r,{dimColor:!0,children:"SEARCH"})]},"search"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"e/w"}),s.jsx(r,{dimColor:!0,children:"SEVERITY"})]},"sev"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"u/o/a"}),s.jsx(r,{dimColor:!0,children:"ACTION"})]},"actions"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"Tab"}),s.jsx(r,{dimColor:!0,children:"PANEL"})]},"tab")],he=s.jsx(u,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:s.jsx(u,{gap:2,overflow:"hidden",paddingX:1,children:ee})}),pe=s.jsxs(Lt,{footer:s.jsxs(r,{dimColor:!0,children:[s.jsx(r,{bold:!0,color:"white",children:"↑↓"})," scroll ",s.jsx(r,{bold:!0,color:"white",children:"?"}),"/",s.jsx(r,{bold:!0,color:"white",children:"Esc"})," close"]}),scrollRef:V,title:"DOCTOR — KEYBOARD SHORTCUTS",visible:g,width:56,children:[s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"NAVIGATION"})]}),s.jsxs(u,{children:[s.jsx(u,{width:26,children:s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" ↑/k "}),s.jsx(r,{dimColor:!0,children:"Move up"})]})}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" ↓/j "}),s.jsx(r,{dimColor:!0,children:"Move down"})]})]}),s.jsxs(u,{children:[s.jsx(u,{width:26,children:s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" PgUp"}),s.jsx(r,{dimColor:!0,children:" Jump up 10"})]})}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" PgDn"}),s.jsx(r,{dimColor:!0,children:" Jump down 10"})]})]}),s.jsxs(u,{children:[s.jsx(u,{width:26,children:s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" Home"}),s.jsx(r,{dimColor:!0,children:" Jump to top"})]})}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" End"}),s.jsx(r,{dimColor:!0,children:" Jump to bottom"})]})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" Tab"}),s.jsx(r,{dimColor:!0,children:" Switch panel"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" →/←"}),s.jsx(r,{dimColor:!0,children:" Section tabs (list) / Focus list (detail)"})]})]}),s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"FILTER"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" /"}),s.jsx(r,{dimColor:!0,children:" Open text filter (Esc/Enter to close)"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" e"}),s.jsx(r,{dimColor:!0,children:" Toggle errors-only filter"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" w"}),s.jsx(r,{dimColor:!0,children:" Toggle warns-only filter"})]})]}),s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"ACTIONS"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" u"}),s.jsx(r,{dimColor:!0,children:" Exit + suggest update / dedupe command"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" o"}),s.jsx(r,{dimColor:!0,children:" Exit + suggest optimize command"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" a"}),s.jsx(r,{dimColor:!0,children:" Exit + print risk-ack snippet"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" d"}),s.jsx(r,{dimColor:!0,children:" Focus detail panel"})]})]}),s.jsxs(u,{flexDirection:"column",children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"EXIT"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" q"}),s.jsx(r,{dimColor:!0,children:" Quit (with countdown)"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" Ctrl+C"}),s.jsx(r,{dimColor:!0,children:" Quit immediately"})]})]})]}),ge=s.jsx(us,{elapsedMs:q,entries:a.entries,filterActive:a.filterActive,filterText:a.filterText,filterType:a.filterType,focused:a.focusedPanel==="list",fromCache:i,grouped:a.grouped,onViewportHeightChange:b,scrollOffset:le,sectionCounts:G,sectionMessage:a.sectionMessage,sectionStatus:a.sectionStatus,selectedIndex:a.selectedIndex,severityFilter:a.severityFilter,totalAll:a.all.length,viewportHeight:j}),fe=t?s.jsx(Yi,{hint:t.hint,message:t.message,severity:t.severity,title:t.title}):null,je=s.jsx(rs,{finding:S,focused:a.focusedPanel==="detail",scrollRef:B});if(ie){const x=Math.floor(c*.4);return s.jsxs(u,{flexDirection:"column",height:h,width:c,children:[fe,s.jsxs(u,{flexDirection:"row",flexGrow:1,children:[s.jsx(u,{flexGrow:1,children:ge}),s.jsx(u,{width:x,children:je})]}),he,s.jsx(Je,{autoExitSeconds:e||3,onCancel:T(()=>{A(!1)},"onCancel"),visible:w}),pe]})}return s.jsxs(u,{flexDirection:"column",height:h,width:c,children:[fe,s.jsx(u,{height:_,children:ge}),s.jsx(u,{flexGrow:1,children:je}),he,s.jsx(Je,{autoExitSeconds:e||3,onCancel:T(()=>{A(!1)},"onCancel"),visible:w}),pe]})},"VisDoctorApp");var ws=Object.defineProperty,ve=T((e,t)=>ws(e,"name",{value:t,configurable:!0}),"n");const vs=ve(e=>e.replaceAll(/[$()+.?[\\\]^{|}]/g,String.raw`\$&`),"escapeRegex"),bs=ve(e=>{const t=e.split("*").map(i=>vs(i));return new RegExp(`^${t.join(".*")}$`,"i")},"compilePattern"),js=ve(e=>e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>bs(t)):[],"parseFilterPatterns"),Ne=ve((e,t)=>{for(const i of t)if(i.test(e))return!0;return!1},"matchesAny"),$s=ve((e,t,i)=>{if(t.length===0)return e;const o=e.outdated.filter(g=>Ne(g.packageName,t)),n=e.duplicates.filter(g=>Ne(g.name,t)),l=e.optimizations.filter(g=>Ne(g.packageName,t));let c=0,h=0,a=0;for(const g of o)g.vulnerabilities&&(c+=g.vulnerabilities.length),g.socketReport&&(h+=g.socketReport.alerts.length,g.socketReport.score.overall<i&&(a+=1));return{...e,duplicates:n,optimizations:l,outdated:o,socketIssues:{alerts:h,lowScore:a},vulnCount:c}},"applyFilter"),jt=ve((e,t)=>t.length===0?[...e]:e.filter(i=>{if(i.kind==="runtime")return!0;const o=i.kind==="duplicate"?i.pkg.name:i.kind==="outdated"||i.kind==="optimization"?i.entry.packageName:i.packageName;return Ne(o,t)}),"filterFindingsByPattern");var Ss=Object.defineProperty,be=T((e,t)=>Ss(e,"name",{value:t,configurable:!0}),"r");const $t=["dependencies","security","optimization","runtime"],tt=be(e=>{const t=new Set;if(!e)return t;for(const i of e.split(",")){const o=i.trim().toLowerCase();$t.includes(o)&&t.add(o)}return t},"parseSectionList"),Cs=be((e,t)=>{if(e!==void 0&&e!=="")return tt(e);const i=tt(t);return new Set($t.filter(o=>!i.has(o)))},"resolveSections"),St=be(e=>{const t={micro:0,native:0,preferred:0,socket:0,total:e.length};for(const i of e)switch(i.category){case"micro-utility":{t.micro+=1;break}case"native":{t.native+=1;break}case"preferred":{t.preferred+=1;break}case"socket":{t.socket+=1;break}}return t},"summarizeOptimizations"),re=be((e,t)=>{if(!e.sections.has(t))return"skip";switch(t){case"dependencies":return e.outdated.length>0||e.duplicates.length>0?"warn":"ok";case"optimization":return e.optimizations.length>0?"warn":"ok";case"runtime":return e.runtime.some(i=>i.status==="warn")?"warn":"ok";case"security":return e.vulnCount>0||e.socketIssues.alerts>0?"error":e.socketIssues.lowScore>0?"warn":"ok";default:return"ok"}},"sectionStatus"),Rs=be((e,t)=>{const i=St(e.optimizations),o={dependencies:re(e,"dependencies"),optimization:re(e,"optimization"),runtime:re(e,"runtime"),security:re(e,"security")},n=new Set([...Object.values(o),e.supplyChain.status]),l=n.has("error")?"error":n.has("warn")?"warn":"ok";return{dependencies:{duplicates:e.duplicates.length,installed:e.installedCount,outdated:e.outdated.length,status:o.dependencies},elapsedMs:e.elapsedMs,optimizations:{microUtilities:i.micro,native:i.native,preferred:i.preferred,socket:i.socket,status:o.optimization,total:i.total},packageManager:t,runtime:e.runtime.map(c=>({detail:c.detail,id:c.id,message:c.message,status:c.status})),runtimeStatus:o.runtime,security:{alerts:e.socketIssues.alerts,lowScorePackages:e.socketIssues.lowScore,status:o.security,vulnerabilities:e.vulnCount},status:l,supplyChain:{findings:e.supplyChain.findings.map(c=>({detail:c.detail,label:c.label,severity:c.severity})),status:e.supplyChain.status},workspaces:e.workspaceCount}},"buildJsonPayload"),it=be((e,t)=>{const i=e.runtime.some(n=>n.status==="warn"),o=e.vulnCount>0||e.socketIssues.alerts>0;return t?o||e.outdated.length>0||e.duplicates.length>0||i:o},"shouldFail");var Ts=Object.defineProperty,Be=T((e,t)=>Ts(e,"name",{value:t,configurable:!0}),"u$1");const As=["aube-workspace.yaml","pnpm-workspace.yaml"],Ce=Be(e=>typeof e=="boolean"?e:void 0,"asBool"),Ps=Be(e=>{if(e==="no-downgrade"||e==="off")return e},"asTrustPolicy"),Is=Be(e=>{const t={allowBuildsCount:0,blockExoticSubdeps:void 0,jailBuilds:void 0,minimumReleaseAge:void 0,minimumReleaseAgeStrict:void 0,paranoid:void 0,source:void 0,strictDepBuilds:void 0,trustPolicy:void 0};for(const i of As){const o=J(e,i);if(!Ae(o))continue;let n;try{n=Vt(qt(o))}catch{continue}if(typeof n!="object"||n===null)continue;const l=n;return t.source=i,t.paranoid=Ce(l.paranoid),t.trustPolicy=Ps(l.trustPolicy),t.blockExoticSubdeps=Ce(l.blockExoticSubdeps),t.jailBuilds=Ce(l.jailBuilds),t.strictDepBuilds=Ce(l.strictDepBuilds),t.minimumReleaseAgeStrict=Ce(l.minimumReleaseAgeStrict),typeof l.minimumReleaseAge=="number"&&Number.isFinite(l.minimumReleaseAge)&&(t.minimumReleaseAge=l.minimumReleaseAge),l.allowBuilds&&typeof l.allowBuilds=="object"&&!Array.isArray(l.allowBuilds)&&(t.allowBuildsCount=Object.keys(l.allowBuilds).length),t}return t},"readAubeSecurityPosture"),Ds=Be(e=>e.paranoid?{...e,jailBuilds:!0,minimumReleaseAgeStrict:!0,strictDepBuilds:!0,trustPolicy:"no-downgrade"}:e,"applyAubeParanoidOverrides");var Os=Object.defineProperty,_e=T((e,t)=>Os(e,"name",{value:t,configurable:!0}),"i");const Ns=/^(@[\w./-]+\/[\w./-]+|[\w.-]+)@(.+)$/,Fs=_e(e=>{const t=Ns.exec(e);if(t)return{name:t[1],version:t[2]}},"parsePatchKey"),Ms=_e((e,t)=>{let i;try{if(t==="pnpm"){const n=J(e,"pnpm-workspace.yaml");Ae(n)&&(i=_t(n)?.patchedDependencies)}else if(t==="bun"){const n=J(e,"package.json");Ae(n)&&(i=ht(n)?.patchedDependencies)}}catch{return[]}if(!i||typeof i!="object")return[];const o=[];for(const[n,l]of Object.entries(i)){if(typeof l!="string"||l.length===0)continue;const c=Fs(n);c&&o.push({name:c.name,patchFile:l,resolvedPatchFile:Xt(l)?l:dt(e,l),version:c.version})}return o},"readPatchedDependencies"),Es=_e(e=>{const t=[];for(const i of e)Ae(i.resolvedPatchFile)||t.push({entry:i,kind:"missing-file"});return t},"findPatchIssues");var zs=Object.defineProperty,Ct=T((e,t)=>zs(e,"name",{value:t,configurable:!0}),"c");const st=Ct(e=>e.some(t=>t.severity==="error")?"error":e.some(t=>t.severity==="warn")?"warn":"ok","rollUpStatus"),Bs=Ct((e,t={})=>{const i=[],o=e?.security;if(!o)return i.push({detail:"Use defineConfig() from '@visulima/vis/config' to apply secure defaults.",label:"No security config — running with the PM's native defaults",severity:"warn"}),{findings:i,status:st(i)};const n=o.policies?.firstSeen?.minutes,l=o.policies?.publisherChange,c=o.policies?.installScripts;n===void 0?i.push({detail:"Set security.policies.firstSeen.minutes to block packages published in the last N minutes (mitigates supply-chain attacks).",label:"policies.firstSeen.minutes is not set",severity:"warn"}):n===0?i.push({detail:"New packages can be installed immediately after publishing. Consider setting a non-zero cooldown.",label:"policies.firstSeen.minutes is explicitly 0",severity:"warn"}):i.push({label:`policies.firstSeen.minutes: ${String(n)} minutes`,severity:"ok"}),l?.mode===void 0||l.mode==="off"?i.push({detail:"Packages whose trust level has decreased will not be blocked. Consider 'no-downgrade'.",label:`policies.publisherChange.mode: ${l?.mode??"not set"}`,severity:"warn"}):i.push({label:`policies.publisherChange.mode: ${l.mode}`,severity:"ok"}),o.blockExoticSubdeps===void 0||!o.blockExoticSubdeps?i.push({detail:"Transitive dependencies can pull code from git repos or tarball URLs. Set to true to block.",label:`blockExoticSubdeps: ${String(o.blockExoticSubdeps??!1)}`,severity:"warn"}):i.push({label:"blockExoticSubdeps: true",severity:"ok"});const h=c?.allow?Object.keys(c.allow).length:0;if(h===0?i.push({detail:"Lifecycle scripts are blocked by default. List trusted packages here to opt them back in (e.g. esbuild, @prisma/client).",label:"policies.installScripts.allow: not configured",severity:"warn"}):i.push({label:`policies.installScripts.allow: ${String(h)} ${h===1?"entry":"entries"}`,severity:"ok"}),c?.strict&&h===0&&i.push({detail:"All dependencies with build scripts will be blocked. Run 'vis approve-builds' to populate the allow list.",label:"policies.installScripts.strict is on but allow is empty",severity:"error"}),t.workspaceRoot){const a=xi(t.workspaceRoot);if(a.length>0){const g=[...new Set(a.map(y=>y.tool))].sort((y,w)=>y.localeCompare(w)).join(", ");i.push({detail:"Run `vis migrate verify` for the full list, then re-run `vis migrate <tool>` to clean up.",label:`${String(a.length)} leftover ${a.length===1?"reference":"references"} to ${g}`,severity:"warn"})}}if(t.workspaceRoot&&t.packageManager==="aube"){const a=Is(t.workspaceRoot),g=Ds(a),y=g.source?` (from ${g.source})`:"";g.paranoid===!0&&i.push({detail:"Forces jailBuilds, trustPolicy=no-downgrade, minimumReleaseAgeStrict, strictStoreIntegrity, and strictDepBuilds on.",label:`aube paranoid: true${y}`,severity:"ok"}),g.trustPolicy==="off"&&i.push({detail:"Trust downgrades between releases will not be blocked. Set trustPolicy: no-downgrade in aube-workspace.yaml.",label:`aube trustPolicy: off${y}`,severity:"warn"}),g.blockExoticSubdeps===!1&&i.push({detail:"Transitive deps from git+, file:, and tarball URLs will not be blocked. Re-enable with blockExoticSubdeps: true.",label:`aube blockExoticSubdeps: false${y}`,severity:"warn"}),g.minimumReleaseAge===0&&i.push({detail:"Newly published versions are not held in a cooling window. Restore with minimumReleaseAge: 1440 (24h) or higher.",label:`aube minimumReleaseAge: 0${y}`,severity:"warn"}),g.jailBuilds===!0&&i.push({label:`aube jailBuilds: true${y}`,severity:"ok"}),g.strictDepBuilds===!0&&i.push({label:`aube strictDepBuilds: true${y}`,severity:"ok"}),g.allowBuildsCount>0&&i.push({label:`aube allowBuilds: ${String(g.allowBuildsCount)} ${g.allowBuildsCount===1?"entry":"entries"}${y}`,severity:"ok"})}if(t.workspaceRoot&&t.packageManager){const a=Ms(t.workspaceRoot,t.packageManager);if(a.length>0){const g=Es(a);if(g.length===0)i.push({label:`patchedDependencies: ${String(a.length)} ${a.length===1?"entry":"entries"} resolved`,severity:"ok"});else for(const y of g)i.push({detail:`Referenced from ${t.packageManager==="pnpm"?"pnpm-workspace.yaml":"package.json"} but the file is not present at ${y.entry.patchFile}.`,label:`patchedDependencies: missing patch file for ${y.entry.name}@${y.entry.version}`,severity:"error"})}}return{findings:i,status:st(i)}},"buildSupplyChainPosture");var Ls=Object.defineProperty,$=T((e,t)=>Ls(e,"name",{value:t,configurable:!0}),"u");const H=$(e=>e>=1e3?`${(e/1e3).toFixed(1)}s`:`${String(Math.round(e))}ms`,"fmtDuration"),De=$(async(e,t,i,o)=>{if(!e)return i();e.start(t);const n=Date.now();try{const l=await i(),c=Date.now()-n,{status:h,summary:a}=o(l,c);return e.finish(t,h,a),l}catch(l){const c=Date.now()-n,h=l instanceof Error?l.message:String(l);throw e.finish(t,"error",`${h} (${H(c)})`),l}},"tracked"),Vs=$((e,t)=>{const i={duplicates:t.duplicates,elapsedMs:0,installedCount:0,optimizations:t.optimizations,outdated:t.outdated,runtime:t.runtime,sections:new Set([e]),socketIssues:{alerts:0,lowScore:0},supplyChain:{findings:[],status:"ok"},vulnCount:0,workspaceCount:0};return wt(i)},"buildSectionFindings"),rt=$(async e=>{const{filterPatterns:t,installed:i,progress:o,resolveCodemods:n,sections:l,store:c,visConfig:h,workspaceRoot:a}=e,g=l.has("dependencies"),y=l.has("security"),w=l.has("optimization"),A=l.has("runtime"),E=$((f,D)=>jt(Vs(f,D),t),"sectionFindings"),p=gt(a),{packageManager:P}=ot(a),z=Xe(J(a,"package.json"),!1),q=pt(a),V=new Set(z);for(const f of q){const D=Xe(J(dt(a,f),"package.json"),!1);for(const O of D)V.add(O)}const B=Gt(a),S=lt(a,P),G=at(h?.security,{minimumScore:h?.security?.policies?.score?.minimum}),U=h?.security?.policies?.score?.minimum??ct,oe=h?.security?.acceptedRisks,ie=ii(a,p.name),_={exclude:[],ignore:[],include:[],includeLocked:!1,includePrerelease:!1,security:!0,target:"latest"},F=g?ui(a,p.name):[],K=w?si(V):[],b=w?ri(V,ie,p,!1):[],j=new Set(K.map(f=>f.packageName)),X=b.filter(f=>!j.has(f.packageName)),C=[...K,...X],le=A?Ei(a):[];c&&(g&&c.startSection("dependencies",S.size>0?"checking outdated catalog dependencies":"scanning duplicates"),y&&c.startSection("security",i.length>0?`scanning ${String(i.length)} packages for advisories`:"no installed packages to scan"),w&&c.startSection("optimization","matching e18e + socket overrides"),A&&c.startSection("runtime","running runtime diagnostics")),c&&A&&c.completeSection("runtime",E("runtime",{duplicates:[],optimizations:[],outdated:[],runtime:le}));const ue=(g||y)&&S.size>0?De(o,"outdated",()=>Ut(S,_,B,void 0,a,G,oe),(f,D)=>{const O=f.outdated.length;return{status:O>0?"warn":"ok",summary:O>0?`${String(O)} outdated · ${H(D)}`:`up to date · ${H(D)}`}}):Promise.resolve({failed:[],ignored:[],outdated:[]}),I=y&&i.length>0?De(o,"vulnerabilities",()=>Ht(i.map(f=>({name:f.name,version:f.version}))),(f,D)=>{let O=0;for(const se of f.values())O+=se.length;return{status:O>0?"error":"ok",summary:O>0?`${String(O)} found · ${H(D)}`:`none found · ${H(D)}`}}):Promise.resolve(new Map),Q=y&&G.length>0&&i.length>0?De(o,"socket",()=>Kt(G,i.map(f=>({name:f.name,version:f.version}))),(f,D)=>{let O=0,se=0;for(const Ye of f.values())O+=Ye.alerts.length,Ye.score.overall<U&&(se+=1);const Ke=O+se;return{status:Ke>0?"warn":"ok",summary:Ke>0?`${String(O)} alert${O===1?"":"s"}, ${String(se)} low-score · ${H(D)}`:`clean · ${H(D)}`}}):Promise.resolve(new Map);let ee,he,pe,ge;const fe=ue.catch(f=>(ee=f instanceof Error?f.message:String(f),c||d.warn(`Outdated scan failed: ${ee}`),{failed:[],ignored:[],outdated:[]})),je=I.catch(f=>(he=f instanceof Error?f.message:String(f),c||d.warn(`Vulnerability scan failed: ${he}`),new Map)),x=Q.catch(f=>(pe=f instanceof Error?f.message:String(f),c||d.warn(`Socket scan failed: ${pe}`),new Map)),m=c&&g?fe.then(f=>{if(ee){c.failSection("dependencies",ee);return}c.completeSection("dependencies",E("dependencies",{duplicates:F,optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,k=c&&y?Promise.all([fe,je,x]).then(([f])=>{const D=ee??he??pe;if(D){c.failSection("security",D);return}c.completeSection("security",E("security",{duplicates:[],optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,$e=(async()=>{if(n&&w&&C.length>0&&await De(o,"codemods",async()=>(await ni(C),C),(f,D)=>{const O=f.filter(se=>se.hasCodemod||se.category==="socket").length;return{status:"ok",summary:`${String(O)} auto-fixable · ${H(D)}`}}).catch(f=>{ge=f instanceof Error?f.message:String(f)}),c&&w){if(ge){c.failSection("optimization",ge);return}c.completeSection("optimization",E("optimization",{duplicates:[],optimizations:C,outdated:[],runtime:[]}))}})(),[ae,Tt,At]=await Promise.all([fe,je,x]);await Promise.all([m,k,$e]);let Ue=0,He=0;if(y&&G.length>0)for(const f of At.values())Ue+=f.alerts.length,f.score.overall<U&&(He+=1);let Le=0;if(y){for(const f of ae.outdated)f.vulnerabilities&&f.vulnerabilities.length>0&&(Le+=f.vulnerabilities.length);for(const f of Tt.values())Le+=f.length}return{duplicates:F,installedCount:i.length,optimizations:w?C:[],outdated:g?ae.outdated:[],runtime:le,sections:l,socketIssues:{alerts:Ue,lowScore:He},supplyChain:Bs(h,{packageManager:P,workspaceRoot:a}),vulnCount:Le,workspaceCount:q.length}},"streamScans"),_s=$(e=>{switch(e){case"error":return Re(N.failure);case"skip":return v(N.dash);case"warn":return Me(N.warning);default:return we(N.success)}},"sectionIcon"),de=$((e,t)=>{const i=process.stderr.columns??80,o=Math.max(20,Math.min(i-2,60)),n=N.dash.repeat(2),l=`${_s(t)} ${ce(e)}`,c=l.replaceAll(/\[[0-9;]*m/g,"").length,h=Math.max(0,o-c-n.length-2);return`${n} ${l} ${v(N.dash.repeat(h))}`},"heading"),W=$(e=>` ${we(N.success)} ${e}`,"itemOk"),Z=$(e=>` ${Me(N.warning)} ${e}`,"itemWarn"),Ge=$(e=>` ${Re(N.failure)} ${e}`,"itemError"),Rt=$(e=>` ${v(N.dash)} ${v(e)}`,"itemSkip"),Y=$((e,t,i)=>{const o=`${ce(String(e))} ${v(t)}`;return i?`${o} ${v(`(${i})`)}`:o},"countLine"),Gs=$(e=>{if(e.sections.has("dependencies")){if(d.log(""),d.log(de("Dependencies",re(e,"dependencies"))),d.log(W(Y(e.installedCount,"packages installed"))),e.outdated.length>0){const t=e.outdated.filter(l=>l.updateType==="major").length,i=e.outdated.filter(l=>l.updateType==="minor").length,o=e.outdated.filter(l=>l.updateType==="patch").length,n=[];t>0&&n.push(`${String(t)} major`),i>0&&n.push(`${String(i)} minor`),o>0&&n.push(`${String(o)} patch`),d.log(Z(Y(e.outdated.length,"outdated",n.join(", "))))}else d.log(W("All dependencies up to date"));e.duplicates.length>0?d.log(Z(Y(e.duplicates.length,"packages with duplicate versions"))):d.log(W("No duplicate dependencies"))}},"displayDependencies"),Us=$(e=>{e.sections.has("security")&&(d.log(""),d.log(de("Security",re(e,"security"))),e.vulnCount>0?d.log(Ge(Y(e.vulnCount,`vulnerabilit${e.vulnCount===1?"y":"ies"} found`))):d.log(W("No known vulnerabilities")),e.socketIssues.alerts>0&&d.log(Z(Y(e.socketIssues.alerts,`Socket.dev security alert${e.socketIssues.alerts===1?"":"s"}`))),e.socketIssues.lowScore>0&&d.log(Z(Y(e.socketIssues.lowScore,`package${e.socketIssues.lowScore===1?"":"s"} with low security score`))),e.socketIssues.alerts===0&&e.socketIssues.lowScore===0&&e.vulnCount===0&&d.log(W("No security issues detected")))},"displaySecurity"),Hs=$(e=>{if(!e.sections.has("optimization"))return;d.log(""),d.log(de("Optimization",re(e,"optimization")));const t=St(e.optimizations);if(t.total===0){d.log(W("No optimizations available"));return}t.native>0&&d.log(Z(Y(t.native,"replaceable with native APIs"))),t.preferred>0&&d.log(Z(Y(t.preferred,"with lighter alternatives"))),t.micro>0&&d.log(Z(Y(t.micro,"trivial micro-utilities"))),t.socket>0&&d.log(Z(Y(t.socket,"@socketregistry overrides available")))},"displayOptimization"),Ks=$(e=>{d.log(""),d.log(de("Supply Chain",e.supplyChain.status));for(const t of e.supplyChain.findings){const i=t.severity==="ok"?W(t.label):t.severity==="error"?Ge(t.label):Z(t.label);d.log(i),t.detail&&d.log(` ${v(N.arrow)} ${v(t.detail)}`)}e.supplyChain.status!=="ok"&&d.log(` ${v(N.arrow)} ${v("Configure with security.* in vis.config.ts. See `vis check --security-config` for details.")}`)},"displaySupplyChain"),Ys=$(e=>{if(e.sections.has("runtime")){d.log(""),d.log(de("Runtime",re(e,"runtime")));for(const t of e.runtime)t.status==="ok"?d.log(W(t.message)):t.status==="skip"?d.log(Rt(t.message)):d.log(Z(t.message))}},"displayRuntime"),Ws=$((e,t)=>{const i=e.vulnCount,o=e.runtime.filter(l=>l.status==="warn").length,n=e.outdated.length+e.duplicates.length+e.optimizations.length+o;if(t){if(i===0&&n===0)d.success(`Everything looks good! ${v(`(${H(e.elapsedMs)})`)}`);else{const l=[];i>0&&l.push(Re(`${String(i)} security`)),n>0&&l.push(Me(`${String(n)} improvement${n===1?"":"s"}`)),d.log(`${Re(N.failure)} ${l.join(", ")} ${v(`(${H(e.elapsedMs)})`)}`)}return}d.log(""),d.log(de("Summary","ok")),i===0&&n===0?d.success(`Everything looks good! ${v(`(${H(e.elapsedMs)})`)}`):(i>0&&d.error(`${String(i)} security issue${i===1?"":"s"}`),n>0&&d.log(` ${Te(N.arrow)} ${ce(String(n))} ${v(`improvement${n===1?"":"s"} available`)} ${v(`(${H(e.elapsedMs)})`)}`))},"displaySummary"),Js=$(e=>{const t=[];if(e.outdated.length>0&&t.push("vis update — update outdated dependencies"),(e.vulnCount>0||e.socketIssues.alerts>0)&&t.push("vis audit — detailed security analysis"),e.optimizations.length>0&&t.push("vis optimize — apply optimizations interactively"),e.duplicates.length>0&&t.push("vis dedupe — reduce duplicate versions"),t.length>0){d.log(""),d.log(ce("Next steps:"));for(const i of t)d.log(` ${v(N.arrow)} ${i}`)}d.log("")},"displayActions"),qs=$((e,t)=>{t||(Gs(e),Us(e),Hs(e),Ys(e),Ks(e)),Ws(e,t)},"displayResults"),Xs=$((e,t,i,o,n)=>{const l=[],c=e.has("dependencies"),h=e.has("security"),a=e.has("optimization");return(c||h)&&t>0&&l.push({id:"outdated",label:"Outdated catalog dependencies"}),h&&o>0&&l.push({id:"vulnerabilities",label:"Known vulnerabilities (OSV)"}),h&&i&&o>0&&l.push({id:"socket",label:"Socket.dev supply-chain reports"}),a&&n&&l.push({id:"codemods",label:"Codemod availability"}),l},"planScanTasks"),Qs=$(e=>{if(d.log(""),d.log(`${ce(Te("vis doctor"))} ${v("— project health check")}`),d.log(W(`Detected ${e.packageManagerName} v${e.packageManagerVersion}`)),e.workspaceCount!==void 0&&e.workspaceCount>0&&d.log(W(Y(e.workspaceCount,`workspace package${e.workspaceCount===1?"":"s"}`))),e.runtimeFindings.length===0)d.log(W(`Node.js ${e.nodeVersion}`));else{for(const t of e.runtimeFindings){const i=t.severity==="error"?Re:Me;d.log(Ge(`Runtime: ${i(t.message)}`))}d.log(` ${v(N.arrow)} Run ${we("vis toolchain install")} to install pinned versions, or ${we("vis toolchain status")} for the per-tool breakdown.`)}d.log("")},"printBanner"),fr=$(async({logger:e,options:t,visConfig:i,visConfigError:o,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root.");const l=t.format==="json"||t.json===!0,c=Cs(t.only,t.skip),h=!!t.quiet,a=t.progress===!1,g=js(t.filter);if(c.size===0){d.error("No sections selected. Check your --only / --skip values."),process.exitCode=2;return}const y=Date.now(),w=gt(n),A=ci(n),E=!!process.stdout.isTTY,p=!l&&E&&!Jt&&!h&&!a;!l&&!p&&Qs({nodeVersion:process.versions.node,packageManagerName:w.name,packageManagerVersion:w.version,runtimeFindings:A,workspaceCount:void 0});const P=lt(n,ot(n).packageManager),z=hi(n,w.name),q=z.length,V=at(i?.security).length>0,B=i?.security?.policies?.score?.minimum??ct,S=pt(n);if(!l&&!h&&!p){const I=S.length>0?v(` · ${String(S.length)} workspace package${S.length===1?"":"s"}`):"";d.log(`${v("·")} ${v("Found")} ${ce(String(q))} ${v(`installed package${q===1?"":"s"}`)}${I}`)}const G=o?{hint:o.file?`Continuing with default settings — fix or regenerate ${o.file} (vis init --force).`:"Continuing with default settings.",message:o.message,severity:"error",title:o.file?`Failed to load ${o.file}`:"Failed to load vis.config"}:void 0,U=pi(n,w.name)?.file,oe=U?J(n,U):void 0,ie=ti(n),_=t.cache!==!1&&!t.fix?vi({configPath:ie,lockfilePath:oe,sections:c,socketEnabled:V,workspaceRoot:n}):void 0,F=_?bi(_):void 0,K=F!==void 0;let b,j;if(p){const I=F?new Ze({activeSections:c,findings:jt(wt(F),g)}):new Ze({activeSections:c}),Q=Yt(Wt.createElement(ks,{banner:G,fromCache:K,startedAt:y,store:I}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0});try{b=F??await rt({filterPatterns:g,installed:z,resolveCodemods:!!t.fix,sections:c,store:I,visConfig:i,workspaceRoot:n})}catch(ee){throw Q.unmount(),ee}await Q.waitUntilExit(),j=I.getSnapshot().pendingAction}else if(F)b=F;else{const I=Xs(c,P.size,V,q,!!t.fix),Q=di(I,{live:!l&&!h&&!a});try{b=await rt({filterPatterns:g,installed:z,progress:Q,resolveCodemods:!!t.fix,sections:c,visConfig:i,workspaceRoot:n})}finally{Q.stop()}}const X={...b,elapsedMs:Date.now()-y};if(_&&!K)try{ji(_,X)}catch{}const C=$s(X,g,B);if(l){process.stdout.write(`${JSON.stringify(Rs(C,w.name),void 0,2)}
4
- `),t.exitCode&&it(C,!!t.strict)&&(process.exitCode=1);return}K&&!h&&d.log(`${v("·")} Cached results (use --no-cache to refresh)`),g.length>0&&!h&&d.log(`${v("·")} Filter active: ${Te(t.filter??"")}`),qs(C,h);const le=C.runtime.some(I=>I.id===Oe&&I.status==="warn"),ue=C.sections.has("optimization")&&C.optimizations.length>0;t.fix&&(ue||le)?await Zs({force:!!t.fixForce,logger:e,pm:w,recoverOrphans:le,results:C,useEditorconfig:i?.editorconfig??!0,workspaceRoot:n}):h||Js(C),j&&(process.stdout.write(`
1
+ var Pt=Object.defineProperty;var T=(e,t)=>Pt(e,"name",{value:t,configurable:!0});import{createRequire as It}from"node:module";import{I as we,e as Me,E as v,T as Re,j as ce,q as Te}from"../packem_shared/Table-DoSoazT6-DwnyTUsA.js";import{m as Ot,a$ as Nt,a5 as s,a6 as u,n as r,l as We,aG as Ft,aH as Mt,aI as Et,aF as zt,w as L,af as Bt,aJ as Lt,aK as Je,b0 as Vt,r as _t,T as ot,h as Gt,a as lt,c as at,j as Ut,v as Ht,f as Kt,p as d,a7 as N,k as Yt,R as Wt,a4 as ct,s as Jt}from"./bin.js";import{M as J,l as Ae,B as qt,a as Xt,C as dt}from"../packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js";import{s as pt,d as ei,j as ti}from"./config.js";import{x as Xe,A as ht,L as ii,F as si,T as ri,U as ni,a as oi,I as li}from"./handler41.js";import{A as gt,y as ai}from"../packem_shared/pm-runner-DmKT2FqF.js";import{c as ci}from"../packem_shared/runtime-check-CilFOqUU.js";import{s as di}from"../packem_shared/scan-progress-DVtCtI2z.js";import{f as ui,l as pi,r as hi}from"../packem_shared/dependency-scan-BUbOcMwX.js";import{n as ft}from"../packem_shared/spinner-C8xs6QZv.js";import{g as gi,r as fi}from"../packem_shared/tabs-xZkm6Y_J.js";import{u as mi}from"../packem_shared/use-measured-height-Lea6TCVD.js";import{s as xi}from"../packem_shared/verify-cLcZwKqe.js";const Dt=It(import.meta.url),Se=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,nt=T(e=>{if(typeof Se<"u"&&Se.versions&&Se.versions.node){const[t,i]=Se.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return Se.getBuiltinModule(e)}return Dt(e)},"__cjs_getBuiltinModule"),{statSync:Qt,rmSync:qe,writeFileSync:Zt,readFileSync:ut}=nt("node:fs"),{spawnSync:Ee}=nt("node:child_process");var yi=Object.defineProperty,Pe=T((e,t)=>yi(e,"name",{value:t,configurable:!0}),"r$2");const Ve=Pe(()=>J(Ot(),"doctor"),"getCacheDirectory"),ki=1800*1e3,Qe=Pe(e=>{if(!e)return"";try{return String(Qt(e).mtimeMs)}catch{return""}},"safeMtime"),wi=2,vi=Pe(e=>{const t=JSON.stringify({configMtime:Qe(e.configPath),lockfileMtime:Qe(e.lockfilePath),schema:wi,sections:[...e.sections].toSorted(),socketEnabled:e.socketEnabled,workspaceRoot:e.workspaceRoot});return Nt(Buffer.from(t))},"buildDoctorCacheKey"),bi=Pe(e=>{const t=J(Ve(),`${e}.json`);if(Ae(t))try{const i=pt(t);if(Date.now()-i.createdAt>i.ttlMs){qe(t,{force:!0});return}return{...i.results,sections:new Set(i.results.sections)}}catch{qe(t,{force:!0});return}},"readDoctorCache"),ji=Pe((e,t,i=ki)=>{ei(Ve());const o={createdAt:Date.now(),results:{...t,sections:[...t.sections]},ttlMs:i};Zt(J(Ve(),`${e}.json`),JSON.stringify(o,void 0,2),"utf8")},"writeDoctorCache");var $i=Object.defineProperty,M=T((e,t)=>$i(e,"name",{value:t,configurable:!0}),"n$1");const Oe="orphans",Si=M(()=>{if(process.platform!=="linux")return{id:"inotify",message:"inotify capacity check skipped (not Linux).",status:"skip"};let e;try{const t=ut("/proc/sys/fs/inotify/max_user_watches","utf8").trim(),i=Number.parseInt(t,10);Number.isFinite(i)&&i>0&&(e=i)}catch{return{id:"inotify",message:"Could not read /proc/sys/fs/inotify/max_user_watches.",status:"warn"}}return e===void 0?{id:"inotify",message:"inotify max_user_watches reported a non-numeric value.",status:"warn"}:e<65536?{detail:{maxWatches:e},id:"inotify",message:`inotify watcher limit is ${String(e)} — large monorepos can exhaust this. Bump now with \`sudo sysctl fs.inotify.max_user_watches=524288\` and persist via \`/etc/sysctl.d/99-vis.conf\` so it survives reboot.`,status:"warn"}:{detail:{maxWatches:e},id:"inotify",message:`inotify capacity OK (${String(e)} watches).`,status:"ok"}},"checkInotifyCapacity"),Ci=M(()=>{const e=!!process.stdin.isTTY,t=!!process.stdout.isTTY;return e&&t?{id:"tty",message:"Interactive TTY available — watch keybinds enabled.",status:"ok"}:!e&&!t?{id:"tty",message:"No TTY on stdin/stdout — running in CI / piped mode (keybinds disabled).",status:"skip"}:{detail:{stdin:String(e),stdout:String(t)},id:"tty",message:e?"stdin is a TTY but stdout is not — output is being captured; keybinds still work.":"stdout is a TTY but stdin is not — keybinds disabled (input is piped).",status:"skip"}},"checkTtyAvailability"),Ri=M(()=>{const e=process.pid;try{return process.platform==="win32"?yt(e):xt(e)}catch{return[]}},"listOrphanPids"),Ti=M(()=>{const e=process.pid;let t;try{t=process.platform==="win32"?yt(e):xt(e)}catch{return{id:Oe,message:"Could not enumerate processes (ps/tasklist failed).",status:"warn"}}if(t.length===0)return{id:Oe,message:"No orphaned vis/task-runner processes detected.",status:"ok"};if(t.length<=2)return{detail:{count:t.length,pids:t.join(",")},id:Oe,message:`${String(t.length)} possibly orphaned process(es) detected (PIDs: ${t.join(", ")}). Likely benign.`,status:"skip"};const i=process.platform==="win32"?t.map(o=>`taskkill /F /PID ${String(o)}`).join(" & "):`kill ${t.join(" ")}`;return{detail:{count:t.length,pids:t.join(",")},id:"orphans",message:`${String(t.length)} possibly orphaned vis/task-runner processes — run \`vis doctor --fix\` to clean them up, or kill them manually: ${i}`,status:"warn"}},"checkOrphanedRunners"),Ai=M((e={})=>{const t=e.enumerate??Ri,i=e.force===!0?"SIGKILL":"SIGTERM",o=e.kill??Ni,n=t(),l=[],c=[];for(const p of n)try{o(p,i),l.push(p)}catch(a){const g=a.code??a.message;if(g==="ESRCH"){l.push(p);continue}c.push({pid:p,reason:g})}return{failed:c,killed:l}},"killOrphanedRunners"),Pi=M(e=>Ee("taskkill",e,{encoding:"utf8"}),"defaultTaskkillRunner"),Ii=M((e,t)=>{process.kill(e,t)},"defaultProcessKill"),Di=M((e,t,i=Pi)=>{const o=t==="SIGKILL"?["/F","/PID",String(e)]:["/PID",String(e)],n=i(o);if(n.error)throw n.error;if(typeof n.status=="number"&&n.status!==0){const l=n.status===128?"ESRCH":`taskkill exited with code ${String(n.status)}`,c=new Error(l);throw c.code=l,c}},"killViaTaskkill"),Oi=M((e,t,i=Ii)=>{i(e,t)},"killViaSignal"),Ni=M((e,t)=>{if(process.platform==="win32"){Di(e,t);return}Oi(e,t)},"defaultKill"),mt=M((e,t)=>{const i=Ee(e,t,{encoding:"utf8"});if(i.error)throw i.error;if(typeof i.status=="number"&&i.status!==0)throw new Error(`${e} exited with code ${String(i.status)}`);return typeof i.stdout=="string"?i.stdout:""},"runProcessListing"),xt=M(e=>{const t=mt("ps",["-Ao","pid=,command="]),i=[];for(const o of t.split(`
2
+ `)){if(o.length===0)continue;const n=/^\s*(\d+)\s+(.+)$/.exec(o);if(!n)continue;const l=Number.parseInt(n[1]??"",10),c=(n[2]??"").toLowerCase();!Number.isFinite(l)||l===e||(/(?:^|[ /])vis-native(?:\s|$|[-.])/.test(c)||/(?:^|[ /])vis\s+run\b/.test(c)||/(?:^|[ /])task-runner(?:\s|$|[-.])/.test(c))&&i.push(l)}return i},"listOrphansUnix"),yt=M(e=>{const t=mt("tasklist",["/FO","CSV","/NH"]),i=[];for(const o of t.split(/\r?\n/)){if(o.length===0)continue;const n=o.split(/","/).map(p=>p.replaceAll(/^"|"$/g,"")),l=(n[0]??"").toLowerCase(),c=Number.parseInt(n[1]??"",10);!Number.isFinite(c)||c===e||(l==="vis.exe"||l.startsWith("vis-native")||l.includes("task-runner"))&&i.push(c)}return i},"listOrphansWindows"),Fi=M(()=>{let e;try{const t=Ee("watchman",["--version"],{encoding:"utf8",timeout:2e3});if(t.error||typeof t.status=="number"&&t.status!==0)throw t.error??new Error("watchman exited non-zero");e=typeof t.stdout=="string"?t.stdout.trim():void 0}catch{return{id:"watchman",message:"Watchman not found — `vis` uses native fs.watch (fine for small repos). Install Watchman + `fb-watchman` to scale watch mode on large monorepos.",status:"skip"}}return{detail:e?{version:e}:void 0,id:"watchman",message:e?`Watchman available (${e}) — scalable watch backend in use.`:"Watchman available — scalable watch backend in use.",status:"ok"}},"checkWatchmanAvailability"),Mi=M((e=process.cwd())=>{let t="";try{t=ut(J(e,".gitattributes"),"utf8")}catch(i){if(i.code!=="ENOENT")return{id:"git-lfs",message:"Could not read .gitattributes.",status:"warn"}}if(!t.includes("filter=lfs"))return{id:"git-lfs",message:"No Git LFS tracking declared in .gitattributes.",status:"skip"};try{const i=Ee("git",["lfs","version"],{encoding:"utf8",timeout:2e3});if(i.error||typeof i.status=="number"&&i.status!==0)throw i.error??new Error("git-lfs not available")}catch{return{id:"git-lfs",message:"Repo tracks files via Git LFS but `git-lfs` is not installed — checked-out LFS files are pointer stubs, not real content. Install git-lfs and run `git lfs pull`.",status:"warn"}}return{id:"git-lfs",message:"Git LFS tracking declared and `git-lfs` is installed.",status:"ok"}},"checkGitLfsTracking"),Ei=M(e=>[Si(),Ci(),Fi(),Mi(e),Ti()],"runRuntimeDiagnostics");var zi=Object.defineProperty,ke=T((e,t)=>zi(e,"name",{value:t,configurable:!0}),"s$2");const ye=[{id:"dependencies",label:"Deps"},{id:"security",label:"Security"},{id:"optimization",label:"Optimize"},{id:"runtime",label:"Runtime"}],Fe=["dependencies","security","optimization","runtime"],me=ke(e=>{const t=new Map;for(const i of Fe)t.set(i,[]);for(const i of e)t.get(i.section).push(i);for(const[i,o]of t)o.length===0&&t.delete(i);return t},"groupBySection"),xe=ke((e,t,i,o)=>{let n=e.filter(l=>l.section===t);if(o&&(n=n.filter(l=>l.severity===o)),i){const l=i.toLowerCase();n=n.filter(c=>c.title.toLowerCase().includes(l))}return[...n]},"filterFindings"),Bi=ke(e=>{const t={dependencies:"idle",optimization:"idle",runtime:"idle",security:"idle"};for(const i of Fe)e.has(i)&&(t[i]="idle");return t},"initialStatus");class Ze{static{T(this,"DoctorStore")}static{ke(this,"DoctorStore")}#e;#i=new Set;constructor(t=[]){const i=Array.isArray(t)?{findings:t}:t,o=i.findings??[],n=i.activeSections??new Set(Fe),l=Fe.find(a=>n.has(a))??"dependencies",c=xe(o,l,"",void 0),p=Bi(n);if(o.length>0)for(const a of o)p[a.section]="done";this.#e={all:o,entries:c,filterActive:!1,filterText:"",filterType:l,focusedPanel:"list",grouped:me(c),pendingAction:void 0,sectionError:{},sectionMessage:{},sectionStatus:p,selectedIndex:0,severityFilter:void 0}}getSnapshot=ke(()=>this.#e,"getSnapshot");subscribe=ke(t=>(this.#i.add(t),()=>{this.#i.delete(t)}),"subscribe");setSelectedIndex(t){const i=Math.max(0,Math.min(t,this.#e.entries.length-1));i!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:i})}setFocusedPanel(t){t!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:t})}setFilterType(t){if(t===this.#e.filterType)return;const i=xe(this.#e.all,t,this.#e.filterText,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterType:t,grouped:me(i),selectedIndex:0})}setFilter(t){const i=xe(this.#e.all,this.#e.filterType,t,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterText:t,grouped:me(i),selectedIndex:0})}setFilterActive(t){if(t===this.#e.filterActive)return;if(t){this.#t({...this.#e,filterActive:!0});return}const i=xe(this.#e.all,this.#e.filterType,"",this.#e.severityFilter);this.#t({...this.#e,entries:i,filterActive:!1,filterText:"",grouped:me(i),selectedIndex:0})}setPendingAction(t){this.#t({...this.#e,pendingAction:t})}setSeverityFilter(t){if(t===this.#e.severityFilter)return;const i=xe(this.#e.all,this.#e.filterType,this.#e.filterText,t);this.#t({...this.#e,entries:i,grouped:me(i),selectedIndex:0,severityFilter:t})}startSection(t,i){this.#t({...this.#e,sectionMessage:{...this.#e.sectionMessage,[t]:i},sectionStatus:{...this.#e.sectionStatus,[t]:"running"}})}completeSection(t,i){const o=[...this.#e.all,...i],n=xe(o,this.#e.filterType,this.#e.filterText,this.#e.severityFilter),l={...this.#e.sectionMessage};delete l[t],this.#t({...this.#e,all:o,entries:n,grouped:me(n),sectionMessage:l,sectionStatus:{...this.#e.sectionStatus,[t]:"done"}})}failSection(t,i){this.#t({...this.#e,sectionError:{...this.#e.sectionError,[t]:i},sectionStatus:{...this.#e.sectionStatus,[t]:"error"}})}#t(t){this.#e=t;for(const i of this.#i)try{i()}catch{}}}var Li=Object.defineProperty,kt=T((e,t)=>Li(e,"name",{value:t,configurable:!0}),"r$1");const et={error:0,warn:1},Vi=kt(e=>!!e.acceptedRisk,"isAcknowledged"),wt=kt(e=>{const t=[];if(e.sections.has("dependencies")){for(const i of e.outdated)t.push({entry:i,id:`outdated:${i.packageName}`,kind:"outdated",section:"dependencies",severity:"warn",subtitle:`${i.currentRange} → ${i.newRange} (${i.updateType})`,title:i.packageName});for(const i of e.duplicates)t.push({id:`duplicate:${i.name}`,kind:"duplicate",pkg:i,section:"dependencies",severity:"warn",subtitle:`${String(i.versions.length)} versions installed`,title:i.name})}if(e.sections.has("security"))for(const i of e.outdated){if(i.vulnerabilities&&i.vulnerabilities.length>0){const o=i.vulnerabilities[0],n=Vi(i)?"warn":"error",l=i.vulnerabilities.length;t.push({entry:i,id:`vuln:${i.packageName}`,kind:"vulnerability",packageName:i.packageName,section:"security",severity:n,subtitle:l===1?`${o.severity} · ${o.id}`:`${String(l)} advisories · top: ${o.severity} ${o.id}`,title:i.packageName})}if(i.socketReport&&i.socketReport.alerts.length>0){const o=Math.round(i.socketReport.score.overall*100);t.push({entry:i,id:`socket:${i.packageName}`,kind:"socket",packageName:i.packageName,section:"security",severity:"warn",subtitle:`${String(i.socketReport.alerts.length)} alert${i.socketReport.alerts.length===1?"":"s"} · score ${String(o)}%`,title:i.packageName})}}if(e.sections.has("optimization"))for(const i of e.optimizations)t.push({entry:i,id:`opt:${i.packageName}`,kind:"optimization",section:"optimization",severity:"warn",subtitle:`${i.category} → ${i.replacement}`,title:i.packageName});if(e.sections.has("runtime"))for(const i of e.runtime)i.status==="warn"&&t.push({diagnostic:i,id:`runtime:${i.id}`,kind:"runtime",section:"runtime",severity:"warn",title:i.message});return t.sort((i,o)=>{if(i.section!==o.section){const n=["dependencies","security","optimization","runtime"];return n.indexOf(i.section)-n.indexOf(o.section)}return et[i.severity]-et[o.severity]}),t},"flattenFindings"),vt={dependencies:"Dependencies",optimization:"Optimization",runtime:"Runtime",security:"Security"};var _i=Object.defineProperty,Gi=T((e,t)=>_i(e,"name",{value:t,configurable:!0}),"a$2");const Ui={error:"red",warn:"yellow"},Hi={error:"✖",warn:"⚠"},Ki={error:" ERROR ",warn:" WARN "},Yi=Gi(({children:e,hint:t,message:i,severity:o,title:n})=>{const l=Ui[o];return s.jsxs(u,{borderColor:l,borderStyle:"single",flexDirection:"column",flexShrink:0,paddingX:1,children:[s.jsxs(u,{gap:1,children:[s.jsx(r,{backgroundColor:l,bold:!0,color:"black",children:Ki[o]}),s.jsx(r,{bold:!0,color:l,children:Hi[o]}),s.jsx(r,{bold:!0,wrap:"truncate-end",children:n})]}),s.jsx(r,{wrap:"truncate-end",children:i}),t?s.jsx(r,{dimColor:!0,wrap:"truncate-end",children:t}):null,e]})},"ConfigBanner");var Wi=Object.defineProperty,te=T((e,t)=>Wi(e,"name",{value:t,configurable:!0}),"d$2");const Ji={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},qi={critical:"red",high:"red",low:"gray",medium:"yellow"},Xi={major:"red",minor:"yellow",patch:"green"},R=te(({children:e,label:t,width:i=14})=>s.jsxs(u,{children:[s.jsx(u,{width:i,children:s.jsxs(r,{dimColor:!0,children:[t,":"]})}),typeof e=="string"?s.jsx(r,{children:e}):e]}),"FieldRow"),ne=te(({children:e})=>s.jsx(u,{marginTop:1,children:s.jsx(r,{bold:!0,color:"white",children:e})}),"SectionTitle"),Qi=te(({finding:e})=>{const{entry:t}=e,i=Xi[t.updateType]??"white";return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Current",children:t.currentRange}),s.jsxs(R,{label:"Target",children:[s.jsx(r,{children:t.newRange}),s.jsxs(r,{bold:!0,color:i,children:[" (",t.updateType,")"]})]}),s.jsx(R,{label:"Catalog",children:t.catalogName}),t.acceptedRisk?s.jsx(R,{label:"Risk ack",children:s.jsx(r,{dimColor:!0,children:t.acceptedRisk.reason??"(no reason recorded)"})}):null,s.jsx(ne,{children:"Action"}),s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis update"})," ","to apply this change."]})]})},"OutdatedDetail"),Zi=te(({finding:e})=>s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Versions",children:s.jsx(r,{children:String(e.pkg.versions.length)})}),s.jsx(ne,{children:"Installed versions"}),e.pkg.versions.map(t=>s.jsxs(r,{children:[" · ",t]},t)),s.jsx(ne,{children:"Action"}),s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis dedupe"})," ","to consolidate to a single resolution."]})]}),"DuplicateDetail"),es=te(({finding:e})=>{const t=e.entry.vulnerabilities??[];return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Package",children:e.packageName}),s.jsx(R,{label:"Current",children:e.entry.currentRange}),s.jsx(R,{label:"Advisories",children:String(t.length)}),e.entry.acceptedRisk?s.jsx(R,{label:"Risk ack",children:s.jsx(r,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,t.map(i=>{const o=Ji[i.severity]??"gray";return s.jsxs(u,{flexDirection:"column",marginTop:1,children:[s.jsxs(u,{children:[s.jsx(r,{bold:!0,color:o,children:i.severity}),s.jsx(r,{children:" "}),s.jsx(r,{children:i.id}),typeof i.cvssScore=="number"?s.jsxs(r,{dimColor:!0,children:[" · CVSS ",i.cvssScore.toFixed(1)]}):null]}),s.jsx(r,{wrap:"wrap",children:i.summary}),i.fixedVersions.length>0?s.jsxs(r,{dimColor:!0,children:["Fixed in: ",i.fixedVersions.join(", ")]}):null,i.aliases&&i.aliases.length>0?s.jsxs(r,{dimColor:!0,children:["Aliases: ",i.aliases.join(", ")]}):null]},i.id)})]})},"VulnerabilityDetail"),ts=te(({finding:e})=>{const t=e.entry.socketReport;if(!t)return s.jsx(r,{dimColor:!0,children:"No Socket report attached."});const i=Math.round(t.score.overall*100),o=We(t.score.overall);return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Package",children:e.packageName}),s.jsx(R,{label:"Overall",children:s.jsxs(r,{color:o,children:[String(i),"%"]})}),s.jsx(R,{label:"Alerts",children:String(t.alerts.length)}),e.entry.acceptedRisk?s.jsx(R,{label:"Risk ack",children:s.jsx(r,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,s.jsx(ne,{children:"Score breakdown"}),Object.entries(t.score).map(([n,l])=>{if(n==="overall")return null;const c=typeof l=="number"?l:0,p=Math.round(c*100),a=We(c);return s.jsxs(u,{children:[s.jsx(u,{width:14,children:s.jsxs(r,{dimColor:!0,children:[n,":"]})}),s.jsxs(r,{color:a,children:[String(p),"%"]})]},n)}),s.jsx(ne,{children:"Alerts"}),t.alerts.map((n,l)=>{const c=qi[n.severity]??"gray";return s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{children:[s.jsx(r,{bold:!0,color:c,children:n.severity}),s.jsx(r,{children:" "}),s.jsx(r,{children:n.type})]}),n.props?s.jsx(r,{dimColor:!0,wrap:"wrap",children:JSON.stringify(n.props)}):null]},`${n.type}-${String(l)}`)})]})},"SocketDetail"),is=te(({finding:e})=>{const{entry:t}=e;return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Package",children:t.packageName}),s.jsx(R,{label:"Category",children:t.category}),s.jsx(R,{label:"Replacement",children:t.replacement}),t.overrideSpec?s.jsx(R,{label:"Override",children:t.overrideSpec}):null,s.jsx(R,{label:"Codemod",children:s.jsx(r,{color:t.hasCodemod?"green":"gray",children:t.hasCodemod?"available":"not available"})}),t.docUrl?s.jsx(R,{label:"Guide",children:s.jsx(r,{color:"cyan",underline:!0,children:t.docUrl})}):null,s.jsx(ne,{children:"Action"}),t.hasCodemod?s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis optimize"})," ","to apply the codemod interactively."]}):t.overrideSpec?s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis optimize"})," ","to install the package override."]}):t.docUrl?s.jsx(r,{dimColor:!0,children:"No automated codemod. Open the migration guide above for the recommended alternative and steps."}):s.jsx(r,{dimColor:!0,children:"No automated codemod. Consult the package's docs or the e18e module-replacements guide for an alternative."})]})},"OptimizationDetail"),ss=te(({finding:e})=>{const{diagnostic:t}=e,i=t.status==="warn"?"yellow":t.status==="ok"?"green":"gray";return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Check",children:t.id}),s.jsx(R,{label:"Status",children:s.jsx(r,{color:i,children:t.status})}),s.jsx(ne,{children:"Message"}),s.jsx(r,{wrap:"wrap",children:t.message}),t.detail&&Object.keys(t.detail).length>0?s.jsxs(s.Fragment,{children:[s.jsx(ne,{children:"Details"}),Object.entries(t.detail).map(([o,n])=>s.jsxs(u,{children:[s.jsx(u,{width:20,children:s.jsxs(r,{dimColor:!0,children:[o,":"]})}),s.jsx(r,{children:String(n)})]},o))]}):null]})},"RuntimeDetail"),rs=te(({finding:e,focused:t,scrollRef:i})=>{const o=t?"white":"gray";if(!e)return s.jsx(u,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:s.jsx(r,{dimColor:!0,children:"No finding selected"})});let n;switch(e.kind){case"duplicate":{n=s.jsx(Zi,{finding:e});break}case"optimization":{n=s.jsx(is,{finding:e});break}case"outdated":{n=s.jsx(Qi,{finding:e});break}case"runtime":{n=s.jsx(ss,{finding:e});break}case"socket":{n=s.jsx(ts,{finding:e});break}case"vulnerability":{n=s.jsx(es,{finding:e});break}default:{n=s.jsx(r,{dimColor:!0,children:"Unknown finding kind."});break}}return s.jsxs(u,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[s.jsxs(u,{flexShrink:0,paddingTop:1,paddingX:2,children:[s.jsx(r,{bold:!0,color:"white",children:e.title}),s.jsxs(r,{dimColor:!0,children:[" ",vt[e.section]]})]}),s.jsxs(Ft,{flexGrow:1,flexShrink:1,paddingX:2,ref:i,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[s.jsx(r,{}),n]})]})},"DoctorDetailPanel");var ns=Object.defineProperty,Ie=T((e,t)=>ns(e,"name",{value:t,configurable:!0}),"c$2");const bt={error:"red",warn:"yellow"},os={error:"✖",warn:"⚠"},ls=Ie(e=>e.kind==="outdated"||e.kind==="vulnerability"||e.kind==="socket"?!!e.entry.acceptedRisk:!1,"hasAcceptedRisk"),as=Ie(({finding:e,isSelected:t})=>{const i=bt[e.severity],o=ls(e);return s.jsxs(u,{flexShrink:0,height:1,children:[s.jsx(r,{children:t?">":" "}),s.jsxs(r,{color:i,children:[" ",os[e.severity]," "]}),s.jsx(u,{flexGrow:1,children:s.jsx(r,{bold:t,inverse:t,wrap:"truncate",children:e.title})}),o?s.jsx(r,{color:"cyan",children:" ack"}):null,e.subtitle?s.jsxs(r,{dimColor:!0,wrap:"truncate",children:[" ",e.subtitle]}):null]})},"FindingRow"),cs=Ie(({count:e,section:t})=>s.jsxs(u,{flexShrink:0,height:1,marginTop:1,children:[s.jsx(r,{dimColor:!0,children:"▼ "}),s.jsx(r,{bold:!0,color:"white",children:vt[t].toUpperCase()}),s.jsxs(r,{dimColor:!0,children:[" (",e,")"]})]}),"SectionHeader"),ds=Ie(({count:e,label:t,status:i})=>s.jsxs(r,{children:[t,i==="running"?s.jsxs(r,{children:[" ",s.jsx(ft,{type:"dots"})]}):null,i==="error"?s.jsx(r,{bold:!0,color:"red",children:" ✖"}):s.jsxs(r,{dimColor:!0,children:[" (",String(e),")"]})]}),"TabLabel"),us=Ie(({elapsedMs:e,entries:t,filterActive:i,filterText:o,filterType:n,focused:l,fromCache:c=!1,grouped:p,onViewportHeightChange:a,scrollOffset:g,sectionCounts:y,sectionMessage:w,sectionStatus:A,selectedIndex:E,severityFilter:h,totalAll:P,viewportHeight:z})=>{const q=l?"white":"gray",{measuredHeight:V,ref:B}=mi(z,a);let S=0,G=0;for(const b of t)b.severity==="error"?S+=1:b.severity==="warn"&&(G+=1);const U=[];S>0&&U.push(`${String(S)} error${S===1?"":"s"}`),G>0&&U.push(`${String(G)} warn${G===1?"":"s"}`);const oe=U.length>0?` (${U.join(", ")})`:"",ie=(e/1e3).toFixed(1),_=[];for(const[b,j]of p){_.push(s.jsx(cs,{count:j.length,section:b},`hdr-${b}`));for(const X of j){const C=t.indexOf(X);_.push(s.jsx(as,{finding:X,isSelected:C===E},X.id))}}let F=0;for(const[,b]of p)F+=2+b.length;const K=F>V&&V>0;return s.jsxs(u,{borderColor:q,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[s.jsxs(u,{flexShrink:0,gap:1,paddingX:1,children:[s.jsx(r,{bold:!0,inverse:!0,children:" DOCTOR "}),s.jsxs(r,{wrap:"truncate",children:[t.length,t.length===P?"":`/${String(P)}`," finding",t.length===1?"":"s",oe]}),h?s.jsx(r,{bold:!0,color:bt[h],inverse:!0,children:` ${h.toUpperCase()} ONLY `}):null,c?s.jsx(r,{bold:!0,color:"cyan",inverse:!0,children:" CACHED "}):null,s.jsxs(r,{dimColor:!0,children:[" · ",ie,"s"]})]}),s.jsx(u,{flexShrink:0,paddingX:1,paddingY:1,children:s.jsx(gi,{isFocused:l,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:T(()=>{},"onChange"),showIndex:!1,value:n,children:ye.map(({id:b,label:j})=>s.jsx(fi,{name:b,children:s.jsx(ds,{count:y[b],label:j,status:A[b]})},b))})}),(()=>{const b=Object.keys(A).filter(j=>A[j]==="running"&&w[j]).map(j=>w[j]);return b.length===0?null:s.jsx(u,{flexShrink:0,paddingX:1,children:s.jsxs(r,{dimColor:!0,wrap:"truncate",children:[s.jsx(ft,{type:"dots"})," ",b.join(" · ")]})})})(),i&&s.jsxs(u,{flexShrink:0,paddingX:1,children:[s.jsx(r,{bold:!0,color:"white",children:"/ "}),s.jsx(r,{children:o}),s.jsx(r,{inverse:!0,children:" "})]}),s.jsxs(u,{flexDirection:"row",flexGrow:1,overflow:"hidden",ref:B,children:[s.jsx(u,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:s.jsx(u,{flexDirection:"column",marginTop:-g,children:_.length>0?_:s.jsx(u,{marginTop:1,children:s.jsx(r,{dimColor:!0,children:"No findings match the current filter."})})})}),K&&s.jsx(u,{flexShrink:0,marginLeft:1,marginRight:1,children:s.jsx(Mt,{contentHeight:F,placement:"inset",scrollOffset:g,style:"block",viewportHeight:V})})]},`list-${n}-${o}`)]})},"DoctorListPanel");var ps=Object.defineProperty,ze=T((e,t)=>ps(e,"name",{value:t,configurable:!0}),"g$1");const hs=ze(e=>{if(e.kind==="outdated")return{command:`vis update ${e.entry.packageName}`,description:`Update ${e.entry.packageName} to ${e.entry.newRange}`};if(e.kind==="duplicate")return{command:`vis dedupe ${e.pkg.name}`,description:`Dedupe ${e.pkg.name} (${String(e.pkg.versions.length)} versions)`}},"buildUpdateAction"),gs=ze(e=>{if(e.kind==="optimization")return{command:`vis optimize ${e.entry.packageName}`,description:`Replace ${e.entry.packageName} with ${e.entry.replacement}`}},"buildOptimizeAction"),fs=ze(e=>{if(e.kind!=="outdated"&&e.kind!=="vulnerability"&&e.kind!=="socket")return;const t=e.kind==="outdated"?e.entry.packageName:e.packageName,i=["// Add to vis.config.ts:","security: {"," acceptedRisks: {",` "${t}": {`,' reason: "explain why this risk is acceptable",',' expiresAt: "YYYY-MM-DD",'," },"," },","},"].join(`
3
+ `);return{command:i,configSnippet:i,description:`Acknowledge risk for ${t}`}},"buildAckAction"),ms=100,xs=40,ys=10,ks=ze(({autoExitSeconds:e=0,banner:t,fromCache:i=!1,startedAt:o,store:n})=>{const{exit:l}=Et(),{columns:c,rows:p}=zt(),a=L.useSyncExternalStore(n.subscribe,n.getSnapshot),[g,y]=L.useState(!1),[w,A]=L.useState(!1),[E,h]=L.useState(0),[P,z]=L.useState(()=>Date.now());L.useEffect(()=>{const x=setInterval(()=>{z(Date.now())},1e3);return()=>{clearInterval(x)}},[]);const q=P-o,V=L.useRef(null),B=L.useRef(null),S=a.entries[a.selectedIndex]??null,G=L.useMemo(()=>{const x={dependencies:0,optimization:0,runtime:0,security:0};for(const m of a.all)x[m.section]+=1;return x},[a.all]),U=t?t.hint?5:4:0,oe=L.useMemo(()=>{for(const x of Object.keys(a.sectionStatus))if(a.sectionStatus[x]==="running"&&a.sectionMessage[x])return 1;return 0},[a.sectionStatus,a.sectionMessage]),ie=c>=ms,_=ie?Math.max(1,p-U-2):Math.floor(p*.55),F=Math.max(1,_-6-oe-(a.filterActive?1:0)),[K,b]=L.useState(F),j=K>0?K:F,X=L.useMemo(()=>{let x=0;for(const[,m]of a.grouped)x+=2+m.length;return x},[a.grouped]),C=Math.max(0,X-j),le=Math.min(E,C),ue=L.useCallback(x=>{let m=0,k=0;for(const[,$e]of a.grouped){m+=2;for(let ae=0;ae<$e.length;ae++){if(k===x)return m;m+=1,k+=1}}return m},[a.grouped]),I=L.useCallback(x=>{const m=ue(x);h(k=>m>k+j-2?Math.min(C,Math.max(0,m-j+2)):m<k+1?Math.max(0,m-1):k)},[ue,j,C]);if(L.useEffect(()=>{B.current?.scrollToTop()},[S?.id]),Bt((x,m)=>{if(x==="c"&&m.ctrl){l();return}if(!w){if(g){m.escape||x==="?"?y(!1):x==="q"?(y(!1),A(!0)):m.downArrow||x==="j"?V.current?.scrollBy(1):(m.upArrow||x==="k")&&V.current?.scrollBy(-1);return}if(x==="?"){y(!0);return}if(x==="q"){A(!0);return}if(m.tab){n.setFocusedPanel(a.focusedPanel==="list"?"detail":"list");return}if(a.filterActive){if(m.escape||m.return){n.setFilterActive(!1);return}if(m.backspace){h(0),n.setFilter(a.filterText.slice(0,-1));return}x&&!m.ctrl&&!m.meta&&(h(0),n.setFilter(a.filterText+x));return}if(a.focusedPanel==="list"&&(m.leftArrow||m.rightArrow)){const k=ye.findIndex(ae=>ae.id===a.filterType),$e=m.rightArrow?(k+1)%ye.length:(k-1+ye.length)%ye.length;h(0),B.current?.scrollToTop(),n.setFilterType(ye[$e].id);return}if(a.focusedPanel==="list"){if(m.downArrow||x==="j"){const k=Math.min(a.selectedIndex+1,a.entries.length-1);n.setSelectedIndex(k),I(k);return}if(m.upArrow||x==="k"){const k=Math.max(a.selectedIndex-1,0);n.setSelectedIndex(k),I(k);return}if(m.pageDown){const k=Math.min(a.selectedIndex+10,a.entries.length-1);n.setSelectedIndex(k),I(k);return}if(m.pageUp){const k=Math.max(a.selectedIndex-10,0);n.setSelectedIndex(k),I(k);return}if(m.home){n.setSelectedIndex(0),h(0);return}if(m.end){const k=a.entries.length-1;n.setSelectedIndex(k),I(k);return}if(x==="/"){n.setFilterActive(!0);return}if(x==="e"){n.setSeverityFilter(a.severityFilter==="error"?void 0:"error"),h(0);return}if(x==="w"){n.setSeverityFilter(a.severityFilter==="warn"?void 0:"warn"),h(0);return}if(x==="u"&&S){const k=hs(S);k&&(n.setPendingAction(k),l());return}if(x==="o"&&S){const k=gs(S);k&&(n.setPendingAction(k),l());return}if(x==="a"&&S){const k=fs(S);k&&(n.setPendingAction(k),l());return}if(x==="d"){n.setFocusedPanel("detail");return}return}if(m.escape||m.leftArrow){n.setFocusedPanel("list");return}if(m.downArrow||x==="j"){B.current?.scrollBy(1);return}if(m.upArrow||x==="k"){B.current?.scrollBy(-1);return}if(m.pageDown){B.current?.scrollBy(10);return}if(m.pageUp){B.current?.scrollBy(-10);return}if(m.home){B.current?.scrollToTop();return}m.end&&B.current?.scrollToBottom()}},{isActive:!0}),c<xs||p<ys)return s.jsx(u,{alignItems:"center",height:p,justifyContent:"center",width:c,children:s.jsxs(r,{color:"yellow",children:["Terminal too small (",c,"x",p,")"]})});const Q=a.focusedPanel==="detail",ee=[s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"q"}),s.jsx(r,{dimColor:!0,children:"QUIT"})]},"q"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"?"}),s.jsx(r,{dimColor:!0,children:"HELP"})]},"?"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"↑↓"}),s.jsx(r,{dimColor:!0,children:Q?"SCROLL":"NAV"})]},"nav"),Q?s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"←/Esc"}),s.jsx(r,{dimColor:!0,children:"LIST"})]},"lr"):s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"←→"}),s.jsx(r,{dimColor:!0,children:"SECTION"})]},"lr"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"/"}),s.jsx(r,{dimColor:!0,children:"SEARCH"})]},"search"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"e/w"}),s.jsx(r,{dimColor:!0,children:"SEVERITY"})]},"sev"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"u/o/a"}),s.jsx(r,{dimColor:!0,children:"ACTION"})]},"actions"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"Tab"}),s.jsx(r,{dimColor:!0,children:"PANEL"})]},"tab")],pe=s.jsx(u,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:s.jsx(u,{gap:2,overflow:"hidden",paddingX:1,children:ee})}),he=s.jsxs(Lt,{footer:s.jsxs(r,{dimColor:!0,children:[s.jsx(r,{bold:!0,color:"white",children:"↑↓"})," scroll ",s.jsx(r,{bold:!0,color:"white",children:"?"}),"/",s.jsx(r,{bold:!0,color:"white",children:"Esc"})," close"]}),scrollRef:V,title:"DOCTOR — KEYBOARD SHORTCUTS",visible:g,width:56,children:[s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"NAVIGATION"})]}),s.jsxs(u,{children:[s.jsx(u,{width:26,children:s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" ↑/k "}),s.jsx(r,{dimColor:!0,children:"Move up"})]})}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" ↓/j "}),s.jsx(r,{dimColor:!0,children:"Move down"})]})]}),s.jsxs(u,{children:[s.jsx(u,{width:26,children:s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" PgUp"}),s.jsx(r,{dimColor:!0,children:" Jump up 10"})]})}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" PgDn"}),s.jsx(r,{dimColor:!0,children:" Jump down 10"})]})]}),s.jsxs(u,{children:[s.jsx(u,{width:26,children:s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" Home"}),s.jsx(r,{dimColor:!0,children:" Jump to top"})]})}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" End"}),s.jsx(r,{dimColor:!0,children:" Jump to bottom"})]})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" Tab"}),s.jsx(r,{dimColor:!0,children:" Switch panel"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" →/←"}),s.jsx(r,{dimColor:!0,children:" Section tabs (list) / Focus list (detail)"})]})]}),s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"FILTER"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" /"}),s.jsx(r,{dimColor:!0,children:" Open text filter (Esc/Enter to close)"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" e"}),s.jsx(r,{dimColor:!0,children:" Toggle errors-only filter"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" w"}),s.jsx(r,{dimColor:!0,children:" Toggle warns-only filter"})]})]}),s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"ACTIONS"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" u"}),s.jsx(r,{dimColor:!0,children:" Exit + suggest update / dedupe command"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" o"}),s.jsx(r,{dimColor:!0,children:" Exit + suggest optimize command"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" a"}),s.jsx(r,{dimColor:!0,children:" Exit + print risk-ack snippet"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" d"}),s.jsx(r,{dimColor:!0,children:" Focus detail panel"})]})]}),s.jsxs(u,{flexDirection:"column",children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"EXIT"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" q"}),s.jsx(r,{dimColor:!0,children:" Quit (with countdown)"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" Ctrl+C"}),s.jsx(r,{dimColor:!0,children:" Quit immediately"})]})]})]}),ge=s.jsx(us,{elapsedMs:q,entries:a.entries,filterActive:a.filterActive,filterText:a.filterText,filterType:a.filterType,focused:a.focusedPanel==="list",fromCache:i,grouped:a.grouped,onViewportHeightChange:b,scrollOffset:le,sectionCounts:G,sectionMessage:a.sectionMessage,sectionStatus:a.sectionStatus,selectedIndex:a.selectedIndex,severityFilter:a.severityFilter,totalAll:a.all.length,viewportHeight:j}),fe=t?s.jsx(Yi,{hint:t.hint,message:t.message,severity:t.severity,title:t.title}):null,je=s.jsx(rs,{finding:S,focused:a.focusedPanel==="detail",scrollRef:B});if(ie){const x=Math.floor(c*.4);return s.jsxs(u,{flexDirection:"column",height:p,width:c,children:[fe,s.jsxs(u,{flexDirection:"row",flexGrow:1,children:[s.jsx(u,{flexGrow:1,children:ge}),s.jsx(u,{width:x,children:je})]}),pe,s.jsx(Je,{autoExitSeconds:e||3,onCancel:T(()=>{A(!1)},"onCancel"),visible:w}),he]})}return s.jsxs(u,{flexDirection:"column",height:p,width:c,children:[fe,s.jsx(u,{height:_,children:ge}),s.jsx(u,{flexGrow:1,children:je}),pe,s.jsx(Je,{autoExitSeconds:e||3,onCancel:T(()=>{A(!1)},"onCancel"),visible:w}),he]})},"VisDoctorApp");var ws=Object.defineProperty,ve=T((e,t)=>ws(e,"name",{value:t,configurable:!0}),"n");const vs=ve(e=>e.replaceAll(/[$()+.?[\\\]^{|}]/g,String.raw`\$&`),"escapeRegex"),bs=ve(e=>{const t=e.split("*").map(i=>vs(i));return new RegExp(`^${t.join(".*")}$`,"i")},"compilePattern"),js=ve(e=>e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>bs(t)):[],"parseFilterPatterns"),Ne=ve((e,t)=>{for(const i of t)if(i.test(e))return!0;return!1},"matchesAny"),$s=ve((e,t,i)=>{if(t.length===0)return e;const o=e.outdated.filter(g=>Ne(g.packageName,t)),n=e.duplicates.filter(g=>Ne(g.name,t)),l=e.optimizations.filter(g=>Ne(g.packageName,t));let c=0,p=0,a=0;for(const g of o)g.vulnerabilities&&(c+=g.vulnerabilities.length),g.socketReport&&(p+=g.socketReport.alerts.length,g.socketReport.score.overall<i&&(a+=1));return{...e,duplicates:n,optimizations:l,outdated:o,socketIssues:{alerts:p,lowScore:a},vulnCount:c}},"applyFilter"),jt=ve((e,t)=>t.length===0?[...e]:e.filter(i=>{if(i.kind==="runtime")return!0;const o=i.kind==="duplicate"?i.pkg.name:i.kind==="outdated"||i.kind==="optimization"?i.entry.packageName:i.packageName;return Ne(o,t)}),"filterFindingsByPattern");var Ss=Object.defineProperty,be=T((e,t)=>Ss(e,"name",{value:t,configurable:!0}),"r");const $t=["dependencies","security","optimization","runtime"],tt=be(e=>{const t=new Set;if(!e)return t;for(const i of e.split(",")){const o=i.trim().toLowerCase();$t.includes(o)&&t.add(o)}return t},"parseSectionList"),Cs=be((e,t)=>{if(e!==void 0&&e!=="")return tt(e);const i=tt(t);return new Set($t.filter(o=>!i.has(o)))},"resolveSections"),St=be(e=>{const t={micro:0,native:0,preferred:0,socket:0,total:e.length};for(const i of e)switch(i.category){case"micro-utility":{t.micro+=1;break}case"native":{t.native+=1;break}case"preferred":{t.preferred+=1;break}case"socket":{t.socket+=1;break}}return t},"summarizeOptimizations"),re=be((e,t)=>{if(!e.sections.has(t))return"skip";switch(t){case"dependencies":return e.outdated.length>0||e.duplicates.length>0?"warn":"ok";case"optimization":return e.optimizations.length>0?"warn":"ok";case"runtime":return e.runtime.some(i=>i.status==="warn")?"warn":"ok";case"security":return e.vulnCount>0||e.socketIssues.alerts>0?"error":e.socketIssues.lowScore>0?"warn":"ok";default:return"ok"}},"sectionStatus"),Rs=be((e,t)=>{const i=St(e.optimizations),o={dependencies:re(e,"dependencies"),optimization:re(e,"optimization"),runtime:re(e,"runtime"),security:re(e,"security")},n=new Set([...Object.values(o),e.supplyChain.status]),l=n.has("error")?"error":n.has("warn")?"warn":"ok";return{dependencies:{duplicates:e.duplicates.length,installed:e.installedCount,outdated:e.outdated.length,status:o.dependencies},elapsedMs:e.elapsedMs,optimizations:{microUtilities:i.micro,native:i.native,preferred:i.preferred,socket:i.socket,status:o.optimization,total:i.total},packageManager:t,runtime:e.runtime.map(c=>({detail:c.detail,id:c.id,message:c.message,status:c.status})),runtimeStatus:o.runtime,security:{alerts:e.socketIssues.alerts,lowScorePackages:e.socketIssues.lowScore,status:o.security,vulnerabilities:e.vulnCount},status:l,supplyChain:{findings:e.supplyChain.findings.map(c=>({detail:c.detail,label:c.label,severity:c.severity})),status:e.supplyChain.status},workspaces:e.workspaceCount}},"buildJsonPayload"),it=be((e,t)=>{const i=e.runtime.some(n=>n.status==="warn"),o=e.vulnCount>0||e.socketIssues.alerts>0;return t?o||e.outdated.length>0||e.duplicates.length>0||i:o},"shouldFail");var Ts=Object.defineProperty,Be=T((e,t)=>Ts(e,"name",{value:t,configurable:!0}),"u$1");const As=["aube-workspace.yaml","pnpm-workspace.yaml"],Ce=Be(e=>typeof e=="boolean"?e:void 0,"asBool"),Ps=Be(e=>{if(e==="no-downgrade"||e==="off")return e},"asTrustPolicy"),Is=Be(e=>{const t={allowBuildsCount:0,blockExoticSubdeps:void 0,jailBuilds:void 0,minimumReleaseAge:void 0,minimumReleaseAgeStrict:void 0,paranoid:void 0,source:void 0,strictDepBuilds:void 0,trustPolicy:void 0};for(const i of As){const o=J(e,i);if(!Ae(o))continue;let n;try{n=Vt(qt(o))}catch{continue}if(typeof n!="object"||n===null)continue;const l=n;return t.source=i,t.paranoid=Ce(l.paranoid),t.trustPolicy=Ps(l.trustPolicy),t.blockExoticSubdeps=Ce(l.blockExoticSubdeps),t.jailBuilds=Ce(l.jailBuilds),t.strictDepBuilds=Ce(l.strictDepBuilds),t.minimumReleaseAgeStrict=Ce(l.minimumReleaseAgeStrict),typeof l.minimumReleaseAge=="number"&&Number.isFinite(l.minimumReleaseAge)&&(t.minimumReleaseAge=l.minimumReleaseAge),l.allowBuilds&&typeof l.allowBuilds=="object"&&!Array.isArray(l.allowBuilds)&&(t.allowBuildsCount=Object.keys(l.allowBuilds).length),t}return t},"readAubeSecurityPosture"),Ds=Be(e=>e.paranoid?{...e,jailBuilds:!0,minimumReleaseAgeStrict:!0,strictDepBuilds:!0,trustPolicy:"no-downgrade"}:e,"applyAubeParanoidOverrides");var Os=Object.defineProperty,_e=T((e,t)=>Os(e,"name",{value:t,configurable:!0}),"i");const Ns=/^(@[\w./-]+\/[\w./-]+|[\w.-]+)@(.+)$/,Fs=_e(e=>{const t=Ns.exec(e);if(t)return{name:t[1],version:t[2]}},"parsePatchKey"),Ms=_e((e,t)=>{let i;try{if(t==="pnpm"){const n=J(e,"pnpm-workspace.yaml");Ae(n)&&(i=_t(n)?.patchedDependencies)}else if(t==="bun"){const n=J(e,"package.json");Ae(n)&&(i=pt(n)?.patchedDependencies)}}catch{return[]}if(!i||typeof i!="object")return[];const o=[];for(const[n,l]of Object.entries(i)){if(typeof l!="string"||l.length===0)continue;const c=Fs(n);c&&o.push({name:c.name,patchFile:l,resolvedPatchFile:Xt(l)?l:dt(e,l),version:c.version})}return o},"readPatchedDependencies"),Es=_e(e=>{const t=[];for(const i of e)Ae(i.resolvedPatchFile)||t.push({entry:i,kind:"missing-file"});return t},"findPatchIssues");var zs=Object.defineProperty,Ct=T((e,t)=>zs(e,"name",{value:t,configurable:!0}),"c");const st=Ct(e=>e.some(t=>t.severity==="error")?"error":e.some(t=>t.severity==="warn")?"warn":"ok","rollUpStatus"),Bs=Ct((e,t={})=>{const i=[],o=e?.security;if(!o)return i.push({detail:"Use defineConfig() from '@visulima/vis/config' to apply secure defaults.",label:"No security config — running with the PM's native defaults",severity:"warn"}),{findings:i,status:st(i)};const n=o.policies?.firstSeen?.minutes,l=o.policies?.publisherChange,c=o.policies?.installScripts;n===void 0?i.push({detail:"Set security.policies.firstSeen.minutes to block packages published in the last N minutes (mitigates supply-chain attacks).",label:"policies.firstSeen.minutes is not set",severity:"warn"}):n===0?i.push({detail:"New packages can be installed immediately after publishing. Consider setting a non-zero cooldown.",label:"policies.firstSeen.minutes is explicitly 0",severity:"warn"}):i.push({label:`policies.firstSeen.minutes: ${String(n)} minutes`,severity:"ok"}),l?.mode===void 0||l.mode==="off"?i.push({detail:"Packages whose trust level has decreased will not be blocked. Consider 'no-downgrade'.",label:`policies.publisherChange.mode: ${l?.mode??"not set"}`,severity:"warn"}):i.push({label:`policies.publisherChange.mode: ${l.mode}`,severity:"ok"}),o.blockExoticSubdeps===void 0||!o.blockExoticSubdeps?i.push({detail:"Transitive dependencies can pull code from git repos or tarball URLs. Set to true to block.",label:`blockExoticSubdeps: ${String(o.blockExoticSubdeps??!1)}`,severity:"warn"}):i.push({label:"blockExoticSubdeps: true",severity:"ok"});const p=c?.allow?Object.keys(c.allow).length:0;if(p===0?i.push({detail:"Lifecycle scripts are blocked by default. List trusted packages here to opt them back in (e.g. esbuild, @prisma/client).",label:"policies.installScripts.allow: not configured",severity:"warn"}):i.push({label:`policies.installScripts.allow: ${String(p)} ${p===1?"entry":"entries"}`,severity:"ok"}),c?.strict&&p===0&&i.push({detail:"All dependencies with build scripts will be blocked. Run 'vis approve-builds' to populate the allow list.",label:"policies.installScripts.strict is on but allow is empty",severity:"error"}),t.workspaceRoot){const a=xi(t.workspaceRoot);if(a.length>0){const g=[...new Set(a.map(y=>y.tool))].sort((y,w)=>y.localeCompare(w)).join(", ");i.push({detail:"Run `vis migrate verify` for the full list, then re-run `vis migrate <tool>` to clean up.",label:`${String(a.length)} leftover ${a.length===1?"reference":"references"} to ${g}`,severity:"warn"})}}if(t.workspaceRoot&&t.packageManager==="aube"){const a=Is(t.workspaceRoot),g=Ds(a),y=g.source?` (from ${g.source})`:"";g.paranoid===!0&&i.push({detail:"Forces jailBuilds, trustPolicy=no-downgrade, minimumReleaseAgeStrict, strictStoreIntegrity, and strictDepBuilds on.",label:`aube paranoid: true${y}`,severity:"ok"}),g.trustPolicy==="off"&&i.push({detail:"Trust downgrades between releases will not be blocked. Set trustPolicy: no-downgrade in aube-workspace.yaml.",label:`aube trustPolicy: off${y}`,severity:"warn"}),g.blockExoticSubdeps===!1&&i.push({detail:"Transitive deps from git+, file:, and tarball URLs will not be blocked. Re-enable with blockExoticSubdeps: true.",label:`aube blockExoticSubdeps: false${y}`,severity:"warn"}),g.minimumReleaseAge===0&&i.push({detail:"Newly published versions are not held in a cooling window. Restore with minimumReleaseAge: 1440 (24h) or higher.",label:`aube minimumReleaseAge: 0${y}`,severity:"warn"}),g.jailBuilds===!0&&i.push({label:`aube jailBuilds: true${y}`,severity:"ok"}),g.strictDepBuilds===!0&&i.push({label:`aube strictDepBuilds: true${y}`,severity:"ok"}),g.allowBuildsCount>0&&i.push({label:`aube allowBuilds: ${String(g.allowBuildsCount)} ${g.allowBuildsCount===1?"entry":"entries"}${y}`,severity:"ok"})}if(t.workspaceRoot&&t.packageManager){const a=Ms(t.workspaceRoot,t.packageManager);if(a.length>0){const g=Es(a);if(g.length===0)i.push({label:`patchedDependencies: ${String(a.length)} ${a.length===1?"entry":"entries"} resolved`,severity:"ok"});else for(const y of g)i.push({detail:`Referenced from ${t.packageManager==="pnpm"?"pnpm-workspace.yaml":"package.json"} but the file is not present at ${y.entry.patchFile}.`,label:`patchedDependencies: missing patch file for ${y.entry.name}@${y.entry.version}`,severity:"error"})}}return{findings:i,status:st(i)}},"buildSupplyChainPosture");var Ls=Object.defineProperty,$=T((e,t)=>Ls(e,"name",{value:t,configurable:!0}),"u");const H=$(e=>e>=1e3?`${(e/1e3).toFixed(1)}s`:`${String(Math.round(e))}ms`,"fmtDuration"),De=$(async(e,t,i,o)=>{if(!e)return i();e.start(t);const n=Date.now();try{const l=await i(),c=Date.now()-n,{status:p,summary:a}=o(l,c);return e.finish(t,p,a),l}catch(l){const c=Date.now()-n,p=l instanceof Error?l.message:String(l);throw e.finish(t,"error",`${p} (${H(c)})`),l}},"tracked"),Vs=$((e,t)=>{const i={duplicates:t.duplicates,elapsedMs:0,installedCount:0,optimizations:t.optimizations,outdated:t.outdated,runtime:t.runtime,sections:new Set([e]),socketIssues:{alerts:0,lowScore:0},supplyChain:{findings:[],status:"ok"},vulnCount:0,workspaceCount:0};return wt(i)},"buildSectionFindings"),rt=$(async e=>{const{filterPatterns:t,installed:i,progress:o,resolveCodemods:n,sections:l,store:c,visConfig:p,workspaceRoot:a}=e,g=l.has("dependencies"),y=l.has("security"),w=l.has("optimization"),A=l.has("runtime"),E=$((f,D)=>jt(Vs(f,D),t),"sectionFindings"),h=gt(a),{packageManager:P}=ot(a),z=Xe(J(a,"package.json"),!1),q=ht(a),V=new Set(z);for(const f of q){const D=Xe(J(dt(a,f),"package.json"),!1);for(const O of D)V.add(O)}const B=Gt(a),S=lt(a,P),G=at(p?.security,{minimumScore:p?.security?.policies?.score?.minimum}),U=p?.security?.policies?.score?.minimum??ct,oe=p?.security?.acceptedRisks,ie=ii(a,h.name),_={exclude:[],ignore:[],include:[],includeLocked:!1,includePrerelease:!1,security:!0,target:"latest"},F=g?ui(a,h.name):[],K=w?si(V):[],b=w?ri(V,ie,h,!1):[],j=new Set(K.map(f=>f.packageName)),X=b.filter(f=>!j.has(f.packageName)),C=[...K,...X],le=A?Ei(a):[];c&&(g&&c.startSection("dependencies",S.size>0?"checking outdated catalog dependencies":"scanning duplicates"),y&&c.startSection("security",i.length>0?`scanning ${String(i.length)} packages for advisories`:"no installed packages to scan"),w&&c.startSection("optimization","matching e18e + socket overrides"),A&&c.startSection("runtime","running runtime diagnostics")),c&&A&&c.completeSection("runtime",E("runtime",{duplicates:[],optimizations:[],outdated:[],runtime:le}));const ue=(g||y)&&S.size>0?De(o,"outdated",()=>Ut(S,_,B,void 0,a,G,oe),(f,D)=>{const O=f.outdated.length;return{status:O>0?"warn":"ok",summary:O>0?`${String(O)} outdated · ${H(D)}`:`up to date · ${H(D)}`}}):Promise.resolve({failed:[],ignored:[],outdated:[]}),I=y&&i.length>0?De(o,"vulnerabilities",()=>Ht(i.map(f=>({name:f.name,version:f.version}))),(f,D)=>{let O=0;for(const se of f.values())O+=se.length;return{status:O>0?"error":"ok",summary:O>0?`${String(O)} found · ${H(D)}`:`none found · ${H(D)}`}}):Promise.resolve(new Map),Q=y&&G.length>0&&i.length>0?De(o,"socket",()=>Kt(G,i.map(f=>({name:f.name,version:f.version}))),(f,D)=>{let O=0,se=0;for(const Ye of f.values())O+=Ye.alerts.length,Ye.score.overall<U&&(se+=1);const Ke=O+se;return{status:Ke>0?"warn":"ok",summary:Ke>0?`${String(O)} alert${O===1?"":"s"}, ${String(se)} low-score · ${H(D)}`:`clean · ${H(D)}`}}):Promise.resolve(new Map);let ee,pe,he,ge;const fe=ue.catch(f=>(ee=f instanceof Error?f.message:String(f),c||d.warn(`Outdated scan failed: ${ee}`),{failed:[],ignored:[],outdated:[]})),je=I.catch(f=>(pe=f instanceof Error?f.message:String(f),c||d.warn(`Vulnerability scan failed: ${pe}`),new Map)),x=Q.catch(f=>(he=f instanceof Error?f.message:String(f),c||d.warn(`Socket scan failed: ${he}`),new Map)),m=c&&g?fe.then(f=>{if(ee){c.failSection("dependencies",ee);return}c.completeSection("dependencies",E("dependencies",{duplicates:F,optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,k=c&&y?Promise.all([fe,je,x]).then(([f])=>{const D=ee??pe??he;if(D){c.failSection("security",D);return}c.completeSection("security",E("security",{duplicates:[],optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,$e=(async()=>{if(n&&w&&C.length>0&&await De(o,"codemods",async()=>(await ni(C),C),(f,D)=>{const O=f.filter(se=>se.hasCodemod||se.category==="socket").length;return{status:"ok",summary:`${String(O)} auto-fixable · ${H(D)}`}}).catch(f=>{ge=f instanceof Error?f.message:String(f)}),c&&w){if(ge){c.failSection("optimization",ge);return}c.completeSection("optimization",E("optimization",{duplicates:[],optimizations:C,outdated:[],runtime:[]}))}})(),[ae,Tt,At]=await Promise.all([fe,je,x]);await Promise.all([m,k,$e]);let Ue=0,He=0;if(y&&G.length>0)for(const f of At.values())Ue+=f.alerts.length,f.score.overall<U&&(He+=1);let Le=0;if(y){for(const f of ae.outdated)f.vulnerabilities&&f.vulnerabilities.length>0&&(Le+=f.vulnerabilities.length);for(const f of Tt.values())Le+=f.length}return{duplicates:F,installedCount:i.length,optimizations:w?C:[],outdated:g?ae.outdated:[],runtime:le,sections:l,socketIssues:{alerts:Ue,lowScore:He},supplyChain:Bs(p,{packageManager:P,workspaceRoot:a}),vulnCount:Le,workspaceCount:q.length}},"streamScans"),_s=$(e=>{switch(e){case"error":return Re(N.failure);case"skip":return v(N.dash);case"warn":return Me(N.warning);default:return we(N.success)}},"sectionIcon"),de=$((e,t)=>{const i=process.stderr.columns??80,o=Math.max(20,Math.min(i-2,60)),n=N.dash.repeat(2),l=`${_s(t)} ${ce(e)}`,c=l.replaceAll(/\[[0-9;]*m/g,"").length,p=Math.max(0,o-c-n.length-2);return`${n} ${l} ${v(N.dash.repeat(p))}`},"heading"),W=$(e=>` ${we(N.success)} ${e}`,"itemOk"),Z=$(e=>` ${Me(N.warning)} ${e}`,"itemWarn"),Ge=$(e=>` ${Re(N.failure)} ${e}`,"itemError"),Rt=$(e=>` ${v(N.dash)} ${v(e)}`,"itemSkip"),Y=$((e,t,i)=>{const o=`${ce(String(e))} ${v(t)}`;return i?`${o} ${v(`(${i})`)}`:o},"countLine"),Gs=$(e=>{if(e.sections.has("dependencies")){if(d.log(""),d.log(de("Dependencies",re(e,"dependencies"))),d.log(W(Y(e.installedCount,"packages installed"))),e.outdated.length>0){const t=e.outdated.filter(l=>l.updateType==="major").length,i=e.outdated.filter(l=>l.updateType==="minor").length,o=e.outdated.filter(l=>l.updateType==="patch").length,n=[];t>0&&n.push(`${String(t)} major`),i>0&&n.push(`${String(i)} minor`),o>0&&n.push(`${String(o)} patch`),d.log(Z(Y(e.outdated.length,"outdated",n.join(", "))))}else d.log(W("All dependencies up to date"));e.duplicates.length>0?d.log(Z(Y(e.duplicates.length,"packages with duplicate versions"))):d.log(W("No duplicate dependencies"))}},"displayDependencies"),Us=$(e=>{e.sections.has("security")&&(d.log(""),d.log(de("Security",re(e,"security"))),e.vulnCount>0?d.log(Ge(Y(e.vulnCount,`vulnerabilit${e.vulnCount===1?"y":"ies"} found`))):d.log(W("No known vulnerabilities")),e.socketIssues.alerts>0&&d.log(Z(Y(e.socketIssues.alerts,`Socket.dev security alert${e.socketIssues.alerts===1?"":"s"}`))),e.socketIssues.lowScore>0&&d.log(Z(Y(e.socketIssues.lowScore,`package${e.socketIssues.lowScore===1?"":"s"} with low security score`))),e.socketIssues.alerts===0&&e.socketIssues.lowScore===0&&e.vulnCount===0&&d.log(W("No security issues detected")))},"displaySecurity"),Hs=$(e=>{if(!e.sections.has("optimization"))return;d.log(""),d.log(de("Optimization",re(e,"optimization")));const t=St(e.optimizations);if(t.total===0){d.log(W("No optimizations available"));return}t.native>0&&d.log(Z(Y(t.native,"replaceable with native APIs"))),t.preferred>0&&d.log(Z(Y(t.preferred,"with lighter alternatives"))),t.micro>0&&d.log(Z(Y(t.micro,"trivial micro-utilities"))),t.socket>0&&d.log(Z(Y(t.socket,"@socketregistry overrides available")))},"displayOptimization"),Ks=$(e=>{d.log(""),d.log(de("Supply Chain",e.supplyChain.status));for(const t of e.supplyChain.findings){const i=t.severity==="ok"?W(t.label):t.severity==="error"?Ge(t.label):Z(t.label);d.log(i),t.detail&&d.log(` ${v(N.arrow)} ${v(t.detail)}`)}e.supplyChain.status!=="ok"&&d.log(` ${v(N.arrow)} ${v("Configure with security.* in vis.config.ts. See `vis check --security-config` for details.")}`)},"displaySupplyChain"),Ys=$(e=>{if(e.sections.has("runtime")){d.log(""),d.log(de("Runtime",re(e,"runtime")));for(const t of e.runtime)t.status==="ok"?d.log(W(t.message)):t.status==="skip"?d.log(Rt(t.message)):d.log(Z(t.message))}},"displayRuntime"),Ws=$((e,t)=>{const i=e.vulnCount,o=e.runtime.filter(l=>l.status==="warn").length,n=e.outdated.length+e.duplicates.length+e.optimizations.length+o;if(t){if(i===0&&n===0)d.success(`Everything looks good! ${v(`(${H(e.elapsedMs)})`)}`);else{const l=[];i>0&&l.push(Re(`${String(i)} security`)),n>0&&l.push(Me(`${String(n)} improvement${n===1?"":"s"}`)),d.log(`${Re(N.failure)} ${l.join(", ")} ${v(`(${H(e.elapsedMs)})`)}`)}return}d.log(""),d.log(de("Summary","ok")),i===0&&n===0?d.success(`Everything looks good! ${v(`(${H(e.elapsedMs)})`)}`):(i>0&&d.error(`${String(i)} security issue${i===1?"":"s"}`),n>0&&d.log(` ${Te(N.arrow)} ${ce(String(n))} ${v(`improvement${n===1?"":"s"} available`)} ${v(`(${H(e.elapsedMs)})`)}`))},"displaySummary"),Js=$(e=>{const t=[];if(e.outdated.length>0&&t.push("vis update — update outdated dependencies"),(e.vulnCount>0||e.socketIssues.alerts>0)&&t.push("vis audit — detailed security analysis"),e.optimizations.length>0&&t.push("vis optimize — apply optimizations interactively"),e.duplicates.length>0&&t.push("vis dedupe — reduce duplicate versions"),t.length>0){d.log(""),d.log(ce("Next steps:"));for(const i of t)d.log(` ${v(N.arrow)} ${i}`)}d.log("")},"displayActions"),qs=$((e,t)=>{t||(Gs(e),Us(e),Hs(e),Ys(e),Ks(e)),Ws(e,t)},"displayResults"),Xs=$((e,t,i,o,n)=>{const l=[],c=e.has("dependencies"),p=e.has("security"),a=e.has("optimization");return(c||p)&&t>0&&l.push({id:"outdated",label:"Outdated catalog dependencies"}),p&&o>0&&l.push({id:"vulnerabilities",label:"Known vulnerabilities (OSV)"}),p&&i&&o>0&&l.push({id:"socket",label:"Socket.dev supply-chain reports"}),a&&n&&l.push({id:"codemods",label:"Codemod availability"}),l},"planScanTasks"),Qs=$(e=>{if(d.log(""),d.log(`${ce(Te("vis doctor"))} ${v("— project health check")}`),d.log(W(`Detected ${e.packageManagerName} v${e.packageManagerVersion}`)),e.workspaceCount!==void 0&&e.workspaceCount>0&&d.log(W(Y(e.workspaceCount,`workspace package${e.workspaceCount===1?"":"s"}`))),e.runtimeFindings.length===0)d.log(W(`Node.js ${e.nodeVersion}`));else{for(const t of e.runtimeFindings){const i=t.severity==="error"?Re:Me;d.log(Ge(`Runtime: ${i(t.message)}`))}d.log(` ${v(N.arrow)} Run ${we("vis toolchain install")} to install pinned versions, or ${we("vis toolchain status")} for the per-tool breakdown.`)}d.log("")},"printBanner"),fr=$(async({logger:e,options:t,visConfig:i,visConfigError:o,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root.");const l=t.format==="json"||t.json===!0,c=Cs(t.only,t.skip),p=!!t.quiet,a=t.progress===!1,g=js(t.filter);if(c.size===0){d.error("No sections selected. Check your --only / --skip values."),process.exitCode=2;return}const y=Date.now(),w=gt(n),A=ci(n),E=!!process.stdout.isTTY,h=!l&&E&&!Jt&&!p&&!a;!l&&!h&&Qs({nodeVersion:process.versions.node,packageManagerName:w.name,packageManagerVersion:w.version,runtimeFindings:A,workspaceCount:void 0});const P=lt(n,ot(n).packageManager),z=pi(n,w.name),q=z.length,V=at(i?.security).length>0,B=i?.security?.policies?.score?.minimum??ct,S=ht(n);if(!l&&!p&&!h){const I=S.length>0?v(` · ${String(S.length)} workspace package${S.length===1?"":"s"}`):"";d.log(`${v("·")} ${v("Found")} ${ce(String(q))} ${v(`installed package${q===1?"":"s"}`)}${I}`)}const G=o?{hint:o.file?`Continuing with default settings — fix or regenerate ${o.file} (vis init --force).`:"Continuing with default settings.",message:o.message,severity:"error",title:o.file?`Failed to load ${o.file}`:"Failed to load vis.config"}:void 0,U=hi(n,w.name)?.file,oe=U?J(n,U):void 0,ie=ti(n),_=t.cache!==!1&&!t.fix?vi({configPath:ie,lockfilePath:oe,sections:c,socketEnabled:V,workspaceRoot:n}):void 0,F=_?bi(_):void 0,K=F!==void 0;let b,j;if(h){const I=F?new Ze({activeSections:c,findings:jt(wt(F),g)}):new Ze({activeSections:c}),Q=Yt(Wt.createElement(ks,{banner:G,fromCache:K,startedAt:y,store:I}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0});try{b=F??await rt({filterPatterns:g,installed:z,resolveCodemods:!!t.fix,sections:c,store:I,visConfig:i,workspaceRoot:n})}catch(ee){throw Q.unmount(),ee}await Q.waitUntilExit(),j=I.getSnapshot().pendingAction}else if(F)b=F;else{const I=Xs(c,P.size,V,q,!!t.fix),Q=di(I,{live:!l&&!p&&!a});try{b=await rt({filterPatterns:g,installed:z,progress:Q,resolveCodemods:!!t.fix,sections:c,visConfig:i,workspaceRoot:n})}finally{Q.stop()}}const X={...b,elapsedMs:Date.now()-y};if(_&&!K)try{ji(_,X)}catch{}const C=$s(X,g,B);if(l){process.stdout.write(`${JSON.stringify(Rs(C,w.name),void 0,2)}
4
+ `),t.exitCode&&it(C,!!t.strict)&&(process.exitCode=1);return}K&&!p&&d.log(`${v("·")} Cached results (use --no-cache to refresh)`),g.length>0&&!p&&d.log(`${v("·")} Filter active: ${Te(t.filter??"")}`),qs(C,p);const le=C.runtime.some(I=>I.id===Oe&&I.status==="warn"),ue=C.sections.has("optimization")&&C.optimizations.length>0;t.fix&&(ue||le)?await Zs({force:!!t.fixForce,logger:e,pm:w,recoverOrphans:le,results:C,useEditorconfig:i?.editorconfig??!0,workspaceRoot:n}):p||Js(C),j&&(process.stdout.write(`
5
5
  `),process.stdout.write(`${ce("→ ")}${j.description}
6
6
  `),j.configSnippet?(process.stdout.write(`
7
7
  `),process.stdout.write(`${v(j.configSnippet)}
8
8
  `)):process.stdout.write(` ${Te(j.command)}
9
9
  `),process.stdout.write(`
10
- `)),t.exitCode&&it(C,!!t.strict)&&(process.exitCode=1)},"execute"),Zs=$(async e=>{const{force:t,logger:i,pm:o,recoverOrphans:n,results:l,useEditorconfig:c,workspaceRoot:h}=e;d.log(""),d.log(de("Applying fixes","ok"));const a=l.optimizations.filter(p=>p.category==="socket"&&p.overrideSpec).map(p=>({original:p.packageName,spec:p.overrideSpec})),g=l.optimizations.filter(p=>p.category!=="socket"&&p.hasCodemod),y=l.optimizations.filter(p=>p.category!=="socket"&&!p.hasCodemod);let w=!1,A=0;const E=[];if(n){const p=Ai({force:t});if(p.killed.length>0&&(d.success(`Cleaned up ${String(p.killed.length)} orphaned process${p.killed.length===1?"":"es"} (PIDs: ${p.killed.join(", ")}).`),w=!0),p.failed.length>0){const P=t?"":" Re-run with `--fix --fix-force` to escalate to SIGKILL.";d.warn(`Could not signal ${String(p.failed.length)} orphan${p.failed.length===1?"":"s"}: ${p.failed.map(z=>`${String(z.pid)} (${z.reason})`).join(", ")}.${P}`)}}if(a.length>0){const p=oi(h,J(h,"package.json"),a,o,c);p.added.length>0&&(d.success(`Added ${String(p.added.length)} security override${p.added.length===1?"":"s"}.`),w=!0),p.updated.length>0&&(d.success(`Updated ${String(p.updated.length)} override${p.updated.length===1?"":"s"}.`),w=!0)}for(const p of g)try{const P=await li(h,p.packageName);P.filesChanged>0&&(d.success(`${p.packageName}: ${String(P.filesChanged)} file${P.filesChanged===1?"":"s"} updated`),A+=1,w=!0)}catch(P){const z=P instanceof Error?P.message:String(P);E.push({error:z,package:p.packageName}),d.warn(`${p.packageName}: codemod failed — ${z}`)}a.length>0&&(d.log(`${Te(N.arrow)} Running ${o.name} install to update lockfile…`),ai(o,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},h,i),w=!0),d.log(""),w?d.success(`Fixes applied. ${A>0?`${String(A)} codemod${A===1?"":"s"} applied.`:""}`.trim()):d.log(Rt("No auto-fixable items in the current run.")),E.length>0&&d.warn(`${String(E.length)} codemod${E.length===1?"":"s"} failed (run ${we("vis optimize")} for the interactive picker).`),y.length>0&&d.notice(`${String(y.length)} optimization${y.length===1?"":"s"} need manual review (no codemod). Run ${we("vis optimize")} to inspect them.`)},"runFixes");export{fr as default};
10
+ `)),t.exitCode&&it(C,!!t.strict)&&(process.exitCode=1)},"execute"),Zs=$(async e=>{const{force:t,logger:i,pm:o,recoverOrphans:n,results:l,useEditorconfig:c,workspaceRoot:p}=e;d.log(""),d.log(de("Applying fixes","ok"));const a=l.optimizations.filter(h=>h.category==="socket"&&h.overrideSpec).map(h=>({original:h.packageName,spec:h.overrideSpec})),g=l.optimizations.filter(h=>h.category!=="socket"&&h.hasCodemod),y=l.optimizations.filter(h=>h.category!=="socket"&&!h.hasCodemod);let w=!1,A=0;const E=[];if(n){const h=Ai({force:t});if(h.killed.length>0&&(d.success(`Cleaned up ${String(h.killed.length)} orphaned process${h.killed.length===1?"":"es"} (PIDs: ${h.killed.join(", ")}).`),w=!0),h.failed.length>0){const P=t?"":" Re-run with `--fix --fix-force` to escalate to SIGKILL.";d.warn(`Could not signal ${String(h.failed.length)} orphan${h.failed.length===1?"":"s"}: ${h.failed.map(z=>`${String(z.pid)} (${z.reason})`).join(", ")}.${P}`)}}if(a.length>0){const h=oi(p,J(p,"package.json"),a,o,c);h.added.length>0&&(d.success(`Added ${String(h.added.length)} security override${h.added.length===1?"":"s"}.`),w=!0),h.updated.length>0&&(d.success(`Updated ${String(h.updated.length)} override${h.updated.length===1?"":"s"}.`),w=!0)}for(const h of g)try{const P=await li(p,h.packageName);P.filesChanged>0&&(d.success(`${h.packageName}: ${String(P.filesChanged)} file${P.filesChanged===1?"":"s"} updated`),A+=1,w=!0)}catch(P){const z=P instanceof Error?P.message:String(P);E.push({error:z,package:h.packageName}),d.warn(`${h.packageName}: codemod failed — ${z}`)}a.length>0&&(d.log(`${Te(N.arrow)} Running ${o.name} install to update lockfile…`),ai(o,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},p,i),w=!0),d.log(""),w?d.success(`Fixes applied. ${A>0?`${String(A)} codemod${A===1?"":"s"} applied.`:""}`.trim()):d.log(Rt("No auto-fixable items in the current run.")),E.length>0&&d.warn(`${String(E.length)} codemod${E.length===1?"":"s"} failed (run ${we("vis optimize")} for the interactive picker).`),y.length>0&&d.notice(`${String(y.length)} optimization${y.length===1?"":"s"} need manual review (no codemod). Run ${we("vis optimize")} to inspect them.`)},"runFixes");export{fr as default};