@visulima/vis 1.0.0-alpha.14 → 1.0.0-alpha.15

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 (87) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE.md +936 -1
  3. package/dist/bin.js +1 -1
  4. package/dist/config/index.js +1 -1
  5. package/dist/packem_chunks/applyDefaults.js +2 -2
  6. package/dist/packem_chunks/bin.js +314 -311
  7. package/dist/packem_chunks/fix.js +1 -1
  8. package/dist/packem_chunks/handler.js +1 -1
  9. package/dist/packem_chunks/handler10.js +1 -1
  10. package/dist/packem_chunks/handler12.js +5 -5
  11. package/dist/packem_chunks/handler14.js +3 -3
  12. package/dist/packem_chunks/handler15.js +1 -1
  13. package/dist/packem_chunks/handler18.js +1 -1
  14. package/dist/packem_chunks/handler19.js +1 -1
  15. package/dist/packem_chunks/handler2.js +1 -1
  16. package/dist/packem_chunks/handler20.js +1 -1
  17. package/dist/packem_chunks/handler22.js +1 -1
  18. package/dist/packem_chunks/handler23.js +1 -1
  19. package/dist/packem_chunks/handler24.js +1 -1
  20. package/dist/packem_chunks/handler25.js +1 -1
  21. package/dist/packem_chunks/handler26.js +1 -1
  22. package/dist/packem_chunks/handler27.js +2 -2
  23. package/dist/packem_chunks/handler28.js +7 -7
  24. package/dist/packem_chunks/handler3.js +1 -1
  25. package/dist/packem_chunks/handler30.js +10 -10
  26. package/dist/packem_chunks/handler31.js +1 -1
  27. package/dist/packem_chunks/handler32.js +1 -1
  28. package/dist/packem_chunks/handler33.js +21 -21
  29. package/dist/packem_chunks/handler34.js +2 -2
  30. package/dist/packem_chunks/handler35.js +3 -3
  31. package/dist/packem_chunks/handler36.js +20 -20
  32. package/dist/packem_chunks/handler37.js +1 -1
  33. package/dist/packem_chunks/handler38.js +2 -2
  34. package/dist/packem_chunks/handler39.js +10 -10
  35. package/dist/packem_chunks/handler40.js +5 -5
  36. package/dist/packem_chunks/handler41.js +10 -24
  37. package/dist/packem_chunks/handler42.js +24 -10
  38. package/dist/packem_chunks/handler43.js +5 -5
  39. package/dist/packem_chunks/handler44.js +5 -5
  40. package/dist/packem_chunks/handler45.js +3 -3
  41. package/dist/packem_chunks/handler46.js +11 -11
  42. package/dist/packem_chunks/handler47.js +15 -15
  43. package/dist/packem_chunks/handler48.js +6 -6
  44. package/dist/packem_chunks/handler5.js +1 -1
  45. package/dist/packem_chunks/handler6.js +1 -1
  46. package/dist/packem_chunks/handler7.js +1 -1
  47. package/dist/packem_chunks/heal-accept.js +1 -1
  48. package/dist/packem_chunks/heal.js +1 -1
  49. package/dist/packem_chunks/help-command.js +1 -1
  50. package/dist/packem_chunks/index.js +2 -2
  51. package/dist/packem_chunks/loader.js +1 -1
  52. package/dist/packem_chunks/tar.js +1 -1
  53. package/dist/packem_shared/{ai-analysis-Dzs_nUwM.js → ai-analysis-CGVjqwdc.js} +1 -1
  54. package/dist/packem_shared/ai-cache-BdPgSfg2.js +1 -0
  55. package/dist/packem_shared/{ai-fix-BmLM72GS.js → ai-fix-iHtGLkJS.js} +1 -1
  56. package/dist/packem_shared/cache-directory-DTfMSzT9.js +1 -0
  57. package/dist/packem_shared/dependency-scan-SQeRzrpJ.js +2 -0
  58. package/dist/packem_shared/docker-D5p9mRPU.js +2 -0
  59. package/dist/packem_shared/failure-log-CElcbnb9.js +2 -0
  60. package/dist/packem_shared/flakiness-C4t4_NoA.js +1 -0
  61. package/dist/packem_shared/{giget-BX2ixMoa.js → giget-CcEy_Elm.js} +2 -2
  62. package/dist/packem_shared/lockfile-B7JJzxnL.js +1 -0
  63. package/dist/packem_shared/otel-CO8UEfTa.js +17 -0
  64. package/dist/packem_shared/otelPlugin-DTynZDWh.js +1 -0
  65. package/dist/packem_shared/readTomlSync-1fKo0R52-DAKNI1Me.js +109 -0
  66. package/dist/packem_shared/registry-D04iOQ5H.js +2 -0
  67. package/dist/packem_shared/run-summary-utils-BPraMTcm.js +1 -0
  68. package/dist/packem_shared/{runtime-check-BaKni2y1.js → runtime-check-l4qFpo08.js} +1 -1
  69. package/dist/packem_shared/{selectors-BvtUXWGY.js → selectors-Sem2CTYA.js} +1 -1
  70. package/dist/packem_shared/{toolchain-B7sIiJxK.js → toolchain-BhZNts--.js} +3 -3
  71. package/dist/packem_shared/typosquats-Dr7VIL2B.js +1 -0
  72. package/dist/packem_shared/verify-C6NNOhTA.js +1 -0
  73. package/dist/packem_shared/{vis-update-app-DR8c4OfG.js → vis-update-app-DGiMc5kb.js} +1 -1
  74. package/package.json +10 -12
  75. package/dist/packem_shared/ai-cache-Dtvmbsru.js +0 -1
  76. package/dist/packem_shared/cache-directory-xASJia6M.js +0 -1
  77. package/dist/packem_shared/dependency-scan-DmwPKwLy.js +0 -2
  78. package/dist/packem_shared/docker-CA-scYu0.js +0 -2
  79. package/dist/packem_shared/failure-log-fD4DiFb1.js +0 -2
  80. package/dist/packem_shared/flakiness-BIg1rwvp.js +0 -1
  81. package/dist/packem_shared/index-OlP7U_t5.js +0 -6
  82. package/dist/packem_shared/lockfile-BXylopgH.js +0 -1
  83. package/dist/packem_shared/otelPlugin-y5hoCw4b.js +0 -1
  84. package/dist/packem_shared/registry-BHqKXiLb.js +0 -2
  85. package/dist/packem_shared/run-summary-utils-D39XBHWW.js +0 -1
  86. package/dist/packem_shared/typosquats-XkC1CnOa.js +0 -1
  87. package/dist/packem_shared/verify-BVTcVfoW.js +0 -1
@@ -1,24 +1,10 @@
1
- var me=Object.defineProperty;var O=(r,e)=>me(r,"name",{value:e,configurable:!0});import{createRequire as he}from"node:module";import{Y as oe,aO as ke,aA as we,aB as be,aC as K,A as xe,p as b,r as $e,s as Ce}from"./bin.js";import{isAccessibleSync as X,readFileSync as G,writeFileSync as M,readJsonSync as ie,glob as Se}from"@visulima/fs";import{M as j,C as Oe}from"../packem_shared/index-OlP7U_t5.js";import{Box as h,Text as s,ScrollView as Pe,ScrollBar as Ne,useApp as Ee,useWindowSize as _e,useInput as je,render as Te}from"@visulima/tui";import Ae from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import De from"module-replacements/manifests/native.json"with{type:"json"};import Re from"module-replacements/manifests/preferred.json"with{type:"json"};import Ie,{useSyncExternalStore as Me,useRef as Fe,useState as Y,useCallback as Ge}from"react";import{readYamlSync as Le}from"@visulima/fs/yaml";import{jsx as o,jsxs as m,Fragment as U}from"react/jsx-runtime";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
- const require = __cjs_mod__.createRequire(import.meta.url);
3
- const ge=he(import.meta.url),I=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ye=O(r=>{if(typeof I<"u"&&I.versions&&I.versions.node){const[e,t]=I.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return I.getBuiltinModule(r)}return ge(r)},"__cjs_getBuiltinModule"),{writeFileSync:ve}=ye("node:fs");var qe=Object.defineProperty,_=O((r,e)=>qe(r,"name",{value:e,configurable:!0}),"d$1");const ze=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ue=["overrides","pnpm","resolutions"],Be=["engines","files"],Je=_(r=>{const e=oe.coerce(r)?.major;return e!==void 0&&e>=10},"isPnpmV10Plus"),He=_(r=>{const e=j(r,"pnpm-workspace.yaml");if(!X(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Le(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},"readPnpmWorkspaceOverrides"),Ve=_((r,e)=>{let t={};return e==="deno"?{overrides:{},source:"package.json"}:(e==="pnpm"?t=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?t=r.resolutions??{}:t=r.overrides??{},{overrides:t,source:"package.json"})},"readPkgJsonOverrides"),We=_((r,e,t)=>t.name==="pnpm"&&Je(t.version)?He(r):Ve(e,t.name),"readOverrides"),Q=_((r,e)=>{const t=e;for(const a of Ue){const i=r.indexOf(a);if(i!==-1&&a!==t)return t==="overrides"?i:i+1}let n=-1;for(const a of ze){const i=r.indexOf(a);i>n&&(n=i)}if(n!==-1)return n+1;for(const a of Be){const i=r.indexOf(a);if(i!==-1)return i}return r.length},"findInsertIndex"),Xe=_((r,e)=>{const t=j(r,"pnpm-workspace.yaml");if(!X(t))throw new Error(`pnpm-workspace.yaml not found at ${t}. Cannot write overrides for pnpm v10+.`);let n=G(t);const a=`overrides:
4
- ${Object.entries(e).map(([i,l])=>` '${i}': '${l}'`).join(`
5
- `)}
6
- `;n=/^overrides:\s*$/m.test(n)||/^overrides:\s*\n/m.test(n)?n.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,a):`${n.trimEnd()}
7
-
8
- ${a}`,M(t,n)},"writePnpmWorkspaceOverrides"),Ke=_((r,e,t,n,a)=>{const i=G(r),l=ke(r,i,{useEditorconfig:a});if(n==="pnpm"){const v=e.pnpm??{};if(v.overrides=t,e.pnpm)e.pnpm=v,M(r,`${JSON.stringify(e,null,l)}
9
- `);else{const x=Object.keys(e),w=Q(x,"pnpm"),k=Object.entries(e);k.splice(w,0,["pnpm",v]),M(r,`${JSON.stringify(Object.fromEntries(k),null,l)}
10
- `)}}else{const v=n==="yarn"||n==="bun"?"resolutions":"overrides";if(e[v])e[v]=t,M(r,`${JSON.stringify(e,null,l)}
11
- `);else{const x=Object.keys(e),w=Q(x,v),k=Object.entries(e);k.splice(w,0,[v,t]),M(r,`${JSON.stringify(Object.fromEntries(k),null,l)}
12
- `)}}},"writePkgJsonOverrides"),Ye=_((r,e,t,n,a)=>{if(n.name==="deno")return{added:[],updated:[]};const i=G(e),l=JSON.parse(i),{overrides:v,source:x}=We(r,l,n),w=[],k=[],c=new Set;if(n.name==="npm")for(const p of["dependencies","devDependencies"]){const g=l[p];if(g)for(const y of Object.keys(g))c.add(y)}for(const p of t){const g=v[p.original];if(typeof g=="object")continue;let y=p.spec;n.name==="npm"&&c.has(p.original)&&(y=`$${p.original}`),g!==y&&(g?k.push(p.original):w.push(p.original),v[p.original]=y)}if(w.length===0&&k.length===0)return{added:w,updated:k};const f=Object.fromEntries(Object.entries(v).sort(([p],[g])=>p.localeCompare(g)));return x==="pnpm-workspace.yaml"?Xe(r,f):Ke(e,l,f,n.name,a),{added:w,updated:k}},"applyOverrides"),Qe=_((r,e)=>{const t={bun:["bun.lock"],deno:["deno.lock"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]};for(const n of t[e]??[]){const a=j(r,n);try{return G(a)}catch{continue}}return""},"readLockfileText"),Ze=_((r,e,t)=>{if(!r)return!1;const n=e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);switch(t){case"bun":return r.includes(`"${e}":`)||new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(r);case"deno":return r.includes(`"${e}"`)||r.includes(`"npm:${e}@`)||r.includes(`"jsr:${e}@`);case"npm":return r.includes(`"${e}":`)||r.includes(`"node_modules/${e}":`);case"pnpm":return new RegExp(String.raw`(^|\s|['"/])${n}(@|['"]?:)`,"m").test(r);case"yarn":return new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(r);default:return!1}},"lockfileContainsPackage");var H={exports:{}},V,Z;function ee(){if(Z)return V;Z=1;var r=Object.defineProperty,e=O((c,f)=>r(c,"name",{value:f,configurable:!0}),"t"),t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,l=e((c,f)=>{for(var p in f)t(c,p,{get:f[p],enumerable:!0})},"__export"),v=e((c,f,p,g)=>{if(f&&typeof f=="object"||typeof f=="function")for(let y of a(f))!i.call(c,y)&&y!==p&&t(c,y,{get:e(()=>f[y],"get"),enumerable:!(g=n(f,y))||g.enumerable});return c},"__copyProps"),x=e(c=>v(t({},"__esModule",{value:!0}),c),"__toCommonJS"),w={};l(w,{PURL_Type:e(()=>k,"PURL_Type")}),V=x(w);var k=(c=>(c.APK="apk",c.BITBUCKET="bitbucket",c.COCOAPODS="cocoapods",c.CARGO="cargo",c.CHROME="chrome",c.COMPOSER="composer",c.CONAN="conan",c.CONDA="conda",c.CRAN="cran",c.DEB="deb",c.DOCKER="docker",c.GEM="gem",c.GENERIC="generic",c.GITHUB="github",c.GOLANG="golang",c.HACKAGE="hackage",c.HEX="hex",c.HUGGINGFACE="huggingface",c.MAVEN="maven",c.MLFLOW="mlflow",c.NPM="npm",c.NUGET="nuget",c.OCI="oci",c.PUB="pub",c.PYPI="pypi",c.QPKG="qpkg",c.RPM="rpm",c.SWID="swid",c.SWIFT="swift",c.VCS="vcs",c))(k||{});return V}O(ee,"requireTypes");var re;function er(){return re||(re=1,(function(r){var e=Object.defineProperty,t=O((f,p)=>e(f,"name",{value:p,configurable:!0}),"a"),n=Object.defineProperty,a=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,v=t((f,p)=>{for(var g in p)n(f,g,{get:p[g],enumerable:!0})},"__export"),x=t((f,p,g,y)=>{if(p&&typeof p=="object"||typeof p=="function")for(let u of i(p))!l.call(f,u)&&u!==g&&n(f,u,{get:t(()=>p[u],"get"),enumerable:!(y=a(p,u))||y.enumerable});return f},"__copyProps"),w=t((f,p,g)=>(x(f,p,"default"),g&&x(g,p,"default")),"__reExport"),k={};v(k,{getManifestData:t(()=>c,"getManifestData")}),w(k,ee(),r.exports);function c(f,p){try{const g=require("../manifest.json");if(!f)return g;const y=g[f];if(!y)return;if(!p)return y;const u=y.find(([C,S])=>S.package===p);return u?u[1]:void 0}catch{return}}O(c,"getManifestData"),t(c,"getManifestData"),r.exports={getManifestData:c,...ee()}})(H)),H.exports}O(er,"requireDist");var rr=er(),tr=Object.defineProperty,F=O((r,e)=>tr(r,"name",{value:e,configurable:!0}),"s");const nr=F((r,e,t)=>{let n=r;if(e!=="all"&&(n=n.filter(a=>a.category===e)),t){const a=t.toLowerCase();n=n.filter(i=>i.packageName.toLowerCase().includes(a))}return n},"filterEntries");class or{static{O(this,"h")}static{F(this,"OptimizeStore")}#e;#t=new Set;constructor(e){this.#e={applyProgress:null,checkedEntries:new Set,entries:e,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",phase:"browsing",selectedIndex:0}}getSnapshot=F(()=>this.#e,"getSnapshot");subscribe=F(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredEntries=F(()=>nr(this.#e.entries,this.#e.filterType,this.#e.filterText),"getFilteredEntries");#r(){this.#e={...this.#e};for(const e of this.#t)e()}select(e){const t=this.getFilteredEntries();this.#e.selectedIndex=t.length===0?-1:Math.max(0,Math.min(e,t.length-1)),this.#r()}toggleCheck(e){const t=new Set(this.#e.checkedEntries);t.has(e)?t.delete(e):t.add(e),this.#e.checkedEntries=t,this.#r()}toggleAll(){const e=this.getFilteredEntries(),t=new Set(this.#e.checkedEntries);if(e.every(n=>t.has(n.packageName)))for(const n of e)t.delete(n.packageName);else for(const n of e)t.add(n.packageName);this.#e.checkedEntries=t,this.#r()}setFilter(e){this.#e.filterType=e,this.#e.selectedIndex=0,this.#r()}setFilterText(e){this.#e.filterText=e,this.#e.selectedIndex=0,this.#r()}setFilterActive(e){this.#e.filterActive=e,this.#r()}setFocusedPanel(e){this.#e.focusedPanel=e,this.#r()}setPhase(e){this.#e.phase=e,this.#r()}setProgress(e,t){this.#e.applyProgress={current:e,total:t},this.#r()}setError(e){this.#e.error=e,this.#e.phase="error",this.#r()}getCheckedEntries(){return this.#e.entries.filter(e=>this.#e.checkedEntries.has(e.packageName))}}const ce={"micro-utility":"gray",native:"green",preferred:"yellow",socket:"cyan"},ir={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},cr={"micro-utility":"Trivial utility package that can be replaced with inline code.",native:"Polyfill for a native JS/Node.js API. Use the built-in instead.",preferred:"A lighter or faster alternative package exists.",socket:"Security-hardened replacement from Socket.dev's @socketregistry."};var ar=Object.defineProperty,sr=O((r,e)=>ar(r,"name",{value:e,configurable:!0}),"d");const lr=sr(({entry:r,focused:e,scrollRef:t})=>{const n=e?"white":"gray";if(!r)return o(h,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:o(s,{dimColor:!0,children:"No entry selected"})});const a=ce[r.category]??"gray";return m(h,{borderColor:n,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[o(h,{flexShrink:0,paddingTop:1,paddingX:2,children:o(s,{bold:!0,color:"white",children:r.packageName})}),m(Pe,{flexGrow:1,flexShrink:1,paddingX:2,ref:t,scrollbar:!0,scrollbarColor:"gray",children:[o(s,{}),m(h,{children:[o(h,{width:14,children:o(s,{dimColor:!0,children:"Category:"})}),o(s,{bold:!0,color:a,children:r.category})]}),m(h,{children:[o(h,{width:14,children:o(s,{dimColor:!0,children:"Replace with:"})}),o(s,{children:r.replacement})]}),r.overrideSpec&&m(h,{children:[o(h,{width:14,children:o(s,{dimColor:!0,children:"Override:"})}),o(s,{color:"cyan",children:r.overrideSpec})]}),m(h,{children:[o(h,{width:14,children:o(s,{dimColor:!0,children:"Codemod:"})}),o(s,{color:r.hasCodemod?"green":"gray",children:r.hasCodemod?"available ⚙":"not available"})]}),m(h,{flexDirection:"column",marginTop:1,children:[o(s,{dimColor:!0,children:"── "}),o(s,{bold:!0,color:"white",children:"DESCRIPTION"}),o(h,{marginTop:1,paddingLeft:2,children:o(s,{children:cr[r.category]??""})})]}),r.category==="native"&&m(h,{flexDirection:"column",marginTop:1,children:[o(s,{dimColor:!0,children:"── "}),o(s,{bold:!0,color:"green",children:"ACTION"}),o(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?m(U,{children:[m(s,{color:"green",children:["✓"," ","Codemod will rewrite imports to use native API."]}),o(s,{dimColor:!0,children:" The package can then be removed from dependencies."})]}):m(U,{children:[m(s,{color:"yellow",children:["ℹ"," ","No automated codemod available."]}),o(s,{dimColor:!0,children:" Manual migration required — replace usage with native equivalent."})]})})]}),r.category==="socket"&&m(h,{flexDirection:"column",marginTop:1,children:[o(s,{dimColor:!0,children:"── "}),o(s,{bold:!0,color:"cyan",children:"ACTION"}),m(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[m(s,{color:"cyan",children:["✓"," ","Override will redirect resolution to the hardened package."]}),o(s,{dimColor:!0,children:" No source code changes needed — drop-in replacement."})]})]}),(r.category==="preferred"||r.category==="micro-utility")&&m(h,{flexDirection:"column",marginTop:1,children:[o(s,{dimColor:!0,children:"── "}),o(s,{bold:!0,color:"yellow",children:"ACTION"}),o(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?m(U,{children:[m(s,{color:"green",children:["✓"," ","Codemod will rewrite imports to the recommended alternative."]}),o(s,{dimColor:!0,children:" The original package can then be removed from dependencies."})]}):m(U,{children:[m(s,{color:"yellow",children:["ℹ"," ","Manual migration required."]}),r.docUrl?o(s,{dimColor:!0,children:" Open the migration guide below for the recommended alternative and steps."}):o(s,{dimColor:!0,children:" Consult the package's docs or the e18e module-replacements guide for an alternative."})]})})]}),m(h,{flexDirection:"column",marginTop:1,children:[o(s,{dimColor:!0,children:"── "}),o(s,{bold:!0,color:"white",children:"LINKS"}),m(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[m(s,{color:"cyan",underline:!0,children:["https://npmx.dev/",r.packageName]}),r.docUrl&&o(s,{color:"cyan",underline:!0,children:r.docUrl})]})]})]})]})},"OptimizeDetailPanel");var dr=Object.defineProperty,ae=O((r,e)=>dr(r,"name",{value:e,configurable:!0}),"b$1");const pr=[{key:"all",label:"All",shortcut:"1"},{key:"native",label:"Native",shortcut:"2"},{key:"preferred",label:"Preferred",shortcut:"3"},{key:"micro-utility",label:"Micro",shortcut:"4"},{key:"socket",label:"Socket",shortcut:"5"}],fr=ae(({checked:r,entry:e,isSelected:t})=>{const n=ce[e.category]??"white",a=ir[e.category]??e.category,i=r?"☑":"☐",l=e.hasCodemod?"⚙":" ";return m(h,{flexShrink:0,height:1,children:[o(s,{children:t?">":" "}),m(s,{color:r?"white":"gray",children:[" ",i," "]}),o(s,{bold:!0,color:n,children:`[${a}]`.padEnd(9)}),m(s,{children:[" ",l," "]}),o(h,{flexGrow:1,children:o(s,{bold:t,inverse:t,wrap:"truncate",children:e.packageName})}),o(s,{dimColor:!0,children:" → "}),o(s,{wrap:"truncate",children:e.replacement})]})},"EntryRow"),ur=ae(({checkedEntries:r,entries:e,filterActive:t,filterText:n,filterType:a,focused:i,isDryRun:l,scrollOffset:v,selectedIndex:x,totalEntries:w,viewportHeight:k})=>{const c=i?"white":"gray";let f=0,p=0,g=0,y=0;for(const d of e)switch(d.category){case"micro-utility":{g++;break}case"native":{f++;break}case"preferred":{p++;break}case"socket":{y++;break}}const u=[];f>0&&u.push(`${f} native`),p>0&&u.push(`${p} preferred`),g>0&&u.push(`${g} micro`),y>0&&u.push(`${y} socket`);const C=u.length>0?` (${u.join(", ")})`:"",S=r.size,T=[];for(const[d,P]of e.entries())T.push(o(fr,{checked:r.has(P.packageName),entry:P,isSelected:d===x},P.packageName));const A=e.length,R=A>k&&k>0;return m(h,{borderColor:c,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[m(h,{flexShrink:0,gap:1,paddingX:1,children:[o(s,{bold:!0,inverse:!0,children:" VIS OPTIMIZE "}),m(s,{wrap:"truncate",children:[w," ","optimizations",C]}),!l&&S>0&&m(s,{dimColor:!0,children:[" ","—",S," ","selected"]})]}),o(h,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:pr.map(d=>{const P=a===d.key;return m(h,{children:[o(s,{dimColor:!P,children:"["}),o(s,{bold:P,color:P?"cyan":"gray",children:d.shortcut}),o(s,{dimColor:!P,children:"]"}),m(s,{color:P?"white":"gray",children:[" ",d.label]})]},d.key)})}),t&&m(h,{flexShrink:0,paddingX:1,children:[o(s,{bold:!0,color:"white",children:"/ "}),o(s,{children:n}),o(s,{inverse:!0,children:" "})]}),m(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[o(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:o(h,{flexDirection:"column",marginTop:-v,children:T})}),R&&o(h,{flexShrink:0,marginLeft:1,marginRight:1,children:o(Ne,{contentHeight:A,placement:"inset",scrollOffset:v,style:"block",viewportHeight:k})})]})]})},"OptimizeListPanel");var mr=Object.defineProperty,hr=O((r,e)=>mr(r,"name",{value:e,configurable:!0}),"I$1");const gr=100,te=10,ne={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},yr=hr(({isDryRun:r,store:e})=>{const{exit:t}=Ee(),{columns:n,rows:a}=_e(),i=Me(e.subscribe,e.getSnapshot),l=Fe(null),[v,x]=Y(0),[w,k]=Y(!1),c=e.getFilteredEntries(),f=c[i.selectedIndex]??null,p=n>=gr,g=Math.max(0,a-5),y=Ge(u=>{t(u)},[t]);return je((u,C)=>{if(w){u==="y"||u==="Y"?y():k(!1);return}if(i.filterActive){C.escape?(e.setFilterActive(!1),e.setFilterText("")):C.return?e.setFilterActive(!1):C.backspace||C.delete?e.setFilterText(i.filterText.slice(0,-1)):u&&!C.ctrl&&!C.meta&&e.setFilterText(i.filterText+u);return}if(u==="q"){!r&&i.checkedEntries.size>0?k(!0):y();return}if(u==="/"){e.setFilterActive(!0);return}if(ne[u]){e.setFilter(ne[u]);return}if(C.tab){e.setFocusedPanel(i.focusedPanel==="list"?"detail":"list");return}if(i.focusedPanel==="list")if(C.upArrow||u==="k"){const S=Math.max(0,i.selectedIndex-1);e.select(S),S<v&&x(S)}else if(C.downArrow||u==="j"){const S=Math.min(c.length-1,i.selectedIndex+1);e.select(S),S>=v+g&&x(S-g+1)}else u===" "?f&&e.toggleCheck(f.packageName):u==="a"?e.toggleAll():C.return&&!r&&i.checkedEntries.size>0&&y(e.getCheckedEntries());else i.focusedPanel==="detail"&&(C.upArrow||u==="k"?l.current?.scrollBy(-1):(C.downArrow||u==="j")&&l.current?.scrollBy(1))},{isActive:i.phase==="browsing"}),a<te?o(h,{alignItems:"center",justifyContent:"center",children:m(s,{color:"yellow",children:["Terminal too small. Resize to at least",te," ","rows."]})}):m(h,{flexDirection:"column",height:a,width:n,children:[m(h,{flexDirection:p?"row":"column",flexGrow:1,children:[o(h,{flexBasis:p?"50%":void 0,flexGrow:1,children:o(ur,{checkedEntries:i.checkedEntries,entries:c,filterActive:i.filterActive,filterText:i.filterText,filterType:i.filterType,focused:i.focusedPanel==="list",isDryRun:r,scrollOffset:v,selectedIndex:i.selectedIndex,totalEntries:i.entries.length,viewportHeight:g})}),o(h,{flexBasis:p?"50%":void 0,flexGrow:1,children:o(lr,{entry:f,focused:i.focusedPanel==="detail",scrollRef:l})})]}),o(h,{flexShrink:0,paddingX:1,children:m(s,{dimColor:!0,children:[r?"Preview mode":"space:toggle a:all enter:apply"," ","| tab:switch panel /: filter q:quit |","⚙","=codemod available"]})}),o(we,{autoExitSeconds:3,onCancel:O(()=>{k(!1)},"onCancel"),visible:w})]})},"VisOptimizeApp");var vr=Object.defineProperty,N=O((r,e)=>vr(r,"name",{value:e,configurable:!0}),"p");const W=N((r,e)=>{const t=new Set;try{const n=ie(r),a=e?[n.dependencies,n.optionalDependencies]:[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies];for(const i of a)if(i)for(const l of Object.keys(i))t.add(l)}catch{}return t},"collectDepsFromPkgJson"),se=N(r=>{const e=be(r);if(e)return K(r,e);const t=j(r,"package.json");if(!X(t))return[];try{const n=ie(t),a=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;return a?K(r,a):[]}catch{return[]}},"discoverWorkspacePackages"),kr="https://github.com/es-tooling/module-replacements/blob/main/docs/modules",wr=N(r=>`${kr}/${r}.md`,"buildE18eDocUrl"),br=N(r=>{if(r.type==="simple"&&r.replacement)return r.replacement;if(r.type==="native"){const e=r.nodeVersion?` (Node ${r.nodeVersion}+)`:"";return r.replacement?`${r.replacement}${e}`:`Native API${e}`}return r.type==="documented"&&r.docPath?"see migration guide":""},"e18eReplacementHint"),le=N(r=>{const e=[],t=N((n,a)=>{const i=n.moduleReplacements;if(Array.isArray(i))for(const l of i)r.has(l.moduleName)&&e.push({category:a,docUrl:l.type==="documented"&&l.docPath?wr(l.docPath):void 0,hasCodemod:!1,overrideSpec:void 0,packageName:l.moduleName,replacement:br(l)})},"scanManifest");return t(De,"native"),t(Re,"preferred"),t(Ae,"micro-utility"),e},"buildE18eEntries"),de=N((r,e,t,n)=>{const a=rr.getManifestData("npm")??[],i=[];for(const[,l]of a){if(l.deprecated)continue;const v=r.has(l.package),x=e?Ze(e,l.package,t.name):!1;if(!v&&!x)continue;const w=oe.coerce(l.version)?.major;if(w===void 0)continue;const k=n?`npm:${l.name}@${l.version}`:`npm:${l.name}@^${String(w)}`;i.push({category:"socket",hasCodemod:!1,overrideSpec:k,packageName:l.package,replacement:l.name})}return i},"buildSocketEntries");let B;const pe=N(async()=>{if(B)return B;try{return B=(await import("module-replacements-codemods")).codemods,B}catch{return{}}},"loadCodemods"),fe=N(async r=>{try{const e=await pe();for(const t of r)t.category!=="socket"&&e[t.packageName]&&(t.hasCodemod=!0)}catch{}},"markCodemodAvailability"),ue=N(async(r,e)=>{let t=0;try{const n=(await pe())[e];if(!n)return{filesChanged:0,packageName:e};const a=n({}),i=await xr(r);for(const l of i){const v=G(l);if(v.includes(e))try{const x=await a.transform({file:{filename:l,source:v}});x!==v&&(ve(l,x,"utf8"),t++)}catch(x){process.stderr.write(`warn: codemod transform failed for ${l}: ${x instanceof Error?x.message:String(x)}
13
- `)}}}catch{}return{filesChanged:t,packageName:e}},"runCodemod"),xr=N(async r=>Se("**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}",{absolute:!0,cwd:r,ignore:["**/.*/**","**/.*","**/node_modules/**","**/dist/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"]}),"collectSourceFiles"),$r=N(async({logger:r,options:e,visConfig:t,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const a=xe(n),i=!!e.dryRun,l=!!e.prod,v=!!e.pin;b.info(`Detected ${a.name} v${a.version}.`);const x=W(j(n,"package.json"),l),w=se(n),k=new Set(x);for(const d of w){const P=W(j(Oe(n,d),"package.json"),l);for(const D of P)k.add(D)}w.length>0&&b.info(`Scanned ${String(w.length)} workspace package${w.length===1?"":"s"}.`),b.info(`Scanning dependencies...
14
- `);const c=Qe(n,a.name),f=le(k),p=de(k,c,a,v),g=new Set(f.map(d=>d.packageName)),y=p.filter(d=>!g.has(d.packageName)),u=[...f,...y];if(await fe(u),u.length===0){b.info("No optimizations found for your dependencies.");return}const C=!!process.stdout.isTTY&&!Ce,S=e.format==="json"||!!e.json;if(C&&!i&&!S){const d=new or(u),P=await Te(Ie.createElement(yr,{isDryRun:!1,store:d}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),D=Array.isArray(P)?P:[];if(D.length===0){b.info("No optimizations selected.");return}const L=D.filter($=>$.category!=="socket"&&$.hasCodemod),q=D.filter($=>$.category!=="socket"&&!$.hasCodemod),J=D.filter($=>$.category==="socket");if(L.length>0){b.info(`
15
- Running ${String(L.length)} codemod${L.length===1?"":"s"}...
16
- `);for(const $ of L){const E=await ue(n,$.packageName);E.filesChanged>0?b.success(` ${$.packageName}: ${String(E.filesChanged)} file${E.filesChanged===1?"":"s"} updated`):b.info(` ${$.packageName}: no files changed`)}}if(q.length>0){b.warn(`
17
- ${String(q.length)} selected replacement${q.length===1?"":"s"} require manual migration (no codemod available):`);for(const $ of q)b.info(` ${$.packageName} → ${$.replacement}`);b.notice(" Replace usage in your source code, then remove from dependencies.")}if(J.length>0){const $=J.filter(z=>z.overrideSpec).map(z=>({original:z.packageName,spec:z.overrideSpec})),E=Ye(n,j(n,"package.json"),$,a,t?.editorconfig??!0);E.added.length>0&&b.success(`
18
- Added ${String(E.added.length)} override${E.added.length===1?"":"s"}.`),E.updated.length>0&&b.success(`Updated ${String(E.updated.length)} override${E.updated.length===1?"":"s"}.`)}if(J.length>0&&e.install!==!1){b.info(`
19
- Running ${a.name} install to update lockfile...`);const $=$e(a,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},n,r);$!==0&&b.warn(`${a.name} install exited with code ${String($)}. Run it manually.`)}b.info(""),b.success("Optimization complete.");return}if(S){process.stdout.write(`${JSON.stringify({e18e:f.map(d=>({category:d.category,hasCodemod:d.hasCodemod,packageName:d.packageName,replacement:d.replacement})),packageManager:a.name,socket:y.map(d=>({overrideSpec:d.overrideSpec,packageName:d.packageName,replacement:d.replacement})),total:u.length,workspaces:w.length},void 0,2)}
20
- `);return}const T=f.filter(d=>d.category==="native"),A=f.filter(d=>d.category==="preferred"),R=f.filter(d=>d.category==="micro-utility");if(T.length>0){b.info(`Native replacements (${String(T.length)}):`);for(const d of T)b.info(` ${d.hasCodemod?"⚙":" "} ${d.packageName} → ${d.replacement}`)}if(A.length>0){b.info(`
21
- Preferred alternatives (${String(A.length)}):`);for(const d of A)b.info(` ${d.hasCodemod?"⚙":" "} ${d.packageName} → ${d.replacement}`)}if(R.length>0){b.info(`
22
- Micro-utilities (${String(R.length)}):`);for(const d of R)b.info(` ${d.hasCodemod?"⚙":" "} ${d.packageName} → ${d.replacement}`)}if(y.length>0){b.info(`
23
- Socket.dev overrides (${String(y.length)}):`);for(const d of y)b.info(` ${d.packageName} → ${d.overrideSpec}`)}b.info(`
24
- Total: ${String(u.length)} optimizations available (⚙ = codemod available).`),i&&b.notice("Run without --dry-run for interactive selection.")},"execute"),Ir=Object.defineProperty({__proto__:null,buildE18eEntries:le,buildSocketEntries:de,collectDepsFromPkgJson:W,default:$r,discoverWorkspacePackages:se,markCodemodAvailability:fe,runCodemod:ue},Symbol.toStringTag,{value:"Module"});export{se as A,le as F,ue as I,Qe as L,de as T,fe as U,Ye as a,Ir as h,W as x};
1
+ var Pt=Object.defineProperty;var P=(e,t)=>Pt(e,"name",{value:t,configurable:!0});import{createRequire as Ot}from"node:module";import{n as Ft,B as qe,aG as Je,a2 as Le,t as Mt,A as at,U as ct,f as zt,R as dt,J as ut,V as jt,N as Et,a as Bt,p as u,c as we,aw as j,e as ze,E as b,d as Re,j as ae,q as Te,s as Lt,v as Vt}from"./bin.js";import{M as te,i as Fe,n as ht,h as _t,O as Ut,C as pt}from"../packem_shared/otel-CO8UEfTa.js";import{Box as h,Text as n,ScrollView as Ht,Spinner as gt,Tabs as Gt,Tab as Yt,ScrollBar as Kt,useApp as qt,useWindowSize as Jt,useInput as Xt,Dialog as Wt,render as Qt}from"@visulima/tui";import Zt,{useSyncExternalStore as ei,useState as xe,useEffect as Be,useRef as Xe,useMemo as De,useCallback as We}from"react";import{X as ni}from"../packem_shared/xxh3-DrAUNq4n.js";import{findVisConfigFile as oi}from"./applyDefaults.js";import{x as Ze,A as ft,L as si,F as li,T as ai,U as ci,a as di,I as ui}from"./handler42.js";import{c as hi}from"../packem_shared/runtime-check-l4qFpo08.js";import{f as pi,l as gi,s as fi}from"../packem_shared/dependency-scan-SQeRzrpJ.js";import{jsxs as a,jsx as r,Fragment as mi}from"react/jsx-runtime";import{u as yi}from"../packem_shared/use-measured-height-DjYgUOKk.js";import{s as ki}from"../packem_shared/verify-C6NNOhTA.js";const Nt=Ot(import.meta.url),Ce=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,lt=P(e=>{if(typeof Ce<"u"&&Ce.versions&&Ce.versions.node){const[t,i]=Ce.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return Ce.getBuiltinModule(e)}return Nt(e)},"__cjs_getBuiltinModule"),{statSync:ti,rmSync:Qe,writeFileSync:ii,readFileSync:ri}=lt("node:fs"),{spawnSync:mt}=lt("node:child_process");var wi=Object.defineProperty,Ae=P((e,t)=>wi(e,"name",{value:t,configurable:!0}),"r$2");const Ve=Ae(()=>te(Ft(),"doctor"),"getCacheDirectory"),vi=1800*1e3,et=Ae(e=>{if(!e)return"";try{return String(ti(e).mtimeMs)}catch{return""}},"safeMtime"),bi=2,$i=Ae(e=>{const t=JSON.stringify({configMtime:et(e.configPath),lockfileMtime:et(e.lockfilePath),schema:bi,sections:[...e.sections].toSorted(),socketEnabled:e.socketEnabled,workspaceRoot:e.workspaceRoot});return ni(Buffer.from(t))},"buildDoctorCacheKey"),Si=Ae(e=>{const t=te(Ve(),`${e}.json`);if(Fe(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"),Ci=Ae((e,t,i=vi)=>{_t(Ve());const s={createdAt:Date.now(),results:{...t,sections:[...t.sections]},ttlMs:i};ii(te(Ve(),`${e}.json`),JSON.stringify(s,void 0,2),"utf8")},"writeDoctorCache");var xi=Object.defineProperty,_=P((e,t)=>xi(e,"name",{value:t,configurable:!0}),"i$3");const Oe="orphans",Ri=_(()=>{if(process.platform!=="linux")return{id:"inotify",message:"inotify capacity check skipped (not Linux).",status:"skip"};let e;try{const t=ri("/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"),Ti=_(()=>{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"),Ai=_(()=>{const e=process.pid;try{return process.platform==="win32"?wt(e):kt(e)}catch{return[]}},"listOrphanPids"),Ii=_(()=>{const e=process.pid;let t;try{t=process.platform==="win32"?wt(e):kt(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(s=>`taskkill /F /PID ${String(s)}`).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"),Di=_((e={})=>{const t=e.enumerate??Ai,i=e.force===!0?"SIGKILL":"SIGTERM",s=e.kill??Mi,o=t(),l=[],c=[];for(const p of o)try{s(p,i),l.push(p)}catch(d){const S=d.code??d.message;if(S==="ESRCH"){l.push(p);continue}c.push({pid:p,reason:S})}return{failed:c,killed:l}},"killOrphanedRunners"),Pi=_(e=>mt("taskkill",e,{encoding:"utf8"}),"defaultTaskkillRunner"),Oi=_((e,t)=>{process.kill(e,t)},"defaultProcessKill"),Ni=_((e,t,i=Pi)=>{const s=t==="SIGKILL"?["/F","/PID",String(e)]:["/PID",String(e)],o=i(s);if(o.error)throw o.error;if(typeof o.status=="number"&&o.status!==0){const l=o.status===128?"ESRCH":`taskkill exited with code ${String(o.status)}`,c=new Error(l);throw c.code=l,c}},"killViaTaskkill"),Fi=_((e,t,i=Oi)=>{i(e,t)},"killViaSignal"),Mi=_((e,t)=>{if(process.platform==="win32"){Ni(e,t);return}Fi(e,t)},"defaultKill"),yt=_((e,t)=>{const i=mt(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"),kt=_(e=>{const t=yt("ps",["-Ao","pid=,command="]),i=[];for(const s of t.split(`
2
+ `)){if(s.length===0)continue;const o=/^\s*(\d+)\s+(.+)$/.exec(s);if(!o)continue;const l=Number.parseInt(o[1]??"",10),c=(o[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"),wt=_(e=>{const t=yt("tasklist",["/FO","CSV","/NH"]),i=[];for(const s of t.split(/\r?\n/)){if(s.length===0)continue;const o=s.split(/","/).map(p=>p.replaceAll(/^"|"$/g,"")),l=(o[0]??"").toLowerCase(),c=Number.parseInt(o[1]??"",10);!Number.isFinite(c)||c===e||(l==="vis.exe"||l.startsWith("vis-native")||l.includes("task-runner"))&&i.push(c)}return i},"listOrphansWindows"),zi=_(()=>[Ri(),Ti(),Ii()],"runRuntimeDiagnostics");var ji=Object.defineProperty,ke=P((e,t)=>ji(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"}],Me=["dependencies","security","optimization","runtime"],fe=ke(e=>{const t=new Map;for(const i of Me)t.set(i,[]);for(const i of e)t.get(i.section).push(i);for(const[i,s]of t)s.length===0&&t.delete(i);return t},"groupBySection"),me=ke((e,t,i,s)=>{let o=e.filter(l=>l.section===t);if(s&&(o=o.filter(l=>l.severity===s)),i){const l=i.toLowerCase();o=o.filter(c=>c.title.toLowerCase().includes(l))}return[...o]},"filterFindings"),Ei=ke(e=>{const t={dependencies:"idle",optimization:"idle",runtime:"idle",security:"idle"};for(const i of Me)e.has(i)&&(t[i]="idle");return t},"initialStatus");class tt{static{P(this,"DoctorStore")}static{ke(this,"DoctorStore")}#e;#i=new Set;constructor(t=[]){const i=Array.isArray(t)?{findings:t}:t,s=i.findings??[],o=i.activeSections??new Set(Me),l=Me.find(d=>o.has(d))??"dependencies",c=me(s,l,"",void 0),p=Ei(o);if(s.length>0)for(const d of s)p[d.section]="done";this.#e={all:s,entries:c,filterActive:!1,filterText:"",filterType:l,focusedPanel:"list",grouped:fe(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=me(this.#e.all,t,this.#e.filterText,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterType:t,grouped:fe(i),selectedIndex:0})}setFilter(t){const i=me(this.#e.all,this.#e.filterType,t,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterText:t,grouped:fe(i),selectedIndex:0})}setFilterActive(t){if(t===this.#e.filterActive)return;if(t){this.#t({...this.#e,filterActive:!0});return}const i=me(this.#e.all,this.#e.filterType,"",this.#e.severityFilter);this.#t({...this.#e,entries:i,filterActive:!1,filterText:"",grouped:fe(i),selectedIndex:0})}setPendingAction(t){this.#t({...this.#e,pendingAction:t})}setSeverityFilter(t){if(t===this.#e.severityFilter)return;const i=me(this.#e.all,this.#e.filterType,this.#e.filterText,t);this.#t({...this.#e,entries:i,grouped:fe(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 s=[...this.#e.all,...i],o=me(s,this.#e.filterType,this.#e.filterText,this.#e.severityFilter),l={...this.#e.sectionMessage};delete l[t],this.#t({...this.#e,all:s,entries:o,grouped:fe(o),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 Bi=Object.defineProperty,vt=P((e,t)=>Bi(e,"name",{value:t,configurable:!0}),"r$1");const it={error:0,warn:1},Li=vt(e=>!!e.acceptedRisk,"isAcknowledged"),bt=vt(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 s=i.vulnerabilities[0],o=Li(i)?"warn":"error",l=i.vulnerabilities.length;t.push({entry:i,id:`vuln:${i.packageName}`,kind:"vulnerability",packageName:i.packageName,section:"security",severity:o,subtitle:l===1?`${s.severity} · ${s.id}`:`${String(l)} advisories · top: ${s.severity} ${s.id}`,title:i.packageName})}if(i.socketReport&&i.socketReport.alerts.length>0){const s=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(s)}%`,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,s)=>{if(i.section!==s.section){const o=["dependencies","security","optimization","runtime"];return o.indexOf(i.section)-o.indexOf(s.section)}return it[i.severity]-it[s.severity]}),t},"flattenFindings"),$t={dependencies:"Dependencies",optimization:"Optimization",runtime:"Runtime",security:"Security"};var Vi=Object.defineProperty,_i=P((e,t)=>Vi(e,"name",{value:t,configurable:!0}),"i$2");const Ui={error:"red",warn:"yellow"},Hi={error:"✖",warn:"⚠"},Gi={error:" ERROR ",warn:" WARN "},Yi=_i(({children:e,hint:t,message:i,severity:s,title:o})=>{const l=Ui[s];return a(h,{borderColor:l,borderStyle:"single",flexDirection:"column",flexShrink:0,paddingX:1,children:[a(h,{gap:1,children:[r(n,{backgroundColor:l,bold:!0,color:"black",children:Gi[s]}),r(n,{bold:!0,color:l,children:Hi[s]}),r(n,{bold:!0,wrap:"truncate-end",children:o})]}),r(n,{wrap:"truncate-end",children:i}),t?r(n,{dimColor:!0,wrap:"truncate-end",children:t}):null,e]})},"ConfigBanner");var Ki=Object.defineProperty,ie=P((e,t)=>Ki(e,"name",{value:t,configurable:!0}),"d");const qi={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},Ji={critical:"red",high:"red",low:"gray",medium:"yellow"},Xi={major:"red",minor:"yellow",patch:"green"},x=ie(({children:e,label:t,width:i=14})=>a(h,{children:[r(h,{width:i,children:a(n,{dimColor:!0,children:[t,":"]})}),typeof e=="string"?r(n,{children:e}):e]}),"FieldRow"),se=ie(({children:e})=>r(h,{marginTop:1,children:r(n,{bold:!0,color:"white",children:e})}),"SectionTitle"),Wi=ie(({finding:e})=>{const{entry:t}=e,i=Xi[t.updateType]??"white";return a(h,{flexDirection:"column",children:[r(x,{label:"Current",children:t.currentRange}),a(x,{label:"Target",children:[r(n,{children:t.newRange}),a(n,{bold:!0,color:i,children:[" (",t.updateType,")"]})]}),r(x,{label:"Catalog",children:t.catalogName}),t.acceptedRisk?r(x,{label:"Risk ack",children:r(n,{dimColor:!0,children:t.acceptedRisk.reason??"(no reason recorded)"})}):null,r(se,{children:"Action"}),a(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis update"})," ","to apply this change."]})]})},"OutdatedDetail"),Qi=ie(({finding:e})=>a(h,{flexDirection:"column",children:[r(x,{label:"Versions",children:r(n,{children:String(e.pkg.versions.length)})}),r(se,{children:"Installed versions"}),e.pkg.versions.map(t=>a(n,{children:[" · ",t]},t)),r(se,{children:"Action"}),a(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis dedupe"})," ","to consolidate to a single resolution."]})]}),"DuplicateDetail"),Zi=ie(({finding:e})=>{const t=e.entry.vulnerabilities??[];return a(h,{flexDirection:"column",children:[r(x,{label:"Package",children:e.packageName}),r(x,{label:"Current",children:e.entry.currentRange}),r(x,{label:"Advisories",children:String(t.length)}),e.entry.acceptedRisk?r(x,{label:"Risk ack",children:r(n,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,t.map(i=>{const s=qi[i.severity]??"gray";return a(h,{flexDirection:"column",marginTop:1,children:[a(h,{children:[r(n,{bold:!0,color:s,children:i.severity}),r(n,{children:" "}),r(n,{children:i.id}),typeof i.cvssScore=="number"?a(n,{dimColor:!0,children:[" · CVSS ",i.cvssScore.toFixed(1)]}):null]}),r(n,{wrap:"wrap",children:i.summary}),i.fixedVersions.length>0?a(n,{dimColor:!0,children:["Fixed in: ",i.fixedVersions.join(", ")]}):null,i.aliases&&i.aliases.length>0?a(n,{dimColor:!0,children:["Aliases: ",i.aliases.join(", ")]}):null]},i.id)})]})},"VulnerabilityDetail"),er=ie(({finding:e})=>{const t=e.entry.socketReport;if(!t)return r(n,{dimColor:!0,children:"No Socket report attached."});const i=Math.round(t.score.overall*100),s=qe(t.score.overall);return a(h,{flexDirection:"column",children:[r(x,{label:"Package",children:e.packageName}),r(x,{label:"Overall",children:a(n,{color:s,children:[String(i),"%"]})}),r(x,{label:"Alerts",children:String(t.alerts.length)}),e.entry.acceptedRisk?r(x,{label:"Risk ack",children:r(n,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,r(se,{children:"Score breakdown"}),Object.entries(t.score).map(([o,l])=>{if(o==="overall")return null;const c=typeof l=="number"?l:0,p=Math.round(c*100),d=qe(c);return a(h,{children:[r(h,{width:14,children:a(n,{dimColor:!0,children:[o,":"]})}),a(n,{color:d,children:[String(p),"%"]})]},o)}),r(se,{children:"Alerts"}),t.alerts.map((o,l)=>{const c=Ji[o.severity]??"gray";return a(h,{flexDirection:"column",marginBottom:1,children:[a(h,{children:[r(n,{bold:!0,color:c,children:o.severity}),r(n,{children:" "}),r(n,{children:o.type})]}),o.props?r(n,{dimColor:!0,wrap:"wrap",children:JSON.stringify(o.props)}):null]},`${o.type}-${String(l)}`)})]})},"SocketDetail"),tr=ie(({finding:e})=>{const{entry:t}=e;return a(h,{flexDirection:"column",children:[r(x,{label:"Package",children:t.packageName}),r(x,{label:"Category",children:t.category}),r(x,{label:"Replacement",children:t.replacement}),t.overrideSpec?r(x,{label:"Override",children:t.overrideSpec}):null,r(x,{label:"Codemod",children:r(n,{color:t.hasCodemod?"green":"gray",children:t.hasCodemod?"available":"not available"})}),t.docUrl?r(x,{label:"Guide",children:r(n,{color:"cyan",underline:!0,children:t.docUrl})}):null,r(se,{children:"Action"}),t.hasCodemod?a(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis optimize"})," ","to apply the codemod interactively."]}):t.overrideSpec?a(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis optimize"})," ","to install the package override."]}):t.docUrl?r(n,{dimColor:!0,children:"No automated codemod. Open the migration guide above for the recommended alternative and steps."}):r(n,{dimColor:!0,children:"No automated codemod. Consult the package's docs or the e18e module-replacements guide for an alternative."})]})},"OptimizationDetail"),ir=ie(({finding:e})=>{const{diagnostic:t}=e,i=t.status==="warn"?"yellow":t.status==="ok"?"green":"gray";return a(h,{flexDirection:"column",children:[r(x,{label:"Check",children:t.id}),r(x,{label:"Status",children:r(n,{color:i,children:t.status})}),r(se,{children:"Message"}),r(n,{wrap:"wrap",children:t.message}),t.detail&&Object.keys(t.detail).length>0?a(mi,{children:[r(se,{children:"Details"}),Object.entries(t.detail).map(([s,o])=>a(h,{children:[r(h,{width:20,children:a(n,{dimColor:!0,children:[s,":"]})}),r(n,{children:String(o)})]},s))]}):null]})},"RuntimeDetail"),rr=ie(({finding:e,focused:t,scrollRef:i})=>{const s=t?"white":"gray";if(!e)return r(h,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:r(n,{dimColor:!0,children:"No finding selected"})});let o;switch(e.kind){case"duplicate":{o=r(Qi,{finding:e});break}case"optimization":{o=r(tr,{finding:e});break}case"outdated":{o=r(Wi,{finding:e});break}case"runtime":{o=r(ir,{finding:e});break}case"socket":{o=r(er,{finding:e});break}case"vulnerability":{o=r(Zi,{finding:e});break}default:{o=r(n,{dimColor:!0,children:"Unknown finding kind."});break}}return a(h,{borderColor:s,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[a(h,{flexShrink:0,paddingTop:1,paddingX:2,children:[r(n,{bold:!0,color:"white",children:e.title}),a(n,{dimColor:!0,children:[" ",$t[e.section]]})]}),a(Ht,{flexGrow:1,flexShrink:1,paddingX:2,ref:i,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[r(n,{}),o]})]})},"DoctorDetailPanel");var nr=Object.defineProperty,Ie=P((e,t)=>nr(e,"name",{value:t,configurable:!0}),"c$2");const St={error:"red",warn:"yellow"},or={error:"✖",warn:"⚠"},sr=Ie(e=>e.kind==="outdated"||e.kind==="vulnerability"||e.kind==="socket"?!!e.entry.acceptedRisk:!1,"hasAcceptedRisk"),lr=Ie(({finding:e,isSelected:t})=>{const i=St[e.severity],s=sr(e);return a(h,{flexShrink:0,height:1,children:[r(n,{children:t?">":" "}),a(n,{color:i,children:[" ",or[e.severity]," "]}),r(h,{flexGrow:1,children:r(n,{bold:t,inverse:t,wrap:"truncate",children:e.title})}),s?r(n,{color:"cyan",children:" ack"}):null,e.subtitle?a(n,{dimColor:!0,wrap:"truncate",children:[" ",e.subtitle]}):null]})},"FindingRow"),ar=Ie(({count:e,section:t})=>a(h,{flexShrink:0,height:1,marginTop:1,children:[r(n,{dimColor:!0,children:"▼ "}),r(n,{bold:!0,color:"white",children:$t[t].toUpperCase()}),a(n,{dimColor:!0,children:[" (",e,")"]})]}),"SectionHeader"),cr=Ie(({count:e,label:t,status:i})=>a(n,{children:[t,i==="running"?a(n,{children:[" ",r(gt,{type:"dots"})]}):null,i==="error"?r(n,{bold:!0,color:"red",children:" ✖"}):a(n,{dimColor:!0,children:[" (",String(e),")"]})]}),"TabLabel"),dr=Ie(({elapsedMs:e,entries:t,filterActive:i,filterText:s,filterType:o,focused:l,fromCache:c=!1,grouped:p,onViewportHeightChange:d,scrollOffset:S,sectionCounts:R,sectionMessage:w,sectionStatus:A,selectedIndex:E,severityFilter:g,totalAll:I,viewportHeight:B})=>{const X=l?"white":"gray",{measuredHeight:L,ref:F}=yi(B,d);let D=0,V=0;for(const v of t)v.severity==="error"?D+=1:v.severity==="warn"&&(V+=1);const W=[];D>0&&W.push(`${String(D)} error${D===1?"":"s"}`),V>0&&W.push(`${String(V)} warn${V===1?"":"s"}`);const re=W.length>0?` (${W.join(", ")})`:"",Y=(e/1e3).toFixed(1),O=[];for(const[v,T]of p){O.push(r(ar,{count:T.length,section:v},`hdr-${v}`));for(const C of T){const H=t.indexOf(C);O.push(r(lr,{finding:C,isSelected:H===E},C.id))}}let U=0;for(const[,v]of p)U+=2+v.length;const K=U>L&&L>0;return a(h,{borderColor:X,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[a(h,{flexShrink:0,gap:1,paddingX:1,children:[r(n,{bold:!0,inverse:!0,children:" DOCTOR "}),a(n,{wrap:"truncate",children:[t.length,t.length===I?"":`/${String(I)}`," finding",t.length===1?"":"s",re]}),g?r(n,{bold:!0,color:St[g],inverse:!0,children:` ${g.toUpperCase()} ONLY `}):null,c?r(n,{bold:!0,color:"cyan",inverse:!0,children:" CACHED "}):null,a(n,{dimColor:!0,children:[" · ",Y,"s"]})]}),r(h,{flexShrink:0,paddingX:1,paddingY:1,children:r(Gt,{isFocused:l,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:P(()=>{},"onChange"),showIndex:!1,value:o,children:ye.map(({id:v,label:T})=>r(Yt,{name:v,children:r(cr,{count:R[v],label:T,status:A[v]})},v))})}),(()=>{const v=Object.keys(A).filter(T=>A[T]==="running"&&w[T]).map(T=>w[T]);return v.length===0?null:r(h,{flexShrink:0,paddingX:1,children:a(n,{dimColor:!0,wrap:"truncate",children:[r(gt,{type:"dots"})," ",v.join(" · ")]})})})(),i&&a(h,{flexShrink:0,paddingX:1,children:[r(n,{bold:!0,color:"white",children:"/ "}),r(n,{children:s}),r(n,{inverse:!0,children:" "})]}),a(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",ref:F,children:[r(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:r(h,{flexDirection:"column",marginTop:-S,children:O.length>0?O:r(h,{marginTop:1,children:r(n,{dimColor:!0,children:"No findings match the current filter."})})})}),K&&r(h,{flexShrink:0,marginLeft:1,marginRight:1,children:r(Kt,{contentHeight:U,placement:"inset",scrollOffset:S,style:"block",viewportHeight:L})})]},`list-${o}-${s}`)]})},"DoctorListPanel");var ur=Object.defineProperty,je=P((e,t)=>ur(e,"name",{value:t,configurable:!0}),"g$1");const hr=je(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"),pr=je(e=>{if(e.kind==="optimization")return{command:`vis optimize ${e.entry.packageName}`,description:`Replace ${e.entry.packageName} with ${e.entry.replacement}`}},"buildOptimizeAction"),gr=je(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"),fr=100,mr=40,yr=10,kr=je(({autoExitSeconds:e=0,banner:t,fromCache:i=!1,startedAt:s,store:o})=>{const{exit:l}=qt(),{columns:c,rows:p}=Jt(),d=ei(o.subscribe,o.getSnapshot),[S,R]=xe(!1),[w,A]=xe(!1),[E,g]=xe(0),[I,B]=xe(()=>Date.now());Be(()=>{const y=setInterval(()=>{B(Date.now())},1e3);return()=>{clearInterval(y)}},[]);const X=I-s,L=Xe(null),F=Xe(null),D=d.entries[d.selectedIndex]??null,V=De(()=>{const y={dependencies:0,optimization:0,runtime:0,security:0};for(const m of d.all)y[m.section]+=1;return y},[d.all]),W=t?t.hint?5:4:0,re=De(()=>{for(const y of Object.keys(d.sectionStatus))if(d.sectionStatus[y]==="running"&&d.sectionMessage[y])return 1;return 0},[d.sectionStatus,d.sectionMessage]),Y=c>=fr,O=Y?Math.max(1,p-W-2):Math.floor(p*.55),U=De(()=>Math.max(1,O-6-re-(d.filterActive?1:0)),[O,re,d.filterActive]),[K,v]=xe(U),T=K>0?K:U,C=De(()=>{let y=0;for(const[,m]of d.grouped)y+=2+m.length;return y},[d.grouped]),H=Math.max(0,C-T);Be(()=>{g(y=>Math.min(y,H))},[H]);const de=We(y=>{let m=0,k=0;for(const[,Se]of d.grouped){m+=2;for(let le=0;le<Se.length;le++){if(k===y)return m;m+=1,k+=1}}return m},[d.grouped]),N=We(y=>{const m=de(y);g(k=>m>k+T-2?Math.min(H,Math.max(0,m-T+2)):m<k+1?Math.max(0,m-1):k)},[de,T,H]);if(Be(()=>{F.current?.scrollToTop()},[D?.id]),Xt((y,m)=>{if(y==="c"&&m.ctrl){l();return}if(!w){if(S){m.escape||y==="?"?R(!1):y==="q"?(R(!1),A(!0)):m.downArrow||y==="j"?L.current?.scrollBy(1):(m.upArrow||y==="k")&&L.current?.scrollBy(-1);return}if(y==="?"){R(!0);return}if(y==="q"){A(!0);return}if(m.tab){o.setFocusedPanel(d.focusedPanel==="list"?"detail":"list");return}if(d.filterActive){if(m.escape||m.return){o.setFilterActive(!1);return}if(m.backspace){g(0),o.setFilter(d.filterText.slice(0,-1));return}y&&!m.ctrl&&!m.meta&&(g(0),o.setFilter(d.filterText+y));return}if(d.focusedPanel==="list"&&(m.leftArrow||m.rightArrow)){const k=ye.findIndex(le=>le.id===d.filterType),Se=m.rightArrow?(k+1)%ye.length:(k-1+ye.length)%ye.length;g(0),F.current?.scrollToTop(),o.setFilterType(ye[Se].id);return}if(d.focusedPanel==="list"){if(m.downArrow||y==="j"){const k=Math.min(d.selectedIndex+1,d.entries.length-1);o.setSelectedIndex(k),N(k);return}if(m.upArrow||y==="k"){const k=Math.max(d.selectedIndex-1,0);o.setSelectedIndex(k),N(k);return}if(m.pageDown){const k=Math.min(d.selectedIndex+10,d.entries.length-1);o.setSelectedIndex(k),N(k);return}if(m.pageUp){const k=Math.max(d.selectedIndex-10,0);o.setSelectedIndex(k),N(k);return}if(m.home){o.setSelectedIndex(0),g(0);return}if(m.end){const k=d.entries.length-1;o.setSelectedIndex(k),N(k);return}if(y==="/"){o.setFilterActive(!0);return}if(y==="e"){o.setSeverityFilter(d.severityFilter==="error"?void 0:"error"),g(0);return}if(y==="w"){o.setSeverityFilter(d.severityFilter==="warn"?void 0:"warn"),g(0);return}if(y==="u"&&D){const k=hr(D);k&&(o.setPendingAction(k),l());return}if(y==="o"&&D){const k=pr(D);k&&(o.setPendingAction(k),l());return}if(y==="a"&&D){const k=gr(D);k&&(o.setPendingAction(k),l());return}if(y==="d"){o.setFocusedPanel("detail");return}return}if(m.escape||m.leftArrow){o.setFocusedPanel("list");return}if(m.downArrow||y==="j"){F.current?.scrollBy(1);return}if(m.upArrow||y==="k"){F.current?.scrollBy(-1);return}if(m.pageDown){F.current?.scrollBy(10);return}if(m.pageUp){F.current?.scrollBy(-10);return}if(m.home){F.current?.scrollToTop();return}m.end&&F.current?.scrollToBottom()}},{isActive:!0}),c<mr||p<yr)return r(h,{alignItems:"center",height:p,justifyContent:"center",width:c,children:a(n,{color:"yellow",children:["Terminal too small (",c,"x",p,")"]})});const Q=d.focusedPanel==="detail",ee=[a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"q"}),r(n,{dimColor:!0,children:"QUIT"})]},"q"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"?"}),r(n,{dimColor:!0,children:"HELP"})]},"?"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"↑↓"}),r(n,{dimColor:!0,children:Q?"SCROLL":"NAV"})]},"nav"),Q?a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"←/Esc"}),r(n,{dimColor:!0,children:"LIST"})]},"lr"):a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"←→"}),r(n,{dimColor:!0,children:"SECTION"})]},"lr"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"/"}),r(n,{dimColor:!0,children:"SEARCH"})]},"search"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"e/w"}),r(n,{dimColor:!0,children:"SEVERITY"})]},"sev"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"u/o/a"}),r(n,{dimColor:!0,children:"ACTION"})]},"actions"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"Tab"}),r(n,{dimColor:!0,children:"PANEL"})]},"tab")],ue=r(h,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:r(h,{gap:2,overflow:"hidden",paddingX:1,children:ee})}),he=a(Wt,{footer:a(n,{dimColor:!0,children:[r(n,{bold:!0,color:"white",children:"↑↓"})," scroll ",r(n,{bold:!0,color:"white",children:"?"}),"/",r(n,{bold:!0,color:"white",children:"Esc"})," close"]}),scrollRef:L,title:"DOCTOR — KEYBOARD SHORTCUTS",visible:S,width:56,children:[a(h,{flexDirection:"column",marginBottom:1,children:[a(h,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"NAVIGATION"})]}),a(h,{children:[r(h,{width:26,children:a(n,{children:[r(n,{bold:!0,color:"white",children:" ↑/k "}),r(n,{dimColor:!0,children:"Move up"})]})}),a(n,{children:[r(n,{bold:!0,color:"white",children:" ↓/j "}),r(n,{dimColor:!0,children:"Move down"})]})]}),a(h,{children:[r(h,{width:26,children:a(n,{children:[r(n,{bold:!0,color:"white",children:" PgUp"}),r(n,{dimColor:!0,children:" Jump up 10"})]})}),a(n,{children:[r(n,{bold:!0,color:"white",children:" PgDn"}),r(n,{dimColor:!0,children:" Jump down 10"})]})]}),a(h,{children:[r(h,{width:26,children:a(n,{children:[r(n,{bold:!0,color:"white",children:" Home"}),r(n,{dimColor:!0,children:" Jump to top"})]})}),a(n,{children:[r(n,{bold:!0,color:"white",children:" End"}),r(n,{dimColor:!0,children:" Jump to bottom"})]})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" Tab"}),r(n,{dimColor:!0,children:" Switch panel"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" →/←"}),r(n,{dimColor:!0,children:" Section tabs (list) / Focus list (detail)"})]})]}),a(h,{flexDirection:"column",marginBottom:1,children:[a(h,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"FILTER"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" /"}),r(n,{dimColor:!0,children:" Open text filter (Esc/Enter to close)"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" e"}),r(n,{dimColor:!0,children:" Toggle errors-only filter"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" w"}),r(n,{dimColor:!0,children:" Toggle warns-only filter"})]})]}),a(h,{flexDirection:"column",marginBottom:1,children:[a(h,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"ACTIONS"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" u"}),r(n,{dimColor:!0,children:" Exit + suggest update / dedupe command"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" o"}),r(n,{dimColor:!0,children:" Exit + suggest optimize command"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" a"}),r(n,{dimColor:!0,children:" Exit + print risk-ack snippet"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" d"}),r(n,{dimColor:!0,children:" Focus detail panel"})]})]}),a(h,{flexDirection:"column",children:[a(h,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"EXIT"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" q"}),r(n,{dimColor:!0,children:" Quit (with countdown)"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" Ctrl+C"}),r(n,{dimColor:!0,children:" Quit immediately"})]})]})]}),pe=r(dr,{elapsedMs:X,entries:d.entries,filterActive:d.filterActive,filterText:d.filterText,filterType:d.filterType,focused:d.focusedPanel==="list",fromCache:i,grouped:d.grouped,onViewportHeightChange:v,scrollOffset:E,sectionCounts:V,sectionMessage:d.sectionMessage,sectionStatus:d.sectionStatus,selectedIndex:d.selectedIndex,severityFilter:d.severityFilter,totalAll:d.all.length,viewportHeight:T}),ge=t?r(Yi,{hint:t.hint,message:t.message,severity:t.severity,title:t.title}):null,$e=r(rr,{finding:D,focused:d.focusedPanel==="detail",scrollRef:F});if(Y){const y=Math.floor(c*.4);return a(h,{flexDirection:"column",height:p,width:c,children:[ge,a(h,{flexDirection:"row",flexGrow:1,children:[r(h,{flexGrow:1,children:pe}),r(h,{width:y,children:$e})]}),ue,r(Je,{autoExitSeconds:e||3,onCancel:P(()=>{A(!1)},"onCancel"),visible:w}),he]})}return a(h,{flexDirection:"column",height:p,width:c,children:[ge,r(h,{height:O,children:pe}),r(h,{flexGrow:1,children:$e}),ue,r(Je,{autoExitSeconds:e||3,onCancel:P(()=>{A(!1)},"onCancel"),visible:w}),he]})},"VisDoctorApp");var wr=Object.defineProperty,ve=P((e,t)=>wr(e,"name",{value:t,configurable:!0}),"n");const vr=ve(e=>e.replaceAll(/[$()+.?[\\\]^{|}]/g,String.raw`\$&`),"escapeRegex"),br=ve(e=>{const t=e.split("*").map(i=>vr(i));return new RegExp(`^${t.join(".*")}$`,"i")},"compilePattern"),$r=ve(e=>e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>br(t)):[],"parseFilterPatterns"),Ne=ve((e,t)=>{for(const i of t)if(i.test(e))return!0;return!1},"matchesAny"),Sr=ve((e,t)=>{if(t.length===0)return e;const i=e.outdated.filter(d=>Ne(d.packageName,t)),s=e.duplicates.filter(d=>Ne(d.name,t)),o=e.optimizations.filter(d=>Ne(d.packageName,t));let l=0,c=0,p=0;for(const d of i)d.vulnerabilities&&(l+=d.vulnerabilities.length),d.socketReport&&(c+=d.socketReport.alerts.length,d.socketReport.score.overall<Le&&(p+=1));return{...e,duplicates:s,optimizations:o,outdated:i,socketIssues:{alerts:c,lowScore:p},vulnCount:l}},"applyFilter"),Ct=ve((e,t)=>t.length===0?[...e]:e.filter(i=>{if(i.kind==="runtime")return!0;const s=i.kind==="duplicate"?i.pkg.name:i.kind==="outdated"||i.kind==="optimization"?i.entry.packageName:i.packageName;return Ne(s,t)}),"filterFindingsByPattern");var Cr=Object.defineProperty,be=P((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"r");const xt=["dependencies","security","optimization","runtime"],rt=be(e=>{const t=new Set;if(!e)return t;for(const i of e.split(",")){const s=i.trim().toLowerCase();xt.includes(s)&&t.add(s)}return t},"parseSectionList"),xr=be((e,t)=>{if(e!==void 0&&e!=="")return rt(e);const i=rt(t);return new Set(xt.filter(s=>!i.has(s)))},"resolveSections"),Rt=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"),oe=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"),Rr=be((e,t)=>{const i=Rt(e.optimizations),s={dependencies:oe(e,"dependencies"),optimization:oe(e,"optimization"),runtime:oe(e,"runtime"),security:oe(e,"security")},o=new Set([...Object.values(s),e.supplyChain.status]),l=o.has("error")?"error":o.has("warn")?"warn":"ok";return{dependencies:{duplicates:e.duplicates.length,installed:e.installedCount,outdated:e.outdated.length,status:s.dependencies},elapsedMs:e.elapsedMs,optimizations:{microUtilities:i.micro,native:i.native,preferred:i.preferred,socket:i.socket,status:s.optimization,total:i.total},packageManager:t,runtime:e.runtime.map(c=>({detail:c.detail,id:c.id,message:c.message,status:c.status})),runtimeStatus:s.runtime,security:{alerts:e.socketIssues.alerts,lowScorePackages:e.socketIssues.lowScore,status:s.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"),nt=be((e,t)=>{const i=e.runtime.some(o=>o.status==="warn"),s=e.vulnCount>0||e.socketIssues.alerts>0;return t?s||e.outdated.length>0||e.duplicates.length>0||i:s},"shouldFail");var Tr=Object.defineProperty,_e=P((e,t)=>Tr(e,"name",{value:t,configurable:!0}),"i");const Ar=/^(@[\w./-]+\/[\w./-]+|[\w.-]+)@(.+)$/,Ir=_e(e=>{const t=Ar.exec(e);if(t)return{name:t[1],version:t[2]}},"parsePatchKey"),Dr=_e((e,t)=>{let i;try{if(t==="pnpm"){const o=te(e,"pnpm-workspace.yaml");Fe(o)&&(i=Mt(o)?.patchedDependencies)}else if(t==="bun"){const o=te(e,"package.json");Fe(o)&&(i=ht(o)?.patchedDependencies)}}catch{return[]}if(!i||typeof i!="object")return[];const s=[];for(const[o,l]of Object.entries(i)){if(typeof l!="string"||l.length===0)continue;const c=Ir(o);c&&s.push({name:c.name,patchFile:l,resolvedPatchFile:Ut(l)?l:pt(e,l),version:c.version})}return s},"readPatchedDependencies"),Pr=_e(e=>{const t=[];for(const i of e)Fe(i.resolvedPatchFile)||t.push({entry:i,kind:"missing-file"});return t},"findPatchIssues");var Or=Object.defineProperty,Tt=P((e,t)=>Or(e,"name",{value:t,configurable:!0}),"a");const ot=Tt(e=>e.some(t=>t.severity==="error")?"error":e.some(t=>t.severity==="warn")?"warn":"ok","rollUpStatus"),Nr=Tt((e,t={})=>{const i=[],s=e?.security;if(!s)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:ot(i)};s.minimumReleaseAge===void 0?i.push({detail:"Set security.minimumReleaseAge to block packages published in the last N minutes (mitigates supply-chain attacks).",label:"minimumReleaseAge is not set",severity:"warn"}):s.minimumReleaseAge===0?i.push({detail:"New packages can be installed immediately after publishing. Consider setting a non-zero cooldown.",label:"minimumReleaseAge is explicitly 0",severity:"warn"}):i.push({label:`minimumReleaseAge: ${String(s.minimumReleaseAge)} minutes`,severity:"ok"}),s.trustPolicy===void 0||s.trustPolicy==="off"?i.push({detail:"Packages whose trust level has decreased will not be blocked. Consider 'no-downgrade'.",label:`trustPolicy: ${s.trustPolicy??"not set"}`,severity:"warn"}):i.push({label:`trustPolicy: ${s.trustPolicy}`,severity:"ok"}),s.blockExoticSubdeps===void 0||!s.blockExoticSubdeps?i.push({detail:"Transitive dependencies can pull code from git repos or tarball URLs. Set to true to block.",label:`blockExoticSubdeps: ${String(s.blockExoticSubdeps??!1)}`,severity:"warn"}):i.push({label:"blockExoticSubdeps: true",severity:"ok"});const o=s.allowBuilds?Object.keys(s.allowBuilds).length:0;if(o===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:"allowBuilds: not configured",severity:"warn"}):i.push({label:`allowBuilds: ${String(o)} ${o===1?"entry":"entries"}`,severity:"ok"}),s.strictDepBuilds&&o===0&&i.push({detail:"All dependencies with build scripts will be blocked. Run 'vis approve-builds' to populate allowBuilds.",label:"strictDepBuilds is on but allowBuilds is empty",severity:"error"}),t.workspaceRoot){const l=ki(t.workspaceRoot);if(l.length>0){const c=[...new Set(l.map(p=>p.tool))].sort((p,d)=>p.localeCompare(d)).join(", ");i.push({detail:"Run `vis migrate verify` for the full list, then re-run `vis migrate <tool>` to clean up.",label:`${String(l.length)} leftover ${l.length===1?"reference":"references"} to ${c}`,severity:"warn"})}}if(t.workspaceRoot&&t.packageManager){const l=Dr(t.workspaceRoot,t.packageManager);if(l.length>0){const c=Pr(l);if(c.length===0)i.push({label:`patchedDependencies: ${String(l.length)} ${l.length===1?"entry":"entries"} resolved`,severity:"ok"});else for(const p of c)i.push({detail:`Referenced from ${t.packageManager==="pnpm"?"pnpm-workspace.yaml":"package.json"} but the file is not present at ${p.entry.patchFile}.`,label:`patchedDependencies: missing patch file for ${p.entry.name}@${p.entry.version}`,severity:"error"})}}return{findings:i,status:ot(i)}},"buildSupplyChainPosture");var Fr=Object.defineProperty,$=P((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"u");const G=$(e=>e>=1e3?`${(e/1e3).toFixed(1)}s`:`${String(Math.round(e))}ms`,"fmtDuration"),Pe=$(async(e,t,i,s)=>{if(!e)return i();e.start(t);const o=Date.now();try{const l=await i(),c=Date.now()-o,{status:p,summary:d}=s(l,c);return e.finish(t,p,d),l}catch(l){const c=Date.now()-o,p=l instanceof Error?l.message:String(l);throw e.finish(t,"error",`${p} (${G(c)})`),l}},"tracked"),Mr=$((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 bt(i)},"buildSectionFindings"),st=$(async e=>{const{filterPatterns:t,installed:i,progress:s,resolveCodemods:o,sections:l,store:c,visConfig:p,workspaceRoot:d}=e,S=l.has("dependencies"),R=l.has("security"),w=l.has("optimization"),A=l.has("runtime"),E=$((f,M)=>Ct(Mr(f,M),t),"sectionFindings"),g=at(d),{packageManager:I}=ct(d),B=Ze(te(d,"package.json"),!1),X=ft(d),L=new Set(B);for(const f of X){const M=Ze(te(pt(d,f),"package.json"),!1);for(const z of M)L.add(z)}const F=zt(d),D=dt(d,I),V=ut(p?.security?.socket),W=p?.security?.socket?.acceptedRisks,re=si(d,g.name),Y={exclude:[],ignore:[],include:[],includeLocked:!1,includePrerelease:!1,security:!0,target:"latest"},O=S?pi(d,g.name):[],U=w?li(L):[],K=w?ai(L,re,g,!1):[],v=new Set(U.map(f=>f.packageName)),T=K.filter(f=>!v.has(f.packageName)),C=[...U,...T],H=A?zi():[];c&&(S&&c.startSection("dependencies",D.size>0?"checking outdated catalog dependencies":"scanning duplicates"),R&&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:H}));const de=(S||R)&&D.size>0?Pe(s,"outdated",()=>jt(D,Y,F,void 0,d,V,W),(f,M)=>{const z=f.outdated.length;return{status:z>0?"warn":"ok",summary:z>0?`${String(z)} outdated · ${G(M)}`:`up to date · ${G(M)}`}}):Promise.resolve({failed:[],ignored:[],outdated:[]}),N=R&&i.length>0?Pe(s,"vulnerabilities",()=>Et(i.map(f=>({name:f.name,version:f.version}))),(f,M)=>{let z=0;for(const ne of f.values())z+=ne.length;return{status:z>0?"error":"ok",summary:z>0?`${String(z)} found · ${G(M)}`:`none found · ${G(M)}`}}):Promise.resolve(new Map),Q=R&&V&&i.length>0?Pe(s,"socket",()=>Bt(i.map(f=>({name:f.name,version:f.version})),V),(f,M)=>{let z=0,ne=0;for(const Ke of f.values())z+=Ke.alerts.length,Ke.score.overall<Le&&(ne+=1);const Ye=z+ne;return{status:Ye>0?"warn":"ok",summary:Ye>0?`${String(z)} alert${z===1?"":"s"}, ${String(ne)} low-score · ${G(M)}`:`clean · ${G(M)}`}}):Promise.resolve(new Map);let ee,ue,he,pe;const ge=de.catch(f=>(ee=f instanceof Error?f.message:String(f),c||u.warn(`Outdated scan failed: ${ee}`),{failed:[],ignored:[],outdated:[]})),$e=N.catch(f=>(ue=f instanceof Error?f.message:String(f),c||u.warn(`Vulnerability scan failed: ${ue}`),new Map)),y=Q.catch(f=>(he=f instanceof Error?f.message:String(f),c||u.warn(`Socket scan failed: ${he}`),new Map)),m=c&&S?ge.then(f=>{if(ee){c.failSection("dependencies",ee);return}c.completeSection("dependencies",E("dependencies",{duplicates:O,optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,k=c&&R?Promise.all([ge,$e,y]).then(([f])=>{const M=ee??ue??he;if(M){c.failSection("security",M);return}c.completeSection("security",E("security",{duplicates:[],optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,Se=(async()=>{if(o&&w&&C.length>0&&await Pe(s,"codemods",async()=>(await ci(C),C),(f,M)=>{const z=f.filter(ne=>ne.hasCodemod||ne.category==="socket").length;return{status:"ok",summary:`${String(z)} auto-fixable · ${G(M)}`}}).catch(f=>{pe=f instanceof Error?f.message:String(f)}),c&&w){if(pe){c.failSection("optimization",pe);return}c.completeSection("optimization",E("optimization",{duplicates:[],optimizations:C,outdated:[],runtime:[]}))}})(),[le,It,Dt]=await Promise.all([ge,$e,y]);await Promise.all([m,k,Se]);let He=0,Ge=0;if(R&&V)for(const f of Dt.values())He+=f.alerts.length,f.score.overall<Le&&(Ge+=1);let Ee=0;if(R){for(const f of le.outdated)f.vulnerabilities&&f.vulnerabilities.length>0&&(Ee+=f.vulnerabilities.length);for(const f of It.values())Ee+=f.length}return{duplicates:O,installedCount:i.length,optimizations:w?C:[],outdated:S?le.outdated:[],runtime:H,sections:l,socketIssues:{alerts:He,lowScore:Ge},supplyChain:Nr(p,{packageManager:I,workspaceRoot:d}),vulnCount:Ee,workspaceCount:X.length}},"streamScans"),zr=$(e=>{switch(e){case"error":return Re(j.failure);case"skip":return b(j.dash);case"warn":return ze(j.warning);default:return we(j.success)}},"sectionIcon"),ce=$((e,t)=>{const i=process.stderr.columns??80,s=Math.max(20,Math.min(i-2,60)),o=j.dash.repeat(2),l=`${zr(t)} ${ae(e)}`,c=l.replaceAll(/\[[0-9;]*m/g,"").length,p=Math.max(0,s-c-o.length-2);return`${o} ${l} ${b(j.dash.repeat(p))}`},"heading"),J=$(e=>` ${we(j.success)} ${e}`,"itemOk"),Z=$(e=>` ${ze(j.warning)} ${e}`,"itemWarn"),Ue=$(e=>` ${Re(j.failure)} ${e}`,"itemError"),At=$(e=>` ${b(j.dash)} ${b(e)}`,"itemSkip"),q=$((e,t,i)=>{const s=`${ae(String(e))} ${b(t)}`;return i?`${s} ${b(`(${i})`)}`:s},"countLine"),jr=$(e=>{if(e.sections.has("dependencies")){if(u.log(""),u.log(ce("Dependencies",oe(e,"dependencies"))),u.log(J(q(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,s=e.outdated.filter(l=>l.updateType==="patch").length,o=[];t>0&&o.push(`${String(t)} major`),i>0&&o.push(`${String(i)} minor`),s>0&&o.push(`${String(s)} patch`),u.log(Z(q(e.outdated.length,"outdated",o.join(", "))))}else u.log(J("All dependencies up to date"));e.duplicates.length>0?u.log(Z(q(e.duplicates.length,"packages with duplicate versions"))):u.log(J("No duplicate dependencies"))}},"displayDependencies"),Er=$(e=>{e.sections.has("security")&&(u.log(""),u.log(ce("Security",oe(e,"security"))),e.vulnCount>0?u.log(Ue(q(e.vulnCount,`vulnerabilit${e.vulnCount===1?"y":"ies"} found`))):u.log(J("No known vulnerabilities")),e.socketIssues.alerts>0&&u.log(Z(q(e.socketIssues.alerts,`Socket.dev security alert${e.socketIssues.alerts===1?"":"s"}`))),e.socketIssues.lowScore>0&&u.log(Z(q(e.socketIssues.lowScore,`package${e.socketIssues.lowScore===1?"":"s"} with low security score`))),e.socketIssues.alerts===0&&e.socketIssues.lowScore===0&&e.vulnCount===0&&u.log(J("No security issues detected")))},"displaySecurity"),Br=$(e=>{if(!e.sections.has("optimization"))return;u.log(""),u.log(ce("Optimization",oe(e,"optimization")));const t=Rt(e.optimizations);if(t.total===0){u.log(J("No optimizations available"));return}t.native>0&&u.log(Z(q(t.native,"replaceable with native APIs"))),t.preferred>0&&u.log(Z(q(t.preferred,"with lighter alternatives"))),t.micro>0&&u.log(Z(q(t.micro,"trivial micro-utilities"))),t.socket>0&&u.log(Z(q(t.socket,"@socketregistry overrides available")))},"displayOptimization"),Lr=$(e=>{u.log(""),u.log(ce("Supply Chain",e.supplyChain.status));for(const t of e.supplyChain.findings){const i=t.severity==="ok"?J(t.label):t.severity==="error"?Ue(t.label):Z(t.label);u.log(i),t.detail&&u.log(` ${b(j.arrow)} ${b(t.detail)}`)}e.supplyChain.status!=="ok"&&u.log(` ${b(j.arrow)} ${b("Configure with security.* in vis.config.ts. See `vis check --security-config` for details.")}`)},"displaySupplyChain"),Vr=$(e=>{if(e.sections.has("runtime")){u.log(""),u.log(ce("Runtime",oe(e,"runtime")));for(const t of e.runtime)t.status==="ok"?u.log(J(t.message)):t.status==="skip"?u.log(At(t.message)):u.log(Z(t.message))}},"displayRuntime"),_r=$((e,t)=>{const i=e.vulnCount,s=e.runtime.filter(l=>l.status==="warn").length,o=e.outdated.length+e.duplicates.length+e.optimizations.length+s;if(t){if(i===0&&o===0)u.success(`Everything looks good! ${b(`(${G(e.elapsedMs)})`)}`);else{const l=[];i>0&&l.push(Re(`${String(i)} security`)),o>0&&l.push(ze(`${String(o)} improvement${o===1?"":"s"}`)),u.log(`${Re(j.failure)} ${l.join(", ")} ${b(`(${G(e.elapsedMs)})`)}`)}return}u.log(""),u.log(ce("Summary","ok")),i===0&&o===0?u.success(`Everything looks good! ${b(`(${G(e.elapsedMs)})`)}`):(i>0&&u.error(`${String(i)} security issue${i===1?"":"s"}`),o>0&&u.log(` ${Te(j.arrow)} ${ae(String(o))} ${b(`improvement${o===1?"":"s"} available`)} ${b(`(${G(e.elapsedMs)})`)}`))},"displaySummary"),Ur=$(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){u.log(""),u.log(ae("Next steps:"));for(const i of t)u.log(` ${b(j.arrow)} ${i}`)}u.log("")},"displayActions"),Hr=$((e,t)=>{t||(jr(e),Er(e),Br(e),Vr(e),Lr(e)),_r(e,t)},"displayResults"),Gr=$((e,t,i,s,o)=>{const l=[],c=e.has("dependencies"),p=e.has("security"),d=e.has("optimization");return(c||p)&&t>0&&l.push({id:"outdated",label:"Outdated catalog dependencies"}),p&&s>0&&l.push({id:"vulnerabilities",label:"Known vulnerabilities (OSV)"}),p&&i&&s>0&&l.push({id:"socket",label:"Socket.dev supply-chain reports"}),d&&o&&l.push({id:"codemods",label:"Codemod availability"}),l},"planScanTasks"),Yr=$(e=>{if(u.log(""),u.log(`${ae(Te("vis doctor"))} ${b("— project health check")}`),u.log(J(`Detected ${e.packageManagerName} v${e.packageManagerVersion}`)),e.workspaceCount!==void 0&&e.workspaceCount>0&&u.log(J(q(e.workspaceCount,`workspace package${e.workspaceCount===1?"":"s"}`))),e.runtimeFindings.length===0)u.log(J(`Node.js ${e.nodeVersion}`));else{for(const t of e.runtimeFindings){const i=t.severity==="error"?Re:ze;u.log(Ue(`Runtime: ${i(t.message)}`))}u.log(` ${b(j.arrow)} Run ${we("vis toolchain install")} to install pinned versions, or ${we("vis toolchain status")} for the per-tool breakdown.`)}u.log("")},"printBanner"),cn=$(async({logger:e,options:t,visConfig:i,visConfigError:s,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root.");const l=t.format==="json"||t.json===!0,c=xr(t.only,t.skip),p=!!t.quiet,d=t.progress===!1,S=$r(t.filter);if(c.size===0){u.error("No sections selected. Check your --only / --skip values."),process.exitCode=2;return}const R=Date.now(),w=at(o),A=hi(o),E=!!process.stdout.isTTY,g=!l&&E&&!Lt&&!p&&!d;!l&&!g&&Yr({nodeVersion:process.versions.node,packageManagerName:w.name,packageManagerVersion:w.version,runtimeFindings:A,workspaceCount:void 0});const I=dt(o,ct(o).packageManager),B=gi(o,w.name),X=B.length,L=!!ut(i?.security?.socket),F=ft(o);if(!l&&!p&&!g){const N=F.length>0?b(` · ${String(F.length)} workspace package${F.length===1?"":"s"}`):"";u.log(`${b("·")} ${b("Found")} ${ae(String(X))} ${b(`installed package${X===1?"":"s"}`)}${N}`)}const D=s?{hint:s.file?`Continuing with default settings — fix or regenerate ${s.file} (vis init --force).`:"Continuing with default settings.",message:s.message,severity:"error",title:s.file?`Failed to load ${s.file}`:"Failed to load vis.config"}:void 0,V={bun:"bun.lock",npm:"package-lock.json",pnpm:"pnpm-lock.yaml",yarn:"yarn.lock"}[w.name],W=V?te(o,V):void 0,re=oi(o),Y=t.cache!==!1&&!t.fix?$i({configPath:re,lockfilePath:W,sections:c,socketEnabled:L,workspaceRoot:o}):void 0,O=Y?Si(Y):void 0,U=O!==void 0;let K,v;if(g){const N=O?new tt({activeSections:c,findings:Ct(bt(O),S)}):new tt({activeSections:c}),Q=Qt(Zt.createElement(kr,{banner:D,fromCache:U,startedAt:R,store:N}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0});try{K=O??await st({filterPatterns:S,installed:B,resolveCodemods:!!t.fix,sections:c,store:N,visConfig:i,workspaceRoot:o})}catch(ee){throw Q.unmount(),ee}await Q.waitUntilExit(),v=N.getSnapshot().pendingAction}else if(O)K=O;else{const N=Gr(c,I.size,L,X,!!t.fix),Q=fi(N,{live:!l&&!p&&!d});try{K=await st({filterPatterns:S,installed:B,progress:Q,resolveCodemods:!!t.fix,sections:c,visConfig:i,workspaceRoot:o})}finally{Q.stop()}}const T={...K,elapsedMs:Date.now()-R};if(Y&&!U)try{Ci(Y,T)}catch{}const C=Sr(T,S);if(l){process.stdout.write(`${JSON.stringify(Rr(C,w.name),void 0,2)}
4
+ `),t.exitCode&&nt(C,!!t.strict)&&(process.exitCode=1);return}U&&!p&&u.log(`${b("·")} Cached results (use --no-cache to refresh)`),S.length>0&&!p&&u.log(`${b("·")} Filter active: ${Te(t.filter??"")}`),Hr(C,p);const H=C.runtime.some(N=>N.id===Oe&&N.status==="warn"),de=C.sections.has("optimization")&&C.optimizations.length>0;t.fix&&(de||H)?await Kr({force:!!t.fixForce,logger:e,pm:w,recoverOrphans:H,results:C,useEditorconfig:i?.editorconfig??!0,workspaceRoot:o}):p||Ur(C),v&&(process.stdout.write(`
5
+ `),process.stdout.write(`${ae("→ ")}${v.description}
6
+ `),v.configSnippet?(process.stdout.write(`
7
+ `),process.stdout.write(`${b(v.configSnippet)}
8
+ `)):process.stdout.write(` ${Te(v.command)}
9
+ `),process.stdout.write(`
10
+ `)),t.exitCode&&nt(C,!!t.strict)&&(process.exitCode=1)},"execute"),Kr=$(async e=>{const{force:t,logger:i,pm:s,recoverOrphans:o,results:l,useEditorconfig:c,workspaceRoot:p}=e;u.log(""),u.log(ce("Applying fixes","ok"));const d=l.optimizations.filter(g=>g.category==="socket"&&g.overrideSpec).map(g=>({original:g.packageName,spec:g.overrideSpec})),S=l.optimizations.filter(g=>g.category!=="socket"&&g.hasCodemod),R=l.optimizations.filter(g=>g.category!=="socket"&&!g.hasCodemod);let w=!1,A=0;const E=[];if(o){const g=Di({force:t});if(g.killed.length>0&&(u.success(`Cleaned up ${String(g.killed.length)} orphaned process${g.killed.length===1?"":"es"} (PIDs: ${g.killed.join(", ")}).`),w=!0),g.failed.length>0){const I=t?"":" Re-run with `--fix --fix-force` to escalate to SIGKILL.";u.warn(`Could not signal ${String(g.failed.length)} orphan${g.failed.length===1?"":"s"}: ${g.failed.map(B=>`${String(B.pid)} (${B.reason})`).join(", ")}.${I}`)}}if(d.length>0){const g=di(p,te(p,"package.json"),d,s,c);g.added.length>0&&(u.success(`Added ${String(g.added.length)} security override${g.added.length===1?"":"s"}.`),w=!0),g.updated.length>0&&(u.success(`Updated ${String(g.updated.length)} override${g.updated.length===1?"":"s"}.`),w=!0)}for(const g of S)try{const I=await ui(p,g.packageName);I.filesChanged>0&&(u.success(`${g.packageName}: ${String(I.filesChanged)} file${I.filesChanged===1?"":"s"} updated`),A+=1,w=!0)}catch(I){const B=I instanceof Error?I.message:String(I);E.push({error:B,package:g.packageName}),u.warn(`${g.packageName}: codemod failed — ${B}`)}d.length>0&&(u.log(`${Te(j.arrow)} Running ${s.name} install to update lockfile…`),Vt(s,{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),u.log(""),w?u.success(`Fixes applied. ${A>0?`${String(A)} codemod${A===1?"":"s"} applied.`:""}`.trim()):u.log(At("No auto-fixable items in the current run.")),E.length>0&&u.warn(`${String(E.length)} codemod${E.length===1?"":"s"} failed (run ${we("vis optimize")} for the interactive picker).`),R.length>0&&u.notice(`${String(R.length)} optimization${R.length===1?"":"s"} need manual review (no codemod). Run ${we("vis optimize")} to inspect them.`)},"runFixes");export{cn as default};